@stripe/stripe-js 8.6.0 → 8.6.3

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/dist/index.js CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _typeof(obj) {
6
+ "@babel/helpers - typeof";
7
+
8
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
9
+ _typeof = function (obj) {
10
+ return typeof obj;
11
+ };
12
+ } else {
13
+ _typeof = function (obj) {
14
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
15
+ };
16
+ }
17
+
18
+ return _typeof(obj);
19
+ }
20
+
5
21
  var RELEASE_TRAIN = 'clover';
6
22
 
7
23
  var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion(version) {
@@ -55,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
55
71
 
56
72
  stripe._registerWrapper({
57
73
  name: 'stripe-js',
58
- version: "8.6.0",
74
+ version: "8.6.3",
59
75
  startTime: startTime
60
76
  });
61
77
  };
@@ -145,13 +161,18 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
145
161
  }
146
162
 
147
163
  var pk = args[0];
164
+
165
+ if (typeof pk !== 'string') {
166
+ throw new Error("Expected publishable key to be of type string, got type ".concat(_typeof(pk), " instead."));
167
+ }
168
+
148
169
  var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
149
170
 
150
171
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
151
172
  var expectedVersion = RELEASE_TRAIN;
152
173
 
153
174
  if (isTestKey && version !== expectedVersion) {
154
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
175
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.3", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
155
176
  }
156
177
 
157
178
  var stripe = maybeStripe.apply(undefined, args);
package/dist/index.mjs CHANGED
@@ -1,3 +1,19 @@
1
+ function _typeof(obj) {
2
+ "@babel/helpers - typeof";
3
+
4
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
5
+ _typeof = function (obj) {
6
+ return typeof obj;
7
+ };
8
+ } else {
9
+ _typeof = function (obj) {
10
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
11
+ };
12
+ }
13
+
14
+ return _typeof(obj);
15
+ }
16
+
1
17
  var RELEASE_TRAIN = 'clover';
2
18
 
3
19
  var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion(version) {
@@ -51,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
51
67
 
52
68
  stripe._registerWrapper({
53
69
  name: 'stripe-js',
54
- version: "8.6.0",
70
+ version: "8.6.3",
55
71
  startTime: startTime
56
72
  });
57
73
  };
@@ -141,13 +157,18 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
141
157
  }
142
158
 
143
159
  var pk = args[0];
160
+
161
+ if (typeof pk !== 'string') {
162
+ throw new Error("Expected publishable key to be of type string, got type ".concat(_typeof(pk), " instead."));
163
+ }
164
+
144
165
  var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
145
166
 
146
167
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
147
168
  var expectedVersion = RELEASE_TRAIN;
148
169
 
149
170
  if (isTestKey && version !== expectedVersion) {
150
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
171
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.3", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
151
172
  }
152
173
 
153
174
  var stripe = maybeStripe.apply(undefined, args);
package/dist/pure.js CHANGED
@@ -71,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
71
71
 
72
72
  stripe._registerWrapper({
73
73
  name: 'stripe-js',
74
- version: "8.6.0",
74
+ version: "8.6.3",
75
75
  startTime: startTime
76
76
  });
77
77
  };
@@ -161,13 +161,18 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
161
161
  }
162
162
 
163
163
  var pk = args[0];
164
+
165
+ if (typeof pk !== 'string') {
166
+ throw new Error("Expected publishable key to be of type string, got type ".concat(_typeof(pk), " instead."));
167
+ }
168
+
164
169
  var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
165
170
 
166
171
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
167
172
  var expectedVersion = RELEASE_TRAIN;
168
173
 
169
174
  if (isTestKey && version !== expectedVersion) {
170
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
175
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.3", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
171
176
  }
172
177
 
173
178
  var stripe = maybeStripe.apply(undefined, args);
package/dist/pure.mjs CHANGED
@@ -67,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
67
67
 
68
68
  stripe._registerWrapper({
69
69
  name: 'stripe-js',
70
- version: "8.6.0",
70
+ version: "8.6.3",
71
71
  startTime: startTime
72
72
  });
73
73
  };
@@ -157,13 +157,18 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
157
157
  }
158
158
 
159
159
  var pk = args[0];
160
+
161
+ if (typeof pk !== 'string') {
162
+ throw new Error("Expected publishable key to be of type string, got type ".concat(_typeof(pk), " instead."));
163
+ }
164
+
160
165
  var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
161
166
 
162
167
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
163
168
  var expectedVersion = RELEASE_TRAIN;
164
169
 
165
170
  if (isTestKey && version !== expectedVersion) {
166
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
171
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.3", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
167
172
  }
168
173
 
169
174
  var stripe = maybeStripe.apply(undefined, args);
@@ -39,6 +39,7 @@ import {
39
39
  StripeExpressCheckoutElementOptions,
40
40
  StripeAddressElementGetElementOptions,
41
41
  StripeTaxIdElement,
42
+ StripeTaxIdElementOptions,
42
43
  } from './elements';
43
44
  import {StripeError} from './stripe';
44
45
 
@@ -372,6 +373,29 @@ export interface StripeElements {
372
373
  elementType: 'issuingCardCopyButton',
373
374
  options: StripeIssuingCardCopyButtonElementOptions
374
375
  ): StripeIssuingCardCopyButtonElement;
