Skip to content

Commit

Permalink
Merge pull request #371 from felixarjuna/fix-verify-signature-double-…
Browse files Browse the repository at this point in the history
…negation

Fix verify signature double negation
  • Loading branch information
Secreto31126 authored Sep 6, 2024
2 parents 441e43d + d3bea58 commit 56620c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit 56620c6

Please sign in to comment.