@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.
Files changed (38) hide show
  1. package/dist/index.d.mts +560 -149
  2. package/dist/index.d.mts.map +1 -1
  3. package/dist/index.mjs +715 -27
  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 +70 -0
  16. package/dist/permission/authorization/module.d.ts.map +1 -0
  17. package/dist/permission/authorization/policy.d.ts +23 -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 +122 -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 +8 -0
  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/policy/built-in/permission-binding/identity-evaluator.d.ts +21 -0
  29. package/dist/policy/built-in/permission-binding/identity-evaluator.d.ts.map +1 -0
  30. package/dist/policy/built-in/permission-binding/index.d.ts +1 -0
  31. package/dist/policy/built-in/permission-binding/index.d.ts.map +1 -1
  32. package/dist/policy/built-in/permission-binding/validator.d.ts.map +1 -1
  33. package/dist/policy/data.d.ts +2 -0
  34. package/dist/policy/data.d.ts.map +1 -1
  35. package/dist/policy/evaluation/context/define.d.ts.map +1 -1
  36. package/dist/policy/evaluation/context/types.d.ts +9 -0
  37. package/dist/policy/evaluation/context/types.d.ts.map +1 -1
  38. package/package.json +5 -5
@@ -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,70 @@
1
+ import type { IPermissionEvaluator } from '../evaluator';
2
+ import type { AuthorizationCheckEvaluatorInput, AuthorizationEvaluatorInput } 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 newer than this package (the
18
+ * built-in type enum is closed while the column is a free string) or a
19
+ * 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
+ export declare function createAuthorizationEvaluator(input: AuthorizationEvaluatorInput): Promise<IPermissionEvaluator>;
43
+ /**
44
+ * An `IPermissionEvaluator` over the answer `POST /authorization/check`
45
+ * served: the caller's own verdicts, paired with the realms they hold in.
46
+ *
47
+ * It is what a PUBLIC client gets where the catalog is out of reach. A public
48
+ * client holds no secret, so it can obtain no `client_credentials` token and
49
+ * has no credential of its own for the catalog's gate to be satisfied by;
50
+ * publishing every policy predicate to it instead would be the wrong trade.
51
+ * The verdicts are computed by the server from the same grants and the same
52
+ * evaluators a request runs, so this is authoritative where the name-only
53
+ * fallback it replaces is merely coarse.
54
+ *
55
+ * Two properties follow from the answer being a pre-gate:
56
+ *
57
+ * It is an UPPER BOUND, so `evaluate` and `evaluateOneOf` answer exactly what
58
+ * the pre-gate pair answers. A check that depends on a resource row belongs to
59
+ * whoever holds the row, and the server decides it there; answering such a
60
+ * check here would mean inventing a verdict. That is the same bound the
61
+ * name-only fallback already had, so nothing that gates on it loosens.
62
+ *
63
+ * And a resource realm is matched against what the REQUEST asked about: a
64
+ * `realmMatch` naming a realm the request never carried is in no entry's list
65
+ * and therefore denies. That is fail-closed by construction rather than by a
66
+ * rule, and it is why a caller must ask about the realms its UI will ask
67
+ * about.
68
+ */
69
+ export declare function createAuthorizationCheckEvaluator(input: AuthorizationCheckEvaluatorInput): Promise<IPermissionEvaluator>;
70
+ //# 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,EAE9B,MAAM,SAAS,CAAC;AAgCjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAsB,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,GAAI,OAAO,CAAC,oBAAoB,CAAC,CAgMrH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,iCAAiC,CACnD,KAAK,EAAE,gCAAgC,GACvC,OAAO,CAAC,oBAAoB,CAAC,CA0GhC"}
@@ -0,0 +1,23 @@
1
+ import type { AuthorizationPolicy } from './types';
2
+ /**
3
+ * The one definition of what a policy looks like on the wire, used by the server
4
+ * to build a document and by the consumer to validate one. A node is the OUTPUT
5
+ * of its type's validator (validup strips every unmounted key, so entity columns
6
+ * such as `id`, `name`, `builtIn` or `createdAt` never travel), plus its type
7
+ * and, for a composite, its projected children.
8
+ *
9
+ * Every refusal is a `ValidupError`, the node's head and the type's own
10
+ * validator alike, and a child's issues are rebased onto the position it sits
11
+ * at, so one message names the node in the tree that is wrong.
12
+ */
13
+ export declare function projectAuthorizationPolicy(input: unknown): Promise<AuthorizationPolicy>;
14
+ /**
15
+ * Whether a projected tree evaluates the permission binding at any depth. A
16
+ * grant policy carrying one would re-enter its own permission's grants, so
17
+ * `createAuthorizationEvaluator` drops the grant that names it and evaluates
18
+ * the permission from the rest. Its one caller is that consumer: the tree is
19
+ * legal in a definition, where the binding check is what reach is enforced
20
+ * by, so the producer carries it and only the grant side is refused.
21
+ */
22
+ export declare function containsBindingCheck(policy: AuthorizationPolicy): boolean;
23
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/permission/authorization/policy.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAkCnD;;;;;;;;;;GAUG;AACH,wBAAsB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAI,OAAO,CAAC,mBAAmB,CAAC,CAuC9F;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,122 @@
1
+ import type { DecisionStrategy } from '@authup/kit';
2
+ import type { IdentityPolicyData } 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
+ /**
77
+ * Which resource realms a batch check evaluates against.
78
+ *
79
+ * A string is SYMBOLIC and resolved server-side against the caller's own
80
+ * identity: `own` is the realm the identity belongs to, `ownOrNull` is that
81
+ * realm plus `null`, the global rows every realm shares. An array is taken
82
+ * VERBATIM: the server resolves no realm key, so it discloses no realm's
83
+ * existence and the caller matches the answer against its own input with no
84
+ * resolution step of its own.
85
+ *
86
+ * String versus array is what discriminates the two forms, so `own` stays
87
+ * unambiguous even though it is a legal realm name.
88
+ */
89
+ export type AuthorizationCheckRealms = `${RealmScope.OWN}` | `${RealmScope.OWN_OR_NULL}` | Array<string | null>;
90
+ /**
91
+ * One permission the identity may attempt, and the requested realms it may
92
+ * attempt it in. Never empty: a permission reaching no requested realm is
93
+ * absent from the answer entirely, so absent means denied.
94
+ */
95
+ export type AuthorizationCheckPermission = {
96
+ name: string;
97
+ realms: Array<string | null>;
98
+ };
99
+ /**
100
+ * The answer `POST /authorization/check` serves: the caller's own verdicts,
101
+ * paired with the realms they hold in.
102
+ *
103
+ * It is an upper bound on what may be ATTEMPTED rather than an entitlement,
104
+ * the same posture the catalog and `GET /schemas` take: it is a pre-gate, so a
105
+ * grant whose junction policy needs a resource row passes here and is still
106
+ * decided per row on the server, which stays the enforcement point.
107
+ */
108
+ export type AuthorizationCheckPermissions = AuthorizationCheckPermission[];
109
+ export type AuthorizationCheckEvaluatorInput = {
110
+ /**
111
+ * An `AuthorizationCheckPermissions`, validated by the schema.
112
+ */
113
+ permissions: unknown;
114
+ /**
115
+ * The identity the verdicts belong to, used to resolve a `realmMatch` of
116
+ * `own` shape: a resource realm equal to this identity's realm id or name
117
+ * is the identity's own realm. Omitted for an anonymous caller, which
118
+ * holds no verdict at all.
119
+ */
120
+ identity?: IdentityPolicyData;
121
+ };
122
+ //# 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,MAAM,cAAc,CAAC;AACvD,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,MAAM,GAAG,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAA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,gBAAgB,CAAC,GAAG,EAAE,2BAA2B,GAAI,OAAO,CAAC,IAAI,CAAC;IAYxE;;;;;;;;;OASG;IACG,OAAO,CAAC,GAAG,EAAE,wBAAwB,GAAI,OAAO,CAAC,uBAAuB,CAAC;CA0ElF"}
@@ -51,6 +51,14 @@ export type PermissionCompileContext = {
51
51
  * compiled condition ranges over.
52
52
  */
53
53
  data?: PolicyData;
54
+ /**
55
+ * Row column the realm reach is lowered onto, when the rows this compilation
56
+ * ranges over carry their realm under another name — a junction's owner-realm
57
+ * key (`roleRealmId`, `clientRealmId`, …). Default `realmId`. Affects the
58
+ * `conditional` condition only; the per-row `post` fallback still reads the
59
+ * realm from the `realmMatch` data key its caller supplies.
60
+ */
61
+ realmAttributeName?: string;
54
62
  };
