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.eyJpYXQiOjE2OTcwNDE1NTQsImF1ZCI6IkJKY0t5YjRmQVB4eGNWT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