diff --git a/package-lock.json b/package-lock.json index 2005eb331..c8a1c4e38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,9 @@ "workspaces": [ "./packages/*" ], + "dependencies": { + "@noble/hashes": "^1.7.1" + }, "devDependencies": { "@babel/preset-typescript": "^7.25.7", "@changesets/changelog-github": "^0.4.8", @@ -5768,6 +5771,18 @@ "@tybys/wasm-util": "^0.9.0" } }, + "node_modules/@noble/hashes": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.7.1.tgz", + "integrity": "sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "license": "MIT", @@ -26162,13 +26177,6 @@ "license": "ISC", "peer": true }, - "node_modules/sha3": { - "version": "2.1.4", - "license": "MIT", - "dependencies": { - "buffer": "6.0.3" - } - }, "node_modules/shallow-clone": { "version": "3.0.1", "license": "MIT", @@ -29050,16 +29058,16 @@ }, "packages/fcl": { "name": "@onflow/fcl", - "version": "1.13.2", + "version": "1.13.4", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", "@onflow/config": "1.5.1", - "@onflow/fcl-core": "1.13.2", - "@onflow/fcl-wc": "5.5.2", + "@onflow/fcl-core": "1.13.4", + "@onflow/fcl-wc": "5.5.4", "@onflow/interaction": "0.0.11", "@onflow/rlp": "1.2.3", - "@onflow/sdk": "1.5.5", + "@onflow/sdk": "1.5.6", "@onflow/types": "1.4.1", "@onflow/util-actor": "1.3.4", "@onflow/util-address": "1.2.3", @@ -29072,8 +29080,7 @@ "@walletconnect/types": "^2.13.2", "abort-controller": "^3.0.0", "cross-fetch": "^4.0.0", - "events": "^3.3.0", - "sha3": "^2.1.4" + "events": "^3.3.0" }, "devDependencies": { "@onflow/fcl-bundle": "1.6.0", @@ -29124,7 +29131,7 @@ }, "packages/fcl-core": { "name": "@onflow/fcl-core", - "version": "1.13.2", + "version": "1.13.4", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", @@ -29132,8 +29139,8 @@ "@onflow/config": "1.5.1", "@onflow/interaction": "0.0.11", "@onflow/rlp": "1.2.3", - "@onflow/sdk": "1.5.5", - "@onflow/transport-http": "1.10.4", + "@onflow/sdk": "1.5.6", + "@onflow/transport-http": "1.10.5", "@onflow/types": "1.4.1", "@onflow/util-actor": "1.3.4", "@onflow/util-address": "1.2.3", @@ -29180,15 +29187,15 @@ }, "packages/fcl-react-native": { "name": "@onflow/fcl-react-native", - "version": "1.9.9", + "version": "1.9.11", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", "@onflow/config": "1.5.1", - "@onflow/fcl-core": "1.13.2", + "@onflow/fcl-core": "1.13.4", "@onflow/interaction": "0.0.11", "@onflow/rlp": "1.2.3", - "@onflow/sdk": "1.5.5", + "@onflow/sdk": "1.5.6", "@onflow/types": "1.4.1", "@onflow/util-actor": "1.3.4", "@onflow/util-address": "1.2.3", @@ -29240,7 +29247,7 @@ }, "packages/fcl-wc": { "name": "@onflow/fcl-wc", - "version": "5.5.2", + "version": "5.5.4", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", @@ -29268,7 +29275,7 @@ "jest-preset-preact": "^4.1.1" }, "peerDependencies": { - "@onflow/fcl-core": "1.13.2" + "@onflow/fcl-core": "1.13.4" } }, "packages/fcl/node_modules/cross-fetch": { @@ -29359,13 +29366,14 @@ }, "packages/sdk": { "name": "@onflow/sdk", - "version": "1.5.5", + "version": "1.5.6", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", + "@noble/hashes": "^1.7.1", "@onflow/config": "1.5.1", "@onflow/rlp": "1.2.3", - "@onflow/transport-http": "1.10.4", + "@onflow/transport-http": "1.10.5", "@onflow/typedefs": "1.4.0", "@onflow/util-actor": "1.3.4", "@onflow/util-address": "1.2.3", @@ -29374,7 +29382,6 @@ "@onflow/util-template": "1.2.3", "deepmerge": "^4.3.1", "events": "^3.3.0", - "sha3": "^2.1.4", "uuid": "^9.0.1" }, "devDependencies": { @@ -29414,13 +29421,13 @@ }, "devDependencies": { "@onflow/fcl-bundle": "1.6.0", - "@onflow/sdk": "1.5.5", + "@onflow/sdk": "1.5.6", "jest": "^29.7.0" } }, "packages/transport-http": { "name": "@onflow/transport-http", - "version": "1.10.4", + "version": "1.10.5", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", @@ -29437,7 +29444,7 @@ "devDependencies": { "@onflow/fcl-bundle": "1.6.0", "@onflow/rlp": "1.2.3", - "@onflow/sdk": "1.5.5", + "@onflow/sdk": "1.5.6", "@onflow/types": "1.4.1", "jest": "^29.7.0" } diff --git a/package.json b/package.json index 4699e1f07..c3e04d794 100644 --- a/package.json +++ b/package.json @@ -36,5 +36,8 @@ "@nx/nx-darwin-x64": "^17.3.2", "@nx/nx-linux-x64-gnu": "^17.3.2", "@nx/nx-win32-x64-msvc": "^17.3.2" + }, + "dependencies": { + "@noble/hashes": "^1.7.1" } } diff --git a/packages/fcl-core/src/interaction-template-utils/utils/hash.js b/packages/fcl-core/src/interaction-template-utils/utils/hash.js index 14917c2b4..aa1493c01 100644 --- a/packages/fcl-core/src/interaction-template-utils/utils/hash.js +++ b/packages/fcl-core/src/interaction-template-utils/utils/hash.js @@ -1,8 +1,7 @@ -import {SHA3} from "sha3" +import {sha3_256} from "@noble/hashes/sha3" +import {bytesToHex} from "@noble/hashes/utils" import {Buffer} from "@onflow/rlp" export function genHash(utf8String) { - const sha = new SHA3(256) - sha.update(Buffer.from(utf8String, "utf8")) - return sha.digest("hex") + return bytesToHex(sha3_256(Buffer.from(utf8String, "utf8"))) } diff --git a/packages/fcl/package.json b/packages/fcl/package.json index ae3c2050f..ed46934fc 100644 --- a/packages/fcl/package.json +++ b/packages/fcl/package.json @@ -66,7 +66,6 @@ "@walletconnect/types": "^2.13.2", "abort-controller": "^3.0.0", "cross-fetch": "^4.0.0", - "events": "^3.3.0", - "sha3": "^2.1.4" + "events": "^3.3.0" } } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index a7ecd3639..5ba9003d8 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -41,6 +41,7 @@ }, "dependencies": { "@babel/runtime": "^7.25.7", + "@noble/hashes": "^1.7.1", "@onflow/config": "1.5.1", "@onflow/rlp": "1.2.3", "@onflow/transport-http": "1.10.5", @@ -52,7 +53,6 @@ "@onflow/util-template": "1.2.3", "deepmerge": "^4.3.1", "events": "^3.3.0", - "sha3": "^2.1.4", "uuid": "^9.0.1" } } diff --git a/packages/sdk/src/encode/encode.ts b/packages/sdk/src/encode/encode.ts index 3c9f31408..8fe91e8da 100644 --- a/packages/sdk/src/encode/encode.ts +++ b/packages/sdk/src/encode/encode.ts @@ -1,4 +1,5 @@ -import {SHA3} from "sha3" +import {sha3_256} from "@noble/hashes/sha3" +import {bytesToHex} from "@noble/hashes/utils" import {encode, Buffer, EncodeInput} from "@onflow/rlp" import {sansPrefix} from "@onflow/util-address" @@ -7,7 +8,7 @@ export const encodeTransactionPayload = (tx: Transaction) => export const encodeTransactionEnvelope = (tx: Transaction) => prependTransactionDomainTag(rlpEncode(prepareEnvelope(tx))) export const encodeTxIdFromVoucher = (voucher: Voucher) => - sha3_256(rlpEncode(prepareVoucher(voucher))) + sha3_256_hash(rlpEncode(prepareVoucher(voucher))) const rightPaddedHexBuffer = (value: string, pad: number) => Buffer.from(value.padEnd(pad * 2, "0"), "hex") @@ -35,10 +36,8 @@ const rlpEncode = (v: EncodeInput) => { return encode(v).toString("hex") } -const sha3_256 = (msg: string) => { - const sha = new SHA3(256) - sha.update(Buffer.from(msg, "hex")) - return sha.digest().toString("hex") +const sha3_256_hash = (msg: string) => { + return bytesToHex(sha3_256(Buffer.from(msg, "utf8"))) } const preparePayload = (tx: Transaction) => {