@astram/guard 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent-provenance.d.ts +24 -0
- package/dist/agent/agent-provenance.d.ts.map +1 -1
- package/dist/agent/agent-provenance.js +33 -1
- package/dist/auth/auth.module.d.ts.map +1 -1
- package/dist/auth/auth.module.js +40 -2
- package/dist/auth/tokens.d.ts +14 -0
- package/dist/auth/tokens.d.ts.map +1 -1
- package/dist/auth/tokens.js +16 -2
- package/dist/authentication/service-account-principal.d.ts +29 -0
- package/dist/authentication/service-account-principal.d.ts.map +1 -0
- package/dist/authentication/service-account-principal.js +55 -0
- package/dist/enforcement/facts-version.d.ts +22 -0
- package/dist/enforcement/facts-version.d.ts.map +1 -0
- package/dist/enforcement/facts-version.js +34 -0
- package/dist/enforcement/global-enforcement.guard.d.ts +9 -26
- package/dist/enforcement/global-enforcement.guard.d.ts.map +1 -1
- package/dist/enforcement/global-enforcement.guard.js +48 -177
- package/dist/enforcement/session-facts-reload.d.ts +66 -0
- package/dist/enforcement/session-facts-reload.d.ts.map +1 -0
- package/dist/enforcement/session-facts-reload.js +168 -0
- package/dist/identity/identity-actions.d.ts +1 -1
- package/dist/identity/identity-actions.d.ts.map +1 -1
- package/dist/identity/identity-actions.js +4 -0
- package/dist/internal.d.ts +23 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +36 -1
- package/dist/module/shield-tokens.d.ts +60 -11
- package/dist/module/shield-tokens.d.ts.map +1 -1
- package/dist/notifications/notification.service.d.ts +3 -0
- package/dist/notifications/notification.service.d.ts.map +1 -1
- package/dist/notifications/notification.service.js +9 -0
- package/dist/request-auth/request-principal.d.ts +5 -0
- package/dist/request-auth/request-principal.d.ts.map +1 -1
- package/dist/request-auth/request-principal.js +7 -1
- package/dist/request-auth/session-token-binder.d.ts +79 -6
- package/dist/request-auth/session-token-binder.d.ts.map +1 -1
- package/dist/request-auth/session-token-binder.js +264 -173
- package/dist/session/call-principals.d.ts +54 -0
- package/dist/session/call-principals.d.ts.map +1 -0
- package/dist/session/call-principals.js +38 -0
- package/dist/session/session-principal.d.ts +86 -0
- package/dist/session/session-principal.d.ts.map +1 -0
- package/dist/session/session-principal.js +139 -0
- package/package.json +5 -5
|
@@ -21,4 +21,28 @@ export interface AgentProvenance {
|
|
|
21
21
|
export declare function mintAgentProvenance(taskId: string, callId: string): AgentProvenance;
|
|
22
22
|
/** `true` only for the exact object {@link mintAgentProvenance} returned. */
|
|
23
23
|
export declare function isMintedAgentProvenance(p: unknown): p is AgentProvenance;
|
|
24
|
+
/** The default and bounds of the per-account, per-kind pending cap (SPEC §5 J `maxPendingPerKind`). */
|
|
25
|
+
export declare const AGENT_UNATTENDED_PENDING_PER_KIND_DEFAULT = 20;
|
|
26
|
+
export declare const AGENT_UNATTENDED_PENDING_PER_KIND_MAX = 50;
|
|
27
|
+
/**
|
|
28
|
+
* Who proposed, for an unattended run: the agent acting as a service account (`requesterUuid` is
|
|
29
|
+
* the account). `maxPendingPerKind` is the agent's `unattended.maxPendingPerKind` option (1–50),
|
|
30
|
+
* carried in the minted object so identity applies the deployment's cap; absent ⇒ 20.
|
|
31
|
+
*/
|
|
32
|
+
export interface AgentUnattendedProvenance {
|
|
33
|
+
readonly origin: 'agent_unattended';
|
|
34
|
+
readonly taskId: string;
|
|
35
|
+
readonly callId: string;
|
|
36
|
+
readonly maxPendingPerKind?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Mint an unattended provenance for the executing call of an unattended (service-account) task.
|
|
40
|
+
* Same rule as {@link mintAgentProvenance}: a NEW frozen, registered object; a copy carries
|
|
41
|
+
* nothing. `maxPendingPerKind` must be an integer 1–50 when given.
|
|
42
|
+
*/
|
|
43
|
+
export declare function mintAgentUnattendedProvenance(taskId: string, callId: string, opts?: {
|
|
44
|
+
readonly maxPendingPerKind?: number;
|
|
45
|
+
}): AgentUnattendedProvenance;
|
|
46
|
+
/** `true` only for the exact object {@link mintAgentUnattendedProvenance} returned. */
|
|
47
|
+
export declare function isMintedAgentUnattendedProvenance(p: unknown): p is AgentUnattendedProvenance;
|
|
24
48
|
//# sourceMappingURL=agent-provenance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-provenance.d.ts","sourceRoot":"","sources":["../../src/agent/agent-provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,mGAAmG;AACnG,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAaD,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAQnF;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,eAAe,CAExE"}
|
|
1
|
+
{"version":3,"file":"agent-provenance.d.ts","sourceRoot":"","sources":["../../src/agent/agent-provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,mGAAmG;AACnG,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAaD,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAQnF;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,eAAe,CAExE;AAID,uGAAuG;AACvG,eAAO,MAAM,yCAAyC,KAAK,CAAC;AAC5D,eAAO,MAAM,qCAAqC,KAAK,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAKD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,IAAI,GAAE;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAO,GACjD,yBAAyB,CAkB3B;AAED,uFAAuF;AACvF,wBAAgB,iCAAiC,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,yBAAyB,CAE5F"}
|
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
* the agent executor mints; identity reads {@link isMintedAgentProvenance}.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AGENT_PROVENANCE_ID_MAX = void 0;
|
|
15
|
+
exports.AGENT_UNATTENDED_PENDING_PER_KIND_MAX = exports.AGENT_UNATTENDED_PENDING_PER_KIND_DEFAULT = exports.AGENT_PROVENANCE_ID_MAX = void 0;
|
|
16
16
|
exports.mintAgentProvenance = mintAgentProvenance;
|
|
17
17
|
exports.isMintedAgentProvenance = isMintedAgentProvenance;
|
|
18
|
+
exports.mintAgentUnattendedProvenance = mintAgentUnattendedProvenance;
|
|
19
|
+
exports.isMintedAgentUnattendedProvenance = isMintedAgentUnattendedProvenance;
|
|
18
20
|
/** The longest task or call id a provenance carries (identity `proposal.service.ts` `IDS_MAX`). */
|
|
19
21
|
exports.AGENT_PROVENANCE_ID_MAX = 64;
|
|
20
22
|
const minted = new WeakSet();
|
|
@@ -38,3 +40,33 @@ function mintAgentProvenance(taskId, callId) {
|
|
|
38
40
|
function isMintedAgentProvenance(p) {
|
|
39
41
|
return typeof p === 'object' && p !== null && minted.has(p);
|
|
40
42
|
}
|
|
43
|
+
// ── Unattended (service-account) agent provenance (background-agent-tasks SPEC v4 §5 G) ─────────
|
|
44
|
+
/** The default and bounds of the per-account, per-kind pending cap (SPEC §5 J `maxPendingPerKind`). */
|
|
45
|
+
exports.AGENT_UNATTENDED_PENDING_PER_KIND_DEFAULT = 20;
|
|
46
|
+
exports.AGENT_UNATTENDED_PENDING_PER_KIND_MAX = 50;
|
|
47
|
+
/** A separate set: an unattended provenance is never accepted as an interactive one, or back. */
|
|
48
|
+
const mintedUnattended = new WeakSet();
|
|
49
|
+
/**
|
|
50
|
+
* Mint an unattended provenance for the executing call of an unattended (service-account) task.
|
|
51
|
+
* Same rule as {@link mintAgentProvenance}: a NEW frozen, registered object; a copy carries
|
|
52
|
+
* nothing. `maxPendingPerKind` must be an integer 1–50 when given.
|
|
53
|
+
*/
|
|
54
|
+
function mintAgentUnattendedProvenance(taskId, callId, opts = {}) {
|
|
55
|
+
const cap = opts.maxPendingPerKind;
|
|
56
|
+
if (cap !== undefined &&
|
|
57
|
+
(!Number.isInteger(cap) || cap < 1 || cap > exports.AGENT_UNATTENDED_PENDING_PER_KIND_MAX)) {
|
|
58
|
+
throw new TypeError(`mintAgentUnattendedProvenance: maxPendingPerKind must be an integer 1-${exports.AGENT_UNATTENDED_PENDING_PER_KIND_MAX}`);
|
|
59
|
+
}
|
|
60
|
+
const provenance = Object.freeze({
|
|
61
|
+
origin: 'agent_unattended',
|
|
62
|
+
taskId: requireId('taskId', taskId),
|
|
63
|
+
callId: requireId('callId', callId),
|
|
64
|
+
...(cap !== undefined ? { maxPendingPerKind: cap } : {}),
|
|
65
|
+
});
|
|
66
|
+
mintedUnattended.add(provenance);
|
|
67
|
+
return provenance;
|
|
68
|
+
}
|
|
69
|
+
/** `true` only for the exact object {@link mintAgentUnattendedProvenance} returned. */
|
|
70
|
+
function isMintedAgentUnattendedProvenance(p) {
|
|
71
|
+
return typeof p === 'object' && p !== null && mintedUnattended.has(p);
|
|
72
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.module.d.ts","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,EAGL,KAAK,aAAa,EAElB,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AAaxB,OAAO,KAAK,EAGV,kBAAkB,EAOlB,QAAQ,EACR,cAAc,EAKf,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.module.d.ts","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,EAGL,KAAK,aAAa,EAElB,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AAaxB,OAAO,KAAK,EAGV,kBAAkB,EAOlB,QAAQ,EACR,cAAc,EAKf,MAAM,cAAc,CAAC;AAuItB,OAAO,KAAK,EAAE,4BAA4B,EAAqB,MAAM,2BAA2B,CAAC;AASjG,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAQ7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAGhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5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AC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,4BAA4B,EAAE,CAAC;CACtE;AAqHD;;;GAGG;AACH,2GAA2G;AAC3G,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,oBAAoB,KAAK,cAAc,CAAC;AAClF,eAAO,MAAM,6BAA6B,EAAE,QAO3C,CAAC;AAmEF;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAcrF;AAsFD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,CAQpE;AAUD;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,QAAQ,CAS1F;AAqCD;;;;;;GAMG;AACH,qBACa,UAAU;IACrB,MAAM,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,QAAQ;IAE1C;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,iBAAsB,GAAG,aAAa;CAwO/D"}
|
package/dist/auth/auth.module.js
CHANGED
|
@@ -145,6 +145,8 @@ const pending_mfa_store_js_1 = require("./pending-mfa-store.js");
|
|
|
145
145
|
const mfa_step_up_js_1 = require("./mfa-step-up.js");
|
|
146
146
|
const tokens_js_1 = require("./tokens.js");
|
|
147
147
|
const session_liveness_js_1 = require("../session/session-liveness.js");
|
|
148
|
+
const call_principals_js_1 = require("../session/call-principals.js");
|
|
149
|
+
const shield_tokens_js_1 = require("../module/shield-tokens.js");
|
|
148
150
|
const mariadb_notification_store_js_1 = require("../notifications/mariadb-notification-store.js");
|
|
149
151
|
const notification_service_js_1 = require("../notifications/notification.service.js");
|
|
150
152
|
const notification_retention_job_js_1 = require("../notifications/notification-retention.job.js");
|
|
@@ -475,12 +477,43 @@ const mfaLimiterProvider = {
|
|
|
475
477
|
*/
|
|
476
478
|
const serviceAuthenticatorProvider = {
|
|
477
479
|
provide: tokens_js_2.SHIELD_SERVICE_AUTHENTICATOR,
|
|
478
|
-
useFactory: (
|
|
479
|
-
store
|
|
480
|
+
useFactory: (store) => (0, core_1.createServiceAuthenticator)({
|
|
481
|
+
store,
|
|
480
482
|
hasher: new argon2id_password_hasher_js_1.Argon2idPasswordHasher(),
|
|
481
483
|
}),
|
|
484
|
+
inject: [tokens_js_1.SHIELD_API_KEY_STORE],
|
|
485
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* The guard's API-key store (ADR-0033): `shield_authz.service_account_key` JOIN the live account
|
|
488
|
+
* over {@link SHIELD_DB_POOL}. One instance shared by the authenticator above and the per-call
|
|
489
|
+
* principals below (background-agent-tasks SPEC §5 B), so both read keys the same way. Not exported.
|
|
490
|
+
*/
|
|
491
|
+
const apiKeyStoreProvider = {
|
|
492
|
+
provide: tokens_js_1.SHIELD_API_KEY_STORE,
|
|
493
|
+
useFactory: (pool, config) => new mariadb_api_key_store_js_1.MariaDbApiKeyStore(pool, (0, app_config_js_1.frameworkSchemasOf)(config)),
|
|
482
494
|
inject: [tokens_js_1.SHIELD_DB_POOL, config_module_js_1.APP_CONFIG],
|
|
483
495
|
};
|
|
496
|
+
/**
|
|
497
|
+
* The per-call principals (background-agent-tasks SPEC v2 §5 B): the guard's session binder and
|
|
498
|
+
* API-key store, wrapped. Only `@astram/agent` reads it, for its background and unattended runs;
|
|
499
|
+
* the enforcement guard never does (no read added to the per-request path). SPEC v9 §5 C: its
|
|
500
|
+
* session facts refresh runs the enforcement guard's own reload over the SAME collaborators the
|
|
501
|
+
* guard injects (the decision authority, the binder, the subtree resolver, the mandatory-2FA
|
|
502
|
+
* service); no decision authority wired ⇒ every refresh is `null` (fail closed).
|
|
503
|
+
*/
|
|
504
|
+
const callPrincipalsProvider = {
|
|
505
|
+
provide: tokens_js_1.SHIELD_CALL_PRINCIPALS,
|
|
506
|
+
useFactory: (binder, store, decisionAuthority, scopeSubtreeResolver, mfaRequirement) => new call_principals_js_1.GuardCallPrincipals(binder, store, Date.now, decisionAuthority
|
|
507
|
+
? { decisionAuthority, tokenBinder: binder, scopeSubtreeResolver, mfaRequirement }
|
|
508
|
+
: null),
|
|
509
|
+
inject: [
|
|
510
|
+
tokens_js_2.SHIELD_SESSION_TOKEN_BINDER,
|
|
511
|
+
tokens_js_1.SHIELD_API_KEY_STORE,
|
|
512
|
+
{ token: shield_tokens_js_1.SHIELD_DECISION_AUTHORITY, optional: true },
|
|
513
|
+
{ token: tokens_js_1.SHIELD_SCOPE_SUBTREE_RESOLVER, optional: true },
|
|
514
|
+
{ token: tokens_js_1.SHIELD_MFA_REQUIREMENT, optional: true },
|
|
515
|
+
],
|
|
516
|
+
};
|
|
484
517
|
/**
|
|
485
518
|
* configurable-framework-db spec 5.D: at application bootstrap (once, never per request, Shield
|
|
486
519
|
* #12) check that every guard migration is in the `@astram/migrate` ledger, read with ONE SELECT
|
|
@@ -1264,7 +1297,10 @@ let AuthModule = class AuthModule {
|
|
|
1264
1297
|
sessionLivenessProvider,
|
|
1265
1298
|
// The service-account API-key authenticator (ADR-0033) — `ask_…` bearer → service_account
|
|
1266
1299
|
// Principal. Provided here (with the guard) so the APP_GUARD sees it; exported below.
|
|
1300
|
+
apiKeyStoreProvider,
|
|
1267
1301
|
serviceAuthenticatorProvider,
|
|
1302
|
+
// background-agent-tasks §5 B: per-call principals for the agent's background runs.
|
|
1303
|
+
callPrincipalsProvider,
|
|
1268
1304
|
// The anti-brute-force rate limiters (spec §5): login (H1) + recovery, each
|
|
1269
1305
|
// a Redis-injected AttemptLimiter with its own threshold. Injected into
|
|
1270
1306
|
// AuthController (@Optional()).
|
|
@@ -1345,6 +1381,8 @@ let AuthModule = class AuthModule {
|
|
|
1345
1381
|
tokens_js_1.SHIELD_NOTIFICATIONS,
|
|
1346
1382
|
// G-036 M1: `@astram/agent` injects it (through @astram/guard/internal).
|
|
1347
1383
|
tokens_js_1.SHIELD_SESSION_LIVENESS,
|
|
1384
|
+
// background-agent-tasks §5 B: `@astram/agent` resolves it (through @astram/guard/internal).
|
|
1385
|
+
tokens_js_1.SHIELD_CALL_PRINCIPALS,
|
|
1348
1386
|
],
|
|
1349
1387
|
};
|
|
1350
1388
|
}
|
package/dist/auth/tokens.d.ts
CHANGED
|
@@ -420,6 +420,20 @@ export declare const SHIELD_SESSION_RESTRICTIONS: unique symbol;
|
|
|
420
420
|
* per-call freshness check. Never used on the guard's per-request path.
|
|
421
421
|
*/
|
|
422
422
|
export declare const SHIELD_SESSION_LIVENESS: unique symbol;
|
|
423
|
+
/**
|
|
424
|
+
* The per-call principals (background-agent-tasks SPEC v2 §5 B) — a
|
|
425
|
+
* {@link import('../session/call-principals.js').CallPrincipals}: `principalForSession` (Redis only)
|
|
426
|
+
* and `principalForServiceAccount` (the `ask_…` lookup), built by the guard's own code. Provided and
|
|
427
|
+
* exported by `AuthModule` (`auth: true`); on `@astram/guard/internal` for `@astram/agent`'s
|
|
428
|
+
* background and unattended runs. Never used on the guard's per-request path.
|
|
429
|
+
*/
|
|
430
|
+
export declare const SHIELD_CALL_PRINCIPALS: unique symbol;
|
|
431
|
+
/**
|
|
432
|
+
* The guard's {@link import('@astram/core').ApiKeyStore} instance (`MariaDbApiKeyStore` over
|
|
433
|
+
* `SHIELD_DB_POOL`), shared by `SHIELD_SERVICE_AUTHENTICATOR` and `SHIELD_CALL_PRINCIPALS` so both
|
|
434
|
+
* read keys through one store. Internal to `AuthModule` (not exported).
|
|
435
|
+
*/
|
|
436
|
+
export declare const SHIELD_API_KEY_STORE: unique symbol;
|
|
423
437
|
/**
|
|
424
438
|
* The validated `signInWith` option (auth capabilities R1.8; `readonly SignInMethod[]`, default
|
|
425
439
|
* `['email']`). Consumed by the default credential resolver (and by login-options).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/auth/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,eAA2B,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,YAAY,eAAyB,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,eAAuC,CAAC;AAE/E;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,eAAyC,CAAC;AAWnF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAE3E;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,eAA4C,CAAC;AAEzF;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,eAAyC,CAAC;AAEnF;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,eAA8C,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,eAAwC,CAAC;AAEjF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,eAAyC,CAAC;AAEnF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,eAAsC,CAAC;AAE7E;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,eAA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AuB,eAAoC,CAAC;AAEzE;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,eAA4C,CAAC;AAEzF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,eAAwC,CAAC;AAEjF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AAEvE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AAEnE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,eAA0C,CAAC;AAErF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,eAAsC,CAAC;AAE7E;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,eAAkC,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,eAAsC,CAAC;AAC7E,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AACzE,eAAO,MAAM,mBAAmB,eAAgC,CAAC"}
|
package/dist/auth/tokens.js
CHANGED
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
* ADR-0003: no framework/DB/crypto imports here — just Symbols (+ one re-export).
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.SHIELD_CAPTCHA_GATE = exports.SHIELD_CAPTCHA_VERIFIER = exports.SHIELD_NOTIFICATION_STORE = exports.SHIELD_NOTIFICATIONS = exports.SHIELD_CAPTCHA_CONFIG = exports.SHIELD_MFA_POLICY_FEATURE = exports.SHIELD_ACCOUNT_UNLOCKER = exports.SHIELD_ADMIN_STEP_UP = void 0;
|
|
26
|
+
exports.SHIELD_SIGN_IN_WITH = exports.SHIELD_API_KEY_STORE = exports.SHIELD_CALL_PRINCIPALS = exports.SHIELD_SESSION_LIVENESS = exports.SHIELD_SESSION_RESTRICTIONS = exports.SHIELD_PERMISSION_VERSION_CACHE = exports.SHIELD_PERMISSION_FACTS = exports.SHIELD_RESET_LIMITER = exports.SHIELD_FORGOT_HINT_LIMITER = exports.SHIELD_FORGOT_LIMITER = exports.SHIELD_LOGIN_TOTP_VERIFIER = exports.SHIELD_MFA_STEP_UP = exports.SHIELD_MFA_LIMITER = exports.SHIELD_RECOVERY_LIMITER = exports.SHIELD_LOGIN_IP_LIMITER = exports.SHIELD_LOGIN_LIMITER = exports.SHIELD_MEMBERSHIP_CHECKER = exports.SHIELD_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_SESSION_FACTS_PROJECTOR = exports.SHIELD_ROOT_IDS = exports.SHIELD_TOTP_VERIFIER_OVERRIDE = exports.SHIELD_TOTP_VERIFIER = exports.SHIELD_RESET_LINK_BASE_URL = exports.SHIELD_SESSION_SWEEPER = exports.SHIELD_MFA_DEVICE_STORE = exports.SHIELD_DEFAULT_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_DEFAULT_AUTH_AUDIT_SINK = exports.SHIELD_AUDIT_SINK = exports.SHIELD_PROFILE_WRITER = exports.SHIELD_RECOVERY_CODE_STORE = exports.SHIELD_EMAIL_DELIVERY = exports.SHIELD_ATTEMPT_LIMITER_FACTORY = exports.SHIELD_MESSAGE_DISPATCHER = exports.SHIELD_EMAIL_SENDER = exports.SHIELD_CONFIRM_EMAIL_LIMITER = exports.SHIELD_EMAIL_CHANGE_LIMITER = exports.SHIELD_EMAIL_CHANGE_LINK_BASE_URL = exports.SHIELD_EMAIL_ADDRESS_CHANGER = exports.SHIELD_EMAIL_CHANGE_TOKEN_STORE = exports.SHIELD_RESET_TOKEN_STORE = exports.SHIELD_CREDENTIAL_WRITER = exports.SHIELD_RECENT_ROTATION_STORE = exports.SHIELD_SESSION_AUTHORITY = exports.SHIELD_AUTHENTICATOR = exports.SHIELD_PROFILE_RESOLVER = exports.SHIELD_CREDENTIAL_RESOLVER = exports.SHIELD_REDIS = exports.SHIELD_AUDIT_SEALER_POOL = exports.SHIELD_DB_POOL = exports.SHIELD_PASSWORD_HASHER = void 0;
|
|
27
|
+
exports.SHIELD_CAPTCHA_GATE = exports.SHIELD_CAPTCHA_VERIFIER = exports.SHIELD_NOTIFICATION_STORE = exports.SHIELD_NOTIFICATIONS = exports.SHIELD_CAPTCHA_CONFIG = exports.SHIELD_MFA_POLICY_FEATURE = exports.SHIELD_ACCOUNT_UNLOCKER = exports.SHIELD_ADMIN_STEP_UP = exports.SHIELD_MFA_REQUIREMENT = exports.SHIELD_MFA_REQUIREMENT_SOURCE = void 0;
|
|
28
28
|
var argon2id_password_hasher_js_1 = require("../authentication/argon2id-password-hasher.js");
|
|
29
29
|
Object.defineProperty(exports, "SHIELD_PASSWORD_HASHER", { enumerable: true, get: function () { return argon2id_password_hasher_js_1.SHIELD_PASSWORD_HASHER; } });
|
|
30
30
|
/**
|
|
@@ -440,6 +440,20 @@ exports.SHIELD_SESSION_RESTRICTIONS = Symbol('SHIELD_SESSION_RESTRICTIONS');
|
|
|
440
440
|
* per-call freshness check. Never used on the guard's per-request path.
|
|
441
441
|
*/
|
|
442
442
|
exports.SHIELD_SESSION_LIVENESS = Symbol('SHIELD_SESSION_LIVENESS');
|
|
443
|
+
/**
|
|
444
|
+
* The per-call principals (background-agent-tasks SPEC v2 §5 B) — a
|
|
445
|
+
* {@link import('../session/call-principals.js').CallPrincipals}: `principalForSession` (Redis only)
|
|
446
|
+
* and `principalForServiceAccount` (the `ask_…` lookup), built by the guard's own code. Provided and
|
|
447
|
+
* exported by `AuthModule` (`auth: true`); on `@astram/guard/internal` for `@astram/agent`'s
|
|
448
|
+
* background and unattended runs. Never used on the guard's per-request path.
|
|
449
|
+
*/
|
|
450
|
+
exports.SHIELD_CALL_PRINCIPALS = Symbol('SHIELD_CALL_PRINCIPALS');
|
|
451
|
+
/**
|
|
452
|
+
* The guard's {@link import('@astram/core').ApiKeyStore} instance (`MariaDbApiKeyStore` over
|
|
453
|
+
* `SHIELD_DB_POOL`), shared by `SHIELD_SERVICE_AUTHENTICATOR` and `SHIELD_CALL_PRINCIPALS` so both
|
|
454
|
+
* read keys through one store. Internal to `AuthModule` (not exported).
|
|
455
|
+
*/
|
|
456
|
+
exports.SHIELD_API_KEY_STORE = Symbol('SHIELD_API_KEY_STORE');
|
|
443
457
|
/**
|
|
444
458
|
* The validated `signInWith` option (auth capabilities R1.8; `readonly SignInMethod[]`, default
|
|
445
459
|
* `['email']`). Consumed by the default credential resolver (and by login-options).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-call service-account principal (background-agent-tasks SPEC v2 §5 B, §11 A, D).
|
|
3
|
+
*
|
|
4
|
+
* `principalForServiceAccount(store, accountId, keyVersion, tenantId)` rebuilds the
|
|
5
|
+
* {@link Principal} the enforcement guard builds for an `ask_…` request of that key, for a call
|
|
6
|
+
* made outside any HTTP request (an unattended agent run). It reuses the guard's own path
|
|
7
|
+
* (Shield #3):
|
|
8
|
+
* - the record: the same {@link ApiKeyStore} instance the guard's `SHIELD_SERVICE_AUTHENTICATOR`
|
|
9
|
+
* reads (`MariaDbApiKeyStore.getByAccountId`: current key version, live account status, live
|
|
10
|
+
* roles and scope, account tenant = key tenant, tenant company exists);
|
|
11
|
+
* - the lifecycle and the principal: core {@link servicePrincipalFromKeyRecord}, the construction
|
|
12
|
+
* `createServiceAuthenticator` runs after the secret verifies.
|
|
13
|
+
* The secret is not re-verified (it is never stored): the key the run started under is named by its
|
|
14
|
+
* version instead, and a different current version (rotated) is `null`.
|
|
15
|
+
*
|
|
16
|
+
* `null` (fail closed) when there is no record (unknown or deleted account, account not `active`,
|
|
17
|
+
* account tenant ≠ key tenant, tenant company gone), the current key version is not `keyVersion`
|
|
18
|
+
* (rotated), the key is revoked or expired, the account's tenant is not `tenantId`, or the store
|
|
19
|
+
* fails.
|
|
20
|
+
*
|
|
21
|
+
* ⚠ Shield #12 / SPEC §11 D: this is the SAME single MariaDB query the guard's `ask_…` path runs on
|
|
22
|
+
* every request (`MariaDbApiKeyStore.getByAccountId`); there is no Redis cache of it in the guard.
|
|
23
|
+
* Called per agent call, it adds that query per call.
|
|
24
|
+
*/
|
|
25
|
+
import { type ApiKeyStore, type Principal } from '@astram/core';
|
|
26
|
+
/** The store surface used (the guard authenticator's lookup). */
|
|
27
|
+
export type ApiKeyRecordReader = Pick<ApiKeyStore, 'getByAccountId'>;
|
|
28
|
+
export declare function principalForServiceAccount(store: ApiKeyRecordReader, accountId: string, keyVersion: number, tenantId: string, now?: () => number): Promise<Principal | null>;
|
|
29
|
+
//# sourceMappingURL=service-account-principal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-account-principal.d.ts","sourceRoot":"","sources":["../../src/authentication/service-account-principal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAiC,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAG/F,iEAAiE;AACjE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAErE,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,kBAAkB,EACzB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,GAAG,GAAE,MAAM,MAAiB,GAC3B,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAkB3B"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.principalForServiceAccount = principalForServiceAccount;
|
|
4
|
+
/**
|
|
5
|
+
* The per-call service-account principal (background-agent-tasks SPEC v2 §5 B, §11 A, D).
|
|
6
|
+
*
|
|
7
|
+
* `principalForServiceAccount(store, accountId, keyVersion, tenantId)` rebuilds the
|
|
8
|
+
* {@link Principal} the enforcement guard builds for an `ask_…` request of that key, for a call
|
|
9
|
+
* made outside any HTTP request (an unattended agent run). It reuses the guard's own path
|
|
10
|
+
* (Shield #3):
|
|
11
|
+
* - the record: the same {@link ApiKeyStore} instance the guard's `SHIELD_SERVICE_AUTHENTICATOR`
|
|
12
|
+
* reads (`MariaDbApiKeyStore.getByAccountId`: current key version, live account status, live
|
|
13
|
+
* roles and scope, account tenant = key tenant, tenant company exists);
|
|
14
|
+
* - the lifecycle and the principal: core {@link servicePrincipalFromKeyRecord}, the construction
|
|
15
|
+
* `createServiceAuthenticator` runs after the secret verifies.
|
|
16
|
+
* The secret is not re-verified (it is never stored): the key the run started under is named by its
|
|
17
|
+
* version instead, and a different current version (rotated) is `null`.
|
|
18
|
+
*
|
|
19
|
+
* `null` (fail closed) when there is no record (unknown or deleted account, account not `active`,
|
|
20
|
+
* account tenant ≠ key tenant, tenant company gone), the current key version is not `keyVersion`
|
|
21
|
+
* (rotated), the key is revoked or expired, the account's tenant is not `tenantId`, or the store
|
|
22
|
+
* fails.
|
|
23
|
+
*
|
|
24
|
+
* ⚠ Shield #12 / SPEC §11 D: this is the SAME single MariaDB query the guard's `ask_…` path runs on
|
|
25
|
+
* every request (`MariaDbApiKeyStore.getByAccountId`); there is no Redis cache of it in the guard.
|
|
26
|
+
* Called per agent call, it adds that query per call.
|
|
27
|
+
*/
|
|
28
|
+
const core_1 = require("@astram/core");
|
|
29
|
+
const session_principal_js_1 = require("../session/session-principal.js");
|
|
30
|
+
async function principalForServiceAccount(store, accountId, keyVersion, tenantId, now = Date.now) {
|
|
31
|
+
if (typeof accountId !== 'string' || accountId === '')
|
|
32
|
+
return null;
|
|
33
|
+
if (typeof keyVersion !== 'number' || !Number.isSafeInteger(keyVersion) || keyVersion < 1) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
let record;
|
|
37
|
+
try {
|
|
38
|
+
record = await store.getByAccountId(accountId);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null; // store outage → fail closed (the authenticator's uniform failure).
|
|
42
|
+
}
|
|
43
|
+
if (record === null || record === undefined)
|
|
44
|
+
return null;
|
|
45
|
+
if (record.accountId !== accountId)
|
|
46
|
+
return null;
|
|
47
|
+
if (record.version !== keyVersion)
|
|
48
|
+
return null; // rotated past the run's key
|
|
49
|
+
const principal = (0, core_1.servicePrincipalFromKeyRecord)(record, now());
|
|
50
|
+
if (principal === null)
|
|
51
|
+
return null; // revoked or expired
|
|
52
|
+
if (!(0, session_principal_js_1.sameId)(principal.tenantId, tenantId))
|
|
53
|
+
return null;
|
|
54
|
+
return principal;
|
|
55
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The permission-version rules the enforcement guard applies to a principal it derives (ADR-0035,
|
|
3
|
+
* G-036 M1 SPEC §5 run-loop "Manifest"). Shared by {@link import('./global-enforcement.guard.js').GlobalEnforcementGuard}
|
|
4
|
+
* and the per-call session principal (`session/session-principal.ts`, background-agent-tasks SPEC
|
|
5
|
+
* §5 B), so both stamp a principal with the same version under the same rule (Shield #3).
|
|
6
|
+
*/
|
|
7
|
+
import type { CoarseGrants, Principal } from '@astram/core';
|
|
8
|
+
/**
|
|
9
|
+
* The binding's cached facts as gate 5 may use them (ADR-0035): absent, or at/past their
|
|
10
|
+
* `validUntilMs` time bound ⇒ `null` (gate 5 reloads). Never fabricated.
|
|
11
|
+
*/
|
|
12
|
+
export declare function usableCachedFacts(facts: CoarseGrants | undefined, nowMs: number): CoarseGrants | null;
|
|
13
|
+
/**
|
|
14
|
+
* The permission version a principal was derived under: gate 5's reload version, else the version
|
|
15
|
+
* of the cached facts it served. `undefined` (callers fail closed) when there is neither, when the
|
|
16
|
+
* principal is ROOT and nothing was reloaded (gate 5 loads and checks no grants for root, so cached
|
|
17
|
+
* facts it never compared say nothing, SPEC v8), when a due subtree re-derive failed
|
|
18
|
+
* (`subtreeStale`: the subtree belongs to no single version), or when the value is not a
|
|
19
|
+
* non-negative safe integer.
|
|
20
|
+
*/
|
|
21
|
+
export declare function derivedFactsVersion(principal: Pick<Principal, 'isRoot'>, reloaded: CoarseGrants | undefined, usableFacts: CoarseGrants | null, subtreeStale: boolean): number | undefined;
|
|
22
|
+
//# sourceMappingURL=facts-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts-version.d.ts","sourceRoot":"","sources":["../../src/enforcement/facts-version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5D;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,KAAK,EAAE,MAAM,GACZ,YAAY,GAAG,IAAI,CAIrB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EACpC,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,WAAW,EAAE,YAAY,GAAG,IAAI,EAChC,YAAY,EAAE,OAAO,GACpB,MAAM,GAAG,SAAS,CAapB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usableCachedFacts = usableCachedFacts;
|
|
4
|
+
exports.derivedFactsVersion = derivedFactsVersion;
|
|
5
|
+
/**
|
|
6
|
+
* The binding's cached facts as gate 5 may use them (ADR-0035): absent, or at/past their
|
|
7
|
+
* `validUntilMs` time bound ⇒ `null` (gate 5 reloads). Never fabricated.
|
|
8
|
+
*/
|
|
9
|
+
function usableCachedFacts(facts, nowMs) {
|
|
10
|
+
if (facts === undefined)
|
|
11
|
+
return null;
|
|
12
|
+
if (typeof facts.validUntilMs === 'number' && nowMs >= facts.validUntilMs)
|
|
13
|
+
return null;
|
|
14
|
+
return facts;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The permission version a principal was derived under: gate 5's reload version, else the version
|
|
18
|
+
* of the cached facts it served. `undefined` (callers fail closed) when there is neither, when the
|
|
19
|
+
* principal is ROOT and nothing was reloaded (gate 5 loads and checks no grants for root, so cached
|
|
20
|
+
* facts it never compared say nothing, SPEC v8), when a due subtree re-derive failed
|
|
21
|
+
* (`subtreeStale`: the subtree belongs to no single version), or when the value is not a
|
|
22
|
+
* non-negative safe integer.
|
|
23
|
+
*/
|
|
24
|
+
function derivedFactsVersion(principal, reloaded, usableFacts, subtreeStale) {
|
|
25
|
+
const derivedUnder = reloaded?.permissionsVersion ??
|
|
26
|
+
(principal.isRoot ? undefined : usableFacts?.permissionsVersion);
|
|
27
|
+
if (!subtreeStale &&
|
|
28
|
+
typeof derivedUnder === 'number' &&
|
|
29
|
+
Number.isSafeInteger(derivedUnder) &&
|
|
30
|
+
derivedUnder >= 0) {
|
|
31
|
+
return derivedUnder;
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
2
|
import { Reflector } from '@nestjs/core';
|
|
3
3
|
import type { CoreDecisionAuthority } from './core-seam.js';
|
|
4
|
-
import {
|
|
4
|
+
import type { SessionTokenBinder } from '../request-auth/session-token-binder.js';
|
|
5
5
|
import type { ServiceAuthenticator } from '@astram/core';
|
|
6
6
|
import type { ScopeSubtreeResolver } from '../auth/ports/scope-subtree-resolver.js';
|
|
7
7
|
import { type MfaRequirementService } from '../session/mfa-requirement-service.js';
|
|
@@ -17,6 +17,14 @@ import { type MfaRequirementService } from '../session/mfa-requirement-service.j
|
|
|
17
17
|
* On `@astram/guard/internal` for `@astram/agent`'s run-start snapshot check.
|
|
18
18
|
*/
|
|
19
19
|
export declare function requestFactsVersion(req: unknown): number | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The key version the enforcement guard verified this request's `ask_` key at (core
|
|
22
|
+
* `ServiceAuthResult.keyVersion`). `undefined` for a session request, a request the guard did not
|
|
23
|
+
* authenticate, a public route, a non-object, or an authenticator that reported none (callers fail
|
|
24
|
+
* closed). On `@astram/guard/internal` for `@astram/agent` only: an unattended task stores it, so a
|
|
25
|
+
* key rotation stops the task. Never an input to a decision.
|
|
26
|
+
*/
|
|
27
|
+
export declare function requestServiceKeyVersion(req: unknown): number | undefined;
|
|
20
28
|
/**
|
|
21
29
|
* Global, fail-closed enforcement guard (ADR-0002) — now with REAL request
|
|
22
30
|
* authorization for classified routes.
|
|
@@ -61,30 +69,5 @@ export declare class GlobalEnforcementGuard implements CanActivate {
|
|
|
61
69
|
* `mfa_enrollment_required`). Fail closed: an allowlist, so an unknown route is denied too.
|
|
62
70
|
*/
|
|
63
71
|
private enforceRestriction;
|
|
64
|
-
/**
|
|
65
|
-
* Write gate 5's reloaded grants and the live roles onto the session binding (ADR-0035). Session
|
|
66
|
-
* bindings only: a service-account key has no binding (its roles and scope are read live per
|
|
67
|
-
* request by the key store). Best-effort and conditional (same session, same tenant, fresher
|
|
68
|
-
* facts, `XX`): a miss or a Redis error only means the next request reloads again.
|
|
69
|
-
*/
|
|
70
|
-
private rebindReloadedGrants;
|
|
71
|
-
/**
|
|
72
|
-
* Re-derive the session's scope subtree after gate 5 reloaded facts at `reloadedVersion`
|
|
73
|
-
* (security hardening Phase 1C). Identity bumps a tenant's permission version when a company is
|
|
74
|
-
* created, moved or deleted under it, so a reload at a version newer than the bound subtree's
|
|
75
|
-
* stamp means the subtree may be stale: resolve it again with the SAME resolver login uses,
|
|
76
|
-
* rebind it (token + session entries) and return the principal the handler should see.
|
|
77
|
-
*
|
|
78
|
-
* Off the hot path: runs only for a session binding that carries a subtree, with a resolver
|
|
79
|
-
* wired, and a reload NEWER than its stamp (or no stamp yet — once, then stamped). That is the
|
|
80
|
-
* only DB read added (one closure query), and only on a version change.
|
|
81
|
-
*
|
|
82
|
-
* FAIL-CLOSED, NON-WIDENING: a resolver error, a non-array or an EMPTY result →
|
|
83
|
-
* {@link SUBTREE_REDERIVE_FAILED}: the bound subtree stays (never replaced by a guess, never
|
|
84
|
-
* widened), the stamp is not advanced, the reloaded facts are not cached (ADR-0035), and the next
|
|
85
|
-
* request reloads and retries. `null` = no re-derive was due. A failed Redis rebind still returns the fresh principal for this request
|
|
86
|
-
* (the DB answer is authoritative); the next reload retries the rebind.
|
|
87
|
-
*/
|
|
88
|
-
private rederiveSubtreeOnVersionMove;
|
|
89
72
|
}
|
|
90
73
|
//# sourceMappingURL=global-enforcement.guard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-enforcement.guard.d.ts","sourceRoot":"","sources":["../../src/enforcement/global-enforcement.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAMjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAK5D,OAAO,
|
|
1
|
+
{"version":3,"file":"global-enforcement.guard.d.ts","sourceRoot":"","sources":["../../src/enforcement/global-enforcement.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAMjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAK5D,OAAO,KAAK,EAEV,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA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