@fuzdev/fuz_app 0.54.0 → 0.56.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 +214 -103
- package/dist/actions/action_bridge.d.ts +8 -5
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +1 -11
- package/dist/actions/action_codegen.d.ts +32 -0
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +35 -15
- package/dist/actions/action_registry.d.ts.map +1 -1
- package/dist/actions/action_registry.js +5 -2
- package/dist/actions/action_rpc.d.ts +141 -22
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +106 -187
- package/dist/actions/action_spec.d.ts +55 -16
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +16 -11
- package/dist/actions/action_types.d.ts +28 -60
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +13 -5
- package/dist/actions/broadcast_api.d.ts +2 -2
- package/dist/actions/broadcast_api.js +2 -2
- package/dist/actions/compile_action_registry.d.ts +50 -0
- package/dist/actions/compile_action_registry.d.ts.map +1 -0
- package/dist/actions/compile_action_registry.js +69 -0
- package/dist/actions/heartbeat.d.ts +8 -4
- package/dist/actions/heartbeat.d.ts.map +1 -1
- package/dist/actions/heartbeat.js +5 -4
- package/dist/actions/perform_action.d.ts +145 -0
- package/dist/actions/perform_action.d.ts.map +1 -0
- package/dist/actions/perform_action.js +258 -0
- package/dist/actions/register_action_ws.d.ts +46 -40
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +101 -159
- package/dist/actions/register_ws_endpoint.d.ts +15 -10
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +54 -7
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +0 -4
- package/dist/actions/transports_ws_auth_guard.d.ts +1 -1
- package/dist/actions/transports_ws_auth_guard.js +1 -1
- package/dist/actions/transports_ws_backend.d.ts +1 -1
- package/dist/actions/transports_ws_backend.js +1 -1
- package/dist/auth/CLAUDE.md +794 -410
- package/dist/auth/account_action_specs.d.ts +28 -7
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +7 -7
- package/dist/auth/account_actions.d.ts +7 -13
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +26 -35
- package/dist/auth/account_queries.d.ts +52 -16
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +87 -38
- package/dist/auth/account_routes.d.ts +9 -11
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +118 -46
- package/dist/auth/account_schema.d.ts +46 -35
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +21 -28
- package/dist/auth/admin_action_specs.d.ts +100 -32
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +64 -33
- package/dist/auth/admin_actions.d.ts +13 -19
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +37 -41
- package/dist/auth/audit_emitter.d.ts +160 -0
- package/dist/auth/audit_emitter.d.ts.map +1 -0
- package/dist/auth/audit_emitter.js +83 -0
- package/dist/auth/audit_log_queries.d.ts +17 -48
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +20 -56
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +7 -3
- package/dist/auth/audit_log_schema.d.ts +92 -32
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +75 -46
- package/dist/auth/auth_guard_resolver.d.ts +44 -0
- package/dist/auth/auth_guard_resolver.d.ts.map +1 -0
- package/dist/auth/auth_guard_resolver.js +56 -0
- package/dist/auth/bearer_auth.d.ts +9 -7
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +13 -21
- package/dist/auth/bootstrap_account.d.ts +7 -7
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +7 -7
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +11 -10
- package/dist/auth/cleanup.d.ts +20 -26
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +33 -42
- package/dist/auth/credential_type_schema.d.ts +115 -0
- package/dist/auth/credential_type_schema.d.ts.map +1 -0
- package/dist/auth/credential_type_schema.js +127 -0
- package/dist/auth/daemon_token_middleware.d.ts +23 -11
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +28 -22
- package/dist/auth/ddl.d.ts +2 -2
- package/dist/auth/ddl.d.ts.map +1 -1
- package/dist/auth/ddl.js +6 -6
- package/dist/auth/deps.d.ts +7 -18
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.d.ts +117 -0
- package/dist/auth/grant_path_schema.d.ts.map +1 -0
- package/dist/auth/grant_path_schema.js +137 -0
- package/dist/auth/invite_queries.d.ts +12 -1
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +12 -1
- package/dist/auth/invite_schema.d.ts +1 -1
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +1 -1
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +9 -4
- package/dist/auth/migrations.d.ts +37 -14
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +79 -32
- package/dist/auth/request_context.d.ts +331 -61
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +378 -95
- package/dist/auth/{permit_offer_action_specs.d.ts → role_grant_offer_action_specs.d.ts} +163 -94
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_action_specs.js +262 -0
- package/dist/auth/role_grant_offer_actions.d.ts +104 -0
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_actions.js +473 -0
- package/dist/auth/{permit_offer_notifications.d.ts → role_grant_offer_notifications.d.ts} +90 -70
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_notifications.js +182 -0
- package/dist/auth/role_grant_offer_queries.d.ts +242 -0
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_queries.js +533 -0
- package/dist/auth/role_grant_offer_schema.d.ts +150 -0
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -0
- package/dist/auth/{permit_offer_schema.js → role_grant_offer_schema.js} +60 -36
- package/dist/auth/role_grant_queries.d.ts +231 -0
- package/dist/auth/role_grant_queries.d.ts.map +1 -0
- package/dist/auth/role_grant_queries.js +320 -0
- package/dist/auth/role_schema.d.ts +150 -40
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +144 -45
- package/dist/auth/scope_kind_schema.d.ts +96 -0
- package/dist/auth/scope_kind_schema.d.ts.map +1 -0
- package/dist/auth/scope_kind_schema.js +94 -0
- package/dist/auth/self_service_role_action_specs.d.ts +6 -1
- package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
- package/dist/auth/self_service_role_action_specs.js +3 -1
- package/dist/auth/self_service_role_actions.d.ts +34 -27
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +68 -48
- package/dist/auth/session_cookie.d.ts +43 -6
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +31 -5
- package/dist/auth/session_middleware.d.ts +37 -3
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +33 -7
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +48 -19
- package/dist/auth/standard_action_specs.d.ts +2 -2
- package/dist/auth/standard_action_specs.js +4 -4
- package/dist/auth/standard_rpc_actions.d.ts +23 -19
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +12 -12
- package/dist/db/migrate.d.ts +12 -8
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +10 -7
- package/dist/dev/setup.d.ts +2 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +9 -7
- package/dist/env/load.d.ts +1 -1
- package/dist/env/load.js +1 -1
- package/dist/hono_context.d.ts +64 -5
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +38 -2
- package/dist/http/CLAUDE.md +264 -87
- package/dist/http/auth_shape.d.ts +191 -0
- package/dist/http/auth_shape.d.ts.map +1 -0
- package/dist/http/auth_shape.js +237 -0
- package/dist/http/common_routes.js +3 -3
- package/dist/http/db_routes.d.ts +4 -0
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +44 -7
- package/dist/http/error_schemas.d.ts +132 -19
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +132 -40
- package/dist/http/jsonrpc_errors.d.ts +27 -2
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +26 -2
- package/dist/http/pending_effects.d.ts +71 -18
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +87 -18
- package/dist/http/proxy.d.ts +52 -5
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +92 -14
- package/dist/http/route_spec.d.ts +113 -41
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +130 -52
- package/dist/http/schema_helpers.d.ts +3 -2
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +9 -2
- package/dist/http/surface.d.ts +2 -1
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +1 -2
- package/dist/http/surface_query.d.ts +39 -35
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +79 -36
- package/dist/primitive_schemas.d.ts +39 -0
- package/dist/primitive_schemas.d.ts.map +1 -0
- package/dist/primitive_schemas.js +40 -0
- package/dist/realtime/sse_auth_guard.d.ts +5 -5
- package/dist/realtime/sse_auth_guard.js +9 -9
- package/dist/runtime/mock.d.ts +1 -1
- package/dist/runtime/mock.js +1 -1
- package/dist/server/app_backend.d.ts +14 -11
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +12 -8
- package/dist/server/app_server.d.ts +7 -7
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +36 -31
- package/dist/server/validate_nginx.d.ts +1 -1
- package/dist/server/validate_nginx.js +1 -1
- package/dist/testing/CLAUDE.md +73 -55
- package/dist/testing/admin_integration.d.ts +5 -6
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +100 -96
- package/dist/testing/adversarial_headers.js +1 -1
- package/dist/testing/app_server.d.ts +11 -14
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +18 -17
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +2 -1
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +15 -9
- package/dist/testing/audit_completeness.d.ts +2 -2
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +53 -39
- package/dist/testing/auth_apps.d.ts +5 -4
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +28 -22
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +5 -5
- package/dist/testing/db.d.ts +1 -1
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +4 -4
- package/dist/testing/db_entities.d.ts +22 -0
- package/dist/testing/db_entities.d.ts.map +1 -0
- package/dist/testing/db_entities.js +28 -0
- package/dist/testing/entities.d.ts +10 -8
- package/dist/testing/entities.d.ts.map +1 -1
- package/dist/testing/entities.js +22 -18
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +13 -14
- package/dist/testing/integration_helpers.d.ts +8 -6
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +29 -23
- package/dist/testing/middleware.d.ts +15 -11
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +75 -32
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +40 -24
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +3 -1
- package/dist/testing/rpc_round_trip.d.ts +1 -1
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +14 -13
- package/dist/testing/sse_round_trip.d.ts +3 -4
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +7 -11
- package/dist/testing/standard.d.ts +1 -1
- package/dist/testing/stubs.d.ts +25 -0
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +43 -2
- package/dist/testing/surface_invariants.d.ts +2 -2
- package/dist/testing/ws_round_trip.d.ts +12 -13
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +24 -12
- package/dist/ui/AdminAccounts.svelte +23 -20
- package/dist/ui/AdminOverview.svelte +15 -13
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/{AdminPermitHistory.svelte → AdminRoleGrantHistory.svelte} +12 -12
- package/dist/ui/AdminRoleGrantHistory.svelte.d.ts +4 -0
- package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -0
- package/dist/ui/BootstrapForm.svelte +1 -1
- package/dist/ui/CLAUDE.md +65 -59
- package/dist/ui/{PermitOfferForm.svelte → RoleGrantOfferForm.svelte} +37 -22
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts +20 -0
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -0
- package/dist/ui/{PermitOfferHistory.svelte → RoleGrantOfferHistory.svelte} +12 -12
- package/dist/ui/{PermitOfferHistory.svelte.d.ts → RoleGrantOfferHistory.svelte.d.ts} +4 -4
- package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -0
- package/dist/ui/{PermitOfferInbox.svelte → RoleGrantOfferInbox.svelte} +14 -14
- package/dist/ui/{PermitOfferInbox.svelte.d.ts → RoleGrantOfferInbox.svelte.d.ts} +4 -4
- package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -0
- package/dist/ui/SignupForm.svelte +1 -1
- package/dist/ui/SurfaceExplorer.svelte +35 -15
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +2 -3
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.js +2 -3
- package/dist/ui/admin_accounts_state.svelte.d.ts +25 -18
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +28 -17
- package/dist/ui/admin_rpc_adapters.d.ts +20 -20
- package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.js +17 -17
- package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/admin_sessions_state.svelte.js +2 -2
- package/dist/ui/audit_log_state.svelte.d.ts +7 -7
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +6 -6
- package/dist/ui/auth_state.svelte.d.ts +3 -3
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +6 -6
- package/dist/ui/format_scope.d.ts +2 -2
- package/dist/ui/format_scope.js +2 -2
- package/dist/ui/{permit_offers_state.svelte.d.ts → role_grant_offers_state.svelte.d.ts} +39 -31
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -0
- package/dist/ui/{permit_offers_state.svelte.js → role_grant_offers_state.svelte.js} +25 -19
- package/dist/ui/ui_format.js +2 -2
- package/package.json +3 -3
- package/dist/auth/permit_offer_action_specs.d.ts.map +0 -1
- package/dist/auth/permit_offer_action_specs.js +0 -227
- package/dist/auth/permit_offer_actions.d.ts +0 -110
- package/dist/auth/permit_offer_actions.d.ts.map +0 -1
- package/dist/auth/permit_offer_actions.js +0 -452
- package/dist/auth/permit_offer_notifications.d.ts.map +0 -1
- package/dist/auth/permit_offer_notifications.js +0 -182
- package/dist/auth/permit_offer_queries.d.ts +0 -183
- package/dist/auth/permit_offer_queries.d.ts.map +0 -1
- package/dist/auth/permit_offer_queries.js +0 -408
- package/dist/auth/permit_offer_schema.d.ts +0 -103
- package/dist/auth/permit_offer_schema.d.ts.map +0 -1
- package/dist/auth/permit_queries.d.ts +0 -210
- package/dist/auth/permit_queries.d.ts.map +0 -1
- package/dist/auth/permit_queries.js +0 -294
- package/dist/auth/require_keeper.d.ts +0 -20
- package/dist/auth/require_keeper.d.ts.map +0 -1
- package/dist/auth/require_keeper.js +0 -35
- package/dist/auth/route_guards.d.ts +0 -21
- package/dist/auth/route_guards.d.ts.map +0 -1
- package/dist/auth/route_guards.js +0 -32
- package/dist/auth/session_lifecycle.d.ts +0 -37
- package/dist/auth/session_lifecycle.d.ts.map +0 -1
- package/dist/auth/session_lifecycle.js +0 -29
- package/dist/ui/AdminPermitHistory.svelte.d.ts +0 -4
- package/dist/ui/AdminPermitHistory.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferForm.svelte.d.ts +0 -14
- package/dist/ui/PermitOfferForm.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferHistory.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferInbox.svelte.d.ts.map +0 -1
- package/dist/ui/permit_offers_state.svelte.d.ts.map +0 -1
|
@@ -18,22 +18,42 @@
|
|
|
18
18
|
import { z } from 'zod';
|
|
19
19
|
import { Uuid } from '@fuzdev/fuz_util/id.js';
|
|
20
20
|
import { ROLE_ADMIN, RoleName } from './role_schema.js';
|
|
21
|
-
import { AdminAccountEntryJson
|
|
22
|
-
import {
|
|
21
|
+
import { AdminAccountEntryJson } from './account_schema.js';
|
|
22
|
+
import { Email, Username } from '../primitive_schemas.js';
|
|
23
|
+
import { ActingActor } from '../http/auth_shape.js';
|
|
24
|
+
import { AdminSessionJson, AUDIT_LOG_DEFAULT_LIMIT, AuditEventTypeName, AuditLogEventWithUsernamesJson, AuditOutcome, RoleGrantHistoryEventJson, } from './audit_log_schema.js';
|
|
23
25
|
import { InviteJson, InviteWithUsernamesJson } from './invite_schema.js';
|
|
24
26
|
import { AppSettingsWithUsernameJson } from './app_settings_schema.js';
|
|
25
|
-
/** Max audit-log page size.
|
|
27
|
+
/** Max audit-log page size. */
|
|
26
28
|
export const AUDIT_LOG_LIST_LIMIT_MAX = 200;
|
|
29
|
+
/** Default `admin_account_list` page size. */
|
|
30
|
+
export const ADMIN_ACCOUNT_LIST_DEFAULT_LIMIT = 50;
|
|
31
|
+
/** Max `admin_account_list` page size. */
|
|
32
|
+
export const ADMIN_ACCOUNT_LIST_LIMIT_MAX = 200;
|
|
27
33
|
// -- Input/output schemas ---------------------------------------------------
|
|
28
|
-
/** Input for `admin_account_list`.
|
|
29
|
-
export const AdminAccountListInput = z.
|
|
34
|
+
/** Input for `admin_account_list`. */
|
|
35
|
+
export const AdminAccountListInput = z.strictObject({
|
|
36
|
+
acting: ActingActor,
|
|
37
|
+
limit: z
|
|
38
|
+
.number()
|
|
39
|
+
.int()
|
|
40
|
+
.min(1)
|
|
41
|
+
.max(ADMIN_ACCOUNT_LIST_LIMIT_MAX)
|
|
42
|
+
.nullish()
|
|
43
|
+
.meta({
|
|
44
|
+
description: `Max accounts to return (default ${ADMIN_ACCOUNT_LIST_DEFAULT_LIMIT}, max ${ADMIN_ACCOUNT_LIST_LIMIT_MAX}).`,
|
|
45
|
+
}),
|
|
46
|
+
offset: z.number().int().min(0).nullish().meta({ description: 'Pagination offset.' }),
|
|
47
|
+
});
|
|
30
48
|
/** Output for `admin_account_list`. */
|
|
31
49
|
export const AdminAccountListOutput = z.strictObject({
|
|
32
50
|
accounts: z.array(AdminAccountEntryJson),
|
|
33
51
|
grantable_roles: z.array(RoleName),
|
|
34
52
|
});
|
|
35
|
-
/** Input for `admin_session_list`.
|
|
36
|
-
export const AdminSessionListInput = z.
|
|
53
|
+
/** Input for `admin_session_list`. */
|
|
54
|
+
export const AdminSessionListInput = z.strictObject({
|
|
55
|
+
acting: ActingActor,
|
|
56
|
+
});
|
|
37
57
|
/** Output for `admin_session_list`. Cross-account listing; fan-out already scoped by role auth. */
|
|
38
58
|
export const AdminSessionListOutput = z.strictObject({
|
|
39
59
|
sessions: z.array(AdminSessionJson),
|
|
@@ -41,6 +61,7 @@ export const AdminSessionListOutput = z.strictObject({
|
|
|
41
61
|
/** Input for `admin_session_revoke_all`. */
|
|
42
62
|
export const AdminSessionRevokeAllInput = z.strictObject({
|
|
43
63
|
account_id: Uuid.meta({ description: 'Account whose sessions to revoke.' }),
|
|
64
|
+
acting: ActingActor,
|
|
44
65
|
});
|
|
45
66
|
/** Output for `admin_session_revoke_all`. */
|
|
46
67
|
export const AdminSessionRevokeAllOutput = z.strictObject({
|
|
@@ -50,6 +71,7 @@ export const AdminSessionRevokeAllOutput = z.strictObject({
|
|
|
50
71
|
/** Input for `admin_token_revoke_all`. */
|
|
51
72
|
export const AdminTokenRevokeAllInput = z.strictObject({
|
|
52
73
|
account_id: Uuid.meta({ description: 'Account whose API tokens to revoke.' }),
|
|
74
|
+
acting: ActingActor,
|
|
53
75
|
});
|
|
54
76
|
/** Output for `admin_token_revoke_all`. */
|
|
55
77
|
export const AdminTokenRevokeAllOutput = z.strictObject({
|
|
@@ -83,13 +105,14 @@ export const AuditLogListInput = z.strictObject({
|
|
|
83
105
|
since_seq: z.number().int().min(0).nullish().meta({
|
|
84
106
|
description: 'Gap-fill from this seq forward. Used for SSE reconnection.',
|
|
85
107
|
}),
|
|
108
|
+
acting: ActingActor,
|
|
86
109
|
});
|
|
87
110
|
/** Output for `audit_log_list`. */
|
|
88
111
|
export const AuditLogListOutput = z.strictObject({
|
|
89
112
|
events: z.array(AuditLogEventWithUsernamesJson),
|
|
90
113
|
});
|
|
91
|
-
/** Input for `
|
|
92
|
-
export const
|
|
114
|
+
/** Input for `audit_log_role_grant_history`. */
|
|
115
|
+
export const AuditLogRoleGrantHistoryInput = z.strictObject({
|
|
93
116
|
limit: z
|
|
94
117
|
.number()
|
|
95
118
|
.int()
|
|
@@ -100,15 +123,17 @@ export const AuditLogPermitHistoryInput = z.strictObject({
|
|
|
100
123
|
description: `Max rows to return (default ${AUDIT_LOG_DEFAULT_LIMIT}, max ${AUDIT_LOG_LIST_LIMIT_MAX}).`,
|
|
101
124
|
}),
|
|
102
125
|
offset: z.number().int().min(0).nullish().meta({ description: 'Pagination offset.' }),
|
|
126
|
+
acting: ActingActor,
|
|
103
127
|
});
|
|
104
|
-
/** Output for `
|
|
105
|
-
export const
|
|
106
|
-
events: z.array(
|
|
128
|
+
/** Output for `audit_log_role_grant_history`. */
|
|
129
|
+
export const AuditLogRoleGrantHistoryOutput = z.strictObject({
|
|
130
|
+
events: z.array(RoleGrantHistoryEventJson),
|
|
107
131
|
});
|
|
108
132
|
/** Input for `invite_create`. At least one of `email` / `username` must be provided. */
|
|
109
133
|
export const InviteCreateInput = z.strictObject({
|
|
110
134
|
email: Email.nullish().meta({ description: 'Invitee email.' }),
|
|
111
135
|
username: Username.nullish().meta({ description: 'Invitee username.' }),
|
|
136
|
+
acting: ActingActor,
|
|
112
137
|
});
|
|
113
138
|
/** Output for `invite_create`. */
|
|
114
139
|
export const InviteCreateOutput = z.strictObject({
|
|
@@ -116,7 +141,9 @@ export const InviteCreateOutput = z.strictObject({
|
|
|
116
141
|
invite: InviteJson,
|
|
117
142
|
});
|
|
118
143
|
/** Input for `invite_list`. */
|
|
119
|
-
export const InviteListInput = z.
|
|
144
|
+
export const InviteListInput = z.strictObject({
|
|
145
|
+
acting: ActingActor,
|
|
146
|
+
});
|
|
120
147
|
/** Output for `invite_list`. Uses the enriched row including creator/claimer usernames. */
|
|
121
148
|
export const InviteListOutput = z.strictObject({
|
|
122
149
|
invites: z.array(InviteWithUsernamesJson),
|
|
@@ -124,13 +151,16 @@ export const InviteListOutput = z.strictObject({
|
|
|
124
151
|
/** Input for `invite_delete`. */
|
|
125
152
|
export const InviteDeleteInput = z.strictObject({
|
|
126
153
|
invite_id: Uuid.meta({ description: 'Invite to delete. Must be unclaimed.' }),
|
|
154
|
+
acting: ActingActor,
|
|
127
155
|
});
|
|
128
156
|
/** Output for `invite_delete`. */
|
|
129
157
|
export const InviteDeleteOutput = z.strictObject({
|
|
130
158
|
ok: z.literal(true),
|
|
131
159
|
});
|
|
132
|
-
/** Input for `app_settings_get`.
|
|
133
|
-
export const AppSettingsGetInput = z.
|
|
160
|
+
/** Input for `app_settings_get`. */
|
|
161
|
+
export const AppSettingsGetInput = z.strictObject({
|
|
162
|
+
acting: ActingActor,
|
|
163
|
+
});
|
|
134
164
|
/** Output for `app_settings_get`. */
|
|
135
165
|
export const AppSettingsGetOutput = z.strictObject({
|
|
136
166
|
settings: AppSettingsWithUsernameJson,
|
|
@@ -138,6 +168,7 @@ export const AppSettingsGetOutput = z.strictObject({
|
|
|
138
168
|
/** Input for `app_settings_update`. */
|
|
139
169
|
export const AppSettingsUpdateInput = z.strictObject({
|
|
140
170
|
open_signup: z.boolean().meta({ description: 'New value for the open signup toggle.' }),
|
|
171
|
+
acting: ActingActor,
|
|
141
172
|
});
|
|
142
173
|
/** Output for `app_settings_update`. */
|
|
143
174
|
export const AppSettingsUpdateOutput = z.strictObject({
|
|
@@ -149,18 +180,18 @@ export const admin_account_list_action_spec = {
|
|
|
149
180
|
method: 'admin_account_list',
|
|
150
181
|
kind: 'request_response',
|
|
151
182
|
initiator: 'frontend',
|
|
152
|
-
auth: {
|
|
183
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
153
184
|
side_effects: false,
|
|
154
185
|
input: AdminAccountListInput,
|
|
155
186
|
output: AdminAccountListOutput,
|
|
156
187
|
async: true,
|
|
157
|
-
description: 'List all accounts with their actors,
|
|
188
|
+
description: 'List all accounts with their actors, role_grants, and pending offers. Admin-only.',
|
|
158
189
|
};
|
|
159
190
|
export const admin_session_list_action_spec = {
|
|
160
191
|
method: 'admin_session_list',
|
|
161
192
|
kind: 'request_response',
|
|
162
193
|
initiator: 'frontend',
|
|
163
|
-
auth: {
|
|
194
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
164
195
|
side_effects: false,
|
|
165
196
|
input: AdminSessionListInput,
|
|
166
197
|
output: AdminSessionListOutput,
|
|
@@ -171,7 +202,7 @@ export const admin_session_revoke_all_action_spec = {
|
|
|
171
202
|
method: 'admin_session_revoke_all',
|
|
172
203
|
kind: 'request_response',
|
|
173
204
|
initiator: 'frontend',
|
|
174
|
-
auth: {
|
|
205
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
175
206
|
side_effects: true,
|
|
176
207
|
input: AdminSessionRevokeAllInput,
|
|
177
208
|
output: AdminSessionRevokeAllOutput,
|
|
@@ -183,7 +214,7 @@ export const admin_token_revoke_all_action_spec = {
|
|
|
183
214
|
method: 'admin_token_revoke_all',
|
|
184
215
|
kind: 'request_response',
|
|
185
216
|
initiator: 'frontend',
|
|
186
|
-
auth: {
|
|
217
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
187
218
|
side_effects: true,
|
|
188
219
|
input: AdminTokenRevokeAllInput,
|
|
189
220
|
output: AdminTokenRevokeAllOutput,
|
|
@@ -195,29 +226,29 @@ export const audit_log_list_action_spec = {
|
|
|
195
226
|
method: 'audit_log_list',
|
|
196
227
|
kind: 'request_response',
|
|
197
228
|
initiator: 'frontend',
|
|
198
|
-
auth: {
|
|
229
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
199
230
|
side_effects: false,
|
|
200
231
|
input: AuditLogListInput,
|
|
201
232
|
output: AuditLogListOutput,
|
|
202
233
|
async: true,
|
|
203
234
|
description: 'List audit log events with optional filters. Admin-only.',
|
|
204
235
|
};
|
|
205
|
-
export const
|
|
206
|
-
method: '
|
|
236
|
+
export const audit_log_role_grant_history_action_spec = {
|
|
237
|
+
method: 'audit_log_role_grant_history',
|
|
207
238
|
kind: 'request_response',
|
|
208
239
|
initiator: 'frontend',
|
|
209
|
-
auth: {
|
|
240
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
210
241
|
side_effects: false,
|
|
211
|
-
input:
|
|
212
|
-
output:
|
|
242
|
+
input: AuditLogRoleGrantHistoryInput,
|
|
243
|
+
output: AuditLogRoleGrantHistoryOutput,
|
|
213
244
|
async: true,
|
|
214
|
-
description: 'List
|
|
245
|
+
description: 'List role_grant grant and revoke events with usernames. Admin-only.',
|
|
215
246
|
};
|
|
216
247
|
export const invite_create_action_spec = {
|
|
217
248
|
method: 'invite_create',
|
|
218
249
|
kind: 'request_response',
|
|
219
250
|
initiator: 'frontend',
|
|
220
|
-
auth: {
|
|
251
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
221
252
|
side_effects: true,
|
|
222
253
|
input: InviteCreateInput,
|
|
223
254
|
output: InviteCreateOutput,
|
|
@@ -229,7 +260,7 @@ export const invite_list_action_spec = {
|
|
|
229
260
|
method: 'invite_list',
|
|
230
261
|
kind: 'request_response',
|
|
231
262
|
initiator: 'frontend',
|
|
232
|
-
auth: {
|
|
263
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
233
264
|
side_effects: false,
|
|
234
265
|
input: InviteListInput,
|
|
235
266
|
output: InviteListOutput,
|
|
@@ -240,7 +271,7 @@ export const invite_delete_action_spec = {
|
|
|
240
271
|
method: 'invite_delete',
|
|
241
272
|
kind: 'request_response',
|
|
242
273
|
initiator: 'frontend',
|
|
243
|
-
auth: {
|
|
274
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
244
275
|
side_effects: true,
|
|
245
276
|
input: InviteDeleteInput,
|
|
246
277
|
output: InviteDeleteOutput,
|
|
@@ -252,7 +283,7 @@ export const app_settings_get_action_spec = {
|
|
|
252
283
|
method: 'app_settings_get',
|
|
253
284
|
kind: 'request_response',
|
|
254
285
|
initiator: 'frontend',
|
|
255
|
-
auth: {
|
|
286
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
256
287
|
side_effects: false,
|
|
257
288
|
input: AppSettingsGetInput,
|
|
258
289
|
output: AppSettingsGetOutput,
|
|
@@ -263,7 +294,7 @@ export const app_settings_update_action_spec = {
|
|
|
263
294
|
method: 'app_settings_update',
|
|
264
295
|
kind: 'request_response',
|
|
265
296
|
initiator: 'frontend',
|
|
266
|
-
auth: {
|
|
297
|
+
auth: { account: 'required', actor: 'required', roles: [ROLE_ADMIN] },
|
|
267
298
|
side_effects: true,
|
|
268
299
|
input: AppSettingsUpdateInput,
|
|
269
300
|
output: AppSettingsUpdateOutput,
|
|
@@ -284,7 +315,7 @@ export const all_admin_action_specs = [
|
|
|
284
315
|
admin_session_revoke_all_action_spec,
|
|
285
316
|
admin_token_revoke_all_action_spec,
|
|
286
317
|
audit_log_list_action_spec,
|
|
287
|
-
|
|
318
|
+
audit_log_role_grant_history_action_spec,
|
|
288
319
|
invite_create_action_spec,
|
|
289
320
|
invite_list_action_spec,
|
|
290
321
|
invite_delete_action_spec,
|
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
*
|
|
6
6
|
* - Account management: `admin_account_list`, `admin_session_list`,
|
|
7
7
|
* `admin_session_revoke_all`, `admin_token_revoke_all`.
|
|
8
|
-
* - Audit log reads: `audit_log_list`, `
|
|
8
|
+
* - Audit log reads: `audit_log_list`, `audit_log_role_grant_history`.
|
|
9
9
|
* - Invite CRUD: `invite_create`, `invite_list`, `invite_delete`.
|
|
10
10
|
* - App settings: `app_settings_get`, `app_settings_update` (registered only
|
|
11
11
|
* when `AdminActionOptions.app_settings` is provided — the mutable ref is
|
|
12
12
|
* owned by the server context and shared with signup middleware).
|
|
13
13
|
*
|
|
14
14
|
* The action specs themselves live in `auth/admin_action_specs.ts`. Mutations
|
|
15
|
-
* emit matching audit events via `
|
|
15
|
+
* emit matching audit events via `deps.audit.emit`.
|
|
16
16
|
*
|
|
17
17
|
* Authorization is declared at the spec level (`auth: {role: 'admin'}`) so
|
|
18
18
|
* the RPC dispatcher enforces it before the handler runs and the generated
|
|
19
|
-
* surface accurately reports the requirement. `
|
|
20
|
-
* `auth/
|
|
19
|
+
* surface accurately reports the requirement. `role_grant_revoke` in
|
|
20
|
+
* `auth/role_grant_offer_actions.ts` uses the same spec-level pattern even though its
|
|
21
21
|
* sibling methods are authenticated-but-not-admin — the dispatcher checks
|
|
22
22
|
* auth per-spec, so mixed-auth endpoints compose cleanly. Handler-level
|
|
23
23
|
* gates are reserved for input-dependent elevation (e.g.
|
|
24
|
-
* `
|
|
24
|
+
* `role_grant_offer_list`/`_history` elevate to admin only when the caller
|
|
25
25
|
* passes an `account_id` other than their own — an input-dependent check
|
|
26
26
|
* the spec can't express).
|
|
27
27
|
*
|
|
@@ -35,8 +35,9 @@ import type { RouteFactoryDeps } from './deps.js';
|
|
|
35
35
|
export interface AdminActionOptions {
|
|
36
36
|
/**
|
|
37
37
|
* Role schema result from `create_role_schema()`. Defaults to builtin
|
|
38
|
-
* roles only. Used to derive `grantable_roles` (the
|
|
39
|
-
*
|
|
38
|
+
* roles only. Used to derive `grantable_roles` (the subset whose
|
|
39
|
+
* `RoleSpec.grant_paths` includes `'admin'`) returned by
|
|
40
|
+
* `admin_account_list`.
|
|
40
41
|
*/
|
|
41
42
|
roles?: RoleSchemaResult;
|
|
42
43
|
/**
|
|
@@ -49,23 +50,16 @@ export interface AdminActionOptions {
|
|
|
49
50
|
*/
|
|
50
51
|
app_settings?: AppSettings;
|
|
51
52
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Dependencies for `create_admin_actions`.
|
|
54
|
-
*
|
|
55
|
-
* Shares shape with `PermitOfferActionDeps` so consumers can pass the same
|
|
56
|
-
* deps to both factories. `log` drives RPC-internal error logging;
|
|
57
|
-
* `on_audit_event` is wired by the two revoke-all mutations so SSE fan-out
|
|
58
|
-
* mirrors the former REST-route behavior. `audit_log_config` flows from
|
|
59
|
-
* `AppDeps` and is consumed by `audit_log_fire_and_forget`.
|
|
60
|
-
*/
|
|
61
|
-
export type AdminActionDeps = Pick<RouteFactoryDeps, 'log' | 'on_audit_event' | 'audit_log_config'>;
|
|
62
53
|
/**
|
|
63
54
|
* Create the admin-only RPC actions.
|
|
64
55
|
*
|
|
65
|
-
* @param deps - `
|
|
56
|
+
* @param deps - `RouteFactoryDeps` (`log`, `audit`, …). `log` drives RPC-
|
|
57
|
+
* internal error logging; `audit.emit` writes audit rows via the captured
|
|
58
|
+
* pool. The bound emitter encapsulates `on_audit_event` fan-out and the
|
|
59
|
+
* optional `AuditLogConfig`.
|
|
66
60
|
* @param options - role schema for `grantable_roles` derivation
|
|
67
61
|
* @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
|
|
68
62
|
* @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
|
|
69
63
|
*/
|
|
70
|
-
export declare const create_admin_actions: (deps:
|
|
64
|
+
export declare const create_admin_actions: (deps: Pick<RouteFactoryDeps, "log" | "audit">, options?: AdminActionOptions) => Array<RpcAction>;
|
|
71
65
|
//# 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,
|
|
1
|
+
{"version":3,"file":"admin_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/admin_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAsC,KAAK,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAE7F,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAuB1B,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAK1D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AA8ChD,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,OAAO,CAAC,EAC7C,UAAS,kBAAuB,KAC9B,KAAK,CAAC,SAAS,CAgQjB,CAAC"}
|
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
*
|
|
6
6
|
* - Account management: `admin_account_list`, `admin_session_list`,
|
|
7
7
|
* `admin_session_revoke_all`, `admin_token_revoke_all`.
|
|
8
|
-
* - Audit log reads: `audit_log_list`, `
|
|
8
|
+
* - Audit log reads: `audit_log_list`, `audit_log_role_grant_history`.
|
|
9
9
|
* - Invite CRUD: `invite_create`, `invite_list`, `invite_delete`.
|
|
10
10
|
* - App settings: `app_settings_get`, `app_settings_update` (registered only
|
|
11
11
|
* when `AdminActionOptions.app_settings` is provided — the mutable ref is
|
|
12
12
|
* owned by the server context and shared with signup middleware).
|
|
13
13
|
*
|
|
14
14
|
* The action specs themselves live in `auth/admin_action_specs.ts`. Mutations
|
|
15
|
-
* emit matching audit events via `
|
|
15
|
+
* emit matching audit events via `deps.audit.emit`.
|
|
16
16
|
*
|
|
17
17
|
* Authorization is declared at the spec level (`auth: {role: 'admin'}`) so
|
|
18
18
|
* the RPC dispatcher enforces it before the handler runs and the generated
|
|
19
|
-
* surface accurately reports the requirement. `
|
|
20
|
-
* `auth/
|
|
19
|
+
* surface accurately reports the requirement. `role_grant_revoke` in
|
|
20
|
+
* `auth/role_grant_offer_actions.ts` uses the same spec-level pattern even though its
|
|
21
21
|
* sibling methods are authenticated-but-not-admin — the dispatcher checks
|
|
22
22
|
* auth per-spec, so mixed-auth endpoints compose cleanly. Handler-level
|
|
23
23
|
* gates are reserved for input-dependent elevation (e.g.
|
|
24
|
-
* `
|
|
24
|
+
* `role_grant_offer_list`/`_history` elevate to admin only when the caller
|
|
25
25
|
* passes an `account_id` other than their own — an input-dependent check
|
|
26
26
|
* the spec can't express).
|
|
27
27
|
*
|
|
@@ -29,35 +29,38 @@
|
|
|
29
29
|
*/
|
|
30
30
|
import { rpc_action } from '../actions/action_rpc.js';
|
|
31
31
|
import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
|
|
32
|
-
import {
|
|
32
|
+
import { BUILTIN_ROLE_SPECS_BY_NAME, list_roles_with_grant_path, } from './role_schema.js';
|
|
33
|
+
import { GRANT_PATH_ADMIN } from './grant_path_schema.js';
|
|
33
34
|
import { query_account_by_email, query_account_by_id, query_account_by_username, query_admin_account_list, } from './account_queries.js';
|
|
34
35
|
import { query_session_list_all_active, query_session_revoke_all_for_account, } from './session_queries.js';
|
|
35
36
|
import { query_revoke_all_api_tokens_for_account } from './api_token_queries.js';
|
|
36
|
-
import {
|
|
37
|
+
import { query_audit_log_list_role_grant_history, query_audit_log_list_with_usernames, } from './audit_log_queries.js';
|
|
37
38
|
import { AUDIT_LOG_DEFAULT_LIMIT } from './audit_log_schema.js';
|
|
38
39
|
import { query_create_invite, query_invite_delete_unclaimed, query_invite_list_all_with_usernames, } from './invite_queries.js';
|
|
39
40
|
import {} from './app_settings_schema.js';
|
|
40
41
|
import { query_app_settings_load_with_username, query_app_settings_update, } from './app_settings_queries.js';
|
|
41
42
|
import { is_pg_unique_violation } from '../db/pg_error.js';
|
|
42
43
|
import { ERROR_ACCOUNT_NOT_FOUND, ERROR_INVITE_ACCOUNT_EXISTS_EMAIL, ERROR_INVITE_ACCOUNT_EXISTS_USERNAME, ERROR_INVITE_DUPLICATE, ERROR_INVITE_MISSING_IDENTIFIER, ERROR_INVITE_NOT_FOUND, } from '../http/error_schemas.js';
|
|
43
|
-
import { admin_account_list_action_spec, admin_session_list_action_spec, admin_session_revoke_all_action_spec, admin_token_revoke_all_action_spec, audit_log_list_action_spec,
|
|
44
|
+
import { admin_account_list_action_spec, admin_session_list_action_spec, admin_session_revoke_all_action_spec, admin_token_revoke_all_action_spec, audit_log_list_action_spec, audit_log_role_grant_history_action_spec, invite_create_action_spec, invite_list_action_spec, invite_delete_action_spec, app_settings_get_action_spec, app_settings_update_action_spec, } from './admin_action_specs.js';
|
|
44
45
|
/**
|
|
45
46
|
* Create the admin-only RPC actions.
|
|
46
47
|
*
|
|
47
|
-
* @param deps - `
|
|
48
|
+
* @param deps - `RouteFactoryDeps` (`log`, `audit`, …). `log` drives RPC-
|
|
49
|
+
* internal error logging; `audit.emit` writes audit rows via the captured
|
|
50
|
+
* pool. The bound emitter encapsulates `on_audit_event` fan-out and the
|
|
51
|
+
* optional `AuditLogConfig`.
|
|
48
52
|
* @param options - role schema for `grantable_roles` derivation
|
|
49
53
|
* @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
|
|
50
54
|
* @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
|
|
51
55
|
*/
|
|
52
56
|
export const create_admin_actions = (deps, options = {}) => {
|
|
53
|
-
const
|
|
54
|
-
const grantable_roles =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const accounts = await query_admin_account_list(ctx);
|
|
57
|
+
const role_specs = options.roles?.role_specs ?? BUILTIN_ROLE_SPECS_BY_NAME;
|
|
58
|
+
const grantable_roles = list_roles_with_grant_path(role_specs, GRANT_PATH_ADMIN);
|
|
59
|
+
const account_list_handler = async (input, ctx) => {
|
|
60
|
+
const accounts = await query_admin_account_list(ctx, {
|
|
61
|
+
limit: input.limit,
|
|
62
|
+
offset: input.offset,
|
|
63
|
+
});
|
|
61
64
|
return { accounts, grantable_roles };
|
|
62
65
|
};
|
|
63
66
|
const session_list_handler = async (_input, ctx) => {
|
|
@@ -68,10 +71,9 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
68
71
|
const auth = ctx.auth;
|
|
69
72
|
const account = await query_account_by_id(ctx, input.account_id);
|
|
70
73
|
if (!account) {
|
|
71
|
-
|
|
74
|
+
deps.audit.emit(ctx, {
|
|
72
75
|
event_type: 'session_revoke_all',
|
|
73
76
|
outcome: 'failure',
|
|
74
|
-
actor_id: auth.actor.id,
|
|
75
77
|
account_id: auth.account.id,
|
|
76
78
|
// `target_account_id` is null: the FK to `account` would reject
|
|
77
79
|
// a probe for a non-existent id. The probed value is preserved
|
|
@@ -82,28 +84,26 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
82
84
|
reason: ERROR_ACCOUNT_NOT_FOUND,
|
|
83
85
|
attempted_account_id: input.account_id,
|
|
84
86
|
},
|
|
85
|
-
}
|
|
87
|
+
});
|
|
86
88
|
throw jsonrpc_errors.not_found('account', { reason: ERROR_ACCOUNT_NOT_FOUND });
|
|
87
89
|
}
|
|
88
90
|
const count = await query_session_revoke_all_for_account(ctx, input.account_id);
|
|
89
|
-
|
|
91
|
+
deps.audit.emit(ctx, {
|
|
90
92
|
event_type: 'session_revoke_all',
|
|
91
|
-
actor_id: auth.actor.id,
|
|
92
93
|
account_id: auth.account.id,
|
|
93
94
|
target_account_id: input.account_id,
|
|
94
95
|
ip: ctx.client_ip,
|
|
95
96
|
metadata: { count },
|
|
96
|
-
}
|
|
97
|
+
});
|
|
97
98
|
return { ok: true, count };
|
|
98
99
|
};
|
|
99
100
|
const token_revoke_all_handler = async (input, ctx) => {
|
|
100
101
|
const auth = ctx.auth;
|
|
101
102
|
const account = await query_account_by_id(ctx, input.account_id);
|
|
102
103
|
if (!account) {
|
|
103
|
-
|
|
104
|
+
deps.audit.emit(ctx, {
|
|
104
105
|
event_type: 'token_revoke_all',
|
|
105
106
|
outcome: 'failure',
|
|
106
|
-
actor_id: auth.actor.id,
|
|
107
107
|
account_id: auth.account.id,
|
|
108
108
|
// See `session_revoke_all_handler` — FK forces null here; the
|
|
109
109
|
// probed id lives under `metadata.attempted_account_id`.
|
|
@@ -113,18 +113,17 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
113
113
|
reason: ERROR_ACCOUNT_NOT_FOUND,
|
|
114
114
|
attempted_account_id: input.account_id,
|
|
115
115
|
},
|
|
116
|
-
}
|
|
116
|
+
});
|
|
117
117
|
throw jsonrpc_errors.not_found('account', { reason: ERROR_ACCOUNT_NOT_FOUND });
|
|
118
118
|
}
|
|
119
119
|
const count = await query_revoke_all_api_tokens_for_account(ctx, input.account_id);
|
|
120
|
-
|
|
120
|
+
deps.audit.emit(ctx, {
|
|
121
121
|
event_type: 'token_revoke_all',
|
|
122
|
-
actor_id: auth.actor.id,
|
|
123
122
|
account_id: auth.account.id,
|
|
124
123
|
target_account_id: input.account_id,
|
|
125
124
|
ip: ctx.client_ip,
|
|
126
125
|
metadata: { count },
|
|
127
|
-
}
|
|
126
|
+
});
|
|
128
127
|
return { ok: true, count };
|
|
129
128
|
};
|
|
130
129
|
const audit_log_list_handler = async (input, ctx) => {
|
|
@@ -138,8 +137,8 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
138
137
|
});
|
|
139
138
|
return { events };
|
|
140
139
|
};
|
|
141
|
-
const
|
|
142
|
-
const events = await
|
|
140
|
+
const audit_log_role_grant_history_handler = async (input, ctx) => {
|
|
141
|
+
const events = await query_audit_log_list_role_grant_history(ctx, input.limit ?? AUDIT_LOG_DEFAULT_LIMIT, input.offset ?? 0);
|
|
143
142
|
return { events };
|
|
144
143
|
};
|
|
145
144
|
const invite_create_handler = async (input, ctx) => {
|
|
@@ -183,13 +182,12 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
183
182
|
}
|
|
184
183
|
throw err;
|
|
185
184
|
}
|
|
186
|
-
|
|
185
|
+
deps.audit.emit(ctx, {
|
|
187
186
|
event_type: 'invite_create',
|
|
188
|
-
actor_id: auth.actor.id,
|
|
189
187
|
account_id: auth.account.id,
|
|
190
188
|
ip: ctx.client_ip,
|
|
191
189
|
metadata: { invite_id: invite.id, email, username },
|
|
192
|
-
}
|
|
190
|
+
});
|
|
193
191
|
return { ok: true, invite };
|
|
194
192
|
};
|
|
195
193
|
const invite_list_handler = async (_input, ctx) => {
|
|
@@ -202,13 +200,12 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
202
200
|
if (!deleted) {
|
|
203
201
|
throw jsonrpc_errors.not_found('invite', { reason: ERROR_INVITE_NOT_FOUND });
|
|
204
202
|
}
|
|
205
|
-
|
|
203
|
+
deps.audit.emit(ctx, {
|
|
206
204
|
event_type: 'invite_delete',
|
|
207
|
-
actor_id: auth.actor.id,
|
|
208
205
|
account_id: auth.account.id,
|
|
209
206
|
ip: ctx.client_ip,
|
|
210
207
|
metadata: { invite_id: input.invite_id },
|
|
211
|
-
}
|
|
208
|
+
});
|
|
212
209
|
return { ok: true };
|
|
213
210
|
};
|
|
214
211
|
const actions = [
|
|
@@ -217,7 +214,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
217
214
|
rpc_action(admin_session_revoke_all_action_spec, session_revoke_all_handler),
|
|
218
215
|
rpc_action(admin_token_revoke_all_action_spec, token_revoke_all_handler),
|
|
219
216
|
rpc_action(audit_log_list_action_spec, audit_log_list_handler),
|
|
220
|
-
rpc_action(
|
|
217
|
+
rpc_action(audit_log_role_grant_history_action_spec, audit_log_role_grant_history_handler),
|
|
221
218
|
rpc_action(invite_create_action_spec, invite_create_handler),
|
|
222
219
|
rpc_action(invite_list_action_spec, invite_list_handler),
|
|
223
220
|
rpc_action(invite_delete_action_spec, invite_delete_handler),
|
|
@@ -237,9 +234,8 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
237
234
|
app_settings.open_signup = updated.open_signup;
|
|
238
235
|
app_settings.updated_at = updated.updated_at;
|
|
239
236
|
app_settings.updated_by = updated.updated_by;
|
|
240
|
-
|
|
237
|
+
deps.audit.emit(ctx, {
|
|
241
238
|
event_type: 'app_settings_update',
|
|
242
|
-
actor_id: auth.actor.id,
|
|
243
239
|
account_id: auth.account.id,
|
|
244
240
|
ip: ctx.client_ip,
|
|
245
241
|
metadata: {
|
|
@@ -247,7 +243,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
247
243
|
old_value,
|
|
248
244
|
new_value: input.open_signup,
|
|
249
245
|
},
|
|
250
|
-
}
|
|
246
|
+
});
|
|
251
247
|
const settings = await query_app_settings_load_with_username(ctx);
|
|
252
248
|
return { ok: true, settings };
|
|
253
249
|
};
|