@fuzdev/fuz_app 0.179.0 → 0.181.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 (358) hide show
  1. package/dist/actions/CLAUDE.md +14 -14
  2. package/dist/actions/action_rpc.d.ts +14 -5
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +53 -46
  5. package/dist/actions/action_types.d.ts +15 -12
  6. package/dist/actions/action_types.d.ts.map +1 -1
  7. package/dist/actions/perform_action.d.ts +4 -4
  8. package/dist/actions/perform_action.d.ts.map +1 -1
  9. package/dist/actions/perform_action.js +6 -6
  10. package/dist/actions/register_action_ws.d.ts +6 -2
  11. package/dist/actions/register_action_ws.d.ts.map +1 -1
  12. package/dist/actions/register_action_ws.js +14 -3
  13. package/dist/actions/ws_socket_session.js +1 -1
  14. package/dist/auth/CLAUDE.md +36 -30
  15. package/dist/auth/account_actions.d.ts.map +1 -1
  16. package/dist/auth/account_actions.js +18 -1
  17. package/dist/auth/account_queries.d.ts +69 -0
  18. package/dist/auth/account_queries.d.ts.map +1 -1
  19. package/dist/auth/account_queries.js +82 -0
  20. package/dist/auth/account_route_schema.d.ts +26 -16
  21. package/dist/auth/account_route_schema.d.ts.map +1 -1
  22. package/dist/auth/account_route_schema.js +10 -24
  23. package/dist/auth/account_routes.d.ts +4 -6
  24. package/dist/auth/account_routes.d.ts.map +1 -1
  25. package/dist/auth/account_routes.js +86 -66
  26. package/dist/auth/admin_actions.d.ts.map +1 -1
  27. package/dist/auth/admin_actions.js +63 -14
  28. package/dist/auth/api_token_queries.d.ts +16 -7
  29. package/dist/auth/api_token_queries.d.ts.map +1 -1
  30. package/dist/auth/api_token_queries.js +18 -18
  31. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  32. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  33. package/dist/auth/audit_log_routes.d.ts +1 -1
  34. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  35. package/dist/auth/audit_log_routes.js +10 -12
  36. package/dist/auth/audit_log_schema.js +4 -4
  37. package/dist/auth/bearer_auth.d.ts +4 -3
  38. package/dist/auth/bearer_auth.d.ts.map +1 -1
  39. package/dist/auth/bearer_auth.js +35 -31
  40. package/dist/auth/bootstrap_account.d.ts +65 -37
  41. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  42. package/dist/auth/bootstrap_account.js +115 -66
  43. package/dist/auth/bootstrap_route_schema.d.ts +6 -2
  44. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_route_schema.js +7 -2
  46. package/dist/auth/bootstrap_routes.d.ts +50 -33
  47. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_routes.js +109 -87
  49. package/dist/auth/bootstrap_token_store.d.ts +60 -0
  50. package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
  51. package/dist/auth/bootstrap_token_store.js +39 -0
  52. package/dist/auth/credential_headers.d.ts +71 -0
  53. package/dist/auth/credential_headers.d.ts.map +1 -0
  54. package/dist/auth/credential_headers.js +100 -0
  55. package/dist/auth/daemon_token.d.ts +13 -1
  56. package/dist/auth/daemon_token.d.ts.map +1 -1
  57. package/dist/auth/daemon_token.js +14 -2
  58. package/dist/auth/daemon_token_middleware.d.ts +10 -11
  59. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  60. package/dist/auth/daemon_token_middleware.js +27 -29
  61. package/dist/auth/deps.d.ts +0 -11
  62. package/dist/auth/deps.d.ts.map +1 -1
  63. package/dist/auth/invite_queries.d.ts +18 -0
  64. package/dist/auth/invite_queries.d.ts.map +1 -1
  65. package/dist/auth/invite_queries.js +24 -0
  66. package/dist/auth/request_context.d.ts +26 -5
  67. package/dist/auth/request_context.d.ts.map +1 -1
  68. package/dist/auth/request_context.js +17 -10
  69. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  70. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  71. package/dist/auth/role_grant_offer_action_specs.js +3 -2
  72. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  73. package/dist/auth/role_grant_offer_actions.js +37 -14
  74. package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
  75. package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
  76. package/dist/auth/role_grant_offer_ddl.js +9 -2
  77. package/dist/auth/role_grant_offer_queries.d.ts +56 -3
  78. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  79. package/dist/auth/role_grant_offer_queries.js +93 -8
  80. package/dist/auth/role_grant_queries.d.ts +7 -0
  81. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  82. package/dist/auth/role_grant_queries.js +8 -0
  83. package/dist/auth/session_cookie.d.ts +105 -25
  84. package/dist/auth/session_cookie.d.ts.map +1 -1
  85. package/dist/auth/session_cookie.js +124 -15
  86. package/dist/auth/session_middleware.d.ts +83 -54
  87. package/dist/auth/session_middleware.d.ts.map +1 -1
  88. package/dist/auth/session_middleware.js +92 -66
  89. package/dist/auth/session_queries.d.ts +64 -4
  90. package/dist/auth/session_queries.d.ts.map +1 -1
  91. package/dist/auth/session_queries.js +53 -4
  92. package/dist/auth/signup_route_schema.d.ts +5 -5
  93. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  94. package/dist/auth/signup_route_schema.js +4 -4
  95. package/dist/auth/signup_routes.d.ts.map +1 -1
  96. package/dist/auth/signup_routes.js +17 -14
  97. package/dist/auth/token_scope.d.ts +5 -7
  98. package/dist/auth/token_scope.d.ts.map +1 -1
  99. package/dist/auth/token_scope.js +5 -8
  100. package/dist/dev/setup.d.ts +6 -1
  101. package/dist/dev/setup.d.ts.map +1 -1
  102. package/dist/dev/setup.js +42 -34
  103. package/dist/hono_context.d.ts +21 -0
  104. package/dist/hono_context.d.ts.map +1 -1
  105. package/dist/hono_context.js +17 -0
  106. package/dist/http/CLAUDE.md +150 -43
  107. package/dist/http/auth_shape.d.ts +3 -3
  108. package/dist/http/common_routes.js +1 -1
  109. package/dist/http/db_routes.d.ts +4 -3
  110. package/dist/http/db_routes.d.ts.map +1 -1
  111. package/dist/http/db_routes.js +14 -14
  112. package/dist/http/dev_route_error_check.d.ts +6 -3
  113. package/dist/http/dev_route_error_check.d.ts.map +1 -1
  114. package/dist/http/dev_route_error_check.js +6 -3
  115. package/dist/http/dev_set_cookie_check.d.ts +53 -0
  116. package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
  117. package/dist/http/dev_set_cookie_check.js +80 -0
  118. package/dist/http/error_schemas.d.ts +36 -1
  119. package/dist/http/error_schemas.d.ts.map +1 -1
  120. package/dist/http/error_schemas.js +39 -2
  121. package/dist/http/header_lines.d.ts +42 -0
  122. package/dist/http/header_lines.d.ts.map +1 -0
  123. package/dist/http/header_lines.js +80 -0
  124. package/dist/http/host.d.ts +12 -9
  125. package/dist/http/host.d.ts.map +1 -1
  126. package/dist/http/host.js +25 -20
  127. package/dist/http/origin.d.ts +7 -22
  128. package/dist/http/origin.d.ts.map +1 -1
  129. package/dist/http/origin.js +11 -25
  130. package/dist/http/proxy.d.ts +1 -0
  131. package/dist/http/proxy.d.ts.map +1 -1
  132. package/dist/http/proxy.js +3 -0
  133. package/dist/http/request_headers.d.ts +95 -0
  134. package/dist/http/request_headers.d.ts.map +1 -0
  135. package/dist/http/request_headers.js +110 -0
  136. package/dist/http/request_target.d.ts +134 -0
  137. package/dist/http/request_target.d.ts.map +1 -0
  138. package/dist/http/request_target.js +193 -0
  139. package/dist/http/route_error_check.d.ts +4 -11
  140. package/dist/http/route_error_check.d.ts.map +1 -1
  141. package/dist/http/route_error_check.js +4 -21
  142. package/dist/http/route_result.d.ts +127 -23
  143. package/dist/http/route_result.d.ts.map +1 -1
  144. package/dist/http/route_result.js +97 -19
  145. package/dist/http/route_spec.d.ts +298 -82
  146. package/dist/http/route_spec.d.ts.map +1 -1
  147. package/dist/http/route_spec.js +548 -71
  148. package/dist/http/simple_request.d.ts +19 -14
  149. package/dist/http/simple_request.d.ts.map +1 -1
  150. package/dist/http/simple_request.js +17 -29
  151. package/dist/http/surface.d.ts +2 -0
  152. package/dist/http/surface.d.ts.map +1 -1
  153. package/dist/http/surface.js +4 -1
  154. package/dist/realtime/outbound_budget.d.ts +1 -2
  155. package/dist/realtime/outbound_budget.d.ts.map +1 -1
  156. package/dist/realtime/outbound_budget.js +1 -2
  157. package/dist/realtime/sse.d.ts +47 -17
  158. package/dist/realtime/sse.d.ts.map +1 -1
  159. package/dist/realtime/sse.js +115 -93
  160. package/dist/realtime/sse_constants.d.ts +7 -1
  161. package/dist/realtime/sse_constants.d.ts.map +1 -1
  162. package/dist/realtime/sse_constants.js +12 -1
  163. package/dist/realtime/sse_registry.d.ts +3 -3
  164. package/dist/realtime/sse_registry.js +3 -3
  165. package/dist/runtime/deps.d.ts +20 -4
  166. package/dist/runtime/deps.d.ts.map +1 -1
  167. package/dist/runtime/mock.d.ts +7 -1
  168. package/dist/runtime/mock.d.ts.map +1 -1
  169. package/dist/runtime/mock.js +33 -3
  170. package/dist/runtime/node.d.ts.map +1 -1
  171. package/dist/runtime/node.js +2 -1
  172. package/dist/runtime/secure_file.d.ts +71 -10
  173. package/dist/runtime/secure_file.d.ts.map +1 -1
  174. package/dist/runtime/secure_file.js +91 -11
  175. package/dist/server/app_backend.d.ts +0 -8
  176. package/dist/server/app_backend.d.ts.map +1 -1
  177. package/dist/server/app_backend.js +1 -3
  178. package/dist/server/app_server.d.ts +28 -17
  179. package/dist/server/app_server.d.ts.map +1 -1
  180. package/dist/server/app_server.js +52 -34
  181. package/dist/server/serve_fact_route.d.ts.map +1 -1
  182. package/dist/server/serve_fact_route.js +49 -45
  183. package/dist/server/static.d.ts +20 -0
  184. package/dist/server/static.d.ts.map +1 -1
  185. package/dist/server/static.js +56 -8
  186. package/dist/server/unmatched_route.d.ts +42 -0
  187. package/dist/server/unmatched_route.d.ts.map +1 -0
  188. package/dist/server/unmatched_route.js +64 -0
  189. package/dist/testing/CLAUDE.md +404 -1200
  190. package/dist/testing/app_server.d.ts +3 -1
  191. package/dist/testing/app_server.d.ts.map +1 -1
  192. package/dist/testing/app_server.js +4 -10
  193. package/dist/testing/auth_apps.d.ts.map +1 -1
  194. package/dist/testing/auth_apps.js +2 -1
  195. package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
  196. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/account_lifecycle.js +277 -6
  198. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
  199. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  200. package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
  201. package/dist/testing/cross_backend/capabilities.d.ts +68 -5
  202. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  203. package/dist/testing/cross_backend/capabilities.js +20 -4
  204. package/dist/testing/cross_backend/cell_gated_create.js +1 -1
  205. package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
  206. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  207. package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
  208. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  209. package/dist/testing/cross_backend/conformance_table.js +179 -23
  210. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  211. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
  212. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  213. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
  214. package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
  215. package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
  216. package/dist/testing/cross_backend/credential_conformance.js +296 -0
  217. package/dist/testing/cross_backend/credential_conformance.json +1284 -0
  218. package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
  219. package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
  220. package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
  221. package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
  222. package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
  224. package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
  225. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
  226. package/dist/testing/cross_backend/credential_wire.js +188 -0
  227. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  228. package/dist/testing/cross_backend/default_backend_configs.js +22 -2
  229. package/dist/testing/cross_backend/default_spine_surface.js +1 -1
  230. package/dist/testing/cross_backend/differential.d.ts +1 -1
  231. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  232. package/dist/testing/cross_backend/differential.js +3 -2
  233. package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
  234. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  235. package/dist/testing/cross_backend/differential_normalize.js +11 -5
  236. package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -0
  237. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  238. package/dist/testing/cross_backend/full_spine_mount.js +7 -0
  239. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  240. package/dist/testing/cross_backend/identity_parity.js +4 -0
  241. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  242. package/dist/testing/cross_backend/in_process_setup.js +78 -4
  243. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  244. package/dist/testing/cross_backend/login_security.js +13 -10
  245. package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
  246. package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
  247. package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
  248. package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
  249. package/dist/testing/cross_backend/request_header_conformance.js +196 -0
  250. package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
  251. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
  252. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
  253. package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
  254. package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
  255. package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
  256. package/dist/testing/cross_backend/request_target_conformance.js +186 -0
  257. package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
  258. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
  259. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
  260. package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
  261. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  262. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
  263. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  264. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +2 -1
  265. package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
  266. package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
  267. package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
  268. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
  269. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  270. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
  271. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  272. package/dist/testing/cross_backend/session_cap.js +56 -29
  273. package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
  274. package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
  275. package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
  276. package/dist/testing/cross_backend/session_login.d.ts +24 -0
  277. package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
  278. package/dist/testing/cross_backend/session_login.js +31 -0
  279. package/dist/testing/cross_backend/setup.d.ts +117 -0
  280. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  281. package/dist/testing/cross_backend/setup.js +193 -9
  282. package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
  283. package/dist/testing/cross_backend/simple_request.js +5 -0
  284. package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
  285. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  286. package/dist/testing/cross_backend/spine_suites.js +88 -5
  287. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  288. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  289. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  290. package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
  291. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  292. package/dist/testing/cross_backend/sse_round_trip.js +205 -64
  293. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  294. package/dist/testing/cross_backend/testing_backdoor.js +5 -2
  295. package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
  296. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
  297. package/dist/testing/cross_backend/testing_credential_read.js +175 -0
  298. package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
  299. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  300. package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
  301. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  302. package/dist/testing/cross_backend/token_lifetime.js +58 -2
  303. package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
  304. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  305. package/dist/testing/cross_backend/transport_composition.js +13 -10
  306. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  307. package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
  308. package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
  309. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  310. package/dist/testing/cross_backend/ws_endpoint.js +19 -2
  311. package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
  312. package/dist/testing/cross_backend/ws_role_gated.js +2 -3
  313. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  314. package/dist/testing/cross_backend/ws_round_trip.js +28 -12
  315. package/dist/testing/cross_backend/xfail.d.ts +44 -11
  316. package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
  317. package/dist/testing/cross_backend/xfail.js +68 -23
  318. package/dist/testing/data_exposure.d.ts.map +1 -1
  319. package/dist/testing/data_exposure.js +4 -3
  320. package/dist/testing/integration.d.ts +1 -2
  321. package/dist/testing/integration.d.ts.map +1 -1
  322. package/dist/testing/integration.js +14 -8
  323. package/dist/testing/integration_helpers.d.ts +50 -3
  324. package/dist/testing/integration_helpers.d.ts.map +1 -1
  325. package/dist/testing/integration_helpers.js +87 -9
  326. package/dist/testing/middleware.d.ts +2 -0
  327. package/dist/testing/middleware.d.ts.map +1 -1
  328. package/dist/testing/middleware.js +9 -2
  329. package/dist/testing/round_trip.d.ts +6 -2
  330. package/dist/testing/round_trip.d.ts.map +1 -1
  331. package/dist/testing/round_trip.js +17 -6
  332. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  333. package/dist/testing/rpc_envelope_cases.js +7 -0
  334. package/dist/testing/rpc_helpers.d.ts +4 -2
  335. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  336. package/dist/testing/rpc_helpers.js +6 -1
  337. package/dist/testing/rpc_round_trip.d.ts +13 -2
  338. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  339. package/dist/testing/rpc_round_trip.js +25 -6
  340. package/dist/testing/schema_generators.d.ts +2 -2
  341. package/dist/testing/schema_generators.d.ts.map +1 -1
  342. package/dist/testing/schema_generators.js +4 -4
  343. package/dist/testing/stubs.d.ts +2 -2
  344. package/dist/testing/stubs.d.ts.map +1 -1
  345. package/dist/testing/stubs.js +8 -8
  346. package/dist/testing/transports/fetch_transport.d.ts +6 -3
  347. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  348. package/dist/testing/transports/fetch_transport.js +31 -19
  349. package/dist/testing/transports/raw_http.d.ts +61 -1
  350. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  351. package/dist/testing/transports/raw_http.js +61 -1
  352. package/dist/testing/transports/ws_raw_client.d.ts +20 -0
  353. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  354. package/dist/testing/transports/ws_raw_client.js +10 -4
  355. package/dist/testing/transports/ws_transport.d.ts +21 -1
  356. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  357. package/dist/testing/transports/ws_transport.js +58 -20
  358. package/package.json +5 -5
