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 calling generateRegistrationOptions() without specifying a value for userID.
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 to Uint8Arrays, and then using isoBase64URL.toString() on userHandle after auth to get back the UTF-8 user identifier.
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: