@fuzdev/fuz_app 0.180.0 → 0.182.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 (389) hide show
  1. package/dist/actions/CLAUDE.md +38 -20
  2. package/dist/actions/action_rpc.d.ts +25 -6
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +56 -48
  5. package/dist/actions/action_types.d.ts +31 -13
  6. package/dist/actions/action_types.d.ts.map +1 -1
  7. package/dist/actions/action_types.js +1 -1
  8. package/dist/actions/notification_sender.d.ts +83 -0
  9. package/dist/actions/notification_sender.d.ts.map +1 -0
  10. package/dist/actions/notification_sender.js +85 -0
  11. package/dist/actions/perform_action.d.ts +13 -4
  12. package/dist/actions/perform_action.d.ts.map +1 -1
  13. package/dist/actions/perform_action.js +27 -18
  14. package/dist/actions/register_action_ws.d.ts +20 -2
  15. package/dist/actions/register_action_ws.d.ts.map +1 -1
  16. package/dist/actions/register_action_ws.js +17 -5
  17. package/dist/actions/ws_socket_session.d.ts +3 -0
  18. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  19. package/dist/actions/ws_socket_session.js +3 -2
  20. package/dist/auth/CLAUDE.md +84 -59
  21. package/dist/auth/account_actions.d.ts.map +1 -1
  22. package/dist/auth/account_actions.js +30 -3
  23. package/dist/auth/account_queries.d.ts +213 -2
  24. package/dist/auth/account_queries.d.ts.map +1 -1
  25. package/dist/auth/account_queries.js +255 -2
  26. package/dist/auth/account_route_schema.d.ts +26 -16
  27. package/dist/auth/account_route_schema.d.ts.map +1 -1
  28. package/dist/auth/account_route_schema.js +10 -24
  29. package/dist/auth/account_routes.d.ts +5 -7
  30. package/dist/auth/account_routes.d.ts.map +1 -1
  31. package/dist/auth/account_routes.js +110 -89
  32. package/dist/auth/admin_actions.d.ts.map +1 -1
  33. package/dist/auth/admin_actions.js +117 -25
  34. package/dist/auth/api_token_queries.d.ts +29 -12
  35. package/dist/auth/api_token_queries.d.ts.map +1 -1
  36. package/dist/auth/api_token_queries.js +42 -27
  37. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  38. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  39. package/dist/auth/audit_log_routes.d.ts +1 -1
  40. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  41. package/dist/auth/audit_log_routes.js +10 -12
  42. package/dist/auth/audit_log_schema.js +4 -4
  43. package/dist/auth/bearer_auth.d.ts +4 -3
  44. package/dist/auth/bearer_auth.d.ts.map +1 -1
  45. package/dist/auth/bearer_auth.js +37 -32
  46. package/dist/auth/bootstrap_account.d.ts +65 -37
  47. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_account.js +115 -66
  49. package/dist/auth/bootstrap_route_schema.d.ts +6 -2
  50. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  51. package/dist/auth/bootstrap_route_schema.js +7 -2
  52. package/dist/auth/bootstrap_routes.d.ts +50 -33
  53. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  54. package/dist/auth/bootstrap_routes.js +109 -87
  55. package/dist/auth/bootstrap_token_store.d.ts +60 -0
  56. package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
  57. package/dist/auth/bootstrap_token_store.js +39 -0
  58. package/dist/auth/credential_headers.d.ts +71 -0
  59. package/dist/auth/credential_headers.d.ts.map +1 -0
  60. package/dist/auth/credential_headers.js +100 -0
  61. package/dist/auth/daemon_token.d.ts +13 -1
  62. package/dist/auth/daemon_token.d.ts.map +1 -1
  63. package/dist/auth/daemon_token.js +14 -2
  64. package/dist/auth/daemon_token_middleware.d.ts +10 -11
  65. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  66. package/dist/auth/daemon_token_middleware.js +39 -30
  67. package/dist/auth/deps.d.ts +10 -11
  68. package/dist/auth/deps.d.ts.map +1 -1
  69. package/dist/auth/invite_queries.d.ts +18 -0
  70. package/dist/auth/invite_queries.d.ts.map +1 -1
  71. package/dist/auth/invite_queries.js +24 -0
  72. package/dist/auth/request_context.d.ts +97 -76
  73. package/dist/auth/request_context.d.ts.map +1 -1
  74. package/dist/auth/request_context.js +93 -104
  75. package/dist/auth/resolved_auth.d.ts +10 -5
  76. package/dist/auth/resolved_auth.d.ts.map +1 -1
  77. package/dist/auth/resolved_auth.js +2 -2
  78. package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
  79. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  80. package/dist/auth/role_grant_offer_action_specs.js +5 -3
  81. package/dist/auth/role_grant_offer_actions.d.ts +7 -11
  82. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  83. package/dist/auth/role_grant_offer_actions.js +97 -106
  84. package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
  85. package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
  86. package/dist/auth/role_grant_offer_ddl.js +9 -2
  87. package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
  88. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  89. package/dist/auth/role_grant_offer_notifications.js +75 -22
  90. package/dist/auth/role_grant_offer_queries.d.ts +143 -9
  91. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  92. package/dist/auth/role_grant_offer_queries.js +266 -66
  93. package/dist/auth/role_grant_offer_schema.js +1 -1
  94. package/dist/auth/role_grant_queries.d.ts +57 -10
  95. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  96. package/dist/auth/role_grant_queries.js +81 -22
  97. package/dist/auth/role_grant_sql.d.ts +21 -0
  98. package/dist/auth/role_grant_sql.d.ts.map +1 -1
  99. package/dist/auth/role_grant_sql.js +21 -0
  100. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  101. package/dist/auth/self_service_role_actions.js +9 -2
  102. package/dist/auth/session_cookie.d.ts +105 -25
  103. package/dist/auth/session_cookie.d.ts.map +1 -1
  104. package/dist/auth/session_cookie.js +124 -15
  105. package/dist/auth/session_middleware.d.ts +83 -54
  106. package/dist/auth/session_middleware.d.ts.map +1 -1
  107. package/dist/auth/session_middleware.js +92 -66
  108. package/dist/auth/session_queries.d.ts +95 -14
  109. package/dist/auth/session_queries.d.ts.map +1 -1
  110. package/dist/auth/session_queries.js +98 -19
  111. package/dist/auth/signup_route_schema.d.ts +5 -5
  112. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  113. package/dist/auth/signup_route_schema.js +4 -4
  114. package/dist/auth/signup_routes.d.ts.map +1 -1
  115. package/dist/auth/signup_routes.js +17 -14
  116. package/dist/auth/standard_rpc_actions.d.ts +6 -19
  117. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  118. package/dist/auth/standard_rpc_actions.js +5 -6
  119. package/dist/auth/token_scope.d.ts +6 -8
  120. package/dist/auth/token_scope.d.ts.map +1 -1
  121. package/dist/auth/token_scope.js +6 -9
  122. package/dist/dev/setup.d.ts +6 -1
  123. package/dist/dev/setup.d.ts.map +1 -1
  124. package/dist/dev/setup.js +42 -34
  125. package/dist/hono_context.d.ts +21 -0
  126. package/dist/hono_context.d.ts.map +1 -1
  127. package/dist/hono_context.js +17 -0
  128. package/dist/http/CLAUDE.md +156 -48
  129. package/dist/http/auth_shape.d.ts +4 -4
  130. package/dist/http/common_routes.js +1 -1
  131. package/dist/http/db_routes.d.ts +4 -3
  132. package/dist/http/db_routes.d.ts.map +1 -1
  133. package/dist/http/db_routes.js +14 -14
  134. package/dist/http/dev_route_error_check.d.ts +6 -3
  135. package/dist/http/dev_route_error_check.d.ts.map +1 -1
  136. package/dist/http/dev_route_error_check.js +6 -3
  137. package/dist/http/dev_set_cookie_check.d.ts +53 -0
  138. package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
  139. package/dist/http/dev_set_cookie_check.js +80 -0
  140. package/dist/http/error_schemas.d.ts +45 -22
  141. package/dist/http/error_schemas.d.ts.map +1 -1
  142. package/dist/http/error_schemas.js +53 -26
  143. package/dist/http/header_lines.d.ts +42 -0
  144. package/dist/http/header_lines.d.ts.map +1 -0
  145. package/dist/http/header_lines.js +80 -0
  146. package/dist/http/host.d.ts +12 -9
  147. package/dist/http/host.d.ts.map +1 -1
  148. package/dist/http/host.js +25 -20
  149. package/dist/http/origin.d.ts +7 -22
  150. package/dist/http/origin.d.ts.map +1 -1
  151. package/dist/http/origin.js +11 -25
  152. package/dist/http/proxy.d.ts +1 -0
  153. package/dist/http/proxy.d.ts.map +1 -1
  154. package/dist/http/proxy.js +3 -0
  155. package/dist/http/request_headers.d.ts +95 -0
  156. package/dist/http/request_headers.d.ts.map +1 -0
  157. package/dist/http/request_headers.js +110 -0
  158. package/dist/http/request_target.d.ts +134 -0
  159. package/dist/http/request_target.d.ts.map +1 -0
  160. package/dist/http/request_target.js +193 -0
  161. package/dist/http/route_error_check.d.ts +4 -11
  162. package/dist/http/route_error_check.d.ts.map +1 -1
  163. package/dist/http/route_error_check.js +4 -21
  164. package/dist/http/route_result.d.ts +127 -23
  165. package/dist/http/route_result.d.ts.map +1 -1
  166. package/dist/http/route_result.js +97 -19
  167. package/dist/http/route_spec.d.ts +299 -83
  168. package/dist/http/route_spec.d.ts.map +1 -1
  169. package/dist/http/route_spec.js +548 -71
  170. package/dist/http/simple_request.d.ts +19 -14
  171. package/dist/http/simple_request.d.ts.map +1 -1
  172. package/dist/http/simple_request.js +17 -29
  173. package/dist/http/surface.d.ts +2 -0
  174. package/dist/http/surface.d.ts.map +1 -1
  175. package/dist/http/surface.js +4 -1
  176. package/dist/realtime/outbound_budget.d.ts +1 -2
  177. package/dist/realtime/outbound_budget.d.ts.map +1 -1
  178. package/dist/realtime/outbound_budget.js +1 -2
  179. package/dist/realtime/sse.d.ts +47 -17
  180. package/dist/realtime/sse.d.ts.map +1 -1
  181. package/dist/realtime/sse.js +115 -93
  182. package/dist/realtime/sse_constants.d.ts +7 -1
  183. package/dist/realtime/sse_constants.d.ts.map +1 -1
  184. package/dist/realtime/sse_constants.js +12 -1
  185. package/dist/realtime/sse_registry.d.ts +3 -3
  186. package/dist/realtime/sse_registry.js +3 -3
  187. package/dist/runtime/deps.d.ts +20 -4
  188. package/dist/runtime/deps.d.ts.map +1 -1
  189. package/dist/runtime/mock.d.ts +7 -1
  190. package/dist/runtime/mock.d.ts.map +1 -1
  191. package/dist/runtime/mock.js +33 -3
  192. package/dist/runtime/node.d.ts.map +1 -1
  193. package/dist/runtime/node.js +2 -1
  194. package/dist/runtime/secure_file.d.ts +71 -10
  195. package/dist/runtime/secure_file.d.ts.map +1 -1
  196. package/dist/runtime/secure_file.js +91 -11
  197. package/dist/server/app_backend.d.ts +0 -8
  198. package/dist/server/app_backend.d.ts.map +1 -1
  199. package/dist/server/app_backend.js +4 -4
  200. package/dist/server/app_server.d.ts +54 -33
  201. package/dist/server/app_server.d.ts.map +1 -1
  202. package/dist/server/app_server.js +69 -41
  203. package/dist/server/serve_fact_route.d.ts +3 -3
  204. package/dist/server/serve_fact_route.d.ts.map +1 -1
  205. package/dist/server/serve_fact_route.js +59 -55
  206. package/dist/server/static.d.ts +20 -0
  207. package/dist/server/static.d.ts.map +1 -1
  208. package/dist/server/static.js +56 -8
  209. package/dist/server/unmatched_route.d.ts +42 -0
  210. package/dist/server/unmatched_route.d.ts.map +1 -0
  211. package/dist/server/unmatched_route.js +64 -0
  212. package/dist/testing/CLAUDE.md +406 -1202
  213. package/dist/testing/app_server.d.ts +3 -1
  214. package/dist/testing/app_server.d.ts.map +1 -1
  215. package/dist/testing/app_server.js +5 -9
  216. package/dist/testing/auth_apps.d.ts.map +1 -1
  217. package/dist/testing/auth_apps.js +3 -2
  218. package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
  219. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  220. package/dist/testing/cross_backend/account_lifecycle.js +320 -6
  221. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
  222. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
  224. package/dist/testing/cross_backend/capabilities.d.ts +68 -5
  225. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  226. package/dist/testing/cross_backend/capabilities.js +20 -4
  227. package/dist/testing/cross_backend/cell_gated_create.js +1 -1
  228. package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
  229. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  230. package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
  231. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  232. package/dist/testing/cross_backend/conformance_table.js +179 -23
  233. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  234. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
  235. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  236. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
  237. package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
  238. package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
  239. package/dist/testing/cross_backend/credential_conformance.js +296 -0
  240. package/dist/testing/cross_backend/credential_conformance.json +1284 -0
  241. package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
  242. package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
  243. package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
  244. package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
  245. package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
  246. package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
  247. package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
  248. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
  249. package/dist/testing/cross_backend/credential_wire.js +188 -0
  250. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  251. package/dist/testing/cross_backend/default_backend_configs.js +22 -2
  252. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
  253. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  254. package/dist/testing/cross_backend/default_spine_surface.js +3 -7
  255. package/dist/testing/cross_backend/differential.d.ts +1 -1
  256. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  257. package/dist/testing/cross_backend/differential.js +3 -2
  258. package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
  259. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  260. package/dist/testing/cross_backend/differential_normalize.js +11 -5
  261. package/dist/testing/cross_backend/full_spine_mount.d.ts +4 -10
  262. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  263. package/dist/testing/cross_backend/full_spine_mount.js +11 -4
  264. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  265. package/dist/testing/cross_backend/identity_parity.js +4 -0
  266. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  267. package/dist/testing/cross_backend/in_process_setup.js +78 -4
  268. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  269. package/dist/testing/cross_backend/login_security.js +13 -10
  270. package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
  271. package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
  272. package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
  273. package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
  274. package/dist/testing/cross_backend/request_header_conformance.js +196 -0
  275. package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
  276. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
  277. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
  278. package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
  279. package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
  280. package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
  281. package/dist/testing/cross_backend/request_target_conformance.js +186 -0
  282. package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
  283. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
  284. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
  285. package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
  286. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  287. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
  288. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
  289. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  290. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +185 -31
  291. package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
  292. package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
  293. package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
  294. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
  295. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  296. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
  297. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  298. package/dist/testing/cross_backend/session_cap.js +82 -34
  299. package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
  300. package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
  301. package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
  302. package/dist/testing/cross_backend/session_login.d.ts +24 -0
  303. package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
  304. package/dist/testing/cross_backend/session_login.js +31 -0
  305. package/dist/testing/cross_backend/setup.d.ts +117 -0
  306. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  307. package/dist/testing/cross_backend/setup.js +193 -9
  308. package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
  309. package/dist/testing/cross_backend/simple_request.js +5 -0
  310. package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
  311. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  312. package/dist/testing/cross_backend/spine_suites.js +88 -5
  313. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  314. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  315. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  316. package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
  317. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  318. package/dist/testing/cross_backend/sse_round_trip.js +205 -64
  319. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  320. package/dist/testing/cross_backend/testing_backdoor.js +5 -2
  321. package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
  322. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
  323. package/dist/testing/cross_backend/testing_credential_read.js +175 -0
  324. package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
  325. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  326. package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
  327. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  328. package/dist/testing/cross_backend/token_lifetime.js +58 -2
  329. package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
  330. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  331. package/dist/testing/cross_backend/transport_composition.js +13 -10
  332. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  333. package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
  334. package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
  335. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  336. package/dist/testing/cross_backend/ws_endpoint.js +19 -2
  337. package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
  338. package/dist/testing/cross_backend/ws_role_gated.js +2 -3
  339. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  340. package/dist/testing/cross_backend/ws_round_trip.js +28 -12
  341. package/dist/testing/cross_backend/xfail.d.ts +44 -11
  342. package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
  343. package/dist/testing/cross_backend/xfail.js +68 -23
  344. package/dist/testing/data_exposure.d.ts.map +1 -1
  345. package/dist/testing/data_exposure.js +4 -3
  346. package/dist/testing/integration.d.ts +1 -2
  347. package/dist/testing/integration.d.ts.map +1 -1
  348. package/dist/testing/integration.js +14 -8
  349. package/dist/testing/integration_helpers.d.ts +50 -3
  350. package/dist/testing/integration_helpers.d.ts.map +1 -1
  351. package/dist/testing/integration_helpers.js +87 -9
  352. package/dist/testing/middleware.d.ts +3 -1
  353. package/dist/testing/middleware.d.ts.map +1 -1
  354. package/dist/testing/middleware.js +14 -7
  355. package/dist/testing/resolved_auth.d.ts +3 -1
  356. package/dist/testing/resolved_auth.d.ts.map +1 -1
  357. package/dist/testing/resolved_auth.js +4 -4
  358. package/dist/testing/round_trip.d.ts +6 -2
  359. package/dist/testing/round_trip.d.ts.map +1 -1
  360. package/dist/testing/round_trip.js +17 -6
  361. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  362. package/dist/testing/rpc_envelope_cases.js +7 -0
  363. package/dist/testing/rpc_helpers.d.ts +4 -2
  364. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  365. package/dist/testing/rpc_helpers.js +6 -1
  366. package/dist/testing/rpc_round_trip.d.ts +13 -2
  367. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  368. package/dist/testing/rpc_round_trip.js +25 -6
  369. package/dist/testing/schema_generators.d.ts +2 -2
  370. package/dist/testing/schema_generators.d.ts.map +1 -1
  371. package/dist/testing/schema_generators.js +4 -4
  372. package/dist/testing/stubs.d.ts +2 -2
  373. package/dist/testing/stubs.d.ts.map +1 -1
  374. package/dist/testing/stubs.js +13 -10
  375. package/dist/testing/transports/fetch_transport.d.ts +6 -3
  376. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  377. package/dist/testing/transports/fetch_transport.js +31 -19
  378. package/dist/testing/transports/raw_http.d.ts +61 -1
  379. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  380. package/dist/testing/transports/raw_http.js +61 -1
  381. package/dist/testing/transports/ws_raw_client.d.ts +20 -0
  382. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  383. package/dist/testing/transports/ws_raw_client.js +10 -4
  384. package/dist/testing/transports/ws_transport.d.ts +21 -1
  385. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  386. package/dist/testing/transports/ws_transport.js +58 -20
  387. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  388. package/dist/testing/ws_round_trip.js +8 -4
  389. package/package.json +1 -1
