@tap-payments/connect 2.6.56-test → 2.6.58-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 +1 -1
- package/build/constants/index.d.ts +1 -1
- package/build/constants/index.js +1 -1
- package/build/features/Connect/ConnectAuth.d.ts +5 -0
- package/build/features/Connect/ConnectAuth.js +113 -0
- package/build/features/Connect/index.d.ts +3 -2
- package/build/features/Connect/index.js +2 -1
- package/build/index.d.ts +3 -3
- package/build/index.js +4 -3
- package/build/utils/validation.d.ts +1 -0
- package/build/utils/validation.js +45 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ const ConnectComponent = () => {
|
|
|
85
85
|
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no"
|
|
86
86
|
/>
|
|
87
87
|
<title>Auth-JsConnect</title>
|
|
88
|
-
<script src="https://tap-sdks.b-cdn.net/connect/build-2.6.
|
|
88
|
+
<script src="https://tap-sdks.b-cdn.net/connect/build-2.6.57-test/main.js"></script>
|
|
89
89
|
</head>
|
|
90
90
|
<body>
|
|
91
91
|
<div id="root"></div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.6.
|
|
1
|
+
export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.6.57-test/";
|
|
2
2
|
export declare const Maturity: {
|
|
3
3
|
readonly FULL: "full";
|
|
4
4
|
readonly EXPRESS: "express";
|
package/build/constants/index.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
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'>;
|
|
4
|
+
export declare const TapConnectAuth: React.MemoExoticComponent<(props: ConnectAuthProps) => import("react/jsx-runtime").JSX.Element>;
|
|
5
|
+
export declare const renderTapConnectAuth: (props: ConnectAuthProps, elementId: string) => Promise<any>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
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
|
+
};
|
|
48
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
|
+
import * as React from 'react';
|
|
50
|
+
import { createRoot } from 'react-dom/client';
|
|
51
|
+
import { findOrCreateElementAndInject, validateConnectAuthProps } from '../../utils';
|
|
52
|
+
import { useScript, useStyle } from '../../hooks';
|
|
53
|
+
import { CDN_LIBRARY_BASE_URL } from '../../constants';
|
|
54
|
+
var ConnectAuth = function (props) {
|
|
55
|
+
useStyle("".concat(CDN_LIBRARY_BASE_URL, "/main.css"));
|
|
56
|
+
var status = useScript("".concat(CDN_LIBRARY_BASE_URL, "/main.js"));
|
|
57
|
+
React.useEffect(function () {
|
|
58
|
+
if (status === 'ready')
|
|
59
|
+
console.info('connect-auth-js is ready!');
|
|
60
|
+
if (status === 'error')
|
|
61
|
+
console.error('connect-auth-js failed to load!');
|
|
62
|
+
}, [status]);
|
|
63
|
+
React.useEffect(function () {
|
|
64
|
+
if (status !== 'ready')
|
|
65
|
+
return;
|
|
66
|
+
var renderAuthLib = window['TapAuth'].renderAuthLib;
|
|
67
|
+
var unmount = renderAuthLib({
|
|
68
|
+
open: props.open,
|
|
69
|
+
mode: 'popup',
|
|
70
|
+
scope: 'auth',
|
|
71
|
+
merchantDomain: props.domain,
|
|
72
|
+
publicKey: props.publicKey,
|
|
73
|
+
redirectUrl: props.redirectUrl,
|
|
74
|
+
data: props.data,
|
|
75
|
+
postURL: props.postURL,
|
|
76
|
+
leadId: props.lead,
|
|
77
|
+
appInfo: {
|
|
78
|
+
name: window.location.hostname || window.location.origin
|
|
79
|
+
},
|
|
80
|
+
businessCountryCode: props.country,
|
|
81
|
+
language: props.language,
|
|
82
|
+
onFlowCompleted: props.onSuccess,
|
|
83
|
+
onError: props.onError,
|
|
84
|
+
onReady: props.onReady,
|
|
85
|
+
onClose: props.onClose
|
|
86
|
+
}, 'tap-connect-auth-lib-id').unmount;
|
|
87
|
+
return function () {
|
|
88
|
+
unmount();
|
|
89
|
+
};
|
|
90
|
+
}, [status]);
|
|
91
|
+
if (status !== 'ready')
|
|
92
|
+
return null;
|
|
93
|
+
return _jsx("div", { id: 'tap-connect-auth-lib-id' });
|
|
94
|
+
};
|
|
95
|
+
export var TapConnectAuth = React.memo(function (props) {
|
|
96
|
+
validateConnectAuthProps(props);
|
|
97
|
+
return _jsx(ConnectAuth, __assign({}, props));
|
|
98
|
+
});
|
|
99
|
+
var tapConnectInstance = null;
|
|
100
|
+
export var renderTapConnectAuth = function (props, elementId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
101
|
+
var el, root, unmount;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
el = findOrCreateElementAndInject(elementId);
|
|
104
|
+
root = createRoot(el);
|
|
105
|
+
root.render(_jsx(TapConnectAuth, __assign({}, props)));
|
|
106
|
+
unmount = function () {
|
|
107
|
+
root.unmount();
|
|
108
|
+
tapConnectInstance = null;
|
|
109
|
+
};
|
|
110
|
+
tapConnectInstance = { unmount: unmount };
|
|
111
|
+
return [2, tapConnectInstance];
|
|
112
|
+
});
|
|
113
|
+
}); };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { TapConnect, ConnectProps as TapConnectProps, renderTapConnect } from './Connect';
|
|
2
|
-
|
|
3
|
-
export {
|
|
2
|
+
import { ConnectAuthProps, TapConnectAuth, renderTapConnectAuth } from './ConnectAuth';
|
|
3
|
+
export type { TapConnectProps, ConnectAuthProps };
|
|
4
|
+
export { TapConnect, renderTapConnect, TapConnectAuth, renderTapConnectAuth };
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TapConnect, TapConnectProps, renderTapConnect } from './features/Connect';
|
|
1
|
+
import { TapConnect, TapConnectProps, renderTapConnect, ConnectAuthProps, TapConnectAuth, renderTapConnectAuth } from './features/Connect';
|
|
2
2
|
import { Language } from './constants';
|
|
3
|
-
export type { TapConnectProps };
|
|
4
|
-
export { Language, TapConnect, renderTapConnect };
|
|
3
|
+
export type { TapConnectProps, ConnectAuthProps };
|
|
4
|
+
export { Language, TapConnect, renderTapConnect, TapConnectAuth, renderTapConnectAuth };
|
package/build/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { TapConnect, renderTapConnect } from './features/Connect';
|
|
1
|
+
import { TapConnect, renderTapConnect, TapConnectAuth, renderTapConnectAuth } from './features/Connect';
|
|
2
2
|
import { Language } from './constants';
|
|
3
|
-
export { Language, TapConnect, renderTapConnect };
|
|
3
|
+
export { Language, TapConnect, renderTapConnect, TapConnectAuth, renderTapConnectAuth };
|
|
4
4
|
window['TapPayments'] = {
|
|
5
5
|
renderTapConnect: renderTapConnect,
|
|
6
|
-
Language: Language
|
|
6
|
+
Language: Language,
|
|
7
|
+
renderTapConnectAuth: renderTapConnectAuth
|
|
7
8
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ConnectProps } from '../@types';
|
|
2
2
|
export declare const validateConnectProps: (props: ConnectProps) => void;
|
|
3
|
+
export declare const validateConnectAuthProps: (props: Pick<ConnectProps, 'open' | 'domain' | 'publicKey' | 'redirectUrl' | 'data' | 'postURL' | 'lead' | 'country' | 'language' | 'onSuccess' | 'onError' | 'onReady' | 'onClose'>) => void;
|
|
@@ -59,3 +59,48 @@ export var validateConnectProps = function (props) {
|
|
|
59
59
|
throw new Error('onSuccess must be a function');
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
+
export var validateConnectAuthProps = function (props) {
|
|
63
|
+
var publicKey = props.publicKey, country = props.country, language = props.language, open = props.open, domain = props.domain, lead = props.lead, onClose = props.onClose, onError = props.onError, onReady = props.onReady, onSuccess = props.onSuccess, postURL = props.postURL, data = props.data;
|
|
64
|
+
if (!data) {
|
|
65
|
+
throw new Error('data is required');
|
|
66
|
+
}
|
|
67
|
+
if (!Array.isArray(data)) {
|
|
68
|
+
throw new Error('data must be an array');
|
|
69
|
+
}
|
|
70
|
+
if (!publicKey) {
|
|
71
|
+
throw new Error('publicKey is required');
|
|
72
|
+
}
|
|
73
|
+
if (!country) {
|
|
74
|
+
throw new Error('country is required');
|
|
75
|
+
}
|
|
76
|
+
if (!language) {
|
|
77
|
+
throw new Error('language is required');
|
|
78
|
+
}
|
|
79
|
+
if (![Language.AR, Language.EN].includes(language)) {
|
|
80
|
+
throw new Error('you can only use AR or EN for language');
|
|
81
|
+
}
|
|
82
|
+
if (!domain) {
|
|
83
|
+
throw new Error('domain is required');
|
|
84
|
+
}
|
|
85
|
+
if (typeof open !== 'boolean') {
|
|
86
|
+
throw new Error('open is required, and must be a boolean');
|
|
87
|
+
}
|
|
88
|
+
if (typeof lead !== 'undefined' && typeof lead !== 'string') {
|
|
89
|
+
throw new Error('lead must be a string');
|
|
90
|
+
}
|
|
91
|
+
if (typeof postURL !== 'undefined' && typeof postURL !== 'string') {
|
|
92
|
+
throw new Error('postURL must be a string');
|
|
93
|
+
}
|
|
94
|
+
if (typeof onClose !== 'undefined' && typeof onClose !== 'function') {
|
|
95
|
+
throw new Error('onClose must be a function');
|
|
96
|
+
}
|
|
97
|
+
if (typeof onError !== 'undefined' && typeof onError !== 'function') {
|
|
98
|
+
throw new Error('onError must be a function');
|
|
99
|
+
}
|
|
100
|
+
if (typeof onReady !== 'undefined' && typeof onReady !== 'function') {
|
|
101
|
+
throw new Error('onReady must be a function');
|
|
102
|
+
}
|
|
103
|
+
if (typeof onSuccess !== 'undefined' && typeof onSuccess !== 'function') {
|
|
104
|
+
throw new Error('onSuccess must be a function');
|
|
105
|
+
}
|
|
106
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/connect",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.58-test",
|
|
4
4
|
"description": "Tap Connect",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"module": "build/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"README.md"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"
|
|
13
|
+
"prepare": "npx husky install",
|
|
14
14
|
"prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\" *.json *.js",
|
|
15
15
|
"prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\" *.json *.js",
|
|
16
16
|
"lint": "eslint src --color --ext .js,.jsx,.ts,.tsx,.json",
|