@fuzdev/fuz_app 0.161.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.
Files changed (63) hide show
  1. package/dist/auth/CLAUDE.md +16 -8
  2. package/dist/auth/account_action_specs.d.ts +173 -35
  3. package/dist/auth/account_action_specs.d.ts.map +1 -1
  4. package/dist/auth/account_action_specs.js +10 -7
  5. package/dist/auth/account_route_schema.d.ts +293 -46
  6. package/dist/auth/account_route_schema.d.ts.map +1 -1
  7. package/dist/auth/account_route_schema.js +5 -4
  8. package/dist/auth/account_schema.d.ts +489 -103
  9. package/dist/auth/account_schema.d.ts.map +1 -1
  10. package/dist/auth/account_schema.js +67 -47
  11. package/dist/auth/admin_action_specs.d.ts +1753 -240
  12. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  13. package/dist/auth/admin_action_specs.js +29 -25
  14. package/dist/auth/audit_emitter.d.ts +8 -3
  15. package/dist/auth/audit_emitter.d.ts.map +1 -1
  16. package/dist/auth/audit_emitter.js +32 -9
  17. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  18. package/dist/auth/audit_log_queries.js +4 -3
  19. package/dist/auth/audit_log_schema.d.ts +786 -259
  20. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  21. package/dist/auth/audit_log_schema.js +188 -201
  22. package/dist/auth/audit_log_schema_fuz.d.ts +17 -3
  23. package/dist/auth/audit_log_schema_fuz.d.ts.map +1 -1
  24. package/dist/auth/audit_log_schema_fuz.js +17 -4
  25. package/dist/auth/credential_type_schema.d.ts +1 -1
  26. package/dist/auth/invite_schema.d.ts +98 -26
  27. package/dist/auth/invite_schema.d.ts.map +1 -1
  28. package/dist/auth/invite_schema.js +21 -14
  29. package/dist/auth/migrations.d.ts.map +1 -1
  30. package/dist/auth/migrations.js +27 -0
  31. package/dist/auth/role_grant_offer_action_specs.d.ts +72 -72
  32. package/dist/auth/role_grant_offer_notifications.d.ts +60 -60
  33. package/dist/auth/role_grant_offer_schema.d.ts +6 -6
  34. package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
  35. package/dist/auth/role_grant_offer_schema.js +8 -8
  36. package/dist/dev/setup.d.ts +14 -7
  37. package/dist/dev/setup.d.ts.map +1 -1
  38. package/dist/dev/setup.js +11 -6
  39. package/dist/primitive_schemas.d.ts +1 -4
  40. package/dist/primitive_schemas.d.ts.map +1 -1
  41. package/dist/primitive_schemas.js +1 -5
  42. package/dist/primitive_schemas_fuz.d.ts +36 -2
  43. package/dist/primitive_schemas_fuz.d.ts.map +1 -1
  44. package/dist/primitive_schemas_fuz.js +34 -3
  45. package/dist/testing/CLAUDE.md +7 -3
  46. package/dist/testing/app_server.d.ts +3 -1
  47. package/dist/testing/app_server.d.ts.map +1 -1
  48. package/dist/testing/app_server.js +6 -2
  49. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  50. package/dist/testing/audit_drift_guard.js +12 -13
  51. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  52. package/dist/testing/cross_backend/identity_parity.js +4 -2
  53. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  54. package/dist/testing/cross_backend/session_cap.js +4 -3
  55. package/dist/testing/db_entities.d.ts +3 -1
  56. package/dist/testing/db_entities.d.ts.map +1 -1
  57. package/dist/testing/db_entities.js +4 -2
  58. package/dist/testing/integration.d.ts.map +1 -1
  59. package/dist/testing/integration.js +3 -2
  60. package/dist/zod.d.ts +2 -1
  61. package/dist/zod.d.ts.map +1 -1
  62. package/dist/zod.js +6 -2
  63. 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;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAkB,IAAI,EAAS,MAAM,yBAAyB,CAAC;AAmBtE;;;;;GAKG;AACH,eAAO,MAAM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AC;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 Zod schemas.
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,11 +12,18 @@
9
12
  * @module
