@fctc/interface-logic 1.0.9 → 1.2.0
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.
- package/dist/config.js +7 -34
- package/dist/config.mjs +7 -34
- package/dist/constants.d.mts +1 -4
- package/dist/constants.d.ts +1 -4
- package/dist/constants.js +0 -3
- package/dist/constants.mjs +0 -3
- package/dist/environment.d.mts +0 -1
- package/dist/environment.d.ts +0 -1
- package/dist/environment.js +7 -36
- package/dist/environment.mjs +7 -36
- package/dist/hook.d.mts +1 -45
- package/dist/hook.d.ts +1 -45
- package/dist/hook.js +112 -444
- package/dist/hook.mjs +71 -395
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +152 -452
- package/dist/index.mjs +106 -398
- package/dist/model.js +7 -39
- package/dist/model.mjs +7 -39
- package/dist/provider.d.mts +3 -4
- package/dist/provider.d.ts +3 -4
- package/dist/provider.js +13 -160
- package/dist/provider.mjs +13 -160
- package/dist/services.d.mts +1 -35
- package/dist/services.d.ts +1 -35
- package/dist/services.js +10 -192
- package/dist/services.mjs +10 -192
- package/dist/utils.d.mts +7 -4
- package/dist/utils.d.ts +7 -4
- package/dist/utils.js +35 -21
- package/dist/utils.mjs +34 -20
- package/package.json +87 -87
package/dist/config.js
CHANGED
@@ -2147,25 +2147,7 @@ function matchDomain(record, domain) {
|
|
2147
2147
|
}
|
2148
2148
|
|
2149
2149
|
// src/utils/function.ts
|
2150
|
-
var
|
2151
|
-
if (!originalRequest.data) return originalRequest.data;
|
2152
|
-
if (typeof originalRequest.data === "string") {
|
2153
|
-
try {
|
2154
|
-
const parsedData = JSON.parse(originalRequest.data);
|
2155
|
-
if (parsedData.with_context && typeof parsedData.with_context === "object") {
|
2156
|
-
parsedData.with_context.token = newAccessToken;
|
2157
|
-
}
|
2158
|
-
return JSON.stringify(parsedData);
|
2159
|
-
} catch (e) {
|
2160
|
-
console.warn("Failed to parse originalRequest.data", e);
|
2161
|
-
return originalRequest.data;
|
2162
|
-
}
|
2163
|
-
}
|
2164
|
-
if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
|
2165
|
-
originalRequest.data.with_context.token = newAccessToken;
|
2166
|
-
}
|
2167
|
-
return originalRequest.data;
|
2168
|
-
};
|
2150
|
+
var import_react = require("react");
|
2169
2151
|
|
2170
2152
|
// src/utils/storage/local-storage.ts
|
2171
2153
|
var localStorageUtils = () => {
|
@@ -2230,8 +2212,7 @@ var axiosClient = {
|
|
2230
2212
|
});
|
2231
2213
|
instance.interceptors.request.use(
|
2232
2214
|
async (config2) => {
|
2233
|
-
const
|
2234
|
-
const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
|
2215
|
+
const token = await localStorage2.getAccessToken();
|
2235
2216
|
if (token) {
|
2236
2217
|
config2.headers["Authorization"] = "Bearer " + token;
|
2237
2218
|
}
|
@@ -2257,7 +2238,7 @@ var axiosClient = {
|
|
2257
2238
|
return data;
|
2258
2239
|
};
|
2259
2240
|
const originalRequest = error.config;
|
2260
|
-
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401
|
2241
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
|
2261
2242
|
error.response.data.code
|
2262
2243
|
)) {
|
2263
2244
|
if (isRefreshing) {
|
@@ -2265,10 +2246,6 @@ var axiosClient = {
|
|
2265
2246
|
failedQueue.push({ resolve, reject });
|
2266
2247
|
}).then((token) => {
|
2267
2248
|
originalRequest.headers["Authorization"] = "Bearer " + token;
|
2268
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
2269
|
-
originalRequest,
|
2270
|
-
token
|
2271
|
-
);
|
2272
2249
|
return instance.request(originalRequest);
|
2273
2250
|
}).catch(async (err) => {
|
2274
2251
|
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
@@ -2293,11 +2270,11 @@ var axiosClient = {
|
|
2293
2270
|
);
|
2294
2271
|
return new Promise(function(resolve) {
|
2295
2272
|
import_axios.default.post(
|
2296
|
-
`${config.baseUrl}${
|
2273
|
+
`${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
2297
2274
|
payload,
|
2298
2275
|
{
|
2299
2276
|
headers: {
|
2300
|
-
"Content-Type":
|
2277
|
+
"Content-Type": "multipart/form-data",
|
2301
2278
|
Authorization: `Bearer ${accessTokenExp}`
|
2302
2279
|
}
|
2303
2280
|
}
|
@@ -2307,14 +2284,10 @@ var axiosClient = {
|
|
2307
2284
|
await localStorage2.setRefreshToken(data.refresh_token);
|
2308
2285
|
import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
2309
2286
|
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
2310
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
2311
|
-
originalRequest,
|
2312
|
-
data.access_token
|
2313
|
-
);
|
2314
2287
|
processQueue(null, data.access_token);
|
2315
2288
|
resolve(instance.request(originalRequest));
|
2316
2289
|
}).catch(async (err) => {
|
2317
|
-
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")
|
2290
|
+
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
|
2318
2291
|
await clearAuthToken();
|
2319
2292
|
}
|
2320
2293
|
if (err && err.response) {
|
@@ -2364,7 +2337,7 @@ var axiosClient = {
|
|
2364
2337
|
const responseBody = (response) => response;
|
2365
2338
|
const requests = {
|
2366
2339
|
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
2367
|
-
post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
|
2340
|
+
post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
|
2368
2341
|
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
2369
2342
|
responseType: "arraybuffer",
|
2370
2343
|
headers: {
|
package/dist/config.mjs
CHANGED
@@ -2111,25 +2111,7 @@ function matchDomain(record, domain) {
|
|
2111
2111
|
}
|
2112
2112
|
|
2113
2113
|
// src/utils/function.ts
|
2114
|
-
|
2115
|
-
if (!originalRequest.data) return originalRequest.data;
|
2116
|
-
if (typeof originalRequest.data === "string") {
|
2117
|
-
try {
|
2118
|
-
const parsedData = JSON.parse(originalRequest.data);
|
2119
|
-
if (parsedData.with_context && typeof parsedData.with_context === "object") {
|
2120
|
-
parsedData.with_context.token = newAccessToken;
|
2121
|
-
}
|
2122
|
-
return JSON.stringify(parsedData);
|
2123
|
-
} catch (e) {
|
2124
|
-
console.warn("Failed to parse originalRequest.data", e);
|
2125
|
-
return originalRequest.data;
|
2126
|
-
}
|
2127
|
-
}
|
2128
|
-
if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
|
2129
|
-
originalRequest.data.with_context.token = newAccessToken;
|
2130
|
-
}
|
2131
|
-
return originalRequest.data;
|
2132
|
-
};
|
2114
|
+
import { useEffect, useState } from "react";
|
2133
2115
|
|
2134
2116
|
// src/utils/storage/local-storage.ts
|
2135
2117
|
var localStorageUtils = () => {
|
@@ -2194,8 +2176,7 @@ var axiosClient = {
|
|
2194
2176
|
});
|
2195
2177
|
instance.interceptors.request.use(
|
2196
2178
|
async (config2) => {
|
2197
|
-
const
|
2198
|
-
const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
|
2179
|
+
const token = await localStorage2.getAccessToken();
|
2199
2180
|
if (token) {
|
2200
2181
|
config2.headers["Authorization"] = "Bearer " + token;
|
2201
2182
|
}
|
@@ -2221,7 +2202,7 @@ var axiosClient = {
|
|
2221
2202
|
return data;
|
2222
2203
|
};
|
2223
2204
|
const originalRequest = error.config;
|
2224
|
-
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401
|
2205
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
|
2225
2206
|
error.response.data.code
|
2226
2207
|
)) {
|
2227
2208
|
if (isRefreshing) {
|
@@ -2229,10 +2210,6 @@ var axiosClient = {
|
|
2229
2210
|
failedQueue.push({ resolve, reject });
|
2230
2211
|
}).then((token) => {
|
2231
2212
|
originalRequest.headers["Authorization"] = "Bearer " + token;
|
2232
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
2233
|
-
originalRequest,
|
2234
|
-
token
|
2235
|
-
);
|
2236
2213
|
return instance.request(originalRequest);
|
2237
2214
|
}).catch(async (err) => {
|
2238
2215
|
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
@@ -2257,11 +2234,11 @@ var axiosClient = {
|
|
2257
2234
|
);
|
2258
2235
|
return new Promise(function(resolve) {
|
2259
2236
|
axios.post(
|
2260
|
-
`${config.baseUrl}${
|
2237
|
+
`${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
2261
2238
|
payload,
|
2262
2239
|
{
|
2263
2240
|
headers: {
|
2264
|
-
"Content-Type":
|
2241
|
+
"Content-Type": "multipart/form-data",
|
2265
2242
|
Authorization: `Bearer ${accessTokenExp}`
|
2266
2243
|
}
|
2267
2244
|
}
|
@@ -2271,14 +2248,10 @@ var axiosClient = {
|
|
2271
2248
|
await localStorage2.setRefreshToken(data.refresh_token);
|
2272
2249
|
axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
2273
2250
|
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
2274
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
2275
|
-
originalRequest,
|
2276
|
-
data.access_token
|
2277
|
-
);
|
2278
2251
|
processQueue(null, data.access_token);
|
2279
2252
|
resolve(instance.request(originalRequest));
|
2280
2253
|
}).catch(async (err) => {
|
2281
|
-
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")
|
2254
|
+
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
|
2282
2255
|
await clearAuthToken();
|
2283
2256
|
}
|
2284
2257
|
if (err && err.response) {
|
@@ -2328,7 +2301,7 @@ var axiosClient = {
|
|
2328
2301
|
const responseBody = (response) => response;
|
2329
2302
|
const requests = {
|
2330
2303
|
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
2331
|
-
post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
|
2304
|
+
post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
|
2332
2305
|
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
2333
2306
|
responseType: "arraybuffer",
|
2334
2307
|
headers: {
|
package/dist/constants.d.mts
CHANGED
@@ -45,10 +45,7 @@ declare enum UriConstants {
|
|
45
45
|
TOKEN = "/check_token",
|
46
46
|
CREATE_UPDATE_PATH = "/create_update",
|
47
47
|
TWOFA_METHOD_PATH = "/id/api/v2/call",
|
48
|
-
SIGNIN_SSO = "/signin-sso/oauth"
|
49
|
-
GRANT_ACCESS = "/grant-access",
|
50
|
-
TOKEN_BY_CODE = "/token",
|
51
|
-
LOGOUT = "/logout"
|
48
|
+
SIGNIN_SSO = "/signin-sso/oauth"
|
52
49
|
}
|
53
50
|
|
54
51
|
declare enum FieldTypeConstants {
|
package/dist/constants.d.ts
CHANGED
@@ -45,10 +45,7 @@ declare enum UriConstants {
|
|
45
45
|
TOKEN = "/check_token",
|
46
46
|
CREATE_UPDATE_PATH = "/create_update",
|
47
47
|
TWOFA_METHOD_PATH = "/id/api/v2/call",
|
48
|
-
SIGNIN_SSO = "/signin-sso/oauth"
|
49
|
-
GRANT_ACCESS = "/grant-access",
|
50
|
-
TOKEN_BY_CODE = "/token",
|
51
|
-
LOGOUT = "/logout"
|
48
|
+
SIGNIN_SSO = "/signin-sso/oauth"
|
52
49
|
}
|
53
50
|
|
54
51
|
declare enum FieldTypeConstants {
|
package/dist/constants.js
CHANGED
@@ -89,9 +89,6 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
|
|
89
89
|
UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
|
90
90
|
UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
|
91
91
|
UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
|
92
|
-
UriConstants2["GRANT_ACCESS"] = "/grant-access";
|
93
|
-
UriConstants2["TOKEN_BY_CODE"] = "/token";
|
94
|
-
UriConstants2["LOGOUT"] = "/logout";
|
95
92
|
return UriConstants2;
|
96
93
|
})(UriConstants || {});
|
97
94
|
|
package/dist/constants.mjs
CHANGED
@@ -51,9 +51,6 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
|
|
51
51
|
UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
|
52
52
|
UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
|
53
53
|
UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
|
54
|
-
UriConstants2["GRANT_ACCESS"] = "/grant-access";
|
55
|
-
UriConstants2["TOKEN_BY_CODE"] = "/token";
|
56
|
-
UriConstants2["LOGOUT"] = "/logout";
|
57
54
|
return UriConstants2;
|
58
55
|
})(UriConstants || {});
|
59
56
|
|
package/dist/environment.d.mts
CHANGED
@@ -21,7 +21,6 @@ declare class EnvStore {
|
|
21
21
|
db?: string;
|
22
22
|
localStorageUtils?: any;
|
23
23
|
sessionStorageUtils?: any;
|
24
|
-
refreshTokenEndpoint?: string;
|
25
24
|
constructor(envStore: EnhancedStore, localStorageUtils?: any, sessionStorageUtils?: any);
|
26
25
|
setup(): void;
|
27
26
|
setupEnv(envConfig: EnvStore): void;
|
package/dist/environment.d.ts
CHANGED
@@ -21,7 +21,6 @@ declare class EnvStore {
|
|
21
21
|
db?: string;
|
22
22
|
localStorageUtils?: any;
|
23
23
|
sessionStorageUtils?: any;
|
24
|
-
refreshTokenEndpoint?: string;
|
25
24
|
constructor(envStore: EnhancedStore, localStorageUtils?: any, sessionStorageUtils?: any);
|
26
25
|
setup(): void;
|
27
26
|
setupEnv(envConfig: EnvStore): void;
|
package/dist/environment.js
CHANGED
@@ -2150,25 +2150,7 @@ function matchDomain(record, domain) {
|
|
2150
2150
|
}
|
2151
2151
|
|
2152
2152
|
// src/utils/function.ts
|
2153
|
-
var
|
2154
|
-
if (!originalRequest.data) return originalRequest.data;
|
2155
|
-
if (typeof originalRequest.data === "string") {
|
2156
|
-
try {
|
2157
|
-
const parsedData = JSON.parse(originalRequest.data);
|
2158
|
-
if (parsedData.with_context && typeof parsedData.with_context === "object") {
|
2159
|
-
parsedData.with_context.token = newAccessToken;
|
2160
|
-
}
|
2161
|
-
return JSON.stringify(parsedData);
|
2162
|
-
} catch (e) {
|
2163
|
-
console.warn("Failed to parse originalRequest.data", e);
|
2164
|
-
return originalRequest.data;
|
2165
|
-
}
|
2166
|
-
}
|
2167
|
-
if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
|
2168
|
-
originalRequest.data.with_context.token = newAccessToken;
|
2169
|
-
}
|
2170
|
-
return originalRequest.data;
|
2171
|
-
};
|
2153
|
+
var import_react = require("react");
|
2172
2154
|
|
2173
2155
|
// src/utils/storage/local-storage.ts
|
2174
2156
|
var localStorageUtils = () => {
|
@@ -2233,8 +2215,7 @@ var axiosClient = {
|
|
2233
2215
|
});
|
2234
2216
|
instance.interceptors.request.use(
|
2235
2217
|
async (config2) => {
|
2236
|
-
const
|
2237
|
-
const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
|
2218
|
+
const token = await localStorage2.getAccessToken();
|
2238
2219
|
if (token) {
|
2239
2220
|
config2.headers["Authorization"] = "Bearer " + token;
|
2240
2221
|
}
|
@@ -2260,7 +2241,7 @@ var axiosClient = {
|
|
2260
2241
|
return data;
|
2261
2242
|
};
|
2262
2243
|
const originalRequest = error.config;
|
2263
|
-
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401
|
2244
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
|
2264
2245
|
error.response.data.code
|
2265
2246
|
)) {
|
2266
2247
|
if (isRefreshing) {
|
@@ -2268,10 +2249,6 @@ var axiosClient = {
|
|
2268
2249
|
failedQueue.push({ resolve, reject });
|
2269
2250
|
}).then((token) => {
|
2270
2251
|
originalRequest.headers["Authorization"] = "Bearer " + token;
|
2271
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
2272
|
-
originalRequest,
|
2273
|
-
token
|
2274
|
-
);
|
2275
2252
|
return instance.request(originalRequest);
|
2276
2253
|
}).catch(async (err) => {
|
2277
2254
|
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
@@ -2296,11 +2273,11 @@ var axiosClient = {
|
|
2296
2273
|
);
|
2297
2274
|
return new Promise(function(resolve) {
|
2298
2275
|
import_axios.default.post(
|
2299
|
-
`${config.baseUrl}${
|
2276
|
+
`${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
2300
2277
|
payload,
|
2301
2278
|
{
|
2302
2279
|
headers: {
|
2303
|
-
"Content-Type":
|
2280
|
+
"Content-Type": "multipart/form-data",
|
2304
2281
|
Authorization: `Bearer ${accessTokenExp}`
|
2305
2282
|
}
|
2306
2283
|
}
|
@@ -2310,14 +2287,10 @@ var axiosClient = {
|
|
2310
2287
|
await localStorage2.setRefreshToken(data.refresh_token);
|
2311
2288
|
import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
2312
2289
|
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
2313
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
2314
|
-
originalRequest,
|
2315
|
-
data.access_token
|
2316
|
-
);
|
2317
2290
|
processQueue(null, data.access_token);
|
2318
2291
|
resolve(instance.request(originalRequest));
|
2319
2292
|
}).catch(async (err) => {
|
2320
|
-
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")
|
2293
|
+
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
|
2321
2294
|
await clearAuthToken();
|
2322
2295
|
}
|
2323
2296
|
if (err && err.response) {
|
@@ -2367,7 +2340,7 @@ var axiosClient = {
|
|
2367
2340
|
const responseBody = (response) => response;
|
2368
2341
|
const requests = {
|
2369
2342
|
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
2370
|
-
post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
|
2343
|
+
post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
|
2371
2344
|
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
2372
2345
|
responseType: "arraybuffer",
|
2373
2346
|
headers: {
|
@@ -3010,7 +2983,6 @@ var EnvStore = class {
|
|
3010
2983
|
db;
|
3011
2984
|
localStorageUtils;
|
3012
2985
|
sessionStorageUtils;
|
3013
|
-
refreshTokenEndpoint;
|
3014
2986
|
constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
3015
2987
|
this.envStore = envStore2;
|
3016
2988
|
this.localStorageUtils = localStorageUtils2;
|
@@ -3027,7 +2999,6 @@ var EnvStore = class {
|
|
3027
2999
|
this.companies = env2?.companies || [];
|
3028
3000
|
this.user = env2?.user;
|
3029
3001
|
this.db = env2?.db;
|
3030
|
-
this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
|
3031
3002
|
}
|
3032
3003
|
setupEnv(envConfig) {
|
3033
3004
|
const dispatch = this.envStore.dispatch;
|
package/dist/environment.mjs
CHANGED
@@ -2111,25 +2111,7 @@ function matchDomain(record, domain) {
|
|
2111
2111
|
}
|
2112
2112
|
|
2113
2113
|
// src/utils/function.ts
|
2114
|
-
|
2115
|
-
if (!originalRequest.data) return originalRequest.data;
|
2116
|
-
if (typeof originalRequest.data === "string") {
|
2117
|
-
try {
|
2118
|
-
const parsedData = JSON.parse(originalRequest.data);
|
2119
|
-
if (parsedData.with_context && typeof parsedData.with_context === "object") {
|
2120
|
-
parsedData.with_context.token = newAccessToken;
|
2121
|
-
}
|
2122
|
-
return JSON.stringify(parsedData);
|
2123
|
-
} catch (e) {
|
2124
|
-
console.warn("Failed to parse originalRequest.data", e);
|
2125
|
-
return originalRequest.data;
|
2126
|
-
}
|
2127
|
-
}
|
2128
|
-
if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
|
2129
|
-
originalRequest.data.with_context.token = newAccessToken;
|
2130
|
-
}
|
2131
|
-
return originalRequest.data;
|
2132
|
-
};
|
2114
|
+
import { useEffect, useState } from "react";
|
2133
2115
|
|
2134
2116
|
// src/utils/storage/local-storage.ts
|
2135
2117
|
var localStorageUtils = () => {
|
@@ -2194,8 +2176,7 @@ var axiosClient = {
|
|
2194
2176
|
});
|
2195
2177
|
instance.interceptors.request.use(
|
2196
2178
|
async (config2) => {
|
2197
|
-
const
|
2198
|
-
const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
|
2179
|
+
const token = await localStorage2.getAccessToken();
|
2199
2180
|
if (token) {
|
2200
2181
|
config2.headers["Authorization"] = "Bearer " + token;
|
2201
2182
|
}
|
@@ -2221,7 +2202,7 @@ var axiosClient = {
|
|
2221
2202
|
return data;
|
2222
2203
|
};
|
2223
2204
|
const originalRequest = error.config;
|
2224
|
-
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401
|
2205
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
|
2225
2206
|
error.response.data.code
|
2226
2207
|
)) {
|
2227
2208
|
if (isRefreshing) {
|
@@ -2229,10 +2210,6 @@ var axiosClient = {
|
|
2229
2210
|
failedQueue.push({ resolve, reject });
|
2230
2211
|
}).then((token) => {
|
2231
2212
|
originalRequest.headers["Authorization"] = "Bearer " + token;
|
2232
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
2233
|
-
originalRequest,
|
2234
|
-
token
|
2235
|
-
);
|
2236
2213
|
return instance.request(originalRequest);
|
2237
2214
|
}).catch(async (err) => {
|
2238
2215
|
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
@@ -2257,11 +2234,11 @@ var axiosClient = {
|
|
2257
2234
|
);
|
2258
2235
|
return new Promise(function(resolve) {
|
2259
2236
|
axios.post(
|
2260
|
-
`${config.baseUrl}${
|
2237
|
+
`${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
2261
2238
|
payload,
|
2262
2239
|
{
|
2263
2240
|
headers: {
|
2264
|
-
"Content-Type":
|
2241
|
+
"Content-Type": "multipart/form-data",
|
2265
2242
|
Authorization: `Bearer ${accessTokenExp}`
|
2266
2243
|
}
|
2267
2244
|
}
|
@@ -2271,14 +2248,10 @@ var axiosClient = {
|
|
2271
2248
|
await localStorage2.setRefreshToken(data.refresh_token);
|
2272
2249
|
axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
2273
2250
|
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
2274
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
2275
|
-
originalRequest,
|
2276
|
-
data.access_token
|
2277
|
-
);
|
2278
2251
|
processQueue(null, data.access_token);
|
2279
2252
|
resolve(instance.request(originalRequest));
|
2280
2253
|
}).catch(async (err) => {
|
2281
|
-
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")
|
2254
|
+
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
|
2282
2255
|
await clearAuthToken();
|
2283
2256
|
}
|
2284
2257
|
if (err && err.response) {
|
@@ -2328,7 +2301,7 @@ var axiosClient = {
|
|
2328
2301
|
const responseBody = (response) => response;
|
2329
2302
|
const requests = {
|
2330
2303
|
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
2331
|
-
post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
|
2304
|
+
post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
|
2332
2305
|
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
2333
2306
|
responseType: "arraybuffer",
|
2334
2307
|
headers: {
|
@@ -2971,7 +2944,6 @@ var EnvStore = class {
|
|
2971
2944
|
db;
|
2972
2945
|
localStorageUtils;
|
2973
2946
|
sessionStorageUtils;
|
2974
|
-
refreshTokenEndpoint;
|
2975
2947
|
constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
2976
2948
|
this.envStore = envStore2;
|
2977
2949
|
this.localStorageUtils = localStorageUtils2;
|
@@ -2988,7 +2960,6 @@ var EnvStore = class {
|
|
2988
2960
|
this.companies = env2?.companies || [];
|
2989
2961
|
this.user = env2?.user;
|
2990
2962
|
this.db = env2?.db;
|
2991
|
-
this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
|
2992
2963
|
}
|
2993
2964
|
setupEnv(envConfig) {
|
2994
2965
|
const dispatch = this.envStore.dispatch;
|
package/dist/hook.d.mts
CHANGED
@@ -36,12 +36,6 @@ declare const useResetPasswordSSO: () => _tanstack_react_query.UseMutationResult
|
|
36
36
|
|
37
37
|
declare const useUpdatePassword: () => _tanstack_react_query.UseMutationResult<any, Error, updatePasswordBody, unknown>;
|
38
38
|
|
39
|
-
declare const useLogout: () => _tanstack_react_query.UseMutationResult<any, Error, string, unknown>;
|
40
|
-
|
41
|
-
declare const useGetAccessByCode: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
42
|
-
code: string;
|
43
|
-
}, unknown>;
|
44
|
-
|
45
39
|
declare const useGetCompanyInfo: () => _tanstack_react_query.UseMutationResult<any, Error, number, unknown>;
|
46
40
|
|
47
41
|
declare const useGetCurrentCompany: () => _tanstack_react_query.UseMutationResult<any, Error, void, unknown>;
|
@@ -291,8 +285,6 @@ declare const useVerify2FA: () => _tanstack_react_query.UseMutationResult<any, E
|
|
291
285
|
method: string;
|
292
286
|
with_context: any;
|
293
287
|
code: string;
|
294
|
-
device: string;
|
295
|
-
location: string;
|
296
288
|
}, unknown>;
|
297
289
|
|
298
290
|
declare const useGet2FAMethods: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
@@ -300,40 +292,4 @@ declare const useGet2FAMethods: () => _tanstack_react_query.UseMutationResult<an
|
|
300
292
|
with_context: any;
|
301
293
|
}, unknown>;
|
302
294
|
|
303
|
-
|
304
|
-
method: string;
|
305
|
-
token: string;
|
306
|
-
views: any;
|
307
|
-
}, unknown>;
|
308
|
-
|
309
|
-
declare const useGrantAccess: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
310
|
-
redirect_uri: string;
|
311
|
-
state: string;
|
312
|
-
client_id: string;
|
313
|
-
scopes: string[];
|
314
|
-
}, unknown>;
|
315
|
-
|
316
|
-
declare const useRemoveTotpSetup: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
317
|
-
method: string;
|
318
|
-
token: string;
|
319
|
-
}, unknown>;
|
320
|
-
|
321
|
-
declare const useRequestSetupTotp: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
322
|
-
method: string;
|
323
|
-
token: string;
|
324
|
-
}, unknown>;
|
325
|
-
|
326
|
-
declare const useSettingsWebRead2fa: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
327
|
-
method: string;
|
328
|
-
model: string;
|
329
|
-
kwargs: any;
|
330
|
-
token: string;
|
331
|
-
}, unknown>;
|
332
|
-
|
333
|
-
declare const useVerifyTotp: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
334
|
-
method: string;
|
335
|
-
action_token: string;
|
336
|
-
code: string;
|
337
|
-
}, unknown>;
|
338
|
-
|
339
|
-
export { useButton, useChangeStatus, useDelete, useDeleteComment, useDuplicateRecord, useExecuteImport, useExportExcel, useForgotPassword, useForgotPasswordSSO, useGet2FAMethods, useGetAccessByCode, useGetActionDetail, useGetAll, useGetCalendar, useGetComment, useGetCompanyInfo, useGetConversionRate, useGetCurrency, useGetCurrentCompany, useGetDetail, useGetFieldExport, useGetFieldOnChange, useGetFieldsViewSecurity, useGetFileExcel, useGetFormView, useGetGroups, useGetImage, useGetListCompany, useGetListData, useGetListMyBankAccount, useGetMenu, useGetPrintReport, useGetProGressBar, useGetProfile, useGetProvider, useGetResequence, useGetUser, useGetView, useGrantAccess, useIsValidToken, useLoadAction, useLoadMessage, useLoginCredential, useLoginSocial, useLogout, useModel, useOdooDataTransform, useOnChangeForm, useParsePreview, usePrint, useRemoveRow, useRemoveTotpSetup, useRequestSetupTotp, useResetPassword, useResetPasswordSSO, useRunAction, useSave, useSendComment, useSettingsWebRead2fa, useSignInSSO, useSwitchLocale, useUpdatePassword, useUploadFile, useUploadIdFile, useUploadImage, useVerify2FA, useVerifyTotp };
|
295
|
+
export { useButton, useChangeStatus, useDelete, useDeleteComment, useDuplicateRecord, useExecuteImport, useExportExcel, useForgotPassword, useForgotPasswordSSO, useGet2FAMethods, useGetActionDetail, useGetAll, useGetCalendar, useGetComment, useGetCompanyInfo, useGetConversionRate, useGetCurrency, useGetCurrentCompany, useGetDetail, useGetFieldExport, useGetFieldOnChange, useGetFileExcel, useGetFormView, useGetGroups, useGetImage, useGetListCompany, useGetListData, useGetListMyBankAccount, useGetMenu, useGetPrintReport, useGetProGressBar, useGetProfile, useGetProvider, useGetResequence, useGetUser, useGetView, useIsValidToken, useLoadAction, useLoadMessage, useLoginCredential, useLoginSocial, useModel, useOdooDataTransform, useOnChangeForm, useParsePreview, usePrint, useRemoveRow, useResetPassword, useResetPasswordSSO, useRunAction, useSave, useSendComment, useSignInSSO, useSwitchLocale, useUpdatePassword, useUploadFile, useUploadIdFile, useUploadImage, useVerify2FA };
|
package/dist/hook.d.ts
CHANGED
@@ -36,12 +36,6 @@ declare const useResetPasswordSSO: () => _tanstack_react_query.UseMutationResult
|
|
36
36
|
|
37
37
|
declare const useUpdatePassword: () => _tanstack_react_query.UseMutationResult<any, Error, updatePasswordBody, unknown>;
|
38
38
|
|
39
|
-
declare const useLogout: () => _tanstack_react_query.UseMutationResult<any, Error, string, unknown>;
|
40
|
-
|
41
|
-
declare const useGetAccessByCode: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
42
|
-
code: string;
|
43
|
-
}, unknown>;
|
44
|
-
|
45
39
|
declare const useGetCompanyInfo: () => _tanstack_react_query.UseMutationResult<any, Error, number, unknown>;
|
46
40
|
|
47
41
|
declare const useGetCurrentCompany: () => _tanstack_react_query.UseMutationResult<any, Error, void, unknown>;
|
@@ -291,8 +285,6 @@ declare const useVerify2FA: () => _tanstack_react_query.UseMutationResult<any, E
|
|
291
285
|
method: string;
|
292
286
|
with_context: any;
|
293
287
|
code: string;
|
294
|
-
device: string;
|
295
|
-
location: string;
|
296
288
|
}, unknown>;
|
297
289
|
|
298
290
|
declare const useGet2FAMethods: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
@@ -300,40 +292,4 @@ declare const useGet2FAMethods: () => _tanstack_react_query.UseMutationResult<an
|
|
300
292
|
with_context: any;
|
301
293
|
}, unknown>;
|
302
294
|
|
303
|
-
|
304
|
-
method: string;
|
305
|
-
token: string;
|
306
|
-
views: any;
|
307
|
-
}, unknown>;
|
308
|
-
|
309
|
-
declare const useGrantAccess: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
310
|
-
redirect_uri: string;
|
311
|
-
state: string;
|
312
|
-
client_id: string;
|
313
|
-
scopes: string[];
|
314
|
-
}, unknown>;
|
315
|
-
|
316
|
-
declare const useRemoveTotpSetup: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
317
|
-
method: string;
|
318
|
-
token: string;
|
319
|
-
}, unknown>;
|
320
|
-
|
321
|
-
declare const useRequestSetupTotp: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
322
|
-
method: string;
|
323
|
-
token: string;
|
324
|
-
}, unknown>;
|
325
|
-
|
326
|
-
declare const useSettingsWebRead2fa: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
327
|
-
method: string;
|
328
|
-
model: string;
|
329
|
-
kwargs: any;
|
330
|
-
token: string;
|
331
|
-
}, unknown>;
|
332
|
-
|
333
|
-
declare const useVerifyTotp: () => _tanstack_react_query.UseMutationResult<any, Error, {
|
334
|
-
method: string;
|
335
|
-
action_token: string;
|
336
|
-
code: string;
|
337
|
-
}, unknown>;
|
338
|
-
|
339
|
-
export { useButton, useChangeStatus, useDelete, useDeleteComment, useDuplicateRecord, useExecuteImport, useExportExcel, useForgotPassword, useForgotPasswordSSO, useGet2FAMethods, useGetAccessByCode, useGetActionDetail, useGetAll, useGetCalendar, useGetComment, useGetCompanyInfo, useGetConversionRate, useGetCurrency, useGetCurrentCompany, useGetDetail, useGetFieldExport, useGetFieldOnChange, useGetFieldsViewSecurity, useGetFileExcel, useGetFormView, useGetGroups, useGetImage, useGetListCompany, useGetListData, useGetListMyBankAccount, useGetMenu, useGetPrintReport, useGetProGressBar, useGetProfile, useGetProvider, useGetResequence, useGetUser, useGetView, useGrantAccess, useIsValidToken, useLoadAction, useLoadMessage, useLoginCredential, useLoginSocial, useLogout, useModel, useOdooDataTransform, useOnChangeForm, useParsePreview, usePrint, useRemoveRow, useRemoveTotpSetup, useRequestSetupTotp, useResetPassword, useResetPasswordSSO, useRunAction, useSave, useSendComment, useSettingsWebRead2fa, useSignInSSO, useSwitchLocale, useUpdatePassword, useUploadFile, useUploadIdFile, useUploadImage, useVerify2FA, useVerifyTotp };
|
295
|
+
export { useButton, useChangeStatus, useDelete, useDeleteComment, useDuplicateRecord, useExecuteImport, useExportExcel, useForgotPassword, useForgotPasswordSSO, useGet2FAMethods, useGetActionDetail, useGetAll, useGetCalendar, useGetComment, useGetCompanyInfo, useGetConversionRate, useGetCurrency, useGetCurrentCompany, useGetDetail, useGetFieldExport, useGetFieldOnChange, useGetFileExcel, useGetFormView, useGetGroups, useGetImage, useGetListCompany, useGetListData, useGetListMyBankAccount, useGetMenu, useGetPrintReport, useGetProGressBar, useGetProfile, useGetProvider, useGetResequence, useGetUser, useGetView, useIsValidToken, useLoadAction, useLoadMessage, useLoginCredential, useLoginSocial, useModel, useOdooDataTransform, useOnChangeForm, useParsePreview, usePrint, useRemoveRow, useResetPassword, useResetPasswordSSO, useRunAction, useSave, useSendComment, useSignInSSO, useSwitchLocale, useUpdatePassword, useUploadFile, useUploadIdFile, useUploadImage, useVerify2FA };
|