@fuzdev/fuz_app 0.160.0 → 0.162.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/auth/CLAUDE.md +31 -21
- package/dist/auth/account_action_specs.d.ts +173 -35
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +10 -7
- package/dist/auth/account_route_schema.d.ts +293 -46
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +5 -4
- package/dist/auth/account_schema.d.ts +489 -103
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +67 -47
- package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
- package/dist/auth/actor_search_action_specs.d.ts +6 -6
- package/dist/auth/admin_action_specs.d.ts +2748 -505
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +175 -187
- package/dist/auth/app_settings_schema.d.ts +46 -23
- package/dist/auth/app_settings_schema.d.ts.map +1 -1
- package/dist/auth/app_settings_schema.js +12 -15
- package/dist/auth/audit_emitter.d.ts +8 -3
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +32 -9
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +4 -3
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_schema.d.ts +791 -253
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +198 -198
- package/dist/auth/audit_log_schema_fuz.d.ts +53 -0
- package/dist/auth/audit_log_schema_fuz.d.ts.map +1 -0
- package/dist/auth/audit_log_schema_fuz.js +50 -0
- package/dist/auth/credential_type_schema.d.ts +5 -8
- package/dist/auth/credential_type_schema.d.ts.map +1 -1
- package/dist/auth/credential_type_schema.js +6 -10
- package/dist/auth/grant_path_schema.d.ts +4 -7
- package/dist/auth/grant_path_schema.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.js +6 -10
- package/dist/auth/invite_schema.d.ts +98 -26
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +21 -14
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +27 -0
- package/dist/auth/name_schema.d.ts +63 -0
- package/dist/auth/name_schema.d.ts.map +1 -0
- package/dist/auth/name_schema.js +65 -0
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +2 -1
- package/dist/auth/role_grant_offer_action_specs.d.ts +192 -192
- package/dist/auth/role_grant_offer_action_specs.js +2 -2
- package/dist/auth/role_grant_offer_notifications.d.ts +126 -126
- package/dist/auth/role_grant_offer_schema.d.ts +12 -12
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +8 -8
- package/dist/auth/role_schema.d.ts +14 -25
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +15 -29
- package/dist/auth/role_schema_fuz.d.ts +4 -3
- package/dist/auth/role_schema_fuz.d.ts.map +1 -1
- package/dist/auth/role_schema_fuz.js +7 -5
- package/dist/auth/scope_kind_schema.d.ts +13 -26
- package/dist/auth/scope_kind_schema.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema.js +15 -31
- package/dist/auth/scope_kind_schema_fuz.d.ts +4 -3
- package/dist/auth/scope_kind_schema_fuz.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema_fuz.js +7 -5
- package/dist/auth/self_service_role_action_specs.d.ts +2 -2
- package/dist/auth/token_scope.d.ts +7 -13
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +9 -14
- package/dist/dev/setup.d.ts +14 -7
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +11 -6
- package/dist/primitive_schemas.d.ts +47 -4
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +40 -19
- package/dist/primitive_schemas_fuz.d.ts +70 -8
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +62 -7
- package/dist/testing/CLAUDE.md +11 -6
- package/dist/testing/app_server.d.ts +3 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +6 -2
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +12 -13
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +24 -13
- package/dist/testing/cross_backend/role_grant_role_grammar.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_role_grammar.js +8 -15
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +4 -3
- package/dist/testing/db_entities.d.ts +3 -1
- package/dist/testing/db_entities.d.ts.map +1 -1
- package/dist/testing/db_entities.js +4 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +3 -2
- package/dist/zod.d.ts +2 -1
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +6 -2
- package/package.json +1 -1
|
@@ -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.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAgBN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAoB,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA4BtF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB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C,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;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEhE,+EAA+E;AAC/E,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIzC,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAE1F,wFAAwF;AACxF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIpC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAIhF;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Audit log types and client-safe
|
|
2
|
+
* Audit log types and client-safe schemas. The wire rows and the builtin
|
|
3
|
+
* metadata schemas are `@fuzdev/fuz_schema` schemas; the event-type and
|
|
4
|
+
* outcome vocabularies are Zod, with their fuz_schema twins in
|
|
5
|
+
* `auth/audit_log_schema_fuz.ts`.
|
|
3
6
|
*
|
|
4
7
|
* Records auth mutations (login, logout, grant, revoke, etc.) for
|
|
5
8
|
* security monitoring and operational visibility.
|
|
@@ -9,10 +12,18 @@
|
|
|
9
12
|
* @module
|
|
10
13
|
*/
|
|
11
14
|
import { z } from 'zod';
|
|
12
|
-
import {
|
|
15
|
+
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 '../primitive_schemas.js';
|
|
18
|
+
import { Email, Timestamp, Uuid } from '../primitive_schemas_fuz.js';
|
|
19
|
+
import { assert_validation_schema } from '../schema_issues.js';
|
|
13
20
|
import { AuthSessionJson, SessionId } from './account_schema.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
21
|
+
import { API_TOKEN_ID_REGEX } from './api_token.js';
|
|
22
|
+
import { BUILTIN_CREDENTIAL_TYPES } from './credential_type_schema.js';
|
|
23
|
+
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));
|
|
16
27
|
/**
|
|
17
28
|
* Defense-in-depth audit field — records the credential channel
|
|
18
29
|
* (`session` / `api_token` / `daemon_token`) the request arrived on.
|
|
@@ -20,7 +31,7 @@ import { BuiltinCredentialType } from './credential_type_schema.js';
|
|
|
20
31
|
* so forensics survive a future loosening or bypass of the spec gate.
|
|
21
32
|
* See `docs/security.md` §Credential-channel gating.
|
|
22
33
|
*/
|
|
23
|
-
const credential_type_meta =
|
|
34
|
+
const credential_type_meta = meta(optional(one_of(BUILTIN_CREDENTIAL_TYPES)), {
|
|
24
35
|
description: 'Credential channel the request arrived on. Defense in depth — the spec gate restricts to `session`, but the row preserves what actually authenticated the request in case the gate is loosened or bypassed in a future refactor.'
|
|
25
36
|
});
|
|
26
37
|
/**
|
|
@@ -150,107 +161,97 @@ export const to_global_role_revocation = (event) => {
|
|
|
150
161
|
return { account_id, role };
|
|
151
162
|
};
|
|
152
163
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
164
|
+
* Zod schema for valid audit event-type name strings: `AUDIT_EVENT_TYPE_NAME_REGEX`,
|
|
165
|
+
* at most `NAME_LENGTH_MAX` UTF-16 code units. Twin of the Rust spine's
|
|
166
|
+
* `is_valid_audit_event_type_name`.
|
|
156
167
|
*/
|
|
157
|
-
export const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
});
|
|
168
|
+
export const AuditEventTypeName = bounded_string({
|
|
169
|
+
max: NAME_LENGTH_MAX,
|
|
170
|
+
max_message: AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE
|
|
171
|
+
}).regex(AUDIT_EVENT_TYPE_NAME_REGEX, { message: AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE });
|
|
162
172
|
/** Zod schema for audit event outcomes. */
|
|
163
173
|
export const AuditOutcome = z.enum(['success', 'failure']);
|
|
164
174
|
/**
|
|
165
|
-
* Per-event-type metadata
|
|
166
|
-
* add fields while known ones are validated. The record is
|
|
167
|
-
* catch mutation bugs at the key level (e.g. tests that try to swap
|
|
168
|
-
* stub schema);
|
|
169
|
-
* freeze isn't a security boundary.
|
|
175
|
+
* Per-event-type metadata schemas, `@fuzdev/fuz_schema` `loose_object`s so
|
|
176
|
+
* consumers can add fields while known ones are validated. The record is
|
|
177
|
+
* frozen to catch mutation bugs at the key level (e.g. tests that try to swap
|
|
178
|
+
* in a stub schema); freeze isn't a security boundary.
|
|
170
179
|
*/
|
|
171
180
|
export const audit_metadata_schemas = Object.freeze({
|
|
172
|
-
login:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
.nullable(),
|
|
183
|
-
signup: z.looseObject({
|
|
184
|
-
username: z.string().meta({ description: 'Username submitted at signup.' }),
|
|
185
|
-
invite_id: Uuid.optional().meta({
|
|
181
|
+
login: nullable(loose_object({
|
|
182
|
+
username: meta(string, { description: 'Username submitted with the login attempt.' })
|
|
183
|
+
})),
|
|
184
|
+
logout: literal(null),
|
|
185
|
+
bootstrap: nullable(loose_object({
|
|
186
|
+
error: meta(string, { description: 'Error message for a failed bootstrap attempt.' })
|
|
187
|
+
})),
|
|
188
|
+
signup: loose_object({
|
|
189
|
+
username: meta(string, { description: 'Username submitted at signup.' }),
|
|
190
|
+
invite_id: meta(optional(Uuid), {
|
|
186
191
|
description: 'Invite consumed by this signup. Set on success and on `signup_conflict` failure rows when an invite was matched at attempt time.'
|
|
187
192
|
}),
|
|
188
|
-
open_signup:
|
|
193
|
+
open_signup: meta(optional(boolean), {
|
|
189
194
|
description: 'True when the signup occurred via the `open_signup` setting (no invite required). Set on success rows under `open_signup` and on failure rows when the attempt was made under `open_signup`.'
|
|
190
195
|
}),
|
|
191
|
-
reason:
|
|
196
|
+
reason: meta(optional(string), {
|
|
192
197
|
description: 'Failure category: `no_match` (no unclaimed invite matched), `signup_conflict` (username/email already exists, raised by the DB unique constraint), `internal_error` (catch-all for non-classified tx failures — Argon2 fault, session create error, DB outage mid-tx). Set only on `outcome=failure`.'
|
|
193
198
|
}),
|
|
194
|
-
email:
|
|
199
|
+
email: meta(optional(Email), {
|
|
195
200
|
description: 'Email submitted at signup — recorded on failure rows for forensic correlation. Omitted on success rows because the email is already tied to the resulting account.'
|
|
196
201
|
})
|
|
197
202
|
}),
|
|
198
|
-
password_change:
|
|
199
|
-
|
|
200
|
-
sessions_revoked: z.number().optional().meta({
|
|
203
|
+
password_change: nullable(loose_object({
|
|
204
|
+
sessions_revoked: meta(optional(number), {
|
|
201
205
|
description: 'Number of sessions revoked as a side effect of the password change. Present on `outcome=success`.'
|
|
202
206
|
}),
|
|
203
|
-
tokens_revoked:
|
|
207
|
+
tokens_revoked: meta(optional(number), {
|
|
204
208
|
description: 'Number of API tokens revoked as a side effect of the password change. Present on `outcome=success`.'
|
|
205
209
|
}),
|
|
206
|
-
reason:
|
|
210
|
+
reason: meta(optional(literal('concurrent_change')), {
|
|
207
211
|
description: 'Failure category. `concurrent_change` indicates another password change committed first against the same starting hash (verify-write race loser). Absent for typed-wrong-password failures.'
|
|
208
212
|
}),
|
|
209
213
|
credential_type: credential_type_meta
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
session_id: SessionId.meta({
|
|
214
|
+
})),
|
|
215
|
+
session_revoke: loose_object({
|
|
216
|
+
session_id: meta(SessionId, {
|
|
214
217
|
description: 'Blake3 hash identifying the revoked session row.'
|
|
215
218
|
}),
|
|
216
219
|
credential_type: credential_type_meta
|
|
217
220
|
}),
|
|
218
|
-
session_revoke_all:
|
|
221
|
+
session_revoke_all: loose_object({
|
|
219
222
|
// Omitted on `outcome='failure'` (no revocation attempted — e.g. target
|
|
220
223
|
// account not found); `reason` carries the failure category, and
|
|
221
224
|
// `attempted_account_id` preserves the probed id (the `target_account_id`
|
|
222
225
|
// column is null in that case because it's a FK to `account`).
|
|
223
|
-
count:
|
|
226
|
+
count: meta(optional(number), {
|
|
224
227
|
description: 'Number of sessions revoked. Omitted on `outcome=failure` because no revocation was attempted.'
|
|
225
228
|
}),
|
|
226
|
-
reason:
|
|
227
|
-
.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
attempted_account_id: Uuid.optional().meta({
|
|
229
|
+
reason: meta(optional(string), {
|
|
230
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
231
|
+
}),
|
|
232
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
231
233
|
description: 'Probed account id when the target lookup missed (FK constraint forces `target_account_id` to null).'
|
|
232
234
|
}),
|
|
233
235
|
credential_type: credential_type_meta
|
|
234
236
|
}),
|
|
235
|
-
token_create:
|
|
236
|
-
token_id:
|
|
237
|
-
name:
|
|
237
|
+
token_create: loose_object({
|
|
238
|
+
token_id: meta(TokenId, { description: 'Public id of the created API token (`tok_…`).' }),
|
|
239
|
+
name: meta(string, { description: 'Operator-supplied label for the token.' }),
|
|
238
240
|
credential_type: credential_type_meta
|
|
239
241
|
}),
|
|
240
|
-
token_revoke:
|
|
241
|
-
token_id:
|
|
242
|
+
token_revoke: loose_object({
|
|
243
|
+
token_id: meta(TokenId, { description: 'Public id of the revoked API token (`tok_…`).' }),
|
|
242
244
|
credential_type: credential_type_meta
|
|
243
245
|
}),
|
|
244
|
-
token_revoke_all:
|
|
246
|
+
token_revoke_all: loose_object({
|
|
245
247
|
// Same shape as `session_revoke_all` for failures.
|
|
246
|
-
count:
|
|
248
|
+
count: meta(optional(number), {
|
|
247
249
|
description: 'Number of tokens revoked. Omitted on `outcome=failure` because no revocation was attempted.'
|
|
248
250
|
}),
|
|
249
|
-
reason:
|
|
250
|
-
.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
attempted_account_id: Uuid.optional().meta({
|
|
251
|
+
reason: meta(optional(string), {
|
|
252
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
253
|
+
}),
|
|
254
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
254
255
|
description: 'Probed account id when the target lookup missed (FK constraint forces `target_account_id` to null).'
|
|
255
256
|
})
|
|
256
257
|
}),
|
|
@@ -258,91 +259,89 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
258
259
|
// (e.g. admin-grant-path denied) never produce a role_grant row.
|
|
259
260
|
// `self_service: true` is set by the self-service role toggle in
|
|
260
261
|
// `self_service_role_actions.ts` — declared explicitly rather than
|
|
261
|
-
// riding on `
|
|
262
|
+
// riding on `loose_object` permissiveness so the field is part of
|
|
262
263
|
// the documented schema surface.
|
|
263
|
-
role_grant_create:
|
|
264
|
-
role:
|
|
265
|
-
role_grant_id:
|
|
264
|
+
role_grant_create: loose_object({
|
|
265
|
+
role: meta(string, { description: 'Role being granted.' }),
|
|
266
|
+
role_grant_id: meta(optional(Uuid), {
|
|
266
267
|
description: 'Id of the resulting role_grant row. Omitted when the grant failed (e.g. admin-grant-path denial).'
|
|
267
268
|
}),
|
|
268
|
-
scope_kind:
|
|
269
|
+
scope_kind: meta(optional(nullable(string)), {
|
|
269
270
|
description: 'Kind tag paired with `scope_id` on a `role_grant_assign` row; null for a global grant.'
|
|
270
271
|
}),
|
|
271
|
-
scope_id: Uuid
|
|
272
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
272
273
|
description: 'Scope of the granted role_grant; null for global role_grants.'
|
|
273
274
|
}),
|
|
274
|
-
source_offer_id:
|
|
275
|
+
source_offer_id: meta(optional(Uuid), {
|
|
275
276
|
description: 'Offer this grant resolved, when the grant originated from an accepted offer.'
|
|
276
277
|
}),
|
|
277
|
-
self_service:
|
|
278
|
+
self_service: meta(optional(boolean), {
|
|
278
279
|
description: 'True when the grant came from the self-service role toggle.'
|
|
279
280
|
})
|
|
280
281
|
}),
|
|
281
|
-
role_grant_revoke:
|
|
282
|
-
role:
|
|
283
|
-
role_grant_id:
|
|
284
|
-
scope_id: Uuid
|
|
282
|
+
role_grant_revoke: loose_object({
|
|
283
|
+
role: meta(string, { description: 'Role being revoked.' }),
|
|
284
|
+
role_grant_id: meta(Uuid, { description: 'Id of the revoked role_grant row.' }),
|
|
285
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
285
286
|
description: 'Scope of the revoked role_grant; null for global role_grants.'
|
|
286
287
|
}),
|
|
287
|
-
reason:
|
|
288
|
-
.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
self_service: z.boolean().optional().meta({
|
|
288
|
+
reason: meta(optional(string), {
|
|
289
|
+
description: 'Optional admin-supplied or self-service reason text.'
|
|
290
|
+
}),
|
|
291
|
+
self_service: meta(optional(boolean), {
|
|
292
292
|
description: 'True when the revoke came from the self-service role toggle.'
|
|
293
293
|
})
|
|
294
294
|
}),
|
|
295
295
|
// `offer_id` is optional because failed creates (e.g. admin-grant-path
|
|
296
296
|
// denied, `authorize` callback denied) never produce an offer row.
|
|
297
|
-
role_grant_offer_create:
|
|
298
|
-
offer_id:
|
|
297
|
+
role_grant_offer_create: loose_object({
|
|
298
|
+
offer_id: meta(optional(Uuid), {
|
|
299
299
|
description: 'Id of the created offer row. Omitted when the create failed before insert.'
|
|
300
300
|
}),
|
|
301
|
-
role:
|
|
302
|
-
scope_id: Uuid
|
|
301
|
+
role: meta(string, { description: 'Role being offered.' }),
|
|
302
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
303
303
|
description: 'Scope of the offered role; null for global offers.'
|
|
304
304
|
}),
|
|
305
|
-
to_account_id:
|
|
305
|
+
to_account_id: meta(Uuid, { description: 'Account the offer is directed to.' })
|
|
306
306
|
}),
|
|
307
307
|
// `role_grant_create` is emitted alongside on accept — two events per accept by
|
|
308
308
|
// design: offer-lifecycle audit + role-grant-lifecycle audit. A refused
|
|
309
309
|
// accept (a builtin-role offer that must not mint) is an `outcome=failure`
|
|
310
310
|
// row with no `role_grant_id` (nothing was minted) and the wire `reason`.
|
|
311
|
-
role_grant_offer_accept:
|
|
312
|
-
offer_id:
|
|
313
|
-
role_grant_id:
|
|
311
|
+
role_grant_offer_accept: loose_object({
|
|
312
|
+
offer_id: meta(Uuid, { description: 'Id of the accepted (or refused) offer.' }),
|
|
313
|
+
role_grant_id: meta(optional(Uuid), {
|
|
314
314
|
description: 'Id of the resulting role_grant row. Omitted on `outcome=failure` because no grant was minted.'
|
|
315
315
|
}),
|
|
316
|
-
role:
|
|
317
|
-
scope_id: Uuid
|
|
316
|
+
role: meta(string, { description: 'Role granted by the offer.' }),
|
|
317
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
318
318
|
description: 'Scope of the resulting role_grant; null for global role_grants.'
|
|
319
319
|
}),
|
|
320
|
-
reason:
|
|
320
|
+
reason: meta(optional(string), {
|
|
321
321
|
description: 'Wire error reason of a refused accept. Set only on `outcome=failure`.'
|
|
322
322
|
})
|
|
323
323
|
}),
|
|
324
|
-
role_grant_offer_decline:
|
|
325
|
-
offer_id:
|
|
326
|
-
role:
|
|
327
|
-
scope_id: Uuid
|
|
324
|
+
role_grant_offer_decline: loose_object({
|
|
325
|
+
offer_id: meta(Uuid, { description: 'Id of the declined offer.' }),
|
|
326
|
+
role: meta(string, { description: 'Role that was offered.' }),
|
|
327
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
328
328
|
description: 'Scope of the offered role; null for global offers.'
|
|
329
329
|
}),
|
|
330
|
-
reason:
|
|
331
|
-
.
|
|
332
|
-
|
|
333
|
-
.meta({ description: 'Optional decline reason text from the recipient.' })
|
|
330
|
+
reason: meta(optional(string), {
|
|
331
|
+
description: 'Optional decline reason text from the recipient.'
|
|
332
|
+
})
|
|
334
333
|
}),
|
|
335
|
-
role_grant_offer_retract:
|
|
336
|
-
offer_id:
|
|
337
|
-
role:
|
|
338
|
-
scope_id: Uuid
|
|
334
|
+
role_grant_offer_retract: loose_object({
|
|
335
|
+
offer_id: meta(Uuid, { description: 'Id of the retracted offer.' }),
|
|
336
|
+
role: meta(string, { description: 'Role that was offered.' }),
|
|
337
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
339
338
|
description: 'Scope of the offered role; null for global offers.'
|
|
340
339
|
})
|
|
341
340
|
}),
|
|
342
|
-
role_grant_offer_expire:
|
|
343
|
-
offer_id:
|
|
344
|
-
role:
|
|
345
|
-
scope_id: Uuid
|
|
341
|
+
role_grant_offer_expire: loose_object({
|
|
342
|
+
offer_id: meta(Uuid, { description: 'Id of the expired offer.' }),
|
|
343
|
+
role: meta(string, { description: 'Role that was offered.' }),
|
|
344
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
346
345
|
description: 'Scope of the offered role; null for global offers.'
|
|
347
346
|
})
|
|
348
347
|
}),
|
|
@@ -352,28 +351,26 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
352
351
|
// — the recipient's grant of the offered role, or a grant of the grantor's),
|
|
353
352
|
// the destroyed parent scope row (for `scope_destroyed`), or the grantor's
|
|
354
353
|
// removed account (for `account_deleted`).
|
|
355
|
-
role_grant_offer_supersede:
|
|
356
|
-
offer_id:
|
|
357
|
-
role:
|
|
358
|
-
scope_id: Uuid
|
|
354
|
+
role_grant_offer_supersede: loose_object({
|
|
355
|
+
offer_id: meta(Uuid, { description: 'Id of the superseded offer.' }),
|
|
356
|
+
role: meta(string, { description: 'Role that was offered.' }),
|
|
357
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
359
358
|
description: 'Scope of the offered role; null for global offers.'
|
|
360
359
|
}),
|
|
361
|
-
reason:
|
|
362
|
-
.enum(['sibling_accepted', 'role_grant_revoked', 'scope_destroyed', 'account_deleted'])
|
|
363
|
-
.meta({
|
|
360
|
+
reason: meta(one_of(['sibling_accepted', 'role_grant_revoked', 'scope_destroyed', 'account_deleted']), {
|
|
364
361
|
description: "Trigger that obsoleted the offer: a sibling offer was accepted, the resulting role_grant or one of the grantor's was revoked, the parent scope row was destroyed, or the grantor's account was deleted or purged."
|
|
365
362
|
}),
|
|
366
|
-
cause_id:
|
|
363
|
+
cause_id: meta(Uuid, {
|
|
367
364
|
description: "Row that caused the supersede: accepted offer (`sibling_accepted`), revoked role_grant (`role_grant_revoked`), destroyed parent scope row (`scope_destroyed`), or the grantor's account (`account_deleted`)."
|
|
368
365
|
})
|
|
369
366
|
}),
|
|
370
|
-
invite_create:
|
|
371
|
-
invite_id:
|
|
372
|
-
email:
|
|
373
|
-
username:
|
|
367
|
+
invite_create: loose_object({
|
|
368
|
+
invite_id: meta(Uuid, { description: 'Id of the created invite.' }),
|
|
369
|
+
email: meta(nullable(string), { description: 'Invited email address; null when not set.' }),
|
|
370
|
+
username: meta(nullable(string), { description: 'Invited username; null when not set.' })
|
|
374
371
|
}),
|
|
375
|
-
invite_delete:
|
|
376
|
-
invite_id:
|
|
372
|
+
invite_delete: loose_object({
|
|
373
|
+
invite_id: meta(Uuid, { description: 'Id of the deleted invite.' })
|
|
377
374
|
}),
|
|
378
375
|
// Account/actor deletion snapshots identity into metadata so the
|
|
379
376
|
// identity behind a now-orphaned audit id survives a purge (the
|
|
@@ -383,33 +380,27 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
383
380
|
// snapshot and the not-found failure shape (`reason` /
|
|
384
381
|
// `attempted_account_id`). See `auth/CLAUDE.md` §Account/actor deletion
|
|
385
382
|
// (delete = soft, purge = hard).
|
|
386
|
-
account_delete:
|
|
387
|
-
username:
|
|
388
|
-
email:
|
|
389
|
-
.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
.optional()
|
|
396
|
-
.meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
|
|
397
|
-
attempted_account_id: Uuid.optional().meta({
|
|
383
|
+
account_delete: loose_object({
|
|
384
|
+
username: meta(optional(string), { description: 'Username at soft-delete time.' }),
|
|
385
|
+
email: meta(optional(nullable(string)), {
|
|
386
|
+
description: 'Email at soft-delete time; null when unset.'
|
|
387
|
+
}),
|
|
388
|
+
reason: meta(optional(string), {
|
|
389
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
390
|
+
}),
|
|
391
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
398
392
|
description: 'Probed account id when the target was missing (`outcome=failure`).'
|
|
399
393
|
})
|
|
400
394
|
}),
|
|
401
|
-
account_purge:
|
|
402
|
-
username:
|
|
403
|
-
email:
|
|
404
|
-
.
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
.optional()
|
|
411
|
-
.meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
|
|
412
|
-
attempted_account_id: Uuid.optional().meta({
|
|
395
|
+
account_purge: loose_object({
|
|
396
|
+
username: meta(optional(string), { description: 'Username at purge time.' }),
|
|
397
|
+
email: meta(optional(nullable(string)), {
|
|
398
|
+
description: 'Email at purge time; null when unset.'
|
|
399
|
+
}),
|
|
400
|
+
reason: meta(optional(string), {
|
|
401
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
402
|
+
}),
|
|
403
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
413
404
|
description: 'Probed account id when the target was missing (`outcome=failure`).'
|
|
414
405
|
})
|
|
415
406
|
}),
|
|
@@ -418,46 +409,43 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
418
409
|
// the delete events so reviewers see who was reactivated; `reason` /
|
|
419
410
|
// `attempted_account_id` carry the not-found failure shape. Admin-only —
|
|
420
411
|
// the self path is unreachable (a tombstoned account can't authenticate).
|
|
421
|
-
account_undelete:
|
|
422
|
-
username:
|
|
423
|
-
email:
|
|
424
|
-
.
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
.optional()
|
|
431
|
-
.meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
|
|
432
|
-
attempted_account_id: Uuid.optional().meta({
|
|
412
|
+
account_undelete: loose_object({
|
|
413
|
+
username: meta(optional(string), { description: 'Username at reactivation time.' }),
|
|
414
|
+
email: meta(optional(nullable(string)), {
|
|
415
|
+
description: 'Email at reactivation time; null when unset.'
|
|
416
|
+
}),
|
|
417
|
+
reason: meta(optional(string), {
|
|
418
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
419
|
+
}),
|
|
420
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
433
421
|
description: 'Probed account id when the target was missing/not-deleted (`outcome=failure`).'
|
|
434
422
|
})
|
|
435
423
|
}),
|
|
436
|
-
actor_delete:
|
|
437
|
-
name:
|
|
424
|
+
actor_delete: loose_object({
|
|
425
|
+
name: meta(optional(string), { description: 'Actor display name at soft-delete time.' })
|
|
438
426
|
}),
|
|
439
|
-
actor_purge:
|
|
440
|
-
name:
|
|
427
|
+
actor_purge: loose_object({
|
|
428
|
+
name: meta(optional(string), { description: 'Actor display name at purge time.' })
|
|
441
429
|
}),
|
|
442
|
-
actor_undelete:
|
|
443
|
-
name:
|
|
430
|
+
actor_undelete: loose_object({
|
|
431
|
+
name: meta(optional(string), { description: 'Actor display name at reactivation time.' })
|
|
444
432
|
}),
|
|
445
|
-
app_settings_update:
|
|
446
|
-
setting:
|
|
447
|
-
old_value:
|
|
448
|
-
new_value:
|
|
433
|
+
app_settings_update: loose_object({
|
|
434
|
+
setting: meta(string, { description: 'Name of the setting that changed.' }),
|
|
435
|
+
old_value: meta(unknown, { description: 'Setting value before the update.' }),
|
|
436
|
+
new_value: meta(unknown, { description: 'Setting value after the update.' })
|
|
449
437
|
}),
|
|
450
438
|
// Row deleted through the generic db-admin table browser
|
|
451
439
|
// (`http/db_routes.ts` / the Rust spine's `fuz_db_admin`). Account-grain
|
|
452
440
|
// attribution (`account_id`, no `actor_id`) — the browser's gate is
|
|
453
441
|
// account-grain by construction. Emitted only on a successful delete;
|
|
454
442
|
// post-composite-refusal the delete is provably single-row, so no count.
|
|
455
|
-
db_admin_row_delete:
|
|
456
|
-
table:
|
|
457
|
-
pk_column:
|
|
443
|
+
db_admin_row_delete: loose_object({
|
|
444
|
+
table: meta(string, { description: 'Table the row was deleted from.' }),
|
|
445
|
+
pk_column: meta(string, {
|
|
458
446
|
description: 'Single primary-key column the `DELETE` filtered on.'
|
|
459
447
|
}),
|
|
460
|
-
id:
|
|
448
|
+
id: meta(string, {
|
|
461
449
|
description: "Primary-key value of the deleted row, as the row's canonical `::text` rendering."
|
|
462
450
|
})
|
|
463
451
|
})
|
|
@@ -479,7 +467,7 @@ export const builtin_audit_log_config = Object.freeze({
|
|
|
479
467
|
* `AppDeps.audit` emitter. Builtin handlers omit the `audit_log_config`
|
|
480
468
|
* slot and pick up `builtin_audit_log_config`.
|
|
481
469
|
*
|
|
482
|
-
* @throws Error when an `extra_events` key collides with a builtin event type or fails `AuditEventTypeName` format validation
|
|
470
|
+
* @throws Error when an `extra_events` key collides with a builtin event type or fails `AuditEventTypeName` format validation, or its value is neither `null` nor a schema of either library
|
|
483
471
|
*/
|
|
484
472
|
export const create_audit_log_config = (options) => {
|
|
485
473
|
const extras = options?.extra_events;
|
|
@@ -500,8 +488,10 @@ export const create_audit_log_config = (options) => {
|
|
|
500
488
|
throw new Error(`extra_events key "${t}" has invalid format: ${name_check.error.issues[0].message}`);
|
|
501
489
|
}
|
|
502
490
|
extra_keys.push(t);
|
|
503
|
-
if (schema !== null)
|
|
491
|
+
if (schema !== null) {
|
|
492
|
+
assert_validation_schema(schema, `extra_events key "${t}"`);
|
|
504
493
|
metadata_schemas[t] = schema;
|
|
494
|
+
}
|
|
505
495
|
}
|
|
506
496
|
return Object.freeze({
|
|
507
497
|
event_types: Object.freeze([...AUDIT_EVENT_TYPES, ...extra_keys]),
|
|
@@ -511,39 +501,49 @@ export const create_audit_log_config = (options) => {
|
|
|
511
501
|
/** Default page size for audit log listings. */
|
|
512
502
|
export const AUDIT_LOG_DEFAULT_LIMIT = 50;
|
|
513
503
|
/**
|
|
514
|
-
*
|
|
504
|
+
* Client-safe audit log event, a `@fuzdev/fuz_schema` schema.
|
|
515
505
|
*
|
|
516
|
-
* `event_type` is `AuditEventTypeName` (regex-validated string
|
|
506
|
+
* `event_type` is `AuditEventTypeName` (regex-validated string, at most
|
|
507
|
+
* `NAME_LENGTH_MAX` characters) — matches
|
|
517
508
|
* the `AuditLogEvent` row and the DB's `TEXT NOT NULL` column. Consumer
|
|
518
509
|
* types registered via `create_audit_log_config({extra_events})` round-trip
|
|
519
510
|
* through queries, `on_audit_event` callbacks, and JSON-RPC responses
|
|
520
511
|
* identically to builtins. `AuditLogInput<T>` stays parameterized on the
|
|
521
|
-
* write side so `AuditMetadataMap` narrows metadata per event type.
|
|
512
|
+
* write side so `AuditMetadataMap` narrows metadata per event type. `seq` is
|
|
513
|
+
* an integer within `Number.MAX_SAFE_INTEGER`, the integers a JSON number
|
|
514
|
+
* holds exactly.
|
|
522
515
|
*/
|
|
523
|
-
export const AuditLogEventJson =
|
|
516
|
+
export const AuditLogEventJson = object({
|
|
524
517
|
id: Uuid,
|
|
525
|
-
seq:
|
|
526
|
-
event_type:
|
|
527
|
-
outcome:
|
|
528
|
-
actor_id:
|
|
529
|
-
account_id:
|
|
530
|
-
target_account_id:
|
|
531
|
-
target_actor_id:
|
|
532
|
-
ip:
|
|
533
|
-
created_at:
|
|
534
|
-
metadata:
|
|
518
|
+
seq: pipe(number, safe_integer),
|
|
519
|
+
event_type: AuditEventTypeNameFuz,
|
|
520
|
+
outcome: AuditOutcomeFuz,
|
|
521
|
+
actor_id: nullable(Uuid),
|
|
522
|
+
account_id: nullable(Uuid),
|
|
523
|
+
target_account_id: nullable(Uuid),
|
|
524
|
+
target_actor_id: nullable(Uuid),
|
|
525
|
+
ip: nullable(string),
|
|
526
|
+
created_at: Timestamp,
|
|
527
|
+
metadata: nullable(record(unknown))
|
|
535
528
|
});
|
|
536
|
-
/**
|
|
537
|
-
export const AuditLogEventWithUsernamesJson =
|
|
538
|
-
|
|
539
|
-
|
|
529
|
+
/** Audit log events with resolved usernames, a `@fuzdev/fuz_schema` schema. */
|
|
530
|
+
export const AuditLogEventWithUsernamesJson = object({
|
|
531
|
+
...AuditLogEventJson.def,
|
|
532
|
+
username: nullable(string),
|
|
533
|
+
target_username: nullable(string)
|
|
540
534
|
});
|
|
541
|
-
/**
|
|
542
|
-
export const RoleGrantHistoryEventJson =
|
|
543
|
-
|
|
544
|
-
|
|
535
|
+
/** Role_grant history events with resolved usernames, a `@fuzdev/fuz_schema` schema. */
|
|
536
|
+
export const RoleGrantHistoryEventJson = object({
|
|
537
|
+
...AuditLogEventJson.def,
|
|
538
|
+
username: nullable(string),
|
|
539
|
+
target_username: nullable(string)
|
|
545
540
|
});
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
541
|
+
const { is_current: _, ...admin_session_entries } = AuthSessionJson.def;
|
|
542
|
+
/**
|
|
543
|
+
* Admin session listing (session + username, without `is_current`), a
|
|
544
|
+
* `@fuzdev/fuz_schema` schema. `username` is a plain string.
|
|
545
|
+
*/
|
|
546
|
+
export const AdminSessionJson = object({
|
|
547
|
+
...admin_session_entries,
|
|
548
|
+
username: string
|
|
549
549
|
});
|