@fuzdev/fuz_app 0.159.0 → 0.161.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 (85) hide show
  1. package/dist/actions/CLAUDE.md +7 -2
  2. package/dist/actions/protocol.d.ts +7 -0
  3. package/dist/actions/protocol.d.ts.map +1 -1
  4. package/dist/actions/protocol.js +19 -4
  5. package/dist/auth/CLAUDE.md +47 -24
  6. package/dist/auth/account_schema.d.ts +2 -2
  7. package/dist/auth/account_schema.d.ts.map +1 -1
  8. package/dist/auth/account_schema.js +1 -1
  9. package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
  10. package/dist/auth/actor_search_action_specs.d.ts +6 -6
  11. package/dist/auth/admin_action_specs.d.ts +1051 -321
  12. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  13. package/dist/auth/admin_action_specs.js +150 -166
  14. package/dist/auth/app_settings_schema.d.ts +46 -23
  15. package/dist/auth/app_settings_schema.d.ts.map +1 -1
  16. package/dist/auth/app_settings_schema.js +12 -15
  17. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  18. package/dist/auth/audit_log_schema.d.ts +14 -3
  19. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  20. package/dist/auth/audit_log_schema.js +20 -7
  21. package/dist/auth/audit_log_schema_fuz.d.ts +39 -0
  22. package/dist/auth/audit_log_schema_fuz.d.ts.map +1 -0
  23. package/dist/auth/audit_log_schema_fuz.js +37 -0
  24. package/dist/auth/credential_type_schema.d.ts +4 -7
  25. package/dist/auth/credential_type_schema.d.ts.map +1 -1
  26. package/dist/auth/credential_type_schema.js +6 -10
  27. package/dist/auth/grant_path_schema.d.ts +4 -7
  28. package/dist/auth/grant_path_schema.d.ts.map +1 -1
  29. package/dist/auth/grant_path_schema.js +6 -10
  30. package/dist/auth/name_schema.d.ts +63 -0
  31. package/dist/auth/name_schema.d.ts.map +1 -0
  32. package/dist/auth/name_schema.js +65 -0
  33. package/dist/auth/request_context.d.ts.map +1 -1
  34. package/dist/auth/request_context.js +2 -1
  35. package/dist/auth/role_grant_offer_action_specs.d.ts +2257 -400
  36. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  37. package/dist/auth/role_grant_offer_action_specs.js +104 -100
  38. package/dist/auth/role_grant_offer_actions.d.ts +6 -3
  39. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  40. package/dist/auth/role_grant_offer_actions.js +15 -6
  41. package/dist/auth/role_grant_offer_notifications.d.ts +1364 -255
  42. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  43. package/dist/auth/role_grant_offer_notifications.js +100 -47
  44. package/dist/auth/role_grant_offer_schema.d.ts +90 -22
  45. package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
  46. package/dist/auth/role_grant_offer_schema.js +40 -39
  47. package/dist/auth/role_schema.d.ts +14 -25
  48. package/dist/auth/role_schema.d.ts.map +1 -1
  49. package/dist/auth/role_schema.js +15 -29
  50. package/dist/auth/role_schema_fuz.d.ts +4 -3
  51. package/dist/auth/role_schema_fuz.d.ts.map +1 -1
  52. package/dist/auth/role_schema_fuz.js +7 -5
  53. package/dist/auth/scope_kind_schema.d.ts +13 -21
  54. package/dist/auth/scope_kind_schema.d.ts.map +1 -1
  55. package/dist/auth/scope_kind_schema.js +15 -26
  56. package/dist/auth/scope_kind_schema_fuz.d.ts +31 -0
  57. package/dist/auth/scope_kind_schema_fuz.d.ts.map +1 -0
  58. package/dist/auth/scope_kind_schema_fuz.js +31 -0
  59. package/dist/auth/self_service_role_action_specs.d.ts +2 -2
  60. package/dist/auth/token_scope.d.ts +7 -13
  61. package/dist/auth/token_scope.d.ts.map +1 -1
  62. package/dist/auth/token_scope.js +9 -14
  63. package/dist/primitive_schemas.d.ts +46 -0
  64. package/dist/primitive_schemas.d.ts.map +1 -1
  65. package/dist/primitive_schemas.js +39 -14
  66. package/dist/primitive_schemas_fuz.d.ts +35 -7
  67. package/dist/primitive_schemas_fuz.d.ts.map +1 -1
  68. package/dist/primitive_schemas_fuz.js +30 -6
  69. package/dist/testing/CLAUDE.md +19 -11
  70. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -1
  71. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  72. package/dist/testing/cross_backend/identity_parity.js +20 -11
  73. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +15 -3
  74. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  75. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +60 -17
  76. package/dist/testing/cross_backend/role_grant_role_grammar.d.ts.map +1 -1
  77. package/dist/testing/cross_backend/role_grant_role_grammar.js +8 -15
  78. package/dist/testing/cross_backend/spine_suites.d.ts +4 -3
  79. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  80. package/dist/testing/cross_backend/spine_suites.js +2 -1
  81. package/dist/ui/CLAUDE.md +4 -4
  82. package/dist/ui/admin_accounts_state.svelte.d.ts +8 -8
  83. package/dist/ui/role_grant_offers_state.svelte.d.ts +9 -9
  84. package/dist/ui/role_grant_offers_state.svelte.js +4 -4
  85. package/package.json +1 -1
