fix(listen): preserve webhook signatures when forwarding#25
Open
bgrcs wants to merge 1 commit into
Open
Conversation
liamdebellada
approved these changes
Jul 10, 2026
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.
I was trying out the CLI for local development with hooks and unfortunately ran into a few issues.
Events forwarded by
polar listenfail signature verification if my org uses usage based billing. Anything carrying meter data gets rejected byvalidateEventfrom@polar-sh/sdk, but other events are fine:The main reason this is an issue is because metering payloads have floats like
"consumed_units": 0.0, JS stringifies that as0, and the webhook signature no longer matches for the body bytes.I changed it to parse the frame with lossless-json, which keeps the original number literals, so the rebuilt body is byte for byte what Polar signed.
Added tests for the reconstruction and also tested against sandbox with a local endpoint verifying via
validateEvent:customer.state_changedgets 403 on main and 202 on this branch.