@astram/core 0.1.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/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/admin/admin-service.d.ts +221 -0
- package/dist/admin/admin-service.d.ts.map +1 -0
- package/dist/admin/admin-service.js +155 -0
- package/dist/admin/admin-service.js.map +1 -0
- package/dist/admin/command/grants.d.ts +40 -0
- package/dist/admin/command/grants.d.ts.map +1 -0
- package/dist/admin/command/grants.js +196 -0
- package/dist/admin/command/grants.js.map +1 -0
- package/dist/admin/command/index.d.ts +23 -0
- package/dist/admin/command/index.d.ts.map +1 -0
- package/dist/admin/command/index.js +23 -0
- package/dist/admin/command/index.js.map +1 -0
- package/dist/admin/command/invitations.d.ts +72 -0
- package/dist/admin/command/invitations.d.ts.map +1 -0
- package/dist/admin/command/invitations.js +241 -0
- package/dist/admin/command/invitations.js.map +1 -0
- package/dist/admin/command/permissions.d.ts +33 -0
- package/dist/admin/command/permissions.d.ts.map +1 -0
- package/dist/admin/command/permissions.js +67 -0
- package/dist/admin/command/permissions.js.map +1 -0
- package/dist/admin/command/pipeline.d.ts +79 -0
- package/dist/admin/command/pipeline.d.ts.map +1 -0
- package/dist/admin/command/pipeline.js +106 -0
- package/dist/admin/command/pipeline.js.map +1 -0
- package/dist/admin/command/policies.d.ts +50 -0
- package/dist/admin/command/policies.d.ts.map +1 -0
- package/dist/admin/command/policies.js +219 -0
- package/dist/admin/command/policies.js.map +1 -0
- package/dist/admin/command/service-accounts.d.ts +58 -0
- package/dist/admin/command/service-accounts.d.ts.map +1 -0
- package/dist/admin/command/service-accounts.js +272 -0
- package/dist/admin/command/service-accounts.js.map +1 -0
- package/dist/admin/command/service.d.ts +65 -0
- package/dist/admin/command/service.d.ts.map +1 -0
- package/dist/admin/command/service.js +128 -0
- package/dist/admin/command/service.js.map +1 -0
- package/dist/admin/command/tiers.d.ts +40 -0
- package/dist/admin/command/tiers.d.ts.map +1 -0
- package/dist/admin/command/tiers.js +79 -0
- package/dist/admin/command/tiers.js.map +1 -0
- package/dist/admin/index.d.ts +36 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +63 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/ports.d.ts +288 -0
- package/dist/admin/ports.d.ts.map +1 -0
- package/dist/admin/ports.js +39 -0
- package/dist/admin/ports.js.map +1 -0
- package/dist/admin/query/audit-view.d.ts +52 -0
- package/dist/admin/query/audit-view.d.ts.map +1 -0
- package/dist/admin/query/audit-view.js +84 -0
- package/dist/admin/query/audit-view.js.map +1 -0
- package/dist/admin/query/catalog.d.ts +70 -0
- package/dist/admin/query/catalog.d.ts.map +1 -0
- package/dist/admin/query/catalog.js +169 -0
- package/dist/admin/query/catalog.js.map +1 -0
- package/dist/admin/query/explain.d.ts +52 -0
- package/dist/admin/query/explain.d.ts.map +1 -0
- package/dist/admin/query/explain.js +145 -0
- package/dist/admin/query/explain.js.map +1 -0
- package/dist/admin/query/index.d.ts +45 -0
- package/dist/admin/query/index.d.ts.map +1 -0
- package/dist/admin/query/index.js +58 -0
- package/dist/admin/query/index.js.map +1 -0
- package/dist/admin/query/simulate.d.ts +42 -0
- package/dist/admin/query/simulate.d.ts.map +1 -0
- package/dist/admin/query/simulate.js +91 -0
- package/dist/admin/query/simulate.js.map +1 -0
- package/dist/admin/safeguards-impl.d.ts +67 -0
- package/dist/admin/safeguards-impl.d.ts.map +1 -0
- package/dist/admin/safeguards-impl.js +318 -0
- package/dist/admin/safeguards-impl.js.map +1 -0
- package/dist/admin/safeguards.d.ts +89 -0
- package/dist/admin/safeguards.d.ts.map +1 -0
- package/dist/admin/safeguards.js +91 -0
- package/dist/admin/safeguards.js.map +1 -0
- package/dist/admin/types.d.ts +485 -0
- package/dist/admin/types.d.ts.map +1 -0
- package/dist/admin/types.js +38 -0
- package/dist/admin/types.js.map +1 -0
- package/dist/audit/audit-recorder.d.ts +129 -0
- package/dist/audit/audit-recorder.d.ts.map +1 -0
- package/dist/audit/audit-recorder.js +265 -0
- package/dist/audit/audit-recorder.js.map +1 -0
- package/dist/audit/canonicalize.d.ts +38 -0
- package/dist/audit/canonicalize.d.ts.map +1 -0
- package/dist/audit/canonicalize.js +174 -0
- package/dist/audit/canonicalize.js.map +1 -0
- package/dist/audit/errors.d.ts +56 -0
- package/dist/audit/errors.d.ts.map +1 -0
- package/dist/audit/errors.js +41 -0
- package/dist/audit/errors.js.map +1 -0
- package/dist/audit/index.d.ts +45 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +24 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/ports.d.ts +131 -0
- package/dist/audit/ports.d.ts.map +1 -0
- package/dist/audit/ports.js +27 -0
- package/dist/audit/ports.js.map +1 -0
- package/dist/audit/sensitive.d.ts +68 -0
- package/dist/audit/sensitive.d.ts.map +1 -0
- package/dist/audit/sensitive.js +159 -0
- package/dist/audit/sensitive.js.map +1 -0
- package/dist/audit/walk.d.ts +109 -0
- package/dist/audit/walk.d.ts.map +1 -0
- package/dist/audit/walk.js +117 -0
- package/dist/audit/walk.js.map +1 -0
- package/dist/authentication/authenticator.d.ts +74 -0
- package/dist/authentication/authenticator.d.ts.map +1 -0
- package/dist/authentication/authenticator.js +208 -0
- package/dist/authentication/authenticator.js.map +1 -0
- package/dist/authentication/credential-resolver.d.ts +76 -0
- package/dist/authentication/credential-resolver.d.ts.map +1 -0
- package/dist/authentication/credential-resolver.js +21 -0
- package/dist/authentication/credential-resolver.js.map +1 -0
- package/dist/authentication/index.d.ts +52 -0
- package/dist/authentication/index.d.ts.map +1 -0
- package/dist/authentication/index.js +27 -0
- package/dist/authentication/index.js.map +1 -0
- package/dist/authentication/password-hasher.d.ts +41 -0
- package/dist/authentication/password-hasher.d.ts.map +1 -0
- package/dist/authentication/password-hasher.js +21 -0
- package/dist/authentication/password-hasher.js.map +1 -0
- package/dist/authentication/totp.d.ts +101 -0
- package/dist/authentication/totp.d.ts.map +1 -0
- package/dist/authentication/totp.js +151 -0
- package/dist/authentication/totp.js.map +1 -0
- package/dist/authorization/cross-tenant/grant-evaluator.d.ts +90 -0
- package/dist/authorization/cross-tenant/grant-evaluator.d.ts.map +1 -0
- package/dist/authorization/cross-tenant/grant-evaluator.js +165 -0
- package/dist/authorization/cross-tenant/grant-evaluator.js.map +1 -0
- package/dist/authorization/decision-authority.d.ts +212 -0
- package/dist/authorization/decision-authority.d.ts.map +1 -0
- package/dist/authorization/decision-authority.js +200 -0
- package/dist/authorization/decision-authority.js.map +1 -0
- package/dist/authorization/default-gates.d.ts +41 -0
- package/dist/authorization/default-gates.d.ts.map +1 -0
- package/dist/authorization/default-gates.js +47 -0
- package/dist/authorization/default-gates.js.map +1 -0
- package/dist/authorization/delegation/operation-identity.d.ts +132 -0
- package/dist/authorization/delegation/operation-identity.d.ts.map +1 -0
- package/dist/authorization/delegation/operation-identity.js +220 -0
- package/dist/authorization/delegation/operation-identity.js.map +1 -0
- package/dist/authorization/errors.d.ts +54 -0
- package/dist/authorization/errors.d.ts.map +1 -0
- package/dist/authorization/errors.js +63 -0
- package/dist/authorization/errors.js.map +1 -0
- package/dist/authorization/gates/object-type.d.ts +63 -0
- package/dist/authorization/gates/object-type.d.ts.map +1 -0
- package/dist/authorization/gates/object-type.js +177 -0
- package/dist/authorization/gates/object-type.js.map +1 -0
- package/dist/authorization/gates/tenant.d.ts +50 -0
- package/dist/authorization/gates/tenant.d.ts.map +1 -0
- package/dist/authorization/gates/tenant.js +87 -0
- package/dist/authorization/gates/tenant.js.map +1 -0
- package/dist/authorization/gates/wiring.d.ts +57 -0
- package/dist/authorization/gates/wiring.d.ts.map +1 -0
- package/dist/authorization/gates/wiring.js +56 -0
- package/dist/authorization/gates/wiring.js.map +1 -0
- package/dist/authorization/index.d.ts +136 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +82 -0
- package/dist/authorization/index.js.map +1 -0
- package/dist/authorization/ports.d.ts +271 -0
- package/dist/authorization/ports.d.ts.map +1 -0
- package/dist/authorization/ports.js +36 -0
- package/dist/authorization/ports.js.map +1 -0
- package/dist/authorization/reason-codes.d.ts +75 -0
- package/dist/authorization/reason-codes.d.ts.map +1 -0
- package/dist/authorization/reason-codes.js +98 -0
- package/dist/authorization/reason-codes.js.map +1 -0
- package/dist/authorization/record/permit-tier.d.ts +57 -0
- package/dist/authorization/record/permit-tier.d.ts.map +1 -0
- package/dist/authorization/record/permit-tier.js +79 -0
- package/dist/authorization/record/permit-tier.js.map +1 -0
- package/dist/authorization/record/rule-evaluator.d.ts +116 -0
- package/dist/authorization/record/rule-evaluator.d.ts.map +1 -0
- package/dist/authorization/record/rule-evaluator.js +125 -0
- package/dist/authorization/record/rule-evaluator.js.map +1 -0
- package/dist/authorization/record/shares.d.ts +70 -0
- package/dist/authorization/record/shares.d.ts.map +1 -0
- package/dist/authorization/record/shares.js +107 -0
- package/dist/authorization/record/shares.js.map +1 -0
- package/dist/identity/broker.d.ts +59 -0
- package/dist/identity/broker.d.ts.map +1 -0
- package/dist/identity/broker.js +135 -0
- package/dist/identity/broker.js.map +1 -0
- package/dist/identity/claim-mapper.d.ts +84 -0
- package/dist/identity/claim-mapper.d.ts.map +1 -0
- package/dist/identity/claim-mapper.js +48 -0
- package/dist/identity/claim-mapper.js.map +1 -0
- package/dist/identity/index.d.ts +60 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +24 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/internal-adapter.d.ts +54 -0
- package/dist/identity/internal-adapter.d.ts.map +1 -0
- package/dist/identity/internal-adapter.js +88 -0
- package/dist/identity/internal-adapter.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata/completeness.d.ts +136 -0
- package/dist/metadata/completeness.d.ts.map +1 -0
- package/dist/metadata/completeness.js +106 -0
- package/dist/metadata/completeness.js.map +1 -0
- package/dist/metadata/dependencies.d.ts +114 -0
- package/dist/metadata/dependencies.d.ts.map +1 -0
- package/dist/metadata/dependencies.js +105 -0
- package/dist/metadata/dependencies.js.map +1 -0
- package/dist/metadata/index.d.ts +153 -0
- package/dist/metadata/index.d.ts.map +1 -0
- package/dist/metadata/index.js +51 -0
- package/dist/metadata/index.js.map +1 -0
- package/dist/metadata/registry.d.ts +23 -0
- package/dist/metadata/registry.d.ts.map +1 -0
- package/dist/metadata/registry.js +204 -0
- package/dist/metadata/registry.js.map +1 -0
- package/dist/risk/evaluator.d.ts +76 -0
- package/dist/risk/evaluator.d.ts.map +1 -0
- package/dist/risk/evaluator.js +59 -0
- package/dist/risk/evaluator.js.map +1 -0
- package/dist/risk/index.d.ts +40 -0
- package/dist/risk/index.d.ts.map +1 -0
- package/dist/risk/index.js +20 -0
- package/dist/risk/index.js.map +1 -0
- package/dist/risk/risk-engine.d.ts +76 -0
- package/dist/risk/risk-engine.d.ts.map +1 -0
- package/dist/risk/risk-engine.js +287 -0
- package/dist/risk/risk-engine.js.map +1 -0
- package/dist/risk/signals.d.ts +60 -0
- package/dist/risk/signals.d.ts.map +1 -0
- package/dist/risk/signals.js +104 -0
- package/dist/risk/signals.js.map +1 -0
- package/dist/risk/thresholds.d.ts +54 -0
- package/dist/risk/thresholds.d.ts.map +1 -0
- package/dist/risk/thresholds.js +60 -0
- package/dist/risk/thresholds.js.map +1 -0
- package/dist/session/index.d.ts +47 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +20 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/lifetimes.d.ts +50 -0
- package/dist/session/lifetimes.d.ts.map +1 -0
- package/dist/session/lifetimes.js +67 -0
- package/dist/session/lifetimes.js.map +1 -0
- package/dist/session/ports.d.ts +266 -0
- package/dist/session/ports.d.ts.map +1 -0
- package/dist/session/ports.js +23 -0
- package/dist/session/ports.js.map +1 -0
- package/dist/session/session-authority.d.ts +97 -0
- package/dist/session/session-authority.d.ts.map +1 -0
- package/dist/session/session-authority.js +393 -0
- package/dist/session/session-authority.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **module-registers-metadata contract**.
|
|
3
|
+
*
|
|
4
|
+
* Per ADR-0003 + 010_Architecture "Module model": a business module plugs into
|
|
5
|
+
* the Core by **declaring metadata** (its object types + fields, the actions it
|
|
6
|
+
* exposes, each operation's access tier / required permission, supporting
|
|
7
|
+
* read-only dependencies, and policies) — it NEVER implements access checks
|
|
8
|
+
* itself. The Core discovers this metadata and gates everything centrally.
|
|
9
|
+
*
|
|
10
|
+
* A module that adds an operation without a classification is denied by default
|
|
11
|
+
* and flagged at build/boot — never silently open (§5.4). Dynamic (admin-defined)
|
|
12
|
+
* object types register via the SAME contract at runtime (§5.5, ADR-0014).
|
|
13
|
+
*
|
|
14
|
+
* TYPES + REGISTRY INTERFACE STUB ONLY — no discovery/enforcement logic here.
|
|
15
|
+
* ADR-0003: framework-agnostic.
|
|
16
|
+
*/
|
|
17
|
+
import { DEFAULT_ACCESS_TIER, derivePermissionKey, } from '../authorization/index.js';
|
|
18
|
+
// The boot-completeness-check contract (ADR-0002/0010) — types + signature only.
|
|
19
|
+
export * from './completeness.js';
|
|
20
|
+
// The ModuleRegistry implementation (Team A, L3) — `createModuleRegistry()`
|
|
21
|
+
// backs the `ModuleRegistry` interface declared below. Storage/lookup only, no
|
|
22
|
+
// engine logic (see ./registry.ts).
|
|
23
|
+
export * from './registry.js';
|
|
24
|
+
// Supporting read-only dependency auto-derivation (ADR-0012, Team B, L3) — pure
|
|
25
|
+
// functions that derive the read-only lookups a permission implies from an
|
|
26
|
+
// object type's reference fields, honoring the neverAutoGrant escape hatch.
|
|
27
|
+
export * from './dependencies.js';
|
|
28
|
+
/**
|
|
29
|
+
* Resolve an action's baseline access tier (§6, ADR-0004): the action's own
|
|
30
|
+
* `tier`, or `gated` when omitted — the fail-closed default. PURE. This is the
|
|
31
|
+
* single canonical tier-resolution rule; every consumer (registry lookups,
|
|
32
|
+
* completeness check, the future evaluator) MUST route through it rather than
|
|
33
|
+
* re-implementing the `?? 'gated'` default, so the default can never drift.
|
|
34
|
+
*/
|
|
35
|
+
export function resolveTier(action) {
|
|
36
|
+
return action.tier ?? DEFAULT_ACCESS_TIER;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Derive an action's stable permission identity (ADR-0010) within its owning
|
|
40
|
+
* module: `moduleKey:typeKey:actionKey`. PURE — wraps {@link derivePermissionKey}
|
|
41
|
+
* with the action's own `typeKey`. Grants bind to this result.
|
|
42
|
+
*
|
|
43
|
+
* NOTE: `public`-tier actions are reachable without a grant; the permission key
|
|
44
|
+
* still derives (for catalog/audit listing per ADR-0012) but a Public action
|
|
45
|
+
* needs no bound grant to be allowed. The consumer decides whether to require a
|
|
46
|
+
* grant based on {@link resolveTier}.
|
|
47
|
+
*/
|
|
48
|
+
export function resolveActionPermissionKey(moduleKey, action) {
|
|
49
|
+
return derivePermissionKey(moduleKey, action.typeKey, action.actionKey);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,2BAA2B,CAAC;AAEnC,iFAAiF;AACjF,cAAc,mBAAmB,CAAC;AAElC,4EAA4E;AAC5E,+EAA+E;AAC/E,oCAAoC;AACpC,cAAc,eAAe,CAAC;AAE9B,gFAAgF;AAChF,2EAA2E;AAC3E,4EAA4E;AAC5E,cAAc,mBAAmB,CAAC;AAkElC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,MAAwB;IAClD,OAAO,MAAM,CAAC,IAAI,IAAI,mBAAmB,CAAC;AAC5C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CACxC,SAAiB,EACjB,MAAwB;IAExB,OAAO,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ModuleRegistry` implementation (Team A, L3) — the Core's **metadata
|
|
3
|
+
* intake / storage / lookup** for the module-registers-metadata contract
|
|
4
|
+
* (`./index.ts`, §5 "Module model", ADR-0010/0014).
|
|
5
|
+
*
|
|
6
|
+
* SCOPE: intake, structural validation, indexing, and lookup ONLY. This is a
|
|
7
|
+
* registry — it stores declarations and answers "what is registered?". It makes
|
|
8
|
+
* NO access decisions: there is zero `decide` / `normalize` / `authenticate` /
|
|
9
|
+
* `assess` / `establish` / `record` logic here (those live in later engine
|
|
10
|
+
* layers). ADR-0003: framework-agnostic — no framework imports.
|
|
11
|
+
*
|
|
12
|
+
* Every resolved {@link RegisteredAction} derives its `permissionKey` and `tier`
|
|
13
|
+
* via the FROZEN pure helpers {@link resolveActionPermissionKey} /
|
|
14
|
+
* {@link resolveTier} — this file NEVER re-derives a key or re-applies the
|
|
15
|
+
* `?? 'gated'` default itself, so the single-source rules can't drift.
|
|
16
|
+
*/
|
|
17
|
+
import { type ModuleRegistry } from './index.js';
|
|
18
|
+
/**
|
|
19
|
+
* Construct a fresh, empty {@link ModuleRegistry}. The registry is stateful
|
|
20
|
+
* (modules accumulate across `register` calls) — one instance per Core boot.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createModuleRegistry(): ModuleRegistry;
|
|
23
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/metadata/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAKL,KAAK,cAAc,EAGpB,MAAM,YAAY,CAAC;AAqOpB;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ModuleRegistry` implementation (Team A, L3) — the Core's **metadata
|
|
3
|
+
* intake / storage / lookup** for the module-registers-metadata contract
|
|
4
|
+
* (`./index.ts`, §5 "Module model", ADR-0010/0014).
|
|
5
|
+
*
|
|
6
|
+
* SCOPE: intake, structural validation, indexing, and lookup ONLY. This is a
|
|
7
|
+
* registry — it stores declarations and answers "what is registered?". It makes
|
|
8
|
+
* NO access decisions: there is zero `decide` / `normalize` / `authenticate` /
|
|
9
|
+
* `assess` / `establish` / `record` logic here (those live in later engine
|
|
10
|
+
* layers). ADR-0003: framework-agnostic — no framework imports.
|
|
11
|
+
*
|
|
12
|
+
* Every resolved {@link RegisteredAction} derives its `permissionKey` and `tier`
|
|
13
|
+
* via the FROZEN pure helpers {@link resolveActionPermissionKey} /
|
|
14
|
+
* {@link resolveTier} — this file NEVER re-derives a key or re-applies the
|
|
15
|
+
* `?? 'gated'` default itself, so the single-source rules can't drift.
|
|
16
|
+
*/
|
|
17
|
+
import { resolveActionPermissionKey, resolveTier, } from './index.js';
|
|
18
|
+
/**
|
|
19
|
+
* In-memory implementation of {@link ModuleRegistry}. Fail-closed posture
|
|
20
|
+
* (ADR-0002): any structural violation at intake throws LOUD so a malformed
|
|
21
|
+
* module can never be silently half-registered.
|
|
22
|
+
*/
|
|
23
|
+
class InMemoryModuleRegistry {
|
|
24
|
+
/** Static modules, keyed by `moduleKey`. Insertion order = registration order. */
|
|
25
|
+
modules = new Map();
|
|
26
|
+
/** Runtime (dynamic-DDL, ADR-0014) object types, keyed by `typeKey`. */
|
|
27
|
+
dynamicObjectTypes = new Map();
|
|
28
|
+
/**
|
|
29
|
+
* Index: every registered object type (static + dynamic) → its descriptor.
|
|
30
|
+
* Spans all modules so {@link resolveObjectType} is O(1) and reference
|
|
31
|
+
* integrity can be checked against the whole registry.
|
|
32
|
+
*/
|
|
33
|
+
objectTypeIndex = new Map();
|
|
34
|
+
/** Index: stable {@link PermissionKey} → the resolved action that owns it. */
|
|
35
|
+
actionIndex = new Map();
|
|
36
|
+
register(metadata) {
|
|
37
|
+
const { moduleKey } = metadata;
|
|
38
|
+
if (moduleKey.length === 0) {
|
|
39
|
+
throw new Error('ModuleRegistry.register: moduleKey must be non-empty');
|
|
40
|
+
}
|
|
41
|
+
if (this.modules.has(moduleKey)) {
|
|
42
|
+
throw new Error(`ModuleRegistry.register: module "${moduleKey}" is already registered (duplicate moduleKey)`);
|
|
43
|
+
}
|
|
44
|
+
// --- Structural validation (all-or-nothing: validate BEFORE mutating any
|
|
45
|
+
// shared index, so a rejected module leaves the registry untouched). ---
|
|
46
|
+
// (1) No duplicate object-type key WITHIN this module, and no collision with
|
|
47
|
+
// an already-registered type key across the registry.
|
|
48
|
+
const localTypeKeys = new Set();
|
|
49
|
+
for (const objectType of metadata.objectTypes) {
|
|
50
|
+
const { typeKey } = objectType;
|
|
51
|
+
if (typeKey.length === 0) {
|
|
52
|
+
throw new Error(`ModuleRegistry.register: module "${moduleKey}" declares an object type with an empty typeKey`);
|
|
53
|
+
}
|
|
54
|
+
if (localTypeKeys.has(typeKey)) {
|
|
55
|
+
throw new Error(`ModuleRegistry.register: module "${moduleKey}" declares duplicate object type "${typeKey}"`);
|
|
56
|
+
}
|
|
57
|
+
if (this.objectTypeIndex.has(typeKey)) {
|
|
58
|
+
throw new Error(`ModuleRegistry.register: object type "${typeKey}" (module "${moduleKey}") collides with an already-registered type`);
|
|
59
|
+
}
|
|
60
|
+
localTypeKeys.add(typeKey);
|
|
61
|
+
}
|
|
62
|
+
// (2) No duplicate action key WITHIN an object type of this module, and every
|
|
63
|
+
// action's derived permission key must be globally unique. The permission
|
|
64
|
+
// key derivation (via the frozen helper) also fail-closes on empty /
|
|
65
|
+
// separator-containing segments.
|
|
66
|
+
const resolvedActions = [];
|
|
67
|
+
const localActionKeysByType = new Map();
|
|
68
|
+
for (const action of metadata.actions) {
|
|
69
|
+
this.assertActionUnique(moduleKey, action, localActionKeysByType);
|
|
70
|
+
const permissionKey = resolveActionPermissionKey(moduleKey, action);
|
|
71
|
+
if (this.actionIndex.has(permissionKey)) {
|
|
72
|
+
throw new Error(`ModuleRegistry.register: permission key "${permissionKey}" (module "${moduleKey}") collides with an already-registered action`);
|
|
73
|
+
}
|
|
74
|
+
resolvedActions.push({
|
|
75
|
+
moduleKey,
|
|
76
|
+
action,
|
|
77
|
+
permissionKey,
|
|
78
|
+
tier: resolveTier(action),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
// (3) Reference integrity — FieldDescriptor.referencesTypeKey and
|
|
82
|
+
// SupportingDependency.typeKey should resolve to a registered object type.
|
|
83
|
+
// Resolvable NOW = this module's own types + any already-registered type
|
|
84
|
+
// (static or dynamic). A reference that resolves within-module or to an
|
|
85
|
+
// earlier module is validated here and fails LOUD on a dangling target.
|
|
86
|
+
//
|
|
87
|
+
// DEFERRED (cross-module forward reference): a reference to a type owned
|
|
88
|
+
// by a module registered LATER is NOT yet resolvable and cannot be
|
|
89
|
+
// validated at this call without ordering assumptions. Per the prelude
|
|
90
|
+
// DONE.md the registry's job is intake/lookup, and modules may register in
|
|
91
|
+
// any order, so such a reference is left to a later whole-registry
|
|
92
|
+
// completeness pass rather than rejected here. See the TODO below.
|
|
93
|
+
// TODO(cross-module-ref): once every module is registered, a boot-time
|
|
94
|
+
// sweep should assert every referencesTypeKey / dependency typeKey
|
|
95
|
+
// resolves via resolveObjectType (spanning the full registry). That sweep
|
|
96
|
+
// is out of this registry's intake scope (Team C completeness owns the
|
|
97
|
+
// whole-registry reconciliation).
|
|
98
|
+
this.assertReferenceIntegrity(moduleKey, metadata);
|
|
99
|
+
// --- Commit: validation passed, mutate the indices atomically. ---
|
|
100
|
+
this.modules.set(moduleKey, metadata);
|
|
101
|
+
for (const objectType of metadata.objectTypes) {
|
|
102
|
+
this.objectTypeIndex.set(objectType.typeKey, objectType);
|
|
103
|
+
}
|
|
104
|
+
for (const resolved of resolvedActions) {
|
|
105
|
+
this.actionIndex.set(resolved.permissionKey, resolved);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
registerDynamicObjectType(objectType) {
|
|
109
|
+
const { typeKey } = objectType;
|
|
110
|
+
if (typeKey.length === 0) {
|
|
111
|
+
throw new Error('ModuleRegistry.registerDynamicObjectType: typeKey must be non-empty');
|
|
112
|
+
}
|
|
113
|
+
if (this.objectTypeIndex.has(typeKey)) {
|
|
114
|
+
throw new Error(`ModuleRegistry.registerDynamicObjectType: object type "${typeKey}" is already registered (duplicate typeKey)`);
|
|
115
|
+
}
|
|
116
|
+
// ADR-0014 / ADR-0004: a runtime-created object type is REGISTERED (so the
|
|
117
|
+
// decision path can resolve it) and Gated by default. "Gated by default" is
|
|
118
|
+
// the classification of any ACTION on this type — an unclassified action
|
|
119
|
+
// resolves to `gated` via resolveTier; the type itself carries no actions
|
|
120
|
+
// here (dynamic actions, if any, are declared via register()). No DDL, no
|
|
121
|
+
// action seeding — registration + Gated classification only.
|
|
122
|
+
this.dynamicObjectTypes.set(typeKey, objectType);
|
|
123
|
+
this.objectTypeIndex.set(typeKey, objectType);
|
|
124
|
+
}
|
|
125
|
+
list() {
|
|
126
|
+
return [...this.modules.values()];
|
|
127
|
+
}
|
|
128
|
+
resolveObjectType(typeKey) {
|
|
129
|
+
// Spans static + dynamic types; a miss ⇒ the decision path treats it as
|
|
130
|
+
// `resource_not_registered` → Deny. Return undefined, NEVER throw.
|
|
131
|
+
return this.objectTypeIndex.get(typeKey);
|
|
132
|
+
}
|
|
133
|
+
resolveByPermissionKey(permissionKey) {
|
|
134
|
+
// A miss ⇒ ORPHANED permission (a grant referencing a permission no live
|
|
135
|
+
// action derives). Return undefined, NEVER throw.
|
|
136
|
+
return this.actionIndex.get(permissionKey);
|
|
137
|
+
}
|
|
138
|
+
listActions() {
|
|
139
|
+
return [...this.actionIndex.values()];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Assert an action key is unique within its object type for this module, and
|
|
143
|
+
* that its `typeKey`/`actionKey` are non-empty. Mutates `seenByType` to record
|
|
144
|
+
* the action key as seen. Throws on a collision (fail-closed).
|
|
145
|
+
*/
|
|
146
|
+
assertActionUnique(moduleKey, action, seenByType) {
|
|
147
|
+
const { actionKey, typeKey } = action;
|
|
148
|
+
if (actionKey.length === 0) {
|
|
149
|
+
throw new Error(`ModuleRegistry.register: module "${moduleKey}" declares an action with an empty actionKey`);
|
|
150
|
+
}
|
|
151
|
+
if (typeKey.length === 0) {
|
|
152
|
+
throw new Error(`ModuleRegistry.register: module "${moduleKey}" declares action "${actionKey}" with an empty typeKey`);
|
|
153
|
+
}
|
|
154
|
+
let seen = seenByType.get(typeKey);
|
|
155
|
+
if (seen === undefined) {
|
|
156
|
+
seen = new Set();
|
|
157
|
+
seenByType.set(typeKey, seen);
|
|
158
|
+
}
|
|
159
|
+
if (seen.has(actionKey)) {
|
|
160
|
+
throw new Error(`ModuleRegistry.register: module "${moduleKey}" declares duplicate action "${actionKey}" on object type "${typeKey}"`);
|
|
161
|
+
}
|
|
162
|
+
seen.add(actionKey);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Validate reference SHAPE at intake: every `FieldDescriptor.referencesTypeKey`
|
|
166
|
+
* and `SupportingDependency.typeKey` that is present must be a non-empty key
|
|
167
|
+
* (an empty target is a malformed declaration → fail loud, fail-closed).
|
|
168
|
+
*
|
|
169
|
+
* Whether the target actually RESOLVES to a registered type is deliberately NOT
|
|
170
|
+
* enforced here: a valid reference may point at a type owned by a module that
|
|
171
|
+
* registers later (cross-module forward reference), which is unresolvable at
|
|
172
|
+
* this call without ordering assumptions. That whole-registry resolution is
|
|
173
|
+
* deferred to a boot-time completeness sweep (see the DEFERRED note in
|
|
174
|
+
* {@link register}). A caller can resolve any reference at any time via
|
|
175
|
+
* {@link resolveObjectType}.
|
|
176
|
+
*/
|
|
177
|
+
assertReferenceIntegrity(moduleKey, metadata) {
|
|
178
|
+
// FieldDescriptor.referencesTypeKey — a field pointing at another type.
|
|
179
|
+
for (const objectType of metadata.objectTypes) {
|
|
180
|
+
for (const field of objectType.fields) {
|
|
181
|
+
const ref = field.referencesTypeKey;
|
|
182
|
+
if (ref !== undefined && ref.length === 0) {
|
|
183
|
+
throw new Error(`ModuleRegistry.register: module "${moduleKey}" object type "${objectType.typeKey}" field "${field.key}" has an empty referencesTypeKey`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// SupportingDependency.typeKey — a read-only lookup an action depends on.
|
|
188
|
+
for (const action of metadata.actions) {
|
|
189
|
+
for (const dep of action.supportingDependencies ?? []) {
|
|
190
|
+
if (dep.typeKey.length === 0) {
|
|
191
|
+
throw new Error(`ModuleRegistry.register: module "${moduleKey}" action "${action.actionKey}" declares a supporting dependency with an empty typeKey`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Construct a fresh, empty {@link ModuleRegistry}. The registry is stateful
|
|
199
|
+
* (modules accumulate across `register` calls) — one instance per Core boot.
|
|
200
|
+
*/
|
|
201
|
+
export function createModuleRegistry() {
|
|
202
|
+
return new InMemoryModuleRegistry();
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/metadata/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,0BAA0B,EAC1B,WAAW,GAMZ,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,MAAM,sBAAsB;IAC1B,kFAAkF;IACjE,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE7D,wEAAwE;IACvD,kBAAkB,GAAG,IAAI,GAAG,EAAgC,CAAC;IAE9E;;;;OAIG;IACc,eA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0EAA0E;QAC1E,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,sBAAsB,IAAI,EAAE,EAAE,CAAC;gBACtD,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC7B,MAAM,IAAI,KAAK,CACb,oCAAoC,SAAS,aAAa,MAAM,CAAC,SAAS,0DAA0D,CACrI,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,sBAAsB,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **risk-signal evaluator CONTRACT** + its registry — the extension seam the
|
|
3
|
+
* Risk engine routes each observed `RiskSignal` through. One evaluator maps one
|
|
4
|
+
* signal to a weighted `0..1` risk CONTRIBUTION plus which `RiskSignalKind`
|
|
5
|
+
* contributed. Mirrors the Authentication factor-verifier contract + registry
|
|
6
|
+
* (`../authentication/totp.ts`) EXACTLY: a discriminator (`name`), a pure
|
|
7
|
+
* evaluate, a tiny fail-closed registry (duplicate → throw LOUD).
|
|
8
|
+
*
|
|
9
|
+
* ⛔ SCOPE: an evaluator SCORES a signal — it never blocks, mints, denies, or
|
|
10
|
+
* throws-to-deny. Risk ADVISES. The engine aggregates these contributions into a
|
|
11
|
+
* `RiskScore` VALUE; enforcement is a later layer.
|
|
12
|
+
*
|
|
13
|
+
* ⛔ FAIL-SAFE DIRECTION (this layer's whole point): an evaluator that cannot make
|
|
14
|
+
* sense of its signal MUST return a HIGH contribution (`elevated(...)`), never a
|
|
15
|
+
* low/zero one, and never throw. Uncertainty ELEVATES risk. An UNKNOWN signal
|
|
16
|
+
* (no registered evaluator for its kind/name) is likewise treated by the engine as
|
|
17
|
+
* elevating — never silently ignored. See `risk-engine.ts` for the aggregation.
|
|
18
|
+
*
|
|
19
|
+
* ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
|
|
20
|
+
*/
|
|
21
|
+
import type { RiskSignal, RiskSignalKind } from './index.js';
|
|
22
|
+
/**
|
|
23
|
+
* The verdict one evaluator returns for one signal. `contribution` is a normalized
|
|
24
|
+
* `0..1` risk weight (0 = this signal adds no risk; 1 = maximal). `kind` names the
|
|
25
|
+
* `RiskSignalKind` that contributed, for the engine's explainability list. PURE
|
|
26
|
+
* value — no side effects.
|
|
27
|
+
*/
|
|
28
|
+
export interface RiskContribution {
|
|
29
|
+
/** Normalized `0..1` risk this signal contributes (0 = none, 1 = maximal). */
|
|
30
|
+
readonly contribution: number;
|
|
31
|
+
/** The signal kind that produced this contribution (for `contributingSignals`). */
|
|
32
|
+
readonly kind: RiskSignalKind;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A single risk-signal evaluator. PURE per call — the engine supplies the observed
|
|
36
|
+
* {@link RiskSignal}; the evaluator returns a {@link RiskContribution}. One
|
|
37
|
+
* evaluator per `name`; registered in a {@link RiskSignalEvaluatorRegistry}.
|
|
38
|
+
*
|
|
39
|
+
* FAIL-SAFE: an evaluator MUST NOT throw for a malformed value bag — it returns a
|
|
40
|
+
* high (elevating) contribution instead, so an un-parseable signal raises risk
|
|
41
|
+
* rather than being dropped. (The engine ALSO wraps every evaluate in a try/catch
|
|
42
|
+
* that elevates on throw, as defense-in-depth — but a well-behaved evaluator
|
|
43
|
+
* elevates itself.)
|
|
44
|
+
*/
|
|
45
|
+
export interface RiskSignalEvaluator {
|
|
46
|
+
/**
|
|
47
|
+
* The evaluator's stable name (its identity in the registry). The engine routes
|
|
48
|
+
* a signal to an evaluator by matching this against a per-kind default OR an
|
|
49
|
+
* explicit `value.__evaluator` selector (see the engine). Non-empty.
|
|
50
|
+
*/
|
|
51
|
+
readonly name: string;
|
|
52
|
+
/** The `RiskSignalKind` this evaluator handles (matched by the engine's router). */
|
|
53
|
+
readonly kind: RiskSignalKind;
|
|
54
|
+
/** Score one signal → a weighted `0..1` contribution. PURE. Never throws-to-deny. */
|
|
55
|
+
evaluate(signal: RiskSignal): RiskContribution;
|
|
56
|
+
}
|
|
57
|
+
/** Clamp any number-ish value into `[0,1]`; non-finite / non-number ⇒ the fail-safe floor. */
|
|
58
|
+
export declare function clampContribution(v: unknown, failSafeFloor: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* A tiny registry of {@link RiskSignalEvaluator}s, keyed by `name`. The engine
|
|
61
|
+
* resolves the evaluator for each signal through this; a MISS is an unknown signal
|
|
62
|
+
* → the engine treats it as ELEVATING (fail-safe), never ignores it. Fail-closed
|
|
63
|
+
* on empty/duplicate registration, mirroring `FactorVerifierRegistry`.
|
|
64
|
+
*/
|
|
65
|
+
export declare class RiskSignalEvaluatorRegistry {
|
|
66
|
+
private readonly byName;
|
|
67
|
+
/**
|
|
68
|
+
* Register an evaluator under its `name`. Fail-closed: an empty name or a
|
|
69
|
+
* duplicate registration throws LOUD (a silently-shadowed evaluator could route a
|
|
70
|
+
* signal to the wrong scorer, corrupting the assessment).
|
|
71
|
+
*/
|
|
72
|
+
register(evaluator: RiskSignalEvaluator): void;
|
|
73
|
+
/** Look up an evaluator by name, or `undefined` if none is registered. */
|
|
74
|
+
resolve(name: string): RiskSignalEvaluator | undefined;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/risk/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,mFAAmF;IACnF,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAAC;CAChD;AAED,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAK3E;AAED;;;;;GAKG;AACH,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;IAEjE;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,mBAAmB,GAAG,IAAI;IAa9C,0EAA0E;IAC1E,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS;CAGvD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **risk-signal evaluator CONTRACT** + its registry — the extension seam the
|
|
3
|
+
* Risk engine routes each observed `RiskSignal` through. One evaluator maps one
|
|
4
|
+
* signal to a weighted `0..1` risk CONTRIBUTION plus which `RiskSignalKind`
|
|
5
|
+
* contributed. Mirrors the Authentication factor-verifier contract + registry
|
|
6
|
+
* (`../authentication/totp.ts`) EXACTLY: a discriminator (`name`), a pure
|
|
7
|
+
* evaluate, a tiny fail-closed registry (duplicate → throw LOUD).
|
|
8
|
+
*
|
|
9
|
+
* ⛔ SCOPE: an evaluator SCORES a signal — it never blocks, mints, denies, or
|
|
10
|
+
* throws-to-deny. Risk ADVISES. The engine aggregates these contributions into a
|
|
11
|
+
* `RiskScore` VALUE; enforcement is a later layer.
|
|
12
|
+
*
|
|
13
|
+
* ⛔ FAIL-SAFE DIRECTION (this layer's whole point): an evaluator that cannot make
|
|
14
|
+
* sense of its signal MUST return a HIGH contribution (`elevated(...)`), never a
|
|
15
|
+
* low/zero one, and never throw. Uncertainty ELEVATES risk. An UNKNOWN signal
|
|
16
|
+
* (no registered evaluator for its kind/name) is likewise treated by the engine as
|
|
17
|
+
* elevating — never silently ignored. See `risk-engine.ts` for the aggregation.
|
|
18
|
+
*
|
|
19
|
+
* ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
|
|
20
|
+
*/
|
|
21
|
+
/** Clamp any number-ish value into `[0,1]`; non-finite / non-number ⇒ the fail-safe floor. */
|
|
22
|
+
export function clampContribution(v, failSafeFloor) {
|
|
23
|
+
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
24
|
+
return failSafeFloor;
|
|
25
|
+
if (v < 0)
|
|
26
|
+
return 0;
|
|
27
|
+
if (v > 1)
|
|
28
|
+
return 1;
|
|
29
|
+
return v;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A tiny registry of {@link RiskSignalEvaluator}s, keyed by `name`. The engine
|
|
33
|
+
* resolves the evaluator for each signal through this; a MISS is an unknown signal
|
|
34
|
+
* → the engine treats it as ELEVATING (fail-safe), never ignores it. Fail-closed
|
|
35
|
+
* on empty/duplicate registration, mirroring `FactorVerifierRegistry`.
|
|
36
|
+
*/
|
|
37
|
+
export class RiskSignalEvaluatorRegistry {
|
|
38
|
+
byName = new Map();
|
|
39
|
+
/**
|
|
40
|
+
* Register an evaluator under its `name`. Fail-closed: an empty name or a
|
|
41
|
+
* duplicate registration throws LOUD (a silently-shadowed evaluator could route a
|
|
42
|
+
* signal to the wrong scorer, corrupting the assessment).
|
|
43
|
+
*/
|
|
44
|
+
register(evaluator) {
|
|
45
|
+
const { name } = evaluator;
|
|
46
|
+
if (typeof name !== 'string' || name.length === 0) {
|
|
47
|
+
throw new Error('RiskSignalEvaluatorRegistry.register: name must be non-empty');
|
|
48
|
+
}
|
|
49
|
+
if (this.byName.has(name)) {
|
|
50
|
+
throw new Error(`RiskSignalEvaluatorRegistry.register: name "${name}" is already registered (duplicate evaluator)`);
|
|
51
|
+
}
|
|
52
|
+
this.byName.set(name, evaluator);
|
|
53
|
+
}
|
|
54
|
+
/** Look up an evaluator by name, or `undefined` if none is registered. */
|
|
55
|
+
resolve(name) {
|
|
56
|
+
return this.byName.get(name);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/risk/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAyCH,8FAA8F;AAC9F,MAAM,UAAU,iBAAiB,CAAC,CAAU,EAAE,aAAqB;IACjE,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,aAAa,CAAC;IACvE,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,2BAA2B;IACrB,MAAM,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEjE;;;;OAIG;IACH,QAAQ,CAAC,SAA8B;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;QAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,+CAA+C,IAAI,+CAA+C,CACnG,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACnC,CAAC;IAED,0EAA0E;IAC1E,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine seam: **Risk** — scores the request to drive adaptive decisions.
|
|
3
|
+
*
|
|
4
|
+
* Evaluates device, behaviour, and context signals into a score that can drive
|
|
5
|
+
* adaptive decisions (e.g. step-up MFA) — 010_Architecture §4. This seam names
|
|
6
|
+
* the scoring contract only; the scoring model is a later layer.
|
|
7
|
+
*
|
|
8
|
+
* TYPES / INTERFACES ONLY. ADR-0003: framework-agnostic.
|
|
9
|
+
*/
|
|
10
|
+
import type { Principal } from '../identity/index.js';
|
|
11
|
+
/** Kinds of signal the risk engine may weigh. */
|
|
12
|
+
export type RiskSignalKind = 'device' | 'behaviour' | 'context' | 'network';
|
|
13
|
+
/** One observed signal contributing to a risk assessment. */
|
|
14
|
+
export interface RiskSignal {
|
|
15
|
+
readonly kind: RiskSignalKind;
|
|
16
|
+
/** Signal-specific observation (e.g. device fingerprint, geo, velocity). */
|
|
17
|
+
readonly value: Readonly<Record<string, unknown>>;
|
|
18
|
+
}
|
|
19
|
+
/** Coarse risk bands an assessment may resolve to. */
|
|
20
|
+
export type RiskLevel = 'low' | 'medium' | 'high';
|
|
21
|
+
/** The result of scoring a request. */
|
|
22
|
+
export interface RiskScore {
|
|
23
|
+
readonly level: RiskLevel;
|
|
24
|
+
/** Normalized 0..1 score (0 = no risk). */
|
|
25
|
+
readonly value: number;
|
|
26
|
+
/** Signals that most contributed — for explainability/audit. */
|
|
27
|
+
readonly contributingSignals: readonly RiskSignalKind[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Risk Engine seam — assesses a principal's request from its signals.
|
|
31
|
+
* Implementation (weighting, thresholds, adaptive policy) is a later layer.
|
|
32
|
+
*/
|
|
33
|
+
export interface RiskEngine {
|
|
34
|
+
assess(principal: Principal, signals: readonly RiskSignal[]): Promise<RiskScore>;
|
|
35
|
+
}
|
|
36
|
+
export * from './evaluator.js';
|
|
37
|
+
export * from './signals.js';
|
|
38
|
+
export * from './thresholds.js';
|
|
39
|
+
export * from './risk-engine.js';
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/risk/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,iDAAiD;AACjD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;AAE5E,6DAA6D;AAC7D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD;AAED,sDAAsD;AACtD,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElD,uCAAuC;AACvC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,QAAQ,CAAC,mBAAmB,EAAE,SAAS,cAAc,EAAE,CAAC;CACzD;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CAClF;AAKD,cAAc,gBAAgB,CAAC;AAE/B,cAAc,cAAc,CAAC;AAE7B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine seam: **Risk** — scores the request to drive adaptive decisions.
|
|
3
|
+
*
|
|
4
|
+
* Evaluates device, behaviour, and context signals into a score that can drive
|
|
5
|
+
* adaptive decisions (e.g. step-up MFA) — 010_Architecture §4. This seam names
|
|
6
|
+
* the scoring contract only; the scoring model is a later layer.
|
|
7
|
+
*
|
|
8
|
+
* TYPES / INTERFACES ONLY. ADR-0003: framework-agnostic.
|
|
9
|
+
*/
|
|
10
|
+
// --- Engine implementation behind the frozen seam above (this layer) ---------
|
|
11
|
+
// The signal-evaluator CONTRACT (the extension seam evaluators plug into) + its
|
|
12
|
+
// registry + the contribution-clamp helper:
|
|
13
|
+
export * from './evaluator.js';
|
|
14
|
+
// The reference signal evaluators (unknown-device, sensitive-action) — Rule of Three:
|
|
15
|
+
export * from './signals.js';
|
|
16
|
+
// The threshold/config schema (band cutoffs + step-up threshold) + its validation:
|
|
17
|
+
export * from './thresholds.js';
|
|
18
|
+
// The scoring engine `createRiskEngine` + the SEPARATE advisory `recommendStepUp`:
|
|
19
|
+
export * from './risk-engine.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/risk/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkCH,gFAAgF;AAChF,gFAAgF;AAChF,4CAA4C;AAC5C,cAAc,gBAAgB,CAAC;AAC/B,sFAAsF;AACtF,cAAc,cAAc,CAAC;AAC7B,mFAAmF;AACnF,cAAc,iBAAiB,CAAC;AAChC,mFAAmF;AACnF,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **Risk engine** — the body behind the FROZEN {@link RiskEngine} seam
|
|
3
|
+
* (`./index.ts`). SCORES a request from its signals into a `RiskScore` VALUE, and
|
|
4
|
+
* exposes a SEPARATE advisory `recommendStepUp` derivation (ADR-0017). Mirrors the
|
|
5
|
+
* Authentication / Session engines EXACTLY: a pure `createRiskEngine(...)` factory
|
|
6
|
+
* over injected capabilities (evaluators + thresholds), a stateless impl, STRICT
|
|
7
|
+
* gates, a top-level try/catch → a FAIL-SAFE result, no logging.
|
|
8
|
+
*
|
|
9
|
+
* ⛔ THE ASSESS-vs-ENFORCE LINE (this layer's whole point):
|
|
10
|
+
* Risk ASSESSES + RECOMMENDS; it NEVER ENFORCES. `assess()` returns a `RiskScore`
|
|
11
|
+
* VALUE — it NEVER blocks, mints, denies, or throws-in-a-way-that-acts-as-a-hard-
|
|
12
|
+
* deny. `recommendStepUp` is a PURE derivation OVER a `RiskScore`, NOT a field on
|
|
13
|
+
* the frozen type and NOT an enforcement action — advice a later layer reads.
|
|
14
|
+
*
|
|
15
|
+
* ⛔ THE FAIL-SAFE DIRECTION (uncertainty ⇒ HIGHER risk, NEVER "allow"):
|
|
16
|
+
* An unknown signal (no evaluator), a malformed value bag, or an evaluator that
|
|
17
|
+
* THROWS is treated as ELEVATING — it raises the score, never lowers or drops it.
|
|
18
|
+
* BUT fail-safe here = advise HARDER (higher value / recommend step-up), NOT
|
|
19
|
+
* throw-to-deny. `assess()` ALWAYS RESOLVES to a `RiskScore` — the outer catch
|
|
20
|
+
* yields a fail-safe HIGH-ish score, never an exception.
|
|
21
|
+
*
|
|
22
|
+
* ⛔ DETERMINISM: same `(principal, signals)` ⇒ same `RiskScore`, every call. NO
|
|
23
|
+
* wall-clock, NO RNG, NO order-dependence — aggregation is a commutative combine.
|
|
24
|
+
*
|
|
25
|
+
* ⛔ MONOTONICITY: adding a risky signal never DECREASES `value`; a superset of
|
|
26
|
+
* signals never scores lower than its subset. The combine is non-decreasing.
|
|
27
|
+
*
|
|
28
|
+
* ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
|
|
29
|
+
*/
|
|
30
|
+
import type { RiskEngine, RiskScore } from './index.js';
|
|
31
|
+
import { type RiskSignalEvaluator } from './evaluator.js';
|
|
32
|
+
import { type RiskThresholdConfig } from './thresholds.js';
|
|
33
|
+
/** Options for {@link createRiskEngine}. */
|
|
34
|
+
export interface CreateRiskEngineOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Signal evaluators. When omitted, the reference {@link DEFAULT_RISK_EVALUATORS}
|
|
37
|
+
* (unknown-device + sensitive-action) are used. Duplicate names fail-closed at
|
|
38
|
+
* registration. The engine builds a per-kind default map from these (first
|
|
39
|
+
* evaluator registered for a kind becomes that kind's default; a duplicate KIND
|
|
40
|
+
* is allowed as long as NAMES are unique — the first wins the kind default).
|
|
41
|
+
*/
|
|
42
|
+
readonly evaluators?: readonly RiskSignalEvaluator[];
|
|
43
|
+
/**
|
|
44
|
+
* Band cutoffs + step-up threshold (ADR-0017). Omitted fields default to
|
|
45
|
+
* {@link DEFAULT_RISK_THRESHOLDS}; validated (bounds) at CONSTRUCTION — a
|
|
46
|
+
* nonsensical config throws LOUD here, never at assess time.
|
|
47
|
+
*/
|
|
48
|
+
readonly thresholds?: Partial<RiskThresholdConfig>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Wire the injected capabilities and return an object implementing the FROZEN
|
|
52
|
+
* {@link RiskEngine}. The engine's public entry point (mirrors `createAuthenticator`
|
|
53
|
+
* / `createSessionAuthority`). Validates the threshold config eagerly at
|
|
54
|
+
* construction (throws LOUD on a nonsensical config — construction-time).
|
|
55
|
+
*/
|
|
56
|
+
export declare function createRiskEngine(options?: CreateRiskEngineOptions): RiskEngine;
|
|
57
|
+
/** Config for {@link recommendStepUp} — only the step-up threshold is consulted. */
|
|
58
|
+
export interface StepUpConfig {
|
|
59
|
+
/** `value >= stepUpThreshold` recommends step-up. Defaults to the threshold default. */
|
|
60
|
+
readonly stepUpThreshold: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The ADR-0017 **step-up recommendation** — a SEPARATE, PURE derivation OVER a
|
|
64
|
+
* {@link RiskScore}. Returns `true` when the score's `level === 'high'` OR its
|
|
65
|
+
* `value >= stepUpThreshold`.
|
|
66
|
+
*
|
|
67
|
+
* ⛔ THIS IS ADVISORY, NOT ENFORCEMENT. It is NOT a field on the frozen `RiskScore`
|
|
68
|
+
* (which has no recommendation/stepUp field — semver, ADR-0023) and it takes NO
|
|
69
|
+
* action. A later layer (Auth performs `mfa_required`; the SDK does UX) READS this
|
|
70
|
+
* advice and decides. Risk never blocks/mints/denies.
|
|
71
|
+
*
|
|
72
|
+
* FAIL-SAFE: a malformed / missing score (null, non-object, non-number value) ⇒
|
|
73
|
+
* recommend step-up (`true`) — uncertainty advises HARDER, never silently `false`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function recommendStepUp(score: RiskScore, config?: Partial<StepUpConfig>): boolean;
|
|
76
|
+
//# sourceMappingURL=risk-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk-engine.d.ts","sourceRoot":"","sources":["../../src/risk/risk-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EACV,UAAU,EAEV,SAAS,EAGV,MAAM,YAAY,CAAC;AACpB,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,iBAAiB,CAAC;AA8OzB,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACrD;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACpD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAgBlF;AAID,oFAAoF;AACpF,MAAM,WAAW,YAAY;IAC3B,wFAAwF;IACxF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAezF"}
|