@tap-payments/auth-jsconnect 2.8.40-test → 2.8.41-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.
@@ -469,6 +469,12 @@ export var PASSWORD_SCREENS_NAVIGATION = [
469
469
  prev: 'PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
470
470
  order: 1
471
471
  },
472
+ {
473
+ name: 'PASSWORD_LOADING_DATA_STEP',
474
+ next: 'PASSWORD_CREATE_PASSWORD_STEP',
475
+ prev: 'PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
476
+ order: 1
477
+ },
472
478
  {
473
479
  name: 'PASSWORD_CREATE_PASSWORD_STEP',
474
480
  next: ['PASSWORD_SUCCESS_STEP', 'PASSWORD_RESET_PASSWORD_OTP_STEP'],
@@ -1,9 +1,13 @@
1
1
  import { RootState } from '../../../app/store';
2
2
  import { FlowsTypes, OTPFormValues, PasswordCreateFormValues, ResponseData, SharedState } from '../../../@types';
3
+ interface verifyLeadTokenProps {
4
+ token: string;
5
+ isInternally?: boolean;
6
+ }
3
7
  export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
4
8
  data: any;
5
9
  token: string;
6
- }, string, {}>;
10
+ }, verifyLeadTokenProps, {}>;
7
11
  export declare const resendOTP: import("@reduxjs/toolkit").AsyncThunk<{
8
12
  data: any;
9
13
  }, void, {}>;
