@tap-payments/connect 1.3.10 → 2.4.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 CHANGED
@@ -81,7 +81,7 @@ const ConnectComponent = () => {
81
81
  content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no"
82
82
  />
83
83
  <title>Auth-JsConnect</title>
84
- <script src="https://tap-sdks.b-cdn.net/connect/build-1.3.10/main.js"></script>
84
+ <script src="https://tap-sdks.b-cdn.net/connect/build-2.4.0/main.js"></script>
85
85
  </head>
86
86
  <body>
87
87
  <div id="root"></div>
@@ -13,6 +13,8 @@ export interface ConnectProps {
13
13
  boardMaturity?: boolean;
14
14
  open: boolean;
15
15
  postURL?: string;
16
+ redirectUrl?: string;
17
+ data?: Array<string>;
16
18
  onError?: (err: Error) => void;
17
19
  onReady?: () => void;
18
20
  onClose?: () => void;
@@ -22,6 +24,7 @@ export interface ConnectProps {
22
24
  }
23
25
  export interface OriginalConnectProps {
24
26
  publicKey: string;
27
+ mode: 'popup' | 'page';
25
28
  open: boolean;
26
29
  merchantDomain: string;
27
30
  language: string;
@@ -30,6 +33,8 @@ export interface OriginalConnectProps {
30
33
  scope: string;
31
34
  leadId?: string;
32
35
  postURL?: string;
36
+ redirectUrl?: string;
37
+ data?: Array<string>;
33
38
  showBoard?: boolean;
34
39
  boardMaturity?: boolean;
35
40
  verifyToken?: string;
@@ -60,6 +65,8 @@ export type TokenParams = {
60
65
  post?: {
61
66
  url: string;
62
67
  };
68
+ redirect_url?: string;
69
+ data?: Array<string>;
63
70
  };
64
71
  export interface TokenResponseParams extends TokenParams {
65
72
  id: string;
@@ -1,4 +1,4 @@
1
- export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.3.6";
1
+ export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.4.0";
2
2
  export declare const Maturity: {
3
3
  readonly FULL: "full";
4
4
  readonly EXPRESS: "express";
@@ -1,4 +1,4 @@
1
- export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.3.6';
1
+ export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.4.0';
2
2
  export var Maturity = {
3
3
  FULL: 'full',
4
4
  EXPRESS: 'express'
@@ -87,20 +87,22 @@ 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, domain, language, country, scope, lead, postURL, mature, onError, payload, _a, data, publicKeyValue, _b, token, redirect, baseUrl, leadId, showBoard, url_1, countryCode, url, el, root, unmount;
90
+ var mode, board, publicKey, boardMaturity, domain, language, country, scope, lead, postURL, mature, onError, redirectUrl, AuthData, payload, _a, data, publicKeyValue, _b, token, redirect, baseUrl, url_1, countryCode, url, el, root, unmount;
91
91
  return __generator(this, function (_c) {
92
92
  switch (_c.label) {
93
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;
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, redirectUrl = props.redirectUrl, AuthData = props.data;
95
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: {
96
+ payload = __assign({ board: board, public_key: publicKey, board_maturity: boardMaturity, domain: domain, language: language, country: country, scope: scope, lead_id: lead, maturity: scope === 'auth' ? false : mature, notification: {
97
+ email: scope !== 'auth',
98
+ sms: scope !== 'auth'
99
+ } }, (postURL && __assign(__assign({ post: {
101
100
  url: postURL
102
- }
103
- }));
101
+ } }, (redirectUrl && {
102
+ platform_redirect_url: redirectUrl
103
+ })), (AuthData && {
104
+ data: AuthData
105
+ }))));
104
106
  return [4, generateConfigToken(payload)];
105
107
  case 1:
106
108
  _a = _c.sent(), data = _a.data, publicKeyValue = _a.publicKey;
@@ -110,11 +112,8 @@ export var renderTapConnect = function (props, elementId) { return __awaiter(voi
110
112
  }
111
113
  _b = data || {}, token = _b.token, redirect = _b.redirect;
112
114
  baseUrl = getRedirectBaseUrl(publicKeyValue || '');
113
- if (!mature) {
114
- leadId = lead;
115
- showBoard = board;
116
- url_1 = (redirect === null || redirect === void 0 ? void 0 : redirect.url) ||
117
- "".concat(baseUrl, "express/?config_token=").concat(token, "leadId=").concat(leadId, "&showBoard=").concat(showBoard, "&boardMaturity=").concat(boardMaturity);
115
+ if (!mature || scope === 'auth') {
116
+ url_1 = (redirect === null || redirect === void 0 ? void 0 : redirect.url) || "".concat(baseUrl, "?config_token=").concat(token);
118
117
  window.location.href = url_1;
119
118
  return [2];
120
119
  }
@@ -9,17 +9,6 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
12
  import * as React from 'react';
24
13
  import { wrapLibConfig } from '../../utils';
25
14
  var ConnectExpress = function (props) {
@@ -64,8 +53,7 @@ var ConnectExpress = function (props) {
64
53
  break;
65
54
  default:
66
55
  unmountComponent();
67
- var onSuccess = props.onSuccess, rest = __rest(props, ["onSuccess"]);
68
- var configAttrs = wrapLibConfig(__assign(__assign({}, rest), { verifyToken: token, onBoardButtonClick: onButtonClick }));
56
+ var configAttrs = wrapLibConfig(__assign(__assign({}, props), { verifyToken: token, onBoardButtonClick: onButtonClick }));
69
57
  var unmountExpress = renderConnectExpressLib(configAttrs, elementId).unmount;
70
58
  unmountComponent = unmountExpress;
71
59
  break;
@@ -3,5 +3,5 @@ type ExtraProps = {
3
3
  verifyToken?: string;
4
4
  onBoardButtonClick?: (data: Record<string, string>) => void;
5
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;
6
+ export declare const wrapLibConfig: ({ publicKey, open, mode, language, country, scope, lead, postURL, onError, onReady, onSuccess, board, verifyToken, domain, onBoardButtonClick, onClose, onCreated, onBoardCompleted, boardMaturity, data, redirectUrl }: ConnectProps & ExtraProps) => OriginalConnectProps;
7
7
  export {};
@@ -1,5 +1,5 @@
1
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;
2
+ var publicKey = _a.publicKey, open = _a.open, mode = _a.mode, 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, data = _a.data, redirectUrl = _a.redirectUrl;
3
3
  return {
4
4
  appInfo: {
5
5
  name: window.location.hostname || window.location.origin
@@ -8,9 +8,12 @@ export var wrapLibConfig = function (_a) {
8
8
  language: language,
9
9
  merchantDomain: domain,
10
10
  open: open,
11
+ mode: mode,
11
12
  postURL: postURL,
12
13
  publicKey: publicKey,
13
14
  scope: scope,
15
+ data: data,
16
+ redirectUrl: redirectUrl,
14
17
  leadId: lead,
15
18
  showBoard: board,
16
19
  boardMaturity: boardMaturity,
@@ -1,6 +1,12 @@
1
1
  import { Language } from '../constants';
2
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;
3
+ var mode = props.mode, 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, redirectUrl = props.redirectUrl;
4
+ if (!mode) {
5
+ throw new Error('mode is required');
6
+ }
7
+ if (!['page', 'popup'].includes(mode)) {
8
+ throw new Error('you can only use page or popup for mode');
9
+ }
4
10
  if (!publicKey) {
5
11
  throw new Error('publicKey is required');
6
12
  }
@@ -11,11 +17,14 @@ export var validateConnectProps = function (props) {
11
17
  throw new Error('language is required');
12
18
  }
13
19
  if (![Language.AR, Language.EN].includes(language)) {
14
- throw new Error('You can only use AR or EN for language');
20
+ throw new Error('you can only use AR or EN for language');
15
21
  }
16
22
  if (!scope) {
17
23
  throw new Error('scope is required');
18
24
  }
25
+ if (scope === 'auth' && mode === 'page' && !redirectUrl) {
26
+ throw new Error('redirectUrl is required');
27
+ }
19
28
  if (!domain) {
20
29
  throw new Error('domain is required');
21
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/connect",
3
- "version": "1.3.10",
3
+ "version": "2.4.0",
4
4
  "description": "Tap Connect",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",