Skip to content

Commit

Permalink
chore(signature-v4-multi-region): cleanups and docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
siddsriv committed Jul 11, 2024
1 parent c4f2e54 commit b4f86d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/signature-v4-multi-region/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@aws-sdk/types": "*",
"@smithy/protocol-http": "^4.0.3",
"@smithy/signature-v4": "^3.1.2",
"@smithy/signature-v4a": "*",
"@smithy/types": "^3.3.0",
"tslib": "^2.6.2"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/signature-v4-multi-region/src/SignatureV4MultiRegion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class SignatureV4MultiRegion implements RequestPresigner, RequestSigner {
private getSigv4aSigner(): InstanceType<OptionalCrtSignerV4> | InstanceType<OptionalSigV4aSigner> {
if (!this.sigv4aSigner) {
let CrtSignerV4: OptionalCrtSignerV4 | null = null;
let JsSigV4a: OptionalSigV4aSigner | null = null;
let JsSigV4aSigner: OptionalSigV4aSigner | null = null;

if (signatureV4CrtContainer.CrtSignerV4) {
try {
Expand All @@ -102,8 +102,8 @@ export class SignatureV4MultiRegion implements RequestPresigner, RequestSigner {
});
} else if (signatureV4aContainer.SignatureV4a) {
try {
JsSigV4a = signatureV4aContainer.SignatureV4a;
if (typeof JsSigV4a !== "function") throw new Error();
JsSigV4aSigner = signatureV4aContainer.SignatureV4a;
if (typeof JsSigV4aSigner !== "function") throw new Error();
} catch (e) {
e.message =
`${e.message}\n` +
Expand All @@ -113,13 +113,13 @@ export class SignatureV4MultiRegion implements RequestPresigner, RequestSigner {
throw e;
}

this.sigv4aSigner = new JsSigV4a({
this.sigv4aSigner = new JsSigV4aSigner({
...this.signerOptions,
});
} else {
throw new Error(
"Neither CRT nor JS SigV4a implementation is available. " +
"Please load either @aws-sdk/signature-v4-crt or @smithy/signature-v4a."
"Please load either @aws-sdk/signature-v4-crt or @smithy/signature-v4a."
);
}
}
Expand Down
11 changes: 11 additions & 0 deletions packages/signature-v4-multi-region/src/signature-v4a-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import type { HttpRequest, RequestPresigner, RequestSigner, RequestSigningArgume
* @public
*/
export type OptionalSigV4aSigner = {
/**
* This constructor is not typed so as not to require a type import
* from the signature-v4a package.
*
* The true type is SignatureV4a from @smithy/signature-v4a.
*/
new (options: any): RequestPresigner &
RequestSigner & {
signWithCredentials(
Expand All @@ -17,6 +23,11 @@ export type OptionalSigV4aSigner = {

/**
* @public
*
* \@smithy/signature-v4a will install the constructor in this
* container if it is installed.
*
* This avoids a runtime-require being interpreted statically by bundlers.
*/
export const signatureV4aContainer: {
SignatureV4a: null | OptionalSigV4aSigner;
Expand Down

0 comments on commit b4f86d9

Please sign in to comment.