When upgrading to the new SFA SDK, I am facing the following error. Any idea what it could mean?
fetchNodeDetails.esm.js:65 Uncaught (in promise) Error: Failed to fetch node details
at T.getNodeDetails (fetchNodeDetails.esm.js:65:31)
at async Lr.connect (Web3Auth.ts:219:47)
at async loginWeb3Auth ((index):240:13)
at async HTMLInputElement.action_1 ((index):647:29)
const chainConfig = {
chainId: chainIdInHex,
chainNamespace: Base.CHAIN_NAMESPACES.OTHER,
rpcTarget: rpc
}
const web3auth = new SingleFactorAuth.Web3Auth({
clientId: WEB3AUTH_CLIENT_ID,
web3AuthNetwork: "legacy_testnet",
chainConfig
// usePnPKey: "false",
});
const privateKeyProvider = new BaseProvider.CommonPrivateKeyProvider({config: {chainConfig}});
web3auth.init(privateKeyProvider);
const parsedJWT = await JSON.parse(atob(jwt.split('.')[1]));
console.log("JWT parsed:", parsedJWT);
await web3auth.connect({
verifier: WEB3AUTH_VERIFIER_NAME, // e.g. `web3auth-sfa-verifier` replace with your verifier name, and it has to be on the same network passed in init().
verifierId: parsedJWT.sub, // e.g. `Yux1873xnibdui` or `name@email.com` replace with your verifier id(sub or email)'s value.
idToken: jwt, // replace with your newly created unused JWT Token.
});
const privateKey = await provider.request({method: "private_key"});
I am getting the following error after the above suggested change:
torusUtils.esm.js:510 Uncaught (in promise) Error: Error occurred while verifying params could not validate field iss, token https://stg-acme.us.auth0.com/, expected https://stg-acme.us.auth0.com/
at torusUtils.esm.js:510:20
at <anonymous>
chainConfig = {
chainId: "0x" + parseInt(chainId).toString(16),
chainNamespace: Base.CHAIN_NAMESPACES.OTHER,
rpcTarget: rpc
}
web3auth = new SingleFactorAuth.Web3Auth({
clientId: "<%= WEB3AUTH_CLIENT_ID %>",
web3AuthNetwork: "testnet",
chainConfig
});
privateKeyProvider = new BaseProvider.CommonPrivateKeyProvider({config: {chainConfig}});
web3auth.init(privateKeyProvider);
web3auth.ready=true
console.log("wallet instantiated:", web3auth.ready);
const parsedJWT = await JSON.parse(atob(jwt.split('.')[1]));
console.log("JWT parsed:", parsedJWT);
provider = await web3auth.connect({
verifier: "<%= WEB3AUTH_VERIFIER_NAME %>", // e.g. `web3auth-sfa-verifier` replace with your verifier name, and it has to be on the same network passed in init().
verifierId: parsedJWT.sub, // e.g. `Yux1873xnibdui` or `name@email.com` replace with your verifier id(sub or email)'s value.
idToken: jwt, // replace with your newly created unused JWT Token.
});
const privateKey = await provider.request({method: "private_key"});
Note that I had to manually indicate that the wallet is instantiated using web3auth.ready=true otherwise it errored saying that the wallet is not instantiated yet.
I’d request to kindly read through our examples of SFA, which have clearly mentioned the whole process of integration.
As I see from your code, please do not manually set web3auth.ready to true since that variable is meant to indicate you the status of the SDK initialisation. If you manually set that, it will definitely error out.
Just add an await before web3auth.init(privateKeyProvider) function. It is meant to be called in your constructor.