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
feat: added isPassKeyAvailable on biometric-ed25519 package #1139
Conversation
🦋 Changeset detectedLatest commit: 4f7f890 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Looks good, one small comment on the util function
if (!PublicKeyCredential || !PublicKeyCredential?.isUserVerifyingPlatformAuthenticatorAvailable) { | ||
return Promise.resolve(false); | ||
} | ||
return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable(); |
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.
if (!PublicKeyCredential || !PublicKeyCredential?.isUserVerifyingPlatformAuthenticatorAvailable) { | |
return Promise.resolve(false); | |
} | |
return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable(); | |
return PublicKeyCredential?.isUserVerifyingPlatformAuthenticatorAvailable?.() || false; |
The return value of an async
function is always a Promise
, so it doesn't need to be wrapped in Promise.resolve
. Also you can use optional chaining to call the PublicKeyCredential
method to avoid needing to reference it more than once 🙂
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.
would this still work if PublicKeyCredential
is not available? From Ref, on WebView Android, it doesn't support at all. Assuming that PublicKeyCredential
can be undefined, should we use
if (typeof PublicKeyCredential !== 'undefined') {
return PublicKeyCredential?.isUserVerifyingPlatformAuthenticatorAvailable?.();
}
return false;
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.
would this still work if PublicKeyCredential is not available?
👍 if it's an invalid reference then it must be guarded.
Other alternatives to your solution would be a try
/catch
or, my personal preference, referencing via window
, i.e.
return window.PublicKeyCredential?.isUserVerifyingPlatformAuthenticatorAvailable?.() || false;
Pre-flight checklist
pnpm changeset
to create achangeset
JSON document appropriate for this change.Motivation
This PR contains a new util function
isPassKeyAvailable
where it will be used to validate the availability of passKey usage of user's current browser.Test Plan
I have conducted manual test on running above code on latest Chrome browser (returns promise true) vs latest Firefox (returns promise false)