@tap-payments/auth-jsconnect 2.8.83-development → 2.8.85-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ export declare const LOCAL_STORAGE_KEYS: {
10
10
  };
11
11
  export declare const SCOPE_AUTH = "auth";
12
12
  export declare const DEFAULT_COUNTRY_ISO2 = "KW";
13
+ export declare const NAFATH_VERIFICATION_FAILED = "nafath_verification_failed";
13
14
  export declare const EXTERNAL_LINKS: {
14
15
  TOS_EN: string;
15
16
  TOS_AR: string;
@@ -10,6 +10,7 @@ export var LOCAL_STORAGE_KEYS = {
10
10
  };
11
11
  export var SCOPE_AUTH = 'auth';
12
12
  export var DEFAULT_COUNTRY_ISO2 = 'KW';
13
+ export var NAFATH_VERIFICATION_FAILED = 'nafath_verification_failed';
13
14
  export var EXTERNAL_LINKS = {
14
15
  TOS_EN: '/en/terms-conditions',
15
16
  TOS_AR: '/ar/terms-conditions',
@@ -120,6 +120,7 @@ export declare const createNafathAuth: import("@reduxjs/toolkit").AsyncThunk<{
120
120
  }>;
121
121
  interface verifyNafathParams {
122
122
  onSuccess?: () => void;
123
+ onFailure?: () => void;
123
124
  }
124
125
  export declare const verifyNafath: import("@reduxjs/toolkit").AsyncThunk<any, verifyNafathParams, {
125
126
  state?: unknown;
@@ -57,7 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
57
57
  var _a;
58
58
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
59
59
  import { AuthForType, AuthTypeNumber, FlowsTypes, MigrationStatus } from '../../../@types';
60
- import { ADD_NEW_ENTITY, AUTH_STEP_NAMES, IDENTIFICATION_TYPE, SCOPE_AUTH, defaultCountry } from '../../../constants';
60
+ import { ADD_NEW_ENTITY, AUTH_STEP_NAMES, IDENTIFICATION_TYPE, NAFATH_VERIFICATION_FAILED, SCOPE_AUTH, defaultCountry } from '../../../constants';
61
61
  import API from '../../../api';
62
62
  import { handleCurrentActiveScreen, handleNextScreenStep, handleOpen, handlePrevScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
63
63
  import { findCountryByIddPrefix, openConnect, sendCustomEventToGTM, sleep } from '../../../utils';
@@ -396,10 +396,10 @@ export var createNafathAuth = createAsyncThunk('auth/createNafathAuth', function
396
396
  });
397
397
  }); });
