@lytjs/plugin-auth 6.9.2 → 6.9.3
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/index.d.cts +52 -0
- package/dist/index.d.ts +52 -0
- package/package.json +4 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as _lytjs_core from '@lytjs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @lytjs/plugin-auth - 类型定义
|
|
5
|
+
*/
|
|
6
|
+
interface User {
|
|
7
|
+
/** 用户 ID */
|
|
8
|
+
id: string | number;
|
|
9
|
+
/** 用户名 */
|
|
10
|
+
username?: string;
|
|
11
|
+
/** 角色列表 */
|
|
12
|
+
roles: string[];
|
|
13
|
+
/** 权限列表 */
|
|
14
|
+
permissions: string[];
|
|
15
|
+
/** 附加数据 */
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface AuthOptions {
|
|
19
|
+
/** 初始用户 */
|
|
20
|
+
initialUser?: User | null;
|
|
21
|
+
/** 持久化 key */
|
|
22
|
+
storageKey?: string;
|
|
23
|
+
/** 是否启用持久化 */
|
|
24
|
+
enablePersistence?: boolean;
|
|
25
|
+
/** 超级管理员角色 */
|
|
26
|
+
superAdminRole?: string;
|
|
27
|
+
}
|
|
28
|
+
interface AuthInstance {
|
|
29
|
+
/** 当前用户 */
|
|
30
|
+
user: User | null;
|
|
31
|
+
/** 是否已登录 */
|
|
32
|
+
isAuthenticated: boolean;
|
|
33
|
+
/** 登录 */
|
|
34
|
+
login: (user: User) => void;
|
|
35
|
+
/** 登出 */
|
|
36
|
+
logout: () => void;
|
|
37
|
+
/** 检查角色 */
|
|
38
|
+
hasRole: (role: string | string[]) => boolean;
|
|
39
|
+
/** 检查权限 */
|
|
40
|
+
hasPermission: (permission: string | string[]) => boolean;
|
|
41
|
+
/** 检查所有角色 */
|
|
42
|
+
hasAllRoles: (roles: string[]) => boolean;
|
|
43
|
+
/** 检查所有权限 */
|
|
44
|
+
hasAllPermissions: (permissions: string[]) => boolean;
|
|
45
|
+
/** 更新用户信息 */
|
|
46
|
+
updateUser: (user: Partial<User>) => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare function createAuth(options?: AuthOptions): AuthInstance;
|
|
50
|
+
declare const pluginAuth: _lytjs_core.PluginDefinition<unknown>;
|
|
51
|
+
|
|
52
|
+
export { type AuthInstance, type AuthOptions, type User, createAuth, pluginAuth as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as _lytjs_core from '@lytjs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @lytjs/plugin-auth - 类型定义
|
|
5
|
+
*/
|
|
6
|
+
interface User {
|
|
7
|
+
/** 用户 ID */
|
|
8
|
+
id: string | number;
|
|
9
|
+
/** 用户名 */
|
|
10
|
+
username?: string;
|
|
11
|
+
/** 角色列表 */
|
|
12
|
+
roles: string[];
|
|
13
|
+
/** 权限列表 */
|
|
14
|
+
permissions: string[];
|
|
15
|
+
/** 附加数据 */
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface AuthOptions {
|
|
19
|
+
/** 初始用户 */
|
|
20
|
+
initialUser?: User | null;
|
|
21
|
+
/** 持久化 key */
|
|
22
|
+
storageKey?: string;
|
|
23
|
+
/** 是否启用持久化 */
|
|
24
|
+
enablePersistence?: boolean;
|
|
25
|
+
/** 超级管理员角色 */
|
|
26
|
+
superAdminRole?: string;
|
|
27
|
+
}
|
|
28
|
+
interface AuthInstance {
|
|
29
|
+
/** 当前用户 */
|
|
30
|
+
user: User | null;
|
|
31
|
+
/** 是否已登录 */
|
|
32
|
+
isAuthenticated: boolean;
|
|
33
|
+
/** 登录 */
|
|
34
|
+
login: (user: User) => void;
|
|
35
|
+
/** 登出 */
|
|
36
|
+
logout: () => void;
|
|
37
|
+
/** 检查角色 */
|
|
38
|
+
hasRole: (role: string | string[]) => boolean;
|
|
39
|
+
/** 检查权限 */
|
|
40
|
+
hasPermission: (permission: string | string[]) => boolean;
|
|
41
|
+
/** 检查所有角色 */
|
|
42
|
+
hasAllRoles: (roles: string[]) => boolean;
|
|
43
|
+
/** 检查所有权限 */
|
|
44
|
+
hasAllPermissions: (permissions: string[]) => boolean;
|
|
45
|
+
/** 更新用户信息 */
|
|
46
|
+
updateUser: (user: Partial<User>) => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare function createAuth(options?: AuthOptions): AuthInstance;
|
|
50
|
+
declare const pluginAuth: _lytjs_core.PluginDefinition<unknown>;
|
|
51
|
+
|
|
52
|
+
export { type AuthInstance, type AuthOptions, type User, createAuth, pluginAuth as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lytjs/plugin-auth",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.3",
|
|
4
4
|
"description": "LytJS official auth plugin for route authorization, permission checking, and role management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"clean": "rm -rf dist"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@lytjs/core": "
|
|
33
|
-
"@lytjs/reactivity": "
|
|
34
|
-
"@lytjs/common-is": "
|
|
32
|
+
"@lytjs/core": "^6.9.3",
|
|
33
|
+
"@lytjs/reactivity": "^6.9.3",
|
|
34
|
+
"@lytjs/common-is": "^6.9.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"tsup": "^8.0.0",
|