Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates @simplewebauthn/server and @simplewebauthn/browser to always base64url-encode the now optional
userID
bytes. In addition, a 32-byte-long random user identifier will now be generated when callinggenerateRegistrationOptions()
without specifying a value foruserID
.Going forward SimpleWebAuthn will encourage new library users to not specify a value for
userID
! The docs will be updated accordingly once this all goes live.However, existing users that upgrade to v10 of @simplewebauthn/browser (containing these changes) and wish to continue specifying their own UTF-8 user IDs can continue to do so by accounting for this when generating registration options and parsing
userHandle
after authentication.Fixes #530.
Breaking Changes
String values for
userID
are no longer allowed.The library will throw an error with a link to https://simplewebauthn.dev/docs/advanced/server/custom-user-ids for refactor guidance. The guidance will boil down to wrapping existing string identifiers in a call to
isoUint8Array.fromUTF8String()
to get them toUint8Array
s, and then usingisoBase64URL.toString()
onuserHandle
after auth to get back the UTF-8 user identifier.Before:
After:
isoBase64URL.toString()
andisoBase64URL.fromString()
have been renamedThe method names have been updated to reflect the use of UTF-8 string encoding.
Before:
After: