@authup/access 1.0.0-beta.68 → 1.0.0-beta.70

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.
@@ -1 +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"}
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,CAiMhC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,iCAAiC,CACnD,KAAK,EAAE,gCAAgC,GACvC,OAAO,CAAC,oBAAoB,CAAC,CA0GhC"}
@@ -3,6 +3,7 @@ export * from './helpers';
3
3
  export * from './provider';
4
4
  export * from './evaluator';
5
5
  export * from './realm-scope';
6
+ export * from './record';
6
7
  export * from './types';
7
8
  export * from './authorization';
8
9
  //# 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;AACxB,cAAc,iBAAiB,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,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './module';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/permission/record/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { IPermissionEvaluator } from '../evaluator';
2
+ import type { RecordEvaluationContext, RecordUpdateEvaluationContext } from './types';
3
+ /**
4
+ * Throws a permission error unless `name` passes for the record: each grant's
5
+ * `realm_scope` is matched against the record's realm and its policies are
6
+ * evaluated against the record. An array of names must ALL pass, like
7
+ * `evaluate()`.
8
+ */
9
+ export declare function evaluateRecord(evaluator: IPermissionEvaluator, ctx: RecordEvaluationContext): Promise<void>;
10
+ /** {@link evaluateRecord} where ANY of the names suffices, like `evaluateOneOf()`. */
11
+ export declare function evaluateRecordOneOf(evaluator: IPermissionEvaluator, ctx: RecordEvaluationContext): Promise<void>;
12
+ /**
13
+ * {@link evaluateRecord} as a predicate. Only a permission error reads as
14
+ * `false`; anything else propagates, so a failure on the authorization path
15
+ * never turns into a quiet "not authorized".
16
+ */
17
+ export declare function reachesRecord(evaluator: IPermissionEvaluator, ctx: RecordEvaluationContext): Promise<boolean>;
18
+ /** {@link evaluateRecordOneOf} as a predicate, like {@link reachesRecord}. */
19
+ export declare function reachesRecordOneOf(evaluator: IPermissionEvaluator, ctx: RecordEvaluationContext): Promise<boolean>;
20
+ /**
21
+ * An update passes only when `name` passes for BOTH the stored row (the actor
22
+ * may only change a row it can already reach) and the updated row (the row
23
+ * must stay in reach afterwards). Evaluating the updated row alone lets an
24
+ * update move a row INTO reach.
25
+ */
26
+ export declare function evaluateRecordUpdate(evaluator: IPermissionEvaluator, ctx: RecordUpdateEvaluationContext): Promise<void>;
27
+ /**
28
+ * Whether a grant of `name` (any of, for an array) reaches every realm with
29
+ * no narrowing policy, i.e. `realm_scope: any`. Reads the `compile()`
30
+ * verdict, so it relies on the binding policy (`system.default`) being bound
31
+ * to the permission: without it a grant's reach is never evaluated and any
32
+ * grant compiles to `allow`. Fail-closed: a policy-bearing `any` grant
33
+ * compiles to `conditional` and reads as `false`.
34
+ */
35
+ export declare function hasUnboundedReach(evaluator: IPermissionEvaluator, name: string | string[]): Promise<boolean>;
36
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/permission/record/module.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAA+B,MAAM,cAAc,CAAC;AACtF,OAAO,KAAK,EACR,uBAAuB,EAEvB,6BAA6B,EAChC,MAAM,SAAS,CAAC;AAuDjB;;;;;GAKG;AACH,wBAAsB,cAAc,CAChC,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,uBAAuB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,sFAAsF;AACtF,wBAAsB,mBAAmB,CACrC,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,uBAAuB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAEf;AAeD;;;;GAIG;AACH,wBAAsB,aAAa,CAC/B,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,uBAAuB,GAC7B,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,8EAA8E;AAC9E,wBAAsB,kBAAkB,CACpC,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,uBAAuB,GAC7B,OAAO,CAAC,OAAO,CAAC,CAElB;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACtC,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,6BAA6B,GACnC,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACnC,SAAS,EAAE,oBAAoB,EAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GACxB,OAAO,CAAC,OAAO,CAAC,CAGlB"}
@@ -0,0 +1,41 @@
1
+ import type { PolicyData, PolicyInput } from '../../policy';
2
+ import type { PermissionEvaluationOptions } from '../evaluator';
3
+ /**
4
+ * The realm of the record a check is evaluated against: a realm id, `null`
5
+ * for a global row, or a list of either when every listed realm must be
6
+ * reached.
7
+ */
8
+ export type RecordRealm = string | null | (string | null)[];
9
+ /** One record a single-record check is evaluated against. */
10
+ export type RecordTarget = {
11
+ /**
12
+ * The RECORD's realm (`null` = global row), or the target realm on
13
+ * create. This is what each grant's `realm_scope` is matched against.
14
+ * It is distinct from `PermissionEvaluationContext.realmId`, which is the
15
+ * realm the PERMISSION is bound to. Required: `undefined` throws, so a
16
+ * caller cannot drop the realm by omission and neutral-pass every grant's
17
+ * `realm_scope`.
18
+ */
19
+ realm: RecordRealm;
20
+ /**
21
+ * The policy data the record is evaluated with: the row under
22
+ * `attributes` (for attribute policies on the grant; never synthesized,
23
+ * so without it an attribute policy stays pending), an identity, a custom
24
+ * key. Never mutated; must not carry `realmMatch`, which is set from
25
+ * `realm`.
26
+ */
27
+ data?: PolicyData | PolicyInput;
28
+ };
29
+ export type RecordEvaluationContext = RecordTarget & {
30
+ name: string | string[];
31
+ options?: PermissionEvaluationOptions;
32
+ };
33
+ export type RecordUpdateEvaluationContext = {
34
+ name: string | string[];
35
+ options?: PermissionEvaluationOptions;
36
+ /** The stored row: the actor must reach it to change it at all. */
37
+ current: RecordTarget;
38
+ /** The updated row: it must stay in reach afterwards. */
39
+ next: RecordTarget;
40
+ };
41
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/permission/record/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;AAE5D,6DAA6D;AAC7D,MAAM,MAAM,YAAY,GAAG;IACvB;;;;;;;OAOG;IACH,KAAK,EAAE,WAAW,CAAC;IACnB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG;IACjD,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IACxC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,2BAA2B,CAAC;IACtC,mEAAmE;IACnE,OAAO,EAAE,YAAY,CAAC;IACtB,yDAAyD;IACzD,IAAI,EAAE,YAAY,CAAC;CACtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../../../src/policy/built-in/identity/data/validator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,qBAAa,2BAA4B,SAAQ,SAAS,CAAC,kBAAkB,CAAC;IACjE,UAAU;CA+CtB"}
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../../../src/policy/built-in/identity/data/validator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AActD,qBAAa,2BAA4B,SAAQ,SAAS,CAAC,kBAAkB,CAAC;IACjE,UAAU;CAuDtB"}
@@ -1,3 +1,4 @@
1
+ import type { PermissionPolicyBinding } from '../../../permission/types';
1
2
  import type { BasePolicy } from '../../types';
