@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
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* Cross-process suite for the WebSocket read loop's **frame envelope** — what
|
|
4
|
+
* each spine answers to a frame before anything dispatches, pinned over a real
|
|
5
|
+
* upgrade. The HTTP twin is `rpc_adversarial`'s envelope cases
|
|
6
|
+
* (`create_rpc_envelope_cases`); a socket classifies its frames in its own
|
|
7
|
+
* loop (TS `register_action_ws`, Rust `fuz_realtime`'s `ws_endpoint`), so the
|
|
8
|
+
* HTTP pins say nothing about it.
|
|
9
|
+
*
|
|
10
|
+
* - **a parse error** — a frame that is not JSON answers `parse_error` with
|
|
11
|
+
* `id: null`, and the socket keeps serving
|
|
12
|
+
* - **a non-object frame** — a JSON scalar answers `invalid_request` with
|
|
13
|
+
* `id: null` (the scalar is not read as its own id)
|
|
14
|
+
* - **a batch array** — answers one `invalid_request` with `id: null`; batches
|
|
15
|
+
* are not supported on either transport
|
|
16
|
+
* - **a notification** — a string method with no id answers no frame
|
|
17
|
+
* - **a stray response** — a `{id, result}` frame matching no server-initiated
|
|
18
|
+
* request answers no frame (it demuxes as a peer response and is dropped)
|
|
19
|
+
* - **`cancel`** — the notification answers no frame: for an unknown id, for
|
|
20
|
+
* malformed params, and for a request in flight, which keeps running and
|
|
21
|
+
* answers under its id once it completes (neither spine's `peer/ping`
|
|
22
|
+
* observes its signal, so the cancel's effect is invisible here; consumer
|
|
23
|
+
* suites with a signal-observing seam pin it)
|
|
24
|
+
*
|
|
25
|
+
* **Silence is asserted positively**: each case marks the received-message
|
|
26
|
+
* count, sends its frames, then round-trips a `heartbeat` probe and reads back
|
|
27
|
+
* everything after the mark. The socket is ordered, so a frame that should
|
|
28
|
+
* produce nothing leaves exactly the probe's response, and the probe doubles as
|
|
29
|
+
* proof the socket survived the frame.
|
|
30
|
+
*
|
|
31
|
+
* Wire codes are independent copies of the producers' constants — parity by
|
|
32
|
+
* test. Gated on `capabilities.ws`; the in-flight cancel also on
|
|
33
|
+
* `capabilities.peer_request` (it holds a request with `peer/ping`).
|
|
34
|
+
*
|
|
35
|
+
* Cross-process only: `create_ws_transport` needs a real bound socket, so wire
|
|
36
|
+
* it from a `*.cross.test.ts` file.
|
|
37
|
+
*
|
|
38
|
+
* @module
|
|
39
|
+
*/
|
|
40
|
+
import { assert, describe } from 'vitest';
|
|
41
|
+
import { create_jsonrpc_request } from '../../http/jsonrpc_helpers.js';
|
|
42
|
+
import { is_response_for } from '../transports/ws_client.js';
|
|
43
|
+
import { test_if } from './capabilities.js';
|
|
44
|
+
import { open_session_ws } from './ws_endpoint.js';
|
|
45
|
+
import { create_holding_peer_ping_responder } from './ws_inbound_dispatch.js';
|
|
46
|
+
const JSONRPC_VERSION = '2.0';
|
|
47
|
+
const PARSE_ERROR = -32700;
|
|
48
|
+
const INVALID_REQUEST = -32600;
|
|
49
|
+
const HEARTBEAT_METHOD = 'heartbeat';
|
|
50
|
+
const PEER_PING_METHOD = 'peer/ping';
|
|
51
|
+
const CANCEL_METHOD = 'cancel';
|
|
52
|
+
/** How long the test waits on a frame — above the server's peer-request deadline. */
|
|
53
|
+
const FRAME_TIMEOUT_MS = 12_000;
|
|
54
|
+
const frame_id = (frame) => typeof frame === 'object' && frame !== null ? frame.id : undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Send `frames`, round-trip a `heartbeat` probe, and return every frame that
|
|
57
|
+
* arrived after the mark except the probe's response.
|
|
58
|
+
*/
|
|
59
|
+
const frames_after = async (ws, frames) => {
|
|
60
|
+
const mark = ws.messages.length;
|
|
61
|
+
const probe_id = `probe-${mark}`;
|
|
62
|
+
for (const frame of frames) {
|
|
63
|
+
await ('text' in frame ? ws.send_text(frame.text) : ws.send(frame.json));
|
|
64
|
+
}
|
|
65
|
+
await ws.send(create_jsonrpc_request(HEARTBEAT_METHOD, undefined, probe_id));
|
|
66
|
+
await ws.wait_for(is_response_for(probe_id), FRAME_TIMEOUT_MS);
|
|
67
|
+
return ws.messages.slice(mark).filter((frame) => frame_id(frame) !== probe_id);
|
|
68
|
+
};
|
|
69
|
+
const REFUSED_FRAME_CASES = [
|
|
70
|
+
{
|
|
71
|
+
name: 'a frame that is not JSON',
|
|
72
|
+
frame: { text: '{"jsonrpc": "2.0", "id": 1,' },
|
|
73
|
+
code: PARSE_ERROR
|
|
74
|
+
},
|
|
75
|
+
{ name: 'a scalar frame', frame: { json: 5 }, code: INVALID_REQUEST },
|
|
76
|
+
{ name: 'a bare string frame', frame: { json: HEARTBEAT_METHOD }, code: INVALID_REQUEST },
|
|
77
|
+
{
|
|
78
|
+
name: 'a batch array',
|
|
79
|
+
frame: { json: [create_jsonrpc_request(HEARTBEAT_METHOD, undefined, 1)] },
|
|
80
|
+
code: INVALID_REQUEST
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
const SILENT_FRAME_CASES = [
|
|
84
|
+
{
|
|
85
|
+
name: 'a notification',
|
|
86
|
+
frames: [{ json: { jsonrpc: JSONRPC_VERSION, method: HEARTBEAT_METHOD } }]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'a stray response matching no server request',
|
|
90
|
+
frames: [{ json: { jsonrpc: JSONRPC_VERSION, id: 'stray', result: {} } }]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'a cancel for an unknown id',
|
|
94
|
+
frames: [
|
|
95
|
+
{ json: { jsonrpc: JSONRPC_VERSION, method: CANCEL_METHOD, params: { request_id: 'nope' } } }
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'a cancel with malformed params',
|
|
100
|
+
frames: [
|
|
101
|
+
{ json: { jsonrpc: JSONRPC_VERSION, method: CANCEL_METHOD, params: { request_id: true } } },
|
|
102
|
+
{ json: { jsonrpc: JSONRPC_VERSION, method: CANCEL_METHOD } }
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
/**
|
|
107
|
+
* Register the WS frame-envelope cases. Gated on `capabilities.ws`; the
|
|
108
|
+
* in-flight cancel also on `capabilities.peer_request`.
|
|
109
|
+
*/
|
|
110
|
+
export const describe_ws_envelope_cross_tests = (options) => {
|
|
111
|
+
const { setup_test, capabilities } = options;
|
|
112
|
+
const open_ws = (fixture) => open_session_ws(options, fixture, { admitted: true, default_timeout_ms: FRAME_TIMEOUT_MS });
|
|
113
|
+
describe('ws frame envelope (cross-process)', () => {
|
|
114
|
+
for (const { name, frame, code } of REFUSED_FRAME_CASES) {
|
|
115
|
+
test_if(capabilities.ws, `${name} answers ${code} with id null`, async () => {
|
|
116
|
+
const fixture = await setup_test();
|
|
117
|
+
const ws = await open_ws(fixture);
|
|
118
|
+
try {
|
|
119
|
+
const frames = await frames_after(ws, [frame]);
|
|
120
|
+
assert.lengthOf(frames, 1, `expected one refusal, got ${JSON.stringify(frames)}`);
|
|
121
|
+
const answer = frames[0];
|
|
122
|
+
assert.deepStrictEqual({ jsonrpc: answer.jsonrpc, id: answer.id, code: answer.error?.code }, { jsonrpc: JSONRPC_VERSION, id: null, code }, `refusal envelope: ${JSON.stringify(answer)}`);
|
|
123
|
+
assert.strictEqual(ws.close_code, null, 'the refusal never closes the socket');
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
await ws.close();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
for (const { name, frames: sent } of SILENT_FRAME_CASES) {
|
|
131
|
+
test_if(capabilities.ws, `${name} answers no frame`, async () => {
|
|
132
|
+
const fixture = await setup_test();
|
|
133
|
+
const ws = await open_ws(fixture);
|
|
134
|
+
try {
|
|
135
|
+
const frames = await frames_after(ws, sent);
|
|
136
|
+
assert.lengthOf(frames, 0, `expected no frame, got ${JSON.stringify(frames)}`);
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
await ws.close();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
test_if(capabilities.ws && capabilities.peer_request, 'a cancel for a request in flight answers no frame; the request answers under its id', async () => {
|
|
144
|
+
const fixture = await setup_test();
|
|
145
|
+
const { responder, release, pinged } = create_holding_peer_ping_responder();
|
|
146
|
+
const ws = await open_session_ws(options, fixture, {
|
|
147
|
+
admitted: true,
|
|
148
|
+
on_request: responder,
|
|
149
|
+
default_timeout_ms: FRAME_TIMEOUT_MS
|
|
150
|
+
});
|
|
151
|
+
try {
|
|
152
|
+
const id = 'held';
|
|
153
|
+
await ws.send(create_jsonrpc_request(PEER_PING_METHOD, { nonce: 41 }, id));
|
|
154
|
+
// the server pinged back: the request is dispatched and waiting
|
|
155
|
+
await pinged(1);
|
|
156
|
+
const frames = await frames_after(ws, [
|
|
157
|
+
{
|
|
158
|
+
json: { jsonrpc: JSONRPC_VERSION, method: CANCEL_METHOD, params: { request_id: id } }
|
|
159
|
+
}
|
|
160
|
+
]);
|
|
161
|
+
assert.lengthOf(frames, 0, `expected no frame, got ${JSON.stringify(frames)}`);
|
|
162
|
+
release();
|
|
163
|
+
const answer = await ws.wait_for(is_response_for(id));
|
|
164
|
+
assert.deepStrictEqual(answer.result?.nonce, 41, `the cancelled request's answer: ${JSON.stringify(answer)}`);
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
release();
|
|
168
|
+
await ws.close();
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import '../assert_dev_env.js';
|
|
2
|
+
import { type WsRequestResponder } from '../transports/ws_client.js';
|
|
2
3
|
import { type BackendCapabilities } from './capabilities.js';
|
|
3
4
|
import type { SetupTest } from './setup.js';
|
|
4
5
|
import { type WsEndpointTarget } from './ws_endpoint.js';
|
|
@@ -9,6 +10,21 @@ export interface WsInboundDispatchCrossTestOptions extends WsEndpointTarget {
|
|
|
9
10
|
/** Backend capability flags; every case gates on `capabilities.peer_request`. */
|
|
10
11
|
readonly capabilities: BackendCapabilities;
|
|
11
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* A client responder that withholds every server-initiated `peer/ping` echo
|
|
15
|
+
* until `release` — so each client `peer/ping` stays in flight on the server —
|
|
16
|
+
* and answers at once after it. Shared with the WS envelope suite's cancel
|
|
17
|
+
* cases.
|
|
18
|
+
*
|
|
19
|
+
* @returns the responder, its `release`, and `pinged(count)`, resolving once
|
|
20
|
+
* `count` pings have reached the client
|
|
21
|
+
*/
|
|
22
|
+
export declare const create_holding_peer_ping_responder: () => {
|
|
23
|
+
responder: WsRequestResponder;
|
|
24
|
+
release: () => void;
|
|
25
|
+
/** Resolves once `count` pings have reached the client. */
|
|
26
|
+
pinged: (count: number) => Promise<void>;
|
|
27
|
+
};
|
|
12
28
|
/**
|
|
13
29
|
* Register the duplicate-id and in-flight-ceiling cases. Gated on
|
|
14
30
|
* `capabilities.peer_request` (the cases hold requests with `peer/ping`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws_inbound_dispatch.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_inbound_dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ws_inbound_dispatch.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_inbound_dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAmC9B,OAAO,EAKN,KAAK,kBAAkB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AACzD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAiB1E,oEAAoE;AACpE,MAAM,WAAW,iCAAkC,SAAQ,gBAAgB;IAC1E,yEAAyE;IACzE,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,iFAAiF;IACjF,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;CAC3C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,QAAO;IACrD,SAAS,EAAE,kBAAkB,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,2DAA2D;IAC3D,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CA0BzC,CAAC;AA4BF;;;GAGG;AACH,eAAO,MAAM,wCAAwC,GACpD,SAAS,iCAAiC,KACxC,IAsGF,CAAC"}
|
|
@@ -48,9 +48,13 @@ const FRAME_TIMEOUT_MS = 12_000;
|
|
|
48
48
|
/**
|
|
49
49
|
* A client responder that withholds every server-initiated `peer/ping` echo
|
|
50
50
|
* until `release` — so each client `peer/ping` stays in flight on the server —
|
|
51
|
-
* and answers at once after it.
|
|
51
|
+
* and answers at once after it. Shared with the WS envelope suite's cancel
|
|
52
|
+
* cases.
|
|
53
|
+
*
|
|
54
|
+
* @returns the responder, its `release`, and `pinged(count)`, resolving once
|
|
55
|
+
* `count` pings have reached the client
|
|
52
56
|
*/
|
|
53
|
-
const
|
|
57
|
+
export const create_holding_peer_ping_responder = () => {
|
|
54
58
|
let release;
|
|
55
59
|
const released = new Promise((resolve) => {
|
|
56
60
|
release = resolve;
|
|
@@ -110,7 +114,7 @@ export const describe_ws_inbound_dispatch_cross_tests = (options) => {
|
|
|
110
114
|
describe('ws inbound dispatch refusals (cross-process)', () => {
|
|
111
115
|
test_if(capabilities.peer_request, 'a request reusing a live id is refused with that id; the first keeps it, then the id frees', async () => {
|
|
112
116
|
const fixture = await setup_test();
|
|
113
|
-
const { responder, release, pinged } =
|
|
117
|
+
const { responder, release, pinged } = create_holding_peer_ping_responder();
|
|
114
118
|
const ws = await open_ws(fixture, responder);
|
|
115
119
|
try {
|
|
116
120
|
const id = 'held';
|
|
@@ -140,7 +144,7 @@ export const describe_ws_inbound_dispatch_cross_tests = (options) => {
|
|
|
140
144
|
});
|
|
141
145
|
test_if(capabilities.peer_request, 'past the in-flight ceiling a request is shed with queue_overflow and the socket keeps serving', async () => {
|
|
142
146
|
const fixture = await setup_test();
|
|
143
|
-
const { responder, release } =
|
|
147
|
+
const { responder, release } = create_holding_peer_ping_responder();
|
|
144
148
|
const ws = await open_ws(fixture, responder);
|
|
145
149
|
try {
|
|
146
150
|
for (let n = 0; n < MAX_INBOUND_DISPATCHES; n++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws_outbound_overflow.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_outbound_overflow.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ws_outbound_overflow.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_outbound_overflow.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4E9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AACzD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA+E1E,sDAAsD;AACtD,MAAM,WAAW,kCAAmC,SAAQ,gBAAgB;IAC3E,yEAAyE;IACzE,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,iFAAiF;IACjF,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,yCAAyC,GACrD,SAAS,kCAAkC,KACzC,IAqNF,CAAC"}
|
|
@@ -4,11 +4,11 @@ import '../assert_dev_env.js';
|
|
|
4
4
|
* real upgrade.
|
|
5
5
|
*
|
|
6
6
|
* Both spines hold what waits to be written to one WebSocket to a byte budget
|
|
7
|
-
* (`
|
|
7
|
+
* (`ConnectionRegistry`'s `outbound_queue_bytes` on the TS side, the
|
|
8
8
|
* Rust `fuz_realtime` outbound queue on the other; both default to 4 MiB, each
|
|
9
9
|
* waiting frame charged its UTF-8 length plus 64 bytes). A frame that does not
|
|
10
|
-
* fit closes the socket with `WS_CLOSE_OUTBOUND_OVERFLOW` and
|
|
11
|
-
* `
|
|
10
|
+
* fit closes the socket with `WS_CLOSE_OUTBOUND_OVERFLOW` and
|
|
11
|
+
* `WS_CLOSE_OUTBOUND_OVERFLOW_REASON`; the credential stays good, so a client reconnects
|
|
12
12
|
* under its ordinary backoff. The code and the reason are therefore wire
|
|
13
13
|
* contract, and this suite is the pin that runs on both.
|
|
14
14
|
*
|
|
@@ -59,15 +59,12 @@ import '../assert_dev_env.js';
|
|
|
59
59
|
*/
|
|
60
60
|
import { assert, describe } from 'vitest';
|
|
61
61
|
import { create_jsonrpc_request } from '../../http/jsonrpc_helpers.js';
|
|
62
|
+
import { WS_CLOSE_OUTBOUND_OVERFLOW, WS_CLOSE_OUTBOUND_OVERFLOW_REASON } from '../../actions/transports.js';
|
|
62
63
|
import { create_admitted_ws_transport } from '../transports/ws_transport.js';
|
|
63
64
|
import { is_notification, is_response_for } from '../transports/ws_client.js';
|
|
64
65
|
import { test_if } from './capabilities.js';
|
|
65
66
|
import { cross_rpc_call } from './cross_rpc.js';
|
|
66
67
|
import { open_session_ws } from './ws_endpoint.js';
|
|
67
|
-
/** The close code both spines send on an outbound overflow. */
|
|
68
|
-
const WS_CLOSE_OUTBOUND_OVERFLOW = 4005;
|
|
69
|
-
/** The close reason both spines send with it. */
|
|
70
|
-
const OUTBOUND_OVERFLOW_REASON = 'outbound queue overflow';
|
|
71
68
|
const FLOOD_METHOD = '_testing_flood_notifications';
|
|
72
69
|
const FLOOD_NOTIFICATION_METHOD = '_testing_flood';
|
|
73
70
|
const HEARTBEAT_METHOD = 'heartbeat';
|
|
@@ -214,7 +211,7 @@ export const describe_ws_outbound_overflow_cross_tests = (options) => {
|
|
|
214
211
|
const closed = await client.wait_for_close(CLOSE_TIMEOUT_MS);
|
|
215
212
|
assert.ok(closed, 'the flooded socket did not close');
|
|
216
213
|
assert.strictEqual(client.close_code, WS_CLOSE_OUTBOUND_OVERFLOW);
|
|
217
|
-
assert.strictEqual(client.close_reason,
|
|
214
|
+
assert.strictEqual(client.close_reason, WS_CLOSE_OUTBOUND_OVERFLOW_REASON);
|
|
218
215
|
// the response of the request whose handler overflowed is not sent
|
|
219
216
|
assert.strictEqual(client.messages.some(is_response_for('overflows')), false, 'no response may follow an overflow');
|
|
220
217
|
// frames accepted before the overflow may or may not arrive; any
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../assert_dev_env.js';
|
|
2
2
|
/**
|
|
3
3
|
* Cross-process **role-gated WebSocket** suite — a socket admitted by an
|
|
4
|
-
* endpoint's role gate (`
|
|
4
|
+
* endpoint's role gate (`register_action_ws`'s `required_roles`) loses it
|
|
5
5
|
* with the role.
|
|
6
6
|
*
|
|
7
7
|
* A role gate decides who may hold a socket, and so who receives the
|
|
@@ -11,7 +11,7 @@ import '../assert_dev_env.js';
|
|
|
11
11
|
* listed role is revoked — with `WS_CLOSE_PERMISSION_REVOKED`, not the
|
|
12
12
|
* session-revoked code, since the credential is still good — and send nothing
|
|
13
13
|
* after the close. The ungated sockets of the same account, on the same
|
|
14
|
-
*
|
|
14
|
+
* registry, stay open: the gate is per endpoint, not per account. A scoped
|
|
15
15
|
* grant never admits at a role gate, so revoking one closes nothing.
|
|
16
16
|
*
|
|
17
17
|
* Runs against a backend that mounts, beside its ungated `ws_path`, a second
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ws_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAuH9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AAItE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAKzD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAK1E,2DAA2D;AAC3D,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAClE;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,wFAAwF;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,4FAA4F;IAC5F,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAClD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,yBAAyB,KAAG,IAwdpF,CAAC"}
|
|
@@ -19,7 +19,7 @@ import '../assert_dev_env.js';
|
|
|
19
19
|
* every WS endpoint — so the suite needs no knowledge of a consumer's domain
|
|
20
20
|
* WS methods. It validates the transport, not the domain.
|
|
21
21
|
*
|
|
22
|
-
* Three cases mirror the upgrade
|
|
22
|
+
* Three cases mirror the upgrade route `register_action_ws` mounts (origin
|
|
23
23
|
* check → `require_auth` → dispatch): an authenticated upgrade round-trips
|
|
24
24
|
* `heartbeat` (the first case), and an anonymous upgrade and a
|
|
25
25
|
* disallowed-origin upgrade are refused (after the spine-parity cases).
|
|
@@ -37,7 +37,7 @@ import '../assert_dev_env.js';
|
|
|
37
37
|
* shapes (absent, `{}`) and refuses a declared param with `invalid_params`, and a
|
|
38
38
|
* message over the backend's cap (`max_message_bytes`, default
|
|
39
39
|
* `DEFAULT_WS_MAX_MESSAGE_BYTES`) closes the socket with
|
|
40
|
-
* `WS_CLOSE_MESSAGE_TOO_BIG`.
|
|
40
|
+
* `WS_CLOSE_MESSAGE_TOO_BIG` and `WS_CLOSE_MESSAGE_TOO_BIG_REASON`.
|
|
41
41
|
*
|
|
42
42
|
* The cases after the refused upgrades (gated on `rpc_path`) cover
|
|
43
43
|
* server-initiated close.
|
|
@@ -82,7 +82,7 @@ import '../assert_dev_env.js';
|
|
|
82
82
|
import { assert, describe } from 'vitest';
|
|
83
83
|
import { assert_rejects } from '@fuzdev/fuz_util/testing.ts';
|
|
84
84
|
import { heartbeat_action_spec } from '../../actions/heartbeat.js';
|
|
85
|
-
import { DEFAULT_WS_MAX_MESSAGE_BYTES, WS_CLOSE_MESSAGE_TOO_BIG, WS_CLOSE_SESSION_REVOKED, WS_CLOSE_SESSION_REVOKED_REASON } from '../../actions/transports.js';
|
|
85
|
+
import { DEFAULT_WS_MAX_MESSAGE_BYTES, WS_CLOSE_MESSAGE_TOO_BIG, WS_CLOSE_MESSAGE_TOO_BIG_REASON, WS_CLOSE_SESSION_REVOKED, WS_CLOSE_SESSION_REVOKED_REASON } from '../../actions/transports.js';
|
|
86
86
|
import { account_session_revoke_all_action_spec, account_token_create_action_spec, account_token_revoke_action_spec, TokenCreateOutput, TokenRevokeOutput } from '../../auth/account_action_specs.js';
|
|
87
87
|
import { DEFAULT_MAX_TOKENS } from '../../auth/account_route_schema.js';
|
|
88
88
|
import { account_delete_action_spec } from '../../auth/admin_action_specs.js';
|
|
@@ -219,7 +219,8 @@ export const describe_cross_process_ws_tests = (options) => {
|
|
|
219
219
|
}
|
|
220
220
|
});
|
|
221
221
|
// Both spines cap an inbound message (`DEFAULT_WS_MAX_MESSAGE_BYTES` by
|
|
222
|
-
// default) and close the socket on a larger one rather than replying
|
|
222
|
+
// default) and close the socket on a larger one rather than replying,
|
|
223
|
+
// lingering so the close frame and its reason arrive.
|
|
223
224
|
test_if(capabilities.ws, 'an oversized message closes the socket with WS_CLOSE_MESSAGE_TOO_BIG', async () => {
|
|
224
225
|
const client = await open_authed();
|
|
225
226
|
try {
|
|
@@ -232,6 +233,7 @@ export const describe_cross_process_ws_tests = (options) => {
|
|
|
232
233
|
const closed = await client.wait_for_close(5000);
|
|
233
234
|
assert.ok(closed, 'socket did not close within 5s of an oversized message');
|
|
234
235
|
assert.strictEqual(client.close_code, WS_CLOSE_MESSAGE_TOO_BIG);
|
|
236
|
+
assert.strictEqual(client.close_reason, WS_CLOSE_MESSAGE_TOO_BIG_REASON);
|
|
235
237
|
}
|
|
236
238
|
finally {
|
|
237
239
|
// the server may reset the connection under the unread tail
|
|
@@ -1,28 +1,34 @@
|
|
|
1
|
+
import './assert_dev_env.js';
|
|
1
2
|
/**
|
|
2
|
-
* Daemon
|
|
3
|
-
*
|
|
4
|
-
* Provides daemon info schema, PID file management, and process lifecycle
|
|
5
|
-
* operations. Separates lifecycle from presentation — `stop_daemon` returns
|
|
6
|
-
* a result object instead of logging directly.
|
|
3
|
+
* Daemon-info file plumbing for the testing servers — `~/.{name}/run/daemon.json`,
|
|
4
|
+
* written at startup and read for stale-process detection.
|
|
7
5
|
*
|
|
8
6
|
* @module
|
|
9
7
|
*/
|
|
10
8
|
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
11
|
-
import {
|
|
9
|
+
import type { CommandDeps, EnvDeps, FsReadDeps, FsWriteDeps, LogDeps } from '../runtime/deps.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get an app's home directory path (`~/.{name}`).
|
|
12
|
+
*
|
|
13
|
+
* @param runtime - runtime with `env_get` capability
|
|
14
|
+
* @param name - application name (e.g., `"tx"`, `"zzz"`)
|
|
15
|
+
* @returns path to the app directory, or null if `$HOME` is not set
|
|
16
|
+
*/
|
|
17
|
+
export declare const get_app_dir: (runtime: Pick<EnvDeps, "env_get">, name: string) => string | null;
|
|
12
18
|
/**
|
|
13
19
|
* Daemon info schema for `~/.{name}/run/daemon.json`, a strict
|
|
14
20
|
* `@fuzdev/fuz_schema` object schema.
|
|
15
21
|
*/
|
|
16
22
|
export declare const DaemonInfo: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
17
23
|
version: number;
|
|
18
|
-
pid: number;
|
|
19
24
|
port: number;
|
|
25
|
+
pid: number;
|
|
20
26
|
started: string;
|
|
21
27
|
app_version: string;
|
|
22
28
|
}, {
|
|
23
29
|
version: number;
|
|
24
|
-
pid: number;
|
|
25
30
|
port: number;
|
|
31
|
+
pid: number;
|
|
26
32
|
started: string;
|
|
27
33
|
app_version: string;
|
|
28
34
|
}, "object", {
|
|
@@ -72,42 +78,4 @@ export declare const read_daemon_info: (runtime: Pick<EnvDeps, "env_get"> & Pick
|
|
|
72
78
|
* @returns `true` if the process is running
|
|
73
79
|
*/
|
|
74
80
|
export declare const is_daemon_running: (runtime: CommandDeps, pid: number) => Promise<boolean>;
|
|
75
|
-
|
|
76
|
-
* Check if a daemon is healthy by probing its `/health` endpoint.
|
|
77
|
-
*
|
|
78
|
-
* Complements `is_daemon_running` (PID check) with an HTTP liveness probe.
|
|
79
|
-
* Requires the daemon to register a `/health` route (e.g. via `create_health_route_spec`).
|
|
80
|
-
*
|
|
81
|
-
* @param deps - runtime with fetch capability
|
|
82
|
-
* @param port - port the daemon should be listening on
|
|
83
|
-
* @param host - hostname (default `localhost`)
|
|
84
|
-
* @param timeout_ms - request timeout in milliseconds (default 2000)
|
|
85
|
-
* @returns `true` if the health endpoint responds with 2xx
|
|
86
|
-
*/
|
|
87
|
-
export declare const check_daemon_health: (deps: FetchDeps, port: number, host?: string, timeout_ms?: number) => Promise<boolean>;
|
|
88
|
-
/**
|
|
89
|
-
* Result of a `stop_daemon` operation.
|
|
90
|
-
*/
|
|
91
|
-
export interface StopDaemonResult {
|
|
92
|
-
/** Whether a daemon was stopped. */
|
|
93
|
-
stopped: boolean;
|
|
94
|
-
/** PID of the stopped daemon, if any. */
|
|
95
|
-
pid?: number;
|
|
96
|
-
/** Human-readable message describing the outcome. */
|
|
97
|
-
message: string;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Stop a running daemon by sending SIGTERM and cleaning up the PID file.
|
|
101
|
-
*
|
|
102
|
-
* Returns a result object instead of logging directly, separating
|
|
103
|
-
* lifecycle from presentation. Errors removing the PID file are swallowed
|
|
104
|
-
* (the daemon's own shutdown handler may have removed it concurrently).
|
|
105
|
-
*
|
|
106
|
-
* @param runtime - runtime with command, file, and env capabilities
|
|
107
|
-
* @param name - application name
|
|
108
|
-
* @returns result describing the outcome
|
|
109
|
-
* @mutates filesystem - removes `~/.{name}/run/daemon.json` on success or when corrupt
|
|
110
|
-
* @mutates external process - sends `SIGTERM` to the daemon process via `kill`
|
|
111
|
-
*/
|
|
112
|
-
export declare const stop_daemon: (runtime: Pick<EnvDeps, "env_get"> & Pick<FsReadDeps, "stat" | "read_text_file"> & FsRemoveDeps & CommandDeps & LogDeps, name: string) => Promise<StopDaemonResult>;
|
|
113
|
-
//# sourceMappingURL=daemon.d.ts.map
|
|
81
|
+
//# sourceMappingURL=daemon_info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon_info.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/daemon_info.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;GAKG;AAEH,OAAO,EAMN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGjG;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,IAGtF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;IACtB,sBAAsB;;IAEtB,yBAAyB;;IAEzB,uCAAuC;;IAEvC,yCAAyC;;IAEzC,0CAA0C;;EAEzC,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAChC,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EACjC,MAAM,MAAM,KACV,MAAM,GAAG,IAGX,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC7B,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,QAAQ,CAAC,EAC7F,MAAM,MAAM,EACZ,MAAM,UAAU,KACd,OAAO,CAAC,IAAI,CAWd,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC5B,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAAC,GAAG,OAAO,EACzF,MAAM,MAAM,KACV,OAAO,CAAC,UAAU,GAAG,IAAI,CAwB3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,SAAS,WAAW,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,OAAO,CAG1F,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import './assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* Daemon-info file plumbing for the testing servers — `~/.{name}/run/daemon.json`,
|
|
4
|
+
* written at startup and read for stale-process detection.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { format_issue, number, object, parse, string } from '@fuzdev/fuz_schema/schema.ts';
|
|
9
|
+
import { write_file_atomic } from '../runtime/fs.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get an app's home directory path (`~/.{name}`).
|
|
12
|
+
*
|
|
13
|
+
* @param runtime - runtime with `env_get` capability
|
|
14
|
+
* @param name - application name (e.g., `"tx"`, `"zzz"`)
|
|
15
|
+
* @returns path to the app directory, or null if `$HOME` is not set
|
|
16
|
+
*/
|
|
17
|
+
export const get_app_dir = (runtime, name) => {
|
|
18
|
+
const home = runtime.env_get('HOME');
|
|
19
|
+
return home ? `${home}/.${name}` : null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Daemon info schema for `~/.{name}/run/daemon.json`, a strict
|
|
23
|
+
* `@fuzdev/fuz_schema` object schema.
|
|
24
|
+
*/
|
|
25
|
+
export const DaemonInfo = object({
|
|
26
|
+
/** Schema version. */
|
|
27
|
+
version: number,
|
|
28
|
+
/** Server process ID. */
|
|
29
|
+
pid: number,
|
|
30
|
+
/** Port the server is listening on. */
|
|
31
|
+
port: number,
|
|
32
|
+
/** ISO timestamp when server started. */
|
|
33
|
+
started: string,
|
|
34
|
+
/** Package version of the application. */
|
|
35
|
+
app_version: string
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Get the daemon info file path (`~/.{name}/run/daemon.json`).
|
|
39
|
+
*
|
|
40
|
+
* @param runtime - runtime with `env_get` capability
|
|
41
|
+
* @param name - application name
|
|
42
|
+
* @returns path to `daemon.json`, or null if `$HOME` is not set
|
|
43
|
+
*/
|
|
44
|
+
export const get_daemon_info_path = (runtime, name) => {
|
|
45
|
+
const app_dir = get_app_dir(runtime, name);
|
|
46
|
+
return app_dir ? `${app_dir}/run/daemon.json` : null;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Write daemon info to the PID file, creating directories as needed.
|
|
50
|
+
*
|
|
51
|
+
* @param runtime - runtime with file write and env capabilities
|
|
52
|
+
* @param name - application name
|
|
53
|
+
* @param info - daemon info to write
|
|
54
|
+
* @mutates filesystem - creates `~/.{name}/run/` and atomically writes `daemon.json`
|
|
55
|
+
* @throws Error if `$HOME` is not set
|
|
56
|
+
*/
|
|
57
|
+
export const write_daemon_info = async (runtime, name, info) => {
|
|
58
|
+
const app_dir = get_app_dir(runtime, name);
|
|
59
|
+
if (!app_dir) {
|
|
60
|
+
throw new Error('$HOME not set');
|
|
61
|
+
}
|
|
62
|
+
const run_dir = `${app_dir}/run`;
|
|
63
|
+
await runtime.mkdir(run_dir, { recursive: true });
|
|
64
|
+
const content = JSON.stringify(info, null, '\t');
|
|
65
|
+
await write_file_atomic(runtime, `${run_dir}/daemon.json`, content + '\n');
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Read and validate daemon info from the PID file.
|
|
69
|
+
*
|
|
70
|
+
* @param runtime - runtime with file read and env capabilities
|
|
71
|
+
* @param name - application name
|
|
72
|
+
* @returns parsed daemon info, or null if missing or invalid
|
|
73
|
+
*/
|
|
74
|
+
export const read_daemon_info = async (runtime, name) => {
|
|
75
|
+
const daemon_path = get_daemon_info_path(runtime, name);
|
|
76
|
+
if (!daemon_path) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const stat = await runtime.stat(daemon_path);
|
|
80
|
+
if (!stat) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const content = await runtime.read_text_file(daemon_path);
|
|
85
|
+
const parsed = JSON.parse(content);
|
|
86
|
+
const result = parse(DaemonInfo, parsed);
|
|
87
|
+
if (!result.ok) {
|
|
88
|
+
runtime.warn(`Invalid daemon.json: ${result.issues.map(format_issue).join('; ')}`);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return result.value;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
runtime.warn('Failed to parse daemon.json');
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Check if a process is running by PID.
|
|
100
|
+
*
|
|
101
|
+
* @param runtime - runtime with command execution capability
|
|
102
|
+
* @param pid - process ID to check
|
|
103
|
+
* @returns `true` if the process is running
|
|
104
|
+
*/
|
|
105
|
+
export const is_daemon_running = async (runtime, pid) => {
|
|
106
|
+
const result = await runtime.run_command('kill', ['-0', String(pid)]);
|
|
107
|
+
return result.success;
|
|
108
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
2
|
import { write_file_atomic } from '../runtime/fs.js';
|
|
3
|
-
import { get_app_dir } from '
|
|
3
|
+
import { get_app_dir } from './daemon_info.js';
|
|
4
4
|
import { generate_daemon_token } from '../auth/daemon_token.js';
|
|
5
5
|
import { resolve_keeper_account_id } from '../auth/daemon_token_middleware.js';
|
|
6
6
|
/** Default rotation interval in milliseconds (30 seconds). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_exposure.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/data_exposure.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAqB7B,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"data_exposure.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/data_exposure.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAqB7B,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAiBrE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAC;AAIvE;;;;;GAKG;AACH,eAAO,MAAM,kCAAkC,GAAI,QAAQ,OAAO,KAAG,GAAG,CAAC,MAAM,CAuB9E,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,yCAAyC,GACrD,SAAS,UAAU,EACnB,mBAAkB,aAAa,CAAC,MAAM,CAA6B,KACjE,IAWF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wCAAwC,GACpD,SAAS,UAAU,EACnB,oBAAmB,aAAa,CAAC,MAAM,CAA8B,KACnE,IAgBF,CAAC;AAIF,kDAAkD;AAClD,MAAM,WAAW,uBAAuB;IACvC,kEAAkE;IAClE,UAAU,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,2FAA2F;IAC3F,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,iGAAiG;IACjG,iBAAiB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,kDAAkD;IAClD,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,uBAAuB,KAAG,IA0L/E,CAAC"}
|
|
@@ -17,6 +17,7 @@ import './assert_dev_env.js';
|
|
|
17
17
|
*/
|
|
18
18
|
import { describe, test, beforeAll, assert } from 'vitest';
|
|
19
19
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
20
|
+
import { create_test_request_headers } from './test_origin.js';
|
|
20
21
|
import { resolve_valid_path, generate_valid_body, to_route_content_type } from './schema_generators.js';
|
|
21
22
|
import { is_null_schema, is_strict_object_schema } from '../http/schema_helpers.js';
|
|
22
23
|
import { is_keeper_auth, is_public_auth } from '../http/auth_shape.js';
|
|
@@ -142,11 +143,9 @@ export const describe_data_exposure_tests = (options) => {
|
|
|
142
143
|
const url = resolve_valid_path(spec.path, spec.params);
|
|
143
144
|
const res = await fixture.transport(url, {
|
|
144
145
|
method: spec.method,
|
|
145
|
-
headers: {
|
|
146
|
-
host: 'localhost',
|
|
147
|
-
origin: 'http://localhost:5173',
|
|
146
|
+
headers: create_test_request_headers({
|
|
148
147
|
'content-type': to_route_content_type(spec)
|
|
149
|
-
}
|
|
148
|
+
})
|
|
150
149
|
});
|
|
151
150
|
if (res.headers.get('Content-Type')?.includes('text/event-stream')) {
|
|
152
151
|
await res.body?.cancel();
|
package/dist/testing/db.js
CHANGED
|
@@ -11,10 +11,10 @@ import './assert_dev_env.js';
|
|
|
11
11
|
* ```ts
|
|
12
12
|
* import {create_default_db_factory, create_pg_factory} from '@fuzdev/fuz_app/testing/db.ts';
|
|
13
13
|
* import {run_migrations} from '@fuzdev/fuz_app/db/migrate.ts';
|
|
14
|
-
* import {
|
|
14
|
+
* import {AUTH_MIGRATION_NS} from '@fuzdev/fuz_app/auth/migrations.ts';
|
|
15
15
|
*
|
|
16
16
|
* const init_schema = async (db) => {
|
|
17
|
-
* await run_migrations(db, [
|
|
17
|
+
* await run_migrations(db, [AUTH_MIGRATION_NS]);
|
|
18
18
|
* };
|
|
19
19
|
* const default_factory = create_default_db_factory(init_schema);
|
|
20
20
|
* const pg_factory = create_pg_factory(init_schema, process.env.TEST_DATABASE_URL);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAkB1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAKpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAkB1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAKpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAK1D;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;OAIG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;;;;;;OASG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,kEAAkE;IAClE,YAAY,EAAE,mBAAmB,CAAC;IAClC;;;;OAIG;IACH,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;;;;;OAYG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,mCAAmC,GAC/C,SAAS,8BAA8B,KACrC,IA28CF,CAAC"}
|