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