@fctc/interface-logic 1.0.5 → 1.0.6

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.
@@ -60,6 +60,8 @@ 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>;
63
65
  };
64
66
 
65
67
  declare const CompanyService: {
@@ -219,6 +221,36 @@ declare const ViewService: {
219
221
  response_type: string;
220
222
  path: string;
221
223
  }): Promise<any>;
224
+ grantAccess({ redirect_uri, state, client_id, scopes, }: {
225
+ redirect_uri: string;
226
+ state: string;
227
+ client_id: string;
228
+ scopes: string[];
229
+ }): Promise<any>;
230
+ getFieldsViewSecurity({ method, token, views, }: {
231
+ method: string;
232
+ token: string;
233
+ views: any;
234
+ }): Promise<any>;
235
+ settingsWebRead2fa({ method, model, kwargs, token, }: {
236
+ method: string;
237
+ token: string;
238
+ kwargs: any;
239
+ model: string;
240
+ }): Promise<any>;
241
+ requestSetupTotp({ method, token }: {
242
+ method: string;
243
+ token: string;
244
+ }): Promise<any>;
245
+ verifyTotp({ method, action_token, code, }: {
246
+ method: string;
247
+ action_token: string;
248
+ code: string;
249
+ }): Promise<any>;
250
+ removeTotpSetUp({ method, token }: {
251
+ method: string;
252
+ token: string;
253
+ }): Promise<any>;
222
254
  };
223
255
 
224
256
  export { ActionService, AuthService, CompanyService, ExcelService, FormService, KanbanServices as KanbanService, ModelService, UserService, ViewService };
@@ -60,6 +60,8 @@ 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>;
63
65
  };
64
66
 
65
67
  declare const CompanyService: {
@@ -219,6 +221,36 @@ declare const ViewService: {
219
221
  response_type: string;
220
222
  path: string;
221
223
  }): Promise<any>;
224
+ grantAccess({ redirect_uri, state, client_id, scopes, }: {
225
+ redirect_uri: string;
226
+ state: string;
227
+ client_id: string;
228
+ scopes: string[];
229
+ }): Promise<any>;
230
+ getFieldsViewSecurity({ method, token, views, }: {
231
+ method: string;
232
+ token: string;
233
+ views: any;
234
+ }): Promise<any>;
235
+ settingsWebRead2fa({ method, model, kwargs, token, }: {
236
+ method: string;
237
+ token: string;
238
+ kwargs: any;
239
+ model: string;
240
+ }): Promise<any>;
241
+ requestSetupTotp({ method, token }: {
242
+ method: string;
243
+ token: string;
244
+ }): Promise<any>;
245
+ verifyTotp({ method, action_token, code, }: {
246
+ method: string;
247
+ action_token: string;
248
+ code: string;
249
+ }): Promise<any>;
250
+ removeTotpSetUp({ method, token }: {
251
+ method: string;
252
+ token: string;
253
+ }): Promise<any>;
222
254
  };
223
255
 
224
256
  export { ActionService, AuthService, CompanyService, ExcelService, FormService, KanbanServices as KanbanService, ModelService, UserService, ViewService };
package/dist/services.js CHANGED
@@ -66,6 +66,9 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
66
66
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
67
67
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
68
68
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
69
+ UriConstants2["GRANT_ACCESS"] = "/grant-access";
70
+ UriConstants2["TOKEN_BY_CODE"] = "/token";
71
+ UriConstants2["LOGOUT"] = "/logout";
69
72
  return UriConstants2;
70
73
  })(UriConstants || {});
71
74
 
@@ -2187,6 +2190,25 @@ var toQueryString = (params) => {
2187
2190
  (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2188
2191
  ).join("&");
2189
2192
  };
2193
+ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2194
+ if (!originalRequest.data) return originalRequest.data;
2195
+ if (typeof originalRequest.data === "string") {
2196
+ try {
2197
+ const parsedData = JSON.parse(originalRequest.data);
2198
+ if (parsedData.with_context && typeof parsedData.with_context === "object") {
2199
+ parsedData.with_context.token = newAccessToken;
2200
+ }
2201
+ return JSON.stringify(parsedData);
2202
+ } catch (e) {
2203
+ console.warn("Failed to parse originalRequest.data", e);
2204
+ return originalRequest.data;
2205
+ }
2206
+ }
2207
+ if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2208
+ originalRequest.data.with_context.token = newAccessToken;
2209
+ }
2210
+ return originalRequest.data;
2211
+ };
2190
2212
 
