Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

maartenba
Copy link

@maartenba maartenba commented Jul 25, 2025

Passkeys - JSON.stringify() fallback for various password managers

Some password managers do not implement PublicKeyCredential.prototype.toJSON correctly, which is required for JSON.stringify() to work when serializing a passkey credential - e.g. https://www.1password.community/discussions/1password/typeerror-illegal-invocation-in-chrome-browser/47399

This PR adds a fallback to work with various password managers.

@Copilot Copilot AI review requested due to automatic review settings July 25, 2025 05:31
@github-actions github-actions bot added the area-blazor Includes: Blazor, Razor Components label Jul 25, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 25, 2025
Copy link
Contributor

Thanks for your PR, @@maartenba. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link
Contributor

@Copilot Copilot AI left a 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

maartenba and others added 3 commits July 25, 2025 07:34
…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]>
@abergs
Copy link

abergs commented Jul 25, 2025

Since I was pinged, for some long forgotten reason I rewrote the helpers here:
https://github.com/bitwarden/passwordless-client-js/blob/main/src/passwordless.ts#L439-L487 (Apache 2.0)

…harp/BlazorWebCSharp.1/Components/Account/Shared/PasskeySubmit.razor.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants