@toruslabs/torus.js
Advanced tools
Comparing version 10.0.5 to 11.0.0
@@ -9,3 +9,1 @@ /*! | ||
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ |
{ | ||
"name": "@toruslabs/torus.js", | ||
"version": "10.0.5", | ||
"version": "11.0.0", | ||
"description": "Handle communication with torus nodes", | ||
@@ -27,8 +27,8 @@ "main": "dist/torusUtils.cjs.js", | ||
"dependencies": { | ||
"@toruslabs/constants": "^11.0.0", | ||
"@toruslabs/eccrypto": "^3.0.0", | ||
"@toruslabs/http-helpers": "^4.0.0", | ||
"@toruslabs/constants": "^13.0.0", | ||
"@toruslabs/eccrypto": "^4.0.0", | ||
"@toruslabs/http-helpers": "^5.0.0", | ||
"bn.js": "^5.2.1", | ||
"elliptic": "^6.5.4", | ||
"ethereum-cryptography": "^2.0.0", | ||
"ethereum-cryptography": "^2.1.2", | ||
"json-stable-stringify": "^1.0.2", | ||
@@ -39,6 +39,7 @@ "loglevel": "^1.8.1" | ||
"@babel/register": "^7.22.5", | ||
"@babel/runtime": "^7.22.6", | ||
"@toruslabs/eslint-config-typescript": "^2.0.0", | ||
"@toruslabs/fetch-node-details": "^11.0.1", | ||
"@toruslabs/torus-scripts": "^4.0.0", | ||
"@babel/runtime": "^7.22.10", | ||
"@toruslabs/config": "^2.0.1", | ||
"@toruslabs/eslint-config-typescript": "^3.0.0", | ||
"@toruslabs/fetch-node-details": "^13.0.0", | ||
"@toruslabs/torus-scripts": "^5.0.2", | ||
"@types/chai": "^4.3.5", | ||
@@ -48,28 +49,17 @@ "@types/elliptic": "^6.4.14", | ||
"@types/json-stable-stringify": "^1.0.34", | ||
"@types/jsonwebtoken": "^9.0.2", | ||
"@types/mocha": "^10.0.1", | ||
"@typescript-eslint/eslint-plugin": "^5.61.0", | ||
"@typescript-eslint/parser": "^5.61.0", | ||
"chai": "^4.3.7", | ||
"cross-env": "^7.0.3", | ||
"dotenv": "^16.3.1", | ||
"eslint": "^8.44.0", | ||
"eslint-plugin-chai-expect": "^3.0.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-mocha": "^10.1.0", | ||
"eslint-plugin-n": "^15.7.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"eslint-plugin-simple-import-sort": "^10.0.0", | ||
"eslint-plugin-tsdoc": "^0.2.17", | ||
"eslint": "^8.46.0", | ||
"faker": "^5.5.3", | ||
"husky": "^8.0.3", | ||
"jsonwebtoken": "^9.0.0", | ||
"jsonwebtoken": "^9.0.1", | ||
"lint-staged": "^13.2.3", | ||
"mocha": "^10.2.0", | ||
"node-fetch": "^3.3.1", | ||
"prettier": "^2.8.8", | ||
"prettier": "^3.0.1", | ||
"rimraf": "^5.0.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.5", | ||
"webpack-node-externals": "^3.0.0" | ||
"typescript": "^5.1.6" | ||
}, | ||
@@ -106,5 +96,5 @@ "repository": { | ||
"engines": { | ||
"node": ">=16.18.1", | ||
"npm": ">=8.x" | ||
"node": ">=18.x", | ||
"npm": ">=9.x" | ||
} | ||
} |
@@ -36,3 +36,2 @@ # Torus.js | ||
- `umd` build `dist/torusUtils.umd.min.js` in es5 format without polyfilling corejs minified | ||
- `nodejs` build `dist/torusUtils-node.js` in es5 format | ||
@@ -39,0 +38,0 @@ By default, the appropriate format is used for your specified usecase |
@@ -1,2 +0,2 @@ | ||
import { LEGACY_NETWORKS_ROUTE_MAP, TORUS_NETWORK_TYPE } from "@toruslabs/constants"; | ||
import { LEGACY_NETWORKS_ROUTE_MAP, TORUS_LEGACY_NETWORK_TYPE, TORUS_NETWORK_TYPE } from "@toruslabs/constants"; | ||
import { generatePrivate, getPublic } from "@toruslabs/eccrypto"; | ||
@@ -87,3 +87,3 @@ import { generateJsonRPCObject, get, post } from "@toruslabs/http-helpers"; | ||
// nonceResult must exist except for extendedVerifierId and legacy networks along with keyResult | ||
if ((keyResult && (nonceResult || extendedVerifierId || LEGACY_NETWORKS_ROUTE_MAP[network])) || errorResult) { | ||
if ((keyResult && (nonceResult || extendedVerifierId || LEGACY_NETWORKS_ROUTE_MAP[network as TORUS_LEGACY_NETWORK_TYPE])) || errorResult) { | ||
if (keyResult) { | ||
@@ -212,3 +212,3 @@ lookupResults.forEach((x1) => { | ||
} else if (importedShares.length === 0 && completedRequests.length >= ~~((endpoints.length * 3) / 4) + 1) { | ||
const requiredNodeResult = completedRequests.find((resp: JRPCResponse<CommitmentRequestResult>) => { | ||
const requiredNodeResult = completedRequests.find((resp: void | JRPCResponse<CommitmentRequestResult>) => { | ||
if (resp && resp.result?.nodeindex === "1") { | ||
@@ -337,3 +337,3 @@ return true; | ||
// then we need to throw other wise address would be incorrect. | ||
if (!thresholdNonceData && !verifierParams.extended_verifier_id && !LEGACY_NETWORKS_ROUTE_MAP[network]) { | ||
if (!thresholdNonceData && !verifierParams.extended_verifier_id && !LEGACY_NETWORKS_ROUTE_MAP[network as TORUS_LEGACY_NETWORK_TYPE]) { | ||
throw new Error( | ||
@@ -351,3 +351,3 @@ `invalid metadata result from nodes, nonce metadata is empty for verifier: ${verifier} and verifierId: ${verifierParams.verifier_id}` | ||
thresholdPublicKey && | ||
(thresholdNonceData || verifierParams.extended_verifier_id || LEGACY_NETWORKS_ROUTE_MAP[network]) | ||
(thresholdNonceData || verifierParams.extended_verifier_id || LEGACY_NETWORKS_ROUTE_MAP[network as TORUS_LEGACY_NETWORK_TYPE]) | ||
) { | ||
@@ -457,6 +457,9 @@ const sharePromises: Promise<void | Buffer>[] = []; | ||
const decryptedShares = sharesResolved.reduce((acc, curr, index) => { | ||
if (curr) acc.push({ index: nodeIndexes[index], value: new BN(curr) }); | ||
return acc; | ||
}, [] as { index: BN; value: BN }[]); | ||
const decryptedShares = sharesResolved.reduce( | ||
(acc, curr, index) => { | ||
if (curr) acc.push({ index: nodeIndexes[index], value: new BN(curr) }); | ||
return acc; | ||
}, | ||
[] as { index: BN; value: BN }[] | ||
); | ||
// run lagrange interpolation on all subsets, faster in the optimistic scenario than berlekamp-welch due to early exit | ||
@@ -468,3 +471,3 @@ const allCombis = kCombinations(decryptedShares.length, ~~(endpoints.length / 2) + 1); | ||
const currentCombi = allCombis[j]; | ||
const currentCombiShares = decryptedShares.filter((v, index) => currentCombi.includes(index)); | ||
const currentCombiShares = decryptedShares.filter((_, index) => currentCombi.includes(index)); | ||
const shares = currentCombiShares.map((x) => x.value); | ||
@@ -513,3 +516,3 @@ const indices = currentCombiShares.map((x) => x.index); | ||
finalPubKey = ecCurve.keyFromPublic({ x: oAuthPubkeyX, y: oAuthPubkeyY }).getPublic(); | ||
} else if (LEGACY_NETWORKS_ROUTE_MAP[network]) { | ||
} else if (LEGACY_NETWORKS_ROUTE_MAP[network as TORUS_LEGACY_NETWORK_TYPE]) { | ||
if (enableOneKey) { | ||
@@ -675,3 +678,4 @@ nonceResult = await getNonce(legacyMetadataHost, ecCurve, serverTimeOffset, oAuthPubkeyX, oAuthPubkeyY, oAuthKey); | ||
); | ||
} catch (error) { | ||
} catch (error2: unknown) { | ||
const error = error2 as { status: number; message: string }; | ||
log.error(error.status, error.message, error, "key assign error"); | ||
@@ -678,0 +682,0 @@ const acceptedErrorMsgs = [ |
@@ -83,3 +83,3 @@ import { INodePub, JRPCResponse, LEGACY_NETWORKS_ROUTE_MAP, SIGNER_MAP, TORUS_LEGACY_NETWORK_TYPE, TORUS_NETWORK_TYPE } from "@toruslabs/constants"; | ||
this.legacyMetadataHost = legacyMetadataHost; | ||
this.signerHost = `${SIGNER_MAP[network]}/api/sign`; | ||
this.signerHost = `${SIGNER_MAP[network as TORUS_LEGACY_NETWORK_TYPE]}/api/sign`; | ||
} | ||
@@ -411,6 +411,9 @@ | ||
const decryptedShares = sharesResolved.reduce((acc, curr, index) => { | ||
if (curr) acc.push({ index: nodeIndexes[index], value: new BN(curr) }); | ||
return acc; | ||
}, [] as { index: BN; value: BN }[]); | ||
const decryptedShares = sharesResolved.reduce( | ||
(acc, curr, index) => { | ||
if (curr) acc.push({ index: nodeIndexes[index], value: new BN(curr) }); | ||
return acc; | ||
}, | ||
[] as { index: BN; value: BN }[] | ||
); | ||
// run lagrange interpolation on all subsets, faster in the optimistic scenario than berlekamp-welch due to early exit | ||
@@ -421,3 +424,3 @@ const allCombis = kCombinations(decryptedShares.length, ~~(endpoints.length / 2) + 1); | ||
const currentCombi = allCombis[j]; | ||
const currentCombiShares = decryptedShares.filter((v, index) => currentCombi.includes(index)); | ||
const currentCombiShares = decryptedShares.filter((_, index) => currentCombi.includes(index)); | ||
const shares = currentCombiShares.map((x) => x.value); | ||
@@ -624,3 +627,3 @@ const indices = currentCombiShares.map((x) => x.index); | ||
// no need of nonce for extendedVerifierId (tss verifier id) | ||
if (!nonceResult && !extendedVerifierId && !LEGACY_NETWORKS_ROUTE_MAP[this.network]) { | ||
if (!nonceResult && !extendedVerifierId && !LEGACY_NETWORKS_ROUTE_MAP[this.network as TORUS_LEGACY_NETWORK_TYPE]) { | ||
throw new GetOrSetNonceError("metadata nonce is missing in share response"); | ||
@@ -637,3 +640,3 @@ } | ||
oAuthPubKey = finalPubKey; | ||
} else if (LEGACY_NETWORKS_ROUTE_MAP[this.network]) { | ||
} else if (LEGACY_NETWORKS_ROUTE_MAP[this.network as TORUS_LEGACY_NETWORK_TYPE]) { | ||
return this.formatLegacyPublicKeyData({ | ||
@@ -640,0 +643,0 @@ isNewKey: keyResult.is_new_key, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
25
1
1642406
44
7220
125
+ Added@toruslabs/constants@13.4.0(transitive)
+ Added@toruslabs/eccrypto@4.0.0(transitive)
+ Added@toruslabs/http-helpers@5.0.0(transitive)
- Removed@toruslabs/constants@11.0.0(transitive)
- Removed@toruslabs/eccrypto@3.0.0(transitive)
- Removed@toruslabs/http-helpers@4.0.0(transitive)
Updated@toruslabs/constants@^13.0.0
Updated@toruslabs/eccrypto@^4.0.0
Updatedethereum-cryptography@^2.1.2