@@ -24,29 +24,18 @@ import { z } from 'zod';
24
24
  import { type CredentialTypeSchemaResult } from './credential_type_schema.js';
25
25
  import { type GrantPathSchemaResult } from './grant_path_schema.js';
26
26
  import type { ScopeKindSchemaResult } from './scope_kind_schema.js';
27
+ /** The message of a role name longer than `NAME_LENGTH_MAX`, in both `RoleName`s. */
28
+ export declare const ROLE_NAME_LENGTH_MESSAGE: string;
29
+ /** The message of a role name off `NAME_REGEX`, in both `RoleName`s. */
30
+ export declare const ROLE_NAME_PATTERN_MESSAGE: string;
27
31
  /**
28
- * The longest role name `RoleName` admits, in characters. A role string is
29
- * caller-chosen text until it passes the grammar, and the grant verbs record
30
- * the role they refuse in a failure audit row, so the grammar bounds its
31
- * length too. Same value as the Rust spine's `ROLE_NAME_LENGTH_MAX`.
32
- */
33
- export declare const ROLE_NAME_LENGTH_MAX = 64;
34
- /**
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.
32
+ * Valid role name: the shared name grammar (`auth/name_schema.ts`), lowercase
33
+ * letters and underscores, no leading, trailing or consecutive underscores, at
34
+ * most `NAME_LENGTH_MAX` characters. A role string is caller-chosen text until
35
+ * it passes the grammar, and the grant verbs record the role they refuse in a
36
+ * failure audit row, so the grammar bounds its length too. Both `RoleName`s
37
+ * hold it, the Zod one here and the `@fuzdev/fuz_schema` twin in
38
+ * `auth/role_schema_fuz.ts`.
50
39
  */
51
40
  export declare const RoleName: z.ZodString;
52
41
  export type RoleName = z.infer<typeof RoleName>;
@@ -101,7 +90,7 @@ export declare const is_builtin_role: (name: string) => name is BuiltinRole;
101
90
  * `builtin_role_specs_by_name`.
102
91
  */
