@tap-payments/auth-jsconnect 2.6.57-test → 2.6.60-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.
Files changed (118) hide show
  1. package/build/@types/app.d.ts +3 -1
  2. package/build/@types/app.js +1 -1
  3. package/build/api/account.d.ts +1 -0
  4. package/build/api/account.js +8 -1
  5. package/build/api/auth.d.ts +2 -0
  6. package/build/api/index.d.ts +4 -3
  7. package/build/api/lead.d.ts +3 -0
  8. package/build/api/operator.d.ts +3 -2
  9. package/build/api/operator.js +2 -2
  10. package/build/app/rootReducer.d.ts +1 -0
  11. package/build/app/rootReducer.js +2 -0
  12. package/build/app/settings.js +3 -2
  13. package/build/app/store.d.ts +2 -0
  14. package/build/assets/locales/ar.json +2 -1
  15. package/build/assets/locales/en.json +2 -1
  16. package/build/constants/app.d.ts +11 -0
  17. package/build/constants/app.js +54 -0
  18. package/build/features/app/auth/authStore.d.ts +189 -0
  19. package/build/features/app/auth/authStore.js +726 -0
  20. package/build/features/app/bank/bankStore.js +5 -4
  21. package/build/features/app/brand/brandStore.js +5 -4
  22. package/build/features/app/business/businessStore.js +37 -28
  23. package/build/features/app/connectExpress/connectExpressStore.js +3 -2
  24. package/build/features/app/entity/entityStore.js +5 -4
  25. package/build/features/app/individual/individualStore.js +5 -4
  26. package/build/features/app/tax/taxStore.js +5 -4
  27. package/build/features/auth/Auth.d.ts +9 -0
  28. package/build/features/auth/Auth.js +93 -0
  29. package/build/features/auth/index.d.ts +1 -0
  30. package/build/features/auth/index.js +1 -0
  31. package/build/features/auth/screens/AuthenticationList/AuthenticationList.d.ts +5 -0
  32. package/build/features/auth/screens/AuthenticationList/AuthenticationList.js +91 -0
  33. package/build/features/auth/screens/AuthenticationList/BrandList.d.ts +10 -0
  34. package/build/features/auth/screens/AuthenticationList/BrandList.js +81 -0
  35. package/build/features/auth/screens/AuthenticationList/EntityList.d.ts +11 -0
  36. package/build/features/auth/screens/AuthenticationList/EntityList.js +96 -0
  37. package/build/features/auth/screens/AuthenticationList/MerchantList.d.ts +10 -0
  38. package/build/features/auth/screens/AuthenticationList/MerchantList.js +107 -0
  39. package/build/features/auth/screens/AuthenticationList/index.d.ts +3 -0
  40. package/build/features/auth/screens/AuthenticationList/index.js +2 -0
  41. package/build/features/auth/screens/AuthenticationList/validation.d.ts +14 -0
  42. package/build/features/auth/screens/AuthenticationList/validation.js +8 -0
  43. package/build/features/auth/screens/BusinessCountry/BusinessCountry.d.ts +5 -0
  44. package/build/features/auth/screens/BusinessCountry/BusinessCountry.js +105 -0
  45. package/build/features/auth/screens/BusinessCountry/index.d.ts +3 -0
  46. package/build/features/auth/screens/BusinessCountry/index.js +2 -0
  47. package/build/features/auth/screens/CivilID/CivilID.d.ts +5 -0
  48. package/build/features/auth/screens/CivilID/CivilID.js +88 -0
  49. package/build/features/auth/screens/CivilID/IDNumber.d.ts +8 -0
  50. package/build/features/auth/screens/CivilID/IDNumber.js +54 -0
  51. package/build/features/auth/screens/CivilID/index.d.ts +3 -0
  52. package/build/features/auth/screens/CivilID/index.js +2 -0
  53. package/build/features/auth/screens/CivilID/validation.d.ts +8 -0
  54. package/build/features/auth/screens/CivilID/validation.js +4 -0
  55. package/build/features/auth/screens/Mobile/Mobile.d.ts +5 -0
  56. package/build/features/auth/screens/Mobile/Mobile.js +108 -0
  57. package/build/features/auth/screens/Mobile/MobileNumber.d.ts +13 -0
  58. package/build/features/auth/screens/Mobile/MobileNumber.js +158 -0
  59. package/build/features/auth/screens/Mobile/index.d.ts +3 -0
  60. package/build/features/auth/screens/Mobile/index.js +2 -0
  61. package/build/features/auth/screens/Mobile/validation.d.ts +8 -0
  62. package/build/features/auth/screens/Mobile/validation.js +30 -0
  63. package/build/features/auth/screens/NID/DOB.d.ts +6 -0
  64. package/build/features/auth/screens/NID/DOB.js +47 -0
  65. package/build/features/auth/screens/NID/IDNumber.d.ts +7 -0
  66. package/build/features/auth/screens/NID/IDNumber.js +55 -0
  67. package/build/features/auth/screens/NID/NID.d.ts +5 -0
  68. package/build/features/auth/screens/NID/NID.js +92 -0
  69. package/build/features/auth/screens/NID/index.d.ts +3 -0
  70. package/build/features/auth/screens/NID/index.js +2 -0
  71. package/build/features/auth/screens/NID/validation.d.ts +11 -0
  72. package/build/features/auth/screens/NID/validation.js +11 -0
  73. package/build/features/auth/screens/OTP/OTP.d.ts +5 -0
  74. package/build/features/auth/screens/OTP/OTP.js +88 -0
  75. package/build/features/auth/screens/OTP/OTPInput.d.ts +5 -0
  76. package/build/features/auth/screens/OTP/OTPInput.js +57 -0
  77. package/build/features/auth/screens/OTP/index.d.ts +3 -0
  78. package/build/features/auth/screens/OTP/index.js +2 -0
  79. package/build/features/auth/screens/OTP/validation.d.ts +8 -0
  80. package/build/features/auth/screens/OTP/validation.js +4 -0
  81. package/build/features/auth/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
  82. package/build/features/auth/screens/VerifyPACI/VerifyPACI.js +34 -0
  83. package/build/features/auth/screens/VerifyPACI/index.d.ts +3 -0
  84. package/build/features/auth/screens/VerifyPACI/index.js +2 -0
  85. package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +6 -33
  86. package/build/features/brand/screens/BrandActivities/RefundPolicy.d.ts +4 -17
  87. package/build/features/brand/screens/BrandActivities/TAC.d.ts +2 -7
  88. package/build/features/business/screens/BusinessType/LicenseType.d.ts +4 -26
  89. package/build/features/business/screens/Customers/CustomerLocations.d.ts +6 -33
  90. package/build/features/business/screens/Customers/RefundPolicy.d.ts +4 -17
  91. package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +4 -26
  92. package/build/features/connectExpress/screens/CollectBusinessInfo/TAC.d.ts +2 -7
  93. package/build/features/connectExpress/screens/Mobile/MobileNumber.js +2 -2
  94. package/build/features/connectExpress/screens/NID/TAC.d.ts +2 -7
  95. package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +6 -33
  96. package/build/features/featuresScreens.d.ts +1 -0
  97. package/build/features/featuresScreens.js +40 -3
  98. package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.d.ts +4 -26
  99. package/build/features/individual/screens/IndividualPersonalInfo/Gender.d.ts +4 -26
  100. package/build/features/shared/Address/CountryList.d.ts +5 -21
  101. package/build/features/shared/Address/InputSelect.d.ts +5 -21
  102. package/build/features/shared/Background/Background.d.ts +2 -1
  103. package/build/features/shared/Background/Background.js +5 -5
  104. package/build/features/shared/Input/Input.d.ts +1 -1
  105. package/build/features/shared/UploadFile/FileUpload.d.ts +2 -7
  106. package/build/features/shared/UploadFile/UploadFile.d.ts +2 -7
  107. package/build/features/shared/UploadFile/UploadWrapper.d.ts +2 -7
  108. package/build/features/shared/UploadMultipleFile/UploadFile.d.ts +2 -7
  109. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +2 -7
  110. package/build/hooks/useAppDispatch.d.ts +1 -0
  111. package/build/index.d.ts +3 -2
  112. package/build/index.js +3 -1
  113. package/build/utils/common.d.ts +1 -0
  114. package/build/utils/common.js +8 -1
  115. package/build/utils/string.d.ts +1 -0
  116. package/build/utils/string.js +3 -0
  117. package/build/utils/validation.js +2 -1
  118. package/package.json +1 -1
