@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
|
@@ -28,14 +28,15 @@
|
|
|
28
28
|
*
|
|
29
29
|
* @module
|
|
30
30
|
*/
|
|
31
|
-
import { rpc_action } from '../actions/
|
|
31
|
+
import { rpc_action } from '../actions/action_types.js';
|
|
32
32
|
import { queue_connection_close } from '../actions/connection_closer.js';
|
|
33
33
|
import { credential_type_required_error } from '../actions/perform_action.js';
|
|
34
34
|
import { jsonrpc_errors, ThrownJsonrpcError } from '../http/jsonrpc_errors.js';
|
|
35
35
|
import { builtin_role_specs_by_name, list_roles_with_grant_path, ROLE_ADMIN, ROLE_KEEPER } from './role_schema.js';
|
|
36
36
|
import { has_scoped_role } from './request_context.js';
|
|
37
|
-
import { query_account_has_global_role, query_account_has_active_global_role,
|
|
37
|
+
import { query_account_has_global_role, query_account_has_active_global_role, query_count_active_accounts_with_global_role_for_update } from './role_grant_queries.js';
|
|
38
38
|
import { GRANT_PATH_ADMIN } from './grant_path_schema.js';
|
|
39
|
+
import { query_role_grant_offer_supersede_outgoing } from './role_grant_offer_queries.js';
|
|
39
40
|
import { query_account_by_email, query_account_by_id, query_account_by_username, query_account_soft_delete, query_account_undelete, query_actor_soft_delete, query_actor_undelete, query_actors_by_account, query_admin_account_list, query_purge_account } from './account_queries.js';
|
|
40
41
|
import { query_session_list_all_active, query_session_revoke_all_for_account } from './session_queries.js';
|
|
41
42
|
import { query_revoke_all_api_tokens_for_account } from './api_token_queries.js';
|
|
@@ -74,12 +75,17 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
74
75
|
const sessions = await query_session_list_all_active(ctx);
|
|
75
76
|
return { sessions };
|
|
76
77
|
};
|
|
77
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Revoke every credential of one kind on an account — the body
|
|
80
|
+
* `session_revoke_all_handler` and `token_revoke_all_handler` share,
|
|
81
|
+
* differing only in the audit event and the revoke query.
|
|
82
|
+
*/
|
|
83
|
+
const revoke_all_for_account = async (event_type, revoke, input, ctx) => {
|
|
78
84
|
const auth = ctx.auth;
|
|
79
85
|
const account = await query_account_by_id(ctx, input.account_id);
|
|
80
86
|
if (!account) {
|
|
81
87
|
deps.audit.emit(ctx, {
|
|
82
|
-
event_type
|
|
88
|
+
event_type,
|
|
83
89
|
outcome: 'failure',
|
|
84
90
|
account_id: auth.account.id,
|
|
85
91
|
// `target_account_id` is null: the FK to `account` would reject
|
|
@@ -94,7 +100,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
94
100
|
});
|
|
95
101
|
throw jsonrpc_errors.not_found('account', { reason: ERROR_ACCOUNT_NOT_FOUND });
|
|
96
102
|
}
|
|
97
|
-
const count = await
|
|
103
|
+
const count = await revoke(ctx, input.account_id);
|
|
98
104
|
// Close the target account's live connections once the revoke has
|
|
99
105
|
// committed — queued, so it never runs before the commit or on
|
|
100
106
|
// rollback, and it does not depend on the audit write below. Queued at
|
|
@@ -114,44 +120,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
114
120
|
// `audit_log_list_with_usernames`; losing it on every success row
|
|
115
121
|
// to harden a corner case isn't worth the query-shape change.
|
|
116
122
|
deps.audit.emit(ctx, {
|
|
117
|
-
event_type
|
|
118
|
-
account_id: auth.account.id,
|
|
119
|
-
target_account_id: input.account_id,
|
|
120
|
-
ip: ctx.client_ip,
|
|
121
|
-
metadata: { count }
|
|
122
|
-
});
|
|
123
|
-
return { ok: true, count };
|
|
124
|
-
};
|
|
125
|
-
const token_revoke_all_handler = async (input, ctx) => {
|
|
126
|
-
const auth = ctx.auth;
|
|
127
|
-
const account = await query_account_by_id(ctx, input.account_id);
|
|
128
|
-
if (!account) {
|
|
129
|
-
deps.audit.emit(ctx, {
|
|
130
|
-
event_type: 'token_revoke_all',
|
|
131
|
-
outcome: 'failure',
|
|
132
|
-
account_id: auth.account.id,
|
|
133
|
-
// See `session_revoke_all_handler` — FK forces null here; the
|
|
134
|
-
// probed id lives under `metadata.attempted_account_id`.
|
|
135
|
-
target_account_id: null,
|
|
136
|
-
ip: ctx.client_ip,
|
|
137
|
-
metadata: {
|
|
138
|
-
reason: ERROR_ACCOUNT_NOT_FOUND,
|
|
139
|
-
attempted_account_id: input.account_id
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
throw jsonrpc_errors.not_found('account', { reason: ERROR_ACCOUNT_NOT_FOUND });
|
|
143
|
-
}
|
|
144
|
-
const count = await query_revoke_all_api_tokens_for_account(ctx, input.account_id);
|
|
145
|
-
// Post-commit close — see `session_revoke_all_handler`.
|
|
146
|
-
queue_connection_close(ctx, connection_closer, {
|
|
147
|
-
kind: 'account',
|
|
148
|
-
account_id: input.account_id
|
|
149
|
-
});
|
|
150
|
-
// TOCTOU window — see `session_revoke_all_handler` for the rationale on
|
|
151
|
-
// keeping `target_account_id` populated rather than switching to the
|
|
152
|
-
// failure-shape.
|
|
153
|
-
deps.audit.emit(ctx, {
|
|
154
|
-
event_type: 'token_revoke_all',
|
|
123
|
+
event_type,
|
|
155
124
|
account_id: auth.account.id,
|
|
156
125
|
target_account_id: input.account_id,
|
|
157
126
|
ip: ctx.client_ip,
|
|
@@ -159,6 +128,8 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
159
128
|
});
|
|
160
129
|
return { ok: true, count };
|
|
161
130
|
};
|
|
131
|
+
const session_revoke_all_handler = (input, ctx) => revoke_all_for_account('session_revoke_all', query_session_revoke_all_for_account, input, ctx);
|
|
132
|
+
const token_revoke_all_handler = (input, ctx) => revoke_all_for_account('token_revoke_all', query_revoke_all_api_tokens_for_account, input, ctx);
|
|
162
133
|
const audit_log_list_handler = async (input, ctx) => {
|
|
163
134
|
const events = await query_audit_log_list_with_usernames(ctx, {
|
|
164
135
|
event_type: input.event_type ?? undefined,
|
|
@@ -245,9 +216,10 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
245
216
|
// keeper/daemon auth with no recovery (keeper role is non-web-
|
|
246
217
|
// revocable and purge itself needs keeper auth). Out-of-band only.
|
|
247
218
|
// 2. **Last admin** — the sole remaining *active* admin is protected
|
|
248
|
-
// (soft-deleted admins can't log in, so they don't count).
|
|
249
|
-
// the
|
|
250
|
-
//
|
|
219
|
+
// (soft-deleted admins can't log in, so they don't count). The count
|
|
220
|
+
// locks the rows it counted, so two removals racing for the last two
|
|
221
|
+
// admins serialize and the second is refused — no web path re-grants
|
|
222
|
+
// a lost admin. `role_grant_revoke` guards the admin grant the same way.
|
|
251
223
|
// A missing account holds neither role here and falls through to the
|
|
252
224
|
// handler's own not-found path. `event_type` selects the audit event so
|
|
253
225
|
// the failure row matches the operation in flight.
|
|
@@ -275,15 +247,38 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
275
247
|
// admin while another active admin exists. Keeper branch above stays
|
|
276
248
|
// unconditional; the last-admin branch fires only for an *active* target.
|
|
277
249
|
if ((await query_account_has_active_global_role(ctx, target_account_id, ROLE_ADMIN)) &&
|
|
278
|
-
(await
|
|
250
|
+
(await query_count_active_accounts_with_global_role_for_update(ctx, ROLE_ADMIN)) <= 1) {
|
|
279
251
|
deny(ERROR_CANNOT_DELETE_LAST_ADMIN, `cannot ${verb} the last admin account`);
|
|
280
252
|
}
|
|
281
253
|
};
|
|
254
|
+
// Supersede every pending offer the removed account's actors made, audited
|
|
255
|
+
// — the cascade a revoke runs on the revokee's offers. An offer records no
|
|
256
|
+
// authority, so one outliving its grantor's account would still confer on
|
|
257
|
+
// accept. No supersede notification: a cascade notifies the grantor, and the
|
|
258
|
+
// grantor's connections close with its account. `cause_id` is the account.
|
|
259
|
+
const cancel_outgoing_offers = async (ctx, target_account_id, actors) => {
|
|
260
|
+
const superseded = await query_role_grant_offer_supersede_outgoing(ctx, actors.map((a) => a.id));
|
|
261
|
+
for (const offer of superseded) {
|
|
262
|
+
deps.audit.emit_role_grant_target(ctx, ctx.auth, {
|
|
263
|
+
event_type: 'role_grant_offer_supersede',
|
|
264
|
+
target_account_id: offer.to_account_id,
|
|
265
|
+
target_actor_id: offer.to_actor_id,
|
|
266
|
+
metadata: {
|
|
267
|
+
offer_id: offer.id,
|
|
268
|
+
role: offer.role,
|
|
269
|
+
scope_id: offer.scope_id,
|
|
270
|
+
reason: 'account_deleted',
|
|
271
|
+
cause_id: target_account_id
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
};
|
|
282
276
|
// Soft-delete an account (reversible tombstone). Self-or-admin:
|
|
283
277
|
// deleting another account requires the admin role. A self-delete is
|
|
284
278
|
// session-only — enforced here, not on the spec, whose gate stays open so
|
|
285
279
|
// an admin deleting another account keeps any credential. Tombstones the
|
|
286
|
-
// account + its actor(s),
|
|
280
|
+
// account + its actor(s), supersedes the pending offers its actors made,
|
|
281
|
+
// revokes sessions/tokens, closes sockets, and
|
|
287
282
|
// emits `account_delete` + one `actor_delete` per soft-deleted actor —
|
|
288
283
|
// each carrying its identity snapshot. `delete` = soft.
|
|
289
284
|
const account_delete_handler = async (input, ctx) => {
|
|
@@ -322,6 +317,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
322
317
|
});
|
|
323
318
|
throw jsonrpc_errors.not_found('account', { reason: ERROR_ACCOUNT_NOT_FOUND });
|
|
324
319
|
}
|
|
320
|
+
await cancel_outgoing_offers(ctx, target_account_id, actors);
|
|
325
321
|
const soft_deleted_actors = [];
|
|
326
322
|
for (const actor of actors) {
|
|
327
323
|
if (await query_actor_soft_delete(ctx, actor.id, auth.actor.id)) {
|
|
@@ -374,6 +370,9 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
374
370
|
await assert_account_removable(ctx, input.account_id, 'account_purge');
|
|
375
371
|
// Snapshot actors before the cascade removes them.
|
|
376
372
|
const actors = await query_actors_by_account(ctx, input.account_id);
|
|
373
|
+
// Before the cascade, whose `ON DELETE CASCADE` would take the offers
|
|
374
|
+
// with no audit row.
|
|
375
|
+
await cancel_outgoing_offers(ctx, input.account_id, actors);
|
|
377
376
|
const snapshot = await query_purge_account(ctx, input.account_id);
|
|
378
377
|
if (!snapshot) {
|
|
379
378
|
deps.audit.emit(ctx, {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import type { RpcAction } from '../actions/
|
|
1
|
+
import type { RpcAction } from '../actions/action_types.js';
|
|
2
2
|
import { type CellActionDeps } from './cell_actions.js';
|
|
3
|
+
import { type CellGrantCreateAuthorize, type CellGrantRevokeAuthorize } from './cell_grant_actions.js';
|
|
3
4
|
import type { RoleSchemaResult } from './role_schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* Dependencies for `create_all_cell_actions` — the CRUD factory's
|
|
7
|
+
* `CellActionDeps` plus the grant factory's optional `authorize_grant_create`
|
|
8
|
+
* and `authorize_grant_revoke`.
|
|
9
|
+
*/
|
|
10
|
+
export type AllCellActionDeps = CellActionDeps & {
|
|
11
|
+
authorize_grant_create?: CellGrantCreateAuthorize;
|
|
12
|
+
authorize_grant_revoke?: CellGrantRevokeAuthorize;
|
|
13
|
+
};
|
|
4
14
|
/**
|
|
5
15
|
* Options for `create_all_cell_actions`.
|
|
6
16
|
*
|
|
@@ -27,9 +37,10 @@ export interface AllCellActionsOptions {
|
|
|
27
37
|
* Distinct from `create_cell_actions` (the CRUD-only factory this bundles) —
|
|
28
38
|
* reach for this whenever a backend mounts the complete cell layer.
|
|
29
39
|
*
|
|
30
|
-
* @param deps - `
|
|
40
|
+
* @param deps - `AllCellActionDeps` (`log`, `audit`, the optional `validate_data`,
|
|
41
|
+
* `authorize_create`, `authorize_grant_create`, and `authorize_grant_revoke`)
|
|
31
42
|
* @param options - the role schema for grant validation
|
|
32
43
|
* @returns every cell `RpcAction`, in mount order
|
|
33
44
|
*/
|
|
34
|
-
export declare const create_all_cell_actions: (deps:
|
|
45
|
+
export declare const create_all_cell_actions: (deps: AllCellActionDeps, options: AllCellActionsOptions) => Array<RpcAction>;
|
|
35
46
|
//# sourceMappingURL=all_cell_actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all_cell_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/all_cell_actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"all_cell_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/all_cell_actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAChD,sBAAsB,CAAC,EAAE,wBAAwB,CAAC;IAClD,sBAAsB,CAAC,EAAE,wBAAwB,CAAC;CAClD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,iBAAiB,EACvB,SAAS,qBAAqB,KAC5B,KAAK,CAAC,SAAS,CAMjB,CAAC"}
|
|
@@ -19,7 +19,8 @@ import { create_cell_audit_actions } from './cell_audit_actions.js';
|
|
|
19
19
|
* Distinct from `create_cell_actions` (the CRUD-only factory this bundles) —
|
|
20
20
|
* reach for this whenever a backend mounts the complete cell layer.
|
|
21
21
|
*
|
|
22
|
-
* @param deps - `
|
|
22
|
+
* @param deps - `AllCellActionDeps` (`log`, `audit`, the optional `validate_data`,
|
|
23
|
+
* `authorize_create`, `authorize_grant_create`, and `authorize_grant_revoke`)
|
|
23
24
|
* @param options - the role schema for grant validation
|
|
24
25
|
* @returns every cell `RpcAction`, in mount order
|
|
25
26
|
*/
|
|
@@ -42,6 +42,7 @@ export declare const API_TOKEN_COLUMNS: readonly ["id", "account_id", "name", "t
|
|
|
42
42
|
* @param account_id - the owning account
|
|
43
43
|
* @param name - human-readable name
|
|
44
44
|
* @param token_hash - blake3 hash of the raw token
|
|
45
|
+
* @param scope - the token's authority narrowing, stored as `jsonb`
|
|
45
46
|
* @param expires_at - optional expiration
|
|
46
47
|
* @returns the stored token record
|
|
47
48
|
* @mutates `api_token` table - inserts the new row keyed by `id`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_token_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/api_token_queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,KAAK,UAAU,EAAmD,MAAM,kBAAkB,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG;IACzD,KAAK,EAAE,UAAU,CAAC;IAClB;;;;;OAKG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,yEAAyE;AACzE,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IACnD,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,0HAUoB,CAAC;AA6BnD
|
|
1
|
+
{"version":3,"file":"api_token_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/api_token_queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,KAAK,UAAU,EAAmD,MAAM,kBAAkB,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG;IACzD,KAAK,EAAE,UAAU,CAAC;IAClB;;;;;OAKG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,yEAAyE;AACzE,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IACnD,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,0HAUoB,CAAC;AA6BnD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,SAAS,EACf,IAAI,MAAM,EACV,YAAY,MAAM,EAClB,MAAM,MAAM,EACZ,YAAY,MAAM,EAClB,OAAO,UAAU,EACjB,aAAa,IAAI,GAAG,IAAI,KACtB,OAAO,CAAC,QAAQ,CAelB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,iBAAiB,EACvB,WAAW,MAAM,EACjB,IAAI,MAAM,GAAG,SAAS,EACtB,iBAAiB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,KAC/C,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAkCvC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,4BAA4B,GACxC,MAAM,SAAS,EACf,IAAI,MAAM,KACR,OAAO,CAAC,MAAM,GAAG,SAAS,CAM5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uCAAuC,GACnD,MAAM,SAAS,EACf,YAAY,MAAM,KAChB,OAAO,CAAC,MAAM,CAMhB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,GAC9C,MAAM,SAAS,EACf,IAAI,MAAM,EACV,YAAY,MAAM,KAChB,OAAO,CAAC,OAAO,CAMjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,SAAS,EACf,YAAY,MAAM,KAChB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAM7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,6BAA6B,GACzC,MAAM,SAAS,EACf,YAAY,MAAM,EAClB,YAAY,MAAM,KAChB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAYvB,CAAC"}
|
|
@@ -57,6 +57,7 @@ const API_TOKEN_IS_LIVE = '(expires_at IS NULL OR expires_at > NOW())';
|
|
|
57
57
|
* @param account_id - the owning account
|
|
58
58
|
* @param name - human-readable name
|
|
59
59
|
* @param token_hash - blake3 hash of the raw token
|
|
60
|
+
* @param scope - the token's authority narrowing, stored as `jsonb`
|
|
60
61
|
* @param expires_at - optional expiration
|
|
61
62
|
* @returns the stored token record
|
|
62
63
|
* @mutates `api_token` table - inserts the new row keyed by `id`
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
* - A **failure** row is announced as soon as it is written. It records an
|
|
44
44
|
* attempt, which happened whether or not the request's transaction commits.
|
|
45
45
|
* - A **success** row is announced only after the request's transaction
|
|
46
|
-
* commits
|
|
46
|
+
* commits (after the handler returns, on a route without one), and never
|
|
47
|
+
* when the handler throws: the fan-out is queued on
|
|
47
48
|
* `ctx.post_commit_effects` and awaits the write. A success row reports a
|
|
48
49
|
* state change, and the listeners act on it — the revocation listeners close
|
|
49
50
|
* connections, the audit stream broadcasts it. Announced before the commit,
|
|
@@ -53,13 +54,18 @@
|
|
|
53
54
|
* A success row emitted by a handler that later throws is still in the table —
|
|
54
55
|
* the write is outside the transaction — but is never announced.
|
|
55
56
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
57
|
+
* A route that runs without a request transaction and opens its own around
|
|
58
|
+
* just its writes (`/login`, `/password`) emits its success row once that
|
|
59
|
+
* transaction has committed, so the row is written after the change it
|
|
60
|
+
* reports. The Rust spine follows the same order: a success row emitted inside
|
|
61
|
+
* a request transaction is written in that transaction and its fan-out queued
|
|
62
|
+
* behind the commit, and `/login` and `/password` emit on the pool after their
|
|
63
|
+
* own transaction commits.
|
|
58
64
|
*
|
|
59
65
|
* Listeners are a documented registration seam — `create_app_server`
|
|
60
66
|
* registers additional listeners via `add_listener` after the backend is
|
|
61
|
-
* built (the factory-managed audit-log SSE,
|
|
62
|
-
*
|
|
67
|
+
* built (the factory-managed audit-log SSE, the revocation guard) before the
|
|
68
|
+
* first request
|
|
63
69
|
* runs, and removes each through the remover `add_listener` returns when its
|
|
64
70
|
* assembly fails or the server closes. Consumers can also register
|
|
65
71
|
* listeners directly on the emitter they return from `audit_factory` for
|
|
@@ -191,7 +197,7 @@ export interface AuditEmitter {
|
|
|
191
197
|
* during its fan-out — it iterates a snapshot — and the next one does not.
|
|
192
198
|
*
|
|
193
199
|
* `create_app_server` registers the factory-managed audit-log SSE
|
|
194
|
-
* listener and
|
|
200
|
+
* listener and the one revocation guard (`create_revocation_guard`) here so
|
|
195
201
|
* SSE + WS fan-out compose on top of the consumer's `on_audit_event`
|
|
196
202
|
* callback without shallow-copying `AppDeps`, and removes them when its
|
|
197
203
|
* assembly fails or the server closes. Consumers can also register
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_emitter.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_emitter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"audit_emitter.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,mBAAoB,SAAQ,sBAAsB;IAClE,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACrE,0FAA0F;IAC1F,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,MAAM;IACxD,UAAU,EAAE,CAAC,CAAC;IACd,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACvC,0CAA0C;IAC1C,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,mBAAmB,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAChF;;;;;;;OAOG;IACH,sBAAsB,CAAC,CAAC,SAAS,MAAM,EACtC,GAAG,EAAE,yBAAyB,EAC9B,IAAI,EAAE,mBAAmB,EACzB,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAC/B,IAAI,CAAC;IACR;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACnC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACnE;;;OAGG;IACH,cAAc,IAAI,MAAM,CAAC;IACzB;;;;;;;;;;;;;;;;OAgBG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC;;;;;;;;;;OAUG;IACH,oBAAoB,IAAI,OAAO,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,SAAS,MAAM,EAC1C,GAAG,EAAE,mBAAmB,EACxB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KACnB,IAAI,CAAC;AAEV;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,WAAW,CAAC;AAEhE,0CAA0C;AAC1C,MAAM,WAAW,yBAAyB;IACzC,oDAAoD;IACpD,EAAE,EAAE,EAAE,CAAC;IACP,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACzD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAYD,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,QAAO,MAA8B,CAAC;AAE3E,0CAA0C;AAC1C,eAAO,MAAM,0BAA0B,QAAO,IAE7C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,yBAAyB,KAAG,YAiJzE,CAAC"}
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
* - A **failure** row is announced as soon as it is written. It records an
|
|
44
44
|
* attempt, which happened whether or not the request's transaction commits.
|
|
45
45
|
* - A **success** row is announced only after the request's transaction
|
|
46
|
-
* commits
|
|
46
|
+
* commits (after the handler returns, on a route without one), and never
|
|
47
|
+
* when the handler throws: the fan-out is queued on
|
|
47
48
|
* `ctx.post_commit_effects` and awaits the write. A success row reports a
|
|
48
49
|
* state change, and the listeners act on it — the revocation listeners close
|
|
49
50
|
* connections, the audit stream broadcasts it. Announced before the commit,
|
|
@@ -53,13 +54,18 @@
|
|
|
53
54
|
* A success row emitted by a handler that later throws is still in the table —
|
|
54
55
|
* the write is outside the transaction — but is never announced.
|
|
55
56
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
57
|
+
* A route that runs without a request transaction and opens its own around
|
|
58
|
+
* just its writes (`/login`, `/password`) emits its success row once that
|
|
59
|
+
* transaction has committed, so the row is written after the change it
|
|
60
|
+
* reports. The Rust spine follows the same order: a success row emitted inside
|
|
61
|
+
* a request transaction is written in that transaction and its fan-out queued
|
|
62
|
+
* behind the commit, and `/login` and `/password` emit on the pool after their
|
|
63
|
+
* own transaction commits.
|
|
58
64
|
*
|
|
59
65
|
* Listeners are a documented registration seam — `create_app_server`
|
|
60
66
|
* registers additional listeners via `add_listener` after the backend is
|
|
61
|
-
* built (the factory-managed audit-log SSE,
|
|
62
|
-
*
|
|
67
|
+
* built (the factory-managed audit-log SSE, the revocation guard) before the
|
|
68
|
+
* first request
|
|
63
69
|
* runs, and removes each through the remover `add_listener` returns when its
|
|
64
70
|
* assembly fails or the server closes. Consumers can also register
|
|
65
71
|
* listeners directly on the emitter they return from `audit_factory` for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_route_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB;;kBAA0C,CAAC;AACxE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,UAAU,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACxC,gBAAe,MAAkC,KAC/C,IAAI,CAAC,SAAS,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"audit_log_route_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB;;kBAA0C,CAAC;AACxE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,UAAU,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACxC,gBAAe,MAAkC,KAC/C,IAAI,CAAC,SAAS,EAAE,SAAS,CA8B1B,CAAC"}
|
|
@@ -36,8 +36,9 @@ export const create_audit_log_route_shape = (required_role = DEFAULT_AUDIT_STREA
|
|
|
36
36
|
// feed is not handed to a credential channel the deployment never
|
|
37
37
|
// chose. Widening the gate loses no close — the handler registers a
|
|
38
38
|
// bearer's stream under its API token id, and a token revocation closes
|
|
39
|
-
// by that id (`create_sse_connection_closer`,
|
|
40
|
-
// `
|
|
39
|
+
// by that id (`create_sse_connection_closer`, which the handlers and the
|
|
40
|
+
// `token` scope of `create_revocation_guard` both close through) — so
|
|
41
|
+
// widening is a consumer's explicit
|
|
41
42
|
// choice about the channel, not a hole in revocation.
|
|
42
43
|
credential_types: ['session'],
|
|
43
44
|
// Rule 3 — a narrowed token holds no audit feed. Same reasoning as the
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
* `GET /audit/stream` SSE route — streams aren't an action-kind, so they
|
|
8
8
|
* stay on REST. The event payload broadcast on the stream surfaces via
|
|
9
9
|
* `audit_log_event_specs` (one `EventSpec` per audit event type) declared
|
|
10
|
-
* alongside the broadcaster in `realtime/
|
|
10
|
+
* alongside the broadcaster in `realtime/audit_log_sse.ts`.
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
14
|
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
15
15
|
import type { RouteSpec } from '../http/route_spec.js';
|
|
16
16
|
import { type SseNotification } from '../realtime/sse.js';
|
|
17
|
-
import type {
|
|
17
|
+
import type { SseRegistry } from '../realtime/sse_registry.js';
|
|
18
18
|
/** Options for audit log route specs. */
|
|
19
19
|
export interface AuditLogRouteOptions {
|
|
20
20
|
/** Role required to access audit routes. Default `'admin'`. */
|
|
@@ -28,8 +28,15 @@ export interface AuditLogRouteOptions {
|
|
|
28
28
|
* (`create_audit_log_sse`, or `AppServerContext.audit_sse`) satisfies it.
|
|
29
29
|
*/
|
|
30
30
|
stream?: {
|
|
31
|
-
registry:
|
|
31
|
+
registry: SseRegistry<SseNotification>;
|
|
32
32
|
log: Logger;
|
|
33
|
+
/**
|
|
34
|
+
* Each stream's keep-alive interval (`SseResponseOptions.keep_alive_ms`)
|
|
35
|
+
* — a test server shortens it. Validated here, at route creation.
|
|
36
|
+
*
|
|
37
|
+
* @default SSE_KEEP_ALIVE_INTERVAL_MS
|
|
38
|
+
*/
|
|
39
|
+
keep_alive_ms?: number | null;
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
@@ -46,23 +53,25 @@ export interface AuditLogRouteOptions {
|
|
|
46
53
|
* route-spec pipeline, before the handler and so before any stream is
|
|
47
54
|
* registered — a revocation landing after them would close nothing. So the
|
|
48
55
|
* handler registers the stream **pending**
|
|
49
|
-
* (`
|
|
50
|
-
*
|
|
51
|
-
* then admits (`
|
|
52
|
-
* those reads is seen by them —
|
|
53
|
-
*
|
|
56
|
+
* (`SseRegistry.subscribe_pending`), then re-reads the credential, the
|
|
57
|
+
* acting actor, and its role grants (`recheck_admission`, which the WebSocket
|
|
58
|
+
* upgrade shares), and only then admits (`SseRegistry.admit`). A
|
|
59
|
+
* revocation that committed before those reads is seen by them —
|
|
60
|
+
* `401 authentication_required` for a dead credential or an acting actor
|
|
61
|
+
* deleted since the gates ran, `403 insufficient_permissions` for a lost
|
|
62
|
+
* role — and one whose
|
|
54
63
|
* close ran after the registration found the pending entry: admission then
|
|
55
64
|
* fails, and the response is a `200` whose body is the connect comment and
|
|
56
65
|
* nothing else — to an `EventSource`, a stream closed an instant after it
|
|
57
66
|
* opened (the client's reconnect is answered by the gates, with the precise
|
|
58
67
|
* status). A pending registration receives no audit row, counts toward no cap,
|
|
59
68
|
* and is removed when a re-read refuses the request. Once the server is
|
|
60
|
-
* shutting down (`
|
|
69
|
+
* shutting down (`SseRegistry` class doc, "Shutdown") the registration
|
|
61
70
|
* is born closed, the re-reads are skipped, and the answer is that same
|
|
62
71
|
* connect comment alone — as it is when the shutdown closes a registration
|
|
63
72
|
* whose re-read is in flight, even if the re-read then fails. The twin of the
|
|
64
|
-
* Rust spine's `audit_stream_router`, which
|
|
65
|
-
*
|
|
73
|
+
* Rust spine's `audit_stream_router`, which runs the same order through its
|
|
74
|
+
* `recheck_admission`.
|
|
66
75
|
*
|
|
67
76
|
* ## Credential deadline
|
|
68
77
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"audit_log_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAUvD,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAW/D,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACpC,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE;QACR,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;QACvC,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;WAKG;QACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC9B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,4BAA4B,GAAI,UAAU,oBAAoB,KAAG,KAAK,CAAC,SAAS,CAgI5F,CAAC"}
|
|
@@ -7,18 +7,20 @@
|
|
|
7
7
|
* `GET /audit/stream` SSE route — streams aren't an action-kind, so they
|
|
8
8
|
* stay on REST. The event payload broadcast on the stream surfaces via
|
|
9
9
|
* `audit_log_event_specs` (one `EventSpec` per audit event type) declared
|
|
10
|
-
* alongside the broadcaster in `realtime/
|
|
10
|
+
* alongside the broadcaster in `realtime/audit_log_sse.ts`.
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
|
+
import { UnreachableError } from '@fuzdev/fuz_util/error.ts';
|
|
14
15
|
import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS } from '../http/error_schemas.js';
|
|
15
|
-
import {
|
|
16
|
+
import { TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
|
|
16
17
|
import { create_audit_log_route_shape, DEFAULT_AUDIT_STREAM_ROLE } from './audit_log_route_schema.js';
|
|
17
18
|
import { create_sse_response } from '../realtime/sse.js';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
19
|
+
import { validate_sse_keep_alive_ms } from '../realtime/sse_constants.js';
|
|
20
|
+
import { require_request_context } from './request_context.js';
|
|
21
|
+
import { get_resolved_auth, recheck_admission, resolved_auth_api_token_id, resolved_auth_session_hash } from './resolved_auth.js';
|
|
20
22
|
import { schedule_credential_deadline } from './credential_deadline.js';
|
|
21
|
-
import { AUDIT_LOG_CHANNEL } from '../realtime/
|
|
23
|
+
import { AUDIT_LOG_CHANNEL } from '../realtime/audit_log_sse.js';
|
|
22
24
|
/**
|
|
23
25
|
* Create the optional audit-log SSE route spec.
|
|
24
26
|
*
|
|
@@ -33,23 +35,25 @@ import { AUDIT_LOG_CHANNEL } from '../realtime/sse_auth_guard.js';
|
|
|
33
35
|
* route-spec pipeline, before the handler and so before any stream is
|
|
34
36
|
* registered — a revocation landing after them would close nothing. So the
|
|
35
37
|
* handler registers the stream **pending**
|
|
36
|
-
* (`
|
|
37
|
-
*
|
|
38
|
-
* then admits (`
|
|
39
|
-
* those reads is seen by them —
|
|
40
|
-
*
|
|
38
|
+
* (`SseRegistry.subscribe_pending`), then re-reads the credential, the
|
|
39
|
+
* acting actor, and its role grants (`recheck_admission`, which the WebSocket
|
|
40
|
+
* upgrade shares), and only then admits (`SseRegistry.admit`). A
|
|
41
|
+
* revocation that committed before those reads is seen by them —
|
|
42
|
+
* `401 authentication_required` for a dead credential or an acting actor
|
|
43
|
+
* deleted since the gates ran, `403 insufficient_permissions` for a lost
|
|
44
|
+
* role — and one whose
|
|
41
45
|
* close ran after the registration found the pending entry: admission then
|
|
42
46
|
* fails, and the response is a `200` whose body is the connect comment and
|
|
43
47
|
* nothing else — to an `EventSource`, a stream closed an instant after it
|
|
44
48
|
* opened (the client's reconnect is answered by the gates, with the precise
|
|
45
49
|
* status). A pending registration receives no audit row, counts toward no cap,
|
|
46
50
|
* and is removed when a re-read refuses the request. Once the server is
|
|
47
|
-
* shutting down (`
|
|
51
|
+
* shutting down (`SseRegistry` class doc, "Shutdown") the registration
|
|
48
52
|
* is born closed, the re-reads are skipped, and the answer is that same
|
|
49
53
|
* connect comment alone — as it is when the shutdown closes a registration
|
|
50
54
|
* whose re-read is in flight, even if the re-read then fails. The twin of the
|
|
51
|
-
* Rust spine's `audit_stream_router`, which
|
|
52
|
-
*
|
|
55
|
+
* Rust spine's `audit_stream_router`, which runs the same order through its
|
|
56
|
+
* `recheck_admission`.
|
|
53
57
|
*
|
|
54
58
|
* ## Credential deadline
|
|
55
59
|
*
|
|
@@ -67,7 +71,8 @@ import { AUDIT_LOG_CHANNEL } from '../realtime/sse_auth_guard.js';
|
|
|
67
71
|
export const create_audit_log_route_specs = (options) => {
|
|
68
72
|
if (!options?.stream)
|
|
69
73
|
return [];
|
|
70
|
-
const { registry, log } = options.stream;
|
|
74
|
+
const { registry, log, keep_alive_ms } = options.stream;
|
|
75
|
+
validate_sse_keep_alive_ms(keep_alive_ms);
|
|
71
76
|
const required_role = options.required_role ?? DEFAULT_AUDIT_STREAM_ROLE;
|
|
72
77
|
return [
|
|
73
78
|
{
|
|
@@ -84,13 +89,16 @@ export const create_audit_log_route_specs = (options) => {
|
|
|
84
89
|
// sessions only, so `api_token_id` is null here; it is registered
|
|
85
90
|
// when present so that a consumer widening the credential gate
|
|
86
91
|
// still has a revoked token's stream closed by `token_revoke`.
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
// Both come off the resolved credential, which carries each only
|
|
93
|
+
// for its own credential type.
|
|
94
|
+
const resolved = get_resolved_auth(c);
|
|
95
|
+
const session_hash = resolved_auth_session_hash(resolved);
|
|
96
|
+
const api_token_id = resolved_auth_api_token_id(resolved);
|
|
89
97
|
// Register pending first: from here every revocation finds the
|
|
90
98
|
// stream (TSDoc, "Admission").
|
|
91
99
|
const pending = registry.subscribe_pending({
|
|
92
100
|
channels: [AUDIT_LOG_CHANNEL],
|
|
93
|
-
scope:
|
|
101
|
+
scope: session_hash ?? undefined,
|
|
94
102
|
groups: api_token_id === null ? [ctx.account.id] : [ctx.account.id, api_token_id]
|
|
95
103
|
});
|
|
96
104
|
// The pending registration is released on every path that does not
|
|
@@ -107,20 +115,31 @@ export const create_audit_log_route_specs = (options) => {
|
|
|
107
115
|
// refuses whatever they answer.
|
|
108
116
|
if (!c.get(TEST_CONTEXT_PRESET_KEY) && !registry.closing) {
|
|
109
117
|
const reread = async () => {
|
|
110
|
-
const resolved = get_resolved_auth(c);
|
|
111
|
-
const credential_is_live = resolved !== null && (await revalidate_resolved_auth(route, resolved));
|
|
112
|
-
if (!credential_is_live) {
|
|
113
|
-
log.info('audit stream: credential revoked during the request', ctx.account.id);
|
|
114
|
-
return c.json({ error: ERROR_AUTHENTICATION_REQUIRED }, 401);
|
|
115
|
-
}
|
|
116
118
|
// Global grants only, like the `require_role` gate that ran in
|
|
117
119
|
// the pipeline — a scoped grant must not open the instance-wide
|
|
118
120
|
// stream.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
const recheck = resolved === null
|
|
122
|
+
? 'credential_revoked'
|
|
123
|
+
: await recheck_admission(route, {
|
|
124
|
+
resolved,
|
|
125
|
+
request_context: ctx,
|
|
126
|
+
required_roles: [required_role]
|
|
127
|
+
});
|
|
128
|
+
switch (recheck) {
|
|
129
|
+
case 'admitted':
|
|
130
|
+
return null;
|
|
131
|
+
case 'credential_revoked':
|
|
132
|
+
log.info('audit stream: credential revoked during the request', ctx.account.id);
|
|
133
|
+
return c.json({ error: ERROR_AUTHENTICATION_REQUIRED }, 401);
|
|
134
|
+
case 'actor_inactive':
|
|
135
|
+
log.info('audit stream: acting actor deleted during the request', ctx.account.id);
|
|
136
|
+
return c.json({ error: ERROR_AUTHENTICATION_REQUIRED }, 401);
|
|
137
|
+
case 'role_revoked':
|
|
138
|
+
log.info('audit stream: role revoked during the request', ctx.account.id);
|
|
139
|
+
return c.json({ error: ERROR_INSUFFICIENT_PERMISSIONS, required_roles: [required_role] }, 403);
|
|
140
|
+
default:
|
|
141
|
+
throw new UnreachableError(recheck);
|
|
122
142
|
}
|
|
123
|
-
return null;
|
|
124
143
|
};
|
|
125
144
|
const refusal = await reread().catch((error) => {
|
|
126
145
|
// the shutdown closed the registration and then the database
|
|
@@ -146,7 +165,8 @@ export const create_audit_log_route_specs = (options) => {
|
|
|
146
165
|
// whose listener runs at once and removes the registration, so
|
|
147
166
|
// `admit` refuses it rather than evicting a live stream for it.
|
|
148
167
|
const { response, stream } = create_sse_response(c, log, {
|
|
149
|
-
account_id: ctx.account.id
|
|
168
|
+
account_id: ctx.account.id,
|
|
169
|
+
keep_alive_ms
|
|
150
170
|
});
|
|
151
171
|
stream.on_close(pending.unsubscribe);
|
|
152
172
|
admitted = registry.admit(pending, stream);
|
|
@@ -158,7 +178,7 @@ export const create_audit_log_route_specs = (options) => {
|
|
|
158
178
|
// The stream ends when the credential it opened on expires —
|
|
159
179
|
// closed as a revocation closes it (TSDoc, "Credential
|
|
160
180
|
// deadline").
|
|
161
|
-
stream.on_close(schedule_credential_deadline(
|
|
181
|
+
stream.on_close(schedule_credential_deadline(resolved?.credential_deadline ?? null, () => {
|
|
162
182
|
log.info('audit stream: credential expired', ctx.account.id);
|
|
163
183
|
stream.close();
|
|
164
184
|
}));
|