2
3
  export interface IdentityPolicy extends BasePolicy {
3
4
  /**
@@ -26,5 +27,13 @@ export type IdentityPolicyData = {
26
27
  * Realm name associated with identity.
27
28
  */
28
29
  realmName?: string | null;
30
+ /**
31
+ * The grants the identity holds. The permission binding evaluator reads
32
+ * them from here rather than loading them, so evaluation is a function of
33
+ * the data alone. Whoever places an identity in the policy data places
34
+ * its grants with it, and an identity without them holds none we could
35
+ * prove.
36
+ */
37
+ grants?: PermissionPolicyBinding[];
29
38
  };
30
39
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/identity/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/identity/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,uBAAuB,EAAE,CAAA;CACrC,CAAC"}
@@ -1,21 +1,21 @@
1
1
  import type { PermissionPolicyBinding, PermissionPolicyBindingAggregated } from '../../../permission/types';
2
2
  import type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';
3
- import type { IdentityPolicyData } from '../identity';
4
3
  import { IdentityPolicyEvaluator } from '../identity';
4
+ import type { IdentityPolicyData } from '../identity';
5
5
  import { RealmMatchPolicyEvaluator } from '../realm-match';
6
6
  import { PermissionBindingPolicyValidator } from './validator';
7
- type IdentityPermissionProvider = {
8
- getFor(identity: IdentityPolicyData): Promise<PermissionPolicyBinding[]>;
9
- };
10
7
  export declare class IdentityPermissionBindingPolicyEvaluator implements IPolicyEvaluator {
11
8
  protected validator: PermissionBindingPolicyValidator;
12
9
  protected identityEvaluator: IdentityPolicyEvaluator;
13
10
  protected realmMatchEvaluator: RealmMatchPolicyEvaluator;
14
- protected identityPermissionProvider: IdentityPermissionProvider;
15
- constructor(identityPermissionProvider: IdentityPermissionProvider);
11
+ constructor();
16
12
  requires(): string[];
17
13
  accessData(ctx: PolicyEvaluationContext): Promise<PermissionPolicyBindingAggregated | null>;
14
+ /**
15
+ * The grants the identity holds. An identity carrying none is missing
16
+ * data, which throws a PolicyError carrying the refusing issue.
17
+ */
18
+ accessGrants(ctx: PolicyEvaluationContext, identity: IdentityPolicyData): PermissionPolicyBinding[];
18
19
  evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult>;
19
20
  }
20
- export {};
21
21
  //# sourceMappingURL=identity-evaluator.d.ts.map
@@ -1 +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,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AErD,SAAS,CAAC,mBAAmB,EAAG,yBAAyB,CAAC;;IAQ1D,QAAQ,IAAK,MAAM,EAAE;IASf,UAAU,CAAC,GAAG,EAAE,uBAAuB,GAAI,OAAO,CAAC,iCAAiC,GAAG,IAAI,CAAC;IAiBlG;;;OAGG;IACH,YAAY,CACR,GAAG,EAAE,uBAAuB,EAC5B,QAAQ,EAAE,kBAAkB,GAC5B,uBAAuB,EAAE;IAcvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAuO5G"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@authup/access",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.68",
5
- "description": "A library for evaluating permissions and policies.",
4
+ "version": "1.0.0-beta.70",
5
+ "description": "Evaluate Authup permissions and policies in your own process, with the same engine the server uses.",
6
6
  "license": "Apache-2.0",
7
7
  "exports": {
8
8
  "./package.json": "./package.json",
@@ -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.68",
58
- "@authup/kit": "^1.0.0-beta.68",
57
+ "@authup/errors": "^1.0.0-beta.70",
58
+ "@authup/kit": "^1.0.0-beta.70",
59
59
  "@ebec/core": "^1.3.2",
60
60
  "@rapiq/adapter-memory": "^2.4.0",
61
61
  "@rapiq/core": "^2.4.0",
@@ -63,11 +63,11 @@
63
63
  "@validup/zod": "^2.0.1",
64
64
  "smob": "^1.6.1",
65
65
  "validup": "^2.0.1",
66
- "zod": "^4.6.5"
66
+ "zod": "^4.6.7"
67
67
  },
68
68
  "devDependencies": {
69
- "unplugin-swc": "^1.6.0",
70
- "vitest": "^4.0.14"
69
+ "unplugin-swc": "^2.0.0",
70
+ "vitest": "^5.0.3"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public"