@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/actions/CLAUDE.md
CHANGED
|
@@ -190,7 +190,7 @@ use `auth: {account: 'none', actor: 'none'}` and `transaction: false`.
|
|
|
190
190
|
|
|
191
191
|
The HTTP RPC dispatcher is a thin shim around `perform_action`
|
|
192
192
|
(`actions/perform_action.ts`). The shim owns wire-shape concerns (envelope
|
|
193
|
-
parsing, GET vs POST split, the envelope responses — each a `route_raw`); the
|
|
193
|
+
parsing, GET vs POST split, the envelope responses — each a `route_raw` data result); the
|
|
194
194
|
auth/validation/dispatch pipeline is shared with the WebSocket dispatcher.
|
|
195
195
|
|
|
196
196
|
**Phase order: 401 → authz → 403 → 429 → 400 → handler.** Authorize first,
|
|
@@ -205,12 +205,12 @@ spines, and an authorized one is `invalid_params`.
|
|
|
205
205
|
|
|
206
206
|
Shim responsibilities (per-request):
|
|
207
207
|
|
|
208
|
-
1. Parse envelope (POST body / GET query string, each through `parse_json_text`, `http/json_text.ts`, so JSON the Rust spine refuses is refused here too); parse errors → `parse_error` 400, a `GET` `params` that is no JSON `invalid_params`. GET reads `method` / `id` / `params`
|
|
208
|
+
1. Parse envelope (POST body / GET query string, each through `parse_json_text`, `http/json_text.ts`, so JSON the Rust spine refuses is refused here too); parse errors → `parse_error` 400, a `GET` `params` that is no JSON `invalid_params`. GET reads `method` / `id` / `params` with `query_first` over `route.query_pairs` (the query decoded strictly, `http/request_target.ts`) — a query holding an escape that doesn't decode is `invalid_request` on `id: null` with reason `undecodable query string` (`RPC_GET_UNDECODABLE_QUERY_REASON`), ahead of the method lookup; first occurrence wins on a duplicated key, unknown keys are ignored, and an empty value counts as missing. This is the cross-impl contract (the Rust GET dispatch mirrors it via `fuz_http`'s `query_first`, including the id numeric-vs-string normalization), pinned by the `query_shape` cross suite.
|
|
209
209
|
2. Lookup method in the `compile_action_registry`-built map; unknown → `method_not_found`.
|
|
210
|
-
3. GET read restriction — GET rejected for `side_effects: true` actions. Every
|
|
211
|
-
4. Build `PerformActionInput` from
|
|
210
|
+
3. GET read restriction — GET rejected for `side_effects: true` actions. Every answer of the GET route carries `Cache-Control: no-store` (`RPC_GET_CACHE_CONTROL`), declared as the spec's `response_headers`, so the handler's refusals and the error catch's 500 carry it too; a refusal by middleware ahead of the route, like the origin 403, does not: a read answers one caller at one moment.
|
|
211
|
+
4. Build `PerformActionInput` from the route context: `route.credential`, `route.client_ip`, `route.signal`. The test-preset escape hatch reads `route.has_test_context_preset` and `route.auth`.
|
|
212
212
|
5. Call `perform_action` (shared core).
|
|
213
|
-
6. Bind result via `serialize_action_result(id, result, method, log)` (`actions/perform_action.ts`, shared with WS) → `{body, status}`,
|
|
213
|
+
6. Bind result via `serialize_action_result(id, result, method, log)` (`actions/perform_action.ts`, shared with WS) → `{body, status}`, spelled with `c.json`'s bytes and content type as a `route_raw` data result, as is every envelope the shim answers: no REST definition describes one.
|
|
214
214
|
|
|
215
215
|
Error paths: `ThrownJsonrpcError` (recognized through
|
|
216
216
|
`to_thrown_jsonrpc_error` in `http/jsonrpc_errors.ts` by its realm-global
|
|
@@ -261,7 +261,9 @@ interface RpcAction {
|
|
|
261
261
|
`rpc_action<TSpec extends RequestResponseActionSpec>(spec, handler)` pins
|
|
262
262
|
the handler's input / output types to `Infer<TSpec['input']>` /
|
|
263
263
|
`Infer<TSpec['output']>` and tightens `ctx.auth` per the conditional
|
|
264
|
-
`HandlerForSpec<TSpec
|
|
264
|
+
`HandlerForSpec<TSpec>`, built on `RequestContextForAuth`
|
|
265
|
+
(`auth/request_context.ts`) — the same narrowing a REST handler's
|
|
266
|
+
`route.auth` takes:
|
|
265
267
|
|
|
266
268
|
- `auth.actor === 'required'` → `ctx.auth: RequestActorContext`.
|
|
267
269
|
- `auth.account === 'required' && auth.actor === 'none'` → `ctx.auth: RequestContext`.
|
|
@@ -273,11 +275,9 @@ at the factory call instead of at runtime. The bracketed form
|
|
|
273
275
|
`AuthAxisState` union (when the spec was typed without preserving its
|
|
274
276
|
literal) falls through to the loosest tier instead of the narrowest.
|
|
275
277
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
`options.app_settings`, `options.max_tokens`), so per-pair typing via
|
|
280
|
-
`rpc_action()` is the right shape here.
|
|
278
|
+
fuz_app's handlers close over factory-captured deps (`log`, `audit`,
|
|
279
|
+
`options.max_tokens`), so per-pair typing via `rpc_action()` is the shape
|
|
280
|
+
that fits.
|
|
281
281
|
|
|
282
282
|
## Shared dispatch core (`actions/perform_action.ts`)
|
|
283
283
|
|
|
@@ -295,7 +295,7 @@ Pipeline (401 → authz → 403 → 429 → 400 → handler):
|
|
|
295
295
|
5. Validate params (400) — first, one walk of object params (`scan_json_value` in `http/schema_helpers.ts`, iterative) refuses, on every input, an own `__proto__` key at any depth with `data.reason` `params_proto_key` (`ERROR_PARAMS_PROTO_KEY`), then U+0000 in any string or key with `params_nul` (`ERROR_PARAMS_NUL` — Postgres refuses it in `text` and `jsonb`); the Rust twin walks after its params-shape check, so a non-object `params` stays the schema's reasonless refusal; then `spec.input` parses them (`parse`) with void / `?? {}` rules; a void input (`is_void_schema`: `s.void`) reads absent, `null` (GET `?params=null`), and `{}` alike as the no-arg call (`to_input_params` in `http/schema_helpers.ts`, via `to_void_params`, the twin of the Rust `require_void_params`; the peer receive path in `ActionDispatcher` runs the same normalizer) and refuses any other shape. A refusal is `to_invalid_params_error`: the generic `invalid params`, `data.reason` when the first issue's field declares an `invalid_reason` in its `meta` and no issue sits on the input itself, such as an unknown key (`resolve_issues_invalid_reason`, `schema_meta.ts` — see ../../../docs/architecture.md §Error Schema System), and the issues DEV-only, as `WireIssue`s (`to_wire_issues`)
|
|
296
296
|
6. Dispatch + DEV output validation + error normalization — `spec.side_effects` picks transaction vs pool. `ThrownJsonrpcError` preserves code + data; generic throws become `internal_error`
|
|
297
297
|
|
|
298
|
-
`PerformActionInput` carries `
|
|
298
|
+
`PerformActionInput` carries `credential` (the request's `ResolvedAuth`, `null` for
|
|
299
299
|
anonymous — the authorization phase reads its account, the post-authorization
|
|
300
300
|
gates its type and scope, `ActionContext` its type and session hash),
|
|
301
301
|
`client_ip`, `signal`, `notify`, optional `connection_id`, optional `preset`.
|
|
@@ -841,12 +841,12 @@ shape `{account: 'required', actor: 'required', roles?, required_scope:
|
|
|
841
841
|
1. `verify_request_source(allowed_origins)` — 403
|
|
842
842
|
2. `require_auth` — 401
|
|
843
843
|
3. `require_token_scope('surface:ws_upgrade')` — a narrowed token cannot hold a socket (403 `token_scope_required`)
|
|
844
|
-
4. The authorization phase (`run_authorization_phase`, `auth/request_context.ts`) — resolves the acting actor (`?acting=` through `parse_acting`; malformed reads as omitted, and the route declares no query schema, so a credential-less `?acting=garbage` is still the 401), seeds `REQUEST_CONTEXT_KEY`
|
|
844
|
+
4. The authorization phase (`run_authorization_phase`, `auth/request_context.ts`) — resolves the acting actor (`?acting=` through `parse_acting`; malformed reads as omitted, and the route declares no query schema, so a credential-less `?acting=garbage` is still the 401; a query holding an escape that doesn't decode is refused here, 400 `invalid_query_params`, after the 401 and the scope gate), seeds `REQUEST_CONTEXT_KEY`
|
|
845
845
|
5. `require_role(required_roles)` when the endpoint is gated — any-of disjunction (coarse upgrade-time gate; per-action `auth` in each spec still applies at dispatch time)
|
|
846
846
|
6. `upgradeWebSocket`
|
|
847
847
|
|
|
848
848
|
Only `GET` is mounted (Hono serves `HEAD` through it, guards included), so any
|
|
849
|
-
other method on the path is a 404. Takes
|
|
849
|
+
other method on the path is the app's 405 (`Allow: GET, HEAD`; `server/unmatched_route.ts`), and a `GET` asking for no upgrade its 404. Takes
|
|
850
850
|
`allowed_origins` (required — `create_app_server` passes the server's), the
|
|
851
851
|
required `connection_closer` and action limiters, and optional
|
|
852
852
|
`required_roles`; returns `{registry}`. Most consumers reach for
|
|
@@ -17,10 +17,18 @@ import type { RpcAction } from './action_types.js';
|
|
|
17
17
|
import { type RouteSpec } from '../http/route_spec.js';
|
|
18
18
|
import type { RateLimiter } from '../rate_limiter.js';
|
|
19
19
|
/**
|
|
20
|
-
* The `Cache-Control` every
|
|
21
|
-
* — a read is per caller and per moment, so nothing may store it.
|
|
20
|
+
* The `Cache-Control` every answer of the RPC endpoint's `GET` route carries
|
|
21
|
+
* — a read is per caller and per moment, so nothing may store it. Declared as
|
|
22
|
+
* the route's `response_headers`, so the error catch's answer carries it too.
|
|
22
23
|
*/
|
|
23
24
|
export declare const RPC_GET_CACHE_CONTROL = "no-store";
|
|
25
|
+
/**
|
|
26
|
+
* The `data.reason` of the RPC `GET`'s `invalid_request` when an escape in
|
|
27
|
+
* its query string doesn't decode (`read_query_pairs`) — before any key is
|
|
28
|
+
* read, so the answer echoes no id. The Rust spine's `rpc_get_handler`
|
|
29
|
+
* answers the same literal.
|
|
30
|
+
*/
|
|
31
|
+
export declare const RPC_GET_UNDECODABLE_QUERY_REASON = "undecodable query string";
|
|
24
32
|
/** Options for `create_rpc_endpoint`. */
|
|
25
33
|
export interface CreateRpcEndpointOptions {
|
|
26
34
|
/** Mount path for the endpoint (e.g., `/api/rpc`). */
|
|
@@ -74,9 +82,10 @@ export interface CreateRpcEndpointOptions {
|
|
|
74
82
|
* 8. **Dispatch** — acquire DB handle (transaction for mutations, pool for reads),
|
|
75
83
|
* construct `ActionContext`, call handler, return JSON-RPC response.
|
|
76
84
|
*
|
|
77
|
-
* GET is restricted to `side_effects: false` actions, and every
|
|
78
|
-
* GET
|
|
79
|
-
* (`RPC_GET_CACHE_CONTROL`)
|
|
85
|
+
* GET is restricted to `side_effects: false` actions, and every answer of the
|
|
86
|
+
* GET route, its refusals and the error catch's included, carries
|
|
87
|
+
* `Cache-Control: no-store` (`RPC_GET_CACHE_CONTROL`, its `response_headers`)
|
|
88
|
+
* — a refusal by middleware ahead of the route does not.
|
|
80
89
|
* All errors use JSON-RPC format: `{jsonrpc, id, error: {code, message, data?}}`.
|
|
81
90
|
*
|
|
82
91
|
* The RouteSpecs use `auth: {type: 'none'}` because auth is checked per-action
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_rpc.d.ts","sourceRoot":"","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"action_rpc.d.ts","sourceRoot":"","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAaxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKtD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,6BAA6B,CAAC;AAE3E,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACxC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;;;;;OAOG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,wBAAwB,KAAG,KAAK,CAAC,SAAS,CAgOtF,CAAC"}
|
|
@@ -17,28 +17,33 @@ import { literal, unknown } from '@fuzdev/fuz_schema/schema.ts';
|
|
|
17
17
|
import { UnreachableError } from '@fuzdev/fuz_util/error.ts';
|
|
18
18
|
import { define_route } from '../http/route_spec.js';
|
|
19
19
|
import { route_raw } from '../http/route_result.js';
|
|
20
|
-
import { get_client_ip } from '../http/client_ip.js';
|
|
21
|
-
import { get_request_context } from '../auth/request_context.js';
|
|
22
|
-
import { get_resolved_auth } from '../auth/resolved_auth.js';
|
|
23
|
-
import { has_test_context_preset } from '../hono_context.js';
|
|
24
20
|
import { compile_action_registry } from './compile_action_registry.js';
|
|
25
21
|
import { jsonrpc_error_messages, jsonrpc_error_code_to_http_status, JSONRPC_ERROR_CODES } from '../http/jsonrpc_errors.js';
|
|
26
22
|
import { classify_jsonrpc_message, create_jsonrpc_error_response } from '../http/jsonrpc_helpers.js';
|
|
27
23
|
import { perform_action, serialize_action_result } from './perform_action.js';
|
|
28
|
-
import { parse_json_text
|
|
24
|
+
import { parse_json_text } from '../http/json_text.js';
|
|
25
|
+
import { query_first } from '../http/request_target.js';
|
|
29
26
|
/**
|
|
30
|
-
* The `Cache-Control` every
|
|
31
|
-
* — a read is per caller and per moment, so nothing may store it.
|
|
27
|
+
* The `Cache-Control` every answer of the RPC endpoint's `GET` route carries
|
|
28
|
+
* — a read is per caller and per moment, so nothing may store it. Declared as
|
|
29
|
+
* the route's `response_headers`, so the error catch's answer carries it too.
|
|
32
30
|
*/
|
|
33
31
|
export const RPC_GET_CACHE_CONTROL = 'no-store';
|
|
32
|
+
/**
|
|
33
|
+
* The `data.reason` of the RPC `GET`'s `invalid_request` when an escape in
|
|
34
|
+
* its query string doesn't decode (`read_query_pairs`) — before any key is
|
|
35
|
+
* read, so the answer echoes no id. The Rust spine's `rpc_get_handler`
|
|
36
|
+
* answers the same literal.
|
|
37
|
+
*/
|
|
38
|
+
export const RPC_GET_UNDECODABLE_QUERY_REASON = 'undecodable query string';
|
|
39
|
+
/** The `Content-Type` `c.json` writes, which every envelope answers with. */
|
|
40
|
+
const JSON_CONTENT_TYPE = { 'Content-Type': 'application/json' };
|
|
34
41
|
/**
|
|
35
42
|
* A JSON-RPC envelope answered at `status`, with the bytes and `Content-Type`
|
|
36
43
|
* `c.json` writes, as a raw result: the endpoint answers envelopes, its
|
|
37
44
|
* refusals included, which no REST definition describes.
|
|
38
45
|
*/
|
|
39
|
-
const envelope_response = (
|
|
40
|
-
'Content-Type': 'application/json'
|
|
41
|
-
}));
|
|
46
|
+
const envelope_response = (envelope, status) => route_raw({ status, headers: JSON_CONTENT_TYPE, body: JSON.stringify(envelope) });
|
|
42
47
|
/**
|
|
43
48
|
* Single JSON-RPC 2.0 endpoint — the canonical RPC transport binding.
|
|
44
49
|
*
|
|
@@ -64,9 +69,10 @@ const envelope_response = (c, envelope, status) => route_raw(c.body(JSON.stringi
|
|
|
64
69
|
* 8. **Dispatch** — acquire DB handle (transaction for mutations, pool for reads),
|
|
65
70
|
* construct `ActionContext`, call handler, return JSON-RPC response.
|
|
66
71
|
*
|
|
67
|
-
* GET is restricted to `side_effects: false` actions, and every
|
|
68
|
-
* GET
|
|
69
|
-
* (`RPC_GET_CACHE_CONTROL`)
|
|
72
|
+
* GET is restricted to `side_effects: false` actions, and every answer of the
|
|
73
|
+
* GET route, its refusals and the error catch's included, carries
|
|
74
|
+
* `Cache-Control: no-store` (`RPC_GET_CACHE_CONTROL`, its `response_headers`)
|
|
75
|
+
* — a refusal by middleware ahead of the route does not.
|
|
70
76
|
* All errors use JSON-RPC format: `{jsonrpc, id, error: {code, message, data?}}`.
|
|
71
77
|
*
|
|
72
78
|
* The RouteSpecs use `auth: {type: 'none'}` because auth is checked per-action
|
|
@@ -102,13 +108,13 @@ export const create_rpc_endpoint = (options) => {
|
|
|
102
108
|
*
|
|
103
109
|
* @param restrict_to_reads - `true` for GET (rejects `side_effects: true` actions)
|
|
104
110
|
*/
|
|
105
|
-
const dispatch = async (
|
|
111
|
+
const dispatch = async (route, method_name, raw_params, id, restrict_to_reads) => {
|
|
106
112
|
const action = action_map.get(method_name);
|
|
107
113
|
if (!action) {
|
|
108
|
-
return envelope_response(
|
|
114
|
+
return envelope_response(create_jsonrpc_error_response(id, jsonrpc_error_messages.method_not_found(method_name)), jsonrpc_error_code_to_http_status(JSONRPC_ERROR_CODES.method_not_found));
|
|
109
115
|
}
|
|
110
116
|
if (restrict_to_reads && action.spec.side_effects) {
|
|
111
|
-
return envelope_response(
|
|
117
|
+
return envelope_response(create_jsonrpc_error_response(id, jsonrpc_error_messages.invalid_request({
|
|
112
118
|
reason: `method '${method_name}' has side effects and must use POST`
|
|
113
119
|
})), jsonrpc_error_code_to_http_status(JSONRPC_ERROR_CODES.invalid_request));
|
|
114
120
|
}
|
|
@@ -122,16 +128,14 @@ export const create_rpc_endpoint = (options) => {
|
|
|
122
128
|
// set `TEST_CONTEXT_PRESET_KEY` to `TEST_CONTEXT_PRESET`. Production middleware never
|
|
123
129
|
// sets the flag; the shim honors it and `perform_action` trusts the
|
|
124
130
|
// pre-baked context instead of running the live authorization phase.
|
|
125
|
-
const preset = has_test_context_preset
|
|
126
|
-
? { request_context: get_request_context(c) }
|
|
127
|
-
: undefined;
|
|
131
|
+
const preset = route.has_test_context_preset ? { request_context: route.auth } : undefined;
|
|
128
132
|
const result = await perform_action({
|
|
129
133
|
action,
|
|
130
134
|
raw_params,
|
|
131
135
|
request_id: id,
|
|
132
|
-
|
|
133
|
-
client_ip:
|
|
134
|
-
signal:
|
|
136
|
+
credential: route.credential,
|
|
137
|
+
client_ip: route.client_ip,
|
|
138
|
+
signal: route.signal,
|
|
135
139
|
notify,
|
|
136
140
|
preset
|
|
137
141
|
}, {
|
|
@@ -145,19 +149,16 @@ export const create_rpc_endpoint = (options) => {
|
|
|
145
149
|
const { body, status } = serialize_action_result(id, result, method_name, log);
|
|
146
150
|
// `status` is 200 or one of the JSON-RPC → HTTP status codes the
|
|
147
151
|
// dispatcher emits (the value space is verified by
|
|
148
|
-
// `jsonrpc_error_code_to_http_status`)
|
|
149
|
-
|
|
150
|
-
return route_raw(c.body(body, status, {
|
|
151
|
-
'Content-Type': 'application/json'
|
|
152
|
-
}));
|
|
152
|
+
// `jsonrpc_error_code_to_http_status`). The content type is `c.json`'s.
|
|
153
|
+
return route_raw({ status, headers: JSON_CONTENT_TYPE, body });
|
|
153
154
|
};
|
|
154
155
|
// POST handler — parse JSON-RPC envelope from body
|
|
155
|
-
const post_handler = async (
|
|
156
|
+
const post_handler = async (route) => {
|
|
156
157
|
// step 1: parse envelope
|
|
157
|
-
const read = await read_json_body(
|
|
158
|
+
const read = await route.read_json_body();
|
|
158
159
|
if (!read.ok) {
|
|
159
160
|
const error = create_jsonrpc_error_response(null, jsonrpc_error_messages.parse_error());
|
|
160
|
-
return envelope_response(
|
|
161
|
+
return envelope_response(error, 400);
|
|
161
162
|
}
|
|
162
163
|
const body = read.value;
|
|
163
164
|
// the classifier the WS path runs; HTTP issues no server-initiated
|
|
@@ -167,40 +168,42 @@ export const create_rpc_endpoint = (options) => {
|
|
|
167
168
|
switch (classified.kind) {
|
|
168
169
|
case 'request': {
|
|
169
170
|
const { method, params, id } = classified.request;
|
|
170
|
-
return dispatch(
|
|
171
|
+
return dispatch(route, method, params, id, false);
|
|
171
172
|
}
|
|
172
173
|
case 'invalid':
|
|
173
|
-
return envelope_response(
|
|
174
|
+
return envelope_response(create_jsonrpc_error_response(classified.id, classified.error), 400);
|
|
174
175
|
case 'notification':
|
|
175
176
|
case 'response':
|
|
176
|
-
return envelope_response(
|
|
177
|
+
return envelope_response(create_jsonrpc_error_response(null, jsonrpc_error_messages.invalid_request()), 400);
|
|
177
178
|
default:
|
|
178
179
|
throw new UnreachableError(classified);
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
182
|
// GET handler — extract method and params from query string
|
|
182
|
-
const get_handler = async (
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
183
|
+
const get_handler = async (route) => {
|
|
184
|
+
// step 1: parse from query string, every escape in it decoded strictly
|
|
185
|
+
// before any key is read, so no key reads a query another would refuse
|
|
186
|
+
const query = route.query_pairs;
|
|
187
|
+
if (!query.ok) {
|
|
188
|
+
const error = create_jsonrpc_error_response(null, jsonrpc_error_messages.invalid_request({ reason: RPC_GET_UNDECODABLE_QUERY_REASON }));
|
|
189
|
+
return envelope_response(error, 400);
|
|
190
|
+
}
|
|
191
|
+
const method_name = query_first(query.value, 'method');
|
|
189
192
|
if (!method_name) {
|
|
190
193
|
const error = create_jsonrpc_error_response(null, jsonrpc_error_messages.invalid_request({ reason: 'missing method query parameter' }));
|
|
191
|
-
return envelope_response(
|
|
194
|
+
return envelope_response(error, 400);
|
|
192
195
|
}
|
|
193
|
-
const id_raw =
|
|
196
|
+
const id_raw = query_first(query.value, 'id');
|
|
194
197
|
if (!id_raw) {
|
|
195
198
|
const error = create_jsonrpc_error_response(null, jsonrpc_error_messages.invalid_request({ reason: 'missing id query parameter' }));
|
|
196
|
-
return envelope_response(
|
|
199
|
+
return envelope_response(error, 400);
|
|
197
200
|
}
|
|
198
201
|
// parse integer ids so GET ?id=42 matches POST {id: 42} behavior
|
|
199
202
|
// JSON-RPC spec: "Numbers SHOULD NOT contain fractional parts"
|
|
200
203
|
const id_num = Number(id_raw);
|
|
201
204
|
const id = Number.isInteger(id_num) && String(id_num) === id_raw ? id_num : id_raw;
|
|
202
205
|
// parse params from query string (optional — null input schemas need no params)
|
|
203
|
-
const params_raw =
|
|
206
|
+
const params_raw = query_first(query.value, 'params');
|
|
204
207
|
let params;
|
|
205
208
|
if (params_raw !== undefined) {
|
|
206
209
|
try {
|
|
@@ -208,10 +211,10 @@ export const create_rpc_endpoint = (options) => {
|
|
|
208
211
|
}
|
|
209
212
|
catch {
|
|
210
213
|
const error = create_jsonrpc_error_response(id, jsonrpc_error_messages.invalid_params('params query parameter is not valid JSON'));
|
|
211
|
-
return envelope_response(
|
|
214
|
+
return envelope_response(error, 400);
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
|
-
return dispatch(
|
|
217
|
+
return dispatch(route, method_name, params, id, true);
|
|
215
218
|
};
|
|
216
219
|
return [
|
|
217
220
|
define_route({
|
|
@@ -236,6 +239,10 @@ export const create_rpc_endpoint = (options) => {
|
|
|
236
239
|
reads_credential: true,
|
|
237
240
|
// answers JSON-RPC envelopes, not REST bodies
|
|
238
241
|
jsonrpc: true,
|
|
242
|
+
// a read answers for one caller at one moment: no cache — the
|
|
243
|
+
// browser's, a proxy's — may keep it and answer a later call, or
|
|
244
|
+
// another caller, with it
|
|
245
|
+
response_headers: { 'Cache-Control': RPC_GET_CACHE_CONTROL },
|
|
239
246
|
handler: get_handler,
|
|
240
247
|
description: `JSON-RPC 2.0 endpoint (side-effect-free reads) — ${actions.length} method${actions.length === 1 ? '' : 's'}`,
|
|
241
248
|
input: literal(null), // params from query string, validated by dispatcher
|
|
@@ -22,7 +22,7 @@ import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
|
22
22
|
import type { Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
23
23
|
import type { ActionSpecUnion, RequestResponseActionSpec } from './action_spec.js';
|
|
24
24
|
import type { Uuid } from '../primitive_schemas.js';
|
|
25
|
-
import type { RequestActorContext, RequestContext } from '../auth/request_context.js';
|
|
25
|
+
import type { RequestActorContext, RequestContext, RequestContextForAuth } from '../auth/request_context.js';
|
|
26
26
|
import type { BuiltinCredentialType } from '../auth/credential_type_schema.js';
|
|
27
27
|
import type { Db } from '../db/db.js';
|
|
28
28
|
import type { JsonrpcRequestId } from '../http/jsonrpc.js';
|
|
@@ -196,21 +196,23 @@ export interface RpcAction {
|
|
|
196
196
|
handler: ActionHandler;
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
|
-
*
|
|
200
|
-
* `
|
|
199
|
+
* The handler for a narrowed `auth` (`RequestContextForAuth`):
|
|
200
|
+
* `ActorActionHandler` for an acting actor, `AuthActionHandler` for an
|
|
201
|
+
* account, `ActionHandler` otherwise.
|
|
202
|
+
*/
|
|
203
|
+
type HandlerForAuth<TAuth extends RequestContext | null, TInput, TOutput> = [TAuth] extends [
|
|
204
|
+
RequestActorContext
|
|
205
|
+
] ? ActorActionHandler<TInput, TOutput> : [TAuth] extends [RequestContext] ? AuthActionHandler<TInput, TOutput> : ActionHandler<TInput, TOutput>;
|
|
206
|
+
/**
|
|
207
|
+
* Conditional handler shape for `rpc_action` — the narrowest `ctx.auth` the
|
|
208
|
+
* dispatcher's runtime guarantee allows, read off the spec's `auth` by
|
|
209
|
+
* `RequestContextForAuth`, the narrowing REST route handlers share:
|
|
201
210
|
*
|
|
202
211
|
* - `auth.actor === 'required'` → `ActorActionHandler` (`ctx.auth: RequestActorContext`).
|
|
203
212
|
* - `auth.account === 'required' && auth.actor === 'none'` → `AuthActionHandler` (`ctx.auth: RequestContext`).
|
|
204
|
-
* - else (public, optional axes) → `ActionHandler` (`ctx.auth: RequestContext | null`).
|
|
205
|
-
*
|
|
206
|
-
* The bracketed form `[T] extends ['required']` defeats distributive
|
|
207
|
-
* conditionals so a degraded `AuthAxisState` union (when the spec was
|
|
208
|
-
* typed without preserving its literal) falls through to the loosest
|
|
209
|
-
* tier instead of collapsing to the narrowest.
|
|
213
|
+
* - else (public, optional axes, a degraded union) → `ActionHandler` (`ctx.auth: RequestContext | null`).
|
|
210
214
|
*/
|
|
211
|
-
export type HandlerForSpec<TSpec extends RequestResponseActionSpec> = [
|
|
212
|
-
TSpec['auth']['actor']
|
|
213
|
-
] extends ['required'] ? ActorActionHandler<Infer<TSpec['input']>, Infer<TSpec['output']>> : [TSpec['auth']['account']] extends ['required'] ? AuthActionHandler<Infer<TSpec['input']>, Infer<TSpec['output']>> : ActionHandler<Infer<TSpec['input']>, Infer<TSpec['output']>>;
|
|
215
|
+
export type HandlerForSpec<TSpec extends RequestResponseActionSpec> = HandlerForAuth<RequestContextForAuth<TSpec['auth']>, Infer<TSpec['input']>, Infer<TSpec['output']>>;
|
|
214
216
|
/**
|
|
215
217
|
* Pair a spec with a handler while preserving per-method input/output types
|
|
216
218
|
* and selecting the narrowest `ctx.auth` shape the spec literal admits.
|
|
@@ -258,4 +260,5 @@ export type HandlerForSpec<TSpec extends RequestResponseActionSpec> = [
|
|
|
258
260
|
* ```
|
|
259
261
|
*/
|
|
260
262
|
export declare const rpc_action: <TSpec extends RequestResponseActionSpec>(spec: TSpec, handler: HandlerForSpec<TSpec>) => RpcAction;
|
|
263
|
+
export {};
|
|
261
264
|
//# sourceMappingURL=action_types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_types.d.ts","sourceRoot":"","sources":["../../src/lib/actions/action_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,E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AAE,OAAO,GAAG,GAAG,IAAI,CAC7D,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,kBAAkB,KACnB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,aAAa,CAAC;CACvB;AAED;;;;GAIG;AACH,KAAK,cAAc,CAAC,KAAK,SAAS,cAAc,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS;IAC3F,mBAAmB;CACnB,GACE,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,CAAC,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GAC/B,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,yBAAyB,IAAI,cAAc,CACnF,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EACpC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EACrB,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,SAAS,yBAAyB,EACjE,MAAM,KAAK,EACX,SAAS,cAAc,CAAC,KAAK,CAAC,KAC5B,SAGD,CAAC"}
|
|
@@ -89,10 +89,10 @@ export interface PerformActionInput {
|
|
|
89
89
|
* post-authorization gates read, and its type and session hash what the
|
|
90
90
|
* handler sees on `ActionContext`.
|
|
91
91
|
*/
|
|
92
|
-
|
|
92
|
+
credential: ResolvedAuth | null;
|
|
93
93
|
/** Resolved client IP (`'unknown'` if upstream couldn't resolve). */
|
|
94
94
|
client_ip: string;
|
|
95
|
-
/** Per-request abort signal. HTTP: `
|
|
95
|
+
/** Per-request abort signal. HTTP: `RouteContext.signal`. WS: `AbortSignal.any([socket, request])`. */
|
|
96
96
|
signal: AbortSignal;
|
|
97
97
|
/** Send a request-scoped notification. HTTP: DEV-warn-and-drop. WS: socket-scoped. */
|
|
98
98
|
notify: (method: string, params: unknown) => void;
|
|
@@ -146,7 +146,7 @@ export interface PerformActionDeps {
|
|
|
146
146
|
/**
|
|
147
147
|
* Discriminated result of `perform_action`. Each transport binds this to
|
|
148
148
|
* its wire shape: HTTP RPC folds the error into a JSON-RPC envelope and
|
|
149
|
-
* returns it as a `route_raw` result
|
|
149
|
+
* returns it as a `route_raw` result; WS sends the response
|
|
150
150
|
* over the socket.
|
|
151
151
|
*/
|
|
152
152
|
export type PerformActionResult = {
|
|
@@ -165,7 +165,7 @@ export type PerformActionResult = {
|
|
|
165
165
|
* Phase order: 401 → authz → 403 → 429 → 400 → handler. On the test-preset path
|
|
166
166
|
* the dispatcher skips the live authorization phase and uses the supplied
|
|
167
167
|
* pre-baked context for post-authorization checks; the 401 still fires when
|
|
168
|
-
* the harness omits `
|
|
168
|
+
* the harness omits `credential`.
|
|
169
169
|
*/
|
|
170
170
|
export declare const perform_action: (input: PerformActionInput, deps: PerformActionDeps) => Promise<PerformActionResult>;
|
|
171
171
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perform_action.d.ts","sourceRoot":"","sources":["../../src/lib/actions/perform_action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAS,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACvF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,E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;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAC9B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAC1B,OAAO,kBAAkB,EACzB,MAAM,iBAAiB,KACrB,OAAO,CAAC,mBAAmB,CA2L7B,CAAC;AA8BF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GACnC,OAAO,SAAS,EAChB,QAAQ,aAAa,CAAC,WAAW,CAAC,EAClC,QAAQ,OAAO,KACb,kBAOF,CAAC;AA6DF;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,GAC1C,2BAA2B,aAAa,CAAC,MAAM,CAAC,KAC9C,kBAIA,CAAC;AAqEJ,0FAA0F;AAC1F,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,uBAAuB,GACnC,IAAI,gBAAgB,EACpB,QAAQ,mBAAmB,EAC3B,QAAQ,MAAM,EACd,KAAK,MAAM,KACT,sBAkBF,CAAC"}
|
|
@@ -85,14 +85,14 @@ import { token_scope_admits_method, token_scope_method_capability } from '../aut
|
|
|
85
85
|
* Phase order: 401 → authz → 403 → 429 → 400 → handler. On the test-preset path
|
|
86
86
|
* the dispatcher skips the live authorization phase and uses the supplied
|
|
87
87
|
* pre-baked context for post-authorization checks; the 401 still fires when
|
|
88
|
-
* the harness omits `
|
|
88
|
+
* the harness omits `credential`.
|
|
89
89
|
*/
|
|
90
90
|
export const perform_action = async (input, deps) => {
|
|
91
|
-
const { action, raw_params, request_id: id,
|
|
91
|
+
const { action, raw_params, request_id: id, credential, client_ip, signal, notify, connection_id, request_client, preset } = input;
|
|
92
92
|
const { db, pending_effects, post_commit_effects, log, action_ip_rate_limiter, action_account_rate_limiter } = deps;
|
|
93
93
|
const { spec, handler } = action;
|
|
94
94
|
const action_auth = spec.auth;
|
|
95
|
-
const account_id =
|
|
95
|
+
const account_id = credential?.account_id ?? null;
|
|
96
96
|
// step 1: pre-authorization auth — 401 short-circuit.
|
|
97
97
|
const pre = check_action_auth_pre_authorization(action_auth, account_id);
|
|
98
98
|
if (pre)
|
|
@@ -133,7 +133,7 @@ export const perform_action = async (input, deps) => {
|
|
|
133
133
|
request_context = result.request_context;
|
|
134
134
|
}
|
|
135
135
|
// step 3: post-authorization auth — credential gate, then scope, then role.
|
|
136
|
-
const post = check_action_auth_post_authorization(action_auth, request_context,
|
|
136
|
+
const post = check_action_auth_post_authorization(action_auth, request_context, credential, action.spec.method);
|
|
137
137
|
if (post)
|
|
138
138
|
return error_result(post);
|
|
139
139
|
// step 4: rate limit — throttle-requests semantics (record on every
|
|
@@ -208,8 +208,8 @@ export const perform_action = async (input, deps) => {
|
|
|
208
208
|
pending_effects,
|
|
209
209
|
post_commit_effects,
|
|
210
210
|
client_ip,
|
|
211
|
-
credential_type:
|
|
212
|
-
session_hash: resolved_auth_session_hash(
|
|
211
|
+
credential_type: credential?.credential_type ?? null,
|
|
212
|
+
session_hash: resolved_auth_session_hash(credential),
|
|
213
213
|
log,
|
|
214
214
|
notify,
|
|
215
215
|
signal
|
|
@@ -22,14 +22,18 @@
|
|
|
22
22
|
* observe far more than it was granted.
|
|
23
23
|
* 4. **Authorization phase** (`run_authorization_phase`) — the acting actor
|
|
24
24
|
* from the `?acting=<uuid>` query string (`parse_acting`; malformed reads
|
|
25
|
-
* as omitted
|
|
25
|
+
* as omitted, but a query holding an escape that doesn't decode, in any
|
|
26
|
+
* key, is a 400 `invalid_query_params` — `read_request_query_pairs`),
|
|
27
|
+
* against the authenticated account, building the
|
|
26
28
|
* `RequestContext` per-message dispatch reads (400s on actor selection).
|
|
27
29
|
* Multi-actor accounts must supply `?acting`; single-actor accounts work
|
|
28
30
|
* without it.
|
|
29
31
|
* 5. `require_role(required_roles)`, for a gated endpoint (403).
|
|
30
32
|
*
|
|
31
33
|
* Only `GET` is mounted (Hono serves `HEAD` through it), so any other method
|
|
32
|
-
* on the path is
|
|
34
|
+
* on the path is the assembled server's 405 (`server/unmatched_route.ts`),
|
|
35
|
+
* and a `GET` the guards admit that asks for no upgrade passes on to its
|
|
36
|
+
* 404. The guards run as middleware ahead of
|
|
33
37
|
* `upgradeWebSocket`, whose callback must return `WSEvents` and so cannot
|
|
34
38
|
* produce a refusal.
|
|
35
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register_action_ws.d.ts","sourceRoot":"","sources":["../../src/lib/actions/register_action_ws.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"register_action_ws.d.ts","sourceRoot":"","sources":["../../src/lib/actions/register_action_ws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAU,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAS5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAOvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wB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,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE;;;;;;;;OAQG;IACH,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;;;;OAMG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD;;;;;OAKG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACxE;AAED,sCAAsC;AACtC,MAAM,WAAW,sBAAsB;IACtC,wEAAwE;IACxE,QAAQ,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,uBAAuB,KAAG,sBAqLrE,CAAC"}
|
|
@@ -22,14 +22,18 @@
|
|
|
22
22
|
* observe far more than it was granted.
|
|
23
23
|
* 4. **Authorization phase** (`run_authorization_phase`) — the acting actor
|
|
24
24
|
* from the `?acting=<uuid>` query string (`parse_acting`; malformed reads
|
|
25
|
-
* as omitted
|
|
25
|
+
* as omitted, but a query holding an escape that doesn't decode, in any
|
|
26
|
+
* key, is a 400 `invalid_query_params` — `read_request_query_pairs`),
|
|
27
|
+
* against the authenticated account, building the
|
|
26
28
|
* `RequestContext` per-message dispatch reads (400s on actor selection).
|
|
27
29
|
* Multi-actor accounts must supply `?acting`; single-actor accounts work
|
|
28
30
|
* without it.
|
|
29
31
|
* 5. `require_role(required_roles)`, for a gated endpoint (403).
|
|
30
32
|
*
|
|
31
33
|
* Only `GET` is mounted (Hono serves `HEAD` through it), so any other method
|
|
32
|
-
* on the path is
|
|
34
|
+
* on the path is the assembled server's 405 (`server/unmatched_route.ts`),
|
|
35
|
+
* and a `GET` the guards admit that asks for no upgrade passes on to its
|
|
36
|
+
* 404. The guards run as middleware ahead of
|
|
33
37
|
* `upgradeWebSocket`, whose callback must return `WSEvents` and so cannot
|
|
34
38
|
* produce a refusal.
|
|
35
39
|
*
|
|
@@ -62,6 +66,8 @@ import { get_resolved_auth } from '../auth/resolved_auth.js';
|
|
|
62
66
|
import { verify_request_source } from '../http/origin.js';
|
|
63
67
|
import { parse_acting } from '../http/auth_shape.js';
|
|
64
68
|
import { get_client_ip } from '../http/client_ip.js';
|
|
69
|
+
import { ERROR_INVALID_QUERY_PARAMS } from '../http/error_schemas.js';
|
|
70
|
+
import { query_first, read_request_query_pairs } from '../http/request_target.js';
|
|
65
71
|
import { has_test_context_preset } from '../hono_context.js';
|
|
66
72
|
import {} from './action_types.js';
|
|
67
73
|
import { compile_action_registry } from './compile_action_registry.js';
|
|
@@ -200,7 +206,12 @@ export const register_action_ws = (options) => {
|
|
|
200
206
|
required_roles
|
|
201
207
|
};
|
|
202
208
|
app.get(path, verify_request_source(allowed_origins), ...pre_authorization, async (c, next) => {
|
|
203
|
-
|
|
209
|
+
// the query is decoded strictly, every key, before `acting` is read;
|
|
210
|
+
// a malformed but decodable `acting` still reads as omitted
|
|
211
|
+
const query = read_request_query_pairs(c);
|
|
212
|
+
if (!query.ok)
|
|
213
|
+
return c.json({ error: ERROR_INVALID_QUERY_PARAMS }, 400);
|
|
214
|
+
const refused = await run_authorization_phase(c, { db }, upgrade_auth, parse_acting(query_first(query.value, 'acting')));
|
|
204
215
|
if (refused)
|
|
205
216
|
return refused;
|
|
206
217
|
return next();
|