@@ -4,9 +4,11 @@ Generic HTTP framework infrastructure — route specs, error schemas, attack
4
4
  surface introspection, JSON-RPC envelope + error taxonomy, proxy/origin
5
5
  middleware primitives, post-commit effect helper, generic admin route specs.
6
6
 
7
- **Nothing in this directory is auth-specific.** Auth middleware, routes, and
8
- guards live in `auth/` and consume these primitives. Routes and actions in
9
- other domains should do the same — extend, don't special-case.
7
+ **No auth logic lives in this directory.** Auth middleware, routes, and
8
+ guards live in `auth/` and consume these primitives; the route context names
9
+ the auth domain's types (`RequestContext`, `ResolvedAuth`) as types only, as
10
+ `hono_context.ts` does. Routes and actions in other domains should do the
11
+ same — extend, don't special-case.
10
12
 
11
13
  For the design rationale behind declarative routes, DEV-only output
12
14
  validation, the route error map, and fire-and-forget
@@ -14,24 +16,29 @@ effects, see ../../../docs/architecture.md.
14
16
 
15
17
  ## Module Map
16
18
 
17
- - `http/route_spec.ts` — `RouteSpec` + `apply_route_specs`, validation pipeline, transactions; `define_route`, `define_route_shape` + `attach_route_handler` (a handler checked against its route), `to_route_response`.
18
- - `http/route_result.ts` — what a handler returns: `route_ok`, `route_fail`, `route_raw` (`RouteResult`). Hono-free (types only).
19
+ - `http/route_spec.ts` — `RouteSpec` + `apply_route_specs`, validation pipeline, transactions; `define_route`, `define_route_shape` + `attach_route_handler` (a handler checked against its route), `prepare_route_response` + `emit_route_response` (the one place a route result becomes a `Response`), and `RouteContext` — everything a handler reads of its request, built from the Hono context the handler never sees.
20
+ - `http/route_result.ts` — what a handler returns, all of it data: `route_ok`, `route_fail`, `route_raw`, `route_sse` (`RouteResult`), and `ROUTE_RAW_REFUSED_HEADERS`. Imports nothing from Hono.
19
21
  - `http/auth_shape.ts` — canonical `RouteAuth` type + `AuthAxisState` + predicates + the registration-time checks: `assert_route_auth_invariants` (the cross-axis invariants 1, 3, 4) and `assert_route_auth_acting_biconditional` (invariant 2), both run by `apply_route_specs` and `compile_action_registry` on every spec.
