@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
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The grammar of the three credential headers — the session cookie in
3
+ * `Cookie`, the API token in `Authorization: Bearer`, the daemon token in
4
+ * `X-Daemon-Token` — as pure readers over header lines.
5
+ *
6
+ * One spelling per credential, the Rust spine's `fuz_auth::credential_headers`
7
+ * reading the same one: a value either reads exactly, or it is not that
8
+ * credential. Nothing is decoded, unquoted, or repaired — a lenient side
9
+ * would authenticate a request the other refuses. The shared table
10
+ * `testing/cross_backend/credential_conformance.json` holds both to the same
11
+ * rows.
12
+ *
13
+ * Each reader takes the header's lines — one field value per header line, in
14
+ * the order sent, outer SP and HTAB already stripped (`get_header_lines` of
15
+ * `http/header_lines.ts` on a request) — so "sent twice" is something a reader
16
+ * can see and decide on.
17
+ *
18
+ * Hono-free: the middleware legs call these, and so does the
19
+ * `_testing_credential_read` action.
20
+ *
21
+ * @module
22
+ */
23
+ import { trim_optional_whitespace } from '../http/header_lines.js';
24
+ import { is_api_token_shaped } from './api_token.js';
25
+ import { is_daemon_token_shaped } from './daemon_token.js';
26
+ /** The `Authorization` scheme of an API token, with the one SP that follows it. */
27
+ const BEARER_PREFIX = 'bearer ';
28
+ /**
29
+ * Read the session cookie's value out of the request's `Cookie` lines.
30
+ *
31
+ * Several `Cookie` lines read as one value joined with `; ` — what Node and
32
+ * Bun hand a handler, and RFC 9113's rule for HTTP/2 cookie crumbs. The value
33
+ * is split on `;`, each pair is stripped of SP and HTAB at both ends (no other
34
+ * byte — not the U+00A0 a `0xA0` arrives as), and the first pair that begins
35
+ * with exactly `<cookie_name>=` wins. Its value is the rest of the pair,
36
+ * verbatim: not percent-decoded, not unquoted, whitespace after the `=` kept.
37
+ * A first pair that will not verify is not skipped for a later one.
38
+ *
39
+ * A pair with an empty value (`name=`) is present, and reads `''` — an
40
+ * invalid cookie to whatever verifies it, not an absent one.
41
+ *
42
+ * @param cookie_lines - the `Cookie` header's lines
43
+ * @param cookie_name - the session cookie's name
44
+ * @returns the cookie's value as sent, or `null` when no pair names it
45
+ */
46
+ export const read_session_cookie_value = (cookie_lines, cookie_name) => {
47
+ const prefix = `${cookie_name}=`;
48
+ // walking the lines in order is reading their `; ` join: the separator
49
+ // holds the `;` the split is on
50
+ for (const line of cookie_lines) {
51
+ for (const part of line.split(';')) {
52
+ const pair = trim_optional_whitespace(part);
53
+ if (pair.startsWith(prefix))
54
+ return pair.slice(prefix.length);
55
+ }
56
+ }
57
+ return null;
58
+ };
59
+ /**
60
+ * Read the API token out of the request's `Authorization` lines.
61
+ *
62
+ * The header must be exactly one line: the scheme `Bearer` in any ASCII case,
63
+ * one SP, and a value `is_api_token_shaped` accepts — nothing before, between,
64
+ * or after. A header sent twice is discarded whatever its lines hold, never
65
+ * resolved to one of them.
66
+ *
67
+ * A runtime that shows no per-line view (`get_header_lines`) hands repeated
68
+ * lines over as one, joined with `, `. No token holds a comma, so the join
69
+ * fails the shape and is discarded as the repeat it is; a lone line that
70
+ * happens to hold `, ` reads the same on both spines.
71
+ *
72
+ * @param authorization_lines - the `Authorization` header's lines
73
+ * @returns the token to look up, or `null` when the header carries none
74
+ */
75
+ export const read_bearer_token = (authorization_lines) => {
76
+ if (authorization_lines.length !== 1)
77
+ return null;
78
+ const value = authorization_lines[0];
79
+ if (value.slice(0, BEARER_PREFIX.length).toLowerCase() !== BEARER_PREFIX)
80
+ return null;
81
+ const token = value.slice(BEARER_PREFIX.length);
82
+ return is_api_token_shaped(token) ? token : null;
83
+ };
84
+ /**
85
+ * Read the daemon token out of the request's `X-Daemon-Token` lines.
86
+ *
87
+ * The header must be exactly one line holding a value
88
+ * `is_daemon_token_shaped` accepts. A header sent twice is discarded — an
89
+ * empty second line included — and, as for `read_bearer_token`, a join with
90
+ * `, ` fails the shape.
91
+ *
92
+ * @param daemon_token_lines - the `X-Daemon-Token` header's lines
93
+ * @returns the token to compare, or `null` when the header carries none
94
+ */
95
+ export const read_daemon_token = (daemon_token_lines) => {
96
+ if (daemon_token_lines.length !== 1)
97
+ return null;
98
+ const value = daemon_token_lines[0];
99
+ return is_daemon_token_shaped(value) ? value : null;
100
+ };
@@ -8,7 +8,19 @@
8
8
  * @module
