@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
@@ -8,16 +8,15 @@
8
8
  * @module
9
9
  */
10
10
  import { z } from 'zod';
11
- import { create_session_and_set_cookie } from './session_lifecycle.js';
11
+ import { create_session_and_set_cookie } from './session_middleware.js';
12
12
  import { query_create_account_with_actor } from './account_queries.js';
13
- import { query_invite_find_unclaimed_match, query_invite_claim } from './invite_queries.js';
14
- import { Username, Email } from './account_schema.js';
13
+ import { query_invite_find_unclaimed_match, query_invite_claim_unscoped } from './invite_queries.js';
14
+ import { Username, Email } from '../primitive_schemas.js';
15
15
  import { Password } from './password.js';
16
16
  import { get_route_input } from '../http/route_spec.js';
17
17
  import { get_client_ip } from '../http/proxy.js';
18
18
  import { rate_limit_exceeded_response } from '../rate_limiter.js';
19
19
  import { ERROR_NO_MATCHING_INVITE, ERROR_SIGNUP_CONFLICT, ERROR_INVALID_JSON_BODY, ERROR_INVALID_REQUEST_BODY, } from '../http/error_schemas.js';
20
- import { audit_log_fire_and_forget } from './audit_log_queries.js';
21
20
  import { is_pg_unique_violation } from '../db/pg_error.js';
22
21
  // -- Input/output schemas ---------------------------------------------------
23
22
  /** Input for `POST /signup`. `email` is optional and must match any referenced invite. */
