webauthn icon indicating copy to clipboard operation
webauthn copied to clipboard

add feature detection blurb...

Open equalsJeffH opened this issue 6 years ago • 4 comments

..pointing back to credman's section 7.1. Website Authors, which briefly & explicitly explains that trying to use if (!navigator.credentials) ... is suboptimal for feature detection, rather if (!window.PublicKeyCredential) ... ought be used. [the examples in webauthn already use the latter as feature detection, so they are already good]

equalsJeffH avatar May 06 '19 21:05 equalsJeffH

In webauthn-json (which is the library we're using in the GitHub codebase itself), we're using this:

export function supported(): boolean {
  return !!(navigator.credentials && navigator.credentials.create && navigator.credentials.get && window.PublicKeyCredential);
}

(https://github.com/github/webauthn-json/blob/61dfd2b004316f5ebc096dfd2ac0576318bfdee7/src/webauthn.ts#L28-L30)

Is that still the "recommended" way to detect support for security key operations?

lgarron avatar Aug 21 '19 02:08 lgarron

technically, according to credman's section 7.1. Website Authors, one only needs to check for window.<necessary-credential-type>, however I'm not a JS & client-side-dev expert. AFAIK, a user agent would need to implement all the things you're checking for in order to support "just" PublicKeyCredential so your thorough check ought to work correctly across various partial impls of crendential management?

equalsJeffH avatar Aug 21 '19 18:08 equalsJeffH

Yeah, we had some issues with https://github.com/brave/brave-ios when we were trying to detect features we thought were needed for WebAuthn compat. Testing the recommended value + the functions that we'll need to call seemed like the best way to check that things will work as expected.

lgarron avatar Aug 21 '19 23:08 lgarron

i think this can be addressed in a milestone later than wd-03

equalsJeffH avatar Jul 01 '20 17:07 equalsJeffH

being addressed by #1923

timcappalli avatar Sep 12 '23 14:09 timcappalli