@fuzdev/fuz_app 0.180.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 +1 -1
@@ -0,0 +1,40 @@
1
+ import '../assert_dev_env.js';
2
+ import { type BackendCapabilities } from './capabilities.js';
3
+ import type { SetupTest } from './setup.js';
4
+ /** Options for `describe_credential_conformance_wire_cross_tests`. */
5
+ export interface CredentialConformanceWireCrossTestOptions {
6
+ /**
7
+ * Per-test fixture producer (cross-process), seeding the
8
+ * `CREDENTIAL_SESSION_ACCOUNT_USERNAME` (with
9
+ * `CREDENTIAL_SESSION_ACCOUNT_PASSWORD`) and
10
+ * `CREDENTIAL_BEARER_ACCOUNT_USERNAME` `extra_accounts`, and no
11
+ * `extra_actors`. Where the backend's WebSocket upgrade is role-gated, both
12
+ * accounts and the keeper (`extra_keeper_roles`) hold its roles.
13
+ */
14
+ readonly setup_test: SetupTest;
15
+ /**
16
+ * `ws` gates the upgrade leg, `ws_account_actions` its `account_verify`
17
+ * frame on each accepted socket.
18
+ */
19
+ readonly capabilities: BackendCapabilities;
20
+ /** Base URL the spawned backend is reachable at (e.g. `http://localhost:1178`). */
21
+ readonly base_url: string;
22
+ /** The spine's session cookie name (`handle.config.cookie_name`). */
23
+ readonly cookie_name: string;
24
+ /**
25
+ * The backend's `SECRET_FUZ_COOKIE_KEYS` value
26
+ * (`handle.config.env.SECRET_FUZ_COOKIE_KEYS`) — the suite signs the cookie
27
+ * spellings the table names with its primary key.
28
+ */
29
+ readonly cookie_keys: string;
30
+ /** A valid daemon token (keeper) — `handle.daemon_token`. */
31
+ readonly daemon_token: string;
32
+ /** JSON-RPC endpoint path. Default `SPINE_RPC_PATH`. */
33
+ readonly rpc_path?: string;
34
+ /** WebSocket endpoint path. Default `SPINE_WS_PATH`. */
35
+ readonly ws_path?: string;
36
+ /** REST login route path. Default `SPINE_ACCOUNT_LOGIN_PATH`. */
37
+ readonly login_path?: string;
38
+ }
39
+ export declare const describe_credential_conformance_wire_cross_tests: (options: CredentialConformanceWireCrossTestOptions) => void;
40
+ //# sourceMappingURL=credential_conformance_wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential_conformance_wire.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/credential_conformance_wire.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAkF9B,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAoBtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C,sEAAsE;AACtE,MAAM,WAAW,yCAAyC;IACzD;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC7B;AAmBD,eAAO,MAAM,gDAAgD,GAC5D,SAAS,yCAAyC,KAChD,IAwQF,CAAC"}
@@ -0,0 +1,293 @@
1
+ import '../assert_dev_env.js';
2
+ /**
3
+ * The credential conformance table over raw sockets: each row's header lines
4
+ * sent to the live backend as they are written, and the real outcome asserted
5
+ * — which credential authenticated the request, and whether the response
6
+ * clears the session cookie.
7
+ *
8
+ * Where `credential_conformance.ts` asks a backend how it *reads* the lines
9
+ * (through its credential-read backdoor), this sends them: the runtime's HTTP
10
+ * parser, its joining of repeated lines, and the whole middleware chain sit
11
+ * between the bytes and the answer. It is what proves a repeated
12
+ * `Authorization` line authenticates nothing on a WebSocket upgrade, that a
13
+ * non-ASCII byte in a sibling cookie hides nothing, and that the clear is on
14
+ * the wire with the exact string. It needs no backdoor of its own, so it runs
15
+ * on a backend that doesn't mount that backdoor.
16
+ *
17
+ * **Which credential authenticated** is read from `account_verify`, which
18
+ * answers the calling account: the session cookie, the API token and the
19
+ * daemon token each belong to a different account (two seeded
20
+ * `extra_accounts`, and the keeper behind the daemon token), so the account
21
+ * in the answer names the credential, and a 401 names none.
22
+ *
23
+ * Every row is sent twice:
24
+ *
25
+ * - as an RPC `POST` — status, the answering account, the session
26
+ * `Set-Cookie` lines (exactly the clearing string, or none), and exactly one
27
+ * response on the connection;
28
+ * - as a WebSocket upgrade (`capabilities.ws`) — `101` when a credential
29
+ * authenticates and `401` otherwise, the clear on a refusal and never on an
30
+ * accepted upgrade; and on the accepted socket an `account_verify` frame
31
+ * (`capabilities.ws_account_actions`), whose answering account names the
32
+ * credential the upgrade was admitted on.
33
+ *
34
+ * A request carries no `Origin`, which the bearer and daemon-token legs would
35
+ * read as a browser context.
36
+ *
37
+ * Beside the table, imperative cases for what a row can't say: the clear's
38
+ * scope (cleared on an unrouted path under the auth scope and on its bare
39
+ * prefix, not outside it), its order against a handler's own `Set-Cookie` (a
40
+ * login carrying a stale cookie answers the clear, then the new cookie), and
41
+ * the cookie a login mints being the raw signed value, which authenticates as
42
+ * sent.
43
+ *
44
+ * **What it needs of a backend**, beyond the spine's auth stack:
45
+ *
46
+ * - `account_verify` on the RPC endpoint (`rpc_path`), admitting a session, an
47
+ * API token and the daemon token — the standard account actions. A backend
48
+ * answering `method_not_found` fails the suite naming it.
49
+ * - The `POST` login route at `login_path`.
50
+ * - A `setup_test` seeding the two `extra_accounts` `credential_wire.ts` names
51
+ * (`create_credential_wire_seed`), the session
52
+ * one with `CREDENTIAL_SESSION_ACCOUNT_PASSWORD` (the login case signs in as
53
+ * it — the suite creates no account of its own, so it needs neither signup
54
+ * nor invites), and no `extra_actors`: the upgrade leg sends no `acting`
55
+ * selector, which a multi-actor keeper's upgrade requires.
56
+ * - With `capabilities.ws`: the upgrade at `ws_path` admitting each of the
57
+ * three credentials with no `Origin`. Where the upgrade is role-gated, the
58
+ * two accounts and the keeper hold its roles (seeded — `extra_accounts`'
59
+ * `roles` and `extra_keeper_roles`).
60
+ * - With `capabilities.ws_account_actions`: `account_verify` on that socket.
61
+ * Without it the upgrade leg pins status and clear alone.
62
+ *
63
+ * Raw-socket by necessity, so **cross-process only**.
64
+ *
65
+ * @module
66
+ */
67
+ import { describe, test, assert } from 'vitest';
68
+ import { CREDENTIAL_TYPE_SESSION } from '../../auth/credential_type_schema.js';
69
+ import { HEALTH_PATH } from '../../http/health_schema.js';
70
+ import { raw_http_count_responses, raw_http_exchange, raw_http_header_values, raw_http_parse_response, raw_http_request, RAW_HTTP_READ_TIMEOUT_MS } from '../transports/raw_http.js';
71
+ import { connect_raw_ws } from '../transports/ws_raw_client.js';
72
+ import { test_if } from './capabilities.js';
73
+ import { build_credential_conformance_placeholders, create_credential_conformance_keyring, load_credential_conformance, to_credential_conformance_checks } from './credential_conformance.js';
74
+ import { CREDENTIAL_SESSION_ACCOUNT_PASSWORD, CREDENTIAL_SESSION_ACCOUNT_USERNAME, credential_of_verify_response, format_authenticated_credential, read_credential_wire_accounts, send_raw_upgrade, send_raw_verify, verify_socket_credential } from './credential_wire.js';
75
+ import { SPINE_ACCOUNT_LOGIN_PATH, SPINE_RPC_PATH, SPINE_WS_PATH } from './spine_surface_constants.js';
76
+ /**
77
+ * The attributes both spines write on every session `Set-Cookie`, in their
78
+ * order. An independent copy of each spine's `SESSION_COOKIE_ATTRIBUTES`, so a
79
+ * change to either producer's string fails here — the TS spine's too, which
80
+ * this module could otherwise only compare with itself.
81
+ */
82
+ const WIRE_SESSION_COOKIE_ATTRIBUTES = 'Path=/; HttpOnly; Secure; SameSite=Strict';
83
+ /** The suite's name, in a throw naming a missing requirement. */
84
+ const SUITE = 'describe_credential_conformance_wire_cross_tests';
85
+ /** The session cookie's `Set-Cookie` lines of a response, in the order sent. */
86
+ const session_set_cookies = (received, cookie_name) => raw_http_header_values(received, 'set-cookie').filter((value) => value.startsWith(`${cookie_name}=`));
87
+ export const describe_credential_conformance_wire_cross_tests = (options) => {
88
+ const { setup_test, capabilities, base_url, cookie_name, daemon_token } = options;
89
+ const rpc_path = options.rpc_path ?? SPINE_RPC_PATH;
90
+ const ws_path = options.ws_path ?? SPINE_WS_PATH;
91
+ const login_path = options.login_path ?? SPINE_ACCOUNT_LOGIN_PATH;
92
+ const host = new URL(base_url).host;
93
+ const table = load_credential_conformance();
94
+ const keyring = create_credential_conformance_keyring(options.cookie_keys);
95
+ // the clearing `Set-Cookie`, byte for byte, spelled here rather than built
96
+ // by the TS spine's formatter
97
+ const clear_cookie = `${cookie_name}=; ${WIRE_SESSION_COOKIE_ATTRIBUTES}; Max-Age=0`;
98
+ /** The table's wire rows, filled with this fixture's live credentials. */
99
+ const wire_checks = async (accounts) => {
100
+ const placeholders = await build_credential_conformance_placeholders({
101
+ cookie_name,
102
+ session_cookie: accounts.session.session_cookie,
103
+ api_token: accounts.bearer.api_token,
104
+ daemon_token,
105
+ keyring
106
+ });
107
+ return to_credential_conformance_checks(table, placeholders);
108
+ };
109
+ /** POST `account_verify` carrying `lines` after the JSON content type. */
110
+ const send_verify = (lines) => send_raw_verify({
111
+ base_url,
112
+ rpc_path,
113
+ host,
114
+ header_lines: ['Content-Type: application/json', ...lines]
115
+ });
116
+ const authenticated_credential = (response, accounts) => credential_of_verify_response(response, accounts, rpc_path, SUITE);
117
+ /**
118
+ * Send one row as a WebSocket upgrade a credential should not authenticate.
119
+ *
120
+ * @returns what disagrees with the row, empty when nothing does
121
+ */
122
+ const check_refused_upgrade = async (check) => {
123
+ const { received, response } = await send_raw_upgrade({
124
+ base_url,
125
+ ws_path,
126
+ host,
127
+ header_lines: check.lines
128
+ });
129
+ if (!response)
130
+ return [`no whole response (${received.slice(0, 80)})`];
131
+ if (response.status !== 401)
132
+ return [`expected 401, got ${response.status}`];
133
+ const cleared = session_set_cookies(received, cookie_name);
134
+ const expected_cleared = check.row.clears_session_cookie ? [clear_cookie] : [];
135
+ if (JSON.stringify(cleared) !== JSON.stringify(expected_cleared)) {
136
+ return [
137
+ `expected session Set-Cookie lines ${JSON.stringify(expected_cleared)} ` +
138
+ `on the 401, got ${cleared.length}`
139
+ ];
140
+ }
141
+ return [];
142
+ };
143
+ /**
144
+ * Send one row as a WebSocket upgrade a credential should authenticate, and
145
+ * ask the socket who it is.
146
+ *
147
+ * @returns what disagrees with the row, empty when nothing does
148
+ */
149
+ const check_accepted_upgrade = async (check, accounts) => {
150
+ const url = new URL(base_url);
151
+ let client;
152
+ try {
153
+ client = await connect_raw_ws({
154
+ port: Number(url.port),
155
+ hostname: url.hostname,
156
+ path: ws_path,
157
+ header_lines: check.lines
158
+ });
159
+ }
160
+ catch (error) {
161
+ return [`expected 101: ${error instanceof Error ? error.message : String(error)}`];
162
+ }
163
+ try {
164
+ const failures = [];
165
+ const cleared = session_set_cookies(client.handshake, cookie_name);
166
+ if (cleared.length > 0) {
167
+ failures.push(`expected no session Set-Cookie on the 101, got ${cleared.length}`);
168
+ }
169
+ if (!capabilities.ws_account_actions)
170
+ return failures;
171
+ const verified = await verify_socket_credential(client, accounts, ws_path, SUITE);
172
+ if ('failure' in verified)
173
+ return [...failures, verified.failure];
174
+ if (verified.credential !== check.row.authenticates) {
175
+ failures.push(`expected the socket to be ${String(check.row.authenticates)}'s, ` +
176
+ `got ${format_authenticated_credential(verified.credential)}`);
177
+ }
178
+ return failures;
179
+ }
180
+ finally {
181
+ client.destroy();
182
+ }
183
+ };
184
+ describe('credential conformance on the wire', () => {
185
+ test('every row authenticates as the credential it names, and clears the cookie when it says so', async () => {
186
+ const fixture = await setup_test();
187
+ const accounts = read_credential_wire_accounts(fixture);
188
+ const checks = await wire_checks(accounts);
189
+ const failures = [];
190
+ for (const check of checks) {
191
+ const { received, response } = await send_verify(check.lines);
192
+ if (!response) {
193
+ failures.push(`${check.label}: no whole response (${received.slice(0, 80)})`);
194
+ continue;
195
+ }
196
+ if (raw_http_count_responses(received) !== 1) {
197
+ failures.push(`${check.label}: more than one response on the connection`);
198
+ }
199
+ const authenticated = authenticated_credential(response, accounts);
200
+ if (authenticated !== check.row.authenticates) {
201
+ failures.push(`${check.label}: expected ${String(check.row.authenticates)} to authenticate, ` +
202
+ `got ${format_authenticated_credential(authenticated)}`);
203
+ }
204
+ const cleared = session_set_cookies(received, cookie_name);
205
+ const expected_cleared = check.row.clears_session_cookie ? [clear_cookie] : [];
206
+ if (JSON.stringify(cleared) !== JSON.stringify(expected_cleared)) {
207
+ failures.push(`${check.label}: expected session Set-Cookie lines ${JSON.stringify(expected_cleared)}, ` +
208
+ `got ${cleared.length} (${cleared.map((value) => value.replace(/=[^;]*/, '=…')).join(' | ')})`);
209
+ }
210
+ }
211
+ assert.ok(checks.length > 0, 'the table has wire rows');
212
+ assert.ok(failures.length === 0, `${failures.length} credential conformance rows disagree on the wire:\n${failures.join('\n')}`);
213
+ });
214
+ test_if(capabilities.ws, 'every row upgrades a WebSocket exactly when a credential authenticates, as that credential, and a refusal clears the cookie', async () => {
215
+ const fixture = await setup_test();
216
+ assert.strictEqual(fixture.extra_actors.length, 0, "the suite's setup_test must seed no extra_actors: the upgrades carry no acting selector");
217
+ const accounts = read_credential_wire_accounts(fixture);
218
+ const checks = await wire_checks(accounts);
219
+ const failures = [];
220
+ for (const check of checks) {
221
+ const disagreements = check.row.authenticates === null
222
+ ? await check_refused_upgrade(check)
223
+ : await check_accepted_upgrade(check, accounts);
224
+ for (const disagreement of disagreements) {
225
+ failures.push(`${check.label}: ${disagreement}`);
226
+ }
227
+ }
228
+ assert.ok(checks.length > 0, 'the table has wire rows');
229
+ assert.ok(failures.length === 0, `${failures.length} credential conformance rows disagree on a WebSocket upgrade:\n` +
230
+ failures.join('\n'));
231
+ });
232
+ test('an invalid cookie is cleared under the auth scope and nowhere else', async () => {
233
+ const probes = [
234
+ // unrouted, under the scope
235
+ ['/api/credential-conformance-unrouted', true],
236
+ // the scope's bare prefix, and the prefix with its slash
237
+ ['/api', true],
238
+ ['/api/', true],
239
+ // a sibling that only starts with the prefix's letters
240
+ ['/apix', false],
241
+ ['/health-credential-conformance-unrouted', false],
242
+ [HEALTH_PATH, false]
243
+ ];
244
+ for (const [path, cleared] of probes) {
245
+ const { received } = await raw_http_exchange(base_url, raw_http_request({
246
+ method: 'GET',
247
+ path,
248
+ host,
249
+ header_lines: [`Cookie: ${cookie_name}=bogus`, 'Connection: close']
250
+ }), { read_timeout_ms: RAW_HTTP_READ_TIMEOUT_MS });
251
+ assert.ok(raw_http_parse_response(received), `${path}: a whole response`);
252
+ assert.deepStrictEqual(session_set_cookies(received, cookie_name), cleared ? [clear_cookie] : [], `GET ${path} carrying an invalid session cookie`);
253
+ }
254
+ });
255
+ test('a login carrying a stale cookie answers the clear, then the new cookie — which authenticates as sent', async () => {
256
+ const fixture = await setup_test();
257
+ const accounts = read_credential_wire_accounts(fixture);
258
+ const { received } = await raw_http_exchange(base_url, raw_http_request({
259
+ method: 'POST',
260
+ path: login_path,
261
+ host,
262
+ header_lines: [
263
+ 'Content-Type: application/json',
264
+ `Cookie: ${cookie_name}=bogus`,
265
+ 'Connection: close'
266
+ ],
267
+ body: JSON.stringify({
268
+ username: CREDENTIAL_SESSION_ACCOUNT_USERNAME,
269
+ password: CREDENTIAL_SESSION_ACCOUNT_PASSWORD
270
+ })
271
+ }), { read_timeout_ms: RAW_HTTP_READ_TIMEOUT_MS });
272
+ const response = raw_http_parse_response(received);
273
+ assert.strictEqual(response?.status, 200, `the login at ${login_path} succeeds as '${CREDENTIAL_SESSION_ACCOUNT_USERNAME}', seeded with ` +
274
+ `CREDENTIAL_SESSION_ACCOUNT_PASSWORD: ${received.slice(0, 120)}`);
275
+ const set_cookies = session_set_cookies(received, cookie_name);
276
+ assert.strictEqual(set_cookies.length, 2, 'the clear and the new cookie, nothing else');
277
+ assert.strictEqual(set_cookies[0], clear_cookie, 'the clear comes first');
278
+ // the new cookie: the raw signed value, then the fixed attributes
279
+ const prefix = `${cookie_name}=`;
280
+ const minted = /^([^;]+); (.+); Max-Age=([1-9]\d*)$/.exec(set_cookies[1].slice(prefix.length));
281
+ assert.ok(minted, 'the new cookie is `name=value; <attributes>; Max-Age=<seconds>`');
282
+ assert.strictEqual(minted[2], WIRE_SESSION_COOKIE_ATTRIBUTES);
283
+ const value = minted[1];
284
+ const verified = await keyring.verify(value);
285
+ assert.ok(verified, 'the minted value verifies as written — nothing to decode');
286
+ // and the value, sent back byte for byte, authenticates as the account
287
+ const { response: verify } = await send_verify([`Cookie: ${cookie_name}=${value}`]);
288
+ assert.ok(verify, 'a whole response to the minted cookie');
289
+ assert.strictEqual(verify.status, 200, 'the minted cookie authenticates');
290
+ assert.strictEqual(authenticated_credential(verify, accounts), CREDENTIAL_TYPE_SESSION, 'and it is the account that logged in');
291
+ });
292
+ });
293
+ };
@@ -1,12 +1,10 @@
1
1
  import '../assert_dev_env.js';
