Failed to connect to Web3Auth using node-sdk on Firebase cloud functions

I try to use the @web3auth/node-sdk@1.0.1 to connect to Web3Auth with Firebase, but there's some errors.

{"severity":"ERROR","message":"Unhandled error Error: Error occurred while verifying paramscould not verify identity A7m6knG8vwY4besTiMPigSTn7Ew2 sub\n at /Users/user/Workspace/wegoing/creatorc-functions/functions/node_modules/@toruslabs/torus.js/dist/torusUtils-node.js:491:20\n at \n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}


Here is the sample code in the client web,

const idToken = await firebase.auth.currentUser?.getIdTokenResult(true);
const signinWallet = httpsCallable(functions, "signinWallet");
const result = await signinWallet({
  idToken: idToken?.token
})

and the code on cloud functions,

const web3auth = new Web3Auth({
    clientId: clientId,
    chainConfig: {
      chainNamespace: "eip155",
      chainId: "0x5",
      rpcTarget: "https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
    },
    web3AuthNetwork: "testnet",
  });
  await web3auth.init();
  const provider = await web3auth.connect({
    verifier: "firebase-verifier",
    verifierId: "sub",
    idToken: idToken,
  });

I also confirmed the idToken contains sub, aud, iat, iss field, etc.

Any idea why this error happened?



Originally posted by: wegoinggroup

Check the discussion at: https://github.com/orgs/Web3Auth/discussions/1361

Finally notice the post Web3Auth's Node.js SDK contained the solution.
The sub should be parsed from the idToken and filled into the verifierId field for the web3auth.connect function.



Originally posted by: wegoinggroup