@tap-payments/connect 2.6.3-test → 2.6.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.
Files changed (37) hide show
  1. package/README.md +37 -31
  2. package/build/@types/config.d.ts +58 -0
  3. package/build/@types/config.js +1 -0
  4. package/build/@types/index.d.ts +10 -21
  5. package/build/api/index.js +14 -26
  6. package/build/constants/index.d.ts +5 -2
  7. package/build/constants/index.js +5 -2
  8. package/build/features/Connect/Connect.d.ts +1 -1
  9. package/build/features/Connect/Connect.js +28 -41
  10. package/build/features/Connect/ConnectAuth.d.ts +7 -0
  11. package/build/features/Connect/ConnectAuth.js +115 -0
  12. package/build/features/Connect/ConnectBank.d.ts +12 -0
  13. package/build/features/Connect/ConnectBank.js +118 -0
  14. package/build/features/Connect/ConnectBoard.d.ts +10 -0
  15. package/build/features/Connect/ConnectBoard.js +117 -0
  16. package/build/features/Connect/ConnectBrand.d.ts +12 -0
  17. package/build/features/Connect/ConnectBrand.js +118 -0
  18. package/build/features/Connect/ConnectEntity.d.ts +12 -0
  19. package/build/features/Connect/ConnectEntity.js +118 -0
  20. package/build/features/Connect/ConnectExpress.js +1 -13
  21. package/build/features/Connect/ConnectIndividual.d.ts +12 -0
  22. package/build/features/Connect/ConnectIndividual.js +118 -0
  23. package/build/features/Connect/ConnectPassword.d.ts +12 -0
  24. package/build/features/Connect/ConnectPassword.js +118 -0
  25. package/build/features/Connect/ConnectTax.d.ts +12 -0
  26. package/build/features/Connect/ConnectTax.js +118 -0
  27. package/build/features/Connect/index.d.ts +10 -2
  28. package/build/features/Connect/index.js +9 -1
  29. package/build/index.d.ts +3 -3
  30. package/build/index.js +10 -3
  31. package/build/utils/common.d.ts +2 -2
  32. package/build/utils/common.js +3 -3
  33. package/build/utils/config.d.ts +1 -1
  34. package/build/utils/config.js +5 -1
  35. package/build/utils/validation.d.ts +6 -0
  36. package/build/utils/validation.js +142 -8
  37. package/package.json +1 -1
package/README.md CHANGED
@@ -40,8 +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
+ // merchant data array `ex: [operator]`
44
+ data={[]}
45
45
  // optional (Lead Id can be passed in case of you already created a lead using our API )
46
46
  lead={'led_xxxxxxxxxxxxxxxxxxxxxx'}
47
47
  // required (Decide the mode of connect `normal` or `express`)
