@fuzdev/fuz_app 0.158.0 → 0.159.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 (42) hide show
  1. package/dist/auth/CLAUDE.md +9 -5
  2. package/dist/auth/audit_log_route_schema.d.ts +18 -6
  3. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  4. package/dist/auth/audit_log_route_schema.js +7 -3
  5. package/dist/auth/credential_type_schema.d.ts +4 -4
  6. package/dist/auth/credential_type_schema.d.ts.map +1 -1
  7. package/dist/auth/credential_type_schema.js +6 -6
  8. package/dist/auth/grant_path_schema.d.ts +4 -4
  9. package/dist/auth/grant_path_schema.d.ts.map +1 -1
  10. package/dist/auth/grant_path_schema.js +6 -6
  11. package/dist/auth/request_context.js +1 -1
  12. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  13. package/dist/auth/role_grant_offer_action_specs.js +9 -6
  14. package/dist/auth/role_grant_offer_ddl.d.ts +5 -4
  15. package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
  16. package/dist/auth/role_grant_offer_ddl.js +5 -4
  17. package/dist/auth/role_schema.d.ts +15 -2
  18. package/dist/auth/role_schema.d.ts.map +1 -1
  19. package/dist/auth/role_schema.js +17 -4
  20. package/dist/auth/role_schema_fuz.d.ts +29 -0
  21. package/dist/auth/role_schema_fuz.d.ts.map +1 -0
  22. package/dist/auth/role_schema_fuz.js +28 -0
  23. package/dist/auth/scope_kind_schema.d.ts +22 -15
  24. package/dist/auth/scope_kind_schema.d.ts.map +1 -1
  25. package/dist/auth/scope_kind_schema.js +24 -17
  26. package/dist/auth/self_service_role_action_specs.d.ts +70 -27
  27. package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
  28. package/dist/auth/self_service_role_action_specs.js +16 -14
  29. package/dist/auth/token_scope.d.ts +3 -2
  30. package/dist/auth/token_scope.d.ts.map +1 -1
  31. package/dist/auth/token_scope.js +4 -3
  32. package/dist/http/CLAUDE.md +6 -0
  33. package/dist/http/db_routes.d.ts.map +1 -1
  34. package/dist/http/db_routes.js +8 -3
  35. package/dist/server/serve_fact_route.d.ts.map +1 -1
  36. package/dist/server/serve_fact_route.js +3 -2
  37. package/dist/server/surface_route.d.ts.map +1 -1
  38. package/dist/server/surface_route.js +3 -2
  39. package/dist/testing/CLAUDE.md +12 -8
  40. package/dist/testing/cross_backend/role_grant_role_grammar.d.ts.map +1 -1
  41. package/dist/testing/cross_backend/role_grant_role_grammar.js +94 -6
  42. package/package.json +1 -1
@@ -57,8 +57,9 @@ Cross-cutting notes that don't live on any single symbol:
57
57
  Convention — `*_schema.ts` is Zod-only; `*_ddl.ts` holds DDL strings.
58
58
 
