@fuzdev/fuz_app 0.160.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 (59) hide show
  1. package/dist/auth/CLAUDE.md +16 -14
  2. package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
  3. package/dist/auth/actor_search_action_specs.d.ts +6 -6
  4. package/dist/auth/admin_action_specs.d.ts +1051 -321
  5. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  6. package/dist/auth/admin_action_specs.js +150 -166
  7. package/dist/auth/app_settings_schema.d.ts +46 -23
  8. package/dist/auth/app_settings_schema.d.ts.map +1 -1
  9. package/dist/auth/app_settings_schema.js +12 -15
  10. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  11. package/dist/auth/audit_log_schema.d.ts +14 -3
  12. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  13. package/dist/auth/audit_log_schema.js +20 -7
  14. package/dist/auth/audit_log_schema_fuz.d.ts +39 -0
  15. package/dist/auth/audit_log_schema_fuz.d.ts.map +1 -0
  16. package/dist/auth/audit_log_schema_fuz.js +37 -0
  17. package/dist/auth/credential_type_schema.d.ts +4 -7
  18. package/dist/auth/credential_type_schema.d.ts.map +1 -1
  19. package/dist/auth/credential_type_schema.js +6 -10
  20. package/dist/auth/grant_path_schema.d.ts +4 -7
  21. package/dist/auth/grant_path_schema.d.ts.map +1 -1
  22. package/dist/auth/grant_path_schema.js +6 -10
  23. package/dist/auth/name_schema.d.ts +63 -0
  24. package/dist/auth/name_schema.d.ts.map +1 -0
  25. package/dist/auth/name_schema.js +65 -0
  26. package/dist/auth/request_context.d.ts.map +1 -1
  27. package/dist/auth/request_context.js +2 -1
  28. package/dist/auth/role_grant_offer_action_specs.d.ts +120 -120
  29. package/dist/auth/role_grant_offer_action_specs.js +2 -2
  30. package/dist/auth/role_grant_offer_notifications.d.ts +66 -66
  31. package/dist/auth/role_grant_offer_schema.d.ts +6 -6
  32. package/dist/auth/role_schema.d.ts +14 -25
  33. package/dist/auth/role_schema.d.ts.map +1 -1
  34. package/dist/auth/role_schema.js +15 -29
  35. package/dist/auth/role_schema_fuz.d.ts +4 -3
  36. package/dist/auth/role_schema_fuz.d.ts.map +1 -1
  37. package/dist/auth/role_schema_fuz.js +7 -5
  38. package/dist/auth/scope_kind_schema.d.ts +13 -26
  39. package/dist/auth/scope_kind_schema.d.ts.map +1 -1
  40. package/dist/auth/scope_kind_schema.js +15 -31
  41. package/dist/auth/scope_kind_schema_fuz.d.ts +4 -3
  42. package/dist/auth/scope_kind_schema_fuz.d.ts.map +1 -1
  43. package/dist/auth/scope_kind_schema_fuz.js +7 -5
  44. package/dist/auth/self_service_role_action_specs.d.ts +2 -2
  45. package/dist/auth/token_scope.d.ts +7 -13
  46. package/dist/auth/token_scope.d.ts.map +1 -1
  47. package/dist/auth/token_scope.js +9 -14
  48. package/dist/primitive_schemas.d.ts +46 -0
  49. package/dist/primitive_schemas.d.ts.map +1 -1
  50. package/dist/primitive_schemas.js +39 -14
  51. package/dist/primitive_schemas_fuz.d.ts +35 -7
  52. package/dist/primitive_schemas_fuz.d.ts.map +1 -1
  53. package/dist/primitive_schemas_fuz.js +30 -6
  54. package/dist/testing/CLAUDE.md +4 -3
  55. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  56. package/dist/testing/cross_backend/identity_parity.js +20 -11
  57. package/dist/testing/cross_backend/role_grant_role_grammar.d.ts.map +1 -1
  58. package/dist/testing/cross_backend/role_grant_role_grammar.js +8 -15
  59. package/package.json +1 -1