20
22
  - `http/error_schemas.ts` — `ERROR_*` constants, the per-code REST error definitions (`rest_error`, `REST_*`), `derive_route_errors`, `to_error_schemas`.
21
23
  - `http/route_errors.ts` — the route error map: `RouteErrorMap`, `resolve_route_error_map`, `resolve_app_route_error_maps`, `get_route_error_map`.
22
- - `http/route_error_check.ts` — `check_route_error` (whether an error response is one its route's map declares, the rule the DEV error check and `assert_response_matches_spec` share; `ALWAYS_ACCEPTED_ERRORS`, `is_error_status`, `format_route_error_check`) `is_json_response`, and the test helpers' hono-free route lookup (`split_route_template` and `parse_route_param`, a template read segment by segment as Hono's `getPattern` reads it; `compile_route_path`; `compile_route_param_pattern`, a `{re}` grouped and anchored as `compile_route_path` reads it — Hono's RegExpRouter reading, stricter than TrieRouter's ungrouped `^re$`; `decode_route_path`, a path as Hono's router decodes it; `to_mounted_routes`; `find_mounted_route`), whose reading `resolve_valid_path` also fills params by. Hono-free and `esm-env`-free.
24
+ - `http/route_error_check.ts` — `check_route_error` (whether an error response is one its route's map declares, the rule the DEV error check and `assert_response_matches_spec` share; `ALWAYS_ACCEPTED_ERRORS`, `is_error_status`, `format_route_error_check`) `is_json_response`, and the test helpers' hono-free route lookup (`split_route_template` and `parse_route_param`, a template read segment by segment as Hono's `getPattern` reads it; `compile_route_path`; `compile_route_param_pattern`, a `{re}` grouped and anchored as `compile_route_path` reads it — Hono's RegExpRouter reading, stricter than TrieRouter's ungrouped `^re$`; `to_mounted_routes`; `find_mounted_route`), whose reading `resolve_valid_path` also fills params by. Hono-free and `esm-env`-free.
23
25
  - `http/dev_route_error_check.ts` — `create_dev_route_error_check({route_specs, route_error_maps, log})`: the DEV-only outer error check, `null` outside DEV; `create_route_lookup`, its lookup by Hono's own router.
26
+ - `http/dev_set_cookie_check.ts` — `create_dev_set_cookie_check({log})`: the DEV-only outer check that a response leads with the `Set-Cookie` line a middleware recorded for it (`EXPECTED_FIRST_SET_COOKIE_KEY` — the session middleware's clear), `null` outside DEV. Knows nothing of sessions.
24
27
  - `http/schema_helpers.ts` — shared schema introspection (null/void/strict/surface/middleware-applies), and `to_void_params` / `to_input_params` / `scan_json_value` / `safe_parse_dropping_unknown_keys`.
25
28
  - `http/json_text.ts` — `parse_json_text`: JSON text read as the Rust spine's `serde_json` reads it, refusing what `JSON.parse` accepts and serde refuses (an escaped lone surrogate in a string or key, a number out of `f64` range, nesting `JSON_DEPTH_LIMIT` (128) deep); one linear scan of the text after `JSON.parse` accepts it (`is_serde_json_text`), so a refused value under a duplicated key is seen and the cost stays a few milliseconds a MiB. `read_json_body(c.req)` reads a request body through it once per request (the authorization phase's `acting` read and input validation share it), as text, never `c.req.json()`. Every body and frame parse runs it: route input, the RPC POST body and `GET` `params`, WS frames. Hono-free, imports nothing.
26
29
  - `http/middleware_spec.ts` — `MiddlewareSpec` interface.
27
30
  - `http/body_limit.ts` — `create_body_limit_middleware(max_size)`: the `413` body cap `create_app_server` mounts, as `create_body_limit_middleware_spec(max_size)`, a `MiddlewareSpec` at `'*'` ahead of the other middleware, absent with `max_body_size: null`. Its hono-free shape, `body_limit_middleware_shape` (`http/body_limit_schema.ts`), declares its `413` `payload_too_large` and `400` `invalid_content_length`, so every route's error map carries both; `create_test_app_surface_spec` lists the same shape with a stub handler. Refuses on `Content-Length` without reading `c.req.raw.body` and answers `Connection: close` — `413` past the cap, `400` `ERROR_INVALID_CONTENT_LENGTH` when the value is not a plain run of ASCII digits (a length the cap cannot read, which Hono's `bodyLimit` would pass uncounted) — else falls through to Hono's `bodyLimit` (no `Content-Length`, or one beside `Transfer-Encoding`), which reads the body into memory up to the cap before the next middleware runs, so its `413` — no `Connection: close` — also precedes origin and auth. After the header `413` Node and Bun close at once (the header is what makes them — Bun 1.4.3 is the tested floor, an older Bun kept the connection and served the next request) (../../../docs/security.md §Body Size Limiting).
28
31
  - `http/surface.ts` — `AppSurface`, `AppSurfaceSpec`, `generate_app_surface`, diagnostics.
29
32
  - `http/surface_query.ts` — pure filters/groupings over `AppSurface`.
30
- - `http/proxy.ts` — trusted-proxy middleware, CIDR parsing, rightmost-first XFF resolution. Pulls `hono/utils/ipaddr` for CIDR matching.
33
+ - `http/proxy.ts` — trusted-proxy middleware, CIDR parsing, rightmost-first XFF resolution; also records the socket's peer address as it read it (`CONNECTION_IP_KEY`, what `RouteContext.connection_ip` answers). Pulls `hono/utils/ipaddr` for CIDR matching.
31
34
  - `http/client_ip.ts` — `get_client_ip(c)` — reads the resolved IP off the context (set by `proxy.ts`'s middleware). Split out of `proxy.ts` so it's hono-free: dispatch + route modules that only _read_ the IP don't pull `hono/utils/ipaddr`, keeping cross-process test surfaces free of the optional `hono` peer.
32
35
  - `http/ip_canonical.ts` — RFC 5952 IPv6 canonicalization + IPv4-mapped collapse, `rate_limit_ip_key` (an IPv6 client's `/64`), and its own `parse_ipv4_bits` / `parse_ipv6_bits` (the grammar of Rust's `IpAddr::from_str`); `IP_LITERAL_CHARS` regex. Imports nothing — the dispatcher keys its IP limiter through it, so it must stay hono-free (`src/test/hono_free_modules.test.ts` walks every `src/lib` module's graph).
36
+ - `http/header_lines.ts` — `get_header_lines(c, name)`: a request header as the lines the client sent — Node's raw header list where `@hono/node-server` provides it (`c.env.incoming.rawHeaders`, plain requests and WebSocket upgrades alike), else the Fetch value as one line (Bun, in-process `app.request`: repeated lines arrive joined) — and `trim_optional_whitespace` (SP and HTAB only). What the credential readers (`auth/credential_headers.ts`) and the gate readers (`http/request_headers.ts`) read, so a header sent twice or empty is seen as such.
37
+ - `http/request_headers.ts` — the gates' header grammar as pure readers over header lines, hono-free: `read_origin`, `read_host`, `read_content_type` (each a `HeaderRead` — `absent`, `one` well-formed line, or `refused`: an empty line, a second line, a byte off the grammar, a comma anywhere) and `is_browser_context(origin_lines, referer_lines)` (any line, an empty one included). A comma is refused so a repeat reads the same joined (Bun, in-process) as it does line by line. Twin of the Rust `fuz_http::request_headers`; both held to `testing/cross_backend/request_header_conformance.json`. `src/test/request_reads_census.test.ts` holds every raw request read in `src/lib` to a per-module allowlist, and these headers and the credential ones to `get_header_lines`.
38
+ - `http/simple_request.ts` — the 415 gate on every `POST` route (`is_post_content_type_refused` over `read_content_type`): a JSON route takes only `application/json`, a `raw_body` route any well-formed type that isn't CORS-safelisted; a repeated, empty or off-grammar `Content-Type` is refused on every runtime (../../../docs/security.md §CSRF Protection).
39
+ - `http/request_target.ts` — the strict readers of the request target: `read_query_pairs` (the query string to its decoded pairs) and `read_path_segment` (one path segment to its text), each a `Result` that refuses an escape that doesn't decode (`PercentDecodeError`: `malformed_escape`, `invalid_utf8`) — never left literal, never replaced with U+FFFD — plus `query_first` / `to_query_record` over the pairs and the two Hono-bound readers every query and param read in the spine goes through (`read_request_query_pairs`, `read_request_route_params`). `+` is a space and the first occurrence of a key wins. Twin of the Rust `fuz_http::request_target`; both held to `testing/cross_backend/request_target_conformance.json`. Also `get_request_path`, the raw path the app's router matches (its `getPath`).
33
40
  - `http/origin.ts` — origin allowlist: the strict pattern grammar shared with the Rust spine, typed refusals, and the Origin-only middleware.
34
- - `http/host.ts` — the host gate (DNS rebinding): `is_loopback_host`, `allows_host` / `allows_request_hosts` over the origin matchers, `create_host_gate_middleware_spec` (`'*'`, 403 `forbidden_host`, on by default in `create_app_server`) and its rate-limited refusal warning (`format_host_refusal_warning`). Twin of the Rust `fuz_http::host`; verdicts pinned by the host rows of `testing/cross_backend/origin_conformance.json` (../../../docs/security.md §DNS Rebinding).
41
+ - `http/host.ts` — the host gate (DNS rebinding): `is_loopback_host`, `allows_host` / `allows_request_hosts` over the origin matchers, `create_host_gate_middleware_spec` (`'*'`, 403 `forbidden_host`, on by default in `create_app_server`) and its rate-limited refusal warning (`format_host_refusal_warning`). Twin of the Rust `fuz_http::host`; reads the `Host` lines through `read_host`; verdicts pinned by the host rows of `testing/cross_backend/origin_conformance.json` and, over repeated and empty lines on the wire, by `request_header_conformance.json` (../../../docs/security.md §DNS Rebinding).
35
42
  - `http/jsonrpc.ts` — JSON-RPC 2.0 envelope schemas (MCP superset, fuz_schema), `JsonrpcErrorCode`.
36
43
  - `http/jsonrpc_errors.ts` — `ThrownJsonrpcError`, `jsonrpc_errors` throwers, HTTP-status mappings.
37
44
  - `http/jsonrpc_helpers.ts` — message builders, type guards, input/result normalizers, and `classify_jsonrpc_message`, the one envelope classifier both transports run.
@@ -52,17 +59,18 @@ consumers.
52
59
  - `method` — `'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'`
53
60
  - `path` — Hono path (supports `:param` segments)
54
61
  - `auth: RouteAuth` — flat record `{account, actor, roles?, credential_types?, required_scope?}` from `http/auth_shape.ts`. `account` / `actor` are `'none' | 'optional' | 'required'`. `required_scope` names the capability a narrowed api token's scope must admit — `surface:<name>`, a non-RPC surface refused to every narrowed token (an `rpc:<method>` capability throws at registration: it is the dispatcher's per-method gate, which a route never reaches) — and is route-spec-only: `compile_action_registry` rejects it on an `ActionSpec`, where the dispatcher derives `rpc:<method>` from `spec.method`. Otherwise the same shape governs `ActionSpec.auth` (see `actions/CLAUDE.md`).
55
- - `handler: RouteHandler` — `(c: Context, route: RouteContext) => RouteResult | Promise<RouteResult>`, a result the framework answers with (§Handlers and results)
62
+ - `handler: RouteHandler` — `(route: RouteContext) => RouteResult | Promise<RouteResult>`: the route context in, a result the framework answers with out (§Handlers and results); a handler never receives the Hono context
56
63
  - `description` — free-text, surfaced in `AppSurface`
57
64
  - `params?: AnySchema` — strict-object schema for URL path params
58
65
  - `query?: AnySchema` — strict-object schema for URL query string
59
- - `input: AnySchema` — request body schema; `literal(null)` for no-body (GET/DELETE)
66
+ - `input: AnySchema` — request body schema; `literal(null)` for no body, and on every `GET` (`apply_route_specs` refuses any other)
60
67
  - `output: AnySchema` — success response schema
61
68
  - `mints_credential?: boolean` — the route issues a session cookie while declaring no auth (login, signup, bootstrap); assembly refuses it outside `AUTH_MIDDLEWARE_PATH`, as it does any route whose `auth.account` is not `'none'` (`assert_credential_routes_in_auth_scope` in `auth/middleware.ts`)
62
69
  - `reads_credential?: boolean` — the handler reads the resolved account while the route declares no auth gate, answering an anonymous caller itself (account status, the cell-scoped fact read, `create_rpc_endpoint`'s pair, whose dispatcher gates per action); held inside `AUTH_MIDDLEWARE_PATH` by the same assertion. Such a handler reads the account through `get_public_account_id` (`auth/request_context.ts`), which answers a scope-narrowed token as anonymous — the RPC pair excepted, its dispatcher gating each method
63
70
  - `rate_limit?: RateLimitKey` — metadata only (`'ip' | 'account' | 'both'`); auto-derives 429
64
71
  - `errors?: ReadonlyArray<RestErrorDef>` — the handler's own error definitions (`rest_error`); joins the route error map beside the derived and middleware ones
65
72
  - `jsonrpc?: boolean` — the route answers JSON-RPC envelopes, not REST bodies; set by `create_rpc_endpoint`, read by the DEV error check and `assert_response_matches_spec`
73
+ - `response_headers?: Record<string, string>` — static headers every answer of the route carries once a request reaches it: its own validation and guard refusals, the handler's result of any kind, and the error catch's 500 and 503. Checked at registration by the raw result's header rules, and refusing the names a body or the framing owns (`ROUTE_RAW_REFUSED_HEADERS`, `Content-Type`, `Content-Length`). A result that names one of them itself is refused at the prepare. Listed on `AppSurfaceRoute`. For a header true of every answer — the RPC `GET`'s `Cache-Control: no-store` — not for a success's own (the fact routes' hardening headers stay on the bytes answer)
66
74
  - `transaction?: boolean` — declarative transaction wrapping (see below)
67
75
 
68
76
  Every schema field takes a `@fuzdev/fuz_schema` schema (`AnySchema`),
@@ -80,26 +88,62 @@ kept by `loose_object`.
80
88
 
81
89
  ### Handlers and results
82
90
 
83
- A handler returns a result, not a `Response`; `apply_route_specs` builds the
84
- response from it (`to_route_response`) inside any wrapping transaction, so a
85
- result that can't become one (a bare `Response`, a result no factory made
86
- such as `{ok: true}` without `value`, `undefined`, a body `JSON.stringify`
87
- refuses) throws before the commit, rolls back, and discards the post-commit
88
- effects:
89
-
90
- - `route_ok(value)` — `value` as JSON at 200.
91
+ A handler returns a result — data, never a `Response` — and the spine builds
92
+ the response in two steps around the commit. `prepare_route_response` runs
93
+ inside any wrapping transaction and checks everything that could fail: a
94
+ result that can't become a response (a bare `Response`, a result no factory
95
+ made such as `{ok: true}` without `value`, `undefined`, a body
96
+ `JSON.stringify` refuses, a raw result breaking a rule below) throws there,
97
+ rolls back, and discards the post-commit effects. `emit_route_response` runs
98
+ after the commit and is the one place a route result becomes a `Response`, through
99
+ the context, so the context's prepared headers — the clearing `Set-Cookie`
100
+ for an invalid session cookie — are on every one. Nothing a handler returned
101
+ reaches the wire for work that didn't commit: a login whose commit fails
102
+ answers its 500 with no cookie.
103
+
104
+ - `route_ok(value, {set_cookie?})` — `value` as JSON at 200. `set_cookie` is
105
+ the success's own `Set-Cookie` lines (`session_cookie_header`,
106
+ `clear_session_cookie_header` of `auth/session_cookie.ts`), written after
107
+ the context's, in order; a failure can't carry one.
91
108
  - `route_fail(def, fields?)` — `{error: def.code, ...fields}` at `def.status`,
