WICG / digital-credentials

Digital Credentials, like driver's licenses
https://wicg.github.io/digital-credentials/
Other
82 stars 9 forks source link

Update example to show feature detection #170

Closed RByers closed 1 month ago

RByers commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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

RByers commented 1 month ago

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.