@schemavaults/auth-common 0.24.0 → 0.25.1

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 (69) hide show
  1. package/dist/audience-schema.d.ts +2 -2
  2. package/dist/audience-schema.js +0 -1
  3. package/dist/audience-schema.js.map +1 -1
  4. package/dist/auth_acquire_tokens_grant_types.d.ts +12 -42
  5. package/dist/auth_acquire_tokens_grant_types.js +1 -1
  6. package/dist/auth_acquire_tokens_grant_types.js.map +1 -1
  7. package/dist/authenticate_result.d.ts +29 -144
  8. package/dist/authenticate_result.js +2 -2
  9. package/dist/authenticate_result.js.map +1 -1
  10. package/dist/authorize-client-application-form-type.d.ts +2 -6
  11. package/dist/credentials/email_credentials.d.ts +3 -9
  12. package/dist/credentials/normalize-email.d.ts +1 -1
  13. package/dist/credentials/normalize-email.js +5 -1
  14. package/dist/credentials/normalize-email.js.map +1 -1
  15. package/dist/credentials/password_requirements.d.ts +1 -1
  16. package/dist/credentials/register_credentials.d.ts +6 -26
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/invite-code/invite-code-definition.d.ts +5 -17
  21. package/dist/invite-code/invite-code-definition.js +1 -1
  22. package/dist/invite-code/invite-code-definition.js.map +1 -1
  23. package/dist/mfa/mfa-challenge.d.ts +2 -8
  24. package/dist/mfa/mfa-challenge.js +1 -1
  25. package/dist/mfa/mfa-challenge.js.map +1 -1
  26. package/dist/mfa/mfa-factor-type.d.ts +4 -1
  27. package/dist/mfa/mfa-verify-body.d.ts +57 -315
  28. package/dist/mfa/mfa-verify-body.js +9 -9
  29. package/dist/mfa/mfa-verify-body.js.map +1 -1
  30. package/dist/mfa/webauthn.d.ts +21 -145
  31. package/dist/mfa/webauthn.js +3 -3
  32. package/dist/mfa/webauthn.js.map +1 -1
  33. package/dist/middleware/auth-middleware-error.d.ts +1 -1
  34. package/dist/middleware/middleware-rules.d.ts +11 -15
  35. package/dist/oidc/index.d.ts +2 -0
  36. package/dist/oidc/index.js +1 -0
  37. package/dist/oidc/index.js.map +1 -1
  38. package/dist/oidc/profile-claims.d.ts +34 -0
  39. package/dist/oidc/profile-claims.js +45 -0
  40. package/dist/oidc/profile-claims.js.map +1 -0
  41. package/dist/organizations/invite_member_form.d.ts +8 -21
  42. package/dist/organizations/invite_member_form.js +5 -5
  43. package/dist/organizations/invite_member_form.js.map +1 -1
  44. package/dist/organizations/organization-membership-role-type.d.ts +1 -1
  45. package/dist/organizations/organization_definition.d.ts +5 -15
  46. package/dist/organizations/organization_definition.js +1 -1
  47. package/dist/organizations/organization_definition.js.map +1 -1
  48. package/dist/organizations/organization_invitation.d.ts +21 -33
  49. package/dist/organizations/organization_invitation.js +5 -5
  50. package/dist/organizations/organization_invitation.js.map +1 -1
  51. package/dist/organizations/organization_membership_role_details.d.ts +6 -18
  52. package/dist/pagination.d.ts +1 -7
  53. package/dist/pkce/code_challenge.d.ts +5 -13
  54. package/dist/pkce/code_verifier.d.ts +6 -16
  55. package/dist/pkce/pkce.d.ts +11 -29
  56. package/dist/request_tokens_result.d.ts +58 -493
  57. package/dist/token-data/token-data.d.ts +23 -73
  58. package/dist/token-data/token-data.js +1 -1
  59. package/dist/token-data/token-data.js.map +1 -1
  60. package/dist/user_data/index.d.ts +1 -0
  61. package/dist/user_data/index.js +1 -0
  62. package/dist/user_data/index.js.map +1 -1
  63. package/dist/user_data/user_data.d.ts +11 -50
  64. package/dist/user_data/user_data.js +13 -3
  65. package/dist/user_data/user_data.js.map +1 -1
  66. package/dist/user_data/user_profile.d.ts +65 -0
  67. package/dist/user_data/user_profile.js +79 -0
  68. package/dist/user_data/user_profile.js.map +1 -0
  69. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"token-data.js","sourceRoot":"","sources":["../../src/token-data/token-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,eAAe,GA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AC,CAAC,CAAC,CAAC;AAG7E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;KAC7B,MAAM,CAAC;IACN,IAAI,EAAE,eAAe;IACrB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CACzB,CAAC;KACD,QAAQ,CAAC;IACR,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,IAAI;CACV,CAAC;KACD,MAAM,EAAE,CAAC;AAUZ,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC,MAAM,CAAC;IAC3D,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC,MAAM,CAAC;IAC1D,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;CAC1B,CAAC,CAAC"}
