@astram/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/dist/admin/admin-service.d.ts +221 -0
  4. package/dist/admin/admin-service.d.ts.map +1 -0
  5. package/dist/admin/admin-service.js +155 -0
  6. package/dist/admin/admin-service.js.map +1 -0
  7. package/dist/admin/command/grants.d.ts +40 -0
  8. package/dist/admin/command/grants.d.ts.map +1 -0
  9. package/dist/admin/command/grants.js +196 -0
  10. package/dist/admin/command/grants.js.map +1 -0
  11. package/dist/admin/command/index.d.ts +23 -0
  12. package/dist/admin/command/index.d.ts.map +1 -0
  13. package/dist/admin/command/index.js +23 -0
  14. package/dist/admin/command/index.js.map +1 -0
  15. package/dist/admin/command/invitations.d.ts +72 -0
  16. package/dist/admin/command/invitations.d.ts.map +1 -0
  17. package/dist/admin/command/invitations.js +241 -0
  18. package/dist/admin/command/invitations.js.map +1 -0
  19. package/dist/admin/command/permissions.d.ts +33 -0
  20. package/dist/admin/command/permissions.d.ts.map +1 -0
  21. package/dist/admin/command/permissions.js +67 -0
  22. package/dist/admin/command/permissions.js.map +1 -0
  23. package/dist/admin/command/pipeline.d.ts +79 -0
  24. package/dist/admin/command/pipeline.d.ts.map +1 -0
  25. package/dist/admin/command/pipeline.js +106 -0
  26. package/dist/admin/command/pipeline.js.map +1 -0
  27. package/dist/admin/command/policies.d.ts +50 -0
  28. package/dist/admin/command/policies.d.ts.map +1 -0
  29. package/dist/admin/command/policies.js +219 -0
  30. package/dist/admin/command/policies.js.map +1 -0
  31. package/dist/admin/command/service-accounts.d.ts +58 -0
  32. package/dist/admin/command/service-accounts.d.ts.map +1 -0
  33. package/dist/admin/command/service-accounts.js +272 -0
  34. package/dist/admin/command/service-accounts.js.map +1 -0
  35. package/dist/admin/command/service.d.ts +65 -0
  36. package/dist/admin/command/service.d.ts.map +1 -0
  37. package/dist/admin/command/service.js +128 -0
  38. package/dist/admin/command/service.js.map +1 -0
  39. package/dist/admin/command/tiers.d.ts +40 -0
  40. package/dist/admin/command/tiers.d.ts.map +1 -0
  41. package/dist/admin/command/tiers.js +79 -0
  42. package/dist/admin/command/tiers.js.map +1 -0
  43. package/dist/admin/index.d.ts +36 -0
  44. package/dist/admin/index.d.ts.map +1 -0
  45. package/dist/admin/index.js +63 -0
  46. package/dist/admin/index.js.map +1 -0
  47. package/dist/admin/ports.d.ts +288 -0
  48. package/dist/admin/ports.d.ts.map +1 -0
  49. package/dist/admin/ports.js +39 -0
  50. package/dist/admin/ports.js.map +1 -0
  51. package/dist/admin/query/audit-view.d.ts +52 -0
  52. package/dist/admin/query/audit-view.d.ts.map +1 -0
  53. package/dist/admin/query/audit-view.js +84 -0
  54. package/dist/admin/query/audit-view.js.map +1 -0
  55. package/dist/admin/query/catalog.d.ts +70 -0
  56. package/dist/admin/query/catalog.d.ts.map +1 -0
  57. package/dist/admin/query/catalog.js +169 -0
  58. package/dist/admin/query/catalog.js.map +1 -0
  59. package/dist/admin/query/explain.d.ts +52 -0
  60. package/dist/admin/query/explain.d.ts.map +1 -0
  61. package/dist/admin/query/explain.js +145 -0
  62. package/dist/admin/query/explain.js.map +1 -0
  63. package/dist/admin/query/index.d.ts +45 -0
  64. package/dist/admin/query/index.d.ts.map +1 -0
  65. package/dist/admin/query/index.js +58 -0
  66. package/dist/admin/query/index.js.map +1 -0
  67. package/dist/admin/query/simulate.d.ts +42 -0
  68. package/dist/admin/query/simulate.d.ts.map +1 -0
  69. package/dist/admin/query/simulate.js +91 -0
  70. package/dist/admin/query/simulate.js.map +1 -0
  71. package/dist/admin/safeguards-impl.d.ts +67 -0
  72. package/dist/admin/safeguards-impl.d.ts.map +1 -0
  73. package/dist/admin/safeguards-impl.js +318 -0
  74. package/dist/admin/safeguards-impl.js.map +1 -0
  75. package/dist/admin/safeguards.d.ts +89 -0
  76. package/dist/admin/safeguards.d.ts.map +1 -0
  77. package/dist/admin/safeguards.js +91 -0
  78. package/dist/admin/safeguards.js.map +1 -0
  79. package/dist/admin/types.d.ts +485 -0
  80. package/dist/admin/types.d.ts.map +1 -0
  81. package/dist/admin/types.js +38 -0
  82. package/dist/admin/types.js.map +1 -0
  83. package/dist/audit/audit-recorder.d.ts +129 -0
  84. package/dist/audit/audit-recorder.d.ts.map +1 -0
  85. package/dist/audit/audit-recorder.js +265 -0
  86. package/dist/audit/audit-recorder.js.map +1 -0
  87. package/dist/audit/canonicalize.d.ts +38 -0
  88. package/dist/audit/canonicalize.d.ts.map +1 -0
  89. package/dist/audit/canonicalize.js +174 -0
  90. package/dist/audit/canonicalize.js.map +1 -0
  91. package/dist/audit/errors.d.ts +56 -0
  92. package/dist/audit/errors.d.ts.map +1 -0
  93. package/dist/audit/errors.js +41 -0
  94. package/dist/audit/errors.js.map +1 -0
  95. package/dist/audit/index.d.ts +45 -0
  96. package/dist/audit/index.d.ts.map +1 -0
  97. package/dist/audit/index.js +24 -0
  98. package/dist/audit/index.js.map +1 -0
  99. package/dist/audit/ports.d.ts +131 -0
  100. package/dist/audit/ports.d.ts.map +1 -0
  101. package/dist/audit/ports.js +27 -0
  102. package/dist/audit/ports.js.map +1 -0
  103. package/dist/audit/sensitive.d.ts +68 -0
  104. package/dist/audit/sensitive.d.ts.map +1 -0
  105. package/dist/audit/sensitive.js +159 -0
  106. package/dist/audit/sensitive.js.map +1 -0
  107. package/dist/audit/walk.d.ts +109 -0
  108. package/dist/audit/walk.d.ts.map +1 -0
  109. package/dist/audit/walk.js +117 -0
  110. package/dist/audit/walk.js.map +1 -0
  111. package/dist/authentication/authenticator.d.ts +74 -0
  112. package/dist/authentication/authenticator.d.ts.map +1 -0
  113. package/dist/authentication/authenticator.js +208 -0
  114. package/dist/authentication/authenticator.js.map +1 -0
  115. package/dist/authentication/credential-resolver.d.ts +76 -0
  116. package/dist/authentication/credential-resolver.d.ts.map +1 -0
  117. package/dist/authentication/credential-resolver.js +21 -0
  118. package/dist/authentication/credential-resolver.js.map +1 -0
  119. package/dist/authentication/index.d.ts +52 -0
  120. package/dist/authentication/index.d.ts.map +1 -0
  121. package/dist/authentication/index.js +27 -0
  122. package/dist/authentication/index.js.map +1 -0
  123. package/dist/authentication/password-hasher.d.ts +41 -0
  124. package/dist/authentication/password-hasher.d.ts.map +1 -0
  125. package/dist/authentication/password-hasher.js +21 -0
  126. package/dist/authentication/password-hasher.js.map +1 -0
  127. package/dist/authentication/totp.d.ts +101 -0
  128. package/dist/authentication/totp.d.ts.map +1 -0
  129. package/dist/authentication/totp.js +151 -0
  130. package/dist/authentication/totp.js.map +1 -0
  131. package/dist/authorization/cross-tenant/grant-evaluator.d.ts +90 -0
  132. package/dist/authorization/cross-tenant/grant-evaluator.d.ts.map +1 -0
  133. package/dist/authorization/cross-tenant/grant-evaluator.js +165 -0
  134. package/dist/authorization/cross-tenant/grant-evaluator.js.map +1 -0
  135. package/dist/authorization/decision-authority.d.ts +212 -0
  136. package/dist/authorization/decision-authority.d.ts.map +1 -0
  137. package/dist/authorization/decision-authority.js +200 -0
  138. package/dist/authorization/decision-authority.js.map +1 -0
  139. package/dist/authorization/default-gates.d.ts +41 -0
  140. package/dist/authorization/default-gates.d.ts.map +1 -0
  141. package/dist/authorization/default-gates.js +47 -0
  142. package/dist/authorization/default-gates.js.map +1 -0
  143. package/dist/authorization/delegation/operation-identity.d.ts +132 -0
  144. package/dist/authorization/delegation/operation-identity.d.ts.map +1 -0
  145. package/dist/authorization/delegation/operation-identity.js +220 -0
  146. package/dist/authorization/delegation/operation-identity.js.map +1 -0
  147. package/dist/authorization/errors.d.ts +54 -0
  148. package/dist/authorization/errors.d.ts.map +1 -0
  149. package/dist/authorization/errors.js +63 -0
  150. package/dist/authorization/errors.js.map +1 -0
  151. package/dist/authorization/gates/object-type.d.ts +63 -0
  152. package/dist/authorization/gates/object-type.d.ts.map +1 -0
  153. package/dist/authorization/gates/object-type.js +177 -0
  154. package/dist/authorization/gates/object-type.js.map +1 -0
  155. package/dist/authorization/gates/tenant.d.ts +50 -0
  156. package/dist/authorization/gates/tenant.d.ts.map +1 -0
  157. package/dist/authorization/gates/tenant.js +87 -0
  158. package/dist/authorization/gates/tenant.js.map +1 -0
  159. package/dist/authorization/gates/wiring.d.ts +57 -0
  160. package/dist/authorization/gates/wiring.d.ts.map +1 -0
  161. package/dist/authorization/gates/wiring.js +56 -0
  162. package/dist/authorization/gates/wiring.js.map +1 -0
  163. package/dist/authorization/index.d.ts +136 -0
  164. package/dist/authorization/index.d.ts.map +1 -0
  165. package/dist/authorization/index.js +82 -0
  166. package/dist/authorization/index.js.map +1 -0
  167. package/dist/authorization/ports.d.ts +271 -0
  168. package/dist/authorization/ports.d.ts.map +1 -0
  169. package/dist/authorization/ports.js +36 -0
  170. package/dist/authorization/ports.js.map +1 -0
  171. package/dist/authorization/reason-codes.d.ts +75 -0
  172. package/dist/authorization/reason-codes.d.ts.map +1 -0
  173. package/dist/authorization/reason-codes.js +98 -0
  174. package/dist/authorization/reason-codes.js.map +1 -0
  175. package/dist/authorization/record/permit-tier.d.ts +57 -0
  176. package/dist/authorization/record/permit-tier.d.ts.map +1 -0
  177. package/dist/authorization/record/permit-tier.js +79 -0
  178. package/dist/authorization/record/permit-tier.js.map +1 -0
  179. package/dist/authorization/record/rule-evaluator.d.ts +116 -0
  180. package/dist/authorization/record/rule-evaluator.d.ts.map +1 -0
  181. package/dist/authorization/record/rule-evaluator.js +125 -0
  182. package/dist/authorization/record/rule-evaluator.js.map +1 -0
  183. package/dist/authorization/record/shares.d.ts +70 -0
  184. package/dist/authorization/record/shares.d.ts.map +1 -0
  185. package/dist/authorization/record/shares.js +107 -0
  186. package/dist/authorization/record/shares.js.map +1 -0
  187. package/dist/identity/broker.d.ts +59 -0
  188. package/dist/identity/broker.d.ts.map +1 -0
  189. package/dist/identity/broker.js +135 -0
  190. package/dist/identity/broker.js.map +1 -0
  191. package/dist/identity/claim-mapper.d.ts +84 -0
  192. package/dist/identity/claim-mapper.d.ts.map +1 -0
  193. package/dist/identity/claim-mapper.js +48 -0
  194. package/dist/identity/claim-mapper.js.map +1 -0
  195. package/dist/identity/index.d.ts +60 -0
  196. package/dist/identity/index.d.ts.map +1 -0
  197. package/dist/identity/index.js +24 -0
  198. package/dist/identity/index.js.map +1 -0
  199. package/dist/identity/internal-adapter.d.ts +54 -0
  200. package/dist/identity/internal-adapter.d.ts.map +1 -0
  201. package/dist/identity/internal-adapter.js +88 -0
  202. package/dist/identity/internal-adapter.js.map +1 -0
  203. package/dist/index.d.ts +43 -0
  204. package/dist/index.d.ts.map +1 -0
  205. package/dist/index.js +48 -0
  206. package/dist/index.js.map +1 -0
  207. package/dist/metadata/completeness.d.ts +136 -0
  208. package/dist/metadata/completeness.d.ts.map +1 -0
  209. package/dist/metadata/completeness.js +106 -0
  210. package/dist/metadata/completeness.js.map +1 -0
  211. package/dist/metadata/dependencies.d.ts +114 -0
  212. package/dist/metadata/dependencies.d.ts.map +1 -0
  213. package/dist/metadata/dependencies.js +105 -0
  214. package/dist/metadata/dependencies.js.map +1 -0
  215. package/dist/metadata/index.d.ts +153 -0
  216. package/dist/metadata/index.d.ts.map +1 -0
  217. package/dist/metadata/index.js +51 -0
  218. package/dist/metadata/index.js.map +1 -0
  219. package/dist/metadata/registry.d.ts +23 -0
  220. package/dist/metadata/registry.d.ts.map +1 -0
  221. package/dist/metadata/registry.js +204 -0
  222. package/dist/metadata/registry.js.map +1 -0
  223. package/dist/risk/evaluator.d.ts +76 -0
  224. package/dist/risk/evaluator.d.ts.map +1 -0
  225. package/dist/risk/evaluator.js +59 -0
  226. package/dist/risk/evaluator.js.map +1 -0
  227. package/dist/risk/index.d.ts +40 -0
  228. package/dist/risk/index.d.ts.map +1 -0
  229. package/dist/risk/index.js +20 -0
  230. package/dist/risk/index.js.map +1 -0
  231. package/dist/risk/risk-engine.d.ts +76 -0
  232. package/dist/risk/risk-engine.d.ts.map +1 -0
  233. package/dist/risk/risk-engine.js +287 -0
  234. package/dist/risk/risk-engine.js.map +1 -0
  235. package/dist/risk/signals.d.ts +60 -0
  236. package/dist/risk/signals.d.ts.map +1 -0
  237. package/dist/risk/signals.js +104 -0
  238. package/dist/risk/signals.js.map +1 -0
  239. package/dist/risk/thresholds.d.ts +54 -0
  240. package/dist/risk/thresholds.d.ts.map +1 -0
  241. package/dist/risk/thresholds.js +60 -0
  242. package/dist/risk/thresholds.js.map +1 -0
  243. package/dist/session/index.d.ts +47 -0
  244. package/dist/session/index.d.ts.map +1 -0
  245. package/dist/session/index.js +20 -0
  246. package/dist/session/index.js.map +1 -0
  247. package/dist/session/lifetimes.d.ts +50 -0
  248. package/dist/session/lifetimes.d.ts.map +1 -0
  249. package/dist/session/lifetimes.js +67 -0
  250. package/dist/session/lifetimes.js.map +1 -0
  251. package/dist/session/ports.d.ts +266 -0
  252. package/dist/session/ports.d.ts.map +1 -0
  253. package/dist/session/ports.js +23 -0
  254. package/dist/session/ports.js.map +1 -0
  255. package/dist/session/session-authority.d.ts +97 -0
  256. package/dist/session/session-authority.d.ts.map +1 -0
  257. package/dist/session/session-authority.js +393 -0
  258. package/dist/session/session-authority.js.map +1 -0
  259. package/package.json +32 -0
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Team B command — **curatePermission** (rename / group a permission, AC 1).
3
+ *
4
+ * Overlays an admin-authored label/group on the registry-seeded catalog via the
5
+ * {@link CatalogStore} (the base catalog is the ModuleRegistry; curation is the
6
+ * overlay). Low-blast, non-destructive — it does NOT change access, only display —
7
+ * so it does not require a confirm token. Still routes the full §11.3 pipeline
8
+ * (delegated-admin gate → validate → mutate → audit) so every curation is
9
+ * attributable (invariant #6).
10
+ *
11
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
12
+ */
13
+ import { buildAuditAttributes, runAdminCommand } from './pipeline.js';
14
+ /**
15
+ * Curate (rename/group) a permission. `label`/`group` are the human-readable
16
+ * overlay values; at least one must be present. Fails `invalid_policy` when both
17
+ * are absent/blank (nothing to curate) — reusing the closed deny taxonomy rather
18
+ * than inventing a reason.
19
+ */
20
+ export function makeCuratePermission(deps) {
21
+ const clock = deps.now ?? Date.now;
22
+ return async function curatePermission(mutation, permissionKey, label, group) {
23
+ return runAdminCommand({
24
+ mutation,
25
+ hasConfirmToken: true, // non-destructive — no confirm required
26
+ validate: () => {
27
+ const hasLabel = typeof label === 'string' && label.trim().length > 0;
28
+ const hasGroup = typeof group === 'string' && group.trim().length > 0;
29
+ if (!hasLabel && !hasGroup) {
30
+ // Nothing to curate — reject structurally (fail-closed).
31
+ return { ok: false, reason: 'invalid_policy' };
32
+ }
33
+ if (typeof permissionKey !== 'string' || permissionKey.length === 0) {
34
+ return { ok: false, reason: 'not_found' };
35
+ }
36
+ return null;
37
+ },
38
+ mutate: async () => {
39
+ await deps.catalogStore.setCuration({
40
+ permissionKey,
41
+ ...(typeof label === 'string' && label.trim().length > 0
42
+ ? { label }
43
+ : {}),
44
+ ...(typeof group === 'string' && group.trim().length > 0
45
+ ? { group }
46
+ : {}),
47
+ });
48
+ },
49
+ emitAudit: async (_value, blastRadius) => {
50
+ const permissionLabel = await deps.labels.resolve('permission', permissionKey, mutation.targetTenantId);
51
+ await deps.audit.record({
52
+ type: 'admin_action',
53
+ occurredAtMs: clock(),
54
+ actorId: mutation.admin.id,
55
+ tenantId: mutation.targetTenantId,
56
+ attributes: buildAuditAttributes(mutation, blastRadius, {
57
+ action: 'curate_permission',
58
+ permissionLabel,
59
+ ...(label !== undefined ? { newLabel: label } : {}),
60
+ ...(group !== undefined ? { newGroup: group } : {}),
61
+ }),
62
+ });
63
+ },
64
+ }, deps.decide);
65
+ };
66
+ }
67
+ //# sourceMappingURL=permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/admin/command/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAYtE;;;;;GAKG;AACH,MAAM,UA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AM,GAAG,CAAC;wBACtD,CAAC,CAAC,EAAE,KAAK,EAAE;wBACX,CAAC,CAAC,EAAE,CAAC;iBACR,CAAC,CAAC;YACL,CAAC;YACD,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;gBACvC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAC/C,YAAY,EACZ,aAAa,EACb,QAAQ,CAAC,cAAc,CACxB,CAAC;gBACF,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;oBACtB,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,KAAK,EAAE;oBACrB,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE;oBAC1B,QAAQ,EAAE,QAAQ,CAAC,cAAc;oBACjC,UAAU,EAAE,oBAAoB,CAAC,QAAQ,EAAE,WAAW,EAAE;wBACtD,MAAM,EAAE,mBAAmB;wBAC3B,eAAe;wBACf,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;wBACnD,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBACpD,CAAC;iBACH,CAAC,CAAC;YACL,CAAC;SACF,EACD,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The Team-B command pipeline runner (§11.3 order) — the REAL-safeguard twin of
3
+ * the prelude's `runCommandPipeline`.
4
+ *
5
+ * ⛔ WHY THIS EXISTS. The frozen `admin-service.ts#runCommandPipeline` hardwires
6
+ * the FAIL-CLOSED STUB safeguards from `safeguards.ts` (which always deny /
7
+ * high-blast / confirm-required). Team B may NOT edit those frozen files. So each
8
+ * command routes through THIS runner, which executes the identical §11.3 ORDER but
9
+ * against Team B's REAL safeguards in `../safeguards-impl.ts`. The integration
10
+ * owner wires the command service to these runners; the frozen stub file stays
11
+ * byte-unchanged.
12
+ *
13
+ * FROZEN ORDER (identical to the prelude's):
14
+ * (1) DELEGATED-ADMIN CHECK — {@link checkDelegatedAdminImpl} (reuses decide()).
15
+ * (2) VALIDATE — the command's own structural check.
16
+ * (3) CONFIRM + BLAST-RADIUS — if {@link requiresConfirmImpl}, require the
17
+ * confirm token (else `confirm_required`) and compute the blast-radius.
18
+ * (4) MUTATE — apply via the store.
19
+ * (5) AUDIT — emit the `admin_action` event, with the blast-radius threaded into
20
+ * the event attributes for destructive commands (the reviewer note).
21
+ *
22
+ * Any step that denies short-circuits fail-closed BEFORE the mutation.
23
+ *
24
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
25
+ */
26
+ import type { DecisionAuthority } from '../../authorization/index.js';
27
+ import { type ComputeBlastRadiusDeps } from '../safeguards-impl.js';
28
+ import type { AdminMutation, BlastRadius, CommandResult } from '../types.js';
29
+ /**
30
+ * The per-command closures Team B supplies to {@link runAdminCommand}. `validate`
31
+ * returns `null` to pass or a deny `CommandResult` to reject (step 2). `mutate`
32
+ * applies the change (step 4). `emitAudit` records the event (step 5) — it
33
+ * RECEIVES the computed blast-radius (present only when the command was
34
+ * destructive/confirm-required) so the emitter can thread it into the audit
35
+ * event's attributes (the reviewer note: the blast-radius must not be discarded).
36
+ */
37
+ export interface AdminCommandStep<T> {
38
+ /** The tagged mutation (drives the real safeguards). */
39
+ readonly mutation: AdminMutation;
40
+ /** Step 2 — structural validation. `null` passes; a deny CommandResult rejects. */
41
+ readonly validate: () => Promise<CommandResult<never> | null> | (CommandResult<never> | null);
42
+ /** Whether the caller supplied a valid confirm token (checked at step 3). */
43
+ readonly hasConfirmToken: boolean;
44
+ /** Step 4 — apply the mutation; returns the command's value. */
45
+ readonly mutate: () => Promise<T>;
46
+ /**
47
+ * Step 5 — emit the audit event for the applied mutation. `blastRadius` is the
48
+ * value computed at step 3 (or `null` when the command was non-destructive and
49
+ * no radius was computed). Team B threads it into the emitted event.
50
+ */
51
+ readonly emitAudit: (value: T, blastRadius: BlastRadius | null) => Promise<void>;
52
+ }
53
+ /**
54
+ * Run a mutating admin command through the frozen §11.3 pipeline against Team B's
55
+ * REAL safeguards. Every deny short-circuits fail-closed BEFORE the mutation.
56
+ *
57
+ * ⛔ `decide` is threaded into {@link checkDelegatedAdminImpl} — the ONE decision
58
+ * path (ADR-0001). The computed blast-radius is threaded into `emitAudit` (step 5)
59
+ * so it is recorded, not discarded.
60
+ */
61
+ export declare function runAdminCommand<T>(step: AdminCommandStep<T>, decide: DecisionAuthority, blastDeps?: ComputeBlastRadiusDeps): Promise<CommandResult<T>>;
62
+ /**
63
+ * Return a copy of `mutation` whose `payload` is enriched with the command's own
64
+ * data, so the §11.3 safeguards (which read ONLY `mutation.payload`) can classify
65
+ * the delegated-admin scope / blast-radius / confirm-required. Each command calls
66
+ * this before {@link runAdminCommand} so the safeguard sees the grant/tier/policy/
67
+ * invitation details even when the service passed them as a separate argument.
68
+ *
69
+ * Existing payload keys (e.g. a caller-supplied `confirm` token) are PRESERVED —
70
+ * the command payload is merged UNDER them so a confirm token is never clobbered.
71
+ */
72
+ export declare function withPayload(mutation: AdminMutation, payload: Readonly<Record<string, unknown>>): AdminMutation;
73
+ /**
74
+ * Build the shared `attributes` bag for an `admin_action` audit event, folding in
75
+ * the mutation kind + (when present) the computed blast-radius. The single place
76
+ * the blast-radius→audit threading happens, so every command records it uniformly.
77
+ */
78
+ export declare function buildAuditAttributes(mutation: AdminMutation, blastRadius: BlastRadius | null, extra?: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>>;
79
+ //# sourceMappingURL=pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/admin/command/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,K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EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAiBnC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * The Team-B command pipeline runner (§11.3 order) — the REAL-safeguard twin of
3
+ * the prelude's `runCommandPipeline`.
4
+ *
5
+ * ⛔ WHY THIS EXISTS. The frozen `admin-service.ts#runCommandPipeline` hardwires
6
+ * the FAIL-CLOSED STUB safeguards from `safeguards.ts` (which always deny /
7
+ * high-blast / confirm-required). Team B may NOT edit those frozen files. So each
8
+ * command routes through THIS runner, which executes the identical §11.3 ORDER but
9
+ * against Team B's REAL safeguards in `../safeguards-impl.ts`. The integration
10
+ * owner wires the command service to these runners; the frozen stub file stays
11
+ * byte-unchanged.
12
+ *
13
+ * FROZEN ORDER (identical to the prelude's):
14
+ * (1) DELEGATED-ADMIN CHECK — {@link checkDelegatedAdminImpl} (reuses decide()).
15
+ * (2) VALIDATE — the command's own structural check.
16
+ * (3) CONFIRM + BLAST-RADIUS — if {@link requiresConfirmImpl}, require the
17
+ * confirm token (else `confirm_required`) and compute the blast-radius.
18
+ * (4) MUTATE — apply via the store.
19
+ * (5) AUDIT — emit the `admin_action` event, with the blast-radius threaded into
20
+ * the event attributes for destructive commands (the reviewer note).
21
+ *
22
+ * Any step that denies short-circuits fail-closed BEFORE the mutation.
23
+ *
24
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
25
+ */
26
+ import { checkDelegatedAdminImpl, computeBlastRadiusImpl, requiresConfirmImpl, } from '../safeguards-impl.js';
27
+ /**
28
+ * Run a mutating admin command through the frozen §11.3 pipeline against Team B's
29
+ * REAL safeguards. Every deny short-circuits fail-closed BEFORE the mutation.
30
+ *
31
+ * ⛔ `decide` is threaded into {@link checkDelegatedAdminImpl} — the ONE decision
32
+ * path (ADR-0001). The computed blast-radius is threaded into `emitAudit` (step 5)
33
+ * so it is recorded, not discarded.
34
+ */
35
+ export async function runAdminCommand(step, decide, blastDeps = {}) {
36
+ // (1) DELEGATED-ADMIN CHECK — fail-closed, reuses decide() (ADR-0001 / §3.2).
37
+ const delegated = await checkDelegatedAdminImpl(step.mutation.admin, step.mutation, decide);
38
+ if (delegated.ok !== true) {
39
+ return {
40
+ ok: false,
41
+ reason: delegated.reason ?? 'delegated_admin_exceeds_authority',
42
+ };
43
+ }
44
+ // (2) VALIDATE — structural (guided policy / tier≠public / legal transition).
45
+ const invalid = await step.validate();
46
+ if (invalid !== null) {
47
+ return invalid;
48
+ }
49
+ // (3) CONFIRM + BLAST-RADIUS — destructive/high-blast requires a confirm token.
50
+ let blastRadius = null;
51
+ if (requiresConfirmImpl(step.mutation) === true) {
52
+ if (step.hasConfirmToken !== true) {
53
+ return { ok: false, reason: 'confirm_required' };
54
+ }
55
+ // Computed for the audit record; threaded into emitAudit below (not discarded).
56
+ blastRadius = await computeBlastRadiusImpl(step.mutation, blastDeps);
57
+ }
58
+ // (4) MUTATE — only reached after 1–3 pass (fail-closed order).
59
+ const value = await step.mutate();
60
+ // (5) AUDIT — every applied mutation is recorded, with the blast-radius threaded
61
+ // into the emitted event's attributes for destructive commands (invariant #6).
62
+ await step.emitAudit(value, blastRadius);
63
+ return { ok: true, value };
64
+ }
65
+ /**
66
+ * Return a copy of `mutation` whose `payload` is enriched with the command's own
67
+ * data, so the §11.3 safeguards (which read ONLY `mutation.payload`) can classify
68
+ * the delegated-admin scope / blast-radius / confirm-required. Each command calls
69
+ * this before {@link runAdminCommand} so the safeguard sees the grant/tier/policy/
70
+ * invitation details even when the service passed them as a separate argument.
71
+ *
72
+ * Existing payload keys (e.g. a caller-supplied `confirm` token) are PRESERVED —
73
+ * the command payload is merged UNDER them so a confirm token is never clobbered.
74
+ */
75
+ export function withPayload(mutation, payload) {
76
+ const existing = mutation.payload !== null &&
77
+ typeof mutation.payload === 'object' &&
78
+ !Array.isArray(mutation.payload)
79
+ ? mutation.payload
80
+ : {};
81
+ return { ...mutation, payload: { ...payload, ...existing } };
82
+ }
83
+ /**
84
+ * Build the shared `attributes` bag for an `admin_action` audit event, folding in
85
+ * the mutation kind + (when present) the computed blast-radius. The single place
86
+ * the blast-radius→audit threading happens, so every command records it uniformly.
87
+ */
88
+ export function buildAuditAttributes(mutation, blastRadius, extra) {
89
+ const base = {
90
+ commandKind: mutation.kind,
91
+ targetTenantId: mutation.targetTenantId,
92
+ ...extra,
93
+ };
94
+ if (blastRadius !== null) {
95
+ base.blastRadius = {
96
+ affectedPrincipalCount: blastRadius.affectedPrincipalCount,
97
+ severity: blastRadius.severity,
98
+ description: blastRadius.description,
99
+ ...(blastRadius.affectedRecordEstimate !== undefined
100
+ ? { affectedRecordEstimate: blastRadius.affectedRecordEstimate }
101
+ : {}),
102
+ };
103
+ }
104
+ return base;
105
+ }
106
+ //# sourceMappingURL=pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/admin/command/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,GAEpB,MAAM,uBAAuB,CAAC;AA8B/B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAyB,EACzB,MAAyB,EACzB,YAAoC,EAAE;IAEtC,8EAA8E;IAC9E,MAAM,SAAS,GAAG,MAAM,uBAAuB,CAC7C,IAAI,CAAC,QAAQ,CAAC,KAAK,EACnB,IAAI,CAAC,QAAQ,EACb,MAAM,CACP,CAAC;IACF,IAAI,SAAS,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,mCAAmC;SAChE,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ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4B;QACpC,WAAW,EAAE,QAAQ,CAAC,IAAI;QAC1B,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,GAAG,KAAK;KACT,CAAC;IACF,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG;YACjB,sBAAsB,EAAE,WAAW,CAAC,sBAAsB;YAC1D,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,GAAG,CAAC,WAAW,CAAC,sBAAsB,KAAK,SAAS;gBAClD,CAAC,CAAC,EAAE,sBAAsB,EAAE,WAAW,CAAC,sBAAsB,EAAE;gBAChE,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Team B command — **authorPolicy** (the GUIDED-BUILDER validation, AC 5 / §3.4).
3
+ *
4
+ * A record-access policy is authored as a structured {@link GuidedPolicy}
5
+ * (typeKey + action + effect + field→operator→value conditions). There is NO
6
+ * raw-expression path — the type literally cannot represent one — but this module
7
+ * VALIDATES the structure defensively:
8
+ * - `typeKey` is a registered object type;
9
+ * - `action` is a non-empty stable key;
10
+ * - each condition's `field` is a KNOWN field of that object type (from the
11
+ * registry descriptor);
12
+ * - the condition's `operator` is VALID FOR THAT FIELD'S TYPE;
13
+ * - the condition's `value` is WELL-FORMED for the operator.
14
+ * Anything else → `invalid_policy`.
15
+ *
16
+ * On success the pipeline persists via {@link PolicyStore.savePolicy} + audits.
17
+ * A policy author is additive (it defines access rules); no confirm token needed.
18
+ *
19
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
20
+ */
21
+ import type { AuditSink } from '../../audit/index.js';
22
+ import type { DecisionAuthority } from '../../authorization/index.js';
23
+ import type { ModuleRegistry } from '../../metadata/index.js';
24
+ import type { PolicyStore } from '../ports.js';
25
+ import type { AdminMutation, CommandResult, GuidedPolicy, Policy } from '../types.js';
26
+ /** Deps the authorPolicy command closes over. */
27
+ export interface AuthorPolicyDeps {
28
+ readonly registry: ModuleRegistry;
29
+ readonly policyStore: PolicyStore;
30
+ readonly decide: DecisionAuthority;
31
+ readonly audit: AuditSink;
32
+ /** UTC clock (epoch ms). */
33
+ readonly now?: () => number;
34
+ }
35
+ /**
36
+ * SHAPE validation of a single condition, WITHOUT the registry (used by the grant
37
+ * command for its inline conditions). Checks: `field` is a non-empty string, the
38
+ * `operator` is a member of the closed set, and the `value` is well-formed for the
39
+ * operator. Does NOT verify the field exists on an object type (that needs the
40
+ * registry + the owning type — done in {@link validateGuidedPolicy}).
41
+ */
42
+ export declare function isValidCondition(condition: unknown): boolean;
43
+ /**
44
+ * Fully validate a {@link GuidedPolicy} against the registry (AC 5). Returns `null`
45
+ * on success or an `invalid_policy` deny on ANY structural failure. Pure (reads the
46
+ * registry, no I/O). Exported so tests + the grant path can reuse it.
47
+ */
48
+ export declare function validateGuidedPolicy(registry: ModuleRegistry, policy: GuidedPolicy): CommandResult<never> | null;
49
+ export declare function makeAuthorPolicy(deps: AuthorPolicyDeps): (inMutation: AdminMutation, policy: GuidedPolicy) => Promise<CommandResult<Policy>>;
50
+ //# sourceMappingURL=policies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../../../src/admin/command/policies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,MAAM,EAGP,MAAM,aAAa,CAAC;AAGrB,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,4BAA4B;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AA4GD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAe5D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,YAAY,GACnB,aAAa,CAAC,KAAK,CAAC,GAAG,IAAI,CAqD7B;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,IAGnD,YAAY,aAAa,EACzB,QAAQ,YAAY,KACnB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAkClC"}
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Team B command — **authorPolicy** (the GUIDED-BUILDER validation, AC 5 / §3.4).
3
+ *
4
+ * A record-access policy is authored as a structured {@link GuidedPolicy}
5
+ * (typeKey + action + effect + field→operator→value conditions). There is NO
6
+ * raw-expression path — the type literally cannot represent one — but this module
7
+ * VALIDATES the structure defensively:
8
+ * - `typeKey` is a registered object type;
9
+ * - `action` is a non-empty stable key;
10
+ * - each condition's `field` is a KNOWN field of that object type (from the
11
+ * registry descriptor);
12
+ * - the condition's `operator` is VALID FOR THAT FIELD'S TYPE;
13
+ * - the condition's `value` is WELL-FORMED for the operator.
14
+ * Anything else → `invalid_policy`.
15
+ *
16
+ * On success the pipeline persists via {@link PolicyStore.savePolicy} + audits.
17
+ * A policy author is additive (it defines access rules); no confirm token needed.
18
+ *
19
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
20
+ */
21
+ import { buildAuditAttributes, runAdminCommand, withPayload } from './pipeline.js';
22
+ /** The complete closed set of guided operators (single source — mirrors the type). */
23
+ const ALL_OPERATORS = new Set([
24
+ 'eq',
25
+ 'ne',
26
+ 'in',
27
+ 'not_in',
28
+ 'gt',
29
+ 'lt',
30
+ 'gte',
31
+ 'lte',
32
+ 'contains',
33
+ 'not_contains',
34
+ 'is_null',
35
+ 'is_not_null',
36
+ 'is_owner',
37
+ 'is_not_owner',
38
+ ]);
39
+ /** Operators that take NO operand (a `value` is ignored / must be absent-ish). */
40
+ const NULLARY_OPERATORS = new Set([
41
+ 'is_null',
42
+ 'is_not_null',
43
+ 'is_owner',
44
+ 'is_not_owner',
45
+ ]);
46
+ /** Operators whose operand MUST be an array (set membership). */
47
+ const ARRAY_OPERATORS = new Set(['in', 'not_in']);
48
+ /** Operators that are ownership predicates — only valid on a REFERENCE field. */
49
+ const OWNERSHIP_OPERATORS = new Set([
50
+ 'is_owner',
51
+ 'is_not_owner',
52
+ ]);
53
+ /**
54
+ * Ordered/relational operators (`gt`/`lt`/`gte`/`lte`) — valid on scalar
55
+ * (non-reference) fields, never on a reference field (you don't order a reference).
56
+ */
57
+ const RELATIONAL_OPERATORS = new Set([
58
+ 'gt',
59
+ 'lt',
60
+ 'gte',
61
+ 'lte',
62
+ ]);
63
+ /** Text operators (`contains`/`not_contains`) — valid on scalar fields only. */
64
+ const TEXT_OPERATORS = new Set([
65
+ 'contains',
66
+ 'not_contains',
67
+ ]);
68
+ /**
69
+ * Is `operator` valid for a field, given whether the field is a REFERENCE field
70
+ * (carries `referencesTypeKey`)? This is the field-type↔operator compatibility
71
+ * rule (§3.4). Conservative + closed:
72
+ * - ownership predicates (`is_owner`/`is_not_owner`) → REFERENCE fields only;
73
+ * - relational (`gt`/`lt`/`gte`/`lte`) + text (`contains`/`not_contains`) →
74
+ * scalar (non-reference) fields only;
75
+ * - equality/membership/null (`eq`/`ne`/`in`/`not_in`/`is_null`/`is_not_null`) →
76
+ * valid on any field.
77
+ */
78
+ function operatorValidForField(operator, field) {
79
+ const isReference = typeof field.referencesTypeKey === 'string' &&
80
+ field.referencesTypeKey.length > 0;
81
+ if (OWNERSHIP_OPERATORS.has(operator)) {
82
+ return isReference;
83
+ }
84
+ if (RELATIONAL_OPERATORS.has(operator) || TEXT_OPERATORS.has(operator)) {
85
+ return !isReference;
86
+ }
87
+ // eq / ne / in / not_in / is_null / is_not_null — universally applicable.
88
+ return true;
89
+ }
90
+ /**
91
+ * Is the `value` well-formed for `operator`?
92
+ * - nullary operators (`is_null`/ownership) → value must be absent/undefined/null;
93
+ * - array operators (`in`/`not_in`) → value must be a non-empty array of primitives;
94
+ * - everything else → value must be a defined primitive (string/number/boolean).
95
+ */
96
+ function valueWellFormed(operator, value) {
97
+ if (NULLARY_OPERATORS.has(operator)) {
98
+ return value === undefined || value === null;
99
+ }
100
+ if (ARRAY_OPERATORS.has(operator)) {
101
+ return (Array.isArray(value) &&
102
+ value.length > 0 &&
103
+ value.every((v) => isPrimitive(v)));
104
+ }
105
+ return isPrimitive(value);
106
+ }
107
+ function isPrimitive(v) {
108
+ return (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean');
109
+ }
110
+ /**
111
+ * SHAPE validation of a single condition, WITHOUT the registry (used by the grant
112
+ * command for its inline conditions). Checks: `field` is a non-empty string, the
113
+ * `operator` is a member of the closed set, and the `value` is well-formed for the
114
+ * operator. Does NOT verify the field exists on an object type (that needs the
115
+ * registry + the owning type — done in {@link validateGuidedPolicy}).
116
+ */
117
+ export function isValidCondition(condition) {
118
+ if (condition === null || typeof condition !== 'object') {
119
+ return false;
120
+ }
121
+ const c = condition;
122
+ if (typeof c.field !== 'string' || c.field.length === 0) {
123
+ return false;
124
+ }
125
+ if (typeof c.operator !== 'string' ||
126
+ !ALL_OPERATORS.has(c.operator)) {
127
+ return false;
128
+ }
129
+ return valueWellFormed(c.operator, c.value);
130
+ }
131
+ /**
132
+ * Fully validate a {@link GuidedPolicy} against the registry (AC 5). Returns `null`
133
+ * on success or an `invalid_policy` deny on ANY structural failure. Pure (reads the
134
+ * registry, no I/O). Exported so tests + the grant path can reuse it.
135
+ */
136
+ export function validateGuidedPolicy(registry, policy) {
137
+ const invalid = { ok: false, reason: 'invalid_policy' };
138
+ // Defensive shape checks (the type guards most of this, but a hostile caller
139
+ // may cast `as GuidedPolicy` over junk — validate defensively, §3.4).
140
+ if (policy === null || typeof policy !== 'object') {
141
+ return invalid;
142
+ }
143
+ if (typeof policy.typeKey !== 'string' || policy.typeKey.length === 0) {
144
+ return invalid;
145
+ }
146
+ if (typeof policy.action !== 'string' || policy.action.length === 0) {
147
+ return invalid;
148
+ }
149
+ if (policy.effect !== 'allow' && policy.effect !== 'deny') {
150
+ return invalid;
151
+ }
152
+ if (!Array.isArray(policy.conditions)) {
153
+ return invalid;
154
+ }
155
+ // The object type must be REGISTERED (an unknown type has no known fields).
156
+ const objectType = registry.resolveObjectType(policy.typeKey);
157
+ if (objectType === undefined) {
158
+ return invalid;
159
+ }
160
+ const fieldsByKey = new Map();
161
+ for (const f of objectType.fields) {
162
+ fieldsByKey.set(f.key, f);
163
+ }
164
+ for (const condition of policy.conditions) {
165
+ // Basic shape (field string, operator in the closed set, value primitive-ish).
166
+ if (!isValidCondition(condition)) {
167
+ return invalid;
168
+ }
169
+ const c = condition;
170
+ // The field must be a KNOWN field of THIS object type.
171
+ const field = fieldsByKey.get(c.field);
172
+ if (field === undefined) {
173
+ return invalid;
174
+ }
175
+ // The operator must be valid FOR THAT FIELD'S TYPE.
176
+ if (!operatorValidForField(c.operator, field)) {
177
+ return invalid;
178
+ }
179
+ // The value must be well-formed for the operator (re-checked with field ctx).
180
+ if (!valueWellFormed(c.operator, c.value)) {
181
+ return invalid;
182
+ }
183
+ }
184
+ return null;
185
+ }
186
+ export function makeAuthorPolicy(deps) {
187
+ const clock = deps.now ?? Date.now;
188
+ return async function authorPolicy(inMutation, policy) {
189
+ // Enrich so the delegated-admin safeguard reads the policy's object type +
190
+ // action (the admin must hold that action on that type to author a policy).
191
+ const mutation = withPayload(inMutation, {
192
+ typeKey: policy.typeKey,
193
+ action: policy.action,
194
+ });
195
+ return runAdminCommand({
196
+ mutation,
197
+ hasConfirmToken: true, // authoring a policy is additive
198
+ validate: () => validateGuidedPolicy(deps.registry, policy),
199
+ mutate: async () => deps.policyStore.savePolicy(mutation.targetTenantId, policy),
200
+ emitAudit: async (value, blastRadius) => {
201
+ await deps.audit.record({
202
+ type: 'admin_action',
203
+ occurredAtMs: clock(),
204
+ actorId: mutation.admin.id,
205
+ tenantId: mutation.targetTenantId,
206
+ attributes: buildAuditAttributes(mutation, blastRadius, {
207
+ action: 'author_policy',
208
+ objectType: policy.typeKey,
209
+ policyAction: policy.action,
210
+ effect: policy.effect,
211
+ conditionCount: policy.conditions.length,
212
+ policyId: value.policyId,
213
+ }),
214
+ });
215
+ },
216
+ }, deps.decide);
217
+ };
218
+ }
219
+ //# sourceMappingURL=policies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policies.js","sourceRoot":"","sources":["../../../src/admin/command/policies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAcH,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAYnF,sFAAsF;AACtF,MAAM,aAAa,GAAgC,IAAI,GAAG,CAAC;IACzD,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,UAAU;IACV,cAAc;IACd,SAAS;IACT,aAAa;IACb,UAAU;IACV,cAAc;CACf,CAAC,CAAC;AAEH,kFAAkF;AAClF,MAAM,iBAAiB,GAAgC,IAAI,GAAG,CAAC;IAC7D,SAAS;IACT,aAAa;IACb,UAAU;IACV,cAAc;CACf,CAAC,CAAC;AAEH,iEAAiE;AACjE,MAAM,eAAe,GAAgC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAA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vB,UAAU,EAAE,MAAM,CAAC,OAAO;wBAC1B,YAAY,EAAE,MAAM,CAAC,MAAM;wBAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM;wBACxC,QAAQ,EAAE,KAAK,CAAC,QAAQ;qBACzB,CAAC;iBACH,CAAC,CAAC;YACL,CAAC;SACF,EACD,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Team B commands — **service-account lifecycle** (AC 10).
3
+ *
4
+ * Five commands: create / scope / rotate-credential / revoke / set-expiry. Every
5
+ * one routes the §11.3 pipeline + audits. Accounts are least-privilege scoped +
6
+ * tenant-bound (invariant #4/#5). A NON-superuser creating/scoping an account is
7
+ * subject to the delegated-admin gate (it can't scope the account beyond the
8
+ * admin's OWN authority — enforced by the safeguard when the scope declares a
9
+ * discrete `(action, typeKey)` authority bound).
10
+ *
11
+ * ⛔ CREDENTIAL CRYPTO. The credential HASH is produced by the Auth layer's hasher
12
+ * port (never here), then persisted via {@link ServiceAccountStore.setCredentialHash}.
13
+ * `AdminCommandDeps` carries no hasher, so rotate takes an OPTIONAL injected
14
+ * {@link PasswordHasher}; when absent it stores a caller-provided pre-computed hash
15
+ * (the credential is minted/hashed by the adapter). This file NEVER logs/returns a
16
+ * secret or a hash.
17
+ *
18
+ * Revocation is IMMEDIATE (the store's revoke is idempotent).
19
+ *
20
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
21
+ */
22
+ import type { AuditSink } from '../../audit/index.js';
23
+ import type { DecisionAuthority } from '../../authorization/index.js';
24
+ import type { PasswordHasher } from '../../authentication/password-hasher.js';
25
+ import type { LabelResolver, ServiceAccountStore } from '../ports.js';
26
+ import type { AdminMutation, CommandResult, CreateServiceAccountInput, RotateServiceAccountCredentialInput, ScopeServiceAccountInput, ServiceAccount, SetServiceAccountExpiryInput } from '../types.js';
27
+ /** Deps the service-account commands close over. */
28
+ export interface ServiceAccountCommandDeps {
29
+ readonly serviceAccountStore: ServiceAccountStore;
30
+ readonly labels: LabelResolver;
31
+ readonly decide: DecisionAuthority;
32
+ readonly audit: AuditSink;
33
+ /** UTC clock (epoch ms). */
34
+ readonly now?: () => number;
35
+ /**
36
+ * Optional Auth-layer hasher for credential rotation. When present, rotate mints
37
+ * a random secret, hashes it, and persists the HASH; when absent, the caller
38
+ * supplies a pre-computed hash via the rotate input's `precomputedHash`.
39
+ */
40
+ readonly hasher?: PasswordHasher;
41
+ /** Injected random secret generator (deterministic in tests). */
42
+ readonly newSecret?: () => string;
43
+ }
44
+ /**
45
+ * A rotate input MAY carry a pre-computed hash when no hasher is injected. Extends
46
+ * the frozen {@link RotateServiceAccountCredentialInput} additively (the frozen
47
+ * type only names the target `id`).
48
+ */
49
+ export interface RotateInputWithHash extends RotateServiceAccountCredentialInput {
50
+ /** A pre-computed credential hash (used when no hasher dep is injected). */
51
+ readonly precomputedHash?: string;
52
+ }
53
+ export declare function makeCreateServiceAccount(deps: ServiceAccountCommandDeps): (mutation: AdminMutation, input: CreateServiceAccountInput) => Promise<CommandResult<ServiceAccount>>;
54
+ export declare function makeScopeServiceAccount(deps: ServiceAccountCommandDeps): (mutation: AdminMutation, input: ScopeServiceAccountInput) => Promise<CommandResult<void>>;
55
+ export declare function makeRotateServiceAccountCredential(deps: ServiceAccountCommandDeps): (mutation: AdminMutation, input: RotateInputWithHash) => Promise<CommandResult<void>>;
56
+ export declare function makeRevokeServiceAccount(deps: ServiceAccountCommandDeps): (mutation: AdminMutation, id: string) => Promise<CommandResult<void>>;
57
+ export declare function makeSetServiceAccountExpiry(deps: ServiceAccountCommandDeps): (mutation: AdminMutation, input: SetServiceAccountExpiryInput) => Promise<CommandResult<void>>;
58
+ //# sourceMappingURL=service-accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-accounts.d.ts","sourceRoot":"","sources":["../../../src/admin/command/service-acc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