@tap-payments/auth-jsconnect 2.11.19-development → 2.11.20-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.
@@ -51,11 +51,11 @@ import { handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../
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
53
  import API from '../../../api';
54
- import { isAuthenticationVerificationFailed, isNetworkError, isTimeoutError, retrieveIndividualData, sleep } from '../../../utils';
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;
57
57
  return __awaiter(void 0, void 0, void 0, function () {
58
- var payload, data, _b, step_name, merchant_id, config, country_code, publicKey, terminalData, nextScreen;
58
+ var payload, data, _b, step_name, merchant_id, config, country_code, publicKey, nextScreen, terminalData, err_1;
59
59
  var _c;
60
60
  return __generator(this, function (_d) {
61
61
  switch (_d.label) {
@@ -79,16 +79,28 @@ export var verifyToken = createAsyncThunk('terminal/verifyLeadToken', function (
79
79
  if (step_name === TERMINAL_STEP_NAMES.PHONE_AUTH) {
80
80
  return [2, { data: data, token: token, nextScreen: CONNECT_FLOWS.terminal.verify }];
81
81
  }
82
- return [4, API.terminalService.retrieveTerminalList([merchant_id])];
82
+ nextScreen = CONNECT_FLOWS.terminal.terminalDeviceList;
83
+ terminalData = undefined;
84
+ _d.label = 2;
83
85
  case 2:
86
+ _d.trys.push([2, 4, , 5]);
87
+ return [4, API.terminalService.retrieveTerminalList([merchant_id])];
88
+ case 3:
84
89
  terminalData = _d.sent();
85
90
  nextScreen = ((_c = terminalData === null || terminalData === void 0 ? void 0 : terminalData.list) === null || _c === void 0 ? void 0 : _c.length) ? CONNECT_FLOWS.terminal.terminalDeviceList : CONNECT_FLOWS.terminal.noTerminalLinked;
86
- return [2, {
87
- data: data,
88
- token: token,
89
- terminalData: terminalData,
90
- nextScreen: nextScreen
91
- }];
91
+ return [3, 5];
92
+ case 4:
93
+ err_1 = _d.sent();
94
+ if (!isNoDataFoundError(err_1 === null || err_1 === void 0 ? void 0 : err_1.message))
95
+ throw new Error(err_1);
96
+ nextScreen = CONNECT_FLOWS.terminal.noTerminalLinked;
97
+ return [3, 5];
98
+ case 5: return [2, {
99
+ data: data,
100
+ token: token,
101
+ terminalData: terminalData,
102
+ nextScreen: nextScreen
103
+ }];
92
104
  }
93
105
  });
94
106
  });
@@ -111,7 +123,7 @@ export var resendOTP = createAsyncThunk('terminal/resendOTP', function (params,
111
123
  });
112
124
  }); });
113
125
  export var verifyTokenOTP = createAsyncThunk('terminal/verifyOtp', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
114
- var _a, terminal, settings, authData, payload, data, _b, config, country_code, merchant_id, publicKey, countryIso2, terminalData, nextScreen;
126
+ var _a, terminal, settings, authData, payload, data, _b, config, country_code, merchant_id, publicKey, countryIso2, nextScreen, terminalData, err_2;
115
127
  var _c, _d, _e, _f;
116
128
  return __generator(this, function (_g) {
117
129
  switch (_g.label) {
@@ -135,10 +147,23 @@ export var verifyTokenOTP = createAsyncThunk('terminal/verifyOtp', function (par
135
147
  thunkApi.dispatch(handlePublicKey(publicKey));
136
148
  if (countryIso2)
137
149
  thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
138
- return [4, API.terminalService.retrieveTerminalList([merchant_id])];
150
+ nextScreen = CONNECT_FLOWS.terminal.terminalDeviceList;
151
+ terminalData = undefined;
152
+ _g.label = 2;
139
153
  case 2:
154
+ _g.trys.push([2, 4, , 5]);
155
+ return [4, API.terminalService.retrieveTerminalList([merchant_id])];
156
+ case 3:
140
157
  terminalData = _g.sent();
141
158
  nextScreen = ((_d = terminalData === null || terminalData === void 0 ? void 0 : terminalData.list) === null || _d === void 0 ? void 0 : _d.length) ? CONNECT_FLOWS.terminal.terminalDeviceList : CONNECT_FLOWS.terminal.noTerminalLinked;
159
+ return [3, 5];
160
+ case 4:
161
+ err_2 = _g.sent();
162
+ if (!isNoDataFoundError(err_2 === null || err_2 === void 0 ? void 0 : err_2.message))
163
+ throw new Error(err_2);
164
+ nextScreen = CONNECT_FLOWS.terminal.noTerminalLinked;
165
+ return [3, 5];
166
+ case 5:
142
167
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, { otp: params.otp });
143
168
  return [2, { data: data, terminalData: terminalData, formData: params, nextScreen: nextScreen }];
144
169
  }
@@ -3,3 +3,4 @@ export declare const isTokenExpired: (error: string | null) => boolean;
3
3
  export declare const isTimeoutError: (error: string | null) => boolean;
4
4
  export declare const isInternalServerError: (error: string | null) => boolean;
5
5
  export declare const isAuthenticationVerificationFailed: (error: string | null) => boolean;
6
+ export declare const isNoDataFoundError: (error: string | null) => boolean;
@@ -13,3 +13,6 @@ export var isInternalServerError = function (error) {
13
13
  export var isAuthenticationVerificationFailed = function (error) {
14
14
  return ['failed to verify the auth'].includes((error || '').trim().toLowerCase());
15
15
  };
16
+ export var isNoDataFoundError = function (error) {
17
+ return ['no data found'].includes((error || '').trim().toLowerCase());
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.11.19-development",
3
+ "version": "2.11.20-development",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",