@tap-payments/auth-jsconnect 2.8.13-test → 2.8.15-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/build/@types/app.d.ts
CHANGED
|
@@ -334,6 +334,13 @@ export declare enum AuthForType {
|
|
|
334
334
|
NATIONAL_ID = "national_id",
|
|
335
335
|
NATIONAL_ID_MISSED = "national_id_missed"
|
|
336
336
|
}
|
|
337
|
+
export declare enum AuthTypeNumber {
|
|
338
|
+
EMAIL_OTP = 5,
|
|
339
|
+
MOBILE_OTP = 2,
|
|
340
|
+
PASSWORD = 1,
|
|
341
|
+
MIGRATION = 10,
|
|
342
|
+
RESET_PASSWORD = 7
|
|
343
|
+
}
|
|
337
344
|
export declare enum AddressFormateType {
|
|
338
345
|
SELECT = "select",
|
|
339
346
|
NUMBER = "number",
|
package/build/@types/app.js
CHANGED
|
@@ -42,6 +42,14 @@ export var AuthForType;
|
|
|
42
42
|
AuthForType["NATIONAL_ID"] = "national_id";
|
|
43
43
|
AuthForType["NATIONAL_ID_MISSED"] = "national_id_missed";
|
|
44
44
|
})(AuthForType || (AuthForType = {}));
|
|
45
|
+
export var AuthTypeNumber;
|
|
46
|
+
(function (AuthTypeNumber) {
|
|
47
|
+
AuthTypeNumber[AuthTypeNumber["EMAIL_OTP"] = 5] = "EMAIL_OTP";
|
|
48
|
+
AuthTypeNumber[AuthTypeNumber["MOBILE_OTP"] = 2] = "MOBILE_OTP";
|
|
49
|
+
AuthTypeNumber[AuthTypeNumber["PASSWORD"] = 1] = "PASSWORD";
|
|
50
|
+
AuthTypeNumber[AuthTypeNumber["MIGRATION"] = 10] = "MIGRATION";
|
|
51
|
+
AuthTypeNumber[AuthTypeNumber["RESET_PASSWORD"] = 7] = "RESET_PASSWORD";
|
|
52
|
+
})(AuthTypeNumber || (AuthTypeNumber = {}));
|
|
45
53
|
export var AddressFormateType;
|
|
46
54
|
(function (AddressFormateType) {
|
|
47
55
|
AddressFormateType["SELECT"] = "select";
|
|
@@ -56,7 +56,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
56
56
|
};
|
|
57
57
|
var _a;
|
|
58
58
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
59
|
-
import { AuthForType, FlowsTypes } from '../../../@types';
|
|
59
|
+
import { AuthForType, AuthTypeNumber, FlowsTypes } from '../../../@types';
|
|
60
60
|
import { ADD_NEW_ENTITY, AUTH_STEP_NAMES, IDENTIFICATION_TYPE, defaultCountry } from '../../../constants';
|
|
61
61
|
import API from '../../../api';
|
|
62
62
|
import { handleCurrentActiveScreen, handleNextScreenStep, handleOpen, handlePrevScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
|
|
@@ -232,9 +232,9 @@ export var createEmailAuth = createAsyncThunk('auth/createEmailAuth', function (
|
|
|
232
232
|
case 1:
|
|
233
233
|
data = _d.sent();
|
|
234
234
|
screen = 'AUTH_PASSWORD_STEP';
|
|
235
|
-
if ((data === null || data === void 0 ? void 0 : data.auth_type) ===
|
|
235
|
+
if ((data === null || data === void 0 ? void 0 : data.auth_type) === AuthTypeNumber.RESET_PASSWORD)
|
|
236
236
|
screen = 'AUTH_RESET_PASSWORD_MESSAGE_STEP';
|
|
237
|
-
if ((data === null || data === void 0 ? void 0 : data.auth_type) ===
|
|
237
|
+
if ((data === null || data === void 0 ? void 0 : data.auth_type) === AuthTypeNumber.EMAIL_OTP)
|
|
238
238
|
screen = 'AUTH_OTP_STEP';
|
|
239
239
|
thunkApi.dispatch(handleNextScreenStep(screen));
|
|
240
240
|
(_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
@@ -271,7 +271,7 @@ export var verifyEmailPassword = createAsyncThunk('auth/verifyEmailPassword', fu
|
|
|
271
271
|
data = (_h.sent()).data;
|
|
272
272
|
if ((_e = data.errors) === null || _e === void 0 ? void 0 : _e.length)
|
|
273
273
|
throw new Error(data.errors[0].description);
|
|
274
|
-
if ((data === null || data === void 0 ? void 0 : data.auth_type) ===
|
|
274
|
+
if ((data === null || data === void 0 ? void 0 : data.auth_type) === AuthTypeNumber.MOBILE_OTP) {
|
|
275
275
|
sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('AUTH_OTP_STEP')); });
|
|
276
276
|
return [2, data];
|
|
277
277
|
}
|
|
@@ -307,7 +307,7 @@ export var resendEmailAuthOTP = createAsyncThunk('auth/resendEmailAuthOTP', func
|
|
|
307
307
|
return [4, API.authService.createAuth(requestBody)];
|
|
308
308
|
case 1:
|
|
309
309
|
data = _b.sent();
|
|
310
|
-
if ((data === null || data === void 0 ? void 0 : data.auth_type) ===
|
|
310
|
+
if ((data === null || data === void 0 ? void 0 : data.auth_type) === AuthTypeNumber.PASSWORD)
|
|
311
311
|
thunkApi.dispatch(handlePrevScreenStep('AUTH_PASSWORD_STEP'));
|
|
312
312
|
return [2, { response: data, formData: params }];
|
|
313
313
|
}
|
|
@@ -552,7 +552,7 @@ export var checkAccountAvailability = createAsyncThunk('auth/checkAccountAvailab
|
|
|
552
552
|
isDataHasIndividualOnly = (authConfigData === null || authConfigData === void 0 ? void 0 : authConfigData.length) === 1 && authConfigData.includes('individual');
|
|
553
553
|
data = (_d = auth.data.responseData) === null || _d === void 0 ? void 0 : _d.authResponse;
|
|
554
554
|
_b = data || {}, authId = _b.id, auth_type = _b.auth_type;
|
|
555
|
-
if (auth_type ===
|
|
555
|
+
if (auth_type === AuthTypeNumber.MIGRATION) {
|
|
556
556
|
}
|
|
557
557
|
return [4, API.accountService.checkAccountAvailability(data === null || data === void 0 ? void 0 : data.individual_id)];
|
|
558
558
|
case 1:
|
|
@@ -66,10 +66,10 @@ import { hasNoneEditableValue, isKW, isTwitter, isWebsite, mapSalesChannel, retr
|
|
|
66
66
|
export var verifyLeadToken = createAsyncThunk('brand/verifyLeadToken', function (_a, thunkApi) {
|
|
67
67
|
var token = _a.token, isInternally = _a.isInternally;
|
|
68
68
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
-
var payload, data, countryIso2, _b, config, brand_id, entity_id, publicKey, salesChannels, brandData;
|
|
70
|
-
var _c;
|
|
71
|
-
return __generator(this, function (
|
|
72
|
-
switch (
|
|
69
|
+
var payload, data, countryIso2, _b, config, brand_id, entity_id, board_id, publicKey, salesChannels, brandData, data_1;
|
|
70
|
+
var _c, _d;
|
|
71
|
+
return __generator(this, function (_e) {
|
|
72
|
+
switch (_e.label) {
|
|
73
73
|
case 0:
|
|
74
74
|
payload = __assign({ service_name: 'tap_email', verify_token: token }, (isInternally && {
|
|
75
75
|
notification: {
|
|
@@ -78,31 +78,38 @@ export var verifyLeadToken = createAsyncThunk('brand/verifyLeadToken', function
|
|
|
78
78
|
}));
|
|
79
79
|
return [4, API.leadService.verifyLeadToken(payload)];
|
|
80
80
|
case 1:
|
|
81
|
-
data = (
|
|
81
|
+
data = (_e.sent()).data;
|
|
82
82
|
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))
|
|
83
83
|
throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
|
|
84
84
|
countryIso2 = data === null || data === void 0 ? void 0 : data.country_code;
|
|
85
85
|
if (countryIso2)
|
|
86
86
|
thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
|
|
87
|
-
_b = data || {}, config = _b.config, brand_id = _b.brand_id, entity_id = _b.entity_id;
|
|
87
|
+
_b = data || {}, config = _b.config, brand_id = _b.brand_id, entity_id = _b.entity_id, board_id = _b.id;
|
|
88
88
|
publicKey = config === null || config === void 0 ? void 0 : config.public_key;
|
|
89
89
|
if (publicKey)
|
|
90
90
|
thunkApi.dispatch(handlePublicKey(publicKey));
|
|
91
91
|
brandData = undefined;
|
|
92
92
|
if (isInternally)
|
|
93
93
|
data.step_name = BRAND_STEP_NAMES.BRAND_INFO;
|
|
94
|
-
if (!(data.step_name !== BRAND_STEP_NAMES.PHONE_AUTH || isInternally)) return [3,
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
return [4, API.brandService.retrieveBrand(brand_id)];
|
|
94
|
+
if (!(data.step_name !== BRAND_STEP_NAMES.PHONE_AUTH || isInternally)) return [3, 7];
|
|
95
|
+
if (!!brand_id) return [3, 3];
|
|
96
|
+
return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
98
97
|
case 2:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
data_1 = _e.sent();
|
|
99
|
+
brandData = data_1;
|
|
100
|
+
if (!((_d = data_1 === null || data_1 === void 0 ? void 0 : data_1.brand) === null || _d === void 0 ? void 0 : _d.id))
|
|
101
|
+
throw new Error('brand_id_missing');
|
|
102
|
+
return [3, 5];
|
|
103
|
+
case 3: return [4, API.brandService.retrieveBrand(brand_id)];
|
|
104
|
+
case 4:
|
|
105
|
+
brandData = _e.sent();
|
|
106
|
+
_e.label = 5;
|
|
107
|
+
case 5: return [4, API.dataService.getChannelsOfServices({ page: 0 })];
|
|
108
|
+
case 6:
|
|
109
|
+
salesChannels = _e.sent();
|
|
103
110
|
thunkApi.dispatch(handleNextScreenStep('BRAND_INFO_STEP'));
|
|
104
|
-
|
|
105
|
-
case
|
|
111
|
+
_e.label = 7;
|
|
112
|
+
case 7: return [2, {
|
|
106
113
|
data: data,
|
|
107
114
|
brandData: brandData === null || brandData === void 0 ? void 0 : brandData.brand,
|
|
108
115
|
salesChannels: salesChannels,
|
|
@@ -131,10 +138,10 @@ export var resendOTP = createAsyncThunk('brandResendOTP', function (params, thun
|
|
|
131
138
|
});
|
|
132
139
|
}); });
|
|
133
140
|
export var verifyBrandLeadOTP = createAsyncThunk('brand/verifyLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
134
|
-
var _a, brand, settings, responseBody, payload, data, publicKey, _b, brand_id, entity_id, brandData, salesChannels;
|
|
135
|
-
var _c, _d, _e, _f, _g;
|
|
136
|
-
return __generator(this, function (
|
|
137
|
-
switch (
|
|
141
|
+
var _a, brand, settings, responseBody, payload, data, publicKey, _b, brand_id, entity_id, boardId, brandData, data_2, salesChannels;
|
|
142
|
+
var _c, _d, _e, _f, _g, _h;
|
|
143
|
+
return __generator(this, function (_j) {
|
|
144
|
+
switch (_j.label) {
|
|
138
145
|
case 0:
|
|
139
146
|
_a = thunkApi.getState(), brand = _a.brand, settings = _a.settings;
|
|
140
147
|
responseBody = brand.data.verify.responseBody;
|
|
@@ -147,22 +154,30 @@ export var verifyBrandLeadOTP = createAsyncThunk('brand/verifyLeadOTP', function
|
|
|
147
154
|
};
|
|
148
155
|
return [4, API.leadService.verifyLeadOTP(payload)];
|
|
149
156
|
case 1:
|
|
150
|
-
data = (
|
|
157
|
+
data = (_j.sent()).data;
|
|
151
158
|
if ((_d = data.errors) === null || _d === void 0 ? void 0 : _d.length)
|
|
152
159
|
throw new Error(data.errors[0].description);
|
|
153
160
|
publicKey = (_e = data === null || data === void 0 ? void 0 : data.config) === null || _e === void 0 ? void 0 : _e.public_key;
|
|
154
161
|
if (publicKey)
|
|
155
162
|
thunkApi.dispatch(handlePublicKey(publicKey));
|
|
156
|
-
_b = data || {}, brand_id = _b.brand_id, entity_id = _b.entity_id;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return [4, API.
|
|
163
|
+
_b = data || {}, brand_id = _b.brand_id, entity_id = _b.entity_id, boardId = _b.id;
|
|
164
|
+
brandData = undefined;
|
|
165
|
+
if (!!brand_id) return [3, 3];
|
|
166
|
+
return [4, API.boardService.retrieveBoardDetails(boardId)];
|
|
160
167
|
case 2:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
data_2 = _j.sent();
|
|
169
|
+
brandData = data_2;
|
|
170
|
+
if (!((_f = data_2 === null || data_2 === void 0 ? void 0 : data_2.brand) === null || _f === void 0 ? void 0 : _f.id))
|
|
171
|
+
throw new Error('brand_id_missing');
|
|
172
|
+
return [3, 5];
|
|
173
|
+
case 3: return [4, API.brandService.retrieveBrand(brand_id)];
|
|
174
|
+
case 4:
|
|
175
|
+
brandData = _j.sent();
|
|
176
|
+
_j.label = 5;
|
|
177
|
+
case 5: return [4, API.dataService.getChannelsOfServices({ page: 0 })];
|
|
178
|
+
case 6:
|
|
179
|
+
salesChannels = _j.sent();
|
|
180
|
+
(_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, { otp: params.otp });
|
|
166
181
|
sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('BRAND_INFO_STEP')); });
|
|
167
182
|
return [2, {
|
|
168
183
|
data: data,
|
|
@@ -21,7 +21,7 @@ import Button from '../../../shared/Button';
|
|
|
21
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
22
22
|
import { useAppDispatch, useAppSelector, useLanguage } from '../../../../hooks';
|
|
23
23
|
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
24
|
-
import { AuthForType } from '../../../../@types';
|
|
24
|
+
import { AuthForType, AuthTypeNumber } from '../../../../@types';
|
|
25
25
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
26
26
|
import Form from '../../../../components/Form';
|
|
27
27
|
import { maskPhone, maskID, deepCopy, maskEmail } from '../../../../utils';
|
|
@@ -47,9 +47,8 @@ var FormStyled = styled(Form)(function () { return ({
|
|
|
47
47
|
flexDirection: 'column'
|
|
48
48
|
}); });
|
|
49
49
|
var OTP = function () {
|
|
50
|
-
var _a;
|
|
51
50
|
var dispatch = useAppDispatch();
|
|
52
|
-
var
|
|
51
|
+
var _a = useAppSelector(authSelector), data = _a.data, loading = _a.loading, error = _a.error;
|
|
53
52
|
var t = useTranslation().t;
|
|
54
53
|
var isAr = useLanguage().isAr;
|
|
55
54
|
var methods = useForm({
|
|
@@ -59,16 +58,20 @@ var OTP = function () {
|
|
|
59
58
|
});
|
|
60
59
|
var isNidAuth = data.otpData.authFor === AuthForType.NATIONAL_ID;
|
|
61
60
|
var isEmailAuth = data.otpData.authFor === AuthForType.EMAIL;
|
|
62
|
-
var phone = data.mobileData.mobile ? ((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix) + data.mobileData.mobile : '';
|
|
63
|
-
var idNumber = data.nidData.nid;
|
|
64
|
-
var email = data.emailData.email;
|
|
65
61
|
var getNumber = function () {
|
|
66
62
|
var _a, _b;
|
|
67
63
|
if (isNidAuth)
|
|
68
|
-
return maskID(
|
|
69
|
-
if (isEmailAuth)
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
return maskID(data.nidData.nid);
|
|
65
|
+
if (isEmailAuth) {
|
|
66
|
+
var _c = ((_a = data.responseData) === null || _a === void 0 ? void 0 : _a.authResponse) || {}, auth_type = _c.auth_type, email = _c.email, mobile = _c.mobile;
|
|
67
|
+
if (auth_type === AuthTypeNumber.MOBILE_OTP && mobile)
|
|
68
|
+
return mobile;
|
|
69
|
+
if (auth_type === AuthTypeNumber.EMAIL_OTP && email)
|
|
70
|
+
return email;
|
|
71
|
+
return maskEmail(data.emailData.email);
|
|
72
|
+
}
|
|
73
|
+
var phone = data.mobileData.mobile ? ((_b = data.mobileData.countryCode) === null || _b === void 0 ? void 0 : _b.idd_prefix) + data.mobileData.mobile : '';
|
|
74
|
+
return maskPhone(phone);
|
|
72
75
|
};
|
|
73
76
|
var getTitle = function () {
|
|
74
77
|
if (isNidAuth)
|