@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
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* 1. **Authentication (middleware)** — `create_request_context_middleware`,
|
|
7
7
|
* `bearer_auth`, and `daemon_token_middleware` validate the credential
|
|
8
|
-
* (session cookie, bearer token
|
|
9
|
-
*
|
|
8
|
+
* (daemon token, session cookie, bearer token — the first that
|
|
9
|
+
* authenticates wins) and set one `ResolvedAuth` on the Hono context
|
|
10
|
+
* (`get_resolved_auth`). They do not resolve
|
|
10
11
|
* an acting actor or load role_grants; `REQUEST_CONTEXT_KEY` stays null at
|
|
11
12
|
* this stage, so account-grain identity is the only thing known.
|
|
12
13
|
* 2. **Authorization (route-spec wrapper / RPC dispatcher)** — after input
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
* schema declared `acting?: ActingActor` (reference equality with the
|
|
15
16
|
* canonical `ActingActor` schema) or the auth requires role_grants
|
|
16
17
|
* (`role` / `keeper`), `apply_authorization_phase` resolves the actor
|
|
17
|
-
* against
|
|
18
|
+
* against the resolved account id plus the validated `acting` value via
|
|
18
19
|
* `resolve_acting_actor`, builds the `{account, actor, role_grants}`
|
|
19
20
|
* context via `build_request_context`, and sets it on
|
|
20
21
|
* `REQUEST_CONTEXT_KEY` before auth guards fire. Authenticated routes
|
|
@@ -38,24 +39,15 @@ import { is_role_grant_active } from './account_schema.js';
|
|
|
38
39
|
import { hash_session_token, query_session_get_valid } from './session_queries.js';
|
|
39
40
|
import { query_account_by_id, query_actor_by_id, query_active_actors_by_account } from './account_queries.js';
|
|
40
41
|
import { query_role_grant_find_active_for_actor } from './role_grant_queries.js';
|
|
41
|
-
import {
|
|
42
|
+
import { RESOLVED_AUTH_KEY, SESSION_COOKIE_EXPIRES_AT_KEY, TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
|
|
42
43
|
import { credential_deadline_after } from './credential_deadline.js';
|
|
43
|
-
import {
|
|
44
|
+
import { get_resolved_auth, resolved_auth_scope } from './resolved_auth.js';
|
|
45
|
+
import { is_route_scope_capability, token_scope_admits_non_rpc, token_scope_denied_body } from './token_scope.js';
|
|
44
46
|
import { is_public_auth, needs_actor, parse_acting } from '../http/auth_shape.js';
|
|
45
47
|
import { is_null_schema } from '../http/schema_helpers.js';
|
|
46
48
|
import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_CREDENTIAL_TYPE_REQUIRED, ERROR_ACTOR_REQUIRED, ERROR_ACTOR_NOT_ON_ACCOUNT, ERROR_NO_ACTORS_ON_ACCOUNT, ERROR_ACCOUNT_VANISHED } from '../http/error_schemas.js';
|
|
47
49
|
/** Hono context variable name for the request context. */
|
|
48
50
|
export const REQUEST_CONTEXT_KEY = 'request_context';
|
|
49
|
-
/**
|
|
50
|
-
* Hono context variable name for the authenticated session token hash.
|
|
51
|
-
*
|
|
52
|
-
* Set by `create_request_context_middleware` after a successful session lookup.
|
|
53
|
-
* `null` when the request is unauthenticated or authenticated via a non-session
|
|
54
|
-
* credential (bearer token, daemon token). Exposed so handlers can scope
|
|
55
|
-
* per-session resources (e.g., SSE stream identity for targeted disconnection
|
|
56
|
-
* on `session_revoke`) without re-hashing the token.
|
|
57
|
-
*/
|
|
58
|
-
export const AUTH_SESSION_TOKEN_HASH_KEY = 'auth_session_token_hash';
|
|
59
51
|
/**
|
|
60
52
|
* Get the request context from a Hono context, or `null` if unauthenticated.
|
|
61
53
|
*
|
|
@@ -84,27 +76,6 @@ export const require_request_context = (c) => {
|
|
|
84
76
|
}
|
|
85
77
|
return ctx;
|
|
86
78
|
};
|
|
87
|
-
/**
|
|
88
|
-
* Check if a request context has an active role_grant for a given role at
|
|
89
|
-
* **any** scope.
|
|
90
|
-
*
|
|
91
|
-
* Checks the role_grants already loaded in the context (no DB query).
|
|
92
|
-
* Null-tolerant — `null` ctx (unauthenticated) returns `false`. Symmetric
|
|
93
|
-
* with `has_scoped_role` / `has_any_scoped_role` so the three helpers
|
|
94
|
-
* compose freely in the same predicate.
|
|
95
|
-
*
|
|
96
|
-
* Scope-blind, so never the gate for a builtin role (`admin` / `keeper`) or
|
|
97
|
-
* for any capability that isn't itself scoped: a grant bound to one resource
|
|
98
|
-
* would pass it. Those gates read the global grant through
|
|
99
|
-
* `has_scoped_role(ctx, role, null)` (e.g.
|
|
100
|
-
* `has_scoped_role(auth, ROLE_ADMIN, null) || has_scoped_role(auth, role, scope)`).
|
|
101
|
-
*
|
|
102
|
-
* @param ctx - the request context, or `null` for unauthenticated callers
|
|
103
|
-
* @param role - the role to check
|
|
104
|
-
* @param now - current time (defaults to `new Date()`, pass for testability and hot-path efficiency)
|
|
105
|
-
* @returns `true` if the actor has an active role_grant for the role
|
|
106
|
-
*/
|
|
107
|
-
export const has_role = (ctx, role, now = new Date()) => ctx?.role_grants.some((p) => p.role === role && is_role_grant_active(p, now)) ?? false;
|
|
108
79
|
/**
|
|
109
80
|
* Whether the request context holds an active role_grant for `role` at `scope_id`.
|
|
110
81
|
*
|
|
@@ -118,8 +89,8 @@ export const has_role = (ctx, role, now = new Date()) => ctx?.role_grants.some((
|
|
|
118
89
|
* provides.
|
|
119
90
|
*
|
|
120
91
|
* Null-tolerant — `null` ctx (unauthenticated) and account-grain
|
|
121
|
-
* contexts (`actor: null`, empty `role_grants`) both return `false
|
|
122
|
-
*
|
|
92
|
+
* contexts (`actor: null`, empty `role_grants`) both return `false`, which
|
|
93
|
+
* lets the helper drop into public
|
|
123
94
|
* (`{account: 'none', actor: 'none'}`) and account-grain
|
|
124
95
|
* (`{account: 'required', actor: 'none'}`) handlers without a manual
|
|
125
96
|
* narrow. See `cell_authorize` for the resource-side analog.
|
|
@@ -209,89 +180,82 @@ export const resolve_acting_actor = async (deps, account_id, acting_actor_id) =>
|
|
|
209
180
|
return { ok: true, actor_id: match.id };
|
|
210
181
|
};
|
|
211
182
|
/**
|
|
212
|
-
* Create middleware that authenticates the account from a session cookie
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* `
|
|
216
|
-
* `
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
183
|
+
* Create middleware that authenticates the account from a session cookie —
|
|
184
|
+
* the session leg of the auth middleware chain.
|
|
185
|
+
*
|
|
186
|
+
* When it starts the chain (`starts_chain`, the default) it first clears
|
|
187
|
+
* `RESOLVED_AUTH_KEY`. It then skips when an earlier leg (the daemon token)
|
|
188
|
+
* already resolved the request. Otherwise reads the session identity (set by session middleware), looks up
|
|
189
|
+
* the `auth_session`, and on a valid session sets the `session` arm of
|
|
190
|
+
* `ResolvedAuth` (`RESOLVED_AUTH_KEY`): the account, the session hash, and the
|
|
191
|
+
* credential deadline — the earlier of the cookie's signed expiry
|
|
192
|
+
* (`SESSION_COOKIE_EXPIRES_AT_KEY`) and the row's. Writes nothing to the
|
|
193
|
+
* session row. Does not load actor or role_grants; `REQUEST_CONTEXT_KEY` is
|
|
194
|
+
* left null — the route-spec / RPC dispatcher authorization phase resolves the
|
|
195
|
+
* acting actor and builds the full `RequestContext` when the route needs one.
|
|
196
|
+
*
|
|
197
|
+
* An invalid or missing session leaves the request unresolved and calls
|
|
198
|
+
* `next()` — the bearer leg may still resolve it, and `require_auth` /
|
|
199
|
+
* `require_role` enforce.
|
|
226
200
|
*
|
|
227
201
|
* @param deps - query dependencies (pool-level db for middleware)
|
|
228
|
-
* @param
|
|
229
|
-
* @mutates Hono context -
|
|
202
|
+
* @param options - the session token's context key, whether this leg starts the chain, and the logger for a start that clears a credential
|
|
203
|
+
* @mutates Hono context - resets `REQUEST_CONTEXT_KEY` (and `RESOLVED_AUTH_KEY` when it starts the chain), then on a valid session (and no credential already resolved) sets `RESOLVED_AUTH_KEY`
|
|
230
204
|
*/
|
|
231
|
-
export const create_request_context_middleware = (deps,
|
|
205
|
+
export const create_request_context_middleware = (deps, options = {}) => {
|
|
206
|
+
const { session_context_key = 'auth_session_id', starts_chain = true, log } = options;
|
|
232
207
|
return async (c, next) => {
|
|
233
208
|
c.set(REQUEST_CONTEXT_KEY, null);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
209
|
+
if (starts_chain) {
|
|
210
|
+
const cleared = get_resolved_auth(c);
|
|
211
|
+
if (cleared !== null) {
|
|
212
|
+
log?.debug(`session leg cleared a credential (${cleared.credential_type}) set before it ` +
|
|
213
|
+
'(an earlier credential leg needs `starts_chain: false` behind it)');
|
|
214
|
+
}
|
|
215
|
+
c.set(RESOLVED_AUTH_KEY, null);
|
|
216
|
+
}
|
|
217
|
+
if (get_resolved_auth(c) !== null) {
|
|
218
|
+
await next();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
239
221
|
const session_token = c.get(session_context_key) ?? null;
|
|
240
222
|
if (!session_token) {
|
|
241
223
|
await next();
|
|
242
224
|
return;
|
|
243
225
|
}
|
|
244
|
-
const
|
|
245
|
-
const session = await query_session_get_valid(deps,
|
|
226
|
+
const session_hash = hash_session_token(session_token);
|
|
227
|
+
const session = await query_session_get_valid(deps, session_hash);
|
|
246
228
|
if (!session) {
|
|
247
229
|
await next();
|
|
248
230
|
return;
|
|
249
231
|
}
|
|
250
|
-
c.set(ACCOUNT_ID_KEY, session.account_id);
|
|
251
|
-
c.set(CREDENTIAL_TYPE_KEY, 'session');
|
|
252
|
-
// A session is full account authority by construction.
|
|
253
|
-
c.set(TOKEN_SCOPE_KEY, token_scope_full());
|
|
254
|
-
c.set(AUTH_SESSION_TOKEN_HASH_KEY, token_hash);
|
|
255
232
|
// The earlier of the signed cookie's expiry (this server's wall clock,
|
|
256
233
|
// which signed it) and the row's (read on the database clock).
|
|
257
234
|
const cookie_expires_at = c.get(SESSION_COOKIE_EXPIRES_AT_KEY) ?? null;
|
|
258
|
-
c.set(
|
|
259
|
-
|
|
260
|
-
session.
|
|
261
|
-
|
|
235
|
+
c.set(RESOLVED_AUTH_KEY, {
|
|
236
|
+
credential_type: 'session',
|
|
237
|
+
account_id: session.account_id,
|
|
238
|
+
session_hash,
|
|
239
|
+
credential_deadline: credential_deadline_after([
|
|
240
|
+
cookie_expires_at === null ? null : cookie_expires_at * 1000 - Date.now(),
|
|
241
|
+
session.expires_in_ms
|
|
242
|
+
])
|
|
243
|
+
});
|
|
262
244
|
await next();
|
|
263
245
|
};
|
|
264
246
|
};
|
|
265
247
|
/**
|
|
266
|
-
* Refuse a
|
|
267
|
-
*
|
|
268
|
-
* The decision every token-scope gate outside the action dispatcher shares.
|
|
269
|
-
* Private because the two exported forms below are the whole surface: a route
|
|
270
|
-
* spec declares `auth.required_scope` and gets `require_token_scope`; anything
|
|
271
|
-
* that is not a route spec calls `token_scope_surface_denial`.
|
|
248
|
+
* Refuse a non-RPC surface to a narrowed token — rule 3. Under the Rust twin's
|
|
249
|
+
* name (`token_scope_surface_denied_response`).
|
|
272
250
|
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*/
|
|
278
|
-
const token_scope_denial = (c, capability) => {
|
|
279
|
-
const scope = c.get(TOKEN_SCOPE_KEY);
|
|
280
|
-
if (scope && !token_scope_admits_capability(scope, capability)) {
|
|
281
|
-
return c.json(token_scope_denied_body(capability.capability), 403);
|
|
282
|
-
}
|
|
283
|
-
return null;
|
|
284
|
-
};
|
|
285
|
-
/**
|
|
286
|
-
* Refuse a non-RPC surface to a narrowed token — rule 3, for callers that are
|
|
287
|
-
* not route specs. Under the Rust twin's name
|
|
288
|
-
* (`token_scope_surface_denied_response`).
|
|
251
|
+
* The decision every token-scope gate outside the action dispatcher shares: a
|
|
252
|
+
* route spec declares `auth.required_scope` and gets `require_token_scope`,
|
|
253
|
+
* which calls this; a consumer gating something that is not a route spec calls
|
|
254
|
+
* it directly.
|
|
289
255
|
*
|
|
290
|
-
* The
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* declaration. A consumer hand-rolling its own upgrade is in the same position
|
|
294
|
-
* and reaches for the same function.
|
|
256
|
+
* The anonymous caller holds no credential to narrow, so it passes
|
|
257
|
+
* (`resolved_auth_scope` answers `null`). Sharing that branch is the point —
|
|
258
|
+
* hand-rolled per surface it is one `&&` from refusing every anonymous read.
|
|
295
259
|
*
|
|
296
260
|
* Takes the whole capability string, not a bare surface name — one spelling
|
|
297
261
|
* across route-spec declarations and direct calls alike, and the twin of the
|
|
@@ -307,7 +271,13 @@ const token_scope_denial = (c, capability) => {
|
|
|
307
271
|
* @param capability - the `surface:<name>` this route demands; names itself in the denial
|
|
308
272
|
* @returns the 403 to return, or `null` when the caller may proceed
|
|
309
273
|
*/
|
|
310
|
-
export const token_scope_surface_denial = (c, capability) =>
|
|
274
|
+
export const token_scope_surface_denial = (c, capability) => {
|
|
275
|
+
const scope = resolved_auth_scope(get_resolved_auth(c));
|
|
276
|
+
if (scope !== null && !token_scope_admits_non_rpc(scope)) {
|
|
277
|
+
return c.json(token_scope_denied_body(capability), 403);
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
};
|
|
311
281
|
/**
|
|
312
282
|
* The account id a public route — one that answers anonymous callers and reads
|
|
313
283
|
* the credential (`reads_credential`) — may act on: `null` for the anonymous
|
|
@@ -321,7 +291,7 @@ export const token_scope_surface_denial = (c, capability) => token_scope_denial(
|
|
|
321
291
|
* would enforce nothing — the holder drops the `Authorization` header and
|
|
322
292
|
* reads the anonymous answer anyway — so the narrowed token *is* the
|
|
323
293
|
* anonymous caller there. Read the credential through this on any
|
|
324
|
-
* `reads_credential` route instead of `
|
|
294
|
+
* `reads_credential` route instead of `get_resolved_auth` directly, so the
|
|
325
295
|
* downgrade is one decision rather than an `&&` hand-rolled per handler.
|
|
326
296
|
*
|
|
327
297
|
* The RPC endpoint is the exception: its dispatcher gates each method against
|
|
@@ -331,13 +301,12 @@ export const token_scope_surface_denial = (c, capability) => token_scope_denial(
|
|
|
331
301
|
* @returns the account id, or `null` for an anonymous caller or a narrowed token
|
|
332
302
|
*/
|
|
333
303
|
export const get_public_account_id = (c) => {
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
304
|
+
const auth = get_resolved_auth(c);
|
|
305
|
+
if (auth === null)
|
|
336
306
|
return null;
|
|
337
|
-
|
|
338
|
-
if (scope && !token_scope_admits_non_rpc(scope))
|
|
307
|
+
if (!token_scope_admits_non_rpc(resolved_auth_scope(auth)))
|
|
339
308
|
return null;
|
|
340
|
-
return account_id;
|
|
309
|
+
return auth.account_id;
|
|
341
310
|
};
|
|
342
311
|
/**
|
|
343
312
|
* Create middleware refusing a route to a credential whose scope does not admit
|
|
@@ -351,17 +320,20 @@ export const get_public_account_id = (c) => {
|
|
|
351
320
|
* Parses at construction, so a malformed capability is a registration-time
|
|
352
321
|
* throw rather than a guard that mounts and reports nonsense.
|
|
353
322
|
*
|
|
323
|
+
* Only the `surface:<name>` arm is accepted (`is_route_scope_capability`): an
|
|
324
|
+
* `rpc:<method>` capability is the dispatcher's per-method gate, which a route
|
|
325
|
+
* never reaches.
|
|
326
|
+
*
|
|
354
327
|
* @param capability - the capability string this route demands, e.g. `surface:audit_stream`
|
|
355
|
-
* @returns middleware that 403s a
|
|
356
|
-
* @throws Error if `capability` is not a well-formed `
|
|
328
|
+
* @returns middleware that 403s a narrowed token
|
|
329
|
+
* @throws Error if `capability` is not a well-formed `surface:<name>` string
|
|
357
330
|
*/
|
|
358
331
|
export const require_token_scope = (capability) => {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
throw new Error(`auth.required_scope "${capability}" is not a valid token-scope capability \u2014 expected 'rpc:<method>' or 'surface:<name>', where a surface name is lowercase letters and underscores`);
|
|
332
|
+
if (!is_route_scope_capability(capability)) {
|
|
333
|
+
throw new Error(`auth.required_scope "${capability}" is not a valid token-scope capability for a route \u2014 expected 'surface:<name>', where a surface name is lowercase letters and underscores ('rpc:<method>' is the action dispatcher's per-method gate, which a route never reaches)`);
|
|
362
334
|
}
|
|
363
335
|
return async (c, next) => {
|
|
364
|
-
const denied =
|
|
336
|
+
const denied = token_scope_surface_denial(c, capability);
|
|
365
337
|
if (denied)
|
|
366
338
|
return denied;
|
|
367
339
|
await next();
|
|
@@ -370,10 +342,10 @@ export const require_token_scope = (capability) => {
|
|
|
370
342
|
/**
|
|
371
343
|
* Middleware that requires authentication.
|
|
372
344
|
*
|
|
373
|
-
* Returns 401 if the auth middleware
|
|
345
|
+
* Returns 401 if the auth middleware resolved no credential.
|
|
374
346
|
*/
|
|
375
347
|
export const require_auth = async (c, next) => {
|
|
376
|
-
if (c
|
|
348
|
+
if (get_resolved_auth(c) === null) {
|
|
377
349
|
return c.json({ error: ERROR_AUTHENTICATION_REQUIRED }, 401);
|
|
378
350
|
}
|
|
379
351
|
await next();
|
|
@@ -391,9 +363,8 @@ export const require_auth = async (c, next) => {
|
|
|
391
363
|
* **global / unscoped role_grants only**. A scoped role_grant
|
|
392
364
|
* (`{role: 'admin', scope_id: <some uuid>}`) does not unlock route-spec
|
|
393
365
|
* gates that are inherently global. The same scope-aware check is
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
* transports agree.
|
|
366
|
+
* run in `actions/perform_action.ts`, the core both the HTTP RPC and WS
|
|
367
|
+
* dispatchers call, so the transports agree.
|
|
397
368
|
*
|
|
398
369
|
* Multi-role disjunction (any-of) lets `auth.roles: ['admin', 'steward']`
|
|
399
370
|
* specs translate to one middleware that admits either role. Single-role
|
|
@@ -403,7 +374,7 @@ export const require_auth = async (c, next) => {
|
|
|
403
374
|
*/
|
|
404
375
|
export const require_role = (roles) => {
|
|
405
376
|
return async (c, next) => {
|
|
406
|
-
if (c
|
|
377
|
+
if (get_resolved_auth(c) === null) {
|
|
407
378
|
return c.json({ error: ERROR_AUTHENTICATION_REQUIRED }, 401);
|
|
408
379
|
}
|
|
409
380
|
const ctx = get_request_context(c);
|
|
@@ -421,8 +392,8 @@ export const require_role = (roles) => {
|
|
|
421
392
|
* `ERROR_CREDENTIAL_TYPE_REQUIRED` + `required_credential_types` echoing
|
|
422
393
|
* the spec's allowlist when the wire-side credential isn't in it.
|
|
423
394
|
*
|
|
424
|
-
* Reads only
|
|
425
|
-
*
|
|
395
|
+
* Reads only the credential the auth middleware resolved (`get_resolved_auth`)
|
|
396
|
+
* — never the resolved `RequestContext`. That is why
|
|
426
397
|
* `fuz_auth_guard_resolver` mounts it in the `pre_authorization` phase: a
|
|
427
398
|
* wrong channel is refused before the route resolves an actor for it, so the
|
|
428
399
|
* denial costs no DB work and discloses no account state.
|
|
@@ -437,11 +408,11 @@ export const require_role = (roles) => {
|
|
|
437
408
|
*/
|
|
438
409
|
export const require_credential_types = (credential_types) => {
|
|
439
410
|
return async (c, next) => {
|
|
440
|
-
|
|
411
|
+
const auth = get_resolved_auth(c);
|
|
412
|
+
if (auth === null) {
|
|
441
413
|
return c.json({ error: ERROR_AUTHENTICATION_REQUIRED }, 401);
|
|
442
414
|
}
|
|
443
|
-
|
|
444
|
-
if (!credential_type || !credential_types.includes(credential_type)) {
|
|
415
|
+
if (!credential_types.includes(auth.credential_type)) {
|
|
445
416
|
return c.json({
|
|
446
417
|
error: ERROR_CREDENTIAL_TYPE_REQUIRED,
|
|
447
418
|
required_credential_types: credential_types
|
|
@@ -604,6 +575,47 @@ export const apply_authorization_phase = async (deps, account_id, auth, acting_v
|
|
|
604
575
|
return { ok: false, status: 500, body: { error: ERROR_ACCOUNT_VANISHED } };
|
|
605
576
|
return { ok: true, request_context: ctx };
|
|
606
577
|
};
|
|
578
|
+
/**
|
|
579
|
+
* Run the authorization phase on a Hono request: resolve the acting actor from
|
|
580
|
+
* `acting` against the authenticated account, and set the resulting
|
|
581
|
+
* `RequestContext` on `REQUEST_CONTEXT_KEY` for the post-authorization guards
|
|
582
|
+
* (`require_role`, `require_credential_types`) and the handler.
|
|
583
|
+
*
|
|
584
|
+
* The phase every Hono-mounted surface shares — the route-spec handler
|
|
585
|
+
* (`create_fuz_authorization_handler`) and the WebSocket upgrade
|
|
586
|
+
* (`register_action_ws`, which reads `acting` off the query string). The HTTP
|
|
587
|
+
* RPC and WS dispatchers consume `apply_authorization_phase` per action
|
|
588
|
+
* directly instead.
|
|
589
|
+
*
|
|
590
|
+
* Skipped for a public `auth` shape, and under the test-preset escape hatch:
|
|
591
|
+
* harnesses that pre-populate `REQUEST_CONTEXT_KEY` flag
|
|
592
|
+
* `TEST_CONTEXT_PRESET_KEY = true` so the phase trusts the supplied context
|
|
593
|
+
* instead of running DB-backed resolution. Production middleware never sets
|
|
594
|
+
* that flag.
|
|
595
|
+
*
|
|
596
|
+
* @param c - the request context, after the pre-authorization guards
|
|
597
|
+
* @param deps - query deps for actor resolution
|
|
598
|
+
* @param auth - the route's auth shape
|
|
599
|
+
* @param acting - the `acting` selector, already through `parse_acting`; `undefined` when absent
|
|
600
|
+
* @returns the refusal to answer (`400` actor selection, `500` a vanished
|
|
601
|
+
* account), or nothing when the request may proceed
|
|
602
|
+
*/
|
|
603
|
+
export const run_authorization_phase = async (c, deps, auth, acting) => {
|
|
604
|
+
if (c.get(TEST_CONTEXT_PRESET_KEY))
|
|
605
|
+
return;
|
|
606
|
+
if (is_public_auth(auth))
|
|
607
|
+
return;
|
|
608
|
+
const account_id = get_resolved_auth(c)?.account_id ?? null;
|
|
609
|
+
const result = await apply_authorization_phase(deps, account_id, auth, acting);
|
|
610
|
+
if (!result.ok)
|
|
611
|
+
return c.json(result.body, result.status);
|
|
612
|
+
if (result.request_context !== null) {
|
|
613
|
+
c.set(REQUEST_CONTEXT_KEY, result.request_context);
|
|
614
|
+
}
|
|
615
|
+
// `request_context: null` — public action or unauthenticated optional axis.
|
|
616
|
+
// Leave `REQUEST_CONTEXT_KEY` null; downstream `require_role` /
|
|
617
|
+
// `require_credential_types` enforce.
|
|
618
|
+
};
|
|
607
619
|
/**
|
|
608
620
|
* Create the route-spec authorization handler used by `apply_route_specs`.
|
|
609
621
|
*
|
|
@@ -625,26 +637,11 @@ export const apply_authorization_phase = async (deps, account_id, auth, acting_v
|
|
|
625
637
|
*/
|
|
626
638
|
export const create_fuz_authorization_handler = (deps) => {
|
|
627
639
|
return async (c, spec) => {
|
|
628
|
-
//
|
|
629
|
-
|
|
630
|
-
// trusts the supplied context instead of running DB-backed resolution.
|
|
631
|
-
// Production middleware never sets this flag.
|
|
632
|
-
if (c.get(TEST_CONTEXT_PRESET_KEY))
|
|
633
|
-
return;
|
|
634
|
-
if (is_public_auth(spec.auth))
|
|
640
|
+
// the same skips `run_authorization_phase` makes, ahead of reading a body
|
|
641
|
+
if (c.get(TEST_CONTEXT_PRESET_KEY) || is_public_auth(spec.auth))
|
|
635
642
|
return;
|
|
636
643
|
const acting_value = needs_actor(spec.auth) ? await read_route_acting(c, spec) : undefined;
|
|
637
|
-
|
|
638
|
-
const result = await apply_authorization_phase(deps, account_id, spec.auth, acting_value);
|
|
639
|
-
if (!result.ok)
|
|
640
|
-
return c.json(result.body, result.status);
|
|
641
|
-
if (result.request_context !== null) {
|
|
642
|
-
c.set(REQUEST_CONTEXT_KEY, result.request_context);
|
|
643
|
-
}
|
|
644
|
-
// `request_context: null` — public action or unauthenticated optional axis.
|
|
645
|
-
// Leave `REQUEST_CONTEXT_KEY` null; downstream `require_role` /
|
|
646
|
-
// `require_credential_types` enforce.
|
|
647
|
-
return;
|
|
644
|
+
return run_authorization_phase(c, deps, spec.auth, acting_value);
|
|
648
645
|
};
|
|
649
646
|
};
|
|
650
647
|
/**
|
|
@@ -2,35 +2,30 @@
|
|
|
2
2
|
* The account-grain credential a request resolved to, and the re-check a
|
|
3
3
|
* long-lived connection runs on it once it is registered.
|
|
4
4
|
*
|
|
5
|
-
* The auth middleware chain
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* The auth middleware chain resolves at most one credential per request —
|
|
6
|
+
* daemon token, then session cookie, then bearer, the first that
|
|
7
|
+
* authenticates winning — and leaves it on the Hono context as one value,
|
|
8
|
+
* `ResolvedAuth` (`RESOLVED_AUTH_KEY`, read with `get_resolved_auth`). Every
|
|
9
|
+
* reader takes that value, so the connections that outlive their request — a
|
|
10
|
+
* WebSocket, an SSE stream — carry it past the handshake, re-read it with
|
|
11
|
+
* `revalidate_resolved_auth` (or the whole admission re-check,
|
|
12
|
+
* `recheck_admission`), and close at its `credential_deadline`.
|
|
11
13
|
*
|
|
12
14
|
* @module
|
|
13
15
|
*/
|
|
14
16
|
import type { Context } from 'hono';
|
|
15
17
|
import type { QueryDeps } from '../db/query_deps.js';
|
|
16
|
-
import { type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
account_id: string;
|
|
28
|
-
/** How the request was authenticated. */
|
|
29
|
-
credential_type: CredentialType;
|
|
30
|
-
/** Blake3 hash of the session token, or `null` for non-session credentials. */
|
|
31
|
-
token_hash: string | null;
|
|
32
|
-
/** `api_token.id` for a bearer credential, else `null`. */
|
|
33
|
-
api_token_id: string | null;
|
|
18
|
+
import { type RequestContext } from './request_context.js';
|
|
19
|
+
import { type TokenScope } from './token_scope.js';
|
|
20
|
+
/** The fields every resolved credential carries. */
|
|
21
|
+
interface ResolvedAuthBase {
|
|
22
|
+
/**
|
|
23
|
+
* The authenticated account. Its id, not its row — the twin of the Rust
|
|
24
|
+
* spine's `ResolvedAuth::account`, which loads the row as it resolves. Here
|
|
25
|
+
* the middleware stays one query per credential and the authorization phase
|
|
26
|
+
* loads the account when a route needs it.
|
|
27
|
+
*/
|
|
28
|
+
readonly account_id: string;
|
|
34
29
|
/**
|
|
35
30
|
* When the credential stops authenticating, as a monotonic
|
|
36
31
|
* `performance.now()` timestamp — the moment a long-lived connection opened
|
|
@@ -41,15 +36,65 @@ export interface ResolvedAuth {
|
|
|
41
36
|
* expiry is read as time remaining on the database clock
|
|
42
37
|
* (`auth/credential_deadline.ts`). The Rust twin's `credential_deadline`.
|
|
43
38
|
*/
|
|
44
|
-
credential_deadline: number | null;
|
|
39
|
+
readonly credential_deadline: number | null;
|
|
40
|
+
}
|
|
41
|
+
/** A session cookie — full account authority by construction. */
|
|
42
|
+
export interface ResolvedSessionAuth extends ResolvedAuthBase {
|
|
43
|
+
readonly credential_type: 'session';
|
|
44
|
+
/** Blake3 hash of the session token — the `auth_session.id`. */
|
|
45
|
+
readonly session_hash: string;
|
|
46
|
+
}
|
|
47
|
+
/** An `Authorization: Bearer` API token — the only credential a scope narrows. */
|
|
48
|
+
export interface ResolvedApiTokenAuth extends ResolvedAuthBase {
|
|
49
|
+
readonly credential_type: 'api_token';
|
|
50
|
+
/** The `api_token.id`. */
|
|
51
|
+
readonly api_token_id: string;
|
|
52
|
+
/** The authority the token was minted with, read off its row. */
|
|
53
|
+
readonly scope: TokenScope;
|
|
54
|
+
}
|
|
55
|
+
/** The keeper-bound daemon token — full authority, no row, no expiry. */
|
|
56
|
+
export interface ResolvedDaemonTokenAuth extends ResolvedAuthBase {
|
|
57
|
+
readonly credential_type: 'daemon_token';
|
|
58
|
+
readonly credential_deadline: null;
|
|
45
59
|
}
|
|
46
60
|
/**
|
|
47
|
-
*
|
|
61
|
+
* An authenticated request's credential, account-grain — no actor.
|
|
62
|
+
*
|
|
63
|
+
* One arm per credential type, each carrying only what belongs to it: the
|
|
64
|
+
* session hash on a session, the token id and scope on an API token, so a
|
|
65
|
+
* session with a narrowed scope or a bearer with a session hash cannot be
|
|
66
|
+
* built. The twin of the Rust spine's `ResolvedAuth`, whose
|
|
67
|
+
* `ResolvedCredential` enum holds the same correlation.
|
|
68
|
+
*/
|
|
69
|
+
export type ResolvedAuth = ResolvedSessionAuth | ResolvedApiTokenAuth | ResolvedDaemonTokenAuth;
|
|
70
|
+
/**
|
|
71
|
+
* The credential's authority narrowing: an API token's own scope, `full` for a
|
|
72
|
+
* session or the daemon token (a browser session *is* full account authority —
|
|
73
|
+
* narrowing it is what role grants are for — and the daemon token is singular,
|
|
74
|
+
* filesystem-proved, and keeper-bound). `null` only for the anonymous caller,
|
|
75
|
+
* who holds no credential to narrow. Every token-scope gate reads this. The twin
|
|
76
|
+
* of the Rust spine's `ResolvedAuth::scope`.
|
|
77
|
+
*
|
|
78
|
+
* @param auth - the resolved credential, or `null` for an anonymous caller
|
|
79
|
+
* @returns the scope, or `null` for an anonymous caller
|
|
80
|
+
*/
|
|
81
|
+
export declare const resolved_auth_scope: (auth: ResolvedAuth | null) => TokenScope | null;
|
|
82
|
+
/**
|
|
83
|
+
* The session hash of a session credential, `null` for any other (or none).
|
|
84
|
+
*
|
|
85
|
+
* @param auth - the resolved credential, or `null` for an anonymous caller
|
|
86
|
+
* @returns the `auth_session.id`, or `null`
|
|
87
|
+
*/
|
|
88
|
+
export declare const resolved_auth_session_hash: (auth: ResolvedAuth | null) => string | null;
|
|
89
|
+
/**
|
|
90
|
+
* The token id of an API token credential, `null` for any other (or none).
|
|
48
91
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
92
|
+
* @param auth - the resolved credential, or `null` for an anonymous caller
|
|
93
|
+
* @returns the `api_token.id`, or `null`
|
|
94
|
+
*/
|
|
95
|
+
export declare const resolved_auth_api_token_id: (auth: ResolvedAuth | null) => string | null;
|
|
96
|
+
/**
|
|
97
|
+
* The credential the auth middleware resolved for this request.
|
|
53
98
|
*
|
|
54
99
|
* @param c - the request context, after the auth middleware chain
|
|
55
100
|
* @returns the resolved credential, or `null` for an unauthenticated request
|
|
@@ -63,8 +108,8 @@ export declare const get_resolved_auth: (c: Context) => ResolvedAuth | null;
|
|
|
63
108
|
* and is authorized once, at open. Such a connection is closed on revocation
|
|
64
109
|
* by identity, but only once it is *registered*; between the credential read
|
|
65
110
|
* and the registration a revocation closes nothing. So the opener registers
|
|
66
|
-
* first (un-admitted — `
|
|
67
|
-
* `
|
|
111
|
+
* first (un-admitted — `ConnectionRegistry.register_pending` /
|
|
112
|
+
* `SseRegistry.subscribe_pending`), then calls this, then admits. A
|
|
68
113
|
* revocation that committed before this read is seen by it; one whose close
|
|
69
114
|
* ran after the registration found the pending entry.
|
|
70
115
|
*
|
|
@@ -100,10 +145,6 @@ export declare const get_resolved_auth: (c: Context) => ResolvedAuth | null;
|
|
|
100
145
|
* `api_token.last_used_at` / `last_used_ip` — re-checking a credential is not
|
|
101
146
|
* using it — and it writes nothing else.
|
|
102
147
|
*
|
|
103
|
-
* A `ResolvedAuth` whose credential type lacks its own key (a session with no
|
|
104
|
-
* `token_hash`, a bearer with no `api_token_id`) is a shape the middleware
|
|
105
|
-
* never builds; it is answered `false`.
|
|
106
|
-
*
|
|
107
148
|
* The twin of the Rust spine's `revalidate_resolved_auth`.
|
|
108
149
|
*
|
|
109
150
|
* @param deps - query dependencies; the pool-level `Db`, not a snapshot transaction
|
|
@@ -113,4 +154,49 @@ export declare const get_resolved_auth: (c: Context) => ResolvedAuth | null;
|
|
|
113
154
|
* unchecked credential is not a valid one.
|
|
114
155
|
*/
|
|
115
156
|
export declare const revalidate_resolved_auth: (deps: QueryDeps, resolved: ResolvedAuth) => Promise<boolean>;
|
|
157
|
+
/**
|
|
158
|
+
* What `recheck_admission` found: `'admitted'`, or the first check that
|
|
159
|
+
* refused — the credential, the acting actor, or the endpoint's role.
|
|
160
|
+
*/
|
|
161
|
+
export type AdmissionRecheck = 'admitted' | 'credential_revoked' | 'actor_inactive' | 'role_revoked';
|
|
162
|
+
/** The connection being admitted, for `recheck_admission`. */
|
|
163
|
+
export interface RecheckAdmissionInput {
|
|
164
|
+
/** The credential the request authenticated with (`get_resolved_auth`). */
|
|
165
|
+
resolved: ResolvedAuth;
|
|
166
|
+
/** The request context the upgrade's gates ran against — its acting actor is re-read. */
|
|
167
|
+
request_context: RequestContext;
|
|
168
|
+
/**
|
|
169
|
+
* The roles the connection's gate required, any-of; `[]` for an ungated
|
|
170
|
+
* connection. A global grant of any of them admits, as the gate did.
|
|
171
|
+
*/
|
|
172
|
+
required_roles: ReadonlyArray<string>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Re-read everything a long-lived connection's gates read, once the
|
|
176
|
+
* connection is registered pending — the admission step a WebSocket upgrade
|
|
177
|
+
* and the audit stream share (twin of the Rust spine's admission re-check).
|
|
178
|
+
*
|
|
179
|
+
* In order, stopping at the first refusal:
|
|
180
|
+
*
|
|
181
|
+
* 1. **The credential** (`revalidate_resolved_auth`) → `'credential_revoked'`.
|
|
182
|
+
* 2. **The acting actor** the gates resolved, when there is one: it must still
|
|
183
|
+
* be an active actor of the account → `'actor_inactive'`. A soft-deleted
|
|
184
|
+
* actor keeps its account's credentials and its own grant rows, so neither
|
|
185
|
+
* other re-read would refuse it.
|
|
186
|
+
* 3. **The role**, when `required_roles` is non-empty: the acting actor's
|
|
187
|
+
* grants read afresh (`refresh_role_grants`), a **global** grant of any
|
|
188
|
+
* listed role admitting → `'role_revoked'`. A scoped grant never admits at
|
|
189
|
+
* a role gate.
|
|
190
|
+
*
|
|
191
|
+
* Every read must see what committed before it started, so `deps.db` is the
|
|
192
|
+
* pool-level `Db` (see `revalidate_resolved_auth`).
|
|
193
|
+
*
|
|
194
|
+
* @param deps - query dependencies; the pool-level `Db`
|
|
195
|
+
* @param input - the credential, the gates' request context, and the required roles
|
|
196
|
+
* @returns `'admitted'`, or which check refused
|
|
197
|
+
* @throws Error propagated from the database. The caller must fail closed — an
|
|
198
|
+
* unchecked connection is not an admitted one.
|
|
199
|
+
*/
|
|
200
|
+
export declare const recheck_admission: (deps: QueryDeps, input: RecheckAdmissionInput) => Promise<AdmissionRecheck>;
|
|
201
|
+
export {};
|
|
116
202
|
//# sourceMappingURL=resolved_auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolved_auth.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/resolved_auth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"resolved_auth.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/resolved_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErE,oDAAoD;AACpD,UAAU,gBAAgB;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;OASG;IACH,QAAQ,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED,iEAAiE;AACjE,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC5D,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC;IACpC,gEAAgE;IAChE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC9B;AAED,kFAAkF;AAClF,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC7D,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC;IACtC,0BAA0B;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC3B;AAED,yEAAyE;AACzE,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAChE,QAAQ,CAAC,eAAe,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,oBAAoB,GAAG,uBAAuB,CAAC;AAEhG;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,YAAY,GAAG,IAAI,KAAG,UAAU,GAAG,IAG5E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM,YAAY,GAAG,IAAI,KAAG,MAAM,GAAG,IACjB,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM,YAAY,GAAG,IAAI,KAAG,MAAM,GAAG,IACf,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,OAAO,KAAG,YAAY,GAAG,IAC7B,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,SAAS,EACf,UAAU,YAAY,KACpB,OAAO,CAAC,OAAO,CAoBjB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAC3B,UAAU,GAAG,oBAAoB,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAEvE,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IACrC,2EAA2E;IAC3E,QAAQ,EAAE,YAAY,CAAC;IACvB,yFAAyF;IACzF,eAAe,EAAE,cAAc,CAAC;IAChC;;;OAGG;IACH,cAAc,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,iBAAiB,GAC7B,MAAM,SAAS,EACf,OAAO,qBAAqB,KAC1B,OAAO,CAAC,gBAAgB,CAa1B,CAAC"}
|