squarefi-bff-api-module 1.26.0 → 1.26.2
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.
|
@@ -55,17 +55,18 @@ const createApiClient = ({ baseURL, isBearerToken, tenantId }) => {
|
|
|
55
55
|
return Object.assign(Object.assign({}, config), { headers: modifiedHeaders });
|
|
56
56
|
});
|
|
57
57
|
instance.interceptors.response.use((response) => response, (error) => {
|
|
58
|
-
var _a, _b, _c, _d, _e;
|
|
58
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
59
59
|
if (typeof window === 'undefined') {
|
|
60
60
|
return Promise.reject(error);
|
|
61
61
|
}
|
|
62
|
-
if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === constants_1.ResponseStatus.UNAUTHORIZED
|
|
62
|
+
if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === constants_1.ResponseStatus.UNAUTHORIZED &&
|
|
63
|
+
!((_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.config.context) === null || _c === void 0 ? void 0 : _c.bypassUnauthorizedHandler)) {
|
|
63
64
|
const { response, config: failedRequestConfig } = error;
|
|
64
65
|
const { refresh_token } = (0, tokensFactory_1.getTokens)();
|
|
65
|
-
const isRetryRequest = (
|
|
66
|
-
const isRefreshTokenRequest = (
|
|
67
|
-
const isTelegramSignInRequest = (
|
|
68
|
-
const isTelegramSignUpRequest = (
|
|
66
|
+
const isRetryRequest = (_d = failedRequestConfig.context) === null || _d === void 0 ? void 0 : _d.isRetryRequest;
|
|
67
|
+
const isRefreshTokenRequest = (_e = failedRequestConfig.url) === null || _e === void 0 ? void 0 : _e.includes(auth_1.refreshTokenPath);
|
|
68
|
+
const isTelegramSignInRequest = (_f = failedRequestConfig.url) === null || _f === void 0 ? void 0 : _f.includes(auth_1.telegramSignInPath);
|
|
69
|
+
const isTelegramSignUpRequest = (_g = failedRequestConfig.url) === null || _g === void 0 ? void 0 : _g.includes(auth_1.telegramSignUpPath);
|
|
69
70
|
const isRefreshNotRequired = !refresh_token && !(0, sdk_react_1.isTMA)();
|
|
70
71
|
const isLogoutNeccesary = isRefreshNotRequired ||
|
|
71
72
|
isTelegramSignInRequest ||
|
package/package.json
CHANGED
package/src/api/types/types.ts
CHANGED
|
@@ -122,7 +122,8 @@ export namespace API {
|
|
|
122
122
|
form_factor: CardFormFactor | string;
|
|
123
123
|
consent_text: string | null;
|
|
124
124
|
name: string;
|
|
125
|
-
card_limit: number;
|
|
125
|
+
// card_limit: number; deprecated, use max_cards instead
|
|
126
|
+
max_cards: number;
|
|
126
127
|
realtime_auth: boolean;
|
|
127
128
|
tokenizable: boolean;
|
|
128
129
|
kyc_rails_id: string;
|
|
@@ -66,7 +66,10 @@ export const createApiClient = ({ baseURL, isBearerToken, tenantId }: CreateApiC
|
|
|
66
66
|
if (typeof window === 'undefined') {
|
|
67
67
|
return Promise.reject(error);
|
|
68
68
|
}
|
|
69
|
-
if (
|
|
69
|
+
if (
|
|
70
|
+
error?.response?.status === ResponseStatus.UNAUTHORIZED &&
|
|
71
|
+
!error?.response?.config.context?.bypassUnauthorizedHandler
|
|
72
|
+
) {
|
|
70
73
|
const { response, config: failedRequestConfig } = error;
|
|
71
74
|
const { refresh_token } = getTokens();
|
|
72
75
|
const isRetryRequest = failedRequestConfig.context?.isRetryRequest;
|