@fuzdev/fuz_app 0.150.0 → 0.152.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.
- package/README.md +1 -1
- package/dist/actions/CLAUDE.md +324 -299
- package/dist/actions/action_bridge.d.ts +5 -86
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +4 -84
- package/dist/actions/action_codegen.d.ts +8 -166
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +19 -95
- package/dist/actions/action_dispatcher.d.ts +10 -0
- package/dist/actions/action_dispatcher.d.ts.map +1 -1
- package/dist/actions/action_dispatcher.js +9 -6
- package/dist/actions/action_event.d.ts +1 -2
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +7 -13
- package/dist/actions/action_event_helpers.d.ts +1 -40
- package/dist/actions/action_event_helpers.d.ts.map +1 -1
- package/dist/actions/action_event_helpers.js +1 -25
- package/dist/actions/action_rpc.d.ts +10 -215
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +56 -111
- package/dist/actions/action_spec.d.ts +2 -2
- package/dist/actions/action_spec.js +2 -2
- package/dist/actions/action_types.d.ts +229 -8
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +56 -5
- package/dist/actions/broadcast_api.d.ts +22 -17
- package/dist/actions/broadcast_api.d.ts.map +1 -1
- package/dist/actions/broadcast_api.js +16 -27
- package/dist/actions/cancel.d.ts +4 -13
- package/dist/actions/cancel.d.ts.map +1 -1
- package/dist/actions/cancel.js +5 -17
- package/dist/actions/compile_action_registry.d.ts +1 -2
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/connection_closer.d.ts +120 -50
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +139 -31
- package/dist/actions/{transports_ws_backend.d.ts → connection_registry.d.ts} +120 -132
- package/dist/actions/connection_registry.d.ts.map +1 -0
- package/dist/actions/{transports_ws_backend.js → connection_registry.js} +149 -152
- package/dist/actions/frontend_rpc_client.d.ts +52 -2
- package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
- package/dist/actions/frontend_rpc_client.js +42 -4
- package/dist/actions/peer_ping.d.ts +7 -9
- package/dist/actions/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +6 -8
- package/dist/actions/peer_request.d.ts +6 -5
- package/dist/actions/peer_request.d.ts.map +1 -1
- package/dist/actions/peer_request.js +6 -5
- package/dist/actions/perform_action.d.ts +36 -28
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +60 -34
- package/dist/actions/protocol.d.ts +14 -0
- package/dist/actions/protocol.d.ts.map +1 -1
- package/dist/actions/protocol.js +18 -0
- package/dist/actions/register_action_ws.d.ts +137 -298
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +155 -923
- package/dist/actions/socket.svelte.d.ts +9 -0
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +16 -5
- package/dist/actions/transports.d.ts +88 -34
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +76 -76
- package/dist/actions/transports_http.d.ts +48 -12
- package/dist/actions/transports_http.d.ts.map +1 -1
- package/dist/actions/transports_http.js +75 -44
- package/dist/actions/transports_ws.d.ts +29 -0
- package/dist/actions/transports_ws.d.ts.map +1 -1
- package/dist/actions/transports_ws.js +34 -8
- package/dist/actions/ws_endpoint_spec.d.ts +52 -75
- package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
- package/dist/actions/ws_endpoint_spec.js +27 -10
- package/dist/actions/ws_outbound_writer.d.ts +3 -3
- package/dist/actions/ws_outbound_writer.js +3 -3
- package/dist/actions/ws_socket_session.d.ts +321 -0
- package/dist/actions/ws_socket_session.d.ts.map +1 -0
- package/dist/actions/ws_socket_session.js +783 -0
- package/dist/auth/CLAUDE.md +70 -44
- package/dist/auth/account_action_specs.d.ts +2 -0
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_actions.d.ts +1 -1
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +9 -3
- package/dist/auth/account_queries.d.ts +10 -0
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +27 -17
- package/dist/auth/account_routes.d.ts +2 -1
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +14 -17
- package/dist/auth/account_schema.d.ts +5 -5
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +5 -2
- package/dist/auth/actor_lookup_actions.d.ts +1 -1
- package/dist/auth/actor_lookup_actions.d.ts.map +1 -1
- package/dist/auth/actor_lookup_actions.js +1 -1
- package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
- package/dist/auth/actor_search_action_specs.js +2 -1
- package/dist/auth/actor_search_actions.d.ts +1 -1
- package/dist/auth/actor_search_actions.d.ts.map +1 -1
- package/dist/auth/actor_search_actions.js +1 -1
- package/dist/auth/actor_search_queries.d.ts +5 -5
- package/dist/auth/actor_search_queries.d.ts.map +1 -1
- package/dist/auth/actor_search_queries.js +7 -7
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +3 -1
- package/dist/auth/admin_actions.d.ts +1 -1
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +12 -42
- package/dist/auth/all_cell_actions.d.ts +6 -4
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +1 -1
- package/dist/auth/api_token_queries.d.ts +1 -0
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +1 -0
- package/dist/auth/audit_emitter.d.ts +3 -3
- package/dist/auth/audit_emitter.js +2 -2
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_route_schema.js +3 -2
- package/dist/auth/audit_log_routes.d.ts +20 -11
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +49 -29
- package/dist/auth/audit_log_schema.d.ts +13 -21
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +10 -18
- package/dist/auth/bearer_auth.d.ts +7 -4
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +21 -15
- package/dist/auth/cell_action_helpers.d.ts +89 -0
- package/dist/auth/cell_action_helpers.d.ts.map +1 -0
- package/dist/auth/cell_action_helpers.js +113 -0
- package/dist/auth/cell_actions.d.ts +22 -13
- package/dist/auth/cell_actions.d.ts.map +1 -1
- package/dist/auth/cell_actions.js +105 -167
- package/dist/auth/cell_audit_actions.d.ts +1 -1
- package/dist/auth/cell_audit_actions.d.ts.map +1 -1
- package/dist/auth/cell_audit_actions.js +3 -12
- package/dist/auth/cell_audit_metadata.d.ts +1 -1
- package/dist/auth/cell_audit_metadata.js +1 -1
- package/dist/auth/cell_field_actions.d.ts +1 -1
- package/dist/auth/cell_field_actions.d.ts.map +1 -1
- package/dist/auth/cell_field_actions.js +16 -66
- package/dist/auth/cell_grant_action_specs.d.ts +2 -2
- package/dist/auth/cell_grant_action_specs.js +3 -3
- package/dist/auth/cell_grant_actions.d.ts +73 -11
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +63 -55
- package/dist/auth/cell_grant_audit_metadata.d.ts +6 -3
- package/dist/auth/cell_grant_audit_metadata.d.ts.map +1 -1
- package/dist/auth/cell_grant_audit_metadata.js +7 -4
- package/dist/auth/cell_item_actions.d.ts +1 -1
- package/dist/auth/cell_item_actions.d.ts.map +1 -1
- package/dist/auth/cell_item_actions.js +21 -82
- package/dist/auth/cleanup.d.ts +1 -1
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +6 -3
- package/dist/auth/credential_deadline.d.ts +3 -3
- package/dist/auth/credential_deadline.js +3 -3
- package/dist/auth/credential_type_schema.d.ts +5 -5
- package/dist/auth/credential_type_schema.js +5 -5
- package/dist/auth/daemon_token_middleware.d.ts +12 -6
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +28 -17
- package/dist/auth/deps.d.ts +4 -4
- package/dist/auth/fail_floor.d.ts +55 -0
- package/dist/auth/fail_floor.d.ts.map +1 -0
- package/dist/auth/fail_floor.js +63 -0
- package/dist/auth/invite_queries.d.ts +3 -15
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +3 -21
- package/dist/auth/middleware.d.ts +12 -7
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +42 -29
- package/dist/auth/migrations.d.ts +5 -33
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +9 -16
- package/dist/auth/request_context.d.ts +101 -71
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +137 -140
- package/dist/auth/resolved_auth.d.ts +122 -36
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +89 -38
- package/dist/auth/role_grant_offer_action_specs.d.ts +99 -14
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +26 -13
- package/dist/auth/role_grant_offer_actions.d.ts +13 -7
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +14 -12
- package/dist/auth/role_grant_offer_notifications.d.ts +3 -3
- package/dist/auth/role_grant_offer_notifications.js +1 -1
- package/dist/auth/role_grant_offer_queries.d.ts +0 -5
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +9 -41
- package/dist/auth/role_grant_queries.d.ts +17 -67
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +34 -106
- package/dist/auth/role_grant_sql.d.ts +42 -0
- package/dist/auth/role_grant_sql.d.ts.map +1 -0
- package/dist/auth/role_grant_sql.js +54 -0
- package/dist/auth/scope_kind_schema.d.ts +1 -1
- package/dist/auth/scope_kind_schema.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +1 -1
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +1 -1
- package/dist/auth/session_queries.d.ts +2 -1
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +2 -1
- package/dist/auth/signup_routes.d.ts +2 -1
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +14 -13
- package/dist/auth/standard_rpc_actions.d.ts +1 -1
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/token_scope.d.ts +19 -46
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +23 -41
- package/dist/db/CLAUDE.md +9 -4
- package/dist/db/cell_ddl.d.ts +5 -142
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +17 -16
- package/dist/db/cell_field_queries.d.ts +0 -13
- package/dist/db/cell_field_queries.d.ts.map +1 -1
- package/dist/db/cell_field_queries.js +0 -16
- package/dist/db/cell_grant_queries.d.ts +10 -5
- package/dist/db/cell_grant_queries.d.ts.map +1 -1
- package/dist/db/cell_grant_queries.js +13 -7
- package/dist/db/cell_item_queries.d.ts +0 -7
- package/dist/db/cell_item_queries.d.ts.map +1 -1
- package/dist/db/cell_item_queries.js +0 -10
- package/dist/db/cell_queries.d.ts +12 -48
- package/dist/db/cell_queries.d.ts.map +1 -1
- package/dist/db/cell_queries.js +24 -55
- package/dist/db/cell_view_sql.d.ts +1 -6
- package/dist/db/cell_view_sql.d.ts.map +1 -1
- package/dist/db/cell_view_sql.js +1 -2
- package/dist/db/fact_ddl.d.ts +5 -30
- package/dist/db/fact_ddl.d.ts.map +1 -1
- package/dist/db/fact_ddl.js +14 -13
- package/dist/db/fact_store.d.ts +11 -0
- package/dist/db/fact_store.d.ts.map +1 -1
- package/dist/db/fact_store.js +4 -1
- package/dist/db/migrate.d.ts +44 -6
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +63 -4
- package/dist/dev/setup.d.ts +18 -14
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +42 -39
- package/dist/env/dotenv.d.ts +2 -2
- package/dist/env/dotenv.js +2 -2
- package/dist/env/update_env_variable.d.ts +33 -21
- package/dist/env/update_env_variable.d.ts.map +1 -1
- package/dist/env/update_env_variable.js +54 -35
- package/dist/hono_context.d.ts +15 -90
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +9 -56
- package/dist/http/CLAUDE.md +35 -20
- package/dist/http/auth_shape.d.ts +1 -8
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +6 -12
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +3 -2
- package/dist/http/db_routes.d.ts +3 -3
- package/dist/http/db_routes.js +3 -3
- package/dist/http/error_schemas.d.ts +1 -2
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +1 -2
- package/dist/http/health_schema.d.ts +16 -0
- package/dist/http/health_schema.d.ts.map +1 -0
- package/dist/http/health_schema.js +12 -0
- package/dist/http/jsonrpc_errors.d.ts +22 -2
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +41 -3
- package/dist/http/jsonrpc_helpers.d.ts +60 -17
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +67 -25
- package/dist/http/origin.d.ts +30 -1
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +46 -9
- package/dist/http/origin_wildcard.d.ts +97 -0
- package/dist/http/origin_wildcard.d.ts.map +1 -0
- package/dist/http/origin_wildcard.js +142 -0
- package/dist/http/pending_effects.d.ts +28 -0
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +32 -1
- package/dist/http/route_spec.d.ts +4 -3
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +54 -45
- package/dist/http/surface.d.ts +1 -1
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface_query.d.ts +9 -50
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +48 -94
- package/dist/realtime/audit_log_sse.d.ts +180 -0
- package/dist/realtime/audit_log_sse.d.ts.map +1 -0
- package/dist/realtime/audit_log_sse.js +154 -0
- package/dist/realtime/sse.d.ts +21 -6
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +33 -10
- package/dist/realtime/sse_constants.d.ts +29 -2
- package/dist/realtime/sse_constants.d.ts.map +1 -1
- package/dist/realtime/sse_constants.js +35 -2
- package/dist/realtime/{subscriber_registry.d.ts → sse_registry.d.ts} +12 -12
- package/dist/realtime/sse_registry.d.ts.map +1 -0
- package/dist/realtime/{subscriber_registry.js → sse_registry.js} +4 -4
- package/dist/schema_meta.d.ts +30 -10
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +85 -21
- package/dist/sensitivity.d.ts +9 -3
- package/dist/sensitivity.d.ts.map +1 -1
- package/dist/sensitivity.js +3 -2
- package/dist/server/app_backend.d.ts +8 -5
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +6 -12
- package/dist/server/app_server.d.ts +62 -51
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +84 -71
- package/dist/server/app_server_context.d.ts +1 -1
- package/dist/server/app_server_context.d.ts.map +1 -1
- package/dist/server/env.d.ts +24 -20
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/env.js +24 -34
- package/dist/server/serve_fact_route.d.ts +12 -16
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +59 -34
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +2 -2
- package/dist/testing/CLAUDE.md +179 -158
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +10 -19
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +8 -0
- package/dist/testing/app_server.d.ts +9 -77
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +31 -112
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +3 -4
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +4 -5
- package/dist/testing/auth_apps.d.ts +3 -3
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +9 -6
- package/dist/testing/connection_closer_helpers.d.ts +8 -16
- package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
- package/dist/testing/connection_closer_helpers.js +7 -20
- package/dist/testing/cross_backend/action_manifest.d.ts +15 -4
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +13 -3
- package/dist/testing/cross_backend/action_manifest_parity.d.ts +15 -7
- package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest_parity.js +8 -1
- package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size.js +25 -22
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts +22 -3
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
- package/dist/testing/cross_backend/build_test_backend_paths.js +34 -11
- package/dist/testing/cross_backend/capabilities.d.ts +13 -7
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_grant_role.js +2 -2
- package/dist/testing/cross_backend/cell_grant_steward.d.ts +4 -0
- package/dist/testing/cross_backend/cell_grant_steward.d.ts.map +1 -0
- package/dist/testing/cross_backend/cell_grant_steward.js +120 -0
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.js +21 -0
- package/dist/testing/cross_backend/conformance_table.d.ts +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.d.ts +18 -4
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +29 -9
- package/dist/testing/cross_backend/default_spine_surface.d.ts +7 -7
- package/dist/testing/cross_backend/default_spine_surface.js +2 -2
- package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
- package/dist/testing/cross_backend/fact_serving.js +48 -0
- package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -4
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +9 -2
- package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_scope.js +5 -13
- package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +29 -4
- package/dist/testing/cross_backend/postgres_database.d.ts +32 -0
- package/dist/testing/cross_backend/postgres_database.d.ts.map +1 -1
- package/dist/testing/cross_backend/postgres_database.js +56 -1
- package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
- package/dist/testing/cross_backend/query_shape.js +18 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +23 -1
- package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -2
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +17 -5
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +5 -4
- package/dist/testing/cross_backend/session_cap.d.ts +8 -0
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +66 -2
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +5 -4
- package/dist/testing/cross_backend/spine_suites.d.ts +4 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +21 -0
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +22 -7
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +22 -7
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +4 -3
- package/dist/testing/cross_backend/standard.d.ts +6 -12
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts +8 -0
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts.map +1 -0
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.js +22 -0
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +4 -6
- package/dist/testing/cross_backend/testing_origin_check.d.ts +1 -1
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +10 -5
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +7 -6
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +5 -4
- package/dist/testing/cross_backend/testing_server_core.d.ts +6 -7
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +1 -1
- package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_node.js +13 -2
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +68 -0
- package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +45 -3
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +16 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +11 -8
- package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_action_rate_limit.js +30 -12
- package/dist/testing/cross_backend/ws_connection_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_connection_cap.js +5 -7
- package/dist/testing/cross_backend/ws_endpoint.d.ts +2 -3
- package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_envelope.d.ts +17 -0
- package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -0
- package/dist/testing/cross_backend/ws_envelope.js +172 -0
- package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts +16 -0
- package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_inbound_dispatch.js +8 -4
- package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_outbound_overflow.js +5 -8
- package/dist/testing/cross_backend/ws_role_gated.js +2 -2
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +6 -4
- package/dist/{cli/daemon.d.ts → testing/daemon_info.d.ts} +15 -47
- package/dist/testing/daemon_info.d.ts.map +1 -0
- package/dist/testing/daemon_info.js +108 -0
- package/dist/testing/daemon_token_rotation.js +1 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +3 -4
- package/dist/testing/db.js +2 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +35 -65
- package/dist/testing/integration_helpers.d.ts +0 -15
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +2 -42
- package/dist/testing/middleware.d.ts +20 -12
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +49 -40
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +13 -22
- package/dist/testing/resolved_auth.d.ts +30 -0
- package/dist/testing/resolved_auth.d.ts.map +1 -0
- package/dist/testing/resolved_auth.js +41 -0
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +3 -0
- package/dist/testing/rpc_helpers.d.ts +1 -1
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +2 -1
- package/dist/testing/sse_round_trip.d.ts +5 -4
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +24 -21
- package/dist/testing/test_origin.d.ts +25 -0
- package/dist/testing/test_origin.d.ts.map +1 -0
- package/dist/testing/test_origin.js +28 -0
- package/dist/testing/transports/raw_http.d.ts +54 -0
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +58 -0
- package/dist/testing/transports/ws_raw_client.d.ts +8 -0
- package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
- package/dist/testing/transports/ws_raw_client.js +13 -0
- package/dist/testing/transports/ws_transport.d.ts +15 -2
- package/dist/testing/transports/ws_transport.d.ts.map +1 -1
- package/dist/testing/transports/ws_transport.js +4 -2
- package/dist/testing/ws_round_trip.d.ts +27 -25
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +34 -26
- package/dist/ui/AccountSessions.svelte +48 -19
- package/dist/ui/AccountSessions.svelte.d.ts +2 -17
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAccounts.svelte +6 -1
- package/dist/ui/AdminAuditLog.svelte +61 -22
- package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
- package/dist/ui/AdminInvites.svelte +1 -1
- package/dist/ui/AdminOverview.svelte +76 -37
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/AdminRoleGrantHistory.svelte +6 -1
- package/dist/ui/AdminSessions.svelte +1 -1
- package/dist/ui/AppShell.svelte +3 -2
- package/dist/ui/AppShell.svelte.d.ts +3 -2
- package/dist/ui/AppShell.svelte.d.ts.map +1 -1
- package/dist/ui/CLAUDE.md +121 -35
- package/dist/ui/Datatable.svelte +33 -18
- package/dist/ui/Datatable.svelte.d.ts +2 -14
- package/dist/ui/Datatable.svelte.d.ts.map +1 -1
- package/dist/ui/OpenSignupToggle.svelte +10 -1
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
- package/dist/ui/PopoverButton.svelte +13 -8
- package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferForm.svelte +3 -2
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts +3 -2
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
- package/dist/ui/RoleGrantOfferInbox.svelte +19 -15
- package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
- package/dist/ui/SurfaceExplorer.svelte +66 -27
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +7 -14
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.d.ts +14 -9
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +6 -4
- package/dist/ui/admin_invites_state.svelte.d.ts +2 -2
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.d.ts +9 -9
- package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.js +9 -9
- package/dist/ui/app_settings_state.svelte.d.ts +2 -2
- package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.d.ts +70 -13
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +239 -47
- package/dist/ui/backend_probe.svelte.d.ts +93 -0
- package/dist/ui/backend_probe.svelte.d.ts.map +1 -0
- package/dist/ui/backend_probe.svelte.js +140 -0
- package/dist/ui/format_scope.d.ts +7 -7
- package/dist/ui/format_scope.d.ts.map +1 -1
- package/dist/ui/format_scope.js +4 -4
- package/dist/ui/keyed_async_slot.svelte.d.ts +2 -2
- package/dist/ui/keyed_async_slot.svelte.js +2 -2
- package/dist/ui/popover.svelte.d.ts +18 -19
- package/dist/ui/popover.svelte.d.ts.map +1 -1
- package/dist/ui/popover.svelte.js +103 -16
- package/dist/ui/role_grant_offers_state.svelte.d.ts +41 -46
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/role_grant_offers_state.svelte.js +37 -19
- package/dist/ui/ui_format.d.ts +17 -0
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +20 -0
- package/package.json +9 -8
- package/dist/actions/register_ws_endpoint.d.ts +0 -79
- package/dist/actions/register_ws_endpoint.d.ts.map +0 -1
- package/dist/actions/register_ws_endpoint.js +0 -109
- package/dist/actions/transports_ws_auth_guard.d.ts +0 -96
- package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
- package/dist/actions/transports_ws_auth_guard.js +0 -141
- package/dist/actions/transports_ws_backend.d.ts.map +0 -1
- package/dist/cli/args.d.ts +0 -55
- package/dist/cli/args.d.ts.map +0 -1
- package/dist/cli/args.js +0 -100
- package/dist/cli/config.d.ts +0 -47
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -77
- package/dist/cli/daemon.d.ts.map +0 -1
- package/dist/cli/daemon.js +0 -181
- package/dist/cli/help.d.ts +0 -124
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -215
- package/dist/cli/logger.d.ts +0 -46
- package/dist/cli/logger.d.ts.map +0 -1
- package/dist/cli/logger.js +0 -48
- package/dist/cli/util.d.ts +0 -36
- package/dist/cli/util.d.ts.map +0 -1
- package/dist/cli/util.js +0 -50
- package/dist/realtime/sse_auth_guard.d.ts +0 -197
- package/dist/realtime/sse_auth_guard.d.ts.map +0 -1
- package/dist/realtime/sse_auth_guard.js +0 -239
- package/dist/realtime/subscriber_registry.d.ts.map +0 -1
- package/dist/testing/bootstrap_success.d.ts +0 -29
- package/dist/testing/bootstrap_success.d.ts.map +0 -1
- package/dist/testing/bootstrap_success.js +0 -144
- package/dist/testing/mock_fs.d.ts +0 -20
- package/dist/testing/mock_fs.d.ts.map +0 -1
- package/dist/testing/mock_fs.js +0 -28
- package/dist/testing/standard.d.ts +0 -122
- package/dist/testing/standard.d.ts.map +0 -1
- package/dist/testing/standard.js +0 -73
- package/dist/testing/testing_rate_limiter.d.ts +0 -65
- package/dist/testing/testing_rate_limiter.d.ts.map +0 -1
- package/dist/testing/testing_rate_limiter.js +0 -80
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Usable in tests, the adversarial auth runner, and future surface explorer UI.
|
|
5
5
|
* Replaces duplicated inline `.filter()` patterns.
|
|
6
6
|
*
|
|
7
|
-
* Categorical filters (`
|
|
8
|
-
* `
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Categorical filters (`filter_role_routes`, `filter_keeper_routes`,
|
|
8
|
+
* `filter_credential_gated_routes`) and `surface_auth_summary` group the
|
|
9
|
+
* flat-record `RouteAuth` shape into categorical buckets for adversarial test
|
|
10
|
+
* runners and the surface explorer. The buckets are
|
|
11
11
|
* derived views over the authority axes (`account`, `actor`, `roles`,
|
|
12
12
|
* `credential_types`) — see `http/auth_shape.ts` for the canonical shape.
|
|
13
13
|
*
|
|
@@ -20,11 +20,6 @@ export const filter_protected_routes = (surface) => surface.routes.filter((r) =>
|
|
|
20
20
|
export const filter_public_routes = (surface) => surface.routes.filter((r) => is_public_auth(r.auth));
|
|
21
21
|
/** Filter all role-guarded routes (any role declared on `auth.roles`). */
|
|
22
22
|
export const filter_role_routes = (surface) => surface.routes.filter((r) => is_role_auth(r.auth));
|
|
23
|
-
/**
|
|
24
|
-
* Filter routes that require basic authentication only — `account === 'required'`
|
|
25
|
-
* with no role / credential gate.
|
|
26
|
-
*/
|
|
27
|
-
export const filter_authenticated_routes = (surface) => surface.routes.filter((r) => is_plain_authenticated_auth(r.auth));
|
|
28
23
|
/** Filter routes that require keeper credentials (`daemon_token`). */
|
|
29
24
|
export const filter_keeper_routes = (surface) => surface.routes.filter((r) => is_keeper_auth(r.auth));
|
|
30
25
|
/**
|
|
@@ -38,74 +33,37 @@ export const filter_keeper_routes = (surface) => surface.routes.filter((r) => is
|
|
|
38
33
|
* in it answers `credential_type_required` to a channel it does not admit.
|
|
39
34
|
*/
|
|
40
35
|
export const filter_credential_gated_routes = (surface) => surface.routes.filter((r) => is_credential_gated_auth(r.auth));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
group.push(r);
|
|
56
|
-
};
|
|
57
|
-
for (const r of surface.routes) {
|
|
58
|
-
const auth = r.auth;
|
|
59
|
-
if (is_public_auth(auth)) {
|
|
60
|
-
push('none', r);
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
if (is_keeper_auth(auth)) {
|
|
64
|
-
push('keeper', r);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (is_role_auth(auth)) {
|
|
68
|
-
for (const role of auth.roles)
|
|
69
|
-
push(`role:${role}`, r);
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (is_credential_gated_auth(auth)) {
|
|
73
|
-
for (const credential_type of auth.credential_types)
|
|
74
|
-
push(`credential:${credential_type}`, r);
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (is_plain_authenticated_auth(auth)) {
|
|
78
|
-
push('authenticated', r);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
if (auth.account === 'optional' || auth.actor === 'optional') {
|
|
82
|
-
push('optional', r);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
push('other', r);
|
|
86
|
-
}
|
|
87
|
-
return groups;
|
|
36
|
+
const categorize_route_auth = (auth) => {
|
|
37
|
+
if (is_public_auth(auth))
|
|
38
|
+
return { kind: 'none' };
|
|
39
|
+
if (is_keeper_auth(auth))
|
|
40
|
+
return { kind: 'keeper' };
|
|
41
|
+
if (is_role_auth(auth))
|
|
42
|
+
return { kind: 'role', names: auth.roles };
|
|
43
|
+
if (is_credential_gated_auth(auth))
|
|
44
|
+
return { kind: 'credential', names: auth.credential_types };
|
|
45
|
+
if (is_plain_authenticated_auth(auth))
|
|
46
|
+
return { kind: 'authenticated' };
|
|
47
|
+
if (auth.account === 'optional' || auth.actor === 'optional')
|
|
48
|
+
return { kind: 'optional' };
|
|
49
|
+
return { kind: 'other' };
|
|
88
50
|
};
|
|
89
|
-
/** Filter routes whose path starts with `prefix`. */
|
|
90
|
-
export const filter_routes_by_prefix = (surface, prefix) => surface.routes.filter((r) => r.path.startsWith(prefix));
|
|
91
51
|
/** Filter routes that have a non-null input schema. */
|
|
92
52
|
export const filter_routes_with_input = (surface) => surface.routes.filter((r) => r.input_schema !== null);
|
|
93
53
|
/** Filter routes that have a non-null params schema. */
|
|
94
54
|
export const filter_routes_with_params = (surface) => surface.routes.filter((r) => r.params_schema !== null);
|
|
95
55
|
/** Filter routes that have a non-null query schema. */
|
|
96
56
|
export const filter_routes_with_query = (surface) => surface.routes.filter((r) => r.query_schema !== null);
|
|
97
|
-
/** Filter routes that are mutations (POST, PUT, DELETE, PATCH). */
|
|
98
|
-
export const filter_mutation_routes = (surface) => surface.routes.filter((r) => r.is_mutation);
|
|
99
|
-
/** Filter routes that declare rate limiting. */
|
|
100
|
-
export const filter_rate_limited_routes = (surface) => surface.routes.filter((r) => r.rate_limit_key !== null);
|
|
101
57
|
/** Format a route as `'METHOD /path'` (e.g. `'GET /health'`). */
|
|
102
58
|
export const format_route_key = (route) => `${route.method} ${route.path}`;
|
|
103
59
|
/**
|
|
104
60
|
* Summarize route auth distribution across the surface.
|
|
105
61
|
*
|
|
106
|
-
* Categorical view over the flat auth record
|
|
107
|
-
* `
|
|
108
|
-
*
|
|
62
|
+
* Categorical view over the flat auth record — `none`, `keeper`, `role` and
|
|
63
|
+
* `credential` (counted per name), `authenticated`, `optional`, `other`.
|
|
64
|
+
* Keeper outranks a role, and a role outranks a channel gate, so the audit
|
|
65
|
+
* SSE stream (admin role, session channel) counts under `role`. Multi-role
|
|
66
|
+
* and multi-channel specs contribute one count per role / channel they admit.
|
|
109
67
|
*
|
|
110
68
|
* @returns counts by auth category, with role and channel counts broken out
|
|
111
69
|
* by name
|
|
@@ -119,36 +77,32 @@ export const surface_auth_summary = (surface) => {
|
|
|
119
77
|
let keeper = 0;
|
|
120
78
|
let other = 0;
|
|
121
79
|
for (const r of surface.routes) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
none
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (auth.account === 'optional' || auth.actor === 'optional') {
|
|
148
|
-
optional++;
|
|
149
|
-
continue;
|
|
80
|
+
const bucket = categorize_route_auth(r.auth);
|
|
81
|
+
switch (bucket.kind) {
|
|
82
|
+
case 'none':
|
|
83
|
+
none++;
|
|
84
|
+
break;
|
|
85
|
+
case 'keeper':
|
|
86
|
+
keeper++;
|
|
87
|
+
break;
|
|
88
|
+
case 'authenticated':
|
|
89
|
+
authenticated++;
|
|
90
|
+
break;
|
|
91
|
+
case 'optional':
|
|
92
|
+
optional++;
|
|
93
|
+
break;
|
|
94
|
+
case 'other':
|
|
95
|
+
other++;
|
|
96
|
+
break;
|
|
97
|
+
case 'role':
|
|
98
|
+
for (const name of bucket.names)
|
|
99
|
+
role.set(name, (role.get(name) ?? 0) + 1);
|
|
100
|
+
break;
|
|
101
|
+
case 'credential':
|
|
102
|
+
for (const name of bucket.names)
|
|
103
|
+
credential.set(name, (credential.get(name) ?? 0) + 1);
|
|
104
|
+
break;
|
|
150
105
|
}
|
|
151
|
-
other++;
|
|
152
106
|
}
|
|
153
107
|
return { none, authenticated, optional, role, credential, keeper, other };
|
|
154
108
|
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The audit log SSE stream's registry, its connection closer, and the
|
|
3
|
+
* convenience factory that wires them.
|
|
4
|
+
*
|
|
5
|
+
* An SSE stream is authorized once, at open, and then only emits — nothing
|
|
6
|
+
* re-reads its credential or its role. `create_sse_connection_closer` adapts a
|
|
7
|
+
* `SseRegistry` to `ConnectionCloser`, and a registry added to the
|
|
8
|
+
* backend's `deps.connection_closer` is closed by every revocation: the
|
|
9
|
+
* handlers' own post-commit closes (`queue_connection_close`), and the one
|
|
10
|
+
* audit listener on that closer (`create_revocation_guard`), which is also the
|
|
11
|
+
* only closer for a role revocation.
|
|
12
|
+
*
|
|
13
|
+
* `create_audit_log_sse` builds the registry and its broadcaster and adds the
|
|
14
|
+
* registry to the closer — making the secure path the easy path for consumers.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
19
|
+
import { type AuditLogEvent } from '../auth/audit_log_schema.js';
|
|
20
|
+
import type { ConnectionCloser, RealtimeCloser } from '../actions/connection_closer.js';
|
|
21
|
+
import { SseRegistry } from './sse_registry.js';
|
|
22
|
+
import type { SseNotification, EventSpec } from './sse.js';
|
|
23
|
+
/** SSE channel the audit-log stream route publishes on. */
|
|
24
|
+
export declare const AUDIT_LOG_CHANNEL = "audit_log";
|
|
25
|
+
/**
|
|
26
|
+
* Adapt an `SseRegistry` to `ConnectionCloser`, so a revocation handler's
|
|
27
|
+
* close reaches its streams.
|
|
28
|
+
*
|
|
29
|
+
* `close_connections` is `SseRegistry.close_by_identity` on the id its
|
|
30
|
+
* target carries, so it closes the streams registered under that id as their
|
|
31
|
+
* `scope` or in their `groups` — pending registrations included. The audit
|
|
32
|
+
* stream route registers `scope = session hash` and `groups = [account id]`; a
|
|
33
|
+
* route that admits bearer tokens registers the API token id too, and a
|
|
34
|
+
* `token` target then reaches it. A `role` target closes the account's
|
|
35
|
+
* streams when its `role` is the one the registry's streams are gated on — the
|
|
36
|
+
* registry keeps one gating role for all its streams, not one per stream.
|
|
37
|
+
* `close_all_connections` is `SseRegistry.close_all` — every stream,
|
|
38
|
+
* for shutdown.
|
|
39
|
+
*
|
|
40
|
+
* Twin of the Rust spine's `ConnectionCloser` impl on `SseRegistry`.
|
|
41
|
+
*
|
|
42
|
+
* @param registry - the registry to close streams on
|
|
43
|
+
* @param required_role - the role every stream of `registry` was gated on,
|
|
44
|
+
* or `null` when they are not role-gated (a `role` target then closes
|
|
45
|
+
* nothing)
|
|
46
|
+
*/
|
|
47
|
+
export declare const create_sse_connection_closer: <T>(registry: SseRegistry<T>, required_role: string | null) => ConnectionCloser;
|
|
48
|
+
/**
|
|
49
|
+
* Convenience factory result for audit log SSE.
|
|
50
|
+
*
|
|
51
|
+
* Satisfies `AuditLogRouteOptions['stream']` and provides the `on_audit_event`
|
|
52
|
+
* callback that broadcasts each row to the stream.
|
|
53
|
+
*/
|
|
54
|
+
export interface AuditLogSse {
|
|
55
|
+
/**
|
|
56
|
+
* The SSE registry the audit stream route registers each stream on
|
|
57
|
+
* (two-phase: `subscribe_pending` then `admit`) — pass as part of the
|
|
58
|
+
* `stream` option to `create_audit_log_route_specs`. Also exposed for
|
|
59
|
+
* subscriber count monitoring.
|
|
60
|
+
*/
|
|
61
|
+
registry: SseRegistry<SseNotification>;
|
|
62
|
+
/** Logger — pass as part of `stream` option to `create_audit_log_route_specs`. */
|
|
63
|
+
log: Logger;
|
|
64
|
+
/**
|
|
65
|
+
* Broadcasts each audit row to the stream's subscribers. Wired by
|
|
66
|
+
* `create_app_server`'s `audit_log_sse` option, or compose inside the
|
|
67
|
+
* consumer's `audit_factory` body. Closes nothing: revocations reach the
|
|
68
|
+
* streams through the registry's membership in the backend's closer.
|
|
69
|
+
*/
|
|
70
|
+
on_audit_event: (event: AuditLogEvent) => void;
|
|
71
|
+
/**
|
|
72
|
+
* The role the stream requires — what a caller adapting `registry` passes
|
|
73
|
+
* `create_sse_connection_closer`, so a role revocation closes its streams.
|
|
74
|
+
*/
|
|
75
|
+
required_role: string;
|
|
76
|
+
/**
|
|
77
|
+
* Each stream's keep-alive interval, read by the audit stream route
|
|
78
|
+
* (`AuditLogRouteOptions['stream']`); `undefined` keeps the default.
|
|
79
|
+
*/
|
|
80
|
+
keep_alive_ms?: number | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* SSE event specs for audit log events.
|
|
84
|
+
*
|
|
85
|
+
* One spec per `AUDIT_EVENT_TYPES` entry, all sharing the `AuditLogEventJson` params schema.
|
|
86
|
+
* Pass to `create_app_server`'s `event_specs` for surface generation and DEV validation.
|
|
87
|
+
*/
|
|
88
|
+
export declare const audit_log_event_specs: Array<EventSpec>;
|
|
89
|
+
/**
|
|
90
|
+
* Default max concurrent SSE subscribers per session scope for the audit log.
|
|
91
|
+
*
|
|
92
|
+
* The audit log SSE subscribes with `scope = session_hash` and
|
|
93
|
+
* `groups = [account_id]`. Only `scope` is capped — so this limits tabs
|
|
94
|
+
* per session. An account's total streams across all sessions is bounded
|
|
95
|
+
* transitively by `max_sessions × AUDIT_LOG_SSE_MAX_PER_SCOPE`. 10 tabs
|
|
96
|
+
* per session is a comfortable ceiling for normal use; consumers raising
|
|
97
|
+
* it above ~50 should consider server-side connection limits.
|
|
98
|
+
*/
|
|
99
|
+
export declare const AUDIT_LOG_SSE_MAX_PER_SCOPE = 10;
|
|
100
|
+
/**
|
|
101
|
+
* Create a complete audit log SSE setup: the registry, its broadcaster, and its
|
|
102
|
+
* connection closer.
|
|
103
|
+
*
|
|
104
|
+
* Builds the `SseRegistry` and the broadcast callback, and adds the
|
|
105
|
+
* registry to `connection_closer` for good — the remover `add` returns is
|
|
106
|
+
* dropped, so a caller that must take the registry out again passes `null` and
|
|
107
|
+
* adds it itself. Revocations close the streams through that closer: the
|
|
108
|
+
* handlers' post-commit closes, and the `create_revocation_guard` listener on
|
|
109
|
+
* it (which `create_app_server` registers; a hand wiring registers its own).
|
|
110
|
+
* The result satisfies `AuditLogRouteOptions['stream']`
|
|
111
|
+
* and provides the `on_audit_event` listener for the audit emitter.
|
|
112
|
+
*
|
|
113
|
+
* Most consumers pass `audit_log_sse: true` to `create_app_server` and never
|
|
114
|
+
* touch this directly — the factory builds an `AuditLogSse`, registers
|
|
115
|
+
* `audit_sse.on_audit_event` via `backend.deps.audit.add_listener`, and
|
|
116
|
+
* exposes it via `AppServerContext.audit_sse`. Reach for the manual path
|
|
117
|
+
* (compose inside `audit_factory` body, or
|
|
118
|
+
* `audit.add_listener(audit_sse.on_audit_event)` post-assembly) only
|
|
119
|
+
* when wiring outside `create_app_server`.
|
|
120
|
+
*
|
|
121
|
+
* @param options - factory options
|
|
122
|
+
* @returns audit log SSE setup (stream options + `on_audit_event` + registry)
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* const connection_closer = create_realtime_closer();
|
|
127
|
+
* const audit_sse = create_audit_log_sse({log, connection_closer});
|
|
128
|
+
*
|
|
129
|
+
* // On CreateAppBackendOptions — the same closer, and the listeners inside
|
|
130
|
+
* // the audit_factory body:
|
|
131
|
+
* connection_closer,
|
|
132
|
+
* audit_factory: ({db, log}) => {
|
|
133
|
+
* const guard = create_revocation_guard(connection_closer, log);
|
|
134
|
+
* return create_audit_emitter({
|
|
135
|
+
* db,
|
|
136
|
+
* log,
|
|
137
|
+
* on_audit_event: (event) => {
|
|
138
|
+
* audit_sse.on_audit_event(event);
|
|
139
|
+
* guard(event);
|
|
140
|
+
* },
|
|
141
|
+
* });
|
|
142
|
+
* },
|
|
143
|
+
*
|
|
144
|
+
* // In create_route_specs:
|
|
145
|
+
* create_audit_log_route_specs({stream: audit_sse});
|
|
146
|
+
*
|
|
147
|
+
* // In create_app_server options:
|
|
148
|
+
* event_specs: audit_log_event_specs,
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare const create_audit_log_sse: (options: {
|
|
152
|
+
/** Role required to access the SSE endpoint. Default `'admin'`. */
|
|
153
|
+
role?: string;
|
|
154
|
+
log: Logger;
|
|
155
|
+
/**
|
|
156
|
+
* The backend's closer — `deps.connection_closer`. The new registry is
|
|
157
|
+
* added to it, so every revocation handler's close reaches these streams.
|
|
158
|
+
* Required so it can't be forgotten: without it no revocation closes these
|
|
159
|
+
* streams — neither the handlers' closes nor the revocation guard, which
|
|
160
|
+
* closes through the same closer. Pass `null` only for a registry no
|
|
161
|
+
* revocation has to reach (tests of the registry itself), or when the
|
|
162
|
+
* caller adds `create_sse_connection_closer(registry, required_role)` itself — as
|
|
163
|
+
* `create_app_server` does, to hold the remover `add` returns.
|
|
164
|
+
*/
|
|
165
|
+
connection_closer: RealtimeCloser | null;
|
|
166
|
+
/**
|
|
167
|
+
* Max concurrent SSE subscribers per session scope. On overflow, the oldest
|
|
168
|
+
* matching subscriber is closed. Default `AUDIT_LOG_SSE_MAX_PER_SCOPE`.
|
|
169
|
+
* Pass `null` to disable the cap.
|
|
170
|
+
*/
|
|
171
|
+
max_per_scope?: number | null;
|
|
172
|
+
/**
|
|
173
|
+
* Each stream's keep-alive interval (`SseResponseOptions.keep_alive_ms`), in
|
|
174
|
+
* ms; `null` turns keep-alives off. A test server shortens it.
|
|
175
|
+
*
|
|
176
|
+
* @default SSE_KEEP_ALIVE_INTERVAL_MS
|
|
177
|
+
*/
|
|
178
|
+
keep_alive_ms?: number | null;
|
|
179
|
+
}) => AuditLogSse;
|
|
180
|
+
//# sourceMappingURL=audit_log_sse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit_log_sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/audit_log_sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAGN,KAAK,aAAa,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG3D,2DAA2D;AAC3D,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,4BAA4B,GAAI,CAAC,EAC7C,UAAU,WAAW,CAAC,CAAC,CAAC,EACxB,eAAe,MAAM,GAAG,IAAI,KAC1B,gBAkBD,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;;;;OAKG;IACH,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IACvC,kFAAkF;IAClF,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,SAAS,CAOlD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS;IAC7C,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;;OASG;IACH,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAAC;IACzC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,KAAG,WAiBH,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The audit log SSE stream's registry, its connection closer, and the
|
|
3
|
+
* convenience factory that wires them.
|
|
4
|
+
*
|
|
5
|
+
* An SSE stream is authorized once, at open, and then only emits — nothing
|
|
6
|
+
* re-reads its credential or its role. `create_sse_connection_closer` adapts a
|
|
7
|
+
* `SseRegistry` to `ConnectionCloser`, and a registry added to the
|
|
8
|
+
* backend's `deps.connection_closer` is closed by every revocation: the
|
|
9
|
+
* handlers' own post-commit closes (`queue_connection_close`), and the one
|
|
10
|
+
* audit listener on that closer (`create_revocation_guard`), which is also the
|
|
11
|
+
* only closer for a role revocation.
|
|
12
|
+
*
|
|
13
|
+
* `create_audit_log_sse` builds the registry and its broadcaster and adds the
|
|
14
|
+
* registry to the closer — making the secure path the easy path for consumers.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import { UnreachableError } from '@fuzdev/fuz_util/error.ts';
|
|
19
|
+
import { AUDIT_EVENT_TYPES, AuditLogEventJson } from '../auth/audit_log_schema.js';
|
|
20
|
+
import { SseRegistry } from './sse_registry.js';
|
|
21
|
+
import { validate_sse_keep_alive_ms } from './sse_constants.js';
|
|
22
|
+
/** SSE channel the audit-log stream route publishes on. */
|
|
23
|
+
export const AUDIT_LOG_CHANNEL = 'audit_log';
|
|
24
|
+
/**
|
|
25
|
+
* Adapt an `SseRegistry` to `ConnectionCloser`, so a revocation handler's
|
|
26
|
+
* close reaches its streams.
|
|
27
|
+
*
|
|
28
|
+
* `close_connections` is `SseRegistry.close_by_identity` on the id its
|
|
29
|
+
* target carries, so it closes the streams registered under that id as their
|
|
30
|
+
* `scope` or in their `groups` — pending registrations included. The audit
|
|
31
|
+
* stream route registers `scope = session hash` and `groups = [account id]`; a
|
|
32
|
+
* route that admits bearer tokens registers the API token id too, and a
|
|
33
|
+
* `token` target then reaches it. A `role` target closes the account's
|
|
34
|
+
* streams when its `role` is the one the registry's streams are gated on — the
|
|
35
|
+
* registry keeps one gating role for all its streams, not one per stream.
|
|
36
|
+
* `close_all_connections` is `SseRegistry.close_all` — every stream,
|
|
37
|
+
* for shutdown.
|
|
38
|
+
*
|
|
39
|
+
* Twin of the Rust spine's `ConnectionCloser` impl on `SseRegistry`.
|
|
40
|
+
*
|
|
41
|
+
* @param registry - the registry to close streams on
|
|
42
|
+
* @param required_role - the role every stream of `registry` was gated on,
|
|
43
|
+
* or `null` when they are not role-gated (a `role` target then closes
|
|
44
|
+
* nothing)
|
|
45
|
+
*/
|
|
46
|
+
export const create_sse_connection_closer = (registry, required_role) => ({
|
|
47
|
+
close_connections: (target) => {
|
|
48
|
+
switch (target.kind) {
|
|
49
|
+
case 'session':
|
|
50
|
+
return registry.close_by_identity(target.session_hash);
|
|
51
|
+
case 'token':
|
|
52
|
+
return registry.close_by_identity(target.api_token_id);
|
|
53
|
+
case 'account':
|
|
54
|
+
return registry.close_by_identity(target.account_id);
|
|
55
|
+
case 'role':
|
|
56
|
+
return required_role !== null && target.role === required_role
|
|
57
|
+
? registry.close_by_identity(target.account_id)
|
|
58
|
+
: 0;
|
|
59
|
+
default:
|
|
60
|
+
throw new UnreachableError(target);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
close_all_connections: () => registry.close_all()
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* SSE event specs for audit log events.
|
|
67
|
+
*
|
|
68
|
+
* One spec per `AUDIT_EVENT_TYPES` entry, all sharing the `AuditLogEventJson` params schema.
|
|
69
|
+
* Pass to `create_app_server`'s `event_specs` for surface generation and DEV validation.
|
|
70
|
+
*/
|
|
71
|
+
export const audit_log_event_specs = AUDIT_EVENT_TYPES.map((event_type) => ({
|
|
72
|
+
method: event_type,
|
|
73
|
+
params: AuditLogEventJson,
|
|
74
|
+
description: `Audit log: ${event_type.replaceAll('_', ' ')}`,
|
|
75
|
+
channel: AUDIT_LOG_CHANNEL
|
|
76
|
+
}));
|
|
77
|
+
/**
|
|
78
|
+
* Default max concurrent SSE subscribers per session scope for the audit log.
|
|
79
|
+
*
|
|
80
|
+
* The audit log SSE subscribes with `scope = session_hash` and
|
|
81
|
+
* `groups = [account_id]`. Only `scope` is capped — so this limits tabs
|
|
82
|
+
* per session. An account's total streams across all sessions is bounded
|
|
83
|
+
* transitively by `max_sessions × AUDIT_LOG_SSE_MAX_PER_SCOPE`. 10 tabs
|
|
84
|
+
* per session is a comfortable ceiling for normal use; consumers raising
|
|
85
|
+
* it above ~50 should consider server-side connection limits.
|
|
86
|
+
*/
|
|
87
|
+
export const AUDIT_LOG_SSE_MAX_PER_SCOPE = 10;
|
|
88
|
+
/**
|
|
89
|
+
* Create a complete audit log SSE setup: the registry, its broadcaster, and its
|
|
90
|
+
* connection closer.
|
|
91
|
+
*
|
|
92
|
+
* Builds the `SseRegistry` and the broadcast callback, and adds the
|
|
93
|
+
* registry to `connection_closer` for good — the remover `add` returns is
|
|
94
|
+
* dropped, so a caller that must take the registry out again passes `null` and
|
|
95
|
+
* adds it itself. Revocations close the streams through that closer: the
|
|
96
|
+
* handlers' post-commit closes, and the `create_revocation_guard` listener on
|
|
97
|
+
* it (which `create_app_server` registers; a hand wiring registers its own).
|
|
98
|
+
* The result satisfies `AuditLogRouteOptions['stream']`
|
|
99
|
+
* and provides the `on_audit_event` listener for the audit emitter.
|
|
100
|
+
*
|
|
101
|
+
* Most consumers pass `audit_log_sse: true` to `create_app_server` and never
|
|
102
|
+
* touch this directly — the factory builds an `AuditLogSse`, registers
|
|
103
|
+
* `audit_sse.on_audit_event` via `backend.deps.audit.add_listener`, and
|
|
104
|
+
* exposes it via `AppServerContext.audit_sse`. Reach for the manual path
|
|
105
|
+
* (compose inside `audit_factory` body, or
|
|
106
|
+
* `audit.add_listener(audit_sse.on_audit_event)` post-assembly) only
|
|
107
|
+
* when wiring outside `create_app_server`.
|
|
108
|
+
*
|
|
109
|
+
* @param options - factory options
|
|
110
|
+
* @returns audit log SSE setup (stream options + `on_audit_event` + registry)
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const connection_closer = create_realtime_closer();
|
|
115
|
+
* const audit_sse = create_audit_log_sse({log, connection_closer});
|
|
116
|
+
*
|
|
117
|
+
* // On CreateAppBackendOptions — the same closer, and the listeners inside
|
|
118
|
+
* // the audit_factory body:
|
|
119
|
+
* connection_closer,
|
|
120
|
+
* audit_factory: ({db, log}) => {
|
|
121
|
+
* const guard = create_revocation_guard(connection_closer, log);
|
|
122
|
+
* return create_audit_emitter({
|
|
123
|
+
* db,
|
|
124
|
+
* log,
|
|
125
|
+
* on_audit_event: (event) => {
|
|
126
|
+
* audit_sse.on_audit_event(event);
|
|
127
|
+
* guard(event);
|
|
128
|
+
* },
|
|
129
|
+
* });
|
|
130
|
+
* },
|
|
131
|
+
*
|
|
132
|
+
* // In create_route_specs:
|
|
133
|
+
* create_audit_log_route_specs({stream: audit_sse});
|
|
134
|
+
*
|
|
135
|
+
* // In create_app_server options:
|
|
136
|
+
* event_specs: audit_log_event_specs,
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export const create_audit_log_sse = (options) => {
|
|
140
|
+
validate_sse_keep_alive_ms(options.keep_alive_ms);
|
|
141
|
+
const role = options.role ?? 'admin';
|
|
142
|
+
const max_per_scope = options.max_per_scope === undefined ? AUDIT_LOG_SSE_MAX_PER_SCOPE : options.max_per_scope;
|
|
143
|
+
const registry = new SseRegistry({ max_per_scope, log: options.log });
|
|
144
|
+
options.connection_closer?.add(create_sse_connection_closer(registry, role));
|
|
145
|
+
return {
|
|
146
|
+
log: options.log,
|
|
147
|
+
required_role: role,
|
|
148
|
+
keep_alive_ms: options.keep_alive_ms,
|
|
149
|
+
on_audit_event: (event) => {
|
|
150
|
+
registry.broadcast(AUDIT_LOG_CHANNEL, { method: event.event_type, params: event });
|
|
151
|
+
},
|
|
152
|
+
registry
|
|
153
|
+
};
|
|
154
|
+
};
|
package/dist/realtime/sse.d.ts
CHANGED
|
@@ -20,6 +20,14 @@
|
|
|
20
20
|
* between. The twin of the Rust spine's `fuz_realtime` SSE bound — the same
|
|
21
21
|
* budget and charge.
|
|
22
22
|
*
|
|
23
|
+
* ## Keep-alive
|
|
24
|
+
*
|
|
25
|
+
* Every `SSE_KEEP_ALIVE_INTERVAL_MS` an open stream writes
|
|
26
|
+
* `SSE_KEEP_ALIVE_COMMENT`, so a proxy's idle read timeout never cuts a quiet
|
|
27
|
+
* stream. The comment is a frame like any other — held to the same budget, so
|
|
28
|
+
* a client that stopped reading ends its stream on a keep-alive as on data —
|
|
29
|
+
* and the timer stops when the stream closes. `keep_alive_ms: null` turns it off.
|
|
30
|
+
*
|
|
23
31
|
* @module
|
|
24
32
|
*/
|
|
25
33
|
import type { Context } from 'hono';
|
|
@@ -37,8 +45,6 @@ export interface SseStream<T = unknown> {
|
|
|
37
45
|
* "Outbound bound").
|
|
38
46
|
*/
|
|
39
47
|
send: (data: T) => void;
|
|
40
|
-
/** Send a comment (for keep-alive pings). */
|
|
41
|
-
comment: (text: string) => void;
|
|
42
48
|
/** Close the stream. */
|
|
43
49
|
close: () => void;
|
|
44
50
|
/**
|
|
@@ -67,12 +73,19 @@ export interface SseResponseOptions {
|
|
|
67
73
|
* stream ends on its outbound budget.
|
|
68
74
|
*/
|
|
69
75
|
account_id?: string | null;
|
|
76
|
+
/**
|
|
77
|
+
* How often the stream writes `SSE_KEEP_ALIVE_COMMENT`, in ms; `null` writes
|
|
78
|
+
* none. Checked by `validate_sse_keep_alive_ms`.
|
|
79
|
+
*
|
|
80
|
+
* @default SSE_KEEP_ALIVE_INTERVAL_MS
|
|
81
|
+
*/
|
|
82
|
+
keep_alive_ms?: number | null;
|
|
70
83
|
}
|
|
71
84
|
/**
|
|
72
85
|
* Create an SSE response for a Hono context.
|
|
73
86
|
*
|
|
74
87
|
* Wraps Hono's `streamSSE` to provide a `{response, stream}` API
|
|
75
|
-
* compatible with `
|
|
88
|
+
* compatible with `SseRegistry` push-based broadcasting.
|
|
76
89
|
* The callback suspends via a promise that resolves on client disconnect
|
|
77
90
|
* or explicit `close()`, keeping the stream alive for external sends.
|
|
78
91
|
*
|
|
@@ -81,7 +94,7 @@ export interface SseResponseOptions {
|
|
|
81
94
|
* cancelling the body. A client already gone when this is called yields a
|
|
82
95
|
* stream that is already closed, so register cleanup with `on_close` (which
|
|
83
96
|
* runs a late listener at once) before handing the stream anywhere that would
|
|
84
|
-
* count it — `
|
|
97
|
+
* count it — `SseRegistry.admit` after `on_close(pending.unsubscribe)`
|
|
85
98
|
* refuses it.
|
|
86
99
|
*
|
|
87
100
|
* Uses `hono_stream.write()` directly (not `writeSSE`) to avoid
|
|
@@ -92,8 +105,10 @@ export interface SseResponseOptions {
|
|
|
92
105
|
*
|
|
93
106
|
* @param log - logger for serialization and `on_close` listener errors, and
|
|
94
107
|
* for the warning when the stream ends on its outbound budget
|
|
95
|
-
* @param options - what the overflow warning names
|
|
108
|
+
* @param options - what the overflow warning names, and the keep-alive interval
|
|
96
109
|
* @returns object with the streaming `Response` and an `SseStream` controller
|
|
110
|
+
* @throws Error when `options.keep_alive_ms` is out of range
|
|
111
|
+
* (`validate_sse_keep_alive_ms`)
|
|
97
112
|
*/
|
|
98
113
|
export declare const create_sse_response: <T = unknown>(c: Context, log: Logger, options?: SseResponseOptions) => {
|
|
99
114
|
response: Response;
|
|
@@ -116,7 +131,7 @@ export interface EventSpec {
|
|
|
116
131
|
* In DEV: warns on unknown methods and invalid params.
|
|
117
132
|
* In production: passes through with zero overhead.
|
|
118
133
|
*
|
|
119
|
-
* @param broadcaster - duck-typed broadcaster (e.g. `
|
|
134
|
+
* @param broadcaster - duck-typed broadcaster (e.g. `SseRegistry`)
|
|
120
135
|
* @param event_specs - event specs to validate against
|
|
121
136
|
* @param log - logger used to emit DEV warnings on unknown methods or param mismatches
|
|
122
137
|
* @returns validated broadcaster wrapper (passthrough in production)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAYtD;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACrC;;;;OAIG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IACxB,wBAAwB;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC/B,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,yCAAyC;AACzC,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AA8DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,GAAG,OAAO,EAC9C,GAAG,OAAO,EACV,KAAK,MAAM,EACX,UAAU,kBAAkB,KAC1B;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;CAsG5C,CAAC;AAEF,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACzB,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC;IAClB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,GAAI,CAAC,SAAS,eAAe,EACrE,aAAa;IAAE,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAAE,EAC9D,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,KAAK,MAAM,KACT;IAAE,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAmBjD,CAAC"}
|