2191
2213
  // src/utils/storage/local-storage.ts
2192
2214
  var localStorageUtils = () => {
@@ -2251,7 +2273,8 @@ var axiosClient = {
2251
2273
  });
2252
2274
  instance.interceptors.request.use(
2253
2275
  async (config2) => {
2254
- const token = await localStorage2.getAccessToken();
2276
+ const useRefreshToken = config2.useRefreshToken;
2277
+ const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
2255
2278
  if (token) {
2256
2279
  config2.headers["Authorization"] = "Bearer " + token;
2257
2280
  }
@@ -2277,7 +2300,7 @@ var axiosClient = {
2277
2300
  return data;
2278
2301
  };
2279
2302
  const originalRequest = error.config;
2280
- if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
2303
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2281
2304
  error.response.data.code
2282
2305
  )) {
2283
2306
  if (isRefreshing) {
@@ -2285,6 +2308,10 @@ var axiosClient = {
2285
2308
  failedQueue.push({ resolve, reject });
2286
2309
  }).then((token) => {
2287
2310
  originalRequest.headers["Authorization"] = "Bearer " + token;
2311
+ originalRequest.data = updateTokenParamInOriginalRequest(
2312
+ originalRequest,
2313
+ token
2314
+ );
2288
2315
  return instance.request(originalRequest);
2289
2316
  }).catch(async (err) => {
2290
2317
  if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
@@ -2309,11 +2336,11 @@ var axiosClient = {
2309
2336
  );
2310
2337
  return new Promise(function(resolve) {
2311
2338
  import_axios.default.post(
2312
- `${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2339
+ `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2313
2340
  payload,
2314
2341
  {
2315
2342
  headers: {
2316
- "Content-Type": "multipart/form-data",
2343
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2317
2344
  Authorization: `Bearer ${accessTokenExp}`
2318
2345
  }
2319
2346
  }
@@ -2323,10 +2350,14 @@ var axiosClient = {
2323
2350
  await localStorage2.setRefreshToken(data.refresh_token);
2324
2351
  import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2325
2352
  originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2353
+ originalRequest.data = updateTokenParamInOriginalRequest(
2354
+ originalRequest,
2355
+ data.access_token
2356
+ );
2326
2357
  processQueue(null, data.access_token);
2327
2358
  resolve(instance.request(originalRequest));
2328
2359
  }).catch(async (err) => {
2329
- if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
2360
+ 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") {
2330
2361
  await clearAuthToken();
2331
2362
  }
2332
2363
  if (err && err.response) {
@@ -3019,6 +3050,7 @@ var EnvStore = class {
3019
3050
  db;
3020
3051
  localStorageUtils;
3021
3052
  sessionStorageUtils;
3053
+ refreshTokenEndpoint;
3022
3054
  constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3023
3055
  this.envStore = envStore2;
3024
3056
  this.localStorageUtils = localStorageUtils2;
@@ -3035,6 +3067,7 @@ var EnvStore = class {
3035
3067
  this.companies = env2?.companies || [];
3036
3068
  this.user = env2?.user;
3037
3069
  this.db = env2?.db;
3070
+ this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
3038
3071
  }
3039
3072
  setupEnv(envConfig) {
3040
3073
  const dispatch = this.envStore.dispatch;
@@ -3366,6 +3399,38 @@ var AuthService = {
3366
3399
  async getProviders(db) {
3367
3400
  const env2 = getEnv();
3368
3401
  return env2?.requests?.get("/oauth/providers", { params: { db } });
3402
+ },
3403
+ async getAccessByCode(code) {
3404
+ const env2 = getEnv();
3405
+ const data = new URLSearchParams();
3406
+ data.append("code", code);
3407
+ data.append("grant_type", "authorization_code");
3408
+ data.append("client_id", env2?.config?.clientId || "");
3409
+ data.append("redirect_uri", env2?.config?.redirectUri || "");
3410
+ return env2?.requests?.post(
3411
+ `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3412
+ data,
3413
+ {
3414
+ headers: {
3415
+ "Content-Type": "application/x-www-form-urlencoded"
3416
+ }
3417
+ }
3418
+ );
3419
+ },
3420
+ async logout(data) {
3421
+ const env2 = getEnv();
3422
+ console.log(data);
3423
+ return env2?.requests?.post(
3424
+ "/logout" /* LOGOUT */,
3425
+ {},
3426
+ {
3427
+ headers: {
3428
+ "Content-Type": "application/json"
3429
+ },
3430
+ withCredentials: true,
3431
+ useRefreshToken: true
3432
+ }
3433
+ );
3369
3434
  }
3370
3435
  };
3371
3436
  var auth_service_default = AuthService;
@@ -4460,6 +4525,119 @@ var ViewService = {
4460
4525
  "Content-Type": "application/json"
4461
4526
  }
4462
4527
  });
4528
+ },
4529
+ async grantAccess({
4530
+ redirect_uri,
4531
+ state,
4532
+ client_id,
4533
+ scopes
4534
+ }) {
4535
+ const env2 = getEnv();
4536
+ const jsonData = {
4537
+ redirect_uri,
4538
+ state,
4539
+ client_id,
4540
+ scopes
4541
+ };
4542
+ return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
4543
+ headers: {
4544
+ "Content-Type": "application/json"
4545
+ },
4546
+ withCredentials: true
4547
+ });
4548
+ },
4549
+ async getFieldsViewSecurity({
4550
+ method,
4551
+ token,
4552
+ views
4553
+ }) {
4554
+ const env2 = getEnv();
4555
+ const jsonData = {
4556
+ method,
4557
+ kwargs: {
4558
+ views
4559
+ },
4560
+ with_context: {
4561
+ token
4562
+ }
4563
+ };
4564
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4565
+ headers: {
4566
+ "Content-Type": "application/json"
4567
+ }
4568
+ });
4569
+ },
4570
+ async settingsWebRead2fa({
4571
+ method,
4572
+ model,
4573
+ kwargs,
4574
+ token
4575
+ }) {
4576
+ const env2 = getEnv();
4577
+ const jsonData = {
4578
+ method,
4579
+ model,
4580
+ kwargs,
4581
+ with_context: {
4582
+ token
4583
+ }
4584
+ };
4585
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4586
+ headers: {
4587
+ "Content-Type": "application/json"
4588
+ }
4589
+ });
4590
+ },
4591
+ async requestSetupTotp({ method, token }) {
4592
+ const env2 = getEnv();
4593
+ const jsonData = {
4594
+ method,
4595
+ with_context: {
4596
+ token
4597
+ }
4598
+ };
4599
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4600
+ headers: {
4601
+ "Content-Type": "application/json"
4602
+ }
4603
+ });
4604
+ },
4605
+ async verifyTotp({
4606
+ method,
4607
+ action_token,
4608
+ code
4609
+ }) {
4610
+ const env2 = getEnv();
4611
+ const jsonData = {
4612
+ method,
4613
+ kwargs: {
4614
+ vals: {
4615
+ code
4616
+ }
4617
+ },
4618
+ with_context: {
4619
+ action_token
4620
+ }
4621
+ };
4622
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4623
+ headers: {
4624
+ "Content-Type": "application/json"
4625
+ }
4626
+ });
4627
+ },
4628
+ async removeTotpSetUp({ method, token }) {
4629
+ const env2 = getEnv();
4630
+ const jsonData = {
4631
+ method,
4632
+ with_context: {
4633
+ token
4634
+ }
4635
+ };
4636
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4637
+ headers: {
4638
+ "Content-Type": "application/json"
4639
+ }
4640
+ });
4463
4641
  }
4464
4642
  };
4465
4643
  var view_service_default = ViewService;
package/dist/services.mjs CHANGED
@@ -22,6 +22,9 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
22
22
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
23
23
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
24
24
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
25
+ UriConstants2["GRANT_ACCESS"] = "/grant-access";
26
+ UriConstants2["TOKEN_BY_CODE"] = "/token";
27
+ UriConstants2["LOGOUT"] = "/logout";
25
28
  return UriConstants2;
26
29
  })(UriConstants || {});
27
30
 
@@ -2143,6 +2146,25 @@ var toQueryString = (params) => {
2143
2146
  (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2144
2147
  ).join("&");
2145
2148
  };
2149
+ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2150
+ if (!originalRequest.data) return originalRequest.data;
2151
+ if (typeof originalRequest.data === "string") {
2152
+ try {
2153
+ const parsedData = JSON.parse(originalRequest.data);
2154
+ if (parsedData.with_context && typeof parsedData.with_context === "object") {
2155
+ parsedData.with_context.token = newAccessToken;
2156
+ }
2157
+ return JSON.stringify(parsedData);
2158
+ } catch (e) {
2159
+ console.warn("Failed to parse originalRequest.data", e);
2160
+ return originalRequest.data;
2161
+ }
2162
+ }
2163
+ if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2164
+ originalRequest.data.with_context.token = newAccessToken;
2165
+ }
2166
+ return originalRequest.data;
2167
+ };
2146
2168
 
2147
2169
  // src/utils/storage/local-storage.ts
2148
2170
  var localStorageUtils = () => {
@@ -2207,7 +2229,8 @@ var axiosClient = {
2207
2229
  });
2208
2230
  instance.interceptors.request.use(
2209
2231
  async (config2) => {
2210
- const token = await localStorage2.getAccessToken();
2232
+ const useRefreshToken = config2.useRefreshToken;
2233
+ const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
2211
2234
  if (token) {
2212
2235
  config2.headers["Authorization"] = "Bearer " + token;
2213
2236
  }
@@ -2233,7 +2256,7 @@ var axiosClient = {
2233
2256
  return data;
2234
2257
  };
2235
2258
  const originalRequest = error.config;
2236
- if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
2259
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2237
2260
  error.response.data.code
2238
2261
  )) {
2239
2262
  if (isRefreshing) {
@@ -2241,6 +2264,10 @@ var axiosClient = {
2241
2264
  failedQueue.push({ resolve, reject });
2242
2265
  }).then((token) => {
2243
2266
  originalRequest.headers["Authorization"] = "Bearer " + token;
2267
+ originalRequest.data = updateTokenParamInOriginalRequest(
2268
+ originalRequest,
2269
+ token
2270
+ );
2244
2271
  return instance.request(originalRequest);
2245
2272
  }).catch(async (err) => {
2246
2273
  if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
@@ -2265,11 +2292,11 @@ var axiosClient = {
2265
2292
  );
2266
2293
  return new Promise(function(resolve) {
2267
2294
  axios.post(
2268
- `${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2295
+ `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2269
2296
  payload,
2270
2297
  {
2271
2298
  headers: {
2272
- "Content-Type": "multipart/form-data",
2299
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2273
2300
  Authorization: `Bearer ${accessTokenExp}`
2274
2301
  }
2275
2302
  }
@@ -2279,10 +2306,14 @@ var axiosClient = {
2279
2306
  await localStorage2.setRefreshToken(data.refresh_token);
2280
2307
  axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2281
2308
  originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2309
+ originalRequest.data = updateTokenParamInOriginalRequest(
2310
+ originalRequest,
2311
+ data.access_token
2312
+ );
2282
2313
  processQueue(null, data.access_token);
2283
2314
  resolve(instance.request(originalRequest));
2284
2315
  }).catch(async (err) => {
2285
- if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
2316
+ 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") {
2286
2317
  await clearAuthToken();
2287
2318
  }
2288
2319
  if (err && err.response) {
@@ -2975,6 +3006,7 @@ var EnvStore = class {
2975
3006
  db;
2976
3007
  localStorageUtils;
2977
3008
  sessionStorageUtils;
3009
+ refreshTokenEndpoint;
2978
3010
  constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
2979
3011
  this.envStore = envStore2;
2980
3012
  this.localStorageUtils = localStorageUtils2;
@@ -2991,6 +3023,7 @@ var EnvStore = class {
2991
3023
  this.companies = env2?.companies || [];
2992
3024
  this.user = env2?.user;
2993
3025
  this.db = env2?.db;
3026
+ this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
2994
3027
  }
2995
3028
  setupEnv(envConfig) {
2996
3029
  const dispatch = this.envStore.dispatch;
@@ -3322,6 +3355,38 @@ var AuthService = {
3322
3355
  async getProviders(db) {
3323
3356
  const env2 = getEnv();
3324
3357
  return env2?.requests?.get("/oauth/providers", { params: { db } });
3358
+ },
3359
+ async getAccessByCode(code) {
3360
+ const env2 = getEnv();
3361
+ const data = new URLSearchParams();
3362
+ data.append("code", code);
3363
+ data.append("grant_type", "authorization_code");
3364
+ data.append("client_id", env2?.config?.clientId || "");
3365
+ data.append("redirect_uri", env2?.config?.redirectUri || "");
3366
+ return env2?.requests?.post(
3367
+ `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3368
+ data,
3369
+ {
3370
+ headers: {
3371
+ "Content-Type": "application/x-www-form-urlencoded"
3372
+ }
3373
+ }
3374
+ );
3375
+ },
3376
+ async logout(data) {
3377
+ const env2 = getEnv();
3378
+ console.log(data);
3379
+ return env2?.requests?.post(
3380
+ "/logout" /* LOGOUT */,
3381
+ {},
3382
+ {
3383
+ headers: {
3384
+ "Content-Type": "application/json"
3385
+ },
3386
+ withCredentials: true,
3387
+ useRefreshToken: true
3388
+ }
3389
+ );
3325
3390
  }
3326
3391
  };
3327
3392
  var auth_service_default = AuthService;
@@ -4416,6 +4481,119 @@ var ViewService = {
4416
4481
  "Content-Type": "application/json"
4417
4482
  }
4418
4483
  });
4484
+ },
4485
+ async grantAccess({
4486
+ redirect_uri,
4487
+ state,
4488
+ client_id,
4489
+ scopes
4490
+ }) {
4491
+ const env2 = getEnv();
4492
+ const jsonData = {
4493
+ redirect_uri,
4494
+ state,
4495
+ client_id,
4496
+ scopes
4497
+ };
4498
+ return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
4499
+ headers: {
4500
+ "Content-Type": "application/json"
4501
+ },
4502
+ withCredentials: true
4503
+ });
4504
+ },
4505
+ async getFieldsViewSecurity({
4506
+ method,
4507
+ token,
4508
+ views
4509
+ }) {
4510
+ const env2 = getEnv();
4511
+ const jsonData = {
4512
+ method,
4513
+ kwargs: {
4514
+ views
4515
+ },
4516
+ with_context: {
4517
+ token
4518
+ }
4519
+ };
4520
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4521
+ headers: {
4522
+ "Content-Type": "application/json"
4523
+ }
4524
+ });
4525
+ },
4526
+ async settingsWebRead2fa({
4527
+ method,
4528
+ model,
4529
+ kwargs,
4530
+ token
4531
+ }) {
4532
+ const env2 = getEnv();
4533
+ const jsonData = {
4534
+ method,
4535
+ model,
4536
+ kwargs,
4537
+ with_context: {
4538
+ token
4539
+ }
4540
+ };
4541
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4542
+ headers: {
4543
+ "Content-Type": "application/json"
4544
+ }
4545
+ });
4546
+ },
4547
+ async requestSetupTotp({ method, token }) {
4548
+ const env2 = getEnv();
4549
+ const jsonData = {
4550
+ method,
4551
+ with_context: {
4552
+ token
4553
+ }
4554
+ };
4555
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4556
+ headers: {
4557
+ "Content-Type": "application/json"
4558
+ }
4559
+ });
4560
+ },
4561
+ async verifyTotp({
4562
+ method,
4563
+ action_token,
4564
+ code
4565
+ }) {
4566
+ const env2 = getEnv();
4567
+ const jsonData = {
4568
+ method,
4569
+ kwargs: {
4570
+ vals: {
4571
+ code
4572
+ }
4573
+ },
4574
+ with_context: {
4575
+ action_token
4576
+ }
4577
+ };
4578
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4579
+ headers: {
4580
+ "Content-Type": "application/json"
4581
+ }
4582
+ });
4583
+ },
4584
+ async removeTotpSetUp({ method, token }) {
4585
+ const env2 = getEnv();
4586
+ const jsonData = {
4587
+ method,
4588
+ with_context: {
4589
+ token
4590
+ }
4591
+ };
4592
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4593
+ headers: {
4594
+ "Content-Type": "application/json"
4595
+ }
4596
+ });
4419
4597
  }
