@fuzdev/fuz_app 0.180.0 → 0.182.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/dist/actions/CLAUDE.md +38 -20
  2. package/dist/actions/action_rpc.d.ts +25 -6
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +56 -48
  5. package/dist/actions/action_types.d.ts +31 -13
  6. package/dist/actions/action_types.d.ts.map +1 -1
  7. package/dist/actions/action_types.js +1 -1
  8. package/dist/actions/notification_sender.d.ts +83 -0
  9. package/dist/actions/notification_sender.d.ts.map +1 -0
  10. package/dist/actions/notification_sender.js +85 -0
  11. package/dist/actions/perform_action.d.ts +13 -4
  12. package/dist/actions/perform_action.d.ts.map +1 -1
  13. package/dist/actions/perform_action.js +27 -18
  14. package/dist/actions/register_action_ws.d.ts +20 -2
  15. package/dist/actions/register_action_ws.d.ts.map +1 -1
  16. package/dist/actions/register_action_ws.js +17 -5
  17. package/dist/actions/ws_socket_session.d.ts +3 -0
  18. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  19. package/dist/actions/ws_socket_session.js +3 -2
  20. package/dist/auth/CLAUDE.md +84 -59
  21. package/dist/auth/account_actions.d.ts.map +1 -1
  22. package/dist/auth/account_actions.js +30 -3
  23. package/dist/auth/account_queries.d.ts +213 -2
  24. package/dist/auth/account_queries.d.ts.map +1 -1
  25. package/dist/auth/account_queries.js +255 -2
  26. package/dist/auth/account_route_schema.d.ts +26 -16
  27. package/dist/auth/account_route_schema.d.ts.map +1 -1
  28. package/dist/auth/account_route_schema.js +10 -24
  29. package/dist/auth/account_routes.d.ts +5 -7
  30. package/dist/auth/account_routes.d.ts.map +1 -1
  31. package/dist/auth/account_routes.js +110 -89
  32. package/dist/auth/admin_actions.d.ts.map +1 -1
  33. package/dist/auth/admin_actions.js +117 -25
  34. package/dist/auth/api_token_queries.d.ts +29 -12
  35. package/dist/auth/api_token_queries.d.ts.map +1 -1
  36. package/dist/auth/api_token_queries.js +42 -27
  37. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  38. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  39. package/dist/auth/audit_log_routes.d.ts +1 -1
  40. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  41. package/dist/auth/audit_log_routes.js +10 -12
  42. package/dist/auth/audit_log_schema.js +4 -4
  43. package/dist/auth/bearer_auth.d.ts +4 -3
  44. package/dist/auth/bearer_auth.d.ts.map +1 -1
  45. package/dist/auth/bearer_auth.js +37 -32
  46. package/dist/auth/bootstrap_account.d.ts +65 -37
  47. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_account.js +115 -66
  49. package/dist/auth/bootstrap_route_schema.d.ts +6 -2
  50. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  51. package/dist/auth/bootstrap_route_schema.js +7 -2
  52. package/dist/auth/bootstrap_routes.d.ts +50 -33
  53. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  54. package/dist/auth/bootstrap_routes.js +109 -87
  55. package/dist/auth/bootstrap_token_store.d.ts +60 -0
  56. package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
  57. package/dist/auth/bootstrap_token_store.js +39 -0
  58. package/dist/auth/credential_headers.d.ts +71 -0
  59. package/dist/auth/credential_headers.d.ts.map +1 -0
  60. package/dist/auth/credential_headers.js +100 -0
  61. package/dist/auth/daemon_token.d.ts +13 -1
  62. package/dist/auth/daemon_token.d.ts.map +1 -1
  63. package/dist/auth/daemon_token.js +14 -2
  64. package/dist/auth/daemon_token_middleware.d.ts +10 -11
  65. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  66. package/dist/auth/daemon_token_middleware.js +39 -30
  67. package/dist/auth/deps.d.ts +10 -11
  68. package/dist/auth/deps.d.ts.map +1 -1
  69. package/dist/auth/invite_queries.d.ts +18 -0
  70. package/dist/auth/invite_queries.d.ts.map +1 -1
  71. package/dist/auth/invite_queries.js +24 -0
  72. package/dist/auth/request_context.d.ts +97 -76
  73. package/dist/auth/request_context.d.ts.map +1 -1
  74. package/dist/auth/request_context.js +93 -104
  75. package/dist/auth/resolved_auth.d.ts +10 -5
  76. package/dist/auth/resolved_auth.d.ts.map +1 -1
  77. package/dist/auth/resolved_auth.js +2 -2
  78. package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
  79. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  80. package/dist/auth/role_grant_offer_action_specs.js +5 -3
  81. package/dist/auth/role_grant_offer_actions.d.ts +7 -11
  82. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  83. package/dist/auth/role_grant_offer_actions.js +97 -106
  84. package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
  85. package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
  86. package/dist/auth/role_grant_offer_ddl.js +9 -2
  87. package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
  88. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  89. package/dist/auth/role_grant_offer_notifications.js +75 -22
  90. package/dist/auth/role_grant_offer_queries.d.ts +143 -9
  91. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  92. package/dist/auth/role_grant_offer_queries.js +266 -66
  93. package/dist/auth/role_grant_offer_schema.js +1 -1
  94. package/dist/auth/role_grant_queries.d.ts +57 -10
  95. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  96. package/dist/auth/role_grant_queries.js +81 -22
  97. package/dist/auth/role_grant_sql.d.ts +21 -0
  98. package/dist/auth/role_grant_sql.d.ts.map +1 -1
  99. package/dist/auth/role_grant_sql.js +21 -0
  100. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  101. package/dist/auth/self_service_role_actions.js +9 -2
  102. package/dist/auth/session_cookie.d.ts +105 -25
  103. package/dist/auth/session_cookie.d.ts.map +1 -1
  104. package/dist/auth/session_cookie.js +124 -15
  105. package/dist/auth/session_middleware.d.ts +83 -54
  106. package/dist/auth/session_middleware.d.ts.map +1 -1
  107. package/dist/auth/session_middleware.js +92 -66
  108. package/dist/auth/session_queries.d.ts +95 -14
  109. package/dist/auth/session_queries.d.ts.map +1 -1
  110. package/dist/auth/session_queries.js +98 -19
  111. package/dist/auth/signup_route_schema.d.ts +5 -5
  112. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  113. package/dist/auth/signup_route_schema.js +4 -4
  114. package/dist/auth/signup_routes.d.ts.map +1 -1
  115. package/dist/auth/signup_routes.js +17 -14
  116. package/dist/auth/standard_rpc_actions.d.ts +6 -19
  117. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  118. package/dist/auth/standard_rpc_actions.js +5 -6
  119. package/dist/auth/token_scope.d.ts +6 -8
  120. package/dist/auth/token_scope.d.ts.map +1 -1
  121. package/dist/auth/token_scope.js +6 -9
  122. package/dist/dev/setup.d.ts +6 -1
  123. package/dist/dev/setup.d.ts.map +1 -1
  124. package/dist/dev/setup.js +42 -34
  125. package/dist/hono_context.d.ts +21 -0
  126. package/dist/hono_context.d.ts.map +1 -1
  127. package/dist/hono_context.js +17 -0
  128. package/dist/http/CLAUDE.md +156 -48
  129. package/dist/http/auth_shape.d.ts +4 -4
  130. package/dist/http/common_routes.js +1 -1
  131. package/dist/http/db_routes.d.ts +4 -3
  132. package/dist/http/db_routes.d.ts.map +1 -1
  133. package/dist/http/db_routes.js +14 -14
  134. package/dist/http/dev_route_error_check.d.ts +6 -3
  135. package/dist/http/dev_route_error_check.d.ts.map +1 -1
  136. package/dist/http/dev_route_error_check.js +6 -3
  137. package/dist/http/dev_set_cookie_check.d.ts +53 -0
  138. package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
  139. package/dist/http/dev_set_cookie_check.js +80 -0
  140. package/dist/http/error_schemas.d.ts +45 -22
  141. package/dist/http/error_schemas.d.ts.map +1 -1
  142. package/dist/http/error_schemas.js +53 -26
  143. package/dist/http/header_lines.d.ts +42 -0
  144. package/dist/http/header_lines.d.ts.map +1 -0
  145. package/dist/http/header_lines.js +80 -0
  146. package/dist/http/host.d.ts +12 -9
  147. package/dist/http/host.d.ts.map +1 -1
  148. package/dist/http/host.js +25 -20
  149. package/dist/http/origin.d.ts +7 -22
  150. package/dist/http/origin.d.ts.map +1 -1
  151. package/dist/http/origin.js +11 -25
  152. package/dist/http/proxy.d.ts +1 -0
  153. package/dist/http/proxy.d.ts.map +1 -1
  154. package/dist/http/proxy.js +3 -0
  155. package/dist/http/request_headers.d.ts +95 -0
  156. package/dist/http/request_headers.d.ts.map +1 -0
  157. package/dist/http/request_headers.js +110 -0
  158. package/dist/http/request_target.d.ts +134 -0
  159. package/dist/http/request_target.d.ts.map +1 -0
  160. package/dist/http/request_target.js +193 -0
  161. package/dist/http/route_error_check.d.ts +4 -11
  162. package/dist/http/route_error_check.d.ts.map +1 -1
  163. package/dist/http/route_error_check.js +4 -21
  164. package/dist/http/route_result.d.ts +127 -23
  165. package/dist/http/route_result.d.ts.map +1 -1
  166. package/dist/http/route_result.js +97 -19
  167. package/dist/http/route_spec.d.ts +299 -83
  168. package/dist/http/route_spec.d.ts.map +1 -1
  169. package/dist/http/route_spec.js +548 -71
  170. package/dist/http/simple_request.d.ts +19 -14
  171. package/dist/http/simple_request.d.ts.map +1 -1
  172. package/dist/http/simple_request.js +17 -29
  173. package/dist/http/surface.d.ts +2 -0
  174. package/dist/http/surface.d.ts.map +1 -1
  175. package/dist/http/surface.js +4 -1
  176. package/dist/realtime/outbound_budget.d.ts +1 -2
  177. package/dist/realtime/outbound_budget.d.ts.map +1 -1
  178. package/dist/realtime/outbound_budget.js +1 -2
  179. package/dist/realtime/sse.d.ts +47 -17
  180. package/dist/realtime/sse.d.ts.map +1 -1
  181. package/dist/realtime/sse.js +115 -93
  182. package/dist/realtime/sse_constants.d.ts +7 -1
  183. package/dist/realtime/sse_constants.d.ts.map +1 -1
  184. package/dist/realtime/sse_constants.js +12 -1
  185. package/dist/realtime/sse_registry.d.ts +3 -3
  186. package/dist/realtime/sse_registry.js +3 -3
  187. package/dist/runtime/deps.d.ts +20 -4
  188. package/dist/runtime/deps.d.ts.map +1 -1
  189. package/dist/runtime/mock.d.ts +7 -1
  190. package/dist/runtime/mock.d.ts.map +1 -1
  191. package/dist/runtime/mock.js +33 -3
  192. package/dist/runtime/node.d.ts.map +1 -1
  193. package/dist/runtime/node.js +2 -1
  194. package/dist/runtime/secure_file.d.ts +71 -10
  195. package/dist/runtime/secure_file.d.ts.map +1 -1
  196. package/dist/runtime/secure_file.js +91 -11
  197. package/dist/server/app_backend.d.ts +0 -8
  198. package/dist/server/app_backend.d.ts.map +1 -1
  199. package/dist/server/app_backend.js +4 -4
  200. package/dist/server/app_server.d.ts +54 -33
  201. package/dist/server/app_server.d.ts.map +1 -1
  202. package/dist/server/app_server.js +69 -41
  203. package/dist/server/serve_fact_route.d.ts +3 -3
  204. package/dist/server/serve_fact_route.d.ts.map +1 -1
  205. package/dist/server/serve_fact_route.js +59 -55
  206. package/dist/server/static.d.ts +20 -0
  207. package/dist/server/static.d.ts.map +1 -1
  208. package/dist/server/static.js +56 -8
  209. package/dist/server/unmatched_route.d.ts +42 -0
  210. package/dist/server/unmatched_route.d.ts.map +1 -0
  211. package/dist/server/unmatched_route.js +64 -0
  212. package/dist/testing/CLAUDE.md +406 -1202
  213. package/dist/testing/app_server.d.ts +3 -1
  214. package/dist/testing/app_server.d.ts.map +1 -1
  215. package/dist/testing/app_server.js +5 -9
  216. package/dist/testing/auth_apps.d.ts.map +1 -1
  217. package/dist/testing/auth_apps.js +3 -2
  218. package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
  219. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  220. package/dist/testing/cross_backend/account_lifecycle.js +320 -6
  221. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
  222. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
  224. package/dist/testing/cross_backend/capabilities.d.ts +68 -5
  225. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  226. package/dist/testing/cross_backend/capabilities.js +20 -4
  227. package/dist/testing/cross_backend/cell_gated_create.js +1 -1
  228. package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
  229. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  230. package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
  231. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  232. package/dist/testing/cross_backend/conformance_table.js +179 -23
  233. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  234. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
  235. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  236. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
  237. package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
  238. package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
  239. package/dist/testing/cross_backend/credential_conformance.js +296 -0
  240. package/dist/testing/cross_backend/credential_conformance.json +1284 -0
  241. package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
  242. package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
  243. package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
  244. package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
  245. package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
  246. package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
  247. package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
  248. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
  249. package/dist/testing/cross_backend/credential_wire.js +188 -0
  250. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  251. package/dist/testing/cross_backend/default_backend_configs.js +22 -2
  252. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
  253. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  254. package/dist/testing/cross_backend/default_spine_surface.js +3 -7
  255. package/dist/testing/cross_backend/differential.d.ts +1 -1
  256. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  257. package/dist/testing/cross_backend/differential.js +3 -2
  258. package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
  259. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  260. package/dist/testing/cross_backend/differential_normalize.js +11 -5
  261. package/dist/testing/cross_backend/full_spine_mount.d.ts +4 -10
  262. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  263. package/dist/testing/cross_backend/full_spine_mount.js +11 -4
  264. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  265. package/dist/testing/cross_backend/identity_parity.js +4 -0
  266. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  267. package/dist/testing/cross_backend/in_process_setup.js +78 -4
  268. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  269. package/dist/testing/cross_backend/login_security.js +13 -10
  270. package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
  271. package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
  272. package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
  273. package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
  274. package/dist/testing/cross_backend/request_header_conformance.js +196 -0
  275. package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
  276. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
  277. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
  278. package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
  279. package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
  280. package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
  281. package/dist/testing/cross_backend/request_target_conformance.js +186 -0
  282. package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
  283. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
  284. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
  285. package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
  286. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  287. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
  288. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
  289. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  290. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +185 -31
  291. package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
  292. package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
  293. package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
  294. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
  295. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  296. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
  297. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  298. package/dist/testing/cross_backend/session_cap.js +82 -34
  299. package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
  300. package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
  301. package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
  302. package/dist/testing/cross_backend/session_login.d.ts +24 -0
  303. package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
  304. package/dist/testing/cross_backend/session_login.js +31 -0
  305. package/dist/testing/cross_backend/setup.d.ts +117 -0
  306. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  307. package/dist/testing/cross_backend/setup.js +193 -9
  308. package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
  309. package/dist/testing/cross_backend/simple_request.js +5 -0
  310. package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
  311. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  312. package/dist/testing/cross_backend/spine_suites.js +88 -5
  313. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  314. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  315. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  316. package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
  317. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  318. package/dist/testing/cross_backend/sse_round_trip.js +205 -64
  319. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  320. package/dist/testing/cross_backend/testing_backdoor.js +5 -2
  321. package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
  322. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
  323. package/dist/testing/cross_backend/testing_credential_read.js +175 -0
  324. package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
  325. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  326. package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
  327. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  328. package/dist/testing/cross_backend/token_lifetime.js +58 -2
  329. package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
  330. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  331. package/dist/testing/cross_backend/transport_composition.js +13 -10
  332. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  333. package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
  334. package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
  335. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  336. package/dist/testing/cross_backend/ws_endpoint.js +19 -2
  337. package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
  338. package/dist/testing/cross_backend/ws_role_gated.js +2 -3
  339. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  340. package/dist/testing/cross_backend/ws_round_trip.js +28 -12
  341. package/dist/testing/cross_backend/xfail.d.ts +44 -11
  342. package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
  343. package/dist/testing/cross_backend/xfail.js +68 -23
  344. package/dist/testing/data_exposure.d.ts.map +1 -1
  345. package/dist/testing/data_exposure.js +4 -3
  346. package/dist/testing/integration.d.ts +1 -2
  347. package/dist/testing/integration.d.ts.map +1 -1
  348. package/dist/testing/integration.js +14 -8
  349. package/dist/testing/integration_helpers.d.ts +50 -3
  350. package/dist/testing/integration_helpers.d.ts.map +1 -1
  351. package/dist/testing/integration_helpers.js +87 -9
  352. package/dist/testing/middleware.d.ts +3 -1
  353. package/dist/testing/middleware.d.ts.map +1 -1
  354. package/dist/testing/middleware.js +14 -7
  355. package/dist/testing/resolved_auth.d.ts +3 -1
  356. package/dist/testing/resolved_auth.d.ts.map +1 -1
  357. package/dist/testing/resolved_auth.js +4 -4
  358. package/dist/testing/round_trip.d.ts +6 -2
  359. package/dist/testing/round_trip.d.ts.map +1 -1
  360. package/dist/testing/round_trip.js +17 -6
  361. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  362. package/dist/testing/rpc_envelope_cases.js +7 -0
  363. package/dist/testing/rpc_helpers.d.ts +4 -2
  364. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  365. package/dist/testing/rpc_helpers.js +6 -1
  366. package/dist/testing/rpc_round_trip.d.ts +13 -2
  367. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  368. package/dist/testing/rpc_round_trip.js +25 -6
  369. package/dist/testing/schema_generators.d.ts +2 -2
  370. package/dist/testing/schema_generators.d.ts.map +1 -1
  371. package/dist/testing/schema_generators.js +4 -4
  372. package/dist/testing/stubs.d.ts +2 -2
  373. package/dist/testing/stubs.d.ts.map +1 -1
  374. package/dist/testing/stubs.js +13 -10
  375. package/dist/testing/transports/fetch_transport.d.ts +6 -3
  376. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  377. package/dist/testing/transports/fetch_transport.js +31 -19
  378. package/dist/testing/transports/raw_http.d.ts +61 -1
  379. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  380. package/dist/testing/transports/raw_http.js +61 -1
  381. package/dist/testing/transports/ws_raw_client.d.ts +20 -0
  382. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  383. package/dist/testing/transports/ws_raw_client.js +10 -4
  384. package/dist/testing/transports/ws_transport.d.ts +21 -1
  385. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  386. package/dist/testing/transports/ws_transport.js +58 -20
  387. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  388. package/dist/testing/ws_round_trip.js +8 -4
  389. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Hono-free wire schemas + route shapes for the account REST routes.
