diff --git a/packages/fetch-node-details/src/interfaces.ts b/packages/fetch-node-details/src/interfaces.ts index 2fe56df..4930db2 100644 --- a/packages/fetch-node-details/src/interfaces.ts +++ b/packages/fetch-node-details/src/interfaces.ts @@ -1,8 +1,9 @@ -import { TORUS_NETWORK_TYPE, WEB3AUTH_KEY_TYPE } from "@toruslabs/constants"; +import { TORUS_NETWORK_TYPE, WEB3AUTH_KEY_TYPE, WEB3AUTH_SIG_TYPE } from "@toruslabs/constants"; export type NodeDetailManagerParams = { network?: TORUS_NETWORK_TYPE; keyType?: WEB3AUTH_KEY_TYPE; + sigType?: WEB3AUTH_SIG_TYPE; fndServerEndpoint?: string; enableLogging?: boolean; }; diff --git a/packages/fetch-node-details/src/nodeDetailManager.ts b/packages/fetch-node-details/src/nodeDetailManager.ts index 43496a0..880ee8a 100644 --- a/packages/fetch-node-details/src/nodeDetailManager.ts +++ b/packages/fetch-node-details/src/nodeDetailManager.ts @@ -5,11 +5,13 @@ import { KEY_TYPE, METADATA_MAP, MULTI_CLUSTER_NETWORKS, + SIG_TYPE, TORUS_LEGACY_NETWORK, TORUS_LEGACY_NETWORK_TYPE, TORUS_NETWORK_TYPE, TORUS_SAPPHIRE_NETWORK, WEB3AUTH_KEY_TYPE, + WEB3AUTH_SIG_TYPE, } from "@toruslabs/constants"; import { fetchLocalConfig } from "@toruslabs/fnd-base"; import { get } from "@toruslabs/http-helpers"; @@ -26,6 +28,8 @@ class NodeDetailManager { private _keyType: WEB3AUTH_KEY_TYPE; + private _sigType: WEB3AUTH_SIG_TYPE; + private _torusNodeEndpoints: string[] = []; private _torusNodeRSSEndpoints: string[] = []; @@ -45,6 +49,7 @@ class NodeDetailManager { constructor({ network = TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET, keyType = KEY_TYPE.SECP256K1, + sigType = SIG_TYPE.ECDSA_SECP256K1, fndServerEndpoint, enableLogging = false, }: NodeDetailManagerParams = {}) { @@ -53,6 +58,7 @@ class NodeDetailManager { } this.network = network; this._keyType = keyType; + this._sigType = sigType; this.updated = false; if (fndServerEndpoint) { this.fndServerEndpoint = fndServerEndpoint; @@ -83,7 +89,7 @@ class NodeDetailManager { try { const { nodeDetails } = await get<{ nodeDetails: INodeDetails }>( - `${this.fndServerEndpoint}?network=${this.network}&verifier=${verifier}&verifierId=${verifierId}&keyType=${this._keyType}` + `${this.fndServerEndpoint}?network=${this.network}&verifier=${verifier}&verifierId=${verifierId}&keyType=${this._keyType}&sigType=${this._sigType}` ); this.setNodeDetails(nodeDetails); @@ -92,7 +98,7 @@ class NodeDetailManager { log.error("Failed to fetch node details from server, using local.", error); } - const nodeDetails = fetchLocalConfig(this.network as TORUS_NETWORK_TYPE, this._keyType); + const nodeDetails = fetchLocalConfig(this.network as TORUS_NETWORK_TYPE, this._keyType, this._sigType); if (!nodeDetails) throw new Error("Failed to fetch node details"); this.setNodeDetails(nodeDetails); return this._nodeDetails; diff --git a/packages/fnd-server/src/router.ts b/packages/fnd-server/src/router.ts index 9d72a33..b1947ef 100644 --- a/packages/fnd-server/src/router.ts +++ b/packages/fnd-server/src/router.ts @@ -1,4 +1,12 @@ -import { KEY_TYPE, TORUS_LEGACY_NETWORK, TORUS_NETWORK_TYPE, TORUS_SAPPHIRE_NETWORK, WEB3AUTH_KEY_TYPE } from "@toruslabs/constants"; +import { + KEY_TYPE, + SIG_TYPE, + TORUS_LEGACY_NETWORK, + TORUS_NETWORK_TYPE, + TORUS_SAPPHIRE_NETWORK, + WEB3AUTH_KEY_TYPE, + WEB3AUTH_SIG_TYPE, +} from "@toruslabs/constants"; import { fetchLocalConfig } from "@toruslabs/fnd-base"; import { celebrate, Joi } from "celebrate"; import express, { Request, Response } from "express"; @@ -27,16 +35,19 @@ router.get( keyType: Joi.string() .optional() .allow(...Object.values(KEY_TYPE)), + sigType: Joi.string() + .optional() + .allow(...Object.values(SIG_TYPE)), }), }, { allowUnknown: true } ), async (req: Request, res: Response) => { try { - const { network, keyType = "secp256k1" } = req.query as Record; + const { network, keyType = KEY_TYPE.SECP256K1, sigType = SIG_TYPE.ECDSA_SECP256K1 } = req.query as Record; const finalNetwork = network.toLowerCase(); // use static details for sapphire mainnet and testnet - const nodeDetails = fetchLocalConfig(finalNetwork as TORUS_NETWORK_TYPE, keyType as WEB3AUTH_KEY_TYPE); + const nodeDetails = fetchLocalConfig(finalNetwork as TORUS_NETWORK_TYPE, keyType as WEB3AUTH_KEY_TYPE, sigType as WEB3AUTH_SIG_TYPE); return res.status(200).json({ nodeDetails,