Skip to content

tolerance, receivedAt, timestamp are now optional in Webhook.ts#2670

Merged
prathmesh-stripe merged 2 commits intomasterfrom
prathmesh/fix-webhook-signature
Apr 14, 2026
Merged

tolerance, receivedAt, timestamp are now optional in Webhook.ts#2670
prathmesh-stripe merged 2 commits intomasterfrom
prathmesh/fix-webhook-signature

Conversation

@prathmesh-stripe
Copy link
Copy Markdown
Contributor

@prathmesh-stripe prathmesh-stripe commented Apr 8, 2026

Why?

In v22, several webhook method parameters that were previously optional in manually maintained became required due to a type consolidation.
generateTestHeaderString only truly requires payload and secret (all other fields have defaults). verifyHeader/constructEvent work without explicit tolerance and cryptoProvider arguments. Users upgrading to v22 now get TypeScript errors when calling these methods with the same arguments that worked in v21.

What?

  • Made timestamp, scheme, signature, and cryptoProvider optional in WebhookTestHeaderOptions
  • Made tolerance and cryptoProvider optional in verifyHeader/verifyHeaderAsync signatures
  • Made scheme optional in parseHeader
  • Updated prepareOptions return type to reflect that defaulted fields are resolved to non-optional
  • Added tests covering all optional parameter default behaviors

See Also

Changelog

@prathmesh-stripe prathmesh-stripe force-pushed the prathmesh/fix-webhook-signature branch from df30437 to 4b1ef97 Compare April 8, 2026 03:54
Comment thread src/Webhooks.ts
@prathmesh-stripe prathmesh-stripe marked this pull request as ready for review April 10, 2026 18:51
@prathmesh-stripe prathmesh-stripe requested a review from a team as a code owner April 10, 2026 18:51
@prathmesh-stripe prathmesh-stripe requested review from xavdid and removed request for a team April 10, 2026 18:51
Copy link
Copy Markdown
Member

@xavdid xavdid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I had a comment about the default.

It's how it's always worked so we're not making things worse, but we should ship with better defaults in the future.

Comment thread src/Webhooks.ts
@prathmesh-stripe prathmesh-stripe force-pushed the prathmesh/fix-webhook-signature branch from db96047 to 74522a1 Compare April 14, 2026 18:29
@prathmesh-stripe prathmesh-stripe enabled auto-merge (squash) April 14, 2026 18:29
@prathmesh-stripe prathmesh-stripe merged commit 549d89f into master Apr 14, 2026
11 checks passed
@prathmesh-stripe prathmesh-stripe deleted the prathmesh/fix-webhook-signature branch April 14, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v22 - change to generateTestHeaderString

2 participants