@authup/access 1.0.0-beta.64 → 1.0.0-beta.66
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.mts +560 -149
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +715 -27
- package/dist/index.mjs.map +1 -1
- package/dist/permission/authorization/check-schema.d.ts +23 -0
- package/dist/permission/authorization/check-schema.d.ts.map +1 -0
- package/dist/permission/authorization/check.d.ts +7 -0
- package/dist/permission/authorization/check.d.ts.map +1 -0
- package/dist/permission/authorization/constants.d.ts +14 -0
- package/dist/permission/authorization/constants.d.ts.map +1 -0
- package/dist/permission/authorization/error.d.ts +18 -0
- package/dist/permission/authorization/error.d.ts.map +1 -0
- package/dist/permission/authorization/index.d.ts +9 -0
- package/dist/permission/authorization/index.d.ts.map +1 -0
- package/dist/permission/authorization/module.d.ts +70 -0
- package/dist/permission/authorization/module.d.ts.map +1 -0
- package/dist/permission/authorization/policy.d.ts +23 -0
- package/dist/permission/authorization/policy.d.ts.map +1 -0
- package/dist/permission/authorization/schema.d.ts +107 -0
- package/dist/permission/authorization/schema.d.ts.map +1 -0
- package/dist/permission/authorization/types.d.ts +122 -0
- package/dist/permission/authorization/types.d.ts.map +1 -0
- package/dist/permission/evaluator/module.d.ts.map +1 -1
- package/dist/permission/evaluator/types.d.ts +8 -0
- package/dist/permission/evaluator/types.d.ts.map +1 -1
- package/dist/permission/index.d.ts +1 -0
- package/dist/permission/index.d.ts.map +1 -1
- package/dist/policy/built-in/permission-binding/identity-evaluator.d.ts +21 -0
- package/dist/policy/built-in/permission-binding/identity-evaluator.d.ts.map +1 -0
- package/dist/policy/built-in/permission-binding/index.d.ts +1 -0
- package/dist/policy/built-in/permission-binding/index.d.ts.map +1 -1
- package/dist/policy/built-in/permission-binding/validator.d.ts.map +1 -1
- package/dist/policy/data.d.ts +2 -0
- package/dist/policy/data.d.ts.map +1 -1
- package/dist/policy/evaluation/context/define.d.ts.map +1 -1
- package/dist/policy/evaluation/context/types.d.ts +9 -0
- package/dist/policy/evaluation/context/types.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -3,30 +3,33 @@ import { DecisionStrategy } from "@authup/kit";
|
|
|
3
3
|
import { ICondition } from "@rapiq/core";
|
|
4
4
|
import { Issue, IssueGroup, IssueItem } from "@ebec/core";
|
|
5
5
|
import { Container } from "validup";
|
|
6
|
+
import { z } from "zod";
|
|
6
7
|
import { MongoFiltersParser, MongoFiltersParserInput } from "@rapiq/parser-mongo";
|
|
7
8
|
//#region src/policy/data.d.ts
|
|
8
|
-
interface IPolicyData {
|
|
9
|
+
export interface IPolicyData {
|
|
9
10
|
set(key: string, value: unknown): void;
|
|
10
11
|
has(key: string): boolean;
|
|
11
12
|
get<T = unknown>(key: string): T;
|
|
13
|
+
delete(key: string): void;
|
|
12
14
|
isValidated(key: string): boolean;
|
|
13
15
|
setValidated(key: string): void;
|
|
14
16
|
clone(): IPolicyData;
|
|
15
17
|
}
|
|
16
|
-
declare class PolicyData implements IPolicyData {
|
|
18
|
+
export declare class PolicyData implements IPolicyData {
|
|
17
19
|
protected data: Record<string, any>;
|
|
18
20
|
protected validated: Set<string>;
|
|
19
21
|
constructor(data?: Record<string, any>, validated?: Set<string>);
|
|
20
22
|
set<T = unknown>(key: string, value: T): void;
|
|
21
23
|
get<T = unknown>(key: string): T;
|
|
22
24
|
has(key: string): boolean;
|
|
25
|
+
delete(key: string): void;
|
|
23
26
|
setValidated(key: string): void;
|
|
24
27
|
isValidated(key: string): boolean;
|
|
25
28
|
clone(): PolicyData;
|
|
26
29
|
}
|
|
27
30
|
//#endregion
|
|
28
31
|
//#region src/policy/evaluation/context/types.d.ts
|
|
29
|
-
type PolicyEvaluationContext = {
|
|
32
|
+
export type PolicyEvaluationContext = {
|
|
30
33
|
readonly evaluators: Record<string, IPolicyEvaluator>;
|
|
31
34
|
readonly path: (string | number)[];
|
|
32
35
|
readonly exclude: string[];
|
|
@@ -39,15 +42,24 @@ type PolicyEvaluationContext = {
|
|
|
39
42
|
* query-build callers opt in.
|
|
40
43
|
*/
|
|
41
44
|
readonly withConditions: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Row column the realm reach is LOWERED onto, for a caller whose rows carry the
|
|
47
|
+
* realm under another name (a junction's `roleRealmId` / `clientRealmId` / …).
|
|
48
|
+
* Default `realmId`. It reaches `RealmMatchPolicyEvaluator` scope mode as
|
|
49
|
+
* `attributeName`, which that mode reads only while lowering — settled
|
|
50
|
+
* evaluation takes the resource realm from the `realmMatch` data key and never
|
|
51
|
+
* consults a column name, so this can never change an evaluate() outcome.
|
|
52
|
+
*/
|
|
53
|
+
readonly realmAttributeName?: string;
|
|
42
54
|
};
|
|
43
|
-
type PolicyEvaluationContextInput = Partial<PolicyEvaluationContext>;
|
|
55
|
+
export type PolicyEvaluationContextInput = Partial<PolicyEvaluationContext>;
|
|
44
56
|
//#endregion
|
|
45
57
|
//#region src/policy/evaluation/context/define.d.ts
|
|
46
|
-
declare function definePolicyEvaluationContext(input?: PolicyEvaluationContextInput): PolicyEvaluationContext;
|
|
58
|
+
export declare function definePolicyEvaluationContext(input?: PolicyEvaluationContextInput): PolicyEvaluationContext;
|
|
47
59
|
//#endregion
|
|
48
60
|
//#region src/policy/evaluation/types.d.ts
|
|
49
|
-
type PolicyEvaluators = Record<string, IPolicyEvaluator>;
|
|
50
|
-
type PolicyEvaluationResult = {
|
|
61
|
+
export type PolicyEvaluators = Record<string, IPolicyEvaluator>;
|
|
62
|
+
export type PolicyEvaluationResult = {
|
|
51
63
|
success: boolean;
|
|
52
64
|
/**
|
|
53
65
|
* The policy could not be settled yet — a data key it requires is absent from the
|
|
@@ -70,7 +82,7 @@ type PolicyEvaluationResult = {
|
|
|
70
82
|
condition?: ICondition;
|
|
71
83
|
issues?: Issue[];
|
|
72
84
|
};
|
|
73
|
-
interface IPolicyEvaluator {
|
|
85
|
+
export interface IPolicyEvaluator {
|
|
74
86
|
/**
|
|
75
87
|
* PolicyData keys this policy needs before it can settle (e.g. `identity`,
|
|
76
88
|
* `attributes`). When any returned key is absent from the evaluation bag, the
|
|
@@ -100,7 +112,7 @@ interface IPolicyEvaluator {
|
|
|
100
112
|
}
|
|
101
113
|
//#endregion
|
|
102
114
|
//#region src/policy/types.d.ts
|
|
103
|
-
type BasePolicy<T extends string = string> = {
|
|
115
|
+
export type BasePolicy<T extends string = string> = {
|
|
104
116
|
/**
|
|
105
117
|
* Type describing the policy.
|
|
106
118
|
*/
|
|
@@ -110,10 +122,10 @@ type BasePolicy<T extends string = string> = {
|
|
|
110
122
|
*/
|
|
111
123
|
invert?: boolean;
|
|
112
124
|
};
|
|
113
|
-
type PolicyWithType<R extends Record<string, any> = Record<string, any>, T extends string = string> = R & BasePolicy<T>;
|
|
125
|
+
export type PolicyWithType<R extends Record<string, any> = Record<string, any>, T extends string = string> = R & BasePolicy<T>;
|
|
114
126
|
//#endregion
|
|
115
127
|
//#region src/policy/engine/types.d.ts
|
|
116
|
-
interface IPolicyEngine {
|
|
128
|
+
export interface IPolicyEngine {
|
|
117
129
|
evaluate(policy: BasePolicy, options: PolicyEvaluationContext): Promise<PolicyEvaluationResult>;
|
|
118
130
|
evaluateOrFail(policy: BasePolicy, options: PolicyEvaluationContext): Promise<void>;
|
|
119
131
|
}
|
|
@@ -123,7 +135,7 @@ interface IPolicyEngine {
|
|
|
123
135
|
* The policy engine is a component that interprets defined policies and makes decisions
|
|
124
136
|
* on whether to allow or deny a particular access.
|
|
125
137
|
*/
|
|
126
|
-
declare class PolicyEngine implements IPolicyEngine {
|
|
138
|
+
export declare class PolicyEngine implements IPolicyEngine {
|
|
127
139
|
protected evaluators: Record<string, IPolicyEvaluator>;
|
|
128
140
|
constructor(evaluators?: PolicyEvaluators);
|
|
129
141
|
registerEvaluator(type: string, evaluator: IPolicyEvaluator): void;
|
|
@@ -137,11 +149,11 @@ declare class PolicyEngine implements IPolicyEngine {
|
|
|
137
149
|
}
|
|
138
150
|
//#endregion
|
|
139
151
|
//#region src/policy/issue/constants.d.ts
|
|
140
|
-
declare enum PolicyIssueSeverity {
|
|
152
|
+
export declare enum PolicyIssueSeverity {
|
|
141
153
|
WARNING = "warning",
|
|
142
154
|
ERROR = "error"
|
|
143
155
|
}
|
|
144
|
-
declare enum PolicyIssueCode {
|
|
156
|
+
export declare enum PolicyIssueCode {
|
|
145
157
|
DATA_MISSING = "DATA_MISSING",
|
|
146
158
|
DATA_INVALID = "DATA_INVALID",
|
|
147
159
|
INVALID = "INVALID",
|
|
@@ -159,17 +171,17 @@ declare enum PolicyIssueCode {
|
|
|
159
171
|
}
|
|
160
172
|
//#endregion
|
|
161
173
|
//#region src/policy/issue/types.d.ts
|
|
162
|
-
type PolicyIssueItem = IssueItem;
|
|
163
|
-
type PolicyIssueGroup = IssueGroup;
|
|
164
|
-
type PolicyIssue = PolicyIssueItem | PolicyIssueGroup;
|
|
174
|
+
export type PolicyIssueItem = IssueItem;
|
|
175
|
+
export type PolicyIssueGroup = IssueGroup;
|
|
176
|
+
export type PolicyIssue = PolicyIssueItem | PolicyIssueGroup;
|
|
165
177
|
//#endregion
|
|
166
178
|
//#region src/policy/issue/define.d.ts
|
|
167
|
-
declare function definePolicyIssueItem(input: Omit<PolicyIssueItem, 'type'>): PolicyIssueItem;
|
|
168
|
-
declare function definePolicyIssueGroup(input: Omit<PolicyIssueGroup, 'type'>): PolicyIssueGroup;
|
|
179
|
+
export declare function definePolicyIssueItem(input: Omit<PolicyIssueItem, 'type'>): PolicyIssueItem;
|
|
180
|
+
export declare function definePolicyIssueGroup(input: Omit<PolicyIssueGroup, 'type'>): PolicyIssueGroup;
|
|
169
181
|
//#endregion
|
|
170
182
|
//#region src/policy/error/module.d.ts
|
|
171
|
-
declare const POLICY_ERROR_INSTANCE: unique symbol;
|
|
172
|
-
declare class PolicyError extends AuthupError {
|
|
183
|
+
export declare const POLICY_ERROR_INSTANCE: unique symbol;
|
|
184
|
+
export declare class PolicyError extends AuthupError {
|
|
173
185
|
constructor(message?: string, code?: string | null, issues?: PolicyIssue[]);
|
|
174
186
|
static evaluatorNotFound(type: string): PolicyError;
|
|
175
187
|
static evaluatorNotProcessable(): PolicyError;
|
|
@@ -177,38 +189,38 @@ declare class PolicyError extends AuthupError {
|
|
|
177
189
|
}
|
|
178
190
|
//#endregion
|
|
179
191
|
//#region src/policy/error/check.d.ts
|
|
180
|
-
declare function isPolicyError(input: unknown): input is PolicyError;
|
|
192
|
+
export declare function isPolicyError(input: unknown): input is PolicyError;
|
|
181
193
|
//#endregion
|
|
182
194
|
//#region src/policy/helpers/invert.d.ts
|
|
183
195
|
type InvertFn = (input: boolean) => boolean;
|
|
184
|
-
declare function maybeInvertPolicyOutcome(outcome: boolean, invert?: boolean | InvertFn): boolean;
|
|
196
|
+
export declare function maybeInvertPolicyOutcome(outcome: boolean, invert?: boolean | InvertFn): boolean;
|
|
185
197
|
//#endregion
|
|
186
198
|
//#region src/policy/built-in/attribute-names/types.d.ts
|
|
187
|
-
interface AttributeNamesPolicy extends BasePolicy {
|
|
199
|
+
export interface AttributeNamesPolicy extends BasePolicy {
|
|
188
200
|
names: string[];
|
|
189
201
|
}
|
|
190
202
|
//#endregion
|
|
191
203
|
//#region src/policy/built-in/attribute-names/validator.d.ts
|
|
192
|
-
declare class AttributeNamesPolicyValidator extends Container<AttributeNamesPolicy> {
|
|
204
|
+
export declare class AttributeNamesPolicyValidator extends Container<AttributeNamesPolicy> {
|
|
193
205
|
initialize(): void;
|
|
194
206
|
}
|
|
195
207
|
//#endregion
|
|
196
208
|
//#region src/policy/built-in/attributes/types.d.ts
|
|
197
|
-
type AttributesPolicyQuery<T extends Record<string, any> = Record<string, any>> = MongoFiltersParserInput<T>;
|
|
198
|
-
interface AttributesPolicy<T extends Record<string, any> = Record<string, any>> extends BasePolicy {
|
|
209
|
+
export type AttributesPolicyQuery<T extends Record<string, any> = Record<string, any>> = MongoFiltersParserInput<T>;
|
|
210
|
+
export interface AttributesPolicy<T extends Record<string, any> = Record<string, any>> extends BasePolicy {
|
|
199
211
|
query: AttributesPolicyQuery<T>;
|
|
200
212
|
}
|
|
201
213
|
//#endregion
|
|
202
214
|
//#region src/policy/built-in/attributes/define.d.ts
|
|
203
|
-
declare function defineAttributesPolicy<T extends Record<string, any> = Record<string, any>>(data: AttributesPolicy<T>): AttributesPolicy<T>;
|
|
215
|
+
export declare function defineAttributesPolicy<T extends Record<string, any> = Record<string, any>>(data: AttributesPolicy<T>): AttributesPolicy<T>;
|
|
204
216
|
//#endregion
|
|
205
217
|
//#region src/policy/built-in/attributes/validator.d.ts
|
|
206
|
-
declare class AttributesPolicyValidator<T extends Record<string, any> = Record<string, any>> extends Container<AttributesPolicy<T>> {
|
|
218
|
+
export declare class AttributesPolicyValidator<T extends Record<string, any> = Record<string, any>> extends Container<AttributesPolicy<T>> {
|
|
207
219
|
initialize(): void;
|
|
208
220
|
}
|
|
209
221
|
//#endregion
|
|
210
222
|
//#region src/policy/built-in/attributes/evaluator.d.ts
|
|
211
|
-
declare class AttributesPolicyEvaluator<T extends Record<string, any> = Record<string, any>> implements IPolicyEvaluator {
|
|
223
|
+
export declare class AttributesPolicyEvaluator<T extends Record<string, any> = Record<string, any>> implements IPolicyEvaluator {
|
|
212
224
|
protected validator: AttributesPolicyValidator<T>;
|
|
213
225
|
protected parser: MongoFiltersParser;
|
|
214
226
|
constructor();
|
|
@@ -220,7 +232,7 @@ declare class AttributesPolicyEvaluator<T extends Record<string, any> = Record<s
|
|
|
220
232
|
}
|
|
221
233
|
//#endregion
|
|
222
234
|
//#region src/policy/built-in/attribute-names/evaluator.d.ts
|
|
223
|
-
declare class AttributeNamesPolicyEvaluator implements IPolicyEvaluator {
|
|
235
|
+
export declare class AttributeNamesPolicyEvaluator implements IPolicyEvaluator {
|
|
224
236
|
protected validator: AttributeNamesPolicyValidator;
|
|
225
237
|
protected attributesEvaluator: AttributesPolicyEvaluator;
|
|
226
238
|
constructor();
|
|
@@ -228,7 +240,7 @@ declare class AttributeNamesPolicyEvaluator implements IPolicyEvaluator {
|
|
|
228
240
|
}
|
|
229
241
|
//#endregion
|
|
230
242
|
//#region src/policy/built-in/composite/types.d.ts
|
|
231
|
-
interface CompositePolicy extends BasePolicy {
|
|
243
|
+
export interface CompositePolicy extends BasePolicy {
|
|
232
244
|
/**
|
|
233
245
|
* How to decide if a policy evaluates to true.
|
|
234
246
|
*/
|
|
@@ -240,46 +252,46 @@ interface CompositePolicy extends BasePolicy {
|
|
|
240
252
|
}
|
|
241
253
|
//#endregion
|
|
242
254
|
//#region src/policy/built-in/composite/validator.d.ts
|
|
243
|
-
declare class CompositePolicyValidator extends Container<CompositePolicy> {
|
|
255
|
+
export declare class CompositePolicyValidator extends Container<CompositePolicy> {
|
|
244
256
|
initialize(): void;
|
|
245
257
|
}
|
|
246
258
|
//#endregion
|
|
247
259
|
//#region src/policy/built-in/composite/evaluator.d.ts
|
|
248
|
-
declare class CompositePolicyEvaluator implements IPolicyEvaluator {
|
|
260
|
+
export declare class CompositePolicyEvaluator implements IPolicyEvaluator {
|
|
249
261
|
protected validator: CompositePolicyValidator;
|
|
250
262
|
constructor();
|
|
251
263
|
evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult>;
|
|
252
264
|
}
|
|
253
265
|
//#endregion
|
|
254
266
|
//#region src/policy/built-in/composite/helper.d.ts
|
|
255
|
-
declare function isCompositePolicy(input: PolicyWithType): input is PolicyWithType<CompositePolicy>;
|
|
267
|
+
export declare function isCompositePolicy(input: PolicyWithType): input is PolicyWithType<CompositePolicy>;
|
|
256
268
|
//#endregion
|
|
257
269
|
//#region src/policy/built-in/date/types.d.ts
|
|
258
|
-
interface DatePolicy extends BasePolicy {
|
|
270
|
+
export interface DatePolicy extends BasePolicy {
|
|
259
271
|
start?: string | Date | number;
|
|
260
272
|
end?: string | Date | number;
|
|
261
273
|
}
|
|
262
274
|
//#endregion
|
|
263
275
|
//#region src/policy/built-in/date/validator.d.ts
|
|
264
|
-
declare class DatePolicyValidator extends Container<DatePolicy> {
|
|
276
|
+
export declare class DatePolicyValidator extends Container<DatePolicy> {
|
|
265
277
|
initialize(): void;
|
|
266
278
|
}
|
|
267
279
|
//#endregion
|
|
268
280
|
//#region src/policy/built-in/date/evaluator.d.ts
|
|
269
|
-
declare class DatePolicyEvaluator implements IPolicyEvaluator {
|
|
281
|
+
export declare class DatePolicyEvaluator implements IPolicyEvaluator {
|
|
270
282
|
protected validator: DatePolicyValidator;
|
|
271
283
|
constructor();
|
|
272
284
|
evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult>;
|
|
273
285
|
}
|
|
274
286
|
//#endregion
|
|
275
287
|
//#region src/policy/built-in/identity/types.d.ts
|
|
276
|
-
interface IdentityPolicy extends BasePolicy {
|
|
288
|
+
export interface IdentityPolicy extends BasePolicy {
|
|
277
289
|
/**
|
|
278
290
|
* Set of allowed identity types.
|
|
279
291
|
*/
|
|
280
292
|
types?: string[];
|
|
281
293
|
}
|
|
282
|
-
type IdentityPolicyData = {
|
|
294
|
+
export type IdentityPolicyData = {
|
|
283
295
|
/**
|
|
284
296
|
* user, client
|
|
285
297
|
*/
|
|
@@ -308,12 +320,12 @@ declare class PolicyIdentityDataValidator extends Container<IdentityPolicyData>
|
|
|
308
320
|
}
|
|
309
321
|
//#endregion
|
|
310
322
|
//#region src/policy/built-in/identity/validator.d.ts
|
|
311
|
-
declare class IdentityPolicyValidator extends Container<IdentityPolicy> {
|
|
323
|
+
export declare class IdentityPolicyValidator extends Container<IdentityPolicy> {
|
|
312
324
|
initialize(): void;
|
|
313
325
|
}
|
|
314
326
|
//#endregion
|
|
315
327
|
//#region src/policy/built-in/identity/evaluator.d.ts
|
|
316
|
-
declare class IdentityPolicyEvaluator implements IPolicyEvaluator {
|
|
328
|
+
export declare class IdentityPolicyEvaluator implements IPolicyEvaluator {
|
|
317
329
|
protected validator: IdentityPolicyValidator;
|
|
318
330
|
protected dataValidator: PolicyIdentityDataValidator;
|
|
319
331
|
constructor();
|
|
@@ -322,22 +334,6 @@ declare class IdentityPolicyEvaluator implements IPolicyEvaluator {
|
|
|
322
334
|
evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult>;
|
|
323
335
|
}
|
|
324
336
|
//#endregion
|
|
325
|
-
//#region src/policy/built-in/permission-binding/types.d.ts
|
|
326
|
-
interface PermissionBindingPolicy extends BasePolicy {}
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/policy/built-in/permission-binding/validator.d.ts
|
|
329
|
-
declare class PermissionBindingPolicyValidator extends Container<PermissionBindingPolicy> {
|
|
330
|
-
initialize(): void;
|
|
331
|
-
}
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region src/policy/built-in/permission-binding/module.d.ts
|
|
334
|
-
declare class PermissionBindingPolicyEvaluator implements IPolicyEvaluator {
|
|
335
|
-
protected validator: PermissionBindingPolicyValidator;
|
|
336
|
-
constructor();
|
|
337
|
-
requires(): string[];
|
|
338
|
-
evaluate(value: Record<string, any>): Promise<PolicyEvaluationResult>;
|
|
339
|
-
}
|
|
340
|
-
//#endregion
|
|
341
337
|
//#region src/permission/realm-scope/constants.d.ts
|
|
342
338
|
/**
|
|
343
339
|
* Actor-relative realm reach of a permission grant.
|
|
@@ -346,7 +342,7 @@ declare class PermissionBindingPolicyEvaluator implements IPolicyEvaluator {
|
|
|
346
342
|
* A missing/unknown column coerces to `own` (fail-closed); `none` is only ever an
|
|
347
343
|
* explicit value (the grant reaches no realm at all).
|
|
348
344
|
*/
|
|
349
|
-
declare enum RealmScope {
|
|
345
|
+
export declare enum RealmScope {
|
|
350
346
|
/** No reach — the grant matches no resource realm. */
|
|
351
347
|
NONE = "none",
|
|
352
348
|
/** Own realm only — resource realm must equal the actor's realm. */
|
|
@@ -357,33 +353,81 @@ declare enum RealmScope {
|
|
|
357
353
|
ANY = "any"
|
|
358
354
|
}
|
|
359
355
|
/** Numeric restrictiveness order — internal to the fold/compare helpers. */
|
|
360
|
-
declare const REALM_SCOPE_ORDER: Record<`${RealmScope}`, number>;
|
|
356
|
+
export declare const REALM_SCOPE_ORDER: Record<`${RealmScope}`, number>;
|
|
361
357
|
//#endregion
|
|
362
358
|
//#region src/permission/realm-scope/helpers.d.ts
|
|
363
359
|
/**
|
|
364
360
|
* Coerce an arbitrary value to a RealmScope, defaulting to `own` for missing /
|
|
365
361
|
* null / unknown input (fail-closed). `none` is honoured only when explicit.
|
|
366
362
|
*/
|
|
367
|
-
declare function normalizeRealmScope(value?: `${RealmScope}` | null): `${RealmScope}`;
|
|
363
|
+
export declare function normalizeRealmScope(value?: `${RealmScope}` | null): `${RealmScope}`;
|
|
368
364
|
/**
|
|
369
365
|
* Numeric comparison of two realm scopes by restrictiveness.
|
|
370
366
|
* Negative when `a` is more restrictive than `b`, positive when less.
|
|
371
367
|
*/
|
|
372
|
-
declare function compareRealmScope(a?: `${RealmScope}` | null, b?: `${RealmScope}` | null): number;
|
|
368
|
+
export declare function compareRealmScope(a?: `${RealmScope}` | null, b?: `${RealmScope}` | null): number;
|
|
373
369
|
/** Fold scopes to the MOST permissive (ordered max). Empty folds to `own`. */
|
|
374
|
-
declare function maxRealmScope(values: Array<`${RealmScope}` | null | undefined>): `${RealmScope}`;
|
|
370
|
+
export declare function maxRealmScope(values: Array<`${RealmScope}` | null | undefined>): `${RealmScope}`;
|
|
375
371
|
/** Fold scopes to the MORE restrictive (ordered min) — used to CAP a grant. Empty folds to `own`. */
|
|
376
|
-
declare function minRealmScope(values: Array<`${RealmScope}` | null | undefined>): `${RealmScope}`;
|
|
372
|
+
export declare function minRealmScope(values: Array<`${RealmScope}` | null | undefined>): `${RealmScope}`;
|
|
377
373
|
/**
|
|
378
374
|
* Whether `scope` reaches the resource. The resource realm may be presented as a single
|
|
379
375
|
* id, `null` (global), or an array of realm ids — the array form (a resource that spans
|
|
380
376
|
* multiple realms) requires the scope to reach EVERY listed realm (unanimous, fail-closed),
|
|
381
377
|
* so any app/entity can express its realm via one or many keys under the canonical contract.
|
|
382
378
|
*/
|
|
383
|
-
declare function realmScopeMatches(scope: `${RealmScope}` | null | undefined, resourceRealmId: string | string[] | null | undefined, identityRealmId: string | null | undefined, identityRealmName?: string | null): boolean;
|
|
379
|
+
export declare function realmScopeMatches(scope: `${RealmScope}` | null | undefined, resourceRealmId: string | string[] | null | undefined, identityRealmId: string | null | undefined, identityRealmName?: string | null): boolean;
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/permission/types.d.ts
|
|
382
|
+
export type BasePermission = {
|
|
383
|
+
name: string;
|
|
384
|
+
clientId?: string | null;
|
|
385
|
+
realmId?: string | null;
|
|
386
|
+
decisionStrategy?: `${DecisionStrategy}` | null;
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* A raw permission grant: one permission with its policies and realm reach, as loaded from a
|
|
390
|
+
* role/identity junction. `aggregatePermissionPolicyBindings` groups these per permission into
|
|
391
|
+
* a `PermissionPolicyBindingAggregated` (the lossless disjunction of grants).
|
|
392
|
+
*/
|
|
393
|
+
export type PermissionPolicyBinding = {
|
|
394
|
+
permission: BasePermission;
|
|
395
|
+
policies?: BasePolicy[];
|
|
396
|
+
/**
|
|
397
|
+
* Relative realm reach of this grant (none/own/ownOrNull/any). Absent coerces to the
|
|
398
|
+
* most restrictive `own` (fail-closed). NOT part of the binding identity key
|
|
399
|
+
* (see isPermissionPolicyBindingEqual).
|
|
400
|
+
*/
|
|
401
|
+
realmScope?: `${RealmScope}`;
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* One disjunction term of an aggregated binding: a single grant's realm reach paired with its
|
|
405
|
+
* own (single) policy. A disjunction-aware consumer ORs `realmScopeMatches(realmScope) ∧ policy`
|
|
406
|
+
* across the grants of a permission.
|
|
407
|
+
*/
|
|
408
|
+
export type PermissionGrant = {
|
|
409
|
+
/** Relative realm reach (none/own/ownOrNull/any), normalized — fail-closed default `own`. */
|
|
410
|
+
realmScope: `${RealmScope}`;
|
|
411
|
+
/**
|
|
412
|
+
* The grant's policy: the raw junction policy (its `id` preserved, for propagation) for a
|
|
413
|
+
* single-policy grant, a composite for a multi-policy (Layer-1) binding, or `undefined`
|
|
414
|
+
* when the grant carries no restriction.
|
|
415
|
+
*/
|
|
416
|
+
policy?: BasePolicy;
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* A permission together with the actor's disjunction of grants for it. Output of
|
|
420
|
+
* `aggregatePermissionPolicyBindings` — the honest, lossless replacement for the collapsed
|
|
421
|
+
* `PermissionPolicyBinding` (no top-level realmScope/policies; the access decision is the
|
|
422
|
+
* OR over `grants`).
|
|
423
|
+
*/
|
|
424
|
+
export type PermissionPolicyBindingAggregated = {
|
|
425
|
+
permission: BasePermission;
|
|
426
|
+
grants: PermissionGrant[];
|
|
427
|
+
};
|
|
384
428
|
//#endregion
|
|
385
429
|
//#region src/policy/built-in/realm-match/types.d.ts
|
|
386
|
-
interface RealmMatchPolicy extends BasePolicy {
|
|
430
|
+
export interface RealmMatchPolicy extends BasePolicy {
|
|
387
431
|
/**
|
|
388
432
|
* Determines how realm-id/name matches are handled.
|
|
389
433
|
*/
|
|
@@ -412,12 +456,12 @@ interface RealmMatchPolicy extends BasePolicy {
|
|
|
412
456
|
}
|
|
413
457
|
//#endregion
|
|
414
458
|
//#region src/policy/built-in/realm-match/validator.d.ts
|
|
415
|
-
declare class RealmMatchPolicyValidator extends Container<RealmMatchPolicy> {
|
|
459
|
+
export declare class RealmMatchPolicyValidator extends Container<RealmMatchPolicy> {
|
|
416
460
|
initialize(): void;
|
|
417
461
|
}
|
|
418
462
|
//#endregion
|
|
419
463
|
//#region src/policy/built-in/realm-match/evaluator.d.ts
|
|
420
|
-
declare class RealmMatchPolicyEvaluator implements IPolicyEvaluator {
|
|
464
|
+
export declare class RealmMatchPolicyEvaluator implements IPolicyEvaluator {
|
|
421
465
|
protected validator: RealmMatchPolicyValidator;
|
|
422
466
|
protected identityEvaluator: IdentityPolicyEvaluator;
|
|
423
467
|
protected attributesEvaluator: AttributesPolicyEvaluator;
|
|
@@ -438,8 +482,39 @@ declare class RealmMatchPolicyEvaluator implements IPolicyEvaluator {
|
|
|
438
482
|
evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult>;
|
|
439
483
|
}
|
|
440
484
|
//#endregion
|
|
485
|
+
//#region src/policy/built-in/permission-binding/types.d.ts
|
|
486
|
+
export interface PermissionBindingPolicy extends BasePolicy {}
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region src/policy/built-in/permission-binding/validator.d.ts
|
|
489
|
+
export declare class PermissionBindingPolicyValidator extends Container<PermissionBindingPolicy> {
|
|
490
|
+
initialize(): void;
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/policy/built-in/permission-binding/identity-evaluator.d.ts
|
|
494
|
+
type IdentityPermissionProvider = {
|
|
495
|
+
getFor(identity: IdentityPolicyData): Promise<PermissionPolicyBinding[]>;
|
|
496
|
+
};
|
|
497
|
+
export declare class IdentityPermissionBindingPolicyEvaluator implements IPolicyEvaluator {
|
|
498
|
+
protected validator: PermissionBindingPolicyValidator;
|
|
499
|
+
protected identityEvaluator: IdentityPolicyEvaluator;
|
|
500
|
+
protected realmMatchEvaluator: RealmMatchPolicyEvaluator;
|
|
501
|
+
protected identityPermissionProvider: IdentityPermissionProvider;
|
|
502
|
+
constructor(identityPermissionProvider: IdentityPermissionProvider);
|
|
503
|
+
requires(): string[];
|
|
504
|
+
accessData(ctx: PolicyEvaluationContext): Promise<PermissionPolicyBindingAggregated | null>;
|
|
505
|
+
evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult>;
|
|
506
|
+
}
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/policy/built-in/permission-binding/module.d.ts
|
|
509
|
+
export declare class PermissionBindingPolicyEvaluator implements IPolicyEvaluator {
|
|
510
|
+
protected validator: PermissionBindingPolicyValidator;
|
|
511
|
+
constructor();
|
|
512
|
+
requires(): string[];
|
|
513
|
+
evaluate(value: Record<string, any>): Promise<PolicyEvaluationResult>;
|
|
514
|
+
}
|
|
515
|
+
//#endregion
|
|
441
516
|
//#region src/policy/built-in/time/constants.d.ts
|
|
442
|
-
declare enum TimePolicyInterval {
|
|
517
|
+
export declare enum TimePolicyInterval {
|
|
443
518
|
DAILY = "daily",
|
|
444
519
|
WEEKLY = "weekly",
|
|
445
520
|
MONTHLY = "monthly",
|
|
@@ -447,7 +522,7 @@ declare enum TimePolicyInterval {
|
|
|
447
522
|
}
|
|
448
523
|
//#endregion
|
|
449
524
|
//#region src/policy/built-in/time/types.d.ts
|
|
450
|
-
interface TimePolicy extends BasePolicy {
|
|
525
|
+
export interface TimePolicy extends BasePolicy {
|
|
451
526
|
/**
|
|
452
527
|
* Format: HH:MM
|
|
453
528
|
*/
|
|
@@ -475,24 +550,24 @@ interface TimePolicy extends BasePolicy {
|
|
|
475
550
|
}
|
|
476
551
|
//#endregion
|
|
477
552
|
//#region src/policy/built-in/time/validator.d.ts
|
|
478
|
-
declare class TimePolicyValidator extends Container<TimePolicy> {
|
|
553
|
+
export declare class TimePolicyValidator extends Container<TimePolicy> {
|
|
479
554
|
initialize(): void;
|
|
480
555
|
}
|
|
481
556
|
//#endregion
|
|
482
557
|
//#region src/policy/built-in/time/evaluator.d.ts
|
|
483
|
-
declare class TimePolicyEvaluator implements IPolicyEvaluator {
|
|
558
|
+
export declare class TimePolicyEvaluator implements IPolicyEvaluator {
|
|
484
559
|
protected validator: TimePolicyValidator;
|
|
485
560
|
constructor();
|
|
486
561
|
evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult>;
|
|
487
562
|
}
|
|
488
563
|
//#endregion
|
|
489
564
|
//#region src/policy/built-in/time/helpers.d.ts
|
|
490
|
-
declare function isIntervalForDayOfWeek(interval: string): interval is TimePolicyInterval.WEEKLY | TimePolicyInterval.MONTHLY | TimePolicyInterval.YEARLY;
|
|
491
|
-
declare function isIntervalForDayOfMonth(interval: string): interval is TimePolicyInterval.MONTHLY | TimePolicyInterval.YEARLY;
|
|
492
|
-
declare function isIntervalForDayOfYear(interval: string): interval is TimePolicyInterval.YEARLY;
|
|
565
|
+
export declare function isIntervalForDayOfWeek(interval: string): interval is TimePolicyInterval.WEEKLY | TimePolicyInterval.MONTHLY | TimePolicyInterval.YEARLY;
|
|
566
|
+
export declare function isIntervalForDayOfMonth(interval: string): interval is TimePolicyInterval.MONTHLY | TimePolicyInterval.YEARLY;
|
|
567
|
+
export declare function isIntervalForDayOfYear(interval: string): interval is TimePolicyInterval.YEARLY;
|
|
493
568
|
//#endregion
|
|
494
569
|
//#region src/policy/built-in/constants.d.ts
|
|
495
|
-
declare enum BuiltInPolicyType {
|
|
570
|
+
export declare enum BuiltInPolicyType {
|
|
496
571
|
/**
|
|
497
572
|
* Bundles different policies.
|
|
498
573
|
*/
|
|
@@ -526,7 +601,7 @@ declare enum BuiltInPolicyType {
|
|
|
526
601
|
*/
|
|
527
602
|
PERMISSION_BINDING = "permissionBinding"
|
|
528
603
|
}
|
|
529
|
-
declare const SystemPolicyName: {
|
|
604
|
+
export declare const SystemPolicyName: {
|
|
530
605
|
readonly DEFAULT: "system.default";
|
|
531
606
|
readonly IDENTITY: "system.identity";
|
|
532
607
|
readonly PERMISSION_BINDING: "system.permission-binding";
|
|
@@ -546,16 +621,16 @@ type BuiltInPolicyTypeMapRaw<T extends Record<string, any> = Record<string, any>
|
|
|
546
621
|
[BuiltInPolicyType.PERMISSION_BINDING]: PermissionBindingPolicy;
|
|
547
622
|
[BuiltInPolicyType.REALM_MATCH]: RealmMatchPolicy;
|
|
548
623
|
};
|
|
549
|
-
type BuiltInPolicyTypeMap<T extends Record<string, any> = Record<string, any>> = { [K in keyof BuiltInPolicyTypeMapRaw<T> as `${K}`]: BuiltInPolicyTypeMapRaw<T>[K]; };
|
|
550
|
-
type BuiltInPolicies<T extends Record<string, any> = Record<string, any>> = { [K in keyof BuiltInPolicyTypeMap<T>]: BuiltInPolicyTypeMap<T>[K] & {
|
|
624
|
+
export type BuiltInPolicyTypeMap<T extends Record<string, any> = Record<string, any>> = { [K in keyof BuiltInPolicyTypeMapRaw<T> as `${K}`]: BuiltInPolicyTypeMapRaw<T>[K]; };
|
|
625
|
+
export type BuiltInPolicies<T extends Record<string, any> = Record<string, any>> = { [K in keyof BuiltInPolicyTypeMap<T>]: BuiltInPolicyTypeMap<T>[K] & {
|
|
551
626
|
type: K;
|
|
552
627
|
}; }[keyof BuiltInPolicyTypeMap];
|
|
553
628
|
//#endregion
|
|
554
629
|
//#region src/policy/built-in/define.d.ts
|
|
555
|
-
declare function definePolicyWithType<K extends keyof BuiltInPolicyTypeMap, D extends BuiltInPolicyTypeMap<any>[K]>(type: K, data: D): PolicyWithType<D, K>;
|
|
630
|
+
export declare function definePolicyWithType<K extends keyof BuiltInPolicyTypeMap, D extends BuiltInPolicyTypeMap<any>[K]>(type: K, data: D): PolicyWithType<D, K>;
|
|
556
631
|
//#endregion
|
|
557
632
|
//#region src/policy/constants.d.ts
|
|
558
|
-
declare const PolicyDefaultEvaluators: {
|
|
633
|
+
export declare const PolicyDefaultEvaluators: {
|
|
559
634
|
readonly composite: CompositePolicyEvaluator;
|
|
560
635
|
readonly attributes: AttributesPolicyEvaluator<Record<string, any>>;
|
|
561
636
|
readonly attributeNames: AttributeNamesPolicyEvaluator;
|
|
@@ -575,7 +650,7 @@ declare const PolicyDefaultEvaluators: {
|
|
|
575
650
|
* a third-party evaluator may supply its own key without any change to this published type
|
|
576
651
|
* (the `access` evaluator set is deliberately extensible).
|
|
577
652
|
*/
|
|
578
|
-
interface PolicyInput {
|
|
653
|
+
export interface PolicyInput {
|
|
579
654
|
[BuiltInPolicyType.IDENTITY]?: IdentityPolicyData;
|
|
580
655
|
[BuiltInPolicyType.ATTRIBUTES]?: Record<string, any>;
|
|
581
656
|
[BuiltInPolicyType.REALM_MATCH]?: string | string[] | null;
|
|
@@ -588,11 +663,11 @@ interface PolicyInput {
|
|
|
588
663
|
* Prefer this over `new PolicyData({ ... })` at construction sites so the key vocabulary and
|
|
589
664
|
* per-key value types live in one place.
|
|
590
665
|
*/
|
|
591
|
-
declare function definePolicyData(input?: PolicyInput): PolicyData;
|
|
666
|
+
export declare function definePolicyData(input?: PolicyInput): PolicyData;
|
|
592
667
|
//#endregion
|
|
593
668
|
//#region src/permission/error/module.d.ts
|
|
594
|
-
declare const PERMISSION_ERROR_INSTANCE: unique symbol;
|
|
595
|
-
declare class PermissionError extends AuthupError {
|
|
669
|
+
export declare const PERMISSION_ERROR_INSTANCE: unique symbol;
|
|
670
|
+
export declare class PermissionError extends AuthupError {
|
|
596
671
|
constructor(options?: AuthupErrorOptions);
|
|
597
672
|
static notFound(name: string): PermissionError;
|
|
598
673
|
static denied(name: string): PermissionError;
|
|
@@ -601,55 +676,7 @@ declare class PermissionError extends AuthupError {
|
|
|
601
676
|
}
|
|
602
677
|
//#endregion
|
|
603
678
|
//#region src/permission/error/check.d.ts
|
|
604
|
-
declare function isPermissionError(input: unknown): input is PermissionError;
|
|
605
|
-
//#endregion
|
|
606
|
-
//#region src/permission/types.d.ts
|
|
607
|
-
type BasePermission = {
|
|
608
|
-
name: string;
|
|
609
|
-
clientId?: string | null;
|
|
610
|
-
realmId?: string | null;
|
|
611
|
-
decisionStrategy?: `${DecisionStrategy}` | null;
|
|
612
|
-
};
|
|
613
|
-
/**
|
|
614
|
-
* A raw permission grant: one permission with its policies and realm reach, as loaded from a
|
|
615
|
-
* role/identity junction. `aggregatePermissionPolicyBindings` groups these per permission into
|
|
616
|
-
* a `PermissionPolicyBindingAggregated` (the lossless disjunction of grants).
|
|
617
|
-
*/
|
|
618
|
-
type PermissionPolicyBinding = {
|
|
619
|
-
permission: BasePermission;
|
|
620
|
-
policies?: BasePolicy[];
|
|
621
|
-
/**
|
|
622
|
-
* Relative realm reach of this grant (none/own/ownOrNull/any). Absent coerces to the
|
|
623
|
-
* most restrictive `own` (fail-closed). NOT part of the binding identity key
|
|
624
|
-
* (see isPermissionPolicyBindingEqual).
|
|
625
|
-
*/
|
|
626
|
-
realmScope?: `${RealmScope}`;
|
|
627
|
-
};
|
|
628
|
-
/**
|
|
629
|
-
* One disjunction term of an aggregated binding: a single grant's realm reach paired with its
|
|
630
|
-
* own (single) policy. A disjunction-aware consumer ORs `realmScopeMatches(realmScope) ∧ policy`
|
|
631
|
-
* across the grants of a permission.
|
|
632
|
-
*/
|
|
633
|
-
type PermissionGrant = {
|
|
634
|
-
/** Relative realm reach (none/own/ownOrNull/any), normalized — fail-closed default `own`. */
|
|
635
|
-
realmScope: `${RealmScope}`;
|
|
636
|
-
/**
|
|
637
|
-
* The grant's policy: the raw junction policy (its `id` preserved, for propagation) for a
|
|
638
|
-
* single-policy grant, a composite for a multi-policy (Layer-1) binding, or `undefined`
|
|
639
|
-
* when the grant carries no restriction.
|
|
640
|
-
*/
|
|
641
|
-
policy?: BasePolicy;
|
|
642
|
-
};
|
|
643
|
-
/**
|
|
644
|
-
* A permission together with the actor's disjunction of grants for it. Output of
|
|
645
|
-
* `aggregatePermissionPolicyBindings` — the honest, lossless replacement for the collapsed
|
|
646
|
-
* `PermissionPolicyBinding` (no top-level realmScope/policies; the access decision is the
|
|
647
|
-
* OR over `grants`).
|
|
648
|
-
*/
|
|
649
|
-
type PermissionPolicyBindingAggregated = {
|
|
650
|
-
permission: BasePermission;
|
|
651
|
-
grants: PermissionGrant[];
|
|
652
|
-
};
|
|
679
|
+
export declare function isPermissionError(input: unknown): input is PermissionError;
|
|
653
680
|
//#endregion
|
|
654
681
|
//#region src/permission/helpers/aggregate.d.ts
|
|
655
682
|
/**
|
|
@@ -659,10 +686,10 @@ type PermissionPolicyBindingAggregated = {
|
|
|
659
686
|
* grant disjunction directly, so each grant's realm reach stays paired with the policy that
|
|
660
687
|
* gates it.
|
|
661
688
|
*/
|
|
662
|
-
declare function aggregatePermissionPolicyBindings(input: PermissionPolicyBinding[]): PermissionPolicyBindingAggregated[];
|
|
689
|
+
export declare function aggregatePermissionPolicyBindings(input: PermissionPolicyBinding[]): PermissionPolicyBindingAggregated[];
|
|
663
690
|
//#endregion
|
|
664
691
|
//#region src/permission/helpers/equal.d.ts
|
|
665
|
-
declare function isPermissionPolicyBindingEqual(a: {
|
|
692
|
+
export declare function isPermissionPolicyBindingEqual(a: {
|
|
666
693
|
permission: BasePermission;
|
|
667
694
|
}, b: {
|
|
668
695
|
permission: BasePermission;
|
|
@@ -675,23 +702,23 @@ declare function isPermissionPolicyBindingEqual(a: {
|
|
|
675
702
|
* (see `policyDominates`). Used per grant by `isSuperset` over the aggregated disjunction —
|
|
676
703
|
* every child grant must be dominated by SOME parent grant.
|
|
677
704
|
*/
|
|
678
|
-
declare function grantDominates(parent: PermissionGrant, child: PermissionGrant): boolean;
|
|
705
|
+
export declare function grantDominates(parent: PermissionGrant, child: PermissionGrant): boolean;
|
|
679
706
|
//#endregion
|
|
680
707
|
//#region src/permission/helpers/key.d.ts
|
|
681
|
-
declare function buildPermissionKey(input: BasePermission): string;
|
|
708
|
+
export declare function buildPermissionKey(input: BasePermission): string;
|
|
682
709
|
//#endregion
|
|
683
710
|
//#region src/permission/provider/types.d.ts
|
|
684
|
-
type PermissionGetOptions = {
|
|
711
|
+
export type PermissionGetOptions = {
|
|
685
712
|
name: string;
|
|
686
713
|
clientId?: string | null;
|
|
687
714
|
realmId?: string | null;
|
|
688
715
|
};
|
|
689
|
-
interface IPermissionProvider {
|
|
716
|
+
export interface IPermissionProvider {
|
|
690
717
|
findOne(criteria: PermissionGetOptions): Promise<PermissionPolicyBindingAggregated | null>;
|
|
691
718
|
}
|
|
692
719
|
//#endregion
|
|
693
720
|
//#region src/permission/provider/memory.d.ts
|
|
694
|
-
declare class PermissionMemoryProvider implements IPermissionProvider {
|
|
721
|
+
export declare class PermissionMemoryProvider implements IPermissionProvider {
|
|
695
722
|
protected items: Record<string, PermissionPolicyBindingAggregated>;
|
|
696
723
|
constructor(items?: PermissionPolicyBinding[]);
|
|
697
724
|
findOne(options: PermissionGetOptions): Promise<PermissionPolicyBindingAggregated | null>;
|
|
@@ -699,20 +726,20 @@ declare class PermissionMemoryProvider implements IPermissionProvider {
|
|
|
699
726
|
}
|
|
700
727
|
//#endregion
|
|
701
728
|
//#region src/permission/evaluator/types.d.ts
|
|
702
|
-
interface IPermissionEvaluator {
|
|
729
|
+
export interface IPermissionEvaluator {
|
|
703
730
|
evaluate(ctx: PermissionEvaluationContext): Promise<void>;
|
|
704
731
|
evaluateOneOf(ctx: PermissionEvaluationContext): Promise<void>;
|
|
705
732
|
preEvaluate(ctx: PermissionEvaluationContext): Promise<void>;
|
|
706
733
|
preEvaluateOneOf(ctx: PermissionEvaluationContext): Promise<void>;
|
|
707
734
|
compile(ctx: PermissionCompileContext): Promise<PermissionCompileResult>;
|
|
708
735
|
}
|
|
709
|
-
type PermissionEvaluatorOptions = {
|
|
736
|
+
export type PermissionEvaluatorOptions = {
|
|
710
737
|
provider: IPermissionProvider;
|
|
711
738
|
policyEngine?: IPolicyEngine;
|
|
712
739
|
realmId?: string | null;
|
|
713
740
|
clientId?: string | null;
|
|
714
741
|
};
|
|
715
|
-
type PermissionEvaluationOptions = {
|
|
742
|
+
export type PermissionEvaluationOptions = {
|
|
716
743
|
decisionStrategy?: `${DecisionStrategy}`;
|
|
717
744
|
policiesIncluded?: string[];
|
|
718
745
|
policiesExcluded?: string[];
|
|
@@ -727,14 +754,14 @@ type PermissionEvaluationOptions = {
|
|
|
727
754
|
*/
|
|
728
755
|
pendingPolicies?: 'deny' | 'permit';
|
|
729
756
|
};
|
|
730
|
-
type PermissionEvaluationContext = {
|
|
757
|
+
export type PermissionEvaluationContext = {
|
|
731
758
|
name: string | string[];
|
|
732
759
|
realmId?: string | null;
|
|
733
760
|
clientId?: string | null;
|
|
734
761
|
data?: PolicyData;
|
|
735
762
|
options?: PermissionEvaluationOptions;
|
|
736
763
|
};
|
|
737
|
-
type PermissionCompileContext = {
|
|
764
|
+
export type PermissionCompileContext = {
|
|
738
765
|
/**
|
|
739
766
|
* Permission name(s). Several names compile as a disjunction — the row is
|
|
740
767
|
* readable when ANY of them passes (`evaluateOneOf` semantics).
|
|
@@ -748,6 +775,14 @@ type PermissionCompileContext = {
|
|
|
748
775
|
* compiled condition ranges over.
|
|
749
776
|
*/
|
|
750
777
|
data?: PolicyData;
|
|
778
|
+
/**
|
|
779
|
+
* Row column the realm reach is lowered onto, when the rows this compilation
|
|
780
|
+
* ranges over carry their realm under another name — a junction's owner-realm
|
|
781
|
+
* key (`roleRealmId`, `clientRealmId`, …). Default `realmId`. Affects the
|
|
782
|
+
* `conditional` condition only; the per-row `post` fallback still reads the
|
|
783
|
+
* realm from the `realmMatch` data key its caller supplies.
|
|
784
|
+
*/
|
|
785
|
+
realmAttributeName?: string;
|
|
751
786
|
};
|
|
752
787
|
/**
|
|
753
788
|
* Outcome of compiling a permission's policy trees against the knowns bag
|
|
@@ -760,7 +795,7 @@ type PermissionCompileContext = {
|
|
|
760
795
|
* - `post` — some pending policy is not expressible as a condition; fall back to
|
|
761
796
|
* loading rows and evaluating per row (always sound).
|
|
762
797
|
*/
|
|
763
|
-
type PermissionCompileResult = {
|
|
798
|
+
export type PermissionCompileResult = {
|
|
764
799
|
verdict: 'allow';
|
|
765
800
|
} | {
|
|
766
801
|
verdict: 'deny';
|
|
@@ -772,7 +807,7 @@ type PermissionCompileResult = {
|
|
|
772
807
|
};
|
|
773
808
|
//#endregion
|
|
774
809
|
//#region src/permission/evaluator/module.d.ts
|
|
775
|
-
declare class PermissionEvaluator implements IPermissionEvaluator {
|
|
810
|
+
export declare class PermissionEvaluator implements IPermissionEvaluator {
|
|
776
811
|
protected provider: IPermissionProvider;
|
|
777
812
|
protected policyEngine: IPolicyEngine;
|
|
778
813
|
protected clientId?: string | null;
|
|
@@ -799,5 +834,381 @@ declare class PermissionEvaluator implements IPermissionEvaluator {
|
|
|
799
834
|
compile(ctx: PermissionCompileContext): Promise<PermissionCompileResult>;
|
|
800
835
|
}
|
|
801
836
|
//#endregion
|
|
802
|
-
|
|
837
|
+
//#region src/permission/authorization/error.d.ts
|
|
838
|
+
export declare const AUTHORIZATION_CATALOG_STALE_ERROR_INSTANCE: unique symbol;
|
|
839
|
+
/**
|
|
840
|
+
* A grant references a definition or a policy the supplied catalog does not
|
|
841
|
+
* carry: the caller's cached catalog predates the definition or the junction
|
|
842
|
+
* row and must be refetched. A definition the catalog carries with
|
|
843
|
+
* `policies: null`, and one whose tree this copy cannot project, are not
|
|
844
|
+
* stale but unevaluable, and a grant of either is dropped.
|
|
845
|
+
*
|
|
846
|
+
* Recognize it with `isAuthorizationCatalogStaleError`, never `instanceof`:
|
|
847
|
+
* this package is a plain caret dependency of several workspaces, so a
|
|
848
|
+
* consumer tree may resolve two copies of it and turn the one recoverable
|
|
849
|
+
* state into an unrecoverable one.
|
|
850
|
+
*/
|
|
851
|
+
export declare class AuthorizationCatalogStaleError extends AuthupError {
|
|
852
|
+
constructor(message: string);
|
|
853
|
+
}
|
|
854
|
+
//#endregion
|
|
855
|
+
//#region src/permission/authorization/check.d.ts
|
|
856
|
+
/**
|
|
857
|
+
* Marker-only: the error carries no code of its own, and it never crosses a
|
|
858
|
+
* wire boundary, so there is no shape to fall back to.
|
|
859
|
+
*/
|
|
860
|
+
export declare function isAuthorizationCatalogStaleError(input: unknown): input is AuthorizationCatalogStaleError;
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/permission/authorization/types.d.ts
|
|
863
|
+
/**
|
|
864
|
+
* One policy tree node as it travels: the type's configuration keys (the output
|
|
865
|
+
* of that type's validator), `invert`, and for a composite its children inline.
|
|
866
|
+
*/
|
|
867
|
+
export type AuthorizationPolicy = {
|
|
868
|
+
type: string;
|
|
869
|
+
invert?: boolean | null;
|
|
870
|
+
children?: AuthorizationPolicy[];
|
|
871
|
+
[key: string]: unknown;
|
|
872
|
+
};
|
|
873
|
+
export type AuthorizationDefinition = {
|
|
874
|
+
name: string;
|
|
875
|
+
realm_id: string | null;
|
|
876
|
+
client_id: string | null;
|
|
877
|
+
decision_strategy: `${DecisionStrategy}` | null;
|
|
878
|
+
/**
|
|
879
|
+
* The definition layer: the ids of the policy trees bound to the permission
|
|
880
|
+
* definition (`auth_permission_policies`). Empty means unrestricted at this
|
|
881
|
+
* layer. `null` means the server could not project one of those trees onto
|
|
882
|
+
* the wire (a policy type the catalog does not carry, or a configuration
|
|
883
|
+
* its validator refuses): the definition exists, a consumer cannot evaluate
|
|
884
|
+
* it and denies it, dropping every grant of it, until the policy is fixed.
|
|
885
|
+
*/
|
|
886
|
+
policies: string[] | null;
|
|
887
|
+
};
|
|
888
|
+
/**
|
|
889
|
+
* Identity-free and cacheable: every permission definition with its policy trees.
|
|
890
|
+
*/
|
|
891
|
+
export type AuthorizationCatalog = {
|
|
892
|
+
/**
|
|
893
|
+
* Every policy tree a definition or a grant can name, keyed by the tree's
|
|
894
|
+
* own id and present exactly once however many of them reference it.
|
|
895
|
+
*/
|
|
896
|
+
policies: Record<string, AuthorizationPolicy>;
|
|
897
|
+
permissions: AuthorizationDefinition[];
|
|
898
|
+
};
|
|
899
|
+
/**
|
|
900
|
+
* One raw grant of an identity as the introspection endpoints report it: the
|
|
901
|
+
* permission namespace it names, its realm reach and the junction policy ids.
|
|
902
|
+
* Structurally the extended `OAuth2TokenPermission` of `@authup/specs` (this
|
|
903
|
+
* package does not depend on specs).
|
|
904
|
+
*/
|
|
905
|
+
export type AuthorizationGrant = {
|
|
906
|
+
name: string;
|
|
907
|
+
realm_id?: string | null;
|
|
908
|
+
client_id?: string | null;
|
|
909
|
+
/**
|
|
910
|
+
* Absent or null coerces to `own`, fail-closed.
|
|
911
|
+
*/
|
|
912
|
+
realm_scope?: `${RealmScope}` | null;
|
|
913
|
+
/**
|
|
914
|
+
* Absent or null means no junction policy.
|
|
915
|
+
*/
|
|
916
|
+
policies?: string[] | null;
|
|
917
|
+
};
|
|
918
|
+
export type AuthorizationEvaluatorInput = {
|
|
919
|
+
/**
|
|
920
|
+
* An `AuthorizationCatalog`, validated by the schema.
|
|
921
|
+
*/
|
|
922
|
+
catalog: unknown;
|
|
923
|
+
/**
|
|
924
|
+
* `AuthorizationGrant[]`, validated by the schema. Defaults to none, and
|
|
925
|
+
* may only be supplied together with the identity holding them.
|
|
926
|
+
*/
|
|
927
|
+
grants?: unknown;
|
|
928
|
+
/**
|
|
929
|
+
* The identity the grants belong to. Omitted for an anonymous caller:
|
|
930
|
+
* no identity data is injected and no grant is bound, so only a
|
|
931
|
+
* definition whose policies need no identity can pass.
|
|
932
|
+
*/
|
|
933
|
+
identity?: IdentityPolicyData;
|
|
934
|
+
};
|
|
935
|
+
/**
|
|
936
|
+
* Which resource realms a batch check evaluates against.
|
|
937
|
+
*
|
|
938
|
+
* A string is SYMBOLIC and resolved server-side against the caller's own
|
|
939
|
+
* identity: `own` is the realm the identity belongs to, `ownOrNull` is that
|
|
940
|
+
* realm plus `null`, the global rows every realm shares. An array is taken
|
|
941
|
+
* VERBATIM: the server resolves no realm key, so it discloses no realm's
|
|
942
|
+
* existence and the caller matches the answer against its own input with no
|
|
943
|
+
* resolution step of its own.
|
|
944
|
+
*
|
|
945
|
+
* String versus array is what discriminates the two forms, so `own` stays
|
|
946
|
+
* unambiguous even though it is a legal realm name.
|
|
947
|
+
*/
|
|
948
|
+
export type AuthorizationCheckRealms = `${RealmScope.OWN}` | `${RealmScope.OWN_OR_NULL}` | Array<string | null>;
|
|
949
|
+
/**
|
|
950
|
+
* One permission the identity may attempt, and the requested realms it may
|
|
951
|
+
* attempt it in. Never empty: a permission reaching no requested realm is
|
|
952
|
+
* absent from the answer entirely, so absent means denied.
|
|
953
|
+
*/
|
|
954
|
+
export type AuthorizationCheckPermission = {
|
|
955
|
+
name: string;
|
|
956
|
+
realms: Array<string | null>;
|
|
957
|
+
};
|
|
958
|
+
/**
|
|
959
|
+
* The answer `POST /authorization/check` serves: the caller's own verdicts,
|
|
960
|
+
* paired with the realms they hold in.
|
|
961
|
+
*
|
|
962
|
+
* It is an upper bound on what may be ATTEMPTED rather than an entitlement,
|
|
963
|
+
* the same posture the catalog and `GET /schemas` take: it is a pre-gate, so a
|
|
964
|
+
* grant whose junction policy needs a resource row passes here and is still
|
|
965
|
+
* decided per row on the server, which stays the enforcement point.
|
|
966
|
+
*/
|
|
967
|
+
export type AuthorizationCheckPermissions = AuthorizationCheckPermission[];
|
|
968
|
+
export type AuthorizationCheckEvaluatorInput = {
|
|
969
|
+
/**
|
|
970
|
+
* An `AuthorizationCheckPermissions`, validated by the schema.
|
|
971
|
+
*/
|
|
972
|
+
permissions: unknown;
|
|
973
|
+
/**
|
|
974
|
+
* The identity the verdicts belong to, used to resolve a `realmMatch` of
|
|
975
|
+
* `own` shape: a resource realm equal to this identity's realm id or name
|
|
976
|
+
* is the identity's own realm. Omitted for an anonymous caller, which
|
|
977
|
+
* holds no verdict at all.
|
|
978
|
+
*/
|
|
979
|
+
identity?: IdentityPolicyData;
|
|
980
|
+
};
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/permission/authorization/check-schema.d.ts
|
|
983
|
+
/**
|
|
984
|
+
* The whole input `createAuthorizationCheckEvaluator` takes: the answer
|
|
985
|
+
* `POST /authorization/check` served and the identity it belongs to. Same
|
|
986
|
+
* validup-over-zod shape as the catalog's input, so a consumer can override
|
|
987
|
+
* one member's rules instead of restating the answer.
|
|
988
|
+
*/
|
|
989
|
+
export declare class AuthorizationCheckEvaluatorInputValidator extends Container<AuthorizationCheckEvaluatorInput> {
|
|
990
|
+
initialize(): void;
|
|
991
|
+
}
|
|
992
|
+
export type AuthorizationCheckEvaluatorInputParsed = {
|
|
993
|
+
permissions: AuthorizationCheckPermissions;
|
|
994
|
+
identity: AuthorizationCheckEvaluatorInput['identity'];
|
|
995
|
+
};
|
|
996
|
+
/**
|
|
997
|
+
* Validate the check evaluator's input, plus the one rule a per-key validator
|
|
998
|
+
* cannot express: a permission namespace appears at most once. Two entries for
|
|
999
|
+
* one name would make the answer depend on which the consumer looked up first,
|
|
1000
|
+
* and the server emits one entry per name by construction.
|
|
1001
|
+
*/
|
|
1002
|
+
export declare function parseAuthorizationCheckEvaluatorInput(input: AuthorizationCheckEvaluatorInput): Promise<AuthorizationCheckEvaluatorInputParsed>;
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region src/permission/authorization/constants.d.ts
|
|
1005
|
+
/**
|
|
1006
|
+
* The node a policy tree travels as when the server withholds it, because the
|
|
1007
|
+
* caller's realm reach does not cover the row it was read from.
|
|
1008
|
+
*
|
|
1009
|
+
* It is deliberately a type no consumer can project: `projectAuthorizationPolicy`
|
|
1010
|
+
* refuses it, which is already the state a definition referencing it denies
|
|
1011
|
+
* through and a grant naming it is dropped through, so withholding a body needs
|
|
1012
|
+
* no rule of its own on the consumer side. That is a contract between the two
|
|
1013
|
+
* halves rather than a server detail, which is why it is declared HERE, next to
|
|
1014
|
+
* the projection that has to keep refusing it, and pinned by this package's own
|
|
1015
|
+
* test.
|
|
1016
|
+
*/
|
|
1017
|
+
export declare const AUTHORIZATION_POLICY_WITHHELD_TYPE = "withheld";
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region src/permission/authorization/module.d.ts
|
|
1020
|
+
/**
|
|
1021
|
+
* Build a resource-server (or console) evaluator from the catalog
|
|
1022
|
+
* `GET /authorization` serves, the identity's grants as the introspection
|
|
1023
|
+
* endpoints report them, and the identity itself. Rejects legacy, incomplete
|
|
1024
|
+
* and unsupported input. A grant referencing a definition or a policy the
|
|
1025
|
+
* catalog lacks throws `AuthorizationCatalogStaleError`, the signal to
|
|
1026
|
+
* refetch the catalog: the grants come from a fresh introspection while the
|
|
1027
|
+
* catalog may predate the definition or the junction row. A definition the
|
|
1028
|
+
* server could not project travels with `policies: null` instead of being
|
|
1029
|
+
* left out, so a grant of it is dropped rather than reported stale: the
|
|
1030
|
+
* definition layer cannot be evaluated here, a refetch changes nothing, and
|
|
1031
|
+
* the permission denies until the policy is fixed.
|
|
1032
|
+
*
|
|
1033
|
+
* A tree THIS copy cannot project is the same condition read from the other
|
|
1034
|
+
* side, and it is per tree: a policy type newer than this package (the
|
|
1035
|
+
* built-in type enum is closed while the column is a free string) or a
|
|
1036
|
+
* configuration its validator refuses denies the definitions that reference
|
|
1037
|
+
* it, exactly as `policies: null` does, and drops a grant that names it,
|
|
1038
|
+
* exactly as a binding check does. One such tree never takes the evaluator
|
|
1039
|
+
* down for the permissions that do not use it. A malformed catalog still
|
|
1040
|
+
* throws: a duplicate permission namespace is not a data condition.
|
|
1041
|
+
*
|
|
1042
|
+
* Both the identity and the grants are optional. Without an identity no grant
|
|
1043
|
+
* is bound and any IDENTITY key the caller supplied is REMOVED, so the
|
|
1044
|
+
* binding evaluator answers with missing data exactly as the server does for
|
|
1045
|
+
* an anonymous request, only a definition whose policies need no identity can
|
|
1046
|
+
* pass, and a caller can never inject an identity the document did not prove.
|
|
1047
|
+
* Grants without the identity they belong to are refused.
|
|
1048
|
+
*
|
|
1049
|
+
* The REALM_MATCH data key follows the server's own three-way rule: a
|
|
1050
|
+
* resource that carries a realm passes it (null for a global row, which
|
|
1051
|
+
* `own` denies), a resource with no realm dimension passes nothing and reach
|
|
1052
|
+
* neutral-passes. `preEvaluate` / `preEvaluateOneOf` are the pre-gate and
|
|
1053
|
+
* enforce reach only when that key is present. `compile` returns the
|
|
1054
|
+
* allow/deny/conditional/post contract; a `post` collection query must be
|
|
1055
|
+
* rejected or evaluated over every candidate before paging. The supplied
|
|
1056
|
+
* identity is authoritative; `options.decisionStrategy` is forwarded and the
|
|
1057
|
+
* policy include, exclude and pending options are refused.
|
|
1058
|
+
*/
|
|
1059
|
+
export declare function createAuthorizationEvaluator(input: AuthorizationEvaluatorInput): Promise<IPermissionEvaluator>;
|
|
1060
|
+
/**
|
|
1061
|
+
* An `IPermissionEvaluator` over the answer `POST /authorization/check`
|
|
1062
|
+
* served: the caller's own verdicts, paired with the realms they hold in.
|
|
1063
|
+
*
|
|
1064
|
+
* It is what a PUBLIC client gets where the catalog is out of reach. A public
|
|
1065
|
+
* client holds no secret, so it can obtain no `client_credentials` token and
|
|
1066
|
+
* has no credential of its own for the catalog's gate to be satisfied by;
|
|
1067
|
+
* publishing every policy predicate to it instead would be the wrong trade.
|
|
1068
|
+
* The verdicts are computed by the server from the same grants and the same
|
|
1069
|
+
* evaluators a request runs, so this is authoritative where the name-only
|
|
1070
|
+
* fallback it replaces is merely coarse.
|
|
1071
|
+
*
|
|
1072
|
+
* Two properties follow from the answer being a pre-gate:
|
|
1073
|
+
*
|
|
1074
|
+
* It is an UPPER BOUND, so `evaluate` and `evaluateOneOf` answer exactly what
|
|
1075
|
+
* the pre-gate pair answers. A check that depends on a resource row belongs to
|
|
1076
|
+
* whoever holds the row, and the server decides it there; answering such a
|
|
1077
|
+
* check here would mean inventing a verdict. That is the same bound the
|
|
1078
|
+
* name-only fallback already had, so nothing that gates on it loosens.
|
|
1079
|
+
*
|
|
1080
|
+
* And a resource realm is matched against what the REQUEST asked about: a
|
|
1081
|
+
* `realmMatch` naming a realm the request never carried is in no entry's list
|
|
1082
|
+
* and therefore denies. That is fail-closed by construction rather than by a
|
|
1083
|
+
* rule, and it is why a caller must ask about the realms its UI will ask
|
|
1084
|
+
* about.
|
|
1085
|
+
*/
|
|
1086
|
+
export declare function createAuthorizationCheckEvaluator(input: AuthorizationCheckEvaluatorInput): Promise<IPermissionEvaluator>;
|
|
1087
|
+
//#endregion
|
|
1088
|
+
//#region src/permission/authorization/policy.d.ts
|
|
1089
|
+
/**
|
|
1090
|
+
* The one definition of what a policy looks like on the wire, used by the server
|
|
1091
|
+
* to build a document and by the consumer to validate one. A node is the OUTPUT
|
|
1092
|
+
* of its type's validator (validup strips every unmounted key, so entity columns
|
|
1093
|
+
* such as `id`, `name`, `builtIn` or `createdAt` never travel), plus its type
|
|
1094
|
+
* and, for a composite, its projected children.
|
|
1095
|
+
*
|
|
1096
|
+
* Every refusal is a `ValidupError`, the node's head and the type's own
|
|
1097
|
+
* validator alike, and a child's issues are rebased onto the position it sits
|
|
1098
|
+
* at, so one message names the node in the tree that is wrong.
|
|
1099
|
+
*/
|
|
1100
|
+
export declare function projectAuthorizationPolicy(input: unknown): Promise<AuthorizationPolicy>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Whether a projected tree evaluates the permission binding at any depth. A
|
|
1103
|
+
* grant policy carrying one would re-enter its own permission's grants, so
|
|
1104
|
+
* `createAuthorizationEvaluator` drops the grant that names it and evaluates
|
|
1105
|
+
* the permission from the rest. Its one caller is that consumer: the tree is
|
|
1106
|
+
* legal in a definition, where the binding check is what reach is enforced
|
|
1107
|
+
* by, so the producer carries it and only the grant side is refused.
|
|
1108
|
+
*/
|
|
1109
|
+
export declare function containsBindingCheck(policy: AuthorizationPolicy): boolean;
|
|
1110
|
+
//#endregion
|
|
1111
|
+
//#region src/permission/authorization/schema.d.ts
|
|
1112
|
+
/**
|
|
1113
|
+
* A policy node as it travels. Deliberately LOOSE: every key beyond `type` is
|
|
1114
|
+
* that type's own configuration, and `projectAuthorizationPolicy` is what
|
|
1115
|
+
* validates it, by running the type's own validator. Mounting a node in a
|
|
1116
|
+
* validup container would strip every key the container does not mount, and
|
|
1117
|
+
* the whole configuration would go with it.
|
|
1118
|
+
*/
|
|
1119
|
+
export declare const authorizationPolicySchema: z.ZodObject<{
|
|
1120
|
+
type: z.ZodString;
|
|
1121
|
+
}, z.core.$loose>;
|
|
1122
|
+
/**
|
|
1123
|
+
* One permission definition. `policies` carries the ids of its
|
|
1124
|
+
* definition-layer trees, or `null` when the server could not project one.
|
|
1125
|
+
*/
|
|
1126
|
+
export declare const authorizationDefinitionSchema: z.ZodObject<{
|
|
1127
|
+
name: z.ZodString;
|
|
1128
|
+
realm_id: z.ZodNullable<z.ZodString>;
|
|
1129
|
+
client_id: z.ZodNullable<z.ZodString>;
|
|
1130
|
+
decision_strategy: z.ZodNullable<z.ZodEnum<typeof DecisionStrategy>>;
|
|
1131
|
+
policies: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
1132
|
+
}, z.core.$strip>;
|
|
1133
|
+
export declare const authorizationCatalogSchema: z.ZodObject<{
|
|
1134
|
+
policies: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1135
|
+
type: z.ZodString;
|
|
1136
|
+
}, z.core.$loose>>;
|
|
1137
|
+
permissions: z.ZodArray<z.ZodObject<{
|
|
1138
|
+
name: z.ZodString;
|
|
1139
|
+
realm_id: z.ZodNullable<z.ZodString>;
|
|
1140
|
+
client_id: z.ZodNullable<z.ZodString>;
|
|
1141
|
+
decision_strategy: z.ZodNullable<z.ZodEnum<typeof DecisionStrategy>>;
|
|
1142
|
+
policies: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
1143
|
+
}, z.core.$strip>>;
|
|
1144
|
+
}, z.core.$strip>;
|
|
1145
|
+
/**
|
|
1146
|
+
* One grant of the identity, as the introspection endpoints report it.
|
|
1147
|
+
* Whether a grant's policy ids are declared is checked against the catalog
|
|
1148
|
+
* the consumer holds, since the two travel separately.
|
|
1149
|
+
*/
|
|
1150
|
+
export declare const authorizationGrantSchema: z.ZodObject<{
|
|
1151
|
+
name: z.ZodString;
|
|
1152
|
+
realm_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1153
|
+
client_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1154
|
+
realm_scope: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof RealmScope>>>;
|
|
1155
|
+
policies: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
1156
|
+
}, z.core.$strip>;
|
|
1157
|
+
export declare const authorizationIdentitySchema: z.ZodObject<{
|
|
1158
|
+
id: z.ZodString;
|
|
1159
|
+
type: z.ZodEnum<{
|
|
1160
|
+
user: "user";
|
|
1161
|
+
client: "client";
|
|
1162
|
+
}>;
|
|
1163
|
+
realmId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1164
|
+
realmName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1165
|
+
clientId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1166
|
+
}, z.core.$strip>;
|
|
1167
|
+
/**
|
|
1168
|
+
* The whole input `createAuthorizationEvaluator` takes: the catalog
|
|
1169
|
+
* `GET /authorization` serves, the grants an introspection reports and the
|
|
1170
|
+
* identity it names. A validup container over zod mounts, the shape every
|
|
1171
|
+
* validator in this package uses, so a consumer can reuse or override one
|
|
1172
|
+
* member's rules instead of restating the document.
|
|
1173
|
+
*/
|
|
1174
|
+
export declare class AuthorizationEvaluatorInputValidator extends Container<AuthorizationEvaluatorInput> {
|
|
1175
|
+
initialize(): void;
|
|
1176
|
+
}
|
|
1177
|
+
export type AuthorizationEvaluatorInputParsed = {
|
|
1178
|
+
catalog: AuthorizationCatalog;
|
|
1179
|
+
grants: AuthorizationGrant[];
|
|
1180
|
+
identity: AuthorizationEvaluatorInput['identity'];
|
|
1181
|
+
};
|
|
1182
|
+
/**
|
|
1183
|
+
* Validate the evaluator's input, plus the two rules per-key validators
|
|
1184
|
+
* cannot express.
|
|
1185
|
+
*
|
|
1186
|
+
* Every id a definition names must be a key of `policies`: a dangling id
|
|
1187
|
+
* resolves to `undefined`, which reads as "this layer carries no policy", so
|
|
1188
|
+
* a catalog that merely omitted a tree would grant unrestricted access rather
|
|
1189
|
+
* than fail. The lookup is own-property only, so an id such as `constructor`
|
|
1190
|
+
* cannot be answered by a member of `Object.prototype`.
|
|
1191
|
+
*
|
|
1192
|
+
* And the identity and its grants travel together: grants without an identity
|
|
1193
|
+
* belong to nobody, while an identity without a grant list is the shape an
|
|
1194
|
+
* INACTIVE introspection produces (`permissions` is absent unless the
|
|
1195
|
+
* credential is active), which read as "holds nothing" would authorize every
|
|
1196
|
+
* definition that carries no binding check. An identity holding no grant says
|
|
1197
|
+
* so with an empty array.
|
|
1198
|
+
*/
|
|
1199
|
+
export declare function parseAuthorizationEvaluatorInput(input: AuthorizationEvaluatorInput): Promise<AuthorizationEvaluatorInputParsed>;
|
|
1200
|
+
/**
|
|
1201
|
+
* One verdict: the permission namespace and the requested realms it holds in.
|
|
1202
|
+
* A realm value is a realm key the caller itself supplied, or `null` for the
|
|
1203
|
+
* global rows, so nothing here is resolved or looked up.
|
|
1204
|
+
*/
|
|
1205
|
+
export declare const authorizationCheckPermissionSchema: z.ZodObject<{
|
|
1206
|
+
name: z.ZodString;
|
|
1207
|
+
realms: z.ZodArray<z.ZodNullable<z.ZodString>>;
|
|
1208
|
+
}, z.core.$strip>;
|
|
1209
|
+
export declare const authorizationCheckPermissionsSchema: z.ZodArray<z.ZodObject<{
|
|
1210
|
+
name: z.ZodString;
|
|
1211
|
+
realms: z.ZodArray<z.ZodNullable<z.ZodString>>;
|
|
1212
|
+
}, z.core.$strip>>;
|
|
1213
|
+
//#endregion
|
|
803
1214
|
//# sourceMappingURL=index.d.mts.map
|