@fuzdev/fuz_app 0.161.0 → 0.163.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 +47 -36
- package/dist/auth/account_action_specs.d.ts +614 -150
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +56 -52
- package/dist/auth/account_route_schema.d.ts +401 -94
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +54 -39
- package/dist/auth/account_routes.js +1 -1
- package/dist/auth/account_schema.d.ts +531 -118
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +76 -58
- package/dist/auth/admin_action_specs.d.ts +1753 -240
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +28 -26
- package/dist/auth/admin_actions.d.ts +4 -4
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +3 -3
- package/dist/auth/all_cell_actions.d.ts +3 -3
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +1 -1
- package/dist/auth/api_token.d.ts +4 -4
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +3 -3
- package/dist/auth/audit_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_schema.d.ts +798 -291
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +192 -201
- package/dist/auth/bootstrap_route_schema.d.ts +173 -50
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +35 -16
- package/dist/auth/cell_grant_action_specs.d.ts +1 -1
- package/dist/auth/cell_grant_action_specs.js +1 -1
- package/dist/auth/cell_grant_actions.d.ts +4 -4
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +1 -1
- package/dist/auth/credential_type_schema.d.ts +16 -29
- package/dist/auth/credential_type_schema.d.ts.map +1 -1
- package/dist/auth/credential_type_schema.js +14 -18
- package/dist/auth/grant_path_schema.d.ts +15 -29
- package/dist/auth/grant_path_schema.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.js +13 -17
- package/dist/auth/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 +28 -1
- package/dist/auth/name_schema.d.ts +7 -6
- package/dist/auth/name_schema.d.ts.map +1 -1
- package/dist/auth/name_schema.js +8 -9
- package/dist/auth/password.d.ts +15 -7
- package/dist/auth/password.d.ts.map +1 -1
- package/dist/auth/password.js +16 -9
- package/dist/auth/role_grant_offer_action_specs.d.ts +72 -72
- package/dist/auth/role_grant_offer_action_specs.js +2 -2
- package/dist/auth/role_grant_offer_actions.d.ts +4 -4
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +3 -3
- package/dist/auth/role_grant_offer_notifications.d.ts +60 -60
- package/dist/auth/role_grant_offer_notifications.js +2 -2
- package/dist/auth/role_grant_offer_schema.d.ts +8 -8
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +10 -10
- package/dist/auth/role_schema.d.ts +47 -55
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +29 -35
- package/dist/auth/scope_kind_schema.d.ts +22 -26
- package/dist/auth/scope_kind_schema.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema.js +19 -19
- package/dist/auth/self_service_role_action_specs.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +6 -6
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +7 -6
- package/dist/auth/signup_route_schema.d.ts +71 -21
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +18 -16
- package/dist/auth/standard_rpc_actions.d.ts +1 -1
- package/dist/auth/standard_rpc_actions.js +1 -1
- package/dist/auth/token_lifetime.d.ts +33 -9
- package/dist/auth/token_lifetime.d.ts.map +1 -1
- package/dist/auth/token_lifetime.js +8 -7
- package/dist/auth/token_scope.d.ts +99 -25
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +57 -35
- package/dist/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 +2 -22
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +2 -24
- package/dist/primitive_schemas_fuz.d.ts +56 -2
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +54 -4
- package/dist/testing/CLAUDE.md +29 -8
- package/dist/testing/admin_integration.d.ts +3 -3
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +1 -1
- 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/default_spine_surface.d.ts +2 -2
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +2 -2
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +43 -8
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -3
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +4 -3
- package/dist/testing/cross_backend/setup.d.ts +1 -1
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +45 -42
- package/dist/testing/cross_backend/spine_suites.d.ts +3 -3
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.d.ts +4 -4
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +34 -1
- 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 +4 -3
- package/dist/testing/token_scope_fixtures.d.ts +24 -0
- package/dist/testing/token_scope_fixtures.d.ts.map +1 -0
- package/dist/testing/token_scope_fixtures.js +49 -0
- package/dist/testing/transports/bootstrap.d.ts +1 -1
- package/dist/testing/transports/bootstrap.d.ts.map +1 -1
- package/dist/testing/transports/bootstrap.js +13 -12
- package/dist/ui/BootstrapForm.svelte +4 -2
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/SignupForm.svelte +4 -2
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- 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
- package/dist/auth/audit_log_schema_fuz.d.ts +0 -39
- package/dist/auth/audit_log_schema_fuz.d.ts.map +0 -1
- package/dist/auth/audit_log_schema_fuz.js +0 -37
- package/dist/auth/role_schema_fuz.d.ts +0 -30
- package/dist/auth/role_schema_fuz.d.ts.map +0 -1
- package/dist/auth/role_schema_fuz.js +0 -30
- package/dist/auth/scope_kind_schema_fuz.d.ts +0 -31
- package/dist/auth/scope_kind_schema_fuz.d.ts.map +0 -1
- package/dist/auth/scope_kind_schema_fuz.js +0 -31
|
@@ -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;;;;;;;;;;;GAWG;AAGH,OAAO,EAmBN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAoC,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAkBtF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,6iBA6BnB,CAAC;AAEZ,8DAA8D;AAC9D,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;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;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,QAA+B,CAAC;AAExE,sEAAsE;AACtE,eAAO,MAAM,oCAAoC,kCAAkD,CAAC;AAEpG,iFAAiF;AACjF,eAA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F;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,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Audit log types and client-safe
|
|
2
|
+
* Audit log types and client-safe `@fuzdev/fuz_schema` schemas: the
|
|
3
|
+
* event-type and outcome vocabularies, the builtin metadata schemas, and the
|
|
4
|
+
* wire rows.
|
|
3
5
|
*
|
|
4
6
|
* Records auth mutations (login, logout, grant, revoke, etc.) for
|
|
5
7
|
* security monitoring and operational visibility.
|
|
@@ -8,11 +10,13 @@
|
|
|
8
10
|
*
|
|
9
11
|
* @module
|
|
10
12
|
*/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
+
import { meta } from '@fuzdev/fuz_schema/meta.ts';
|
|
14
|
+
import { boolean, format_issue, literal, loose_object, message, nullable, number, object, one_of, optional, parse, pipe, record, regex, safe_integer, string, unknown } from '@fuzdev/fuz_schema/schema.ts';
|
|
15
|
+
import { bounded_string, Email, Timestamp, Uuid } from '../primitive_schemas_fuz.js';
|
|
16
|
+
import { assert_validation_schema } from '../schema_issues.js';
|
|
13
17
|
import { AuthSessionJson, SessionId } from './account_schema.js';
|
|
14
18
|
import { ApiTokenId } from './api_token.js';
|
|
15
|
-
import {
|
|
19
|
+
import { BUILTIN_CREDENTIAL_TYPES } from './credential_type_schema.js';
|
|
16
20
|
import { NAME_LENGTH_MAX } from './name_schema.js';
|
|
17
21
|
/**
|
|
18
22
|
* Defense-in-depth audit field — records the credential channel
|
|
@@ -21,7 +25,7 @@ import { NAME_LENGTH_MAX } from './name_schema.js';
|
|
|
21
25
|
* so forensics survive a future loosening or bypass of the spec gate.
|
|
22
26
|
* See `docs/security.md` §Credential-channel gating.
|
|
23
27
|
*/
|
|
24
|
-
const credential_type_meta =
|
|
28
|
+
const credential_type_meta = meta(optional(one_of(BUILTIN_CREDENTIAL_TYPES)), {
|
|
25
29
|
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
30
|
});
|
|
27
31
|
/**
|
|
@@ -60,8 +64,6 @@ export const AUDIT_EVENT_TYPES = Object.freeze([
|
|
|
60
64
|
'app_settings_update',
|
|
61
65
|
'db_admin_row_delete'
|
|
62
66
|
]);
|
|
63
|
-
/** Zod schema for audit event types. */
|
|
64
|
-
export const AuditEventType = z.enum(AUDIT_EVENT_TYPES);
|
|
65
67
|
/**
|
|
66
68
|
* The `RevocationScope` of every builtin audit event — declared once, the one
|
|
67
69
|
* answer the revocation listener reads, and the twin of the Rust spine's table. Typed over `AuditEventType`, so a new event type does not compile
|
|
@@ -163,106 +165,97 @@ export const AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE = `must be at most ${NAME_LENG
|
|
|
163
165
|
/** The message of an audit event-type name off `AUDIT_EVENT_TYPE_NAME_REGEX`. */
|
|
164
166
|
export const AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE = 'must start with a letter; only letters, digits, _ . / - allowed';
|
|
165
167
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* `
|
|
168
|
+
* Valid audit event-type name strings: `AUDIT_EVENT_TYPE_NAME_REGEX`, at most
|
|
169
|
+
* `NAME_LENGTH_MAX` UTF-16 code units. A string it refuses gets
|
|
170
|
+
* `AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE` or
|
|
171
|
+
* `AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE`, the length one alone for a string
|
|
172
|
+
* both too long and off the grammar; a value that is no string, fuz_schema's
|
|
173
|
+
* message. Twin of the Rust spine's `is_valid_audit_event_type_name`.
|
|
169
174
|
*/
|
|
170
|
-
export const AuditEventTypeName = bounded_string({
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}).regex(AUDIT_EVENT_TYPE_NAME_REGEX, { message: AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE });
|
|
174
|
-
/** Zod schema for audit event outcomes. */
|
|
175
|
-
export const AuditOutcome = z.enum(['success', 'failure']);
|
|
175
|
+
export const AuditEventTypeName = pipe(bounded_string({ max: NAME_LENGTH_MAX, max_message: AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE }), message(regex(AUDIT_EVENT_TYPE_NAME_REGEX), AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE));
|
|
176
|
+
/** Audit event outcome. */
|
|
177
|
+
export const AuditOutcome = one_of(['success', 'failure']);
|
|
176
178
|
/**
|
|
177
|
-
* Per-event-type metadata
|
|
178
|
-
* add fields while known ones are validated. The record is
|
|
179
|
-
* catch mutation bugs at the key level (e.g. tests that try to swap
|
|
180
|
-
* stub schema);
|
|
181
|
-
* freeze isn't a security boundary.
|
|
179
|
+
* Per-event-type metadata schemas, `@fuzdev/fuz_schema` `loose_object`s so
|
|
180
|
+
* consumers can add fields while known ones are validated. The record is
|
|
181
|
+
* frozen to catch mutation bugs at the key level (e.g. tests that try to swap
|
|
182
|
+
* in a stub schema); freeze isn't a security boundary.
|
|
182
183
|
*/
|
|
183
184
|
export const audit_metadata_schemas = Object.freeze({
|
|
184
|
-
login:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
.nullable(),
|
|
195
|
-
signup: z.looseObject({
|
|
196
|
-
username: z.string().meta({ description: 'Username submitted at signup.' }),
|
|
197
|
-
invite_id: Uuid.optional().meta({
|
|
185
|
+
login: nullable(loose_object({
|
|
186
|
+
username: meta(string, { description: 'Username submitted with the login attempt.' })
|
|
187
|
+
})),
|
|
188
|
+
logout: literal(null),
|
|
189
|
+
bootstrap: nullable(loose_object({
|
|
190
|
+
error: meta(string, { description: 'Error message for a failed bootstrap attempt.' })
|
|
191
|
+
})),
|
|
192
|
+
signup: loose_object({
|
|
193
|
+
username: meta(string, { description: 'Username submitted at signup.' }),
|
|
194
|
+
invite_id: meta(optional(Uuid), {
|
|
198
195
|
description: 'Invite consumed by this signup. Set on success and on `signup_conflict` failure rows when an invite was matched at attempt time.'
|
|
199
196
|
}),
|
|
200
|
-
open_signup:
|
|
197
|
+
open_signup: meta(optional(boolean), {
|
|
201
198
|
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
199
|
}),
|
|
203
|
-
reason:
|
|
200
|
+
reason: meta(optional(string), {
|
|
204
201
|
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
202
|
}),
|
|
206
|
-
email:
|
|
203
|
+
email: meta(optional(Email), {
|
|
207
204
|
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
205
|
})
|
|
209
206
|
}),
|
|
210
|
-
password_change:
|
|
211
|
-
|
|
212
|
-
sessions_revoked: z.number().optional().meta({
|
|
207
|
+
password_change: nullable(loose_object({
|
|
208
|
+
sessions_revoked: meta(optional(number), {
|
|
213
209
|
description: 'Number of sessions revoked as a side effect of the password change. Present on `outcome=success`.'
|
|
214
210
|
}),
|
|
215
|
-
tokens_revoked:
|
|
211
|
+
tokens_revoked: meta(optional(number), {
|
|
216
212
|
description: 'Number of API tokens revoked as a side effect of the password change. Present on `outcome=success`.'
|
|
217
213
|
}),
|
|
218
|
-
reason:
|
|
214
|
+
reason: meta(optional(literal('concurrent_change')), {
|
|
219
215
|
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
216
|
}),
|
|
221
217
|
credential_type: credential_type_meta
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
session_id: SessionId.meta({
|
|
218
|
+
})),
|
|
219
|
+
session_revoke: loose_object({
|
|
220
|
+
session_id: meta(SessionId, {
|
|
226
221
|
description: 'Blake3 hash identifying the revoked session row.'
|
|
227
222
|
}),
|
|
228
223
|
credential_type: credential_type_meta
|
|
229
224
|
}),
|
|
230
|
-
session_revoke_all:
|
|
225
|
+
session_revoke_all: loose_object({
|
|
231
226
|
// Omitted on `outcome='failure'` (no revocation attempted — e.g. target
|
|
232
227
|
// account not found); `reason` carries the failure category, and
|
|
233
228
|
// `attempted_account_id` preserves the probed id (the `target_account_id`
|
|
234
229
|
// column is null in that case because it's a FK to `account`).
|
|
235
|
-
count:
|
|
230
|
+
count: meta(optional(number), {
|
|
236
231
|
description: 'Number of sessions revoked. Omitted on `outcome=failure` because no revocation was attempted.'
|
|
237
232
|
}),
|
|
238
|
-
reason:
|
|
239
|
-
.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
attempted_account_id: Uuid.optional().meta({
|
|
233
|
+
reason: meta(optional(string), {
|
|
234
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
235
|
+
}),
|
|
236
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
243
237
|
description: 'Probed account id when the target lookup missed (FK constraint forces `target_account_id` to null).'
|
|
244
238
|
}),
|
|
245
239
|
credential_type: credential_type_meta
|
|
246
240
|
}),
|
|
247
|
-
token_create:
|
|
248
|
-
token_id:
|
|
249
|
-
name:
|
|
241
|
+
token_create: loose_object({
|
|
242
|
+
token_id: meta(ApiTokenId, { description: 'Public id of the created API token (`tok_…`).' }),
|
|
243
|
+
name: meta(string, { description: 'Operator-supplied label for the token.' }),
|
|
250
244
|
credential_type: credential_type_meta
|
|
251
245
|
}),
|
|
252
|
-
token_revoke:
|
|
253
|
-
token_id:
|
|
246
|
+
token_revoke: loose_object({
|
|
247
|
+
token_id: meta(ApiTokenId, { description: 'Public id of the revoked API token (`tok_…`).' }),
|
|
254
248
|
credential_type: credential_type_meta
|
|
255
249
|
}),
|
|
256
|
-
token_revoke_all:
|
|
250
|
+
token_revoke_all: loose_object({
|
|
257
251
|
// Same shape as `session_revoke_all` for failures.
|
|
258
|
-
count:
|
|
252
|
+
count: meta(optional(number), {
|
|
259
253
|
description: 'Number of tokens revoked. Omitted on `outcome=failure` because no revocation was attempted.'
|
|
260
254
|
}),
|
|
261
|
-
reason:
|
|
262
|
-
.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
attempted_account_id: Uuid.optional().meta({
|
|
255
|
+
reason: meta(optional(string), {
|
|
256
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
257
|
+
}),
|
|
258
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
266
259
|
description: 'Probed account id when the target lookup missed (FK constraint forces `target_account_id` to null).'
|
|
267
260
|
})
|
|
268
261
|
}),
|
|
@@ -270,91 +263,89 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
270
263
|
// (e.g. admin-grant-path denied) never produce a role_grant row.
|
|
271
264
|
// `self_service: true` is set by the self-service role toggle in
|
|
272
265
|
// `self_service_role_actions.ts` — declared explicitly rather than
|
|
273
|
-
// riding on `
|
|
266
|
+
// riding on `loose_object` permissiveness so the field is part of
|
|
274
267
|
// the documented schema surface.
|
|
275
|
-
role_grant_create:
|
|
276
|
-
role:
|
|
277
|
-
role_grant_id:
|
|
268
|
+
role_grant_create: loose_object({
|
|
269
|
+
role: meta(string, { description: 'Role being granted.' }),
|
|
270
|
+
role_grant_id: meta(optional(Uuid), {
|
|
278
271
|
description: 'Id of the resulting role_grant row. Omitted when the grant failed (e.g. admin-grant-path denial).'
|
|
279
272
|
}),
|
|
280
|
-
scope_kind:
|
|
273
|
+
scope_kind: meta(optional(nullable(string)), {
|
|
281
274
|
description: 'Kind tag paired with `scope_id` on a `role_grant_assign` row; null for a global grant.'
|
|
282
275
|
}),
|
|
283
|
-
scope_id: Uuid
|
|
276
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
284
277
|
description: 'Scope of the granted role_grant; null for global role_grants.'
|
|
285
278
|
}),
|
|
286
|
-
source_offer_id:
|
|
279
|
+
source_offer_id: meta(optional(Uuid), {
|
|
287
280
|
description: 'Offer this grant resolved, when the grant originated from an accepted offer.'
|
|
288
281
|
}),
|
|
289
|
-
self_service:
|
|
282
|
+
self_service: meta(optional(boolean), {
|
|
290
283
|
description: 'True when the grant came from the self-service role toggle.'
|
|
291
284
|
})
|
|
292
285
|
}),
|
|
293
|
-
role_grant_revoke:
|
|
294
|
-
role:
|
|
295
|
-
role_grant_id:
|
|
296
|
-
scope_id: Uuid
|
|
286
|
+
role_grant_revoke: loose_object({
|
|
287
|
+
role: meta(string, { description: 'Role being revoked.' }),
|
|
288
|
+
role_grant_id: meta(Uuid, { description: 'Id of the revoked role_grant row.' }),
|
|
289
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
297
290
|
description: 'Scope of the revoked role_grant; null for global role_grants.'
|
|
298
291
|
}),
|
|
299
|
-
reason:
|
|
300
|
-
.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
self_service: z.boolean().optional().meta({
|
|
292
|
+
reason: meta(optional(string), {
|
|
293
|
+
description: 'Optional admin-supplied or self-service reason text.'
|
|
294
|
+
}),
|
|
295
|
+
self_service: meta(optional(boolean), {
|
|
304
296
|
description: 'True when the revoke came from the self-service role toggle.'
|
|
305
297
|
})
|
|
306
298
|
}),
|
|
307
299
|
// `offer_id` is optional because failed creates (e.g. admin-grant-path
|
|
308
300
|
// denied, `authorize` callback denied) never produce an offer row.
|
|
309
|
-
role_grant_offer_create:
|
|
310
|
-
offer_id:
|
|
301
|
+
role_grant_offer_create: loose_object({
|
|
302
|
+
offer_id: meta(optional(Uuid), {
|
|
311
303
|
description: 'Id of the created offer row. Omitted when the create failed before insert.'
|
|
312
304
|
}),
|
|
313
|
-
role:
|
|
314
|
-
scope_id: Uuid
|
|
305
|
+
role: meta(string, { description: 'Role being offered.' }),
|
|
306
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
315
307
|
description: 'Scope of the offered role; null for global offers.'
|
|
316
308
|
}),
|
|
317
|
-
to_account_id:
|
|
309
|
+
to_account_id: meta(Uuid, { description: 'Account the offer is directed to.' })
|
|
318
310
|
}),
|
|
319
311
|
// `role_grant_create` is emitted alongside on accept — two events per accept by
|
|
320
312
|
// design: offer-lifecycle audit + role-grant-lifecycle audit. A refused
|
|
321
313
|
// accept (a builtin-role offer that must not mint) is an `outcome=failure`
|
|
322
314
|
// row with no `role_grant_id` (nothing was minted) and the wire `reason`.
|
|
323
|
-
role_grant_offer_accept:
|
|
324
|
-
offer_id:
|
|
325
|
-
role_grant_id:
|
|
315
|
+
role_grant_offer_accept: loose_object({
|
|
316
|
+
offer_id: meta(Uuid, { description: 'Id of the accepted (or refused) offer.' }),
|
|
317
|
+
role_grant_id: meta(optional(Uuid), {
|
|
326
318
|
description: 'Id of the resulting role_grant row. Omitted on `outcome=failure` because no grant was minted.'
|
|
327
319
|
}),
|
|
328
|
-
role:
|
|
329
|
-
scope_id: Uuid
|
|
320
|
+
role: meta(string, { description: 'Role granted by the offer.' }),
|
|
321
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
330
322
|
description: 'Scope of the resulting role_grant; null for global role_grants.'
|
|
331
323
|
}),
|
|
332
|
-
reason:
|
|
324
|
+
reason: meta(optional(string), {
|
|
333
325
|
description: 'Wire error reason of a refused accept. Set only on `outcome=failure`.'
|
|
334
326
|
})
|
|
335
327
|
}),
|
|
336
|
-
role_grant_offer_decline:
|
|
337
|
-
offer_id:
|
|
338
|
-
role:
|
|
339
|
-
scope_id: Uuid
|
|
328
|
+
role_grant_offer_decline: loose_object({
|
|
329
|
+
offer_id: meta(Uuid, { description: 'Id of the declined offer.' }),
|
|
330
|
+
role: meta(string, { description: 'Role that was offered.' }),
|
|
331
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
340
332
|
description: 'Scope of the offered role; null for global offers.'
|
|
341
333
|
}),
|
|
342
|
-
reason:
|
|
343
|
-
.
|
|
344
|
-
|
|
345
|
-
.meta({ description: 'Optional decline reason text from the recipient.' })
|
|
334
|
+
reason: meta(optional(string), {
|
|
335
|
+
description: 'Optional decline reason text from the recipient.'
|
|
336
|
+
})
|
|
346
337
|
}),
|
|
347
|
-
role_grant_offer_retract:
|
|
348
|
-
offer_id:
|
|
349
|
-
role:
|
|
350
|
-
scope_id: Uuid
|
|
338
|
+
role_grant_offer_retract: loose_object({
|
|
339
|
+
offer_id: meta(Uuid, { description: 'Id of the retracted offer.' }),
|
|
340
|
+
role: meta(string, { description: 'Role that was offered.' }),
|
|
341
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
351
342
|
description: 'Scope of the offered role; null for global offers.'
|
|
352
343
|
})
|
|
353
344
|
}),
|
|
354
|
-
role_grant_offer_expire:
|
|
355
|
-
offer_id:
|
|
356
|
-
role:
|
|
357
|
-
scope_id: Uuid
|
|
345
|
+
role_grant_offer_expire: loose_object({
|
|
346
|
+
offer_id: meta(Uuid, { description: 'Id of the expired offer.' }),
|
|
347
|
+
role: meta(string, { description: 'Role that was offered.' }),
|
|
348
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
358
349
|
description: 'Scope of the offered role; null for global offers.'
|
|
359
350
|
})
|
|
360
351
|
}),
|
|
@@ -364,28 +355,26 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
364
355
|
// — the recipient's grant of the offered role, or a grant of the grantor's),
|
|
365
356
|
// the destroyed parent scope row (for `scope_destroyed`), or the grantor's
|
|
366
357
|
// removed account (for `account_deleted`).
|
|
367
|
-
role_grant_offer_supersede:
|
|
368
|
-
offer_id:
|
|
369
|
-
role:
|
|
370
|
-
scope_id: Uuid
|
|
358
|
+
role_grant_offer_supersede: loose_object({
|
|
359
|
+
offer_id: meta(Uuid, { description: 'Id of the superseded offer.' }),
|
|
360
|
+
role: meta(string, { description: 'Role that was offered.' }),
|
|
361
|
+
scope_id: meta(optional(nullable(Uuid)), {
|
|
371
362
|
description: 'Scope of the offered role; null for global offers.'
|
|
372
363
|
}),
|
|
373
|
-
reason:
|
|
374
|
-
.enum(['sibling_accepted', 'role_grant_revoked', 'scope_destroyed', 'account_deleted'])
|
|
375
|
-
.meta({
|
|
364
|
+
reason: meta(one_of(['sibling_accepted', 'role_grant_revoked', 'scope_destroyed', 'account_deleted']), {
|
|
376
365
|
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
366
|
}),
|
|
378
|
-
cause_id:
|
|
367
|
+
cause_id: meta(Uuid, {
|
|
379
368
|
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
369
|
})
|
|
381
370
|
}),
|
|
382
|
-
invite_create:
|
|
383
|
-
invite_id:
|
|
384
|
-
email:
|
|
385
|
-
username:
|
|
371
|
+
invite_create: loose_object({
|
|
372
|
+
invite_id: meta(Uuid, { description: 'Id of the created invite.' }),
|
|
373
|
+
email: meta(nullable(string), { description: 'Invited email address; null when not set.' }),
|
|
374
|
+
username: meta(nullable(string), { description: 'Invited username; null when not set.' })
|
|
386
375
|
}),
|
|
387
|
-
invite_delete:
|
|
388
|
-
invite_id:
|
|
376
|
+
invite_delete: loose_object({
|
|
377
|
+
invite_id: meta(Uuid, { description: 'Id of the deleted invite.' })
|
|
389
378
|
}),
|
|
390
379
|
// Account/actor deletion snapshots identity into metadata so the
|
|
391
380
|
// identity behind a now-orphaned audit id survives a purge (the
|
|
@@ -395,33 +384,27 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
395
384
|
// snapshot and the not-found failure shape (`reason` /
|
|
396
385
|
// `attempted_account_id`). See `auth/CLAUDE.md` §Account/actor deletion
|
|
397
386
|
// (delete = soft, purge = hard).
|
|
398
|
-
account_delete:
|
|
399
|
-
username:
|
|
400
|
-
email:
|
|
401
|
-
.
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
.optional()
|
|
408
|
-
.meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
|
|
409
|
-
attempted_account_id: Uuid.optional().meta({
|
|
387
|
+
account_delete: loose_object({
|
|
388
|
+
username: meta(optional(string), { description: 'Username at soft-delete time.' }),
|
|
389
|
+
email: meta(optional(nullable(string)), {
|
|
390
|
+
description: 'Email at soft-delete time; null when unset.'
|
|
391
|
+
}),
|
|
392
|
+
reason: meta(optional(string), {
|
|
393
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
394
|
+
}),
|
|
395
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
410
396
|
description: 'Probed account id when the target was missing (`outcome=failure`).'
|
|
411
397
|
})
|
|
412
398
|
}),
|
|
413
|
-
account_purge:
|
|
414
|
-
username:
|
|
415
|
-
email:
|
|
416
|
-
.
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
.optional()
|
|
423
|
-
.meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
|
|
424
|
-
attempted_account_id: Uuid.optional().meta({
|
|
399
|
+
account_purge: loose_object({
|
|
400
|
+
username: meta(optional(string), { description: 'Username at purge time.' }),
|
|
401
|
+
email: meta(optional(nullable(string)), {
|
|
402
|
+
description: 'Email at purge time; null when unset.'
|
|
403
|
+
}),
|
|
404
|
+
reason: meta(optional(string), {
|
|
405
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
406
|
+
}),
|
|
407
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
425
408
|
description: 'Probed account id when the target was missing (`outcome=failure`).'
|
|
426
409
|
})
|
|
427
410
|
}),
|
|
@@ -430,46 +413,43 @@ export const audit_metadata_schemas = Object.freeze({
|
|
|
430
413
|
// the delete events so reviewers see who was reactivated; `reason` /
|
|
431
414
|
// `attempted_account_id` carry the not-found failure shape. Admin-only —
|
|
432
415
|
// the self path is unreachable (a tombstoned account can't authenticate).
|
|
433
|
-
account_undelete:
|
|
434
|
-
username:
|
|
435
|
-
email:
|
|
436
|
-
.
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
.optional()
|
|
443
|
-
.meta({ description: 'Failure category. Set only on `outcome=failure`.' }),
|
|
444
|
-
attempted_account_id: Uuid.optional().meta({
|
|
416
|
+
account_undelete: loose_object({
|
|
417
|
+
username: meta(optional(string), { description: 'Username at reactivation time.' }),
|
|
418
|
+
email: meta(optional(nullable(string)), {
|
|
419
|
+
description: 'Email at reactivation time; null when unset.'
|
|
420
|
+
}),
|
|
421
|
+
reason: meta(optional(string), {
|
|
422
|
+
description: 'Failure category. Set only on `outcome=failure`.'
|
|
423
|
+
}),
|
|
424
|
+
attempted_account_id: meta(optional(Uuid), {
|
|
445
425
|
description: 'Probed account id when the target was missing/not-deleted (`outcome=failure`).'
|
|
446
426
|
})
|
|
447
427
|
}),
|
|
448
|
-
actor_delete:
|
|
449
|
-
name:
|
|
428
|
+
actor_delete: loose_object({
|
|
429
|
+
name: meta(optional(string), { description: 'Actor display name at soft-delete time.' })
|
|
450
430
|
}),
|
|
451
|
-
actor_purge:
|
|
452
|
-
name:
|
|
431
|
+
actor_purge: loose_object({
|
|
432
|
+
name: meta(optional(string), { description: 'Actor display name at purge time.' })
|
|
453
433
|
}),
|
|
454
|
-
actor_undelete:
|
|
455
|
-
name:
|
|
434
|
+
actor_undelete: loose_object({
|
|
435
|
+
name: meta(optional(string), { description: 'Actor display name at reactivation time.' })
|
|
456
436
|
}),
|
|
457
|
-
app_settings_update:
|
|
458
|
-
setting:
|
|
459
|
-
old_value:
|
|
460
|
-
new_value:
|
|
437
|
+
app_settings_update: loose_object({
|
|
438
|
+
setting: meta(string, { description: 'Name of the setting that changed.' }),
|
|
439
|
+
old_value: meta(unknown, { description: 'Setting value before the update.' }),
|
|
440
|
+
new_value: meta(unknown, { description: 'Setting value after the update.' })
|
|
461
441
|
}),
|
|
462
442
|
// Row deleted through the generic db-admin table browser
|
|
463
443
|
// (`http/db_routes.ts` / the Rust spine's `fuz_db_admin`). Account-grain
|
|
464
444
|
// attribution (`account_id`, no `actor_id`) — the browser's gate is
|
|
465
445
|
// account-grain by construction. Emitted only on a successful delete;
|
|
466
446
|
// post-composite-refusal the delete is provably single-row, so no count.
|
|
467
|
-
db_admin_row_delete:
|
|
468
|
-
table:
|
|
469
|
-
pk_column:
|
|
447
|
+
db_admin_row_delete: loose_object({
|
|
448
|
+
table: meta(string, { description: 'Table the row was deleted from.' }),
|
|
449
|
+
pk_column: meta(string, {
|
|
470
450
|
description: 'Single primary-key column the `DELETE` filtered on.'
|
|
471
451
|
}),
|
|
472
|
-
id:
|
|
452
|
+
id: meta(string, {
|
|
473
453
|
description: "Primary-key value of the deleted row, as the row's canonical `::text` rendering."
|
|
474
454
|
})
|
|
475
455
|
})
|
|
@@ -491,7 +471,7 @@ export const builtin_audit_log_config = Object.freeze({
|
|
|
491
471
|
* `AppDeps.audit` emitter. Builtin handlers omit the `audit_log_config`
|
|
492
472
|
* slot and pick up `builtin_audit_log_config`.
|
|
493
473
|
*
|
|
494
|
-
* @throws Error when an `extra_events` key collides with a builtin event type or fails `AuditEventTypeName` format validation
|
|
474
|
+
* @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
475
|
*/
|
|
496
476
|
export const create_audit_log_config = (options) => {
|
|
497
477
|
const extras = options?.extra_events;
|
|
@@ -507,13 +487,15 @@ export const create_audit_log_config = (options) => {
|
|
|
507
487
|
if (builtin_set.has(t)) {
|
|
508
488
|
throw new Error(`extra_events key "${t}" collides with a builtin event type — pick a distinct string (e.g. "app_${t}")`);
|
|
509
489
|
}
|
|
510
|
-
const name_check = AuditEventTypeName
|
|
511
|
-
if (!name_check.
|
|
512
|
-
throw new Error(`extra_events key "${t}" has invalid format: ${name_check.
|
|
490
|
+
const name_check = parse(AuditEventTypeName, t);
|
|
491
|
+
if (!name_check.ok) {
|
|
492
|
+
throw new Error(`extra_events key "${t}" has invalid format: ${format_issue(name_check.issues[0])}`);
|
|
513
493
|
}
|
|
514
494
|
extra_keys.push(t);
|
|
515
|
-
if (schema !== null)
|
|
495
|
+
if (schema !== null) {
|
|
496
|
+
assert_validation_schema(schema, `extra_events key "${t}"`);
|
|
516
497
|
metadata_schemas[t] = schema;
|
|
498
|
+
}
|
|
517
499
|
}
|
|
518
500
|
return Object.freeze({
|
|
519
501
|
event_types: Object.freeze([...AUDIT_EVENT_TYPES, ...extra_keys]),
|
|
@@ -523,7 +505,7 @@ export const create_audit_log_config = (options) => {
|
|
|
523
505
|
/** Default page size for audit log listings. */
|
|
524
506
|
export const AUDIT_LOG_DEFAULT_LIMIT = 50;
|
|
525
507
|
/**
|
|
526
|
-
*
|
|
508
|
+
* Client-safe audit log event, a `@fuzdev/fuz_schema` schema.
|
|
527
509
|
*
|
|
528
510
|
* `event_type` is `AuditEventTypeName` (regex-validated string, at most
|
|
529
511
|
* `NAME_LENGTH_MAX` characters) — matches
|
|
@@ -531,32 +513,41 @@ export const AUDIT_LOG_DEFAULT_LIMIT = 50;
|
|
|
531
513
|
* types registered via `create_audit_log_config({extra_events})` round-trip
|
|
532
514
|
* through queries, `on_audit_event` callbacks, and JSON-RPC responses
|
|
533
515
|
* identically to builtins. `AuditLogInput<T>` stays parameterized on the
|
|
534
|
-
* write side so `AuditMetadataMap` narrows metadata per event type.
|
|
516
|
+
* write side so `AuditMetadataMap` narrows metadata per event type. `seq` is
|
|
517
|
+
* an integer within `Number.MAX_SAFE_INTEGER`, the integers a JSON number
|
|
518
|
+
* holds exactly.
|
|
535
519
|
*/
|
|
536
|
-
export const AuditLogEventJson =
|
|
520
|
+
export const AuditLogEventJson = object({
|
|
537
521
|
id: Uuid,
|
|
538
|
-
seq:
|
|
522
|
+
seq: pipe(number, safe_integer),
|
|
539
523
|
event_type: AuditEventTypeName,
|
|
540
524
|
outcome: AuditOutcome,
|
|
541
|
-
actor_id:
|
|
542
|
-
account_id:
|
|
543
|
-
target_account_id:
|
|
544
|
-
target_actor_id:
|
|
545
|
-
ip:
|
|
546
|
-
created_at:
|
|
547
|
-
metadata:
|
|
525
|
+
actor_id: nullable(Uuid),
|
|
526
|
+
account_id: nullable(Uuid),
|
|
527
|
+
target_account_id: nullable(Uuid),
|
|
528
|
+
target_actor_id: nullable(Uuid),
|
|
529
|
+
ip: nullable(string),
|
|
530
|
+
created_at: Timestamp,
|
|
531
|
+
metadata: nullable(record(unknown))
|
|
548
532
|
});
|
|
549
|
-
/**
|
|
550
|
-
export const AuditLogEventWithUsernamesJson =
|
|
551
|
-
|
|
552
|
-
|
|
533
|
+
/** Audit log events with resolved usernames, a `@fuzdev/fuz_schema` schema. */
|
|
534
|
+
export const AuditLogEventWithUsernamesJson = object({
|
|
535
|
+
...AuditLogEventJson.def,
|
|
536
|
+
username: nullable(string),
|
|
537
|
+
target_username: nullable(string)
|
|
553
538
|
});
|
|
554
|
-
/**
|
|
555
|
-
export const RoleGrantHistoryEventJson =
|
|
556
|
-
|
|
557
|
-
|
|
539
|
+
/** Role_grant history events with resolved usernames, a `@fuzdev/fuz_schema` schema. */
|
|
540
|
+
export const RoleGrantHistoryEventJson = object({
|
|
541
|
+
...AuditLogEventJson.def,
|
|
542
|
+
username: nullable(string),
|
|
543
|
+
target_username: nullable(string)
|
|
558
544
|
});
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
545
|
+
const { is_current: _, ...admin_session_entries } = AuthSessionJson.def;
|
|
546
|
+
/**
|
|
547
|
+
* Admin session listing (session + username, without `is_current`), a
|
|
548
|
+
* `@fuzdev/fuz_schema` schema. `username` is a plain string.
|
|
549
|
+
*/
|
|
550
|
+
export const AdminSessionJson = object({
|
|
551
|
+
...admin_session_entries,
|
|
552
|
+
username: string
|
|
562
553
|
});
|