feat(sdk): add standardWebhooks.verify for Standard Webhooks (Svix) signature verification - #4930
Conversation
…ignature verification Adds a first-class helper for verifying webhooks that follow the Standard Webhooks spec (https://www.standardwebhooks.com/), used by Stripe, GitHub, Slack, Linear, Shopify, Composio, Resend, Novu, Knock, Courier, ngrok, and all Svix-native providers. The helper handles the composed signature format that the existing verifyRequestSignature helper does not cover: HMAC-SHA256 over `${webhook-id}.${webhook-timestamp}.${raw_body}` with a `v1,<base64>` prefix, base64-decoded secret, multi-signature support, and a configurable timestamp tolerance window (default 300 seconds per the spec). API: import { standardWebhooks } from "@trigger.dev/sdk"; const result = await standardWebhooks.verify(request, secret); // result.payload — parsed JSON // result.raw — raw body string // disable the anti-replay tolerance check: await standardWebhooks.verify(request, secret, { tolerance: 0 }); Throws WebhookError on missing headers, unsupported signature version, bad signature, or out-of-tolerance timestamps. Refs triggerdotdev#4928
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
WalkthroughAdds the exported ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @bobclarkdramisinfo, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
Title :
feat(sdk): add standardWebhooks.verify for Standard Webhooks (Svix) signature verificationSummary
Adds a
standardWebhooks.verifyhelper to@trigger.dev/sdkthat verifies webhook signatures following the Standard Webhooks spec — used by Stripe, GitHub, Slack, Linear, Shopify, Composio, Resend, Novu, Knock, Courier, ngrok, and most Svix-native providers.The current
verifyRequestSignaturehelper only covers single-header signature schemes (Stripe/GitHub/Cal.com/Novu style). Every user integrating Trigger.dev with a Standard Webhooks provider currently hand-rolls the same ~50 lines of crypto. This helper wraps a small spec-compliant verification function and re-uses the existingWebhookErrorshape.What's in the change
packages/trigger-sdk/src/v3/webhooks.ts— additive only:standardWebhooks.verify(request, secret, options?)— verifies the composed signature, returns{ payload, raw }standardWebhooks.TOLERANCE_SECONDS = 300(per the Standard Webhooks spec)v1,a v1,bseparated by space — accepts any one match)v1,v1a,v1bsignature versions; throwsWebhookError("unsupported signature version")otherwise${webhook-id}.${webhook-timestamp}.${raw_body}with base64-decoded secrettimingSafeEqualcompare (constant-time){ tolerance: 0 }to disable the anti-replay checkpackages/trigger-sdk/src/v3/webhooks.test.ts— 25 test cases covering happy path, all error modes, edge cases (boundary timestamps, multi-signature, empty secret, version variants).packages/trigger-sdk/src/v3/webhooks.test-fixtures.ts— known-good test vectors saved as constants, reviewable.Usage
Why now
The Standard Webhooks spec keeps winning — Stripe and GitHub both migrated to it. Every new Standard Webhooks integration in Trigger.dev costs ~50 lines of crypto boilerplate. This closes the gap without absorbing integration logic (per the SDK's
verifyRequestSignaturedesign pattern).Refs
Checklist