@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
package/dist/dev/setup.js
CHANGED
|
@@ -396,48 +396,56 @@ export const reset_database = async (deps, database_url, options) => {
|
|
|
396
396
|
* requested role grants. Never updates an existing password (rerun would
|
|
397
397
|
* silently rotate it).
|
|
398
398
|
*
|
|
399
|
+
* Flips `bootstrap_lock` in the same transaction as its writes, as a real
|
|
400
|
+
* bootstrap and `bootstrap_test_keeper` do: a database holding an account
|
|
401
|
+
* never reads as open for bootstrap, so the lock stays the single signal
|
|
402
|
+
* production trusts. Seed after bootstrapping, or seed the keeper itself.
|
|
403
|
+
*
|
|
399
404
|
* Intended for a dev setup task — do not call in production.
|
|
400
405
|
*
|
|
401
|
-
* @mutates database - inserts an account/actor pair when missing
|
|
406
|
+
* @mutates database - inserts an account/actor pair when missing, grants any requested role role_grants, and flips `bootstrap_lock.bootstrapped`
|
|
402
407
|
* @throws Error if an existing account is found without an associated actor row
|
|
403
408
|
*/
|
|
404
409
|
export const seed_dev_account = async (deps, input, options) => {
|
|
405
410
|
const log = options?.log ?? default_setup_logger;
|
|
406
|
-
const query_deps = { db: deps.db };
|
|
407
411
|
const username = input.username.toLowerCase();
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
412
|
+
const result = await deps.db.transaction(async (tx) => {
|
|
413
|
+
const query_deps = { db: tx };
|
|
414
|
+
await tx.query('UPDATE bootstrap_lock SET bootstrapped = true WHERE id = 1 AND bootstrapped = false');
|
|
415
|
+
const grant_roles = async (actor_id) => {
|
|
416
|
+
for (const role of input.roles ?? []) {
|
|
417
|
+
await query_create_role_grant(query_deps, {
|
|
418
|
+
actor_id,
|
|
419
|
+
role,
|
|
420
|
+
granted_by: null,
|
|
421
|
+
expires_at: null
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const existing = await query_account_by_username(query_deps, username);
|
|
426
|
+
if (existing) {
|
|
427
|
+
const actors = await query_actors_by_account(query_deps, existing.id);
|
|
428
|
+
if (actors.length === 0) {
|
|
429
|
+
log.error(`dev account '${input.username}' exists but has no actor`);
|
|
430
|
+
throw new Error(`dev account '${input.username}' has no actor`);
|
|
431
|
+
}
|
|
432
|
+
// Dev seed is single-actor by construction; pick the first.
|
|
433
|
+
const actor = actors[0];
|
|
434
|
+
await grant_roles(actor.id);
|
|
435
|
+
return { account_id: existing.id, actor_id: actor.id, created: false };
|
|
424
436
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const password_hash = await deps.hash_password(input.password);
|
|
429
|
-
const { account, actor } = await query_create_account_with_actor(query_deps, {
|
|
430
|
-
username,
|
|
431
|
-
password_hash
|
|
432
|
-
});
|
|
433
|
-
for (const role of input.roles ?? []) {
|
|
434
|
-
await query_create_role_grant(query_deps, {
|
|
435
|
-
actor_id: actor.id,
|
|
436
|
-
role,
|
|
437
|
-
granted_by: null,
|
|
438
|
-
expires_at: null
|
|
437
|
+
const { account, actor } = await query_create_account_with_actor(query_deps, {
|
|
438
|
+
username,
|
|
439
|
+
password_hash: await deps.hash_password(input.password)
|
|
439
440
|
});
|
|
441
|
+
await grant_roles(actor.id);
|
|
442
|
+
return { account_id: account.id, actor_id: actor.id, created: true };
|
|
443
|
+
});
|
|
444
|
+
if (result.created) {
|
|
445
|
+
log.ok(`Seeded dev account '${input.username}'`);
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
log.skip(`Dev account '${input.username}' already exists`);
|
|
440
449
|
}
|
|
441
|
-
|
|
442
|
-
return { account_id: account.id, actor_id: actor.id, created: true };
|
|
450
|
+
return result;
|
|
443
451
|
};
|
package/dist/hono_context.d.ts
CHANGED
|
@@ -40,6 +40,23 @@ export declare const SESSION_TOKEN_KEY = "auth_session_id";
|
|
|
40
40
|
* middleware folds it into the session's `ResolvedAuth.credential_deadline`.
|
|
41
41
|
*/
|
|
42
42
|
export declare const SESSION_COOKIE_EXPIRES_AT_KEY = "auth_session_cookie_expires_at";
|
|
43
|
+
/**
|
|
44
|
+
* Hono context variable name for the connection's peer address — what the
|
|
45
|
+
* trusted-proxy middleware's `get_connection_ip` returned, before any
|
|
46
|
+
* `X-Forwarded-For` resolution; `null` when the runtime gave none. What
|
|
47
|
+
* `RouteContext.connection_ip` reads.
|
|
48
|
+
*/
|
|
49
|
+
export declare const CONNECTION_IP_KEY = "connection_ip";
|
|
50
|
+
/**
|
|
51
|
+
* Hono context variable name for the `Set-Cookie` line a response must lead
|
|
52
|
+
* with — set by a middleware that put that line on the context's prepared
|
|
53
|
+
* headers (the session middleware's clear of a stale cookie), so every
|
|
54
|
+
* response built through the context carries it first. The DEV `Set-Cookie`
|
|
55
|
+
* check (`http/dev_set_cookie_check.ts`) reads it after the request and logs
|
|
56
|
+
* a response that doesn't — one built past the context, by a layer the route
|
|
57
|
+
* system doesn't own.
|
|
58
|
+
*/
|
|
59
|
+
export declare const EXPECTED_FIRST_SET_COOKIE_KEY = "expected_first_set_cookie";
|
|
43
60
|
/**
|
|
44
61
|
* Hono context variable name for the test-harness pre-baked context flag.
|
|
45
62
|
*
|
|
@@ -75,6 +92,10 @@ declare module 'hono' {
|
|
|
75
92
|
interface ContextVariableMap {
|
|
76
93
|
/** Resolved client IP, set by the trusted proxy middleware. */
|
|
77
94
|
client_ip: string;
|
|
95
|
+
/** The connection's peer address (`CONNECTION_IP_KEY`), set by the trusted proxy middleware. */
|
|
96
|
+
connection_ip: string | null;
|
|
97
|
+
/** The `Set-Cookie` line every response must lead with (`EXPECTED_FIRST_SET_COOKIE_KEY`). */
|
|
98
|
+
expected_first_set_cookie: string;
|
|
78
99
|
/** The session token (`SESSION_TOKEN_KEY`), set by the session middleware. */
|
|
79
100
|
auth_session_id: string | null;
|
|
80
101
|
request_context: RequestContext | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono_context.d.ts","sourceRoot":"","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,mCAAmC,CAAC;AAE9E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,MAAsC,CAAC;AAEhF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAAI,GAAG,OAAO,KAAG,OACE,CAAC;AAExD,OAAO,QAAQ,MAAM,CAAC;IACrB,UAAU,kBAAkB;QAC3B,+DAA+D;QAC/D,SAAS,EAAE,MAAM,CAAC;QAClB,8EAA8E;QAC9E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;QACvC,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,OAAO,CAAC;QACzB;;;;WAIG;QACH,aAAa,EAAE,YAAY,GAAG,IAAI,CAAC;QACnC,2FAA2F;QAC3F,8BAA8B,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9C;;;;;;;WAOG;QACH,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC;;;;;;;;;;;;WAYG;QACH,mBAAmB,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD;;;;;WAKG;QACH,mBAAmB,EAAE,OAAO,mBAAmB,CAAC;KAChD;CACD"}
|
|
1
|
+
{"version":3,"file":"hono_context.d.ts","sourceRoot":"","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,mCAAmC,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AAEzE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,MAAsC,CAAC;AAEhF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAAI,GAAG,OAAO,KAAG,OACE,CAAC;AAExD,OAAO,QAAQ,MAAM,CAAC;IACrB,UAAU,kBAAkB;QAC3B,+DAA+D;QAC/D,SAAS,EAAE,MAAM,CAAC;QAClB,gGAAgG;QAChG,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,6FAA6F;QAC7F,yBAAyB,EAAE,MAAM,CAAC;QAClC,8EAA8E;QAC9E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;QACvC,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,OAAO,CAAC;QACzB;;;;WAIG;QACH,aAAa,EAAE,YAAY,GAAG,IAAI,CAAC;QACnC,2FAA2F;QAC3F,8BAA8B,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9C;;;;;;;WAOG;QACH,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC;;;;;;;;;;;;WAYG;QACH,mBAAmB,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD;;;;;WAKG;QACH,mBAAmB,EAAE,OAAO,mBAAmB,CAAC;KAChD;CACD"}
|
package/dist/hono_context.js
CHANGED
|
@@ -37,6 +37,23 @@ export const SESSION_TOKEN_KEY = 'auth_session_id';
|
|
|
37
37
|
* middleware folds it into the session's `ResolvedAuth.credential_deadline`.
|
|
38
38
|
*/
|
|
39
39
|
export const SESSION_COOKIE_EXPIRES_AT_KEY = 'auth_session_cookie_expires_at';
|
|
40
|
+
/**
|
|
41
|
+
* Hono context variable name for the connection's peer address — what the
|
|
42
|
+
* trusted-proxy middleware's `get_connection_ip` returned, before any
|
|
43
|
+
* `X-Forwarded-For` resolution; `null` when the runtime gave none. What
|
|
44
|
+
* `RouteContext.connection_ip` reads.
|
|
45
|
+
*/
|
|
46
|
+
export const CONNECTION_IP_KEY = 'connection_ip';
|
|
47
|
+
/**
|
|
48
|
+
* Hono context variable name for the `Set-Cookie` line a response must lead
|
|
49
|
+
* with — set by a middleware that put that line on the context's prepared
|
|
50
|
+
* headers (the session middleware's clear of a stale cookie), so every
|
|
51
|
+
* response built through the context carries it first. The DEV `Set-Cookie`
|
|
52
|
+
* check (`http/dev_set_cookie_check.ts`) reads it after the request and logs
|
|
53
|
+
* a response that doesn't — one built past the context, by a layer the route
|
|
54
|
+
* system doesn't own.
|
|
55
|
+
*/
|
|
56
|
+
export const EXPECTED_FIRST_SET_COOKIE_KEY = 'expected_first_set_cookie';
|
|
40
57
|
/**
|
|
41
58
|
* Hono context variable name for the test-harness pre-baked context flag.
|
|
42
59
|
*
|
package/dist/http/CLAUDE.md
CHANGED
|
@@ -4,9 +4,11 @@ Generic HTTP framework infrastructure — route specs, error schemas, attack
|
|
|
4
4
|
surface introspection, JSON-RPC envelope + error taxonomy, proxy/origin
|
|
5
5
|
middleware primitives, post-commit effect helper, generic admin route specs.
|
|
6
6
|
|
|
7
|
-
**
|
|
8
|
-
guards live in `auth/` and consume these primitives
|
|
9
|
-
|
|
7
|
+
**No auth logic lives in this directory.** Auth middleware, routes, and
|
|
8
|
+
guards live in `auth/` and consume these primitives; the route context names
|
|
9
|
+
the auth domain's types (`RequestContext`, `ResolvedAuth`) as types only, as
|
|
10
|
+
`hono_context.ts` does. Routes and actions in other domains should do the
|
|
11
|
+
same — extend, don't special-case.
|
|
10
12
|
|
|
11
13
|
For the design rationale behind declarative routes, DEV-only output
|
|
12
14
|
validation, the route error map, and fire-and-forget
|
|
@@ -14,24 +16,29 @@ effects, see ../../../docs/architecture.md.
|
|
|
14
16
|
|
|
15
17
|
## Module Map
|
|
16
18
|
|
|
17
|
-
- `http/route_spec.ts` — `RouteSpec` + `apply_route_specs`, validation pipeline, transactions; `define_route`, `define_route_shape` + `attach_route_handler` (a handler checked against its route), `
|
|
18
|
-
- `http/route_result.ts` — what a handler returns: `route_ok`, `route_fail`, `route_raw` (`RouteResult`)
|
|
19
|
+
- `http/route_spec.ts` — `RouteSpec` + `apply_route_specs`, validation pipeline, transactions; `define_route`, `define_route_shape` + `attach_route_handler` (a handler checked against its route), `prepare_route_response` + `emit_route_response` (the one place a route result becomes a `Response`), and `RouteContext` — everything a handler reads of its request, built from the Hono context the handler never sees.
|
|
20
|
+
- `http/route_result.ts` — what a handler returns, all of it data: `route_ok`, `route_fail`, `route_raw`, `route_sse` (`RouteResult`), and `ROUTE_RAW_REFUSED_HEADERS`. Imports nothing from Hono.
|
|
19
21
|
- `http/auth_shape.ts` — canonical `RouteAuth` type + `AuthAxisState` + predicates + the registration-time checks: `assert_route_auth_invariants` (the cross-axis invariants 1, 3, 4) and `assert_route_auth_acting_biconditional` (invariant 2), both run by `apply_route_specs` and `compile_action_registry` on every spec.
|
|
20
22
|
- `http/error_schemas.ts` — `ERROR_*` constants, the per-code REST error definitions (`rest_error`, `REST_*`), `derive_route_errors`, `to_error_schemas`.
|
|
21
23
|
- `http/route_errors.ts` — the route error map: `RouteErrorMap`, `resolve_route_error_map`, `resolve_app_route_error_maps`, `get_route_error_map`.
|
|
22
|
-
- `http/route_error_check.ts` — `check_route_error` (whether an error response is one its route's map declares, the rule the DEV error check and `assert_response_matches_spec` share; `ALWAYS_ACCEPTED_ERRORS`, `is_error_status`, `format_route_error_check`) `is_json_response`, and the test helpers' hono-free route lookup (`split_route_template` and `parse_route_param`, a template read segment by segment as Hono's `getPattern` reads it; `compile_route_path`; `compile_route_param_pattern`, a `{re}` grouped and anchored as `compile_route_path` reads it — Hono's RegExpRouter reading, stricter than TrieRouter's ungrouped `^re$`; `
|
|
24
|
+
- `http/route_error_check.ts` — `check_route_error` (whether an error response is one its route's map declares, the rule the DEV error check and `assert_response_matches_spec` share; `ALWAYS_ACCEPTED_ERRORS`, `is_error_status`, `format_route_error_check`) `is_json_response`, and the test helpers' hono-free route lookup (`split_route_template` and `parse_route_param`, a template read segment by segment as Hono's `getPattern` reads it; `compile_route_path`; `compile_route_param_pattern`, a `{re}` grouped and anchored as `compile_route_path` reads it — Hono's RegExpRouter reading, stricter than TrieRouter's ungrouped `^re$`; `to_mounted_routes`; `find_mounted_route`), whose reading `resolve_valid_path` also fills params by. Hono-free and `esm-env`-free.
|
|
23
25
|
- `http/dev_route_error_check.ts` — `create_dev_route_error_check({route_specs, route_error_maps, log})`: the DEV-only outer error check, `null` outside DEV; `create_route_lookup`, its lookup by Hono's own router.
|
|
26
|
+
- `http/dev_set_cookie_check.ts` — `create_dev_set_cookie_check({log})`: the DEV-only outer check that a response leads with the `Set-Cookie` line a middleware recorded for it (`EXPECTED_FIRST_SET_COOKIE_KEY` — the session middleware's clear), `null` outside DEV. Knows nothing of sessions.
|
|
24
27
|
- `http/schema_helpers.ts` — shared schema introspection (null/void/strict/surface/middleware-applies), and `to_void_params` / `to_input_params` / `scan_json_value` / `safe_parse_dropping_unknown_keys`.
|
|
25
28
|
- `http/json_text.ts` — `parse_json_text`: JSON text read as the Rust spine's `serde_json` reads it, refusing what `JSON.parse` accepts and serde refuses (an escaped lone surrogate in a string or key, a number out of `f64` range, nesting `JSON_DEPTH_LIMIT` (128) deep); one linear scan of the text after `JSON.parse` accepts it (`is_serde_json_text`), so a refused value under a duplicated key is seen and the cost stays a few milliseconds a MiB. `read_json_body(c.req)` reads a request body through it once per request (the authorization phase's `acting` read and input validation share it), as text, never `c.req.json()`. Every body and frame parse runs it: route input, the RPC POST body and `GET` `params`, WS frames. Hono-free, imports nothing.
|
|
26
29
|
- `http/middleware_spec.ts` — `MiddlewareSpec` interface.
|
|
27
30
|
- `http/body_limit.ts` — `create_body_limit_middleware(max_size)`: the `413` body cap `create_app_server` mounts, as `create_body_limit_middleware_spec(max_size)`, a `MiddlewareSpec` at `'*'` ahead of the other middleware, absent with `max_body_size: null`. Its hono-free shape, `body_limit_middleware_shape` (`http/body_limit_schema.ts`), declares its `413` `payload_too_large` and `400` `invalid_content_length`, so every route's error map carries both; `create_test_app_surface_spec` lists the same shape with a stub handler. Refuses on `Content-Length` without reading `c.req.raw.body` and answers `Connection: close` — `413` past the cap, `400` `ERROR_INVALID_CONTENT_LENGTH` when the value is not a plain run of ASCII digits (a length the cap cannot read, which Hono's `bodyLimit` would pass uncounted) — else falls through to Hono's `bodyLimit` (no `Content-Length`, or one beside `Transfer-Encoding`), which reads the body into memory up to the cap before the next middleware runs, so its `413` — no `Connection: close` — also precedes origin and auth. After the header `413` Node and Bun close at once (the header is what makes them — Bun 1.4.3 is the tested floor, an older Bun kept the connection and served the next request) (../../../docs/security.md §Body Size Limiting).
|
|
28
31
|
- `http/surface.ts` — `AppSurface`, `AppSurfaceSpec`, `generate_app_surface`, diagnostics.
|
|
29
32
|
- `http/surface_query.ts` — pure filters/groupings over `AppSurface`.
|
|
30
|
-
- `http/proxy.ts` — trusted-proxy middleware, CIDR parsing, rightmost-first XFF resolution. Pulls `hono/utils/ipaddr` for CIDR matching.
|
|
33
|
+
- `http/proxy.ts` — trusted-proxy middleware, CIDR parsing, rightmost-first XFF resolution; also records the socket's peer address as it read it (`CONNECTION_IP_KEY`, what `RouteContext.connection_ip` answers). Pulls `hono/utils/ipaddr` for CIDR matching.
|
|
31
34
|
- `http/client_ip.ts` — `get_client_ip(c)` — reads the resolved IP off the context (set by `proxy.ts`'s middleware). Split out of `proxy.ts` so it's hono-free: dispatch + route modules that only _read_ the IP don't pull `hono/utils/ipaddr`, keeping cross-process test surfaces free of the optional `hono` peer.
|
|
32
35
|
- `http/ip_canonical.ts` — RFC 5952 IPv6 canonicalization + IPv4-mapped collapse, `rate_limit_ip_key` (an IPv6 client's `/64`), and its own `parse_ipv4_bits` / `parse_ipv6_bits` (the grammar of Rust's `IpAddr::from_str`); `IP_LITERAL_CHARS` regex. Imports nothing — the dispatcher keys its IP limiter through it, so it must stay hono-free (`src/test/hono_free_modules.test.ts` walks every `src/lib` module's graph).
|
|
36
|
+
- `http/header_lines.ts` — `get_header_lines(c, name)`: a request header as the lines the client sent — Node's raw header list where `@hono/node-server` provides it (`c.env.incoming.rawHeaders`, plain requests and WebSocket upgrades alike), else the Fetch value as one line (Bun, in-process `app.request`: repeated lines arrive joined) — and `trim_optional_whitespace` (SP and HTAB only). What the credential readers (`auth/credential_headers.ts`) and the gate readers (`http/request_headers.ts`) read, so a header sent twice or empty is seen as such.
|
|
37
|
+
- `http/request_headers.ts` — the gates' header grammar as pure readers over header lines, hono-free: `read_origin`, `read_host`, `read_content_type` (each a `HeaderRead` — `absent`, `one` well-formed line, or `refused`: an empty line, a second line, a byte off the grammar, a comma anywhere) and `is_browser_context(origin_lines, referer_lines)` (any line, an empty one included). A comma is refused so a repeat reads the same joined (Bun, in-process) as it does line by line. Twin of the Rust `fuz_http::request_headers`; both held to `testing/cross_backend/request_header_conformance.json`. `src/test/request_reads_census.test.ts` holds every raw request read in `src/lib` to a per-module allowlist, and these headers and the credential ones to `get_header_lines`.
|
|
38
|
+
- `http/simple_request.ts` — the 415 gate on every `POST` route (`is_post_content_type_refused` over `read_content_type`): a JSON route takes only `application/json`, a `raw_body` route any well-formed type that isn't CORS-safelisted; a repeated, empty or off-grammar `Content-Type` is refused on every runtime (../../../docs/security.md §CSRF Protection).
|
|
39
|
+
- `http/request_target.ts` — the strict readers of the request target: `read_query_pairs` (the query string to its decoded pairs) and `read_path_segment` (one path segment to its text), each a `Result` that refuses an escape that doesn't decode (`PercentDecodeError`: `malformed_escape`, `invalid_utf8`) — never left literal, never replaced with U+FFFD — plus `query_first` / `to_query_record` over the pairs and the two Hono-bound readers every query and param read in the spine goes through (`read_request_query_pairs`, `read_request_route_params`). `+` is a space and the first occurrence of a key wins. Twin of the Rust `fuz_http::request_target`; both held to `testing/cross_backend/request_target_conformance.json`. Also `get_request_path`, the raw path the app's router matches (its `getPath`).
|
|
33
40
|
- `http/origin.ts` — origin allowlist: the strict pattern grammar shared with the Rust spine, typed refusals, and the Origin-only middleware.
|
|
34
|
-
- `http/host.ts` — the host gate (DNS rebinding): `is_loopback_host`, `allows_host` / `allows_request_hosts` over the origin matchers, `create_host_gate_middleware_spec` (`'*'`, 403 `forbidden_host`, on by default in `create_app_server`) and its rate-limited refusal warning (`format_host_refusal_warning`). Twin of the Rust `fuz_http::host`; verdicts pinned by the host rows of `testing/cross_backend/origin_conformance.json` (../../../docs/security.md §DNS Rebinding).
|
|
41
|
+
- `http/host.ts` — the host gate (DNS rebinding): `is_loopback_host`, `allows_host` / `allows_request_hosts` over the origin matchers, `create_host_gate_middleware_spec` (`'*'`, 403 `forbidden_host`, on by default in `create_app_server`) and its rate-limited refusal warning (`format_host_refusal_warning`). Twin of the Rust `fuz_http::host`; reads the `Host` lines through `read_host`; verdicts pinned by the host rows of `testing/cross_backend/origin_conformance.json` and, over repeated and empty lines on the wire, by `request_header_conformance.json` (../../../docs/security.md §DNS Rebinding).
|
|
35
42
|
- `http/jsonrpc.ts` — JSON-RPC 2.0 envelope schemas (MCP superset, fuz_schema), `JsonrpcErrorCode`.
|
|
36
43
|
- `http/jsonrpc_errors.ts` — `ThrownJsonrpcError`, `jsonrpc_errors` throwers, HTTP-status mappings.
|
|
37
44
|
- `http/jsonrpc_helpers.ts` — message builders, type guards, input/result normalizers, and `classify_jsonrpc_message`, the one envelope classifier both transports run.
|
|
@@ -52,17 +59,18 @@ consumers.
|
|
|
52
59
|
- `method` — `'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'`
|
|
53
60
|
- `path` — Hono path (supports `:param` segments)
|
|
54
61
|
- `auth: RouteAuth` — flat record `{account, actor, roles?, credential_types?, required_scope?}` from `http/auth_shape.ts`. `account` / `actor` are `'none' | 'optional' | 'required'`. `required_scope` names the capability a narrowed api token's scope must admit — `surface:<name>`, a non-RPC surface refused to every narrowed token (an `rpc:<method>` capability throws at registration: it is the dispatcher's per-method gate, which a route never reaches) — and is route-spec-only: `compile_action_registry` rejects it on an `ActionSpec`, where the dispatcher derives `rpc:<method>` from `spec.method`. Otherwise the same shape governs `ActionSpec.auth` (see `actions/CLAUDE.md`).
|
|
55
|
-
- `handler: RouteHandler` — `(
|
|
62
|
+
- `handler: RouteHandler` — `(route: RouteContext) => RouteResult | Promise<RouteResult>`: the route context in, a result the framework answers with out (§Handlers and results); a handler never receives the Hono context
|
|
56
63
|
- `description` — free-text, surfaced in `AppSurface`
|
|
57
64
|
- `params?: AnySchema` — strict-object schema for URL path params
|
|
58
65
|
- `query?: AnySchema` — strict-object schema for URL query string
|
|
59
|
-
- `input: AnySchema` — request body schema; `literal(null)` for no
|
|
66
|
+
- `input: AnySchema` — request body schema; `literal(null)` for no body, and on every `GET` (`apply_route_specs` refuses any other)
|
|
60
67
|
- `output: AnySchema` — success response schema
|
|
61
68
|
- `mints_credential?: boolean` — the route issues a session cookie while declaring no auth (login, signup, bootstrap); assembly refuses it outside `AUTH_MIDDLEWARE_PATH`, as it does any route whose `auth.account` is not `'none'` (`assert_credential_routes_in_auth_scope` in `auth/middleware.ts`)
|
|
62
|
-
- `reads_credential?: boolean` — the handler reads the resolved account while the route declares no auth gate, answering an anonymous caller itself (account status, the cell-scoped fact read, `create_rpc_endpoint`'s pair, whose dispatcher gates per action); held inside `AUTH_MIDDLEWARE_PATH` by the same assertion. Such a handler reads the account through `
|
|
69
|
+
- `reads_credential?: boolean` — the handler reads the resolved account while the route declares no auth gate, answering an anonymous caller itself (account status, the cell-scoped fact read, `create_rpc_endpoint`'s pair, whose dispatcher gates per action); held inside `AUTH_MIDDLEWARE_PATH` by the same assertion. Such a handler reads the account through `get_public_account` (`auth/request_context.ts`), which answers a scope-narrowed token as anonymous — the RPC pair excepted, its dispatcher gating each method
|
|
63
70
|
- `rate_limit?: RateLimitKey` — metadata only (`'ip' | 'account' | 'both'`); auto-derives 429
|
|
64
71
|
- `errors?: ReadonlyArray<RestErrorDef>` — the handler's own error definitions (`rest_error`); joins the route error map beside the derived and middleware ones
|
|
65
72
|
- `jsonrpc?: boolean` — the route answers JSON-RPC envelopes, not REST bodies; set by `create_rpc_endpoint`, read by the DEV error check and `assert_response_matches_spec`
|
|
73
|
+
- `response_headers?: Record<string, string>` — static headers every answer of the route carries once a request reaches it: its own validation and guard refusals, the handler's result of any kind, and the error catch's 500 and 503. Checked at registration by the raw result's header rules, and refusing the names a body or the framing owns (`ROUTE_RAW_REFUSED_HEADERS`, `Content-Type`, `Content-Length`). A result that names one of them itself is refused at the prepare. Listed on `AppSurfaceRoute`. For a header true of every answer — the RPC `GET`'s `Cache-Control: no-store` — not for a success's own (the fact routes' hardening headers stay on the bytes answer)
|
|
66
74
|
- `transaction?: boolean` — declarative transaction wrapping (see below)
|
|
67
75
|
|
|
68
76
|
Every schema field takes a `@fuzdev/fuz_schema` schema (`AnySchema`),
|
|
@@ -80,26 +88,62 @@ kept by `loose_object`.
|
|
|
80
88
|
|
|
81
89
|
### Handlers and results
|
|
82
90
|
|
|
83
|
-
A handler returns a result,
|
|
84
|
-
response
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
A handler returns a result — data, never a `Response` — and the spine builds
|
|
92
|
+
the response in two steps around the commit. `prepare_route_response` runs
|
|
93
|
+
inside any wrapping transaction and checks everything that could fail: a
|
|
94
|
+
result that can't become a response (a bare `Response`, a result no factory
|
|
95
|
+
made such as `{ok: true}` without `value`, `undefined`, a body
|
|
96
|
+
`JSON.stringify` refuses, a raw result breaking a rule below) throws there,
|
|
97
|
+
rolls back, and discards the post-commit effects. `emit_route_response` runs
|
|
98
|
+
after the commit and is the one place a route result becomes a `Response`, through
|
|
99
|
+
the context, so the context's prepared headers — the clearing `Set-Cookie`
|
|
100
|
+
for an invalid session cookie — are on every one. Nothing a handler returned
|
|
101
|
+
reaches the wire for work that didn't commit: a login whose commit fails
|
|
102
|
+
answers its 500 with no cookie.
|
|
103
|
+
|
|
104
|
+
- `route_ok(value, {set_cookie?})` — `value` as JSON at 200. `set_cookie` is
|
|
105
|
+
the success's own `Set-Cookie` lines (`session_cookie_header`,
|
|
106
|
+
`clear_session_cookie_header` of `auth/session_cookie.ts`), written after
|
|
107
|
+
the context's, in order; a failure can't carry one.
|
|
91
108
|
- `route_fail(def, fields?)` — `{error: def.code, ...fields}` at `def.status`,
|
|
92
109
|
with the headers `def` derives (`REST_RATE_LIMIT_EXCEEDED`'s `Retry-After`).
|
|
93
110
|
`fields` is absent for a bare code, optional when every field is, required
|
|
94
111
|
when any is.
|
|
95
|
-
- `route_raw(
|
|
96
|
-
bytes, a stream,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
`
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
112
|
+
- `route_raw({status, headers?, body?})` — an answer the route spells itself:
|
|
113
|
+
an empty body, text, bytes, a stream, a JSON-RPC envelope. The prepare
|
|
114
|
+
refuses what would not send as written: a status outside 200–599; a header
|
|
115
|
+
in `ROUTE_RAW_REFUSED_HEADERS` (`Set-Cookie` and the hop-by-hop names), a
|
|
116
|
+
name twice in any case, an empty value; a body without a `Content-Type`,
|
|
117
|
+
or on a 204, 205 or 304; a `Content-Length` that is not a canonical
|
|
118
|
+
decimal within the safe integer range (no leading zero), that rides a 204
|
|
119
|
+
or 205, or that, for a text or bytes body, is not its byte length (it is
|
|
120
|
+
free with no body or a stream — a size answered without the bytes); a
|
|
121
|
+
locked stream, detached bytes, a view left out of bounds by a shrunk
|
|
122
|
+
resizable buffer, a `Response`. A stream that was read and released can't
|
|
123
|
+
be told from a fresh one. A stream body's `cancel` must release its
|
|
124
|
+
source: the spine cancels one the route ends up not answering with —
|
|
125
|
+
refused, rolled back by a failed commit, or asked for by `HEAD`.
|
|
126
|
+
- `route_sse(stream)` — an event stream the handler opened with
|
|
127
|
+
`route.open_sse(options)`, so it exists before the handler admits it to a
|
|
128
|
+
registry. Opening writes nothing on the context: the response is built at
|
|
129
|
+
the emit with `SSE_RESPONSE_HEADERS`, and a stream the route opened and
|
|
130
|
+
did not answer with (another result, a throw) is closed. A stream another
|
|
131
|
+
request opened is refused.
|
|
132
|
+
|
|
133
|
+
**`HEAD`.** Hono serves `HEAD` by running the `GET` handler and dropping the
|
|
134
|
+
body unread, so the spine releases what a stream holds: the emit cancels a
|
|
135
|
+
raw stream body and closes an SSE stream (its `on_close` listeners run, its
|
|
136
|
+
registry drops it), then answers the prepared status and headers with no
|
|
137
|
+
body — an SSE answer without its `Connection: keep-alive`, so the
|
|
138
|
+
connection can end. A handler has no `HEAD` branch to write.
|
|
139
|
+
|
|
140
|
+
A response that can't be built after the commit — the runtime refusing what
|
|
141
|
+
the prepare let through — is logged naming the route and answered by the
|
|
142
|
+
error catch's 500; the work stays committed. A handler holds no Hono
|
|
143
|
+
context, so it writes nothing on one: what a response carries is the
|
|
144
|
+
result, the spec's `response_headers`, and what middleware prepared
|
|
145
|
+
(`src/test/route_modules_hono_free.test.ts` holds every module that defines
|
|
146
|
+
a route to importing nothing from Hono and building no `Response`). A failure is plain data
|
|
103
147
|
(`ok: false`), so domain code and shared helpers fail without the context and
|
|
104
148
|
a handler forwards one (`if (!result.ok) return result`). A thrown error is
|
|
105
149
|
still the error catch's.
|
|
@@ -122,21 +166,80 @@ mint, so a spec literal doesn't typecheck; a spread of a spec keeps the brand
|
|
|
122
166
|
and is not checked again (the DEV error check covers a rewritten `auth` or
|
|
123
167
|
`errors`). At runtime they return the spec, or the shape with its handler.
|
|
124
168
|
|
|
125
|
-
### `RouteContext` —
|
|
169
|
+
### `RouteContext` — what a handler gets
|
|
126
170
|
|
|
127
|
-
The
|
|
171
|
+
The handler's one argument, built by `apply_route_specs` from the Hono
|
|
172
|
+
context:
|
|
128
173
|
|
|
129
174
|
```typescript
|
|
130
|
-
interface RouteContext {
|
|
175
|
+
interface RouteContext<TAuth, TInput, TParams, TQuery> {
|
|
176
|
+
// shared with `ActionContext`, same names and types
|
|
177
|
+
auth: TAuth; // RequestContext | null, narrowed by the spec's `auth`
|
|
178
|
+
client_ip: string; // resolved by the trusted proxy; 'unknown' without one
|
|
179
|
+
signal: AbortSignal; // aborts on client disconnect
|
|
131
180
|
db: Db; // transaction-scoped when `transaction: true`, pool-level otherwise
|
|
132
181
|
pending_effects: Array<Promise<void>>; // eager pool writes already in flight
|
|
133
182
|
post_commit_effects: Array<() => void | Promise<void>>; // deferred — push via `emit_after_commit`
|
|
183
|
+
// REST's own
|
|
184
|
+
credential: ResolvedAuth | null; // what the auth middleware resolved
|
|
185
|
+
connection_ip: string | null; // the socket's peer, as the runtime spells it
|
|
186
|
+
input: TInput; // validated body; null for a route with none
|
|
187
|
+
params: TParams; // validated path params; undefined without a `params` schema
|
|
188
|
+
query: TQuery; // validated query; undefined without a `query` schema
|
|
189
|
+
has_test_context_preset: boolean; // a harness pre-built `auth`; never in production
|
|
190
|
+
request: Request; // the raw request: a `raw_body` stream, the undecoded URL
|
|
191
|
+
query_pairs: QueryPairsRead; // the query decoded strictly, or why it doesn't decode; a key read with `query_first(pairs, key)`
|
|
192
|
+
read_json_body: () => Promise<JsonBodyResult>; // the once-per-request JSON read
|
|
193
|
+
header_lines: (name: string) => Array<string>; // a header as the lines sent
|
|
194
|
+
close_connection: () => void; // answer with `Connection: close`
|
|
195
|
+
open_sse: <T = unknown>(options?: RouteOpenSseOptions) => SseStream<T>; // the stream a `route_sse` answers with
|
|
134
196
|
}
|
|
135
197
|
```
|
|
136
198
|
|
|
199
|
+
- **Typed from the spec.** `define_route` and `attach_route_handler` type
|
|
200
|
+
`input`, `params` and `query` from the route's schemas (`TypedRouteContext`),
|
|
201
|
+
so `route.params.x` on a route with no `params` is a type error, and
|
|
202
|
+
`auth` from the route's `auth` through `RequestContextForAuth`
|
|
203
|
+
(`auth/request_context.ts`) — the one conditional `rpc_action`'s
|
|
204
|
+
`HandlerForSpec` also narrows by: an actor-required route gets a
|
|
205
|
+
`RequestActorContext`, an account-required one a `RequestContext`,
|
|
206
|
+
anything else `RequestContext | null`. A handler of a required tier is
|
|
207
|
+
wrapped where it is defined and throws rather than run without the
|
|
208
|
+
context its type promises (a spread spec whose `auth` was loosened
|
|
209
|
+
answers 500, not a handler running on `null`).
|
|
210
|
+
- **`route.credential`** is the whole resolved credential. A
|
|
211
|
+
`reads_credential` route never reads the account off it: it calls
|
|
212
|
+
`get_public_account(route)` (`auth/request_context.ts`), which answers
|
|
213
|
+
a scope-narrowed API token as the anonymous caller
|
|
214
|
+
(`src/test/auth/token_scope_surface_census.test.ts` holds every route
|
|
215
|
+
module to that).
|
|
216
|
+
- **`route.connection_ip`** is the TCP peer, never a forwarded address, and
|
|
217
|
+
not normalized (`::ffff:127.0.0.1` stays that) — for a route that admits
|
|
218
|
+
loopback callers only. `null` when the trusted-proxy middleware isn't
|
|
219
|
+
mounted.
|
|
220
|
+
- **Reading the request.** `query_pairs` is the query string read by
|
|
221
|
+
`read_query_pairs` (`http/request_target.ts`): every pair percent-decoded,
|
|
222
|
+
or the reason it doesn't decode — a handler that reads an undeclared key
|
|
223
|
+
refuses an undecodable query in its own shape (the RPC `GET` its envelope)
|
|
224
|
+
and reads a key with `query_first(pairs, key)` — first occurrence, `''`
|
|
225
|
+
for a key with no value, the cross-implementation contract the
|
|
226
|
+
`query_shape` suite pins;
|
|
227
|
+
`read_json_body()` shares the one body read with the authorization phase
|
|
228
|
+
and input validation; `request` is the raw `Request`, whose body is
|
|
229
|
+
already used on a route the pipeline read a JSON input for.
|
|
230
|
+
- **`route.close_connection()`** makes the spine answer with
|
|
231
|
+
`Connection: close` whatever the result, the error catch's answer
|
|
232
|
+
included, so the runtime drops a connection whose request body nothing
|
|
233
|
+
will read. A raw result can't carry the header itself, and an SSE answer
|
|
234
|
+
after it is refused.
|
|
137
235
|
- **`route.db`** — handler's main DB work. Wrapped in a transaction when `transaction: true` (default for non-GET); routes that opt out (`transaction: false`, e.g. signup / bootstrap) get the pool here directly and may call `route.db.transaction(...)` for their own scope.
|
|
138
236
|
- **`route.pending_effects`** — direct push for eager fire-and-forget pool writes (audit, api-token usage tracking).
|
|
139
237
|
- **`route.post_commit_effects`** — do not push directly; reach for `emit_after_commit` from `http/pending_effects.ts`. The helper pushes a thunk that the flush middleware invokes after the handler returns, closing the microtask-ordering window that an eager `Promise.resolve().then(fn)` leaves open inside the wrapping `db.transaction`.
|
|
238
|
+
- **`route.open_sse(options)`** — opens the event stream the route answers with (`route_sse(stream)`) through the opener `apply_route_specs` was given (`create_sse_stream`, wired by `create_app_server`). It writes nothing on the context; a stream not answered with is closed. Without an opener it throws.
|
|
239
|
+
|
|
240
|
+
Middleware, the authorization phase and the WebSocket upgrade still run on
|
|
241
|
+
the Hono context and read it through their own helpers (`get_client_ip(c)`,
|
|
242
|
+
`get_resolved_auth(c)`, `get_header_lines(c, name)`).
|
|
140
243
|
|
|
141
244
|
Audit rows run through the bound `AppDeps.audit` capability — see
|
|
142
245
|
`auth/CLAUDE.md` §Audit emitter. `await deps.audit.emit(route, input)` writes
|
|
@@ -157,15 +260,20 @@ wrapper). See `auth/signup_routes.ts`.
|
|
|
157
260
|
|
|
158
261
|
### Validation pipeline (per-route middleware order)
|
|
159
262
|
|
|
160
|
-
`apply_route_specs`
|
|
263
|
+
`apply_route_specs(app, specs, resolve_auth_guards, log, db, {authorize?, open_sse?})` — `open_sse` is the `RouteSseOpener`, `create_sse_stream` in the assembled server.
|
|
264
|
+
|
|
265
|
+
`apply_route_specs` assembles the following middleware chain per spec, behind
|
|
266
|
+
one stage that writes the spec's `response_headers` on the context (when it
|
|
267
|
+
declares any), so every stage after it answers with them:
|
|
161
268
|
|
|
162
|
-
|
|
163
|
-
|
|
269
|
+
0. **Content type** — every `POST` route: `is_post_content_type_refused(read_content_type(...), raw_body)` → 415 `ERROR_UNSUPPORTED_CONTENT_TYPE`, before any credential or body read (`http/simple_request.ts`)
|
|
270
|
+
1. **Params validation** — `spec.params` → `validated_params` context var; mismatch returns 400 `ERROR_INVALID_ROUTE_PARAMS` with `issues`. Each param is decoded strictly from the raw target first (`read_request_route_params`): an escape that doesn't decode is the same 400 with no `issues`, whatever the schema
|
|
271
|
+
2. **Query validation** — `spec.query` → `validated_query`; mismatch returns 400 `ERROR_INVALID_QUERY_PARAMS`. The query is decoded strictly first (`read_request_query_pairs`): an escape that doesn't decode, in any key or value, is the same 400
|
|
164
272
|
3. **Pre-authorization auth guards** — every gate that reads only what the auth middleware set, in coarse-to-fine order: `require_auth` (401 `ERROR_AUTHENTICATION_REQUIRED`) when `auth.account === 'required'` or `auth.actor === 'required'`; `require_credential_types(types)` (403 `ERROR_CREDENTIAL_TYPE_REQUIRED` with `required_credential_types: ReadonlyArray<string>`) when `auth.credential_types?.length`; `require_token_scope(capability)` (403 `ERROR_TOKEN_SCOPE_REQUIRED` with `required_scope`, the token-scope refusal) when `auth.required_scope` names a capability. All fire before any body parsing — so a caller they refuse never sees route-shape information from input parse failures — and before actor resolution, so a wrong channel costs no DB work and never learns account state (e.g. that the account is multi-actor). The `AuthGuardResolver` (e.g. `fuz_auth_guard_resolver` from `auth/auth_guard_resolver.ts`) returns this set as `pre_authorization: Array<MiddlewareHandler>`.
|
|
165
|
-
4. **Authorization phase** — when `spec.auth.actor !== 'none'`, resolves the acting actor against the resolved credential's account (`get_resolved_auth`, set by the auth middleware) plus the `acting` selector (`validated_query.acting` on GETs; read off the raw body on mutations, since body validation now runs after the gates), builds `RequestContext` via `build_request_context`, and sets `REQUEST_CONTEXT_KEY`. When `auth.account !== 'none' && auth.actor === 'none'`, an account-only context is built. Resolution failures return 400 `ERROR_ACTOR_REQUIRED` (with `available[]`) or `ERROR_ACTOR_NOT_ON_ACCOUNT` (or 500 `ERROR_NO_ACTORS_ON_ACCOUNT` on signup-invariant violation
|
|
273
|
+
4. **Authorization phase** — when `spec.auth.actor !== 'none'`, resolves the acting actor against the resolved credential's account (`get_resolved_auth`, set by the auth middleware) plus the `acting` selector (`validated_query.acting` on GETs; read off the raw body on mutations, since body validation now runs after the gates), builds `RequestContext` via `build_request_context`, and sets `REQUEST_CONTEXT_KEY`. When `auth.account !== 'none' && auth.actor === 'none'`, an account-only context is built. Resolution failures return 400 `ERROR_ACTOR_REQUIRED` (with `available[]`) or `ERROR_ACTOR_NOT_ON_ACCOUNT` (or 500 `ERROR_NO_ACTORS_ON_ACCOUNT` on signup-invariant violation — a live account with no actor — and 401 `ERROR_AUTHENTICATION_REQUIRED` when the account was deleted or purged after the credential leg read it). The phase builds on the account row that leg read, reading the account again only to tell a removed account from one with no actor. Public routes (`account: 'none' && actor: 'none'`) skip this phase entirely.
|
|
166
274
|
5. **Post-authorization auth guards** — `require_role(roles)` (403 `ERROR_INSUFFICIENT_PERMISSIONS` with `required_roles: ReadonlyArray<string>`) when `auth.roles?.length`. The only gate in this phase, because it is the only one that reads `REQUEST_CONTEXT_KEY` (populated by step 4) rather than the auth middleware's own context vars. Multi-role specs admit any-of via `has_any_scoped_role(ctx, roles, null)`.
|
|
167
|
-
6. **Input validation** — JSON body parsed (`read_json_body`) + validated; mismatch returns 400 `ERROR_INVALID_JSON_BODY` (not JSON, or JSON the Rust spine refuses — `parse_json_text`) or `ERROR_INVALID_REQUEST_BODY` (schema failure with `issues`). Every schema refusal's `issues` are `WireIssue`s (`to_wire_issues`, `schema_issues.ts`), sent under DEV only (`dev_only`). Skipped on
|
|
168
|
-
7. **Handler** — wrapped in transaction when `use_transaction` (see above), receives `RouteContext`; its result
|
|
275
|
+
6. **Input validation** — JSON body parsed (`read_json_body`) + validated; mismatch returns 400 `ERROR_INVALID_JSON_BODY` (not JSON, or JSON the Rust spine refuses — `parse_json_text`) or `ERROR_INVALID_REQUEST_BODY` (schema failure with `issues`). Every schema refusal's `issues` are `WireIssue`s (`to_wire_issues`, `schema_issues.ts`), sent under DEV only (`dev_only`). Skipped on a null input (`is_null_schema`: `literal(null)`), which every `GET` has — `apply_route_specs` refuses a `GET` with any other input. The validated input lands on `c.var.validated_input`.
|
|
276
|
+
7. **Handler** — wrapped in transaction when `use_transaction` (see above), receives `RouteContext`; its result is prepared inside the transaction and emitted after the commit (`prepare_route_response`, `emit_route_response`)
|
|
169
277
|
8. **Error catch** — catches a thrown JSON-RPC error (`ThrownJsonrpcError`, recognized by brand through `to_thrown_jsonrpc_error`, so one from a second fuz_app copy maps too; a foreign error class carrying a JSON-RPC `code` falls to the generic path) → maps to HTTP status + the flat REST error body (`{error: <reason>, message?, ...rest_data}`); catches generic `Error` → 500 `{error: 'internal_error', message?}` (message only in DEV). The reason string comes from `err.data.reason` when set (consumer-supplied canonical reason override) or from `jsonrpc_error_code_to_name(err.code)` (e.g. `-32003 → 'not_found'`). The flat shape matches what middleware and direct handlers emit — REST callers see one envelope across every emit site, while the JSON-RPC dispatcher keeps its own `{jsonrpc, id, error: {code, message, data}}` envelope on the RPC mount.
|
|
170
278
|
9. **DEV-only output validation** — a 2xx JSON body against `spec.output` (see below); error responses are the outer DEV error check's
|
|
171
279
|
|
|
@@ -182,11 +290,8 @@ GETs.
|
|
|
182
290
|
|
|
183
291
|
Duplicate `method path` pairs throw at registration.
|
|
184
292
|
|
|
185
|
-
|
|
186
|
-
`
|
|
187
|
-
matching schema, and the return type infers as `Infer<typeof schema>`.
|
|
188
|
-
Each helper has a `<T>(c)` overload (no schema arg) for callers without the
|
|
189
|
-
schema in scope.
|
|
293
|
+
A handler reads the validated values as `route.input`, `route.params` and
|
|
294
|
+
`route.query`, typed from the spec's schemas.
|
|
190
295
|
|
|
191
296
|
### DEV-only output + error validation
|
|
192
297
|
|
|
@@ -197,7 +302,8 @@ are the contract with external callers.
|
|
|
197
302
|
`esm-env`, each in one place:
|
|
198
303
|
|
|
199
304
|
- **Output** — `wrap_output_validation`, per route: a 2xx JSON body against `spec.output`. Skips non-`application/json` responses so SSE doesn't hang on `.json()`.
|
|
200
|
-
- **Errors** — `create_dev_route_error_check` (`http/dev_route_error_check.ts`), one outer middleware `create_app_server` mounts outermost (`app.use('*')`, first after `onError`), so it sees what every layer answers — a middleware's refusal (body limit, origin, auth guards) as much as a handler's or the error catch's. After the request it finds the route with Hono's own router (`create_route_lookup`: the `SmartRouter` over a `RegExpRouter` and a `TrieRouter` that `new Hono()` builds, the route specs added in mount order, the first match the route, `HEAD` read as `GET`) and checks a JSON body at 400 and up against the route's error map (`check_route_error`, `http/route_error_check.ts`): a status the map lacks logs `Undeclared error status (S): METHOD path`, a body off the status's schema `Error schema mismatch (S): METHOD path`. Always accepted: a 500 `internal_error` and a 503 `service_unavailable` (`ALWAYS_ACCEPTED_ERRORS`, which the catch layers answer on any route). On a `jsonrpc` route (the pair `create_rpc_endpoint` builds) a JSON-RPC error envelope is skipped (`is_jsonrpc_error_response`): the endpoint answers its refusals as envelopes, which no REST error definition describes, and the dispatch core checks its own outputs. On any other route an envelope-shaped body is checked. Skipped: non-JSON responses (`is_json_response`, the gate both checks run), and a request no route spec matches —
|
|
305
|
+
- **Errors** — `create_dev_route_error_check` (`http/dev_route_error_check.ts`), one outer middleware `create_app_server` mounts outermost (`app.use('*')`, first after `onError`), so it sees what every layer answers — a middleware's refusal (body limit, origin, auth guards) as much as a handler's or the error catch's. After the request it finds the route with Hono's own router (`create_route_lookup`: the `SmartRouter` over a `RegExpRouter` and a `TrieRouter` that `new Hono()` builds, the route specs added in mount order, the first match the route, `HEAD` read as `GET`) and checks a JSON body at 400 and up against the route's error map (`check_route_error`, `http/route_error_check.ts`): a status the map lacks logs `Undeclared error status (S): METHOD path`, a body off the status's schema `Error schema mismatch (S): METHOD path`. Always accepted: a 500 `internal_error` and a 503 `service_unavailable` (`ALWAYS_ACCEPTED_ERRORS`, which the catch layers answer on any route). On a `jsonrpc` route (the pair `create_rpc_endpoint` builds) a JSON-RPC error envelope is skipped (`is_jsonrpc_error_response`): the endpoint answers its refusals as envelopes, which no REST error definition describes, and the dispatch core checks its own outputs. On any other route an envelope-shaped body is checked. Skipped: non-JSON responses (`is_json_response`, the gate both checks run), and a request no route spec matches — the 405 and 404s of the unmatched-route handler (`server/unmatched_route.ts`) are no route's answer. `assert_response_matches_spec` runs the same `check_route_error`.
|
|
306
|
+
- **The first `Set-Cookie`** — `create_dev_set_cookie_check` (`http/dev_set_cookie_check.ts`), mounted beside the error check: when a middleware recorded the line it put first on the response (`EXPECTED_FIRST_SET_COOKIE_KEY` — the session middleware's clear of an invalid cookie), the answer's first `Set-Cookie` must be that line, else it logs naming the method and path. It reaches what the route system doesn't build — a consumer's `post_route_middleware`, a raw Hono route, a `transform_middleware` layer answering with its own `Response` or replacing the context's cookie. An accepted WebSocket upgrade's placeholder is skipped.
|
|
201
307
|
- **Logs on mismatch, returns the response unchanged** — never throws (a throw inside the error check, its logger's included, is swallowed), never mutates the body
|
|
202
308
|
|
|
203
309
|
Production short-circuits: `wrap_output_validation` returns the handler
|
|
@@ -246,9 +352,9 @@ are both kept, a union of their bodies. The result, `RouteErrorMap`, holds the
|
|
|
246
352
|
definitions (`defs`) and the status map they group into (`schemas`):
|
|
247
353
|
|
|
248
354
|
1. **Derived** — `derive_route_errors({method, auth, has_input?, has_params?, has_query?, rate_limit?})`, narrowed to the slots the route has:
|
|
249
|
-
- a body — `input` not null, `method` not `GET` (
|
|
355
|
+
- a body — `input` not null, `method` not `GET` (registration refuses a `GET` with an input; a surface built from specs alone derives none for one) → 400 `invalid_request_body`, `invalid_json_body`
|
|
250
356
|
- `params` → 400 `invalid_route_params`; `query` → 400 `invalid_query_params`
|
|
251
|
-
- `auth.actor !== 'none'` → 400 `actor_required`, `actor_not_on_account`, 500 `no_actors_on_account`, `
|
|
357
|
+
- `auth.actor !== 'none'` → 400 `actor_required`, `actor_not_on_account`, 500 `no_actors_on_account`, 401 `authentication_required` (an account removed after the credential leg read it — declared on an actor-optional route too) — what the dispatcher's authorization phase emits on routes whose input declares `acting?: ActingActor` (per registry-time invariant 2)
|
|
252
358
|
- `auth.account === 'required'` or `auth.actor === 'required'` → 401 `authentication_required` (`REST_AUTHENTICATION_REQUIRED`), the only body the pre-authorization gate answers
|
|
253
359
|
- `auth.required_scope` → 403 `token_scope_required`; `auth.credential_types?.length` → 403 `credential_type_required`; `auth.roles?.length` → 403 `insufficient_permissions` — in the order the gates fire, each carrying what the route demanded
|
|
254
360
|
- `rate_limit` → 429 `rate_limit_exceeded` (`retry_after`, a non-negative integer of seconds)
|
|
@@ -303,6 +409,7 @@ confirmation.
|
|
|
303
409
|
- **Auth**: `ERROR_AUTHENTICATION_REQUIRED`, `ERROR_INSUFFICIENT_PERMISSIONS`, `ERROR_CREDENTIAL_TYPE_REQUIRED`, `ERROR_RATE_LIMIT_EXCEEDED`, `ERROR_INVALID_CREDENTIALS`, `ERROR_PAYLOAD_TOO_LARGE`, `ERROR_INVALID_CONTENT_LENGTH`
|
|
304
410
|
- **Origin + bearer**: `ERROR_FORBIDDEN_ORIGIN`, `ERROR_INVALID_TOKEN`, `ERROR_ACCOUNT_NOT_FOUND`
|
|
305
411
|
- **Keeper/daemon**: `ERROR_KEEPER_ACCOUNT_NOT_FOUND`
|
|
412
|
+
- **Routing + gates**: `ERROR_METHOD_NOT_ALLOWED`, `ERROR_ROUTE_NOT_FOUND` (+ `NOT_FOUND_TEXT`, the plain-text 404 outside `/api/`), `ERROR_FORBIDDEN_HOST`, `ERROR_UNSUPPORTED_CONTENT_TYPE`
|
|
306
413
|
- **Bootstrap**: `ERROR_ALREADY_BOOTSTRAPPED`, `ERROR_TOKEN_FILE_MISSING`
|
|
307
414
|
- **Signup/invites**: `ERROR_NO_MATCHING_INVITE`, `ERROR_SIGNUP_CONFLICT`, `ERROR_INVITE_NOT_FOUND`, `ERROR_INVITE_DUPLICATE`, `ERROR_INVITE_ACCOUNT_EXISTS_USERNAME`, `ERROR_INVITE_ACCOUNT_EXISTS_EMAIL`
|
|
308
415
|
- **Admin**: `ERROR_ROLE_NOT_WEB_GRANTABLE`, `ERROR_ROLE_GRANT_NOT_FOUND`, `ERROR_INVALID_EVENT_TYPE`
|
|
@@ -430,8 +537,8 @@ CSRF is handled by `SameSite: strict` on session cookies (`auth/session_middlewa
|
|
|
430
537
|
- `parse_allowed_origins(raw)` — comma-separated entries → `Result<{origins: Array<RegExp>}, {errors: Array<AllowedOriginsError>}>`; every refused entry is reported (`{kind, index, entry}`, 1-based), a blank value is `{kind: 'no_origins'}`
|
|
431
538
|
- `OriginPatternErrorKind` / `AllowedOriginsErrorKind` — the refusal kinds, fuz_schema `one_of`s whose `def` is the names, wire names shared with the Rust spine; `ALLOWED_ORIGINS_ERROR_MESSAGES` the reason per kind, `format_allowed_origins_error` one refusal as a boot-error line (entry quoted and escaped)
|
|
432
539
|
- `should_allow_origin(origin, patterns)` — case-insensitive match; a value that isn't visible ASCII matches nothing
|
|
433
|
-
- `verify_request_source(allowed_patterns, carve_outs?)` — Hono handler: `Origin`
|
|
434
|
-
- `is_browser_context(
|
|
540
|
+
- `verify_request_source(allowed_patterns, carve_outs?)` — Hono handler: one `Origin` line → must match allowlist or 403 `ERROR_FORBIDDEN_ORIGIN`; no `Origin` → allow through (curl, CLI, token auth is primary control). It reads the lines the client sent (`read_origin` over `get_header_lines`), so an empty or repeated `Origin` is refused on every runtime, a WebSocket upgrade on `@hono/node-server` included. A request whose path a `carve_outs` entry (`MiddlewareCarveOut`, `{path, reason}`) matches passes unchecked
|
|
541
|
+
- `is_browser_context(origin_lines, referer_lines)` (`http/request_headers.ts`) — true when the request carries any `Origin` or `Referer` line, an empty one included. The bearer + daemon-token middleware discard their credential when true; twin of the Rust spine's `fuz_http::is_browser_context`. Distinct from `verify_request_source` (allowlist gate) — this only detects browser context
|
|
435
542
|
|
|
436
543
|
**Origin-only by design.** Fetch spec mandates `Origin` on every unsafe
|
|
437
544
|
method, so a real browser request on any state-changing surface always
|
|
@@ -611,10 +718,11 @@ two-sided contract + Rust-twin parity note live on the helper's TSDoc in
|
|
|
611
718
|
`http/pending_effects.ts`.
|
|
612
719
|
|
|
613
720
|
```typescript
|
|
614
|
-
emit_after_commit(ctx, () => notification_sender.send_to_account(account_id, msg));
|
|
721
|
+
emit_after_commit(ctx, () => ctx.notification_sender.send_to_account(account_id, msg));
|
|
615
722
|
```
|
|
616
723
|
|
|
617
|
-
Used for WS sends (`
|
|
724
|
+
Used for WS sends (`ctx.notification_sender`, through
|
|
725
|
+
`queue_offer_notification` / `queue_supersede_notifications` for the
|
|
618
726
|
role-grant-offer notifications — see `auth/CLAUDE.md` §WS notifications),
|
|
619
727
|
a revocation's connection closes (`queue_connection_close` — see
|
|
620
728
|
`actions/CLAUDE.md` §Connection closer), the audit emitter's listener fan-out
|
|
@@ -116,9 +116,9 @@ export interface RouteAuth {
|
|
|
116
116
|
*
|
|
117
117
|
* - `surface:<name>` — a non-RPC surface, refused to every narrowed token
|
|
118
118
|
* whatever its method list says (token scoping's rule that a narrowed
|
|
119
|
-
* token is RPC-only). `surface:audit_stream`, `surface:fact_bare`,
|
|
120
|
-
* `surface:
|
|
121
|
-
*
|
|
119
|
+
* token is RPC-only). `surface:audit_stream`, `surface:fact_bare`, and
|
|
120
|
+
* `surface:app_surface` are the spine's route-spec ones; a consumer names
|
|
121
|
+
* its own without registering it.
|
|
122
122
|
*
|
|
123
123
|
* The `rpc:<method>` arm of that vocabulary is the dispatcher's per-method
|
|
124
124
|
* gate, which a route never reaches, so a route may not declare it.
|
|
@@ -134,7 +134,7 @@ export interface RouteAuth {
|
|
|
134
134
|
* RPC endpoint runs its own per-method check inside the dispatcher, the
|
|
135
135
|
* `reads_credential` routes that answer anonymous callers (account status,
|
|
136
136
|
* the cell-scoped fact read) can't take the field and answer a narrowed
|
|
137
|
-
* token as anonymous in their handler (`
|
|
137
|
+
* token as anonymous in their handler (`get_public_account`), and the
|
|
138
138
|
* server-status route admits a narrowed token by design — and all are
|
|
139
139
|
* route specs too.
|
|
140
140
|
*
|
|
@@ -97,7 +97,7 @@ export const create_ready_route_spec = (options) => {
|
|
|
97
97
|
input: literal(null),
|
|
98
98
|
output: object({ ready: literal(true) }),
|
|
99
99
|
errors: [REST_SCHEMA_DRIFT, REST_DB_UNREACHABLE],
|
|
100
|
-
handler: async (
|
|
100
|
+
handler: async (route) => {
|
|
101
101
|
try {
|
|
102
102
|
const drift = await check_schema_drift(route.db, options.expected);
|
|
103
103
|
if (drift.ok)
|
package/dist/http/db_routes.d.ts
CHANGED
|
@@ -78,9 +78,10 @@ export declare const NON_BROWSABLE_TABLES: ReadonlyArray<string>;
|
|
|
78
78
|
* surface. It is also part of how revocation propagates: the revocation guard
|
|
79
79
|
* (`create_revocation_guard`) closes live connections by listening to audit
|
|
80
80
|
* events, so a raw row delete here is invisible to it.
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
81
|
+
* - `bootstrap_lock` — deleting the singleton closes bootstrap for good:
|
|
82
|
+
* `check_bootstrap_status` reads a missing row as unavailable (logged as an
|
|
83
|
+
* error), so a database that has not bootstrapped never can until the row
|
|
84
|
+
* is restored.
|
|
84
85
|
* - `app_settings` — deleting the singleton makes every settings read throw.
|
|
85
86
|
* - `schema_version` — the migration tracker. Already refused by the
|
|
86
87
|
* single-column-primary-key rule (its key is `(namespace, name)`), but that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db_routes.d.ts","sourceRoot":"","sources":["../../src/lib/http/db_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAsBtD,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"db_routes.d.ts","sourceRoot":"","sources":["../../src/lib/http/db_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAsBtD,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAc/D;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB;AAwCD,sDAAsD;AACtD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,sDAAsD;AACtD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAKrD,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAKrD,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;;;;;OAMG;IACH,KAAK,EAAE;QACN,SAAS,EAAE,CAAC,KAAK,EAAE;YAClB,UAAU,EAAE,qBAAqB,CAAC;YAClC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;YACxB,EAAE,EAAE,MAAM,CAAC;YACX,QAAQ,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,MAAM,CAAC;gBAAC,EAAE,EAAE,MAAM,CAAA;aAAE,CAAC;SAC3D,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,8EAA8E;IAC9E,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C;AA2CD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,WAAW,EACjB,SAAS,cAAc,KACrB,KAAK,CAAC,SAAS,CA8VjB,CAAC"}
|