The latest node-sdk is not usable with @web3auth/ethereum-provider.
ethereum-provider is a CommonJS module, so cannot be used with import syntax in NodeJS. The @web3auth/node-sdk cannot be used as a commonJS module. The two are not compatible.
How is one supposed to use the node-sdk with the ethereum provider with NodeJS?
In the example you provided, Web3Auth is not exported by the ethereum-provider package. Either way, using:
import Web3Auth from "@web3auth/node-sdk";
import * as Provider from "@web3auth/ethereum-provider";
const { EthereumPrivateKeyProvider } = Provider;
import jwt from "jsonwebtoken";
import fs from "fs";
Causes the following error:
/Users/dev/web3auth-error/node_modules/@web3auth/node-sdk/dist/index.js:1
export * from "./interface";
^^^^^^
SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1178:20)
at Module._compile (node:internal/modules/cjs/loader:1220:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Node.js v18.17.0
Using older versions of the packages, I’m able to at least run the script (thought I would like to solve the issue with the latest versions, mentioned above, but the error returned is:
/Users/dev/web3auth-backend/demo/node-app/node_modules/@toruslabs/torus.js/dist/torusUtils-node.js:621
throw new Error(`Sorry, the Torus Network that powers Web3Auth is currently very busy.
^
Error: Sorry, the Torus Network that powers Web3Auth is currently very busy.
We will generate your key in time. Pls try again later.
Only absolute URLs are supported
This is not a helpful error message. What is Only absolute URLs are supported referring to?
Hey @accounts, I understand that this is causing inconvenience to you and your users. Why don’t you hop on to our next community call and get this addressed by our engineers. Register here.