@authup/access 1.0.0-beta.65 → 1.0.0-beta.67

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.
Files changed (50) hide show
  1. package/dist/index.d.mts +557 -65
  2. package/dist/index.d.mts.map +1 -1
  3. package/dist/index.mjs +838 -30
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/permission/authorization/check-schema.d.ts +23 -0
  6. package/dist/permission/authorization/check-schema.d.ts.map +1 -0
  7. package/dist/permission/authorization/check.d.ts +7 -0
  8. package/dist/permission/authorization/check.d.ts.map +1 -0
  9. package/dist/permission/authorization/constants.d.ts +14 -0
  10. package/dist/permission/authorization/constants.d.ts.map +1 -0
  11. package/dist/permission/authorization/error.d.ts +18 -0
  12. package/dist/permission/authorization/error.d.ts.map +1 -0
  13. package/dist/permission/authorization/index.d.ts +9 -0
  14. package/dist/permission/authorization/index.d.ts.map +1 -0
  15. package/dist/permission/authorization/module.d.ts +77 -0
  16. package/dist/permission/authorization/module.d.ts.map +1 -0
  17. package/dist/permission/authorization/policy.d.ts +31 -0
  18. package/dist/permission/authorization/policy.d.ts.map +1 -0
  19. package/dist/permission/authorization/schema.d.ts +107 -0
  20. package/dist/permission/authorization/schema.d.ts.map +1 -0
  21. package/dist/permission/authorization/types.d.ts +136 -0
  22. package/dist/permission/authorization/types.d.ts.map +1 -0
  23. package/dist/permission/evaluator/module.d.ts.map +1 -1
  24. package/dist/permission/evaluator/types.d.ts +16 -1
  25. package/dist/permission/evaluator/types.d.ts.map +1 -1
  26. package/dist/permission/index.d.ts +1 -0
  27. package/dist/permission/index.d.ts.map +1 -1
  28. package/dist/permission/realm-scope/helpers.d.ts +1 -1
  29. package/dist/permission/realm-scope/helpers.d.ts.map +1 -1
  30. package/dist/policy/built-in/date/evaluator.d.ts.map +1 -1
  31. package/dist/policy/built-in/permission-binding/identity-evaluator.d.ts +21 -0
  32. package/dist/policy/built-in/permission-binding/identity-evaluator.d.ts.map +1 -0
  33. package/dist/policy/built-in/permission-binding/index.d.ts +1 -0
  34. package/dist/policy/built-in/permission-binding/index.d.ts.map +1 -1
  35. package/dist/policy/built-in/permission-binding/validator.d.ts.map +1 -1
  36. package/dist/policy/built-in/time/evaluator.d.ts.map +1 -1
  37. package/dist/policy/constants.d.ts +11 -0
  38. package/dist/policy/constants.d.ts.map +1 -1
  39. package/dist/policy/data.d.ts +2 -0
  40. package/dist/policy/data.d.ts.map +1 -1
  41. package/dist/policy/evaluation/context/define.d.ts.map +1 -1
  42. package/dist/policy/evaluation/context/index.d.ts +1 -0
  43. package/dist/policy/evaluation/context/index.d.ts.map +1 -1
  44. package/dist/policy/evaluation/context/transition.d.ts +13 -0
  45. package/dist/policy/evaluation/context/transition.d.ts.map +1 -0
  46. package/dist/policy/evaluation/context/types.d.ts +27 -0
  47. package/dist/policy/evaluation/context/types.d.ts.map +1 -1
  48. package/dist/policy/types.d.ts +5 -0
  49. package/dist/policy/types.d.ts.map +1 -1
  50. package/package.json +8 -8
