@fuzdev/fuz_app 0.55.0 → 0.57.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 (333) hide show
  1. package/dist/actions/CLAUDE.md +211 -155
  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 +19 -0
  6. package/dist/actions/action_codegen.d.ts.map +1 -1
  7. package/dist/actions/action_codegen.js +20 -14
  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 +110 -44
  11. package/dist/actions/action_rpc.d.ts.map +1 -1
  12. package/dist/actions/action_rpc.js +92 -287
  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 +44 -38
  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 +2 -10
  34. package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
  35. package/dist/actions/register_ws_endpoint.js +32 -10
  36. package/dist/actions/transports_ws_auth_guard.d.ts +1 -1
  37. package/dist/actions/transports_ws_auth_guard.js +1 -1
  38. package/dist/actions/transports_ws_backend.d.ts +1 -1
  39. package/dist/actions/transports_ws_backend.js +1 -1
  40. package/dist/auth/CLAUDE.md +673 -442
  41. package/dist/auth/account_action_specs.d.ts +28 -7
  42. package/dist/auth/account_action_specs.d.ts.map +1 -1
  43. package/dist/auth/account_action_specs.js +7 -7
  44. package/dist/auth/account_actions.d.ts +8 -14
  45. package/dist/auth/account_actions.d.ts.map +1 -1
  46. package/dist/auth/account_actions.js +26 -32
  47. package/dist/auth/account_queries.d.ts +46 -13
  48. package/dist/auth/account_queries.d.ts.map +1 -1
  49. package/dist/auth/account_queries.js +73 -33
  50. package/dist/auth/account_routes.d.ts +4 -3
  51. package/dist/auth/account_routes.d.ts.map +1 -1
  52. package/dist/auth/account_routes.js +58 -33
  53. package/dist/auth/account_schema.d.ts +46 -54
  54. package/dist/auth/account_schema.d.ts.map +1 -1
  55. package/dist/auth/account_schema.js +21 -48
  56. package/dist/auth/admin_action_specs.d.ts +55 -21
  57. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  58. package/dist/auth/admin_action_specs.js +42 -26
  59. package/dist/auth/admin_actions.d.ts +14 -21
  60. package/dist/auth/admin_actions.d.ts.map +1 -1
  61. package/dist/auth/admin_actions.js +47 -44
  62. package/dist/auth/audit_emitter.d.ts +160 -0
  63. package/dist/auth/audit_emitter.d.ts.map +1 -0
  64. package/dist/auth/audit_emitter.js +83 -0
  65. package/dist/auth/audit_log_queries.d.ts +17 -87
  66. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  67. package/dist/auth/audit_log_queries.js +17 -96
  68. package/dist/auth/audit_log_routes.d.ts +1 -1
  69. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  70. package/dist/auth/audit_log_routes.js +7 -3
  71. package/dist/auth/audit_log_schema.d.ts +48 -42
  72. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  73. package/dist/auth/audit_log_schema.js +56 -43
  74. package/dist/auth/auth_guard_resolver.d.ts +44 -0
  75. package/dist/auth/auth_guard_resolver.d.ts.map +1 -0
  76. package/dist/auth/auth_guard_resolver.js +56 -0
  77. package/dist/auth/bootstrap_account.d.ts +7 -7
  78. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  79. package/dist/auth/bootstrap_account.js +7 -7
  80. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  81. package/dist/auth/bootstrap_routes.js +11 -10
  82. package/dist/auth/cleanup.d.ts +20 -26
  83. package/dist/auth/cleanup.d.ts.map +1 -1
  84. package/dist/auth/cleanup.js +33 -47
  85. package/dist/auth/credential_type_schema.d.ts +115 -0
  86. package/dist/auth/credential_type_schema.d.ts.map +1 -0
  87. package/dist/auth/credential_type_schema.js +127 -0
  88. package/dist/auth/daemon_token_middleware.d.ts +1 -1
  89. package/dist/auth/daemon_token_middleware.js +3 -3
  90. package/dist/auth/ddl.d.ts +2 -2
  91. package/dist/auth/ddl.d.ts.map +1 -1
  92. package/dist/auth/ddl.js +6 -6
  93. package/dist/auth/deps.d.ts +7 -32
  94. package/dist/auth/deps.d.ts.map +1 -1
  95. package/dist/auth/grant_path_schema.d.ts +117 -0
  96. package/dist/auth/grant_path_schema.d.ts.map +1 -0
  97. package/dist/auth/grant_path_schema.js +137 -0
  98. package/dist/auth/invite_queries.d.ts +12 -1
  99. package/dist/auth/invite_queries.d.ts.map +1 -1
  100. package/dist/auth/invite_queries.js +12 -1
  101. package/dist/auth/invite_schema.d.ts +1 -1
  102. package/dist/auth/invite_schema.d.ts.map +1 -1
  103. package/dist/auth/invite_schema.js +1 -1
  104. package/dist/auth/middleware.d.ts.map +1 -1
  105. package/dist/auth/middleware.js +5 -2
  106. package/dist/auth/migrations.d.ts +22 -7
  107. package/dist/auth/migrations.d.ts.map +1 -1
  108. package/dist/auth/migrations.js +64 -25
  109. package/dist/auth/request_context.d.ts +157 -170
  110. package/dist/auth/request_context.d.ts.map +1 -1
  111. package/dist/auth/request_context.js +224 -268
  112. package/dist/auth/{permit_offer_action_specs.d.ts → role_grant_offer_action_specs.d.ts} +130 -100
  113. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -0
  114. package/dist/auth/role_grant_offer_action_specs.js +262 -0
  115. package/dist/auth/role_grant_offer_actions.d.ts +104 -0
  116. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -0
  117. package/dist/auth/{permit_offer_actions.js → role_grant_offer_actions.js} +153 -140
  118. package/dist/auth/{permit_offer_notifications.d.ts → role_grant_offer_notifications.d.ts} +80 -70
  119. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -0
  120. package/dist/auth/role_grant_offer_notifications.js +182 -0
  121. package/dist/auth/{permit_offer_queries.d.ts → role_grant_offer_queries.d.ts} +64 -64
  122. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -0
  123. package/dist/auth/{permit_offer_queries.js → role_grant_offer_queries.js} +136 -123
  124. package/dist/auth/role_grant_offer_schema.d.ts +150 -0
  125. package/dist/auth/role_grant_offer_schema.d.ts.map +1 -0
  126. package/dist/auth/{permit_offer_schema.js → role_grant_offer_schema.js} +55 -36
  127. package/dist/auth/role_grant_queries.d.ts +231 -0
  128. package/dist/auth/role_grant_queries.d.ts.map +1 -0
  129. package/dist/auth/role_grant_queries.js +320 -0
  130. package/dist/auth/role_schema.d.ts +150 -40
  131. package/dist/auth/role_schema.d.ts.map +1 -1
  132. package/dist/auth/role_schema.js +144 -45
  133. package/dist/auth/scope_kind_schema.d.ts +96 -0
  134. package/dist/auth/scope_kind_schema.d.ts.map +1 -0
  135. package/dist/auth/scope_kind_schema.js +94 -0
  136. package/dist/auth/self_service_role_action_specs.d.ts +4 -1
  137. package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
  138. package/dist/auth/self_service_role_action_specs.js +2 -2
  139. package/dist/auth/self_service_role_actions.d.ts +35 -29
  140. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  141. package/dist/auth/self_service_role_actions.js +58 -48
  142. package/dist/auth/session_cookie.d.ts +43 -6
  143. package/dist/auth/session_cookie.d.ts.map +1 -1
  144. package/dist/auth/session_cookie.js +31 -5
  145. package/dist/auth/session_middleware.d.ts +37 -3
  146. package/dist/auth/session_middleware.d.ts.map +1 -1
  147. package/dist/auth/session_middleware.js +33 -7
  148. package/dist/auth/signup_routes.d.ts.map +1 -1
  149. package/dist/auth/signup_routes.js +48 -19
  150. package/dist/auth/standard_action_specs.d.ts +2 -2
  151. package/dist/auth/standard_action_specs.js +4 -4
  152. package/dist/auth/standard_rpc_actions.d.ts +23 -19
  153. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  154. package/dist/auth/standard_rpc_actions.js +12 -12
  155. package/dist/db/migrate.d.ts +1 -1
  156. package/dist/db/migrate.js +1 -1
  157. package/dist/dev/setup.d.ts +2 -2
  158. package/dist/dev/setup.d.ts.map +1 -1
  159. package/dist/dev/setup.js +4 -4
  160. package/dist/env/load.d.ts +1 -1
  161. package/dist/env/load.js +1 -1
  162. package/dist/hono_context.d.ts +27 -45
  163. package/dist/hono_context.d.ts.map +1 -1
  164. package/dist/hono_context.js +14 -28
  165. package/dist/http/CLAUDE.md +235 -121
  166. package/dist/http/auth_shape.d.ts +191 -0
  167. package/dist/http/auth_shape.d.ts.map +1 -0
  168. package/dist/http/auth_shape.js +237 -0
  169. package/dist/http/common_routes.js +3 -3
  170. package/dist/http/db_routes.d.ts +4 -0
  171. package/dist/http/db_routes.d.ts.map +1 -1
  172. package/dist/http/db_routes.js +44 -7
  173. package/dist/http/error_schemas.d.ts +72 -39
  174. package/dist/http/error_schemas.d.ts.map +1 -1
  175. package/dist/http/error_schemas.js +81 -33
  176. package/dist/http/pending_effects.d.ts +71 -18
  177. package/dist/http/pending_effects.d.ts.map +1 -1
  178. package/dist/http/pending_effects.js +87 -18
  179. package/dist/http/proxy.d.ts +52 -5
  180. package/dist/http/proxy.d.ts.map +1 -1
  181. package/dist/http/proxy.js +92 -14
  182. package/dist/http/route_spec.d.ts +89 -75
  183. package/dist/http/route_spec.d.ts.map +1 -1
  184. package/dist/http/route_spec.js +54 -72
  185. package/dist/http/schema_helpers.d.ts +3 -14
  186. package/dist/http/schema_helpers.d.ts.map +1 -1
  187. package/dist/http/schema_helpers.js +2 -14
  188. package/dist/http/surface.d.ts +2 -10
  189. package/dist/http/surface.d.ts.map +1 -1
  190. package/dist/http/surface.js +3 -4
  191. package/dist/http/surface_query.d.ts +39 -35
  192. package/dist/http/surface_query.d.ts.map +1 -1
  193. package/dist/http/surface_query.js +79 -36
  194. package/dist/primitive_schemas.d.ts +39 -0
  195. package/dist/primitive_schemas.d.ts.map +1 -0
  196. package/dist/primitive_schemas.js +40 -0
  197. package/dist/realtime/sse_auth_guard.d.ts +5 -5
  198. package/dist/realtime/sse_auth_guard.js +9 -9
  199. package/dist/runtime/mock.d.ts +1 -1
  200. package/dist/runtime/mock.js +1 -1
  201. package/dist/server/app_backend.d.ts +14 -11
  202. package/dist/server/app_backend.d.ts.map +1 -1
  203. package/dist/server/app_backend.js +12 -8
  204. package/dist/server/app_server.d.ts +7 -7
  205. package/dist/server/app_server.d.ts.map +1 -1
  206. package/dist/server/app_server.js +35 -40
  207. package/dist/server/validate_nginx.d.ts +1 -1
  208. package/dist/server/validate_nginx.js +1 -1
  209. package/dist/testing/CLAUDE.md +50 -38
  210. package/dist/testing/admin_integration.d.ts +5 -6
  211. package/dist/testing/admin_integration.d.ts.map +1 -1
  212. package/dist/testing/admin_integration.js +87 -85
  213. package/dist/testing/app_server.d.ts +11 -14
  214. package/dist/testing/app_server.d.ts.map +1 -1
  215. package/dist/testing/app_server.js +16 -15
  216. package/dist/testing/assertions.d.ts.map +1 -1
  217. package/dist/testing/assertions.js +2 -1
  218. package/dist/testing/attack_surface.d.ts.map +1 -1
  219. package/dist/testing/attack_surface.js +15 -9
  220. package/dist/testing/audit_completeness.d.ts +2 -2
  221. package/dist/testing/audit_completeness.d.ts.map +1 -1
  222. package/dist/testing/audit_completeness.js +36 -36
  223. package/dist/testing/auth_apps.d.ts +5 -4
  224. package/dist/testing/auth_apps.d.ts.map +1 -1
  225. package/dist/testing/auth_apps.js +22 -19
  226. package/dist/testing/data_exposure.d.ts.map +1 -1
  227. package/dist/testing/data_exposure.js +5 -5
  228. package/dist/testing/db.d.ts +1 -1
  229. package/dist/testing/db.d.ts.map +1 -1
  230. package/dist/testing/db.js +4 -4
  231. package/dist/testing/db_entities.d.ts +22 -0
  232. package/dist/testing/db_entities.d.ts.map +1 -0
  233. package/dist/testing/db_entities.js +28 -0
  234. package/dist/testing/entities.d.ts +8 -7
  235. package/dist/testing/entities.d.ts.map +1 -1
  236. package/dist/testing/entities.js +21 -18
  237. package/dist/testing/integration.d.ts.map +1 -1
  238. package/dist/testing/integration.js +13 -14
  239. package/dist/testing/integration_helpers.d.ts +4 -4
  240. package/dist/testing/integration_helpers.d.ts.map +1 -1
  241. package/dist/testing/integration_helpers.js +20 -18
  242. package/dist/testing/middleware.d.ts +4 -4
  243. package/dist/testing/middleware.d.ts.map +1 -1
  244. package/dist/testing/middleware.js +12 -11
  245. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  246. package/dist/testing/rpc_attack_surface.js +40 -24
  247. package/dist/testing/rpc_round_trip.d.ts +1 -1
  248. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  249. package/dist/testing/rpc_round_trip.js +14 -13
  250. package/dist/testing/sse_round_trip.d.ts +3 -4
  251. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  252. package/dist/testing/sse_round_trip.js +7 -11
  253. package/dist/testing/standard.d.ts +1 -1
  254. package/dist/testing/stubs.d.ts +25 -0
  255. package/dist/testing/stubs.d.ts.map +1 -1
  256. package/dist/testing/stubs.js +43 -2
  257. package/dist/testing/surface_invariants.d.ts +14 -6
  258. package/dist/testing/surface_invariants.d.ts.map +1 -1
  259. package/dist/testing/surface_invariants.js +119 -43
  260. package/dist/testing/ws_round_trip.d.ts +12 -13
  261. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  262. package/dist/testing/ws_round_trip.js +19 -11
  263. package/dist/ui/AdminAccounts.svelte +23 -20
  264. package/dist/ui/AdminOverview.svelte +15 -13
  265. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  266. package/dist/ui/{AdminPermitHistory.svelte → AdminRoleGrantHistory.svelte} +12 -12
  267. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts +4 -0
  268. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -0
  269. package/dist/ui/BootstrapForm.svelte +1 -1
  270. package/dist/ui/CLAUDE.md +60 -60
  271. package/dist/ui/{PermitOfferForm.svelte → RoleGrantOfferForm.svelte} +27 -26
  272. package/dist/ui/{PermitOfferForm.svelte.d.ts → RoleGrantOfferForm.svelte.d.ts} +7 -7
  273. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -0
  274. package/dist/ui/{PermitOfferHistory.svelte → RoleGrantOfferHistory.svelte} +12 -12
  275. package/dist/ui/{PermitOfferHistory.svelte.d.ts → RoleGrantOfferHistory.svelte.d.ts} +4 -4
  276. package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -0
  277. package/dist/ui/{PermitOfferInbox.svelte → RoleGrantOfferInbox.svelte} +14 -14
  278. package/dist/ui/{PermitOfferInbox.svelte.d.ts → RoleGrantOfferInbox.svelte.d.ts} +4 -4
  279. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -0
  280. package/dist/ui/SignupForm.svelte +1 -1
  281. package/dist/ui/SurfaceExplorer.svelte +35 -15
  282. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  283. package/dist/ui/account_sessions_state.svelte.d.ts +2 -3
  284. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  285. package/dist/ui/account_sessions_state.svelte.js +2 -3
  286. package/dist/ui/admin_accounts_state.svelte.d.ts +18 -18
  287. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  288. package/dist/ui/admin_accounts_state.svelte.js +16 -16
  289. package/dist/ui/admin_rpc_adapters.d.ts +20 -20
  290. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  291. package/dist/ui/admin_rpc_adapters.js +17 -17
  292. package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
  293. package/dist/ui/admin_sessions_state.svelte.js +2 -2
  294. package/dist/ui/audit_log_state.svelte.d.ts +7 -7
  295. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  296. package/dist/ui/audit_log_state.svelte.js +6 -6
  297. package/dist/ui/auth_state.svelte.d.ts +3 -3
  298. package/dist/ui/auth_state.svelte.d.ts.map +1 -1
  299. package/dist/ui/auth_state.svelte.js +6 -6
  300. package/dist/ui/format_scope.d.ts +2 -2
  301. package/dist/ui/format_scope.js +2 -2
  302. package/dist/ui/{permit_offers_state.svelte.d.ts → role_grant_offers_state.svelte.d.ts} +30 -30
  303. package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -0
  304. package/dist/ui/{permit_offers_state.svelte.js → role_grant_offers_state.svelte.js} +18 -18
  305. package/dist/ui/ui_format.js +2 -2
  306. package/package.json +3 -3
  307. package/dist/auth/permit_offer_action_specs.d.ts.map +0 -1
  308. package/dist/auth/permit_offer_action_specs.js +0 -258
  309. package/dist/auth/permit_offer_actions.d.ts +0 -110
  310. package/dist/auth/permit_offer_actions.d.ts.map +0 -1
  311. package/dist/auth/permit_offer_notifications.d.ts.map +0 -1
  312. package/dist/auth/permit_offer_notifications.js +0 -182
  313. package/dist/auth/permit_offer_queries.d.ts.map +0 -1
  314. package/dist/auth/permit_offer_schema.d.ts +0 -125
  315. package/dist/auth/permit_offer_schema.d.ts.map +0 -1
  316. package/dist/auth/permit_queries.d.ts +0 -222
  317. package/dist/auth/permit_queries.d.ts.map +0 -1
  318. package/dist/auth/permit_queries.js +0 -305
  319. package/dist/auth/require_keeper.d.ts +0 -20
  320. package/dist/auth/require_keeper.d.ts.map +0 -1
  321. package/dist/auth/require_keeper.js +0 -35
  322. package/dist/auth/route_guards.d.ts +0 -27
  323. package/dist/auth/route_guards.d.ts.map +0 -1
  324. package/dist/auth/route_guards.js +0 -38
  325. package/dist/auth/session_lifecycle.d.ts +0 -37
  326. package/dist/auth/session_lifecycle.d.ts.map +0 -1
  327. package/dist/auth/session_lifecycle.js +0 -29
  328. package/dist/ui/AdminPermitHistory.svelte.d.ts +0 -4
  329. package/dist/ui/AdminPermitHistory.svelte.d.ts.map +0 -1
  330. package/dist/ui/PermitOfferForm.svelte.d.ts.map +0 -1
  331. package/dist/ui/PermitOfferHistory.svelte.d.ts.map +0 -1
  332. package/dist/ui/PermitOfferInbox.svelte.d.ts.map +0 -1
  333. 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,EAAyB,KAAK,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AACvF,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,yBAChB,SAAQ,kBAAkB,EAAE,wBAAwB,EAAE,oBAAoB;CAAG;AAE9E;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,GACvC,MAAM,sBAAsB,EAC5B,UAAS,yBAA8B,KACrC,KAAK,CAAC,SAAS,CAIjB,CAAC"}
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,2BAA2B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAyB,KAAK,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AACvF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AAC5E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,yBAChB,SAAQ,kBAAkB,EAAE,2BAA2B,EAAE,oBAAoB;CAAG;AAEjF;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,OAAO,CAAC;IACtF,mBAAmB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAChD;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,GACvC,MAAM,sBAAsB,EAC5B,UAAS,yBAA8B,KACrC,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
  ];
