Skip to content

Commit

Permalink
fix: support new flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Nov 26, 2024
1 parent a65a447 commit 18bd39b
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -571,6 +572,10 @@ function App() {
<button onClick={registerAuthenticatorSecret} className="card">
Register Authenticator
</button>
<input value={otpValue} onChange={(e) => setOtpValue(e.target.value)}/>
<button onClick={deleteAuthenticator} className="card">
Delete Authenticator
</button>
</div>
</div>
);
Expand Down

0 comments on commit 18bd39b

Please sign in to comment.