Skip to content

Added string[] to WebhookHeader type for compatibility with express#2652

Merged
prathmesh-stripe merged 2 commits intomasterfrom
prathmesh/updated-constructevent-signature
Apr 3, 2026
Merged

Added string[] to WebhookHeader type for compatibility with express#2652
prathmesh-stripe merged 2 commits intomasterfrom
prathmesh/updated-constructevent-signature

Conversation

@prathmesh-stripe
Copy link
Copy Markdown
Contributor

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

Why?

In the most resent release we got rid of the manually maintained type for constructEvent in Webhook.d.ts.
This caused a problem with express framework. Express's type for Request#headers is string | []string. Although signature would never be string[], we still need to handle it.

What?

  • Added string[] to WebhookHeader type.
  • Moved up the array check in parseEventDetails to throw an error early.
  • changed type of internal validateComputedSignature method to accommodate the change in type of WebhookHeader.

See Also

#2651

Changelog

  • Added string[] to the type of signature param in stripe.webhooks.construct_event method.

@prathmesh-stripe prathmesh-stripe requested a review from a team as a code owner April 3, 2026 20:11
@prathmesh-stripe prathmesh-stripe requested review from mbroshi-stripe and xavdid and removed request for a team April 3, 2026 20:11
@mbroshi-stripe mbroshi-stripe requested a review from Copilot April 3, 2026 20:15
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.

fix looks good, but you should add a line to the types test to we catch this sort of thing in the future!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the webhook header typing and related internal parsing/validation to be compatible with Express/Node header types, addressing the string | string[] header scenario raised in issue #2651.

Changes:

  • Expanded WebhookHeader to include string[] for Express compatibility.
  • Moved the “array header” guard earlier in parseEventDetails to fail fast.
  • Tightened internal WebhookParsedEvent and validateComputedSignature types to reflect decoded string values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Webhooks.ts
@prathmesh-stripe prathmesh-stripe merged commit 0382565 into master Apr 3, 2026
10 checks passed
@prathmesh-stripe prathmesh-stripe deleted the prathmesh/updated-constructevent-signature branch April 3, 2026 20:31
@prathmesh-stripe prathmesh-stripe changed the title Added string[] to WebhookHeader type for compatibility with express Added string[] to WebhookHeader type for compatibility with express Apr 3, 2026
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.

3 participants