@stripe/connect-js 3.0.0 → 3.0.1
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/connect.esm.js +26 -1
- package/dist/connect.js +26 -1
- package/dist/pure.esm.js +26 -1
- package/dist/pure.js +26 -1
- package/dist/types/config.d.ts +9 -0
- package/package.json +1 -1
- package/src/shared.ts +19 -0
- package/types/config.ts +27 -0
- package/types/shared.d.ts +9 -21
- /package/dist/{pure.d.ts → src/pure.d.ts} +0 -0
- /package/dist/{shared.d.ts → src/shared.d.ts} +0 -0
- /package/dist/{utils → src/utils}/jestHelpers.d.ts +0 -0
- /package/dist/{utils → src/utils}/jestSetup.d.ts +0 -0
package/dist/connect.esm.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
const ConnectElementCustomMethodConfig = {
|
|
4
|
+
"account-onboarding": {
|
|
5
|
+
setFullTermsOfServiceUrl: termOfServiceUrl => {},
|
|
6
|
+
setRecipientTermsOfServiceUrl: recipientTermsOfServiceUrl => {},
|
|
7
|
+
setPrivacyPolicyUrl: privacyPolicyUrl => {},
|
|
8
|
+
setSkipTermsOfServiceCollection: skipTermsOfServiceCollection => {},
|
|
9
|
+
setOnExit: listener => {}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
1
13
|
const componentNameMapping = {
|
|
2
14
|
"account-onboarding": "stripe-connect-account-onboarding"
|
|
3
15
|
};
|
|
@@ -59,6 +71,9 @@ const loadScript = () => {
|
|
|
59
71
|
});
|
|
60
72
|
return stripePromise;
|
|
61
73
|
};
|
|
74
|
+
const hasCustomMethod = tagName => {
|
|
75
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
76
|
+
};
|
|
62
77
|
const initStripeConnect = (stripePromise, initParams) => {
|
|
63
78
|
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
64
79
|
return {
|
|
@@ -68,6 +83,16 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
68
83
|
htmlName = tagName;
|
|
69
84
|
}
|
|
70
85
|
const element = document.createElement(htmlName);
|
|
86
|
+
if (hasCustomMethod(tagName)) {
|
|
87
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
88
|
+
for (const method in methods) {
|
|
89
|
+
element[method] = function (value) {
|
|
90
|
+
stripeConnectInstance.then(() => {
|
|
91
|
+
this[`${method}InternalOnly`](value);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
71
96
|
stripeConnectInstance.then(instance => {
|
|
72
97
|
element.setConnector(instance.connect);
|
|
73
98
|
});
|
|
@@ -100,7 +125,7 @@ const createWrapper = stripeConnect => {
|
|
|
100
125
|
sdk: true,
|
|
101
126
|
sdkOptions: {
|
|
102
127
|
// This will be replaced by the npm package version when bundling
|
|
103
|
-
sdkVersion: "3.0.
|
|
128
|
+
sdkVersion: "3.0.1"
|
|
104
129
|
}
|
|
105
130
|
})
|
|
106
131
|
}));
|
package/dist/connect.js
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7
|
+
const ConnectElementCustomMethodConfig = {
|
|
8
|
+
"account-onboarding": {
|
|
9
|
+
setFullTermsOfServiceUrl: termOfServiceUrl => {},
|
|
10
|
+
setRecipientTermsOfServiceUrl: recipientTermsOfServiceUrl => {},
|
|
11
|
+
setPrivacyPolicyUrl: privacyPolicyUrl => {},
|
|
12
|
+
setSkipTermsOfServiceCollection: skipTermsOfServiceCollection => {},
|
|
13
|
+
setOnExit: listener => {}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
5
17
|
const componentNameMapping = {
|
|
6
18
|
"account-onboarding": "stripe-connect-account-onboarding"
|
|
7
19
|
};
|
|
@@ -63,6 +75,9 @@ const loadScript = () => {
|
|
|
63
75
|
});
|
|
64
76
|
return stripePromise;
|
|
65
77
|
};
|
|
78
|
+
const hasCustomMethod = tagName => {
|
|
79
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
80
|
+
};
|
|
66
81
|
const initStripeConnect = (stripePromise, initParams) => {
|
|
67
82
|
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
68
83
|
return {
|
|
@@ -72,6 +87,16 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
72
87
|
htmlName = tagName;
|
|
73
88
|
}
|
|
74
89
|
const element = document.createElement(htmlName);
|
|
90
|
+
if (hasCustomMethod(tagName)) {
|
|
91
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
92
|
+
for (const method in methods) {
|
|
93
|
+
element[method] = function (value) {
|
|
94
|
+
stripeConnectInstance.then(() => {
|
|
95
|
+
this[`${method}InternalOnly`](value);
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
75
100
|
stripeConnectInstance.then(instance => {
|
|
76
101
|
element.setConnector(instance.connect);
|
|
77
102
|
});
|
|
@@ -104,7 +129,7 @@ const createWrapper = stripeConnect => {
|
|
|
104
129
|
sdk: true,
|
|
105
130
|
sdkOptions: {
|
|
106
131
|
// This will be replaced by the npm package version when bundling
|
|
107
|
-
sdkVersion: "3.0.
|
|
132
|
+
sdkVersion: "3.0.1"
|
|
108
133
|
}
|
|
109
134
|
})
|
|
110
135
|
}));
|
package/dist/pure.esm.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
const ConnectElementCustomMethodConfig = {
|
|
4
|
+
"account-onboarding": {
|
|
5
|
+
setFullTermsOfServiceUrl: termOfServiceUrl => {},
|
|
6
|
+
setRecipientTermsOfServiceUrl: recipientTermsOfServiceUrl => {},
|
|
7
|
+
setPrivacyPolicyUrl: privacyPolicyUrl => {},
|
|
8
|
+
setSkipTermsOfServiceCollection: skipTermsOfServiceCollection => {},
|
|
9
|
+
setOnExit: listener => {}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
1
13
|
const componentNameMapping = {
|
|
2
14
|
"account-onboarding": "stripe-connect-account-onboarding"
|
|
3
15
|
};
|
|
@@ -59,6 +71,9 @@ const loadScript = () => {
|
|
|
59
71
|
});
|
|
60
72
|
return stripePromise;
|
|
61
73
|
};
|
|
74
|
+
const hasCustomMethod = tagName => {
|
|
75
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
76
|
+
};
|
|
62
77
|
const initStripeConnect = (stripePromise, initParams) => {
|
|
63
78
|
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
64
79
|
return {
|
|
@@ -68,6 +83,16 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
68
83
|
htmlName = tagName;
|
|
69
84
|
}
|
|
70
85
|
const element = document.createElement(htmlName);
|
|
86
|
+
if (hasCustomMethod(tagName)) {
|
|
87
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
88
|
+
for (const method in methods) {
|
|
89
|
+
element[method] = function (value) {
|
|
90
|
+
stripeConnectInstance.then(() => {
|
|
91
|
+
this[`${method}InternalOnly`](value);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
71
96
|
stripeConnectInstance.then(instance => {
|
|
72
97
|
element.setConnector(instance.connect);
|
|
73
98
|
});
|
|
@@ -100,7 +125,7 @@ const createWrapper = stripeConnect => {
|
|
|
100
125
|
sdk: true,
|
|
101
126
|
sdkOptions: {
|
|
102
127
|
// This will be replaced by the npm package version when bundling
|
|
103
|
-
sdkVersion: "3.0.
|
|
128
|
+
sdkVersion: "3.0.1"
|
|
104
129
|
}
|
|
105
130
|
})
|
|
106
131
|
}));
|
package/dist/pure.js
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7
|
+
const ConnectElementCustomMethodConfig = {
|
|
8
|
+
"account-onboarding": {
|
|
9
|
+
setFullTermsOfServiceUrl: termOfServiceUrl => {},
|
|
10
|
+
setRecipientTermsOfServiceUrl: recipientTermsOfServiceUrl => {},
|
|
11
|
+
setPrivacyPolicyUrl: privacyPolicyUrl => {},
|
|
12
|
+
setSkipTermsOfServiceCollection: skipTermsOfServiceCollection => {},
|
|
13
|
+
setOnExit: listener => {}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
5
17
|
const componentNameMapping = {
|
|
6
18
|
"account-onboarding": "stripe-connect-account-onboarding"
|
|
7
19
|
};
|
|
@@ -63,6 +75,9 @@ const loadScript = () => {
|
|
|
63
75
|
});
|
|
64
76
|
return stripePromise;
|
|
65
77
|
};
|
|
78
|
+
const hasCustomMethod = tagName => {
|
|
79
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
80
|
+
};
|
|
66
81
|
const initStripeConnect = (stripePromise, initParams) => {
|
|
67
82
|
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
68
83
|
return {
|
|
@@ -72,6 +87,16 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
72
87
|
htmlName = tagName;
|
|
73
88
|
}
|
|
74
89
|
const element = document.createElement(htmlName);
|
|
90
|
+
if (hasCustomMethod(tagName)) {
|
|
91
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
92
|
+
for (const method in methods) {
|
|
93
|
+
element[method] = function (value) {
|
|
94
|
+
stripeConnectInstance.then(() => {
|
|
95
|
+
this[`${method}InternalOnly`](value);
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
75
100
|
stripeConnectInstance.then(instance => {
|
|
76
101
|
element.setConnector(instance.connect);
|
|
77
102
|
});
|
|
@@ -104,7 +129,7 @@ const createWrapper = stripeConnect => {
|
|
|
104
129
|
sdk: true,
|
|
105
130
|
sdkOptions: {
|
|
106
131
|
// This will be replaced by the npm package version when bundling
|
|
107
|
-
sdkVersion: "3.0.
|
|
132
|
+
sdkVersion: "3.0.1"
|
|
108
133
|
}
|
|
109
134
|
})
|
|
110
135
|
}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const ConnectElementCustomMethodConfig: {
|
|
2
|
+
"account-onboarding": {
|
|
3
|
+
setFullTermsOfServiceUrl: (termOfServiceUrl: string | undefined) => void;
|
|
4
|
+
setRecipientTermsOfServiceUrl: (recipientTermsOfServiceUrl: string | undefined) => void;
|
|
5
|
+
setPrivacyPolicyUrl: (privacyPolicyUrl: string | undefined) => void;
|
|
6
|
+
setSkipTermsOfServiceCollection: (skipTermsOfServiceCollection: boolean | undefined) => void;
|
|
7
|
+
setOnExit: (listener: (() => void) | undefined) => void;
|
|
8
|
+
};
|
|
9
|
+
};
|
package/package.json
CHANGED
package/src/shared.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ConnectElementTagName,
|
|
5
5
|
ConnectHTMLElementRecord
|
|
6
6
|
} from "../types";
|
|
7
|
+
import { ConnectElementCustomMethodConfig } from "../types/config";
|
|
7
8
|
|
|
8
9
|
export type LoadConnectAndInitialize = (
|
|
9
10
|
initParams: IStripeConnectInitParams
|
|
@@ -108,6 +109,12 @@ export const loadScript = (): Promise<StripeConnectWrapper> => {
|
|
|
108
109
|
return stripePromise;
|
|
109
110
|
};
|
|
110
111
|
|
|
112
|
+
const hasCustomMethod = (
|
|
113
|
+
tagName: ConnectElementTagName
|
|
114
|
+
): tagName is keyof typeof ConnectElementCustomMethodConfig => {
|
|
115
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
116
|
+
};
|
|
117
|
+
|
|
111
118
|
export const initStripeConnect = (
|
|
112
119
|
stripePromise: Promise<StripeConnectWrapper>,
|
|
113
120
|
initParams: IStripeConnectInitParams
|
|
@@ -123,6 +130,18 @@ export const initStripeConnect = (
|
|
|
123
130
|
htmlName = (tagName as unknown) as ConnectElementHTMLName;
|
|
124
131
|
}
|
|
125
132
|
const element = document.createElement(htmlName);
|
|
133
|
+
|
|
134
|
+
if (hasCustomMethod(tagName)) {
|
|
135
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
136
|
+
for (const method in methods) {
|
|
137
|
+
(element as any)[method] = function(value: any) {
|
|
138
|
+
stripeConnectInstance.then(() => {
|
|
139
|
+
this[`${method}InternalOnly`](value);
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
126
145
|
stripeConnectInstance.then(instance => {
|
|
127
146
|
(element as any).setConnector((instance as any).connect);
|
|
128
147
|
});
|
package/types/config.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ConnectElementTagName } from "./shared.d";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
|
+
|
|
6
|
+
export const ConnectElementCustomMethodConfig = {
|
|
7
|
+
"account-onboarding": {
|
|
8
|
+
setFullTermsOfServiceUrl: (
|
|
9
|
+
termOfServiceUrl: string | undefined
|
|
10
|
+
): void => {},
|
|
11
|
+
setRecipientTermsOfServiceUrl: (
|
|
12
|
+
recipientTermsOfServiceUrl: string | undefined
|
|
13
|
+
): void => {},
|
|
14
|
+
setPrivacyPolicyUrl: (privacyPolicyUrl: string | undefined): void => {},
|
|
15
|
+
setSkipTermsOfServiceCollection: (
|
|
16
|
+
skipTermsOfServiceCollection: boolean | undefined
|
|
17
|
+
): void => {},
|
|
18
|
+
setOnExit: (listener: (() => void) | undefined): void => {}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// ensure that keys of ConnectElementCustomMethodConfig are from ConnectElementTagName
|
|
23
|
+
type HasType<T, Q extends T> = Q;
|
|
24
|
+
type CustomMethodConfigValidation = HasType<
|
|
25
|
+
ConnectElementTagName,
|
|
26
|
+
keyof typeof ConnectElementCustomMethodConfig
|
|
27
|
+
>;
|
package/types/shared.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ConnectElementCustomMethodConfig } from "./config";
|
|
2
|
+
|
|
1
3
|
export declare type LoadConnectAndInitialize = (
|
|
2
4
|
initParams: IStripeConnectInitParams
|
|
3
5
|
) => StripeConnectInstance;
|
|
@@ -354,28 +356,14 @@ export interface IStripeConnectInitParams {
|
|
|
354
356
|
locale?: string;
|
|
355
357
|
}
|
|
356
358
|
|
|
357
|
-
type
|
|
358
|
-
[key in string]: HTMLElement | null;
|
|
359
|
-
};
|
|
360
|
-
type ConnectHTMLElementRecordBase = {
|
|
361
|
-
[tagName in ConnectElementTagName]: HTMLElement;
|
|
362
|
-
};
|
|
359
|
+
type ConnectElementCustomMethods = typeof ConnectElementCustomMethodConfig;
|
|
363
360
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
recipientTermsOfServiceUrl: string | undefined
|
|
371
|
-
) => void;
|
|
372
|
-
setPrivacyPolicyUrl: (privacyPolicyUrl: string | undefined) => void;
|
|
373
|
-
setSkipTermsOfServiceCollection: (
|
|
374
|
-
skipTermsOfServiceCollection: boolean | undefined
|
|
375
|
-
) => void;
|
|
376
|
-
setOnExit: (listener: () => void) => void;
|
|
377
|
-
};
|
|
378
|
-
}
|
|
361
|
+
type ConnectHTMLElementRecord = {
|
|
362
|
+
[K in keyof ConnectElementCustomMethods]: HTMLElement &
|
|
363
|
+
ConnectElementCustomMethods[K];
|
|
364
|
+
} & {
|
|
365
|
+
[key: string]: HTMLElement;
|
|
366
|
+
};
|
|
379
367
|
|
|
380
368
|
export interface StripeConnectInstance {
|
|
381
369
|
/**
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|