4420
4598
  };
4421
4599
  var view_service_default = ViewService;
package/dist/utils.d.mts CHANGED
@@ -82,6 +82,9 @@ declare const getSubdomain: (url?: string) => string | null;
82
82
  declare const resequence: (arr: any, start: any, end: any) => any;
83
83
  declare const getOffSet: (arr: any, start: any, end: any) => any;
84
84
  declare const copyTextToClipboard: (text: string) => Promise<void>;
85
+ declare const updateTokenParamInOriginalRequest: (originalRequest: {
86
+ data?: any;
87
+ }, newAccessToken: string) => any;
85
88
  declare const isObjectEmpty: (obj: object) => boolean;
86
89
 
87
- export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, stringToColor, toQueryString, useTabModel, validateAndParseDate };
90
+ export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useTabModel, validateAndParseDate };
package/dist/utils.d.ts CHANGED
@@ -82,6 +82,9 @@ declare const getSubdomain: (url?: string) => string | null;
82
82
  declare const resequence: (arr: any, start: any, end: any) => any;
83
83
  declare const getOffSet: (arr: any, start: any, end: any) => any;
84
84
  declare const copyTextToClipboard: (text: string) => Promise<void>;
85
+ declare const updateTokenParamInOriginalRequest: (originalRequest: {
86
+ data?: any;
87
+ }, newAccessToken: string) => any;
85
88
  declare const isObjectEmpty: (obj: object) => boolean;
