@tap-payments/auth-jsconnect 2.11.29-development → 2.11.31-development
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/build/constants/app.d.ts +2 -0
- package/build/constants/app.js +21 -7
- package/build/features/app/auth/authStore.d.ts +4 -0
- package/build/features/app/auth/authStore.js +98 -0
- package/build/features/app/individual/individualStore.js +6 -4
- package/build/features/auth/Auth.js +3 -2
- package/build/features/auth/screens/OTPSessionExpired/OTPInput.d.ts +3 -0
- package/build/features/auth/screens/OTPSessionExpired/OTPInput.js +58 -0
- package/build/features/auth/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
- package/build/features/auth/screens/OTPSessionExpired/OTPSessionExpired.js +85 -0
- package/build/features/auth/screens/OTPSessionExpired/index.d.ts +2 -0
- package/build/features/auth/screens/OTPSessionExpired/index.js +2 -0
- package/build/features/auth/screens/OTPSessionExpired/validation.d.ts +8 -0
- package/build/features/auth/screens/OTPSessionExpired/validation.js +4 -0
- package/build/features/featuresScreens.js +5 -0
- package/package.json +1 -1
package/build/constants/app.d.ts
CHANGED
|
@@ -124,6 +124,8 @@ export declare const AUTH_STEP_NAMES: {
|
|
|
124
124
|
VERIFY_AUTH_NID: string;
|
|
125
125
|
UPDATE_DOB_INFO: string;
|
|
126
126
|
CREATE_AUTH_PASSCODE: string;
|
|
127
|
+
CREATE_AUTH_SESSION_EXPIRED: string;
|
|
128
|
+
VERIFY_AUTH_SESSION_EXPIRED: string;
|
|
127
129
|
};
|
|
128
130
|
export declare const CONNECT_EXPRESS_STEP_NAMES: {
|
|
129
131
|
CREATE_AUTH_MOBILE: string;
|
package/build/constants/app.js
CHANGED
|
@@ -398,37 +398,43 @@ export var AUTH_SCREENS_NAVIGATION = [
|
|
|
398
398
|
'AUTH_OTP_VERIFY_SECURITY_ERROR_STEP'
|
|
399
399
|
],
|
|
400
400
|
prev: ['AUTH_MOBILE_STEP', 'AUTH_NID_STEP', 'AUTH_EMAIL_STEP', 'AUTH_PASSWORD_STEP'],
|
|
401
|
-
order: 2
|
|
401
|
+
order: 2,
|
|
402
|
+
back: 'AUTH_SWITCH_STEP'
|
|
402
403
|
},
|
|
403
404
|
{
|
|
404
405
|
name: 'AUTH_PASSCODE_STEP',
|
|
405
406
|
next: ['AUTH_OTP_STEP', 'AUTH_PREPARING_DATA_STEP', 'AUTH_MIGRATING_DATA_STEP', 'AUTH_OTP_VERIFY_SECURITY_ERROR_STEP'],
|
|
406
407
|
prev: ['AUTH_MOBILE_STEP', 'AUTH_EMAIL_STEP'],
|
|
407
|
-
order: 2
|
|
408
|
+
order: 2,
|
|
409
|
+
back: 'AUTH_SWITCH_STEP'
|
|
408
410
|
},
|
|
409
411
|
{
|
|
410
412
|
name: 'AUTH_NAFATH_VERIFY_STEP',
|
|
411
413
|
next: ['AUTH_PREPARING_DATA_STEP', 'AUTH_DOB_STEP'],
|
|
412
414
|
prev: 'AUTH_NID_STEP',
|
|
413
|
-
order: 2
|
|
415
|
+
order: 2,
|
|
416
|
+
back: 'AUTH_NID_STEP'
|
|
414
417
|
},
|
|
415
418
|
{
|
|
416
419
|
name: 'AUTH_PASSWORD_STEP',
|
|
417
420
|
next: ['AUTH_PREPARING_DATA_STEP', 'AUTH_OTP_STEP'],
|
|
418
421
|
prev: 'AUTH_EMAIL_STEP',
|
|
419
|
-
order: 2
|
|
422
|
+
order: 2,
|
|
423
|
+
back: 'AUTH_EMAIL_STEP'
|
|
420
424
|
},
|
|
421
425
|
{
|
|
422
426
|
name: 'AUTH_RESET_PASSWORD_MESSAGE_STEP',
|
|
423
427
|
next: '',
|
|
424
428
|
prev: 'AUTH_EMAIL_STEP',
|
|
425
|
-
order: 2
|
|
429
|
+
order: 2,
|
|
430
|
+
back: 'AUTH_EMAIL_STEP'
|
|
426
431
|
},
|
|
427
432
|
{
|
|
428
433
|
name: 'AUTH_VERIFY_PACI_STEP',
|
|
429
434
|
next: 'AUTH_PREPARING_DATA_STEP',
|
|
430
435
|
prev: 'AUTH_CIVIL_ID_STEP',
|
|
431
|
-
order: 2
|
|
436
|
+
order: 2,
|
|
437
|
+
back: 'AUTH_CIVIL_ID_STEP'
|
|
432
438
|
},
|
|
433
439
|
{
|
|
434
440
|
name: 'AUTH_DOB_STEP',
|
|
@@ -483,6 +489,12 @@ export var AUTH_SCREENS_NAVIGATION = [
|
|
|
483
489
|
next: '',
|
|
484
490
|
prev: '',
|
|
485
491
|
order: 5
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
name: 'AUTH_SESSION_EXPIRED_OTP_STEP',
|
|
495
|
+
next: '',
|
|
496
|
+
prev: '',
|
|
497
|
+
order: 6
|
|
486
498
|
}
|
|
487
499
|
];
|
|
488
500
|
export var KYC_SCREENS_NAVIGATION = [
|
|
@@ -1238,7 +1250,9 @@ export var AUTH_STEP_NAMES = {
|
|
|
1238
1250
|
CREATE_AUTH_NID: 'auth_create_auth_nid',
|
|
1239
1251
|
VERIFY_AUTH_NID: 'auth_verify_auth_nid',
|
|
1240
1252
|
UPDATE_DOB_INFO: 'auth_update_dob_info',
|
|
1241
|
-
CREATE_AUTH_PASSCODE: 'auth_create_auth_passcode'
|
|
1253
|
+
CREATE_AUTH_PASSCODE: 'auth_create_auth_passcode',
|
|
1254
|
+
CREATE_AUTH_SESSION_EXPIRED: 'auth_create_auth_session_expired',
|
|
1255
|
+
VERIFY_AUTH_SESSION_EXPIRED: 'auth_verify_auth_session_expired'
|
|
1242
1256
|
};
|
|
1243
1257
|
export var CONNECT_EXPRESS_STEP_NAMES = {
|
|
1244
1258
|
CREATE_AUTH_MOBILE: 'connect_express_create_auth_mobile',
|
|
@@ -22,6 +22,10 @@ export declare const resendMobileAuthOTP: import("@reduxjs/toolkit").AsyncThunk<
|
|
|
22
22
|
formData: MobileFormValues;
|
|
23
23
|
}, MobileFormValues, {}>;
|
|
24
24
|
export declare const verifyMobileOtp: import("@reduxjs/toolkit").AsyncThunk<any, OTPFormValues, {}>;
|
|
25
|
+
export declare const createAuthSessionExpired: import("@reduxjs/toolkit").AsyncThunk<{
|
|
26
|
+
response: any;
|
|
27
|
+
}, boolean, {}>;
|
|
28
|
+
export declare const verifySessionExpiredOtp: import("@reduxjs/toolkit").AsyncThunk<any, OTPFormValues, {}>;
|
|
25
29
|
export declare const verifyPasscode: import("@reduxjs/toolkit").AsyncThunk<any, PasscodeFormValues, {}>;
|
|
26
30
|
interface CreateEmailAuthParams extends AuthEmailFormValues {
|
|
27
31
|
skipPasscode?: boolean;
|
|
@@ -222,6 +222,75 @@ export var verifyMobileOtp = createAsyncThunk('auth/verifyMobileOtp', function (
|
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
224
|
}); });
|
|
225
|
+
export var createAuthSessionExpired = createAsyncThunk('auth/createAuthSessionExpired', function (redirect, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
226
|
+
var _a, settings, auth, requestBody, data;
|
|
227
|
+
var _b, _c;
|
|
228
|
+
return __generator(this, function (_d) {
|
|
229
|
+
switch (_d.label) {
|
|
230
|
+
case 0:
|
|
231
|
+
_a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
|
|
232
|
+
requestBody = {
|
|
233
|
+
country: settings.data.businessCountry.iso2,
|
|
234
|
+
scope: settings.data.appConfig.scope,
|
|
235
|
+
lang: settings.data.language,
|
|
236
|
+
lead_id: auth.data.leadId,
|
|
237
|
+
sign_in: false,
|
|
238
|
+
login: true,
|
|
239
|
+
is_lead: true,
|
|
240
|
+
step_name: AUTH_STEP_NAMES.CREATE_AUTH_SESSION_EXPIRED,
|
|
241
|
+
encryption_contract: []
|
|
242
|
+
};
|
|
243
|
+
return [4, API.authService.createAuth(requestBody)];
|
|
244
|
+
case 1:
|
|
245
|
+
data = _d.sent();
|
|
246
|
+
if (redirect)
|
|
247
|
+
thunkApi.dispatch(handleCurrentActiveScreen('AUTH_SESSION_EXPIRED_OTP_STEP'));
|
|
248
|
+
(_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody);
|
|
249
|
+
return [2, { response: data }];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}); });
|
|
253
|
+
export var verifySessionExpiredOtp = createAsyncThunk('auth/verifySessionExpiredOtp', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
254
|
+
var _a, settings, auth, session, _b, responseData, leadId, _c, auth_token, device_token, service_name, auth_type, sign_in, payload, data;
|
|
255
|
+
var _d, _e, _f;
|
|
256
|
+
return __generator(this, function (_g) {
|
|
257
|
+
switch (_g.label) {
|
|
258
|
+
case 0:
|
|
259
|
+
_a = thunkApi.getState(), settings = _a.settings, auth = _a.auth, session = _a.session;
|
|
260
|
+
_b = auth.data || {}, responseData = _b.responseData, leadId = _b.leadId;
|
|
261
|
+
_c = (_d = responseData === null || responseData === void 0 ? void 0 : responseData.authResponse) !== null && _d !== void 0 ? _d : {}, auth_token = _c.auth_token, device_token = _c.device_token, service_name = _c.service_name, auth_type = _c.auth_type, sign_in = _c.sign_in;
|
|
262
|
+
if (!auth_token)
|
|
263
|
+
throw new Error('Auth token is missing');
|
|
264
|
+
payload = {
|
|
265
|
+
auth_token: auth_token,
|
|
266
|
+
lead_id: leadId,
|
|
267
|
+
data: params.otp,
|
|
268
|
+
auth_type: auth_type,
|
|
269
|
+
device_token: device_token,
|
|
270
|
+
service_name: service_name,
|
|
271
|
+
sign_in: sign_in,
|
|
272
|
+
step_name: AUTH_STEP_NAMES.VERIFY_AUTH_SESSION_EXPIRED,
|
|
273
|
+
encryption_contract: ['data']
|
|
274
|
+
};
|
|
275
|
+
return [4, API.authService.verifyAuth(payload).catch(function (err) {
|
|
276
|
+
if (isAuthenticationVerificationFailed(err === null || err === void 0 ? void 0 : err.message))
|
|
277
|
+
thunkApi.dispatch(handleCurrentActiveScreen(session.data.nextScreen));
|
|
278
|
+
throw new Error(err === null || err === void 0 ? void 0 : err.message);
|
|
279
|
+
})];
|
|
280
|
+
case 1:
|
|
281
|
+
data = _g.sent();
|
|
282
|
+
setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
|
|
283
|
+
sendCustomEventToGTM({
|
|
284
|
+
event: 'Send Event',
|
|
285
|
+
event_category: 'User Registration Flow',
|
|
286
|
+
event_action: 'Session Expired - OTP Success'
|
|
287
|
+
});
|
|
288
|
+
(_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
|
|
289
|
+
thunkApi.dispatch(handleCurrentActiveScreen(session.data.nextScreen));
|
|
290
|
+
return [2, data];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}); });
|
|
225
294
|
export var verifyPasscode = createAsyncThunk('auth/verifyPasscode', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
226
295
|
var _a, settings, auth, _b, responseData, leadId, _c, auth_token, device_token, service_name, auth_type, sign_in, scope, payload, data, stepName_1;
|
|
227
296
|
var _d, _e, _f, _g, _h;
|
|
@@ -1042,6 +1111,35 @@ export var authSlice = createSlice({
|
|
|
1042
1111
|
state.loading = false;
|
|
1043
1112
|
if (!isAuthenticationVerificationFailed(message))
|
|
1044
1113
|
state.error = message;
|
|
1114
|
+
})
|
|
1115
|
+
.addCase(createAuthSessionExpired.pending, function (state) {
|
|
1116
|
+
state.loading = true;
|
|
1117
|
+
state.error = null;
|
|
1118
|
+
})
|
|
1119
|
+
.addCase(createAuthSessionExpired.fulfilled, function (state, action) {
|
|
1120
|
+
state.loading = false;
|
|
1121
|
+
state.data.otpData.authFor = AuthForType.MOBILE;
|
|
1122
|
+
state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: action.payload.response });
|
|
1123
|
+
})
|
|
1124
|
+
.addCase(createAuthSessionExpired.rejected, function (state, action) {
|
|
1125
|
+
state.loading = false;
|
|
1126
|
+
state.error = action.error.message;
|
|
1127
|
+
})
|
|
1128
|
+
.addCase(verifySessionExpiredOtp.pending, function (state) {
|
|
1129
|
+
state.loading = true;
|
|
1130
|
+
state.error = null;
|
|
1131
|
+
})
|
|
1132
|
+
.addCase(verifySessionExpiredOtp.fulfilled, function (state, action) {
|
|
1133
|
+
var _a;
|
|
1134
|
+
state.loading = false;
|
|
1135
|
+
var data = action.payload;
|
|
1136
|
+
state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: __assign(__assign({}, (_a = state.data.responseData) === null || _a === void 0 ? void 0 : _a.authResponse), data) });
|
|
1137
|
+
})
|
|
1138
|
+
.addCase(verifySessionExpiredOtp.rejected, function (state, _a) {
|
|
1139
|
+
var message = _a.error.message;
|
|
1140
|
+
state.loading = false;
|
|
1141
|
+
if (!isAuthenticationVerificationFailed(message))
|
|
1142
|
+
state.error = message;
|
|
1045
1143
|
})
|
|
1046
1144
|
.addCase(verifyPasscode.pending, function (state) {
|
|
1047
1145
|
state.loading = true;
|
|
@@ -1052,8 +1052,9 @@ export var individualSlice = createSlice({
|
|
|
1052
1052
|
if (identification === null || identification === void 0 ? void 0 : identification.issued_country_code) {
|
|
1053
1053
|
state.data.individualPersonalData.issuedCountry = findCountryByIso2(countries, identification === null || identification === void 0 ? void 0 : identification.issued_country_code);
|
|
1054
1054
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1055
|
+
state.data.individualPersonalData.expiryDate = (identification === null || identification === void 0 ? void 0 : identification.expiry)
|
|
1056
|
+
? convertNumbers2English(dateFormat(new Date(identification.expiry)))
|
|
1057
|
+
: undefined;
|
|
1057
1058
|
if (birth === null || birth === void 0 ? void 0 : birth.date)
|
|
1058
1059
|
state.data.individualPersonalData.dob = convertNumbers2English(dateFormat(new Date(birth === null || birth === void 0 ? void 0 : birth.date)));
|
|
1059
1060
|
if (birth === null || birth === void 0 ? void 0 : birth.country) {
|
|
@@ -1147,8 +1148,9 @@ export var individualSlice = createSlice({
|
|
|
1147
1148
|
if (identification === null || identification === void 0 ? void 0 : identification.issued_country_code) {
|
|
1148
1149
|
state.data.individualPersonalData.issuedCountry = findCountryByIso2(countries, identification === null || identification === void 0 ? void 0 : identification.issued_country_code);
|
|
1149
1150
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1151
|
+
state.data.individualPersonalData.expiryDate = (identification === null || identification === void 0 ? void 0 : identification.expiry)
|
|
1152
|
+
? convertNumbers2English(dateFormat(new Date(identification.expiry)))
|
|
1153
|
+
: undefined;
|
|
1152
1154
|
if (birth === null || birth === void 0 ? void 0 : birth.date)
|
|
1153
1155
|
state.data.individualPersonalData.dob = convertNumbers2English(dateFormat(birth === null || birth === void 0 ? void 0 : birth.date));
|
|
1154
1156
|
if (birth === null || birth === void 0 ? void 0 : birth.country) {
|
|
@@ -59,7 +59,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
59
59
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
60
60
|
import React, { memo } from 'react';
|
|
61
61
|
import { createRoot } from 'react-dom/client';
|
|
62
|
-
import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useAppDispatch } from '../../hooks';
|
|
62
|
+
import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useAppDispatch, useSessionExpiryHandler } from '../../hooks';
|
|
63
63
|
import { handleCurrentActiveScreen, handleOpen, handleSetCountryByIso2, settingsSelector } from '../../app/settings';
|
|
64
64
|
import AnimationFlow from '../../components/AnimationFlow';
|
|
65
65
|
import { store } from '../../app/store';
|
|
@@ -69,7 +69,7 @@ import { findOrCreateElementAndInject, sendPageView, isTapDomain, isOtherThanKWO
|
|
|
69
69
|
import { AUTH_SCREENS_NAVIGATION } from '../../constants';
|
|
70
70
|
import Background from '../shared/Background';
|
|
71
71
|
import { FeatureContainer } from '../shared/Containers';
|
|
72
|
-
import { authSelector, setMobileCountryCode, setLeadId, retrieveLeadIdentityByIdAsync, storeIsBusinessCountryPassed } from '../app/auth/authStore';
|
|
72
|
+
import { authSelector, setMobileCountryCode, setLeadId, retrieveLeadIdentityByIdAsync, storeIsBusinessCountryPassed, clearError, createAuthSessionExpired } from '../app/auth/authStore';
|
|
73
73
|
import { authFeatureScreens } from '../featuresScreens';
|
|
74
74
|
var Auth = memo(function (_a) {
|
|
75
75
|
var _b, _c, _d, _e;
|
|
@@ -95,6 +95,7 @@ var Auth = memo(function (_a) {
|
|
|
95
95
|
event_action: 'Registration Error'
|
|
96
96
|
});
|
|
97
97
|
useStepStartedListener();
|
|
98
|
+
useSessionExpiryHandler({ error: authError, clearError: clearError, createAuthSession: createAuthSessionExpired });
|
|
98
99
|
var activeScreen = settingData.activeScreen, isTapOrigin = settingData.isTapOrigin, open = settingData.open, merchant = settingData.merchant, appConfig = settingData.appConfig;
|
|
99
100
|
var animationDirection = open ? (_b = appConfig.features) === null || _b === void 0 ? void 0 : _b.dialogStartTransition : (_c = appConfig.features) === null || _c === void 0 ? void 0 : _c.dialogEndTransition;
|
|
100
101
|
var hideOverlay = ((_d = appConfig.features) === null || _d === void 0 ? void 0 : _d.overlay) === false;
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import Box from '@mui/material/Box/Box';
|
|
17
|
+
import { styled } from '@mui/material/styles';
|
|
18
|
+
import OTPField from '../../../shared/OTP';
|
|
19
|
+
import { DEFAULT_TIMER_VALUE } from '../../../../constants';
|
|
20
|
+
import { authSelector, clearError, createAuthSessionExpired } from '../../../app/auth/authStore';
|
|
21
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
22
|
+
import { sendCustomEventToGTM } from '../../../../utils';
|
|
23
|
+
var BoxStyled = styled(Box)(function (_a) {
|
|
24
|
+
var theme = _a.theme;
|
|
25
|
+
return ({
|
|
26
|
+
display: 'flex',
|
|
27
|
+
flexDirection: 'column',
|
|
28
|
+
fontFamily: theme.typography.fontFamily
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
var OTPInput = function () {
|
|
32
|
+
var _a = useFormContext(), control = _a.control, setValue = _a.setValue;
|
|
33
|
+
var t = useTranslation().t;
|
|
34
|
+
var dispatch = useAppDispatch();
|
|
35
|
+
var otpControl = useController({ name: 'otp', control: control });
|
|
36
|
+
var error = useAppSelector(authSelector).error;
|
|
37
|
+
var sendEventAskAnotherOTP = function () {
|
|
38
|
+
sendCustomEventToGTM({
|
|
39
|
+
event: 'Send Event',
|
|
40
|
+
event_category: 'User Registration Flow',
|
|
41
|
+
event_action: 'Session Expired - Another OTP asked'
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var handleOnOTPChange = function (otp) {
|
|
45
|
+
if (error)
|
|
46
|
+
dispatch(clearError());
|
|
47
|
+
otpControl.field.onChange(otp);
|
|
48
|
+
};
|
|
49
|
+
var handleOnResendOTP = function () {
|
|
50
|
+
if (otpControl.field.value)
|
|
51
|
+
setValue('otp', '', { shouldValidate: true });
|
|
52
|
+
sendEventAskAnotherOTP();
|
|
53
|
+
dispatch(createAuthSessionExpired(false));
|
|
54
|
+
};
|
|
55
|
+
var otpValue = otpControl.field.value;
|
|
56
|
+
return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
|
|
57
|
+
};
|
|
58
|
+
export default React.memo(OTPInput);
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import Box from '@mui/material/Box/Box';
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
|
+
import * as React from 'react';
|
|
16
|
+
import { useTranslation } from 'react-i18next';
|
|
17
|
+
import Text from '../../../../components/Text';
|
|
18
|
+
import { clearError, authSelector, resetOTPValue, verifySessionExpiredOtp } from '../../../app/auth/authStore';
|
|
19
|
+
import Button from '../../../shared/Button';
|
|
20
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
21
|
+
import { useAppDispatch, useAppSelector, useSanitizedTranslation } from '../../../../hooks';
|
|
22
|
+
import { useLanguage } from '../../../../hooks';
|
|
23
|
+
import { useForm, FormProvider } from 'react-hook-form';
|
|
24
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
25
|
+
import Form from '../../../../components/Form';
|
|
26
|
+
import { maskPhone, deepCopy, sendCustomEventToGTM } from '../../../../utils';
|
|
27
|
+
import { OTPValidation } from './validation';
|
|
28
|
+
import OTPInput from './OTPInput';
|
|
29
|
+
var OTPTitleContainerStyled = styled(Box)(function (_a) {
|
|
30
|
+
var theme = _a.theme;
|
|
31
|
+
return ({
|
|
32
|
+
background: theme.palette.common.white,
|
|
33
|
+
border: '1px solid',
|
|
34
|
+
borderColor: theme.palette.divider,
|
|
35
|
+
direction: theme.direction,
|
|
36
|
+
borderRadius: theme.spacing(0, 0, 1.25, 1.25),
|
|
37
|
+
marginBottom: theme.spacing(5.75)
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
var OTPTitleStyled = styled(Text)(function (_a) {
|
|
41
|
+
var theme = _a.theme;
|
|
42
|
+
return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInline: theme.spacing(2.5), lineHeight: 1.75, whiteSpace: 'pre-line' }));
|
|
43
|
+
});
|
|
44
|
+
var FormStyled = styled(Form)(function () { return ({
|
|
45
|
+
display: 'flex',
|
|
46
|
+
flexDirection: 'column'
|
|
47
|
+
}); });
|
|
48
|
+
var OTP = function () {
|
|
49
|
+
var _a;
|
|
50
|
+
var dispatch = useAppDispatch();
|
|
51
|
+
var _b = useAppSelector(authSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
52
|
+
var t = useTranslation().t;
|
|
53
|
+
var st = useSanitizedTranslation();
|
|
54
|
+
var isAr = useLanguage().isAr;
|
|
55
|
+
var methods = useForm({
|
|
56
|
+
resolver: yupResolver(OTPValidation),
|
|
57
|
+
defaultValues: data.otpData,
|
|
58
|
+
mode: 'onChange'
|
|
59
|
+
});
|
|
60
|
+
React.useEffect(function () {
|
|
61
|
+
if (error)
|
|
62
|
+
dispatch(clearError());
|
|
63
|
+
}, [methods.formState.isValid]);
|
|
64
|
+
React.useEffect(function () {
|
|
65
|
+
if (error)
|
|
66
|
+
dispatch(clearError());
|
|
67
|
+
sendCustomEventToGTM({
|
|
68
|
+
event: 'Send Event',
|
|
69
|
+
event_category: 'User Registration Flow',
|
|
70
|
+
event_action: 'Session Expired - Ask For OTP'
|
|
71
|
+
});
|
|
72
|
+
return function () {
|
|
73
|
+
dispatch(resetOTPValue());
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
var onSubmit = function (formData) {
|
|
77
|
+
dispatch(verifySessionExpiredOtp(deepCopy(formData)));
|
|
78
|
+
};
|
|
79
|
+
var disabled = !methods.formState.isValid;
|
|
80
|
+
var code = "+".concat((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix, " ");
|
|
81
|
+
var phone = data.mobileData.mobile ? data.mobileData.mobile : '';
|
|
82
|
+
var title = t('session_expired_otp');
|
|
83
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? st('ide_otp_waiting_title') : title, !loading && (_jsxs("span", __assign({ dir: 'ltr', style: { display: 'block' } }, { children: [st('code_sent_to'), " ", code, " ", maskPhone(phone)] })))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: t('next') }))] })) })) }));
|
|
84
|
+
};
|
|
85
|
+
export default React.memo(OTP);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
5
|
+
otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
6
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
8
|
+
}>>>;
|
|
@@ -63,6 +63,7 @@ import AuthMigratingDataScreen from './auth/screens/MigratingData';
|
|
|
63
63
|
import AuthOperatorError from './auth/screens/OperatorError';
|
|
64
64
|
import AuthPasscodeScreen from './auth/screens/Passcode';
|
|
65
65
|
import AuthOTPVerifySecurityError from './shared/OTPVerifySecurityError';
|
|
66
|
+
import AuthOTPSessionExpired from './auth/screens/OTPSessionExpired';
|
|
66
67
|
import CustomersPage from './business/screens/Customers';
|
|
67
68
|
import IDBODPage from './business/screens/IDBOD';
|
|
68
69
|
import BusinessVerifyPage from './business/screens/Verify';
|
|
@@ -428,6 +429,10 @@ export var authFeatureScreens = [
|
|
|
428
429
|
{
|
|
429
430
|
name: 'AUTH_OTP_VERIFY_SECURITY_ERROR_STEP',
|
|
430
431
|
element: AuthOTPVerifySecurityError
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
name: 'AUTH_SESSION_EXPIRED_OTP_STEP',
|
|
435
|
+
element: AuthOTPSessionExpired
|
|
431
436
|
}
|
|
432
437
|
];
|
|
433
438
|
export var businessFeatureScreens = [
|