@@ -1 +1,2 @@
1
1
  export { userDataSchema, type UserData } from './user_data';
2
+ export { USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH, MAX_USER_NAME_PART_LENGTH, USERNAME_REGEX, usernameFormatSchema, userNamePartSchema, userDisplayNameSchema, userProfileNamesSchema, updateUserProfileRequestSchema, userProfileResponseSchema, type Username, type UserProfileNames, type UpdateUserProfileRequest, type UserProfileResponse, } from './user_profile';
@@ -1,2 +1,3 @@
1
1
  export { userDataSchema } from './user_data';
2
+ export { USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH, MAX_USER_NAME_PART_LENGTH, USERNAME_REGEX, usernameFormatSchema, userNamePartSchema, userDisplayNameSchema, userProfileNamesSchema, updateUserProfileRequestSchema, userProfileResponseSchema, } from './user_profile';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user_data/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EAEf,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user_data/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EAEf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,GAK1B,MAAM,gBAAgB,CAAC"}
@@ -1,58 +1,19 @@
1
1
  import { z } from "zod";
2
- export declare const userDataSchema: z.ZodEffects<z.ZodObject<{
3
- uid: z.ZodString;
4
- sub: z.ZodString;
5
- email: z.ZodString;
2
+ export declare const userDataSchema: z.ZodObject<{
3
+ uid: z.ZodNonOptional<z.ZodGUID>;
4
+ sub: z.ZodNonOptional<z.ZodGUID>;
5
+ email: z.ZodNonOptional<z.ZodEmail>;
6
6
  email_verified: z.ZodOptional<z.ZodBoolean>;
7
+ username: z.ZodOptional<z.ZodString>;
8
+ first_name: z.ZodOptional<z.ZodString>;
9
+ middle_name: z.ZodOptional<z.ZodString>;
10
+ last_name: z.ZodOptional<z.ZodString>;
11
+ display_name: z.ZodOptional<z.ZodString>;
7
12
  admin: z.ZodOptional<z.ZodBoolean>;
8
13
  phone_number: z.ZodOptional<z.ZodString>;
9
14
  phone_verified: z.ZodOptional<z.ZodBoolean>;
10
15
  disabled: z.ZodOptional<z.ZodBoolean>;
11
- created_at: z.ZodNumber;
16
+ created_at: z.ZodNonOptional<z.ZodNumber>;
12
17
  invite_code: z.ZodOptional<z.ZodString>;
13
- }, "strict", z.ZodTypeAny, {
14
- uid: string;
15
- sub: string;
16
- email: string;
17
- created_at: number;
18
- email_verified?: boolean | undefined;
19
- admin?: boolean | undefined;
20
- phone_number?: string | undefined;
21
- phone_verified?: boolean | undefined;
22
- disabled?: boolean | undefined;
23
- invite_code?: string | undefined;
24
- }, {
25
- uid: string;
26
- sub: string;
27
- email: string;
28
- created_at: number;
29
- email_verified?: boolean | undefined;
30
- admin?: boolean | undefined;
31
- phone_number?: string | undefined;
32
- phone_verified?: boolean | undefined;
33
- disabled?: boolean | undefined;
34
- invite_code?: string | undefined;
35
- }>, {
36
- uid: string;
37
- sub: string;
38
- email: string;
39
- created_at: number;
40
- email_verified?: boolean | undefined;
41
- admin?: boolean | undefined;
42
- phone_number?: string | undefined;
43
- phone_verified?: boolean | undefined;
44
- disabled?: boolean | undefined;
45
- invite_code?: string | undefined;
46
- }, {
47
- uid: string;
48
- sub: string;
49
- email: string;
50
- created_at: number;
51
- email_verified?: boolean | undefined;
52
- admin?: boolean | undefined;
53
- phone_number?: string | undefined;
54
- phone_verified?: boolean | undefined;
55
- disabled?: boolean | undefined;
56
- invite_code?: string | undefined;
57
- }>;
18
+ }, z.core.$strict>;
58
19
  export type UserData = z.infer<typeof userDataSchema>;
