Fix Shopify HMAC base64 verification and improve webhook error diagnostics#33
Merged
Prateek32177 merged 1 commit intomainfrom Feb 19, 2026
Merged
Conversation
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.
Motivation
X-Shopify-Hmac-SHA256signature is base64-encoded while the verifier previously treated some providers as hex/Clerk-style secrets.verifyAny()returned opaque failures when multiple platform attempts existed, making it hard to debug which platform or reason failed.errorCodeandmetadatamakes failures actionable for integrators.Description
src/platforms/algorithms.tsto treat Shopify as a base64-signed HMAC (headerName: 'x-shopify-hmac-sha256',customConfig.encoding: 'base64',customConfig.secretEncoding: 'utf8') and finalized Polar’s Standard Webhooks config (webhook-signature,webhook-timestamp,customConfigpayload).src/verifiers/algorithms.tsby decoding the secret only whenconfig.customConfig?.secretEncoding === 'base64'and handling underscore-prefixed secret formats safely; Shopify secrets remain UTF-8 and are not base64-decoded.src/index.tsby collecting per-platformfailedAttemptsand returning an aggregatederrorstring plusmetadata.attemptscontaining{ platform, error, errorCode }for each attempt.src/adapters/express.ts,src/adapters/nextjs.ts, andsrc/adapters/cloudflare.tsto includeerrorCodeandmetadatain 400 responses to aid troubleshooting.src/utils.tsandsrc/index.tsso Polar can be auto-detected fromwebhook-signaturewith a Polaruser-agent.src/test.tsfor Shopify verification,verifyAnydiagnostic reporting, and Polar Standard Webhooks, and updated documentation inREADME.md,USAGE.md,FRAMEWORK_SUMMARY.md, andARCHITECTURE.mdto reflect these behaviors.Testing
npm run build, which completed successfully.npm test; tests were iterated during fixes and the final run shows all tests passing (dist/test.jsexecution completed with all test cases PASSED).Codex Task