Skip to content

Commit a0cdbc6

Browse files
Add typings for generateTestHeaderStringAsync (#2152)
Co-authored-by: David Brownman <[email protected]>
1 parent 4d13647 commit a0cdbc6

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

types/Webhooks.d.ts

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,40 +89,49 @@ declare module 'stripe' {
8989
/**
9090
* Generates a header to be used for webhook mocking
9191
*/
92-
generateTestHeaderString(opts: {
93-
/**
94-
* JSON stringified payload object, containing the 'id' and 'object' parameters.
95-
*/
96-
payload: string;
92+
generateTestHeaderString(opts: WebhookTestHeaderOptions): string;
9793

98-
/**
99-
* Timestamp of the header. Defaults to Date.now().
100-
*/
101-
timestamp?: number;
94+
/**
95+
* Generates a header to be used for webhook mocking
96+
*/
97+
generateTestHeaderStringAsync(
98+
opts: WebhookTestHeaderOptions
99+
): Promise<string>;
102100

103-
/**
104-
* Stripe webhook secret, e.g., 'whsec_...'.
105-
*/
106-
secret: string;
101+
signature: Signature;
102+
}
107103

108-
/**
109-
* Version of API to hit. Defaults to 'v1'.
110-
*/
111-
scheme?: string;
104+
export interface WebhookTestHeaderOptions {
105+
/**
106+
* JSON stringified payload object, containing the 'id' and 'object' parameters.
107+
*/
108+
payload: string;
112109

113-
/**
114-
* Computed webhook signature.
115-
*/
116-
signature?: string;
110+
/**
111+
* Timestamp of the header. Defaults to Date.now().
112+
*/
113+
timestamp?: number;
117114

118-
/**
119-
* Optional CryptoProvider to use for computing HMAC signatures, if no
120-
* signature is given.
121-
*/
122-
cryptoProvider?: CryptoProvider;
123-
}): string;
115+
/**
116+
* Stripe webhook secret, e.g., 'whsec_...'.
117+
*/
118+
secret: string;
124119

125-
signature: Signature;
120+
/**
121+
* Version of API to hit. Defaults to 'v1'.
122+
*/
123+
scheme?: string;
124+
125+
/**
126+
* Computed webhook signature.
127+
*/
128+
signature?: string;
129+
130+
/**
131+
* Optional CryptoProvider to use for computing HMAC signatures, if no
132+
* signature is given.
133+
*/
134+
cryptoProvider?: CryptoProvider;
126135
}
127136

128137
export class Signature {

0 commit comments

Comments
 (0)