@fuzdev/fuz_app 0.180.0 → 0.182.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 +38 -20
- package/dist/actions/action_rpc.d.ts +25 -6
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +56 -48
- package/dist/actions/action_types.d.ts +31 -13
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +1 -1
- package/dist/actions/notification_sender.d.ts +83 -0
- package/dist/actions/notification_sender.d.ts.map +1 -0
- package/dist/actions/notification_sender.js +85 -0
- package/dist/actions/perform_action.d.ts +13 -4
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +27 -18
- package/dist/actions/register_action_ws.d.ts +20 -2
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +17 -5
- package/dist/actions/ws_socket_session.d.ts +3 -0
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +3 -2
- package/dist/auth/CLAUDE.md +84 -59
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +30 -3
- package/dist/auth/account_queries.d.ts +213 -2
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +255 -2
- 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 +5 -7
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +110 -89
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +117 -25
- package/dist/auth/api_token_queries.d.ts +29 -12
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +42 -27
- 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 +37 -32
- 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 +39 -30
- package/dist/auth/deps.d.ts +10 -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 +97 -76
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +93 -104
- package/dist/auth/resolved_auth.d.ts +10 -5
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +2 -2
- package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +5 -3
- package/dist/auth/role_grant_offer_actions.d.ts +7 -11
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +97 -106
- 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_notifications.d.ts +87 -38
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +75 -22
- package/dist/auth/role_grant_offer_queries.d.ts +143 -9
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +266 -66
- package/dist/auth/role_grant_offer_schema.js +1 -1
- package/dist/auth/role_grant_queries.d.ts +57 -10
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +81 -22
- package/dist/auth/role_grant_sql.d.ts +21 -0
- package/dist/auth/role_grant_sql.d.ts.map +1 -1
- package/dist/auth/role_grant_sql.js +21 -0
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +9 -2
- 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 +95 -14
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +98 -19
- 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/standard_rpc_actions.d.ts +6 -19
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +5 -6
- package/dist/auth/token_scope.d.ts +6 -8
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +6 -9
- 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 +156 -48
- package/dist/http/auth_shape.d.ts +4 -4
- 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 +45 -22
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +53 -26
- 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 +299 -83
- 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 +4 -4
- package/dist/server/app_server.d.ts +54 -33
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +69 -41
- package/dist/server/serve_fact_route.d.ts +3 -3
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +59 -55
- 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 +406 -1202
- 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 +5 -9
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +3 -2
- 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 +320 -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.d.ts +1 -26
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +3 -7
- 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 +4 -10
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +11 -4
- 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 +5 -4
- 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 +185 -31
- 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 +82 -34
- 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 +3 -1
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +14 -7
- package/dist/testing/resolved_auth.d.ts +3 -1
- package/dist/testing/resolved_auth.d.ts.map +1 -1
- package/dist/testing/resolved_auth.js +4 -4
- 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 +13 -10
- 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/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +8 -4
- package/package.json +1 -1
|
@@ -71,14 +71,14 @@
|
|
|
71
71
|
* Auth shape on the cell-scoped route is `{account: 'none', actor: 'none'}`
|
|
72
72
|
* — the dispatcher's authorization phase is skipped for pure-public routes,
|
|
73
73
|
* so the handler builds the `RequestContext` itself from the resolved account
|
|
74
|
-
*
|
|
74
|
+
* (`get_public_account`, over what the `/api/*` auth middleware set) by
|
|
75
75
|
* resolving the caller's single actor and loading their role_grants.
|
|
76
76
|
* Unauthed callers pass through with `req_ctx: null` and are admitted only by
|
|
77
77
|
* a `cell.visibility === 'public'` cell whose `moderation` admits an audience (unmoderated or
|
|
78
78
|
* `'approved'`). Multi-actor accounts fall through with `req_ctx: null`
|
|
79
79
|
* — there's no `acting?` slot on a pure-public route, so multi-actor
|
|
80
80
|
* callers are treated as anonymous. A scope-narrowed API token is treated as
|
|
81
|
-
* anonymous too, not refused (`
|
|
81
|
+
* anonymous too, not refused (`get_public_account`): a narrowed token
|
|
82
82
|
* reaches no non-RPC surface, but on a route that admits anonymous callers
|
|
83
83
|
* a 403 would enforce nothing — the holder drops the `Authorization` header and
|
|
84
84
|
* re-reads every public cell anyway.
|
|
@@ -135,10 +135,10 @@ import { Readable } from 'node:stream';
|
|
|
135
135
|
import { join } from 'node:path';
|
|
136
136
|
import { ActingActor, FactHashSchema, Uuid } from '../primitive_schemas.js';
|
|
137
137
|
import { literal, object } from '@fuzdev/fuz_schema/schema.ts';
|
|
138
|
-
import { build_request_context,
|
|
138
|
+
import { build_request_context, get_public_account, has_scoped_role } from '../auth/request_context.js';
|
|
139
139
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
140
140
|
import { query_active_actors_by_account } from '../auth/account_queries.js';
|
|
141
|
-
import { define_route
|
|
141
|
+
import { define_route } from '../http/route_spec.js';
|
|
142
142
|
import { route_fail, route_raw } from '../http/route_result.js';
|
|
143
143
|
import { REST_INTERNAL_ERROR } from '../http/error_schemas.js';
|
|
144
144
|
import { query_get_fact, query_get_fact_meta } from '../db/fact_queries.js';
|
|
@@ -173,15 +173,16 @@ const cell_fact_params_schema = object({ cell_id: Uuid, hash: FactHashSchema });
|
|
|
173
173
|
* Returns 404 when the fact's metadata is missing, its embedded bytes have
|
|
174
174
|
* vanished (a race), or its disk file is missing, so the response shape is
|
|
175
175
|
* identical whether the fact is genuinely absent or merely unviewable; any
|
|
176
|
-
* other failure to open the disk file answers a logged 500.
|
|
177
|
-
*
|
|
178
|
-
*
|
|
176
|
+
* other failure to open the disk file answers a logged 500. A disk fact's body
|
|
177
|
+
* is a stream over the open file, whose cancel closes it: a `HEAD`, which
|
|
178
|
+
* opens the file and so answers the same statuses, is answered with the
|
|
179
|
+
* headers alone and the stream cancelled by the spine (`emit_route_response`).
|
|
179
180
|
*/
|
|
180
|
-
const serve_fact_bytes = async (
|
|
181
|
+
const serve_fact_bytes = async (route, hash, config) => {
|
|
181
182
|
const { facts_dir, x_accel, log } = config;
|
|
182
183
|
const meta = await query_get_fact_meta({ db: route.db }, hash);
|
|
183
184
|
if (!meta) {
|
|
184
|
-
return route_raw(
|
|
185
|
+
return route_raw({ status: 404 });
|
|
185
186
|
}
|
|
186
187
|
const content_type = meta.content_type ?? 'application/octet-stream';
|
|
187
188
|
const size = String(meta.size);
|
|
@@ -191,39 +192,46 @@ const serve_fact_bytes = async (c, route, hash, config) => {
|
|
|
191
192
|
if (!row || row.bytes === null) {
|
|
192
193
|
// Race: meta said embedded but bytes vanished. Treat as not-found.
|
|
193
194
|
log.warn(`serve_fact: embedded bytes missing for ${hash} (meta said embedded, row=${row ? 'present' : 'null'})`);
|
|
194
|
-
return route_raw(
|
|
195
|
+
return route_raw({ status: 404 });
|
|
195
196
|
}
|
|
196
197
|
const bytes = to_uint8(row.bytes);
|
|
197
|
-
return route_raw(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
return route_raw({
|
|
199
|
+
status: 200,
|
|
200
|
+
headers: {
|
|
201
|
+
'Content-Type': content_type,
|
|
202
|
+
'Content-Length': size,
|
|
203
|
+
'Cache-Control': FACT_CACHE_CONTROL,
|
|
204
|
+
...FACT_SECURITY_HEADERS
|
|
205
|
+
},
|
|
206
|
+
body: bytes
|
|
207
|
+
});
|
|
203
208
|
}
|
|
204
209
|
// External — defense-in-depth re-validate the URL before trusting it
|
|
205
210
|
// to address the filesystem: its shape, then that it is this hash's file
|
|
206
211
|
const parsed = parse_file_fact_url(meta.external_url);
|
|
207
212
|
if (!parsed) {
|
|
208
213
|
log.error(`serve_fact: external_url for ${hash} is not a file:<shard>/<rest> URL; answering 404`);
|
|
209
|
-
return route_raw(
|
|
214
|
+
return route_raw({ status: 404 });
|
|
210
215
|
}
|
|
211
216
|
if (!file_fact_url_addresses(parsed, hash)) {
|
|
212
217
|
log.error(`serve_fact: external_url for ${hash} addresses another fact's file; answering 404`);
|
|
213
|
-
return route_raw(
|
|
218
|
+
return route_raw({ status: 404 });
|
|
214
219
|
}
|
|
215
220
|
const { shard, rest } = parsed;
|
|
216
221
|
if (x_accel !== undefined) {
|
|
217
222
|
// Production: hand off to nginx via the validated `internal;` facts location.
|
|
218
223
|
// nginx answers with that location's own `add_header` set, not these
|
|
219
224
|
// headers, which is why the validator requires the fact pair there.
|
|
220
|
-
return route_raw(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
return route_raw({
|
|
226
|
+
status: 200,
|
|
227
|
+
headers: {
|
|
228
|
+
'Content-Type': content_type,
|
|
229
|
+
'Content-Length': size,
|
|
230
|
+
'Cache-Control': FACT_CACHE_CONTROL,
|
|
231
|
+
'X-Accel-Redirect': `${x_accel.redirect_prefix}${shard}/${rest}`,
|
|
232
|
+
...FACT_SECURITY_HEADERS
|
|
233
|
+
}
|
|
234
|
+
});
|
|
227
235
|
}
|
|
228
236
|
// Dev / tests: stream from disk. Open before committing the 200 so a
|
|
229
237
|
// missing file answers 404 and any other open failure a logged 500, as the
|
|
@@ -236,7 +244,7 @@ const serve_fact_bytes = async (c, route, hash, config) => {
|
|
|
236
244
|
catch (err) {
|
|
237
245
|
if (err.code === 'ENOENT') {
|
|
238
246
|
log.warn(`serve_fact: disk file for ${hash} is missing; answering 404`);
|
|
239
|
-
return route_raw(
|
|
247
|
+
return route_raw({ status: 404 });
|
|
240
248
|
}
|
|
241
249
|
log.error(`serve_fact: disk open for ${hash} failed`, err);
|
|
242
250
|
return route_fail(REST_INTERNAL_ERROR);
|
|
@@ -247,21 +255,17 @@ const serve_fact_bytes = async (c, route, hash, config) => {
|
|
|
247
255
|
'Cache-Control': FACT_CACHE_CONTROL,
|
|
248
256
|
...FACT_SECURITY_HEADERS
|
|
249
257
|
};
|
|
250
|
-
//
|
|
251
|
-
//
|
|
252
|
-
if (c.req.method === 'HEAD') {
|
|
253
|
-
await handle.close();
|
|
254
|
-
return route_raw(c.body(null, 200, headers));
|
|
255
|
-
}
|
|
258
|
+
// the stream's cancel closes the handle — what releases it on a `HEAD`, a
|
|
259
|
+
// refused answer, or a rolled-back one
|
|
256
260
|
const web_stream = Readable.toWeb(handle.createReadStream());
|
|
257
|
-
return route_raw(
|
|
261
|
+
return route_raw({ status: 200, headers, body: web_stream });
|
|
258
262
|
};
|
|
259
263
|
/**
|
|
260
264
|
* Resolve the caller's `RequestContext` on a pure-public route from the
|
|
261
|
-
*
|
|
262
|
-
* a scope-narrowed API token returns `null` — downgraded to anonymous, not
|
|
263
|
-
* refused (see the module doc).
|
|
264
|
-
* `AuthGate::public_request_context`.
|
|
265
|
+
* account the auth middleware resolved, read through `get_public_account`,
|
|
266
|
+
* so a scope-narrowed API token returns `null` — downgraded to anonymous, not
|
|
267
|
+
* refused (see the module doc). The account is that row, not read again. Twin
|
|
268
|
+
* of the Rust `AuthGate::public_request_context`.
|
|
265
269
|
*
|
|
266
270
|
* Multi-actor accounts return `null` (no `acting?` slot on a public route to
|
|
267
271
|
* disambiguate); single active-actor accounts resolve their actor and
|
|
@@ -270,15 +274,15 @@ const serve_fact_bytes = async (c, route, hash, config) => {
|
|
|
270
274
|
* count (`query_active_actors_by_account`), matching the acting-actor
|
|
271
275
|
* resolution path — a tombstoned actor is never resolvable here.
|
|
272
276
|
*/
|
|
273
|
-
const build_public_request_context = async (
|
|
277
|
+
const build_public_request_context = async (route) => {
|
|
274
278
|
// a narrowed token is the anonymous caller here, never a refusal
|
|
275
|
-
const
|
|
276
|
-
if (!
|
|
279
|
+
const account = get_public_account(route);
|
|
280
|
+
if (!account)
|
|
277
281
|
return null;
|
|
278
|
-
const actors = await query_active_actors_by_account({ db: route.db },
|
|
282
|
+
const actors = await query_active_actors_by_account({ db: route.db }, account.id);
|
|
279
283
|
if (actors.length !== 1)
|
|
280
284
|
return null;
|
|
281
|
-
return build_request_context({ db: route.db },
|
|
285
|
+
return build_request_context({ db: route.db }, account, actors[0]);
|
|
282
286
|
};
|
|
283
287
|
/**
|
|
284
288
|
* Build the cell-scoped `GET /api/cells/:cell_id/facts/:hash` `RouteSpec`
|
|
@@ -293,7 +297,7 @@ const build_public_request_context = async (c, route) => {
|
|
|
293
297
|
* other referrers.
|
|
294
298
|
*
|
|
295
299
|
* Pure-public auth — the handler builds the per-request `RequestContext`
|
|
296
|
-
* from the resolved account id (`
|
|
300
|
+
* from the resolved account id (`get_public_account`) and enforces
|
|
297
301
|
* visibility per-reference.
|
|
298
302
|
*/
|
|
299
303
|
export const create_serve_cell_fact_route_spec = (options) => {
|
|
@@ -309,18 +313,18 @@ export const create_serve_cell_fact_route_spec = (options) => {
|
|
|
309
313
|
input: literal(null),
|
|
310
314
|
// The body is a binary stream; no JSON output schema applies.
|
|
311
315
|
output: literal(null),
|
|
312
|
-
handler: async (
|
|
313
|
-
const { cell_id, hash } =
|
|
316
|
+
handler: async (route) => {
|
|
317
|
+
const { cell_id, hash } = route.params;
|
|
314
318
|
// Resolve the named cell. Missing / soft-deleted → 404 (masked).
|
|
315
319
|
const cell = await query_cell_get({ db: route.db }, cell_id);
|
|
316
320
|
if (!cell) {
|
|
317
|
-
return route_raw(
|
|
321
|
+
return route_raw({ status: 404 });
|
|
318
322
|
}
|
|
319
323
|
// Per-reference view check — scoped to *this* cell only. It runs
|
|
320
324
|
// before the edge check, so a cell the caller can't view does the
|
|
321
325
|
// same work, and answers the same 404, whether or not it references
|
|
322
326
|
// the hash — the edge stays unobservable to a non-viewer.
|
|
323
|
-
const req_ctx = await build_public_request_context(
|
|
327
|
+
const req_ctx = await build_public_request_context(route);
|
|
324
328
|
// Unauthenticated callers skip the grant fetch entirely — no grant
|
|
325
329
|
// can admit a null req_ctx (the only admit path is the
|
|
326
330
|
// public-visibility branch in `can_view_cell`, which doesn't read
|
|
@@ -334,16 +338,16 @@ export const create_serve_cell_fact_route_spec = (options) => {
|
|
|
334
338
|
if (!can_view_cell(req_ctx, cell, grants) &&
|
|
335
339
|
!(await cell_steward_admits({ db: route.db }, req_ctx, cell))) {
|
|
336
340
|
// 404 (not 403) so an unviewable cell→fact edge doesn't leak.
|
|
337
|
-
return route_raw(
|
|
341
|
+
return route_raw({ status: 404 });
|
|
338
342
|
}
|
|
339
343
|
// The cell→fact edge: the cell must actually reference the hash.
|
|
340
344
|
// `cell.refs` is auto-derived from `data` on every write, so this is
|
|
341
345
|
// the authoritative "does this cell reference these bytes" check.
|
|
342
346
|
// Missing edge → 404 (masked), never "exists elsewhere".
|
|
343
347
|
if (!cell.refs?.includes(hash)) {
|
|
344
|
-
return route_raw(
|
|
348
|
+
return route_raw({ status: 404 });
|
|
345
349
|
}
|
|
346
|
-
return serve_fact_bytes(
|
|
350
|
+
return serve_fact_bytes(route, hash, config);
|
|
347
351
|
}
|
|
348
352
|
});
|
|
349
353
|
};
|
|
@@ -392,18 +396,18 @@ export const create_serve_fact_route_spec = (options) => {
|
|
|
392
396
|
input: literal(null),
|
|
393
397
|
// The body is a binary stream; no JSON output schema applies.
|
|
394
398
|
output: literal(null),
|
|
395
|
-
handler: async (
|
|
396
|
-
const { hash } =
|
|
399
|
+
handler: async (route) => {
|
|
400
|
+
const { hash } = route.params;
|
|
397
401
|
// Defense-in-depth: the auth phase already gated this on the admin
|
|
398
402
|
// role, but re-check the resolved context so a mounting/auth-shape
|
|
399
403
|
// regression fails closed instead of serving by bare hash. Global
|
|
400
404
|
// grant only — a scoped `admin` row must not read every fact. It
|
|
401
405
|
// fires only on such a regression, so it fails loud as well.
|
|
402
|
-
if (!has_scoped_role(
|
|
406
|
+
if (!has_scoped_role(route.auth, ROLE_ADMIN, null)) {
|
|
403
407
|
log.error('bare-hash fact read reached the handler without a global admin grant — the auth gate did not run');
|
|
404
|
-
return route_raw(
|
|
408
|
+
return route_raw({ status: 404 });
|
|
405
409
|
}
|
|
406
|
-
return serve_fact_bytes(
|
|
410
|
+
return serve_fact_bytes(route, hash, config);
|
|
407
411
|
}
|
|
408
412
|
});
|
|
409
413
|
};
|
package/dist/server/static.d.ts
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
* - Step 2: `.html` fallback for clean URLs (`/about` → `/about.html`)
|
|
7
7
|
* - Step 3 (optional): SPA fallback for client-side routes
|
|
8
8
|
*
|
|
9
|
+
* The server routes on the raw request path (`get_request_path`), and a
|
|
10
|
+
* runtime's `serveStatic` refuses a path holding a `%` — it expects one the
|
|
11
|
+
* router already decoded. So a path with an escape is decoded here first
|
|
12
|
+
* (`to_static_file_path`) and handed to `serveStatic` as the file to serve;
|
|
13
|
+
* one with no escape goes to it as is. The SPA fallback names its file
|
|
14
|
+
* outright, so no step but the exact match hands `serveStatic` the request
|
|
15
|
+
* path.
|
|
16
|
+
*
|
|
9
17
|
* @module
|
|
10
18
|
*/
|
|
11
19
|
import type { MiddlewareHandler } from 'hono';
|
|
@@ -16,6 +24,8 @@ export interface ServeStaticOptions {
|
|
|
16
24
|
root: string;
|
|
17
25
|
rewriteRequestPath?: (path: string) => string;
|
|
18
26
|
mimes?: Record<string, string>;
|
|
27
|
+
/** The file to serve, relative to `root`, in place of the request's path. */
|
|
28
|
+
path?: string;
|
|
19
29
|
}
|
|
20
30
|
/**
|
|
21
31
|
* Factory function that creates a static file serving middleware.
|
|
@@ -23,6 +33,16 @@ export interface ServeStaticOptions {
|
|
|
23
33
|
* Matches the signature of `serveStatic` from `@hono/node-server/serve-static` and `@hono/bun`.
|
|
24
34
|
*/
|
|
25
35
|
export type ServeStaticFactory = (options: ServeStaticOptions) => MiddlewareHandler;
|
|
36
|
+
/**
|
|
37
|
+
* The file a raw request path names, each segment percent-decoded by
|
|
38
|
+
* `decodeURIComponent` — or `null`, no file, for an escape that doesn't
|
|
39
|
+
* decode, a segment that decodes to a `/` or a `%` (which `serveStatic`
|
|
40
|
+
* never served: it refused the router's decoded path holding either), and a
|
|
41
|
+
* decoded path holding a dot segment, an empty segment, a backslash or a NUL.
|
|
42
|
+
*
|
|
43
|
+
* @param path - the raw request path
|
|
44
|
+
*/
|
|
45
|
+
export declare const to_static_file_path: (path: string) => string | null;
|
|
26
46
|
/**
|
|
27
47
|
* Create static file serving middleware for SvelteKit static builds.
|
|
28
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/lib/server/static.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/lib/server/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,iBAAiB,CAAC;AAKpF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAc3D,CAAC;AAMF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACpC,cAAc,kBAAkB,EAChC,UAAU;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,KAC1F,KAAK,CAAC,iBAAiB,CAmCzB,CAAC"}
|
package/dist/server/static.js
CHANGED
|
@@ -6,8 +6,44 @@
|
|
|
6
6
|
* - Step 2: `.html` fallback for clean URLs (`/about` → `/about.html`)
|
|
7
7
|
* - Step 3 (optional): SPA fallback for client-side routes
|
|
8
8
|
*
|
|
9
|
+
* The server routes on the raw request path (`get_request_path`), and a
|
|
10
|
+
* runtime's `serveStatic` refuses a path holding a `%` — it expects one the
|
|
11
|
+
* router already decoded. So a path with an escape is decoded here first
|
|
12
|
+
* (`to_static_file_path`) and handed to `serveStatic` as the file to serve;
|
|
13
|
+
* one with no escape goes to it as is. The SPA fallback names its file
|
|
14
|
+
* outright, so no step but the exact match hands `serveStatic` the request
|
|
15
|
+
* path.
|
|
16
|
+
*
|
|
9
17
|
* @module
|
|
10
18
|
*/
|
|
19
|
+
/** A dot segment, an empty segment, a backslash or a NUL — what `serveStatic` refuses too, the NUL aside. */
|
|
20
|
+
const UNSAFE_STATIC_PATH = /(?:^|[/\\])\.{1,2}(?:$|[/\\])|[/\\]{2,}|\\|\0/;
|
|
21
|
+
/**
|
|
22
|
+
* The file a raw request path names, each segment percent-decoded by
|
|
23
|
+
* `decodeURIComponent` — or `null`, no file, for an escape that doesn't
|
|
24
|
+
* decode, a segment that decodes to a `/` or a `%` (which `serveStatic`
|
|
25
|
+
* never served: it refused the router's decoded path holding either), and a
|
|
26
|
+
* decoded path holding a dot segment, an empty segment, a backslash or a NUL.
|
|
27
|
+
*
|
|
28
|
+
* @param path - the raw request path
|
|
29
|
+
*/
|
|
30
|
+
export const to_static_file_path = (path) => {
|
|
31
|
+
const segments = [];
|
|
32
|
+
for (const segment of path.split('/')) {
|
|
33
|
+
let decoded;
|
|
34
|
+
try {
|
|
35
|
+
decoded = decodeURIComponent(segment);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (decoded.includes('/') || decoded.includes('%'))
|
|
41
|
+
return null;
|
|
42
|
+
segments.push(decoded);
|
|
43
|
+
}
|
|
44
|
+
const file = segments.join('/');
|
|
45
|
+
return UNSAFE_STATIC_PATH.test(file) ? null : file;
|
|
46
|
+
};
|
|
11
47
|
/** Default SPA route filter — serves the SPA fallback for all paths except `/api` and `/api/…`. */
|
|
12
48
|
const is_spa_route_default = (path) => path !== '/api' && !path.startsWith('/api/');
|
|
13
49
|
/**
|
|
@@ -21,23 +57,35 @@ const is_spa_route_default = (path) => path !== '/api' && !path.startsWith('/api
|
|
|
21
57
|
export const create_static_middleware = (serve_static, options) => {
|
|
22
58
|
const root = options?.root ?? './build';
|
|
23
59
|
const handlers = [];
|
|
24
|
-
// Step 1: exact path match
|
|
25
|
-
|
|
26
|
-
|
|
60
|
+
// Step 1: exact path match — a path with an escape decoded here, since
|
|
61
|
+
// `serve_static` refuses a `%`
|
|
62
|
+
const serve_exact = serve_static({ root });
|
|
27
63
|
handlers.push(async (c, next) => {
|
|
28
64
|
const path = c.req.path;
|
|
29
|
-
if (path
|
|
65
|
+
if (!path.includes('%'))
|
|
66
|
+
return serve_exact(c, next);
|
|
67
|
+
const file = to_static_file_path(path);
|
|
68
|
+
if (file === null)
|
|
69
|
+
return next();
|
|
70
|
+
return serve_static({ root, path: file })(c, next);
|
|
71
|
+
});
|
|
72
|
+
// Step 2: .html fallback for clean URLs (/about → /about.html)
|
|
73
|
+
handlers.push(async (c, next) => {
|
|
74
|
+
const file = to_static_file_path(c.req.path);
|
|
75
|
+
if (file === null || file === '/' || file.includes('.'))
|
|
30
76
|
return next();
|
|
31
|
-
return serve_static({ root,
|
|
77
|
+
return serve_static({ root, path: `${file}.html` })(c, next);
|
|
32
78
|
});
|
|
33
|
-
// Step 3: optional SPA fallback for client-side routes
|
|
79
|
+
// Step 3: optional SPA fallback for client-side routes — the fallback named
|
|
80
|
+
// as the file, since `serve_static` refuses a request path holding a `%`
|
|
81
|
+
// (a client route's encoded param) before it reads a rewrite
|
|
34
82
|
if (options?.spa_fallback) {
|
|
35
|
-
const
|
|
83
|
+
const serve_fallback = serve_static({ root, path: options.spa_fallback });
|
|
36
84
|
const is_spa_route = options.is_spa_route ?? is_spa_route_default;
|
|
37
85
|
handlers.push(async (c, next) => {
|
|
38
86
|
if (!is_spa_route(c.req.path))
|
|
39
87
|
return next();
|
|
40
|
-
return
|
|
88
|
+
return serve_fallback(c, next);
|
|
41
89
|
});
|
|
42
90
|
}
|
|
43
91
|
return handlers;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a request no route answers gets: the assembled server's not-found
|
|
3
|
+
* handler, twin of the Rust spine's method fallback (`fuz_http::compose_stack`)
|
|
4
|
+
* and fallback group (`fuz_actions::server::unmatched_route_response`).
|
|
5
|
+
*
|
|
6
|
+
* - **A method its path doesn't serve** — the path matches a route under
|
|
7
|
+
* another method — is `405 {"error":"method_not_allowed"}` with `Allow`
|
|
8
|
+
* naming the methods the path serves, `HEAD` wherever `GET` is.
|
|
9
|
+
* - **A path no route serves** is `404`: under the auth scope
|
|
10
|
+
* (`AUTH_MIDDLEWARE_PATH`) the JSON `{"error":"route_not_found"}`, like
|
|
11
|
+
* every other refusal there; elsewhere the one plain-text `NOT_FOUND_TEXT`.
|
|
12
|
+
* A route that passed the request on (the WebSocket path's `GET` asking for
|
|
13
|
+
* no upgrade) answers the same.
|
|
14
|
+
*
|
|
15
|
+
* The methods a path serves are read from the app's own router — every route
|
|
16
|
+
* registered on it, a spec's, a WebSocket upgrade's or one a consumer adds to
|
|
17
|
+
* the assembled app, and never a middleware (`ALL`).
|
|
18
|
+
*
|
|
19
|
+
* Both decide on the raw path the router matched (`get_request_path`), so
|
|
20
|
+
* `/%61pi/x` is outside the auth scope, as on the Rust spine. Hono runs this
|
|
21
|
+
* after every middleware, so the host gate and the origin check answer
|
|
22
|
+
* first, and ahead of authentication, which only the routes enforce: an
|
|
23
|
+
* anonymous `PUT` on the RPC path is the 405, not a 401. The answer is built
|
|
24
|
+
* through the context, so the session middleware's clear of a cookie that
|
|
25
|
+
* doesn't verify rides it like any other.
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import type { NotFoundHandler } from 'hono';
|
|
30
|
+
import type { Router } from 'hono/router';
|
|
31
|
+
import type { RouterRoute } from 'hono/types';
|
|
32
|
+
/** What `create_unmatched_route_handler` reads: the app's router (`app.router`). */
|
|
33
|
+
export type UnmatchedRouteRouter = Pick<Router<[unknown, RouterRoute]>, 'match'>;
|
|
34
|
+
/**
|
|
35
|
+
* Build the not-found handler (module doc) over the app's router.
|
|
36
|
+
*
|
|
37
|
+
* @param router - the assembled app's router, `app.router`, read at request
|
|
38
|
+
* time, so a route added after assembly is seen too
|
|
39
|
+
* @returns the handler for `app.notFound`
|
|
40
|
+
*/
|
|
41
|
+
export declare const create_unmatched_route_handler: (router: UnmatchedRouteRouter) => NotFoundHandler;
|
|
42
|
+
//# sourceMappingURL=unmatched_route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unmatched_route.d.ts","sourceRoot":"","sources":["../../src/lib/server/unmatched_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgB9C,oFAAoF;AACpF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAUjF;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,GAAI,QAAQ,oBAAoB,KAAG,eAiB7E,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a request no route answers gets: the assembled server's not-found
|
|
3
|
+
* handler, twin of the Rust spine's method fallback (`fuz_http::compose_stack`)
|
|
4
|
+
* and fallback group (`fuz_actions::server::unmatched_route_response`).
|
|
5
|
+
*
|
|
6
|
+
* - **A method its path doesn't serve** — the path matches a route under
|
|
7
|
+
* another method — is `405 {"error":"method_not_allowed"}` with `Allow`
|
|
8
|
+
* naming the methods the path serves, `HEAD` wherever `GET` is.
|
|
9
|
+
* - **A path no route serves** is `404`: under the auth scope
|
|
10
|
+
* (`AUTH_MIDDLEWARE_PATH`) the JSON `{"error":"route_not_found"}`, like
|
|
11
|
+
* every other refusal there; elsewhere the one plain-text `NOT_FOUND_TEXT`.
|
|
12
|
+
* A route that passed the request on (the WebSocket path's `GET` asking for
|
|
13
|
+
* no upgrade) answers the same.
|
|
14
|
+
*
|
|
15
|
+
* The methods a path serves are read from the app's own router — every route
|
|
16
|
+
* registered on it, a spec's, a WebSocket upgrade's or one a consumer adds to
|
|
17
|
+
* the assembled app, and never a middleware (`ALL`).
|
|
18
|
+
*
|
|
19
|
+
* Both decide on the raw path the router matched (`get_request_path`), so
|
|
20
|
+
* `/%61pi/x` is outside the auth scope, as on the Rust spine. Hono runs this
|
|
21
|
+
* after every middleware, so the host gate and the origin check answer
|
|
22
|
+
* first, and ahead of authentication, which only the routes enforce: an
|
|
23
|
+
* anonymous `PUT` on the RPC path is the 405, not a 401. The answer is built
|
|
24
|
+
* through the context, so the session middleware's clear of a cookie that
|
|
25
|
+
* doesn't verify rides it like any other.
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import { AUTH_MIDDLEWARE_PATH } from '../auth/middleware.js';
|
|
30
|
+
import { ERROR_METHOD_NOT_ALLOWED, ERROR_ROUTE_NOT_FOUND, NOT_FOUND_TEXT } from '../http/error_schemas.js';
|
|
31
|
+
import { middleware_applies } from '../http/schema_helpers.js';
|
|
32
|
+
/** The `Content-Type` of `NOT_FOUND_TEXT`, as the Rust spine writes it. */
|
|
33
|
+
const NOT_FOUND_CONTENT_TYPE = 'text/plain; charset=utf-8';
|
|
34
|
+
/** The methods a route may serve, in the order `Allow` lists them. */
|
|
35
|
+
const ROUTE_METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'];
|
|
36
|
+
/**
|
|
37
|
+
* Whether `router` holds a route — not a middleware — for `method` at `path`.
|
|
38
|
+
* A match carries each handler's registration, whose `method` is the one it
|
|
39
|
+
* was added under: a route's own, or `ALL` for a middleware.
|
|
40
|
+
*/
|
|
41
|
+
const serves = (router, method, path) => router.match(method, path)[0].some(([[, route]]) => route.method === method);
|
|
42
|
+
/**
|
|
43
|
+
* Build the not-found handler (module doc) over the app's router.
|
|
44
|
+
*
|
|
45
|
+
* @param router - the assembled app's router, `app.router`, read at request
|
|
46
|
+
* time, so a route added after assembly is seen too
|
|
47
|
+
* @returns the handler for `app.notFound`
|
|
48
|
+
*/
|
|
49
|
+
export const create_unmatched_route_handler = (router) => {
|
|
50
|
+
return (c) => {
|
|
51
|
+
const path = c.req.path;
|
|
52
|
+
// `HEAD` is served wherever `GET` is, which Hono answers it with
|
|
53
|
+
const allow = ROUTE_METHODS.filter((method) => serves(router, method === 'HEAD' ? 'GET' : method, path));
|
|
54
|
+
const method = c.req.method === 'HEAD' ? 'GET' : c.req.method;
|
|
55
|
+
if (allow.length > 0 && !allow.includes(method)) {
|
|
56
|
+
c.header('Allow', allow.join(', '));
|
|
57
|
+
return c.json({ error: ERROR_METHOD_NOT_ALLOWED }, 405);
|
|
58
|
+
}
|
|
59
|
+
if (middleware_applies(AUTH_MIDDLEWARE_PATH, path)) {
|
|
60
|
+
return c.json({ error: ERROR_ROUTE_NOT_FOUND }, 404);
|
|
61
|
+
}
|
|
62
|
+
return c.body(NOT_FOUND_TEXT, 404, { 'Content-Type': NOT_FOUND_CONTENT_TYPE });
|
|
63
|
+
};
|
|
64
|
+
};
|