@@ -0,0 +1,23 @@
1
+ import { Container } from 'validup';
2
+ import type { AuthorizationCheckEvaluatorInput, AuthorizationCheckPermissions } from './types';
3
+ /**
4
+ * The whole input `createAuthorizationCheckEvaluator` takes: the answer
5
+ * `POST /authorization/check` served and the identity it belongs to. Same
6
+ * validup-over-zod shape as the catalog's input, so a consumer can override
7
+ * one member's rules instead of restating the answer.
8
+ */
9
+ export declare class AuthorizationCheckEvaluatorInputValidator extends Container<AuthorizationCheckEvaluatorInput> {
10
+ initialize(): void;
11
+ }
12
+ export type AuthorizationCheckEvaluatorInputParsed = {
13
+ permissions: AuthorizationCheckPermissions;
14
+ identity: AuthorizationCheckEvaluatorInput['identity'];
15
+ };
16
+ /**
17
+ * Validate the check evaluator's input, plus the one rule a per-key validator
18
+ * cannot express: a permission namespace appears at most once. Two entries for
19
+ * one name would make the answer depend on which the consumer looked up first,
20
+ * and the server emits one entry per name by construction.
21
+ */
22
+ export declare function parseAuthorizationCheckEvaluatorInput(input: AuthorizationCheckEvaluatorInput): Promise<AuthorizationCheckEvaluatorInputParsed>;
23
+ //# sourceMappingURL=check-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-schema.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/check-schema.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAC;AAElD,OAAO,KAAK,EAAE,gCAAgC,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAE/F;;;;;GAKG;AACH,qBAAa,yCAA0C,SAAQ,SAAS,CAAC,gCAAgC,CAAC;IAC7F,UAAU;CAMtB;AAID,MAAM,MAAM,sCAAsC,GAAG;IACjD,WAAW,EAAE,6BAA6B,CAAC;IAC3C,QAAQ,EAAE,gCAAgC,CAAC,UAAU,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,qCAAqC,CACvD,KAAK,EAAE,gCAAgC,GACvC,OAAO,CAAC,sCAAsC,CAAC,CA0BlD"}
@@ -0,0 +1,7 @@
1
+ import type { AuthorizationCatalogStaleError } from './error';
2
+ /**
3
+ * Marker-only: the error carries no code of its own, and it never crosses a
4
+ * wire boundary, so there is no shape to fall back to.
5
+ */
6
+ export declare function isAuthorizationCatalogStaleError(input: unknown): input is AuthorizationCatalogStaleError;
7
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/check.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAG9D;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,OAAO,GAAI,KAAK,IAAI,8BAA8B,CAEzG"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The node a policy tree travels as when the server withholds it, because the
3
+ * caller's realm reach does not cover the row it was read from.
4
+ *
5
+ * It is deliberately a type no consumer can project: `projectAuthorizationPolicy`
6
+ * refuses it, which is already the state a definition referencing it denies
7
+ * through and a grant naming it is dropped through, so withholding a body needs
8
+ * no rule of its own on the consumer side. That is a contract between the two
9
+ * halves rather than a server detail, which is why it is declared HERE, next to
10
+ * the projection that has to keep refusing it, and pinned by this package's own
11
+ * test.
12
+ */
13
+ export declare const AUTHORIZATION_POLICY_WITHHELD_TYPE = "withheld";
14
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/constants.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kCAAkC,aAAa,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { AuthupError } from '@authup/errors';
2
+ export declare const AUTHORIZATION_CATALOG_STALE_ERROR_INSTANCE: unique symbol;
3
+ /**
4
+ * A grant references a definition or a policy the supplied catalog does not
5
+ * carry: the caller's cached catalog predates the definition or the junction
6
+ * row and must be refetched. A definition the catalog carries with
7
+ * `policies: null`, and one whose tree this copy cannot project, are not
8
+ * stale but unevaluable, and a grant of either is dropped.
9
+ *
10
+ * Recognize it with `isAuthorizationCatalogStaleError`, never `instanceof`:
11
+ * this package is a plain caret dependency of several workspaces, so a
12
+ * consumer tree may resolve two copies of it and turn the one recoverable
13
+ * state into an unrecoverable one.
14
+ */
15
+ export declare class AuthorizationCatalogStaleError extends AuthupError {
16
+ constructor(message: string);
17
+ }
18
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/error.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAkB,MAAM,gBAAgB,CAAC;AAE7D,eAAO,MAAM,0CAA0C,eAA8D,CAAC;AAEtH;;;;;;;;;;;GAWG;AACH,qBAAa,8BAA+B,SAAQ,WAAW;gBAC/C,OAAO,EAAE,MAAM;CAM9B"}
@@ -0,0 +1,9 @@
1
+ export * from './check';
2
+ export * from './check-schema';
3
+ export * from './constants';
4
+ export * from './error';
5
+ export * from './module';
6
+ export * from './policy';
7
+ export * from './schema';
8
+ export * from './types';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/index.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,77 @@
1
+ import type { IPermissionEvaluator } from '../evaluator';
2
+ import type { AuthorizationCheckEvaluatorInput, AuthorizationEvaluatorInput, AuthorizationEvaluatorOptions } from './types';
3
+ /**
4
+ * Build a resource-server (or console) evaluator from the catalog
5
+ * `GET /authorization` serves, the identity's grants as the introspection
6
+ * endpoints report them, and the identity itself. Rejects legacy, incomplete
7
+ * and unsupported input. A grant referencing a definition or a policy the
8
+ * catalog lacks throws `AuthorizationCatalogStaleError`, the signal to
9
+ * refetch the catalog: the grants come from a fresh introspection while the
10
+ * catalog may predate the definition or the junction row. A definition the
11
+ * server could not project travels with `policies: null` instead of being
12
+ * left out, so a grant of it is dropped rather than reported stale: the
13
+ * definition layer cannot be evaluated here, a refetch changes nothing, and
14
+ * the permission denies until the policy is fixed.
15
+ *
16
+ * A tree THIS copy cannot project is the same condition read from the other
17
+ * side, and it is per tree: a policy type the validator registry lacks (a
18
+ * type newer than this package, or a custom one the caller did not register)
19
+ * or a configuration its validator refuses denies the definitions that reference
20
+ * it, exactly as `policies: null` does, and drops a grant that names it,
21
+ * exactly as a binding check does. One such tree never takes the evaluator
22
+ * down for the permissions that do not use it. A malformed catalog still
23
+ * throws: a duplicate permission namespace is not a data condition.
24
+ *
25
+ * Both the identity and the grants are optional. Without an identity no grant
26
+ * is bound and any IDENTITY key the caller supplied is REMOVED, so the
27
+ * binding evaluator answers with missing data exactly as the server does for
28
+ * an anonymous request, only a definition whose policies need no identity can
29
+ * pass, and a caller can never inject an identity the document did not prove.
30
+ * Grants without the identity they belong to are refused.
31
+ *
32
+ * The REALM_MATCH data key follows the server's own three-way rule: a
33
+ * resource that carries a realm passes it (null for a global row, which
34
+ * `own` denies), a resource with no realm dimension passes nothing and reach
35
+ * neutral-passes. `preEvaluate` / `preEvaluateOneOf` are the pre-gate and
36
+ * enforce reach only when that key is present. `compile` returns the
37
+ * allow/deny/conditional/post contract; a `post` collection query must be
38
+ * rejected or evaluated over every candidate before paging. The supplied
39
+ * identity is authoritative; `options.decisionStrategy` is forwarded and the
40
+ * policy include, exclude and pending options are refused.
41
+ *
42
+ * The policy type set is open (#3635): `options.validators` decides which
43
+ * trees project and `options.evaluators` how they evaluate, the built-in
44
+ * registries by default. A custom type needs both, the validator the server
45
+ * projected it with and the evaluator the server decides it with; given only
46
+ * the first it projects and then denies. The binding evaluator is always this
47
+ * function's own, since it is what binds the introspected grants.
48
+ */
49
+ export declare function createAuthorizationEvaluator(input: AuthorizationEvaluatorInput, options?: AuthorizationEvaluatorOptions): Promise<IPermissionEvaluator>;
50
+ /**
51
+ * An `IPermissionEvaluator` over the answer `POST /authorization/check`
52
+ * served: the caller's own verdicts, paired with the realms they hold in.
53
+ *
54
+ * It is what a PUBLIC client gets where the catalog is out of reach. A public
55
+ * client holds no secret, so it can obtain no `client_credentials` token and
56
+ * has no credential of its own for the catalog's gate to be satisfied by;
57
+ * publishing every policy predicate to it instead would be the wrong trade.
58
+ * The verdicts are computed by the server from the same grants and the same
59
+ * evaluators a request runs, so this is authoritative where the name-only
60
+ * fallback it replaces is merely coarse.
61
+ *
62
+ * Two properties follow from the answer being a pre-gate:
63
+ *
64
+ * It is an UPPER BOUND, so `evaluate` and `evaluateOneOf` answer exactly what
65
+ * the pre-gate pair answers. A check that depends on a resource row belongs to
66
+ * whoever holds the row, and the server decides it there; answering such a
67
+ * check here would mean inventing a verdict. That is the same bound the
68
+ * name-only fallback already had, so nothing that gates on it loosens.
69
+ *
70
+ * And a resource realm is matched against what the REQUEST asked about: a
71
+ * `realmMatch` naming a realm the request never carried is in no entry's list
72
+ * and therefore denies. That is fail-closed by construction rather than by a
73
+ * rule, and it is why a caller must ask about the realms its UI will ask
74
+ * about.
75
+ */
76
+ export declare function createAuthorizationCheckEvaluator(input: AuthorizationCheckEvaluatorInput): Promise<IPermissionEvaluator>;
77
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/module.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACR,oBAAoB,EAIvB,MAAM,cAAc,CAAC;AAWtB,OAAO,KAAK,EACR,gCAAgC,EAChC,2BAA2B,EAC3B,6BAA6B,EAEhC,MAAM,SAAS,CAAC;AA0CjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAsB,4BAA4B,CAC9C,KAAK,EAAE,2BAA2B,EAClC,OAAO,GAAE,6BAAkC,GAC3C,OAAO,CAAC,oBAAoB,CAAC,CAgMhC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,iCAAiC,CACnD,KAAK,EAAE,gCAAgC,GACvC,OAAO,CAAC,oBAAoB,CAAC,CA0GhC"}
@@ -0,0 +1,31 @@
1
+ import type { PolicyValidators } from '../../policy';
2
+ import type { AuthorizationPolicy } from './types';
3
+ /**
4
+ * The one definition of what a policy looks like on the wire, used by the server
5
+ * to build a document and by the consumer to validate one. A node is the OUTPUT
6
+ * of its type's validator (validup strips every unmounted key, so entity columns
7
+ * such as `id`, `name`, `builtIn` or `createdAt` never travel), plus its type
8
+ * and, for a composite, its projected children.
9
+ *
10
+ * The type set is the `validators` registry, `PolicyDefaultValidators` unless
11
+ * the caller hands another (#3635): a type the registry lacks is refused, so
12
+ * the server and a consumer that register the same custom type let it travel,
13
+ * and one that does not denies it. The withheld node is refused whatever the
14
+ * registry says, since projecting it would evaluate a tree the caller was not
15
+ * allowed to see.
16
+ *
17
+ * Every refusal is a `ValidupError`, the node's head and the type's own
18
+ * validator alike, and a child's issues are rebased onto the position it sits
19
+ * at, so one message names the node in the tree that is wrong.
20
+ */
21
+ export declare function projectAuthorizationPolicy(input: unknown, validators?: PolicyValidators): Promise<AuthorizationPolicy>;
22
+ /**
23
+ * Whether a projected tree evaluates the permission binding at any depth. A
24
+ * grant policy carrying one would re-enter its own permission's grants, so
25
+ * `createAuthorizationEvaluator` drops the grant that names it and evaluates
26
+ * the permission from the rest. Its one caller is that consumer: the tree is
27
+ * legal in a definition, where the binding check is what reach is enforced
28
+ * by, so the producer carries it and only the grant side is refused.
29
+ */
30
+ export declare function containsBindingCheck(policy: AuthorizationPolicy): boolean;
31
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/policy.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAqBnD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,0BAA0B,CAC5C,KAAK,EAAE,OAAO,EACd,UAAU,GAAE,gBAA0C,GACtD,OAAO,CAAC,mBAAmB,CAAC,CA+C/B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,GAAI,OAAO,CAM1E"}
@@ -0,0 +1,107 @@
1
+ import { DecisionStrategy } from '@authup/kit';
2
+ import { Container } from 'validup';
3
+ import { z } from 'zod';
4
+ import { RealmScope } from '../realm-scope';
5
+ import type { AuthorizationCatalog, AuthorizationEvaluatorInput, AuthorizationGrant } from './types';
6
+ /**
7
+ * A policy node as it travels. Deliberately LOOSE: every key beyond `type` is
8
+ * that type's own configuration, and `projectAuthorizationPolicy` is what
9
+ * validates it, by running the type's own validator. Mounting a node in a
10
+ * validup container would strip every key the container does not mount, and
11
+ * the whole configuration would go with it.
12
+ */
13
+ export declare const authorizationPolicySchema: z.ZodObject<{
14
+ type: z.ZodString;
15
+ }, z.core.$loose>;
16
+ /**
17
+ * One permission definition. `policies` carries the ids of its
18
+ * definition-layer trees, or `null` when the server could not project one.
19
+ */
20
+ export declare const authorizationDefinitionSchema: z.ZodObject<{
21
+ name: z.ZodString;
22
+ realm_id: z.ZodNullable<z.ZodString>;
23
+ client_id: z.ZodNullable<z.ZodString>;
24
+ decision_strategy: z.ZodNullable<z.ZodEnum<typeof DecisionStrategy>>;
25
+ policies: z.ZodNullable<z.ZodArray<z.ZodString>>;
26
+ }, z.core.$strip>;
27
+ export declare const authorizationCatalogSchema: z.ZodObject<{
28
+ policies: z.ZodRecord<z.ZodString, z.ZodObject<{
29
+ type: z.ZodString;
30
+ }, z.core.$loose>>;
31
+ permissions: z.ZodArray<z.ZodObject<{
32
+ name: z.ZodString;
33
+ realm_id: z.ZodNullable<z.ZodString>;
34
+ client_id: z.ZodNullable<z.ZodString>;
35
+ decision_strategy: z.ZodNullable<z.ZodEnum<typeof DecisionStrategy>>;
36
+ policies: z.ZodNullable<z.ZodArray<z.ZodString>>;
37
+ }, z.core.$strip>>;
38
+ }, z.core.$strip>;
39
+ /**
40
+ * One grant of the identity, as the introspection endpoints report it.
41
+ * Whether a grant's policy ids are declared is checked against the catalog
42
+ * the consumer holds, since the two travel separately.
43
+ */
44
+ export declare const authorizationGrantSchema: z.ZodObject<{
45
+ name: z.ZodString;
46
+ realm_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ client_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ realm_scope: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof RealmScope>>>;
49
+ policies: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
50
+ }, z.core.$strip>;
51
+ export declare const authorizationIdentitySchema: z.ZodObject<{
52
+ id: z.ZodString;
53
+ type: z.ZodEnum<{
54
+ user: "user";
55
+ client: "client";
56
+ }>;
57
+ realmId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ realmName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
59
+ clientId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
60
+ }, z.core.$strip>;
61
+ /**
62
+ * The whole input `createAuthorizationEvaluator` takes: the catalog
63
+ * `GET /authorization` serves, the grants an introspection reports and the
64
+ * identity it names. A validup container over zod mounts, the shape every
65
+ * validator in this package uses, so a consumer can reuse or override one
66
+ * member's rules instead of restating the document.
67
+ */
68
+ export declare class AuthorizationEvaluatorInputValidator extends Container<AuthorizationEvaluatorInput> {
69
+ initialize(): void;
70
+ }
71
+ export type AuthorizationEvaluatorInputParsed = {
72
+ catalog: AuthorizationCatalog;
73
+ grants: AuthorizationGrant[];
74
+ identity: AuthorizationEvaluatorInput['identity'];
75
+ };
76
+ /**
77
+ * Validate the evaluator's input, plus the two rules per-key validators
78
+ * cannot express.
79
+ *
80
+ * Every id a definition names must be a key of `policies`: a dangling id
81
+ * resolves to `undefined`, which reads as "this layer carries no policy", so
82
+ * a catalog that merely omitted a tree would grant unrestricted access rather
83
+ * than fail. The lookup is own-property only, so an id such as `constructor`
84
+ * cannot be answered by a member of `Object.prototype`.
85
+ *
86
+ * And the identity and its grants travel together: grants without an identity
87
+ * belong to nobody, while an identity without a grant list is the shape an
88
+ * INACTIVE introspection produces (`permissions` is absent unless the
89
+ * credential is active), which read as "holds nothing" would authorize every
90
+ * definition that carries no binding check. An identity holding no grant says
91
+ * so with an empty array.
92
+ */
93
+ export declare function parseAuthorizationEvaluatorInput(input: AuthorizationEvaluatorInput): Promise<AuthorizationEvaluatorInputParsed>;
94
+ /**
95
+ * One verdict: the permission namespace and the requested realms it holds in.
96
+ * A realm value is a realm key the caller itself supplied, or `null` for the
97
+ * global rows, so nothing here is resolved or looked up.
98
+ */
99
+ export declare const authorizationCheckPermissionSchema: z.ZodObject<{
100
+ name: z.ZodString;
101
+ realms: z.ZodArray<z.ZodNullable<z.ZodString>>;
102
+ }, z.core.$strip>;
103
+ export declare const authorizationCheckPermissionsSchema: z.ZodArray<z.ZodObject<{
104
+ name: z.ZodString;
105
+ realms: z.ZodArray<z.ZodNullable<z.ZodString>>;
106
+ }, z.core.$strip>>;
107
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/schema.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EACR,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EACrB,MAAM,SAAS,CAAC;AAKjB;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB;;iBAA6C,CAAC;AAEpF;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;;;;;iBAMxC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;iBAGrC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;iBAMnC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;iBAMtC,CAAC;AAEH;;;;;;GAMG;AACH,qBAAa,oCAAqC,SAAQ,SAAS,CAAC,2BAA2B,CAAC;IACnF,UAAU;CAOtB;AAID,MAAM,MAAM,iCAAiC,GAAG;IAC5C,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,QAAQ,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gCAAgC,CAClD,KAAK,EAAE,2BAA2B,GAClC,OAAO,CAAC,iCAAiC,CAAC,CAqD7C;AAED;;;;GAIG;AACH,eAAO,MAAM,kCAAkC;;;iBAG7C,CAAC;AAEH,eAAO,MAAM,mCAAmC;;;kBAA8C,CAAC"}
@@ -0,0 +1,136 @@
1
+ import type { DecisionStrategy } from '@authup/kit';
2
+ import type { IdentityPolicyData, PolicyEvaluators, PolicyValidators } from '../../policy';
3
+ import type { RealmScope } from '../realm-scope';
4
+ /**
5
+ * One policy tree node as it travels: the type's configuration keys (the output
6
+ * of that type's validator), `invert`, and for a composite its children inline.
7
+ */
8
+ export type AuthorizationPolicy = {
9
+ type: string;
10
+ invert?: boolean | null;
11
+ children?: AuthorizationPolicy[];
12
+ [key: string]: unknown;
13
+ };
14
+ export type AuthorizationDefinition = {
15
+ name: string;
16
+ realm_id: string | null;
17
+ client_id: string | null;
18
+ decision_strategy: `${DecisionStrategy}` | null;
19
+ /**
20
+ * The definition layer: the ids of the policy trees bound to the permission
21
+ * definition (`auth_permission_policies`). Empty means unrestricted at this
22
+ * layer. `null` means the server could not project one of those trees onto
23
+ * the wire (a policy type the catalog does not carry, or a configuration
24
+ * its validator refuses): the definition exists, a consumer cannot evaluate
25
+ * it and denies it, dropping every grant of it, until the policy is fixed.
26
+ */
27
+ policies: string[] | null;
28
+ };
29
+ /**
30
+ * Identity-free and cacheable: every permission definition with its policy trees.
31
+ */
32
+ export type AuthorizationCatalog = {
33
+ /**
34
+ * Every policy tree a definition or a grant can name, keyed by the tree's
35
+ * own id and present exactly once however many of them reference it.
36
+ */
37
+ policies: Record<string, AuthorizationPolicy>;
38
+ permissions: AuthorizationDefinition[];
39
+ };
40
+ /**
41
+ * One raw grant of an identity as the introspection endpoints report it: the
42
+ * permission namespace it names, its realm reach and the junction policy ids.
43
+ * Structurally the extended `OAuth2TokenPermission` of `@authup/specs` (this
44
+ * package does not depend on specs).
45
+ */
46
+ export type AuthorizationGrant = {
47
+ name: string;
48
+ realm_id?: string | null;
49
+ client_id?: string | null;
50
+ /**
51
+ * Absent or null coerces to `own`, fail-closed.
52
+ */
53
+ realm_scope?: `${RealmScope}` | null;
54
+ /**
55
+ * Absent or null means no junction policy.
56
+ */
57
+ policies?: string[] | null;
58
+ };
59
+ export type AuthorizationEvaluatorInput = {
60
+ /**
61
+ * An `AuthorizationCatalog`, validated by the schema.
62
+ */
63
+ catalog: unknown;
64
+ /**
65
+ * `AuthorizationGrant[]`, validated by the schema. Defaults to none, and
66
+ * may only be supplied together with the identity holding them.
67
+ */
68
+ grants?: unknown;
69
+ /**
70
+ * The identity the grants belong to. Omitted for an anonymous caller:
71
+ * no identity data is injected and no grant is bound, so only a
72
+ * definition whose policies need no identity can pass.
73
+ */
74
+ identity?: IdentityPolicyData;
75
+ };
76
+ export type AuthorizationEvaluatorOptions = {
77
+ /**
78
+ * The policy types a catalog tree may carry. Defaults to
79
+ * `PolicyDefaultValidators`; spread it to add a custom type.
80
+ */
81
+ validators?: PolicyValidators;
82
+ /**
83
+ * How the projected trees evaluate. Defaults to
84
+ * `PolicyDefaultEvaluators`; spread it to add a custom type. The
85
+ * permission-binding evaluator is always replaced by the one binding the
86
+ * introspected grants.
87
+ */
88
+ evaluators?: PolicyEvaluators;
89
+ };
90
+ /**
91
+ * Which resource realms a batch check evaluates against.
92
+ *
93
+ * A string is SYMBOLIC and resolved server-side against the caller's own
94
+ * identity: `own` is the realm the identity belongs to, `ownOrNull` is that
95
+ * realm plus `null`, the global rows every realm shares. An array is taken
96
+ * VERBATIM: the server resolves no realm key, so it discloses no realm's
97
+ * existence and the caller matches the answer against its own input with no
98
+ * resolution step of its own.
99
+ *
100
+ * String versus array is what discriminates the two forms, so `own` stays
101
+ * unambiguous even though it is a legal realm name.
102
+ */
103
+ export type AuthorizationCheckRealms = `${RealmScope.OWN}` | `${RealmScope.OWN_OR_NULL}` | Array<string | null>;
104
+ /**
105
+ * One permission the identity may attempt, and the requested realms it may
106
+ * attempt it in. Never empty: a permission reaching no requested realm is
107
+ * absent from the answer entirely, so absent means denied.
108
+ */
109
+ export type AuthorizationCheckPermission = {
110
+ name: string;
111
+ realms: Array<string | null>;
112
+ };
113
+ /**
114
+ * The answer `POST /authorization/check` serves: the caller's own verdicts,
115
+ * paired with the realms they hold in.
116
+ *
117
+ * It is an upper bound on what may be ATTEMPTED rather than an entitlement,
118
+ * the same posture the catalog and `GET /schemas` take: it is a pre-gate, so a
119
+ * grant whose junction policy needs a resource row passes here and is still
120
+ * decided per row on the server, which stays the enforcement point.
121
+ */
122
+ export type AuthorizationCheckPermissions = AuthorizationCheckPermission[];
123
+ export type AuthorizationCheckEvaluatorInput = {
124
+ /**
125
+ * An `AuthorizationCheckPermissions`, validated by the schema.
126
+ */
127
+ permissions: unknown;
128
+ /**
129
+ * The identity the verdicts belong to, used to resolve a `realmMatch` of
130
+ * `own` shape: a resource realm equal to this identity's realm id or name
131
+ * is the identity's own realm. Omitted for an anonymous caller, which
132
+ * holds no verdict at all.
133
+ */
134
+ identity?: IdentityPolicyData;
135
+ };
136
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACjC,CAAC,GAAG,EAAE,MA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B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KACtB,GACN,OAAO,CAAC,iCAAiC,GAAG,IAAI,CAAC;IAU/C,QAAQ,CAAC,GAAG,EAAE,2BAA2B,GAAI,OAAO,CAAC,IAAI,CAAC;IAsH1D,aAAa,CAAC,GAAG,EAAE,2BAA2B,GAAI,OAAO,CAAC,IAAI,CAAC;IAY/D,WAAW,CAAC,GAAG,EAAE,2BAA2B,GAAI,OAAO,CAAC,IAAI,CAAC;IAe7D,gBAAgB,CAAC,GAAG,EAAE,2BAA2B,GAAI,OAAO,CAAC,IAAI,CAAC;IAYxE;;;;;;;;;OASG;IACG,OAAO,CAAC,GAAG,EAAE,wBAAwB,GAAI,OAAO,CAAC,uBAAuB,CAAC;CA0ElF"}
@@ -1,6 +1,6 @@
1
1
  import type { ICondition } from '@rapiq/core';
