@fuzdev/fuz_app 0.50.0 → 0.52.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/dist/actions/CLAUDE.md +16 -3
- package/dist/actions/action_bridge.d.ts +3 -1
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +3 -1
- package/dist/actions/action_codegen.d.ts +44 -13
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +58 -20
- package/dist/actions/action_event.d.ts +44 -1
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +44 -1
- package/dist/actions/action_event_helpers.d.ts +26 -0
- package/dist/actions/action_event_helpers.d.ts.map +1 -1
- package/dist/actions/action_event_helpers.js +26 -1
- package/dist/actions/action_peer.d.ts +17 -0
- package/dist/actions/action_peer.d.ts.map +1 -1
- package/dist/actions/action_peer.js +8 -0
- package/dist/actions/action_registry.d.ts +2 -2
- package/dist/actions/action_registry.js +2 -2
- package/dist/actions/action_rpc.d.ts +4 -0
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +4 -0
- package/dist/actions/action_spec.d.ts +23 -3
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +17 -3
- package/dist/actions/action_types.d.ts +2 -2
- package/dist/actions/action_types.js +2 -2
- package/dist/actions/cancel.d.ts +2 -2
- package/dist/actions/cancel.js +2 -2
- package/dist/actions/heartbeat.d.ts +2 -2
- package/dist/actions/heartbeat.js +2 -2
- package/dist/actions/protocol.d.ts +1 -1
- package/dist/actions/protocol.js +1 -1
- package/dist/actions/register_action_ws.d.ts +4 -1
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +4 -1
- package/dist/actions/register_ws_endpoint.d.ts +3 -0
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +3 -0
- package/dist/actions/request_tracker.svelte.d.ts +14 -1
- package/dist/actions/request_tracker.svelte.d.ts.map +1 -1
- package/dist/actions/request_tracker.svelte.js +14 -1
- package/dist/actions/socket.svelte.d.ts +35 -15
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +33 -13
- package/dist/actions/transports.d.ts +12 -3
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +16 -7
- package/dist/actions/transports_http.d.ts +7 -0
- package/dist/actions/transports_http.d.ts.map +1 -1
- package/dist/actions/transports_http.js +7 -0
- package/dist/actions/transports_ws.d.ts +13 -0
- package/dist/actions/transports_ws.d.ts.map +1 -1
- package/dist/actions/transports_ws.js +13 -0
- package/dist/actions/transports_ws_auth_guard.d.ts +6 -2
- package/dist/actions/transports_ws_auth_guard.d.ts.map +1 -1
- package/dist/actions/transports_ws_auth_guard.js +6 -2
- package/dist/actions/transports_ws_backend.d.ts +14 -1
- package/dist/actions/transports_ws_backend.d.ts.map +1 -1
- package/dist/actions/transports_ws_backend.js +14 -1
- package/dist/auth/CLAUDE.md +40 -4
- 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 +10 -0
- package/dist/auth/account_routes.d.ts +3 -3
- package/dist/auth/account_routes.js +3 -3
- package/dist/auth/account_schema.d.ts +1 -1
- package/dist/auth/account_schema.js +1 -1
- package/dist/auth/admin_actions.d.ts +1 -0
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +1 -0
- package/dist/auth/api_token.d.ts +1 -1
- package/dist/auth/api_token.js +1 -1
- package/dist/auth/api_token_queries.d.ts +7 -0
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +7 -0
- package/dist/auth/app_settings_queries.d.ts +4 -0
- package/dist/auth/app_settings_queries.d.ts.map +1 -1
- package/dist/auth/app_settings_queries.js +4 -0
- package/dist/auth/audit_log_queries.d.ts +6 -0
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +6 -0
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.js +1 -1
- package/dist/auth/audit_log_schema.d.ts +3 -1
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +134 -55
- package/dist/auth/bearer_auth.d.ts +2 -0
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +2 -0
- package/dist/auth/bootstrap_account.d.ts +3 -0
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +3 -0
- package/dist/auth/cleanup.d.ts +6 -0
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +6 -0
- package/dist/auth/daemon_token.d.ts +1 -1
- package/dist/auth/daemon_token.js +1 -1
- package/dist/auth/daemon_token_middleware.d.ts +5 -1
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +5 -1
- package/dist/auth/ddl.d.ts +1 -1
- package/dist/auth/ddl.js +1 -1
- package/dist/auth/invite_queries.d.ts +4 -0
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +4 -0
- package/dist/auth/password.d.ts +1 -1
- package/dist/auth/password.js +1 -1
- package/dist/auth/permit_offer_action_specs.d.ts +5 -0
- package/dist/auth/permit_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/permit_offer_action_specs.js +10 -0
- package/dist/auth/permit_offer_queries.d.ts +19 -0
- package/dist/auth/permit_offer_queries.d.ts.map +1 -1
- package/dist/auth/permit_offer_queries.js +19 -0
- package/dist/auth/permit_queries.d.ts +8 -0
- package/dist/auth/permit_queries.d.ts.map +1 -1
- package/dist/auth/permit_queries.js +8 -0
- package/dist/auth/request_context.d.ts +1 -0
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +1 -0
- package/dist/auth/role_schema.d.ts +2 -0
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +2 -0
- package/dist/auth/route_guards.d.ts +1 -1
- package/dist/auth/route_guards.js +1 -1
- package/dist/auth/self_service_role_action_specs.d.ts +1 -1
- package/dist/auth/self_service_role_action_specs.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +2 -1
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +2 -1
- package/dist/auth/session_lifecycle.d.ts +3 -0
- package/dist/auth/session_lifecycle.d.ts.map +1 -1
- package/dist/auth/session_lifecycle.js +3 -0
- package/dist/auth/session_middleware.d.ts +5 -0
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +5 -0
- package/dist/auth/session_queries.d.ts +10 -1
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +10 -1
- package/dist/auth/signup_routes.d.ts +1 -1
- package/dist/auth/signup_routes.js +1 -1
- package/dist/cli/config.d.ts +2 -0
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +2 -0
- package/dist/cli/daemon.d.ts +6 -1
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/daemon.js +6 -1
- package/dist/cli/util.d.ts +1 -1
- package/dist/cli/util.js +1 -1
- package/dist/db/assert_row.d.ts +2 -1
- package/dist/db/assert_row.d.ts.map +1 -1
- package/dist/db/assert_row.js +2 -1
- package/dist/db/create_db.d.ts +5 -2
- package/dist/db/create_db.d.ts.map +1 -1
- package/dist/db/create_db.js +5 -2
- package/dist/db/db.d.ts +22 -7
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +21 -6
- package/dist/db/db_pg.d.ts +2 -1
- package/dist/db/db_pg.d.ts.map +1 -1
- package/dist/db/db_pg.js +5 -3
- package/dist/db/db_pglite.d.ts +3 -2
- package/dist/db/db_pglite.d.ts.map +1 -1
- package/dist/db/db_pglite.js +3 -2
- package/dist/db/migrate.d.ts +8 -4
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +6 -2
- package/dist/db/sql_identifier.d.ts +2 -1
- package/dist/db/sql_identifier.d.ts.map +1 -1
- package/dist/db/sql_identifier.js +2 -1
- package/dist/db/status.d.ts +4 -1
- package/dist/db/status.d.ts.map +1 -1
- package/dist/db/status.js +5 -2
- package/dist/dev/setup.d.ts +18 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +18 -2
- package/dist/env/dotenv.d.ts +2 -1
- package/dist/env/dotenv.d.ts.map +1 -1
- package/dist/env/dotenv.js +2 -1
- package/dist/env/load.d.ts +1 -1
- package/dist/env/load.js +1 -1
- package/dist/env/resolve.d.ts +1 -1
- package/dist/env/resolve.js +1 -1
- package/dist/env/update_env_variable.d.ts +2 -0
- package/dist/env/update_env_variable.d.ts.map +1 -1
- package/dist/env/update_env_variable.js +2 -0
- package/dist/hono_context.d.ts +1 -1
- package/dist/hono_context.js +1 -1
- package/dist/http/jsonrpc_errors.d.ts +2 -2
- package/dist/http/jsonrpc_errors.js +2 -2
- package/dist/http/jsonrpc_helpers.d.ts +2 -2
- package/dist/http/jsonrpc_helpers.js +2 -2
- package/dist/http/middleware_spec.d.ts +1 -1
- package/dist/http/middleware_spec.js +1 -1
- package/dist/http/origin.d.ts +1 -1
- package/dist/http/origin.js +1 -1
- package/dist/http/pending_effects.d.ts +4 -0
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +4 -0
- package/dist/http/proxy.d.ts +3 -0
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +3 -0
- package/dist/http/route_spec.d.ts +1 -0
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +7 -0
- package/dist/http/schema_helpers.d.ts +1 -1
- package/dist/http/schema_helpers.js +1 -1
- package/dist/http/surface.d.ts +1 -1
- package/dist/http/surface.js +1 -1
- package/dist/rate_limiter.d.ts +14 -1
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +14 -1
- package/dist/realtime/sse.d.ts +7 -1
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +3 -1
- package/dist/realtime/sse_auth_guard.d.ts +21 -21
- package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
- package/dist/realtime/sse_auth_guard.js +24 -24
- package/dist/realtime/subscriber_registry.d.ts +4 -2
- package/dist/realtime/subscriber_registry.d.ts.map +1 -1
- package/dist/realtime/subscriber_registry.js +4 -2
- package/dist/runtime/deno.d.ts +1 -1
- package/dist/runtime/deno.js +1 -1
- package/dist/runtime/fs.d.ts +5 -0
- package/dist/runtime/fs.d.ts.map +1 -1
- package/dist/runtime/fs.js +5 -0
- package/dist/runtime/mock.d.ts +6 -0
- package/dist/runtime/mock.d.ts.map +1 -1
- package/dist/runtime/mock.js +6 -0
- package/dist/runtime/node.d.ts +1 -1
- package/dist/runtime/node.js +1 -1
- package/dist/server/app_backend.d.ts +1 -0
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +1 -0
- package/dist/server/app_server.d.ts +4 -0
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +4 -0
- package/dist/server/validate_nginx.d.ts +3 -0
- package/dist/server/validate_nginx.d.ts.map +1 -1
- package/dist/testing/admin_integration.d.ts +5 -0
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +5 -0
- package/dist/testing/adversarial_headers.d.ts +5 -3
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +5 -3
- package/dist/testing/adversarial_input.d.ts +4 -0
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +4 -0
- package/dist/testing/app_server.d.ts +3 -0
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +11 -0
- package/dist/testing/assertions.d.ts +23 -7
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +23 -7
- package/dist/testing/audit_completeness.d.ts +4 -0
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +4 -0
- package/dist/testing/auth_apps.d.ts +3 -0
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +3 -0
- package/dist/testing/db.d.ts +9 -1
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +9 -1
- package/dist/testing/error_coverage.d.ts +9 -0
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +9 -0
- package/dist/testing/integration.d.ts +4 -0
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +4 -0
- package/dist/testing/integration_helpers.d.ts +10 -4
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +10 -4
- package/dist/testing/middleware.d.ts +5 -0
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +5 -0
- package/dist/testing/rate_limiting.d.ts +3 -0
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -0
- package/dist/testing/rpc_attack_surface.js +1 -1
- package/dist/testing/rpc_helpers.d.ts +21 -8
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +22 -9
- package/dist/testing/schema_generators.d.ts +7 -2
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +7 -2
- package/dist/testing/sse_round_trip.d.ts +3 -0
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +3 -0
- package/dist/testing/stubs.d.ts +7 -0
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +7 -0
- package/dist/testing/surface_invariants.d.ts +14 -0
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +14 -0
- package/dist/testing/ws_round_trip.d.ts +13 -1
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +1 -1
- package/dist/ui/AccountSessions.svelte +9 -0
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAccounts.svelte +10 -0
- package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAuditLog.svelte +10 -0
- package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
- package/dist/ui/AdminInvites.svelte +9 -0
- package/dist/ui/AdminInvites.svelte.d.ts.map +1 -1
- package/dist/ui/AdminOverview.svelte +10 -0
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/AdminPermitHistory.svelte +9 -0
- package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSessions.svelte +10 -0
- package/dist/ui/AdminSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSettings.svelte +9 -0
- package/dist/ui/AdminSettings.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSurface.svelte +9 -0
- package/dist/ui/AdminSurface.svelte.d.ts.map +1 -1
- package/dist/ui/AppShell.svelte +24 -0
- package/dist/ui/AppShell.svelte.d.ts +23 -0
- package/dist/ui/AppShell.svelte.d.ts.map +1 -1
- package/dist/ui/BootstrapForm.svelte +17 -0
- package/dist/ui/BootstrapForm.svelte.d.ts +4 -0
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/ColumnLayout.svelte +11 -0
- package/dist/ui/ColumnLayout.svelte.d.ts +10 -0
- package/dist/ui/ColumnLayout.svelte.d.ts.map +1 -1
- package/dist/ui/Datatable.svelte +18 -0
- package/dist/ui/Datatable.svelte.d.ts +17 -0
- package/dist/ui/Datatable.svelte.d.ts.map +1 -1
- package/dist/ui/LoginForm.svelte +18 -0
- package/dist/ui/LoginForm.svelte.d.ts +9 -0
- package/dist/ui/LoginForm.svelte.d.ts.map +1 -1
- package/dist/ui/LogoutButton.svelte +9 -0
- package/dist/ui/LogoutButton.svelte.d.ts +8 -0
- package/dist/ui/LogoutButton.svelte.d.ts.map +1 -1
- package/dist/ui/MenuLink.svelte +10 -0
- package/dist/ui/MenuLink.svelte.d.ts +9 -0
- package/dist/ui/MenuLink.svelte.d.ts.map +1 -1
- package/dist/ui/OpenSignupToggle.svelte +9 -0
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
- package/dist/ui/SignupForm.svelte +16 -0
- package/dist/ui/SignupForm.svelte.d.ts +4 -0
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- package/dist/ui/SurfaceExplorer.svelte +9 -0
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/account_sessions_state.svelte.js +1 -1
- package/dist/ui/admin_rpc_adapters.d.ts +1 -1
- package/dist/ui/admin_rpc_adapters.js +1 -1
- package/dist/ui/audit_log_state.svelte.d.ts +6 -1
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +6 -1
- package/dist/ui/auth_state.svelte.d.ts +16 -4
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +16 -4
- package/dist/ui/form_state.svelte.d.ts +9 -0
- package/dist/ui/form_state.svelte.d.ts.map +1 -1
- package/dist/ui/form_state.svelte.js +9 -0
- package/dist/ui/loadable.svelte.d.ts +6 -1
- package/dist/ui/loadable.svelte.d.ts.map +1 -1
- package/dist/ui/loadable.svelte.js +6 -1
- package/dist/ui/permit_offers_state.svelte.d.ts +2 -0
- package/dist/ui/permit_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/permit_offers_state.svelte.js +2 -0
- package/dist/ui/popover.svelte.d.ts +17 -4
- package/dist/ui/popover.svelte.d.ts.map +1 -1
- package/dist/ui/popover.svelte.js +17 -4
- package/dist/ui/position_helpers.d.ts +1 -0
- package/dist/ui/position_helpers.d.ts.map +1 -1
- package/dist/ui/position_helpers.js +1 -0
- package/dist/ui/sidebar_state.svelte.d.ts +22 -9
- package/dist/ui/sidebar_state.svelte.d.ts.map +1 -1
- package/dist/ui/sidebar_state.svelte.js +17 -2
- package/dist/ui/table_state.svelte.d.ts +14 -0
- package/dist/ui/table_state.svelte.d.ts.map +1 -1
- package/dist/ui/table_state.svelte.js +14 -0
- package/package.json +1 -1
|
@@ -23,11 +23,15 @@ export class BackendWebsocketTransport {
|
|
|
23
23
|
/**
|
|
24
24
|
* Add a new WebSocket connection with auth info.
|
|
25
25
|
* Session connections pass a token hash for targeted revocation.
|
|
26
|
-
* Bearer token connections (api_token) pass the `api_token.id` so the
|
|
26
|
+
* Bearer token connections (`api_token`) pass the `api_token.id` so the
|
|
27
27
|
* socket can be closed when that specific token is revoked without
|
|
28
28
|
* tearing down the account's other sockets. Daemon-token connections
|
|
29
29
|
* pass `null` for both — they're only reachable via
|
|
30
30
|
* `close_sockets_for_account`.
|
|
31
|
+
*
|
|
32
|
+
* @returns the freshly assigned `connection_id` (branded `Uuid`)
|
|
33
|
+
* @mutates this - inserts into `#connections`, `#connection_ids`, and
|
|
34
|
+
* `#connection_identities`
|
|
31
35
|
*/
|
|
32
36
|
add_connection(ws, token_hash, account_id, api_token_id = null) {
|
|
33
37
|
const connection_id = create_uuid();
|
|
@@ -39,6 +43,9 @@ export class BackendWebsocketTransport {
|
|
|
39
43
|
/**
|
|
40
44
|
* Remove a WebSocket connection and its auth tracking data.
|
|
41
45
|
* Idempotent — safe to call after revocation has already cleaned up.
|
|
46
|
+
*
|
|
47
|
+
* @mutates this - deletes the connection's entries from `#connections`,
|
|
48
|
+
* `#connection_ids`, and `#connection_identities`
|
|
42
49
|
*/
|
|
43
50
|
remove_connection(ws) {
|
|
44
51
|
const connection_id = this.#connection_ids.get(ws);
|
|
@@ -68,6 +75,8 @@ export class BackendWebsocketTransport {
|
|
|
68
75
|
* Close all sockets associated with a specific session token hash.
|
|
69
76
|
*
|
|
70
77
|
* @returns the number of sockets closed
|
|
78
|
+
* @mutates this - removes matching connections from internal maps and
|
|
79
|
+
* closes their underlying `WSContext` with `WS_CLOSE_SESSION_REVOKED`
|
|
71
80
|
*/
|
|
72
81
|
close_sockets_for_session(token_hash) {
|
|
73
82
|
return this.#close_where((id) => id.token_hash === token_hash);
|
|
@@ -76,6 +85,8 @@ export class BackendWebsocketTransport {
|
|
|
76
85
|
* Close all sockets associated with a specific account.
|
|
77
86
|
*
|
|
78
87
|
* @returns the number of sockets closed
|
|
88
|
+
* @mutates this - removes matching connections from internal maps and
|
|
89
|
+
* closes their underlying `WSContext` with `WS_CLOSE_SESSION_REVOKED`
|
|
79
90
|
*/
|
|
80
91
|
close_sockets_for_account(account_id) {
|
|
81
92
|
return this.#close_where((id) => id.account_id === account_id);
|
|
@@ -88,6 +99,8 @@ export class BackendWebsocketTransport {
|
|
|
88
99
|
* tokens' sockets.
|
|
89
100
|
*
|
|
90
101
|
* @returns the number of sockets closed
|
|
102
|
+
* @mutates this - removes matching connections from internal maps and
|
|
103
|
+
* closes their underlying `WSContext` with `WS_CLOSE_SESSION_REVOKED`
|
|
91
104
|
*/
|
|
92
105
|
close_sockets_for_token(api_token_id) {
|
|
93
106
|
return this.#close_where((id) => id.api_token_id === api_token_id);
|
package/dist/auth/CLAUDE.md
CHANGED
|
@@ -157,10 +157,39 @@ Separated from runtime types to isolate DDL concerns. Consumed by
|
|
|
157
157
|
|
|
158
158
|
### Audit log (`audit_log_schema.ts`)
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
#### Audit event types
|
|
161
|
+
|
|
162
|
+
`AUDIT_EVENT_TYPES` — 21 events covering auth + permit + offer + invite +
|
|
163
|
+
settings mutations. Offer lifecycle: `permit_offer_create` / `_accept` /
|
|
164
|
+
`_decline` / `_retract` / `_expire` / `_supersede`. `AuditEventType` is the
|
|
165
|
+
Zod enum; `AuditOutcome` is `'success' | 'failure'`.
|
|
166
|
+
|
|
167
|
+
| Event type |
|
|
168
|
+
| ------------------------ |
|
|
169
|
+
| `login` |
|
|
170
|
+
| `logout` |
|
|
171
|
+
| `bootstrap` |
|
|
172
|
+
| `signup` |
|
|
173
|
+
| `password_change` |
|
|
174
|
+
| `session_revoke` |
|
|
175
|
+
| `session_revoke_all` |
|
|
176
|
+
| `token_create` |
|
|
177
|
+
| `token_revoke` |
|
|
178
|
+
| `token_revoke_all` |
|
|
179
|
+
| `permit_grant` |
|
|
180
|
+
| `permit_revoke` |
|
|
181
|
+
| `permit_offer_create` |
|
|
182
|
+
| `permit_offer_accept` |
|
|
183
|
+
| `permit_offer_decline` |
|
|
184
|
+
| `permit_offer_retract` |
|
|
185
|
+
| `permit_offer_expire` |
|
|
186
|
+
| `permit_offer_supersede` |
|
|
187
|
+
| `invite_create` |
|
|
188
|
+
| `invite_delete` |
|
|
189
|
+
| `app_settings_update` |
|
|
190
|
+
|
|
191
|
+
#### Metadata schemas
|
|
192
|
+
|
|
164
193
|
- `AUDIT_METADATA_SCHEMAS` — per-type `z.looseObject`. Notable shapes:
|
|
165
194
|
- `permit_grant` — `scope_id`, optional `permit_id` (failed grants
|
|
166
195
|
omit — `web_grantable` denial never produces a row), optional
|
|
@@ -957,6 +986,13 @@ Plus re-uses from `../http/error_schemas.ts`: `ERROR_PERMIT_NOT_FOUND`,
|
|
|
957
986
|
`ERROR_ROLE_NOT_WEB_GRANTABLE`, `ERROR_INSUFFICIENT_PERMISSIONS`,
|
|
958
987
|
`ERROR_ACCOUNT_NOT_FOUND`.
|
|
959
988
|
|
|
989
|
+
Each spec declares the reason codes its handler may surface (see
|
|
990
|
+
`../actions/CLAUDE.md` §Action specs for the field semantics). Only
|
|
991
|
+
domain reasons returned via `error.data.reason` are listed; standard
|
|
992
|
+
transport errors (validation, auth, rate-limit) stay implicit. Drift
|
|
993
|
+
between declared reasons and handler throws is caught by
|
|
994
|
+
`../../test/auth/permit_offer_actions.error_reasons.test.ts`.
|
|
995
|
+
|
|
960
996
|
Failure-outcome audit events emitted (success and failure rows both carry
|
|
961
997
|
`ip: ctx.client_ip` — uniform with the admin and self-service surfaces):
|
|
962
998
|
|
|
@@ -14,6 +14,8 @@ import { type Account, type Actor, type CreateAccountInput, type AdminAccountEnt
|
|
|
14
14
|
* @param deps - query dependencies
|
|
15
15
|
* @param input - the account fields
|
|
16
16
|
* @returns the created account
|
|
17
|
+
* @mutates `account` table - inserts the new row
|
|
18
|
+
* @throws Error if the INSERT does not return a row (failed `assert_row` invariant)
|
|
17
19
|
*/
|
|
18
20
|
export declare const query_create_account: (deps: QueryDeps, input: CreateAccountInput) => Promise<Account>;
|
|
19
21
|
/**
|
|
@@ -42,10 +44,14 @@ export declare const query_account_by_email: (deps: QueryDeps, email: string) =>
|
|
|
42
44
|
export declare const query_account_by_username_or_email: (deps: QueryDeps, input: string) => Promise<Account | undefined>;
|
|
43
45
|
/**
|
|
44
46
|
* Update the password hash for an account.
|
|
47
|
+
*
|
|
48
|
+
* @mutates `account` row - updates `password_hash`, `updated_at`, and `updated_by`
|
|
45
49
|
*/
|
|
46
50
|
export declare const query_update_account_password: (deps: QueryDeps, id: string, password_hash: string, updated_by: string | null) => Promise<void>;
|
|
47
51
|
/**
|
|
48
52
|
* Delete an account. Cascades to actors, permits, sessions, and tokens.
|
|
53
|
+
*
|
|
54
|
+
* @mutates `account` table and downstream FK rows - DELETE cascades through actors/permits/sessions/tokens
|
|
49
55
|
*/
|
|
50
56
|
export declare const query_delete_account: (deps: QueryDeps, id: string) => Promise<boolean>;
|
|
51
57
|
/**
|
|
@@ -59,6 +65,8 @@ export declare const query_account_has_any: (deps: QueryDeps) => Promise<boolean
|
|
|
59
65
|
* @param account_id - the owning account
|
|
60
66
|
* @param name - display name (defaults to account username)
|
|
61
67
|
* @returns the created actor
|
|
68
|
+
* @mutates `actor` table - inserts the new row
|
|
69
|
+
* @throws Error if the INSERT does not return a row (failed `assert_row` invariant)
|
|
62
70
|
*/
|
|
63
71
|
export declare const query_create_actor: (deps: QueryDeps, account_id: string, name: string) => Promise<Actor>;
|
|
64
72
|
/**
|
|
@@ -79,6 +87,8 @@ export declare const query_actor_by_id: (deps: QueryDeps, id: string) => Promise
|
|
|
79
87
|
* @param deps - query dependencies
|
|
80
88
|
* @param input - the account fields
|
|
81
89
|
* @returns the created account and actor
|
|
90
|
+
* @mutates `account` and `actor` tables - inserts one row in each
|
|
91
|
+
* @throws Error if either INSERT does not return a row
|
|
82
92
|
*/
|
|
83
93
|
export declare const query_create_account_with_actor: (deps: QueryDeps, input: CreateAccountInput) => Promise<{
|
|
84
94
|
account: Account;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAEN,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B
|
|
1
|
+
{"version":3,"file":"account_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAEN,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,SAAS,EACf,OAAO,kBAAkB,KACvB,OAAO,CAAC,OAAO,CAQjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,SAAS,EACf,IAAI,MAAM,KACR,OAAO,CAAC,OAAO,GAAG,SAAS,CAE7B,CA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;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,CAI1C,CAAC;AAyBF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,SAAS,KACb,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CA+EtC,CAAC"}
|
|
@@ -14,6 +14,8 @@ import { to_admin_account, } from './account_schema.js';
|
|
|
14
14
|
* @param deps - query dependencies
|
|
15
15
|
* @param input - the account fields
|
|
16
16
|
* @returns the created account
|
|
17
|
+
* @mutates `account` table - inserts the new row
|
|
18
|
+
* @throws Error if the INSERT does not return a row (failed `assert_row` invariant)
|
|
17
19
|
*/
|
|
18
20
|
export const query_create_account = async (deps, input) => {
|
|
19
21
|
const row = await deps.db.query_one(`INSERT INTO account (username, password_hash, email)
|
|
@@ -62,12 +64,16 @@ export const query_account_by_username_or_email = async (deps, input) => {
|
|
|
62
64
|
};
|
|
63
65
|
/**
|
|
64
66
|
* Update the password hash for an account.
|
|
67
|
+
*
|
|
68
|
+
* @mutates `account` row - updates `password_hash`, `updated_at`, and `updated_by`
|
|
65
69
|
*/
|
|
66
70
|
export const query_update_account_password = async (deps, id, password_hash, updated_by) => {
|
|
67
71
|
await deps.db.query(`UPDATE account SET password_hash = $1, updated_at = NOW(), updated_by = $2 WHERE id = $3`, [password_hash, updated_by ?? null, id]);
|
|
68
72
|
};
|
|
69
73
|
/**
|
|
70
74
|
* Delete an account. Cascades to actors, permits, sessions, and tokens.
|
|
75
|
+
*
|
|
76
|
+
* @mutates `account` table and downstream FK rows - DELETE cascades through actors/permits/sessions/tokens
|
|
71
77
|
*/
|
|
72
78
|
export const query_delete_account = async (deps, id) => {
|
|
73
79
|
const rows = await deps.db.query(`DELETE FROM account WHERE id = $1 RETURNING id`, [
|
|
@@ -89,6 +95,8 @@ export const query_account_has_any = async (deps) => {
|
|
|
89
95
|
* @param account_id - the owning account
|
|
90
96
|
* @param name - display name (defaults to account username)
|
|
91
97
|
* @returns the created actor
|
|
98
|
+
* @mutates `actor` table - inserts the new row
|
|
99
|
+
* @throws Error if the INSERT does not return a row (failed `assert_row` invariant)
|
|
92
100
|
*/
|
|
93
101
|
export const query_create_actor = async (deps, account_id, name) => {
|
|
94
102
|
const row = await deps.db.query_one(`INSERT INTO actor (account_id, name) VALUES ($1, $2) RETURNING *`, [account_id, name]);
|
|
@@ -116,6 +124,8 @@ export const query_actor_by_id = async (deps, id) => {
|
|
|
116
124
|
* @param deps - query dependencies
|
|
117
125
|
* @param input - the account fields
|
|
118
126
|
* @returns the created account and actor
|
|
127
|
+
* @mutates `account` and `actor` tables - inserts one row in each
|
|
128
|
+
* @throws Error if either INSERT does not return a row
|
|
119
129
|
*/
|
|
120
130
|
export const query_create_account_with_actor = async (deps, input) => {
|
|
121
131
|
const account = await query_create_account(deps, input);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Returns `RouteSpec[]` — caller applies them to Hono via `apply_route_specs`.
|
|
5
5
|
*
|
|
6
6
|
* Four REST flows remain here; each has a concrete reason to stay REST
|
|
7
|
-
* rather than moving to `account_actions.ts`:
|
|
7
|
+
* rather than moving to `auth/account_actions.ts`:
|
|
8
8
|
*
|
|
9
9
|
* - `POST /login` — issues a signed `Set-Cookie` and pre-handler rate-limits
|
|
10
10
|
* by IP + per-canonical-account before password hashing.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* callers should use the `account_verify` RPC action for the typed payload.
|
|
16
16
|
*
|
|
17
17
|
* Session listing/revocation and API token CRUD are on the RPC endpoint —
|
|
18
|
-
* see `account_actions.ts`. Signup is in `signup_routes.ts`. Defaults are
|
|
18
|
+
* see `auth/account_actions.ts`. Signup is in `auth/signup_routes.ts`. Defaults are
|
|
19
19
|
* closed/safe: accounts are created through bootstrap, admin action, or
|
|
20
20
|
* invite.
|
|
21
21
|
*
|
|
@@ -184,7 +184,7 @@ export type PasswordChangeOutput = z.infer<typeof PasswordChangeOutput>;
|
|
|
184
184
|
*
|
|
185
185
|
* The returned specs cover the three flows that stay REST after the RPC
|
|
186
186
|
* migration (login, logout, password change). Self-service session/token
|
|
187
|
-
* management and verify are on `account_actions.ts`.
|
|
187
|
+
* management and verify are on `auth/account_actions.ts`.
|
|
188
188
|
*
|
|
189
189
|
* @param deps - stateless capabilities (keyring, password, log)
|
|
190
190
|
* @param options - per-factory configuration (session_options, ip_rate_limiter, login_account_rate_limiter)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Returns `RouteSpec[]` — caller applies them to Hono via `apply_route_specs`.
|
|
5
5
|
*
|
|
6
6
|
* Four REST flows remain here; each has a concrete reason to stay REST
|
|
7
|
-
* rather than moving to `account_actions.ts`:
|
|
7
|
+
* rather than moving to `auth/account_actions.ts`:
|
|
8
8
|
*
|
|
9
9
|
* - `POST /login` — issues a signed `Set-Cookie` and pre-handler rate-limits
|
|
10
10
|
* by IP + per-canonical-account before password hashing.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* callers should use the `account_verify` RPC action for the typed payload.
|
|
16
16
|
*
|
|
17
17
|
* Session listing/revocation and API token CRUD are on the RPC endpoint —
|
|
18
|
-
* see `account_actions.ts`. Signup is in `signup_routes.ts`. Defaults are
|
|
18
|
+
* see `auth/account_actions.ts`. Signup is in `auth/signup_routes.ts`. Defaults are
|
|
19
19
|
* closed/safe: accounts are created through bootstrap, admin action, or
|
|
20
20
|
* invite.
|
|
21
21
|
*
|
|
@@ -167,7 +167,7 @@ export const PasswordChangeOutput = z.strictObject({
|
|
|
167
167
|
*
|
|
168
168
|
* The returned specs cover the three flows that stay REST after the RPC
|
|
169
169
|
* migration (login, logout, password change). Self-service session/token
|
|
170
|
-
* management and verify are on `account_actions.ts`.
|
|
170
|
+
* management and verify are on `auth/account_actions.ts`.
|
|
171
171
|
*
|
|
172
172
|
* @param deps - stateless capabilities (keyring, password, log)
|
|
173
173
|
* @param options - per-factory configuration (session_options, ip_rate_limiter, login_account_rate_limiter)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Defines the runtime types for the fuz identity system:
|
|
5
5
|
* `Account`, `Actor`, `Permit`, `AuthSession`, and `ApiToken`.
|
|
6
6
|
*
|
|
7
|
-
* DDL lives in `ddl.ts`; role system in `role_schema.ts`.
|
|
7
|
+
* DDL lives in `auth/ddl.ts`; role system in `auth/role_schema.ts`.
|
|
8
8
|
* See docs/identity.md for design rationale.
|
|
9
9
|
*
|
|
10
10
|
* @module
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Defines the runtime types for the fuz identity system:
|
|
5
5
|
* `Account`, `Actor`, `Permit`, `AuthSession`, and `ApiToken`.
|
|
6
6
|
*
|
|
7
|
-
* DDL lives in `ddl.ts`; role system in `role_schema.ts`.
|
|
7
|
+
* DDL lives in `auth/ddl.ts`; role system in `auth/role_schema.ts`.
|
|
8
8
|
* See docs/identity.md for design rationale.
|
|
9
9
|
*
|
|
10
10
|
* @module
|
|
@@ -65,6 +65,7 @@ export type AdminActionDeps = Pick<RouteFactoryDeps, 'log' | 'on_audit_event' |
|
|
|
65
65
|
* @param deps - `AdminActionDeps` slice of `AppDeps` (`log`, `on_audit_event`, optional `audit_log_config`)
|
|
66
66
|
* @param options - role schema for `grantable_roles` derivation
|
|
67
67
|
* @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
|
|
68
|
+
* @mutates `options.app_settings` ref - `app_settings_update` writes `open_signup`, `updated_at`, and `updated_by` so signup middleware reads without a DB round trip
|
|
68
69
|
*/
|
|
69
70
|
export declare const create_admin_actions: (deps: AdminActionDeps, options?: AdminActionOptions) => Array<RpcAction>;
|
|
70
71
|
//# sourceMappingURL=admin_actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/admin_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAiC,KAAK,SAAS,EAA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C9B,KAAK,CAAC,SAAS,CAmSjB,CAAC"}
|
|
@@ -47,6 +47,7 @@ import { admin_account_list_action_spec, admin_session_list_action_spec, admin_s
|
|
|
47
47
|
* @param deps - `AdminActionDeps` slice of `AppDeps` (`log`, `on_audit_event`, optional `audit_log_config`)
|
|
48
48
|
* @param options - role schema for `grantable_roles` derivation
|
|
49
49
|
* @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
|
|
50
|
+
* @mutates `options.app_settings` ref - `app_settings_update` writes `open_signup`, `updated_at`, and `updated_by` so signup middleware reads without a DB round trip
|
|
50
51
|
*/
|
|
51
52
|
export const create_admin_actions = (deps, options = {}) => {
|
|
52
53
|
const role_options = options.roles?.role_options ?? BUILTIN_ROLE_OPTIONS;
|
package/dist/auth/api_token.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Tokens use the format `secret_fuz_token_<base64url>` and are stored
|
|
5
5
|
* as blake3 hashes. These are pure cryptographic operations with no
|
|
6
6
|
* framework dependency — the bearer auth middleware that validates
|
|
7
|
-
* tokens lives in `bearer_auth.ts`.
|
|
7
|
+
* tokens lives in `auth/bearer_auth.ts`.
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
package/dist/auth/api_token.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Tokens use the format `secret_fuz_token_<base64url>` and are stored
|
|
5
5
|
* as blake3 hashes. These are pure cryptographic operations with no
|
|
6
6
|
* framework dependency — the bearer auth middleware that validates
|
|
7
|
-
* tokens lives in `bearer_auth.ts`.
|
|
7
|
+
* tokens lives in `auth/bearer_auth.ts`.
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
@@ -20,6 +20,8 @@ export interface ApiTokenQueryDeps extends QueryDeps {
|
|
|
20
20
|
* @param token_hash - blake3 hash of the raw token
|
|
21
21
|
* @param expires_at - optional expiration
|
|
22
22
|
* @returns the stored token record
|
|
23
|
+
* @mutates `api_token` table - inserts the new row keyed by `id`
|
|
24
|
+
* @throws Error if the INSERT does not return a row (failed `assert_row` invariant)
|
|
23
25
|
*/
|
|
24
26
|
export declare const query_create_api_token: (deps: QueryDeps, id: string, account_id: string, name: string, token_hash: string, expires_at?: Date | null) => Promise<ApiToken>;
|
|
25
27
|
/**
|
|
@@ -34,6 +36,8 @@ export declare const query_create_api_token: (deps: QueryDeps, id: string, accou
|
|
|
34
36
|
* @param ip - the client IP address (for audit)
|
|
35
37
|
* @param pending_effects - optional array to register the usage-tracking effect for later awaiting
|
|
36
38
|
* @returns the token record if valid, or `undefined`
|
|
39
|
+
* @mutates `api_token` row - fire-and-forget UPDATE of `last_used_at` / `last_used_ip` on a valid token
|
|
40
|
+
* @mutates `pending_effects` - pushes the in-flight tracking promise when provided
|
|
37
41
|
*/
|
|
38
42
|
export declare const query_validate_api_token: (deps: ApiTokenQueryDeps, raw_token: string, ip: string | undefined, pending_effects: Array<Promise<void>> | undefined) => Promise<ApiToken | undefined>;
|
|
39
43
|
/**
|
|
@@ -42,6 +46,7 @@ export declare const query_validate_api_token: (deps: ApiTokenQueryDeps, raw_tok
|
|
|
42
46
|
* @param deps - query dependencies
|
|
43
47
|
* @param account_id - the account whose tokens to revoke
|
|
44
48
|
* @returns the number of tokens revoked
|
|
49
|
+
* @mutates `api_token` table - deletes every row for `account_id`
|
|
45
50
|
*/
|
|
46
51
|
export declare const query_revoke_all_api_tokens_for_account: (deps: QueryDeps, account_id: string) => Promise<number>;
|
|
47
52
|
/**
|
|
@@ -53,6 +58,7 @@ export declare const query_revoke_all_api_tokens_for_account: (deps: QueryDeps,
|
|
|
53
58
|
* @param id - the public token id
|
|
54
59
|
* @param account_id - the account that must own the token
|
|
55
60
|
* @returns `true` if a token was revoked, `false` if not found or wrong account
|
|
61
|
+
* @mutates `api_token` table - deletes the row when account ownership matches
|
|
56
62
|
*/
|
|
57
63
|
export declare const query_revoke_api_token_for_account: (deps: QueryDeps, id: string, account_id: string) => Promise<boolean>;
|
|
58
64
|
/**
|
|
@@ -75,6 +81,7 @@ export declare const query_api_token_list_for_account: (deps: QueryDeps, account
|
|
|
75
81
|
* @param account_id - the account to enforce the limit for
|
|
76
82
|
* @param max_tokens - maximum number of tokens to keep
|
|
77
83
|
* @returns the number of tokens evicted
|
|
84
|
+
* @mutates `api_token` table - deletes the oldest rows past the cap
|
|
78
85
|
*/
|
|
79
86
|
export declare const query_api_token_enforce_limit: (deps: QueryDeps, account_id: string, max_tokens: number) => Promise<number>;
|
|
80
87
|
//# sourceMappingURL=api_token_queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_token_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/api_token_queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAGlD,yEAAyE;AACzE,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IACnD,GAAG,EAAE,MAAM,CAAC;CACZ;AAED
|
|
1
|
+
{"version":3,"file":"api_token_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/api_token_queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAGlD,yEAAyE;AACzE,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IACnD,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,SAAS,EACf,IAAI,MAAM,EACV,YAAY,MAAM,EAClB,MAAM,MAAM,EACZ,YAAY,MAAM,EAClB,aAAa,IAAI,GAAG,IAAI,KACtB,OAAO,CAAC,QAAQ,CAQlB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,iBAAiB,EACvB,WAAW,MAAM,EACjB,IAAI,MAAM,GAAG,SAAS,EACtB,iBAAiB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,KAC/C,OAAO,CAAC,QAAQ,GAAG,SAAS,CAuB9B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uCAAuC,GACnD,MAAM,SAAS,EACf,YAAY,MAAM,KAChB,OAAO,CAAC,MAAM,CAMhB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,GAC9C,MAAM,SAAS,EACf,IAAI,MAAM,EACV,YAAY,MAAM,KAChB,OAAO,CAAC,OAAO,CAMjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,SAAS,EACf,YAAY,MAAM,KAChB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAM7C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,6BAA6B,GACzC,MAAM,SAAS,EACf,YAAY,MAAM,EAClB,YAAY,MAAM,KAChB,OAAO,CAAC,MAAM,CAYhB,CAAC"}
|
|
@@ -15,6 +15,8 @@ import { hash_api_token } from './api_token.js';
|
|
|
15
15
|
* @param token_hash - blake3 hash of the raw token
|
|
16
16
|
* @param expires_at - optional expiration
|
|
17
17
|
* @returns the stored token record
|
|
18
|
+
* @mutates `api_token` table - inserts the new row keyed by `id`
|
|
19
|
+
* @throws Error if the INSERT does not return a row (failed `assert_row` invariant)
|
|
18
20
|
*/
|
|
19
21
|
export const query_create_api_token = async (deps, id, account_id, name, token_hash, expires_at) => {
|
|
20
22
|
const row = await deps.db.query_one(`INSERT INTO api_token (id, account_id, name, token_hash, expires_at)
|
|
@@ -34,6 +36,8 @@ export const query_create_api_token = async (deps, id, account_id, name, token_h
|
|
|
34
36
|
* @param ip - the client IP address (for audit)
|
|
35
37
|
* @param pending_effects - optional array to register the usage-tracking effect for later awaiting
|
|
36
38
|
* @returns the token record if valid, or `undefined`
|
|
39
|
+
* @mutates `api_token` row - fire-and-forget UPDATE of `last_used_at` / `last_used_ip` on a valid token
|
|
40
|
+
* @mutates `pending_effects` - pushes the in-flight tracking promise when provided
|
|
37
41
|
*/
|
|
38
42
|
export const query_validate_api_token = async (deps, raw_token, ip, pending_effects) => {
|
|
39
43
|
const token_hash = hash_api_token(raw_token);
|
|
@@ -61,6 +65,7 @@ export const query_validate_api_token = async (deps, raw_token, ip, pending_effe
|
|
|
61
65
|
* @param deps - query dependencies
|
|
62
66
|
* @param account_id - the account whose tokens to revoke
|
|
63
67
|
* @returns the number of tokens revoked
|
|
68
|
+
* @mutates `api_token` table - deletes every row for `account_id`
|
|
64
69
|
*/
|
|
65
70
|
export const query_revoke_all_api_tokens_for_account = async (deps, account_id) => {
|
|
66
71
|
const rows = await deps.db.query(`DELETE FROM api_token WHERE account_id = $1 RETURNING id`, [account_id]);
|
|
@@ -75,6 +80,7 @@ export const query_revoke_all_api_tokens_for_account = async (deps, account_id)
|
|
|
75
80
|
* @param id - the public token id
|
|
76
81
|
* @param account_id - the account that must own the token
|
|
77
82
|
* @returns `true` if a token was revoked, `false` if not found or wrong account
|
|
83
|
+
* @mutates `api_token` table - deletes the row when account ownership matches
|
|
78
84
|
*/
|
|
79
85
|
export const query_revoke_api_token_for_account = async (deps, id, account_id) => {
|
|
80
86
|
const rows = await deps.db.query(`DELETE FROM api_token WHERE id = $1 AND account_id = $2 RETURNING id`, [id, account_id]);
|
|
@@ -103,6 +109,7 @@ export const query_api_token_list_for_account = async (deps, account_id) => {
|
|
|
103
109
|
* @param account_id - the account to enforce the limit for
|
|
104
110
|
* @param max_tokens - maximum number of tokens to keep
|
|
105
111
|
* @returns the number of tokens evicted
|
|
112
|
+
* @mutates `api_token` table - deletes the oldest rows past the cap
|
|
106
113
|
*/
|
|
107
114
|
export const query_api_token_enforce_limit = async (deps, account_id, max_tokens) => {
|
|
108
115
|
const rows = await deps.db.query(`DELETE FROM api_token
|
|
@@ -12,6 +12,7 @@ import type { AppSettings, AppSettingsWithUsernameJson } from './app_settings_sc
|
|
|
12
12
|
*
|
|
13
13
|
* @param deps - query dependencies
|
|
14
14
|
* @returns the app settings row
|
|
15
|
+
* @throws Error if the singleton `app_settings` row is missing (migration drift — should not occur in practice)
|
|
15
16
|
*/
|
|
16
17
|
export declare const query_app_settings_load: (deps: QueryDeps) => Promise<AppSettings>;
|
|
17
18
|
/**
|
|
@@ -19,6 +20,7 @@ export declare const query_app_settings_load: (deps: QueryDeps) => Promise<AppSe
|
|
|
19
20
|
*
|
|
20
21
|
* @param deps - query dependencies
|
|
21
22
|
* @returns the app settings with `updated_by_username`
|
|
23
|
+
* @throws Error if the singleton `app_settings` row is missing
|
|
22
24
|
*/
|
|
23
25
|
export declare const query_app_settings_load_with_username: (deps: QueryDeps) => Promise<AppSettingsWithUsernameJson>;
|
|
24
26
|
/**
|
|
@@ -28,6 +30,8 @@ export declare const query_app_settings_load_with_username: (deps: QueryDeps) =>
|
|
|
28
30
|
* @param open_signup - new value for the open_signup toggle
|
|
29
31
|
* @param actor_id - the actor making the change
|
|
30
32
|
* @returns the updated app settings row
|
|
33
|
+
* @mutates `app_settings` row - sets `open_signup`, `updated_at`, and `updated_by`
|
|
34
|
+
* @throws Error if the singleton `app_settings` row is missing
|
|
31
35
|
*/
|
|
32
36
|
export declare const query_app_settings_update: (deps: QueryDeps, open_signup: boolean, actor_id: string) => Promise<AppSettings>;
|
|
33
37
|
//# sourceMappingURL=app_settings_queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_settings_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/app_settings_queries.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAC,WAAW,EAAE,2BAA2B,EAAC,MAAM,0BAA0B,CAAC;AAEvF
|
|
1
|
+
{"version":3,"file":"app_settings_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/app_settings_queries.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAC,WAAW,EAAE,2BAA2B,EAAC,MAAM,0BAA0B,CAAC;AAEvF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,WAAW,CAQlF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,GACjD,MAAM,SAAS,KACb,OAAO,CAAC,2BAA2B,CAWrC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GACrC,MAAM,SAAS,EACf,aAAa,OAAO,EACpB,UAAU,MAAM,KACd,OAAO,CAAC,WAAW,CASrB,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @param deps - query dependencies
|
|
12
12
|
* @returns the app settings row
|
|
13
|
+
* @throws Error if the singleton `app_settings` row is missing (migration drift — should not occur in practice)
|
|
13
14
|
*/
|
|
14
15
|
export const query_app_settings_load = async (deps) => {
|
|
15
16
|
const row = await deps.db.query_one(`SELECT open_signup, updated_at, updated_by FROM app_settings WHERE id = 1`);
|
|
@@ -23,6 +24,7 @@ export const query_app_settings_load = async (deps) => {
|
|
|
23
24
|
*
|
|
24
25
|
* @param deps - query dependencies
|
|
25
26
|
* @returns the app settings with `updated_by_username`
|
|
27
|
+
* @throws Error if the singleton `app_settings` row is missing
|
|
26
28
|
*/
|
|
27
29
|
export const query_app_settings_load_with_username = async (deps) => {
|
|
28
30
|
const row = await deps.db.query_one(`SELECT s.open_signup, s.updated_at, s.updated_by, act.name AS updated_by_username
|
|
@@ -41,6 +43,8 @@ export const query_app_settings_load_with_username = async (deps) => {
|
|
|
41
43
|
* @param open_signup - new value for the open_signup toggle
|
|
42
44
|
* @param actor_id - the actor making the change
|
|
43
45
|
* @returns the updated app settings row
|
|
46
|
+
* @mutates `app_settings` row - sets `open_signup`, `updated_at`, and `updated_by`
|
|
47
|
+
* @throws Error if the singleton `app_settings` row is missing
|
|
44
48
|
*/
|
|
45
49
|
export const query_app_settings_update = async (deps, open_signup, actor_id) => {
|
|
46
50
|
const row = await deps.db.query_one(`UPDATE app_settings SET open_signup = $1, updated_at = NOW(), updated_by = $2 WHERE id = 1 RETURNING open_signup, updated_at, updated_by`, [open_signup, actor_id]);
|
|
@@ -36,6 +36,9 @@ export declare const reset_audit_unknown_event_type_failures: () => void;
|
|
|
36
36
|
* @param input - the audit event to record
|
|
37
37
|
* @param config - audit-log config. Defaults to `BUILTIN_AUDIT_LOG_CONFIG`.
|
|
38
38
|
* @returns the inserted audit log row
|
|
39
|
+
* @mutates `audit_log` table - inserts the new row
|
|
40
|
+
* @mutates drift counters - bumps `audit_unknown_event_type_failures` and/or `audit_metadata_validation_failures` on mismatch
|
|
41
|
+
* @throws Error if the INSERT does not return a row (failed `assert_row` invariant)
|
|
39
42
|
*/
|
|
40
43
|
export declare const query_audit_log: <T extends string>(deps: QueryDeps, input: AuditLogInput<T>, config?: AuditLogConfig) => Promise<AuditLogEvent>;
|
|
41
44
|
/**
|
|
@@ -77,6 +80,7 @@ export declare const query_audit_log_list_permit_history: (deps: QueryDeps, limi
|
|
|
77
80
|
* @param deps - query dependencies
|
|
78
81
|
* @param before - delete entries created before this date
|
|
79
82
|
* @returns the number of entries deleted
|
|
83
|
+
* @mutates `audit_log` table - deletes every row with `created_at < before`
|
|
80
84
|
*/
|
|
81
85
|
export declare const query_audit_log_cleanup_before: (deps: QueryDeps, before: Date) => Promise<number>;
|
|
82
86
|
/**
|
|
@@ -102,6 +106,8 @@ export type AuditLogFireAndForgetDeps = Pick<AppDeps, 'log' | 'on_audit_event' |
|
|
|
102
106
|
* @param input - the audit event to record
|
|
103
107
|
* @param deps - logger, `on_audit_event` callback, and optional `audit_log_config`
|
|
104
108
|
* @returns the settled promise (callers may ignore it)
|
|
109
|
+
* @mutates `audit_log` table - inserts a row via `background_db` (independent of the request transaction)
|
|
110
|
+
* @mutates `route.pending_effects` - pushes the in-flight settled promise for test flushing
|
|
105
111
|
*/
|
|
106
112
|
export declare const audit_log_fire_and_forget: <T extends string>(route: Pick<RouteContext, "background_db" | "pending_effects">, input: AuditLogInput<T>, deps: AuditLogFireAndForgetDeps) => Promise<void>;
|
|
107
113
|
//# sourceMappingURL=audit_log_queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,MAAM,uBAAuB,CAAC;AAa/B,iFAAiF;AACjF,eAAO,MAAM,sCAAsC,QAAO,MACvB,CAAC;AAEpC,0CAA0C;AAC1C,eAAO,MAAM,wCAAwC,QAAO,IAE3D,CAAC;AAYF,gFAAgF;AAChF,eAAO,MAAM,qCAAqC,QAAO,MACvB,CAAC;AAEnC,0CAA0C;AAC1C,eAAO,MAAM,uCAAuC,QAAO,IA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C,MAAM,SAAS,EACf,YAAY,MAAM,EAClB,cAA+B,KAC7B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAO9B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mCAAmC,GAC/C,MAAM,SAAS,EACf,cAA+B,EAC/B,eAAU,KACR,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAYvC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,GAC1C,MAAM,SAAS,EACf,QAAQ,IAAI,KACV,OAAO,CAAC,MAAM,CAMhB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC3C,OAAO,EACP,KAAK,GAAG,gBAAgB,GAAG,kBAAkB,CAC7C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,GAAI,CAAC,SAAS,MAAM,EACzD,OAAO,IAAI,CAAC,YAAY,EAAE,eAAe,GAAG,iBAAiB,CAAC,EAC9D,OAAO,aAAa,CAAC,CAAC,CAAC,EACvB,MAAM,yBAAyB,KAC7B,OAAO,CAAC,IAAI,CAed,CAAC"}
|
|
@@ -57,6 +57,9 @@ export const reset_audit_unknown_event_type_failures = () => {
|
|
|
57
57
|
* @param input - the audit event to record
|
|
58
58
|
* @param config - audit-log config. Defaults to `BUILTIN_AUDIT_LOG_CONFIG`.
|
|
59
59
|
* @returns the inserted audit log row
|
|
60
|
+
* @mutates `audit_log` table - inserts the new row
|
|
61
|
+
* @mutates drift counters - bumps `audit_unknown_event_type_failures` and/or `audit_metadata_validation_failures` on mismatch
|
|
62
|
+
* @throws Error if the INSERT does not return a row (failed `assert_row` invariant)
|
|
60
63
|
*/
|
|
61
64
|
export const query_audit_log = async (deps, input, config = BUILTIN_AUDIT_LOG_CONFIG) => {
|
|
62
65
|
if (!config.event_types.includes(input.event_type)) {
|
|
@@ -204,6 +207,7 @@ export const query_audit_log_list_permit_history = async (deps, limit = AUDIT_LO
|
|
|
204
207
|
* @param deps - query dependencies
|
|
205
208
|
* @param before - delete entries created before this date
|
|
206
209
|
* @returns the number of entries deleted
|
|
210
|
+
* @mutates `audit_log` table - deletes every row with `created_at < before`
|
|
207
211
|
*/
|
|
208
212
|
export const query_audit_log_cleanup_before = async (deps, before) => {
|
|
209
213
|
const rows = await deps.db.query(`DELETE FROM audit_log WHERE created_at < $1 RETURNING id`, [before.toISOString()]);
|
|
@@ -220,6 +224,8 @@ export const query_audit_log_cleanup_before = async (deps, before) => {
|
|
|
220
224
|
* @param input - the audit event to record
|
|
221
225
|
* @param deps - logger, `on_audit_event` callback, and optional `audit_log_config`
|
|
222
226
|
* @returns the settled promise (callers may ignore it)
|
|
227
|
+
* @mutates `audit_log` table - inserts a row via `background_db` (independent of the request transaction)
|
|
228
|
+
* @mutates `route.pending_effects` - pushes the in-flight settled promise for test flushing
|
|
223
229
|
*/
|
|
224
230
|
export const audit_log_fire_and_forget = (route, input, deps) => {
|
|
225
231
|
const { log, on_audit_event, audit_log_config = BUILTIN_AUDIT_LOG_CONFIG } = deps;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Audit log SSE stream route.
|
|
3
3
|
*
|
|
4
4
|
* The two list-reads (`audit_log_list`, `audit_log_permit_history`) moved to
|
|
5
|
-
* RPC in `admin_actions.ts`, and the admin session listing moved to
|
|
5
|
+
* RPC in `auth/admin_actions.ts`, and the admin session listing moved to
|
|
6
6
|
* `admin_session_list` on the same file. What remains here is the optional
|
|
7
7
|
* `GET /audit-log/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
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Audit log SSE stream route.
|
|
3
3
|
*
|
|
4
4
|
* The two list-reads (`audit_log_list`, `audit_log_permit_history`) moved to
|
|
5
|
-
* RPC in `admin_actions.ts`, and the admin session listing moved to
|
|
5
|
+
* RPC in `auth/admin_actions.ts`, and the admin session listing moved to
|
|
6
6
|
* `admin_session_list` on the same file. What remains here is the optional
|
|
7
7
|
* `GET /audit-log/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
|
|
@@ -242,7 +242,7 @@ export interface CreateAuditLogConfigOptions {
|
|
|
242
242
|
*
|
|
243
243
|
* Collisions with builtin event-type strings throw at construction.
|
|
244
244
|
* Schemas are run via `safeParse` at insert time; mismatches log + count
|
|
245
|
-
* but never throw (fail-open — see the drift counters in `audit_log_queries.ts`).
|
|
245
|
+
* but never throw (fail-open — see the drift counters in `auth/audit_log_queries.ts`).
|
|
246
246
|
*/
|
|
247
247
|
extra_events?: Readonly<Record<string, z.ZodType | null>>;
|
|
248
248
|
}
|
|
@@ -255,6 +255,8 @@ export interface CreateAuditLogConfigOptions {
|
|
|
255
255
|
* Call once at startup; pass the result to consumer-emitted
|
|
256
256
|
* `audit_log_fire_and_forget` calls. Builtin handlers omit the argument and
|
|
257
257
|
* pick up `BUILTIN_AUDIT_LOG_CONFIG`.
|
|
258
|
+
*
|
|
259
|
+
* @throws Error when an `extra_events` key collides with a builtin event type or fails `AuditEventTypeName` format validation
|
|
258
260
|
*/
|
|
259
261
|
export declare const create_audit_log_config: (options?: CreateAuditLogConfigOptions) => AuditLogConfig;
|
|
260
262
|
/** Default page size for audit log listings. */
|
|
@@ -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;;;;;;;GAOG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAI5C;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,6YAsBnB,CAAC;AAEZ,wCAAwC;AACxC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;EAA4B,CAAC;AACxD,MAAM,MAAM,cAAc,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