@astram/guard 0.37.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.
Files changed (69) hide show
  1. package/dist/agent/agent-provenance.d.ts +24 -0
  2. package/dist/agent/agent-provenance.d.ts.map +1 -1
  3. package/dist/agent/agent-provenance.js +33 -1
  4. package/dist/auth/auth.controller.d.ts.map +1 -1
  5. package/dist/auth/auth.controller.js +5 -1
  6. package/dist/auth/auth.module.d.ts.map +1 -1
  7. package/dist/auth/auth.module.js +40 -2
  8. package/dist/auth/dto.d.ts +2 -0
  9. package/dist/auth/dto.d.ts.map +1 -1
  10. package/dist/auth/tokens.d.ts +14 -0
  11. package/dist/auth/tokens.d.ts.map +1 -1
  12. package/dist/auth/tokens.js +16 -2
  13. package/dist/authentication/service-account-principal.d.ts +29 -0
  14. package/dist/authentication/service-account-principal.d.ts.map +1 -0
  15. package/dist/authentication/service-account-principal.js +55 -0
  16. package/dist/authz/mariadb-policy-store.d.ts +38 -3
  17. package/dist/authz/mariadb-policy-store.d.ts.map +1 -1
  18. package/dist/authz/mariadb-policy-store.js +61 -4
  19. package/dist/completeness/catalog-reconciler.d.ts +10 -1
  20. package/dist/completeness/catalog-reconciler.d.ts.map +1 -1
  21. package/dist/completeness/catalog-reconciler.js +23 -4
  22. package/dist/completeness/ports/catalog-store.d.ts +19 -2
  23. package/dist/completeness/ports/catalog-store.d.ts.map +1 -1
  24. package/dist/enforcement/facts-version.d.ts +22 -0
  25. package/dist/enforcement/facts-version.d.ts.map +1 -0
  26. package/dist/enforcement/facts-version.js +34 -0
  27. package/dist/enforcement/global-enforcement.guard.d.ts +9 -26
  28. package/dist/enforcement/global-enforcement.guard.d.ts.map +1 -1
  29. package/dist/enforcement/global-enforcement.guard.js +48 -177
  30. package/dist/enforcement/session-facts-reload.d.ts +66 -0
  31. package/dist/enforcement/session-facts-reload.d.ts.map +1 -0
  32. package/dist/enforcement/session-facts-reload.js +168 -0
  33. package/dist/identity/auth-facts.controller.d.ts.map +1 -1
  34. package/dist/identity/auth-facts.controller.js +5 -1
  35. package/dist/identity/identity-actions.d.ts +9 -1
  36. package/dist/identity/identity-actions.d.ts.map +1 -1
  37. package/dist/identity/identity-actions.js +12 -1
  38. package/dist/identity/module-registry.bridge.d.ts +16 -0
  39. package/dist/identity/module-registry.bridge.d.ts.map +1 -1
  40. package/dist/identity/module-registry.bridge.js +45 -0
  41. package/dist/identity/permission-facts.adapter.d.ts +41 -1
  42. package/dist/identity/permission-facts.adapter.d.ts.map +1 -1
  43. package/dist/identity/permission-facts.adapter.js +98 -1
  44. package/dist/index.d.ts +6 -5
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +12 -6
  47. package/dist/internal.d.ts +23 -0
  48. package/dist/internal.d.ts.map +1 -1
  49. package/dist/internal.js +36 -1
  50. package/dist/module/shield-tokens.d.ts +87 -11
  51. package/dist/module/shield-tokens.d.ts.map +1 -1
  52. package/dist/module/shield-tokens.js +8 -1
  53. package/dist/notifications/notification.service.d.ts +3 -0
  54. package/dist/notifications/notification.service.d.ts.map +1 -1
  55. package/dist/notifications/notification.service.js +9 -0
  56. package/dist/request-auth/request-principal.d.ts +5 -0
  57. package/dist/request-auth/request-principal.d.ts.map +1 -1
  58. package/dist/request-auth/request-principal.js +7 -1
  59. package/dist/request-auth/session-token-binder.d.ts +79 -6
  60. package/dist/request-auth/session-token-binder.d.ts.map +1 -1
  61. package/dist/request-auth/session-token-binder.js +264 -173
  62. package/dist/session/call-principals.d.ts +54 -0
  63. package/dist/session/call-principals.d.ts.map +1 -0
  64. package/dist/session/call-principals.js +38 -0
  65. package/dist/session/session-principal.d.ts +86 -0
  66. package/dist/session/session-principal.d.ts.map +1 -0
  67. package/dist/session/session-principal.js +139 -0
  68. package/migrations/1710000000143-AddPermissionGroup.cjs +41 -0
  69. package/package.json +5 -5
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuardCallPrincipals = void 0;
4
+ const session_principal_js_1 = require("./session-principal.js");
5
+ const service_account_principal_js_1 = require("../authentication/service-account-principal.js");
6
+ class GuardCallPrincipals {
7
+ binder;
8
+ keyStore;
9
+ now;
10
+ refresh;
11
+ constructor(binder,
12
+ /** `null` when no API-key store is wired: every service-account call is `null`. */
13
+ keyStore, now = Date.now,
14
+ /**
15
+ * The guard's reload collaborators (`null` when no decision authority is wired: every refresh
16
+ * is `null`, fail closed). Its `tokenBinder` is the same binder instance as `binder`.
17
+ */
18
+ refresh = null) {
19
+ this.binder = binder;
20
+ this.keyStore = keyStore;
21
+ this.now = now;
22
+ this.refresh = refresh;
23
+ }
24
+ principalForSession(sessionId, tenantId, userId) {
25
+ return (0, session_principal_js_1.principalForSession)(this.binder, sessionId, tenantId, userId, this.now);
26
+ }
27
+ async principalForServiceAccount(accountId, keyId, tenantId) {
28
+ if (this.keyStore === null)
29
+ return null;
30
+ return (0, service_account_principal_js_1.principalForServiceAccount)(this.keyStore, accountId, keyId, tenantId, this.now);
31
+ }
32
+ async refreshSessionFacts(sessionId, tenantId, userId) {
33
+ if (this.refresh === null)
34
+ return null;
35
+ return (0, session_principal_js_1.refreshSessionFacts)(this.refresh, sessionId, tenantId, userId, this.now);
36
+ }
37
+ }
38
+ exports.GuardCallPrincipals = GuardCallPrincipals;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * The per-call session principal (background-agent-tasks SPEC v2 §5 B, §11 A, D).
3
+ *
4
+ * `principalForSession(binder, sessionId, tenantId, userId)` rebuilds the {@link Principal} the
5
+ * enforcement guard builds for a request of that session, from Redis facts only, for a call made
6
+ * outside any HTTP request (a background agent run). It reuses the guard's own steps (Shield #3):
7
+ * - the claims: {@link SessionTokenBinder.resolveSession} — the binder's own parser
8
+ * (`parseBoundClaims`) and session-state overlay (`overlaySessionState`) that `resolve()` runs
9
+ * for every request, applied to the session-claims entry the request path's liveness gate reads;
10
+ * - the restricted-session rule: {@link restrictionOf} (the guard's `enforceRestriction` rule,
11
+ * grace deadline included). A restricted session reaches only the re-secure allowlist, which no
12
+ * agent call is on, so it is `null` here;
13
+ * - the principal: {@link principalFromClaims} (the request path's construction);
14
+ * - the facts version: {@link usableCachedFacts} + {@link derivedFactsVersion} (the rule behind the
15
+ * guard's `requestFactsVersion`), read with {@link principalFactsVersion}.
16
+ *
17
+ * `null` (fail closed, Shield #1/#12) when the session ended or was revoked (entry gone), the entry
18
+ * is malformed or belongs to another session, its active tenant is not `tenantId` (scope switch),
19
+ * its user is not `userId`, it is a service-account binding, it is restricted (re-enrol or mandatory
20
+ * 2FA), or Redis errors. One Redis GET; no MariaDB read.
21
+ *
22
+ * Not done here (the guard does it per request, both need MariaDB): gate 5's grant reload and the
23
+ * mandatory-2FA recompute after a permission-version move. The principal carries the roles and
24
+ * subtree the binding holds, i.e. the ones the guard rebound after its last reload; the caller
25
+ * compares {@link principalFactsVersion} with the tenant's current version and stops on a move.
26
+ *
27
+ * {@link refreshSessionFacts} (background-agent-tasks SPEC v9 §5 C) is that reload, off-request:
28
+ * the guard's own request-path code ({@link decideOnSessionFacts}, shared with the enforcement
29
+ * guard), for a background run's liveness poll once the session's cached facts are unusable.
30
+ */
31
+ import type { Principal } from '@astram/core';
32
+ import type { SessionTokenBinder } from '../request-auth/session-token-binder.js';
33
+ import { type SessionFactsReloadDeps } from '../enforcement/session-facts-reload.js';
34
+ /** The binder surface used (one method, one Redis GET). */
35
+ export type SessionClaimsReader = Pick<SessionTokenBinder, 'resolveSession'>;
36
+ /**
37
+ * What {@link refreshSessionFacts} needs: the guard's own decision authority, binder, subtree
38
+ * resolver and mandatory-2FA service (the enforcement guard's collaborators).
39
+ */
40
+ export interface SessionFactsRefreshDeps extends SessionFactsReloadDeps {
41
+ readonly tokenBinder: Pick<SessionTokenBinder, 'resolveSession' | 'refreshGrants' | 'rederiveScopeSubtree'>;
42
+ }
43
+ /**
44
+ * The classification the refresh runs the guard's request path for: the agent's own route
45
+ * (`@Classified({ typeKey: 'agent', action: 'chat' })`, the `identity:agent:chat` permission every
46
+ * agent call is decided on), so gate 5 is reached exactly as on a request to that route. The
47
+ * decision itself is not the refresh's answer: the caller's own freshness check decides `chat` on
48
+ * the refreshed principal (a deny there stops the task).
49
+ */
50
+ export declare const SESSION_FACTS_REFRESH_CLASSIFICATION: Readonly<{
51
+ typeKey: "agent";
52
+ action: "chat";
53
+ }>;
54
+ /**
55
+ * The permission version a principal returned by {@link principalForSession} was derived under:
56
+ * the version of the binding's usable cached facts, by the guard's `requestFactsVersion` rule
57
+ * (`derivedFactsVersion` with no reload). `undefined` (callers fail closed) for any other object,
58
+ * for a root principal, or when the binding holds no usable facts (absent or past their time
59
+ * bound: the guard would reload them from MariaDB).
60
+ */
61
+ export declare function principalFactsVersion(principal: unknown): number | undefined;
62
+ /** Same id: exact, or the same canonical UUID. Empty or non-string ⇒ never the same. */
63
+ export declare function sameId(a: unknown, b: unknown): boolean;
64
+ export declare function principalForSession(binder: SessionClaimsReader, sessionId: string, tenantId: string, userId: string, now?: () => number): Promise<Principal | null>;
65
+ /**
66
+ * Refresh a session's cached facts OFF-REQUEST (background-agent-tasks SPEC v9 §5 C) through the
67
+ * enforcement guard's own request path ({@link decideOnSessionFacts}, Shield #3): what a request on
68
+ * this session to the agent's route would do now — gate 5 serves fresh cached facts or reloads them
69
+ * (the one MariaDB read, `PermissionFactsPort.loadCoarseGrants`, when they are absent, past their
70
+ * `validUntilMs` or behind the tenant's version), the mandatory-2FA recompute and the subtree
71
+ * re-derive when the version moved past their stamps (the request path's reads, only then), and the
72
+ * write-back of the reloaded facts and live roles onto the session-claims entry and the session's
73
+ * current access-token entry (conditional, `XX`, TTL kept: never extends the session).
74
+ *
75
+ * Bounded by the session's refresh-idle window: the session-claims entry must still exist (idle
76
+ * expiry, logout, end-sessions and the disable sweep delete it). Returns the principal the guard
77
+ * hands a handler after that request, stamped for {@link principalFactsVersion} with the version
78
+ * it was derived under, or `null` (fail closed, Shield #1/#12) when: the entry is gone, malformed or
79
+ * another session's; its tenant is not `tenantId`; its user is not `userId`; it is a
80
+ * service-account binding or root (gate 5 loads no grants for root); it is restricted before or
81
+ * after the recompute; the recompute failed; the subtree re-derive failed or no version could be
82
+ * derived; or anything throws (Redis, the reload, `decide()`). A `deny` from `decide()` is NOT
83
+ * `null`: the refreshed principal is returned and the caller's own `chat` check stops the task.
84
+ */
85
+ export declare function refreshSessionFacts(deps: SessionFactsRefreshDeps, sessionId: string, tenantId: string, userId: string, now?: () => number): Promise<Principal | null>;
86
+ //# sourceMappingURL=session-principal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-principal.d.ts","sourceRoot":"","sources":["../../src/session/session-principal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAIlF,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,wCAAwC,CAAC;AAEhD,2DAA2D;AAC3D,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;IACrE,QAAQ,CAAC,WAAW,EAAE,IAAI,CACxB,kBAAkB,EAClB,gBAAgB,GAAG,eAAe,GAAG,sBAAsB,CAC5D,CAAC;CACH;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oCAAoC;;;EAG/C,CAAC;AAQH;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG5E;AAED,wFAAwF;AACxF,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAKtD;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,mBAAmB,EAC3B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,GAAE,MAAM,MAAiB,GAC3B,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAyB3B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,uBAAuB,EAC7B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,GAAE,MAAM,MAAiB,GAC3B,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CA2B3B"}
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SESSION_FACTS_REFRESH_CLASSIFICATION = void 0;
4
+ exports.principalFactsVersion = principalFactsVersion;
5
+ exports.sameId = sameId;
6
+ exports.principalForSession = principalForSession;
7
+ exports.refreshSessionFacts = refreshSessionFacts;
8
+ const engine_1 = require("@astram/engine");
9
+ const request_principal_js_1 = require("../request-auth/request-principal.js");
10
+ const session_restriction_js_1 = require("./session-restriction.js");
11
+ const facts_version_js_1 = require("../enforcement/facts-version.js");
12
+ const session_facts_reload_js_1 = require("../enforcement/session-facts-reload.js");
13
+ /**
14
+ * The classification the refresh runs the guard's request path for: the agent's own route
15
+ * (`@Classified({ typeKey: 'agent', action: 'chat' })`, the `identity:agent:chat` permission every
16
+ * agent call is decided on), so gate 5 is reached exactly as on a request to that route. The
17
+ * decision itself is not the refresh's answer: the caller's own freshness check decides `chat` on
18
+ * the refreshed principal (a deny there stops the task).
19
+ */
20
+ exports.SESSION_FACTS_REFRESH_CLASSIFICATION = Object.freeze({
21
+ typeKey: 'agent',
22
+ action: 'chat',
23
+ });
24
+ /**
25
+ * The version each rebuilt principal was derived under. Keyed by the (frozen) principal object, so
26
+ * nothing outside this module can set it; read only through {@link principalFactsVersion}.
27
+ */
28
+ const PRINCIPAL_FACTS_VERSION = new WeakMap();
29
+ /**
30
+ * The permission version a principal returned by {@link principalForSession} was derived under:
31
+ * the version of the binding's usable cached facts, by the guard's `requestFactsVersion` rule
32
+ * (`derivedFactsVersion` with no reload). `undefined` (callers fail closed) for any other object,
33
+ * for a root principal, or when the binding holds no usable facts (absent or past their time
34
+ * bound: the guard would reload them from MariaDB).
35
+ */
36
+ function principalFactsVersion(principal) {
37
+ if (principal === null || typeof principal !== 'object')
38
+ return undefined;
39
+ return PRINCIPAL_FACTS_VERSION.get(principal);
40
+ }
41
+ /** Same id: exact, or the same canonical UUID. Empty or non-string ⇒ never the same. */
42
+ function sameId(a, b) {
43
+ if (typeof a !== 'string' || typeof b !== 'string' || a === '' || b === '')
44
+ return false;
45
+ if (a === b)
46
+ return true;
47
+ const ca = (0, engine_1.canonicalUuid)(a);
48
+ return ca !== null && ca === (0, engine_1.canonicalUuid)(b);
49
+ }
50
+ async function principalForSession(binder, sessionId, tenantId, userId, now = Date.now) {
51
+ if (typeof sessionId !== 'string' || sessionId === '')
52
+ return null;
53
+ let claims;
54
+ try {
55
+ claims = await binder.resolveSession(sessionId);
56
+ }
57
+ catch {
58
+ return null; // resolveSession never throws; defence in depth (fail closed).
59
+ }
60
+ if (claims === null)
61
+ return null;
62
+ // A session binding only: a service-account principal has no session.
63
+ if (claims.kind === 'service_account')
64
+ return null;
65
+ if (!sameId(claims.tenantId, tenantId))
66
+ return null; // scope switch (tenant changed)
67
+ if (!sameId(claims.id, userId))
68
+ return null;
69
+ const nowMs = now();
70
+ if ((0, session_restriction_js_1.restrictionOf)(claims, nowMs) !== null)
71
+ return null;
72
+ const principal = (0, request_principal_js_1.principalFromClaims)(claims);
73
+ if (principal === null)
74
+ return null;
75
+ const version = (0, facts_version_js_1.derivedFactsVersion)(principal, undefined, (0, facts_version_js_1.usableCachedFacts)(claims.cachedFacts, nowMs), false);
76
+ if (version !== undefined)
77
+ PRINCIPAL_FACTS_VERSION.set(principal, version);
78
+ return principal;
79
+ }
80
+ /**
81
+ * Refresh a session's cached facts OFF-REQUEST (background-agent-tasks SPEC v9 §5 C) through the
82
+ * enforcement guard's own request path ({@link decideOnSessionFacts}, Shield #3): what a request on
83
+ * this session to the agent's route would do now — gate 5 serves fresh cached facts or reloads them
84
+ * (the one MariaDB read, `PermissionFactsPort.loadCoarseGrants`, when they are absent, past their
85
+ * `validUntilMs` or behind the tenant's version), the mandatory-2FA recompute and the subtree
86
+ * re-derive when the version moved past their stamps (the request path's reads, only then), and the
87
+ * write-back of the reloaded facts and live roles onto the session-claims entry and the session's
88
+ * current access-token entry (conditional, `XX`, TTL kept: never extends the session).
89
+ *
90
+ * Bounded by the session's refresh-idle window: the session-claims entry must still exist (idle
91
+ * expiry, logout, end-sessions and the disable sweep delete it). Returns the principal the guard
92
+ * hands a handler after that request, stamped for {@link principalFactsVersion} with the version
93
+ * it was derived under, or `null` (fail closed, Shield #1/#12) when: the entry is gone, malformed or
94
+ * another session's; its tenant is not `tenantId`; its user is not `userId`; it is a
95
+ * service-account binding or root (gate 5 loads no grants for root); it is restricted before or
96
+ * after the recompute; the recompute failed; the subtree re-derive failed or no version could be
97
+ * derived; or anything throws (Redis, the reload, `decide()`). A `deny` from `decide()` is NOT
98
+ * `null`: the refreshed principal is returned and the caller's own `chat` check stops the task.
99
+ */
100
+ async function refreshSessionFacts(deps, sessionId, tenantId, userId, now = Date.now) {
101
+ if (typeof sessionId !== 'string' || sessionId === '')
102
+ return null;
103
+ try {
104
+ const claims = await deps.tokenBinder.resolveSession(sessionId);
105
+ if (claims === null)
106
+ return null; // ended (idle window passed, logout, end-sessions)
107
+ if (claims.kind === 'service_account')
108
+ return null;
109
+ if (!sameId(claims.tenantId, tenantId))
110
+ return null;
111
+ if (!sameId(claims.id, userId))
112
+ return null;
113
+ if (claims.isRoot === true)
114
+ return null;
115
+ if ((0, session_restriction_js_1.restrictionOf)(claims, now()) !== null)
116
+ return null;
117
+ const principal = (0, request_principal_js_1.principalFromClaims)(claims);
118
+ if (principal === null || principal.isRoot === true)
119
+ return null;
120
+ const outcome = await (0, session_facts_reload_js_1.decideOnSessionFacts)(deps, {
121
+ principal,
122
+ claims,
123
+ accessToken: null,
124
+ classification: exports.SESSION_FACTS_REFRESH_CLASSIFICATION,
125
+ nowMs: now(),
126
+ });
127
+ if (outcome.mfaFailed)
128
+ return null;
129
+ if ((0, session_restriction_js_1.restrictionOf)(outcome.enforced, now()) !== null)
130
+ return null;
131
+ if (outcome.factsVersion === undefined)
132
+ return null;
133
+ PRINCIPAL_FACTS_VERSION.set(outcome.principal, outcome.factsVersion);
134
+ return outcome.principal;
135
+ }
136
+ catch {
137
+ return null;
138
+ }
139
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Framework authz migration — permission groups (docs/features/permission-groups/SPEC.md §4).
3
+ *
4
+ * Adds to `permission` the display-only group of the key's object type, declared in code by
5
+ * `@ObjectType({ group })` and written by the catalog reconcile: `perm_group_key`,
6
+ * `perm_group_label` and `perm_group_order` (the effective sort order). NULL = no group. Grants,
7
+ * wildcards, bundles and decide() never read these columns.
8
+ *
9
+ * No backfill: existing rows stay NULL until the first reconcile after upgrade writes them.
10
+ * `down` drops the columns with no refusal: the data is derived from code and rewritten by the
11
+ * reconcile after a re-`up`.
12
+ *
13
+ * Idempotent: `ADD COLUMN IF NOT EXISTS` / `DROP COLUMN IF EXISTS`. Literal column names; run by
14
+ * the DDL account.
15
+ */
16
+
17
+ const { frameworkSchemasForMigration } = require('@astram/core');
18
+
19
+ const COLUMNS = [
20
+ ['perm_group_key', 'VARCHAR(32) NULL DEFAULT NULL'],
21
+ ['perm_group_label', 'VARCHAR(40) NULL DEFAULT NULL'],
22
+ ['perm_group_order', 'INT NULL DEFAULT NULL'],
23
+ ];
24
+
25
+ async function up(ctx) {
26
+ const { query } = ctx;
27
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
28
+ for (const [name, type] of COLUMNS) {
29
+ await query(`ALTER TABLE \`${SCHEMA}\`.\`permission\` ADD COLUMN IF NOT EXISTS ${name} ${type}`);
30
+ }
31
+ }
32
+
33
+ async function down(ctx) {
34
+ const { query } = ctx;
35
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
36
+ for (const [name] of [...COLUMNS].reverse()) {
37
+ await query(`ALTER TABLE \`${SCHEMA}\`.\`permission\` DROP COLUMN IF EXISTS ${name}`);
38
+ }
39
+ }
40
+
41
+ module.exports = { up, down };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astram/guard",
3
- "version": "0.37.0",
3
+ "version": "0.40.0",
4
4
  "license": "MIT",
5
5
  "description": "Astram framework — the enforcement guard + real-world adapters (the 'hands'). One global deny-by-default gate every request passes through (ADR-0002), classification decorators, boot-pool assertion (ADR-0018), the forRoot() registration seam, and the DB/Redis/crypto adapters that connect the sealed core to a real backend. Depends on @astram/core (ADR-0003, ADR-0023).",
6
6
  "type": "commonjs",
@@ -36,8 +36,8 @@
36
36
  "argon2": "^0.41.1",
37
37
  "ioredis": "^5.4.1",
38
38
  "mariadb": "^3.5.4",
39
- "@astram/engine": "0.22.1",
40
- "@astram/core": "1.21.0"
39
+ "@astram/core": "1.22.0",
40
+ "@astram/engine": "0.23.1"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@nestjs/common": "^11",
@@ -45,7 +45,7 @@
45
45
  "@nestjs/platform-express": "^11",
46
46
  "reflect-metadata": "^0.2",
47
47
  "rxjs": "^7",
48
- "@astram/messaging": "^0.1.28"
48
+ "@astram/messaging": "^0.1.31"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
51
  "@astram/messaging": {
@@ -68,7 +68,7 @@
68
68
  "typescript": "^5.7.0",
69
69
  "unplugin-swc": "^1.5.1",
70
70
  "vitest": "^2.1.8",
71
- "@astram/messaging": "0.1.28"
71
+ "@astram/messaging": "0.1.31"
72
72
  },
73
73
  "repository": {
74
74
  "type": "git",