@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/provider.mjs CHANGED
@@ -646,7 +646,7 @@ var MainProvider = ({ children }) => {
646
646
  };
647
647
 
648
648
  // src/provider/version-gate-provider.tsx
649
- import { useEffect, useState } from "react";
649
+ import { useEffect as useEffect2, useState as useState2 } from "react";
650
650
  import { useQueryClient } from "@tanstack/react-query";
651
651
 
652
652
  // src/configs/axios-client.ts
@@ -2762,25 +2762,7 @@ function matchDomain(record, domain) {
2762
2762
  }
2763
2763
 
2764
2764
  // src/utils/function.ts
2765
- var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2766
- if (!originalRequest.data) return originalRequest.data;
2767
- if (typeof originalRequest.data === "string") {
2768
- try {
2769
- const parsedData = JSON.parse(originalRequest.data);
2770
- if (parsedData.with_context && typeof parsedData.with_context === "object") {
2771
- parsedData.with_context.token = newAccessToken;
2772
- }
2773
- return JSON.stringify(parsedData);
2774
- } catch (e) {
2775
- console.warn("Failed to parse originalRequest.data", e);
2776
- return originalRequest.data;
2777
- }
2778
- }
2779
- if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2780
- originalRequest.data.with_context.token = newAccessToken;
2781
- }
2782
- return originalRequest.data;
2783
- };
2765
+ import { useEffect, useState } from "react";
2784
2766
 
2785
2767
  // src/utils/storage/local-storage.ts
2786
2768
  var localStorageUtils = () => {
@@ -2845,8 +2827,7 @@ var axiosClient = {
2845
2827
  });