59
59
  - `auth/account_schema.ts` — `Account`, `Actor`, `RoleGrant`, `AuthSession`, `ApiToken` + client-safe JSON shapes. 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/role_schema.ts` — `RoleName` (lowercase letters and underscores, no leading or trailing underscore, at most `ROLE_NAME_LENGTH_MAX` = 64 characters — the grammar every `role` input and every registered role holds, twin of the Rust `is_valid_role_name`), `RoleSpec`, `ROLE_KEEPER`, `ROLE_ADMIN`, `is_builtin_role`, `create_role_schema`, `builtin_role_specs_by_name`, `role_has_grant_path`, `list_roles_with_grant_path`.
61
- - `auth/scope_kind_schema.ts` — `ScopeKindName`, `create_scope_kind_schema` (open registry, no builtins), `SCOPE_KIND_LENGTH_MAX` (64 — bounds 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).
60
+ - `auth/role_schema.ts` — `RoleName` (lowercase letters and underscores, no leading, trailing or consecutive underscores, at most `ROLE_NAME_LENGTH_MAX` = 64 characters — the grammar every `role` input and every registered role holds, twin of the Rust `is_valid_role_name`), the constants it is built from (`ROLE_NAME_PATTERN`, `ROLE_NAME_LENGTH_MESSAGE`, `ROLE_NAME_PATTERN_MESSAGE`), `RoleSpec`, `ROLE_KEEPER`, `ROLE_ADMIN`, `is_builtin_role`, `create_role_schema`, `builtin_role_specs_by_name`, `role_has_grant_path`, `list_roles_with_grant_path`.
61
+ - `auth/role_schema_fuz.ts` — the `@fuzdev/fuz_schema` twin of `RoleName` under the same name (`@nodocs` while the Zod one stays), `pipe(bounded_string({max, max_message}), message(regex(ROLE_NAME_PATTERN), ROLE_NAME_PATTERN_MESSAGE))` over the same constants: the same verdict, output and JSON Schema as the Zod one, and its messages; a string both too long and off the grammar gets the length issue alone, where Zod adds the grammar issue. Pinned by `role_schema_fuz.test.ts`. `self_service_role_set`'s input declares it; every other `role` input is the Zod one.
62
+ - `auth/scope_kind_schema.ts` — `ScopeKindName`, `create_scope_kind_schema` (open registry, no builtins), `SCOPE_KIND_LENGTH_MAX` (64). `ScopeKindName` (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.
62
63
  - `auth/credential_type_schema.ts` — `CredentialTypeName`, `CREDENTIAL_TYPE_SESSION` / `_API_TOKEN` / `_DAEMON_TOKEN`, `create_credential_type_schema`.
63
64
  - `auth/grant_path_schema.ts` — `GrantPathName`, `GRANT_PATH_ADMIN` / `_SELF_SERVICE` / `_SYSTEM` / `_BOOTSTRAP`, `create_grant_path_schema`.
64
65
  - `auth/token_lifetime.ts` — the temporal axis of a minted token: `TokenLifetimeInput` (required union on `account_token_create` — `{kind:'eternal'}` or `{kind:'ttl', days}`), `token_lifetime_to_expires_at`, `TOKEN_TTL_DAYS_MAX`. No default — `expires_at IS NULL` always means "deliberately eternal".
@@ -492,7 +493,9 @@ Four open string registries — `RoleName`, `ScopeKindName`,
492
493
  `CredentialTypeName`, `GrantPathName` — share the same factory shape:
493
494
  construction-time guards (name regex, duplicate detection, builtin-collision
494
495
  rejection), `ReadonlyMap` output, pass into `create_role_schema` for
495
- cross-axis validation.
496
+ cross-axis validation. The four share one name grammar, runs of lowercase
497
+ letters joined by single underscores, which a token's `surface:` name holds
498
+ too.
496
499
 
497
500
  Dependency flow:
498
501
 
@@ -755,7 +758,7 @@ event additionally records `credential_type` in metadata (defense in depth).
755
758
  > suite assume auto-accept and have to redesign their tests when they
756
759
  > discover otherwise.
757
760
 
758
- - `role_grant_offer_create_action_spec` — session-only; input `{to_account_id, to_actor_id?, role, scope_kind?, scope_id?, message?}` (`scope_kind` + `scope_id` paired — both or neither, else `invalid_params`); output `{offer}`.
761
+ - `role_grant_offer_create_action_spec` — session-only; input `{to_account_id, to_actor_id?, role, scope_kind?, scope_id?, message?}` (`scope_kind` a `ScopeKindName`; `scope_kind` + `scope_id` paired — both or neither, else `invalid_params`); output `{offer}`.
759
762
  - `role_grant_offer_accept_action_spec` — session-only; input `{offer_id}`; output `{role_grant_id, offer, superseded_offer_ids}`. Refuses a builtin-role offer that must not mint (see below), leaving it pending.
760
763
  - `role_grant_offer_decline_action_spec` — input `{offer_id, reason?}`; output `{offer}` (the declined offer, as accept answers its own).
761
764
  - `role_grant_offer_retract_action_spec` — input `{offer_id}`; output `{offer}` (the retracted offer).
@@ -958,7 +961,8 @@ account actions hits `method_not_found` on first admin-suite run.
958
961
  `auth/self_service_role_actions.ts`. One static action
959
962
  `self_service_role_set({role, enabled})` toggles a global role_grant on the
960
963
  caller. Idempotent in both directions (`changed: false` when the post-call
961
- state already matched).
964
+ state already matched). Its input and output are `@fuzdev/fuz_schema`
965
+ `object`s, refusing unknown keys, `role` the fuz_schema `RoleName` twin.
962
966
 
963
967
  Audit metadata carries `self_service: true` so admin reviewers can
964
968
  distinguish self-toggled role_grants. Eligibility derives from
@@ -10,13 +10,25 @@
10
10
  *
11
11
  * @module
12
12
  */
13
- import { z } from 'zod';
13
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
14
14
  import type { RouteSpec } from '../http/route_spec.js';
15
- /** Query schema for the audit-log SSE route — multi-actor admins pass `?acting=<uuid>`. */
16
- export declare const AuditStreamQuery: z.ZodObject<{
17
- acting: z.ZodOptional<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
18
- }, z.core.$strict>;
19
- export type AuditStreamQuery = z.infer<typeof AuditStreamQuery>;
15
+ /**
16
+ * Query schema for the audit-log SSE route, a `@fuzdev/fuz_schema` `object`
17
+ * that refuses unknown keys — multi-actor admins pass `?acting=<uuid>`.
18
+ */
19
+ export declare const AuditStreamQuery: import("@fuzdev/fuz_schema/schema.ts").Schema<{
20
+ acting?: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | undefined;
21
+ }, {
22
+ acting?: string | undefined;
23
+ }, "object", {
24
+ acting: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime">)[]> & {
25
+ readonly '~types'?: {
26
+ readonly input: string;
27
+ readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
28
+ } | undefined;
29
+ }>>;
30
+ }>;
31
+ export type AuditStreamQuery = Infer<typeof AuditStreamQuery>;
20
32
  /** Default role required to access the audit-log SSE route. */
21
33
  export declare const DEFAULT_AUDIT_STREAM_ROLE = "admin";
22
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"audit_log_route_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB;;kBAA0C,CAAC;AACxE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,UAAU,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACxC,gBAAe,MAAkC,KAC/C,IAAI,CAAC,SAAS,EAAE,SAAS,CA8B1B,CAAC"}
1
+ {"version":3,"file":"audit_log_route_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;EAAkC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,UAAU,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACxC,gBAAe,MAAkC,KAC/C,IAAI,CAAC,SAAS,EAAE,SAAS,CA8B1B,CAAC"}
@@ -11,9 +11,13 @@
11
11
  * @module
12
12
  */
13
13
  import { z } from 'zod';
14
- import { ActingActor } from '../http/auth_shape.js';
15
- /** Query schema for the audit-log SSE route — multi-actor admins pass `?acting=<uuid>`. */
16
- export const AuditStreamQuery = z.strictObject({ acting: ActingActor });
14
+ import { object } from '@fuzdev/fuz_schema/schema.ts';
15
+ import { ActingActor } from '../primitive_schemas_fuz.js';
16
+ /**
17
+ * Query schema for the audit-log SSE route, a `@fuzdev/fuz_schema` `object`
18
+ * that refuses unknown keys — multi-actor admins pass `?acting=<uuid>`.
19
+ */
20
+ export const AuditStreamQuery = object({ acting: ActingActor });
17
21
  /** Default role required to access the audit-log SSE route. */
18
22
  export const DEFAULT_AUDIT_STREAM_ROLE = 'admin';
19
23
  /**
@@ -22,10 +22,10 @@
22
22
  */
23
23
  import { z } from 'zod';
24
24
  /**
25
- * Letter (lowercase a-z) start and end (or single letter), with letters
26
- * and underscores in between. Mirrors `RoleName`, `ScopeKindName`,
27
- * `GrantPathName`. Rejects empty strings, leading or trailing
28
- * underscores, uppercase, and digits.
25
+ * Runs of lowercase letters (a-z) joined by single underscores, the grammar
26
+ * of `RoleName`, `ScopeKindName` and `GrantPathName` too. Rejects empty
27
+ * strings, leading, trailing or consecutive underscores, uppercase, and
28
+ * digits.
29
29
  */
30
30
  export declare const CREDENTIAL_TYPE_NAME_REGEX: RegExp;
31
31
  /** Zod schema for valid credential-type name strings. */
@@ -1 +1 @@
1
- {"version":3,"file":"credential_type_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/credential_type_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,QAAgC,CAAC;AAExE,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,aAK7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAE3D,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,mDAI3B,CAAC;AAEX,kDAAkD;AAClD,eAAO,MAAM,qBAAqB;;;;EAAmC,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAa/E,CAAC;AAEH,qFAAqF;AACrF,MAAM,WAAW,0BAA0B;IAC1C;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC;;;OAGG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,6BAA6B,GACzC,iBAAgB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAM,KACrD,0BA2BF,CAAC"}
1
+ {"version":3,"file":"credential_type_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/credential_type_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,QAAyB,CAAC;AAEjE,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,aAK7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAE3D,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,mDAI3B,CAAC;AAEX,kDAAkD;AAClD,eAAO,MAAM,qBAAqB;;;;EAAmC,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAa/E,CAAC;AAEH,qFAAqF;AACrF,MAAM,WAAW,0BAA0B;IAC1C;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC;;;OAGG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,6BAA6B,GACzC,iBAAgB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAM,KACrD,0BA2BF,CAAC"}
@@ -22,16 +22,16 @@
22
22
  */
23
23
  import { z } from 'zod';
24
24
  /**
25
- * Letter (lowercase a-z) start and end (or single letter), with letters
26
- * and underscores in between. Mirrors `RoleName`, `ScopeKindName`,
27
- * `GrantPathName`. Rejects empty strings, leading or trailing
28
- * underscores, uppercase, and digits.
25
+ * Runs of lowercase letters (a-z) joined by single underscores, the grammar
26
+ * of `RoleName`, `ScopeKindName` and `GrantPathName` too. Rejects empty
27
+ * strings, leading, trailing or consecutive underscores, uppercase, and
28
+ * digits.
29
29
  */
30
- export const CREDENTIAL_TYPE_NAME_REGEX = /^[a-z][a-z_]*[a-z]$|^[a-z]$/;
30
+ export const CREDENTIAL_TYPE_NAME_REGEX = /^[a-z]+(?:_[a-z]+)*$/;
31
31
  /** Zod schema for valid credential-type name strings. */
32
32
  export const CredentialTypeName = z
33
33
  .string()
34
- .regex(CREDENTIAL_TYPE_NAME_REGEX, 'Credential-type names must be lowercase letters and underscores (a-z_), no leading/trailing underscore');
34
+ .regex(CREDENTIAL_TYPE_NAME_REGEX, 'Credential-type names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores');
35
35
  // Builtin credential types — provided by fuz_app, always available.
36
36
  /** Cookie-based session credential. */
37
37
  export const CREDENTIAL_TYPE_SESSION = 'session';
@@ -26,10 +26,10 @@
26
26
  */
27
27
  import { z } from 'zod';
28
28
  /**
29
- * Letter (lowercase a-z) start and end (or single letter), with letters
30
- * and underscores in between. Mirrors `RoleName`, `ScopeKindName`,
31
- * `CredentialTypeName`. Rejects empty strings, leading or trailing
32
- * underscores, uppercase, and digits.
29
+ * Runs of lowercase letters (a-z) joined by single underscores, the grammar
30
+ * of `RoleName`, `ScopeKindName` and `CredentialTypeName` too. Rejects empty
31
+ * strings, leading, trailing or consecutive underscores, uppercase, and
32
+ * digits.
33
33
  */
34
34
  export declare const GRANT_PATH_NAME_REGEX: RegExp;
35
35
  /** Zod schema for valid grant-path name strings. */
@@ -1 +1 @@
1
- {"version":3,"file":"grant_path_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/grant_path_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAgC,CAAC;AAEnE,oDAAoD;AACpD,eAAO,MAAM,aAAa,aAKxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAA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aAKxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAI1D,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,2DAKtB,CAAC;AAEX,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB;;;;;EAA8B,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAuBrE,CAAC;AAEH,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,wBAAwB,GACpC,iBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,KAChD,qBA2BF,CAAC"}
@@ -26,16 +26,16 @@
26
26
  */
27
27
  import { z } from 'zod';
28
28
  /**
29
- * Letter (lowercase a-z) start and end (or single letter), with letters
30
- * and underscores in between. Mirrors `RoleName`, `ScopeKindName`,
31
- * `CredentialTypeName`. Rejects empty strings, leading or trailing
32
- * underscores, uppercase, and digits.
29
+ * Runs of lowercase letters (a-z) joined by single underscores, the grammar
30
+ * of `RoleName`, `ScopeKindName` and `CredentialTypeName` too. Rejects empty
31
+ * strings, leading, trailing or consecutive underscores, uppercase, and
32
+ * digits.
33
33
  */
34
- export const GRANT_PATH_NAME_REGEX = /^[a-z][a-z_]*[a-z]$|^[a-z]$/;
34
+ export const GRANT_PATH_NAME_REGEX = /^[a-z]+(?:_[a-z]+)*$/;
35
35
  /** Zod schema for valid grant-path name strings. */
36
36
  export const GrantPathName = z
37
37
  .string()
38
- .regex(GRANT_PATH_NAME_REGEX, 'Grant-path names must be lowercase letters and underscores (a-z_), no leading/trailing underscore');
38
+ .regex(GRANT_PATH_NAME_REGEX, 'Grant-path names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores');
39
39
  // Builtin grant paths — provided by fuz_app, always available.
40
40
  /** Admin-mediated grant — `role_grant_offer_create` plus admin-direct flows. */
41
41
  export const GRANT_PATH_ADMIN = 'admin';
@@ -331,7 +331,7 @@ export const get_public_account_id = (c) => {
331
331
  */
332
332
  export const require_token_scope = (capability) => {
333
333
  if (!is_route_scope_capability(capability)) {
334
- throw new Error(`auth.required_scope "${capability}" is not a valid token-scope capability for a route \u2014 expected 'surface:<name>', where a surface name is lowercase letters and underscores ('rpc:<method>' is the action dispatcher's per-method gate, which a route never reaches)`);
334
+ throw new Error(`auth.required_scope "${capability}" is not a valid token-scope capability for a route \u2014 expected 'surface:<name>', where a surface name is runs of lowercase letters joined by single underscores ('rpc:<method>' is the action dispatcher's per-method gate, which a route never reaches)`);
335
335
  }