55
63
  /**
56
64
  * 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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CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACtC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,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"}
@@ -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;AAK1G,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;AAEF,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;CA+M5G"}
@@ -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"}
@@ -2,6 +2,7 @@ export interface IPolicyData {
2
2
  set(key: string, value: unknown): void;
3
3
  has(key: string): boolean;
4
4
  get<T = unknown>(key: string): T;
5
+ delete(key: string): void;
5
6
  isValidated(key: string): boolean;
6
7
  setValidated(key: string): void;
7
8
  clone(): IPolicyData;
@@ -13,6 +14,7 @@ export declare class PolicyData implements IPolicyData {
13
14
  set<T = unknown>(key: string, value: T): void;
14
15
  get<T = unknown>(key: string): T;
15
16
  has(key: string): boolean;
17
+ delete(key: string): void;
16
18
  setValidated(key: string): void;
17
19
  isValidated(key: string): boolean;
18
20
  clone(): PolicyData;
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/policy/data.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAI,IAAI,CAAC;IACxC,GAAG,CAAC,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,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAI,IAAI,CAAC;IAEjC,KAAK,IAAK,WAAW,CAAA;CACxB;AAED,qBAAa,UAAW,YAAW,WAAW;IAC1C,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEpC,SAAS,CAAC,SAAS,EAAG,GAAG,CAAC,MAAM,CAAC,CAAC;gBAG9B,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAC9B,SAAS,GAAE,GAAG,CAAC,MAAM,CAAa;IAMtC,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAI,IAAI;IAK9C,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAI,CAAC;IAQjC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAI,IAAI;IAK1B,YAAY,CAAC,GAAG,EAAE,MAAM,GAAI,IAAI;IAIhC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAI,OAAO;IAIlC,KAAK;CAGR"}
@@ -1 +1 @@
1
- {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../../src/policy/evaluation/context/define.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAGxF,wBAAgB,6BAA6B,CACzC,KAAK,GAAE,4BAAiC,GACxC,uBAAuB,CAS1B"}
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../../src/policy/evaluation/context/define.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAGxF,wBAAgB,6BAA6B,CACzC,KAAK,GAAE,4BAAiC,GACxC,uBAAuB,CAU1B"}
@@ -13,6 +13,15 @@ export type PolicyEvaluationContext = {
13
13
  * query-build callers opt in.
14
14
  */
