@tap-payments/auth-jsconnect 2.13.6-beta → 2.13.8-beta

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.
@@ -104,8 +104,8 @@ export interface IndividualPersonalInfoFormValues extends IndividualEmailMobileF
104
104
  gender: string | null;
105
105
  nid: string;
106
106
  issuedCountry: CountryCode | undefined;
107
- expiryDate: string;
108
- dob: string;
107
+ expiryDate: string | undefined;
108
+ dob: string | undefined;
109
109
  placeOfBirthCountry: CountryCode | undefined;
110
110
  placeOfBirthCity: City | undefined;
111
111
  nationality: CountryCode | undefined;
@@ -19,8 +19,8 @@ export declare type ExpressCreateAccountBody = {
19
19
  declare const accountService: {
20
20
  createAccount: (data: CreateAccountBody) => Promise<any>;
21
21
  expressCreateAccount: (data: ExpressCreateAccountBody) => Promise<any>;
22
- checkAccountAvailability: (individualId: string) => Promise<any>;
23
- checkAccountAvailabilityStatus: (individualId: string) => Promise<any>;
22
+ checkAccountAvailability: (individualId: string, authSession?: string) => Promise<any>;
23
+ checkAccountAvailabilityStatus: (individualId: string, authSession?: string) => Promise<any>;
24
24
  checkMigrationStatus: (jobId: string) => Promise<any>;
25
25
  };
26
26
  export { accountService };
@@ -1,5 +1,6 @@
1
1
  import { ENDPOINT_PATHS } from '../constants';
2
2
  import { httpClient } from './axios';
3
+ import { getAuthHeaders } from './headers';
3
4
  var createAccount = function (data) {
4
5
  return httpClient({
5
6
  method: 'post',
@@ -14,16 +15,18 @@ var expressCreateAccount = function (data) {
14
15
  data: data
15
16
  });
16
17
  };
17
- var checkAccountAvailability = function (individualId) {
18
+ var checkAccountAvailability = function (individualId, authSession) {
18
19
  return httpClient({
19
20
  method: 'get',
20
- url: "".concat(ENDPOINT_PATHS.INDIVIDUAL, "/").concat(individualId, "/accounts")
21
+ url: "".concat(ENDPOINT_PATHS.INDIVIDUAL, "/").concat(individualId, "/accounts"),
22
+ headers: getAuthHeaders(authSession)
21
23
  });
22
24
  };
23
- var checkAccountAvailabilityStatus = function (individualId) {
25
+ var checkAccountAvailabilityStatus = function (individualId, authSession) {
24
26
  return httpClient({
25
27
  method: 'get',
26
- url: "".concat(ENDPOINT_PATHS.INDIVIDUAL, "/").concat(individualId, "/accounts?data=status")
28
+ url: "".concat(ENDPOINT_PATHS.INDIVIDUAL, "/").concat(individualId, "/accounts?data=status"),
29
+ headers: getAuthHeaders(authSession)
27
30
  });
28
31
  };
29
32
  var checkMigrationStatus = function (jobId) {
@@ -0,0 +1,5 @@
1
+ export declare const getAuthHeaders: (authSession?: string) => {
2
+ st: string;
3
+ } | {
4
+ st?: undefined;
5
+ };
@@ -0,0 +1,3 @@
1
+ export var getAuthHeaders = function (authSession) {
2
+ return authSession ? { st: authSession } : {};
3
+ };
@@ -20,7 +20,7 @@ declare const API: {
20
20
  };
21
21
  operatorService: {
22
22
  validateOperator: (body: ValidateOperatorBody) => Promise<any>;
23
- confirm: (data: ConfirmBody) => Promise<any>;
23
+ confirm: (data: ConfirmBody, authSession?: string) => Promise<any>;
24
24
  };
25
25
  countryService: {
26
26
  getCountries: (disableCountries?: boolean | undefined) => Promise<any> | {
@@ -90,8 +90,8 @@ declare const API: {
90
90
  accountService: {
91
91
  createAccount: (data: CreateAccountBody) => Promise<any>;
92
92
  expressCreateAccount: (data: ExpressCreateAccountBody) => Promise<any>;
93
- checkAccountAvailability: (individualId: string) => Promise<any>;
94
- checkAccountAvailabilityStatus: (individualId: string) => Promise<any>;
93
+ checkAccountAvailability: (individualId: string, authSession?: string | undefined) => Promise<any>;
94
+ checkAccountAvailabilityStatus: (individualId: string, authSession?: string | undefined) => Promise<any>;
95
95
  checkMigrationStatus: (jobId: string) => Promise<any>;
96
96
  };
97
97
  dataService: {
@@ -17,6 +17,6 @@ export declare type ConfirmBody = {
17
17
  };
18
18
  declare const operatorService: {
19
19
  validateOperator: (body: ValidateOperatorBody) => Promise<any>;
20
- confirm: (data: ConfirmBody) => Promise<any>;
20
+ confirm: (data: ConfirmBody, authSession?: string) => Promise<any>;
21
21
  };
22
22
  export { operatorService };
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { ENDPOINT_PATHS } from '../constants';
38
38
  import { httpClient } from './axios';
39
+ import { getAuthHeaders } from './headers';
39
40
  var validateOperator = function (body) { return __awaiter(void 0, void 0, void 0, function () {
40
41
  var data, error_1;
41
42
  return __generator(this, function (_a) {
@@ -59,11 +60,13 @@ var validateOperator = function (body) { return __awaiter(void 0, void 0, void 0
59
60
  }
60
61
  });
61
62
  }); };
62
- var confirm = function (data) {
63
+ var confirm = function (data, authSession) {
64
+ if (authSession === void 0) { authSession = ''; }
63
65
  return httpClient({
64
66
  method: 'post',
65
67
  url: "".concat(ENDPOINT_PATHS.CONNECT, "/confirm"),
66
- data: data
68
+ data: data,
69
+ headers: getAuthHeaders(authSession)
67
70
  });
68
71
  };
69
72
  var operatorService = {
@@ -1,7 +1,7 @@
1
1
  var SANDBOX_BASE_URL = 'https://connect-mw.sandbox.tap.company/middleware';
2
2
  var PRODUCTION_BASE_URL = 'https://connect-mw.tap.company/middleware';
3
3
  var PRODUCTION_BASE_URL_SA = 'https://connect-mw.tap.com.sa/middleware';
4
- var PRODUCTION_BASE_URL_SA_DR = 'https://connect-mw-test.tap.com.sa/middleware';
4
+ var PRODUCTION_BASE_URL_SA_DR = 'https://connect-mw.tap.com.sa/middleware';
5
5
  var DEV_BASE_URL = 'https://connect-mw.dev.tap.company/middleware';
6
6
  var BETA_BASE_URL = 'https://connect-mw.beta.tap.company/middleware';
7
7
  var API_BUSINESS_COUNTRIES = 'https://godata.sandbox.tap.company/api/v1/business/country/list';
@@ -677,36 +677,36 @@ export var checkMigrationStatus = createAsyncThunk('auth/checkMigrationStatus',
677
677
  });
678
678
  }); });
679
679
  export var checkAccountAvailability = createAsyncThunk('auth/checkAccountAvailability', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
680
- var _a, settings, auth, authConfigData, authDataHasValue, isDataHasIndividualOnly, data, authId, accountData, _b, step_name, brands, entities, brandList, entityList, isExistingUser;
681
- var _c;
682
- return __generator(this, function (_d) {
683
- switch (_d.label) {
680
+ var _a, settings, auth, authConfigData, authDataHasValue, isDataHasIndividualOnly, data, _b, authId, auth_session, accountData, _c, step_name, brands, entities, brandList, entityList, isExistingUser;
681
+ var _d;
682
+ return __generator(this, function (_e) {
683
+ switch (_e.label) {
684
684
  case 0:
685
685
  _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
686
686
  authConfigData = settings.data.appConfig.data;
687
687
  authDataHasValue = authConfigData === null || authConfigData === void 0 ? void 0 : authConfigData.length;
688
688
  isDataHasIndividualOnly = (authConfigData === null || authConfigData === void 0 ? void 0 : authConfigData.length) === 1 && authConfigData.includes('individual');
689
- data = (_c = auth.data.responseData) === null || _c === void 0 ? void 0 : _c.authResponse;
690
- authId = (data || {}).id;
689
+ data = (_d = auth.data.responseData) === null || _d === void 0 ? void 0 : _d.authResponse;
690
+ _b = data || {}, authId = _b.id, auth_session = _b.auth_session;
691
691
  accountData = undefined;
692
692
  if (!isDataHasIndividualOnly) return [3, 2];
693
- return [4, API.accountService.checkAccountAvailabilityStatus(data === null || data === void 0 ? void 0 : data.individual_id)];
693
+ return [4, API.accountService.checkAccountAvailabilityStatus(data === null || data === void 0 ? void 0 : data.individual_id, auth_session)];
694
694
  case 1:
695
- accountData = _d.sent();
695
+ accountData = _e.sent();
696
696
  return [3, 4];
697
- case 2: return [4, API.accountService.checkAccountAvailability(data === null || data === void 0 ? void 0 : data.individual_id)];
697
+ case 2: return [4, API.accountService.checkAccountAvailability(data === null || data === void 0 ? void 0 : data.individual_id, auth_session)];
698
698
  case 3:
699
- accountData = _d.sent();
700
- _d.label = 4;
699
+ accountData = _e.sent();
700
+ _e.label = 4;
701
701
  case 4:
702
- _b = accountData || {}, step_name = _b.step_name, brands = _b.brands, entities = _b.entities;
702
+ _c = accountData || {}, step_name = _c.step_name, brands = _c.brands, entities = _c.entities;
703
703
  brandList = brands || [];
704
704
  entityList = entities || [];
705
705
  isExistingUser = step_name === 'select_account';
706
706
  if (!(isExistingUser && isDataHasIndividualOnly && authId)) return [3, 6];
707
707
  return [4, thunkApi.dispatch(confirmInfo({ authId: authId }))];
708
708
  case 5:
709
- _d.sent();
709
+ _e.sent();
710
710
  return [2, { brandList: brandList, entityList: entityList }];
711
711
  case 6:
712
712
  if (isExistingUser && authDataHasValue && brandList.length && entityList.length) {
@@ -803,7 +803,7 @@ export var confirmInfo = createAsyncThunk('auth/confirmInfo', function (_a, thun
803
803
  entity_id: (entityInfo === null || entityInfo === void 0 ? void 0 : entityInfo.id) || '',
804
804
  data: settings.data.appConfig.data || []
805
805
  };
806
- return [4, API.operatorService.confirm(body)];
806
+ return [4, API.operatorService.confirm(body, authResponse === null || authResponse === void 0 ? void 0 : authResponse.auth_session)];
807
807
  case 1:
808
808
  data = _k.sent();
809
809
  (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, data);
@@ -82,14 +82,15 @@ export declare const updateLeadMobile: import("@reduxjs/toolkit").AsyncThunk<{
82
82
  export declare const skipUpdateLeadMobile: import("@reduxjs/toolkit").AsyncThunk<{
83
83
  leadResponse: any;
84
84
  }, void, {}>;
85
+ interface EmailCheckProps {
86
+ email: string;
87
+ cancelToken: CancelToken;
88
+ onSuccess?: () => void;
89
+ }
85
90
  export declare const checkEmailAvailability: import("@reduxjs/toolkit").AsyncThunk<{
86
91
  response: any;
87
92
  formData: string;
88
- } | undefined, {
89
- email: string;
90
- cancelToken: CancelToken;
91
- onSuccess?: (() => void) | undefined;
92
- }, {}>;
93
+ } | undefined, EmailCheckProps, {}>;
93
94
  export declare const checkBrandNameAvailability: import("@reduxjs/toolkit").AsyncThunk<{
94
95
  response: any;
95
96
  formData: {
@@ -71,7 +71,7 @@ import { handleCurrentActiveScreen, handleNextScreenStep, handleSetCountryByIso2
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';
73
73
  import { AuthForType, FlowsTypes } from '../../../@types';
74
- import { capitalizeTheFirstLetterOfEachWord, concatenateObjectValues, findCountryByIddPrefix, fixBrandList, isTwitter, getIndividualName, isWebsite, sleep, sendCustomEventToGTM, isOtherThanKWOrSA, isKW, findCountryByIso2, getMetaData, isNetworkError, isTimeoutError } from '../../../utils';
74
+ import { capitalizeTheFirstLetterOfEachWord, concatenateObjectValues, findCountryByIddPrefix, fixBrandList, isTwitter, getIndividualName, isWebsite, sleep, sendCustomEventToGTM, isOtherThanKWOrSA, isKW, findCountryByIso2, getMetaData, isNetworkError, isTimeoutError, isInternalServerError } from '../../../utils';
75
75
  export var updateBusinessCountry = createAsyncThunk('connect/updateBusinessCountry', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
76
76
  var connect, payload, data;
77
77
  return __generator(this, function (_a) {
@@ -763,23 +763,36 @@ export var skipUpdateLeadMobile = createAsyncThunk('connect/skipUpdateLeadMobile
763
763
  export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', function (_a, thunkApi) {
764
764
  var email = _a.email, cancelToken = _a.cancelToken, onSuccess = _a.onSuccess;
765
765
  return __awaiter(void 0, void 0, void 0, function () {
766
- var connect, requestBody, data;
767
- var _b, _c;
768
- return __generator(this, function (_d) {
769
- switch (_d.label) {
766
+ var responseBody, requestBody, data, retryData;
767
+ var _b, _c, _d, _e;
768
+ return __generator(this, function (_f) {
769
+ switch (_f.label) {
770
770
  case 0:
771
- connect = thunkApi.getState().connect;
771
+ responseBody = thunkApi.getState().connect.data.otpData.responseBody;
772
772
  requestBody = {
773
773
  email: email,
774
- country: (_c = (_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.leadData) === null || _c === void 0 ? void 0 : _c.country_code,
774
+ country: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.leadData) === null || _b === void 0 ? void 0 : _b.country_code,
775
775
  encryption_contract: ['email']
776
776
  };
777
777
  return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
778
778
  case 1:
779
- data = (_d.sent()).data;
780
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
781
- if (!data.errors)
779
+ data = (_f.sent()).data;
780
+ if (!data.errors) {
781
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
782
782
  return [2, { response: data, formData: email }];
783
+ }
784
+ if (!isInternalServerError((_d = (_c = data.errors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.error)) {
785
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
786
+ return [2];
787
+ }
788
+ return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
789
+ case 2:
790
+ retryData = (_f.sent()).data;
791
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
792
+ if (!retryData.errors)
793
+ return [2, { response: retryData, formData: email }];
794
+ if (isInternalServerError((_e = retryData.errors) === null || _e === void 0 ? void 0 : _e[0].error))
795
+ return [2, { response: { is_available: true }, formData: email }];
783
796
  return [2];
784
797
  }
785
798
  });
@@ -82,14 +82,15 @@ export declare const verifyNafathIdentityAsync: import("@reduxjs/toolkit").Async
82
82
  isNextScreenIsDob: boolean;
83
83
  }, verifyPACIAsyncParams, {}>;
84
84
  export declare const verifyPaciLeadIdentityAsync: import("@reduxjs/toolkit").AsyncThunk<any, verifyPACIAsyncParams, {}>;
85
+ interface EmailCheckProps {
86
+ email: string;
87
+ cancelToken: CancelToken;
88
+ onSuccess?: () => void;
89
+ }
85
90
  export declare const checkEmailAvailabilityAsync: import("@reduxjs/toolkit").AsyncThunk<{
86
91
  response: any;
87
92
  formData: string;
88
- } | undefined, {
89
- email: string;
90
- cancelToken: CancelToken;
91
- onSuccess?: (() => void) | undefined;
92
- }, {}>;
93
+ } | undefined, EmailCheckProps, {}>;
93
94
  export declare const checkBrandNameAvailabilityAsync: import("@reduxjs/toolkit").AsyncThunk<{
94
95
  response: any;
95
96
  formData: {
@@ -61,7 +61,7 @@ import { FlowsTypes, AuthForType, BusinessType, LicenseType, AuthForScreen } fro
61
61
  import API 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
- import { getIndividualName, capitalizeTheFirstLetterOfEachWord, sleep, findCountryByIddPrefix, concatenateObjectValues, isSA, isKW, isOtherThanKWOrSA, sendCustomEventToGTM, sendCustomDimension, getMetaData, isNetworkError, isTimeoutError } from '../../../utils';
64
+ import { getIndividualName, capitalizeTheFirstLetterOfEachWord, sleep, findCountryByIddPrefix, concatenateObjectValues, isSA, isKW, isOtherThanKWOrSA, sendCustomEventToGTM, sendCustomDimension, getMetaData, isNetworkError, isTimeoutError, isInternalServerError } from '../../../utils';
65
65
  export var updateBusinessCountryAsync = createAsyncThunk('connectExpress/updateBusinessCountryAsync', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
66
  var connectExpress, payload, data;
67
67
  return __generator(this, function (_a) {
@@ -838,23 +838,36 @@ export var verifyPaciLeadIdentityAsync = createAsyncThunk('connectExpress/verify
838
838
  export var checkEmailAvailabilityAsync = createAsyncThunk('connectExpress/CheckEmailAvailabilityAsync', function (_a, thunkApi) {
839
839
  var email = _a.email, cancelToken = _a.cancelToken, onSuccess = _a.onSuccess;
840
840
  return __awaiter(void 0, void 0, void 0, function () {
841
- var connectExpress, requestBody, data;
842
- var _b, _c;
843
- return __generator(this, function (_d) {
844
- switch (_d.label) {
841
+ var responseData, requestBody, data, retryData;
842
+ var _b, _c, _d, _e, _f;
843
+ return __generator(this, function (_g) {
844
+ switch (_g.label) {
845
845
  case 0:
846
- connectExpress = thunkApi.getState().connectExpress;
846
+ responseData = thunkApi.getState().connectExpress.data.responseData;
847
847
  requestBody = {
848
848
  email: email,
849
- country: (_c = (_b = connectExpress.data.responseData) === null || _b === void 0 ? void 0 : _b.leadData) === null || _c === void 0 ? void 0 : _c.country_code,
849
+ country: (_b = responseData === null || responseData === void 0 ? void 0 : responseData.leadData) === null || _b === void 0 ? void 0 : _b.country_code,
850
850
  encryption_contract: ['email']
851
851
  };
852
852
  return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
853
853
  case 1:
854
- data = (_d.sent()).data;
855
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
856
- if (!data.errors)
854
+ data = (_g.sent()).data;
855
+ if (!data.errors) {
856
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
857
857
  return [2, { response: data, formData: email }];
858
+ }
859
+ if (!isInternalServerError((_d = (_c = data.errors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.error)) {
860
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
861
+ return [2];
862
+ }
863
+ return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
864
+ case 2:
865
+ retryData = (_g.sent()).data;
866
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
867
+ if (!retryData.errors)
868
+ return [2, { response: retryData, formData: email }];
869
+ if (isInternalServerError((_f = (_e = retryData.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.error))
870
+ return [2, { response: { is_available: true }, formData: email }];
858
871
  return [2];
859
872
  }
860
873
  });
@@ -1929,6 +1942,7 @@ export var connectSlice = createSlice({
1929
1942
  state.loading = false;
1930
1943
  state.error = null;
1931
1944
  state.data.individualData.mobile = action.payload.formData.mobile;
1945
+ state.data.individualData.countryCode = action.payload.formData.countryCode;
1932
1946
  state.data.responseData = __assign(__assign({}, state.data.responseData), { individualData: action.payload.leadResponse, verifyAuthMobile: action.payload.leadResponse });
1933
1947
  state.data.verifyAuthOtpData.authFor = AuthForScreen.MOBILE_OWNERSHIP;
1934
1948
  })
@@ -621,7 +621,8 @@ export var updateIndividualPersonalInfo = createAsyncThunk('individual/updateInd
621
621
  expiry: isExpiryNonEditable || !expiryDate ? undefined : new Date(expiryDate).getTime(),
622
622
  type: isIdTypeNonEditable || !identification_id_type ? undefined : identification_id_type
623
623
  }
624
- })), (!isDOBNonEditable && {
624
+ })), (!isDOBNonEditable &&
625
+ dob && {
625
626
  date_of_birth: dob
626
627
  })), (hasBirth &&
627
628
  !(isBirthCityNonEditable && isBirthCountryNonEditable) && {
@@ -911,8 +912,8 @@ var initialState = {
911
912
  gender: IndividualGender.MALE,
912
913
  nid: '',
913
914
  issuedCountry: undefined,
914
- expiryDate: '',
915
- dob: '',
915
+ expiryDate: undefined,
916
+ dob: undefined,
916
917
  placeOfBirthCountry: undefined,
917
918
  placeOfBirthCity: undefined,
918
919
  nationality: undefined
@@ -1,3 +1,4 @@
1
1
  export declare const isNetworkError: (error: string | null) => boolean;
2
2
  export declare const isTokenExpired: (error: string | null) => boolean;
3
3
  export declare const isTimeoutError: (error: string | null) => boolean;
4
+ export declare const isInternalServerError: (error: string | null) => boolean;
@@ -7,3 +7,6 @@ export var isTokenExpired = function (error) {
7
7
  export var isTimeoutError = function (error) {
8
8
  return (error || '').trim().toLowerCase().includes('timeout');
9
9
  };
10
+ export var isInternalServerError = function (error) {
11
+ return ['internal_server_error'].includes((error || '').trim().toLowerCase());
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.13.6-beta",
3
+ "version": "2.13.8-beta",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",