@fuzdev/fuz_app 0.150.0 → 0.152.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 +324 -299
- package/dist/actions/action_bridge.d.ts +5 -86
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +4 -84
- 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_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 -34
- 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 -298
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +155 -923
- 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 +52 -75
- 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 +70 -44
- 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_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 +5 -5
- package/dist/auth/actor_search_queries.d.ts.map +1 -1
- package/dist/auth/actor_search_queries.js +7 -7
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +3 -1
- 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 +12 -42
- package/dist/auth/all_cell_actions.d.ts +6 -4
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +1 -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 +3 -3
- package/dist/auth/audit_emitter.js +2 -2
- 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 +13 -21
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +10 -18
- 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/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_actions.d.ts +22 -13
- package/dist/auth/cell_actions.d.ts.map +1 -1
- package/dist/auth/cell_actions.js +105 -167
- 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_metadata.d.ts +1 -1
- package/dist/auth/cell_audit_metadata.js +1 -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 +2 -2
- package/dist/auth/cell_grant_action_specs.js +3 -3
- package/dist/auth/cell_grant_actions.d.ts +73 -11
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +63 -55
- 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 +5 -5
- package/dist/auth/credential_type_schema.js +5 -5
- 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 +99 -14
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +26 -13
- package/dist/auth/role_grant_offer_actions.d.ts +13 -7
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +14 -12
- package/dist/auth/role_grant_offer_notifications.d.ts +3 -3
- package/dist/auth/role_grant_offer_notifications.js +1 -1
- package/dist/auth/role_grant_offer_queries.d.ts +0 -5
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +9 -41
- package/dist/auth/role_grant_queries.d.ts +17 -67
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +34 -106
- 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/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 +1 -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 +9 -4
- package/dist/db/cell_ddl.d.ts +5 -142
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +17 -16
- 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 +12 -48
- package/dist/db/cell_queries.d.ts.map +1 -1
- package/dist/db/cell_queries.js +24 -55
- 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/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_errors.d.ts +22 -2
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +41 -3
- 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/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 +1 -1
- package/dist/http/surface.d.ts.map +1 -1
- 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 +30 -10
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +85 -21
- 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 +62 -51
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +84 -71
- 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 +179 -158
- 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 -77
- 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/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 +13 -7
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- 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_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 +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- 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/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 +9 -2
- 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 +23 -1
- 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_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 +45 -3
- 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 +9 -8
- 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 -96
- package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
- package/dist/actions/transports_ws_auth_guard.js +0 -141
- 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 -239
- 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
|
@@ -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
|
}));
|
|
@@ -50,8 +50,8 @@ export declare const AuditEventType: z.ZodEnum<{
|
|
|
50
50
|
}>;
|
|
51
51
|
export type AuditEventType = z.infer<typeof AuditEventType>;
|
|
52
52
|
/**
|
|
53
|
-
* What a **successful** audit row invalidates — the axis
|
|
54
|
-
*
|
|
53
|
+
* What a **successful** audit row invalidates — the axis the revocation
|
|
54
|
+
* listener (`create_revocation_guard`) dispatches on.
|
|
55
55
|
*
|
|
56
56
|
* - `none` — the row invalidates no live connection.
|
|
57
57
|
* - `session` — one session: the connections whose session-token hash equals
|
|
@@ -63,8 +63,8 @@ export type AuditEventType = z.infer<typeof AuditEventType>;
|
|
|
63
63
|
* `metadata.role`, when the revoked grant was global
|
|
64
64
|
* (`to_global_role_revocation`).
|
|
65
65
|
*
|
|
66
|
-
* The scope says what the row invalidated;
|
|
67
|
-
* alike. On `role` that matters for the WebSocket too: per-message dispatch
|
|
66
|
+
* The scope says what the row invalidated; the listener acts on every scope
|
|
67
|
+
* alike, for every transport. On `role` that matters for the WebSocket too: per-message dispatch
|
|
68
68
|
* re-authorizes each request against its own action, but a socket admitted by
|
|
69
69
|
* a role gate also receives every server push its endpoint sends, which no
|
|
70
70
|
* dispatch ever re-checks — so a socket that lost the gating role is closed,
|
|
@@ -74,9 +74,8 @@ export type AuditEventType = z.infer<typeof AuditEventType>;
|
|
|
74
74
|
*/
|
|
75
75
|
export type RevocationScope = 'none' | 'session' | 'token' | 'account' | 'role';
|
|
76
76
|
/**
|
|
77
|
-
* The `RevocationScope` of every builtin audit event — declared once,
|
|
78
|
-
*
|
|
79
|
-
* list each. Typed over `AuditEventType`, so a new event type does not compile
|
|
77
|
+
* The `RevocationScope` of every builtin audit event — declared once, the one
|
|
78
|
+
* answer the revocation listener reads, and the twin of the Rust spine's table. Typed over `AuditEventType`, so a new event type does not compile
|
|
80
79
|
* until it declares its scope here.
|
|
81
80
|
*
|
|
82
81
|
* A scope other than `none` marks an event whose success invalidates a live
|
|
@@ -104,15 +103,16 @@ export declare const to_revocation_scope: (event_type: string) => RevocationScop
|
|
|
104
103
|
* The account and role a successful `role`-scope row took away, when the
|
|
105
104
|
* revoked grant was **global** — `null` otherwise.
|
|
106
105
|
*
|
|
107
|
-
* A role gate (`
|
|
106
|
+
* A role gate (`register_action_ws`'s `required_roles`, the audit stream's
|
|
108
107
|
* `require_role`) admits on global grants only, so revoking a scoped grant
|
|
109
108
|
* takes away nothing a gate admitted on and closes nothing. A row with no
|
|
110
109
|
* `metadata.scope_id` reads as global: when unsure, closing is the safe side.
|
|
111
110
|
* The target is `target_account_id ?? account_id`, as for the `account` scope.
|
|
112
|
-
*
|
|
113
|
-
* role close on the same rows.
|
|
111
|
+
* The revocation guard reads it for every transport, so a socket and a
|
|
112
|
+
* stream gated on one role close on the same rows.
|
|
114
113
|
*
|
|
115
|
-
* Twin of the Rust spine's
|
|
114
|
+
* Twin of the role arm of the Rust spine's
|
|
115
|
+
* `ConnectionCloseTarget::from_audit_event`.
|
|
116
116
|
*
|
|
117
117
|
* @param event - a row whose scope is `role` (the caller dispatched on it)
|
|
118
118
|
* @returns the account and role to close on, or `null` when the row names no
|
|
@@ -380,14 +380,6 @@ export interface AuditLogEvent {
|
|
|
380
380
|
created_at: string;
|
|
381
381
|
metadata: Record<string, unknown> | null;
|
|
382
382
|
}
|
|
383
|
-
/**
|
|
384
|
-
* Narrow metadata type for a known event type.
|
|
385
|
-
*
|
|
386
|
-
* Use after checking `event_type` to get typed metadata access.
|
|
387
|
-
*/
|
|
388
|
-
export declare const get_audit_metadata: <T extends AuditEventType>(event: AuditLogEvent & {
|
|
389
|
-
event_type: T;
|
|
390
|
-
}) => AuditMetadataMap[T] | null;
|
|
391
383
|
/** Input for creating an audit log entry. */
|
|
392
384
|
export interface AuditLogInput<T extends string = AuditEventType> {
|
|
393
385
|
event_type: T;
|
|
@@ -486,7 +478,7 @@ export interface AuditLogListOptions {
|
|
|
486
478
|
* types registered via `create_audit_log_config({extra_events})` round-trip
|
|
487
479
|
* through queries, `on_audit_event` callbacks, and JSON-RPC responses
|
|
488
480
|
* identically to builtins. `AuditLogInput<T>` stays parameterized on the
|
|
489
|
-
* write side so `AuditMetadataMap`
|
|
481
|
+
* write side so `AuditMetadataMap` narrows metadata per event type.
|
|
490
482
|
*/
|
|
491
483
|
export declare const AuditLogEventJson: z.ZodObject<{
|
|
492
484
|
id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
|
|
@@ -545,7 +537,7 @@ export declare const RoleGrantHistoryEventJson: z.ZodObject<{
|
|
|
545
537
|
target_username: z.ZodNullable<z.ZodString>;
|
|
546
538
|
}, z.core.$strict>;
|
|
547
539
|
export type RoleGrantHistoryEventJson = z.infer<typeof RoleGrantHistoryEventJson>;
|
|
548
|
-
/** Zod schema for admin session listing (session + username). */
|
|
540
|
+
/** Zod schema for admin session listing (session + username, without `is_current`). */
|
|
549
541
|
export declare const AdminSessionJson: z.ZodObject<{
|
|
550
542
|
id: z.core.$ZodBranded<z.ZodString, "SessionId", "out">;
|
|
551
543
|
account_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAS,MAAM,yBAAyB,CAAC;AAkBtD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,6iBA6BnB,CAAC;AAEZ,wCAAwC;AACxC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA4B,CAAC;AACxD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhF
|
|
1
|
+
{"version":3,"file":"audit_log_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema.ts"],"names":[],"mappings":"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"}
|
|
@@ -62,9 +62,8 @@ export const AUDIT_EVENT_TYPES = Object.freeze([
|
|
|
62
62
|
/** Zod schema for audit event types. */
|
|
63
63
|
export const AuditEventType = z.enum(AUDIT_EVENT_TYPES);
|
|
64
64
|
/**
|
|
65
|
-
* The `RevocationScope` of every builtin audit event — declared once,
|
|
66
|
-
*
|
|
67
|
-
* list each. Typed over `AuditEventType`, so a new event type does not compile
|
|
65
|
+
* The `RevocationScope` of every builtin audit event — declared once, the one
|
|
66
|
+
* answer the revocation listener reads, and the twin of the Rust spine's table. Typed over `AuditEventType`, so a new event type does not compile
|
|
68
67
|
* until it declares its scope here.
|
|
69
68
|
*
|
|
70
69
|
* A scope other than `none` marks an event whose success invalidates a live
|
|
@@ -123,15 +122,16 @@ export const to_revocation_scope = (event_type) => Object.hasOwn(audit_event_rev
|
|
|
123
122
|
* The account and role a successful `role`-scope row took away, when the
|
|
124
123
|
* revoked grant was **global** — `null` otherwise.
|
|
125
124
|
*
|
|
126
|
-
* A role gate (`
|
|
125
|
+
* A role gate (`register_action_ws`'s `required_roles`, the audit stream's
|
|
127
126
|
* `require_role`) admits on global grants only, so revoking a scoped grant
|
|
128
127
|
* takes away nothing a gate admitted on and closes nothing. A row with no
|
|
129
128
|
* `metadata.scope_id` reads as global: when unsure, closing is the safe side.
|
|
130
129
|
* The target is `target_account_id ?? account_id`, as for the `account` scope.
|
|
131
|
-
*
|
|
132
|
-
* role close on the same rows.
|
|
130
|
+
* The revocation guard reads it for every transport, so a socket and a
|
|
131
|
+
* stream gated on one role close on the same rows.
|
|
133
132
|
*
|
|
134
|
-
* Twin of the Rust spine's
|
|
133
|
+
* Twin of the role arm of the Rust spine's
|
|
134
|
+
* `ConnectionCloseTarget::from_audit_event`.
|
|
135
135
|
*
|
|
136
136
|
* @param event - a row whose scope is `role` (the caller dispatched on it)
|
|
137
137
|
* @returns the account and role to close on, or `null` when the row names no
|
|
@@ -462,14 +462,6 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
462
462
|
})
|
|
463
463
|
})
|
|
464
464
|
});
|
|
465
|
-
/**
|
|
466
|
-
* Narrow metadata type for a known event type.
|
|
467
|
-
*
|
|
468
|
-
* Use after checking `event_type` to get typed metadata access.
|
|
469
|
-
*/
|
|
470
|
-
export const get_audit_metadata = (event) => {
|
|
471
|
-
return event.metadata;
|
|
472
|
-
};
|
|
473
465
|
/** Builtin fuz_app audit-log config — every existing event type and its metadata schema. */
|
|
474
466
|
export const builtin_audit_log_config = Object.freeze({
|
|
475
467
|
event_types: AUDIT_EVENT_TYPES,
|
|
@@ -526,7 +518,7 @@ export const AUDIT_LOG_DEFAULT_LIMIT = 50;
|
|
|
526
518
|
* types registered via `create_audit_log_config({extra_events})` round-trip
|
|
527
519
|
* through queries, `on_audit_event` callbacks, and JSON-RPC responses
|
|
528
520
|
* identically to builtins. `AuditLogInput<T>` stays parameterized on the
|
|
529
|
-
* write side so `AuditMetadataMap`
|
|
521
|
+
* write side so `AuditMetadataMap` narrows metadata per event type.
|
|
530
522
|
*/
|
|
531
523
|
export const AuditLogEventJson = z.strictObject({
|
|
532
524
|
id: Uuid,
|
|
@@ -551,7 +543,7 @@ export const RoleGrantHistoryEventJson = AuditLogEventJson.extend({
|
|
|
551
543
|
username: z.string().nullable(),
|
|
552
544
|
target_username: z.string().nullable()
|
|
553
545
|
});
|
|
554
|
-
/** Zod schema for admin session listing (session + username). */
|
|
555
|
-
export const AdminSessionJson = AuthSessionJson.extend({
|
|
546
|
+
/** Zod schema for admin session listing (session + username, without `is_current`). */
|
|
547
|
+
export const AdminSessionJson = AuthSessionJson.omit({ is_current: true }).extend({
|
|
556
548
|
username: z.string()
|
|
557
549
|
});
|
|
@@ -34,9 +34,12 @@ import type { QueryDeps } from '../db/query_deps.js';
|
|
|
34
34
|
* A token that fails the `is_api_token_shaped` precheck soft-fails before
|
|
35
35
|
* the database is touched.
|
|
36
36
|
* Auth scheme matching is case-insensitive per RFC 7235.
|
|
37
|
-
* On success, sets `
|
|
38
|
-
* and
|
|
39
|
-
* (
|
|
37
|
+
* On success, sets the `api_token` arm of `ResolvedAuth` (`RESOLVED_AUTH_KEY`):
|
|
38
|
+
* the account, the token id, its scope, and its deadline. The last leg of the
|
|
39
|
+
* chain, it skips when an earlier one (the daemon token or a session cookie)
|
|
40
|
+
* already resolved the request — before reading the header, so a token sent
|
|
41
|
+
* beside a winning credential is never looked up and its `last_used_at` /
|
|
42
|
+
* `last_used_ip` never move. Acting-actor resolution + `RequestContext`
|
|
40
43
|
* construction are deferred to the dispatcher's authorization phase.
|
|
41
44
|
*
|
|
42
45
|
* There is deliberately **no rate limit on this path**, and no 429 — every
|
|
@@ -50,7 +53,7 @@ import type { QueryDeps } from '../db/query_deps.js';
|
|
|
50
53
|
*
|
|
51
54
|
* @param deps - query dependencies (pool-level db for middleware)
|
|
52
55
|
* @param log - the logger instance
|
|
53
|
-
* @mutates Hono context - sets `
|
|
56
|
+
* @mutates Hono context - sets `RESOLVED_AUTH_KEY` on success
|
|
54
57
|
*/
|
|
55
58
|
export declare const create_bearer_auth_middleware: (deps: QueryDeps, log: Logger) => MiddlewareHandler;
|
|
56
59
|
//# sourceMappingURL=bearer_auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bearer_auth.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/bearer_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"bearer_auth.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/bearer_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAOtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,6BAA6B,GAAI,MAAM,SAAS,EAAE,KAAK,MAAM,KAAG,iBAkF5E,CAAC"}
|
package/dist/auth/bearer_auth.js
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
* @module
|
|
16
16
|
*/
|
|
17
17
|
import { DEV } from 'esm-env';
|
|
18
|
-
import {
|
|
18
|
+
import { RESOLVED_AUTH_KEY } from '../hono_context.js';
|
|
19
19
|
import { credential_deadline_after } from './credential_deadline.js';
|
|
20
|
+
import { get_resolved_auth } from './resolved_auth.js';
|
|
20
21
|
import { is_api_token_shaped } from './api_token.js';
|
|
21
22
|
import { query_validate_api_token } from './api_token_queries.js';
|
|
22
23
|
import { get_client_ip } from '../http/client_ip.js';
|
|
@@ -38,9 +39,12 @@ import { is_browser_context } from '../http/origin.js';
|
|
|
38
39
|
* A token that fails the `is_api_token_shaped` precheck soft-fails before
|
|
39
40
|
* the database is touched.
|
|
40
41
|
* Auth scheme matching is case-insensitive per RFC 7235.
|
|
41
|
-
* On success, sets `
|
|
42
|
-
* and
|
|
43
|
-
* (
|
|
42
|
+
* On success, sets the `api_token` arm of `ResolvedAuth` (`RESOLVED_AUTH_KEY`):
|
|
43
|
+
* the account, the token id, its scope, and its deadline. The last leg of the
|
|
44
|
+
* chain, it skips when an earlier one (the daemon token or a session cookie)
|
|
45
|
+
* already resolved the request — before reading the header, so a token sent
|
|
46
|
+
* beside a winning credential is never looked up and its `last_used_at` /
|
|
47
|
+
* `last_used_ip` never move. Acting-actor resolution + `RequestContext`
|
|
44
48
|
* construction are deferred to the dispatcher's authorization phase.
|
|
45
49
|
*
|
|
46
50
|
* There is deliberately **no rate limit on this path**, and no 429 — every
|
|
@@ -54,12 +58,12 @@ import { is_browser_context } from '../http/origin.js';
|
|
|
54
58
|
*
|
|
55
59
|
* @param deps - query dependencies (pool-level db for middleware)
|
|
56
60
|
* @param log - the logger instance
|
|
57
|
-
* @mutates Hono context - sets `
|
|
61
|
+
* @mutates Hono context - sets `RESOLVED_AUTH_KEY` on success
|
|
58
62
|
*/
|
|
59
63
|
export const create_bearer_auth_middleware = (deps, log) => {
|
|
60
64
|
return async (c, next) => {
|
|
61
|
-
//
|
|
62
|
-
if (c
|
|
65
|
+
// an earlier leg (daemon token, session cookie) already resolved the request
|
|
66
|
+
if (get_resolved_auth(c) !== null) {
|
|
63
67
|
await next();
|
|
64
68
|
return;
|
|
65
69
|
}
|
|
@@ -112,14 +116,16 @@ export const create_bearer_auth_middleware = (deps, log) => {
|
|
|
112
116
|
await next();
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
115
|
-
c.set(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
c.set(RESOLVED_AUTH_KEY, {
|
|
120
|
+
credential_type: 'api_token',
|
|
121
|
+
account_id: api_token.account_id,
|
|
122
|
+
api_token_id: api_token.id,
|
|
123
|
+
// Parsed by the query, which refuses a token whose stored scope is
|
|
124
|
+
// unreadable — there is no default to fall back to.
|
|
125
|
+
scope: api_token.scope,
|
|
126
|
+
// the row's expiry, read on the database clock; none for an eternal token
|
|
127
|
+
credential_deadline: credential_deadline_after([api_token.expires_in_ms])
|
|
128
|
+
});
|
|
123
129
|
await next();
|
|
124
130
|
};
|
|
125
131
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cell verbs' shared gates and audit emit.
|
|
3
|
+
*
|
|
4
|
+
* Every gate loads the cell, reads its grants where the tier consults them,
|
|
5
|
+
* applies the tier's predicate, and answers a miss and a denial with the same
|
|
6
|
+
* `cell_not_found` 404. A 403 on denial would confirm the row exists, so a
|
|
7
|
+
* caller with no authority could walk ids and read a private cell's existence
|
|
8
|
+
* off the difference; one wire shape for both is the IDOR mask. Each gate
|
|
9
|
+
* returns the loaded row, so a handler that needs it doesn't re-read it.
|
|
10
|
+
*
|
|
11
|
+
* Twins of the Rust `fuz_cell_actions` helpers; `require_viewable_cell`
|
|
12
|
+
* covers both of Rust's authenticated and `_optional_auth` read gates.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import type { ActionActorContext, ActionContext } from '../actions/action_types.js';
|
|
17
|
+
import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
|
|
18
|
+
import type { QueryDeps } from '../db/query_deps.js';
|
|
19
|
+
import { type CellRow } from '../db/cell_queries.js';
|
|
20
|
+
import type { Uuid } from '../primitive_schemas.js';
|
|
21
|
+
import type { AuditLogInput } from './audit_log_schema.js';
|
|
22
|
+
import type { AuditEmitter } from './audit_emitter.js';
|
|
23
|
+
import type { RequestActorContext, RequestContext } from './request_context.js';
|
|
24
|
+
/**
|
|
25
|
+
* The 404 every cell gate answers for a miss and a denial alike.
|
|
26
|
+
*
|
|
27
|
+
* @returns the `cell_not_found` JSON-RPC error
|
|
28
|
+
*/
|
|
29
|
+
export declare const cell_not_found_error: () => ReturnType<typeof jsonrpc_errors.not_found>;
|
|
30
|
+
/**
|
|
31
|
+
* Load a cell and gate the caller on `can_view_cell`, 404-masking a miss and a
|
|
32
|
+
* denial alike.
|
|
33
|
+
*
|
|
34
|
+
* The read tier: a create's parent, a clone's source, the far endpoint a write
|
|
35
|
+
* links to (so a link is no existence oracle), and the endpoints of the
|
|
36
|
+
* public relation lists, where `auth` may be `null`.
|
|
37
|
+
*
|
|
38
|
+
* @param deps - query deps
|
|
39
|
+
* @param auth - the caller, or `null` when unauthenticated
|
|
40
|
+
* @param cell_id - the cell to load
|
|
41
|
+
* @returns the loaded row
|
|
42
|
+
* @throws the `cell_not_found` 404 on a miss or a denial
|
|
43
|
+
*/
|
|
44
|
+
export declare const require_viewable_cell: (deps: QueryDeps, auth: RequestContext | null, cell_id: Uuid) => Promise<CellRow>;
|
|
45
|
+
/**
|
|
46
|
+
* Load a cell and gate the caller on `can_edit_cell`, 404-masking a miss and a
|
|
47
|
+
* denial alike.
|
|
48
|
+
*
|
|
49
|
+
* The write tier: `cell_update` / `cell_delete`, the source a field write
|
|
50
|
+
* writes, and the parent every item mutation writes.
|
|
51
|
+
*
|
|
52
|
+
* @param deps - query deps
|
|
53
|
+
* @param auth - the caller
|
|
54
|
+
* @param cell_id - the cell to load
|
|
55
|
+
* @returns the loaded row
|
|
56
|
+
* @throws the `cell_not_found` 404 on a miss or a denial
|
|
57
|
+
*/
|
|
58
|
+
export declare const require_editable_cell: (deps: QueryDeps, auth: RequestActorContext, cell_id: Uuid) => Promise<CellRow>;
|
|
59
|
+
/**
|
|
60
|
+
* Load a cell and gate the caller on `can_manage_cell`, 404-masking a miss and
|
|
61
|
+
* a denial alike.
|
|
62
|
+
*
|
|
63
|
+
* The manage tier: `cell_audit_list`, `cell_grant_create`, `cell_grant_list`.
|
|
64
|
+
* Manage is admin-or-owner and not a grant level, so no grant is read. A
|
|
65
|
+
* viewer or an editor gets the same mask a stranger does: an audit timeline
|
|
66
|
+
* and a share list say who touched the cell, which is more sensitive than the
|
|
67
|
+
* content.
|
|
68
|
+
*
|
|
69
|
+
* @param deps - query deps
|
|
70
|
+
* @param auth - the caller
|
|
71
|
+
* @param cell_id - the cell to load
|
|
72
|
+
* @returns the loaded row
|
|
73
|
+
* @throws the `cell_not_found` 404 on a miss or a denial
|
|
74
|
+
*/
|
|
75
|
+
export declare const require_manageable_cell: (deps: QueryDeps, auth: RequestActorContext, cell_id: Uuid) => Promise<CellRow>;
|
|
76
|
+
/**
|
|
77
|
+
* Emit a cell-domain audit event for the caller, with `actor_id`,
|
|
78
|
+
* `account_id`, and `ip` lifted from `auth` and `ctx`. `metadata` is the
|
|
79
|
+
* event's own envelope.
|
|
80
|
+
*
|
|
81
|
+
* @param ctx - the action context
|
|
82
|
+
* @param audit - the bound audit emitter
|
|
83
|
+
* @param auth - the caller
|
|
84
|
+
* @param event_type - the cell event
|
|
85
|
+
* @param metadata - the event's metadata envelope
|
|
86
|
+
* @mutates `audit_log` table - inserts the row through `audit.emit`
|
|
87
|
+
*/
|
|
88
|
+
export declare const emit_cell_audit: <T extends string>(ctx: ActionContext | ActionActorContext, audit: AuditEmitter, auth: RequestActorContext, event_type: T, metadata: AuditLogInput<T>["metadata"]) => void;
|
|
89
|
+
//# sourceMappingURL=cell_action_helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell_action_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_action_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAO,UAAU,CAAC,OAAO,cAAc,CAAC,SAAS,CACf,CAAC;AAyBpE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,SAAS,EACf,MAAM,cAAc,GAAG,IAAI,EAC3B,SAAS,IAAI,KACX,OAAO,CAAC,OAAO,CAA8D,CAAC;AAEjF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,SAAS,EACf,MAAM,mBAAmB,EACzB,SAAS,IAAI,KACX,OAAO,CAAC,OAAO,CAA8D,CAAC;AAEjF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,SAAS,EACf,MAAM,mBAAmB,EACzB,SAAS,IAAI,KACX,OAAO,CAAC,OAAO,CAIjB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAC/C,KAAK,aAAa,GAAG,kBAAkB,EACvC,OAAO,YAAY,EACnB,MAAM,mBAAmB,EACzB,YAAY,CAAC,EACb,UAAU,aAAa,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KACpC,IAQF,CAAC"}
|