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 verify signature double negation #371

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 src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ export class WhatsAppAPI<EmittersReturnType = void> {
.map((b) => b.toString(16).padStart(2, "0"))
.join("");

return signature !== check;
return signature === check;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion test/index.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,11 @@ describe("WhatsAppAPI", function () {

it("should throw 401 if the signature doesn't match the hash", async function () {
await rejects(
Whatsapp.post(valid_message_mock, body, "wrong"),
Whatsapp.post(
valid_message_mock,
body,
"sha256=wrong"
),
threw(401)
);
});
Expand Down