@tap-payments/connect 0.0.3-test → 0.0.5-test
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/README.md +70 -59
- package/build/@types/index.d.ts +15 -14
- package/build/constants/index.d.ts +5 -1
- package/build/constants/index.js +5 -1
- package/build/features/Connect/Connect.d.ts +2 -2
- package/build/features/Connect/Connect.js +5 -5
- package/build/features/Connect/ConnectExpress.js +1 -1
- package/build/features/Connect/index.d.ts +3 -3
- package/build/features/Connect/index.js +2 -2
- package/build/index.d.ts +4 -4
- package/build/index.js +6 -6
- package/build/utils/config.d.ts +2 -5
- package/build/utils/config.js +28 -12
- package/build/utils/validation.js +26 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,13 +9,13 @@ This is a [React](https://reactjs.org/) module available through the
|
|
|
9
9
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
|
10
10
|
|
|
11
11
|
```console
|
|
12
|
-
npm install @tap-payments/connect
|
|
12
|
+
npm install @tap-payments/connect
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
---------------------------- OR -------------------------
|
|
16
16
|
|
|
17
17
|
```console
|
|
18
|
-
yarn add @tap-payments/connect
|
|
18
|
+
yarn add @tap-payments/connect
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Examples
|
|
@@ -25,66 +25,70 @@ yarn add @tap-payments/connect-auth
|
|
|
25
25
|
### ES6
|
|
26
26
|
|
|
27
27
|
```js
|
|
28
|
-
import {
|
|
28
|
+
import { TapConnect, Language } from '@tap-payments/connect'
|
|
29
29
|
|
|
30
30
|
// we have two ways to use the connect element
|
|
31
31
|
// 1- full flow
|
|
32
|
-
const
|
|
32
|
+
const ConnectExpressComponent = () => {
|
|
33
33
|
return (
|
|
34
|
-
<
|
|
34
|
+
<TapConnect
|
|
35
35
|
// required (the public key of the merchant account provided by Tap Payments)
|
|
36
|
-
publicKey={'
|
|
36
|
+
publicKey={'pk_test_XXXXXXXXXXXXXXXXXXXXXXX'}
|
|
37
37
|
// required (boolean to open/close the connect element)
|
|
38
38
|
open={true}
|
|
39
39
|
// required (the country ISO2 of the merchant)
|
|
40
40
|
country={'SA'}
|
|
41
41
|
// required (Language flag to control the language of the connect element and only we support [en,ar])
|
|
42
|
-
language={
|
|
43
|
-
// required (Decide the maturity of the
|
|
44
|
-
|
|
42
|
+
language={Language.EN}
|
|
43
|
+
// required (Decide the maturity of the TapConnect library)
|
|
44
|
+
mature={true}
|
|
45
45
|
// required (the domain of the merchant)
|
|
46
|
-
|
|
46
|
+
domain={'https://example.com'}
|
|
47
47
|
// required (the scope of the merchant)
|
|
48
48
|
scope={'merchant'}
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
// optional (
|
|
49
|
+
// optional (Lead Id can be passed in case of you already created a lead using our API )
|
|
50
|
+
lead={'led_xxxxxxxxxxxxxxxxxxxxxx'}
|
|
51
|
+
// optional (The POST Method URL used to push te data from our server to the merchant server)
|
|
52
|
+
postURL={'https://api.example.com/post'}
|
|
53
|
+
// optional (show/hide board screen after creating an account)
|
|
54
|
+
board={true}
|
|
55
|
+
// optional (Callback function to handle the error)
|
|
52
56
|
onError={(err) => console.log('onError', err)}
|
|
53
|
-
//optional (
|
|
57
|
+
//optional (Callback function to handle the ready state of the TapConnect )
|
|
54
58
|
onReady={() => console.log('onReady')}
|
|
59
|
+
// optional (Callback function runs when the user close TaConnect)
|
|
60
|
+
onClose={() => console.log('onClose')}
|
|
61
|
+
// optional (Callback function runs after creating an account)
|
|
62
|
+
onCreated={(data) => console.log('onCreated', data)}
|
|
55
63
|
/>
|
|
56
64
|
)
|
|
57
65
|
}
|
|
58
66
|
// 2- express flow
|
|
59
|
-
const
|
|
67
|
+
const ConnectFullComponent = () => {
|
|
60
68
|
return (
|
|
61
|
-
<
|
|
69
|
+
<TapConnect
|
|
62
70
|
// required (the public key of the merchant account provided by Tap Payments)
|
|
63
|
-
publicKey={'
|
|
71
|
+
publicKey={'pk_test_XXXXXXXXXXXXXXXXXXXXXXX'}
|
|
64
72
|
// required (boolean to open/close the connect element)
|
|
65
73
|
open={true}
|
|
66
74
|
// required (the country ISO2 of the merchant)
|
|
67
75
|
country={'SA'}
|
|
68
76
|
// required (Language flag to control the language of the connect element and only we support [en,ar])
|
|
69
|
-
language={
|
|
70
|
-
// required (Decide the maturity of the
|
|
71
|
-
|
|
77
|
+
language={Language.EN}
|
|
78
|
+
// required (Decide the maturity of the TapConnect library)
|
|
79
|
+
mature={false}
|
|
72
80
|
// required (the domain of the merchant)
|
|
73
|
-
|
|
81
|
+
domain={'https://example.com'}
|
|
74
82
|
// required (the scope of the merchant)
|
|
75
83
|
scope={'merchant'}
|
|
76
|
-
// optional (
|
|
77
|
-
leadId={'led_6KOZ10239353ps316c20712'}
|
|
78
|
-
// required (The POST Method URL used to push te data from our server to the merchant server)
|
|
79
|
-
postURL={'https://example.com'}
|
|
80
|
-
// optional (boolean to show/hide board screen after creating an account)
|
|
81
|
-
showBoard={true}
|
|
82
|
-
// required (callback function to handle the success response, it will run after the user finish the flow)
|
|
83
|
-
onSuccess={(data) => console.log('onSuccess', data)}
|
|
84
|
-
// optional (callback function to handle the error response, it will run if the user face any error)
|
|
84
|
+
// optional (Callback function to handle the error)
|
|
85
85
|
onError={(err) => console.log('onError', err)}
|
|
86
|
-
//optional (
|
|
86
|
+
//optional (Callback function to handle the ready state of the TapConnect )
|
|
87
87
|
onReady={() => console.log('onReady')}
|
|
88
|
+
// optional (Callback function runs when the user close TaConnect)
|
|
89
|
+
onClose={() => console.log('onClose')}
|
|
90
|
+
// optional (Callback function runs after finishing the flow)
|
|
91
|
+
onSuccess={(data) => console.log('onSuccess', data)}
|
|
88
92
|
/>
|
|
89
93
|
)
|
|
90
94
|
}
|
|
@@ -102,29 +106,32 @@ const ConnectExpressComponent = () => {
|
|
|
102
106
|
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no"
|
|
103
107
|
/>
|
|
104
108
|
<title>Auth-JsConnect</title>
|
|
105
|
-
<script src="https://connect-auth.b-cdn.net/build-0.0.
|
|
109
|
+
<script src="https://connect-auth.b-cdn.net/build-0.0.5-test/main.js"></script>
|
|
106
110
|
</head>
|
|
107
111
|
<body>
|
|
108
112
|
<div id="root"></div>
|
|
109
113
|
<script>
|
|
110
|
-
//
|
|
111
|
-
const {
|
|
114
|
+
// once our cdn script is loaded we can use the window.TapPayments object
|
|
115
|
+
const { renderTapConnect, Language } = window.TapPayments
|
|
112
116
|
let unmountConnect = null
|
|
113
117
|
const startConnectAuth = () => {
|
|
114
|
-
const { unmount } =
|
|
118
|
+
const { unmount } = renderTapConnect(
|
|
115
119
|
{
|
|
116
|
-
publicKey: '
|
|
120
|
+
publicKey: 'pk_test_xxxxxxxxxxxxxxxxxxxxxxxx',
|
|
117
121
|
open: true,
|
|
118
122
|
country: 'SA',
|
|
119
|
-
language:
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
language: Language.EN,
|
|
124
|
+
mature: true,
|
|
125
|
+
domain: 'https://example.com',
|
|
122
126
|
scope: 'merchant',
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
lead: 'led_xxxxxxxxxxxxxxxxxxxxxx',
|
|
128
|
+
postURL: 'https://api.example.com/post',
|
|
129
|
+
board: true,
|
|
125
130
|
onSuccess: (data) => console.log('onSuccess', data),
|
|
126
131
|
onError: (err) => console.log('onError', err),
|
|
127
|
-
onReady: () => console.log('onReady')
|
|
132
|
+
onReady: () => console.log('onReady'),
|
|
133
|
+
onClose: () => console.log('onClose'),
|
|
134
|
+
onCreated: (data) => console.log('onCreated', data)
|
|
128
135
|
},
|
|
129
136
|
'root'
|
|
130
137
|
)
|
|
@@ -133,7 +140,7 @@ const ConnectExpressComponent = () => {
|
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
const stopConnectAuth = () => {
|
|
136
|
-
unmountConnect
|
|
143
|
+
unmountConnect && unmountConnect()
|
|
137
144
|
}
|
|
138
145
|
</script>
|
|
139
146
|
<button onclick="startConnectAuth()">Start</button>
|
|
@@ -141,23 +148,27 @@ const ConnectExpressComponent = () => {
|
|
|
141
148
|
</body>
|
|
142
149
|
</html>
|
|
143
150
|
|
|
151
|
+
|
|
144
152
|
```
|
|
145
153
|
|
|
146
154
|
## Properties
|
|
147
155
|
|
|
148
|
-
| name
|
|
149
|
-
|
|
|
150
|
-
| publicKey `required`
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
|
|
|
158
|
-
|
|
|
159
|
-
|
|
|
160
|
-
|
|
|
161
|
-
|
|
|
162
|
-
|
|
|
163
|
-
|
|
|
156
|
+
| name | type | description |
|
|
157
|
+
| -------------------- | ----------- | -------------------------------------------------------------------------------------------- |
|
|
158
|
+
| publicKey `required` | `string` | Public key of the merchant account provided by Tap Payments |
|
|
159
|
+
| domain `required` | `string` | Domain of the merchant |
|
|
160
|
+
| language `required` | `Languages` | language flag to control the language of the connect element and only accept [ar,en] |
|
|
161
|
+
| country `required` | `string` | Country ISO2 of the merchant |
|
|
162
|
+
| scope `required` | `string` | the scope of the merchant |
|
|
163
|
+
| lead `optional` | `string` | Lead Id can be passed in case of you already created a lead using our API |
|
|
164
|
+
| mature `required` | `boolean` | Decide the mode of connect |
|
|
165
|
+
| board `optional` | `string` | Show/Hide board screens |
|
|
166
|
+
| open `required` | `boolean` | Open/Close the connect library |
|
|
167
|
+
| postURL `optional` | `string` | The POST Method URL used to push te data from our server to the merchant server and |
|
|
168
|
+
| | | it's required only if `mature` is `true` |
|
|
169
|
+
| onError `optional` | `function` | Callback function to handle the error response, it will run if the user face any error |
|
|
170
|
+
| onReady `optional` | `function` | Callback function to handle the ready state of the `TapConnect` |
|
|
171
|
+
| onClose `optional` | `function` | Callback function to called when `TapConnect` get close |
|
|
172
|
+
| onCreated `optional` | `function` | Callback function to called the the account created successfully |
|
|
173
|
+
| | | it calls only if `mature` is `true` |
|
|
174
|
+
| onSuccess `optional` | `function` | Callback function to handle the success response, it will run after the user finish the flow |
|
package/build/@types/index.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Language } from '../constants';
|
|
2
2
|
export interface ConnectProps {
|
|
3
3
|
publicKey: string;
|
|
4
|
-
|
|
4
|
+
domain: string;
|
|
5
|
+
language: typeof Language[keyof typeof Language];
|
|
5
6
|
country: string;
|
|
6
|
-
language: string;
|
|
7
|
-
maturity: typeof Maturity[keyof typeof Maturity];
|
|
8
7
|
scope: string;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
lead?: string;
|
|
9
|
+
mature: boolean;
|
|
10
|
+
board?: boolean;
|
|
11
|
+
open: boolean;
|
|
11
12
|
postURL?: string;
|
|
12
|
-
|
|
13
|
+
onError?: (err: Error) => void;
|
|
13
14
|
onReady?: () => void;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
onCreated?: (res: object) => void;
|
|
17
|
+
onSuccess?: (res: object) => void;
|
|
16
18
|
}
|
|
17
19
|
export interface OriginalConnectProps {
|
|
18
20
|
publicKey: string;
|
|
@@ -23,7 +25,7 @@ export interface OriginalConnectProps {
|
|
|
23
25
|
businessCountryCode: string;
|
|
24
26
|
scope: string;
|
|
25
27
|
leadId?: string;
|
|
26
|
-
postURL
|
|
28
|
+
postURL?: string;
|
|
27
29
|
showBoard?: boolean;
|
|
28
30
|
verifyToken?: string;
|
|
29
31
|
onFlowCompleted: (res: object, headers?: Record<string, string>) => void;
|
|
@@ -31,8 +33,7 @@ export interface OriginalConnectProps {
|
|
|
31
33
|
onStepCompleted?: (name: string, info: any) => void;
|
|
32
34
|
onReady?: () => void;
|
|
33
35
|
onStepStarted?: (name: string) => void;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}) => void;
|
|
36
|
+
onBoardButtonClick?: (data: Record<string, any>) => void;
|
|
37
|
+
onCreated?: (res: Record<string, any>) => void;
|
|
38
|
+
onClose?: () => void;
|
|
38
39
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.1.
|
|
1
|
+
export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.1.73-test";
|
|
2
2
|
export declare const Maturity: {
|
|
3
3
|
readonly FULL: "full";
|
|
4
4
|
readonly EXPRESS: "express";
|
|
5
5
|
};
|
|
6
|
+
export declare const Language: {
|
|
7
|
+
readonly EN: "en";
|
|
8
|
+
readonly AR: "ar";
|
|
9
|
+
};
|
package/build/constants/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.1.
|
|
1
|
+
export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.1.73-test';
|
|
2
2
|
export var Maturity = {
|
|
3
3
|
FULL: 'full',
|
|
4
4
|
EXPRESS: 'express'
|
|
5
5
|
};
|
|
6
|
+
export var Language = {
|
|
7
|
+
EN: 'en',
|
|
8
|
+
AR: 'ar'
|
|
9
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ConnectProps } from '../../@types';
|
|
3
3
|
export type { ConnectProps };
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
4
|
+
export declare const TapConnect: React.MemoExoticComponent<(props: ConnectProps) => JSX.Element>;
|
|
5
|
+
export declare const renderTapConnect: (props: ConnectProps, elementId: string) => {
|
|
6
6
|
unmount: () => void;
|
|
7
7
|
};
|
|
@@ -14,7 +14,7 @@ import * as React from 'react';
|
|
|
14
14
|
import { createRoot } from 'react-dom/client';
|
|
15
15
|
import { createElementAndInject, validateConnectProps } from '../../utils';
|
|
16
16
|
import { useScript, useStyle } from '../../hooks';
|
|
17
|
-
import {
|
|
17
|
+
import { CDN_LIBRARY_BASE_URL } from '../../constants';
|
|
18
18
|
import ConnectFull from './ConnectFull';
|
|
19
19
|
import ConnectExpress from './ConnectExpress';
|
|
20
20
|
var Connect = function (props) {
|
|
@@ -28,18 +28,18 @@ var Connect = function (props) {
|
|
|
28
28
|
}, [status]);
|
|
29
29
|
if (status !== 'ready')
|
|
30
30
|
return null;
|
|
31
|
-
if (props.
|
|
31
|
+
if (props.mature)
|
|
32
32
|
return _jsx(ConnectExpress, __assign({}, props));
|
|
33
33
|
return _jsx(ConnectFull, __assign({}, props));
|
|
34
34
|
};
|
|
35
|
-
export var
|
|
35
|
+
export var TapConnect = React.memo(function (props) {
|
|
36
36
|
validateConnectProps(props);
|
|
37
37
|
return _jsx(Connect, __assign({}, props));
|
|
38
38
|
});
|
|
39
|
-
export var
|
|
39
|
+
export var renderTapConnect = function (props, elementId) {
|
|
40
40
|
var el = createElementAndInject(elementId);
|
|
41
41
|
var root = createRoot(el);
|
|
42
|
-
root.render(_jsx(
|
|
42
|
+
root.render(_jsx(TapConnect, __assign({}, props)));
|
|
43
43
|
var unmount = function () { return root.unmount(); };
|
|
44
44
|
return { unmount: unmount };
|
|
45
45
|
};
|
|
@@ -23,7 +23,7 @@ var ConnectExpress = function (props) {
|
|
|
23
23
|
var elementId = 'tap-connect-sdk-lib';
|
|
24
24
|
React.useEffect(function () {
|
|
25
25
|
console.log('rendering: ', name);
|
|
26
|
-
var config = wrapLibConfig(__assign(__assign({}, props), { verifyToken: token,
|
|
26
|
+
var config = wrapLibConfig(__assign(__assign({}, props), { verifyToken: token, onBoardButtonClick: onButtonClick }));
|
|
27
27
|
switch (name) {
|
|
28
28
|
case 'brand':
|
|
29
29
|
renderBrandLib(config, elementId);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type {
|
|
3
|
-
export {
|
|
1
|
+
import { TapConnect, ConnectProps as TapConnectProps, renderTapConnect } from './Connect';
|
|
2
|
+
export type { TapConnectProps };
|
|
3
|
+
export { TapConnect, renderTapConnect };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { TapConnect, renderTapConnect } from './Connect';
|
|
2
|
+
export { TapConnect, renderTapConnect };
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export type {
|
|
4
|
-
export {
|
|
1
|
+
import { TapConnect, TapConnectProps, renderTapConnect } from './features/Connect';
|
|
2
|
+
import { Language } from './constants';
|
|
3
|
+
export type { TapConnectProps };
|
|
4
|
+
export { Language, TapConnect, renderTapConnect };
|
package/build/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
window['
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { TapConnect, renderTapConnect } from './features/Connect';
|
|
2
|
+
import { Language } from './constants';
|
|
3
|
+
export { Language, TapConnect, renderTapConnect };
|
|
4
|
+
window['TapPayments'] = {
|
|
5
|
+
renderTapConnect: renderTapConnect,
|
|
6
|
+
Language: Language
|
|
7
7
|
};
|
package/build/utils/config.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { ConnectProps, OriginalConnectProps } from '../@types';
|
|
2
2
|
type ExtraProps = {
|
|
3
3
|
verifyToken?: string;
|
|
4
|
-
|
|
5
|
-
name: string;
|
|
6
|
-
token: string;
|
|
7
|
-
}) => void;
|
|
4
|
+
onBoardButtonClick?: (data: Record<string, string>) => void;
|
|
8
5
|
};
|
|
9
|
-
export declare const wrapLibConfig: ({
|
|
6
|
+
export declare const wrapLibConfig: ({ publicKey, open, language, country, scope, lead, postURL, onError, onReady, onSuccess, board, verifyToken, domain, onBoardButtonClick, onClose, onCreated }: ConnectProps & ExtraProps) => OriginalConnectProps;
|
|
10
7
|
export {};
|
package/build/utils/config.js
CHANGED
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
export var wrapLibConfig = function (_a) {
|
|
2
|
-
var
|
|
2
|
+
var publicKey = _a.publicKey, open = _a.open, language = _a.language, country = _a.country, scope = _a.scope, lead = _a.lead, postURL = _a.postURL, onError = _a.onError, onReady = _a.onReady, onSuccess = _a.onSuccess, board = _a.board, verifyToken = _a.verifyToken, domain = _a.domain, onBoardButtonClick = _a.onBoardButtonClick, onClose = _a.onClose, onCreated = _a.onCreated;
|
|
3
3
|
return {
|
|
4
|
-
publicKey: publicKey,
|
|
5
|
-
open: open,
|
|
6
|
-
language: language,
|
|
7
|
-
merchantDomain: merchantDomain,
|
|
8
4
|
appInfo: {
|
|
9
5
|
name: window.location.hostname
|
|
10
6
|
},
|
|
11
7
|
businessCountryCode: country,
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
language: language,
|
|
9
|
+
merchantDomain: domain,
|
|
10
|
+
open: open,
|
|
14
11
|
postURL: postURL,
|
|
15
|
-
|
|
12
|
+
publicKey: publicKey,
|
|
13
|
+
scope: scope,
|
|
14
|
+
leadId: lead,
|
|
15
|
+
showBoard: board,
|
|
16
16
|
verifyToken: verifyToken,
|
|
17
|
-
onFlowCompleted: function (res) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
onFlowCompleted: function (res) {
|
|
18
|
+
onSuccess && onSuccess(res);
|
|
19
|
+
},
|
|
20
|
+
onError: function (err) {
|
|
21
|
+
onError && onError(err);
|
|
22
|
+
},
|
|
23
|
+
onReady: function () {
|
|
24
|
+
onReady && onReady();
|
|
25
|
+
},
|
|
26
|
+
onBoardButtonClick: function (data) {
|
|
27
|
+
onBoardButtonClick && onBoardButtonClick(data);
|
|
28
|
+
},
|
|
29
|
+
onCreated: function (res) {
|
|
30
|
+
onCreated && onCreated(res);
|
|
31
|
+
},
|
|
32
|
+
onClose: function () {
|
|
33
|
+
onClose && onClose();
|
|
34
|
+
},
|
|
35
|
+
onStepCompleted: function (name, info) { },
|
|
36
|
+
onStepStarted: function (name) { }
|
|
21
37
|
};
|
|
22
38
|
};
|
|
@@ -1,43 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Language } from '../constants';
|
|
2
2
|
export var validateConnectProps = function (props) {
|
|
3
|
-
var publicKey = props.publicKey,
|
|
3
|
+
var publicKey = props.publicKey, mature = props.mature, country = props.country, language = props.language, scope = props.scope, open = props.open, domain = props.domain, board = props.board, lead = props.lead, onClose = props.onClose, onCreated = props.onCreated, onError = props.onError, onReady = props.onReady, onSuccess = props.onSuccess, postURL = props.postURL;
|
|
4
4
|
if (!publicKey) {
|
|
5
5
|
throw new Error('publicKey is required');
|
|
6
6
|
}
|
|
7
|
-
if (!maturity) {
|
|
8
|
-
throw new Error('maturity is required');
|
|
9
|
-
}
|
|
10
|
-
if (![Maturity.EXPRESS, Maturity.FULL].includes(maturity)) {
|
|
11
|
-
throw new Error('maturity is invalid');
|
|
12
|
-
}
|
|
13
7
|
if (!country) {
|
|
14
8
|
throw new Error('country is required');
|
|
15
9
|
}
|
|
16
10
|
if (!language) {
|
|
17
11
|
throw new Error('language is required');
|
|
18
12
|
}
|
|
13
|
+
if (![Language.AR, Language.EN].includes(language)) {
|
|
14
|
+
throw new Error('You can only use AR or EN for language');
|
|
15
|
+
}
|
|
19
16
|
if (!scope) {
|
|
20
17
|
throw new Error('scope is required');
|
|
21
18
|
}
|
|
22
|
-
if (!
|
|
23
|
-
throw new Error('
|
|
19
|
+
if (!domain) {
|
|
20
|
+
throw new Error('domain is required');
|
|
24
21
|
}
|
|
25
22
|
if (typeof open !== 'boolean') {
|
|
26
23
|
throw new Error('open is required, and must be a boolean');
|
|
27
24
|
}
|
|
28
|
-
if (typeof
|
|
29
|
-
throw new Error('
|
|
25
|
+
if (typeof mature !== 'boolean') {
|
|
26
|
+
throw new Error('mature is required, and must be a boolean');
|
|
27
|
+
}
|
|
28
|
+
if (typeof board !== 'undefined' && typeof board !== 'boolean') {
|
|
29
|
+
throw new Error('board is required, and must be a boolean');
|
|
30
30
|
}
|
|
31
|
-
if (
|
|
32
|
-
throw new Error('
|
|
31
|
+
if (typeof lead !== 'undefined' && typeof lead !== 'string') {
|
|
32
|
+
throw new Error('lead must be a string');
|
|
33
33
|
}
|
|
34
|
-
if (postURL && typeof postURL !== 'string') {
|
|
34
|
+
if (typeof postURL !== 'undefined' && typeof postURL !== 'string') {
|
|
35
35
|
throw new Error('postURL must be a string');
|
|
36
36
|
}
|
|
37
|
-
if (
|
|
37
|
+
if (typeof onClose !== 'undefined' && typeof onClose !== 'function') {
|
|
38
|
+
throw new Error('onClose must be a function');
|
|
39
|
+
}
|
|
40
|
+
if (typeof onCreated !== 'undefined' && typeof onCreated !== 'function') {
|
|
41
|
+
throw new Error('onCreated must be a function');
|
|
42
|
+
}
|
|
43
|
+
if (typeof onError !== 'undefined' && typeof onError !== 'function') {
|
|
38
44
|
throw new Error('onError must be a function');
|
|
39
45
|
}
|
|
40
|
-
if (onReady && typeof onReady !== 'function') {
|
|
46
|
+
if (typeof onReady !== 'undefined' && typeof onReady !== 'function') {
|
|
41
47
|
throw new Error('onReady must be a function');
|
|
42
48
|
}
|
|
49
|
+
if (typeof onSuccess !== 'undefined' && typeof onSuccess !== 'function') {
|
|
50
|
+
throw new Error('onSuccess must be a function');
|
|
51
|
+
}
|
|
43
52
|
};
|