Skip to content

Commit

Permalink
Update generated code for beta (#1811)
Browse files Browse the repository at this point in the history
* Update generated code for v372

* Update generated code for v374

* Update generated code for v375

* Adding error message for when signing secrets contain whitespace

* Add a couple newlines

* format

* Update generated code for v376

* Update generated code for v377

* Update generated code (#1809)

* Update generated code for v370

* Update generated code for v374

* Update generated code for v375

* Update generated code for v376

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Richard Marmorstein <[email protected]>

* Update generated code for v379

* Update generated code for v380

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Anthony Annis <[email protected]>
Co-authored-by: Richard Marmorstein <[email protected]>
Co-authored-by: Richard Marmorstein <[email protected]>
  • Loading branch information
4 people authored Jun 8, 2023
1 parent 84e0290 commit 3047ab6
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 21 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v369
v380
23 changes: 19 additions & 4 deletions src/Webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export function createWebhooks(
encodedHeader,
this.EXPECTED_SCHEME
);
const secretContainsWhitespace = /\s/.test(secret);

cryptoProvider = cryptoProvider || getCryptoProvider();
const expectedSignature = cryptoProvider.computeHMACSignature(
Expand All @@ -194,6 +195,7 @@ export function createWebhooks(
expectedSignature,
tolerance,
suspectPayloadType,
secretContainsWhitespace,
receivedAt
);

Expand All @@ -218,6 +220,7 @@ export function createWebhooks(
encodedHeader,
this.EXPECTED_SCHEME
);
const secretContainsWhitespace = /\s/.test(secret);

cryptoProvider = cryptoProvider || getCryptoProvider();

Expand All @@ -233,6 +236,7 @@ export function createWebhooks(
expectedSignature,
tolerance,
suspectPayloadType,
secretContainsWhitespace,
receivedAt
);
},
Expand Down Expand Up @@ -332,29 +336,40 @@ export function createWebhooks(
expectedSignature: string,
tolerance: number,
suspectPayloadType: boolean,
secretContainsWhitespace: boolean,
receivedAt: number
): boolean {
const signatureFound = !!details.signatures.filter(
platformFunctions.secureCompare.bind(platformFunctions, expectedSignature)
).length;

const docsLocation =
'\nLearn more about webhook signing and explore webhook integration examples for various frameworks at ' +
'https://github.com/stripe/stripe-node#webhook-signing';

const whitespaceMessage = secretContainsWhitespace
? '\n\nNote: The provided signing secret contains whitespace. This often indicates an extra newline or space is in the value'
: '';

if (!signatureFound) {
if (suspectPayloadType) {
throw new StripeSignatureVerificationError(header, payload, {
message:
'Webhook payload must be provided as a string or a Buffer (https://nodejs.org/api/buffer.html) instance representing the _raw_ request body.' +
'Payload was provided as a parsed JavaScript object instead. \n' +
'Signature verification is impossible without access to the original signed material. \n' +
'Learn more about webhook signing and explore webhook integration examples for various frameworks at ' +
'https://github.com/stripe/stripe-node#webhook-signing',
docsLocation +
'\n' +
whitespaceMessage,
});
}
throw new StripeSignatureVerificationError(header, payload, {
message:
'No signatures found matching the expected signature for payload.' +
' Are you passing the raw request body you received from Stripe? \n' +
'Learn more about webhook signing and explore webhook integration examples for various frameworks at ' +
'https://github.com/stripe/stripe-node#webhook-signing',
docsLocation +
'\n' +
whitespaceMessage,
});
}

Expand Down
14 changes: 14 additions & 0 deletions test/Webhook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,20 @@ describe('Webhooks', () => {
);
});

it('should raise a SignatureVerificationError when the signing secret contians whitespace', async () => {
const header = stripe.webhooks.generateTestHeaderString({
payload: EVENT_PAYLOAD_STRING,
secret: SECRET,
});

await expect(
verifyHeaderFn(EVENT_PAYLOAD_STRING, header, SECRET + ' ')
).to.be.rejectedWith(
StripeSignatureVerificationError,
/The provided signing secret contains whitespace/
);
});

describe('custom CryptoProvider', () => {
const cryptoProvider = new FakeCryptoProvider();

Expand Down
4 changes: 2 additions & 2 deletions types/Charges.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,12 +1149,12 @@ declare module 'stripe' {
/**
* A unique and immutable identifier assigned by Cash App to every buyer.
*/
buyer_id?: string | null;
buyer_id: string | null;

/**
* A public identifier for buyers using Cash App.
*/
cashtag?: string | null;
cashtag: string | null;
}

interface CustomerBalance {}
Expand Down
2 changes: 1 addition & 1 deletion types/Events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ declare module 'stripe' {
object: Data.Object;

/**
* Object containing the names of the attributes that have changed, and their previous values (sent along only with *.updated events).
* Object containing the names of the updated attributes and their values prior to the event (only included in events of type `*.updated`). If an array attribute has any updated elements, this object contains the entire array. In Stripe API versions 2017-04-06 or earlier, an updated array attribute in this object includes only the updated array elements.
*/
previous_attributes?: Data.PreviousAttributes;
}
Expand Down
4 changes: 2 additions & 2 deletions types/Invoices.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare module 'stripe' {
* If your invoice is configured to be billed through automatic charges,
* Stripe automatically finalizes your invoice and attempts payment. Note
* that finalizing the invoice,
* [when automatic](https://stripe.com/docs/billing/invoices/workflow/#auto_advance), does
* [when automatic](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection), does
* not happen immediately as the invoice is created. Stripe waits
* until one hour after the last webhook was successfully sent (or the last
* webhook timed out after failing). If you (and the platforms you may have
Expand Down Expand Up @@ -111,7 +111,7 @@ declare module 'stripe' {
attempted: boolean;

/**
* Controls whether Stripe will perform [automatic collection](https://stripe.com/docs/billing/invoices/workflow/#auto_advance) of the invoice. When `false`, the invoice's state will not automatically advance without an explicit action.
* Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. If `false`, the invoice's state doesn't automatically advance without an explicit action.
*/
auto_advance?: boolean;

Expand Down
6 changes: 3 additions & 3 deletions types/InvoicesResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ declare module 'stripe' {
application_fee_amount?: number;

/**
* Controls whether Stripe will perform [automatic collection](https://stripe.com/docs/billing/invoices/workflow/#auto_advance) of the invoice. When `false`, the invoice's state will not automatically advance without an explicit action.
* Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. If `false`, the invoice's state doesn't automatically advance without an explicit action.
*/
auto_advance?: boolean;

Expand Down Expand Up @@ -694,7 +694,7 @@ declare module 'stripe' {
application_fee_amount?: number;

/**
* Controls whether Stripe will perform [automatic collection](https://stripe.com/docs/billing/invoices/workflow/#auto_advance) of the invoice.
* Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice.
*/
auto_advance?: boolean;

Expand Down Expand Up @@ -1354,7 +1354,7 @@ declare module 'stripe' {

interface InvoiceFinalizeInvoiceParams {
/**
* Controls whether Stripe will perform [automatic collection](https://stripe.com/docs/invoicing/automatic-charging) of the invoice. When `false`, the invoice's state will not automatically advance without an explicit action.
* Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. If `false`, the invoice's state doesn't automatically advance without an explicit action.
*/
auto_advance?: boolean;

Expand Down
2 changes: 1 addition & 1 deletion types/LoginLinks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare module 'stripe' {
namespace Stripe {
/**
* The LoginLink object.
* Login Links are single-use login link for an Express account to access their Stripe dashboard.
*/
interface LoginLink {
/**
Expand Down
3 changes: 2 additions & 1 deletion types/PaymentIntentsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6306,7 +6306,8 @@ declare module 'stripe' {
* If the selected payment method requires additional authentication steps, the
* PaymentIntent will transition to the requires_action status and
* suggest additional actions via next_action. If payment fails,
* the PaymentIntent will transition to the requires_payment_method status. If
* the PaymentIntent transitions to the requires_payment_method status or the
* canceled status if the confirmation limit is reached. If
* payment succeeds, the PaymentIntent will transition to the succeeded
* status (or requires_capture, if capture_method is set to manual).
* If the confirmation_method is automatic, payment may be attempted
Expand Down
4 changes: 2 additions & 2 deletions types/PaymentMethods.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,12 @@ declare module 'stripe' {
/**
* A unique and immutable identifier assigned by Cash App to every buyer.
*/
buyer_id?: string | null;
buyer_id: string | null;

/**
* A public identifier for buyers using Cash App.
*/
cashtag?: string | null;
cashtag: string | null;
}

interface CustomerBalance {}
Expand Down
3 changes: 2 additions & 1 deletion types/SetupIntentsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3073,7 +3073,8 @@ declare module 'stripe' {
* Otherwise, it will transition to the requires_action status and
* suggest additional actions via next_action. If setup fails,
* the SetupIntent will transition to the
* requires_payment_method status.
* requires_payment_method status or the canceled status if the
* confirmation limit is reached.
*/
confirm(
id: string,
Expand Down
22 changes: 22 additions & 0 deletions types/Tax/Calculations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,35 @@ declare module 'stripe' {

tax_rate_details: TaxBreakdown.TaxRateDetails;

/**
* The reasoning behind this tax, for example, if the product is tax exempt. We might extend the possible values for this field to support new tax rules.
*/
taxability_reason: TaxBreakdown.TaxabilityReason;

/**
* The amount on which tax is calculated, in integer cents.
*/
taxable_amount: number;
}

namespace TaxBreakdown {
type TaxabilityReason =
| 'customer_exempt'
| 'not_collecting'
| 'not_subject_to_tax'
| 'not_supported'
| 'portion_product_exempt'
| 'portion_reduced_rated'
| 'portion_standard_rated'
| 'product_exempt'
| 'product_exempt_holiday'
| 'proportionally_rated'
| 'reduced_rated'
| 'reverse_charge'
| 'standard_rated'
| 'taxable_basis_reduced'
| 'zero_rated';

interface TaxRateDetails {
/**
* Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
Expand Down
4 changes: 2 additions & 2 deletions types/Tax/RegistrationsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1081,14 +1081,14 @@ declare module 'stripe' {
namespace Us {
interface LocalAmusementTax {
/**
* A [FIPS code](https://www.census.gov/library/reference/code-lists/ansi.html) representing the local jurisdiction.
* A [FIPS code](https://www.census.gov/library/reference/code-lists/ansi.html) representing the local jurisdiction. Supported FIPS codes are: `14000` (Chicago), `06613` (Bloomington), `21696` (East Dundee), `24582` (Evanston), and `68081` (Schiller Park).
*/
jurisdiction: string;
}

interface LocalLeaseTax {
/**
* A [FIPS code](https://www.census.gov/library/reference/code-lists/ansi.html) representing the local jurisdiction.
* A [FIPS code](https://www.census.gov/library/reference/code-lists/ansi.html) representing the local jurisdiction. Supported FIPS codes are: `14000` (Chicago).
*/
jurisdiction: string;
}
Expand Down
2 changes: 1 addition & 1 deletion types/Terminal/ReadersResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ declare module 'stripe' {
): Promise<Stripe.Response<Stripe.Terminal.Reader>>;

/**
* Finializes a payment on a Reader.
* Finalizes a payment on a Reader.
*/
confirmPaymentIntent(
id: string,
Expand Down

0 comments on commit 3047ab6

Please sign in to comment.