@fuzdev/fuz_app 0.152.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 +3 -7
|
@@ -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.
|
|
64
|
+
*
|
|
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`).
|
|
38
74
|
*
|
|
39
|
-
*
|
|
40
|
-
* is outside the request's transaction, so it survives a rollback. Listener
|
|
41
|
-
* fan-out is a separate step, and it depends on the outcome:
|
|
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
|
|
@@ -73,18 +96,63 @@
|
|
|
73
96
|
*
|
|
74
97
|
* @module
|
|
75
98
|
*/
|
|
99
|
+
import { to_error_message } from '@fuzdev/fuz_util/error.ts';
|
|
100
|
+
import { MASKED_VALUE } from '../env/mask.js';
|
|
101
|
+
import { schema_sensitivity } from '../schema_meta.js';
|
|
102
|
+
import { zod_maybe_get_field_schema } from '../zod.js';
|
|
76
103
|
import { emit_after_commit } from '../http/pending_effects.js';
|
|
77
104
|
import { query_audit_log } from './audit_log_queries.js';
|
|
78
105
|
import { builtin_audit_log_config } from './audit_log_schema.js';
|
|
79
106
|
/**
|
|
80
|
-
* Process-wide counter for audit rows an emitter failed to write
|
|
81
|
-
* write behind `emit` / `emit_pool` / `emit_role_grant_target` is
|
|
82
|
-
* a refused `INSERT` is logged and the request proceeds — so a
|
|
83
|
-
* otherwise visible only in the log.
|
|
107
|
+
* Process-wide counter for audit rows an emitter failed to write on the pool.
|
|
108
|
+
* The pool write behind `emit` / `emit_pool` / `emit_role_grant_target` is
|
|
109
|
+
* fail-open — a refused `INSERT` is logged and the request proceeds — so a
|
|
110
|
+
* lost row is otherwise visible only in the log. An in-transaction write is
|
|
111
|
+
* not counted: its failure rejects `emit` and fails the request. Same posture and lifetime as the drift
|
|
84
112
|
* counters in `auth/audit_log_queries.ts`: in-process, resets on restart, and
|
|
85
113
|
* asserted zero per test by `install_audit_drift_guard`.
|
|
86
114
|
*/
|
|
87
115
|
let audit_write_failures = 0;
|
|
116
|
+
/**
|
|
117
|
+
* The whole row a dropped pool write would have inserted, as the one JSON
|
|
118
|
+
* object its `audit row dropped` log line carries: `event_type`, `outcome`, the
|
|
119
|
+
* four id columns, `ip`, and `metadata` — with each metadata field whose
|
|
120
|
+
* schema in `config` is marked `sensitivity: 'secret'` replaced by
|
|
121
|
+
* `MASKED_VALUE`. No builtin event declares a secret field, so a builtin row
|
|
122
|
+
* logs whole, as the Rust twin's `fuz_auth::dropped_row_json` does.
|
|
123
|
+
*
|
|
124
|
+
* The masking reads only the top-level fields of an object metadata schema. A
|
|
125
|
+
* secret field nested under an object field, or declared in a union or
|
|
126
|
+
* discriminated-union schema, is logged in clear, and so is every
|
|
127
|
+
* `sensitivity: 'personal'` field. Keep secrets out of audit metadata — they
|
|
128
|
+
* would land in `audit_log` too.
|
|
129
|
+
*
|
|
130
|
+
* @param input - the row's input
|
|
131
|
+
* @param config - the emitter's `AuditLogConfig`, whose event schemas mark secret fields
|
|
132
|
+
* @returns the row, ready to `JSON.stringify`
|
|
133
|
+
*/
|
|
134
|
+
export const to_dropped_audit_row = (input, config) => {
|
|
135
|
+
let metadata = input.metadata ?? null;
|
|
136
|
+
const schema = config.metadata_schemas[input.event_type];
|
|
137
|
+
if (schema && metadata !== null && typeof metadata === 'object' && !Array.isArray(metadata)) {
|
|
138
|
+
const masked = {};
|
|
139
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
140
|
+
const field = zod_maybe_get_field_schema(schema, key);
|
|
141
|
+
masked[key] = field && schema_sensitivity(field) === 'secret' ? MASKED_VALUE : value;
|
|
142
|
+
}
|
|
143
|
+
metadata = masked;
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
event_type: input.event_type,
|
|
147
|
+
outcome: input.outcome ?? 'success',
|
|
148
|
+
actor_id: input.actor_id ?? null,
|
|
149
|
+
account_id: input.account_id ?? null,
|
|
150
|
+
target_account_id: input.target_account_id ?? null,
|
|
151
|
+
target_actor_id: input.target_actor_id ?? null,
|
|
152
|
+
ip: input.ip ?? null,
|
|
153
|
+
metadata
|
|
154
|
+
};
|
|
155
|
+
};
|
|
88
156
|
/** Number of audit rows an emitter failed to write since process start. */
|
|
89
157
|
export const get_audit_write_failures = () => audit_write_failures;
|
|
90
158
|
/** Reset the counter — for tests only. */
|
|
@@ -124,19 +192,19 @@ export const create_audit_emitter = (options) => {
|
|
|
124
192
|
}
|
|
125
193
|
}
|
|
126
194
|
};
|
|
127
|
-
// The pool write. Never rejects: a failed write is
|
|
128
|
-
// resolves `null`, so there is no row to announce.
|
|
195
|
+
// The pool write. Never rejects: a failed write is counted and logged with
|
|
196
|
+
// the whole row, and resolves `null`, so there is no row to announce.
|
|
129
197
|
const write = async (input) => {
|
|
130
198
|
try {
|
|
131
199
|
return await query_audit_log({ db }, input, audit_log_config);
|
|
132
200
|
}
|
|
133
201
|
catch (err) {
|
|
134
202
|
audit_write_failures++;
|
|
135
|
-
log.error(
|
|
203
|
+
log.error(`audit row dropped: ${JSON.stringify(to_dropped_audit_row(input, audit_log_config))} error: ${to_error_message(err)}`);
|
|
136
204
|
return null;
|
|
137
205
|
}
|
|
138
206
|
};
|
|
139
|
-
const
|
|
207
|
+
const write_and_notify = async (input) => {
|
|
140
208
|
const event = await write(input);
|
|
141
209
|
if (event)
|
|
142
210
|
notify(event);
|
|
@@ -167,15 +235,24 @@ export const create_audit_emitter = (options) => {
|
|
|
167
235
|
}
|
|
168
236
|
};
|
|
169
237
|
const is_tracking_inflight = () => inflight !== null;
|
|
170
|
-
const
|
|
238
|
+
const emit_pool = (input) => track(write_and_notify(input));
|
|
239
|
+
// The routing — see the module doc, "Where a row is written".
|
|
240
|
+
const base_emit = async (ctx, input) => {
|
|
171
241
|
if (input.outcome === 'failure') {
|
|
172
242
|
// an attempt happened whether or not the transaction commits
|
|
173
|
-
ctx.pending_effects.push(
|
|
243
|
+
ctx.pending_effects.push(emit_pool(input));
|
|
174
244
|
return;
|
|
175
245
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
246
|
+
if (ctx.db.in_transaction) {
|
|
247
|
+
// Written in the request's transaction, so it commits or rolls back
|
|
248
|
+
// with the change it reports; a throw here fails the handler. The
|
|
249
|
+
// fan-out waits for the commit and is discarded on rollback.
|
|
250
|
+
const event = await query_audit_log({ db: ctx.db }, input, audit_log_config);
|
|
251
|
+
emit_after_commit(ctx, () => notify(event));
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
// No transaction to join: written on the pool now, announced once the
|
|
255
|
+
// handler has returned — and not at all if it throws.
|
|
179
256
|
const written = track(write(input));
|
|
180
257
|
ctx.pending_effects.push(written.then(() => undefined));
|
|
181
258
|
emit_after_commit(ctx, async () => {
|
|
@@ -189,18 +266,16 @@ export const create_audit_emitter = (options) => {
|
|
|
189
266
|
// route through any `emit_decorator` the caller supplied. Production
|
|
190
267
|
// passes no decorator, so this collapses to `base_emit`.
|
|
191
268
|
const emit = emit_decorator ? emit_decorator(base_emit) : base_emit;
|
|
192
|
-
const emit_role_grant_target = (ctx, auth, input) => {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
});
|
|
203
|
-
};
|
|
269
|
+
const emit_role_grant_target = (ctx, auth, input) => emit(ctx, {
|
|
270
|
+
event_type: input.event_type,
|
|
271
|
+
actor_id: auth.actor.id,
|
|
272
|
+
account_id: auth.account.id,
|
|
273
|
+
outcome: input.outcome,
|
|
274
|
+
target_account_id: input.target_account_id,
|
|
275
|
+
target_actor_id: input.target_actor_id,
|
|
276
|
+
ip: ctx.client_ip,
|
|
277
|
+
metadata: input.metadata
|
|
278
|
+
});
|
|
204
279
|
const add_listener = (listener) => {
|
|
205
280
|
const entry = { listener };
|
|
206
281
|
listeners.push(entry);
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Audit log database queries.
|
|
3
3
|
*
|
|
4
4
|
* Records and retrieves auth mutation events for security monitoring. The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* the
|
|
10
|
-
*
|
|
5
|
+
* request entry point is `AppDeps.audit.emit(ctx, input)` (see
|
|
6
|
+
* `auth/audit_emitter.ts`). It writes a success row in the request
|
|
7
|
+
* transaction and a failure row on the pool it closes over, so an attempt's
|
|
8
|
+
* row persists when the request transaction rolls back. This module only
|
|
9
|
+
* exposes the `query_*` primitives and the drift counters. The bound emitter
|
|
10
|
+
* writes through `query_audit_log`.
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
@@ -49,10 +49,9 @@ export declare const reset_audit_unknown_event_type_failures: () => void;
|
|
|
49
49
|
* `create_audit_log_config({extra_events})`.
|
|
50
50
|
*
|
|
51
51
|
* In-transaction call site for query helpers that must atomically write the
|
|
52
|
-
* row alongside other mutations (e.g. `query_accept_offer`).
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* rolls back.
|
|
52
|
+
* row alongside other mutations (e.g. `query_accept_offer`). Request handlers
|
|
53
|
+
* reach for `AppDeps.audit.emit` instead, which picks the transaction or the
|
|
54
|
+
* pool by outcome.
|
|
56
55
|
*
|
|
57
56
|
* @param deps - query dependencies
|
|
58
57
|
* @param input - the audit event to record
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC9B,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,mJAYyB,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,cAAc,8DAA4D,CAAC;AAaxF,iFAAiF;AACjF,eAAO,MAAM,sCAAsC,QAAO,MACvB,CAAC;AAEpC,0CAA0C;AAC1C,eAAO,MAAM,wCAAwC,QAAO,IAE3D,CAAC;AAYF,gFAAgF;AAChF,eAAO,MAAM,qCAAqC,QAAO,MACvB,CAAC;AAEnC,0CAA0C;AAC1C,eAAO,MAAM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ACH,eAAO,MAAM,uCAAuC,GACnD,MAAM,SAAS,EACf,cAA+B,EAC/B,eAAU,KACR,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAmB1C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,GAC1C,MAAM,SAAS,EACf,QAAQ,IAAI,KACV,OAAO,CAAC,MAAM,CAMhB,CAAC"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Audit log database queries.
|
|
3
3
|
*
|
|
4
4
|
* Records and retrieves auth mutation events for security monitoring. The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* the
|
|
10
|
-
*
|
|
5
|
+
* request entry point is `AppDeps.audit.emit(ctx, input)` (see
|
|
6
|
+
* `auth/audit_emitter.ts`). It writes a success row in the request
|
|
7
|
+
* transaction and a failure row on the pool it closes over, so an attempt's
|
|
8
|
+
* row persists when the request transaction rolls back. This module only
|
|
9
|
+
* exposes the `query_*` primitives and the drift counters. The bound emitter
|
|
10
|
+
* writes through `query_audit_log`.
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
@@ -85,10 +85,9 @@ export const reset_audit_unknown_event_type_failures = () => {
|
|
|
85
85
|
* `create_audit_log_config({extra_events})`.
|
|
86
86
|
*
|
|
87
87
|
* In-transaction call site for query helpers that must atomically write the
|
|
88
|
-
* row alongside other mutations (e.g. `query_accept_offer`).
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* rolls back.
|
|
88
|
+
* row alongside other mutations (e.g. `query_accept_offer`). Request handlers
|
|
89
|
+
* reach for `AppDeps.audit.emit` instead, which picks the transaction or the
|
|
90
|
+
* pool by outcome.
|
|
92
91
|
*
|
|
93
92
|
* @param deps - query dependencies
|
|
94
93
|
* @param input - the audit event to record
|
|
@@ -193,6 +192,10 @@ export const query_audit_log_list_with_usernames = async (deps, options) => {
|
|
|
193
192
|
conditions.push(`al.outcome = $${param_index++}`);
|
|
194
193
|
params.push(options.outcome);
|
|
195
194
|
}
|
|
195
|
+
// TODO: `seq` is assigned at INSERT and an in-transaction row commits later,
|
|
196
|
+
// so a strict `seq >` cursor can miss a row that commits while the stream is
|
|
197
|
+
// down — anchor the gap fill at the cursor minus a margin, or on `created_at`,
|
|
198
|
+
// and de-dupe by `id` (the UI already does)
|
|
196
199
|
if (options?.since_seq != null) {
|
|
197
200
|
conditions.push(`al.seq > $${param_index++}`);
|
|
198
201
|
params.push(options.since_seq);
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { UnreachableError } from '@fuzdev/fuz_util/error.ts';
|
|
15
15
|
import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS } from '../http/error_schemas.js';
|
|
16
|
-
import {
|
|
16
|
+
import { has_test_context_preset } from '../hono_context.js';
|
|
17
17
|
import { create_audit_log_route_shape, DEFAULT_AUDIT_STREAM_ROLE } from './audit_log_route_schema.js';
|
|
18
18
|
import { create_sse_response } from '../realtime/sse.js';
|
|
19
19
|
import { validate_sse_keep_alive_ms } from '../realtime/sse_constants.js';
|
|
@@ -113,7 +113,7 @@ export const create_audit_log_route_specs = (options) => {
|
|
|
113
113
|
// pre-baked context has no rows behind it to re-read, and for a
|
|
114
114
|
// registration born closed by the shutdown, which admission
|
|
115
115
|
// refuses whatever they answer.
|
|
116
|
-
if (!c
|
|
116
|
+
if (!has_test_context_preset(c) && !registry.closing) {
|
|
117
117
|
const reread = async () => {
|
|
118
118
|
// Global grants only, like the `require_role` gate that ran in
|
|
119
119
|
// the pipeline — a scoped grant must not open the instance-wide
|
|
@@ -467,7 +467,12 @@ export interface AuditLogListOptions {
|
|
|
467
467
|
event_type_in?: Array<string>;
|
|
468
468
|
account_id?: Uuid;
|
|
469
469
|
outcome?: AuditOutcome;
|
|
470
|
-
/**
|
|
470
|
+
/**
|
|
471
|
+
* When set, only return events with `seq` greater than this value. Enables
|
|
472
|
+
* SSE reconnection gap fill. `seq` is assigned at INSERT; an in-transaction
|
|
473
|
+
* row commits later, so a row can become visible after a higher `seq` — a
|
|
474
|
+
* gap fill can miss one that commits while the stream is down.
|
|
475
|
+
*/
|
|
471
476
|
since_seq?: number;
|
|
472
477
|
}
|
|
473
478
|
/**
|
|
@@ -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;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAS,MAAM,yBAAyB,CAAC;AAkBtD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,6iBA6BnB,CAAC;AAEZ,wCAAwC;AACxC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA4B,CAAC;AACxD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,eAAe,CAAC,CA8BzF,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,eAG/C,CAAC;AAEX;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB,GACrC,OAAO,aAAa,KAClB;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAQvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAA+B,CAAC;AAExE,0DAA0D;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C,CAAC;CAC1D;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,GAAI,UAAU,2BAA2B,KAAG,cA6B/E,CAAC;AAEF,gDAAgD;AAChD,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;kBAY5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,+DAA+D;AAC/D,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;kBAGzC,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAE5F,wEAAwE;AACxE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;kBAGpC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,uFAAuF;AACvF,eAAO,MAAM,gBAAgB;;;;;;kBAE3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -70,9 +70,10 @@ export interface BootstrapAccountDeps {
|
|
|
70
70
|
* The fewest bytes a bootstrap token holds, counted after its one optional
|
|
71
71
|
* trailing LF. A shorter file is read as unreadable: an empty or `"\n"` file
|
|
72
72
|
* would otherwise leave bootstrap advertised as open while nothing can ever
|
|
73
|
-
* match it, and a short token is guessable. Every generator writes
|
|
74
|
-
*
|
|
75
|
-
* `BOOTSTRAP_TOKEN_MIN_BYTES`
|
|
73
|
+
* match it, and a short token is guessable. Every generator writes more
|
|
74
|
+
* (32 random bytes as 64 lowercase hex characters); the readers accept any
|
|
75
|
+
* bytes that clear this floor. Twin of the Rust `BOOTSTRAP_TOKEN_MIN_BYTES`
|
|
76
|
+
* (`fuz_auth`).
|
|
76
77
|
*/
|
|
77
78
|
export declare const BOOTSTRAP_TOKEN_MIN_BYTES = 32;
|
|
78
79
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap_account.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/bootstrap_account.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACN,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,gDAAgD;AAChD,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,6DAA6D;AAC7D,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,IAAI,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE;QAAE,MAAM,EAAE,SAAS,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAA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D,qBAAqB;IACrB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,6EAA6E;IAC7E,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;IAClD,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;CACZ;AAcD;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,IAAI,CAAC,oBAAoB,EAAE,kBAAkB,GAAG,KAAK,CAAC,EAC5D,YAAY,MAAM,KAChB,OAAO,CAAC,UAAU,CAQpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB,GAC7B,MAAM,oBAAoB,EAC1B,gBAAgB,MAAM,EACtB,OAAO,qBAAqB,KAC1B,OAAO,CAAC,sBAAsB,CA8EhC,CAAC"}
|
|
@@ -26,9 +26,10 @@ const strip_one_trailing_newline = (bytes) => bytes.at(-1) === 0x0a ? bytes.suba
|
|
|
26
26
|
* The fewest bytes a bootstrap token holds, counted after its one optional
|
|
27
27
|
* trailing LF. A shorter file is read as unreadable: an empty or `"\n"` file
|
|
28
28
|
* would otherwise leave bootstrap advertised as open while nothing can ever
|
|
29
|
-
* match it, and a short token is guessable. Every generator writes
|
|
30
|
-
*
|
|
31
|
-
* `BOOTSTRAP_TOKEN_MIN_BYTES`
|
|
29
|
+
* match it, and a short token is guessable. Every generator writes more
|
|
30
|
+
* (32 random bytes as 64 lowercase hex characters); the readers accept any
|
|
31
|
+
* bytes that clear this floor. Twin of the Rust `BOOTSTRAP_TOKEN_MIN_BYTES`
|
|
32
|
+
* (`fuz_auth`).
|
|
32
33
|
*/
|
|
33
34
|
export const BOOTSTRAP_TOKEN_MIN_BYTES = 32;
|
|
34
35
|
/**
|
|
@@ -114,7 +114,7 @@ export const create_bootstrap_route_specs = (deps, options) => {
|
|
|
114
114
|
if (result.error === ERROR_TOKEN_FILE_MISSING)
|
|
115
115
|
bootstrap_status.available = false;
|
|
116
116
|
ip_reserved.reservation.record();
|
|
117
|
-
deps.audit.emit(route, {
|
|
117
|
+
await deps.audit.emit(route, {
|
|
118
118
|
event_type: 'bootstrap',
|
|
119
119
|
outcome: 'failure',
|
|
120
120
|
ip: get_client_ip(c),
|
|
@@ -147,7 +147,7 @@ export const create_bootstrap_route_specs = (deps, options) => {
|
|
|
147
147
|
deps.log.error(`on_bootstrap callback failed: ${to_error_message(err)}`);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
deps.audit.emit(route, {
|
|
150
|
+
await deps.audit.emit(route, {
|
|
151
151
|
event_type: 'bootstrap',
|
|
152
152
|
actor_id: result.actor.id,
|
|
153
153
|
account_id: result.account.id,
|
|
@@ -83,7 +83,8 @@ export declare const require_manageable_cell: (deps: QueryDeps, auth: RequestAct
|
|
|
83
83
|
* @param auth - the caller
|
|
84
84
|
* @param event_type - the cell event
|
|
85
85
|
* @param metadata - the event's metadata envelope
|
|
86
|
-
* @mutates `audit_log` table - inserts the row through `audit.emit
|
|
86
|
+
* @mutates `audit_log` table - inserts the row through `audit.emit`, in the request transaction
|
|
87
|
+
* @throws Error when the in-transaction INSERT fails, failing the handler
|
|
87
88
|
*/
|
|
88
|
-
export declare const emit_cell_audit: <T extends string>(ctx: ActionContext | ActionActorContext, audit: AuditEmitter, auth: RequestActorContext, event_type: T, metadata: AuditLogInput<T>["metadata"]) => void
|
|
89
|
+
export declare const emit_cell_audit: <T extends string>(ctx: ActionContext | ActionActorContext, audit: AuditEmitter, auth: RequestActorContext, event_type: T, metadata: AuditLogInput<T>["metadata"]) => Promise<void>;
|
|
89
90
|
//# sourceMappingURL=cell_action_helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell_action_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_action_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAO,UAAU,CAAC,OAAO,cAAc,CAAC,SAAS,CACf,CAAC;AAyBpE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,SAAS,EACf,MAAM,cAAc,GAAG,IAAI,EAC3B,SAAS,IAAI,KACX,OAAO,CAAC,OAAO,CAA8D,CAAC;AAEjF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,SAAS,EACf,MAAM,mBAAmB,EACzB,SAAS,IAAI,KACX,OAAO,CAAC,OAAO,CAA8D,CAAC;AAEjF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,SAAS,EACf,MAAM,mBAAmB,EACzB,SAAS,IAAI,KACX,OAAO,CAAC,OAAO,CAIjB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"cell_action_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_action_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,kB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I,CAOZ,CAAC"}
|
|
@@ -100,14 +100,13 @@ export const require_manageable_cell = async (deps, auth, cell_id) => {
|
|
|
100
100
|
* @param auth - the caller
|
|
101
101
|
* @param event_type - the cell event
|
|
102
102
|
* @param metadata - the event's metadata envelope
|
|
103
|
-
* @mutates `audit_log` table - inserts the row through `audit.emit
|
|
103
|
+
* @mutates `audit_log` table - inserts the row through `audit.emit`, in the request transaction
|
|
104
|
+
* @throws Error when the in-transaction INSERT fails, failing the handler
|
|
104
105
|
*/
|
|
105
|
-
export const emit_cell_audit = (ctx, audit, auth, event_type, metadata) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
113
|
-
};
|
|
106
|
+
export const emit_cell_audit = (ctx, audit, auth, event_type, metadata) => audit.emit(ctx, {
|
|
107
|
+
event_type,
|
|
108
|
+
actor_id: auth.actor.id,
|
|
109
|
+
account_id: auth.account.id,
|
|
110
|
+
ip: ctx.client_ip,
|
|
111
|
+
metadata
|
|
112
|
+
});
|
|
@@ -336,7 +336,7 @@ export const create_cell_actions = (deps) => {
|
|
|
336
336
|
throw path_taken_error();
|
|
337
337
|
throw err;
|
|
338
338
|
}
|
|
339
|
-
emit_cell_audit(ctx, deps.audit, auth, 'cell_create', cell_mutation_metadata(row));
|
|
339
|
+
await emit_cell_audit(ctx, deps.audit, auth, 'cell_create', cell_mutation_metadata(row));
|
|
340
340
|
return { cell: to_cell_json(row) };
|
|
341
341
|
};
|
|
342
342
|
const get_handler = async (input, ctx) => {
|
|
@@ -463,7 +463,7 @@ export const create_cell_actions = (deps) => {
|
|
|
463
463
|
// Raced with a deleter between the visibility check and the UPDATE.
|
|
464
464
|
throw cell_not_found_error();
|
|
465
465
|
}
|
|
466
|
-
emit_cell_audit(ctx, deps.audit, auth, 'cell_update', cell_mutation_metadata(updated));
|
|
466
|
+
await emit_cell_audit(ctx, deps.audit, auth, 'cell_update', cell_mutation_metadata(updated));
|
|
467
467
|
return { cell: to_cell_json(updated) };
|
|
468
468
|
};
|
|
469
469
|
const delete_handler = async (input, ctx) => {
|
|
@@ -476,7 +476,7 @@ export const create_cell_actions = (deps) => {
|
|
|
476
476
|
// Raced with another deleter.
|
|
477
477
|
throw cell_not_found_error();
|
|
478
478
|
}
|
|
479
|
-
emit_cell_audit(ctx, deps.audit, auth, 'cell_delete', cell_mutation_metadata(existing));
|
|
479
|
+
await emit_cell_audit(ctx, deps.audit, auth, 'cell_delete', cell_mutation_metadata(existing));
|
|
480
480
|
return { ok: true, deleted: true };
|
|
481
481
|
};
|
|
482
482
|
const moderate_handler = async (input, ctx) => {
|
|
@@ -515,7 +515,7 @@ export const create_cell_actions = (deps) => {
|
|
|
515
515
|
throw cell_not_pending_error();
|
|
516
516
|
throw cell_not_found_error();
|
|
517
517
|
}
|
|
518
|
-
emit_cell_audit(ctx, deps.audit, auth, 'cell_moderate', {
|
|
518
|
+
await emit_cell_audit(ctx, deps.audit, auth, 'cell_moderate', {
|
|
519
519
|
cell_id: updated.id,
|
|
520
520
|
root_id: existing.root_id,
|
|
521
521
|
moderation: input.moderation
|
|
@@ -550,7 +550,7 @@ export const create_cell_actions = (deps) => {
|
|
|
550
550
|
if (!result)
|
|
551
551
|
throw cell_not_found_error();
|
|
552
552
|
const updated = result.cell;
|
|
553
|
-
emit_cell_audit(ctx, deps.audit, auth, 'cell_policy_set', {
|
|
553
|
+
await emit_cell_audit(ctx, deps.audit, auth, 'cell_policy_set', {
|
|
554
554
|
cell_id: updated.id,
|
|
555
555
|
policy: updated.policy,
|
|
556
556
|
// read under the UPDATE's row lock, not from `existing`, which a set
|
|
@@ -746,7 +746,7 @@ export const create_cell_actions = (deps) => {
|
|
|
746
746
|
// `kind` is the source's (not the cloned row's) so the audit trail
|
|
747
747
|
// attributes the clone to the source's shape.
|
|
748
748
|
const cloned_child_count = deep ? cloneable_items.length : 0;
|
|
749
|
-
emit_cell_audit(ctx, deps.audit, auth, 'cell_clone', {
|
|
749
|
+
await emit_cell_audit(ctx, deps.audit, auth, 'cell_clone', {
|
|
750
750
|
source_id: source.id,
|
|
751
751
|
new_id: cloned_root.id,
|
|
752
752
|
deep,
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
* (`cell.visibility`) is likewise a peer column, enforced by `can_view_cell`
|
|
26
26
|
* reading the column directly (no JSON dive).
|
|
27
27
|
*
|
|
28
|
+
* **An own `__proto__` key never reaches this schema.** The dispatcher
|
|
29
|
+
* refuses params holding one at any depth (`ERROR_PARAMS_PROTO_KEY`), so
|
|
30
|
+
* stored `data` carries none — the loose object would drop a top-level one
|
|
31
|
+
* silently and keep a nested one.
|
|
32
|
+
*
|
|
28
33
|
* @module
|
|
29
34
|
*/
|
|
30
35
|
import { z } from 'zod';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell_data_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_data_schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cell_data_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_data_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;;;iBAGnB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC"}
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
* (`cell.visibility`) is likewise a peer column, enforced by `can_view_cell`
|
|
26
26
|
* reading the column directly (no JSON dive).
|
|
27
27
|
*
|
|
28
|
+
* **An own `__proto__` key never reaches this schema.** The dispatcher
|
|
29
|
+
* refuses params holding one at any depth (`ERROR_PARAMS_PROTO_KEY`), so
|
|
30
|
+
* stored `data` carries none — the loose object would drop a top-level one
|
|
31
|
+
* silently and keep a nested one.
|
|
32
|
+
*
|
|
28
33
|
* @module
|
|
29
34
|
*/
|
|
30
35
|
import { z } from 'zod';
|
|
@@ -52,7 +52,7 @@ export const create_cell_field_actions = (deps) => {
|
|
|
52
52
|
name: input.name,
|
|
53
53
|
target_id: input.target_id
|
|
54
54
|
});
|
|
55
|
-
emit_cell_audit(ctx, deps.audit, auth, 'cell_field_set', {
|
|
55
|
+
await emit_cell_audit(ctx, deps.audit, auth, 'cell_field_set', {
|
|
56
56
|
source_id: row.source_id,
|
|
57
57
|
name: row.name,
|
|
58
58
|
target_id: row.target_id
|
|
@@ -64,7 +64,7 @@ export const create_cell_field_actions = (deps) => {
|
|
|
64
64
|
await require_editable_cell(ctx, auth, input.source_id);
|
|
65
65
|
const deleted = await query_cell_field_delete(ctx, input.source_id, input.name);
|
|
66
66
|
if (deleted) {
|
|
67
|
-
emit_cell_audit(ctx, deps.audit, auth, 'cell_field_delete', {
|
|
67
|
+
await emit_cell_audit(ctx, deps.audit, auth, 'cell_field_delete', {
|
|
68
68
|
source_id: deleted.source_id,
|
|
69
69
|
name: deleted.name,
|
|
70
70
|
target_id: deleted.target_id
|