@fuzdev/fuz_app 0.179.0 → 0.181.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/dist/actions/CLAUDE.md +14 -14
  2. package/dist/actions/action_rpc.d.ts +14 -5
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +53 -46
  5. package/dist/actions/action_types.d.ts +15 -12
  6. package/dist/actions/action_types.d.ts.map +1 -1
  7. package/dist/actions/perform_action.d.ts +4 -4
  8. package/dist/actions/perform_action.d.ts.map +1 -1
  9. package/dist/actions/perform_action.js +6 -6
  10. package/dist/actions/register_action_ws.d.ts +6 -2
  11. package/dist/actions/register_action_ws.d.ts.map +1 -1
  12. package/dist/actions/register_action_ws.js +14 -3
  13. package/dist/actions/ws_socket_session.js +1 -1
  14. package/dist/auth/CLAUDE.md +36 -30
  15. package/dist/auth/account_actions.d.ts.map +1 -1
  16. package/dist/auth/account_actions.js +18 -1
  17. package/dist/auth/account_queries.d.ts +69 -0
  18. package/dist/auth/account_queries.d.ts.map +1 -1
  19. package/dist/auth/account_queries.js +82 -0
  20. package/dist/auth/account_route_schema.d.ts +26 -16
  21. package/dist/auth/account_route_schema.d.ts.map +1 -1
  22. package/dist/auth/account_route_schema.js +10 -24
  23. package/dist/auth/account_routes.d.ts +4 -6
  24. package/dist/auth/account_routes.d.ts.map +1 -1
  25. package/dist/auth/account_routes.js +86 -66
  26. package/dist/auth/admin_actions.d.ts.map +1 -1
  27. package/dist/auth/admin_actions.js +63 -14
  28. package/dist/auth/api_token_queries.d.ts +16 -7
  29. package/dist/auth/api_token_queries.d.ts.map +1 -1
  30. package/dist/auth/api_token_queries.js +18 -18
  31. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  32. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  33. package/dist/auth/audit_log_routes.d.ts +1 -1
  34. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  35. package/dist/auth/audit_log_routes.js +10 -12
  36. package/dist/auth/audit_log_schema.js +4 -4
  37. package/dist/auth/bearer_auth.d.ts +4 -3
  38. package/dist/auth/bearer_auth.d.ts.map +1 -1
  39. package/dist/auth/bearer_auth.js +35 -31
  40. package/dist/auth/bootstrap_account.d.ts +65 -37
  41. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  42. package/dist/auth/bootstrap_account.js +115 -66
  43. package/dist/auth/bootstrap_route_schema.d.ts +6 -2
  44. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_route_schema.js +7 -2
  46. package/dist/auth/bootstrap_routes.d.ts +50 -33
  47. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_routes.js +109 -87
  49. package/dist/auth/bootstrap_token_store.d.ts +60 -0
  50. package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
  51. package/dist/auth/bootstrap_token_store.js +39 -0
  52. package/dist/auth/credential_headers.d.ts +71 -0
  53. package/dist/auth/credential_headers.d.ts.map +1 -0
  54. package/dist/auth/credential_headers.js +100 -0
  55. package/dist/auth/daemon_token.d.ts +13 -1
  56. package/dist/auth/daemon_token.d.ts.map +1 -1
  57. package/dist/auth/daemon_token.js +14 -2
  58. package/dist/auth/daemon_token_middleware.d.ts +10 -11
  59. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  60. package/dist/auth/daemon_token_middleware.js +27 -29
  61. package/dist/auth/deps.d.ts +0 -11
  62. package/dist/auth/deps.d.ts.map +1 -1
  63. package/dist/auth/invite_queries.d.ts +18 -0
  64. package/dist/auth/invite_queries.d.ts.map +1 -1
  65. package/dist/auth/invite_queries.js +24 -0
  66. package/dist/auth/request_context.d.ts +26 -5
  67. package/dist/auth/request_context.d.ts.map +1 -1
  68. package/dist/auth/request_context.js +17 -10
  69. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  70. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  71. package/dist/auth/role_grant_offer_action_specs.js +3 -2
  72. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  73. package/dist/auth/role_grant_offer_actions.js +37 -14
  74. package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
  75. package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
  76. package/dist/auth/role_grant_offer_ddl.js +9 -2
  77. package/dist/auth/role_grant_offer_queries.d.ts +56 -3
  78. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  79. package/dist/auth/role_grant_offer_queries.js +93 -8
  80. package/dist/auth/role_grant_queries.d.ts +7 -0
  81. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  82. package/dist/auth/role_grant_queries.js +8 -0
  83. package/dist/auth/session_cookie.d.ts +105 -25
  84. package/dist/auth/session_cookie.d.ts.map +1 -1
  85. package/dist/auth/session_cookie.js +124 -15
  86. package/dist/auth/session_middleware.d.ts +83 -54
  87. package/dist/auth/session_middleware.d.ts.map +1 -1
  88. package/dist/auth/session_middleware.js +92 -66
  89. package/dist/auth/session_queries.d.ts +64 -4
  90. package/dist/auth/session_queries.d.ts.map +1 -1
  91. package/dist/auth/session_queries.js +53 -4
  92. package/dist/auth/signup_route_schema.d.ts +5 -5
  93. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  94. package/dist/auth/signup_route_schema.js +4 -4
  95. package/dist/auth/signup_routes.d.ts.map +1 -1
  96. package/dist/auth/signup_routes.js +17 -14
  97. package/dist/auth/token_scope.d.ts +5 -7
  98. package/dist/auth/token_scope.d.ts.map +1 -1
  99. package/dist/auth/token_scope.js +5 -8
  100. package/dist/dev/setup.d.ts +6 -1
  101. package/dist/dev/setup.d.ts.map +1 -1
  102. package/dist/dev/setup.js +42 -34
  103. package/dist/hono_context.d.ts +21 -0
  104. package/dist/hono_context.d.ts.map +1 -1
  105. package/dist/hono_context.js +17 -0
  106. package/dist/http/CLAUDE.md +150 -43
  107. package/dist/http/auth_shape.d.ts +3 -3
  108. package/dist/http/common_routes.js +1 -1
  109. package/dist/http/db_routes.d.ts +4 -3
  110. package/dist/http/db_routes.d.ts.map +1 -1
  111. package/dist/http/db_routes.js +14 -14
  112. package/dist/http/dev_route_error_check.d.ts +6 -3
  113. package/dist/http/dev_route_error_check.d.ts.map +1 -1
  114. package/dist/http/dev_route_error_check.js +6 -3
  115. package/dist/http/dev_set_cookie_check.d.ts +53 -0
  116. package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
  117. package/dist/http/dev_set_cookie_check.js +80 -0
  118. package/dist/http/error_schemas.d.ts +36 -1
  119. package/dist/http/error_schemas.d.ts.map +1 -1
  120. package/dist/http/error_schemas.js +39 -2
  121. package/dist/http/header_lines.d.ts +42 -0
  122. package/dist/http/header_lines.d.ts.map +1 -0
  123. package/dist/http/header_lines.js +80 -0
  124. package/dist/http/host.d.ts +12 -9
  125. package/dist/http/host.d.ts.map +1 -1
  126. package/dist/http/host.js +25 -20
  127. package/dist/http/origin.d.ts +7 -22
  128. package/dist/http/origin.d.ts.map +1 -1
  129. package/dist/http/origin.js +11 -25
  130. package/dist/http/proxy.d.ts +1 -0
  131. package/dist/http/proxy.d.ts.map +1 -1
  132. package/dist/http/proxy.js +3 -0
  133. package/dist/http/request_headers.d.ts +95 -0
  134. package/dist/http/request_headers.d.ts.map +1 -0
  135. package/dist/http/request_headers.js +110 -0
  136. package/dist/http/request_target.d.ts +134 -0
  137. package/dist/http/request_target.d.ts.map +1 -0
  138. package/dist/http/request_target.js +193 -0
  139. package/dist/http/route_error_check.d.ts +4 -11
  140. package/dist/http/route_error_check.d.ts.map +1 -1
  141. package/dist/http/route_error_check.js +4 -21
  142. package/dist/http/route_result.d.ts +127 -23
  143. package/dist/http/route_result.d.ts.map +1 -1
  144. package/dist/http/route_result.js +97 -19
  145. package/dist/http/route_spec.d.ts +298 -82
  146. package/dist/http/route_spec.d.ts.map +1 -1
  147. package/dist/http/route_spec.js +548 -71
  148. package/dist/http/simple_request.d.ts +19 -14
  149. package/dist/http/simple_request.d.ts.map +1 -1
  150. package/dist/http/simple_request.js +17 -29
  151. package/dist/http/surface.d.ts +2 -0
  152. package/dist/http/surface.d.ts.map +1 -1
  153. package/dist/http/surface.js +4 -1
  154. package/dist/realtime/outbound_budget.d.ts +1 -2
  155. package/dist/realtime/outbound_budget.d.ts.map +1 -1
  156. package/dist/realtime/outbound_budget.js +1 -2
  157. package/dist/realtime/sse.d.ts +47 -17
  158. package/dist/realtime/sse.d.ts.map +1 -1
  159. package/dist/realtime/sse.js +115 -93
  160. package/dist/realtime/sse_constants.d.ts +7 -1
  161. package/dist/realtime/sse_constants.d.ts.map +1 -1
  162. package/dist/realtime/sse_constants.js +12 -1
  163. package/dist/realtime/sse_registry.d.ts +3 -3
  164. package/dist/realtime/sse_registry.js +3 -3
  165. package/dist/runtime/deps.d.ts +20 -4
  166. package/dist/runtime/deps.d.ts.map +1 -1
  167. package/dist/runtime/mock.d.ts +7 -1
  168. package/dist/runtime/mock.d.ts.map +1 -1
  169. package/dist/runtime/mock.js +33 -3
  170. package/dist/runtime/node.d.ts.map +1 -1
  171. package/dist/runtime/node.js +2 -1
  172. package/dist/runtime/secure_file.d.ts +71 -10
  173. package/dist/runtime/secure_file.d.ts.map +1 -1
  174. package/dist/runtime/secure_file.js +91 -11
  175. package/dist/server/app_backend.d.ts +0 -8
  176. package/dist/server/app_backend.d.ts.map +1 -1
  177. package/dist/server/app_backend.js +1 -3
  178. package/dist/server/app_server.d.ts +28 -17
  179. package/dist/server/app_server.d.ts.map +1 -1
  180. package/dist/server/app_server.js +52 -34
  181. package/dist/server/serve_fact_route.d.ts.map +1 -1
  182. package/dist/server/serve_fact_route.js +49 -45
  183. package/dist/server/static.d.ts +20 -0
  184. package/dist/server/static.d.ts.map +1 -1
  185. package/dist/server/static.js +56 -8
  186. package/dist/server/unmatched_route.d.ts +42 -0
  187. package/dist/server/unmatched_route.d.ts.map +1 -0
  188. package/dist/server/unmatched_route.js +64 -0
  189. package/dist/testing/CLAUDE.md +404 -1200
  190. package/dist/testing/app_server.d.ts +3 -1
  191. package/dist/testing/app_server.d.ts.map +1 -1
  192. package/dist/testing/app_server.js +4 -10
  193. package/dist/testing/auth_apps.d.ts.map +1 -1
  194. package/dist/testing/auth_apps.js +2 -1
  195. package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
  196. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/account_lifecycle.js +277 -6
  198. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
  199. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  200. package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
  201. package/dist/testing/cross_backend/capabilities.d.ts +68 -5
  202. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  203. package/dist/testing/cross_backend/capabilities.js +20 -4
  204. package/dist/testing/cross_backend/cell_gated_create.js +1 -1
  205. package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
  206. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  207. package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
  208. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  209. package/dist/testing/cross_backend/conformance_table.js +179 -23
  210. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  211. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
  212. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  213. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
  214. package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
  215. package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
  216. package/dist/testing/cross_backend/credential_conformance.js +296 -0
  217. package/dist/testing/cross_backend/credential_conformance.json +1284 -0
  218. package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
  219. package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
  220. package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
  221. package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
  222. package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
  224. package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
  225. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
  226. package/dist/testing/cross_backend/credential_wire.js +188 -0
  227. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  228. package/dist/testing/cross_backend/default_backend_configs.js +22 -2
  229. package/dist/testing/cross_backend/default_spine_surface.js +1 -1
  230. package/dist/testing/cross_backend/differential.d.ts +1 -1
  231. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  232. package/dist/testing/cross_backend/differential.js +3 -2
  233. package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
  234. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  235. package/dist/testing/cross_backend/differential_normalize.js +11 -5
  236. package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -0
  237. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  238. package/dist/testing/cross_backend/full_spine_mount.js +7 -0
  239. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  240. package/dist/testing/cross_backend/identity_parity.js +4 -0
  241. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  242. package/dist/testing/cross_backend/in_process_setup.js +78 -4
  243. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  244. package/dist/testing/cross_backend/login_security.js +13 -10
  245. package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
  246. package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
  247. package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
  248. package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
  249. package/dist/testing/cross_backend/request_header_conformance.js +196 -0
  250. package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
  251. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
  252. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
  253. package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
  254. package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
  255. package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
  256. package/dist/testing/cross_backend/request_target_conformance.js +186 -0
  257. package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
  258. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
  259. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
  260. package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
  261. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  262. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
  263. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  264. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +2 -1
  265. package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
  266. package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
  267. package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
  268. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
  269. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  270. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
  271. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  272. package/dist/testing/cross_backend/session_cap.js +56 -29
  273. package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
  274. package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
  275. package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
  276. package/dist/testing/cross_backend/session_login.d.ts +24 -0
  277. package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
  278. package/dist/testing/cross_backend/session_login.js +31 -0
  279. package/dist/testing/cross_backend/setup.d.ts +117 -0
  280. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  281. package/dist/testing/cross_backend/setup.js +193 -9
  282. package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
  283. package/dist/testing/cross_backend/simple_request.js +5 -0
  284. package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
  285. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  286. package/dist/testing/cross_backend/spine_suites.js +88 -5
  287. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  288. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  289. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  290. package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
  291. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  292. package/dist/testing/cross_backend/sse_round_trip.js +205 -64
  293. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  294. package/dist/testing/cross_backend/testing_backdoor.js +5 -2
  295. package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
  296. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
  297. package/dist/testing/cross_backend/testing_credential_read.js +175 -0
  298. package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
  299. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  300. package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
  301. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  302. package/dist/testing/cross_backend/token_lifetime.js +58 -2
  303. package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
  304. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  305. package/dist/testing/cross_backend/transport_composition.js +13 -10
  306. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  307. package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
  308. package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
  309. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  310. package/dist/testing/cross_backend/ws_endpoint.js +19 -2
  311. package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
  312. package/dist/testing/cross_backend/ws_role_gated.js +2 -3
  313. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  314. package/dist/testing/cross_backend/ws_round_trip.js +28 -12
  315. package/dist/testing/cross_backend/xfail.d.ts +44 -11
  316. package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
  317. package/dist/testing/cross_backend/xfail.js +68 -23
  318. package/dist/testing/data_exposure.d.ts.map +1 -1
  319. package/dist/testing/data_exposure.js +4 -3
  320. package/dist/testing/integration.d.ts +1 -2
  321. package/dist/testing/integration.d.ts.map +1 -1
  322. package/dist/testing/integration.js +14 -8
  323. package/dist/testing/integration_helpers.d.ts +50 -3
  324. package/dist/testing/integration_helpers.d.ts.map +1 -1
  325. package/dist/testing/integration_helpers.js +87 -9
  326. package/dist/testing/middleware.d.ts +2 -0
  327. package/dist/testing/middleware.d.ts.map +1 -1
  328. package/dist/testing/middleware.js +9 -2
  329. package/dist/testing/round_trip.d.ts +6 -2
  330. package/dist/testing/round_trip.d.ts.map +1 -1
  331. package/dist/testing/round_trip.js +17 -6
  332. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  333. package/dist/testing/rpc_envelope_cases.js +7 -0
  334. package/dist/testing/rpc_helpers.d.ts +4 -2
  335. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  336. package/dist/testing/rpc_helpers.js +6 -1
  337. package/dist/testing/rpc_round_trip.d.ts +13 -2
  338. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  339. package/dist/testing/rpc_round_trip.js +25 -6
  340. package/dist/testing/schema_generators.d.ts +2 -2
  341. package/dist/testing/schema_generators.d.ts.map +1 -1
  342. package/dist/testing/schema_generators.js +4 -4
  343. package/dist/testing/stubs.d.ts +2 -2
  344. package/dist/testing/stubs.d.ts.map +1 -1
  345. package/dist/testing/stubs.js +8 -8
  346. package/dist/testing/transports/fetch_transport.d.ts +6 -3
  347. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  348. package/dist/testing/transports/fetch_transport.js +31 -19
  349. package/dist/testing/transports/raw_http.d.ts +61 -1
  350. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  351. package/dist/testing/transports/raw_http.js +61 -1
  352. package/dist/testing/transports/ws_raw_client.d.ts +20 -0
  353. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  354. package/dist/testing/transports/ws_raw_client.js +10 -4
  355. package/dist/testing/transports/ws_transport.d.ts +21 -1
  356. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  357. package/dist/testing/transports/ws_transport.js +58 -20
  358. package/package.json +5 -5