9
9
  */
10
10
  import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
11
- /** Daemon token format, a `@fuzdev/fuz_schema` schema: 43 base64url characters (256 bits). */
11
+ /** Regex for a daemon token: exactly 43 base64url characters (256 bits). */
12
+ export declare const DAEMON_TOKEN_REGEX: RegExp;
13
+ /**
14
+ * Whether `raw` has the shape of a daemon token — the daemon leg's precheck,
15
+ * ahead of the constant-time compare, so an off-form value is discarded
16
+ * without one. A `true` says nothing about whether the token is the current
17
+ * one. Twin of the Rust spine's `is_daemon_token_shaped`.
18
+ *
19
+ * @param raw - the value of an `X-Daemon-Token` line
20
+ * @returns `true` when `raw` matches `DAEMON_TOKEN_REGEX`
21
+ */
22
+ export declare const is_daemon_token_shaped: (raw: string) => boolean;
23
+ /** Daemon token format, a `@fuzdev/fuz_schema` schema over `DAEMON_TOKEN_REGEX`. */
12
24
  export declare const DaemonToken: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
13
25
  export type DaemonToken = Infer<typeof DaemonToken>;
14
26
  /** The `X-Daemon-Token` header name. */
@@ -1 +1 @@
1
- {"version":3,"file":"daemon_token.d.ts","sourceRoot":"","sources":["../../src/lib/auth/daemon_token.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAgC,KAAK,KAAK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AG,IAAI,CAAC;IAC9B,uCAAuC;IACvC,UAAU,EAAE,IAAI,CAAC;IACjB,iFAAiF;IACjF,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAExC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,EAAE,OAAO,gBAAgB,KAAG,OAgBjF,CAAC"}
@@ -10,8 +10,20 @@
10
10
  import { timingSafeEqual } from 'node:crypto';
11
11
  import { message, pipe, regex, string } from '@fuzdev/fuz_schema/schema.ts';
12
12
  import { generate_random_base64url } from '../crypto.js';
13
- /** Daemon token format, a `@fuzdev/fuz_schema` schema: 43 base64url characters (256 bits). */
14
- export const DaemonToken = pipe(string, message(regex(/^[A-Za-z0-9_-]{43}$/), 'Invalid daemon token format'));
13
+ /** Regex for a daemon token: exactly 43 base64url characters (256 bits). */
14
+ export const DAEMON_TOKEN_REGEX = /^[A-Za-z0-9_-]{43}$/;
15
+ /**
16
+ * Whether `raw` has the shape of a daemon token — the daemon leg's precheck,
17
+ * ahead of the constant-time compare, so an off-form value is discarded
18
+ * without one. A `true` says nothing about whether the token is the current
19
+ * one. Twin of the Rust spine's `is_daemon_token_shaped`.
20
+ *
21
+ * @param raw - the value of an `X-Daemon-Token` line
22
+ * @returns `true` when `raw` matches `DAEMON_TOKEN_REGEX`
23
+ */
24
+ export const is_daemon_token_shaped = (raw) => DAEMON_TOKEN_REGEX.test(raw);
25
+ /** Daemon token format, a `@fuzdev/fuz_schema` schema over `DAEMON_TOKEN_REGEX`. */
26
+ export const DaemonToken = pipe(string, message(regex(DAEMON_TOKEN_REGEX), 'Invalid daemon token format'));
15
27
  /** The `X-Daemon-Token` header name. */
16
28
  export const DAEMON_TOKEN_HEADER = 'X-Daemon-Token';
17
29
  /**
@@ -41,19 +41,18 @@ export declare const resolve_keeper_account_id: (deps: QueryDeps) => Promise<str
41
41
  * `RESOLVED_AUTH_KEY` on entry, so a layer mounted before the credential legs
42
42
  * cannot pre-set an identity that every leg would then skip past.
43
43
  *
44
- * Checks the `X-Daemon-Token` header. Behavior:
45
- * - No header: pass through.
46
- * - Header present + `Origin` / `Referer` present: discard the credential
44
+ * Reads the `X-Daemon-Token` header's lines through `read_daemon_token`.
45
+ * Behavior:
46
+ * - No header, a malformed value (fails `is_daemon_token_shaped`), or the
47
+ * header sent as more than one line: soft-fail discard (pass through, not
48
+ * 401) — mirrors the bearer guard and the Rust spine's `resolve.rs`
49
+ * (`None`). Downstream a daemon-gated action returns
50
+ * `credential_type_required`; a public action proceeds anonymous.
51
+ * - A shaped token + `Origin` / `Referer` present: discard the credential
47
52
  * (browser context) and pass through — daemon tokens are loopback-only and
48
53
  * never carry an `Origin` in production, so a header-bearing request is not
49
- * a legitimate daemon caller. Mirrors the bearer guard: `next()` rather than
50
- * 401, so downstream auth enforcement returns `credential_type_required`
51
- * (not a hard fail). Silent on the wire (anti-enumeration); in `DEV` only,
52
- * sets `X-Fuz-Auth-Debug: daemon_token_discarded_browser_context`.
53
- * - Header present + malformed (fails `DaemonToken`): soft-fail discard (pass through,
54
- * not 401) — mirrors the bearer guard and the Rust spine's `resolve.rs`
55
- * (`None`). Downstream a daemon-gated action returns `credential_type_required`;
56
- * a public action proceeds anonymous.
54
+ * a legitimate daemon caller. Silent on the wire (anti-enumeration); in
55
+ * `DEV` only, sets `X-Fuz-Auth-Debug: daemon_token_discarded_browser_context`.
57
56
  * - Header present + invalid value (not the current/previous token): soft-fail
58
57
  * discard (pass through, not 401) — same downstream behavior.
59
58
  * - Header present + valid + `keeper_account_id` null (still pre-bootstrap
@@ -1 +1 @@
1
- {"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"","sources":["../../src/lib/auth/daemon_token_middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;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;AAErD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,MAAM,SAAS,EACf,KAAK,MAAM,KACT,iBAiFF,CAAC"}
1
+ {"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"","sources":["../../src/lib/auth/daemon_token_middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;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;AAGrD,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,MAAM,SAAS,EACf,KAAK,MAAM,KACT,iBAsFF,CAAC"}
@@ -14,13 +14,15 @@
14
14
  * @module
15
15
  */
16
16
  import { DEV } from 'esm-env';
17
- import { is } from '@fuzdev/fuz_schema/schema.ts';
18
17
  import { RESOLVED_AUTH_KEY } from '../hono_context.js';
19
18
  import { get_resolved_auth } from './resolved_auth.js';
20
- import { is_browser_context } from '../http/origin.js';
19
+ import { get_header_lines } from '../http/header_lines.js';
20
+ import { is_browser_context } from '../http/request_headers.js';
21
21
  import { query_role_grant_find_account_id_for_role } from './role_grant_queries.js';
22
+ import { query_account_by_id } from './account_queries.js';
22
23
  import { ROLE_KEEPER } from './role_schema.js';
23
- import { DaemonToken, DAEMON_TOKEN_HEADER, validate_daemon_token } from './daemon_token.js';
24
+ import { read_daemon_token } from './credential_headers.js';
25
+ import { DAEMON_TOKEN_HEADER, validate_daemon_token } from './daemon_token.js';
24
26
  /**
25
27
  * Resolve the keeper account ID by querying for the account with an active
26
28
  * keeper role_grant.
@@ -47,19 +49,18 @@ export const resolve_keeper_account_id = async (deps) => {
47
49
  * `RESOLVED_AUTH_KEY` on entry, so a layer mounted before the credential legs
48
50
  * cannot pre-set an identity that every leg would then skip past.
49
51
  *
50
- * Checks the `X-Daemon-Token` header. Behavior:
51
- * - No header: pass through.
52
- * - Header present + `Origin` / `Referer` present: discard the credential
52
+ * Reads the `X-Daemon-Token` header's lines through `read_daemon_token`.
53
+ * Behavior:
54
+ * - No header, a malformed value (fails `is_daemon_token_shaped`), or the
55
+ * header sent as more than one line: soft-fail discard (pass through, not
56
+ * 401) — mirrors the bearer guard and the Rust spine's `resolve.rs`
57
+ * (`None`). Downstream a daemon-gated action returns
58
+ * `credential_type_required`; a public action proceeds anonymous.
59
+ * - A shaped token + `Origin` / `Referer` present: discard the credential
53
60
  * (browser context) and pass through — daemon tokens are loopback-only and
54
61
  * never carry an `Origin` in production, so a header-bearing request is not
55
- * a legitimate daemon caller. Mirrors the bearer guard: `next()` rather than
56
- * 401, so downstream auth enforcement returns `credential_type_required`
57
- * (not a hard fail). Silent on the wire (anti-enumeration); in `DEV` only,
58
- * sets `X-Fuz-Auth-Debug: daemon_token_discarded_browser_context`.
59
- * - Header present + malformed (fails `DaemonToken`): soft-fail discard (pass through,
60
- * not 401) — mirrors the bearer guard and the Rust spine's `resolve.rs`
61
- * (`None`). Downstream a daemon-gated action returns `credential_type_required`;
62
- * a public action proceeds anonymous.
62
+ * a legitimate daemon caller. Silent on the wire (anti-enumeration); in
63
+ * `DEV` only, sets `X-Fuz-Auth-Debug: daemon_token_discarded_browser_context`.
63
64
  * - Header present + invalid value (not the current/previous token): soft-fail
64
65
  * discard (pass through, not 401) — same downstream behavior.
65
66
  * - Header present + valid + `keeper_account_id` null (still pre-bootstrap
@@ -90,36 +91,34 @@ export const create_daemon_token_middleware = (state, deps, log) => {
90
91
  log.debug(`daemon token leg cleared a credential (${cleared.credential_type}) set before it`);
91
92
  }
92
93
  c.set(RESOLVED_AUTH_KEY, null);
93
- const token_header = c.req.header(DAEMON_TOKEN_HEADER);
94
- if (!token_header) {
94
+ // The header's one shaped value, or nothing: absent, malformed, and sent
95
+ // as more than one line all read `null` and pass through — a soft-fail
96
+ // discard, not a 401, mirroring the bearer guard and the Rust spine's
97
+ // `resolve.rs`. On a daemon-gated action the dispatcher returns
98
+ // `credential_type_required` downstream; a public action proceeds
99
+ // anonymous.
100
+ const token_lines = get_header_lines(c, DAEMON_TOKEN_HEADER);
101
+ const token_header = read_daemon_token(token_lines);
102
+ if (token_header === null) {
103
+ if (token_lines.length > 0)
104
+ log.debug('daemon token auth soft-fail: malformed token');
95
105
  await next();
96
106
  return;
97
107
  }
98
108
  // Silently discard daemon tokens in browser context (`is_browser_context`
99
- // — Origin or Referer present) — mirrors the bearer guard (and the Rust
109
+ // — an Origin or Referer line present) — mirrors the bearer guard (and the Rust
100
110
  // spine's `resolve.rs`, which returns `None`). Daemon tokens are
101
111
  // loopback-only and never carry an `Origin` in production, so a
102
112
  // header-bearing request is not a legitimate daemon caller. Discards
103
113
  // (next()) rather than 401 so the dispatcher returns
104
114
  // `credential_type_required` downstream rather than a hard fail.
105
- if (is_browser_context(c)) {
115
+ if (is_browser_context(get_header_lines(c, 'origin'), get_header_lines(c, 'referer'))) {
106
116
  log.debug('daemon token auth rejected: browser context (Origin/Referer present)');
107
117
  if (DEV)
108
118
  c.header('X-Fuz-Auth-Debug', 'daemon_token_discarded_browser_context');
109
119
  await next();
110
120
  return;
111
121
  }
112
- // Validate the token format at the I/O boundary. A malformed token is
113
- // a soft-fail discard (pass through), not a 401 — mirroring the bearer
114
- // guard and the Rust spine's `resolve.rs`, which return `None` on an
115
- // unparseable credential. The request falls through: on a daemon-gated
116
- // action the dispatcher returns `credential_type_required` downstream; on
117
- // a public action it proceeds anonymous.
118
- if (!is(DaemonToken, token_header)) {
119
- log.debug('daemon token auth soft-fail: malformed token');
120
- await next();
121
- return;
122
- }
123
122
  // Well-formed but not the current/previous token — soft-fail discard, not
124
123
  // a 401, for the same reason: no downgrade, falls through to downstream
125
124
  // `credential_type_required` (matching the Rust spine's `None`).
@@ -147,12 +146,22 @@ export const create_daemon_token_middleware = (state, deps, log) => {
147
146
  await next();
148
147
  return;
149
148
  }
149
+ // The keeper's row, read per request as every credential leg reads its
150
+ // account, so the authorization phase builds on it. A keeper account
151
+ // gone or tombstoned (no API path removes it) authenticates nothing —
152
+ // as the Rust spine's daemon leg.
153
+ const account = await query_account_by_id(deps, state.keeper_account_id);
154
+ if (!account) {
155
+ log.warn('daemon token auth soft-fail: keeper account not found');
156
+ await next();
157
+ return;
158
+ }
150
159
  // Full authority (`resolved_auth_scope`): singular, filesystem-proved,
151
160
  // keeper-bound — no minting step at which a narrowing could have been
152
161
  // chosen. No row, no expiry.
153
162
  c.set(RESOLVED_AUTH_KEY, {
154
163
  credential_type: 'daemon_token',
155
- account_id: state.keeper_account_id,
164
+ account,
156
165
  credential_deadline: null
157
166
  });
158
167
  await next();
@@ -14,6 +14,7 @@ import type { PasswordHashDeps } from './password.js';
14
14
  import type { Db } from '../db/db.js';
15
15
  import type { AuditEmitter } from './audit_emitter.js';
16
16
  import type { ConnectionCloser, RealtimeCloser } from '../actions/connection_closer.js';
17
+ import type { RealtimeNotificationSender } from '../actions/notification_sender.js';
17
18
  /**
18
19
  * Stateless capabilities bundle for fuz_app backends.
19
20
  *
@@ -21,17 +22,6 @@ import type { ConnectionCloser, RealtimeCloser } from '../actions/connection_clo
21
22
  * Does not contain config (static values) or runtime state (mutable refs).
22
23
  */
23
24
  export interface AppDeps {
24
- /**
25
- * Hardened secret-file read — used for the bootstrap token (the file that
26
- * mints the keeper account). Production wiring passes the runtime's
27
- * `read_secure_file` (`FsSecureReadDeps`), which rejects symlinks,
28
- * non-regular files, group/other-accessible modes, and oversized files; both the boot-time
29
- * availability probe and the request-time read go through this one
30
- * capability so the probe can never be laxer than the read it gates.
31
- */
32
- read_secure_file: (path: string) => Promise<Uint8Array>;
33
- /** Delete a file. */
34
- delete_file: (path: string) => Promise<void>;
35
25
  /** HMAC-SHA256 cookie signing keyring. */
36
26
  keyring: Keyring;
37
27
  /** Password hashing operations. Use `argon2_password_deps` in production. */
@@ -59,6 +49,15 @@ export interface AppDeps {
59
49
  * option of `register_action_ws` / `create_audit_log_sse`.
60
50
  */
61
51
  connection_closer: RealtimeCloser;
52
+ /**
53
+ * Sends server-initiated notifications to an account's live WebSocket
54
+ * connections. The action dispatchers put it on every handler context
55
+ * (`ActionContext.notification_sender`), so it must reach every
56
+ * WebSocket registry of the backend: `create_app_backend` creates it
57
+ * empty, and `create_app_server` adds each registry it mounts. With no
58
+ * WebSocket endpoint mounted it reaches no one.
59
+ */
60
+ notification_sender: RealtimeNotificationSender;
62
61
  /**
63
62
  * Optional content-addressed byte store. Present only on backends that
64
63
  * serve binary content (facts) — minimal consumers leave it unset. The
@@ -1 +1 @@
1
- {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../src/lib/auth/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,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ACH,iBAAiB,EAAE,gBAAgB,CAAC;CACpC"}
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @module
8
8
  */
9
+ import type { Uuid } from '../primitive_schemas.js';
9
10
  import type { QueryDeps } from '../db/query_deps.js';
10
11
  import type { Invite, CreateInviteInput, InviteWithUsernamesJson } from './invite_schema.js';
11
12
  /**
@@ -87,4 +88,21 @@ export declare const query_invite_list_all_with_usernames: (deps: QueryDeps) =>
87
88
  * @mutates `invite` table - deletes the row when still unclaimed
88
89
  */
89
90
  export declare const query_invite_delete_unclaimed: (deps: QueryDeps, id: string) => Promise<boolean>;
91
+ /**
92
+ * Delete every unclaimed invite issued by one of `created_by_actor_ids` — the
93
+ * invite cascade of an account delete or purge.
94
+ *
95
+ * An invite records no authority, so one outliving its issuer's account would
96
+ * still admit a signup. Deleting is how an invite is revoked
97
+ * (`query_invite_delete_unclaimed`), so a voided invite answers a signup as a
98
+ * revoked or unknown one does, and an undelete has nothing to bring back. A
99
+ * claimed invite stays, as the record of the signup it admitted. Twin of the
100
+ * Rust `query_invite_delete_unclaimed_by_creators`.
101
+ *
102
+ * @param deps - query dependencies
103
+ * @param created_by_actor_ids - the issuing actors whose unclaimed invites end
104
+ * @returns the ids of the deleted invites
105
+ * @mutates `invite` table - deletes every unclaimed row created by `created_by_actor_ids`
106
+ */
107
+ export declare const query_invite_delete_unclaimed_by_creators: (deps: QueryDeps, created_by_actor_ids: ReadonlyArray<Uuid>) => Promise<Array<Uuid>>;
90
108
  //# sourceMappingURL=invite_queries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"invite_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/invite_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7F;;;;;;;;GAQG;A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GAqBG;AACH,eAAO,MAAM,4CAA4C,GACxD,MAAM,SAAS,EACf,OAAO,MAAM,GAAG,IAAI,EACpB,UAAU,MAAM,KACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAgB5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,2BAA2B,GACvC,MAAM,SAAS,EACf,WAAW,MAAM,EACjB,YAAY,MAAM,KAChB,OAAO,CAAC,OAAO,CAQjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,GAChD,MAAM,SAAS,KACb,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAUxC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,GACzC,MAAM,SAAS,EACf,IAAI,MAAM,KACR,OAAO,CAAC,OAAO,CAMjB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,yCAAyC,GACrD,MAAM,SAAS,EACf,sBAAsB,aAAa,CAAC,IAAI,CAAC,KACvC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CASrB,CAAC"}
@@ -131,3 +131,27 @@ export const query_invite_delete_unclaimed = async (deps, id) => {
131
131
  const rows = await deps.db.query(`DELETE FROM invite WHERE id = $1 AND claimed_at IS NULL RETURNING id`, [id]);
132
132
  return rows.length > 0;
133
133
  };
134
+ /**
135
+ * Delete every unclaimed invite issued by one of `created_by_actor_ids` — the
136
+ * invite cascade of an account delete or purge.
137
+ *
138
+ * An invite records no authority, so one outliving its issuer's account would
139
+ * still admit a signup. Deleting is how an invite is revoked
140
+ * (`query_invite_delete_unclaimed`), so a voided invite answers a signup as a
141
+ * revoked or unknown one does, and an undelete has nothing to bring back. A
142
+ * claimed invite stays, as the record of the signup it admitted. Twin of the
143
+ * Rust `query_invite_delete_unclaimed_by_creators`.
144
+ *
145
+ * @param deps - query dependencies
146
+ * @param created_by_actor_ids - the issuing actors whose unclaimed invites end
147
+ * @returns the ids of the deleted invites
148
+ * @mutates `invite` table - deletes every unclaimed row created by `created_by_actor_ids`
149
+ */
150
+ export const query_invite_delete_unclaimed_by_creators = async (deps, created_by_actor_ids) => {
151
+ if (created_by_actor_ids.length === 0)
152
+ return [];
153
+ const rows = await deps.db.query(`DELETE FROM invite
154
+ WHERE created_by = ANY($1) AND claimed_at IS NULL
155
+ RETURNING id`, [created_by_actor_ids]);
156
+ return rows.map((row) => row.id);
157
+ };