From 18bd39bc1196318dff71d6a339ef2d4d05661750 Mon Sep 17 00:00:00 2001 From: ieow Date: Tue, 26 Nov 2024 15:05:30 +0800 Subject: [PATCH] fix: support new flow --- .../src/App.tsx | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mpc-core-kit-web/quick-starts/mpc-core-kit-react-remote-sign/src/App.tsx b/mpc-core-kit-web/quick-starts/mpc-core-kit-react-remote-sign/src/App.tsx index d9dde579..fe2cf53c 100644 --- a/mpc-core-kit-web/quick-starts/mpc-core-kit-react-remote-sign/src/App.tsx +++ b/mpc-core-kit-web/quick-starts/mpc-core-kit-react-remote-sign/src/App.tsx @@ -78,7 +78,7 @@ if (typeof window !== "undefined") { web3AuthClientId, web3AuthNetwork: WEB3AUTH_NETWORK.MAINNET, storage: window.localStorage, - manualSync: true, // This is the recommended approach + // manualSync: true, // This is the recommended approach tssLib: dklsLib, }); @@ -204,28 +204,29 @@ function App() { if (!coreKitInstance || !authenticatorService) { throw new Error("coreKitInstance not found"); } - const mfaSecret = generateSecretKey(); - const factorkey = generateFactorKey(); - const result = await authenticatorService.registerFactor( mfaSecret, factorkey.private.toString("hex") ) + const result = await authenticatorService.startRegisterFactor() console.log(result); // qrcode - setQrCodeSVG(mfaSecret); + setQrCodeSVG(result.secretKey); setShowQrCode(true); }; + const deleteAuthenticator = async () => { + if (!coreKitInstance || !authenticatorService) { + throw new Error("coreKitInstance not found"); + } + await authenticatorService.unregisterFactor(); + } const registerAuthenticatorFactorkey = async ( code : string) => { if (!coreKitInstance || !authenticatorService) { throw new Error("coreKitInstance not found"); } - const factorKey = authenticatorService.factorKey; - if (!factorKey) { - throw new Error("factorKey not found"); - } - await authenticatorService.verifyRegistration( code ); + const factorkey = generateFactorKey(); + await authenticatorService.verifyRegistration( code, factorkey.private.toString("hex") ); await coreKitInstance.commitChanges(); setShowQrCode(false); } @@ -571,6 +572,10 @@ function App() { + setOtpValue(e.target.value)}/> + );