Handling multiple users on server using SFA node.js

How can we manage multiple wallets/providers by generating key pairs on the server without disconnecting the existing provider? Our goal is to streamline the process and avoid building separate implementations for different platforms.

var token = jwt.sign(
  {
    sub: sub,
    name: 'Agrawal Alam Mishra Rawski Bherwani',
    email: 'devrel@web3auth.io',
    aud: 'urn:api-web3auth-io',
    iss: 'https://web3auth.io',
    iat: Math.floor(Date.now() / 1000),
    exp: Math.floor(Date.now() / 1000) + 60 * 60,
  },
  privateKey,
  { algorithm: 'RS256', keyid: '2ma4enu1kdvw5bo9xsfpi3gcjzrt6q78yl0h' },
);

const connect = async () => {
  const provider = await web3auth.connect({
    verifier: "w3a-node-demo", // replace with your verifier name
    verifierId: sub, // replace with your verifier id's value, for example, sub value of JWT Token, or email address.
    idToken: token, // replace with your newly created unused JWT Token.
  });
  const eth_private_key = await provider.request({ method: "eth_private_key" });
  console.log("ETH PrivateKey: ", eth_private_key);
};

Each time a new user connects, the provider is re-initialized. This provider object holds the context for the currently connected user. When a new user connects, the old user’s context is overwritten, which effectively disconnects the previous user’s wallet because the server is using a shared provider for all users.

Similarly, the JWT token is also re-generated for each new user connection. Since the JWT token is specific to the new login.

Hey @nethaji that’s the expected behaviour, although I’ll confirm with the team if there’s anything you can do to achieve your behaviour.

Hey @nethaji, this is not possible from Web3Auth SDK, as the SDK is designed in that way.

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