@stripe/connect-js 3.3.11 → 3.3.12

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.
@@ -1,5 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function */
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
+ const ConnectElementCommonMethodConfig = {
4
+ setOnLoadError: _listener => {},
5
+ setOnLoaderStart: _listener => {}
6
+ };
3
7
  const ConnectElementCustomMethodConfig = {
4
8
  "account-onboarding": {
5
9
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
@@ -119,15 +123,14 @@ const initStripeConnect = (stripePromise, initParams) => {
119
123
  htmlName = tagName;
120
124
  }
121
125
  const element = document.createElement(htmlName);
122
- if (hasCustomMethod(tagName)) {
123
- const methods = ConnectElementCustomMethodConfig[tagName];
124
- for (const method in methods) {
125
- element[method] = function (value) {
126
- stripeConnectInstance.then(() => {
127
- this[`${method}InternalOnly`](value);
128
- });
129
- };
130
- }
126
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
127
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
128
+ for (const method in methods) {
129
+ element[method] = function (value) {
130
+ stripeConnectInstance.then(() => {
131
+ this[`${method}InternalOnly`](value);
132
+ });
133
+ };
131
134
  }
132
135
  stripeConnectInstance.then(instance => {
133
136
  if (!element.isConnected && !element.setConnector) {
@@ -177,7 +180,7 @@ const createWrapper = stripeConnect => {
177
180
  sdk: true,
178
181
  sdkOptions: {
179
182
  // This will be replaced by the npm package version when bundling
180
- sdkVersion: "3.3.11"
183
+ sdkVersion: "3.3.12"
181
184
  }
182
185
  })
183
186
  }));
package/dist/connect.js CHANGED
@@ -4,6 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  /* eslint-disable @typescript-eslint/no-empty-function */
6
6
  /* eslint-disable @typescript-eslint/no-unused-vars */
7
+ const ConnectElementCommonMethodConfig = {
8
+ setOnLoadError: _listener => {},
9
+ setOnLoaderStart: _listener => {}
10
+ };
7
11
  const ConnectElementCustomMethodConfig = {
8
12
  "account-onboarding": {
9
13
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
@@ -123,15 +127,14 @@ const initStripeConnect = (stripePromise, initParams) => {
123
127
  htmlName = tagName;
124
128
  }
125
129
  const element = document.createElement(htmlName);
126
- if (hasCustomMethod(tagName)) {
127
- const methods = ConnectElementCustomMethodConfig[tagName];
128
- for (const method in methods) {
129
- element[method] = function (value) {
130
- stripeConnectInstance.then(() => {
131
- this[`${method}InternalOnly`](value);
132
- });
133
- };
134
- }
130
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
131
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
132
+ for (const method in methods) {
133
+ element[method] = function (value) {
134
+ stripeConnectInstance.then(() => {
135
+ this[`${method}InternalOnly`](value);
136
+ });
137
+ };
135
138
  }
136
139
  stripeConnectInstance.then(instance => {
137
140
  if (!element.isConnected && !element.setConnector) {
@@ -181,7 +184,7 @@ const createWrapper = stripeConnect => {
181
184
  sdk: true,
182
185
  sdkOptions: {
183
186
  // This will be replaced by the npm package version when bundling
184
- sdkVersion: "3.3.11"
187
+ sdkVersion: "3.3.12"
185
188
  }
186
189
  })
187
190
  }));
package/dist/pure.esm.js CHANGED
@@ -1,5 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function */
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
+ const ConnectElementCommonMethodConfig = {
4
+ setOnLoadError: _listener => {},
5
+ setOnLoaderStart: _listener => {}
6
+ };
3
7
  const ConnectElementCustomMethodConfig = {
4
8
  "account-onboarding": {
5
9
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
@@ -119,15 +123,14 @@ const initStripeConnect = (stripePromise, initParams) => {
119
123
  htmlName = tagName;
120
124
  }
121
125
  const element = document.createElement(htmlName);
122
- if (hasCustomMethod(tagName)) {
123
- const methods = ConnectElementCustomMethodConfig[tagName];
124
- for (const method in methods) {
125
- element[method] = function (value) {
126
- stripeConnectInstance.then(() => {
127
- this[`${method}InternalOnly`](value);
128
- });
129
- };
130
- }
126
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
127
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
128
+ for (const method in methods) {
129
+ element[method] = function (value) {
130
+ stripeConnectInstance.then(() => {
131
+ this[`${method}InternalOnly`](value);
132
+ });
133
+ };
131
134
  }
132
135
  stripeConnectInstance.then(instance => {
133
136
  if (!element.isConnected && !element.setConnector) {
@@ -177,7 +180,7 @@ const createWrapper = stripeConnect => {
177
180
  sdk: true,
178
181
  sdkOptions: {
179
182
  // This will be replaced by the npm package version when bundling
180
- sdkVersion: "3.3.11"
183
+ sdkVersion: "3.3.12"
181
184
  }
182
185
  })
183
186
  }));
package/dist/pure.js CHANGED
@@ -4,6 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  /* eslint-disable @typescript-eslint/no-empty-function */
6
6
  /* eslint-disable @typescript-eslint/no-unused-vars */
7
+ const ConnectElementCommonMethodConfig = {
8
+ setOnLoadError: _listener => {},
9
+ setOnLoaderStart: _listener => {}
10
+ };
7
11
  const ConnectElementCustomMethodConfig = {
8
12
  "account-onboarding": {
9
13
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
@@ -123,15 +127,14 @@ const initStripeConnect = (stripePromise, initParams) => {
123
127
  htmlName = tagName;
124
128
  }
125
129
  const element = document.createElement(htmlName);
126
- if (hasCustomMethod(tagName)) {
127
- const methods = ConnectElementCustomMethodConfig[tagName];
128
- for (const method in methods) {
129
- element[method] = function (value) {
130
- stripeConnectInstance.then(() => {
131
- this[`${method}InternalOnly`](value);
132
- });
133
- };
134
- }
130
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
131
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
132
+ for (const method in methods) {
133
+ element[method] = function (value) {
134
+ stripeConnectInstance.then(() => {
135
+ this[`${method}InternalOnly`](value);
136
+ });
137
+ };
135
138
  }
136
139
  stripeConnectInstance.then(instance => {
137
140
  if (!element.isConnected && !element.setConnector) {
@@ -181,7 +184,7 @@ const createWrapper = stripeConnect => {
181
184
  sdk: true,
182
185
  sdkOptions: {
183
186
  // This will be replaced by the npm package version when bundling
184
- sdkVersion: "3.3.11"
187
+ sdkVersion: "3.3.12"
185
188
  }
186
189
  })
187
190
  }));
@@ -6,6 +6,46 @@ export type NotificationCount = {
6
6
  total: number;
7
7
  actionRequired: number;
8
8
  };
9
+ export type LoaderStart = {
10
+ elementTagName: string;
11
+ };
12
+ export type LoadError = {
13
+ elementTagName: string;
14
+ error: EmbeddedError;
15
+ };
16
+ export type EmbeddedError = {
17
+ type: EmbeddedErrorType;
18
+ message?: string;
19
+ };
20
+ export type EmbeddedErrorType =
21
+ /**
22
+ * Failure to connect to Stripe's API.
23
+ */
24
+ "api_connection_error"
25
+ /**
26
+ * Failure to perform the authentication flow within Connect Embedded Components
27
+ */
28
+ | "authentication_error"
29
+ /**
30
+ * Account session create failed
31
+ */
32
+ | "account_session_create_error"
33
+ /**
34
+ * Request failed with an 4xx status code, typically caused by platform configuration issues
35
+ */
36
+ | "invalid_request_error"
37
+ /**
38
+ * Too many requests hit the API too quickly.
39
+ */
40
+ | "rate_limit_error"
41
+ /**
42
+ * API errors covering any other type of problem (e.g., a temporary problem with Stripe's servers), and are extremely uncommon.
43
+ */
44
+ | "api_error";
45
+ export declare const ConnectElementCommonMethodConfig: {
46
+ setOnLoadError: (_listener: (({ error, elementTagName }: LoadError) => void) | undefined) => void;
47
+ setOnLoaderStart: (_listener: (({ elementTagName }: LoaderStart) => void) | undefined) => void;
48
+ };
9
49
  export declare const ConnectElementCustomMethodConfig: {
10
50
  "account-onboarding": {
11
51
  setFullTermsOfServiceUrl: (_termOfServiceUrl: string | undefined) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/connect-js",
3
- "version": "3.3.11",
3
+ "version": "3.3.12",
4
4
  "description": "Connect.js loading utility package",
5
5
  "main": "dist/connect.js",
6
6
  "module": "dist/connect.esm.js",
package/src/shared.ts CHANGED
@@ -4,7 +4,10 @@ import {
4
4
  ConnectElementTagName,
5
5
  ConnectHTMLElementRecord
6
6
  } from "../types";
7
- import { ConnectElementCustomMethodConfig } from "../types/config";
7
+ import {
8
+ ConnectElementCommonMethodConfig,
9
+ ConnectElementCustomMethodConfig
10
+ } from "../types/config";
8
11
 
9
12
  export type LoadConnectAndInitialize = (
10
13
  initParams: IStripeConnectInitParams
@@ -170,15 +173,16 @@ export const initStripeConnect = (
170
173
  }
171
174
  const element = document.createElement(htmlName);
172
175
 
173
- if (hasCustomMethod(tagName)) {
174
- const methods = ConnectElementCustomMethodConfig[tagName];
175
- for (const method in methods) {
176
- (element as any)[method] = function(value: any) {
177
- stripeConnectInstance.then(() => {
178
- this[`${method}InternalOnly`](value);
179
- });
180
- };
181
- }
176
+ const customMethods = hasCustomMethod(tagName)
177
+ ? ConnectElementCustomMethodConfig[tagName]
178
+ : {};
179
+ const methods = { ...customMethods, ...ConnectElementCommonMethodConfig };
180
+ for (const method in methods) {
181
+ (element as any)[method] = function(value: any) {
182
+ stripeConnectInstance.then(() => {
183
+ this[`${method}InternalOnly`](value);
184
+ });
185
+ };
182
186
  }
183
187
 
184
188
  stripeConnectInstance.then(instance => {
package/types/config.ts CHANGED
@@ -11,6 +11,55 @@ export type NotificationCount = {
11
11
  actionRequired: number;
12
12
  };
13
13
 
14
+ export type LoaderStart = {
15
+ elementTagName: string;
16
+ };
17
+
18
+ export type LoadError = {
19
+ elementTagName: string;
20
+ error: EmbeddedError;
21
+ };
22
+
23
+ export type EmbeddedError = {
24
+ type: EmbeddedErrorType;
25
+ message?: string;
26
+ };
27
+
28
+ export type EmbeddedErrorType =
29
+ /**
30
+ * Failure to connect to Stripe's API.
31
+ */
32
+ | "api_connection_error"
33
+ /**
34
+ * Failure to perform the authentication flow within Connect Embedded Components
35
+ */
36
+ | "authentication_error"
37
+ /**
38
+ * Account session create failed
39
+ */
40
+ | "account_session_create_error"
41
+ /**
42
+ * Request failed with an 4xx status code, typically caused by platform configuration issues
43
+ */
44
+ | "invalid_request_error"
45
+ /**
46
+ * Too many requests hit the API too quickly.
47
+ */
48
+ | "rate_limit_error"
49
+ /**
50
+ * API errors covering any other type of problem (e.g., a temporary problem with Stripe's servers), and are extremely uncommon.
51
+ */
52
+ | "api_error";
53
+
54
+ export const ConnectElementCommonMethodConfig = {
55
+ setOnLoadError: (
56
+ _listener: (({ error, elementTagName }: LoadError) => void) | undefined
57
+ ): void => {},
58
+ setOnLoaderStart: (
59
+ _listener: (({ elementTagName }: LoaderStart) => void) | undefined
60
+ ): void => {}
61
+ };
62
+
14
63
  export const ConnectElementCustomMethodConfig = {
15
64
  "account-onboarding": {
16
65
  setFullTermsOfServiceUrl: (
package/types/shared.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- import { ConnectElementCustomMethodConfig } from "./config";
1
+ import {
2
+ ConnectElementCustomMethodConfig,
3
+ ConnectElementCommonMethodConfig
4
+ } from "./config";
2
5
 
3
6
  export declare type LoadConnectAndInitialize = (
4
7
  initParams: IStripeConnectInitParams
@@ -412,12 +415,14 @@ export interface IStripeConnectInitParams {
412
415
  }
413
416
 
414
417
  type ConnectElementCustomMethods = typeof ConnectElementCustomMethodConfig;
418
+ type ConnectElementCommonMethods = typeof ConnectElementCommonMethodConfig;
415
419
 
416
420
  export type ConnectHTMLElementRecord = {
417
421
  [K in keyof ConnectElementCustomMethods]: HTMLElement &
418
- ConnectElementCustomMethods[K];
422
+ ConnectElementCustomMethods[K] &
423
+ ConnectElementCommonMethods;
419
424
  } & {
420
- [key: string]: HTMLElement;
425
+ [key: string]: HTMLElement & ConnectElementCommonMethods;
421
426
  };
422
427
 
423
428
  export interface StripeConnectInstance {