@qntx/wallet-chains 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +22 -2
- package/dist/bitcoin-sign.d.mts +14 -0
- package/dist/bitcoin-sign.mjs +29 -0
- package/dist/bitcoin-sign.mjs.map +1 -0
- package/dist/bitcoin.d.mts +71 -0
- package/dist/bitcoin.mjs +632 -0
- package/dist/bitcoin.mjs.map +1 -0
- package/dist/curve-BeDNVVGm.mjs +2865 -0
- package/dist/curve-BeDNVVGm.mjs.map +1 -0
- package/dist/ed25519-DUtI5nWr.mjs +586 -0
- package/dist/ed25519-DUtI5nWr.mjs.map +1 -0
- package/dist/evm-sign.d.mts +10 -0
- package/dist/evm-sign.mjs +94 -0
- package/dist/evm-sign.mjs.map +1 -0
- package/dist/evm.d.mts +88 -0
- package/dist/evm.mjs +348 -0
- package/dist/evm.mjs.map +1 -0
- package/dist/index.d.mts +142 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/dist/message-AfNel4WZ.mjs +185 -0
- package/dist/message-AfNel4WZ.mjs.map +1 -0
- package/dist/secp256k1-D0CRzacO.mjs +1384 -0
- package/dist/secp256k1-D0CRzacO.mjs.map +1 -0
- package/dist/solana-sign.d.mts +5 -0
- package/dist/solana-sign.mjs +20 -0
- package/dist/solana-sign.mjs.map +1 -0
- package/dist/solana.d.mts +78 -0
- package/dist/solana.mjs +355 -0
- package/dist/solana.mjs.map +1 -0
- package/dist/typed-data-D28VBOIm.mjs +464 -0
- package/dist/typed-data-D28VBOIm.mjs.map +1 -0
- package/package.json +98 -4
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { ChainError } from "./index.mjs";
|
|
2
|
+
import { B as aexists, G as clean, H as anumber, J as swap32IfBE, K as createHasher, R as abool, U as aoutput, W as bytesToHex, X as split, Y as u32, z as abytes } from "./curve-BeDNVVGm.mjs";
|
|
3
|
+
import { n as secp256k1 } from "./secp256k1-D0CRzacO.mjs";
|
|
4
|
+
import * as Address from "ox/Address";
|
|
5
|
+
import * as TypedData from "ox/TypedData";
|
|
6
|
+
//#region ../../node_modules/.bun/@noble+hashes@2.4.0/node_modules/@noble/hashes/sha3.js
|
|
7
|
+
/**
|
|
8
|
+
* SHA3 (keccak) hash function, based on a new "Sponge function" design.
|
|
9
|
+
* Different from older hashes, the internal state is bigger than output size.
|
|
10
|
+
*
|
|
11
|
+
* Check out
|
|
12
|
+
* {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf | FIPS-202},
|
|
13
|
+
* {@link https://keccak.team/keccak.html | Website}, and
|
|
14
|
+
* {@link https://crypto.stackexchange.com/q/15727 | the differences between
|
|
15
|
+
* SHA-3 and Keccak}.
|
|
16
|
+
*
|
|
17
|
+
* Check out `sha3-addons` module for cSHAKE, k12, and others.
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
const _0n = BigInt(0);
|
|
21
|
+
const _1n = BigInt(1);
|
|
22
|
+
const _2n = BigInt(2);
|
|
23
|
+
const _7n = BigInt(7);
|
|
24
|
+
const _256n = BigInt(256);
|
|
25
|
+
const _0x71n = BigInt(113);
|
|
26
|
+
const SHA3_PI = [];
|
|
27
|
+
const SHA3_ROTL = [];
|
|
28
|
+
const _SHA3_IOTA = [];
|
|
29
|
+
for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
|
30
|
+
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
31
|
+
SHA3_PI.push(2 * (5 * y + x));
|
|
32
|
+
SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
|
|
33
|
+
let t = _0n;
|
|
34
|
+
for (let j = 0; j < 7; j++) {
|
|
35
|
+
R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
|
|
36
|
+
if (R & _2n) t ^= _1n << (_1n << BigInt(j)) - _1n;
|
|
37
|
+
}
|
|
38
|
+
_SHA3_IOTA.push(t);
|
|
39
|
+
}
|
|
40
|
+
const IOTAS = split(_SHA3_IOTA, true);
|
|
41
|
+
const SHA3_IOTA_H = IOTAS[0];
|
|
42
|
+
const SHA3_IOTA_L = IOTAS[1];
|
|
43
|
+
const rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
44
|
+
const rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
45
|
+
const rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
46
|
+
const rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
47
|
+
const rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
|
|
48
|
+
const rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
|
|
49
|
+
const B = /* @__PURE__ */ new Uint32Array(10);
|
|
50
|
+
/**
|
|
51
|
+
* `keccakf1600` internal permutation, additionally allows adjusting the round count.
|
|
52
|
+
* @param s - 5x5 Keccak state encoded as 25 lanes split into 50 uint32 words
|
|
53
|
+
* in this file's local little-endian lane-word order
|
|
54
|
+
* @param rounds - number of rounds to execute
|
|
55
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
56
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
57
|
+
* @throws If `rounds` is outside the supported `1..24` range. {@link Error}
|
|
58
|
+
* @example
|
|
59
|
+
* Permute a Keccak state with the default 24 rounds.
|
|
60
|
+
* ```ts
|
|
61
|
+
* keccakP(new Uint32Array(50));
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function keccakP(s, rounds = 24) {
|
|
65
|
+
if (!(s instanceof Uint32Array)) throw new TypeError("\"s\" expected Uint32Array(50), got type=" + typeof s);
|
|
66
|
+
if (s.length !== 50) throw new RangeError("\"s\" expected Uint32Array(50), got length=" + s.length);
|
|
67
|
+
anumber(rounds, "rounds");
|
|
68
|
+
if (rounds < 1 || rounds > 24) throw new Error("\"rounds\" expected integer 1..24");
|
|
69
|
+
for (let round = 24 - rounds; round < 24; round++) {
|
|
70
|
+
for (let x = 0; x < 10; x++) B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
71
|
+
for (let x = 0; x < 10; x += 2) {
|
|
72
|
+
const idx1 = (x + 8) % 10;
|
|
73
|
+
const idx0 = (x + 2) % 10;
|
|
74
|
+
const B0 = B[idx0];
|
|
75
|
+
const B1 = B[idx0 + 1];
|
|
76
|
+
const Th = rotlH(B0, B1, 1) ^ B[idx1];
|
|
77
|
+
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
|
|
78
|
+
for (let y = 0; y < 50; y += 10) {
|
|
79
|
+
s[x + y] ^= Th;
|
|
80
|
+
s[x + y + 1] ^= Tl;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let curH = s[2];
|
|
84
|
+
let curL = s[3];
|
|
85
|
+
for (let t = 0; t < 24; t++) {
|
|
86
|
+
const shift = SHA3_ROTL[t];
|
|
87
|
+
const Th = rotlH(curH, curL, shift);
|
|
88
|
+
const Tl = rotlL(curH, curL, shift);
|
|
89
|
+
const PI = SHA3_PI[t];
|
|
90
|
+
curH = s[PI];
|
|
91
|
+
curL = s[PI + 1];
|
|
92
|
+
s[PI] = Th;
|
|
93
|
+
s[PI + 1] = Tl;
|
|
94
|
+
}
|
|
95
|
+
for (let y = 0; y < 50; y += 10) {
|
|
96
|
+
const b0 = s[y], b1 = s[y + 1], b2 = s[y + 2], b3 = s[y + 3];
|
|
97
|
+
s[y] ^= ~s[y + 2] & s[y + 4];
|
|
98
|
+
s[y + 1] ^= ~s[y + 3] & s[y + 5];
|
|
99
|
+
s[y + 2] ^= ~s[y + 4] & s[y + 6];
|
|
100
|
+
s[y + 3] ^= ~s[y + 5] & s[y + 7];
|
|
101
|
+
s[y + 4] ^= ~s[y + 6] & s[y + 8];
|
|
102
|
+
s[y + 5] ^= ~s[y + 7] & s[y + 9];
|
|
103
|
+
s[y + 6] ^= ~s[y + 8] & b0;
|
|
104
|
+
s[y + 7] ^= ~s[y + 9] & b1;
|
|
105
|
+
s[y + 8] ^= ~b0 & b2;
|
|
106
|
+
s[y + 9] ^= ~b1 & b3;
|
|
107
|
+
}
|
|
108
|
+
s[0] ^= SHA3_IOTA_H[round];
|
|
109
|
+
s[1] ^= SHA3_IOTA_L[round];
|
|
110
|
+
}
|
|
111
|
+
clean(B);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Keccak sponge function.
|
|
115
|
+
* @param blockLen - absorb/squeeze rate in bytes
|
|
116
|
+
* @param suffix - domain separation suffix byte
|
|
117
|
+
* @param outputLen - default digest length in bytes. This base sponge only
|
|
118
|
+
* requires a non-negative integer; wrappers that need positive output
|
|
119
|
+
* lengths must enforce that themselves.
|
|
120
|
+
* @param enableXOF - whether XOF output is allowed
|
|
121
|
+
* @param rounds - number of Keccak-f rounds
|
|
122
|
+
* @example
|
|
123
|
+
* Build a sponge state, absorb bytes, then finalize a digest.
|
|
124
|
+
* ```ts
|
|
125
|
+
* const hash = new Keccak(136, 0x06, 32);
|
|
126
|
+
* hash.update(new Uint8Array([1, 2, 3]));
|
|
127
|
+
* hash.digest();
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
var Keccak = class Keccak {
|
|
131
|
+
state;
|
|
132
|
+
pos = 0;
|
|
133
|
+
posOut = 0;
|
|
134
|
+
finished = false;
|
|
135
|
+
state32;
|
|
136
|
+
destroyed = false;
|
|
137
|
+
blockLen;
|
|
138
|
+
suffix;
|
|
139
|
+
outputLen;
|
|
140
|
+
canXOF;
|
|
141
|
+
enableXOF = false;
|
|
142
|
+
rounds;
|
|
143
|
+
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
144
|
+
anumber(blockLen, "blockLen");
|
|
145
|
+
anumber(suffix, "suffix");
|
|
146
|
+
anumber(rounds, "rounds");
|
|
147
|
+
abool(enableXOF, "enableXOF");
|
|
148
|
+
this.blockLen = blockLen;
|
|
149
|
+
this.suffix = suffix;
|
|
150
|
+
this.outputLen = outputLen;
|
|
151
|
+
this.enableXOF = enableXOF;
|
|
152
|
+
this.canXOF = enableXOF;
|
|
153
|
+
this.rounds = rounds;
|
|
154
|
+
anumber(outputLen, "outputLen");
|
|
155
|
+
if (!(0 < blockLen && blockLen < 200)) throw new Error("\"blockLen\" must be 1..199");
|
|
156
|
+
this.state = /* @__PURE__ */ new Uint8Array(200);
|
|
157
|
+
this.state32 = u32(this.state);
|
|
158
|
+
}
|
|
159
|
+
clone() {
|
|
160
|
+
return this._cloneInto();
|
|
161
|
+
}
|
|
162
|
+
keccak() {
|
|
163
|
+
swap32IfBE(this.state32);
|
|
164
|
+
keccakP(this.state32, this.rounds);
|
|
165
|
+
swap32IfBE(this.state32);
|
|
166
|
+
this.posOut = 0;
|
|
167
|
+
this.pos = 0;
|
|
168
|
+
}
|
|
169
|
+
update(data) {
|
|
170
|
+
aexists(this);
|
|
171
|
+
abytes(data);
|
|
172
|
+
const { blockLen, state, state32 } = this;
|
|
173
|
+
const len = data.length;
|
|
174
|
+
const canUseU32 = blockLen % 4 === 0 && data.byteOffset % 4 === 0;
|
|
175
|
+
const blockLen32 = blockLen / 4;
|
|
176
|
+
const data32 = canUseU32 && len >= blockLen ? u32(data) : void 0;
|
|
177
|
+
for (let pos = 0; pos < len;) {
|
|
178
|
+
if (data32 !== void 0 && this.pos === 0 && pos % 4 === 0 && len - pos >= blockLen) {
|
|
179
|
+
for (let i = 0, o = pos / 4; i < blockLen32; i++) state32[i] ^= data32[o + i];
|
|
180
|
+
pos += blockLen;
|
|
181
|
+
this.pos = blockLen;
|
|
182
|
+
this.keccak();
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
186
|
+
for (let i = 0; i < take; i++) state[this.pos++] ^= data[pos++];
|
|
187
|
+
if (this.pos === blockLen) this.keccak();
|
|
188
|
+
}
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
finish() {
|
|
192
|
+
if (this.finished) return;
|
|
193
|
+
this.finished = true;
|
|
194
|
+
const { state, suffix, pos, blockLen } = this;
|
|
195
|
+
state[pos] ^= suffix;
|
|
196
|
+
if ((suffix & 128) !== 0 && pos === blockLen - 1) this.keccak();
|
|
197
|
+
state[blockLen - 1] ^= 128;
|
|
198
|
+
this.keccak();
|
|
199
|
+
}
|
|
200
|
+
writeInto(out) {
|
|
201
|
+
aexists(this, false);
|
|
202
|
+
abytes(out);
|
|
203
|
+
this.finish();
|
|
204
|
+
const bufferOut = this.state;
|
|
205
|
+
const { blockLen } = this;
|
|
206
|
+
for (let pos = 0, len = out.length; pos < len;) {
|
|
207
|
+
if (this.posOut >= blockLen) this.keccak();
|
|
208
|
+
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
209
|
+
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
210
|
+
this.posOut += take;
|
|
211
|
+
pos += take;
|
|
212
|
+
}
|
|
213
|
+
return out;
|
|
214
|
+
}
|
|
215
|
+
xofInto(out) {
|
|
216
|
+
if (!this.enableXOF) throw new Error("XOF is not enabled");
|
|
217
|
+
return this.writeInto(out);
|
|
218
|
+
}
|
|
219
|
+
xof(bytes) {
|
|
220
|
+
anumber(bytes);
|
|
221
|
+
return this.xofInto(new Uint8Array(bytes));
|
|
222
|
+
}
|
|
223
|
+
digestInto(out) {
|
|
224
|
+
aoutput(out, this);
|
|
225
|
+
if (this.finished) throw new Error("digest() was already called");
|
|
226
|
+
this.writeInto(out.length === this.outputLen ? out : out.subarray(0, this.outputLen));
|
|
227
|
+
this.destroy();
|
|
228
|
+
}
|
|
229
|
+
digest() {
|
|
230
|
+
const out = new Uint8Array(this.outputLen);
|
|
231
|
+
this.digestInto(out);
|
|
232
|
+
return out;
|
|
233
|
+
}
|
|
234
|
+
destroy() {
|
|
235
|
+
this.destroyed = true;
|
|
236
|
+
clean(this.state);
|
|
237
|
+
}
|
|
238
|
+
_cloneInto(to) {
|
|
239
|
+
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
240
|
+
to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds);
|
|
241
|
+
to.blockLen = blockLen;
|
|
242
|
+
to.state32.set(this.state32);
|
|
243
|
+
to.pos = this.pos;
|
|
244
|
+
to.posOut = this.posOut;
|
|
245
|
+
to.finished = this.finished;
|
|
246
|
+
to.rounds = rounds;
|
|
247
|
+
to.suffix = suffix;
|
|
248
|
+
to.outputLen = outputLen;
|
|
249
|
+
to.enableXOF = enableXOF;
|
|
250
|
+
to.canXOF = this.canXOF;
|
|
251
|
+
to.destroyed = this.destroyed;
|
|
252
|
+
return to;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
const genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info);
|
|
256
|
+
/**
|
|
257
|
+
* Keccak-256 hash function. Different from SHA3-256.
|
|
258
|
+
* @param msg - message bytes to hash
|
|
259
|
+
* @param opts - Reserved hash options.
|
|
260
|
+
* @returns Digest bytes.
|
|
261
|
+
* @example
|
|
262
|
+
* Hash a message with Keccak-256.
|
|
263
|
+
* ```ts
|
|
264
|
+
* keccak_256(new Uint8Array([97, 98, 99]));
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
const keccak_256 = /* @__PURE__ */ genKeccak(1, 136, 32);
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/evm/address.ts
|
|
270
|
+
/** EIP-55 checksummed address, e.g. `0x52908400098527886E0F7030069857D2E4169EE7`. */
|
|
271
|
+
const isEvmAddress = (value) => /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
272
|
+
function checksumEvmAddress(address) {
|
|
273
|
+
if (!isEvmAddress(address)) throw new ChainError("invalid-address", "not an EVM address");
|
|
274
|
+
const checksummed = Address.checksum(address);
|
|
275
|
+
Address.assert(checksummed, { strict: true });
|
|
276
|
+
return checksummed;
|
|
277
|
+
}
|
|
278
|
+
/** `keccak256(pubkey)[12:]` — accepts a 33-byte compressed or 65-byte uncompressed secp256k1 key. */
|
|
279
|
+
function evmAddressFromPublicKey(pubkey) {
|
|
280
|
+
const uncompressed = pubkey.length === 65 && pubkey[0] === 4 ? pubkey : pubkey.length === 33 ? secp256k1.Point.fromBytes(pubkey).toBytes(false) : void 0;
|
|
281
|
+
if (uncompressed === void 0 || uncompressed[0] !== 4) throw new ChainError("invalid-address", "expected a compressed or uncompressed secp256k1 key");
|
|
282
|
+
return checksumEvmAddress(`0x${bytesToHex(keccak_256(uncompressed.subarray(1))).slice(-40)}`);
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/evm/transaction.ts
|
|
286
|
+
/** Validates a string is `0x`-hex and narrows it to the branded hex type. */
|
|
287
|
+
function assertHex(value, field) {
|
|
288
|
+
if (!/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) throw new ChainError("invalid-quantity", `${field} must be 0x-prefixed bytes`);
|
|
289
|
+
}
|
|
290
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
291
|
+
const CANONICAL_HEX = /^0x(?:0|[1-9a-f][0-9a-f]*)$/;
|
|
292
|
+
const isCanonicalHex = (value) => CANONICAL_HEX.test(value);
|
|
293
|
+
const canonicalHex = (value) => `0x${value.toString(16)}`;
|
|
294
|
+
const safeInteger = (value, field) => {
|
|
295
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) throw new ChainError("invalid-quantity", `${field} must be a non-negative safe integer`);
|
|
296
|
+
return value;
|
|
297
|
+
};
|
|
298
|
+
const quantity = (value, field) => {
|
|
299
|
+
if (typeof value !== "string") throw new ChainError("invalid-quantity", `${field} must be a 0x quantity string`);
|
|
300
|
+
if (CANONICAL_HEX.test(value)) return value;
|
|
301
|
+
if (/^0x[0-9a-fA-F]+$/.test(value) || value === "0x") return canonicalHex(BigInt(value === "0x" ? "0x0" : value));
|
|
302
|
+
throw new ChainError("invalid-quantity", `${field} must be a 0x quantity`);
|
|
303
|
+
};
|
|
304
|
+
const hexBytes = (value, field) => {
|
|
305
|
+
if (typeof value !== "string" || !/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) throw new ChainError("invalid-quantity", `${field} must be 0x-prefixed bytes`);
|
|
306
|
+
return value.toLowerCase();
|
|
307
|
+
};
|
|
308
|
+
const accessList = (value) => {
|
|
309
|
+
if (!Array.isArray(value)) throw new ChainError("invalid-request", "accessList must be an array");
|
|
310
|
+
return value.map((entry) => {
|
|
311
|
+
if (!isRecord(entry)) throw new ChainError("invalid-address", "accessList entries must be objects");
|
|
312
|
+
const keys = Object.keys(entry).sort();
|
|
313
|
+
if (keys.length !== 2 || keys[0] !== "address" || keys[1] !== "storageKeys") throw new ChainError("unknown-field", `accessList entry fields must be exactly address+storageKeys, got ${keys.join(",")}`);
|
|
314
|
+
const { address, storageKeys } = entry;
|
|
315
|
+
if (typeof address !== "string" || !isEvmAddress(address)) throw new ChainError("invalid-address", "accessList entry has an invalid address");
|
|
316
|
+
if (!Array.isArray(storageKeys)) throw new ChainError("invalid-quantity", "accessList storageKeys must be an array");
|
|
317
|
+
return {
|
|
318
|
+
address: checksumEvmAddress(address),
|
|
319
|
+
storageKeys: storageKeys.map((k) => {
|
|
320
|
+
if (typeof k !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(k)) throw new ChainError("invalid-quantity", "accessList storageKeys must be 32-byte hex strings");
|
|
321
|
+
return k.toLowerCase();
|
|
322
|
+
})
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
/** The EIP-155 part of a CAIP-2 `network` string, e.g. `eip155:1` → 1. */
|
|
327
|
+
const networkChainId = (network) => {
|
|
328
|
+
const idPart = /^eip155:(\d+)$/.exec(network)?.[1];
|
|
329
|
+
if (idPart === void 0) throw new ChainError("chain-id-mismatch", `network is not an eip155 CAIP-2 id: ${network}`);
|
|
330
|
+
const id = Number(idPart);
|
|
331
|
+
if (!Number.isSafeInteger(id)) throw new ChainError("chain-id-mismatch", `chain id is not a safe integer: ${network}`);
|
|
332
|
+
return id;
|
|
333
|
+
};
|
|
334
|
+
const REQUIRED = {
|
|
335
|
+
base: [
|
|
336
|
+
"chainId",
|
|
337
|
+
"nonce",
|
|
338
|
+
"gas",
|
|
339
|
+
"value",
|
|
340
|
+
"data"
|
|
341
|
+
],
|
|
342
|
+
gasPrice: ["gasPrice"],
|
|
343
|
+
accessList: ["accessList"],
|
|
344
|
+
eip1559: ["maxFeePerGas", "maxPriorityFeePerGas"]
|
|
345
|
+
};
|
|
346
|
+
const ALLOWED = {
|
|
347
|
+
base: [
|
|
348
|
+
"type",
|
|
349
|
+
"chainId",
|
|
350
|
+
"nonce",
|
|
351
|
+
"gas",
|
|
352
|
+
"value",
|
|
353
|
+
"data",
|
|
354
|
+
"to"
|
|
355
|
+
],
|
|
356
|
+
legacy: ["gasPrice"],
|
|
357
|
+
eip2930: ["gasPrice", "accessList"],
|
|
358
|
+
eip1559: [
|
|
359
|
+
"accessList",
|
|
360
|
+
"maxFeePerGas",
|
|
361
|
+
"maxPriorityFeePerGas"
|
|
362
|
+
]
|
|
363
|
+
};
|
|
364
|
+
const requireFields = (input, fields) => {
|
|
365
|
+
for (const field of fields) if (input[field] === void 0) throw new ChainError("invalid-request", `tx.${field} is required`);
|
|
366
|
+
};
|
|
367
|
+
const rejectUnknown = (input, type) => {
|
|
368
|
+
const allowed = /* @__PURE__ */ new Set([...ALLOWED.base, ...ALLOWED[type]]);
|
|
369
|
+
const unknown = Object.keys(input).filter((k) => !allowed.has(k));
|
|
370
|
+
if (unknown.length > 0) throw new ChainError("unknown-field", `tx has unknown fields for ${type}: ${unknown.sort().join(", ")}`);
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
373
|
+
* Canonicalizes an EVM transaction: exact key sets per type, all required fields present, `0x`
|
|
374
|
+
* canonical quantities, EIP-55 addresses. Idempotent.
|
|
375
|
+
*/
|
|
376
|
+
const normalizeEvmTransaction = (tx) => {
|
|
377
|
+
if (!isRecord(tx)) throw new ChainError("invalid-request", "tx must be an object");
|
|
378
|
+
const { type } = tx;
|
|
379
|
+
if (type !== "legacy" && type !== "eip2930" && type !== "eip1559") throw new ChainError("unsupported", `transaction type ${String(type)} is not supported (legacy, eip2930 and eip1559 only)`);
|
|
380
|
+
rejectUnknown(tx, type);
|
|
381
|
+
requireFields(tx, REQUIRED.base);
|
|
382
|
+
const chainId = safeInteger(tx["chainId"], "chainId");
|
|
383
|
+
const nonce = safeInteger(tx["nonce"], "nonce");
|
|
384
|
+
const gas = quantity(tx["gas"], "gas");
|
|
385
|
+
const value = quantity(tx["value"], "value");
|
|
386
|
+
const data = hexBytes(tx["data"], "data");
|
|
387
|
+
const toRaw = tx["to"];
|
|
388
|
+
const to = toRaw === void 0 ? void 0 : typeof toRaw === "string" && isEvmAddress(toRaw) ? checksumEvmAddress(toRaw) : void 0;
|
|
389
|
+
if (toRaw !== void 0 && to === void 0) throw new ChainError("invalid-address", "to must be a valid EVM address");
|
|
390
|
+
const base = {
|
|
391
|
+
chainId,
|
|
392
|
+
nonce,
|
|
393
|
+
gas,
|
|
394
|
+
value,
|
|
395
|
+
data,
|
|
396
|
+
...to === void 0 ? {} : { to }
|
|
397
|
+
};
|
|
398
|
+
if (type === "legacy") {
|
|
399
|
+
requireFields(tx, REQUIRED.gasPrice);
|
|
400
|
+
return {
|
|
401
|
+
type,
|
|
402
|
+
...base,
|
|
403
|
+
gasPrice: quantity(tx["gasPrice"], "gasPrice")
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
if (type === "eip2930") {
|
|
407
|
+
requireFields(tx, [...REQUIRED.gasPrice, ...REQUIRED.accessList]);
|
|
408
|
+
return {
|
|
409
|
+
type,
|
|
410
|
+
...base,
|
|
411
|
+
gasPrice: quantity(tx["gasPrice"], "gasPrice"),
|
|
412
|
+
accessList: accessList(tx["accessList"])
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
requireFields(tx, [...REQUIRED.accessList, ...REQUIRED.eip1559]);
|
|
416
|
+
return {
|
|
417
|
+
type,
|
|
418
|
+
...base,
|
|
419
|
+
accessList: accessList(tx["accessList"]),
|
|
420
|
+
maxFeePerGas: quantity(tx["maxFeePerGas"], "maxFeePerGas"),
|
|
421
|
+
maxPriorityFeePerGas: quantity(tx["maxPriorityFeePerGas"], "maxPriorityFeePerGas")
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/evm/typed-data.ts
|
|
426
|
+
const isField = (value) => isRecord(value) && typeof value["name"] === "string" && typeof value["type"] === "string";
|
|
427
|
+
const isTypedDataInput = (value) => {
|
|
428
|
+
if (!isRecord(value)) return false;
|
|
429
|
+
const { types, primaryType, domain, message } = value;
|
|
430
|
+
if (!isRecord(types)) return false;
|
|
431
|
+
if (typeof primaryType !== "string" || primaryType === "") return false;
|
|
432
|
+
if (!isRecord(domain)) return false;
|
|
433
|
+
if (!isRecord(message)) return false;
|
|
434
|
+
return Object.values(types).every((fields) => Array.isArray(fields) && fields.every(isField));
|
|
435
|
+
};
|
|
436
|
+
/** Parses the EIP-712 JSON source and validates its shape with ox. */
|
|
437
|
+
const parseTypedData = (typedData, network) => {
|
|
438
|
+
let json;
|
|
439
|
+
try {
|
|
440
|
+
json = JSON.parse(typedData);
|
|
441
|
+
} catch {
|
|
442
|
+
throw new ChainError("invalid-typed-data", "typedData is not valid JSON");
|
|
443
|
+
}
|
|
444
|
+
if (!isTypedDataInput(json)) throw new ChainError("invalid-typed-data", "typedData must be a JSON object with types, primaryType, domain and message");
|
|
445
|
+
try {
|
|
446
|
+
TypedData.validate(json);
|
|
447
|
+
} catch {
|
|
448
|
+
throw new ChainError("invalid-typed-data", "typedData failed EIP-712 validation");
|
|
449
|
+
}
|
|
450
|
+
const { chainId } = json.domain;
|
|
451
|
+
const numeric = typeof chainId === "number" ? chainId : typeof chainId === "string" ? Number(chainId) : NaN;
|
|
452
|
+
return {
|
|
453
|
+
json,
|
|
454
|
+
chainIdMismatch: Number.isSafeInteger(numeric) && numeric !== networkChainId(network)
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
const typedDataWarnings = (parsed) => parsed.chainIdMismatch ? [{
|
|
458
|
+
kind: "chain-id-mismatch",
|
|
459
|
+
message: "typed-data domain.chainId does not match the request network"
|
|
460
|
+
}] : [];
|
|
461
|
+
//#endregion
|
|
462
|
+
export { isCanonicalHex as a, normalizeEvmTransaction as c, isEvmAddress as d, canonicalHex as i, checksumEvmAddress as l, typedDataWarnings as n, isRecord as o, assertHex as r, networkChainId as s, parseTypedData as t, evmAddressFromPublicKey as u };
|
|
463
|
+
|
|
464
|
+
//# sourceMappingURL=typed-data-D28VBOIm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-data-D28VBOIm.mjs","names":[],"sources":["../../../node_modules/.bun/@noble+hashes@2.4.0/node_modules/@noble/hashes/sha3.js","../src/evm/address.ts","../src/evm/transaction.ts","../src/evm/typed-data.ts"],"sourcesContent":["/**\n * SHA3 (keccak) hash function, based on a new \"Sponge function\" design.\n * Different from older hashes, the internal state is bigger than output size.\n *\n * Check out\n * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf | FIPS-202},\n * {@link https://keccak.team/keccak.html | Website}, and\n * {@link https://crypto.stackexchange.com/q/15727 | the differences between\n * SHA-3 and Keccak}.\n *\n * Check out `sha3-addons` module for cSHAKE, k12, and others.\n * @module\n */\nimport { split } from \"./_u64.js\";\n// prettier-ignore\nimport { abool, abytes, aexists, anumber, aoutput, checkOpts, clean, createHasher, oidNist, swap32IfBE, u32 } from \"./utils.js\";\n// No __PURE__ annotations in sha3 header:\n// EVERYTHING is in fact used on every export.\n// Various per round constants calculations\nconst _0n = BigInt(0);\nconst _1n = BigInt(1);\nconst _2n = BigInt(2);\nconst _7n = BigInt(7);\nconst _256n = BigInt(256);\n// FIPS 202 Algorithm 5 rc(): when the outgoing bit is 1, the 8-bit LFSR xors\n// taps 0, 4, 5, and 6, which compresses to the feedback mask `0x71`.\nconst _0x71n = BigInt(0x71);\nconst SHA3_PI = [];\nconst SHA3_ROTL = [];\nconst _SHA3_IOTA = []; // no pure annotation: var is always used\nfor (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {\n // Pi\n [x, y] = [y, (2 * x + 3 * y) % 5];\n SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);\n // Iota\n let t = _0n;\n for (let j = 0; j < 7; j++) {\n R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;\n if (R & _2n)\n t ^= _1n << ((_1n << BigInt(j)) - _1n);\n }\n _SHA3_IOTA.push(t);\n}\nconst IOTAS = split(_SHA3_IOTA, true);\n// `split(..., true)` keeps the local little-endian lane-word layout used by\n// `state32`, so these `H` / `L` tables follow the file's first-word /\n// second-word lane slots rather than `_u64.ts`'s usual high/low naming.\nconst SHA3_IOTA_H = IOTAS[0];\nconst SHA3_IOTA_L = IOTAS[1];\n// 64-bit left rotates as u32 pairs. Inlined here (not imported from _u64) so V8 can\n// inline them into keccakP — the import path costs ~24% on sha3_256. SHA3 is the only\n// consumer of left-rotates; other hashes use right-rotates from _u64.\n// Valid for s in 1..31 (SH/SL) and 33..63 (BH/BL); keccak never rotates by 0/32/64.\nconst rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));\nconst rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));\nconst rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));\nconst rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));\nconst rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));\nconst rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));\n// Reused Theta scratch buffer (column parities), same pattern as SHA256_W in sha2.\n// keccakP never calls user code, so the shared buffer cannot be observed mid-permutation.\nconst B = new Uint32Array(5 * 2);\n/**\n * `keccakf1600` internal permutation, additionally allows adjusting the round count.\n * @param s - 5x5 Keccak state encoded as 25 lanes split into 50 uint32 words\n * in this file's local little-endian lane-word order\n * @param rounds - number of rounds to execute\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @throws If `rounds` is outside the supported `1..24` range. {@link Error}\n * @example\n * Permute a Keccak state with the default 24 rounds.\n * ```ts\n * keccakP(new Uint32Array(50));\n * ```\n */\nexport function keccakP(s, rounds = 24) {\n if (!(s instanceof Uint32Array))\n throw new TypeError('\"s\" expected Uint32Array(50), got type=' + typeof s);\n if (s.length !== 50)\n throw new RangeError('\"s\" expected Uint32Array(50), got length=' + s.length);\n anumber(rounds, 'rounds');\n // This implementation precomputes only the standard Keccak-f[1600] 24-round Iota table.\n if (rounds < 1 || rounds > 24)\n throw new Error('\"rounds\" expected integer 1..24');\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for (let round = 24 - rounds; round < 24; round++) {\n // Theta θ\n for (let x = 0; x < 10; x++)\n B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for (let x = 0; x < 10; x += 2) {\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for (let y = 0; y < 50; y += 10) {\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for (let t = 0; t < 24; t++) {\n const shift = SHA3_ROTL[t];\n const Th = rotlH(curH, curL, shift);\n const Tl = rotlL(curH, curL, shift);\n const PI = SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n // Same as:\n // for (let x = 0; x < 10; x++) B[x] = s[y + x];\n // for (let x = 0; x < 10; x++) s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n for (let y = 0; y < 50; y += 10) {\n const b0 = s[y], b1 = s[y + 1], b2 = s[y + 2], b3 = s[y + 3];\n s[y] ^= ~s[y + 2] & s[y + 4];\n s[y + 1] ^= ~s[y + 3] & s[y + 5];\n s[y + 2] ^= ~s[y + 4] & s[y + 6];\n s[y + 3] ^= ~s[y + 5] & s[y + 7];\n s[y + 4] ^= ~s[y + 6] & s[y + 8];\n s[y + 5] ^= ~s[y + 7] & s[y + 9];\n s[y + 6] ^= ~s[y + 8] & b0;\n s[y + 7] ^= ~s[y + 9] & b1;\n s[y + 8] ^= ~b0 & b2;\n s[y + 9] ^= ~b1 & b3;\n }\n // Iota (ι)\n s[0] ^= SHA3_IOTA_H[round];\n s[1] ^= SHA3_IOTA_L[round];\n }\n clean(B);\n}\n/**\n * Keccak sponge function.\n * @param blockLen - absorb/squeeze rate in bytes\n * @param suffix - domain separation suffix byte\n * @param outputLen - default digest length in bytes. This base sponge only\n * requires a non-negative integer; wrappers that need positive output\n * lengths must enforce that themselves.\n * @param enableXOF - whether XOF output is allowed\n * @param rounds - number of Keccak-f rounds\n * @example\n * Build a sponge state, absorb bytes, then finalize a digest.\n * ```ts\n * const hash = new Keccak(136, 0x06, 32);\n * hash.update(new Uint8Array([1, 2, 3]));\n * hash.digest();\n * ```\n */\nexport class Keccak {\n state;\n pos = 0;\n posOut = 0;\n finished = false;\n state32;\n destroyed = false;\n blockLen;\n suffix;\n outputLen;\n canXOF;\n enableXOF = false;\n rounds;\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {\n anumber(blockLen, 'blockLen');\n anumber(suffix, 'suffix');\n anumber(rounds, 'rounds');\n abool(enableXOF, 'enableXOF');\n this.blockLen = blockLen;\n this.suffix = suffix;\n this.outputLen = outputLen;\n this.enableXOF = enableXOF;\n this.canXOF = enableXOF;\n this.rounds = rounds;\n // Can be passed from user as dkLen\n anumber(outputLen, 'outputLen');\n // Only keccak-f1600 is supported: 1600 bits (5x5 matrix of 64bit) === 200 bytes of state.\n if (!(0 < blockLen && blockLen < 200))\n throw new Error('\"blockLen\" must be 1..199');\n this.state = new Uint8Array(200);\n this.state32 = u32(this.state);\n }\n clone() {\n return this._cloneInto();\n }\n keccak() {\n swap32IfBE(this.state32);\n keccakP(this.state32, this.rounds);\n swap32IfBE(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data) {\n aexists(this);\n abytes(data);\n const { blockLen, state, state32 } = this;\n const len = data.length;\n // Absorb full blocks with u32 XORs when both sides are 4-byte aligned.\n // XOR of same-position words equals XOR of same-position bytes, so this is endianness-safe.\n const canUseU32 = blockLen % 4 === 0 && data.byteOffset % 4 === 0;\n const blockLen32 = blockLen / 4;\n const data32 = canUseU32 && len >= blockLen ? u32(data) : undefined;\n for (let pos = 0; pos < len;) {\n if (data32 !== undefined && this.pos === 0 && pos % 4 === 0 && len - pos >= blockLen) {\n for (let i = 0, o = pos / 4; i < blockLen32; i++)\n state32[i] ^= data32[o + i];\n pos += blockLen;\n // Subclasses (_KeccakPRG) read `this.pos` inside their `keccak()` override,\n // so it must reflect the fully-absorbed block before the permutation fires.\n this.pos = blockLen;\n this.keccak();\n continue;\n }\n const take = Math.min(blockLen - this.pos, len - pos);\n for (let i = 0; i < take; i++)\n state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen)\n this.keccak();\n }\n return this;\n }\n finish() {\n if (this.finished)\n return;\n this.finished = true;\n const { state, suffix, pos, blockLen } = this;\n // FIPS 202 appends the SHA3/SHAKE domain-separation suffix before pad10*1.\n // These byte values already include the first padding bit, while the\n // final `0x80` below supplies the closing `1` bit in the last rate byte.\n state[pos] ^= suffix;\n // If that combined suffix lands in the last rate byte and already sets\n // bit 7, absorb it first so the final pad10*1 bit can be xored into a\n // fresh block.\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1)\n this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n writeInto(out) {\n aexists(this, false);\n abytes(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen } = this;\n for (let pos = 0, len = out.length; pos < len;) {\n if (this.posOut >= blockLen)\n this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out;\n }\n xofInto(out) {\n // Plain SHA3/Keccak usage with XOF is probably a mistake, but this base\n // class is also reused by SHAKE/cSHAKE/KMAC/TupleHash/ParallelHash/\n // TurboSHAKE/KangarooTwelve wrappers that intentionally enable XOF.\n if (!this.enableXOF)\n throw new Error('XOF is not enabled');\n return this.writeInto(out);\n }\n xof(bytes) {\n anumber(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out) {\n aoutput(out, this);\n if (this.finished)\n throw new Error('digest() was already called');\n // `aoutput(...)` allows oversized buffers; digestInto() must fill only the advertised digest.\n this.writeInto(out.length === this.outputLen ? out : out.subarray(0, this.outputLen));\n this.destroy();\n }\n digest() {\n const out = new Uint8Array(this.outputLen);\n this.digestInto(out);\n return out;\n }\n destroy() {\n this.destroyed = true;\n clean(this.state);\n }\n _cloneInto(to) {\n const { blockLen, suffix, outputLen, rounds, enableXOF } = this;\n to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds);\n // Reused destinations can come from a different rate/capacity variant, so clone must rewrite\n // the sponge geometry as well as the state words.\n to.blockLen = blockLen;\n to.state32.set(this.state32);\n // Sponge padding and XOF output are positional, so both offsets are part of the clone state.\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n // Clones must preserve the public capability bit too; `_KMAC` reuses this path and deep clone\n // tests compare instance fields directly, so leaving `canXOF` behind makes the clone lie.\n to.canXOF = this.canXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\nconst genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info);\n/**\n * SHA3-224 hash function.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA3-224.\n * ```ts\n * sha3_224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha3_224 = /* @__PURE__ */ genKeccak(0x06, 144, 28, \n/* @__PURE__ */ oidNist(0x07));\n/**\n * SHA3-256 hash function. Different from keccak-256.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA3-256.\n * ```ts\n * sha3_256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha3_256 = /* @__PURE__ */ genKeccak(0x06, 136, 32, \n/* @__PURE__ */ oidNist(0x08));\n/**\n * SHA3-384 hash function.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA3-384.\n * ```ts\n * sha3_384(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha3_384 = /* @__PURE__ */ genKeccak(0x06, 104, 48, \n/* @__PURE__ */ oidNist(0x09));\n/**\n * SHA3-512 hash function.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA3-512.\n * ```ts\n * sha3_512(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha3_512 = /* @__PURE__ */ genKeccak(0x06, 72, 64, \n/* @__PURE__ */ oidNist(0x0a));\n/**\n * Keccak-224 hash function.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with Keccak-224.\n * ```ts\n * keccak_224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const keccak_224 = /* @__PURE__ */ genKeccak(0x01, 144, 28);\n/**\n * Keccak-256 hash function. Different from SHA3-256.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with Keccak-256.\n * ```ts\n * keccak_256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const keccak_256 = /* @__PURE__ */ genKeccak(0x01, 136, 32);\n/**\n * Keccak-384 hash function.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with Keccak-384.\n * ```ts\n * keccak_384(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const keccak_384 = /* @__PURE__ */ genKeccak(0x01, 104, 48);\n/**\n * Keccak-512 hash function.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with Keccak-512.\n * ```ts\n * keccak_512(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const keccak_512 = /* @__PURE__ */ genKeccak(0x01, 72, 64);\nconst genShake = (suffix, blockLen, outputLen, info = {}) => createHasher((opts = {}) => {\n opts = checkOpts({}, opts);\n return new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true);\n}, info);\n/**\n * SHAKE128 XOF with 128-bit security and a 16-byte default output.\n * @param msg - message bytes to hash\n * @param opts - Optional output-length override. See {@link ShakeOpts}.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHAKE128.\n * ```ts\n * shake128(new Uint8Array([97, 98, 99]), { dkLen: 32 });\n * ```\n */\nexport const shake128 = \n/* @__PURE__ */\ngenShake(0x1f, 168, 16, /* @__PURE__ */ oidNist(0x0b));\n/**\n * SHAKE256 XOF with 256-bit security and a 32-byte default output.\n * @param msg - message bytes to hash\n * @param opts - Optional output-length override. See {@link ShakeOpts}.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHAKE256.\n * ```ts\n * shake256(new Uint8Array([97, 98, 99]), { dkLen: 64 });\n * ```\n */\nexport const shake256 = \n/* @__PURE__ */\ngenShake(0x1f, 136, 32, /* @__PURE__ */ oidNist(0x0c));\n/**\n * SHAKE128 XOF with 256-bit output (NIST version).\n * @param msg - message bytes to hash\n * @param opts - Optional output-length override. See {@link ShakeOpts}.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHAKE128 using a 32-byte default output.\n * ```ts\n * shake128_32(new Uint8Array([97, 98, 99]), { dkLen: 32 });\n * ```\n */\nexport const shake128_32 = \n/* @__PURE__ */\ngenShake(0x1f, 168, 32, /* @__PURE__ */ oidNist(0x0b));\n/**\n * SHAKE256 XOF with 512-bit output (NIST version).\n * @param msg - message bytes to hash\n * @param opts - Optional output-length override. See {@link ShakeOpts}.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHAKE256 using a 64-byte default output.\n * ```ts\n * shake256_64(new Uint8Array([97, 98, 99]), { dkLen: 64 });\n * ```\n */\nexport const shake256_64 = \n/* @__PURE__ */\ngenShake(0x1f, 136, 64, /* @__PURE__ */ oidNist(0x0c));\n","import { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport { keccak_256 } from \"@noble/hashes/sha3.js\";\nimport { bytesToHex } from \"@noble/hashes/utils.js\";\nimport * as Address from \"ox/Address\";\n\nimport { ChainError } from \"../index.ts\";\n\n/** EIP-55 checksummed address, e.g. `0x52908400098527886E0F7030069857D2E4169EE7`. */\nexport const isEvmAddress = (value: string): boolean => /^0x[0-9a-fA-F]{40}$/.test(value);\n\nexport function checksumEvmAddress(address: string): string {\n if (!isEvmAddress(address)) {\n throw new ChainError(\"invalid-address\", \"not an EVM address\");\n }\n const checksummed = Address.checksum(address);\n Address.assert(checksummed, { strict: true });\n return checksummed;\n}\n\n/** `keccak256(pubkey)[12:]` — accepts a 33-byte compressed or 65-byte uncompressed secp256k1 key. */\nexport function evmAddressFromPublicKey(pubkey: Uint8Array): string {\n const uncompressed =\n pubkey.length === 65 && pubkey[0] === 4\n ? pubkey\n : pubkey.length === 33\n ? secp256k1.Point.fromBytes(pubkey).toBytes(false)\n : undefined;\n if (uncompressed === undefined || uncompressed[0] !== 4) {\n throw new ChainError(\"invalid-address\", \"expected a compressed or uncompressed secp256k1 key\");\n }\n return checksumEvmAddress(`0x${bytesToHex(keccak_256(uncompressed.subarray(1))).slice(-40)}`);\n}\n","import { ChainError } from \"../index.ts\";\nimport type { EvmTransaction, EvmAccessListEntry } from \"../index.ts\";\nimport { checksumEvmAddress, isEvmAddress } from \"./address.ts\";\n\n/** Validates a string is `0x`-hex and narrows it to the branded hex type. */\nexport function assertHex(value: string, field: string): asserts value is `0x${string}` {\n if (!/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) {\n throw new ChainError(\"invalid-quantity\", `${field} must be 0x-prefixed bytes`);\n }\n}\n\nexport const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst CANONICAL_HEX = /^0x(?:0|[1-9a-f][0-9a-f]*)$/;\n\nexport const isCanonicalHex = (value: string): boolean => CANONICAL_HEX.test(value);\n\nexport const canonicalHex = (value: bigint): string => `0x${value.toString(16)}`;\n\nconst safeInteger = (value: unknown, field: string): number => {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0) {\n throw new ChainError(\"invalid-quantity\", `${field} must be a non-negative safe integer`);\n }\n return value;\n};\n\nconst quantity = (value: unknown, field: string): string => {\n if (typeof value !== \"string\") {\n throw new ChainError(\"invalid-quantity\", `${field} must be a 0x quantity string`);\n }\n if (CANONICAL_HEX.test(value)) {\n return value;\n }\n if (/^0x[0-9a-fA-F]+$/.test(value) || value === \"0x\") {\n return canonicalHex(BigInt(value === \"0x\" ? \"0x0\" : value));\n }\n throw new ChainError(\"invalid-quantity\", `${field} must be a 0x quantity`);\n};\n\nconst hexBytes = (value: unknown, field: string): string => {\n if (typeof value !== \"string\" || !/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) {\n throw new ChainError(\"invalid-quantity\", `${field} must be 0x-prefixed bytes`);\n }\n return value.toLowerCase();\n};\n\nconst accessList = (value: unknown): ReadonlyArray<EvmAccessListEntry> => {\n if (!Array.isArray(value)) {\n throw new ChainError(\"invalid-request\", \"accessList must be an array\");\n }\n return value.map((entry): EvmAccessListEntry => {\n if (!isRecord(entry)) {\n throw new ChainError(\"invalid-address\", \"accessList entries must be objects\");\n }\n const keys = Object.keys(entry).sort();\n if (keys.length !== 2 || keys[0] !== \"address\" || keys[1] !== \"storageKeys\") {\n throw new ChainError(\n \"unknown-field\",\n `accessList entry fields must be exactly address+storageKeys, got ${keys.join(\",\")}`,\n );\n }\n const { address, storageKeys } = entry;\n if (typeof address !== \"string\" || !isEvmAddress(address)) {\n throw new ChainError(\"invalid-address\", \"accessList entry has an invalid address\");\n }\n if (!Array.isArray(storageKeys)) {\n throw new ChainError(\"invalid-quantity\", \"accessList storageKeys must be an array\");\n }\n return {\n address: checksumEvmAddress(address),\n storageKeys: storageKeys.map((k) => {\n if (typeof k !== \"string\" || !/^0x[0-9a-fA-F]{64}$/.test(k)) {\n throw new ChainError(\n \"invalid-quantity\",\n \"accessList storageKeys must be 32-byte hex strings\",\n );\n }\n return k.toLowerCase();\n }),\n };\n });\n};\n\n/** The EIP-155 part of a CAIP-2 `network` string, e.g. `eip155:1` → 1. */\nexport const networkChainId = (network: string): number => {\n const match = /^eip155:(\\d+)$/.exec(network);\n const idPart = match?.[1];\n if (idPart === undefined) {\n throw new ChainError(\"chain-id-mismatch\", `network is not an eip155 CAIP-2 id: ${network}`);\n }\n const id = Number(idPart);\n if (!Number.isSafeInteger(id)) {\n throw new ChainError(\"chain-id-mismatch\", `chain id is not a safe integer: ${network}`);\n }\n return id;\n};\n\nconst REQUIRED = {\n base: [\"chainId\", \"nonce\", \"gas\", \"value\", \"data\"],\n gasPrice: [\"gasPrice\"],\n accessList: [\"accessList\"],\n eip1559: [\"maxFeePerGas\", \"maxPriorityFeePerGas\"],\n} as const;\n\nconst ALLOWED = {\n base: [\"type\", \"chainId\", \"nonce\", \"gas\", \"value\", \"data\", \"to\"],\n legacy: [\"gasPrice\"],\n eip2930: [\"gasPrice\", \"accessList\"],\n eip1559: [\"accessList\", \"maxFeePerGas\", \"maxPriorityFeePerGas\"],\n} as const;\n\nconst requireFields = (input: Record<string, unknown>, fields: ReadonlyArray<string>): void => {\n for (const field of fields) {\n if (input[field] === undefined) {\n throw new ChainError(\"invalid-request\", `tx.${field} is required`);\n }\n }\n};\n\nconst rejectUnknown = (\n input: Record<string, unknown>,\n type: \"legacy\" | \"eip2930\" | \"eip1559\",\n): void => {\n const allowed = new Set<string>([...ALLOWED.base, ...ALLOWED[type]]);\n const unknown = Object.keys(input).filter((k) => !allowed.has(k));\n if (unknown.length > 0) {\n throw new ChainError(\n \"unknown-field\",\n `tx has unknown fields for ${type}: ${unknown.sort().join(\", \")}`,\n );\n }\n};\n\n/**\n * Canonicalizes an EVM transaction: exact key sets per type, all required fields present, `0x`\n * canonical quantities, EIP-55 addresses. Idempotent.\n */\nexport const normalizeEvmTransaction = (tx: unknown): EvmTransaction => {\n if (!isRecord(tx)) {\n throw new ChainError(\"invalid-request\", \"tx must be an object\");\n }\n const { type } = tx;\n if (type !== \"legacy\" && type !== \"eip2930\" && type !== \"eip1559\") {\n throw new ChainError(\n \"unsupported\",\n `transaction type ${String(type)} is not supported (legacy, eip2930 and eip1559 only)`,\n );\n }\n rejectUnknown(tx, type);\n requireFields(tx, REQUIRED.base);\n const chainId = safeInteger(tx[\"chainId\"], \"chainId\");\n const nonce = safeInteger(tx[\"nonce\"], \"nonce\");\n const gas = quantity(tx[\"gas\"], \"gas\");\n const value = quantity(tx[\"value\"], \"value\");\n const data = hexBytes(tx[\"data\"], \"data\");\n const toRaw = tx[\"to\"];\n const to =\n toRaw === undefined\n ? undefined\n : typeof toRaw === \"string\" && isEvmAddress(toRaw)\n ? checksumEvmAddress(toRaw)\n : undefined;\n if (toRaw !== undefined && to === undefined) {\n throw new ChainError(\"invalid-address\", \"to must be a valid EVM address\");\n }\n const base = { chainId, nonce, gas, value, data, ...(to === undefined ? {} : { to }) };\n if (type === \"legacy\") {\n requireFields(tx, REQUIRED.gasPrice);\n return { type, ...base, gasPrice: quantity(tx[\"gasPrice\"], \"gasPrice\") };\n }\n if (type === \"eip2930\") {\n requireFields(tx, [...REQUIRED.gasPrice, ...REQUIRED.accessList]);\n return {\n type,\n ...base,\n gasPrice: quantity(tx[\"gasPrice\"], \"gasPrice\"),\n accessList: accessList(tx[\"accessList\"]),\n };\n }\n requireFields(tx, [...REQUIRED.accessList, ...REQUIRED.eip1559]);\n return {\n type,\n ...base,\n accessList: accessList(tx[\"accessList\"]),\n maxFeePerGas: quantity(tx[\"maxFeePerGas\"], \"maxFeePerGas\"),\n maxPriorityFeePerGas: quantity(tx[\"maxPriorityFeePerGas\"], \"maxPriorityFeePerGas\"),\n };\n};\n","import * as TypedData from \"ox/TypedData\";\n\nimport { ChainError } from \"../index.ts\";\nimport type { IntentWarning } from \"../index.ts\";\nimport { isRecord, networkChainId } from \"./transaction.ts\";\n\ntype TypedDataField = {\n readonly name: string;\n readonly type: string;\n};\n\n/**\n * The subset of the EIP-712 document the wallet needs to see before handing it to ox's validator —\n * object with `types`, `primaryType`, `domain` and `message` of the right shapes.\n */\nexport type TypedDataInput = {\n readonly types: Record<string, ReadonlyArray<TypedDataField>>;\n readonly primaryType: string;\n readonly domain: Record<string, unknown>;\n readonly message: Record<string, unknown>;\n};\n\nconst isField = (value: unknown): value is TypedDataField =>\n isRecord(value) && typeof value[\"name\"] === \"string\" && typeof value[\"type\"] === \"string\";\n\nconst isTypedDataInput = (value: unknown): value is TypedDataInput => {\n if (!isRecord(value)) {\n return false;\n }\n const { types, primaryType, domain, message } = value;\n if (!isRecord(types)) {\n return false;\n }\n if (typeof primaryType !== \"string\" || primaryType === \"\") {\n return false;\n }\n if (!isRecord(domain)) {\n return false;\n }\n if (!isRecord(message)) {\n return false;\n }\n return Object.values(types).every((fields) => Array.isArray(fields) && fields.every(isField));\n};\n\nexport type ParsedTypedData = {\n readonly json: TypedDataInput;\n /**\n * True when `domain.chainId` disagrees with the request's network — the intent is still signable\n * but renders `opaque` with a warning.\n */\n readonly chainIdMismatch: boolean;\n};\n\n/** Parses the EIP-712 JSON source and validates its shape with ox. */\nexport const parseTypedData = (typedData: string, network: string): ParsedTypedData => {\n let json: unknown;\n try {\n json = JSON.parse(typedData);\n } catch {\n throw new ChainError(\"invalid-typed-data\", \"typedData is not valid JSON\");\n }\n if (!isTypedDataInput(json)) {\n throw new ChainError(\n \"invalid-typed-data\",\n \"typedData must be a JSON object with types, primaryType, domain and message\",\n );\n }\n try {\n TypedData.validate(json);\n } catch {\n throw new ChainError(\"invalid-typed-data\", \"typedData failed EIP-712 validation\");\n }\n const { chainId } = json.domain;\n const numeric =\n typeof chainId === \"number\"\n ? chainId\n : typeof chainId === \"string\"\n ? Number(chainId)\n : Number.NaN;\n return {\n json,\n chainIdMismatch: Number.isSafeInteger(numeric) && numeric !== networkChainId(network),\n };\n};\n\nexport const typedDataWarnings = (parsed: ParsedTypedData): ReadonlyArray<IntentWarning> =>\n parsed.chainIdMismatch\n ? [\n {\n kind: \"chain-id-mismatch\",\n message: \"typed-data domain.chainId does not match the request network\",\n },\n ]\n : [];\n"],"ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,MAAM,OAAO,CAAC;AACpB,MAAM,MAAM,OAAO,CAAC;AACpB,MAAM,MAAM,OAAO,CAAC;AACpB,MAAM,MAAM,OAAO,CAAC;AACpB,MAAM,QAAQ,OAAO,GAAG;AAGxB,MAAM,SAAS,OAAO,GAAI;AAC1B,MAAM,UAAU,CAAC;AACjB,MAAM,YAAY,CAAC;AACnB,MAAM,aAAa,CAAC;AACpB,KAAK,IAAI,QAAQ,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,QAAQ,IAAI,SAAS;CAE5D,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC;CAChC,QAAQ,KAAK,KAAK,IAAI,IAAI,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,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO;CAET,MAAM,EAAE,OAAO,aAAa,QAAQ,YAAY;CAChD,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO;CAET,IAAI,OAAO,gBAAgB,YAAY,gBAAgB,IACrD,OAAO;CAET,IAAI,CAAC,SAAS,MAAM,GAClB,OAAO;CAET,IAAI,CAAC,SAAS,OAAO,GACnB,OAAO;CAET,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,OAAO,WAAW,MAAM,QAAQ,MAAM,KAAK,OAAO,MAAM,OAAO,CAAC;AAC9F;;AAYA,MAAa,kBAAkB,WAAmB,YAAqC;CACrF,IAAI;CACJ,IAAI;EACF,OAAO,KAAK,MAAM,SAAS;CAC7B,QAAQ;EACN,MAAM,IAAI,WAAW,sBAAsB,6BAA6B;CAC1E;CACA,IAAI,CAAC,iBAAiB,IAAI,GACxB,MAAM,IAAI,WACR,sBACA,6EACF;CAEF,IAAI;EACF,UAAU,SAAS,IAAI;CACzB,QAAQ;EACN,MAAM,IAAI,WAAW,sBAAsB,qCAAqC;CAClF;CACA,MAAM,EAAE,YAAY,KAAK;CACzB,MAAM,UACJ,OAAO,YAAY,WACf,UACA,OAAO,YAAY,WACjB,OAAO,OAAO,IACd;CACR,OAAO;EACL;EACA,iBAAiB,OAAO,cAAc,OAAO,KAAK,YAAY,eAAe,OAAO;CACtF;AACF;AAEA,MAAa,qBAAqB,WAChC,OAAO,kBACH,CACE;CACE,MAAM;CACN,SAAS;AACX,CACF,IACA,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,100 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qntx/wallet-chains",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "qntx/wallet chain semantics: SignRequest codecs, display decoding, verifiability and signing for EVM, Solana and Bitcoin",
|
|
5
|
+
"license": "MIT OR Apache-2.0",
|
|
6
|
+
"author": "QuantX <x@qntx.org>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/qntx/wallet.git",
|
|
10
|
+
"directory": "packages/wallet-chains"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"LICENSE-MIT",
|
|
15
|
+
"LICENSE-APACHE",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.mts",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./evm": {
|
|
26
|
+
"types": "./dist/evm.d.mts",
|
|
27
|
+
"default": "./dist/evm.mjs"
|
|
28
|
+
},
|
|
29
|
+
"./evm/sign": {
|
|
30
|
+
"types": "./dist/evm-sign.d.mts",
|
|
31
|
+
"default": "./dist/evm-sign.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./solana": {
|
|
34
|
+
"types": "./dist/solana.d.mts",
|
|
35
|
+
"default": "./dist/solana.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./solana/sign": {
|
|
38
|
+
"types": "./dist/solana-sign.d.mts",
|
|
39
|
+
"default": "./dist/solana-sign.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./bitcoin": {
|
|
42
|
+
"types": "./dist/bitcoin.d.mts",
|
|
43
|
+
"default": "./dist/bitcoin.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./bitcoin/sign": {
|
|
46
|
+
"types": "./dist/bitcoin-sign.d.mts",
|
|
47
|
+
"default": "./dist/bitcoin-sign.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./package.json": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "vp pack",
|
|
56
|
+
"test": "vp test && bun scripts/size-check.ts",
|
|
57
|
+
"typecheck": "tsc --noEmit",
|
|
58
|
+
"smoke:hermes": "bun scripts/hermes-smoke.ts",
|
|
59
|
+
"check:pkg": "vp pack && publint && attw --pack . --profile esm-only"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@scure/bip32": "2.4.0",
|
|
63
|
+
"@scure/btc-signer": "2.4.1",
|
|
64
|
+
"@solana/addresses": "8.5.0",
|
|
65
|
+
"@solana/codecs": "8.5.0",
|
|
66
|
+
"@solana/transaction-messages": "8.5.0",
|
|
67
|
+
"@solana/transactions": "8.5.0",
|
|
68
|
+
"ox": "1.8.9"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
72
|
+
"@metamask/eth-sig-util": "9.0.0",
|
|
73
|
+
"@qntx/tsconfig": "1.0.1",
|
|
74
|
+
"@scure/bip39": "2.4.0",
|
|
75
|
+
"@solana-program/compute-budget": "0.20.0",
|
|
76
|
+
"@solana-program/stake": "0.11.0",
|
|
77
|
+
"@solana-program/system": "0.16.0",
|
|
78
|
+
"@solana-program/token": "0.18.0",
|
|
79
|
+
"@solana-program/token-2022": "0.20.0",
|
|
80
|
+
"@solana/kit": "8.5.0",
|
|
81
|
+
"@types/node": "26.6.5",
|
|
82
|
+
"bitcoinjs-lib": "^7.0.5",
|
|
83
|
+
"ecpair": "^3.0.2",
|
|
84
|
+
"publint": "0.3.25",
|
|
85
|
+
"tiny-secp256k1": "^2.2.5",
|
|
86
|
+
"typescript": "7.0.2",
|
|
87
|
+
"viem": "2.57.8",
|
|
88
|
+
"vite-plus": "1.3.0"
|
|
89
|
+
},
|
|
90
|
+
"devEngines": {
|
|
91
|
+
"packageManager": {
|
|
92
|
+
"name": "bun",
|
|
93
|
+
"version": "1.4.0",
|
|
94
|
+
"onFail": "ignore"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"engines": {
|
|
98
|
+
"node": ">=20.19.0"
|
|
99
|
+
}
|
|
100
|
+
}
|