我正在 Angular 应用程序中实现 FIDO2(WebAuthn)。
我已经获得了 PublicKeyCredentialCreationOptions 对象和 seccessfullt 寄存器。
但打电话后
let response = await navigator.credentials.create({'publicKey': myPublicKeyCredentialCreationOption })
我尝试将响应发送到服务器。但是失败了。
当我尝试使用浏览器中的对象查看时
console.log(JSON.stringify(response))
I get
{}
作为输出 (?..) 但在做时
console.log(response)
我在控制台中得到一个带有值的对象......
对象应该如何序列化以发送到服务器?
公钥凭证对象包含数组缓冲区无法序列化为 JSON 的对象。您可以在 Angular 应用程序中对这些值进行 Base64 编码,然后在服务器上进行解码以获取相同的字节数组。存在一个专门为 WebAuthn 执行此操作的帮助程序库:https://github.com/github/webauthn-json
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)