92
109
  with the headers `def` derives (`REST_RATE_LIMIT_EXCEEDED`'s `Retry-After`).
93
110
  `fields` is absent for a bare code, optional when every field is, required
94
111
  when any is.
95
- - `route_raw(response)` — the response as it is, at any status: an empty body,
96
- bytes, a stream, an SSE response, a JSON-RPC envelope (`c.body(json, status,
97
- {'Content-Type': 'application/json'})`). A `Response` typed as `c.json`'s
98
- return is refused: a JSON answer of the route's own is `route_ok` or
99
- `route_fail`.
100
-
101
- Headers and cookies a handler sets on `c` (`c.header`, `setCookie`) before it
102
- returns carry onto the response the framework builds. A failure is plain data
112
+ - `route_raw({status, headers?, body?})` — an answer the route spells itself:
113
+ an empty body, text, bytes, a stream, a JSON-RPC envelope. The prepare
114
+ refuses what would not send as written: a status outside 200–599; a header
115
+ in `ROUTE_RAW_REFUSED_HEADERS` (`Set-Cookie` and the hop-by-hop names), a
116
+ name twice in any case, an empty value; a body without a `Content-Type`,
117
+ or on a 204, 205 or 304; a `Content-Length` that is not a canonical
118
+ decimal within the safe integer range (no leading zero), that rides a 204
119
+ or 205, or that, for a text or bytes body, is not its byte length (it is
120
+ free with no body or a stream — a size answered without the bytes); a
121
+ locked stream, detached bytes, a view left out of bounds by a shrunk
122
+ resizable buffer, a `Response`. A stream that was read and released can't
123
+ be told from a fresh one. A stream body's `cancel` must release its
124
+ source: the spine cancels one the route ends up not answering with —
125
+ refused, rolled back by a failed commit, or asked for by `HEAD`.
126
+ - `route_sse(stream)` — an event stream the handler opened with
127
+ `route.open_sse(options)`, so it exists before the handler admits it to a
128
+ registry. Opening writes nothing on the context: the response is built at
129
+ the emit with `SSE_RESPONSE_HEADERS`, and a stream the route opened and
130
+ did not answer with (another result, a throw) is closed. A stream another
131
+ request opened is refused.
132
+
133
+ **`HEAD`.** Hono serves `HEAD` by running the `GET` handler and dropping the
134
+ body unread, so the spine releases what a stream holds: the emit cancels a
135
+ raw stream body and closes an SSE stream (its `on_close` listeners run, its
136
+ registry drops it), then answers the prepared status and headers with no
137
+ body — an SSE answer without its `Connection: keep-alive`, so the
138
+ connection can end. A handler has no `HEAD` branch to write.
139
+
140
+ A response that can't be built after the commit — the runtime refusing what
141
+ the prepare let through — is logged naming the route and answered by the
142
+ error catch's 500; the work stays committed. A handler holds no Hono
143
+ context, so it writes nothing on one: what a response carries is the
144
+ result, the spec's `response_headers`, and what middleware prepared
145
+ (`src/test/route_modules_hono_free.test.ts` holds every module that defines
146
+ a route to importing nothing from Hono and building no `Response`). A failure is plain data
103
147
  (`ok: false`), so domain code and shared helpers fail without the context and
104
148
  a handler forwards one (`if (!result.ok) return result`). A thrown error is
105
149
  still the error catch's.
@@ -122,21 +166,80 @@ mint, so a spec literal doesn't typecheck; a spread of a spec keeps the brand
122
166
  and is not checked again (the DEV error check covers a rewritten `auth` or
123
167
  `errors`). At runtime they return the spec, or the shape with its handler.
124
168
 
125
- ### `RouteContext` — per-request deps
169
+ ### `RouteContext` — what a handler gets
126
170
 
127
- The second handler argument is always a `RouteContext`:
171
+ The handler's one argument, built by `apply_route_specs` from the Hono
172
+ context:
128
173
 
129
174
  ```typescript
130
- interface RouteContext {
175
+ interface RouteContext<TAuth, TInput, TParams, TQuery> {
176
+ // shared with `ActionContext`, same names and types
177
+ auth: TAuth; // RequestContext | null, narrowed by the spec's `auth`
178
+ client_ip: string; // resolved by the trusted proxy; 'unknown' without one
179
+ signal: AbortSignal; // aborts on client disconnect
131
180
  db: Db; // transaction-scoped when `transaction: true`, pool-level otherwise
132
181
  pending_effects: Array<Promise<void>>; // eager pool writes already in flight
133
182
  post_commit_effects: Array<() => void | Promise<void>>; // deferred — push via `emit_after_commit`
183
+ // REST's own
184
+ credential: ResolvedAuth | null; // what the auth middleware resolved
185
+ connection_ip: string | null; // the socket's peer, as the runtime spells it
186
+ input: TInput; // validated body; null for a route with none
187
+ params: TParams; // validated path params; undefined without a `params` schema
188
+ query: TQuery; // validated query; undefined without a `query` schema
189
+ has_test_context_preset: boolean; // a harness pre-built `auth`; never in production
190
+ request: Request; // the raw request: a `raw_body` stream, the undecoded URL
191
+ query_pairs: QueryPairsRead; // the query decoded strictly, or why it doesn't decode; a key read with `query_first(pairs, key)`
192
+ read_json_body: () => Promise<JsonBodyResult>; // the once-per-request JSON read
193
+ header_lines: (name: string) => Array<string>; // a header as the lines sent
194
+ close_connection: () => void; // answer with `Connection: close`
195
+ open_sse: <T = unknown>(options?: RouteOpenSseOptions) => SseStream<T>; // the stream a `route_sse` answers with
134
196
  }
135
197
  ```
136
198
 
199
+ - **Typed from the spec.** `define_route` and `attach_route_handler` type
200
+ `input`, `params` and `query` from the route's schemas (`TypedRouteContext`),
201
+ so `route.params.x` on a route with no `params` is a type error, and
202
+ `auth` from the route's `auth` through `RequestContextForAuth`
203
+ (`auth/request_context.ts`) — the one conditional `rpc_action`'s
204
+ `HandlerForSpec` also narrows by: an actor-required route gets a
205
+ `RequestActorContext`, an account-required one a `RequestContext`,
206
+ anything else `RequestContext | null`. A handler of a required tier is
207
+ wrapped where it is defined and throws rather than run without the
208
+ context its type promises (a spread spec whose `auth` was loosened
209
+ answers 500, not a handler running on `null`).
210
+ - **`route.credential`** is the whole resolved credential. A
211
+ `reads_credential` route never reads the account off it: it calls
212
+ `get_public_account_id(route)` (`auth/request_context.ts`), which answers
213
+ a scope-narrowed API token as the anonymous caller
214
+ (`src/test/auth/token_scope_surface_census.test.ts` holds every route
215
+ module to that).
216
+ - **`route.connection_ip`** is the TCP peer, never a forwarded address, and
217
+ not normalized (`::ffff:127.0.0.1` stays that) — for a route that admits
218
+ loopback callers only. `null` when the trusted-proxy middleware isn't
219
+ mounted.
220
+ - **Reading the request.** `query_pairs` is the query string read by
221
+ `read_query_pairs` (`http/request_target.ts`): every pair percent-decoded,
222
+ or the reason it doesn't decode — a handler that reads an undeclared key
223
+ refuses an undecodable query in its own shape (the RPC `GET` its envelope)
224
+ and reads a key with `query_first(pairs, key)` — first occurrence, `''`
225
+ for a key with no value, the cross-implementation contract the
226
+ `query_shape` suite pins;
227
+ `read_json_body()` shares the one body read with the authorization phase
228
+ and input validation; `request` is the raw `Request`, whose body is
229
+ already used on a route the pipeline read a JSON input for.
230
+ - **`route.close_connection()`** makes the spine answer with
231
+ `Connection: close` whatever the result, the error catch's answer
232
+ included, so the runtime drops a connection whose request body nothing
233
+ will read. A raw result can't carry the header itself, and an SSE answer
234
+ after it is refused.
137
235
  - **`route.db`** — handler's main DB work. Wrapped in a transaction when `transaction: true` (default for non-GET); routes that opt out (`transaction: false`, e.g. signup / bootstrap) get the pool here directly and may call `route.db.transaction(...)` for their own scope.
138
236
  - **`route.pending_effects`** — direct push for eager fire-and-forget pool writes (audit, api-token usage tracking).
139
237
  - **`route.post_commit_effects`** — do not push directly; reach for `emit_after_commit` from `http/pending_effects.ts`. The helper pushes a thunk that the flush middleware invokes after the handler returns, closing the microtask-ordering window that an eager `Promise.resolve().then(fn)` leaves open inside the wrapping `db.transaction`.
238
+ - **`route.open_sse(options)`** — opens the event stream the route answers with (`route_sse(stream)`) through the opener `apply_route_specs` was given (`create_sse_stream`, wired by `create_app_server`). It writes nothing on the context; a stream not answered with is closed. Without an opener it throws.
239
+
240
+ Middleware, the authorization phase and the WebSocket upgrade still run on
241
+ the Hono context and read it through their own helpers (`get_client_ip(c)`,
242
+ `get_resolved_auth(c)`, `get_header_lines(c, name)`).
140
243
 
141
244
  Audit rows run through the bound `AppDeps.audit` capability — see
142
245
  `auth/CLAUDE.md` §Audit emitter. `await deps.audit.emit(route, input)` writes
@@ -157,15 +260,20 @@ wrapper). See `auth/signup_routes.ts`.
157
260
 
