🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

@tkey/core

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tkey/core - npm Package Compare versions

Comparing version

to
16.0.0

@@ -42,4 +42,3 @@ 'use strict';

}
var AuthMetadata$1 = AuthMetadata;
module.exports = AuthMetadata$1;
module.exports = AuthMetadata;

@@ -16,5 +16,3 @@ 'use strict';

const ed25519SeedConst = "ed25519Seed";
// TODO: handle errors for get and set with retries
class ThresholdKey {

@@ -107,3 +105,2 @@ constructor(args) {

});
// this will computed during reconstructKey should we restore here?

@@ -113,3 +110,2 @@ if (privKey) tb.privKey = new BN(privKey, "hex");

tb.shares = shares;
// switch to deserialize local metadata transition based on Object.keys() of authMetadata, ShareStore's and, IMessageMetadata

@@ -150,3 +146,2 @@ const AuthMetadataKeys = Object.keys(JSON.parse(stringify(new authMetadata(new metadata(new commonTypes.Point("0", "0")), new BN("0", "hex")))));

// check if cloud metadata is updated before
tb.metadata = tempMetadata;

@@ -170,3 +165,2 @@ tb.lastFetchedCloudMetadata = tempCloud;

}
// if tempCloud exist, share must able to catchup to latest share

@@ -186,7 +180,5 @@ // as syncmetadata is called before

}
// initialize module as in initialize
tb.initializeModules();
}
// if metadata is undefined, it mean that the tkey instance is not initialized previously

@@ -246,3 +238,2 @@ return tb;

}
// no metadata set, assumes new user

@@ -271,3 +262,2 @@ // check for serviceprovider migratableKey for import key from service provider for new user

}
// return after created new tkey account ( skip other steps)

@@ -281,3 +271,2 @@ return this.getKeyDetails();

}
// We determine the latest metadata on the SDK and if there has been

@@ -302,3 +291,2 @@ // needed transitions to include

}
// lets check if the cloud metadata has been updated or not from previously if we are reinitializing

@@ -315,3 +303,2 @@ if (reinitializing && !reinitializingWithNewKeyAssign) {

}
// If we've been provided with transition metadata we use that as the current metadata instead

@@ -333,3 +320,2 @@ // as we want to maintain state before and after serialization.

}
// initialize modules

