@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,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Identity **normalization core** — the body behind the frozen
|
|
3
|
+
* {@link IdentityBroker} seam (`./index.ts`). Turns an ALREADY-VERIFIED
|
|
4
|
+
* {@link ExternalIdentityAssertion} into ONE tenant-bound {@link Principal},
|
|
5
|
+
* uniformly for every principal kind (ADR-0007: no is-this-a-machine branch).
|
|
6
|
+
*
|
|
7
|
+
* SCOPE — shape the WHO, nothing more:
|
|
8
|
+
* - dispatch on `assertion.source` → the registered {@link IdentityClaimMapper};
|
|
9
|
+
* - map claims → candidate fields;
|
|
10
|
+
* - VALIDATE + tenant-bind → a safe Principal, or REJECT (fail-closed).
|
|
11
|
+
*
|
|
12
|
+
* OUT of scope (later steps, deliberately absent here): proving identity
|
|
13
|
+
* (no credential/MFA/WebAuthn verification — Authentication, step 5), session
|
|
14
|
+
* lifecycle (step 6), service-account credential lifecycle (Authentication). This
|
|
15
|
+
* core ASSUMES the assertion is authentic and only maps + tenant-binds + rejects
|
|
16
|
+
* malformed/unknown.
|
|
17
|
+
*
|
|
18
|
+
* Two security invariants, both fail-closed:
|
|
19
|
+
* 1. TENANT-BINDING — every Principal MUST be bound to exactly one non-empty
|
|
20
|
+
* tenant; a missing/empty tenant REJECTS (§2/§7.3, tenant is the boundary).
|
|
21
|
+
* 2. SUPERUSER SAFETY — `isPlatformSuperuser` defaults `false` and is honored
|
|
22
|
+
* ONLY from a mapper's trusted `trustedSuperuserSignal`; an attacker-supplied
|
|
23
|
+
* `superuser`/`isPlatformSuperuser` claim can never flip it (default-deny).
|
|
24
|
+
*
|
|
25
|
+
* ADR-0003: framework-agnostic — no framework / HTTP / DB imports.
|
|
26
|
+
*/
|
|
27
|
+
import { IdentityClaimMapperRegistry, } from './claim-mapper.js';
|
|
28
|
+
import { createInternalIdentityAdapter } from './internal-adapter.js';
|
|
29
|
+
/** The set of valid principal kinds — the ONLY accepted `kind` values (§7.1). */
|
|
30
|
+
const VALID_PRINCIPAL_KINDS = new Set([
|
|
31
|
+
'user',
|
|
32
|
+
'role_group',
|
|
33
|
+
'service_account',
|
|
34
|
+
]);
|
|
35
|
+
/** Kind defaults to `user` when a mapper leaves it absent. */
|
|
36
|
+
const DEFAULT_PRINCIPAL_KIND = 'user';
|
|
37
|
+
/** Thrown when an assertion cannot be normalized into a safe Principal. */
|
|
38
|
+
export class IdentityNormalizationError extends Error {
|
|
39
|
+
constructor(message) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = 'IdentityNormalizationError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The concrete normalization core. Stateless per call; holds only the mapper
|
|
46
|
+
* registry (its dispatch table). Instances come from {@link createIdentityBroker}.
|
|
47
|
+
*/
|
|
48
|
+
class BrokerImpl {
|
|
49
|
+
registry;
|
|
50
|
+
constructor(registry) {
|
|
51
|
+
this.registry = registry;
|
|
52
|
+
}
|
|
53
|
+
async normalize(assertion) {
|
|
54
|
+
// --- Guard the input SHAPE before destructuring: a null/undefined/non-object
|
|
55
|
+
// assertion must fail closed with the SAME typed error as every other
|
|
56
|
+
// rejection (not a raw TypeError from destructuring), so a caller
|
|
57
|
+
// catching IdentityNormalizationError → 400/401 never leaks a 500. ---
|
|
58
|
+
if (assertion === null || typeof assertion !== 'object') {
|
|
59
|
+
throw new IdentityNormalizationError('normalize: assertion must be a non-null object (ExternalIdentityAssertion)');
|
|
60
|
+
}
|
|
61
|
+
// --- Dispatch: unknown/unregistered source → REJECT (never fabricate). ---
|
|
62
|
+
const { source } = assertion;
|
|
63
|
+
if (typeof source !== 'string' || source.length === 0) {
|
|
64
|
+
throw new IdentityNormalizationError('normalize: assertion.source must be a non-empty string');
|
|
65
|
+
}
|
|
66
|
+
const mapper = this.registry.resolve(source);
|
|
67
|
+
if (mapper === undefined) {
|
|
68
|
+
throw new IdentityNormalizationError(`normalize: no identity adapter registered for source "${source}" (unknown/unregistered source — fail-closed, no principal fabricated)`);
|
|
69
|
+
}
|
|
70
|
+
// --- Map claims → candidate fields (mapper does NOT validate/enforce). ---
|
|
71
|
+
const claims = assertion.claims ?? {};
|
|
72
|
+
const candidate = mapper.map(claims);
|
|
73
|
+
// --- Enforce invariants (fail-closed): a violation REJECTS; we never return
|
|
74
|
+
// a partial/unsafe Principal. ---
|
|
75
|
+
// id — non-empty, stable, opaque.
|
|
76
|
+
const id = candidate.id;
|
|
77
|
+
if (typeof id !== 'string' || id.length === 0) {
|
|
78
|
+
throw new IdentityNormalizationError(`normalize: assertion from "${source}" produced no stable principal id (fail-closed)`);
|
|
79
|
+
}
|
|
80
|
+
// tenantId — TENANT-BINDING: exactly one non-empty tenant, or REJECT.
|
|
81
|
+
const tenantId = candidate.tenantId;
|
|
82
|
+
if (typeof tenantId !== 'string' || tenantId.length === 0) {
|
|
83
|
+
throw new IdentityNormalizationError(`normalize: principal "${id}" from "${source}" is not tenant-bound (missing/empty tenantId — every principal MUST belong to exactly one tenant)`);
|
|
84
|
+
}
|
|
85
|
+
// kind — default to 'user'; an explicit-but-unrecognized kind REJECTS.
|
|
86
|
+
const kind = this.resolveKind(candidate.kind, id, source);
|
|
87
|
+
// roleIds — default to []; freeze a defensive copy so the Principal is immutable.
|
|
88
|
+
const roleIds = Object.freeze([...(candidate.roleIds ?? [])]);
|
|
89
|
+
// isPlatformSuperuser — SUPERUSER SAFETY: default-deny. Honored ONLY from the
|
|
90
|
+
// mapper's TRUSTED signal (an allowlisted, first-party path). We NEVER read
|
|
91
|
+
// any raw claim here, so an attacker-controllable `superuser`/`isPlatformSuperuser`
|
|
92
|
+
// claim cannot influence this value.
|
|
93
|
+
const isPlatformSuperuser = candidate.trustedSuperuserSignal === true;
|
|
94
|
+
return Object.freeze({
|
|
95
|
+
kind,
|
|
96
|
+
id,
|
|
97
|
+
tenantId,
|
|
98
|
+
roleIds,
|
|
99
|
+
isPlatformSuperuser,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/** Resolve + validate the principal kind (default `user`, reject unknown). */
|
|
103
|
+
resolveKind(candidateKind, id, source) {
|
|
104
|
+
if (candidateKind === undefined)
|
|
105
|
+
return DEFAULT_PRINCIPAL_KIND;
|
|
106
|
+
if (!VALID_PRINCIPAL_KINDS.has(candidateKind)) {
|
|
107
|
+
throw new IdentityNormalizationError(`normalize: principal "${id}" from "${source}" has invalid kind "${candidateKind}" (must be one of user | role_group | service_account)`);
|
|
108
|
+
}
|
|
109
|
+
return candidateKind;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Wire the mapper registry + adapters and return an object implementing the
|
|
114
|
+
* frozen {@link IdentityBroker}. This is the engine's public entry point.
|
|
115
|
+
*
|
|
116
|
+
* - No `mappers` given ⇒ registers ONE reference Internal adapter (canonical
|
|
117
|
+
* claim shape) with the given (default empty) superuser allowlist.
|
|
118
|
+
* - `mappers` given ⇒ registers exactly those (the seam future protocol adapters
|
|
119
|
+
* plug into). Duplicate sources fail-closed at registration.
|
|
120
|
+
*/
|
|
121
|
+
export function createIdentityBroker(options = {}) {
|
|
122
|
+
const registry = new IdentityClaimMapperRegistry();
|
|
123
|
+
if (options.mappers === undefined) {
|
|
124
|
+
registry.register(createInternalIdentityAdapter(options.internalSuperuserIds !== undefined
|
|
125
|
+
? { superuserIds: options.internalSuperuserIds }
|
|
126
|
+
: {}));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
for (const mapper of options.mappers) {
|
|
130
|
+
registry.register(mapper);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return new BrokerImpl(registry);
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=broker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../../src/identity/broker.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **IdP-adapter contract** for the Identity engine — the internal extension
|
|
3
|
+
* seam that turns a source's opaque, provider-native claims into a set of
|
|
4
|
+
* *candidate* principal fields the normalization core then validates + binds.
|
|
5
|
+
*
|
|
6
|
+
* This is the seam the 7 deferred protocol adapters (OIDC / SAML / LDAP / Entra
|
|
7
|
+
* / Cognito / Okta / Google) will each implement — ONE `IdentityClaimMapper` per
|
|
8
|
+
* source. It is deliberately MINIMAL (ADR-0023 §7 Rule of Three): a `source`
|
|
9
|
+
* discriminator + a pure `map()` + a tiny registry. It grows an abstraction only
|
|
10
|
+
* when a third concrete need appears.
|
|
11
|
+
*
|
|
12
|
+
* SCOPE: claim → candidate fields ONLY. A mapper does NOT verify the assertion
|
|
13
|
+
* (authenticity is Authentication's job, step 5), does NOT enforce invariants
|
|
14
|
+
* (the core does — a mapper may legitimately produce an incomplete candidate, and
|
|
15
|
+
* the core fail-closes on it), and does NOT decide the superuser flag from
|
|
16
|
+
* attacker-controllable claims (see {@link CandidatePrincipalFields.trustedSuperuserSignal}).
|
|
17
|
+
*
|
|
18
|
+
* ADR-0003: framework-agnostic — no framework / HTTP / DB imports here.
|
|
19
|
+
*/
|
|
20
|
+
import { type PrincipalKind } from './index.js';
|
|
21
|
+
/**
|
|
22
|
+
* The un-validated result of mapping one source's claims. Every field is
|
|
23
|
+
* *candidate* — the normalization core is the sole authority that validates
|
|
24
|
+
* (non-empty id, non-empty tenant, valid kind) and fail-closes. A mapper returns
|
|
25
|
+
* its best-effort read of the claims; it never throws for a *missing* field (that
|
|
26
|
+
* is the core's fail-closed reject), only for a claim shape it cannot parse.
|
|
27
|
+
*/
|
|
28
|
+
export interface CandidatePrincipalFields {
|
|
29
|
+
/** Candidate stable opaque id. May be absent/empty → core rejects. */
|
|
30
|
+
readonly id?: string;
|
|
31
|
+
/** Candidate home tenant. May be absent/empty → core rejects (tenant-binding). */
|
|
32
|
+
readonly tenantId?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Candidate principal kind. Absent ⇒ the core defaults to `'user'`; an
|
|
35
|
+
* unrecognized value ⇒ the core rejects (invalid kind).
|
|
36
|
+
*/
|
|
37
|
+
readonly kind?: PrincipalKind | string;
|
|
38
|
+
/** Candidate role/group ids. Absent ⇒ the core defaults to `[]`. */
|
|
39
|
+
readonly roleIds?: readonly string[];
|
|
40
|
+
/**
|
|
41
|
+
* SUPERUSER SAFETY (security-critical). A mapper sets this to `true` ONLY when
|
|
42
|
+
* its OWN, trusted, explicitly-designed path establishes that the assertion is
|
|
43
|
+
* the platform superuser — e.g. the first-party Internal provider honoring a
|
|
44
|
+
* signal on ITS trusted source. An external protocol adapter (OIDC/SAML/…) must
|
|
45
|
+
* NEVER derive this from a caller-supplied claim like `superuser:true`; it must
|
|
46
|
+
* leave this `undefined`/`false`. The core defaults the resulting Principal's
|
|
47
|
+
* `isPlatformSuperuser` to `false` and only ever honors THIS explicit field —
|
|
48
|
+
* so an attacker-controllable claim can never flip it (default-deny).
|
|
49
|
+
*/
|
|
50
|
+
readonly trustedSuperuserSignal?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A single IdP adapter: maps one `source`'s native claims to
|
|
54
|
+
* {@link CandidatePrincipalFields}. PURE per call (no I/O, no verification).
|
|
55
|
+
* Implemented per source; registered in an {@link IdentityClaimMapperRegistry}.
|
|
56
|
+
*/
|
|
57
|
+
export interface IdentityClaimMapper {
|
|
58
|
+
/** The assertion `source` this mapper handles (matched exactly). */
|
|
59
|
+
readonly source: string;
|
|
60
|
+
/**
|
|
61
|
+
* Map provider-native claims to candidate principal fields. May throw ONLY if
|
|
62
|
+
* the claims are structurally un-parseable for this source; a merely *missing*
|
|
63
|
+
* field is returned absent (the core fail-closes on it, uniformly).
|
|
64
|
+
*/
|
|
65
|
+
map(claims: Readonly<Record<string, unknown>>): CandidatePrincipalFields;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A tiny registry of {@link IdentityClaimMapper}s, keyed by `source`. The
|
|
69
|
+
* normalization core dispatches on `assertion.source` through this: a hit selects
|
|
70
|
+
* the mapper; a MISS is an unknown/unregistered source → the core rejects
|
|
71
|
+
* (fail-closed — never fabricate a principal). Fresh per broker.
|
|
72
|
+
*/
|
|
73
|
+
export declare class IdentityClaimMapperRegistry {
|
|
74
|
+
private readonly mappers;
|
|
75
|
+
/**
|
|
76
|
+
* Register a mapper for its `source`. Fail-closed: an empty source or a
|
|
77
|
+
* duplicate registration throws LOUD (a silently-shadowed mapper could route
|
|
78
|
+
* an assertion to the wrong IdP).
|
|
79
|
+
*/
|
|
80
|
+
register(mapper: IdentityClaimMapper): void;
|
|
81
|
+
/** Look up the mapper for a source, or `undefined` if none is registered. */
|
|
82
|
+
resolve(source: string): IdentityClaimMapper | undefined;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=claim-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-mapper.d.ts","sourceRoot":"","sources":["../../src/identity/claim-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IACvC,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;;;;;;OASG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAC3C;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,wBAAwB,CAAC;CAC1E;AAED;;;;;GAKG;AACH,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0C;IAElE;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IAa3C,6EAA6E;IAC7E,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS;CAGzD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **IdP-adapter contract** for the Identity engine — the internal extension
|
|
3
|
+
* seam that turns a source's opaque, provider-native claims into a set of
|
|
4
|
+
* *candidate* principal fields the normalization core then validates + binds.
|
|
5
|
+
*
|
|
6
|
+
* This is the seam the 7 deferred protocol adapters (OIDC / SAML / LDAP / Entra
|
|
7
|
+
* / Cognito / Okta / Google) will each implement — ONE `IdentityClaimMapper` per
|
|
8
|
+
* source. It is deliberately MINIMAL (ADR-0023 §7 Rule of Three): a `source`
|
|
9
|
+
* discriminator + a pure `map()` + a tiny registry. It grows an abstraction only
|
|
10
|
+
* when a third concrete need appears.
|
|
11
|
+
*
|
|
12
|
+
* SCOPE: claim → candidate fields ONLY. A mapper does NOT verify the assertion
|
|
13
|
+
* (authenticity is Authentication's job, step 5), does NOT enforce invariants
|
|
14
|
+
* (the core does — a mapper may legitimately produce an incomplete candidate, and
|
|
15
|
+
* the core fail-closes on it), and does NOT decide the superuser flag from
|
|
16
|
+
* attacker-controllable claims (see {@link CandidatePrincipalFields.trustedSuperuserSignal}).
|
|
17
|
+
*
|
|
18
|
+
* ADR-0003: framework-agnostic — no framework / HTTP / DB imports here.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* A tiny registry of {@link IdentityClaimMapper}s, keyed by `source`. The
|
|
22
|
+
* normalization core dispatches on `assertion.source` through this: a hit selects
|
|
23
|
+
* the mapper; a MISS is an unknown/unregistered source → the core rejects
|
|
24
|
+
* (fail-closed — never fabricate a principal). Fresh per broker.
|
|
25
|
+
*/
|
|
26
|
+
export class IdentityClaimMapperRegistry {
|
|
27
|
+
mappers = new Map();
|
|
28
|
+
/**
|
|
29
|
+
* Register a mapper for its `source`. Fail-closed: an empty source or a
|
|
30
|
+
* duplicate registration throws LOUD (a silently-shadowed mapper could route
|
|
31
|
+
* an assertion to the wrong IdP).
|
|
32
|
+
*/
|
|
33
|
+
register(mapper) {
|
|
34
|
+
const { source } = mapper;
|
|
35
|
+
if (source.length === 0) {
|
|
36
|
+
throw new Error('IdentityClaimMapperRegistry.register: source must be non-empty');
|
|
37
|
+
}
|
|
38
|
+
if (this.mappers.has(source)) {
|
|
39
|
+
throw new Error(`IdentityClaimMapperRegistry.register: source "${source}" is already registered (duplicate mapper)`);
|
|
40
|
+
}
|
|
41
|
+
this.mappers.set(source, mapper);
|
|
42
|
+
}
|
|
43
|
+
/** Look up the mapper for a source, or `undefined` if none is registered. */
|
|
44
|
+
resolve(source) {
|
|
45
|
+
return this.mappers.get(source);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=claim-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-mapper.js","sourceRoot":"","sources":["../../src/identity/claim-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAoDH;;;;;GAKG;AACH,MAAM,OAAO,2BAA2B;IACrB,OAAO,GAAG,IAAI,GAAG,EAA+B,CAAC;IAElE;;;;OAIG;IACH,QAAQ,CAAC,MAA2B;QAClC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QACpF,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,iDAAiD,MAAM,4CAA4C,CACpG,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,6EAA6E;IAC7E,OAAO,CAAC,MAAc;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine seam: **Identity** — resolves *who* the principal is.
|
|
3
|
+
*
|
|
4
|
+
* The Identity Broker normalizes any source IdP into ONE uniform Principal model
|
|
5
|
+
* regardless of origin (010_Architecture "the request's journey" §1). Users,
|
|
6
|
+
* roles/groups, and service accounts flow through the SAME downstream decision
|
|
7
|
+
* (§7 of 050 AUTHORIZATION_REQUIREMENTS).
|
|
8
|
+
*
|
|
9
|
+
* The FROZEN public types below (ADR-0023, semver-published) are the seam other
|
|
10
|
+
* layers build against — DO NOT change them. The engine that IMPLEMENTS this seam
|
|
11
|
+
* (the normalization core, the IdP-adapter contract, the reference Internal
|
|
12
|
+
* adapter, and the `createIdentityBroker` factory) lives in the sibling files
|
|
13
|
+
* re-exported at the bottom of this barrel.
|
|
14
|
+
* ADR-0003: framework-agnostic — nothing here may import a framework.
|
|
15
|
+
*/
|
|
16
|
+
/** Kinds of principal that flow uniformly through the decision (§7.1). */
|
|
17
|
+
export type PrincipalKind = 'user' | 'role_group' | 'service_account';
|
|
18
|
+
/** The tenant is the default authorization boundary (§7.3 tenant gate). */
|
|
19
|
+
export interface Tenant {
|
|
20
|
+
readonly tenantId: string;
|
|
21
|
+
/** Human-readable label — never surface a raw id to end users. */
|
|
22
|
+
readonly displayName: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The normalized principal — the single identity model every layer consumes,
|
|
26
|
+
* produced by the Identity Broker from whichever IdP authenticated the caller.
|
|
27
|
+
*/
|
|
28
|
+
export interface Principal {
|
|
29
|
+
readonly kind: PrincipalKind;
|
|
30
|
+
/** Stable opaque id (internal — never rendered to end users). */
|
|
31
|
+
readonly id: string;
|
|
32
|
+
/** The principal's home tenant — the default boundary for the tenant gate. */
|
|
33
|
+
readonly tenantId: string;
|
|
34
|
+
/** Roles / groups this principal belongs to, by stable id. */
|
|
35
|
+
readonly roleIds: readonly string[];
|
|
36
|
+
/**
|
|
37
|
+
* The platform superuser bypasses the tenant gate (§7.3). Ordinary principals
|
|
38
|
+
* are `false`. Defaulting/enforcement is a later layer's concern.
|
|
39
|
+
*/
|
|
40
|
+
readonly isPlatformSuperuser: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** A raw assertion from some external IdP, prior to normalization. */
|
|
43
|
+
export interface ExternalIdentityAssertion {
|
|
44
|
+
/** Which IdP/source produced this assertion (e.g. an OIDC issuer id). */
|
|
45
|
+
readonly source: string;
|
|
46
|
+
/** Opaque provider-native claims — the broker maps these to a {@link Principal}. */
|
|
47
|
+
readonly claims: Readonly<Record<string, unknown>>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Identity Broker seam — normalizes any IdP assertion into one {@link Principal}.
|
|
51
|
+
* Implementation (claim mapping, IdP adapters) is a later layer.
|
|
52
|
+
*/
|
|
53
|
+
export interface IdentityBroker {
|
|
54
|
+
/** Normalize an external assertion into the uniform principal model. */
|
|
55
|
+
normalize(assertion: ExternalIdentityAssertion): Promise<Principal>;
|
|
56
|
+
}
|
|
57
|
+
export * from './claim-mapper.js';
|
|
58
|
+
export * from './internal-adapter.js';
|
|
59
|
+
export * from './broker.js';
|
|
60
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,iBAAiB,CAAC;AAEtE,2EAA2E;AAC3E,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;CACvC;AAED,sEAAsE;AACtE,MAAM,WAAW,yBAAyB;IACxC,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,SAAS,CAAC,SAAS,EAAE,yBAAyB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACrE;AAKD,cAAc,mBAAmB,CAAC;AAElC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine seam: **Identity** — resolves *who* the principal is.
|
|
3
|
+
*
|
|
4
|
+
* The Identity Broker normalizes any source IdP into ONE uniform Principal model
|
|
5
|
+
* regardless of origin (010_Architecture "the request's journey" §1). Users,
|
|
6
|
+
* roles/groups, and service accounts flow through the SAME downstream decision
|
|
7
|
+
* (§7 of 050 AUTHORIZATION_REQUIREMENTS).
|
|
8
|
+
*
|
|
9
|
+
* The FROZEN public types below (ADR-0023, semver-published) are the seam other
|
|
10
|
+
* layers build against — DO NOT change them. The engine that IMPLEMENTS this seam
|
|
11
|
+
* (the normalization core, the IdP-adapter contract, the reference Internal
|
|
12
|
+
* adapter, and the `createIdentityBroker` factory) lives in the sibling files
|
|
13
|
+
* re-exported at the bottom of this barrel.
|
|
14
|
+
* ADR-0003: framework-agnostic — nothing here may import a framework.
|
|
15
|
+
*/
|
|
16
|
+
// --- Engine implementation behind the frozen seam above (this layer) ---------
|
|
17
|
+
// The IdP-adapter contract (the extension seam future protocol adapters plug
|
|
18
|
+
// into) + its registry:
|
|
19
|
+
export * from './claim-mapper.js';
|
|
20
|
+
// The reference Internal / generic-claims adapter (the "own IdP" path):
|
|
21
|
+
export * from './internal-adapter.js';
|
|
22
|
+
// The normalization core + the `createIdentityBroker` factory + its error type:
|
|
23
|
+
export * from './broker.js';
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgDH,gFAAgF;AAChF,6EAA6E;AAC7E,wBAAwB;AACxB,cAAc,mBAAmB,CAAC;AAClC,wEAAwE;AACxE,cAAc,uBAAuB,CAAC;AACtC,gFAAgF;AAChF,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reference {@link IdentityClaimMapper} — the **Internal / generic-claims
|
|
3
|
+
* provider** (Shield's own first-party IdP path).
|
|
4
|
+
*
|
|
5
|
+
* It expects a CANONICAL claim shape (`id`, `tenantId`, `kind`, `roleIds`, and a
|
|
6
|
+
* superuser signal) and maps it 1:1 to {@link CandidatePrincipalFields}. This is
|
|
7
|
+
* the "own IdP" path AND the shape the future protocol adapters target: an OIDC /
|
|
8
|
+
* SAML / LDAP adapter's job is to translate its provider-native claims INTO this
|
|
9
|
+
* canonical shape, then this same normalization guarantees apply.
|
|
10
|
+
*
|
|
11
|
+
* Uniform treatment (ADR-0007): a `service_account` assertion flows through the
|
|
12
|
+
* EXACT SAME `map()` as a `user` — there is no "is-this-a-machine" branch. Kind
|
|
13
|
+
* is carried through as data.
|
|
14
|
+
*
|
|
15
|
+
* SUPERUSER SAFETY (security-critical). This adapter is the ONE trusted path that
|
|
16
|
+
* may propose the platform-superuser flag, and it does so ONLY via an EXPLICIT,
|
|
17
|
+
* ALLOWLISTED mechanism: the Internal source is configured with the exact set of
|
|
18
|
+
* canonical ids that ARE platform superusers (`superuserIds`). The flag is set
|
|
19
|
+
* `true` iff the asserted `id` is in that allowlist — it is NEVER read from a
|
|
20
|
+
* caller-supplied `superuser` / `isPlatformSuperuser` claim. So even on this
|
|
21
|
+
* trusted source, an attacker who can influence claim VALUES cannot flip it
|
|
22
|
+
* (they'd have to be in the server-side allowlist, which they can't write). Every
|
|
23
|
+
* other (external) adapter leaves the signal `false`. Default-deny, everywhere.
|
|
24
|
+
*
|
|
25
|
+
* ADR-0003: framework-agnostic — no framework / HTTP / DB imports.
|
|
26
|
+
*/
|
|
27
|
+
import { type IdentityClaimMapper } from './claim-mapper.js';
|
|
28
|
+
/** The canonical `source` id for Shield's first-party Internal provider. */
|
|
29
|
+
export declare const INTERNAL_IDENTITY_SOURCE = "internal";
|
|
30
|
+
/** Configuration for the Internal adapter — the trusted superuser allowlist. */
|
|
31
|
+
export interface InternalAdapterConfig {
|
|
32
|
+
/**
|
|
33
|
+
* SUPERUSER SAFETY: the explicit, server-side allowlist of canonical principal
|
|
34
|
+
* ids that ARE platform superusers on the Internal source. The ONLY way the
|
|
35
|
+
* `isPlatformSuperuser` flag is ever set. Default: empty ⇒ nobody is a
|
|
36
|
+
* superuser (default-deny). An external claim never contributes to this set.
|
|
37
|
+
*/
|
|
38
|
+
readonly superuserIds?: readonly string[];
|
|
39
|
+
/**
|
|
40
|
+
* Optional override of the `source` this adapter answers to (defaults to
|
|
41
|
+
* {@link INTERNAL_IDENTITY_SOURCE}). Lets a deployment name its own IdP while
|
|
42
|
+
* reusing the canonical-shape mapping + trusted superuser path.
|
|
43
|
+
*/
|
|
44
|
+
readonly source?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build the reference Internal adapter. It maps the canonical claim shape 1:1
|
|
48
|
+
* and — via the trusted, allowlisted mechanism only — proposes the superuser
|
|
49
|
+
* signal. It performs NO verification (auth's job) and enforces NO invariants
|
|
50
|
+
* (the core does): a missing `id`/`tenantId` is returned absent so the core
|
|
51
|
+
* fail-closes uniformly.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createInternalIdentityAdapter(config?: InternalAdapterConfig): IdentityClaimMapper;
|
|
54
|
+
//# sourceMappingURL=internal-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-adapter.d.ts","sourceRoot":"","sources":["../../src/identity/internal-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAE3B,4EAA4E;AAC5E,eAAO,MAAM,wBAAwB,aAAa,CAAC;AAEnD,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAoBD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,GAAE,qBAA0B,GACjC,mBAAmB,CAmCrB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reference {@link IdentityClaimMapper} — the **Internal / generic-claims
|
|
3
|
+
* provider** (Shield's own first-party IdP path).
|
|
4
|
+
*
|
|
5
|
+
* It expects a CANONICAL claim shape (`id`, `tenantId`, `kind`, `roleIds`, and a
|
|
6
|
+
* superuser signal) and maps it 1:1 to {@link CandidatePrincipalFields}. This is
|
|
7
|
+
* the "own IdP" path AND the shape the future protocol adapters target: an OIDC /
|
|
8
|
+
* SAML / LDAP adapter's job is to translate its provider-native claims INTO this
|
|
9
|
+
* canonical shape, then this same normalization guarantees apply.
|
|
10
|
+
*
|
|
11
|
+
* Uniform treatment (ADR-0007): a `service_account` assertion flows through the
|
|
12
|
+
* EXACT SAME `map()` as a `user` — there is no "is-this-a-machine" branch. Kind
|
|
13
|
+
* is carried through as data.
|
|
14
|
+
*
|
|
15
|
+
* SUPERUSER SAFETY (security-critical). This adapter is the ONE trusted path that
|
|
16
|
+
* may propose the platform-superuser flag, and it does so ONLY via an EXPLICIT,
|
|
17
|
+
* ALLOWLISTED mechanism: the Internal source is configured with the exact set of
|
|
18
|
+
* canonical ids that ARE platform superusers (`superuserIds`). The flag is set
|
|
19
|
+
* `true` iff the asserted `id` is in that allowlist — it is NEVER read from a
|
|
20
|
+
* caller-supplied `superuser` / `isPlatformSuperuser` claim. So even on this
|
|
21
|
+
* trusted source, an attacker who can influence claim VALUES cannot flip it
|
|
22
|
+
* (they'd have to be in the server-side allowlist, which they can't write). Every
|
|
23
|
+
* other (external) adapter leaves the signal `false`. Default-deny, everywhere.
|
|
24
|
+
*
|
|
25
|
+
* ADR-0003: framework-agnostic — no framework / HTTP / DB imports.
|
|
26
|
+
*/
|
|
27
|
+
/** The canonical `source` id for Shield's first-party Internal provider. */
|
|
28
|
+
export const INTERNAL_IDENTITY_SOURCE = 'internal';
|
|
29
|
+
/** Read a claim as a trimmed non-empty string, or `undefined`. */
|
|
30
|
+
function asStr(value) {
|
|
31
|
+
if (typeof value !== 'string')
|
|
32
|
+
return undefined;
|
|
33
|
+
const trimmed = value.trim();
|
|
34
|
+
return trimmed.length === 0 ? undefined : trimmed;
|
|
35
|
+
}
|
|
36
|
+
/** Read a claim as an array of non-empty strings (roles); `[]` when absent. */
|
|
37
|
+
function asStrArray(value) {
|
|
38
|
+
if (!Array.isArray(value))
|
|
39
|
+
return [];
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const item of value) {
|
|
42
|
+
const s = asStr(item);
|
|
43
|
+
if (s !== undefined)
|
|
44
|
+
out.push(s);
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the reference Internal adapter. It maps the canonical claim shape 1:1
|
|
50
|
+
* and — via the trusted, allowlisted mechanism only — proposes the superuser
|
|
51
|
+
* signal. It performs NO verification (auth's job) and enforces NO invariants
|
|
52
|
+
* (the core does): a missing `id`/`tenantId` is returned absent so the core
|
|
53
|
+
* fail-closes uniformly.
|
|
54
|
+
*/
|
|
55
|
+
export function createInternalIdentityAdapter(config = {}) {
|
|
56
|
+
const source = config.source ?? INTERNAL_IDENTITY_SOURCE;
|
|
57
|
+
// Snapshot the allowlist into a Set at construction — it is SERVER-SIDE trusted
|
|
58
|
+
// config, never influenced by an assertion's claims.
|
|
59
|
+
const superuserIds = new Set(config.superuserIds ?? []);
|
|
60
|
+
return {
|
|
61
|
+
source,
|
|
62
|
+
map(claims) {
|
|
63
|
+
const id = asStr(claims.id);
|
|
64
|
+
const tenantId = asStr(claims.tenantId);
|
|
65
|
+
// Kind carried as data (uniform treatment) — the core validates it against
|
|
66
|
+
// the allowed PrincipalKind set and rejects an unrecognized value.
|
|
67
|
+
const kind = asStr(claims.kind);
|
|
68
|
+
const roleIds = asStrArray(claims.roleIds);
|
|
69
|
+
// SUPERUSER SAFETY: the flag comes SOLELY from the server-side allowlist
|
|
70
|
+
// keyed by the asserted (trusted) id — NEVER from claims.superuser /
|
|
71
|
+
// claims.isPlatformSuperuser. Those attacker-controllable claims are
|
|
72
|
+
// deliberately ignored here; the core also defaults the flag false.
|
|
73
|
+
const trustedSuperuserSignal = id !== undefined && superuserIds.has(id);
|
|
74
|
+
// Build with only the keys we actually have present — under
|
|
75
|
+
// `exactOptionalPropertyTypes` an optional field must be OMITTED (not set
|
|
76
|
+
// to `undefined`). A missing id/tenantId is returned absent so the core
|
|
77
|
+
// fail-closes uniformly.
|
|
78
|
+
const candidate = { roleIds, trustedSuperuserSignal };
|
|
79
|
+
return {
|
|
80
|
+
...candidate,
|
|
81
|
+
...(id !== undefined ? { id } : {}),
|
|
82
|
+
...(tenantId !== undefined ? { tenantId } : {}),
|
|
83
|
+
...(kind !== undefined ? { kind } : {}),
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=internal-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-adapter.js","sourceRoot":"","sources":["../../src/identity/internal-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAOH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAC;AAmBnD,kEAAkE;AAClE,SAAS,KAAK,CAAC,KAAc;IAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AACpD,CAAC;AAED,+EAA+E;AAC/E,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,SAAS;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAC3C,SAAgC,EAAE;IAElC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,wBAAwB,CAAC;IACzD,gFAAgF;IAChF,qDAAqD;IACrD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IAExD,OAAO;QACL,MAAM;QACN,GAAG,CAAC,MAAyC;YAC3C,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACxC,2EAA2E;YAC3E,mEAAmE;YACnE,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAChC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAE3C,yEAAyE;YACzE,qEAAqE;YACrE,qEAAqE;YACrE,oEAAoE;YACpE,MAAM,sBAAsB,GAAG,EAAE,KAAK,SAAS,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAExE,4DAA4D;YAC5D,0EAA0E;YAC1E,wEAAwE;YACxE,yBAAyB;YACzB,MAAM,SAAS,GAA6B,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;YAChF,OAAO;gBACL,GAAG,SAAS;gBACZ,GAAG,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/C,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@astram/core` — the framework-agnostic security Core (ADR-0003).
|
|
3
|
+
*
|
|
4
|
+
* **This barrel is the FROZEN public contract (ADR-0023).** Everything exported
|
|
5
|
+
* here is what Layer-3 teams and downstream consumers build against; keep it
|
|
6
|
+
* deliberate and stable (semver). ZERO framework imports (no @nestjs/*, react,
|
|
7
|
+
* react-dom, vite, express) — enforced by the root ESLint ADR-0003 boundary.
|
|
8
|
+
*
|
|
9
|
+
* The public surface is:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Six engine PORT interfaces** — one per layer, in the request's journey
|
|
12
|
+
* order. TYPES/INTERFACES ONLY; each is implemented by a later step (4-9):
|
|
13
|
+
* Identity (IdentityBroker) → Authentication (Authenticator) →
|
|
14
|
+
* Session (SessionAuthority) → Risk (RiskEngine) →
|
|
15
|
+
* Authorization (DecisionAuthority — the ONE decision entry) →
|
|
16
|
+
* Audit (AuditSink).
|
|
17
|
+
*
|
|
18
|
+
* 2. **The module-registers-metadata contract** — FieldDescriptor,
|
|
19
|
+
* ObjectTypeDescriptor, SupportingDependency (neverAutoGrant), ActionDescriptor
|
|
20
|
+
* (tier), ModuleMetadata; the `ModuleRegistry` interface (Team A implements)
|
|
21
|
+
* with its resolved lookups (RegisteredAction).
|
|
22
|
+
*
|
|
23
|
+
* 3. **Pure derivation RULES** (the only logic in this contract layer — no engine
|
|
24
|
+
* bodies): `derivePermissionKey` (the stable `feature:object:action` identity,
|
|
25
|
+
* ADR-0010) + the `PermissionKey` brand; `resolveTier` (ADR-0004 `gated`
|
|
26
|
+
* default) + `DEFAULT_ACCESS_TIER`; `resolveActionPermissionKey`.
|
|
27
|
+
*
|
|
28
|
+
* 4. **The boot-completeness-check contract** (ADR-0002/0010) — OperationInventory
|
|
29
|
+
* (caller-fed), CompletenessResult, and the `checkCompleteness` SIGNATURE
|
|
30
|
+
* (Team C implements the body).
|
|
31
|
+
*
|
|
32
|
+
* No engine logic lives here — decide()/normalize()/authenticate()/assess()/
|
|
33
|
+
* establish()/record() and checkCompleteness() are all seams/signatures only.
|
|
34
|
+
*/
|
|
35
|
+
export * from './identity/index.js';
|
|
36
|
+
export * from './authentication/index.js';
|
|
37
|
+
export * from './session/index.js';
|
|
38
|
+
export * from './risk/index.js';
|
|
39
|
+
export * from './authorization/index.js';
|
|
40
|
+
export * from './audit/index.js';
|
|
41
|
+
export * from './metadata/index.js';
|
|
42
|
+
export * from './admin/index.js';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,qBAAqB,CAAC;AAKpC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@astram/core` — the framework-agnostic security Core (ADR-0003).
|
|
3
|
+
*
|
|
4
|
+
* **This barrel is the FROZEN public contract (ADR-0023).** Everything exported
|
|
5
|
+
* here is what Layer-3 teams and downstream consumers build against; keep it
|
|
6
|
+
* deliberate and stable (semver). ZERO framework imports (no @nestjs/*, react,
|
|
7
|
+
* react-dom, vite, express) — enforced by the root ESLint ADR-0003 boundary.
|
|
8
|
+
*
|
|
9
|
+
* The public surface is:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Six engine PORT interfaces** — one per layer, in the request's journey
|
|
12
|
+
* order. TYPES/INTERFACES ONLY; each is implemented by a later step (4-9):
|
|
13
|
+
* Identity (IdentityBroker) → Authentication (Authenticator) →
|
|
14
|
+
* Session (SessionAuthority) → Risk (RiskEngine) →
|
|
15
|
+
* Authorization (DecisionAuthority — the ONE decision entry) →
|
|
16
|
+
* Audit (AuditSink).
|
|
17
|
+
*
|
|
18
|
+
* 2. **The module-registers-metadata contract** — FieldDescriptor,
|
|
19
|
+
* ObjectTypeDescriptor, SupportingDependency (neverAutoGrant), ActionDescriptor
|
|
20
|
+
* (tier), ModuleMetadata; the `ModuleRegistry` interface (Team A implements)
|
|
21
|
+
* with its resolved lookups (RegisteredAction).
|
|
22
|
+
*
|
|
23
|
+
* 3. **Pure derivation RULES** (the only logic in this contract layer — no engine
|
|
24
|
+
* bodies): `derivePermissionKey` (the stable `feature:object:action` identity,
|
|
25
|
+
* ADR-0010) + the `PermissionKey` brand; `resolveTier` (ADR-0004 `gated`
|
|
26
|
+
* default) + `DEFAULT_ACCESS_TIER`; `resolveActionPermissionKey`.
|
|
27
|
+
*
|
|
28
|
+
* 4. **The boot-completeness-check contract** (ADR-0002/0010) — OperationInventory
|
|
29
|
+
* (caller-fed), CompletenessResult, and the `checkCompleteness` SIGNATURE
|
|
30
|
+
* (Team C implements the body).
|
|
31
|
+
*
|
|
32
|
+
* No engine logic lives here — decide()/normalize()/authenticate()/assess()/
|
|
33
|
+
* establish()/record() and checkCompleteness() are all seams/signatures only.
|
|
34
|
+
*/
|
|
35
|
+
// Engine seams (one per layer) — PORTs, implemented by steps 4-9.
|
|
36
|
+
export * from './identity/index.js';
|
|
37
|
+
export * from './authentication/index.js';
|
|
38
|
+
export * from './session/index.js';
|
|
39
|
+
export * from './risk/index.js';
|
|
40
|
+
export * from './authorization/index.js';
|
|
41
|
+
export * from './audit/index.js';
|
|
42
|
+
// Module-registers-metadata contract + pure derivation rules + completeness check.
|
|
43
|
+
export * from './metadata/index.js';
|
|
44
|
+
// Admin Console (Layer 10) — a NEW top-level module (append-only; no frozen
|
|
45
|
+
// prior-layer seam changed): admin ports + query/command types + §11.3 safeguard
|
|
46
|
+
// signatures + the query/command service factories + command-pipeline order.
|
|
47
|
+
export * from './admin/index.js';
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,kEAAkE;AAClE,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AAEjC,mFAAmF;AACnF,cAAc,qBAAqB,CAAC;AAEpC,4EAA4E;AAC5E,iFAAiF;AACjF,6EAA6E;AAC7E,cAAc,kBAAkB,CAAC"}
|