158
261
  ### Validation pipeline (per-route middleware order)
159
262
 
160
- `apply_route_specs` assembles the following middleware chain per spec:
263
+ `apply_route_specs(app, specs, resolve_auth_guards, log, db, {authorize?, open_sse?})` — `open_sse` is the `RouteSseOpener`, `create_sse_stream` in the assembled server.
264
+
265
+ `apply_route_specs` assembles the following middleware chain per spec, behind
266
+ one stage that writes the spec's `response_headers` on the context (when it
267
+ declares any), so every stage after it answers with them:
161
268
 
162
- 1. **Params validation** — `spec.params` → `validated_params` context var; mismatch returns 400 `ERROR_INVALID_ROUTE_PARAMS` with `issues`
163
- 2. **Query validation** — `spec.query` → `validated_query`; mismatch returns 400 `ERROR_INVALID_QUERY_PARAMS`
269
+ 0. **Content type** — every `POST` route: `is_post_content_type_refused(read_content_type(...), raw_body)` → 415 `ERROR_UNSUPPORTED_CONTENT_TYPE`, before any credential or body read (`http/simple_request.ts`)
270
+ 1. **Params validation** — `spec.params` → `validated_params` context var; mismatch returns 400 `ERROR_INVALID_ROUTE_PARAMS` with `issues`. Each param is decoded strictly from the raw target first (`read_request_route_params`): an escape that doesn't decode is the same 400 with no `issues`, whatever the schema
271
+ 2. **Query validation** — `spec.query` → `validated_query`; mismatch returns 400 `ERROR_INVALID_QUERY_PARAMS`. The query is decoded strictly first (`read_request_query_pairs`): an escape that doesn't decode, in any key or value, is the same 400
164
272
  3. **Pre-authorization auth guards** — every gate that reads only what the auth middleware set, in coarse-to-fine order: `require_auth` (401 `ERROR_AUTHENTICATION_REQUIRED`) when `auth.account === 'required'` or `auth.actor === 'required'`; `require_credential_types(types)` (403 `ERROR_CREDENTIAL_TYPE_REQUIRED` with `required_credential_types: ReadonlyArray<string>`) when `auth.credential_types?.length`; `require_token_scope(capability)` (403 `ERROR_TOKEN_SCOPE_REQUIRED` with `required_scope`, the token-scope refusal) when `auth.required_scope` names a capability. All fire before any body parsing — so a caller they refuse never sees route-shape information from input parse failures — and before actor resolution, so a wrong channel costs no DB work and never learns account state (e.g. that the account is multi-actor). The `AuthGuardResolver` (e.g. `fuz_auth_guard_resolver` from `auth/auth_guard_resolver.ts`) returns this set as `pre_authorization: Array<MiddlewareHandler>`.
165
273
  4. **Authorization phase** — when `spec.auth.actor !== 'none'`, resolves the acting actor against the resolved credential's account (`get_resolved_auth`, set by the auth middleware) plus the `acting` selector (`validated_query.acting` on GETs; read off the raw body on mutations, since body validation now runs after the gates), builds `RequestContext` via `build_request_context`, and sets `REQUEST_CONTEXT_KEY`. When `auth.account !== 'none' && auth.actor === 'none'`, an account-only context is built. Resolution failures return 400 `ERROR_ACTOR_REQUIRED` (with `available[]`) or `ERROR_ACTOR_NOT_ON_ACCOUNT` (or 500 `ERROR_NO_ACTORS_ON_ACCOUNT` on signup-invariant violation, 500 `ERROR_ACCOUNT_VANISHED` on torn account/actor reads after a successful resolve). Public routes (`account: 'none' && actor: 'none'`) skip this phase entirely.
166
274
  5. **Post-authorization auth guards** — `require_role(roles)` (403 `ERROR_INSUFFICIENT_PERMISSIONS` with `required_roles: ReadonlyArray<string>`) when `auth.roles?.length`. The only gate in this phase, because it is the only one that reads `REQUEST_CONTEXT_KEY` (populated by step 4) rather than the auth middleware's own context vars. Multi-role specs admit any-of via `has_any_scoped_role(ctx, roles, null)`.
