enableMFA with auth0 jwt

Hi,

i try to use enableMFA() function (React Hooks for PnP No Modal SDK | Documentation | Web3Auth), but i receive this error

There seems to be some bug in the code. Please contact support to fix this.
Invalid params for jwt login. Missing domain*
Error: Invalid params for jwt login. Missing domain: traceId: undefined - spanId: undefined

Why?

Hello indirizzo 1!

Thanks for reaching out. It seems you’re experiencing an issue with using the enableMFA() function alongside Auth0 JWT in the Plug n Play SDK.

From the error message, it appears that the domain parameter might be missing in your Auth0 JWT login configuration. To better assist, could you please check the following:

  1. Code Snippets: Share the section of your code where you’re initializing Web3Auth and setting up the JWT login. It will help us identify if there’s any missing configuration.

  2. Check Parameters: Ensure that your JWT login configuration includes all necessary parameters, specifically the domain related to your Auth0 setup.

If you provide the code and any additional configuration details, the support team will be able to help you further!

Let me know if you need help with anything else. :blush:

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

async enableMFA(): Promise<void> {
    if (this.web3authInstance) {
      const mfa = await this.web3authInstance.enableMFA()
      console.log(mfa)
    }
  }


 // Connect to the Web3Auth adapter
      const web3authProvider = await this.web3authInstance.connectTo(WALLET_ADAPTERS.AUTH, {
        loginProvider: "jwt", // Specify the login provider (e.g., "jwt" for custom JWT-based login)

        extraLoginOptions: {
          domain: auth0Domain,
          verifierIdField: 'sub',

        },
      });



// Get openlogin adapter by provider
export const getOpenloginAdapterByProvider = (): AuthAdapter => {
  return new AuthAdapter({

    adapterSettings: {

      network: web3AuthNetwrok,
      uxMode: 'redirect',
      whiteLabel: {
        logoDark: ''
        logoLight: ''
        appName: '',
        appUrl: '', 
        defaultLanguage: 'en',
        theme: {
          primary: '#000000',
        },
        useLogoLoader: true,
      },

      loginConfig: {

        jwt: {
          verifier: auth0Verifier,
          typeOfLogin: 'jwt',
          clientId: auth0ClientId,
          logoDark: ''
          logoLight: ''
        },
      },
    },

  });
}

Please pass the same login params that you’re passing to ConnectTo()

const mfa = await this.web3authInstance.enableMFA({
        loginProvider: "jwt",
        extraLoginOptions: {
          domain: auth0Domain,
          verifierIdField: 'sub',
        },
     });

I receive the same error

  async enableMFA(): Promise<void> {
    if (this.web3authInstance) {
      const mfa = await this.web3authInstance.enableMFA({
        loginProvider: "jwt",
        domain: auth0Domain,
        extraLoginOptions: {
          domain: auth0Domain,
          verifierIdField: 'sub',
        }
      })
      console.log(mfa)
    }
  }

In console log:

Error: Invalid params for jwt login. Missing domain: traceId: undefined - spanId: undefined

Which login method are you using on Auth0 Modal?

I’m using google and email/password

// Get openlogin adapter by provider
export const getOpenloginAdapterByProvider = (): AuthAdapter => {
  return new AuthAdapter({

    adapterSettings: {

      network: web3AuthNetwrok,
      uxMode: 'redirect',
      whiteLabel: {
        logoDark: 'logo-dark.png', // TODO: CHANGE
        logoLight: 'logo-light.png', // TODO: CHANGE
        appName: '',
        appUrl: 'h', // TODO: CHANGE
        defaultLanguage: 'en',
        theme: {
          primary: '#000000',
        },
        useLogoLoader: true,
      },

      loginConfig: {

        jwt: {
          verifier: auth0Verifier,
          typeOfLogin: 'jwt',
          clientId: auth0ClientId,
          logoDark: 'logo-dark.png', // TODO: CHANGE
          logoLight: 'logo-light.png', // TODO: CHANGE
        },
      },
    },

  });
}

async initWeb3Auth(): Promise<> {
    try {
      const chainConfig = getChainConfig();
      const privateKeyProvider = getPrivateKeyProviderByConfig(chainConfig);
      const web3authInstance = getWeb3AuthNoModalByConfig(chainConfig, privateKeyProvider);

      const openloginAdapter = getOpenloginAdapterByProvider();

      web3authInstance.configureAdapter(openloginAdapter);
      await web3authInstance.init();
} catch {}}

async login(): Promise<> {
   
      if (!this.web3authInstance) {
        throw new Error("Web3Auth not initialized. Please initialize it before logging in.");
      }

      // logout if already connected
      if (this.web3authInstance?.connected) {
        await this.web3authInstance.logout();
      }


      // Connect to the Web3Auth adapter
      const web3authProvider = await this.web3authInstance.connectTo(WALLET_ADAPTERS.AUTH, {
        loginProvider: "jwt", // Specify the login provider (e.g., "jwt" for custom JWT-based login)

        extraLoginOptions: {
          domain: auth0Domain,
          verifierIdField: 'sub',

        },
      });
}


  async enableMFA(): Promise<void> {
    if (this.web3authInstance) {
      const mfa = await this.web3authInstance.enableMFA({
        loginProvider: "jwt",
        extraLoginOptions: {
          domain: auth0Domain,
          verifierIdField: 'sub',
        }
      })
      console.log(mfa)
    }
  }

You can check my auth0 method on loginConfig

Hey, any news for me?

Hi @indirizzo722,

We have successfully reproduced the issue on our end and have shared it with our product team for further investigation.

One approach that seems to work for enabling MFA is passing the idToken. However, for this to work with Auth0, you will need to allow login separately and extract the idToken, which is a more complicated process. We will follow up with you once we have an update.

1 Like

There are any news?
I need to go on production in the next month with that functionality.

Thank you

Hi @indirizzo722,

We tested it on our end and could reproduce the issue. We’ve informed the team and will get back to you once we have an update.

Thank you

1 Like

Hi, how is the fixing of this issue going?

Thank you

Hey @indirizzo722

No update for now, will ping the team again today.

Thank you for your patience.