@fuzdev/fuz_app 0.179.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 +5 -5
|
@@ -77,7 +77,7 @@ import '../assert_dev_env.js';
|
|
|
77
77
|
*/
|
|
78
78
|
import { describe, test, assert } from 'vitest';
|
|
79
79
|
import { ERROR_RATE_LIMIT_EXCEEDED } from '../../http/error_schemas.js';
|
|
80
|
-
import { raw_http_exchange, raw_http_parse_response } from '../transports/raw_http.js';
|
|
80
|
+
import { raw_http_exchange, raw_http_parse_response, raw_http_request } from '../transports/raw_http.js';
|
|
81
81
|
import { default_login_account_rate_limit, default_login_ip_rate_limit } from '../../rate_limiter.js';
|
|
82
82
|
import { list_audit_events } from './audit_cross_helpers.js';
|
|
83
83
|
import { SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_PASSWORD_PATH } from './spine_surface_constants.js';
|
|
@@ -306,15 +306,18 @@ export const describe_login_security_cross_tests = (options) => {
|
|
|
306
306
|
// fresh spoofed address and answer 401.
|
|
307
307
|
const url = new URL(base_url);
|
|
308
308
|
const body = JSON.stringify({ username: 'probe_xff_lines', password: PROBE_PASSWORD });
|
|
309
|
-
const request =
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
309
|
+
const request = raw_http_request({
|
|
310
|
+
method: 'POST',
|
|
311
|
+
path: login_path,
|
|
312
|
+
host: url.host,
|
|
313
|
+
header_lines: [
|
|
314
|
+
'content-type: application/json',
|
|
315
|
+
`x-forwarded-for: ${XFF_SPOOFED_LINE}`,
|
|
316
|
+
`x-forwarded-for: ${XFF_REPEATED_LINES}`,
|
|
317
|
+
'connection: close'
|
|
318
|
+
],
|
|
319
|
+
body
|
|
320
|
+
});
|
|
318
321
|
const { received } = await raw_http_exchange(base_url, request, {
|
|
319
322
|
read_timeout_ms: LOGIN_RAW_READ_TIMEOUT_MS,
|
|
320
323
|
until: 'response'
|
|
@@ -11,7 +11,7 @@ export interface PeerPingWsTestOptions extends WsEndpointTarget {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Register the server-initiated `peer/ping` suite — a positive round-trip
|
|
14
|
-
* plus the security negatives
|
|
14
|
+
* plus the security negatives
|
|
15
15
|
* (unsolicited-response rejection, per-connection id isolation, never-reply
|
|
16
16
|
* `Timeout`, wrong-shape reply rejection, plus client-error forwarding, the
|
|
17
17
|
* reading of a malformed client error, and the HTTP no-transport path).
|
|
@@ -23,7 +23,7 @@ import '../assert_dev_env.js';
|
|
|
23
23
|
* `WsClient.send` to inject unsolicited / cross-connection frames.
|
|
24
24
|
*
|
|
25
25
|
* **Per-spec auth.** `peer/ping` is `auth: public` (a liveness echo is
|
|
26
|
-
* non-sensitive
|
|
26
|
+
* non-sensitive); the WS upgrade itself still
|
|
27
27
|
* authenticates, so the suite drives it over the keeper's session.
|
|
28
28
|
*
|
|
29
29
|
* Gated on `capabilities.peer_request`, which a backend declares once it
|
|
@@ -62,7 +62,7 @@ const ISOLATION_DEADLINE_MS = 5000;
|
|
|
62
62
|
const valid_reply = (nonce) => ({ nonce, protocol_version: 1 });
|
|
63
63
|
/**
|
|
64
64
|
* Register the server-initiated `peer/ping` suite — a positive round-trip
|
|
65
|
-
* plus the security negatives
|
|
65
|
+
* plus the security negatives
|
|
66
66
|
* (unsolicited-response rejection, per-connection id isolation, never-reply
|
|
67
67
|
* `Timeout`, wrong-shape reply rejection, plus client-error forwarding, the
|
|
68
68
|
* reading of a malformed client error, and the HTTP no-transport path).
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
3
|
+
import type { HeaderRead } from '../../http/request_headers.js';
|
|
4
|
+
/** One reader's reading in the table: `"absent"`, `"refused"`, or `{"one": value}`. */
|
|
5
|
+
export declare const RequestHeaderConformanceRead: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
6
|
+
one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
7
|
+
}>]>;
|
|
8
|
+
export type RequestHeaderConformanceRead = Infer<typeof RequestHeaderConformanceRead>;
|
|
9
|
+
/** What a request observably does — refused with a code, or authenticated as a credential. */
|
|
10
|
+
export declare const RequestHeaderConformanceOutcome: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
11
|
+
refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
|
|
12
|
+
}>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
13
|
+
authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
|
|
14
|
+
}>]>;
|
|
15
|
+
export type RequestHeaderConformanceOutcome = Infer<typeof RequestHeaderConformanceOutcome>;
|
|
16
|
+
/** One row of the table. */
|
|
17
|
+
export declare const RequestHeaderConformanceRow: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
18
|
+
name: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
19
|
+
lines: import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
20
|
+
read: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
21
|
+
origin: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
22
|
+
one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
23
|
+
}>]>;
|
|
24
|
+
browser_context: import("@fuzdev/fuz_schema/schema.ts").BooleanSchema;
|
|
25
|
+
host: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
26
|
+
one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
27
|
+
}>]>;
|
|
28
|
+
content_type: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
29
|
+
one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
30
|
+
}>]>;
|
|
31
|
+
}>;
|
|
32
|
+
post: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
33
|
+
refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
|
|
34
|
+
}>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
35
|
+
authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
|
|
36
|
+
}>]>>;
|
|
37
|
+
upgrade: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
38
|
+
refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
|
|
39
|
+
}>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
40
|
+
authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
|
|
41
|
+
}>]>>;
|
|
42
|
+
upgrade_runtime_refusal: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["empty_host"]>>;
|
|
43
|
+
wire_reason: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
44
|
+
note: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
45
|
+
}>;
|
|
46
|
+
export type RequestHeaderConformanceRow = Infer<typeof RequestHeaderConformanceRow>;
|
|
47
|
+
/** The placeholder names a row may use, each written `{name}` in the table. */
|
|
48
|
+
export declare const REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS: readonly ["cookie_name", "session_cookie", "api_token", "daemon_token", "host", "foreign_host", "origin", "foreign_origin"];
|
|
49
|
+
/** A placeholder name — see `REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS`. */
|
|
50
|
+
export type RequestHeaderConformancePlaceholder = (typeof REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS)[number];
|
|
51
|
+
/** The value each placeholder takes on one leg. */
|
|
52
|
+
export type RequestHeaderConformancePlaceholders = Readonly<Record<RequestHeaderConformancePlaceholder, string>>;
|
|
53
|
+
/** The table, a `@fuzdev/fuz_schema` `object`. */
|
|
54
|
+
export declare const RequestHeaderConformance: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
55
|
+
unit_placeholders: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
56
|
+
cookie_name: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
57
|
+
session_cookie: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
58
|
+
api_token: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
59
|
+
daemon_token: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
60
|
+
host: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
61
|
+
foreign_host: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
62
|
+
origin: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
63
|
+
foreign_origin: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
64
|
+
}>;
|
|
65
|
+
rows: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<{
|
|
66
|
+
name: string;
|
|
67
|
+
lines: string[];
|
|
68
|
+
read: {
|
|
69
|
+
origin: "absent" | "refused" | {
|
|
70
|
+
one: string;
|
|
71
|
+
};
|
|
72
|
+
browser_context: boolean;
|
|
73
|
+
host: "absent" | "refused" | {
|
|
74
|
+
one: string;
|
|
75
|
+
};
|
|
76
|
+
content_type: "absent" | "refused" | {
|
|
77
|
+
one: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
post?: {
|
|
81
|
+
refused: "forbidden_origin" | "forbidden_host" | "unsupported_content_type";
|
|
82
|
+
} | {
|
|
83
|
+
authenticates: "session" | "api_token" | "daemon_token" | null;
|
|
84
|
+
} | undefined;
|
|
85
|
+
upgrade?: {
|
|
86
|
+
refused: "forbidden_origin" | "forbidden_host" | "unsupported_content_type";
|
|
87
|
+
} | {
|
|
88
|
+
authenticates: "session" | "api_token" | "daemon_token" | null;
|
|
89
|
+
} | undefined;
|
|
90
|
+
upgrade_runtime_refusal?: "empty_host" | undefined;
|
|
91
|
+
wire_reason?: string | undefined;
|
|
92
|
+
note?: string | undefined;
|
|
93
|
+
}[], import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
94
|
+
name: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
95
|
+
lines: import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
96
|
+
read: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
97
|
+
origin: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
98
|
+
one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
99
|
+
}>]>;
|
|
100
|
+
browser_context: import("@fuzdev/fuz_schema/schema.ts").BooleanSchema;
|
|
101
|
+
host: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
102
|
+
one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
103
|
+
}>]>;
|
|
104
|
+
content_type: import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"absent">, import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"refused">, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
105
|
+
one: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
106
|
+
}>]>;
|
|
107
|
+
}>;
|
|
108
|
+
post: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
109
|
+
refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
|
|
110
|
+
}>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
111
|
+
authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
|
|
112
|
+
}>]>>;
|
|
113
|
+
upgrade: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").UnionSchema<readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
114
|
+
refused: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["forbidden_host", "forbidden_origin", "unsupported_content_type"]>;
|
|
115
|
+
}>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
116
|
+
authenticates: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["session", "api_token", "daemon_token"]>>;
|
|
117
|
+
}>]>>;
|
|
118
|
+
upgrade_runtime_refusal: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["empty_host"]>>;
|
|
119
|
+
wire_reason: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
120
|
+
note: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
|
|
121
|
+
}>>>;
|
|
122
|
+
}>;
|
|
123
|
+
export type RequestHeaderConformance = Infer<typeof RequestHeaderConformance>;
|
|
124
|
+
/** The committed table, resolved relative to this module. */
|
|
125
|
+
export declare const REQUEST_HEADER_CONFORMANCE_URL: URL;
|
|
126
|
+
/**
|
|
127
|
+
* Read and parse the committed table, and check each row is either a wire
|
|
128
|
+
* row (`post` and `upgrade`) or names why it isn't (`wire_reason`).
|
|
129
|
+
*
|
|
130
|
+
* @throws Error when the file is off the schema, or a row is neither
|
|
131
|
+
*/
|
|
132
|
+
export declare const load_request_header_conformance: () => RequestHeaderConformance;
|
|
133
|
+
/**
|
|
134
|
+
* Fill a row's `{placeholders}`.
|
|
135
|
+
*
|
|
136
|
+
* @throws Error on a placeholder this leg has no value for
|
|
137
|
+
*/
|
|
138
|
+
export declare const fill_request_header_conformance_placeholders: (text: string, placeholders: RequestHeaderConformancePlaceholders) => string;
|
|
139
|
+
/** A reading in the table's spelling, its `one` value filled. */
|
|
140
|
+
export declare const fill_request_header_conformance_read: (read: RequestHeaderConformanceRead, placeholders: RequestHeaderConformancePlaceholders) => RequestHeaderConformanceRead;
|
|
141
|
+
/** A reader's `HeaderRead` in the table's spelling. */
|
|
142
|
+
export declare const to_request_header_conformance_read: (read: HeaderRead<string>) => RequestHeaderConformanceRead;
|
|
143
|
+
/** One header line, split at its first `:` and its value stripped of SP and HTAB, as a request-head parser reads it. */
|
|
144
|
+
export interface ParsedHeaderLine {
|
|
145
|
+
/** The name as written. */
|
|
146
|
+
readonly name: string;
|
|
147
|
+
/** The value, outer SP and HTAB stripped. */
|
|
148
|
+
readonly value: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Split a `Name: value` line.
|
|
152
|
+
*
|
|
153
|
+
* @throws Error on a line with no `:` — the table holds none
|
|
154
|
+
*/
|
|
155
|
+
export declare const parse_request_header_line: (line: string) => ParsedHeaderLine;
|
|
156
|
+
/**
|
|
157
|
+
* The values of one header among `lines`, in order — what `get_header_lines`
|
|
158
|
+
* answers on a runtime with a per-line view.
|
|
159
|
+
*
|
|
160
|
+
* @param lines - `Name: value` lines
|
|
161
|
+
* @param name - the header name, in any case
|
|
162
|
+
*/
|
|
163
|
+
export declare const request_header_values: (lines: ReadonlyArray<string>, name: string) => Array<string>;
|
|
164
|
+
/**
|
|
165
|
+
* Fold `lines` to one line per name, in the order each name first appears —
|
|
166
|
+
* the view a runtime without a per-line view gives: the Fetch `Headers` value,
|
|
167
|
+
* its lines joined with `, ` (`; ` for `Cookie`), then stripped of SP and HTAB
|
|
168
|
+
* at both ends as `get_header_lines` strips every line.
|
|
169
|
+
*
|
|
170
|
+
* @param lines - `Name: value` lines
|
|
171
|
+
* @returns one `Name: value` line per name
|
|
172
|
+
*/
|
|
173
|
+
export declare const fold_header_lines: (lines: ReadonlyArray<string>) => Array<string>;
|
|
174
|
+
//# sourceMappingURL=request_header_conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request_header_conformance.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/request_header_conformance.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAkD9B,OAAO,EAaN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAStC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,uFAAuF;AACvF,eAAO,MAAM,4BAA4B;;IAIvC,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEtF,8FAA8F;AAC9F,eAAO,MAAM,+BAA+B;;;;IAK1C,CAAC;AACH,MAAM,MAAM,+BAA+B,GAAG,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAE5F,4BAA4B;AAC5B,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;EActC,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEpF,+EAA+E;AAC/E,eAAO,MAAM,uCAAuC,6HAS1C,CAAC;AAEX,0EAA0E;AAC1E,MAAM,MAAM,mCAAmC,GAC9C,CAAC,OAAO,uCAAuC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,mDAAmD;AACnD,MAAM,MAAM,oCAAoC,GAAG,QAAQ,CAC1D,MAAM,CAAC,mCAAmC,EAAE,MAAM,CAAC,CACnD,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYnC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE9E,6DAA6D;AAC7D,eAAO,MAAM,8BAA8B,EAAE,GAG5C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,QAAO,wBAqBlD,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,4CAA4C,GACxD,MAAM,MAAM,EACZ,cAAc,oCAAoC,KAChD,MAMA,CAAC;AAEJ,iEAAiE;AACjE,eAAO,MAAM,oCAAoC,GAChD,MAAM,4BAA4B,EAClC,cAAc,oCAAoC,KAChD,4BAG8E,CAAC;AAElF,uDAAuD;AACvD,eAAO,MAAM,kCAAkC,GAC9C,MAAM,UAAU,CAAC,MAAM,CAAC,KACtB,4BAAuF,CAAC;AAE3F,wHAAwH;AACxH,MAAM,WAAW,gBAAgB;IAChC,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,MAAM,MAAM,KAAG,gBAOxD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GACjC,OAAO,aAAa,CAAC,MAAM,CAAC,EAC5B,MAAM,MAAM,KACV,KAAK,CAAC,MAAM,CAMd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,aAAa,CAAC,MAAM,CAAC,KAAG,KAAK,CAAC,MAAM,CAY5E,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* The request header conformance table: how both spines read `Origin`,
|
|
4
|
+
* `Referer`, `Host` and `Content-Type` — the gates' inputs — and what a
|
|
5
|
+
* request carrying given lines of them observably does.
|
|
6
|
+
*
|
|
7
|
+
* `request_header_conformance.json` (beside this module) holds one row per
|
|
8
|
+
* case, `{name, lines, read, post?, upgrade?, upgrade_runtime_refusal?,
|
|
9
|
+
* wire_reason?, note?}`:
|
|
10
|
+
*
|
|
11
|
+
* - **lines** — header lines, each `Name: value`, one byte per character (a
|
|
12
|
+
* character U+0080–U+00FF is that byte on the wire). A name may repeat.
|
|
13
|
+
* - **read** — each reader's reading of exactly those lines
|
|
14
|
+
* (`http/request_headers.ts`, the Rust `fuz_http::request_headers`):
|
|
15
|
+
* `origin`, `host` and `content_type` are `"absent"`, `"refused"`, or
|
|
16
|
+
* `{"one": value}` (`HeaderRead`; a content type's value is its lowercased
|
|
17
|
+
* essence), and `browser_context` whether an `Origin` or `Referer` line is
|
|
18
|
+
* there at all.
|
|
19
|
+
* - **post** and **upgrade** — what the request does on the wire, sent as an
|
|
20
|
+
* RPC `POST` and as a WebSocket upgrade: `{"refused": code}`, or
|
|
21
|
+
* `{"authenticates": credential}` (`null` for none). The wire leg adds a
|
|
22
|
+
* `Host` naming the server when the row has no `Host` line, and
|
|
23
|
+
* `Content-Type: application/json` on the `POST` when it has no
|
|
24
|
+
* `Content-Type` line, so a row says only what it is about. Where one
|
|
25
|
+
* request trips several gates the row pins which answers: the host gate,
|
|
26
|
+
* then the origin check, then the content type, then the credential legs.
|
|
27
|
+
* - **upgrade_runtime_refusal** — a runtime trait the row's upgrade meets
|
|
28
|
+
* before the app runs on a backend declaring it
|
|
29
|
+
* (`BackendCapabilities.ws_upgrade_runtime_refusals`).
|
|
30
|
+
* - **wire_reason** — present instead of `post` and `upgrade` on a row the
|
|
31
|
+
* wire leg can't send as the row means it; the unit legs still read it.
|
|
32
|
+
*
|
|
33
|
+
* The legs: the TS unit test over the readers (`src/test/http/`), the Rust
|
|
34
|
+
* unit test beside `fuz_http::request_headers` over a byte-identical copy of
|
|
35
|
+
* the file, and `request_header_conformance_wire.ts`, sending each row to a
|
|
36
|
+
* live backend. Both unit legs also hold every row **join-invariant**: the
|
|
37
|
+
* reading of its lines equals the reading of the same lines folded to one
|
|
38
|
+
* line per name (`fold_header_lines`) — the view Bun and an in-process
|
|
39
|
+
* `app.request` give the spine — which is what lets one expected column hold
|
|
40
|
+
* on every runtime.
|
|
41
|
+
*
|
|
42
|
+
* Live values are per leg, so lines name them with `{placeholders}`
|
|
43
|
+
* (`REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS`); the unit legs fill them from
|
|
44
|
+
* the table's own `unit_placeholders`. Edited by hand, never generated.
|
|
45
|
+
*
|
|
46
|
+
* @module
|
|
47
|
+
*/
|
|
48
|
+
import { readFileSync } from 'node:fs';
|
|
49
|
+
import { array, boolean, literal, min_length, nullable, object, one_of, optional, parse_or_throw, pipe, string, union } from '@fuzdev/fuz_schema/schema.ts';
|
|
50
|
+
import { BUILTIN_CREDENTIAL_TYPES } from '../../auth/credential_type_schema.js';
|
|
51
|
+
import { ERROR_FORBIDDEN_HOST, ERROR_FORBIDDEN_ORIGIN, ERROR_UNSUPPORTED_CONTENT_TYPE } from '../../http/error_schemas.js';
|
|
52
|
+
import { trim_optional_whitespace } from '../../http/header_lines.js';
|
|
53
|
+
import { WS_UPGRADE_RUNTIME_REFUSALS } from './capabilities.js';
|
|
54
|
+
/** One reader's reading in the table: `"absent"`, `"refused"`, or `{"one": value}`. */
|
|
55
|
+
export const RequestHeaderConformanceRead = union([
|
|
56
|
+
literal('absent'),
|
|
57
|
+
literal('refused'),
|
|
58
|
+
object({ one: string })
|
|
59
|
+
]);
|
|
60
|
+
/** What a request observably does — refused with a code, or authenticated as a credential. */
|
|
61
|
+
export const RequestHeaderConformanceOutcome = union([
|
|
62
|
+
object({
|
|
63
|
+
refused: one_of([ERROR_FORBIDDEN_HOST, ERROR_FORBIDDEN_ORIGIN, ERROR_UNSUPPORTED_CONTENT_TYPE])
|
|
64
|
+
}),
|
|
65
|
+
object({ authenticates: nullable(one_of(BUILTIN_CREDENTIAL_TYPES)) })
|
|
66
|
+
]);
|
|
67
|
+
/** One row of the table. */
|
|
68
|
+
export const RequestHeaderConformanceRow = object({
|
|
69
|
+
name: string,
|
|
70
|
+
lines: array(string),
|
|
71
|
+
read: object({
|
|
72
|
+
origin: RequestHeaderConformanceRead,
|
|
73
|
+
browser_context: boolean,
|
|
74
|
+
host: RequestHeaderConformanceRead,
|
|
75
|
+
content_type: RequestHeaderConformanceRead
|
|
76
|
+
}),
|
|
77
|
+
post: optional(RequestHeaderConformanceOutcome),
|
|
78
|
+
upgrade: optional(RequestHeaderConformanceOutcome),
|
|
79
|
+
upgrade_runtime_refusal: optional(one_of(WS_UPGRADE_RUNTIME_REFUSALS)),
|
|
80
|
+
wire_reason: optional(string),
|
|
81
|
+
note: optional(string)
|
|
82
|
+
});
|
|
83
|
+
/** The placeholder names a row may use, each written `{name}` in the table. */
|
|
84
|
+
export const REQUEST_HEADER_CONFORMANCE_PLACEHOLDERS = [
|
|
85
|
+
'cookie_name',
|
|
86
|
+
'session_cookie',
|
|
87
|
+
'api_token',
|
|
88
|
+
'daemon_token',
|
|
89
|
+
'host',
|
|
90
|
+
'foreign_host',
|
|
91
|
+
'origin',
|
|
92
|
+
'foreign_origin'
|
|
93
|
+
];
|
|
94
|
+
/** The table, a `@fuzdev/fuz_schema` `object`. */
|
|
95
|
+
export const RequestHeaderConformance = object({
|
|
96
|
+
unit_placeholders: object({
|
|
97
|
+
cookie_name: string,
|
|
98
|
+
session_cookie: string,
|
|
99
|
+
api_token: string,
|
|
100
|
+
daemon_token: string,
|
|
101
|
+
host: string,
|
|
102
|
+
foreign_host: string,
|
|
103
|
+
origin: string,
|
|
104
|
+
foreign_origin: string
|
|
105
|
+
}),
|
|
106
|
+
rows: pipe(array(RequestHeaderConformanceRow), min_length(1))
|
|
107
|
+
});
|
|
108
|
+
/** The committed table, resolved relative to this module. */
|
|
109
|
+
export const REQUEST_HEADER_CONFORMANCE_URL = new URL('./request_header_conformance.json', import.meta.url);
|
|
110
|
+
/**
|
|
111
|
+
* Read and parse the committed table, and check each row is either a wire
|
|
112
|
+
* row (`post` and `upgrade`) or names why it isn't (`wire_reason`).
|
|
113
|
+
*
|
|
114
|
+
* @throws Error when the file is off the schema, or a row is neither
|
|
115
|
+
*/
|
|
116
|
+
export const load_request_header_conformance = () => {
|
|
117
|
+
const table = parse_or_throw(RequestHeaderConformance, JSON.parse(readFileSync(REQUEST_HEADER_CONFORMANCE_URL, 'utf8')));
|
|
118
|
+
for (const row of table.rows) {
|
|
119
|
+
const wire = row.post !== undefined && row.upgrade !== undefined;
|
|
120
|
+
const unit_only = row.wire_reason !== undefined && row.post === undefined && row.upgrade === undefined;
|
|
121
|
+
if (wire === unit_only) {
|
|
122
|
+
throw new Error(`request header conformance row '${row.name}': give both \`post\` and \`upgrade\`, or a \`wire_reason\` and neither`);
|
|
123
|
+
}
|
|
124
|
+
if (row.upgrade_runtime_refusal !== undefined && !wire) {
|
|
125
|
+
throw new Error(`request header conformance row '${row.name}': \`upgrade_runtime_refusal\` on a row the wire leg doesn't send`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return table;
|
|
129
|
+
};
|
|
130
|
+
const PLACEHOLDER_REGEX = /\{([a-z_]+)\}/g;
|
|
131
|
+
/**
|
|
132
|
+
* Fill a row's `{placeholders}`.
|
|
133
|
+
*
|
|
134
|
+
* @throws Error on a placeholder this leg has no value for
|
|
135
|
+
*/
|
|
136
|
+
export const fill_request_header_conformance_placeholders = (text, placeholders) => text.replace(PLACEHOLDER_REGEX, (_match, name) => {
|
|
137
|
+
if (!Object.hasOwn(placeholders, name)) {
|
|
138
|
+
throw new Error(`unknown request header conformance placeholder {${name}}`);
|
|
139
|
+
}
|
|
140
|
+
return placeholders[name];
|
|
141
|
+
});
|
|
142
|
+
/** A reading in the table's spelling, its `one` value filled. */
|
|
143
|
+
export const fill_request_header_conformance_read = (read, placeholders) => typeof read === 'string'
|
|
144
|
+
? read
|
|
145
|
+
: { one: fill_request_header_conformance_placeholders(read.one, placeholders) };
|
|
146
|
+
/** A reader's `HeaderRead` in the table's spelling. */
|
|
147
|
+
export const to_request_header_conformance_read = (read) => (read.kind === 'one' ? { one: read.value } : read.kind);
|
|
148
|
+
/**
|
|
149
|
+
* Split a `Name: value` line.
|
|
150
|
+
*
|
|
151
|
+
* @throws Error on a line with no `:` — the table holds none
|
|
152
|
+
*/
|
|
153
|
+
export const parse_request_header_line = (line) => {
|
|
154
|
+
const colon = line.indexOf(':');
|
|
155
|
+
if (colon <= 0)
|
|
156
|
+
throw new Error(`not a header line: ${JSON.stringify(line)}`);
|
|
157
|
+
return {
|
|
158
|
+
name: line.slice(0, colon),
|
|
159
|
+
value: trim_optional_whitespace(line.slice(colon + 1))
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* The values of one header among `lines`, in order — what `get_header_lines`
|
|
164
|
+
* answers on a runtime with a per-line view.
|
|
165
|
+
*
|
|
166
|
+
* @param lines - `Name: value` lines
|
|
167
|
+
* @param name - the header name, in any case
|
|
168
|
+
*/
|
|
169
|
+
export const request_header_values = (lines, name) => {
|
|
170
|
+
const lower = name.toLowerCase();
|
|
171
|
+
return lines
|
|
172
|
+
.map(parse_request_header_line)
|
|
173
|
+
.filter((line) => line.name.toLowerCase() === lower)
|
|
174
|
+
.map((line) => line.value);
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Fold `lines` to one line per name, in the order each name first appears —
|
|
178
|
+
* the view a runtime without a per-line view gives: the Fetch `Headers` value,
|
|
179
|
+
* its lines joined with `, ` (`; ` for `Cookie`), then stripped of SP and HTAB
|
|
180
|
+
* at both ends as `get_header_lines` strips every line.
|
|
181
|
+
*
|
|
182
|
+
* @param lines - `Name: value` lines
|
|
183
|
+
* @returns one `Name: value` line per name
|
|
184
|
+
*/
|
|
185
|
+
export const fold_header_lines = (lines) => {
|
|
186
|
+
const folded = new Map();
|
|
187
|
+
for (const line of lines.map(parse_request_header_line)) {
|
|
188
|
+
const key = line.name.toLowerCase();
|
|
189
|
+
const entry = folded.get(key);
|
|
190
|
+
if (entry)
|
|
191
|
+
entry.values.push(line.value);
|
|
192
|
+
else
|
|
193
|
+
folded.set(key, { name: line.name, values: [line.value] });
|
|
194
|
+
}
|
|
195
|
+
return [...folded.entries()].map(([key, { name, values }]) => `${name}: ${trim_optional_whitespace(values.join(key === 'cookie' ? '; ' : ', '))}`);
|
|
196
|
+
};
|