Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kuestcom/builder-signing-sdk",
"description": "Kuest SDK for creating builder headers",
"version": "2.0.1",
"version": "2.0.2",
"repository": {
"type": "git",
"url": "git+https://github.com/kuestcom/builder-signing-sdk.git"
Expand Down
3 changes: 2 additions & 1 deletion src/signing/hmac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const buildHmacSignature = (
requestPath: string,
body?: string,
): string => {
let message = timestamp + method + requestPath;
const signingPath = requestPath.split("?")[0];
let message = timestamp + method + signingPath;
if (body !== undefined) {
message += body;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/hmac.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,23 @@ describe("hmac", () => {
expect(signature.length).toBeGreaterThan(0);
expect(signature).toBe("ZwAdJKvoYRlEKDkNMwd5BuwNNtg93kNaR_oU2HrfVvc=");
});

it("excludes query parameters from the signing path", () => {
const pathSignature = buildHmacSignature(
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
1000000,
"test-sign",
"/orders",
'{"hash": "0x123"}',
);
const querySignature = buildHmacSignature(
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
1000000,
"test-sign",
"/orders?market=condition",
'{"hash": "0x123"}',
);

expect(querySignature).toBe(pathSignature);
});
});
Loading