@@ -339,3 +325,2 @@ await this.initializeModules();

}
/**

@@ -402,3 +387,2 @@ * catchupToLatestShare recursively loops fetches metadata of the provided share and checks if there is an encrypted share for it.

const pubPolyID = pubPoly.getPolynomialID();
// check if we have enough shares to meet threshold

@@ -441,3 +425,2 @@ let sharesLeft = requiredThreshold;

}
// Input shares to ensure atomicity

@@ -477,3 +460,2 @@ sharesToInput.forEach(share => {

}
// ed25519key

@@ -524,3 +506,2 @@ if (this.getEd25519PublicKey()) {

}
// Get existing shares

@@ -537,3 +518,2 @@ const pubPoly = this.metadata.getLatestPublicPolynomial();

});
// Update shares

@@ -610,3 +590,2 @@ if (existingShareIndexes.length === newShareIndexes.length) {

if (!(Array.isArray(this._localMetadataTransitions[0]) && this._localMetadataTransitions[0].length > 0)) return;
// get lock

@@ -639,3 +618,2 @@ let acquiredLock = false;

}
// Returns a new instance of metadata with a clean state. All the previous state will be reset.

@@ -658,3 +636,2 @@ async updateSDK(params) {

}
// Delete unnecessary polyIDs and shareStores

@@ -670,3 +647,2 @@ const allPolyIDList = tb.metadata.polyIDList;

});
// catchup to latest shareStore for all latest available shares.

@@ -679,3 +655,2 @@ // TODO: fix edge cases where shares are deleted in the newer polynomials

}
// NOTE: This API will be DEPRECATED in the future in favour of inputShareStoreSafe()

@@ -696,3 +671,2 @@ inputShareStore(shareStore) {

}
// inputs a share ensuring that the share is the latest share AND metadata is updated to its latest state

@@ -797,5 +771,3 @@ async inputShareStoreSafe(shareStore, autoUpdateMetadata = false) {

}
// Auth functions
generateAuthMetadata(params) {

@@ -850,3 +822,2 @@ const {

}
// fetches the latest metadata potentially searching in local transition states first

@@ -881,3 +852,2 @@ async getGenericMetadataWithTransitionStates(params) {

}
// Lock functions

@@ -889,3 +859,2 @@ async acquireWriteMetadataLock() {

}
// we check the metadata of a random share we have on the latest polynomial we know that reflects the cloud

@@ -906,3 +875,2 @@ // below we cater for if we have an existing share or need to create the share in the SDK

const latestMetadata = latestRes.shareMetadata;
// read errors for what each means

@@ -923,3 +891,2 @@ if (latestMetadata.nonce > this.lastFetchedCloudMetadata.nonce) {

if (res.status !== 1) throw errors.acquireLockFailed(`lock cannot be acquired from storage layer status code: ${res.status}`);
// increment metadata nonce for write session

@@ -939,5 +906,3 @@ // this.metadata.nonce += 1;

}
// Module functions
async _syncShareMetadata(adjustScopedStore) {

@@ -1051,3 +1016,2 @@ if (!this.metadata) {

}
// update metadataStore

@@ -1093,3 +1057,2 @@ this.metadata.setTkeyStoreDomain(moduleName, rawTkeyStoreItems);

}
// Import export shares

@@ -1154,3 +1117,2 @@ async outputShare(shareIndex, type) {

}
/// Destructive method. All data will be wiped!

@@ -1167,3 +1129,2 @@ async CRITICAL_deleteTkey() {

}
// Construct all shares

@@ -1181,3 +1142,2 @@ const shareArray = this.getAllShareStoresForLatestPolynomial();

await this.syncLocalMetadataTransitions(); // forcesync
this.privKey = undefined;

@@ -1231,3 +1191,2 @@ this.metadata = undefined;

}
// update metadata nonce

@@ -1255,6 +1214,4 @@ this.metadata.nonce += 1;

}
// add metadata new poly to metadata
this.metadata.addFromPolynomialAndShares(poly, shares);
// change to share stores for public storing

@@ -1267,5 +1224,3 @@ const oldShareStores = {};

});
// evaluate oldPoly for old shares and set new metadata with encrypted share for new polynomial
const m = this.metadata.clone();

@@ -1282,3 +1237,2 @@ const newScopedStore = {};

const metadataToPush = Array(sharesToPush.length).fill(m);
// run refreshShare middleware

@@ -1301,3 +1255,2 @@ // If a shareIndex is left out during refresh shares, we assume that it being explicitly deleted.

});
// Combine Authmetadata and service provider ShareStore

@@ -1308,3 +1261,2 @@ await this.addLocalMetadataTransitions({

});
// update this.shares with these new shares

@@ -1334,3 +1286,2 @@ for (let index = 0; index < newShareIndexes.length; index += 1) {

}
// create a random poly and respective shares

@@ -1350,3 +1301,2 @@ // 1 is defined as the serviceProvider share

const shares = poly.generateShares(shareIndexes);
// create metadata to be stored

@@ -1358,7 +1308,5 @@ const metadata$1 = new metadata(commonTypes.getPubKeyPoint(this.privKey));

this.metadata = metadata$1;
// setup ed25519 seed after metadata is set
// import/gen ed25519 seed
await this.setupEd25519Seed(importEd25519Seed);
// initialize modules

@@ -1376,3 +1324,2 @@ if (initializeModules) {

});
// because this is the first time we're setting metadata there is no need to acquire a lock

@@ -1392,3 +1339,2 @@ // acquireLock: false. Force push

}
// store metadata on metadata respective to shares

@@ -1420,3 +1366,2 @@ for (let index = 0; index < shareIndexes.length; index += 1) {

}
// derive key pair (scalar, public key point) from seed

@@ -1442,4 +1387,3 @@ const keyPair = torus_js.getEd25519ExtendedPublicKey(seed);

}
var ThresholdKey$1 = ThresholdKey;
module.exports = ThresholdKey$1;
module.exports = ThresholdKey;

@@ -29,3 +29,2 @@ 'use strict';

super(code, message);
// Set name explicitly as minification can mangle class names

@@ -42,3 +41,2 @@ Object.defineProperty(this, "name", {

}
// Custom methods

@@ -58,3 +56,2 @@ // Metadata

}
// TkeyData

@@ -70,3 +67,2 @@ static tkeyStoreInvalid(extraMessage = "") {

}
// Shares

@@ -85,3 +81,2 @@ static privateKeyUnavailable(extraMessage = "") {

}
// Metadata locks

@@ -94,3 +89,2 @@ static acquireLockFailed(extraMessage = "") {

}
// Authmetadata

@@ -145,4 +139,3 @@ static privKeyUnavailable(extraMessage = "") {

});
var CoreError$1 = CoreError;
module.exports = CoreError$1;
module.exports = CoreError;

@@ -103,3 +103,2 @@ 'use strict';

}
// generateRandomPolynomial - determinisiticShares are assumed random

@@ -139,3 +138,2 @@ function generateRandomPolynomial(degree, secret, deterministicShares) {

}
// 2 + 3x = y | secret for index 1 is 5 >>> g^5 is the commitment | now we have g^2, g^3 and 1, |

@@ -142,0 +140,0 @@ function polyCommitmentEval(polyCommitments, index) {

@@ -101,3 +101,2 @@ 'use strict';

metadata.publicPolynomials[pubPolyID] = publicPolynomial;
// for polyIDList

@@ -142,3 +141,2 @@ unserializedPolyIDList.push([pubPolyID, secondHalf]);

}
// appends shares and public polynomial to metadata.

@@ -227,3 +225,2 @@ // should represent a generation of share or edit of threshold

}
// if not reconstruct

@@ -275,3 +272,2 @@ if (!pubShare) {

}
/**

@@ -296,4 +292,3 @@ * Updates the TSS metadata for the given tag.

}
var Metadata$1 = Metadata;
module.exports = Metadata$1;
module.exports = Metadata;

@@ -40,4 +40,3 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';

}
var AuthMetadata$1 = AuthMetadata;
export { AuthMetadata$1 as default };
export { AuthMetadata as default };

@@ -1392,4 +1392,3 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';

}
var ThresholdKey$1 = ThresholdKey;
export { ThresholdKey$1 as default };
export { ThresholdKey as default };

@@ -137,4 +137,3 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';

});
var CoreError$1 = CoreError;
export { CoreError$1 as default };
export { CoreError as default };

@@ -290,4 +290,3 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';

}
var Metadata$1 = Metadata;
export { Metadata$1 as default };
export { Metadata as default };
{
"name": "@tkey/core",
"version": "15.2.1-alpha.0",
"version": "16.0.0",
"description": "TKey Core library",

@@ -9,3 +9,3 @@ "main": "dist/lib.cjs/index.js",

"jsdelivr": "dist/core.umd.min.js",
"types": "dist/types/index.d.ts",
"types": "dist/lib.cjs/types/index.d.ts",
"sideEffects": false,

@@ -38,15 +38,14 @@ "scripts": {

"dependencies": {
"@tkey/common-types": "^15.2.1-alpha.0",
"@toruslabs/eccrypto": "^5.0.4",
"@toruslabs/http-helpers": "^7.0.0",
"@toruslabs/torus.js": "^15.1.0",
"@tkey/common-types": "^16.0.0",
"@toruslabs/eccrypto": "^6.0.2",
"@toruslabs/http-helpers": "^8.1.1",
"@toruslabs/torus.js": "^16.0.0",
"bn.js": "^5.2.1",
"elliptic": "^6.5.5",
"ethereum-cryptography": "^2.1.3",
"json-stable-stringify": "^1.1.1"
"elliptic": "^6.6.1",
"ethereum-cryptography": "^3.1.0",
"json-stable-stringify": "^1.2.1"
},
"devDependencies": {
"@types/bn.js": "^5.1.5",
"@types/elliptic": "^6.4.18",
"@types/json-stable-stringify": "^1.0.36"
"@types/bn.js": "^5.1.6",
"@types/elliptic": "^6.4.18"
},

@@ -78,6 +77,6 @@ "peerDependencies": {

"engines": {
"node": ">=18.x",
"node": ">=20.x",
"npm": ">=9.x"
},
"gitHead": "654beb4640145b80b2c8d615968a480698e06d61"
"gitHead": "a5e740eea4140322fc950878f09d8974b4b3761a"
}

Sorry, the diff of this file is too big to display