Skip to content

feat: add webhook signature verification - #75

Merged
Abd-Standard merged 4 commits into
Core-Foundry:mainfrom
MerlinTheWhiz:feature/webhook-signature-verification
Jun 20, 2026
Merged

feat: add webhook signature verification#75
Abd-Standard merged 4 commits into
Core-Foundry:mainfrom
MerlinTheWhiz:feature/webhook-signature-verification

Conversation

@MerlinTheWhiz

Copy link
Copy Markdown
Contributor

Closes #29

Changes Made
New files

  • listener/src/services/webhook-verifier.ts — HMAC-SHA256 signature verification module with:
    • verifySignature() — constant-time comparison via crypto.timingSafeEqual
    • extractSignature() / extractKeyId() — header extraction (case-insensitive, supports X-Webhook-Signature and X-Webhook-Key-Id)
    • getSecretForKey() — secret lookup by key ID (supports key rotation)
    • collectRawBody() — raw body stream collection
    • listener/src/services/webhook-verifier.test.ts — 15 tests covering valid/invalid signatures, missing headers, unknown keys, constant-time comparison, empty payloads

Modified files

  • listener/src/types/index.ts:18-21 — added WebhookSecret interface ({id, secret}); added webhookSecrets?: WebhookSecret[] to Config
  • listener/src/config.ts:87-110 — added validateWebhookSecrets() with validation; parses WEBHOOK_SECRETS env var
  • listener/src/config.test.ts — 5 tests: defaults, valid parse, invalid JSON, missing id/secret, non-array value
  • listener/src/api/events-server.ts — added POST /api/webhooks handler that extracts headers, looks up secret by key ID, verifies HMAC, returns 202 (accepted) or 401 (with descriptive error)
  • listener/src/api/events-server.test.ts — 6 tests: valid signature, invalid signature, missing signature header, missing key-id, unknown key-id, no secrets configured, non-webhook POST
  • listener/.env.example — documented WEBHOOK_SECRETS env var

Screenshot:
image

@Abd-Standard

Copy link
Copy Markdown
Collaborator

please fix resolve conflicts

@MerlinTheWhiz

Copy link
Copy Markdown
Contributor Author

@Abd-Standard Alright, give me a sec.

@MerlinTheWhiz

Copy link
Copy Markdown
Contributor Author

@Abd-Standard Yh I'm done resolving the conflicts.

@Abd-Standard

Copy link
Copy Markdown
Collaborator

conflicts still shows , please resolve it

@MerlinTheWhiz

Copy link
Copy Markdown
Contributor Author

conflicts still shows , please resolve it

@Abd-Standard That is because you merged a PR that conflicted with it again

image

Also, why are you merging the PR with number 109 before mine that is 75? How do you priortise PR?

I will resolve it again, please merge mine before merging others that I clearly completed mine before them.

@MerlinTheWhiz

Copy link
Copy Markdown
Contributor Author

@Abd-Standard I've resolve it again, now please merge:

image

@Abd-Standard
Abd-Standard merged commit 96c28a2 into Core-Foundry:main Jun 20, 2026
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.

Add Webhook Signature Verification

2 participants