Skip to content

Feat/webhook handling - #114

Merged
jhayniffy merged 2 commits into
InsurNiffy:mainfrom
Petah1:feat/webhook-handling
Mar 25, 2026
Merged

Feat/webhook handling#114
jhayniffy merged 2 commits into
InsurNiffy:mainfrom
Petah1:feat/webhook-handling

Conversation

@Petah1

@Petah1 Petah1 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements `POST /webhooks/:provider` with per-provider HMAC verification, idempotency, and async job enqueueing.

Providers

  • `github` — HMAC-SHA256 via `X-Hub-Signature-256`, dedup via `X-GitHub-Delivery`
  • `stripe` — Stripe-Signature `t=,v1=` scheme with timestamp tolerance
  • `generic` — HMAC-SHA256 with `X-Webhook-Timestamp` + `X-Webhook-Id`

Key features

  • Constant-time signature comparison (`timingSafeEqual`) on all providers
  • Timestamp validation rejects replays outside the 300s tolerance window
  • Idempotency dedup — duplicates return `200 {status: duplicate}` without re-enqueueing
  • Zero-downtime secret rotation: `secrets` is an array, list old + new during rollover
  • BullMQ-compatible in-memory queue (swap for real BullMQ + Redis when available)
  • Verification failures log provider + reason only — no secrets or bodies exposed
  • Optional per-provider IP allowlisting
  • `GET /webhooks/queue/stats` for observability
  • 16 tests covering valid requests, bad signatures, replay attacks, duplicates, IP blocking, rotation

Closes #45

@drips-wave

drips-wave Bot commented Mar 24, 2026

Copy link
Copy Markdown

@Petah1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@jhayniffy
jhayniffy merged commit 4fda629 into InsurNiffy:main Mar 25, 2026
0 of 3 checks passed
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.

Backend — Webhook ingress: signature verification, async queues, and deduplication

2 participants