@@ -1,13 +1,23 @@
1
1
  import { inviteCodeFormatSchema } from "../invite-code/invite-code-format";
2
+ import { usernameFormatSchema, userNamePartSchema, userDisplayNameSchema, } from "../user_data/user_profile";
2
3
  import { z } from "zod";
3
4
  const _baseUserDataSchema = z
4
5
  .object({
5
6
  // User ID
6
- uid: z.string().uuid(),
7
- sub: z.string().uuid(), // duplicate of uid
7
+ uid: z.guid(),
8
+ sub: z.guid(), // duplicate of uid
8
9
  // Email
9
- email: z.string().email(),
10
+ email: z.email(),
10
11
  email_verified: z.boolean().optional(),
12
+ // Profile names (user-editable; absent for accounts that never set
13
+ // them). Only present when the UserData was built from the database
14
+ // row (loadUserData) — UserData derived from a decoded token payload
15
+ // does not carry them.
16
+ username: usernameFormatSchema.optional(),
17
+ first_name: userNamePartSchema.optional(),
18
+ middle_name: userNamePartSchema.optional(),
19
+ last_name: userNamePartSchema.optional(),
20
+ display_name: userDisplayNameSchema.optional(),
11
21
  // Admin
12
22
  admin: z.boolean().optional(),
13
23
  // Phone
@@ -1 +1 @@
1
- {"version":3,"file":"user_data.js","sourceRoot":"","sources":["../../src/user_data/user_data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,mBAAmB,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,UAAU;IACV,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACtB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,mBAAmB;IAE3C,QAAQ;IACR,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;IACzB,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAEtC,QAAQ;IACR,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAE7B,QAAQ;IACR,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACnD,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAEtC,4BAA4B;IAC5B,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAEhC,qBAAqB;IACrB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAEvC,cAAc;IACd,WAAW,EAAE,sBAAsB,CAAC,QAAQ,EAAE;CAC/C,CAAC;KACD,QAAQ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IACR,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACnD,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAEtC,4BAA4B;IAC5B,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAEhC,qBAAqB;IACrB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAEvC,cAAc;IACd,WAAW,EAAE,sBAAsB,CAAC,QAAQ,EAAE;CAC/C,CAAC;KACD,QAAQ,CAAC;IACR,GAAG,EAAE,IAAI;IACT,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,IAAI;IACT,UAAU,EAAE,IAAI;CACjB,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IAChE,OAAO,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC;AAC/B,CAAC,EAAE,6BAA6B,CAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { z } from "zod";
2
+ export declare const USERNAME_MIN_LENGTH: number;
3
+ export declare const USERNAME_MAX_LENGTH: number;
4
+ /**
5
+ * Maximum length for each individual person-name part (first / middle /
6
+ * last) and for the public display name.
7
+ */
8
+ export declare const MAX_USER_NAME_PART_LENGTH: number;
9
+ /**
10
+ * Usernames are unique per deployment (case-insensitively — the database
11
+ * enforces uniqueness on LOWER(username), while the stored casing is
12
+ * preserved for display). Format: alphanumeric start and end with `.`,
13
+ * `_`, and `-` permitted in between. `@` is deliberately excluded so a
14
+ * username can never be confused with an email address, and `|` can
15
+ * never appear (the OIDC sub-claim delimiter).
16
+ */
17
+ export declare const USERNAME_REGEX: RegExp;
18
+ export declare const usernameFormatSchema: z.ZodString;
19
+ export type Username = z.infer<typeof usernameFormatSchema>;
20
+ /** A single part of a user's personal name (first / middle / last). */
21
+ export declare const userNamePartSchema: z.ZodString;
22
+ /**
23
+ * The user's public display name. Shown to other users and exposed to
24
+ * OIDC relying parties as the `name` claim when the `profile` scope is
25
+ * granted.
26
+ */
27
+ export declare const userDisplayNameSchema: z.ZodString;
28
+ /**
29
+ * The user-editable profile name fields stored on the USERS row. All
30
+ * fields are optional — accounts predating this feature (and accounts
31
+ * that never fill them in) simply have none set.
32
+ */
33
+ export declare const userProfileNamesSchema: z.ZodObject<{
34
+ username: z.ZodOptional<z.ZodString>;
35
+ first_name: z.ZodOptional<z.ZodString>;
36
+ middle_name: z.ZodOptional<z.ZodString>;
37
+ last_name: z.ZodOptional<z.ZodString>;
38
+ display_name: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strict>;
40
+ export type UserProfileNames = z.infer<typeof userProfileNamesSchema>;
41
+ /**
42
+ * PUT /api/user/profile request body. Full-replacement semantics: every
43
+ * field the user wants to keep must be present; `null` (or an omitted
44
+ * field) clears the stored value.
45
+ */
46
+ export declare const updateUserProfileRequestSchema: z.ZodObject<{
47
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ first_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
+ middle_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ last_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ }, z.core.$strict>;
53
+ export type UpdateUserProfileRequest = z.infer<typeof updateUserProfileRequestSchema>;
54
+ /** GET/PUT /api/user/profile success response body. */
55
+ export declare const userProfileResponseSchema: z.ZodObject<{
56
+ success: z.ZodLiteral<true>;
57
+ profile: z.ZodObject<{
58
+ username: z.ZodOptional<z.ZodString>;
59
+ first_name: z.ZodOptional<z.ZodString>;
60
+ middle_name: z.ZodOptional<z.ZodString>;
61
+ last_name: z.ZodOptional<z.ZodString>;
62
+ display_name: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strict>;
64
+ }, z.core.$strict>;
65
+ export type UserProfileResponse = z.infer<typeof userProfileResponseSchema>;
@@ -0,0 +1,79 @@
1
+ import { z } from "zod";
2
+ export const USERNAME_MIN_LENGTH = 3;
3
+ export const USERNAME_MAX_LENGTH = 32;
4
+ /**
5
+ * Maximum length for each individual person-name part (first / middle /
6
+ * last) and for the public display name.
7
+ */
8
+ export const MAX_USER_NAME_PART_LENGTH = 64;
9
+ /**
10
+ * Usernames are unique per deployment (case-insensitively — the database
11
+ * enforces uniqueness on LOWER(username), while the stored casing is
12
+ * preserved for display). Format: alphanumeric start and end with `.`,
13
+ * `_`, and `-` permitted in between. `@` is deliberately excluded so a
14
+ * username can never be confused with an email address, and `|` can
15
+ * never appear (the OIDC sub-claim delimiter).
16
+ */
17
+ export const USERNAME_REGEX = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
18
+ export const usernameFormatSchema = z
19
+ .string()
20
+ .min(USERNAME_MIN_LENGTH, `Username must be at least ${USERNAME_MIN_LENGTH} characters long!`)
21
+ .max(USERNAME_MAX_LENGTH, `Username may not be longer than ${USERNAME_MAX_LENGTH} characters!`)
22
+ .regex(USERNAME_REGEX, "Username may only contain letters, numbers, '.', '_', and '-', and must start and end with a letter or number.");
23
+ /**
24
+ * Rejects ASCII control characters (including CR/LF) that could pollute
25
+ * logs, headers, or rendered UI. All other unicode is permitted — names
26
+ * are human text.
27
+ */
28
+ // eslint-disable-next-line no-control-regex -- rejecting control chars is the point
29
+ const NO_CONTROL_CHARS_REGEX = /^[^\u0000-\u001F\u007F]*$/;
30
+ const namePartSchema = z
31
+ .string()
32
+ .trim()
33
+ .min(1)
34
+ .max(MAX_USER_NAME_PART_LENGTH, `Name may not be longer than ${MAX_USER_NAME_PART_LENGTH} characters!`)
35
+ .regex(NO_CONTROL_CHARS_REGEX, "Name may not contain control characters!");
36
+ /** A single part of a user's personal name (first / middle / last). */
37
+ export const userNamePartSchema = namePartSchema;
38
+ /**
39
+ * The user's public display name. Shown to other users and exposed to
40
+ * OIDC relying parties as the `name` claim when the `profile` scope is
41
+ * granted.
42
+ */
43
+ export const userDisplayNameSchema = namePartSchema;
44
+ /**
45
+ * The user-editable profile name fields stored on the USERS row. All
46
+ * fields are optional — accounts predating this feature (and accounts
47
+ * that never fill them in) simply have none set.
48
+ */
49
+ export const userProfileNamesSchema = z
50
+ .object({
51
+ username: usernameFormatSchema.optional(),
52
+ first_name: userNamePartSchema.optional(),
53
+ middle_name: userNamePartSchema.optional(),
54
+ last_name: userNamePartSchema.optional(),
55
+ display_name: userDisplayNameSchema.optional(),
56
+ })
57
+ .strict();
58
+ /**
59
+ * PUT /api/user/profile request body. Full-replacement semantics: every
60
+ * field the user wants to keep must be present; `null` (or an omitted
61
+ * field) clears the stored value.
62
+ */
63
+ export const updateUserProfileRequestSchema = z
64
+ .object({
65
+ username: usernameFormatSchema.nullable().optional(),
66
+ first_name: userNamePartSchema.nullable().optional(),
67
+ middle_name: userNamePartSchema.nullable().optional(),
68
+ last_name: userNamePartSchema.nullable().optional(),
69
+ display_name: userDisplayNameSchema.nullable().optional(),
70
+ })
71
+ .strict();
72
+ /** GET/PUT /api/user/profile success response body. */
73
+ export const userProfileResponseSchema = z
74
+ .object({
75
+ success: z.literal(true),
76
+ profile: userProfileNamesSchema,
77
+ })
78
+ .strict();
79
+ //# sourceMappingURL=user_profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user_profile.js","sourceRoot":"","sources":["../../src/user_data/user_profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,mBAAmB,GAAW,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAW,EAAE,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAW,EAAE,CAAC;AAEpD;;;;;;;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AAC,QAAQ,EAAE;IACpD,WAAW,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACrD,SAAS,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACnD,YAAY,EAAE,qBAAqB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC1D,CAAC;KACD,MAAM,EAAE,CAAC;AAMZ,uDAAuD;AACvD,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC;KACvC,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IACxB,OAAO,EAAE,sBAAsB;CAChC,CAAC;KACD,MAAM,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@schemavaults/auth-common",
3
3
  "description": "Types and utility functions for authentication and authorization",
4
- "version": "0.24.0",
4
+ "version": "0.25.1",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
7
7
  "repository": {
@@ -13,8 +13,8 @@
13
13
  "main": "dist/index.js",
14
14
  "types": "dist/index.d.ts",
15
15
  "dependencies": {
16
- "zod": "3.25.8",
17
- "@schemavaults/app-definitions": "0.12.0",
16
+ "zod": "4.4.3",
17
+ "@schemavaults/app-definitions": "0.12.1",
18
18
  "crypto-js": "4.2.0"
19
19
  },
20
20
  "scripts": {