-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Passkeys - JSON.stringify() fallback for various password managers #62917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a fallback mechanism for JSON serialization of passkey credentials to handle password managers that don't properly implement PublicKeyCredential.prototype.toJSON
. The change addresses compatibility issues where JSON.stringify()
fails with an "Illegal invocation" error in certain password managers like 1Password.
- Wraps the existing
JSON.stringify(credential)
call in a try-catch block - Implements manual JSON serialization as a fallback when the standard approach fails
- Adds a helper function to convert ArrayBuffer/Uint8Array data to base64url format
.../content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js
Outdated
Show resolved
Hide resolved
.../content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js
Outdated
Show resolved
Hide resolved
.../content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js
Outdated
Show resolved
Hide resolved
.../content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js
Outdated
Show resolved
Hide resolved
.../content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js
Outdated
Show resolved
Hide resolved
…harp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js Co-authored-by: Copilot <[email protected]>
…harp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js Co-authored-by: Copilot <[email protected]>
…harp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js Co-authored-by: Copilot <[email protected]>
Since I was pinged, for some long forgotten reason I rewrote the helpers here: |
.../content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js
Show resolved
Hide resolved
…harp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js
@maartenba can you name which password managers are affected by this? I'm not keen on dumping a bunch of code like this on the template to work around a bug in a password manager implementation. I would rather have the password managers fix their implementation to be compliant. As an alternative we can offer this as a sample but putting it on the template raises other concerns like maintainability, updates and so on in the longer term. |
@javiercn agree this is the password manager's responsibility, looks like at least 1Password has had this issue for a longer time now with no resolution in sight. If there are docs (or planned docs) I'm happy to suggest a PR there to provide guidance to others who may want to handle this issue in their application. |
@mikekistler @MackinnonBuck thoughts on putting this on docs instead? |
@javiercn @maartenba I agree that we probably don't want to bloat the templates with workaround logic for bugs in password managers. We are certainly planning docs for the Passkey support and putting some guidance there for this issue seems reasonable. |
Feel free to reuse the JS code here, or if you'd like that as a contribution when working on docs I'd be happy to help. |
I agree that mentioning this in the docs is the right direction. |
@maartenba @MackinnonBuck @mikekistler I've created #63078 to track the doc additions. I'm going to close the PR for now since we don't plan to take it. @maartenba thanks in any case for putting this forward and starting the discussion. |
Passkeys - JSON.stringify() fallback for various password managers
Some password managers do not implement
PublicKeyCredential.prototype.toJSON
correctly, which is required forJSON.stringify()
to work when serializing a passkey credential - e.g. https://www.1password.community/discussions/1password/typeerror-illegal-invocation-in-chrome-browser/47399This PR adds a fallback to work with various password managers.