167
- 6. **Input validation** — JSON body parsed (`read_json_body`) + validated; mismatch returns 400 `ERROR_INVALID_JSON_BODY` (not JSON, or JSON the Rust spine refuses — `parse_json_text`) or `ERROR_INVALID_REQUEST_BODY` (schema failure with `issues`). Every schema refusal's `issues` are `WireIssue`s (`to_wire_issues`, `schema_issues.ts`), sent under DEV only (`dev_only`). Skipped on GET and on a null input (`is_null_schema`: `literal(null)`). The validated input lands on `c.var.validated_input`.
168
- 7. **Handler** — wrapped in transaction when `use_transaction` (see above), receives `RouteContext`; its result becomes the response (`to_route_response`)
275
+ 6. **Input validation** — JSON body parsed (`read_json_body`) + validated; mismatch returns 400 `ERROR_INVALID_JSON_BODY` (not JSON, or JSON the Rust spine refuses — `parse_json_text`) or `ERROR_INVALID_REQUEST_BODY` (schema failure with `issues`). Every schema refusal's `issues` are `WireIssue`s (`to_wire_issues`, `schema_issues.ts`), sent under DEV only (`dev_only`). Skipped on a null input (`is_null_schema`: `literal(null)`), which every `GET` has — `apply_route_specs` refuses a `GET` with any other input. The validated input lands on `c.var.validated_input`.
276
+ 7. **Handler** — wrapped in transaction when `use_transaction` (see above), receives `RouteContext`; its result is prepared inside the transaction and emitted after the commit (`prepare_route_response`, `emit_route_response`)
169
277
  8. **Error catch** — catches a thrown JSON-RPC error (`ThrownJsonrpcError`, recognized by brand through `to_thrown_jsonrpc_error`, so one from a second fuz_app copy maps too; a foreign error class carrying a JSON-RPC `code` falls to the generic path) → maps to HTTP status + the flat REST error body (`{error: <reason>, message?, ...rest_data}`); catches generic `Error` → 500 `{error: 'internal_error', message?}` (message only in DEV). The reason string comes from `err.data.reason` when set (consumer-supplied canonical reason override) or from `jsonrpc_error_code_to_name(err.code)` (e.g. `-32003 → 'not_found'`). The flat shape matches what middleware and direct handlers emit — REST callers see one envelope across every emit site, while the JSON-RPC dispatcher keeps its own `{jsonrpc, id, error: {code, message, data}}` envelope on the RPC mount.
170
278
  9. **DEV-only output validation** — a 2xx JSON body against `spec.output` (see below); error responses are the outer DEV error check's
171
279
 
@@ -182,11 +290,8 @@ GETs.
182
290
 
183
291
  Duplicate `method path` pairs throw at registration.
184
292
 
185
- Validated values are accessed via `get_route_input(c, schema)`,
186
- `get_route_params(c, schema)`, `get_route_query(c, schema)` — pass the
187
- matching schema, and the return type infers as `Infer<typeof schema>`.
188
- Each helper has a `<T>(c)` overload (no schema arg) for callers without the
189
- schema in scope.
293
+ A handler reads the validated values as `route.input`, `route.params` and
294
+ `route.query`, typed from the spec's schemas.
190
295
 
191
296
  ### DEV-only output + error validation
192
297
 
@@ -197,7 +302,8 @@ are the contract with external callers.
197
302
  `esm-env`, each in one place:
198
303
 
199
304
  - **Output** — `wrap_output_validation`, per route: a 2xx JSON body against `spec.output`. Skips non-`application/json` responses so SSE doesn't hang on `.json()`.