2
- /** Options for the credential-header robustness probe — needs the raw URL + a valid daemon token. */
2
+ /** Options for the credential-header robustness probe — needs only the raw URL. */
3
3
  export interface CredentialHeaderRobustnessCrossTestOptions {
4
4
  /** Base URL the spawned backend is reachable at (e.g. `http://localhost:1178`). */
5
5
  readonly base_url: string;
6
6
  /** RPC endpoint path to target. Default `/api/rpc`. */
7
7
  readonly rpc_path?: string;
8
- /** A valid daemon token (keeper) — `handle.daemon_token`. */
9
- readonly daemon_token: string;
10
8
  }
11
9
  export declare const describe_credential_header_robustness_cross_tests: (options: CredentialHeaderRobustnessCrossTestOptions) => void;
12
10
  //# sourceMappingURL=credential_header_robustness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"credential_header_robustness.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/credential_header_robustness.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA6D9B,qGAAqG;AACrG,MAAM,WAAW,0CAA0C;IAC1D,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC9B;AA6CD,eAAO,MAAM,iDAAiD,GAC7D,SAAS,0CAA0C,KACjD,IAkHF,CAAC"}
1
+ {"version":3,"file":"credential_header_robustness.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/credential_header_robustness.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAkD9B,mFAAmF;AACnF,MAAM,WAAW,0CAA0C;IAC1D,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AA2CD,eAAO,MAAM,iDAAiD,GAC7D,SAAS,0CAA0C,KACjD,IAiEF,CAAC"}
@@ -3,44 +3,32 @@ import '../assert_dev_env.js';
3
3
  * Cross-backend **credential-header robustness** probe — the auth sibling of
