@fuzdev/fuz_app 0.51.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 +14 -1
- 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 +18 -8
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +18 -8
- 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 +1 -1
- package/dist/actions/action_registry.js +1 -1
- 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 +22 -2
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +16 -2
- package/dist/actions/register_action_ws.d.ts +3 -0
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +3 -0
- 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/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_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_schema.d.ts +2 -0
- 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_middleware.d.ts +4 -0
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +4 -0
- 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/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/self_service_role_actions.d.ts +1 -0
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +1 -0
- 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 +9 -0
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +9 -0
- 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/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 +3 -0
- package/dist/db/create_db.d.ts.map +1 -1
- package/dist/db/create_db.js +3 -0
- package/dist/db/db.d.ts +19 -4
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +18 -3
- 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/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/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/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/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_helpers.d.ts +21 -8
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +21 -8
- 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/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/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
|
@@ -25,7 +25,10 @@ export class Transports {
|
|
|
25
25
|
*/
|
|
26
26
|
allow_fallback = true; // TODO allow registering transports with a priority level so this can be customized
|
|
27
27
|
/**
|
|
28
|
-
* Registers a transport.
|
|
28
|
+
* Registers a transport. The first transport registered also becomes the current.
|
|
29
|
+
*
|
|
30
|
+
* @mutates this - inserts into `#transport_by_name`; sets `#current_transport`
|
|
31
|
+
* if no current is set
|
|
29
32
|
*/
|
|
30
33
|
register_transport(transport) {
|
|
31
34
|
this.#transport_by_name.set(transport.transport_name, transport); // TODO maybe ensure unregistering of any previous transport?
|
|
@@ -34,6 +37,12 @@ export class Transports {
|
|
|
34
37
|
this.#current_transport = transport;
|
|
35
38
|
}
|
|
36
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Switch the current transport selection by name.
|
|
42
|
+
*
|
|
43
|
+
* @mutates this - sets `#current_transport`
|
|
44
|
+
* @throws Error if no transport with `transport_name` has been registered
|
|
45
|
+
*/
|
|
37
46
|
set_current_transport(transport_name) {
|
|
38
47
|
const transport = this.#transport_by_name.get(transport_name);
|
|
39
48
|
if (!transport)
|
|
@@ -42,9 +51,9 @@ export class Transports {
|
|
|
42
51
|
}
|
|
43
52
|
/**
|
|
44
53
|
* Gets either the current transport or the first ready transport
|
|
45
|
-
* depending on `allow_fallback
|
|
54
|
+
* depending on `allow_fallback`.
|
|
46
55
|
* @param transport_name - optional transport to use instead of the current
|
|
47
|
-
* @
|
|
56
|
+
* @returns the resolved transport, or `null` when none is ready
|
|
48
57
|
*/
|
|
49
58
|
get_transport(transport_name) {
|
|
50
59
|
return this.allow_fallback
|
|
@@ -68,9 +77,9 @@ export class Transports {
|
|
|
68
77
|
return this.#transport_by_name.get(transport_name) ?? null;
|
|
69
78
|
}
|
|
70
79
|
/**
|
|
71
|
-
* Gets the specified transport, defaulting to the current
|
|
80
|
+
* Gets the specified transport, defaulting to the current.
|
|
72
81
|
* @param transport_name - optional transport type to use instead of the current
|
|
73
|
-
* @
|
|
82
|
+
* @returns the resolved transport when ready, else `null`
|
|
74
83
|
*/
|
|
75
84
|
#get_exact(transport_name) {
|
|
76
85
|
const transport = transport_name
|
|
@@ -82,9 +91,9 @@ export class Transports {
|
|
|
82
91
|
return null;
|
|
83
92
|
}
|
|
84
93
|
/**
|
|
85
|
-
* Gets the appropriate transport
|
|
94
|
+
* Gets the appropriate transport.
|
|
86
95
|
* @param transport_name - optional transport type or array of types to use instead of the current
|
|
87
|
-
* @
|
|
96
|
+
* @returns the first ready transport (specified → current → any), or `null`
|
|
88
97
|
*/
|
|
89
98
|
#get_first_ready(transport_name) {
|
|
90
99
|
// First try the specified transport(s) if provided
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { JsonrpcNotification, JsonrpcRequest, JsonrpcResponseOrError, JsonrpcErrorResponse } from '../http/jsonrpc.js';
|
|
7
7
|
import type { Transport, TransportSendOptions } from './transports.js';
|
|
8
|
+
/**
|
|
9
|
+
* Thin `fetch` adapter for the JSON-RPC endpoint. POST by default; GET when
|
|
10
|
+
* the optional `has_side_effects(method)` callback returns `false` for the
|
|
11
|
+
* method (matches `create_rpc_endpoint`'s GET convention). On non-OK HTTP
|
|
12
|
+
* responses, synthesizes a JSON-RPC error envelope via
|
|
13
|
+
* `http_status_to_jsonrpc_error_code`. Always reports ready.
|
|
14
|
+
*/
|
|
8
15
|
export declare class FrontendHttpTransport implements Transport {
|
|
9
16
|
#private;
|
|
10
17
|
readonly transport_name: "frontend_http_rpc";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports_http.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,OAAO,KAAK,EAGX,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,SAAS,EAAE,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AAErE,qBAAa,qBAAsB,YAAW,SAAS;;IACtD,QAAQ,CAAC,cAAc,EAAG,mBAAmB,CAAU;gBAOtD,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO;IAOzC,IAAI,CACT,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,sBAAsB,CAAC;IAC5B,IAAI,CACT,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAyEvC,QAAQ,IAAI,OAAO;CAGnB"}
|
|
1
|
+
{"version":3,"file":"transports_http.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,OAAO,KAAK,EAGX,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,SAAS,EAAE,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AAErE;;;;;;GAMG;AACH,qBAAa,qBAAsB,YAAW,SAAS;;IACtD,QAAQ,CAAC,cAAc,EAAG,mBAAmB,CAAU;gBAOtD,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO;IAOzC,IAAI,CACT,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,sBAAsB,CAAC;IAC5B,IAAI,CACT,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAyEvC,QAAQ,IAAI,OAAO;CAGnB"}
|
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
import { DEV } from 'esm-env';
|
|
7
7
|
import { ThrownJsonrpcError, jsonrpc_error_messages, http_status_to_jsonrpc_error_code, UNKNOWN_ERROR_MESSAGE, } from '../http/jsonrpc_errors.js';
|
|
8
8
|
import { create_jsonrpc_error_response, to_jsonrpc_message_id, is_jsonrpc_error_response, } from '../http/jsonrpc_helpers.js';
|
|
9
|
+
/**
|
|
10
|
+
* Thin `fetch` adapter for the JSON-RPC endpoint. POST by default; GET when
|
|
11
|
+
* the optional `has_side_effects(method)` callback returns `false` for the
|
|
12
|
+
* method (matches `create_rpc_endpoint`'s GET convention). On non-OK HTTP
|
|
13
|
+
* responses, synthesizes a JSON-RPC error envelope via
|
|
14
|
+
* `http_status_to_jsonrpc_error_code`. Always reports ready.
|
|
15
|
+
*/
|
|
9
16
|
export class FrontendHttpTransport {
|
|
10
17
|
transport_name = 'frontend_http_rpc';
|
|
11
18
|
#url;
|
|
@@ -41,6 +41,12 @@ export interface WebsocketRpcConnection extends WebsocketConnection {
|
|
|
41
41
|
id?: JsonrpcRequestId;
|
|
42
42
|
}) => Promise<unknown>;
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Thin adapter over `WebsocketRpcConnection` (canonical implementation:
|
|
46
|
+
* `FrontendWebsocketClient`). Routes inbound server-pushed requests and
|
|
47
|
+
* notifications into the supplied `receive` callback; responses are owned
|
|
48
|
+
* by the connection's own `request()` pending map and are ignored here.
|
|
49
|
+
*/
|
|
44
50
|
export declare class FrontendWebsocketTransport implements Transport {
|
|
45
51
|
#private;
|
|
46
52
|
readonly transport_name: "frontend_websocket_rpc";
|
|
@@ -48,6 +54,13 @@ export declare class FrontendWebsocketTransport implements Transport {
|
|
|
48
54
|
send(message: JsonrpcRequest, options?: TransportSendOptions): Promise<JsonrpcResponseOrError>;
|
|
49
55
|
send(message: JsonrpcNotification, options?: TransportSendOptions): Promise<JsonrpcErrorResponse | null>;
|
|
50
56
|
is_ready(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Detach the inbound message and error handlers registered on the
|
|
59
|
+
* connection. Idempotent — subsequent calls no-op. Does not close the
|
|
60
|
+
* underlying connection (that lifecycle is owned by the caller).
|
|
61
|
+
*
|
|
62
|
+
* @mutates this - clears the two stored unsubscribe references after invoking them
|
|
63
|
+
*/
|
|
51
64
|
dispose(): void;
|
|
52
65
|
}
|
|
53
66
|
//# sourceMappingURL=transports_ws.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports_ws.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_ws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,OAAO,KAAK,EAGX,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,SAAS,EAAE,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AAIrE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IAC5E,iBAAiB,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CACnE;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IAClE,OAAO,EAAE,CACR,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE;QAAC,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,EAAE,CAAC,EAAE,gBAAgB,CAAA;KAAC,KACpE,OAAO,CAAC,OAAO,CAAC,CAAC;CACtB;AAED,qBAAa,0BAA2B,YAAW,SAAS;;IAC3D,QAAQ,CAAC,cAAc,EAAG,wBAAwB,CAAU;gBAOhD,UAAU,EAAE,sBAAsB,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC;IAyBtF,IAAI,CACT,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,sBAAsB,CAAC;IAC5B,IAAI,CACT,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA4DvC,QAAQ,IAAI,OAAO;IAInB,OAAO,IAAI,IAAI;CAUf"}
|
|
1
|
+
{"version":3,"file":"transports_ws.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_ws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,OAAO,KAAK,EAGX,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,SAAS,EAAE,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AAIrE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IAC5E,iBAAiB,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CACnE;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IAClE,OAAO,EAAE,CACR,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE;QAAC,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,EAAE,CAAC,EAAE,gBAAgB,CAAA;KAAC,KACpE,OAAO,CAAC,OAAO,CAAC,CAAC;CACtB;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,YAAW,SAAS;;IAC3D,QAAQ,CAAC,cAAc,EAAG,wBAAwB,CAAU;gBAOhD,UAAU,EAAE,sBAAsB,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC;IAyBtF,IAAI,CACT,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,sBAAsB,CAAC;IAC5B,IAAI,CACT,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA4DvC,QAAQ,IAAI,OAAO;IAInB;;;;;;OAMG;IACH,OAAO,IAAI,IAAI;CAUf"}
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { ThrownJsonrpcError, jsonrpc_error_messages } from '../http/jsonrpc_errors.js';
|
|
15
15
|
import { is_jsonrpc_notification, is_jsonrpc_request, to_jsonrpc_message_id, to_jsonrpc_result, create_jsonrpc_response, create_jsonrpc_error_response, } from '../http/jsonrpc_helpers.js';
|
|
16
|
+
/**
|
|
17
|
+
* Thin adapter over `WebsocketRpcConnection` (canonical implementation:
|
|
18
|
+
* `FrontendWebsocketClient`). Routes inbound server-pushed requests and
|
|
19
|
+
* notifications into the supplied `receive` callback; responses are owned
|
|
20
|
+
* by the connection's own `request()` pending map and are ignored here.
|
|
21
|
+
*/
|
|
16
22
|
export class FrontendWebsocketTransport {
|
|
17
23
|
transport_name = 'frontend_websocket_rpc';
|
|
18
24
|
#connection;
|
|
@@ -86,6 +92,13 @@ export class FrontendWebsocketTransport {
|
|
|
86
92
|
is_ready() {
|
|
87
93
|
return this.#connection.connected;
|
|
88
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Detach the inbound message and error handlers registered on the
|
|
97
|
+
* connection. Idempotent — subsequent calls no-op. Does not close the
|
|
98
|
+
* underlying connection (that lifecycle is owned by the caller).
|
|
99
|
+
*
|
|
100
|
+
* @mutates this - clears the two stored unsubscribe references after invoking them
|
|
101
|
+
*/
|
|
89
102
|
dispose() {
|
|
90
103
|
if (this.#remove_message_handler) {
|
|
91
104
|
this.#remove_message_handler();
|
|
@@ -47,7 +47,9 @@ export declare const WS_DISCONNECT_EVENT_TYPES: ReadonlySet<string>;
|
|
|
47
47
|
*
|
|
48
48
|
* @param transport - the backend WebSocket transport to guard
|
|
49
49
|
* @param log - logger for disconnect events (info level on non-zero closures)
|
|
50
|
-
* @returns an `on_audit_event` callback suitable for `CreateAppBackendOptions
|
|
50
|
+
* @returns an `on_audit_event` callback suitable for `CreateAppBackendOptions`.
|
|
51
|
+
* The returned callback mutates `transport` (closing matching sockets via
|
|
52
|
+
* `close_sockets_for_session` / `_token` / `_account`) on every relevant event.
|
|
51
53
|
*/
|
|
52
54
|
export declare const create_ws_auth_guard: (transport: BackendWebsocketTransport, log: Logger) => AuditEventHandler;
|
|
53
55
|
/**
|
|
@@ -78,7 +80,9 @@ export declare const create_ws_auth_guard: (transport: BackendWebsocketTransport
|
|
|
78
80
|
*
|
|
79
81
|
* @param transport - the backend WebSocket transport to guard
|
|
80
82
|
* @param log - logger for disconnect events (info level on non-zero closures)
|
|
81
|
-
* @returns an `on_audit_event` callback wireable alongside `create_ws_auth_guard
|
|
83
|
+
* @returns an `on_audit_event` callback wireable alongside `create_ws_auth_guard`.
|
|
84
|
+
* The returned callback mutates `transport` via `close_sockets_for_account`
|
|
85
|
+
* on every successful `logout` event with a non-empty `account_id`.
|
|
82
86
|
*/
|
|
83
87
|
export declare const create_ws_logout_closer: (transport: BackendWebsocketTransport, log: Logger) => AuditEventHandler;
|
|
84
88
|
//# sourceMappingURL=transports_ws_auth_guard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports_ws_auth_guard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_ws_auth_guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,4BAA4B,CAAC;AAE1E;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAE/D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAMxD,CAAC;AAEH
|
|
1
|
+
{"version":3,"file":"transports_ws_auth_guard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_ws_auth_guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,4BAA4B,CAAC;AAE1E;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAE/D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAMxD,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAChC,WAAW,yBAAyB,EACpC,KAAK,MAAM,KACT,iBA6CF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,uBAAuB,GACnC,WAAW,yBAAyB,EACpC,KAAK,MAAM,KACT,iBAaF,CAAC"}
|
|
@@ -40,7 +40,9 @@ export const WS_DISCONNECT_EVENT_TYPES = new Set([
|
|
|
40
40
|
*
|
|
41
41
|
* @param transport - the backend WebSocket transport to guard
|
|
42
42
|
* @param log - logger for disconnect events (info level on non-zero closures)
|
|
43
|
-
* @returns an `on_audit_event` callback suitable for `CreateAppBackendOptions
|
|
43
|
+
* @returns an `on_audit_event` callback suitable for `CreateAppBackendOptions`.
|
|
44
|
+
* The returned callback mutates `transport` (closing matching sockets via
|
|
45
|
+
* `close_sockets_for_session` / `_token` / `_account`) on every relevant event.
|
|
44
46
|
*/
|
|
45
47
|
export const create_ws_auth_guard = (transport, log) => {
|
|
46
48
|
return (event) => {
|
|
@@ -112,7 +114,9 @@ export const create_ws_auth_guard = (transport, log) => {
|
|
|
112
114
|
*
|
|
113
115
|
* @param transport - the backend WebSocket transport to guard
|
|
114
116
|
* @param log - logger for disconnect events (info level on non-zero closures)
|
|
115
|
-
* @returns an `on_audit_event` callback wireable alongside `create_ws_auth_guard
|
|
117
|
+
* @returns an `on_audit_event` callback wireable alongside `create_ws_auth_guard`.
|
|
118
|
+
* The returned callback mutates `transport` via `close_sockets_for_account`
|
|
119
|
+
* on every successful `logout` event with a non-empty `account_id`.
|
|
116
120
|
*/
|
|
117
121
|
export const create_ws_logout_closer = (transport, log) => {
|
|
118
122
|
return (event) => {
|
|
@@ -44,28 +44,39 @@ export declare class BackendWebsocketTransport implements FilterableBroadcastTra
|
|
|
44
44
|
/**
|
|
45
45
|
* Add a new WebSocket connection with auth info.
|
|
46
46
|
* Session connections pass a token hash for targeted revocation.
|
|
47
|
-
* Bearer token connections (api_token) pass the `api_token.id` so the
|
|
47
|
+
* Bearer token connections (`api_token`) pass the `api_token.id` so the
|
|
48
48
|
* socket can be closed when that specific token is revoked without
|
|
49
49
|
* tearing down the account's other sockets. Daemon-token connections
|
|
50
50
|
* pass `null` for both — they're only reachable via
|
|
51
51
|
* `close_sockets_for_account`.
|
|
52
|
+
*
|
|
53
|
+
* @returns the freshly assigned `connection_id` (branded `Uuid`)
|
|
54
|
+
* @mutates this - inserts into `#connections`, `#connection_ids`, and
|
|
55
|
+
* `#connection_identities`
|
|
52
56
|
*/
|
|
53
57
|
add_connection(ws: WSContext, token_hash: string | null, account_id: Uuid, api_token_id?: string | null): Uuid;
|
|
54
58
|
/**
|
|
55
59
|
* Remove a WebSocket connection and its auth tracking data.
|
|
56
60
|
* Idempotent — safe to call after revocation has already cleaned up.
|
|
61
|
+
*
|
|
62
|
+
* @mutates this - deletes the connection's entries from `#connections`,
|
|
63
|
+
* `#connection_ids`, and `#connection_identities`
|
|
57
64
|
*/
|
|
58
65
|
remove_connection(ws: WSContext): void;
|
|
59
66
|
/**
|
|
60
67
|
* Close all sockets associated with a specific session token hash.
|
|
61
68
|
*
|
|
62
69
|
* @returns the number of sockets closed
|
|
70
|
+
* @mutates this - removes matching connections from internal maps and
|
|
71
|
+
* closes their underlying `WSContext` with `WS_CLOSE_SESSION_REVOKED`
|
|
63
72
|
*/
|
|
64
73
|
close_sockets_for_session(token_hash: string): number;
|
|
65
74
|
/**
|
|
66
75
|
* Close all sockets associated with a specific account.
|
|
67
76
|
*
|
|
68
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`
|
|
69
80
|
*/
|
|
70
81
|
close_sockets_for_account(account_id: Uuid): number;
|
|
71
82
|
/**
|
|
@@ -76,6 +87,8 @@ export declare class BackendWebsocketTransport implements FilterableBroadcastTra
|
|
|
76
87
|
* tokens' sockets.
|
|
77
88
|
*
|
|
78
89
|
* @returns the number of sockets closed
|
|
90
|
+
* @mutates this - removes matching connections from internal maps and
|
|
91
|
+
* closes their underlying `WSContext` with `WS_CLOSE_SESSION_REVOKED`
|
|
79
92
|
*/
|
|
80
93
|
close_sockets_for_token(api_token_id: string): number;
|
|
81
94
|
send(message: JsonrpcRequest, options?: TransportSendOptions): Promise<JsonrpcResponseOrError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports_ws_backend.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_ws_backend.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,EAAc,KAAK,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAEX,gCAAgC,EAChC,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAA2B,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AAIpG;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAClC,sEAAsE;IACtE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,4CAA4C;IAC5C,UAAU,EAAE,IAAI,CAAC;IACjB,sEAAsE;IACtE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,4BAA6B,SAAQ,SAAS;IAC9D,kBAAkB,EAAE,CACnB,OAAO,EAAE,gCAAgC,EACzC,SAAS,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,KAChD,MAAM,CAAC;CACZ;AAED,qDAAqD;AACrD,eAAO,MAAM,iCAAiC,GAC7C,WAAW,SAAS,KAClB,SAAS,IAAI,4BAEqE,CAAC;AAEtF,qBAAa,yBAA0B,YAAW,4BAA4B;;IAC7E,QAAQ,CAAC,cAAc,EAAG,uBAAuB,CAAU;IAY3D
|
|
1
|
+
{"version":3,"file":"transports_ws_backend.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_ws_backend.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,EAAc,KAAK,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAEX,gCAAgC,EAChC,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAA2B,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AAIpG;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAClC,sEAAsE;IACtE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,4CAA4C;IAC5C,UAAU,EAAE,IAAI,CAAC;IACjB,sEAAsE;IACtE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,4BAA6B,SAAQ,SAAS;IAC9D,kBAAkB,EAAE,CACnB,OAAO,EAAE,gCAAgC,EACzC,SAAS,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,KAChD,MAAM,CAAC;CACZ;AAED,qDAAqD;AACrD,eAAO,MAAM,iCAAiC,GAC7C,WAAW,SAAS,KAClB,SAAS,IAAI,4BAEqE,CAAC;AAEtF,qBAAa,yBAA0B,YAAW,4BAA4B;;IAC7E,QAAQ,CAAC,cAAc,EAAG,uBAAuB,CAAU;IAY3D;;;;;;;;;;;;OAYG;IACH,cAAc,CACb,EAAE,EAAE,SAAS,EACb,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,UAAU,EAAE,IAAI,EAChB,YAAY,GAAE,MAAM,GAAG,IAAW,GAChC,IAAI;IAQP;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;IA0BtC;;;;;;OAMG;IACH,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAIrD;;;;;;OAMG;IACH,yBAAyB,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM;IAInD;;;;;;;;;;OAUG;IACH,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAsB/C,IAAI,CACT,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,sBAAsB,CAAC;IAC5B,IAAI,CACT,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA6CvC;;;;;;;;;OASG;IACH,kBAAkB,CACjB,OAAO,EAAE,gCAAgC,EACzC,SAAS,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,GAClD,MAAM;IAoBT;;;;;;;;;;;;;OAaG;IACH,eAAe,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,gCAAgC,GAAG,MAAM;IAIpF,QAAQ,IAAI,OAAO;IAInB;;;;;;;OAOG;IACH,oBAAoB,IAAI,MAAM;CAG9B"}
|
|
@@ -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,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GACrC,MAAM,SAAS,EACf,UAAU,MAAM,KACd,OAAO,CAAC,OAAO,GAAG,SAAS,CAI7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,SAAS,EACf,OAAO,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,SAAS,CAI7B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,GAC9C,MAAM,SAAS,EACf,OAAO,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,SAAS,CAS7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GACzC,MAAM,SAAS,EACf,IAAI,MAAM,EACV,eAAe,MAAM,EACrB,YAAY,MAAM,GAAG,IAAI,KACvB,OAAO,CAAC,IAAI,CAKd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAU,MAAM,SAAS,EAAE,IAAI,MAAM,KAAG,OAAO,CAAC,OAAO,CAKvF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,OAAO,CAK5E,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC9B,MAAM,SAAS,EACf,YAAY,MAAM,EAClB,MAAM,MAAM,KACV,OAAO,CAAC,KAAK,CAMf,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,SAAS,EACf,YAAY,MAAM,KAChB,OAAO,CAAC,KAAK,GAAG,SAAS,CAE3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC7B,MAAM,SAAS,EACf,IAAI,MAAM,KACR,OAAO,CAAC,KAAK,GAAG,SAAS,CAE3B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,GAC3C,MAAM,SAAS,EACf,OAAO,kBAAkB,KACvB,OAAO,CAAC;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);
|
|
@@ -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,EAAC,MAAM,0BAA0B,CAAC;AAExF,OAAO,EAAuB,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAuB7E,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAK1D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AA8ChD,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC;;;;OAIG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,GAAG,kBAAkB,CAAC,CAAC;AAEpG
|
|
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,EAAC,MAAM,0BAA0B,CAAC;AAExF,OAAO,EAAuB,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAuB7E,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAK1D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AA8ChD,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC;;;;OAIG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,GAAG,kBAAkB,CAAC,CAAC;AAEpG;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,eAAe,EACrB,UAAS,kBAAuB,KAC9B,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;
|
|
@@ -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"}
|