fix(typescript): support alphabetical body param sorting in webhook signature verification#14280
Conversation
…signature verification
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
…ook-body-param-sorting
…edTypeReferenceExampleImpl
- Add dateTimeRfc2822 visitor case to PrimitiveTypeV2 and ExamplePrimitive visitors - Add DATE_TIME_RFC_2822 switch case to primitiveTypeNeedsStringify and typeNeedsStringify - Add forwardCompatible to EnumTypeDeclaration test data - Add bodySort to WebhookPayloadFormat test data
…TypeReferenceExampleImpl.ts
SDK Generation Benchmark ResultsComparing PR branch against latest nightly baseline on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Description
Linear ticket: Refs FER-8948
The TypeScript SDK generator's
WebhooksHelperGeneratornow handles thebodySort: ALPHABETICALfield onWebhookPayloadFormatin the IR. When a provider's webhook signing algorithm requires POST body parameters to be sorted alphabetically by key before computing the HMAC signature, the generatedverifySignaturemethod now supports this.Changes Made
WebhooksHelperGenerator.ts:buildHmacParameters: WhenbodySortis set, therequestBodyparameter type changes fromstringtostring | Record<string, string>addPayloadConstruction: WhenbodySortis set, generates a runtimetypeofcheck that either uses the raw string or sorts Record keys alphabetically and concatenateskey + valuepairsbuildJsDoc: Adds documentation about the dual-typerequestBodyparameter whenbodySortis presentWebhooksHelperGenerator.test.ts: 3 new test cases (BODY-only with bodySort, NOTIFICATION_URL + BODY with bodySort, JSDoc generation)versions.yml: Added changelog entry for v3.61.0-rc.1 (fix, irVersion 66)Review Checklist
Object.keys(requestBody).sort().map(key => key + requestBody[key]).join(""). Params sorted alphabetically by key, each key+value concatenated (no separator between pairs). Verify this matches the expected signing spec.bodySortisundefined(all existing webhook configs), the generated code is byte-for-byte identical to before — no type change, no sorting logic. Existing snapshots are unchanged.bodySortproperty access: Accessed directly fromconfig.payloadFormat.bodySortusing the native IR SDK type — no local type extensions or casts.Testing
Link to Devin session: https://app.devin.ai/sessions/e1333475cf904a6e98026ecfaa106ad9
Requested by: @iamnamananand996