From bcbb5f2ca5751cacb21f3129ead4ef12e126a2d6 Mon Sep 17 00:00:00 2001 From: Mariano Aguero Date: Fri, 20 Nov 2026 12:49:24 -0300 Subject: [PATCH 1/5] fix(deps): upgrade ox to 1.8.16 and migrate p256 --- bun.lock | 32 +++++++++++++++++++++++++++++--- package.json | 4 ++-- src/p256.ts | 20 ++++++-------------- src/signatures.ts | 10 +++++++--- test/p256.test.ts | 8 ++++---- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/bun.lock b/bun.lock index 802c88a..bbd131a 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "frames-ts", "dependencies": { - "ox": "^0.14.45", + "ox": "^1.8.16", }, "devDependencies": { "@semantic-release/changelog": "^7.0.0", @@ -102,12 +102,14 @@ "@napi-rs/lzma-linux-x64-gnu": ["@napi-rs/lzma-linux-x64-gnu@1.5.1", "", { "os": "linux", "cpu": "x64" }, "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ=="], - "@noble/ciphers": ["@noble/ciphers@1.3.0", "", {}, "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw=="], + "@noble/ciphers": ["@noble/ciphers@2.4.0", "", {}, "sha512-AnjFn0Jv92laAkvMrghlFZq4qQCIN/4DxFV/eooqtC2YTjB7kBeLMS2T9KJX4Dn+ZVXLOwK0lSgqDtx9gvxtiw=="], "@noble/curves": ["@noble/curves@1.9.1", "", { "dependencies": { "@noble/hashes": "1.8.0" } }, "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA=="], "@noble/hashes": ["@noble/hashes@1.8.0", "", {}, "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A=="], + "@noble/post-quantum": ["@noble/post-quantum@0.6.1", "", { "dependencies": { "@noble/ciphers": "~2.2.0", "@noble/curves": "~2.2.0", "@noble/hashes": "~2.2.0" } }, "sha512-+pormrDZwjRw05U8ADK4JpHejo87+gBd+muRBB/ozztH5yhDLMDF4jHQWN3NQQAsu1zBNPWTG0ZwVI0CR29H0A=="], + "@octokit/auth-token": ["@octokit/auth-token@6.0.0", "", {}, "sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w=="], "@octokit/core": ["@octokit/core@7.0.8", "", { "dependencies": { "@octokit/auth-token": "^6.0.0", "@octokit/graphql": "^9.0.5", "@octokit/request": "^10.0.16", "@octokit/request-error": "^7.1.2", "@octokit/types": "^18.0.0", "before-after-hook": "^4.0.0", "universal-user-agent": "^7.0.0" } }, "sha512-L7y8eYc+AwxGr2PWI4WFt1VG4TiJ66c26BD16mXpYIlXxG0SMigM1+m4aTSlYyBr5BlQsGAlz8uDCoZN4SEMcg=="], @@ -532,7 +534,7 @@ "onetime": ["onetime@6.0.0", "", { "dependencies": { "mimic-fn": "^4.0.0" } }, "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ=="], - "ox": ["ox@0.14.45", "", { "dependencies": { "@adraffy/ens-normalize": "^1.11.0", "@noble/ciphers": "^1.3.0", "@noble/curves": "1.9.1", "@noble/hashes": "^1.8.0", "@scure/bip32": "^1.7.0", "@scure/bip39": "^1.6.0", "abitype": "^1.2.3", "eventemitter3": "5.0.1" }, "peerDependencies": { "typescript": ">=5.4.0" }, "optionalPeers": ["typescript"] }, "sha512-jpsQ+p0JZh9mKCxxzxz0d5qFHZZg2/O9xW18IpEC/dNXXPVqmDJ0c//9RMz0CILkbSGPA42+cbU0fC/ghwJ03w=="], + "ox": ["ox@1.8.16", "", { "dependencies": { "@adraffy/ens-normalize": "^1.11.0", "@noble/ciphers": "^2.2.0", "@noble/curves": "^2.2.0", "@noble/hashes": "^2.2.0", "@noble/post-quantum": "^0.6.1", "@scure/bip32": "^2.0.0", "@scure/bip39": "^2.0.0", "abitype": "^1.3.0", "eventemitter3": "5.0.1", "zod": "^4.4.3" }, "peerDependencies": { "typescript": ">=5.4.0" }, "optionalPeers": ["typescript"] }, "sha512-Gh73v6zaeKyB9vdhxJGwOt6oDn15sttSUF7skE0MwSeGyLLNf+KttlnHJcjxNYGobJ8xjoASwFCWOljO9bZUiQ=="], "p-each-series": ["p-each-series@3.0.0", "", {}, "sha512-lastgtAdoH9YaLyDa5i5z64q+kzOcQHsQ5SsZJD3q0VEyI8mq872S3geuNbRUQLVAE9siMfgKrpj7MloKFHruw=="], @@ -776,8 +778,16 @@ "yoctocolors": ["yoctocolors@2.2.0", "", {}, "sha512-xYqdZFUK/VYazNl/oCDYN+3WloWQwMfZxBoiNt6qNyk+xfOdi598muWE42rNZFp1kNOiqW936q5RhUdnpqElSg=="], + "zod": ["zod@4.6.7", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="], + "@actions/http-client/undici": ["undici@6.28.1", "", {}, "sha512-zWpdTVD54H48CIybL0rWQ3ukpb9d23wM7eH5RtfdmeP70cWHNjtfo7P4vZX+5CoDcO53J4Pu5uXp7lNfjc6DRA=="], + "@noble/post-quantum/@noble/ciphers": ["@noble/ciphers@2.2.0", "", {}, "sha512-Z6pjIZ/8IJcCGzb2S/0Px5J81yij85xASuk1teLNeg75bfT07MV3a/O2Mtn1I2se43k3lkVEcFaR10N4cgQcZA=="], + + "@noble/post-quantum/@noble/curves": ["@noble/curves@2.2.0", "", { "dependencies": { "@noble/hashes": "2.2.0" } }, "sha512-T/BoHgFXirb0ENSPBquzX0rcjXeM6Lo892a2jlYJkqk83LqZx0l1Of7DzlKJ6jkpvMrkHSnAcgb5JegL8SeIkQ=="], + + "@noble/post-quantum/@noble/hashes": ["@noble/hashes@2.2.0", "", {}, "sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg=="], + "@octokit/plugin-paginate-rest/@octokit/types": ["@octokit/types@16.0.0", "", { "dependencies": { "@octokit/openapi-types": "^27.0.0" } }, "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg=="], "@octokit/plugin-retry/@octokit/types": ["@octokit/types@17.0.0", "", { "dependencies": { "@octokit/openapi-types": "^28.0.0" } }, "sha512-ByP1v7YL5SMveFPP7+sj0/ZuWCOOg/Chs4NafOMpq6WNIM/hdGY0S7C0TCGDBWu1aGmOxmUIhMx3cO+IdwYZ1Q=="], @@ -1102,6 +1112,16 @@ "npm/yallist": ["yallist@5.0.0", "", {}, "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw=="], + "ox/@noble/curves": ["@noble/curves@2.4.0", "", { "dependencies": { "@noble/hashes": "2.4.0" } }, "sha512-P4/62zrgfH33CneE3Dn4WhJVA22YUU0eR51wKIan4NVRvwsA0YnPTwWGpNbpuacSujmSFLvyzpyuR30+fbq2Ew=="], + + "ox/@noble/hashes": ["@noble/hashes@2.4.0", "", {}, "sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA=="], + + "ox/@scure/bip32": ["@scure/bip32@2.4.0", "", { "dependencies": { "@noble/curves": "2.4.0", "@noble/hashes": "2.4.0", "@scure/base": "2.4.0" } }, "sha512-i3DS0CptAocyvqE4n3SUkpzeQK4vJMFwWLofTwRiiKo2aWojBOfyMCgfKw9HVpO6fSY5AK86sHS/Uzn8kK9Few=="], + + "ox/@scure/bip39": ["@scure/bip39@2.4.0", "", { "dependencies": { "@noble/hashes": "2.4.0" } }, "sha512-82dxFbZUYboyOf0AXiydsQrFQ5Q4h9mX+O2UkE91ROYmsc0BKMGZLwDmy96Jpa2+vrtoxomjUhy1RPIgH/r2nA=="], + + "ox/abitype": ["abitype@1.3.0", "", { "peerDependencies": { "typescript": ">=5.0.4", "zod": "^3.22.0 || ^4.0.0" }, "optionalPeers": ["typescript", "zod"] }, "sha512-fk6Te+bojIFrMvMZrnOO+SxCB+RUksTGOzq/60ZRvs1L+BVzvi2bqt9L3W/17ZLdZsyM1FuYf65P5nlmoiH1Bg=="], + "parse5-htmlparser2-tree-adapter/parse5": ["parse5@6.0.1", "", {}, "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="], "pkg-types/pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="], @@ -1124,6 +1144,8 @@ "tsx/esbuild": ["esbuild@0.28.2", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.28.2", "@esbuild/android-arm": "0.28.2", "@esbuild/android-arm64": "0.28.2", "@esbuild/android-x64": "0.28.2", "@esbuild/darwin-arm64": "0.28.2", "@esbuild/darwin-x64": "0.28.2", "@esbuild/freebsd-arm64": "0.28.2", "@esbuild/freebsd-x64": "0.28.2", "@esbuild/linux-arm": "0.28.2", "@esbuild/linux-arm64": "0.28.2", "@esbuild/linux-ia32": "0.28.2", "@esbuild/linux-loong64": "0.28.2", "@esbuild/linux-mips64el": "0.28.2", "@esbuild/linux-ppc64": "0.28.2", "@esbuild/linux-riscv64": "0.28.2", "@esbuild/linux-s390x": "0.28.2", "@esbuild/linux-x64": "0.28.2", "@esbuild/netbsd-arm64": "0.28.2", "@esbuild/netbsd-x64": "0.28.2", "@esbuild/openbsd-arm64": "0.28.2", "@esbuild/openbsd-x64": "0.28.2", "@esbuild/openharmony-arm64": "0.28.2", "@esbuild/sunos-x64": "0.28.2", "@esbuild/win32-arm64": "0.28.2", "@esbuild/win32-ia32": "0.28.2", "@esbuild/win32-x64": "0.28.2" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA=="], + "viem/ox": ["ox@0.14.45", "", { "dependencies": { "@adraffy/ens-normalize": "^1.11.0", "@noble/ciphers": "^1.3.0", "@noble/curves": "1.9.1", "@noble/hashes": "^1.8.0", "@scure/bip32": "^1.7.0", "@scure/bip39": "^1.6.0", "abitype": "^1.2.3", "eventemitter3": "5.0.1" }, "peerDependencies": { "typescript": ">=5.4.0" }, "optionalPeers": ["typescript"] }, "sha512-jpsQ+p0JZh9mKCxxzxz0d5qFHZZg2/O9xW18IpEC/dNXXPVqmDJ0c//9RMz0CILkbSGPA42+cbU0fC/ghwJ03w=="], + "vite/esbuild": ["esbuild@0.21.5", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.21.5", "@esbuild/android-arm": "0.21.5", "@esbuild/android-arm64": "0.21.5", "@esbuild/android-x64": "0.21.5", "@esbuild/darwin-arm64": "0.21.5", "@esbuild/darwin-x64": "0.21.5", "@esbuild/freebsd-arm64": "0.21.5", "@esbuild/freebsd-x64": "0.21.5", "@esbuild/linux-arm": "0.21.5", "@esbuild/linux-arm64": "0.21.5", "@esbuild/linux-ia32": "0.21.5", "@esbuild/linux-loong64": "0.21.5", "@esbuild/linux-mips64el": "0.21.5", "@esbuild/linux-ppc64": "0.21.5", "@esbuild/linux-riscv64": "0.21.5", "@esbuild/linux-s390x": "0.21.5", "@esbuild/linux-x64": "0.21.5", "@esbuild/netbsd-x64": "0.21.5", "@esbuild/openbsd-x64": "0.21.5", "@esbuild/sunos-x64": "0.21.5", "@esbuild/win32-arm64": "0.21.5", "@esbuild/win32-ia32": "0.21.5", "@esbuild/win32-x64": "0.21.5" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw=="], "wrap-ansi/ansi-styles": ["ansi-styles@6.2.3", "", {}, "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg=="], @@ -1168,6 +1190,8 @@ "npm/minipass-pipeline/minipass": ["minipass@3.3.6", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw=="], + "ox/@scure/bip32/@scure/base": ["@scure/base@2.4.0", "", {}, "sha512-thZ1TuJwFwBblOhgsjDKvvGirBxNp+wSvY/DR6tJBJOTDhdAAcHJ8Vbr2eFnqaxeca4+t0i9KBf+uHYGWwZORg=="], + "read-pkg/parse-json/type-fest": ["type-fest@4.41.0", "", {}, "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA=="], "semantic-release/execa/get-stream": ["get-stream@9.0.1", "", { "dependencies": { "@sec-ant/readable-stream": "^0.4.1", "is-stream": "^4.0.1" } }, "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA=="], @@ -1230,6 +1254,8 @@ "tsx/esbuild/@esbuild/win32-x64": ["@esbuild/win32-x64@0.28.2", "", { "os": "win32", "cpu": "x64" }, "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g=="], + "viem/ox/@noble/ciphers": ["@noble/ciphers@1.3.0", "", {}, "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw=="], + "vite/esbuild/@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.21.5", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ=="], "vite/esbuild/@esbuild/android-arm": ["@esbuild/android-arm@0.21.5", "", { "os": "android", "cpu": "arm" }, "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg=="], diff --git a/package.json b/package.json index 05cd0ff..6d8baa7 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "typecheck": "tsc --noEmit" }, "dependencies": { - "ox": "^0.14.45" + "ox": "^1.8.16" }, "peerDependencies": { "viem": "^2.21.0" @@ -92,6 +92,6 @@ }, "engines": { "bun": ">=1.2.0", - "node": ">=20" + "node": "^20.19.0 || >=22.12.0" } } diff --git a/src/p256.ts b/src/p256.ts index dd284ff..37022d5 100644 --- a/src/p256.ts +++ b/src/p256.ts @@ -4,7 +4,6 @@ import { concatHex, getAddress, keccak256, - numberToHex, size, sliceHex, } from 'viem' @@ -35,12 +34,12 @@ function oxPublicKey(publicKey: Hex) { const qy = sliceHex(publicKey, 33, 65) const value = { prefix: 4 as const, - x: BigInt(qx), - y: BigInt(qy), + x: qx, + y: qy, } try { - P256.noble.ProjectivePoint.fromHex(publicKey.slice(2)) + P256.noble.Point.fromHex(publicKey.slice(2)) } catch { throw new FrameEncodeError('P-256 public key is not a point on the curve') } @@ -57,18 +56,14 @@ export function p256SignerIdentity(publicKey: Hex): Address { export function privateKeyToP256Account(privateKey: Hex): P256FrameSigner { assertBytes32(privateKey, 'P-256 private key') - let point: ReturnType + let point: ReturnType> try { point = P256.getPublicKey({ privateKey }) } catch { throw new FrameEncodeError('P-256 private key is not a valid scalar') } - const publicKey = concatHex([ - '0x04', - numberToHex(point.x, { size: 32 }), - numberToHex(point.y, { size: 32 }), - ]) + const publicKey = concatHex(['0x04', point.x, point.y]) return { type: 'p256', @@ -83,10 +78,7 @@ export function privateKeyToP256Account(privateKey: Hex): P256FrameSigner { privateKey, extraEntropy: false, }) - return concatHex([ - numberToHex(r, { size: 32 }), - numberToHex(s, { size: 32 }), - ]) + return concatHex([r, s]) }, } } diff --git a/src/signatures.ts b/src/signatures.ts index 5be2a42..fffed23 100644 --- a/src/signatures.ts +++ b/src/signatures.ts @@ -224,10 +224,14 @@ async function signP256Entry( const s = returnedS > SECP256R1_N / 2n ? SECP256R1_N - returnedS : returnedS const publicKey = { prefix: 4 as const, - x: BigInt(sliceHex(signer.publicKey, 1, 33)), - y: BigInt(sliceHex(signer.publicKey, 33, 65)), + x: sliceHex(signer.publicKey, 1, 33), + y: sliceHex(signer.publicKey, 33, 65), } - if (!P256.verify({ payload: digest, publicKey, signature: { r, s } })) + const signature = { + r: numberToHex(r, { size: 32 }), + s: numberToHex(s, { size: 32 }), + } + if (!P256.verify({ payload: digest, publicKey, signature })) throw new FrameEncodeError( `signature ${index}: signer returned a signature that does not verify against its public key`, ) diff --git a/test/p256.test.ts b/test/p256.test.ts index 76c44a7..4792903 100644 --- a/test/p256.test.ts +++ b/test/p256.test.ts @@ -84,13 +84,13 @@ describe('signFrameSignature with a P-256 owner', () => { expect(() => assertCanonicalSignature(signed.signatures[0]!, 0)).not.toThrow() const signature = { - r: BigInt(sliceHex(bytes, 0, 32)), - s: BigInt(sliceHex(bytes, 32, 64)), + r: sliceHex(bytes, 0, 32), + s: sliceHex(bytes, 32, 64), } const publicKey = { prefix: 4 as const, - x: BigInt(sliceHex(signer.publicKey, 1, 33)), - y: BigInt(sliceHex(signer.publicKey, 33, 65)), + x: sliceHex(signer.publicKey, 1, 33), + y: sliceHex(signer.publicKey, 33, 65), } expect(P256.verify({ payload: hash, publicKey, signature })).toBe(true) expect(P256.verify({ payload: hash, publicKey, signature, hash: true })).toBe(false) From 2c9c01d9f6397079b10c06466745d3c525d45e8c Mon Sep 17 00:00:00 2001 From: Mariano Aguero Date: Wed, 25 Nov 2026 21:03:30 -0300 Subject: [PATCH 2/5] ci: load built cjs entries on oldest supported node --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ scripts/check-cjs.cjs | 28 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 scripts/check-cjs.cjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c8da9f..3caf3af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,3 +48,26 @@ jobs: # declarations, which a passing test suite would not notice. - name: Check published type resolution run: bunx --yes @arethetypeswrong/cli@latest --pack . + + # The suite above imports from src/ and runs on the latest Node 22, where + # require() of an ES module already works. This loads the built CommonJS + # entries on the oldest Node in `engines`, where a dependency that ships + # ESM only throws ERR_REQUIRE_ESM. + cjs-oldest-node: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - run: bun install --frozen-lockfile + + - run: bun run build + + - uses: actions/setup-node@v7 + with: + node-version: 20.0.0 + + - run: node scripts/check-cjs.cjs diff --git a/scripts/check-cjs.cjs b/scripts/check-cjs.cjs new file mode 100644 index 0000000..7efb9e8 --- /dev/null +++ b/scripts/check-cjs.cjs @@ -0,0 +1,28 @@ +// Loads the built CommonJS entries with require() and checks that a P-256 +// account derived through them matches the one from the ESM build. The test +// suite imports from src/, so only this catches a CJS build that cannot load +// on the oldest Node release in `engines`. +const assert = require('node:assert/strict') + +const key = `0x${'11'.repeat(32)}` +const hash = `0x${'22'.repeat(32)}` + +async function main() { + const cjs = require('../dist/index.cjs') + const viem = require('../dist/viem.cjs') + const esm = await import('../dist/index.js') + + assert.equal(typeof viem.frameActions, 'function') + + const fromCjs = cjs.privateKeyToP256Account(key) + const fromEsm = esm.privateKeyToP256Account(key) + assert.equal(fromCjs.address, fromEsm.address) + assert.equal(await fromCjs.sign({ hash }), await fromEsm.sign({ hash })) + + console.log(`CJS build loads on Node ${process.version}: ${fromCjs.address}`) +} + +main().catch((error) => { + console.error(error) + process.exit(1) +}) From 5ea177a856712e5776f9b28613e5f2547d8e6b2e Mon Sep 17 00:00:00 2001 From: Mariano Aguero Date: Wed, 25 Nov 2026 21:04:38 -0300 Subject: [PATCH 3/5] fix(build): bundle ox into cjs output for node 20 --- package.json | 2 +- tsup.config.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 6d8baa7..16a3769 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,6 @@ }, "engines": { "bun": ">=1.2.0", - "node": "^20.19.0 || >=22.12.0" + "node": ">=20" } } diff --git a/tsup.config.ts b/tsup.config.ts index 538206b..fe431a5 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,16 +1,21 @@ -import { defineConfig } from 'tsup' +import { defineConfig, type Options } from 'tsup' -export default defineConfig({ +const shared: Options = { entry: { index: 'src/index.ts', viem: 'src/viem.ts', }, - format: ['esm', 'cjs'], dts: true, sourcemap: true, - clean: true, treeshake: true, // viem stays external: consumers bring their own, and bundling it would // duplicate its secp256k1 and keccak implementations. external: ['viem'], -}) +} + +export default defineConfig([ + { ...shared, format: ['esm'], clean: true }, + // ox 1.x ships ESM only, and require() of an ES module needs Node 20.19 or + // 22.12. Bundling it into the CJS build keeps require() working on Node 20. + { ...shared, format: ['cjs'], noExternal: ['ox'] }, +]) From b66a8e7170674565523c7ee4ce7c47196972ae5b Mon Sep 17 00:00:00 2001 From: Mariano Aguero Date: Thu, 26 Nov 2026 19:37:28 -0300 Subject: [PATCH 4/5] fix(build): clear dist before tsup and gate release on dist --- .github/workflows/release.yml | 7 +++++++ package.json | 2 +- tsup.config.ts | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31712a7..f119d37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,6 +61,13 @@ jobs: # dist/ must exist before publish, since the tarball is files: ["dist", ...]. - run: bun run build + # An npm version cannot be replaced, so check the built entries and their + # type declarations before anything is published. + - run: node scripts/check-cjs.cjs + + - name: Check published type resolution + run: bunx --yes @arethetypeswrong/cli@latest --pack . + - name: Release and publish run: | if [ -n "$(git tag -l 'v*')" ]; then diff --git a/package.json b/package.json index 16a3769..24e5576 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "rlp" ], "scripts": { - "build": "tsup", + "build": "rm -rf dist && tsup", "test": "vitest run", "test:live": "FRAMES_LIVE=1 vitest run test/live", "test:watch": "vitest", diff --git a/tsup.config.ts b/tsup.config.ts index fe431a5..d27544d 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -14,7 +14,7 @@ const shared: Options = { } export default defineConfig([ - { ...shared, format: ['esm'], clean: true }, + { ...shared, format: ['esm'] }, // ox 1.x ships ESM only, and require() of an ES module needs Node 20.19 or // 22.12. Bundling it into the CJS build keeps require() working on Node 20. { ...shared, format: ['cjs'], noExternal: ['ox'] }, From 24b87f89f835540673a33b83cb2f14fb8a14ac1c Mon Sep 17 00:00:00 2001 From: Mariano Aguero Date: Thu, 26 Nov 2026 19:53:35 -0300 Subject: [PATCH 5/5] docs(readme): note engine-strict install on node 20.0 to 20.18 --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 686f473..54a9a3d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,11 @@ bun add @jaw.id/frametx-kit viem `viem` is a peer dependency, not a bundled one. `frameActions` extends a viem client, so your client and this library have to be the same viem. +The library runs on Node 20.0 and newer. Installing it on Node 20.0 to 20.18 can still +fail: some dependencies of `ox` declare `node >=20.19`, and Yarn 1, or npm with +`engine-strict`, rejects the install. Use Node 20.19 or newer, or install without engine +checks (for example `yarn --ignore-engines` on Yarn 1). + ## Use ```ts