@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
@@ -77,7 +77,7 @@ import '../assert_dev_env.js';
77
77
  */
78
78
  import { describe, test, assert } from 'vitest';
79
79
  import { ERROR_RATE_LIMIT_EXCEEDED } from '../../http/error_schemas.js';
80
- import { raw_http_exchange, raw_http_parse_response } from '../transports/raw_http.js';
80
+ import { raw_http_exchange, raw_http_parse_response, raw_http_request } from '../transports/raw_http.js';
81
81
  import { default_login_account_rate_limit, default_login_ip_rate_limit } from '../../rate_limiter.js';
82
82
  import { list_audit_events } from './audit_cross_helpers.js';
83
83
  import { SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_PASSWORD_PATH } from './spine_surface_constants.js';
@@ -306,15 +306,18 @@ export const describe_login_security_cross_tests = (options) => {
306
306
  // fresh spoofed address and answer 401.
307
307
  const url = new URL(base_url);
308
308
  const body = JSON.stringify({ username: 'probe_xff_lines', password: PROBE_PASSWORD });
309
- const request = `POST ${login_path} HTTP/1.1\r\n` +
310
- `host: ${url.host}\r\n` +
311
- `content-type: application/json\r\n` +
312
- `x-forwarded-for: ${XFF_SPOOFED_LINE}\r\n` +
313
- `x-forwarded-for: ${XFF_REPEATED_LINES}\r\n` +
314
- `content-length: ${body.length}\r\n` +
315
- `connection: close\r\n` +
316
- `\r\n` +
317
- body;
309
+ const request = raw_http_request({
310
+ method: 'POST',
311
+ path: login_path,
312
+ host: url.host,
313
+ header_lines: [
314
+ 'content-type: application/json',
315
+ `x-forwarded-for: ${XFF_SPOOFED_LINE}`,
316
+ `x-forwarded-for: ${XFF_REPEATED_LINES}`,
317
+ 'connection: close'
318
+ ],
319
+ body
320
+ });
318
321
  const { received } = await raw_http_exchange(base_url, request, {
319
322
  read_timeout_ms: LOGIN_RAW_READ_TIMEOUT_MS,
320
323
  until: 'response'
@@ -11,7 +11,7 @@ export interface PeerPingWsTestOptions extends WsEndpointTarget {
11
11
  }
12
12
  /**
13
13
  * Register the server-initiated `peer/ping` suite — a positive round-trip
14
- * plus the security negatives the design doc's §Security surface mandates
14
+ * plus the security negatives
15
15
  * (unsolicited-response rejection, per-connection id isolation, never-reply
16
16
  * `Timeout`, wrong-shape reply rejection, plus client-error forwarding, the
17
17
  * reading of a malformed client error, and the HTTP no-transport path).
@@ -23,7 +23,7 @@ import '../assert_dev_env.js';
23
23
  * `WsClient.send` to inject unsolicited / cross-connection frames.
24
24
  *
25
25
  * **Per-spec auth.** `peer/ping` is `auth: public` (a liveness echo is
26
- * non-sensitive — see the design doc); the WS upgrade itself still
26
+ * non-sensitive); the WS upgrade itself still
27
27
  * authenticates, so the suite drives it over the keeper's session.
28
28
  *
29
29
  * Gated on `capabilities.peer_request`, which a backend declares once it
@@ -62,7 +62,7 @@ const ISOLATION_DEADLINE_MS = 5000;
62
62
  const valid_reply = (nonce) => ({ nonce, protocol_version: 1 });
63
63
  /**
64
64
  * Register the server-initiated `peer/ping` suite — a positive round-trip
65
- * plus the security negatives the design doc's §Security surface mandates
65
+ * plus the security negatives
66
66
  * (unsolicited-response rejection, per-connection id isolation, never-reply
67
67
  * `Timeout`, wrong-shape reply rejection, plus client-error forwarding, the
68
68
  * reading of a malformed client error, and the HTTP no-transport path).
@@ -0,0 +1,174 @@
1
+ import '../assert_dev_env.js';
2
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
3
+ import type { HeaderRead } from '../../http/request_headers.js';
4
+ /** One reader's reading in the table: `"absent"`, `"refused"`, or `{"one": value}`. */
5
+ export declare const RequestHeaderConformanceRead: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
6
+ one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
7
+ }>]>;
8
+ export type RequestHeaderConformanceRead = Infer<typeof RequestHeaderConformanceRead>;
9
+ /** What a request observably does — refused with a code, or authenticated as a credential. */
10
+ export declare const RequestHeaderConformanceOutcome: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
11
+ refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
12
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
13
+ authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
14
+ }>]>;
15
+ export type RequestHeaderConformanceOutcome = Infer<typeof RequestHeaderConformanceOutcome>;
16
+ /** One row of the table. */
17
+ export declare const RequestHeaderConformanceRow: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
18
+ name: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
19
+ lines: import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
20
+ read: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
21
+ origin: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
22
+ one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
23
+ }>]>;
24
+ browser_context: import("@fuzdev/fuz_schema/schema.ts").BooleanSchema;
25
+ host: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
26
+ one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
27
+ }>]>;
28
+ content_type: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
29
+ one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
30
+ }>]>;
31
+ }>;
32
+ post: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
33
+ refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
34
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
35
+ authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
36
+ }>]>>;
37
+ upgrade: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
38
+ refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
39
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
40
+ authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
41
+ }>]>>;
42
+ upgrade_runtime_refusal: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["empty_host"]>>;
43
+ wire_reason: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
44
+ note: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
45
+ }>;
46
+ export type RequestHeaderConformanceRow = Infer<typeof RequestHeaderConformanceRow>;
47
+ /** The placeholder names a row may use, each written `{name}` in the table. */
48
+ export declare const REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS: readonly ["cookie_name", "session_cookie", "api_token", "daemon_token", "host", "foreign_host", "origin", "foreign_origin"];
49
+ /** A placeholder name — see `REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS`. */
50
+ export type RequestHeaderConformancePlaceholder = (typeof REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS)[number];
51
+ /** The value each placeholder takes on one leg. */
52
+ export type RequestHeaderConformancePlaceholders = Readonly<Record<RequestHeaderConformancePlaceholder, string>>;
53
+ /** The table, a `@fuzdev/fuz_schema` `object`. */
54
+ export declare const RequestHeaderConformance: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
55
+ unit_placeholders: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
56
+ cookie_name: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
57
+ session_cookie: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
58
+ api_token: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
59
+ daemon_token: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
60
+ host: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
61
+ foreign_host: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
62
+ origin: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
63
+ foreign_origin: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
64
+ }>;
65
+ rows: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<{
66
+ name: string;
67
+ lines: string[];
68
+ read: {
69
+ origin: "absent" | "refused" | {
70
+ one: string;
71
+ };
72
+ browser_context: boolean;
73
+ host: "absent" | "refused" | {
74
+ one: string;
75
+ };
76
+ content_type: "absent" | "refused" | {
77
+ one: string;
78
+ };
79
+ };
80
+ post?: {
81
+ refused: "forbidden_origin" | "forbidden_host" | "unsupported_content_type";
82
+ } | {
83
+ authenticates: "session" | "api_token" | "daemon_token" | null;
84
+ } | undefined;
85
+ upgrade?: {
86
+ refused: "forbidden_origin" | "forbidden_host" | "unsupported_content_type";
87
+ } | {
88
+ authenticates: "session" | "api_token" | "daemon_token" | null;
89
+ } | undefined;
90
+ upgrade_runtime_refusal?: "empty_host" | undefined;
91
+ wire_reason?: string | undefined;
92
+ note?: string | undefined;
93
+ }[], import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
94
+ name: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
95
+ lines: import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
96
+ read: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
97
+ origin: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
98
+ one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
99
+ }>]>;
100
+ browser_context: import("@fuzdev/fuz_schema/schema.ts").BooleanSchema;
101
+ host: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
102
+ one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
103
+ }>]>;
104
+ content_type: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
105
+ one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
106
+ }>]>;
107
+ }>;
108
+ post: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
109
+ refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
110
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
111
+ authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
112
+ }>]>>;
113
+ upgrade: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
114
+ refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
115
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
116
+ authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
117
+ }>]>>;
118
+ upgrade_runtime_refusal: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["empty_host"]>>;
119
+ wire_reason: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
120
+ note: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
121
+ }>>>;
122
+ }>;
123
+ export type RequestHeaderConformance = Infer<typeof RequestHeaderConformance>;
124
+ /** The committed table, resolved relative to this module. */
125
+ export declare const REQUEST_HEADER_CONFORMANCE_URL: URL;
126
+ /**
127
+ * Read and parse the committed table, and check each row is either a wire
128
+ * row (`post` and `upgrade`) or names why it isn't (`wire_reason`).
129
+ *
130
+ * @throws Error when the file is off the schema, or a row is neither
131
+ */
132
+ export declare const load_request_header_conformance: () => RequestHeaderConformance;
133
+ /**
134
+ * Fill a row's `{placeholders}`.
135
+ *
136
+ * @throws Error on a placeholder this leg has no value for
137
+ */
138
+ export declare const fill_request_header_conformance_placeholders: (text: string, placeholders: RequestHeaderConformancePlaceholders) => string;
139
+ /** A reading in the table's spelling, its `one` value filled. */
140
+ export declare const fill_request_header_conformance_read: (read: RequestHeaderConformanceRead, placeholders: RequestHeaderConformancePlaceholders) => RequestHeaderConformanceRead;
141
+ /** A reader's `HeaderRead` in the table's spelling. */
142
+ export declare const to_request_header_conformance_read: (read: HeaderRead<string>) => RequestHeaderConformanceRead;
143
+ /** One header line, split at its first `:` and its value stripped of SP and HTAB, as a request-head parser reads it. */
144
+ export interface ParsedHeaderLine {
145
+ /** The name as written. */
146
+ readonly name: string;
147
+ /** The value, outer SP and HTAB stripped. */
148
+ readonly value: string;
149
+ }
150
+ /**
151
+ * Split a `Name: value` line.
152
+ *
153
+ * @throws Error on a line with no `:` — the table holds none
154
+ */
155
+ export declare const parse_request_header_line: (line: string) => ParsedHeaderLine;
156
+ /**
157
+ * The values of one header among `lines`, in order — what `get_header_lines`
158
+ * answers on a runtime with a per-line view.
159
+ *
160
+ * @param lines - `Name: value` lines
161
+ * @param name - the header name, in any case
162
+ */
163
+ export declare const request_header_values: (lines: ReadonlyArray<string>, name: string) => Array<string>;
164
+ /**
165
+ * Fold `lines` to one line per name, in the order each name first appears —
166
+ * the view a runtime without a per-line view gives: the Fetch `Headers` value,
167
+ * its lines joined with `, ` (`; ` for `Cookie`), then stripped of SP and HTAB
168
+ * at both ends as `get_header_lines` strips every line.
169
+ *
170
+ * @param lines - `Name: value` lines
171
+ * @returns one `Name: value` line per name
172
+ */
173
+ export declare const fold_header_lines: (lines: ReadonlyArray<string>) => Array<string>;
174
+ //# sourceMappingURL=request_header_conformance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request_header_conformance.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/request_header_conformance.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAkD9B,OAAO,EAaN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAStC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,uFAAuF;AACvF,eAAO,MAAM,4BAA4B;;IAIvC,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEtF,8FAA8F;AAC9F,eAAO,MAAM,+BAA+B;;;;IAK1C,CAAC;AACH,MAAM,MAAM,+BAA+B,GAAG,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAE5F,4BAA4B;AAC5B,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;EActC,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEpF,+EAA+E;AAC/E,eAAO,MAAM,uCAAuC,6HAS1C,CAAC;AAEX,0EAA0E;AAC1E,MAAM,MAAM,mCAAmC,GAC9C,CAAC,OAAO,uCAAuC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,mDAAmD;AACnD,MAAM,MAAM,oCAAoC,GAAG,QAAQ,CAC1D,MAAM,CAAC,mCAAmC,EAAE,MAAM,CAAC,CACnD,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYnC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE9E,6DAA6D;AAC7D,eAAO,MAAM,8BAA8B,EAAE,GAG5C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,QAAO,wBAqBlD,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,4CAA4C,GACxD,MAAM,MAAM,EACZ,cAAc,oCAAoC,KAChD,MAMA,CAAC;AAEJ,iEAAiE;AACjE,eAAO,MAAM,oCAAoC,GAChD,MAAM,4BAA4B,EAClC,cAAc,oCAAoC,KAChD,4BAG8E,CAAC;AAElF,uDAAuD;AACvD,eAAO,MAAM,kCAAkC,GAC9C,MAAM,UAAU,CAAC,MAAM,CAAC,KACtB,4BAAuF,CAAC;AAE3F,wHAAwH;AACxH,MAAM,WAAW,gBAAgB;IAChC,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,MAAM,MAAM,KAAG,gBAOxD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GACjC,OAAO,aAAa,CAAC,MAAM,CAAC,EAC5B,MAAM,MAAM,KACV,KAAK,CAAC,MAAM,CAMd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,aAAa,CAAC,MAAM,CAAC,KAAG,KAAK,CAAC,MAAM,CAY5E,CAAC"}
@@ -0,0 +1,196 @@
1
+ import '../assert_dev_env.js';
2
+ /**
3
+ * The request header conformance table: how both spines read `Origin`,
4
+ * `Referer`, `Host` and `Content-Type` — the gates' inputs — and what a
5
+ * request carrying given lines of them observably does.
6
+ *
7
+ * `request_header_conformance.json` (beside this module) holds one row per
8
+ * case, `{name, lines, read, post?, upgrade?, upgrade_runtime_refusal?,
9
+ * wire_reason?, note?}`:
10
+ *
11
+ * - **lines** — header lines, each `Name: value`, one byte per character (a
12
+ * character U+0080–U+00FF is that byte on the wire). A name may repeat.
13
+ * - **read** — each reader's reading of exactly those lines
14
+ * (`http/request_headers.ts`, the Rust `fuz_http::request_headers`):
15
+ * `origin`, `host` and `content_type` are `"absent"`, `"refused"`, or
16
+ * `{"one": value}` (`HeaderRead`; a content type's value is its lowercased
17
+ * essence), and `browser_context` whether an `Origin` or `Referer` line is
18
+ * there at all.
19
+ * - **post** and **upgrade** — what the request does on the wire, sent as an
20
+ * RPC `POST` and as a WebSocket upgrade: `{"refused": code}`, or
21
+ * `{"authenticates": credential}` (`null` for none). The wire leg adds a
22
+ * `Host` naming the server when the row has no `Host` line, and
23
+ * `Content-Type: application/json` on the `POST` when it has no
24
+ * `Content-Type` line, so a row says only what it is about. Where one
25
+ * request trips several gates the row pins which answers: the host gate,
26
+ * then the origin check, then the content type, then the credential legs.
27
+ * - **upgrade_runtime_refusal** — a runtime trait the row's upgrade meets
28
+ * before the app runs on a backend declaring it
29
+ * (`BackendCapabilities.ws_upgrade_runtime_refusals`).
30
+ * - **wire_reason** — present instead of `post` and `upgrade` on a row the
31
+ * wire leg can't send as the row means it; the unit legs still read it.
32
+ *
33
+ * The legs: the TS unit test over the readers (`src/test/http/`), the Rust
34
+ * unit test beside `fuz_http::request_headers` over a byte-identical copy of
35
+ * the file, and `request_header_conformance_wire.ts`, sending each row to a
36
+ * live backend. Both unit legs also hold every row **join-invariant**: the
37
+ * reading of its lines equals the reading of the same lines folded to one
38
+ * line per name (`fold_header_lines`) — the view Bun and an in-process
39
+ * `app.request` give the spine — which is what lets one expected column hold
40
+ * on every runtime.
41
+ *
42
+ * Live values are per leg, so lines name them with `{placeholders}`
43
+ * (`REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS`); the unit legs fill them from
44
+ * the table's own `unit_placeholders`. Edited by hand, never generated.
45
+ *
46
+ * @module
47
+ */
48
+ import { readFileSync } from 'node:fs';
49
+ import { array, boolean, literal, min_length, nullable, object, one_of, optional, parse_or_throw, pipe, string, union } from '@fuzdev/fuz_schema/schema.ts';
50
+ import { BUILTIN_CREDENTIAL_TYPES } from '../../auth/credential_type_schema.js';
51
+ import { ERROR_FORBIDDEN_HOST, ERROR_FORBIDDEN_ORIGIN, ERROR_UNSUPPORTED_CONTENT_TYPE } from '../../http/error_schemas.js';
52
+ import { trim_optional_whitespace } from '../../http/header_lines.js';
53
+ import { WS_UPGRADE_RUNTIME_REFUSALS } from './capabilities.js';
54
+ /** One reader's reading in the table: `"absent"`, `"refused"`, or `{"one": value}`. */
55
+ export const RequestHeaderConformanceRead = union([
56
+ literal('absent'),
57
+ literal('refused'),
58
+ object({ one: string })
59
+ ]);
60
+ /** What a request observably does — refused with a code, or authenticated as a credential. */
61
+ export const RequestHeaderConformanceOutcome = union([
62
+ object({
63
+ refused: one_of([ERROR_FORBIDDEN_HOST, ERROR_FORBIDDEN_ORIGIN, ERROR_UNSUPPORTED_CONTENT_TYPE])
64
+ }),
65
+ object({ authenticates: nullable(one_of(BUILTIN_CREDENTIAL_TYPES)) })
66
+ ]);
67
+ /** One row of the table. */
68
+ export const RequestHeaderConformanceRow = object({
69
+ name: string,
70
+ lines: array(string),
71
+ read: object({
72
+ origin: RequestHeaderConformanceRead,
73
+ browser_context: boolean,
74
+ host: RequestHeaderConformanceRead,
75
+ content_type: RequestHeaderConformanceRead
76
+ }),
77
+ post: optional(RequestHeaderConformanceOutcome),
78
+ upgrade: optional(RequestHeaderConformanceOutcome),
79
+ upgrade_runtime_refusal: optional(one_of(WS_UPGRADE_RUNTIME_REFUSALS)),
80
+ wire_reason: optional(string),
81
+ note: optional(string)
82
+ });
83
+ /** The placeholder names a row may use, each written `{name}` in the table. */
84
+ export const REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS = [
85
+ 'cookie_name',
86
+ 'session_cookie',
87
+ 'api_token',
88
+ 'daemon_token',
89
+ 'host',
90
+ 'foreign_host',
91
+ 'origin',
92
+ 'foreign_origin'
93
+ ];
94
+ /** The table, a `@fuzdev/fuz_schema` `object`. */
95
+ export const RequestHeaderConformance = object({
96
+ unit_placeholders: object({
97
+ cookie_name: string,
98
+ session_cookie: string,
99
+ api_token: string,
100
+ daemon_token: string,
101
+ host: string,
102
+ foreign_host: string,
103
+ origin: string,
104
+ foreign_origin: string
105
+ }),
106
+ rows: pipe(array(RequestHeaderConformanceRow), min_length(1))
107
+ });
108
+ /** The committed table, resolved relative to this module. */
109
+ export const REQUEST_HEADER_CONFORMANCE_URL = new URL('./request_header_conformance.json', import.meta.url);
110
+ /**
111
+ * Read and parse the committed table, and check each row is either a wire
112
+ * row (`post` and `upgrade`) or names why it isn't (`wire_reason`).
113
+ *
114
+ * @throws Error when the file is off the schema, or a row is neither
115
+ */
116
+ export const load_request_header_conformance = () => {
117
+ const table = parse_or_throw(RequestHeaderConformance, JSON.parse(readFileSync(REQUEST_HEADER_CONFORMANCE_URL, 'utf8')));
118
+ for (const row of table.rows) {
119
+ const wire = row.post !== undefined && row.upgrade !== undefined;
120
+ const unit_only = row.wire_reason !== undefined && row.post === undefined && row.upgrade === undefined;
121
+ if (wire === unit_only) {
122
+ throw new Error(`request header conformance row '${row.name}': give both \`post\` and \`upgrade\`, or a \`wire_reason\` and neither`);
123
+ }
124
+ if (row.upgrade_runtime_refusal !== undefined && !wire) {
125
+ throw new Error(`request header conformance row '${row.name}': \`upgrade_runtime_refusal\` on a row the wire leg doesn't send`);
126
+ }
127
+ }
128
+ return table;
129
+ };
130
+ const PLACEHOLDER_REGEX = /\{([a-z_]+)\}/g;
131
+ /**
132
+ * Fill a row's `{placeholders}`.
133
+ *
134
+ * @throws Error on a placeholder this leg has no value for
135
+ */
136
+ export const fill_request_header_conformance_placeholders = (text, placeholders) => text.replace(PLACEHOLDER_REGEX, (_match, name) => {
137
+ if (!Object.hasOwn(placeholders, name)) {
138
+ throw new Error(`unknown request header conformance placeholder {${name}}`);
139
+ }
140
+ return placeholders[name];
141
+ });
142
+ /** A reading in the table's spelling, its `one` value filled. */
143
+ export const fill_request_header_conformance_read = (read, placeholders) => typeof read === 'string'
144
+ ? read
145
+ : { one: fill_request_header_conformance_placeholders(read.one, placeholders) };
146
+ /** A reader's `HeaderRead` in the table's spelling. */
147
+ export const to_request_header_conformance_read = (read) => (read.kind === 'one' ? { one: read.value } : read.kind);
148
+ /**
149
+ * Split a `Name: value` line.
150
+ *
151
+ * @throws Error on a line with no `:` — the table holds none
152
+ */
153
+ export const parse_request_header_line = (line) => {
154
+ const colon = line.indexOf(':');
155
+ if (colon <= 0)
156
+ throw new Error(`not a header line: ${JSON.stringify(line)}`);
157
+ return {
158
+ name: line.slice(0, colon),
159
+ value: trim_optional_whitespace(line.slice(colon + 1))
160
+ };
161
+ };
162
+ /**
163
+ * The values of one header among `lines`, in order — what `get_header_lines`
164
+ * answers on a runtime with a per-line view.
165
+ *
166
+ * @param lines - `Name: value` lines
167
+ * @param name - the header name, in any case
168
+ */
169
+ export const request_header_values = (lines, name) => {
170
+ const lower = name.toLowerCase();
171
+ return lines
172
+ .map(parse_request_header_line)
173
+ .filter((line) => line.name.toLowerCase() === lower)
174
+ .map((line) => line.value);
175
+ };
176
+ /**
177
+ * Fold `lines` to one line per name, in the order each name first appears —
178
+ * the view a runtime without a per-line view gives: the Fetch `Headers` value,
179
+ * its lines joined with `, ` (`; ` for `Cookie`), then stripped of SP and HTAB
180
+ * at both ends as `get_header_lines` strips every line.
181
+ *
182
+ * @param lines - `Name: value` lines
183
+ * @returns one `Name: value` line per name
184
+ */
185
+ export const fold_header_lines = (lines) => {
186
+ const folded = new Map();
187
+ for (const line of lines.map(parse_request_header_line)) {
188
+ const key = line.name.toLowerCase();
189
+ const entry = folded.get(key);
190
+ if (entry)
191
+ entry.values.push(line.value);
192
+ else
193
+ folded.set(key, { name: line.name, values: [line.value] });
194
+ }
195
+ return [...folded.entries()].map(([key, { name, values }]) => `${name}: ${trim_optional_whitespace(values.join(key === 'cookie' ? '; ' : ', '))}`);
196
+ };