Skip to content

Commit

Permalink
Add typings for generateTestHeaderStringAsync (#2152)
Browse files Browse the repository at this point in the history
Co-authored-by: David Brownman <109395161+xavdid-stripe@users.noreply.github.com>
  • Loading branch information
hansottowirtz and xavdid-stripe authored Aug 19, 2024
1 parent 4d13647 commit a0cdbc6
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions types/Webhooks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,40 +89,49 @@ declare module 'stripe' {
/**
* Generates a header to be used for webhook mocking
*/
generateTestHeaderString(opts: {
/**
* JSON stringified payload object, containing the 'id' and 'object' parameters.
*/
payload: string;
generateTestHeaderString(opts: WebhookTestHeaderOptions): string;

/**
* Timestamp of the header. Defaults to Date.now().
*/
timestamp?: number;
/**
* Generates a header to be used for webhook mocking
*/
generateTestHeaderStringAsync(
opts: WebhookTestHeaderOptions
): Promise<string>;

/**
* Stripe webhook secret, e.g., 'whsec_...'.
*/
secret: string;
signature: Signature;
}

/**
* Version of API to hit. Defaults to 'v1'.
*/
scheme?: string;
export interface WebhookTestHeaderOptions {
/**
* JSON stringified payload object, containing the 'id' and 'object' parameters.
*/
payload: string;

/**
* Computed webhook signature.
*/
signature?: string;
/**
* Timestamp of the header. Defaults to Date.now().
*/
timestamp?: number;

/**
* Optional CryptoProvider to use for computing HMAC signatures, if no
* signature is given.
*/
cryptoProvider?: CryptoProvider;
}): string;
/**
* Stripe webhook secret, e.g., 'whsec_...'.
*/
secret: string;

signature: Signature;
/**
* Version of API to hit. Defaults to 'v1'.
*/
scheme?: string;

/**
* Computed webhook signature.
*/
signature?: string;

/**
* Optional CryptoProvider to use for computing HMAC signatures, if no
* signature is given.
*/
cryptoProvider?: CryptoProvider;
}

export class Signature {
Expand Down

0 comments on commit a0cdbc6

Please sign in to comment.