@web3auth/node-sdk and @web3auth/ethereum-provider not compatible

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?

Demo repo found here: GitHub - Craigson/web3auth-error: Web3auth node-sdk troubleshooting

Docs are out of date: https://web3auth.io/docs/sdk/core-kit/sfa-node/usage

@accounts Welcome Aboard!

Your issue is under review and we will get back with further updates

Hey @accounts,
Do you face any error by importing everything and destructuring and using as you may see fit? Example:

import * as Web3Auth from "@web3auth/ethereum-provider";
const { EthereumPrivateKeyProvider } = Web3Auth;

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,
Please share with me the initialization snippet and the config you’re sending

The source code is in the original post, but its literally the example from the docs: GitHub - Craigson/web3auth-error: Web3auth node-sdk troubleshooting

The post referencing the url error is here: Error: Sorry, the Torus Network that powers Web3Auth is currently very busy. Only absolute URLs are supported

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.

I am facing the exact same issue @maharshi , can you please help me out as well?

Facing same issue, did anyone manage to resolve this?

Hey @dvogel1,

Could you please share the version of the Node SDK that you are using?

    "@web3auth/base": "^8.8.0",
    "@web3auth/ethereum-provider": "^8.10.2",
    "@web3auth/node-sdk": "^3.3.0",

Btw, this is my current workaround:

import { CHAIN_NAMESPACES } from "@web3auth/base";
import { Wallet, ethers } from "ethers";
import { createRequire } from "module";

const require = createRequire(import.meta.url);
const { EthereumPrivateKeyProvider } = require("@web3auth/ethereum-provider");
const { Web3Auth } = require("@web3auth/node-sdk");

Without this I get that errors both EthereumPrivateKeyProvider and Web3Auth are not constructors, or bigNumber.js fails