@@ -71,14 +71,14 @@
71
71
  * Auth shape on the cell-scoped route is `{account: 'none', actor: 'none'}`
72
72
  * — the dispatcher's authorization phase is skipped for pure-public routes,
73
73
  * so the handler builds the `RequestContext` itself from the resolved account
74
- * id (`get_public_account_id`, over what the `/api/*` auth middleware set) by
74
+ * (`get_public_account`, over what the `/api/*` auth middleware set) by
75
75
  * resolving the caller's single actor and loading their role_grants.
76
76
  * Unauthed callers pass through with `req_ctx: null` and are admitted only by
77
77
  * a `cell.visibility === 'public'` cell whose `moderation` admits an audience (unmoderated or
78
78
  * `'approved'`). Multi-actor accounts fall through with `req_ctx: null`
79
79
  * — there's no `acting?` slot on a pure-public route, so multi-actor
80
80
  * callers are treated as anonymous. A scope-narrowed API token is treated as
81
- * anonymous too, not refused (`get_public_account_id`): a narrowed token
81
+ * anonymous too, not refused (`get_public_account`): a narrowed token
82
82
  * reaches no non-RPC surface, but on a route that admits anonymous callers
83
83
  * a 403 would enforce nothing — the holder drops the `Authorization` header and
84
84
  * re-reads every public cell anyway.
