@astram/guard 0.1.1 → 0.3.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 (183) hide show
  1. package/dist/auth/account.controller.d.ts +245 -0
  2. package/dist/auth/account.controller.d.ts.map +1 -0
  3. package/dist/auth/account.controller.js +673 -0
  4. package/dist/auth/account.controller.js.map +1 -0
  5. package/dist/auth/auth.controller.d.ts +316 -0
  6. package/dist/auth/auth.controller.d.ts.map +1 -0
  7. package/dist/auth/auth.controller.js +1091 -0
  8. package/dist/auth/auth.controller.js.map +1 -0
  9. package/dist/auth/auth.module.d.ts +202 -0
  10. package/dist/auth/auth.module.d.ts.map +1 -0
  11. package/dist/auth/auth.module.js +610 -0
  12. package/dist/auth/auth.module.js.map +1 -0
  13. package/dist/auth/connections.d.ts +61 -0
  14. package/dist/auth/connections.d.ts.map +1 -0
  15. package/dist/auth/connections.js +116 -0
  16. package/dist/auth/connections.js.map +1 -0
  17. package/dist/auth/dto.d.ts +154 -0
  18. package/dist/auth/dto.d.ts.map +1 -0
  19. package/dist/auth/dto.js +29 -0
  20. package/dist/auth/dto.js.map +1 -0
  21. package/dist/auth/pending-mfa-store.d.ts +72 -0
  22. package/dist/auth/pending-mfa-store.d.ts.map +1 -0
  23. package/dist/auth/pending-mfa-store.js +106 -0
  24. package/dist/auth/pending-mfa-store.js.map +1 -0
  25. package/dist/auth/persistence.module.d.ts +42 -0
  26. package/dist/auth/persistence.module.d.ts.map +1 -0
  27. package/dist/auth/persistence.module.js +94 -0
  28. package/dist/auth/persistence.module.js.map +1 -0
  29. package/dist/auth/ports/audit-sink.d.ts +47 -0
  30. package/dist/auth/ports/audit-sink.d.ts.map +1 -0
  31. package/dist/auth/ports/audit-sink.js +20 -0
  32. package/dist/auth/ports/audit-sink.js.map +1 -0
  33. package/dist/auth/ports/credential-writer.d.ts +23 -0
  34. package/dist/auth/ports/credential-writer.d.ts.map +1 -0
  35. package/dist/auth/ports/credential-writer.js +2 -0
  36. package/dist/auth/ports/credential-writer.js.map +1 -0
  37. package/dist/auth/ports/email-sender.d.ts +14 -0
  38. package/dist/auth/ports/email-sender.d.ts.map +1 -0
  39. package/dist/auth/ports/email-sender.js +2 -0
  40. package/dist/auth/ports/email-sender.js.map +1 -0
  41. package/dist/auth/ports/mfa-device-store.d.ts +45 -0
  42. package/dist/auth/ports/mfa-device-store.d.ts.map +1 -0
  43. package/dist/auth/ports/mfa-device-store.js +13 -0
  44. package/dist/auth/ports/mfa-device-store.js.map +1 -0
  45. package/dist/auth/ports/profile-writer.d.ts +12 -0
  46. package/dist/auth/ports/profile-writer.d.ts.map +1 -0
  47. package/dist/auth/ports/profile-writer.js +2 -0
  48. package/dist/auth/ports/profile-writer.js.map +1 -0
  49. package/dist/auth/ports/recovery-code-store.d.ts +10 -0
  50. package/dist/auth/ports/recovery-code-store.d.ts.map +1 -0
  51. package/dist/auth/ports/recovery-code-store.js +2 -0
  52. package/dist/auth/ports/recovery-code-store.js.map +1 -0
  53. package/dist/auth/ports/reset-token-store.d.ts +12 -0
  54. package/dist/auth/ports/reset-token-store.d.ts.map +1 -0
  55. package/dist/auth/ports/reset-token-store.js +2 -0
  56. package/dist/auth/ports/reset-token-store.js.map +1 -0
  57. package/dist/auth/ports/session-facts-projector.d.ts +44 -0
  58. package/dist/auth/ports/session-facts-projector.d.ts.map +1 -0
  59. package/dist/auth/ports/session-facts-projector.js +30 -0
  60. package/dist/auth/ports/session-facts-projector.js.map +1 -0
  61. package/dist/auth/ports/session-sweeper.d.ts +12 -0
  62. package/dist/auth/ports/session-sweeper.d.ts.map +1 -0
  63. package/dist/auth/ports/session-sweeper.js +2 -0
  64. package/dist/auth/ports/session-sweeper.js.map +1 -0
  65. package/dist/auth/profile-resolver.d.ts +73 -0
  66. package/dist/auth/profile-resolver.d.ts.map +1 -0
  67. package/dist/auth/profile-resolver.js +28 -0
  68. package/dist/auth/profile-resolver.js.map +1 -0
  69. package/dist/auth/rate-limit/attempt-limiter.d.ts +91 -0
  70. package/dist/auth/rate-limit/attempt-limiter.d.ts.map +1 -0
  71. package/dist/auth/rate-limit/attempt-limiter.js +133 -0
  72. package/dist/auth/rate-limit/attempt-limiter.js.map +1 -0
  73. package/dist/auth/tokens.d.ts +236 -0
  74. package/dist/auth/tokens.d.ts.map +1 -0
  75. package/dist/auth/tokens.js +254 -0
  76. package/dist/auth/tokens.js.map +1 -0
  77. package/dist/auth/totp-enrollment.d.ts +42 -0
  78. package/dist/auth/totp-enrollment.d.ts.map +1 -0
  79. package/dist/auth/totp-enrollment.js +96 -0
  80. package/dist/auth/totp-enrollment.js.map +1 -0
  81. package/dist/authentication/argon2id-password-hasher.js.map +1 -0
  82. package/dist/authentication/mariadb-credential-resolver.d.ts +110 -0
  83. package/dist/authentication/mariadb-credential-resolver.d.ts.map +1 -0
  84. package/dist/authentication/mariadb-credential-resolver.js +170 -0
  85. package/dist/authentication/mariadb-credential-resolver.js.map +1 -0
  86. package/dist/authz/cross-tenant-grant-writer.d.ts +259 -0
  87. package/dist/authz/cross-tenant-grant-writer.d.ts.map +1 -0
  88. package/dist/authz/cross-tenant-grant-writer.js +397 -0
  89. package/dist/authz/cross-tenant-grant-writer.js.map +1 -0
  90. package/dist/authz/manifest-operation-authority-adapter.d.ts +65 -0
  91. package/dist/authz/manifest-operation-authority-adapter.d.ts.map +1 -0
  92. package/dist/authz/manifest-operation-authority-adapter.js +108 -0
  93. package/dist/authz/manifest-operation-authority-adapter.js.map +1 -0
  94. package/dist/authz/mariadb-cross-tenant-grant-adapter.d.ts +90 -0
  95. package/dist/authz/mariadb-cross-tenant-grant-adapter.d.ts.map +1 -0
  96. package/dist/authz/mariadb-cross-tenant-grant-adapter.js +211 -0
  97. package/dist/authz/mariadb-cross-tenant-grant-adapter.js.map +1 -0
  98. package/dist/authz/mariadb-record-rule-adapter.d.ts +60 -0
  99. package/dist/authz/mariadb-record-rule-adapter.d.ts.map +1 -0
  100. package/dist/authz/mariadb-record-rule-adapter.js +154 -0
  101. package/dist/authz/mariadb-record-rule-adapter.js.map +1 -0
  102. package/dist/authz/mariadb-record-share-adapter.d.ts +75 -0
  103. package/dist/authz/mariadb-record-share-adapter.d.ts.map +1 -0
  104. package/dist/authz/mariadb-record-share-adapter.js +106 -0
  105. package/dist/authz/mariadb-record-share-adapter.js.map +1 -0
  106. package/dist/authz/record-share-cascade.d.ts +52 -0
  107. package/dist/authz/record-share-cascade.d.ts.map +1 -0
  108. package/dist/authz/record-share-cascade.js +49 -0
  109. package/dist/authz/record-share-cascade.js.map +1 -0
  110. package/dist/authz/record-share-writer.d.ts +175 -0
  111. package/dist/authz/record-share-writer.d.ts.map +1 -0
  112. package/dist/authz/record-share-writer.js +225 -0
  113. package/dist/authz/record-share-writer.js.map +1 -0
  114. package/dist/authz/wire-record-authorization.d.ts +66 -0
  115. package/dist/authz/wire-record-authorization.d.ts.map +1 -0
  116. package/dist/authz/wire-record-authorization.js +34 -0
  117. package/dist/authz/wire-record-authorization.js.map +1 -0
  118. package/dist/boot/boot-sequence.js.map +1 -0
  119. package/dist/boot/boot.module.js.map +1 -0
  120. package/dist/completeness/catalog-reconciler.d.ts +21 -0
  121. package/dist/completeness/catalog-reconciler.d.ts.map +1 -0
  122. package/dist/completeness/catalog-reconciler.js +74 -0
  123. package/dist/completeness/catalog-reconciler.js.map +1 -0
  124. package/dist/completeness/operation-inventory-scanner.d.ts +17 -0
  125. package/dist/completeness/operation-inventory-scanner.d.ts.map +1 -0
  126. package/dist/completeness/operation-inventory-scanner.js +79 -0
  127. package/dist/completeness/operation-inventory-scanner.js.map +1 -0
  128. package/dist/completeness/ports/catalog-store.d.ts +33 -0
  129. package/dist/completeness/ports/catalog-store.d.ts.map +1 -0
  130. package/dist/completeness/ports/catalog-store.js +2 -0
  131. package/dist/completeness/ports/catalog-store.js.map +1 -0
  132. package/dist/config/app-config.d.ts +134 -1
  133. package/dist/config/app-config.d.ts.map +1 -1
  134. package/dist/config/app-config.js +144 -2
  135. package/dist/config/app-config.js.map +1 -0
  136. package/dist/config/config.module.js.map +1 -0
  137. package/dist/enforcement/classification.decorator.d.ts +33 -14
  138. package/dist/enforcement/classification.decorator.d.ts.map +1 -1
  139. package/dist/enforcement/classification.decorator.js +34 -14
  140. package/dist/enforcement/classification.decorator.js.map +1 -0
  141. package/dist/enforcement/core-seam.js.map +1 -0
  142. package/dist/enforcement/enforcement.module.js.map +1 -0
  143. package/dist/enforcement/global-enforcement.guard.d.ts +29 -19
  144. package/dist/enforcement/global-enforcement.guard.d.ts.map +1 -1
  145. package/dist/enforcement/global-enforcement.guard.js +108 -25
  146. package/dist/enforcement/global-enforcement.guard.js.map +1 -0
  147. package/dist/enforcement/reenroll-allowlist.d.ts +49 -0
  148. package/dist/enforcement/reenroll-allowlist.d.ts.map +1 -0
  149. package/dist/enforcement/reenroll-allowlist.js +77 -0
  150. package/dist/enforcement/reenroll-allowlist.js.map +1 -0
  151. package/dist/index.d.ts +43 -3
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +198 -1
  154. package/dist/index.js.map +1 -0
  155. package/dist/module/shield-tokens.d.ts +15 -0
  156. package/dist/module/shield-tokens.d.ts.map +1 -0
  157. package/dist/module/shield-tokens.js +17 -0
  158. package/dist/module/shield-tokens.js.map +1 -0
  159. package/dist/module/shield.module.d.ts +203 -8
  160. package/dist/module/shield.module.d.ts.map +1 -1
  161. package/dist/module/shield.module.js +232 -14
  162. package/dist/module/shield.module.js.map +1 -0
  163. package/dist/request-auth/request-principal.d.ts +42 -0
  164. package/dist/request-auth/request-principal.d.ts.map +1 -0
  165. package/dist/request-auth/request-principal.js +87 -0
  166. package/dist/request-auth/request-principal.js.map +1 -0
  167. package/dist/request-auth/session-facts-als.d.ts +65 -0
  168. package/dist/request-auth/session-facts-als.d.ts.map +1 -0
  169. package/dist/request-auth/session-facts-als.js +57 -0
  170. package/dist/request-auth/session-facts-als.js.map +1 -0
  171. package/dist/request-auth/session-token-binder.d.ts +130 -0
  172. package/dist/request-auth/session-token-binder.d.ts.map +1 -0
  173. package/dist/request-auth/session-token-binder.js +277 -0
  174. package/dist/request-auth/session-token-binder.js.map +1 -0
  175. package/dist/request-auth/tokens.d.ts +14 -0
  176. package/dist/request-auth/tokens.d.ts.map +1 -0
  177. package/dist/request-auth/tokens.js +16 -0
  178. package/dist/request-auth/tokens.js.map +1 -0
  179. package/dist/session/crypto-adapters.js.map +1 -0
  180. package/dist/session/index.js.map +1 -0
  181. package/dist/session/mariadb-session-record-store.js.map +1 -0
  182. package/dist/session/redis-hot-session-store.js.map +1 -0
  183. package/package.json +2 -2
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ /**
3
+ * `MariaDbCredentialResolver` — the framework-DEFAULT concrete
4
+ * {@link CredentialResolver} (core port) backed by the single
5
+ * `shield_identity.identity_credential` table. Resolves an `identityHint`
6
+ * (username / email) → a {@link ResolvedCredential} the Authentication engine
7
+ * verifies, or `null` for an unknown hint.
8
+ *
9
+ * ⛔ PASSWORD-ONLY BY DESIGN. This default resolver reads ONLY the columns the
10
+ * framework's shipped seed (`infra/mariadb/init/30-identity-credential.sql`)
11
+ * actually creates: `ic_password_hash, ic_principal_id, ic_tenant_id, ic_roles`.
12
+ * It therefore ALWAYS returns `requiredFactors: []` — it does NOT provide an
13
+ * MFA/second-factor challenge. There is no TOTP column here: the multi-device MFA
14
+ * model moved authenticator secrets out of `identity_credential` into a separate
15
+ * `mfa_device` table, which the framework ships only as an UNIMPLEMENTED port.
16
+ *
17
+ * MFA / required-factors are a CONSUMER concern, delivered by plugging a custom
18
+ * `credentialResolver` (+ a concrete `MfaDeviceStore`) via `ShieldModule.forRoot`
19
+ * — NOT by this default. See astram3's `IdentityCredentialResolver`, which reads
20
+ * this same table AND folds in the consumer's confirmed authenticators via
21
+ * `listConfirmedSecrets(mfa_device)` to populate `requiredFactors`. That seam is
22
+ * the supported way to add MFA-at-login on top of this password-only default.
23
+ *
24
+ * ─────────────────────────────────────────────────────────────────────────────
25
+ * THE TABLE CONTRACT (infra seed `infra/mariadb/init/30-identity-credential.sql`,
26
+ * in `shield_identity`; the runtime `shield_core` account already has DML there —
27
+ * no new grant). Columns per spec §3 (prefix `ic_` to match the repo's
28
+ * session-table convention):
29
+ *
30
+ * identity_credential
31
+ * ┌────────────────────────┬──────────────┬────────────────────────────────────┐
32
+ * │ column │ type │ notes │
33
+ * ├────────────────────────┼──────────────┼────────────────────────────────────┤
34
+ * │ ic_identity_hint │ VARCHAR(255) │ UNIQUE — the login key (user/email)│
35
+ * │ ic_password_hash │ VARCHAR(255) │ Argon2id encoded hash (verify in) │
36
+ * │ ic_principal_id │ VARCHAR(255) │ → ResolvedCredential.claims.id │
37
+ * │ ic_tenant_id │ VARCHAR(255) │ → claims.tenantId │
38
+ * │ ic_roles │ JSON / TEXT │ role-id array → claims.roleIds │
39
+ * │ ic_created_at_ms │ BIGINT │ UTC epoch ms (platform sets UTC) │
40
+ * │ ic_updated_at_ms │ BIGINT │ UTC epoch ms │
41
+ * └────────────────────────┴──────────────┴────────────────────────────────────┘
42
+ * PRIMARY KEY / UNIQUE on ic_identity_hint (single-row resolve by hint).
43
+ * (No `ic_totp_secret` column — MFA secrets live in the consumer's `mfa_device`
44
+ * table, resolved by a consumer-plugged resolver, not by this default.)
45
+ *
46
+ * The resolver's SELECT must:
47
+ * 1. `SELECT ic_password_hash, ic_principal_id, ic_tenant_id, ic_roles
48
+ * FROM shield_identity.identity_credential
49
+ * WHERE ic_identity_hint = ? LIMIT 1` (parameterized — NEVER string-built).
50
+ * 2. Return `null` when NO row matches — the ONLY "not found" signal
51
+ * (anti-enumeration; MUST NOT throw for an unknown hint; the engine burns a
52
+ * decoy verify on `null` so timing is uniform).
53
+ * 3. Map a found row → `ResolvedCredential`:
54
+ * passwordHash = ic_password_hash
55
+ * claims = { id: ic_principal_id, tenantId: ic_tenant_id,
56
+ * roleIds: <parsed ic_roles> } // canonical Internal claims
57
+ * requiredFactors = [] // ALWAYS empty — password-only default (see above)
58
+ * 4. NEVER log the hash or the raw row.
59
+ * 5. A store outage (connection/query error) MAY throw — the engine treats a
60
+ * resolver throw as fail-closed `authentication_unavailable` (never a leak).
61
+ * It MUST NOT convert a throw into a `null` (that would make an outage look
62
+ * like "unknown user").
63
+ *
64
+ * (`claims.kind` is optional — the Internal adapter defaults an absent kind; add
65
+ * an `ic_kind` column later if a deployment needs non-`user` principals. Do NOT
66
+ * put any root flag in the row — root is the broker's server-side
67
+ * allowlist, never a claim, per core/identity.)
68
+ * ─────────────────────────────────────────────────────────────────────────────
69
+ *
70
+ * ADR-0003: the concrete DB lives in guard (Core stays zero-dep). ADR-0013/0014:
71
+ * reads `shield_identity` via the hot-path `shield_core` account.
72
+ */
73
+ Object.defineProperty(exports, "__esModule", { value: true });
74
+ exports.MariaDbCredentialResolver = exports.SHIELD_CREDENTIAL_RESOLVER = void 0;
75
+ /** DI token for the resolver — re-exported from the shared auth tokens module. */
76
+ var tokens_js_1 = require("../auth/tokens.js");
77
+ Object.defineProperty(exports, "SHIELD_CREDENTIAL_RESOLVER", { enumerable: true, get: function () { return tokens_js_1.SHIELD_CREDENTIAL_RESOLVER; } });
78
+ /**
79
+ * Normalize the stored `ic_roles` into a role-id string array. Accepts BOTH:
80
+ * - a native `string[]` (the mariadb `JSON`-column driver already parsed it);
81
+ * - a JSON string (defensive — a `TEXT` column / `autoJsonMap` disabled), which
82
+ * is `JSON.parse`d here.
83
+ *
84
+ * A malformed roles value is a DATA-INTEGRITY error, not an unknown user — so this
85
+ * THROWS (the engine treats a resolver throw as fail-closed
86
+ * `authentication_unavailable`) rather than silently granting an empty role set (a
87
+ * silent privilege change) OR crashing later. Anything that is not, after
88
+ * normalization, an array of strings is rejected the same way.
89
+ */
90
+ function parseRoleIds(raw, hint) {
91
+ let value = raw;
92
+ if (typeof value === 'string') {
93
+ try {
94
+ value = JSON.parse(value);
95
+ }
96
+ catch {
97
+ // Never include the raw blob in the message (defensive; it isn't a secret,
98
+ // but keep the no-detail-leak discipline uniform).
99
+ throw new Error(`MariaDbCredentialResolver: malformed ic_roles JSON for identity "${hint}" ` +
100
+ `(data-integrity error — failing closed rather than granting empty roles).`);
101
+ }
102
+ }
103
+ if (!Array.isArray(value) || !value.every((r) => typeof r === 'string')) {
104
+ throw new Error(`MariaDbCredentialResolver: ic_roles for identity "${hint}" is not an array ` +
105
+ `of strings (data-integrity error — failing closed).`);
106
+ }
107
+ return value;
108
+ }
109
+ /**
110
+ * The concrete MariaDB-backed {@link CredentialResolver}. Constructed with the
111
+ * live `shield_core` {@link Pool} (via {@link SHIELD_CREDENTIAL_RESOLVER}'s
112
+ * factory, which injects {@link SHIELD_DB_POOL}). Stateless per call apart from
113
+ * the injected pool.
114
+ *
115
+ * ⛔ SKELETON: `resolve()` throws until Team A implements the SELECT above.
116
+ */
117
+ class MariaDbCredentialResolver {
118
+ pool;
119
+ constructor(pool) {
120
+ this.pool = pool;
121
+ }
122
+ /**
123
+ * Resolve `identityHint` → {@link ResolvedCredential}, or `null` when no such
124
+ * principal exists.
125
+ *
126
+ * - Parameterized SELECT (`WHERE ic_identity_hint = ? LIMIT 1`) — never
127
+ * string-built, so the hint can never inject SQL.
128
+ * - **No row ⇒ `null`** — the ONLY "not found" signal (anti-enumeration; the
129
+ * engine burns a decoy password verify on `null` so an unknown user is
130
+ * indistinguishable from a wrong password by content or timing). We do NOT
131
+ * throw for an unknown hint.
132
+ * - A **query/connection ERROR propagates** (rejects) — an outage is NOT an
133
+ * unknown user; the engine treats a resolver throw as fail-closed
134
+ * `authentication_unavailable`. We never convert an error into `null` (that
135
+ * would mask an outage AND make it look like "no such user").
136
+ * - The password hash is NEVER logged; the raw row is never logged. On success
137
+ * it is returned to the engine as a verify input only.
138
+ * - **Password-only:** `requiredFactors` is ALWAYS `[]`. This default provides
139
+ * no second-factor challenge; MFA-at-login is delivered by a consumer-plugged
140
+ * `credentialResolver` (+ `MfaDeviceStore`) — see the class doc header and
141
+ * astram3's `IdentityCredentialResolver`.
142
+ */
143
+ async resolve(identityHint) {
144
+ // A failed query rejects out of here unchanged (fail-closed): we deliberately
145
+ // do NOT wrap this in a try/catch that returns null — only a genuine "no row"
146
+ // maps to null (below), never a store outage.
147
+ const rows = (await this.pool.query(`SELECT ic_password_hash, ic_principal_id, ic_tenant_id, ic_roles
148
+ FROM shield_identity.identity_credential
149
+ WHERE ic_identity_hint = ?
150
+ LIMIT 1`, [identityHint]));
151
+ const row = rows[0];
152
+ // Unknown hint → null (anti-enumeration). MUST NOT throw here.
153
+ if (!row) {
154
+ return null;
155
+ }
156
+ // Password-only default: no second factor is derived here. MFA is a consumer
157
+ // concern (custom resolver + MfaDeviceStore), so requiredFactors is always [].
158
+ const requiredFactors = [];
159
+ return {
160
+ passwordHash: row.ic_password_hash,
161
+ claims: {
162
+ id: row.ic_principal_id,
163
+ tenantId: row.ic_tenant_id,
164
+ roleIds: parseRoleIds(row.ic_roles, identityHint),
165
+ },
166
+ requiredFactors,
167
+ };
168
+ }
169
+ }
170
+ exports.MariaDbCredentialResolver = MariaDbCredentialResolver;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mariadb-credential-resolver.js","sourceRoot":"","sources":["../../src/authentication/mariadb-credential-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;;;AASH,kFAAkF;AAClF,+CAA+D;AAAtD,uHAAA,0BAA0B,OAAA;AAkBnC;;;;;;;;;;;GAWG;AACH,SAAS,YAAY,CAAC,GAAY,EAAE,IAAY;IAC9C,IAAI,KAAK,GAAY,GAAG,CAAC;IACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,2EAA2E;YAC3E,mDAAmD;YACnD,MAAM,IAAI,KAAK,CACb,oEAAoE,IAAI,IAAI;gBAC1E,2E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Y-GRANT write path (ADR-0009, the KEY
3
+ * NEW INVARIANT of Phase 4). Cross-tenant grant LIFECYCLE — offer / accept / revoke — is
4
+ * framework-governed here so a grant can NEVER be minted by the party that BENEFITS from it.
5
+ *
6
+ * ⛔ THIS IS NOT A CORE PORT. Grant EVALUATION is a core port ({@link CrossTenantGrantPort});
7
+ * grant LIFECYCLE is a guard WRITE path (it needs the `mariadb` driver + the consumer's
8
+ * identity schema to answer "is X an admin of tenant T", neither of which core may touch —
9
+ * ADR-0003). It lives in guard and is exposed as a provider the consumer app's grant surface
10
+ * calls (the invitation-email / inbox UX is DEFERRED — ADR-0009's Admin-Console follow-up).
11
+ *
12
+ * ── THE CONSENT MODEL (ADR-0009). A cross-tenant grant is TENANT B (the OWNING tenant, whose
13
+ * data is reached into) consenting to let TENANT A's principal in. The handshake:
14
+ * offer → an owner/ADMIN in the OWNING tenant (or root) declares the grant
15
+ * (object type, scope, action ceiling, expiry) → row created in 'offered' status.
16
+ * accept → the GRANTEE tenant must ACCEPT → row moves to 'accepted' → the grant ACTIVATES
17
+ * (only now does {@link CrossTenantGrantPort.findActiveGrant} return it).
18
+ * revoke → EITHER side (owning tenant admin OR grantee tenant member) may revoke → row
19
+ * moves to 'revoked' + `ctg_revoked_at` stamped → immediately inactive.
20
+ * ⛔ THE #1 SECURITY CRUX: the grantee's OWN tenant can NEVER unilaterally mint a grant. A
21
+ * grant is consent FROM the owning tenant; only an owning-tenant admin may OFFER.
22
+ *
23
+ * ── THE BOUNDS (enforced fail-closed, IN ORDER, BEFORE any write):
24
+ * • offer:
25
+ * 1. The offerer MUST hold `'share'` authority in the OWNING tenant (`ctg_owning_tenant_uuid`)
26
+ * — verified SERVER-SIDE via the injected {@link GrantAuthorizeFn} (the app's `decide()`);
27
+ * rejected otherwise. ⛔ `offeredBy` + `owningTenantId` come from the AUTHENTICATED
28
+ * principal context — the caller supplies them from the request principal, NEVER from
29
+ * a user-controlled body field for the authority decision.
30
+ * 2. `allowedActions` MUST be non-empty AND MUST NOT contain a wildcard (`'*'`) — the
31
+ * ceiling is a hard, explicit, enumerated set (ADR-0009: "non-wildcard, non-empty").
32
+ * 3. `expiresAtMs` MUST be a finite FUTURE timestamp — no perpetual / absent / past
33
+ * expiry (ADR-0009: "expiry mandatory").
34
+ * 4. scope='record' REQUIRES a non-empty `recordId`; scope='object_type' FORBIDS one.
35
+ * On pass ⇒ INSERT a fresh row in 'offered' status.
36
+ * • accept:
37
+ * Only a principal who holds `'accept'` authority in the GRANTEE tenant (`ctg_grantee_tenant_uuid`)
38
+ * may accept — verified via {@link GrantAuthorizeFn} (the app's `decide()`, which implies
39
+ * grantee-tenant membership); and only a grant
40
+ * currently in 'offered' status (not already accepted/revoked). On pass ⇒ UPDATE to
41
+ * 'accepted' + stamp `ctg_accepted_at`. Re-accepting an already-'accepted' grant is a
42
+ * benign no-op (idempotent). Accepting a 'revoked' grant is REJECTED (a revoked grant is
43
+ * dead — it must be re-offered).
44
+ * • revoke:
45
+ * EITHER an admin of the OWNING tenant OR a member of the GRANTEE tenant may revoke
46
+ * (ADR-0009: "either side may revoke immediately"). A stranger (neither) is REJECTED. On
47
+ * pass ⇒ UPDATE to 'revoked' + stamp `ctg_revoked_at`. Re-revoking an already-'revoked'
48
+ * grant is a benign no-op (idempotent).
49
+ *
50
+ * ── AUDIT ON BOTH TENANTS (ADR-0009: "audited on BOTH tenants as cross-tenant"). Every
51
+ * offer/accept/revoke emits ONE {@link GrantAuditEvent} through the injected
52
+ * {@link GrantAuditSink} carrying BOTH `owningTenantId` and `granteeTenantId` in STRUCTURED
53
+ * fields — so the consumer's sink can record it under each tenant's audit trail. NO raw uuid
54
+ * appears in any human-readable MESSAGE (ids ride in structured attributes only). Best-effort
55
+ * — a sink throw never fails the lifecycle operation.
56
+ *
57
+ * ── FETCH-THEN-GATE (mirrors {@link RecordShareWriter}). The authority decisions (is-admin /
58
+ * is-member) are resolved SERVER-SIDE via the injected resolver — NEVER trusted from caller
59
+ * input. accept/revoke FETCH the grant's owning+grantee tenants from the row (not from the
60
+ * caller) before deciding who may act.
61
+ */
62
+ import type { GrantQueryable } from './mariadb-cross-tenant-grant-adapter.js';
63
+ /** The DI token the writer is bound under. */
64
+ export declare const SHIELD_CROSS_TENANT_GRANT_WRITER: unique symbol;
65
+ /** Who a grant is granted to (the grantee principal kind). Mirrors `ctg_grantee_kind`. */
66
+ export type GrantGranteeKind = 'user' | 'role';
67
+ /** The two scopes a grant may span (mirrors core's `CrossTenantGrantScope`). */
68
+ export type GrantScope = 'object_type' | 'record';
69
+ /**
70
+ * The ONE authority question the writer asks: "may this principal perform `action` within
71
+ * `tenantId`?" — answered by the CONSUMER over its OWN identity + authorization model, so guard
72
+ * never imports `@astram/engine` or the app (ADR-0003 layering).
73
+ *
74
+ * This REPLACES the former `GrantAuthorityResolver` port (the bespoke `isTenantAdmin` /
75
+ * `isTenantMember` pair). Cross-tenant sharing is NOT a special authority question — it is the
76
+ * SAME "may this person do this?" question every other action asks. So the app resolves it the
77
+ * SAME way it resolves everything else: through `decide()`. The app's closure builds the
78
+ * principal (id → roleIds for `tenantId`, via its in-effect membership→posting read) and calls
79
+ * its own `decide(principal, {key: action}, {level:'object_type', typeKey:'cross_tenant_grant',
80
+ * tenantId}, ...)`. Because a principal's permissions are resolved THROUGH their membership,
81
+ * one `decide()` answers BOTH "are you in this tenant" AND "do you hold the permission" — so no
82
+ * separate membership check is needed.
83
+ *
84
+ * • offer → `authorize(offeredBy, owningTenantId, 'share')` (act in your own tenant A)
85
+ * • accept → `authorize(acceptedBy, granteeTenantId, 'accept')` (act in your own tenant B)
86
+ * • revoke → `authorize(revokedBy, owningTenantId, 'revoke')` OR (…granteeTenantId, 'revoke')
87
+ *
88
+ * Returns a genuine boolean; the writer gates on strict `=== true`. A store/authority outage
89
+ * SHOULD throw (the writer surfaces it as {@link GrantStoreUnavailableError}, a retryable 503) —
90
+ * never a silent `false` that would mask an outage as "not authorized".
91
+ */
92
+ export type GrantAuthorizeFn = (principalId: string, tenantId: string, action: 'share' | 'accept' | 'revoke') => Promise<boolean>;
93
+ /** A grant lifecycle audit event (structured — ids in fields, NEVER in a rendered message). */
94
+ export interface GrantAuditEvent {
95
+ /** Always `'cross_tenant_grant'`. */
96
+ readonly type: 'cross_tenant_grant';
97
+ /** The specific lifecycle event. */
98
+ readonly action: 'grant.offered' | 'grant.accepted' | 'grant.revoked';
99
+ /** Epoch ms the event occurred. */
100
+ readonly occurredAtMs: number;
101
+ /** The principal who performed the action (offerer / accepter / revoker). */
102
+ readonly actorId: string;
103
+ /**
104
+ * The grant's OWNING tenant (whose data is reached into / who consents). Present so the
105
+ * consumer's sink records the event under this tenant's audit trail too (audit-on-both).
106
+ */
107
+ readonly owningTenantId: string;
108
+ /** The grant's GRANTEE tenant (reaching in). Present so the sink records it under BOTH. */
109
+ readonly granteeTenantId: string;
110
+ /** Structured, UUID-free-message detail (the ids live HERE, not in a message string). */
111
+ readonly attributes: {
112
+ readonly grantUuid: string;
113
+ readonly typeKey: string;
114
+ readonly scope: GrantScope;
115
+ readonly recordId?: string;
116
+ readonly granteeKind: GrantGranteeKind;
117
+ readonly granteeUuid: string;
118
+ readonly allowedActions: readonly string[];
119
+ };
120
+ }
121
+ /** The audit seam the writer emits through. Best-effort — a throw never fails the write. */
122
+ export interface GrantAuditSink {
123
+ record(event: GrantAuditEvent): Promise<void>;
124
+ }
125
+ /** Input to {@link CrossTenantGrantWriter.offer}. */
126
+ export interface OfferGrantInput {
127
+ /**
128
+ * ⛔ The OWNING tenant — whose data is reached into / who consents. Supplied from the
129
+ * AUTHENTICATED principal's context, NEVER a user-controlled body field for the authority
130
+ * decision. The offerer MUST be an admin of THIS tenant.
131
+ */
132
+ readonly owningTenantId: string;
133
+ /** The GRANTEE tenant — the tenant reaching in. */
134
+ readonly granteeTenantId: string;
135
+ /** Who in the grantee tenant the grant is for (a specific user or role). */
136
+ readonly granteeKind: GrantGranteeKind;
137
+ /** The grantee user/role uuid (in the grantee tenant). */
138
+ readonly granteeUuid: string;
139
+ /** The object type the grant covers. */
140
+ readonly typeKey: string;
141
+ /** Whole-object-type, or a single record. */
142
+ readonly scope: GrantScope;
143
+ /** REQUIRED iff `scope='record'`; FORBIDDEN for `scope='object_type'`. */
144
+ readonly recordId?: string;
145
+ /** The hard action ceiling — non-empty, non-wildcard, enumerated action keys. */
146
+ readonly allowedActions: readonly string[];
147
+ /** Mandatory FUTURE expiry (UTC epoch ms). No perpetual/absent/past grants. */
148
+ readonly expiresAtMs: number;
149
+ /**
150
+ * ⛔ The AUTHENTICATED principal id who is offering — supplied from the request principal,
151
+ * never a user-controlled body field. Proven to be an OWNING-tenant admin before the write.
152
+ */
153
+ readonly offeredBy: string;
154
+ }
155
+ /** Input to {@link CrossTenantGrantWriter.accept}. */
156
+ export interface AcceptGrantInput {
157
+ /** The grant to accept (its uuid). */
158
+ readonly grantUuid: string;
159
+ /**
160
+ * ⛔ The AUTHENTICATED principal accepting — supplied from the request principal. Proven to
161
+ * be a MEMBER of the grant's GRANTEE tenant before the write.
162
+ */
163
+ readonly acceptedBy: string;
164
+ }
165
+ /** Input to {@link CrossTenantGrantWriter.revoke}. */
166
+ export interface RevokeGrantInput {
167
+ /** The grant to revoke (its uuid). */
168
+ readonly grantUuid: string;
169
+ /**
170
+ * ⛔ The AUTHENTICATED principal revoking — supplied from the request principal. Proven to be
171
+ * EITHER an admin of the OWNING tenant OR a member of the GRANTEE tenant before the write.
172
+ */
173
+ readonly revokedBy: string;
174
+ }
175
+ /** Thrown when the who-may-grant bound rejects an offer/accept/revoke (fail-closed). */
176
+ export declare class GrantNotPermittedError extends Error {
177
+ constructor(message: string);
178
+ }
179
+ /** Thrown when the grant input is malformed (bad ceiling / expiry / scope). */
180
+ export declare class InvalidGrantError extends Error {
181
+ constructor(message: string);
182
+ }
183
+ /** Thrown when the grant store genuinely cannot answer/write (transient → 503-retryable). */
184
+ export declare class GrantStoreUnavailableError extends Error {
185
+ constructor(message: string);
186
+ }
187
+ export declare class CrossTenantGrantWriter {
188
+ private readonly db;
189
+ private readonly authorize;
190
+ private readonly audit;
191
+ private readonly schema;
192
+ private readonly now;
193
+ constructor(deps: {
194
+ db: GrantQueryable;
195
+ /**
196
+ * Answers "may `principalId` perform `action` in `tenantId`?" over the consumer's OWN
197
+ * authorization model (typically a thin closure that builds the principal and calls the
198
+ * app's `decide()`). Replaces the former `authority: GrantAuthorityResolver`.
199
+ */
200
+ authorize: GrantAuthorizeFn;
201
+ /** Optional — absent ⇒ lifecycle events are un-audited (never blocks the write). */
202
+ audit?: GrantAuditSink;
203
+ schema?: string;
204
+ /** Test seam: a deterministic clock (defaults to Date.now). */
205
+ nowMs?: () => number;
206
+ });
207
+ /**
208
+ * OFFER a grant — the OWNING tenant consents to let a grantee tenant's principal in. Enforces
209
+ * the offer bound (owning-tenant admin, non-empty/non-wildcard ceiling, future expiry, scope
210
+ * ↔ recordId). Creates a fresh row in 'offered' status. Emits `grant.offered`.
211
+ *
212
+ * @returns the new grant's uuid.
213
+ * @throws {@link GrantNotPermittedError} if the offerer is not an owning-tenant admin.
214
+ * @throws {@link InvalidGrantError} on a bad ceiling / expiry / scope.
215
+ * @throws {@link GrantStoreUnavailableError} if the store cannot be reached (transient).
216
+ */
217
+ offer(input: OfferGrantInput): Promise<string>;
218
+ /**
219
+ * ACCEPT a grant — the GRANTEE tenant activates it. Only a MEMBER of the grant's grantee
220
+ * tenant may accept, and only a grant currently 'offered'. Moves it to 'accepted' (the point
221
+ * at which it becomes ACTIVE for `findActiveGrant`). Re-accepting an 'accepted' grant is a
222
+ * benign no-op; accepting a 'revoked' grant is rejected. Emits `grant.accepted`.
223
+ *
224
+ * @throws {@link GrantNotPermittedError} if the accepter is not a grantee-tenant member, the
225
+ * grant does not exist, or it is not in 'offered' status.
226
+ * @throws {@link GrantStoreUnavailableError} if the store cannot be reached (transient).
227
+ */
228
+ accept(input: AcceptGrantInput): Promise<void>;
229
+ /**
230
+ * REVOKE a grant — EITHER an admin of the owning tenant OR a member of the grantee tenant may
231
+ * revoke (either side, ADR-0009). Moves it to 'revoked' + stamps `ctg_revoked_at` (it becomes
232
+ * immediately inactive — `findActiveGrant` reads live). Re-revoking a 'revoked' grant is a
233
+ * benign no-op. Emits `grant.revoked`.
234
+ *
235
+ * @throws {@link GrantNotPermittedError} if the revoker is neither an owning-tenant admin nor
236
+ * a grantee-tenant member, or the grant does not exist.
237
+ * @throws {@link GrantStoreUnavailableError} if the store cannot be reached (transient).
238
+ */
239
+ revoke(input: RevokeGrantInput): Promise<void>;
240
+ /**
241
+ * Enforce the offer INPUT bounds (ceiling non-empty + non-wildcard, future expiry, scope ↔
242
+ * recordId). Throws {@link InvalidGrantError} on any failure (fail-closed). The is-admin
243
+ * authority check is done separately (it needs I/O).
244
+ */
245
+ private assertValidOffer;
246
+ /**
247
+ * Run an authority resolver call, translating a store outage into
248
+ * {@link GrantStoreUnavailableError} (retryable) — a resolver that THROWS is an outage, not a
249
+ * "not authorized". A resolver returning `false` is a legitimate deny (handled by the caller).
250
+ */
251
+ private resolveAuthority;
252
+ /** Fetch a grant's lifecycle row (tenants + status) by uuid — never trusts caller-supplied tenants. */
253
+ private fetchGrant;
254
+ /** Emit an offer event (fields already assembled). Best-effort. */
255
+ private emit;
256
+ /** Emit an accept/revoke event, deriving structured attributes from the fetched row. */
257
+ private emitFromRow;
258
+ }
259
+ //# sourceMappingURL=cross-tenant-grant-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-tenant-grant-writer.d.ts","sourceRoot":"","sources":["../../src/authz/cross-tenant-grant-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAK9E,8CAA8C;AAC9C,eAAO,MAAM,gCAAgC,eAA6C,CAAC;AAE3F,0FAA0F;AAC1F,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,C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