@fuzdev/fuz_app 0.149.0 → 0.151.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/README.md +1 -1
- package/dist/actions/CLAUDE.md +327 -300
- package/dist/actions/action_bridge.d.ts +5 -79
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +4 -74
- package/dist/actions/action_codegen.d.ts +8 -166
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +19 -95
- package/dist/actions/action_dispatcher.d.ts +10 -0
- package/dist/actions/action_dispatcher.d.ts.map +1 -1
- package/dist/actions/action_dispatcher.js +9 -6
- package/dist/actions/action_event.d.ts +1 -2
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +7 -13
- package/dist/actions/action_event_helpers.d.ts +1 -40
- package/dist/actions/action_event_helpers.d.ts.map +1 -1
- package/dist/actions/action_event_helpers.js +1 -25
- package/dist/actions/action_event_types.d.ts +1 -1
- package/dist/actions/action_event_types.d.ts.map +1 -1
- package/dist/actions/action_rpc.d.ts +10 -215
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +56 -111
- package/dist/actions/action_spec.d.ts +2 -2
- package/dist/actions/action_spec.js +2 -2
- package/dist/actions/action_types.d.ts +229 -8
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +56 -5
- package/dist/actions/broadcast_api.d.ts +22 -17
- package/dist/actions/broadcast_api.d.ts.map +1 -1
- package/dist/actions/broadcast_api.js +16 -27
- package/dist/actions/cancel.d.ts +4 -13
- package/dist/actions/cancel.d.ts.map +1 -1
- package/dist/actions/cancel.js +5 -17
- package/dist/actions/compile_action_registry.d.ts +1 -2
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/connection_closer.d.ts +120 -50
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +139 -31
- package/dist/actions/{transports_ws_backend.d.ts → connection_registry.d.ts} +120 -132
- package/dist/actions/connection_registry.d.ts.map +1 -0
- package/dist/actions/{transports_ws_backend.js → connection_registry.js} +149 -152
- package/dist/actions/frontend_rpc_client.d.ts +52 -2
- package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
- package/dist/actions/frontend_rpc_client.js +42 -4
- package/dist/actions/peer_ping.d.ts +7 -9
- package/dist/actions/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +6 -8
- package/dist/actions/peer_request.d.ts +6 -5
- package/dist/actions/peer_request.d.ts.map +1 -1
- package/dist/actions/peer_request.js +6 -5
- package/dist/actions/perform_action.d.ts +36 -28
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +60 -31
- package/dist/actions/protocol.d.ts +14 -0
- package/dist/actions/protocol.d.ts.map +1 -1
- package/dist/actions/protocol.js +18 -0
- package/dist/actions/register_action_ws.d.ts +137 -292
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +155 -903
- package/dist/actions/socket.svelte.d.ts +9 -0
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +16 -5
- package/dist/actions/transports.d.ts +88 -34
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +76 -76
- package/dist/actions/transports_http.d.ts +48 -12
- package/dist/actions/transports_http.d.ts.map +1 -1
- package/dist/actions/transports_http.js +75 -44
- package/dist/actions/transports_ws.d.ts +29 -0
- package/dist/actions/transports_ws.d.ts.map +1 -1
- package/dist/actions/transports_ws.js +34 -8
- package/dist/actions/ws_endpoint_spec.d.ts +53 -76
- package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
- package/dist/actions/ws_endpoint_spec.js +27 -10
- package/dist/actions/ws_outbound_writer.d.ts +3 -3
- package/dist/actions/ws_outbound_writer.js +3 -3
- package/dist/actions/ws_socket_session.d.ts +321 -0
- package/dist/actions/ws_socket_session.d.ts.map +1 -0
- package/dist/actions/ws_socket_session.js +783 -0
- package/dist/auth/CLAUDE.md +132 -68
- package/dist/auth/account_action_specs.d.ts +2 -0
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_actions.d.ts +1 -1
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +9 -3
- package/dist/auth/account_queries.d.ts +10 -0
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +27 -17
- package/dist/auth/account_routes.d.ts +2 -1
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +14 -17
- package/dist/auth/account_schema.d.ts +5 -5
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +5 -2
- package/dist/auth/actor_lookup_actions.d.ts +1 -1
- package/dist/auth/actor_lookup_actions.d.ts.map +1 -1
- package/dist/auth/actor_lookup_actions.js +1 -1
- package/dist/auth/actor_lookup_queries.d.ts +3 -2
- package/dist/auth/actor_lookup_queries.d.ts.map +1 -1
- package/dist/auth/actor_lookup_queries.js +6 -3
- package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
- package/dist/auth/actor_search_action_specs.js +2 -1
- package/dist/auth/actor_search_actions.d.ts +1 -1
- package/dist/auth/actor_search_actions.d.ts.map +1 -1
- package/dist/auth/actor_search_actions.js +1 -1
- package/dist/auth/actor_search_queries.d.ts +10 -7
- package/dist/auth/actor_search_queries.d.ts.map +1 -1
- package/dist/auth/actor_search_queries.js +18 -11
- package/dist/auth/admin_action_specs.d.ts +4 -4
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +7 -5
- package/dist/auth/admin_actions.d.ts +1 -1
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +47 -48
- package/dist/auth/all_cell_actions.d.ts +14 -3
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +2 -1
- package/dist/auth/api_token_queries.d.ts +1 -0
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +1 -0
- package/dist/auth/audit_emitter.d.ts +12 -6
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +11 -5
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_route_schema.js +3 -2
- package/dist/auth/audit_log_routes.d.ts +20 -11
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +49 -29
- package/dist/auth/audit_log_schema.d.ts +14 -21
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +19 -23
- package/dist/auth/bearer_auth.d.ts +7 -4
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +21 -15
- package/dist/auth/bootstrap_account.d.ts +25 -1
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +37 -4
- package/dist/auth/bootstrap_routes.d.ts +3 -2
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +5 -4
- package/dist/auth/cell_action_helpers.d.ts +89 -0
- package/dist/auth/cell_action_helpers.d.ts.map +1 -0
- package/dist/auth/cell_action_helpers.js +113 -0
- package/dist/auth/cell_action_specs.d.ts +215 -15
- package/dist/auth/cell_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_action_specs.js +103 -16
- package/dist/auth/cell_actions.d.ts +58 -27
- package/dist/auth/cell_actions.d.ts.map +1 -1
- package/dist/auth/cell_actions.js +206 -161
- package/dist/auth/cell_audit_actions.d.ts +1 -1
- package/dist/auth/cell_audit_actions.d.ts.map +1 -1
- package/dist/auth/cell_audit_actions.js +3 -12
- package/dist/auth/cell_audit_events.d.ts +1 -1
- package/dist/auth/cell_audit_events.d.ts.map +1 -1
- package/dist/auth/cell_audit_events.js +3 -2
- package/dist/auth/cell_audit_metadata.d.ts +12 -1
- package/dist/auth/cell_audit_metadata.d.ts.map +1 -1
- package/dist/auth/cell_audit_metadata.js +11 -1
- package/dist/auth/cell_field_actions.d.ts +1 -1
- package/dist/auth/cell_field_actions.d.ts.map +1 -1
- package/dist/auth/cell_field_actions.js +16 -66
- package/dist/auth/cell_grant_action_specs.d.ts +9 -2
- package/dist/auth/cell_grant_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_grant_action_specs.js +10 -3
- package/dist/auth/cell_grant_actions.d.ts +105 -11
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +81 -56
- package/dist/auth/cell_grant_audit_metadata.d.ts +6 -3
- package/dist/auth/cell_grant_audit_metadata.d.ts.map +1 -1
- package/dist/auth/cell_grant_audit_metadata.js +7 -4
- package/dist/auth/cell_item_actions.d.ts +1 -1
- package/dist/auth/cell_item_actions.d.ts.map +1 -1
- package/dist/auth/cell_item_actions.js +21 -82
- package/dist/auth/cleanup.d.ts +1 -1
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +6 -3
- package/dist/auth/credential_deadline.d.ts +3 -3
- package/dist/auth/credential_deadline.js +3 -3
- package/dist/auth/credential_type_schema.d.ts +8 -7
- package/dist/auth/credential_type_schema.d.ts.map +1 -1
- package/dist/auth/credential_type_schema.js +8 -7
- package/dist/auth/daemon_token_middleware.d.ts +12 -6
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +28 -17
- package/dist/auth/deps.d.ts +4 -4
- package/dist/auth/fail_floor.d.ts +55 -0
- package/dist/auth/fail_floor.d.ts.map +1 -0
- package/dist/auth/fail_floor.js +63 -0
- package/dist/auth/invite_queries.d.ts +3 -15
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +3 -21
- package/dist/auth/middleware.d.ts +12 -7
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +42 -29
- package/dist/auth/migrations.d.ts +5 -33
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +9 -16
- package/dist/auth/request_context.d.ts +101 -71
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +137 -140
- package/dist/auth/resolved_auth.d.ts +122 -36
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +89 -38
- package/dist/auth/role_grant_offer_action_specs.d.ts +117 -16
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +51 -16
- package/dist/auth/role_grant_offer_actions.d.ts +22 -11
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +72 -19
- package/dist/auth/role_grant_offer_notifications.d.ts +6 -5
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +4 -3
- package/dist/auth/role_grant_offer_queries.d.ts +20 -5
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +40 -37
- package/dist/auth/role_grant_queries.d.ts +44 -76
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +73 -118
- package/dist/auth/role_grant_sql.d.ts +42 -0
- package/dist/auth/role_grant_sql.d.ts.map +1 -0
- package/dist/auth/role_grant_sql.js +54 -0
- package/dist/auth/role_schema.d.ts +14 -8
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +6 -3
- package/dist/auth/scope_kind_schema.d.ts +1 -1
- package/dist/auth/scope_kind_schema.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +1 -1
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +21 -1
- package/dist/auth/session_queries.d.ts +2 -1
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +2 -1
- package/dist/auth/signup_routes.d.ts +2 -1
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +14 -13
- package/dist/auth/standard_rpc_actions.d.ts +1 -1
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/token_scope.d.ts +19 -46
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +23 -41
- package/dist/db/CLAUDE.md +18 -6
- package/dist/db/cell_ddl.d.ts +5 -134
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +28 -17
- package/dist/db/cell_field_queries.d.ts +0 -13
- package/dist/db/cell_field_queries.d.ts.map +1 -1
- package/dist/db/cell_field_queries.js +0 -16
- package/dist/db/cell_grant_queries.d.ts +10 -5
- package/dist/db/cell_grant_queries.d.ts.map +1 -1
- package/dist/db/cell_grant_queries.js +13 -7
- package/dist/db/cell_item_queries.d.ts +0 -7
- package/dist/db/cell_item_queries.d.ts.map +1 -1
- package/dist/db/cell_item_queries.js +0 -10
- package/dist/db/cell_queries.d.ts +65 -55
- package/dist/db/cell_queries.d.ts.map +1 -1
- package/dist/db/cell_queries.js +85 -62
- package/dist/db/cell_view_sql.d.ts +1 -6
- package/dist/db/cell_view_sql.d.ts.map +1 -1
- package/dist/db/cell_view_sql.js +1 -2
- package/dist/db/fact_ddl.d.ts +5 -30
- package/dist/db/fact_ddl.d.ts.map +1 -1
- package/dist/db/fact_ddl.js +14 -13
- package/dist/db/fact_store.d.ts +11 -0
- package/dist/db/fact_store.d.ts.map +1 -1
- package/dist/db/fact_store.js +4 -1
- package/dist/db/migrate.d.ts +44 -6
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +63 -4
- package/dist/dev/setup.d.ts +18 -14
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +42 -39
- package/dist/env/dotenv.d.ts +2 -2
- package/dist/env/dotenv.js +2 -2
- package/dist/env/update_env_variable.d.ts +33 -21
- package/dist/env/update_env_variable.d.ts.map +1 -1
- package/dist/env/update_env_variable.js +54 -35
- package/dist/hono_context.d.ts +15 -90
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +9 -56
- package/dist/http/CLAUDE.md +35 -20
- package/dist/http/auth_shape.d.ts +1 -8
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +6 -12
- package/dist/http/body_limit.d.ts +3 -1
- package/dist/http/body_limit.d.ts.map +1 -1
- package/dist/http/body_limit.js +6 -1
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +3 -2
- package/dist/http/db_routes.d.ts +3 -3
- package/dist/http/db_routes.js +3 -3
- package/dist/http/error_schemas.d.ts +1 -2
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +1 -2
- package/dist/http/health_schema.d.ts +16 -0
- package/dist/http/health_schema.d.ts.map +1 -0
- package/dist/http/health_schema.js +12 -0
- package/dist/http/jsonrpc.d.ts +9 -0
- package/dist/http/jsonrpc.d.ts.map +1 -1
- package/dist/http/jsonrpc.js +17 -0
- package/dist/http/jsonrpc_errors.d.ts +22 -2
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +70 -23
- package/dist/http/jsonrpc_helpers.d.ts +60 -17
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +67 -25
- package/dist/http/origin.d.ts +30 -1
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +46 -9
- package/dist/http/origin_wildcard.d.ts +97 -0
- package/dist/http/origin_wildcard.d.ts.map +1 -0
- package/dist/http/origin_wildcard.js +142 -0
- package/dist/http/pending_effects.d.ts +28 -0
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +32 -1
- package/dist/http/proxy.d.ts +4 -2
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +7 -2
- package/dist/http/route_spec.d.ts +4 -3
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +54 -45
- package/dist/http/surface.d.ts +4 -2
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +7 -4
- package/dist/http/surface_query.d.ts +9 -50
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +48 -94
- package/dist/realtime/audit_log_sse.d.ts +180 -0
- package/dist/realtime/audit_log_sse.d.ts.map +1 -0
- package/dist/realtime/audit_log_sse.js +154 -0
- package/dist/realtime/sse.d.ts +21 -6
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +33 -10
- package/dist/realtime/sse_constants.d.ts +29 -2
- package/dist/realtime/sse_constants.d.ts.map +1 -1
- package/dist/realtime/sse_constants.js +35 -2
- package/dist/realtime/{subscriber_registry.d.ts → sse_registry.d.ts} +12 -12
- package/dist/realtime/sse_registry.d.ts.map +1 -0
- package/dist/realtime/{subscriber_registry.js → sse_registry.js} +4 -4
- package/dist/schema_meta.d.ts +52 -1
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +123 -6
- package/dist/sensitivity.d.ts +9 -3
- package/dist/sensitivity.d.ts.map +1 -1
- package/dist/sensitivity.js +3 -2
- package/dist/server/app_backend.d.ts +8 -5
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +6 -12
- package/dist/server/app_server.d.ts +73 -54
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +115 -78
- package/dist/server/app_server_context.d.ts +1 -1
- package/dist/server/app_server_context.d.ts.map +1 -1
- package/dist/server/env.d.ts +24 -20
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/env.js +24 -34
- package/dist/server/serve_fact_route.d.ts +12 -16
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +59 -34
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +2 -2
- package/dist/testing/CLAUDE.md +213 -179
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +10 -19
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +8 -0
- package/dist/testing/app_server.d.ts +9 -75
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +31 -112
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +3 -4
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +4 -5
- package/dist/testing/auth_apps.d.ts +3 -3
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +9 -6
- package/dist/testing/connection_closer_helpers.d.ts +8 -16
- package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
- package/dist/testing/connection_closer_helpers.js +7 -20
- package/dist/testing/cross_backend/action_manifest.d.ts +15 -4
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +13 -3
- package/dist/testing/cross_backend/action_manifest_parity.d.ts +15 -7
- package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest_parity.js +8 -1
- package/dist/testing/cross_backend/actor_lookup.d.ts.map +1 -1
- package/dist/testing/cross_backend/actor_lookup.js +27 -0
- package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size.js +25 -22
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts +22 -3
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
- package/dist/testing/cross_backend/build_test_backend_paths.js +34 -11
- package/dist/testing/cross_backend/capabilities.d.ts +15 -8
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_gated_create.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_gated_create.js +109 -13
- package/dist/testing/cross_backend/cell_grant_role.js +2 -2
- package/dist/testing/cross_backend/cell_grant_steward.d.ts +4 -0
- package/dist/testing/cross_backend/cell_grant_steward.d.ts.map +1 -0
- package/dist/testing/cross_backend/cell_grant_steward.js +120 -0
- package/dist/testing/cross_backend/cell_moderate.d.ts +7 -1
- package/dist/testing/cross_backend/cell_moderate.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_moderate.js +68 -4
- package/dist/testing/cross_backend/cell_ref_admission.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_ref_admission.js +18 -9
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.js +21 -0
- package/dist/testing/cross_backend/conformance_table.d.ts +6 -1
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +12 -10
- package/dist/testing/cross_backend/default_backend_configs.d.ts +18 -4
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +29 -9
- package/dist/testing/cross_backend/default_spine_surface.d.ts +7 -7
- package/dist/testing/cross_backend/default_spine_surface.js +2 -2
- package/dist/testing/cross_backend/differential.d.ts +7 -0
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +17 -0
- package/dist/testing/cross_backend/expected_schema.json +1 -0
- package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
- package/dist/testing/cross_backend/fact_serving.js +48 -0
- package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -4
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +13 -5
- package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_scope.js +5 -13
- package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +29 -4
- package/dist/testing/cross_backend/postgres_database.d.ts +32 -0
- package/dist/testing/cross_backend/postgres_database.d.ts.map +1 -1
- package/dist/testing/cross_backend/postgres_database.js +56 -1
- package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
- package/dist/testing/cross_backend/query_shape.js +18 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +96 -2
- package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -2
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +17 -5
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +5 -4
- package/dist/testing/cross_backend/session_cap.d.ts +8 -0
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +66 -2
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +5 -4
- package/dist/testing/cross_backend/spine_suites.d.ts +4 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +21 -0
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +22 -7
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +22 -7
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +4 -3
- package/dist/testing/cross_backend/standard.d.ts +6 -12
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/test_cell_gated_create_authorize.d.ts +18 -19
- package/dist/testing/cross_backend/test_cell_gated_create_authorize.d.ts.map +1 -1
- package/dist/testing/cross_backend/test_cell_gated_create_authorize.js +66 -42
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts +8 -0
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts.map +1 -0
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.js +22 -0
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +4 -6
- package/dist/testing/cross_backend/testing_origin_check.d.ts +1 -1
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +10 -5
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +7 -6
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +5 -4
- package/dist/testing/cross_backend/testing_server_core.d.ts +6 -7
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +1 -1
- package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_node.js +13 -2
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +68 -0
- package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +48 -6
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +16 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +11 -8
- package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_action_rate_limit.js +30 -12
- package/dist/testing/cross_backend/ws_connection_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_connection_cap.js +5 -7
- package/dist/testing/cross_backend/ws_endpoint.d.ts +2 -3
- package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_envelope.d.ts +17 -0
- package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -0
- package/dist/testing/cross_backend/ws_envelope.js +172 -0
- package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts +16 -0
- package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_inbound_dispatch.js +8 -4
- package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_outbound_overflow.js +5 -8
- package/dist/testing/cross_backend/ws_role_gated.js +2 -2
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +6 -4
- package/dist/{cli/daemon.d.ts → testing/daemon_info.d.ts} +15 -47
- package/dist/testing/daemon_info.d.ts.map +1 -0
- package/dist/testing/daemon_info.js +108 -0
- package/dist/testing/daemon_token_rotation.js +1 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +3 -4
- package/dist/testing/db.js +2 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +35 -65
- package/dist/testing/integration_helpers.d.ts +0 -15
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +2 -42
- package/dist/testing/middleware.d.ts +20 -12
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +49 -40
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +13 -22
- package/dist/testing/resolved_auth.d.ts +30 -0
- package/dist/testing/resolved_auth.d.ts.map +1 -0
- package/dist/testing/resolved_auth.js +41 -0
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +3 -0
- package/dist/testing/rpc_helpers.d.ts +1 -1
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +2 -1
- package/dist/testing/sse_round_trip.d.ts +5 -4
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +24 -21
- package/dist/testing/test_origin.d.ts +25 -0
- package/dist/testing/test_origin.d.ts.map +1 -0
- package/dist/testing/test_origin.js +28 -0
- package/dist/testing/transports/raw_http.d.ts +54 -0
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +58 -0
- package/dist/testing/transports/ws_raw_client.d.ts +8 -0
- package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
- package/dist/testing/transports/ws_raw_client.js +13 -0
- package/dist/testing/transports/ws_transport.d.ts +15 -2
- package/dist/testing/transports/ws_transport.d.ts.map +1 -1
- package/dist/testing/transports/ws_transport.js +4 -2
- package/dist/testing/ws_round_trip.d.ts +27 -25
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +34 -26
- package/dist/ui/AccountSessions.svelte +48 -19
- package/dist/ui/AccountSessions.svelte.d.ts +2 -17
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAccounts.svelte +6 -1
- package/dist/ui/AdminAuditLog.svelte +61 -22
- package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
- package/dist/ui/AdminInvites.svelte +1 -1
- package/dist/ui/AdminOverview.svelte +76 -37
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/AdminRoleGrantHistory.svelte +6 -1
- package/dist/ui/AdminSessions.svelte +1 -1
- package/dist/ui/AppShell.svelte +3 -2
- package/dist/ui/AppShell.svelte.d.ts +3 -2
- package/dist/ui/AppShell.svelte.d.ts.map +1 -1
- package/dist/ui/CLAUDE.md +121 -35
- package/dist/ui/Datatable.svelte +33 -18
- package/dist/ui/Datatable.svelte.d.ts +2 -14
- package/dist/ui/Datatable.svelte.d.ts.map +1 -1
- package/dist/ui/OpenSignupToggle.svelte +10 -1
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
- package/dist/ui/PopoverButton.svelte +13 -8
- package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferForm.svelte +3 -2
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts +3 -2
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
- package/dist/ui/RoleGrantOfferInbox.svelte +19 -15
- package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
- package/dist/ui/SurfaceExplorer.svelte +66 -27
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +7 -14
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.d.ts +14 -9
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +6 -4
- package/dist/ui/admin_invites_state.svelte.d.ts +2 -2
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.d.ts +9 -9
- package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.js +9 -9
- package/dist/ui/app_settings_state.svelte.d.ts +2 -2
- package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.d.ts +70 -13
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +239 -47
- package/dist/ui/backend_probe.svelte.d.ts +93 -0
- package/dist/ui/backend_probe.svelte.d.ts.map +1 -0
- package/dist/ui/backend_probe.svelte.js +140 -0
- package/dist/ui/format_scope.d.ts +7 -7
- package/dist/ui/format_scope.d.ts.map +1 -1
- package/dist/ui/format_scope.js +4 -4
- package/dist/ui/keyed_async_slot.svelte.d.ts +2 -2
- package/dist/ui/keyed_async_slot.svelte.js +2 -2
- package/dist/ui/popover.svelte.d.ts +18 -19
- package/dist/ui/popover.svelte.d.ts.map +1 -1
- package/dist/ui/popover.svelte.js +103 -16
- package/dist/ui/role_grant_offers_state.svelte.d.ts +41 -46
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/role_grant_offers_state.svelte.js +37 -19
- package/dist/ui/ui_format.d.ts +17 -0
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +20 -0
- package/package.json +2 -1
- package/dist/actions/register_ws_endpoint.d.ts +0 -79
- package/dist/actions/register_ws_endpoint.d.ts.map +0 -1
- package/dist/actions/register_ws_endpoint.js +0 -109
- package/dist/actions/transports_ws_auth_guard.d.ts +0 -94
- package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
- package/dist/actions/transports_ws_auth_guard.js +0 -138
- package/dist/actions/transports_ws_backend.d.ts.map +0 -1
- package/dist/cli/args.d.ts +0 -55
- package/dist/cli/args.d.ts.map +0 -1
- package/dist/cli/args.js +0 -100
- package/dist/cli/config.d.ts +0 -47
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -77
- package/dist/cli/daemon.d.ts.map +0 -1
- package/dist/cli/daemon.js +0 -181
- package/dist/cli/help.d.ts +0 -124
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -215
- package/dist/cli/logger.d.ts +0 -46
- package/dist/cli/logger.d.ts.map +0 -1
- package/dist/cli/logger.js +0 -48
- package/dist/cli/util.d.ts +0 -36
- package/dist/cli/util.d.ts.map +0 -1
- package/dist/cli/util.js +0 -50
- package/dist/realtime/sse_auth_guard.d.ts +0 -197
- package/dist/realtime/sse_auth_guard.d.ts.map +0 -1
- package/dist/realtime/sse_auth_guard.js +0 -238
- package/dist/realtime/subscriber_registry.d.ts.map +0 -1
- package/dist/testing/bootstrap_success.d.ts +0 -29
- package/dist/testing/bootstrap_success.d.ts.map +0 -1
- package/dist/testing/bootstrap_success.js +0 -144
- package/dist/testing/mock_fs.d.ts +0 -20
- package/dist/testing/mock_fs.d.ts.map +0 -1
- package/dist/testing/mock_fs.js +0 -28
- package/dist/testing/standard.d.ts +0 -122
- package/dist/testing/standard.d.ts.map +0 -1
- package/dist/testing/standard.js +0 -73
- package/dist/testing/testing_rate_limiter.d.ts +0 -65
- package/dist/testing/testing_rate_limiter.d.ts.map +0 -1
- package/dist/testing/testing_rate_limiter.js +0 -80
|
@@ -11,7 +11,7 @@ import { Hono } from 'hono';
|
|
|
11
11
|
import { logger } from 'hono/logger';
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { session_cookie_options } from '../auth/session_cookie.js';
|
|
14
|
-
import { create_audit_log_sse, create_sse_connection_closer, audit_log_event_specs } from '../realtime/
|
|
14
|
+
import { create_audit_log_sse, create_sse_connection_closer, audit_log_event_specs } from '../realtime/audit_log_sse.js';
|
|
15
15
|
import { BaseServerEnv } from './env.js';
|
|
16
16
|
import { RateLimiter, announce_rate_limiters_disabled, default_login_ip_rate_limit, default_login_account_rate_limit, default_action_account_rate_limit, default_action_ip_rate_limit } from '../rate_limiter.js';
|
|
17
17
|
// Side-effect import: augments Hono's ContextVariableMap so consumers
|
|
@@ -24,15 +24,16 @@ import { create_app_surface_spec } from '../http/surface.js';
|
|
|
24
24
|
import { apply_middleware_specs, apply_route_specs, prefix_route_specs } from '../http/route_spec.js';
|
|
25
25
|
import { check_bootstrap_status, create_bootstrap_route_specs } from '../auth/bootstrap_routes.js';
|
|
26
26
|
import { create_surface_route_spec } from './surface_route.js';
|
|
27
|
-
import {
|
|
27
|
+
import { flush_request_effects } from '../http/pending_effects.js';
|
|
28
28
|
import { assert_credential_routes_in_auth_scope, assert_endpoint_in_auth_scope, assert_middleware_stack_mounted, create_auth_middleware_specs } from '../auth/middleware.js';
|
|
29
29
|
import { fuz_auth_guard_resolver } from '../auth/auth_guard_resolver.js';
|
|
30
30
|
import { create_fuz_authorization_handler } from '../auth/request_context.js';
|
|
31
31
|
import { create_body_limit_middleware } from '../http/body_limit.js';
|
|
32
|
+
import { admit_origin_wildcards, ALLOWED_ORIGINS_VAR } from '../http/origin_wildcard.js';
|
|
32
33
|
import { create_rpc_endpoint } from '../actions/action_rpc.js';
|
|
33
|
-
import {
|
|
34
|
+
import { register_action_ws } from '../actions/register_action_ws.js';
|
|
34
35
|
import { resolve_ws_endpoints } from '../actions/ws_endpoint_spec.js';
|
|
35
|
-
import {
|
|
36
|
+
import { create_revocation_guard } from '../actions/connection_closer.js';
|
|
36
37
|
import { start_auth_cleanup } from '../auth/cleanup.js';
|
|
37
38
|
/**
|
|
38
39
|
* Assert that `audit_sse` was wired by `create_app_server` and return it
|
|
@@ -57,8 +58,11 @@ export const require_audit_sse = (source) => {
|
|
|
57
58
|
}
|
|
58
59
|
return source.audit_sse;
|
|
59
60
|
};
|
|
60
|
-
/**
|
|
61
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Default maximum request body size: 1 MiB. Twin of the Rust spine's
|
|
63
|
+
* `fuz_http` `DEFAULT_BODY_LIMIT_BYTES`.
|
|
64
|
+
*/
|
|
65
|
+
export const DEFAULT_BODY_LIMIT_BYTES = 1024 * 1024;
|
|
62
66
|
/**
|
|
63
67
|
* Each `AppServerOptions` rate-limiter field, with the defaults an omitted one
|
|
64
68
|
* is built from under `rate_limiters: 'enforced'` and the name its
|
|
@@ -126,7 +130,8 @@ export const resolve_rate_limiters = (options) => {
|
|
|
126
130
|
* spec-level ones: a weakened session cookie, and an open rate-limited
|
|
127
131
|
* surface — one warning for `'disabled_for_testing'`, otherwise one per
|
|
128
132
|
* explicitly-null limiter, so a deployment that disables login's limiter but
|
|
129
|
-
* keeps signup's reads differently from one that disables both
|
|
133
|
+
* keeps signup's reads differently from one that disables both — and a
|
|
134
|
+
* disabled request body size limit (`max_body_size: null`).
|
|
130
135
|
*
|
|
131
136
|
* @internal
|
|
132
137
|
*/
|
|
@@ -176,6 +181,14 @@ export const collect_config_diagnostics = (input) => {
|
|
|
176
181
|
}
|
|
177
182
|
}
|
|
178
183
|
}
|
|
184
|
+
if (input.max_body_size === null) {
|
|
185
|
+
diagnostics.push({
|
|
186
|
+
level: 'warning',
|
|
187
|
+
category: 'security',
|
|
188
|
+
message: 'request body size limit explicitly disabled (max_body_size: null) — ' +
|
|
189
|
+
'every route must cap its own body'
|
|
190
|
+
});
|
|
191
|
+
}
|
|
179
192
|
return diagnostics;
|
|
180
193
|
};
|
|
181
194
|
/**
|
|
@@ -190,9 +203,12 @@ export const collect_config_diagnostics = (input) => {
|
|
|
190
203
|
*
|
|
191
204
|
* When `audit_log_sse` is set, the SSE registry's listener is registered via
|
|
192
205
|
* `backend.deps.audit.add_listener` — no shallow-copy of `AppDeps`. That
|
|
193
|
-
* registry and every WebSocket
|
|
206
|
+
* registry and every WebSocket connection registry mounted from `ws_endpoints` are added
|
|
194
207
|
* to `backend.deps.connection_closer`, so the revocation handlers built from
|
|
195
|
-
* `ctx.deps` close their connections with no further wiring
|
|
208
|
+
* `ctx.deps` close their connections with no further wiring, and — when the
|
|
209
|
+
* server mounts either — one `create_revocation_guard` listener on that closer
|
|
210
|
+
* repeats each close on the audit row (the only closer of a role revocation).
|
|
211
|
+
* The
|
|
196
212
|
* `audit_sse` field on the returned `AppServer` (and the
|
|
197
213
|
* `AppServerContext` passed to `create_route_specs`) is non-null in that
|
|
198
214
|
* case; consumers can call `require_audit_sse(ctx)` / `require_audit_sse(server)`
|
|
@@ -213,7 +229,7 @@ export const collect_config_diagnostics = (input) => {
|
|
|
213
229
|
* closes the database (`AppServer.close`).
|
|
214
230
|
*
|
|
215
231
|
* @returns the assembled Hono app with its surface, bootstrap status, migration results,
|
|
216
|
-
* audit SSE, mounted WS
|
|
232
|
+
* audit SSE, mounted WS registries, and `close`
|
|
217
233
|
* @throws Error from any assembly step, after releasing what assembly acquired
|
|
218
234
|
*/
|
|
219
235
|
export const create_app_server = async (options) => {
|
|
@@ -249,6 +265,22 @@ const assemble_app_server = async (options, releases) => {
|
|
|
249
265
|
const { backend } = options;
|
|
250
266
|
const { deps } = backend;
|
|
251
267
|
const { log } = deps;
|
|
268
|
+
// option checks first, before anything is acquired
|
|
269
|
+
if (options.allowed_origins.length === 0) {
|
|
270
|
+
throw new Error('create_app_server: allowed_origins is empty — list at least one origin pattern ' +
|
|
271
|
+
'(an empty list refuses every browser request)');
|
|
272
|
+
}
|
|
273
|
+
const wildcards = admit_origin_wildcards(options.allowed_origins, options.allow_origin_wildcards ?? false);
|
|
274
|
+
if (!wildcards.ok)
|
|
275
|
+
throw new Error(`create_app_server: ${wildcards.message}`);
|
|
276
|
+
for (const { entry, warning } of wildcards.wildcards) {
|
|
277
|
+
log.warn(`${ALLOWED_ORIGINS_VAR}: ${warning} (origin ${entry})`);
|
|
278
|
+
}
|
|
279
|
+
// body size limit — rejects oversized payloads before auth/validation; the
|
|
280
|
+
// middleware throws on a cap that is not a safe integer 0 or more
|
|
281
|
+
const body_limit_middleware = options.max_body_size === null
|
|
282
|
+
? null
|
|
283
|
+
: create_body_limit_middleware(options.max_body_size ?? DEFAULT_BODY_LIMIT_BYTES);
|
|
252
284
|
// Rate limiters — the ones built here are the server's to dispose, on
|
|
253
285
|
// close or when assembly fails.
|
|
254
286
|
const { mode: rate_limiter_mode, limiters: rate_limiters, built: built_rate_limiters } = resolve_rate_limiters(options);
|
|
@@ -265,7 +297,9 @@ const assemble_app_server = async (options, releases) => {
|
|
|
265
297
|
const audit_sse = options.audit_log_sse
|
|
266
298
|
? create_audit_log_sse({
|
|
267
299
|
log,
|
|
268
|
-
|
|
300
|
+
...(typeof options.audit_log_sse === 'object'
|
|
301
|
+
? { role: options.audit_log_sse.role, keep_alive_ms: options.audit_log_sse.keep_alive_ms }
|
|
302
|
+
: null),
|
|
269
303
|
connection_closer: null
|
|
270
304
|
})
|
|
271
305
|
: null;
|
|
@@ -358,15 +392,16 @@ const assemble_app_server = async (options, releases) => {
|
|
|
358
392
|
}
|
|
359
393
|
// WS endpoint resolution — done here (alongside RPC) so the captured
|
|
360
394
|
// array threads into surface generation below. Actual mount happens
|
|
361
|
-
// after `apply_route_specs` because `
|
|
362
|
-
// live Hono `app` (
|
|
363
|
-
//
|
|
364
|
-
// until the assembly phase below.
|
|
365
|
-
// A spec without `allowed_origins` takes the server's list
|
|
366
|
-
//
|
|
395
|
+
// after `apply_route_specs` because `register_action_ws` mutates the
|
|
396
|
+
// live Hono `app` (the `app.get(path, ...)` upgrade route with its
|
|
397
|
+
// origin / auth / scope / authorization / role chain), and `app` does not
|
|
398
|
+
// exist until the assembly phase below.
|
|
399
|
+
// A spec without `allowed_origins` takes the server's list, and one without
|
|
400
|
+
// `actions` the sole RPC endpoint's — resolved here, once, so the mount and
|
|
401
|
+
// the surface read the same values.
|
|
367
402
|
const resolved_ws_endpoints = resolve_ws_endpoints(typeof options.ws_endpoints === 'function'
|
|
368
403
|
? options.ws_endpoints(context)
|
|
369
|
-
: options.ws_endpoints, options.allowed_origins);
|
|
404
|
+
: options.ws_endpoints, { allowed_origins: options.allowed_origins, rpc_endpoints: resolved_rpc_endpoints });
|
|
370
405
|
// the endpoints to mount and the adapter factory they need — null when none resolve
|
|
371
406
|
let ws_mount = null;
|
|
372
407
|
if (resolved_ws_endpoints?.length) {
|
|
@@ -380,6 +415,14 @@ const assemble_app_server = async (options, releases) => {
|
|
|
380
415
|
}
|
|
381
416
|
ws_mount = { endpoints: resolved_ws_endpoints, create_upgrade_websocket };
|
|
382
417
|
}
|
|
418
|
+
// The one revocation listener, registered when a WS endpoint or the audit
|
|
419
|
+
// stream is mounted — on the backend's closer, so it reaches every member:
|
|
420
|
+
// each WS connection registry the mount below adds, the audit stream registry, and any
|
|
421
|
+
// the consumer added by hand. After the audit stream's listener, so a
|
|
422
|
+
// revocation's row reaches the stream before the guard can close it.
|
|
423
|
+
if (audit_sse || ws_mount) {
|
|
424
|
+
releases.push(deps.audit.add_listener(create_revocation_guard(deps.connection_closer, log)));
|
|
425
|
+
}
|
|
383
426
|
// Surface route (opt-in)
|
|
384
427
|
if (options.surface_route) {
|
|
385
428
|
factory_routes.push(create_surface_route_spec(surface_ref));
|
|
@@ -390,9 +433,10 @@ const assemble_app_server = async (options, releases) => {
|
|
|
390
433
|
// prefixes included (account and signup specs are relative)
|
|
391
434
|
assert_credential_routes_in_auth_scope(route_specs);
|
|
392
435
|
// WS path checks — pure data, so they run before anything mounts.
|
|
393
|
-
// `
|
|
436
|
+
// `register_action_ws` mounts a `GET path` upgrade route: a duplicate
|
|
394
437
|
// path, or one a `RouteSpec` already registered as `GET path`, would be
|
|
395
|
-
// silently shadowed by Hono's last-wins semantics — fail fast instead.
|
|
438
|
+
// silently shadowed by Hono's last-wins semantics — fail fast instead. An
|
|
439
|
+
// endpoint's own empty `allowed_origins` would refuse every browser upgrade.
|
|
396
440
|
if (ws_mount) {
|
|
397
441
|
const route_spec_get_paths = new Set();
|
|
398
442
|
for (const r of route_specs) {
|
|
@@ -407,6 +451,23 @@ const assemble_app_server = async (options, releases) => {
|
|
|
407
451
|
if (route_spec_get_paths.has(endpoint.path)) {
|
|
408
452
|
throw new Error(`create_app_server: ws_endpoints path collides with a GET RouteSpec: ${endpoint.path}`);
|
|
409
453
|
}
|
|
454
|
+
if (endpoint.allowed_origins.length === 0) {
|
|
455
|
+
throw new Error(`create_app_server: ws_endpoints allowed_origins is empty for ${endpoint.path} — ` +
|
|
456
|
+
'list at least one origin pattern, or omit it to take the server list ' +
|
|
457
|
+
'(an empty list refuses every browser upgrade)');
|
|
458
|
+
}
|
|
459
|
+
// an endpoint's own list gets the server list's wildcard check (one
|
|
460
|
+
// that took the server list was checked above)
|
|
461
|
+
if (endpoint.allowed_origins !== options.allowed_origins) {
|
|
462
|
+
const label = `ws_endpoints allowed_origins for ${endpoint.path}`;
|
|
463
|
+
const endpoint_wildcards = admit_origin_wildcards(endpoint.allowed_origins, options.allow_origin_wildcards ?? false, label);
|
|
464
|
+
if (!endpoint_wildcards.ok) {
|
|
465
|
+
throw new Error(`create_app_server: ${endpoint_wildcards.message}`);
|
|
466
|
+
}
|
|
467
|
+
for (const { entry, warning } of endpoint_wildcards.wildcards) {
|
|
468
|
+
log.warn(`${label}: ${warning} (origin ${entry})`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
410
471
|
seen_paths.add(endpoint.path);
|
|
411
472
|
}
|
|
412
473
|
}
|
|
@@ -430,7 +491,8 @@ const assemble_app_server = async (options, releases) => {
|
|
|
430
491
|
const config_diagnostics = collect_config_diagnostics({
|
|
431
492
|
cookie_options: options.session_options.cookie_options,
|
|
432
493
|
rate_limiter_mode,
|
|
433
|
-
rate_limiters
|
|
494
|
+
rate_limiters,
|
|
495
|
+
max_body_size: options.max_body_size
|
|
434
496
|
});
|
|
435
497
|
if (config_diagnostics.length) {
|
|
436
498
|
surface_spec.surface.diagnostics = [...surface_spec.surface.diagnostics, ...config_diagnostics];
|
|
@@ -444,12 +506,14 @@ const assemble_app_server = async (options, releases) => {
|
|
|
444
506
|
// fire-and-forget promises (audit emits, api-token usage). `post_commit_effects` collects deferred thunks pushed via
|
|
445
507
|
// `emit_after_commit` (WS notifications, anything that must observe a
|
|
446
508
|
// committed transaction). Both queues drain here, after the handler
|
|
447
|
-
// (and any wrapping `db.transaction`) returns
|
|
448
|
-
//
|
|
449
|
-
//
|
|
450
|
-
//
|
|
451
|
-
//
|
|
452
|
-
//
|
|
509
|
+
// (and any wrapping `db.transaction`) returns, through the flush the WS
|
|
510
|
+
// dispatcher shares (`flush_request_effects`). In test mode the flush is
|
|
511
|
+
// awaited before the response returns; in production it runs
|
|
512
|
+
// fire-and-forget. Either way eager rejections reach `on_effect_error`,
|
|
513
|
+
// and the deferred thunks are invoked without waiting for the eager
|
|
514
|
+
// writes to settle — a revocation's connection close must not sit behind
|
|
515
|
+
// a slow audit INSERT.
|
|
516
|
+
const on_effect_error = options.on_effect_error;
|
|
453
517
|
app.use('*', async (c, next) => {
|
|
454
518
|
c.set('pending_effects', []);
|
|
455
519
|
c.set('post_commit_effects', []);
|
|
@@ -460,42 +524,32 @@ const assemble_app_server = async (options, releases) => {
|
|
|
460
524
|
const eager = c.var.pending_effects;
|
|
461
525
|
const deferred = c.var.post_commit_effects;
|
|
462
526
|
if (eager.length || deferred.length) {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
void flush_pending_effects(eager, log, callback ? (reason) => callback(reason, error_ctx) : undefined);
|
|
474
|
-
// `flush_post_commit_effects` is non-throwing: per-thunk
|
|
475
|
-
// errors are routed through `log.error` inside the helper,
|
|
476
|
-
// so production fire-and-forget skips the `on_effect_error`
|
|
477
|
-
// fan-out (deferred thunks are wrapped end-to-end already).
|
|
478
|
-
void flush_post_commit_effects(deferred, log);
|
|
479
|
-
}
|
|
527
|
+
const error_ctx = {
|
|
528
|
+
transport: 'http',
|
|
529
|
+
method: c.req.method,
|
|
530
|
+
path: c.req.path
|
|
531
|
+
};
|
|
532
|
+
const flushed = flush_request_effects(eager, deferred, log, on_effect_error ? (reason) => on_effect_error(reason, error_ctx) : undefined);
|
|
533
|
+
if (options.await_pending_effects)
|
|
534
|
+
await flushed;
|
|
535
|
+
else
|
|
536
|
+
void flushed;
|
|
480
537
|
}
|
|
481
538
|
}
|
|
482
539
|
});
|
|
483
540
|
if (log.level !== 'off') {
|
|
484
541
|
app.use(logger((msg) => log.info(msg)));
|
|
485
542
|
}
|
|
486
|
-
//
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
const max_size = options.max_body_size ?? DEFAULT_MAX_BODY_SIZE;
|
|
490
|
-
app.use(create_body_limit_middleware(max_size));
|
|
543
|
+
// body size limit, built with the option checks above
|
|
544
|
+
if (body_limit_middleware) {
|
|
545
|
+
app.use(body_limit_middleware);
|
|
491
546
|
}
|
|
492
547
|
apply_middleware_specs(app, middleware_specs);
|
|
493
548
|
const authorize = create_fuz_authorization_handler({ db: deps.db });
|
|
494
549
|
apply_route_specs(app, route_specs, fuz_auth_guard_resolver, log, deps.db, authorize);
|
|
495
550
|
// WS endpoint auto-mount — must run after `app` exists and
|
|
496
551
|
// `apply_route_specs` has registered the request routes. Each spec
|
|
497
|
-
// becomes a `
|
|
498
|
-
// wiring onto the audit chain. `post_route_middleware` and static
|
|
552
|
+
// becomes a `register_action_ws` call. `post_route_middleware` and static
|
|
499
553
|
// serving register after this loop, so WS upgrade routes sit
|
|
500
554
|
// adjacent to the consumer routes and ahead of the static fallback —
|
|
501
555
|
// matches the "WS mount is route registration" mental model.
|
|
@@ -504,50 +558,33 @@ const assemble_app_server = async (options, releases) => {
|
|
|
504
558
|
// the adapter helper — built from this app, which Node's
|
|
505
559
|
// `createNodeWebSocket({app})` needs, and only when there is something to mount
|
|
506
560
|
const upgrade_websocket = ws_mount.create_upgrade_websocket(app);
|
|
507
|
-
// Dedupe `auth_guard` wiring by transport reference — two specs
|
|
508
|
-
// sharing one transport instance get a single listener,
|
|
509
|
-
// otherwise revocation events would fire `close_sockets_for_*`
|
|
510
|
-
// twice per event (idempotent on the transport but log-spammy).
|
|
511
|
-
// Cross-spec OR-semantics: any spec with `auth_guard !== false`
|
|
512
|
-
// wires the guard for that transport; once wired, sibling specs
|
|
513
|
-
// (even with explicit `auth_guard: false`) cannot opt out. To
|
|
514
|
-
// disable, every spec sharing the transport must pass `auth_guard: false`.
|
|
515
|
-
const guarded_transports = new WeakSet();
|
|
516
561
|
for (const endpoint of ws_mount.endpoints) {
|
|
517
|
-
const {
|
|
562
|
+
const { registry: endpoint_registry } = register_action_ws({
|
|
518
563
|
app,
|
|
519
564
|
path: endpoint.path,
|
|
520
565
|
upgradeWebSocket: upgrade_websocket,
|
|
521
566
|
allowed_origins: endpoint.allowed_origins,
|
|
522
567
|
db: deps.db,
|
|
523
568
|
actions: endpoint.actions,
|
|
524
|
-
|
|
569
|
+
registry: endpoint.registry,
|
|
525
570
|
// added below instead, so the remover is the server's
|
|
526
571
|
connection_closer: null,
|
|
527
572
|
max_connections_per_account: endpoint.max_connections_per_account,
|
|
528
573
|
outbound_queue_bytes: endpoint.outbound_queue_bytes,
|
|
529
|
-
|
|
530
|
-
artificial_delay: endpoint.artificial_delay,
|
|
574
|
+
receive_timeout: endpoint.receive_timeout,
|
|
531
575
|
max_message_bytes: endpoint.max_message_bytes,
|
|
532
576
|
on_socket_open: endpoint.on_socket_open,
|
|
533
577
|
on_socket_close: endpoint.on_socket_close,
|
|
534
578
|
log,
|
|
535
579
|
required_roles: endpoint.required_roles,
|
|
536
580
|
action_ip_rate_limiter,
|
|
537
|
-
action_account_rate_limiter
|
|
581
|
+
action_account_rate_limiter,
|
|
582
|
+
on_effect_error
|
|
538
583
|
});
|
|
539
|
-
mounted_ws_endpoints[endpoint.path] =
|
|
540
|
-
// every revocation
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
guarded_transports.add(endpoint_transport);
|
|
544
|
-
releases.push(deps.audit.add_listener(create_ws_auth_guard(endpoint_transport, log)));
|
|
545
|
-
}
|
|
546
|
-
if (endpoint.extra_audit_handlers?.length) {
|
|
547
|
-
for (const handler of endpoint.extra_audit_handlers) {
|
|
548
|
-
releases.push(deps.audit.add_listener(handler));
|
|
549
|
-
}
|
|
550
|
-
}
|
|
584
|
+
mounted_ws_endpoints[endpoint.path] = endpoint_registry;
|
|
585
|
+
// every revocation's close — the handlers' and the guard's — reaches
|
|
586
|
+
// this registry
|
|
587
|
+
releases.push(deps.connection_closer.add(endpoint_registry));
|
|
551
588
|
}
|
|
552
589
|
}
|
|
553
590
|
// Post-route middleware (before static serving)
|
|
@@ -578,7 +615,7 @@ const assemble_app_server = async (options, releases) => {
|
|
|
578
615
|
// then the connections, so none outlives the server — a failure here
|
|
579
616
|
// must not keep the database open
|
|
580
617
|
try {
|
|
581
|
-
deps.connection_closer.
|
|
618
|
+
deps.connection_closer.close_all_connections();
|
|
582
619
|
}
|
|
583
620
|
catch (error) {
|
|
584
621
|
log.error('create_app_server: closing live connections on shutdown failed:', error);
|
|
@@ -18,7 +18,7 @@ import type { AppBackend } from './app_backend.js';
|
|
|
18
18
|
import type { BootstrapStatus } from '../auth/bootstrap_routes.js';
|
|
19
19
|
import type { SessionOptions } from '../auth/session_cookie.js';
|
|
20
20
|
import type { RateLimiter } from '../rate_limiter.js';
|
|
21
|
-
import type { AuditLogSse } from '../realtime/
|
|
21
|
+
import type { AuditLogSse } from '../realtime/audit_log_sse.js';
|
|
22
22
|
/** Context passed to `create_route_specs`. */
|
|
23
23
|
export interface AppServerContext {
|
|
24
24
|
deps: AppDeps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_server_context.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"app_server_context.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,UAAU,CAAC;IACpB,gBAAgB,EAAE,eAAe,CAAC;IAClC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;;OASG;IACH,qBAAqB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1C,wDAAwD;IACxD,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C,2DAA2D;IAC3D,yBAAyB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9C,4DAA4D;IAC5D,0BAA0B,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/C,6DAA6D;IAC7D,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,iGAAiG;IACjG,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;OAGG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD;;;;OAIG;IACH,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B"}
|
package/dist/server/env.d.ts
CHANGED
|
@@ -9,14 +9,16 @@
|
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
11
|
import { z } from 'zod';
|
|
12
|
+
import type { Result } from '@fuzdev/fuz_util/result.ts';
|
|
12
13
|
import { type Keyring } from '../auth/keyring.js';
|
|
13
14
|
/**
|
|
14
15
|
* Base Zod schema for server environment variables.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* Declares only what the spine reads — server config, database, cookie keys,
|
|
18
|
+
* allowed origins and the wildcard opt-in, and the bootstrap token path —
|
|
19
|
+
* matching the Rust spine's `BaseServerEnv`. Anything else (fact storage,
|
|
20
|
+
* X-Accel delivery, public URLs) is the app's own var: extend with
|
|
21
|
+
* app-specific fields via `.extend()`.
|
|
20
22
|
*/
|
|
21
23
|
export declare const BaseServerEnv: z.ZodObject<{
|
|
22
24
|
NODE_ENV: z.ZodEnum<{
|
|
@@ -28,44 +30,46 @@ export declare const BaseServerEnv: z.ZodObject<{
|
|
|
28
30
|
DATABASE_URL: z.ZodString;
|
|
29
31
|
SECRET_FUZ_COOKIE_KEYS: z.ZodString;
|
|
30
32
|
FUZ_ALLOWED_ORIGINS: z.ZodString;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
FUZ_ALLOW_ORIGIN_WILDCARDS: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
true: "true";
|
|
35
|
+
false: "false";
|
|
36
|
+
}>>;
|
|
34
37
|
FUZ_BOOTSTRAP_TOKEN_PATH: z.ZodOptional<z.ZodString>;
|
|
35
|
-
SMTP_HOST: z.ZodOptional<z.ZodString>;
|
|
36
|
-
SMTP_USER: z.ZodOptional<z.ZodString>;
|
|
37
|
-
SMTP_PASSWORD: z.ZodOptional<z.ZodString>;
|
|
38
|
-
FUZ_FACTS_DIR: z.ZodDefault<z.ZodString>;
|
|
39
|
-
FUZ_FACTS_X_ACCEL_REDIRECT_PREFIX: z.ZodOptional<z.ZodString>;
|
|
40
38
|
}, z.core.$strict>;
|
|
41
39
|
export type BaseServerEnv = z.infer<typeof BaseServerEnv>;
|
|
42
40
|
/**
|
|
43
41
|
* Validated server env config — the artifacts `create_app_server()` needs.
|
|
44
42
|
*/
|
|
45
|
-
export interface
|
|
46
|
-
ok: true;
|
|
43
|
+
export interface ValidatedServerEnv {
|
|
47
44
|
keyring: Keyring;
|
|
48
45
|
allowed_origins: Array<RegExp>;
|
|
46
|
+
/**
|
|
47
|
+
* `FUZ_ALLOW_ORIGIN_WILDCARDS=true` — pass to `create_app_server`'s
|
|
48
|
+
* `allow_origin_wildcards`, which refuses a wildcard entry without it.
|
|
49
|
+
*/
|
|
50
|
+
allow_origin_wildcards: boolean;
|
|
49
51
|
bootstrap_token_path: string | null;
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
54
|
* Error from `validate_server_env` — keyring or origin validation failed.
|
|
53
55
|
*/
|
|
54
|
-
export interface
|
|
55
|
-
ok: false;
|
|
56
|
+
export interface ServerEnvValidationError {
|
|
56
57
|
field: 'SECRET_FUZ_COOKIE_KEYS' | 'FUZ_ALLOWED_ORIGINS';
|
|
57
58
|
errors: Array<string>;
|
|
58
59
|
}
|
|
59
|
-
export type ServerEnvOptionsResult = ServerEnvOptions | ServerEnvOptionsError;
|
|
60
60
|
/**
|
|
61
61
|
* Validate a loaded `BaseServerEnv` and produce the artifacts needed for server init.
|
|
62
62
|
*
|
|
63
63
|
* Handles keyring validation, origin parsing (every refused allowlist entry is
|
|
64
|
-
* reported, each on its own line),
|
|
64
|
+
* reported, each on its own line), the wildcard opt-in (a wildcard entry
|
|
65
|
+
* without `FUZ_ALLOW_ORIGIN_WILDCARDS=true` is refused with
|
|
66
|
+
* `admit_origin_wildcards`' text, as `create_app_server` would), and
|
|
67
|
+
* bootstrap token path extraction.
|
|
65
68
|
* Returns a Result so callers handle errors their own way (exit, logging, etc).
|
|
66
69
|
*
|
|
67
70
|
* @param env - a loaded and Zod-validated `BaseServerEnv`
|
|
68
|
-
* @returns `{ok: true, keyring, allowed_origins,
|
|
71
|
+
* @returns `{ok: true, keyring, allowed_origins, allow_origin_wildcards, bootstrap_token_path}`
|
|
72
|
+
* or `{ok: false, field, errors}`
|
|
69
73
|
*/
|
|
70
|
-
export declare const validate_server_env: (env: BaseServerEnv) =>
|
|
74
|
+
export declare const validate_server_env: (env: BaseServerEnv) => Result<ValidatedServerEnv, ServerEnvValidationError>;
|
|
71
75
|
//# sourceMappingURL=env.d.ts.map
|
package/dist/server/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAIlE;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;kBA6BxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,KAAK,EAAE,wBAAwB,GAAG,qBAAqB,CAAC;IACxD,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,GAC/B,KAAK,aAAa,KAChB,MAAM,CAAC,kBAAkB,EAAE,wBAAwB,CA2BrD,CAAC"}
|
package/dist/server/env.js
CHANGED
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { create_keyring } from '../auth/keyring.js';
|
|
13
13
|
import { format_allowed_origins_error, parse_allowed_origins } from '../http/origin.js';
|
|
14
|
+
import { admit_origin_wildcards } from '../http/origin_wildcard.js';
|
|
14
15
|
/**
|
|
15
16
|
* Base Zod schema for server environment variables.
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Declares only what the spine reads — server config, database, cookie keys,
|
|
19
|
+
* allowed origins and the wildcard opt-in, and the bootstrap token path —
|
|
20
|
+
* matching the Rust spine's `BaseServerEnv`. Anything else (fact storage,
|
|
21
|
+
* X-Accel delivery, public URLs) is the app's own var: extend with
|
|
22
|
+
* app-specific fields via `.extend()`.
|
|
21
23
|
*/
|
|
22
24
|
export const BaseServerEnv = z.strictObject({
|
|
23
25
|
NODE_ENV: z.enum(['development', 'production']).meta({ description: 'Runtime environment mode' }),
|
|
@@ -40,47 +42,27 @@ export const BaseServerEnv = z.strictObject({
|
|
|
40
42
|
FUZ_ALLOWED_ORIGINS: z.string().min(1, 'FUZ_ALLOWED_ORIGINS is required').meta({
|
|
41
43
|
description: 'Comma-separated origin patterns for API verification'
|
|
42
44
|
}),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.union([z.email(), z.literal('')])
|
|
47
|
-
.optional()
|
|
48
|
-
.meta({ description: 'Public contact email address' }),
|
|
45
|
+
FUZ_ALLOW_ORIGIN_WILDCARDS: z.enum(['true', 'false']).optional().meta({
|
|
46
|
+
description: 'Exactly `true` lets a wildcard FUZ_ALLOWED_ORIGINS entry (`:*`, a `*` label) boot, warned of on every boot; unset or `false` refuses one'
|
|
47
|
+
}),
|
|
49
48
|
FUZ_BOOTSTRAP_TOKEN_PATH: z
|
|
50
49
|
.string()
|
|
51
50
|
.optional()
|
|
52
|
-
.meta({ description: 'Path to one-shot admin bootstrap token', sensitivity: 'secret' })
|
|
53
|
-
SMTP_HOST: z.string().optional().meta({ description: 'SMTP server hostname' }),
|
|
54
|
-
// SMTP usernames are frequently not emails (SendGrid uses "apikey",
|
|
55
|
-
// AWS SES / Postmark use token-style credentials), so validate as a plain
|
|
56
|
-
// string — `z.email()` here would reject valid provider configs. Marked
|
|
57
|
-
// `secret`: those token-style usernames are credentials (Postmark reuses
|
|
58
|
-
// the server token as both user and password), so the value is masked in
|
|
59
|
-
// the startup summary / logs like `SMTP_PASSWORD`.
|
|
60
|
-
SMTP_USER: z
|
|
61
|
-
.string()
|
|
62
|
-
.optional()
|
|
63
|
-
.meta({ description: 'SMTP authentication username', sensitivity: 'secret' }),
|
|
64
|
-
SMTP_PASSWORD: z
|
|
65
|
-
.string()
|
|
66
|
-
.optional()
|
|
67
|
-
.meta({ description: 'SMTP authentication password', sensitivity: 'secret' }),
|
|
68
|
-
FUZ_FACTS_DIR: z.string().min(1).default('./.facts').meta({
|
|
69
|
-
description: 'Directory for referenced (large) fact bytes, sharded <shard>/<rest>'
|
|
70
|
-
}),
|
|
71
|
-
FUZ_FACTS_X_ACCEL_REDIRECT_PREFIX: z.string().optional().meta({
|
|
72
|
-
description: 'Internal nginx prefix for X-Accel-Redirect fact delivery, ending in `/` (production only)'
|
|
73
|
-
})
|
|
51
|
+
.meta({ description: 'Path to one-shot admin bootstrap token', sensitivity: 'secret' })
|
|
74
52
|
});
|
|
75
53
|
/**
|
|
76
54
|
* Validate a loaded `BaseServerEnv` and produce the artifacts needed for server init.
|
|
77
55
|
*
|
|
78
56
|
* Handles keyring validation, origin parsing (every refused allowlist entry is
|
|
79
|
-
* reported, each on its own line),
|
|
57
|
+
* reported, each on its own line), the wildcard opt-in (a wildcard entry
|
|
58
|
+
* without `FUZ_ALLOW_ORIGIN_WILDCARDS=true` is refused with
|
|
59
|
+
* `admit_origin_wildcards`' text, as `create_app_server` would), and
|
|
60
|
+
* bootstrap token path extraction.
|
|
80
61
|
* Returns a Result so callers handle errors their own way (exit, logging, etc).
|
|
81
62
|
*
|
|
82
63
|
* @param env - a loaded and Zod-validated `BaseServerEnv`
|
|
83
|
-
* @returns `{ok: true, keyring, allowed_origins,
|
|
64
|
+
* @returns `{ok: true, keyring, allowed_origins, allow_origin_wildcards, bootstrap_token_path}`
|
|
65
|
+
* or `{ok: false, field, errors}`
|
|
84
66
|
*/
|
|
85
67
|
export const validate_server_env = (env) => {
|
|
86
68
|
const keyring_result = create_keyring(env.SECRET_FUZ_COOKIE_KEYS);
|
|
@@ -95,10 +77,18 @@ export const validate_server_env = (env) => {
|
|
|
95
77
|
errors: origins_result.errors.map(format_allowed_origins_error)
|
|
96
78
|
};
|
|
97
79
|
}
|
|
80
|
+
// refused here too, so an env-driven server fails before its backend
|
|
81
|
+
// touches the DB (`create_app_server` repeats the check for direct callers)
|
|
82
|
+
const allow_origin_wildcards = env.FUZ_ALLOW_ORIGIN_WILDCARDS === 'true';
|
|
83
|
+
const wildcards = admit_origin_wildcards(origins_result.origins, allow_origin_wildcards);
|
|
84
|
+
if (!wildcards.ok) {
|
|
85
|
+
return { ok: false, field: 'FUZ_ALLOWED_ORIGINS', errors: [wildcards.message] };
|
|
86
|
+
}
|
|
98
87
|
return {
|
|
99
88
|
ok: true,
|
|
100
89
|
keyring: keyring_result.keyring,
|
|
101
90
|
allowed_origins: origins_result.origins,
|
|
91
|
+
allow_origin_wildcards,
|
|
102
92
|
bootstrap_token_path: env.FUZ_BOOTSTRAP_TOKEN_PATH ?? null
|
|
103
93
|
};
|
|
104
94
|
};
|
|
@@ -86,7 +86,10 @@
|
|
|
86
86
|
* 404 is the universal "not viewable" response: missing fact, missing or
|
|
87
87
|
* unviewable cell, or the cell doesn't reference the hash. We deliberately
|
|
88
88
|
* don't distinguish 403 from 404 — neither the existence of a fact nor the
|
|
89
|
-
* existence of a cell→fact edge should leak through the public surface.
|
|
89
|
+
* existence of a cell→fact edge should leak through the public surface. The
|
|
90
|
+
* view check runs before the edge check, so an unviewable cell does the same
|
|
91
|
+
* work whether or not it references the hash — its refs don't leak through
|
|
92
|
+
* response timing either.
|
|
90
93
|
*
|
|
91
94
|
* A ref is a `data` string value that is exactly a fact hash
|
|
92
95
|
* (`derive_cell_refs`) — a hash inside prose or markup is not one. So a doc
|
|
@@ -129,17 +132,8 @@
|
|
|
129
132
|
*/
|
|
130
133
|
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
131
134
|
import { type RouteSpec } from '../http/route_spec.js';
|
|
132
|
-
import type { AppDeps } from '../auth/deps.js';
|
|
133
135
|
import type { XAccelConfig } from './x_accel.js';
|
|
134
136
|
export interface CreateServeFactRouteSpecOptions {
|
|
135
|
-
/**
|
|
136
|
-
* App deps reference. Currently unused at handler time (cell + fact
|
|
137
|
-
* tables are read via `RouteContext.db`); kept on the factory
|
|
138
|
-
* signature for symmetry with sibling route factories and to give
|
|
139
|
-
* future role_grant-scoped viewer extensions somewhere to read other
|
|
140
|
-
* deps without changing the public shape.
|
|
141
|
-
*/
|
|
142
|
-
deps: AppDeps;
|
|
143
137
|
/** Absolute path of the facts directory. Used for the dev/test streaming path. */
|
|
144
138
|
facts_dir: string;
|
|
145
139
|
/**
|
|
@@ -159,9 +153,11 @@ export interface CreateServeFactRouteSpecOptions {
|
|
|
159
153
|
*
|
|
160
154
|
* Resolves the named cell (404 if missing / soft-deleted), requires
|
|
161
155
|
* `can_view_cell(caller, cell)` — or the steward arm,
|
|
162
|
-
* `cell_steward_admits` —
|
|
163
|
-
* (else 404, masked), then serves the bytes.
|
|
164
|
-
*
|
|
156
|
+
* `cell_steward_admits` — and then `cell.refs` to include the hash
|
|
157
|
+
* (else 404, masked), then serves the bytes. The view check runs first, so a
|
|
158
|
+
* caller that can't view the cell learns nothing about its refs. Authz is
|
|
159
|
+
* scoped to this one `(cell, hash)` edge — never unioned across the fact's
|
|
160
|
+
* other referrers.
|
|
165
161
|
*
|
|
166
162
|
* Pure-public auth — the handler builds the per-request `RequestContext`
|
|
167
163
|
* from the resolved account id (`get_public_account_id`) and enforces
|
|
@@ -182,9 +178,9 @@ export declare const create_serve_cell_fact_route_spec: (options: CreateServeFac
|
|
|
182
178
|
* post-authorization guard enforces the admin role before the handler runs.
|
|
183
179
|
* The handler re-checks the **global** admin grant
|
|
184
180
|
* (`has_scoped_role(_, admin, null)`, the auth phase's own reading) as
|
|
185
|
-
* defense-in-depth so a future
|
|
186
|
-
*
|
|
187
|
-
*
|
|
181
|
+
* defense-in-depth so a future mounting/auth-shape regression fails closed —
|
|
182
|
+
* a masked 404, logged at error — rather than serving by bare hash to a
|
|
183
|
+
* non-admin.
|
|
188
184
|
*/
|
|
189
185
|
export declare const create_serve_fact_route_spec: (options: CreateServeFactRouteSpecOptions) => RouteSpec;
|
|
190
186
|
//# sourceMappingURL=serve_fact_route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve_fact_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/serve_fact_route.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"serve_fact_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/serve_fact_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmIG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAetD,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAS5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAoCjD,MAAM,WAAW,+BAA+B;IAC/C,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACZ;AAkJD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iCAAiC,GAC7C,SAAS,+BAA+B,KACtC,SA0DF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,SA+CF,CAAC"}
|