103
92
  export interface RoleSpec {
104
- /** Unique role name. Must match `RoleName` — its regex and length cap; collisions with builtins throw. */
93
+ /** Unique role name. Must match `RoleName` — the name grammar and its length cap; collisions with builtins throw. */
105
94
  name: string;
106
95
  /** Admin-UI-facing copy describing the role's intent. */
107
96
  description?: string;
@@ -175,8 +164,8 @@ export interface RoleSchemaResult {
175
164
  *
176
165
  * Construction-time guards (all fire on misconfiguration):
177
166
  *
178
- * 1. Every `consumer_roles[i].name` matches `RoleName` — its regex and its
179
- * `ROLE_NAME_LENGTH_MAX` length cap.
167
+ * 1. Every `consumer_roles[i].name` matches `RoleName` — the name grammar
168
+ * and its `NAME_LENGTH_MAX` length cap.
180
169
  * 2. No two consumer roles share a name.
181
170
  * 3. No consumer role collides with a builtin (`keeper` / `admin`).
182
171
  * 4. When `options.credential_types` is supplied, every entry in
@@ -1 +1 @@
1
- {"version":3,"file":"role_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAEN,KAAK,0BAA0B,EAC/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGN,KAAK,qBAAqB,EAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,QAAyB,CAAC;AAExD,0FAA0F;AAC1F,eAAO,MAAM,wBAAwB,6CAAkE,CAAC;AAExG,mFAAmF;AACnF,eAAO,MAAM,yBAAyB,iHACyE,CAAC;AAEhH;;;GAGG;AACH,eAAO,MAAM,QAAQ,aAGiC,CAAC;AACvD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAIhD,sFAAsF;AACtF,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,iEAAiE;AACjE,eAAO,MAAM,UAAU,UAAU,CAAC;AAElC,+CAA+C;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AA4B,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"}
@@ -21,37 +21,23 @@
21
21
  * @module
22
22
  */
23
23
  import { z } from 'zod';
24
- import { bounded_string } from '../primitive_schemas.js';
25
24
  import { CREDENTIAL_TYPE_DAEMON_TOKEN } from './credential_type_schema.js';
26
25
  import { GRANT_PATH_ADMIN, GRANT_PATH_BOOTSTRAP } from './grant_path_schema.js';
26
+ import { create_name_schema, format_name_length_message, format_name_pattern_message } from './name_schema.js';
27
+ /** The message of a role name longer than `NAME_LENGTH_MAX`, in both `RoleName`s. */
28
+ export const ROLE_NAME_LENGTH_MESSAGE = format_name_length_message('Role');
29
+ /** The message of a role name off `NAME_REGEX`, in both `RoleName`s. */
30
+ export const ROLE_NAME_PATTERN_MESSAGE = format_name_pattern_message('Role');
27
31
  /**
28
- * The longest role name `RoleName` admits, in characters. A role string is
29
- * caller-chosen text until it passes the grammar, and the grant verbs record
30
- * the role they refuse in a failure audit row, so the grammar bounds its
31
- * length too. Same value as the Rust spine's `ROLE_NAME_LENGTH_MAX`.
32
+ * Valid role name: the shared name grammar (`auth/name_schema.ts`), lowercase
33
+ * letters and underscores, no leading, trailing or consecutive underscores, at
34
+ * most `NAME_LENGTH_MAX` characters. A role string is caller-chosen text until
35
+ * it passes the grammar, and the grant verbs record the role they refuse in a
36
+ * failure audit row, so the grammar bounds its length too. Both `RoleName`s
37
+ * hold it, the Zod one here and the `@fuzdev/fuz_schema` twin in
38
+ * `auth/role_schema_fuz.ts`.
32
39
  */
33
- export const ROLE_NAME_LENGTH_MAX = 64;
34
- /**
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.
50
- */
51
- export const RoleName = bounded_string({
52
- max: ROLE_NAME_LENGTH_MAX,
53
- max_message: ROLE_NAME_LENGTH_MESSAGE
54
- }).regex(ROLE_NAME_PATTERN, ROLE_NAME_PATTERN_MESSAGE);
40
+ export const RoleName = create_name_schema('Role');
55
41
  // Builtin roles — provided by fuz_app, always available.
56
42
  /** System-level role. Requires daemon token (filesystem proof). Controls the keep. */
57
43
  export const ROLE_KEEPER = 'keeper';
@@ -127,8 +113,8 @@ const validate_registry_membership = (role_name, field, values, registry) => {
127
113
  *
128
114
  * Construction-time guards (all fire on misconfiguration):
129
115
  *
130
- * 1. Every `consumer_roles[i].name` matches `RoleName` — its regex and its
131
- * `ROLE_NAME_LENGTH_MAX` length cap.
116
+ * 1. Every `consumer_roles[i].name` matches `RoleName` — the name grammar
117
+ * and its `NAME_LENGTH_MAX` length cap.
132
118
  * 2. No two consumer roles share a name.
133
119
  * 3. No consumer role collides with a builtin (`keeper` / `admin`).
134
120
  * 4. When `options.credential_types` is supplied, every entry in
@@ -2,8 +2,9 @@
2
2
  * The `@fuzdev/fuz_schema` twin of the Zod `RoleName` (`auth/role_schema.ts`),
3
3
  * under the same name, for schemas written in fuz_schema.
4
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
5
+ * Both are built from the same constants, the bound and the grammar of
6
+ * `auth/name_schema.ts` and the two messages `role_schema.ts` exports, so
7
+ * they can't drift apart. They give every input
7
8
  * the same verdict and output, and write the same JSON Schema
8
9
  * (`maxLength` and `pattern`); a string both too long and outside the grammar
9
10
  * gets the one length issue from this twin, as its `pipe` stops at the first
@@ -17,7 +18,7 @@
17
18
  import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
18
19
  /**
19
20
  * 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
+ * consecutive underscores, at most `NAME_LENGTH_MAX` UTF-16 code units, the twin of
21
22
  * the Zod `RoleName`. A string it refuses gets the Zod one's message; a
22
23
  * value that is no string, fuz_schema's.
23
24
  *
@@ -1 +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"}
1
+ {"version":3,"file":"role_schema_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_schema_fuz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAwB,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAMhF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,0MAGpB,CAAC;AACF,cAAc;AACd,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC"}
@@ -2,8 +2,9 @@
2
2
  * The `@fuzdev/fuz_schema` twin of the Zod `RoleName` (`auth/role_schema.ts`),
3
3
  * under the same name, for schemas written in fuz_schema.
4
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
5
+ * Both are built from the same constants, the bound and the grammar of
6
+ * `auth/name_schema.ts` and the two messages `role_schema.ts` exports, so
7
+ * they can't drift apart. They give every input
7
8
  * the same verdict and output, and write the same JSON Schema
8
9
  * (`maxLength` and `pattern`); a string both too long and outside the grammar
9
10
  * gets the one length issue from this twin, as its `pipe` stops at the first
@@ -16,13 +17,14 @@
16
17
  */
17
18
  import { message, pipe, regex } from '@fuzdev/fuz_schema/schema.ts';
18
19
  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
+ import { NAME_LENGTH_MAX, NAME_REGEX } from './name_schema.js';
21
+ import { ROLE_NAME_LENGTH_MESSAGE, ROLE_NAME_PATTERN_MESSAGE } from './role_schema.js';
20
22
  /**
21
23
  * 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
24
+ * consecutive underscores, at most `NAME_LENGTH_MAX` UTF-16 code units, the twin of
23
25
  * the Zod `RoleName`. A string it refuses gets the Zod one's message; a
24
26
  * value that is no string, fuz_schema's.
25
27
  *
26
28
  * @nodocs
27
29
  */
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));
30
+ export const RoleName = pipe(bounded_string({ max: NAME_LENGTH_MAX, max_message: ROLE_NAME_LENGTH_MESSAGE }), message(regex(NAME_REGEX), ROLE_NAME_PATTERN_MESSAGE));
@@ -32,28 +32,20 @@
32
32
  * @module
33
33
  */
34
34
  import { z } from 'zod';
35
- /**
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.
40
- */
41
- export declare const SCOPE_KIND_NAME_REGEX: RegExp;
42
- /**
43
- * Maximum length of a `scope_kind`, in UTF-16 code units (what
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
48
- * registry declares a kind the grant inputs would refuse. Same value as
49
- * `ROLE_NAME_LENGTH_MAX`, whose grammar the name shares, and as the Rust
50
- * spine's `SCOPE_KIND_LENGTH_MAX`.
51
- */
52
- export declare const SCOPE_KIND_LENGTH_MAX = 64;
35
+ /** The message of a scope-kind name longer than `NAME_LENGTH_MAX`, in both `ScopeKindName`s. */
36
+ export declare const SCOPE_KIND_NAME_LENGTH_MESSAGE: string;
37
+ /** The message of a scope-kind name off `NAME_REGEX`, in both `ScopeKindName`s. */
38
+ export declare const SCOPE_KIND_NAME_PATTERN_MESSAGE: string;
53
39
  /**
54
40
  * 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`.
41
+ * `scope_kind` the grant inputs take. The shared name grammar
42
+ * (`auth/name_schema.ts`), at most `NAME_LENGTH_MAX` UTF-16 code units, which
43
+ * bounds a registered name and the tag where it enters — the grant inputs
44
+ * (`role_grant_offer_create`, `role_grant_assign`) copy it into the row and
45
+ * its audit metadata — so no registry declares a kind the grant inputs would
46
+ * refuse. Off the grammar is the index-side `'GLOBAL'` token. Twin of the Rust
47
+ * spine's `is_valid_name`, and of the `@fuzdev/fuz_schema` `ScopeKindName` in
48
+ * `auth/scope_kind_schema_fuz.ts`, built from the same constants.
57
49
  */
58
50
  export declare const ScopeKindName: z.ZodString;
59
51
  export type ScopeKindName = z.infer<typeof ScopeKindName>;
@@ -99,7 +91,7 @@ export interface ScopeKindSchemaResult {
99
91
  * @param consumer_kinds - the consumer-declared scope-kind set with optional metadata
100
92
  * @returns `{ScopeKind, scope_kinds}` — Zod schema and metadata map
101
93
  *
102
- * @throws Error if any `consumer_kinds` key fails the `ScopeKindName` regex or appears more than once
94
+ * @throws Error if any `consumer_kinds` key fails `ScopeKindName` (its grammar or its length cap) or appears more than once
103
95
  *
104
96
  * @example
105
97
  * ```ts
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
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;AAQxB,gGAAgG;AAChG,eAAO,MAAM,8BAA8B,QAA2C,CAAC;AAEvF,mFAAmF;AACnF,eAAO,MAAM,+BAA+B,QAA4C,CAAC;AAEzF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,aAAmC,CAAC;AAC9D,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"}
@@ -32,34 +32,23 @@
32
32
  * @module
33
33
  */
34
34
  import { z } from 'zod';
35
- import { bounded_string } from '../primitive_schemas.js';
36
- /**
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.
41
- */
42
- export const SCOPE_KIND_NAME_REGEX = /^[a-z]+(?:_[a-z]+)*$/;
43
- /**
44
- * Maximum length of a `scope_kind`, in UTF-16 code units (what
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
49
- * registry declares a kind the grant inputs would refuse. Same value as
50
- * `ROLE_NAME_LENGTH_MAX`, whose grammar the name shares, and as the Rust
51
- * spine's `SCOPE_KIND_LENGTH_MAX`.
52
- */
53
- export const SCOPE_KIND_LENGTH_MAX = 64;
35
+ import { create_name_schema, format_name_length_message, format_name_pattern_message } from './name_schema.js';
36
+ /** The message of a scope-kind name longer than `NAME_LENGTH_MAX`, in both `ScopeKindName`s. */
37
+ export const SCOPE_KIND_NAME_LENGTH_MESSAGE = format_name_length_message('Scope-kind');
38
+ /** The message of a scope-kind name off `NAME_REGEX`, in both `ScopeKindName`s. */
39
+ export const SCOPE_KIND_NAME_PATTERN_MESSAGE = format_name_pattern_message('Scope-kind');
54
40
  /**
55
41
  * 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`.
42
+ * `scope_kind` the grant inputs take. The shared name grammar
43
+ * (`auth/name_schema.ts`), at most `NAME_LENGTH_MAX` UTF-16 code units, which
44
+ * bounds a registered name and the tag where it enters — the grant inputs
45
+ * (`role_grant_offer_create`, `role_grant_assign`) copy it into the row and
46
+ * its audit metadata — so no registry declares a kind the grant inputs would
47
+ * refuse. Off the grammar is the index-side `'GLOBAL'` token. Twin of the Rust
48
+ * spine's `is_valid_name`, and of the `@fuzdev/fuz_schema` `ScopeKindName` in
49
+ * `auth/scope_kind_schema_fuz.ts`, built from the same constants.
58
50
  */
59
- export const ScopeKindName = bounded_string({
60
- max: SCOPE_KIND_LENGTH_MAX,
61
- max_message: `Scope-kind names must be at most ${SCOPE_KIND_LENGTH_MAX} characters`
62
- }).regex(SCOPE_KIND_NAME_REGEX, 'Scope-kind names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores');
51
+ export const ScopeKindName = create_name_schema('Scope-kind');
63
52
  /**
64
53
  * Create a scope-kind schema from a consumer-declared registry.
65
54
  *
@@ -79,7 +68,7 @@ export const ScopeKindName = bounded_string({
79
68
  * @param consumer_kinds - the consumer-declared scope-kind set with optional metadata
80
69
  * @returns `{ScopeKind, scope_kinds}` — Zod schema and metadata map
81
70
  *
82
- * @throws Error if any `consumer_kinds` key fails the `ScopeKindName` regex or appears more than once
71
+ * @throws Error if any `consumer_kinds` key fails `ScopeKindName` (its grammar or its length cap) or appears more than once
83
72
  *
84
73
  * @example
85
74
  * ```ts
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The `@fuzdev/fuz_schema` twin of the Zod `ScopeKindName`
3
+ * (`auth/scope_kind_schema.ts`), under the same name, for schemas written in
4
+ * fuz_schema.
5
+ *
6
+ * Both are built from the same constants, the bound and the grammar of
7
+ * `auth/name_schema.ts` and the two messages `scope_kind_schema.ts` exports,
8
+ * so they can't drift apart. They give every
9
+ * input the same verdict and output, and write the same JSON Schema
10
+ * (`maxLength` and `pattern`); a string both too long and outside the grammar
11
+ * gets the one length issue from this twin, as its `pipe` stops at the first
12
+ * failing step, where the Zod one adds the grammar issue after it.
13
+ *
14
+ * The export is `@nodocs` while the Zod `ScopeKindName` stays, as the docs
15
+ * build refuses two exports of one name.
16
+ *
17
+ * @module
18
+ */
19
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
20
+ /**
21
+ * Valid scope-kind name: runs of lowercase letters joined by single
22
+ * underscores, at most `NAME_LENGTH_MAX` UTF-16 code units, the twin of
23
+ * the Zod `ScopeKindName`. 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 declare const ScopeKindName: 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>>>;
29
+ /** @nodocs */
30
+ export type ScopeKindName = Infer<typeof ScopeKindName>;
31
+ //# sourceMappingURL=scope_kind_schema_fuz.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope_kind_schema_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/scope_kind_schema_fuz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAwB,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAShF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,0MAGzB,CAAC;AACF,cAAc;AACd,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The `@fuzdev/fuz_schema` twin of the Zod `ScopeKindName`
3
+ * (`auth/scope_kind_schema.ts`), under the same name, for schemas written in
4
+ * fuz_schema.
5
+ *
6
+ * Both are built from the same constants, the bound and the grammar of
7
+ * `auth/name_schema.ts` and the two messages `scope_kind_schema.ts` exports,
8
+ * so they can't drift apart. They give every
9
+ * input the same verdict and output, and write the same JSON Schema
10
+ * (`maxLength` and `pattern`); a string both too long and outside the grammar
11
+ * gets the one length issue from this twin, as its `pipe` stops at the first
12
+ * failing step, where the Zod one adds the grammar issue after it.
13
+ *
14
+ * The export is `@nodocs` while the Zod `ScopeKindName` stays, as the docs
15
+ * build refuses two exports of one name.
16
+ *
17
+ * @module
18
+ */
19
+ import { message, pipe, regex } from '@fuzdev/fuz_schema/schema.ts';
20
+ import { bounded_string } from '../primitive_schemas_fuz.js';
21
+ import { NAME_LENGTH_MAX, NAME_REGEX } from './name_schema.js';
22
+ import { SCOPE_KIND_NAME_LENGTH_MESSAGE, SCOPE_KIND_NAME_PATTERN_MESSAGE } from './scope_kind_schema.js';
23
+ /**
24
+ * Valid scope-kind name: runs of lowercase letters joined by single
25
+ * underscores, at most `NAME_LENGTH_MAX` UTF-16 code units, the twin of
26
+ * the Zod `ScopeKindName`. A string it refuses gets the Zod one's message; a
27
+ * value that is no string, fuz_schema's.
28
+ *
29
+ * @nodocs
30
+ */
31
+ export const ScopeKindName = pipe(bounded_string({ max: NAME_LENGTH_MAX, max_message: SCOPE_KIND_NAME_LENGTH_MESSAGE }), message(regex(NAME_REGEX), SCOPE_KIND_NAME_PATTERN_MESSAGE));
@@ -23,7 +23,7 @@ export declare const SelfServiceRoleSetInput: import("@fuzdev/fuz_schema/schema.
23
23
  }, "object", {
24
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
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">)[]> & {
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<"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"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
27
27
  readonly '~types'?: {
28
28
  readonly input: string;
29
29
  readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
@@ -85,7 +85,7 @@ export declare const self_service_role_set_action_spec: {
85
85
  }, "object", {
86
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
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">)[]> & {
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<"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"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
89
89
  readonly '~types'?: {
90
90
  readonly input: string;
91
91
  readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
@@ -149,17 +149,6 @@ export type TokenSurface = (typeof TOKEN_SURFACES)[number];
149
149
  * mount.
150
150
  */
151
151
  export declare const is_token_surface: (value: string) => value is TokenSurface;
152
- /**
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.
156
- *
157
- * Applied to the `surface:` arm only. The `rpc:` arm's identifier is an action
158
- * method name, whose vocabulary belongs to `ActionSpec` (and includes shapes
159
- * like `peer/ping` this regex would refuse); the dispatcher computes it from the
160
- * registered method, so nothing parses one.
161
- */
162
- export declare const TOKEN_SURFACE_NAME_REGEX: RegExp;
163
152
  /**
164
153
  * The capability string an action method is refused under: `rpc:<method>`.
165
154
  *
@@ -179,8 +168,13 @@ export declare const token_scope_method_capability: (method: string) => string;
179
168
  * Callers turn `false` into a registration-time throw: `RouteAuth.required_scope`
180
169
  * is typed as a plain string so `http/` needs no `auth/` import, and this is the
181
170
  * single point where that string becomes a mounted guard, so it is where the
182
- * value gets checked. The identifier is checked for shape
183
- * (`TOKEN_SURFACE_NAME_REGEX`), not membership — a consumer names its own surface.
171
+ * value gets checked. The identifier is checked for shape, not membership —
172
+ * a consumer names its own surface: the shared name grammar (`is_valid_name`),
173
+ * runs of lowercase letters joined by single underscores, at most
174
+ * `NAME_LENGTH_MAX` characters. The `rpc:` arm's identifier is an action method
175
+ * name, whose vocabulary belongs to `ActionSpec` (and includes shapes like
176
+ * `peer/ping` the grammar would refuse); the dispatcher computes it from the
177
+ * registered method, so nothing parses one.
184
178
  *
185
179
  * @param value - the declared capability string, e.g. `surface:audit_stream`
186
180
  * @returns whether `value` is a well-formed `surface:<name>` capability
@@ -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,eAAe;;;;;4BAG1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,QAAO,UAGlC,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AAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,YACA,CAAC;AAQ3D;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GAAI,QAAQ,MAAM,KAAG,MAC3B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,KAAG,OAEG,CAAC;AAE9D;;;;;;;;;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"}
@@ -29,6 +29,7 @@
29
29
  * @module
30
30
  */
31
31
  import { z } from 'zod';
32
+ import { is_valid_name } from './name_schema.js';
32
33
  /** Current `TokenScope` document version. Must match the Rust `TOKEN_SCOPE_VERSION`. */
33
34
  export const TOKEN_SCOPE_VERSION = 1;
34
35
  /**
@@ -161,17 +162,6 @@ export const TOKEN_SURFACES = [
161
162
  * mount.
162
163
  */
163
164
  export const is_token_surface = (value) => TOKEN_SURFACES.includes(value);
164
- /**
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.
168
- *
169
- * Applied to the `surface:` arm only. The `rpc:` arm's identifier is an action
170
- * method name, whose vocabulary belongs to `ActionSpec` (and includes shapes
171
- * like `peer/ping` this regex would refuse); the dispatcher computes it from the
172
- * registered method, so nothing parses one.
173
- */
174
- export const TOKEN_SURFACE_NAME_REGEX = /^[a-z]+(?:_[a-z]+)*$/;
175
165
  // Capability-string prefixes. Private: `token_scope_method_capability` builds
176
166
  // the one capability anything computes, and `is_route_scope_capability` checks
177
167
  // the one a route declares, so nothing outside this module concatenates these.
@@ -196,14 +186,19 @@ export const token_scope_method_capability = (method) => `${CAPABILITY_RPC_PREFI
196
186
  * Callers turn `false` into a registration-time throw: `RouteAuth.required_scope`
197
187
  * is typed as a plain string so `http/` needs no `auth/` import, and this is the
198
188
  * single point where that string becomes a mounted guard, so it is where the
199
- * value gets checked. The identifier is checked for shape
200
- * (`TOKEN_SURFACE_NAME_REGEX`), not membership — a consumer names its own surface.
189
+ * value gets checked. The identifier is checked for shape, not membership —
190
+ * a consumer names its own surface: the shared name grammar (`is_valid_name`),
191
+ * runs of lowercase letters joined by single underscores, at most
192
+ * `NAME_LENGTH_MAX` characters. The `rpc:` arm's identifier is an action method
193
+ * name, whose vocabulary belongs to `ActionSpec` (and includes shapes like
194
+ * `peer/ping` the grammar would refuse); the dispatcher computes it from the
195
+ * registered method, so nothing parses one.
201
196
  *
202
197
  * @param value - the declared capability string, e.g. `surface:audit_stream`
203
198
  * @returns whether `value` is a well-formed `surface:<name>` capability
204
199
  */
205
200
  export const is_route_scope_capability = (value) => value.startsWith(CAPABILITY_SURFACE_PREFIX) &&
206
- TOKEN_SURFACE_NAME_REGEX.test(value.slice(CAPABILITY_SURFACE_PREFIX.length));
201
+ is_valid_name(value.slice(CAPABILITY_SURFACE_PREFIX.length));
207
202
  /**
208
203
  * Build the flat denial body a non-RPC route returns when a narrowed token
209
204
  * reaches a capability it lacks:
@@ -59,6 +59,12 @@ export declare const bounded_string: (options: BoundedStringOptions) => z.ZodStr
59
59
  export declare const USERNAME_LENGTH_MIN = 3;
60
60
  /** Maximum username length (matches GitHub's limit). The grammar is ASCII, so units and characters agree. */
61
61
  export declare const USERNAME_LENGTH_MAX = 39;
62
+ /**
63
+ * The creation username's grammar: a letter, then letters, digits, `_` or
64
+ * `-`, ending in a letter or digit. ASCII, so it needs at least two
65
+ * characters, and `Username` bounds the length beside it.
66
+ */
67
+ export declare const USERNAME_REGEX: RegExp;
62
68
  /** Maximum length for username input on login/lookup, in UTF-16 code units, measured before trimming — more permissive than `USERNAME_LENGTH_MAX` for forward-compatibility if the creation limit is raised. */
63
69
  export declare const USERNAME_PROVIDED_LENGTH_MAX = 255;
64
70
  /**
@@ -96,6 +102,43 @@ export type UsernameProvided = z.infer<typeof UsernameProvided>;
96
102
  * Rust spine's `s.len()` check; for an all-ASCII address bytes == characters.
97
103
  */
98
104
  export declare const EMAIL_LENGTH_MAX = 254;
105
+ /**
106
+ * Loose email shape `local@domain.tld`: a non-empty local part, exactly one
107
+ * `@`, a domain that holds a `.` and neither starts nor ends with one, and
108
+ * no whitespace. Accepts `a@b.c` (single-char TLDs are fine), `a@b..c` and
109
+ * `user+tag@a.co`; rejects `notanemail`, `@x.com`, `user@`, `user@host`,
110
+ * `a@.b.c`, `a@b.c.`, and any whitespace. The Rust spine's `is_valid_email`
111
+ * is the same rule.
112
+ *
113
+ * The negated class excludes `\s` **plus** U+0085 (NEL): JS's `\s` omits
114
+ * U+0085 but Unicode `White_Space` (Rust's `char::is_whitespace`) includes
115
+ * it, so excluding it keeps the whitespace set identical across the twins.
116
+ * (The Rust side correspondingly also rejects U+FEFF, which JS `\s` treats as
117
+ * whitespace but Unicode `White_Space` does not — so both spines reject
118
+ * exactly `White_Space ∪ {U+FEFF}`.)
119
+ *
120
+ * Linear in the input's length: the `@` can match only the first `@`, and the
121
+ * `\.` only the domain's first `.`, since the classes before each exclude it,
122
+ * so the tail after the `\.` is scanned once. The domain spelled
123
+ * `[^\s\u0085@.][^\s\u0085@]*\.[^\s\u0085@]*[^\s\u0085@.]`, the same
124
+ * language, is quadratic: it tries every `.` as the split.
125
+ */
126
+ export declare const EMAIL_REGEX: RegExp;
127
+ /** The message of an email over `EMAIL_LENGTH_MAX` bytes, on either schema library's `Email`. */
128
+ export declare const EMAIL_LENGTH_MESSAGE = "Email must be at most 254 bytes";
129
+ /**
130
+ * Whether `s` is at most `EMAIL_LENGTH_MAX` bytes in UTF-8, the bound both
131
+ * `Email` schemas check.
132
+ *
133
+ * `s.length` (UTF-16 units) is a cheap upper bound that short-circuits the
134
+ * `encode` on absurd inputs: a valid (<= 254-byte) address is necessarily
135
+ * <= 254 code units, so it never refuses one — the byte count is the real
136
+ * RFC-5321 octet bound, matching the Rust spine's `s.len()`.
137
+ *
138
+ * @param s - the address
139
+ * @returns `true` when the address is within the byte bound
140
+ */
141
+ export declare const is_email_within_length_max: (s: string) => boolean;
99
142
  /**
100
143
  * Email validation. Every current consumer pairs it with `Username` (signup,
101
144
  * invites, audit log), so the two live together with the other Zod
@@ -113,6 +156,9 @@ export declare const EMAIL_LENGTH_MAX = 254;
113
156
  * transform: case is preserved and surrounding whitespace is rejected (not
114
157
  * trimmed), so storage is verbatim and the case-insensitive lookup rides the
115
158
  * DB-side `LOWER(email)`.
159
+ *
160
+ * The byte bound runs first and aborts, so an address past it gets the
161
+ * length issue alone and is never read by the regex.
116
162
  */
117
163
  export declare const Email: z.ZodString;
118
164
  export type Email = z.infer<typeof Email>;
@@ -1 +1 @@
1
- {"version":3,"file":"primitive_schemas.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/primitive_schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAIlF,gEAAgE;AACh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