@fuzdev/fuz_app 0.150.0 → 0.151.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 (597) hide show
  1. package/README.md +1 -1
  2. package/dist/actions/CLAUDE.md +324 -299
  3. package/dist/actions/action_bridge.d.ts +5 -86
  4. package/dist/actions/action_bridge.d.ts.map +1 -1
  5. package/dist/actions/action_bridge.js +4 -84
  6. package/dist/actions/action_codegen.d.ts +8 -166
  7. package/dist/actions/action_codegen.d.ts.map +1 -1
  8. package/dist/actions/action_codegen.js +19 -95
  9. package/dist/actions/action_dispatcher.d.ts +10 -0
  10. package/dist/actions/action_dispatcher.d.ts.map +1 -1
  11. package/dist/actions/action_dispatcher.js +9 -6
  12. package/dist/actions/action_event.d.ts +1 -2
  13. package/dist/actions/action_event.d.ts.map +1 -1
  14. package/dist/actions/action_event.js +7 -13
  15. package/dist/actions/action_event_helpers.d.ts +1 -40
  16. package/dist/actions/action_event_helpers.d.ts.map +1 -1
  17. package/dist/actions/action_event_helpers.js +1 -25
  18. package/dist/actions/action_rpc.d.ts +10 -215
  19. package/dist/actions/action_rpc.d.ts.map +1 -1
  20. package/dist/actions/action_rpc.js +56 -111
  21. package/dist/actions/action_spec.d.ts +2 -2
  22. package/dist/actions/action_spec.js +2 -2
  23. package/dist/actions/action_types.d.ts +229 -8
  24. package/dist/actions/action_types.d.ts.map +1 -1
  25. package/dist/actions/action_types.js +56 -5
  26. package/dist/actions/broadcast_api.d.ts +22 -17
  27. package/dist/actions/broadcast_api.d.ts.map +1 -1
  28. package/dist/actions/broadcast_api.js +16 -27
  29. package/dist/actions/cancel.d.ts +4 -13
  30. package/dist/actions/cancel.d.ts.map +1 -1
  31. package/dist/actions/cancel.js +5 -17
  32. package/dist/actions/compile_action_registry.d.ts +1 -2
  33. package/dist/actions/compile_action_registry.d.ts.map +1 -1
  34. package/dist/actions/connection_closer.d.ts +120 -50
  35. package/dist/actions/connection_closer.d.ts.map +1 -1
  36. package/dist/actions/connection_closer.js +139 -31
  37. package/dist/actions/{transports_ws_backend.d.ts → connection_registry.d.ts} +120 -132
  38. package/dist/actions/connection_registry.d.ts.map +1 -0
  39. package/dist/actions/{transports_ws_backend.js → connection_registry.js} +149 -152
  40. package/dist/actions/frontend_rpc_client.d.ts +52 -2
  41. package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
  42. package/dist/actions/frontend_rpc_client.js +42 -4
  43. package/dist/actions/peer_ping.d.ts +7 -9
  44. package/dist/actions/peer_ping.d.ts.map +1 -1
  45. package/dist/actions/peer_ping.js +6 -8
  46. package/dist/actions/peer_request.d.ts +6 -5
  47. package/dist/actions/peer_request.d.ts.map +1 -1
  48. package/dist/actions/peer_request.js +6 -5
  49. package/dist/actions/perform_action.d.ts +36 -28
  50. package/dist/actions/perform_action.d.ts.map +1 -1
  51. package/dist/actions/perform_action.js +60 -34
  52. package/dist/actions/protocol.d.ts +14 -0
  53. package/dist/actions/protocol.d.ts.map +1 -1
  54. package/dist/actions/protocol.js +18 -0
  55. package/dist/actions/register_action_ws.d.ts +137 -298
  56. package/dist/actions/register_action_ws.d.ts.map +1 -1
  57. package/dist/actions/register_action_ws.js +155 -923
  58. package/dist/actions/socket.svelte.d.ts +9 -0
  59. package/dist/actions/socket.svelte.d.ts.map +1 -1
  60. package/dist/actions/socket.svelte.js +16 -5
  61. package/dist/actions/transports.d.ts +88 -34
  62. package/dist/actions/transports.d.ts.map +1 -1
  63. package/dist/actions/transports.js +76 -76
  64. package/dist/actions/transports_http.d.ts +48 -12
  65. package/dist/actions/transports_http.d.ts.map +1 -1
  66. package/dist/actions/transports_http.js +75 -44
  67. package/dist/actions/transports_ws.d.ts +29 -0
  68. package/dist/actions/transports_ws.d.ts.map +1 -1
  69. package/dist/actions/transports_ws.js +34 -8
  70. package/dist/actions/ws_endpoint_spec.d.ts +52 -75
  71. package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
  72. package/dist/actions/ws_endpoint_spec.js +27 -10
  73. package/dist/actions/ws_outbound_writer.d.ts +3 -3
  74. package/dist/actions/ws_outbound_writer.js +3 -3
  75. package/dist/actions/ws_socket_session.d.ts +321 -0
  76. package/dist/actions/ws_socket_session.d.ts.map +1 -0
  77. package/dist/actions/ws_socket_session.js +783 -0
  78. package/dist/auth/CLAUDE.md +70 -44
  79. package/dist/auth/account_action_specs.d.ts +2 -0
  80. package/dist/auth/account_action_specs.d.ts.map +1 -1
  81. package/dist/auth/account_actions.d.ts +1 -1
  82. package/dist/auth/account_actions.d.ts.map +1 -1
  83. package/dist/auth/account_actions.js +9 -3
  84. package/dist/auth/account_queries.d.ts +10 -0
  85. package/dist/auth/account_queries.d.ts.map +1 -1
  86. package/dist/auth/account_queries.js +27 -17
  87. package/dist/auth/account_routes.d.ts +2 -1
  88. package/dist/auth/account_routes.d.ts.map +1 -1
  89. package/dist/auth/account_routes.js +14 -17
  90. package/dist/auth/account_schema.d.ts +5 -5
  91. package/dist/auth/account_schema.d.ts.map +1 -1
  92. package/dist/auth/account_schema.js +5 -2
  93. package/dist/auth/actor_lookup_actions.d.ts +1 -1
  94. package/dist/auth/actor_lookup_actions.d.ts.map +1 -1
  95. package/dist/auth/actor_lookup_actions.js +1 -1
  96. package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
  97. package/dist/auth/actor_search_action_specs.js +2 -1
  98. package/dist/auth/actor_search_actions.d.ts +1 -1
  99. package/dist/auth/actor_search_actions.d.ts.map +1 -1
  100. package/dist/auth/actor_search_actions.js +1 -1
  101. package/dist/auth/actor_search_queries.d.ts +5 -5
  102. package/dist/auth/actor_search_queries.d.ts.map +1 -1
  103. package/dist/auth/actor_search_queries.js +7 -7
  104. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  105. package/dist/auth/admin_action_specs.js +3 -1
  106. package/dist/auth/admin_actions.d.ts +1 -1
  107. package/dist/auth/admin_actions.d.ts.map +1 -1
  108. package/dist/auth/admin_actions.js +12 -42
  109. package/dist/auth/all_cell_actions.d.ts +6 -4
  110. package/dist/auth/all_cell_actions.d.ts.map +1 -1
  111. package/dist/auth/all_cell_actions.js +1 -1
  112. package/dist/auth/api_token_queries.d.ts +1 -0
  113. package/dist/auth/api_token_queries.d.ts.map +1 -1
  114. package/dist/auth/api_token_queries.js +1 -0
  115. package/dist/auth/audit_emitter.d.ts +3 -3
  116. package/dist/auth/audit_emitter.js +2 -2
  117. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  118. package/dist/auth/audit_log_route_schema.js +3 -2
  119. package/dist/auth/audit_log_routes.d.ts +20 -11
  120. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  121. package/dist/auth/audit_log_routes.js +49 -29
  122. package/dist/auth/audit_log_schema.d.ts +13 -21
  123. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  124. package/dist/auth/audit_log_schema.js +10 -18
  125. package/dist/auth/bearer_auth.d.ts +7 -4
  126. package/dist/auth/bearer_auth.d.ts.map +1 -1
  127. package/dist/auth/bearer_auth.js +21 -15
  128. package/dist/auth/cell_action_helpers.d.ts +89 -0
  129. package/dist/auth/cell_action_helpers.d.ts.map +1 -0
  130. package/dist/auth/cell_action_helpers.js +113 -0
  131. package/dist/auth/cell_actions.d.ts +22 -13
  132. package/dist/auth/cell_actions.d.ts.map +1 -1
  133. package/dist/auth/cell_actions.js +105 -167
  134. package/dist/auth/cell_audit_actions.d.ts +1 -1
  135. package/dist/auth/cell_audit_actions.d.ts.map +1 -1
  136. package/dist/auth/cell_audit_actions.js +3 -12
  137. package/dist/auth/cell_audit_metadata.d.ts +1 -1
  138. package/dist/auth/cell_audit_metadata.js +1 -1
  139. package/dist/auth/cell_field_actions.d.ts +1 -1
  140. package/dist/auth/cell_field_actions.d.ts.map +1 -1
  141. package/dist/auth/cell_field_actions.js +16 -66
  142. package/dist/auth/cell_grant_action_specs.d.ts +2 -2
  143. package/dist/auth/cell_grant_action_specs.js +3 -3
  144. package/dist/auth/cell_grant_actions.d.ts +73 -11
  145. package/dist/auth/cell_grant_actions.d.ts.map +1 -1
  146. package/dist/auth/cell_grant_actions.js +63 -55
  147. package/dist/auth/cell_grant_audit_metadata.d.ts +6 -3
  148. package/dist/auth/cell_grant_audit_metadata.d.ts.map +1 -1
  149. package/dist/auth/cell_grant_audit_metadata.js +7 -4
  150. package/dist/auth/cell_item_actions.d.ts +1 -1
  151. package/dist/auth/cell_item_actions.d.ts.map +1 -1
  152. package/dist/auth/cell_item_actions.js +21 -82
  153. package/dist/auth/cleanup.d.ts +1 -1
  154. package/dist/auth/cleanup.d.ts.map +1 -1
  155. package/dist/auth/cleanup.js +6 -3
  156. package/dist/auth/credential_deadline.d.ts +3 -3
  157. package/dist/auth/credential_deadline.js +3 -3
  158. package/dist/auth/credential_type_schema.d.ts +5 -5
  159. package/dist/auth/credential_type_schema.js +5 -5
  160. package/dist/auth/daemon_token_middleware.d.ts +12 -6
  161. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  162. package/dist/auth/daemon_token_middleware.js +28 -17
  163. package/dist/auth/deps.d.ts +4 -4
  164. package/dist/auth/fail_floor.d.ts +55 -0
  165. package/dist/auth/fail_floor.d.ts.map +1 -0
  166. package/dist/auth/fail_floor.js +63 -0
  167. package/dist/auth/invite_queries.d.ts +3 -15
  168. package/dist/auth/invite_queries.d.ts.map +1 -1
  169. package/dist/auth/invite_queries.js +3 -21
  170. package/dist/auth/middleware.d.ts +12 -7
  171. package/dist/auth/middleware.d.ts.map +1 -1
  172. package/dist/auth/middleware.js +42 -29
  173. package/dist/auth/migrations.d.ts +5 -33
  174. package/dist/auth/migrations.d.ts.map +1 -1
  175. package/dist/auth/migrations.js +9 -16
  176. package/dist/auth/request_context.d.ts +101 -71
  177. package/dist/auth/request_context.d.ts.map +1 -1
  178. package/dist/auth/request_context.js +137 -140
  179. package/dist/auth/resolved_auth.d.ts +122 -36
  180. package/dist/auth/resolved_auth.d.ts.map +1 -1
  181. package/dist/auth/resolved_auth.js +89 -38
  182. package/dist/auth/role_grant_offer_action_specs.d.ts +99 -14
  183. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  184. package/dist/auth/role_grant_offer_action_specs.js +26 -13
  185. package/dist/auth/role_grant_offer_actions.d.ts +13 -7
  186. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  187. package/dist/auth/role_grant_offer_actions.js +14 -12
  188. package/dist/auth/role_grant_offer_notifications.d.ts +3 -3
  189. package/dist/auth/role_grant_offer_notifications.js +1 -1
  190. package/dist/auth/role_grant_offer_queries.d.ts +0 -5
  191. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  192. package/dist/auth/role_grant_offer_queries.js +9 -41
  193. package/dist/auth/role_grant_queries.d.ts +17 -67
  194. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  195. package/dist/auth/role_grant_queries.js +34 -106
  196. package/dist/auth/role_grant_sql.d.ts +42 -0
  197. package/dist/auth/role_grant_sql.d.ts.map +1 -0
  198. package/dist/auth/role_grant_sql.js +54 -0
  199. package/dist/auth/scope_kind_schema.d.ts +1 -1
  200. package/dist/auth/scope_kind_schema.js +1 -1
  201. package/dist/auth/self_service_role_actions.d.ts +1 -1
  202. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  203. package/dist/auth/self_service_role_actions.js +1 -1
  204. package/dist/auth/session_queries.d.ts +2 -1
  205. package/dist/auth/session_queries.d.ts.map +1 -1
  206. package/dist/auth/session_queries.js +2 -1
  207. package/dist/auth/signup_routes.d.ts +2 -1
  208. package/dist/auth/signup_routes.d.ts.map +1 -1
  209. package/dist/auth/signup_routes.js +14 -13
  210. package/dist/auth/standard_rpc_actions.d.ts +1 -1
  211. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  212. package/dist/auth/token_scope.d.ts +19 -46
  213. package/dist/auth/token_scope.d.ts.map +1 -1
  214. package/dist/auth/token_scope.js +23 -41
  215. package/dist/db/CLAUDE.md +9 -4
  216. package/dist/db/cell_ddl.d.ts +5 -142
  217. package/dist/db/cell_ddl.d.ts.map +1 -1
  218. package/dist/db/cell_ddl.js +17 -16
  219. package/dist/db/cell_field_queries.d.ts +0 -13
  220. package/dist/db/cell_field_queries.d.ts.map +1 -1
  221. package/dist/db/cell_field_queries.js +0 -16
  222. package/dist/db/cell_grant_queries.d.ts +10 -5
  223. package/dist/db/cell_grant_queries.d.ts.map +1 -1
  224. package/dist/db/cell_grant_queries.js +13 -7
  225. package/dist/db/cell_item_queries.d.ts +0 -7
  226. package/dist/db/cell_item_queries.d.ts.map +1 -1
  227. package/dist/db/cell_item_queries.js +0 -10
  228. package/dist/db/cell_queries.d.ts +12 -48
  229. package/dist/db/cell_queries.d.ts.map +1 -1
  230. package/dist/db/cell_queries.js +24 -55
  231. package/dist/db/cell_view_sql.d.ts +1 -6
  232. package/dist/db/cell_view_sql.d.ts.map +1 -1
  233. package/dist/db/cell_view_sql.js +1 -2
  234. package/dist/db/fact_ddl.d.ts +5 -30
  235. package/dist/db/fact_ddl.d.ts.map +1 -1
  236. package/dist/db/fact_ddl.js +14 -13
  237. package/dist/db/fact_store.d.ts +11 -0
  238. package/dist/db/fact_store.d.ts.map +1 -1
  239. package/dist/db/fact_store.js +4 -1
  240. package/dist/db/migrate.d.ts +44 -6
  241. package/dist/db/migrate.d.ts.map +1 -1
  242. package/dist/db/migrate.js +63 -4
  243. package/dist/dev/setup.d.ts +18 -14
  244. package/dist/dev/setup.d.ts.map +1 -1
  245. package/dist/dev/setup.js +42 -39
  246. package/dist/env/dotenv.d.ts +2 -2
  247. package/dist/env/dotenv.js +2 -2
  248. package/dist/env/update_env_variable.d.ts +33 -21
  249. package/dist/env/update_env_variable.d.ts.map +1 -1
  250. package/dist/env/update_env_variable.js +54 -35
  251. package/dist/hono_context.d.ts +15 -90
  252. package/dist/hono_context.d.ts.map +1 -1
  253. package/dist/hono_context.js +9 -56
  254. package/dist/http/CLAUDE.md +35 -20
  255. package/dist/http/auth_shape.d.ts +1 -8
  256. package/dist/http/auth_shape.d.ts.map +1 -1
  257. package/dist/http/auth_shape.js +6 -12
  258. package/dist/http/common_routes.d.ts.map +1 -1
  259. package/dist/http/common_routes.js +3 -2
  260. package/dist/http/db_routes.d.ts +3 -3
  261. package/dist/http/db_routes.js +3 -3
  262. package/dist/http/error_schemas.d.ts +1 -2
  263. package/dist/http/error_schemas.d.ts.map +1 -1
  264. package/dist/http/error_schemas.js +1 -2
  265. package/dist/http/health_schema.d.ts +16 -0
  266. package/dist/http/health_schema.d.ts.map +1 -0
  267. package/dist/http/health_schema.js +12 -0
  268. package/dist/http/jsonrpc_errors.d.ts +22 -2
  269. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  270. package/dist/http/jsonrpc_errors.js +41 -3
  271. package/dist/http/jsonrpc_helpers.d.ts +60 -17
  272. package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
  273. package/dist/http/jsonrpc_helpers.js +67 -25
  274. package/dist/http/origin.d.ts +30 -1
  275. package/dist/http/origin.d.ts.map +1 -1
  276. package/dist/http/origin.js +46 -9
  277. package/dist/http/origin_wildcard.d.ts +97 -0
  278. package/dist/http/origin_wildcard.d.ts.map +1 -0
  279. package/dist/http/origin_wildcard.js +142 -0
  280. package/dist/http/pending_effects.d.ts +28 -0
  281. package/dist/http/pending_effects.d.ts.map +1 -1
  282. package/dist/http/pending_effects.js +32 -1
  283. package/dist/http/route_spec.d.ts +4 -3
  284. package/dist/http/route_spec.d.ts.map +1 -1
  285. package/dist/http/route_spec.js +54 -45
  286. package/dist/http/surface.d.ts +1 -1
  287. package/dist/http/surface.d.ts.map +1 -1
  288. package/dist/http/surface_query.d.ts +9 -50
  289. package/dist/http/surface_query.d.ts.map +1 -1
  290. package/dist/http/surface_query.js +48 -94
  291. package/dist/realtime/audit_log_sse.d.ts +180 -0
  292. package/dist/realtime/audit_log_sse.d.ts.map +1 -0
  293. package/dist/realtime/audit_log_sse.js +154 -0
  294. package/dist/realtime/sse.d.ts +21 -6
  295. package/dist/realtime/sse.d.ts.map +1 -1
  296. package/dist/realtime/sse.js +33 -10
  297. package/dist/realtime/sse_constants.d.ts +29 -2
  298. package/dist/realtime/sse_constants.d.ts.map +1 -1
  299. package/dist/realtime/sse_constants.js +35 -2
  300. package/dist/realtime/{subscriber_registry.d.ts → sse_registry.d.ts} +12 -12
  301. package/dist/realtime/sse_registry.d.ts.map +1 -0
  302. package/dist/realtime/{subscriber_registry.js → sse_registry.js} +4 -4
  303. package/dist/schema_meta.d.ts +30 -10
  304. package/dist/schema_meta.d.ts.map +1 -1
  305. package/dist/schema_meta.js +85 -21
  306. package/dist/sensitivity.d.ts +9 -3
  307. package/dist/sensitivity.d.ts.map +1 -1
  308. package/dist/sensitivity.js +3 -2
  309. package/dist/server/app_backend.d.ts +8 -5
  310. package/dist/server/app_backend.d.ts.map +1 -1
  311. package/dist/server/app_backend.js +6 -12
  312. package/dist/server/app_server.d.ts +62 -51
  313. package/dist/server/app_server.d.ts.map +1 -1
  314. package/dist/server/app_server.js +84 -71
  315. package/dist/server/app_server_context.d.ts +1 -1
  316. package/dist/server/app_server_context.d.ts.map +1 -1
  317. package/dist/server/env.d.ts +24 -20
  318. package/dist/server/env.d.ts.map +1 -1
  319. package/dist/server/env.js +24 -34
  320. package/dist/server/serve_fact_route.d.ts +12 -16
  321. package/dist/server/serve_fact_route.d.ts.map +1 -1
  322. package/dist/server/serve_fact_route.js +59 -34
  323. package/dist/server/static.d.ts.map +1 -1
  324. package/dist/server/static.js +2 -2
  325. package/dist/testing/CLAUDE.md +179 -158
  326. package/dist/testing/admin_integration.d.ts.map +1 -1
  327. package/dist/testing/admin_integration.js +10 -19
  328. package/dist/testing/adversarial_headers.d.ts.map +1 -1
  329. package/dist/testing/adversarial_headers.js +8 -0
  330. package/dist/testing/app_server.d.ts +9 -77
  331. package/dist/testing/app_server.d.ts.map +1 -1
  332. package/dist/testing/app_server.js +31 -112
  333. package/dist/testing/attack_surface.d.ts.map +1 -1
  334. package/dist/testing/attack_surface.js +3 -4
  335. package/dist/testing/audit_completeness.d.ts.map +1 -1
  336. package/dist/testing/audit_completeness.js +4 -5
  337. package/dist/testing/auth_apps.d.ts +3 -3
  338. package/dist/testing/auth_apps.d.ts.map +1 -1
  339. package/dist/testing/auth_apps.js +9 -6
  340. package/dist/testing/connection_closer_helpers.d.ts +8 -16
  341. package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
  342. package/dist/testing/connection_closer_helpers.js +7 -20
  343. package/dist/testing/cross_backend/action_manifest.d.ts +15 -4
  344. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  345. package/dist/testing/cross_backend/action_manifest.js +13 -3
  346. package/dist/testing/cross_backend/action_manifest_parity.d.ts +15 -7
  347. package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
  348. package/dist/testing/cross_backend/action_manifest_parity.js +8 -1
  349. package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
  350. package/dist/testing/cross_backend/body_size.js +25 -22
  351. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +22 -3
  352. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  353. package/dist/testing/cross_backend/build_test_backend_paths.js +34 -11
  354. package/dist/testing/cross_backend/capabilities.d.ts +13 -7
  355. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  356. package/dist/testing/cross_backend/cell_grant_role.js +2 -2
  357. package/dist/testing/cross_backend/cell_grant_steward.d.ts +4 -0
  358. package/dist/testing/cross_backend/cell_grant_steward.d.ts.map +1 -0
  359. package/dist/testing/cross_backend/cell_grant_steward.js +120 -0
  360. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  361. package/dist/testing/cross_backend/cell_relations.js +21 -0
  362. package/dist/testing/cross_backend/conformance_table.d.ts +1 -1
  363. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  364. package/dist/testing/cross_backend/default_backend_configs.d.ts +18 -4
  365. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  366. package/dist/testing/cross_backend/default_backend_configs.js +29 -9
  367. package/dist/testing/cross_backend/default_spine_surface.d.ts +7 -7
  368. package/dist/testing/cross_backend/default_spine_surface.js +2 -2
  369. package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
  370. package/dist/testing/cross_backend/fact_serving.js +48 -0
  371. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -4
  372. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  373. package/dist/testing/cross_backend/full_spine_mount.js +9 -2
  374. package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -1
  375. package/dist/testing/cross_backend/origin_scope.js +5 -13
  376. package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
  377. package/dist/testing/cross_backend/peer_ping_ws.js +29 -4
  378. package/dist/testing/cross_backend/postgres_database.d.ts +32 -0
  379. package/dist/testing/cross_backend/postgres_database.d.ts.map +1 -1
  380. package/dist/testing/cross_backend/postgres_database.js +56 -1
  381. package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
  382. package/dist/testing/cross_backend/query_shape.js +18 -1
  383. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  384. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +23 -1
  385. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -2
  386. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
  387. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  388. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +17 -5
  389. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  390. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +5 -4
  391. package/dist/testing/cross_backend/session_cap.d.ts +8 -0
  392. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  393. package/dist/testing/cross_backend/session_cap.js +66 -2
  394. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  395. package/dist/testing/cross_backend/setup.js +5 -4
  396. package/dist/testing/cross_backend/spine_suites.d.ts +4 -1
  397. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  398. package/dist/testing/cross_backend/spine_suites.js +21 -0
  399. package/dist/testing/cross_backend/spine_surface_constants.d.ts +22 -7
  400. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  401. package/dist/testing/cross_backend/spine_surface_constants.js +22 -7
  402. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  403. package/dist/testing/cross_backend/sse_round_trip.js +4 -3
  404. package/dist/testing/cross_backend/standard.d.ts +6 -12
  405. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  406. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts +8 -0
  407. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts.map +1 -0
  408. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.js +22 -0
  409. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  410. package/dist/testing/cross_backend/testing_backdoor.js +4 -6
  411. package/dist/testing/cross_backend/testing_origin_check.d.ts +1 -1
  412. package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
  413. package/dist/testing/cross_backend/testing_origin_check.js +1 -1
  414. package/dist/testing/cross_backend/testing_reset_actions.d.ts +10 -5
  415. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  416. package/dist/testing/cross_backend/testing_reset_actions.js +7 -6
  417. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  418. package/dist/testing/cross_backend/testing_server_bun.js +5 -4
  419. package/dist/testing/cross_backend/testing_server_core.d.ts +6 -7
  420. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  421. package/dist/testing/cross_backend/testing_server_core.js +1 -1
  422. package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
  423. package/dist/testing/cross_backend/testing_server_node.js +13 -2
  424. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  425. package/dist/testing/cross_backend/token_lifetime.js +68 -0
  426. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  427. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  428. package/dist/testing/cross_backend/transport_composition.js +45 -3
  429. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +16 -2
  430. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  431. package/dist/testing/cross_backend/ts_spine_backend_config.js +11 -8
  432. package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
  433. package/dist/testing/cross_backend/ws_action_rate_limit.js +30 -12
  434. package/dist/testing/cross_backend/ws_connection_cap.d.ts.map +1 -1
  435. package/dist/testing/cross_backend/ws_connection_cap.js +5 -7
  436. package/dist/testing/cross_backend/ws_endpoint.d.ts +2 -3
  437. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  438. package/dist/testing/cross_backend/ws_envelope.d.ts +17 -0
  439. package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -0
  440. package/dist/testing/cross_backend/ws_envelope.js +172 -0
  441. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts +16 -0
  442. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts.map +1 -1
  443. package/dist/testing/cross_backend/ws_inbound_dispatch.js +8 -4
  444. package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
  445. package/dist/testing/cross_backend/ws_outbound_overflow.js +5 -8
  446. package/dist/testing/cross_backend/ws_role_gated.js +2 -2
  447. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  448. package/dist/testing/cross_backend/ws_round_trip.js +6 -4
  449. package/dist/{cli/daemon.d.ts → testing/daemon_info.d.ts} +15 -47
  450. package/dist/testing/daemon_info.d.ts.map +1 -0
  451. package/dist/testing/daemon_info.js +108 -0
  452. package/dist/testing/daemon_token_rotation.js +1 -1
  453. package/dist/testing/data_exposure.d.ts.map +1 -1
  454. package/dist/testing/data_exposure.js +3 -4
  455. package/dist/testing/db.js +2 -2
  456. package/dist/testing/integration.d.ts.map +1 -1
  457. package/dist/testing/integration.js +35 -65
  458. package/dist/testing/integration_helpers.d.ts +0 -15
  459. package/dist/testing/integration_helpers.d.ts.map +1 -1
  460. package/dist/testing/integration_helpers.js +2 -42
  461. package/dist/testing/middleware.d.ts +20 -12
  462. package/dist/testing/middleware.d.ts.map +1 -1
  463. package/dist/testing/middleware.js +49 -40
  464. package/dist/testing/rate_limiting.d.ts.map +1 -1
  465. package/dist/testing/rate_limiting.js +13 -22
  466. package/dist/testing/resolved_auth.d.ts +30 -0
  467. package/dist/testing/resolved_auth.d.ts.map +1 -0
  468. package/dist/testing/resolved_auth.js +41 -0
  469. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  470. package/dist/testing/rpc_envelope_cases.js +3 -0
  471. package/dist/testing/rpc_helpers.d.ts +1 -1
  472. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  473. package/dist/testing/rpc_helpers.js +2 -1
  474. package/dist/testing/sse_round_trip.d.ts +5 -4
  475. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  476. package/dist/testing/sse_round_trip.js +2 -2
  477. package/dist/testing/stubs.d.ts +2 -2
  478. package/dist/testing/stubs.d.ts.map +1 -1
  479. package/dist/testing/stubs.js +24 -21
  480. package/dist/testing/test_origin.d.ts +25 -0
  481. package/dist/testing/test_origin.d.ts.map +1 -0
  482. package/dist/testing/test_origin.js +28 -0
  483. package/dist/testing/transports/raw_http.d.ts +54 -0
  484. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  485. package/dist/testing/transports/raw_http.js +58 -0
  486. package/dist/testing/transports/ws_raw_client.d.ts +8 -0
  487. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  488. package/dist/testing/transports/ws_raw_client.js +13 -0
  489. package/dist/testing/transports/ws_transport.d.ts +15 -2
  490. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  491. package/dist/testing/transports/ws_transport.js +4 -2
  492. package/dist/testing/ws_round_trip.d.ts +27 -25
  493. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  494. package/dist/testing/ws_round_trip.js +34 -26
  495. package/dist/ui/AccountSessions.svelte +48 -19
  496. package/dist/ui/AccountSessions.svelte.d.ts +2 -17
  497. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
  498. package/dist/ui/AdminAccounts.svelte +6 -1
  499. package/dist/ui/AdminAuditLog.svelte +61 -22
  500. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
  501. package/dist/ui/AdminInvites.svelte +1 -1
  502. package/dist/ui/AdminOverview.svelte +76 -37
  503. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  504. package/dist/ui/AdminRoleGrantHistory.svelte +6 -1
  505. package/dist/ui/AdminSessions.svelte +1 -1
  506. package/dist/ui/AppShell.svelte +3 -2
  507. package/dist/ui/AppShell.svelte.d.ts +3 -2
  508. package/dist/ui/AppShell.svelte.d.ts.map +1 -1
  509. package/dist/ui/CLAUDE.md +121 -35
  510. package/dist/ui/Datatable.svelte +33 -18
  511. package/dist/ui/Datatable.svelte.d.ts +2 -14
  512. package/dist/ui/Datatable.svelte.d.ts.map +1 -1
  513. package/dist/ui/OpenSignupToggle.svelte +10 -1
  514. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
  515. package/dist/ui/PopoverButton.svelte +13 -8
  516. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
  517. package/dist/ui/RoleGrantOfferForm.svelte +3 -2
  518. package/dist/ui/RoleGrantOfferForm.svelte.d.ts +3 -2
  519. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
  520. package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
  521. package/dist/ui/RoleGrantOfferInbox.svelte +19 -15
  522. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
  523. package/dist/ui/SurfaceExplorer.svelte +66 -27
  524. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  525. package/dist/ui/account_sessions_state.svelte.d.ts +7 -14
  526. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  527. package/dist/ui/admin_accounts_state.svelte.d.ts +14 -9
  528. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  529. package/dist/ui/admin_accounts_state.svelte.js +6 -4
  530. package/dist/ui/admin_invites_state.svelte.d.ts +2 -2
  531. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
  532. package/dist/ui/admin_rpc_adapters.d.ts +9 -9
  533. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  534. package/dist/ui/admin_rpc_adapters.js +9 -9
  535. package/dist/ui/app_settings_state.svelte.d.ts +2 -2
  536. package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
  537. package/dist/ui/audit_log_state.svelte.d.ts +70 -13
  538. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  539. package/dist/ui/audit_log_state.svelte.js +239 -47
  540. package/dist/ui/backend_probe.svelte.d.ts +93 -0
  541. package/dist/ui/backend_probe.svelte.d.ts.map +1 -0
  542. package/dist/ui/backend_probe.svelte.js +140 -0
  543. package/dist/ui/format_scope.d.ts +7 -7
  544. package/dist/ui/format_scope.d.ts.map +1 -1
  545. package/dist/ui/format_scope.js +4 -4
  546. package/dist/ui/keyed_async_slot.svelte.d.ts +2 -2
  547. package/dist/ui/keyed_async_slot.svelte.js +2 -2
  548. package/dist/ui/popover.svelte.d.ts +18 -19
  549. package/dist/ui/popover.svelte.d.ts.map +1 -1
  550. package/dist/ui/popover.svelte.js +103 -16
  551. package/dist/ui/role_grant_offers_state.svelte.d.ts +41 -46
  552. package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
  553. package/dist/ui/role_grant_offers_state.svelte.js +37 -19
  554. package/dist/ui/ui_format.d.ts +17 -0
  555. package/dist/ui/ui_format.d.ts.map +1 -1
  556. package/dist/ui/ui_format.js +20 -0
  557. package/package.json +2 -1
  558. package/dist/actions/register_ws_endpoint.d.ts +0 -79
  559. package/dist/actions/register_ws_endpoint.d.ts.map +0 -1
  560. package/dist/actions/register_ws_endpoint.js +0 -109
  561. package/dist/actions/transports_ws_auth_guard.d.ts +0 -96
  562. package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
  563. package/dist/actions/transports_ws_auth_guard.js +0 -141
  564. package/dist/actions/transports_ws_backend.d.ts.map +0 -1
  565. package/dist/cli/args.d.ts +0 -55
  566. package/dist/cli/args.d.ts.map +0 -1
  567. package/dist/cli/args.js +0 -100
  568. package/dist/cli/config.d.ts +0 -47
  569. package/dist/cli/config.d.ts.map +0 -1
  570. package/dist/cli/config.js +0 -77
  571. package/dist/cli/daemon.d.ts.map +0 -1
  572. package/dist/cli/daemon.js +0 -181
  573. package/dist/cli/help.d.ts +0 -124
  574. package/dist/cli/help.d.ts.map +0 -1
  575. package/dist/cli/help.js +0 -215
  576. package/dist/cli/logger.d.ts +0 -46
  577. package/dist/cli/logger.d.ts.map +0 -1
  578. package/dist/cli/logger.js +0 -48
  579. package/dist/cli/util.d.ts +0 -36
  580. package/dist/cli/util.d.ts.map +0 -1
  581. package/dist/cli/util.js +0 -50
  582. package/dist/realtime/sse_auth_guard.d.ts +0 -197
  583. package/dist/realtime/sse_auth_guard.d.ts.map +0 -1
  584. package/dist/realtime/sse_auth_guard.js +0 -239
  585. package/dist/realtime/subscriber_registry.d.ts.map +0 -1
  586. package/dist/testing/bootstrap_success.d.ts +0 -29
  587. package/dist/testing/bootstrap_success.d.ts.map +0 -1
  588. package/dist/testing/bootstrap_success.js +0 -144
  589. package/dist/testing/mock_fs.d.ts +0 -20
  590. package/dist/testing/mock_fs.d.ts.map +0 -1
  591. package/dist/testing/mock_fs.js +0 -28
  592. package/dist/testing/standard.d.ts +0 -122
  593. package/dist/testing/standard.d.ts.map +0 -1
  594. package/dist/testing/standard.js +0 -73
  595. package/dist/testing/testing_rate_limiter.d.ts +0 -65
  596. package/dist/testing/testing_rate_limiter.d.ts.map +0 -1
  597. package/dist/testing/testing_rate_limiter.js +0 -80
