@tap-payments/connect 1.1.0 → 1.3.0
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 +1 -1
- package/build/@types/index.d.ts +33 -0
- package/build/api/index.d.ts +2 -0
- package/build/api/index.js +61 -0
- package/build/constants/index.d.ts +3 -1
- package/build/constants/index.js +3 -1
- package/build/features/Connect/Connect.d.ts +1 -1
- package/build/features/Connect/Connect.js +89 -15
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ const ConnectFullComponent = () => {
|
|
|
109
109
|
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no"
|
|
110
110
|
/>
|
|
111
111
|
<title>Auth-JsConnect</title>
|
|
112
|
-
<script src="https://connect-auth.b-cdn.net/build-1.
|
|
112
|
+
<script src="https://connect-auth.b-cdn.net/build-1.3.0/main.js"></script>
|
|
113
113
|
</head>
|
|
114
114
|
<body>
|
|
115
115
|
<div id="root"></div>
|
package/build/@types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface ConnectProps {
|
|
|
8
8
|
scope: string;
|
|
9
9
|
lead?: string;
|
|
10
10
|
mature: boolean;
|
|
11
|
+
mode: 'popup' | 'page';
|
|
11
12
|
board?: boolean;
|
|
12
13
|
boardMaturity?: boolean;
|
|
13
14
|
open: boolean;
|
|
@@ -42,3 +43,35 @@ export interface OriginalConnectProps {
|
|
|
42
43
|
onClose?: () => void;
|
|
43
44
|
onBoardCompleted?: () => void;
|
|
44
45
|
}
|
|
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
|
+
};
|
|
64
|
+
export interface TokenResponseParams extends TokenParams {
|
|
65
|
+
id: string;
|
|
66
|
+
contact: {
|
|
67
|
+
email: string;
|
|
68
|
+
phone: {
|
|
69
|
+
country_code: string;
|
|
70
|
+
number: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
redirect: {
|
|
74
|
+
url: string;
|
|
75
|
+
};
|
|
76
|
+
token: string;
|
|
77
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import axios from 'axios';
|
|
38
|
+
import { CONNECT_MW_URL } from '../constants';
|
|
39
|
+
export var generateConfigToken = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
40
|
+
var response, error_1;
|
|
41
|
+
return __generator(this, function (_a) {
|
|
42
|
+
switch (_a.label) {
|
|
43
|
+
case 0:
|
|
44
|
+
_a.trys.push([0, 2, , 3]);
|
|
45
|
+
return [4, axios.post("".concat(CONNECT_MW_URL, "connect"), data, {
|
|
46
|
+
headers: {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
'Access-Control-Allow-Headers': true,
|
|
49
|
+
authorization: data.public_key
|
|
50
|
+
}
|
|
51
|
+
})];
|
|
52
|
+
case 1:
|
|
53
|
+
response = _a.sent();
|
|
54
|
+
return [2, response.data];
|
|
55
|
+
case 2:
|
|
56
|
+
error_1 = _a.sent();
|
|
57
|
+
return [2, { error: error_1 }];
|
|
58
|
+
case 3: return [2];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}); };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.
|
|
1
|
+
export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.3.0";
|
|
2
2
|
export declare const Maturity: {
|
|
3
3
|
readonly FULL: "full";
|
|
4
4
|
readonly EXPRESS: "express";
|
|
@@ -7,3 +7,5 @@ export declare const Language: {
|
|
|
7
7
|
readonly EN: "en";
|
|
8
8
|
readonly AR: "ar";
|
|
9
9
|
};
|
|
10
|
+
export declare const CONNECT_URL = "https://connect.tap.company/";
|
|
11
|
+
export declare const CONNECT_MW_URL = "https://connect-mw.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.
|
|
1
|
+
export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.3.0';
|
|
2
2
|
export var Maturity = {
|
|
3
3
|
FULL: 'full',
|
|
4
4
|
EXPRESS: 'express'
|
|
@@ -7,3 +7,5 @@ export var Language = {
|
|
|
7
7
|
EN: 'en',
|
|
8
8
|
AR: 'ar'
|
|
9
9
|
};
|
|
10
|
+
export var CONNECT_URL = 'https://connect.tap.company/';
|
|
11
|
+
export var CONNECT_MW_URL = 'https://connect-mw.tap.company/middleware/';
|
|
@@ -2,4 +2,4 @@ import * as React from 'react';
|
|
|
2
2
|
import { ConnectProps as ConnectAttrs } from '../../@types';
|
|
3
3
|
export type ConnectProps = Omit<ConnectAttrs, 'elementId'>;
|
|
4
4
|
export declare const TapConnect: React.MemoExoticComponent<(props: ConnectAttrs) => JSX.Element>;
|
|
5
|
-
export declare const renderTapConnect: (props: ConnectProps, elementId: string) => any
|
|
5
|
+
export declare const renderTapConnect: (props: ConnectProps, elementId: string) => Promise<any>;
|
|
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
12
48
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
49
|
var t = {};
|
|
14
50
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -25,7 +61,8 @@ import * as React from 'react';
|
|
|
25
61
|
import { createRoot } from 'react-dom/client';
|
|
26
62
|
import { findOrCreateElementAndInject, validateConnectProps } from '../../utils';
|
|
27
63
|
import { useScript, useStyle } from '../../hooks';
|
|
28
|
-
import { CDN_LIBRARY_BASE_URL } from '../../constants';
|
|
64
|
+
import { CDN_LIBRARY_BASE_URL, CONNECT_URL } from '../../constants';
|
|
65
|
+
import { generateConfigToken } from '../../api';
|
|
29
66
|
import ConnectFull from './ConnectFull';
|
|
30
67
|
import ConnectExpress from './ConnectExpress';
|
|
31
68
|
var Connect = function (_a) {
|
|
@@ -49,17 +86,54 @@ export var TapConnect = React.memo(function (props) {
|
|
|
49
86
|
return _jsx(Connect, __assign({}, props));
|
|
50
87
|
});
|
|
51
88
|
var tapConnectInstance = null;
|
|
52
|
-
export var renderTapConnect = function (props, elementId) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
89
|
+
export var renderTapConnect = function (props, elementId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
+
var mode, board, publicKey, boardMaturity, domain, language, country, scope, lead, postURL, mature, onError, payload, data, _a, token, redirect, leadId, showBoard, url_1, countryCode, url, el, root, unmount;
|
|
91
|
+
return __generator(this, function (_b) {
|
|
92
|
+
switch (_b.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
mode = props.mode, board = props.board, publicKey = props.publicKey, boardMaturity = props.boardMaturity, domain = props.domain, language = props.language, country = props.country, scope = props.scope, lead = props.lead, postURL = props.postURL, mature = props.mature, onError = props.onError;
|
|
95
|
+
if (!(mode === 'page')) return [3, 2];
|
|
96
|
+
payload = __assign({ board: board, public_key: publicKey, board_maturity: boardMaturity, domain: domain, language: language, country: country, scope: scope, lead_id: lead, maturity: mature, notification: {
|
|
97
|
+
email: true,
|
|
98
|
+
sms: true
|
|
99
|
+
} }, (postURL && {
|
|
100
|
+
post: {
|
|
101
|
+
url: postURL
|
|
102
|
+
}
|
|
103
|
+
}));
|
|
104
|
+
return [4, generateConfigToken(payload)];
|
|
105
|
+
case 1:
|
|
106
|
+
data = _b.sent();
|
|
107
|
+
if (data === null || data === void 0 ? void 0 : data.error) {
|
|
108
|
+
onError === null || onError === void 0 ? void 0 : onError(data.error);
|
|
109
|
+
return [2];
|
|
110
|
+
}
|
|
111
|
+
_a = data || {}, token = _a.token, redirect = _a.redirect;
|
|
112
|
+
if (!mature) {
|
|
113
|
+
leadId = lead;
|
|
114
|
+
showBoard = board;
|
|
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);
|
|
117
|
+
window.open(url_1, '_blank');
|
|
118
|
+
return [2];
|
|
119
|
+
}
|
|
120
|
+
countryCode = country.toLowerCase();
|
|
121
|
+
url = (redirect === null || redirect === void 0 ? void 0 : redirect.url) || "".concat(CONNECT_URL).concat(countryCode, "?config_token=").concat(token);
|
|
122
|
+
window.open(url, '_blank');
|
|
123
|
+
return [2];
|
|
124
|
+
case 2:
|
|
125
|
+
if (tapConnectInstance) {
|
|
126
|
+
return [2, tapConnectInstance];
|
|
127
|
+
}
|
|
128
|
+
el = findOrCreateElementAndInject(elementId);
|
|
129
|
+
root = createRoot(el);
|
|
130
|
+
root.render(_jsx(TapConnect, __assign({}, props, { elementId: elementId })));
|
|
131
|
+
unmount = function () {
|
|
132
|
+
root.unmount();
|
|
133
|
+
tapConnectInstance = null;
|
|
134
|
+
};
|
|
135
|
+
tapConnectInstance = { unmount: unmount };
|
|
136
|
+
return [2, tapConnectInstance];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}); };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/connect",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Tap Connect",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"module": "build/index.js",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@babel/preset-env": "^7.18.6",
|
|
34
34
|
"@babel/preset-react": "^7.18.6",
|
|
35
35
|
"@babel/preset-typescript": "^7.18.6",
|
|
36
|
+
"@types/axios": "^0.14.0",
|
|
36
37
|
"@types/crypto-js": "^4.1.1",
|
|
37
38
|
"@types/react": "^18.0.15",
|
|
38
39
|
"@types/react-dom": "^18.0.6",
|
|
@@ -72,8 +73,8 @@
|
|
|
72
73
|
"webpack-merge": "^5.8.0"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
|
-
"react": "
|
|
76
|
-
"react-dom": "
|
|
76
|
+
"react": ">=18.2.0",
|
|
77
|
+
"react-dom": ">=18.2.0"
|
|
77
78
|
},
|
|
78
79
|
"peerDependencies": {
|
|
79
80
|
"@types/react": ">=18.0.15",
|