@tap-payments/connect 1.0.0 → 1.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/README.md +181 -174
- package/build/@types/index.d.ts +44 -39
- package/build/@types/index.js +1 -1
- package/build/constants/index.d.ts +9 -9
- package/build/constants/index.js +9 -9
- package/build/features/Connect/Connect.d.ts +5 -7
- package/build/features/Connect/Connect.js +65 -45
- package/build/features/Connect/ConnectExpress.d.ts +4 -4
- package/build/features/Connect/ConnectExpress.js +90 -76
- package/build/features/Connect/ConnectFull.d.ts +4 -4
- package/build/features/Connect/ConnectFull.js +13 -12
- package/build/features/Connect/index.d.ts +3 -3
- package/build/features/Connect/index.js +2 -2
- package/build/hooks/index.d.ts +2 -2
- package/build/hooks/index.js +2 -2
- package/build/hooks/useScript.d.ts +1 -1
- package/build/hooks/useScript.js +39 -39
- package/build/hooks/useStyle.d.ts +1 -1
- package/build/hooks/useStyle.js +13 -13
- package/build/index.d.ts +4 -4
- package/build/index.js +7 -7
- package/build/utils/config.d.ts +7 -7
- package/build/utils/config.js +42 -38
- package/build/utils/html.d.ts +1 -1
- package/build/utils/html.js +9 -6
- package/build/utils/index.d.ts +3 -3
- package/build/utils/index.js +3 -3
- package/build/utils/validation.d.ts +2 -2
- package/build/utils/validation.js +52 -52
- package/package.json +1 -1
|
@@ -1,76 +1,90 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
import * as React from 'react';
|
|
24
|
-
import { wrapLibConfig } from '../../utils';
|
|
25
|
-
var ConnectExpress = function (props) {
|
|
26
|
-
var _a = React.useState(''), token = _a[0], setToken = _a[1];
|
|
27
|
-
var _b = React.useState('express'), name = _b[0], setName = _b[1];
|
|
28
|
-
var onButtonClick = function (_a) {
|
|
29
|
-
var name = _a.name, token = _a.token;
|
|
30
|
-
setToken(token);
|
|
31
|
-
setName(name);
|
|
32
|
-
};
|
|
33
|
-
var _c = window['TapAuth'], renderConnectExpressLib = _c.renderConnectExpressLib, renderIndividualLib = _c.renderIndividualLib, renderBankLib = _c.renderBankLib, renderTaxLib = _c.renderTaxLib, renderEntityLib = _c.renderEntityLib, renderBrandLib = _c.renderBrandLib;
|
|
34
|
-
var elementId =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
break;
|
|
45
|
-
case '
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import * as React from 'react';
|
|
24
|
+
import { wrapLibConfig } from '../../utils';
|
|
25
|
+
var ConnectExpress = function (props) {
|
|
26
|
+
var _a = React.useState(''), token = _a[0], setToken = _a[1];
|
|
27
|
+
var _b = React.useState('express'), name = _b[0], setName = _b[1];
|
|
28
|
+
var onButtonClick = function (_a) {
|
|
29
|
+
var name = _a.name, token = _a.token;
|
|
30
|
+
setToken(token);
|
|
31
|
+
setName(name);
|
|
32
|
+
};
|
|
33
|
+
var _c = window['TapAuth'], renderConnectExpressLib = _c.renderConnectExpressLib, renderIndividualLib = _c.renderIndividualLib, renderBankLib = _c.renderBankLib, renderTaxLib = _c.renderTaxLib, renderEntityLib = _c.renderEntityLib, renderBrandLib = _c.renderBrandLib;
|
|
34
|
+
var elementId = props.elementId;
|
|
35
|
+
var unmountComponent = function () { };
|
|
36
|
+
React.useEffect(function () {
|
|
37
|
+
console.log('rendering: ', name);
|
|
38
|
+
var config = wrapLibConfig(__assign(__assign({}, props), { verifyToken: token, onBoardButtonClick: onButtonClick }));
|
|
39
|
+
switch (name) {
|
|
40
|
+
case 'brand':
|
|
41
|
+
unmountComponent();
|
|
42
|
+
var unmountBrand = renderBrandLib(config, elementId).unmount;
|
|
43
|
+
unmountComponent = unmountBrand;
|
|
44
|
+
break;
|
|
45
|
+
case 'tax':
|
|
46
|
+
unmountComponent();
|
|
47
|
+
var unmountTax = renderTaxLib(config, elementId).unmount;
|
|
48
|
+
unmountComponent = unmountTax;
|
|
49
|
+
break;
|
|
50
|
+
case 'bank':
|
|
51
|
+
unmountComponent();
|
|
52
|
+
var unmountBank = renderBankLib(config, elementId).unmount;
|
|
53
|
+
unmountComponent = unmountBank;
|
|
54
|
+
break;
|
|
55
|
+
case 'individual':
|
|
56
|
+
unmountComponent();
|
|
57
|
+
var unmountIndiv = renderIndividualLib(config, elementId).unmount;
|
|
58
|
+
unmountComponent = unmountIndiv;
|
|
59
|
+
break;
|
|
60
|
+
case 'entity':
|
|
61
|
+
unmountComponent();
|
|
62
|
+
var unmountEntity = renderEntityLib(config, elementId).unmount;
|
|
63
|
+
unmountComponent = unmountEntity;
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
unmountComponent();
|
|
67
|
+
var onSuccess = props.onSuccess, rest = __rest(props, ["onSuccess"]);
|
|
68
|
+
var configAttrs = wrapLibConfig(__assign(__assign({}, rest), { verifyToken: token, onBoardButtonClick: onButtonClick }));
|
|
69
|
+
var unmountExpress = renderConnectExpressLib(configAttrs, elementId).unmount;
|
|
70
|
+
unmountComponent = unmountExpress;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
return function () { return unmountComponent(); };
|
|
74
|
+
}, [
|
|
75
|
+
name,
|
|
76
|
+
token,
|
|
77
|
+
renderConnectExpressLib,
|
|
78
|
+
renderIndividualLib,
|
|
79
|
+
renderBankLib,
|
|
80
|
+
renderTaxLib,
|
|
81
|
+
renderEntityLib,
|
|
82
|
+
renderBrandLib,
|
|
83
|
+
props,
|
|
84
|
+
elementId,
|
|
85
|
+
onButtonClick,
|
|
86
|
+
wrapLibConfig
|
|
87
|
+
]);
|
|
88
|
+
return null;
|
|
89
|
+
};
|
|
90
|
+
export default React.memo(ConnectExpress);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ConnectProps } from '../../@types';
|
|
3
|
-
declare const _default: React.MemoExoticComponent<(props: ConnectProps) => null>;
|
|
4
|
-
export default _default;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ConnectProps } from '../../@types';
|
|
3
|
+
declare const _default: React.MemoExoticComponent<(props: ConnectProps) => null>;
|
|
4
|
+
export default _default;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { wrapLibConfig } from '../../utils';
|
|
3
|
-
var ConnectFull = function (props) {
|
|
4
|
-
var renderConnectLib = window['TapAuth'].renderConnectLib;
|
|
5
|
-
var id =
|
|
6
|
-
React.useEffect(function () {
|
|
7
|
-
var config = wrapLibConfig(props);
|
|
8
|
-
renderConnectLib(config, id);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { wrapLibConfig } from '../../utils';
|
|
3
|
+
var ConnectFull = function (props) {
|
|
4
|
+
var renderConnectLib = window['TapAuth'].renderConnectLib;
|
|
5
|
+
var id = props.elementId;
|
|
6
|
+
React.useEffect(function () {
|
|
7
|
+
var config = wrapLibConfig(props);
|
|
8
|
+
var unmount = renderConnectLib(config, id).unmount;
|
|
9
|
+
return function () { return unmount(); };
|
|
10
|
+
}, [renderConnectLib, props]);
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
export default React.memo(ConnectFull);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TapConnect, ConnectProps as TapConnectProps, renderTapConnect } from './Connect';
|
|
2
|
-
export type { TapConnectProps };
|
|
3
|
-
export { TapConnect, renderTapConnect };
|
|
1
|
+
import { TapConnect, ConnectProps as TapConnectProps, renderTapConnect } from './Connect';
|
|
2
|
+
export type { TapConnectProps };
|
|
3
|
+
export { TapConnect, renderTapConnect };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TapConnect, renderTapConnect } from './Connect';
|
|
2
|
-
export { TapConnect, renderTapConnect };
|
|
1
|
+
import { TapConnect, renderTapConnect } from './Connect';
|
|
2
|
+
export { TapConnect, renderTapConnect };
|
package/build/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './useScript';
|
|
2
|
-
export * from './useStyle';
|
|
1
|
+
export * from './useScript';
|
|
2
|
+
export * from './useStyle';
|
package/build/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './useScript';
|
|
2
|
-
export * from './useStyle';
|
|
1
|
+
export * from './useScript';
|
|
2
|
+
export * from './useStyle';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useScript(src: string, async?: boolean): "ready" | "loading" | "idle" | "error";
|
|
1
|
+
export declare function useScript(src: string, async?: boolean): "ready" | "loading" | "idle" | "error";
|
package/build/hooks/useScript.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
export function useScript(src, async) {
|
|
3
|
-
if (async === void 0) { async = true; }
|
|
4
|
-
var _a = useState(src ? 'loading' : 'idle'), status = _a[0], setStatus = _a[1];
|
|
5
|
-
useEffect(function () {
|
|
6
|
-
if (!src) {
|
|
7
|
-
setStatus('idle');
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
var script = document.querySelector("script[src=\"".concat(src, "\"]"));
|
|
11
|
-
if (!script) {
|
|
12
|
-
script = document.createElement('script');
|
|
13
|
-
script.src = src;
|
|
14
|
-
script.async = async;
|
|
15
|
-
script.setAttribute('data-status', 'loading');
|
|
16
|
-
document.body.appendChild(script);
|
|
17
|
-
var setAttributeFromEvent = function (event) {
|
|
18
|
-
script.setAttribute('data-status', event.type === 'load' ? 'ready' : 'error');
|
|
19
|
-
};
|
|
20
|
-
script.addEventListener('load', setAttributeFromEvent);
|
|
21
|
-
script.addEventListener('error', setAttributeFromEvent);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
setStatus(script.getAttribute('data-status'));
|
|
25
|
-
}
|
|
26
|
-
var setStateFromEvent = function (event) {
|
|
27
|
-
setStatus(event.type === 'load' ? 'ready' : 'error');
|
|
28
|
-
};
|
|
29
|
-
script.addEventListener('load', setStateFromEvent);
|
|
30
|
-
script.addEventListener('error', setStateFromEvent);
|
|
31
|
-
return function () {
|
|
32
|
-
if (script) {
|
|
33
|
-
script.removeEventListener('load', setStateFromEvent);
|
|
34
|
-
script.removeEventListener('error', setStateFromEvent);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}, [src]);
|
|
38
|
-
return status;
|
|
39
|
-
}
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
export function useScript(src, async) {
|
|
3
|
+
if (async === void 0) { async = true; }
|
|
4
|
+
var _a = useState(src ? 'loading' : 'idle'), status = _a[0], setStatus = _a[1];
|
|
5
|
+
useEffect(function () {
|
|
6
|
+
if (!src) {
|
|
7
|
+
setStatus('idle');
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
var script = document.querySelector("script[src=\"".concat(src, "\"]"));
|
|
11
|
+
if (!script) {
|
|
12
|
+
script = document.createElement('script');
|
|
13
|
+
script.src = src;
|
|
14
|
+
script.async = async;
|
|
15
|
+
script.setAttribute('data-status', 'loading');
|
|
16
|
+
document.body.appendChild(script);
|
|
17
|
+
var setAttributeFromEvent = function (event) {
|
|
18
|
+
script.setAttribute('data-status', event.type === 'load' ? 'ready' : 'error');
|
|
19
|
+
};
|
|
20
|
+
script.addEventListener('load', setAttributeFromEvent);
|
|
21
|
+
script.addEventListener('error', setAttributeFromEvent);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
setStatus(script.getAttribute('data-status'));
|
|
25
|
+
}
|
|
26
|
+
var setStateFromEvent = function (event) {
|
|
27
|
+
setStatus(event.type === 'load' ? 'ready' : 'error');
|
|
28
|
+
};
|
|
29
|
+
script.addEventListener('load', setStateFromEvent);
|
|
30
|
+
script.addEventListener('error', setStateFromEvent);
|
|
31
|
+
return function () {
|
|
32
|
+
if (script) {
|
|
33
|
+
script.removeEventListener('load', setStateFromEvent);
|
|
34
|
+
script.removeEventListener('error', setStateFromEvent);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}, [src]);
|
|
38
|
+
return status;
|
|
39
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyle: (url: string) => void;
|
|
1
|
+
export declare const useStyle: (url: string) => void;
|
package/build/hooks/useStyle.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
export var useStyle = function (url) {
|
|
3
|
-
useEffect(function () {
|
|
4
|
-
var link = document.createElement('link');
|
|
5
|
-
link.href = url;
|
|
6
|
-
link.rel = 'stylesheet';
|
|
7
|
-
link.type = 'text/css';
|
|
8
|
-
document.head.appendChild(link);
|
|
9
|
-
return function () {
|
|
10
|
-
document.head.removeChild(link);
|
|
11
|
-
};
|
|
12
|
-
}, [url]);
|
|
13
|
-
};
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
export var useStyle = function (url) {
|
|
3
|
+
useEffect(function () {
|
|
4
|
+
var link = document.createElement('link');
|
|
5
|
+
link.href = url;
|
|
6
|
+
link.rel = 'stylesheet';
|
|
7
|
+
link.type = 'text/css';
|
|
8
|
+
document.head.appendChild(link);
|
|
9
|
+
return function () {
|
|
10
|
+
document.head.removeChild(link);
|
|
11
|
+
};
|
|
12
|
+
}, [url]);
|
|
13
|
+
};
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TapConnect, TapConnectProps, renderTapConnect } from './features/Connect';
|
|
2
|
-
import { Language } from './constants';
|
|
3
|
-
export type { TapConnectProps };
|
|
4
|
-
export { Language, TapConnect, renderTapConnect };
|
|
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 { 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
|
-
};
|
|
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
|
+
};
|
package/build/utils/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ConnectProps, OriginalConnectProps } from '../@types';
|
|
2
|
-
type ExtraProps = {
|
|
3
|
-
verifyToken?: string;
|
|
4
|
-
onBoardButtonClick?: (data: Record<string, string>) => void;
|
|
5
|
-
};
|
|
6
|
-
export declare const wrapLibConfig: ({ publicKey, open, language, country, scope, lead, postURL, onError, onReady, onSuccess, board, verifyToken, domain, onBoardButtonClick, onClose, onCreated }: ConnectProps & ExtraProps) => OriginalConnectProps;
|
|
7
|
-
export {};
|
|
1
|
+
import { ConnectProps, OriginalConnectProps } from '../@types';
|
|
2
|
+
type ExtraProps = {
|
|
3
|
+
verifyToken?: string;
|
|
4
|
+
onBoardButtonClick?: (data: Record<string, string>) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const wrapLibConfig: ({ publicKey, open, language, country, scope, lead, postURL, onError, onReady, onSuccess, board, verifyToken, domain, onBoardButtonClick, onClose, onCreated, onBoardCompleted, boardMaturity }: ConnectProps & ExtraProps) => OriginalConnectProps;
|
|
7
|
+
export {};
|
package/build/utils/config.js
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
export var wrapLibConfig = function (_a) {
|
|
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
|
-
return {
|
|
4
|
-
appInfo: {
|
|
5
|
-
name: window.location.hostname
|
|
6
|
-
},
|
|
7
|
-
businessCountryCode: country,
|
|
8
|
-
language: language,
|
|
9
|
-
merchantDomain: domain,
|
|
10
|
-
open: open,
|
|
11
|
-
postURL: postURL,
|
|
12
|
-
publicKey: publicKey,
|
|
13
|
-
scope: scope,
|
|
14
|
-
leadId: lead,
|
|
15
|
-
showBoard: board,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
1
|
+
export var wrapLibConfig = function (_a) {
|
|
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, onBoardCompleted = _a.onBoardCompleted, boardMaturity = _a.boardMaturity;
|
|
3
|
+
return {
|
|
4
|
+
appInfo: {
|
|
5
|
+
name: window.location.hostname || window.location.origin
|
|
6
|
+
},
|
|
7
|
+
businessCountryCode: country,
|
|
8
|
+
language: language,
|
|
9
|
+
merchantDomain: domain,
|
|
10
|
+
open: open,
|
|
11
|
+
postURL: postURL,
|
|
12
|
+
publicKey: publicKey,
|
|
13
|
+
scope: scope,
|
|
14
|
+
leadId: lead,
|
|
15
|
+
showBoard: board,
|
|
16
|
+
boardMaturity: boardMaturity,
|
|
17
|
+
verifyToken: verifyToken,
|
|
18
|
+
onFlowCompleted: function (res) {
|
|
19
|
+
onSuccess && onSuccess(res);
|
|
20
|
+
},
|
|
21
|
+
onError: function (err) {
|
|
22
|
+
onError && onError(err);
|
|
23
|
+
},
|
|
24
|
+
onReady: function () {
|
|
25
|
+
onReady && onReady();
|
|
26
|
+
},
|
|
27
|
+
onBoardButtonClick: function (data) {
|
|
28
|
+
onBoardButtonClick && onBoardButtonClick(data);
|
|
29
|
+
},
|
|
30
|
+
onCreated: function (res) {
|
|
31
|
+
onCreated && onCreated(res);
|
|
32
|
+
},
|
|
33
|
+
onClose: function () {
|
|
34
|
+
onClose && onClose();
|
|
35
|
+
},
|
|
36
|
+
onBoardCompleted: function () {
|
|
37
|
+
onBoardCompleted && onBoardCompleted();
|
|
38
|
+
},
|
|
39
|
+
onStepCompleted: function (name, info) { },
|
|
40
|
+
onStepStarted: function (name) { }
|
|
41
|
+
};
|
|
42
|
+
};
|
package/build/utils/html.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const findOrCreateElementAndInject: (id: string) => HTMLElement;
|
package/build/utils/html.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export var findOrCreateElementAndInject = function (id) {
|
|
2
|
+
var elementExist = document.getElementById(id);
|
|
3
|
+
if (elementExist)
|
|
4
|
+
return elementExist;
|
|
5
|
+
var element = document.createElement('div');
|
|
6
|
+
element.setAttribute('id', id || 'tap-connect-sdk-lib');
|
|
7
|
+
document.body.prepend(element);
|
|
8
|
+
return element;
|
|
9
|
+
};
|
package/build/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './html';
|
|
2
|
-
export * from './validation';
|
|
3
|
-
export * from './config';
|
|
1
|
+
export * from './html';
|
|
2
|
+
export * from './validation';
|
|
3
|
+
export * from './config';
|
package/build/utils/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './html';
|
|
2
|
-
export * from './validation';
|
|
3
|
-
export * from './config';
|
|
1
|
+
export * from './html';
|
|
2
|
+
export * from './validation';
|
|
3
|
+
export * from './config';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ConnectProps } from '../@types';
|
|
2
|
-
export declare const validateConnectProps: (props: ConnectProps) => void;
|
|
1
|
+
import { ConnectProps } from '../@types';
|
|
2
|
+
export declare const validateConnectProps: (props: ConnectProps) => void;
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { Language } from '../constants';
|
|
2
|
-
export var validateConnectProps = function (props) {
|
|
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
|
-
if (!publicKey) {
|
|
5
|
-
throw new Error('publicKey is required');
|
|
6
|
-
}
|
|
7
|
-
if (!country) {
|
|
8
|
-
throw new Error('country is required');
|
|
9
|
-
}
|
|
10
|
-
if (!language) {
|
|
11
|
-
throw new Error('language is required');
|
|
12
|
-
}
|
|
13
|
-
if (![Language.AR, Language.EN].includes(language)) {
|
|
14
|
-
throw new Error('You can only use AR or EN for language');
|
|
15
|
-
}
|
|
16
|
-
if (!scope) {
|
|
17
|
-
throw new Error('scope is required');
|
|
18
|
-
}
|
|
19
|
-
if (!domain) {
|
|
20
|
-
throw new Error('domain is required');
|
|
21
|
-
}
|
|
22
|
-
if (typeof open !== 'boolean') {
|
|
23
|
-
throw new Error('open is required, and must be a boolean');
|
|
24
|
-
}
|
|
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
|
-
}
|
|
31
|
-
if (typeof lead !== 'undefined' && typeof lead !== 'string') {
|
|
32
|
-
throw new Error('lead must be a string');
|
|
33
|
-
}
|
|
34
|
-
if (typeof postURL !== 'undefined' && typeof postURL !== 'string') {
|
|
35
|
-
throw new Error('postURL must be a string');
|
|
36
|
-
}
|
|
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') {
|
|
44
|
-
throw new Error('onError must be a function');
|
|
45
|
-
}
|
|
46
|
-
if (typeof onReady !== 'undefined' && typeof onReady !== 'function') {
|
|
47
|
-
throw new Error('onReady must be a function');
|
|
48
|
-
}
|
|
49
|
-
if (typeof onSuccess !== 'undefined' && typeof onSuccess !== 'function') {
|
|
50
|
-
throw new Error('onSuccess must be a function');
|
|
51
|
-
}
|
|
52
|
-
};
|
|
1
|
+
import { Language } from '../constants';
|
|
2
|
+
export var validateConnectProps = function (props) {
|
|
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
|
+
if (!publicKey) {
|
|
5
|
+
throw new Error('publicKey is required');
|
|
6
|
+
}
|
|
7
|
+
if (!country) {
|
|
8
|
+
throw new Error('country is required');
|
|
9
|
+
}
|
|
10
|
+
if (!language) {
|
|
11
|
+
throw new Error('language is required');
|
|
12
|
+
}
|
|
13
|
+
if (![Language.AR, Language.EN].includes(language)) {
|
|
14
|
+
throw new Error('You can only use AR or EN for language');
|
|
15
|
+
}
|
|
16
|
+
if (!scope) {
|
|
17
|
+
throw new Error('scope is required');
|
|
18
|
+
}
|
|
19
|
+
if (!domain) {
|
|
20
|
+
throw new Error('domain is required');
|
|
21
|
+
}
|
|
22
|
+
if (typeof open !== 'boolean') {
|
|
23
|
+
throw new Error('open is required, and must be a boolean');
|
|
24
|
+
}
|
|
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
|
+
}
|
|
31
|
+
if (typeof lead !== 'undefined' && typeof lead !== 'string') {
|
|
32
|
+
throw new Error('lead must be a string');
|
|
33
|
+
}
|
|
34
|
+
if (typeof postURL !== 'undefined' && typeof postURL !== 'string') {
|
|
35
|
+
throw new Error('postURL must be a string');
|
|
36
|
+
}
|
|
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') {
|
|
44
|
+
throw new Error('onError must be a function');
|
|
45
|
+
}
|
|
46
|
+
if (typeof onReady !== 'undefined' && typeof onReady !== 'function') {
|
|
47
|
+
throw new Error('onReady must be a function');
|
|
48
|
+
}
|
|
49
|
+
if (typeof onSuccess !== 'undefined' && typeof onSuccess !== 'function') {
|
|
50
|
+
throw new Error('onSuccess must be a function');
|
|
51
|
+
}
|
|
52
|
+
};
|