@tap-payments/auth-jsconnect 2.13.6-beta → 2.13.7-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;
@@ -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';
@@ -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.7-beta",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",