@oxyhq/core 21.2.0 → 22.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -123,7 +123,7 @@ export { retryAsync } from './utils/asyncUtils.js';
123
123
  // ---------------------------------------------------------------------------
124
124
  // Validation
125
125
  // ---------------------------------------------------------------------------
126
- export { EMAIL_REGEX, USERNAME_REGEX, PASSWORD_REGEX, MAX_DISPLAY_NAME_LENGTH, DISPLAY_NAME_INVALID_MESSAGE, isValidEmail, isValidUsername, isValidPassword, isValidDisplayName, DISPLAY_NAME_ALLOWED_SCRIPTS, DISPLAY_NAME_DISALLOWED_SOURCE, DISPLAY_NAME_ORPHANED_MARK_SOURCE, DISPLAY_NAME_UNFLANKED_SEPARATOR_SOURCE, isRequiredString, isRequiredNumber, isRequiredBoolean, isValidArray, isValidObject, isValidUUID, isValidURL, isValidDate, isValidFileSize, isValidFileType, sanitizeString, sanitizeHTML, isValidObjectId, validateAndSanitizeUserInput, } from './utils/validationUtils.js';
126
+ export { EMAIL_REGEX, PASSWORD_REGEX, MAX_DISPLAY_NAME_LENGTH, DISPLAY_NAME_INVALID_MESSAGE, isValidEmail, isValidPassword, isValidDisplayName, DISPLAY_NAME_ALLOWED_SCRIPTS, DISPLAY_NAME_DISALLOWED_SOURCE, DISPLAY_NAME_ORPHANED_MARK_SOURCE, DISPLAY_NAME_UNFLANKED_SEPARATOR_SOURCE, isRequiredString, isRequiredNumber, isRequiredBoolean, isValidArray, isValidObject, isValidUUID, isValidURL, isValidDate, isValidFileSize, isValidFileType, sanitizeString, sanitizeHTML, isValidObjectId, validateAndSanitizeUserInput, } from './utils/validationUtils.js';
127
127
  // ---------------------------------------------------------------------------
128
128
  // Text normalization
129
129
  // ---------------------------------------------------------------------------
@@ -2,6 +2,7 @@
2
2
  * Validation utilities for common data validation patterns
3
3
  */
4
4
  import { DISPLAY_NAME_ALLOWED_SCRIPTS_RANGES, DISPLAY_NAME_COMBINING_MARKS_RANGES, DISPLAY_NAME_SPACE_SEPARATORS_RANGES, DISPLAY_NAME_LETTERS_RANGES, DISPLAY_NAME_NAME_SEPARATORS_RANGES, } from './displayNamePolicyRanges.generated.js';
5
+ import { usernameSchema } from '@oxyhq/contracts';
5
6
  /**
6
7
  * Maximum stored length of a display name, in code units after cleaning.
7
8
  * Shared by the API write path and client input surfaces.
@@ -13,10 +14,6 @@ export const DISPLAY_NAME_INVALID_MESSAGE = 'Name may only contain letters, spac
13
14
  * Email validation regex
14
15
  */
15
16
  export const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
16
- /**
17
- * Username validation regex (alphanumeric, underscores, and hyphens, 3-30 chars)
18
- */
19
- export const USERNAME_REGEX = /^[a-zA-Z0-9_-]{3,30}$/;
20
17
  /**
21
18
  * Password validation regex (at least 8 chars, 1 uppercase, 1 lowercase, 1 number)
22
19
  */
@@ -28,12 +25,6 @@ export const PASSWORD_REGEX = /^.{8,}$/;
28
25
  export function isValidEmail(email) {
29
26
  return EMAIL_REGEX.test(email);
30
27
  }
31
- /**
32
- * Validate username format
33
- */
34
- export function isValidUsername(username) {
35
- return USERNAME_REGEX.test(username);
36
- }
37
28
  /**
38
29
  * Validate password strength
39
30
  */
@@ -336,7 +327,10 @@ export function validateAndSanitizeUserInput(input, type) {
336
327
  case 'email':
337
328
  return isValidEmail(sanitized) ? sanitized : null;
338
329
  case 'username':
339
- return isValidUsername(sanitized) ? sanitized : null;
330
+ // The ONE policy, from `@oxyhq/contracts`. This module used to declare a
331
+ // second one (`^[a-zA-Z0-9_-]{3,30}$`) that the server did not enforce, so
332
+ // the SDK could call a name valid and the API 400 it.
333
+ return usernameSchema.safeParse(sanitized).success ? sanitized : null;
340
334
  case 'string':
341
335
  return isRequiredString(sanitized) ? sanitized : null;
342
336
  default: