-
Notifications
You must be signed in to change notification settings - Fork 15
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
[Question, Web dev] Best way for detecting U2F in Web pages #38
Comments
@My1 Test if |
Hm, if (typeof window.u2f !== "undefined") returns true then it must have some value set right? |
yes but for internet explorer (bottom right) it should not be true, I dont think IE does U2F |
Ah interesting, could you see what value it typeof returns for it in IE instead checking if it's not undefined? Also doesn't that script you are loading is defining it by chance (if it's compatibility shim for chrome then i am pretty sure it does that)? |
well I used the yubico documentation to do U2F and they said "Client-side https://developers.yubico.com/U2F/Libraries/Using_a_library.html so at least the text pretty much assumes that the api (or something similar) is needed to expose those fuctions If I dont load the api prior to checking, a plugged firefox says true but everyone else (including chrome) says false. |
Chrome does expose u2f functionality as extension messaging port, and what that js code does is implement window.u2f.register/sign functions by sending/receiving messages from that port. This firefox extension just makes window.u2f.register/sign always available. So you check probably should work by checking if window.u2f exists before loading that script, if it's here you good to go, if not check if it's Chrome and you should be good as well (you could also check for browser version in this situation to see if it's one that should have it). |
but if a browser goes for a chrome similar approach (it might just be a fork of it) then it wont work which is a bit sad because it needs to stay updated. and that user agent isnt reliable is pretty obvious considering that all browsers have mozilla in their agents to circumvent useragent-based browser switches |
Well there is no real solution for having 100% sure way to be forward compatible, and i doubt that other browsers will implement interface that is compatible with what Chrome does (this will require having message port exposed as window.chrome.extension., and have lot more code that chrome has for extension managing). |
okay. it is a bit sad the the there isnt some kind of "featureset" array set by the browser and read-only where any js software can check whether feature x is available. it would be intresting to know how github did it but when I checked some months agoI couldnt make much sense of their code, honestly. |
I am writing a site that also should work with U2F but there's one important question.
what is the best way to detect U2F functionality for both chrome and users of addons for other browsers?
The text was updated successfully, but these errors were encountered: