fix(webhooks): forward Standard Webhooks headers from listen --forward-to#41
Open
jflayhart wants to merge 1 commit into
Open
fix(webhooks): forward Standard Webhooks headers from listen --forward-to#41jflayhart wants to merge 1 commit into
jflayhart wants to merge 1 commit into
Conversation
…d-to
`linq webhooks listen --forward-to` signed forwarded events with only the legacy
scheme — HMAC-SHA256 over `{timestamp}.{body}`, hex, in X-Webhook-Signature.
Production sends that too, but it leads with Standard Webhooks: webhook-id,
webhook-timestamp, and webhook-signature (`v1,<base64>` over
`{webhook-id}.{webhook-timestamp}.{body}`, keyed on the decoded secret).
That gap breaks the documented local-development loop. A handler written against
`client.webhooks.unwrap()` — the SDK helper we point developers at — needs the
Standard Webhooks headers, so it rejected everything the forwarder sent while
working correctly in production. The natural response to a handler that drops
100% of local traffic is to delete the verification, which is the opposite of
what we want people shipping.
The forwarder now emits both header sets, matching the dispatcher. The legacy
pair stays so existing handlers keep working.
decodeSigningSecret is a faithful port of the dispatcher's, including the
url-safe and raw-bytes fallbacks for legacy secrets. Go's base64 decoders reject
invalid characters while Node's silently drop them, so the charset is checked
explicitly rather than relying on Buffer.from.
Tested: signatures produced here are accepted by the SDK's unwrap(), with
negative controls for a tampered body and a wrong secret. 179 tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
linq webhooks listen --forward-tosigned forwarded events with only the legacy scheme — HMAC-SHA256 over{timestamp}.{body}, hex, inX-Webhook-Signature.Production (
webhook-service/internal/dispatcher/dispatcher.go) sends that too, but leads with Standard Webhooks:So the local forwarder never emitted
webhook-id,webhook-timestamp, orwebhook-signature.That breaks the documented development loop. A handler written against
client.webhooks.unwrap()— the helper we point developers at — requires the Standard Webhooks headers. It therefore rejected everything the forwarder sent, while working correctly in production. The natural response to a handler that drops 100% of local traffic is to delete the verification, which is the opposite of what we want people shipping.The change
The forwarder now emits both header sets, matching the dispatcher. The legacy pair stays so existing handlers keep working.
decodeSigningSecretis a faithful port of the dispatcher's, including the url-safe and raw-bytes fallbacks for legacy secrets. Worth a look during review: Go's base64 decoders reject invalid characters, while Node's silently drop them, so the charset is checked explicitly rather than relying onBuffer.fromto fail.Verification
7 new tests, 179 passing overall:
unwrap()decodeSigningSecretcoverswhsec_-prefixed, bare legacy, url-safe, and non-base64 secrets🤖 Generated with Claude Code
https://claude.ai/code/session_01L3QhRZE6nKoGLGNhzUkmmF