2
2
  import type { DecisionStrategy } from '@authup/kit';
3
- import type { IPolicyEngine, PolicyData } from '../../policy';
3
+ import type { IPolicyEngine, PolicyData, PolicyTransitionSink } from '../../policy';
4
4
  import type { IPermissionProvider } from '../provider';
5
5
  export interface IPermissionEvaluator {
6
6
  evaluate(ctx: PermissionEvaluationContext): Promise<void>;
@@ -29,6 +29,13 @@ export type PermissionEvaluationOptions = {
29
29
  * (`preEvaluate()`): only a tree that settles false with the current bag denies.
30
30
  */
31
31
  pendingPolicies?: 'deny' | 'permit';
32
+ /**
33
+ * Receives the instants at which a clock-dependent policy (`date`, `time`)
34
+ * in an evaluated tree could change its verdict, so a caller caching the
35
+ * outcome knows when it expires. Handed to every policy evaluation this call
36
+ * runs; a policy-free grant evaluates nothing and reports nothing.
37
+ */
38
+ transitions?: PolicyTransitionSink;
32
39
  };
33
40
  export type PermissionEvaluationContext = {
34
41
  name: string | string[];
@@ -51,6 +58,14 @@ export type PermissionCompileContext = {
51
58
  * compiled condition ranges over.
52
59
  */
53
60
  data?: PolicyData;
61
+ /**
62
+ * Row column the realm reach is lowered onto, when the rows this compilation
63
+ * ranges over carry their realm under another name — a junction's owner-realm
64
+ * key (`roleRealmId`, `clientRealmId`, …). Default `realmId`. Affects the
65
+ * `conditional` condition only; the per-row `post` fallback still reads the
66
+ * realm from the `realmMatch` data key its caller supplies.
67
+ */
68
+ realmAttributeName?: string;
54
69
  };
55
70
  /**
56
71
  * Outcome of compiling a permission's policy trees against the knowns bag
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/permission/evaluator/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,oBAAoB;IACjC,QAAQ,CAAC,GAAG,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D,aAAa,CAAC,GAAG,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/D,WAAW,CAAC,GAAG,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7D,gBAAgB,CAAC,GAAG,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElE,OAAO,CAAC,GAAG,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAC5E;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACtC,gBAAgB,CAAC,EAAE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AAO,CAAC,EAAE,2BAA2B,CAAA;CACxC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACnC;;;OAGG;IACH,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;;OAIG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GACtD;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACnB;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,GACjD;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -4,4 +4,5 @@ export * from './provider';
4
4
  export * from './evaluator';
5
5
  export * from './realm-scope';
6
6
  export * from './types';
7
+ export * from './authorization';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/permission/index.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/permission/index.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
@@ -19,5 +19,5 @@ export declare function minRealmScope(values: Array<`${RealmScope}` | null | und
19
19
  * multiple realms) requires the scope to reach EVERY listed realm (unanimous, fail-closed),
20
20
  * so any app/entity can express its realm via one or many keys under the canonical contract.
21
21
  */
22
- export declare function realmScopeMatches(scope: `${RealmScope}` | null | undefined, resourceRealmId: string | string[] | null | undefined, identityRealmId: string | null | undefined, identityRealmName?: string | null): boolean;
22
+ export declare function realmScopeMatches(scope: `${RealmScope}` | null | undefined, resourceRealmId: string | Array<string | null> | null | undefined, identityRealmId: string | null | undefined, identityRealmName?: string | null): boolean;
23
23
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/permission/realm-scope/helpers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAqB,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,GAAG,UAAU,EAAE,CAMnF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC7B,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,EAC1B,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,GAC3B,MAAM,CAER;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,UAAU,EAAE,CAYhG;AAED,qGAAqG;AACrG,wBAAgB,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,UAAU,EAAE,CAWhG;AAwBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,EACzC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,EACrD,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC1C,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAClC,OAAO,CAyBT"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/permission/realm-scope/helpers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAqB,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,GAAG,UAAU,EAAE,CAMnF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC7B,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,EAC1B,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,GAC3B,MAAM,CAER;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,UAAU,EAAE,CAYhG;AAED,qGAAqG;AACrG,wBAAgB,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,UAAU,EAAE,CAWhG;AAwBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,EACzC,eAAe,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,EACjE,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC1C,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAClC,OAAO,CAyBT"}
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/date/evaluator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAkBlD,qBAAa,mBAAoB,YAAW,gBAAgB;IACxD,SAAS,CAAC,SAAS,EAAG,mBAAmB,CAAC;;IAMpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAoC5G"}
1
+ {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/date/evaluator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAI1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA0ClD,qBAAa,mBAAoB,YAAW,gBAAgB;IACxD,SAAS,CAAC,SAAS,EAAG,mBAAmB,CAAC;;IAMpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CA4C5G"}
@@ -0,0 +1,21 @@
1
+ import type { PermissionPolicyBinding, PermissionPolicyBindingAggregated } from '../../../permission/types';
2
+ import type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';
3
+ import type { IdentityPolicyData } from '../identity';
4
+ import { IdentityPolicyEvaluator } from '../identity';
5
+ import { RealmMatchPolicyEvaluator } from '../realm-match';
6
+ import { PermissionBindingPolicyValidator } from './validator';
7
+ type IdentityPermissionProvider = {
8
+ getFor(identity: IdentityPolicyData): Promise<PermissionPolicyBinding[]>;
9
+ };
10
+ export declare class IdentityPermissionBindingPolicyEvaluator implements IPolicyEvaluator {
11
+ protected validator: PermissionBindingPolicyValidator;
12
+ protected identityEvaluator: IdentityPolicyEvaluator;
13
+ protected realmMatchEvaluator: RealmMatchPolicyEvaluator;
14
+ protected identityPermissionProvider: IdentityPermissionProvider;
15
+ constructor(identityPermissionProvider: IdentityPermissionProvider);
16
+ requires(): string[];
17
+ accessData(ctx: PolicyEvaluationContext): Promise<PermissionPolicyBindingAggregated | null>;
18
+ evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult>;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=identity-evaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/permission-binding/identity-evaluator.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAG5G,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAM1G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AAE/D,KAAK,0BAA0B,GAAG;IAC9B,MAAM,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAAC;CAC5E,CAAC;AAmBF,qBAAa,wCAAyC,YAAW,gBAAgB;IAC7E,SAAS,CAAC,SAAS,EAAG,gCAAgC,CAAC;IAEvD,SAAS,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;IAErD,SAAS,CAAC,mBAAmB,EAAG,yBAAyB,CAAC;IAE1D,SAAS,CAAC,0BAA0B,EAAE,0BAA0B,CAAC;gBAErD,0BAA0B,EAAE,0BAA0B;IAOlE,QAAQ,IAAK,MAAM,EAAE;IAQf,UAAU,CAAC,GAAG,EAAE,uBAAuB,GAAI,OAAO,CAAC,iCAAiC,GAAG,IAAI,CAAC;IAiB5F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CA6N5G"}
@@ -1,3 +1,4 @@
1
+ export * from './identity-evaluator';
1
2
  export * from './module';
2
3
  export * from './types';
3
4
  export * from './validator';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/permission-binding/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/permission-binding/index.ts"],"names":[],"mappings":"AAOA,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/permission-binding/validator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,gCAAiC,SAAQ,SAAS,CAAC,uBAAuB,CAAC;IAC3E,UAAU;CAGtB"}
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/permission-binding/validator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,gCAAiC,SAAQ,SAAS,CAAC,uBAAuB,CAAC;IAC3E,UAAU;CAWtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/time/evaluator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAI1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA6ClD,qBAAa,mBAAoB,YAAW,gBAAgB;IACxD,SAAS,CAAC,SAAS,EAAG,mBAAmB,CAAC;;IAMpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAwE5G"}
1
+ {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/time/evaluator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAK1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAkGlD,qBAAa,mBAAoB,YAAW,gBAAgB;IACxD,SAAS,CAAC,SAAS,EAAG,mBAAmB,CAAC;;IAMpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAgF5G"}