336
336
  return async (c, next) => {
337
337
  const denied = token_scope_surface_denial(c, capability);
@@ -1 +1 @@
1
- {"version":3,"file":"role_grant_offer_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK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;;;;;;;;;;CAmBL,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,EAAE,KAAK,CAAC,yBAAyB,CAS9E,CAAC"}
@@ -24,7 +24,7 @@ import { z } from 'zod';
24
24
  import { Uuid, bounded_string } from '../primitive_schemas.js';
25
25
  import { ERROR_INSUFFICIENT_PERMISSIONS, ERROR_LIMIT_INVALID, ERROR_OFFSET_INVALID, ERROR_ROLE_GRANT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE } from '../http/error_schemas.js';
26
26
  import { RoleName } from './role_schema.js';
27
- import { SCOPE_KIND_LENGTH_MAX } from './scope_kind_schema.js';
27
+ import { SCOPE_KIND_LENGTH_MAX, ScopeKindName } from './scope_kind_schema.js';
28
28
  import { ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX, RoleGrantOfferJson } from './role_grant_offer_schema.js';
29
29
  import { ROLE_GRANT_REVOKED_REASON_LENGTH_MAX } from './account_schema.js';
30
30
  import { ActingActor } from '../http/auth_shape.js';
@@ -79,11 +79,14 @@ export const ERROR_CANNOT_REVOKE_LAST_ADMIN = 'cannot_revoke_last_admin';
79
79
  export const is_grant_scope_paired = (input) => (input.scope_kind == null) === (input.scope_id == null);
80
80
  /** The message a half-scoped grant input fails with — the grant inputs' refine, and the UI's pre-RPC guard. */
81
81
  export const GRANT_SCOPE_PAIRED_MESSAGE = "'scope_kind' and 'scope_id' must be given together (both for a scoped grant, neither for a global one)";
82
- /** The `scope_kind` field both grant inputs share, paired with `scope_id`. */
83
- const GrantScopeKind = bounded_string({ max: SCOPE_KIND_LENGTH_MAX })
84
- .nullish()
85
- .meta({
86
- description: `Machine-readable kind tag for \`scope_id\` — paired-null with \`scope_id\` (both null for global, both non-null for scoped). Required iff \`scope_id\` is set. At most ${SCOPE_KIND_LENGTH_MAX} characters.`
82
+ /**
83
+ * The `scope_kind` field both grant inputs share, paired with `scope_id`. A
84
+ * `ScopeKindName`, so off the grammar is refused at validation: the
85
+ * index-side `'GLOBAL'` token among it, which with the all-zeros uuid would
86
+ * otherwise equal a global grant's key in the partial unique indexes.
87
+ */
88
+ const GrantScopeKind = ScopeKindName.nullish().meta({
89
+ description: `Machine-readable kind tag for \`scope_id\` — paired-null with \`scope_id\` (both null for global, both non-null for scoped). Required iff \`scope_id\` is set. A scope-kind name: runs of lowercase letters (a-z) joined by single underscores, at most ${SCOPE_KIND_LENGTH_MAX} characters.`
87
90
  });
88
91
  // -- Input/output schemas ---------------------------------------------------
89
92
  /**
@@ -17,10 +17,11 @@
17
17
  /** Sentinel UUID used inside the partial unique indexes to collapse `scope_id IS NULL` into a comparable value. */
18
18
  export declare const ROLE_GRANT_OFFER_SCOPE_SENTINEL_UUID = "00000000-0000-0000-0000-000000000000";
19
19
  /**
20
- * Index-side token for the global case in the partial unique index. Uppercase
21
- * so it cannot collide with consumer-declared `ScopeKindName` values (which
22
- * are lowercase by regex). Never appears as a column value — column-level
23
- * `scope_kind = NULL` and `scope_id = NULL` together encode the global case.
20
+ * Index-side token for the global case in the partial unique index.
21
+ * Uppercase, so it is off the `ScopeKindName` grammar: no registry declares
22
+ * it, and the grant inputs refuse it, so no row they write holds it.
23
+ * Column-level `scope_kind = NULL` and `scope_id = NULL` together encode the
24
+ * global case.
24
25
  */
25
26
  export declare const ROLE_GRANT_OFFER_SCOPE_KIND_GLOBAL_TOKEN = "GLOBAL";
26
27
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"role_grant_offer_ddl.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_ddl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,mHAAmH;AACnH,eAAO,MAAM,oCAAoC,yCAAyC,CAAC;AAE3F;;;;;GAKG;AACH,eAAO,MAAM,wCAAwC,WAAW,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,4QAkBmB,CAAC;AAEzD;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,8DAQhC,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,oCAAoC,QAMI,CAAC;AAKtD,eAAO,MAAM,uBAAuB,qzCAkClC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qCAAqC,2XAYpB,CAAC;AAE/B,+EAA+E;AAC/E,eAAO,MAAM,4BAA4B,kOAMX,CAAC"}
1
+ {"version":3,"file":"role_grant_offer_ddl.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_ddl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,mHAAmH;AACnH,eAAO,MAAM,oCAAoC,yCAAyC,CAAC;AAE3F;;;;;;GAMG;AACH,eAAO,MAAM,wCAAwC,WAAW,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,4QAkBmB,CAAC;AAEzD;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,8DAQhC,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,oCAAoC,QAMI,CAAC;AAKtD,eAAO,MAAM,uBAAuB,qzCAkClC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qCAAqC,2XAYpB,CAAC;AAE/B,+EAA+E;AAC/E,eAAO,MAAM,4BAA4B,kOAMX,CAAC"}
@@ -18,10 +18,11 @@ import { iso8601_timestamp_expr, qualify_columns } from '../db/sql_columns.js';
18
18
  /** Sentinel UUID used inside the partial unique indexes to collapse `scope_id IS NULL` into a comparable value. */
19
19
  export const ROLE_GRANT_OFFER_SCOPE_SENTINEL_UUID = '00000000-0000-0000-0000-000000000000';
20
20
  /**
21
- * Index-side token for the global case in the partial unique index. Uppercase
22
- * so it cannot collide with consumer-declared `ScopeKindName` values (which
23
- * are lowercase by regex). Never appears as a column value — column-level
24
- * `scope_kind = NULL` and `scope_id = NULL` together encode the global case.
21
+ * Index-side token for the global case in the partial unique index.
22
+ * Uppercase, so it is off the `ScopeKindName` grammar: no registry declares
23
+ * it, and the grant inputs refuse it, so no row they write holds it.
24
+ * Column-level `scope_kind = NULL` and `scope_id = NULL` together encode the
25
+ * global case.
25
26
  */
26
27
  export const ROLE_GRANT_OFFER_SCOPE_KIND_GLOBAL_TOKEN = 'GLOBAL';
27
28
  /**
@@ -32,8 +32,21 @@ import type { ScopeKindSchemaResult } from './scope_kind_schema.js';
32
32
  */
33
33
  export declare const ROLE_NAME_LENGTH_MAX = 64;
34
34
  /**
35
- * Valid role name: lowercase letters and underscores, no leading/trailing
36
- * underscore, at most `ROLE_NAME_LENGTH_MAX` characters.
35
+ * The grammar of a role name: runs of lowercase letters joined by single
36
+ * underscores, so no leading, trailing or consecutive underscores. Both
37
+ * `RoleName`s hold it, the Zod one here and the `@fuzdev/fuz_schema` twin in
38
+ * `auth/role_schema_fuz.ts`, and the sibling name grammars are the same
39
+ * pattern: `GRANT_PATH_NAME_REGEX`, `CREDENTIAL_TYPE_NAME_REGEX`,
40
+ * `SCOPE_KIND_NAME_REGEX` and `TOKEN_SURFACE_NAME_REGEX`.
41
+ */
42
+ export declare const ROLE_NAME_PATTERN: RegExp;
43
+ /** The message of a role name longer than `ROLE_NAME_LENGTH_MAX`, in both `RoleName`s. */
44
+ export declare const ROLE_NAME_LENGTH_MESSAGE = "Role names must be at most 64 characters";
45
+ /** The message of a role name outside `ROLE_NAME_PATTERN`, in both `RoleName`s. */
46
+ export declare const ROLE_NAME_PATTERN_MESSAGE = "Role names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores";
47
+ /**
48
+ * Valid role name: lowercase letters and underscores, no leading, trailing or
49
+ * consecutive underscores, at most `ROLE_NAME_LENGTH_MAX` characters.
37
50
  */
38
51
  export declare const RoleName: z.ZodString;
39
52
  export type RoleName = z.infer<typeof RoleName>;
@@ -1 +1 @@
1
- {"version":3,"file":"role_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;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;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAuBnE,CAAC;AAEH,iGAAiG;AACjG,MAAM,WAAW,uBAAuB;IACvC,uGAAuG;IACvG,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAC9C,+FAA+F;IAC/F,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,oFAAoF;IACpF,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACpC;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAChC,0GAA0G;IAC1G,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,yEAAyE;IACzE,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC1C;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,eAAO,MAAM,kBAAkB,GAC9B,gBAAgB,aAAa,CAAC,QAAQ,CAAC,EACvC,UAAS,uBAA4B,KACnC,gBA2CF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC/B,YAAY,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EACzC,MAAM,MAAM,EACZ,YAAY,MAAM,KAChB,OAGF,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,0BAA0B,GACtC,YAAY,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EACzC,YAAY,MAAM,KAChB,KAAK,CAAC,MAAM,CAMd,CAAC"}
@@ -32,13 +32,26 @@ import { GRANT_PATH_ADMIN, GRANT_PATH_BOOTSTRAP } from './grant_path_schema.js';
32
32
  */
33
33
  export const ROLE_NAME_LENGTH_MAX = 64;
34
34
  /**
35
- * Valid role name: lowercase letters and underscores, no leading/trailing
36
- * underscore, at most `ROLE_NAME_LENGTH_MAX` characters.
35
+ * The grammar of a role name: runs of lowercase letters joined by single
36
+ * underscores, so no leading, trailing or consecutive underscores. Both
37
+ * `RoleName`s hold it, the Zod one here and the `@fuzdev/fuz_schema` twin in
38
+ * `auth/role_schema_fuz.ts`, and the sibling name grammars are the same
39
+ * pattern: `GRANT_PATH_NAME_REGEX`, `CREDENTIAL_TYPE_NAME_REGEX`,
40
+ * `SCOPE_KIND_NAME_REGEX` and `TOKEN_SURFACE_NAME_REGEX`.
41
+ */
42
+ export const ROLE_NAME_PATTERN = /^[a-z]+(?:_[a-z]+)*$/;
43
+ /** The message of a role name longer than `ROLE_NAME_LENGTH_MAX`, in both `RoleName`s. */
44
+ export const ROLE_NAME_LENGTH_MESSAGE = `Role names must be at most ${ROLE_NAME_LENGTH_MAX} characters`;
45
+ /** The message of a role name outside `ROLE_NAME_PATTERN`, in both `RoleName`s. */
46
+ export const ROLE_NAME_PATTERN_MESSAGE = 'Role names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores';
47
+ /**
48
+ * Valid role name: lowercase letters and underscores, no leading, trailing or
49
+ * consecutive underscores, at most `ROLE_NAME_LENGTH_MAX` characters.
37
50
  */
38
51
  export const RoleName = bounded_string({
39
52
  max: ROLE_NAME_LENGTH_MAX,
40
- max_message: `Role names must be at most ${ROLE_NAME_LENGTH_MAX} characters`
41
- }).regex(/^[a-z][a-z_]*[a-z]$|^[a-z]$/, 'Role names must be lowercase letters and underscores (a-z_), no leading/trailing underscore');
53
+ max_message: ROLE_NAME_LENGTH_MESSAGE
54
+ }).regex(ROLE_NAME_PATTERN, ROLE_NAME_PATTERN_MESSAGE);
42
55
  // Builtin roles — provided by fuz_app, always available.
