Skip to content

Commit

Permalink
fix(middleware-sdk-s3): missing dependency with esbuild (#2814)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP committed Sep 24, 2021
1 parent d01420b commit d5924e9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/middleware-sdk-s3/src/S3SignatureV4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class S3SignatureV4 implements RequestPresigner, RequestSigner {
if (options.signingRegion === "*") {
if (this.signerOptions.runtime !== "node")
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
return (await this.getSigv4aSigner()).sign(requestToSign, options);
return this.getSigv4aSigner().sign(requestToSign, options);
}
return this.sigv4Signer.sign(requestToSign, options);
}
Expand All @@ -44,16 +44,17 @@ export class S3SignatureV4 implements RequestPresigner, RequestSigner {
if (options.signingRegion === "*") {
if (this.signerOptions.runtime !== "node")
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
return (await this.getSigv4aSigner()).presign(originalRequest, options);
return this.getSigv4aSigner().presign(originalRequest, options);
}
return this.sigv4Signer.presign(originalRequest, options);
}

private async getSigv4aSigner(): Promise<CrtSignerV4> {
private getSigv4aSigner(): CrtSignerV4 {
if (!this.sigv4aSigner) {
let CrtSignerV4: new (options: CrtSignerV4Init & SignatureV4CryptoInit) => CrtSignerV4;
try {
CrtSignerV4 = (await import("@aws-sdk/signature-v4-crt")).CrtSignerV4;
CrtSignerV4 = require("@aws-sdk/signature-v4-crt").CrtSignerV4;
if (typeof CrtSignerV4 !== "function") throw new Error();
} catch (e) {
e.message =
`${e.message}\nPlease check if you have installed "@aws-sdk/signature-v4-crt" package explicitly. \n` +
Expand Down

0 comments on commit d5924e9

Please sign in to comment.