Encountering an 'Error occurred while verifying paramsCould not get timesignedint from' error during the connection attempt

Hello, I’ve been working with the Node.js sample code, and I’m currently facing an issue. When I attempt to establish a connection, the error below is generated

{
  connectionError: Error: Error occurred while verifying paramsCould not get timesignedint from 
      at /Users/vaibhav/Downloads/web3auth-backend-main/node_modules/@toruslabs/torus.js/dist/torusUtils-node.js:467:20
      at <anonymous>
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}

Here’s the sample code:


const verifyToken = async (idToken) => {
  const jwks = jose.createRemoteJWKSet(new URL("https://api-auth.web3auth.io/jwks"));
  try {
    const jwtDecoded = await jose.jwtVerify(idToken, jwks, { algorithms: ["ES256"] });
    console.log(`jwtDecoded`, jwtDecoded);
    return { email: jwtDecoded.payload.email };
  } catch (e) {
    console.log({ verifyTokenError: e });
  }
};

const chainConfig = {
  chainNamespace: CHAIN_NAMESPACES.EIP155,
  chainId: "0x13881",
  rpcTarget: "https://rpc-mumbai.maticvigil.com",
  displayName: "Polygon-Mumbai",
  blockExplorer: "https://mumbai.polygonscan.com/",
  ticker: "MATIC",
  tickerName: "Polygon-mumbai",
};

const privateKeyProvider = new EthereumPrivateKeyProvider({
  config: { chainConfig },
});

const web3auth = new Web3Auth({
  clientId: process.env.WEB3_AUTH_CLIENT_ID,
  chainConfig,
  web3AuthNetwork: "testnet",
  usePnPKey: false,
});

web3auth.init({ provider: privateKeyProvider });

const connect = async ({ verifierId, idToken }) => {
  try {
    const provider = await web3auth.connect({
      verifier: "trikon-v3",
      verifierId,
      idToken,
    });

    const privateKey = await provider.request({ method: "eth_private_key" });
    console.log(`privateKey`, privateKey);
  } catch (e) {
    console.log({ connectionError: e });
  }
};

const connectWithId = async ({ idToken }) => {
  const token = await verifyToken(idToken); // getting the email from 'token.email' from idToken
  connect({ verifierId: token.email, idToken });
};

connectWithId({ idToken });

and sample token

eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlRZT2dnXy01RU9FYmxhWS1WVlJZcVZhREFncHRuZktWNDUzNU1aUEMwdzAifQ.eyJpYXQiOjE2OTcwNDE1NTQsImF1ZCI6IkJKY0t5YjRmQVB4eGNWTUpSbWQxQ1A2bmhjay1QeUVndTlJMHNHY0FyZThzNy1kcjg0ejJrbnBsRlZMMFNLSWxXNHVRUENiRjB5VWRCZVo2NlpvbVU5NCIsIm5vbmNlIjoiMDI3YjE4MzM5YTdkZTQwOTg2YTBkYWI2OGJlNmE1OTYwZmJiMmE3NTRkZTBkMTdmZDU0OGYwNzUzZjU4NGZiZmYxIiwiaXNzIjoiaHR0cHM6Ly9hcGktYXV0aC53ZWIzYXV0aC5pbyIsIndhbGxldHMiOlt7InB1YmxpY19rZXkiOiIwMjU4M2M0NTAwMTY0ODcxYThiMDY3MzI0ODBiNDM0M2ZlZWM1MWE3YTMxYTM0ZjcxYzg3MjU1OGZjNGEzNWFkMzAiLCJ0eXBlIjoid2ViM2F1dGhfYXBwX2tleSIsImN1cnZlIjoic2VjcDI1NmsxIn1dLCJlbWFpbCI6InZhaWJoYXZzaW5oYTYxOUBnbWFpbC5jb20iLCJuYW1lIjoiVmFpYmhhdiBTaW5oYSIsInByb2ZpbGVJbWFnZSI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS9hL0FDZzhvY0s5WG9aSFVJQ2stRFNlMWE3VVNYOFQ3Q1RweTFNUmZQdDBwekJNTHhfVXJnPXM5Ni1jIiwidmVyaWZpZXIiOiJ0cmlrb24tdjMiLCJ2ZXJpZmllcklkIjoidmFpYmhhdnNpbmhhNjE5QGdtYWlsLmNvbSIsImFnZ3JlZ2F0ZVZlcmlmaWVyIjoidHJpa29uLXYzIiwiZXhwIjoxNjk3MTI3OTU0fQ.a3JWmVGXS8-B6s3jYVV7uVMzokWzFgfTcLNVcbryWrzMc7gaF5Yk2LzPJsglkWCjCQ5ljYedvFd58-R-yZNHtw

Error occurred while verifying paramstimesigned error could be because:

  • JWT is expired.
  • The JWT’s exp field is less than the current time.
  • The JWT’s iat field is greater than 60s from current time.

Web3Auth accepts only those JWTs whose iat is less than the current time and is not greater than 60s from current time. Regardless of the exp field of the JWT.

  • In short, the JWT is considered expired if the iat is greater than 60s from the current time.

Could you try generating a fresh token and check?

The exp time is set to 24 hours, and I’ve already attempted using a freshly generated token within 60 seconds.

Attaching the code for the openloginAdapter for reference

const openloginAdapter = new OpenloginAdapter({
      privateKeyProvider,
      adapterSettings: {
        loginConfig: {
          google: {
            name: "Trikon",
            verifier: "trikon-v3",
            typeOfLogin: "google",
            clientId:
              GOOGLE_CLIENT_ID
          },
        },
      },
    });

This must be sapphire_devnet if you are using testnet. Please setup your project as well with sapphire_devnet if you need test environment.

You may also refer to our troubleshooting guide for JWT errors:

Hello @vjgee,

Thank you for the previous resolution. However, I’m now encountering the following error when attempting to connect

connectionError: WalletLoginError: Custom. User has already enabled mfa, please use the @web3auth/web3auth-web sdk for login with mfa at WalletLoginError.fromCode

 code: 5000

I’d like to mention that I’m using the email as the verifierId.

I have created a new user, and mfa is disabled. However, I’m unable to establish a connection
Screenshot 2023-10-12 at 1.52.02 PM

It appears that there may be an issue with your verifier trikon-v3. Would you be able to provide me with the validation fields that you used when initially setting up the verifier? This information will be helpful in resolving the issue.

Also, the verifierId here will be the sub value, not the email.

SFA SDKs work only for users who have not enabled MFA. Check out the warning here .

Here are the verifier details, but I’m not receiving the sub value in the token. Additionally, MFA is disabled for the user

This is the code I am utilizing for authentication and token generation

const openloginAdapter = new OpenloginAdapter({
      privateKeyProvider,
      adapterSettings: {
        loginConfig: {
          google: {
            name: "Trikon",
            verifier: "trikon-v3",
            typeOfLogin: "google",
            clientId:
              GOOGLE_CLIENT_ID
          },
        },
      },
    });

@vaibhavsinha619 Please check if you are passing correct verifier for connect function, should be Custom Provider instead of Social Login Provider Authentication in Core Kit Node SDK | Documentation | Web3Auth. I will link an example here

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.