Description
src/webhooks/webhook.signature.ts provides signing utilities, but inbound webhook routes must verify signatures and reject replays. This backend task adds signature-verification middleware to src/webhooks/webhook.routes.ts, including timestamp tolerance and a timing-safe comparison to prevent forged callbacks.
Requirements and Context
- Verify the HMAC signature header against the raw request body.
- Reject requests outside a configurable timestamp tolerance window (replay protection).
- Use timing-safe comparison and return 401 on mismatch.
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b feature/webhook-signature-verification
- Implement changes
src/webhooks/webhook.routes.ts — add verify middleware
src/webhooks/webhook.signature.ts — add verify helper
- Preserve raw body for verification
- Test and commit
npm test -- src/webhooks/webhook.signature.test.ts src/webhooks/webhook.auth.test.ts
- Cover edge cases
- Include test output and notes in the PR
Example commit message
feat: verify HMAC signatures on inbound webhooks
Acceptance Criteria
Guidelines
- Minimum 90% test coverage with Jest
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
src/webhooks/webhook.signature.tsprovides signing utilities, but inbound webhook routes must verify signatures and reject replays. This backend task adds signature-verification middleware tosrc/webhooks/webhook.routes.ts, including timestamp tolerance and a timing-safe comparison to prevent forged callbacks.Requirements and Context
Suggested Execution
src/webhooks/webhook.routes.ts— add verify middlewaresrc/webhooks/webhook.signature.ts— add verify helpernpm test -- src/webhooks/webhook.signature.test.ts src/webhooks/webhook.auth.test.tsExample commit message
Acceptance Criteria
Guidelines