Skip to content

Commit

Permalink
remove default export
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Jul 15, 2024
1 parent ac68bd5 commit 35cb4ae
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 47 deletions.
25 changes: 5 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = "[email protected]";
Expand All @@ -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
Expand All @@ -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 = "[email protected]"; // 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`
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
6 changes: 3 additions & 3 deletions test/aqua.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 () {
Expand Down
6 changes: 3 additions & 3 deletions test/celeste.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 () {
Expand Down
6 changes: 3 additions & 3 deletions test/cyan.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 () {
Expand Down
6 changes: 3 additions & 3 deletions test/mainnet.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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,
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/onekey.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 = "[email protected]";
Expand Down
12 changes: 6 additions & 6 deletions test/sapphire_devnet.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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",
Expand All @@ -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",
});
Expand Down Expand Up @@ -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,
});

Expand Down Expand Up @@ -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",
});
Expand Down
6 changes: 3 additions & 3 deletions test/sapphire_mainnet.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -17,15 +17,15 @@ const TORUS_EXTENDED_VERIFIER_EMAIL = "[email protected]";

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({
network: TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET,
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 () {
Expand Down
6 changes: 3 additions & 3 deletions test/testnet.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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,
});
});
Expand Down

0 comments on commit 35cb4ae

Please sign in to comment.