@fuzdev/fuz_app 0.151.0 → 0.153.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +14 -11
- package/dist/actions/action_rpc.js +3 -3
- package/dist/actions/action_types.d.ts +3 -3
- package/dist/actions/broadcast_api.d.ts +0 -6
- package/dist/actions/broadcast_api.d.ts.map +1 -1
- package/dist/actions/connection_closer.d.ts +14 -15
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +13 -13
- package/dist/actions/perform_action.d.ts +5 -1
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +57 -19
- package/dist/actions/register_action_ws.d.ts +6 -5
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +5 -6
- package/dist/auth/CLAUDE.md +44 -14
- package/dist/auth/account_actions.d.ts +2 -2
- package/dist/auth/account_actions.js +6 -6
- package/dist/auth/account_routes.js +9 -9
- package/dist/auth/admin_actions.d.ts +2 -1
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +21 -20
- package/dist/auth/audit_emitter.d.ts +111 -64
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +130 -55
- package/dist/auth/audit_log_queries.d.ts +9 -10
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +13 -10
- package/dist/auth/audit_log_routes.js +2 -2
- package/dist/auth/audit_log_schema.d.ts +6 -1
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.d.ts +4 -3
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +4 -3
- package/dist/auth/bootstrap_routes.js +2 -2
- package/dist/auth/cell_action_helpers.d.ts +3 -2
- package/dist/auth/cell_action_helpers.d.ts.map +1 -1
- package/dist/auth/cell_action_helpers.js +9 -10
- package/dist/auth/cell_actions.js +6 -6
- package/dist/auth/cell_data_schema.d.ts +5 -0
- package/dist/auth/cell_data_schema.d.ts.map +1 -1
- package/dist/auth/cell_data_schema.js +5 -0
- package/dist/auth/cell_field_actions.js +2 -2
- package/dist/auth/cell_grant_actions.js +2 -2
- package/dist/auth/cell_item_actions.js +3 -3
- package/dist/auth/deps.d.ts +12 -10
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/middleware.js +1 -1
- package/dist/auth/request_context.d.ts +5 -10
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +10 -9
- package/dist/auth/role_grant_offer_actions.d.ts +11 -8
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +57 -41
- package/dist/auth/self_service_role_actions.d.ts +6 -5
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +17 -6
- package/dist/auth/session_cookie.d.ts +4 -4
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +0 -1
- package/dist/auth/session_middleware.d.ts +8 -5
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +10 -7
- package/dist/auth/signup_routes.js +6 -6
- package/dist/auth/standard_rpc_actions.d.ts +3 -2
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +3 -2
- package/dist/db/CLAUDE.md +10 -1
- package/dist/db/create_db.d.ts +18 -1
- package/dist/db/create_db.d.ts.map +1 -1
- package/dist/db/create_db.js +15 -4
- package/dist/db/db.d.ts +27 -0
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +26 -0
- package/dist/db/db_checkout_error.d.ts +36 -0
- package/dist/db/db_checkout_error.d.ts.map +1 -0
- package/dist/db/db_checkout_error.js +48 -0
- package/dist/db/db_pg.d.ts +83 -5
- package/dist/db/db_pg.d.ts.map +1 -1
- package/dist/db/db_pg.js +119 -9
- package/dist/db/pg_error.d.ts +4 -0
- package/dist/db/pg_error.d.ts.map +1 -1
- package/dist/db/pg_error.js +13 -3
- package/dist/dev/setup.d.ts +4 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +12 -5
- package/dist/hono_context.d.ts +36 -6
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +29 -2
- package/dist/http/CLAUDE.md +11 -10
- package/dist/http/db_routes.d.ts +7 -12
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +32 -17
- package/dist/http/error_schemas.d.ts +12 -0
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +12 -0
- package/dist/http/jsonrpc_errors.d.ts +10 -0
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +14 -0
- package/dist/http/jsonrpc_helpers.d.ts +4 -0
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +8 -1
- package/dist/http/route_spec.d.ts +4 -4
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +20 -3
- package/dist/http/schema_helpers.d.ts +21 -0
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +38 -0
- package/dist/realtime/audit_log_sse.d.ts +2 -2
- package/dist/realtime/audit_log_sse.js +2 -2
- package/dist/server/app_backend.d.ts +25 -1
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +16 -3
- package/dist/server/app_error_handler.d.ts +30 -0
- package/dist/server/app_error_handler.d.ts.map +1 -0
- package/dist/server/app_error_handler.js +41 -0
- package/dist/server/app_server.d.ts +1 -1
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +6 -1
- package/dist/server/env.d.ts +8 -3
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/env.js +26 -4
- package/dist/testing/CLAUDE.md +22 -16
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +2 -0
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +2 -2
- package/dist/testing/cross_backend/conformance_case.d.ts +2 -0
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_case.js +8 -0
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +24 -7
- package/dist/testing/cross_backend/default_backend_configs.d.ts +4 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +7 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +11 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.d.ts +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +15 -11
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +3 -12
- package/dist/testing/daemon_token_rotation.d.ts +4 -14
- package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
- package/dist/testing/daemon_token_rotation.js +0 -12
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +7 -3
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +2 -2
- package/dist/testing/rpc_helpers.d.ts +19 -0
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +25 -2
- package/dist/testing/schema_parity.d.ts +1 -1
- package/dist/testing/stubs.js +2 -2
- package/dist/testing/surface_invariants.js +1 -1
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +3 -3
- package/dist/zod.d.ts +9 -0
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +1 -1
- package/package.json +10 -14
|
@@ -43,8 +43,8 @@ export interface AccountActionOptions {
|
|
|
43
43
|
* Create the self-service account RPC actions.
|
|
44
44
|
*
|
|
45
45
|
* @param deps - `RevokingActionFactoryDeps` (`log`, `audit`,
|
|
46
|
-
* `connection_closer`). `audit.emit` writes
|
|
47
|
-
* pool; the bound emitter encapsulates `on_audit_event` fan-out and the
|
|
46
|
+
* `connection_closer`). `audit.emit` writes a success row in the request
|
|
47
|
+
* transaction and a failure row via the captured pool; the bound emitter encapsulates `on_audit_event` fan-out and the
|
|
48
48
|
* optional `AuditLogConfig`. `connection_closer` closes a revoked
|
|
49
49
|
* credential's live connections after the revocation commits.
|
|
50
50
|
* @param options - per-factory configuration
|
|
@@ -44,8 +44,8 @@ import { account_verify_action_spec, account_session_list_action_spec, account_s
|
|
|
44
44
|
* Create the self-service account RPC actions.
|
|
45
45
|
*
|
|
46
46
|
* @param deps - `RevokingActionFactoryDeps` (`log`, `audit`,
|
|
47
|
-
* `connection_closer`). `audit.emit` writes
|
|
48
|
-
* pool; the bound emitter encapsulates `on_audit_event` fan-out and the
|
|
47
|
+
* `connection_closer`). `audit.emit` writes a success row in the request
|
|
48
|
+
* transaction and a failure row via the captured pool; the bound emitter encapsulates `on_audit_event` fan-out and the
|
|
49
49
|
* optional `AuditLogConfig`. `connection_closer` closes a revoked
|
|
50
50
|
* credential's live connections after the revocation commits.
|
|
51
51
|
* @param options - per-factory configuration
|
|
@@ -82,7 +82,7 @@ export const create_account_actions = (deps, options = {}) => {
|
|
|
82
82
|
session_hash: input.session_id
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
deps.audit.emit(ctx, {
|
|
85
|
+
await deps.audit.emit(ctx, {
|
|
86
86
|
event_type: 'session_revoke',
|
|
87
87
|
outcome: revoked ? 'success' : 'failure',
|
|
88
88
|
account_id: ctx.auth.account.id,
|
|
@@ -102,7 +102,7 @@ export const create_account_actions = (deps, options = {}) => {
|
|
|
102
102
|
kind: 'account',
|
|
103
103
|
account_id: ctx.auth.account.id
|
|
104
104
|
});
|
|
105
|
-
deps.audit.emit(ctx, {
|
|
105
|
+
await deps.audit.emit(ctx, {
|
|
106
106
|
event_type: 'session_revoke_all',
|
|
107
107
|
account_id: ctx.auth.account.id,
|
|
108
108
|
ip: ctx.client_ip,
|
|
@@ -142,7 +142,7 @@ export const create_account_actions = (deps, options = {}) => {
|
|
|
142
142
|
queue_connection_close(ctx, connection_closer, { kind: 'token', api_token_id });
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
deps.audit.emit(ctx, {
|
|
145
|
+
await deps.audit.emit(ctx, {
|
|
146
146
|
event_type: 'token_create',
|
|
147
147
|
account_id: ctx.auth.account.id,
|
|
148
148
|
ip: ctx.client_ip,
|
|
@@ -183,7 +183,7 @@ export const create_account_actions = (deps, options = {}) => {
|
|
|
183
183
|
api_token_id: input.token_id
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
-
deps.audit.emit(ctx, {
|
|
186
|
+
await deps.audit.emit(ctx, {
|
|
187
187
|
event_type: 'token_revoke',
|
|
188
188
|
outcome: revoked ? 'success' : 'failure',
|
|
189
189
|
account_id: ctx.auth.account.id,
|
|
@@ -250,7 +250,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
250
250
|
await password.verify_dummy(pw);
|
|
251
251
|
ip_reserved.reservation.record();
|
|
252
252
|
account_reservation?.record();
|
|
253
|
-
deps.audit.emit(route, {
|
|
253
|
+
await deps.audit.emit(route, {
|
|
254
254
|
event_type: 'login',
|
|
255
255
|
outcome: 'failure',
|
|
256
256
|
ip: get_client_ip(c),
|
|
@@ -263,7 +263,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
263
263
|
if (!valid) {
|
|
264
264
|
ip_reserved.reservation.record();
|
|
265
265
|
account_reservation?.record();
|
|
266
|
-
deps.audit.emit(route, {
|
|
266
|
+
await deps.audit.emit(route, {
|
|
267
267
|
event_type: 'login',
|
|
268
268
|
outcome: 'failure',
|
|
269
269
|
account_id: account.id,
|
|
@@ -307,7 +307,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
307
307
|
for (const session_hash of evicted) {
|
|
308
308
|
close_connections_after_commit(connection_closer, { kind: 'session', session_hash }, deps.log);
|
|
309
309
|
}
|
|
310
|
-
deps.audit.emit(route, {
|
|
310
|
+
await deps.audit.emit(route, {
|
|
311
311
|
event_type: 'login',
|
|
312
312
|
account_id: account.id,
|
|
313
313
|
ip: get_client_ip(c)
|
|
@@ -331,8 +331,8 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
331
331
|
await query_session_revoke_by_hash_unscoped(route, session_hash);
|
|
332
332
|
// Close this account's live connections once the revoke has
|
|
333
333
|
// committed — queued, so it never runs before the commit or on
|
|
334
|
-
// rollback, and it does not depend on the
|
|
335
|
-
//
|
|
334
|
+
// rollback, and it does not depend on the audit row below (written
|
|
335
|
+
// in the route transaction, so it commits with the revoke). Account-wide (not session-targeted) to match the Rust
|
|
336
336
|
// `account_logout` handler and the sibling `/password` handler
|
|
337
337
|
// — logout is a self-initiated account-grain operation. The
|
|
338
338
|
// audit listeners repeat the same close on the announced
|
|
@@ -346,7 +346,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
346
346
|
// Account-grain operation — no `actor_id` (which actor was
|
|
347
347
|
// resolved per-request is incidental to "this account ended
|
|
348
348
|
// its session"). Mirrors `login`.
|
|
349
|
-
deps.audit.emit(route, {
|
|
349
|
+
await deps.audit.emit(route, {
|
|
350
350
|
event_type: 'logout',
|
|
351
351
|
account_id: ctx.account.id,
|
|
352
352
|
ip: get_client_ip(c)
|
|
@@ -386,7 +386,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
386
386
|
if (!valid) {
|
|
387
387
|
ip_reserved.reservation.record();
|
|
388
388
|
account_reservation?.record();
|
|
389
|
-
deps.audit.emit(route, {
|
|
389
|
+
await deps.audit.emit(route, {
|
|
390
390
|
event_type: 'password_change',
|
|
391
391
|
outcome: 'failure',
|
|
392
392
|
account_id: ctx.account.id,
|
|
@@ -446,7 +446,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
446
446
|
// no cookie clear here either.
|
|
447
447
|
ip_reserved.reservation.record();
|
|
448
448
|
account_reservation?.record();
|
|
449
|
-
deps.audit.emit(route, {
|
|
449
|
+
await deps.audit.emit(route, {
|
|
450
450
|
event_type: 'password_change',
|
|
451
451
|
outcome: 'failure',
|
|
452
452
|
account_id: ctx.account.id,
|
|
@@ -468,7 +468,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
468
468
|
// account-level state; which per-request actor was resolved
|
|
469
469
|
// has no semantic bearing on "this account changed its
|
|
470
470
|
// password". Mirrors `login`/`logout`.
|
|
471
|
-
deps.audit.emit(route, {
|
|
471
|
+
await deps.audit.emit(route, {
|
|
472
472
|
event_type: 'password_change',
|
|
473
473
|
account_id: ctx.account.id,
|
|
474
474
|
ip: get_client_ip(c),
|
|
@@ -46,7 +46,8 @@ export interface AdminActionOptions {
|
|
|
46
46
|
*
|
|
47
47
|
* @param deps - `RevokingActionFactoryDeps` (`log`, `audit`,
|
|
48
48
|
* `connection_closer`). `log` drives RPC-internal error logging;
|
|
49
|
-
* `audit.emit` writes
|
|
49
|
+
* `audit.emit` writes a success row in the request transaction and a
|
|
50
|
+
* failure row via the captured pool. The bound emitter
|
|
50
51
|
* encapsulates listener fan-out and the optional `AuditLogConfig`.
|
|
51
52
|
* `connection_closer` closes the target account's live connections after a
|
|
52
53
|
* revoke-all, delete, or purge commits.
|
|
@@ -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,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AA2C1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA0D3D,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED
|
|
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,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AA2C1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA0D3D,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,yBAAyB,EAC/B,UAAS,kBAAuB,KAC9B,KAAK,CAAC,SAAS,CA6hBjB,CAAC"}
|
|
@@ -52,7 +52,8 @@ import { admin_account_list_action_spec, admin_session_list_action_spec, admin_s
|
|
|
52
52
|
*
|
|
53
53
|
* @param deps - `RevokingActionFactoryDeps` (`log`, `audit`,
|
|
54
54
|
* `connection_closer`). `log` drives RPC-internal error logging;
|
|
55
|
-
* `audit.emit` writes
|
|
55
|
+
* `audit.emit` writes a success row in the request transaction and a
|
|
56
|
+
* failure row via the captured pool. The bound emitter
|
|
56
57
|
* encapsulates listener fan-out and the optional `AuditLogConfig`.
|
|
57
58
|
* `connection_closer` closes the target account's live connections after a
|
|
58
59
|
* revoke-all, delete, or purge commits.
|
|
@@ -84,7 +85,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
84
85
|
const auth = ctx.auth;
|
|
85
86
|
const account = await query_account_by_id(ctx, input.account_id);
|
|
86
87
|
if (!account) {
|
|
87
|
-
deps.audit.emit(ctx, {
|
|
88
|
+
await deps.audit.emit(ctx, {
|
|
88
89
|
event_type,
|
|
89
90
|
outcome: 'failure',
|
|
90
91
|
account_id: auth.account.id,
|
|
@@ -119,7 +120,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
119
120
|
// because the FK linkage powers the username-join in
|
|
120
121
|
// `audit_log_list_with_usernames`; losing it on every success row
|
|
121
122
|
// to harden a corner case isn't worth the query-shape change.
|
|
122
|
-
deps.audit.emit(ctx, {
|
|
123
|
+
await deps.audit.emit(ctx, {
|
|
123
124
|
event_type,
|
|
124
125
|
account_id: auth.account.id,
|
|
125
126
|
target_account_id: input.account_id,
|
|
@@ -181,7 +182,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
181
182
|
}
|
|
182
183
|
throw err;
|
|
183
184
|
}
|
|
184
|
-
deps.audit.emit(ctx, {
|
|
185
|
+
await deps.audit.emit(ctx, {
|
|
185
186
|
event_type: 'invite_create',
|
|
186
187
|
account_id: auth.account.id,
|
|
187
188
|
ip: ctx.client_ip,
|
|
@@ -199,7 +200,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
199
200
|
if (!deleted) {
|
|
200
201
|
throw jsonrpc_errors.not_found('invite', { reason: ERROR_INVITE_NOT_FOUND });
|
|
201
202
|
}
|
|
202
|
-
deps.audit.emit(ctx, {
|
|
203
|
+
await deps.audit.emit(ctx, {
|
|
203
204
|
event_type: 'invite_delete',
|
|
204
205
|
account_id: auth.account.id,
|
|
205
206
|
ip: ctx.client_ip,
|
|
@@ -225,8 +226,8 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
225
226
|
// the failure row matches the operation in flight.
|
|
226
227
|
const assert_account_removable = async (ctx, target_account_id, event_type) => {
|
|
227
228
|
const auth = ctx.auth;
|
|
228
|
-
const deny = (reason, message) => {
|
|
229
|
-
deps.audit.emit(ctx, {
|
|
229
|
+
const deny = async (reason, message) => {
|
|
230
|
+
await deps.audit.emit(ctx, {
|
|
230
231
|
event_type,
|
|
231
232
|
outcome: 'failure',
|
|
232
233
|
actor_id: auth.actor.id,
|
|
@@ -239,7 +240,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
239
240
|
};
|
|
240
241
|
const verb = event_type === 'account_purge' ? 'purge' : 'delete';
|
|
241
242
|
if (await query_account_has_global_role(ctx, target_account_id, ROLE_KEEPER)) {
|
|
242
|
-
deny(ERROR_CANNOT_DELETE_KEEPER, `cannot ${verb} the keeper account`);
|
|
243
|
+
await deny(ERROR_CANNOT_DELETE_KEEPER, `cannot ${verb} the keeper account`);
|
|
243
244
|
}
|
|
244
245
|
// `_active_` variant: a tombstoned admin is already excluded from the
|
|
245
246
|
// active count, so removing it can't drop the tally — guarding it would
|
|
@@ -248,7 +249,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
248
249
|
// unconditional; the last-admin branch fires only for an *active* target.
|
|
249
250
|
if ((await query_account_has_active_global_role(ctx, target_account_id, ROLE_ADMIN)) &&
|
|
250
251
|
(await query_count_active_accounts_with_global_role_for_update(ctx, ROLE_ADMIN)) <= 1) {
|
|
251
|
-
deny(ERROR_CANNOT_DELETE_LAST_ADMIN, `cannot ${verb} the last admin account`);
|
|
252
|
+
await deny(ERROR_CANNOT_DELETE_LAST_ADMIN, `cannot ${verb} the last admin account`);
|
|
252
253
|
}
|
|
253
254
|
};
|
|
254
255
|
// Supersede every pending offer the removed account's actors made, audited
|
|
@@ -259,7 +260,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
259
260
|
const cancel_outgoing_offers = async (ctx, target_account_id, actors) => {
|
|
260
261
|
const superseded = await query_role_grant_offer_supersede_outgoing(ctx, actors.map((a) => a.id));
|
|
261
262
|
for (const offer of superseded) {
|
|
262
|
-
deps.audit.emit_role_grant_target(ctx, ctx.auth, {
|
|
263
|
+
await deps.audit.emit_role_grant_target(ctx, ctx.auth, {
|
|
263
264
|
event_type: 'role_grant_offer_supersede',
|
|
264
265
|
target_account_id: offer.to_account_id,
|
|
265
266
|
target_actor_id: offer.to_actor_id,
|
|
@@ -307,7 +308,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
307
308
|
const snapshot = await query_account_soft_delete(ctx, target_account_id, auth.actor.id);
|
|
308
309
|
if (!snapshot) {
|
|
309
310
|
// Missing or already soft-deleted — UUID probe key, failure audit is safe.
|
|
310
|
-
deps.audit.emit(ctx, {
|
|
311
|
+
await deps.audit.emit(ctx, {
|
|
311
312
|
event_type: 'account_delete',
|
|
312
313
|
outcome: 'failure',
|
|
313
314
|
actor_id: auth.actor.id,
|
|
@@ -332,7 +333,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
332
333
|
kind: 'account',
|
|
333
334
|
account_id: target_account_id
|
|
334
335
|
});
|
|
335
|
-
deps.audit.emit(ctx, {
|
|
336
|
+
await deps.audit.emit(ctx, {
|
|
336
337
|
event_type: 'account_delete',
|
|
337
338
|
actor_id: auth.actor.id,
|
|
338
339
|
account_id: auth.account.id,
|
|
@@ -341,7 +342,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
341
342
|
metadata: { username: snapshot.username, email: snapshot.email }
|
|
342
343
|
});
|
|
343
344
|
for (const actor of soft_deleted_actors) {
|
|
344
|
-
deps.audit.emit(ctx, {
|
|
345
|
+
await deps.audit.emit(ctx, {
|
|
345
346
|
event_type: 'actor_delete',
|
|
346
347
|
actor_id: auth.actor.id,
|
|
347
348
|
account_id: auth.account.id,
|
|
@@ -375,7 +376,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
375
376
|
await cancel_outgoing_offers(ctx, input.account_id, actors);
|
|
376
377
|
const snapshot = await query_purge_account(ctx, input.account_id);
|
|
377
378
|
if (!snapshot) {
|
|
378
|
-
deps.audit.emit(ctx, {
|
|
379
|
+
await deps.audit.emit(ctx, {
|
|
379
380
|
event_type: 'account_purge',
|
|
380
381
|
outcome: 'failure',
|
|
381
382
|
actor_id: auth.actor.id,
|
|
@@ -392,7 +393,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
392
393
|
account_id: input.account_id
|
|
393
394
|
});
|
|
394
395
|
deps.log.warn(`account hard-purged (irreversible cascading delete): ${input.account_id} by actor ${auth.actor.id}`);
|
|
395
|
-
deps.audit.emit(ctx, {
|
|
396
|
+
await deps.audit.emit(ctx, {
|
|
396
397
|
event_type: 'account_purge',
|
|
397
398
|
actor_id: auth.actor.id,
|
|
398
399
|
account_id: auth.account.id,
|
|
@@ -401,7 +402,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
401
402
|
metadata: { username: snapshot.username, email: snapshot.email }
|
|
402
403
|
});
|
|
403
404
|
for (const actor of actors) {
|
|
404
|
-
deps.audit.emit(ctx, {
|
|
405
|
+
await deps.audit.emit(ctx, {
|
|
405
406
|
event_type: 'actor_purge',
|
|
406
407
|
actor_id: auth.actor.id,
|
|
407
408
|
account_id: auth.account.id,
|
|
@@ -426,7 +427,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
426
427
|
const snapshot = await query_account_undelete(ctx, input.account_id);
|
|
427
428
|
if (!snapshot) {
|
|
428
429
|
// Missing or not soft-deleted — UUID probe key, failure audit is safe.
|
|
429
|
-
deps.audit.emit(ctx, {
|
|
430
|
+
await deps.audit.emit(ctx, {
|
|
430
431
|
event_type: 'account_undelete',
|
|
431
432
|
outcome: 'failure',
|
|
432
433
|
actor_id: auth.actor.id,
|
|
@@ -442,7 +443,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
442
443
|
undeleted_actors.push(actor);
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
|
-
deps.audit.emit(ctx, {
|
|
446
|
+
await deps.audit.emit(ctx, {
|
|
446
447
|
event_type: 'account_undelete',
|
|
447
448
|
actor_id: auth.actor.id,
|
|
448
449
|
account_id: auth.account.id,
|
|
@@ -451,7 +452,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
451
452
|
metadata: { username: snapshot.username, email: snapshot.email }
|
|
452
453
|
});
|
|
453
454
|
for (const actor of undeleted_actors) {
|
|
454
|
-
deps.audit.emit(ctx, {
|
|
455
|
+
await deps.audit.emit(ctx, {
|
|
455
456
|
event_type: 'actor_undelete',
|
|
456
457
|
actor_id: auth.actor.id,
|
|
457
458
|
account_id: auth.account.id,
|
|
@@ -486,7 +487,7 @@ export const create_admin_actions = (deps, options = {}) => {
|
|
|
486
487
|
// Read the prior value for the audit row before writing the new one.
|
|
487
488
|
const { open_signup: old_value } = await query_app_settings_load(ctx);
|
|
488
489
|
await query_app_settings_update(ctx, input.open_signup, auth.actor.id);
|
|
489
|
-
deps.audit.emit(ctx, {
|
|
490
|
+
await deps.audit.emit(ctx, {
|
|
490
491
|
event_type: 'app_settings_update',
|
|
491
492
|
account_id: auth.account.id,
|
|
492
493
|
ip: ctx.client_ip,
|
|
@@ -6,24 +6,23 @@
|
|
|
6
6
|
* consumer's `audit_factory` callback on `CreateAppBackendOptions` —
|
|
7
7
|
* `create_app_backend` invokes the factory once with its constructed
|
|
8
8
|
* `{db, log}` and lands the result on `AppDeps.audit`. Consumers reach
|
|
9
|
-
* for `deps.audit.emit(ctx, input)
|
|
10
|
-
*
|
|
11
|
-
* transactional `db` (which would be rolled back with the parent on a
|
|
12
|
-
* handler throw).
|
|
9
|
+
* for `await deps.audit.emit(ctx, input)`; the emitter picks where the row
|
|
10
|
+
* is written (see "Where a row is written").
|
|
13
11
|
*
|
|
14
12
|
* These methods cover every fan-out shape the auth domain needs
|
|
15
13
|
* (`add_listener` and `listener_count` manage the listener chain):
|
|
16
14
|
*
|
|
17
|
-
* - `emit(ctx, input)` —
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* - `emit(ctx, input)` — the request-scoped emit. A success row inside a
|
|
16
|
+
* request transaction is written in it and the promise rejects when the
|
|
17
|
+
* INSERT fails; every other row is a fire-and-forget pool write whose
|
|
18
|
+
* in-flight promise goes on `ctx.pending_effects`, and the returned promise
|
|
19
|
+
* resolves at once.
|
|
22
20
|
* - `emit_role_grant_target(ctx, auth, input)` — wrapper that lifts the
|
|
23
21
|
* `actor_id` / `account_id` / `ip` boilerplate every role-grant-shape audit
|
|
24
22
|
* site repeated. Delegates to `emit`.
|
|
25
23
|
* - `emit_pool(input)` — awaitable pool write for code paths without a
|
|
26
|
-
* request
|
|
24
|
+
* request transaction (maintenance scripts, a post-commit thunk). Writes,
|
|
25
|
+
* then notifies.
|
|
27
26
|
* - `notify(event)` — fan out an already-written audit row (e.g. rows
|
|
28
27
|
* returned by `query_accept_offer` that were inserted in-transaction by
|
|
29
28
|
* the query layer, or the offer-expiry rows `auth/cleanup.ts` writes in
|
|
@@ -34,33 +33,57 @@
|
|
|
34
33
|
* - `is_tracking_inflight()` — whether that barrier can wait on anything, so a
|
|
35
34
|
* test binary built without tracking is caught rather than racing.
|
|
36
35
|
*
|
|
37
|
-
* ##
|
|
36
|
+
* ## Where a row is written
|
|
37
|
+
*
|
|
38
|
+
* The routing reads two things: the row's outcome and whether `ctx.db` is a
|
|
39
|
+
* transaction (`Db.in_transaction`).
|
|
40
|
+
*
|
|
41
|
+
* - A **success** row emitted inside a request transaction (an action with
|
|
42
|
+
* `side_effects`, a route with `transaction: true`) is written **in that
|
|
43
|
+
* transaction**: the change and the row that reports it commit together or
|
|
44
|
+
* not at all. The INSERT is awaited, and a failed one rejects `emit`, so the
|
|
45
|
+
* handler throws and its transaction rolls back — a committed change is
|
|
46
|
+
* never left unaudited.
|
|
47
|
+
* - A **failure** row is written on the pool, outside the request's
|
|
48
|
+
* transaction, so it survives the rollback that usually follows it — the
|
|
49
|
+
* forensic record of a refused attempt.
|
|
50
|
+
* - A success row emitted with no request transaction open (a `GET`, or a
|
|
51
|
+
* route that runs `transaction: false` and opens its own around just its
|
|
52
|
+
* writes, like `/login` and `/password`, which emit once that transaction
|
|
53
|
+
* has committed) is written on the pool too — there is no transaction to
|
|
54
|
+
* join.
|
|
55
|
+
*
|
|
56
|
+
* A pool write is fail-open: a failed one is counted
|
|
57
|
+
* (`get_audit_write_failures`) and logged as one `error` line carrying the
|
|
58
|
+
* whole row, secret metadata masked (`to_dropped_audit_row`), and the request
|
|
59
|
+
* goes on. Its checkout waits the backend's audit bound
|
|
60
|
+
* (`FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS`, 30 s by default — `create_app_backend`
|
|
61
|
+
* hands the factory its pool `Db` through `Db.with_checkout_timeout`), longer
|
|
62
|
+
* than a request's, so a pool saturated enough to shed requests with a 503
|
|
63
|
+
* does not also drop the failure rows recording them.
|
|
38
64
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
65
|
+
* This is the Rust spine's split: `fuz_auth`'s `route_audit_emit` writes an
|
|
66
|
+
* action's success row in the request transaction (`emit_in_tx`) and every
|
|
67
|
+
* failure row on the pool (`emit`), and its REST handlers (`/login`,
|
|
68
|
+
* `/password`, signup, bootstrap) emit on the pool. Two rows differ in
|
|
69
|
+
* routing between the twins, visible on the wire only when the audit INSERT
|
|
70
|
+
* fails: the TS `/logout` runs in a route transaction, so its success row is
|
|
71
|
+
* written in it (Rust writes it on the pool), and `db_admin_row_delete` is
|
|
72
|
+
* written on the pool after the commit on both (`http/db_routes.ts`, through
|
|
73
|
+
* `emit_pool`).
|
|
74
|
+
*
|
|
75
|
+
* ## When listeners hear about a row
|
|
42
76
|
*
|
|
43
77
|
* - A **failure** row is announced as soon as it is written. It records an
|
|
44
78
|
* attempt, which happened whether or not the request's transaction commits.
|
|
45
79
|
* - A **success** row is announced only after the request's transaction
|
|
46
80
|
* commits (after the handler returns, on a route without one), and never
|
|
47
81
|
* when the handler throws: the fan-out is queued on
|
|
48
|
-
* `ctx.post_commit_effects
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* A success row emitted by a handler that later throws is still in the table —
|
|
55
|
-
* the write is outside the transaction — but is never announced.
|
|
56
|
-
*
|
|
57
|
-
* A route that runs without a request transaction and opens its own around
|
|
58
|
-
* just its writes (`/login`, `/password`) emits its success row once that
|
|
59
|
-
* transaction has committed, so the row is written after the change it
|
|
60
|
-
* reports. The Rust spine follows the same order: a success row emitted inside
|
|
61
|
-
* a request transaction is written in that transaction and its fan-out queued
|
|
62
|
-
* behind the commit, and `/login` and `/password` emit on the pool after their
|
|
63
|
-
* own transaction commits.
|
|
82
|
+
* `ctx.post_commit_effects`. A success row reports a state change, and the
|
|
83
|
+
* listeners act on it — the revocation listeners close connections, the
|
|
84
|
+
* audit stream broadcasts it. Announced before the commit, a close could run
|
|
85
|
+
* while the revoked credential still reads as valid, and a rolled-back
|
|
86
|
+
* revocation would close connections anyway.
|
|
64
87
|
*
|
|
65
88
|
* Listeners are a documented registration seam — `create_app_server`
|
|
66
89
|
* registers additional listeners via `add_listener` after the backend is
|
|
@@ -76,29 +99,27 @@
|
|
|
76
99
|
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
77
100
|
import type { Uuid } from '../primitive_schemas.js';
|
|
78
101
|
import type { Db } from '../db/db.js';
|
|
102
|
+
import type { QueryDeps } from '../db/query_deps.js';
|
|
79
103
|
import { type EmitAfterCommitContext } from '../http/pending_effects.js';
|
|
80
104
|
import type { RequestActorContext } from './request_context.js';
|
|
81
105
|
import { type AuditLogConfig, type AuditLogEvent, type AuditLogInput } from './audit_log_schema.js';
|
|
82
106
|
/**
|
|
83
|
-
* Per-request context required by `AuditEmitter.emit` — the request's
|
|
84
|
-
* side-effect queues. The bound emitter carries its own `log`
|
|
85
|
-
* inside the closure, so per-call contexts don't need one.
|
|
107
|
+
* Per-request context required by `AuditEmitter.emit` — the request's `db`
|
|
108
|
+
* and its two side-effect queues. The bound emitter carries its own `log`
|
|
109
|
+
* reference inside the closure, so per-call contexts don't need one.
|
|
86
110
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* `post_commit_effects`
|
|
92
|
-
* row").
|
|
93
|
-
*
|
|
94
|
-
* One success-only event also defers its *write*: the `db_admin_row_delete`
|
|
95
|
-
* emit in `http/db_routes.ts` wraps the whole emit in `emit_after_commit`, so
|
|
96
|
-
* the trail can't claim a mutation whose transaction failed at COMMIT.
|
|
111
|
+
* `db` decides where a success row is written: inside the request's
|
|
112
|
+
* transaction when `db.in_transaction`, else on the pool (module doc, "Where a
|
|
113
|
+
* row is written"). A pool write is eager — the emitter fires it immediately
|
|
114
|
+
* and pushes the in-flight `Promise<void>` onto `pending_effects`. A success
|
|
115
|
+
* row's listener fan-out goes on `post_commit_effects` (module doc, "When
|
|
116
|
+
* listeners hear about a row").
|
|
97
117
|
*
|
|
98
118
|
* Both `RouteContext` and `ActionContext` structurally satisfy this
|
|
99
|
-
* shape, so handlers pass `route` / `ctx` directly.
|
|
119
|
+
* shape, so handlers pass `route` / `ctx` directly. Never pass one from a
|
|
120
|
+
* post-commit thunk: its transaction has ended — use `emit_pool` there.
|
|
100
121
|
*/
|
|
101
|
-
export interface AuditEmitterContext extends EmitAfterCommitContext {
|
|
122
|
+
export interface AuditEmitterContext extends EmitAfterCommitContext, QueryDeps {
|
|
102
123
|
pending_effects: Array<Promise<void>>;
|
|
103
124
|
}
|
|
104
125
|
/**
|
|
@@ -130,26 +151,30 @@ export interface AuditEmitRoleGrantInput<T extends string> {
|
|
|
130
151
|
*/
|
|
131
152
|
export interface AuditEmitter {
|
|
132
153
|
/**
|
|
133
|
-
*
|
|
154
|
+
* Write an audit row for a request, routed by outcome and `ctx.db` (module
|
|
155
|
+
* doc, "Where a row is written").
|
|
134
156
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
157
|
+
* A success row inside a request transaction is written in it: the
|
|
158
|
+
* promise settles once the INSERT has run, and rejects when it fails, so
|
|
159
|
+
* the handler throws and the change rolls back with its row. Any other row
|
|
160
|
+
* is a fire-and-forget pool write: its in-flight promise goes on
|
|
161
|
+
* `ctx.pending_effects` (so tests with `await_pending_effects: true` can
|
|
162
|
+
* assert it inline), its errors are logged and counted, never thrown, and
|
|
163
|
+
* the returned promise resolves at once.
|
|
141
164
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* code paths without `pending_effects`, use `emit_pool`.
|
|
165
|
+
* A written row fans out to every listener on the chain (`notify`): a
|
|
166
|
+
* failure row as soon as it is written, a success row from
|
|
167
|
+
* `ctx.post_commit_effects` — after the request's transaction commits, and
|
|
168
|
+
* never when the handler throws.
|
|
147
169
|
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
170
|
+
* Always `await` it — the twin of the Rust `ctx.audit_emit(db, input).await?`.
|
|
171
|
+
*
|
|
172
|
+
* @mutates `audit_log` table - inserts the row in `ctx.db`'s transaction or via the captured pool
|
|
173
|
+
* @mutates `ctx.pending_effects` - appends a pool write's in-flight settled promise
|
|
150
174
|
* @mutates `ctx.post_commit_effects` - appends a success row's listener fan-out
|
|
175
|
+
* @throws Error when an in-transaction INSERT fails
|
|
151
176
|
*/
|
|
152
|
-
emit<T extends string>(ctx: AuditEmitterContext, input: AuditLogInput<T>): void
|
|
177
|
+
emit<T extends string>(ctx: AuditEmitterContext, input: AuditLogInput<T>): Promise<void>;
|
|
153
178
|
/**
|
|
154
179
|
* Emit a role-grant-shape audit event with `actor_id` / `account_id` /
|
|
155
180
|
* `ip` lifted from `auth` + `ctx`. Delegates to `emit`.
|
|
@@ -158,12 +183,15 @@ export interface AuditEmitter {
|
|
|
158
183
|
* Reach for the lower-level `emit` only when the event is non-role-grant
|
|
159
184
|
* shape (e.g. `app_settings_update`, bootstrap, signup).
|
|
160
185
|
*/
|
|
161
|
-
emit_role_grant_target<T extends string>(ctx: AuditEmitRoleGrantContext, auth: RequestActorContext, input: AuditEmitRoleGrantInput<T>): void
|
|
186
|
+
emit_role_grant_target<T extends string>(ctx: AuditEmitRoleGrantContext, auth: RequestActorContext, input: AuditEmitRoleGrantInput<T>): Promise<void>;
|
|
162
187
|
/**
|
|
163
|
-
* Awaitable pool write for code paths without a request
|
|
188
|
+
* Awaitable pool write for code paths without a request transaction — a
|
|
189
|
+
* maintenance script, or a post-commit thunk whose transaction has ended
|
|
190
|
+
* (`db_admin_row_delete`, `http/db_routes.ts`).
|
|
164
191
|
*
|
|
165
192
|
* Writes, then notifies the listeners, whatever the outcome — there is no
|
|
166
|
-
* request transaction to order the fan-out against.
|
|
193
|
+
* request transaction to order the fan-out against. Tracked by
|
|
194
|
+
* `drain_inflight` like `emit`'s pool writes. Errors are logged and
|
|
167
195
|
* swallowed (resolved void), so callers can sequence writes with
|
|
168
196
|
* `await audit.emit_pool(...)` without try/catch boilerplate.
|
|
169
197
|
*
|
|
@@ -254,7 +282,7 @@ export interface AuditEmitter {
|
|
|
254
282
|
* a `this.emit` lookup. Exposed as a type so `EmitDecorator` can name
|
|
255
283
|
* the inner / outer slot.
|
|
256
284
|
*/
|
|
257
|
-
export type AuditEmitFn = <T extends string>(ctx: AuditEmitterContext, input: AuditLogInput<T>) => void
|
|
285
|
+
export type AuditEmitFn = <T extends string>(ctx: AuditEmitterContext, input: AuditLogInput<T>) => Promise<void>;
|
|
258
286
|
/**
|
|
259
287
|
* Wrap the bound `emit` before it gets captured by `emit_role_grant_target`'s
|
|
260
288
|
* closure and exposed on the returned `AuditEmitter`. Test instrumentation
|
|
@@ -305,6 +333,25 @@ export interface CreateAuditEmitterOptions {
|
|
|
305
333
|
*/
|
|
306
334
|
track_inflight?: boolean;
|
|
307
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* The whole row a dropped pool write would have inserted, as the one JSON
|
|
338
|
+
* object its `audit row dropped` log line carries: `event_type`, `outcome`, the
|
|
339
|
+
* four id columns, `ip`, and `metadata` — with each metadata field whose
|
|
340
|
+
* schema in `config` is marked `sensitivity: 'secret'` replaced by
|
|
341
|
+
* `MASKED_VALUE`. No builtin event declares a secret field, so a builtin row
|
|
342
|
+
* logs whole, as the Rust twin's `fuz_auth::dropped_row_json` does.
|
|
343
|
+
*
|
|
344
|
+
* The masking reads only the top-level fields of an object metadata schema. A
|
|
345
|
+
* secret field nested under an object field, or declared in a union or
|
|
346
|
+
* discriminated-union schema, is logged in clear, and so is every
|
|
347
|
+
* `sensitivity: 'personal'` field. Keep secrets out of audit metadata — they
|
|
348
|
+
* would land in `audit_log` too.
|
|
349
|
+
*
|
|
350
|
+
* @param input - the row's input
|
|
351
|
+
* @param config - the emitter's `AuditLogConfig`, whose event schemas mark secret fields
|
|
352
|
+
* @returns the row, ready to `JSON.stringify`
|
|
353
|
+
*/
|
|
354
|
+
export declare const to_dropped_audit_row: <T extends string>(input: AuditLogInput<T>, config: AuditLogConfig) => Record<string, unknown>;
|
|
308
355
|
/** Number of audit rows an emitter failed to write since process start. */
|
|
309
356
|
export declare const get_audit_write_failures: () => number;
|
|
310
357
|
/** Reset the counter — for tests only. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_emitter.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_emitter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"audit_emitter.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_emitter.ts"],"names":[],"mappings":"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"}
|