@@ -135,10 +135,10 @@ import { Readable } from 'node:stream';
135
135
  import { join } from 'node:path';
136
136
  import { ActingActor, FactHashSchema, Uuid } from '../primitive_schemas.js';
137
137
  import { literal, object } from '@fuzdev/fuz_schema/schema.ts';
138
- import { build_request_context, get_public_account_id, get_request_context, has_scoped_role } from '../auth/request_context.js';
138
+ import { build_request_context, get_public_account, has_scoped_role } from '../auth/request_context.js';
139
139
  import { ROLE_ADMIN } from '../auth/role_schema.js';
140
140
  import { query_active_actors_by_account } from '../auth/account_queries.js';
141
- import { define_route, get_route_params } from '../http/route_spec.js';
141
+ import { define_route } from '../http/route_spec.js';
142
142
  import { route_fail, route_raw } from '../http/route_result.js';
143
143
  import { REST_INTERNAL_ERROR } from '../http/error_schemas.js';
144
144
  import { query_get_fact, query_get_fact_meta } from '../db/fact_queries.js';
@@ -173,15 +173,16 @@ const cell_fact_params_schema = object({ cell_id: Uuid, hash: FactHashSchema });
173
173
  * Returns 404 when the fact's metadata is missing, its embedded bytes have