86
89
 
87
- export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, stringToColor, toQueryString, useTabModel, validateAndParseDate };
90
+ export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useTabModel, validateAndParseDate };
package/dist/utils.js CHANGED
@@ -58,6 +58,7 @@ __export(utils_exports, {
58
58
  sessionStorageUtils: () => sessionStorageUtils,
59
59
  stringToColor: () => stringToColor,
60
60
  toQueryString: () => toQueryString,
61
+ updateTokenParamInOriginalRequest: () => updateTokenParamInOriginalRequest,
61
62
  useTabModel: () => useTabModel,
62
63
  validateAndParseDate: () => validateAndParseDate
63
64
  });
@@ -2872,6 +2873,25 @@ var copyTextToClipboard = async (text) => {
2872
2873
  }
2873
2874
  }
2874
2875
  };
2876
+ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2877
+ if (!originalRequest.data) return originalRequest.data;
2878
+ if (typeof originalRequest.data === "string") {
2879
+ try {
2880
+ const parsedData = JSON.parse(originalRequest.data);
2881
+ if (parsedData.with_context && typeof parsedData.with_context === "object") {
2882
+ parsedData.with_context.token = newAccessToken;
2883
+ }
2884
+ return JSON.stringify(parsedData);
2885
+ } catch (e) {
2886
+ console.warn("Failed to parse originalRequest.data", e);
2887
+ return originalRequest.data;
2888
+ }
2889
+ }
2890
+ if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2891
+ originalRequest.data.with_context.token = newAccessToken;
2892
+ }
2893
+ return originalRequest.data;
2894
+ };
2875
2895
  var isObjectEmpty = (obj) => {
2876
2896
  return Object.keys(obj).length === 0;
2877
2897
  };
@@ -2942,6 +2962,7 @@ var sessionStorageUtils = () => {
2942
2962
  sessionStorageUtils,
2943
2963
  stringToColor,
2944
2964
  toQueryString,
2965
+ updateTokenParamInOriginalRequest,
2945
2966
  useTabModel,
2946
2967
  validateAndParseDate
2947
2968
  });