@@ -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,C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M,KAAG,OACtB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;GAoBG;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;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;;;;;;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K,CAAC,OAAO,KAAK,CAAC,CAAC;AAE1C,wCAAwC;AACxC,eAAO,MAAM,WAAW,QAAO,IAAmC,CAAC;AAcnE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAEC,CAAC;AAC1E,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,qFAAqF;AACrF,eAAO,MAAM,eAAe,iIAA4B,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,yDAAqC,CAAC;AAC3D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,QAAO,QAAgD,CAAC;AAErF,sFAAsF;AACtF,eAAO,MAAM,WAAW,uEAAqC,CAAC;AAC9D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,uFAAuF;AACvF,eAAO,MAAM,UAAU,aAEuD,CAAC;AAC/E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAEA,CAAC"}
@@ -96,6 +96,12 @@ export const bounded_string = (options) => {
96
96
  export const USERNAME_LENGTH_MIN = 3;
97
97
  /** Maximum username length (matches GitHub's limit). The grammar is ASCII, so units and characters agree. */
98
98
  export const USERNAME_LENGTH_MAX = 39;
99
+ /**
100
+ * The creation username's grammar: a letter, then letters, digits, `_` or
101
+ * `-`, ending in a letter or digit. ASCII, so it needs at least two
102
+ * characters, and `Username` bounds the length beside it.
103
+ */
104
+ export const USERNAME_REGEX = /^[a-zA-Z][0-9a-zA-Z_-]*[0-9a-zA-Z]$/;
99
105
  /** 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. */
100
106
  export const USERNAME_PROVIDED_LENGTH_MAX = 255;
101
107
  /**
@@ -109,7 +115,7 @@ export const USERNAME_PROVIDED_LENGTH_MAX = 255;
109
115
  * `LOWER(username) = LOWER($1)` lookup contract simple.
110
116
  */
111
117
  export const Username = bounded_string({ min: USERNAME_LENGTH_MIN, max: USERNAME_LENGTH_MAX })
112
- .regex(/^[a-zA-Z][0-9a-zA-Z_-]*[0-9a-zA-Z]$/)
118
+ .regex(USERNAME_REGEX)
113
119
  .transform((s) => s.toLowerCase());
114
120
  /**
115
121
  * Username submitted for login or lookup — minimal validation for forward-compatibility if format rules change.
@@ -137,10 +143,11 @@ export const UsernameProvided = bounded_string({ min: 1, max: USERNAME_PROVIDED_
137
143
  export const EMAIL_LENGTH_MAX = 254;
138
144
  /**
139
145
  * Loose email shape `local@domain.tld`: a non-empty local part, exactly one
140
- * `@`, a domain with an interior dot (a non-empty label on each side), and
141
- * no whitespace. Accepts `a@b.c` (single-char TLDs are fine) and
142
- * `user+tag@a.co`; rejects `notanemail`, `@x.com`, `user@`, `user@host`, and
143
- * any whitespace.
146
+ * `@`, a domain that holds a `.` and neither starts nor ends with one, and
147
+ * no whitespace. Accepts `a@b.c` (single-char TLDs are fine), `a@b..c` and
148
+ * `user+tag@a.co`; rejects `notanemail`, `@x.com`, `user@`, `user@host`,
149
+ * `a@.b.c`, `a@b.c.`, and any whitespace. The Rust spine's `is_valid_email`
150
+ * is the same rule.
144
151
  *
145
152
  * The negated class excludes `\s` **plus** U+0085 (NEL): JS's `\s` omits
146
153
  * U+0085 but Unicode `White_Space` (Rust's `char::is_whitespace`) includes
@@ -148,10 +155,31 @@ export const EMAIL_LENGTH_MAX = 254;
148
155
  * (The Rust side correspondingly also rejects U+FEFF, which JS `\s` treats as
149
156
  * whitespace but Unicode `White_Space` does not — so both spines reject
150
157
  * exactly `White_Space ∪ {U+FEFF}`.)
158
+ *
159
+ * Linear in the input's length: the `@` can match only the first `@`, and the
160
+ * `\.` only the domain's first `.`, since the classes before each exclude it,
161
+ * so the tail after the `\.` is scanned once. The domain spelled
162
+ * `[^\s\u0085@.][^\s\u0085@]*\.[^\s\u0085@]*[^\s\u0085@.]`, the same
163
+ * language, is quadratic: it tries every `.` as the split.
151
164
  */
152
- const EMAIL_REGEX = /^[^\s\u0085@]+@[^\s\u0085@]+\.[^\s\u0085@]+$/;
165
+ export const EMAIL_REGEX = /^[^\s\u0085@]+@[^\s\u0085@.]+\.[^\s\u0085@]*[^\s\u0085@.]$/;
166
+ /** The message of an email over `EMAIL_LENGTH_MAX` bytes, on either schema library's `Email`. */
167
+ export const EMAIL_LENGTH_MESSAGE = `Email must be at most ${EMAIL_LENGTH_MAX} bytes`;
153
168
  /** UTF-8 encoder for the `EMAIL_LENGTH_MAX` byte (octet) bound. */
154
169
  const utf8_encoder = new TextEncoder();
170
+ /**
171
+ * Whether `s` is at most `EMAIL_LENGTH_MAX` bytes in UTF-8, the bound both
172
+ * `Email` schemas check.
173
+ *
174
+ * `s.length` (UTF-16 units) is a cheap upper bound that short-circuits the
175
+ * `encode` on absurd inputs: a valid (<= 254-byte) address is necessarily
176
+ * <= 254 code units, so it never refuses one — the byte count is the real
177
+ * RFC-5321 octet bound, matching the Rust spine's `s.len()`.
178
+ *
179
+ * @param s - the address
180
+ * @returns `true` when the address is within the byte bound
181
+ */
182
+ export const is_email_within_length_max = (s) => s.length <= EMAIL_LENGTH_MAX && utf8_encoder.encode(s).length <= EMAIL_LENGTH_MAX;
155
183
  /**
156
184
  * Email validation. Every current consumer pairs it with `Username` (signup,
157
185
  * invites, audit log), so the two live together with the other Zod
@@ -169,17 +197,14 @@ const utf8_encoder = new TextEncoder();
169
197
  * transform: case is preserved and surrounding whitespace is rejected (not
170
198
  * trimmed), so storage is verbatim and the case-insensitive lookup rides the
171
199
  * DB-side `LOWER(email)`.
200
+ *
201
+ * The byte bound runs first and aborts, so an address past it gets the
202
+ * length issue alone and is never read by the regex.
172
203
  */
173
204
  export const Email = z
174
205
  .string()
175
- .regex(EMAIL_REGEX)
176
- // `s.length` (UTF-16 units) is a cheap upper bound that short-circuits the
177
- // `encode` on absurd inputs: a valid (<= 254-byte) address is necessarily
178
- // <= 254 code units, so this never rejects one — the byte count is the real
179
- // RFC-5321 octet bound, matching the Rust spine's `s.len()`.
180
- .refine((s) => s.length <= EMAIL_LENGTH_MAX && utf8_encoder.encode(s).length <= EMAIL_LENGTH_MAX, {
181
- message: `Email must be at most ${EMAIL_LENGTH_MAX} bytes`
182
- });
206
+ .refine(is_email_within_length_max, { message: EMAIL_LENGTH_MESSAGE, abort: true })
207
+ .regex(EMAIL_REGEX);
183
208
  /** Returns a new random (v4) `Uuid`. */
184
209
  export const create_uuid = () => crypto.randomUUID();
185
210
  /**
@@ -1,8 +1,8 @@
1
1
  /**
2
- * `@fuzdev/fuz_schema` twins of the Zod `bounded_string`, `Uuid`,
3
- * `UuidWithDefault` (`primitive_schemas.ts`), and `ActingActor`
4
- * (`http/auth_shape.ts`), under the same names, for schemas written in
5
- * fuz_schema.
2
+ * `@fuzdev/fuz_schema` twins of the Zod `bounded_string`, `Username`,
3
+ * `Email`, `Uuid`, `UuidWithDefault` (`primitive_schemas.ts`), and
4
+ * `ActingActor` (`http/auth_shape.ts`), under the same names, for schemas
5
+ * written in fuz_schema.
6
6
  *
7
7
  * The output type is shared: the Zod `Uuid` outputs fuz_schema's
8
8
  * `Branded<string, 'Uuid'>` too, so a value parsed by either twin goes where
@@ -32,6 +32,34 @@ import { type BoundedStringOptions } from './primitive_schemas.js';
32
32
  * @nodocs
33
33
  */
34
34
  export declare const bounded_string: (options: BoundedStringOptions) => PipeSchema<string, typeof string>;
35
+ /**
36
+ * Username for account creation, the twin of the Zod `Username`: the same
37
+ * bounds and grammar, output in lowercase. Every input gets the same verdict
38
+ * and output from both; a string outside the bounds and off the grammar gets
39
+ * the length issue alone, where Zod adds the grammar issue after it.
40
+ *
41
+ * @nodocs
42
+ */
43
+ export declare const Username: PipeSchema<string, PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
44
+ /** @nodocs */
45
+ export type Username = Infer<typeof Username>;
46
+ /**
47
+ * Email validation, the twin of the Zod `Email`: `EMAIL_REGEX` and at most
48
+ * `EMAIL_LENGTH_MAX` UTF-8 bytes, no transform. The `max_length` ahead of the
49
+ * grammar refuses a string past the bound in UTF-16 code units, which is past
50
+ * it in bytes too, before the regex reads it, and the `check` after it the
51
+ * multibyte address within the units but past the bytes, both with
52
+ * `EMAIL_LENGTH_MESSAGE`. Every input gets the same verdict and output from
53
+ * both; a string past the bound in code units gets the length issue as a
54
+ * `max_length`, where Zod gives a `check`, and one within the bound in code
55
+ * units but past it in bytes and off the grammar gets the grammar issue, where
56
+ * Zod gives the length one.
57
+ *
58
+ * @nodocs
59
+ */
60
+ export declare const Email: PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
61
+ /** @nodocs */
62
+ export type Email = Infer<typeof Email>;
35
63
  /**
36
64
  * Branded UUID schema: a UUID of RFC 9562 in either case, output in
37
65
  * lowercase, the form Postgres renders a `uuid` in and every id the server
@@ -40,7 +68,7 @@ export declare const bounded_string: (options: BoundedStringOptions) => PipeSche
40
68
  *
41
69
  * @nodocs
42
70
  */
43
- export declare const Uuid: 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">)[]> & {
71
+ export declare const Uuid: 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">)[]> & {
44
72
  readonly '~types'?: {
45
73
  readonly input: string;
46
74
  readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
@@ -53,7 +81,7 @@ export type Uuid = Infer<typeof Uuid>;
53
81
  *
54
82
  * @nodocs
55
83
  */
56
- export declare const UuidWithDefault: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string | undefined, "with_default_fn", import("@fuzdev/fuz_schema/schema.ts").SchemaDefaultFnDef<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">)[]> & {
84
+ export declare const UuidWithDefault: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string | undefined, "with_default_fn", import("@fuzdev/fuz_schema/schema.ts").SchemaDefaultFnDef<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">)[]> & {
57
85
  readonly '~types'?: {
58
86
  readonly input: string;
59
87
  readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
@@ -71,7 +99,7 @@ export declare const ACTING_ACTOR_DESCRIPTION = "Actor on the authenticated acco
71
99
  *
72
100
  * @nodocs
73
101
  */
74
- export declare const ActingActor: 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">)[]> & {
102
+ export declare const ActingActor: 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">)[]> & {
75
103
  readonly '~types'?: {
76
104
  readonly input: string;
77
105
  readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"primitive_schemas_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/primitive_schemas_fuz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAON,MAAM,EAIN,KAAK,KAAK,EACV,KAAK,UAAU,EACf,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAe,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEhF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAC1B,SAAS,oBAAoB,KAC3B,UAAU,CAAC,MAAM,EAAE,OAAO,MAAM,CAKlC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI;;;;;CAAmD,CAAC;AACrE,cAAc;AACd,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,eAAe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CAAC,CAAC;AAE5D,wDAAwD;AACxD,eAAO,MAAM,wBAAwB,0HACmF,CAAC;AAEzH;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW;;;;;GAAkE,CAAC;AAC3F,cAAc;AACd,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * `@fuzdev/fuz_schema` twins of the Zod `bounded_string`, `Uuid`,
3
- * `UuidWithDefault` (`primitive_schemas.ts`), and `ActingActor`
4
- * (`http/auth_shape.ts`), under the same names, for schemas written in
5
- * fuz_schema.
2
+ * `@fuzdev/fuz_schema` twins of the Zod `bounded_string`, `Username`,
3
+ * `Email`, `Uuid`, `UuidWithDefault` (`primitive_schemas.ts`), and
4
+ * `ActingActor` (`http/auth_shape.ts`), under the same names, for schemas
5
+ * written in fuz_schema.
6
6
  *
7
7
  * The output type is shared: the Zod `Uuid` outputs fuz_schema's
8
8
  * `Branded<string, 'Uuid'>` too, so a value parsed by either twin goes where
@@ -18,8 +18,8 @@
18
18
  * @module
19
19
  */
20
20
  import { meta } from '@fuzdev/fuz_schema/meta.ts';
21
- import { brand, max_length, message, min_length, optional, pipe, string, to_lower_case, uuid, with_default_fn } from '@fuzdev/fuz_schema/schema.ts';
22
- import { create_uuid } from './primitive_schemas.js';
21
+ import { brand, check, max_length, message, min_length, optional, pipe, regex, string, to_lower_case, uuid, with_default_fn } from '@fuzdev/fuz_schema/schema.ts';
22
+ import { create_uuid, EMAIL_LENGTH_MAX, EMAIL_LENGTH_MESSAGE, EMAIL_REGEX, is_email_within_length_max, USERNAME_LENGTH_MAX, USERNAME_LENGTH_MIN, USERNAME_REGEX } from './primitive_schemas.js';
23
23
  /**
24
24
  * A string schema whose length is bounded in UTF-16 code units, the twin of
25
25
  * the Zod `bounded_string`: fuz_schema's `min_length` / `max_length` read
@@ -37,6 +37,30 @@ export const bounded_string = (options) => {
37
37
  const max_step = max_message === undefined ? max_length(max) : message(max_length(max), max_message);
38
38
  return min === undefined ? pipe(string, max_step) : pipe(string, min_length(min), max_step);
39
39
  };
40
+ /**
41
+ * Username for account creation, the twin of the Zod `Username`: the same
42
+ * bounds and grammar, output in lowercase. Every input gets the same verdict
43
+ * and output from both; a string outside the bounds and off the grammar gets
44
+ * the length issue alone, where Zod adds the grammar issue after it.
45
+ *
46
+ * @nodocs
47
+ */
48
+ export const Username = pipe(bounded_string({ min: USERNAME_LENGTH_MIN, max: USERNAME_LENGTH_MAX }), regex(USERNAME_REGEX), to_lower_case);
49
+ /**
50
+ * Email validation, the twin of the Zod `Email`: `EMAIL_REGEX` and at most
51
+ * `EMAIL_LENGTH_MAX` UTF-8 bytes, no transform. The `max_length` ahead of the
52
+ * grammar refuses a string past the bound in UTF-16 code units, which is past
53
+ * it in bytes too, before the regex reads it, and the `check` after it the
54
+ * multibyte address within the units but past the bytes, both with
55
+ * `EMAIL_LENGTH_MESSAGE`. Every input gets the same verdict and output from
56
+ * both; a string past the bound in code units gets the length issue as a
57
+ * `max_length`, where Zod gives a `check`, and one within the bound in code
58
+ * units but past it in bytes and off the grammar gets the grammar issue, where
59
+ * Zod gives the length one.
60
+ *
61
+ * @nodocs
62
+ */
63
+ export const Email = pipe(string, message(max_length(EMAIL_LENGTH_MAX), EMAIL_LENGTH_MESSAGE), regex(EMAIL_REGEX), message(check(is_email_within_length_max), EMAIL_LENGTH_MESSAGE));
40
64
  /**
41
65
  * Branded UUID schema: a UUID of RFC 9562 in either case, output in
42
66
  * lowercase, the form Postgres renders a `uuid` in and every id the server
@@ -2711,10 +2711,11 @@ USERNAME_LENGTH_MAX]` = `[3, 39]` boundary edges (just-outside → 400,
2711
2711
  `_`/`-` accepted), catching an off-by-one or position bug in the TS Zod
2712
2712
  `.min/.max/.regex` vs the Rust byte-scan `is_valid_username_for_creation`.
2713
2713
  - **Email format (creation)** — the optional signup `email` validated to the
2714
- loose `local@domain.tld` shape (TS `Email` `^[^\s\u0085@]+@[^\s\u0085@]+\.[^\s\u0085@]+$` + 254-byte
2714
+ loose `local@domain.tld` shape (TS `Email`, `EMAIL_REGEX` + 254-byte
2715
2715
  bound, Rust `is_valid_email`): malformed (no `@` / no domain dot / empty
2716
- side / dot at a domain edge / whitespace / over-length) → 400, well-formed →
2717
- 403 no-invite. Accepted siblings include the single-char-TLD `a@b.c` that
2716
+ side / dot at a domain edge, beside another dot inside it too / whitespace /
2717
+ over-length) → 400, well-formed → 403 no-invite. Accepted siblings include
2718
+ the single-char-TLD `a@b.c` and the consecutive dots inside a domain that
2718
2719
  Zod's `z.email()` rejects — the deliberately-looser shared rule. **Closed a
2719
2720
  real divergence**: the Rust spine previously length-checked the email only,
2720
2721
  accepting any non-empty string TS rejected.
@@ -1 +1 @@
1
- {"version":3,"file":"identity_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/identity_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAoH9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAyB5C,uDAAuD;AACvD,MAAM,WAAW,8BAA8B;IAC9C,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AA8JD,eAAO,MAAM,oCAAoC,GAChD,SAAS,8BAA8B,KACrC,IAieF,CAAC"}
1
+ {"version":3,"file":"identity_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/identity_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqH9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAyB5C,uDAAuD;AACvD,MAAM,WAAW,8BAA8B;IAC9C,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAsKD,eAAO,MAAM,oCAAoC,GAChD,SAAS,8BAA8B,KACrC,IAieF,CAAC"}
@@ -75,9 +75,10 @@ import '../assert_dev_env.js';
75
75
  * bootstrap completed.
76
76
  *
77
77
  * **Email format (creation):** the optional signup `email` is validated to a
78
- * loose `local@domain.tld` shape on both spines — TS `Email`
79
- * (`^[^\s\u0085@]+@[^\s\u0085@]+\.[^\s\u0085@]+$` plus a 254-byte (RFC 5321 octet) length bound; whitespace `White_Space ∪ {U+FEFF}`), Rust the
80
- * hand-rolled `is_valid_email`. A malformed email → 400, a well-formed one →
78
+ * loose `local@domain.tld` shape on both spines — TS `Email` (`EMAIL_REGEX`:
79
+ * a non-empty local part, one `@`, a domain holding a `.` at neither of its
80
+ * edges, no whitespace — `White_Space ∪ {U+FEFF}` — plus a 254-byte (RFC 5321
81
+ * octet) length bound), Rust the hand-rolled `is_valid_email`. A malformed email → 400, a well-formed one →
81
82
  * 403 no-matching-invite (the same accept/reject settle the username tables
82
83
  * use). The accepted siblings include the single-char-TLD `a@b.c` that Zod's
83
84
  * `z.email()` would reject — the deliberately-looser rule both spines now
@@ -195,14 +196,15 @@ const USERNAME_FORMAT_CASES = [
195
196
  ];
196
197
  /**
197
198
  * Signup email-format cases for the loose `Email` shape `local@domain.tld`
198
- * (TS `^[^\s\u0085@]+@[^\s\u0085@]+\.[^\s\u0085@]+$` plus the 254 length bound; Rust the
199
- * hand-rolled `is_valid_email`). The rejected cases each violate the shape at
200
- * a different point — no `@`, no dot in the domain, empty local/domain, a dot
201
- * at a domain edge, surrounding whitespace, over the length bound — so a
202
- * backend policing only one of them is caught. The accepted siblings are the
203
- * don't-over-reject control and include the shapes Zod's `z.email()` rejects
204
- * but our looser rule accepts — single-char TLD `a@b.c` and consecutive dots
205
- * `a..b@c.d` — pinning the deliberately-looser shared rule in both directions.
199
+ * (TS `EMAIL_REGEX` plus the 254 length bound; Rust the hand-rolled
200
+ * `is_valid_email`). The rejected cases each violate the shape at a different
201
+ * point — no `@`, no dot in the domain, empty local/domain, a dot at a domain
202
+ * edge (beside another dot inside the domain too), surrounding whitespace,
203
+ * over the length bound — so a backend policing only one of them is caught.
204
+ * The accepted siblings are the don't-over-reject control and include the
205
+ * shapes Zod's `z.email()` rejects but our looser rule accepts — single-char
206
+ * TLD `a@b.c` and consecutive dots `a..b@c.d` and `a@b..c` — pinning the
207
+ * deliberately-looser shared rule in both directions.
206
208
  * Every case rides a valid username so the rejection (or the 403 no-invite
207
209
  * settle) isolates the email.
208
210
  */
@@ -213,6 +215,8 @@ const SIGNUP_EMAIL_CASES = [
213
215
  { email: 'user@', label: 'empty domain', status: 400 },
214
216
  { email: 'user@.com', label: 'domain starts with a dot', status: 400 },
215
217
  { email: 'user@com.', label: 'domain ends with a dot', status: 400 },
218
+ { email: 'user@.example.com', label: 'multi-label domain starts with a dot', status: 400 },
219
+ { email: 'user@example.com.', label: 'multi-label domain ends with a dot', status: 400 },
216
220
  { email: 'a@@b.c', label: 'two @', status: 400 },
217
221
  { email: ' user@example.com', label: 'leading whitespace', status: 400 },
218
222
  { email: 'user@example.com ', label: 'trailing whitespace', status: 400 },
@@ -251,6 +255,11 @@ const SIGNUP_EMAIL_CASES = [
251
255
  label: 'consecutive dots (looser than z.email)',
252
256
  status: VALID_USERNAME_NO_INVITE_STATUS
253
257
  },
258
+ {
259
+ email: 'user@example..com',
260
+ label: 'consecutive dots inside the domain (looser than z.email)',
261
+ status: VALID_USERNAME_NO_INVITE_STATUS
262
+ },
254
263
  {
255
264
  email: 'user+tag@example.co.uk',
256
265
  label: 'plus-tag + multi-label',
@@ -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;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
+ {"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;AA4D5E,eAAO,MAAM,4CAA4C,GACxD,SAAS,oCAAoC,KAC3C,IAqKF,CAAC"}
@@ -47,14 +47,15 @@ import { cross_rpc_call, error_reason } from './cross_rpc.js';
47
47
  import { SPINE_RPC_PATH } from './spine_surface_constants.js';
48
48
  const NIL_UUID = '00000000-0000-0000-0000-000000000000';
49
49
  /**
50
- * The longest role name the grammar admits — an independent copy of the
51
- * producers' `ROLE_NAME_LENGTH_MAX`, so a cap moved on one spine fails here.
50
+ * The longest role name or scope kind the grammar admits — an independent
51
+ * copy of the producers' `NAME_LENGTH_MAX`, so a cap moved on one spine fails
52
+ * here.
52
53
  */
53
- const ROLE_NAME_LENGTH_MAX = 64;
54
+ const NAME_LENGTH_MAX = 64;
54
55
  /** All lowercase letters, so only its length is off the grammar. */
55
- const OVER_LENGTH_ROLE = 'a'.repeat(ROLE_NAME_LENGTH_MAX + 1);
56
+ const OVER_LENGTH_ROLE = 'a'.repeat(NAME_LENGTH_MAX + 1);
56
57
  /** On the grammar at exactly the length cap, held by no registry. */
57
- const AT_LENGTH_ROLE = 'a'.repeat(ROLE_NAME_LENGTH_MAX);
58
+ const AT_LENGTH_ROLE = 'a'.repeat(NAME_LENGTH_MAX);
58
59
  /** Each breaks one rule of the `RoleName` grammar. */
59
60
  const OFF_GRAMMAR_ROLES = [
60
61
  'Admin', // uppercase
@@ -70,11 +71,6 @@ const OFF_GRAMMAR_ROLES = [
70
71
  ];
71
72
  /** On the grammar, held by no registry. */
72
73
  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
74
  /** Each breaks one rule of the `ScopeKindName` grammar. */
79
75
  const OFF_GRAMMAR_SCOPE_KINDS = [
80
76
  'GLOBAL', // the partial unique indexes' token for a global grant
@@ -84,13 +80,10 @@ const OFF_GRAMMAR_SCOPE_KINDS = [
84
80
  'a_', // trailing underscore
85
81
  'a1', // digit
86
82
  '', // empty
87
- 'a'.repeat(SCOPE_KIND_LENGTH_MAX + 1) // on the alphabet, one past the length cap
83
+ 'a'.repeat(NAME_LENGTH_MAX + 1) // on the alphabet, one past the length cap
88
84
  ];
89
85
  /** 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
- ];
86
+ const ON_GRAMMAR_SCOPE_KINDS = ['classroom', 'a'.repeat(NAME_LENGTH_MAX)];
94
87
  const GRANT_METHODS = ['role_grant_assign', 'role_grant_offer_create'];
95
88
  /** What each grant verb refuses an unregistered role with, past validation. */
96
89
  const NOT_GRANTABLE_REASONS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_app",
3
- "version": "0.160.0",
3
+ "version": "0.161.0",
4
4
  "description": "fullstack app library",
5
5
  "glyph": "🗝",
6
6
  "logo": "logo.svg",