@@ -14,7 +14,7 @@ import { Logger } from '@fuzdev/fuz_util/log.ts';
14
14
  import { create_audit_emitter } from '../auth/audit_emitter.js';
15
15
  import { create_realtime_closer } from '../actions/connection_closer.js';
16
16
  import { run_migrations } from '../db/migrate.js';
17
- import { auth_migration_ns, reserved_migration_namespaces } from '../auth/migrations.js';
17
+ import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
18
18
  import { create_db } from '../db/create_db.js';
19
19
  /**
20
20
  * Trivial `AuditFactory` for consumers that don't compose `on_audit_event`
@@ -38,27 +38,21 @@ export const default_audit_factory = ({ db, log }) => create_audit_emitter({ db,
38
38
  *
39
39
  * @param options - keyring, password deps, `audit_factory`, optional database URL, and optional `migration_namespaces`
40
40
  * @returns app backend with deps, database metadata, and combined migration results
41
- * @throws Error if `migration_namespaces` contains a namespace in `reserved_migration_namespaces`
41
+ * @throws MigrationError `namespace-reserved` if a `migration_namespaces` entry bears a `reserved_migration_namespaces` name and is not the spine's own namespace
42
42
  */
43
43
  export const create_app_backend = async (options) => {
44
44
  const { database_url, keyring, password, read_secure_file, delete_file, audit_factory } = options;
45
45
  const log = options.log ?? new Logger('server');
46
46
  const { db, close, db_type, db_name } = await create_db(database_url);
47
- // Everything after `create_db` can throw — reserved-namespace check,
48
- // `run_migrations` (seven MigrationError kinds), `audit_factory`.
47
+ // Everything after `create_db` can throw — `run_migrations` (its
48
+ // `MigrationError` kinds include the reserved-namespace refusal),
49
+ // `audit_factory`.
49
50
  // Without this guard the pool leaks because `close` is only returned
50
51
  // on the success path. Cleanup errors are logged and swallowed so the
51
52
  // caller sees the original failure, not a teardown-shaped one.
52
53
  try {
53
- if (options.migration_namespaces?.length) {
54
- for (const ns of options.migration_namespaces) {
55
- if (reserved_migration_namespaces.includes(ns.namespace)) {
56
- throw new Error(`Migration namespace "${ns.namespace}" is reserved by fuz_app — choose a different namespace`);
57
- }
58
- }
59
- }
60
54
  const migration_results = await run_migrations(db, [
61
- auth_migration_ns,
55
+ AUTH_MIGRATION_NS,
62
56
  ...(options.migration_namespaces ?? [])
63
57
  ]);
64
58
  const audit = audit_factory({ db, log });
@@ -13,7 +13,7 @@ import { z } from 'zod';
13
13
  import { type SessionOptions, type SessionCookieOptions } from '../auth/session_cookie.js';
14
14
  import type { BootstrapAccountSuccess } from '../auth/bootstrap_account.js';
15
15
  import type { EventSpec } from '../realtime/sse.js';
16
- import { type AuditLogSse } from '../realtime/sse_auth_guard.js';
16
+ import { type AuditLogSse } from '../realtime/audit_log_sse.js';
17
17
  import { RateLimiter, type RateLimiterMode, type RateLimiterOptions } from '../rate_limiter.js';
18
18
  import type { DaemonTokenState } from '../auth/daemon_token.js';
19
19
  import type { MigrationResult } from '../db/migrate.js';
@@ -25,18 +25,10 @@ import { type AppSurfaceSpec, type AppSurfaceDiagnostic, type RpcEndpointSpec }
25
25
  import { type RouteSpec } from '../http/route_spec.js';
26
26
  import type { MiddlewareCarveOut, MiddlewareSpec } from '../http/middleware_spec.js';
27
27
  import { type BootstrapStatus } from '../auth/bootstrap_routes.js';
28
+ import { type EffectErrorContext } from '../http/pending_effects.js';
28
29
  import { type WsEndpointSpec } from '../actions/ws_endpoint_spec.js';
29
- import type { BackendWebsocketTransport } from '../actions/transports_ws_backend.js';
30
+ import type { ConnectionRegistry } from '../actions/connection_registry.js';
30
31
  import { type AuthCleanupScheduleOptions } from '../auth/cleanup.js';
31
- /**
32
- * Context passed to `on_effect_error` when a pending effect rejects.
33
- */
34
- export interface EffectErrorContext {
35
- /** HTTP method of the request that spawned the effect. */
36
- method: string;
37
- /** URL path of the request that spawned the effect. */
38
- path: string;
39
- }
40
32
  /**
41
33
  * Bootstrap configuration for `AppServerOptions.bootstrap`.
42
34
  *
@@ -89,10 +81,23 @@ export interface AppServerOptions {
89
81
  /** Session options for cookie-based auth. */
90
82
  session_options: SessionOptions<string>;
91
83
  /**
92
- * Parsed allowed origin patterns. Must not be empty — an empty list would
93
- * refuse every browser request, so assembly throws.
84
+ * Parsed allowed origin patterns, as `parse_allowed_origins` returns them
85
+ * (`validate_server_env`'s `allowed_origins`); assembly throws on a matcher
86
+ * built any other way, since its wildcards can't be checked. Must not be
87
+ * empty — an empty list would refuse every browser request, so assembly
88
+ * throws.
94
89
  */
95
90
  allowed_origins: Array<RegExp>;
91
+ /**
92
+ * Admit a wildcard `allowed_origins` entry (`:*`, a `*` label) — the
93
+ * operator's `FUZ_ALLOW_ORIGIN_WILDCARDS=true`, as `validate_server_env`
94
+ * reads it. Without it assembly throws on one, naming each entry and what it
95
+ * admits; with it each is logged at `warn`, on every assembly. Covers each
96
+ * `ws_endpoints` spec's own `allowed_origins` too. Classifies the matchers
97
+ * `parse_allowed_origins` built (`http/origin_wildcard.ts`); assembly throws
98
+ * on any other matcher, flag or not. Defaults to `false`.
99
+ */
100
+ allow_origin_wildcards?: boolean;
96
101
  /**
97
102
  * Paths the origin check skips, each with its reason. The check covers
98
103
  * every path by default (`ORIGIN_MIDDLEWARE_PATH`) — a request with no
@@ -252,18 +257,21 @@ export interface AppServerOptions {
252
257
  * this option is set, the field is non-null. Use `require_audit_sse(ctx)` to
253
258
  * assert the invariant in route factories that depend on it.
254
259
  *
255
- * Pass `true` for defaults (admin role), or `{role: 'custom'}` for a custom role.
256
- * Omit to wire audit SSE manually.
260
+ * Pass `true` for defaults (admin role), or `{role: 'custom'}` for a custom
261
+ * role; `keep_alive_ms` sets the streams' keep-alive interval (a test server
262
+ * shortens it; default `SSE_KEEP_ALIVE_INTERVAL_MS`). Omit to wire audit SSE
263
+ * manually.
257
264
  */
258
265
  audit_log_sse?: true | {
259
266
  role?: string;
267
+ keep_alive_ms?: number | null;
260
268
  };
261
269
  /**
262
270
  * Schedule the auth cleanup beside the server: `start_auth_cleanup` over
263
271
  * `backend.deps` — a pass as assembly finishes, then one per interval —
264
272
  * stopped by `AppServer.close`. Each pass deletes expired sessions and
265
273
  * closes the connections they opened through `deps.connection_closer`
266
- * (every WebSocket transport and audit stream this server mounts), and
274
+ * (every WebSocket connection registry and audit stream this server mounts), and
267
275
  * audits each newly expired role_grant offer once.
268
276
  *
269
277
  * **Off by default; a production server should turn it on.** Without it
@@ -335,8 +343,13 @@ export interface AppServerOptions {
335
343
  /**
336
344
  * WebSocket endpoint specs — single source of truth for both surface
337
345
  * generation *and* live dispatch. Each entry is auto-mounted via
338
- * `register_ws_endpoint` against the assembled Hono app on every
339
- * runtime, so consumers don't call `register_ws_endpoint` themselves.
346
+ * `register_action_ws` against the assembled Hono app on every
347
+ * runtime, so consumers don't call `register_action_ws` themselves.
348
+ *
349
+ * An entry that omits `actions` serves the actions of the sole
350
+ * `rpc_endpoints` entry (`to_ws_actions`: the protocol actions first, then
351
+ * the RPC set), so one action set runs on both transports; assembly throws
352
+ * unless exactly one RPC endpoint resolves.
340
353
  *
341
354
  * Accepts either an array (evaluated eagerly) or a factory
342
355
  * `(ctx: AppServerContext) => ReadonlyArray<WsEndpointSpec>`
@@ -351,7 +364,8 @@ export interface AppServerOptions {
351
364
  * Every mount gets what the HTTP surface gets: the auth middleware (a
352
365
  * path outside `AUTH_MIDDLEWARE_PATH` throws at assembly, like
353
366
  * `rpc_endpoints`), the server's `allowed_origins` unless the spec
354
- * narrows them, and the same `action_ip_rate_limiter` /
367
+ * narrows them (a spec's own list gets the same wildcard check,
368
+ * `allow_origin_wildcards`), and the same `action_ip_rate_limiter` /
355
369
  * `action_account_rate_limiter` instances the RPC endpoints charge — one
356
370
  * budget per action across both transports. The upgrade routes register
357
371
  * after the route specs and before `post_route_middleware` and
@@ -361,19 +375,11 @@ export interface AppServerOptions {
361
375
  * GET `RouteSpec` already claims, throw at assembly before any endpoint
362
376
  * mounts (Hono would silently shadow them otherwise).
363
377
  *
364
- * Every mounted transport is added to `deps.connection_closer`, so
365
- * the revocation handlers' post-commit closes reach its sockets —
366
- * unconditionally, since those closes are what ends a revoked
367
- * credential's connections. `AppServer.close` removes it again.
368
- *
369
- * Each spec's `auth_guard?` defaults to `true` — the factory
370
- * registers `create_ws_auth_guard` against the mounted transport via
371
- * `deps.audit.add_listener`, repeating the close on the audit row.
372
- * Wiring is deduped by transport **reference identity** so two specs
373
- * sharing one `BackendWebsocketTransport` instance get a single
374
- * listener; wrapped / proxied transports dedupe as separate
375
- * entries (set `auth_guard: false` on duplicates and compose
376
- * against the underlying transport once).
378
+ * Every mounted connection registry is added to `deps.connection_closer`, so
379
+ * the revocation handlers' post-commit closes reach its sockets, and so
380
+ * does the one revocation guard `create_app_server` registers on that
381
+ * closer (`create_revocation_guard`) when it mounts a WS endpoint or the
382
+ * audit stream. `AppServer.close` removes it again.
377
383
  */
378
384
  ws_endpoints?: ReadonlyArray<WsEndpointSpec> | ((context: AppServerContext) => ReadonlyArray<WsEndpointSpec>);
379
385
  /**
@@ -405,9 +411,9 @@ export interface AppServerOptions {
405
411
  */
406
412
  await_pending_effects?: boolean;
407
413
  /**
408
- * Called when a pending effect rejects.
409
- * Use for monitoring, metrics, or alerting in production.
410
- * Only called when `await_pending_effects` is `false` (production mode).
414
+ * Called when an eager pending effect rejects, on HTTP requests and on the
415
+ * frames of every WS endpoint the server mounts, in either
416
+ * `await_pending_effects` mode. Use for monitoring, metrics, or alerting.
411
417
  */
412
418
  on_effect_error?: (error: unknown, context: EffectErrorContext) => void;
413
419
  /** Env values for startup summary logging. */
@@ -429,8 +435,8 @@ export interface AppServer {
429
435
  audit_sse: AuditLogSse | null;
430
436
  /**
431
437
  * Path-keyed map of mounted WS endpoints. Each value is the
432
- * `BackendWebsocketTransport` `create_app_server` registered
433
- * connections against — supplied via `WsEndpointSpec.transport` or
438
+ * `ConnectionRegistry` `create_app_server` registered
439
+ * connections against — supplied via `WsEndpointSpec.registry` or
434
440
  * auto-created when omitted. Retain for broadcast / fan-out:
435
441
  *
436
442
  * ```ts
@@ -439,7 +445,7 @@ export interface AppServer {
439
445
  *
440
446
  * Empty when no `ws_endpoints` were mounted.
441
447
  */
442
- ws_endpoints: Readonly<Record<string, BackendWebsocketTransport>>;
448
+ ws_endpoints: Readonly<Record<string, ConnectionRegistry>>;
443
449
  /**
444
450
  * Shut the server's resources down, in order:
445
451
  *
@@ -447,19 +453,18 @@ export interface AppServer {
447
453
  * one, waiting for a pass in progress — that wait has no bound of its
448
454
  * own, so a shutdown with a deadline races it
449
455
  * 2. close every live connection on `deps.connection_closer`
450
- * (`close_all_sockets`) — each WebSocket with `WS_CLOSE_GOING_AWAY`, each
451
- * audit stream — including transports supplied through
452
- * `WsEndpointSpec.transport` or added by hand, since they are registered
456
+ * (`close_all_connections`) — each WebSocket with `WS_CLOSE_GOING_AWAY`, each
457
+ * audit stream — including registries supplied through
458
+ * `WsEndpointSpec.registry` or added by hand, since they are registered
453
459
  * on the backend's closer and the backend is going away; a close that
454
- * throws is logged and the shutdown goes on. Each transport and registry
460
+ * throws is logged and the shutdown goes on. Each connection and SSE registry
455
461
  * is left closing, so an upgrade or stream that registers afterward is
456
462
  * born closed — refused at once rather than outliving the server — and
457
- * a closed transport hosts no other server
463
+ * a closed registry hosts no other server
458
464
  * 3. release what assembly acquired, last acquired first: remove the
459
465
  * audit listeners `create_app_server` registered on `deps.audit` (the
460
- * audit-log SSE listener, the WS auth guards, each
461
- * `extra_audit_handlers` entry) and the closer members it added to
462
- * `deps.connection_closer` (each mounted transport, the audit stream
466
+ * revocation guard, the audit-log SSE listener) and the closer members it added to
467
+ * `deps.connection_closer` (each mounted connection registry, the audit stream
463
468
  * registry), and `dispose` the rate limiters it built for omitted
464
469
  * options — never one passed in, which its caller owns. A release that
465
470
  * throws is logged and the rest still run. The backend's emitter and
@@ -497,8 +502,11 @@ export interface AppServer {
497
502
  export declare const require_audit_sse: (source: {
498
503
  audit_sse: AuditLogSse | null;
499
504
  }) => AuditLogSse;
500
- /** Default maximum request body size: 1 MiB. */
501
- export declare const DEFAULT_MAX_BODY_SIZE: number;
505
+ /**
506
+ * Default maximum request body size: 1 MiB. Twin of the Rust spine's
507
+ * `fuz_http` `DEFAULT_BODY_LIMIT_BYTES`.
508
+ */
509
+ export declare const DEFAULT_BODY_LIMIT_BYTES: number;
502
510
  /**
503
511
  * Each `AppServerOptions` rate-limiter field, with the defaults an omitted one
504
512
  * is built from under `rate_limiters: 'enforced'` and the name its
@@ -614,9 +622,12 @@ export declare const collect_config_diagnostics: (input: ConfigDiagnosticsInput)
614
622
  *
615
623
  * When `audit_log_sse` is set, the SSE registry's listener is registered via
616
624
  * `backend.deps.audit.add_listener` — no shallow-copy of `AppDeps`. That
617
- * registry and every WebSocket transport mounted from `ws_endpoints` are added
625
+ * registry and every WebSocket connection registry mounted from `ws_endpoints` are added
618
626
  * to `backend.deps.connection_closer`, so the revocation handlers built from
619
- * `ctx.deps` close their connections with no further wiring. The
627
+ * `ctx.deps` close their connections with no further wiring, and — when the
628
+ * server mounts either — one `create_revocation_guard` listener on that closer
629
+ * repeats each close on the audit row (the only closer of a role revocation).
630
+ * The
620
631
  * `audit_sse` field on the returned `AppServer` (and the
621
632
  * `AppServerContext` passed to `create_route_specs`) is non-null in that
622
633
  * case; consumers can call `require_audit_sse(ctx)` / `require_audit_sse(server)`
@@ -637,7 +648,7 @@ export declare const collect_config_diagnostics: (input: ConfigDiagnosticsInput)
637
648
  * closes the database (`AppServer.close`).
638
649
  *
639
650
  * @returns the assembled Hono app with its surface, bootstrap status, migration results,
640
- * audit SSE, mounted WS transports, and `close`
651
+ * audit SSE, mounted WS registries, and `close`
641
652
  * @throws Error from any assembly step, after releasing what assembly acquired
642
653
  */
643
654
  export declare const create_app_server: (options: AppServerOptions) => Promise<AppServer>;
@@ -1 +1 @@
1
- {"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,OAAO,EAA0B,MAAM,MAAM,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,oB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MAAM,OAAO,kBAAkB,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,EAEpC,aAAa,CAAC,uBAAuB,CAAC,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC,2DAA2D;IAC3D,IAAI,EAAE,eAAe,CAAC;IACtB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC,uBAAuB,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;IAC9D;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,GACjC,SAAS,IAAI,CAAC,gBAAgB,EAAE,uBAAuB,GAAG,eAAe,CAAC,KACxE,oBAkBF,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC,6EAA6E;IAC7E,cAAc,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,SAAS,CAAC;IAC1D,2CAA2C;IAC3C,iBAAiB,EAAE,eAAe,CAAC;IACnC,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC,uBAAuB,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;IACnE,uFAAuF;IACvF,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GACtC,OAAO,sBAAsB,KAC3B,KAAK,CAAC,oBAAoB,CA0D5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,iBAAiB,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,SAAS,CAQpF,CAAC"}
@@ -11,7 +11,7 @@ import { Hono } from 'hono';
11
11
  import { logger } from 'hono/logger';
12
12
  import { z } from 'zod';
13
13
  import { session_cookie_options } from '../auth/session_cookie.js';
14
- import { create_audit_log_sse, create_sse_connection_closer, audit_log_event_specs } from '../realtime/sse_auth_guard.js';
14
+ import { create_audit_log_sse, create_sse_connection_closer, audit_log_event_specs } from '../realtime/audit_log_sse.js';
15
15
  import { BaseServerEnv } from './env.js';
16
16
  import { RateLimiter, announce_rate_limiters_disabled, default_login_ip_rate_limit, default_login_account_rate_limit, default_action_account_rate_limit, default_action_ip_rate_limit } from '../rate_limiter.js';
17
17
  // Side-effect import: augments Hono's ContextVariableMap so consumers
@@ -24,15 +24,16 @@ import { create_app_surface_spec } from '../http/surface.js';
24
24
  import { apply_middleware_specs, apply_route_specs, prefix_route_specs } from '../http/route_spec.js';
25
25
  import { check_bootstrap_status, create_bootstrap_route_specs } from '../auth/bootstrap_routes.js';
26
26
  import { create_surface_route_spec } from './surface_route.js';
27
- import { flush_pending_effects, flush_post_commit_effects } from '../http/pending_effects.js';
27
+ import { flush_request_effects } from '../http/pending_effects.js';
28
28
  import { assert_credential_routes_in_auth_scope, assert_endpoint_in_auth_scope, assert_middleware_stack_mounted, create_auth_middleware_specs } from '../auth/middleware.js';
29
29
  import { fuz_auth_guard_resolver } from '../auth/auth_guard_resolver.js';
30
30
  import { create_fuz_authorization_handler } from '../auth/request_context.js';
31
31
  import { create_body_limit_middleware } from '../http/body_limit.js';
32
+ import { admit_origin_wildcards, ALLOWED_ORIGINS_VAR } from '../http/origin_wildcard.js';
32
33
  import { create_rpc_endpoint } from '../actions/action_rpc.js';
33
- import { register_ws_endpoint } from '../actions/register_ws_endpoint.js';
34
+ import { register_action_ws } from '../actions/register_action_ws.js';
34
35
  import { resolve_ws_endpoints } from '../actions/ws_endpoint_spec.js';
35
- import { create_ws_auth_guard } from '../actions/transports_ws_auth_guard.js';
36
+ import { create_revocation_guard } from '../actions/connection_closer.js';
36
37
  import { start_auth_cleanup } from '../auth/cleanup.js';
37
38
  /**
38
39
  * Assert that `audit_sse` was wired by `create_app_server` and return it
@@ -57,8 +58,11 @@ export const require_audit_sse = (source) => {
57
58
  }
58
59
  return source.audit_sse;
59
60
  };
60
- /** Default maximum request body size: 1 MiB. */
61
- export const DEFAULT_MAX_BODY_SIZE = 1024 * 1024;
61
+ /**
62
+ * Default maximum request body size: 1 MiB. Twin of the Rust spine's
63
+ * `fuz_http` `DEFAULT_BODY_LIMIT_BYTES`.
64
+ */
65
+ export const DEFAULT_BODY_LIMIT_BYTES = 1024 * 1024;
62
66
  /**
63
67
  * Each `AppServerOptions` rate-limiter field, with the defaults an omitted one
64
68
  * is built from under `rate_limiters: 'enforced'` and the name its
@@ -199,9 +203,12 @@ export const collect_config_diagnostics = (input) => {
199
203
  *
200
204
  * When `audit_log_sse` is set, the SSE registry's listener is registered via
201
205
  * `backend.deps.audit.add_listener` — no shallow-copy of `AppDeps`. That
202
- * registry and every WebSocket transport mounted from `ws_endpoints` are added
206
+ * registry and every WebSocket connection registry mounted from `ws_endpoints` are added
203
207
  * to `backend.deps.connection_closer`, so the revocation handlers built from
204
- * `ctx.deps` close their connections with no further wiring. The
208
+ * `ctx.deps` close their connections with no further wiring, and — when the
209
+ * server mounts either — one `create_revocation_guard` listener on that closer
210
+ * repeats each close on the audit row (the only closer of a role revocation).
211
+ * The
205
212
  * `audit_sse` field on the returned `AppServer` (and the
206
213
  * `AppServerContext` passed to `create_route_specs`) is non-null in that
207
214
  * case; consumers can call `require_audit_sse(ctx)` / `require_audit_sse(server)`
@@ -222,7 +229,7 @@ export const collect_config_diagnostics = (input) => {
222
229
  * closes the database (`AppServer.close`).
223
230
  *
224
231
  * @returns the assembled Hono app with its surface, bootstrap status, migration results,
225
- * audit SSE, mounted WS transports, and `close`
232
+ * audit SSE, mounted WS registries, and `close`
226
233
  * @throws Error from any assembly step, after releasing what assembly acquired
227
234
  */
228
235
  export const create_app_server = async (options) => {
@@ -263,11 +270,17 @@ const assemble_app_server = async (options, releases) => {
263
270
  throw new Error('create_app_server: allowed_origins is empty — list at least one origin pattern ' +
264
271
  '(an empty list refuses every browser request)');
265
272
  }
273
+ const wildcards = admit_origin_wildcards(options.allowed_origins, options.allow_origin_wildcards ?? false);
274
+ if (!wildcards.ok)
275
+ throw new Error(`create_app_server: ${wildcards.message}`);
276
+ for (const { entry, warning } of wildcards.wildcards) {
277
+ log.warn(`${ALLOWED_ORIGINS_VAR}: ${warning} (origin ${entry})`);
278
+ }
266
279
  // body size limit — rejects oversized payloads before auth/validation; the
267
280
  // middleware throws on a cap that is not a safe integer 0 or more
268
281
  const body_limit_middleware = options.max_body_size === null
269
282
  ? null
270
- : create_body_limit_middleware(options.max_body_size ?? DEFAULT_MAX_BODY_SIZE);
283
+ : create_body_limit_middleware(options.max_body_size ?? DEFAULT_BODY_LIMIT_BYTES);
271
284
  // Rate limiters — the ones built here are the server's to dispose, on
272
285
  // close or when assembly fails.
273
286
  const { mode: rate_limiter_mode, limiters: rate_limiters, built: built_rate_limiters } = resolve_rate_limiters(options);
@@ -284,7 +297,9 @@ const assemble_app_server = async (options, releases) => {
284
297
  const audit_sse = options.audit_log_sse
285
298
  ? create_audit_log_sse({
286
299
  log,
287
- role: typeof options.audit_log_sse === 'object' ? options.audit_log_sse.role : undefined,
300
+ ...(typeof options.audit_log_sse === 'object'
301
+ ? { role: options.audit_log_sse.role, keep_alive_ms: options.audit_log_sse.keep_alive_ms }
302
+ : null),
288
303
  connection_closer: null
289
304
  })
290
305
  : null;
@@ -377,15 +392,16 @@ const assemble_app_server = async (options, releases) => {
377
392
  }
378
393
  // WS endpoint resolution — done here (alongside RPC) so the captured
379
394
  // array threads into surface generation below. Actual mount happens
380
- // after `apply_route_specs` because `register_ws_endpoint` mutates the
381
- // live Hono `app` (origin / auth / role / authorization middleware +
382
- // the `app.get(path, ...)` upgrade route), and `app` does not exist
383
- // until the assembly phase below.
384
- // A spec without `allowed_origins` takes the server's list — resolved here,
385
- // once, so the mount and the surface read the same patterns.
395
+ // after `apply_route_specs` because `register_action_ws` mutates the
396
+ // live Hono `app` (the `app.get(path, ...)` upgrade route with its
397
+ // origin / auth / scope / authorization / role chain), and `app` does not
398
+ // exist until the assembly phase below.
399
+ // A spec without `allowed_origins` takes the server's list, and one without
400
+ // `actions` the sole RPC endpoint's — resolved here, once, so the mount and
401
+ // the surface read the same values.
386
402
  const resolved_ws_endpoints = resolve_ws_endpoints(typeof options.ws_endpoints === 'function'
387
403
  ? options.ws_endpoints(context)
388
- : options.ws_endpoints, options.allowed_origins);
404
+ : options.ws_endpoints, { allowed_origins: options.allowed_origins, rpc_endpoints: resolved_rpc_endpoints });
389
405
  // the endpoints to mount and the adapter factory they need — null when none resolve
390
406
  let ws_mount = null;
391
407
  if (resolved_ws_endpoints?.length) {
@@ -399,6 +415,14 @@ const assemble_app_server = async (options, releases) => {
399
415
  }
400
416
  ws_mount = { endpoints: resolved_ws_endpoints, create_upgrade_websocket };
401
417
  }
418
+ // The one revocation listener, registered when a WS endpoint or the audit
419
+ // stream is mounted — on the backend's closer, so it reaches every member:
420
+ // each WS connection registry the mount below adds, the audit stream registry, and any
421
+ // the consumer added by hand. After the audit stream's listener, so a
422
+ // revocation's row reaches the stream before the guard can close it.
423
+ if (audit_sse || ws_mount) {
424
+ releases.push(deps.audit.add_listener(create_revocation_guard(deps.connection_closer, log)));
425
+ }
402
426
  // Surface route (opt-in)
403
427
  if (options.surface_route) {
404
428
  factory_routes.push(create_surface_route_spec(surface_ref));
@@ -409,7 +433,7 @@ const assemble_app_server = async (options, releases) => {
409
433
  // prefixes included (account and signup specs are relative)
410
434
  assert_credential_routes_in_auth_scope(route_specs);
411
435
  // WS path checks — pure data, so they run before anything mounts.
412
- // `register_ws_endpoint` mounts a `GET path` upgrade route: a duplicate
436
+ // `register_action_ws` mounts a `GET path` upgrade route: a duplicate
413
437
  // path, or one a `RouteSpec` already registered as `GET path`, would be
414
438
  // silently shadowed by Hono's last-wins semantics — fail fast instead. An
415
439
  // endpoint's own empty `allowed_origins` would refuse every browser upgrade.
@@ -432,6 +456,18 @@ const assemble_app_server = async (options, releases) => {
432
456
  'list at least one origin pattern, or omit it to take the server list ' +
433
457
  '(an empty list refuses every browser upgrade)');
434
458
  }
459
+ // an endpoint's own list gets the server list's wildcard check (one
460
+ // that took the server list was checked above)
461
+ if (endpoint.allowed_origins !== options.allowed_origins) {
462
+ const label = `ws_endpoints allowed_origins for ${endpoint.path}`;
463
+ const endpoint_wildcards = admit_origin_wildcards(endpoint.allowed_origins, options.allow_origin_wildcards ?? false, label);
464
+ if (!endpoint_wildcards.ok) {
465
+ throw new Error(`create_app_server: ${endpoint_wildcards.message}`);
466
+ }
467
+ for (const { entry, warning } of endpoint_wildcards.wildcards) {
468
+ log.warn(`${label}: ${warning} (origin ${entry})`);
469
+ }
470
+ }
435
471
  seen_paths.add(endpoint.path);
436
472
  }
437
473
  }
@@ -470,12 +506,14 @@ const assemble_app_server = async (options, releases) => {
470
506
  // fire-and-forget promises (audit emits, api-token usage). `post_commit_effects` collects deferred thunks pushed via
471
507
  // `emit_after_commit` (WS notifications, anything that must observe a
472
508
  // committed transaction). Both queues drain here, after the handler
473
- // (and any wrapping `db.transaction`) returns. In test mode both are
474
- // awaited before the response returns; in production, eager-queue
475
- // rejections are reported via `on_effect_error`. Either way the
476
- // deferred thunks are invoked without waiting for the eager writes to
477
- // settle — a revocation's connection close must not sit behind a slow
478
- // audit INSERT.
509
+ // (and any wrapping `db.transaction`) returns, through the flush the WS
510
+ // dispatcher shares (`flush_request_effects`). In test mode the flush is
511
+ // awaited before the response returns; in production it runs
512
+ // fire-and-forget. Either way eager rejections reach `on_effect_error`,
513
+ // and the deferred thunks are invoked without waiting for the eager
514
+ // writes to settle — a revocation's connection close must not sit behind
515
+ // a slow audit INSERT.
516
+ const on_effect_error = options.on_effect_error;
479
517
  app.use('*', async (c, next) => {
480
518
  c.set('pending_effects', []);
481
519
  c.set('post_commit_effects', []);
@@ -486,23 +524,16 @@ const assemble_app_server = async (options, releases) => {
486
524
  const eager = c.var.pending_effects;
487
525
  const deferred = c.var.post_commit_effects;
488
526
  if (eager.length || deferred.length) {
489
- if (options.await_pending_effects) {
490
- // run the deferred thunks before awaiting the eager writes,
491
- // so neither mode holds them behind a write
492
- const deferred_flush = flush_post_commit_effects(deferred, log);
493
- await flush_pending_effects(eager, log);
494
- await deferred_flush;
495
- }
496
- else {
497
- const error_ctx = { method: c.req.method, path: c.req.path };
498
- const callback = options.on_effect_error;
499
- void flush_pending_effects(eager, log, callback ? (reason) => callback(reason, error_ctx) : undefined);
500
- // `flush_post_commit_effects` is non-throwing: per-thunk
501
- // errors are routed through `log.error` inside the helper,
502
- // so production fire-and-forget skips the `on_effect_error`
503
- // fan-out (deferred thunks are wrapped end-to-end already).
504
- void flush_post_commit_effects(deferred, log);
505
- }
527
+ const error_ctx = {
528
+ transport: 'http',
529
+ method: c.req.method,
530
+ path: c.req.path
531
+ };
532
+ const flushed = flush_request_effects(eager, deferred, log, on_effect_error ? (reason) => on_effect_error(reason, error_ctx) : undefined);
533
+ if (options.await_pending_effects)
534
+ await flushed;
535
+ else
536
+ void flushed;
506
537
  }
507
538
  }
508
539
  });
@@ -518,8 +549,7 @@ const assemble_app_server = async (options, releases) => {
518
549
  apply_route_specs(app, route_specs, fuz_auth_guard_resolver, log, deps.db, authorize);
519
550
  // WS endpoint auto-mount — must run after `app` exists and
520
551
  // `apply_route_specs` has registered the request routes. Each spec
521
- // becomes a `register_ws_endpoint` call, plus optional `auth_guard`
522
- // wiring onto the audit chain. `post_route_middleware` and static
552
+ // becomes a `register_action_ws` call. `post_route_middleware` and static
523
553
  // serving register after this loop, so WS upgrade routes sit
524
554
  // adjacent to the consumer routes and ahead of the static fallback —
525
555
  // matches the "WS mount is route registration" mental model.
@@ -528,50 +558,33 @@ const assemble_app_server = async (options, releases) => {
528
558
  // the adapter helper — built from this app, which Node's
529
559
  // `createNodeWebSocket({app})` needs, and only when there is something to mount
530
560
  const upgrade_websocket = ws_mount.create_upgrade_websocket(app);
531
- // Dedupe `auth_guard` wiring by transport reference — two specs
532
- // sharing one transport instance get a single listener,
533
- // otherwise revocation events would fire `close_sockets_for_*`
534
- // twice per event (idempotent on the transport but log-spammy).
535
- // Cross-spec OR-semantics: any spec with `auth_guard !== false`
536
- // wires the guard for that transport; once wired, sibling specs
537
- // (even with explicit `auth_guard: false`) cannot opt out. To
538
- // disable, every spec sharing the transport must pass `auth_guard: false`.
539
- const guarded_transports = new WeakSet();
540
561
  for (const endpoint of ws_mount.endpoints) {
541
- const { transport: endpoint_transport } = register_ws_endpoint({
562
+ const { registry: endpoint_registry } = register_action_ws({
542
563
  app,
543
564
  path: endpoint.path,
544
565
  upgradeWebSocket: upgrade_websocket,
545
566
  allowed_origins: endpoint.allowed_origins,
546
567
  db: deps.db,
547
568
  actions: endpoint.actions,
548
- transport: endpoint.transport,
569
+ registry: endpoint.registry,
549
570
  // added below instead, so the remover is the server's
550
571
  connection_closer: null,
551
572
  max_connections_per_account: endpoint.max_connections_per_account,
552
573
  outbound_queue_bytes: endpoint.outbound_queue_bytes,
553
- heartbeat: endpoint.heartbeat,
554
- artificial_delay: endpoint.artificial_delay,
574
+ receive_timeout: endpoint.receive_timeout,
555
575
  max_message_bytes: endpoint.max_message_bytes,
556
576
  on_socket_open: endpoint.on_socket_open,
557
577
  on_socket_close: endpoint.on_socket_close,
558
578
  log,
559
579
  required_roles: endpoint.required_roles,
560
580
  action_ip_rate_limiter,
561
- action_account_rate_limiter
581
+ action_account_rate_limiter,
582
+ on_effect_error
562
583
  });
563
- mounted_ws_endpoints[endpoint.path] = endpoint_transport;
564
- // every revocation handler's close reaches this transport
565
- releases.push(deps.connection_closer.add(endpoint_transport));
566
- if (endpoint.auth_guard !== false && !guarded_transports.has(endpoint_transport)) {
567
- guarded_transports.add(endpoint_transport);
568
- releases.push(deps.audit.add_listener(create_ws_auth_guard(endpoint_transport, log)));
569
- }
570
- if (endpoint.extra_audit_handlers?.length) {
571
- for (const handler of endpoint.extra_audit_handlers) {
572
- releases.push(deps.audit.add_listener(handler));
573
- }
574
- }
584
+ mounted_ws_endpoints[endpoint.path] = endpoint_registry;
585
+ // every revocation's close — the handlers' and the guard's — reaches
586
+ // this registry
587
+ releases.push(deps.connection_closer.add(endpoint_registry));
575
588
  }
576
589
  }
577
590
  // Post-route middleware (before static serving)
@@ -602,7 +615,7 @@ const assemble_app_server = async (options, releases) => {
602
615
  // then the connections, so none outlives the server — a failure here
603
616
  // must not keep the database open
604
617
  try {
605
- deps.connection_closer.close_all_sockets();
618
+ deps.connection_closer.close_all_connections();
606
619
  }
607
620
  catch (error) {
608
621
  log.error('create_app_server: closing live connections on shutdown failed:', error);
@@ -18,7 +18,7 @@ import type { AppBackend } from './app_backend.js';
18
18
  import type { BootstrapStatus } from '../auth/bootstrap_routes.js';
19
19
  import type { SessionOptions } from '../auth/session_cookie.js';
20
20
  import type { RateLimiter } from '../rate_limiter.js';
21
- import type { AuditLogSse } from '../realtime/sse_auth_guard.js';
21
+ import type { AuditLogSse } from '../realtime/audit_log_sse.js';
22
22
  /** Context passed to `create_route_specs`. */
23
23
  export interface AppServerContext {
24
24
  deps: AppDeps;
@@ -1 +1 @@
1
- {"version":3,"file":"app_server_context.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,UAAU,CAAC;IACpB,gBAAgB,EAAE,eAAe,CAAC;IAClC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;;OASG;IACH,qBAAqB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1C,wDAAwD;IACxD,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C,2DAA2D;IAC3D,yBAAyB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9C,4DAA4D;IAC5D,0BAA0B,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/C,6DAA6D;IAC7D,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,iGAAiG;IACjG,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;OAGG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD;;;;OAIG;IACH,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B"}
1
+ {"version":3,"file":"app_server_context.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,UAAU,CAAC;IACpB,gBAAgB,EAAE,eAAe,CAAC;IAClC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;;OASG;IACH,qBAAqB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1C,wDAAwD;IACxD,sBAAsB,EAAE,WAAW,G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