200
- - **Errors** — `create_dev_route_error_check` (`http/dev_route_error_check.ts`), one outer middleware `create_app_server` mounts outermost (`app.use('*')`, first after `onError`), so it sees what every layer answers — a middleware's refusal (body limit, origin, auth guards) as much as a handler's or the error catch's. After the request it finds the route with Hono's own router (`create_route_lookup`: the `SmartRouter` over a `RegExpRouter` and a `TrieRouter` that `new Hono()` builds, the route specs added in mount order, the first match the route, `HEAD` read as `GET`) and checks a JSON body at 400 and up against the route's error map (`check_route_error`, `http/route_error_check.ts`): a status the map lacks logs `Undeclared error status (S): METHOD path`, a body off the status's schema `Error schema mismatch (S): METHOD path`. Always accepted: a 500 `internal_error` and a 503 `service_unavailable` (`ALWAYS_ACCEPTED_ERRORS`, which the catch layers answer on any route). On a `jsonrpc` route (the pair `create_rpc_endpoint` builds) a JSON-RPC error envelope is skipped (`is_jsonrpc_error_response`): the endpoint answers its refusals as envelopes, which no REST error definition describes, and the dispatch core checks its own outputs. On any other route an envelope-shaped body is checked. Skipped: non-JSON responses (`is_json_response`, the gate both checks run), and a request no route spec matches — an unmatched path's 404 is Hono's plain text, with no JSON convention to hold it to. `assert_response_matches_spec` runs the same `check_route_error`.
305
+ - **Errors** — `create_dev_route_error_check` (`http/dev_route_error_check.ts`), one outer middleware `create_app_server` mounts outermost (`app.use('*')`, first after `onError`), so it sees what every layer answers — a middleware's refusal (body limit, origin, auth guards) as much as a handler's or the error catch's. After the request it finds the route with Hono's own router (`create_route_lookup`: the `SmartRouter` over a `RegExpRouter` and a `TrieRouter` that `new Hono()` builds, the route specs added in mount order, the first match the route, `HEAD` read as `GET`) and checks a JSON body at 400 and up against the route's error map (`check_route_error`, `http/route_error_check.ts`): a status the map lacks logs `Undeclared error status (S): METHOD path`, a body off the status's schema `Error schema mismatch (S): METHOD path`. Always accepted: a 500 `internal_error` and a 503 `service_unavailable` (`ALWAYS_ACCEPTED_ERRORS`, which the catch layers answer on any route). On a `jsonrpc` route (the pair `create_rpc_endpoint` builds) a JSON-RPC error envelope is skipped (`is_jsonrpc_error_response`): the endpoint answers its refusals as envelopes, which no REST error definition describes, and the dispatch core checks its own outputs. On any other route an envelope-shaped body is checked. Skipped: non-JSON responses (`is_json_response`, the gate both checks run), and a request no route spec matches — the 405 and 404s of the unmatched-route handler (`server/unmatched_route.ts`) are no route's answer. `assert_response_matches_spec` runs the same `check_route_error`.
306
+ - **The first `Set-Cookie`** — `create_dev_set_cookie_check` (`http/dev_set_cookie_check.ts`), mounted beside the error check: when a middleware recorded the line it put first on the response (`EXPECTED_FIRST_SET_COOKIE_KEY` — the session middleware's clear of an invalid cookie), the answer's first `Set-Cookie` must be that line, else it logs naming the method and path. It reaches what the route system doesn't build — a consumer's `post_route_middleware`, a raw Hono route, a `transform_middleware` layer answering with its own `Response` or replacing the context's cookie. An accepted WebSocket upgrade's placeholder is skipped.
201
307
  - **Logs on mismatch, returns the response unchanged** — never throws (a throw inside the error check, its logger's included, is swallowed), never mutates the body
202
308
 
203
309
  Production short-circuits: `wrap_output_validation` returns the handler
@@ -246,7 +352,7 @@ are both kept, a union of their bodies. The result, `RouteErrorMap`, holds the
246
352
  definitions (`defs`) and the status map they group into (`schemas`):
247
353
 
248
354
  1. **Derived** — `derive_route_errors({method, auth, has_input?, has_params?, has_query?, rate_limit?})`, narrowed to the slots the route has:
249
- - a body — `input` not null, `method` not `GET` (the input middleware skips a `GET`) → 400 `invalid_request_body`, `invalid_json_body`
355
+ - a body — `input` not null, `method` not `GET` (registration refuses a `GET` with an input; a surface built from specs alone derives none for one) → 400 `invalid_request_body`, `invalid_json_body`
250
356
  - `params` → 400 `invalid_route_params`; `query` → 400 `invalid_query_params`
251
357
  - `auth.actor !== 'none'` → 400 `actor_required`, `actor_not_on_account`, 500 `no_actors_on_account`, `account_vanished` — what the dispatcher's authorization phase emits on routes whose input declares `acting?: ActingActor` (per registry-time invariant 2)
252
358
  - `auth.account === 'required'` or `auth.actor === 'required'` → 401 `authentication_required` (`REST_AUTHENTICATION_REQUIRED`), the only body the pre-authorization gate answers
@@ -303,6 +409,7 @@ confirmation.
303
409
  - **Auth**: `ERROR_AUTHENTICATION_REQUIRED`, `ERROR_INSUFFICIENT_PERMISSIONS`, `ERROR_CREDENTIAL_TYPE_REQUIRED`, `ERROR_RATE_LIMIT_EXCEEDED`, `ERROR_INVALID_CREDENTIALS`, `ERROR_PAYLOAD_TOO_LARGE`, `ERROR_INVALID_CONTENT_LENGTH`
304
410
  - **Origin + bearer**: `ERROR_FORBIDDEN_ORIGIN`, `ERROR_INVALID_TOKEN`, `ERROR_ACCOUNT_NOT_FOUND`
305
411
  - **Keeper/daemon**: `ERROR_KEEPER_ACCOUNT_NOT_FOUND`
412
+ - **Routing + gates**: `ERROR_METHOD_NOT_ALLOWED`, `ERROR_ROUTE_NOT_FOUND` (+ `NOT_FOUND_TEXT`, the plain-text 404 outside `/api/`), `ERROR_FORBIDDEN_HOST`, `ERROR_UNSUPPORTED_CONTENT_TYPE`
306
413
  - **Bootstrap**: `ERROR_ALREADY_BOOTSTRAPPED`, `ERROR_TOKEN_FILE_MISSING`
307
414
  - **Signup/invites**: `ERROR_NO_MATCHING_INVITE`, `ERROR_SIGNUP_CONFLICT`, `ERROR_INVITE_NOT_FOUND`, `ERROR_INVITE_DUPLICATE`, `ERROR_INVITE_ACCOUNT_EXISTS_USERNAME`, `ERROR_INVITE_ACCOUNT_EXISTS_EMAIL`
308
415
  - **Admin**: `ERROR_ROLE_NOT_WEB_GRANTABLE`, `ERROR_ROLE_GRANT_NOT_FOUND`, `ERROR_INVALID_EVENT_TYPE`
@@ -430,8 +537,8 @@ CSRF is handled by `SameSite: strict` on session cookies (`auth/session_middlewa
430
537
  - `parse_allowed_origins(raw)` — comma-separated entries → `Result<{origins: Array<RegExp>}, {errors: Array<AllowedOriginsError>}>`; every refused entry is reported (`{kind, index, entry}`, 1-based), a blank value is `{kind: 'no_origins'}`
431
538
  - `OriginPatternErrorKind` / `AllowedOriginsErrorKind` — the refusal kinds, fuz_schema `one_of`s whose `def` is the names, wire names shared with the Rust spine; `ALLOWED_ORIGINS_ERROR_MESSAGES` the reason per kind, `format_allowed_origins_error` one refusal as a boot-error line (entry quoted and escaped)
432
539
  - `should_allow_origin(origin, patterns)` — case-insensitive match; a value that isn't visible ASCII matches nothing
433
- - `verify_request_source(allowed_patterns, carve_outs?)` — Hono handler: `Origin` present → must match allowlist or 403 `ERROR_FORBIDDEN_ORIGIN`; no `Origin` → allow through (curl, CLI, token auth is primary control). A repeated `Origin` reaches it joined (`a, b`) and is refused. A request whose path a `carve_outs` entry (`MiddlewareCarveOut`, `{path, reason}`) matches passes unchecked
434
- - `is_browser_context(c)` — true when `Origin` or `Referer` is present (`!== undefined`, so empty-string counts). The bearer + daemon-token middleware discard their credential when true; twin of the Rust spine's `bearer_auth::is_browser_context`. Distinct from `verify_request_source` (allowlist gate) — this only detects browser context
540
+ - `verify_request_source(allowed_patterns, carve_outs?)` — Hono handler: one `Origin` line → must match allowlist or 403 `ERROR_FORBIDDEN_ORIGIN`; no `Origin` → allow through (curl, CLI, token auth is primary control). It reads the lines the client sent (`read_origin` over `get_header_lines`), so an empty or repeated `Origin` is refused on every runtime, a WebSocket upgrade on `@hono/node-server` included. A request whose path a `carve_outs` entry (`MiddlewareCarveOut`, `{path, reason}`) matches passes unchecked
541
+ - `is_browser_context(origin_lines, referer_lines)` (`http/request_headers.ts`) — true when the request carries any `Origin` or `Referer` line, an empty one included. The bearer + daemon-token middleware discard their credential when true; twin of the Rust spine's `fuz_http::is_browser_context`. Distinct from `verify_request_source` (allowlist gate) — this only detects browser context
435
542
 
436
543
  **Origin-only by design.** Fetch spec mandates `Origin` on every unsafe
437
544
  method, so a real browser request on any state-changing surface always
@@ -116,9 +116,9 @@ export interface RouteAuth {
116
116
  *
117
117
  * - `surface:<name>` — a non-RPC surface, refused to every narrowed token
118
118
  * whatever its method list says (token scoping's rule that a narrowed
119
- * token is RPC-only). `surface:audit_stream`, `surface:fact_bare`,
120
- * `surface:account_verify`, and `surface:app_surface` are the spine's
121
- * route-spec ones; a consumer names its own without registering it.
119
+ * token is RPC-only). `surface:audit_stream`, `surface:fact_bare`, and
120
+ * `surface:app_surface` are the spine's route-spec ones; a consumer names
121
+ * its own without registering it.
122
122
  *
123
123
  * The `rpc:<method>` arm of that vocabulary is the dispatcher's per-method
124
124
  * gate, which a route never reaches, so a route may not declare it.
@@ -97,7 +97,7 @@ export const create_ready_route_spec = (options) => {
97
97
  input: literal(null),
98
98
  output: object({ ready: literal(true) }),
99
99
  errors: [REST_SCHEMA_DRIFT, REST_DB_UNREACHABLE],
100
- handler: async (_c, route) => {
100
+ handler: async (route) => {
101
101
  try {
102
102
  const drift = await check_schema_drift(route.db, options.expected);
103
103
  if (drift.ok)
@@ -78,9 +78,10 @@ export declare const NON_BROWSABLE_TABLES: ReadonlyArray<string>;
78
78
  * surface. It is also part of how revocation propagates: the revocation guard
79
79
  * (`create_revocation_guard`) closes live connections by listening to audit
80
80
  * events, so a raw row delete here is invisible to it.
81
- * `bootstrap_lock` — deleting the singleton leaves `check_bootstrap_status`
82
- * advertising an open bootstrap window on the next boot that
83
- * `bootstrap_account.ts`'s atomic flip then always refuses.
81
+ * - `bootstrap_lock` — deleting the singleton closes bootstrap for good:
82
+ * `check_bootstrap_status` reads a missing row as unavailable (logged as an
83
+ * error), so a database that has not bootstrapped never can until the row
84
+ * is restored.
84
85
  * - `app_settings` — deleting the singleton makes every settings read throw.
85
86
  * - `schema_version` — the migration tracker. Already refused by the
86
87
  * single-column-primary-key rule (its key is `(namespace, name)`), but that
@@ -1 +1 @@
1
- {"version":3,"file":"db_routes.d.ts","sourceRoot":"","sources":["../../src/lib/http/db_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAsBtD,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAmD,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAelG;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB;AAwCD,sDAAsD;AACtD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,sDAAsD;AACtD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAKrD,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAKrD,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;;;;;OAMG;IACH,KAAK,EAAE;QACN,SAAS,EAAE,CAAC,KAAK,EAAE;YAClB,UAAU,EAAE,qBAAqB,CAAC;YAClC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;YACxB,EAAE,EAAE,MAAM,CAAC;YACX,QAAQ,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,MAAM,CAAC;gBAAC,EAAE,EAAE,MAAM,CAAA;aAAE,CAAC;SAC3D,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,8EAA8E;IAC9E,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C;AA2CD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,WAAW,EACjB,SAAS,cAAc,KACrB,KAAK,CAAC,SAAS,CA8VjB,CAAC"}
1
+ {"version":3,"file":"db_routes.d.ts","sourceRoot":"","sources":["../../src/lib/http/db_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAsBtD,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAc/D;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB;AAwCD,sDAAsD;AACtD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,sDAAsD;AACtD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAKrD,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAKrD,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;;;;;OAMG;IACH,KAAK,EAAE;QACN,SAAS,EAAE,CAAC,KAAK,EAAE;YAClB,UAAU,EAAE,qBAAqB,CAAC;YAClC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;YACxB,EAAE,EAAE,MAAM,CAAC;YACX,QAAQ,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,MAAM,CAAC;gBAAC,EAAE,EAAE,MAAM,CAAA;aAAE,CAAC;SAC3D,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,8EAA8E;IAC9E,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C;AA2CD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,WAAW,EACjB,SAAS,cAAc,KACrB,KAAK,CAAC,SAAS,CA8VjB,CAAC"}
@@ -12,12 +12,11 @@
12
12
  import { meta } from '@fuzdev/fuz_schema/meta.ts';
13
13
  import { array, boolean, integer, literal, loose_object, max_value, min_value, nullable, number, object, pipe, record, regex, safe_integer, string, transform, unknown, with_default } from '@fuzdev/fuz_schema/schema.ts';
14
14
  import { ActingActor } from '../primitive_schemas.js';
15
- import { define_route, get_route_params, get_route_query } from './route_spec.js';
15
+ import { define_route } from './route_spec.js';
16
16
  import { route_fail, route_ok } from './route_result.js';
17
17
  import { REST_DATABASE_CONNECTION_FAILED, REST_FOREIGN_KEY_VIOLATION, REST_ROW_NOT_FOUND, REST_TABLE_NO_PRIMARY_KEY, REST_TABLE_NOT_DELETABLE, REST_TABLE_NOT_FOUND } from './error_schemas.js';
18
18
  import { assert_valid_sql_identifier, VALID_SQL_IDENTIFIER } from '../db/sql_identifier.js';
19
19
  import { pg_error_code } from '../db/pg_error.js';
20
- import { get_client_ip } from './client_ip.js';
21
20
  import { emit_after_commit } from './pending_effects.js';
22
21
  // the spellings `query_int` reads as an integer: decimal digits with an optional sign
23
22
  const QUERY_INT_PATTERN = /^[+-]?\d+$/;
@@ -84,9 +83,10 @@ export const NON_BROWSABLE_TABLES = Object.freeze([
84
83
  * surface. It is also part of how revocation propagates: the revocation guard
85
84
  * (`create_revocation_guard`) closes live connections by listening to audit
86
85
  * events, so a raw row delete here is invisible to it.
87
- * `bootstrap_lock` — deleting the singleton leaves `check_bootstrap_status`
88
- * advertising an open bootstrap window on the next boot that
89
- * `bootstrap_account.ts`'s atomic flip then always refuses.
86
+ * - `bootstrap_lock` — deleting the singleton closes bootstrap for good:
87
+ * `check_bootstrap_status` reads a missing row as unavailable (logged as an
88
+ * error), so a database that has not bootstrapped never can until the row
89
+ * is restored.
90
90
  * - `app_settings` — deleting the singleton makes every settings read throw.
91
91
  * - `schema_version` — the migration tracker. Already refused by the
92
92
  * single-column-primary-key rule (its key is `(namespace, name)`), but that
@@ -179,7 +179,7 @@ export const create_db_route_specs = (deps, options) => {
179
179
  input: literal(null),
180
180
  output: loose_object({ connected: boolean }),
181
181
  errors: [REST_DATABASE_CONNECTION_FAILED],
182
- handler: async (_c, route) => {
182
+ handler: async (route) => {
183
183
  try {
184
184
  await route.db.query('SELECT 1');
185
185
  // Deliberately schema-wide (not allowlist-filtered): the count
@@ -218,7 +218,7 @@ export const create_db_route_specs = (deps, options) => {
218
218
  tables: array(object({ name: string, row_count: Count }))
219
219
  }),
220
220
  transaction: true,
221
- handler: async (_c, route) => {
221
+ handler: async (route) => {
222
222
  await set_statement_timeout(route.db);
223
223
  // Existence still comes from `information_schema` — a listed table
224
224
  // that hasn't migrated in yet is silently absent, not a 500.
@@ -266,9 +266,9 @@ export const create_db_route_specs = (deps, options) => {
266
266
  deletable: boolean
267
267
  }),
268
268
  transaction: true,
269
- handler: async (c, route) => {
270
- const { name } = get_route_params(c);
271
- const { offset, limit } = get_route_query(c);
269
+ handler: async (route) => {
270
+ const { name } = route.params;
271
+ const { offset, limit } = route.query;
272
272
  // Allowlist gate, masked: an unlisted (or floor) table answers
273
273
  // exactly like one that doesn't exist.
274
274
  if (!(await gate_browsable_table(route.db, name))) {
@@ -338,8 +338,8 @@ export const create_db_route_specs = (deps, options) => {
338
338
  REST_ROW_NOT_FOUND,
339
339
  REST_FOREIGN_KEY_VIOLATION
340
340
  ],
341
- handler: async (c, route) => {
342
- const { name, id } = get_route_params(c);
341
+ handler: async (route) => {
342
+ const { name, id } = route.params;
343
343
  // Same allowlist gate and masking as the detail route — an
344
344
  // unbrowsable table exposes no rows to delete either.
345
345
  if (!(await gate_browsable_table(route.db, name))) {
@@ -403,8 +403,8 @@ export const create_db_route_specs = (deps, options) => {
403
403
  // `emit_pool`, not the transaction-routing `emit`. Account-grain
404
404
  // attribution — the browser is a raw storage surface, so no actor
405
405
  // is claimed.
406
- const account_id = c.var.request_context?.account.id ?? null;
407
- const ip = get_client_ip(c);
406
+ const account_id = route.auth.account.id;
407
+ const ip = route.client_ip;
408
408
  emit_after_commit(route, () => deps.audit.emit_pool({
409
409
  event_type: 'db_admin_row_delete',
410
410
  account_id,
@@ -11,9 +11,9 @@
11
11
  * status the map lacks, or a body off the status's schema, is logged. A 500
12
12
  * `internal_error` and a 503 `service_unavailable` are always accepted, a
13
13
  * JSON-RPC error envelope on a `jsonrpc` route is not a REST error body, a
14
- * non-JSON response is skipped, and so is a request no route spec matches
15
- * (an unmatched path's 404 is Hono's plain text, no JSON convention to hold
16
- * it to).
14
+ * non-JSON response is skipped, and so is a request no route spec matches:
15
+ * the unmatched-route handler's `405` and `404` (`server/unmatched_route.ts`)
16
+ * answer for no route, so no route's map can hold them.
17
17
  *
18
18
  * Logs, never throws — a throw inside it, its logger's included, is swallowed
19
19
  * — and leaves the response unchanged. Outside DEV
@@ -37,6 +37,9 @@ import { type RouteErrorMap, type RouteErrorMapSpec } from './route_errors.js';
37
37
  * lookup has a `RegExpRouter`. Where the two differ the cost is a missed DEV
38
38
  * log, and rarely a wrong route.
39
39
  *
40
+ * The path is matched as the app's router matches it: the raw request path
41
+ * (`get_request_path`), nothing percent-decoded.
42
+ *
40
43
  * @param routes - the routes, in the order they were mounted
41
44
  * @param to_value - what to keep beside each route
42
45
  * @returns a function from a request's method and path to the matched route's
@@ -1 +1 @@
1
- {"version":3,"file":"dev_route_error_check.d.ts","sourceRoot":"","sources":["../../src/lib/http/dev_route_error_check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAK9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAQtD,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEpG;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACjE,CAAC,EAED,QAAQ,aAAa,CAAC,MAAM,CAAC,EAC7B,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,KAC5B,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,CAclD,CAAC;AAEF,iEAAiE;AACjE,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,kDAAkD;AAClD,MAAM,WAAW,yBAAyB;IACzC,6CAA6C;IAC7C,WAAW,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;IACnD,oFAAoF;IACpF,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACrD,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,yBAAyB,KAChC,iBAAiB,GAAG,IA2CtB,CAAC"}
1
+ {"version":3,"file":"dev_route_error_check.d.ts","sourceRoot":"","sources":["../../src/lib/http/dev_route_error_check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAK9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAQtD,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEpG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACjE,CAAC,EAED,QAAQ,aAAa,CAAC,MAAM,CAAC,EAC7B,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,KAC5B,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,CAclD,CAAC;AAEF,iEAAiE;AACjE,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,kDAAkD;AAClD,MAAM,WAAW,yBAAyB;IACzC,6CAA6C;IAC7C,WAAW,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;IACnD,oFAAoF;IACpF,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACrD,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,yBAAyB,KAChC,iBAAiB,GAAG,IA2CtB,CAAC"}
@@ -11,9 +11,9 @@
11
11
  * status the map lacks, or a body off the status's schema, is logged. A 500
12
12
  * `internal_error` and a 503 `service_unavailable` are always accepted, a
13
13
  * JSON-RPC error envelope on a `jsonrpc` route is not a REST error body, a
14
- * non-JSON response is skipped, and so is a request no route spec matches
15
- * (an unmatched path's 404 is Hono's plain text, no JSON convention to hold
16
- * it to).
14
+ * non-JSON response is skipped, and so is a request no route spec matches:
15
+ * the unmatched-route handler's `405` and `404` (`server/unmatched_route.ts`)
16
+ * answer for no route, so no route's map can hold them.
17
17
  *
18
18
  * Logs, never throws — a throw inside it, its logger's included, is swallowed
19
19
  * — and leaves the response unchanged. Outside DEV
@@ -40,6 +40,9 @@ import { get_route_error_map } from './route_errors.js';
40
40
  * lookup has a `RegExpRouter`. Where the two differ the cost is a missed DEV
41
41
  * log, and rarely a wrong route.
42
42
  *
43
+ * The path is matched as the app's router matches it: the raw request path
44
+ * (`get_request_path`), nothing percent-decoded.
45
+ *
43
46
  * @param routes - the routes, in the order they were mounted
44
47
  * @param to_value - what to keep beside each route
45
48
  * @returns a function from a request's method and path to the matched route's
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The DEV-only `Set-Cookie` check: an outer middleware that logs a response
3
+ * which does not lead with the `Set-Cookie` line a middleware put on the
4
+ * context for every response.
5
+ *
6
+ * A middleware that writes a line on the context's prepared headers — the
7
+ * session middleware's clear of a stale cookie — records it under
8
+ * `EXPECTED_FIRST_SET_COOKIE_KEY`. Every response built through the context
9
+ * then carries it first: every route result, which the spine emits there,
10
+ * and every middleware and catch layer answering with `c.json` or `c.text`.
11
+ * A response built past the context does not — a consumer's
12
+ * `post_route_middleware`, a `transform_middleware` layer, or a raw Hono route
13
+ * answering with a `Response` it made — and only a check of the finished
14
+ * response can see that, so this one runs after the request: when a line was
15
+ * recorded, the response's first `Set-Cookie` must be that line, else it logs
16
+ * an error naming the method and path, and whether the response carries no
17
+ * `Set-Cookie` or another one first.
18
+ *
19
+ * One response is skipped: an accepted WebSocket upgrade's placeholder. No
20
+ * runtime adapter hands Hono a `101` — `@hono/node-server`'s and `@hono/bun`'s
21
+ * `upgradeWebSocket` return a bodiless `200` and the runtime writes the real
22
+ * `101` itself — so the check recognizes the placeholder by its shape: a
23
+ * request with `Upgrade: websocket` answered `200` with no body. That
24
+ * placeholder is no response a client reads, and no layer builds it through
25
+ * the context. The cost: a raw route answering a bodiless `200` to an upgrade
26
+ * request it did not accept goes unchecked too.
27
+ *
28
+ * Generic: it knows a line and an order, nothing of sessions. A sibling of
29
+ * the DEV error check (`http/dev_route_error_check.ts`) rather than part of
30
+ * it, as that one reads the route a request reached and only its error
31
+ * answers, where this one holds every answer of every path, routed or not.
32
+ * Mounted outermost beside it by `create_app_server`. Logs, never throws — a
33
+ * throw inside it, its logger's included, is swallowed — and leaves the
34
+ * response unchanged. Outside DEV `create_dev_set_cookie_check` returns `null`
35
+ * and nothing is mounted.
36
+ *
37
+ * @module
38
+ */
39
+ import type { MiddlewareHandler } from 'hono';
40
+ import type { Logger } from '@fuzdev/fuz_util/log.ts';
41
+ /** Options for `create_dev_set_cookie_check`. */
42
+ export interface DevSetCookieCheckOptions {
43
+ /** Receives each response that does not lead with the recorded line. */
44
+ log: Logger;
45
+ }
46
+ /**
47
+ * Build the DEV `Set-Cookie` check (module doc), or `null` outside DEV.
48
+ *
49
+ * @param options - the logger
50
+ * @returns the middleware to mount outermost, or `null` in production
51
+ */
52
+ export declare const create_dev_set_cookie_check: (options: DevSetCookieCheckOptions) => MiddlewareHandler | null;
53
+ //# sourceMappingURL=dev_set_cookie_check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev_set_cookie_check.d.ts","sourceRoot":"","sources":["../../src/lib/http/dev_set_cookie_check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAE9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAItD,iDAAiD;AACjD,MAAM,WAAW,wBAAwB;IACxC,wEAAwE;IACxE,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GACvC,SAAS,wBAAwB,KAC/B,iBAAiB,GAAG,IAkCtB,CAAC"}