@tap-payments/auth-jsconnect 2.11.24-development → 2.11.26-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.
@@ -3,3 +3,4 @@ export declare const getAuthHeaders: (authSession?: string) => {
3
3
  } | {
4
4
  st?: undefined;
5
5
  };
6
+ export declare const setAuthSessionToGlobalHeaders: (authSession?: string) => void;
@@ -1,3 +1,18 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { getAxiosHeaders, setAxiosGlobalHeaders } from './axios';
1
13
  export var getAuthHeaders = function (authSession) {
2
14
  return authSession ? { st: authSession } : {};
3
15
  };
16
+ export var setAuthSessionToGlobalHeaders = function (authSession) {
17
+ setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), (authSession && { st: authSession })));
18
+ };
@@ -14,6 +14,7 @@ import { UploadFileBody } from './file';
14
14
  import { DocumentUpdateBody, DocumentInfo, DocumentBody } from './document';
15
15
  import { InitBody } from './init';
16
16
  import { GenerateAuthLinkNewTerminalProps, UnlinkTerminalDeviceProps, LinkTerminalDeviceProps } from './terminal';
17
+ import { setAuthSessionToGlobalHeaders } from './headers';
17
18
  declare const API: {
18
19
  locationService: {
19
20
  getIP: () => Promise<any>;
@@ -172,5 +173,5 @@ declare const API: {
172
173
  };
173
174
  };
174
175
  export type { ValidateOperatorBody, CreateAuthBody, ExpressCreateAccountBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoBody, CreateAccountBody, EntityBankUpdateBody, CreatePasswordBody, BrandListBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, UpdateBoardBody, UpdateBrandBody, DataElementBody, UploadFileBody, UpdateEntityBody, DocumentUpdateBody, DocumentInfo, VerifyAuthExpressOTPBody, UpdateIndividualBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, BankDocumentInfo, GetUserListBody, GetIndividualListBody, RequestEmailBody, DocumentBody, UpdateEntityAOAFileBody, InitBody, RemoveBrandActivity, RemoveEntityActivity, UpdateIndividualWithTypeBody, UpdateMultipleIndividualBody, ExpressLeadVerifyBody, ConfirmBody, ConfigBody, MerchantListBody, CreateEntityBody, CreateNafathAuthBody, GetUserListSegmentBody, CreateKYCAuthBody, GenerateAuthLinkNewTerminalProps, UnlinkTerminalDeviceProps, LinkTerminalDeviceProps };
175
- export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, axiosInstance, getAxiosHeaders };
176
+ export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, axiosInstance, getAxiosHeaders, setAuthSessionToGlobalHeaders };
176
177
  export default API;
@@ -17,6 +17,7 @@ import { fileService } from './file';
17
17
  import { documentService } from './document';
18
18
  import { initService } from './init';
19
19
  import { terminalService } from './terminal';
20
+ import { setAuthSessionToGlobalHeaders } from './headers';
20
21
  var API = {
21
22
  locationService: locationService,
22
23
  operatorService: operatorService,
@@ -37,5 +38,5 @@ var API = {
37
38
  initService: initService,
38
39
  terminalService: terminalService
39
40
  };
40
- export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, axiosInstance, getAxiosHeaders };
41
+ export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, axiosInstance, getAxiosHeaders, setAuthSessionToGlobalHeaders };
41
42
  export default API;
@@ -69,7 +69,7 @@ var _a;
69
69
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
70
70
  import { AuthForType, AuthTypeNumber, FlowsTypes, MigrationStatus } from '../../../@types';
71
71
  import { ADD_NEW_ENTITY, AUTH_STEP_NAMES, COLLECT_DOB_INFO_NAFATH, IDENTIFICATION_TYPE, NAFATH_PACI_TIMEOUT_DURATION, NAFATH_VERIFICATION_FAILED, SCOPE_AUTH, defaultCountry } from '../../../constants';