43
56
  /** System-level role. Requires daemon token (filesystem proof). Controls the keep. */
44
57
  export const ROLE_KEEPER = 'keeper';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The `@fuzdev/fuz_schema` twin of the Zod `RoleName` (`auth/role_schema.ts`),
3
+ * under the same name, for schemas written in fuz_schema.
4
+ *
5
+ * Both are built from the constants `role_schema.ts` exports, so the bound,
6
+ * the grammar and the two messages can't drift apart. They give every input
7
+ * the same verdict and output, and write the same JSON Schema
8
+ * (`maxLength` and `pattern`); a string both too long and outside the grammar
9
+ * gets the one length issue from this twin, as its `pipe` stops at the first
10
+ * failing step, where the Zod one adds the grammar issue after it.
11
+ *
12
+ * The export is `@nodocs` while the Zod `RoleName` stays, as the docs build
13
+ * refuses two exports of one name.
14
+ *
15
+ * @module
16
+ */
17
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
18
+ /**
19
+ * Valid role name: lowercase letters and underscores, no leading, trailing or
20
+ * consecutive underscores, at most `ROLE_NAME_LENGTH_MAX` UTF-16 code units, the twin of
21
+ * the Zod `RoleName`. A string it refuses gets the Zod one's message; a
22
+ * value that is no string, fuz_schema's.
23
+ *
24
+ * @nodocs
25
+ */
26
+ export declare const RoleName: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
27
+ /** @nodocs */
28
+ export type RoleName = Infer<typeof RoleName>;
29
+ //# sourceMappingURL=role_schema_fuz.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role_schema_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_schema_fuz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAwB,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAUhF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,0MAGpB,CAAC;AACF,cAAc;AACd,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The `@fuzdev/fuz_schema` twin of the Zod `RoleName` (`auth/role_schema.ts`),
3
+ * under the same name, for schemas written in fuz_schema.
4
+ *
5
+ * Both are built from the constants `role_schema.ts` exports, so the bound,
6
+ * the grammar and the two messages can't drift apart. They give every input
7
+ * the same verdict and output, and write the same JSON Schema
8
+ * (`maxLength` and `pattern`); a string both too long and outside the grammar
9
+ * gets the one length issue from this twin, as its `pipe` stops at the first
10
+ * failing step, where the Zod one adds the grammar issue after it.
11
+ *
12
+ * The export is `@nodocs` while the Zod `RoleName` stays, as the docs build
13
+ * refuses two exports of one name.
14
+ *
15
+ * @module
16
+ */
17
+ import { message, pipe, regex } from '@fuzdev/fuz_schema/schema.ts';
18
+ import { bounded_string } from '../primitive_schemas_fuz.js';
19
+ import { ROLE_NAME_LENGTH_MAX, ROLE_NAME_LENGTH_MESSAGE, ROLE_NAME_PATTERN, ROLE_NAME_PATTERN_MESSAGE } from './role_schema.js';
20
+ /**
21
+ * Valid role name: lowercase letters and underscores, no leading, trailing or
22
+ * consecutive underscores, at most `ROLE_NAME_LENGTH_MAX` UTF-16 code units, the twin of
23
+ * the Zod `RoleName`. A string it refuses gets the Zod one's message; a
24
+ * value that is no string, fuz_schema's.
25
+ *
26
+ * @nodocs
27
+ */
28
+ export const RoleName = pipe(bounded_string({ max: ROLE_NAME_LENGTH_MAX, max_message: ROLE_NAME_LENGTH_MESSAGE }), message(regex(ROLE_NAME_PATTERN), ROLE_NAME_PATTERN_MESSAGE));
@@ -22,32 +22,39 @@
22
22
  *
23
23
  * The literal `'GLOBAL'` (uppercase) appears as an index expression
24
24
  * inside the partial unique indexes on `role_grant` and `role_grant_offer`
25
- * (`COALESCE(scope_kind, 'GLOBAL')`) — never as a column value, never
26
- * as a registry entry. The uppercase form is structurally distinct
27
- * from any consumer-declared kind (which match the lowercase
28
- * `ScopeKindName` regex), so it cannot collide.
25
+ * (`COALESCE(scope_kind, 'GLOBAL')`), never as a registry entry. It is off
26
+ * the `ScopeKindName` grammar, so no registry declares it and the grant
27
+ * inputs (`role_grant_offer_create`, `role_grant_assign`) refuse it: a row
28
+ * written through them never holds it. One written by other means could,
29
+ * and with the all-zeros `scope_id` it would share a global grant's index
30
+ * key.
29
31
  *
30
32
  * @module
31
33
  */
32
34
  import { z } from 'zod';
33
35
  /**
34
- * Letter (lowercase a-z) start and end (or single letter), with letters
35
- * and underscores in between. Mirrors `RoleName`. Rejects empty strings,
36
- * leading or trailing underscores, uppercase, digits, and the index-side
37
- * `'GLOBAL'` token.
36
+ * Runs of lowercase letters (a-z) joined by single underscores, the grammar
37
+ * of `RoleName`, `CredentialTypeName` and `GrantPathName` too. Rejects empty
38
+ * strings, leading, trailing or consecutive underscores, uppercase, digits,
39
+ * and the index-side `'GLOBAL'` token.
38
40
  */
39
41
  export declare const SCOPE_KIND_NAME_REGEX: RegExp;
40
42
  /**
41
43
  * Maximum length of a `scope_kind`, in UTF-16 code units (what
42
- * `String.length` measures; enforced by `bounded_string`). Bounds the tag where it enters
43
- * — the grant inputs (`role_grant_offer_create`, `role_grant_assign`) copy it
44
- * into the row and its audit metadata — and a registered name, so no
44
+ * `String.length` measures; enforced by `bounded_string`). Part of the
45
+ * `ScopeKindName` grammar, which bounds a registered name and the tag where
46
+ * it enters — the grant inputs (`role_grant_offer_create`,
47
+ * `role_grant_assign`) copy it into the row and its audit metadata — so no
45
48
  * registry declares a kind the grant inputs would refuse. Same value as
46
- * `ROLE_NAME_LENGTH_MAX`, whose grammar the name mirrors, and as the Rust
49
+ * `ROLE_NAME_LENGTH_MAX`, whose grammar the name shares, and as the Rust
47
50
  * spine's `SCOPE_KIND_LENGTH_MAX`.
48
51
  */
49
52
  export declare const SCOPE_KIND_LENGTH_MAX = 64;
50
- /** Zod schema for valid scope-kind name strings. */
53
+ /**
54
+ * Zod schema for valid scope-kind name strings: a registered name, and the
55
+ * `scope_kind` the grant inputs take. Twin of the Rust spine's
56
+ * `is_valid_scope_kind_name`.
57
+ */
51
58
  export declare const ScopeKindName: z.ZodString;
52
59
  export type ScopeKindName = z.infer<typeof ScopeKindName>;
