检查浏览器的U2F功能

My1*_*My1 10 javascript authentication fido-u2f

有没有办法检查浏览器是否支持U2F

我知道现在,Chrome是唯一正式使用U2F的浏览器,但是有一些Firefox的插件,也可能有自定义的浏览器可能已经获得了U2F.

我不想像谷歌那样抛弃这样的浏览器,因为插件用户将无法使用它.

我看到GitHub似乎有办法看到它(因为它区分了有和没有插件的Firefox),但我不知道如何做到这一点.

小智 1

使用库caniuse-support,它使用来自服务caniuse.com ( https://caniuse.com/#feat=u2f ) 的信息并使用库Bowser(浏览器检测器):

const {
  getSupport,
  currentBrowser,
} = CaniuseSupport;

const test1 = getSupport("u2f"); // current browser

console.log(
  "Get feature support of U2F current browser (" +
    currentBrowser.id +
    " " +
    currentBrowser.version +
    "):",
  test1.level
);
Run Code Online (Sandbox Code Playgroud)

CodePen 沙箱