@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
|
@@ -1,39 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Write updates to `.env` files while preserving formatting.
|
|
3
3
|
*
|
|
4
|
+
* `update_env_content` is the one env-file writer: a pure line rebuild that
|
|
5
|
+
* `update_env_variable` (read, update, write) and `dev/setup.ts`'s
|
|
6
|
+
* `setup_env_file` both build on, so every value lands quoted and escaped the
|
|
7
|
+
* same way and round-trips through `parse_dotenv`.
|
|
8
|
+
*
|
|
4
9
|
* @module
|
|
5
10
|
*/
|
|
11
|
+
import type { FsReadDeps, FsRemoveDeps, FsWriteDeps } from '../runtime/deps.js';
|
|
6
12
|
/**
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export interface UpdateEnvVariableOptions {
|
|
10
|
-
/** Path to the .env file. */
|
|
11
|
-
env_file_path: string;
|
|
12
|
-
/** Function to read file contents (defaults to `node:fs/promises` `readFile`). */
|
|
13
|
-
read_file?: (path: string, encoding: string) => Promise<string>;
|
|
14
|
-
/** Function to write file contents (defaults to `node:fs/promises` `writeFile`). */
|
|
15
|
-
write_file?: (path: string, content: string, encoding: string) => Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Updates or adds an environment variable in the .env file.
|
|
13
|
+
* Set `key` to `value` in dotenv `content`, returning the new content.
|
|
19
14
|
* Preserves existing formatting, comments, and other variables.
|
|
20
15
|
*
|
|
21
16
|
* Behavior:
|
|
22
17
|
* - **Duplicate keys**: updates the LAST occurrence (matches dotenv behavior)
|
|
23
18
|
* - **Inline comments**: preserved after the value (e.g., `KEY=value # comment`)
|
|
24
|
-
* - **Quote style**:
|
|
19
|
+
* - **Quote style**: a quoted value stays quoted; an unquoted one stays bare
|
|
20
|
+
* unless the new value would not read back bare (surrounding whitespace, a
|
|
21
|
+
* `#` comment marker, a leading quote, a line break), which is quoted
|
|
25
22
|
* - **`export ` prefix**: preserved when updating an `export KEY=…` line
|
|
23
|
+
* - **Absent key**: appended as a quoted assignment
|
|
24
|
+
*
|
|
25
|
+
* The line is rebuilt from its parts, so no character of `value` (`$&`, `` $` ``,
|
|
26
|
+
* `$'`, `\`) is interpreted.
|
|
27
|
+
*
|
|
28
|
+
* @param content - dotenv file content (`''` for a new file)
|
|
29
|
+
* @param key - the environment variable name
|
|
30
|
+
* @param value - the new value
|
|
31
|
+
* @returns the updated content
|
|
32
|
+
*/
|
|
33
|
+
export declare const update_env_content: (content: string, key: string, value: string) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Updates or adds an environment variable in an env file — read,
|
|
36
|
+
* `update_env_content`, then an atomic replace at mode `0o600` (an env file
|
|
37
|
+
* holds secrets, so the fresh owner-only inode also tightens a permissive
|
|
38
|
+
* hand-made one). A missing file is created.
|
|
26
39
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* the file. Acceptable for single-user, infrequent edits; revisit if a
|
|
30
|
-
* concurrent-writer consumer emerges.
|
|
40
|
+
* A read-modify-write: a concurrent writer's update can be lost (the last
|
|
41
|
+
* replace wins), though the file is never left half-written.
|
|
31
42
|
*
|
|
43
|
+
* @param deps - file read and write capabilities; pass `remove` too for best-effort temp cleanup on a failed write
|
|
44
|
+
* @param env_path - path to the env file
|
|
32
45
|
* @param key - the environment variable name (e.g., `'SOME_CONFIGURATION_KEY'`)
|
|
33
46
|
* @param value - the new value for the environment variable
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
36
|
-
* @throws Error if the file read fails for any reason other than `ENOENT`, or if the write fails
|
|
47
|
+
* @mutates filesystem - atomically replaces `env_path` at mode `0o600`
|
|
48
|
+
* @throws Error if the read or the write fails
|
|
37
49
|
*/
|
|
38
|
-
export declare const update_env_variable: (
|
|
50
|
+
export declare const update_env_variable: (deps: FsReadDeps & FsWriteDeps & Partial<FsRemoveDeps>, env_path: string, key: string, value: string) => Promise<void>;
|
|
39
51
|
//# sourceMappingURL=update_env_variable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update_env_variable.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/update_env_variable.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"update_env_variable.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/update_env_variable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGhF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,EAAE,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,MAmChF,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,EACtD,UAAU,MAAM,EAChB,KAAK,MAAM,EACX,OAAO,MAAM,KACX,OAAO,CAAC,IAAI,CAId,CAAC"}
|
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Write updates to `.env` files while preserving formatting.
|
|
3
3
|
*
|
|
4
|
+
* `update_env_content` is the one env-file writer: a pure line rebuild that
|
|
5
|
+
* `update_env_variable` (read, update, write) and `dev/setup.ts`'s
|
|
6
|
+
* `setup_env_file` both build on, so every value lands quoted and escaped the
|
|
7
|
+
* same way and round-trips through `parse_dotenv`.
|
|
8
|
+
*
|
|
4
9
|
* @module
|
|
5
10
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { resolve } from 'node:path';
|
|
11
|
+
import { write_file_atomic } from '../runtime/fs.js';
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* Set `key` to `value` in dotenv `content`, returning the new content.
|
|
10
14
|
* Preserves existing formatting, comments, and other variables.
|
|
11
15
|
*
|
|
12
16
|
* Behavior:
|
|
13
17
|
* - **Duplicate keys**: updates the LAST occurrence (matches dotenv behavior)
|
|
14
18
|
* - **Inline comments**: preserved after the value (e.g., `KEY=value # comment`)
|
|
15
|
-
* - **Quote style**:
|
|
19
|
+
* - **Quote style**: a quoted value stays quoted; an unquoted one stays bare
|
|
20
|
+
* unless the new value would not read back bare (surrounding whitespace, a
|
|
21
|
+
* `#` comment marker, a leading quote, a line break), which is quoted
|
|
16
22
|
* - **`export ` prefix**: preserved when updating an `export KEY=…` line
|
|
23
|
+
* - **Absent key**: appended as a quoted assignment
|
|
17
24
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* the file. Acceptable for single-user, infrequent edits; revisit if a
|
|
21
|
-
* concurrent-writer consumer emerges.
|
|
25
|
+
* The line is rebuilt from its parts, so no character of `value` (`$&`, `` $` ``,
|
|
26
|
+
* `$'`, `\`) is interpreted.
|
|
22
27
|
*
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @
|
|
27
|
-
* @throws Error if the file read fails for any reason other than `ENOENT`, or if the write fails
|
|
28
|
+
* @param content - dotenv file content (`''` for a new file)
|
|
29
|
+
* @param key - the environment variable name
|
|
30
|
+
* @param value - the new value
|
|
31
|
+
* @returns the updated content
|
|
28
32
|
*/
|
|
29
|
-
export const
|
|
30
|
-
const { env_file_path, read_file = readFile, write_file = writeFile } = options;
|
|
31
|
-
const file_path = resolve(env_file_path);
|
|
32
|
-
let content = '';
|
|
33
|
-
try {
|
|
34
|
-
content = await read_file(file_path, 'utf-8');
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
if (error?.code !== 'ENOENT') {
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
33
|
+
export const update_env_content = (content, key, value) => {
|
|
41
34
|
// TODO CRLF: split on `/\r?\n/` + remember per-line delimiter (pinned by edge_cases.test.ts)
|
|
42
35
|
// Preserve trailing-newline state: `split('\n')` on `'a\n'` yields `['a', '']`
|
|
43
36
|
// — drop that trailing empty so appends don't insert a blank line. Re-add
|
|
44
37
|
// the trailing `\n` at the end if the original had one.
|
|
38
|
+
if (content === '')
|
|
39
|
+
return `${key}=${quote_value(value)}\n`;
|
|
45
40
|
const has_trailing_newline = content.endsWith('\n');
|
|
46
41
|
const lines = content.split('\n');
|
|
47
42
|
if (has_trailing_newline)
|
|
@@ -57,22 +52,36 @@ export const update_env_variable = async (key, value, options) => {
|
|
|
57
52
|
const value_part = line.substring(equals_pos + 1);
|
|
58
53
|
const inline_comment = extract_inline_comment(value_part);
|
|
59
54
|
const trimmed_value = value_part.trim();
|
|
60
|
-
const
|
|
61
|
-
return
|
|
62
|
-
? `${export_prefix}${key}=${quote_value(value)}${inline_comment}`
|
|
63
|
-
: `${export_prefix}${key}=${value}${inline_comment}`;
|
|
55
|
+
const written = is_quoted_value(trimmed_value) || !reads_back_bare(value) ? quote_value(value) : value;
|
|
56
|
+
return `${export_prefix}${key}=${written}${inline_comment}`;
|
|
64
57
|
}
|
|
65
58
|
return line;
|
|
66
59
|
});
|
|
67
60
|
if (last_match_idx === -1) {
|
|
68
|
-
if (content === '') {
|
|
69
|
-
await write_file(file_path, `${key}=${quote_value(value)}\n`, 'utf-8');
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
61
|
updated_lines.push(`${key}=${quote_value(value)}`);
|
|
73
62
|
}
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
return updated_lines.join('\n') + (has_trailing_newline ? '\n' : '');
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Updates or adds an environment variable in an env file — read,
|
|
67
|
+
* `update_env_content`, then an atomic replace at mode `0o600` (an env file
|
|
68
|
+
* holds secrets, so the fresh owner-only inode also tightens a permissive
|
|
69
|
+
* hand-made one). A missing file is created.
|
|
70
|
+
*
|
|
71
|
+
* A read-modify-write: a concurrent writer's update can be lost (the last
|
|
72
|
+
* replace wins), though the file is never left half-written.
|
|
73
|
+
*
|
|
74
|
+
* @param deps - file read and write capabilities; pass `remove` too for best-effort temp cleanup on a failed write
|
|
75
|
+
* @param env_path - path to the env file
|
|
76
|
+
* @param key - the environment variable name (e.g., `'SOME_CONFIGURATION_KEY'`)
|
|
77
|
+
* @param value - the new value for the environment variable
|
|
78
|
+
* @mutates filesystem - atomically replaces `env_path` at mode `0o600`
|
|
79
|
+
* @throws Error if the read or the write fails
|
|
80
|
+
*/
|
|
81
|
+
export const update_env_variable = async (deps, env_path, key, value) => {
|
|
82
|
+
const stat = await deps.stat(env_path);
|
|
83
|
+
const content = stat ? await deps.read_text_file(env_path) : '';
|
|
84
|
+
await write_file_atomic(deps, env_path, update_env_content(content, key, value), { mode: 0o600 });
|
|
76
85
|
};
|
|
77
86
|
// Keep this tokenization aligned with `parse_dotenv` in `env/dotenv.ts`:
|
|
78
87
|
// trim, skip empties/comments, strip a leading `export `, split on the first `=`.
|
|
@@ -160,6 +169,16 @@ const quote_value = (value) => {
|
|
|
160
169
|
return `"${escape_for_double_quoted(value)}"`;
|
|
161
170
|
};
|
|
162
171
|
const has_newline_chars = (value) => value.includes('\n') || value.includes('\r');
|
|
172
|
+
/**
|
|
173
|
+
* Whether `value`, written unquoted, reads back unchanged through
|
|
174
|
+
* `parse_dotenv` — no surrounding whitespace, no leading quote or `#`, no
|
|
175
|
+
* whitespace-then-`#` comment marker, no line break.
|
|
176
|
+
*/
|
|
177
|
+
const reads_back_bare = (value) => value === value.trim() &&
|
|
178
|
+
!has_newline_chars(value) &&
|
|
179
|
+
!is_quoted_value(value) &&
|
|
180
|
+
!value.startsWith('#') &&
|
|
181
|
+
!/\s#/.test(value);
|
|
163
182
|
/**
|
|
164
183
|
* Order matters: backslashes must be escaped first so the introduced
|
|
165
184
|
* backslashes from later replacements aren't re-escaped.
|
package/dist/hono_context.d.ts
CHANGED
|
@@ -5,75 +5,28 @@
|
|
|
5
5
|
* variables used by auth, http, server, and testing modules.
|
|
6
6
|
*
|
|
7
7
|
* Auto-loaded by `server/app_server.ts` (side-effect import) and
|
|
8
|
-
* transitively by auth middleware modules that import `
|
|
8
|
+
* transitively by auth middleware modules that import `RESOLVED_AUTH_KEY`.
|
|
9
9
|
* Consumers don't need a manual import unless bypassing the standard server assembly.
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
|
-
import { z } from 'zod';
|
|
14
|
-
import type { TokenScope } from './auth/token_scope.js';
|
|
15
13
|
import type { RequestContext } from './auth/request_context.js';
|
|
14
|
+
import type { ResolvedAuth } from './auth/resolved_auth.js';
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* registry time by `create_role_schema` for `RoleSpec.required_credential_types`
|
|
21
|
-
* validation; the wire-validated `CredentialType` enum here stays
|
|
22
|
-
* narrow because middleware only ever sets one of the three builtins.
|
|
23
|
-
*/
|
|
24
|
-
export declare const CREDENTIAL_TYPES: readonly ["session", "api_token", "daemon_token"];
|
|
25
|
-
/** Credential type — how a request was authenticated. */
|
|
26
|
-
export declare const CredentialType: z.ZodEnum<{
|
|
27
|
-
daemon_token: "daemon_token";
|
|
28
|
-
session: "session";
|
|
29
|
-
api_token: "api_token";
|
|
30
|
-
}>;
|
|
31
|
-
export type CredentialType = z.infer<typeof CredentialType>;
|
|
32
|
-
/** Hono context variable name for the credential type. */
|
|
33
|
-
export declare const CREDENTIAL_TYPE_KEY = "credential_type";
|
|
34
|
-
/** Hono context variable name for the authenticated API token id. */
|
|
35
|
-
export declare const AUTH_API_TOKEN_ID_KEY = "auth_api_token_id";
|
|
36
|
-
/**
|
|
37
|
-
* Hono context variable name for the credential's `TokenScope`.
|
|
38
|
-
*
|
|
39
|
-
* Set by every auth middleware that resolves a credential — bearer reads it
|
|
40
|
-
* from the token row; session and daemon-token set `full`, because a browser
|
|
41
|
-
* session *is* full account authority (narrowing it is what role grants are
|
|
42
|
-
* for) and the daemon token is singular, filesystem-proved, and keeper-bound.
|
|
43
|
-
*
|
|
44
|
-
* Unset only for the anonymous caller, who holds no credential to narrow.
|
|
45
|
-
* Downstream must not read an unset value as permissive for an *authenticated*
|
|
46
|
-
* caller — that absent case is exactly the permissive default this design
|
|
47
|
-
* removes.
|
|
48
|
-
*/
|
|
49
|
-
export declare const TOKEN_SCOPE_KEY = "token_scope";
|
|
50
|
-
/**
|
|
51
|
-
* Hono context variable name for the authenticated account id.
|
|
16
|
+
* Hono context variable name for the request's resolved credential
|
|
17
|
+
* (`ResolvedAuth`) — the one value every auth middleware leg writes, read
|
|
18
|
+
* through `get_resolved_auth`.
|
|
52
19
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* actor; account-grain auth guards (`require_auth`) and account-grain handlers
|
|
57
|
-
* read it directly.
|
|
20
|
+
* The daemon-token, session, and bearer legs run in that order, and the first
|
|
21
|
+
* that authenticates sets it; the legs after it see it set and skip. Unset
|
|
22
|
+
* (read as `null`) for an unauthenticated request.
|
|
58
23
|
*/
|
|
59
|
-
export declare const
|
|
60
|
-
/**
|
|
61
|
-
* Hono context variable name for the credential's deadline — when it stops
|
|
62
|
-
* authenticating, as a monotonic `performance.now()` timestamp
|
|
63
|
-
* (`auth/credential_deadline.ts`), or `null` for one with no expiry (a daemon
|
|
64
|
-
* token, an eternal API token) and for an unauthenticated request.
|
|
65
|
-
*
|
|
66
|
-
* Set by every auth middleware that resolves a credential: session (the
|
|
67
|
-
* earlier of the signed cookie's expiry and the row's), bearer (the row's),
|
|
68
|
-
* daemon token (`null`). A long-lived connection opened on the credential
|
|
69
|
-
* closes at it (`ResolvedAuth.credential_deadline`).
|
|
70
|
-
*/
|
|
71
|
-
export declare const CREDENTIAL_DEADLINE_KEY = "credential_deadline";
|
|
24
|
+
export declare const RESOLVED_AUTH_KEY = "resolved_auth";
|
|
72
25
|
/**
|
|
73
26
|
* Hono context variable name for the session cookie's signed expiry, in
|
|
74
27
|
* seconds since the Unix epoch — set by the session middleware on a cookie
|
|
75
28
|
* that verified and has not expired, `null` otherwise. The request-context
|
|
76
|
-
* middleware folds it into `
|
|
29
|
+
* middleware folds it into the session's `ResolvedAuth.credential_deadline`.
|
|
77
30
|
*/
|
|
78
31
|
export declare const SESSION_COOKIE_EXPIRES_AT_KEY = "auth_session_cookie_expires_at";
|
|
79
32
|
/**
|
|
@@ -99,45 +52,17 @@ declare module 'hono' {
|
|
|
99
52
|
validated_input: unknown;
|
|
100
53
|
validated_params: unknown;
|
|
101
54
|
validated_query: unknown;
|
|
102
|
-
/** How the request was authenticated (`'session'`, `'api_token'`, or `'daemon_token'`). */
|
|
103
|
-
credential_type: CredentialType | null;
|
|
104
|
-
/**
|
|
105
|
-
* The credential's authority narrowing. Set by every auth middleware that
|
|
106
|
-
* resolves a credential — bearer reads it off the token row; session and
|
|
107
|
-
* daemon-token set `full`. Absent only for the anonymous caller, who holds
|
|
108
|
-
* no credential to narrow; downstream must not read absent as permissive
|
|
109
|
-
* for an authenticated one.
|
|
110
|
-
*/
|
|
111
|
-
token_scope: TokenScope | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* Authenticated account id. Set by the session / bearer / daemon-token
|
|
114
|
-
* middleware on a valid credential; `null` for unauthenticated requests.
|
|
115
|
-
* The dispatcher's authorization phase resolves the acting actor against
|
|
116
|
-
* this id; `require_auth` 401s when it is `null`.
|
|
117
|
-
*/
|
|
118
|
-
auth_account_id: string | null;
|
|
119
|
-
/**
|
|
120
|
-
* blake3 hash of the authenticated session token, or `null` for non-session
|
|
121
|
-
* credentials. Set by `create_request_context_middleware`. Used to scope
|
|
122
|
-
* per-session resources (e.g., SSE stream identity for `session_revoke`
|
|
123
|
-
* disconnection) without re-hashing the cookie in every handler.
|
|
124
|
-
*/
|
|
125
|
-
auth_session_token_hash: string | null;
|
|
126
55
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* `
|
|
130
|
-
* (e.g., WS connection revocation on `token_revoke`) without re-looking
|
|
131
|
-
* up the token.
|
|
56
|
+
* The credential the auth middleware resolved (`RESOLVED_AUTH_KEY`);
|
|
57
|
+
* `null` or unset for an unauthenticated request. Read it with
|
|
58
|
+
* `get_resolved_auth`.
|
|
132
59
|
*/
|
|
133
|
-
|
|
134
|
-
/** The credential's deadline (`CREDENTIAL_DEADLINE_KEY`). */
|
|
135
|
-
credential_deadline: number | null;
|
|
60
|
+
resolved_auth: ResolvedAuth | null;
|
|
136
61
|
/** The session cookie's signed expiry, epoch seconds (`SESSION_COOKIE_EXPIRES_AT_KEY`). */
|
|
137
62
|
auth_session_cookie_expires_at: number | null;
|
|
138
63
|
/**
|
|
139
64
|
* Eager fire-and-forget pool writes for this request — audit emits,
|
|
140
|
-
*
|
|
65
|
+
* api-token usage tracking. Producers push the
|
|
141
66
|
* in-flight `Promise<void>` directly. The flush middleware drains via
|
|
142
67
|
* `flush_pending_effects` after the handler returns. Initialized by
|
|
143
68
|
* `create_app_server`. In test mode (`await_pending_effects: true`),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono_context.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"hono_context.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,mCAAmC,CAAC;AAE9E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D,OAAO,QAAQ,MAAM,CAAC;IACrB,UAAU,kBAAkB;QAC3B,+DAA+D;QAC/D,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;QACvC,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,OAAO,CAAC;QACzB;;;;WAIG;QACH,aAAa,EAAE,YAAY,GAAG,IAAI,CAAC;QACnC,2FAA2F;QAC3F,8BAA8B,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9C;;;;;;;WAOG;QACH,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC;;;;;;;;;;;;WAYG;QACH,mBAAmB,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD;;;;WAIG;QACH,mBAAmB,EAAE,OAAO,CAAC;KAC7B;CACD"}
|
package/dist/hono_context.js
CHANGED
|
@@ -5,73 +5,26 @@
|
|
|
5
5
|
* variables used by auth, http, server, and testing modules.
|
|
6
6
|
*
|
|
7
7
|
* Auto-loaded by `server/app_server.ts` (side-effect import) and
|
|
8
|
-
* transitively by auth middleware modules that import `
|
|
8
|
+
* transitively by auth middleware modules that import `RESOLVED_AUTH_KEY`.
|
|
9
9
|
* Consumers don't need a manual import unless bypassing the standard server assembly.
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
|
-
import { z } from 'zod';
|
|
14
|
-
import { CREDENTIAL_TYPE_API_TOKEN, CREDENTIAL_TYPE_DAEMON_TOKEN, CREDENTIAL_TYPE_SESSION } from './auth/credential_type_schema.js';
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* registry time by `create_role_schema` for `RoleSpec.required_credential_types`
|
|
20
|
-
* validation; the wire-validated `CredentialType` enum here stays
|
|
21
|
-
* narrow because middleware only ever sets one of the three builtins.
|
|
22
|
-
*/
|
|
23
|
-
export const CREDENTIAL_TYPES = [
|
|
24
|
-
CREDENTIAL_TYPE_SESSION,
|
|
25
|
-
CREDENTIAL_TYPE_API_TOKEN,
|
|
26
|
-
CREDENTIAL_TYPE_DAEMON_TOKEN
|
|
27
|
-
];
|
|
28
|
-
/** Credential type — how a request was authenticated. */
|
|
29
|
-
export const CredentialType = z.enum(CREDENTIAL_TYPES);
|
|
30
|
-
/** Hono context variable name for the credential type. */
|
|
31
|
-
export const CREDENTIAL_TYPE_KEY = 'credential_type';
|
|
32
|
-
/** Hono context variable name for the authenticated API token id. */
|
|
33
|
-
export const AUTH_API_TOKEN_ID_KEY = 'auth_api_token_id';
|
|
34
|
-
/**
|
|
35
|
-
* Hono context variable name for the credential's `TokenScope`.
|
|
36
|
-
*
|
|
37
|
-
* Set by every auth middleware that resolves a credential — bearer reads it
|
|
38
|
-
* from the token row; session and daemon-token set `full`, because a browser
|
|
39
|
-
* session *is* full account authority (narrowing it is what role grants are
|
|
40
|
-
* for) and the daemon token is singular, filesystem-proved, and keeper-bound.
|
|
41
|
-
*
|
|
42
|
-
* Unset only for the anonymous caller, who holds no credential to narrow.
|
|
43
|
-
* Downstream must not read an unset value as permissive for an *authenticated*
|
|
44
|
-
* caller — that absent case is exactly the permissive default this design
|
|
45
|
-
* removes.
|
|
46
|
-
*/
|
|
47
|
-
export const TOKEN_SCOPE_KEY = 'token_scope';
|
|
48
|
-
/**
|
|
49
|
-
* Hono context variable name for the authenticated account id.
|
|
50
|
-
*
|
|
51
|
-
* Set by the auth middleware (session, bearer, or daemon token) on a valid
|
|
52
|
-
* credential. `null` for unauthenticated requests. The route-spec wrapper /
|
|
53
|
-
* RPC dispatcher's authorization phase reads this when resolving the acting
|
|
54
|
-
* actor; account-grain auth guards (`require_auth`) and account-grain handlers
|
|
55
|
-
* read it directly.
|
|
56
|
-
*/
|
|
57
|
-
export const ACCOUNT_ID_KEY = 'auth_account_id';
|
|
58
|
-
/**
|
|
59
|
-
* Hono context variable name for the credential's deadline — when it stops
|
|
60
|
-
* authenticating, as a monotonic `performance.now()` timestamp
|
|
61
|
-
* (`auth/credential_deadline.ts`), or `null` for one with no expiry (a daemon
|
|
62
|
-
* token, an eternal API token) and for an unauthenticated request.
|
|
14
|
+
* Hono context variable name for the request's resolved credential
|
|
15
|
+
* (`ResolvedAuth`) — the one value every auth middleware leg writes, read
|
|
16
|
+
* through `get_resolved_auth`.
|
|
63
17
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* closes at it (`ResolvedAuth.credential_deadline`).
|
|
18
|
+
* The daemon-token, session, and bearer legs run in that order, and the first
|
|
19
|
+
* that authenticates sets it; the legs after it see it set and skip. Unset
|
|
20
|
+
* (read as `null`) for an unauthenticated request.
|
|
68
21
|
*/
|
|
69
|
-
export const
|
|
22
|
+
export const RESOLVED_AUTH_KEY = 'resolved_auth';
|
|
70
23
|
/**
|
|
71
24
|
* Hono context variable name for the session cookie's signed expiry, in
|
|
72
25
|
* seconds since the Unix epoch — set by the session middleware on a cookie
|
|
73
26
|
* that verified and has not expired, `null` otherwise. The request-context
|
|
74
|
-
* middleware folds it into `
|
|
27
|
+
* middleware folds it into the session's `ResolvedAuth.credential_deadline`.
|
|
75
28
|
*/
|
|
76
29
|
export const SESSION_COOKIE_EXPIRES_AT_KEY = 'auth_session_cookie_expires_at';
|
|
77
30
|
/**
|
package/dist/http/CLAUDE.md
CHANGED
|
@@ -28,10 +28,11 @@ effects, see ../../../docs/architecture.md.
|
|
|
28
28
|
- `http/origin.ts` — origin allowlist: the strict pattern grammar shared with the Rust spine, typed refusals, and the Origin-only middleware.
|
|
29
29
|
- `http/jsonrpc.ts` — JSON-RPC 2.0 envelope schemas (MCP superset), `JsonrpcErrorCode`, `_meta`.
|
|
30
30
|
- `http/jsonrpc_errors.ts` — `ThrownJsonrpcError`, `jsonrpc_errors` throwers, HTTP-status mappings.
|
|
31
|
-
- `http/jsonrpc_helpers.ts` — message builders, type guards, input/result normalizers.
|
|
31
|
+
- `http/jsonrpc_helpers.ts` — message builders, type guards, input/result normalizers, and `classify_jsonrpc_message`, the one envelope classifier both transports run.
|
|
32
|
+
- `http/health_schema.ts` — `HEALTH_PATH` + the `HealthResponse` schema, browser-safe, shared by the health route spec and the client probe (`ui/backend_probe.svelte.ts`).
|
|
32
33
|
- `http/common_routes.ts` — health check + readiness probe (`/ready` schema-drift deploy gate) + authenticated server-status route specs (the surface explorer route lives in `server/surface_route.ts`).
|
|
33
34
|
- `http/db_routes.ts` — allowlist-gated keeper-only table browser route specs (`public` schema, minus the `NON_BROWSABLE_TABLES` credential floor).
|
|
34
|
-
- `http/pending_effects.ts` — `emit_after_commit` + `dispatch_with_post_commit_rollback` (the shared rollback-discard wrapper both dispatch sites use) + `flush_pending_effects` + `flush_post_commit_effects` + `EmitAfterCommitContext`.
|
|
35
|
+
- `http/pending_effects.ts` — `emit_after_commit` + `dispatch_with_post_commit_rollback` (the shared rollback-discard wrapper both dispatch sites use) + `flush_request_effects` (the one two-queue flush HTTP and WS share, over `flush_pending_effects` + `flush_post_commit_effects`) + `EffectErrorContext` + `EmitAfterCommitContext`.
|
|
35
36
|
|
|
36
37
|
## Route Spec System
|
|
37
38
|
|
|
@@ -44,7 +45,7 @@ consumers.
|
|
|
44
45
|
|
|
45
46
|
- `method` — `'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'`
|
|
46
47
|
- `path` — Hono path (supports `:param` segments)
|
|
47
|
-
- `auth: RouteAuth` — flat record `{account, actor, roles?, credential_types?, required_scope?}` from `http/auth_shape.ts`. `account` / `actor` are `'none' | 'optional' | 'required'`. `required_scope` names the capability a narrowed api token's scope must admit — `surface:<name
|
|
48
|
+
- `auth: RouteAuth` — flat record `{account, actor, roles?, credential_types?, required_scope?}` from `http/auth_shape.ts`. `account` / `actor` are `'none' | 'optional' | 'required'`. `required_scope` names the capability a narrowed api token's scope must admit — `surface:<name>`, a non-RPC surface refused to every narrowed token (an `rpc:<method>` capability throws at registration: it is the dispatcher's per-method gate, which a route never reaches) — and is route-spec-only: `compile_action_registry` rejects it on an `ActionSpec`, where the dispatcher derives `rpc:<method>` from `spec.method`. Otherwise the same shape governs `ActionSpec.auth` (see `actions/CLAUDE.md`).
|
|
48
49
|
- `handler: RouteHandler` — `(c: Context, route: RouteContext) => Response | Promise<Response>`
|
|
49
50
|
- `description` — free-text, surfaced in `AppSurface`
|
|
50
51
|
- `params?: z.ZodObject` — strict-object schema for URL path params
|
|
@@ -101,12 +102,12 @@ wrapper). See `auth/signup_routes.ts`.
|
|
|
101
102
|
1. **Params validation** — `spec.params` → `validated_params` context var; mismatch returns 400 `ERROR_INVALID_ROUTE_PARAMS` with Zod `issues`
|
|
102
103
|
2. **Query validation** — `spec.query` → `validated_query`; mismatch returns 400 `ERROR_INVALID_QUERY_PARAMS`
|
|
103
104
|
3. **Pre-authorization auth guards** — every gate that reads only what the auth middleware set, in coarse-to-fine order: `require_auth` (401 `ERROR_AUTHENTICATION_REQUIRED`) when `auth.account === 'required'` or `auth.actor === 'required'`; `require_credential_types(types)` (403 `ERROR_CREDENTIAL_TYPE_REQUIRED` with `required_credential_types: ReadonlyArray<string>`) when `auth.credential_types?.length`; `require_token_scope(capability)` (403 `ERROR_TOKEN_SCOPE_REQUIRED` with `required_scope`, the token-scope refusal) when `auth.required_scope` names a capability. All fire before any body parsing — so a caller they refuse never sees route-shape information from input parse failures — and before actor resolution, so a wrong channel costs no DB work and never learns account state (e.g. that the account is multi-actor). The `AuthGuardResolver` (e.g. `fuz_auth_guard_resolver` from `auth/auth_guard_resolver.ts`) returns this set as `pre_authorization: Array<MiddlewareHandler>`.
|
|
104
|
-
4. **Authorization phase** — when `spec.auth.actor !== 'none'`, resolves the acting actor against `
|
|
105
|
+
4. **Authorization phase** — when `spec.auth.actor !== 'none'`, resolves the acting actor against the resolved credential's account (`get_resolved_auth`, set by the auth middleware) plus the `acting` selector (`validated_query.acting` on GETs; read off the raw body on mutations, since body validation now runs after the gates), builds `RequestContext` via `build_request_context`, and sets `REQUEST_CONTEXT_KEY`. When `auth.account !== 'none' && auth.actor === 'none'`, an account-only context is built. Resolution failures return 400 `ERROR_ACTOR_REQUIRED` (with `available[]`) or `ERROR_ACTOR_NOT_ON_ACCOUNT` (or 500 `ERROR_NO_ACTORS_ON_ACCOUNT` on signup-invariant violation, 500 `ERROR_ACCOUNT_VANISHED` on torn account/actor reads after a successful resolve). Public routes (`account: 'none' && actor: 'none'`) skip this phase entirely.
|
|
105
106
|
5. **Post-authorization auth guards** — `require_role(roles)` (403 `ERROR_INSUFFICIENT_PERMISSIONS` with `required_roles: ReadonlyArray<string>`) when `auth.roles?.length`. The only gate in this phase, because it is the only one that reads `REQUEST_CONTEXT_KEY` (populated by step 4) rather than the auth middleware's own context vars. Multi-role specs admit any-of via `has_any_scoped_role(ctx, roles, null)`.
|
|
106
107
|
6. **Input validation** — JSON body parsed + validated; mismatch returns 400 `ERROR_INVALID_JSON_BODY` (not JSON) or `ERROR_INVALID_REQUEST_BODY` (schema failure with `issues`). Skipped on GET and `z.null()` inputs. The validated input lands on `c.var.validated_input`.
|
|
107
108
|
7. **Handler** — wrapped in transaction when `use_transaction` (see above), receives `RouteContext`
|
|
108
|
-
8. **
|
|
109
|
-
9. **
|
|
109
|
+
8. **Error catch** — catches a thrown JSON-RPC error (`ThrownJsonrpcError`, recognized by brand through `to_thrown_jsonrpc_error`, so one from a second fuz_app copy maps too; a foreign error class carrying a JSON-RPC `code` falls to the generic path) → maps to HTTP status + the flat REST `ApiError` body (`{error: <reason>, message?, ...rest_data}`); catches generic `Error` → 500 `{error: 'internal_error', message?}` (message only in DEV). The reason string comes from `err.data.reason` when set (consumer-supplied canonical reason override) or from `jsonrpc_error_code_to_name(err.code)` (e.g. `-32003 → 'not_found'`). The flat shape matches what middleware and direct handlers emit — REST callers see one envelope across every emit site, while the JSON-RPC dispatcher keeps its own `{jsonrpc, id, error: {code, message, data}}` envelope on the RPC mount.
|
|
110
|
+
9. **DEV-only output + error validation** — wraps the error catch (see below), so a body built from a thrown error is validated like a returned one
|
|
110
111
|
|
|
111
112
|
**Ordering: 401 → authz → 403 → 400 → handler.** Mirrors the RPC dispatcher
|
|
112
113
|
(`actions/action_rpc.ts`) so HTTP RPC and REST fail with the same priority, and
|
|
@@ -137,7 +138,8 @@ are the contract with external callers.
|
|
|
137
138
|
|
|
138
139
|
- Skips streaming responses (non-`application/json` Content-Type) so SSE doesn't hang on `.json()`
|
|
139
140
|
- On 2xx JSON: validates body against `spec.output`
|
|
140
|
-
- On non-2xx JSON: validates body against the merged error schema for that HTTP status
|
|
141
|
+
- On non-2xx JSON: validates body against the merged error schema for that HTTP status — returned or built by the error catch from a thrown error
|
|
142
|
+
- Always accepts a 500 `{error: 'internal_error'}`: the error catch answers it for any generic throw, so no route declares it
|
|
141
143
|
- **Logs on mismatch, returns the response unchanged** — never throws, never mutates the body
|
|
142
144
|
|
|
143
145
|
Production short-circuits to the unwrapped handler — no parse work on the
|
|
@@ -273,15 +275,14 @@ the source specs, for tests that need to iterate over raw specs.
|
|
|
273
275
|
No side effects, no state — filters and groupings over `AppSurface`:
|
|
274
276
|
|
|
275
277
|
- `filter_protected_routes` / `filter_public_routes`
|
|
276
|
-
- `filter_role_routes` / `
|
|
277
|
-
- `
|
|
278
|
-
- `routes_by_auth_type(surface)` — `Map<RouteAuthCategory, Array<AppSurfaceRoute>>` where `RouteAuthCategory = 'none' | 'authenticated' | 'optional' | 'keeper' | 'role:<name>' | 'credential:<type>' | 'other'`. Multi-role / multi-channel specs appear under each bucket. Keeper is tested before the role bucket and the general credential bucket after it — keeper is an authority _level_ and names the route, a session gate is a _channel_ restriction over the authority the route already declares (so the audit SSE stream buckets as `role:admin`)
|
|
278
|
+
- `filter_role_routes` / `filter_keeper_routes` / `filter_credential_gated_routes` (any `auth.credential_types` gate — superset of keeper)
|
|
279
|
+
- `filter_routes_with_input` / `filter_routes_with_params` / `filter_routes_with_query`
|
|
279
280
|
- `format_route_key(route)` → `'METHOD /path'`
|
|
280
|
-
- `surface_auth_summary(surface)` — counts per auth
|
|
281
|
+
- `surface_auth_summary(surface)` — counts per auth bucket (`none`, `keeper`, `role`, `credential`, `authenticated`, `optional`, `other`), roles and credential channels broken out by name; multi-role / multi-channel specs count once per name. One private categorizer decides the bucket: keeper is tested before the role bucket and the general credential bucket after it — keeper is an authority _level_ and names the route, a session gate is a _channel_ restriction over the authority the route already declares (so the audit SSE stream counts under `role`)
|
|
281
282
|
|
|
282
283
|
The per-route auth predicates these filters compose over (`is_public_auth`,
|
|
283
284
|
`is_role_auth`, `is_credential_gated_auth`, `is_keeper_auth`,
|
|
284
|
-
`is_plain_authenticated_auth`, plus `needs_actor`
|
|
285
|
+
`is_plain_authenticated_auth`, plus `needs_actor`) live
|
|
285
286
|
in `http/auth_shape.ts` next to the canonical `RouteAuth` schema — import
|
|
286
287
|
them from there, not from this module. Same predicates back the
|
|
287
288
|
dispatcher's authorization phase, the route-spec auth-guard resolver,
|
|
@@ -364,6 +365,17 @@ whitespace and written as a browser writes an `Origin` — exact
|
|
|
364
365
|
position — matches `api.fuz.dev`, NOT `fuz.dev` or `a.b.fuz.dev`); several
|
|
365
366
|
`https://*.*.corp.fuz.dev`; port wildcard `http://localhost:*` (any port or
|
|
366
367
|
none); IPv6 `http://[::1]:3000` (exact, no wildcard inside the brackets).
|
|
368
|
+
A wildcard entry boots only with `FUZ_ALLOW_ORIGIN_WILDCARDS=true`:
|
|
369
|
+
`origin_wildcard.ts` classifies each parsed entry (`origin_wildcard_kind` —
|
|
370
|
+
port, host with some or no label fixed, or both — from the `OriginPattern`
|
|
371
|
+
`parse_allowed_origins` returns beside each matcher and brands onto it under
|
|
372
|
+
the realm-global `Symbol.for('@fuzdev/fuz_app/OriginPattern')`, so a second
|
|
373
|
+
fuz_app copy reads it — `origin_pattern_of`), renders what it admits
|
|
374
|
+
(`origin_wildcard_warning`, the Rust `fuz_http::origin_wildcard_warning` text
|
|
375
|
+
word for word), and `admit_origin_wildcards` gives `validate_server_env` and
|
|
376
|
+
`create_app_server` (the server list and each `ws_endpoints` spec's own) the
|
|
377
|
+
refusal or the warnings (`allow_origin_wildcards`). A matcher with no brand —
|
|
378
|
+
hand-built, or copied with `new RegExp` — is refused, flag or not.
|
|
367
379
|
**Nothing is normalized** — the matcher is built from the entry as written, so
|
|
368
380
|
an entry a browser would never send is refused rather than rewritten: non-ASCII
|
|
369
381
|
(punycode an IDN host), a scheme other than http/https (`null`, `file://`,
|
|
@@ -440,15 +452,18 @@ which holds a declaration to the same rules.
|
|
|
440
452
|
- `jsonrpc_error_messages` — named constructors returning `JsonrpcErrorObject`
|
|
441
453
|
- `jsonrpc_errors` — named constructors returning `ThrownJsonrpcError` (derived from `jsonrpc_error_messages` via `create_error_thrower`). Usage: `throw jsonrpc_errors.not_found('user')`, `throw jsonrpc_errors.forbidden()`
|
|
442
454
|
- `ThrownJsonrpcError` — `Error` subclass carrying `code` + optional `data`
|
|
455
|
+
- `to_thrown_jsonrpc_error(err)` — the one thrown → wire conversion: the `JsonrpcErrorObject` a `ThrownJsonrpcError` carries, recognized by a realm-global `Symbol.for` brand on its prototype (so one from a second fuz_app copy is read too), when its `code` is a JSON-RPC error code; else `null` — a foreign error class with a JSON-RPC-shaped `code` (another library's RPC error) or a `DOMException` included. Read by the REST catch layer, `perform_action`, `create_jsonrpc_error_response_from_thrown`, the frontend HTTP and WS transports, and `ActionEvent`'s handler-throw normalization, each masking everything else its own way
|
|
443
456
|
- `jsonrpc_error_code_to_http_status` / `http_status_to_jsonrpc_error_code` (fall back to 500 / `internal_error`) — the code → status table is module-private; `HTTP_STATUS_TO_JSONRPC_ERROR_CODE` (frozen) is the reverse over the base set
|
|
444
457
|
- `register_jsonrpc_error_code(code, http_status)` — declares a consumer code's status (see **Consumer codes** above)
|
|
445
458
|
- Envelope schemas in `http/jsonrpc.ts`: `JsonrpcRequest`, `JsonrpcNotification`, `JsonrpcResponse`, `JsonrpcErrorResponse`, `JsonrpcResponseOrError`, `JsonrpcMessage`, `JsonrpcMessageFromClientToServer`, `JsonrpcMessageFromServerToClient`. Also `JsonrpcRequestId`, `JsonrpcMethod`, `JsonrpcProgressToken`, `JsonrpcMcpMeta`, `JsonrpcRequestParamsMeta`
|
|
446
|
-
- Builders in `http/jsonrpc_helpers.ts`: `create_jsonrpc_request`, `create_jsonrpc_notification`, `create_jsonrpc_response`, `create_jsonrpc_error_response`, `create_jsonrpc_error_response_from_thrown` (preserves code/message/data on `
|
|
447
|
-
- Type guards: `is_jsonrpc_request_id` (rejects NaN/Infinity), `is_jsonrpc_object`, `
|
|
459
|
+
- Builders in `http/jsonrpc_helpers.ts`: `create_jsonrpc_request`, `create_jsonrpc_notification`, `create_jsonrpc_response`, `create_jsonrpc_error_response`, `create_jsonrpc_error_response_from_thrown` (preserves code/message/data on a thrown JSON-RPC error, via `to_thrown_jsonrpc_error`; plain `Error` → `internal_error` with `{stack}` in DEV)
|
|
460
|
+
- Type guards: `is_jsonrpc_request_id` (rejects NaN/Infinity), `is_jsonrpc_object`, `is_jsonrpc_request` / `_notification` / `_response` / `_error_response`
|
|
448
461
|
- Converters: `to_jsonrpc_message_id`, `to_jsonrpc_params` (normalizes primitives to `{value}`)
|
|
462
|
+
- Classifier: `classify_jsonrpc_message(json)` → `ClassifiedJsonrpcMessage` (`request` / `notification` / `response` / `invalid`, the last carrying the error and the id to answer it on), twin of the Rust `fuz_http::classify` in order and answers. The WS frame handler and the HTTP POST handler switch on it, each keeping its transport's arms: WS refuses batches before it, routes `cancel` and peer responses, and checks duplicate ids and the in-flight ceiling after; POST answers a notification or a response `invalid_request` on `id: null`. Only a refused request envelope carries data — the schema's issues, DEV-only.
|
|
449
463
|
|
|
450
464
|
Handlers can `throw jsonrpc_errors.*` — `apply_route_specs`' error-catch
|
|
451
|
-
layer converts to `{error:
|
|
465
|
+
layer converts to the flat REST body (`{error: <reason>, message?, ...rest_data}`)
|
|
466
|
+
at the correct HTTP status.
|
|
452
467
|
Generic `Error` maps to 500 `internal_error` (message in DEV only).
|
|
453
468
|
|
|
454
469
|
## Pending Effects
|
|
@@ -467,7 +482,7 @@ interface EmitAfterCommitContext {
|
|
|
467
482
|
```
|
|
468
483
|
|
|
469
484
|
- **`pending_effects: Array<Promise<void>>`** — eager. Producers push the in-flight `Promise<void>` for fire-and-forget pool writes already running: audit emits via `AppDeps.audit`, session-touch UPDATE, api-token usage tracking. The pool write is rollback-resilient by virtue of running outside the request transaction; pushing the in-flight handle lets test mode (`await_pending_effects: true`) await it. Drain: `flush_pending_effects(effects, log, on_rejection?)`.
|
|
470
|
-
- **`post_commit_effects: Array<() => void | Promise<void>>`** — deferred. Producers go through `emit_after_commit(ctx, fn)` exclusively; raw thunks should not be pushed directly. The flush middleware (in `server/app_server.ts` and the per-message WS dispatcher in `actions/
|
|
485
|
+
- **`post_commit_effects: Array<() => void | Promise<void>>`** — deferred. Producers go through `emit_after_commit(ctx, fn)` exclusively; raw thunks should not be pushed directly. The flush middleware (in `server/app_server.ts` and the per-message WS dispatcher in `actions/ws_socket_session.ts`) is the only site that invokes each thunk, after the wrapping `db.transaction` resolves. Drain: `flush_post_commit_effects(effects, log)`.
|
|
471
486
|
|
|
472
487
|
### Why split
|
|
473
488
|
|
|
@@ -512,7 +527,7 @@ must run only after the transaction commits.
|
|
|
512
527
|
### Key properties
|
|
513
528
|
|
|
514
529
|
- **The flush owns the safety net.** `flush_post_commit_effects` wraps every thunk in `try/catch` and routes errors through `ctx.log.error`, so one failing send cannot starve sibling effects in the same batch nor corrupt the already-committed response. Per-thunk `try/catch` inside `emit_after_commit` would skip directly-pushed thunks (e.g. tests); centralizing the wrap in the flush closes that gap.
|
|
515
|
-
- **
|
|
530
|
+
- **One flush, every transport.** `flush_request_effects(pending_effects, post_commit_effects, log, on_rejection?)` drains both queues; the HTTP middleware and the per-message WS flush both call it, threading `on_effect_error` (with `{transport, method, path}`) into `on_rejection`. Test mode (`await_pending_effects: true`) awaits it before the response returns; production HTTP runs it fire-and-forget; WS awaits it per frame, after the reply.
|
|
516
531
|
- **The deferred thunks never wait on the eager writes.** Every flush site (both modes here, and the per-message WS flush) invokes the `post_commit_effects` thunks before it awaits `pending_effects`, so a revocation's connection close is not held behind a slow audit INSERT. A thunk that needs a write — the audit emitter's success-row fan-out — awaits that write itself.
|
|
517
532
|
- **Drain at the outer flush; discard at the dispatch site.** The successful-path _drain_ of both queues stays at the outer flush middleware (`server/app_server.ts`) + the per-message WS flush — adjacent, one location, no per-wrapper drain timing. What the dispatch sites (route-spec wrapper / `perform_action`) own is the _rollback discard_, via the shared `dispatch_with_post_commit_rollback` helper: on a handler throw they truncate `post_commit_effects` before the outer flush ever sees it, so the flush only drains effects from a committed handler. The eager `pending_effects` queue is never truncated — it drains regardless (attempt audits survive rollback).
|
|
518
533
|
- Structurally satisfied by both `RouteContext` (HTTP) and `ActionContext` (RPC + WS) — they share the `{log, post_commit_effects}` shape, which is why this helper lives in `http/` rather than `actions/` or `auth/`.
|
|
@@ -527,7 +542,7 @@ at send time.
|
|
|
527
542
|
`http/common_routes.ts` exposes three generic route-spec factories with no
|
|
528
543
|
auth-domain dependencies:
|
|
529
544
|
|
|
530
|
-
- `create_health_route_spec()` — `GET /health
|
|
545
|
+
- `create_health_route_spec()` — `GET /health` (`HEALTH_PATH`), public, returns `{status: 'ok'}` (`HealthResponse`, both from `http/health_schema.ts`). Infrastructure endpoint for uptime monitors, and what `ui/backend_probe.svelte.ts` reads
|
|
531
546
|
- `create_ready_route_spec({expected, log})` — `GET /ready`, public, the deploy gate. Introspects the live DB's columns (`db/schema_ready.ts`) and compares against the committed `expected` column map: `200 {ready: true}` on match, else `503 {error: 'schema_drift' | 'db_unreachable'}`. Detailed drift logs server-side only (minimal body — no schema leak, mirrors why `/api/surface` is admin-only). Throws at assembly on an empty `expected` (fail-loud). Opt-in like `/health`; pair with `load_expected_schema(url)` — loads + URL-caches a consumer's committed `expected_schema.json` and throws on an empty map
|
|
532
547
|
- `create_server_status_route_spec({version, get_uptime_ms})` — `GET /api/server/status`, authenticated, returns `{version, uptime_ms}`
|
|
533
548
|
|
|
@@ -576,7 +591,7 @@ a request. Twin of the Rust spine's `fuz_db_admin` router.
|
|
|
576
591
|
400 `ERROR_TABLE_NOT_DELETABLE` before the key-shape check, because a generic
|
|
577
592
|
storage endpoint has no business deleting a row whose meaning lives in the
|
|
578
593
|
domain layer. `audit_log` is the sharpest: it is both the trail and, since
|
|
579
|
-
|
|
594
|
+
the revocation guard (`create_revocation_guard`) closes live connections by
|
|
580
595
|
listening to audit events, part of how revocation propagates. The three
|
|
581
596
|
singletons each fail differently on deletion — `bootstrap_lock` leaves
|
|
582
597
|
`check_bootstrap_status` advertising a window `bootstrap_account.ts` then always
|
|
@@ -629,5 +644,5 @@ Interfaces exported for consumer use: `TableInfo`, `TableWithCount`,
|
|
|
629
644
|
|
|
630
645
|
- **Middleware ordering** is assembled by `create_app_server` — see the root ../../../CLAUDE.md §Middleware Ordering. The invariants `http/` needs consumers to uphold: trusted-proxy runs before auth/rate-limit; origin verification runs before session parsing; `client_ip` must be set before any handler or rate limiter reads it
|
|
631
646
|
- **No re-exports.** Import every symbol from its canonical source module. `http/surface.ts` no longer re-exports schema helpers — go through `http/schema_helpers.ts`
|
|
632
|
-
- **Input/output schemas align with SAES.** When wiring RPC via `actions/action_rpc.ts
|
|
647
|
+
- **Input/output schemas align with SAES.** When wiring RPC via `actions/action_rpc.ts`, the same Zod types flow through unchanged (see `actions/CLAUDE.md` §Single JSON-RPC 2.0 endpoint)
|
|
633
648
|
- **Error modules are complementary, not redundant.** `http/error_schemas.ts` is Zod-first (for routes and surface); `http/jsonrpc_errors.ts` is throw-first (for handlers and the catch layer). A single `ERROR_*` code can be raised either way depending on whether the handler needs to also attach diagnostic fields
|