@tap-payments/connect 2.5.2-test → 2.5.2
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 +44 -56
- package/build/@types/config.d.ts +54 -0
- package/build/@types/config.js +1 -0
- package/build/@types/index.d.ts +16 -19
- package/build/api/index.d.ts +11 -1
- package/build/api/index.js +46 -12
- package/build/constants/index.d.ts +9 -3
- package/build/constants/index.js +9 -3
- package/build/features/Connect/Connect.js +29 -18
- package/build/features/Connect/ConnectAuth.d.ts +7 -0
- package/build/features/Connect/ConnectAuth.js +117 -0
- package/build/features/Connect/ConnectBank.d.ts +12 -0
- package/build/features/Connect/ConnectBank.js +118 -0
- package/build/features/Connect/ConnectBoard.d.ts +10 -0
- package/build/features/Connect/ConnectBoard.js +117 -0
- package/build/features/Connect/ConnectBrand.d.ts +12 -0
- package/build/features/Connect/ConnectBrand.js +118 -0
- package/build/features/Connect/ConnectEntity.d.ts +12 -0
- package/build/features/Connect/ConnectEntity.js +118 -0
- package/build/features/Connect/ConnectExpress.js +1 -13
- package/build/features/Connect/ConnectIndividual.d.ts +12 -0
- package/build/features/Connect/ConnectIndividual.js +118 -0
- package/build/features/Connect/ConnectPassword.d.ts +12 -0
- package/build/features/Connect/ConnectPassword.js +118 -0
- package/build/features/Connect/ConnectTax.d.ts +12 -0
- package/build/features/Connect/ConnectTax.js +118 -0
- package/build/features/Connect/index.d.ts +10 -2
- package/build/features/Connect/index.js +9 -1
- package/build/index.d.ts +3 -3
- package/build/index.js +10 -3
- package/build/utils/common.d.ts +2 -0
- package/build/utils/common.js +16 -0
- package/build/utils/config.d.ts +1 -1
- package/build/utils/config.js +5 -1
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/build/utils/validation.d.ts +6 -0
- package/build/utils/validation.js +143 -5
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -27,9 +27,7 @@ yarn add @tap-payments/connect
|
|
|
27
27
|
```js
|
|
28
28
|
import { TapConnect, Language } from '@tap-payments/connect'
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
// 1- express flow
|
|
32
|
-
const ConnectExpressComponent = () => {
|
|
30
|
+
const ConnectComponent = () => {
|
|
33
31
|
return (
|
|
34
32
|
<TapConnect
|
|
35
33
|
// required (the public key of the merchant account provided by Tap Payments)
|
|
@@ -42,17 +40,24 @@ const ConnectExpressComponent = () => {
|
|
|
42
40
|
country={'SA'}
|
|
43
41
|
// required (the scope of the merchant)
|
|
44
42
|
scope={'merchant'}
|
|
43
|
+
// merchant data array `ex: [operator]`
|
|
44
|
+
data={[]}
|
|
45
45
|
// optional (Lead Id can be passed in case of you already created a lead using our API )
|
|
46
46
|
lead={'led_xxxxxxxxxxxxxxxxxxxxxx'}
|
|
47
|
-
// required (Decide the
|
|
47
|
+
// required (Decide the mode of connect `normal` or `express`)
|
|
48
48
|
mature={false}
|
|
49
49
|
// optional (show/hide board screen after creating an account)
|
|
50
50
|
board={true}
|
|
51
|
+
// optional ( Decide the board maturity )
|
|
51
52
|
boardMaturity={false}
|
|
53
|
+
// optional ( Decide to show connect as a `popup` or `page` to our connect domain. Default value is `popup` )
|
|
54
|
+
mode={'popup'}
|
|
52
55
|
// required (boolean to open/close the connect element)
|
|
53
56
|
open={true}
|
|
54
57
|
// optional (The POST Method URL used to push te data from our server to the merchant server)
|
|
55
58
|
postURL={'https://api.example.com/post'}
|
|
59
|
+
// This redirect url after verify authentication go to merchant website
|
|
60
|
+
redirectUrl={''}
|
|
56
61
|
//optional (Callback function to handle the ready state of the TapConnect )
|
|
57
62
|
onReady={() => console.log('onReady')}
|
|
58
63
|
// optional (Callback function runs after creating an account)
|
|
@@ -66,35 +71,6 @@ const ConnectExpressComponent = () => {
|
|
|
66
71
|
/>
|
|
67
72
|
)
|
|
68
73
|
}
|
|
69
|
-
// 2- full flow
|
|
70
|
-
const ConnectFullComponent = () => {
|
|
71
|
-
return (
|
|
72
|
-
<TapConnect
|
|
73
|
-
// required (the public key of the merchant account provided by Tap Payments)
|
|
74
|
-
publicKey={'pk_test_XXXXXXXXXXXXXXXXXXXXXXX'}
|
|
75
|
-
// required (the domain of the merchant)
|
|
76
|
-
domain={'https://example.com'}
|
|
77
|
-
// required (Language flag to control the language of the connect element and only we support [en,ar])
|
|
78
|
-
language={Language.EN}
|
|
79
|
-
// required (the country ISO2 of the merchant)
|
|
80
|
-
country={'SA'}
|
|
81
|
-
// required (the scope of the merchant)
|
|
82
|
-
scope={'merchant'}
|
|
83
|
-
// required (Decide the maturity of the TapConnect library)
|
|
84
|
-
mature={true}
|
|
85
|
-
// required (boolean to open/close the connect element)
|
|
86
|
-
open={true}
|
|
87
|
-
//optional (Callback function to handle the ready state of the TapConnect )
|
|
88
|
-
onReady={() => console.log('onReady')}
|
|
89
|
-
// optional (Callback function runs after finishing the flow)
|
|
90
|
-
onSuccess={(data) => console.log('onSuccess', data)}
|
|
91
|
-
// optional (Callback function runs when the user close TaConnect)
|
|
92
|
-
onClose={() => console.log('onClose')}
|
|
93
|
-
// optional (Callback function to handle the error)
|
|
94
|
-
onError={(err) => console.log('onError', err)}
|
|
95
|
-
/>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
74
|
```
|
|
99
75
|
|
|
100
76
|
### Vanilla JS
|
|
@@ -109,7 +85,7 @@ const ConnectFullComponent = () => {
|
|
|
109
85
|
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no"
|
|
110
86
|
/>
|
|
111
87
|
<title>Auth-JsConnect</title>
|
|
112
|
-
<script src="https://
|
|
88
|
+
<script src="https://tap-sdks.b-cdn.net/connect/build-2.5.2/main.js"></script>
|
|
113
89
|
</head>
|
|
114
90
|
<body>
|
|
115
91
|
<div id="root"></div>
|
|
@@ -125,12 +101,15 @@ const ConnectFullComponent = () => {
|
|
|
125
101
|
domain: 'https://example.com',
|
|
126
102
|
country: 'SA',
|
|
127
103
|
scope: 'merchant',
|
|
104
|
+
data: [],
|
|
128
105
|
lead: 'led_xxxxxxxxxxxxxxxxxxxxxx',
|
|
129
106
|
mature: false,
|
|
130
107
|
board: true,
|
|
131
108
|
boardMaturity: false,
|
|
109
|
+
mode: "popup",
|
|
132
110
|
open: true,
|
|
133
111
|
postURL: 'https://api.example.com/post',
|
|
112
|
+
redirectUrl: '',
|
|
134
113
|
onReady: () => console.log('onReady'),
|
|
135
114
|
onCreated: (data) => console.log('onCreated', data),
|
|
136
115
|
onError: (err) => console.log('onError', err),
|
|
@@ -158,25 +137,34 @@ const ConnectFullComponent = () => {
|
|
|
158
137
|
|
|
159
138
|
## Properties
|
|
160
139
|
|
|
161
|
-
| name
|
|
162
|
-
|
|
|
163
|
-
| publicKey `required`
|
|
164
|
-
| domain `required`
|
|
165
|
-
| language `required`
|
|
166
|
-
| country `required`
|
|
167
|
-
| scope `required`
|
|
168
|
-
|
|
|
169
|
-
|
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
175
|
-
|
|
|
176
|
-
|
|
|
177
|
-
|
|
|
178
|
-
|
|
|
179
|
-
|
|
|
180
|
-
|
|
|
181
|
-
|
|
|
182
|
-
|
|
|
140
|
+
| name | type | description |
|
|
141
|
+
| ---------------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
142
|
+
| publicKey `required` | `string` | Public key of the merchant account provided by Tap Payments |
|
|
143
|
+
| domain `required` | `string` | Domain of the merchant |
|
|
144
|
+
| language `required` | `Languages` | language flag to control the language of the connect element and only accept [ar,en] |
|
|
145
|
+
| country `required` | `string` | Country ISO2 of the merchant |
|
|
146
|
+
| scope `required` | `string` | the scope of the merchant available values [merchant, auth] |
|
|
147
|
+
| data `optional` | `Array<string>` | Merchant data array `ex: [operator]` |
|
|
148
|
+
| lead `optional` | `string` | Lead Id can be passed in case of you already created a lead using our API |
|
|
149
|
+
| mode `required` | `string` | Decide to show connect as a `popup` or `page` or `content` to our connect domain. Default value is `popup`. `content` mode only used for board kit |
|
|
150
|
+
| mature `required` | `boolean` | Decide the mode of connect `normal` or `express` |
|
|
151
|
+
| board `optional` | `string` | Show/Hide board screens |
|
|
152
|
+
| open `required` | `boolean` | Open/Close the connect library |
|
|
153
|
+
| openAnimationDirection `optional` | `left or right or up or down` | Used to handle **auth** slide animation direction when open popup for auth kit |
|
|
154
|
+
| closeAnimationDirection `optional` | `left or right or up or down` | Used to handle **auth** slide animation direction when close popup for auth kit |
|
|
155
|
+
| features `object` | `all values true` | Used to show or hide some fields (poweredBy, merchantLogo - Used to hide the merchant logo and it can be used only for auth kit, switchLanguage, overlay - Used to disable the background color and it can be used only for auth kit, loaderOverlay - Used to disable the loader background color and it can be used only for auth kit, tapTextLogo, closeButton - Used enable to close dialog) |
|
|
156
|
+
| loaderColor `optional` | `string` | Used to change loader color and it can be used only for board kit |
|
|
157
|
+
| boardMaturity `optional` | `boolean` | Decide the board maturity |
|
|
158
|
+
| settingData `optional` | `boolean` | This is to get settings information. It is used board kit and other kits open from board |
|
|
159
|
+
| postURL `optional` | `string` | The POST Method URL used to push te data from our server to the merchant server and |
|
|
160
|
+
| | | it's required only if `mature` is `false` |
|
|
161
|
+
| redirectUrl `optional` | `string` | This redirect url after verify authentication go to merchant website |
|
|
162
|
+
| | | It is `required` if scope is `auth` and mode is `page` |
|
|
163
|
+
| onReady `optional` | `function` | Callback function to handle the ready state of the `TapConnect` |
|
|
164
|
+
| onCreated `optional` | `function` | Callback function to called the the account created successfully |
|
|
165
|
+
| | | it calls only if `mature` is `false` |
|
|
166
|
+
| onSuccess `optional` | `function` | Callback function to handle the success response, it will run after the user finish the flow |
|
|
167
|
+
| onError `optional` | `function` | Callback function to handle the error response, it will run if the user face any error |
|
|
168
|
+
| onClose `optional` | `function` | Callback function to called when `TapConnect` get close |
|
|
169
|
+
| onBoardCompleted `optional` | `function` | Callback function to called when you complete all flows |
|
|
170
|
+
| onSettingFetched `optional` | `function` | Callback function to called after fetch settings information. It is used board kit and other kits open from board |
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface ConfigInfo {
|
|
2
|
+
operator: Operator;
|
|
3
|
+
scope: string;
|
|
4
|
+
data?: string[];
|
|
5
|
+
lead?: Lead;
|
|
6
|
+
board?: Board;
|
|
7
|
+
interface?: Interface;
|
|
8
|
+
redirect?: Redirect;
|
|
9
|
+
post?: Redirect;
|
|
10
|
+
connect?: Redirect;
|
|
11
|
+
platforms?: string[];
|
|
12
|
+
payment_provider?: PaymentProvider;
|
|
13
|
+
}
|
|
14
|
+
export interface ConnectFeatures {
|
|
15
|
+
poweredBy?: boolean;
|
|
16
|
+
merchantLogo?: boolean;
|
|
17
|
+
switchLanguage?: boolean;
|
|
18
|
+
overlay?: boolean;
|
|
19
|
+
loaderOverlay?: boolean;
|
|
20
|
+
tapTextLogo?: boolean;
|
|
21
|
+
closeButton?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface PaymentProvider {
|
|
24
|
+
technology_id: string;
|
|
25
|
+
settlement_by: string;
|
|
26
|
+
}
|
|
27
|
+
interface Redirect {
|
|
28
|
+
url: string;
|
|
29
|
+
}
|
|
30
|
+
interface Interface {
|
|
31
|
+
locale?: 'dynamic' | 'ar' | 'en';
|
|
32
|
+
edges?: 'straight' | 'curved';
|
|
33
|
+
}
|
|
34
|
+
interface Board {
|
|
35
|
+
display?: boolean;
|
|
36
|
+
editable?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface Lead {
|
|
39
|
+
id: string;
|
|
40
|
+
}
|
|
41
|
+
interface Operator {
|
|
42
|
+
public_key: string;
|
|
43
|
+
}
|
|
44
|
+
type RecordType = Record<string, any>;
|
|
45
|
+
export interface SettingAsyncData {
|
|
46
|
+
fingerPrint: RecordType;
|
|
47
|
+
locale: RecordType;
|
|
48
|
+
country_list: RecordType;
|
|
49
|
+
ip_info: RecordType;
|
|
50
|
+
merchant: RecordType;
|
|
51
|
+
operator: RecordType;
|
|
52
|
+
config: RecordType;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/@types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Language } from '../constants';
|
|
2
|
+
import { ConfigInfo, ConnectFeatures, SettingAsyncData } from './config';
|
|
2
3
|
export interface ConnectProps {
|
|
3
4
|
elementId: string;
|
|
4
5
|
publicKey: string;
|
|
@@ -8,20 +9,30 @@ export interface ConnectProps {
|
|
|
8
9
|
scope: string;
|
|
9
10
|
lead?: string;
|
|
10
11
|
mature: boolean;
|
|
11
|
-
mode
|
|
12
|
+
mode?: 'popup' | 'page' | 'content';
|
|
12
13
|
board?: boolean;
|
|
13
14
|
boardMaturity?: boolean;
|
|
15
|
+
openAnimationDirection?: 'left' | 'right' | 'up' | 'down';
|
|
16
|
+
closeAnimationDirection?: 'left' | 'right' | 'up' | 'down';
|
|
17
|
+
loaderColor?: string;
|
|
18
|
+
boardId?: string;
|
|
14
19
|
open: boolean;
|
|
15
20
|
postURL?: string;
|
|
21
|
+
redirectUrl?: string;
|
|
22
|
+
data?: Array<string>;
|
|
23
|
+
settingData?: SettingAsyncData;
|
|
24
|
+
features?: ConnectFeatures;
|
|
16
25
|
onError?: (err: Error) => void;
|
|
17
26
|
onReady?: () => void;
|
|
18
27
|
onClose?: () => void;
|
|
19
28
|
onCreated?: (res: object) => void;
|
|
20
29
|
onSuccess?: (res: object) => void;
|
|
21
30
|
onBoardCompleted?: () => void;
|
|
31
|
+
onSettingFetched?: (data: SettingAsyncData) => void;
|
|
22
32
|
}
|
|
23
33
|
export interface OriginalConnectProps {
|
|
24
34
|
publicKey: string;
|
|
35
|
+
mode?: 'popup' | 'page' | 'content';
|
|
25
36
|
open: boolean;
|
|
26
37
|
merchantDomain: string;
|
|
27
38
|
language: string;
|
|
@@ -30,8 +41,11 @@ export interface OriginalConnectProps {
|
|
|
30
41
|
scope: string;
|
|
31
42
|
leadId?: string;
|
|
32
43
|
postURL?: string;
|
|
44
|
+
redirectUrl?: string;
|
|
45
|
+
data?: Array<string>;
|
|
33
46
|
showBoard?: boolean;
|
|
34
47
|
boardMaturity?: boolean;
|
|
48
|
+
features?: ConnectFeatures;
|
|
35
49
|
verifyToken?: string;
|
|
36
50
|
onFlowCompleted: (res: object, headers?: Record<string, string>) => void;
|
|
37
51
|
onError: (err: any) => void;
|
|
@@ -43,24 +57,7 @@ export interface OriginalConnectProps {
|
|
|
43
57
|
onClose?: () => void;
|
|
44
58
|
onBoardCompleted?: () => void;
|
|
45
59
|
}
|
|
46
|
-
export type TokenParams =
|
|
47
|
-
board?: boolean;
|
|
48
|
-
public_key: string;
|
|
49
|
-
board_maturity?: boolean;
|
|
50
|
-
domain: string;
|
|
51
|
-
language: string;
|
|
52
|
-
country: string;
|
|
53
|
-
scope: string;
|
|
54
|
-
lead_id?: string;
|
|
55
|
-
maturity: boolean;
|
|
56
|
-
notification: {
|
|
57
|
-
email: boolean;
|
|
58
|
-
sms: boolean;
|
|
59
|
-
};
|
|
60
|
-
post?: {
|
|
61
|
-
url: string;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
60
|
+
export type TokenParams = ConfigInfo;
|
|
64
61
|
export interface TokenResponseParams extends TokenParams {
|
|
65
62
|
id: string;
|
|
66
63
|
contact: {
|
package/build/api/index.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
import { GetResult } from '@fingerprintjs/fingerprintjs';
|
|
1
2
|
import { TokenParams } from '../@types';
|
|
2
|
-
export declare const
|
|
3
|
+
export declare const getFingerPrint: () => Promise<GetResult>;
|
|
4
|
+
export declare const generateConfigToken: (data: TokenParams) => Promise<{
|
|
5
|
+
data: any;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
error?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
error: unknown;
|
|
10
|
+
data?: undefined;
|
|
11
|
+
publicKey?: undefined;
|
|
12
|
+
}>;
|
package/build/api/index.js
CHANGED
|
@@ -35,27 +35,61 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import axios from 'axios';
|
|
38
|
-
import
|
|
38
|
+
import FingerprintJS from '@fingerprintjs/fingerprintjs';
|
|
39
|
+
import { getBaseUrl } from '../utils';
|
|
40
|
+
export var getFingerPrint = function () {
|
|
41
|
+
return FingerprintJS.load().then(function (fp) {
|
|
42
|
+
return fp.get().then(function (result) {
|
|
43
|
+
return result;
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
};
|
|
39
47
|
export var generateConfigToken = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
40
|
-
var response, error_1;
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
var visitorId, publicKey, baseUrl, res, public_key, response, error_1;
|
|
49
|
+
var _a;
|
|
50
|
+
return __generator(this, function (_b) {
|
|
51
|
+
switch (_b.label) {
|
|
43
52
|
case 0:
|
|
44
|
-
|
|
45
|
-
return [4,
|
|
53
|
+
_b.trys.push([0, 4, , 5]);
|
|
54
|
+
return [4, getFingerPrint()];
|
|
55
|
+
case 1:
|
|
56
|
+
visitorId = (_b.sent()).visitorId;
|
|
57
|
+
publicKey = data.operator.public_key;
|
|
58
|
+
baseUrl = getBaseUrl(publicKey);
|
|
59
|
+
return [4, axios.post("".concat(baseUrl, "init"), {}, {
|
|
46
60
|
headers: {
|
|
47
61
|
'Content-Type': 'application/json',
|
|
48
62
|
'Access-Control-Allow-Headers': true,
|
|
49
|
-
authorization:
|
|
63
|
+
authorization: publicKey,
|
|
64
|
+
bi: visitorId || '',
|
|
65
|
+
cu: window.location.href,
|
|
66
|
+
mdn: window.location.origin
|
|
50
67
|
}
|
|
51
68
|
})];
|
|
52
|
-
case 1:
|
|
53
|
-
response = _a.sent();
|
|
54
|
-
return [2, response.data];
|
|
55
69
|
case 2:
|
|
56
|
-
|
|
70
|
+
res = _b.sent();
|
|
71
|
+
public_key = (((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.config) || {}).public_key;
|
|
72
|
+
if (public_key) {
|
|
73
|
+
publicKey = public_key;
|
|
74
|
+
baseUrl = getBaseUrl(public_key);
|
|
75
|
+
}
|
|
76
|
+
return [4, axios.post("".concat(baseUrl, "v3/connect"), data, {
|
|
77
|
+
headers: {
|
|
78
|
+
'Content-Type': 'application/json',
|
|
79
|
+
'Access-Control-Allow-Headers': true,
|
|
80
|
+
authorization: publicKey,
|
|
81
|
+
bi: visitorId || '',
|
|
82
|
+
cu: window.location.href,
|
|
83
|
+
mdn: window.location.origin
|
|
84
|
+
}
|
|
85
|
+
})];
|
|
86
|
+
case 3:
|
|
87
|
+
response = _b.sent();
|
|
88
|
+
return [2, { data: response.data, publicKey: publicKey }];
|
|
89
|
+
case 4:
|
|
90
|
+
error_1 = _b.sent();
|
|
57
91
|
return [2, { error: error_1 }];
|
|
58
|
-
case
|
|
92
|
+
case 5: return [2];
|
|
59
93
|
}
|
|
60
94
|
});
|
|
61
95
|
}); };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.5.2
|
|
1
|
+
export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.5.2";
|
|
2
2
|
export declare const Maturity: {
|
|
3
3
|
readonly FULL: "full";
|
|
4
4
|
readonly EXPRESS: "express";
|
|
@@ -7,5 +7,11 @@ export declare const Language: {
|
|
|
7
7
|
readonly EN: "en";
|
|
8
8
|
readonly AR: "ar";
|
|
9
9
|
};
|
|
10
|
-
export declare const CONNECT_URL = "https://connect.
|
|
11
|
-
export declare const
|
|
10
|
+
export declare const CONNECT_URL = "https://connect.tap.company/";
|
|
11
|
+
export declare const CONNECT_BETA_URL = "https://connect.beta.tap.company/";
|
|
12
|
+
export declare const CONNECT_SANDBOX_URL = "https://connect.sandbox.tap.company/";
|
|
13
|
+
export declare const CONNECT_DEV_URL = "https://connect.dev.tap.company/";
|
|
14
|
+
export declare const CONNECT_MW_URL = "https://connect-mw.tap.company/middleware/";
|
|
15
|
+
export declare const CONNECT_MW_BETA_URL = "https://connect-mw.beta.tap.company/middleware/";
|
|
16
|
+
export declare const CONNECT_SANDBOX_MW_URL = "https://connect-mw.sandbox.tap.company/middleware/";
|
|
17
|
+
export declare const CONNECT_DEV_MW_URL = "https://connect-mw.dev.tap.company/middleware/";
|
package/build/constants/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.5.2
|
|
1
|
+
export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.5.2';
|
|
2
2
|
export var Maturity = {
|
|
3
3
|
FULL: 'full',
|
|
4
4
|
EXPRESS: 'express'
|
|
@@ -7,5 +7,11 @@ export var Language = {
|
|
|
7
7
|
EN: 'en',
|
|
8
8
|
AR: 'ar'
|
|
9
9
|
};
|
|
10
|
-
export var CONNECT_URL = 'https://connect.
|
|
11
|
-
export var
|
|
10
|
+
export var CONNECT_URL = 'https://connect.tap.company/';
|
|
11
|
+
export var CONNECT_BETA_URL = 'https://connect.beta.tap.company/';
|
|
12
|
+
export var CONNECT_SANDBOX_URL = 'https://connect.sandbox.tap.company/';
|
|
13
|
+
export var CONNECT_DEV_URL = 'https://connect.dev.tap.company/';
|
|
14
|
+
export var CONNECT_MW_URL = 'https://connect-mw.tap.company/middleware/';
|
|
15
|
+
export var CONNECT_MW_BETA_URL = 'https://connect-mw.beta.tap.company/middleware/';
|
|
16
|
+
export var CONNECT_SANDBOX_MW_URL = 'https://connect-mw.sandbox.tap.company/middleware/';
|
|
17
|
+
export var CONNECT_DEV_MW_URL = 'https://connect-mw.dev.tap.company/middleware/';
|
|
@@ -59,9 +59,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
59
59
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
60
60
|
import * as React from 'react';
|
|
61
61
|
import { createRoot } from 'react-dom/client';
|
|
62
|
-
import { findOrCreateElementAndInject, validateConnectProps } from '../../utils';
|
|
62
|
+
import { findOrCreateElementAndInject, getRedirectBaseUrl, validateConnectProps } from '../../utils';
|
|
63
63
|
import { useScript, useStyle } from '../../hooks';
|
|
64
|
-
import { CDN_LIBRARY_BASE_URL
|
|
64
|
+
import { CDN_LIBRARY_BASE_URL } from '../../constants';
|
|
65
65
|
import { generateConfigToken } from '../../api';
|
|
66
66
|
import ConnectFull from './ConnectFull';
|
|
67
67
|
import ConnectExpress from './ConnectExpress';
|
|
@@ -87,38 +87,49 @@ export var TapConnect = React.memo(function (props) {
|
|
|
87
87
|
});
|
|
88
88
|
var tapConnectInstance = null;
|
|
89
89
|
export var renderTapConnect = function (props, elementId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
-
var mode, board, publicKey, boardMaturity,
|
|
91
|
-
return __generator(this, function (
|
|
92
|
-
switch (
|
|
90
|
+
var mode, board, publicKey, boardMaturity, language, country, scope, lead, postURL, mature, onError, redirectUrl, AuthData, payload, _a, data, publicKeyValue, _b, token, connect, baseUrl, url_1, countryCode, url, el, root, unmount;
|
|
91
|
+
return __generator(this, function (_c) {
|
|
92
|
+
switch (_c.label) {
|
|
93
93
|
case 0:
|
|
94
|
-
|
|
94
|
+
props.mode = props.mode || 'popup';
|
|
95
|
+
mode = props.mode, board = props.board, publicKey = props.publicKey, boardMaturity = props.boardMaturity, language = props.language, country = props.country, scope = props.scope, lead = props.lead, postURL = props.postURL, mature = props.mature, onError = props.onError, redirectUrl = props.redirectUrl, AuthData = props.data;
|
|
95
96
|
if (!(mode === 'page')) return [3, 2];
|
|
96
|
-
payload = __assign({
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
payload = __assign(__assign(__assign(__assign({ operator: {
|
|
98
|
+
public_key: publicKey
|
|
99
|
+
}, scope: scope }, (AuthData && {
|
|
100
|
+
data: AuthData
|
|
101
|
+
})), { lead: {
|
|
102
|
+
id: lead || ''
|
|
103
|
+
}, board: {
|
|
104
|
+
display: board,
|
|
105
|
+
editable: boardMaturity
|
|
106
|
+
}, interface: {
|
|
107
|
+
locale: language
|
|
108
|
+
} }), (redirectUrl && {
|
|
109
|
+
redirect: {
|
|
110
|
+
url: redirectUrl
|
|
111
|
+
}
|
|
112
|
+
})), (postURL && {
|
|
100
113
|
post: {
|
|
101
114
|
url: postURL
|
|
102
115
|
}
|
|
103
116
|
}));
|
|
104
117
|
return [4, generateConfigToken(payload)];
|
|
105
118
|
case 1:
|
|
106
|
-
|
|
119
|
+
_a = _c.sent(), data = _a.data, publicKeyValue = _a.publicKey;
|
|
107
120
|
if (data === null || data === void 0 ? void 0 : data.error) {
|
|
108
121
|
onError === null || onError === void 0 ? void 0 : onError(data.error);
|
|
109
122
|
return [2];
|
|
110
123
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
url_1 = (redirect === null || redirect === void 0 ? void 0 : redirect.url) ||
|
|
116
|
-
"".concat(CONNECT_URL, "express/?config_token=").concat(token, "leadId=").concat(leadId, "&showBoard=").concat(showBoard, "&boardMaturity=").concat(boardMaturity);
|
|
124
|
+
_b = data || {}, token = _b.token, connect = _b.connect;
|
|
125
|
+
baseUrl = getRedirectBaseUrl(publicKeyValue || '');
|
|
126
|
+
if (!mature || scope === 'auth') {
|
|
127
|
+
url_1 = (connect === null || connect === void 0 ? void 0 : connect.url) || "".concat(baseUrl, "?config_token=").concat(token);
|
|
117
128
|
window.location.href = url_1;
|
|
118
129
|
return [2];
|
|
119
130
|
}
|
|
120
131
|
countryCode = country.toLowerCase();
|
|
121
|
-
url = (
|
|
132
|
+
url = (connect === null || connect === void 0 ? void 0 : connect.url) || "".concat(baseUrl).concat(countryCode, "?config_token=").concat(token);
|
|
122
133
|
window.location.href = url;
|
|
123
134
|
return [2];
|
|
124
135
|
case 2:
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ConnectProps as ConnectAttrs } from '../../@types';
|
|
3
|
+
export type ConnectAuthProps = Pick<ConnectAttrs, 'open' | 'domain' | 'publicKey' | 'redirectUrl' | 'data' | 'postURL' | 'lead' | 'country' | 'language' | 'onSuccess' | 'onError' | 'onReady' | 'onClose' | 'features' | 'openAnimationDirection' | 'closeAnimationDirection'>;
|
|
4
|
+
export declare const TapConnectAuth: React.MemoExoticComponent<(props: ConnectAuthProps & {
|
|
5
|
+
id?: string;
|
|
6
|
+
}) => JSX.Element>;
|
|
7
|
+
export declare const renderTapConnectAuth: (props: ConnectAuthProps, elementId: string) => Promise<any>;
|