174
174
  * vanished (a race), or its disk file is missing, so the response shape is
175
175
  * identical whether the fact is genuinely absent or merely unviewable; any
176
- * other failure to open the disk file answers a logged 500. HEAD on a disk
177
- * fact opens the file (so it answers the same statuses) and closes it again,
178
- * sending headers only.
176
+ * other failure to open the disk file answers a logged 500. A disk fact's body
177
+ * is a stream over the open file, whose cancel closes it: a `HEAD`, which
178
+ * opens the file and so answers the same statuses, is answered with the
179
+ * headers alone and the stream cancelled by the spine (`emit_route_response`).
179
180
  */
180
- const serve_fact_bytes = async (c, route, hash, config) => {
181
+ const serve_fact_bytes = async (route, hash, config) => {
181
182
  const { facts_dir, x_accel, log } = config;
182
183
  const meta = await query_get_fact_meta({ db: route.db }, hash);
183
184
  if (!meta) {
184
- return route_raw(c.body(null, 404));
185
+ return route_raw({ status: 404 });
185
186
  }
186
187
  const content_type = meta.content_type ?? 'application/octet-stream';
187
188
  const size = String(meta.size);
@@ -191,39 +192,46 @@ const serve_fact_bytes = async (c, route, hash, config) => {
191
192
  if (!row || row.bytes === null) {
192
193
  // Race: meta said embedded but bytes vanished. Treat as not-found.
193
194
  log.warn(`serve_fact: embedded bytes missing for ${hash} (meta said embedded, row=${row ? 'present' : 'null'})`);
194
- return route_raw(c.body(null, 404));
195
+ return route_raw({ status: 404 });
195
196
  }
196
197
  const bytes = to_uint8(row.bytes);
197
- return route_raw(c.body(bytes, 200, {
198
- 'Content-Type': content_type,
199
- 'Content-Length': size,
200
- 'Cache-Control': FACT_CACHE_CONTROL,
201
- ...FACT_SECURITY_HEADERS
202
- }));
198
+ return route_raw({
199
+ status: 200,
200
+ headers: {
201
+ 'Content-Type': content_type,
202
+ 'Content-Length': size,
203
+ 'Cache-Control': FACT_CACHE_CONTROL,
204
+ ...FACT_SECURITY_HEADERS
205
+ },
206
+ body: bytes
207
+ });
203
208
  }
204
209
  // External — defense-in-depth re-validate the URL before trusting it
205
210
  // to address the filesystem: its shape, then that it is this hash's file
206
211
  const parsed = parse_file_fact_url(meta.external_url);
207
212
  if (!parsed) {
208
213
  log.error(`serve_fact: external_url for ${hash} is not a file:<shard>/<rest> URL; answering 404`);
209
- return route_raw(c.body(null, 404));
214
+ return route_raw({ status: 404 });
210
215
  }
211
216
  if (!file_fact_url_addresses(parsed, hash)) {
212
217
  log.error(`serve_fact: external_url for ${hash} addresses another fact's file; answering 404`);
213
- return route_raw(c.body(null, 404));
218
+ return route_raw({ status: 404 });
214
219
  }
215
220
  const { shard, rest } = parsed;
216
221
  if (x_accel !== undefined) {
217
222
  // Production: hand off to nginx via the validated `internal;` facts location.
218
223
  // nginx answers with that location's own `add_header` set, not these
219
224
  // headers, which is why the validator requires the fact pair there.
220
- return route_raw(c.body(null, 200, {
221
- 'Content-Type': content_type,
222
- 'Content-Length': size,
223
- 'Cache-Control': FACT_CACHE_CONTROL,
224
- 'X-Accel-Redirect': `${x_accel.redirect_prefix}${shard}/${rest}`,
225
- ...FACT_SECURITY_HEADERS
226
- }));
225
+ return route_raw({
226
+ status: 200,
227
+ headers: {
228
+ 'Content-Type': content_type,
229
+ 'Content-Length': size,
230
+ 'Cache-Control': FACT_CACHE_CONTROL,
231
+ 'X-Accel-Redirect': `${x_accel.redirect_prefix}${shard}/${rest}`,
232
+ ...FACT_SECURITY_HEADERS
233
+ }
234
+ });
227
235
  }
228
236
  // Dev / tests: stream from disk. Open before committing the 200 so a
229
237
  // missing file answers 404 and any other open failure a logged 500, as the
@@ -236,7 +244,7 @@ const serve_fact_bytes = async (c, route, hash, config) => {
236
244
  catch (err) {
237
245
  if (err.code === 'ENOENT') {
238
246
  log.warn(`serve_fact: disk file for ${hash} is missing; answering 404`);
239
- return route_raw(c.body(null, 404));
247
+ return route_raw({ status: 404 });
240
248
  }
241
249
  log.error(`serve_fact: disk open for ${hash} failed`, err);
242
250
  return route_fail(REST_INTERNAL_ERROR);
@@ -247,21 +255,17 @@ const serve_fact_bytes = async (c, route, hash, config) => {
247
255
  'Cache-Control': FACT_CACHE_CONTROL,
248
256
  ...FACT_SECURITY_HEADERS
249
257
  };
250
- // Hono answers HEAD by running this GET handler and discarding the body
251
- // unread, so a stream built here would hold the handle open until GC
252
- if (c.req.method === 'HEAD') {
253
- await handle.close();
254
- return route_raw(c.body(null, 200, headers));
255
- }
258
+ // the stream's cancel closes the handle — what releases it on a `HEAD`, a
259
+ // refused answer, or a rolled-back one
256
260
  const web_stream = Readable.toWeb(handle.createReadStream());
257
- return route_raw(c.body(web_stream, 200, headers));
261
+ return route_raw({ status: 200, headers, body: web_stream });
258
262
  };
259
263
  /**
260
264
  * Resolve the caller's `RequestContext` on a pure-public route from the
261
- * session-middleware-set account id, read through `get_public_account_id`, so
262
- * a scope-narrowed API token returns `null` — downgraded to anonymous, not
263
- * refused (see the module doc). Twin of the Rust
264
- * `AuthGate::public_request_context`.
265
+ * account the auth middleware resolved, read through `get_public_account`,
266
+ * so a scope-narrowed API token returns `null` — downgraded to anonymous, not
267
+ * refused (see the module doc). The account is that row, not read again. Twin
268
+ * of the Rust `AuthGate::public_request_context`.
265
269
  *
266
270
  * Multi-actor accounts return `null` (no `acting?` slot on a public route to
267
271
  * disambiguate); single active-actor accounts resolve their actor and
@@ -270,15 +274,15 @@ const serve_fact_bytes = async (c, route, hash, config) => {
270
274
  * count (`query_active_actors_by_account`), matching the acting-actor
271
275
  * resolution path — a tombstoned actor is never resolvable here.
272
276
  */
273
- const build_public_request_context = async (c, route) => {
277
+ const build_public_request_context = async (route) => {
274
278
  // a narrowed token is the anonymous caller here, never a refusal
275
- const account_id = get_public_account_id(c);
276
- if (!account_id)
279
+ const account = get_public_account(route);
280
+ if (!account)
277
281
  return null;
278
- const actors = await query_active_actors_by_account({ db: route.db }, account_id);
282
+ const actors = await query_active_actors_by_account({ db: route.db }, account.id);
279
283
  if (actors.length !== 1)
280
284
  return null;
281
- return build_request_context({ db: route.db }, account_id, actors[0].id);
285
+ return build_request_context({ db: route.db }, account, actors[0]);
282
286
  };
283
287
  /**
284
288
  * Build the cell-scoped `GET /api/cells/:cell_id/facts/:hash` `RouteSpec`
@@ -293,7 +297,7 @@ const build_public_request_context = async (c, route) => {
293
297
  * other referrers.
294
298
  *
295
299
  * Pure-public auth — the handler builds the per-request `RequestContext`
296
- * from the resolved account id (`get_public_account_id`) and enforces
300
+ * from the resolved account id (`get_public_account`) and enforces
297
301
  * visibility per-reference.
298
302
  */
299
303
  export const create_serve_cell_fact_route_spec = (options) => {
@@ -309,18 +313,18 @@ export const create_serve_cell_fact_route_spec = (options) => {
309
313
  input: literal(null),
310
314
  // The body is a binary stream; no JSON output schema applies.
311
315
  output: literal(null),
312
- handler: async (c, route) => {
313
- const { cell_id, hash } = get_route_params(c);
316
+ handler: async (route) => {
317
+ const { cell_id, hash } = route.params;
314
318
  // Resolve the named cell. Missing / soft-deleted → 404 (masked).
315
319
  const cell = await query_cell_get({ db: route.db }, cell_id);
316
320
  if (!cell) {
317
- return route_raw(c.body(null, 404));
321
+ return route_raw({ status: 404 });
318
322
  }
319
323
  // Per-reference view check — scoped to *this* cell only. It runs
320
324
  // before the edge check, so a cell the caller can't view does the
321
325
  // same work, and answers the same 404, whether or not it references
322
326
  // the hash — the edge stays unobservable to a non-viewer.
323
- const req_ctx = await build_public_request_context(c, route);
327
+ const req_ctx = await build_public_request_context(route);
324
328
  // Unauthenticated callers skip the grant fetch entirely — no grant
325
329
  // can admit a null req_ctx (the only admit path is the
326
330
  // public-visibility branch in `can_view_cell`, which doesn't read
@@ -334,16 +338,16 @@ export const create_serve_cell_fact_route_spec = (options) => {
334
338
  if (!can_view_cell(req_ctx, cell, grants) &&
335
339
  !(await cell_steward_admits({ db: route.db }, req_ctx, cell))) {
336
340
  // 404 (not 403) so an unviewable cell→fact edge doesn't leak.
337
- return route_raw(c.body(null, 404));
341
+ return route_raw({ status: 404 });
338
342
  }
339
343
  // The cell→fact edge: the cell must actually reference the hash.
340
344
  // `cell.refs` is auto-derived from `data` on every write, so this is
341
345
  // the authoritative "does this cell reference these bytes" check.
342
346
  // Missing edge → 404 (masked), never "exists elsewhere".
343
347
  if (!cell.refs?.includes(hash)) {
344
- return route_raw(c.body(null, 404));
348
+ return route_raw({ status: 404 });
345
349
  }
346
- return serve_fact_bytes(c, route, hash, config);
350
+ return serve_fact_bytes(route, hash, config);
347
351
  }
348
352
  });
349
353
  };
@@ -392,18 +396,18 @@ export const create_serve_fact_route_spec = (options) => {
392
396
  input: literal(null),
393
397
  // The body is a binary stream; no JSON output schema applies.
394
398
  output: literal(null),
395
- handler: async (c, route) => {
396
- const { hash } = get_route_params(c);
399
+ handler: async (route) => {
400
+ const { hash } = route.params;
397
401
  // Defense-in-depth: the auth phase already gated this on the admin
398
402
  // role, but re-check the resolved context so a mounting/auth-shape
399
403
  // regression fails closed instead of serving by bare hash. Global
400
404
  // grant only — a scoped `admin` row must not read every fact. It
401
405
  // fires only on such a regression, so it fails loud as well.
402
- if (!has_scoped_role(get_request_context(c), ROLE_ADMIN, null)) {
406
+ if (!has_scoped_role(route.auth, ROLE_ADMIN, null)) {
403
407
  log.error('bare-hash fact read reached the handler without a global admin grant — the auth gate did not run');
404
- return route_raw(c.body(null, 404));
408
+ return route_raw({ status: 404 });
405
409
  }
406
- return serve_fact_bytes(c, route, hash, config);
410
+ return serve_fact_bytes(route, hash, config);
407
411
  }
408
412
  });
409
413
  };
@@ -6,6 +6,14 @@
6
6
  * - Step 2: `.html` fallback for clean URLs (`/about` → `/about.html`)
7
7
  * - Step 3 (optional): SPA fallback for client-side routes
8
8
  *
9
+ * The server routes on the raw request path (`get_request_path`), and a
10
+ * runtime's `serveStatic` refuses a path holding a `%` — it expects one the
11
+ * router already decoded. So a path with an escape is decoded here first
12
+ * (`to_static_file_path`) and handed to `serveStatic` as the file to serve;
13
+ * one with no escape goes to it as is. The SPA fallback names its file
14
+ * outright, so no step but the exact match hands `serveStatic` the request
15
+ * path.
16
+ *
9
17
  * @module
10
18
  */
11
19
  import type { MiddlewareHandler } from 'hono';
@@ -16,6 +24,8 @@ export interface ServeStaticOptions {
16
24
  root: string;
17
25
  rewriteRequestPath?: (path: string) => string;
18
26
  mimes?: Record<string, string>;
27
+ /** The file to serve, relative to `root`, in place of the request's path. */
28
+ path?: string;
19
29
  }
20
30
  /**
21
31
  * Factory function that creates a static file serving middleware.
@@ -23,6 +33,16 @@ export interface ServeStaticOptions {
23
33
  * Matches the signature of `serveStatic` from `@hono/node-server/serve-static` and `@hono/bun`.
24
34
  */
25
35
  export type ServeStaticFactory = (options: ServeStaticOptions) => MiddlewareHandler;
36
+ /**
37
+ * The file a raw request path names, each segment percent-decoded by
38
+ * `decodeURIComponent` — or `null`, no file, for an escape that doesn't
39
+ * decode, a segment that decodes to a `/` or a `%` (which `serveStatic`
40
+ * never served: it refused the router's decoded path holding either), and a
41
+ * decoded path holding a dot segment, an empty segment, a backslash or a NUL.
42
+ *
43
+ * @param path - the raw request path
44
+ */
45
+ export declare const to_static_file_path: (path: string) => string | null;
26
46
  /**
27
47
  * Create static file serving middleware for SvelteKit static builds.
28
48
  *
@@ -1 +1 @@
1
- {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/lib/server/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,iBAAiB,CAAC;AAMpF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACpC,cAAc,kBAAkB,EAChC,UAAU;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,KAC1F,KAAK,CAAC,iBAAiB,CAyBzB,CAAC"}
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/lib/server/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,iBAAiB,CAAC;AAKpF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAc3D,CAAC;AAMF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACpC,cAAc,kBAAkB,EAChC,UAAU;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,KAC1F,KAAK,CAAC,iBAAiB,CAmCzB,CAAC"}
@@ -6,8 +6,44 @@
6
6
  * - Step 2: `.html` fallback for clean URLs (`/about` → `/about.html`)
7
7
  * - Step 3 (optional): SPA fallback for client-side routes
8
8
  *
9
+ * The server routes on the raw request path (`get_request_path`), and a
10
+ * runtime's `serveStatic` refuses a path holding a `%` — it expects one the
11
+ * router already decoded. So a path with an escape is decoded here first
12
+ * (`to_static_file_path`) and handed to `serveStatic` as the file to serve;
13
+ * one with no escape goes to it as is. The SPA fallback names its file
14
+ * outright, so no step but the exact match hands `serveStatic` the request
15
+ * path.
16
+ *
9
17
  * @module
10
18
  */
19
+ /** A dot segment, an empty segment, a backslash or a NUL — what `serveStatic` refuses too, the NUL aside. */
20
+ const UNSAFE_STATIC_PATH = /(?:^|[/\\])\.{1,2}(?:$|[/\\])|[/\\]{2,}|\\|\0/;
21
+ /**
22
+ * The file a raw request path names, each segment percent-decoded by
23
+ * `decodeURIComponent` — or `null`, no file, for an escape that doesn't
24
+ * decode, a segment that decodes to a `/` or a `%` (which `serveStatic`
25
+ * never served: it refused the router's decoded path holding either), and a
26
+ * decoded path holding a dot segment, an empty segment, a backslash or a NUL.
27
+ *
28
+ * @param path - the raw request path
29
+ */
30
+ export const to_static_file_path = (path) => {
31
+ const segments = [];
32
+ for (const segment of path.split('/')) {
33
+ let decoded;
34
+ try {
35
+ decoded = decodeURIComponent(segment);
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ if (decoded.includes('/') || decoded.includes('%'))
41
+ return null;
42
+ segments.push(decoded);
43
+ }
44
+ const file = segments.join('/');
45
+ return UNSAFE_STATIC_PATH.test(file) ? null : file;
46
+ };
11
47
  /** Default SPA route filter — serves the SPA fallback for all paths except `/api` and `/api/…`. */
12
48
  const is_spa_route_default = (path) => path !== '/api' && !path.startsWith('/api/');
13
49
  /**
@@ -21,23 +57,35 @@ const is_spa_route_default = (path) => path !== '/api' && !path.startsWith('/api
21
57
  export const create_static_middleware = (serve_static, options) => {
22
58
  const root = options?.root ?? './build';
23
59
  const handlers = [];
24
- // Step 1: exact path match
25
- handlers.push(serve_static({ root }));
26
- // Step 2: .html fallback for clean URLs (/about → /about.html)
60
+ // Step 1: exact path match — a path with an escape decoded here, since
61
+ // `serve_static` refuses a `%`
62
+ const serve_exact = serve_static({ root });
27
63
  handlers.push(async (c, next) => {
28
64
  const path = c.req.path;
29
- if (path === '/' || path.includes('.'))
65
+ if (!path.includes('%'))
66
+ return serve_exact(c, next);
67
+ const file = to_static_file_path(path);
68
+ if (file === null)
69
+ return next();
70
+ return serve_static({ root, path: file })(c, next);
71
+ });
72
+ // Step 2: .html fallback for clean URLs (/about → /about.html)
73
+ handlers.push(async (c, next) => {
74
+ const file = to_static_file_path(c.req.path);
75
+ if (file === null || file === '/' || file.includes('.'))
30
76
  return next();
31
- return serve_static({ root, rewriteRequestPath: () => `${path}.html` })(c, next);
77
+ return serve_static({ root, path: `${file}.html` })(c, next);
32
78
  });
33
- // Step 3: optional SPA fallback for client-side routes
79
+ // Step 3: optional SPA fallback for client-side routes — the fallback named
80
+ // as the file, since `serve_static` refuses a request path holding a `%`
81
+ // (a client route's encoded param) before it reads a rewrite
34
82
  if (options?.spa_fallback) {
35
- const fallback = options.spa_fallback;
83
+ const serve_fallback = serve_static({ root, path: options.spa_fallback });
36
84
  const is_spa_route = options.is_spa_route ?? is_spa_route_default;
37
85
  handlers.push(async (c, next) => {
38
86
  if (!is_spa_route(c.req.path))
39
87
  return next();
40
- return serve_static({ root, rewriteRequestPath: () => fallback })(c, next);
88
+ return serve_fallback(c, next);
41
89
  });
42
90
  }
43
91
  return handlers;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * What a request no route answers gets: the assembled server's not-found
3
+ * handler, twin of the Rust spine's method fallback (`fuz_http::compose_stack`)
4
+ * and fallback group (`fuz_actions::server::unmatched_route_response`).
5
+ *
6
+ * - **A method its path doesn't serve** — the path matches a route under
7
+ * another method — is `405 {"error":"method_not_allowed"}` with `Allow`
8
+ * naming the methods the path serves, `HEAD` wherever `GET` is.
9
+ * - **A path no route serves** is `404`: under the auth scope
10
+ * (`AUTH_MIDDLEWARE_PATH`) the JSON `{"error":"route_not_found"}`, like
11
+ * every other refusal there; elsewhere the one plain-text `NOT_FOUND_TEXT`.
12
+ * A route that passed the request on (the WebSocket path's `GET` asking for
13
+ * no upgrade) answers the same.
14
+ *
15
+ * The methods a path serves are read from the app's own router — every route
16
+ * registered on it, a spec's, a WebSocket upgrade's or one a consumer adds to
17
+ * the assembled app, and never a middleware (`ALL`).
18
+ *
19
+ * Both decide on the raw path the router matched (`get_request_path`), so
20
+ * `/%61pi/x` is outside the auth scope, as on the Rust spine. Hono runs this
21
+ * after every middleware, so the host gate and the origin check answer
22
+ * first, and ahead of authentication, which only the routes enforce: an
23
+ * anonymous `PUT` on the RPC path is the 405, not a 401. The answer is built
24
+ * through the context, so the session middleware's clear of a cookie that
25
+ * doesn't verify rides it like any other.
26
+ *
27
+ * @module
28
+ */
29
+ import type { NotFoundHandler } from 'hono';
30
+ import type { Router } from 'hono/router';
31
+ import type { RouterRoute } from 'hono/types';
32
+ /** What `create_unmatched_route_handler` reads: the app's router (`app.router`). */
33
+ export type UnmatchedRouteRouter = Pick<Router<[unknown, RouterRoute]>, 'match'>;
34
+ /**
35
+ * Build the not-found handler (module doc) over the app's router.
36
+ *
37
+ * @param router - the assembled app's router, `app.router`, read at request
38
+ * time, so a route added after assembly is seen too
39
+ * @returns the handler for `app.notFound`
40
+ */
41
+ export declare const create_unmatched_route_handler: (router: UnmatchedRouteRouter) => NotFoundHandler;
42
+ //# sourceMappingURL=unmatched_route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unmatched_route.d.ts","sourceRoot":"","sources":["../../src/lib/server/unmatched_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgB9C,oFAAoF;AACpF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAUjF;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,GAAI,QAAQ,oBAAoB,KAAG,eAiB7E,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * What a request no route answers gets: the assembled server's not-found
3
+ * handler, twin of the Rust spine's method fallback (`fuz_http::compose_stack`)
4
+ * and fallback group (`fuz_actions::server::unmatched_route_response`).
5
+ *
6
+ * - **A method its path doesn't serve** — the path matches a route under
7
+ * another method — is `405 {"error":"method_not_allowed"}` with `Allow`
8
+ * naming the methods the path serves, `HEAD` wherever `GET` is.
9
+ * - **A path no route serves** is `404`: under the auth scope
10
+ * (`AUTH_MIDDLEWARE_PATH`) the JSON `{"error":"route_not_found"}`, like
11
+ * every other refusal there; elsewhere the one plain-text `NOT_FOUND_TEXT`.
12
+ * A route that passed the request on (the WebSocket path's `GET` asking for
13
+ * no upgrade) answers the same.
14
+ *
15
+ * The methods a path serves are read from the app's own router — every route
16
+ * registered on it, a spec's, a WebSocket upgrade's or one a consumer adds to
17
+ * the assembled app, and never a middleware (`ALL`).
18
+ *
19
+ * Both decide on the raw path the router matched (`get_request_path`), so
20
+ * `/%61pi/x` is outside the auth scope, as on the Rust spine. Hono runs this
21
+ * after every middleware, so the host gate and the origin check answer
22
+ * first, and ahead of authentication, which only the routes enforce: an
23
+ * anonymous `PUT` on the RPC path is the 405, not a 401. The answer is built
24
+ * through the context, so the session middleware's clear of a cookie that
25
+ * doesn't verify rides it like any other.
26
+ *
27
+ * @module
28
+ */
29
+ import { AUTH_MIDDLEWARE_PATH } from '../auth/middleware.js';
30
+ import { ERROR_METHOD_NOT_ALLOWED, ERROR_ROUTE_NOT_FOUND, NOT_FOUND_TEXT } from '../http/error_schemas.js';
31
+ import { middleware_applies } from '../http/schema_helpers.js';
32
+ /** The `Content-Type` of `NOT_FOUND_TEXT`, as the Rust spine writes it. */
33
+ const NOT_FOUND_CONTENT_TYPE = 'text/plain; charset=utf-8';
34
+ /** The methods a route may serve, in the order `Allow` lists them. */
35
+ const ROUTE_METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'];
36
+ /**
37
+ * Whether `router` holds a route — not a middleware — for `method` at `path`.
38
+ * A match carries each handler's registration, whose `method` is the one it
39
+ * was added under: a route's own, or `ALL` for a middleware.
40
+ */
41
+ const serves = (router, method, path) => router.match(method, path)[0].some(([[, route]]) => route.method === method);
42
+ /**
43
+ * Build the not-found handler (module doc) over the app's router.
44
+ *
45
+ * @param router - the assembled app's router, `app.router`, read at request
46
+ * time, so a route added after assembly is seen too
47
+ * @returns the handler for `app.notFound`
48
+ */
49
+ export const create_unmatched_route_handler = (router) => {
50
+ return (c) => {
51
+ const path = c.req.path;
52
+ // `HEAD` is served wherever `GET` is, which Hono answers it with
53
+ const allow = ROUTE_METHODS.filter((method) => serves(router, method === 'HEAD' ? 'GET' : method, path));
54
+ const method = c.req.method === 'HEAD' ? 'GET' : c.req.method;
55
+ if (allow.length > 0 && !allow.includes(method)) {
56
+ c.header('Allow', allow.join(', '));
57
+ return c.json({ error: ERROR_METHOD_NOT_ALLOWED }, 405);
58
+ }
59
+ if (middleware_applies(AUTH_MIDDLEWARE_PATH, path)) {
60
+ return c.json({ error: ERROR_ROUTE_NOT_FOUND }, 404);
61
+ }
62
+ return c.body(NOT_FOUND_TEXT, 404, { 'Content-Type': NOT_FOUND_CONTENT_TYPE });
63
+ };
64
+ };