@fctc/interface-logic 1.2.0 → 1.2.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.
- package/dist/config.js +34 -6
- package/dist/config.mjs +34 -6
- package/dist/constants.d.mts +4 -1
- package/dist/constants.d.ts +4 -1
- package/dist/constants.js +3 -0
- package/dist/constants.mjs +3 -0
- package/dist/environment.d.mts +1 -0
- package/dist/environment.d.ts +1 -0
- package/dist/environment.js +36 -6
- package/dist/environment.mjs +36 -6
- package/dist/hook.d.mts +46 -2
- package/dist/hook.d.ts +46 -2
- package/dist/hook.js +449 -116
- package/dist/hook.mjs +400 -75
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +454 -119
- package/dist/index.mjs +400 -74
- package/dist/model.js +41 -8
- package/dist/model.mjs +41 -8
- package/dist/provider.d.mts +4 -3
- package/dist/provider.d.ts +4 -3
- package/dist/provider.js +158 -10
- package/dist/provider.mjs +158 -10
- package/dist/services.d.mts +36 -2
- package/dist/services.d.ts +36 -2
- package/dist/services.js +195 -12
- package/dist/services.mjs +195 -12
- package/dist/utils.d.mts +4 -1
- package/dist/utils.d.ts +4 -1
- package/dist/utils.js +21 -0
- package/dist/utils.mjs +20 -0
- package/package.json +87 -87
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
|
|
|
@@ -2188,6 +2191,25 @@ var toQueryString = (params) => {
|
|
|
2188
2191
|
(key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
|
|
2189
2192
|
).join("&");
|
|
2190
2193
|
};
|
|
2194
|
+
var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
2195
|
+
if (!originalRequest.data) return originalRequest.data;
|
|
2196
|
+
if (typeof originalRequest.data === "string") {
|
|
2197
|
+
try {
|
|
2198
|
+
const parsedData = JSON.parse(originalRequest.data);
|
|
2199
|
+
if (parsedData.with_context && typeof parsedData.with_context === "object") {
|
|
2200
|
+
parsedData.with_context.token = newAccessToken;
|
|
2201
|
+
}
|
|
2202
|
+
return JSON.stringify(parsedData);
|
|
2203
|
+
} catch (e) {
|
|
2204
|
+
console.warn("Failed to parse originalRequest.data", e);
|
|
2205
|
+
return originalRequest.data;
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
|
|
2209
|
+
originalRequest.data.with_context.token = newAccessToken;
|
|
2210
|
+
}
|
|
2211
|
+
return originalRequest.data;
|
|
2212
|
+
};
|
|
2191
2213
|
|
|
2192
2214
|
// src/utils/storage/local-storage.ts
|
|
2193
2215
|
var localStorageUtils = () => {
|
|
@@ -2252,7 +2274,8 @@ var axiosClient = {
|
|
|
2252
2274
|
});
|
|
2253
2275
|
instance.interceptors.request.use(
|
|
2254
2276
|
async (config2) => {
|
|
2255
|
-
const
|
|
2277
|
+
const useRefreshToken = config2.useRefreshToken;
|
|
2278
|
+
const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
|
|
2256
2279
|
if (token) {
|
|
2257
2280
|
config2.headers["Authorization"] = "Bearer " + token;
|
|
2258
2281
|
}
|
|
@@ -2278,7 +2301,7 @@ var axiosClient = {
|
|
|
2278
2301
|
return data;
|
|
2279
2302
|
};
|
|
2280
2303
|
const originalRequest = error.config;
|
|
2281
|
-
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
|
|
2304
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
|
|
2282
2305
|
error.response.data.code
|
|
2283
2306
|
)) {
|
|
2284
2307
|
if (isRefreshing) {
|
|
@@ -2286,6 +2309,10 @@ var axiosClient = {
|
|
|
2286
2309
|
failedQueue.push({ resolve, reject });
|
|
2287
2310
|
}).then((token) => {
|
|
2288
2311
|
originalRequest.headers["Authorization"] = "Bearer " + token;
|
|
2312
|
+
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2313
|
+
originalRequest,
|
|
2314
|
+
token
|
|
2315
|
+
);
|
|
2289
2316
|
return instance.request(originalRequest);
|
|
2290
2317
|
}).catch(async (err) => {
|
|
2291
2318
|
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
@@ -2310,11 +2337,11 @@ var axiosClient = {
|
|
|
2310
2337
|
);
|
|
2311
2338
|
return new Promise(function(resolve) {
|
|
2312
2339
|
import_axios.default.post(
|
|
2313
|
-
`${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2340
|
+
`${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2314
2341
|
payload,
|
|
2315
2342
|
{
|
|
2316
2343
|
headers: {
|
|
2317
|
-
"Content-Type": "multipart/form-data",
|
|
2344
|
+
"Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
|
|
2318
2345
|
Authorization: `Bearer ${accessTokenExp}`
|
|
2319
2346
|
}
|
|
2320
2347
|
}
|
|
@@ -2324,10 +2351,14 @@ var axiosClient = {
|
|
|
2324
2351
|
await localStorage2.setRefreshToken(data.refresh_token);
|
|
2325
2352
|
import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
2326
2353
|
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
2354
|
+
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2355
|
+
originalRequest,
|
|
2356
|
+
data.access_token
|
|
2357
|
+
);
|
|
2327
2358
|
processQueue(null, data.access_token);
|
|
2328
2359
|
resolve(instance.request(originalRequest));
|
|
2329
2360
|
}).catch(async (err) => {
|
|
2330
|
-
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
|
|
2361
|
+
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") {
|
|
2331
2362
|
await clearAuthToken();
|
|
2332
2363
|
}
|
|
2333
2364
|
if (err && err.response) {
|
|
@@ -2377,7 +2408,7 @@ var axiosClient = {
|
|
|
2377
2408
|
const responseBody = (response) => response;
|
|
2378
2409
|
const requests = {
|
|
2379
2410
|
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
|
2380
|
-
post: (url, body, headers) => instance.post(formatUrl(url, db), body,
|
|
2411
|
+
post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
|
|
2381
2412
|
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
|
2382
2413
|
responseType: "arraybuffer",
|
|
2383
2414
|
headers: {
|
|
@@ -3020,6 +3051,7 @@ var EnvStore = class {
|
|
|
3020
3051
|
db;
|
|
3021
3052
|
localStorageUtils;
|
|
3022
3053
|
sessionStorageUtils;
|
|
3054
|
+
refreshTokenEndpoint;
|
|
3023
3055
|
constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
|
3024
3056
|
this.envStore = envStore2;
|
|
3025
3057
|
this.localStorageUtils = localStorageUtils2;
|
|
@@ -3036,6 +3068,7 @@ var EnvStore = class {
|
|
|
3036
3068
|
this.companies = env2?.companies || [];
|
|
3037
3069
|
this.user = env2?.user;
|
|
3038
3070
|
this.db = env2?.db;
|
|
3071
|
+
this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
|
|
3039
3072
|
}
|
|
3040
3073
|
setupEnv(envConfig) {
|
|
3041
3074
|
const dispatch = this.envStore.dispatch;
|
|
@@ -3367,6 +3400,38 @@ var AuthService = {
|
|
|
3367
3400
|
async getProviders(db) {
|
|
3368
3401
|
const env2 = getEnv();
|
|
3369
3402
|
return env2?.requests?.get("/oauth/providers", { params: { db } });
|
|
3403
|
+
},
|
|
3404
|
+
async getAccessByCode(code) {
|
|
3405
|
+
const env2 = getEnv();
|
|
3406
|
+
const data = new URLSearchParams();
|
|
3407
|
+
data.append("code", code);
|
|
3408
|
+
data.append("grant_type", "authorization_code");
|
|
3409
|
+
data.append("client_id", env2?.config?.clientId || "");
|
|
3410
|
+
data.append("redirect_uri", env2?.config?.redirectUri || "");
|
|
3411
|
+
return env2?.requests?.post(
|
|
3412
|
+
`${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
|
|
3413
|
+
data,
|
|
3414
|
+
{
|
|
3415
|
+
headers: {
|
|
3416
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
);
|
|
3420
|
+
},
|
|
3421
|
+
async logout(data) {
|
|
3422
|
+
const env2 = getEnv();
|
|
3423
|
+
console.log(data);
|
|
3424
|
+
return env2?.requests?.post(
|
|
3425
|
+
"/logout" /* LOGOUT */,
|
|
3426
|
+
{},
|
|
3427
|
+
{
|
|
3428
|
+
headers: {
|
|
3429
|
+
"Content-Type": "application/json"
|
|
3430
|
+
},
|
|
3431
|
+
withCredentials: true,
|
|
3432
|
+
useRefreshToken: true
|
|
3433
|
+
}
|
|
3434
|
+
);
|
|
3370
3435
|
}
|
|
3371
3436
|
};
|
|
3372
3437
|
var auth_service_default = AuthService;
|
|
@@ -4077,9 +4142,9 @@ var model_service_default = ModelService;
|
|
|
4077
4142
|
|
|
4078
4143
|
// src/services/user-service/index.ts
|
|
4079
4144
|
var UserService = {
|
|
4080
|
-
async getProfile() {
|
|
4145
|
+
async getProfile(path) {
|
|
4081
4146
|
const env2 = getEnv();
|
|
4082
|
-
return env2.requests.get("/userinfo" /* PROFILE_PATH */, {
|
|
4147
|
+
return env2.requests.get(path ?? "/userinfo" /* PROFILE_PATH */, {
|
|
4083
4148
|
headers: {
|
|
4084
4149
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
4085
4150
|
}
|
|
@@ -4422,14 +4487,18 @@ var ViewService = {
|
|
|
4422
4487
|
async verify2FA({
|
|
4423
4488
|
method,
|
|
4424
4489
|
with_context,
|
|
4425
|
-
code
|
|
4490
|
+
code,
|
|
4491
|
+
device,
|
|
4492
|
+
location
|
|
4426
4493
|
}) {
|
|
4427
4494
|
const env2 = getEnv();
|
|
4428
4495
|
const jsonData = {
|
|
4429
4496
|
method,
|
|
4430
4497
|
kwargs: {
|
|
4431
4498
|
vals: {
|
|
4432
|
-
code
|
|
4499
|
+
code,
|
|
4500
|
+
device,
|
|
4501
|
+
location
|
|
4433
4502
|
}
|
|
4434
4503
|
},
|
|
4435
4504
|
with_context
|
|
@@ -4437,7 +4506,8 @@ var ViewService = {
|
|
|
4437
4506
|
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4438
4507
|
headers: {
|
|
4439
4508
|
"Content-Type": "application/json"
|
|
4440
|
-
}
|
|
4509
|
+
},
|
|
4510
|
+
withCredentials: true
|
|
4441
4511
|
});
|
|
4442
4512
|
},
|
|
4443
4513
|
async signInSSO({
|
|
@@ -4456,7 +4526,120 @@ var ViewService = {
|
|
|
4456
4526
|
});
|
|
4457
4527
|
const url = `${path}?${params.toString()}`;
|
|
4458
4528
|
return env2?.requests.get(url, {
|
|
4459
|
-
|
|
4529
|
+
headers: {
|
|
4530
|
+
"Content-Type": "application/json"
|
|
4531
|
+
},
|
|
4532
|
+
withCredentials: true
|
|
4533
|
+
});
|
|
4534
|
+
},
|
|
4535
|
+
async grantAccess({
|
|
4536
|
+
redirect_uri,
|
|
4537
|
+
state,
|
|
4538
|
+
client_id,
|
|
4539
|
+
scopes
|
|
4540
|
+
}) {
|
|
4541
|
+
const env2 = getEnv();
|
|
4542
|
+
const jsonData = {
|
|
4543
|
+
redirect_uri,
|
|
4544
|
+
state,
|
|
4545
|
+
client_id,
|
|
4546
|
+
scopes
|
|
4547
|
+
};
|
|
4548
|
+
return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
|
|
4549
|
+
headers: {
|
|
4550
|
+
"Content-Type": "application/json"
|
|
4551
|
+
},
|
|
4552
|
+
withCredentials: true
|
|
4553
|
+
});
|
|
4554
|
+
},
|
|
4555
|
+
async getFieldsViewSecurity({
|
|
4556
|
+
method,
|
|
4557
|
+
token,
|
|
4558
|
+
views
|
|
4559
|
+
}) {
|
|
4560
|
+
const env2 = getEnv();
|
|
4561
|
+
const jsonData = {
|
|
4562
|
+
method,
|
|
4563
|
+
kwargs: {
|
|
4564
|
+
views
|
|
4565
|
+
},
|
|
4566
|
+
with_context: {
|
|
4567
|
+
token
|
|
4568
|
+
}
|
|
4569
|
+
};
|
|
4570
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4571
|
+
headers: {
|
|
4572
|
+
"Content-Type": "application/json"
|
|
4573
|
+
}
|
|
4574
|
+
});
|
|
4575
|
+
},
|
|
4576
|
+
async settingsWebRead2fa({
|
|
4577
|
+
method,
|
|
4578
|
+
model,
|
|
4579
|
+
kwargs,
|
|
4580
|
+
token
|
|
4581
|
+
}) {
|
|
4582
|
+
const env2 = getEnv();
|
|
4583
|
+
const jsonData = {
|
|
4584
|
+
method,
|
|
4585
|
+
model,
|
|
4586
|
+
kwargs,
|
|
4587
|
+
with_context: {
|
|
4588
|
+
token
|
|
4589
|
+
}
|
|
4590
|
+
};
|
|
4591
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4592
|
+
headers: {
|
|
4593
|
+
"Content-Type": "application/json"
|
|
4594
|
+
}
|
|
4595
|
+
});
|
|
4596
|
+
},
|
|
4597
|
+
async requestSetupTotp({ method, token }) {
|
|
4598
|
+
const env2 = getEnv();
|
|
4599
|
+
const jsonData = {
|
|
4600
|
+
method,
|
|
4601
|
+
with_context: {
|
|
4602
|
+
token
|
|
4603
|
+
}
|
|
4604
|
+
};
|
|
4605
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4606
|
+
headers: {
|
|
4607
|
+
"Content-Type": "application/json"
|
|
4608
|
+
}
|
|
4609
|
+
});
|
|
4610
|
+
},
|
|
4611
|
+
async verifyTotp({
|
|
4612
|
+
method,
|
|
4613
|
+
action_token,
|
|
4614
|
+
code
|
|
4615
|
+
}) {
|
|
4616
|
+
const env2 = getEnv();
|
|
4617
|
+
const jsonData = {
|
|
4618
|
+
method,
|
|
4619
|
+
kwargs: {
|
|
4620
|
+
vals: {
|
|
4621
|
+
code
|
|
4622
|
+
}
|
|
4623
|
+
},
|
|
4624
|
+
with_context: {
|
|
4625
|
+
action_token
|
|
4626
|
+
}
|
|
4627
|
+
};
|
|
4628
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4629
|
+
headers: {
|
|
4630
|
+
"Content-Type": "application/json"
|
|
4631
|
+
}
|
|
4632
|
+
});
|
|
4633
|
+
},
|
|
4634
|
+
async removeTotpSetUp({ method, token }) {
|
|
4635
|
+
const env2 = getEnv();
|
|
4636
|
+
const jsonData = {
|
|
4637
|
+
method,
|
|
4638
|
+
with_context: {
|
|
4639
|
+
token
|
|
4640
|
+
}
|
|
4641
|
+
};
|
|
4642
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4460
4643
|
headers: {
|
|
4461
4644
|
"Content-Type": "application/json"
|
|
4462
4645
|
}
|
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
|
|
|
@@ -2144,6 +2147,25 @@ var toQueryString = (params) => {
|
|
|
2144
2147
|
(key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
|
|
2145
2148
|
).join("&");
|
|
2146
2149
|
};
|
|
2150
|
+
var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
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
|
+
};
|
|
2147
2169
|
|
|
2148
2170
|
// src/utils/storage/local-storage.ts
|
|
2149
2171
|
var localStorageUtils = () => {
|
|
@@ -2208,7 +2230,8 @@ var axiosClient = {
|
|
|
2208
2230
|
});
|
|
2209
2231
|
instance.interceptors.request.use(
|
|
2210
2232
|
async (config2) => {
|
|
2211
|
-
const
|
|
2233
|
+
const useRefreshToken = config2.useRefreshToken;
|
|
2234
|
+
const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
|
|
2212
2235
|
if (token) {
|
|
2213
2236
|
config2.headers["Authorization"] = "Bearer " + token;
|
|
2214
2237
|
}
|
|
@@ -2234,7 +2257,7 @@ var axiosClient = {
|
|
|
2234
2257
|
return data;
|
|
2235
2258
|
};
|
|
2236
2259
|
const originalRequest = error.config;
|
|
2237
|
-
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
|
|
2260
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
|
|
2238
2261
|
error.response.data.code
|
|
2239
2262
|
)) {
|
|
2240
2263
|
if (isRefreshing) {
|
|
@@ -2242,6 +2265,10 @@ var axiosClient = {
|
|
|
2242
2265
|
failedQueue.push({ resolve, reject });
|
|
2243
2266
|
}).then((token) => {
|
|
2244
2267
|
originalRequest.headers["Authorization"] = "Bearer " + token;
|
|
2268
|
+
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2269
|
+
originalRequest,
|
|
2270
|
+
token
|
|
2271
|
+
);
|
|
2245
2272
|
return instance.request(originalRequest);
|
|
2246
2273
|
}).catch(async (err) => {
|
|
2247
2274
|
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
@@ -2266,11 +2293,11 @@ var axiosClient = {
|
|
|
2266
2293
|
);
|
|
2267
2294
|
return new Promise(function(resolve) {
|
|
2268
2295
|
axios.post(
|
|
2269
|
-
`${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2296
|
+
`${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2270
2297
|
payload,
|
|
2271
2298
|
{
|
|
2272
2299
|
headers: {
|
|
2273
|
-
"Content-Type": "multipart/form-data",
|
|
2300
|
+
"Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
|
|
2274
2301
|
Authorization: `Bearer ${accessTokenExp}`
|
|
2275
2302
|
}
|
|
2276
2303
|
}
|
|
@@ -2280,10 +2307,14 @@ var axiosClient = {
|
|
|
2280
2307
|
await localStorage2.setRefreshToken(data.refresh_token);
|
|
2281
2308
|
axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
2282
2309
|
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
2310
|
+
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2311
|
+
originalRequest,
|
|
2312
|
+
data.access_token
|
|
2313
|
+
);
|
|
2283
2314
|
processQueue(null, data.access_token);
|
|
2284
2315
|
resolve(instance.request(originalRequest));
|
|
2285
2316
|
}).catch(async (err) => {
|
|
2286
|
-
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
|
|
2317
|
+
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") {
|
|
2287
2318
|
await clearAuthToken();
|
|
2288
2319
|
}
|
|
2289
2320
|
if (err && err.response) {
|
|
@@ -2333,7 +2364,7 @@ var axiosClient = {
|
|
|
2333
2364
|
const responseBody = (response) => response;
|
|
2334
2365
|
const requests = {
|
|
2335
2366
|
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
|
2336
|
-
post: (url, body, headers) => instance.post(formatUrl(url, db), body,
|
|
2367
|
+
post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
|
|
2337
2368
|
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
|
2338
2369
|
responseType: "arraybuffer",
|
|
2339
2370
|
headers: {
|
|
@@ -2976,6 +3007,7 @@ var EnvStore = class {
|
|
|
2976
3007
|
db;
|
|
2977
3008
|
localStorageUtils;
|
|
2978
3009
|
sessionStorageUtils;
|
|
3010
|
+
refreshTokenEndpoint;
|
|
2979
3011
|
constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
|
2980
3012
|
this.envStore = envStore2;
|
|
2981
3013
|
this.localStorageUtils = localStorageUtils2;
|
|
@@ -2992,6 +3024,7 @@ var EnvStore = class {
|
|
|
2992
3024
|
this.companies = env2?.companies || [];
|
|
2993
3025
|
this.user = env2?.user;
|
|
2994
3026
|
this.db = env2?.db;
|
|
3027
|
+
this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
|
|
2995
3028
|
}
|
|
2996
3029
|
setupEnv(envConfig) {
|
|
2997
3030
|
const dispatch = this.envStore.dispatch;
|
|
@@ -3323,6 +3356,38 @@ var AuthService = {
|
|
|
3323
3356
|
async getProviders(db) {
|
|
3324
3357
|
const env2 = getEnv();
|
|
3325
3358
|
return env2?.requests?.get("/oauth/providers", { params: { db } });
|
|
3359
|
+
},
|
|
3360
|
+
async getAccessByCode(code) {
|
|
3361
|
+
const env2 = getEnv();
|
|
3362
|
+
const data = new URLSearchParams();
|
|
3363
|
+
data.append("code", code);
|
|
3364
|
+
data.append("grant_type", "authorization_code");
|
|
3365
|
+
data.append("client_id", env2?.config?.clientId || "");
|
|
3366
|
+
data.append("redirect_uri", env2?.config?.redirectUri || "");
|
|
3367
|
+
return env2?.requests?.post(
|
|
3368
|
+
`${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
|
|
3369
|
+
data,
|
|
3370
|
+
{
|
|
3371
|
+
headers: {
|
|
3372
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
);
|
|
3376
|
+
},
|
|
3377
|
+
async logout(data) {
|
|
3378
|
+
const env2 = getEnv();
|
|
3379
|
+
console.log(data);
|
|
3380
|
+
return env2?.requests?.post(
|
|
3381
|
+
"/logout" /* LOGOUT */,
|
|
3382
|
+
{},
|
|
3383
|
+
{
|
|
3384
|
+
headers: {
|
|
3385
|
+
"Content-Type": "application/json"
|
|
3386
|
+
},
|
|
3387
|
+
withCredentials: true,
|
|
3388
|
+
useRefreshToken: true
|
|
3389
|
+
}
|
|
3390
|
+
);
|
|
3326
3391
|
}
|
|
3327
3392
|
};
|
|
3328
3393
|
var auth_service_default = AuthService;
|
|
@@ -4033,9 +4098,9 @@ var model_service_default = ModelService;
|
|
|
4033
4098
|
|
|
4034
4099
|
// src/services/user-service/index.ts
|
|
4035
4100
|
var UserService = {
|
|
4036
|
-
async getProfile() {
|
|
4101
|
+
async getProfile(path) {
|
|
4037
4102
|
const env2 = getEnv();
|
|
4038
|
-
return env2.requests.get("/userinfo" /* PROFILE_PATH */, {
|
|
4103
|
+
return env2.requests.get(path ?? "/userinfo" /* PROFILE_PATH */, {
|
|
4039
4104
|
headers: {
|
|
4040
4105
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
4041
4106
|
}
|
|
@@ -4378,14 +4443,18 @@ var ViewService = {
|
|
|
4378
4443
|
async verify2FA({
|
|
4379
4444
|
method,
|
|
4380
4445
|
with_context,
|
|
4381
|
-
code
|
|
4446
|
+
code,
|
|
4447
|
+
device,
|
|
4448
|
+
location
|
|
4382
4449
|
}) {
|
|
4383
4450
|
const env2 = getEnv();
|
|
4384
4451
|
const jsonData = {
|
|
4385
4452
|
method,
|
|
4386
4453
|
kwargs: {
|
|
4387
4454
|
vals: {
|
|
4388
|
-
code
|
|
4455
|
+
code,
|
|
4456
|
+
device,
|
|
4457
|
+
location
|
|
4389
4458
|
}
|
|
4390
4459
|
},
|
|
4391
4460
|
with_context
|
|
@@ -4393,7 +4462,8 @@ var ViewService = {
|
|
|
4393
4462
|
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4394
4463
|
headers: {
|
|
4395
4464
|
"Content-Type": "application/json"
|
|
4396
|
-
}
|
|
4465
|
+
},
|
|
4466
|
+
withCredentials: true
|
|
4397
4467
|
});
|
|
4398
4468
|
},
|
|
4399
4469
|
async signInSSO({
|
|
@@ -4412,7 +4482,120 @@ var ViewService = {
|
|
|
4412
4482
|
});
|
|
4413
4483
|
const url = `${path}?${params.toString()}`;
|
|
4414
4484
|
return env2?.requests.get(url, {
|
|
4415
|
-
|
|
4485
|
+
headers: {
|
|
4486
|
+
"Content-Type": "application/json"
|
|
4487
|
+
},
|
|
4488
|
+
withCredentials: true
|
|
4489
|
+
});
|
|
4490
|
+
},
|
|
4491
|
+
async grantAccess({
|
|
4492
|
+
redirect_uri,
|
|
4493
|
+
state,
|
|
4494
|
+
client_id,
|
|
4495
|
+
scopes
|
|
4496
|
+
}) {
|
|
4497
|
+
const env2 = getEnv();
|
|
4498
|
+
const jsonData = {
|
|
4499
|
+
redirect_uri,
|
|
4500
|
+
state,
|
|
4501
|
+
client_id,
|
|
4502
|
+
scopes
|
|
4503
|
+
};
|
|
4504
|
+
return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
|
|
4505
|
+
headers: {
|
|
4506
|
+
"Content-Type": "application/json"
|
|
4507
|
+
},
|
|
4508
|
+
withCredentials: true
|
|
4509
|
+
});
|
|
4510
|
+
},
|
|
4511
|
+
async getFieldsViewSecurity({
|
|
4512
|
+
method,
|
|
4513
|
+
token,
|
|
4514
|
+
views
|
|
4515
|
+
}) {
|
|
4516
|
+
const env2 = getEnv();
|
|
4517
|
+
const jsonData = {
|
|
4518
|
+
method,
|
|
4519
|
+
kwargs: {
|
|
4520
|
+
views
|
|
4521
|
+
},
|
|
4522
|
+
with_context: {
|
|
4523
|
+
token
|
|
4524
|
+
}
|
|
4525
|
+
};
|
|
4526
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4527
|
+
headers: {
|
|
4528
|
+
"Content-Type": "application/json"
|
|
4529
|
+
}
|
|
4530
|
+
});
|
|
4531
|
+
},
|
|
4532
|
+
async settingsWebRead2fa({
|
|
4533
|
+
method,
|
|
4534
|
+
model,
|
|
4535
|
+
kwargs,
|
|
4536
|
+
token
|
|
4537
|
+
}) {
|
|
4538
|
+
const env2 = getEnv();
|
|
4539
|
+
const jsonData = {
|
|
4540
|
+
method,
|
|
4541
|
+
model,
|
|
4542
|
+
kwargs,
|
|
4543
|
+
with_context: {
|
|
4544
|
+
token
|
|
4545
|
+
}
|
|
4546
|
+
};
|
|
4547
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4548
|
+
headers: {
|
|
4549
|
+
"Content-Type": "application/json"
|
|
4550
|
+
}
|
|
4551
|
+
});
|
|
4552
|
+
},
|
|
4553
|
+
async requestSetupTotp({ method, token }) {
|
|
4554
|
+
const env2 = getEnv();
|
|
4555
|
+
const jsonData = {
|
|
4556
|
+
method,
|
|
4557
|
+
with_context: {
|
|
4558
|
+
token
|
|
4559
|
+
}
|
|
4560
|
+
};
|
|
4561
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4562
|
+
headers: {
|
|
4563
|
+
"Content-Type": "application/json"
|
|
4564
|
+
}
|
|
4565
|
+
});
|
|
4566
|
+
},
|
|
4567
|
+
async verifyTotp({
|
|
4568
|
+
method,
|
|
4569
|
+
action_token,
|
|
4570
|
+
code
|
|
4571
|
+
}) {
|
|
4572
|
+
const env2 = getEnv();
|
|
4573
|
+
const jsonData = {
|
|
4574
|
+
method,
|
|
4575
|
+
kwargs: {
|
|
4576
|
+
vals: {
|
|
4577
|
+
code
|
|
4578
|
+
}
|
|
4579
|
+
},
|
|
4580
|
+
with_context: {
|
|
4581
|
+
action_token
|
|
4582
|
+
}
|
|
4583
|
+
};
|
|
4584
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4585
|
+
headers: {
|
|
4586
|
+
"Content-Type": "application/json"
|
|
4587
|
+
}
|
|
4588
|
+
});
|
|
4589
|
+
},
|
|
4590
|
+
async removeTotpSetUp({ method, token }) {
|
|
4591
|
+
const env2 = getEnv();
|
|
4592
|
+
const jsonData = {
|
|
4593
|
+
method,
|
|
4594
|
+
with_context: {
|
|
4595
|
+
token
|
|
4596
|
+
}
|
|
4597
|
+
};
|
|
4598
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4416
4599
|
headers: {
|
|
4417
4600
|
"Content-Type": "application/json"
|
|
4418
4601
|
}
|
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
|
declare const useField: (props: any) => {
|
|
87
90
|
invisible: boolean;
|
|
@@ -90,4 +93,4 @@ declare const useField: (props: any) => {
|
|
|
90
93
|
nameField: string | null;
|
|
91
94
|
};
|
|
92
95
|
|
|
93
|
-
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, useField, useTabModel, validateAndParseDate };
|
|
96
|
+
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, useField, 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
|
declare const useField: (props: any) => {
|
|
87
90
|
invisible: boolean;
|
|
@@ -90,4 +93,4 @@ declare const useField: (props: any) => {
|
|
|
90
93
|
nameField: string | null;
|
|
91
94
|
};
|
|
92
95
|
|
|
93
|
-
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, useField, useTabModel, validateAndParseDate };
|
|
96
|
+
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, useField, useTabModel, validateAndParseDate };
|