[英]Fido U2F client side javascript source code
我正在尋找 JavaScript 源代碼(客戶端)來在 Fido U2F 令牌和 Google Chrome(版本 41.0.2272.89 m)之間進行通信。
請幫我
這是使用 Yubico u2f-api 文件獲取注冊令牌響應的示例
var RegistrationData = {"challenge":"dG7vN-E440ZnJaKQ7Ynq8AemLHziJfKrBpIBi5OET_0",
"appId":"https://localhost:8443",
"version":"U2F_V2"};
window.u2f.register([RegistrationData], [],
function(data) {if(data.errorCode) {
alert("U2F failed with error: " + data.errorCode);
return;
}
alert(JSON.stringify(data));
});
您必須包含 u2f-api.js 並使用 Https 服務器
您可以執行注冊,甚至可以使用 Javascript 解析 registrationData
let registerRequest = {
challenge: 'RegisterChallenge',
version: 'U2F_V2'
}
u2f.register('https://localhost', [registerRequest], [],
(response) => {
U2FRegistration.parse(response.registrationData);
console.log(U2FRegistration);
}
);
這是一個 github 存儲庫,演示了這一點: https : //github.com/infiniteloopltd/U2FJS - 如前所述,您需要一個 HTTPS 服務器,並包含 u2f-api.js
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.