@fuzdev/fuz_app 0.54.0 → 0.56.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 (348) hide show
  1. package/dist/actions/CLAUDE.md +214 -103
  2. package/dist/actions/action_bridge.d.ts +8 -5
  3. package/dist/actions/action_bridge.d.ts.map +1 -1
  4. package/dist/actions/action_bridge.js +1 -11
  5. package/dist/actions/action_codegen.d.ts +32 -0
  6. package/dist/actions/action_codegen.d.ts.map +1 -1
  7. package/dist/actions/action_codegen.js +35 -15
  8. package/dist/actions/action_registry.d.ts.map +1 -1
  9. package/dist/actions/action_registry.js +5 -2
  10. package/dist/actions/action_rpc.d.ts +141 -22
  11. package/dist/actions/action_rpc.d.ts.map +1 -1
  12. package/dist/actions/action_rpc.js +106 -187
  13. package/dist/actions/action_spec.d.ts +55 -16
  14. package/dist/actions/action_spec.d.ts.map +1 -1
  15. package/dist/actions/action_spec.js +16 -11
  16. package/dist/actions/action_types.d.ts +28 -60
  17. package/dist/actions/action_types.d.ts.map +1 -1
  18. package/dist/actions/action_types.js +13 -5
  19. package/dist/actions/broadcast_api.d.ts +2 -2
  20. package/dist/actions/broadcast_api.js +2 -2
  21. package/dist/actions/compile_action_registry.d.ts +50 -0
  22. package/dist/actions/compile_action_registry.d.ts.map +1 -0
  23. package/dist/actions/compile_action_registry.js +69 -0
  24. package/dist/actions/heartbeat.d.ts +8 -4
  25. package/dist/actions/heartbeat.d.ts.map +1 -1
  26. package/dist/actions/heartbeat.js +5 -4
  27. package/dist/actions/perform_action.d.ts +145 -0
  28. package/dist/actions/perform_action.d.ts.map +1 -0
  29. package/dist/actions/perform_action.js +258 -0
  30. package/dist/actions/register_action_ws.d.ts +46 -40
  31. package/dist/actions/register_action_ws.d.ts.map +1 -1
  32. package/dist/actions/register_action_ws.js +101 -159
  33. package/dist/actions/register_ws_endpoint.d.ts +15 -10
  34. package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
  35. package/dist/actions/register_ws_endpoint.js +54 -7
  36. package/dist/actions/transports.d.ts.map +1 -1
  37. package/dist/actions/transports.js +0 -4
  38. package/dist/actions/transports_ws_auth_guard.d.ts +1 -1
  39. package/dist/actions/transports_ws_auth_guard.js +1 -1
  40. package/dist/actions/transports_ws_backend.d.ts +1 -1
  41. package/dist/actions/transports_ws_backend.js +1 -1
  42. package/dist/auth/CLAUDE.md +794 -410
  43. package/dist/auth/account_action_specs.d.ts +28 -7
  44. package/dist/auth/account_action_specs.d.ts.map +1 -1
  45. package/dist/auth/account_action_specs.js +7 -7
  46. package/dist/auth/account_actions.d.ts +7 -13
  47. package/dist/auth/account_actions.d.ts.map +1 -1
  48. package/dist/auth/account_actions.js +26 -35
  49. package/dist/auth/account_queries.d.ts +52 -16
  50. package/dist/auth/account_queries.d.ts.map +1 -1
  51. package/dist/auth/account_queries.js +87 -38
  52. package/dist/auth/account_routes.d.ts +9 -11
  53. package/dist/auth/account_routes.d.ts.map +1 -1
  54. package/dist/auth/account_routes.js +118 -46
  55. package/dist/auth/account_schema.d.ts +46 -35
  56. package/dist/auth/account_schema.d.ts.map +1 -1
  57. package/dist/auth/account_schema.js +21 -28
  58. package/dist/auth/admin_action_specs.d.ts +100 -32
  59. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  60. package/dist/auth/admin_action_specs.js +64 -33
  61. package/dist/auth/admin_actions.d.ts +13 -19
  62. package/dist/auth/admin_actions.d.ts.map +1 -1
  63. package/dist/auth/admin_actions.js +37 -41
  64. package/dist/auth/audit_emitter.d.ts +160 -0
  65. package/dist/auth/audit_emitter.d.ts.map +1 -0
  66. package/dist/auth/audit_emitter.js +83 -0
  67. package/dist/auth/audit_log_queries.d.ts +17 -48
  68. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  69. package/dist/auth/audit_log_queries.js +20 -56
  70. package/dist/auth/audit_log_routes.d.ts +1 -1
  71. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  72. package/dist/auth/audit_log_routes.js +7 -3
  73. package/dist/auth/audit_log_schema.d.ts +92 -32
  74. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  75. package/dist/auth/audit_log_schema.js +75 -46
  76. package/dist/auth/auth_guard_resolver.d.ts +44 -0
  77. package/dist/auth/auth_guard_resolver.d.ts.map +1 -0
  78. package/dist/auth/auth_guard_resolver.js +56 -0
  79. package/dist/auth/bearer_auth.d.ts +9 -7
  80. package/dist/auth/bearer_auth.d.ts.map +1 -1
  81. package/dist/auth/bearer_auth.js +13 -21
  82. package/dist/auth/bootstrap_account.d.ts +7 -7
  83. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  84. package/dist/auth/bootstrap_account.js +7 -7
  85. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  86. package/dist/auth/bootstrap_routes.js +11 -10
  87. package/dist/auth/cleanup.d.ts +20 -26
  88. package/dist/auth/cleanup.d.ts.map +1 -1
  89. package/dist/auth/cleanup.js +33 -42
  90. package/dist/auth/credential_type_schema.d.ts +115 -0
  91. package/dist/auth/credential_type_schema.d.ts.map +1 -0
  92. package/dist/auth/credential_type_schema.js +127 -0
  93. package/dist/auth/daemon_token_middleware.d.ts +23 -11
  94. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  95. package/dist/auth/daemon_token_middleware.js +28 -22
  96. package/dist/auth/ddl.d.ts +2 -2
  97. package/dist/auth/ddl.d.ts.map +1 -1
  98. package/dist/auth/ddl.js +6 -6
  99. package/dist/auth/deps.d.ts +7 -18
  100. package/dist/auth/deps.d.ts.map +1 -1
  101. package/dist/auth/grant_path_schema.d.ts +117 -0
  102. package/dist/auth/grant_path_schema.d.ts.map +1 -0
  103. package/dist/auth/grant_path_schema.js +137 -0
  104. package/dist/auth/invite_queries.d.ts +12 -1
  105. package/dist/auth/invite_queries.d.ts.map +1 -1
  106. package/dist/auth/invite_queries.js +12 -1
  107. package/dist/auth/invite_schema.d.ts +1 -1
  108. package/dist/auth/invite_schema.d.ts.map +1 -1
  109. package/dist/auth/invite_schema.js +1 -1
  110. package/dist/auth/middleware.d.ts.map +1 -1
  111. package/dist/auth/middleware.js +9 -4
  112. package/dist/auth/migrations.d.ts +37 -14
  113. package/dist/auth/migrations.d.ts.map +1 -1
  114. package/dist/auth/migrations.js +79 -32
  115. package/dist/auth/request_context.d.ts +331 -61
  116. package/dist/auth/request_context.d.ts.map +1 -1
  117. package/dist/auth/request_context.js +378 -95
  118. package/dist/auth/{permit_offer_action_specs.d.ts → role_grant_offer_action_specs.d.ts} +163 -94
  119. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -0
  120. package/dist/auth/role_grant_offer_action_specs.js +262 -0
  121. package/dist/auth/role_grant_offer_actions.d.ts +104 -0
  122. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -0
  123. package/dist/auth/role_grant_offer_actions.js +473 -0
  124. package/dist/auth/{permit_offer_notifications.d.ts → role_grant_offer_notifications.d.ts} +90 -70
  125. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -0
  126. package/dist/auth/role_grant_offer_notifications.js +182 -0
  127. package/dist/auth/role_grant_offer_queries.d.ts +242 -0
  128. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -0
  129. package/dist/auth/role_grant_offer_queries.js +533 -0
  130. package/dist/auth/role_grant_offer_schema.d.ts +150 -0
  131. package/dist/auth/role_grant_offer_schema.d.ts.map +1 -0
  132. package/dist/auth/{permit_offer_schema.js → role_grant_offer_schema.js} +60 -36
  133. package/dist/auth/role_grant_queries.d.ts +231 -0
  134. package/dist/auth/role_grant_queries.d.ts.map +1 -0
  135. package/dist/auth/role_grant_queries.js +320 -0
  136. package/dist/auth/role_schema.d.ts +150 -40
  137. package/dist/auth/role_schema.d.ts.map +1 -1
  138. package/dist/auth/role_schema.js +144 -45
  139. package/dist/auth/scope_kind_schema.d.ts +96 -0
  140. package/dist/auth/scope_kind_schema.d.ts.map +1 -0
  141. package/dist/auth/scope_kind_schema.js +94 -0
  142. package/dist/auth/self_service_role_action_specs.d.ts +6 -1
  143. package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
  144. package/dist/auth/self_service_role_action_specs.js +3 -1
  145. package/dist/auth/self_service_role_actions.d.ts +34 -27
  146. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  147. package/dist/auth/self_service_role_actions.js +68 -48
  148. package/dist/auth/session_cookie.d.ts +43 -6
  149. package/dist/auth/session_cookie.d.ts.map +1 -1
  150. package/dist/auth/session_cookie.js +31 -5
  151. package/dist/auth/session_middleware.d.ts +37 -3
  152. package/dist/auth/session_middleware.d.ts.map +1 -1
  153. package/dist/auth/session_middleware.js +33 -7
  154. package/dist/auth/signup_routes.d.ts.map +1 -1
  155. package/dist/auth/signup_routes.js +48 -19
  156. package/dist/auth/standard_action_specs.d.ts +2 -2
  157. package/dist/auth/standard_action_specs.js +4 -4
  158. package/dist/auth/standard_rpc_actions.d.ts +23 -19
  159. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  160. package/dist/auth/standard_rpc_actions.js +12 -12
  161. package/dist/db/migrate.d.ts +12 -8
  162. package/dist/db/migrate.d.ts.map +1 -1
  163. package/dist/db/migrate.js +10 -7
  164. package/dist/dev/setup.d.ts +2 -2
  165. package/dist/dev/setup.d.ts.map +1 -1
  166. package/dist/dev/setup.js +9 -7
  167. package/dist/env/load.d.ts +1 -1
  168. package/dist/env/load.js +1 -1
  169. package/dist/hono_context.d.ts +64 -5
  170. package/dist/hono_context.d.ts.map +1 -1
  171. package/dist/hono_context.js +38 -2
  172. package/dist/http/CLAUDE.md +264 -87
  173. package/dist/http/auth_shape.d.ts +191 -0
  174. package/dist/http/auth_shape.d.ts.map +1 -0
  175. package/dist/http/auth_shape.js +237 -0
  176. package/dist/http/common_routes.js +3 -3
  177. package/dist/http/db_routes.d.ts +4 -0
  178. package/dist/http/db_routes.d.ts.map +1 -1
  179. package/dist/http/db_routes.js +44 -7
  180. package/dist/http/error_schemas.d.ts +132 -19
  181. package/dist/http/error_schemas.d.ts.map +1 -1
  182. package/dist/http/error_schemas.js +132 -40
  183. package/dist/http/jsonrpc_errors.d.ts +27 -2
  184. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  185. package/dist/http/jsonrpc_errors.js +26 -2
  186. package/dist/http/pending_effects.d.ts +71 -18
  187. package/dist/http/pending_effects.d.ts.map +1 -1
  188. package/dist/http/pending_effects.js +87 -18
  189. package/dist/http/proxy.d.ts +52 -5
  190. package/dist/http/proxy.d.ts.map +1 -1
  191. package/dist/http/proxy.js +92 -14
  192. package/dist/http/route_spec.d.ts +113 -41
  193. package/dist/http/route_spec.d.ts.map +1 -1
  194. package/dist/http/route_spec.js +130 -52
  195. package/dist/http/schema_helpers.d.ts +3 -2
  196. package/dist/http/schema_helpers.d.ts.map +1 -1
  197. package/dist/http/schema_helpers.js +9 -2
  198. package/dist/http/surface.d.ts +2 -1
  199. package/dist/http/surface.d.ts.map +1 -1
  200. package/dist/http/surface.js +1 -2
  201. package/dist/http/surface_query.d.ts +39 -35
  202. package/dist/http/surface_query.d.ts.map +1 -1
  203. package/dist/http/surface_query.js +79 -36
  204. package/dist/primitive_schemas.d.ts +39 -0
  205. package/dist/primitive_schemas.d.ts.map +1 -0
  206. package/dist/primitive_schemas.js +40 -0
  207. package/dist/realtime/sse_auth_guard.d.ts +5 -5
  208. package/dist/realtime/sse_auth_guard.js +9 -9
  209. package/dist/runtime/mock.d.ts +1 -1
  210. package/dist/runtime/mock.js +1 -1
  211. package/dist/server/app_backend.d.ts +14 -11
  212. package/dist/server/app_backend.d.ts.map +1 -1
  213. package/dist/server/app_backend.js +12 -8
  214. package/dist/server/app_server.d.ts +7 -7
  215. package/dist/server/app_server.d.ts.map +1 -1
  216. package/dist/server/app_server.js +36 -31
  217. package/dist/server/validate_nginx.d.ts +1 -1
  218. package/dist/server/validate_nginx.js +1 -1
  219. package/dist/testing/CLAUDE.md +73 -55
  220. package/dist/testing/admin_integration.d.ts +5 -6
  221. package/dist/testing/admin_integration.d.ts.map +1 -1
  222. package/dist/testing/admin_integration.js +100 -96
  223. package/dist/testing/adversarial_headers.js +1 -1
  224. package/dist/testing/app_server.d.ts +11 -14
  225. package/dist/testing/app_server.d.ts.map +1 -1
  226. package/dist/testing/app_server.js +18 -17
  227. package/dist/testing/assertions.d.ts.map +1 -1
  228. package/dist/testing/assertions.js +2 -1
  229. package/dist/testing/attack_surface.d.ts.map +1 -1
  230. package/dist/testing/attack_surface.js +15 -9
  231. package/dist/testing/audit_completeness.d.ts +2 -2
  232. package/dist/testing/audit_completeness.d.ts.map +1 -1
  233. package/dist/testing/audit_completeness.js +53 -39
  234. package/dist/testing/auth_apps.d.ts +5 -4
  235. package/dist/testing/auth_apps.d.ts.map +1 -1
  236. package/dist/testing/auth_apps.js +28 -22
  237. package/dist/testing/data_exposure.d.ts.map +1 -1
  238. package/dist/testing/data_exposure.js +5 -5
  239. package/dist/testing/db.d.ts +1 -1
  240. package/dist/testing/db.d.ts.map +1 -1
  241. package/dist/testing/db.js +4 -4
  242. package/dist/testing/db_entities.d.ts +22 -0
  243. package/dist/testing/db_entities.d.ts.map +1 -0
  244. package/dist/testing/db_entities.js +28 -0
  245. package/dist/testing/entities.d.ts +10 -8
  246. package/dist/testing/entities.d.ts.map +1 -1
  247. package/dist/testing/entities.js +22 -18
  248. package/dist/testing/integration.d.ts.map +1 -1
  249. package/dist/testing/integration.js +13 -14
  250. package/dist/testing/integration_helpers.d.ts +8 -6
  251. package/dist/testing/integration_helpers.d.ts.map +1 -1
  252. package/dist/testing/integration_helpers.js +29 -23
  253. package/dist/testing/middleware.d.ts +15 -11
  254. package/dist/testing/middleware.d.ts.map +1 -1
  255. package/dist/testing/middleware.js +75 -32
  256. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  257. package/dist/testing/rpc_attack_surface.js +40 -24
  258. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  259. package/dist/testing/rpc_helpers.js +3 -1
  260. package/dist/testing/rpc_round_trip.d.ts +1 -1
  261. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  262. package/dist/testing/rpc_round_trip.js +14 -13
  263. package/dist/testing/sse_round_trip.d.ts +3 -4
  264. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  265. package/dist/testing/sse_round_trip.js +7 -11
  266. package/dist/testing/standard.d.ts +1 -1
  267. package/dist/testing/stubs.d.ts +25 -0
  268. package/dist/testing/stubs.d.ts.map +1 -1
  269. package/dist/testing/stubs.js +43 -2
  270. package/dist/testing/surface_invariants.d.ts +2 -2
  271. package/dist/testing/ws_round_trip.d.ts +12 -13
  272. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  273. package/dist/testing/ws_round_trip.js +24 -12
  274. package/dist/ui/AdminAccounts.svelte +23 -20
  275. package/dist/ui/AdminOverview.svelte +15 -13
  276. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  277. package/dist/ui/{AdminPermitHistory.svelte → AdminRoleGrantHistory.svelte} +12 -12
  278. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts +4 -0
  279. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -0
  280. package/dist/ui/BootstrapForm.svelte +1 -1
  281. package/dist/ui/CLAUDE.md +65 -59
  282. package/dist/ui/{PermitOfferForm.svelte → RoleGrantOfferForm.svelte} +37 -22
  283. package/dist/ui/RoleGrantOfferForm.svelte.d.ts +20 -0
  284. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -0
  285. package/dist/ui/{PermitOfferHistory.svelte → RoleGrantOfferHistory.svelte} +12 -12
  286. package/dist/ui/{PermitOfferHistory.svelte.d.ts → RoleGrantOfferHistory.svelte.d.ts} +4 -4
  287. package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -0
  288. package/dist/ui/{PermitOfferInbox.svelte → RoleGrantOfferInbox.svelte} +14 -14
  289. package/dist/ui/{PermitOfferInbox.svelte.d.ts → RoleGrantOfferInbox.svelte.d.ts} +4 -4
  290. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -0
  291. package/dist/ui/SignupForm.svelte +1 -1
  292. package/dist/ui/SurfaceExplorer.svelte +35 -15
  293. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  294. package/dist/ui/account_sessions_state.svelte.d.ts +2 -3
  295. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  296. package/dist/ui/account_sessions_state.svelte.js +2 -3
  297. package/dist/ui/admin_accounts_state.svelte.d.ts +25 -18
  298. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  299. package/dist/ui/admin_accounts_state.svelte.js +28 -17
  300. package/dist/ui/admin_rpc_adapters.d.ts +20 -20
  301. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  302. package/dist/ui/admin_rpc_adapters.js +17 -17
  303. package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
  304. package/dist/ui/admin_sessions_state.svelte.js +2 -2
  305. package/dist/ui/audit_log_state.svelte.d.ts +7 -7
  306. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  307. package/dist/ui/audit_log_state.svelte.js +6 -6
  308. package/dist/ui/auth_state.svelte.d.ts +3 -3
  309. package/dist/ui/auth_state.svelte.d.ts.map +1 -1
  310. package/dist/ui/auth_state.svelte.js +6 -6
  311. package/dist/ui/format_scope.d.ts +2 -2
  312. package/dist/ui/format_scope.js +2 -2
  313. package/dist/ui/{permit_offers_state.svelte.d.ts → role_grant_offers_state.svelte.d.ts} +39 -31
  314. package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -0
  315. package/dist/ui/{permit_offers_state.svelte.js → role_grant_offers_state.svelte.js} +25 -19
  316. package/dist/ui/ui_format.js +2 -2
  317. package/package.json +3 -3
  318. package/dist/auth/permit_offer_action_specs.d.ts.map +0 -1
  319. package/dist/auth/permit_offer_action_specs.js +0 -227
  320. package/dist/auth/permit_offer_actions.d.ts +0 -110
  321. package/dist/auth/permit_offer_actions.d.ts.map +0 -1
  322. package/dist/auth/permit_offer_actions.js +0 -452
  323. package/dist/auth/permit_offer_notifications.d.ts.map +0 -1
  324. package/dist/auth/permit_offer_notifications.js +0 -182
  325. package/dist/auth/permit_offer_queries.d.ts +0 -183
  326. package/dist/auth/permit_offer_queries.d.ts.map +0 -1
  327. package/dist/auth/permit_offer_queries.js +0 -408
  328. package/dist/auth/permit_offer_schema.d.ts +0 -103
  329. package/dist/auth/permit_offer_schema.d.ts.map +0 -1
  330. package/dist/auth/permit_queries.d.ts +0 -210
  331. package/dist/auth/permit_queries.d.ts.map +0 -1
  332. package/dist/auth/permit_queries.js +0 -294
  333. package/dist/auth/require_keeper.d.ts +0 -20
  334. package/dist/auth/require_keeper.d.ts.map +0 -1
  335. package/dist/auth/require_keeper.js +0 -35
  336. package/dist/auth/route_guards.d.ts +0 -21
  337. package/dist/auth/route_guards.d.ts.map +0 -1
  338. package/dist/auth/route_guards.js +0 -32
  339. package/dist/auth/session_lifecycle.d.ts +0 -37
  340. package/dist/auth/session_lifecycle.d.ts.map +0 -1
  341. package/dist/auth/session_lifecycle.js +0 -29
  342. package/dist/ui/AdminPermitHistory.svelte.d.ts +0 -4
  343. package/dist/ui/AdminPermitHistory.svelte.d.ts.map +0 -1
  344. package/dist/ui/PermitOfferForm.svelte.d.ts +0 -14
  345. package/dist/ui/PermitOfferForm.svelte.d.ts.map +0 -1
  346. package/dist/ui/PermitOfferHistory.svelte.d.ts.map +0 -1
  347. package/dist/ui/PermitOfferInbox.svelte.d.ts.map +0 -1
  348. package/dist/ui/permit_offers_state.svelte.d.ts.map +0 -1
