@das-fed/utils 7.1.0-dev.3 → 7.1.0-dev.30
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/api-services/index.js +994 -958
- package/api-services/index.js.gz +0 -0
- package/api-services/modules/app-manage/index.js +851 -852
- package/api-services/modules/app-manage/index.js.gz +0 -0
- package/api-services/modules/authentication/index.js +487 -470
- package/api-services/modules/authentication/index.js.gz +0 -0
- package/api-services/modules/bems/index.js +486 -469
- package/api-services/modules/bems/index.js.gz +0 -0
- package/api-services/modules/contract/index.js +753 -718
- package/api-services/modules/contract/index.js.gz +0 -0
- package/api-services/modules/duty-manage/index.js +494 -477
- package/api-services/modules/duty-manage/index.js.gz +0 -0
- package/api-services/modules/enterpriseright/index.js +487 -470
- package/api-services/modules/enterpriseright/index.js.gz +0 -0
- package/api-services/modules/file/index.js +844 -809
- package/api-services/modules/file/index.js.gz +0 -0
- package/api-services/modules/gateway-edge/index.js +487 -470
- package/api-services/modules/gateway-edge/index.js.gz +0 -0
- package/api-services/modules/index.js +1046 -1046
- package/api-services/modules/index.js.gz +0 -0
- package/api-services/modules/iot/index.js +544 -527
- package/api-services/modules/iot/index.js.gz +0 -0
- package/api-services/modules/justauth/index.d.ts +1 -1
- package/api-services/modules/justauth/index.js +757 -721
- package/api-services/modules/justauth/index.js.gz +0 -0
- package/api-services/modules/knowledge/index.js +487 -470
- package/api-services/modules/knowledge/index.js.gz +0 -0
- package/api-services/modules/link/index.js +487 -470
- package/api-services/modules/link/index.js.gz +0 -0
- package/api-services/modules/permission/index.js +487 -470
- package/api-services/modules/permission/index.js.gz +0 -0
- package/api-services/modules/platformManage/index.js +753 -718
- package/api-services/modules/platformManage/index.js.gz +0 -0
- package/api-services/modules/portal/index.js +487 -470
- package/api-services/modules/portal/index.js.gz +0 -0
- package/api-services/modules/space-manage/index.js +487 -470
- package/api-services/modules/space-manage/index.js.gz +0 -0
- package/api-services/modules/super-admin/index.js +757 -722
- package/api-services/modules/super-admin/index.js.gz +0 -0
- package/api-services/modules/supplier/index.js +537 -520
- package/api-services/modules/supplier/index.js.gz +0 -0
- package/api-services/modules/supplychain-manage/index.js +753 -718
- package/api-services/modules/supplychain-manage/index.js.gz +0 -0
- package/api-services/modules/systemConfiguration/index.js +487 -470
- package/api-services/modules/systemConfiguration/index.js.gz +0 -0
- package/api-services/modules/tool/index.js +487 -470
- package/api-services/modules/tool/index.js.gz +0 -0
- package/api-services/src/create-service/index.js +728 -693
- package/api-services/src/create-service/index.js.gz +0 -0
- package/common-info/index.d.ts +1 -1
- package/common-tools/platform-tools/index.d.ts +7 -2
- package/common-tools/platform-tools/index.js +27 -15
- package/common-tools/platform-tools/index.js.gz +0 -0
- package/create-api-service/index.js +486 -469
- package/create-api-service/index.js.gz +0 -0
- package/create-api-service/sso/authorizer.d.ts +1 -0
- package/create-api-service/sso/index.d.ts +16 -7
- package/create-api-service/sso/index.js +870 -769
- package/create-api-service/sso/index.js.gz +0 -0
- package/create-api-service/sso/utils.d.ts +2 -0
- package/create-api-service/thirdLogout/index.d.ts +19 -0
- package/create-api-service/thirdLogout/index.js +1835 -0
- package/create-api-service/thirdLogout/index.js.gz +0 -0
- package/create-api-service/unauthorized-recovery/index.d.ts +36 -0
- package/create-api-service/unauthorized-recovery/index.js +16 -0
- package/curring-http/type.d.ts +93 -87
- package/esm-map.json +10 -1
- package/package.json +4 -4
- package/token-tools/index.d.ts +2 -1
- package/token-tools/index.js +1 -1
- package/token-tools/index.js.gz +0 -0
|
Binary file
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CurringConfig } from '../../curring-http/type';
|
|
2
|
+
|
|
3
|
+
/** 401 恢复成功后的结果。 */
|
|
4
|
+
export interface UnauthorizedRecoveryResult {
|
|
5
|
+
/** 恢复后用于重试原请求的平台访问令牌。 */
|
|
6
|
+
accessToken: string;
|
|
7
|
+
}
|
|
8
|
+
/** 401 恢复处理器接收的上下文。 */
|
|
9
|
+
export interface UnauthorizedRecoveryContext {
|
|
10
|
+
/** Axios 返回的原始错误。 */
|
|
11
|
+
error: any;
|
|
12
|
+
/** 发生 401 的原始请求配置。 */
|
|
13
|
+
config: CurringConfig;
|
|
14
|
+
}
|
|
15
|
+
/** 项目可注册的 401 恢复处理器。 */
|
|
16
|
+
export type UnauthorizedRecoveryHandler = (context: UnauthorizedRecoveryContext) => Promise<UnauthorizedRecoveryResult | null>;
|
|
17
|
+
/**
|
|
18
|
+
* 判断当前是否已经注册项目级 401 恢复处理器。
|
|
19
|
+
* 框架默认刷新返回 401 后据此判断是否交由项目恢复,避免直接触发退出登录。
|
|
20
|
+
* @returns 是否存在项目级恢复处理器
|
|
21
|
+
*/
|
|
22
|
+
export declare const hasUnauthorizedRecovery: () => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 注册项目自定义的 401 恢复处理器。
|
|
25
|
+
* 后注册的处理器会覆盖之前的处理器,避免不同项目逻辑同时接管认证流程。
|
|
26
|
+
* @param handler 项目自定义恢复处理器
|
|
27
|
+
* @returns 注销当前处理器的方法
|
|
28
|
+
*/
|
|
29
|
+
export declare const registerUnauthorizedRecovery: (handler: UnauthorizedRecoveryHandler) => () => void;
|
|
30
|
+
/**
|
|
31
|
+
* 尝试恢复 401 请求。
|
|
32
|
+
* 并发 401 共用同一个恢复任务,避免短时间内重复续签 Token。
|
|
33
|
+
* @param context 401 请求上下文
|
|
34
|
+
* @returns 恢复成功后的新 Token;无法恢复时返回 null
|
|
35
|
+
*/
|
|
36
|
+
export declare const recoverUnauthorized: (context: UnauthorizedRecoveryContext) => unknown;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const n = Symbol.for("@das-fed/utils/unauthorized-recovery-state"), o = () => {
|
|
2
|
+
const r = globalThis;
|
|
3
|
+
return r[n] || (r[n] = {
|
|
4
|
+
handler: null,
|
|
5
|
+
promise: null
|
|
6
|
+
}), r[n];
|
|
7
|
+
}, e = o(), l = () => e.handler !== null, t = (r) => (e.handler = r, () => {
|
|
8
|
+
e.handler === r && (e.handler = null);
|
|
9
|
+
}), s = async (r) => e.handler ? (e.promise || (e.promise = Promise.resolve(e.handler(r)).finally(() => {
|
|
10
|
+
e.promise = null;
|
|
11
|
+
})), e.promise) : null;
|
|
12
|
+
export {
|
|
13
|
+
l as hasUnauthorizedRecovery,
|
|
14
|
+
s as recoverUnauthorized,
|
|
15
|
+
t as registerUnauthorizedRecovery
|
|
16
|
+
};
|
package/curring-http/type.d.ts
CHANGED
|
@@ -1,89 +1,95 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, AxiosError } from 'axios';
|
|
2
2
|
import { Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** 请求工具配置项 */
|
|
6
|
-
export type CurringConfig = AxiosRequestConfig & {
|
|
7
|
-
/** 请求实例 */
|
|
8
|
-
axiosInstance?: AxiosInstance
|
|
9
|
-
|
|
10
|
-
/** 请求方法 */
|
|
11
|
-
method?: Method
|
|
12
|
-
|
|
13
|
-
/** 请求的body数据 */
|
|
14
|
-
data?: any
|
|
15
|
-
|
|
16
|
-
/** 请求的query数据 */
|
|
17
|
-
params?: any
|
|
18
|
-
|
|
19
|
-
/** 接口地址前缀 */
|
|
20
|
-
urlPrefix?: string
|
|
21
|
-
|
|
22
|
-
/** 标记为公共接口,不需要鉴权,默认为false */
|
|
23
|
-
public?: boolean
|
|
24
|
-
|
|
25
|
-
/** 请求成功执行的回调 */
|
|
26
|
-
onSuccess?: (res: any, config: CurringConfig) => Promise<any>
|
|
27
|
-
|
|
28
|
-
/** 请求失败执行的回调 */
|
|
29
|
-
onError?: (error: any, config: CurringConfig) => Promise<any>
|
|
30
|
-
|
|
31
|
-
/** 自定义处理请求失败执行的回调 */
|
|
32
|
-
onCustomError?: (error: any, config: CurringConfig) => Promise<any>
|
|
33
|
-
|
|
34
|
-
/** 不管请求成功或失败都会执行的回调 */
|
|
35
|
-
finally?: (config: CurringConfig) => any
|
|
36
|
-
|
|
37
|
-
/** 每次请求之前都会执行的函数 */
|
|
38
|
-
beforeRun?: (config: CurringConfig) => Promise<CurringConfig>
|
|
39
|
-
|
|
40
|
-
/** 自定义错误信息 */
|
|
41
|
-
customErrorMessage?: (
|
|
42
|
-
/** 原始错误信息 */
|
|
43
|
-
message: string,
|
|
44
|
-
|
|
45
|
-
/** 原始错误对象 */
|
|
46
|
-
error: any,
|
|
47
|
-
) => string | null | undefined
|
|
48
|
-
|
|
49
|
-
/** 忽略错误提示 */
|
|
50
|
-
ignoreErrorMessage?: boolean
|
|
51
|
-
|
|
52
|
-
/** 接口401是否重定向到登录页 */
|
|
53
|
-
noRedireLogin?: boolean
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/** 请求工具配置项 */
|
|
6
|
+
export type CurringConfig = AxiosRequestConfig & {
|
|
7
|
+
/** 请求实例 */
|
|
8
|
+
axiosInstance?: AxiosInstance
|
|
9
|
+
|
|
10
|
+
/** 请求方法 */
|
|
11
|
+
method?: Method
|
|
12
|
+
|
|
13
|
+
/** 请求的body数据 */
|
|
14
|
+
data?: any
|
|
15
|
+
|
|
16
|
+
/** 请求的query数据 */
|
|
17
|
+
params?: any
|
|
18
|
+
|
|
19
|
+
/** 接口地址前缀 */
|
|
20
|
+
urlPrefix?: string
|
|
21
|
+
|
|
22
|
+
/** 标记为公共接口,不需要鉴权,默认为false */
|
|
23
|
+
public?: boolean
|
|
24
|
+
|
|
25
|
+
/** 请求成功执行的回调 */
|
|
26
|
+
onSuccess?: (res: any, config: CurringConfig) => Promise<any>
|
|
27
|
+
|
|
28
|
+
/** 请求失败执行的回调 */
|
|
29
|
+
onError?: (error: any, config: CurringConfig) => Promise<any>
|
|
30
|
+
|
|
31
|
+
/** 自定义处理请求失败执行的回调 */
|
|
32
|
+
onCustomError?: (error: any, config: CurringConfig) => Promise<any>
|
|
33
|
+
|
|
34
|
+
/** 不管请求成功或失败都会执行的回调 */
|
|
35
|
+
finally?: (config: CurringConfig) => any
|
|
36
|
+
|
|
37
|
+
/** 每次请求之前都会执行的函数 */
|
|
38
|
+
beforeRun?: (config: CurringConfig) => Promise<CurringConfig>
|
|
39
|
+
|
|
40
|
+
/** 自定义错误信息 */
|
|
41
|
+
customErrorMessage?: (
|
|
42
|
+
/** 原始错误信息 */
|
|
43
|
+
message: string,
|
|
44
|
+
|
|
45
|
+
/** 原始错误对象 */
|
|
46
|
+
error: any,
|
|
47
|
+
) => string | null | undefined
|
|
48
|
+
|
|
49
|
+
/** 忽略错误提示 */
|
|
50
|
+
ignoreErrorMessage?: boolean
|
|
51
|
+
|
|
52
|
+
/** 接口401是否重定向到登录页 */
|
|
53
|
+
noRedireLogin?: boolean
|
|
54
|
+
|
|
55
|
+
/** 是否跳过项目注册的401恢复逻辑 */
|
|
56
|
+
skipUnauthorizedRecovery?: boolean
|
|
57
|
+
|
|
58
|
+
/** 标记当前请求已完成一次401恢复重试,防止重复续签 */
|
|
59
|
+
_unauthorizedRecoveryRetried?: boolean
|
|
60
|
+
|
|
61
|
+
/** 开启CSRF安全选项 */
|
|
62
|
+
csrf?: boolean
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type Method = 'get' | 'post' | 'put' | 'delete' | 'patch'
|
|
66
|
+
|
|
67
|
+
export type CurringConfigFun = (config: CurringConfig) => CurringConfig | Promise<CurringConfig>
|
|
68
|
+
|
|
69
|
+
export type CurringRes = {
|
|
70
|
+
/** 请求时返回的接口数据 */
|
|
71
|
+
data: Ref<any>
|
|
72
|
+
|
|
73
|
+
/** 请求时的错误信息 */
|
|
74
|
+
error: Ref<any>
|
|
75
|
+
|
|
76
|
+
/** 请求时的loading */
|
|
77
|
+
loading: Ref<boolean>
|
|
78
|
+
|
|
79
|
+
/** 发起请求 返回格式 [ error, data ] */
|
|
80
|
+
run: (payload?: any, config?: CurringConfig) => CurringRunRes
|
|
81
|
+
|
|
82
|
+
/** 取消请求控制器 */
|
|
83
|
+
abortController: Ref<AbortController | null>
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 返回为数组 [error, data], 请求成功error为null,请求失败data为null */
|
|
87
|
+
export type CurringRunRes = Promise<
|
|
88
|
+
[
|
|
89
|
+
/** 请求返回的错误信息,请求成功时为null,请求失败时为错误信息 */
|
|
90
|
+
error: { code: string | number; msg: string; error: AxiosError } | null,
|
|
91
|
+
|
|
92
|
+
/** 请求返回的接口数据,请求成功时为后端数据,请求失败时为null */
|
|
93
|
+
data: any | null,
|
|
94
|
+
]
|
|
95
|
+
>
|
package/esm-map.json
CHANGED
|
@@ -143,5 +143,14 @@
|
|
|
143
143
|
"calcTextWidth": "/common-tools/calc-text-width/index",
|
|
144
144
|
"getFileExtension": "/common-tools/get-file-extension/index",
|
|
145
145
|
"getLanguages": "/common-info/index",
|
|
146
|
-
"appendQueryParams": "/common-tools/get-url-params/index"
|
|
146
|
+
"appendQueryParams": "/common-tools/get-url-params/index",
|
|
147
|
+
"refreshToken": "/create-api-service/sso/index",
|
|
148
|
+
"isThirdLogin": "/create-api-service/thirdLogout/index",
|
|
149
|
+
"thirdLogout": "/create-api-service/thirdLogout/index",
|
|
150
|
+
"oauthClient": "/api-services/modules/justauth/index",
|
|
151
|
+
"zhongshenLogout": "/create-api-service/thirdLogout/index",
|
|
152
|
+
"jmcLogout": "/create-api-service/thirdLogout/index",
|
|
153
|
+
"registerUnauthorizedRecovery": "/create-api-service/unauthorized-recovery/index",
|
|
154
|
+
"recoverUnauthorized": "/create-api-service/unauthorized-recovery/index",
|
|
155
|
+
"hasUnauthorizedRecovery": "/create-api-service/unauthorized-recovery/index"
|
|
147
156
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@das-fed/utils",
|
|
3
|
-
"version": "7.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.30",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@antv/x6": "^2.18.1",
|
|
12
|
-
"@das-fed/utils": "7.1.0-dev.
|
|
12
|
+
"@das-fed/utils": "7.1.0-dev.30",
|
|
13
13
|
"@vue/shared": "^3.4.21",
|
|
14
14
|
"@vueuse/core": "^9.6.0",
|
|
15
15
|
"axios": "^1.6.7",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"vue": "^3.4.21"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@das-fed/cli": "7.1.0-dev.
|
|
25
|
-
"@das-fed/web": "7.1.0-dev.
|
|
24
|
+
"@das-fed/cli": "7.1.0-dev.30",
|
|
25
|
+
"@das-fed/web": "7.1.0-dev.30",
|
|
26
26
|
"@types/js-cookie": "^3.0.6",
|
|
27
27
|
"@types/lodash-es": "^4.17.12",
|
|
28
28
|
"@types/qs": "^6.9.15",
|
package/token-tools/index.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export declare const getAccessToken: () => string;
|
|
|
10
10
|
/**
|
|
11
11
|
* 获取tokenInfo相关信息
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
type TokenInfoKey = typeof accessTokenExpiredAtKey | typeof refreshTokenKey | typeof redirectUriKey | typeof accessTokenInfoKey;
|
|
14
|
+
export declare const getAccessTokenInfo: (key: TokenInfoKey) => any;
|
|
14
15
|
/**
|
|
15
16
|
* 存入token、tokenInfo
|
|
16
17
|
* @param token
|
package/token-tools/index.js
CHANGED
|
@@ -71,7 +71,7 @@ function d(e, t) {
|
|
|
71
71
|
var p = d(k, { path: "/" });
|
|
72
72
|
const a = "accessToken", m = "accessTokenExpiredAt", v = "refreshToken", u = "redirectUri", S = "csrf-token", h = () => localStorage.getItem(a) ?? p.get(a) ?? sessionStorage.getItem(a) ?? "", C = (e) => localStorage.getItem(e) ?? p.get(e) ?? sessionStorage.getItem(e) ?? "", x = (e, t = {}) => {
|
|
73
73
|
var n;
|
|
74
|
-
(n = window.webConfig) != null && n.disableSaveToken || (localStorage.setItem(a, e), localStorage.setItem(m, t.accessTokenExpiredAt ??
|
|
74
|
+
(n = window.webConfig) != null && n.disableSaveToken || (localStorage.setItem(a, e), localStorage.setItem(m, t.accessTokenExpiredAt ?? 0), localStorage.setItem(v, t.refreshToken ?? 0), t.redirectUri && localStorage.setItem(u, t.redirectUri));
|
|
75
75
|
}, U = () => {
|
|
76
76
|
localStorage.removeItem(a), localStorage.removeItem(m), localStorage.removeItem(v), localStorage.removeItem(u), localStorage.removeItem(S);
|
|
77
77
|
};
|
package/token-tools/index.js.gz
CHANGED
|
Binary file
|