@fuzdev/fuz_app 0.162.0 → 0.164.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/actions/action_event_data.d.ts +1 -1
- 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 +3 -3
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/auth/CLAUDE.md +39 -36
- package/dist/auth/account_action_specs.d.ts +441 -115
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +47 -46
- package/dist/auth/account_route_schema.d.ts +98 -62
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +45 -45
- package/dist/auth/account_routes.js +1 -1
- package/dist/auth/account_schema.d.ts +54 -27
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +16 -18
- package/dist/auth/admin_action_specs.d.ts +76 -76
- package/dist/auth/admin_action_specs.js +2 -4
- package/dist/auth/admin_actions.d.ts +4 -4
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +3 -3
- package/dist/auth/all_cell_actions.d.ts +3 -3
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +1 -1
- package/dist/auth/api_token.d.ts +4 -4
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +3 -3
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_route_schema.js +4 -5
- package/dist/auth/audit_log_schema.d.ts +46 -66
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +34 -30
- package/dist/auth/bootstrap_route_schema.d.ts +146 -52
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +33 -19
- package/dist/auth/cell_grant_action_specs.d.ts +1 -1
- package/dist/auth/cell_grant_action_specs.js +1 -1
- package/dist/auth/cell_grant_actions.d.ts +4 -4
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +1 -1
- package/dist/auth/credential_type_schema.d.ts +16 -29
- package/dist/auth/credential_type_schema.d.ts.map +1 -1
- package/dist/auth/credential_type_schema.js +14 -18
- package/dist/auth/daemon_token.d.ts +4 -4
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token.js +3 -3
- package/dist/auth/daemon_token_middleware.d.ts +1 -1
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +5 -5
- package/dist/auth/grant_path_schema.d.ts +15 -29
- package/dist/auth/grant_path_schema.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.js +13 -17
- package/dist/auth/middleware.js +4 -4
- package/dist/auth/migrations.js +1 -1
- package/dist/auth/name_schema.d.ts +7 -6
- package/dist/auth/name_schema.d.ts.map +1 -1
- package/dist/auth/name_schema.js +8 -9
- package/dist/auth/password.d.ts +15 -7
- package/dist/auth/password.d.ts.map +1 -1
- package/dist/auth/password.js +16 -9
- package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
- package/dist/auth/role_grant_offer_action_specs.js +2 -2
- package/dist/auth/role_grant_offer_actions.d.ts +4 -4
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +3 -3
- package/dist/auth/role_grant_offer_notifications.js +2 -2
- package/dist/auth/role_grant_offer_schema.d.ts +2 -2
- package/dist/auth/role_grant_offer_schema.js +2 -2
- package/dist/auth/role_schema.d.ts +47 -55
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +29 -35
- package/dist/auth/scope_kind_schema.d.ts +22 -26
- package/dist/auth/scope_kind_schema.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema.js +19 -19
- package/dist/auth/self_service_role_action_specs.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +6 -6
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +7 -6
- package/dist/auth/signup_route_schema.d.ts +71 -21
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +17 -19
- package/dist/auth/standard_rpc_actions.d.ts +1 -1
- package/dist/auth/standard_rpc_actions.js +1 -1
- package/dist/auth/token_lifetime.d.ts +33 -9
- package/dist/auth/token_lifetime.d.ts.map +1 -1
- package/dist/auth/token_lifetime.js +8 -7
- package/dist/auth/token_scope.d.ts +99 -25
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +57 -35
- package/dist/db/CLAUDE.md +2 -1
- package/dist/db/file_fact_url.d.ts +11 -6
- package/dist/db/file_fact_url.d.ts.map +1 -1
- package/dist/db/file_fact_url.js +5 -5
- package/dist/db/schema_ready.d.ts +0 -5
- package/dist/db/schema_ready.d.ts.map +1 -1
- package/dist/db/schema_ready.js +0 -5
- package/dist/http/CLAUDE.md +104 -71
- package/dist/http/auth_shape.d.ts +48 -29
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +12 -85
- package/dist/http/body_limit.d.ts +12 -0
- package/dist/http/body_limit.d.ts.map +1 -1
- package/dist/http/body_limit.js +15 -0
- package/dist/http/body_limit_schema.d.ts +20 -0
- package/dist/http/body_limit_schema.d.ts.map +1 -0
- package/dist/http/body_limit_schema.js +20 -0
- package/dist/http/common_routes.d.ts +1 -1
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +11 -14
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +59 -69
- package/dist/http/dev_route_error_check.d.ts +70 -0
- package/dist/http/dev_route_error_check.d.ts.map +1 -0
- package/dist/http/dev_route_error_check.js +119 -0
- package/dist/http/error_schemas.d.ts +365 -189
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +256 -149
- package/dist/http/health_schema.d.ts +10 -6
- package/dist/http/health_schema.d.ts.map +1 -1
- package/dist/http/health_schema.js +3 -3
- package/dist/http/middleware_spec.d.ts +8 -3
- package/dist/http/middleware_spec.d.ts.map +1 -1
- package/dist/http/origin.d.ts +12 -43
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +10 -6
- package/dist/http/route_error_check.d.ts +158 -0
- package/dist/http/route_error_check.d.ts.map +1 -0
- package/dist/http/route_error_check.js +247 -0
- package/dist/http/route_errors.d.ts +80 -0
- package/dist/http/route_errors.d.ts.map +1 -0
- package/dist/http/route_errors.js +83 -0
- package/dist/http/route_spec.d.ts +33 -17
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +48 -62
- package/dist/http/schema_helpers.d.ts +0 -33
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +0 -45
- package/dist/http/surface.d.ts +19 -12
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +25 -38
- package/dist/http/surface_query.d.ts +11 -2
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +7 -1
- package/dist/primitive_schemas.d.ts +2 -19
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +2 -20
- package/dist/primitive_schemas_fuz.d.ts +39 -5
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +36 -7
- package/dist/rate_limiter.d.ts +13 -0
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +20 -2
- package/dist/schema_issues.d.ts +29 -11
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +11 -10
- package/dist/schema_meta.d.ts +8 -1
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +2 -1
- package/dist/server/app_server.d.ts +3 -1
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +24 -10
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +8 -31
- package/dist/server/surface_route.d.ts.map +1 -1
- package/dist/server/surface_route.js +5 -6
- package/dist/server/x_accel.d.ts +12 -7
- package/dist/server/x_accel.d.ts.map +1 -1
- package/dist/server/x_accel.js +7 -9
- package/dist/testing/CLAUDE.md +55 -44
- package/dist/testing/admin_integration.d.ts +3 -3
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +2 -2
- package/dist/testing/adversarial_404.d.ts +4 -18
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +19 -51
- package/dist/testing/adversarial_headers.d.ts +3 -4
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +8 -6
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +18 -17
- package/dist/testing/assertions.d.ts +33 -11
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +52 -12
- package/dist/testing/attack_surface.d.ts +5 -35
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +29 -91
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +2 -1
- package/dist/testing/cross_backend/action_manifest.d.ts +126 -56
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +11 -11
- package/dist/testing/cross_backend/action_manifest_parity.d.ts +1 -1
- package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.js +2 -1
- package/dist/testing/cross_backend/conformance_table.js +1 -1
- package/dist/testing/cross_backend/default_spine_surface.d.ts +2 -2
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +2 -2
- package/dist/testing/cross_backend/fact_serving.js +3 -3
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +39 -6
- package/dist/testing/cross_backend/origin_conformance.d.ts +278 -102
- package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_conformance.js +21 -21
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -3
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +7 -1
- package/dist/testing/cross_backend/setup.d.ts +14 -1
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +68 -48
- package/dist/testing/cross_backend/spine_suites.d.ts +3 -3
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.d.ts +4 -4
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.d.ts +147 -71
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +16 -13
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +70 -27
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +34 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +5 -4
- package/dist/testing/error_coverage.d.ts +24 -34
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +46 -89
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +6 -14
- package/dist/testing/integration_helpers.d.ts +37 -9
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +86 -40
- package/dist/testing/middleware.d.ts +3 -5
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +5 -4
- package/dist/testing/rate_limiting.d.ts +1 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +5 -4
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +5 -3
- package/dist/testing/schema_generators.d.ts +10 -3
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +23 -11
- package/dist/testing/stubs.d.ts +10 -1
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +15 -5
- package/dist/testing/surface_invariants.d.ts +36 -115
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +106 -269
- package/dist/testing/token_scope_fixtures.d.ts +24 -0
- package/dist/testing/token_scope_fixtures.d.ts.map +1 -0
- package/dist/testing/token_scope_fixtures.js +49 -0
- package/dist/testing/transports/bootstrap.d.ts +1 -1
- package/dist/testing/transports/bootstrap.d.ts.map +1 -1
- package/dist/testing/transports/bootstrap.js +13 -12
- package/dist/ui/BootstrapForm.svelte +4 -2
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/CLAUDE.md +4 -2
- package/dist/ui/SignupForm.svelte +4 -2
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +2 -8
- package/dist/ui/backend_probe.svelte.js +3 -3
- package/dist/ui/table_state.svelte.d.ts.map +1 -1
- package/dist/ui/table_state.svelte.js +1 -8
- package/dist/ui/ui_fetch.d.ts +12 -2
- package/dist/ui/ui_fetch.d.ts.map +1 -1
- package/dist/ui/ui_fetch.js +22 -4
- package/package.json +1 -1
- package/dist/auth/audit_log_schema_fuz.d.ts +0 -53
- package/dist/auth/audit_log_schema_fuz.d.ts.map +0 -1
- package/dist/auth/audit_log_schema_fuz.js +0 -50
- package/dist/auth/role_schema_fuz.d.ts +0 -30
- package/dist/auth/role_schema_fuz.d.ts.map +0 -1
- package/dist/auth/role_schema_fuz.js +0 -30
- package/dist/auth/scope_kind_schema_fuz.d.ts +0 -31
- package/dist/auth/scope_kind_schema_fuz.d.ts.map +0 -1
- package/dist/auth/scope_kind_schema_fuz.js +0 -31
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
* @module
|
|
30
30
|
*/
|
|
31
31
|
import { type RpcAction } from '../actions/action_types.js';
|
|
32
|
-
import { type
|
|
32
|
+
import { type RoleRegistry } from './role_schema.js';
|
|
33
33
|
import type { RevokingActionFactoryDeps } from './deps.js';
|
|
34
34
|
/** Options for `create_admin_actions`. */
|
|
35
35
|
export interface AdminActionOptions {
|
|
36
36
|
/**
|
|
37
|
-
* Role
|
|
37
|
+
* Role registry from `create_role_registry()`. Defaults to builtin
|
|
38
38
|
* roles only. Used to derive `grantable_roles` (the subset whose
|
|
39
39
|
* `RoleSpec.grant_paths` includes `'admin'`) returned by
|
|
40
40
|
* `admin_account_list`.
|
|
41
41
|
*/
|
|
42
|
-
roles?:
|
|
42
|
+
roles?: RoleRegistry;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Create the admin-only RPC actions.
|
|
@@ -51,7 +51,7 @@ export interface AdminActionOptions {
|
|
|
51
51
|
* encapsulates listener fan-out and the optional `AuditLogConfig`.
|
|
52
52
|
* `connection_closer` closes the target account's live connections after a
|
|
53
53
|
* revoke-all, delete, or purge commits.
|
|
54
|
-
* @param options - role
|
|
54
|
+
* @param options - role registry for `grantable_roles` derivation
|
|
55
55
|
* @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
|
|
56
56
|
*/
|
|
57
57
|
export declare const create_admin_actions: (deps: RevokingActionFactoryDeps, options?: AdminActionOptions) => Array<RpcAction>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/admin_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIjG,OAAO,EAKN,KAAK,
|
|
1
|
+
{"version":3,"file":"admin_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/admin_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIjG,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;AA2C1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA0D3D,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,yBAAyB,EAC/B,UAAS,kBAAuB,KAC9B,KAAK,CAAC,SAAS,CA6hBjB,CAAC"}
|
|
@@ -32,7 +32,7 @@ import { rpc_action } from '../actions/action_types.js';
|
|
|
32
32
|
import { queue_connection_close } from '../actions/connection_closer.js';
|
|
33
33
|
import { credential_type_required_error } from '../actions/perform_action.js';
|
|
34
34
|
import { jsonrpc_errors, ThrownJsonrpcError } from '../http/jsonrpc_errors.js';
|
|
35
|
-
import {
|
|
35
|
+
import { builtin_role_specs, list_roles_with_grant_path, ROLE_ADMIN, ROLE_KEEPER } from './role_schema.js';
|
|
36
36
|
import { has_scoped_role } from './request_context.js';
|
|
37
37
|
import { query_account_has_global_role, query_account_has_active_global_role, query_count_active_accounts_with_global_role_for_update } from './role_grant_queries.js';
|
|
38
38
|
import { GRANT_PATH_ADMIN } from './grant_path_schema.js';
|
|
@@ -57,11 +57,11 @@ import { admin_account_list_action_spec, admin_session_list_action_spec, admin_s
|
|
|
57
57
|
* encapsulates listener fan-out and the optional `AuditLogConfig`.
|
|
58
58
|
* `connection_closer` closes the target account's live connections after a
|
|
59
59
|
* revoke-all, delete, or purge commits.
|
|
60
|
-
* @param options - role
|
|
60
|
+
* @param options - role registry for `grantable_roles` derivation
|
|
61
61
|
* @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
|
|
62
62
|
*/
|
|
63
63
|
export const create_admin_actions = (deps, options = {}) => {
|
|
64
|
-
const role_specs = options.roles?.role_specs ??
|
|
64
|
+
const role_specs = options.roles?.role_specs ?? builtin_role_specs;
|
|
65
65
|
const grantable_roles = list_roles_with_grant_path(role_specs, GRANT_PATH_ADMIN);
|
|
66
66
|
const { connection_closer } = deps;
|
|
67
67
|
const account_list_handler = async (input, ctx) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RpcAction } from '../actions/action_types.js';
|
|
2
2
|
import { type CellActionDeps } from './cell_actions.js';
|
|
3
3
|
import { type CellGrantCreateAuthorize, type CellGrantRevokeAuthorize } from './cell_grant_actions.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { RoleRegistry } from './role_schema.js';
|
|
5
5
|
/**
|
|
6
6
|
* Dependencies for `create_all_cell_actions` — the CRUD factory's
|
|
7
7
|
* `CellActionDeps` plus the grant factory's optional `authorize_grant_create`
|
|
@@ -19,7 +19,7 @@ export type AllCellActionDeps = CellActionDeps & {
|
|
|
19
19
|
* schema (the same one `create_standard_rpc_actions` takes).
|
|
20
20
|
*/
|
|
21
21
|
export interface AllCellActionsOptions {
|
|
22
|
-
readonly roles:
|
|
22
|
+
readonly roles: RoleRegistry;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Build the full cell RPC action set — CRUD (`create_cell_actions`,
|
|
@@ -39,7 +39,7 @@ export interface AllCellActionsOptions {
|
|
|
39
39
|
*
|
|
40
40
|
* @param deps - `AllCellActionDeps` (`log`, `audit`, the optional `validate_data`,
|
|
41
41
|
* `authorize_create`, `authorize_grant_create`, and `authorize_grant_revoke`)
|
|
42
|
-
* @param options - the role
|
|
42
|
+
* @param options - the role registry for grant validation
|
|
43
43
|
* @returns every cell `RpcAction`, in mount order
|
|
44
44
|
*/
|
|
45
45
|
export declare const create_all_cell_actions: (deps: AllCellActionDeps, options: AllCellActionsOptions) => Array<RpcAction>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all_cell_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/all_cell_actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"all_cell_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/all_cell_actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAChD,sBAAsB,CAAC,EAAE,wBAAwB,CAAC;IAClD,sBAAsB,CAAC,EAAE,wBAAwB,CAAC;CAClD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,iBAAiB,EACvB,SAAS,qBAAqB,KAC5B,KAAK,CAAC,SAAS,CAMjB,CAAC"}
|
|
@@ -21,7 +21,7 @@ import { create_cell_audit_actions } from './cell_audit_actions.js';
|
|
|
21
21
|
*
|
|
22
22
|
* @param deps - `AllCellActionDeps` (`log`, `audit`, the optional `validate_data`,
|
|
23
23
|
* `authorize_create`, `authorize_grant_create`, and `authorize_grant_revoke`)
|
|
24
|
-
* @param options - the role
|
|
24
|
+
* @param options - the role registry for grant validation
|
|
25
25
|
* @returns every cell `RpcAction`, in mount order
|
|
26
26
|
*/
|
|
27
27
|
export const create_all_cell_actions = (deps, options) => [
|
package/dist/auth/api_token.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
12
12
|
/** Prefix for all fuz API tokens (enables secret scanning). */
|
|
13
13
|
export declare const API_TOKEN_PREFIX = "secret_fuz_token_";
|
|
14
14
|
/** Random bytes encoded into the raw token body (256 bits). */
|
|
@@ -37,9 +37,9 @@ export declare const is_api_token_shaped: (raw: string) => boolean;
|
|
|
37
37
|
* by `generate_api_token`.
|
|
38
38
|
*/
|
|
39
39
|
export declare const API_TOKEN_ID_REGEX: RegExp;
|
|
40
|
-
/**
|
|
41
|
-
export declare const ApiTokenId:
|
|
42
|
-
export type ApiTokenId =
|
|
40
|
+
/** The public API token id, `API_TOKEN_ID_REGEX`, a `@fuzdev/fuz_schema` schema. */
|
|
41
|
+
export declare const ApiTokenId: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
42
|
+
export type ApiTokenId = Infer<typeof ApiTokenId>;
|
|
43
43
|
/**
|
|
44
44
|
* Hash an API token for storage using blake3.
|
|
45
45
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_token.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/api_token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"api_token.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/api_token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAuB,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAK/E,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAEpD,+DAA+D;AAC/D,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,QAA+C,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAE3B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,KAAG,OAAoC,CAAC;AAEvF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAA4B,CAAC;AAE5D,oFAAoF;AACpF,eAAO,MAAM,UAAU,+IAA0C,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,MAA4B,CAAC;AAE5E;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,QAAO;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAMpF,CAAC"}
|
package/dist/auth/api_token.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { pipe, regex, string } from '@fuzdev/fuz_schema/schema.ts';
|
|
12
12
|
import { hash_blake3 } from '@fuzdev/fuz_util/hash_blake3.ts';
|
|
13
13
|
import { generate_random_base64url } from '../crypto.js';
|
|
14
14
|
/** Prefix for all fuz API tokens (enables secret scanning). */
|
|
@@ -39,8 +39,8 @@ export const is_api_token_shaped = (raw) => API_TOKEN_REGEX.test(raw);
|
|
|
39
39
|
* by `generate_api_token`.
|
|
40
40
|
*/
|
|
41
41
|
export const API_TOKEN_ID_REGEX = /^tok_[A-Za-z0-9_-]{12}$/;
|
|
42
|
-
/**
|
|
43
|
-
export const ApiTokenId =
|
|
42
|
+
/** The public API token id, `API_TOKEN_ID_REGEX`, a `@fuzdev/fuz_schema` schema. */
|
|
43
|
+
export const ApiTokenId = pipe(string, regex(API_TOKEN_ID_REGEX));
|
|
44
44
|
/**
|
|
45
45
|
* Hash an API token for storage using blake3.
|
|
46
46
|
*
|
|
@@ -35,7 +35,7 @@ export declare const DEFAULT_AUDIT_STREAM_ROLE = "admin";
|
|
|
35
35
|
* The `GET /audit/stream` SSE route shape minus its handler — pure hono-free
|
|
36
36
|
* data. `create_audit_log_route_specs` spreads this and attaches the live SSE
|
|
37
37
|
* handler; cross-process surface builders spread it with a stub handler. The
|
|
38
|
-
* output is `
|
|
38
|
+
* output is `literal(null)` because SSE streams have no JSON response body.
|
|
39
39
|
*
|
|
40
40
|
* @param required_role - role gating the stream (default `DEFAULT_AUDIT_STREAM_ROLE`)
|
|
41
41
|
* @returns the SSE route shape minus its handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_route_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"audit_log_route_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAmB,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;EAAkC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,UAAU,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACxC,gBAAe,MAAkC,KAC/C,IAAI,CAAC,SAAS,EAAE,SAAS,CA8B1B,CAAC"}
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
14
|
-
import { object } from '@fuzdev/fuz_schema/schema.ts';
|
|
13
|
+
import { literal, object } from '@fuzdev/fuz_schema/schema.ts';
|
|
15
14
|
import { ActingActor } from '../primitive_schemas_fuz.js';
|
|
16
15
|
/**
|
|
17
16
|
* Query schema for the audit-log SSE route, a `@fuzdev/fuz_schema` `object`
|
|
@@ -24,7 +23,7 @@ export const DEFAULT_AUDIT_STREAM_ROLE = 'admin';
|
|
|
24
23
|
* The `GET /audit/stream` SSE route shape minus its handler — pure hono-free
|
|
25
24
|
* data. `create_audit_log_route_specs` spreads this and attaches the live SSE
|
|
26
25
|
* handler; cross-process surface builders spread it with a stub handler. The
|
|
27
|
-
* output is `
|
|
26
|
+
* output is `literal(null)` because SSE streams have no JSON response body.
|
|
28
27
|
*
|
|
29
28
|
* @param required_role - role gating the stream (default `DEFAULT_AUDIT_STREAM_ROLE`)
|
|
30
29
|
* @returns the SSE route shape minus its handler
|
|
@@ -57,6 +56,6 @@ export const create_audit_log_route_shape = (required_role = DEFAULT_AUDIT_STREA
|
|
|
57
56
|
},
|
|
58
57
|
description: 'Subscribe to realtime audit log events',
|
|
59
58
|
query: AuditStreamQuery,
|
|
60
|
-
input:
|
|
61
|
-
output:
|
|
59
|
+
input: literal(null),
|
|
60
|
+
output: literal(null) // SSE — no JSON response
|
|
62
61
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Audit log types and client-safe schemas
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* `auth/audit_log_schema_fuz.ts`.
|
|
2
|
+
* Audit log types and client-safe `@fuzdev/fuz_schema` schemas: the
|
|
3
|
+
* event-type and outcome vocabularies, the builtin metadata schemas, and the
|
|
4
|
+
* wire rows.
|
|
6
5
|
*
|
|
7
6
|
* Records auth mutations (login, logout, grant, revoke, etc.) for
|
|
8
7
|
* security monitoring and operational visibility.
|
|
@@ -11,7 +10,6 @@
|
|
|
11
10
|
*
|
|
12
11
|
* @module
|
|
13
12
|
*/
|
|
14
|
-
import { z } from 'zod';
|
|
15
13
|
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
16
14
|
import { Uuid } from '../primitive_schemas_fuz.js';
|
|
17
15
|
import { type ValidationSchema } from '../schema_issues.js';
|
|
@@ -22,38 +20,8 @@ import { type ValidationSchema } from '../schema_issues.js';
|
|
|
22
20
|
* audit logging.
|
|
23
21
|
*/
|
|
24
22
|
export declare const AUDIT_EVENT_TYPES: readonly ["login", "logout", "bootstrap", "signup", "password_change", "session_revoke", "session_revoke_all", "token_create", "token_revoke", "token_revoke_all", "role_grant_create", "role_grant_revoke", "role_grant_offer_create", "role_grant_offer_accept", "role_grant_offer_decline", "role_grant_offer_retract", "role_grant_offer_expire", "role_grant_offer_supersede", "invite_create", "invite_delete", "account_delete", "account_purge", "account_undelete", "actor_delete", "actor_purge", "actor_undelete", "app_settings_update", "db_admin_row_delete"];
|
|
25
|
-
/**
|
|
26
|
-
export
|
|
27
|
-
bootstrap: "bootstrap";
|
|
28
|
-
login: "login";
|
|
29
|
-
logout: "logout";
|
|
30
|
-
signup: "signup";
|
|
31
|
-
password_change: "password_change";
|
|
32
|
-
session_revoke: "session_revoke";
|
|
33
|
-
session_revoke_all: "session_revoke_all";
|
|
34
|
-
token_create: "token_create";
|
|
35
|
-
token_revoke: "token_revoke";
|
|
36
|
-
token_revoke_all: "token_revoke_all";
|
|
37
|
-
role_grant_create: "role_grant_create";
|
|
38
|
-
role_grant_revoke: "role_grant_revoke";
|
|
39
|
-
role_grant_offer_create: "role_grant_offer_create";
|
|
40
|
-
role_grant_offer_accept: "role_grant_offer_accept";
|
|
41
|
-
role_grant_offer_decline: "role_grant_offer_decline";
|
|
42
|
-
role_grant_offer_retract: "role_grant_offer_retract";
|
|
43
|
-
role_grant_offer_expire: "role_grant_offer_expire";
|
|
44
|
-
role_grant_offer_supersede: "role_grant_offer_supersede";
|
|
45
|
-
invite_create: "invite_create";
|
|
46
|
-
invite_delete: "invite_delete";
|
|
47
|
-
account_delete: "account_delete";
|
|
48
|
-
account_purge: "account_purge";
|
|
49
|
-
account_undelete: "account_undelete";
|
|
50
|
-
actor_delete: "actor_delete";
|
|
51
|
-
actor_purge: "actor_purge";
|
|
52
|
-
actor_undelete: "actor_undelete";
|
|
53
|
-
app_settings_update: "app_settings_update";
|
|
54
|
-
db_admin_row_delete: "db_admin_row_delete";
|
|
55
|
-
}>;
|
|
56
|
-
export type AuditEventType = z.infer<typeof AuditEventType>;
|
|
23
|
+
/** A builtin audit event type, one of `AUDIT_EVENT_TYPES`. */
|
|
24
|
+
export type AuditEventType = (typeof AUDIT_EVENT_TYPES)[number];
|
|
57
25
|
/**
|
|
58
26
|
* What a **successful** audit row invalidates — the axis the revocation
|
|
59
27
|
* listener (`create_revocation_guard`) dispatches on.
|
|
@@ -128,18 +96,30 @@ export declare const to_global_role_revocation: (event: AuditLogEvent) => {
|
|
|
128
96
|
role: string;
|
|
129
97
|
} | null;
|
|
130
98
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
99
|
+
* Letter start, then letters, digits, `_`, `.`, `/`, `-`. Accepts snake_case,
|
|
100
|
+
* dotted, and namespaced consumer conventions; rejects empty strings, leading
|
|
101
|
+
* separators, whitespace, and control characters. The audit event type's own
|
|
102
|
+
* grammar, wider than the shared name grammar (`auth/name_schema.ts`), whose
|
|
103
|
+
* length cap `AuditEventTypeName` takes.
|
|
134
104
|
*/
|
|
135
|
-
export declare const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
105
|
+
export declare const AUDIT_EVENT_TYPE_NAME_REGEX: RegExp;
|
|
106
|
+
/** The message of an audit event-type name past `NAME_LENGTH_MAX`. */
|
|
107
|
+
export declare const AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE = "must be at most 64 characters";
|
|
108
|
+
/** The message of an audit event-type name off `AUDIT_EVENT_TYPE_NAME_REGEX`. */
|
|
109
|
+
export declare const AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE = "must start with a letter; only letters, digits, _ . / - allowed";
|
|
110
|
+
/**
|
|
111
|
+
* Valid audit event-type name strings: `AUDIT_EVENT_TYPE_NAME_REGEX`, at most
|
|
112
|
+
* `NAME_LENGTH_MAX` UTF-16 code units. A string it refuses gets
|
|
113
|
+
* `AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE` or
|
|
114
|
+
* `AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE`, the length one alone for a string
|
|
115
|
+
* both too long and off the grammar; a value that is no string, fuz_schema's
|
|
116
|
+
* message. Twin of the Rust spine's `is_valid_audit_event_type_name`.
|
|
117
|
+
*/
|
|
118
|
+
export declare const AuditEventTypeName: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
119
|
+
export type AuditEventTypeName = Infer<typeof AuditEventTypeName>;
|
|
120
|
+
/** Audit event outcome. */
|
|
121
|
+
export declare const AuditOutcome: import("@fuzdev/fuz_schema/schema.ts").Schema<"success" | "failure", "success" | "failure", "one_of", readonly ["success", "failure"]>;
|
|
122
|
+
export type AuditOutcome = Infer<typeof AuditOutcome>;
|
|
143
123
|
/**
|
|
144
124
|
* Per-event-type metadata schemas, `@fuzdev/fuz_schema` `loose_object`s so
|
|
145
125
|
* consumers can add fields while known ones are validated. The record is
|
|
@@ -195,25 +175,25 @@ export declare const audit_metadata_schemas: Readonly<{
|
|
|
195
175
|
email: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
196
176
|
}>;
|
|
197
177
|
password_change: import("@fuzdev/fuz_schema/schema.ts").Schema<({
|
|
178
|
+
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
198
179
|
reason?: "concurrent_change" | undefined;
|
|
199
180
|
sessions_revoked?: number | undefined;
|
|
200
181
|
tokens_revoked?: number | undefined;
|
|
201
|
-
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
202
182
|
} & Record<string, unknown>) | null, ({
|
|
183
|
+
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
203
184
|
reason?: "concurrent_change" | undefined;
|
|
204
185
|
sessions_revoked?: number | undefined;
|
|
205
186
|
tokens_revoked?: number | undefined;
|
|
206
|
-
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
207
187
|
} & Record<string, unknown>) | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
188
|
+
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
208
189
|
reason?: "concurrent_change" | undefined;
|
|
209
190
|
sessions_revoked?: number | undefined;
|
|
210
191
|
tokens_revoked?: number | undefined;
|
|
211
|
-
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
212
192
|
} & Record<string, unknown>, {
|
|
193
|
+
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
213
194
|
reason?: "concurrent_change" | undefined;
|
|
214
195
|
sessions_revoked?: number | undefined;
|
|
215
196
|
tokens_revoked?: number | undefined;
|
|
216
|
-
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
217
197
|
} & Record<string, unknown>, "loose_object", {
|
|
218
198
|
sessions_revoked: import("@fuzdev/fuz_schema/schema.ts").Schema<number | undefined, number | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>>;
|
|
219
199
|
tokens_revoked: import("@fuzdev/fuz_schema/schema.ts").Schema<number | undefined, number | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>>;
|
|
@@ -236,13 +216,13 @@ export declare const audit_metadata_schemas: Readonly<{
|
|
|
236
216
|
credential_type: import("@fuzdev/fuz_schema/schema.ts").Schema<"session" | "api_token" | "daemon_token" | undefined, "session" | "api_token" | "daemon_token" | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<"session" | "api_token" | "daemon_token", "session" | "api_token" | "daemon_token", "one_of", readonly ["session", "api_token", "daemon_token"]>>>;
|
|
237
217
|
}>;
|
|
238
218
|
session_revoke_all: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
239
|
-
reason?: string | undefined;
|
|
240
219
|
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
220
|
+
reason?: string | undefined;
|
|
241
221
|
count?: number | undefined;
|
|
242
222
|
attempted_account_id?: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | undefined;
|
|
243
223
|
} & Record<string, unknown>, {
|
|
244
|
-
reason?: string | undefined;
|
|
245
224
|
credential_type?: "session" | "api_token" | "daemon_token" | undefined;
|
|
225
|
+
reason?: string | undefined;
|
|
246
226
|
count?: number | undefined;
|
|
247
227
|
attempted_account_id?: string | undefined;
|
|
248
228
|
} & Record<string, unknown>, "loose_object", {
|
|
@@ -857,25 +837,25 @@ export declare const AuditLogEventJson: import("@fuzdev/fuz_schema/schema.ts").S
|
|
|
857
837
|
id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">;
|
|
858
838
|
account_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
859
839
|
created_at: string;
|
|
860
|
-
|
|
840
|
+
outcome: "success" | "failure";
|
|
861
841
|
seq: number;
|
|
862
842
|
event_type: string;
|
|
863
|
-
outcome: "success" | "failure";
|
|
864
843
|
actor_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
865
844
|
target_account_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
866
845
|
target_actor_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
846
|
+
ip: string | null;
|
|
867
847
|
}, {
|
|
868
848
|
metadata: Record<string, unknown> | null;
|
|
869
849
|
id: string;
|
|
870
850
|
account_id: string | null;
|
|
871
851
|
created_at: string;
|
|
872
|
-
|
|
852
|
+
outcome: "success" | "failure";
|
|
873
853
|
seq: number;
|
|
874
854
|
event_type: string;
|
|
875
|
-
outcome: "success" | "failure";
|
|
876
855
|
actor_id: string | null;
|
|
877
856
|
target_account_id: string | null;
|
|
878
857
|
target_actor_id: string | null;
|
|
858
|
+
ip: string | null;
|
|
879
859
|
}, "object", {
|
|
880
860
|
id: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
881
861
|
readonly '~types'?: {
|
|
@@ -922,13 +902,13 @@ export declare const AuditLogEventWithUsernamesJson: import("@fuzdev/fuz_schema/
|
|
|
922
902
|
account_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
923
903
|
created_at: string;
|
|
924
904
|
username: string | null;
|
|
925
|
-
|
|
905
|
+
outcome: "success" | "failure";
|
|
926
906
|
seq: number;
|
|
927
907
|
event_type: string;
|
|
928
|
-
outcome: "success" | "failure";
|
|
929
908
|
actor_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
930
909
|
target_account_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
931
910
|
target_actor_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
911
|
+
ip: string | null;
|
|
932
912
|
target_username: string | null;
|
|
933
913
|
}, {
|
|
934
914
|
metadata: Record<string, unknown> | null;
|
|
@@ -936,13 +916,13 @@ export declare const AuditLogEventWithUsernamesJson: import("@fuzdev/fuz_schema/
|
|
|
936
916
|
account_id: string | null;
|
|
937
917
|
created_at: string;
|
|
938
918
|
username: string | null;
|
|
939
|
-
|
|
919
|
+
outcome: "success" | "failure";
|
|
940
920
|
seq: number;
|
|
941
921
|
event_type: string;
|
|
942
|
-
outcome: "success" | "failure";
|
|
943
922
|
actor_id: string | null;
|
|
944
923
|
target_account_id: string | null;
|
|
945
924
|
target_actor_id: string | null;
|
|
925
|
+
ip: string | null;
|
|
946
926
|
target_username: string | null;
|
|
947
927
|
}, "object", {
|
|
948
928
|
username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
@@ -992,13 +972,13 @@ export declare const RoleGrantHistoryEventJson: import("@fuzdev/fuz_schema/schem
|
|
|
992
972
|
account_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
993
973
|
created_at: string;
|
|
994
974
|
username: string | null;
|
|
995
|
-
|
|
975
|
+
outcome: "success" | "failure";
|
|
996
976
|
seq: number;
|
|
997
977
|
event_type: string;
|
|
998
|
-
outcome: "success" | "failure";
|
|
999
978
|
actor_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
1000
979
|
target_account_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
1001
980
|
target_actor_id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
981
|
+
ip: string | null;
|
|
1002
982
|
target_username: string | null;
|
|
1003
983
|
}, {
|
|
1004
984
|
metadata: Record<string, unknown> | null;
|
|
@@ -1006,13 +986,13 @@ export declare const RoleGrantHistoryEventJson: import("@fuzdev/fuz_schema/schem
|
|
|
1006
986
|
account_id: string | null;
|
|
1007
987
|
created_at: string;
|
|
1008
988
|
username: string | null;
|
|
1009
|
-
|
|
989
|
+
outcome: "success" | "failure";
|
|
1010
990
|
seq: number;
|
|
1011
991
|
event_type: string;
|
|
1012
|
-
outcome: "success" | "failure";
|
|
1013
992
|
actor_id: string | null;
|
|
1014
993
|
target_account_id: string | null;
|
|
1015
994
|
target_actor_id: string | null;
|
|
995
|
+
ip: string | null;
|
|
1016
996
|
target_username: string | null;
|
|
1017
997
|
}, "object", {
|
|
1018
998
|
username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"audit_log_schema.d.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BAAyB,CAAC,CAAC;AAIhF;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Audit log types and client-safe schemas
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* `auth/audit_log_schema_fuz.ts`.
|
|
2
|
+
* Audit log types and client-safe `@fuzdev/fuz_schema` schemas: the
|
|
3
|
+
* event-type and outcome vocabularies, the builtin metadata schemas, and the
|
|
4
|
+
* wire rows.
|
|
6
5
|
*
|
|
7
6
|
* Records auth mutations (login, logout, grant, revoke, etc.) for
|
|
8
7
|
* security monitoring and operational visibility.
|
|
@@ -11,19 +10,14 @@
|
|
|
11
10
|
*
|
|
12
11
|
* @module
|
|
13
12
|
*/
|
|
14
|
-
import { z } from 'zod';
|
|
15
13
|
import { meta } from '@fuzdev/fuz_schema/meta.ts';
|
|
16
|
-
import { boolean, literal, loose_object, nullable, number, object, one_of, optional, pipe, record, regex, safe_integer, string, unknown } from '@fuzdev/fuz_schema/schema.ts';
|
|
17
|
-
import { bounded_string } from '../
|
|
18
|
-
import { Email, Timestamp, Uuid } from '../primitive_schemas_fuz.js';
|
|
14
|
+
import { boolean, format_issue, literal, loose_object, message, nullable, number, object, one_of, optional, parse, pipe, record, regex, safe_integer, string, unknown } from '@fuzdev/fuz_schema/schema.ts';
|
|
15
|
+
import { bounded_string, Email, Timestamp, Uuid } from '../primitive_schemas_fuz.js';
|
|
19
16
|
import { assert_validation_schema } from '../schema_issues.js';
|
|
20
17
|
import { AuthSessionJson, SessionId } from './account_schema.js';
|
|
21
|
-
import {
|
|
18
|
+
import { ApiTokenId } from './api_token.js';
|
|
22
19
|
import { BUILTIN_CREDENTIAL_TYPES } from './credential_type_schema.js';
|
|
23
20
|
import { NAME_LENGTH_MAX } from './name_schema.js';
|
|
24
|
-
import { AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE, AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE, AUDIT_EVENT_TYPE_NAME_REGEX, AuditEventTypeName as AuditEventTypeNameFuz, AuditOutcome as AuditOutcomeFuz } from './audit_log_schema_fuz.js';
|
|
25
|
-
/** An API token's public id (`tok_…`), `ApiTokenId`'s check in fuz_schema. */
|
|
26
|
-
const TokenId = pipe(string, regex(API_TOKEN_ID_REGEX));
|
|
27
21
|
/**
|
|
28
22
|
* Defense-in-depth audit field — records the credential channel
|
|
29
23
|
* (`session` / `api_token` / `daemon_token`) the request arrived on.
|
|
@@ -70,8 +64,6 @@ export const AUDIT_EVENT_TYPES = Object.freeze([
|
|
|
70
64
|
'app_settings_update',
|
|
71
65
|
'db_admin_row_delete'
|
|
72
66
|
]);
|
|
73
|
-
/** Zod schema for audit event types. */
|
|
74
|
-
export const AuditEventType = z.enum(AUDIT_EVENT_TYPES);
|
|
75
67
|
/**
|
|
76
68
|
* The `RevocationScope` of every builtin audit event — declared once, the one
|
|
77
69
|
* answer the revocation listener reads, and the twin of the Rust spine's table. Typed over `AuditEventType`, so a new event type does not compile
|
|
@@ -161,16 +153,28 @@ export const to_global_role_revocation = (event) => {
|
|
|
161
153
|
return { account_id, role };
|
|
162
154
|
};
|
|
163
155
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
156
|
+
* Letter start, then letters, digits, `_`, `.`, `/`, `-`. Accepts snake_case,
|
|
157
|
+
* dotted, and namespaced consumer conventions; rejects empty strings, leading
|
|
158
|
+
* separators, whitespace, and control characters. The audit event type's own
|
|
159
|
+
* grammar, wider than the shared name grammar (`auth/name_schema.ts`), whose
|
|
160
|
+
* length cap `AuditEventTypeName` takes.
|
|
167
161
|
*/
|
|
168
|
-
export const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
162
|
+
export const AUDIT_EVENT_TYPE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_./-]*$/;
|
|
163
|
+
/** The message of an audit event-type name past `NAME_LENGTH_MAX`. */
|
|
164
|
+
export const AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE = `must be at most ${NAME_LENGTH_MAX} characters`;
|
|
165
|
+
/** The message of an audit event-type name off `AUDIT_EVENT_TYPE_NAME_REGEX`. */
|
|
166
|
+
export const AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE = 'must start with a letter; only letters, digits, _ . / - allowed';
|
|
167
|
+
/**
|
|
168
|
+
* Valid audit event-type name strings: `AUDIT_EVENT_TYPE_NAME_REGEX`, at most
|
|
169
|
+
* `NAME_LENGTH_MAX` UTF-16 code units. A string it refuses gets
|
|
170
|
+
* `AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE` or
|
|
171
|
+
* `AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE`, the length one alone for a string
|
|
172
|
+
* both too long and off the grammar; a value that is no string, fuz_schema's
|
|
173
|
+
* message. Twin of the Rust spine's `is_valid_audit_event_type_name`.
|
|
174
|
+
*/
|
|
175
|
+
export const AuditEventTypeName = pipe(bounded_string({ max: NAME_LENGTH_MAX, max_message: AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE }), message(regex(AUDIT_EVENT_TYPE_NAME_REGEX), AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE));
|
|
176
|
+
/** Audit event outcome. */
|
|
177
|
+
export const AuditOutcome = one_of(['success', 'failure']);
|
|
174
178
|
/**
|
|
175
179
|
* Per-event-type metadata schemas, `@fuzdev/fuz_schema` `loose_object`s so
|
|
176
180
|
* consumers can add fields while known ones are validated. The record is
|
|
@@ -235,12 +239,12 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
235
239
|
credential_type: credential_type_meta
|
|
236
240
|
}),
|
|
237
241
|
token_create: loose_object({
|
|
238
|
-
token_id: meta(
|
|
242
|
+
token_id: meta(ApiTokenId, { description: 'Public id of the created API token (`tok_…`).' }),
|
|
239
243
|
name: meta(string, { description: 'Operator-supplied label for the token.' }),
|
|
240
244
|
credential_type: credential_type_meta
|
|
241
245
|
}),
|
|
242
246
|
token_revoke: loose_object({
|
|
243
|
-
token_id: meta(
|
|
247
|
+
token_id: meta(ApiTokenId, { description: 'Public id of the revoked API token (`tok_…`).' }),
|
|
244
248
|
credential_type: credential_type_meta
|
|
245
249
|
}),
|
|
246
250
|
token_revoke_all: loose_object({
|
|
@@ -483,9 +487,9 @@ export const create_audit_log_config = (options) => {
|
|
|
483
487
|
if (builtin_set.has(t)) {
|
|
484
488
|
throw new Error(`extra_events key "${t}" collides with a builtin event type — pick a distinct string (e.g. "app_${t}")`);
|
|
485
489
|
}
|
|
486
|
-
const name_check = AuditEventTypeName
|
|
487
|
-
if (!name_check.
|
|
488
|
-
throw new Error(`extra_events key "${t}" has invalid format: ${name_check.
|
|
490
|
+
const name_check = parse(AuditEventTypeName, t);
|
|
491
|
+
if (!name_check.ok) {
|
|
492
|
+
throw new Error(`extra_events key "${t}" has invalid format: ${format_issue(name_check.issues[0])}`);
|
|
489
493
|
}
|
|
490
494
|
extra_keys.push(t);
|
|
491
495
|
if (schema !== null) {
|
|
@@ -516,8 +520,8 @@ export const AUDIT_LOG_DEFAULT_LIMIT = 50;
|
|
|
516
520
|
export const AuditLogEventJson = object({
|
|
517
521
|
id: Uuid,
|
|
518
522
|
seq: pipe(number, safe_integer),
|
|
519
|
-
event_type:
|
|
520
|
-
outcome:
|
|
523
|
+
event_type: AuditEventTypeName,
|
|
524
|
+
outcome: AuditOutcome,
|
|
521
525
|
actor_id: nullable(Uuid),
|
|
522
526
|
account_id: nullable(Uuid),
|
|
523
527
|
target_account_id: nullable(Uuid),
|