stripe 11.14.0 → 11.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/VERSION +1 -1
- package/{lib → cjs}/RequestSender.js +18 -18
- package/{lib → cjs}/StripeMethod.js +5 -5
- package/{lib → cjs}/StripeResource.js +10 -10
- package/{lib → cjs}/Webhooks.js +9 -9
- package/{lib → cjs}/autoPagination.js +4 -4
- package/{lib → cjs}/crypto/NodeCryptoProvider.js +2 -2
- package/{lib → cjs}/crypto/SubtleCryptoProvider.js +2 -2
- package/{lib → cjs}/multipart.js +3 -3
- package/{lib → cjs}/net/FetchHttpClient.js +4 -4
- package/{lib → cjs}/net/NodeHttpClient.js +4 -4
- package/cjs/package.json +1 -0
- package/{lib → cjs}/platform/NodePlatformFunctions.js +11 -11
- package/{lib → cjs}/platform/PlatformFunctions.js +4 -4
- package/{lib → cjs}/platform/WebPlatformFunctions.js +4 -4
- package/{lib → cjs}/resources/AccountLinks.js +4 -4
- package/{lib → cjs}/resources/Accounts.js +4 -4
- package/{lib → cjs}/resources/ApplePayDomains.js +4 -4
- package/{lib → cjs}/resources/ApplicationFees.js +4 -4
- package/{lib → cjs}/resources/Apps/Secrets.js +4 -4
- package/{lib → cjs}/resources/Balance.js +4 -4
- package/{lib → cjs}/resources/BalanceTransactions.js +4 -4
- package/{lib → cjs}/resources/BillingPortal/Configurations.js +4 -4
- package/{lib → cjs}/resources/BillingPortal/Sessions.js +4 -4
- package/{lib → cjs}/resources/Charges.js +4 -4
- package/{lib → cjs}/resources/Checkout/Sessions.js +4 -4
- package/{lib → cjs}/resources/CountrySpecs.js +4 -4
- package/{lib → cjs}/resources/Coupons.js +4 -4
- package/{lib → cjs}/resources/CreditNotes.js +4 -4
- package/{lib → cjs}/resources/Customers.js +4 -4
- package/{lib → cjs}/resources/Disputes.js +4 -4
- package/{lib → cjs}/resources/EphemeralKeys.js +4 -4
- package/{lib → cjs}/resources/Events.js +4 -4
- package/{lib → cjs}/resources/ExchangeRates.js +4 -4
- package/{lib → cjs}/resources/FileLinks.js +4 -4
- package/{lib → cjs}/resources/Files.js +6 -6
- package/{lib → cjs}/resources/FinancialConnections/Accounts.js +4 -4
- package/{lib → cjs}/resources/FinancialConnections/Sessions.js +4 -4
- package/{lib → cjs}/resources/Identity/VerificationReports.js +4 -4
- package/{lib → cjs}/resources/Identity/VerificationSessions.js +4 -4
- package/{lib → cjs}/resources/InvoiceItems.js +4 -4
- package/{lib → cjs}/resources/Invoices.js +4 -4
- package/{lib → cjs}/resources/Issuing/Authorizations.js +4 -4
- package/{lib → cjs}/resources/Issuing/Cardholders.js +4 -4
- package/{lib → cjs}/resources/Issuing/Cards.js +4 -4
- package/{lib → cjs}/resources/Issuing/Disputes.js +4 -4
- package/{lib → cjs}/resources/Issuing/Transactions.js +4 -4
- package/{lib → cjs}/resources/Mandates.js +4 -4
- package/{lib → cjs}/resources/OAuth.js +5 -5
- package/{lib → cjs}/resources/PaymentIntents.js +4 -4
- package/{lib → cjs}/resources/PaymentLinks.js +4 -4
- package/{lib → cjs}/resources/PaymentMethods.js +4 -4
- package/{lib → cjs}/resources/Payouts.js +4 -4
- package/{lib → cjs}/resources/Plans.js +4 -4
- package/{lib → cjs}/resources/Prices.js +4 -4
- package/{lib → cjs}/resources/Products.js +4 -4
- package/{lib → cjs}/resources/PromotionCodes.js +4 -4
- package/{lib → cjs}/resources/Quotes.js +4 -4
- package/{lib → cjs}/resources/Radar/EarlyFraudWarnings.js +4 -4
- package/{lib → cjs}/resources/Radar/ValueListItems.js +4 -4
- package/{lib → cjs}/resources/Radar/ValueLists.js +4 -4
- package/{lib → cjs}/resources/Refunds.js +4 -4
- package/{lib → cjs}/resources/Reporting/ReportRuns.js +4 -4
- package/{lib → cjs}/resources/Reporting/ReportTypes.js +4 -4
- package/{lib → cjs}/resources/Reviews.js +4 -4
- package/{lib → cjs}/resources/SetupAttempts.js +4 -4
- package/{lib → cjs}/resources/SetupIntents.js +4 -4
- package/{lib → cjs}/resources/ShippingRates.js +4 -4
- package/{lib → cjs}/resources/Sigma/ScheduledQueryRuns.js +4 -4
- package/{lib → cjs}/resources/Sources.js +4 -4
- package/{lib → cjs}/resources/SubscriptionItems.js +4 -4
- package/{lib → cjs}/resources/SubscriptionSchedules.js +4 -4
- package/{lib → cjs}/resources/Subscriptions.js +4 -4
- package/{lib → cjs}/resources/TaxCodes.js +4 -4
- package/{lib → cjs}/resources/TaxRates.js +4 -4
- package/{lib → cjs}/resources/Terminal/Configurations.js +4 -4
- package/{lib → cjs}/resources/Terminal/ConnectionTokens.js +4 -4
- package/{lib → cjs}/resources/Terminal/Locations.js +4 -4
- package/{lib → cjs}/resources/Terminal/Readers.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/Customers.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/Issuing/Cards.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/Refunds.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/Terminal/Readers.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/TestClocks.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/Treasury/InboundTransfers.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/Treasury/OutboundPayments.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/Treasury/OutboundTransfers.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/Treasury/ReceivedCredits.js +4 -4
- package/{lib → cjs}/resources/TestHelpers/Treasury/ReceivedDebits.js +4 -4
- package/{lib → cjs}/resources/Tokens.js +4 -4
- package/{lib → cjs}/resources/Topups.js +4 -4
- package/{lib → cjs}/resources/Transfers.js +4 -4
- package/{lib → cjs}/resources/Treasury/CreditReversals.js +4 -4
- package/{lib → cjs}/resources/Treasury/DebitReversals.js +4 -4
- package/{lib → cjs}/resources/Treasury/FinancialAccounts.js +4 -4
- package/{lib → cjs}/resources/Treasury/InboundTransfers.js +4 -4
- package/{lib → cjs}/resources/Treasury/OutboundPayments.js +4 -4
- package/{lib → cjs}/resources/Treasury/OutboundTransfers.js +4 -4
- package/{lib → cjs}/resources/Treasury/ReceivedCredits.js +4 -4
- package/{lib → cjs}/resources/Treasury/ReceivedDebits.js +4 -4
- package/{lib → cjs}/resources/Treasury/TransactionEntries.js +4 -4
- package/{lib → cjs}/resources/Treasury/Transactions.js +4 -4
- package/{lib → cjs}/resources/WebhookEndpoints.js +4 -4
- package/cjs/resources.js +210 -0
- package/{lib/stripe.worker.js → cjs/stripe.cjs.node.js} +3 -3
- package/{lib/stripe.node.js → cjs/stripe.cjs.worker.js} +3 -3
- package/{lib/stripe.common.js → cjs/stripe.core.js} +25 -21
- package/{lib → cjs}/utils.js +0 -1
- package/esm/Error.js +130 -0
- package/esm/RequestSender.js +348 -0
- package/esm/ResourceNamespace.js +14 -0
- package/esm/StripeEmitter.js +42 -0
- package/esm/StripeMethod.js +37 -0
- package/esm/StripeResource.js +166 -0
- package/esm/Webhooks.js +175 -0
- package/esm/apiVersion.js +2 -0
- package/esm/autoPagination.js +230 -0
- package/esm/crypto/CryptoProvider.js +31 -0
- package/esm/crypto/NodeCryptoProvider.js +19 -0
- package/esm/crypto/SubtleCryptoProvider.js +43 -0
- package/esm/multipart.js +54 -0
- package/esm/net/FetchHttpClient.js +101 -0
- package/esm/net/HttpClient.js +48 -0
- package/esm/net/NodeHttpClient.js +95 -0
- package/esm/package.json +1 -0
- package/esm/platform/NodePlatformFunctions.js +122 -0
- package/esm/platform/PlatformFunctions.js +94 -0
- package/esm/platform/WebPlatformFunctions.js +38 -0
- package/esm/resources/AccountLinks.js +9 -0
- package/esm/resources/Accounts.js +106 -0
- package/esm/resources/ApplePayDomains.js +22 -0
- package/esm/resources/ApplicationFees.js +31 -0
- package/esm/resources/Apps/Secrets.js +22 -0
- package/esm/resources/Balance.js +9 -0
- package/esm/resources/BalanceTransactions.js +14 -0
- package/esm/resources/BillingPortal/Configurations.js +22 -0
- package/esm/resources/BillingPortal/Sessions.js +9 -0
- package/esm/resources/Charges.js +31 -0
- package/esm/resources/Checkout/Sessions.js +27 -0
- package/esm/resources/CountrySpecs.js +14 -0
- package/esm/resources/Coupons.js +26 -0
- package/esm/resources/CreditNotes.js +40 -0
- package/esm/resources/Customers.js +124 -0
- package/esm/resources/Disputes.js +22 -0
- package/esm/resources/EphemeralKeys.js +18 -0
- package/esm/resources/Events.js +14 -0
- package/esm/resources/ExchangeRates.js +14 -0
- package/esm/resources/FileLinks.js +22 -0
- package/esm/resources/Files.js +24 -0
- package/esm/resources/FinancialConnections/Accounts.js +27 -0
- package/esm/resources/FinancialConnections/Sessions.js +13 -0
- package/esm/resources/Identity/VerificationReports.js +14 -0
- package/esm/resources/Identity/VerificationSessions.js +30 -0
- package/esm/resources/InvoiceItems.js +26 -0
- package/esm/resources/Invoices.js +65 -0
- package/esm/resources/Issuing/Authorizations.js +26 -0
- package/esm/resources/Issuing/Cardholders.js +22 -0
- package/esm/resources/Issuing/Cards.js +22 -0
- package/esm/resources/Issuing/Disputes.js +26 -0
- package/esm/resources/Issuing/Transactions.js +18 -0
- package/esm/resources/Mandates.js +9 -0
- package/esm/resources/OAuth.js +42 -0
- package/esm/resources/PaymentIntents.js +51 -0
- package/esm/resources/PaymentLinks.js +27 -0
- package/esm/resources/PaymentMethods.js +30 -0
- package/esm/resources/Payouts.js +30 -0
- package/esm/resources/Plans.js +26 -0
- package/esm/resources/Prices.js +27 -0
- package/esm/resources/Products.js +31 -0
- package/esm/resources/PromotionCodes.js +22 -0
- package/esm/resources/Quotes.js +50 -0
- package/esm/resources/Radar/EarlyFraudWarnings.js +14 -0
- package/esm/resources/Radar/ValueListItems.js +22 -0
- package/esm/resources/Radar/ValueLists.js +26 -0
- package/esm/resources/Refunds.js +26 -0
- package/esm/resources/Reporting/ReportRuns.js +18 -0
- package/esm/resources/Reporting/ReportTypes.js +14 -0
- package/esm/resources/Reviews.js +18 -0
- package/esm/resources/SetupAttempts.js +10 -0
- package/esm/resources/SetupIntents.js +34 -0
- package/esm/resources/ShippingRates.js +22 -0
- package/esm/resources/Sigma/ScheduledQueryRuns.js +14 -0
- package/esm/resources/Sources.js +26 -0
- package/esm/resources/SubscriptionItems.js +35 -0
- package/esm/resources/SubscriptionSchedules.js +30 -0
- package/esm/resources/Subscriptions.js +43 -0
- package/esm/resources/TaxCodes.js +14 -0
- package/esm/resources/TaxRates.js +22 -0
- package/esm/resources/Terminal/Configurations.js +26 -0
- package/esm/resources/Terminal/ConnectionTokens.js +9 -0
- package/esm/resources/Terminal/Locations.js +26 -0
- package/esm/resources/Terminal/Readers.js +46 -0
- package/esm/resources/TestHelpers/Customers.js +9 -0
- package/esm/resources/TestHelpers/Issuing/Cards.js +21 -0
- package/esm/resources/TestHelpers/Refunds.js +9 -0
- package/esm/resources/TestHelpers/Terminal/Readers.js +9 -0
- package/esm/resources/TestHelpers/TestClocks.js +26 -0
- package/esm/resources/TestHelpers/Treasury/InboundTransfers.js +17 -0
- package/esm/resources/TestHelpers/Treasury/OutboundPayments.js +17 -0
- package/esm/resources/TestHelpers/Treasury/OutboundTransfers.js +17 -0
- package/esm/resources/TestHelpers/Treasury/ReceivedCredits.js +9 -0
- package/esm/resources/TestHelpers/Treasury/ReceivedDebits.js +9 -0
- package/esm/resources/Tokens.js +13 -0
- package/esm/resources/Topups.js +26 -0
- package/esm/resources/Transfers.js +39 -0
- package/esm/resources/Treasury/CreditReversals.js +18 -0
- package/esm/resources/Treasury/DebitReversals.js +18 -0
- package/esm/resources/Treasury/FinancialAccounts.js +30 -0
- package/esm/resources/Treasury/InboundTransfers.js +22 -0
- package/esm/resources/Treasury/OutboundPayments.js +22 -0
- package/esm/resources/Treasury/OutboundTransfers.js +22 -0
- package/esm/resources/Treasury/ReceivedCredits.js +14 -0
- package/esm/resources/Treasury/ReceivedDebits.js +14 -0
- package/esm/resources/Treasury/TransactionEntries.js +14 -0
- package/esm/resources/Treasury/Transactions.js +14 -0
- package/esm/resources/WebhookEndpoints.js +26 -0
- package/esm/resources.js +160 -0
- package/esm/stripe.core.js +348 -0
- package/esm/stripe.esm.node.js +4 -0
- package/esm/stripe.esm.worker.js +4 -0
- package/esm/utils.js +287 -0
- package/package.json +18 -7
- package/types/Accounts.d.ts +7 -0
- package/types/AccountsResource.d.ts +45 -0
- package/types/BankAccounts.d.ts +198 -0
- package/types/Charges.d.ts +11 -1
- package/types/Checkout/Sessions.d.ts +13 -0
- package/types/Checkout/SessionsResource.d.ts +22 -1
- package/types/CustomersResource.d.ts +1 -0
- package/types/Invoices.d.ts +1 -0
- package/types/InvoicesResource.d.ts +2 -0
- package/types/Mandates.d.ts +4 -0
- package/types/PaymentIntents.d.ts +63 -1
- package/types/PaymentIntentsResource.d.ts +135 -3
- package/types/PaymentLinks.d.ts +3 -2
- package/types/PaymentLinksResource.d.ts +3 -1
- package/types/PaymentMethods.d.ts +5 -0
- package/types/PaymentMethodsResource.d.ts +16 -0
- package/types/Products.d.ts +1 -1
- package/types/SetupAttempts.d.ts +4 -0
- package/types/SetupIntents.d.ts +35 -0
- package/types/SetupIntentsResource.d.ts +24 -0
- package/types/Subscriptions.d.ts +1 -0
- package/types/SubscriptionsResource.d.ts +2 -0
- package/types/WebhookEndpointsResource.d.ts +2 -0
- package/lib/resources.js +0 -210
- /package/{lib → cjs}/Error.js +0 -0
- /package/{lib → cjs}/ResourceNamespace.js +0 -0
- /package/{lib → cjs}/StripeEmitter.js +0 -0
- /package/{lib → cjs}/apiVersion.js +0 -0
- /package/{lib → cjs}/crypto/CryptoProvider.js +0 -0
- /package/{lib → cjs}/net/HttpClient.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 11.15.0 - 2023-03-16
|
|
4
|
+
* [#1714](https://github.com/stripe/stripe-node/pull/1714) API Updates
|
|
5
|
+
* Add support for `cashapp_payments` on `Account.capabilities`, `AccountCreateParams.capabilities`, and `AccountUpdateParams.capabilities`
|
|
6
|
+
* Add support for new value `cashapp` as a new `type` throughout the API.
|
|
7
|
+
* Add support for `future_requirements` and `requirements` on `BankAccount`
|
|
8
|
+
* Add support for `country` on `Charge.payment_method_details.link`
|
|
9
|
+
* Add support for new value `automatic_async` on enums `CheckoutSessionCreateParams.payment_intent_data.capture_method`, `PaymentIntent.capture_method`, `PaymentIntentConfirmParams.capture_method`, `PaymentIntentCreateParams.capture_method`, `PaymentIntentUpdateParams.capture_method`, `PaymentLink.payment_intent_data.capture_method`, and `PaymentLinkCreateParams.payment_intent_data.capture_method`
|
|
10
|
+
|
|
11
|
+
* Add support for `preferred_locale` on `PaymentIntent.payment_method_options.affirm`,
|
|
12
|
+
* Add support for `cashapp_handle_redirect_or_display_qr_code` on `PaymentIntent.next_action` and `SetupIntent.next_action`
|
|
13
|
+
* Add support for new value `payout.reconciliation_completed` on enums `WebhookEndpointCreateParams.enabled_events[]` and `WebhookEndpointUpdateParams.enabled_events[]`
|
|
14
|
+
* [#1709](https://github.com/stripe/stripe-node/pull/1709) Add ES module package entry point
|
|
15
|
+
* Add support for ES modules by defining a separate ESM entry point. This updates stripe-node to be a [dual CommonJS / ES module package](https://nodejs.org/api/packages.html#dual-commonjses-module-packages).
|
|
16
|
+
* [#1704](https://github.com/stripe/stripe-node/pull/1704) Configure 2 TypeScript compile targets for ESM and CJS
|
|
17
|
+
* [#1710](https://github.com/stripe/stripe-node/pull/1710) Update generated code (new)
|
|
18
|
+
* Add support for `cashapp_payments` on `Account.capabilities`, `AccountCreateParams.capabilities`, and `AccountUpdateParams.capabilities`
|
|
19
|
+
* Add support for `cashapp` on `Charge.payment_method_details`, `Checkout.Session.payment_method_options`, `CheckoutSessionCreateParams.payment_method_options`, `Mandate.payment_method_details`, `PaymentIntent.payment_method_options`, `PaymentIntentConfirmParams.payment_method_data`, `PaymentIntentConfirmParams.payment_method_options`, `PaymentIntentCreateParams.payment_method_data`, `PaymentIntentCreateParams.payment_method_options`, `PaymentIntentUpdateParams.payment_method_data`, `PaymentIntentUpdateParams.payment_method_options`, `PaymentMethodCreateParams`, `PaymentMethodUpdateParams`, `PaymentMethod`, `SetupAttempt.payment_method_details`, `SetupIntentConfirmParams.payment_method_data`, `SetupIntentCreateParams.payment_method_data`, and `SetupIntentUpdateParams.payment_method_data`
|
|
20
|
+
* Add support for new value `cashapp` on enum `CheckoutSessionCreateParams.payment_method_types[]`
|
|
21
|
+
* Add support for new value `cashapp` on enums `CustomerListPaymentMethodsParams.type` and `PaymentMethodListParams.type`
|
|
22
|
+
* Add support for new value `cashapp` on enums `Invoice.payment_settings.payment_method_types[]`, `InvoiceCreateParams.payment_settings.payment_method_types[]`, `InvoiceUpdateParams.payment_settings.payment_method_types[]`, `Subscription.payment_settings.payment_method_types[]`, `SubscriptionCreateParams.payment_settings.payment_method_types[]`, and `SubscriptionUpdateParams.payment_settings.payment_method_types[]`
|
|
23
|
+
* Add support for new value `cashapp` on enums `PaymentIntentConfirmParams.payment_method_data.type`, `PaymentIntentCreateParams.payment_method_data.type`, `PaymentIntentUpdateParams.payment_method_data.type`, `SetupIntentConfirmParams.payment_method_data.type`, `SetupIntentCreateParams.payment_method_data.type`, and `SetupIntentUpdateParams.payment_method_data.type`
|
|
24
|
+
* Add support for `preferred_locale` on `PaymentIntent.payment_method_options.affirm`, `PaymentIntentConfirmParams.payment_method_options.affirm`, `PaymentIntentCreateParams.payment_method_options.affirm`, and `PaymentIntentUpdateParams.payment_method_options.affirm`
|
|
25
|
+
* Add support for `cashapp_handle_redirect_or_display_qr_code` on `PaymentIntent.next_action` and `SetupIntent.next_action`
|
|
26
|
+
* Add support for new value `cashapp` on enums `PaymentLink.payment_method_types[]`, `PaymentLinkCreateParams.payment_method_types[]`, and `PaymentLinkUpdateParams.payment_method_types[]`
|
|
27
|
+
* Add support for new value `cashapp` on enum `PaymentMethodCreateParams.type`
|
|
28
|
+
* Add support for new value `cashapp` on enum `PaymentMethod.type`
|
|
29
|
+
* Add support for new value `payout.reconciliation_completed` on enums `WebhookEndpointCreateParams.enabled_events[]` and `WebhookEndpointUpdateParams.enabled_events[]`
|
|
30
|
+
|
|
3
31
|
## 11.14.0 - 2023-03-09
|
|
4
32
|
* [#1703](https://github.com/stripe/stripe-node/pull/1703) API Updates
|
|
5
33
|
* Add support for `card_issuing` on `IssuingCardholderCreateParams.individual` and `IssuingCardholderUpdateParams.individual`
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
11.
|
|
1
|
+
11.15.0
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RequestSender = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const Error_js_1 = require("./Error.js");
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
6
|
+
const HttpClient_js_1 = require("./net/HttpClient.js");
|
|
7
7
|
const MAX_RETRY_AFTER_WAIT = 60;
|
|
8
8
|
class RequestSender {
|
|
9
9
|
constructor(stripe, maxBufferedRequestMetric) {
|
|
@@ -22,7 +22,7 @@ class RequestSender {
|
|
|
22
22
|
_makeResponseEvent(requestEvent, statusCode, headers) {
|
|
23
23
|
const requestEndTime = Date.now();
|
|
24
24
|
const requestDurationMs = requestEndTime - requestEvent.request_start_time;
|
|
25
|
-
return (0,
|
|
25
|
+
return (0, utils_js_1.removeNullish)({
|
|
26
26
|
api_version: headers['stripe-version'],
|
|
27
27
|
account: headers['stripe-account'],
|
|
28
28
|
idempotency_key: headers['idempotency-key'],
|
|
@@ -93,22 +93,22 @@ class RequestSender {
|
|
|
93
93
|
jsonResponse.error.statusCode = statusCode;
|
|
94
94
|
jsonResponse.error.requestId = requestId;
|
|
95
95
|
if (statusCode === 401) {
|
|
96
|
-
err = new
|
|
96
|
+
err = new Error_js_1.StripeAuthenticationError(jsonResponse.error);
|
|
97
97
|
}
|
|
98
98
|
else if (statusCode === 403) {
|
|
99
|
-
err = new
|
|
99
|
+
err = new Error_js_1.StripePermissionError(jsonResponse.error);
|
|
100
100
|
}
|
|
101
101
|
else if (statusCode === 429) {
|
|
102
|
-
err = new
|
|
102
|
+
err = new Error_js_1.StripeRateLimitError(jsonResponse.error);
|
|
103
103
|
}
|
|
104
104
|
else {
|
|
105
|
-
err =
|
|
105
|
+
err = Error_js_1.StripeError.generate(jsonResponse.error);
|
|
106
106
|
}
|
|
107
107
|
throw err;
|
|
108
108
|
}
|
|
109
109
|
return jsonResponse;
|
|
110
110
|
}, (e) => {
|
|
111
|
-
throw new
|
|
111
|
+
throw new Error_js_1.StripeAPIError({
|
|
112
112
|
message: 'Invalid JSON received from the Stripe API',
|
|
113
113
|
exception: e,
|
|
114
114
|
requestId: headers['request-id'],
|
|
@@ -135,7 +135,7 @@ class RequestSender {
|
|
|
135
135
|
static _shouldRetry(res, numRetries, maxRetries, error) {
|
|
136
136
|
if (error &&
|
|
137
137
|
numRetries === 0 &&
|
|
138
|
-
|
|
138
|
+
HttpClient_js_1.HttpClient.CONNECTION_CLOSED_ERROR_CODES.includes(error.code)) {
|
|
139
139
|
return true;
|
|
140
140
|
}
|
|
141
141
|
// Do not retry if we are out of retries.
|
|
@@ -233,13 +233,13 @@ class RequestSender {
|
|
|
233
233
|
// and fix these cases as they are semantically incorrect.
|
|
234
234
|
if (methodHasPayload || contentLength) {
|
|
235
235
|
if (!methodHasPayload) {
|
|
236
|
-
(0,
|
|
236
|
+
(0, utils_js_1.emitWarning)(`${method} method had non-zero contentLength but no payload is expected for this verb`);
|
|
237
237
|
}
|
|
238
238
|
defaultHeaders['Content-Length'] = contentLength;
|
|
239
239
|
}
|
|
240
|
-
return Object.assign((0,
|
|
240
|
+
return Object.assign((0, utils_js_1.removeNullish)(defaultHeaders),
|
|
241
241
|
// If the user supplied, say 'idempotency-key', override instead of appending by ensuring caps are the same.
|
|
242
|
-
(0,
|
|
242
|
+
(0, utils_js_1.normalizeHeaders)(userSuppliedHeaders));
|
|
243
243
|
}
|
|
244
244
|
_getUserAgentString() {
|
|
245
245
|
const packageVersion = this._stripe.getConstant('PACKAGE_VERSION');
|
|
@@ -260,7 +260,7 @@ class RequestSender {
|
|
|
260
260
|
_recordRequestMetrics(requestId, requestDurationMs) {
|
|
261
261
|
if (this._stripe.getTelemetryEnabled() && requestId) {
|
|
262
262
|
if (this._stripe._prevRequestMetrics.length > this._maxBufferedRequestMetric) {
|
|
263
|
-
(0,
|
|
263
|
+
(0, utils_js_1.emitWarning)('Request metrics buffer is full, dropping telemetry message.');
|
|
264
264
|
}
|
|
265
265
|
else {
|
|
266
266
|
this._stripe._prevRequestMetrics.push({
|
|
@@ -288,7 +288,7 @@ class RequestSender {
|
|
|
288
288
|
.makeRequest(host || this._stripe.getApiField('host'), this._stripe.getApiField('port'), path, method, headers, requestData, this._stripe.getApiField('protocol'), timeout);
|
|
289
289
|
const requestStartTime = Date.now();
|
|
290
290
|
// @ts-ignore
|
|
291
|
-
const requestEvent = (0,
|
|
291
|
+
const requestEvent = (0, utils_js_1.removeNullish)({
|
|
292
292
|
api_version: apiVersion,
|
|
293
293
|
account: headers['Stripe-Account'],
|
|
294
294
|
idempotency_key: headers['Idempotency-Key'],
|
|
@@ -318,8 +318,8 @@ class RequestSender {
|
|
|
318
318
|
return retryRequest(makeRequest, apiVersion, headers, requestRetries, null);
|
|
319
319
|
}
|
|
320
320
|
else {
|
|
321
|
-
const isTimeoutError = error.code && error.code ===
|
|
322
|
-
return callback(new
|
|
321
|
+
const isTimeoutError = error.code && error.code === HttpClient_js_1.HttpClient.TIMEOUT_ERROR_CODE;
|
|
322
|
+
return callback(new Error_js_1.StripeConnectionError({
|
|
323
323
|
message: isTimeoutError
|
|
324
324
|
? `Request aborted due to timeout being reached (${timeout}ms)`
|
|
325
325
|
: RequestSender._generateConnectionErrorMessage(requestRetries),
|
|
@@ -345,7 +345,7 @@ class RequestSender {
|
|
|
345
345
|
requestDataProcessor(method, data, options.headers, prepareAndMakeRequest);
|
|
346
346
|
}
|
|
347
347
|
else {
|
|
348
|
-
prepareAndMakeRequest(null, (0,
|
|
348
|
+
prepareAndMakeRequest(null, (0, utils_js_1.stringifyRequestData)(data || {}));
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stripeMethod = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
|
+
const autoPagination_js_1 = require("./autoPagination.js");
|
|
6
6
|
/**
|
|
7
7
|
* Create an API method from the declared spec.
|
|
8
8
|
*
|
|
@@ -27,12 +27,12 @@ function stripeMethod(spec) {
|
|
|
27
27
|
}
|
|
28
28
|
return function (...args) {
|
|
29
29
|
const callback = typeof args[args.length - 1] == 'function' && args.pop();
|
|
30
|
-
spec.urlParams = (0,
|
|
31
|
-
const requestPromise = (0,
|
|
30
|
+
spec.urlParams = (0, utils_js_1.extractUrlParams)(spec.fullPath || this.createResourcePathWithSymbols(spec.path || ''));
|
|
31
|
+
const requestPromise = (0, utils_js_1.callbackifyPromiseWithTimeout)(this._makeRequest(args, spec, {}), callback);
|
|
32
32
|
// Please note `spec.methodType === 'search'` is beta functionality and this
|
|
33
33
|
// interface is subject to change/removal at any time.
|
|
34
34
|
if (spec.methodType === 'list' || spec.methodType === 'search') {
|
|
35
|
-
const autoPaginationMethods = (0,
|
|
35
|
+
const autoPaginationMethods = (0, autoPagination_js_1.makeAutoPaginationMethods)(this, args, spec, requestPromise);
|
|
36
36
|
Object.assign(requestPromise, autoPaginationMethods);
|
|
37
37
|
}
|
|
38
38
|
return requestPromise;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StripeResource = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
|
+
const StripeMethod_js_1 = require("./StripeMethod.js");
|
|
6
6
|
// Provide extension mechanism for Stripe Resource Sub-Classes
|
|
7
|
-
StripeResource.extend =
|
|
7
|
+
StripeResource.extend = utils_js_1.protoExtend;
|
|
8
8
|
// Expose method-creator
|
|
9
|
-
StripeResource.method =
|
|
9
|
+
StripeResource.method = StripeMethod_js_1.stripeMethod;
|
|
10
10
|
StripeResource.MAX_BUFFERED_REQUEST_METRICS = 100;
|
|
11
11
|
/**
|
|
12
12
|
* Encapsulates request logic for a Stripe Resource
|
|
@@ -16,13 +16,13 @@ function StripeResource(stripe, deprecatedUrlData) {
|
|
|
16
16
|
if (deprecatedUrlData) {
|
|
17
17
|
throw new Error('Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids.');
|
|
18
18
|
}
|
|
19
|
-
this.basePath = (0,
|
|
19
|
+
this.basePath = (0, utils_js_1.makeURLInterpolator)(
|
|
20
20
|
// @ts-ignore changing type of basePath
|
|
21
21
|
this.basePath || stripe.getApiField('basePath'));
|
|
22
22
|
// @ts-ignore changing type of path
|
|
23
23
|
this.resourcePath = this.path;
|
|
24
24
|
// @ts-ignore changing type of path
|
|
25
|
-
this.path = (0,
|
|
25
|
+
this.path = (0, utils_js_1.makeURLInterpolator)(this.path);
|
|
26
26
|
this.initialize(...arguments);
|
|
27
27
|
}
|
|
28
28
|
exports.StripeResource = StripeResource;
|
|
@@ -84,7 +84,7 @@ StripeResource.prototype = {
|
|
|
84
84
|
const urlParams = spec.urlParams || [];
|
|
85
85
|
const encode = spec.encode || ((data) => data);
|
|
86
86
|
const isUsingFullPath = !!spec.fullPath;
|
|
87
|
-
const commandPath = (0,
|
|
87
|
+
const commandPath = (0, utils_js_1.makeURLInterpolator)(isUsingFullPath ? spec.fullPath : spec.path || '');
|
|
88
88
|
// When using fullPath, we ignore the resource path as it should already be
|
|
89
89
|
// fully qualified.
|
|
90
90
|
const path = isUsingFullPath
|
|
@@ -102,9 +102,9 @@ StripeResource.prototype = {
|
|
|
102
102
|
return urlData;
|
|
103
103
|
}, {});
|
|
104
104
|
// Pull request data and options (headers, auth) from args.
|
|
105
|
-
const dataFromArgs = (0,
|
|
105
|
+
const dataFromArgs = (0, utils_js_1.getDataFromArgs)(args);
|
|
106
106
|
const data = encode(Object.assign({}, dataFromArgs, overrideData));
|
|
107
|
-
const options = (0,
|
|
107
|
+
const options = (0, utils_js_1.getOptionsFromArgs)(args);
|
|
108
108
|
const host = options.host || spec.host;
|
|
109
109
|
const streaming = !!spec.streaming;
|
|
110
110
|
// Validate that there are no more args.
|
|
@@ -160,7 +160,7 @@ StripeResource.prototype = {
|
|
|
160
160
|
const path = [
|
|
161
161
|
opts.requestPath,
|
|
162
162
|
emptyQuery ? '' : '?',
|
|
163
|
-
(0,
|
|
163
|
+
(0, utils_js_1.stringifyRequestData)(opts.queryData),
|
|
164
164
|
].join('');
|
|
165
165
|
const { headers, settings } = opts;
|
|
166
166
|
this._stripe._requestSender._request(opts.requestMethod, opts.host, path, opts.bodyData, opts.auth, { headers, settings, streaming: opts.streaming }, requestCallback, (_a = this.requestDataProcessor) === null || _a === void 0 ? void 0 : _a.bind(this));
|
package/{lib → cjs}/Webhooks.js
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWebhooks = void 0;
|
|
4
|
-
const
|
|
4
|
+
const Error_js_1 = require("./Error.js");
|
|
5
5
|
function createWebhooks(platformFunctions) {
|
|
6
6
|
const Webhook = {
|
|
7
7
|
DEFAULT_TOLERANCE: 300,
|
|
@@ -34,7 +34,7 @@ function createWebhooks(platformFunctions) {
|
|
|
34
34
|
*/
|
|
35
35
|
generateTestHeaderString: function (opts) {
|
|
36
36
|
if (!opts) {
|
|
37
|
-
throw new
|
|
37
|
+
throw new Error_js_1.StripeError({
|
|
38
38
|
message: 'Options are required',
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -73,7 +73,7 @@ function createWebhooks(platformFunctions) {
|
|
|
73
73
|
}
|
|
74
74
|
function parseEventDetails(encodedPayload, encodedHeader, expectedScheme) {
|
|
75
75
|
if (!encodedPayload) {
|
|
76
|
-
throw new
|
|
76
|
+
throw new Error_js_1.StripeSignatureVerificationError(encodedHeader, encodedPayload, {
|
|
77
77
|
message: 'No webhook payload was provided.',
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -91,7 +91,7 @@ function createWebhooks(platformFunctions) {
|
|
|
91
91
|
throw new Error('Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header.');
|
|
92
92
|
}
|
|
93
93
|
if (encodedHeader == null || encodedHeader == '') {
|
|
94
|
-
throw new
|
|
94
|
+
throw new Error_js_1.StripeSignatureVerificationError(encodedHeader, encodedPayload, {
|
|
95
95
|
message: 'No stripe-signature header value was provided.',
|
|
96
96
|
});
|
|
97
97
|
}
|
|
@@ -100,12 +100,12 @@ function createWebhooks(platformFunctions) {
|
|
|
100
100
|
: encodedHeader;
|
|
101
101
|
const details = parseHeader(decodedHeader, expectedScheme);
|
|
102
102
|
if (!details || details.timestamp === -1) {
|
|
103
|
-
throw new
|
|
103
|
+
throw new Error_js_1.StripeSignatureVerificationError(decodedHeader, decodedPayload, {
|
|
104
104
|
message: 'Unable to extract timestamp and signatures from header',
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
if (!details.signatures.length) {
|
|
108
|
-
throw new
|
|
108
|
+
throw new Error_js_1.StripeSignatureVerificationError(decodedHeader, decodedPayload, {
|
|
109
109
|
message: 'No signatures found with expected scheme',
|
|
110
110
|
});
|
|
111
111
|
}
|
|
@@ -120,7 +120,7 @@ function createWebhooks(platformFunctions) {
|
|
|
120
120
|
const signatureFound = !!details.signatures.filter(platformFunctions.secureCompare.bind(platformFunctions, expectedSignature)).length;
|
|
121
121
|
if (!signatureFound) {
|
|
122
122
|
if (suspectPayloadType) {
|
|
123
|
-
throw new
|
|
123
|
+
throw new Error_js_1.StripeSignatureVerificationError(header, payload, {
|
|
124
124
|
message: 'Webhook payload must be provided as a string or a Buffer (https://nodejs.org/api/buffer.html) instance representing the _raw_ request body.' +
|
|
125
125
|
'Payload was provided as a parsed JavaScript object instead. \n' +
|
|
126
126
|
'Signature verification is impossible without access to the original signed material. \n' +
|
|
@@ -128,7 +128,7 @@ function createWebhooks(platformFunctions) {
|
|
|
128
128
|
'https://github.com/stripe/stripe-node#webhook-signing',
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
throw new
|
|
131
|
+
throw new Error_js_1.StripeSignatureVerificationError(header, payload, {
|
|
132
132
|
message: 'No signatures found matching the expected signature for payload.' +
|
|
133
133
|
' Are you passing the raw request body you received from Stripe? \n' +
|
|
134
134
|
'Learn more about webhook signing and explore webhook integration examples for various frameworks at ' +
|
|
@@ -138,7 +138,7 @@ function createWebhooks(platformFunctions) {
|
|
|
138
138
|
const timestampAge = Math.floor(Date.now() / 1000) - details.timestamp;
|
|
139
139
|
if (tolerance > 0 && timestampAge > tolerance) {
|
|
140
140
|
// @ts-ignore
|
|
141
|
-
throw new
|
|
141
|
+
throw new Error_js_1.StripeSignatureVerificationError(header, payload, {
|
|
142
142
|
message: 'Timestamp outside the tolerance zone',
|
|
143
143
|
});
|
|
144
144
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeAutoPaginationMethods = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
5
|
function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) {
|
|
6
6
|
const promiseCache = { currentPromise: null };
|
|
7
7
|
const reverseIteration = isReverseIteration(requestArgs);
|
|
@@ -171,7 +171,7 @@ function makeAutoPagingEach(asyncIteratorNext) {
|
|
|
171
171
|
const autoPagePromise = wrapAsyncIteratorWithCallback(asyncIteratorNext,
|
|
172
172
|
// @ts-ignore we might need a null check
|
|
173
173
|
onItem);
|
|
174
|
-
return (0,
|
|
174
|
+
return (0, utils_js_1.callbackifyPromiseWithTimeout)(autoPagePromise, onDone);
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
function makeAutoPagingToArray(autoPagingEach) {
|
|
@@ -197,7 +197,7 @@ function makeAutoPagingToArray(autoPagingEach) {
|
|
|
197
197
|
.catch(reject);
|
|
198
198
|
});
|
|
199
199
|
// @ts-ignore
|
|
200
|
-
return (0,
|
|
200
|
+
return (0, utils_js_1.callbackifyPromiseWithTimeout)(promise, onDone);
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) {
|
|
@@ -229,6 +229,6 @@ function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) {
|
|
|
229
229
|
}
|
|
230
230
|
function isReverseIteration(requestArgs) {
|
|
231
231
|
const args = [].slice.call(requestArgs);
|
|
232
|
-
const dataFromArgs = (0,
|
|
232
|
+
const dataFromArgs = (0, utils_js_1.getDataFromArgs)(args);
|
|
233
233
|
return !!dataFromArgs.ending_before;
|
|
234
234
|
}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NodeCryptoProvider = void 0;
|
|
4
4
|
const crypto = require("crypto");
|
|
5
|
-
const
|
|
5
|
+
const CryptoProvider_js_1 = require("./CryptoProvider.js");
|
|
6
6
|
/**
|
|
7
7
|
* `CryptoProvider which uses the Node `crypto` package for its computations.
|
|
8
8
|
*/
|
|
9
|
-
class NodeCryptoProvider extends
|
|
9
|
+
class NodeCryptoProvider extends CryptoProvider_js_1.CryptoProvider {
|
|
10
10
|
/** @override */
|
|
11
11
|
computeHMACSignature(payload, secret) {
|
|
12
12
|
return crypto
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SubtleCryptoProvider = void 0;
|
|
4
|
-
const
|
|
4
|
+
const CryptoProvider_js_1 = require("./CryptoProvider.js");
|
|
5
5
|
/**
|
|
6
6
|
* `CryptoProvider which uses the SubtleCrypto interface of the Web Crypto API.
|
|
7
7
|
*
|
|
8
8
|
* This only supports asynchronous operations.
|
|
9
9
|
*/
|
|
10
|
-
class SubtleCryptoProvider extends
|
|
10
|
+
class SubtleCryptoProvider extends CryptoProvider_js_1.CryptoProvider {
|
|
11
11
|
constructor(subtleCrypto) {
|
|
12
12
|
super();
|
|
13
13
|
// If no subtle crypto is interface, default to the global namespace. This
|
package/{lib → cjs}/multipart.js
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.multipartRequestDataProcessor = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
5
|
// Method for formatting HTTP body for the multipart/form-data specification
|
|
6
6
|
// Mostly taken from Fermata.js
|
|
7
7
|
// https://github.com/natevw/fermata/blob/5d9732a33d776ce925013a265935facd1626cc88/fermata.js#L315-L343
|
|
@@ -22,7 +22,7 @@ const multipartDataGenerator = (method, data, headers) => {
|
|
|
22
22
|
function q(s) {
|
|
23
23
|
return `"${s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ')}"`;
|
|
24
24
|
}
|
|
25
|
-
const flattenedData = (0,
|
|
25
|
+
const flattenedData = (0, utils_js_1.flattenAndStringify)(data);
|
|
26
26
|
for (const k in flattenedData) {
|
|
27
27
|
const v = flattenedData[k];
|
|
28
28
|
push(`--${segno}`);
|
|
@@ -45,7 +45,7 @@ const multipartDataGenerator = (method, data, headers) => {
|
|
|
45
45
|
function multipartRequestDataProcessor(method, data, headers, callback) {
|
|
46
46
|
data = data || {};
|
|
47
47
|
if (method !== 'POST') {
|
|
48
|
-
return callback(null, (0,
|
|
48
|
+
return callback(null, (0, utils_js_1.stringifyRequestData)(data));
|
|
49
49
|
}
|
|
50
50
|
this._stripe._platformFunctions
|
|
51
51
|
.tryBufferData(data)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FetchHttpClientResponse = exports.FetchHttpClient = void 0;
|
|
4
|
-
const
|
|
4
|
+
const HttpClient_js_1 = require("./HttpClient.js");
|
|
5
5
|
/**
|
|
6
6
|
* HTTP client which uses a `fetch` function to issue requests.
|
|
7
7
|
*
|
|
@@ -10,7 +10,7 @@ const HttpClient_1 = require("./HttpClient");
|
|
|
10
10
|
* Fetch API. As an example, this could be the function provided by the
|
|
11
11
|
* node-fetch package (https://github.com/node-fetch/node-fetch).
|
|
12
12
|
*/
|
|
13
|
-
class FetchHttpClient extends
|
|
13
|
+
class FetchHttpClient extends HttpClient_js_1.HttpClient {
|
|
14
14
|
constructor(fetchFn) {
|
|
15
15
|
super();
|
|
16
16
|
this._fetchFn = fetchFn;
|
|
@@ -54,7 +54,7 @@ class FetchHttpClient extends HttpClient_1.HttpClient {
|
|
|
54
54
|
const timeoutPromise = new Promise((_, reject) => {
|
|
55
55
|
pendingTimeoutId = setTimeout(() => {
|
|
56
56
|
pendingTimeoutId = null;
|
|
57
|
-
reject(
|
|
57
|
+
reject(HttpClient_js_1.HttpClient.makeTimeoutError());
|
|
58
58
|
}, timeout);
|
|
59
59
|
});
|
|
60
60
|
return Promise.race([fetchPromise, timeoutPromise])
|
|
@@ -69,7 +69,7 @@ class FetchHttpClient extends HttpClient_1.HttpClient {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
exports.FetchHttpClient = FetchHttpClient;
|
|
72
|
-
class FetchHttpClientResponse extends
|
|
72
|
+
class FetchHttpClientResponse extends HttpClient_js_1.HttpClientResponse {
|
|
73
73
|
constructor(res) {
|
|
74
74
|
super(res.status, FetchHttpClientResponse._transformHeadersToObject(res.headers));
|
|
75
75
|
this._res = res;
|
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NodeHttpClientResponse = exports.NodeHttpClient = void 0;
|
|
4
4
|
const http = require("http");
|
|
5
5
|
const https = require("https");
|
|
6
|
-
const
|
|
6
|
+
const HttpClient_js_1 = require("./HttpClient.js");
|
|
7
7
|
const defaultHttpAgent = new http.Agent({ keepAlive: true });
|
|
8
8
|
const defaultHttpsAgent = new https.Agent({ keepAlive: true });
|
|
9
9
|
/**
|
|
10
10
|
* HTTP client which uses the Node `http` and `https` packages to issue
|
|
11
11
|
* requests.`
|
|
12
12
|
*/
|
|
13
|
-
class NodeHttpClient extends
|
|
13
|
+
class NodeHttpClient extends HttpClient_js_1.HttpClient {
|
|
14
14
|
constructor(agent) {
|
|
15
15
|
super();
|
|
16
16
|
this._agent = agent;
|
|
@@ -36,7 +36,7 @@ class NodeHttpClient extends HttpClient_1.HttpClient {
|
|
|
36
36
|
ciphers: 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5',
|
|
37
37
|
});
|
|
38
38
|
req.setTimeout(timeout, () => {
|
|
39
|
-
req.destroy(
|
|
39
|
+
req.destroy(HttpClient_js_1.HttpClient.makeTimeoutError());
|
|
40
40
|
});
|
|
41
41
|
req.on('response', (res) => {
|
|
42
42
|
resolve(new NodeHttpClientResponse(res));
|
|
@@ -63,7 +63,7 @@ class NodeHttpClient extends HttpClient_1.HttpClient {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
exports.NodeHttpClient = NodeHttpClient;
|
|
66
|
-
class NodeHttpClientResponse extends
|
|
66
|
+
class NodeHttpClientResponse extends HttpClient_js_1.HttpClientResponse {
|
|
67
67
|
constructor(res) {
|
|
68
68
|
// @ts-ignore
|
|
69
69
|
super(res.statusCode, res.headers || {});
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -3,18 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NodePlatformFunctions = void 0;
|
|
4
4
|
const crypto = require("crypto");
|
|
5
5
|
const events_1 = require("events");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
6
|
+
const NodeCryptoProvider_js_1 = require("../crypto/NodeCryptoProvider.js");
|
|
7
|
+
const NodeHttpClient_js_1 = require("../net/NodeHttpClient.js");
|
|
8
|
+
const PlatformFunctions_js_1 = require("./PlatformFunctions.js");
|
|
9
|
+
const Error_js_1 = require("../Error.js");
|
|
10
|
+
const utils_js_1 = require("../utils.js");
|
|
11
11
|
const child_process_1 = require("child_process");
|
|
12
|
-
class StreamProcessingError extends
|
|
12
|
+
class StreamProcessingError extends Error_js_1.StripeError {
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Specializes WebPlatformFunctions using APIs available in Node.js.
|
|
16
16
|
*/
|
|
17
|
-
class NodePlatformFunctions extends
|
|
17
|
+
class NodePlatformFunctions extends PlatformFunctions_js_1.PlatformFunctions {
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
20
|
this._exec = child_process_1.exec;
|
|
@@ -95,7 +95,7 @@ class NodePlatformFunctions extends PlatformFunctions_1.PlatformFunctions {
|
|
|
95
95
|
.once('end', () => {
|
|
96
96
|
// @ts-ignore
|
|
97
97
|
const bufferData = Object.assign({}, data);
|
|
98
|
-
bufferData.file.data = (0,
|
|
98
|
+
bufferData.file.data = (0, utils_js_1.concat)(bufferArray);
|
|
99
99
|
resolve(bufferData);
|
|
100
100
|
})
|
|
101
101
|
.on('error', (err) => {
|
|
@@ -108,15 +108,15 @@ class NodePlatformFunctions extends PlatformFunctions_1.PlatformFunctions {
|
|
|
108
108
|
}
|
|
109
109
|
/** @override */
|
|
110
110
|
createNodeHttpClient(agent) {
|
|
111
|
-
return new
|
|
111
|
+
return new NodeHttpClient_js_1.NodeHttpClient(agent);
|
|
112
112
|
}
|
|
113
113
|
/** @override */
|
|
114
114
|
createDefaultHttpClient() {
|
|
115
|
-
return new
|
|
115
|
+
return new NodeHttpClient_js_1.NodeHttpClient();
|
|
116
116
|
}
|
|
117
117
|
/** @override */
|
|
118
118
|
createNodeCryptoProvider() {
|
|
119
|
-
return new
|
|
119
|
+
return new NodeCryptoProvider_js_1.NodeCryptoProvider();
|
|
120
120
|
}
|
|
121
121
|
/** @override */
|
|
122
122
|
createDefaultCryptoProvider() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PlatformFunctions = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const FetchHttpClient_js_1 = require("../net/FetchHttpClient.js");
|
|
5
|
+
const SubtleCryptoProvider_js_1 = require("../crypto/SubtleCryptoProvider.js");
|
|
6
6
|
/**
|
|
7
7
|
* Interface encapsulating various utility functions whose
|
|
8
8
|
* implementations depend on the platform / JS runtime.
|
|
@@ -71,7 +71,7 @@ class PlatformFunctions {
|
|
|
71
71
|
* passed, will default to the default `fetch` function in the global scope.
|
|
72
72
|
*/
|
|
73
73
|
createFetchHttpClient(fetchFn) {
|
|
74
|
-
return new
|
|
74
|
+
return new FetchHttpClient_js_1.FetchHttpClient(fetchFn);
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Creates an HTTP client using runtime-specific APIs.
|
|
@@ -89,7 +89,7 @@ class PlatformFunctions {
|
|
|
89
89
|
* Creates a CryptoProvider which uses the SubtleCrypto interface of the Web Crypto API.
|
|
90
90
|
*/
|
|
91
91
|
createSubtleCryptoProvider(subtleCrypto) {
|
|
92
|
-
return new
|
|
92
|
+
return new SubtleCryptoProvider_js_1.SubtleCryptoProvider(subtleCrypto);
|
|
93
93
|
}
|
|
94
94
|
createDefaultCryptoProvider() {
|
|
95
95
|
throw new Error('createDefaultCryptoProvider not implemented.');
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebPlatformFunctions = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const PlatformFunctions_js_1 = require("./PlatformFunctions.js");
|
|
5
|
+
const StripeEmitter_js_1 = require("../StripeEmitter.js");
|
|
6
6
|
/**
|
|
7
7
|
* Specializes WebPlatformFunctions using APIs available in Web workers.
|
|
8
8
|
*/
|
|
9
|
-
class WebPlatformFunctions extends
|
|
9
|
+
class WebPlatformFunctions extends PlatformFunctions_js_1.PlatformFunctions {
|
|
10
10
|
/** @override */
|
|
11
11
|
getUname() {
|
|
12
12
|
return Promise.resolve(null);
|
|
13
13
|
}
|
|
14
14
|
/** @override */
|
|
15
15
|
createEmitter() {
|
|
16
|
-
return new
|
|
16
|
+
return new StripeEmitter_js_1.StripeEmitter();
|
|
17
17
|
}
|
|
18
18
|
/** @override */
|
|
19
19
|
tryBufferData(data) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// File generated from our OpenAPI spec
|
|
2
|
-
'use strict';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.AccountLinks = void 0;
|
|
5
|
-
const
|
|
6
|
-
const stripeMethod =
|
|
7
|
-
exports.AccountLinks =
|
|
5
|
+
const StripeResource_js_1 = require("../StripeResource.js");
|
|
6
|
+
const stripeMethod = StripeResource_js_1.StripeResource.method;
|
|
7
|
+
exports.AccountLinks = StripeResource_js_1.StripeResource.extend({
|
|
8
8
|
create: stripeMethod({
|
|
9
9
|
method: 'POST',
|
|
10
10
|
fullPath: '/v1/account_links',
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// File generated from our OpenAPI spec
|
|
2
|
-
'use strict';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Accounts = void 0;
|
|
5
|
-
const
|
|
6
|
-
const stripeMethod =
|
|
5
|
+
const StripeResource_js_1 = require("../StripeResource.js");
|
|
6
|
+
const stripeMethod = StripeResource_js_1.StripeResource.method;
|
|
7
7
|
// Since path can either be `account` or `accounts`, support both through stripeMethod path;
|
|
8
|
-
exports.Accounts =
|
|
8
|
+
exports.Accounts = StripeResource_js_1.StripeResource.extend({
|
|
9
9
|
create: stripeMethod({
|
|
10
10
|
method: 'POST',
|
|
11
11
|
fullPath: '/v1/accounts',
|