@fuzdev/fuz_app 0.162.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 +38 -35
- package/dist/auth/account_action_specs.d.ts +441 -115
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +47 -46
- package/dist/auth/account_route_schema.d.ts +120 -60
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +50 -36
- package/dist/auth/account_routes.js +1 -1
- package/dist/auth/account_schema.d.ts +54 -27
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +16 -18
- package/dist/auth/admin_action_specs.d.ts +20 -20
- package/dist/auth/admin_action_specs.js +2 -4
- 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_log_schema.d.ts +28 -48
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +34 -30
- 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/migrations.js +1 -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.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.js +2 -2
- package/dist/auth/role_grant_offer_schema.d.ts +2 -2
- package/dist/auth/role_grant_offer_schema.js +2 -2
- 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/primitive_schemas.d.ts +2 -19
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +2 -20
- package/dist/primitive_schemas_fuz.d.ts +22 -2
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +23 -4
- package/dist/testing/CLAUDE.md +22 -5
- 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/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 +39 -6
- 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/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/integration.js +1 -1
- 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/package.json +1 -1
- package/dist/auth/audit_log_schema_fuz.d.ts +0 -53
- package/dist/auth/audit_log_schema_fuz.d.ts.map +0 -1
- package/dist/auth/audit_log_schema_fuz.js +0 -50
- 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
package/dist/auth/CLAUDE.md
CHANGED
|
@@ -33,9 +33,9 @@ over the pool so rows persist when request transactions roll back. See root
|
|
|
33
33
|
|
|
34
34
|
- `auth/keyring.ts` — `Keyring`, `create_keyring` (validates — the one way to build a `Keyring`), `validate_keyring`.
|
|
35
35
|
- `auth/session_cookie.ts` — `SessionOptions<T>`, `parse_session`, `process_session_cookie` (`'none' | 'clear'` — no refresh action; the 30-day lifetime is an absolute cap signed once at mint), `create_session_config`, `fuz_session_config`, `SESSION_AGE_MAX`.
|
|
36
|
-
- `auth/password.ts` — `Password`, `PasswordProvided
|
|
36
|
+
- `auth/password.ts` — `Password`, `PasswordProvided` (`@fuzdev/fuz_schema` schemas), `PasswordHashDeps`, `PASSWORD_LENGTH_MIN` (12, OWASP), `PASSWORD_LENGTH_MAX` (300).
|
|
37
37
|
- `auth/password_argon2.ts` — `hash_password`, `verify_password`, `verify_dummy`, `argon2_password_deps`.
|
|
38
|
-
- `auth/api_token.ts` — `API_TOKEN_PREFIX` (`secret_fuz_token_`), `hash_api_token`, `generate_api_token`, and the shape precheck `is_api_token_shaped` (`API_TOKEN_REGEX`: the prefix plus exactly `API_TOKEN_BODY_LENGTH` = 43 base64url chars).
|
|
38
|
+
- `auth/api_token.ts` — `API_TOKEN_PREFIX` (`secret_fuz_token_`), `ApiTokenId` (the public id, `pipe(string, regex(API_TOKEN_ID_REGEX))`, a `@fuzdev/fuz_schema` schema), `hash_api_token`, `generate_api_token`, and the shape precheck `is_api_token_shaped` (`API_TOKEN_REGEX`: the prefix plus exactly `API_TOKEN_BODY_LENGTH` = 43 base64url chars).
|
|
39
39
|
- `auth/daemon_token.ts` — `DaemonToken`, `DAEMON_TOKEN_HEADER` (`X-Daemon-Token`), `generate_daemon_token`, `validate_daemon_token`, `DaemonTokenState`.
|
|
40
40
|
- `auth/bootstrap_account.ts` — `bootstrap_account` (one-shot, `bootstrap_lock`-protected) + `read_bootstrap_token`, the read both it and `check_bootstrap_status` use: the secure read less one trailing LF, a token under `BOOTSTRAP_TOKEN_MIN_BYTES` (32) refused as unreadable with an error log.
|
|
41
41
|
|
|
@@ -54,25 +54,22 @@ Cross-cutting notes that don't live on any single symbol:
|
|
|
54
54
|
|
|
55
55
|
### Schemas, types, DDL
|
|
56
56
|
|
|
57
|
-
Convention — `*_schema.ts` holds a domain's schemas, Zod or `@fuzdev/fuz_schema`;
|
|
58
|
-
|
|
59
|
-
- `auth/account_schema.ts` — `Account`, `Actor`, `RoleGrant`, `AuthSession`, `ApiToken` + client-safe JSON shapes, `@fuzdev/fuz_schema` schemas
|
|
60
|
-
- `auth/name_schema.ts` — the name grammar the auth vocabularies share: `NAME_REGEX` (runs of lowercase letters joined by single underscores), `NAME_LENGTH_MAX` (64), `is_valid_name`, `create_name_schema(label)` (the
|
|
61
|
-
- `auth/role_schema.ts` — `RoleName` (`create_name_schema('Role')`: lowercase letters and underscores, no leading, trailing or consecutive underscores, at most `NAME_LENGTH_MAX` = 64 characters — the grammar every `role` input and every registered role holds, twin of the Rust `is_valid_name`), its messages (`ROLE_NAME_LENGTH_MESSAGE`, `ROLE_NAME_PATTERN_MESSAGE`), `RoleSpec`, `ROLE_KEEPER`, `ROLE_ADMIN`, `
|
|
62
|
-
- `auth/
|
|
63
|
-
- `auth/
|
|
64
|
-
- `auth/
|
|
65
|
-
- `auth/
|
|
66
|
-
- `auth/
|
|
67
|
-
- `auth/token_scope.ts` — per-credential authority narrowing stored on `api_token.scope`: `TokenScope` / `TokenScopeInput` + constructors, `parse_stored_token_scope` (fail-closed), `token_scope_admits_method` / `_non_rpc`, and the `<section>:<id>` capability vocabulary (`token_scope_method_capability` for the dispatcher's `rpc:<method>`, `is_route_scope_capability` for the `surface:<name>` a `RouteAuth.required_scope` may declare, `token_scope_denied_body`, `TOKEN_SURFACES`). Not an open registry — see ../../../docs/security.md §Token scoping for why the identifier half is deliberately unregistered.
|
|
57
|
+
Convention — `*_schema.ts` holds a domain's schemas, Zod or `@fuzdev/fuz_schema`; `*_ddl.ts` holds DDL strings.
|
|
58
|
+
|
|
59
|
+
- `auth/account_schema.ts` — `Account`, `Actor`, `RoleGrant`, `AuthSession`, `ApiToken` + client-safe JSON shapes, `@fuzdev/fuz_schema` schemas: `SessionId` (`brand(Blake3Hash, 'SessionId')`, minted by `hash_session_token`), `SessionAccountJson` and `AdminAccountJson` (their `username` `UsernameCanonical`, so a username in another case fails), `AuthSessionJson`, `RoleGrantSummaryJson` and `PendingOfferSummaryJson` (`role` a `RoleName`, `scope_kind` a `ScopeKindName` or `null`), `ActorSummaryJson`, `AdminAccountEntryJson`, `ClientApiTokenJson` (`id` an `ApiTokenId`); every timestamp a `Timestamp`. Grant predicates over wire fields: `is_role_grant_active` (not revoked, not expired) and `has_global_role(role_grants, role, now?)` (an active grant of the role with `scope_id === null` — the bare-list form of `has_scoped_role(ctx, role, null)`, used client-side by `AuthState`).
|
|
60
|
+
- `auth/name_schema.ts` — the name grammar the auth vocabularies share: `NAME_REGEX` (runs of lowercase letters joined by single underscores), `NAME_LENGTH_MAX` (64), `is_valid_name`, `create_name_schema(label)` (the `@fuzdev/fuz_schema` schema, `pipe(bounded_string, message(regex))`: a string too long and off the grammar gets the one length issue, a value that is no string fuz_schema's message; its JSON Schema `maxLength` and `pattern`) and the message builders `format_name_length_message` / `format_name_pattern_message`, so each domain keeps its own label in its messages. `RoleName`, `ScopeKindName`, `GrantPathName`, `CredentialTypeName` and a token's `surface:` name (`is_route_scope_capability`) hold it; `AuditEventTypeName` takes its cap over its own grammar. Twin of the Rust `fuz_auth::is_valid_name` / `NAME_LENGTH_MAX`.
|
|
61
|
+
- `auth/role_schema.ts` — `RoleName` (`create_name_schema('Role')`: lowercase letters and underscores, no leading, trailing or consecutive underscores, at most `NAME_LENGTH_MAX` = 64 characters — the grammar every `role` input and every registered role holds, twin of the Rust `is_valid_name`), its messages (`ROLE_NAME_LENGTH_MESSAGE`, `ROLE_NAME_PATTERN_MESSAGE`), `RoleSpec`, `ROLE_KEEPER`, `ROLE_ADMIN`, `BUILTIN_ROLES` and its type `BuiltinRole`, `is_builtin_role`, `create_role_registry` (returns `{role_specs}`), `builtin_role_specs`, `role_has_grant_path`, `list_roles_with_grant_path`. Pinned against a Zod copy by `role_schema.name.test.ts`.
|
|
62
|
+
- `auth/scope_kind_schema.ts` — `ScopeKindName`, the constants its messages come from (`SCOPE_KIND_NAME_LENGTH_MESSAGE`, `SCOPE_KIND_NAME_PATTERN_MESSAGE`), `create_scope_kind_registry` (open registry, no builtins; returns `{scope_kinds}`). `ScopeKindName` (`create_name_schema('Scope-kind')`, grammar and cap) checks a registered name and the `scope_kind` on `role_grant_offer_create` / `role_grant_assign`, which is copied into the row and its audit metadata; off the grammar is the partial unique indexes' `'GLOBAL'` token. Pinned against a Zod copy by `scope_kind_schema.name.test.ts`.
|
|
63
|
+
- `auth/credential_type_schema.ts` — `CredentialTypeName` (`create_name_schema('Credential-type')`), `CREDENTIAL_TYPE_SESSION` / `_API_TOKEN` / `_DAEMON_TOKEN`, `BUILTIN_CREDENTIAL_TYPES` and its type `BuiltinCredentialType`, `create_credential_type_registry` (returns `{credential_types}`).
|
|
64
|
+
- `auth/grant_path_schema.ts` — `GrantPathName` (`create_name_schema('Grant-path')`), `GRANT_PATH_ADMIN` / `_SELF_SERVICE` / `_SYSTEM` / `_BOOTSTRAP`, `BUILTIN_GRANT_PATHS` and its type `BuiltinGrantPath`, `create_grant_path_registry` (returns `{grant_paths}`).
|
|
65
|
+
- `auth/token_lifetime.ts` — the temporal axis of a minted token: `TokenLifetimeInput` (required `variant` on `account_token_create` — `{kind:'eternal'}` or `{kind:'ttl', days}`, a `@fuzdev/fuz_schema` schema), `token_lifetime_to_expires_at`, `TOKEN_TTL_DAYS_MAX`. No default — `expires_at IS NULL` always means "deliberately eternal".
|
|
66
|
+
- `auth/token_scope.ts` — per-credential authority narrowing stored on `api_token.scope`: `TokenScope` / `TokenScopeInput` (`@fuzdev/fuz_schema` `variant`s of strict `object` arms) + constructors, `parse_stored_token_scope` (fail-closed; the `MAX_TOKEN_SCOPE_BYTES` cap counts UTF-8 bytes of the compact document at mint and at read, as the Rust spine does), `token_scope_admits_method` / `_non_rpc`, and the `<section>:<id>` capability vocabulary (`token_scope_method_capability` for the dispatcher's `rpc:<method>`, `is_route_scope_capability` for the `surface:<name>` a `RouteAuth.required_scope` may declare, `token_scope_denied_body`, `TOKEN_SURFACES`). Not an open registry — see ../../../docs/security.md §Token scoping for why the identifier half is deliberately unregistered.
|
|
68
67
|
- `auth/auth_ddl.ts` — `CREATE TABLE` / index / seed strings for the core identity tables.
|
|
69
|
-
- `auth/audit_log_schema.ts` — `AUDIT_EVENT_TYPES` (the builtin event types)
|
|
70
|
-
- `auth/audit_log_schema_fuz.ts` — the `@fuzdev/fuz_schema` twins of `AuditEventTypeName` and `AuditOutcome` under the same names (`@nodocs` while the Zod ones stay), and the grammar and messages both are built from (`AUDIT_EVENT_TYPE_NAME_REGEX`, `AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE`, `AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE`), here because `audit_log_schema.ts` builds its rows from the twins: the same verdict, output and JSON Schema as the Zod ones, and their messages, but for the one length issue of a name too long and off the grammar. Pinned by `audit_log_schema_fuz.test.ts`. `audit_log_list`'s input declares them.
|
|
68
|
+
- `auth/audit_log_schema.ts` — `@fuzdev/fuz_schema` throughout: `AUDIT_EVENT_TYPES` (the builtin event types) and the type `AuditEventType` (`(typeof AUDIT_EVENT_TYPES)[number]`), `AuditEventTypeName` (`pipe(bounded_string, message(regex))`, `AUDIT_EVENT_TYPE_NAME_REGEX` under `NAME_LENGTH_MAX`, with `AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE` / `AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE`; a name too long and off the grammar gets the one length issue), `AuditOutcome` (`one_of(['success', 'failure'])`), `audit_metadata_schemas`, `AuditLogEvent`, `AuditLogInput`, `AuditLogConfig` (`metadata_schemas` of either library), `create_audit_log_config` (refuses an `extra_events` key off `AuditEventTypeName` with its first issue's message), and the wire rows `AuditLogEventJson` (`seq` `pipe(number, safe_integer)`, `created_at` a `Timestamp`), `AuditLogEventWithUsernamesJson`, `RoleGrantHistoryEventJson` and `AdminSessionJson`. `audit_log_list`'s input declares `AuditEventTypeName` and `AuditOutcome`. Pinned against Zod copies by `audit_log_schema.names.test.ts`.
|
|
71
69
|
- `auth/audit_log_ddl.ts` — `audit_log` table DDL with `seq BIGSERIAL` for cursor-based gap fill (BIGSERIAL converges with the Rust spine; `create_db` registers a `pg.types` int8 parser so `seq` still reads as a JS number).
|
|
72
70
|
- `auth/invite_schema.ts` — `Invite`, `CreateInviteInput`, and the `@fuzdev/fuz_schema` rows `InviteJson` (`username` a `UsernameCanonical` or `null`, timestamps `Timestamp`s) and `InviteWithUsernamesJson`, whose resolved names are plain strings.
|
|
73
71
|
- `auth/app_settings_schema.ts` — `AppSettings` (single-row via `CHECK (id = 1)`) and its `@fuzdev/fuz_schema` schemas `AppSettingsJson` and `AppSettingsWithUsernameJson`.
|
|
74
|
-
- `auth/
|
|
75
|
-
- `auth/role_grant_offer_schema.ts` — `RoleGrantOffer`, `RoleGrantOfferJson` (a `@fuzdev/fuz_schema` `object`: `role` the fuz_schema `RoleName`, `scope_kind` the fuz_schema `ScopeKindName` or `null`, so an offer row holding a name off either grammar fails it), `to_role_grant_offer_json`.
|
|
72
|
+
- `auth/role_grant_offer_schema.ts` — `RoleGrantOffer`, `RoleGrantOfferJson` (a `@fuzdev/fuz_schema` `object`: `role` a `RoleName`, `scope_kind` a `ScopeKindName` or `null`, so an offer row holding a name off either grammar fails it), `to_role_grant_offer_json`.
|
|
76
73
|
- `auth/role_grant_offer_ddl.ts` — `role_grant_offer` table + indexes + `ROLE_GRANT_OFFER_SCOPE_SENTINEL_UUID` / `_GLOBAL_TOKEN` + `ROLE_GRANT_OFFER_COLUMNS` and the shared `ROLE_GRANT_OFFER_WITH_GRANTOR_SELECT` CTE tail (homed here per the placement rule in `db/sql_columns.ts`).
|
|
77
74
|
- `auth/role_grant_sql.ts` — the liveness predicates every grant and offer read shares: `role_grant_active_sql(alias)` (not revoked, not expired) and `offer_pending_predicate(alias)` (every `OFFER_TERMINAL_COLUMNS` entry null), twins of the Rust spine's. The frozen partial-index DDL keeps its literal text.
|
|
78
75
|
- `auth/role_grant_offer_notifications.ts` — the WS notification specs for the consentful-grant lifecycle, their `@fuzdev/fuz_schema` params, builders, `role_grant_offer_notification_actions`, `role_grant_offer_notification_specs`, and `create_validated_notification_sender`.
|
|
@@ -217,7 +214,15 @@ attack surface — and a backend-spawning consumer assembling its surface import
|
|
|
217
214
|
the shapes without dragging `hono/cookie` / `hono/streaming` (and the optional
|
|
218
215
|
`hono` peer) onto a Rust-only cross-process suite. Shared route-limit constants
|
|
219
216
|
(`DEFAULT_MAX_SESSIONS` / `_TOKENS`) live in `account_route_schema.ts` for the
|
|
220
|
-
same reason (the RPC `account_actions` reads `DEFAULT_MAX_TOKENS`).
|
|
217
|
+
same reason (the RPC `account_actions` reads `DEFAULT_MAX_TOKENS`). The
|
|
218
|
+
account, signup and bootstrap shapes' schemas, error bodies included, are
|
|
219
|
+
`@fuzdev/fuz_schema` schemas: `/login` takes `UsernameProvided` and
|
|
220
|
+
`PasswordProvided`; the output `username` of `/logout`, `/signup` and
|
|
221
|
+
`/bootstrap` is a `UsernameCanonical`; `/password`'s revoke counts are
|
|
222
|
+
non-negative integers; `/bootstrap`'s `token` is 1 to
|
|
223
|
+
`BOOTSTRAP_TOKEN_LENGTH_MAX` (4096, the token file's cap) UTF-16 code units,
|
|
224
|
+
a longer one a `400 invalid_request_body` before the window check, with no
|
|
225
|
+
audit row — twin of the Rust `BOOTSTRAP_TOKEN_LENGTH_MAX`.
|
|
221
226
|
|
|
222
227
|
**`POST /login` timing floor.** Login 401s are floored to
|
|
223
228
|
`DEFAULT_LOGIN_FAIL_FLOOR_MS` (250ms) + uniform jitter (±25ms) via
|
|
@@ -495,7 +500,7 @@ index-backed, matching the Rust twin (which aliases nothing, so its bare
|
|
|
495
500
|
Four open string registries — `RoleName`, `ScopeKindName`,
|
|
496
501
|
`CredentialTypeName`, `GrantPathName` — share the same factory shape:
|
|
497
502
|
construction-time guards (name regex, duplicate detection, builtin-collision
|
|
498
|
-
rejection), `ReadonlyMap` output, pass into `
|
|
503
|
+
rejection), `ReadonlyMap` output, pass into `create_role_registry` for
|
|
499
504
|
cross-axis validation. The four share one name grammar, runs of lowercase
|
|
500
505
|
letters joined by single underscores, at most `NAME_LENGTH_MAX` characters
|
|
501
506
|
(`auth/name_schema.ts`), which a token's `surface:` name holds too.
|
|
@@ -503,9 +508,9 @@ letters joined by single underscores, at most `NAME_LENGTH_MAX` characters
|
|
|
503
508
|
Dependency flow:
|
|
504
509
|
|
|
505
510
|
```
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
511
|
+
create_credential_type_registry()
|
|
512
|
+
create_scope_kind_registry() → create_role_registry({roles, options}) → role_specs
|
|
513
|
+
create_grant_path_registry()
|
|
509
514
|
```
|
|
510
515
|
|
|
511
516
|
`role_specs` drives downstream defaults:
|
|
@@ -729,7 +734,7 @@ on invite delete. `invite_create` empty input is rejected at the schema via
|
|
|
729
734
|
|
|
730
735
|
Closure state:
|
|
731
736
|
|
|
732
|
-
- `grantable_roles` derived once from `options.roles?.role_specs ??
|
|
737
|
+
- `grantable_roles` derived once from `options.roles?.role_specs ?? builtin_role_specs`
|
|
733
738
|
via `list_roles_with_grant_path(_, GRANT_PATH_ADMIN)`.
|
|
734
739
|
- `app_settings_get`/`_update` handlers are always wired and read/write the DB
|
|
735
740
|
directly (`query_app_settings_load`/`query_app_settings_update`);
|
|
@@ -768,7 +773,7 @@ event additionally records `credential_type` in metadata (defense in depth).
|
|
|
768
773
|
|
|
769
774
|
The specs' inputs and outputs are `@fuzdev/fuz_schema` schemas
|
|
770
775
|
(`auth/role_grant_offer_action_specs.ts`), every object refusing unknown keys,
|
|
771
|
-
`role`
|
|
776
|
+
`role` a `RoleName`, `scope_kind` a `ScopeKindName`.
|
|
772
777
|
The create and assign inputs end in a `check` of `is_grant_scope_paired`
|
|
773
778
|
(`GRANT_SCOPE_PAIRED_MESSAGE`), run only on an input whose fields all passed;
|
|
774
779
|
the list and history inputs read an omitted input as a fresh `{}`
|
|
@@ -914,7 +919,7 @@ the payload — `revoked_by` is deliberately not in the `role_grant_revoked`
|
|
|
914
919
|
payload (the revokee doesn't need to learn the admin's identity). When
|
|
915
920
|
`notification_sender` is absent, WS fan-out is silently skipped.
|
|
916
921
|
|
|
917
|
-
Options: `roles?:
|
|
922
|
+
Options: `roles?: RoleRegistry` (drives admin-grant-path lookup),
|
|
918
923
|
`default_ttl_ms?` (defaults to `ROLE_GRANT_OFFER_DEFAULT_TTL_MS` = 30 days),
|
|
919
924
|
`authorize?: RoleGrantOfferCreateAuthorize`.
|
|
920
925
|
|
|
@@ -922,12 +927,12 @@ Options: `roles?: RoleSchemaResult` (drives admin-grant-path lookup),
|
|
|
922
927
|
|
|
923
928
|
`create_account_actions(deps, options?)` in `auth/account_actions.ts`.
|
|
924
929
|
|
|
925
|
-
- `account_verify_action_spec` — read; input `
|
|
926
|
-
- `account_session_list_action_spec` — read; input `
|
|
930
|
+
- `account_verify_action_spec` — read; input fuz_schema's `void`; output `SessionAccountJson`.
|
|
931
|
+
- `account_session_list_action_spec` — read; input fuz_schema's `void`; output `{sessions}`, each with `is_current` (the session the request authenticated with; `false` on every row for a bearer or daemon-token caller).
|
|
927
932
|
- `account_session_revoke_action_spec` — mutation; input `{session_id}`; output `{ok, revoked}`.
|
|
928
|
-
- `account_session_revoke_all_action_spec` — mutation; input `
|
|
929
|
-
- `account_token_create_action_spec` — mutation; input `{name?, scope, lifetime}` (both `scope` and `lifetime` required — default-deny at mint on both axes; `name` at most `API_TOKEN_NAME_LENGTH_MAX` = 255 characters, since it is copied into the audit row); output `{ok, token, id, name, expires_at}`. `scope` / `lifetime` declare `invalid_reason` `ERROR_TOKEN_SCOPE_INVALID` / `ERROR_TOKEN_LIFETIME_INVALID`, so every refusal of either carries it — the handler's over-cap scope refusal included.
|
|
930
|
-
- `account_token_list_action_spec` — read; input `
|
|
933
|
+
- `account_session_revoke_all_action_spec` — mutation; input fuz_schema's `void`; output `{ok, count}`, `count` a non-negative integer.
|
|
934
|
+
- `account_token_create_action_spec` — mutation; input `{name?, scope, lifetime}` (both `scope` and `lifetime` required — default-deny at mint on both axes; `name` at most `API_TOKEN_NAME_LENGTH_MAX` = 255 characters, since it is copied into the audit row); output `{ok, token, id, name, expires_at}`, `expires_at` a `Timestamp` or `null`. `scope` / `lifetime` declare `invalid_reason` `ERROR_TOKEN_SCOPE_INVALID` / `ERROR_TOKEN_LIFETIME_INVALID`, so every refusal of either carries it — the handler's over-cap scope refusal included.
|
|
935
|
+
- `account_token_list_action_spec` — read; input fuz_schema's `void`; output `{tokens}`, each a `ClientApiTokenJson`.
|
|
931
936
|
- `account_token_revoke_action_spec` — mutation; input `{token_id}`; output `{ok, revoked}`.
|
|
932
937
|
|
|
933
938
|
`account_verify` is intentionally on both surfaces: the REST `GET /verify`
|
|
@@ -938,10 +943,8 @@ rule-3 surface, refused to every narrowed token, and `GET /status` answers one
|
|
|
938
943
|
as the anonymous caller.
|
|
939
944
|
|
|
940
945
|
`session_id` validates as `SessionId`, the fuz_schema `Blake3Hash` branded;
|
|
941
|
-
`token_id` as `ApiTokenId` (`tok_[A-Za-z0-9_-]{12}`).
|
|
942
|
-
|
|
943
|
-
`account_verify`, `account_session_list` and `account_token_revoke` are
|
|
944
|
-
`@fuzdev/fuz_schema` schemas; the rest are Zod.
|
|
946
|
+
`token_id` as `ApiTokenId` (`tok_[A-Za-z0-9_-]{12}`). Every input and output
|
|
947
|
+
is a `@fuzdev/fuz_schema` schema.
|
|
945
948
|
|
|
946
949
|
Audit events via `deps.audit.emit` with `ip: ctx.client_ip`:
|
|
947
950
|
`session_revoke`, `session_revoke_all`, `token_create`, `token_revoke`. Every
|
|
@@ -993,7 +996,7 @@ account actions hits `method_not_found` on first admin-suite run.
|
|
|
993
996
|
`self_service_role_set({role, enabled})` toggles a global role_grant on the
|
|
994
997
|
caller. Idempotent in both directions (`changed: false` when the post-call
|
|
995
998
|
state already matched). Its input and output are `@fuzdev/fuz_schema`
|
|
996
|
-
`object`s, refusing unknown keys, `role`
|
|
999
|
+
`object`s, refusing unknown keys, `role` a `RoleName`.
|
|
997
1000
|
|
|
998
1001
|
Audit metadata carries `self_service: true` so admin reviewers can
|
|
999
1002
|
distinguish self-toggled role_grants. Eligibility derives from
|