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

Update example to show feature detection #170

Closed
RByers opened this issue Sep 18, 2024 · 3 comments · Fixed by #173
Closed

Update example to show feature detection #170

RByers opened this issue Sep 18, 2024 · 3 comments · Fixed by #173
Assignees

Comments

@RByers
Copy link
Member

RByers commented Sep 18, 2024

Now that we're back to using navigator.credentials, our simple feature detection mechanism of if ('identity' in navigator) won't work. Presumably we'd recommend if ('DigitalCredential' in window) instead, right? Perhaps we should add this to the example in the explainer to make it clear?

I know of one developer who wasn't sure how best to feature-detect our origin trial and so instead looked for a Chrome Android UA string with Chrome version >= 128. Obviously that's not what we want people doing since the API will become available on other browsers too. Our examples should document our best-practice recommendations.

@timcappalli
Copy link
Member

timcappalli commented Sep 18, 2024

For passkeys and WebAuthn, we typically recommend:

if ( typeof window.PublicKeyCredential !== 'undefined' ) {
// do stuff
}

I vaguely remember there being a reason why we didn't use in, but I'm blanking on it.

@timcappalli
Copy link
Member

@RByers you can probably steal this updated example: https://digitalcredentials.dev/docs/verifier-site/requesting-cred/

@RByers
Copy link
Member Author

RByers commented Sep 20, 2024

SGTM, happy to incorporate something like this into the explainer. Putting on my queue for now, but also happy for someone else to grab it if they get to it before me.

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

Successfully merging a pull request may close this issue.

3 participants