@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
@@ -34,18 +34,19 @@ import { credential_type_required_error } from '../actions/perform_action.js';
34
34
  import { jsonrpc_errors, ThrownJsonrpcError } from '../http/jsonrpc_errors.js';
35
35
  import { builtin_role_specs, list_roles_with_grant_path, ROLE_ADMIN, ROLE_KEEPER } from './role_schema.js';
36
36
  import { has_scoped_role } from './request_context.js';
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';
37
+ import { query_account_has_global_role, query_account_has_active_global_role, query_count_active_accounts_with_global_role_locked } 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_lock_for_account_removal, query_role_grant_offer_supersede_incoming, query_role_grant_offer_supersede_outgoing } from './role_grant_offer_queries.js';
40
+ import { queue_supersede_notifications } from './role_grant_offer_notifications.js';
41
+ import { query_account_by_email, query_account_by_id, query_account_by_username, query_account_lock_admins_for_purge, query_account_lock_for_purge, query_account_lock_live_many, 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
42
  import { query_session_list_all_active, query_session_revoke_all_for_account } from './session_queries.js';
42
43
  import { query_revoke_all_api_tokens_for_account } from './api_token_queries.js';
43
44
  import { query_audit_log_list_role_grant_history, query_audit_log_list_with_usernames } from './audit_log_queries.js';
44
45
  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';
46
+ 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
47
  import { query_app_settings_load, query_app_settings_load_with_username, query_app_settings_update } from './app_settings_queries.js';
47
48
  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';
49
+ 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
50
  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
51
  /**
51
52
  * Create the admin-only RPC actions.
@@ -166,6 +167,16 @@ export const create_admin_actions = (deps, options = {}) => {
166
167
  });
167
168
  }
168
169
  }
170
+ // The issuer's account was read before this transaction. A delete
171
+ // committed since creates nothing — refused as the dead credential it now
172
+ // is, as `account_token_create` refuses it — and one still to commit
173
+ // waits on this lock, then deletes the invite with the account's other
174
+ // unclaimed ones: a delete writes its tombstone first.
175
+ if (!(await query_account_lock_live_many(ctx, [auth.account.id])).has(auth.account.id)) {
176
+ throw jsonrpc_errors.unauthenticated('unauthenticated', {
177
+ reason: ERROR_AUTHENTICATION_REQUIRED
178
+ });
179
+ }
169
180
  let invite;
170
181
  try {
171
182
  invite = await query_create_invite(ctx, {
@@ -248,17 +259,16 @@ export const create_admin_actions = (deps, options = {}) => {
248
259
  // admin while another active admin exists. Keeper branch above stays
249
260
  // unconditional; the last-admin branch fires only for an *active* target.
250
261
  if ((await query_account_has_active_global_role(ctx, target_account_id, ROLE_ADMIN)) &&
251
- (await query_count_active_accounts_with_global_role_for_update(ctx, ROLE_ADMIN)) <= 1) {
262
+ (await query_count_active_accounts_with_global_role_locked(ctx, ROLE_ADMIN)) <= 1) {
252
263
  await deny(ERROR_CANNOT_DELETE_LAST_ADMIN, `cannot ${verb} the last admin account`);
253
264
  }
254
265
  };
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));
266
+ // One `role_grant_offer_supersede` row per offer an account removal ended,
267
+ // `reason: 'account_deleted'` and `cause_id` the removed account, whichever
268
+ // side of the offer the account was on, then the notification to the offer's
269
+ // other party — `audience`, the side the removed account is not on, with the
270
+ // `cause_id` that side is sent; the account's own connections close with it.
271
+ const emit_account_deleted_supersedes = async (ctx, target_account_id, superseded, audience) => {
262
272
  for (const offer of superseded) {
263
273
  await deps.audit.emit_role_grant_target(ctx, ctx.auth, {
264
274
  event_type: 'role_grant_offer_supersede',
@@ -273,13 +283,63 @@ export const create_admin_actions = (deps, options = {}) => {
273
283
  }
274
284
  });
275
285
  }
286
+ queue_supersede_notifications(ctx, superseded, 'account_deleted', audience);
287
+ };
288
+ // Lock every pending offer the removal supersedes, both directions, in one
289
+ // id-ordered statement before either supersede writes — the order every
290
+ // multi-row offer write takes its rows in
291
+ // (`query_role_grant_offer_lock_for_account_removal` has why).
292
+ const lock_removed_account_offers = (ctx, target_account_id, actors) => query_role_grant_offer_lock_for_account_removal(ctx, target_account_id, actors.map((a) => a.id));
293
+ // Supersede every pending offer the removed account's actors made, audited
294
+ // — the cascade a revoke runs on the revokee's offers. An offer records no
295
+ // authority, so one outliving its grantor's account would still confer on
296
+ // accept. Each recipient is told, sent its grantor's actor as `cause_id` — an
297
+ // id it already holds, where the audit row's is the removed account's; the
298
+ // grantor is the removed account.
299
+ const cancel_outgoing_offers = async (ctx, target_account_id, actors) => {
300
+ const superseded = await query_role_grant_offer_supersede_outgoing(ctx, actors.map((a) => a.id));
301
+ await emit_account_deleted_supersedes(ctx, target_account_id, superseded, {
302
+ grantor: null,
303
+ recipient: { kind: 'from_actor' }
304
+ });
305
+ };
306
+ // Supersede every pending offer made to the removed account, account- or
307
+ // actor-addressed, audited as the outgoing cascade is, each grantor told,
308
+ // sent the removed account as `cause_id` (the offer's `to_account_id`). An
309
+ // undelete restores a deleted account, so an offer left pending through the
310
+ // delete would come back with it and could be accepted; a purge's cascade
311
+ // would take the offers with no audit row and no word to their grantors.
312
+ const cancel_incoming_offers = async (ctx, target_account_id) => {
313
+ const superseded = await query_role_grant_offer_supersede_incoming(ctx, target_account_id);
314
+ await emit_account_deleted_supersedes(ctx, target_account_id, superseded, {
315
+ grantor: { kind: 'id', id: target_account_id },
316
+ recipient: null
317
+ });
318
+ };
319
+ // Delete the unclaimed invites the removed account's actors issued, each
320
+ // audited as an `invite_delete` is. An invite records no authority, so one
321
+ // outliving its issuer's account would still admit a signup; deleted, it
322
+ // answers a signup as a revoked one does, and an undelete can't revive it.
323
+ // A claimed invite is untouched.
324
+ const void_unclaimed_invites = async (ctx, actors) => {
325
+ const invite_ids = await query_invite_delete_unclaimed_by_creators(ctx, actors.map((a) => a.id));
326
+ for (const invite_id of invite_ids) {
327
+ await deps.audit.emit(ctx, {
328
+ event_type: 'invite_delete',
329
+ account_id: ctx.auth.account.id,
330
+ ip: ctx.client_ip,
331
+ metadata: { invite_id }
332
+ });
333
+ }
276
334
  };
277
335
  // Soft-delete an account (reversible tombstone). Self-or-admin:
278
336
  // deleting another account requires the admin role. A self-delete is
279
337
  // session-only — enforced here, not on the spec, whose gate stays open so
280
338
  // 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
339
+ // account + its actor(s), supersedes the pending offers its actors made and
340
+ // the ones made to it (each offer's other party told), revokes
341
+ // sessions/tokens, deletes the unclaimed
342
+ // invites its actors issued, closes sockets, and
283
343
  // emits `account_delete` + one `actor_delete` per soft-deleted actor —
284
344
  // each carrying its identity snapshot. `delete` = soft.
285
345
  const account_delete_handler = async (input, ctx) => {
@@ -318,7 +378,9 @@ export const create_admin_actions = (deps, options = {}) => {
318
378
  });
319
379
  throw jsonrpc_errors.not_found('account', { reason: ERROR_ACCOUNT_NOT_FOUND });
320
380
  }
381
+ await lock_removed_account_offers(ctx, target_account_id, actors);
321
382
  await cancel_outgoing_offers(ctx, target_account_id, actors);
383
+ await cancel_incoming_offers(ctx, target_account_id);
322
384
  const soft_deleted_actors = [];
323
385
  for (const actor of actors) {
324
386
  if (await query_actor_soft_delete(ctx, actor.id, auth.actor.id)) {
@@ -327,6 +389,7 @@ export const create_admin_actions = (deps, options = {}) => {
327
389
  }
328
390
  await query_session_revoke_all_for_account(ctx, target_account_id);
329
391
  await query_revoke_all_api_tokens_for_account(ctx, target_account_id);
392
+ await void_unclaimed_invites(ctx, actors);
330
393
  // The tombstone ends every credential of the account; its connections
331
394
  // close once that has committed.
332
395
  queue_connection_close(ctx, connection_closer, {
@@ -355,7 +418,9 @@ export const create_admin_actions = (deps, options = {}) => {
355
418
  return { ok: true, deleted: true };
356
419
  };
357
420
  // Hard-purge an account (keeper-only, irreversible). Fail-loud:
358
- // requires `confirm: true` + emits a WARN. Snapshots identity into
421
+ // requires `confirm: true` + emits a WARN. Supersedes the account's pending
422
+ // offers, both ways, as a delete does, before its cascade deletes the rows —
423
+ // the audit rows and the notifications are what remain of them. Snapshots identity into
359
424
  // `account_purge` + per-actor `actor_purge` before the cascading delete
360
425
  // removes the rows — the `audit_log` id columns carry no FK, so the
361
426
  // purged ids survive on historical rows and the snapshots name them.
@@ -367,15 +432,17 @@ export const create_admin_actions = (deps, options = {}) => {
367
432
  reason: ERROR_PURGE_NOT_CONFIRMED
368
433
  });
369
434
  }
435
+ // Every admin's account row and the target's, in one id-ordered statement:
436
+ // the cascade writes admin rows (the grants the target's actors granted).
437
+ // Every other removal's guard and every other purge take those accounts
438
+ // first, and no other writer of an admin's grant waits on an account row
439
+ // while holding one, so holding the accounts orders the purge before any of
440
+ // them (`query_account_lock_admins_for_purge` has why). The last-admin guard
441
+ // then runs only for an admin target, in `assert_account_removable`.
442
+ await query_account_lock_admins_for_purge(ctx, input.account_id);
370
443
  // Keeper + last-admin guards (fail-loud, before the cascade).
371
444
  await assert_account_removable(ctx, input.account_id, 'account_purge');
372
- // Snapshot actors before the cascade removes them.
373
- const actors = await query_actors_by_account(ctx, input.account_id);
374
- // Before the cascade, whose `ON DELETE CASCADE` would take the offers
375
- // with no audit row.
376
- await cancel_outgoing_offers(ctx, input.account_id, actors);
377
- const snapshot = await query_purge_account(ctx, input.account_id);
378
- if (!snapshot) {
445
+ const refuse_not_found = async () => {
379
446
  await deps.audit.emit(ctx, {
380
447
  event_type: 'account_purge',
381
448
  outcome: 'failure',
@@ -385,7 +452,29 @@ export const create_admin_actions = (deps, options = {}) => {
385
452
  metadata: { reason: ERROR_ACCOUNT_NOT_FOUND, attempted_account_id: input.account_id }
386
453
  });
387
454
  throw jsonrpc_errors.not_found('account', { reason: ERROR_ACCOUNT_NOT_FOUND });
388
- }
455
+ };
456
+ // The account row before any write, as every writer of the account takes
457
+ // it — `query_account_lock_for_purge` has why.
458
+ if (!(await query_account_lock_for_purge(ctx, input.account_id)))
459
+ await refuse_not_found();
460
+ // Snapshot actors before the cascade removes them.
461
+ const actors = await query_actors_by_account(ctx, input.account_id);
462
+ // Before the cascade, whose `ON DELETE CASCADE` would take the offers
463
+ // with no audit row and no notification, the ones the account made and
464
+ // the ones made to it. After the account row: an offer create from or to
465
+ // the account takes that row first, so it has committed or waits.
466
+ await lock_removed_account_offers(ctx, input.account_id, actors);
467
+ await cancel_outgoing_offers(ctx, input.account_id, actors);
468
+ await cancel_incoming_offers(ctx, input.account_id);
469
+ // Before the cascade too: `invite.created_by` is `ON DELETE SET NULL`, so
470
+ // the cascade would leave the account's unclaimed invites usable.
471
+ await void_unclaimed_invites(ctx, actors);
472
+ // Before the cascade as well: it would delete the account's sessions and
473
+ // tokens in its own plan's order, against a revoke or a sweep of the
474
+ // same rows taking them in id order — the order these take them in.
475
+ await query_session_revoke_all_for_account(ctx, input.account_id);
476
+ await query_revoke_all_api_tokens_for_account(ctx, input.account_id);
477
+ const snapshot = (await query_purge_account(ctx, input.account_id)) ?? (await refuse_not_found());
389
478
  // The cascade removed every credential of the account; its connections
390
479
  // close once that has committed.
391
480
  queue_connection_close(ctx, connection_closer, {
@@ -418,7 +507,10 @@ export const create_admin_actions = (deps, options = {}) => {
418
507
  // the self path is unreachable (a tombstoned account can't authenticate).
419
508
  // Clears `deleted_at` on the account + its soft-deleted actor(s) and
420
509
  // emits `account_undelete` + one `actor_undelete` per reactivated actor.
421
- // Does NOT restore revoked sessions/tokens. The inverse of `delete`.
510
+ // The inverse of `delete` for the account, its actors and its role grants —
511
+ // the delete leaves the grants as they were, inert while no credential of
512
+ // the account authenticates — and for nothing the delete ended: revoked
513
+ // sessions and tokens, superseded offers and deleted invites stay ended.
422
514
  const account_undelete_handler = async (input, ctx) => {
423
515
  const auth = ctx.auth;
424
516
  // Snapshot actors (the listing includes soft-deleted rows) before
@@ -54,18 +54,27 @@ export declare const query_create_api_token: (deps: QueryDeps, id: string, accou
54
54
  * Hashes the token with blake3, looks up the hash, and checks
55
55
  * expiration, reading how long the token has left on the database clock in
56
56
  * the same statement. A row whose stored scope is unreadable is refused like an
57
- * unknown hash. Updates `last_used_at` and `last_used_ip` on success
58
- * (fire-and-forget — errors logged, never thrown).
57
+ * unknown hash. Records no use: the caller touches the token
58
+ * (`query_api_token_touch`) once it has also found the account live, so a
59
+ * token on a tombstoned account records none — the Rust twin's order.
59
60
  *
60
61
  * @param deps - query dependencies with logger
61
62
  * @param raw_token - the raw API token from the Authorization header
62
- * @param ip - the client IP address (for audit)
63
- * @param pending_effects - optional array to register the usage-tracking effect for later awaiting
64
63
  * @returns the token record with its parsed scope if valid, or `undefined`
65
- * @mutates `api_token` row - fire-and-forget UPDATE of `last_used_at` / `last_used_ip` on a valid token
66
- * @mutates `pending_effects` - pushes the in-flight tracking promise when provided
67
64
  */
68
- export declare const query_validate_api_token: (deps: ApiTokenQueryDeps, raw_token: string, ip: string | undefined, pending_effects: Array<Promise<void>> | undefined) => Promise<ValidatedApiToken | undefined>;
65
+ export declare const query_validate_api_token: (deps: ApiTokenQueryDeps, raw_token: string) => Promise<ValidatedApiToken | undefined>;
66
+ /**
67
+ * Record a use of an API token: `last_used_at` now, `last_used_ip` the
68
+ * client's address (`null` when none resolved). The bearer leg runs it
69
+ * fire-and-forget once the token has authenticated. Twin of the Rust
70
+ * `fuz_auth::query_api_token_touch`.
71
+ *
72
+ * @param deps - query dependencies
73
+ * @param id - the public token id
74
+ * @param ip - the client IP address
75
+ * @mutates `api_token` row - sets `last_used_at` and `last_used_ip`
76
+ */
77
+ export declare const query_api_token_touch: (deps: QueryDeps, id: string, ip: string | undefined) => Promise<void>;
69
78
  /**
70
79
  * Look up the owning account of a live API token — one that still exists and
71
80
  * has not expired — by its public id.
@@ -85,6 +94,12 @@ export declare const query_api_token_live_account: (deps: QueryDeps, id: string)
85
94
  /**
86
95
  * Revoke all tokens for an account.
87
96
  *
97
+ * Locks its rows in id order before it deletes them (`ORDER BY id FOR
98
+ * UPDATE`), as the cap's eviction (`query_api_token_enforce_limit`) does, so
99
+ * the two reaching the same rows wait one on the other instead of
100
+ * deadlocking in the opposite orders their plans would otherwise walk. Twin
101
+ * of the Rust `fuz_auth::query_revoke_all_api_tokens_for_account`.
102
+ *
88
103
  * @param deps - query dependencies
89
104
  * @param account_id - the account whose tokens to revoke
90
105
  * @returns the number of tokens revoked
@@ -117,14 +132,16 @@ export declare const query_api_token_list_for_account: (deps: QueryDeps, account
117
132
  * spec declares `side_effects: true`, making one creator's INSERT +
118
133
  * enforce_limit pair atomic. That does **not** serialize concurrent creators:
119
134
  * under Read Committed, two transactions can't see each other's uncommitted
120
- * token row, so each evicts against a stale count and both can commit above
121
- * `max_tokens`. Closing this needs one serialization point per
122
- * `(account_id, credential_kind)` before count/evict/insert — see the matching
123
- * note on `query_session_enforce_limit`.
135
+ * token row, so each would evict against a stale count and both commit above
136
+ * `max_tokens`. The handler serializes them first, taking the account row
137
+ * `FOR NO KEY UPDATE` (`query_account_lock_live`) — see the matching note on
138
+ * `query_session_enforce_limit`.
124
139
  *
125
140
  * Ordering carries the same `id DESC` stability tie-breaker, with the same
126
141
  * caveat, as `query_session_enforce_limit` — deterministic survivors under a
127
- * `created_at` tie, not a guarantee that the row just inserted survives.
142
+ * `created_at` tie, not a guarantee that the row just inserted survives. The
143
+ * victims are locked in id order before the delete, as the revoke-all
144
+ * (`query_revoke_all_api_tokens_for_account`) locks its rows.
128
145
  *
129
146
  * Deleting a token row does not end the connections it opened, so the
130
147
  * returned ids are what the caller closes once the transaction commits
@@ -1 +1 @@
1
- {"version":3,"file":"api_token_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/api_token_queries.ts"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O,CAAC,KAAK,CAAC,MAAM,CAAC,CAiBvB,CAAC"}
@@ -81,18 +81,15 @@ export const query_create_api_token = async (deps, id, account_id, name, token_h
81
81
  * Hashes the token with blake3, looks up the hash, and checks
82
82
  * expiration, reading how long the token has left on the database clock in
83
83
  * the same statement. A row whose stored scope is unreadable is refused like an
84
- * unknown hash. Updates `last_used_at` and `last_used_ip` on success
85
- * (fire-and-forget — errors logged, never thrown).
84
+ * unknown hash. Records no use: the caller touches the token
85
+ * (`query_api_token_touch`) once it has also found the account live, so a
86
+ * token on a tombstoned account records none — the Rust twin's order.
86
87
  *
87
88
  * @param deps - query dependencies with logger
88
89
  * @param raw_token - the raw API token from the Authorization header
89
- * @param ip - the client IP address (for audit)
90
- * @param pending_effects - optional array to register the usage-tracking effect for later awaiting
91
90
  * @returns the token record with its parsed scope if valid, or `undefined`
92
- * @mutates `api_token` row - fire-and-forget UPDATE of `last_used_at` / `last_used_ip` on a valid token
93
- * @mutates `pending_effects` - pushes the in-flight tracking promise when provided
94
91
  */
95
- export const query_validate_api_token = async (deps, raw_token, ip, pending_effects) => {
92
+ export const query_validate_api_token = async (deps, raw_token) => {
96
93
  const token_hash = hash_api_token(raw_token);
97
94
  const row = await deps.db.query_one(`SELECT ${columns_sql(API_TOKEN_COLUMNS, api_token_expr)}, ${EXPIRES_IN_MS_SQL} AS expires_in_ms
98
95
  FROM api_token
@@ -109,19 +106,22 @@ export const query_validate_api_token = async (deps, raw_token, ip, pending_effe
109
106
  deps.log.warn(`api_token.scope is unreadable for ${row.id}; refusing the credential`);
110
107
  return undefined;
111
108
  }
112
- // Fire-and-forget usage tracking
113
- const p = deps.db
114
- .query(`UPDATE api_token SET last_used_at = NOW(), last_used_ip = $1 WHERE id = $2`, [
115
- ip ?? null,
116
- row.id
117
- ])
118
- .then(() => { })
119
- .catch((err) => {
120
- deps.log.error('Failed to update last_used_at:', err);
121
- });
122
- pending_effects?.push(p);
123
109
  return { ...row, scope };
124
110
  };
111
+ /**
112
+ * Record a use of an API token: `last_used_at` now, `last_used_ip` the
113
+ * client's address (`null` when none resolved). The bearer leg runs it
114
+ * fire-and-forget once the token has authenticated. Twin of the Rust
115
+ * `fuz_auth::query_api_token_touch`.
116
+ *
117
+ * @param deps - query dependencies
118
+ * @param id - the public token id
119
+ * @param ip - the client IP address
120
+ * @mutates `api_token` row - sets `last_used_at` and `last_used_ip`
121
+ */
122
+ export const query_api_token_touch = async (deps, id, ip) => {
123
+ await deps.db.query(`UPDATE api_token SET last_used_at = NOW(), last_used_ip = $1 WHERE id = $2`, [ip ?? null, id]);
124
+ };
125
125
  /**
126
126
  * Look up the owning account of a live API token — one that still exists and
127
127
  * has not expired — by its public id.
@@ -144,13 +144,21 @@ export const query_api_token_live_account = async (deps, id) => {
144
144
  /**
145
145
  * Revoke all tokens for an account.
146
146
  *
147
+ * Locks its rows in id order before it deletes them (`ORDER BY id FOR
148
+ * UPDATE`), as the cap's eviction (`query_api_token_enforce_limit`) does, so
149
+ * the two reaching the same rows wait one on the other instead of
150
+ * deadlocking in the opposite orders their plans would otherwise walk. Twin
151
+ * of the Rust `fuz_auth::query_revoke_all_api_tokens_for_account`.
152
+ *
147
153
  * @param deps - query dependencies
148
154
  * @param account_id - the account whose tokens to revoke
149
155
  * @returns the number of tokens revoked
150
156
  * @mutates `api_token` table - deletes every row for `account_id`
151
157
  */
152
158
  export const query_revoke_all_api_tokens_for_account = async (deps, account_id) => {
153
- const rows = await deps.db.query(`DELETE FROM api_token WHERE account_id = $1 RETURNING id`, [account_id]);
159
+ const rows = await deps.db.query(`DELETE FROM api_token
160
+ WHERE id IN (SELECT id FROM api_token WHERE account_id = $1 ORDER BY id FOR UPDATE)
161
+ RETURNING id`, [account_id]);
154
162
  return rows.length;
155
163
  };
156
164
  /**
@@ -185,14 +193,16 @@ export const query_api_token_list_for_account = async (deps, account_id) => {
185
193
  * spec declares `side_effects: true`, making one creator's INSERT +
186
194
  * enforce_limit pair atomic. That does **not** serialize concurrent creators:
187
195
  * under Read Committed, two transactions can't see each other's uncommitted
188
- * token row, so each evicts against a stale count and both can commit above
189
- * `max_tokens`. Closing this needs one serialization point per
190
- * `(account_id, credential_kind)` before count/evict/insert — see the matching
191
- * note on `query_session_enforce_limit`.
196
+ * token row, so each would evict against a stale count and both commit above
197
+ * `max_tokens`. The handler serializes them first, taking the account row
198
+ * `FOR NO KEY UPDATE` (`query_account_lock_live`) — see the matching note on
199
+ * `query_session_enforce_limit`.
192
200
  *
193
201
  * Ordering carries the same `id DESC` stability tie-breaker, with the same
194
202
  * caveat, as `query_session_enforce_limit` — deterministic survivors under a
195
- * `created_at` tie, not a guarantee that the row just inserted survives.
203
+ * `created_at` tie, not a guarantee that the row just inserted survives. The
204
+ * victims are locked in id order before the delete, as the revoke-all
205
+ * (`query_revoke_all_api_tokens_for_account`) locks its rows.
196
206
  *
197
207
  * Deleting a token row does not end the connections it opened, so the
198
208
  * returned ids are what the caller closes once the transaction commits
@@ -209,9 +219,14 @@ export const query_api_token_enforce_limit = async (deps, account_id, max_tokens
209
219
  const rows = await deps.db.query(`DELETE FROM api_token
210
220
  WHERE id IN (
211
221
  SELECT id FROM api_token
212
- WHERE account_id = $1
213
- ORDER BY created_at DESC, id DESC
214
- OFFSET $2
222
+ WHERE id IN (
223
+ SELECT id FROM api_token
224
+ WHERE account_id = $1
225
+ ORDER BY created_at DESC, id DESC
226
+ OFFSET $2
227
+ )
228
+ ORDER BY id
229
+ FOR UPDATE
215
230
  ) RETURNING id`, [account_id, max_tokens]);
216
231
  return rows.map((row) => row.id);
217
232
  };
@@ -39,5 +39,5 @@ export interface AuditStreamAuth {
39
39
  * @param required_role - role gating the stream (default `DEFAULT_AUDIT_STREAM_ROLE`)
40
40
  * @returns the SSE route shape minus its handler
41
41
  */
42
- export declare const create_audit_log_route_shape: (required_role?: string) => RouteShape<[], Schema<null, null, "literal", null>, AuditStreamAuth, undefined>;
42
+ export declare const create_audit_log_route_shape: (required_role?: string) => RouteShape<[], Schema<null, null, "literal", null>, AuditStreamAuth, undefined, Schema<null, null, "literal", null>, undefined, typeof AuditStreamQuery>;
43
43
  //# sourceMappingURL=audit_log_route_schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"audit_log_route_schema.d.ts","sourceRoot":"","sources":["../../src/lib/auth/audit_log_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAmB,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAExF,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG5E;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;EAAkC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,UAAU,CAAC;AAEjD,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,cAAc,EAAE,sBAAsB,CAAC;CACvC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACxC,gBAAe,MAAkC,KAC/C,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,eAAe,EAAE,SAAS,CA+B9E,CAAC"}
1
+ {"version":3,"file":"audit_log_route_schema.d.ts","sourceRoot":"","sources":["../../src/lib/auth/audit_log_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAmB,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAExF,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG5E;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;EAAkC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,UAAU,CAAC;AAEjD,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,cAAc,EAAE,sBAAsB,CAAC;CACvC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACxC,gBAAe,MAAkC,KAC/C,UAAU,CACZ,EAAE,EACF,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EACnC,eAAe,EACf,SAAS,EACT,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EACnC,SAAS,EACT,OAAO,gBAAgB,CAgCrB,CAAC"}
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import type { Logger } from '@fuzdev/fuz_util/log.ts';
15
15
  import { type RouteSpec } from '../http/route_spec.js';
16
- import { type SseNotification } from '../realtime/sse.js';
16
+ import type { SseNotification } from '../realtime/sse.js';
17
17
  import type { SseRegistry } from '../realtime/sse_registry.js';
18
18
  /** Options for audit log route specs. */
19
19
  export interface AuditLogRouteOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"audit_log_routes.d.ts","sourceRoot":"","sources":["../../src/lib/auth/audit_log_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAW7E,OAAO,EAAuB,KAAK,eAAe,E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A8CG;AACH,eAAO,MAAM,4BAA4B,GAAI,UAAU,oBAAoB,KAAG,KAAK,CAAC,SAAS,CA6H5F,CAAC"}
@@ -13,14 +13,11 @@
13
13
  */
14
14
  import { UnreachableError } from '@fuzdev/fuz_util/error.ts';
15
15
  import { attach_route_handler } from '../http/route_spec.js';
16
- import { route_fail, route_raw } from '../http/route_result.js';
16
+ import { route_fail, route_sse } from '../http/route_result.js';
17
17
  import { REST_AUTHENTICATION_REQUIRED, REST_INSUFFICIENT_PERMISSIONS } from '../http/error_schemas.js';
18
- import { has_test_context_preset } from '../hono_context.js';
19
18
  import { create_audit_log_route_shape, DEFAULT_AUDIT_STREAM_ROLE } from './audit_log_route_schema.js';
20
- import { create_sse_response } from '../realtime/sse.js';
21
19
  import { validate_sse_keep_alive_ms } from '../realtime/sse_constants.js';
22
- import { require_request_context } from './request_context.js';
23
- import { get_resolved_auth, recheck_admission, resolved_auth_api_token_id, resolved_auth_session_hash } from './resolved_auth.js';
20
+ import { recheck_admission, resolved_auth_api_token_id, resolved_auth_session_hash } from './resolved_auth.js';
24
21
  import { schedule_credential_deadline } from './credential_deadline.js';
25
22
  import { AUDIT_LOG_CHANNEL } from '../realtime/audit_log_sse.js';
26
23
  /**
@@ -77,11 +74,11 @@ export const create_audit_log_route_specs = (options) => {
77
74
  validate_sse_keep_alive_ms(keep_alive_ms);
78
75
  const required_role = options.required_role ?? DEFAULT_AUDIT_STREAM_ROLE;
79
76
  return [
80
- attach_route_handler(create_audit_log_route_shape(required_role), async (c, route) => {
77
+ attach_route_handler(create_audit_log_route_shape(required_role), async (route) => {
81
78
  // Rule 3 is declared on the route shape's `auth.required_scope`,
82
79
  // so a narrowed token is refused ahead of the role gate rather
83
80
  // than here.
84
- const ctx = require_request_context(c);
81
+ const ctx = route.auth;
85
82
  // scope = session hash (capped → tabs-per-session limit and
86
83
  // session-specific `session_revoke` close). groups = [account_id]
87
84
  // (uncapped → coarse close on role_grant_revoke / session_revoke_all
@@ -91,7 +88,7 @@ export const create_audit_log_route_specs = (options) => {
91
88
  // still has a revoked token's stream closed by `token_revoke`.
92
89
  // Both come off the resolved credential, which carries each only
93
90
  // for its own credential type.
94
- const resolved = get_resolved_auth(c);
91
+ const resolved = route.credential;
95
92
  const session_hash = resolved_auth_session_hash(resolved);
96
93
  const api_token_id = resolved_auth_api_token_id(resolved);
97
94
  // Register pending first: from here every revocation finds the
@@ -113,7 +110,7 @@ export const create_audit_log_route_specs = (options) => {
113
110
  // pre-baked context has no rows behind it to re-read, and for a
114
111
  // registration born closed by the shutdown, which admission
115
112
  // refuses whatever they answer.
116
- if (!has_test_context_preset(c) && !registry.closing) {
113
+ if (!route.has_test_context_preset && !registry.closing) {
117
114
  const reread = async () => {
118
115
  // Global grants only, like the `require_role` gate that ran in
119
116
  // the pipeline — a scoped grant must not open the instance-wide
@@ -166,9 +163,10 @@ export const create_audit_log_route_specs = (options) => {
166
163
  // left during the re-reads gets a stream that is already closed,
167
164
  // whose listener runs at once and removes the registration, so
168
165
  // `admit` refuses it rather than evicting a live stream for it.
169
- const { response, stream } = create_sse_response(c, log, {
166
+ const stream = route.open_sse({
170
167
  account_id: ctx.account.id,
171
- keep_alive_ms
168
+ keep_alive_ms,
169
+ log
172
170
  });
173
171
  stream.on_close(pending.unsubscribe);
174
172
  admitted = registry.admit(pending, stream);
@@ -185,7 +183,7 @@ export const create_audit_log_route_specs = (options) => {
185
183
  stream.close();
186
184
  }));
187
185
  }
188
- return route_raw(response);
186
+ return route_sse(stream);
189
187
  }
190
188
  finally {
191
189
  if (!admitted)
@@ -353,8 +353,8 @@ export const audit_metadata_schemas = Object.freeze({
353
353
  // distinguishes the trigger; `cause_id` points to the accepted offer
354
354
  // (for `sibling_accepted`), the revoked role_grant (for `role_grant_revoked`
355
355
  // — the recipient's grant of the offered role, or a grant of the grantor's),
356
- // the destroyed parent scope row (for `scope_destroyed`), or the grantor's
357
- // removed account (for `account_deleted`).
356
+ // the destroyed parent scope row (for `scope_destroyed`), or the removed
357
+ // account of the grantor or the recipient (for `account_deleted`).
358
358
  role_grant_offer_supersede: loose_object({
359
359
  offer_id: meta(Uuid, { description: 'Id of the superseded offer.' }),
360
360
  role: meta(string, { description: 'Role that was offered.' }),
@@ -362,10 +362,10 @@ export const audit_metadata_schemas = Object.freeze({
362
362
  description: 'Scope of the offered role; null for global offers.'
363
363
  }),
364
364
  reason: meta(one_of(['sibling_accepted', 'role_grant_revoked', 'scope_destroyed', 'account_deleted']), {
365
- description: "Trigger that obsoleted the offer: a sibling offer was accepted, the resulting role_grant or one of the grantor's was revoked, the parent scope row was destroyed, or the grantor's account was deleted or purged."
365
+ description: "Trigger that obsoleted the offer: a sibling offer was accepted, the resulting role_grant or one of the grantor's was revoked, the parent scope row was destroyed, or the grantor's account was deleted or purged, or the recipient's deleted."
366
366
  }),
367
367
  cause_id: meta(Uuid, {
368
- description: "Row that caused the supersede: accepted offer (`sibling_accepted`), revoked role_grant (`role_grant_revoked`), destroyed parent scope row (`scope_destroyed`), or the grantor's account (`account_deleted`)."
368
+ description: "Row that caused the supersede: accepted offer (`sibling_accepted`), revoked role_grant (`role_grant_revoked`), destroyed parent scope row (`scope_destroyed`), or the removed account, the grantor's or the recipient's (`account_deleted`)."
369
369
  })
370
370
  }),
371
371
  invite_create: loose_object({
@@ -31,9 +31,10 @@ import type { QueryDeps } from '../db/query_deps.js';
31
31
  * Discards bearer tokens when an `Origin` or `Referer` header is present —
32
32
  * `next()` with no identity, as for a bad token — so browsers must use cookie
33
33
  * auth, reducing attack surface.
34
- * A token that fails the `is_api_token_shaped` precheck soft-fails before
35
- * the database is touched.
36
- * Auth scheme matching is case-insensitive per RFC 7235.
34
+ * The token is read by `read_bearer_token`: one `Authorization` line, the
35
+ * scheme in any case (RFC 7235), one space, an `is_api_token_shaped` value. A
36
+ * header that reads no token — sent twice included — soft-fails before the
37
+ * database is touched.
37
38
  * On success, sets the `api_token` arm of `ResolvedAuth` (`RESOLVED_AUTH_KEY`):
38
39
  * the account, the token id, its scope, and its deadline. The last leg of the
39
40
  * chain, it skips when an earlier one (the daemon token or a session cookie)
@@ -1 +1 @@
1
- {"version":3,"file":"bearer_auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bearer_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAOtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,6BAA6B,GAAI,MAAM,SAAS,EAAE,KAAK,MAAM,KAAG,iBAkF5E,CAAC"}
1
+ {"version":3,"file":"bearer_auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bearer_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAQtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,6BAA6B,GAAI,MAAM,SAAS,EAAE,KAAK,MAAM,KAAG,iBA0E5E,CAAC"}