15
15
  readonly withConditions: boolean;
16
+ /**
17
+ * Row column the realm reach is LOWERED onto, for a caller whose rows carry the
18
+ * realm under another name (a junction's `roleRealmId` / `clientRealmId` / …).
19
+ * Default `realmId`. It reaches `RealmMatchPolicyEvaluator` scope mode as
20
+ * `attributeName`, which that mode reads only while lowering — settled
21
+ * evaluation takes the resource realm from the `realmMatch` data key and never
22
+ * consults a column name, so this can never change an evaluate() outcome.
23
+ */
24
+ readonly realmAttributeName?: string;
16
25
  };
17
26
  export type PolicyEvaluationContextInput = Partial<PolicyEvaluationContext>;
18
27
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/policy/evaluation/context/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,MAAM,uBAAuB,GAAG;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACtD,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;CACnC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/policy/evaluation/context/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,MAAM,uBAAuB,GAAG;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACtD,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC;;;;;;;OAOG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CACvC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@authup/access",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.64",
4
+ "version": "1.0.0-beta.66",
5
5
  "description": "A library for evaluating permissions and policies.",
6
6
  "license": "Apache-2.0",
7
7
  "exports": {
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "homepage": "https://github.com/authup/authup#readme",
56
56
  "dependencies": {
57
- "@authup/errors": "^1.0.0-beta.64",
58
- "@authup/kit": "^1.0.0-beta.64",
57
+ "@authup/errors": "^1.0.0-beta.66",
58
+ "@authup/kit": "^1.0.0-beta.66",
59
59
  "@ebec/core": "^1.3.2",
60
60
  "@rapiq/adapter-memory": "^2.2.0",
61
61
  "@rapiq/core": "^2.2.0",
@@ -63,10 +63,10 @@
63
63
  "@validup/zod": "^2.0.1",
64
64
  "smob": "^1.6.1",
65
65
  "validup": "^2.0.1",
66
- "zod": "^4.5.4"
66
+ "zod": "^4.6.5"
67
67
  },
68
68
  "devDependencies": {
69
- "unplugin-swc": "^1.5.11",
69
+ "unplugin-swc": "^1.6.0",
70
70
  "vitest": "^4.0.14"
71
71
  },
72
72
  "publishConfig": {