3
3
  *
4
- * Split from `account_routes.ts` (whose handlers pull `hono/cookie` via
5
- * `session_middleware`) so cross-process test suites can build the account
4
+ * Split from `account_routes.ts` (whose handlers mint and end sessions through
5
+ * `session_middleware` and the query layer) so cross-process test suites can build the account
6
6
  * route shapes — and assert on the `POST /login` / `GET /api/account/status`
7
- * response shapes — without dragging the in-process Hono session handler, and
8
- * its optional `hono` peer, onto a backend-spawning consumer. `account_routes.ts`
7
+ * response shapes — without dragging the in-process session handlers and
8
+ * their queries onto a backend-spawning consumer. `account_routes.ts`
9
9
  * imports these back and attaches the live handlers; single source of truth
10
10
  * for the wire shape.
11
11
  *
@@ -16,7 +16,7 @@ import { ActorSummaryJson, RoleGrantSummaryJson, SessionAccountJson } from './ac
16
16
  import { UsernameCanonical, UsernameProvided } from '../primitive_schemas.js';
17
17
  import { Password, PasswordProvided } from './password.js';
18
18
  import { define_route_shape } from '../http/route_spec.js';
19
- import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS } from '../http/error_schemas.js';
19
+ import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS, REST_INVALID_QUERY_PARAMS } from '../http/error_schemas.js';
20
20
  /** Input for `GET /api/account/status`, `literal(null)`. No parameters — caller is the subject. */