@@ -44,7 +43,7 @@ export const create_signup_route_specs = (deps, options) => {
44
43
  {
45
44
  method: 'POST',
46
45
  path: '/signup',
47
- auth: { type: 'none' },
46
+ auth: { account: 'none', actor: 'none' },
48
47
  description: 'Create account (invite-gated or open signup)',
49
48
  transaction: false, // manages its own transaction for TOCTOU safety
50
49
  input: SignupInput,
@@ -75,24 +74,41 @@ export const create_signup_route_specs = (deps, options) => {
75
74
  return rate_limit_exceeded_response(c, check.retry_after);
76
75
  }
77
76
  }
78
- // Check for matching invite (unless open signup is enabled)
77
+ // Check for matching invite (unless open signup is enabled).
78
+ // `transaction: false` makes `route.db` the pool, which is
79
+ // what the pre-tx invite lookup wants.
79
80
  let invite;
80
81
  if (!app_settings.open_signup) {
81
- invite = await query_invite_find_unclaimed_match({ db: route.background_db }, email ?? null, username);
82
- if (!invite) {
83
- if (ip_rate_limiter && ip)
84
- ip_rate_limiter.record(ip);
85
- if (signup_account_rate_limiter)
86
- signup_account_rate_limiter.record(account_key);
87
- return c.json({ error: ERROR_NO_MATCHING_INVITE }, 403);
88
- }
82
+ invite = await query_invite_find_unclaimed_match({ db: route.db }, email ?? null, username);
83
+ }
84
+ const emit_failure_audit = (reason) => {
85
+ deps.audit.emit(route, {
86
+ event_type: 'signup',
87
+ outcome: 'failure',
88
+ ip: get_client_ip(c),
89
+ metadata: {
90
+ username,
91
+ reason,
92
+ ...(invite && { invite_id: invite.id }),
93
+ ...(email != null && { email }),
94
+ ...(app_settings.open_signup && { open_signup: true }),
95
+ },
96
+ });
97
+ };
98
+ if (!app_settings.open_signup && !invite) {
99
+ if (ip_rate_limiter && ip)
100
+ ip_rate_limiter.record(ip);
101
+ if (signup_account_rate_limiter)
102
+ signup_account_rate_limiter.record(account_key);
103
+ emit_failure_audit('no_match');
104
+ return c.json({ error: ERROR_NO_MATCHING_INVITE }, 403);
89
105
  }
90
106
  // Create account, optionally claim invite, and create session atomically.
91
107
  // Username/email uniqueness enforced by DB unique constraints.
92
108
  const password_hash = await password.hash_password(pw);
93
109
  let result;
94
110
  try {
95
- result = await route.background_db.transaction(async (tx) => {
111
+ result = await route.db.transaction(async (tx) => {
96
112
  const tx_deps = { db: tx };
97
113
  const { account } = await query_create_account_with_actor(tx_deps, {
98
114
  username,
@@ -100,9 +116,20 @@ export const create_signup_route_specs = (deps, options) => {
100
116
  email,
101
117
  });
102
118
  if (invite) {
103
- const claimed = await query_invite_claim(tx_deps, invite.id, account.id);
119
+ const claimed = await query_invite_claim_unscoped(tx_deps, invite.id, account.id);
104
120
  if (!claimed) {
105
- // Race: invite was claimed between the find and this claim
121
+ // Race: invite was claimed between the find and this claim.
122
+ //
123
+ // SECURITY NOTE: this branch is largely shadowed by the account
124
+ // unique constraints. Because `query_invite_find_unclaimed_match`
125
+ // returns at most one invite for the (username, email) tuple, two
126
+ // concurrent signups satisfying the same find share the same
127
+ // username and/or email — and the case-insensitive partial uniques
128
+ // on `account.username` / `account.email` (`ACCOUNT_USERNAME_CI_INDEX`
129
+ // / `ACCOUNT_EMAIL_INDEX`) fire on the second `query_create_account_with_actor`
130
+ // before the claim runs. The audit emit is kept for defense-in-depth
131
+ // in case those constraints are loosened or the find query starts
132
+ // returning multiple invites for a single signup tuple.
106
133
  throw new SignupConflictError(ERROR_NO_MATCHING_INVITE);
107
134
  }
108
135
  }
@@ -122,6 +149,7 @@ export const create_signup_route_specs = (deps, options) => {
122
149
  ip_rate_limiter.record(ip);
123
150
  if (signup_account_rate_limiter)
124
151
  signup_account_rate_limiter.record(account_key);
152
+ emit_failure_audit('race_lost');
125
153
  return c.json({ error: e.error }, 403);
126
154
  }
127
155
  // Unique constraint violation: username or email already exists.
@@ -130,6 +158,7 @@ export const create_signup_route_specs = (deps, options) => {
130
158
  ip_rate_limiter.record(ip);
131
159
  if (signup_account_rate_limiter)
132
160
  signup_account_rate_limiter.record(account_key);
161
+ emit_failure_audit('signup_conflict');
133
162
  return c.json({ error: ERROR_SIGNUP_CONFLICT }, 409);
134
163
  }
135
164
  throw e;
@@ -139,12 +168,12 @@ export const create_signup_route_specs = (deps, options) => {
139
168
  ip_rate_limiter.reset(ip);
140
169
  if (signup_account_rate_limiter)
141
170
  signup_account_rate_limiter.reset(account_key);
142
- void audit_log_fire_and_forget(route, {
171
+ deps.audit.emit(route, {
143
172
  event_type: 'signup',
144
173
  account_id: result.id,
145
174
  ip: get_client_ip(c),
146
175
  metadata: invite ? { invite_id: invite.id, username } : { open_signup: true, username },
147
- }, deps);
176
+ });
148
177
  return c.json({ ok: true });
149
178
  },
150
179
  },
@@ -2,7 +2,7 @@
2
2
  * Aggregate spec list mirroring `create_standard_rpc_actions` on the backend.
3
3
  *
4
4
  * `create_standard_rpc_actions` (in `auth/standard_rpc_actions.ts`) bundles three
5
- * action registries into one mounted RPC surface: admin + permit_offer +
5
+ * action registries into one mounted RPC surface: admin + role_grant_offer +
6
6
  * account. Frontends mounting that surface need the matching spec list to
7
7
  * feed `create_rpc_client` so the typed Proxy knows about every standard
8
8
  * method.
@@ -22,7 +22,7 @@
22
22
  import type { RequestResponseActionSpec } from '../actions/action_spec.js';
23
23
  /**
24
24
  * Combined spec registry for the standard RPC surface (admin +
25
- * permit_offer + account). Symmetric with `create_standard_rpc_actions`.
25
+ * role_grant_offer + account). Symmetric with `create_standard_rpc_actions`.
26
26
  *
27
27
  * Spec count is the sum of the three sub-registries. Adding a method to
28
28
  * any sub-registry surfaces here automatically.
@@ -2,7 +2,7 @@
2
2
  * Aggregate spec list mirroring `create_standard_rpc_actions` on the backend.
3
3
  *
4
4
  * `create_standard_rpc_actions` (in `auth/standard_rpc_actions.ts`) bundles three
5
- * action registries into one mounted RPC surface: admin + permit_offer +
5
+ * action registries into one mounted RPC surface: admin + role_grant_offer +
6
6
  * account. Frontends mounting that surface need the matching spec list to
7
7
  * feed `create_rpc_client` so the typed Proxy knows about every standard
8
8
  * method.
@@ -20,17 +20,17 @@
20
20
  * @module
21
21
  */
22
22
  import { all_admin_action_specs } from './admin_action_specs.js';
23
- import { all_permit_offer_action_specs } from './permit_offer_action_specs.js';
23
+ import { all_role_grant_offer_action_specs } from './role_grant_offer_action_specs.js';
24
24
  import { all_account_action_specs } from './account_action_specs.js';
25
25
  /**
26
26
  * Combined spec registry for the standard RPC surface (admin +
27
- * permit_offer + account). Symmetric with `create_standard_rpc_actions`.
27
+ * role_grant_offer + account). Symmetric with `create_standard_rpc_actions`.
28
28
  *
29
29
  * Spec count is the sum of the three sub-registries. Adding a method to
30
30
  * any sub-registry surfaces here automatically.
31
31
  */
32
32
  export const all_standard_action_specs = [
33
33
  ...all_admin_action_specs,
34
- ...all_permit_offer_action_specs,
34
+ ...all_role_grant_offer_action_specs,
35
35
  ...all_account_action_specs,
36
36
  ];
@@ -1,16 +1,16 @@
1
1
  /**
2
- * Combined admin + permit-offer + account RPC actions for fuz_app consumers.
2
+ * Combined admin + role-grant-offer + account RPC actions for fuz_app consumers.
3
3
  *
4
4
  * The canonical "standard" RPC surface: every stock fuz_app RPC action a
5
5
  * typical web consumer wants on one endpoint. Consumers that want a
6
6
  * narrower surface drop down to the per-domain factories directly
7
- * (`create_admin_actions` / `create_permit_offer_actions` /
7
+ * (`create_admin_actions` / `create_role_grant_offer_actions` /
8
8
  * `create_account_actions`).
9
9
  *
10
- * Option routing: shared `roles` flows to both admin and permit-offer;
10
+ * Option routing: shared `roles` flows to both admin and role-grant-offer;
11
11
  * `app_settings` goes to admin only; `default_ttl_ms` and `authorize` go
12
- * to permit-offer only; `max_tokens` goes to account only;
13
- * `notification_sender` reaches permit-offer transparently (admin + account
12
+ * to role-grant-offer only; `max_tokens` goes to account only;
13
+ * `notification_sender` reaches role-grant-offer transparently (admin + account
14
14
  * ignore it).
15
15
  *
16
16
  * Paired with `create_admin_rpc_adapters` on the UI side.
@@ -18,39 +18,43 @@
18
18
  * @module
19
19
  */
20
20
  import { type AdminActionOptions } from './admin_actions.js';
21
- import { type PermitOfferActionDeps, type PermitOfferActionOptions } from './permit_offer_actions.js';
21
+ import { type RoleGrantOfferActionOptions } from './role_grant_offer_actions.js';
22
22
  import { type AccountActionOptions } from './account_actions.js';
23
+ import type { RouteFactoryDeps } from './deps.js';
24
+ import type { NotificationSender } from './role_grant_offer_notifications.js';
23
25
  import type { RpcAction } from '../actions/action_rpc.js';
24
26
  /**
25
27
  * Options for `create_standard_rpc_actions`.
26
28
  *
27
29
  * Composes `AdminActionOptions` (`roles`, `app_settings`),
28
- * `PermitOfferActionOptions` (`roles`, `default_ttl_ms`, `authorize`), and
30
+ * `RoleGrantOfferActionOptions` (`roles`, `default_ttl_ms`, `authorize`), and
29
31
  * `AccountActionOptions` (`max_tokens`). `roles` is shared between admin
30
- * and permit-offer — the caller supplies it once and the helper threads
32
+ * and role-grant-offer — the caller supplies it once and the helper threads
31
33
  * the same reference to both.
32
34
  */
33
- export interface StandardRpcActionsOptions extends AdminActionOptions, PermitOfferActionOptions, AccountActionOptions {
35
+ export interface StandardRpcActionsOptions extends AdminActionOptions, RoleGrantOfferActionOptions, AccountActionOptions {
34
36
  }
35
37
  /**
36
38
  * Dependencies for `create_standard_rpc_actions`.
37
39
  *
38
- * Same shape as `PermitOfferActionDeps` `log`, `on_audit_event`, and an
39
- * optional `notification_sender` for permit-offer WS fan-out. Admin and
40
- * account factories only read `log` + `on_audit_event`; the extra field
41
- * is harmless.
40
+ * Stack-standard `RouteFactoryDeps` slice (`log`, `audit`) plus an optional
41
+ * `notification_sender` consumed only by the role-grant-offer sub-factory
42
+ * for WS fan-out. Admin and account sub-factories ignore
43
+ * `notification_sender`.
42
44
  */
43
- export type StandardRpcActionsDeps = PermitOfferActionDeps;
45
+ export interface StandardRpcActionsDeps extends Pick<RouteFactoryDeps, 'log' | 'audit'> {
46
+ notification_sender?: NotificationSender | null;
47
+ }
44
48
  /**
45
- * Build the combined admin + permit-offer + account RPC action set.
49
+ * Build the combined admin + role-grant-offer + account RPC action set.
46
50
  *
47
51
  * Spreads `create_admin_actions(deps, {roles, app_settings})`,
48
- * `create_permit_offer_actions(deps, {roles, default_ttl_ms, authorize})`,
52
+ * `create_role_grant_offer_actions(deps, {roles, default_ttl_ms, authorize})`,
49
53
  * and `create_account_actions(deps, {max_tokens})`. The shared `roles`
50
- * option flows to admin + permit-offer.
54
+ * option flows to admin + role-grant-offer.
51
55
  *
52
- * @param deps - `StandardRpcActionsDeps` (`log`, `on_audit_event`, optional `audit_log_config` from `AppDeps`; optional `notification_sender` for WS fan-out)
53
- * @param options - role schema, optional app-settings ref, permit-offer config, account config
56
+ * @param deps - `StandardRpcActionsDeps` (`log`, `audit` from `RouteFactoryDeps`; optional `notification_sender` for WS fan-out)
57
+ * @param options - role schema, optional app-settings ref, role-grant-offer config, account config
54
58
  * @returns RPC actions to pass as `rpc_endpoints` or spread into `create_rpc_endpoint`
55
59
  */
56
60
  export declare const create_standard_rpc_actions: (deps: StandardRpcActionsDeps, options?: StandardRpcActionsOptions) => Array<RpcAction>;
@@ -1 +1 @@
1
- {"version":3,"file":"standard_rpc_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/standard_rpc_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAuB,KAAK,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAEN,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EA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rC,KAAK,CAAC,SAAS,CAIjB,CAAC"}
@@ -1,16 +1,16 @@
1
1
  /**
2
- * Combined admin + permit-offer + account RPC actions for fuz_app consumers.
2
+ * Combined admin + role-grant-offer + account RPC actions for fuz_app consumers.
3
3
  *
4
4
  * The canonical "standard" RPC surface: every stock fuz_app RPC action a
5
5
  * typical web consumer wants on one endpoint. Consumers that want a
6
6
  * narrower surface drop down to the per-domain factories directly
7
- * (`create_admin_actions` / `create_permit_offer_actions` /
7
+ * (`create_admin_actions` / `create_role_grant_offer_actions` /
8
8
  * `create_account_actions`).
9
9
  *
10
- * Option routing: shared `roles` flows to both admin and permit-offer;
10
+ * Option routing: shared `roles` flows to both admin and role-grant-offer;
11
11
  * `app_settings` goes to admin only; `default_ttl_ms` and `authorize` go
12
- * to permit-offer only; `max_tokens` goes to account only;
13
- * `notification_sender` reaches permit-offer transparently (admin + account
12
+ * to role-grant-offer only; `max_tokens` goes to account only;
13
+ * `notification_sender` reaches role-grant-offer transparently (admin + account
14
14
  * ignore it).
15
15
  *
16
16
  * Paired with `create_admin_rpc_adapters` on the UI side.
@@ -18,22 +18,22 @@
18
18
  * @module
19
19
  */
20
20
  import { create_admin_actions } from './admin_actions.js';
21
- import { create_permit_offer_actions, } from './permit_offer_actions.js';
21
+ import { create_role_grant_offer_actions, } from './role_grant_offer_actions.js';
22
22
  import { create_account_actions } from './account_actions.js';
23
23
  /**
24
- * Build the combined admin + permit-offer + account RPC action set.
24
+ * Build the combined admin + role-grant-offer + account RPC action set.
25
25
  *
26
26
  * Spreads `create_admin_actions(deps, {roles, app_settings})`,
27
- * `create_permit_offer_actions(deps, {roles, default_ttl_ms, authorize})`,
27
+ * `create_role_grant_offer_actions(deps, {roles, default_ttl_ms, authorize})`,
28
28
  * and `create_account_actions(deps, {max_tokens})`. The shared `roles`
29
- * option flows to admin + permit-offer.
29
+ * option flows to admin + role-grant-offer.
30
30
  *
31
- * @param deps - `StandardRpcActionsDeps` (`log`, `on_audit_event`, optional `audit_log_config` from `AppDeps`; optional `notification_sender` for WS fan-out)
32
- * @param options - role schema, optional app-settings ref, permit-offer config, account config
31
+ * @param deps - `StandardRpcActionsDeps` (`log`, `audit` from `RouteFactoryDeps`; optional `notification_sender` for WS fan-out)
32
+ * @param options - role schema, optional app-settings ref, role-grant-offer config, account config
33
33
  * @returns RPC actions to pass as `rpc_endpoints` or spread into `create_rpc_endpoint`
34
34
  */
35
35
  export const create_standard_rpc_actions = (deps, options = {}) => [
36
36
  ...create_admin_actions(deps, options),
37
- ...create_permit_offer_actions(deps, options),
37
+ ...create_role_grant_offer_actions(deps, options),
38
38
  ...create_account_actions(deps, options),
39
39
  ];
@@ -6,12 +6,15 @@
6
6
  * `(namespace, name, sequence, applied_at)` — and the runner verifies the
7
7
  * applied list is a name-prefix of the code's migration array at boot.
8
8
  *
9
- * **Append-only after first publish**: once a fuz_app version containing a
10
- * given migration is published (`npm publish` / `jsr publish`), that
11
- * migration's name and position are frozen. Never edit, rename, or reorder
12
- * after publish append only. Pre-publish, anything goes; the cliff is the
13
- * publish event. Edits to a published migration's body slip past the runner
14
- * (no content hashing) and are caught by schema-snapshot tests in consumers.
9
+ * **Schema is not stabilized yet append-only is NOT the rule.** While
10
+ * fuz_app is pre-stable, migration bodies, names, and positions can change
11
+ * freely between versions; consumers upgrading across a schema change are
12
+ * expected to drop and re-bootstrap their dev/test databases (production
13
+ * deployments are not yet a supported use case). Once the schema is
14
+ * declared stable a hard append-only-after-publish rule will apply and the
15
+ * cliff will be called out in that release's notes; until then, body edits
16
+ * to a published migration slip past the runner (no content hashing) by
17
+ * design — they're the recommended way to evolve the schema.
15
18
  *
16
19
  * **Chain-level transactions**: All pending migrations in a namespace run in
17
20
  * a single transaction. Any failure rolls back every migration in that run —
@@ -21,7 +24,7 @@
21
24
  * **Chain idempotency, not migration idempotency**: the chain-tx wraps every
22
25
  * migration replayed in a single boot, so an individual migration may
23
26
  * temporarily produce intermediate state that a later migration reverses
24
- * (e.g. v0's `PERMIT_INDEXES` recreates an index that v1 drops; chain-tx
27
+ * (e.g. v0's `ROLE_GRANT_INDEXES` recreates an index that v1 drops; chain-tx
25
28
  * hides this from observers). What matters is that the *committed end state*
26
29
  * matches; the in-tx steps may not be individually idempotent against an
27
30
  * arbitrary mid-chain target.
@@ -53,7 +56,8 @@ export interface Migration {
53
56
  /**
54
57
  * A named group of ordered migrations.
55
58
  *
56
- * Array index = position in the chain. Append-only after publish.
59
+ * Array index = position in the chain. Pre-stable: bodies, names, and
60
+ * positions can change between versions (consumers re-bootstrap on upgrade).
57
61
  */
58
62
  export interface MigrationNamespace {
59
63
  namespace: string;
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAC;AAEhC;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC7B;AAED,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAC3B,sBAAsB,GACtB,sBAAsB,GACtB,mBAAmB,GACnB,kBAAkB,GAClB,2BAA2B,GAC3B,4BAA4B,GAC5B,sCAAsC,CAAC;AAE1C,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IACrC,SAAS,CAAC,EAA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CG;AACH,eAAO,MAAM,QAAQ,GACpB,IAAI,EAAE,EACN,IAAI,kBAAkB,EACtB,OAAO,aAAa,CAAC,MAAM,CAAC,KAC1B,OAAO,CAAC,IAAI,CA+Dd,CAAC"}
@@ -6,12 +6,15 @@
6
6
  * `(namespace, name, sequence, applied_at)` — and the runner verifies the
7
7
  * applied list is a name-prefix of the code's migration array at boot.
8
8
  *
9
- * **Append-only after first publish**: once a fuz_app version containing a
10
- * given migration is published (`npm publish` / `jsr publish`), that
11
- * migration's name and position are frozen. Never edit, rename, or reorder
12
- * after publish append only. Pre-publish, anything goes; the cliff is the
13
- * publish event. Edits to a published migration's body slip past the runner
14
- * (no content hashing) and are caught by schema-snapshot tests in consumers.
9
+ * **Schema is not stabilized yet append-only is NOT the rule.** While
10
+ * fuz_app is pre-stable, migration bodies, names, and positions can change
11
+ * freely between versions; consumers upgrading across a schema change are
12
+ * expected to drop and re-bootstrap their dev/test databases (production
13
+ * deployments are not yet a supported use case). Once the schema is
14
+ * declared stable a hard append-only-after-publish rule will apply and the
15
+ * cliff will be called out in that release's notes; until then, body edits
16
+ * to a published migration slip past the runner (no content hashing) by
17
+ * design — they're the recommended way to evolve the schema.
15
18
  *
16
19
  * **Chain-level transactions**: All pending migrations in a namespace run in
17
20
  * a single transaction. Any failure rolls back every migration in that run —
@@ -21,7 +24,7 @@
21
24
  * **Chain idempotency, not migration idempotency**: the chain-tx wraps every
22
25
  * migration replayed in a single boot, so an individual migration may
23
26
  * temporarily produce intermediate state that a later migration reverses
24
- * (e.g. v0's `PERMIT_INDEXES` recreates an index that v1 drops; chain-tx
27
+ * (e.g. v0's `ROLE_GRANT_INDEXES` recreates an index that v1 drops; chain-tx
25
28
  * hides this from observers). What matters is that the *committed end state*
26
29
  * matches; the in-tx steps may not be individually idempotent against an
27
30
  * arbitrary mid-chain target.
@@ -173,7 +173,7 @@ export interface SeedDevAccountInput {
173
173
  username: string;
174
174
  /** Account password. Policy is bypassed — any non-empty string is accepted. */
175
175
  password: string;
176
- /** Roles to grant via permit (idempotent). */
176
+ /** Roles to grant via role_grant (idempotent). */
177
177
  roles?: ReadonlyArray<string>;
178
178
  }
179
179
  /** Result of `seed_dev_account`. */
@@ -197,7 +197,7 @@ export interface SeedDevAccountDeps extends QueryDeps {
197
197
  *
198
198
  * Intended for `scripts/dev_setup.ts` — do not call in production.
199
199
  *
200
- * @mutates database - inserts an account/actor pair when missing and grants any requested role permits
200
+ * @mutates database - inserts an account/actor pair when missing and grants any requested role role_grants
201
201
  * @throws Error if an existing account is found without an associated actor row
202
202
  */
203
203
  export declare const seed_dev_account: (deps: SeedDevAccountDeps, input: SeedDevAccountInput, options?: {
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/dev/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACX,WAAW,EACX,aAAa,EACb,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAQnD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,2CAA2C;AAC3C,eAAO,MAAM,oBAAoB,EAAE,WAIlC,CAAC;AAEF,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC9B,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,OAAO,EAAE,OAAO,CAAC;IACjB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,yCAAyC;AACzC,MAAM,WAAW,gBAAgB;IAChC,kEAAkE;IAClE,OAAO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W,mBAAmB;IACnC,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED,oCAAoC;AACpC,MAAM,WAAW,oBAAoB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACpD,oEAAoE;IACpE,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACrD;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAC5B,MAAM,kBAAkB,EACxB,OAAO,mBAAmB,EAC1B,UAAU;IAAC,GAAG,CAAC,EAAE,WAAW,CAAA;CAAC,KAC3B,OAAO,CAAC,oBAAoB,CAwC9B,CAAC"}
package/dist/dev/setup.js CHANGED
@@ -8,8 +8,8 @@
8
8
  *
9
9
  * @module
10
10
  */
11
- import { query_account_by_username, query_actor_by_account, query_create_account_with_actor, } from '../auth/account_queries.js';
12
- import { query_grant_permit } from '../auth/permit_queries.js';
11
+ import { query_account_by_username, query_actors_by_account, query_create_account_with_actor, } from '../auth/account_queries.js';
12
+ import { query_create_role_grant } from '../auth/role_grant_queries.js';
13
13
  /** Default logger using bracket format. */
14
14
  export const default_setup_logger = {
15
15
  ok: (msg) => console.log(` [ok] ${msg}`),
@@ -284,7 +284,7 @@ export const reset_database = async (deps, database_url, options) => {
284
284
  *
285
285
  * Intended for `scripts/dev_setup.ts` — do not call in production.
286
286
  *
287
- * @mutates database - inserts an account/actor pair when missing and grants any requested role permits
287
+ * @mutates database - inserts an account/actor pair when missing and grants any requested role role_grants
288
288
  * @throws Error if an existing account is found without an associated actor row
289
289
  */
290
290
  export const seed_dev_account = async (deps, input, options) => {
@@ -292,13 +292,15 @@ export const seed_dev_account = async (deps, input, options) => {
292
292
  const query_deps = { db: deps.db };
293
293
  const existing = await query_account_by_username(query_deps, input.username);
294
294
  if (existing) {
295
- const actor = await query_actor_by_account(query_deps, existing.id);
296
- if (!actor) {
295
+ const actors = await query_actors_by_account(query_deps, existing.id);
296
+ if (actors.length === 0) {
297
297
  log.error(`dev account '${input.username}' exists but has no actor`);
298
298
  throw new Error(`dev account '${input.username}' has no actor`);
299
299
  }
300
+ // Dev seed is single-actor by construction; pick the first.
301
+ const actor = actors[0];
300
302
  for (const role of input.roles ?? []) {
301
- await query_grant_permit(query_deps, {
303
+ await query_create_role_grant(query_deps, {
302
304
  actor_id: actor.id,
303
305
  role,
304
306
  granted_by: null,
@@ -314,7 +316,7 @@ export const seed_dev_account = async (deps, input, options) => {
314
316
  password_hash,
315
317
  });
316
318
  for (const role of input.roles ?? []) {
317
- await query_grant_permit(query_deps, {
319
+ await query_create_role_grant(query_deps, {
318
320
  actor_id: actor.id,
319
321
  role,
320
322
  granted_by: null,
@@ -35,7 +35,7 @@ export declare class EnvValidationError extends Error {
35
35
  * `error.all_undefined` before calling this.
36
36
  *
37
37
  * @param error - the env validation error
38
- * @param label - optional prefix for log lines (e.g., 'tx daemon', 'env')
38
+ * @param label - optional prefix for log lines (e.g., 'zap daemon', 'env')
39
39
  */
40
40
  export declare const log_env_validation_error: (error: EnvValidationError, label?: string) => void;
41
41
  /**
package/dist/env/load.js CHANGED
@@ -42,7 +42,7 @@ export class EnvValidationError extends Error {
42
42
  * `error.all_undefined` before calling this.
43
43
  *
44
44
  * @param error - the env validation error
45
- * @param label - optional prefix for log lines (e.g., 'tx daemon', 'env')
45
+ * @param label - optional prefix for log lines (e.g., 'zap daemon', 'env')
46
46
  */
47
47
  export const log_env_validation_error = (error, label) => {
48
48
  const prefix = label ? `[${label}] ` : '';
@@ -12,19 +12,50 @@
12
12
  */
13
13
  import { z } from 'zod';
14
14
  import type { RequestContext } from './auth/request_context.js';
15
- /** The credential types that can authenticate a request. */
15
+ /**
16
+ * The credential types that can authenticate a request — the closed set
17
+ * of fuz_app builtins. The open registry on top
18
+ * (`create_credential_type_schema(consumer_types)`) is consulted at
19
+ * registry time by `create_role_schema` for `RoleSpec.required_credential_types`
20
+ * validation; the wire-validated `CredentialType` enum here stays
21
+ * narrow because middleware only ever sets one of the three builtins.
22
+ */
16
23
  export declare const CREDENTIAL_TYPES: readonly ["session", "api_token", "daemon_token"];
17
24
  /** Credential type — how a request was authenticated. */
18
25
  export declare const CredentialType: z.ZodEnum<{
26
+ daemon_token: "daemon_token";
19
27
  session: "session";
20
28
  api_token: "api_token";
21
- daemon_token: "daemon_token";
22
29
  }>;
23
30
  export type CredentialType = z.infer<typeof CredentialType>;
24
31
  /** Hono context variable name for the credential type. */
25
32
  export declare const CREDENTIAL_TYPE_KEY = "credential_type";
26
33
  /** Hono context variable name for the authenticated API token id. */
27
34
  export declare const AUTH_API_TOKEN_ID_KEY = "auth_api_token_id";
35
+ /**
36
+ * Hono context variable name for the authenticated account id.
37
+ *
38
+ * Set by the auth middleware (session, bearer, or daemon token) on a valid
39
+ * credential. `null` for unauthenticated requests. The route-spec wrapper /
40
+ * RPC dispatcher's authorization phase reads this when resolving the acting
41
+ * actor; account-grain auth guards (`require_auth`) and account-grain handlers
42
+ * read it directly.
43
+ */
44
+ export declare const ACCOUNT_ID_KEY = "auth_account_id";
45
+ /**
46
+ * Hono context variable name for the test-harness pre-baked context flag.
47
+ *
48
+ * Test harnesses (`create_test_app_from_specs`, `create_fake_hono_context`,
49
+ * the WS round-trip `connect()` helper, plus per-test middleware that
50
+ * pre-populates `REQUEST_CONTEXT_KEY`) set this to `true` so
51
+ * `apply_authorization_phase` skips its DB-backed actor resolution and
52
+ * trusts the supplied `RequestContext`. Production middleware never sets
53
+ * this key — only test code does. The flag is the explicit escape hatch
54
+ * that replaced the implicit "is `REQUEST_CONTEXT_KEY` already set?" probe,
55
+ * so that future production code consulting `REQUEST_CONTEXT_KEY` cannot
56
+ * silently bypass the live build.
57
+ */
58
+ export declare const TEST_CONTEXT_PRESET_KEY = "test_context_preset";
28
59
  declare module 'hono' {
29
60
  interface ContextVariableMap {
30
61
  /** Resolved client IP, set by the trusted proxy middleware. */
@@ -36,6 +67,13 @@ declare module 'hono' {
36
67
  validated_query: unknown;
37
68
  /** How the request was authenticated (`'session'`, `'api_token'`, or `'daemon_token'`). */
38
69
  credential_type: CredentialType | null;
70
+ /**
71
+ * Authenticated account id. Set by the session / bearer / daemon-token
72
+ * middleware on a valid credential; `null` for unauthenticated requests.
73
+ * The dispatcher's authorization phase resolves the acting actor against
74
+ * this id; `require_auth` 401s when it is `null`.
75
+ */
76
+ auth_account_id: string | null;
39
77
  /**
40
78
  * blake3 hash of the authenticated session token, or `null` for non-session
41
79
  * credentials. Set by `create_request_context_middleware`. Used to scope
@@ -52,11 +90,32 @@ declare module 'hono' {
52
90
  */
53
91
  auth_api_token_id: string | null;
54
92
  /**
55
- * Pending fire-and-forget effects for this request (audit logs, usage tracking, etc.).
56
- * Initialized by `create_app_server`. In test mode (`await_pending_effects: true`),
57
- * all effects are awaited before the response returns.
93
+ * Eager fire-and-forget pool writes for this request audit emits,
94
+ * session-touch UPDATE, api-token usage tracking. Producers push the
95
+ * in-flight `Promise<void>` directly. The flush middleware drains via
96
+ * `flush_pending_effects` after the handler returns. Initialized by
97
+ * `create_app_server`. In test mode (`await_pending_effects: true`),
98
+ * every promise resolves before the response returns.
58
99
  */
59
100
  pending_effects: Array<Promise<void>>;
101
+ /**
102
+ * Post-commit thunks pushed via `emit_after_commit(ctx, fn)`. The
103
+ * flush middleware invokes each thunk after the handler returns —
104
+ * never inline — so notifications (WS sends, etc.) cannot fire
105
+ * mid-transaction. Producers do not push raw thunks directly. The
106
+ * flush owns per-thunk `try/catch` + `log.error` so a directly-pushed
107
+ * thunk (tests included) cannot escape the safety net.
108
+ * Initialized by `create_app_server`. In test mode
109
+ * (`await_pending_effects: true`), every thunk completes before the
110
+ * response returns.
111
+ */
112
+ post_commit_effects: Array<() => void | Promise<void>>;
113
+ /**
114
+ * Set to `true` by test harnesses that pre-populate `request_context`
115
+ * to bypass the dispatcher's DB-backed actor resolution. Read by
116
+ * `apply_authorization_phase`. Production middleware never sets this.
117
+ */
118
+ test_context_preset: boolean;
60
119
  }
61
120
  }
62
121
  //# sourceMappingURL=hono_context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hono_context.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAE9D,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,mDAAoD,CAAC;AAElF,yDAAyD;AACzD,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,OAAO,QAAQ,MAAM,CAAC;IACrB,UAAU,kBAAkB;QAC3B,+DAA+D;QAC/D,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;QACvC,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,OAAO,CAAC;QACzB,2FAA2F;QAC3F,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;QACvC;;;;;WAKG;QACH,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;QACvC;;;;;;WAMG;QACH,iBAAiB,EAA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