398
398
  export var verifyNafath = createAsyncThunk('auth/verifyNafath', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
399
- var _a, settings, auth, authResponse, expiry, scope, interval, maxCalls, count, data, isSuccess;
400
- var _b, _c, _d;
401
- return __generator(this, function (_e) {
402
- switch (_e.label) {
399
+ var _a, settings, auth, authResponse, expiry, scope, interval, maxCalls, count, data, isSuccess, isFailed;
400
+ var _b, _c, _d, _e, _f;
401
+ return __generator(this, function (_g) {
402
+ switch (_g.label) {
403
403
  case 0:
404
404
  _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
405
405
  authResponse = (auth.data.responseData || {}).authResponse;
@@ -408,7 +408,7 @@ export var verifyNafath = createAsyncThunk('auth/verifyNafath', function (params
408
408
  interval = 3;
409
409
  maxCalls = Math.floor(expiry / interval);
410
410
  count = 1;
411
- _e.label = 1;
411
+ _g.label = 1;
412
412
  case 1:
413
413
  if (!(count <= maxCalls)) return [3, 5];
414
414
  if (thunkApi.signal.aborted) {
@@ -416,25 +416,30 @@ export var verifyNafath = createAsyncThunk('auth/verifyNafath', function (params
416
416
  }
417
417
  return [4, API.authService.getVerifyAuth(authResponse === null || authResponse === void 0 ? void 0 : authResponse.auth_token)];
418
418
  case 2:
419
- data = _e.sent();
419
+ data = _g.sent();
420
420
  isSuccess = ((_b = data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
421
+ isFailed = ((_c = data === null || data === void 0 ? void 0 : data.status) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'failed';
422
+ if (isFailed) {
423
+ (_d = params.onFailure) === null || _d === void 0 ? void 0 : _d.call(params);
424
+ return [2, data];
425
+ }
421
426
  if (isSuccess) {
422
427
  if (scope === 'merchant') {
423
428
  openConnect(settings.data.appConfig.publicKey, settings.data.businessCountry.iso2);
424
429
  return [2, data];
425
430
  }
426
- (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
431
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
427
432
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('AUTH_PREPARING_DATA_STEP')); });
428
433
  return [2, data];
429
434
  }
430
435
  return [4, sleep(interval * 1000)];
431
436
  case 3:
432
- _e.sent();
433
- _e.label = 4;
437
+ _g.sent();
438
+ _g.label = 4;
434
439
  case 4:
435
440
  count++;
436
441
  return [3, 1];
437
- case 5: throw new Error('nafath_verification_failed');
442
+ case 5: throw new Error(NAFATH_VERIFICATION_FAILED);
438
443
  }
439
444
  });
440
445
  }); });
@@ -59,10 +59,9 @@ export declare const verifyLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
59
59
  }>;
60
60
  interface verifyNafathParams {
61
61
  onSuccess?: () => void;
62
+ onFailure?: () => void;
62
63
  }
63
- export declare const verifyNafath: import("@reduxjs/toolkit").AsyncThunk<{
64
- response: any;
65
- }, verifyNafathParams, {
64
+ export declare const verifyNafath: import("@reduxjs/toolkit").AsyncThunk<any, verifyNafathParams, {
66
65
  state?: unknown;
67
66
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
68
67
  extra?: unknown;
@@ -58,7 +58,7 @@ var _a;
58
58
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
59
59
  import API from '../../../api';
60
60
  import { BusinessType, FlowsTypes, DocumentPurpose, LicenseType } from '../../../@types';
61
- import { BUSINESS_STEP_NAMES, EXPECTED_SALES_LIST, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_ENTITY_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
61
+ import { BUSINESS_STEP_NAMES, EXPECTED_SALES_LIST, IDENTIFICATION_TYPE, NAFATH_VERIFICATION_FAILED, OTHER_CR_LICENSE, OTHER_ENTITY_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
62
62
  import { convertNumbers2English, hasKey, sleep, isKW, isSA, dateFormat, isOtherLicense, isOtherThanKWOrSA, hasNoneEditableValue, sendCustomEventToGTM } from '../../../utils';
63
63
  import { handleNextScreenStep, handlePublicKey, handleSetCountryByIso2 } from '../../../app/settings';
64
64
  export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
@@ -308,10 +308,10 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
308
308
  });
309
309
  }); });
310
310
  export var verifyNafath = createAsyncThunk('business/verifyNafathParams', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
311
- var _a, settings, business, responseBody, expiry, interval, maxCalls, count, data, isSuccess;
312
- var _b, _c, _d, _e;
313
- return __generator(this, function (_f) {
314
- switch (_f.label) {
311
+ var _a, settings, business, responseBody, expiry, interval, maxCalls, count, data, isSuccess, isFailed;
312
+ var _b, _c, _d, _e, _f, _g;
313
+ return __generator(this, function (_h) {
314
+ switch (_h.label) {
315
315
  case 0:
316
316
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
317
317
  responseBody = business.data.nidData.responseBody;
@@ -322,32 +322,37 @@ export var verifyNafath = createAsyncThunk('business/verifyNafathParams', functi
322
322
  return [2, { response: null }];
323
323
  }
324
324
  count = 1;
325
- _f.label = 1;
325
+ _h.label = 1;
326
326
  case 1:
327
327
  if (!(count <= maxCalls)) return [3, 8];
328
328
  return [4, API.authService.getTokenVerify(responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token)];
329
329
  case 2:
330
- data = _f.sent();
330
+ data = _h.sent();
331
331
  isSuccess = ((_b = data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
332
+ isFailed = ((_c = data.status) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'failed';
333
+ if (isFailed) {
334
+ (_d = params.onFailure) === null || _d === void 0 ? void 0 : _d.call(params);
335
+ return [2, data];
336
+ }
332
337
  if (!isSuccess) return [3, 5];
333
338
  return [4, thunkApi.dispatch(retrieveEntityList({ leadId: responseBody === null || responseBody === void 0 ? void 0 : responseBody.id }))];
334
339
  case 3:
335
- _f.sent();
336
- (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, {});
337
- (_e = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _e === void 0 ? void 0 : _e.call(params);
340
+ _h.sent();
341
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, {});
342
+ (_g = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _g === void 0 ? void 0 : _g.call(params);
338
343
  return [4, sleep(3000)];
339
344
  case 4:
340
- _f.sent();
345
+ _h.sent();
341
346
  thunkApi.dispatch(handleNextScreenStep());
342
347
  return [2, { response: data }];
343
348
  case 5: return [4, sleep(interval * 1000)];
344
349
  case 6:
345
- _f.sent();
346
- _f.label = 7;
350
+ _h.sent();
351
+ _h.label = 7;
347
352
  case 7:
348
353
  count++;
349
354
  return [3, 1];
350
- case 8: throw new Error('nafath_verification_failed');
355
+ case 8: throw new Error(NAFATH_VERIFICATION_FAILED);
351
356
  }
352
357
  });
353
358
  }); });
@@ -98,8 +98,13 @@ export declare const verifyPACI: import("@reduxjs/toolkit").AsyncThunk<{
98
98
  }>;
99
99
  interface verifyNafathParams {
100
100
  onSuccess?: () => void;
101
+ onFailure?: () => void;
101
102
  }
102
103
  export declare const verifyNafath: import("@reduxjs/toolkit").AsyncThunk<{
104
+ authResponse: any;
105
+ countryCode: CountryCode;
106
+ leadResponse?: undefined;
107
+ } | {
103
108
  authResponse: any;
104
109
  leadResponse: any;
105
110
  countryCode: CountryCode;
@@ -68,7 +68,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
68
68
  var _a;
69
69
  import API from '../../../api';
70
70
  import { handleCurrentActiveScreen, handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
71
- import { CONNECT_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, OTHER_BRAND } from '../../../constants';
71
+ import { CONNECT_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, NAFATH_VERIFICATION_FAILED, OTHER_BRAND } from '../../../constants';
72
72
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
73
73
  import { AuthForType, FlowsTypes } from '../../../@types';
74
74
  import { capitalizeTheFirstLetterOfEachWord, concatenateObjectValues, findCountryByIddPrefix, fixBrandList, isTwitter, getIndividualName, isWebsite, sleep, sendCustomEventToGTM, isOtherThanKWOrSA, isKW, findCountryByIso2 } from '../../../utils';
@@ -359,10 +359,10 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
359
359
  });
360
360
  }); });
361
361
  export var verifyNafath = createAsyncThunk('connect/verifyNafath', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
362
- var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, lead_id, leadResponse, countryCode, channels, brand, err_5, brands, err_6, phone;
363
- var _b, _c, _d, _e, _f;
364
- return __generator(this, function (_g) {
365
- switch (_g.label) {
362
+ var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, isFailed, countryCode, lead_id, leadResponse, channels, brand, err_5, brands, err_6, phone;
363
+ var _b, _c, _d, _e, _f, _g, _h;
364
+ return __generator(this, function (_j) {
365
+ switch (_j.label) {
366
366
  case 0:
367
367
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
368
368
  responseBody = connect.data.nidData.responseBody;
@@ -370,7 +370,7 @@ export var verifyNafath = createAsyncThunk('connect/verifyNafath', function (par
370
370
  interval = 3;
371
371
  maxCalls = Math.floor(expiry / interval);
372
372
  count = 1;
373
- _g.label = 1;
373
+ _j.label = 1;
374
374
  case 1:
375
375
  if (!(count <= maxCalls)) return [3, 16];
376
376
  if (thunkApi.signal.aborted) {
@@ -378,62 +378,67 @@ export var verifyNafath = createAsyncThunk('connect/verifyNafath', function (par
378
378
  }
379
379
  return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
380
380
  case 2:
381
- authResponse = _g.sent();
381
+ authResponse = _j.sent();
382
382
  isSuccess = ((_b = authResponse.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
383
+ isFailed = ((_c = authResponse === null || authResponse === void 0 ? void 0 : authResponse.status) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'failed';
384
+ countryCode = settings.data.businessCountry;
385
+ if (isFailed) {
386
+ (_d = params.onFailure) === null || _d === void 0 ? void 0 : _d.call(params);
387
+ return [2, { authResponse: authResponse, countryCode: countryCode }];
388
+ }
383
389
  if (!isSuccess) return [3, 13];
384
390
  lead_id = authResponse.lead_id;
385
391
  if (!lead_id)
386
392
  throw new Error('Lead id is missing');
387
393
  return [4, API.leadService.retrieveLead(lead_id)];
388
394
  case 3:
389
- leadResponse = (_g.sent()).data;
390
- if ((_c = leadResponse.errors) === null || _c === void 0 ? void 0 : _c.length)
395
+ leadResponse = (_j.sent()).data;
396
+ if ((_e = leadResponse.errors) === null || _e === void 0 ? void 0 : _e.length)
391
397
  throw new Error(leadResponse.errors[0].description);
392
- countryCode = settings.data.businessCountry;
393
398
  return [4, API.dataService.getChannelsOfServices({ page: 0 })];
394
399
  case 4:
395
- channels = (_g.sent()).list;
400
+ channels = (_j.sent()).list;
396
401
  leadResponse.channel_list = channels;
397
- _g.label = 5;
402
+ _j.label = 5;
398
403
  case 5:
399
- _g.trys.push([5, 7, , 8]);
404
+ _j.trys.push([5, 7, , 8]);
400
405
  return [4, API.brandService.retrieveBrand(leadResponse.brand.id)];
401
406
  case 6:
402
- brand = (_g.sent()).brand;
407
+ brand = (_j.sent()).brand;
403
408
  leadResponse.brand = __assign(__assign({}, leadResponse.brand), brand);
404
409
  return [3, 8];
405
410
  case 7:
406
- err_5 = _g.sent();
411
+ err_5 = _j.sent();
407
412
  return [3, 8];
408
413
  case 8:
409
- _g.trys.push([8, 10, , 11]);
414
+ _j.trys.push([8, 10, , 11]);
410
415
  return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
411
416
  case 9:
412
- brands = (_g.sent()).brands;
417
+ brands = (_j.sent()).brands;
413
418
  leadResponse.brand_list = fixBrandList(brands, channels);
414
419
  return [3, 11];
415
420
  case 10:
416
- err_6 = _g.sent();
421
+ err_6 = _j.sent();
417
422
  return [3, 11];
418
423
  case 11:
419
- (_d = params.onSuccess) === null || _d === void 0 ? void 0 : _d.call(params);
424
+ (_f = params.onSuccess) === null || _f === void 0 ? void 0 : _f.call(params);
420
425
  return [4, sleep(3000)];
421
426
  case 12:
422
- _g.sent();
427
+ _j.sent();
423
428
  phone = (leadResponse.contact || {}).phone;
424
429
  if (phone === null || phone === void 0 ? void 0 : phone.country_code)
425
430
  countryCode = findCountryByIddPrefix(settings.data.countries, phone.country_code);
426
- (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, {});
431
+ (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, {});
427
432
  thunkApi.dispatch(handleNextScreenStep());
428
433
  return [2, { authResponse: authResponse, leadResponse: leadResponse, countryCode: countryCode }];
429
434
  case 13: return [4, sleep(interval * 1000)];
430
435
  case 14:
431
- _g.sent();
432
- _g.label = 15;
436
+ _j.sent();
437
+ _j.label = 15;
433
438
  case 15:
434
439
  count++;
435
440
  return [3, 1];
436
- case 16: throw new Error('nafath_verification_failed');
441
+ case 16: throw new Error(NAFATH_VERIFICATION_FAILED);
437
442
  }
438
443
  });
439
444
  }); });
@@ -920,8 +925,8 @@ export var connectSlice = createSlice({
920
925
  state.loading = false;
921
926
  state.error = null;
922
927
  var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse, countryCode = _b.countryCode;
923
- var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, is_new_individual = leadResponse.is_new_individual, id = leadResponse.id;
924
- var _c = contact || {}, email = _c.email, phone = _c.phone;
928
+ var _c = leadResponse || {}, name = _c.name, contact = _c.contact, brand = _c.brand, brand_list = _c.brand_list, channel_list = _c.channel_list, is_new_individual = _c.is_new_individual, id = _c.id;
929
+ var _d = contact || {}, email = _d.email, phone = _d.phone;
925
930
  var fullName = concatenateObjectValues(name, ['first', 'middle', 'last']);
926
931
  if (!!fullName) {
927
932
  var capitalizedName = capitalizeTheFirstLetterOfEachWord(fullName);
@@ -298,6 +298,7 @@ export declare const createEntity: import("@reduxjs/toolkit").AsyncThunk<{
298
298
  }>;
299
299
  interface verifyPACIAsyncParams {
300
300
  onSuccess: () => void;
301
+ onFailure?: () => void;
301
302
  }
302
303
  export declare const updateLeadIndividualAsync: import("@reduxjs/toolkit").AsyncThunk<{
303
304
  response: any;
@@ -59,7 +59,7 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
59
59
  import { handleNextScreenStep, handleCurrentActiveScreen, handleOpen, handleSetCountryByIso2, onCloseComplete, storeAuthId } from '../../../app/settings';
60
60
  import { FlowsTypes, AuthForType, BusinessType, LicenseType } from '../../../@types';
61
61
  import API from '../../../api';
62
- import { ADD_NEW_ENTITY, CONNECT_EXPRESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE, SCOPE_AUTH } from '../../../constants';
62
+ import { ADD_NEW_ENTITY, CONNECT_EXPRESS_STEP_NAMES, IDENTIFICATION_TYPE, NAFATH_VERIFICATION_FAILED, OTHER_CR_LICENSE, OTHER_FL_LICENSE, SCOPE_AUTH } from '../../../constants';
63
63
  import { defaultCountry } from '../../../constants';
64
64
  import { getIndividualName, capitalizeTheFirstLetterOfEachWord, sleep, findCountryByIddPrefix, concatenateObjectValues, isSA, isKW, isOtherThanKWOrSA, sendCustomEventToGTM, sendCustomDimension } from '../../../utils';
65
65
  export var updateBusinessCountryAsync = createAsyncThunk('connectExpress/updateBusinessCountryAsync', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
@@ -340,10 +340,10 @@ export var createNafathAuth = createAsyncThunk('connectExpress/createNafathAuth'
340
340
  });
341
341
  }); });
342
342
  export var verifyNafathAsync = createAsyncThunk('connectExpress/verifyNafathAsync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
343
- var _a, settings, connectExpress, authData, _b, scope, redirectUrl, authConfigData, isScopeAuthentication, bi, isDataHasIndividualOnly, authDataHasValue, expiry, interval, maxCalls, count, data, isSuccess, authId, urlQueryStart, _c, brandList, entityList, stepName, needToCollectMoreInfo, creatingAccount;
344
- var _d, _e, _f, _g, _h;
345
- return __generator(this, function (_j) {
346
- switch (_j.label) {
343
+ var _a, settings, connectExpress, authData, _b, scope, redirectUrl, authConfigData, isScopeAuthentication, bi, isDataHasIndividualOnly, authDataHasValue, expiry, interval, maxCalls, count, data, isSuccess, isFailed, authId, leadId, urlQueryStart, _c, brandList, entityList, stepName, needToCollectMoreInfo, creatingAccount;
344
+ var _d, _e, _f, _g, _h, _j, _k, _l;
345
+ return __generator(this, function (_m) {
346
+ switch (_m.label) {
347
347
  case 0:
348
348
  _a = thunkApi.getState(), settings = _a.settings, connectExpress = _a.connectExpress;
349
349
  authData = (connectExpress.data.responseData || {}).authData;
@@ -356,7 +356,7 @@ export var verifyNafathAsync = createAsyncThunk('connectExpress/verifyNafathAsyn
356
356
  interval = 3;
357
357
  maxCalls = Math.floor(expiry / interval);
358
358
  count = 1;
359
- _j.label = 1;
359
+ _m.label = 1;
360
360
  case 1:
361
361
  if (!(count <= maxCalls)) return [3, 9];
362
362
  if (thunkApi.signal.aborted) {
@@ -364,10 +364,16 @@ export var verifyNafathAsync = createAsyncThunk('connectExpress/verifyNafathAsyn
364
364
  }
365
365
  return [4, API.authService.getVerifyExpressAuth(authData === null || authData === void 0 ? void 0 : authData.auth_token)];
366
366
  case 2:
367
- data = _j.sent();
367
+ data = _m.sent();
368
368
  isSuccess = ((_e = (_d = data.auth) === null || _d === void 0 ? void 0 : _d.status) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === 'success';
369
+ isFailed = ((_g = (_f = data.auth) === null || _f === void 0 ? void 0 : _f.status) === null || _g === void 0 ? void 0 : _g.toLowerCase()) === 'failed';
370
+ if (isFailed) {
371
+ (_h = params.onFailure) === null || _h === void 0 ? void 0 : _h.call(params);
372
+ return [2, data];
373
+ }
369
374
  if (!isSuccess) return [3, 6];
370
- authId = (_f = data.auth) === null || _f === void 0 ? void 0 : _f.id;
375
+ authId = (_j = data.auth) === null || _j === void 0 ? void 0 : _j.id;
376
+ leadId = (_k = data.auth) === null || _k === void 0 ? void 0 : _k.lead_id;
371
377
  thunkApi.dispatch(storeAuthId(authId));
372
378
  if (isScopeAuthentication && !data.new_user && isDataHasIndividualOnly && authId) {
373
379
  if (settings.data.appConfig.mode === 'popup') {
@@ -384,19 +390,19 @@ export var verifyNafathAsync = createAsyncThunk('connectExpress/verifyNafathAsyn
384
390
  if (!(isScopeAuthentication && !data.new_user && authDataHasValue)) return [3, 4];
385
391
  return [4, thunkApi.dispatch(retrieveAuthenticationListAsync({ individualId: data.individual_id })).unwrap()];
386
392
  case 3:
387
- _c = _j.sent(), brandList = _c.brandList, entityList = _c.entityList;
393
+ _c = _m.sent(), brandList = _c.brandList, entityList = _c.entityList;
388
394
  if (brandList.length && entityList.length) {
389
395
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('CONNECT_EXPRESS_AUTHENTICATION_LIST_STEP')); });
390
396
  return [2, data];
391
397
  }
392
- _j.label = 4;
393
- case 4: return [4, thunkApi.dispatch(getLeadByIdAsync((_g = data.lead) === null || _g === void 0 ? void 0 : _g.id)).unwrap()];
398
+ _m.label = 4;
399
+ case 4: return [4, thunkApi.dispatch(getLeadByIdAsync(leadId)).unwrap()];
394
400
  case 5:
395
- _j.sent();
401
+ _m.sent();
396
402
  stepName = data.step_name;
397
403
  needToCollectMoreInfo = stepName === 'collect_info';
398
404
  creatingAccount = stepName === 'create_account';
399
- (_h = params.onSuccess) === null || _h === void 0 ? void 0 : _h.call(params);
405
+ (_l = params.onSuccess) === null || _l === void 0 ? void 0 : _l.call(params);
400
406
  if (creatingAccount) {
401
407
  sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_WAITING_FOR_CREATING_ACCOUNT_STEP')); });
402
408
  }
@@ -406,12 +412,12 @@ export var verifyNafathAsync = createAsyncThunk('connectExpress/verifyNafathAsyn
406
412
  return [2, data];
407
413
  case 6: return [4, sleep(interval * 1000)];
408
414
  case 7:
409
- _j.sent();
410
- _j.label = 8;
415
+ _m.sent();
416
+ _m.label = 8;
411
417
  case 8:
412
418
  count++;
413
419
  return [3, 1];
414
- case 9: throw new Error('nafath_verification_failed');
420
+ case 9: throw new Error(NAFATH_VERIFICATION_FAILED);
415
421
  }
416
422
  });
417
423
  }); });
@@ -669,10 +675,10 @@ export var createNIDNafathAuthIdentityAsync = createAsyncThunk('connectExpress/c
669
675
  });
670
676
  }); });
671
677
  export var verifyNafathIdentityAsync = createAsyncThunk('connectExpress/verifyNafathIdentityAsync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
672
- var connectExpress, authData, expiry, interval, maxCalls, count, data, isSuccess, needToCollectMoreInfo, creatingAccount;
673
- var _a, _b, _c, _d;
674
- return __generator(this, function (_e) {
675
- switch (_e.label) {
678
+ var connectExpress, authData, expiry, interval, maxCalls, count, data, isSuccess, isFailed, needToCollectMoreInfo, creatingAccount;
679
+ var _a, _b, _c, _d, _e, _f, _g;
680
+ return __generator(this, function (_h) {
681
+ switch (_h.label) {
676
682
  case 0:
677
683
  connectExpress = thunkApi.getState().connectExpress;
678
684
  authData = (connectExpress.data.responseData || {}).authData;
@@ -680,7 +686,7 @@ export var verifyNafathIdentityAsync = createAsyncThunk('connectExpress/verifyNa
680
686
  interval = 3;
681
687
  maxCalls = Math.floor(expiry / interval);
682
688
  count = 1;
683
- _e.label = 1;
689
+ _h.label = 1;
684
690
  case 1:
685
691
  if (!(count <= maxCalls)) return [3, 7];
686
692
  if (thunkApi.signal.aborted) {
@@ -688,15 +694,20 @@ export var verifyNafathIdentityAsync = createAsyncThunk('connectExpress/verifyNa
688
694
  }
689
695
  return [4, API.authService.getExpressTokenVerify({ token: authData === null || authData === void 0 ? void 0 : authData.verify_token, leadId: authData === null || authData === void 0 ? void 0 : authData.lead_id })];
690
696
  case 2:
691
- data = _e.sent();
697
+ data = _h.sent();
692
698
  isSuccess = ((_b = (_a = data.auth) === null || _a === void 0 ? void 0 : _a.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
699
+ isFailed = ((_d = (_c = data.auth) === null || _c === void 0 ? void 0 : _c.status) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === 'failed';
700
+ if (isFailed) {
701
+ (_e = params.onFailure) === null || _e === void 0 ? void 0 : _e.call(params);
702
+ return [2, data];
703
+ }
693
704
  if (!isSuccess) return [3, 4];
694
- return [4, thunkApi.dispatch(getLeadByIdAsync((_c = data.lead) === null || _c === void 0 ? void 0 : _c.id)).unwrap()];
705
+ return [4, thunkApi.dispatch(getLeadByIdAsync((_f = data.auth) === null || _f === void 0 ? void 0 : _f.lead_id)).unwrap()];
695
706
  case 3:
696
- _e.sent();
707
+ _h.sent();
697
708
  needToCollectMoreInfo = data.step_name === 'collect_info';
698
709
  creatingAccount = data.step_name === 'create_account';
699
- (_d = params.onSuccess) === null || _d === void 0 ? void 0 : _d.call(params);
710
+ (_g = params.onSuccess) === null || _g === void 0 ? void 0 : _g.call(params);
700
711
  if (creatingAccount) {
701
712
  sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_WAITING_FOR_CREATING_ACCOUNT_STEP')); });
702
713
  }
@@ -706,12 +717,12 @@ export var verifyNafathIdentityAsync = createAsyncThunk('connectExpress/verifyNa
706
717
  return [2, data];
707
718
  case 4: return [4, sleep(interval * 1000)];
708
719
  case 5:
709
- _e.sent();
710
- _e.label = 6;
720
+ _h.sent();
721
+ _h.label = 6;
711
722
  case 6:
712
723
  count++;
713
724
  return [3, 1];
714
- case 7: throw new Error('nafath_verification_failed');
725
+ case 7: throw new Error(NAFATH_VERIFICATION_FAILED);
715
726
  }
716
727
  });
717
728
  }); });
@@ -758,7 +769,7 @@ export var verifyPaciLeadIdentityAsync = createAsyncThunk('connectExpress/verify
758
769
  case 6:
759
770
  count++;
760
771
  return [3, 1];
761
- case 7: throw new Error('nafath_verification_failed');
772
+ case 7: throw new Error('paci_verification_failed');
762
773
  }
763
774
  });
764
775
  }); });
@@ -7,10 +7,11 @@ import { useAppDispatch, useAppSelector } from '../../../../hooks';
7
7
  var VerifyNafath = function () {
8
8
  var _a;
9
9
  var _b = React.useState(false), success = _b[0], setSuccess = _b[1];
10
- var _c = React.useState(false), isReady = _c[0], setIsReady = _c[1];
10
+ var _c = React.useState(false), failed = _c[0], setFailed = _c[1];
11
+ var _d = React.useState(false), isReady = _d[0], setIsReady = _d[1];
11
12
  var dispatch = useAppDispatch();
12
13
  var data = useAppSelector(authSelector).data;
13
- var _d = ((_a = data.responseData) === null || _a === void 0 ? void 0 : _a.authResponse) || {}, expiry = _d.expiry, app_url_android = _d.app_url_android, app_url_ios = _d.app_url_ios, random = _d.random;
14
+ var _e = ((_a = data.responseData) === null || _a === void 0 ? void 0 : _a.authResponse) || {}, expiry = _e.expiry, app_url_android = _e.app_url_android, app_url_ios = _e.app_url_ios, random = _e.random;
14
15
  React.useEffect(function () {
15
16
  if (data.responseData && !isReady) {
16
17
  setIsReady(true);
@@ -19,7 +20,7 @@ var VerifyNafath = function () {
19
20
  React.useEffect(function () {
20
21
  if (!isReady)
21
22
  return;
22
- var promise = dispatch(verifyNafathFun({ onSuccess: function () { return setSuccess(true); } }));
23
+ var promise = dispatch(verifyNafathFun({ onSuccess: function () { return setSuccess(true); }, onFailure: function () { return setFailed(true); } }));
23
24
  return function () {
24
25
  promise === null || promise === void 0 ? void 0 : promise.abort();
25
26
  };
@@ -29,6 +30,6 @@ var VerifyNafath = function () {
29
30
  }, []);
30
31
  if (!isReady)
31
32
  return null;
32
- return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
+ return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, failed: failed, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
34
  };
34
35
  export default React.memo(VerifyNafath);
@@ -6,11 +6,12 @@ import { handlePrevScreenStep } from '../../../../app/settings';
6
6
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
7
7
  var VerifyNafath = function () {
8
8
  var _a = React.useState(false), success = _a[0], setSuccess = _a[1];
9
- var _b = React.useState(false), isReady = _b[0], setIsReady = _b[1];
9
+ var _b = React.useState(false), failed = _b[0], setFailed = _b[1];
10
+ var _c = React.useState(false), isReady = _c[0], setIsReady = _c[1];
10
11
  var dispatch = useAppDispatch();
11
12
  var data = useAppSelector(businessSelector).data;
12
13
  var responseBody = data.nidData.responseBody;
13
- var _c = responseBody || {}, expiry = _c.expiry, app_url_android = _c.app_url_android, app_url_ios = _c.app_url_ios, random = _c.random;
14
+ var _d = responseBody || {}, expiry = _d.expiry, app_url_android = _d.app_url_android, app_url_ios = _d.app_url_ios, random = _d.random;
14
15
  React.useEffect(function () {
15
16
  if (responseBody && !isReady) {
16
17
  setIsReady(true);
@@ -19,7 +20,7 @@ var VerifyNafath = function () {
19
20
  React.useEffect(function () {
20
21
  if (!isReady)
21
22
  return;
22
- var promise = dispatch(verifyNafath({ onSuccess: function () { return setSuccess(true); } }));
23
+ var promise = dispatch(verifyNafath({ onSuccess: function () { return setSuccess(true); }, onFailure: function () { return setFailed(true); } }));
23
24
  return function () {
24
25
  promise === null || promise === void 0 ? void 0 : promise.abort();
25
26
  };
@@ -29,6 +30,6 @@ var VerifyNafath = function () {
29
30
  }, []);
30
31
  if (!isReady)
31
32
  return null;
32
- return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
+ return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, failed: failed, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
34
  };
34
35
  export default React.memo(VerifyNafath);
@@ -6,11 +6,12 @@ import { handlePrevScreenStep } from '../../../../app/settings';
6
6
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
7
7
  var VerifyNafath = function () {
8
8
  var _a = React.useState(false), success = _a[0], setSuccess = _a[1];
9
- var _b = React.useState(false), isReady = _b[0], setIsReady = _b[1];
9
+ var _b = React.useState(false), failed = _b[0], setFailed = _b[1];
10
+ var _c = React.useState(false), isReady = _c[0], setIsReady = _c[1];
10
11
  var dispatch = useAppDispatch();
11
12
  var data = useAppSelector(connectSelector).data;
12
13
  var responseBody = data.nidData.responseBody;
13
- var _c = responseBody || {}, expiry = _c.expiry, app_url_android = _c.app_url_android, app_url_ios = _c.app_url_ios, random = _c.random;
14
+ var _d = responseBody || {}, expiry = _d.expiry, app_url_android = _d.app_url_android, app_url_ios = _d.app_url_ios, random = _d.random;
14
15
  React.useEffect(function () {
15
16
  if (responseBody && !isReady) {
16
17
  setIsReady(true);
@@ -19,7 +20,7 @@ var VerifyNafath = function () {
19
20
  React.useEffect(function () {
20
21
  if (!isReady)
21
22
  return;
22
- var promise = dispatch(verifyNafathFun({ onSuccess: function () { return setSuccess(true); } }));
23
+ var promise = dispatch(verifyNafathFun({ onSuccess: function () { return setSuccess(true); }, onFailure: function () { return setFailed(true); } }));
23
24
  return function () {
24
25
  promise === null || promise === void 0 ? void 0 : promise.abort();
25
26
  };
@@ -29,6 +30,6 @@ var VerifyNafath = function () {
29
30
  }, []);
30
31
  if (!isReady)
31
32
  return null;
32
- return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
+ return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, failed: failed, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
34
  };
34
35
  export default React.memo(VerifyNafath);
@@ -6,11 +6,12 @@ import { handlePrevScreenStep } from '../../../../app/settings';
6
6
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
7
7
  var IdentityVerifyNafath = function () {
8
8
  var _a = React.useState(false), success = _a[0], setSuccess = _a[1];
9
- var _b = React.useState(false), isReady = _b[0], setIsReady = _b[1];
9
+ var _b = React.useState(false), failed = _b[0], setFailed = _b[1];
10
+ var _c = React.useState(false), isReady = _c[0], setIsReady = _c[1];
10
11
  var dispatch = useAppDispatch();
11
12
  var data = useAppSelector(connectExpressSelector).data;
12
13
  var authData = (data.responseData || {}).authData;
13
- var _c = authData || {}, expiry = _c.expiry, app_url_android = _c.app_url_android, app_url_ios = _c.app_url_ios, random = _c.random;
14
+ var _d = authData || {}, expiry = _d.expiry, app_url_android = _d.app_url_android, app_url_ios = _d.app_url_ios, random = _d.random;
14
15
  React.useEffect(function () {
15
16
  if (authData && !isReady) {
16
17
  setIsReady(true);
@@ -19,7 +20,7 @@ var IdentityVerifyNafath = function () {
19
20
  React.useEffect(function () {
20
21
  if (!isReady)
21
22
  return;
22
- var promise = dispatch(verifyNafathIdentityAsync({ onSuccess: function () { return setSuccess(true); } }));
23
+ var promise = dispatch(verifyNafathIdentityAsync({ onSuccess: function () { return setSuccess(true); }, onFailure: function () { return setFailed(true); } }));
23
24
  return function () {
24
25
  promise === null || promise === void 0 ? void 0 : promise.abort();
25
26
  };
@@ -29,6 +30,6 @@ var IdentityVerifyNafath = function () {
29
30
  }, []);
30
31
  if (!isReady)
31
32
  return null;
32
- return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
+ return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, failed: failed, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
34
  };
34
35
  export default React.memo(IdentityVerifyNafath);
@@ -6,11 +6,12 @@ import { handlePrevScreenStep } from '../../../../app/settings';
6
6
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
7
7
  var VerifyNafath = function () {
8
8
  var _a = React.useState(false), success = _a[0], setSuccess = _a[1];
9
- var _b = React.useState(false), isReady = _b[0], setIsReady = _b[1];
9
+ var _b = React.useState(false), failed = _b[0], setFailed = _b[1];
10
+ var _c = React.useState(false), isReady = _c[0], setIsReady = _c[1];
10
11
  var dispatch = useAppDispatch();
11
12
  var data = useAppSelector(connectExpressSelector).data;
12
13
  var authData = (data.responseData || {}).authData;
13
- var _c = authData || {}, expiry = _c.expiry, app_url_android = _c.app_url_android, app_url_ios = _c.app_url_ios, random = _c.random;
14
+ var _d = authData || {}, expiry = _d.expiry, app_url_android = _d.app_url_android, app_url_ios = _d.app_url_ios, random = _d.random;
14
15
  React.useEffect(function () {
15
16
  if (authData && !isReady) {
16
17
  setIsReady(true);
@@ -19,7 +20,7 @@ var VerifyNafath = function () {
19
20
  React.useEffect(function () {
20
21
  if (!isReady)
21
22
  return;
22
- var promise = dispatch(verifyNafathAsync({ onSuccess: function () { return setSuccess(true); } }));
23
+ var promise = dispatch(verifyNafathAsync({ onSuccess: function () { return setSuccess(true); }, onFailure: function () { return setFailed(true); } }));
23
24
  return function () {
24
25
  promise === null || promise === void 0 ? void 0 : promise.abort();
25
26
  };
@@ -29,6 +30,6 @@ var VerifyNafath = function () {
29
30
  }, []);
30
31
  if (!isReady)
31
32
  return null;
32
- return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
+ return (_jsx(NafathVerification, { randomNumber: random, expiryInSeconds: expiry, success: success, failed: failed, urls: { android: app_url_android, ios: app_url_ios }, onFinish: function () { return onBack(); } }));
33
34
  };
34
35
  export default React.memo(VerifyNafath);
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  export interface VerifyNafathProps {
3
3
  randomNumber: string;
4
4
  success: boolean;
5
+ failed?: boolean;
5
6
  expiryInSeconds: number;
6
7
  urls?: {
7
8
  android: string;
@@ -9,5 +10,5 @@ export interface VerifyNafathProps {
9
10
  };
10
11
  onFinish?: () => void;
11
12
  }
12
- declare const _default: React.MemoExoticComponent<({ randomNumber, success, expiryInSeconds, urls, onFinish }: VerifyNafathProps) => import("react/jsx-runtime").JSX.Element>;
13
+ declare const _default: React.MemoExoticComponent<({ randomNumber, success, failed, expiryInSeconds, urls, onFinish }: VerifyNafathProps) => import("react/jsx-runtime").JSX.Element>;
13
14
  export default _default;
@@ -18,7 +18,7 @@ import Text from '../../../components/Text';
18
18
  import { ScreenContainer } from '../../shared/Containers';
19
19
  import { MobileButton } from '../../shared/Button';
20
20
  import { mobileOS } from '../../../utils';
21
- import { useCountUp } from '../../../hooks';
21
+ import { useCountDown, useCountUp } from '../../../hooks';
22
22
  import VerifyNafathLoading from './VerifyNafathLoading';
23
23
  import VerifyNafathSuccess from './VerifyNafathSuccess';
24
24
  var VerifyNafathTitleContainerStyled = styled(Box)(function (_a) {
@@ -51,16 +51,16 @@ var Container = styled(Box)(function (_a) {
51
51
  });
52
52
  });
53
53
  var VerifyNafath = function (_a) {
54
- var randomNumber = _a.randomNumber, success = _a.success, expiryInSeconds = _a.expiryInSeconds, urls = _a.urls, onFinish = _a.onFinish;
54
+ var randomNumber = _a.randomNumber, success = _a.success, failed = _a.failed, expiryInSeconds = _a.expiryInSeconds, urls = _a.urls, onFinish = _a.onFinish;
55
55
  var t = useTranslation().t;
56
56
  var count = useCountUp({ start: 0, end: expiryInSeconds, sleepMS: 1000 }).count;
57
57
  var errorWaitingTime = 3;
58
+ var failedCount = useCountDown({ startTimer: !!failed, start: errorWaitingTime, end: 0, sleepMS: 1000 }).count;
58
59
  var phases = 2;
59
60
  var remainingTime = expiryInSeconds - errorWaitingTime;
60
61
  var phaseNumber = Math.floor((count / remainingTime) * phases) + 1;
61
- var isEnded = count === expiryInSeconds;
62
+ var isEnded = failed ? failedCount === 0 : count === expiryInSeconds;
62
63
  var endPhaseStarted = count >= remainingTime;
63
- console.log('VerifyNafath', VerifyNafath);
64
64
  React.useEffect(function () {
65
65
  if (isEnded && onFinish)
66
66
  onFinish();
@@ -86,7 +86,7 @@ var VerifyNafath = function (_a) {
86
86
  return 'nafath_verification_description_wait';
87
87
  return 'nafath_verification_description_check';
88
88
  }, [phaseNumber]);
89
- var isErrorPhase = endPhaseStarted && !success;
89
+ var isErrorPhase = (endPhaseStarted && !success) || failed;
90
90
  return (_jsxs(ScreenContainer, __assign({ sx: { mb: 2.5 } }, { children: [_jsxs(VerifyNafathTitleContainerStyled, { children: [_jsx(Container, { children: success ? _jsx(VerifyNafathSuccess, {}) : _jsx(VerifyNafathLoading, { randomNumber: randomNumber, type: isErrorPhase ? 3 : phaseNumber }) }), isErrorPhase ? (_jsxs(_Fragment, { children: [_jsx(VerifyNafathTitleStyled, { children: t('nafath_verification_title_error') }), _jsx(VerifyNafathSubTitleStyled, __assign({ sx: { pb: 1 } }, { children: t('nafath_verification_description_error') })), _jsx(VerifyNafathSubTitleStyled, { children: t('nafath_verification_redirection_message') })] })) : (_jsxs(_Fragment, { children: [_jsx(VerifyNafathTitleStyled, { children: t(title) }), _jsx(VerifyNafathSubTitleStyled, { children: t(description) })] }))] }), (isAndroid || isIOS) && (_jsx(MobileButton, __assign({ onClick: onRedirect, hideIcon: true }, { children: t('open_nafath_app') })))] })));
91
91
  };
92
92
  export default React.memo(VerifyNafath);
@@ -13,6 +13,7 @@ export * from './useStepStartedListener';
13
13
  export * from './useScreen';
14
14
  export * from './useSetFromDefaultValues';
15
15
  export * from './useCountUp';
16
+ export * from './useCountDown';
16
17
  export * from './useCountry';
17
18
  export * from './useVerifyToken';
18
19
  export * from './useFormReadOnly';
@@ -13,6 +13,7 @@ export * from './useStepStartedListener';
13
13
  export * from './useScreen';
14
14
  export * from './useSetFromDefaultValues';
15
15
  export * from './useCountUp';
16
+ export * from './useCountDown';
16
17
  export * from './useCountry';
17
18
  export * from './useVerifyToken';
18
19
  export * from './useFormReadOnly';
@@ -0,0 +1,10 @@
1
+ interface CountDownOptions {
2
+ end?: number;
3
+ start: number;
4
+ startTimer: boolean;
5
+ sleepMS?: number;
6
+ }
7
+ export declare const useCountDown: ({ end, start, startTimer, sleepMS }: CountDownOptions) => {
8
+ count: number;
9
+ };
10
+ export {};
@@ -0,0 +1,17 @@
1
+ import { useEffect, useState } from 'react';
2
+ export var useCountDown = function (_a) {
3
+ var _b = _a.end, end = _b === void 0 ? 0 : _b, start = _a.start, startTimer = _a.startTimer, _c = _a.sleepMS, sleepMS = _c === void 0 ? 0 : _c;
4
+ var _d = useState(start), count = _d[0], setCount = _d[1];
5
+ var decrement = function () {
6
+ setCount(count - 1);
7
+ };
8
+ useEffect(function () {
9
+ if (count === end || !startTimer)
10
+ return;
11
+ var timer = setTimeout(function () {
12
+ decrement();
13
+ }, sleepMS);
14
+ return function () { return clearTimeout(timer); };
15
+ }, [count, startTimer]);
16
+ return { count: count };
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.8.83-development",
3
+ "version": "2.8.85-development",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",