diff --git a/jest.config.cjs b/jest.config.cjs index 3f0397b5..b28f6b07 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -202,6 +202,9 @@ module.exports = { tsconfig: { module: 'CommonJS', moduleResolution: 'Node', + // TS 6 deprecates node10 resolution. The tests are compiled to + // CommonJS, so node10 is still the correct choice for them. + ignoreDeprecations: '6.0', verbatimModuleSyntax: false, }, }, diff --git a/package.json b/package.json index adf7302c..4a8ac033 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "@types/node": "^22.13.14", "@types/semver": "^7", "@types/uuid": "^9.0.8", + "@typescript/native": "npm:typescript@^7.0.2", "eslint": "^9.39.1", "eslint-config-prettier": "^9.1.0", "eslint-import-resolver-typescript": "^3.6.3", @@ -98,7 +99,7 @@ "ts-jest": "^29.4.11", "tsd": "^0.29.0", "typedoc": "^0.25.13", - "typescript": "~5.3.3", + "typescript": "npm:@typescript/typescript6@^6.0.2", "typescript-eslint": "^8.48.0", "web3": "^4.16.0" }, @@ -111,7 +112,7 @@ "engines": { "node": "^22.14.0 || ^24" }, - "packageManager": "yarn@4.16.0", + "packageManager": "yarn@4.17.1+sha256.471ffb15e0523663865bbf46a69e7d157ecf532412eb436c48dfab6e3f2abe88", "lavamoat": { "allowScripts": { "@lavamoat/preinstall-always-fail": false, diff --git a/src/errors.ts b/src/errors.ts index 6c2a8e9e..6ae07f0f 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -71,6 +71,7 @@ export function getErrorMessage(error: unknown): string { return ''; } + // eslint-disable-next-line @typescript-eslint/no-base-to-string -- Stringifying an arbitrary value is the documented fallback here, so `[object Object]` is an accepted result rather than a mistake. return String(error); } diff --git a/src/hashing.ts b/src/hashing.ts index 0405f64f..2d8185c4 100644 --- a/src/hashing.ts +++ b/src/hashing.ts @@ -12,6 +12,11 @@ import { * @param bytes - A byte array. * @returns The SHA-256 hash as a byte array. */ +// `crypto.subtle.digest` takes a `BufferSource`, which TypeScript 7 will not +// accept a plain `Uint8Array` for: it is now generic over the buffer, so it +// could be backed by a `SharedArrayBuffer`. Runtimes accept those, and +// narrowing the exported signatures below would break callers, so the +// assertion is kept at the call sites. export async function sha256(bytes: Uint8Array): Promise { // Use crypto.subtle.digest whenever possible as it is faster. if ( @@ -20,7 +25,7 @@ export async function sha256(bytes: Uint8Array): Promise { globalThis.crypto.subtle?.digest ) { return new Uint8Array( - await globalThis.crypto.subtle.digest('SHA-256', bytes), + await globalThis.crypto.subtle.digest('SHA-256', bytes as BufferSource), ); } return nobleSha256(bytes); @@ -42,7 +47,7 @@ export async function sha512(bytes: Uint8Array): Promise { globalThis.crypto.subtle?.digest ) { return new Uint8Array( - await globalThis.crypto.subtle.digest('SHA-512', bytes), + await globalThis.crypto.subtle.digest('SHA-512', bytes as BufferSource), ); } return nobleSha512(bytes); @@ -64,7 +69,7 @@ export async function sha384(bytes: Uint8Array): Promise { globalThis.crypto.subtle?.digest ) { return new Uint8Array( - await globalThis.crypto.subtle.digest('SHA-384', bytes), + await globalThis.crypto.subtle.digest('SHA-384', bytes as BufferSource), ); } return nobleSha384(bytes); diff --git a/yarn.lock b/yarn.lock index d8341501..a246a8a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1213,6 +1213,7 @@ __metadata: "@types/node": "npm:^22.13.14" "@types/semver": "npm:^7" "@types/uuid": "npm:^9.0.8" + "@typescript/native": "npm:typescript@^7.0.2" debug: "npm:^4.3.4" eslint: "npm:^9.39.1" eslint-config-prettier: "npm:^9.1.0" @@ -1237,7 +1238,7 @@ __metadata: ts-jest: "npm:^29.4.11" tsd: "npm:^0.29.0" typedoc: "npm:^0.25.13" - typescript: "npm:~5.3.3" + typescript: "npm:@typescript/typescript6@^6.0.2" typescript-eslint: "npm:^8.48.0" uuid: "npm:^9.0.1" web3: "npm:^4.16.0" @@ -2531,6 +2532,227 @@ __metadata: languageName: node linkType: hard +"@typescript/native@npm:typescript@^7.0.2": + version: 7.0.2 + resolution: "typescript@npm:7.0.2" + dependencies: + "@typescript/typescript-aix-ppc64": "npm:7.0.2" + "@typescript/typescript-darwin-arm64": "npm:7.0.2" + "@typescript/typescript-darwin-x64": "npm:7.0.2" + "@typescript/typescript-freebsd-arm64": "npm:7.0.2" + "@typescript/typescript-freebsd-x64": "npm:7.0.2" + "@typescript/typescript-linux-arm": "npm:7.0.2" + "@typescript/typescript-linux-arm64": "npm:7.0.2" + "@typescript/typescript-linux-loong64": "npm:7.0.2" + "@typescript/typescript-linux-mips64el": "npm:7.0.2" + "@typescript/typescript-linux-ppc64": "npm:7.0.2" + "@typescript/typescript-linux-riscv64": "npm:7.0.2" + "@typescript/typescript-linux-s390x": "npm:7.0.2" + "@typescript/typescript-linux-x64": "npm:7.0.2" + "@typescript/typescript-netbsd-arm64": "npm:7.0.2" + "@typescript/typescript-netbsd-x64": "npm:7.0.2" + "@typescript/typescript-openbsd-arm64": "npm:7.0.2" + "@typescript/typescript-openbsd-x64": "npm:7.0.2" + "@typescript/typescript-sunos-x64": "npm:7.0.2" + "@typescript/typescript-win32-arm64": "npm:7.0.2" + "@typescript/typescript-win32-x64": "npm:7.0.2" + dependenciesMeta: + "@typescript/typescript-aix-ppc64": + optional: true + "@typescript/typescript-darwin-arm64": + optional: true + "@typescript/typescript-darwin-x64": + optional: true + "@typescript/typescript-freebsd-arm64": + optional: true + "@typescript/typescript-freebsd-x64": + optional: true + "@typescript/typescript-linux-arm": + optional: true + "@typescript/typescript-linux-arm64": + optional: true + "@typescript/typescript-linux-loong64": + optional: true + "@typescript/typescript-linux-mips64el": + optional: true + "@typescript/typescript-linux-ppc64": + optional: true + "@typescript/typescript-linux-riscv64": + optional: true + "@typescript/typescript-linux-s390x": + optional: true + "@typescript/typescript-linux-x64": + optional: true + "@typescript/typescript-netbsd-arm64": + optional: true + "@typescript/typescript-netbsd-x64": + optional: true + "@typescript/typescript-openbsd-arm64": + optional: true + "@typescript/typescript-openbsd-x64": + optional: true + "@typescript/typescript-sunos-x64": + optional: true + "@typescript/typescript-win32-arm64": + optional: true + "@typescript/typescript-win32-x64": + optional: true + bin: + tsc: bin/tsc + checksum: 10/b0179005349b43dc1febb35c4e79162cdf89b84eae60f6deac142429109041e07582e69a6aacf5a897e085869686d4512ea444a10acf5b5aa2b60910f82a19ca + languageName: node + linkType: hard + +"@typescript/old@npm:typescript@^6": + version: 6.0.3 + resolution: "typescript@npm:6.0.3" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/0ef2357a4cffd916b52b683a021cdab0f81eea4e9aa35f2d254581c9a5106da02224e3392e1b0ed42b7a48f80c966e5f52b8e1a27941fa0523c1705a9c2e0330 + languageName: node + linkType: hard + +"@typescript/typescript-aix-ppc64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-aix-ppc64@npm:7.0.2" + conditions: os=aix & cpu=ppc64 + languageName: node + linkType: hard + +"@typescript/typescript-darwin-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-darwin-arm64@npm:7.0.2" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-darwin-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-darwin-x64@npm:7.0.2" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-freebsd-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-freebsd-arm64@npm:7.0.2" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-freebsd-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-freebsd-x64@npm:7.0.2" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-arm64@npm:7.0.2" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-arm@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-arm@npm:7.0.2" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@typescript/typescript-linux-loong64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-loong64@npm:7.0.2" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-mips64el@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-mips64el@npm:7.0.2" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + +"@typescript/typescript-linux-ppc64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-ppc64@npm:7.0.2" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-riscv64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-riscv64@npm:7.0.2" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-s390x@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-s390x@npm:7.0.2" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + +"@typescript/typescript-linux-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-x64@npm:7.0.2" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-netbsd-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-netbsd-arm64@npm:7.0.2" + conditions: os=netbsd & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-netbsd-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-netbsd-x64@npm:7.0.2" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-openbsd-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-openbsd-arm64@npm:7.0.2" + conditions: os=openbsd & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-openbsd-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-openbsd-x64@npm:7.0.2" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-sunos-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-sunos-x64@npm:7.0.2" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-win32-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-win32-arm64@npm:7.0.2" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-win32-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-win32-x64@npm:7.0.2" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@ungap/structured-clone@npm:^1.3.0": version: 1.4.0 resolution: "@ungap/structured-clone@npm:1.4.0" @@ -6966,14 +7188,14 @@ __metadata: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin, resolve@patch:resolve@npm%3A^1.10.0#optional!builtin": version: 1.22.8 - resolution: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin::version=1.22.8&hash=c3c19d" + resolution: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin::version=1.22.8&hash=9bd1a5" dependencies: is-core-module: "npm:^2.13.0" path-parse: "npm:^1.0.7" supports-preserve-symlinks-flag: "npm:^1.0.0" bin: resolve: bin/resolve - checksum: 10/f345cd37f56a2c0275e3fe062517c650bb673815d885e7507566df589375d165bbbf4bdb6aa95600a9bc55f4744b81f452b5a63f95b9f10a72787dba3c90890a + checksum: 10/b14c82cbce48701a1e963c60f196b91a289186e8b596334e09c881df8069cefcfb0ac9ce85ea768742b361a58005494bf2428a95dc5056d2ba441aa993731b1f languageName: node linkType: hard @@ -7702,23 +7924,25 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~5.3.3": - version: 5.3.3 - resolution: "typescript@npm:5.3.3" +"typescript@npm:@typescript/typescript6@^6.0.2": + version: 6.0.2 + resolution: "@typescript/typescript6@npm:6.0.2" + dependencies: + "@typescript/old": "npm:typescript@^6" bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 10/6e4e6a14a50c222b3d14d4ea2f729e79f972fa536ac1522b91202a9a65af3605c2928c4a790a4a50aa13694d461c479ba92cedaeb1e7b190aadaa4e4b96b8e18 + tsc6: bin/tsc6 + checksum: 10/e214aa9b2783ac924498ebbb42a4419e1d8681acc10d26daa145e938d6da0ecde46ad36690fc4e9083a4b47cf73cdc83f2c2054f32e07f10920768956c2b00a1 languageName: node linkType: hard -"typescript@patch:typescript@npm%3A~5.3.3#optional!builtin": - version: 5.3.3 - resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7" +"typescript@patch:typescript@npm%3A@typescript/typescript6@^6.0.2#optional!builtin": + version: 6.0.2 + resolution: "typescript@patch:@typescript/typescript6@npm%3A6.0.2#optional!builtin::version=6.0.2&hash=5786d5" + dependencies: + "@typescript/old": "npm:typescript@^6" bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 10/c93786fcc9a70718ba1e3819bab56064ead5817004d1b8186f8ca66165f3a2d0100fee91fa64c840dcd45f994ca5d615d8e1f566d39a7470fc1e014dbb4cf15d + tsc6: bin/tsc6 + checksum: 10/b190ec6b713b0fa95c059ff8019b740c17591ea83a3b60e6fe592d51d56d73c360b86abce48f616d25c39697cc5f4bb9efe8e2a231096f493758457cb175e11c languageName: node linkType: hard