72
- import API, { setAxiosGlobalHeaders, getAxiosHeaders } from '../../../api';
72
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
73
73
  import { handleCurrentActiveScreen, handleNextScreenStep, handleOpen, handlePrevScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
74
74
  import { findCountryByIddPrefix, isAuthenticationVerificationFailed, isNetworkError, isTimeoutError, openConnect, sendCustomEventToGTM, sleep } from '../../../utils';
75
75
  export var updateBusinessCountry = createAsyncThunk('auth/updateBusinessCountry', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
@@ -206,7 +206,7 @@ export var verifyMobileOtp = createAsyncThunk('auth/verifyMobileOtp', function (
206
206
  })];
207
207
  case 1:
208
208
  data = _g.sent();
209
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
209
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
210
210
  sendCustomEventToGTM({
211
211
  event: 'Send Event',
212
212
  event_category: 'User Registration Flow',
@@ -252,7 +252,7 @@ export var verifyPasscode = createAsyncThunk('auth/verifyPasscode', function (pa
252
252
  })];
253
253
  case 1:
254
254
  data = _j.sent();
255
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
255
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
256
256
  if (((_e = data === null || data === void 0 ? void 0 : data.status) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === 'success' && (data === null || data === void 0 ? void 0 : data.auth_session)) {
257
257
  if (scope === 'merchant') {
258
258
  openConnect(settings.data.appConfig.publicKey, settings.data.businessCountry.iso2);
@@ -328,7 +328,7 @@ export var verifyEmailPassword = createAsyncThunk('auth/verifyEmailPassword', fu
328
328
  return [4, API.authService.verifyAuth(payload)];
329
329
  case 1:
330
330
  data = _g.sent();
331
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
331
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
332
332
  if ((data === null || data === void 0 ? void 0 : data.auth_type) === AuthTypeNumber.MOBILE_OTP) {
333
333
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('AUTH_OTP_STEP')); });
334
334
  return [2, data];
@@ -397,7 +397,7 @@ export var verifyEmailOtp = createAsyncThunk('auth/verifyEmailOtp', function (pa
397
397
  })];
398
398
  case 1:
399
399
  data = _g.sent();
400
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
400
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
401
401
  sendCustomEventToGTM({
402
402
  event: 'Send Event',
403
403
  event_category: 'User Registration Flow',
@@ -489,7 +489,7 @@ export var verifyNafath = createAsyncThunk('auth/verifyNafath', function (params
489
489
  return [2, { value: data }];
490
490
  }
491
491
  if (isSuccess) {
492
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
492
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
493
493
  if (scope === 'merchant') {
494
494
  openConnect(settings.data.appConfig.publicKey, settings.data.businessCountry.iso2);
495
495
  return [2, { value: data }];
@@ -615,7 +615,7 @@ export var verifyPACI = createAsyncThunk('auth/verifyPACI', function (params, th
615
615
  case 5:
616
616
  isSuccess = ((_b = data === null || data === void 0 ? void 0 : data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
617
617
  if (isSuccess) {
618
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
618
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
619
619
  if (scope === 'merchant') {
620
620
  openConnect(settings.data.appConfig.publicKey, settings.data.businessCountry.iso2);
621
621
  return [2, data];
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
- import API from '../../../api';
50
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
51
51
  import { DocumentPurpose, FlowsTypes } from '../../../@types';
52
52
  import { handleCurrentActiveScreen, handleNextScreenStep, handlePrevScreenStep, handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
53
53
  import { BANK_STEP_NAMES } from '../../../constants';
@@ -70,6 +70,7 @@ export var verifyLeadToken = createAsyncThunk('bankVerifyLeadToken', function (_
70
70
  data = (_j.sent()).data;
71
71
  if ((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length)
72
72
  throw new Error(data.errors[0].description);
73
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
73
74
  bankData = undefined;
74
75
  _b = data || {}, config = _b.config, country_code = _b.country_code, step_name = _b.step_name, bank_account_id = _b.bank_account_id, wallet_id = _b.wallet_id, boardId = _b.id;
75
76
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
@@ -155,6 +156,7 @@ export var verifyBankLeadOTP = createAsyncThunk('verifyBankLeadOTP', function (p
155
156
  })];
156
157
  case 1:
157
158
  data = _m.sent();
159
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
158
160
  countryIso2 = (data === null || data === void 0 ? void 0 : data.country_code) || (responseBody === null || responseBody === void 0 ? void 0 : responseBody.country_code);
159
161
  publicKey = (_d = data === null || data === void 0 ? void 0 : data.config) === null || _d === void 0 ? void 0 : _d.public_key;
160
162
  if (countryIso2)
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
- import API from '../../../api';
50
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
51
51
  import { FlowsTypes } from '../../../@types';
52
52
  import { handleCurrentActiveScreen, handleNextScreenStep, handlePublicKey, handleSetCountryByIso2 } from '../../../app/settings';
53
53
  import { BOARD_STEP_STEPS } from '../../../constants';
@@ -72,6 +72,7 @@ export var createVerifyTokenBy = createAsyncThunk('board/createVerifyTokenByBoar
72
72
  data = _f.sent();
73
73
  _b = data || {}, country_code = _b.country_code, config = _b.config;
74
74
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
75
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
75
76
  if (country_code)
76
77
  thunkApi.dispatch(handleSetCountryByIso2(country_code));
77
78
  if (publicKey)
@@ -136,6 +137,7 @@ export var verifyBoardLeadOTP = createAsyncThunk('board/verifyBoardLeadOTP', fun
136
137
  })];
137
138
  case 1:
138
139
  data = _j.sent();
140
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
139
141
  _b = data || {}, country_code = _b.country_code, config = _b.config;
140
142
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
141
143
  if (country_code)
@@ -58,7 +58,7 @@ var __rest = (this && this.__rest) || function (s, e) {
58
58
  };
59
59
  var _a;
60
60
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
61
- import API from '../../../api';
61
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
62
62
  import { FlowsTypes } from '../../../@types';
63
63
  import { handleNextScreenStep, handlePrevScreenStep, handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
64
64
  import { BRAND_STEP_NAMES, EXPECTED_SALES_LIST } from '../../../constants';
@@ -83,6 +83,7 @@ export var verifyLeadToken = createAsyncThunk('brand/verifyLeadToken', function
83
83
  throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
84
84
  _b = data || {}, config = _b.config, brand_id = _b.brand_id, entity_id = _b.entity_id, board_id = _b.id, country_code = _b.country_code;
85
85
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
86
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
86
87
  if (country_code)
87
88
  thunkApi.dispatch(handleSetCountryByIso2(country_code));
88
89
  if (publicKey)
@@ -163,6 +164,7 @@ export var verifyBrandLeadOTP = createAsyncThunk('brand/verifyLeadOTP', function
163
164
  })];
164
165
  case 1:
165
166
  data = _j.sent();
167
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
166
168
  publicKey = (_d = data === null || data === void 0 ? void 0 : data.config) === null || _d === void 0 ? void 0 : _d.public_key;
167
169
  countryIso2 = (data === null || data === void 0 ? void 0 : data.country_code) || (responseBody === null || responseBody === void 0 ? void 0 : responseBody.country_code);
168
170
  if (publicKey)
@@ -56,7 +56,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
56
56
  };
57
57
  var _a;
58
58
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
59
- import API from '../../../api';
59
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
60
60
  import { BusinessType, FlowsTypes, DocumentPurpose, LicenseType } from '../../../@types';
61
61
  import { BUSINESS_STEP_NAMES, COLLECT_DOB_INFO_NAFATH, EXPECTED_SALES_LIST, IDENTIFICATION_TYPE, NAFATH_PACI_TIMEOUT_DURATION, NAFATH_VERIFICATION_FAILED, OTHER_CR_LICENSE, OTHER_ENTITY_LICENSE, OTHER_FL_LICENSE, defaultCountry } from '../../../constants';
62
62
  import { convertNumbers2English, hasKey, sleep, isKW, isSA, dateFormat, isOtherLicense, isOtherThanKWOrSA, hasNoneEditableValue, sendCustomEventToGTM, findCountryByIddPrefix, isNetworkError, isTimeoutError, isAuthenticationVerificationFailed } from '../../../utils';
@@ -78,6 +78,7 @@ export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', functio
78
78
  throw new Error(data.errors[0].description);
79
79
  if (data.mw_error)
80
80
  throw new Error(data.mw_error);
81
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
81
82
  publicKey = (_c = data === null || data === void 0 ? void 0 : data.config) === null || _c === void 0 ? void 0 : _c.public_key;
82
83
  if (publicKey) {
83
84
  thunkApi.dispatch(handlePublicKey(publicKey));
@@ -220,6 +221,7 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
220
221
  })];
221
222
  case 1:
222
223
  data = _j.sent();
224
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
223
225
  publicKey = (_f = data === null || data === void 0 ? void 0 : data.config) === null || _f === void 0 ? void 0 : _f.public_key;
224
226
  if (publicKey) {
225
227
  thunkApi.dispatch(handlePublicKey(publicKey));
@@ -66,7 +66,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
66
  return to.concat(ar || Array.prototype.slice.call(from));
67
67
  };
68
68
  var _a;
69
- import API, { getAxiosHeaders, setAxiosGlobalHeaders } from '../../../api';
69
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
70
70
  import { handleCurrentActiveScreen, handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
71
71
  import { COLLECT_DOB_INFO_NAFATH, CONNECT_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, NAFATH_PACI_TIMEOUT_DURATION, NAFATH_VERIFICATION_FAILED, OTHER_BRAND } from '../../../constants';
72
72
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
@@ -236,7 +236,7 @@ export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params,
236
236
  })];
237
237
  case 1:
238
238
  data = _f.sent();
239
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
239
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
240
240
  sendCustomEventToGTM({
241
241
  event: 'Send Event',
242
242
  event_category: 'User Registration Flow',
@@ -321,7 +321,7 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
321
321
  case 5:
322
322
  isSuccess = ((_b = authResponse === null || authResponse === void 0 ? void 0 : authResponse.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
323
323
  if (!isSuccess) return [3, 16];
324
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((authResponse === null || authResponse === void 0 ? void 0 : authResponse.auth_session) && { st: authResponse.auth_session })));
324
+ setAuthSessionToGlobalHeaders(authResponse === null || authResponse === void 0 ? void 0 : authResponse.auth_session);
325
325
  lead_id = authResponse.lead_id;
326
326
  if (!lead_id)
327
327
  throw new Error('Lead id is missing');
@@ -419,7 +419,7 @@ export var verifyNafath = createAsyncThunk('connect/verifyNafath', function (par
419
419
  return [2, { authResponse: authResponse, countryCode: countryCode }];
420
420
  }
421
421
  if (!isSuccess) return [3, 16];
422
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((authResponse === null || authResponse === void 0 ? void 0 : authResponse.auth_session) && { st: authResponse.auth_session })));
422
+ setAuthSessionToGlobalHeaders(authResponse === null || authResponse === void 0 ? void 0 : authResponse.auth_session);
423
423
  lead_id = authResponse.lead_id;
424
424
  if (!lead_id)
425
425
  throw new Error('Lead id is missing');
@@ -769,9 +769,9 @@ export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', f
769
769
  var email = _a.email, cancelToken = _a.cancelToken, onSuccess = _a.onSuccess;
770
770
  return __awaiter(void 0, void 0, void 0, function () {
771
771
  var responseBody, requestBody, data, retryData;
772
- var _b, _c, _d, _e;
773
- return __generator(this, function (_f) {
774
- switch (_f.label) {
772
+ var _b, _c, _d, _e, _f, _g;
773
+ return __generator(this, function (_h) {
774
+ switch (_h.label) {
775
775
  case 0:
776
776
  responseBody = thunkApi.getState().connect.data.otpData.responseBody;
777
777
  requestBody = {
@@ -781,22 +781,22 @@ export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', f
781
781
  };
782
782
  return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
783
783
  case 1:
784
- data = (_f.sent()).data;
784
+ data = (_h.sent()).data;
785
785
  if (!data.errors) {
786
786
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
787
787
  return [2, { response: data, formData: email }];
788
788
  }
789
789
  if (!isInternalServerError((_d = (_c = data.errors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.error)) {
790
790
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
791
- return [2];
791
+ throw new Error((_f = (_e = data.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.error);
792
792
  }
793
793
  return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
794
794
  case 2:
795
- retryData = (_f.sent()).data;
795
+ retryData = (_h.sent()).data;
796
796
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
797
797
  if (!retryData.errors)
798
798
  return [2, { response: retryData, formData: email }];
799
- if (isInternalServerError((_e = retryData.errors) === null || _e === void 0 ? void 0 : _e[0].error))
799
+ if (isInternalServerError((_g = retryData.errors) === null || _g === void 0 ? void 0 : _g[0].error))
800
800
  return [2, { response: { is_available: true }, formData: email }];
801
801
  return [2];
802
802
  }
@@ -58,7 +58,7 @@ var _a;
58
58
  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, AuthForScreen } from '../../../@types';
61
- import API, { getAxiosHeaders, setAxiosGlobalHeaders } from '../../../api';
61
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
62
62
  import { ADD_NEW_ENTITY, COLLECT_DOB_INFO_NAFATH, CONNECT_EXPRESS_STEP_NAMES, IDENTIFICATION_TYPE, NAFATH_PACI_TIMEOUT_DURATION, NAFATH_VERIFICATION_FAILED, OTHER_CR_LICENSE, OTHER_FL_LICENSE, SCOPE_AUTH, SCOPE_MERCHANT } from '../../../constants';
63
63
  import { defaultCountry } from '../../../constants';
64
64
  import { getIndividualName, capitalizeTheFirstLetterOfEachWord, sleep, findCountryByIddPrefix, concatenateObjectValues, isSA, isKW, isOtherThanKWOrSA, sendCustomEventToGTM, sendCustomDimension, getMetaData, isNetworkError, isTimeoutError, isInternalServerError, isAuthenticationVerificationFailed } from '../../../utils';
@@ -385,7 +385,7 @@ export var verifyNafathAsync = createAsyncThunk('connectExpress/verifyNafathAsyn
385
385
  return [2, { data: data }];
386
386
  }
387
387
  if (!isSuccess) return [3, 9];
388
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
388
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
389
389
  authId = (_j = data.auth) === null || _j === void 0 ? void 0 : _j.id;
390
390
  leadId = (_k = data.auth) === null || _k === void 0 ? void 0 : _k.lead_id;
391
391
  thunkApi.dispatch(storeAuthId(authId));
@@ -507,7 +507,7 @@ export var verifyMobileOtpAsync = createAsyncThunk('connectExpress/verifyMobileO
507
507
  })];
508
508
  case 1:
509
509
  data = _h.sent();
510
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
510
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
511
511
  sendCustomEventToGTM({
512
512
  event: 'Send Event',
513
513
  event_category: 'User Registration Flow',
@@ -589,7 +589,7 @@ export var verifyPACIAsync = createAsyncThunk('connectExpress/verifyPACIAsync',
589
589
  case 5:
590
590
  isSuccess = ((_e = (_d = data === null || data === void 0 ? void 0 : data.auth) === null || _d === void 0 ? void 0 : _d.status) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === 'success';
591
591
  if (!isSuccess) return [3, 9];
592
- setAxiosGlobalHeaders(__assign(__assign({}, getAxiosHeaders()), ((data === null || data === void 0 ? void 0 : data.auth_session) && { st: data.auth_session })));
592
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
593
593
  authId = data.auth.id;
594
594
  thunkApi.dispatch(storeAuthId(authId));
595
595
  if (isScopeAuthentication && !data.new_user && isDataHasIndividualOnly && authId) {
@@ -846,9 +846,9 @@ export var checkEmailAvailabilityAsync = createAsyncThunk('connectExpress/CheckE
846
846
  var email = _a.email, cancelToken = _a.cancelToken, onSuccess = _a.onSuccess;
847
847
  return __awaiter(void 0, void 0, void 0, function () {
848
848
  var responseData, requestBody, data, retryData;
849
- var _b, _c, _d, _e, _f;
850
- return __generator(this, function (_g) {
851
- switch (_g.label) {
849
+ var _b, _c, _d, _e, _f, _g, _h;
850
+ return __generator(this, function (_j) {
851
+ switch (_j.label) {
852
852
  case 0:
853
853
  responseData = thunkApi.getState().connectExpress.data.responseData;
854
854
  requestBody = {
@@ -858,22 +858,22 @@ export var checkEmailAvailabilityAsync = createAsyncThunk('connectExpress/CheckE
858
858
  };
859
859
  return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
860
860
  case 1:
861
- data = (_g.sent()).data;
861
+ data = (_j.sent()).data;
862
862
  if (!data.errors) {
863
863
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
864
864
  return [2, { response: data, formData: email }];
865
865
  }
866
866
  if (!isInternalServerError((_d = (_c = data.errors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.error)) {
867
867
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
868
- return [2];
868
+ throw new Error((_f = (_e = data.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.error);
869
869
  }
870
870
  return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
871
871
  case 2:
872
- retryData = (_g.sent()).data;
872
+ retryData = (_j.sent()).data;
873
873
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
874
874
  if (!retryData.errors)
875
875
  return [2, { response: retryData, formData: email }];
876
- if (isInternalServerError((_f = (_e = retryData.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.error))
876
+ if (isInternalServerError((_h = (_g = retryData.errors) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.error))
877
877
  return [2, { response: { is_available: true }, formData: email }];
878
878
  return [2];
879
879
  }
@@ -58,7 +58,7 @@ var __rest = (this && this.__rest) || function (s, e) {
58
58
  };
59
59
  var _a;
60
60
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
61
- import API from '../../../api';
61
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
62
62
  import { BusinessType, DocumentPurpose, FlowsTypes, LicenseType } from '../../../@types';
63
63
  import { handleNextScreenStep, handlePrevScreenStep, handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
64
64
  import { ENTITY_STEP_NAMES } from '../../../constants';
@@ -85,6 +85,7 @@ export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function
85
85
  throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
86
86
  if (isInternally)
87
87
  data.step_name = ENTITY_STEP_NAMES.ENTITY_INFO;
88
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
88
89
  _b = data || {}, country_code = _b.country_code, config = _b.config;
89
90
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
90
91
  if (country_code)
@@ -165,6 +166,7 @@ export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', functio
165
166
  })];
166
167
  case 1:
167
168
  data = _h.sent();
169
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
168
170
  _b = data || {}, entity_id = _b.entity_id, config = _b.config, boardId = _b.id, country_code = _b.country_code;
169
171
  entityData = undefined;
170
172
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
@@ -67,7 +67,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
67
67
  };
68
68
  var _a;
69
69
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
70
- import API from '../../../api';
70
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
71
71
  import { FlowsTypes, IndividualGender, DocumentPurpose } from '../../../@types';
72
72
  import { handleNextScreenStep, handlePrevScreenStep, handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
73
73
  import { defaultCountry, IDENTIFICATION_TYPE, INDIVIDUAl_STEP_NAMES, MONTHLY_INCOME_LIST } from '../../../constants';
@@ -93,6 +93,7 @@ export var verifyToken = createAsyncThunk('individual/verifyToken', function (_a
93
93
  countries = settings.data.countries;
94
94
  if (((_e = data.errors) === null || _e === void 0 ? void 0 : _e.length) || (data === null || data === void 0 ? void 0 : data.mw_error))
95
95
  throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
96
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
96
97
  if (isInternally)
97
98
  data.step_name = INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO;
98
99
  _b = data || {}, country_code = _b.country_code, config = _b.config, boardId = _b.id;
@@ -466,6 +467,7 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
466
467
  })];
467
468
  case 1:
468
469
  data = _l.sent();
470
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
469
471
  recipientData = undefined;
470
472
  publicKey = (_e = data === null || data === void 0 ? void 0 : data.config) === null || _e === void 0 ? void 0 : _e.public_key;
471
473
  countryCode = data === null || data === void 0 ? void 0 : data.country_code;
@@ -50,7 +50,7 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import { handlePublicKey, handleSetCountryByIso2 } from '../../../app/settings';
51
51
  import { FlowsTypes } from '../../../@types';
52
52
  import { CONNECT_FLOWS, KYC_STEP_NAMES, NAFATH_PACI_TIMEOUT_DURATION, NAFATH_VERIFICATION_FAILED } from '../../../constants';
53
- import API from '../../../api';
53
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
54
54
  import { isNetworkError, isTimeoutError, sendCustomEventToGTM, sleep } from '../../../utils';
55
55
  export var verifyTokenApi = createAsyncThunk('kyc/verifyTokenApi', function (_a, thunkApi) {
56
56
  var token = _a.token;
@@ -70,6 +70,7 @@ export var verifyTokenApi = createAsyncThunk('kyc/verifyTokenApi', function (_a,
70
70
  return [4, API.leadService.verifyToken(payload)];
71
71
  case 1:
72
72
  data = _d.sent();
73
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
73
74
  _b = data || {}, config = _b.config, country_code = _b.country_code, segment_id = _b.segment_id, boardId = _b.id, boardInfoId = _b.board_info_id;
74
75
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
75
76
  return [4, API.boardService.retrieveBoardInfo({ id: boardId, infoId: boardInfoId })];
@@ -200,6 +201,7 @@ export var verifyNafath = createAsyncThunk('kyc/verifyNafath', function (params,
200
201
  return [2, { data: data, createAuthData: createAuthData }];
201
202
  }
202
203
  if (!isSuccess) return [3, 7];
204
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
203
205
  (_d = params.onSuccess) === null || _d === void 0 ? void 0 : _d.call(params);
204
206
  return [4, thunkApi.dispatch(updateKYCSuccess())];
205
207
  case 6:
@@ -252,6 +254,7 @@ export var verifyPaci = createAsyncThunk('kyc/verifyPaci', function (params, thu
252
254
  case 5:
253
255
  isSuccess = ((_a = data === null || data === void 0 ? void 0 : data.status) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'success';
254
256
  if (!isSuccess) return [3, 7];
257
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
255
258
  (_b = params.onSuccess) === null || _b === void 0 ? void 0 : _b.call(params);
256
259
  return [4, thunkApi.dispatch(updateKYCSuccess())];
257
260
  case 6:
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
- import API from '../../../api';
50
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
51
51
  import { FlowsTypes } from '../../../@types';
52
52
  import { handleCurrentActiveScreen, handleNextScreenStep, handlePrevScreenStep, handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
53
53
  import { PASSWORD_OPERATION_TYPE, PASSWORD_STEP_NAMES } from '../../../constants';
@@ -72,6 +72,7 @@ export var verifyLeadToken = createAsyncThunk('passwordVerifyLeadToken', functio
72
72
  throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
73
73
  if (isInternally)
74
74
  data.step_name = PASSWORD_STEP_NAMES.PASSWORD_INFO;
75
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
75
76
  _b = data || {}, config = _b.config, board_info_password_status = _b.board_info_password_status, country_code = _b.country_code, board_id = _b.id, recipient = _b.recipient;
76
77
  countryIso2 = country_code;
77
78
  if (countryIso2)
@@ -177,6 +178,7 @@ export var verifyPasswordLeadOTP = createAsyncThunk('verifyPasswordLeadOTP', fun
177
178
  case 1:
178
179
  data = _g.sent();
179
180
  _b = data || {}, config = _b.config, board_info_password_status = _b.board_info_password_status, country_code = _b.country_code, board_id = _b.id, recipient = _b.recipient;
181
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
180
182
  countryIso2 = country_code;
181
183
  if (countryIso2)
182
184
  thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
@@ -310,6 +312,7 @@ export var verifyOperationToken = createAsyncThunk('verifyOperationToken', funct
310
312
  return [4, API.authService.verifyAuth(payload)];
311
313
  case 1:
312
314
  data = _c.sent();
315
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
313
316
  countryIso2 = data === null || data === void 0 ? void 0 : data.country;
314
317
  if (countryIso2)
315
318
  thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
@@ -378,6 +381,7 @@ export var resetPassword = createAsyncThunk('resetPassword', function (params, t
378
381
  })];
379
382
  case 1:
380
383
  data = _d.sent();
384
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
381
385
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('PASSWORD_SUCCESS_STEP')); });
382
386
  (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, payload);
383
387
  return [2, { data: data, formData: __assign(__assign({}, params), passwordData) }];
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
- import API from '../../../api';
50
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
51
51
  import { DocumentPurpose, FlowsTypes } from '../../../@types';
52
52
  import { handleNextScreenStep, handleCurrentActiveScreen, handleSetCountryByIso2, handlePrevScreenStep, handlePublicKey, onCloseComplete } from '../../../app/settings';
53
53
  import { TAX_STEP_NAMES } from '../../../constants';
@@ -73,6 +73,7 @@ export var verifyLeadToken = createAsyncThunk('taxVerifyLeadToken', function (_a
73
73
  throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
74
74
  if (isInternally)
75
75
  data.step_name = TAX_STEP_NAMES.TAX_INFO;
76
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
76
77
  _b = data || {}, config = _b.config, country_code = _b.country_code, entity_id = _b.entity_id, boardId = _b.id;
77
78
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
78
79
  if (publicKey)
@@ -198,6 +199,7 @@ export var verifyTaxLeadOTP = createAsyncThunk('verifyTaxLeadOTP', function (par
198
199
  })];
199
200
  case 1:
200
201
  data = _h.sent();
202
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
201
203
  _b = data || {}, config = _b.config, entity_id = _b.entity_id, boardId = _b.id, country_code = _b.country_code;
202
204
  entityData = undefined;
203
205
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
@@ -50,7 +50,7 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import { handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
51
51
  import { FlowsTypes } from '../../../@types';
52
52
  import { CONNECT_FLOWS, NAFATH_PACI_TIMEOUT_DURATION, SELECTED_POS_DEFAULT_INFO, SELECTED_TERMINAL_DEFAULT_INFO, TERMINAL_PUSH_NOTIFICATION_DURATION, TERMINAL_PUSH_NOTIFICATION_FAILED, TERMINAL_STEP_NAMES } from '../../../constants';
53
- import API from '../../../api';
53
+ import API, { setAuthSessionToGlobalHeaders } from '../../../api';
54
54
  import { isAuthenticationVerificationFailed, isNetworkError, isNoDataFoundError, isTimeoutError, retrieveIndividualData, sleep } from '../../../utils';
55
55
  export var verifyToken = createAsyncThunk('terminal/verifyLeadToken', function (_a, thunkApi) {
56
56
  var token = _a.token, isInternally = _a.isInternally;
@@ -72,6 +72,7 @@ export var verifyToken = createAsyncThunk('terminal/verifyLeadToken', function (
72
72
  if (isInternally)
73
73
  data.step_name = TERMINAL_STEP_NAMES.PHONE_AUTH;
74
74
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
75
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
75
76
  if (publicKey)
76
77
  thunkApi.dispatch(handlePublicKey(publicKey));
77
78
  if (country_code)
@@ -140,6 +141,7 @@ export var verifyTokenOTP = createAsyncThunk('terminal/verifyOtp', function (par
140
141
  return [4, API.leadService.verifyTokenOTP(payload)];
141
142
  case 1:
142
143
  data = _g.sent();
144
+ setAuthSessionToGlobalHeaders(data === null || data === void 0 ? void 0 : data.auth_session);
143
145
  _b = data || {}, config = _b.config, country_code = _b.country_code, merchant_id = _b.merchant_id;
144
146
  publicKey = config === null || config === void 0 ? void 0 : config.public_key;
145
147
  countryIso2 = country_code || (authData === null || authData === void 0 ? void 0 : authData.country_code);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.11.24-development",
3
+ "version": "2.11.26-development",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",