376
+
377
+ /////////////////////////////
378
+ /// taxId
379
+ /////////////////////////////
380
+
381
+ /**
382
+ * Requires beta access:
383
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
384
+ *
385
+ * Creates a `TaxIdElement`.
386
+ */
387
+ create(
388
+ elementType: 'taxId',
389
+ options?: StripeTaxIdElementOptions
390
+ ): StripeTaxIdElement;
391
+
392
+ /**
393
+ * Requires beta access:
394
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
395
+ *
396
+ * Looks up a previously created `Element` by its type.
397
+ */
398
+ getElement(elementType: 'taxId'): StripeTaxIdElement | null;
375
399
  }
376
400
 
377
401
  export type StripeElementType =
@@ -691,6 +715,13 @@ interface BaseStripeElementsOptions {
691
715
  * @docs https://docs.stripe.com/js/elements_object/create#stripe_elements-options-syncAddressCheckbox
692
716
  */
693
717
  syncAddressCheckbox?: 'billing' | 'shipping' | 'none';
718
+
719
+ /**
720
+ * Allows PaymentMethods to be created from the Elements instance.
721
+ *
722
+ * @docs https://docs.stripe.com/js/elements_object/create#stripe_elements-options-paymentMethodCreation
723
+ */
724
+ paymentMethodCreation?: 'manual';
694
725
  }
695
726
 
696
727
  export interface StripeElementsOptionsClientSecret
@@ -803,11 +834,6 @@ interface StripeElementsOptionsModeBase extends BaseStripeElementsOptions {
803
834
  */
804
835
  payment_method_configuration?: string;
805
836
 
806
- /**
807
- * Allows PaymentMethods to be created from the Elements instance.
808
- */
809
- paymentMethodCreation?: 'manual';
810
-
811
837
  /**
812
838
  * Additional payment-method-specific options for configuring Payment Element behavior.
813
839
  *
@@ -39,6 +39,7 @@ import {
39
39
  StripeExpressCheckoutElementOptions,
40
40
  StripeAddressElementGetElementOptions,
41
41
  StripeTaxIdElement,
42
+ StripeTaxIdElementOptions,
42
43
  } from './elements';
43
44
  import {StripeError} from './stripe';
44
45
 
@@ -372,6 +373,29 @@ export interface StripeElements {
372
373
  elementType: 'issuingCardCopyButton',
373
374
  options: StripeIssuingCardCopyButtonElementOptions
374
375
  ): StripeIssuingCardCopyButtonElement;
376
+
377
+ /////////////////////////////
378
+ /// taxId
379
+ /////////////////////////////
380
+
381
+ /**
382
+ * Requires beta access:
383
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
384
+ *
385
+ * Creates a `TaxIdElement`.
386
+ */
387
+ create(
388
+ elementType: 'taxId',
389
+ options?: StripeTaxIdElementOptions
390
+ ): StripeTaxIdElement;
391
+
392
+ /**
393
+ * Requires beta access:
394
+ * Contact [Stripe support](https://support.stripe.com/) for more information.
395
+ *
396
+ * Looks up a previously created `Element` by its type.
397
+ */
398
+ getElement(elementType: 'taxId'): StripeTaxIdElement | null;
375
399
  }
376
400
 
377
401
  export type StripeElementType =
@@ -691,6 +715,13 @@ interface BaseStripeElementsOptions {
691
715
  * @docs https://docs.stripe.com/js/elements_object/create#stripe_elements-options-syncAddressCheckbox
692
716
  */
693
717
  syncAddressCheckbox?: 'billing' | 'shipping' | 'none';
718
+
719
+ /**
720
+ * Allows PaymentMethods to be created from the Elements instance.
721
+ *
722
+ * @docs https://docs.stripe.com/js/elements_object/create#stripe_elements-options-paymentMethodCreation
723
+ */
724
+ paymentMethodCreation?: 'manual';
694
725
  }
695
726
 
696
727
  export interface StripeElementsOptionsClientSecret
@@ -803,11 +834,6 @@ interface StripeElementsOptionsModeBase extends BaseStripeElementsOptions {
803
834
  */
804
835
  payment_method_configuration?: string;
805
836
 
806
- /**
807
- * Allows PaymentMethods to be created from the Elements instance.
808
- */
809
- paymentMethodCreation?: 'manual';
810
-
811
837
  /**
812
838
  * Additional payment-method-specific options for configuring Payment Element behavior.
813
839
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/stripe-js",
3
- "version": "8.6.0",
3
+ "version": "8.6.3",
4
4
  "description": "Stripe.js loading utility",
5
5
  "repository": "github:stripe/stripe-js",
6
6
  "main": "lib/index.js",
@@ -14,6 +14,7 @@
14
14
  "test:unit": "jest",
15
15
  "test:package-types": "attw --pack . --entrypoints ./lib ./pure",
16
16
  "test:types": "zx ./tests/types/scripts/test.mjs",
17
+ "update-ts-snapshot": "zx ./tests/types/scripts/update-ts-snapshot.mjs",
17
18
  "lint": "eslint '{src,types}/**/*.{ts,js}' && yarn prettier-check",
18
19
  "typecheck": "tsc",
19
20
  "copy-types": "./scripts/copy-types",
package/src/shared.ts CHANGED
@@ -169,6 +169,13 @@ export const initStripe = (
169
169
  }
170
170
 
171
171
  const pk = args[0];
172
+
173
+ if (typeof pk !== 'string') {
174
+ throw new Error(
175
+ `Expected publishable key to be of type string, got type ${typeof pk} instead.`
176
+ );
177
+ }
178
+
172
179
  const isTestKey = pk.match(/^pk_test/);
173
180
 
174
181
  // @ts-expect-error this is not publicly typed