@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,291 @@
|
|
|
1
|
+
import type { AccessAuthentication, AccessAuthorization } from './aaa';
|
|
2
|
+
import type { AccessPath } from './common';
|
|
3
|
+
import type { AccessResource } from './resource';
|
|
4
|
+
/**
|
|
5
|
+
* 访问记录器
|
|
6
|
+
*/
|
|
7
|
+
export interface AccessRecorder {
|
|
8
|
+
/**
|
|
9
|
+
* 获取当前路径
|
|
10
|
+
*/
|
|
11
|
+
getCurrentPath(): AccessPath | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* 设置当前路径
|
|
14
|
+
* @param currentPath 当前路径
|
|
15
|
+
*/
|
|
16
|
+
setCurrentPath(currentPath: AccessPath): void;
|
|
17
|
+
/**
|
|
18
|
+
* 存在当前路径
|
|
19
|
+
*/
|
|
20
|
+
existCurrentPath(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 是否当前路径名
|
|
23
|
+
* @param pathname 路径名
|
|
24
|
+
*/
|
|
25
|
+
isCurrentPath(pathname: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 是否当前路径名集合
|
|
28
|
+
* @param pathnames 路径名集合
|
|
29
|
+
*/
|
|
30
|
+
isCurrentPaths(...pathnames: string[]): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 获取允许路径
|
|
33
|
+
*/
|
|
34
|
+
getAllowPath(): AccessPath | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* 设置允许路径
|
|
37
|
+
* @param allowPath 允许路径
|
|
38
|
+
*/
|
|
39
|
+
setAllowPath(allowPath: AccessPath): void;
|
|
40
|
+
/**
|
|
41
|
+
* 存在允许路径
|
|
42
|
+
*/
|
|
43
|
+
existAllowPath(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* 是否允许路径名
|
|
46
|
+
* @param pathname 路径名
|
|
47
|
+
*/
|
|
48
|
+
isAllowPath(pathname: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* 是否允许路径名集合
|
|
51
|
+
* @param pathnames 路径名集合
|
|
52
|
+
*/
|
|
53
|
+
isAllowPaths(...pathnames: string[]): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 获取原始路径
|
|
56
|
+
*/
|
|
57
|
+
getOriginPath(): AccessPath | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* 设置原始路径
|
|
60
|
+
* @param originPath 原始路径
|
|
61
|
+
*/
|
|
62
|
+
setOriginPath(originPath: AccessPath): void;
|
|
63
|
+
/**
|
|
64
|
+
* 存在原始路径
|
|
65
|
+
*/
|
|
66
|
+
existOriginPath(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* 是否原始路径名
|
|
69
|
+
* @param pathname 路径名
|
|
70
|
+
*/
|
|
71
|
+
isOriginPath(pathname: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* 是否原始路径名集合
|
|
74
|
+
* @param pathnames 路径名集合
|
|
75
|
+
*/
|
|
76
|
+
isOriginPaths(...pathnames: string[]): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* 获取访问资源
|
|
79
|
+
*/
|
|
80
|
+
getAccessResource(): AccessResource | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* 设置访问资源
|
|
83
|
+
* @param accessResource 访问资源
|
|
84
|
+
*/
|
|
85
|
+
setAccessResource(accessResource: AccessResource): void;
|
|
86
|
+
/**
|
|
87
|
+
* 存在访问资源
|
|
88
|
+
*/
|
|
89
|
+
existAccessResource(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* 获取访问认证
|
|
92
|
+
*/
|
|
93
|
+
getAccessAuthentication(): AccessAuthentication | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* 设置访问认证
|
|
96
|
+
* @param accessAuthentication 访问认证
|
|
97
|
+
*/
|
|
98
|
+
setAccessAuthentication(accessAuthentication: AccessAuthentication): void;
|
|
99
|
+
/**
|
|
100
|
+
* 存在访问认证
|
|
101
|
+
*/
|
|
102
|
+
existAccessAuthentication(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* 获取访问授权
|
|
105
|
+
*/
|
|
106
|
+
getAccessAuthorization(): AccessAuthorization | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* 设置访问授权
|
|
109
|
+
* @param accessAuthorization 访问授权
|
|
110
|
+
*/
|
|
111
|
+
setAccessAuthorization(accessAuthorization: AccessAuthorization): void;
|
|
112
|
+
/**
|
|
113
|
+
* 存在访问授权
|
|
114
|
+
*/
|
|
115
|
+
existAccessAuthorization(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* 清理原始路径
|
|
118
|
+
*/
|
|
119
|
+
clearOriginPath(): void;
|
|
120
|
+
/**
|
|
121
|
+
* 清理访问资源
|
|
122
|
+
*/
|
|
123
|
+
clearAccessResource(): void;
|
|
124
|
+
/**
|
|
125
|
+
* 清理访问认证
|
|
126
|
+
*/
|
|
127
|
+
clearAccessAuthentication(): void;
|
|
128
|
+
/**
|
|
129
|
+
* 清理访问授权
|
|
130
|
+
*/
|
|
131
|
+
clearAccessAuthorization(): void;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 简单记录器
|
|
135
|
+
*/
|
|
136
|
+
export declare class SimpleRecorder implements AccessRecorder {
|
|
137
|
+
/**
|
|
138
|
+
* 当前路径
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
private currentPath?;
|
|
142
|
+
/**
|
|
143
|
+
* 允许路径
|
|
144
|
+
* @private
|
|
145
|
+
*/
|
|
146
|
+
private allowPath?;
|
|
147
|
+
/**
|
|
148
|
+
* 原始路径
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
private originPath?;
|
|
152
|
+
/**
|
|
153
|
+
* 访问资源
|
|
154
|
+
* @private
|
|
155
|
+
*/
|
|
156
|
+
private accessResource?;
|
|
157
|
+
/**
|
|
158
|
+
* 访问认证
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
private accessAuthentication?;
|
|
162
|
+
/**
|
|
163
|
+
* 访问授权
|
|
164
|
+
* @private
|
|
165
|
+
*/
|
|
166
|
+
private accessAuthorization?;
|
|
167
|
+
/**
|
|
168
|
+
* 获取当前路径
|
|
169
|
+
*/
|
|
170
|
+
getCurrentPath(): AccessPath | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* 设置当前路径
|
|
173
|
+
* @param currentPath 当前路径
|
|
174
|
+
*/
|
|
175
|
+
setCurrentPath(currentPath: AccessPath): void;
|
|
176
|
+
/**
|
|
177
|
+
* 存在当前路径
|
|
178
|
+
*/
|
|
179
|
+
existCurrentPath(): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* 是否当前路径名
|
|
182
|
+
* @param pathname 当前路径名
|
|
183
|
+
*/
|
|
184
|
+
isCurrentPath(pathname: string): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* 是否当前路径名集合
|
|
187
|
+
* @param pathnames 路径名集合
|
|
188
|
+
*/
|
|
189
|
+
isCurrentPaths(...pathnames: string[]): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* 获取允许路径
|
|
192
|
+
*/
|
|
193
|
+
getAllowPath(): AccessPath | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* 设置允许路径
|
|
196
|
+
* @param allowPath 允许路径
|
|
197
|
+
*/
|
|
198
|
+
setAllowPath(allowPath: AccessPath): void;
|
|
199
|
+
/**
|
|
200
|
+
* 存在允许路径
|
|
201
|
+
*/
|
|
202
|
+
existAllowPath(): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* 是否允许路径名
|
|
205
|
+
* @param pathname 允许路径名
|
|
206
|
+
*/
|
|
207
|
+
isAllowPath(pathname: string): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* 是否允许路径名集合
|
|
210
|
+
* @param pathnames 路径名集合
|
|
211
|
+
*/
|
|
212
|
+
isAllowPaths(...pathnames: string[]): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* 获取原始路径
|
|
215
|
+
*/
|
|
216
|
+
getOriginPath(): AccessPath | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* 设置原始路径
|
|
219
|
+
* @param originPath 原始路径
|
|
220
|
+
*/
|
|
221
|
+
setOriginPath(originPath: AccessPath): void;
|
|
222
|
+
/**
|
|
223
|
+
* 存在原始路径
|
|
224
|
+
*/
|
|
225
|
+
existOriginPath(): boolean;
|
|
226
|
+
/**
|
|
227
|
+
* 是否原始路径名
|
|
228
|
+
* @param pathname 路径名
|
|
229
|
+
*/
|
|
230
|
+
isOriginPath(pathname: string): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* 是否原始路径名集合
|
|
233
|
+
* @param pathnames 路径名集合
|
|
234
|
+
*/
|
|
235
|
+
isOriginPaths(...pathnames: string[]): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* 获取访问资源
|
|
238
|
+
*/
|
|
239
|
+
getAccessResource(): AccessResource | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* 设置访问资源
|
|
242
|
+
* @param accessResource 访问资源
|
|
243
|
+
*/
|
|
244
|
+
setAccessResource(accessResource: AccessResource): void;
|
|
245
|
+
/**
|
|
246
|
+
* 存在访问资源
|
|
247
|
+
*/
|
|
248
|
+
existAccessResource(): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* 获取访问认证
|
|
251
|
+
*/
|
|
252
|
+
getAccessAuthentication(): AccessAuthentication | undefined;
|
|
253
|
+
/**
|
|
254
|
+
* 设置访问认证
|
|
255
|
+
* @param accessAuthentication 访问认证
|
|
256
|
+
*/
|
|
257
|
+
setAccessAuthentication(accessAuthentication: AccessAuthentication): void;
|
|
258
|
+
/**
|
|
259
|
+
* 存在访问认证
|
|
260
|
+
*/
|
|
261
|
+
existAccessAuthentication(): boolean;
|
|
262
|
+
/**
|
|
263
|
+
* 获取访问授权
|
|
264
|
+
*/
|
|
265
|
+
getAccessAuthorization(): AccessAuthorization | undefined;
|
|
266
|
+
/**
|
|
267
|
+
* 设置访问授权
|
|
268
|
+
* @param accessAuthorization 访问授权
|
|
269
|
+
*/
|
|
270
|
+
setAccessAuthorization(accessAuthorization: AccessAuthorization): void;
|
|
271
|
+
/**
|
|
272
|
+
* 存在访问授权
|
|
273
|
+
*/
|
|
274
|
+
existAccessAuthorization(): boolean;
|
|
275
|
+
/**
|
|
276
|
+
* 清理原始路径
|
|
277
|
+
*/
|
|
278
|
+
clearOriginPath(): void;
|
|
279
|
+
/**
|
|
280
|
+
* 清理访问资源
|
|
281
|
+
*/
|
|
282
|
+
clearAccessResource(): void;
|
|
283
|
+
/**
|
|
284
|
+
* 清理访问认证
|
|
285
|
+
*/
|
|
286
|
+
clearAccessAuthentication(): void;
|
|
287
|
+
/**
|
|
288
|
+
* 清理访问授权
|
|
289
|
+
*/
|
|
290
|
+
clearAccessAuthorization(): void;
|
|
291
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import type { PathPattern } from '../bridge';
|
|
2
|
+
import type { AccessPermission, AccessPermissions } from './common';
|
|
3
|
+
/**
|
|
4
|
+
* 资源模式
|
|
5
|
+
*/
|
|
6
|
+
export type ResourcePattern = PathPattern<string> | string;
|
|
7
|
+
/**
|
|
8
|
+
* 资源模式集合
|
|
9
|
+
*/
|
|
10
|
+
export type ResourcePatterns = ResourcePattern[];
|
|
11
|
+
/**
|
|
12
|
+
* 资源标签
|
|
13
|
+
*/
|
|
14
|
+
export type ResourceLabel = string;
|
|
15
|
+
/**
|
|
16
|
+
* 资源标签集合
|
|
17
|
+
*/
|
|
18
|
+
export type ResourceLabels = ResourceLabel[];
|
|
19
|
+
/**
|
|
20
|
+
* 访问资源
|
|
21
|
+
*/
|
|
22
|
+
export interface AccessResource {
|
|
23
|
+
/**
|
|
24
|
+
* 获取模式集合
|
|
25
|
+
*/
|
|
26
|
+
getPatterns(): Set<ResourcePattern>;
|
|
27
|
+
/**
|
|
28
|
+
* 获取权限集合
|
|
29
|
+
*/
|
|
30
|
+
getPermissions(): Set<AccessPermission>;
|
|
31
|
+
/**
|
|
32
|
+
* 获取标签集合
|
|
33
|
+
*/
|
|
34
|
+
getLabels(): Set<ResourceLabel>;
|
|
35
|
+
/**
|
|
36
|
+
* 是否包含模式
|
|
37
|
+
* @param pattern 模式
|
|
38
|
+
*/
|
|
39
|
+
hasPattern(pattern: ResourcePattern): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* 是否包含权限
|
|
42
|
+
* @param permission 权限
|
|
43
|
+
*/
|
|
44
|
+
hasPermission(permission: AccessPermission): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 是否包含标签
|
|
47
|
+
* @param label 标签
|
|
48
|
+
*/
|
|
49
|
+
hasLabel(label: ResourceLabel): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 是否匿名的
|
|
52
|
+
*/
|
|
53
|
+
isAnonymous(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 是否已认证
|
|
56
|
+
*/
|
|
57
|
+
isAuthenticated(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* 是否已授权
|
|
60
|
+
*/
|
|
61
|
+
isAuthorized(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* 是否已签名
|
|
64
|
+
*/
|
|
65
|
+
isSignatured(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* 是否始终签名
|
|
68
|
+
*/
|
|
69
|
+
isAlwaysSignature(): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* 获取基础路径
|
|
72
|
+
*/
|
|
73
|
+
getBasename(): string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* 设置基础路径
|
|
76
|
+
*/
|
|
77
|
+
setBasename(basename: string | undefined): void;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 访问资源集合
|
|
81
|
+
*/
|
|
82
|
+
export type AccessResources = AccessResource[];
|
|
83
|
+
/**
|
|
84
|
+
* 简单资源
|
|
85
|
+
*/
|
|
86
|
+
export declare class SimpleResource implements AccessResource {
|
|
87
|
+
/**
|
|
88
|
+
* 权限:匿名的
|
|
89
|
+
*/
|
|
90
|
+
static readonly PERMISSION_ANONYMOUS = "__anonymous__";
|
|
91
|
+
/**
|
|
92
|
+
* 权限:已认证
|
|
93
|
+
*/
|
|
94
|
+
static readonly PERMISSION_AUTHENTICATED = "__authenticated__";
|
|
95
|
+
/**
|
|
96
|
+
* 权限:已授权
|
|
97
|
+
*/
|
|
98
|
+
static readonly PERMISSION_AUTHORIZED = "__authorized__";
|
|
99
|
+
/**
|
|
100
|
+
* 标签:已签名
|
|
101
|
+
*/
|
|
102
|
+
static readonly LABEL_SIGNATURED = "__signatured__";
|
|
103
|
+
/**
|
|
104
|
+
* 标签:始终签名
|
|
105
|
+
*/
|
|
106
|
+
static readonly LABEL_ALWAYS_SIGNATURE = "__always_signature__";
|
|
107
|
+
/**
|
|
108
|
+
* 模式集合
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
private readonly patterns;
|
|
112
|
+
/**
|
|
113
|
+
* 权限集合
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
private readonly permissions;
|
|
117
|
+
/**
|
|
118
|
+
* 标签集合
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
private readonly labels;
|
|
122
|
+
/**
|
|
123
|
+
* 匿名的
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
126
|
+
private readonly anonymous;
|
|
127
|
+
/**
|
|
128
|
+
* 已认证
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
private readonly authenticated;
|
|
132
|
+
/**
|
|
133
|
+
* 已授权
|
|
134
|
+
* @private
|
|
135
|
+
*/
|
|
136
|
+
private readonly authorized;
|
|
137
|
+
/**
|
|
138
|
+
* 已签名
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
private readonly signatured;
|
|
142
|
+
/**
|
|
143
|
+
* 始终签名
|
|
144
|
+
* @private
|
|
145
|
+
*/
|
|
146
|
+
private readonly alwaysSignature;
|
|
147
|
+
/**
|
|
148
|
+
* 基础路径
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
private basename?;
|
|
152
|
+
/**
|
|
153
|
+
* 构造函数
|
|
154
|
+
* @param patterns 模式集合
|
|
155
|
+
* @param permissions 权限集合
|
|
156
|
+
* @param labels 标签集合
|
|
157
|
+
* @param basename 基础路径
|
|
158
|
+
*/
|
|
159
|
+
constructor(patterns: ResourcePatterns | Set<ResourcePattern>, permissions: AccessPermissions | Set<AccessPermission>, labels: ResourceLabels | Set<ResourceLabel>, basename?: string);
|
|
160
|
+
/**
|
|
161
|
+
* 获取模式集合
|
|
162
|
+
*/
|
|
163
|
+
getPatterns(): Set<ResourcePattern>;
|
|
164
|
+
/**
|
|
165
|
+
* 获取权限集合
|
|
166
|
+
*/
|
|
167
|
+
getPermissions(): Set<AccessPermission>;
|
|
168
|
+
/**
|
|
169
|
+
* 获取标签集合
|
|
170
|
+
*/
|
|
171
|
+
getLabels(): Set<ResourceLabel>;
|
|
172
|
+
/**
|
|
173
|
+
* 是否包含模式
|
|
174
|
+
* @param pattern 模式
|
|
175
|
+
*/
|
|
176
|
+
hasPattern(pattern: ResourcePattern): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* 是否包含权限
|
|
179
|
+
* @param permission 权限
|
|
180
|
+
*/
|
|
181
|
+
hasPermission(permission: AccessPermission): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* 是否包含标签
|
|
184
|
+
* @param label 标签
|
|
185
|
+
*/
|
|
186
|
+
hasLabel(label: ResourceLabel): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* 是否匿名的
|
|
189
|
+
*/
|
|
190
|
+
isAnonymous(): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* 是否已认证
|
|
193
|
+
*/
|
|
194
|
+
isAuthenticated(): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* 是否已授权
|
|
197
|
+
*/
|
|
198
|
+
isAuthorized(): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* 是否已签名
|
|
201
|
+
*/
|
|
202
|
+
isSignatured(): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* 是否始终签名
|
|
205
|
+
*/
|
|
206
|
+
isAlwaysSignature(): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* 获取基础路径
|
|
209
|
+
*/
|
|
210
|
+
getBasename(): string | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* 设置基础路径
|
|
213
|
+
*/
|
|
214
|
+
setBasename(basename: string | undefined): void;
|
|
215
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { type AccessAuthentication, type AccessAuthorization, type AccessDatasheet, type AuthenticationDatasheet, type AuthorizationDatasheet } from './aaa';
|
|
2
|
+
import type { AccessPath } from './common';
|
|
3
|
+
import type { AccessRecorder } from './recorder';
|
|
4
|
+
/**
|
|
5
|
+
* 访问存储器
|
|
6
|
+
*/
|
|
7
|
+
export interface AccessStorer {
|
|
8
|
+
/**
|
|
9
|
+
* 加载认证
|
|
10
|
+
* @param recorder 记录器
|
|
11
|
+
*/
|
|
12
|
+
loadAuthentication(recorder: AccessRecorder): AccessAuthentication | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* 校验认证
|
|
15
|
+
* @param recorder 记录器
|
|
16
|
+
* @param authentication 认证
|
|
17
|
+
*/
|
|
18
|
+
verifyAuthentication(recorder: AccessRecorder, authentication: AccessAuthentication): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 删除认证
|
|
21
|
+
* @param recorder 记录器
|
|
22
|
+
*/
|
|
23
|
+
deleteAuthentication(recorder: AccessRecorder): void;
|
|
24
|
+
/**
|
|
25
|
+
* 保存认证
|
|
26
|
+
* @param recorder 记录器
|
|
27
|
+
* @param datasheet 数据表
|
|
28
|
+
*/
|
|
29
|
+
saveAuthentication<Datasheet>(recorder: AccessRecorder, datasheet: AccessDatasheet<AuthenticationDatasheet<Datasheet>>): void;
|
|
30
|
+
/**
|
|
31
|
+
* 加载授权
|
|
32
|
+
* @param recorder 记录器
|
|
33
|
+
* @param authentication 认证 | undefined
|
|
34
|
+
*/
|
|
35
|
+
loadAuthorization(recorder: AccessRecorder, authentication: AccessAuthentication | undefined): AccessAuthorization | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* 删除授权
|
|
38
|
+
* @param recorder 记录器
|
|
39
|
+
*/
|
|
40
|
+
deleteAuthorization(recorder: AccessRecorder): void;
|
|
41
|
+
/**
|
|
42
|
+
* 保存授权
|
|
43
|
+
* @param recorder 记录器
|
|
44
|
+
* @param datasheet 数据表
|
|
45
|
+
*/
|
|
46
|
+
saveAuthorization<Datasheet>(recorder: AccessRecorder, datasheet: AccessDatasheet<AuthorizationDatasheet<Datasheet>>): void;
|
|
47
|
+
/**
|
|
48
|
+
* 加载签名
|
|
49
|
+
* @param recorder 记录器
|
|
50
|
+
* @param path 路径
|
|
51
|
+
* @param authentication 认证
|
|
52
|
+
* @param authorization 授权
|
|
53
|
+
*/
|
|
54
|
+
loadSignature(recorder: AccessRecorder, path: AccessPath, authentication: AccessAuthentication, authorization: AccessAuthorization): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* 移除签名
|
|
57
|
+
* @param recorder 记录器
|
|
58
|
+
* @param path 路径
|
|
59
|
+
*/
|
|
60
|
+
removeSignature(recorder: AccessRecorder, path: AccessPath): void;
|
|
61
|
+
/**
|
|
62
|
+
* 删除签名
|
|
63
|
+
* @param recorder 记录器
|
|
64
|
+
*/
|
|
65
|
+
deleteSignature(recorder: AccessRecorder): void;
|
|
66
|
+
/**
|
|
67
|
+
* 保存签名
|
|
68
|
+
* @param recorder 记录器
|
|
69
|
+
* @param path 路径
|
|
70
|
+
*/
|
|
71
|
+
saveSignature(recorder: AccessRecorder, path: AccessPath): void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 访问验证器
|
|
75
|
+
*/
|
|
76
|
+
export type AccessValidator = (recorder: AccessRecorder, authentication: AccessAuthentication) => boolean;
|
|
77
|
+
/**
|
|
78
|
+
* 简单存储器
|
|
79
|
+
*/
|
|
80
|
+
export declare class SimpleStorer implements AccessStorer {
|
|
81
|
+
/**
|
|
82
|
+
* 存储健:认证
|
|
83
|
+
*/
|
|
84
|
+
static readonly KEY_AUTHENTICATION = "__authentication__";
|
|
85
|
+
/**
|
|
86
|
+
* 存储健:授权
|
|
87
|
+
*/
|
|
88
|
+
static readonly KEY_AUTHORIZATION = "__authorization__";
|
|
89
|
+
/**
|
|
90
|
+
* 存储健:签名
|
|
91
|
+
*/
|
|
92
|
+
static readonly KEY_SIGNATURE = "__signature__";
|
|
93
|
+
/**
|
|
94
|
+
* 认证与授权存储
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
private readonly aaaStorage;
|
|
98
|
+
/**
|
|
99
|
+
* 签名存储
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
private readonly signStorage;
|
|
103
|
+
/**
|
|
104
|
+
* 认证健
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
private readonly authenticationKey;
|
|
108
|
+
/**
|
|
109
|
+
* 授权健
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
private readonly authorizationKey;
|
|
113
|
+
/**
|
|
114
|
+
* 签名健
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
private readonly signatureKey;
|
|
118
|
+
/**
|
|
119
|
+
* 认证验证器
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
122
|
+
private readonly authenticationValidator?;
|
|
123
|
+
/**
|
|
124
|
+
* 构造函数
|
|
125
|
+
* @param aaaStorage 认证与授权存储
|
|
126
|
+
* @param signStorage 签名存储
|
|
127
|
+
* @param authenticationKey 认证健
|
|
128
|
+
* @param authorizationKey 授权健
|
|
129
|
+
* @param signatureKey 签名健
|
|
130
|
+
* @param authenticationValidator 认证验证器
|
|
131
|
+
*/
|
|
132
|
+
constructor(aaaStorage: Storage, signStorage: Storage, authenticationKey?: string, authorizationKey?: string, signatureKey?: string, authenticationValidator?: AccessValidator);
|
|
133
|
+
/**
|
|
134
|
+
* 加载认证
|
|
135
|
+
* @param recorder 记录器
|
|
136
|
+
*/
|
|
137
|
+
loadAuthentication(recorder: AccessRecorder): AccessAuthentication | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* 校验认证
|
|
140
|
+
* @param recorder 记录器
|
|
141
|
+
* @param authentication 认证
|
|
142
|
+
*/
|
|
143
|
+
verifyAuthentication(recorder: AccessRecorder, authentication: AccessAuthentication): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* 删除认证
|
|
146
|
+
* @param recorder 记录器
|
|
147
|
+
*/
|
|
148
|
+
deleteAuthentication(recorder: AccessRecorder): void;
|
|
149
|
+
/**
|
|
150
|
+
* 保存认证
|
|
151
|
+
* @param recorder 记录器
|
|
152
|
+
* @param datasheet 数据表
|
|
153
|
+
*/
|
|
154
|
+
saveAuthentication<Datasheet>(recorder: AccessRecorder, datasheet: AccessDatasheet<AuthenticationDatasheet<Datasheet>>): void;
|
|
155
|
+
/**
|
|
156
|
+
* 加载授权
|
|
157
|
+
* @param recorder 记录器
|
|
158
|
+
* @param authentication 认证 | undefined
|
|
159
|
+
*/
|
|
160
|
+
loadAuthorization(recorder: AccessRecorder, authentication: AccessAuthentication | undefined): AccessAuthorization | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* 删除授权
|
|
163
|
+
* @param recorder 记录器
|
|
164
|
+
*/
|
|
165
|
+
deleteAuthorization(recorder: AccessRecorder): void;
|
|
166
|
+
/**
|
|
167
|
+
* 保存授权
|
|
168
|
+
* @param recorder 记录器
|
|
169
|
+
* @param datasheet 数据表
|
|
170
|
+
*/
|
|
171
|
+
saveAuthorization<Datasheet>(recorder: AccessRecorder, datasheet: AccessDatasheet<AuthorizationDatasheet<Datasheet>>): void;
|
|
172
|
+
/**
|
|
173
|
+
* 加载签名
|
|
174
|
+
* @param recorder 记录器
|
|
175
|
+
* @param path 路径
|
|
176
|
+
* @param authentication 认证
|
|
177
|
+
* @param authorization 授权
|
|
178
|
+
*/
|
|
179
|
+
loadSignature(recorder: AccessRecorder, path: AccessPath, authentication: AccessAuthentication, authorization: AccessAuthorization): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* 移除签名
|
|
182
|
+
* @param recorder 记录器
|
|
183
|
+
* @param path 路径
|
|
184
|
+
*/
|
|
185
|
+
removeSignature(recorder: AccessRecorder, path: AccessPath): void;
|
|
186
|
+
/**
|
|
187
|
+
* 删除签名
|
|
188
|
+
* @param recorder 记录器
|
|
189
|
+
*/
|
|
190
|
+
deleteSignature(recorder: AccessRecorder): void;
|
|
191
|
+
/**
|
|
192
|
+
* 保存签名
|
|
193
|
+
* @param recorder 记录器
|
|
194
|
+
* @param path 路径
|
|
195
|
+
*/
|
|
196
|
+
saveSignature(recorder: AccessRecorder, path: AccessPath): void;
|
|
197
|
+
}
|