@toruslabs/torus.js
Advanced tools
Comparing version 7.2.0 to 8.0.0
@@ -453,2 +453,3 @@ /******/ (() => { // webpackBootstrap | ||
if (z) { | ||
var _error$data; | ||
const { | ||
@@ -458,3 +459,3 @@ id, | ||
} = z; | ||
if (error?.data?.length > 0) { | ||
if ((error === null || error === void 0 ? void 0 : (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.length) > 0) { | ||
if (error.data.startsWith("Error occurred while verifying params")) acc[id] = capitalizeFirstLetter(error.data);else acc[id] = error.data; | ||
@@ -470,6 +471,7 @@ } | ||
} else { | ||
var _predicateError; | ||
reject(new SomeError({ | ||
errors: errorArr, | ||
responses: resultArr, | ||
predicate: predicateError?.message || predicateError | ||
predicate: ((_predicateError = predicateError) === null || _predicateError === void 0 ? void 0 : _predicateError.message) || predicateError | ||
})); | ||
@@ -611,3 +613,3 @@ } | ||
if (error?.status === 502 || acceptedErrorMsgs.includes(error.message) || error.message && error.message.includes("reason: getaddrinfo EAI_AGAIN")) return keyAssign({ | ||
if ((error === null || error === void 0 ? void 0 : error.status) === 502 || (error === null || error === void 0 ? void 0 : error.status) === 401 || acceptedErrorMsgs.includes(error.message) || error.message && error.message.includes("reason: getaddrinfo EAI_AGAIN")) return keyAssign({ | ||
endpoints, | ||
@@ -745,3 +747,3 @@ torusNodePubs, | ||
const assignResult = await waitKeyLookup(endpoints, verifier, verifierId, 1000); | ||
finalKeyResult = assignResult?.keyResult; | ||
finalKeyResult = assignResult === null || assignResult === void 0 ? void 0 : assignResult.keyResult; | ||
isNewKey = true; | ||
@@ -758,2 +760,3 @@ } else if (keyResult) { | ||
if (finalKeyResult) { | ||
var _nonce, _nonceResult; | ||
const { | ||
@@ -801,3 +804,3 @@ pub_key_X: X, | ||
typeOfUser, | ||
nonce: nonce?.toString(16), | ||
nonce: (_nonce = nonce) === null || _nonce === void 0 ? void 0 : _nonce.toString(16), | ||
pubNonce | ||
@@ -812,3 +815,3 @@ }); | ||
pubNonce, | ||
upgraded: nonceResult?.upgraded || undefined | ||
upgraded: ((_nonceResult = nonceResult) === null || _nonceResult === void 0 ? void 0 : _nonceResult.upgraded) || undefined | ||
}; | ||
@@ -961,4 +964,5 @@ } | ||
for (let i = 0; i < shareResponses.length; i += 1) { | ||
var _currentShareResponse, _currentShareResponse2; | ||
const currentShareResponse = shareResponses[i]; | ||
if (currentShareResponse?.result?.keys?.length > 0) { | ||
if ((currentShareResponse === null || currentShareResponse === void 0 ? void 0 : (_currentShareResponse = currentShareResponse.result) === null || _currentShareResponse === void 0 ? void 0 : (_currentShareResponse2 = _currentShareResponse.keys) === null || _currentShareResponse2 === void 0 ? void 0 : _currentShareResponse2.length) > 0) { | ||
currentShareResponse.result.keys.sort((a, b) => new (external_bn_js_default())(a.Index, 16).cmp(new (external_bn_js_default())(b.Index, 16))); | ||
@@ -1178,3 +1182,3 @@ const firstKey = currentShareResponse.result.keys[0]; | ||
const assignResult = await waitKeyLookup(endpoints, verifier, verifierId, 1000); | ||
finalKeyResult = assignResult?.keyResult; | ||
finalKeyResult = assignResult === null || assignResult === void 0 ? void 0 : assignResult.keyResult; | ||
isNewKey = true; | ||
@@ -1191,2 +1195,3 @@ } else if (keyResult) { | ||
if (finalKeyResult) { | ||
var _nonce2, _nonceResult2; | ||
let { | ||
@@ -1253,3 +1258,3 @@ pub_key_X: X, | ||
typeOfUser, | ||
nonce: nonce?.toString(16), | ||
nonce: (_nonce2 = nonce) === null || _nonce2 === void 0 ? void 0 : _nonce2.toString(16), | ||
pubNonce | ||
@@ -1265,3 +1270,3 @@ }); | ||
pubNonce, | ||
upgraded: nonceResult?.upgraded || undefined | ||
upgraded: ((_nonceResult2 = nonceResult) === null || _nonceResult2 === void 0 ? void 0 : _nonceResult2.upgraded) || undefined | ||
}; | ||
@@ -1268,0 +1273,0 @@ } |
@@ -143,2 +143,3 @@ /******/ (() => { // webpackBootstrap | ||
if (z) { | ||
var _error$data; | ||
const { | ||
@@ -148,3 +149,3 @@ id, | ||
} = z; | ||
if (error?.data?.length > 0) { | ||
if ((error === null || error === void 0 ? void 0 : (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.length) > 0) { | ||
if (error.data.startsWith("Error occurred while verifying params")) acc[id] = capitalizeFirstLetter(error.data);else acc[id] = error.data; | ||
@@ -160,6 +161,7 @@ } | ||
} else { | ||
var _predicateError; | ||
reject(new SomeError({ | ||
errors: errorArr, | ||
responses: resultArr, | ||
predicate: predicateError?.message || predicateError | ||
predicate: ((_predicateError = predicateError) === null || _predicateError === void 0 ? void 0 : _predicateError.message) || predicateError | ||
})); | ||
@@ -301,3 +303,3 @@ } | ||
if (error?.status === 502 || acceptedErrorMsgs.includes(error.message) || error.message && error.message.includes("reason: getaddrinfo EAI_AGAIN")) return keyAssign({ | ||
if ((error === null || error === void 0 ? void 0 : error.status) === 502 || (error === null || error === void 0 ? void 0 : error.status) === 401 || acceptedErrorMsgs.includes(error.message) || error.message && error.message.includes("reason: getaddrinfo EAI_AGAIN")) return keyAssign({ | ||
endpoints, | ||
@@ -435,3 +437,3 @@ torusNodePubs, | ||
const assignResult = await waitKeyLookup(endpoints, verifier, verifierId, 1000); | ||
finalKeyResult = assignResult?.keyResult; | ||
finalKeyResult = assignResult === null || assignResult === void 0 ? void 0 : assignResult.keyResult; | ||
isNewKey = true; | ||
@@ -448,2 +450,3 @@ } else if (keyResult) { | ||
if (finalKeyResult) { | ||
var _nonce, _nonceResult; | ||
const { | ||
@@ -491,3 +494,3 @@ pub_key_X: X, | ||
typeOfUser, | ||
nonce: nonce?.toString(16), | ||
nonce: (_nonce = nonce) === null || _nonce === void 0 ? void 0 : _nonce.toString(16), | ||
pubNonce | ||
@@ -502,3 +505,3 @@ }); | ||
pubNonce, | ||
upgraded: nonceResult?.upgraded || undefined | ||
upgraded: ((_nonceResult = nonceResult) === null || _nonceResult === void 0 ? void 0 : _nonceResult.upgraded) || undefined | ||
}; | ||
@@ -651,4 +654,5 @@ } | ||
for (let i = 0; i < shareResponses.length; i += 1) { | ||
var _currentShareResponse, _currentShareResponse2; | ||
const currentShareResponse = shareResponses[i]; | ||
if (currentShareResponse?.result?.keys?.length > 0) { | ||
if ((currentShareResponse === null || currentShareResponse === void 0 ? void 0 : (_currentShareResponse = currentShareResponse.result) === null || _currentShareResponse === void 0 ? void 0 : (_currentShareResponse2 = _currentShareResponse.keys) === null || _currentShareResponse2 === void 0 ? void 0 : _currentShareResponse2.length) > 0) { | ||
currentShareResponse.result.keys.sort((a, b) => new (external_bn_js_default())(a.Index, 16).cmp(new (external_bn_js_default())(b.Index, 16))); | ||
@@ -868,3 +872,3 @@ const firstKey = currentShareResponse.result.keys[0]; | ||
const assignResult = await waitKeyLookup(endpoints, verifier, verifierId, 1000); | ||
finalKeyResult = assignResult?.keyResult; | ||
finalKeyResult = assignResult === null || assignResult === void 0 ? void 0 : assignResult.keyResult; | ||
isNewKey = true; | ||
@@ -881,2 +885,3 @@ } else if (keyResult) { | ||
if (finalKeyResult) { | ||
var _nonce2, _nonceResult2; | ||
let { | ||
@@ -943,3 +948,3 @@ pub_key_X: X, | ||
typeOfUser, | ||
nonce: nonce?.toString(16), | ||
nonce: (_nonce2 = nonce) === null || _nonce2 === void 0 ? void 0 : _nonce2.toString(16), | ||
pubNonce | ||
@@ -955,3 +960,3 @@ }); | ||
pubNonce, | ||
upgraded: nonceResult?.upgraded || undefined | ||
upgraded: ((_nonceResult2 = nonceResult) === null || _nonceResult2 === void 0 ? void 0 : _nonceResult2.upgraded) || undefined | ||
}; | ||
@@ -958,0 +963,0 @@ } |
@@ -64,2 +64,3 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
if (z) { | ||
var _error$data; | ||
const { | ||
@@ -69,3 +70,3 @@ id, | ||
} = z; | ||
if (error?.data?.length > 0) { | ||
if ((error === null || error === void 0 ? void 0 : (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.length) > 0) { | ||
if (error.data.startsWith("Error occurred while verifying params")) acc[id] = capitalizeFirstLetter(error.data);else acc[id] = error.data; | ||
@@ -81,6 +82,7 @@ } | ||
} else { | ||
var _predicateError; | ||
reject(new SomeError({ | ||
errors: errorArr, | ||
responses: resultArr, | ||
predicate: predicateError?.message || predicateError | ||
predicate: ((_predicateError = predicateError) === null || _predicateError === void 0 ? void 0 : _predicateError.message) || predicateError | ||
})); | ||
@@ -210,3 +212,3 @@ } | ||
if (error?.status === 502 || acceptedErrorMsgs.includes(error.message) || error.message && error.message.includes("reason: getaddrinfo EAI_AGAIN")) return keyAssign({ | ||
if ((error === null || error === void 0 ? void 0 : error.status) === 502 || (error === null || error === void 0 ? void 0 : error.status) === 401 || acceptedErrorMsgs.includes(error.message) || error.message && error.message.includes("reason: getaddrinfo EAI_AGAIN")) return keyAssign({ | ||
endpoints, | ||
@@ -332,3 +334,3 @@ torusNodePubs, | ||
const assignResult = await waitKeyLookup(endpoints, verifier, verifierId, 1000); | ||
finalKeyResult = assignResult?.keyResult; | ||
finalKeyResult = assignResult === null || assignResult === void 0 ? void 0 : assignResult.keyResult; | ||
isNewKey = true; | ||
@@ -345,2 +347,3 @@ } else if (keyResult) { | ||
if (finalKeyResult) { | ||
var _nonce, _nonceResult; | ||
const { | ||
@@ -388,3 +391,3 @@ pub_key_X: X, | ||
typeOfUser, | ||
nonce: nonce?.toString(16), | ||
nonce: (_nonce = nonce) === null || _nonce === void 0 ? void 0 : _nonce.toString(16), | ||
pubNonce | ||
@@ -399,3 +402,3 @@ }); | ||
pubNonce, | ||
upgraded: nonceResult?.upgraded || undefined | ||
upgraded: ((_nonceResult = nonceResult) === null || _nonceResult === void 0 ? void 0 : _nonceResult.upgraded) || undefined | ||
}; | ||
@@ -546,4 +549,5 @@ } | ||
for (let i = 0; i < shareResponses.length; i += 1) { | ||
var _currentShareResponse, _currentShareResponse2; | ||
const currentShareResponse = shareResponses[i]; | ||
if (currentShareResponse?.result?.keys?.length > 0) { | ||
if ((currentShareResponse === null || currentShareResponse === void 0 ? void 0 : (_currentShareResponse = currentShareResponse.result) === null || _currentShareResponse === void 0 ? void 0 : (_currentShareResponse2 = _currentShareResponse.keys) === null || _currentShareResponse2 === void 0 ? void 0 : _currentShareResponse2.length) > 0) { | ||
currentShareResponse.result.keys.sort((a, b) => new BN(a.Index, 16).cmp(new BN(b.Index, 16))); | ||
@@ -761,3 +765,3 @@ const firstKey = currentShareResponse.result.keys[0]; | ||
const assignResult = await waitKeyLookup(endpoints, verifier, verifierId, 1000); | ||
finalKeyResult = assignResult?.keyResult; | ||
finalKeyResult = assignResult === null || assignResult === void 0 ? void 0 : assignResult.keyResult; | ||
isNewKey = true; | ||
@@ -774,2 +778,3 @@ } else if (keyResult) { | ||
if (finalKeyResult) { | ||
var _nonce2, _nonceResult2; | ||
let { | ||
@@ -836,3 +841,3 @@ pub_key_X: X, | ||
typeOfUser, | ||
nonce: nonce?.toString(16), | ||
nonce: (_nonce2 = nonce) === null || _nonce2 === void 0 ? void 0 : _nonce2.toString(16), | ||
pubNonce | ||
@@ -848,3 +853,3 @@ }); | ||
pubNonce, | ||
upgraded: nonceResult?.upgraded || undefined | ||
upgraded: ((_nonceResult2 = nonceResult) === null || _nonceResult2 === void 0 ? void 0 : _nonceResult2.upgraded) || undefined | ||
}; | ||
@@ -851,0 +856,0 @@ } |
@@ -11,3 +11,1 @@ /*! | ||
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ | ||
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ |
{ | ||
"name": "@toruslabs/torus.js", | ||
"version": "7.2.0", | ||
"version": "8.0.0", | ||
"description": "Handle communication with torus nodes", | ||
@@ -27,5 +27,5 @@ "main": "dist/torusUtils.cjs.js", | ||
"dependencies": { | ||
"@toruslabs/constants": "^9.0.1", | ||
"@toruslabs/eccrypto": "^2.2.0", | ||
"@toruslabs/http-helpers": "^3.4.0", | ||
"@toruslabs/constants": "^10.0.0", | ||
"@toruslabs/eccrypto": "^3.0.0", | ||
"@toruslabs/http-helpers": "^4.0.0", | ||
"bn.js": "^5.2.1", | ||
@@ -40,5 +40,5 @@ "elliptic": "^6.5.4", | ||
"@babel/runtime": "^7.21.5", | ||
"@toruslabs/eslint-config-typescript": "^1.4.3", | ||
"@toruslabs/fetch-node-details": "^9.0.1", | ||
"@toruslabs/torus-scripts": "^3.0.8", | ||
"@toruslabs/eslint-config-typescript": "^2.0.0", | ||
"@toruslabs/fetch-node-details": "^10.0.0", | ||
"@toruslabs/torus-scripts": "^4.0.0", | ||
"@types/chai": "^4.3.5", | ||
@@ -106,5 +106,5 @@ "@types/elliptic": "^6.4.14", | ||
"engines": { | ||
"node": ">=14.17.0", | ||
"npm": ">=6.x" | ||
"node": ">=16.18.1", | ||
"npm": ">=8.x" | ||
} | ||
} |
@@ -31,7 +31,6 @@ # Torus.js | ||
This module is distributed in 5 formats | ||
This module is distributed in 4 formats | ||
- `esm` build `dist/torusUtils.esm.js` in es6 format | ||
- `commonjs` build `dist/torusUtils.cjs.js` in es5 format | ||
- `commonjs` build `dist/torusUtils-bundled.cjs.js` in es5 format with problematic packages bundled (benfits non-webpack users) | ||
- `umd` build `dist/torusUtils.umd.min.js` in es5 format without polyfilling corejs minified | ||
@@ -73,30 +72,30 @@ - `nodejs` build `dist/torusUtils-node.js` in es5 format | ||
```ts | ||
import FetchNodeDetails from '@toruslabs/fetch-node-details' | ||
import TorusUtils from '@toruslabs/torus.js' | ||
import FetchNodeDetails from "@toruslabs/fetch-node-details"; | ||
import TorusUtils from "@toruslabs/torus.js"; | ||
const fetchNodeDetails = new FetchNodeDetails() | ||
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' | ||
const { torusNodeEndpoints, torusNodePub, torusIndexes } = await fetchNodeDetails.getNodeDetails() | ||
const publicAddress = await torus.getPublicAddress(torusNodeEndpoints, torusNodePub, { verifier, verifierId }) | ||
const fetchNodeDetails = new FetchNodeDetails(); | ||
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"; | ||
const { torusNodeEndpoints, torusNodePub, torusIndexes } = await fetchNodeDetails.getNodeDetails(); | ||
const publicAddress = await torus.getPublicAddress(torusNodeEndpoints, torusNodePub, { verifier, verifierId }); | ||
const idToken = 'YOUR_ID_TOKEN' | ||
const keyData = await torus.retrieveShares(torusNodeEndpoints, torusIndexes, verifier, { verifier_id: verifierId }, idToken) | ||
const idToken = "YOUR_ID_TOKEN"; | ||
const keyData = await torus.retrieveShares(torusNodeEndpoints, torusIndexes, verifier, { verifier_id: verifierId }, idToken); | ||
``` | ||
```js | ||
const FetchNodeDetails = require('@toruslabs/fetch-node-details').default | ||
const TorusUtils = require('@toruslabs/torus.js').default | ||
const FetchNodeDetails = require("@toruslabs/fetch-node-details").default; | ||
const TorusUtils = require("@toruslabs/torus.js").default; | ||
const fetchNodeDetails = new FetchNodeDetails() | ||
const torus = new TorusUtils({ network: 'mainnet', clientId: 'YOUR_CLIENT_ID' }) // get your Client ID from Web3Auth Dashboard | ||
const verifier = 'google' // any verifier | ||
const verifierId = 'hello@tor.us' // any verifier id | ||
const fetchNodeDetails = new FetchNodeDetails(); | ||
const torus = new TorusUtils({ network: "mainnet", clientId: "YOUR_CLIENT_ID" }); // get your Client ID from Web3Auth Dashboard | ||
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)) | ||
.then((publicAddress) => console.log(publicAddress)); | ||
const idToken = 'YOUR_ID_TOKEN' | ||
const idToken = "YOUR_ID_TOKEN"; | ||
fetchNodeDetails | ||
@@ -107,3 +106,3 @@ .getNodeDetails() | ||
) | ||
.then((keyData) => console.log(keyData)) | ||
.then((keyData) => console.log(keyData)); | ||
``` | ||
@@ -113,13 +112,13 @@ | ||
// 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 = 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 | ||
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)) | ||
.then((publicAddress) => console.log(publicAddress)); | ||
``` | ||
@@ -130,2 +129,2 @@ | ||
- This package requires a peer dependency of `@babel/runtime` | ||
- Node 14+ | ||
- Node 16+ |
@@ -153,2 +153,3 @@ import { generateJsonRPCObject, post } from "@toruslabs/http-helpers"; | ||
error?.status === 502 || | ||
error?.status === 401 || | ||
acceptedErrorMsgs.includes(error.message) || | ||
@@ -155,0 +156,0 @@ (error.message && error.message.includes("reason: getaddrinfo EAI_AGAIN")) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
0
1364691
24
5089
126
+ Added@toruslabs/constants@10.0.0(transitive)
+ Added@toruslabs/eccrypto@3.0.0(transitive)
+ Added@toruslabs/http-helpers@4.0.0(transitive)
- Removed@toruslabs/constants@9.0.1(transitive)
- Removed@toruslabs/eccrypto@2.2.1(transitive)
- Removed@toruslabs/http-helpers@3.4.0(transitive)
Updated@toruslabs/constants@^10.0.0
Updated@toruslabs/eccrypto@^3.0.0