Firebase 10.8.0 TOTP多因素认证注册时出现TypeError问题
Firebase 10.8.0 TOTP多因素认证注册报错及解决方法
我在使用Firebase 10.8.0版本为Web应用添加TOTP多因素认证功能时,遵循官方文档的用户注册步骤操作:
- 已成功生成TOTP密钥并通过二维码展示给用户,方便导入至认证应用(对应文档步骤1-4)
- 后续提示用户输入认证应用的确认码,执行以下代码完成MFA注册(对应文档步骤5):
const auth = getAuth().currentUser; const multiFactorAssertion = TotpMultiFactorGenerator.assertionForEnrollment( totpSecret, verificationCode ); multiFactor(user) .enroll(multiFactorAssertion, "mfa_totp") .then((res) => { // Success console.log(res); }) .catch((error) => { // Error console.log(error); });
执行时出现如下错误:
TypeError: this.secret._makeTotpVerificationInfo is not a function at TotpMultiFactorAssertionImpl._callee97$ (index-bea2a320.js:18548:1) at tryCatch (regeneratorRuntime.js:45:1) at Generator.<anonymous> (regeneratorRuntime.js:133:1) at Generator.next (regeneratorRuntime.js:74:1) at asyncGeneratorStep (asyncToGenerator.js:3:1) at _next (asyncToGenerator.js:22:1) at asyncToGenerator.js:27:1 at new Promise (<anonymous>) at TotpMultiFactorAssertionImpl.<anonymous> (asyncToGenerator.js:19:1) at TotpMultiFactorAssertionImpl._finalizeEnroll (index-bea2a320.js:18560:1) at TotpMultiFactorAssertionImpl._process (index-bea2a320.js:18296:1) at MultiFactorUserImpl._callee54$ (index-bea2a320.js:12161:1) at tryCatch (regeneratorRuntime.js:45:1) at Generator.<anonymous> (regeneratorRuntime.js:133:1) at Generator.next (regeneratorRuntime.js:74:1) at asyncGeneratorStep (asyncToGenerator.js:3:1) at _next (asyncToGenerator.js:22:1)
最初怀疑是包内Bug,后排查发现问题所在:
更新:问题已解决
生成multiFactorAssertion时,错误使用了totpSecret.secretKey作为参数,正确做法是直接传入totpSecret本身。
内容的提问来源于stack exchange,提问作者Tejogol
相关产品推荐
相关产品推荐