@@ -14,12 +14,12 @@ import { Uuid } from '@fuzdev/fuz_util/id.js';
14
14
  * Not a security boundary — in-process code has many other paths to subvert
15
15
  * audit logging.
16
16
  */
17
- export declare const AUDIT_EVENT_TYPES: readonly ["login", "logout", "bootstrap", "signup", "password_change", "session_revoke", "session_revoke_all", "token_create", "token_revoke", "token_revoke_all", "permit_grant", "permit_revoke", "permit_offer_create", "permit_offer_accept", "permit_offer_decline", "permit_offer_retract", "permit_offer_expire", "permit_offer_supersede", "invite_create", "invite_delete", "app_settings_update"];
17
+ export declare const AUDIT_EVENT_TYPES: readonly ["login", "logout", "bootstrap", "signup", "password_change", "session_revoke", "session_revoke_all", "token_create", "token_revoke", "token_revoke_all", "role_grant_create", "role_grant_revoke", "role_grant_offer_create", "role_grant_offer_accept", "role_grant_offer_decline", "role_grant_offer_retract", "role_grant_offer_expire", "role_grant_offer_supersede", "invite_create", "invite_delete", "app_settings_update"];
18
18
  /** Zod schema for audit event types. */
19
19
  export declare const AuditEventType: z.ZodEnum<{
20
+ bootstrap: "bootstrap";
20
21
  login: "login";
21
22
  logout: "logout";
22
- bootstrap: "bootstrap";
23
23
  signup: "signup";
24
24
  password_change: "password_change";
25
25
  session_revoke: "session_revoke";
@@ -27,14 +27,14 @@ export declare const AuditEventType: z.ZodEnum<{
27
27
  token_create: "token_create";
28
28
  token_revoke: "token_revoke";
29
29
  token_revoke_all: "token_revoke_all";
30
- permit_grant: "permit_grant";
31
- permit_revoke: "permit_revoke";
32
- permit_offer_create: "permit_offer_create";
33
- permit_offer_accept: "permit_offer_accept";
34
- permit_offer_decline: "permit_offer_decline";
35
- permit_offer_retract: "permit_offer_retract";
36
- permit_offer_expire: "permit_offer_expire";
37
- permit_offer_supersede: "permit_offer_supersede";
30
+ role_grant_create: "role_grant_create";
31
+ role_grant_revoke: "role_grant_revoke";
32
+ role_grant_offer_create: "role_grant_offer_create";
33
+ role_grant_offer_accept: "role_grant_offer_accept";
34
+ role_grant_offer_decline: "role_grant_offer_decline";
35
+ role_grant_offer_retract: "role_grant_offer_retract";
36
+ role_grant_offer_expire: "role_grant_offer_expire";
37
+ role_grant_offer_supersede: "role_grant_offer_supersede";
38
38
  invite_create: "invite_create";
39
39
  invite_delete: "invite_delete";
40
40
  app_settings_update: "app_settings_update";
@@ -74,9 +74,15 @@ export declare const AUDIT_METADATA_SCHEMAS: Readonly<{
74
74
  username: z.ZodString;
75
75
  invite_id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
76
76
  open_signup: z.ZodOptional<z.ZodBoolean>;
77
+ reason: z.ZodOptional<z.ZodString>;
78
+ email: z.ZodOptional<z.ZodEmail>;
77
79
  }, z.core.$loose>;
78
80
  password_change: z.ZodNullable<z.ZodObject<{
79
- sessions_revoked: z.ZodNumber;
81
+ sessions_revoked: z.ZodOptional<z.ZodNumber>;
82
+ tokens_revoked: z.ZodOptional<z.ZodNumber>;
83
+ reason: z.ZodOptional<z.ZodEnum<{
84
+ concurrent_change: "concurrent_change";
85
+ }>>;
80
86
  }, z.core.$loose>>;
81
87
  session_revoke: z.ZodObject<{
82
88
  session_id: z.ZodString;
@@ -98,55 +104,55 @@ export declare const AUDIT_METADATA_SCHEMAS: Readonly<{
98
104
  reason: z.ZodOptional<z.ZodString>;
99
105
  attempted_account_id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
100
106
  }, z.core.$loose>;
101
- permit_grant: z.ZodObject<{
107
+ role_grant_create: z.ZodObject<{
102
108
  role: z.ZodString;
103
- permit_id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
109
+ role_grant_id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
104
110
  scope_id: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>>;
105
111
  source_offer_id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
106
112
  self_service: z.ZodOptional<z.ZodBoolean>;
107
113
  }, z.core.$loose>;
108
- permit_revoke: z.ZodObject<{
114
+ role_grant_revoke: z.ZodObject<{
109
115
  role: z.ZodString;
110
- permit_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
116
+ role_grant_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
111
117
  scope_id: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>>;
112
118
  reason: z.ZodOptional<z.ZodString>;
113
119
  self_service: z.ZodOptional<z.ZodBoolean>;
114
120
  }, z.core.$loose>;
115
- permit_offer_create: z.ZodObject<{
121
+ role_grant_offer_create: z.ZodObject<{
116
122
  offer_id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
117
123
  role: z.ZodString;
118
124
  scope_id: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>>;
119
125
  to_account_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
120
126
  }, z.core.$loose>;
121
- permit_offer_accept: z.ZodObject<{
127
+ role_grant_offer_accept: z.ZodObject<{
122
128
  offer_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
123
- permit_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
129
+ role_grant_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
124
130
  role: z.ZodString;
125
131
  scope_id: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>>;
126
132
  }, z.core.$loose>;
127
- permit_offer_decline: z.ZodObject<{
133
+ role_grant_offer_decline: z.ZodObject<{
128
134
  offer_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
129
135
  role: z.ZodString;
130
136
  scope_id: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>>;
131
137
  reason: z.ZodOptional<z.ZodString>;
132
138
  }, z.core.$loose>;
133
- permit_offer_retract: z.ZodObject<{
139
+ role_grant_offer_retract: z.ZodObject<{
134
140
  offer_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
135
141
  role: z.ZodString;
136
142
  scope_id: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>>;
137
143
  }, z.core.$loose>;
138
- permit_offer_expire: z.ZodObject<{
144
+ role_grant_offer_expire: z.ZodObject<{
139
145
  offer_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
140
146
  role: z.ZodString;
141
147
  scope_id: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>>;
142
148
  }, z.core.$loose>;
143
- permit_offer_supersede: z.ZodObject<{
149
+ role_grant_offer_supersede: z.ZodObject<{
144
150
  offer_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
145
151
  role: z.ZodString;
146
152
  scope_id: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>>;
147
153
  reason: z.ZodEnum<{
148
154
  sibling_accepted: "sibling_accepted";
149
- permit_revoked: "permit_revoked";
155
+ role_grant_revoked: "role_grant_revoked";
150
156
  scope_destroyed: "scope_destroyed";
151
157
  }>;
152
158
  cause_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
@@ -175,9 +181,59 @@ export interface AuditLogEvent {
175
181
  seq: number;
176
182
  event_type: AuditEventTypeName;
177
183
  outcome: AuditOutcome;
184
+ /**
185
+ * Operator (the actor that initiated the event) — populated when the
186
+ * request resolved an acting actor.
187
+ *
188
+ * Resolution is driven per-request by the route-spec wrapper / RPC
189
+ * dispatcher; a route gets an acting actor when its input schema
190
+ * declares `acting?: ActingActor` or its auth requires role_grants
191
+ * (`role` / `keeper`). Account-grain operations declare neither,
192
+ * so no actor is resolved and `actor_id` is null: login (also
193
+ * pre-credential), logout, signup, bootstrap, password_change,
194
+ * session/token revoke, app_settings_update, invite events.
195
+ * Role grant events, admin actions, and actor-targeted offers
196
+ * populate this with the initiator's actor.
197
+ */
178
198
  actor_id: Uuid | null;
179
199
  account_id: Uuid | null;
180
200
  target_account_id: Uuid | null;
201
+ /**
202
+ * Actor-grain target — populated when the event subject is bound to
203
+ * a specific actor.
204
+ *
205
+ * Concretely:
206
+ * - Always populated: `role_grant_revoke` and `role_grant_create`
207
+ * (admin direct-grant, self-service toggle, and in-tx
208
+ * `role_grant_offer_accept` all populate both target columns — the
209
+ * role_grant's grantee is the actor-grain subject regardless of who
210
+ * initiated the grant), `role_grant_offer_accept` on accept (the
211
+ * accept binds the actor deterministically), `role_grant_offer_decline`
212
+ * (the grantor actor — decline is *to* the offering actor).
213
+ * - Conditionally populated: offer-shape events
214
+ * (`role_grant_offer_create`, `_expire`, `_retract`, `_supersede`)
215
+ * carry the actor when the offer was actor-targeted at create time
216
+ * (`role_grant_offer.to_actor_id` set), null when the offer was
217
+ * account-grain (any actor on `to_account_id` may accept).
218
+ * - Not populated: admin actions, account-shape events (login,
219
+ * logout, signup, bootstrap, password_change, session/token
220
+ * revoke, app_settings_update, invite events) — subject is the
221
+ * account or no specific resource, not an actor-bound role_grant.
222
+ * - Not populated: events whose principal isn't an actor-bound
223
+ * resource (e.g. consumer events that name a non-actor scope in
224
+ * metadata).
225
+ *
226
+ * Multi-actor invariants this column relies on: when both
227
+ * `target_actor_id` and `target_account_id` are populated they refer
228
+ * to the same account (`actor.account_id`-derivable). The invariant
229
+ * holds uniformly across every populated event including decline
230
+ * (the grantor's account is joined into the decline RETURNING) and
231
+ * the supersede cascade (the recipient account is known on
232
+ * `role_grant_offer.to_account_id`). `target_account_id` stays the
233
+ * SSE/WS socket-close key because sessions remain account-grain
234
+ * after multi-actor lands.
235
+ */
236
+ target_actor_id: Uuid | null;
181
237
  ip: string | null;
182
238
  created_at: string;
183
239
  metadata: Record<string, unknown> | null;
@@ -197,6 +253,7 @@ export interface AuditLogInput<T extends string = AuditEventType> {
197
253
  actor_id?: Uuid | null;
198
254
  account_id?: Uuid | null;
199
255
  target_account_id?: Uuid | null;
256
+ target_actor_id?: Uuid | null;
200
257
  ip?: string | null;
201
258
  /**
202
259
  * Per-event-type metadata. Builtin `T` narrows to `AuditMetadataMap[T]`;
@@ -210,8 +267,8 @@ export interface AuditLogInput<T extends string = AuditEventType> {
210
267
  *
211
268
  * Lets consumers extend the closed `AUDIT_EVENT_TYPES` enum with their own
212
269
  * event strings (and metadata Zod schemas) without forking. Pass to
213
- * `audit_log_fire_and_forget` / `query_audit_log` as the optional `config`
214
- * argument; both default to `BUILTIN_AUDIT_LOG_CONFIG`.
270
+ * `create_audit_emitter` (or `query_audit_log` for in-tx call sites) as the
271
+ * optional `config` argument; both default to `BUILTIN_AUDIT_LOG_CONFIG`.
215
272
  *
216
273
  * The DB column is `TEXT NOT NULL` and never enforced an enum, so consumer
217
274
  * event types round-trip through `query_audit_log_list` and SSE identically
@@ -252,9 +309,9 @@ export interface CreateAuditLogConfigOptions {
252
309
  * Throws when an `extra_events` key collides with a builtin event type, or
253
310
  * fails `AuditEventTypeName` format validation.
254
311
  *
255
- * Call once at startup; pass the result to consumer-emitted
256
- * `audit_log_fire_and_forget` calls. Builtin handlers omit the argument and
257
- * pick up `BUILTIN_AUDIT_LOG_CONFIG`.
312
+ * Call once at startup; pass the result to `create_app_backend` (which
313
+ * threads it into `AppDeps.audit`). Builtin handlers omit the
314
+ * `audit_log_config` slot and pick up `BUILTIN_AUDIT_LOG_CONFIG`.
258
315
  *
259
316
  * @throws Error when an `extra_events` key collides with a builtin event type or fails `AuditEventTypeName` format validation
260
317
  */
@@ -298,6 +355,7 @@ export declare const AuditLogEventJson: z.ZodObject<{
298
355
  actor_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
299
356
  account_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
300
357
  target_account_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
358
+ target_actor_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
301
359
  ip: z.ZodNullable<z.ZodString>;
302
360
  created_at: z.ZodString;
303
361
  metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -315,6 +373,7 @@ export declare const AuditLogEventWithUsernamesJson: z.ZodObject<{
315
373
  actor_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
316
374
  account_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
317
375
  target_account_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
376
+ target_actor_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
318
377
  ip: z.ZodNullable<z.ZodString>;
319
378
  created_at: z.ZodString;
320
379
  metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -322,8 +381,8 @@ export declare const AuditLogEventWithUsernamesJson: z.ZodObject<{
322
381
  target_username: z.ZodNullable<z.ZodString>;
323
382
  }, z.core.$strict>;
324
383
  export type AuditLogEventWithUsernamesJson = z.infer<typeof AuditLogEventWithUsernamesJson>;
325
- /** Zod schema for permit history events with resolved usernames. */
326
- export declare const PermitHistoryEventJson: z.ZodObject<{
384
+ /** Zod schema for role_grant history events with resolved usernames. */
385
+ export declare const RoleGrantHistoryEventJson: z.ZodObject<{
327
386
  id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
328
387
  seq: z.ZodNumber;
329
388
  event_type: z.ZodString;
@@ -334,13 +393,14 @@ export declare const PermitHistoryEventJson: z.ZodObject<{
334
393
  actor_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
335
394
  account_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
336
395
  target_account_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
396
+ target_actor_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
337
397
  ip: z.ZodNullable<z.ZodString>;
338
398
  created_at: z.ZodString;
339
399
  metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
340
400
  username: z.ZodNullable<z.ZodString>;
341
401
  target_username: z.ZodNullable<z.ZodString>;
342
402
  }, z.core.$strict>;
343
- export type PermitHistoryEventJson = z.infer<typeof PermitHistoryEventJson>;
403
+ export type RoleGrantHistoryEventJson = z.infer<typeof RoleGrantHistoryEventJson>;
344
404
  /** Zod schema for admin session listing (session + username). */
345
405
  export declare const AdminSessionJson: z.ZodObject<{
346
406
  id: z.ZodString;
@@ -351,6 +411,6 @@ export declare const AdminSessionJson: z.ZodObject<{
351
411
  username: z.ZodString;
352
412
  }, z.core.$strict>;
353
413
  export type AdminSessionJson = z.infer<typeof AdminSessionJson>;
354
- export declare const AUDIT_LOG_SCHEMA = "\nCREATE TABLE IF NOT EXISTS audit_log (\n id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n seq SERIAL NOT NULL,\n event_type TEXT NOT NULL,\n outcome TEXT NOT NULL DEFAULT 'success',\n actor_id UUID REFERENCES actor(id) ON DELETE SET NULL,\n account_id UUID REFERENCES account(id) ON DELETE SET NULL,\n target_account_id UUID REFERENCES account(id) ON DELETE SET NULL,\n ip TEXT,\n created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),\n metadata JSONB\n)";
414
+ export declare const AUDIT_LOG_SCHEMA = "\nCREATE TABLE IF NOT EXISTS audit_log (\n id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n seq SERIAL NOT NULL,\n event_type TEXT NOT NULL,\n outcome TEXT NOT NULL DEFAULT 'success',\n actor_id UUID REFERENCES actor(id) ON DELETE SET NULL,\n account_id UUID REFERENCES account(id) ON DELETE SET NULL,\n target_account_id UUID REFERENCES account(id) ON DELETE SET NULL,\n target_actor_id UUID REFERENCES actor(id) ON DELETE SET NULL,\n ip TEXT,\n created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),\n metadata JSONB\n)";
355
415
  export declare const AUDIT_LOG_INDEXES: string[];
356
416
  //# sourceMappingURL=audit_log_schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"audit_log_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,IAAI,EAAC,MAAM,wBA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;AAC/D,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;kBAGzC,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAE5F,wEAAwE;AACxE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;kBAGpC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,iEAAiE;AACjE,eAAO,MAAM,gBAAgB;;;;;;;kBAE3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAehE,eAAO,MAAM,gBAAgB,ihBAa3B,CAAC;AAEH,eAAO,MAAM,iBAAiB,UAM7B,CAAC"}
@@ -8,7 +8,10 @@
8
8
  */
9
9
  import { z } from 'zod';
10
10
  import { Uuid } from '@fuzdev/fuz_util/id.js';
11
+ import { Blake3Hash } from '@fuzdev/fuz_util/hash_blake3.js';
11
12
  import { AuthSessionJson } from './account_schema.js';
13
+ import { Email } from '../primitive_schemas.js';
14
+ import { ApiTokenId } from './api_token.js';
12
15
  /**
13
16
  * All tracked auth event types. Frozen to convert accidental in-process
14
17
  * mutation (test cross-contamination, cast escapes) into loud TypeErrors.
@@ -26,14 +29,14 @@ export const AUDIT_EVENT_TYPES = Object.freeze([
26
29
  'token_create',
27
30
  'token_revoke',
28
31
  'token_revoke_all',
29
- 'permit_grant',
30
- 'permit_revoke',
31
- 'permit_offer_create',
32
- 'permit_offer_accept',
33
- 'permit_offer_decline',
34
- 'permit_offer_retract',
35
- 'permit_offer_expire',
36
- 'permit_offer_supersede',
32
+ 'role_grant_create',
33
+ 'role_grant_revoke',
34
+ 'role_grant_offer_create',
35
+ 'role_grant_offer_accept',
36
+ 'role_grant_offer_decline',
37
+ 'role_grant_offer_retract',
38
+ 'role_grant_offer_expire',
39
+ 'role_grant_offer_supersede',
37
40
  'invite_create',
38
41
  'invite_delete',
39
42
  'app_settings_update',
@@ -72,23 +75,35 @@ export const AUDIT_METADATA_SCHEMAS = Object.freeze({
72
75
  })
73
76
  .nullable(),
74
77
  signup: z.looseObject({
75
- username: z.string().meta({ description: 'Username chosen at signup.' }),
78
+ username: z.string().meta({ description: 'Username submitted at signup.' }),
76
79
  invite_id: Uuid.optional().meta({
77
- description: 'Invite consumed by this signup, when one was matched.',
80
+ description: 'Invite consumed by this signup. Set on success and on `race_lost` / `signup_conflict` failure rows when an invite was matched at attempt time.',
78
81
  }),
79
82
  open_signup: z.boolean().optional().meta({
80
- description: 'True when the signup occurred via the `open_signup` setting (no invite required).',
83
+ description: 'True when the signup occurred via the `open_signup` setting (no invite required). Set on success rows under `open_signup` and on failure rows when the attempt was made under `open_signup`.',
84
+ }),
85
+ reason: z.string().optional().meta({
86
+ description: 'Failure category: `no_match` (no unclaimed invite matched), `race_lost` (invite was claimed between find and claim), `signup_conflict` (username/email already exists). Set only on `outcome=failure`.',
87
+ }),
88
+ email: Email.optional().meta({
89
+ description: 'Email submitted at signup — recorded on failure rows for forensic correlation. Omitted on success rows because the email is already tied to the resulting account.',
81
90
  }),
82
91
  }),
83
92
  password_change: z
84
93
  .looseObject({
85
- sessions_revoked: z
86
- .number()
87
- .meta({ description: 'Number of sessions revoked as a side effect of the password change.' }),
94
+ sessions_revoked: z.number().optional().meta({
95
+ description: 'Number of sessions revoked as a side effect of the password change. Present on `outcome=success`.',
96
+ }),
97
+ tokens_revoked: z.number().optional().meta({
98
+ description: 'Number of API tokens revoked as a side effect of the password change. Present on `outcome=success`.',
99
+ }),
100
+ reason: z.enum(['concurrent_change']).optional().meta({
101
+ description: 'Failure category. `concurrent_change` indicates another password change committed first against the same starting hash (verify-write race loser). Absent for typed-wrong-password failures.',
102
+ }),
88
103
  })
89
104
  .nullable(),
90
105
  session_revoke: z.looseObject({
91
- session_id: z.string().meta({ description: 'Blake3 hash identifying the revoked session row.' }),
106
+ session_id: Blake3Hash.meta({ description: 'Blake3 hash identifying the revoked session row.' }),
92
107
  }),
93
108
  session_revoke_all: z.looseObject({
94
109
  // Omitted on `outcome='failure'` (no revocation attempted — e.g. target
@@ -107,11 +122,11 @@ export const AUDIT_METADATA_SCHEMAS = Object.freeze({
107
122
  }),
108
123
  }),
109
124
  token_create: z.looseObject({
110
- token_id: z.string().meta({ description: 'Public id of the created API token (`tok_…`).' }),
125
+ token_id: ApiTokenId.meta({ description: 'Public id of the created API token (`tok_…`).' }),
111
126
  name: z.string().meta({ description: 'Operator-supplied label for the token.' }),
112
127
  }),
113
128
  token_revoke: z.looseObject({
114
- token_id: z.string().meta({ description: 'Public id of the revoked API token (`tok_…`).' }),
129
+ token_id: ApiTokenId.meta({ description: 'Public id of the revoked API token (`tok_…`).' }),
115
130
  }),
116
131
  token_revoke_all: z.looseObject({
117
132
  // Same shape as `session_revoke_all` for failures.
@@ -126,19 +141,19 @@ export const AUDIT_METADATA_SCHEMAS = Object.freeze({
126
141
  description: 'Probed account id when the target lookup missed (FK constraint forces `target_account_id` to null).',
127
142
  }),
128
143
  }),
129
- // `permit_id` is optional on `permit_grant` because failed grants
130
- // (e.g. `web_grantable` denied) never produce a permit row.
144
+ // `role_grant_id` is optional on `role_grant_create` because failed grants
145
+ // (e.g. admin-grant-path denied) never produce a role_grant row.
131
146
  // `self_service: true` is set by the self-service role toggle in
132
147
  // `self_service_role_actions.ts` — declared explicitly rather than
133
148
  // riding on `z.looseObject` permissiveness so the field is part of
134
149
  // the documented schema surface.
135
- permit_grant: z.looseObject({
150
+ role_grant_create: z.looseObject({
136
151
  role: z.string().meta({ description: 'Role being granted.' }),
137
- permit_id: Uuid.optional().meta({
138
- description: 'Id of the resulting permit row. Omitted when the grant failed (e.g. `web_grantable` denial).',
152
+ role_grant_id: Uuid.optional().meta({
153
+ description: 'Id of the resulting role_grant row. Omitted when the grant failed (e.g. admin-grant-path denial).',
139
154
  }),
140
155
  scope_id: Uuid.nullish().meta({
141
- description: 'Scope of the granted permit; null for global permits.',
156
+ description: 'Scope of the granted role_grant; null for global role_grants.',
142
157
  }),
143
158
  source_offer_id: Uuid.optional().meta({
144
159
  description: 'Offer this grant resolved, when the grant originated from an accepted offer.',
@@ -147,11 +162,11 @@ export const AUDIT_METADATA_SCHEMAS = Object.freeze({
147
162
  description: 'True when the grant came from the self-service role toggle.',
148
163
  }),
149
164
  }),
150
- permit_revoke: z.looseObject({
165
+ role_grant_revoke: z.looseObject({
151
166
  role: z.string().meta({ description: 'Role being revoked.' }),
152
- permit_id: Uuid.meta({ description: 'Id of the revoked permit row.' }),
167
+ role_grant_id: Uuid.meta({ description: 'Id of the revoked role_grant row.' }),
153
168
  scope_id: Uuid.nullish().meta({
154
- description: 'Scope of the revoked permit; null for global permits.',
169
+ description: 'Scope of the revoked role_grant; null for global role_grants.',
155
170
  }),
156
171
  reason: z
157
172
  .string()
@@ -161,9 +176,9 @@ export const AUDIT_METADATA_SCHEMAS = Object.freeze({
161
176
  description: 'True when the revoke came from the self-service role toggle.',
162
177
  }),
163
178
  }),
164
- // `offer_id` is optional because failed creates (e.g. `web_grantable`
179
+ // `offer_id` is optional because failed creates (e.g. admin-grant-path
165
180
  // denied, `authorize` callback denied) never produce an offer row.
166
- permit_offer_create: z.looseObject({
181
+ role_grant_offer_create: z.looseObject({
167
182
  offer_id: Uuid.optional().meta({
168
183
  description: 'Id of the created offer row. Omitted when the create failed before insert.',
169
184
  }),
@@ -173,17 +188,17 @@ export const AUDIT_METADATA_SCHEMAS = Object.freeze({
173
188
  }),
174
189
  to_account_id: Uuid.meta({ description: 'Account the offer is directed to.' }),
175
190
  }),
176
- // `permit_grant` is emitted alongside on accept — two events per accept by
177
- // design: offer-lifecycle audit + permit-lifecycle audit.
178
- permit_offer_accept: z.looseObject({
191
+ // `role_grant_create` is emitted alongside on accept — two events per accept by
192
+ // design: offer-lifecycle audit + role-grant-lifecycle audit.
193
+ role_grant_offer_accept: z.looseObject({
179
194
  offer_id: Uuid.meta({ description: 'Id of the accepted offer.' }),
180
- permit_id: Uuid.meta({ description: 'Id of the resulting permit row.' }),
195
+ role_grant_id: Uuid.meta({ description: 'Id of the resulting role_grant row.' }),
181
196
  role: z.string().meta({ description: 'Role granted by the offer.' }),
182
197
  scope_id: Uuid.nullish().meta({
183
- description: 'Scope of the resulting permit; null for global permits.',
198
+ description: 'Scope of the resulting role_grant; null for global role_grants.',
184
199
  }),
185
200
  }),
186
- permit_offer_decline: z.looseObject({
201
+ role_grant_offer_decline: z.looseObject({
187
202
  offer_id: Uuid.meta({ description: 'Id of the declined offer.' }),
188
203
  role: z.string().meta({ description: 'Role that was offered.' }),
189
204
  scope_id: Uuid.nullish().meta({
@@ -194,14 +209,14 @@ export const AUDIT_METADATA_SCHEMAS = Object.freeze({
194
209
  .optional()
195
210
  .meta({ description: 'Optional decline reason text from the recipient.' }),
196
211
  }),
197
- permit_offer_retract: z.looseObject({
212
+ role_grant_offer_retract: z.looseObject({
198
213
  offer_id: Uuid.meta({ description: 'Id of the retracted offer.' }),
199
214
  role: z.string().meta({ description: 'Role that was offered.' }),
200
215
  scope_id: Uuid.nullish().meta({
201
216
  description: 'Scope of the offered role; null for global offers.',
202
217
  }),
203
218
  }),
204
- permit_offer_expire: z.looseObject({
219
+ role_grant_offer_expire: z.looseObject({
205
220
  offer_id: Uuid.meta({ description: 'Id of the expired offer.' }),
206
221
  role: z.string().meta({ description: 'Role that was offered.' }),
207
222
  scope_id: Uuid.nullish().meta({
@@ -210,19 +225,19 @@ export const AUDIT_METADATA_SCHEMAS = Object.freeze({
210
225
  }),
211
226
  // Emitted when an offer is obsoleted by an external event. `reason`
212
227
  // distinguishes the trigger; `cause_id` points to the accepted offer
213
- // (for `sibling_accepted`), the revoked permit (for `permit_revoked`),
228
+ // (for `sibling_accepted`), the revoked role_grant (for `role_grant_revoked`),
214
229
  // or the destroyed parent scope row (for `scope_destroyed`).
215
- permit_offer_supersede: z.looseObject({
230
+ role_grant_offer_supersede: z.looseObject({
216
231
  offer_id: Uuid.meta({ description: 'Id of the superseded offer.' }),
217
232
  role: z.string().meta({ description: 'Role that was offered.' }),
218
233
  scope_id: Uuid.nullish().meta({
219
234
  description: 'Scope of the offered role; null for global offers.',
220
235
  }),
221
- reason: z.enum(['sibling_accepted', 'permit_revoked', 'scope_destroyed']).meta({
222
- description: 'Trigger that obsoleted the offer: a sibling offer was accepted, the resulting permit was revoked, or the parent scope row was destroyed.',
236
+ reason: z.enum(['sibling_accepted', 'role_grant_revoked', 'scope_destroyed']).meta({
237
+ description: 'Trigger that obsoleted the offer: a sibling offer was accepted, the resulting role_grant was revoked, or the parent scope row was destroyed.',
223
238
  }),
224
239
  cause_id: Uuid.meta({
225
- description: 'Row that caused the supersede: accepted offer (`sibling_accepted`), revoked permit (`permit_revoked`), or destroyed parent scope row (`scope_destroyed`).',
240
+ description: 'Row that caused the supersede: accepted offer (`sibling_accepted`), revoked role_grant (`role_grant_revoked`), or destroyed parent scope row (`scope_destroyed`).',
226
241
  }),
227
242
  }),
228
243
  invite_create: z.looseObject({
@@ -258,9 +273,9 @@ export const BUILTIN_AUDIT_LOG_CONFIG = Object.freeze({
258
273
  * Throws when an `extra_events` key collides with a builtin event type, or
259
274
  * fails `AuditEventTypeName` format validation.
260
275
  *
261
- * Call once at startup; pass the result to consumer-emitted
262
- * `audit_log_fire_and_forget` calls. Builtin handlers omit the argument and
263
- * pick up `BUILTIN_AUDIT_LOG_CONFIG`.
276
+ * Call once at startup; pass the result to `create_app_backend` (which
277
+ * threads it into `AppDeps.audit`). Builtin handlers omit the
278
+ * `audit_log_config` slot and pick up `BUILTIN_AUDIT_LOG_CONFIG`.
264
279
  *
265
280
  * @throws Error when an `extra_events` key collides with a builtin event type or fails `AuditEventTypeName` format validation
266
281
  */
@@ -311,6 +326,7 @@ export const AuditLogEventJson = z.strictObject({
311
326
  actor_id: Uuid.nullable(),
312
327
  account_id: Uuid.nullable(),
313
328
  target_account_id: Uuid.nullable(),
329
+ target_actor_id: Uuid.nullable(),
314
330
  ip: z.string().nullable(),
315
331
  created_at: z.string(),
316
332
  metadata: z.record(z.string(), z.unknown()).nullable(),
@@ -320,8 +336,8 @@ export const AuditLogEventWithUsernamesJson = AuditLogEventJson.extend({
320
336
  username: z.string().nullable(),
321
337
  target_username: z.string().nullable(),
322
338
  });
323
- /** Zod schema for permit history events with resolved usernames. */
324
- export const PermitHistoryEventJson = AuditLogEventJson.extend({
339
+ /** Zod schema for role_grant history events with resolved usernames. */
340
+ export const RoleGrantHistoryEventJson = AuditLogEventJson.extend({
325
341
  username: z.string().nullable(),
326
342
  target_username: z.string().nullable(),
327
343
  });
@@ -330,6 +346,17 @@ export const AdminSessionJson = AuthSessionJson.extend({
330
346
  username: z.string(),
331
347
  });
332
348
  // Schema DDL
349
+ //
350
+ // Multi-actor invariants the envelope columns assume:
351
+ // - `actor_id` + `account_id`, when both populated, refer to the same
352
+ // account (derivable via `actor.account_id`). Denormalized for
353
+ // indexed audit queries; do not let them disagree.
354
+ // - `target_actor_id` + `target_account_id`, same rule when both populated.
355
+ // - `target_account_id` is the SSE/WS socket-close key — sessions stay
356
+ // account-grain after multi-actor lands, so this column carries
357
+ // the routing identity even on actor-bound events.
358
+ // - `target_actor_id` is populated iff the event subject is actor-bound
359
+ // (see `AuditLogEvent.target_actor_id` doc-comment for the rule).
333
360
  export const AUDIT_LOG_SCHEMA = `
334
361
  CREATE TABLE IF NOT EXISTS audit_log (
335
362
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
@@ -339,6 +366,7 @@ CREATE TABLE IF NOT EXISTS audit_log (
339
366
  actor_id UUID REFERENCES actor(id) ON DELETE SET NULL,
340
367
  account_id UUID REFERENCES account(id) ON DELETE SET NULL,
341
368
  target_account_id UUID REFERENCES account(id) ON DELETE SET NULL,
369
+ target_actor_id UUID REFERENCES actor(id) ON DELETE SET NULL,
342
370
  ip TEXT,
343
371
  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
344
372
  metadata JSONB
@@ -348,4 +376,5 @@ export const AUDIT_LOG_INDEXES = [
348
376
  `CREATE INDEX IF NOT EXISTS idx_audit_log_account ON audit_log(account_id)`,
349
377
  `CREATE INDEX IF NOT EXISTS idx_audit_log_event_type ON audit_log(event_type)`,
350
378
  `CREATE INDEX IF NOT EXISTS idx_audit_log_target_account ON audit_log(target_account_id)`,
379
+ `CREATE INDEX IF NOT EXISTS idx_audit_log_target_actor ON audit_log(target_actor_id)`,
351
380
  ];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Auth guard resolver for the route spec system.
3
+ *
4
+ * Maps the four-axis `RouteAuth` (`account` / `actor` / `roles` /
5
+ * `credential_types`) to two-phase middleware sets that
6
+ * `apply_route_specs` weaves into the per-route pipeline:
7
+ *
8
+ * - `pre_validation` runs before input validation. `require_auth` lands
9
+ * here whenever `auth.account === 'required'` or `auth.actor ===
10
+ * 'required'` (per registry-time invariant 3, `actor: 'required'`
11
+ * today implies a credential — accountless actors are out of scope
12
+ * for v1). Pre-validation 401 fires before any body parsing so
13
+ * unauthenticated callers never see route-shape information from
14
+ * parse failures.
15
+ * - `post_authorization` runs after the dispatcher's authorization
16
+ * phase has populated `RequestContext`. `require_role(roles)` fires
17
+ * whenever `auth.roles?.length`. `require_credential_types(types)`
18
+ * fires whenever `auth.credential_types?.length`.
19
+ *
20
+ * Public routes (`auth.account === 'none' && auth.actor === 'none'`)
21
+ * yield empty guard arrays. `'optional'` axes contribute no
22
+ * pre-validation 401; the authorization phase sets `RequestContext`
23
+ * to whatever the credential supports and the post-authorization
24
+ * gates decide whether the actor's role_grants / credential type match.
25
+ *
26
+ * @module
27
+ */
28
+ import type { AuthGuardResolver } from '../http/route_spec.js';
29
+ /**
30
+ * Standard auth guard resolver for fuz_app.
31
+ *
32
+ * Reads each axis of the four-axis `RouteAuth` shape and emits the
33
+ * corresponding middleware:
34
+ *
35
+ * - `account === 'required'` or `actor === 'required'` → pre-validation `require_auth`
36
+ * - `roles?.length` → post-authorization `require_role(roles)` (multi-role any-of)
37
+ * - `credential_types?.length` → post-authorization `require_credential_types(types)`
38
+ *
39
+ * Multiple post-authorization guards run in declaration order: credential
40
+ * type check first (since failing it implies the request can never
41
+ * resolve a usable identity), role check second.
42
+ */
43
+ export declare const fuz_auth_guard_resolver: AuthGuardResolver;
44
+ //# sourceMappingURL=auth_guard_resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth_guard_resolver.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/auth_guard_resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAerC,CAAC"}