@@ -0,0 +1,726 @@
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
+ var _a;
49
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
+ import { AuthForType, FlowsTypes } from '../../../@types';
51
+ import { ACCOUNT_NOT_AVAILABLE, AUTH_STEP_NAMES, IDENTIFICATION_TYPE, defaultCountry } from '../../../constants';
52
+ import API from '../../../api';
53
+ import { handleCurrentActiveScreen, handleNextScreenStep, handleOpen, handleSetCountryByIso2 } from '../../../app/settings';
54
+ import { findCountryByIddPrefix, isSA, sleep } from '../../../utils';
55
+ export var updateBusinessCountry = createAsyncThunk('auth/updateBusinessCountry', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var auth, payload, data;
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0:
60
+ auth = thunkApi.getState().auth;
61
+ payload = {
62
+ id: auth.data.leadId || '',
63
+ country_code: countryCode,
64
+ encryption_contract: []
65
+ };
66
+ return [4, API.leadService.updateLead(payload)];
67
+ case 1:
68
+ data = _a.sent();
69
+ return [2, data];
70
+ }
71
+ });
72
+ }); });
73
+ export var retrieveLeadIdentityByIdAsync = createAsyncThunk('auth/retrieveLeadIdentityByIdAsync', function (leadId, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
74
+ var settingData, countryCode, data, _a, country_code, contact, phone;
75
+ var _b, _c;
76
+ return __generator(this, function (_d) {
77
+ switch (_d.label) {
78
+ case 0:
79
+ settingData = thunkApi.getState().settings.data;
80
+ countryCode = settingData.businessCountry;
81
+ return [4, API.leadService.retrieveLeadIdentity(leadId)];
82
+ case 1:
83
+ data = _d.sent();
84
+ _a = data || {}, country_code = _a.country_code, contact = _a.contact;
85
+ if (country_code)
86
+ thunkApi.dispatch(handleSetCountryByIso2(country_code));
87
+ phone = (contact || {}).phone;
88
+ if (phone === null || phone === void 0 ? void 0 : phone.country_code)
89
+ countryCode = findCountryByIddPrefix(settingData.countries, phone.country_code);
90
+ if (!(data === null || data === void 0 ? void 0 : data.country_code) && !((_b = settingData.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2)) {
91
+ thunkApi.dispatch(handleCurrentActiveScreen('AUTH_BUSINESS_COUNTRY_STEP'));
92
+ return [2, { data: data, countryCode: countryCode }];
93
+ }
94
+ if ((data === null || data === void 0 ? void 0 : data.country_code) && !((_c = settingData.businessCountry) === null || _c === void 0 ? void 0 : _c.iso2)) {
95
+ thunkApi.dispatch(handleSetCountryByIso2(data.country_code));
96
+ if (!isSA(data.country_code))
97
+ thunkApi.dispatch(handleCurrentActiveScreen('AUTH_MOBILE_STEP'));
98
+ return [2, { data: data, countryCode: countryCode }];
99
+ }
100
+ if (!isSA(settingData.businessCountry.iso2)) {
101
+ thunkApi.dispatch(handleCurrentActiveScreen('AUTH_MOBILE_STEP'));
102
+ return [2, { data: data, countryCode: countryCode }];
103
+ }
104
+ return [2, { data: data, countryCode: countryCode }];
105
+ }
106
+ });
107
+ }); });
108
+ export var createMobileAuth = createAsyncThunk('auth/createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
109
+ var _a, settings, auth, requestBody, data;
110
+ var _b, _c;
111
+ return __generator(this, function (_d) {
112
+ switch (_d.label) {
113
+ case 0:
114
+ _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
115
+ requestBody = {
116
+ country: settings.data.businessCountry.iso2,
117
+ scope: settings.data.appConfig.scope,
118
+ lang: settings.data.language,
119
+ lead_id: auth.data.leadId,
120
+ user_credentail: {
121
+ phone: params.mobile || '',
122
+ code: params.countryCode.idd_prefix.toString()
123
+ },
124
+ sign_in: false,
125
+ is_lead: true,
126
+ step_name: AUTH_STEP_NAMES.CREATE_AUTH_MOBILE,
127
+ encryption_contract: ['user_credentail.phone', 'user_credentail.code']
128
+ };
129
+ return [4, API.authService.createAuth(requestBody)];
130
+ case 1:
131
+ data = _d.sent();
132
+ thunkApi.dispatch(handleNextScreenStep());
133
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody.user_credentail);
134
+ return [2, { response: data, formData: params }];
135
+ }
136
+ });
137
+ }); });
138
+ export var resendMobileAuthOTP = createAsyncThunk('auth/resendMobileAuthOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
139
+ var _a, settings, auth, requestBody, data;
140
+ return __generator(this, function (_b) {
141
+ switch (_b.label) {
142
+ case 0:
143
+ _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
144
+ requestBody = {
145
+ country: settings.data.businessCountry.iso2,
146
+ scope: settings.data.appConfig.scope,
147
+ lang: settings.data.language,
148
+ lead_id: auth.data.leadId,
149
+ user_credentail: {
150
+ phone: params.mobile,
151
+ code: params.countryCode.idd_prefix.toString()
152
+ },
153
+ sign_in: false,
154
+ is_lead: true,
155
+ step_name: AUTH_STEP_NAMES.CREATE_AUTH_MOBILE,
156
+ encryption_contract: ['user_credentail.phone', 'user_credentail.code']
157
+ };
158
+ return [4, API.authService.createAuth(requestBody)];
159
+ case 1:
160
+ data = _b.sent();
161
+ return [2, { response: data, formData: params }];
162
+ }
163
+ });
164
+ }); });
165
+ export var verifyMobileOtp = createAsyncThunk('auth/verifyMobileOtp', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
166
+ var _a, settings, auth, _b, responseData, leadId, _c, auth_token, device_token, service_name, authData, isDataHasIndividualOnly, payload, data, accountData, _d, step_name, brands, entities, brandList, entityList, isExistingUser, authId;
167
+ var _e, _f, _g, _h;
168
+ return __generator(this, function (_j) {
169
+ switch (_j.label) {
170
+ case 0:
171
+ _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
172
+ _b = auth.data || {}, responseData = _b.responseData, leadId = _b.leadId;
173
+ _c = (_e = responseData === null || responseData === void 0 ? void 0 : responseData.authResponse) !== null && _e !== void 0 ? _e : {}, auth_token = _c.auth_token, device_token = _c.device_token, service_name = _c.service_name;
174
+ if (!auth_token)
175
+ throw new Error('Auth token is missing');
176
+ authData = settings.data.appConfig.data;
177
+ isDataHasIndividualOnly = (authData === null || authData === void 0 ? void 0 : authData.length) === 1 && authData.includes('individual');
178
+ payload = {
179
+ auth_token: auth_token,
180
+ lead_id: leadId,
181
+ data: params.otp,
182
+ auth_type: 2,
183
+ device_token: device_token,
184
+ service_name: service_name,
185
+ sign_in: false,
186
+ step_name: AUTH_STEP_NAMES.VERIFY_AUTH_MOBILE,
187
+ encryption_contract: ['data']
188
+ };
189
+ return [4, API.authService.verifyAuth(payload)];
190
+ case 1:
191
+ data = (_j.sent()).data;
192
+ if ((_f = data.errors) === null || _f === void 0 ? void 0 : _f.length)
193
+ throw new Error(data.errors[0].description);
194
+ return [4, API.accountService.checkAccountAvailability(data.individual_id)];
195
+ case 2:
196
+ accountData = _j.sent();
197
+ (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, params);
198
+ _d = accountData || {}, step_name = _d.step_name, brands = _d.brands, entities = _d.entities;
199
+ brandList = brands || [];
200
+ entityList = entities || [];
201
+ isExistingUser = step_name === 'select_account';
202
+ authId = data.id;
203
+ if (!(isExistingUser && isDataHasIndividualOnly && authId)) return [3, 4];
204
+ return [4, thunkApi.dispatch(confirmInfo({ authId: authId }))];
205
+ case 3:
206
+ _j.sent();
207
+ return [2, { data: data, brandList: brandList, entityList: entityList }];
208
+ case 4:
209
+ if (isExistingUser && !isDataHasIndividualOnly && brandList.length && entityList.length) {
210
+ sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('AUTH_AUTHENTICATION_LIST_STEP')); });
211
+ return [2, { data: data, brandList: brandList, entityList: entityList }];
212
+ }
213
+ throw new Error(ACCOUNT_NOT_AVAILABLE);
214
+ }
215
+ });
216
+ }); });
217
+ export var createNIDAuth = createAsyncThunk('auth/createNIDAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
218
+ var _a, settings, auth, dob, nid, nidType, countryCode, requestBody, data;
219
+ var _b, _c;
220
+ return __generator(this, function (_d) {
221
+ switch (_d.label) {
222
+ case 0:
223
+ _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
224
+ dob = params.dob, nid = params.nid;
225
+ nidType = nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
226
+ countryCode = settings.data.businessCountry.iso2;
227
+ requestBody = {
228
+ country: countryCode,
229
+ scope: settings.data.appConfig.scope,
230
+ lang: settings.data.language,
231
+ lead_id: auth.data.leadId,
232
+ user_credentail: {
233
+ identification_id: nid,
234
+ identification_id_type: nidType,
235
+ date_of_birth: dob,
236
+ country_code: countryCode
237
+ },
238
+ sign_in: false,
239
+ is_lead: true,
240
+ step_name: AUTH_STEP_NAMES.CREATE_AUTH_NID,
241
+ encryption_contract: [
242
+ 'user_credentail.country_code',
243
+ 'user_credentail.identification_id',
244
+ 'user_credentail.identification_id_type',
245
+ 'user_credentail.date_of_birth'
246
+ ]
247
+ };
248
+ return [4, API.authService.createAuth(requestBody)];
249
+ case 1:
250
+ data = _d.sent();
251
+ thunkApi.dispatch(handleNextScreenStep());
252
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody.user_credentail);
253
+ return [2, { response: data, formData: params }];
254
+ }
255
+ });
256
+ }); });
257
+ export var resendNIDAuthOTP = createAsyncThunk('auth/resendNIDAuthOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
258
+ var _a, settings, auth, dob, nid, nidType, countryCode, requestBody, data;
259
+ return __generator(this, function (_b) {
260
+ switch (_b.label) {
261
+ case 0:
262
+ _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
263
+ dob = params.dob, nid = params.nid;
264
+ nidType = nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
265
+ countryCode = settings.data.businessCountry.iso2;
266
+ requestBody = {
267
+ country: countryCode,
268
+ scope: settings.data.appConfig.scope,
269
+ lang: settings.data.language,
270
+ lead_id: auth.data.leadId,
271
+ user_credentail: {
272
+ identification_id: nid,
273
+ identification_id_type: nidType,
274
+ date_of_birth: dob,
275
+ country_code: countryCode
276
+ },
277
+ sign_in: false,
278
+ is_lead: true,
279
+ step_name: AUTH_STEP_NAMES.CREATE_AUTH_NID,
280
+ encryption_contract: [
281
+ 'user_credentail.country_code',
282
+ 'user_credentail.identification_id',
283
+ 'user_credentail.identification_id_type',
284
+ 'user_credentail.date_of_birth'
285
+ ]
286
+ };
287
+ return [4, API.authService.createAuth(requestBody)];
288
+ case 1:
289
+ data = _b.sent();
290
+ return [2, { response: data, formData: params }];
291
+ }
292
+ });
293
+ }); });
294
+ export var verifyNIDOtp = createAsyncThunk('auth/verifyNIDOtp', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
295
+ var _a, settings, auth, _b, responseData, leadId, _c, auth_token, device_token, service_name, authData, isDataHasIndividualOnly, payload, data, accountData, _d, step_name, brands, entities, brandList, entityList, isExistingUser, authId;
296
+ var _e, _f, _g, _h;
297
+ return __generator(this, function (_j) {
298
+ switch (_j.label) {
299
+ case 0:
300
+ _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
301
+ _b = auth.data || {}, responseData = _b.responseData, leadId = _b.leadId;
302
+ _c = (_e = responseData === null || responseData === void 0 ? void 0 : responseData.authResponse) !== null && _e !== void 0 ? _e : {}, auth_token = _c.auth_token, device_token = _c.device_token, service_name = _c.service_name;
303
+ if (!auth_token)
304
+ throw new Error('Auth token is missing');
305
+ authData = settings.data.appConfig.data;
306
+ isDataHasIndividualOnly = (authData === null || authData === void 0 ? void 0 : authData.length) === 1 && authData.includes('individual');
307
+ payload = {
308
+ auth_token: auth_token,
309
+ lead_id: leadId,
310
+ data: params.otp,
311
+ auth_type: 2,
312
+ device_token: device_token,
313
+ service_name: service_name || 'ABSHER',
314
+ sign_in: false,
315
+ step_name: AUTH_STEP_NAMES.VERIFY_AUTH_NID,
316
+ encryption_contract: ['data']
317
+ };
318
+ return [4, API.authService.verifyAuth(payload)];
319
+ case 1:
320
+ data = (_j.sent()).data;
321
+ if ((_f = data.errors) === null || _f === void 0 ? void 0 : _f.length)
322
+ throw new Error(data.errors[0].description);
323
+ return [4, API.accountService.checkAccountAvailability(data.individual_id)];
324
+ case 2:
325
+ accountData = _j.sent();
326
+ (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, params);
327
+ _d = accountData || {}, step_name = _d.step_name, brands = _d.brands, entities = _d.entities;
328
+ brandList = brands || [];
329
+ entityList = entities || [];
330
+ isExistingUser = step_name === 'select_account';
331
+ authId = data.id;
332
+ if (!(isExistingUser && isDataHasIndividualOnly && authId)) return [3, 4];
333
+ return [4, thunkApi.dispatch(confirmInfo({ authId: authId }))];
334
+ case 3:
335
+ _j.sent();
336
+ return [2, { data: data, brandList: brandList, entityList: entityList }];
337
+ case 4:
338
+ if (isExistingUser && !isDataHasIndividualOnly && brandList.length && entityList.length) {
339
+ sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('AUTH_AUTHENTICATION_LIST_STEP')); });
340
+ return [2, { data: data, brandList: brandList, entityList: entityList }];
341
+ }
342
+ throw new Error(ACCOUNT_NOT_AVAILABLE);
343
+ }
344
+ });
345
+ }); });
346
+ export var createCivilIdAuth = createAsyncThunk('auth/createCivilAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
347
+ var settings, countryCode, requestBody, data;
348
+ var _a, _b;
349
+ return __generator(this, function (_c) {
350
+ switch (_c.label) {
351
+ case 0:
352
+ settings = thunkApi.getState().settings;
353
+ countryCode = settings.data.businessCountry.iso2;
354
+ requestBody = {
355
+ country: settings.data.businessCountry.iso2,
356
+ scope: settings.data.appConfig.scope,
357
+ lang: settings.data.language,
358
+ user_credentail: {
359
+ identification_id: params.civilId,
360
+ country_code: countryCode
361
+ },
362
+ sign_in: false,
363
+ is_lead: true,
364
+ step_name: AUTH_STEP_NAMES.CREATE_AUTH_CIVIL_ID,
365
+ encryption_contract: ['user_credentail.identification_id']
366
+ };
367
+ return [4, API.authService.createAuth(requestBody)];
368
+ case 1:
369
+ data = _c.sent();
370
+ thunkApi.dispatch(handleNextScreenStep());
371
+ (_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody.user_credentail);
372
+ return [2, { response: data, formData: params }];
373
+ }
374
+ });
375
+ }); });
376
+ export var verifyPACI = createAsyncThunk('auth/verifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
377
+ var _a, settings, auth, authResponse, authConfigData, isDataHasIndividualOnly, expiry, interval, maxCalls, count, data, isSuccess, authId, accountData, _b, step_name, brands, entities, brandList, entityList, isExistingUser;
378
+ var _c;
379
+ return __generator(this, function (_d) {
380
+ switch (_d.label) {
381
+ case 0:
382
+ _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
383
+ authResponse = (auth.data.responseData || {}).authResponse;
384
+ authConfigData = settings.data.appConfig.data;
385
+ isDataHasIndividualOnly = (authConfigData === null || authConfigData === void 0 ? void 0 : authConfigData.length) === 1 && authConfigData.includes('individual');
386
+ expiry = (authResponse === null || authResponse === void 0 ? void 0 : authResponse.expiry) || 120;
387
+ interval = 3;
388
+ maxCalls = Math.floor(expiry / interval);
389
+ count = 1;
390
+ _d.label = 1;
391
+ case 1:
392
+ if (!(count <= maxCalls)) return [3, 9];
393
+ if (thunkApi.signal.aborted) {
394
+ return [3, 9];
395
+ }
396
+ return [4, API.authService.getVerifyAuth(authResponse === null || authResponse === void 0 ? void 0 : authResponse.auth_token)];
397
+ case 2:
398
+ data = _d.sent();
399
+ isSuccess = ((_c = data === null || data === void 0 ? void 0 : data.status) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'success';
400
+ if (!isSuccess) return [3, 6];
401
+ authId = data.id;
402
+ return [4, API.accountService.checkAccountAvailability(data.individual_id)];
403
+ case 3:
404
+ accountData = _d.sent();
405
+ _b = accountData || {}, step_name = _b.step_name, brands = _b.brands, entities = _b.entities;
406
+ brandList = brands || [];
407
+ entityList = entities || [];
408
+ isExistingUser = step_name === 'select_account';
409
+ if (!(isExistingUser && isDataHasIndividualOnly && authId)) return [3, 5];
410
+ return [4, thunkApi.dispatch(confirmInfo({ authId: authId }))];
411
+ case 4:
412
+ _d.sent();
413
+ return [2, { data: data, brandList: brandList, entityList: entityList }];
414
+ case 5:
415
+ if (isExistingUser && !isDataHasIndividualOnly && brandList.length && entityList.length) {
416
+ sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('AUTH_AUTHENTICATION_LIST_STEP')); });
417
+ return [2, { data: data, brandList: brandList, entityList: entityList }];
418
+ }
419
+ throw new Error(ACCOUNT_NOT_AVAILABLE);
420
+ case 6: return [4, sleep(interval * 1000)];
421
+ case 7:
422
+ _d.sent();
423
+ _d.label = 8;
424
+ case 8:
425
+ count++;
426
+ return [3, 1];
427
+ case 9: throw new Error('paci_verification_failed');
428
+ }
429
+ });
430
+ }); });
431
+ export var getMerchantList = createAsyncThunk('auth/getMerchantList', function (entityId) { return __awaiter(void 0, void 0, void 0, function () {
432
+ var merchants;
433
+ return __generator(this, function (_a) {
434
+ switch (_a.label) {
435
+ case 0: return [4, API.entityService.getMerchantListUsingEntityId(entityId)];
436
+ case 1:
437
+ merchants = (_a.sent()).merchants;
438
+ return [2, merchants || []];
439
+ }
440
+ });
441
+ }); });
442
+ export var confirmInfo = createAsyncThunk('auth/confirmInfo', function (_a, thunkApi) {
443
+ var brandInfo = _a.brandInfo, entityInfo = _a.entityInfo, merchantInfo = _a.merchantInfo, authId = _a.authId;
444
+ return __awaiter(void 0, void 0, void 0, function () {
445
+ var _b, auth, settings, authResponse, _c, postURL, redirectUrl, bi, authenticationId, body, data, urlQueryStart;
446
+ var _d, _e, _f;
447
+ return __generator(this, function (_g) {
448
+ switch (_g.label) {
449
+ case 0:
450
+ _b = thunkApi.getState(), auth = _b.auth, settings = _b.settings;
451
+ authResponse = ((_d = auth.data.responseData) !== null && _d !== void 0 ? _d : {}).authResponse;
452
+ _c = settings.data.appConfig, postURL = _c.postURL, redirectUrl = _c.redirectUrl;
453
+ bi = settings.data.deviceInfo.browser.browser_id;
454
+ authenticationId = authId || (authResponse === null || authResponse === void 0 ? void 0 : authResponse.id);
455
+ body = {
456
+ post_url: postURL || '',
457
+ authentication_id: authenticationId,
458
+ bi: bi,
459
+ brand_id: (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.id) || '',
460
+ merchant_id: (merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.id) || '',
461
+ entity_id: (entityInfo === null || entityInfo === void 0 ? void 0 : entityInfo.id) || '',
462
+ data: settings.data.appConfig.data || []
463
+ };
464
+ return [4, API.operatorService.confirm(body)];
465
+ case 1:
466
+ data = _g.sent();
467
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, data);
468
+ if (authenticationId) {
469
+ if (settings.data.appConfig.mode === 'popup') {
470
+ settings.data.appConfig.onFlowCompleted({ auth_id: authenticationId, bi: bi });
471
+ thunkApi.dispatch(handleOpen(false));
472
+ return [2];
473
+ }
474
+ if (redirectUrl) {
475
+ urlQueryStart = redirectUrl.includes('?') ? '&' : '?';
476
+ window.open("".concat(redirectUrl).concat(urlQueryStart, "authentication_id=").concat(authenticationId, "&bi=").concat(bi), '_self');
477
+ }
478
+ }
479
+ return [2];
480
+ }
481
+ });
482
+ });
483
+ });
484
+ var initialState = {
485
+ error: null,
486
+ loading: false,
487
+ customLoading: false,
488
+ data: {
489
+ isStartFromBusinessCountry: false,
490
+ flowName: FlowsTypes.AUTH,
491
+ mobileData: {
492
+ countryCode: defaultCountry,
493
+ mobile: '',
494
+ termAndConditionChecked: false
495
+ },
496
+ nidData: {
497
+ nid: '',
498
+ dob: '',
499
+ termAndConditionChecked: false
500
+ },
501
+ civilIdData: {
502
+ civilId: ''
503
+ },
504
+ otpData: {
505
+ otp: '',
506
+ authFor: AuthForType.MOBILE
507
+ },
508
+ authenticationData: {
509
+ brandInfo: undefined,
510
+ entityInfo: undefined,
511
+ merchantInfo: undefined
512
+ }
513
+ }
514
+ };
515
+ export var authSlice = createSlice({
516
+ name: 'auth/store',
517
+ initialState: initialState,
518
+ reducers: {
519
+ setLeadId: function (state, action) {
520
+ state.data.leadId = action.payload;
521
+ },
522
+ setMobileCountryCode: function (state, action) {
523
+ state.data.mobileData.countryCode = action.payload;
524
+ },
525
+ clearError: function (state) {
526
+ state.error = null;
527
+ },
528
+ storeIsStartFromBusinessCountry: function (state, action) {
529
+ state.data.isStartFromBusinessCountry = action.payload;
530
+ },
531
+ resetStore: function (state) {
532
+ state.data = __assign(__assign({}, state.data), { responseData: undefined });
533
+ },
534
+ resetOTPValue: function (state) {
535
+ state.data.otpData.otp = '';
536
+ }
537
+ },
538
+ extraReducers: function (builder) {
539
+ builder
540
+ .addCase(updateBusinessCountry.pending, function (state) {
541
+ state.loading = true;
542
+ state.error = null;
543
+ })
544
+ .addCase(updateBusinessCountry.rejected, function (state, action) {
545
+ state.loading = false;
546
+ state.error = action.error.message;
547
+ })
548
+ .addCase(updateBusinessCountry.fulfilled, function (state) {
549
+ state.loading = false;
550
+ state.error = null;
551
+ })
552
+ .addCase(retrieveLeadIdentityByIdAsync.pending, function (state) {
553
+ state.error = null;
554
+ state.customLoading = true;
555
+ })
556
+ .addCase(retrieveLeadIdentityByIdAsync.fulfilled, function (state, action) {
557
+ state.customLoading = false;
558
+ var _a = action.payload, data = _a.data, countryCode = _a.countryCode;
559
+ var _b = data || {}, identification = _b.identification, date_of_birth = _b.date_of_birth, contact = _b.contact;
560
+ if (identification === null || identification === void 0 ? void 0 : identification.id)
561
+ state.data.nidData.nid = identification === null || identification === void 0 ? void 0 : identification.id;
562
+ if (date_of_birth)
563
+ state.data.nidData.dob = date_of_birth;
564
+ var phone = (contact || {}).phone;
565
+ if (phone) {
566
+ state.data.mobileData.mobile = phone === null || phone === void 0 ? void 0 : phone.number;
567
+ state.data.mobileData.countryCode = countryCode;
568
+ }
569
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { leadResponse: data });
570
+ })
571
+ .addCase(retrieveLeadIdentityByIdAsync.rejected, function (state, action) {
572
+ state.customLoading = false;
573
+ state.error = action.error.message;
574
+ })
575
+ .addCase(createMobileAuth.pending, function (state) {
576
+ state.loading = true;
577
+ state.error = null;
578
+ })
579
+ .addCase(createMobileAuth.fulfilled, function (state, action) {
580
+ state.loading = false;
581
+ state.data.mobileData = action.payload.formData;
582
+ state.data.otpData.authFor = AuthForType.MOBILE;
583
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: action.payload.response });
584
+ })
585
+ .addCase(createMobileAuth.rejected, function (state, action) {
586
+ state.loading = false;
587
+ state.error = action.error.message;
588
+ })
589
+ .addCase(resendMobileAuthOTP.pending, function (state) {
590
+ state.error = null;
591
+ })
592
+ .addCase(resendMobileAuthOTP.fulfilled, function (state, action) {
593
+ state.data.mobileData = action.payload.formData;
594
+ state.data.otpData.authFor = AuthForType.MOBILE;
595
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: action.payload.response });
596
+ })
597
+ .addCase(resendMobileAuthOTP.rejected, function (state, action) {
598
+ state.error = action.error.message;
599
+ })
600
+ .addCase(verifyMobileOtp.pending, function (state) {
601
+ state.loading = true;
602
+ state.error = null;
603
+ })
604
+ .addCase(verifyMobileOtp.fulfilled, function (state, action) {
605
+ var _a;
606
+ state.loading = false;
607
+ var _b = action.payload, data = _b.data, brandList = _b.brandList, entityList = _b.entityList;
608
+ if (brandList === null || brandList === void 0 ? void 0 : brandList.length)
609
+ state.data.authenticationData.brandInfo = brandList[0];
610
+ if (entityList === null || entityList === void 0 ? void 0 : entityList.length)
611
+ state.data.authenticationData.entityInfo = entityList[0];
612
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: __assign(__assign({}, (_a = state.data.responseData) === null || _a === void 0 ? void 0 : _a.authResponse), data), brandList: brandList, entityList: entityList });
613
+ })
614
+ .addCase(verifyMobileOtp.rejected, function (state, action) {
615
+ state.loading = false;
616
+ state.error = action.error.message;
617
+ })
618
+ .addCase(createNIDAuth.pending, function (state) {
619
+ state.loading = true;
620
+ state.error = null;
621
+ })
622
+ .addCase(createNIDAuth.fulfilled, function (state, action) {
623
+ state.loading = false;
624
+ state.data.nidData = action.payload.formData;
625
+ state.data.otpData.authFor = AuthForType.NATIONAL_ID;
626
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: action.payload.response });
627
+ })
628
+ .addCase(createNIDAuth.rejected, function (state, action) {
629
+ state.loading = false;
630
+ state.error = action.error.message;
631
+ })
632
+ .addCase(resendNIDAuthOTP.pending, function (state) {
633
+ state.error = null;
634
+ })
635
+ .addCase(resendNIDAuthOTP.fulfilled, function (state, action) {
636
+ state.data.nidData = action.payload.formData;
637
+ state.data.otpData.authFor = AuthForType.NATIONAL_ID;
638
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: action.payload.response });
639
+ })
640
+ .addCase(resendNIDAuthOTP.rejected, function (state, action) {
641
+ state.error = action.error.message;
642
+ })
643
+ .addCase(verifyNIDOtp.pending, function (state) {
644
+ state.loading = true;
645
+ state.error = null;
646
+ })
647
+ .addCase(verifyNIDOtp.fulfilled, function (state, action) {
648
+ var _a;
649
+ state.loading = false;
650
+ var _b = action.payload, data = _b.data, brandList = _b.brandList, entityList = _b.entityList;
651
+ if (brandList === null || brandList === void 0 ? void 0 : brandList.length)
652
+ state.data.authenticationData.brandInfo = brandList[0];
653
+ if (entityList === null || entityList === void 0 ? void 0 : entityList.length)
654
+ state.data.authenticationData.entityInfo = entityList[0];
655
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: __assign(__assign({}, (_a = state.data.responseData) === null || _a === void 0 ? void 0 : _a.authResponse), data), brandList: brandList, entityList: entityList });
656
+ })
657
+ .addCase(verifyNIDOtp.rejected, function (state, action) {
658
+ state.loading = false;
659
+ state.error = action.error.message;
660
+ })
661
+ .addCase(createCivilIdAuth.pending, function (state) {
662
+ state.loading = true;
663
+ state.error = null;
664
+ })
665
+ .addCase(createCivilIdAuth.fulfilled, function (state, action) {
666
+ state.loading = false;
667
+ state.data.civilIdData = action.payload.formData;
668
+ state.data.otpData.authFor = AuthForType.NATIONAL_ID;
669
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: action.payload.response });
670
+ })
671
+ .addCase(createCivilIdAuth.rejected, function (state, action) {
672
+ state.loading = false;
673
+ state.error = action.error.message;
674
+ })
675
+ .addCase(verifyPACI.pending, function (state) {
676
+ state.loading = true;
677
+ state.error = null;
678
+ })
679
+ .addCase(verifyPACI.fulfilled, function (state, action) {
680
+ var _a;
681
+ state.loading = false;
682
+ var _b = action.payload, data = _b.data, brandList = _b.brandList, entityList = _b.entityList;
683
+ if (brandList === null || brandList === void 0 ? void 0 : brandList.length)
684
+ state.data.authenticationData.brandInfo = brandList[0];
685
+ if (entityList === null || entityList === void 0 ? void 0 : entityList.length)
686
+ state.data.authenticationData.entityInfo = entityList[0];
687
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { authResponse: __assign(__assign({}, (_a = state.data.responseData) === null || _a === void 0 ? void 0 : _a.authResponse), data), brandList: brandList, entityList: entityList });
688
+ })
689
+ .addCase(verifyPACI.rejected, function (state, action) {
690
+ state.loading = false;
691
+ state.error = action.error.message;
692
+ })
693
+ .addCase(getMerchantList.pending, function (state) {
694
+ state.merchantLoading = true;
695
+ state.error = null;
696
+ })
697
+ .addCase(getMerchantList.fulfilled, function (state, action) {
698
+ state.merchantLoading = false;
699
+ state.error = null;
700
+ var merchantList = action.payload;
701
+ if (merchantList === null || merchantList === void 0 ? void 0 : merchantList.length) {
702
+ state.data.authenticationData.merchantInfo = merchantList[0];
703
+ }
704
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { merchantList: merchantList });
705
+ })
706
+ .addCase(getMerchantList.rejected, function (state, action) {
707
+ state.merchantLoading = false;
708
+ state.error = action.error.message;
709
+ })
710
+ .addCase(confirmInfo.pending, function (state) {
711
+ state.loading = true;
712
+ state.error = null;
713
+ })
714
+ .addCase(confirmInfo.fulfilled, function (state) {
715
+ state.loading = false;
716
+ state.error = null;
717
+ })
718
+ .addCase(confirmInfo.rejected, function (state, action) {
719
+ state.loading = false;
720
+ state.error = action.error.message;
721
+ });
722
+ }
723
+ });
724
+ export var clearError = (_a = authSlice.actions, _a.clearError), resetStore = _a.resetStore, setMobileCountryCode = _a.setMobileCountryCode, setLeadId = _a.setLeadId, resetOTPValue = _a.resetOTPValue, storeIsStartFromBusinessCountry = _a.storeIsStartFromBusinessCountry;
725
+ export default authSlice.reducer;
726
+ export var authSelector = function (state) { return state.auth; };