@astram/core 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/admin-service.d.ts +1 -1
- package/dist/admin/command/grants.js +3 -3
- package/dist/admin/command/grants.js.map +1 -1
- package/dist/admin/command/invitations.d.ts +2 -2
- package/dist/admin/command/invitations.js +8 -8
- package/dist/admin/command/invitations.js.map +1 -1
- package/dist/admin/command/service-accounts.d.ts +1 -1
- package/dist/admin/command/service-accounts.js +1 -1
- package/dist/admin/query/simulate.d.ts.map +1 -1
- package/dist/admin/query/simulate.js +4 -0
- package/dist/admin/query/simulate.js.map +1 -1
- package/dist/admin/safeguards-impl.d.ts +2 -2
- package/dist/admin/safeguards-impl.js +9 -9
- package/dist/admin/safeguards-impl.js.map +1 -1
- package/dist/admin/safeguards.d.ts +4 -4
- package/dist/admin/safeguards.js +4 -4
- package/dist/admin/types.d.ts +1 -1
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/authentication/authenticator.d.ts +2 -2
- package/dist/authentication/authenticator.js +2 -2
- package/dist/authentication/authenticator.js.map +1 -1
- package/dist/authentication/credential-resolver.d.ts +1 -1
- package/dist/authorization/cross-tenant/grant-evaluator.d.ts +2 -2
- package/dist/authorization/cross-tenant/grant-evaluator.js +2 -2
- package/dist/authorization/decision-authority.d.ts +2 -2
- package/dist/authorization/decision-authority.d.ts.map +1 -1
- package/dist/authorization/decision-authority.js +11 -3
- package/dist/authorization/decision-authority.js.map +1 -1
- package/dist/authorization/errors.d.ts +37 -0
- package/dist/authorization/errors.d.ts.map +1 -1
- package/dist/authorization/errors.js +43 -0
- package/dist/authorization/errors.js.map +1 -1
- package/dist/authorization/gates/object-type.d.ts +2 -2
- package/dist/authorization/gates/object-type.d.ts.map +1 -1
- package/dist/authorization/gates/object-type.js +20 -7
- package/dist/authorization/gates/object-type.js.map +1 -1
- package/dist/authorization/gates/tenant.d.ts +3 -3
- package/dist/authorization/gates/tenant.js +7 -7
- package/dist/authorization/gates/tenant.js.map +1 -1
- package/dist/authorization/index.d.ts +23 -4
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +29 -4
- package/dist/authorization/index.js.map +1 -1
- package/dist/authorization/ports.d.ts +3 -3
- package/dist/authorization/reason-codes.d.ts +7 -1
- package/dist/authorization/reason-codes.d.ts.map +1 -1
- package/dist/authorization/reason-codes.js +9 -1
- package/dist/authorization/reason-codes.js.map +1 -1
- package/dist/authorization/record/owner-baseline.d.ts +43 -0
- package/dist/authorization/record/owner-baseline.d.ts.map +1 -0
- package/dist/authorization/record/owner-baseline.js +72 -0
- package/dist/authorization/record/owner-baseline.js.map +1 -0
- package/dist/authorization/record/permit-tier.d.ts.map +1 -1
- package/dist/authorization/record/permit-tier.js +16 -5
- package/dist/authorization/record/permit-tier.js.map +1 -1
- package/dist/identity/broker.d.ts +8 -8
- package/dist/identity/broker.d.ts.map +1 -1
- package/dist/identity/broker.js +8 -8
- package/dist/identity/broker.js.map +1 -1
- package/dist/identity/claim-mapper.d.ts +8 -8
- package/dist/identity/claim-mapper.d.ts.map +1 -1
- package/dist/identity/claim-mapper.js +4 -4
- package/dist/identity/index.d.ts +2 -2
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/internal-adapter.d.ts +12 -12
- package/dist/identity/internal-adapter.d.ts.map +1 -1
- package/dist/identity/internal-adapter.js +9 -9
- package/dist/identity/internal-adapter.js.map +1 -1
- package/dist/metadata/index.d.ts +43 -0
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/index.js +6 -0
- package/dist/metadata/index.js.map +1 -1
- package/dist/metadata/registry.d.ts.map +1 -1
- package/dist/metadata/registry.js +2 -1
- package/dist/metadata/registry.js.map +1 -1
- package/dist-cjs/admin/admin-service.js +159 -0
- package/dist-cjs/admin/command/grants.js +200 -0
- package/dist-cjs/admin/command/index.js +38 -0
- package/dist-cjs/admin/command/invitations.js +246 -0
- package/dist-cjs/admin/command/permissions.js +69 -0
- package/dist-cjs/admin/command/pipeline.js +110 -0
- package/dist-cjs/admin/command/policies.js +223 -0
- package/dist-cjs/admin/command/service-accounts.js +278 -0
- package/dist-cjs/admin/command/service.js +130 -0
- package/dist-cjs/admin/command/tiers.js +81 -0
- package/dist-cjs/admin/index.js +78 -0
- package/dist-cjs/admin/ports.js +41 -0
- package/dist-cjs/admin/query/audit-view.js +88 -0
- package/dist-cjs/admin/query/catalog.js +174 -0
- package/dist-cjs/admin/query/explain.js +149 -0
- package/dist-cjs/admin/query/index.js +74 -0
- package/dist-cjs/admin/query/simulate.js +98 -0
- package/dist-cjs/admin/safeguards-impl.js +322 -0
- package/dist-cjs/admin/safeguards.js +95 -0
- package/dist-cjs/admin/types.js +40 -0
- package/dist-cjs/audit/audit-recorder.js +269 -0
- package/dist-cjs/audit/canonicalize.js +176 -0
- package/dist-cjs/audit/errors.js +44 -0
- package/dist-cjs/audit/index.js +39 -0
- package/dist-cjs/audit/ports.js +27 -0
- package/dist-cjs/audit/sensitive.js +162 -0
- package/dist-cjs/audit/walk.js +123 -0
- package/dist-cjs/authentication/authenticator.js +210 -0
- package/dist-cjs/authentication/credential-resolver.js +21 -0
- package/dist-cjs/authentication/index.js +42 -0
- package/dist-cjs/authentication/password-hasher.js +21 -0
- package/dist-cjs/authentication/totp.js +155 -0
- package/dist-cjs/authorization/cross-tenant/grant-evaluator.js +167 -0
- package/dist-cjs/authorization/decision-authority.js +213 -0
- package/dist-cjs/authorization/default-gates.js +53 -0
- package/dist-cjs/authorization/delegation/operation-identity.js +226 -0
- package/dist-cjs/authorization/errors.js +110 -0
- package/dist-cjs/authorization/gates/object-type.js +192 -0
- package/dist-cjs/authorization/gates/tenant.js +89 -0
- package/dist-cjs/authorization/gates/wiring.js +59 -0
- package/dist-cjs/authorization/index.js +124 -0
- package/dist-cjs/authorization/ports.js +36 -0
- package/dist-cjs/authorization/reason-codes.js +117 -0
- package/dist-cjs/authorization/record/owner-baseline.js +74 -0
- package/dist-cjs/authorization/record/permit-tier.js +92 -0
- package/dist-cjs/authorization/record/rule-evaluator.js +128 -0
- package/dist-cjs/authorization/record/shares.js +110 -0
- package/dist-cjs/identity/broker.js +139 -0
- package/dist-cjs/identity/claim-mapper.js +51 -0
- package/dist-cjs/identity/index.js +39 -0
- package/dist-cjs/identity/internal-adapter.js +91 -0
- package/dist-cjs/index.js +63 -0
- package/dist-cjs/metadata/completeness.js +108 -0
- package/dist-cjs/metadata/dependencies.js +110 -0
- package/dist-cjs/metadata/index.js +76 -0
- package/dist-cjs/metadata/registry.js +207 -0
- package/dist-cjs/package.json +3 -0
- package/dist-cjs/risk/evaluator.js +63 -0
- package/dist-cjs/risk/index.js +35 -0
- package/dist-cjs/risk/risk-engine.js +290 -0
- package/dist-cjs/risk/signals.js +106 -0
- package/dist-cjs/risk/thresholds.js +63 -0
- package/dist-cjs/session/index.js +35 -0
- package/dist-cjs/session/lifetimes.js +70 -0
- package/dist-cjs/session/ports.js +23 -0
- package/dist-cjs/session/session-authority.js +398 -0
- package/package.json +13 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decision-authority.js","sourceRoot":"","sources":["../../src/authorization/decision-authority.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"decision-authority.js","sourceRoot":"","sources":["../../src/authorization/decision-authority.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAgBzD,OAAO,EACL,KAAK,EACL,aAAa,EACb,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAqB3B,sEAAsE;AACtE,MAAM,UAAU,YAAY;IAC1B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9B,C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CAAC;QAED,6EAA6E;QAC7E,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9D,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,OAAO,CAAC,QAAQ,CAAC;QACrD,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO,KAAK,EAAE,CAAC;QAE7C,8EAA8E;QAC9E,4EAA4E;QAC5E,wEAAwE;QACxE,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAKD;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAoC;IAEpC,OAAO,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -18,6 +18,23 @@
|
|
|
18
18
|
*
|
|
19
19
|
* ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
|
|
20
20
|
*/
|
|
21
|
+
/**
|
|
22
|
+
* ⛔ CROSS-BUILD BRAND (ADR-0016 hardening). `@astram/core` is DUAL-BUILT (ESM `dist/` +
|
|
23
|
+
* CJS `dist-cjs/`). A guard adapter compiled against one build can throw an
|
|
24
|
+
* `AuthorizationUnavailableError` whose class is a DIFFERENT realized constructor from the
|
|
25
|
+
* one the wiring loaded in the other build — so a bare `err instanceof
|
|
26
|
+
* AuthorizationUnavailableError` returns FALSE across the build boundary, and a genuine
|
|
27
|
+
* store OUTAGE would be mis-classified as `deny_by_default` (403 terminal) instead of the
|
|
28
|
+
* retryable 503 the ADR mandates.
|
|
29
|
+
*
|
|
30
|
+
* `Symbol.for(...)` is keyed on the GLOBAL symbol registry, shared across every module
|
|
31
|
+
* realm/build in the process — so a value carrying this brand is recognizable regardless of
|
|
32
|
+
* WHICH core build minted it. It is the robust, cross-realm transient signal;
|
|
33
|
+
* {@link isAuthorizationUnavailable} tests `instanceof` FIRST (fast, primary) then this
|
|
34
|
+
* brand (the dual-build fallback). A coincidental `name` alone is deliberately NOT trusted
|
|
35
|
+
* as the sole signal (see the guard).
|
|
36
|
+
*/
|
|
37
|
+
export declare const AUTHORIZATION_UNAVAILABLE_BRAND: unique symbol;
|
|
21
38
|
/**
|
|
22
39
|
* A TYPED, transient-unavailable signal thrown by `decide()` ONLY when an injected
|
|
23
40
|
* port genuinely CANNOT answer (ADR-0016) — e.g. the hot-facts read yields
|
|
@@ -49,6 +66,26 @@ export declare class AuthorizationUnavailableError extends Error {
|
|
|
49
66
|
* never returned to the caller, never reveals whether a resource exists.
|
|
50
67
|
*/
|
|
51
68
|
readonly detail?: string;
|
|
69
|
+
/**
|
|
70
|
+
* The global-registry brand (see {@link AUTHORIZATION_UNAVAILABLE_BRAND}). Stamped `true`
|
|
71
|
+
* on every instance so {@link isAuthorizationUnavailable} recognizes the error across the
|
|
72
|
+
* ESM/CJS dual-build boundary, where `instanceof` alone can be false.
|
|
73
|
+
*/
|
|
74
|
+
readonly [AUTHORIZATION_UNAVAILABLE_BRAND]: true;
|
|
52
75
|
constructor(detail?: string, cause?: unknown);
|
|
53
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The robust, dual-build-safe transient test: is `err` an {@link AuthorizationUnavailableError}
|
|
79
|
+
* (ADR-0016 transient signal) regardless of WHICH core build (ESM `dist/` vs CJS `dist-cjs/`)
|
|
80
|
+
* minted it?
|
|
81
|
+
*
|
|
82
|
+
* Checks `instanceof` FIRST (primary, fast, exact within one build), then falls back to the
|
|
83
|
+
* GLOBAL-registry {@link AUTHORIZATION_UNAVAILABLE_BRAND} (cross-build/cross-realm safe). The
|
|
84
|
+
* brand is a `Symbol.for(...)` on the process-shared registry, so a differently-realized
|
|
85
|
+
* constructor still carries the SAME brand symbol — impossible to spoof by a coincidental
|
|
86
|
+
* `name` (we do NOT trust `name` as the sole signal; only the brand or a true `instanceof`).
|
|
87
|
+
* An ordinary `Error` has neither → returns false → the caller fail-closes it to
|
|
88
|
+
* `deny_by_default` (the ordinary-error path is unchanged).
|
|
89
|
+
*/
|
|
90
|
+
export declare function isAuthorizationUnavailable(err: unknown): err is AuthorizationUnavailableError;
|
|
54
91
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/authorization/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;IACtD;;;;OAIG;IACH,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;IAElC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/authorization/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,+BAA+B,EAAE,OAAO,MAEpD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;IACtD;;;;OAIG;IACH,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;IAElC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,CAAC,+BAA+B,CAAC,EAAG,IAAI,CAAU;gBAE/C,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAQ7C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,6BAA6B,CAOtC"}
|
|
@@ -18,6 +18,23 @@
|
|
|
18
18
|
*
|
|
19
19
|
* ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
|
|
20
20
|
*/
|
|
21
|
+
/**
|
|
22
|
+
* ⛔ CROSS-BUILD BRAND (ADR-0016 hardening). `@astram/core` is DUAL-BUILT (ESM `dist/` +
|
|
23
|
+
* CJS `dist-cjs/`). A guard adapter compiled against one build can throw an
|
|
24
|
+
* `AuthorizationUnavailableError` whose class is a DIFFERENT realized constructor from the
|
|
25
|
+
* one the wiring loaded in the other build — so a bare `err instanceof
|
|
26
|
+
* AuthorizationUnavailableError` returns FALSE across the build boundary, and a genuine
|
|
27
|
+
* store OUTAGE would be mis-classified as `deny_by_default` (403 terminal) instead of the
|
|
28
|
+
* retryable 503 the ADR mandates.
|
|
29
|
+
*
|
|
30
|
+
* `Symbol.for(...)` is keyed on the GLOBAL symbol registry, shared across every module
|
|
31
|
+
* realm/build in the process — so a value carrying this brand is recognizable regardless of
|
|
32
|
+
* WHICH core build minted it. It is the robust, cross-realm transient signal;
|
|
33
|
+
* {@link isAuthorizationUnavailable} tests `instanceof` FIRST (fast, primary) then this
|
|
34
|
+
* brand (the dual-build fallback). A coincidental `name` alone is deliberately NOT trusted
|
|
35
|
+
* as the sole signal (see the guard).
|
|
36
|
+
*/
|
|
37
|
+
export const AUTHORIZATION_UNAVAILABLE_BRAND = Symbol.for('astram.core.AuthorizationUnavailable');
|
|
21
38
|
/**
|
|
22
39
|
* A TYPED, transient-unavailable signal thrown by `decide()` ONLY when an injected
|
|
23
40
|
* port genuinely CANNOT answer (ADR-0016) — e.g. the hot-facts read yields
|
|
@@ -49,6 +66,12 @@ export class AuthorizationUnavailableError extends Error {
|
|
|
49
66
|
* never returned to the caller, never reveals whether a resource exists.
|
|
50
67
|
*/
|
|
51
68
|
detail;
|
|
69
|
+
/**
|
|
70
|
+
* The global-registry brand (see {@link AUTHORIZATION_UNAVAILABLE_BRAND}). Stamped `true`
|
|
71
|
+
* on every instance so {@link isAuthorizationUnavailable} recognizes the error across the
|
|
72
|
+
* ESM/CJS dual-build boundary, where `instanceof` alone can be false.
|
|
73
|
+
*/
|
|
74
|
+
[AUTHORIZATION_UNAVAILABLE_BRAND] = true;
|
|
52
75
|
constructor(detail, cause) {
|
|
53
76
|
super(detail ?? 'authorization_unavailable');
|
|
54
77
|
this.name = 'AuthorizationUnavailableError';
|
|
@@ -60,4 +83,24 @@ export class AuthorizationUnavailableError extends Error {
|
|
|
60
83
|
Object.setPrototypeOf(this, AuthorizationUnavailableError.prototype);
|
|
61
84
|
}
|
|
62
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* The robust, dual-build-safe transient test: is `err` an {@link AuthorizationUnavailableError}
|
|
88
|
+
* (ADR-0016 transient signal) regardless of WHICH core build (ESM `dist/` vs CJS `dist-cjs/`)
|
|
89
|
+
* minted it?
|
|
90
|
+
*
|
|
91
|
+
* Checks `instanceof` FIRST (primary, fast, exact within one build), then falls back to the
|
|
92
|
+
* GLOBAL-registry {@link AUTHORIZATION_UNAVAILABLE_BRAND} (cross-build/cross-realm safe). The
|
|
93
|
+
* brand is a `Symbol.for(...)` on the process-shared registry, so a differently-realized
|
|
94
|
+
* constructor still carries the SAME brand symbol — impossible to spoof by a coincidental
|
|
95
|
+
* `name` (we do NOT trust `name` as the sole signal; only the brand or a true `instanceof`).
|
|
96
|
+
* An ordinary `Error` has neither → returns false → the caller fail-closes it to
|
|
97
|
+
* `deny_by_default` (the ordinary-error path is unchanged).
|
|
98
|
+
*/
|
|
99
|
+
export function isAuthorizationUnavailable(err) {
|
|
100
|
+
if (err instanceof AuthorizationUnavailableError)
|
|
101
|
+
return true;
|
|
102
|
+
return (typeof err === 'object' &&
|
|
103
|
+
err !== null &&
|
|
104
|
+
err[AUTHORIZATION_UNAVAILABLE_BRAND] === true);
|
|
105
|
+
}
|
|
63
106
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/authorization/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD;;;;OAIG;IACe,KAAK,CAAW;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;;;;;;;GAYG;AACH,MAAM,UAAU,0BAA0B,CACxC,GAAY;IAEZ,IAAI,GAAG,YAAY,6BAA6B;QAAE,OAAO,IAAI,CAAC;IAC9D,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACX,GAAoC,CAAC,+BAA+B,CAAC,KAAK,IAAI,CAChF,CAAC;AACJ,CAAC"}
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
* view here and never mutate the frozen slot.)
|
|
31
31
|
*
|
|
32
32
|
* ── Cross-tenant case (§7.3.3): when the tenant DIFFERS (and the principal is not
|
|
33
|
-
* the
|
|
33
|
+
* the root), gate 3 only let evaluation proceed BECAUSE a
|
|
34
34
|
* cross-tenant grant covers it — and that grant's scope + action-ceiling SERVES
|
|
35
35
|
* AS the object-type grant. Coarse facts are the WRONG-tenant facts, so this
|
|
36
36
|
* gate does NOT consult them; it RE-RESOLVES the grant via
|
|
37
37
|
* {@link CrossTenantGrantPort} (gate 3 is pure and stashed nothing) and, if the
|
|
38
38
|
* action is in-ceiling, `continue`s (record level → gate 6 runs) or `allow`s
|
|
39
|
-
* (feature/object-type level → terminates). A
|
|
39
|
+
* (feature/object-type level → terminates). A root crossing tenants is NOT
|
|
40
40
|
* grant-backed; it takes the normal coarse-grants path below.
|
|
41
41
|
*
|
|
42
42
|
* ── Decision:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-type.d.ts","sourceRoot":"","sources":["../../../src/authorization/gates/object-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAGH,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"object-type.d.ts","sourceRoot":"","sources":["../../../src/authorization/gates/object-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAGH,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AA2ClC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,gBAAgB,CAyEvD"}
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
* view here and never mutate the frozen slot.)
|
|
31
31
|
*
|
|
32
32
|
* ── Cross-tenant case (§7.3.3): when the tenant DIFFERS (and the principal is not
|
|
33
|
-
* the
|
|
33
|
+
* the root), gate 3 only let evaluation proceed BECAUSE a
|
|
34
34
|
* cross-tenant grant covers it — and that grant's scope + action-ceiling SERVES
|
|
35
35
|
* AS the object-type grant. Coarse facts are the WRONG-tenant facts, so this
|
|
36
36
|
* gate does NOT consult them; it RE-RESOLVES the grant via
|
|
37
37
|
* {@link CrossTenantGrantPort} (gate 3 is pure and stashed nothing) and, if the
|
|
38
38
|
* action is in-ceiling, `continue`s (record level → gate 6 runs) or `allow`s
|
|
39
|
-
* (feature/object-type level → terminates). A
|
|
39
|
+
* (feature/object-type level → terminates). A root crossing tenants is NOT
|
|
40
40
|
* grant-backed; it takes the normal coarse-grants path below.
|
|
41
41
|
*
|
|
42
42
|
* ── Decision:
|
|
@@ -52,8 +52,9 @@
|
|
|
52
52
|
* ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
|
|
53
53
|
*/
|
|
54
54
|
import { gateAllow, gateContinue, gateDeny, } from '../decision-authority.js';
|
|
55
|
-
import { denyMissingObjectTypeGrant, strictTrue } from '../reason-codes.js';
|
|
55
|
+
import { denyMissingObjectTypeGrant, denyRootDataPlane, strictTrue } from '../reason-codes.js';
|
|
56
56
|
import { isCrossTenantGrantApplicable } from '../cross-tenant/grant-evaluator.js';
|
|
57
|
+
import { resolvePlane } from '../../metadata/index.js';
|
|
57
58
|
/**
|
|
58
59
|
* A minimal, defensive typed VIEW of the opaque `cachedFacts` slot (ADR-0011). We
|
|
59
60
|
* do NOT trust the slot to already be a well-formed {@link CoarseGrants}; we probe
|
|
@@ -101,14 +102,14 @@ export function createObjectTypeGate() {
|
|
|
101
102
|
return async function objectTypeGate(ctx) {
|
|
102
103
|
const { principal, action, resource, deps } = ctx;
|
|
103
104
|
const isRecordLevel = resource.level === 'record';
|
|
104
|
-
// ── Cross-tenant grant path (§7.3.3): a non-
|
|
105
|
+
// ── Cross-tenant grant path (§7.3.3): a non-root reaching a foreign
|
|
105
106
|
// tenant proceeded past gate 3 ONLY via a cross-tenant grant, whose scope +
|
|
106
107
|
// ceiling SERVES AS the object-type grant. Re-resolve it here (gate 3 is
|
|
107
|
-
// pure), NOT the wrong-tenant coarse facts.
|
|
108
|
+
// pure), NOT the wrong-tenant coarse facts. Root is not grant-backed;
|
|
108
109
|
// it falls through to the coarse-grants path.
|
|
109
110
|
const crossesTenant = resource.tenantId !== undefined &&
|
|
110
111
|
principal.tenantId !== resource.tenantId &&
|
|
111
|
-
!strictTrue(principal.
|
|
112
|
+
!strictTrue(principal.isRoot);
|
|
112
113
|
if (crossesTenant) {
|
|
113
114
|
// Re-resolve the grant through the SINGLE-SOURCE cross-tenant helper (TEAM C)
|
|
114
115
|
// so gates 3/5/6 share ONE ceiling+scope+expiry implementation (RULING 1 /
|
|
@@ -129,7 +130,7 @@ export function createObjectTypeGate() {
|
|
|
129
130
|
// No covering grant on the foreign tenant ⇒ no object-type grant applies.
|
|
130
131
|
return gateDeny(denyMissingObjectTypeGrant());
|
|
131
132
|
}
|
|
132
|
-
// ── Same-tenant (or
|
|
133
|
+
// ── Same-tenant (or root) path — coarse feature/object-type grants
|
|
133
134
|
// (ADR-0011). Derive the required stable permission key by re-resolving the
|
|
134
135
|
// registered action over the frozen registry surface.
|
|
135
136
|
const registered = deps.registry
|
|
@@ -140,6 +141,18 @@ export function createObjectTypeGate() {
|
|
|
140
141
|
return gateDeny(denyMissingObjectTypeGrant());
|
|
141
142
|
}
|
|
142
143
|
const requiredKey = registered.permissionKey;
|
|
144
|
+
// ── ROOT CAP (§0/§2, ISO A.8.2 / A.5.3): a root is
|
|
145
|
+
// control-plane ONLY. Deny every data-plane capability BY CONSTRUCTION —
|
|
146
|
+
// grant-independent (even a fully-granted root is denied). Control-plane
|
|
147
|
+
// capabilities are allowed WITHOUT a grant (root's authority is the flag +
|
|
148
|
+
// plane classification, not RBAC grants). Default plane is `data` → a
|
|
149
|
+
// forgotten classification denies root (fail-safe).
|
|
150
|
+
if (strictTrue(principal.isRoot)) {
|
|
151
|
+
if (resolvePlane(registered.action) === 'data') {
|
|
152
|
+
return gateDeny(denyRootDataPlane());
|
|
153
|
+
}
|
|
154
|
+
return isRecordLevel ? gateContinue() : gateAllow();
|
|
155
|
+
}
|
|
143
156
|
// Hot path: prefer the request's cached facts when they are FRESH; reload on a
|
|
144
157
|
// stale version or an unusable cache.
|
|
145
158
|
const grants = await resolveCoarseGrants(ctx, requiredKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-type.js","sourceRoot":"","sources":["../../../src/authorization/gates/object-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAGH,OAAO,EACL,SAAS,EACT,YAAY,EACZ,QAAQ,GAIT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"object-type.js","sourceRoot":"","sources":["../../../src/authorization/gates/object-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAGH,OAAO,EACL,SAAS,EACT,YAAY,EACZ,QAAQ,GAIT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,YAAY,EAA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AAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The tenant boundary is the platform's DEFAULT authorization boundary (§7.3): a
|
|
5
5
|
* principal may only reach a resource its own tenant owns, UNLESS it is the
|
|
6
|
-
*
|
|
6
|
+
* root (break-glass) or an active, consented cross-tenant grant
|
|
7
7
|
* (ADR-0009) lets evaluation PROCEED. This gate can ONLY block (`deny`) or let
|
|
8
8
|
* evaluation continue (`continue`) — it NEVER returns `allow`. An `allow` from
|
|
9
9
|
* the tenant gate would be a fail-open (the pipeline treats an unexpected `allow`
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* carries no instance tenant) ⇒ `continue`. A feature/object-type-level
|
|
19
19
|
* resource with no `tenantId` is same-tenant BY CONSTRUCTION — there is no
|
|
20
20
|
* foreign instance to cross into, so it is the principal's own tenant.
|
|
21
|
-
* 2. MISMATCH +
|
|
21
|
+
* 2. MISMATCH + root (STRICT `=== true`) ⇒ `continue` (break-glass,
|
|
22
22
|
* audited by a later layer — not this gate's concern).
|
|
23
|
-
* 3. MISMATCH + not
|
|
23
|
+
* 3. MISMATCH + not root ⇒ consult {@link CrossTenantGrantPort}:
|
|
24
24
|
* - an ACTIVE grant whose action-ceiling INCLUDES this action (STRICT
|
|
25
25
|
* membership) ⇒ `continue` (proceed only; it confers no object-type/record
|
|
26
26
|
* permission — those gates still run);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The tenant boundary is the platform's DEFAULT authorization boundary (§7.3): a
|
|
5
5
|
* principal may only reach a resource its own tenant owns, UNLESS it is the
|
|
6
|
-
*
|
|
6
|
+
* root (break-glass) or an active, consented cross-tenant grant
|
|
7
7
|
* (ADR-0009) lets evaluation PROCEED. This gate can ONLY block (`deny`) or let
|
|
8
8
|
* evaluation continue (`continue`) — it NEVER returns `allow`. An `allow` from
|
|
9
9
|
* the tenant gate would be a fail-open (the pipeline treats an unexpected `allow`
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* carries no instance tenant) ⇒ `continue`. A feature/object-type-level
|
|
19
19
|
* resource with no `tenantId` is same-tenant BY CONSTRUCTION — there is no
|
|
20
20
|
* foreign instance to cross into, so it is the principal's own tenant.
|
|
21
|
-
* 2. MISMATCH +
|
|
21
|
+
* 2. MISMATCH + root (STRICT `=== true`) ⇒ `continue` (break-glass,
|
|
22
22
|
* audited by a later layer — not this gate's concern).
|
|
23
|
-
* 3. MISMATCH + not
|
|
23
|
+
* 3. MISMATCH + not root ⇒ consult {@link CrossTenantGrantPort}:
|
|
24
24
|
* - an ACTIVE grant whose action-ceiling INCLUDES this action (STRICT
|
|
25
25
|
* membership) ⇒ `continue` (proceed only; it confers no object-type/record
|
|
26
26
|
* permission — those gates still run);
|
|
@@ -56,12 +56,12 @@ export function createTenantGate() {
|
|
|
56
56
|
if (resource.tenantId === undefined || principal.tenantId === resource.tenantId) {
|
|
57
57
|
return gateContinue();
|
|
58
58
|
}
|
|
59
|
-
// 2. Mismatch +
|
|
60
|
-
// non-boolean
|
|
61
|
-
if (strictTrue(principal.
|
|
59
|
+
// 2. Mismatch + root (break-glass). STRICT === true — a truthy
|
|
60
|
+
// non-boolean root flag must NOT bypass the tenant boundary.
|
|
61
|
+
if (strictTrue(principal.isRoot)) {
|
|
62
62
|
return gateContinue();
|
|
63
63
|
}
|
|
64
|
-
// 3. Mismatch + not
|
|
64
|
+
// 3. Mismatch + not root — the ONLY sanctioned crossing is an active,
|
|
65
65
|
// consented cross-tenant grant (ADR-0009). Resolve applicability through the
|
|
66
66
|
// SINGLE-SOURCE cross-tenant helper (TEAM C) so gates 3/5/6 share ONE
|
|
67
67
|
// ceiling+scope+expiry implementation (RULING 1 / AC-13 defense-in-depth): a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant.js","sourceRoot":"","sources":["../../../src/authorization/gates/tenant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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AA+D;QAC/D,gEAAgE;QAChE,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YACjC,OAAO,YAAY,EAAE,CAAC;QACxB,CAAC;QAED,sEAAsE;QACtE,gFAAgF;QAChF,yEAAyE;QACzE,gFAAgF;QAChF,8EAA8E;QAC9E,gFAAgF;QAChF,iFAAiF;QACjF,8EAA8E;QAC9E,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,4BAA4B,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC/E,SAAS;YACT,MAAM;YACN,QAAQ;SACT,CAAC,CAAC;QAEH,IAAI,UAAU,EAAE,CAAC;YACf,0EAA0E;YAC1E,0EAA0E;YAC1E,OAAO,YAAY,EAAE,CAAC;QACxB,CAAC;QAED,gFAAgF;QAChF,iEAAiE;QACjE,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -46,16 +46,34 @@ export type PermissionKey = string & {
|
|
|
46
46
|
* A single-source constant so producers/consumers can't drift.
|
|
47
47
|
*/
|
|
48
48
|
export declare const PERMISSION_KEY_SEPARATOR: ":";
|
|
49
|
+
/**
|
|
50
|
+
* The required format for each permission-key segment (moduleKey / typeKey /
|
|
51
|
+
* actionKey): `snake_case` — a lowercase letter, then lowercase letters, digits,
|
|
52
|
+
* and underscores. Single-source so the rule can't drift between producers.
|
|
53
|
+
* Enforced in {@link derivePermissionKey} as a fail-loud reject (never normalized),
|
|
54
|
+
* so every consumer app names its modules/types/actions uniformly and a casing
|
|
55
|
+
* typo fails at boot instead of silently denying at request time.
|
|
56
|
+
*/
|
|
57
|
+
export declare const SEGMENT_FORMAT: RegExp;
|
|
49
58
|
/**
|
|
50
59
|
* Derive the stable permission identity `feature:object:action` from a module's
|
|
51
60
|
* `moduleKey`, an object type's `typeKey`, and an action's `actionKey`
|
|
52
61
|
* (ADR-0010, confirmed decision #1). PURE — no I/O, no state, deterministic.
|
|
53
62
|
*
|
|
54
63
|
* This is the ONLY sanctioned way to construct a {@link PermissionKey}; grants
|
|
55
|
-
* bind to its result. Segments must be non-empty
|
|
56
|
-
* the key round-trips unambiguously
|
|
64
|
+
* bind to its result. Segments must be non-empty, free of the separator, and in
|
|
65
|
+
* `snake_case` so the key round-trips unambiguously AND every consumer app names
|
|
66
|
+
* its modules/types/actions uniformly.
|
|
67
|
+
*
|
|
68
|
+
* `snake_case` = {@link SEGMENT_FORMAT} = lowercase start, then lowercase letters,
|
|
69
|
+
* digits, and underscores (`^[a-z][a-z0-9_]*$`). This is enforced here — the single
|
|
70
|
+
* sanctioned key constructor — so a stray `CompanyBranch`/`company-branch` typeKey
|
|
71
|
+
* is a HARD, loud failure at boot (when the registry builds keys), never a silent
|
|
72
|
+
* casing mismatch that denies at request time. It is a format REJECT, never a
|
|
73
|
+
* normalization: the key is used exactly as written (the gate compares with `===`),
|
|
74
|
+
* so we refuse a bad name rather than silently rewrite an identity string.
|
|
57
75
|
*
|
|
58
|
-
* @throws if any segment is empty
|
|
76
|
+
* @throws if any segment is empty, contains the `:` separator, or is not snake_case.
|
|
59
77
|
*/
|
|
60
78
|
export declare function derivePermissionKey(moduleKey: string, typeKey: string, actionKey: string): PermissionKey;
|
|
61
79
|
/**
|
|
@@ -98,7 +116,7 @@ export type DecisionEffect = 'allow' | 'deny';
|
|
|
98
116
|
* failing gate/absent grant for troubleshooting, WITHOUT leaking the existence
|
|
99
117
|
* of resources the principal may not know about (§7.5 / §13 privacy).
|
|
100
118
|
*/
|
|
101
|
-
export type DecisionReasonCode = 'allowed' | 'not_authenticated' | 'tenant_mismatch' | 'missing_object_type_grant' | 'no_record_permit' | 'explicit_deny_policy' | 'resource_not_registered' | 'deny_by_default';
|
|
119
|
+
export type DecisionReasonCode = 'allowed' | 'not_authenticated' | 'tenant_mismatch' | 'missing_object_type_grant' | 'no_record_permit' | 'explicit_deny_policy' | 'resource_not_registered' | 'root_data_plane_denied' | 'deny_by_default';
|
|
102
120
|
/** The output of the single decision function (§7.1, §7.5). */
|
|
103
121
|
export interface Decision {
|
|
104
122
|
readonly effect: DecisionEffect;
|
|
@@ -131,6 +149,7 @@ export * from './record/rule-evaluator.js';
|
|
|
131
149
|
export * from './record/shares.js';
|
|
132
150
|
export * from './cross-tenant/grant-evaluator.js';
|
|
133
151
|
export * from './delegation/operation-identity.js';
|
|
152
|
+
export * from './record/owner-baseline.js';
|
|
134
153
|
export * from './record/permit-tier.js';
|
|
135
154
|
export * from './gates/wiring.js';
|
|
136
155
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,sBAAsB,GAAG,OAAO,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAAoB,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAG,GAAY,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG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ACjB,2BAA2B,GAC3B,kBAAkB,GAClB,sBAAsB,GACtB,yBAAyB,GACzB,wBAAwB,GACxB,iBAAiB,CAAC;AAEtB,+DAA+D;AAC/D,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,kEAAkE;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,MAAM,CACJ,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtB;AAMD,cAAc,aAAa,CAAC;AAE5B,cAAc,YAAY,CAAC;AAE3B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,yBAAyB,CAAC;AAExC,cAAc,oBAAoB,CAAC;AAInC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mCAAmC,CAAC;AAElD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,4BAA4B,CAAC;AAE3C,cAAc,yBAAyB,CAAC;AAExC,cAAc,mBAAmB,CAAC"}
|
|
@@ -22,16 +22,34 @@ export const DEFAULT_ACCESS_TIER = 'gated';
|
|
|
22
22
|
* A single-source constant so producers/consumers can't drift.
|
|
23
23
|
*/
|
|
24
24
|
export const PERMISSION_KEY_SEPARATOR = ':';
|
|
25
|
+
/**
|
|
26
|
+
* The required format for each permission-key segment (moduleKey / typeKey /
|
|
27
|
+
* actionKey): `snake_case` — a lowercase letter, then lowercase letters, digits,
|
|
28
|
+
* and underscores. Single-source so the rule can't drift between producers.
|
|
29
|
+
* Enforced in {@link derivePermissionKey} as a fail-loud reject (never normalized),
|
|
30
|
+
* so every consumer app names its modules/types/actions uniformly and a casing
|
|
31
|
+
* typo fails at boot instead of silently denying at request time.
|
|
32
|
+
*/
|
|
33
|
+
export const SEGMENT_FORMAT = /^[a-z][a-z0-9_]*$/;
|
|
25
34
|
/**
|
|
26
35
|
* Derive the stable permission identity `feature:object:action` from a module's
|
|
27
36
|
* `moduleKey`, an object type's `typeKey`, and an action's `actionKey`
|
|
28
37
|
* (ADR-0010, confirmed decision #1). PURE — no I/O, no state, deterministic.
|
|
29
38
|
*
|
|
30
39
|
* This is the ONLY sanctioned way to construct a {@link PermissionKey}; grants
|
|
31
|
-
* bind to its result. Segments must be non-empty
|
|
32
|
-
* the key round-trips unambiguously
|
|
40
|
+
* bind to its result. Segments must be non-empty, free of the separator, and in
|
|
41
|
+
* `snake_case` so the key round-trips unambiguously AND every consumer app names
|
|
42
|
+
* its modules/types/actions uniformly.
|
|
33
43
|
*
|
|
34
|
-
*
|
|
44
|
+
* `snake_case` = {@link SEGMENT_FORMAT} = lowercase start, then lowercase letters,
|
|
45
|
+
* digits, and underscores (`^[a-z][a-z0-9_]*$`). This is enforced here — the single
|
|
46
|
+
* sanctioned key constructor — so a stray `CompanyBranch`/`company-branch` typeKey
|
|
47
|
+
* is a HARD, loud failure at boot (when the registry builds keys), never a silent
|
|
48
|
+
* casing mismatch that denies at request time. It is a format REJECT, never a
|
|
49
|
+
* normalization: the key is used exactly as written (the gate compares with `===`),
|
|
50
|
+
* so we refuse a bad name rather than silently rewrite an identity string.
|
|
51
|
+
*
|
|
52
|
+
* @throws if any segment is empty, contains the `:` separator, or is not snake_case.
|
|
35
53
|
*/
|
|
36
54
|
export function derivePermissionKey(moduleKey, typeKey, actionKey) {
|
|
37
55
|
for (const [name, seg] of [
|
|
@@ -39,12 +57,17 @@ export function derivePermissionKey(moduleKey, typeKey, actionKey) {
|
|
|
39
57
|
['typeKey', typeKey],
|
|
40
58
|
['actionKey', actionKey],
|
|
41
59
|
]) {
|
|
60
|
+
// Order matters: empty and separator checks first so their existing error
|
|
61
|
+
// messages/wording are preserved, then the generic snake_case format check.
|
|
42
62
|
if (seg.length === 0) {
|
|
43
63
|
throw new Error(`derivePermissionKey: ${name} must be non-empty`);
|
|
44
64
|
}
|
|
45
65
|
if (seg.includes(PERMISSION_KEY_SEPARATOR)) {
|
|
46
66
|
throw new Error(`derivePermissionKey: ${name} must not contain "${PERMISSION_KEY_SEPARATOR}" (got "${seg}")`);
|
|
47
67
|
}
|
|
68
|
+
if (!SEGMENT_FORMAT.test(seg)) {
|
|
69
|
+
throw new Error(`derivePermissionKey: ${name} must be snake_case (${SEGMENT_FORMAT.source}) — got "${seg}"`);
|
|
70
|
+
}
|
|
48
71
|
}
|
|
49
72
|
return `${moduleKey}${PERMISSION_KEY_SEPARATOR}${typeKey}${PERMISSION_KEY_SEPARATOR}${actionKey}`;
|
|
50
73
|
}
|
|
@@ -75,7 +98,9 @@ export * from './record/shares.js';
|
|
|
75
98
|
export * from './cross-tenant/grant-evaluator.js';
|
|
76
99
|
// - TEAM D: delegation overlay / trusted operation identity (gate 7):
|
|
77
100
|
export * from './delegation/operation-identity.js';
|
|
78
|
-
// -
|
|
101
|
+
// - FRAMEWORK BASELINE: the declaration-driven owner/system/tenantScoped permit (gate 6):
|
|
102
|
+
export * from './record/owner-baseline.js';
|
|
103
|
+
// - INTEGRATION: the composed gate-6 record permit tier (baseline ∪ policy ∪ share, deny-wins):
|
|
79
104
|
export * from './record/permit-tier.js';
|
|
80
105
|
// - INTEGRATION: the production gate-set wiring + fully-wired DecisionAuthority factory:
|
|
81
106
|
export * from './gates/wiring.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAgBH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAe,OAAO,CAAC;AAcvD;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAA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F;AACjF,8EAA8E;AAC9E,iEAAiE;AACjE,6CAA6C;AAC7C,cAAc,aAAa,CAAC;AAC5B,uFAAuF;AACvF,cAAc,YAAY,CAAC;AAC3B,oFAAoF;AACpF,cAAc,mBAAmB,CAAC;AAClC,6EAA6E;AAC7E,gFAAgF;AAChF,cAAc,yBAAyB,CAAC;AACxC,kFAAkF;AAClF,cAAc,oBAAoB,CAAC;AACnC,sFAAsF;AACtF,qEAAqE;AACrE,sEAAsE;AACtE,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,4EAA4E;AAC5E,cAAc,4BAA4B,CAAC;AAC3C,6EAA6E;AAC7E,cAAc,oBAAoB,CAAC;AACnC,sFAAsF;AACtF,cAAc,mCAAmC,CAAC;AAClD,wEAAwE;AACxE,cAAc,oCAAoC,CAAC;AACnD,4FAA4F;AAC5F,cAAc,4BAA4B,CAAC;AAC3C,kGAAkG;AAClG,cAAc,yBAAyB,CAAC;AACxC,2FAA2F;AAC3F,cAAc,mBAAmB,CAAC"}
|
|
@@ -178,7 +178,7 @@ export interface CrossTenantGrantQuery {
|
|
|
178
178
|
* PROCEED for a principal whose tenant differs from the resource's — but it is a
|
|
179
179
|
* HARD action-ceiling: it never widens beyond its declared `allowedActions`,
|
|
180
180
|
* never crosses to a wildcard, and expires. The engine treats a grant as a
|
|
181
|
-
* permit source, never as a
|
|
181
|
+
* permit source, never as a root bypass.
|
|
182
182
|
*/
|
|
183
183
|
export interface CrossTenantGrant {
|
|
184
184
|
/** What the grant spans — a whole object type, or a single record. */
|
|
@@ -203,8 +203,8 @@ export interface CrossTenantGrant {
|
|
|
203
203
|
}
|
|
204
204
|
/**
|
|
205
205
|
* Resolves an active cross-tenant consented grant (ADR-0009) — the ONLY sanctioned
|
|
206
|
-
* way a principal reaches a resource owned by a different tenant (short of
|
|
207
|
-
*
|
|
206
|
+
* way a principal reaches a resource owned by a different tenant (short of root).
|
|
207
|
+
* A grant lets gate 3 PROCEED and is a permit source in gate 6, bounded
|
|
208
208
|
* by its action ceiling + expiry.
|
|
209
209
|
*
|
|
210
210
|
* Concrete adapter ships in `@astram/guard`.
|
|
@@ -37,7 +37,7 @@ export declare function allow(): Decision;
|
|
|
37
37
|
export declare function denyNotAuthenticated(detail?: string): Decision;
|
|
38
38
|
/**
|
|
39
39
|
* DENY — gate 3 (tenant gate): the principal's tenant differs from the resource's,
|
|
40
|
-
* with no active cross-tenant grant and not a
|
|
40
|
+
* with no active cross-tenant grant and not a root. Reason
|
|
41
41
|
* `tenant_mismatch`. FINAL — the tenant boundary is never relaxed downstream.
|
|
42
42
|
*/
|
|
43
43
|
export declare function denyTenantMismatch(detail?: string): Decision;
|
|
@@ -58,6 +58,12 @@ export declare function denyNoRecordPermit(detail?: string): Decision;
|
|
|
58
58
|
* deny matched. Overrides any share/grant widening. Reason `explicit_deny_policy`.
|
|
59
59
|
*/
|
|
60
60
|
export declare function denyExplicitPolicy(detail?: string): Decision;
|
|
61
|
+
/**
|
|
62
|
+
* DENY — the ROOT CAP: a root attempted a DATA-PLANE
|
|
63
|
+
* capability. Root is control-plane only (§0/§2); data-plane is denied by
|
|
64
|
+
* construction, grant-independent. Reason `root_data_plane_denied`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function denyRootDataPlane(detail?: string): Decision;
|
|
61
67
|
/**
|
|
62
68
|
* DENY — gate 0 (resource registration): the resource's object type is not
|
|
63
69
|
* registered with the {@link ModuleRegistry} (unregistered ⇒ Deny, §5.4/5.5).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reason-codes.d.ts","sourceRoot":"","sources":["../../src/authorization/reason-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,KAAK,I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AC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAE5D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAEnE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAEvD"}
|
|
@@ -42,7 +42,7 @@ export function denyNotAuthenticated(detail) {
|
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* DENY — gate 3 (tenant gate): the principal's tenant differs from the resource's,
|
|
45
|
-
* with no active cross-tenant grant and not a
|
|
45
|
+
* with no active cross-tenant grant and not a root. Reason
|
|
46
46
|
* `tenant_mismatch`. FINAL — the tenant boundary is never relaxed downstream.
|
|
47
47
|
*/
|
|
48
48
|
export function denyTenantMismatch(detail) {
|
|
@@ -71,6 +71,14 @@ export function denyNoRecordPermit(detail) {
|
|
|
71
71
|
export function denyExplicitPolicy(detail) {
|
|
72
72
|
return freezeDeny('explicit_deny_policy', detail);
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* DENY — the ROOT CAP: a root attempted a DATA-PLANE
|
|
76
|
+
* capability. Root is control-plane only (§0/§2); data-plane is denied by
|
|
77
|
+
* construction, grant-independent. Reason `root_data_plane_denied`.
|
|
78
|
+
*/
|
|
79
|
+
export function denyRootDataPlane(detail) {
|
|
80
|
+
return freezeDeny('root_data_plane_denied', detail);
|
|
81
|
+
}
|
|
74
82
|
/**
|
|
75
83
|
* DENY — gate 0 (resource registration): the resource's object type is not
|
|
76
84
|
* registered with the {@link ModuleRegistry} (unregistered ⇒ Deny, §5.4/5.5).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reason-codes.js","sourceRoot":"","sources":["../../src/authorization/reason-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,CAAU;IACnC,OAAO,CAAC,KAAK,IAAI,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAe;IAClD,OAAO,UAAU,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAChD,OAAO,UAAU,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAe;IACxD,OAAO,UAAU,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAChD,OAAO,UAAU,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAChD,OAAO,UAAU,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAe;IACvD,OAAO,UAAU,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,OAAO,UAAU,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,+EAA+E;AAC/E,SAAS,U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AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,OAAO,UAAU,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAe;IACvD,OAAO,UAAU,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,OAAO,UAAU,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,+EAA+E;AAC/E,SAAS,UAAU,CACjB,MAA8C,EAC9C,MAAe;IAEf,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC3C,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FRAMEWORK-OWNED record-permit BASELINE (gate 6, design §5.2) — a PURE,
|
|
3
|
+
* declaration-driven permit source computed IN CORE (no DB, no rows, no adapter).
|
|
4
|
+
*
|
|
5
|
+
* This replaces the app-supplied "no rule = allow" fail-open smell with a baseline
|
|
6
|
+
* the framework OWNS and the app cannot weaken. It is derived entirely from the
|
|
7
|
+
* object type's ACCESS POSTURE (design §3, threaded onto the {@link ObjectTypeDescriptor}
|
|
8
|
+
* by the registry bridge) and, for owned types, ONE decision attribute the ENGINE
|
|
9
|
+
* supplies (`ownerId` — the existing record's owner column, fetched tenant-scoped by
|
|
10
|
+
* the engine BEFORE `decide()`; core never touches the DB — ADR-0003).
|
|
11
|
+
*
|
|
12
|
+
* The three postures (design §5.2):
|
|
13
|
+
* - `owned` → allow IFF `attributes.ownerId === principal.id` (STRICT ===).
|
|
14
|
+
* The DAC owner baseline: a principal passes for their OWN records.
|
|
15
|
+
* A missing/mismatched/undefined `ownerId` does NOT allow.
|
|
16
|
+
* - `system` → allow. Identity/infra (company/user/role): the object-type grant
|
|
17
|
+
* (gate 5) already governs; the record tier adds no narrowing.
|
|
18
|
+
* - `tenantScoped` → allow. The tenant gate (gate 3) already isolated the record to the
|
|
19
|
+
* actor's tenant; the record baseline adds no further narrowing.
|
|
20
|
+
* - (no access declared / unknown type) → does NOT allow (fail-CLOSED). A rule/share
|
|
21
|
+
* must permit it; the baseline never manufactures an allow for an
|
|
22
|
+
* un-declared type.
|
|
23
|
+
*
|
|
24
|
+
* The baseline is a WIDENING source: it is UNIONed with the admin policy + shares in the
|
|
25
|
+
* permit tier (deny-wins is unchanged — an explicit admin deny still overrides it).
|
|
26
|
+
*
|
|
27
|
+
* PURE + zero-dep (ADR-0003): reads only the resolved descriptor from the registry, the
|
|
28
|
+
* principal, and `ctx.context.attributes`. No I/O.
|
|
29
|
+
*/
|
|
30
|
+
import type { GateContext } from '../decision-authority.js';
|
|
31
|
+
/**
|
|
32
|
+
* Compute the framework-owned record-permit baseline for this record+principal.
|
|
33
|
+
*
|
|
34
|
+
* Returns `true` when the baseline affirmatively permits (owner match / system /
|
|
35
|
+
* tenantScoped), `false` otherwise (no framework baseline — the policy/share must
|
|
36
|
+
* permit). NEVER throws — it is a pure comparison over already-resolved inputs.
|
|
37
|
+
*
|
|
38
|
+
* @param ctx the shared gate context (record-level resource; `ctx.deps.registry`
|
|
39
|
+
* resolves the descriptor's access posture; `ctx.context.attributes.ownerId` is the
|
|
40
|
+
* engine-supplied owner of the existing row for `owned` types).
|
|
41
|
+
*/
|
|
42
|
+
export declare function evaluateOwnerBaseline(ctx: GateContext): boolean;
|
|
43
|
+
//# sourceMappingURL=owner-baseline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner-baseline.d.ts","sourceRoot":"","sources":["../../../src/authorization/record/owner-baseline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAgC/D"}
|