fix: passkey fields validation (#1047)

This commit is contained in:
diced
2026-04-18 22:35:09 -07:00
parent a97cf32682
commit db3a1b88ad
2 changed files with 16 additions and 1 deletions
+8 -1
View File
@@ -268,14 +268,21 @@ export const schema = z.object({
rpID: z
.string()
.trim()
.refine(
(v) => v.length === 0 || /^[a-zA-Z0-9.-]+$/.test(v),
'RP ID can only contain letters, numbers, dots, and hyphens. Example: example.com, localhost, zipline.example.com.',
)
.transform((v) => (v.length > 0 ? v : null))
.nullable()
.default(null),
origin: z
.string()
.trim()
.refine(
(v) => v.length === 0 || /^https?:\/\/[a-zA-Z0-9.-]+(:\d+)?(\/.*)?$/.test(v),
'Origin must be a valid URL starting with http:// or https://',
)
.transform((v) => (v.length > 0 ? v : null))
.refine((v) => (v ? URL.canParse(v) : true), 'Invalid URL')
.nullable()
.default(null),
}),