@tap-payments/connect 2.5.14-test → 2.6.3-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 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-2.5.14-test/main.js"></script>
88
+ <script src="https://tap-sdks.b-cdn.net/connect/build-2.6.3-test/main.js"></script>
85
89
  </head>
86
90
  <body>
87
91
  <div id="root"></div>
@@ -97,13 +101,15 @@ 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,
103
108
  boardMaturity: false,
104
- mode: "popup",
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` |
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 |
@@ -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;
@@ -30,6 +32,8 @@ export interface OriginalConnectProps {
30
32
  scope: string;
31
33
  leadId?: string;
32
34
  postURL?: string;
35
+ redirectUrl?: string;
36
+ data?: Array<string>;
33
37
  showBoard?: boolean;
34
38
  boardMaturity?: boolean;
35
39
  verifyToken?: string;
@@ -60,6 +64,8 @@ export type TokenParams = {
60
64
  post?: {
61
65
  url: string;
62
66
  };
67
+ redirect_url?: string;
68
+ data?: Array<string>;
63
69
  };
64
70
  export interface TokenResponseParams extends TokenParams {
65
71
  id: string;
@@ -1,4 +1,4 @@
1
- export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.5.11-test/";
1
+ export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.6.3-test/";
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.5.11-test/';
1
+ export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.6.3-test/';
2
2
  export var Maturity = {
3
3
  FULL: 'full',
4
4
  EXPRESS: 'express'
@@ -87,12 +87,38 @@ 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;
91
- return __generator(this, function (_c) {
92
- switch (_c.label) {
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, payload, _c, data, publicKeyValue, _d, token, redirect, baseUrl, url_1, countryCode, url, el, root, unmount;
91
+ return __generator(this, function (_e) {
92
+ switch (_e.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;
95
- if (!(mode === 'page')) return [3, 2];
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
+ if (!(scope === 'auth')) return [3, 2];
96
+ payload = __assign(__assign(__assign({ board: board, public_key: publicKey, board_maturity: boardMaturity, domain: domain, language: language, country: country, scope: scope, lead_id: lead, maturity: false, notification: {
97
+ email: false,
98
+ sms: false
99
+ } }, (postURL && {
100
+ post: {
101
+ url: postURL
102
+ }
103
+ })), (redirectUrl && {
104
+ platform_redirect_url: redirectUrl
105
+ })), (AuthData && {
106
+ data: AuthData
107
+ }));
108
+ return [4, generateConfigToken(payload)];
109
+ case 1:
110
+ _a = _e.sent(), data = _a.data, publicKeyValue = _a.publicKey;
111
+ if (data === null || data === void 0 ? void 0 : data.error) {
112
+ onError === null || onError === void 0 ? void 0 : onError(data.error);
113
+ return [2];
114
+ }
115
+ _b = data || {}, token = _b.token, redirect = _b.redirect;
116
+ baseUrl = getRedirectBaseUrl(publicKeyValue || '');
117
+ url = (redirect === null || redirect === void 0 ? void 0 : redirect.url) || "".concat(baseUrl, "?config_token=").concat(token);
118
+ window.location.href = url;
119
+ return [2];
120
+ case 2:
121
+ if (!(mode === 'page')) return [3, 4];
96
122
  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
123
  email: true,
98
124
  sms: true
@@ -102,19 +128,16 @@ export var renderTapConnect = function (props, elementId) { return __awaiter(voi
102
128
  }
103
129
  }));
104
130
  return [4, generateConfigToken(payload)];
105
- case 1:
106
- _a = _c.sent(), data = _a.data, publicKeyValue = _a.publicKey;
131
+ case 3:
132
+ _c = _e.sent(), data = _c.data, publicKeyValue = _c.publicKey;
107
133
  if (data === null || data === void 0 ? void 0 : data.error) {
108
134
  onError === null || onError === void 0 ? void 0 : onError(data.error);
109
135
  return [2];
110
136
  }
111
- _b = data || {}, token = _b.token, redirect = _b.redirect;
137
+ _d = data || {}, token = _d.token, redirect = _d.redirect;
112
138
  baseUrl = getRedirectBaseUrl(publicKeyValue || '');
113
139
  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);
140
+ url_1 = (redirect === null || redirect === void 0 ? void 0 : redirect.url) || "".concat(baseUrl, "?config_token=").concat(token);
118
141
  window.location.href = url_1;
119
142
  return [2];
120
143
  }
@@ -122,7 +145,7 @@ export var renderTapConnect = function (props, elementId) { return __awaiter(voi
122
145
  url = (redirect === null || redirect === void 0 ? void 0 : redirect.url) || "".concat(baseUrl).concat(countryCode, "?config_token=").concat(token);
123
146
  window.location.href = url;
124
147
  return [2];
125
- case 2:
148
+ case 4:
126
149
  if (tapConnectInstance) {
127
150
  return [2, tapConnectInstance];
128
151
  }
@@ -1,6 +1,6 @@
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 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
4
  if (!publicKey) {
5
5
  throw new Error('publicKey is required');
6
6
  }
@@ -16,6 +16,10 @@ export var validateConnectProps = function (props) {
16
16
  if (!scope) {
17
17
  throw new Error('scope is required');
18
18
  }
19
+ if (scope === 'auth') {
20
+ if (!redirectUrl)
21
+ throw new Error('redirectUrl is required');
22
+ }
19
23
  if (!domain) {
20
24
  throw new Error('domain is required');
21
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/connect",
3
- "version": "2.5.14-test",
3
+ "version": "2.6.3-test",
4
4
  "description": "Tap Connect",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",