@@ -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';
@@ -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,SAgFjF,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_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_account_context, build_request_context, get_public_account_id, 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
  *
@@ -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_id(route);
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,7 +97,12 @@ 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);
104
107
  const acting_result = acting_raw !== undefined && acting === undefined
105
108
  ? null
@@ -158,8 +161,8 @@ export const DEFAULT_LOGIN_FAIL_JITTER_MS = 25;
158
161
  * Create account route specs for session-based auth.
159
162
  *
160
163
  * 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
164
+ * `/status` (account info + bootstrap availability), `/login`, `/logout`,
165
+ * `/password`. `/status` is bundled
163
166
  * here (relative path, prefixed to `/api/account/status` by the caller) so
164
167
  * every account surface serves it, matching the Rust `account_router`.
165
168
  * Self-service session/token management is on `auth/account_actions.ts`.
@@ -181,7 +184,7 @@ export const create_account_route_specs = (deps, options) => {
181
184
  const { keyring, password, connection_closer } = deps;
182
185
  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
186
  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({
187
+ const [login_shape, logout_shape, password_shape] = create_account_route_shapes({
185
188
  login_account_rate_limited: login_account_rate_limiter !== null
186
189
  });
187
190
  return [
@@ -190,12 +193,7 @@ export const create_account_route_specs = (deps, options) => {
190
193
  // it — matching the Rust `account_router`. The standalone
191
194
  // `create_account_status_route_spec` stays the building block.
192
195
  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) => {
196
+ attach_route_handler(login_shape, async (route) => {
199
197
  // Per-IP rate limit (before any DB/password work). Reserved, not
200
198
  // checked: the attempt counts against the cap from here until it
201
199
  // settles, so a concurrent burst can't all pass before any of it
@@ -208,9 +206,9 @@ export const create_account_route_specs = (deps, options) => {
208
206
  // address exceed its cap meanwhile. The `finally` releases whatever
209
207
  // no branch recorded.
210
208
  // 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;
209
+ const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(route.client_ip) : null;
212
210
  const ip_reserved = await reserve_optional(login_ip_rate_limiter, ip_key, {
213
- signal: c.req.raw.signal
211
+ signal: route.signal
214
212
  });
215
213
  if (!ip_reserved.ok) {
216
214
  return route_fail(REST_RATE_LIMIT_EXCEEDED, { retry_after: ip_reserved.retry_after });
@@ -219,17 +217,17 @@ export const create_account_route_specs = (deps, options) => {
219
217
  try {
220
218
  // `UsernameProvided` canonicalizes via `.trim().toLowerCase()` at
221
219
  // parse time — the validated value lands canonical in
222
- // `c.var.validated_input`, so the per-account rate-limit key,
220
+ // `route.input`, so the per-account rate-limit key,
223
221
  // DB lookup, and audit metadata see one form. See
224
222
  // `primitive_schemas.ts` for the schema-layer canonicalization.
225
- const { username, password: pw } = get_route_input(c);
223
+ const { username, password: pw } = route.input;
226
224
  // DB lookup first so we can key the per-account rate limit by a canonical value
227
225
  // (account.id) rather than the submitted identifier. Otherwise an attacker could
228
226
  // alternate between username and email to double the per-account bucket.
229
227
  const account = await query_account_by_username_or_email(route, username);
230
228
  const account_rate_key = account ? account.id : username;
231
229
  // 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 });
230
+ const account_reserved = await reserve_optional(login_account_rate_limiter, account_rate_key, { signal: route.signal });
233
231
  if (!account_reserved.ok) {
234
232
  return route_fail(REST_RATE_LIMIT_EXCEEDED, {
235
233
  retry_after: account_reserved.retry_after
@@ -249,26 +247,61 @@ export const create_account_route_specs = (deps, options) => {
249
247
  await deps.audit.emit(route, {
250
248
  event_type: 'login',
251
249
  outcome: 'failure',
252
- ip: get_client_ip(c),
250
+ ip: route.client_ip,
253
251
  metadata: { username }
254
252
  });
255
253
  await delay;
256
254
  return route_fail(REST_INVALID_CREDENTIALS);
257
255
  }
258
256
  const valid = await password.verify_password(pw, account.password_hash);
259
- if (!valid) {
257
+ // The session INSERT and the cap eviction are the route's only
258
+ // writes, and only atomic together: one transaction around just
259
+ // them (the route is `transaction: false`, so the reservation
260
+ // waits above and the Argon2 verify held no connection). Twin of
261
+ // the Rust login's transaction around `create_capped_session`. It
262
+ // first locks the account row as the verify read it — live, the
263
+ // verified hash — so a password change or a delete that committed
264
+ // since mints nothing, and one still to commit waits and then
265
+ // revokes this session (`query_account_lock_verified`). The
266
+ // cookie line is formatted inside it, so a value the formatter
267
+ // refuses rolls the session back, and rides the success, which is
268
+ // answered only once the commit has landed.
269
+ const minted = valid
270
+ ? await route.db.transaction(async (tx) => {
271
+ const tx_deps = { db: tx };
272
+ if (!(await query_account_lock_verified(tx_deps, account.id, account.password_hash))) {
273
+ return null;
274
+ }
275
+ const session = await create_capped_session({
276
+ keyring,
277
+ deps: tx_deps,
278
+ account_id: account.id,
279
+ session_options,
280
+ max_sessions
281
+ });
282
+ return {
283
+ evicted: session.evicted,
284
+ set_cookie: session_cookie_header(session.cookie_value, session_options)
285
+ };
286
+ })
287
+ : null;
288
+ // A wrong password, and a right one whose account changed under
289
+ // it, are one refusal: the same answer, charge, and audit row, so
290
+ // the caller can't learn the password was right a moment ago.
291
+ if (!minted) {
260
292
  ip_reserved.reservation.record();
261
293
  account_reservation?.record();
262
294
  await deps.audit.emit(route, {
263
295
  event_type: 'login',
264
296
  outcome: 'failure',
265
297
  account_id: account.id,
266
- ip: get_client_ip(c),
298
+ ip: route.client_ip,
267
299
  metadata: { username }
268
300
  });
269
301
  await delay;
270
302
  return route_fail(REST_INVALID_CREDENTIALS);
271
303
  }
304
+ const { evicted, set_cookie } = minted;
272
305
  // Successful login — clear the account-grain failure history only.
273
306
  // The IP aggregate is deliberately left standing: it is the
274
307
  // distributed-spray backstop, so a success on one account must not
@@ -279,19 +312,6 @@ export const create_account_route_specs = (deps, options) => {
279
312
  account_reservation?.release();
280
313
  if (login_account_rate_limiter)
281
314
  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
315
  // The sessions the cap evicted are gone from the table, but not
296
316
  // from the connections they opened — a WebSocket keeps the
297
317
  // authority it resolved at upgrade, and an SSE stream never
@@ -306,20 +326,20 @@ export const create_account_route_specs = (deps, options) => {
306
326
  await deps.audit.emit(route, {
307
327
  event_type: 'login',
308
328
  account_id: account.id,
309
- ip: get_client_ip(c)
329
+ ip: route.client_ip
310
330
  });
311
- return route_ok({ ok: true });
331
+ return route_ok({ ok: true }, { set_cookie: [set_cookie] });
312
332
  }
313
333
  finally {
314
334
  ip_reserved.reservation.release();
315
335
  account_reservation?.release();
316
336
  }
317
337
  }),
318
- attach_route_handler(logout_shape, async (c, route) => {
319
- const ctx = require_request_context(c);
338
+ attach_route_handler(logout_shape, async (route) => {
339
+ const ctx = route.auth;
320
340
  // the shape admits only a session credential, so this is its hash
321
341
  // (the Rust `account_logout` reads the same value)
322
- const session_hash = resolved_auth_session_hash(get_resolved_auth(c));
342
+ const session_hash = resolved_auth_session_hash(route.credential);
323
343
  if (session_hash !== null) {
324
344
  await query_session_revoke_by_hash_unscoped(route, session_hash);
325
345
  // Close this account's live connections once the revoke has
@@ -335,39 +355,40 @@ export const create_account_route_specs = (deps, options) => {
335
355
  account_id: ctx.account.id
336
356
  });
337
357
  }
338
- clear_session_cookie(c, session_options);
339
358
  // Account-grain operation — no `actor_id` (which actor was
340
359
  // resolved per-request is incidental to "this account ended
341
360
  // its session"). Mirrors `login`.
342
361
  await deps.audit.emit(route, {
343
362
  event_type: 'logout',
344
363
  account_id: ctx.account.id,
345
- ip: get_client_ip(c)
364
+ ip: route.client_ip
346
365
  });
347
- return route_ok({ ok: true, username: ctx.account.username });
366
+ // the clear rides the success, answered once the revoke and this
367
+ // row have committed — a rollback clears nothing
368
+ return route_ok({ ok: true, username: ctx.account.username }, { set_cookie: [clear_session_cookie_header(session_options)] });
348
369
  }),
349
- attach_route_handler(password_shape, async (c, route) => {
370
+ attach_route_handler(password_shape, async (route) => {
350
371
  // Per-IP rate limit (before argon2 work). Reserved, not checked:
351
372
  // the attempt counts against the shared login limiters from here
352
373
  // until it settles, so a concurrent burst of guesses at
353
374
  // `current_password` can't all pass before any of it records. The
354
375
  // `finally` releases whatever no branch recorded.
355
376
  // 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;
377
+ const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(route.client_ip) : null;
357
378
  const ip_reserved = await reserve_optional(login_ip_rate_limiter, ip_key, {
358
- signal: c.req.raw.signal
379
+ signal: route.signal
359
380
  });
360
381
  if (!ip_reserved.ok) {
361
382
  return route_fail(REST_RATE_LIMIT_EXCEEDED, { retry_after: ip_reserved.retry_after });
362
383
  }
363
384
  let account_reservation = null;
364
385
  try {
365
- const ctx = require_request_context(c);
366
- const { current_password, new_password } = get_route_input(c);
386
+ const ctx = route.auth;
387
+ const { current_password, new_password } = route.input;
367
388
  // Defense in depth — see `docs/security.md` §Credential-channel gating.
368
- const credential_type = get_resolved_auth(c)?.credential_type;
389
+ const credential_type = route.credential?.credential_type;
369
390
  // 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 });
391
+ const account_reserved = await reserve_optional(login_account_rate_limiter, ctx.account.id, { signal: route.signal });
371
392
  if (!account_reserved.ok) {
372
393
  return route_fail(REST_RATE_LIMIT_EXCEEDED, {
373
394
  retry_after: account_reserved.retry_after
@@ -382,7 +403,7 @@ export const create_account_route_specs = (deps, options) => {
382
403
  event_type: 'password_change',
383
404
  outcome: 'failure',
384
405
  account_id: ctx.account.id,
385
- ip: get_client_ip(c),
406
+ ip: route.client_ip,
386
407
  metadata: { credential_type }
387
408
  });
388
409
  return route_fail(REST_INVALID_CREDENTIALS);
@@ -442,7 +463,7 @@ export const create_account_route_specs = (deps, options) => {
442
463
  event_type: 'password_change',
443
464
  outcome: 'failure',
444
465
  account_id: ctx.account.id,
445
- ip: get_client_ip(c),
466
+ ip: route.client_ip,
446
467
  metadata: { reason: 'concurrent_change', credential_type }
447
468
  });
448
469
  return route_fail(REST_INVALID_CREDENTIALS);
@@ -455,7 +476,6 @@ export const create_account_route_specs = (deps, options) => {
455
476
  // not depend on the fail-open audit write below; the audit
456
477
  // listeners repeat it on the announced `password_change` row.
457
478
  close_connections_after_commit(connection_closer, { kind: 'account', account_id: ctx.account.id }, deps.log);
458
- clear_session_cookie(c, session_options);
459
479
  // Account-grain operation — no `actor_id`. The password is
460
480
  // account-level state; which per-request actor was resolved
461
481
  // has no semantic bearing on "this account changed its
@@ -463,10 +483,10 @@ export const create_account_route_specs = (deps, options) => {
463
483
  await deps.audit.emit(route, {
464
484
  event_type: 'password_change',
465
485
  account_id: ctx.account.id,
466
- ip: get_client_ip(c),
486
+ ip: route.client_ip,
467
487
  metadata: { sessions_revoked, tokens_revoked, credential_type }
468
488
  });
469
- return route_ok({ ok: true, sessions_revoked, tokens_revoked });
489
+ return route_ok({ ok: true, sessions_revoked, tokens_revoked }, { set_cookie: [clear_session_cookie_header(session_options)] });
470
490
  }
471
491
  finally {
472
492
  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;AAiD1B,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,CA8lBjB,CAAC"}
@@ -36,16 +36,16 @@ import { builtin_role_specs, list_roles_with_grant_path, ROLE_ADMIN, ROLE_KEEPER
36
36
  import { has_scoped_role } from './request_context.js';
37
37
  import { query_account_has_global_role, query_account_has_active_global_role, query_count_active_accounts_with_global_role_for_update } from './role_grant_queries.js';
38
38
  import { GRANT_PATH_ADMIN } from './grant_path_schema.js';
39
- import { query_role_grant_offer_supersede_outgoing } from './role_grant_offer_queries.js';
40
- import { query_account_by_email, query_account_by_id, query_account_by_username, query_account_soft_delete, query_account_undelete, query_actor_soft_delete, query_actor_undelete, query_actors_by_account, query_admin_account_list, query_purge_account } from './account_queries.js';
39
+ import { query_role_grant_offer_supersede_incoming, query_role_grant_offer_supersede_outgoing } from './role_grant_offer_queries.js';
40
+ import { query_account_by_email, query_account_by_id, query_account_by_username, query_account_lock_live, query_account_soft_delete, query_account_undelete, query_actor_soft_delete, query_actor_undelete, query_actors_by_account, query_admin_account_list, query_purge_account } from './account_queries.js';
41
41
  import { query_session_list_all_active, query_session_revoke_all_for_account } from './session_queries.js';
42
42
  import { query_revoke_all_api_tokens_for_account } from './api_token_queries.js';
43
43
  import { query_audit_log_list_role_grant_history, query_audit_log_list_with_usernames } from './audit_log_queries.js';
44
44
  import { AUDIT_LOG_DEFAULT_LIMIT } from './audit_log_schema.js';
45
- import { query_create_invite, query_invite_delete_unclaimed, query_invite_list_all_with_usernames } from './invite_queries.js';
45
+ import { query_create_invite, query_invite_delete_unclaimed, query_invite_delete_unclaimed_by_creators, query_invite_list_all_with_usernames } from './invite_queries.js';
46
46
  import { query_app_settings_load, query_app_settings_load_with_username, query_app_settings_update } from './app_settings_queries.js';
47
47
  import { is_pg_unique_violation } from '../db/pg_error.js';
48
- import { ERROR_ACCOUNT_NOT_FOUND, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_INVITE_ACCOUNT_EXISTS_EMAIL, ERROR_INVITE_ACCOUNT_EXISTS_USERNAME, ERROR_INVITE_DUPLICATE, ERROR_INVITE_NOT_FOUND } from '../http/error_schemas.js';
48
+ import { ERROR_ACCOUNT_NOT_FOUND, ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_INVITE_ACCOUNT_EXISTS_EMAIL, ERROR_INVITE_ACCOUNT_EXISTS_USERNAME, ERROR_INVITE_DUPLICATE, ERROR_INVITE_NOT_FOUND } from '../http/error_schemas.js';
49
49
  import { admin_account_list_action_spec, admin_session_list_action_spec, admin_session_revoke_all_action_spec, admin_token_revoke_all_action_spec, audit_log_list_action_spec, audit_log_role_grant_history_action_spec, invite_create_action_spec, invite_list_action_spec, invite_delete_action_spec, account_delete_action_spec, account_purge_action_spec, account_undelete_action_spec, app_settings_get_action_spec, app_settings_update_action_spec, ERROR_PURGE_NOT_CONFIRMED, ERROR_CANNOT_DELETE_KEEPER, ERROR_CANNOT_DELETE_LAST_ADMIN } from './admin_action_specs.js';
50
50
  /**
51
51
  * Create the admin-only RPC actions.
@@ -166,6 +166,16 @@ export const create_admin_actions = (deps, options = {}) => {
166
166
  });
167
167
  }
168
168
  }
169
+ // The issuer's account was read before this transaction. A delete
170
+ // committed since creates nothing — refused as the dead credential it now
171
+ // is, as `account_token_create` refuses it — and one still to commit
172
+ // waits on this lock, then deletes the invite with the account's other
173
+ // unclaimed ones: a delete writes its tombstone first.
174
+ if (!(await query_account_lock_live(ctx, auth.account.id))) {
175
+ throw jsonrpc_errors.unauthenticated('unauthenticated', {
176
+ reason: ERROR_AUTHENTICATION_REQUIRED
177
+ });
178
+ }
169
179
  let invite;
170
180
  try {
171
181
  invite = await query_create_invite(ctx, {
@@ -252,13 +262,10 @@ export const create_admin_actions = (deps, options = {}) => {
252
262
  await deny(ERROR_CANNOT_DELETE_LAST_ADMIN, `cannot ${verb} the last admin account`);
253
263
  }
254
264
  };
255
- // Supersede every pending offer the removed account's actors made, audited
256
- // — the cascade a revoke runs on the revokee's offers. An offer records no
257
- // authority, so one outliving its grantor's account would still confer on
258
- // accept. No supersede notification: a cascade notifies the grantor, and the
259
- // grantor's connections close with its account. `cause_id` is the account.
260
- const cancel_outgoing_offers = async (ctx, target_account_id, actors) => {
261
- const superseded = await query_role_grant_offer_supersede_outgoing(ctx, actors.map((a) => a.id));
265
+ // One `role_grant_offer_supersede` row per offer an account removal ended,
266
+ // `reason: 'account_deleted'` and `cause_id` the removed account, whichever
267
+ // side of the offer the account was on.
268
+ const emit_account_deleted_supersedes = async (ctx, target_account_id, superseded) => {
262
269
  for (const offer of superseded) {
263
270
  await deps.audit.emit_role_grant_target(ctx, ctx.auth, {
264
271
  event_type: 'role_grant_offer_supersede',
@@ -274,12 +281,46 @@ export const create_admin_actions = (deps, options = {}) => {
274
281
  });
275
282
  }
276
283
  };
284
+ // Supersede every pending offer the removed account's actors made, audited
285
+ // — the cascade a revoke runs on the revokee's offers. An offer records no
286
+ // authority, so one outliving its grantor's account would still confer on
287
+ // accept. No supersede notification: a cascade notifies the grantor, and the
288
+ // grantor's connections close with its account. `cause_id` is the account.
289
+ const cancel_outgoing_offers = async (ctx, target_account_id, actors) => {
290
+ const superseded = await query_role_grant_offer_supersede_outgoing(ctx, actors.map((a) => a.id));
291
+ await emit_account_deleted_supersedes(ctx, target_account_id, superseded);
292
+ };
293
+ // Supersede every pending offer made to the deleted account, account- or
294
+ // actor-addressed, audited as the outgoing cascade is and, like it, with no
295
+ // notification. An undelete restores the account, so an offer left pending
296
+ // through the delete would come back with it and could be accepted.
297
+ const cancel_incoming_offers = async (ctx, target_account_id) => {
298
+ const superseded = await query_role_grant_offer_supersede_incoming(ctx, target_account_id);
299
+ await emit_account_deleted_supersedes(ctx, target_account_id, superseded);
300
+ };
301
+ // Delete the unclaimed invites the removed account's actors issued, each
302
+ // audited as an `invite_delete` is. An invite records no authority, so one
303
+ // outliving its issuer's account would still admit a signup; deleted, it
304
+ // answers a signup as a revoked one does, and an undelete can't revive it.
305
+ // A claimed invite is untouched.
306
+ const void_unclaimed_invites = async (ctx, actors) => {
307
+ const invite_ids = await query_invite_delete_unclaimed_by_creators(ctx, actors.map((a) => a.id));
308
+ for (const invite_id of invite_ids) {
309
+ await deps.audit.emit(ctx, {
310
+ event_type: 'invite_delete',
311
+ account_id: ctx.auth.account.id,
312
+ ip: ctx.client_ip,
313
+ metadata: { invite_id }
314
+ });
315
+ }
316
+ };
277
317
  // Soft-delete an account (reversible tombstone). Self-or-admin:
278
318
  // deleting another account requires the admin role. A self-delete is
279
319
  // session-only — enforced here, not on the spec, whose gate stays open so
280
320
  // an admin deleting another account keeps any credential. Tombstones the
281
- // account + its actor(s), supersedes the pending offers its actors made,
282
- // revokes sessions/tokens, closes sockets, and
321
+ // account + its actor(s), supersedes the pending offers its actors made and
322
+ // the ones made to it, revokes sessions/tokens, deletes the unclaimed
323
+ // invites its actors issued, closes sockets, and
283
324
  // emits `account_delete` + one `actor_delete` per soft-deleted actor —
284
325
  // each carrying its identity snapshot. `delete` = soft.
285
326
  const account_delete_handler = async (input, ctx) => {
@@ -319,6 +360,7 @@ export const create_admin_actions = (deps, options = {}) => {
319
360
  throw jsonrpc_errors.not_found('account', { reason: ERROR_ACCOUNT_NOT_FOUND });
320
361
  }
321
362
  await cancel_outgoing_offers(ctx, target_account_id, actors);
363
+ await cancel_incoming_offers(ctx, target_account_id);
322
364
  const soft_deleted_actors = [];
323
365
  for (const actor of actors) {
324
366
  if (await query_actor_soft_delete(ctx, actor.id, auth.actor.id)) {
@@ -327,6 +369,7 @@ export const create_admin_actions = (deps, options = {}) => {
327
369
  }
328
370
  await query_session_revoke_all_for_account(ctx, target_account_id);
329
371
  await query_revoke_all_api_tokens_for_account(ctx, target_account_id);
372
+ await void_unclaimed_invites(ctx, actors);
330
373
  // The tombstone ends every credential of the account; its connections
331
374
  // close once that has committed.
332
375
  queue_connection_close(ctx, connection_closer, {
@@ -374,6 +417,9 @@ export const create_admin_actions = (deps, options = {}) => {
374
417
  // Before the cascade, whose `ON DELETE CASCADE` would take the offers
375
418
  // with no audit row.
376
419
  await cancel_outgoing_offers(ctx, input.account_id, actors);
420
+ // Before the cascade too: `invite.created_by` is `ON DELETE SET NULL`, so
421
+ // the cascade would leave the account's unclaimed invites usable.
422
+ await void_unclaimed_invites(ctx, actors);
377
423
  const snapshot = await query_purge_account(ctx, input.account_id);
378
424
  if (!snapshot) {
379
425
  await deps.audit.emit(ctx, {
@@ -418,7 +464,10 @@ export const create_admin_actions = (deps, options = {}) => {
418
464
  // the self path is unreachable (a tombstoned account can't authenticate).
419
465
  // Clears `deleted_at` on the account + its soft-deleted actor(s) and
420
466
  // emits `account_undelete` + one `actor_undelete` per reactivated actor.
421
- // Does NOT restore revoked sessions/tokens. The inverse of `delete`.
467
+ // The inverse of `delete` for the account, its actors and its role grants —
468
+ // the delete leaves the grants as they were, inert while no credential of
469
+ // the account authenticates — and for nothing the delete ended: revoked
470
+ // sessions and tokens, superseded offers and deleted invites stay ended.
422
471
  const account_undelete_handler = async (input, ctx) => {
423
472
  const auth = ctx.auth;
424
473
  // Snapshot actors (the listing includes soft-deleted rows) before