Skip to content

Commit

Permalink
fix(middleware-websocket): pass options to presign in WebsocketSignat…
Browse files Browse the repository at this point in the history
…ureV4 sign (#5015)
  • Loading branch information
trivikr committed Jul 26, 2023
1 parent e8f3d8f commit 3663a9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/middleware-websocket/src/WebsocketSignatureV4.spec.ts
Expand Up @@ -58,7 +58,7 @@ describe("WebsocketSignatureV4", () => {
(isInstance as unknown as jest.Mock).mockReturnValueOnce(true);
});

const expectSignArgs = (result: any) => {
const expectSignArgs = (result: any, options: RequestPresigningArguments = {}) => {
expect(result).toStrictEqual({
...mockPresignedRequest,
body: request.body,
Expand All @@ -69,6 +69,7 @@ describe("WebsocketSignatureV4", () => {
expect(presign).toHaveBeenCalledWith(
{ ...request, body: "" },
{
...options,
expiresIn: 60,
unsignableHeaders: new Set(Object.keys(request.headers).filter((header) => header !== "host")),
}
Expand All @@ -82,11 +83,10 @@ describe("WebsocketSignatureV4", () => {
});

it("with options", async () => {
const options = {
unsignableHeaders: new Set(Object.keys(headers)),
};
const signingDate = new Date();
const options = { signingDate };
const result = await sigV4.sign(request as any, options);
expectSignArgs(result);
expectSignArgs(result, options);
});
});

Expand Down
1 change: 1 addition & 0 deletions packages/middleware-websocket/src/WebsocketSignatureV4.ts
Expand Up @@ -27,6 +27,7 @@ export class WebsocketSignatureV4 implements RequestSigner, RequestPresigner {
const signedRequest = await this.signer.presign(
{ ...toSign, body: "" },
{
...options,
// presigned url must be expired within 1 min.
expiresIn: 60,
// Not to sign headers. Transcribe-streaming WebSocket
Expand Down

0 comments on commit 3663a9b

Please sign in to comment.