10
13
  */
11
14
  import { z } from 'zod';
12
- import { bounded_string, Uuid, Email } from '../primitive_schemas.js';
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 { ApiTokenId } from './api_token.js';
15
- import { BuiltinCredentialType } from './credential_type_schema.js';
21
+ import { API_TOKEN_ID_REGEX } from './api_token.js';
22
+ import { BUILTIN_CREDENTIAL_TYPES } from './credential_type_schema.js';
16
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));
17
27
  /**
18
28
  * Defense-in-depth audit field — records the credential channel
19
29
  * (`session` / `api_token` / `daemon_token`) the request arrived on.
@@ -21,7 +31,7 @@ import { NAME_LENGTH_MAX } from './name_schema.js';
21
31
  * so forensics survive a future loosening or bypass of the spec gate.
22
32
  * See `docs/security.md` §Credential-channel gating.
23
33
  */
24
- const credential_type_meta = BuiltinCredentialType.optional().meta({
34
+ const credential_type_meta = meta(optional(one_of(BUILTIN_CREDENTIAL_TYPES)), {
25
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.'
26
36
  });
27
37
  /**
@@ -150,18 +160,6 @@ export const to_global_role_revocation = (event) => {
150
160
  return null;
151
161
  return { account_id, role };
152
162
  };
153
- /**
154
- * Letter start, then letters, digits, `_`, `.`, `/`, `-`. Accepts snake_case,
155
- * dotted, and namespaced consumer conventions; rejects empty strings, leading
156
- * separators, whitespace, and control characters. The audit event type's own
157
- * grammar, wider than the shared name grammar (`auth/name_schema.ts`), whose
158
- * length cap `AuditEventTypeName` takes.
159
- */
160
- export const AUDIT_EVENT_TYPE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_./-]*$/;
161
- /** The message of an audit event-type name past `NAME_LENGTH_MAX`. */
162
- export const AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE = `must be at most ${NAME_LENGTH_MAX} characters`;
163
- /** The message of an audit event-type name off `AUDIT_EVENT_TYPE_NAME_REGEX`. */
164
- export const AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE = 'must start with a letter; only letters, digits, _ . / - allowed';
165
163
  /**
166
164
  * Zod schema for valid audit event-type name strings: `AUDIT_EVENT_TYPE_NAME_REGEX`,
167
165
  * at most `NAME_LENGTH_MAX` UTF-16 code units. Twin of the Rust spine's
@@ -174,95 +172,86 @@ export const AuditEventTypeName = bounded_string({
174
172
  /** Zod schema for audit event outcomes. */
175
173
  export const AuditOutcome = z.enum(['success', 'failure']);
176
174
  /**
177
- * Per-event-type metadata Zod schemas. `z.looseObject` so consumers can
178
- * add fields while known ones are validated. The record is frozen to
179
- * catch mutation bugs at the key level (e.g. tests that try to swap in a
180
- * stub schema); the Zod schemas themselves are reachable and mutable —
181
- * 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.
182
179
  */
183
180
  export const audit_metadata_schemas = Object.freeze({
184
- login: z
185
- .looseObject({
186
- username: z.string().meta({ description: 'Username submitted with the login attempt.' })
187
- })
188
- .nullable(),
189
- logout: z.null(),
190
- bootstrap: z
191
- .looseObject({
192
- error: z.string().meta({ description: 'Error message for a failed bootstrap attempt.' })
193
- })
194
- .nullable(),
195
- signup: z.looseObject({
196
- username: z.string().meta({ description: 'Username submitted at signup.' }),
197
- 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), {
198
191
  description: 'Invite consumed by this signup. Set on success and on `signup_conflict` failure rows when an invite was matched at attempt time.'
199
192
  }),
200
- open_signup: z.boolean().optional().meta({
193
+ open_signup: meta(optional(boolean), {
201
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`.'
202
195
  }),
203
- reason: z.string().optional().meta({
196
+ reason: meta(optional(string), {
204
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`.'
205
198
  }),
206
- email: Email.optional().meta({
199
+ email: meta(optional(Email), {
207
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.'
208
201
  })
209
202
  }),
210
- password_change: z
211
- .looseObject({
212
- sessions_revoked: z.number().optional().meta({
203
+ password_change: nullable(loose_object({
204
+ sessions_revoked: meta(optional(number), {
213
205
  description: 'Number of sessions revoked as a side effect of the password change. Present on `outcome=success`.'
214
206
  }),
215
- tokens_revoked: z.number().optional().meta({
207
+ tokens_revoked: meta(optional(number), {
216
208
  description: 'Number of API tokens revoked as a side effect of the password change. Present on `outcome=success`.'
217
209
  }),
218
- reason: z.enum(['concurrent_change']).optional().meta({
210
+ reason: meta(optional(literal('concurrent_change')), {
219
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.'
220
212
  }),
221
213
  credential_type: credential_type_meta
222
- })
223
- .nullable(),
224
- session_revoke: z.looseObject({
225
- session_id: SessionId.meta({
214
+ })),
215
+ session_revoke: loose_object({
216
+ session_id: meta(SessionId, {
226
217
  description: 'Blake3 hash identifying the revoked session row.'
227
218
  }),
228
219
  credential_type: credential_type_meta
229
220
  }),
230
- session_revoke_all: z.looseObject({
221
+ session_revoke_all: loose_object({
231
222
  // Omitted on `outcome='failure'` (no revocation attempted — e.g. target
232
223
  // account not found); `reason` carries the failure category, and
233
224
  // `attempted_account_id` preserves the probed id (the `target_account_id`
234
225
  // column is null in that case because it's a FK to `account`).
235
- count: z.number().optional().meta({
226
+ count: meta(optional(number), {
236
227
  description: 'Number of sessions revoked. Omitted on `outcome=failure` because no revocation was attempted.'
237
228
  }),
238
- reason: z
239
- .string()
240
- .optional()
241
- .meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
242
- 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), {
243
233
  description: 'Probed account id when the target lookup missed (FK constraint forces `target_account_id` to null).'
244
234
  }),
245
235
  credential_type: credential_type_meta
246
236
  }),
247
- token_create: z.looseObject({
248
- token_id: ApiTokenId.meta({ description: 'Public id of the created API token (`tok_…`).' }),
249
- name: z.string().meta({ description: 'Operator-supplied label for the token.' }),
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.' }),
250
240
  credential_type: credential_type_meta
251
241
  }),
252
- token_revoke: z.looseObject({
253
- token_id: ApiTokenId.meta({ description: 'Public id of the revoked API token (`tok_…`).' }),
242
+ token_revoke: loose_object({
243
+ token_id: meta(TokenId, { description: 'Public id of the revoked API token (`tok_…`).' }),
254
244
  credential_type: credential_type_meta
255
245
  }),
256
- token_revoke_all: z.looseObject({
246
+ token_revoke_all: loose_object({
257
247
  // Same shape as `session_revoke_all` for failures.
258
- count: z.number().optional().meta({
248
+ count: meta(optional(number), {
259
249
  description: 'Number of tokens revoked. Omitted on `outcome=failure` because no revocation was attempted.'
260
250
  }),
261
- reason: z
262
- .string()
263
- .optional()
264
- .meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
265
- 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), {
266
255
  description: 'Probed account id when the target lookup missed (FK constraint forces `target_account_id` to null).'
267
256
  })
268
257
  }),
@@ -270,91 +259,89 @@ export const audit_metadata_schemas = Object.freeze({
270
259
  // (e.g. admin-grant-path denied) never produce a role_grant row.
271
260
  // `self_service: true` is set by the self-service role toggle in
272
261
  // `self_service_role_actions.ts` — declared explicitly rather than
273
- // riding on `z.looseObject` permissiveness so the field is part of
262
+ // riding on `loose_object` permissiveness so the field is part of
274
263
  // the documented schema surface.
275
- role_grant_create: z.looseObject({
276
- role: z.string().meta({ description: 'Role being granted.' }),
277
- role_grant_id: Uuid.optional().meta({
264
+ role_grant_create: loose_object({
265
+ role: meta(string, { description: 'Role being granted.' }),
266
+ role_grant_id: meta(optional(Uuid), {
278
267
  description: 'Id of the resulting role_grant row. Omitted when the grant failed (e.g. admin-grant-path denial).'
279
268
  }),
280
- scope_kind: z.string().nullish().meta({
269
+ scope_kind: meta(optional(nullable(string)), {
281
270
  description: 'Kind tag paired with `scope_id` on a `role_grant_assign` row; null for a global grant.'
282
271
  }),
283
- scope_id: Uuid.nullish().meta({
272
+ scope_id: meta(optional(nullable(Uuid)), {
284
273
  description: 'Scope of the granted role_grant; null for global role_grants.'
285
274
  }),
286
- source_offer_id: Uuid.optional().meta({
275
+ source_offer_id: meta(optional(Uuid), {
287
276
  description: 'Offer this grant resolved, when the grant originated from an accepted offer.'
288
277
  }),
289
- self_service: z.boolean().optional().meta({
278
+ self_service: meta(optional(boolean), {
290
279
  description: 'True when the grant came from the self-service role toggle.'
291
280
  })
292
281
  }),
293
- role_grant_revoke: z.looseObject({
294
- role: z.string().meta({ description: 'Role being revoked.' }),
295
- role_grant_id: Uuid.meta({ description: 'Id of the revoked role_grant row.' }),
296
- scope_id: Uuid.nullish().meta({
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)), {
297
286
  description: 'Scope of the revoked role_grant; null for global role_grants.'
298
287
  }),
299
- reason: z
300
- .string()
301
- .optional()
302
- .meta({ description: 'Optional admin-supplied or self-service reason text.' }),
303
- 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), {
304
292
  description: 'True when the revoke came from the self-service role toggle.'
305
293
  })
306
294
  }),
307
295
  // `offer_id` is optional because failed creates (e.g. admin-grant-path
308
296
  // denied, `authorize` callback denied) never produce an offer row.
309
- role_grant_offer_create: z.looseObject({
310
- offer_id: Uuid.optional().meta({
297
+ role_grant_offer_create: loose_object({
298
+ offer_id: meta(optional(Uuid), {
311
299
  description: 'Id of the created offer row. Omitted when the create failed before insert.'
312
300
  }),
313
- role: z.string().meta({ description: 'Role being offered.' }),
314
- scope_id: Uuid.nullish().meta({
301
+ role: meta(string, { description: 'Role being offered.' }),
302
+ scope_id: meta(optional(nullable(Uuid)), {
315
303
  description: 'Scope of the offered role; null for global offers.'
316
304
  }),
317
- to_account_id: Uuid.meta({ description: 'Account the offer is directed to.' })
305
+ to_account_id: meta(Uuid, { description: 'Account the offer is directed to.' })
318
306
  }),
319
307
  // `role_grant_create` is emitted alongside on accept — two events per accept by
320
308
  // design: offer-lifecycle audit + role-grant-lifecycle audit. A refused
321
309
  // accept (a builtin-role offer that must not mint) is an `outcome=failure`
322
310
  // row with no `role_grant_id` (nothing was minted) and the wire `reason`.
323
- role_grant_offer_accept: z.looseObject({
324
- offer_id: Uuid.meta({ description: 'Id of the accepted (or refused) offer.' }),
325
- role_grant_id: Uuid.optional().meta({
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), {
326
314
  description: 'Id of the resulting role_grant row. Omitted on `outcome=failure` because no grant was minted.'
327
315
  }),
328
- role: z.string().meta({ description: 'Role granted by the offer.' }),
329
- scope_id: Uuid.nullish().meta({
316
+ role: meta(string, { description: 'Role granted by the offer.' }),
317
+ scope_id: meta(optional(nullable(Uuid)), {
330
318
  description: 'Scope of the resulting role_grant; null for global role_grants.'
331
319
  }),
332
- reason: z.string().optional().meta({
320
+ reason: meta(optional(string), {
333
321
  description: 'Wire error reason of a refused accept. Set only on `outcome=failure`.'
334
322
  })
335
323
  }),
336
- role_grant_offer_decline: z.looseObject({
337
- offer_id: Uuid.meta({ description: 'Id of the declined offer.' }),
338
- role: z.string().meta({ description: 'Role that was offered.' }),
339
- scope_id: Uuid.nullish().meta({
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)), {
340
328
  description: 'Scope of the offered role; null for global offers.'
341
329
  }),
342
- reason: z
343
- .string()
344
- .optional()
345
- .meta({ description: 'Optional decline reason text from the recipient.' })
330
+ reason: meta(optional(string), {
331
+ description: 'Optional decline reason text from the recipient.'
332
+ })
346
333
  }),
347
- role_grant_offer_retract: z.looseObject({
348
- offer_id: Uuid.meta({ description: 'Id of the retracted offer.' }),
349
- role: z.string().meta({ description: 'Role that was offered.' }),
350
- scope_id: Uuid.nullish().meta({
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)), {
351
338
  description: 'Scope of the offered role; null for global offers.'
352
339
  })
353
340
  }),
354
- role_grant_offer_expire: z.looseObject({
355
- offer_id: Uuid.meta({ description: 'Id of the expired offer.' }),
356
- role: z.string().meta({ description: 'Role that was offered.' }),
357
- scope_id: Uuid.nullish().meta({
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)), {
358
345
  description: 'Scope of the offered role; null for global offers.'
359
346
  })
360
347
  }),
@@ -364,28 +351,26 @@ export const audit_metadata_schemas = Object.freeze({
364
351
  // — the recipient's grant of the offered role, or a grant of the grantor's),
365
352
  // the destroyed parent scope row (for `scope_destroyed`), or the grantor's
366
353
  // removed account (for `account_deleted`).
367
- role_grant_offer_supersede: z.looseObject({
368
- offer_id: Uuid.meta({ description: 'Id of the superseded offer.' }),
369
- role: z.string().meta({ description: 'Role that was offered.' }),
370
- scope_id: Uuid.nullish().meta({
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)), {
371
358
  description: 'Scope of the offered role; null for global offers.'
372
359
  }),
373
- reason: z
374
- .enum(['sibling_accepted', 'role_grant_revoked', 'scope_destroyed', 'account_deleted'])
375
- .meta({
360
+ reason: meta(one_of(['sibling_accepted', 'role_grant_revoked', 'scope_destroyed', 'account_deleted']), {
376
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."
377
362
  }),
378
- cause_id: Uuid.meta({
363
+ cause_id: meta(Uuid, {
379
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`)."
380
365
  })
381
366
  }),
382
- invite_create: z.looseObject({
383
- invite_id: Uuid.meta({ description: 'Id of the created invite.' }),
384
- email: z.string().nullable().meta({ description: 'Invited email address; null when not set.' }),
385
- username: z.string().nullable().meta({ description: 'Invited username; null when not set.' })
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.' })
386
371
  }),
387
- invite_delete: z.looseObject({
388
- invite_id: Uuid.meta({ description: 'Id of the deleted invite.' })
372
+ invite_delete: loose_object({
373
+ invite_id: meta(Uuid, { description: 'Id of the deleted invite.' })
389
374
  }),
390
375
  // Account/actor deletion snapshots identity into metadata so the
391
376
  // identity behind a now-orphaned audit id survives a purge (the
@@ -395,33 +380,27 @@ export const audit_metadata_schemas = Object.freeze({
395
380
  // snapshot and the not-found failure shape (`reason` /
396
381
  // `attempted_account_id`). See `auth/CLAUDE.md` §Account/actor deletion
397
382
  // (delete = soft, purge = hard).
398
- account_delete: z.looseObject({
399
- username: z.string().optional().meta({ description: 'Username at soft-delete time.' }),
400
- email: z
401
- .string()
402
- .nullable()
403
- .optional()
404
- .meta({ description: 'Email at soft-delete time; null when unset.' }),
405
- reason: z
406
- .string()
407
- .optional()
408
- .meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
409
- 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), {
410
392
  description: 'Probed account id when the target was missing (`outcome=failure`).'
411
393
  })
412
394
  }),
413
- account_purge: z.looseObject({
414
- username: z.string().optional().meta({ description: 'Username at purge time.' }),
415
- email: z
416
- .string()
417
- .nullable()
418
- .optional()
419
- .meta({ description: 'Email at purge time; null when unset.' }),
420
- reason: z
421
- .string()
422
- .optional()
423
- .meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
424
- 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), {
425
404
  description: 'Probed account id when the target was missing (`outcome=failure`).'
426
405
  })
427
406
  }),
@@ -430,46 +409,43 @@ export const audit_metadata_schemas = Object.freeze({
430
409
  // the delete events so reviewers see who was reactivated; `reason` /
431
410
  // `attempted_account_id` carry the not-found failure shape. Admin-only —
432
411
  // the self path is unreachable (a tombstoned account can't authenticate).
433
- account_undelete: z.looseObject({
434
- username: z.string().optional().meta({ description: 'Username at reactivation time.' }),
435
- email: z
436
- .string()
437
- .nullable()
438
- .optional()
439
- .meta({ description: 'Email at reactivation time; null when unset.' }),
440
- reason: z
441
- .string()
442
- .optional()
443
- .meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
444
- 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), {
445
421
  description: 'Probed account id when the target was missing/not-deleted (`outcome=failure`).'
446
422
  })
447
423
  }),
448
- actor_delete: z.looseObject({
449
- name: z.string().optional().meta({ description: 'Actor display name at soft-delete time.' })
424
+ actor_delete: loose_object({
425
+ name: meta(optional(string), { description: 'Actor display name at soft-delete time.' })
450
426
  }),
451
- actor_purge: z.looseObject({
452
- name: z.string().optional().meta({ description: 'Actor display name at purge time.' })
427
+ actor_purge: loose_object({
428
+ name: meta(optional(string), { description: 'Actor display name at purge time.' })
453
429
  }),
454
- actor_undelete: z.looseObject({
455
- name: z.string().optional().meta({ description: 'Actor display name at reactivation time.' })
430
+ actor_undelete: loose_object({
431
+ name: meta(optional(string), { description: 'Actor display name at reactivation time.' })
456
432
  }),
457
- app_settings_update: z.looseObject({
458
- setting: z.string().meta({ description: 'Name of the setting that changed.' }),
459
- old_value: z.unknown().meta({ description: 'Setting value before the update.' }),
460
- new_value: z.unknown().meta({ description: 'Setting value after the update.' })
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.' })
461
437
  }),
462
438
  // Row deleted through the generic db-admin table browser
463
439
  // (`http/db_routes.ts` / the Rust spine's `fuz_db_admin`). Account-grain
464
440
  // attribution (`account_id`, no `actor_id`) — the browser's gate is
465
441
  // account-grain by construction. Emitted only on a successful delete;
466
442
  // post-composite-refusal the delete is provably single-row, so no count.
467
- db_admin_row_delete: z.looseObject({
468
- table: z.string().meta({ description: 'Table the row was deleted from.' }),
469
- pk_column: z.string().meta({
443
+ db_admin_row_delete: loose_object({
444
+ table: meta(string, { description: 'Table the row was deleted from.' }),
445
+ pk_column: meta(string, {
470
446
  description: 'Single primary-key column the `DELETE` filtered on.'
471
447
  }),
472
- id: z.string().meta({
448
+ id: meta(string, {
473
449
  description: "Primary-key value of the deleted row, as the row's canonical `::text` rendering."
474
450
  })
475
451
  })
@@ -491,7 +467,7 @@ export const builtin_audit_log_config = Object.freeze({
491
467
  * `AppDeps.audit` emitter. Builtin handlers omit the `audit_log_config`
492
468
  * slot and pick up `builtin_audit_log_config`.
493
469
  *
494
- * @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
495
471
  */
496
472
  export const create_audit_log_config = (options) => {
497
473
  const extras = options?.extra_events;
@@ -512,8 +488,10 @@ export const create_audit_log_config = (options) => {
512
488
  throw new Error(`extra_events key "${t}" has invalid format: ${name_check.error.issues[0].message}`);
513
489
  }
514
490
  extra_keys.push(t);
515
- if (schema !== null)
491
+ if (schema !== null) {
492
+ assert_validation_schema(schema, `extra_events key "${t}"`);
516
493
  metadata_schemas[t] = schema;
494
+ }
517
495
  }
518
496
  return Object.freeze({
519
497
  event_types: Object.freeze([...AUDIT_EVENT_TYPES, ...extra_keys]),
@@ -523,7 +501,7 @@ export const create_audit_log_config = (options) => {
523
501
  /** Default page size for audit log listings. */
524
502
  export const AUDIT_LOG_DEFAULT_LIMIT = 50;
525
503
  /**
526
- * Zod schema for client-safe audit log event.
504
+ * Client-safe audit log event, a `@fuzdev/fuz_schema` schema.
527
505
  *
528
506
  * `event_type` is `AuditEventTypeName` (regex-validated string, at most
529
507
  * `NAME_LENGTH_MAX` characters) — matches
@@ -531,32 +509,41 @@ export const AUDIT_LOG_DEFAULT_LIMIT = 50;
531
509
  * types registered via `create_audit_log_config({extra_events})` round-trip
532
510
  * through queries, `on_audit_event` callbacks, and JSON-RPC responses
533
511
  * identically to builtins. `AuditLogInput<T>` stays parameterized on the
534
- * 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.
535
515
  */
536
- export const AuditLogEventJson = z.strictObject({
516
+ export const AuditLogEventJson = object({
537
517
  id: Uuid,
538
- seq: z.number().int(),
539
- event_type: AuditEventTypeName,
540
- outcome: AuditOutcome,
541
- actor_id: Uuid.nullable(),
542
- account_id: Uuid.nullable(),
543
- target_account_id: Uuid.nullable(),
544
- target_actor_id: Uuid.nullable(),
545
- ip: z.string().nullable(),
546
- created_at: z.string(),
547
- metadata: z.record(z.string(), z.unknown()).nullable()
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))
548
528
  });
549
- /** Zod schema for audit log events with resolved usernames. */
550
- export const AuditLogEventWithUsernamesJson = AuditLogEventJson.extend({
551
- username: z.string().nullable(),
552
- target_username: z.string().nullable()
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)
553
534
  });
554
- /** Zod schema for role_grant history events with resolved usernames. */
555
- export const RoleGrantHistoryEventJson = AuditLogEventJson.extend({
556
- username: z.string().nullable(),
557
- target_username: z.string().nullable()
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)
558
540
  });
559
- /** Zod schema for admin session listing (session + username, without `is_current`). */
560
- export const AdminSessionJson = AuthSessionJson.omit({ is_current: true }).extend({
561
- username: z.string()
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
562
549
  });