@tap-payments/connect 1.3.11 → 2.4.3

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
@@ -40,6 +40,8 @@ const ConnectComponent = () => {
40
40
  country={'SA'}
41
41
  // required (the scope of the merchant)
42
42
  scope={'merchant'}
43
+ // merchant data array `ex: [operator]`
44
+ data={[]}
43
45
  // optional (Lead Id can be passed in case of you already created a lead using our API )
44
46
  lead={'led_xxxxxxxxxxxxxxxxxxxxxx'}
45
47
  // required (Decide the mode of connect `normal` or `express`)
@@ -54,6 +56,8 @@ const ConnectComponent = () => {
54
56
  open={true}
55
57
  // optional (The POST Method URL used to push te data from our server to the merchant server)
56
58
  postURL={'https://api.example.com/post'}
59
+ // This redirect url after verify authentication go to merchant website
60
+ redirectUrl={''}
57
61
  //optional (Callback function to handle the ready state of the TapConnect )
58
62
  onReady={() => console.log('onReady')}
59
63
  // optional (Callback function runs after creating an account)
@@ -81,7 +85,7 @@ const ConnectComponent = () => {
81
85
  content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no"
82
86
  />
83
87
  <title>Auth-JsConnect</title>
84
- <script src="https://tap-sdks.b-cdn.net/connect/build-1.3.11/main.js"></script>
88
+ <script src="https://tap-sdks.b-cdn.net/connect/build-2.4.3/main.js"></script>
85
89
  </head>
86
90
  <body>
87
91
  <div id="root"></div>
@@ -97,6 +101,7 @@ const ConnectComponent = () => {
97
101
  domain: 'https://example.com',
98
102
  country: 'SA',
99
103
  scope: 'merchant',
104
+ data: [],
100
105
  lead: 'led_xxxxxxxxxxxxxxxxxxxxxx',
101
106
  mature: false,
102
107
  board: true,
@@ -104,6 +109,7 @@ const ConnectComponent = () => {
104
109
  mode: "popup",
105
110
  open: true,
106
111
  postURL: 'https://api.example.com/post',
112
+ redirectUrl: '',
107
113
  onReady: () => console.log('onReady'),
108
114
  onCreated: (data) => console.log('onCreated', data),
109
115
  onError: (err) => console.log('onError', err),
@@ -131,25 +137,28 @@ const ConnectComponent = () => {
131
137
 
132
138
  ## Properties
133
139
 
134
- | name | type | description |
135
- | --------------------------- | ----------- | --------------------------------------------------------------------------------------------- |
136
- | publicKey `required` | `string` | Public key of the merchant account provided by Tap Payments |
137
- | domain `required` | `string` | Domain of the merchant |
138
- | language `required` | `Languages` | language flag to control the language of the connect element and only accept [ar,en] |
139
- | country `required` | `string` | Country ISO2 of the merchant |
140
- | scope `required` | `string` | the scope of the merchant |
141
- | lead `optional` | `string` | Lead Id can be passed in case of you already created a lead using our API |
142
- | mode `required` | `string` | Decide to show connect as a `popup` or `page` to our connect domain. Default value is `popup` |
143
- | mature `required` | `boolean` | Decide the mode of connect `normal` or `express` |
144
- | board `optional` | `string` | Show/Hide board screens |
145
- | open `required` | `boolean` | Open/Close the connect library |
146
- | boardMaturity `optional` | `boolean` | Decide the board maturity |
147
- | postURL `optional` | `string` | The POST Method URL used to push te data from our server to the merchant server and |
148
- | | | it's required only if `mature` is `false` |
149
- | onReady `optional` | `function` | Callback function to handle the ready state of the `TapConnect` |
150
- | onCreated `optional` | `function` | Callback function to called the the account created successfully |
151
- | | | it calls only if `mature` is `false` |
152
- | onSuccess `optional` | `function` | Callback function to handle the success response, it will run after the user finish the flow |
153
- | onError `optional` | `function` | Callback function to handle the error response, it will run if the user face any error |
154
- | onClose `optional` | `function` | Callback function to called when `TapConnect` get close |
155
- | onBoardCompleted `optional` | `function` | Callback function to called when you complete all flows |
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` to our connect domain. Default value is `popup` |
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
+ | boardMaturity `optional` | `boolean` | Decide the board maturity |
154
+ | postURL `optional` | `string` | The POST Method URL used to push te data from our server to the merchant server and |
155
+ | | | it's required only if `mature` is `false` |
156
+ | redirectUrl `optional` | `string` | This redirect url after verify authentication go to merchant website |
157
+ | | | It is `required` if scope is `auth` and mode is `page` |
158
+ | onReady `optional` | `function` | Callback function to handle the ready state of the `TapConnect` |
159
+ | onCreated `optional` | `function` | Callback function to called the the account created successfully |
160
+ | | | it calls only if `mature` is `false` |
161
+ | onSuccess `optional` | `function` | Callback function to handle the success response, it will run after the user finish the flow |
162
+ | onError `optional` | `function` | Callback function to handle the error response, it will run if the user face any error |
163
+ | onClose `optional` | `function` | Callback function to called when `TapConnect` get close |
164
+ | onBoardCompleted `optional` | `function` | Callback function to called when you complete all flows |
@@ -8,11 +8,13 @@ export interface ConnectProps {
8
8
  scope: string;
9
9
  lead?: string;
10
10
  mature: boolean;
11
- mode: 'popup' | 'page';
11
+ mode?: 'popup' | 'page';
12
12
  board?: boolean;
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.7";
1
+ export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.4.3";
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.7';
1
+ export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.4.3';
2
2
  export var Maturity = {
3
3
  FULL: 'full',
4
4
  EXPRESS: 'express'
@@ -87,20 +87,23 @@ 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
+ props.mode = props.mode || 'popup';
95
+ 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
96
  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: {
97
+ 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: {
98
+ email: scope !== 'auth',
99
+ sms: scope !== 'auth'
100
+ } }, (postURL && __assign(__assign({ post: {
101
101
  url: postURL
102
- }
103
- }));
102
+ } }, (redirectUrl && {
103
+ platform_redirect_url: redirectUrl
104
+ })), (AuthData && {
105
+ data: AuthData
106
+ }))));
104
107
  return [4, generateConfigToken(payload)];
105
108
  case 1:
106
109
  _a = _c.sent(), data = _a.data, publicKeyValue = _a.publicKey;
@@ -110,11 +113,8 @@ export var renderTapConnect = function (props, elementId) { return __awaiter(voi
110
113
  }
111
114
  _b = data || {}, token = _b.token, redirect = _b.redirect;
112
115
  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);
116
+ if (!mature || scope === 'auth') {
117
+ url_1 = (redirect === null || redirect === void 0 ? void 0 : redirect.url) || "".concat(baseUrl, "?config_token=").concat(token);
118
118
  window.location.href = url_1;
119
119
  return [2];
120
120
  }
@@ -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.11",
3
+ "version": "2.4.3",
4
4
  "description": "Tap Connect",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",