@fuzdev/fuz_app 0.51.0 → 0.53.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 +43 -10
- package/dist/actions/action_bridge.d.ts +3 -1
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +3 -1
- package/dist/actions/action_codegen.d.ts +28 -43
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +31 -50
- package/dist/actions/action_event.d.ts +44 -1
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +44 -1
- package/dist/actions/action_event_helpers.d.ts +26 -0
- package/dist/actions/action_event_helpers.d.ts.map +1 -1
- package/dist/actions/action_event_helpers.js +26 -1
- package/dist/actions/action_peer.d.ts +17 -0
- package/dist/actions/action_peer.d.ts.map +1 -1
- package/dist/actions/action_peer.js +8 -9
- package/dist/actions/action_registry.d.ts +1 -5
- package/dist/actions/action_registry.d.ts.map +1 -1
- package/dist/actions/action_registry.js +5 -11
- package/dist/actions/action_rpc.d.ts +20 -0
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +45 -20
- package/dist/actions/action_spec.d.ts +75 -6
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +36 -6
- package/dist/actions/frontend_rpc_client.d.ts +1 -9
- package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
- package/dist/actions/frontend_rpc_client.js +1 -9
- package/dist/actions/register_action_ws.d.ts +19 -0
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +44 -1
- package/dist/actions/register_ws_endpoint.d.ts +3 -0
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +3 -0
- package/dist/actions/request_tracker.svelte.d.ts +24 -16
- package/dist/actions/request_tracker.svelte.d.ts.map +1 -1
- package/dist/actions/request_tracker.svelte.js +24 -16
- package/dist/actions/rpc_client.d.ts +0 -1
- package/dist/actions/rpc_client.d.ts.map +1 -1
- package/dist/actions/rpc_client.js +3 -17
- package/dist/actions/socket.svelte.d.ts +35 -16
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +33 -14
- package/dist/actions/transports.d.ts +15 -5
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +15 -15
- package/dist/actions/transports_http.d.ts +7 -0
- package/dist/actions/transports_http.d.ts.map +1 -1
- package/dist/actions/transports_http.js +7 -0
- package/dist/actions/transports_ws.d.ts +13 -0
- package/dist/actions/transports_ws.d.ts.map +1 -1
- package/dist/actions/transports_ws.js +13 -0
- package/dist/actions/transports_ws_auth_guard.d.ts +6 -4
- package/dist/actions/transports_ws_auth_guard.d.ts.map +1 -1
- package/dist/actions/transports_ws_auth_guard.js +6 -4
- package/dist/actions/transports_ws_backend.d.ts +14 -1
- package/dist/actions/transports_ws_backend.d.ts.map +1 -1
- package/dist/actions/transports_ws_backend.js +14 -10
- package/dist/auth/CLAUDE.md +64 -18
- package/dist/auth/account_queries.d.ts +7 -0
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +7 -0
- package/dist/auth/admin_action_specs.d.ts +5 -0
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +5 -0
- package/dist/auth/admin_actions.d.ts +1 -0
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +1 -0
- package/dist/auth/api_token_queries.d.ts +6 -0
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +6 -0
- package/dist/auth/app_settings_queries.d.ts +4 -0
- package/dist/auth/app_settings_queries.d.ts.map +1 -1
- package/dist/auth/app_settings_queries.js +4 -0
- package/dist/auth/audit_log_queries.d.ts +5 -0
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +5 -0
- package/dist/auth/audit_log_routes.d.ts +2 -2
- package/dist/auth/audit_log_routes.js +2 -2
- package/dist/auth/audit_log_schema.d.ts +2 -0
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +134 -55
- package/dist/auth/bearer_auth.d.ts +2 -0
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +2 -0
- package/dist/auth/bootstrap_account.d.ts +3 -0
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +3 -0
- package/dist/auth/cleanup.d.ts +6 -0
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +6 -0
- package/dist/auth/daemon_token_middleware.d.ts +4 -0
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +4 -0
- package/dist/auth/invite_queries.d.ts +3 -0
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +3 -0
- package/dist/auth/permit_offer_action_specs.d.ts +6 -0
- package/dist/auth/permit_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/permit_offer_action_specs.js +11 -0
- package/dist/auth/permit_offer_queries.d.ts +18 -0
- package/dist/auth/permit_offer_queries.d.ts.map +1 -1
- package/dist/auth/permit_offer_queries.js +18 -0
- package/dist/auth/permit_queries.d.ts +7 -0
- package/dist/auth/permit_queries.d.ts.map +1 -1
- package/dist/auth/permit_queries.js +7 -0
- package/dist/auth/request_context.d.ts +1 -0
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +1 -0
- package/dist/auth/role_schema.d.ts +2 -0
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +2 -0
- package/dist/auth/self_service_role_actions.d.ts +1 -0
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +1 -0
- package/dist/auth/session_lifecycle.d.ts +2 -0
- package/dist/auth/session_lifecycle.d.ts.map +1 -1
- package/dist/auth/session_lifecycle.js +2 -0
- package/dist/auth/session_middleware.d.ts +1 -0
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +1 -0
- package/dist/auth/session_queries.d.ts +9 -0
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +9 -0
- package/dist/cli/config.d.ts +1 -2
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +1 -2
- package/dist/cli/daemon.d.ts +6 -1
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/daemon.js +6 -1
- package/dist/db/assert_row.d.ts +2 -1
- package/dist/db/assert_row.d.ts.map +1 -1
- package/dist/db/assert_row.js +2 -1
- package/dist/db/create_db.d.ts +3 -1
- package/dist/db/create_db.d.ts.map +1 -1
- package/dist/db/create_db.js +3 -1
- package/dist/db/db.d.ts +15 -4
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +14 -3
- package/dist/db/db_pg.d.ts +4 -3
- package/dist/db/db_pg.d.ts.map +1 -1
- package/dist/db/db_pg.js +7 -5
- package/dist/db/db_pglite.d.ts +4 -4
- package/dist/db/db_pglite.js +4 -4
- package/dist/db/migrate.d.ts +7 -4
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +5 -2
- package/dist/db/sql_identifier.d.ts +2 -1
- package/dist/db/sql_identifier.d.ts.map +1 -1
- package/dist/db/sql_identifier.js +2 -1
- package/dist/db/status.d.ts +4 -1
- package/dist/db/status.d.ts.map +1 -1
- package/dist/db/status.js +5 -2
- package/dist/dev/setup.d.ts +15 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +15 -2
- package/dist/env/dotenv.d.ts +2 -1
- package/dist/env/dotenv.d.ts.map +1 -1
- package/dist/env/dotenv.js +2 -1
- package/dist/env/load.d.ts +1 -3
- package/dist/env/load.d.ts.map +1 -1
- package/dist/env/load.js +1 -3
- package/dist/env/resolve.d.ts +1 -1
- package/dist/env/resolve.js +1 -1
- package/dist/env/update_env_variable.d.ts +2 -0
- package/dist/env/update_env_variable.d.ts.map +1 -1
- package/dist/env/update_env_variable.js +2 -0
- package/dist/hono_context.d.ts +2 -5
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +2 -5
- package/dist/http/common_routes.d.ts +0 -8
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +0 -8
- package/dist/http/db_routes.d.ts +0 -3
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +0 -3
- package/dist/http/error_schemas.d.ts +12 -11
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +11 -7
- package/dist/http/jsonrpc_errors.d.ts +0 -6
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +0 -6
- package/dist/http/origin.d.ts +6 -13
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +7 -14
- package/dist/http/pending_effects.d.ts +4 -0
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +4 -0
- package/dist/http/proxy.d.ts +3 -6
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +3 -6
- package/dist/http/route_spec.d.ts +14 -35
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +17 -22
- package/dist/http/schema_helpers.d.ts +0 -4
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +0 -4
- package/dist/http/surface.d.ts +2 -12
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +1 -12
- package/dist/rate_limiter.d.ts +30 -1
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +40 -1
- package/dist/realtime/sse.d.ts +7 -2
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +3 -2
- package/dist/realtime/sse_auth_guard.d.ts +21 -21
- package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
- package/dist/realtime/sse_auth_guard.js +24 -24
- package/dist/realtime/subscriber_registry.d.ts +4 -5
- package/dist/realtime/subscriber_registry.d.ts.map +1 -1
- package/dist/realtime/subscriber_registry.js +4 -5
- package/dist/runtime/fs.d.ts +5 -3
- package/dist/runtime/fs.d.ts.map +1 -1
- package/dist/runtime/fs.js +5 -3
- package/dist/runtime/mock.d.ts +6 -3
- package/dist/runtime/mock.d.ts.map +1 -1
- package/dist/runtime/mock.js +6 -3
- package/dist/server/app_backend.d.ts +1 -0
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +1 -0
- package/dist/server/app_server.d.ts +31 -5
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +23 -7
- package/dist/server/startup.d.ts +0 -2
- package/dist/server/startup.d.ts.map +1 -1
- package/dist/server/startup.js +0 -2
- package/dist/server/static.d.ts +0 -1
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +0 -1
- package/dist/server/validate_nginx.d.ts +3 -3
- package/dist/server/validate_nginx.d.ts.map +1 -1
- package/dist/server/validate_nginx.js +0 -3
- package/dist/testing/CLAUDE.md +1 -1
- package/dist/testing/admin_integration.d.ts +5 -1
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +8 -6
- package/dist/testing/adversarial_404.d.ts +0 -2
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +0 -2
- package/dist/testing/adversarial_headers.d.ts +5 -4
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +5 -4
- package/dist/testing/adversarial_input.d.ts +4 -2
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +4 -2
- package/dist/testing/app_server.d.ts +25 -0
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +11 -2
- package/dist/testing/assertions.d.ts +23 -11
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +23 -11
- package/dist/testing/attack_surface.d.ts +0 -4
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +0 -4
- package/dist/testing/audit_completeness.d.ts +4 -1
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +4 -1
- package/dist/testing/auth_apps.d.ts +5 -10
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +5 -10
- package/dist/testing/data_exposure.d.ts +0 -11
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +0 -11
- package/dist/testing/db.d.ts +9 -7
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +9 -7
- package/dist/testing/error_coverage.d.ts +9 -14
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +9 -14
- package/dist/testing/integration.d.ts +4 -1
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +4 -1
- package/dist/testing/integration_helpers.d.ts +5 -34
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +5 -41
- package/dist/testing/middleware.d.ts +5 -10
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +5 -10
- package/dist/testing/mock_fs.d.ts +0 -2
- package/dist/testing/mock_fs.d.ts.map +1 -1
- package/dist/testing/mock_fs.js +0 -2
- package/dist/testing/rate_limiting.d.ts +3 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -1
- package/dist/testing/round_trip.d.ts +0 -2
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +0 -2
- package/dist/testing/rpc_attack_surface.d.ts +0 -2
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +0 -2
- package/dist/testing/rpc_helpers.d.ts +21 -14
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +21 -14
- package/dist/testing/rpc_round_trip.d.ts +0 -2
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +0 -2
- package/dist/testing/schema_generators.d.ts +5 -3
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +22 -3
- package/dist/testing/sse_round_trip.d.ts +3 -1
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +3 -1
- package/dist/testing/standard.d.ts +0 -2
- package/dist/testing/standard.d.ts.map +1 -1
- package/dist/testing/standard.js +0 -2
- package/dist/testing/stubs.d.ts +8 -3
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +10 -3
- package/dist/testing/surface_invariants.d.ts +14 -3
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +14 -3
- package/dist/testing/ws_round_trip.d.ts +13 -1
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/ui/AccountSessions.svelte +9 -0
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAccounts.svelte +10 -0
- package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAuditLog.svelte +10 -0
- package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
- package/dist/ui/AdminInvites.svelte +9 -0
- package/dist/ui/AdminInvites.svelte.d.ts.map +1 -1
- package/dist/ui/AdminOverview.svelte +10 -0
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/AdminPermitHistory.svelte +9 -0
- package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSessions.svelte +10 -0
- package/dist/ui/AdminSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSettings.svelte +9 -0
- package/dist/ui/AdminSettings.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSurface.svelte +9 -0
- package/dist/ui/AdminSurface.svelte.d.ts.map +1 -1
- package/dist/ui/AppShell.svelte +24 -0
- package/dist/ui/AppShell.svelte.d.ts +23 -0
- package/dist/ui/AppShell.svelte.d.ts.map +1 -1
- package/dist/ui/BootstrapForm.svelte +17 -0
- package/dist/ui/BootstrapForm.svelte.d.ts +4 -0
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/CLAUDE.md +1 -1
- package/dist/ui/ColumnLayout.svelte +11 -0
- package/dist/ui/ColumnLayout.svelte.d.ts +10 -0
- package/dist/ui/ColumnLayout.svelte.d.ts.map +1 -1
- package/dist/ui/Datatable.svelte +18 -0
- package/dist/ui/Datatable.svelte.d.ts +17 -0
- package/dist/ui/Datatable.svelte.d.ts.map +1 -1
- package/dist/ui/LoginForm.svelte +18 -0
- package/dist/ui/LoginForm.svelte.d.ts +9 -0
- package/dist/ui/LoginForm.svelte.d.ts.map +1 -1
- package/dist/ui/LogoutButton.svelte +9 -0
- package/dist/ui/LogoutButton.svelte.d.ts +8 -0
- package/dist/ui/LogoutButton.svelte.d.ts.map +1 -1
- package/dist/ui/MenuLink.svelte +10 -0
- package/dist/ui/MenuLink.svelte.d.ts +9 -0
- package/dist/ui/MenuLink.svelte.d.ts.map +1 -1
- package/dist/ui/OpenSignupToggle.svelte +9 -0
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
- package/dist/ui/SignupForm.svelte +16 -0
- package/dist/ui/SignupForm.svelte.d.ts +4 -0
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- package/dist/ui/SurfaceExplorer.svelte +9 -0
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.d.ts +6 -1
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +7 -2
- package/dist/ui/auth_state.svelte.d.ts +16 -4
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +16 -4
- package/dist/ui/form_state.svelte.d.ts +9 -0
- package/dist/ui/form_state.svelte.d.ts.map +1 -1
- package/dist/ui/form_state.svelte.js +9 -0
- package/dist/ui/loadable.svelte.d.ts +6 -1
- package/dist/ui/loadable.svelte.d.ts.map +1 -1
- package/dist/ui/loadable.svelte.js +6 -1
- package/dist/ui/permit_offers_state.svelte.d.ts +2 -0
- package/dist/ui/permit_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/permit_offers_state.svelte.js +2 -0
- package/dist/ui/popover.svelte.d.ts +17 -4
- package/dist/ui/popover.svelte.d.ts.map +1 -1
- package/dist/ui/popover.svelte.js +17 -4
- package/dist/ui/position_helpers.d.ts +1 -3
- package/dist/ui/position_helpers.d.ts.map +1 -1
- package/dist/ui/position_helpers.js +1 -3
- package/dist/ui/sidebar_state.svelte.d.ts +21 -9
- package/dist/ui/sidebar_state.svelte.d.ts.map +1 -1
- package/dist/ui/sidebar_state.svelte.js +16 -2
- package/dist/ui/table_state.svelte.d.ts +14 -0
- package/dist/ui/table_state.svelte.d.ts.map +1 -1
- package/dist/ui/table_state.svelte.js +14 -0
- package/dist/ui/ui_fetch.d.ts +1 -7
- package/dist/ui/ui_fetch.d.ts.map +1 -1
- package/dist/ui/ui_fetch.js +1 -7
- package/dist/ui/ui_format.d.ts +2 -14
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +2 -14
- package/package.json +2 -2
|
@@ -46,15 +46,11 @@ export type AuthGuardResolver = (auth: RouteAuth) => Array<MiddlewareHandler>;
|
|
|
46
46
|
export type RouteMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
47
47
|
/**
|
|
48
48
|
* Per-request deps provided by the framework to route handlers.
|
|
49
|
-
*
|
|
50
|
-
* `db` is transaction-scoped for mutation routes and pool-level for reads.
|
|
51
|
-
* `background_db` is always pool-level — use it for fire-and-forget effects
|
|
52
|
-
* that must outlive the transaction.
|
|
53
49
|
*/
|
|
54
50
|
export interface RouteContext {
|
|
55
51
|
/** Transaction-scoped for mutations, pool-level for reads. */
|
|
56
52
|
db: Db;
|
|
57
|
-
/** Always pool-level — for fire-and-forget effects that outlive the transaction. */
|
|
53
|
+
/** Always pool-level — for fire-and-forget effects that must outlive the transaction. */
|
|
58
54
|
background_db: Db;
|
|
59
55
|
/** Fire-and-forget side effects — push here for post-response flushing. */
|
|
60
56
|
pending_effects: Array<Promise<void>>;
|
|
@@ -76,20 +72,14 @@ export type RouteHandler = (c: Context, route: RouteContext) => Response | Promi
|
|
|
76
72
|
export interface RouteSpec {
|
|
77
73
|
method: RouteMethod;
|
|
78
74
|
path: string;
|
|
79
|
-
/**
|
|
80
|
-
* Auth requirement for this route.
|
|
81
|
-
*
|
|
82
|
-
* `{type: 'none'}` means the route is open to all clients including non-browser
|
|
83
|
-
* callers (CLI, scripts) — no auth guards are applied.
|
|
84
|
-
*/
|
|
85
75
|
auth: RouteAuth;
|
|
86
76
|
handler: RouteHandler;
|
|
87
77
|
description: string;
|
|
88
78
|
/**
|
|
89
79
|
* URL path parameter schema. Use `z.strictObject()` with string fields matching `:param` segments.
|
|
90
80
|
*
|
|
91
|
-
*
|
|
92
|
-
* `input
|
|
81
|
+
* REST-only — actions dispatch through a single JSON-RPC endpoint and encode
|
|
82
|
+
* everything in `input`, so `params` doesn't appear on `ActionSpec`.
|
|
93
83
|
*/
|
|
94
84
|
params?: z.ZodObject;
|
|
95
85
|
/** URL query parameter schema. Use `z.strictObject()` with string fields. */
|
|
@@ -131,38 +121,30 @@ export interface RouteSpec {
|
|
|
131
121
|
/**
|
|
132
122
|
* Get validated input from the Hono context.
|
|
133
123
|
*
|
|
134
|
-
* Call
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* @returns the validated request body
|
|
124
|
+
* Call after the input validation middleware has run. The type parameter
|
|
125
|
+
* should match the route's `input` schema.
|
|
138
126
|
*/
|
|
139
127
|
export declare const get_route_input: <T>(c: Context) => T;
|
|
140
128
|
/**
|
|
141
129
|
* Get validated URL path params from the Hono context.
|
|
142
130
|
*
|
|
143
|
-
* Call
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* TODO @action-system-review Make typesafe — derive `T` from the `params` schema on the
|
|
147
|
-
* route spec so the type parameter isn't manually specified.
|
|
131
|
+
* Call after the params validation middleware has run. The type parameter
|
|
132
|
+
* should match the route's `params` schema.
|
|
148
133
|
*
|
|
149
|
-
*
|
|
134
|
+
* TODO derive `T` from the route spec so the type parameter isn't manually
|
|
135
|
+
* specified — same applies to `get_route_input` / `get_route_query`.
|
|
150
136
|
*/
|
|
151
137
|
export declare const get_route_params: <T>(c: Context) => T;
|
|
152
138
|
/**
|
|
153
139
|
* Get validated URL query params from the Hono context.
|
|
154
140
|
*
|
|
155
|
-
* Call
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* @returns the validated query parameters
|
|
141
|
+
* Call after the query validation middleware has run. The type parameter
|
|
142
|
+
* should match the route's `query` schema.
|
|
159
143
|
*/
|
|
160
144
|
export declare const get_route_query: <T>(c: Context) => T;
|
|
161
145
|
/**
|
|
162
146
|
* Apply named middleware specs to a Hono app.
|
|
163
147
|
*
|
|
164
|
-
* @param app - the Hono app
|
|
165
|
-
* @param specs - middleware specs to apply
|
|
166
148
|
* @mutates `app`
|
|
167
149
|
*/
|
|
168
150
|
export declare const apply_middleware_specs: (app: Hono, specs: Array<MiddlewareSpec>) => void;
|
|
@@ -179,20 +161,17 @@ export declare const apply_middleware_specs: (app: Hono, specs: Array<Middleware
|
|
|
179
161
|
* - `background_db`: always pool-level
|
|
180
162
|
* - `pending_effects`: fire-and-forget effect queue
|
|
181
163
|
*
|
|
182
|
-
* @param app - the Hono app
|
|
183
|
-
* @param specs - route specs to apply
|
|
184
164
|
* @param resolve_auth_guards - maps `RouteAuth` to middleware — use `fuz_auth_guard_resolver` from `auth/route_guards.ts`
|
|
185
|
-
* @param
|
|
186
|
-
* @param db - database instance for transaction wrapping and `RouteContext`
|
|
165
|
+
* @param db - used for transaction wrapping and `RouteContext`
|
|
187
166
|
* @mutates `app`
|
|
167
|
+
* @throws Error if two specs share the same `method` + `path` (each combination must be unique)
|
|
188
168
|
*/
|
|
189
169
|
export declare const apply_route_specs: (app: Hono, specs: Array<RouteSpec>, resolve_auth_guards: AuthGuardResolver, log: Logger, db: Db) => void;
|
|
190
170
|
/**
|
|
191
171
|
* Prepend a prefix to all route spec paths.
|
|
192
172
|
*
|
|
193
173
|
* @param prefix - the path prefix (e.g. `/api/account`)
|
|
194
|
-
* @
|
|
195
|
-
* @returns new array of specs with prefixed paths
|
|
174
|
+
* @returns a new array — the input specs are not mutated
|
|
196
175
|
*/
|
|
197
176
|
export declare const prefix_route_specs: (prefix: string, specs: Array<RouteSpec>) => Array<RouteSpec>;
|
|
198
177
|
//# sourceMappingURL=route_spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAW,IAAI,EAAE,iBAAiB,EAAC,MAAM,MAAM,CAAC;AACpE,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,aAAa,CAAC;AACpC,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAKjB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAClB;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GACd;IAAC,IAAI,EAAE,eAAe,CAAA;CAAC,GACvB;IAAC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F;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,GAAG,OAAO,KAAG,CAE/C,CAAC;AA8IF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,IAAI,EAAE,OAAO,KAAK,CAAC,cAAc,CAAC,KAAG,IAIhF,CAAC;AAgCF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,GAC7B,KAAK,IAAI,EACT,OAAO,KAAK,CAAC,SAAS,CAAC,EACvB,qBAAqB,iBAAiB,EACtC,KAAK,MAAM,EACX,IAAI,EAAE,KACJ,IAsCF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAG,KAAK,CAAC,SAAS,CAK3F,CAAC"}
|
package/dist/http/route_spec.js
CHANGED
|
@@ -19,10 +19,8 @@ import { is_null_schema, merge_error_schemas } from './schema_helpers.js';
|
|
|
19
19
|
/**
|
|
20
20
|
* Get validated input from the Hono context.
|
|
21
21
|
*
|
|
22
|
-
* Call
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @returns the validated request body
|
|
22
|
+
* Call after the input validation middleware has run. The type parameter
|
|
23
|
+
* should match the route's `input` schema.
|
|
26
24
|
*/
|
|
27
25
|
export const get_route_input = (c) => {
|
|
28
26
|
return c.get('validated_input');
|
|
@@ -30,13 +28,11 @@ export const get_route_input = (c) => {
|
|
|
30
28
|
/**
|
|
31
29
|
* Get validated URL path params from the Hono context.
|
|
32
30
|
*
|
|
33
|
-
* Call
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* TODO @action-system-review Make typesafe — derive `T` from the `params` schema on the
|
|
37
|
-
* route spec so the type parameter isn't manually specified.
|
|
31
|
+
* Call after the params validation middleware has run. The type parameter
|
|
32
|
+
* should match the route's `params` schema.
|
|
38
33
|
*
|
|
39
|
-
*
|
|
34
|
+
* TODO derive `T` from the route spec so the type parameter isn't manually
|
|
35
|
+
* specified — same applies to `get_route_input` / `get_route_query`.
|
|
40
36
|
*/
|
|
41
37
|
export const get_route_params = (c) => {
|
|
42
38
|
return c.get('validated_params');
|
|
@@ -44,10 +40,8 @@ export const get_route_params = (c) => {
|
|
|
44
40
|
/**
|
|
45
41
|
* Get validated URL query params from the Hono context.
|
|
46
42
|
*
|
|
47
|
-
* Call
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @returns the validated query parameters
|
|
43
|
+
* Call after the query validation middleware has run. The type parameter
|
|
44
|
+
* should match the route's `query` schema.
|
|
51
45
|
*/
|
|
52
46
|
export const get_route_query = (c) => {
|
|
53
47
|
return c.get('validated_query');
|
|
@@ -60,6 +54,8 @@ export const get_route_query = (c) => {
|
|
|
60
54
|
* and for null-input routes (no body expected). For other routes with input
|
|
61
55
|
* schemas, returns a middleware that parses and validates the JSON body,
|
|
62
56
|
* storing the result on the context as `validated_input`.
|
|
57
|
+
*
|
|
58
|
+
* @mutates `c.var.validated_input` - set to the parsed and validated body on success
|
|
63
59
|
*/
|
|
64
60
|
const create_input_validation = (input_schema, method) => {
|
|
65
61
|
if (method === 'GET')
|
|
@@ -92,6 +88,8 @@ const create_input_validation = (input_schema, method) => {
|
|
|
92
88
|
* Returns an empty array when no params schema is defined.
|
|
93
89
|
* For routes with params schemas, returns a middleware that validates
|
|
94
90
|
* `c.req.param()` against the schema, storing the result on the context as `validated_params`.
|
|
91
|
+
*
|
|
92
|
+
* @mutates `c.var.validated_params` - set to the parsed and validated path params on success
|
|
95
93
|
*/
|
|
96
94
|
const create_params_validation = (params_schema) => {
|
|
97
95
|
if (!params_schema)
|
|
@@ -113,6 +111,8 @@ const create_params_validation = (params_schema) => {
|
|
|
113
111
|
* Returns an empty array when no query schema is defined.
|
|
114
112
|
* For routes with query schemas, returns a middleware that validates
|
|
115
113
|
* `c.req.query()` against the schema, storing the result on the context as `validated_query`.
|
|
114
|
+
*
|
|
115
|
+
* @mutates `c.var.validated_query` - set to the parsed and validated query params on success
|
|
116
116
|
*/
|
|
117
117
|
const create_query_validation = (query_schema) => {
|
|
118
118
|
if (!query_schema)
|
|
@@ -182,8 +182,6 @@ const wrap_output_validation = (handler, output_schema, error_schemas, log) => {
|
|
|
182
182
|
/**
|
|
183
183
|
* Apply named middleware specs to a Hono app.
|
|
184
184
|
*
|
|
185
|
-
* @param app - the Hono app
|
|
186
|
-
* @param specs - middleware specs to apply
|
|
187
185
|
* @mutates `app`
|
|
188
186
|
*/
|
|
189
187
|
export const apply_middleware_specs = (app, specs) => {
|
|
@@ -232,12 +230,10 @@ const wrap_error_catch = (handler, log) => {
|
|
|
232
230
|
* - `background_db`: always pool-level
|
|
233
231
|
* - `pending_effects`: fire-and-forget effect queue
|
|
234
232
|
*
|
|
235
|
-
* @param app - the Hono app
|
|
236
|
-
* @param specs - route specs to apply
|
|
237
233
|
* @param resolve_auth_guards - maps `RouteAuth` to middleware — use `fuz_auth_guard_resolver` from `auth/route_guards.ts`
|
|
238
|
-
* @param
|
|
239
|
-
* @param db - database instance for transaction wrapping and `RouteContext`
|
|
234
|
+
* @param db - used for transaction wrapping and `RouteContext`
|
|
240
235
|
* @mutates `app`
|
|
236
|
+
* @throws Error if two specs share the same `method` + `path` (each combination must be unique)
|
|
241
237
|
*/
|
|
242
238
|
export const apply_route_specs = (app, specs, resolve_auth_guards, log, db) => {
|
|
243
239
|
const registered = new Set();
|
|
@@ -269,8 +265,7 @@ export const apply_route_specs = (app, specs, resolve_auth_guards, log, db) => {
|
|
|
269
265
|
* Prepend a prefix to all route spec paths.
|
|
270
266
|
*
|
|
271
267
|
* @param prefix - the path prefix (e.g. `/api/account`)
|
|
272
|
-
* @
|
|
273
|
-
* @returns new array of specs with prefixed paths
|
|
268
|
+
* @returns a new array — the input specs are not mutated
|
|
274
269
|
*/
|
|
275
270
|
export const prefix_route_specs = (prefix, specs) => {
|
|
276
271
|
return specs.map((spec) => ({
|
|
@@ -47,9 +47,6 @@ export declare const schema_to_surface: (schema: z.ZodType) => unknown;
|
|
|
47
47
|
* - `/api/*` matches `/api/anything`
|
|
48
48
|
* - `/api/tx/*` matches `/api/tx/runs` but not `/api/account/login`
|
|
49
49
|
* - Exact match: `/health` matches `/health`
|
|
50
|
-
*
|
|
51
|
-
* @param mw_path - the middleware path pattern
|
|
52
|
-
* @param route_path - the route path
|
|
53
50
|
*/
|
|
54
51
|
export declare const middleware_applies: (mw_path: string, route_path: string) => boolean;
|
|
55
52
|
/**
|
|
@@ -59,7 +56,6 @@ export declare const middleware_applies: (mw_path: string, route_path: string) =
|
|
|
59
56
|
* Later layers override earlier ones for the same status code.
|
|
60
57
|
*
|
|
61
58
|
* @param spec - the route spec (needs `auth`, `input`, `params`, `rate_limit`, `errors`)
|
|
62
|
-
* @param middleware_errors - optional middleware error schemas
|
|
63
59
|
* @returns merged error schemas, or `null` if empty
|
|
64
60
|
*/
|
|
65
61
|
export declare const merge_error_schemas: (spec: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/schema_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAuB,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAEnG;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,OAAsC,CAAC;AAE1F;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,OAAsC,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,OACe,CAAC;AAE5E;;;;GAIG;AACH,eAAO,MAAM,i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,9 +76,6 @@ const strip_json_schema_noise = (value) => {
|
|
|
76
76
|
* - `/api/*` matches `/api/anything`
|
|
77
77
|
* - `/api/tx/*` matches `/api/tx/runs` but not `/api/account/login`
|
|
78
78
|
* - Exact match: `/health` matches `/health`
|
|
79
|
-
*
|
|
80
|
-
* @param mw_path - the middleware path pattern
|
|
81
|
-
* @param route_path - the route path
|
|
82
79
|
*/
|
|
83
80
|
export const middleware_applies = (mw_path, route_path) => {
|
|
84
81
|
if (mw_path === '*')
|
|
@@ -98,7 +95,6 @@ export const middleware_applies = (mw_path, route_path) => {
|
|
|
98
95
|
* Later layers override earlier ones for the same status code.
|
|
99
96
|
*
|
|
100
97
|
* @param spec - the route spec (needs `auth`, `input`, `params`, `rate_limit`, `errors`)
|
|
101
|
-
* @param middleware_errors - optional middleware error schemas
|
|
102
98
|
* @returns merged error schemas, or `null` if empty
|
|
103
99
|
*/
|
|
104
100
|
export const merge_error_schemas = (spec, middleware_errors) => {
|
package/dist/http/surface.d.ts
CHANGED
|
@@ -70,6 +70,8 @@ export interface AppSurfaceRpcMethod {
|
|
|
70
70
|
output_schema: unknown;
|
|
71
71
|
side_effects: boolean;
|
|
72
72
|
description: string;
|
|
73
|
+
/** Rate limit key declared on the action spec. `null` when not rate-limited. */
|
|
74
|
+
rate_limit_key: RateLimitKey | null;
|
|
73
75
|
}
|
|
74
76
|
/** An RPC endpoint in the generated attack surface (JSON-serializable). */
|
|
75
77
|
export interface AppSurfaceRpcEndpoint {
|
|
@@ -120,8 +122,6 @@ export interface GenerateAppSurfaceOptions {
|
|
|
120
122
|
/**
|
|
121
123
|
* Collect error schemas from all middleware that applies to a route path.
|
|
122
124
|
*
|
|
123
|
-
* @param middleware - the middleware specs
|
|
124
|
-
* @param route_path - the route path to match against
|
|
125
125
|
* @returns merged middleware error schemas, or `null` if none
|
|
126
126
|
*/
|
|
127
127
|
export declare const collect_middleware_errors: (middleware: Array<MiddlewareSpec>, route_path: string) => RouteErrorSchemas | null;
|
|
@@ -129,29 +129,19 @@ export declare const collect_middleware_errors: (middleware: Array<MiddlewareSpe
|
|
|
129
129
|
* Convert env schema to surface entries using `.meta()` metadata.
|
|
130
130
|
*
|
|
131
131
|
* @param schema - Zod object schema with `.meta()` on fields
|
|
132
|
-
* @returns array of env surface entries
|
|
133
132
|
*/
|
|
134
133
|
export declare const env_schema_to_surface: (schema: z.ZodObject) => Array<AppSurfaceEnv>;
|
|
135
134
|
/**
|
|
136
135
|
* Convert SSE event specs to surface entries.
|
|
137
|
-
*
|
|
138
|
-
* @param event_specs - event specs to convert
|
|
139
|
-
* @returns array of event surface entries
|
|
140
136
|
*/
|
|
141
137
|
export declare const events_to_surface: (event_specs: Array<EventSpec>) => Array<AppSurfaceEvent>;
|
|
142
138
|
/**
|
|
143
139
|
* Generate a JSON-serializable attack surface from middleware, route specs,
|
|
144
140
|
* and optional env/event metadata.
|
|
145
|
-
*
|
|
146
|
-
* @param options - the surface generation options
|
|
147
|
-
* @returns the attack surface
|
|
148
141
|
*/
|
|
149
142
|
export declare const generate_app_surface: (options: GenerateAppSurfaceOptions) => AppSurface;
|
|
150
143
|
/**
|
|
151
144
|
* Create an `AppSurfaceSpec` — the surface bundled with its source specs.
|
|
152
|
-
*
|
|
153
|
-
* @param options - the surface generation options
|
|
154
|
-
* @returns the surface spec with surface and raw specs
|
|
155
145
|
*/
|
|
156
146
|
export declare const create_app_surface_spec: (options: GenerateAppSurfaceOptions) => AppSurfaceSpec;
|
|
157
147
|
//# sourceMappingURL=surface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;A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,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;CACvC;AAID;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GACrC,YAAY,KAAK,CAAC,cAAc,CAAC,EACjC,YAAY,MAAM,KAChB,iBAAiB,GAAG,IAQtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,SAAS,KAAG,KAAK,CAAC,aAAa,CAe9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,KAAK,CAAC,SAAS,CAAC,KAAG,KAAK,CAAC,eAAe,CAOtF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,yBAAyB,KAAG,UAyFzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,yBAAyB,KAAG,cAQ5E,CAAC"}
|
package/dist/http/surface.js
CHANGED
|
@@ -13,8 +13,6 @@ import { schema_to_surface, middleware_applies, merge_error_schemas, is_null_sch
|
|
|
13
13
|
/**
|
|
14
14
|
* Collect error schemas from all middleware that applies to a route path.
|
|
15
15
|
*
|
|
16
|
-
* @param middleware - the middleware specs
|
|
17
|
-
* @param route_path - the route path to match against
|
|
18
16
|
* @returns merged middleware error schemas, or `null` if none
|
|
19
17
|
*/
|
|
20
18
|
export const collect_middleware_errors = (middleware, route_path) => {
|
|
@@ -30,7 +28,6 @@ export const collect_middleware_errors = (middleware, route_path) => {
|
|
|
30
28
|
* Convert env schema to surface entries using `.meta()` metadata.
|
|
31
29
|
*
|
|
32
30
|
* @param schema - Zod object schema with `.meta()` on fields
|
|
33
|
-
* @returns array of env surface entries
|
|
34
31
|
*/
|
|
35
32
|
export const env_schema_to_surface = (schema) => {
|
|
36
33
|
const entries = [];
|
|
@@ -50,9 +47,6 @@ export const env_schema_to_surface = (schema) => {
|
|
|
50
47
|
};
|
|
51
48
|
/**
|
|
52
49
|
* Convert SSE event specs to surface entries.
|
|
53
|
-
*
|
|
54
|
-
* @param event_specs - event specs to convert
|
|
55
|
-
* @returns array of event surface entries
|
|
56
50
|
*/
|
|
57
51
|
export const events_to_surface = (event_specs) => {
|
|
58
52
|
return event_specs.map((spec) => ({
|
|
@@ -65,9 +59,6 @@ export const events_to_surface = (event_specs) => {
|
|
|
65
59
|
/**
|
|
66
60
|
* Generate a JSON-serializable attack surface from middleware, route specs,
|
|
67
61
|
* and optional env/event metadata.
|
|
68
|
-
*
|
|
69
|
-
* @param options - the surface generation options
|
|
70
|
-
* @returns the attack surface
|
|
71
62
|
*/
|
|
72
63
|
export const generate_app_surface = (options) => {
|
|
73
64
|
const { route_specs, middleware_specs, env_schema, event_specs, rpc_endpoints } = options;
|
|
@@ -147,6 +138,7 @@ export const generate_app_surface = (options) => {
|
|
|
147
138
|
output_schema: schema_to_surface(a.spec.output),
|
|
148
139
|
side_effects: a.spec.side_effects,
|
|
149
140
|
description: a.spec.description,
|
|
141
|
+
rate_limit_key: a.spec.rate_limit ?? null,
|
|
150
142
|
})),
|
|
151
143
|
}))
|
|
152
144
|
: [],
|
|
@@ -156,9 +148,6 @@ export const generate_app_surface = (options) => {
|
|
|
156
148
|
};
|
|
157
149
|
/**
|
|
158
150
|
* Create an `AppSurfaceSpec` — the surface bundled with its source specs.
|
|
159
|
-
*
|
|
160
|
-
* @param options - the surface generation options
|
|
161
|
-
* @returns the surface spec with surface and raw specs
|
|
162
151
|
*/
|
|
163
152
|
export const create_app_surface_spec = (options) => {
|
|
164
153
|
const surface = generate_app_surface(options);
|
package/dist/rate_limiter.d.ts
CHANGED
|
@@ -46,6 +46,22 @@ export interface RateLimiterOptions {
|
|
|
46
46
|
export declare const DEFAULT_LOGIN_IP_RATE_LIMIT: RateLimiterOptions;
|
|
47
47
|
/** Default options for per-account login rate limiting: 10 attempts per 30 minutes. */
|
|
48
48
|
export declare const DEFAULT_LOGIN_ACCOUNT_RATE_LIMIT: RateLimiterOptions;
|
|
49
|
+
/**
|
|
50
|
+
* Default options for per-IP action-dispatcher rate limiting: 600 attempts
|
|
51
|
+
* per 15 minutes. Shared by the HTTP RPC and WebSocket action dispatchers
|
|
52
|
+
* (one budget per action, not per transport). Permissive — catches runaway
|
|
53
|
+
* scripts and egregious oracle probes, but well above human or normal
|
|
54
|
+
* automation pace. Tighten downstream for stricter deployments.
|
|
55
|
+
*/
|
|
56
|
+
export declare const DEFAULT_ACTION_IP_RATE_LIMIT: RateLimiterOptions;
|
|
57
|
+
/**
|
|
58
|
+
* Default options for per-actor action-dispatcher rate limiting: 1200
|
|
59
|
+
* attempts per 15 minutes. Shared by the HTTP RPC and WebSocket action
|
|
60
|
+
* dispatchers. Permissive — sustained ~80/min is well above any human
|
|
61
|
+
* admin workflow; an oracle probing 10k addresses still finishes in
|
|
62
|
+
* ~2 hours, slow enough to surface in audit. Tighten downstream.
|
|
63
|
+
*/
|
|
64
|
+
export declare const DEFAULT_ACTION_ACCOUNT_RATE_LIMIT: RateLimiterOptions;
|
|
49
65
|
/**
|
|
50
66
|
* Result of a rate limit check or record operation.
|
|
51
67
|
*/
|
|
@@ -83,8 +99,13 @@ export declare class RateLimiter {
|
|
|
83
99
|
/**
|
|
84
100
|
* Check whether `key` is allowed without recording an attempt.
|
|
85
101
|
*
|
|
102
|
+
* Prunes timestamps that fell outside the window as a side effect (and
|
|
103
|
+
* removes the key entirely when none remain), so the backing map stays
|
|
104
|
+
* bounded even under read-only traffic.
|
|
105
|
+
*
|
|
86
106
|
* @param key - rate limit key (e.g. IP address)
|
|
87
107
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
108
|
+
* @mutates internal map - prunes expired timestamps for `key`
|
|
88
109
|
*/
|
|
89
110
|
check(key: string, now?: number): RateLimitResult;
|
|
90
111
|
/**
|
|
@@ -92,19 +113,27 @@ export declare class RateLimiter {
|
|
|
92
113
|
*
|
|
93
114
|
* @param key - rate limit key (e.g. IP address)
|
|
94
115
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
116
|
+
* @mutates internal map - appends `now` to the timestamp list for `key` (after pruning expired entries)
|
|
95
117
|
*/
|
|
96
118
|
record(key: string, now?: number): RateLimitResult;
|
|
97
119
|
/**
|
|
98
120
|
* Clear all attempts for `key` (e.g. after successful login).
|
|
121
|
+
*
|
|
122
|
+
* @mutates internal map - removes the entry for `key`
|
|
99
123
|
*/
|
|
100
124
|
reset(key: string): void;
|
|
101
125
|
/**
|
|
102
126
|
* Remove entries whose timestamps are all outside the window.
|
|
103
127
|
*
|
|
104
128
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
129
|
+
* @mutates internal map - prunes expired timestamps and deletes empty keys
|
|
105
130
|
*/
|
|
106
131
|
cleanup(now?: number): void;
|
|
107
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Stop the cleanup timer. Safe to call multiple times.
|
|
134
|
+
*
|
|
135
|
+
* @mutates timer - clears the cleanup `setInterval` and nulls the handle
|
|
136
|
+
*/
|
|
108
137
|
dispose(): void;
|
|
109
138
|
}
|
|
110
139
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/rate_limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAKlC;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,SAAU,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAA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EF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAW;;IACvB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAOzB,OAAO,EAAE,kBAAkB;IAcvC,8BAA8B;IAC9B,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,eAAe;IA2B7D;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,eAAe;IA0B9D;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB;;;;;OAKG;IACH,OAAO,CAAC,GAAG,GAAE,MAAmB,GAAG,IAAI;IAgBvC;;;;OAIG;IACH,OAAO,IAAI,IAAI;CAMf;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,OAAO,CAAC,kBAAkB,CAAC,KAAG,WAE3E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAI,GAAG,OAAO,EAAE,aAAa,MAAM,KAAG,QAI7E,CAAC"}
|
package/dist/rate_limiter.js
CHANGED
|
@@ -30,6 +30,32 @@ export const DEFAULT_LOGIN_ACCOUNT_RATE_LIMIT = {
|
|
|
30
30
|
cleanup_interval_ms: 5 * 60_000,
|
|
31
31
|
max_keys: DEFAULT_RATE_LIMITER_MAX_KEYS,
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Default options for per-IP action-dispatcher rate limiting: 600 attempts
|
|
35
|
+
* per 15 minutes. Shared by the HTTP RPC and WebSocket action dispatchers
|
|
36
|
+
* (one budget per action, not per transport). Permissive — catches runaway
|
|
37
|
+
* scripts and egregious oracle probes, but well above human or normal
|
|
38
|
+
* automation pace. Tighten downstream for stricter deployments.
|
|
39
|
+
*/
|
|
40
|
+
export const DEFAULT_ACTION_IP_RATE_LIMIT = {
|
|
41
|
+
max_attempts: 600,
|
|
42
|
+
window_ms: 15 * 60_000,
|
|
43
|
+
cleanup_interval_ms: 5 * 60_000,
|
|
44
|
+
max_keys: DEFAULT_RATE_LIMITER_MAX_KEYS,
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Default options for per-actor action-dispatcher rate limiting: 1200
|
|
48
|
+
* attempts per 15 minutes. Shared by the HTTP RPC and WebSocket action
|
|
49
|
+
* dispatchers. Permissive — sustained ~80/min is well above any human
|
|
50
|
+
* admin workflow; an oracle probing 10k addresses still finishes in
|
|
51
|
+
* ~2 hours, slow enough to surface in audit. Tighten downstream.
|
|
52
|
+
*/
|
|
53
|
+
export const DEFAULT_ACTION_ACCOUNT_RATE_LIMIT = {
|
|
54
|
+
max_attempts: 1200,
|
|
55
|
+
window_ms: 15 * 60_000,
|
|
56
|
+
cleanup_interval_ms: 5 * 60_000,
|
|
57
|
+
max_keys: DEFAULT_RATE_LIMITER_MAX_KEYS,
|
|
58
|
+
};
|
|
33
59
|
/**
|
|
34
60
|
* In-memory sliding window rate limiter.
|
|
35
61
|
*
|
|
@@ -71,8 +97,13 @@ export class RateLimiter {
|
|
|
71
97
|
/**
|
|
72
98
|
* Check whether `key` is allowed without recording an attempt.
|
|
73
99
|
*
|
|
100
|
+
* Prunes timestamps that fell outside the window as a side effect (and
|
|
101
|
+
* removes the key entirely when none remain), so the backing map stays
|
|
102
|
+
* bounded even under read-only traffic.
|
|
103
|
+
*
|
|
74
104
|
* @param key - rate limit key (e.g. IP address)
|
|
75
105
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
106
|
+
* @mutates internal map - prunes expired timestamps for `key`
|
|
76
107
|
*/
|
|
77
108
|
check(key, now = Date.now()) {
|
|
78
109
|
const { max_attempts, window_ms } = this.options;
|
|
@@ -102,6 +133,7 @@ export class RateLimiter {
|
|
|
102
133
|
*
|
|
103
134
|
* @param key - rate limit key (e.g. IP address)
|
|
104
135
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
136
|
+
* @mutates internal map - appends `now` to the timestamp list for `key` (after pruning expired entries)
|
|
105
137
|
*/
|
|
106
138
|
record(key, now = Date.now()) {
|
|
107
139
|
const { max_attempts, window_ms } = this.options;
|
|
@@ -128,6 +160,8 @@ export class RateLimiter {
|
|
|
128
160
|
}
|
|
129
161
|
/**
|
|
130
162
|
* Clear all attempts for `key` (e.g. after successful login).
|
|
163
|
+
*
|
|
164
|
+
* @mutates internal map - removes the entry for `key`
|
|
131
165
|
*/
|
|
132
166
|
reset(key) {
|
|
133
167
|
this.#attempts.delete(key);
|
|
@@ -136,6 +170,7 @@ export class RateLimiter {
|
|
|
136
170
|
* Remove entries whose timestamps are all outside the window.
|
|
137
171
|
*
|
|
138
172
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
173
|
+
* @mutates internal map - prunes expired timestamps and deletes empty keys
|
|
139
174
|
*/
|
|
140
175
|
cleanup(now = Date.now()) {
|
|
141
176
|
const cutoff = now - this.options.window_ms;
|
|
@@ -153,7 +188,11 @@ export class RateLimiter {
|
|
|
153
188
|
}
|
|
154
189
|
}
|
|
155
190
|
}
|
|
156
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Stop the cleanup timer. Safe to call multiple times.
|
|
193
|
+
*
|
|
194
|
+
* @mutates timer - clears the cleanup `setInterval` and nulls the handle
|
|
195
|
+
*/
|
|
157
196
|
dispose() {
|
|
158
197
|
if (this.#cleanup_timer !== null) {
|
|
159
198
|
clearInterval(this.#cleanup_timer);
|
package/dist/realtime/sse.d.ts
CHANGED
|
@@ -46,8 +46,8 @@ export interface SseNotification {
|
|
|
46
46
|
* Uses `hono_stream.write()` directly (not `writeSSE`) to avoid
|
|
47
47
|
* Hono's HTML callback resolution — keeps the same `data: JSON\n\n` format.
|
|
48
48
|
*
|
|
49
|
-
* @param
|
|
50
|
-
* @returns object with
|
|
49
|
+
* @param log - logger for serialization and `on_close` listener errors
|
|
50
|
+
* @returns object with the streaming `Response` and an `SseStream` controller
|
|
51
51
|
*/
|
|
52
52
|
export declare const create_sse_response: <T = unknown>(c: Context, log: Logger) => {
|
|
53
53
|
response: Response;
|
|
@@ -57,9 +57,13 @@ export declare const create_sse_response: <T = unknown>(c: Context, log: Logger)
|
|
|
57
57
|
export declare const SSE_CONNECTED_COMMENT = ": connected\n\n";
|
|
58
58
|
/** Spec for a push event — declares params schema, description, and channel. */
|
|
59
59
|
export interface EventSpec {
|
|
60
|
+
/** Event method name, used as the JSON-RPC notification `method`. */
|
|
60
61
|
method: string;
|
|
62
|
+
/** Zod schema for the notification `params` payload. */
|
|
61
63
|
params: z.ZodType;
|
|
64
|
+
/** Human-readable description for surface output and docs. */
|
|
62
65
|
description: string;
|
|
66
|
+
/** Channel this event broadcasts on. Omit for cross-channel events. */
|
|
63
67
|
channel?: string;
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
@@ -70,6 +74,7 @@ export interface EventSpec {
|
|
|
70
74
|
*
|
|
71
75
|
* @param broadcaster - duck-typed broadcaster (e.g. `SubscriberRegistry`)
|
|
72
76
|
* @param event_specs - event specs to validate against
|
|
77
|
+
* @param log - logger used to emit DEV warnings on unknown methods or param mismatches
|
|
73
78
|
* @returns validated broadcaster wrapper (passthrough in production)
|
|
74
79
|
*/
|
|
75
80
|
export declare const create_validated_broadcaster: <T extends SseNotification>(broadcaster: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAElC,OAAO,EAAC,CAAC,EAAC,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AAa,KAAK,CAAC,SAAS,CAAC,EAC7B,KAAK,MAAM,KACT;IAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAmBhD,CAAC"}
|
package/dist/realtime/sse.js
CHANGED
|
@@ -20,8 +20,8 @@ import { DEV } from 'esm-env';
|
|
|
20
20
|
* Uses `hono_stream.write()` directly (not `writeSSE`) to avoid
|
|
21
21
|
* Hono's HTML callback resolution — keeps the same `data: JSON\n\n` format.
|
|
22
22
|
*
|
|
23
|
-
* @param
|
|
24
|
-
* @returns object with
|
|
23
|
+
* @param log - logger for serialization and `on_close` listener errors
|
|
24
|
+
* @returns object with the streaming `Response` and an `SseStream` controller
|
|
25
25
|
*/
|
|
26
26
|
export const create_sse_response = (c, log) => {
|
|
27
27
|
const { promise, resolve } = Promise.withResolvers();
|
|
@@ -84,6 +84,7 @@ export const SSE_CONNECTED_COMMENT = `: connected\n\n`;
|
|
|
84
84
|
*
|
|
85
85
|
* @param broadcaster - duck-typed broadcaster (e.g. `SubscriberRegistry`)
|
|
86
86
|
* @param event_specs - event specs to validate against
|
|
87
|
+
* @param log - logger used to emit DEV warnings on unknown methods or param mismatches
|
|
87
88
|
* @returns validated broadcaster wrapper (passthrough in production)
|
|
88
89
|
*/
|
|
89
90
|
export const create_validated_broadcaster = (broadcaster, event_specs, log) => {
|