if (navigator.credentials && window.PublicKeyCredential) {
const available = await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();
if (available) {
const newCredentialInfo = await navigator.credentials.create(options);
var response = newCredentialInfo.response;
var clientExtensionsResults = newCredentialInfo.getClientExtensionResults();
alert(JSON.stringify(response))
alert(JSON.stringify(clientExtensionsResults));
}
else {
alert("Unsupported");
}
}
给我只使用私钥(usb或smthg )。但是如果我将这个options.publicKey
与JavaScript和html结合使用,一切都会好起来的。它让我可以使用FaveID来进行测试,但是响应是空的。
我的选择是
{"rp":{"id":"https://im-faceid.netlify.app","name":"netlify.app"},"user":{"id":{"0":97,"1":87,"2":120,"3":53,"4":89,"5":87,"6":49,"7":118,"8":99,"9":109,"10":82,"11":104,"12":99,"13":50,"14":57,"15":50},"name":"test","displayName":"Test User"},"challenge":{"0":79,"1":72,"2":78,"3":122,"4":101,"5":71,"6":86,"7":111},"pubKeyCredParams":[{"type":"public-key","alg":-7}],"authenticatorSelection":{"authenticatorAttachment":"platform","requireResidentKey":false,"userVerification":"required"},"attestation":"none","timeout":15000}
发布于 2021-04-25 01:30:19
我看到您在<App />
组件的componentDidMount()
中调用了componentDidMount()
。macOS和iOS Safari都要求WebAuthn API调用要使用Touch ID的必须是“用户手势”的结果:
主动提示的数量惊人地低。这是不同的情况下发布的脸ID和触摸ID的网站。所以,web的Face和Touch ID需要用户手势才能工作。(为了向后兼容的安全密钥不需要用户手势)。
参见苹果公司对WebAuthn支持的介绍,以获得更多指导:https://webkit.org/blog/11312/meet-face-id-and-touch-id-for-the-web/
如果您更新了您的反应代码,将调用navigator.credentials.create()
的逻辑移动到按钮单击处理程序中,您就可以使用Face。它将要求您单击一个按钮来触发WebAuthn,而不仅仅是加载页面,但这是在苹果操作系统上使用WebAuthn的现实。
https://stackoverflow.com/questions/67241714
复制相似问题