@@ -56,8 +56,8 @@ const ConnectComponent = () => {
56
56
  open={true}
57
57
  // optional (The POST Method URL used to push te data from our server to the merchant server)
58
58
  postURL={'https://api.example.com/post'}
59
- // This redirect url after verify authentication go to merchant website
60
- redirectUrl={''}
59
+ // This redirect url after verify authentication go to merchant website
60
+ redirectUrl={''}
61
61
  //optional (Callback function to handle the ready state of the TapConnect )
62
62
  onReady={() => console.log('onReady')}
63
63
  // optional (Callback function runs after creating an account)
@@ -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.3-test/main.js"></script>
88
+ <script src="https://tap-sdks.b-cdn.net/connect/build-2.6.3/main.js"></script>
89
89
  </head>
90
90
  <body>
91
91
  <div id="root"></div>
@@ -106,7 +106,7 @@ const ConnectComponent = () => {
106
106
  mature: false,
107
107
  board: true,
108
108
  boardMaturity: false,
109
- mode: "popup",
109
+ mode: "popup",
110
110
  open: true,
111
111
  postURL: 'https://api.example.com/post',
112
112
  redirectUrl: '',
@@ -137,28 +137,34 @@ const ConnectComponent = () => {
137
137
 
138
138
  ## Properties
139
139
 
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 |
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` or `content` to our connect domain. Default value is `popup`. `content` mode only used for board kit |
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
+ | features.dialogStartTransition `optional` | `left or right or up or down` | Used to handle **auth** slide animation direction when open popup for auth kit |
154
+ | features.dialogEndTransition `optional` | `left or right or up or down` | Used to handle **auth** slide animation direction when close popup for auth kit |
155
+ | features `object` | `all values true` | Used to show or hide some fields (poweredBy, merchantLogo - Used to hide the merchant logo and it can be used only for auth kit, switchLanguage, overlay - Used to disable the background color and it can be used only for auth kit, loaderOverlay - Used to disable the loader background color and it can be used only for auth kit, tapTextLogo, closeButton - Used enable to close dialog, disableNafath - Used to hide nafath login button in **auth** kit, disablePaci - Used to hide paci login button in **auth** kit) |
156
+ | loaderColor `optional` | `string` | Used to change loader color and it can be used only for board kit |
157
+ | boardMaturity `optional` | `boolean` | Decide the board maturity |
158
+ | settingData `optional` | `boolean` | This is to get settings information. It is used board kit and other kits open from board |
159
+ | postURL `optional` | `string` | The POST Method URL used to push te data from our server to the merchant server and |
160
+ | | | it's required only if `mature` is `false` |
161
+ | redirectUrl `optional` | `string` | This redirect url after verify authentication go to merchant website |
162
+ | | | It is `required` if scope is `auth` and mode is `page` |
163
+ | onReady `optional` | `function` | Callback function to handle the ready state of the `TapConnect` |
164
+ | onCreated `optional` | `function` | Callback function to called the the account created successfully |
165
+ | | | it calls only if `mature` is `false` |
166
+ | onSuccess `optional` | `function` | Callback function to handle the success response, it will run after the user finish the flow |
167
+ | onError `optional` | `function` | Callback function to handle the error response, it will run if the user face any error |
168
+ | onClose `optional` | `function` | Callback function to called when `TapConnect` get close |
169
+ | onBoardCompleted `optional` | `function` | Callback function to called when you complete all flows |
170
+ | onSettingFetched `optional` | `function` | Callback function to called after fetch settings information. It is used board kit and other kits open from board |
@@ -0,0 +1,58 @@
1
+ export interface ConfigInfo {
2
+ operator: Operator;
3
+ scope: string;
4
+ data?: string[];
5
+ lead?: Lead;
6
+ board?: Board;
7
+ interface?: Interface;
8
+ redirect?: Redirect;
9
+ post?: Redirect;
10
+ connect?: Redirect;
11
+ platforms?: string[];
12
+ payment_provider?: PaymentProvider;
13
+ }
14
+ export interface ConnectFeatures {
15
+ poweredBy?: boolean;
16
+ merchantLogo?: boolean;
17
+ switchLanguage?: boolean;
18
+ overlay?: boolean;
19
+ loaderOverlay?: boolean;
20
+ tapTextLogo?: boolean;
21
+ closeButton?: boolean;
22
+ dialogStartTransition?: 'left' | 'right' | 'up' | 'down';
23
+ dialogEndTransition?: 'left' | 'right' | 'up' | 'down';
24
+ disableNafath?: boolean;
25
+ disablePaci?: boolean;
26
+ }
27
+ export interface PaymentProvider {
28
+ technology_id: string;
29
+ settlement_by: string;
30
+ }
31
+ interface Redirect {
32
+ url: string;
33
+ }
34
+ interface Interface {
35
+ locale?: 'dynamic' | 'ar' | 'en';
36
+ edges?: 'straight' | 'curved';
37
+ }
38
+ interface Board {
39
+ display?: boolean;
40
+ editable?: boolean;
41
+ }
42
+ interface Lead {
43
+ id: string;
44
+ }
45
+ interface Operator {
46
+ public_key: string;
47
+ }
48
+ type RecordType = Record<string, any>;
49
+ export interface SettingAsyncData {
50
+ fingerPrint: RecordType;
51
+ locale: RecordType;
52
+ country_list: RecordType;
53
+ ip_info: RecordType;
54
+ merchant: RecordType;
55
+ operator: RecordType;
56
+ config: RecordType;
57
+ }
58
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { Language } from '../constants';
2
+ import { ConfigInfo, ConnectFeatures, SettingAsyncData } from './config';
2
3
  export interface ConnectProps {
3
4
  elementId: string;
4
5
  publicKey: string;
@@ -8,22 +9,28 @@ export interface ConnectProps {
8
9
  scope: string;
9
10
  lead?: string;
10
11
  mature: boolean;
11
- mode: 'popup' | 'page';
12
+ mode?: 'popup' | 'page' | 'content';
12
13
  board?: boolean;
13
14
  boardMaturity?: boolean;
15
+ loaderColor?: string;
16
+ boardId?: string;
14
17
  open: boolean;
15
18
  postURL?: string;
16
19
  redirectUrl?: string;
17
20
  data?: Array<string>;
21
+ settingData?: SettingAsyncData;
22
+ features?: ConnectFeatures;
18
23
  onError?: (err: Error) => void;
19
24
  onReady?: () => void;
20
25
  onClose?: () => void;
21
26
  onCreated?: (res: object) => void;
22
27
  onSuccess?: (res: object) => void;
23
28
  onBoardCompleted?: () => void;
29
+ onSettingFetched?: (data: SettingAsyncData) => void;
24
30
  }
25
31
  export interface OriginalConnectProps {
26
32
  publicKey: string;
33
+ mode?: 'popup' | 'page' | 'content';
27
34
  open: boolean;
28
35
  merchantDomain: string;
29
36
  language: string;
@@ -36,6 +43,7 @@ export interface OriginalConnectProps {
36
43
  data?: Array<string>;
37
44
  showBoard?: boolean;
38
45
  boardMaturity?: boolean;
46
+ features?: ConnectFeatures;
39
47
  verifyToken?: string;
40
48
  onFlowCompleted: (res: object, headers?: Record<string, string>) => void;
41
49
  onError: (err: any) => void;
@@ -47,26 +55,7 @@ export interface OriginalConnectProps {
47
55
  onClose?: () => void;
48
56
  onBoardCompleted?: () => void;
49
57
  }
50
- export type TokenParams = {
51
- board?: boolean;
52
- public_key: string;
53
- board_maturity?: boolean;
54
- domain: string;
55
- language: string;
56
- country: string;
57
- scope: string;
58
- lead_id?: string;
59
- maturity: boolean;
60
- notification: {
61
- email: boolean;
62
- sms: boolean;
63
- };
64
- post?: {
65
- url: string;
66
- };
67
- redirect_url?: string;
68
- data?: Array<string>;
69
- };
58
+ export type TokenParams = ConfigInfo;
70
59
  export interface TokenResponseParams extends TokenParams {
71
60
  id: string;
72
61
  contact: {
@@ -1,14 +1,3 @@
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
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -56,36 +45,35 @@ export var getFingerPrint = function () {
56
45
  });
57
46
  };
58
47
  export var generateConfigToken = function (data) { return __awaiter(void 0, void 0, void 0, function () {
59
- var visitorId, baseUrl, publicKey, res, public_key, payload, response, error_1;
60
- var _a, _b, _c;
61
- return __generator(this, function (_d) {
62
- switch (_d.label) {
48
+ var visitorId, publicKey, baseUrl, res, public_key, response, error_1;
49
+ var _a;
50
+ return __generator(this, function (_b) {
51
+ switch (_b.label) {
63
52
  case 0:
64
- _d.trys.push([0, 4, , 5]);
53
+ _b.trys.push([0, 4, , 5]);
65
54
  return [4, getFingerPrint()];
66
55
  case 1:
67
- visitorId = (_d.sent()).visitorId;
68
- baseUrl = getBaseUrl(data.public_key);
69
- publicKey = data.public_key;
70
- return [4, axios.post("".concat(baseUrl, "init"), data, {
56
+ visitorId = (_b.sent()).visitorId;
57
+ publicKey = data.operator.public_key;
58
+ baseUrl = getBaseUrl(publicKey);
59
+ return [4, axios.post("".concat(baseUrl, "init"), {}, {
71
60
  headers: {
72
61
  'Content-Type': 'application/json',
73
62
  'Access-Control-Allow-Headers': true,
74
- authorization: data.public_key,
63
+ authorization: publicKey,
75
64
  bi: visitorId || '',
76
65
  cu: window.location.href,
77
66
  mdn: window.location.origin
78
67
  }
79
68
  })];
80
69
  case 2:
81
- res = _d.sent();
70
+ res = _b.sent();
82
71
  public_key = (((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.config) || {}).public_key;
83
72
  if (public_key) {
84
73
  publicKey = public_key;
85
74
  baseUrl = getBaseUrl(public_key);
86
75
  }
87
- payload = __assign(__assign({}, data), (((_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.config) && ((_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.config)));
88
- return [4, axios.post("".concat(baseUrl, "connect"), payload, {
76
+ return [4, axios.post("".concat(baseUrl, "v3/connect"), data, {
89
77
  headers: {
90
78
  'Content-Type': 'application/json',
91
79
  'Access-Control-Allow-Headers': true,
@@ -96,10 +84,10 @@ export var generateConfigToken = function (data) { return __awaiter(void 0, void
96
84
  }
97
85
  })];
98
86
  case 3:
99
- response = _d.sent();
87
+ response = _b.sent();
100
88
  return [2, { data: response.data, publicKey: publicKey }];
101
89
  case 4:
102
- error_1 = _d.sent();
90
+ error_1 = _b.sent();
103
91
  return [2, { error: error_1 }];
104
92
  case 5: return [2];
105
93
  }
@@ -1,4 +1,4 @@
1
- export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.6.3-test/";
1
+ export declare const CDN_LIBRARY_BASE_URL = "https://auth-jsconnect.b-cdn.net/build-2.6.3";
2
2
  export declare const Maturity: {
3
3
  readonly FULL: "full";
4
4
  readonly EXPRESS: "express";
@@ -8,7 +8,10 @@ export declare const Language: {
8
8
  readonly AR: "ar";
9
9
  };
10
10
  export declare const CONNECT_URL = "https://connect.tap.company/";
11
+ export declare const CONNECT_BETA_URL = "https://connect.beta.tap.company/";
12
+ export declare const CONNECT_SANDBOX_URL = "https://connect.sandbox.tap.company/";
11
13
  export declare const CONNECT_DEV_URL = "https://connect.dev.tap.company/";
12
14
  export declare const CONNECT_MW_URL = "https://connect-mw.tap.company/middleware/";
13
- export declare const CONNECT_DEV_MW_URL = "https://connect-mw.dev.tap.company/middleware/";
15
+ export declare const CONNECT_MW_BETA_URL = "https://connect-mw.beta.tap.company/middleware/";
14
16
  export declare const CONNECT_SANDBOX_MW_URL = "https://connect-mw.sandbox.tap.company/middleware/";
17
+ export declare const CONNECT_DEV_MW_URL = "https://connect-mw.dev.tap.company/middleware/";
@@ -1,4 +1,4 @@
1
- export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.6.3-test/';
1
+ export var CDN_LIBRARY_BASE_URL = 'https://auth-jsconnect.b-cdn.net/build-2.6.3';
2
2
  export var Maturity = {
3
3
  FULL: 'full',
4
4
  EXPRESS: 'express'
@@ -8,7 +8,10 @@ export var Language = {
8
8
  AR: 'ar'
9
9
  };
10
10
  export var CONNECT_URL = 'https://connect.tap.company/';
11
+ export var CONNECT_BETA_URL = 'https://connect.beta.tap.company/';
12
+ export var CONNECT_SANDBOX_URL = 'https://connect.sandbox.tap.company/';
11
13
  export var CONNECT_DEV_URL = 'https://connect.dev.tap.company/';
12
14
  export var CONNECT_MW_URL = 'https://connect-mw.tap.company/middleware/';
13
- export var CONNECT_DEV_MW_URL = 'https://connect-mw.dev.tap.company/middleware/';
15
+ export var CONNECT_MW_BETA_URL = 'https://connect-mw.beta.tap.company/middleware/';
14
16
  export var CONNECT_SANDBOX_MW_URL = 'https://connect-mw.sandbox.tap.company/middleware/';
17
+ export var CONNECT_DEV_MW_URL = 'https://connect-mw.dev.tap.company/middleware/';
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { ConnectProps as ConnectAttrs } from '../../@types';
3
3
  export type ConnectProps = Omit<ConnectAttrs, 'elementId'>;
4
- export declare const TapConnect: React.MemoExoticComponent<(props: ConnectAttrs) => import("react/jsx-runtime").JSX.Element>;
4
+ export declare const TapConnect: React.MemoExoticComponent<(props: ConnectAttrs) => JSX.Element>;
5
5
  export declare const renderTapConnect: (props: ConnectProps, elementId: string) => Promise<any>;
@@ -87,65 +87,52 @@ 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, 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) {
90
+ var mode, board, publicKey, boardMaturity, language, country, scope, lead, postURL, mature, onError, redirectUrl, AuthData, payload, _a, data, publicKeyValue, _b, token, connect, baseUrl, url_1, countryCode, url, el, root, unmount;
91
+ return __generator(this, function (_c) {
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, 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 && {
94
+ props.mode = props.mode || 'popup';
95
+ mode = props.mode, board = props.board, publicKey = props.publicKey, boardMaturity = props.boardMaturity, 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;
96
+ if (!(mode === 'page')) return [3, 2];
97
+ payload = __assign(__assign(__assign(__assign({ operator: {
98
+ public_key: publicKey
99
+ }, scope: scope }, (AuthData && {
106
100
  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];
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: {
123
- email: true,
124
- sms: true
125
- } }, (postURL && {
101
+ })), { lead: {
102
+ id: lead || ''
103
+ }, board: {
104
+ display: board,
105
+ editable: boardMaturity
106
+ }, interface: {
107
+ locale: language
108
+ } }), (redirectUrl && {
109
+ redirect: {
110
+ url: redirectUrl
111
+ }
112
+ })), (postURL && {
126
113
  post: {
127
114
  url: postURL
128
115
  }
129
116
  }));
130
117
  return [4, generateConfigToken(payload)];
131
- case 3:
132
- _c = _e.sent(), data = _c.data, publicKeyValue = _c.publicKey;
118
+ case 1:
119
+ _a = _c.sent(), data = _a.data, publicKeyValue = _a.publicKey;
133
120
  if (data === null || data === void 0 ? void 0 : data.error) {
134
121
  onError === null || onError === void 0 ? void 0 : onError(data.error);
135
122
  return [2];
136
123
  }
137
- _d = data || {}, token = _d.token, redirect = _d.redirect;
124
+ _b = data || {}, token = _b.token, connect = _b.connect;
138
125
  baseUrl = getRedirectBaseUrl(publicKeyValue || '');
139
- if (!mature) {
140
- url_1 = (redirect === null || redirect === void 0 ? void 0 : redirect.url) || "".concat(baseUrl, "?config_token=").concat(token);
126
+ if (!mature || scope === 'auth') {
127
+ url_1 = (connect === null || connect === void 0 ? void 0 : connect.url) || "".concat(baseUrl, "?config_token=").concat(token);
141
128
  window.location.href = url_1;
142
129
  return [2];
143
130
  }
144
131
  countryCode = country.toLowerCase();
145
- url = (redirect === null || redirect === void 0 ? void 0 : redirect.url) || "".concat(baseUrl).concat(countryCode, "?config_token=").concat(token);
132
+ url = (connect === null || connect === void 0 ? void 0 : connect.url) || "".concat(baseUrl).concat(countryCode, "?config_token=").concat(token);
146
133
  window.location.href = url;
147
134
  return [2];
148
- case 4:
135
+ case 2:
149
136
  if (tapConnectInstance) {
150
137
  return [2, tapConnectInstance];
151
138
  }
@@ -0,0 +1,7 @@
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' | 'features'>;
4
+ export declare const TapConnectAuth: React.MemoExoticComponent<(props: ConnectAuthProps & {
5
+ id?: string;
6
+ }) => JSX.Element>;
7
+ export declare const renderTapConnectAuth: (props: ConnectAuthProps, elementId: string) => Promise<any>;
@@ -0,0 +1,115 @@
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
+ var _a;
65
+ if (status !== 'ready')
66
+ return;
67
+ var renderAuthLib = window['TapAuth'].renderAuthLib;
68
+ var unmount = renderAuthLib({
69
+ open: props.open,
70
+ mode: 'popup',
71
+ scope: 'auth',
72
+ merchantDomain: props.domain,
73
+ publicKey: props.publicKey,
74
+ redirectUrl: props.redirectUrl,
75
+ data: props.data,
76
+ postURL: props.postURL,
77
+ leadId: props.lead,
78
+ appInfo: {
79
+ name: window.location.hostname || window.location.origin
80
+ },
81
+ businessCountryCode: props.country,
82
+ language: props.language,
83
+ onFlowCompleted: props.onSuccess,
84
+ onError: props.onError,
85
+ onReady: props.onReady,
86
+ onClose: props.onClose,
87
+ features: props.features
88
+ }, (_a = props.id) !== null && _a !== void 0 ? _a : 'tap-connect-auth-lib-id').unmount;
89
+ return function () {
90
+ unmount();
91
+ };
92
+ }, [status]);
93
+ if (status !== 'ready')
94
+ return null;
95
+ return _jsx("div", { id: 'tap-connect-auth-lib-id' });
96
+ };
97
+ export var TapConnectAuth = React.memo(function (props) {
98
+ validateConnectAuthProps(props);
99
+ return _jsx(ConnectAuth, __assign({}, props));
100
+ });
101
+ var tapConnectInstance = null;
102
+ export var renderTapConnectAuth = function (props, elementId) { return __awaiter(void 0, void 0, void 0, function () {
103
+ var el, root, unmount;
104
+ return __generator(this, function (_a) {
105
+ el = findOrCreateElementAndInject(elementId);
106
+ root = createRoot(el);
107
+ root.render(_jsx(TapConnectAuth, __assign({}, props)));
108
+ unmount = function () {
109
+ root.unmount();
110
+ tapConnectInstance = null;
111
+ };
112
+ tapConnectInstance = { unmount: unmount };
113
+ return [2, tapConnectInstance];
114
+ });
115
+ }); };
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { ConnectProps as ConnectAttrs } from '../../@types';
3
+ type BankProps = Pick<ConnectAttrs, 'open' | 'mode' | 'scope' | 'domain' | 'board' | 'publicKey' | 'postURL' | 'country' | 'language' | 'onSuccess' | 'onError' | 'onReady' | 'onClose' | 'loaderColor' | 'settingData' | 'onSettingFetched' | 'features'>;
4
+ export type TapBankProps = BankProps & {
5
+ verifyToken: string;
6
+ onBoardButtonClick: (data: Record<string, string>) => void;
7
+ };
8
+ export declare const TapBank: React.MemoExoticComponent<(props: TapBankProps & {
9
+ id?: string;
10
+ }) => JSX.Element>;
11
+ export declare const renderTapBank: (props: TapBankProps, elementId: string) => Promise<any>;
12
+ export {};