@@ -52,49 +52,55 @@ import { FlowsTypes } from '../../../@types';
52
52
  import { handleCurrentActiveScreen, handleNextScreenStep, handlePrevScreenStep, handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
53
53
  import { PASSWORD_OPERATION_TYPE, PASSWORD_STEP_NAMES } from '../../../constants';
54
54
  import { retrieveIndividualData, sleep } from '../../../utils';
55
- export var verifyLeadToken = createAsyncThunk('passwordVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
- var payload, data, _a, config, board_info_password_status, country_code, board_id, countryIso2, publicKey, data_1;
57
- var _b, _c;
58
- return __generator(this, function (_d) {
59
- switch (_d.label) {
60
- case 0:
61
- payload = {
62
- service_name: 'tap_email',
63
- verify_token: token
64
- };
65
- return [4, API.leadService.verifyLeadToken(payload)];
66
- case 1:
67
- data = (_d.sent()).data;
68
- if (((_b = data === null || data === void 0 ? void 0 : data.errors) === null || _b === void 0 ? void 0 : _b.length) || (data === null || data === void 0 ? void 0 : data.mw_error))
69
- throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
70
- _a = data || {}, config = _a.config, board_info_password_status = _a.board_info_password_status, country_code = _a.country_code, board_id = _a.board_id;
71
- countryIso2 = country_code;
72
- if (countryIso2)
73
- thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
74
- publicKey = config === null || config === void 0 ? void 0 : config.public_key;
75
- if (publicKey)
76
- thunkApi.dispatch(handlePublicKey(publicKey));
77
- if (!!country_code) return [3, 3];
78
- return [4, API.boardService.retrieveBoardDetails(board_id)];
79
- case 2:
80
- data_1 = _d.sent();
81
- if ((_c = data_1 === null || data_1 === void 0 ? void 0 : data_1.entity) === null || _c === void 0 ? void 0 : _c.country)
82
- thunkApi.dispatch(handleSetCountryByIso2(data_1.entity.country));
83
- _d.label = 3;
84
- case 3:
85
- if (data.step_name === PASSWORD_STEP_NAMES.PHONE_AUTH) {
86
- thunkApi.dispatch(handleCurrentActiveScreen('PASSWORD_VERIFY_STEP'));
87
- }
88
- else if (board_info_password_status === 'completed') {
89
- thunkApi.dispatch(handleNextScreenStep('PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
90
- }
91
- else if (data.step_name === PASSWORD_STEP_NAMES.PASSWORD_INFO) {
92
- thunkApi.dispatch(handleNextScreenStep('PASSWORD_CREATE_PASSWORD_STEP'));
93
- }
94
- return [2, { data: data, token: token }];
95
- }
55
+ export var verifyLeadToken = createAsyncThunk('passwordVerifyLeadToken', function (_a, thunkApi) {
56
+ var token = _a.token, isInternally = _a.isInternally;
57
+ return __awaiter(void 0, void 0, void 0, function () {
58
+ var payload, data, _b, config, board_info_password_status, country_code, board_id, countryIso2, publicKey, data_1;
59
+ var _c, _d;
60
+ return __generator(this, function (_e) {
61
+ switch (_e.label) {
62
+ case 0:
63
+ payload = __assign({ service_name: 'tap_email', verify_token: token }, (isInternally && {
64
+ notification: {
65
+ sms: false
66
+ }
67
+ }));
68
+ return [4, API.leadService.verifyLeadToken(payload)];
69
+ case 1:
70
+ data = (_e.sent()).data;
71
+ if (((_c = data === null || data === void 0 ? void 0 : data.errors) === null || _c === void 0 ? void 0 : _c.length) || (data === null || data === void 0 ? void 0 : data.mw_error))
72
+ throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
73
+ if (isInternally)
74
+ data.step_name = PASSWORD_STEP_NAMES.PASSWORD_INFO;
75
+ _b = data || {}, config = _b.config, board_info_password_status = _b.board_info_password_status, country_code = _b.country_code, board_id = _b.board_id;
76
+ countryIso2 = country_code;
77
+ if (countryIso2)
78
+ thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
79
+ publicKey = config === null || config === void 0 ? void 0 : config.public_key;
80
+ if (publicKey)
81
+ thunkApi.dispatch(handlePublicKey(publicKey));
82
+ if (!!country_code) return [3, 3];
83
+ return [4, API.boardService.retrieveBoardDetails(board_id)];
84
+ case 2:
85
+ data_1 = _e.sent();
86
+ if ((_d = data_1 === null || data_1 === void 0 ? void 0 : data_1.entity) === null || _d === void 0 ? void 0 : _d.country)
87
+ thunkApi.dispatch(handleSetCountryByIso2(data_1.entity.country));
88
+ _e.label = 3;
89
+ case 3:
90
+ if (data.step_name === PASSWORD_STEP_NAMES.PHONE_AUTH) {
91
+ thunkApi.dispatch(handleCurrentActiveScreen('PASSWORD_VERIFY_STEP'));
92
+ }
93
+ else if (board_info_password_status === 'completed') {
94
+ thunkApi.dispatch(handleNextScreenStep('PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
95
+ }
96
+ else if (data.step_name === PASSWORD_STEP_NAMES.PASSWORD_INFO) {
97
+ thunkApi.dispatch(handleNextScreenStep('PASSWORD_CREATE_PASSWORD_STEP'));
98
+ }
99
+ return [2, { data: data, token: token }];
100
+ }
101
+ });
96
102
  });
97
- }); });
103
+ });
98
104
  export var resendOTP = createAsyncThunk('resendOTPPassword', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
99
105
  var password, payload, data;
100
106
  return __generator(this, function (_a) {
@@ -58,6 +58,7 @@ import BusVerifyPACIScreen from './business/screens/VerifyPACI';
58
58
  import BrandVerifyScreen from './business/screens/BrandDetails';
59
59
  import PasswordVerifyPage from './password/screens/Verify';
60
60
  import CreatePasswordPage from './password/screens/CreatePassword';
61
+ import PasswordDataLoadingPage from './password/screens/PrepareDataLoading';
61
62
  import PasswordOTPPage from './password/screens/OTP';
62
63
  import SuccessPasswordPage from './password/screens/Success';
63
64
  import PasswordSuccessWithFlowPage from './password/screens/SuccessWithFlowButtons';
@@ -342,6 +343,10 @@ export var passwordFeatureScreens = [
342
343
  name: 'PASSWORD_CREATE_PASSWORD_STEP',
343
344
  element: CreatePasswordPage
344
345
  },
346
+ {
347
+ name: 'PASSWORD_LOADING_DATA_STEP',
348
+ element: PasswordDataLoadingPage
349
+ },
345
350
  {
346
351
  name: 'PASSWORD_RESET_PASSWORD_OTP_STEP',
347
352
  element: PasswordOTPPage
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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 (_) 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
+ };
12
48
  var __rest = (this && this.__rest) || function (s, e) {
13
49
  var t = {};
14
50
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -21,10 +57,10 @@ var __rest = (this && this.__rest) || function (s, e) {
21
57
  return t;
22
58
  };
23
59
  import { jsx as _jsx } from "react/jsx-runtime";
24
- import { memo, useEffect } from 'react';
60
+ import { memo } from 'react';
25
61
  import { createRoot } from 'react-dom/client';
26
- import { useAppTheme, useAppDispatch, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener } from '../../hooks';
27
- import { handleLanguage, settingsSelector } from '../../app/settings';
62
+ import { useAppTheme, useAppDispatch, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useVerifyToken } from '../../hooks';
63
+ import { settingsSelector } from '../../app/settings';
28
64
  import AnimationFlow from '../../components/AnimationFlow';
29
65
  import { store } from '../../app/store';
30
66
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
@@ -44,33 +80,40 @@ var Password = memo(function (_a) {
44
80
  useAppConfig(__assign({ navigation: PASSWORD_SCREENS_NAVIGATION, disableSettingFetching: props.mode === 'content' ? false : !!verifyToken || !!configToken }, props));
45
81
  useErrorListener(passwordError || error);
46
82
  useStepStartedListener();
47
- var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open, merchant = data.merchant, isMaturityExpress = data.isMaturityExpress;
48
- var handleVerifyToken = function () {
49
- var token = verifyToken !== null && verifyToken !== void 0 ? verifyToken : getParameterByName('token');
50
- var lang = getParameterByName('lang');
51
- var operationType = getParameterByName('operation_type');
52
- var boardId = getParameterByName('board_id') || '';
53
- var boardInfoId = getParameterByName('board_info_id') || '';
54
- var userId = getParameterByName('user_id') || '';
55
- var userType = getParameterByName('user_type') || '';
56
- if (lang)
57
- dispatch(handleLanguage(lang));
58
- if (!token)
59
- throw new Error('Auth token is not found!');
60
- sendPageView({
61
- title: 'Password'
62
- });
63
- if (operationType === PASSWORD_OPERATION_TYPE.RESET_PASSWORD) {
64
- dispatch(verifyOperationToken({ token: token, boardId: boardId, boardInfoId: boardInfoId, userId: userId, userType: userType }));
65
- return;
66
- }
67
- dispatch(verifyLeadToken(token));
83
+ var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open, merchant = data.merchant, isMaturityExpress = data.isMaturityExpress, featureScreensNavigation = data.featureScreensNavigation;
84
+ var handleVerifyToken = function (_a) {
85
+ var token = _a.token, isInternally = _a.isInternally;
86
+ return function () { return __awaiter(void 0, void 0, void 0, function () {
87
+ var operationType, boardId, boardInfoId, userId, userType;
88
+ return __generator(this, function (_a) {
89
+ operationType = getParameterByName('operation_type');
90
+ boardId = getParameterByName('board_id') || '';
91
+ boardInfoId = getParameterByName('board_info_id') || '';
92
+ userId = getParameterByName('user_id') || '';
93
+ userType = getParameterByName('user_type') || '';
94
+ sendPageView({
95
+ title: 'Password'
96
+ });
97
+ if (operationType === PASSWORD_OPERATION_TYPE.RESET_PASSWORD) {
98
+ dispatch(verifyOperationToken({ token: token, boardId: boardId, boardInfoId: boardInfoId, userId: userId, userType: userType }));
99
+ return [2];
100
+ }
101
+ dispatch(verifyLeadToken({ token: token, isInternally: isInternally }));
102
+ return [2];
103
+ });
104
+ }); };
68
105
  };
69
- useEffect(function () {
70
- if (!settingLoading && open)
71
- handleVerifyToken();
72
- }, [settingLoading]);
73
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ mode: props.mode, open: open, isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ pointerEvents: loading ? 'none' : 'auto', isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, breakpoint: 'sm', loaderColor: loaderColor, screenId: activeScreen.name, merchantInfo: merchant, isMaturityExpress: isMaturityExpress, type: props.mode === 'content' ? 'CONTENT' : undefined, dialogEdgeFormat: data.appConfig.dialogEdgeFormat }, { children: _jsx(FeatureContainer, __assign({ mode: props.mode, isMaturityExpress: isMaturityExpress }, { children: passwordFeatureScreens.map(function (_a, index) {
106
+ useVerifyToken({
107
+ verify: handleVerifyToken,
108
+ loadingScreenName: 'PASSWORD_LOADING_DATA_STEP',
109
+ navigation: featureScreensNavigation,
110
+ open: open,
111
+ mode: props.mode,
112
+ internalToken: verifyToken,
113
+ settingLoading: settingLoading
114
+ });
115
+ var initialLoading = verifyToken && props.mode !== 'content' ? settingLoading : settingLoading || customLoading;
116
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ mode: props.mode, open: open, isTapOrigin: isTapOrigin, loading: initialLoading }, { children: _jsx(AnimationFlow, __assign({ pointerEvents: loading ? 'none' : 'auto', isTapOrigin: isTapOrigin, loading: initialLoading, error: error, open: open, breakpoint: 'sm', loaderColor: loaderColor, screenId: activeScreen.name, merchantInfo: merchant, isMaturityExpress: isMaturityExpress, type: props.mode === 'content' ? 'CONTENT' : undefined, dialogEdgeFormat: data.appConfig.dialogEdgeFormat }, { children: _jsx(FeatureContainer, __assign({ mode: props.mode, isMaturityExpress: isMaturityExpress }, { children: passwordFeatureScreens.map(function (_a, index) {
74
117
  var Element = _a.element, name = _a.name;
75
118
  var isActive = activeScreen.name === name;
76
119
  return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const PrepareDataLoading: () => JSX.Element;
3
+ declare const _default: React.MemoExoticComponent<() => JSX.Element>;
4
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { useAppSelector } from '../../../../hooks';
4
+ import DataLoading from '../../../shared/DataLoading';
5
+ import { individualSelector } from '../../../app/individual/individualStore';
6
+ export var PrepareDataLoading = function () {
7
+ var error = useAppSelector(individualSelector).error;
8
+ return _jsx(DataLoading, { error: error });
9
+ };
10
+ export default memo(PrepareDataLoading);
@@ -0,0 +1,2 @@
1
+ import PrepareDataLoading from './PrepareDataLoading';
2
+ export default PrepareDataLoading;
@@ -0,0 +1,2 @@
1
+ import PrepareDataLoading from './PrepareDataLoading';
2
+ export default PrepareDataLoading;
@@ -1,5 +1,5 @@
1
1
  import { ScreenStepNavigation } from '../@types';
2
- interface VerifyLeadTokenProps {
2
+ export interface VerifyLeadTokenProps {
3
3
  token: string;
4
4
  isInternally?: boolean;
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.8.40-test",
3
+ "version": "2.8.41-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",