Skip to content
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

Handle undefined PublicKeyCredential in browserSupportsWebAuthnAutofill helper #544

Closed
clarafitzgerald opened this issue Apr 2, 2024 · 1 comment · Fixed by #557
Closed
Milestone

Comments

@clarafitzgerald
Copy link

Describe the issue

Currently, calling the browserSupportsWebAuthnAutofill helper on a browser without webauthn support will cause an error since it is trying to evaluate isConditionalMediationAvailable of undefined.

The helper should check whether PublicKeyCredential is defined first and resolve false if it isn't, similar to the platformAuthenticatorIsAvailable helper.

Code Samples + WebAuthn Options and Responses

import {
  browserSupportsWebAuthn,
  browserSupportsWebAuthnAutofill,
  platformAuthenticatorIsAvailable,
} from "@simplewebauthn/browser";

export const getPasskeySupportInfo = async () => {
  const hasWebAuthnSupport = browserSupportsWebAuthn();
  const hasWebAuthnAutofillSupport = await browserSupportsWebAuthnAutofill();
  const hasPlatformAuthenticator = await platformAuthenticatorIsAvailable();

  return {
    hasWebAuthnSupport,
    hasWebAuthnAutofillSupport,
    hasPlatformAuthenticator,
  };
};

Error message:

iOS: undefined is not an object (evaluating 'e.isConditionalMediationAvailable')
Android: Cannot read properties of undefined (reading 'isConditionalMediationAvailable')

SimpleWebAuthn Libraries

$ npm list --depth=0 | grep @simplewebauthn
├── @simplewebauthn/browser@9.0.1
├── @simplewebauthn/types@9.0.1
# ...
@MasterKale
Copy link
Owner

@clarafitzgerald This fix is now available in the recently-published @simplewebauthn/browser@10.0.0 ✌️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants