@fuzdev/fuz_app 0.180.0 → 0.181.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +14 -14
- package/dist/actions/action_rpc.d.ts +14 -5
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +53 -46
- package/dist/actions/action_types.d.ts +15 -12
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/perform_action.d.ts +4 -4
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +6 -6
- package/dist/actions/register_action_ws.d.ts +6 -2
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +14 -3
- package/dist/actions/ws_socket_session.js +1 -1
- package/dist/auth/CLAUDE.md +36 -30
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +18 -1
- package/dist/auth/account_queries.d.ts +69 -0
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +82 -0
- package/dist/auth/account_route_schema.d.ts +26 -16
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +10 -24
- package/dist/auth/account_routes.d.ts +4 -6
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +86 -66
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +63 -14
- package/dist/auth/api_token_queries.d.ts +16 -7
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +18 -18
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +10 -12
- package/dist/auth/audit_log_schema.js +4 -4
- package/dist/auth/bearer_auth.d.ts +4 -3
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +35 -31
- package/dist/auth/bootstrap_account.d.ts +65 -37
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +115 -66
- package/dist/auth/bootstrap_route_schema.d.ts +6 -2
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +7 -2
- package/dist/auth/bootstrap_routes.d.ts +50 -33
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +109 -87
- package/dist/auth/bootstrap_token_store.d.ts +60 -0
- package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
- package/dist/auth/bootstrap_token_store.js +39 -0
- package/dist/auth/credential_headers.d.ts +71 -0
- package/dist/auth/credential_headers.d.ts.map +1 -0
- package/dist/auth/credential_headers.js +100 -0
- package/dist/auth/daemon_token.d.ts +13 -1
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token.js +14 -2
- package/dist/auth/daemon_token_middleware.d.ts +10 -11
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +27 -29
- package/dist/auth/deps.d.ts +0 -11
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/invite_queries.d.ts +18 -0
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +24 -0
- package/dist/auth/request_context.d.ts +26 -5
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +17 -10
- package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +3 -2
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +37 -14
- package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
- package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_ddl.js +9 -2
- package/dist/auth/role_grant_offer_queries.d.ts +56 -3
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +93 -8
- package/dist/auth/role_grant_queries.d.ts +7 -0
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +8 -0
- package/dist/auth/session_cookie.d.ts +105 -25
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +124 -15
- package/dist/auth/session_middleware.d.ts +83 -54
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +92 -66
- package/dist/auth/session_queries.d.ts +64 -4
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +53 -4
- package/dist/auth/signup_route_schema.d.ts +5 -5
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +4 -4
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +17 -14
- package/dist/auth/token_scope.d.ts +5 -7
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +5 -8
- package/dist/dev/setup.d.ts +6 -1
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +42 -34
- package/dist/hono_context.d.ts +21 -0
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +17 -0
- package/dist/http/CLAUDE.md +150 -43
- package/dist/http/auth_shape.d.ts +3 -3
- package/dist/http/common_routes.js +1 -1
- package/dist/http/db_routes.d.ts +4 -3
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +14 -14
- package/dist/http/dev_route_error_check.d.ts +6 -3
- package/dist/http/dev_route_error_check.d.ts.map +1 -1
- package/dist/http/dev_route_error_check.js +6 -3
- package/dist/http/dev_set_cookie_check.d.ts +53 -0
- package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
- package/dist/http/dev_set_cookie_check.js +80 -0
- package/dist/http/error_schemas.d.ts +36 -1
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +39 -2
- package/dist/http/header_lines.d.ts +42 -0
- package/dist/http/header_lines.d.ts.map +1 -0
- package/dist/http/header_lines.js +80 -0
- package/dist/http/host.d.ts +12 -9
- package/dist/http/host.d.ts.map +1 -1
- package/dist/http/host.js +25 -20
- package/dist/http/origin.d.ts +7 -22
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +11 -25
- package/dist/http/proxy.d.ts +1 -0
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +3 -0
- package/dist/http/request_headers.d.ts +95 -0
- package/dist/http/request_headers.d.ts.map +1 -0
- package/dist/http/request_headers.js +110 -0
- package/dist/http/request_target.d.ts +134 -0
- package/dist/http/request_target.d.ts.map +1 -0
- package/dist/http/request_target.js +193 -0
- package/dist/http/route_error_check.d.ts +4 -11
- package/dist/http/route_error_check.d.ts.map +1 -1
- package/dist/http/route_error_check.js +4 -21
- package/dist/http/route_result.d.ts +127 -23
- package/dist/http/route_result.d.ts.map +1 -1
- package/dist/http/route_result.js +97 -19
- package/dist/http/route_spec.d.ts +298 -82
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +548 -71
- package/dist/http/simple_request.d.ts +19 -14
- package/dist/http/simple_request.d.ts.map +1 -1
- package/dist/http/simple_request.js +17 -29
- package/dist/http/surface.d.ts +2 -0
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +4 -1
- package/dist/realtime/outbound_budget.d.ts +1 -2
- package/dist/realtime/outbound_budget.d.ts.map +1 -1
- package/dist/realtime/outbound_budget.js +1 -2
- package/dist/realtime/sse.d.ts +47 -17
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +115 -93
- package/dist/realtime/sse_constants.d.ts +7 -1
- package/dist/realtime/sse_constants.d.ts.map +1 -1
- package/dist/realtime/sse_constants.js +12 -1
- package/dist/realtime/sse_registry.d.ts +3 -3
- package/dist/realtime/sse_registry.js +3 -3
- package/dist/runtime/deps.d.ts +20 -4
- package/dist/runtime/deps.d.ts.map +1 -1
- package/dist/runtime/mock.d.ts +7 -1
- package/dist/runtime/mock.d.ts.map +1 -1
- package/dist/runtime/mock.js +33 -3
- package/dist/runtime/node.d.ts.map +1 -1
- package/dist/runtime/node.js +2 -1
- package/dist/runtime/secure_file.d.ts +71 -10
- package/dist/runtime/secure_file.d.ts.map +1 -1
- package/dist/runtime/secure_file.js +91 -11
- package/dist/server/app_backend.d.ts +0 -8
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +1 -3
- package/dist/server/app_server.d.ts +28 -17
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +52 -34
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +49 -45
- package/dist/server/static.d.ts +20 -0
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +56 -8
- package/dist/server/unmatched_route.d.ts +42 -0
- package/dist/server/unmatched_route.d.ts.map +1 -0
- package/dist/server/unmatched_route.js +64 -0
- package/dist/testing/CLAUDE.md +404 -1200
- package/dist/testing/app_server.d.ts +3 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +4 -10
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +2 -1
- package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
- package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/account_lifecycle.js +277 -6
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
- package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
- package/dist/testing/cross_backend/capabilities.d.ts +68 -5
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +20 -4
- package/dist/testing/cross_backend/cell_gated_create.js +1 -1
- package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +179 -23
- package/dist/testing/cross_backend/cookie_attributes.js +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
- package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
- package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_conformance.js +296 -0
- package/dist/testing/cross_backend/credential_conformance.json +1284 -0
- package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
- package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
- package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
- package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
- package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
- package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
- package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_wire.js +188 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +22 -2
- package/dist/testing/cross_backend/default_spine_surface.js +1 -1
- package/dist/testing/cross_backend/differential.d.ts +1 -1
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +3 -2
- package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
- package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential_normalize.js +11 -5
- package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -0
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +7 -0
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +4 -0
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +78 -4
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +13 -10
- package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
- package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
- package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_header_conformance.js +196 -0
- package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
- package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
- package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_target_conformance.js +186 -0
- package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +2 -1
- package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
- package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
- package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +56 -29
- package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
- package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
- package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
- package/dist/testing/cross_backend/session_login.d.ts +24 -0
- package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
- package/dist/testing/cross_backend/session_login.js +31 -0
- package/dist/testing/cross_backend/setup.d.ts +117 -0
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +193 -9
- package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
- package/dist/testing/cross_backend/simple_request.js +5 -0
- package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +88 -5
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +205 -64
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +5 -2
- package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
- package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
- package/dist/testing/cross_backend/testing_credential_read.js +175 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +58 -2
- package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +13 -10
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
- package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
- package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_endpoint.js +19 -2
- package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_role_gated.js +2 -3
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +28 -12
- package/dist/testing/cross_backend/xfail.d.ts +44 -11
- package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
- package/dist/testing/cross_backend/xfail.js +68 -23
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +4 -3
- package/dist/testing/integration.d.ts +1 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +14 -8
- package/dist/testing/integration_helpers.d.ts +50 -3
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +87 -9
- package/dist/testing/middleware.d.ts +2 -0
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +9 -2
- package/dist/testing/round_trip.d.ts +6 -2
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +17 -6
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +7 -0
- package/dist/testing/rpc_helpers.d.ts +4 -2
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +6 -1
- package/dist/testing/rpc_round_trip.d.ts +13 -2
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +25 -6
- package/dist/testing/schema_generators.d.ts +2 -2
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +4 -4
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +8 -8
- package/dist/testing/transports/fetch_transport.d.ts +6 -3
- package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
- package/dist/testing/transports/fetch_transport.js +31 -19
- package/dist/testing/transports/raw_http.d.ts +61 -1
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +61 -1
- package/dist/testing/transports/ws_raw_client.d.ts +20 -0
- package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
- package/dist/testing/transports/ws_raw_client.js +10 -4
- package/dist/testing/transports/ws_transport.d.ts +21 -1
- package/dist/testing/transports/ws_transport.d.ts.map +1 -1
- package/dist/testing/transports/ws_transport.js +58 -20
- package/package.json +1 -1
|
@@ -17,20 +17,22 @@ import '../assert_dev_env.js';
|
|
|
17
17
|
* 1. **connects** — the stream opens and emits the `: connected` comment.
|
|
18
18
|
* 2. **data frame** (gated on `rpc_path`) — a minted secondary's sessions are
|
|
19
19
|
* revoked over the keeper's admin channel (`admin_session_revoke_all`),
|
|
20
|
-
* broadcasting a `session_revoke_all` audit event
|
|
21
|
-
* the subscribed keeper **without** closing its stream
|
|
22
|
-
* the secondary, not the subscriber). The secondary is
|
|
23
|
-
* stream opens so `create_account`'s own audit events
|
|
24
|
-
* login / token) don't land on it.
|
|
20
|
+
* broadcasting a `session_revoke_all` audit event naming the secondary as
|
|
21
|
+
* one `data:` frame to the subscribed keeper **without** closing its stream
|
|
22
|
+
* (the event targets the secondary, not the subscriber). The secondary is
|
|
23
|
+
* minted *before* the stream opens so `create_account`'s own audit events
|
|
24
|
+
* (invite / signup / login / token) don't land on it.
|
|
25
25
|
* 3. **close-on-revoke, account-wide** (gated on `rpc_path`) — the subscriber's
|
|
26
26
|
* *own* sessions are revoked (`account_session_revoke_all`), which closes
|
|
27
27
|
* every stream of the account once the revoke commits (the handler's
|
|
28
28
|
* close, repeated by the audit guard on the `session_revoke_all` row).
|
|
29
29
|
* Asserted via `SseTransport.wait_for_close`.
|
|
30
|
-
* 4. **close-on-revoke, session-scoped** (gated on `rpc_path`) —
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* 4. **close-on-revoke, session-scoped** (gated on `rpc_path`) — a second
|
|
31
|
+
* admin holds two sessions with a stream on each; the second session
|
|
32
|
+
* revokes the first (`account_session_revoke`), which closes only the
|
|
33
|
+
* stream registered under the named session's hash, while the caller's own
|
|
34
|
+
* stream stays open and still receives a broadcast — so a backend closing
|
|
35
|
+
* the whole account, or the caller's streams, on a session revoke fails it.
|
|
34
36
|
* 5. **close on account delete** (gated on `rpc_path` and
|
|
35
37
|
* `capabilities.account_lifecycle`) — the keeper soft-deletes a second
|
|
36
38
|
* admin whose stream is open; the delete revokes its credentials and
|
|
@@ -42,7 +44,18 @@ import '../assert_dev_env.js';
|
|
|
42
44
|
* the WS suite.
|
|
43
45
|
* 7. **per-session cap** — one stream past `max_per_scope` on one session
|
|
44
46
|
* closes the oldest (evict-oldest, no final frame) and leaves every other
|
|
45
|
-
* stream open.
|
|
47
|
+
* stream open. With `rpc_path`, each stream is proven admitted as it opens
|
|
48
|
+
* and each survivor proven open after the overflow by a broadcast frame;
|
|
49
|
+
* without it, by the connect comment and a short silence.
|
|
50
|
+
*
|
|
51
|
+
* Cases 2–6 need `rpc_path` (each drives an RPC method); 1 and 7 run without
|
|
52
|
+
* it. Every close case (3–6, and 7 when `rpc_path` is given) first proves its
|
|
53
|
+
* stream **admitted**: after the connect comment, an admin writes one audit
|
|
54
|
+
* row (`app_settings_update`, `open_signup` set to its reset value) and the
|
|
55
|
+
* stream must deliver its frame. The comment alone proves nothing — a
|
|
56
|
+
* stream closed before admission is still answered `200` with the comment and
|
|
57
|
+
* then ends — so a close observed without it can't tell a working revocation
|
|
58
|
+
* from a broken admission.
|
|
46
59
|
*
|
|
47
60
|
* The close-on-revoke matrix is layered: cases 3–6 exercise the account-wide
|
|
48
61
|
* and session-scoped paths cross-process; `token_revoke` (token-scoped — the
|
|
@@ -61,7 +74,7 @@ import '../assert_dev_env.js';
|
|
|
61
74
|
import { assert, describe } from 'vitest';
|
|
62
75
|
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
63
76
|
import { account_session_list_action_spec, account_session_revoke_action_spec, account_session_revoke_all_action_spec } from '../../auth/account_action_specs.js';
|
|
64
|
-
import { account_delete_action_spec, admin_session_revoke_all_action_spec } from '../../auth/admin_action_specs.js';
|
|
77
|
+
import { account_delete_action_spec, admin_session_revoke_all_action_spec, app_settings_update_action_spec } from '../../auth/admin_action_specs.js';
|
|
65
78
|
import { ROLE_ADMIN } from '../../auth/role_schema.js';
|
|
66
79
|
import { AUDIT_LOG_SSE_MAX_PER_SCOPE, audit_log_event_specs } from '../../realtime/audit_log_sse.js';
|
|
67
80
|
import { SSE_CONNECTED_COMMENT } from '../../realtime/sse_constants.js';
|
|
@@ -70,21 +83,102 @@ import { create_rpc_post_init } from '../rpc_helpers.js';
|
|
|
70
83
|
import { DEFAULT_TEST_PASSWORD } from '../test_credentials.js';
|
|
71
84
|
import { test_if } from './capabilities.js';
|
|
72
85
|
import { create_account_revocations } from './revocation_drivers.js';
|
|
73
|
-
import {
|
|
86
|
+
import { login_fresh_session } from './session_login.js';
|
|
87
|
+
import { SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_LOGOUT_PATH, SPINE_ACCOUNT_PASSWORD_PATH, SPINE_SSE_PATH } from './spine_surface_constants.js';
|
|
88
|
+
/** The audit event a session revoke-all writes, what the data-frame and cap cases read. */
|
|
89
|
+
const SESSION_REVOKE_ALL_EVENT = 'session_revoke_all';
|
|
90
|
+
/** The `data:` payload of a frame, or `null` for a comment frame. */
|
|
91
|
+
const parse_data_frame = (frame) => {
|
|
92
|
+
const data_line = frame.split('\n').find((line) => line.startsWith('data: '));
|
|
93
|
+
if (!data_line)
|
|
94
|
+
return null;
|
|
95
|
+
return JSON.parse(data_line.slice('data: '.length));
|
|
96
|
+
};
|
|
74
97
|
/**
|
|
75
98
|
* Assert a decoded SSE frame is a well-formed audit `{method, params}`
|
|
76
99
|
* payload whose `params` validate against the matching `audit_log_event_specs`
|
|
77
100
|
* entry.
|
|
101
|
+
*
|
|
102
|
+
* @returns the payload
|
|
78
103
|
*/
|
|
79
104
|
const assert_audit_data_frame = (frame) => {
|
|
80
|
-
const
|
|
81
|
-
assert.ok(
|
|
82
|
-
const payload = JSON.parse(data_line.slice('data: '.length));
|
|
105
|
+
const payload = parse_data_frame(frame);
|
|
106
|
+
assert.ok(payload, `SSE frame has no 'data:' line: ${JSON.stringify(frame)}`);
|
|
83
107
|
assert.strictEqual(typeof payload.method, 'string', 'audit data frame method must be a string');
|
|
84
108
|
const spec = audit_log_event_specs.find((s) => s.method === payload.method);
|
|
85
109
|
assert.ok(spec, `no EventSpec declared for audit method '${String(payload.method)}'`);
|
|
86
110
|
const result = parse(spec.params, payload.params);
|
|
87
111
|
assert.ok(result.ok, `audit data frame params mismatch for '${String(payload.method)}': ${result.ok ? '' : JSON.stringify(result.issues)}`);
|
|
112
|
+
return payload;
|
|
113
|
+
};
|
|
114
|
+
/** Read a stream's first frame and assert it is the connect comment. */
|
|
115
|
+
const assert_connected_comment = async (sse, label) => {
|
|
116
|
+
const first = await sse.read_frame();
|
|
117
|
+
assert.strictEqual(first + '\n\n', SSE_CONNECTED_COMMENT, `${label}: first frame must be the connected comment`);
|
|
118
|
+
};
|
|
119
|
+
/** How long a stream may take to deliver a frame a case triggered. */
|
|
120
|
+
const TRIGGERED_FRAME_TIMEOUT_MS = 5000;
|
|
121
|
+
/**
|
|
122
|
+
* Read the stream until an audit frame of `method` that `match` accepts
|
|
123
|
+
* arrives, skipping comment frames and other rows' frames (a login, an
|
|
124
|
+
* earlier probe).
|
|
125
|
+
*
|
|
126
|
+
* @returns the matching frame's payload
|
|
127
|
+
* @throws Error naming `label` when none arrives — the stream ended or went
|
|
128
|
+
* quiet past `TRIGGERED_FRAME_TIMEOUT_MS` — with the read's error as `cause`
|
|
129
|
+
*/
|
|
130
|
+
const read_audit_frame = async (sse, method, label, match = () => true) => {
|
|
131
|
+
const deadline = Date.now() + TRIGGERED_FRAME_TIMEOUT_MS;
|
|
132
|
+
try {
|
|
133
|
+
for (;;) {
|
|
134
|
+
const remaining = deadline - Date.now();
|
|
135
|
+
if (remaining <= 0)
|
|
136
|
+
throw new Error(`none within ${TRIGGERED_FRAME_TIMEOUT_MS}ms`);
|
|
137
|
+
const frame = await sse.read_frame(remaining);
|
|
138
|
+
if (parse_data_frame(frame)?.method !== method)
|
|
139
|
+
continue;
|
|
140
|
+
const payload = assert_audit_data_frame(frame);
|
|
141
|
+
if (match(payload.params))
|
|
142
|
+
return payload;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
throw new Error(`${label}: no valid ${method} frame reached the stream`, { cause: error });
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Write one audit row through `trigger` (an admin's transport) and read the
|
|
151
|
+
* stream until a frame of its kind arrives. The row is an `app_settings_update`
|
|
152
|
+
* setting `open_signup` to `false`, its value on a fresh reset, audited on
|
|
153
|
+
* every spine whether or not it changes anything. It changes only the
|
|
154
|
+
* settings row's `updated_at` / `updated_by` and adds an audit row — no case
|
|
155
|
+
* reads either, and the per-test reset clears both.
|
|
156
|
+
*/
|
|
157
|
+
const read_probe_frame = async (sse, trigger, rpc_path, label) => {
|
|
158
|
+
const res = await trigger(rpc_path, create_rpc_post_init(app_settings_update_action_spec.method, { open_signup: false }));
|
|
159
|
+
assert.strictEqual(res.status, 200, `${label}: app_settings_update failed (status=${res.status})`);
|
|
160
|
+
await read_audit_frame(sse, app_settings_update_action_spec.method, label);
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Open an audit stream and prove the backend admitted it before a case
|
|
164
|
+
* revokes anything: the connect comment, then one broadcast row's frame.
|
|
165
|
+
* The comment alone proves nothing — a stream closed before admission is
|
|
166
|
+
* still answered `200` with the comment and then ends — so without the frame
|
|
167
|
+
* a backend whose admission is broken passes every close case.
|
|
168
|
+
*/
|
|
169
|
+
const open_admitted_stream = async (options) => {
|
|
170
|
+
const { base_url, sse_path, origin, cookies, trigger, rpc_path } = options;
|
|
171
|
+
const label = options.label ?? 'stream';
|
|
172
|
+
const sse = await create_sse_transport({ base_url, sse_path, cookies, origin });
|
|
173
|
+
try {
|
|
174
|
+
await assert_connected_comment(sse, label);
|
|
175
|
+
await read_probe_frame(sse, trigger, rpc_path, label);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
await sse.close();
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
return sse;
|
|
88
182
|
};
|
|
89
183
|
/**
|
|
90
184
|
* Register the cross-process SSE round-trip suite. Its cases run over a
|
|
@@ -94,9 +188,19 @@ const assert_audit_data_frame = (frame) => {
|
|
|
94
188
|
* per-session cap.
|
|
95
189
|
*/
|
|
96
190
|
export const describe_cross_process_sse_tests = (options) => {
|
|
97
|
-
const { setup_test, capabilities, base_url, rpc_path, origin, logout_path = SPINE_ACCOUNT_LOGOUT_PATH, password_path = SPINE_ACCOUNT_PASSWORD_PATH } = options;
|
|
191
|
+
const { setup_test, capabilities, base_url, rpc_path, origin, login_path = SPINE_ACCOUNT_LOGIN_PATH, logout_path = SPINE_ACCOUNT_LOGOUT_PATH, password_path = SPINE_ACCOUNT_PASSWORD_PATH } = options;
|
|
98
192
|
const sse_path = options.sse_path ?? SPINE_SSE_PATH;
|
|
99
193
|
const max_per_scope = options.max_per_scope === undefined ? AUDIT_LOG_SSE_MAX_PER_SCOPE : options.max_per_scope;
|
|
194
|
+
/** `open_admitted_stream` on this suite's endpoint, the keeper as the probe's admin. */
|
|
195
|
+
const open_admitted = (fixture, cookies, label) => open_admitted_stream({
|
|
196
|
+
base_url,
|
|
197
|
+
sse_path,
|
|
198
|
+
origin,
|
|
199
|
+
cookies,
|
|
200
|
+
trigger: fixture.transport,
|
|
201
|
+
rpc_path: rpc_path,
|
|
202
|
+
...(label !== undefined && { label })
|
|
203
|
+
});
|
|
100
204
|
describe('cross-process sse', () => {
|
|
101
205
|
test_if(capabilities.sse, 'connects and emits the connected comment', async () => {
|
|
102
206
|
const fixture = await setup_test();
|
|
@@ -107,8 +211,7 @@ export const describe_cross_process_sse_tests = (options) => {
|
|
|
107
211
|
origin
|
|
108
212
|
});
|
|
109
213
|
try {
|
|
110
|
-
|
|
111
|
-
assert.strictEqual(first + '\n\n', SSE_CONNECTED_COMMENT, 'first frame must be the connected comment');
|
|
214
|
+
await assert_connected_comment(sse, 'stream');
|
|
112
215
|
}
|
|
113
216
|
finally {
|
|
114
217
|
await sse.close();
|
|
@@ -131,14 +234,15 @@ export const describe_cross_process_sse_tests = (options) => {
|
|
|
131
234
|
origin
|
|
132
235
|
});
|
|
133
236
|
try {
|
|
134
|
-
|
|
135
|
-
assert.strictEqual(first + '\n\n', SSE_CONNECTED_COMMENT, 'first frame must be the connected comment');
|
|
237
|
+
await assert_connected_comment(sse, 'stream');
|
|
136
238
|
const res = await fixture.transport(rpc_path, create_rpc_post_init(admin_session_revoke_all_action_spec.method, {
|
|
137
239
|
account_id: secondary.account.id
|
|
138
240
|
}));
|
|
139
241
|
assert.strictEqual(res.status, 200, `admin_session_revoke_all RPC failed (status=${res.status})`);
|
|
140
|
-
|
|
141
|
-
assert_audit_data_frame(
|
|
242
|
+
// the next data frame is the row the revoke wrote, naming the secondary
|
|
243
|
+
const payload = assert_audit_data_frame(await sse.read_frame());
|
|
244
|
+
assert.strictEqual(payload.method, SESSION_REVOKE_ALL_EVENT);
|
|
245
|
+
assert.strictEqual(payload.params.target_account_id, secondary.account.id);
|
|
142
246
|
}
|
|
143
247
|
finally {
|
|
144
248
|
await sse.close();
|
|
@@ -149,15 +253,8 @@ export const describe_cross_process_sse_tests = (options) => {
|
|
|
149
253
|
// the `session_revoke_all` row).
|
|
150
254
|
test_if(capabilities.sse && rpc_path !== undefined, 'stream closes when the subscriber sessions are revoked', async () => {
|
|
151
255
|
const fixture = await setup_test();
|
|
152
|
-
const sse = await
|
|
153
|
-
base_url,
|
|
154
|
-
sse_path,
|
|
155
|
-
cookies: fixture.transport.cookies(),
|
|
156
|
-
origin
|
|
157
|
-
});
|
|
256
|
+
const sse = await open_admitted(fixture, fixture.transport.cookies());
|
|
158
257
|
try {
|
|
159
|
-
const first = await sse.read_frame();
|
|
160
|
-
assert.strictEqual(first + '\n\n', SSE_CONNECTED_COMMENT, 'first frame must be the connected comment');
|
|
161
258
|
const res = await fixture.transport(rpc_path, create_rpc_post_init(account_session_revoke_all_action_spec.method));
|
|
162
259
|
assert.strictEqual(res.status, 200, `account_session_revoke_all RPC failed (status=${res.status})`);
|
|
163
260
|
const closed = await sse.wait_for_close(2000);
|
|
@@ -167,37 +264,63 @@ export const describe_cross_process_sse_tests = (options) => {
|
|
|
167
264
|
await sse.close();
|
|
168
265
|
}
|
|
169
266
|
});
|
|
170
|
-
// Single `session_revoke` of the subscriber's
|
|
267
|
+
// Single `session_revoke` of one of the subscriber's sessions → the
|
|
171
268
|
// session-hash-scoped close (the Rust registry's
|
|
172
269
|
// `ConnectionCloseTarget::Session` close, the TS registry's
|
|
173
|
-
// `close_by_identity(session_hash)`). The
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
//
|
|
270
|
+
// `close_by_identity(session_hash)`). The subscriber — a second admin, so
|
|
271
|
+
// the keeper stays free to drive the probes — holds two sessions with a
|
|
272
|
+
// stream on each, and the second revokes the first: the named session's
|
|
273
|
+
// stream must close and the caller's own stay open and receiving, which a
|
|
274
|
+
// backend closing the whole account, or the caller's streams, fails.
|
|
275
|
+
// `role_grant_revoke`'s role-matched close is covered by `fuz_realtime`'s
|
|
276
|
+
// SSE registry unit tests.
|
|
178
277
|
test_if(capabilities.sse && rpc_path !== undefined, 'stream closes on a single session_revoke of the subscriber session', async () => {
|
|
179
278
|
const fixture = await setup_test();
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
279
|
+
const target = await fixture.create_account({
|
|
280
|
+
username: 'sse_session_revoke',
|
|
281
|
+
password_value: DEFAULT_TEST_PASSWORD,
|
|
282
|
+
roles: [ROLE_ADMIN]
|
|
283
|
+
});
|
|
284
|
+
const first_cookie = target.create_session_headers().cookie;
|
|
285
|
+
assert.ok(first_cookie, 'expected a session cookie for the target account');
|
|
286
|
+
// a second login, a second session of the same account on its own jar
|
|
287
|
+
const second_transport = await login_fresh_session(fixture, {
|
|
288
|
+
login_path,
|
|
289
|
+
username: target.account.username,
|
|
290
|
+
password: DEFAULT_TEST_PASSWORD,
|
|
291
|
+
label: 'the second login'
|
|
185
292
|
});
|
|
293
|
+
const streams = [];
|
|
186
294
|
try {
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
const
|
|
295
|
+
const revoked = await open_admitted(fixture, [first_cookie], 'first session stream');
|
|
296
|
+
streams.push(revoked);
|
|
297
|
+
const survivor = await open_admitted(fixture, second_transport.cookies(), 'second session stream');
|
|
298
|
+
streams.push(survivor);
|
|
299
|
+
// the first session's id: the row its own list marks current
|
|
300
|
+
const list_init = create_rpc_post_init(account_session_list_action_spec.method);
|
|
301
|
+
const list_res = await fixture.fresh_transport()(rpc_path, {
|
|
302
|
+
...list_init,
|
|
303
|
+
headers: target.create_session_headers(list_init.headers)
|
|
304
|
+
});
|
|
190
305
|
assert.strictEqual(list_res.status, 200, `account_session_list RPC failed (status=${list_res.status})`);
|
|
191
306
|
const list_body = (await list_res.json());
|
|
192
|
-
const
|
|
193
|
-
assert.ok(
|
|
194
|
-
const
|
|
307
|
+
const sessions = list_body.result?.sessions ?? [];
|
|
308
|
+
assert.ok(sessions.length >= 2, `expected two sessions, got ${sessions.length}`);
|
|
309
|
+
const current = sessions.filter((row) => row.is_current === true);
|
|
310
|
+
assert.strictEqual(current.length, 1, "exactly one session is the caller's own");
|
|
311
|
+
const session_id = current[0]?.id;
|
|
312
|
+
assert.ok(typeof session_id === 'string' && session_id.length > 0, 'expected the first session id (blake3 hash) to revoke');
|
|
313
|
+
// revoked by the second session, so the stream that must close is
|
|
314
|
+
// not the caller's
|
|
315
|
+
const revoke_res = await second_transport(rpc_path, create_rpc_post_init(account_session_revoke_action_spec.method, { session_id }));
|
|
195
316
|
assert.strictEqual(revoke_res.status, 200, `account_session_revoke RPC failed (status=${revoke_res.status})`);
|
|
196
|
-
const closed = await
|
|
197
|
-
assert.ok(closed, 'stream did not close within 2s after session_revoke');
|
|
317
|
+
const closed = await revoked.wait_for_close(2000);
|
|
318
|
+
assert.ok(closed, 'the named session stream did not close within 2s after session_revoke');
|
|
319
|
+
// the caller's own stream is still open and still broadcast to
|
|
320
|
+
await read_probe_frame(survivor, fixture.transport, rpc_path, 'second session stream');
|
|
198
321
|
}
|
|
199
322
|
finally {
|
|
200
|
-
await sse.close();
|
|
323
|
+
await Promise.all(streams.map((sse) => sse.close()));
|
|
201
324
|
}
|
|
202
325
|
});
|
|
203
326
|
// A soft-deleted account's credentials stop authenticating, and a stream
|
|
@@ -212,10 +335,8 @@ export const describe_cross_process_sse_tests = (options) => {
|
|
|
212
335
|
});
|
|
213
336
|
const cookie = target.create_session_headers().cookie;
|
|
214
337
|
assert.ok(cookie, 'expected a session cookie for the target account');
|
|
215
|
-
const sse = await
|
|
338
|
+
const sse = await open_admitted(fixture, [cookie]);
|
|
216
339
|
try {
|
|
217
|
-
const first = await sse.read_frame();
|
|
218
|
-
assert.strictEqual(first + '\n\n', SSE_CONNECTED_COMMENT, 'first frame must be the connected comment');
|
|
219
340
|
const res = await fixture.transport(rpc_path, create_rpc_post_init(account_delete_action_spec.method, {
|
|
220
341
|
account_id: target.account.id
|
|
221
342
|
}));
|
|
@@ -247,10 +368,8 @@ export const describe_cross_process_sse_tests = (options) => {
|
|
|
247
368
|
});
|
|
248
369
|
const cookie = target.create_session_headers().cookie;
|
|
249
370
|
assert.ok(cookie, 'expected a session cookie for the target account');
|
|
250
|
-
const sse = await
|
|
371
|
+
const sse = await open_admitted(fixture, [cookie]);
|
|
251
372
|
try {
|
|
252
|
-
const first = await sse.read_frame();
|
|
253
|
-
assert.strictEqual(first + '\n\n', SSE_CONNECTED_COMMENT, 'first frame must be the connected comment');
|
|
254
373
|
await revoke(fixture, target);
|
|
255
374
|
const closed = await sse.wait_for_close(2000);
|
|
256
375
|
assert.ok(closed, `stream did not close within 2s after ${label}`);
|
|
@@ -261,27 +380,49 @@ export const describe_cross_process_sse_tests = (options) => {
|
|
|
261
380
|
});
|
|
262
381
|
}
|
|
263
382
|
// One stream past the cap on one session → the oldest closes, the newest
|
|
264
|
-
// stays open. Opened in sequence, each
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
//
|
|
383
|
+
// stays open. Opened in sequence, each admitted before the next opens (a
|
|
384
|
+
// broadcast row's frame read on it, given `rpc_path`; else its connect
|
|
385
|
+
// comment), so the server registered them in order and "oldest" is
|
|
386
|
+
// stream 0 on both spines. Given `rpc_path`, every survivor then reads
|
|
387
|
+
// the frame of a row written after the overflow — a `session_revoke_all`
|
|
388
|
+
// naming an account minted for it, a kind no admission probe writes, so
|
|
389
|
+
// a frame buffered before the overflow can't stand in; without it, a
|
|
390
|
+
// short silence is the only check. The evicted stream ends with no final
|
|
391
|
+
// frame, so a browser `EventSource` would reconnect — this asserts the
|
|
392
|
+
// server side only.
|
|
268
393
|
test_if(capabilities.sse && max_per_scope !== null, 'one stream past the per-session cap closes the oldest', async () => {
|
|
269
394
|
const fixture = await setup_test();
|
|
395
|
+
// minted before any stream opens, so its own audit rows land on none
|
|
396
|
+
const marker = rpc_path === undefined
|
|
397
|
+
? null
|
|
398
|
+
: await fixture.create_account({ username: 'sse_cap_marker', roles: [] });
|
|
270
399
|
const cookies = fixture.transport.cookies();
|
|
271
400
|
const streams = [];
|
|
272
401
|
try {
|
|
273
402
|
for (let i = 0; i <= max_per_scope; i++) {
|
|
403
|
+
if (rpc_path !== undefined) {
|
|
404
|
+
streams.push(await open_admitted(fixture, cookies, `stream ${i}`));
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
274
407
|
const sse = await create_sse_transport({ base_url, sse_path, cookies, origin });
|
|
275
408
|
streams.push(sse);
|
|
276
|
-
|
|
277
|
-
assert.strictEqual(first + '\n\n', SSE_CONNECTED_COMMENT, `stream ${i}: first frame must be the connected comment`);
|
|
409
|
+
await assert_connected_comment(sse, `stream ${i}`);
|
|
278
410
|
}
|
|
279
411
|
const [oldest, ...survivors] = streams;
|
|
280
412
|
const closed = await oldest.wait_for_close(2000);
|
|
281
413
|
assert.ok(closed, 'the oldest stream did not close within 2s of the cap overflow');
|
|
282
414
|
// only the oldest — every later stream on the session stays open
|
|
283
|
-
|
|
284
|
-
|
|
415
|
+
if (marker !== null) {
|
|
416
|
+
const res = await fixture.transport(rpc_path, create_rpc_post_init(admin_session_revoke_all_action_spec.method, {
|
|
417
|
+
account_id: marker.account.id
|
|
418
|
+
}));
|
|
419
|
+
assert.strictEqual(res.status, 200, `admin_session_revoke_all RPC failed (status=${res.status})`);
|
|
420
|
+
await Promise.all(survivors.map((sse, i) => read_audit_frame(sse, SESSION_REVOKE_ALL_EVENT, `stream ${i + 1} (only the oldest may close)`, (params) => params.target_account_id === marker.account.id)));
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
const survivors_closed = await Promise.all(survivors.map((sse) => sse.wait_for_close(200)));
|
|
424
|
+
assert.deepStrictEqual(survivors_closed, survivors.map(() => false), 'only the oldest stream may close; the rest of the session stays open');
|
|
425
|
+
}
|
|
285
426
|
}
|
|
286
427
|
finally {
|
|
287
428
|
await Promise.all(streams.map((sse) => sse.close()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing_backdoor.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_backdoor.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA2F9B,OAAO,KAAK,EAAE,uCAAuC,EAAe,MAAM,YAAY,CAAC;AAMvF,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"testing_backdoor.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_backdoor.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA2F9B,OAAO,KAAK,EAAE,uCAAuC,EAAe,MAAM,YAAY,CAAC;AAMvF,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAiD1E;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC1B;AAkDD,8CAA8C;AAC9C,MAAM,WAAW,+BAAgC,SAAQ,uCAAuC;IAC/F;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC7D;AAqDD;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,GACjD,SAAS,+BAA+B,KACtC,IAgHF,CAAC"}
|
|
@@ -7,8 +7,8 @@ import '../assert_dev_env.js';
|
|
|
7
7
|
* `_testing_mint_session`, `_testing_put_fact`,
|
|
8
8
|
* `_testing_flood_notifications`, `_testing_schema_snapshot`,
|
|
9
9
|
* `_testing_migration_tracker`, `_testing_action_manifest`,
|
|
10
|
-
* `_testing_origin_check`, `
|
|
11
|
-
* `_testing_room_evict`) are privileged test-binary actions the production
|
|
10
|
+
* `_testing_origin_check`, `_testing_credential_read`,
|
|
11
|
+
* `_testing_shorten_credential_expiry`, `_testing_room_evict`) are privileged test-binary actions the production
|
|
12
12
|
* wire never exposes — direct DB writes (full auth wipe, forged session row,
|
|
13
13
|
* raw fact insert), the audit barrier, a flood of the caller's own connection,
|
|
14
14
|
* introspection reads (the live schema, the `schema_version` migration
|
|
@@ -115,6 +115,9 @@ const BACKDOOR_PARAMS = {
|
|
|
115
115
|
// The origin conformance probe — a valid `{patterns, origin}` pair, so it
|
|
116
116
|
// clears the 400 phase like the rest.
|
|
117
117
|
_testing_origin_check: { patterns: 'http://localhost:*', origin: null },
|
|
118
|
+
// The credential conformance probe — header lines naming no credential, so
|
|
119
|
+
// it clears the 400 phase like the rest.
|
|
120
|
+
_testing_credential_read: { lines: [] },
|
|
118
121
|
// The credential-expiry rewrite — a valid `{account_id, seconds}` pair (a
|
|
119
122
|
// syntactically valid UUID; no row needs to match), so it clears the 400
|
|
120
123
|
// phase like the rest.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* `_testing_credential_read` — the testing seam behind the cross-impl
|
|
4
|
+
* credential conformance table (`credential_conformance.json`): its input and
|
|
5
|
+
* output schemas, the pure read it answers with, its spec, and the action
|
|
6
|
+
* builder.
|
|
7
|
+
*
|
|
8
|
+
* A leaf like `testing_origin_check.ts`, and hono-free for the same reason: a
|
|
9
|
+
* consumer whose backend is a spawned Rust binary runs the table without
|
|
10
|
+
* installing `hono`.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
15
|
+
import { type RpcAction } from '../../actions/action_types.js';
|
|
16
|
+
import type { Keyring } from '../../auth/keyring.js';
|
|
17
|
+
import { type SessionOptions } from '../../auth/session_cookie.js';
|
|
18
|
+
/**
|
|
19
|
+
* The `data.reason` of every refusal `_testing_credential_read` gives its
|
|
20
|
+
* `lines`: a value that is no list of strings, a list or a line over its cap
|
|
21
|
+
* (`TESTING_CREDENTIAL_READ_LINES_MAX`,
|
|
22
|
+
* `TESTING_CREDENTIAL_READ_LINE_LENGTH_MAX`), and a line it cannot read as a
|
|
23
|
+
* header line — no `:`, a name that is no HTTP token, or a character that is
|
|
24
|
+
* no byte a field value holds: above U+00FF (a line is bytes, one per
|
|
25
|
+
* character), or a control character other than HTAB, which an HTTP parser
|
|
26
|
+
* refuses before any spine code runs.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ERROR_TESTING_CREDENTIAL_READ_LINE = "invalid_header_line";
|
|
29
|
+
/**
|
|
30
|
+
* The longest header line `_testing_credential_read` reads, in UTF-16 code
|
|
31
|
+
* units — one a byte for every character a line may hold. A cap both spines
|
|
32
|
+
* state, so neither reads a line the other's header types refuse for its
|
|
33
|
+
* length; far above any credential line.
|
|
34
|
+
*/
|
|
35
|
+
export declare const TESTING_CREDENTIAL_READ_LINE_LENGTH_MAX = 1024;
|
|
36
|
+
/** The most header lines `_testing_credential_read` reads — both spines' cap. */
|
|
37
|
+
export declare const TESTING_CREDENTIAL_READ_LINES_MAX = 32;
|
|
38
|
+
/** Input of `_testing_credential_read`, a `@fuzdev/fuz_schema` `object`. */
|
|
39
|
+
export declare const TestingCredentialReadInput: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
40
|
+
/**
|
|
41
|
+
* The request's header lines, each `Name: value`, in the order sent — a
|
|
42
|
+
* name may repeat. Every character is one byte a field value may hold
|
|
43
|
+
* (HTAB, U+0020–U+007E, U+0080–U+00FF), as a runtime hands a handler a
|
|
44
|
+
* header's bytes. At most `TESTING_CREDENTIAL_READ_LINES_MAX` lines of at
|
|
45
|
+
* most `TESTING_CREDENTIAL_READ_LINE_LENGTH_MAX` characters each.
|
|
46
|
+
*/
|
|
47
|
+
lines: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string[], import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>>>;
|
|
48
|
+
}>;
|
|
49
|
+
export type TestingCredentialReadInput = Infer<typeof TestingCredentialReadInput>;
|
|
50
|
+
/**
|
|
51
|
+
* What a request's `Cookie` lines hold of the session cookie — the wire form
|
|
52
|
+
* of the Rust spine's `fuz_auth::SessionCookieRead`, its variants in
|
|
53
|
+
* lowercase.
|
|
54
|
+
*/
|
|
55
|
+
export declare const SessionCookieRead: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["absent", "invalid", "valid"]>;
|
|
56
|
+
export type SessionCookieRead = Infer<typeof SessionCookieRead>;
|
|
57
|
+
/**
|
|
58
|
+
* Output of `_testing_credential_read`, a `@fuzdev/fuz_schema` `object`: how
|
|
59
|
+
* each credential leg reads the lines, before any database work.
|
|
60
|
+
*/
|
|
61
|
+
export declare const TestingCredentialReadOutput: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
62
|
+
/**
|
|
63
|
+
* `absent` — no pair names the cookie; `invalid` — one does and its value
|
|
64
|
+
* fails verification (what the spine clears); `valid` — it verifies under
|
|
65
|
+
* the server's keyring and its signed expiry is ahead. Says nothing about
|
|
66
|
+
* the `auth_session` row.
|
|
67
|
+
*/
|
|
68
|
+
session_cookie: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["absent", "invalid", "valid"]>;
|
|
69
|
+
/** The API token the bearer leg would look up, or `null` when it reads none. */
|
|
70
|
+
bearer_token: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
71
|
+
/** The daemon token the daemon leg would compare, or `null` when it reads none. */
|
|
72
|
+
daemon_token: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
73
|
+
}>;
|
|
74
|
+
export type TestingCredentialReadOutput = Infer<typeof TestingCredentialReadOutput>;
|
|
75
|
+
/** What `run_testing_credential_read` verifies the session cookie with. */
|
|
76
|
+
export interface TestingCredentialReadDeps {
|
|
77
|
+
/** The server's cookie keyring. */
|
|
78
|
+
readonly keyring: Keyring;
|
|
79
|
+
/** The server's session options — the cookie name and identity decoder. */
|
|
80
|
+
readonly session_options: SessionOptions<string>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Split `Name: value` lines into the per-name lines the credential readers
|
|
84
|
+
* take — what an HTTP parser does to a request head: the name ends at the
|
|
85
|
+
* first `:` and compares in ASCII lowercase, the value loses its outer SP and
|
|
86
|
+
* HTAB, and lines of one name keep their order.
|
|
87
|
+
*
|
|
88
|
+
* @param lines - the header lines
|
|
89
|
+
* @returns the lines of a header by its lowercase name (`[]` for a header not sent)
|
|
90
|
+
* @throws ThrownJsonrpcError `invalid_params` with reason `ERROR_TESTING_CREDENTIAL_READ_LINE` for a line with no `:`, a name that is no token, or a character no header line holds
|
|
91
|
+
*/
|
|
92
|
+
export declare const parse_testing_header_lines: (lines: ReadonlyArray<string>) => ((lower_name: string) => ReadonlyArray<string>);
|
|
93
|
+
/**
|
|
94
|
+
* Answer one `_testing_credential_read` input: read each credential out of
|
|
95
|
+
* the lines with the readers the auth middleware legs call
|
|
96
|
+
* (`read_session_cookie_value` then `process_session_cookie`,
|
|
97
|
+
* `read_bearer_token`, `read_daemon_token`). The action handler and the
|
|
98
|
+
* conformance table's unit test both call this, so the table checks the same
|
|
99
|
+
* functions the wire serves.
|
|
100
|
+
*
|
|
101
|
+
* @param input - the header lines
|
|
102
|
+
* @param deps - the keyring and session options the cookie is verified with
|
|
103
|
+
* @returns the reading the Rust twin returns for the same lines
|
|
104
|
+
* @throws ThrownJsonrpcError `invalid_params` for a line `parse_testing_header_lines` refuses
|
|
105
|
+
*/
|
|
106
|
+
export declare const run_testing_credential_read: (input: TestingCredentialReadInput, deps: TestingCredentialReadDeps) => Promise<TestingCredentialReadOutput>;
|
|
107
|
+
/**
|
|
108
|
+
* `_testing_credential_read` — read the three credentials out of a list of
|
|
109
|
+
* header lines, so the shared conformance table
|
|
110
|
+
* (`credential_conformance.json`) checks each backend's header grammar over
|
|
111
|
+
* the wire, row by row. Pure: no database, no state beyond the server's
|
|
112
|
+
* keyring and cookie name. The Rust mirror is
|
|
113
|
+
* `fuz_testing::create_testing_credential_read_action_spec`.
|
|
114
|
+
*
|
|
115
|
+
* Like `_testing_origin_check`, it is **not** bundled by
|
|
116
|
+
* `create_testing_actions`: a consumer whose Rust binary doesn't mount the
|
|
117
|
+
* mirror would fail its action-manifest parity gate. The spine test binary
|
|
118
|
+
* appends it at the full-mount layer (`build_full_spine_rpc_actions`).
|
|
119
|
+
*
|
|
120
|
+
* `auth` gates on the daemon-token credential, matching `_testing_reset`.
|
|
121
|
+
*/
|
|
122
|
+
export declare const testing_credential_read_action_spec: {
|
|
123
|
+
readonly method: "_testing_credential_read";
|
|
124
|
+
readonly kind: "request_response";
|
|
125
|
+
readonly initiator: "frontend";
|
|
126
|
+
readonly auth: {
|
|
127
|
+
readonly account: "required";
|
|
128
|
+
readonly actor: "none";
|
|
129
|
+
readonly credential_types: readonly ["daemon_token"];
|
|
130
|
+
};
|
|
131
|
+
readonly side_effects: false;
|
|
132
|
+
readonly input: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
133
|
+
/**
|
|
134
|
+
* The request's header lines, each `Name: value`, in the order sent — a
|
|
135
|
+
* name may repeat. Every character is one byte a field value may hold
|
|
136
|
+
* (HTAB, U+0020–U+007E, U+0080–U+00FF), as a runtime hands a handler a
|
|
137
|
+
* header's bytes. At most `TESTING_CREDENTIAL_READ_LINES_MAX` lines of at
|
|
138
|
+
* most `TESTING_CREDENTIAL_READ_LINE_LENGTH_MAX` characters each.
|
|
139
|
+
*/
|
|
140
|
+
lines: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string[], import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>>>;
|
|
141
|
+
}>;
|
|
142
|
+
readonly output: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
143
|
+
/**
|
|
144
|
+
* `absent` — no pair names the cookie; `invalid` — one does and its value
|
|
145
|
+
* fails verification (what the spine clears); `valid` — it verifies under
|
|
146
|
+
* the server's keyring and its signed expiry is ahead. Says nothing about
|
|
147
|
+
* the `auth_session` row.
|
|
148
|
+
*/
|
|
149
|
+
session_cookie: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["absent", "invalid", "valid"]>;
|
|
150
|
+
/** The API token the bearer leg would look up, or `null` when it reads none. */
|
|
151
|
+
bearer_token: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
152
|
+
/** The daemon token the daemon leg would compare, or `null` when it reads none. */
|
|
153
|
+
daemon_token: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
154
|
+
}>;
|
|
155
|
+
readonly async: true;
|
|
156
|
+
readonly error_reasons: readonly ["invalid_header_line"];
|
|
157
|
+
readonly description: string;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Build the standalone `_testing_credential_read` action (see the spec doc).
|
|
161
|
+
*
|
|
162
|
+
* @param deps - the server's keyring and session options
|
|
163
|
+
*/
|
|
164
|
+
export declare const create_testing_credential_read_action: (deps: TestingCredentialReadDeps) => RpcAction;
|
|
165
|
+
//# sourceMappingURL=testing_credential_read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing_credential_read.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_credential_read.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;GAWG;AAEH,OAAO,EAQN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAQ3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM3F;;;;;;;;;GASG;AACH,eAAO,MAAM,kCAAkC,wBAAwB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,uCAAuC,OAAO,CAAC;AAE5D,iFAAiF;AACjF,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAEpD,4EAA4E;AAC5E,eAAO,MAAM,0BAA0B;IACtC;;;;;;OAMG;;EAQF,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,6FAAyC,CAAC;AACxE,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,2BAA2B;IACvC;;;;;OAKG;;IAEH,gFAAgF;;IAEhF,mFAAmF;;EAElF,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEpF,2EAA2E;AAC3E,MAAM,WAAW,yBAAyB;IACzC,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACjD;AAiBD;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GACtC,OAAO,aAAa,CAAC,MAAM,CAAC,KAC1B,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,aAAa,CAAC,MAAM,CAAC,CAgBhD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,2BAA2B,GACvC,OAAO,0BAA0B,EACjC,MAAM,yBAAyB,KAC7B,OAAO,CAAC,2BAA2B,CAYrC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;QA9I/C;;;;;;WAMG;;;;QAwBH;;;;;WAKG;;QAEH,gFAAgF;;QAEhF,mFAAmF;;;;;;CAoHtC,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,GAAI,MAAM,yBAAyB,KAAG,SAGtF,CAAC"}
|