53
60
  /**
@@ -78,8 +85,8 @@ export interface ScopeKindSchemaResult {
78
85
  *
79
86
  * Open registry — no builtins. The `'GLOBAL'` token used inside the
80
87
  * partial unique indexes on `role_grant` and `role_grant_offer` is not a
81
- * registry entry (it's an index expression only) and cannot collide
82
- * with consumer-declared kinds because the regex rejects uppercase.
88
+ * registry entry (it's an index expression only), and no consumer can
89
+ * declare it because the regex rejects uppercase.
83
90
  *
84
91
  * Call once at server init. Pass the result into `create_role_schema`'s
85
92
  * optional `scope_kinds` parameter so each role's
@@ -1 +1 @@
1
- {"version":3,"file":"scope_kind_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/scope_kind_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAgC,CAAC;AAEnE;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,oDAAoD;AACpD,eAAO,MAAM,aAAa,aAMzB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;OAKG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,wBAAwB,GACpC,gBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAC3C,qBAwBF,CAAC"}
1
+ {"version":3,"file":"scope_kind_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/scope_kind_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAyB,CAAC;AAE5D;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,aAAa,aAMzB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;OAKG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,wBAAwB,GACpC,gBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAC3C,qBAwBF,CAAC"}
@@ -22,44 +22,51 @@
22
22
  *
23
23
  * The literal `'GLOBAL'` (uppercase) appears as an index expression
24
24
  * inside the partial unique indexes on `role_grant` and `role_grant_offer`
25
- * (`COALESCE(scope_kind, 'GLOBAL')`) — never as a column value, never
26
- * as a registry entry. The uppercase form is structurally distinct
27
- * from any consumer-declared kind (which match the lowercase
28
- * `ScopeKindName` regex), so it cannot collide.
25
+ * (`COALESCE(scope_kind, 'GLOBAL')`), never as a registry entry. It is off
26
+ * the `ScopeKindName` grammar, so no registry declares it and the grant
27
+ * inputs (`role_grant_offer_create`, `role_grant_assign`) refuse it: a row
28
+ * written through them never holds it. One written by other means could,
29
+ * and with the all-zeros `scope_id` it would share a global grant's index
30
+ * key.
29
31
  *
30
32
  * @module
31
33
  */
32
34
  import { z } from 'zod';
33
35
  import { bounded_string } from '../primitive_schemas.js';
34
36
  /**
35
- * Letter (lowercase a-z) start and end (or single letter), with letters
36
- * and underscores in between. Mirrors `RoleName`. Rejects empty strings,
37
- * leading or trailing underscores, uppercase, digits, and the index-side
38
- * `'GLOBAL'` token.
37
+ * Runs of lowercase letters (a-z) joined by single underscores, the grammar
38
+ * of `RoleName`, `CredentialTypeName` and `GrantPathName` too. Rejects empty
39
+ * strings, leading, trailing or consecutive underscores, uppercase, digits,
40
+ * and the index-side `'GLOBAL'` token.
39
41
  */
40
- export const SCOPE_KIND_NAME_REGEX = /^[a-z][a-z_]*[a-z]$|^[a-z]$/;
42
+ export const SCOPE_KIND_NAME_REGEX = /^[a-z]+(?:_[a-z]+)*$/;
41
43
  /**
42
44
  * Maximum length of a `scope_kind`, in UTF-16 code units (what
43
- * `String.length` measures; enforced by `bounded_string`). Bounds the tag where it enters
44
- * — the grant inputs (`role_grant_offer_create`, `role_grant_assign`) copy it
45
- * into the row and its audit metadata — and a registered name, so no
45
+ * `String.length` measures; enforced by `bounded_string`). Part of the
46
+ * `ScopeKindName` grammar, which bounds a registered name and the tag where
47
+ * it enters — the grant inputs (`role_grant_offer_create`,
48
+ * `role_grant_assign`) copy it into the row and its audit metadata — so no
46
49
  * registry declares a kind the grant inputs would refuse. Same value as
47
- * `ROLE_NAME_LENGTH_MAX`, whose grammar the name mirrors, and as the Rust
50
+ * `ROLE_NAME_LENGTH_MAX`, whose grammar the name shares, and as the Rust
48
51
  * spine's `SCOPE_KIND_LENGTH_MAX`.
49
52
  */
50
53
  export const SCOPE_KIND_LENGTH_MAX = 64;
51
- /** Zod schema for valid scope-kind name strings. */
54
+ /**
55
+ * Zod schema for valid scope-kind name strings: a registered name, and the
56
+ * `scope_kind` the grant inputs take. Twin of the Rust spine's
57
+ * `is_valid_scope_kind_name`.
58
+ */
52
59
  export const ScopeKindName = bounded_string({
53
60
  max: SCOPE_KIND_LENGTH_MAX,
54
61
  max_message: `Scope-kind names must be at most ${SCOPE_KIND_LENGTH_MAX} characters`
55
- }).regex(SCOPE_KIND_NAME_REGEX, 'Scope-kind names must be lowercase letters and underscores (a-z_), no leading/trailing underscore');
62
+ }).regex(SCOPE_KIND_NAME_REGEX, 'Scope-kind names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores');
56
63
  /**
57
64
  * Create a scope-kind schema from a consumer-declared registry.
58
65
  *
59
66
  * Open registry — no builtins. The `'GLOBAL'` token used inside the
60
67
  * partial unique indexes on `role_grant` and `role_grant_offer` is not a
61
- * registry entry (it's an index expression only) and cannot collide
62
- * with consumer-declared kinds because the regex rejects uppercase.
68
+ * registry entry (it's an index expression only), and no consumer can
69
+ * declare it because the regex rejects uppercase.
63
70
  *
64
71
  * Call once at server init. Pass the result into `create_role_schema`'s
65
72
  * optional `scope_kinds` parameter so each role's
@@ -7,28 +7,50 @@
7
7
  *
8
8
  * @module
9
9
  */
10
- import { z } from 'zod';
10
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
11
11
  import type { RequestResponseActionSpec } from '../actions/action_spec.js';
12
12
  /** Error reason — caller asked to self-toggle a role outside the configured allowlist. */
13
13
  export declare const ERROR_ROLE_NOT_SELF_SERVICE_ELIGIBLE: "role_not_self_service_eligible";
14
- /** Input for `self_service_role_set`. */
15
- export declare const SelfServiceRoleSetInput: z.ZodObject<{
16
- role: z.ZodString;
17
- enabled: z.ZodBoolean;
18
- acting: z.ZodOptional<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
19
- }, z.core.$strict>;
20
- export type SelfServiceRoleSetInput = z.infer<typeof SelfServiceRoleSetInput>;
14
+ /** Input for `self_service_role_set`, a `@fuzdev/fuz_schema` schema. */
15
+ export declare const SelfServiceRoleSetInput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
16
+ role: string;
17
+ enabled: boolean;
18
+ acting?: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | undefined;
19
+ }, {
20
+ role: string;
21
+ enabled: boolean;
22
+ acting?: string | undefined;
23
+ }, "object", {
24
+ role: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
25
+ enabled: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
26
+ acting: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime">)[]> & {
27
+ readonly '~types'?: {
28
+ readonly input: string;
29
+ readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
30
+ } | undefined;
31
+ }>>;
32
+ }>;
33
+ export type SelfServiceRoleSetInput = Infer<typeof SelfServiceRoleSetInput>;
21
34
  /**
22
- * Output for `self_service_role_set`. `enabled` echoes the post-call state
23
- * (always equals the input `enabled` on success). `changed` is `true` only
24
- * when the call mutated — re-grants / re-revokes return `false`.
35
+ * Output for `self_service_role_set`, a `@fuzdev/fuz_schema` schema. `enabled`
36
+ * echoes the post-call state (always equals the input `enabled` on success).
37
+ * `changed` is `true` only when the call mutated — re-grants / re-revokes
38
+ * return `false`.
25
39
  */
26
- export declare const SelfServiceRoleSetOutput: z.ZodObject<{
27
- ok: z.ZodLiteral<true>;
28
- enabled: z.ZodBoolean;
29
- changed: z.ZodBoolean;
30
- }, z.core.$strict>;
31
- export type SelfServiceRoleSetOutput = z.infer<typeof SelfServiceRoleSetOutput>;
40
+ export declare const SelfServiceRoleSetOutput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
41
+ ok: true;
42
+ enabled: boolean;
43
+ changed: boolean;
44
+ }, {
45
+ ok: true;
46
+ enabled: boolean;
47
+ changed: boolean;
48
+ }, "object", {
49
+ ok: import("@fuzdev/fuz_schema/schema.ts").Schema<true, true, "literal", true>;
50
+ enabled: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
51
+ changed: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
52
+ }>;
53
+ export type SelfServiceRoleSetOutput = Infer<typeof SelfServiceRoleSetOutput>;
32
54
  /**
33
55
  * `rate_limit: 'account'` bounds audit-row churn. The toggle is idempotent
34
56
  * (`changed: false` re-grants/re-revokes), but every call still writes a
@@ -52,16 +74,37 @@ export declare const self_service_role_set_action_spec: {
52
74
  credential_types: string[];
53
75
  };
54
76
  side_effects: true;
55
- input: z.ZodObject<{
56
- role: z.ZodString;
57
- enabled: z.ZodBoolean;
58
- acting: z.ZodOptional<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
59
- }, z.core.$strict>;
60
- output: z.ZodObject<{
61
- ok: z.ZodLiteral<true>;
62
- enabled: z.ZodBoolean;
63
- changed: z.ZodBoolean;
64
- }, z.core.$strict>;
77
+ input: import("@fuzdev/fuz_schema/schema.ts").Schema<{
78
+ role: string;
79
+ enabled: boolean;
80
+ acting?: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | undefined;
81
+ }, {
82
+ role: string;
83
+ enabled: boolean;
84
+ acting?: string | undefined;
85
+ }, "object", {
86
+ role: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
87
+ enabled: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
88
+ acting: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime">)[]> & {
89
+ readonly '~types'?: {
90
+ readonly input: string;
91
+ readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
92
+ } | undefined;
93
+ }>>;
94
+ }>;
95
+ output: import("@fuzdev/fuz_schema/schema.ts").Schema<{
96
+ ok: true;
97
+ enabled: boolean;
98
+ changed: boolean;
99
+ }, {
100
+ ok: true;
101
+ enabled: boolean;
102
+ changed: boolean;
103
+ }, "object", {
104
+ ok: import("@fuzdev/fuz_schema/schema.ts").Schema<true, true, "literal", true>;
105
+ enabled: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
106
+ changed: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
107
+ }>;
65
108
  async: true;
66
109
  description: string;
67
110
  rate_limit: "account";
@@ -1 +1 @@
1
- {"version":3,"file":"self_service_role_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/self_service_role_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAI3E,0FAA0F;AAC1F,eAAO,MAAM,oCAAoC,EAAG,gCAAyC,CAAC;AAE9F,yCAAyC;AACzC,eAAO,MAAM,uBAAuB;;;;kBAOlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;kBAInC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;CAYT,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,aAAa,CAAC,yBAAyB,CAEvF,CAAC"}
1
+ {"version":3,"file":"self_service_role_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/self_service_role_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAA4B,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAEpF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAI3E,0FAA0F;AAC1F,eAAO,MAAM,oCAAoC,EAAG,gCAAyC,CAAC;AAE9F,wEAAwE;AACxE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;EAOlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAInC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE9E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYT,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,aAAa,CAAC,yBAAyB,CAEvF,CAAC"}
@@ -7,28 +7,30 @@
7
7
  *
8
8
  * @module
9
9
  */
