Skip to content

Commit

Permalink
Removes fnd call
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1995 committed Oct 3, 2024
1 parent 6a34bed commit ac02476
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 52 deletions.
19 changes: 10 additions & 9 deletions examples/vue-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 2 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@toruslabs/broadcast-channel": "^11.0.0",
"@toruslabs/constants": "^14.0.0",
"@toruslabs/eccrypto": "^5.0.4",
"@toruslabs/fetch-node-details": "^14.0.1",
"@toruslabs/fnd-base": "^14.0.0",
"@toruslabs/http-helpers": "^7.0.0",
"@toruslabs/metadata-helpers": "^6.0.0",
"@toruslabs/session-manager": "^3.1.0",
Expand Down
31 changes: 8 additions & 23 deletions src/login.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TORUS_NETWORK_TYPE } from "@toruslabs/constants";
import { NodeDetailManager } from "@toruslabs/fetch-node-details";
import { keccak256, Torus, TorusKey } from "@toruslabs/torus.js";
import { fetchLocalConfig } from "@toruslabs/fnd-base";
import { keccak256, type KeyType, Torus, TorusKey } from "@toruslabs/torus.js";

import createHandler from "./handlers/HandlerFactory";
import {
Expand Down Expand Up @@ -41,12 +41,11 @@ class CustomAuth {
useDkg?: boolean;
web3AuthClientId: string;
web3AuthNetwork: TORUS_NETWORK_TYPE;
keyType: KeyType;
};

torus: Torus;

nodeDetailManager: NodeDetailManager;

storageHelper: StorageHelper;

sentryHandler: SentryHandler;
Expand Down Expand Up @@ -86,6 +85,7 @@ class CustomAuth {
useDkg,
web3AuthClientId,
web3AuthNetwork: network,
keyType,
};
const torus = new Torus({
network,
Expand All @@ -97,7 +97,6 @@ class CustomAuth {
});
Torus.setAPIKey(apiKey);
this.torus = torus;
this.nodeDetailManager = new NodeDetailManager({ network });
if (enableLogging) log.enableAll();
else log.disableAll();
this.storageHelper = new StorageHelper(storageServerUrl);
Expand Down Expand Up @@ -177,7 +176,6 @@ class CustomAuth {

const torusKey = await this.getTorusKey(
verifier,
userInfo.verifierId,
{ verifier_id: userInfo.verifierId },
loginParams.idToken || loginParams.accessToken,
userInfo.extraVerifierParams
Expand Down Expand Up @@ -262,28 +260,15 @@ class CustomAuth {
aggregateIdTokenSeeds.sort();
const aggregateIdToken = keccak256(Buffer.from(aggregateIdTokenSeeds.join(String.fromCharCode(29)), "utf8")).slice(2);
aggregateVerifierParams.verifier_id = aggregateVerifierId;
const torusKey = await this.getTorusKey(verifierIdentifier, aggregateVerifierId, aggregateVerifierParams, aggregateIdToken, extraVerifierParams);
const torusKey = await this.getTorusKey(verifierIdentifier, aggregateVerifierParams, aggregateIdToken, extraVerifierParams);
return {
...torusKey,
userInfo: userInfoArray.map((x, index) => ({ ...x, ...loginParamsArray[index] })),
};
}

async getTorusKey(
verifier: string,
verifierId: string,
verifierParams: { verifier_id: string },
idToken: string,
additionalParams?: ExtraParams
): Promise<TorusKey> {
const nodeDetails = await this.sentryHandler.startSpan(
{
name: SENTRY_TXNS.FETCH_NODE_DETAILS,
},
async () => {
return this.nodeDetailManager.getNodeDetails({ verifier, verifierId });
}
);
async getTorusKey(verifier: string, verifierParams: { verifier_id: string }, idToken: string, additionalParams?: ExtraParams): Promise<TorusKey> {
const nodeDetails = fetchLocalConfig(this.config.web3AuthNetwork, this.config.keyType);

log.debug("torus-direct/getTorusKey", { torusNodeEndpoints: nodeDetails.torusNodeEndpoints });

Expand Down Expand Up @@ -329,7 +314,7 @@ class CustomAuth {
aggregateIdTokenSeeds.sort();
const aggregateIdToken = keccak256(Buffer.from(aggregateIdTokenSeeds.join(String.fromCharCode(29)), "utf8")).slice(2);
aggregateVerifierParams.verifier_id = verifierId;
return this.getTorusKey(verifier, verifierId, aggregateVerifierParams, aggregateIdToken, extraVerifierParams);
return this.getTorusKey(verifier, aggregateVerifierParams, aggregateIdToken, extraVerifierParams);
}

async getRedirectResult({ replaceUrl = true, clearLoginDetails = true }: RedirectResultParams = {}): Promise<RedirectResult> {
Expand Down

0 comments on commit ac02476

Please sign in to comment.