diff --git a/package-lock.json b/package-lock.json index 54500d5..aa925b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fhevmjs", - "version": "0.6.0-12", + "version": "0.6.0-13", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "fhevmjs", - "version": "0.6.0-12", + "version": "0.6.0-13", "license": "BSD-3-Clause-Clear", "dependencies": { "bigint-buffer": "^1.1.5", @@ -14,9 +14,9 @@ "fetch-mock": "^11.1.3", "keccak": "^3.0.4", "node-tfhe": "^0.9.1", - "node-tkms": "0.9.0-rc27", + "node-tkms": "^0.9.0-rc36", "tfhe": "^0.9.1", - "tkms": "0.9.0-rc27", + "tkms": "^0.9.0-rc36", "wasm-feature-detect": "^1.8.0" }, "bin": { @@ -52,6 +52,7 @@ "ts-loader": "^9.4.2", "tsc-alias": "^1.8.6", "tslib": "^2.5.3", + "typescript": "^5.7.2", "webpack": "^5.82.1", "webpack-cli": "^5.1.1", "webpack-merge": "^5.9.0" @@ -5819,9 +5820,9 @@ "integrity": "sha512-M2CbUVX4DQneaaK/4fygy9lW0zjOOzM8yGWAgbKGRt/Gd07zaloFEGGHW7dbmUaHo022q1uo7nzxyYhe4UgqCw==" }, "node_modules/node-tkms": { - "version": "0.9.0-rc27", - "resolved": "https://registry.npmjs.org/node-tkms/-/node-tkms-0.9.0-rc27.tgz", - "integrity": "sha512-lRCgH5pHewK5IRkczX1zpDpU0BidGHKDtaN812Yh9fhR97aqKVDWdSidQrOqX7RSstDkHeJ1dDyN6fx2wkQ+4Q==", + "version": "0.9.0-rc36", + "resolved": "https://registry.npmjs.org/node-tkms/-/node-tkms-0.9.0-rc36.tgz", + "integrity": "sha512-oGqJfjvb/igd9VgQaqYbzKc+CmrnQ/eY0ShmdE3JDKXL3C4Re/tBswT0KkWmlT1aM+Lxt5ihRNOs2oHtrPqr5w==", "license": "BSD-3-Clause-Clear" }, "node_modules/normalize-path": { @@ -7084,9 +7085,9 @@ "integrity": "sha512-kmtl7KfCCZJaFhm9lUYsTtat+yT0qzOiO6bOidM2Pt7/7jptkbS2/myeGHxb9qi2/aJ30g2joo1euKZPa207tg==" }, "node_modules/tkms": { - "version": "0.9.0-rc27", - "resolved": "https://registry.npmjs.org/tkms/-/tkms-0.9.0-rc27.tgz", - "integrity": "sha512-sSO1jb4/gw0FjS+AubW35/KnJfx1qBp2EuIb0gLg7247DS2VlsBh2iNlBtHKKBevhkgfvjdOt0YZT1J0y9Bv/Q==", + "version": "0.9.0-rc36", + "resolved": "https://registry.npmjs.org/tkms/-/tkms-0.9.0-rc36.tgz", + "integrity": "sha512-8IoRi6mYgnrmwTNBe/ejvHOFRhs5M6o2Ls2RVXCgAzSVBBBWJC1O8hquqlciHfME/VooUD4iokzEaBfADvoXZw==", "license": "BSD-3-Clause-Clear" }, "node_modules/tmpl": { @@ -7328,17 +7329,17 @@ "license": "MIT" }, "node_modules/typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, - "peer": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=12.20" + "node": ">=14.17" } }, "node_modules/unbox-primitive": { @@ -12074,9 +12075,9 @@ "integrity": "sha512-M2CbUVX4DQneaaK/4fygy9lW0zjOOzM8yGWAgbKGRt/Gd07zaloFEGGHW7dbmUaHo022q1uo7nzxyYhe4UgqCw==" }, "node-tkms": { - "version": "0.9.0-rc27", - "resolved": "https://registry.npmjs.org/node-tkms/-/node-tkms-0.9.0-rc27.tgz", - "integrity": "sha512-lRCgH5pHewK5IRkczX1zpDpU0BidGHKDtaN812Yh9fhR97aqKVDWdSidQrOqX7RSstDkHeJ1dDyN6fx2wkQ+4Q==" + "version": "0.9.0-rc36", + "resolved": "https://registry.npmjs.org/node-tkms/-/node-tkms-0.9.0-rc36.tgz", + "integrity": "sha512-oGqJfjvb/igd9VgQaqYbzKc+CmrnQ/eY0ShmdE3JDKXL3C4Re/tBswT0KkWmlT1aM+Lxt5ihRNOs2oHtrPqr5w==" }, "normalize-path": { "version": "3.0.0", @@ -12957,9 +12958,9 @@ "integrity": "sha512-kmtl7KfCCZJaFhm9lUYsTtat+yT0qzOiO6bOidM2Pt7/7jptkbS2/myeGHxb9qi2/aJ30g2joo1euKZPa207tg==" }, "tkms": { - "version": "0.9.0-rc27", - "resolved": "https://registry.npmjs.org/tkms/-/tkms-0.9.0-rc27.tgz", - "integrity": "sha512-sSO1jb4/gw0FjS+AubW35/KnJfx1qBp2EuIb0gLg7247DS2VlsBh2iNlBtHKKBevhkgfvjdOt0YZT1J0y9Bv/Q==" + "version": "0.9.0-rc36", + "resolved": "https://registry.npmjs.org/tkms/-/tkms-0.9.0-rc36.tgz", + "integrity": "sha512-8IoRi6mYgnrmwTNBe/ejvHOFRhs5M6o2Ls2RVXCgAzSVBBBWJC1O8hquqlciHfME/VooUD4iokzEaBfADvoXZw==" }, "tmpl": { "version": "1.0.5", @@ -13121,11 +13122,10 @@ "dev": true }, "typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", - "dev": true, - "peer": true + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true }, "unbox-primitive": { "version": "1.0.2", diff --git a/package.json b/package.json index a59cf8e..59ea71f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fhevmjs", - "version": "0.6.0-12", + "version": "0.6.0-13", "description": "fhEVM SDK for blockchain using TFHE", "main": "lib/node.js", "types": "lib/node/node.d.ts", @@ -52,9 +52,9 @@ "fetch-mock": "^11.1.3", "keccak": "^3.0.4", "node-tfhe": "^0.9.1", - "node-tkms": "0.9.0-rc27", + "node-tkms": "^0.9.0-rc36", "tfhe": "^0.9.1", - "tkms": "0.9.0-rc27", + "tkms": "^0.9.0-rc36", "wasm-feature-detect": "^1.8.0" }, "devDependencies": { @@ -87,6 +87,7 @@ "ts-loader": "^9.4.2", "tsc-alias": "^1.8.6", "tslib": "^2.5.3", + "typescript": "^5.7.2", "webpack": "^5.82.1", "webpack-cli": "^5.1.1", "webpack-merge": "^5.9.0" diff --git a/src/sdk/config.ts b/src/sdk/config.ts index fd9938d..a2159ba 100644 --- a/src/sdk/config.ts +++ b/src/sdk/config.ts @@ -73,7 +73,9 @@ export const getTfheCompactPublicKey = async ( publicKeyId: config.publicKeyId, }; } catch (e) { - throw new Error('Invalid public key (deserialization failed)'); + throw new Error('Invalid public key (deserialization failed)', { + cause: e, + }); } } else { throw new Error('You must provide a public key with its public key ID.'); @@ -102,7 +104,9 @@ export const getPublicParams = async ( }, }; } catch (e) { - throw new Error('Invalid public key (deserialization failed)'); + throw new Error('Invalid public key (deserialization failed)', { + cause: e, + }); } } else { throw new Error('You must provide a valid CRS with its CRS ID.'); diff --git a/src/sdk/encrypt.ts b/src/sdk/encrypt.ts index 4b947f2..76e1953 100644 --- a/src/sdk/encrypt.ts +++ b/src/sdk/encrypt.ts @@ -281,8 +281,7 @@ export const createEncryptedInput = const response = await fetch(`${gateway}verify_proven_ct`, options); json = await response.json(); } catch (e) { - console.log('verify_proven_ct failed with error', e); - throw new Error("Gateway didn't response correctly"); + throw new Error("Gateway didn't response correctly", { cause: e }); } // Note that the hex strings returned by the gateway do have have the 0x prefix diff --git a/src/sdk/network.ts b/src/sdk/network.ts index 8a56c8e..21fadec 100644 --- a/src/sdk/network.ts +++ b/src/sdk/network.ts @@ -102,8 +102,9 @@ export const getKeysFromGateway = async ( } else { throw new Error('No public key available'); } - } catch (error) { - console.log('error', error); - throw new Error('Impossible to fetch public key: wrong gateway url.'); + } catch (e) { + throw new Error('Impossible to fetch public key: wrong gateway url.', { + cause: e, + }); } }; diff --git a/src/sdk/reencrypt.ts b/src/sdk/reencrypt.ts index 72b0825..3e49697 100644 --- a/src/sdk/reencrypt.ts +++ b/src/sdk/reencrypt.ts @@ -60,7 +60,7 @@ export const reencryptRequest = pubKey = u8vec_to_cryptobox_pk(fromHexString(publicKey)); privKey = u8vec_to_cryptobox_sk(fromHexString(privateKey)); } catch (e) { - throw new Error('Invalid public or private key'); + throw new Error('Invalid public or private key', { cause: e }); } let json; @@ -68,11 +68,11 @@ export const reencryptRequest = const response = await fetch(`${gatewayUrl}reencrypt`, options); json = await response.json(); } catch (e) { - throw new Error("Gateway didn't response correctly"); + throw new Error("Gateway didn't response correctly", { cause: e }); } if (json.status === 'failure') { - throw new Error("The reencryption didn't succeed"); + throw new Error("The reencryption didn't succeed", { cause: json }); } const client = new_client(kmsSignatures, userAddress, 'default'); @@ -109,6 +109,6 @@ export const reencryptRequest = return bytesToBigInt(decryption); } catch (e) { - throw new Error('An error occured during decryption'); + throw new Error('An error occured during decryption', { cause: e }); } }; diff --git a/tsconfig.json b/tsconfig.json index 46fda76..983b322 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "outDir": "bundle", "declaration": false, "target": "es5", - "lib": ["DOM", "WebWorker"], + "lib": ["es2022", "DOM", "WebWorker"], "module": "commonjs", "skipLibCheck": true, "esModuleInterop": true, diff --git a/tsconfig.rollup.json b/tsconfig.rollup.json index c09ec25..0b6235c 100644 --- a/tsconfig.rollup.json +++ b/tsconfig.rollup.json @@ -3,8 +3,8 @@ "rootDir": "src", "outDir": "lib", "declaration": true, - "target": "ES2020", - "lib": ["DOM", "WebWorker"], + "target": "ES2022", + "lib": ["es2022", "DOM", "WebWorker"], "module": "esnext", "skipLibCheck": true, "esModuleInterop": true,