10
- import { z } from 'zod';
11
- import { RoleName } from './role_schema.js';
12
- import { ActingActor } from '../http/auth_shape.js';
10
+ import { meta } from '@fuzdev/fuz_schema/meta.ts';
11
+ import { boolean, literal, object } from '@fuzdev/fuz_schema/schema.ts';
12
+ import { ActingActor } from '../primitive_schemas_fuz.js';
13
+ import { RoleName } from './role_schema_fuz.js';
13
14
  /** Error reason — caller asked to self-toggle a role outside the configured allowlist. */
14
15
  export const ERROR_ROLE_NOT_SELF_SERVICE_ELIGIBLE = 'role_not_self_service_eligible';
15
- /** Input for `self_service_role_set`. */
16
- export const SelfServiceRoleSetInput = z.strictObject({
17
- role: RoleName.meta({ description: 'Role to toggle. Must be in the configured allowlist.' }),
18
- enabled: z.boolean().meta({
16
+ /** Input for `self_service_role_set`, a `@fuzdev/fuz_schema` schema. */
17
+ export const SelfServiceRoleSetInput = object({
18
+ role: meta(RoleName, { description: 'Role to toggle. Must be in the configured allowlist.' }),
19
+ enabled: meta(boolean, {
19
20
  description: 'Desired post-call state. `true` grants if not held; `false` revokes if held. Idempotent in both directions.'
20
21
  }),
21
22
  acting: ActingActor
22
23
  });
23
24
  /**
24
- * Output for `self_service_role_set`. `enabled` echoes the post-call state
25
- * (always equals the input `enabled` on success). `changed` is `true` only
26
- * when the call mutated — re-grants / re-revokes return `false`.
25
+ * Output for `self_service_role_set`, a `@fuzdev/fuz_schema` schema. `enabled`
26
+ * echoes the post-call state (always equals the input `enabled` on success).
27
+ * `changed` is `true` only when the call mutated — re-grants / re-revokes
28
+ * return `false`.
27
29
  */
28
- export const SelfServiceRoleSetOutput = z.strictObject({
29
- ok: z.literal(true),
30
- enabled: z.boolean(),
31
- changed: z.boolean()
30
+ export const SelfServiceRoleSetOutput = object({
31
+ ok: literal(true),
32
+ enabled: boolean,
33
+ changed: boolean
32
34
  });
33
35
  /**
34
36
  * `rate_limit: 'account'` bounds audit-row churn. The toggle is idempotent
@@ -150,8 +150,9 @@ export type TokenSurface = (typeof TOKEN_SURFACES)[number];
150
150
  */
151
151
  export declare const is_token_surface: (value: string) => value is TokenSurface;
152
152
  /**
153
- * Name format for the identifier half of a capability string. Mirrors
154
- * `RoleName` / `CredentialTypeName` / `ScopeKindName`.
153
+ * Name format for the identifier half of a capability string: runs of
154
+ * lowercase letters (a-z) joined by single underscores, the grammar of
155
+ * `RoleName` / `CredentialTypeName` / `ScopeKindName` / `GrantPathName` too.
155
156
  *
156
157
  * Applied to the `surface:` arm only. The `rpc:` arm's identifier is an action
157
158
  * method name, whose vocabulary belongs to `ActionSpec` (and includes shapes
@@ -1 +1 @@
1
- {"version":3,"file":"token_scope.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/token_scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAW,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU;;;;;;;;;4BAYrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;;;;;;;GAQG;AACH,eAAO,MAAM,e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oBG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,UAAU,KAAG,OAAgC,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,mGAOjB,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,YACA,CAAC;AAE3D;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,QAAyB,CAAC;AAQ/D;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GAAI,QAAQ,MAAM,KAAG,MAC3B,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,KAAG,OAEmB,CAAC;AAE9E;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,YAAY,MAAM,KAChB;IAAE,KAAK,EAAE,sBAAsB,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAGxD,CAAC;AAEH,4CAA4C;AAC5C,eAAO,MAAM,iBAAiB,GAAI,OAAO,UAAU,KAAG,MAGrD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,UAAU,GAAG,IAU5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,UAAU,KAAG,MAQzD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,UAAU,GAAG,IAQtE,CAAC"}
@@ -162,15 +162,16 @@ export const TOKEN_SURFACES = [
162
162
  */
163
163
  export const is_token_surface = (value) => TOKEN_SURFACES.includes(value);
164
164
  /**
165
- * Name format for the identifier half of a capability string. Mirrors
166
- * `RoleName` / `CredentialTypeName` / `ScopeKindName`.
165
+ * Name format for the identifier half of a capability string: runs of
166
+ * lowercase letters (a-z) joined by single underscores, the grammar of
167
+ * `RoleName` / `CredentialTypeName` / `ScopeKindName` / `GrantPathName` too.
167
168
  *
168
169
  * Applied to the `surface:` arm only. The `rpc:` arm's identifier is an action
169
170
  * method name, whose vocabulary belongs to `ActionSpec` (and includes shapes
170
171
  * like `peer/ping` this regex would refuse); the dispatcher computes it from the
171
172
  * registered method, so nothing parses one.
172
173
  */
173
- export const TOKEN_SURFACE_NAME_REGEX = /^[a-z][a-z_]*[a-z]$|^[a-z]$/;
174
+ export const TOKEN_SURFACE_NAME_REGEX = /^[a-z]+(?:_[a-z]+)*$/;
174
175
  // Capability-string prefixes. Private: `token_scope_method_capability` builds
175
176
  // the one capability anything computes, and `is_route_scope_capability` checks
176
177
  // the one a route declares, so nothing outside this module concatenates these.
@@ -587,6 +587,12 @@ table browser; the factory is domain-agnostic.
587
587
  - `GET /tables/:name` — columns + rows (paginated via `?offset`/`?limit`, limit validated to `[1, 1000]` with default 100; bytea values come back as `<N bytes>` placeholders, NULL stays NULL, column metadata untouched) + total count + `primary_key` (the single PK column, or `null` when the table has none or a composite one) + `deletable` (whether the row-`DELETE` will accept this table at all — see below)
588
588
  - `DELETE /tables/:name/rows/:id` — delete by PK, compared typed as `"<pk>" = $1` (twinning the Rust spine — the untyped text-format param makes PG coerce the id with the PK type's input function, so the delete index-scans and follows the column type's semantics; an uncoercible id — 22P02/22003 — is the same clean 404 as a typed miss). `RETURNING "<pk>"::text` feeds the audit trail the row's canonical PK rendering. Returns 400 if the table is excluded by policy (`ERROR_TABLE_NOT_DELETABLE`) or has no single-column PK (`ERROR_TABLE_NO_PRIMARY_KEY`), 404 if row missing (`ERROR_ROW_NOT_FOUND`) or table missing/unbrowsable (`ERROR_TABLE_NOT_FOUND`), 409 on a referencing-row refusal (pg error `23503` foreign_key_violation, or `23001` restrict_violation — PG 18+ raises the latter for `ON DELETE RESTRICT`)
589
589
 
590
+ Every route declares `acting?: ActingActor` on its `query` (registry-time
591
+ invariant 2). The `{acting}`-only queries of `GET /health`, `GET /tables` and
592
+ the row `DELETE` are `@fuzdev/fuz_schema` `object`s over the twin
593
+ `ActingActor`; `GET /tables/:name`'s stays Zod, its paging params being
594
+ `query_int`'s Zod preprocess.
595
+
590
596
  **The allowlist gates everything.** `DbRouteOptions.browsable_tables` is
591
597
  required with no "all" escape hatch — the table list shows only listed tables,
592
598
  and detail/`DELETE` on an unlisted table answer exactly like a table that
@@ -1 +1 @@
1
- {"version":3,"file":"db_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/db_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAqC,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAiBpF;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,sDAAsD;AACtD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,sDAAsD;AACtD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM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;gBAAC,EAAE,EAAE,MAAM,CAAA;aAAE,CAAC;SAC3D,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,8EAA8E;IAC9E,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C;AA2CD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,WAAW,EACjB,SAAS,cAAc,KACrB,KAAK,CAAC,SAAS,CA+YjB,CAAC"}
@@ -10,6 +10,8 @@
10
10
  * @module
11
11
  */
12
12
  import { z } from 'zod';
13
+ import { object } from '@fuzdev/fuz_schema/schema.ts';
14
+ import { ActingActor as ActingActorFuz } from '../primitive_schemas_fuz.js';
13
15
  import { get_route_params, get_route_query } from './route_spec.js';
14
16
  import { ActingActor } from './auth_shape.js';
15
17
  import { ForeignKeyError, ERROR_TABLE_NOT_FOUND, ERROR_TABLE_NO_PRIMARY_KEY, ERROR_TABLE_NOT_DELETABLE, ERROR_ROW_NOT_FOUND, ERROR_FOREIGN_KEY_VIOLATION, ERROR_INVALID_ROUTE_PARAMS, ERROR_DATABASE_CONNECTION_FAILED } from './error_schemas.js';
@@ -161,7 +163,7 @@ export const create_db_route_specs = (deps, options) => {
161
163
  credential_types: ['daemon_token']
162
164
  },
163
165
  description: 'Database health and stats',
164
- query: z.strictObject({ acting: ActingActor }),
166
+ query: object({ acting: ActingActorFuz }),
165
167
  input: z.null(),
166
168
  output: z.looseObject({ connected: z.boolean() }),
167
169
  errors: {
@@ -204,7 +206,7 @@ export const create_db_route_specs = (deps, options) => {
204
206
  credential_types: ['daemon_token']
205
207
  },
206
208
  description: 'List browsable tables with row counts',
207
- query: z.strictObject({ acting: ActingActor }),
209
+ query: object({ acting: ActingActorFuz }),
208
210
  input: z.null(),
209
211
  output: z.looseObject({
210
212
  tables: z.array(z.strictObject({ name: z.string(), row_count: z.number() }))
@@ -241,6 +243,9 @@ export const create_db_route_specs = (deps, options) => {
241
243
  },
242
244
  description: 'Get table columns and rows (paginated)',
243
245
  params: z.strictObject({ name: z.string().regex(VALID_SQL_IDENTIFIER) }),
246
+ // Zod, unlike the `{acting}`-only queries here: its paging params are
247
+ // `query_int`'s Zod preprocess, which stays with the rest of these
248
+ // routes' Zod schemas
244
249
  query: z.strictObject({
245
250
  acting: ActingActor,
246
251
  offset: query_int(z.number().int().min(0), 0),
@@ -330,7 +335,7 @@ export const create_db_route_specs = (deps, options) => {
330
335
  name: z.string().regex(VALID_SQL_IDENTIFIER),
331
336
  id: z.string()
332
337
  }),
333
- query: z.strictObject({ acting: ActingActor }),
338
+ query: object({ acting: ActingActorFuz }),
334
339
  input: z.null(),
335
340
  output: z.looseObject({ success: z.boolean() }),
336
341
  errors: {
@@ -1 +1 @@
1
- {"version":3,"file":"serve_fact_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/serve_fact_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmIG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAetD,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAU5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAoCjD,MAAM,WAAW,+BAA+B;IAC/C,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACZ;AAkJD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iCAAiC,GAC7C,SAAS,+BAA+B,KACtC,SA0DF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,SA+CF,CAAC"}
1
+ {"version":3,"file":"serve_fact_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/serve_fact_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmIG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAgBtD,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAU5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAoCjD,MAAM,WAAW,+BAA+B;IAC/C,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACZ;AAkJD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iCAAiC,GAC7C,SAAS,+BAA+B,KACtC,SA0DF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,SA+CF,CAAC"}
@@ -134,10 +134,11 @@ import { open } from 'node:fs/promises';
134
134
  import { Readable } from 'node:stream';
135
135
  import { join } from 'node:path';
136
136
  import { FactHashSchema, Uuid } from '../primitive_schemas.js';
137
+ import { ActingActor } from '../primitive_schemas_fuz.js';
137
138
  import { z } from 'zod';
139
+ import { object } from '@fuzdev/fuz_schema/schema.ts';
138
140
  import { build_request_context, get_public_account_id, get_request_context, has_scoped_role } from '../auth/request_context.js';
139
141
  import { ROLE_ADMIN } from '../auth/role_schema.js';
140
- import { ActingActor } from '../http/auth_shape.js';
141
142
  import { query_active_actors_by_account } from '../auth/account_queries.js';
142
143
  import { get_route_params } from '../http/route_spec.js';
143
144
  import { ERROR_INVALID_ROUTE_PARAMS } from '../http/error_schemas.js';
@@ -407,7 +408,7 @@ export const create_serve_fact_route_spec = (options) => {
407
408
  // authorization phase to resolve an acting actor — registry-time
408
409
  // invariant 2 requires the `acting?` slot. On a GET it lives on
409
410
  // `query` (a multi-actor admin disambiguates via `?acting=<actor>`).
410
- query: z.strictObject({ acting: ActingActor }),
411
+ query: object({ acting: ActingActor }),
411
412
  input: z.null(),
412
413
  // The body is a binary stream; no JSON output schema applies.
413
414
  output: z.null(),
@@ -1 +1 @@
1
- {"version":3,"file":"surface_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/surface_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IACnC,2GAA2G;IAC3G,OAAO,EAAE,UAAU,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,mBAAmB,KAAG,SAmBvE,CAAC"}
1
+ {"version":3,"file":"surface_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/surface_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IACnC,2GAA2G;IAC3G,OAAO,EAAE,UAAU,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,mBAAmB,KAAG,SAmBvE,CAAC"}
@@ -8,7 +8,8 @@
8
8
  * @module
9
9
  */
10
10
  import { z } from 'zod';
11
- import { ActingActor } from '../http/auth_shape.js';
11
+ import { object } from '@fuzdev/fuz_schema/schema.ts';
12
+ import { ActingActor } from '../primitive_schemas_fuz.js';
12
13
  import { ROLE_ADMIN } from '../auth/role_schema.js';
13
14
  /**
14
15
  * Create the admin-only route spec that serves the `AppSurface` as JSON.
@@ -37,7 +38,7 @@ export const create_surface_route_spec = (options) => ({
37
38
  },
38
39
  handler: (c) => c.json(options.surface),
39
40
  description: 'Application surface (routes, middleware, schemas) — admin only',
40
- query: z.strictObject({ acting: ActingActor }),
41
+ query: object({ acting: ActingActor }),
41
42
  input: z.null(),
42
43
  output: z.looseObject({
43
44
  routes: z.array(z.looseObject({})),
@@ -534,9 +534,7 @@ handler needing real seeded state, a path segment no schema describes. A
534
534
  route whose params merely carry a format needs no entry: `resolve_valid_path`
535
535
  synthesizes a segment the route accepts.
536
536
 
537
- Also exported: `describe_adversarial_auth(options)` (group 3 on its own) and
538
- `build_error_schema_lookup(specs, middleware_specs?)` (pre-built
539
- `Map<string, RouteErrorSchemas>` for per-response validation).
537
+ Also exported: `describe_adversarial_auth(options)` (group 3 on its own).
540
538
 
541
539
  ### `adversarial_input.ts` + `adversarial_input_cases.ts` — schema-walk payload generation
542
540
 
@@ -2534,19 +2532,25 @@ Cross-process only — the per-surface in-process TS pins live beside each
2534
2532
  module's own tests (`account_status.test.ts`, `action_rpc.test.ts`,
2535
2533
  `serve_fact_route.db.test.ts`);
2536
2534
 
2537
- ### Grant-verb role grammar parity — `cross_backend/role_grant_role_grammar.ts`
2535
+ ### Grant-verb role and scope-kind grammar parity — `cross_backend/role_grant_role_grammar.ts`
2538
2536
 
2539
2537
  `describe_role_grant_role_grammar_cross_tests({setup_test, rpc_path?})` — an
2540
- off-grammar `role` (uppercase, hyphen, digit, leading or trailing underscore,
2541
- space, empty, or all lowercase and one character past the length cap) on `role_grant_assign` and `role_grant_offer_create` answers
2538
+ off-grammar `role` (uppercase, hyphen, digit, leading, trailing or consecutive
2539
+ underscores, space, empty, or all lowercase and one character past the length
2540
+ cap) on `role_grant_assign` and `role_grant_offer_create` answers
2542
2541
  `invalid_params` with no `data.reason`, and after the refusals no
2543
2542
  `role_grant_create` / `role_grant_offer_create` audit row carries one of those
2544
2543
  strings. The control — an on-grammar role no registry holds, refused past
2545
2544
  validation with `role_not_web_grantable` — keeps the audit read from being
2546
2545
  vacuous, and the same refusal for a role exactly at the length cap pins that
2547
- boundary. Exists because the action-manifest parity gate captures no param
2546
+ boundary. An off-grammar `scope_kind` with its `scope_id` (the same grammar
2547
+ and cap, `ScopeKindName`, among them `'GLOBAL'` with the all-zeros uuid, the
2548
+ partial unique indexes' key for a global grant) is refused the same way and
2549
+ recorded in no row; with an unregistered role, on-grammar ones (one at the cap)
2550
+ are refused past validation with the verb's not-grantable reason. Exists
2551
+ because the action-manifest parity gate captures no param
2548
2552
  schemas while the Rust spine parses params by hand, and the grant verbs write
2549
- the role they refuse into their failure rows. Ungated; cross-process only (it
2553
+ the role and `scope_kind` they refuse into their failure rows. Ungated; cross-process only (it
2550
2554
  reads the audit log behind `_testing_drain_effects`).
2551
2555
 
2552
2556
  ### API-token lifetime parity — `cross_backend/token_lifetime.ts`
@@ -1 +1 @@
1
- {"version":3,"file":"role_grant_role_grammar.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/role_grant_role_grammar.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAuC9B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAG3D,8EAA8E;AAC9E,MAAM,MAAM,oCAAoC,GAAG,wBAAwB,CAAC;AAoC5E,eAAO,MAAM,4CAA4C,GACxD,SAAS,oCAAoC,KAC3C,IAyFF,CAAC"}
1
+ {"version":3,"file":"role_grant_role_grammar.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/role_grant_role_grammar.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAiD9B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAG3D,8EAA8E;AAC9E,MAAM,MAAM,oCAAoC,GAAG,wBAAwB,CAAC;AAoE5E,eAAO,MAAM,4CAA4C,GACxD,SAAS,oCAAoC,KAC3C,IAqKF,CAAC"}
@@ -1,13 +1,15 @@
1
1
  import '../assert_dev_env.js';
2
2
  /**
3
- * Cross-backend parity suite for an **off-grammar `role`** on the grant verbs.
3
+ * Cross-backend parity suite for an **off-grammar `role` or `scope_kind`** on
4
+ * the grant verbs.
4
5
  *
5
6
  * `role_grant_assign` and `role_grant_offer_create` declare `role` as
6
- * `RoleName` (lowercase letters and underscores, no leading or trailing
7
- * underscore, at most 64 characters). A role string outside that grammar is refused at input
8
- * validation — JSON-RPC `invalid_params`, with no `data.reason` — and writes
9
- * no audit row: a role is caller-chosen text until it passes the grammar, and
10
- * the grant verbs record the role they refuse in their failure rows.
7
+ * `RoleName` (lowercase letters and underscores, no leading, trailing or
8
+ * consecutive underscores, at most 64 characters). A role string outside that
9
+ * grammar is refused at input validation — JSON-RPC `invalid_params`, with no
10
+ * `data.reason` — and writes no audit row: a role is caller-chosen text until
11
+ * it passes the grammar, and the grant verbs record the role they refuse in
12
+ * their failure rows.
11
13
  *
12
14
  * - **refused at validation** — each off-grammar role, on each verb, answers
13
15
  * `invalid_params` with no reason, so the refusal is the input schema's and
@@ -19,6 +21,13 @@ import '../assert_dev_env.js';
19
21
  * on-grammar role no registry holds is refused past validation with
20
22
  * `role_not_web_grantable`, the refusal a failure row records — as is one
21
23
  * exactly at the length cap, which pins the boundary.
24
+ * - **`scope_kind` too** — `scope_kind` is a `ScopeKindName`, the same grammar
25
+ * and cap, so an off-grammar one with its `scope_id` is refused the same way
26
+ * and recorded in no row. Among them is `'GLOBAL'` with the all-zeros
27
+ * uuid, the partial unique indexes' key for a global grant, which a spine
28
+ * letting it through would answer with a 500 on an actor already holding
29
+ * the role globally. The role is on the grammar and held by no registry, so
30
+ * a `scope_kind` let through is refused past validation with a reason.
22
31
  *
23
32
  * Exists because the action-manifest parity gate captures no param schemas
24
33
  * while the Rust spine parses params by hand — a spine that let an off-grammar
@@ -30,6 +39,7 @@ import '../assert_dev_env.js';
30
39
  * @module
31
40
  */
32
41
  import { assert, describe, test } from 'vitest';
42
+ import { ERROR_ROLE_GRANT_OFFER_ROLE_NOT_GRANTABLE } from '../../auth/role_grant_offer_action_specs.js';
33
43
  import { ERROR_ROLE_NOT_WEB_GRANTABLE } from '../../http/error_schemas.js';
34
44
  import { JSONRPC_ERROR_CODES } from '../../http/jsonrpc_errors.js';
35
45
  import { list_audit_events } from './audit_cross_helpers.js';
@@ -52,13 +62,41 @@ const OFF_GRAMMAR_ROLES = [
52
62
  'role1', // digit
53
63
  '_role', // leading underscore
54
64
  'role_', // trailing underscore
65
+ 'role__name', // a run of two underscores
66
+ 'role___name', // a run of three
55
67
  'role name', // space
56
68
  '', // empty
57
69
  OVER_LENGTH_ROLE // on the alphabet, one past the length cap
58
70
  ];
59
71
  /** On the grammar, held by no registry. */
60
72
  const UNREGISTERED_ROLE = 'not_a_registered_role';
73
+ /**
74
+ * The longest scope kind the grammar admits — an independent copy of the
75
+ * producers' `SCOPE_KIND_LENGTH_MAX`.
76
+ */
77
+ const SCOPE_KIND_LENGTH_MAX = 64;
78
+ /** Each breaks one rule of the `ScopeKindName` grammar. */
79
+ const OFF_GRAMMAR_SCOPE_KINDS = [
80
+ 'GLOBAL', // the partial unique indexes' token for a global grant
81
+ 'Classroom', // uppercase
82
+ 'a__b', // a run of two underscores
83
+ '_a', // leading underscore
84
+ 'a_', // trailing underscore
85
+ 'a1', // digit
86
+ '', // empty
87
+ 'a'.repeat(SCOPE_KIND_LENGTH_MAX + 1) // on the alphabet, one past the length cap
88
+ ];
89
+ /** On the grammar, the second exactly at the length cap. */
90
+ const ON_GRAMMAR_SCOPE_KINDS = [
91
+ 'classroom',
92
+ 'a'.repeat(SCOPE_KIND_LENGTH_MAX)
93
+ ];
61
94
  const GRANT_METHODS = ['role_grant_assign', 'role_grant_offer_create'];
95
+ /** What each grant verb refuses an unregistered role with, past validation. */
96
+ const NOT_GRANTABLE_REASONS = {
97
+ role_grant_assign: ERROR_ROLE_NOT_WEB_GRANTABLE,
98
+ role_grant_offer_create: ERROR_ROLE_GRANT_OFFER_ROLE_NOT_GRANTABLE
99
+ };
62
100
  /** The audit event types the grant verbs write. */
63
101
  const GRANT_EVENT_TYPES = ['role_grant_create', 'role_grant_offer_create'];
64
102
  export const describe_role_grant_role_grammar_cross_tests = (options) => {
@@ -111,4 +149,54 @@ export const describe_role_grant_role_grammar_cross_tests = (options) => {
111
149
  }
112
150
  });
113
151
  });
152
+ describe('grant verbs refuse an off-grammar scope_kind at validation', () => {
153
+ const scoped = (scope_kind) => ({
154
+ to_account_id: NIL_UUID,
155
+ role: UNREGISTERED_ROLE,
156
+ scope_kind,
157
+ scope_id: NIL_UUID
158
+ });
159
+ for (const method of GRANT_METHODS) {
160
+ test(`${method}: an off-grammar scope_kind is invalid_params with no reason`, async () => {
161
+ const fixture = await setup_test();
162
+ const t = fixture.fresh_transport();
163
+ for (const scope_kind of OFF_GRAMMAR_SCOPE_KINDS) {
164
+ const res = await cross_rpc_call(t, rpc_path, method, scoped(scope_kind), fixture.create_session_headers());
165
+ const label = `${method} scope_kind=${JSON.stringify(scope_kind)}`;
166
+ assert.strictEqual(res.ok, false, `${label}: expected a refusal`);
167
+ assert.strictEqual(res.error?.code, JSONRPC_ERROR_CODES.invalid_params, label);
168
+ // a validation refusal, not the grant-path one an unregistered role gets
169
+ assert.strictEqual(error_reason(res), undefined, `${label}: no data.reason`);
170
+ }
171
+ // on the grammar, the same call reaches the grant-path gate
172
+ for (const scope_kind of ON_GRAMMAR_SCOPE_KINDS) {
173
+ const res = await cross_rpc_call(t, rpc_path, method, scoped(scope_kind), fixture.create_session_headers());
174
+ assert.strictEqual(error_reason(res), NOT_GRANTABLE_REASONS[method], `${method} scope_kind=${JSON.stringify(scope_kind)}: passes validation`);
175
+ }
176
+ });
177
+ }
178
+ test('an off-grammar scope_kind writes no audit row', async () => {
179
+ const fixture = await setup_test();
180
+ const t = fixture.fresh_transport();
181
+ const session = fixture.create_session_headers();
182
+ for (const method of GRANT_METHODS) {
183
+ for (const scope_kind of [...OFF_GRAMMAR_SCOPE_KINDS, ...ON_GRAMMAR_SCOPE_KINDS]) {
184
+ await cross_rpc_call(t, rpc_path, method, scoped(scope_kind), session);
185
+ }
186
+ }
187
+ for (const event_type of GRANT_EVENT_TYPES) {
188
+ const events = await list_audit_events(fixture, { event_type }, rpc_path);
189
+ const scope_kinds = events.map((event) => event.metadata?.scope_kind);
190
+ for (const scope_kind of scope_kinds) {
191
+ assert.ok(typeof scope_kind !== 'string' || !OFF_GRAMMAR_SCOPE_KINDS.includes(scope_kind), `${event_type}: an audit row records the off-grammar scope_kind ${JSON.stringify(scope_kind)}`);
192
+ }
193
+ if (event_type === 'role_grant_create') {
194
+ // the on-grammar refusals' failure rows are in the same read, so it is not vacuous
195
+ for (const scope_kind of ON_GRAMMAR_SCOPE_KINDS) {
196
+ assert.ok(scope_kinds.includes(scope_kind), `the scope_kind=${JSON.stringify(scope_kind)} refusal wrote its failure row`);
197
+ }
198
+ }
199
+ }
200
+ });
201
+ });
114
202
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_app",
3
- "version": "0.158.0",
3
+ "version": "0.159.0",
4
4
  "description": "fullstack app library",
5
5
  "glyph": "🗝",
6
6
  "logo": "logo.svg",