2846
2828
  instance.interceptors.request.use(
2847
2829
  async (config2) => {
2848
- const useRefreshToken = config2.useRefreshToken;
2849
- const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
2830
+ const token = await localStorage2.getAccessToken();
2850
2831
  if (token) {
2851
2832
  config2.headers["Authorization"] = "Bearer " + token;
2852
2833
  }
@@ -2872,7 +2853,7 @@ var axiosClient = {
2872
2853
  return data;
2873
2854
  };
2874
2855
  const originalRequest = error.config;
2875
- if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2856
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
2876
2857
  error.response.data.code
2877
2858
  )) {
2878
2859
  if (isRefreshing) {
@@ -2880,10 +2861,6 @@ var axiosClient = {
2880
2861
  failedQueue.push({ resolve, reject });
2881
2862
  }).then((token) => {
2882
2863
  originalRequest.headers["Authorization"] = "Bearer " + token;
2883
- originalRequest.data = updateTokenParamInOriginalRequest(
2884
- originalRequest,
2885
- token
2886
- );
2887
2864
  return instance.request(originalRequest);
2888
2865
  }).catch(async (err) => {
2889
2866
  if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
@@ -2908,11 +2885,11 @@ var axiosClient = {
2908
2885
  );
2909
2886
  return new Promise(function(resolve) {
2910
2887
  axios.post(
2911
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2888
+ `${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2912
2889
  payload,
2913
2890
  {
2914
2891
  headers: {
2915
- "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2892
+ "Content-Type": "multipart/form-data",
2916
2893
  Authorization: `Bearer ${accessTokenExp}`
2917
2894
  }
2918
2895
  }
@@ -2922,14 +2899,10 @@ var axiosClient = {
2922
2899
  await localStorage2.setRefreshToken(data.refresh_token);
2923
2900
  axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2924
2901
  originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2925
- originalRequest.data = updateTokenParamInOriginalRequest(
2926
- originalRequest,
2927
- data.access_token
2928
- );
2929
2902
  processQueue(null, data.access_token);
2930
2903
  resolve(instance.request(originalRequest));
2931
2904
  }).catch(async (err) => {
2932
- if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST") || err?.error_code === "ERR_2FA_006") {
2905
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
2933
2906
  await clearAuthToken();
2934
2907
  }
2935
2908
  if (err && err.response) {
@@ -2979,7 +2952,7 @@ var axiosClient = {
2979
2952
  const responseBody = (response) => response;
2980
2953
  const requests = {
2981
2954
  get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2982
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2955
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
2983
2956
  post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2984
2957
  responseType: "arraybuffer",
2985
2958
  headers: {
@@ -3008,7 +2981,6 @@ var EnvStore = class {
3008
2981
  db;
3009
2982
  localStorageUtils;
3010
2983
  sessionStorageUtils;
3011
- refreshTokenEndpoint;
3012
2984
  constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3013
2985
  this.envStore = envStore2;
3014
2986
  this.localStorageUtils = localStorageUtils2;
@@ -3025,7 +2997,6 @@ var EnvStore = class {
3025
2997
  this.companies = env2?.companies || [];
3026
2998
  this.user = env2?.user;
3027
2999
  this.db = env2?.db;
3028
- this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
3029
3000
  }
3030
3001
  setupEnv(envConfig) {
3031
3002
  const dispatch = this.envStore.dispatch;
@@ -3361,18 +3332,14 @@ var ViewService = {
3361
3332
  async verify2FA({
3362
3333
  method,
3363
3334
  with_context,
3364
- code,
3365
- device,
3366
- location
3335
+ code
3367
3336
  }) {
3368
3337
  const env2 = getEnv();
3369
3338
  const jsonData = {
3370
3339
  method,
3371
3340
  kwargs: {
3372
3341
  vals: {
3373
- code,
3374
- device,
3375
- location
3342
+ code
3376
3343
  }
3377
3344
  },
3378
3345
  with_context
@@ -3380,8 +3347,7 @@ var ViewService = {
3380
3347
  return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3381
3348
  headers: {
3382
3349
  "Content-Type": "application/json"
3383
- },
3384
- withCredentials: true
3350
+ }
3385
3351
  });
3386
3352
  },
3387
3353
  async signInSSO({
@@ -3405,119 +3371,6 @@ var ViewService = {
3405
3371
  "Content-Type": "application/json"
3406
3372
  }
3407
3373
  });
3408
- },
3409
- async grantAccess({
3410
- redirect_uri,
3411
- state,
3412
- client_id,
3413
- scopes
3414
- }) {
3415
- const env2 = getEnv();
3416
- const jsonData = {
3417
- redirect_uri,
3418
- state,
3419
- client_id,
3420
- scopes
3421
- };
3422
- return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
3423
- headers: {
3424
- "Content-Type": "application/json"
3425
- },
3426
- withCredentials: true
3427
- });
3428
- },
3429
- async getFieldsViewSecurity({
3430
- method,
3431
- token,
3432
- views
3433
- }) {
3434
- const env2 = getEnv();
3435
- const jsonData = {
3436
- method,
3437
- kwargs: {
3438
- views
3439
- },
3440
- with_context: {
3441
- token
3442
- }
3443
- };
3444
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3445
- headers: {
3446
- "Content-Type": "application/json"
3447
- }
3448
- });
3449
- },
3450
- async settingsWebRead2fa({
3451
- method,
3452
- model,
3453
- kwargs,
3454
- token
3455
- }) {
3456
- const env2 = getEnv();
3457
- const jsonData = {
3458
- method,
3459
- model,
3460
- kwargs,
3461
- with_context: {
3462
- token
3463
- }
3464
- };
3465
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3466
- headers: {
3467
- "Content-Type": "application/json"
3468
- }
3469
- });
3470
- },
3471
- async requestSetupTotp({ method, token }) {
3472
- const env2 = getEnv();
3473
- const jsonData = {
3474
- method,
3475
- with_context: {
3476
- token
3477
- }
3478
- };
3479
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3480
- headers: {
3481
- "Content-Type": "application/json"
3482
- }
3483
- });
3484
- },
3485
- async verifyTotp({
3486
- method,
3487
- action_token,
3488
- code
3489
- }) {
3490
- const env2 = getEnv();
3491
- const jsonData = {
3492
- method,
3493
- kwargs: {
3494
- vals: {
3495
- code
3496
- }
3497
- },
3498
- with_context: {
3499
- action_token
3500
- }
3501
- };
3502
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3503
- headers: {
3504
- "Content-Type": "application/json"
3505
- }
3506
- });
3507
- },
3508
- async removeTotpSetUp({ method, token }) {
3509
- const env2 = getEnv();
3510
- const jsonData = {
3511
- method,
3512
- with_context: {
3513
- token
3514
- }
3515
- };
3516
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3517
- headers: {
3518
- "Content-Type": "application/json"
3519
- }
3520
- });
3521
3374
  }
3522
3375
  };
3523
3376
  var view_service_default = ViewService;
@@ -3526,8 +3379,8 @@ var view_service_default = ViewService;
3526
3379
  import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
3527
3380
  var VersionGate = ({ children }) => {
3528
3381
  const queryClient = useQueryClient();
3529
- const [ready, setReady] = useState(false);
3530
- useEffect(() => {
3382
+ const [ready, setReady] = useState2(false);
3383
+ useEffect2(() => {
3531
3384
  const clearVersion = () => {
3532
3385
  queryClient.clear();
3533
3386
  localStorage.removeItem("__api_version__");
@@ -60,8 +60,6 @@ declare const AuthService: {
60
60
  access_token: string;
61
61
  }): Promise<any>;
62
62
  getProviders(db?: string): Promise<any>;
63
- getAccessByCode(code: string): Promise<any>;
64
- logout(data: string): Promise<any>;
65
63
  };
66
64
 
67
65
  declare const CompanyService: {
@@ -209,12 +207,10 @@ declare const ViewService: {
209
207
  method: string;
210
208
  with_context: any;
211
209
  }): Promise<any>;
212
- verify2FA({ method, with_context, code, device, location, }: {
210
+ verify2FA({ method, with_context, code, }: {
213
211
  method: string;
214
212
  with_context: any;
215
213
  code: string;
216
- device: string;
217
- location: string;
218
214
  }): Promise<any>;
219
215
  signInSSO({ redirect_uri, state, client_id, response_type, path, }: {
220
216
  redirect_uri: string;
@@ -223,36 +219,6 @@ declare const ViewService: {
223
219
  response_type: string;
224
220
  path: string;
225
221
  }): Promise<any>;
226
- grantAccess({ redirect_uri, state, client_id, scopes, }: {
227
- redirect_uri: string;
228
- state: string;
229
- client_id: string;
230
- scopes: string[];
231
- }): Promise<any>;
232
- getFieldsViewSecurity({ method, token, views, }: {
233
- method: string;
234
- token: string;
235
- views: any;
236
- }): Promise<any>;
237
- settingsWebRead2fa({ method, model, kwargs, token, }: {
238
- method: string;
239
- token: string;
240
- kwargs: any;
241
- model: string;
242
- }): Promise<any>;
243
- requestSetupTotp({ method, token }: {
244
- method: string;
245
- token: string;
246
- }): Promise<any>;
247
- verifyTotp({ method, action_token, code, }: {
248
- method: string;
249
- action_token: string;
250
- code: string;
251
- }): Promise<any>;
252
- removeTotpSetUp({ method, token }: {
253
- method: string;
254
- token: string;
255
- }): Promise<any>;
256
222
  };
257
223
 
258
224
  export { ActionService, AuthService, CompanyService, ExcelService, FormService, KanbanServices as KanbanService, ModelService, UserService, ViewService };
@@ -60,8 +60,6 @@ declare const AuthService: {
60
60
  access_token: string;
61
61
  }): Promise<any>;
62
62
  getProviders(db?: string): Promise<any>;
63
- getAccessByCode(code: string): Promise<any>;
64
- logout(data: string): Promise<any>;
65
63
  };
66
64
 
67
65
  declare const CompanyService: {
@@ -209,12 +207,10 @@ declare const ViewService: {
209
207
  method: string;
210
208
  with_context: any;
211
209
  }): Promise<any>;
212
- verify2FA({ method, with_context, code, device, location, }: {
210
+ verify2FA({ method, with_context, code, }: {
213
211
  method: string;
214
212
  with_context: any;
215
213
  code: string;
216
- device: string;
217
- location: string;
218
214
  }): Promise<any>;
219
215
  signInSSO({ redirect_uri, state, client_id, response_type, path, }: {
220
216
  redirect_uri: string;
@@ -223,36 +219,6 @@ declare const ViewService: {
223
219
  response_type: string;
224
220
  path: string;
225
221
  }): Promise<any>;
226
- grantAccess({ redirect_uri, state, client_id, scopes, }: {
227
- redirect_uri: string;
228
- state: string;
229
- client_id: string;
230
- scopes: string[];
231
- }): Promise<any>;
232
- getFieldsViewSecurity({ method, token, views, }: {
233
- method: string;
234
- token: string;
235
- views: any;
236
- }): Promise<any>;
237
- settingsWebRead2fa({ method, model, kwargs, token, }: {
238
- method: string;
239
- token: string;
240
- kwargs: any;
241
- model: string;
242
- }): Promise<any>;
243
- requestSetupTotp({ method, token }: {
244
- method: string;
245
- token: string;
246
- }): Promise<any>;
247
- verifyTotp({ method, action_token, code, }: {
248
- method: string;
249
- action_token: string;
250
- code: string;
251
- }): Promise<any>;
252
- removeTotpSetUp({ method, token }: {
253
- method: string;
254
- token: string;
255
- }): Promise<any>;
256
222
  };
257
223
 
258
224
  export { ActionService, AuthService, CompanyService, ExcelService, FormService, KanbanServices as KanbanService, ModelService, UserService, ViewService };