21
21
  export const AccountStatusInput = literal(null);
22
22
  /** Output for `GET /api/account/status`, a `@fuzdev/fuz_schema` schema. */
@@ -88,7 +88,7 @@ export const DEFAULT_MAX_TOKENS = 10;
88
88
  * context; surface generation attaches a stub.
89
89
  *
90
90
  * The path is **relative** like the sibling account shapes (`/login`,
91
- * `/verify`), so it composes under `prefix_route_specs('/api/account', …)` into
91
+ * `/logout`), so it composes under `prefix_route_specs('/api/account', …)` into
92
92
  * `/api/account/status`. `create_account_route_specs` bundles it (so every
93
93
  * account surface serves `/status`, matching the Rust `account_router`);
94
94
  * mirror Rust by mounting it as part of the account family, not separately.
@@ -103,35 +103,21 @@ export const account_status_route_shape = define_route_shape({
103
103
  description: 'Current account info (unauthenticated: 401 with bootstrap status)',
104
104
  input: AccountStatusInput,
105
105
  output: AccountStatusOutput,
106
- errors: [REST_AUTHENTICATION_REQUIRED_BOOTSTRAP]
106
+ // the query is read after the anonymous 401, decoded strictly
107
+ errors: [REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_QUERY_PARAMS]
107
108
  });
