@clownlee/cores 1.0.19 → 1.0.20
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/apis/auth.d.ts +4 -48
- package/dist/apis/index.d.ts +2 -2
- package/dist/index.js +18 -89
- package/package.json +1 -1
package/dist/apis/auth.d.ts
CHANGED
|
@@ -1,55 +1,11 @@
|
|
|
1
1
|
import { RequestInitConfig, HttpInstance } from '@clownlee/http';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 子应用授权相关 API(登录/注册等已提取至 main-app views/auth)
|
|
5
|
+
*/
|
|
6
|
+
export default class SubAppAuthApis {
|
|
4
7
|
protected http: HttpInstance;
|
|
5
8
|
constructor(config: RequestInitConfig | HttpInstance);
|
|
6
|
-
/**
|
|
7
|
-
* 用户登录 API
|
|
8
|
-
* @param data 登录表单数据
|
|
9
|
-
* @returns 用户信息和Token
|
|
10
|
-
*/
|
|
11
|
-
login(data: any): Promise<any>;
|
|
12
|
-
/**
|
|
13
|
-
* 用户登出 API
|
|
14
|
-
* @param data 登出数据,包含 userId、password、tenantId
|
|
15
|
-
* @returns 登出结果
|
|
16
|
-
*/
|
|
17
|
-
logout(data?: {
|
|
18
|
-
userId?: string;
|
|
19
|
-
password?: string;
|
|
20
|
-
tenantId?: string;
|
|
21
|
-
}): Promise<any>;
|
|
22
|
-
/**
|
|
23
|
-
* 用户注册 API
|
|
24
|
-
* @param data 注册表单数据
|
|
25
|
-
* @returns 用户信息和Token
|
|
26
|
-
*/
|
|
27
|
-
register(data: any): Promise<any>;
|
|
28
|
-
/**
|
|
29
|
-
* 获取租户列表 API
|
|
30
|
-
* @param type 租户类型:LOGIN(登录)或 REGISTER(注册)
|
|
31
|
-
* @returns 租户列表
|
|
32
|
-
*/
|
|
33
|
-
getTenants(type?: 'LOGIN' | 'REGISTER'): Promise<any>;
|
|
34
|
-
/**
|
|
35
|
-
* 获取授权码 API
|
|
36
|
-
* @param token 一次性Token(JWT)
|
|
37
|
-
* @returns 授权码
|
|
38
|
-
*/
|
|
39
|
-
getAuthorizationCode(token: string): Promise<any>;
|
|
40
|
-
/**
|
|
41
|
-
* 获取AccessToken和RefreshToken API
|
|
42
|
-
* @param code 授权码
|
|
43
|
-
* @param token 一次性Token(JWT)
|
|
44
|
-
* @returns AccessToken和RefreshToken
|
|
45
|
-
*/
|
|
46
|
-
getAccessToken(code: string, token: string): Promise<any>;
|
|
47
|
-
/**
|
|
48
|
-
* Token 刷新 API
|
|
49
|
-
* @param refreshToken RefreshToken
|
|
50
|
-
* @returns 新的AccessToken
|
|
51
|
-
*/
|
|
52
|
-
refreshToken(refreshToken: string): Promise<any>;
|
|
53
9
|
/**
|
|
54
10
|
* 获取子应用授权码 API
|
|
55
11
|
* @param clientId 客户端ID
|
package/dist/apis/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { default as MenuApis } from './menu';
|
|
2
|
-
import { default as
|
|
2
|
+
import { default as SubAppAuthApis } from './auth';
|
|
3
3
|
import { default as AppUserApis } from './app-user';
|
|
4
4
|
import { default as ClientApis } from './client';
|
|
5
5
|
import { default as RoleApis } from './role';
|
|
6
6
|
import { default as RolePermissionApis } from './role-permission';
|
|
7
7
|
import { default as UserCenterApis } from './user-center';
|
|
8
8
|
|
|
9
|
-
export { MenuApis,
|
|
9
|
+
export { MenuApis, SubAppAuthApis, AppUserApis, ClientApis, RoleApis, RolePermissionApis, UserCenterApis, };
|
package/dist/index.js
CHANGED
|
@@ -2651,11 +2651,14 @@ async function handleTokenRefresh(refreshConfig, store, refreshTokenFromResponse
|
|
|
2651
2651
|
throw refreshError;
|
|
2652
2652
|
}
|
|
2653
2653
|
}
|
|
2654
|
+
const REDIRECT_TO_LOGIN_CODES = [2006, 2007, 2003, 2004, 2e3];
|
|
2655
|
+
const TOKEN_REFRESH_CODE = 2001;
|
|
2656
|
+
const TENANT_SUPER_ADMIN_FIRST_LOGIN_CODE = 2008;
|
|
2654
2657
|
async function handleResponseInterceptor(response, store, refreshConfig) {
|
|
2655
2658
|
var _a, _b;
|
|
2656
2659
|
const responseData = response == null ? void 0 : response.data;
|
|
2657
2660
|
const code = responseData == null ? void 0 : responseData.code;
|
|
2658
|
-
if (
|
|
2661
|
+
if (REDIRECT_TO_LOGIN_CODES.includes(code)) {
|
|
2659
2662
|
if (!response.request.responseURL.endsWith("login") && !response.request.responseURL.endsWith("register") && !response.request.responseURL.endsWith("register/tenants")) {
|
|
2660
2663
|
window.parent.postMessage({
|
|
2661
2664
|
type: "error",
|
|
@@ -2667,7 +2670,7 @@ async function handleResponseInterceptor(response, store, refreshConfig) {
|
|
|
2667
2670
|
}, "*");
|
|
2668
2671
|
}
|
|
2669
2672
|
throw new Error(responseData == null ? void 0 : responseData.message);
|
|
2670
|
-
} else if (code ===
|
|
2673
|
+
} else if (code === TOKEN_REFRESH_CODE) {
|
|
2671
2674
|
const config = response.config;
|
|
2672
2675
|
if (config._retry) {
|
|
2673
2676
|
window.parent.postMessage({
|
|
@@ -2704,8 +2707,8 @@ async function handleResponseInterceptor(response, store, refreshConfig) {
|
|
|
2704
2707
|
} catch (refreshError) {
|
|
2705
2708
|
throw refreshError;
|
|
2706
2709
|
}
|
|
2707
|
-
} else if (code > 0) {
|
|
2708
|
-
throw new Error(responseData == null ? void 0 : responseData.message);
|
|
2710
|
+
} else if (code > 0 && code !== TENANT_SUPER_ADMIN_FIRST_LOGIN_CODE) {
|
|
2711
|
+
throw new Error((responseData == null ? void 0 : responseData.message + 222) ?? "请求失败");
|
|
2709
2712
|
}
|
|
2710
2713
|
return response;
|
|
2711
2714
|
}
|
|
@@ -2875,7 +2878,7 @@ function init(config) {
|
|
|
2875
2878
|
service.init(config);
|
|
2876
2879
|
return service;
|
|
2877
2880
|
}
|
|
2878
|
-
let Apis$
|
|
2881
|
+
let Apis$5 = class Apis {
|
|
2879
2882
|
constructor(config) {
|
|
2880
2883
|
__publicField(this, "http");
|
|
2881
2884
|
this.http = config || init(config);
|
|
@@ -2957,85 +2960,11 @@ let Apis$6 = class Apis {
|
|
|
2957
2960
|
return await this.http.post("/api/v1/app/menu/update", data);
|
|
2958
2961
|
}
|
|
2959
2962
|
};
|
|
2960
|
-
|
|
2963
|
+
class SubAppAuthApis {
|
|
2961
2964
|
constructor(config) {
|
|
2962
2965
|
__publicField(this, "http");
|
|
2963
2966
|
this.http = config || init(config);
|
|
2964
2967
|
}
|
|
2965
|
-
/**
|
|
2966
|
-
* 用户登录 API
|
|
2967
|
-
* @param data 登录表单数据
|
|
2968
|
-
* @returns 用户信息和Token
|
|
2969
|
-
*/
|
|
2970
|
-
async login(data) {
|
|
2971
|
-
return await this.http.post("/api/v1/iam/auth/login", data);
|
|
2972
|
-
}
|
|
2973
|
-
/**
|
|
2974
|
-
* 用户登出 API
|
|
2975
|
-
* @param data 登出数据,包含 userId、password、tenantId
|
|
2976
|
-
* @returns 登出结果
|
|
2977
|
-
*/
|
|
2978
|
-
async logout(data) {
|
|
2979
|
-
return await this.http.post("/api/v1/iam/auth/logout", data || {});
|
|
2980
|
-
}
|
|
2981
|
-
/**
|
|
2982
|
-
* 用户注册 API
|
|
2983
|
-
* @param data 注册表单数据
|
|
2984
|
-
* @returns 用户信息和Token
|
|
2985
|
-
*/
|
|
2986
|
-
async register(data) {
|
|
2987
|
-
return await this.http.post("/api/v1/iam/auth/register", data);
|
|
2988
|
-
}
|
|
2989
|
-
/**
|
|
2990
|
-
* 获取租户列表 API
|
|
2991
|
-
* @param type 租户类型:LOGIN(登录)或 REGISTER(注册)
|
|
2992
|
-
* @returns 租户列表
|
|
2993
|
-
*/
|
|
2994
|
-
async getTenants(type = "LOGIN") {
|
|
2995
|
-
return await this.http.post("/api/v1/iam/auth/register/tenants", {
|
|
2996
|
-
type
|
|
2997
|
-
});
|
|
2998
|
-
}
|
|
2999
|
-
/**
|
|
3000
|
-
* 获取授权码 API
|
|
3001
|
-
* @param token 一次性Token(JWT)
|
|
3002
|
-
* @returns 授权码
|
|
3003
|
-
*/
|
|
3004
|
-
async getAuthorizationCode(token) {
|
|
3005
|
-
return await this.http.get("/api/v1/iam/oauth2/authorize", null, {
|
|
3006
|
-
headers: {
|
|
3007
|
-
Authorization: `Bearer ${token}`
|
|
3008
|
-
}
|
|
3009
|
-
});
|
|
3010
|
-
}
|
|
3011
|
-
/**
|
|
3012
|
-
* 获取AccessToken和RefreshToken API
|
|
3013
|
-
* @param code 授权码
|
|
3014
|
-
* @param token 一次性Token(JWT)
|
|
3015
|
-
* @returns AccessToken和RefreshToken
|
|
3016
|
-
*/
|
|
3017
|
-
async getAccessToken(code, token) {
|
|
3018
|
-
return await this.http.post("/api/v1/iam/oauth2/token", {
|
|
3019
|
-
grantType: "login_code",
|
|
3020
|
-
code
|
|
3021
|
-
}, {
|
|
3022
|
-
headers: {
|
|
3023
|
-
Authorization: `Bearer ${token}`
|
|
3024
|
-
}
|
|
3025
|
-
});
|
|
3026
|
-
}
|
|
3027
|
-
/**
|
|
3028
|
-
* Token 刷新 API
|
|
3029
|
-
* @param refreshToken RefreshToken
|
|
3030
|
-
* @returns 新的AccessToken
|
|
3031
|
-
*/
|
|
3032
|
-
async refreshToken(refreshToken) {
|
|
3033
|
-
return await this.http.post("/api/v1/iam/auth/refresh-token", null, {
|
|
3034
|
-
headers: {
|
|
3035
|
-
Authorization: `Bearer ${refreshToken}`
|
|
3036
|
-
}
|
|
3037
|
-
});
|
|
3038
|
-
}
|
|
3039
2968
|
/**
|
|
3040
2969
|
* 获取子应用授权码 API
|
|
3041
2970
|
* @param clientId 客户端ID
|
|
@@ -3063,8 +2992,8 @@ let Apis$5 = class Apis2 {
|
|
|
3063
2992
|
redirectUri
|
|
3064
2993
|
});
|
|
3065
2994
|
}
|
|
3066
|
-
}
|
|
3067
|
-
let Apis$4 = class
|
|
2995
|
+
}
|
|
2996
|
+
let Apis$4 = class Apis2 {
|
|
3068
2997
|
constructor(config) {
|
|
3069
2998
|
__publicField(this, "http");
|
|
3070
2999
|
this.http = config || init(config);
|
|
@@ -3134,7 +3063,7 @@ let Apis$4 = class Apis3 {
|
|
|
3134
3063
|
return await this.http.post("/api/v1/app/user/assignRoles", data);
|
|
3135
3064
|
}
|
|
3136
3065
|
};
|
|
3137
|
-
let Apis$3 = class
|
|
3066
|
+
let Apis$3 = class Apis3 {
|
|
3138
3067
|
constructor(config) {
|
|
3139
3068
|
__publicField(this, "http");
|
|
3140
3069
|
this.http = config || init(config);
|
|
@@ -3220,7 +3149,7 @@ let Apis$3 = class Apis4 {
|
|
|
3220
3149
|
});
|
|
3221
3150
|
}
|
|
3222
3151
|
};
|
|
3223
|
-
let Apis$2 = class
|
|
3152
|
+
let Apis$2 = class Apis4 {
|
|
3224
3153
|
constructor(config) {
|
|
3225
3154
|
__publicField(this, "http");
|
|
3226
3155
|
this.http = config || init(config);
|
|
@@ -3290,7 +3219,7 @@ let Apis$2 = class Apis5 {
|
|
|
3290
3219
|
});
|
|
3291
3220
|
}
|
|
3292
3221
|
};
|
|
3293
|
-
let Apis$1 = class
|
|
3222
|
+
let Apis$1 = class Apis5 {
|
|
3294
3223
|
constructor(config) {
|
|
3295
3224
|
__publicField(this, "http");
|
|
3296
3225
|
this.http = config || init(config);
|
|
@@ -3321,7 +3250,7 @@ let Apis$1 = class Apis6 {
|
|
|
3321
3250
|
return await this.http.post("/api/v1/app/permission/getPermission");
|
|
3322
3251
|
}
|
|
3323
3252
|
};
|
|
3324
|
-
class
|
|
3253
|
+
class Apis6 {
|
|
3325
3254
|
constructor(config) {
|
|
3326
3255
|
__publicField(this, "http");
|
|
3327
3256
|
this.http = config || init(config);
|
|
@@ -22079,12 +22008,11 @@ function formatDateTime(dateTime) {
|
|
|
22079
22008
|
const initHttp = init;
|
|
22080
22009
|
export {
|
|
22081
22010
|
Apis$4 as AppUserApis,
|
|
22082
|
-
Apis$5 as AuthApis,
|
|
22083
22011
|
_sfc_main$5 as Breadcrumb,
|
|
22084
22012
|
Apis$3 as ClientApis,
|
|
22085
22013
|
index as CropImage,
|
|
22086
22014
|
iconsSelect as IconsSelect,
|
|
22087
|
-
Apis$
|
|
22015
|
+
Apis$5 as MenuApis,
|
|
22088
22016
|
PERMISSION_CHECKER_KEY,
|
|
22089
22017
|
PERMISSION_STORE_KEY,
|
|
22090
22018
|
_sfc_main$1 as PageContainer,
|
|
@@ -22095,7 +22023,8 @@ export {
|
|
|
22095
22023
|
Apis$2 as RoleApis,
|
|
22096
22024
|
Apis$1 as RolePermissionApis,
|
|
22097
22025
|
selectLoadMore as SelectLoadMore,
|
|
22098
|
-
|
|
22026
|
+
SubAppAuthApis,
|
|
22027
|
+
Apis6 as UserCenterApis,
|
|
22099
22028
|
checkMultiplePermissionsAND,
|
|
22100
22029
|
checkMultiplePermissionsOR,
|
|
22101
22030
|
checkPermission,
|