Skip to content

fix(middleware-sdk-s3): missing dependency with esbuild #2814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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