4
4
  * `body_size_smuggling.ts`.
5
5
  *
6
- * The auth middleware reads a single credential per header (`Authorization`,
7
- * `X-Daemon-Token`). What a *duplicated*, *oversized*, or *control-char-injected*
8
- * credential header does is framework-territory — Hono reads its headers via the
9
- * Web `Headers` API, axum via `http::HeaderMap` — and the two could resolve a
10
- * duplicate differently (first-vs-last), cap header size differently, or parse a
11
- * malformed value differently. None of that is exercised over `fetch` (the
12
- * `FetchTransport` can't emit a duplicate or malformed header), so it had no
13
- * cross-impl pin. This raw-socket suite sends hand-framed requests and asserts
14
- * the **security invariants that must hold regardless of how each framework
15
- * resolves the ambiguity** — so it pins a real property without blessing one
16
- * resolution over the other:
6
+ * What a *control-char-injected* or *oversized* credential header does is
7
+ * framework territory — each spine's HTTP parser decides before the spine
8
+ * reads a byte — so this raw-socket suite asserts the **security invariants
9
+ * that must hold however the parser resolves it**, without blessing one
10
+ * resolution:
17
11
  *
18
- * - **a duplicated credential header never escalates** — a request carrying a
19
- * valid keeper `X-Daemon-Token` *and* a second, conflicting one must not
20
- * perform a keeper operation. The target omits `confirm`, so the documented
21
- * confirm guard (`purge_not_confirmed`) makes the honored-token branch a
22
- * guaranteed non-2xx with **zero side effect**, and the discarded-token
23
- * branch is a non-2xx auth/credential refusal — so whichever copy the
24
- * framework picks, the outcome is non-2xx. The same shape with two garbage
25
- * `Authorization` headers pins the bearer path can't be escalated either.
26
12
  * - **a control-char-injected credential header can't smuggle or authenticate**
27
13
  * — embedded `CRLF` / bare `CR` in the value never frames a second request
28
14
  * (no smuggle) and never authenticates (the truncated / rejected value is no
29
15
  * token).
30
- * - **no response desync** — each crafted request yields exactly one HTTP
31
- * response (a duplicate header that reframed the request would surface as a
32
- * second status line, like the body-size smuggling probe).
16
+ * - **no response desync** — each crafted request yields at most one HTTP
17
+ * response.
33
18
  * - **an oversized credential header can't wedge the server** — after a request
34
19
  * with a 64 KiB `X-Daemon-Token` (well past both frameworks' header caps), a
35
20
  * subsequent normal request on a fresh connection still gets a response. The
36
21
  * oversized request's own outcome (4xx / 431 / connection close) is
37
22
  * don't-care; surviving it is the property.
38
23
  *
39
- * Raw-socket by necessity (`fetch` can't emit duplicate or malformed headers),
24
+ * A *duplicated* credential header is not here: both spines discard one, and
25
+ * the exact outcome — which credential authenticates, one response — is pinned
26
+ * row by row in `credential_conformance_wire.ts`.
27
+ *
28
+ * Raw-socket by necessity (`fetch` can't emit malformed headers),
40
29
  * so — like `body_size_smuggling.ts` — this is **cross-process only** and
41
- * fixture-free: it needs only the base URL, the RPC path, and a valid daemon
42
- * token (`handle.daemon_token`, read once at spawn and static for the run, the
43
- * same credential the `_testing_reset` channel uses). Cited property: `docs/security.md`
30
+ * fixture-free: it needs only the base URL and the RPC path — every
31
+ * credential it sends is garbage. Cited property: `docs/security.md`
44
32
  * §"Credential Type Hierarchy" (a leaked / conflicting credential header can't
45
33
  * escalate the credential ceiling) + §"API Token Security" (bearer handling).
46
34
  *
@@ -48,7 +36,7 @@ import '../assert_dev_env.js';
48
36
  */
49
37
  import { describe, test, assert } from 'vitest';
50
38
  import { DAEMON_TOKEN_HEADER } from '../../auth/daemon_token.js';
51
- import { raw_http_count_responses, raw_http_exchange, raw_http_first_status, RAW_HTTP_READ_TIMEOUT_MS } from '../transports/raw_http.js';
39
+ import { raw_http_count_responses, raw_http_exchange, raw_http_first_status, raw_http_request, RAW_HTTP_READ_TIMEOUT_MS } from '../transports/raw_http.js';
52
40
  import { SPINE_RPC_PATH } from './spine_surface_constants.js';
53
41
  /** A well-formed UUID that never names a real row. */
54
42
  const NIL_UUID = '00000000-0000-0000-0000-000000000000';
@@ -61,17 +49,15 @@ const is_success_status = (status) => status >= 200 && status < 300;
61
49
  /**
62
50
  * Frame a raw HTTP/1.1 POST with the given extra header lines + JSON body.
63
51
  * `Connection: close` so the server closes after one response (the response
64
- * count is then unambiguous). The body is ASCII JSON, so `body.length` is the
65
- * byte length — no `Buffer` needed.
52
+ * count is then unambiguous).
66
53
  */
67
- const rpc_post = (host, path, header_lines, body) => `POST ${path} HTTP/1.1\r\n` +
68
- `Host: ${host}\r\n` +
69
- `Content-Type: application/json\r\n` +
70
- header_lines.map((h) => `${h}\r\n`).join('') +
71
- `Content-Length: ${body.length}\r\n` +
72
- `Connection: close\r\n` +
73
- `\r\n` +
74
- body;
54
+ const rpc_post = (host, path, header_lines, body) => raw_http_request({
55
+ method: 'POST',
56
+ path,
57
+ host,
58
+ header_lines: ['Content-Type: application/json', ...header_lines, 'Connection: close'],
59
+ body
60
+ });
75
61
  /**
76
62
  * A keeper-gated `account_purge` body with `confirm` OMITTED — the confirm
77
63
  * guard (`purge_not_confirmed`, before any deletion) guarantees the
@@ -80,27 +66,10 @@ const rpc_post = (host, path, header_lines, body) => `POST ${path} HTTP/1.1\r\n`
80
66
  */
81
67
  const purge_body = (id) => JSON.stringify({ jsonrpc: '2.0', method: 'account_purge', id, params: { account_id: NIL_UUID } });
82
68
  export const describe_credential_header_robustness_cross_tests = (options) => {
83
- const { base_url, daemon_token } = options;
69
+ const { base_url } = options;
84
70
  const rpc_path = options.rpc_path ?? SPINE_RPC_PATH;
85
71
  const host = new URL(base_url).host;
86
72
  describe('credential-header robustness', () => {
87
- test('duplicate X-Daemon-Token (valid + conflicting) never escalates → one non-2xx response', async () => {
88
- const req = rpc_post(host, rpc_path, [`${DAEMON_TOKEN_HEADER}: ${daemon_token}`, `${DAEMON_TOKEN_HEADER}: ${GARBAGE_TOKEN}`], purge_body('dup-daemon'));
89
- const raw = await send_raw(base_url, req);
90
- assert.strictEqual(raw_http_count_responses(raw), 1, `a duplicated X-Daemon-Token must yield exactly one response (no desync). Raw head: ${raw.slice(0, 120)}`);
91
- const status = raw_http_first_status(raw);
92
- assert.ok(status !== null, `expected an HTTP response. Raw head: ${raw.slice(0, 120)}`);
93
- assert.ok(!is_success_status(status), `a duplicated daemon token must not perform a keeper operation; whichever copy wins, ` +
94
- `the result must be non-2xx (got ${status})`);
95
- });
96
- test('duplicate Authorization bearer headers (both garbage) do not authenticate → one non-2xx response', async () => {
97
- const req = rpc_post(host, rpc_path, [`Authorization: Bearer ${GARBAGE_TOKEN}`, `Authorization: Bearer ${GARBAGE_TOKEN}-2`], purge_body('dup-bearer'));
98
- const raw = await send_raw(base_url, req);
99
- assert.strictEqual(raw_http_count_responses(raw), 1, `duplicate Authorization headers must yield exactly one response (no desync). Raw head: ${raw.slice(0, 120)}`);
100
- const status = raw_http_first_status(raw);
101
- assert.ok(status !== null, `expected an HTTP response. Raw head: ${raw.slice(0, 120)}`);
102
- assert.ok(!is_success_status(status), `garbage bearer tokens (even duplicated) must not authenticate (got ${status})`);
103
- });
104
73
  test('control-char-injected credential header (CR/LF) cannot smuggle or authenticate', async () => {
105
74
  // Embedded CRLF and a bare CR (header-splitting attempts) in a garbage
106
75
  // `X-Daemon-Token` value. A strict HTTP parser rejects the request
@@ -0,0 +1,112 @@
1
+ import '../assert_dev_env.js';
2
+ import { type BuiltinCredentialType } from '../../auth/credential_type_schema.js';
3
+ import type { TestAccount } from '../app_server.js';
4
+ import { type RawHttpResponse } from '../transports/raw_http.js';
5
+ import { type RawWsClient } from '../transports/ws_raw_client.js';
6
+ import type { CrossProcessSetupOptions, TestFixture } from './setup.js';
7
+ /**
8
+ * The `extra_accounts` username whose session cookie the suites send. Their
9
+ * `setup_test` must seed it, with `CREDENTIAL_SESSION_ACCOUNT_PASSWORD`.
10
+ */
11
+ export declare const CREDENTIAL_SESSION_ACCOUNT_USERNAME = "credential_session";
12
+ /**
13
+ * The password the `CREDENTIAL_SESSION_ACCOUNT_USERNAME` account is seeded
14
+ * with (`ExtraAccountSpec.password_value`) — the credential suite's login
15
+ * case signs in as it.
16
+ */
17
+ export declare const CREDENTIAL_SESSION_ACCOUNT_PASSWORD = "credential-session-password";
18
+ /**
19
+ * The `extra_accounts` username whose API token the suites send. Their
20
+ * `setup_test` must seed it.
21
+ */
22
+ export declare const CREDENTIAL_BEARER_ACCOUNT_USERNAME = "credential_bearer";
23
+ /**
24
+ * The seeding the credential suites need: the two accounts, each holding
25
+ * `ws_required_roles` so it can open a socket where the upgrade is
26
+ * role-gated, and the keeper behind the daemon token holding them too.
27
+ *
28
+ * @param ws_required_roles - the roles the backend's WebSocket upgrade requires
29
+ */
30
+ export declare const create_credential_wire_seed: (ws_required_roles?: ReadonlyArray<string>) => CrossProcessSetupOptions;
31
+ /** What an `account_verify` answer says of the credential behind it. */
32
+ export type AuthenticatedCredential = BuiltinCredentialType | {
33
+ readonly unexpected: string;
34
+ };
35
+ /** A credential reading for a failure message. */
36
+ export declare const format_authenticated_credential: (credential: AuthenticatedCredential | null) => string;
37
+ /** The accounts behind the three credentials of one fixture. */
38
+ export interface CredentialWireAccounts {
39
+ readonly session: TestAccount;
40
+ readonly bearer: TestAccount;
41
+ /** The keeper's account id — who the daemon token authenticates as. */
42
+ readonly keeper_id: string;
43
+ }
44
+ /**
45
+ * The fixture's three credential accounts.
46
+ *
47
+ * @throws AssertionError when the fixture lacks the seeded accounts, or two credentials share one
48
+ */
49
+ export declare const read_credential_wire_accounts: (fixture: TestFixture) => CredentialWireAccounts;
50
+ /** The id of the `account_verify` call the suites send. */
51
+ export declare const CREDENTIAL_WIRE_VERIFY_ID = "credential";
52
+ /** The `account_verify` call the suites send — an RPC body, and a socket frame. */
53
+ export declare const CREDENTIAL_WIRE_VERIFY_BODY: string;
54
+ /** An upgrade request's own header lines, with RFC 6455's sample key. */
55
+ export declare const WS_UPGRADE_HEADER_LINES: ReadonlyArray<string>;
56
+ /**
57
+ * The credential an `account_verify` envelope names, by the account it
58
+ * answers as.
59
+ *
60
+ * @param suite - the calling suite, named in the throw
61
+ * @throws Error when the backend has no `account_verify` there — a missing requirement, not a row's failure
62
+ */
63
+ export declare const credential_of_verify_envelope: (envelope: unknown, accounts: CredentialWireAccounts, where: string, suite: string) => AuthenticatedCredential;
64
+ /** One raw request a suite sends. */
65
+ export interface CredentialWireRequest {
66
+ /** Base URL the backend is reachable at; only its host and port are used. */
67
+ readonly base_url: string;
68
+ /** The `Host` to write, or `null` when `header_lines` carry the request's `Host` lines. */
69
+ readonly host: string | null;
70
+ /** The header lines, written in order and as given. */
71
+ readonly header_lines: ReadonlyArray<string>;
72
+ }
73
+ /**
74
+ * `POST` `account_verify` to `rpc_path` carrying `header_lines` (and
75
+ * `Connection: close`), read until the server closes.
76
+ */
77
+ export declare const send_raw_verify: (request: CredentialWireRequest & {
78
+ readonly rpc_path: string;
79
+ }) => Promise<{
80
+ received: string;
81
+ response: RawHttpResponse | null;
82
+ }>;
83
+ /**
84
+ * The credential an RPC `account_verify` response names; `null` for a 401.
85
+ *
86
+ * @param suite - the calling suite, named in a throw
87
+ */
88
+ export declare const credential_of_verify_response: (response: RawHttpResponse, accounts: CredentialWireAccounts, rpc_path: string, suite: string) => AuthenticatedCredential | null;
89
+ /**
90
+ * Send a WebSocket upgrade to `ws_path` carrying `header_lines` after the
91
+ * upgrade's own lines, and read the first response — for an upgrade the
92
+ * caller expects refused.
93
+ */
94
+ export declare const send_raw_upgrade: (request: CredentialWireRequest & {
95
+ readonly ws_path: string;
96
+ }) => Promise<{
97
+ received: string;
98
+ response: RawHttpResponse | null;
99
+ }>;
100
+ /**
101
+ * Ask an accepted socket who it is: send `account_verify` and read the
102
+ * credential its answer names.
103
+ *
104
+ * @param suite - the calling suite, named in a throw
105
+ * @returns the credential, or why none could be read
106
+ */
107
+ export declare const verify_socket_credential: (client: RawWsClient, accounts: CredentialWireAccounts, ws_path: string, suite: string) => Promise<{
108
+ credential: AuthenticatedCredential;
109
+ } | {
110
+ failure: string;
111
+ }>;
112
+ //# sourceMappingURL=credential_wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential_wire.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/credential_wire.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqB9B,OAAO,EAIN,KAAK,qBAAqB,EAC1B,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAMN,KAAK,eAAe,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGN,KAAK,WAAW,EAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,mCAAmC,uBAAuB,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,gCAAgC,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,kCAAkC,sBAAsB,CAAC;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACvC,oBAAmB,aAAa,CAAC,MAAM,CAAM,KAC3C,wBAaD,CAAC;AAEH,wEAAwE;AACxE,MAAM,MAAM,uBAAuB,GAAG,qBAAqB,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9F,kDAAkD;AAClD,eAAO,MAAM,+BAA+B,GAC3C,YAAY,uBAAuB,GAAG,IAAI,KACxC,MAGmB,CAAC;AAEvB,gEAAgE;AAChE,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GAAI,SAAS,WAAW,KAAG,sBAWpE,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,yBAAyB,eAAe,CAAC;AAEtD,mFAAmF;AACnF,eAAO,MAAM,2BAA2B,QAItC,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,EAAE,aAAa,CAAC,MAAM,CAKzD,CAAC;AAKF;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,GACzC,UAAU,OAAO,EACjB,UAAU,sBAAsB,EAChC,OAAO,MAAM,EACb,OAAO,MAAM,KACX,uBAuBF,CAAC;AAEF,qCAAqC;AACrC,MAAM,WAAW,qBAAqB;IACrC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2FAA2F;IAC3F,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC3B,SAAS,qBAAqB,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,KAC5D,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAA;CAAE,CAahE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GACzC,UAAU,eAAe,EACzB,UAAU,sBAAsB,EAChC,UAAU,MAAM,EAChB,OAAO,MAAM,KACX,uBAAuB,GAAG,IAW5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC5B,SAAS,qBAAqB,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KAC3D,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAA;CAAE,CAYhE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACpC,QAAQ,WAAW,EACnB,UAAU,sBAAsB,EAChC,SAAS,MAAM,EACf,OAAO,MAAM,KACX,OAAO,CAAC;IAAE,UAAU,EAAE,uBAAuB,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CA0BvE,CAAC"}