How to migrate @web3auth/single-factor-auth to v10

In our Dapp we are using @web3auth/single-factor-auth v9, which will get deprecated soon.

What would be the exact method or library to use in v10? I believe it should be some config/method when using @web3auth/modal no?

Sorry about my question but did not see any migration documents about this library.

Many thanks in advance!

Hi Albert — thanks for the clear question. You’re asking about a migration (not reporting a runtime error), so this is about moving your DApp from @web3auth/single-factor-auth v9 → v10.

Summary of what I’ve pulled from your message

  • SDK: MetaMask Embedded Wallets (Web3Auth)
  • Current package/version: @web3auth/single-factor-auth v9 (will be deprecated)
  • Target: v10 migration
  • Platform: DApp / web (assumed — tell me if it’s another platform)

What to know and the recommended migration path

  • In Web3Auth v10, the single-factor (passwordless) flow is handled by the OpenLogin adapter functionality and is integrated through the Web3Auth core/modal flow rather than a dedicated single-factor package. In short: replace the old @web3auth/single-factor-auth usage with the OpenLogin adapter + Web3Auth (modal or core) in v10.

High-level example (pseudocode) — adapt to your project and exact v10 package names:

  • import Web3Auth (from @web3auth/web3auth or @web3auth/modal)
  • import OpenloginAdapter (from @web3auth/openlogin-adapter)
  • const web3auth = new Web3Auth({ clientId, chainConfig });
  • const openloginAdapter = new OpenloginAdapter({ adapterSettings: { uxMode: ‘popup’, loginConfig: { /* provider config */ } } });
  • web3auth.configureAdapter(openloginAdapter);
  • await web3auth.initModal();
  • const provider = await web3auth.connect();

Notes and links

  • The exact package names and API details are in Web3Auth’s v10 docs — I recommend checking their v10 migration docs and the OpenLoginAdapter docs for the precise import names and options: Introduction | Documentation | Web3Auth

If you want a precise code migration

  • If you can paste your current initialization + login snippets (the minimal code that uses @web3auth/single-factor-auth), I’ll produce a drop-in v10 version for you.
  • Only attach browser console logs/screenshots if you hit runtime errors after migration — we don’t need them yet.

If you’d like I can also:

  • Provide a line-by-line migration of your current snippet
  • Verify exact package names to install (I can confirm the npm packages you should use for v10)

Would you like me to convert your current init/login code to v10? If yes, paste the snippet you’re using and I’ll return the converted code.

Note: This response was generated by an AI bot and may require further verification. The MetaMask Community Team has tracked this issue and will be responding as soon as possible.

Additionally, we would recommend you to join our biweekly Office Hours to get this resolved even faster. MetaMask Developer Office Hours

This is our current @web3auth/single-factor-auth v9 implementation:

import { Web3Auth as Web3AuthSFA, decodeToken } from "@web3auth/single-factor-auth";
import { WEB3AUTH_NETWORK } from "@web3auth/modal";

async function connectWeb3AuthSFA(idToken, verifier, clientId) {
  const web3auth = new Web3AuthSFA({
      web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
      clientId,
      usePnPKey: false
  });
  await web3auth.init();
  const { payload } = decodeToken(idToken);
  const sfaParams = {
    verifier,
    verifierId: payload.sub,
    idToken
  };
  await web3auth.connect(sfaParams);
}

Please have a look at this example: web3auth-examples/custom-authentication/single-connection/custom-jwt-example at main · Web3Auth/web3auth-examples · GitHub
You just need to use the same web3auth Network, client id and verifier(which is now connectionId)
make sure you pass the useSFAKey parameter as true in the Web3auth constructor to get the same keys as before.

Many thanks for the explanation @maharshi it worked great!

2 Likes