@fuzdev/fuz_app 0.180.0 → 0.181.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +14 -14
- package/dist/actions/action_rpc.d.ts +14 -5
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +53 -46
- package/dist/actions/action_types.d.ts +15 -12
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/perform_action.d.ts +4 -4
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +6 -6
- package/dist/actions/register_action_ws.d.ts +6 -2
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +14 -3
- package/dist/actions/ws_socket_session.js +1 -1
- package/dist/auth/CLAUDE.md +36 -30
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +18 -1
- package/dist/auth/account_queries.d.ts +69 -0
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +82 -0
- package/dist/auth/account_route_schema.d.ts +26 -16
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +10 -24
- package/dist/auth/account_routes.d.ts +4 -6
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +86 -66
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +63 -14
- package/dist/auth/api_token_queries.d.ts +16 -7
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +18 -18
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +10 -12
- package/dist/auth/audit_log_schema.js +4 -4
- package/dist/auth/bearer_auth.d.ts +4 -3
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +35 -31
- package/dist/auth/bootstrap_account.d.ts +65 -37
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +115 -66
- package/dist/auth/bootstrap_route_schema.d.ts +6 -2
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +7 -2
- package/dist/auth/bootstrap_routes.d.ts +50 -33
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +109 -87
- package/dist/auth/bootstrap_token_store.d.ts +60 -0
- package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
- package/dist/auth/bootstrap_token_store.js +39 -0
- package/dist/auth/credential_headers.d.ts +71 -0
- package/dist/auth/credential_headers.d.ts.map +1 -0
- package/dist/auth/credential_headers.js +100 -0
- package/dist/auth/daemon_token.d.ts +13 -1
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token.js +14 -2
- package/dist/auth/daemon_token_middleware.d.ts +10 -11
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +27 -29
- package/dist/auth/deps.d.ts +0 -11
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/invite_queries.d.ts +18 -0
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +24 -0
- package/dist/auth/request_context.d.ts +26 -5
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +17 -10
- package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +3 -2
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +37 -14
- package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
- package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_ddl.js +9 -2
- package/dist/auth/role_grant_offer_queries.d.ts +56 -3
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +93 -8
- package/dist/auth/role_grant_queries.d.ts +7 -0
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +8 -0
- package/dist/auth/session_cookie.d.ts +105 -25
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +124 -15
- package/dist/auth/session_middleware.d.ts +83 -54
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +92 -66
- package/dist/auth/session_queries.d.ts +64 -4
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +53 -4
- package/dist/auth/signup_route_schema.d.ts +5 -5
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +4 -4
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +17 -14
- package/dist/auth/token_scope.d.ts +5 -7
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +5 -8
- package/dist/dev/setup.d.ts +6 -1
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +42 -34
- package/dist/hono_context.d.ts +21 -0
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +17 -0
- package/dist/http/CLAUDE.md +150 -43
- package/dist/http/auth_shape.d.ts +3 -3
- package/dist/http/common_routes.js +1 -1
- package/dist/http/db_routes.d.ts +4 -3
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +14 -14
- package/dist/http/dev_route_error_check.d.ts +6 -3
- package/dist/http/dev_route_error_check.d.ts.map +1 -1
- package/dist/http/dev_route_error_check.js +6 -3
- package/dist/http/dev_set_cookie_check.d.ts +53 -0
- package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
- package/dist/http/dev_set_cookie_check.js +80 -0
- package/dist/http/error_schemas.d.ts +36 -1
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +39 -2
- package/dist/http/header_lines.d.ts +42 -0
- package/dist/http/header_lines.d.ts.map +1 -0
- package/dist/http/header_lines.js +80 -0
- package/dist/http/host.d.ts +12 -9
- package/dist/http/host.d.ts.map +1 -1
- package/dist/http/host.js +25 -20
- package/dist/http/origin.d.ts +7 -22
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +11 -25
- package/dist/http/proxy.d.ts +1 -0
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +3 -0
- package/dist/http/request_headers.d.ts +95 -0
- package/dist/http/request_headers.d.ts.map +1 -0
- package/dist/http/request_headers.js +110 -0
- package/dist/http/request_target.d.ts +134 -0
- package/dist/http/request_target.d.ts.map +1 -0
- package/dist/http/request_target.js +193 -0
- package/dist/http/route_error_check.d.ts +4 -11
- package/dist/http/route_error_check.d.ts.map +1 -1
- package/dist/http/route_error_check.js +4 -21
- package/dist/http/route_result.d.ts +127 -23
- package/dist/http/route_result.d.ts.map +1 -1
- package/dist/http/route_result.js +97 -19
- package/dist/http/route_spec.d.ts +298 -82
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +548 -71
- package/dist/http/simple_request.d.ts +19 -14
- package/dist/http/simple_request.d.ts.map +1 -1
- package/dist/http/simple_request.js +17 -29
- package/dist/http/surface.d.ts +2 -0
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +4 -1
- package/dist/realtime/outbound_budget.d.ts +1 -2
- package/dist/realtime/outbound_budget.d.ts.map +1 -1
- package/dist/realtime/outbound_budget.js +1 -2
- package/dist/realtime/sse.d.ts +47 -17
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +115 -93
- package/dist/realtime/sse_constants.d.ts +7 -1
- package/dist/realtime/sse_constants.d.ts.map +1 -1
- package/dist/realtime/sse_constants.js +12 -1
- package/dist/realtime/sse_registry.d.ts +3 -3
- package/dist/realtime/sse_registry.js +3 -3
- package/dist/runtime/deps.d.ts +20 -4
- package/dist/runtime/deps.d.ts.map +1 -1
- package/dist/runtime/mock.d.ts +7 -1
- package/dist/runtime/mock.d.ts.map +1 -1
- package/dist/runtime/mock.js +33 -3
- package/dist/runtime/node.d.ts.map +1 -1
- package/dist/runtime/node.js +2 -1
- package/dist/runtime/secure_file.d.ts +71 -10
- package/dist/runtime/secure_file.d.ts.map +1 -1
- package/dist/runtime/secure_file.js +91 -11
- package/dist/server/app_backend.d.ts +0 -8
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +1 -3
- package/dist/server/app_server.d.ts +28 -17
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +52 -34
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +49 -45
- package/dist/server/static.d.ts +20 -0
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +56 -8
- package/dist/server/unmatched_route.d.ts +42 -0
- package/dist/server/unmatched_route.d.ts.map +1 -0
- package/dist/server/unmatched_route.js +64 -0
- package/dist/testing/CLAUDE.md +404 -1200
- package/dist/testing/app_server.d.ts +3 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +4 -10
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +2 -1
- package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
- package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/account_lifecycle.js +277 -6
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
- package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
- package/dist/testing/cross_backend/capabilities.d.ts +68 -5
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +20 -4
- package/dist/testing/cross_backend/cell_gated_create.js +1 -1
- package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +179 -23
- package/dist/testing/cross_backend/cookie_attributes.js +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
- package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
- package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_conformance.js +296 -0
- package/dist/testing/cross_backend/credential_conformance.json +1284 -0
- package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
- package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
- package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
- package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
- package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
- package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
- package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_wire.js +188 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +22 -2
- package/dist/testing/cross_backend/default_spine_surface.js +1 -1
- package/dist/testing/cross_backend/differential.d.ts +1 -1
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +3 -2
- package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
- package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential_normalize.js +11 -5
- package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -0
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +7 -0
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +4 -0
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +78 -4
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +13 -10
- package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
- package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
- package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_header_conformance.js +196 -0
- package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
- package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
- package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_target_conformance.js +186 -0
- package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +2 -1
- package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
- package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
- package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +56 -29
- package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
- package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
- package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
- package/dist/testing/cross_backend/session_login.d.ts +24 -0
- package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
- package/dist/testing/cross_backend/session_login.js +31 -0
- package/dist/testing/cross_backend/setup.d.ts +117 -0
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +193 -9
- package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
- package/dist/testing/cross_backend/simple_request.js +5 -0
- package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +88 -5
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +205 -64
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +5 -2
- package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
- package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
- package/dist/testing/cross_backend/testing_credential_read.js +175 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +58 -2
- package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +13 -10
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
- package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
- package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_endpoint.js +19 -2
- package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_role_gated.js +2 -3
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +28 -12
- package/dist/testing/cross_backend/xfail.d.ts +44 -11
- package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
- package/dist/testing/cross_backend/xfail.js +68 -23
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +4 -3
- package/dist/testing/integration.d.ts +1 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +14 -8
- package/dist/testing/integration_helpers.d.ts +50 -3
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +87 -9
- package/dist/testing/middleware.d.ts +2 -0
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +9 -2
- package/dist/testing/round_trip.d.ts +6 -2
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +17 -6
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +7 -0
- package/dist/testing/rpc_helpers.d.ts +4 -2
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +6 -1
- package/dist/testing/rpc_round_trip.d.ts +13 -2
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +25 -6
- package/dist/testing/schema_generators.d.ts +2 -2
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +4 -4
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +8 -8
- package/dist/testing/transports/fetch_transport.d.ts +6 -3
- package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
- package/dist/testing/transports/fetch_transport.js +31 -19
- package/dist/testing/transports/raw_http.d.ts +61 -1
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +61 -1
- package/dist/testing/transports/ws_raw_client.d.ts +20 -0
- package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
- package/dist/testing/transports/ws_raw_client.js +10 -4
- package/dist/testing/transports/ws_transport.d.ts +21 -1
- package/dist/testing/transports/ws_transport.d.ts.map +1 -1
- package/dist/testing/transports/ws_transport.js +58 -20
- package/package.json +1 -1
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
|
+
};
|