diff options
author | Matthew Miller <matthew@millerti.me> | 2022-03-04 16:43:59 -0800 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2022-03-04 16:43:59 -0800 |
commit | 3ed5397398b9cb1c2184b4cd61dd2ac759622335 (patch) | |
tree | 9485c197065a67d46b60a19be007806a37f65ee1 /packages/browser/src/helpers/identifyRegistrationError.ts | |
parent | 0cb596123e6c9f3b7eba1e15bf78144d94625e94 (diff) |
Get more specific with user ID TypeError
Diffstat (limited to 'packages/browser/src/helpers/identifyRegistrationError.ts')
-rw-r--r-- | packages/browser/src/helpers/identifyRegistrationError.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/browser/src/helpers/identifyRegistrationError.ts b/packages/browser/src/helpers/identifyRegistrationError.ts index faa7a1e..4779f1a 100644 --- a/packages/browser/src/helpers/identifyRegistrationError.ts +++ b/packages/browser/src/helpers/identifyRegistrationError.ts @@ -59,8 +59,10 @@ export function identifyRegistrationError({ error, options }: { return new WebAuthnError(`The RP ID "${publicKey.rp.id}" is invalid for this domain (SecurityError)`); } } else if (error.name === 'TypeError') { - // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 5) - return new WebAuthnError('User ID was not between 1 and 64 characters'); + if (publicKey.user.id.byteLength < 1 || publicKey.user.id.byteLength > 64) { + // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 5) + return new WebAuthnError('User ID was not between 1 and 64 characters (TypeError)'); + } } else if (error.name === 'UnknownError') { // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 1) // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 8) |