diff --git a/README.md b/README.md index 9bc2e4c..6ae95cd 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ This library handles these checks and allows you to query the Torus network easi ### Bundling -This module is distributed in 4 formats +This module is distributed in 3 formats - `esm` build `dist/torusUtils.esm.js` in es6 format - `commonjs` build `dist/torusUtils.cjs.js` in es5 format @@ -67,10 +67,10 @@ Add [`@toruslabs/torus.js`](https://www.npmjs.com/package/@toruslabs/torus.js) t Needs to be used in conjuction with [`@toruslabs/fetch-node-details`](https://www.npmjs.com/package/@toruslabs/fetch-node-details) ```ts -import FetchNodeDetails from "@toruslabs/fetch-node-details"; +import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import TorusUtils from "@toruslabs/torus.js"; -const fetchNodeDetails = new FetchNodeDetails(); +const fetchNodeDetails = new NodeDetailManager(); const torus = new TorusUtils({ network: "mainnet", clientId: "YOUR_CLIENT_ID" }); // get your Client ID from Web3Auth Dashboard const verifier = "google"; const verifierId = "hello@tor.us"; @@ -82,8 +82,8 @@ const keyData = await torus.retrieveShares(torusNodeEndpoints, torusIndexes, ver ``` ```js -const FetchNodeDetails = require("@toruslabs/fetch-node-details").default; -const TorusUtils = require("@toruslabs/torus.js").default; +const { NodeDetailManager: FetchNodeDetails } = require("@toruslabs/fetch-node-details"); +const { Torus: TorusUtils } = require("@toruslabs/torus.js"); const fetchNodeDetails = new FetchNodeDetails(); const torus = new TorusUtils({ network: "mainnet", clientId: "YOUR_CLIENT_ID" }); // get your Client ID from Web3Auth Dashboard @@ -103,21 +103,6 @@ fetchNodeDetails .then((keyData) => console.log(keyData)); ``` -```js -// For Node.js -const FetchNodeDetails = require("@toruslabs/fetch-node-details/dist/fetchNodeDetails-node.js").default; -const TorusUtils = require("@toruslabs/torus.js/dist/torusUtils-node.js").default; - -const fetchNodeDetails = new FetchNodeDetails(); -const torus = new TorusUtils({ network: "mainnet" }); -const verifier = "google"; // any verifier -const verifierId = "hello@tor.us"; // any verifier id -fetchNodeDetails - .getNodeDetails() - .then(({ torusNodeEndpoints, torusNodePub }) => torus.getPublicAddress(torusNodeEndpoints, torusNodePub, { verifier, verifierId })) - .then((publicAddress) => console.log(publicAddress)); -``` - ## Requirements - This package requires a peer dependency of `@babel/runtime` diff --git a/src/index.ts b/src/index.ts index 0ff87f0..a7e6297 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,4 +4,4 @@ export * from "./interfaces"; export { default as Point } from "./Point"; export { default as Polynomial } from "./Polynomial"; export { default as Share } from "./Share"; -export { default } from "./torus"; +export { default as Torus } from "./torus"; diff --git a/test/aqua.test.ts b/test/aqua.test.ts index 4fa4fde..d8f8ba3 100644 --- a/test/aqua.test.ts +++ b/test/aqua.test.ts @@ -1,5 +1,5 @@ import { TORUS_LEGACY_NETWORK } from "@toruslabs/constants"; -import NodeManager from "@toruslabs/fetch-node-details"; +import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import BN from "bn.js"; import { expect } from "chai"; import faker from "faker"; @@ -14,14 +14,14 @@ const TORUS_TEST_AGGREGATE_VERIFIER = "torus-test-health-aggregate"; describe("torus utils aqua", function () { let torus: TorusUtils; - let TORUS_NODE_MANAGER: NodeManager; + let TORUS_NODE_MANAGER: NodeDetailManager; beforeEach("one time execution before all tests", async function () { torus = new TorusUtils({ network: "aqua", clientId: "YOUR_CLIENT_ID", }); - TORUS_NODE_MANAGER = new NodeManager({ network: TORUS_LEGACY_NETWORK.AQUA }); + TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_LEGACY_NETWORK.AQUA }); }); it("should fetch public address", async function () { diff --git a/test/celeste.test.ts b/test/celeste.test.ts index 7623295..476b46b 100644 --- a/test/celeste.test.ts +++ b/test/celeste.test.ts @@ -1,5 +1,5 @@ import { TORUS_LEGACY_NETWORK } from "@toruslabs/constants"; -import NodeManager from "@toruslabs/fetch-node-details"; +import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import BN from "bn.js"; import { expect } from "chai"; import faker from "faker"; @@ -14,14 +14,14 @@ const TORUS_TEST_AGGREGATE_VERIFIER = "torus-test-health-aggregate"; describe("torus utils celeste", function () { let torus: TorusUtils; - let TORUS_NODE_MANAGER: NodeManager; + let TORUS_NODE_MANAGER: NodeDetailManager; beforeEach("one time execution before all tests", async function () { torus = new TorusUtils({ network: "celeste", clientId: "YOUR_CLIENT_ID", }); - TORUS_NODE_MANAGER = new NodeManager({ network: TORUS_LEGACY_NETWORK.CELESTE }); + TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_LEGACY_NETWORK.CELESTE }); }); it("should fetch public address", async function () { diff --git a/test/cyan.test.ts b/test/cyan.test.ts index f0c4792..eac782b 100644 --- a/test/cyan.test.ts +++ b/test/cyan.test.ts @@ -1,5 +1,5 @@ import { TORUS_LEGACY_NETWORK } from "@toruslabs/constants"; -import NodeManager from "@toruslabs/fetch-node-details"; +import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import BN from "bn.js"; import { expect } from "chai"; import faker from "faker"; @@ -14,14 +14,14 @@ const TORUS_TEST_AGGREGATE_VERIFIER = "torus-test-health-aggregate"; describe("torus utils cyan", function () { let torus: TorusUtils; - let TORUS_NODE_MANAGER: NodeManager; + let TORUS_NODE_MANAGER: NodeDetailManager; beforeEach("one time execution before all tests", async function () { torus = new TorusUtils({ network: "cyan", clientId: "YOUR_CLIENT_ID", }); - TORUS_NODE_MANAGER = new NodeManager({ network: TORUS_LEGACY_NETWORK.CYAN }); + TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_LEGACY_NETWORK.CYAN }); }); it("should fetch public address", async function () { diff --git a/test/mainnet.test.ts b/test/mainnet.test.ts index 2ee12b2..a19aef6 100644 --- a/test/mainnet.test.ts +++ b/test/mainnet.test.ts @@ -1,5 +1,5 @@ import { TORUS_LEGACY_NETWORK } from "@toruslabs/constants"; -import NodeManager from "@toruslabs/fetch-node-details"; +import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import BN from "bn.js"; import { expect } from "chai"; import faker from "faker"; @@ -14,12 +14,12 @@ const TORUS_TEST_AGGREGATE_VERIFIER = "torus-test-health-aggregate"; describe("torus utils mainnet", function () { let torus: TorusUtils; - let TORUS_NODE_MANAGER: NodeManager; + let TORUS_NODE_MANAGER: NodeDetailManager; beforeEach("one time execution before all tests", async function () { // TorusUtils.enableLogging(true); torus = new TorusUtils({ network: "mainnet", clientId: "YOUR_CLIENT_ID" }); - TORUS_NODE_MANAGER = new NodeManager({ + TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_LEGACY_NETWORK.MAINNET, }); }); diff --git a/test/onekey.test.ts b/test/onekey.test.ts index 3d91039..8940bfb 100644 --- a/test/onekey.test.ts +++ b/test/onekey.test.ts @@ -1,5 +1,5 @@ import { TORUS_LEGACY_NETWORK } from "@toruslabs/constants"; -import FetchNodeDetails from "@toruslabs/fetch-node-details"; +import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import BN from "bn.js"; import { expect } from "chai"; import faker from "faker"; @@ -8,7 +8,7 @@ import { keccak256, TorusPublicKey } from "../src"; import TorusUtils from "../src/torus"; import { generateIdToken } from "./helpers"; -const TORUS_NODE_MANAGER = new FetchNodeDetails({ +const TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_LEGACY_NETWORK.TESTNET, }); const TORUS_TEST_EMAIL = "hello@tor.us"; diff --git a/test/sapphire_devnet.test.ts b/test/sapphire_devnet.test.ts index a2605b5..bad0b9e 100644 --- a/test/sapphire_devnet.test.ts +++ b/test/sapphire_devnet.test.ts @@ -1,6 +1,6 @@ import { TORUS_LEGACY_NETWORK, TORUS_SAPPHIRE_NETWORK } from "@toruslabs/constants"; import { generatePrivate } from "@toruslabs/eccrypto"; -import NodeManager from "@toruslabs/fetch-node-details"; +import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import BN from "bn.js"; import { expect } from "chai"; import faker from "faker"; @@ -23,10 +23,10 @@ const HashEnabledVerifier = "torus-test-verifierid-hash"; describe("torus utils sapphire devnet", function () { let torus: TorusUtils; - let TORUS_NODE_MANAGER: NodeManager; + let TORUS_NODE_MANAGER: NodeDetailManager; beforeEach("one time execution before all tests", async function () { - TORUS_NODE_MANAGER = new NodeManager({ network: TORUS_SAPPHIRE_NETWORK.SAPPHIRE_DEVNET }); + TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_SAPPHIRE_NETWORK.SAPPHIRE_DEVNET }); torus = new TorusUtils({ network: TORUS_SAPPHIRE_NETWORK.SAPPHIRE_DEVNET, clientId: "YOUR_CLIENT_ID", @@ -37,7 +37,7 @@ describe("torus utils sapphire devnet", function () { it("should fetch public address of a legacy v1 user", async function () { const verifier = "google-lrc"; // any verifier - const LEGACY_TORUS_NODE_MANAGER = new NodeManager({ + const LEGACY_TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_LEGACY_NETWORK.TESTNET, // fndServerEndpoint: "http://localhost:8060/node-details", }); @@ -79,7 +79,7 @@ describe("torus utils sapphire devnet", function () { const verifier = "google-lrc"; const token = generateIdToken(email, "ES256"); - const LEGACY_TORUS_NODE_MANAGER = new NodeManager({ + const LEGACY_TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_LEGACY_NETWORK.TESTNET, }); @@ -124,7 +124,7 @@ describe("torus utils sapphire devnet", function () { }); it("should fetch user type and public address of legacy v2 user", async function () { - const LEGACY_TORUS_NODE_MANAGER = new NodeManager({ + const LEGACY_TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_LEGACY_NETWORK.TESTNET, // fndServerEndpoint: "http://localhost:8060/node-details", }); diff --git a/test/sapphire_mainnet.test.ts b/test/sapphire_mainnet.test.ts index 559011b..1bc0340 100644 --- a/test/sapphire_mainnet.test.ts +++ b/test/sapphire_mainnet.test.ts @@ -1,6 +1,6 @@ import { TORUS_SAPPHIRE_NETWORK } from "@toruslabs/constants"; import { generatePrivate } from "@toruslabs/eccrypto"; -import NodeManager from "@toruslabs/fetch-node-details"; +import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import BN from "bn.js"; import { expect } from "chai"; import faker from "faker"; @@ -17,7 +17,7 @@ const TORUS_EXTENDED_VERIFIER_EMAIL = "testextenderverifierid@example.com"; describe("torus utils sapphire mainnet", function () { let torus: TorusUtils; - let TORUS_NODE_MANAGER: NodeManager; + let TORUS_NODE_MANAGER: NodeDetailManager; beforeEach("one time execution before all tests", async function () { torus = new TorusUtils({ @@ -25,7 +25,7 @@ describe("torus utils sapphire mainnet", function () { clientId: "YOUR_CLIENT_ID", enableOneKey: true, }); - TORUS_NODE_MANAGER = new NodeManager({ network: TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET }); + TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET }); }); it("should fetch public address", async function () { diff --git a/test/testnet.test.ts b/test/testnet.test.ts index 60f183c..b8637a7 100644 --- a/test/testnet.test.ts +++ b/test/testnet.test.ts @@ -1,5 +1,5 @@ import { TORUS_LEGACY_NETWORK } from "@toruslabs/constants"; -import NodeManager from "@toruslabs/fetch-node-details"; +import { NodeDetailManager } from "@toruslabs/fetch-node-details"; import { fail } from "assert"; import BN from "bn.js"; import { expect } from "chai"; @@ -16,11 +16,11 @@ const TORUS_TEST_AGGREGATE_VERIFIER = "torus-test-health-aggregate"; describe("torus utils migrated testnet on sapphire", function () { let torus: TorusUtils; - let TORUS_NODE_MANAGER: NodeManager; + let TORUS_NODE_MANAGER: NodeDetailManager; beforeEach("one time execution before all tests", async function () { torus = new TorusUtils({ network: "testnet", clientId: "YOUR_CLIENT_ID" }); - TORUS_NODE_MANAGER = new NodeManager({ + TORUS_NODE_MANAGER = new NodeDetailManager({ network: TORUS_LEGACY_NETWORK.TESTNET, }); });