Can i use Web3Auth on the server side for ex: NodeJS? #315
metallicalfa2
announced in
Help
Replies: 1 comment
-
You can use the below code to get clientID on the server side: global.fetch = require("node-fetch");
global.atob = require("atob");
// Please install node-fetch@2
const FetchNodeDetails = require("@toruslabs/fetch-node-details/dist/fetchNodeDetails-node").default;
const TorusUtils = require("@toruslabs/torus.js/dist/torusUtils-node").default;
const fetchNodeDetails = new FetchNodeDetails({ network: "ropsten", proxyAddress: "0x6258c9d6c12ed3edda59a1a6527e469517744aa7" });
const torusUtils = new TorusUtils({ enableOneKey: true, network: "testnet" });
async function getTorusPublicAddress(verifier, verifierId) {
const { torusNodeEndpoints, torusNodePub } = await fetchNodeDetails.getNodeDetails({ verifier, verifierId });
const publicAddress = await torusUtils.getPublicAddress(torusNodeEndpoints, torusNodePub, { verifier, verifierId });
return publicAddress;
}
async function getTorusKey(verifier, verifierId, idToken) {
const { torusNodeEndpoints, torusIndexes } = await fetchNodeDetails.getNodeDetails({ verifier, verifierId });
const { ethAddress, privKey } = await torusUtils.retrieveShares(torusNodeEndpoints, torusIndexes, verifier, { verifier_id: verifierId }, idToken);
return { ethAddress, privKey };
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to get the private key for my client ID on the server side, how can i do this ?
Beta Was this translation helpful? Give feedback.
All reactions