@lanaqi/rsr 0.0.1-rc.0
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/README.md +49 -0
- package/dist/access/aaa.d.ts +177 -0
- package/dist/access/addon.d.ts +92 -0
- package/dist/access/blocker.d.ts +94 -0
- package/dist/access/common.d.ts +63 -0
- package/dist/access/context.d.ts +162 -0
- package/dist/access/guarder.d.ts +173 -0
- package/dist/access/handler.d.ts +183 -0
- package/dist/access/index.d.ts +56 -0
- package/dist/access/manager.d.ts +109 -0
- package/dist/access/matcher.d.ts +70 -0
- package/dist/access/navigator.d.ts +33 -0
- package/dist/access/recorder.d.ts +291 -0
- package/dist/access/resource.d.ts +215 -0
- package/dist/access/storer.d.ts +197 -0
- package/dist/access/voter.d.ts +156 -0
- package/dist/addons/index.d.ts +4 -0
- package/dist/addons/micro.d.ts +53 -0
- package/dist/bridge.d.ts +8 -0
- package/dist/builder/blocker.d.ts +24 -0
- package/dist/builder/builder.d.ts +9 -0
- package/dist/builder/context.d.ts +112 -0
- package/dist/builder/guarder.d.ts +54 -0
- package/dist/builder/handler.d.ts +21 -0
- package/dist/builder/index.d.ts +48 -0
- package/dist/builder/manager.d.ts +55 -0
- package/dist/builder/matcher.d.ts +37 -0
- package/dist/builder/navigator.d.ts +22 -0
- package/dist/builder/recorder.d.ts +11 -0
- package/dist/builder/resource.d.ts +101 -0
- package/dist/builder/storer.d.ts +83 -0
- package/dist/builder/voter.d.ts +41 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +1778 -0
- package/dist/security/blocker.d.ts +14 -0
- package/dist/security/index.d.ts +8 -0
- package/dist/security/provider.d.ts +31 -0
- package/dist/support/aaa.d.ts +29 -0
- package/dist/support/blocker.d.ts +28 -0
- package/dist/support/index.d.ts +20 -0
- package/dist/support/permission.d.ts +5 -0
- package/dist/support/signature.d.ts +21 -0
- package/dist/support/user.d.ts +14 -0
- package/dist/warpper/index.d.ts +4 -0
- package/dist/warpper/permission.d.ts +24 -0
- package/package.json +74 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ComponentType, type PropsWithChildren } from 'react';
|
|
2
|
+
import { type SecurityBundler } from './provider';
|
|
3
|
+
/**
|
|
4
|
+
* 安全阻断器组件
|
|
5
|
+
* @param children 子组件
|
|
6
|
+
* @constructor
|
|
7
|
+
*/
|
|
8
|
+
export declare function SecurityBlocker({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* 安全阻断器包装
|
|
11
|
+
* @param Component 组件
|
|
12
|
+
* @param bundler 打包器
|
|
13
|
+
*/
|
|
14
|
+
export declare const withSecurityBlocker: (Component: ComponentType, bundler: SecurityBundler) => () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type PropsWithChildren } from 'react';
|
|
2
|
+
import type { AccessProvider } from '../access';
|
|
3
|
+
import { AccessGuarderBuilder } from '../builder';
|
|
4
|
+
/**
|
|
5
|
+
* 安全打包器
|
|
6
|
+
*/
|
|
7
|
+
export type SecurityBundler = (builder: AccessGuarderBuilder) => AccessProvider;
|
|
8
|
+
/**
|
|
9
|
+
* 安全安装器
|
|
10
|
+
*/
|
|
11
|
+
export type SecurityInstaller = PropsWithChildren<{
|
|
12
|
+
/**
|
|
13
|
+
* 打包器
|
|
14
|
+
*/
|
|
15
|
+
readonly bundler: SecurityBundler;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* 安全上下文
|
|
19
|
+
*/
|
|
20
|
+
export declare const SecurityContext: import("react").Context<AccessProvider | null>;
|
|
21
|
+
/**
|
|
22
|
+
* 安全上下文钩子
|
|
23
|
+
*/
|
|
24
|
+
export declare const useSecurityContext: () => AccessProvider;
|
|
25
|
+
/**
|
|
26
|
+
* 安全提供者组件
|
|
27
|
+
* @param children 子组件
|
|
28
|
+
* @param bundler 打包器
|
|
29
|
+
* @constructor
|
|
30
|
+
*/
|
|
31
|
+
export declare function SecurityProvider({ children, bundler }: SecurityInstaller): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AccessAuthentication, AccessAuthorization, AccessDatasheet, AuthenticationDatasheet, AuthorizationDatasheet } from '../access';
|
|
2
|
+
/**
|
|
3
|
+
* 取得认证钩子
|
|
4
|
+
*/
|
|
5
|
+
export declare const useObtainAuthentication: () => (() => AccessAuthentication | undefined);
|
|
6
|
+
/**
|
|
7
|
+
* 取得授权钩子
|
|
8
|
+
*/
|
|
9
|
+
export declare const useObtainAuthorization: () => (() => AccessAuthorization | undefined);
|
|
10
|
+
/**
|
|
11
|
+
* 删除认证钩子
|
|
12
|
+
*/
|
|
13
|
+
export declare const useDeleteAuthentication: () => (() => void);
|
|
14
|
+
/**
|
|
15
|
+
* 删除授权钩子
|
|
16
|
+
*/
|
|
17
|
+
export declare const useDeleteAuthorization: () => (() => void);
|
|
18
|
+
/**
|
|
19
|
+
* 保存认证钩子
|
|
20
|
+
* @param navigate 是否导航
|
|
21
|
+
* @param redirect 重定向路径(如果不存在原始路径时使用)
|
|
22
|
+
*/
|
|
23
|
+
export declare const useSaveAuthentication: <Datasheet>(navigate?: boolean, redirect?: string) => ((datasheet: AccessDatasheet<AuthenticationDatasheet<Datasheet>>) => void);
|
|
24
|
+
/**
|
|
25
|
+
* 保存授权钩子
|
|
26
|
+
* @param navigate 是否导航
|
|
27
|
+
* @param redirect 重定向路径(如果不存在原始路径时使用)
|
|
28
|
+
*/
|
|
29
|
+
export declare const useSaveAuthorization: <Datasheet>(navigate?: boolean, redirect?: string) => ((datasheet: AccessDatasheet<AuthorizationDatasheet<Datasheet>>) => void);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AccessPath, BlockHandler } from '../access';
|
|
2
|
+
/**
|
|
3
|
+
* 自定义阻断器钩子
|
|
4
|
+
* @param handler 处理器
|
|
5
|
+
*/
|
|
6
|
+
export declare const useCustomBlocker: (handler: BlockHandler) => void;
|
|
7
|
+
/**
|
|
8
|
+
* 安全阻断器钩子
|
|
9
|
+
* @param recover 是否恢复 blocked = false
|
|
10
|
+
*/
|
|
11
|
+
export declare const useSecurityBlocker: (recover?: boolean) => {
|
|
12
|
+
/**
|
|
13
|
+
* 是否已阻断
|
|
14
|
+
*/
|
|
15
|
+
blocked: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 处理阻断(即继续访问)
|
|
18
|
+
*/
|
|
19
|
+
proceed: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* 重置阻断(即不再访问)
|
|
22
|
+
*/
|
|
23
|
+
reset: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* 阻断路径
|
|
26
|
+
*/
|
|
27
|
+
path: AccessPath | undefined;
|
|
28
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 认证与授权
|
|
3
|
+
*/
|
|
4
|
+
export * from './aaa';
|
|
5
|
+
/**
|
|
6
|
+
* 权限
|
|
7
|
+
*/
|
|
8
|
+
export * from './permission';
|
|
9
|
+
/**
|
|
10
|
+
* 签名
|
|
11
|
+
*/
|
|
12
|
+
export * from './signature';
|
|
13
|
+
/**
|
|
14
|
+
* 用户
|
|
15
|
+
*/
|
|
16
|
+
export * from './user';
|
|
17
|
+
/**
|
|
18
|
+
* 阻断器
|
|
19
|
+
*/
|
|
20
|
+
export * from './blocker';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AccessPath } from '../access';
|
|
2
|
+
/**
|
|
3
|
+
* 保存签名钩子
|
|
4
|
+
* @param navigate 是否导航(默认:true)
|
|
5
|
+
* @param redirect 重定向路径(如果不存在原始路径时使用)
|
|
6
|
+
*/
|
|
7
|
+
export declare const useSaveSignature: (navigate?: boolean, redirect?: string) => ((path?: AccessPath) => void);
|
|
8
|
+
/**
|
|
9
|
+
* 删除签名钩子
|
|
10
|
+
*/
|
|
11
|
+
export declare const useDeleteSignature: () => (() => void);
|
|
12
|
+
/**
|
|
13
|
+
* 移除签名钩子
|
|
14
|
+
*/
|
|
15
|
+
export declare const useRemoveSignature: () => ((path: string | AccessPath) => void);
|
|
16
|
+
/**
|
|
17
|
+
* 清除签名(当前路径)钩子
|
|
18
|
+
*
|
|
19
|
+
* 当触发销毁时执行清除
|
|
20
|
+
*/
|
|
21
|
+
export declare const usePurgeSignature: () => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AccessDatasheet, UserDatasheet } from '../access';
|
|
2
|
+
/**
|
|
3
|
+
* 登出钩子
|
|
4
|
+
* @param navigate 是否导航(默认:true)
|
|
5
|
+
* @param redirect 重定向路径(如果不存在原始路径时使用)
|
|
6
|
+
*/
|
|
7
|
+
export declare const useLogout: (navigate?: boolean, redirect?: string) => (() => void);
|
|
8
|
+
/**
|
|
9
|
+
* 登入钩子
|
|
10
|
+
* @param logined 已登录跳转
|
|
11
|
+
* @param navigate 是否导航(默认:true)
|
|
12
|
+
* @param redirect 重定向路径(如果不存在原始路径时使用)
|
|
13
|
+
*/
|
|
14
|
+
export declare const useLogin: <Datasheet>(logined?: boolean, navigate?: boolean, redirect?: string) => ((datasheet: AccessDatasheet<UserDatasheet<Datasheet>>) => void);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
+
import type { AccessPermission, AccessPermissions } from '../access';
|
|
3
|
+
/**
|
|
4
|
+
* 权限条件
|
|
5
|
+
*/
|
|
6
|
+
export type PermissionTerm = PropsWithChildren<{
|
|
7
|
+
/**
|
|
8
|
+
* 条件
|
|
9
|
+
*/
|
|
10
|
+
readonly term: AccessPermission | AccessPermissions;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* 拥有权限组件
|
|
14
|
+
* @param children 子组件
|
|
15
|
+
* @param term 条件
|
|
16
|
+
* @constructor
|
|
17
|
+
*/
|
|
18
|
+
export declare function HavePermission({ children, term }: PermissionTerm): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* 拥有权限包装
|
|
21
|
+
* @param Component 组件
|
|
22
|
+
* @param term 条件
|
|
23
|
+
*/
|
|
24
|
+
export declare const withHavePermission: (Component: ComponentType, term: AccessPermission | AccessPermissions) => () => import("react/jsx-runtime").JSX.Element;
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lanaqi/rsr",
|
|
3
|
+
"version": "0.0.1-rc.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"files": ["dist"],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"react",
|
|
16
|
+
"router",
|
|
17
|
+
"security",
|
|
18
|
+
"react-security",
|
|
19
|
+
"router-security",
|
|
20
|
+
"react-security-router",
|
|
21
|
+
"react-router-security",
|
|
22
|
+
"guard",
|
|
23
|
+
"react-guard",
|
|
24
|
+
"router-guard",
|
|
25
|
+
"react-router-guard",
|
|
26
|
+
"react-router",
|
|
27
|
+
"react-router-dom",
|
|
28
|
+
"modern-js",
|
|
29
|
+
"modernjs",
|
|
30
|
+
"安全",
|
|
31
|
+
"鉴权",
|
|
32
|
+
"守护",
|
|
33
|
+
"认证",
|
|
34
|
+
"授权",
|
|
35
|
+
"权限",
|
|
36
|
+
"安全框架",
|
|
37
|
+
"路由安全",
|
|
38
|
+
"认证授权",
|
|
39
|
+
"路由守护"
|
|
40
|
+
],
|
|
41
|
+
"description": "React 安全路由器",
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "rslib build",
|
|
44
|
+
"lint": "biome lint",
|
|
45
|
+
"check": "biome check",
|
|
46
|
+
"format": "biome format --write",
|
|
47
|
+
"release": "npm run build && npm publish"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@biomejs/biome": "^1.9.4",
|
|
51
|
+
"@rsbuild/plugin-react": "^1.1.1",
|
|
52
|
+
"@rslib/core": "^0.5.5",
|
|
53
|
+
"@types/react": "^18.3.19",
|
|
54
|
+
"@types/react-dom": "^18.3.5",
|
|
55
|
+
"react": "^18.3.1",
|
|
56
|
+
"react-dom": "^18.3.1",
|
|
57
|
+
"react-router-dom": "^6.30.0",
|
|
58
|
+
"typescript": "^5.8.2"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"react": ">=17.0.0",
|
|
62
|
+
"react-dom": ">=17.0.0",
|
|
63
|
+
"react-router-dom": "^6.0.0"
|
|
64
|
+
},
|
|
65
|
+
"private": false,
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public",
|
|
68
|
+
"registry": "https://registry.npmjs.org"
|
|
69
|
+
},
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "https://github.com/lanaqi-opensource/react-security-router.git"
|
|
73
|
+
}
|
|
74
|
+
}
|