108
109
  /**
109
- * The four account route shapes (`/verify`, `/login`, `/logout`, `/password`)
110
+ * The account route shapes (`/login`, `/logout`, `/password`)
110
111
  * minus their handlers — pure hono-free data. `create_account_route_specs`
111
112
  * attaches the live handler to each (`attach_route_handler`); cross-process
112
113
  * surface builders attach stubs (`stub_route_spec`). Single source of truth —
113
114
  * the shapes can't drift between the live routes and the surface.
114
115
  *
115
- * Returns a fixed 4-tuple `[verify, login, logout, password]` so destructuring
116
+ * Returns a fixed tuple `[login, logout, password]` so destructuring
116
117
  * yields non-optional shapes under `noUncheckedIndexedAccess`, each with the
117
118
  * types `attach_route_handler` checks its handler against.
118
119
  */
119
120
  export const create_account_route_shapes = (options) => [
120
- define_route_shape({
121
- method: 'GET',
122
- path: '/verify',
123
- // a non-RPC surface: the probe answers 200 for the account behind a
124
- // credential, so a narrowed token is refused it (it would otherwise pass
125
- // an nginx `auth_request` gate as its account)
126
- auth: {
127
- account: 'required',
128
- actor: 'none',
129
- required_scope: 'surface:account_verify'
130
- },
131
- description: 'Session-validity probe for nginx auth_request (empty body; 200, 401, or 403 for a narrowed token)',
132
- input: literal(null),
133
- output: literal(null)
134
- }),
135
121
  define_route_shape({
136
122
  method: 'POST',
137
123
  path: '/login',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Returns `RouteSpec[]` — caller applies them to Hono via `apply_route_specs`.
5
5
  *
6
- * Four REST flows remain here; each has a concrete reason to stay REST
6
+ * These REST flows remain here, each with a concrete reason to stay REST
7
7
  * rather than moving to `auth/account_actions.ts`:
8
8
  *
9
9
  * - `POST /login` — issues a signed `Set-Cookie` and pre-handler rate-limits
@@ -11,8 +11,6 @@
11
11
  * - `POST /logout` — clears the session cookie.
12
12
  * - `POST /password` — cookie clear + revoke-all cascade; rate-limit-shaped
13
13
  * error envelope on 429.
14
- * - `GET /verify` — empty-body nginx `auth_request` probe. Programmatic
15
- * callers should use the `account_verify` RPC action for the typed payload.
16
14
  *
17
15
  * Session listing/revocation and API token CRUD are on the RPC endpoint —
18
16
  * see `auth/account_actions.ts`. Signup is in `auth/signup_routes.ts`. Defaults are
@@ -21,7 +19,7 @@
21
19
  *
22
20
  * @module
23
21
  */
24
- import type { SessionOptions } from './session_cookie.js';
22
+ import { type SessionOptions } from './session_cookie.js';
25
23
  import { type RouteSpec } from '../http/route_spec.js';
26
24
  import { type RateLimiter } from '../rate_limiter.js';
27
25
  import type { RouteFactoryDeps } from './deps.js';
@@ -38,7 +36,7 @@ import type { RouteFactoryDeps } from './deps.js';
38
36
  * its verification state, and the acting actor's role grants; the route
39
37
  * already answers anonymous callers, so that answer is the refusal — a 403
40
38
  * would tell the holder nothing that dropping the header doesn't. The handler
41
- * reads the credential through `get_public_account_id`, which applies it.
39
+ * reads the credential through `get_public_account`, which applies it.
42
40
  *
43
41
  * This eliminates the need for a separate `/health` fetch on page load —
44
42
  * the frontend gets both session state and bootstrap availability in one request.
@@ -136,8 +134,8 @@ export interface AccountRouteOptions extends AuthSessionRouteOptions {
136
134
  * Create account route specs for session-based auth.
137
135
  *
138
136
  * The returned specs cover the REST flows that stay after the RPC migration:
139
- * `/status` (account info + bootstrap availability), `/verify` (nginx
140
- * `auth_request` shim), `/login`, `/logout`, `/password`. `/status` is bundled
137
+ * `/status` (account info + bootstrap availability), `/login`, `/logout`,
138
+ * `/password`. `/status` is bundled
141
139
  * here (relative path, prefixed to `/api/account/status` by the caller) so
142
140
  * every account surface serves it, matching the Rust `account_router`.
143
141
  * Self-service session/token management is on `auth/account_actions.ts`.
@@ -1 +1 @@
1
- {"version":3,"file":"account_routes.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA4B1D,OAAO,EAAyC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAK9F,OAAO,EAAoB,KAAK,WAAW,EAA6B,MAAM,oBAAoB,CAAC;AACnG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAYlD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gCAAgC,GAAI,UAAU,oBAAoB,KAAG,SA4EjF,CAAC;AAEF,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACpC,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1C;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,uBAAuB;IACvC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IACnE;;;;;;;OAOG;IACH,qBAAqB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1C,4FAA4F;IAC5F,0BAA0B,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/C,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1C;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,0BAA0B,GACtC,MAAM,gBAAgB,EACtB,SAAS,mBAAmB,KAC1B,KAAK,CAAC,SAAS,CA0VjB,CAAC"}
1
+ {"version":3,"file":"account_routes.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAyB7B,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAI7E,OAAO,EAAoB,KAAK,WAAW,EAA6B,MAAM,oBAAoB,CAAC;AACnG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAclD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gCAAgC,GAAI,UAAU,oBAAoB,KAAG,SAiFjF,CAAC;AAEF,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACpC,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1C;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,uBAAuB;IACvC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IACnE;;;;;;;OAOG;IACH,qBAAqB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1C,4FAA4F;IAC5F,0BAA0B,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/C,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1C;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,0BAA0B,GACtC,MAAM,gBAAgB,EACtB,SAAS,mBAAmB,KAC1B,KAAK,CAAC,SAAS,CAkXjB,CAAC"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Returns `RouteSpec[]` — caller applies them to Hono via `apply_route_specs`.
5
5
  *
6
- * Four REST flows remain here; each has a concrete reason to stay REST
6
+ * These REST flows remain here, each with a concrete reason to stay REST
7
7
  * rather than moving to `auth/account_actions.ts`:
8
8
  *
9
9
  * - `POST /login` — issues a signed `Set-Cookie` and pre-handler rate-limits
@@ -11,8 +11,6 @@
11
11
  * - `POST /logout` — clears the session cookie.
12
12
  * - `POST /password` — cookie clear + revoke-all cascade; rate-limit-shaped
13
13
  * error envelope on 429.
14
- * - `GET /verify` — empty-body nginx `auth_request` probe. Programmatic
15
- * callers should use the `account_verify` RPC action for the typed payload.
16
14
  *
17
15
  * Session listing/revocation and API token CRUD are on the RPC endpoint —
18
16
  * see `auth/account_actions.ts`. Signup is in `auth/signup_routes.ts`. Defaults are
@@ -21,23 +19,23 @@
21
19
  *
22
20
  * @module
23
21
  */
24
- import { clear_session_cookie, create_session_and_set_cookie } from './session_middleware.js';
22
+ import { clear_session_cookie_header, session_cookie_header } from './session_cookie.js';
25
23
  import { RoleGrantSummaryJson, to_session_account } from './account_schema.js';
26
24
  import { account_status_route_shape, create_account_route_shapes, DEFAULT_MAX_SESSIONS } from './account_route_schema.js';
27
- import { query_session_revoke_all_for_account, query_session_revoke_by_hash_unscoped } from './session_queries.js';
28
- import { query_account_by_username_or_email, query_update_account_password } from './account_queries.js';
25
+ import { create_capped_session, query_session_revoke_all_for_account, query_session_revoke_by_hash_unscoped } from './session_queries.js';
26
+ import { query_account_by_id, query_account_by_username_or_email, query_account_lock_verified, query_update_account_password } from './account_queries.js';
29
27
  import { query_revoke_all_api_tokens_for_account } from './api_token_queries.js';
30
- import { build_account_context, build_request_context, get_public_account_id, get_request_context, require_request_context, resolve_acting_actor } from './request_context.js';
31
- import { get_resolved_auth, resolved_auth_session_hash } from './resolved_auth.js';
32
- import { attach_route_handler, get_route_input } from '../http/route_spec.js';
33
- import { route_fail, route_ok, route_raw } from '../http/route_result.js';
34
- import { get_client_ip } from '../http/client_ip.js';
28
+ import { build_request_context, get_public_account, resolve_acting_actor } from './request_context.js';
29
+ import { resolved_auth_session_hash } from './resolved_auth.js';
30
+ import { attach_route_handler } from '../http/route_spec.js';
31
+ import { route_fail, route_ok } from '../http/route_result.js';
35
32
  import { rate_limit_ip_key } from '../http/ip_canonical.js';
36
33
  import { parse_acting } from '../http/auth_shape.js';
37
34
  import { reserve_optional } from '../rate_limiter.js';
38
35
  import { start_fail_floor, warn_if_fail_floor_disabled } from './fail_floor.js';
39
36
  import { close_connections_after_commit, queue_connection_close } from '../actions/connection_closer.js';
40
- import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS, REST_RATE_LIMIT_EXCEEDED } from '../http/error_schemas.js';
37
+ import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS, REST_INVALID_QUERY_PARAMS, REST_RATE_LIMIT_EXCEEDED } from '../http/error_schemas.js';
38
+ import { query_first } from '../http/request_target.js';
41
39
  /**
42
40
  * Create the account status route spec.
43
41
  *
@@ -51,7 +49,7 @@ import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS, REST_
51
49
  * its verification state, and the acting actor's role grants; the route
52
50
  * already answers anonymous callers, so that answer is the refusal — a 403
53
51
  * would tell the holder nothing that dropping the header doesn't. The handler
54
- * reads the credential through `get_public_account_id`, which applies it.
52
+ * reads the credential through `get_public_account`, which applies it.
55
53
  *
56
54
  * This eliminates the need for a separate `/health` fetch on page load —
57
55
  * the frontend gets both session state and bootstrap availability in one request.
@@ -67,16 +65,16 @@ export const create_account_status_route_spec = (options) => {
67
65
  return attach_route_handler({
68
66
  ...account_status_route_shape,
69
67
  path: options?.path ?? account_status_route_shape.path
70
- }, async (c, route) => {
68
+ }, async (route) => {
71
69
  // a narrowed token is the anonymous caller here, never a refusal
72
- const account_id = get_public_account_id(c);
70
+ const account_id = get_public_account(route)?.id;
73
71
  if (!account_id)
74
72
  return fail_anonymous();
75
73
  // Honor a pre-populated request context. The dispatcher's authorization
76
74
  // phase doesn't run for `auth: 'none'` routes, but a caller (test
77
75
  // harness, or future middleware) may still populate the context — use
78
76
  // it directly to avoid redundant lookups.
79
- const existing = get_request_context(c);
77
+ const existing = route.auth;
80
78
  if (existing && existing.account.id === account_id) {
81
79
  const role_grants = existing.role_grants.map((p) => ({
82
80
  id: p.id,
@@ -99,35 +97,41 @@ export const create_account_status_route_spec = (options) => {
99
97
  // surface a persona picker. The selector goes through the `ActingActor`
100
98
  // schema, lowercased; a malformed value is a missing persona —
101
99
  // account-only, never a default-actor resolve (as on the Rust spine).
102
- const acting_raw = c.req.query('acting');
100
+ // A query that doesn't decode is refused here, where it is read —
101
+ // after the anonymous 401, so a caller with no account learns nothing
102
+ // of the query.
103
+ if (!route.query_pairs.ok)
104
+ return route_fail(REST_INVALID_QUERY_PARAMS);
105
+ const acting_raw = query_first(route.query_pairs.value, 'acting');
103
106
  const acting = parse_acting(acting_raw);
107
+ // The account read again for the answer, live (`deleted_at IS NULL`),
108
+ // as the Rust twin's summary read is: one deleted or purged since the
109
+ // credential leg is the anonymous caller.
110
+ const account = await query_account_by_id(route, account_id);
111
+ if (!account)
112
+ return fail_anonymous();
104
113
  const acting_result = acting_raw !== undefined && acting === undefined
105
114
  ? null
106
- : await resolve_acting_actor(route, account_id, acting);
115
+ : await resolve_acting_actor(route, account.id, acting);
107
116
  if (acting_result?.ok) {
108
- const ctx = await build_request_context(route, account_id, acting_result.actor_id);
109
- if (ctx) {
110
- const role_grants = ctx.role_grants.map((p) => ({
111
- id: p.id,
112
- role: p.role,
113
- scope_kind: p.scope_kind,
114
- scope_id: p.scope_id,
115
- created_at: p.created_at,
116
- expires_at: p.expires_at,
117
- granted_by: p.granted_by
118
- }));
119
- return route_ok({
120
- account: to_session_account(ctx.account),
121
- actor: { id: ctx.actor.id, name: ctx.actor.name },
122
- role_grants
123
- });
124
- }
117
+ const ctx = await build_request_context(route, account, acting_result.actor);
118
+ const role_grants = ctx.role_grants.map((p) => ({
119
+ id: p.id,
120
+ role: p.role,
121
+ scope_kind: p.scope_kind,
122
+ scope_id: p.scope_id,
123
+ created_at: p.created_at,
124
+ expires_at: p.expires_at,
125
+ granted_by: p.granted_by
126
+ }));
127
+ return route_ok({
128
+ account: to_session_account(ctx.account),
129
+ actor: { id: ctx.actor.id, name: ctx.actor.name },
130
+ role_grants
131
+ });
125
132
  }
126
- const account_ctx = await build_account_context(route, account_id);
127
- if (!account_ctx)
128
- return fail_anonymous();
129
133
  return route_ok({
130
- account: to_session_account(account_ctx.account),
134
+ account: to_session_account(account),
131
135
  actor: null,
132
136
  role_grants: []
133
137
  });
@@ -158,8 +162,8 @@ export const DEFAULT_LOGIN_FAIL_JITTER_MS = 25;
158
162
  * Create account route specs for session-based auth.
159
163
  *
160
164
  * The returned specs cover the REST flows that stay after the RPC migration:
161
- * `/status` (account info + bootstrap availability), `/verify` (nginx
162
- * `auth_request` shim), `/login`, `/logout`, `/password`. `/status` is bundled
165
+ * `/status` (account info + bootstrap availability), `/login`, `/logout`,
166
+ * `/password`. `/status` is bundled
163
167
  * here (relative path, prefixed to `/api/account/status` by the caller) so
164
168
  * every account surface serves it, matching the Rust `account_router`.
165
169
  * Self-service session/token management is on `auth/account_actions.ts`.
@@ -181,7 +185,7 @@ export const create_account_route_specs = (deps, options) => {
181
185
  const { keyring, password, connection_closer } = deps;
182
186
  const { session_options, login_ip_rate_limiter, login_account_rate_limiter, max_sessions = DEFAULT_MAX_SESSIONS, login_fail_floor_ms = DEFAULT_LOGIN_FAIL_FLOOR_MS, login_fail_jitter_ms = DEFAULT_LOGIN_FAIL_JITTER_MS, bootstrap_status } = options;
183
187
  warn_if_fail_floor_disabled('login', login_fail_floor_ms, deps.log);
184
- const [verify_shape, login_shape, logout_shape, password_shape] = create_account_route_shapes({
188
+ const [login_shape, logout_shape, password_shape] = create_account_route_shapes({
185
189
  login_account_rate_limited: login_account_rate_limiter !== null
186
190
  });
187
191
  return [
@@ -190,12 +194,7 @@ export const create_account_route_specs = (deps, options) => {
190
194
  // it — matching the Rust `account_router`. The standalone
191
195
  // `create_account_status_route_spec` stays the building block.
192
196
  create_account_status_route_spec({ bootstrap_status }),
193
- attach_route_handler(verify_shape, (c) => {
194
- require_request_context(c);
195
- // the probe's answer is its status alone, an empty body
196
- return route_raw(c.body(null, 200));
197
- }),
198
- attach_route_handler(login_shape, async (c, route) => {
197
+ attach_route_handler(login_shape, async (route) => {
199
198
  // Per-IP rate limit (before any DB/password work). Reserved, not
200
199
  // checked: the attempt counts against the cap from here until it
201
200
  // settles, so a concurrent burst can't all pass before any of it
@@ -208,9 +207,9 @@ export const create_account_route_specs = (deps, options) => {
208
207
  // address exceed its cap meanwhile. The `finally` releases whatever
209
208
  // no branch recorded.
210
209
  // keyed by the address's rate-limit key (an IPv6 client's /64)
211
- const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(get_client_ip(c)) : null;
210
+ const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(route.client_ip) : null;
212
211
  const ip_reserved = await reserve_optional(login_ip_rate_limiter, ip_key, {
213
- signal: c.req.raw.signal
212
+ signal: route.signal
214
213
  });
215
214
  if (!ip_reserved.ok) {
216
215
  return route_fail(REST_RATE_LIMIT_EXCEEDED, { retry_after: ip_reserved.retry_after });
@@ -219,17 +218,17 @@ export const create_account_route_specs = (deps, options) => {
219
218
  try {
220
219
  // `UsernameProvided` canonicalizes via `.trim().toLowerCase()` at
221
220
  // parse time — the validated value lands canonical in
222
- // `c.var.validated_input`, so the per-account rate-limit key,
221
+ // `route.input`, so the per-account rate-limit key,
223
222
  // DB lookup, and audit metadata see one form. See
224
223
  // `primitive_schemas.ts` for the schema-layer canonicalization.
225
- const { username, password: pw } = get_route_input(c);
224
+ const { username, password: pw } = route.input;
226
225
  // DB lookup first so we can key the per-account rate limit by a canonical value
227
226
  // (account.id) rather than the submitted identifier. Otherwise an attacker could
228
227
  // alternate between username and email to double the per-account bucket.
229
228
  const account = await query_account_by_username_or_email(route, username);
230
229
  const account_rate_key = account ? account.id : username;
231
230
  // Per-account rate limit (after DB lookup so the key is canonical)
232
- const account_reserved = await reserve_optional(login_account_rate_limiter, account_rate_key, { signal: c.req.raw.signal });
231
+ const account_reserved = await reserve_optional(login_account_rate_limiter, account_rate_key, { signal: route.signal });
233
232
  if (!account_reserved.ok) {
234
233
  return route_fail(REST_RATE_LIMIT_EXCEEDED, {
235
234
  retry_after: account_reserved.retry_after
@@ -249,26 +248,61 @@ export const create_account_route_specs = (deps, options) => {
249
248
  await deps.audit.emit(route, {
250
249
  event_type: 'login',
251
250
  outcome: 'failure',
252
- ip: get_client_ip(c),
251
+ ip: route.client_ip,
253
252
  metadata: { username }
254
253
  });
255
254
  await delay;
256
255
  return route_fail(REST_INVALID_CREDENTIALS);
257
256
  }
258
257
  const valid = await password.verify_password(pw, account.password_hash);
259
- if (!valid) {
258
+ // The session INSERT and the cap eviction are the route's only
259
+ // writes, and only atomic together: one transaction around just
260
+ // them (the route is `transaction: false`, so the reservation
261
+ // waits above and the Argon2 verify held no connection). Twin of
262
+ // the Rust login's transaction around `create_capped_session`. It
263
+ // first locks the account row as the verify read it — live, the
264
+ // verified hash — so a password change or a delete that committed
265
+ // since mints nothing, and one still to commit waits and then
266
+ // revokes this session (`query_account_lock_verified`). The
267
+ // cookie line is formatted inside it, so a value the formatter
268
+ // refuses rolls the session back, and rides the success, which is
269
+ // answered only once the commit has landed.
270
+ const minted = valid
271
+ ? await route.db.transaction(async (tx) => {
272
+ const tx_deps = { db: tx };
273
+ if (!(await query_account_lock_verified(tx_deps, account.id, account.password_hash))) {
274
+ return null;
275
+ }
276
+ const session = await create_capped_session({
277
+ keyring,
278
+ deps: tx_deps,
279
+ account_id: account.id,
280
+ session_options,
281
+ max_sessions
282
+ });
283
+ return {
284
+ evicted: session.evicted,
285
+ set_cookie: session_cookie_header(session.cookie_value, session_options)
286
+ };
287
+ })
288
+ : null;
289
+ // A wrong password, and a right one whose account changed under
290
+ // it, are one refusal: the same answer, charge, and audit row, so
291
+ // the caller can't learn the password was right a moment ago.
292
+ if (!minted) {
260
293
  ip_reserved.reservation.record();
261
294
  account_reservation?.record();
262
295
  await deps.audit.emit(route, {
263
296
  event_type: 'login',
264
297
  outcome: 'failure',
265
298
  account_id: account.id,
266
- ip: get_client_ip(c),
299
+ ip: route.client_ip,
267
300
  metadata: { username }
268
301
  });
269
302
  await delay;
270
303
  return route_fail(REST_INVALID_CREDENTIALS);
271
304
  }
305
+ const { evicted, set_cookie } = minted;
272
306
  // Successful login — clear the account-grain failure history only.
273
307
  // The IP aggregate is deliberately left standing: it is the
274
308
  // distributed-spray backstop, so a success on one account must not
@@ -279,19 +313,6 @@ export const create_account_route_specs = (deps, options) => {
279
313
  account_reservation?.release();
280
314
  if (login_account_rate_limiter)
281
315
  login_account_rate_limiter.reset(account_rate_key);
282
- // The session INSERT and the cap eviction are the route's only
283
- // writes, and only atomic together: one transaction around just
284
- // them (the route is `transaction: false`, so the reservation
285
- // waits above and the Argon2 verify held no connection). Twin of
286
- // the Rust login's transaction around `create_capped_session`.
287
- const evicted = await route.db.transaction((tx) => create_session_and_set_cookie({
288
- keyring,
289
- deps: { db: tx },
290
- c,
291
- account_id: account.id,
292
- session_options,
293
- max_sessions
294
- }));
295
316
  // The sessions the cap evicted are gone from the table, but not
296
317
  // from the connections they opened — a WebSocket keeps the
297
318
  // authority it resolved at upgrade, and an SSE stream never
@@ -306,20 +327,20 @@ export const create_account_route_specs = (deps, options) => {
306
327
  await deps.audit.emit(route, {
307
328
  event_type: 'login',
308
329
  account_id: account.id,
309
- ip: get_client_ip(c)
330
+ ip: route.client_ip
310
331
  });
311
- return route_ok({ ok: true });
332
+ return route_ok({ ok: true }, { set_cookie: [set_cookie] });
312
333
  }
313
334
  finally {
314
335
  ip_reserved.reservation.release();
315
336
  account_reservation?.release();
316
337
  }
317
338
  }),
318
- attach_route_handler(logout_shape, async (c, route) => {
319
- const ctx = require_request_context(c);
339
+ attach_route_handler(logout_shape, async (route) => {
340
+ const ctx = route.auth;
320
341
  // the shape admits only a session credential, so this is its hash
321
342
  // (the Rust `account_logout` reads the same value)
322
- const session_hash = resolved_auth_session_hash(get_resolved_auth(c));
343
+ const session_hash = resolved_auth_session_hash(route.credential);
323
344
  if (session_hash !== null) {
324
345
  await query_session_revoke_by_hash_unscoped(route, session_hash);
325
346
  // Close this account's live connections once the revoke has
@@ -335,39 +356,40 @@ export const create_account_route_specs = (deps, options) => {
335
356
  account_id: ctx.account.id
336
357
  });
337
358
  }
338
- clear_session_cookie(c, session_options);
339
359
  // Account-grain operation — no `actor_id` (which actor was
340
360
  // resolved per-request is incidental to "this account ended
341
361
  // its session"). Mirrors `login`.
342
362
  await deps.audit.emit(route, {
343
363
  event_type: 'logout',
344
364
  account_id: ctx.account.id,
345
- ip: get_client_ip(c)
365
+ ip: route.client_ip
346
366
  });
347
- return route_ok({ ok: true, username: ctx.account.username });
367
+ // the clear rides the success, answered once the revoke and this
368
+ // row have committed — a rollback clears nothing
369
+ return route_ok({ ok: true, username: ctx.account.username }, { set_cookie: [clear_session_cookie_header(session_options)] });
348
370
  }),
349
- attach_route_handler(password_shape, async (c, route) => {
371
+ attach_route_handler(password_shape, async (route) => {
350
372
  // Per-IP rate limit (before argon2 work). Reserved, not checked:
351
373
  // the attempt counts against the shared login limiters from here
352
374
  // until it settles, so a concurrent burst of guesses at
353
375
  // `current_password` can't all pass before any of it records. The
354
376
  // `finally` releases whatever no branch recorded.
355
377
  // keyed by the address's rate-limit key (an IPv6 client's /64)
356
- const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(get_client_ip(c)) : null;
378
+ const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(route.client_ip) : null;
357
379
  const ip_reserved = await reserve_optional(login_ip_rate_limiter, ip_key, {
358
- signal: c.req.raw.signal
380
+ signal: route.signal
359
381
  });
360
382
  if (!ip_reserved.ok) {
361
383
  return route_fail(REST_RATE_LIMIT_EXCEEDED, { retry_after: ip_reserved.retry_after });
362
384
  }
363
385
  let account_reservation = null;
364
386
  try {
365
- const ctx = require_request_context(c);
366
- const { current_password, new_password } = get_route_input(c);
387
+ const ctx = route.auth;
388
+ const { current_password, new_password } = route.input;
367
389
  // Defense in depth — see `docs/security.md` §Credential-channel gating.
368
- const credential_type = get_resolved_auth(c)?.credential_type;
390
+ const credential_type = route.credential?.credential_type;
369
391
  // per-account rate limit (after context resolution, before argon2 work)
370
- const account_reserved = await reserve_optional(login_account_rate_limiter, ctx.account.id, { signal: c.req.raw.signal });
392
+ const account_reserved = await reserve_optional(login_account_rate_limiter, ctx.account.id, { signal: route.signal });
371
393
  if (!account_reserved.ok) {
372
394
  return route_fail(REST_RATE_LIMIT_EXCEEDED, {
373
395
  retry_after: account_reserved.retry_after
@@ -382,7 +404,7 @@ export const create_account_route_specs = (deps, options) => {
382
404
  event_type: 'password_change',
383
405
  outcome: 'failure',
384
406
  account_id: ctx.account.id,
385
- ip: get_client_ip(c),
407
+ ip: route.client_ip,
386
408
  metadata: { credential_type }
387
409
  });
388
410
  return route_fail(REST_INVALID_CREDENTIALS);
@@ -442,7 +464,7 @@ export const create_account_route_specs = (deps, options) => {
442
464
  event_type: 'password_change',
443
465
  outcome: 'failure',
444
466
  account_id: ctx.account.id,
445
- ip: get_client_ip(c),
467
+ ip: route.client_ip,
446
468
  metadata: { reason: 'concurrent_change', credential_type }
447
469
  });
448
470
  return route_fail(REST_INVALID_CREDENTIALS);
@@ -455,7 +477,6 @@ export const create_account_route_specs = (deps, options) => {
455
477
  // not depend on the fail-open audit write below; the audit
456
478
  // listeners repeat it on the announced `password_change` row.
457
479
  close_connections_after_commit(connection_closer, { kind: 'account', account_id: ctx.account.id }, deps.log);
458
- clear_session_cookie(c, session_options);
459
480
  // Account-grain operation — no `actor_id`. The password is
460
481
  // account-level state; which per-request actor was resolved
461
482
  // has no semantic bearing on "this account changed its
@@ -463,10 +484,10 @@ export const create_account_route_specs = (deps, options) => {
463
484
  await deps.audit.emit(route, {
464
485
  event_type: 'password_change',
465
486
  account_id: ctx.account.id,
466
- ip: get_client_ip(c),
487
+ ip: route.client_ip,
467
488
  metadata: { sessions_revoked, tokens_revoked, credential_type }
468
489
  });
469
- return route_ok({ ok: true, sessions_revoked, tokens_revoked });
490
+ return route_ok({ ok: true, sessions_revoked, tokens_revoked }, { set_cookie: [clear_session_cookie_header(session_options)] });
470
491
  }
471
492
  finally {
472
493
  ip_reserved.reservation.release();
@@ -1 +1 @@
1
- {"version":3,"file":"admin_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/admin_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIjG,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;AA2C1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA0D3D,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,yBAAyB,EAC/B,UAAS,kBAAuB,KAC9B,KAAK,CAAC,SAAS,CA6hBjB,CAAC"}
1
+ {"version":3,"file":"admin_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/admin_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIjG,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;AAwD1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA2D3D,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,yBAAyB,EAC/B,UAAS,kBAAuB,KAC9B,KAAK,CAAC,SAAS,CAmpBjB,CAAC"}