Skip to content

feat(webhooks): export standalone verifyWebhookSignature with timingSafeEqual and WebhookVerificationError (#617) - #723

Closed
s6pa1rta3n-lab wants to merge 1 commit into
Stellar-split:mainfrom
s6pa1rta3n-lab:feat/issue-617-verify-webhook-signature
Closed

feat(webhooks): export standalone verifyWebhookSignature with timingSafeEqual and WebhookVerificationError (#617)#723
s6pa1rta3n-lab wants to merge 1 commit into
Stellar-split:mainfrom
s6pa1rta3n-lab:feat/issue-617-verify-webhook-signature

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary of Changes

  • Exposes verifyWebhookSignature as a standalone utility from src/webhooks/verify.ts and re-exports it from src/index.ts.
  • Computes HMAC-SHA256 digest over the raw payload and performs constant-time comparison via crypto.timingSafeEqual to prevent timing attacks.
  • Gracefully handles malformed hex signatures, mismatched lengths, and non-string inputs by returning false without throwing.
  • Introduces and exports WebhookVerificationError and assertWebhookSignature for consumers requiring throwing assertion flows.
  • Adds comprehensive unit tests in test/webhooks/verify.test.ts covering valid signatures, invalid keys, tampered payloads, odd-length signatures, and export verification.

Closes #617
/claim #617

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export verifyWebhookSignature as standalone function from webhooks/verify.ts

2 participants