@@ -24,7 +24,7 @@
24
24
  * **Chain idempotency, not migration idempotency**: the chain-tx wraps every
25
25
  * migration replayed in a single boot, so an individual migration may
26
26
  * temporarily produce intermediate state that a later migration reverses
27
- * (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
28
28
  * hides this from observers). What matters is that the *committed end state*
29
29
  * matches; the in-tx steps may not be individually idempotent against an
30
30
  * arbitrary mid-chain target.
@@ -24,7 +24,7 @@
24
24
  * **Chain idempotency, not migration idempotency**: the chain-tx wraps every
25
25
  * migration replayed in a single boot, so an individual migration may
26
26
  * temporarily produce intermediate state that a later migration reverses
27
- * (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
28
28
  * hides this from observers). What matters is that the *committed end state*
29
29
  * matches; the in-tx steps may not be individually idempotent against an
30
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;;;;;;;;;G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,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
@@ -9,7 +9,7 @@
9
9
  * @module
10
10
  */
11
11
  import { query_account_by_username, query_actors_by_account, query_create_account_with_actor, } from '../auth/account_queries.js';
12
- import { query_grant_permit } from '../auth/permit_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) => {
@@ -300,7 +300,7 @@ export const seed_dev_account = async (deps, input, options) => {
300
300
  // Dev seed is single-actor by construction; pick the first.
301
301
  const actor = actors[0];
302
302
  for (const role of input.roles ?? []) {
303
- await query_grant_permit(query_deps, {
303
+ await query_create_role_grant(query_deps, {
304
304
  actor_id: actor.id,
305
305
  role,
306
306
  granted_by: null,
@@ -316,7 +316,7 @@ export const seed_dev_account = async (deps, input, options) => {
316
316
  password_hash,
317
317
  });
318
318
  for (const role of input.roles ?? []) {
319
- await query_grant_permit(query_deps, {
319
+ await query_create_role_grant(query_deps, {
320
320
  actor_id: actor.id,
321
321
  role,
322
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,13 +12,20 @@
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. */
@@ -49,39 +56,6 @@ export declare const ACCOUNT_ID_KEY = "auth_account_id";
49
56
  * silently bypass the live build.
50
57
  */
51
58
  export declare const TEST_CONTEXT_PRESET_KEY = "test_context_preset";
52
- /**
53
- * Cached parsed JSON request body, keyed by `'cached_request_body'`.
54
- *
55
- * Written by `read_raw_acting` (in the dispatcher's authorization
56
- * phase) when it pre-parses the body to extract the `acting` field;
57
- * read by `create_input_validation` so the input-validation step does
58
- * not pay for a second `JSON.parse` on the same Hono-cached body text.
59
- *
60
- * Decouples our pipeline from Hono's internal `bodyCache` shape: Hono
61
- * caches the body *text* (so a second `c.req.json()` call doesn't
62
- * re-read the request stream), but each call still re-runs
63
- * `JSON.parse(text)`. Storing the parsed value here saves the second
64
- * parse and keeps fuz_app from depending on undocumented Hono
65
- * implementation details.
66
- *
67
- * Three states:
68
- *
69
- * - Key absent — body has not been pre-parsed yet (the route had no
70
- * `acting` to extract, or the request is GET).
71
- * - `{ok: true, body: unknown}` — pre-parse succeeded; the parsed
72
- * value (object, primitive, or array) is in `body`.
73
- * - `{ok: false}` — pre-parse threw (malformed JSON). The downstream
74
- * input-validation step short-circuits with `ERROR_INVALID_JSON_BODY`
75
- * instead of re-parsing.
76
- */
77
- export declare const CACHED_REQUEST_BODY_KEY = "cached_request_body";
78
- /** The shape stored under `CACHED_REQUEST_BODY_KEY`. */
79
- export type CachedRequestBody = {
80
- ok: true;
81
- body: unknown;
82
- } | {
83
- ok: false;
84
- };
85
59
  declare module 'hono' {
86
60
  interface ContextVariableMap {
87
61
  /** Resolved client IP, set by the trusted proxy middleware. */
@@ -116,24 +90,32 @@ declare module 'hono' {
116
90
  */
117
91
  auth_api_token_id: string | null;
118
92
  /**
119
- * Pending fire-and-forget effects for this request (audit logs, usage tracking, etc.).
120
- * Initialized by `create_app_server`. In test mode (`await_pending_effects: true`),
121
- * 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.
122
99
  */
123
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>>;
124
113
  /**
125
114
  * Set to `true` by test harnesses that pre-populate `request_context`
126
115
  * to bypass the dispatcher's DB-backed actor resolution. Read by
127
116
  * `apply_authorization_phase`. Production middleware never sets this.
128
117
  */
129
118
  test_context_preset: boolean;
130
- /**
131
- * Pre-parsed JSON request body cache. Written by `read_raw_acting`
132
- * (the dispatcher's `acting` extractor) and read by
133
- * `create_input_validation` so the same body is not parsed twice.
134
- * See `CACHED_REQUEST_BODY_KEY` for state semantics.
135
- */
136
- cached_request_body: CachedRequestBody;
137
119
  }
138
120
  }
139
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;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D;;;;;;;;;;;;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AAM,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;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D,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,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B;;;;;WAKG;QACH,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;QACvC;;;;;;WAMG;QACH,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC;;;;;;;WAOG;QACH,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC;;;;;;;;;;WAUG;QACH,mBAAmB,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD;;;;WAIG;QACH,mBAAmB,EAAE,OAAO,CAAC;KAC7B;CACD"}
@@ -11,8 +11,20 @@
11
11
  * @module
12
12
  */
13
13
  import { z } from 'zod';
14
- /** The credential types that can authenticate a request. */
15
- export const CREDENTIAL_TYPES = ['session', 'api_token', 'daemon_token'];
14
+ import { CREDENTIAL_TYPE_API_TOKEN, CREDENTIAL_TYPE_DAEMON_TOKEN, CREDENTIAL_TYPE_SESSION, } from './auth/credential_type_schema.js';
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
+ */
23
+ export const CREDENTIAL_TYPES = [
24
+ CREDENTIAL_TYPE_SESSION,
25
+ CREDENTIAL_TYPE_API_TOKEN,
26
+ CREDENTIAL_TYPE_DAEMON_TOKEN,
27
+ ];
16
28
  /** Credential type — how a request was authenticated. */
17
29
  export const CredentialType = z.enum(CREDENTIAL_TYPES);
18
30
  /** Hono context variable name for the credential type. */
@@ -43,29 +55,3 @@ export const ACCOUNT_ID_KEY = 'auth_account_id';
43
55
  * silently bypass the live build.
44
56
  */
45
57
  export const TEST_CONTEXT_PRESET_KEY = 'test_context_preset';
46
- /**
47
- * Cached parsed JSON request body, keyed by `'cached_request_body'`.
48
- *
49
- * Written by `read_raw_acting` (in the dispatcher's authorization
50
- * phase) when it pre-parses the body to extract the `acting` field;
51
- * read by `create_input_validation` so the input-validation step does
52
- * not pay for a second `JSON.parse` on the same Hono-cached body text.
53
- *
54
- * Decouples our pipeline from Hono's internal `bodyCache` shape: Hono
55
- * caches the body *text* (so a second `c.req.json()` call doesn't
56
- * re-read the request stream), but each call still re-runs
57
- * `JSON.parse(text)`. Storing the parsed value here saves the second
58
- * parse and keeps fuz_app from depending on undocumented Hono
59
- * implementation details.
60
- *
61
- * Three states:
62
- *
63
- * - Key absent — body has not been pre-parsed yet (the route had no
64
- * `acting` to extract, or the request is GET).
65
- * - `{ok: true, body: unknown}` — pre-parse succeeded; the parsed
66
- * value (object, primitive, or array) is in `body`.
67
- * - `{ok: false}` — pre-parse threw (malformed JSON). The downstream
68
- * input-validation step short-circuits with `ERROR_INVALID_JSON_BODY`
69
- * instead of re-parsing.
70
- */
71
- export const CACHED_REQUEST_BODY_KEY = 'cached_request_body';