Skip to content
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

fix(middleware-websocket): pass options to presign in WebsocketSignatureV4 sign #5015

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions packages/middleware-websocket/src/WebsocketSignatureV4.spec.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading