@dvmkit/dvm-cli 0.0.0 → 0.1.5

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.
Files changed (50) hide show
  1. package/LICENSE +67 -0
  2. package/NOTICE +2 -0
  3. package/README.md +28 -3
  4. package/dist/_esm-MN4BUYV6.js +885 -0
  5. package/dist/_esm-NRGECLJ7.js +35 -0
  6. package/dist/accounts-2WZE4N5F.js +73 -0
  7. package/dist/actions-LR65XILR.js +244 -0
  8. package/dist/ccip-JXYJSXTW.js +18 -0
  9. package/dist/chains-LJ7XK6H3.js +1460 -0
  10. package/dist/chunk-2VVVWBQA.js +15436 -0
  11. package/dist/chunk-3SWX5BQP.js +66 -0
  12. package/dist/chunk-3W2M46WM.js +61142 -0
  13. package/dist/chunk-4JXFXP4Y.js +757 -0
  14. package/dist/chunk-4NWEJTAW.js +16616 -0
  15. package/dist/chunk-65EY7CT4.js +2691 -0
  16. package/dist/chunk-6CC6JGEU.js +1815 -0
  17. package/dist/chunk-6O27TEXD.js +1181 -0
  18. package/dist/chunk-7OK7MBT6.js +258 -0
  19. package/dist/chunk-BECPI5H5.js +30063 -0
  20. package/dist/chunk-CJTE5TS3.js +1298 -0
  21. package/dist/chunk-ECEM3ZAS.js +339 -0
  22. package/dist/chunk-ECK465AY.js +5614 -0
  23. package/dist/chunk-EGY4KDBW.js +5149 -0
  24. package/dist/chunk-EVQERRCP.js +21369 -0
  25. package/dist/chunk-EZHT2RLJ.js +1447 -0
  26. package/dist/chunk-F55NNH2F.js +6484 -0
  27. package/dist/chunk-G5C6E6PJ.js +9063 -0
  28. package/dist/chunk-GZWKCIYN.js +3319 -0
  29. package/dist/chunk-IYHTITNZ.js +45 -0
  30. package/dist/chunk-LH3QPVN6.js +9869 -0
  31. package/dist/chunk-MLDUKBU3.js +2426 -0
  32. package/dist/chunk-N3UJT2NJ.js +3 -0
  33. package/dist/chunk-OWJZYYMG.js +185 -0
  34. package/dist/chunk-RA24J4QM.js +3717 -0
  35. package/dist/chunk-ZJYO7OLO.js +514 -0
  36. package/dist/client-OWIOFBKS.js +54 -0
  37. package/dist/dist-2G3QBGID.js +47 -0
  38. package/dist/dvm.js +56008 -0
  39. package/dist/esm-RQLHAH2K.js +5183 -0
  40. package/dist/internal-QFQ7MJ5V.js +1228 -0
  41. package/dist/mine.wasm-DNBKYCTQ.js +12 -0
  42. package/dist/payout-reporter-3UB5WRCV-XTVZFIAO.js +17 -0
  43. package/dist/pocket-refill-PQ5ZVSBY.js +129 -0
  44. package/dist/revenue-reporter-JIKUPXOK-TYUBTF4P.js +11 -0
  45. package/dist/secp256k1-JLZEQ2H7.js +19 -0
  46. package/dist/tempo-lifecycle-SQL3KLEZ-AATA2SKI.js +28 -0
  47. package/dist/tempo-wallet-QOLEIPCV-SWCXRBDS.js +33 -0
  48. package/dist/x402-FTG2GRAQ-UGAUMUL6.js +80 -0
  49. package/package.json +63 -6
  50. package/skills/dvm/SKILL.md +71 -0
@@ -0,0 +1,1447 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __dvmCreateRequire } from "node:module";
3
+ const require = __dvmCreateRequire(import.meta.url);
4
+ import {
5
+ Field,
6
+ assert2 as assert,
7
+ create,
8
+ createCurve,
9
+ extraEntropy,
10
+ extract,
11
+ from as from3,
12
+ fromRpcList,
13
+ sha256,
14
+ sha2562,
15
+ sha384,
16
+ sha512,
17
+ toBytes,
18
+ toHex,
19
+ toRpcList,
20
+ validate,
21
+ yParityToV
22
+ } from "./chunk-LH3QPVN6.js";
23
+ import {
24
+ BaseError,
25
+ concat,
26
+ concat2,
27
+ from,
28
+ from2,
29
+ fromArray,
30
+ fromBytes2 as fromBytes,
31
+ fromHex,
32
+ fromNumber2 as fromNumber,
33
+ fromString,
34
+ fromString2,
35
+ isEqual,
36
+ size2 as size,
37
+ slice,
38
+ toBigInt,
39
+ toBigInt2,
40
+ toNumber2 as toNumber,
41
+ toString,
42
+ trimLeft2 as trimLeft
43
+ } from "./chunk-F55NNH2F.js";
44
+ import {
45
+ __export
46
+ } from "./chunk-IYHTITNZ.js";
47
+
48
+ // node_modules/ox/_esm/core/Base64.js
49
+ var Base64_exports = {};
50
+ __export(Base64_exports, {
51
+ fromBytes: () => fromBytes2,
52
+ fromHex: () => fromHex2,
53
+ fromString: () => fromString3,
54
+ toBytes: () => toBytes2,
55
+ toHex: () => toHex2,
56
+ toString: () => toString2
57
+ });
58
+ var encoder = /* @__PURE__ */ new TextEncoder();
59
+ var decoder = /* @__PURE__ */ new TextDecoder();
60
+ var integerToCharacter = /* @__PURE__ */ Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((a, i) => [i, a.charCodeAt(0)]));
61
+ var characterToInteger = {
62
+ ...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((a, i) => [a.charCodeAt(0), i])),
63
+ ["=".charCodeAt(0)]: 0,
64
+ ["-".charCodeAt(0)]: 62,
65
+ ["_".charCodeAt(0)]: 63
66
+ };
67
+ function fromBytes2(value, options = {}) {
68
+ const { pad = true, url = false } = options;
69
+ const encoded = new Uint8Array(Math.ceil(value.length / 3) * 4);
70
+ for (let i = 0, j = 0; j < value.length; i += 4, j += 3) {
71
+ const y = (value[j] << 16) + (value[j + 1] << 8) + (value[j + 2] | 0);
72
+ encoded[i] = integerToCharacter[y >> 18];
73
+ encoded[i + 1] = integerToCharacter[y >> 12 & 63];
74
+ encoded[i + 2] = integerToCharacter[y >> 6 & 63];
75
+ encoded[i + 3] = integerToCharacter[y & 63];
76
+ }
77
+ const k = value.length % 3;
78
+ const end = Math.floor(value.length / 3) * 4 + (k && k + 1);
79
+ let base64 = decoder.decode(new Uint8Array(encoded.buffer, 0, end));
80
+ if (pad && k === 1)
81
+ base64 += "==";
82
+ if (pad && k === 2)
83
+ base64 += "=";
84
+ if (url)
85
+ base64 = base64.replaceAll("+", "-").replaceAll("/", "_");
86
+ return base64;
87
+ }
88
+ function fromHex2(value, options = {}) {
89
+ return fromBytes2(fromHex(value), options);
90
+ }
91
+ function fromString3(value, options = {}) {
92
+ return fromBytes2(fromString(value), options);
93
+ }
94
+ function toBytes2(value) {
95
+ const base64 = value.replace(/=+$/, "");
96
+ const size2 = base64.length;
97
+ const decoded = new Uint8Array(size2 + 3);
98
+ encoder.encodeInto(base64 + "===", decoded);
99
+ for (let i = 0, j = 0; i < base64.length; i += 4, j += 3) {
100
+ const x = (characterToInteger[decoded[i]] << 18) + (characterToInteger[decoded[i + 1]] << 12) + (characterToInteger[decoded[i + 2]] << 6) + characterToInteger[decoded[i + 3]];
101
+ decoded[j] = x >> 16;
102
+ decoded[j + 1] = x >> 8 & 255;
103
+ decoded[j + 2] = x & 255;
104
+ }
105
+ const decodedSize = (size2 >> 2) * 3 + (size2 % 4 && size2 % 4 - 1);
106
+ return new Uint8Array(decoded.buffer, 0, decodedSize);
107
+ }
108
+ function toHex2(value) {
109
+ return fromBytes(toBytes2(value));
110
+ }
111
+ function toString2(value) {
112
+ return toString(toBytes2(value));
113
+ }
114
+
115
+ // node_modules/ox/node_modules/@noble/curves/esm/nist.js
116
+ var Fp256 = Field(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"));
117
+ var p256_a = Fp256.create(BigInt("-3"));
118
+ var p256_b = BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");
119
+ var p256 = createCurve({
120
+ a: p256_a,
121
+ b: p256_b,
122
+ Fp: Fp256,
123
+ n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
124
+ Gx: BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
125
+ Gy: BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),
126
+ h: BigInt(1),
127
+ lowS: false
128
+ }, sha256);
129
+ var Fp384 = Field(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"));
130
+ var p384_a = Fp384.create(BigInt("-3"));
131
+ var p384_b = BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef");
132
+ var p384 = createCurve({
133
+ a: p384_a,
134
+ b: p384_b,
135
+ Fp: Fp384,
136
+ n: BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),
137
+ Gx: BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),
138
+ Gy: BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),
139
+ h: BigInt(1),
140
+ lowS: false
141
+ }, sha384);
142
+ var Fp521 = Field(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
143
+ var p521_a = Fp521.create(BigInt("-3"));
144
+ var p521_b = BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00");
145
+ var p521 = createCurve({
146
+ a: p521_a,
147
+ b: p521_b,
148
+ Fp: Fp521,
149
+ n: BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),
150
+ Gx: BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),
151
+ Gy: BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),
152
+ h: BigInt(1),
153
+ lowS: false,
154
+ allowedPrivateKeyLengths: [130, 131, 132]
155
+ // P521 keys are variable-length. Normalize to 132b
156
+ }, sha512);
157
+
158
+ // node_modules/ox/node_modules/@noble/curves/esm/p256.js
159
+ var p2562 = p256;
160
+ var secp256r1 = p256;
161
+
162
+ // node_modules/ox/_esm/core/P256.js
163
+ function getPublicKey(options) {
164
+ const { privateKey } = options;
165
+ const point = secp256r1.ProjectivePoint.fromPrivateKey(typeof privateKey === "string" ? privateKey.slice(2) : fromBytes(privateKey).slice(2));
166
+ return from3(point);
167
+ }
168
+ function sign(options) {
169
+ const { extraEntropy: extraEntropy2 = extraEntropy, hash, payload, privateKey } = options;
170
+ const { r, s, recovery } = secp256r1.sign(payload instanceof Uint8Array ? payload : fromHex(payload), privateKey instanceof Uint8Array ? privateKey : fromHex(privateKey), {
171
+ extraEntropy: typeof extraEntropy2 === "boolean" ? extraEntropy2 : from2(extraEntropy2).slice(2),
172
+ lowS: true,
173
+ ...hash ? { prehash: true } : {}
174
+ });
175
+ return {
176
+ r,
177
+ s,
178
+ yParity: recovery
179
+ };
180
+ }
181
+ function verify(options) {
182
+ const { hash, payload, publicKey, signature } = options;
183
+ return secp256r1.verify(signature, payload instanceof Uint8Array ? payload : fromHex(payload), toHex(publicKey).substring(2), { lowS: true, ...hash ? { prehash: true } : {} });
184
+ }
185
+
186
+ // node_modules/ox/_esm/core/Cbor.js
187
+ function encode(data, options = {}) {
188
+ const { as = "Hex" } = options;
189
+ const encodable = getEncodable(data);
190
+ const cursor = create(new Uint8Array(encodable.length));
191
+ encodable.encode(cursor);
192
+ if (as === "Hex")
193
+ return fromBytes(cursor.bytes);
194
+ return cursor.bytes;
195
+ }
196
+ var InvalidMajorTypeError = class extends BaseError {
197
+ constructor({ majorType }) {
198
+ super(`Invalid CBOR major type: ${majorType}`);
199
+ Object.defineProperty(this, "name", {
200
+ enumerable: true,
201
+ configurable: true,
202
+ writable: true,
203
+ value: "Cbor.InvalidMajorTypeError"
204
+ });
205
+ }
206
+ };
207
+ var InvalidAdditionalInfoError = class extends BaseError {
208
+ constructor({ additionalInfo }) {
209
+ super(`Invalid CBOR additional info: ${additionalInfo}`);
210
+ Object.defineProperty(this, "name", {
211
+ enumerable: true,
212
+ configurable: true,
213
+ writable: true,
214
+ value: "Cbor.InvalidAdditionalInfoError"
215
+ });
216
+ }
217
+ };
218
+ var Unsupported64BitIntegerError = class extends BaseError {
219
+ constructor() {
220
+ super("64-bit integers are not supported in CBOR decoding.");
221
+ Object.defineProperty(this, "name", {
222
+ enumerable: true,
223
+ configurable: true,
224
+ writable: true,
225
+ value: "Cbor.Unsupported64BitIntegerError"
226
+ });
227
+ }
228
+ };
229
+ var UnsupportedTagError = class extends BaseError {
230
+ constructor({ tag }) {
231
+ super(`CBOR tagged data (tag ${tag}) is not yet supported.`);
232
+ Object.defineProperty(this, "name", {
233
+ enumerable: true,
234
+ configurable: true,
235
+ writable: true,
236
+ value: "Cbor.UnsupportedTagError"
237
+ });
238
+ }
239
+ };
240
+ var InvalidIndefiniteLengthChunkError = class extends BaseError {
241
+ constructor({ type }) {
242
+ super(`Invalid chunk type in indefinite-length ${type}`);
243
+ Object.defineProperty(this, "name", {
244
+ enumerable: true,
245
+ configurable: true,
246
+ writable: true,
247
+ value: "Cbor.InvalidIndefiniteLengthChunkError"
248
+ });
249
+ }
250
+ };
251
+ var InvalidSimpleValueError = class extends BaseError {
252
+ constructor({ value }) {
253
+ super(`Invalid CBOR simple value: ${value}`);
254
+ Object.defineProperty(this, "name", {
255
+ enumerable: true,
256
+ configurable: true,
257
+ writable: true,
258
+ value: "Cbor.InvalidSimpleValueError"
259
+ });
260
+ }
261
+ };
262
+ var UnsupportedBigIntError = class extends BaseError {
263
+ constructor() {
264
+ super("BigInt values are not supported in CBOR encoding.");
265
+ Object.defineProperty(this, "name", {
266
+ enumerable: true,
267
+ configurable: true,
268
+ writable: true,
269
+ value: "Cbor.UnsupportedBigIntError"
270
+ });
271
+ }
272
+ };
273
+ var UnexpectedTokenError = class extends BaseError {
274
+ constructor({ token }) {
275
+ super(`Unexpected token: ${token}`);
276
+ Object.defineProperty(this, "name", {
277
+ enumerable: true,
278
+ configurable: true,
279
+ writable: true,
280
+ value: "Cbor.UnexpectedTokenError"
281
+ });
282
+ }
283
+ };
284
+ var NumberTooLargeError = class extends BaseError {
285
+ constructor({ number }) {
286
+ super(`Number exceeds maximum safe integer (${Number.MAX_SAFE_INTEGER}): ${number}`);
287
+ Object.defineProperty(this, "name", {
288
+ enumerable: true,
289
+ configurable: true,
290
+ writable: true,
291
+ value: "Cbor.NumberTooLargeError"
292
+ });
293
+ }
294
+ };
295
+ var StringTooLargeError = class extends BaseError {
296
+ constructor({ size: size2 }) {
297
+ super(`String length exceeds maximum (4294967295): ${size2}`);
298
+ Object.defineProperty(this, "name", {
299
+ enumerable: true,
300
+ configurable: true,
301
+ writable: true,
302
+ value: "Cbor.StringTooLargeError"
303
+ });
304
+ }
305
+ };
306
+ var ArrayTooLargeError = class extends BaseError {
307
+ constructor({ size: size2 }) {
308
+ super(`Array length exceeds maximum (4294967295): ${size2}`);
309
+ Object.defineProperty(this, "name", {
310
+ enumerable: true,
311
+ configurable: true,
312
+ writable: true,
313
+ value: "Cbor.ArrayTooLargeError"
314
+ });
315
+ }
316
+ };
317
+ var ObjectTooLargeError = class extends BaseError {
318
+ constructor({ size: size2 }) {
319
+ super(`Object size exceeds maximum (4294967295): ${size2}`);
320
+ Object.defineProperty(this, "name", {
321
+ enumerable: true,
322
+ configurable: true,
323
+ writable: true,
324
+ value: "Cbor.ObjectTooLargeError"
325
+ });
326
+ }
327
+ };
328
+ var ByteStringTooLargeError = class extends BaseError {
329
+ constructor({ size: size2 }) {
330
+ super(`Byte string length exceeds maximum (4294967295): ${size2}`);
331
+ Object.defineProperty(this, "name", {
332
+ enumerable: true,
333
+ configurable: true,
334
+ writable: true,
335
+ value: "Cbor.ByteStringTooLargeError"
336
+ });
337
+ }
338
+ };
339
+ function getEncodable(value) {
340
+ if (typeof value === "undefined")
341
+ return { length: 1, encode: (cursor) => cursor.pushUint8(247) };
342
+ if (value === null)
343
+ return { length: 1, encode: (cursor) => cursor.pushUint8(246) };
344
+ if (typeof value === "boolean")
345
+ return {
346
+ length: 1,
347
+ encode: (cursor) => cursor.pushUint8(value ? 245 : 244)
348
+ };
349
+ if (typeof value === "number")
350
+ return getEncodable.number(value);
351
+ if (typeof value === "bigint")
352
+ throw new UnsupportedBigIntError();
353
+ if (typeof value === "string")
354
+ return getEncodable.string(value);
355
+ if (Array.isArray(value))
356
+ return getEncodable.array(value);
357
+ if (value instanceof Uint8Array)
358
+ return getEncodable.byteString(value);
359
+ if (value instanceof ArrayBuffer)
360
+ return getEncodable.byteString(new Uint8Array(value));
361
+ if (ArrayBuffer.isView(value))
362
+ return getEncodable.byteString(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));
363
+ if (value instanceof Map)
364
+ return getEncodable.map(value);
365
+ if (typeof value === "object")
366
+ return getEncodable.object(value);
367
+ throw new UnexpectedTokenError({ token: String(value) });
368
+ }
369
+ (function(getEncodable2) {
370
+ function number(value) {
371
+ if (!Number.isSafeInteger(value)) {
372
+ const float32 = Math.fround(value);
373
+ if (Number.isNaN(value) || value === float32)
374
+ return {
375
+ length: 5,
376
+ // 1 byte prefix + 4 bytes float32
377
+ encode(cursor) {
378
+ cursor.pushUint8(250);
379
+ cursor.dataView.setFloat32(cursor.position, value, false);
380
+ cursor.position += 4;
381
+ }
382
+ };
383
+ return {
384
+ length: 9,
385
+ // 1 byte prefix + 8 bytes float64
386
+ encode(cursor) {
387
+ cursor.pushUint8(251);
388
+ cursor.dataView.setFloat64(cursor.position, value, false);
389
+ cursor.position += 8;
390
+ }
391
+ };
392
+ }
393
+ if (value >= 0) {
394
+ if (value <= 23)
395
+ return { length: 1, encode: (cursor) => cursor.pushUint8(value) };
396
+ if (value <= 255)
397
+ return {
398
+ length: 2,
399
+ // 1 byte prefix + 1 byte uint8
400
+ encode: (cursor) => {
401
+ cursor.pushUint8(24);
402
+ cursor.pushUint8(value);
403
+ }
404
+ };
405
+ if (value <= 65535)
406
+ return {
407
+ length: 3,
408
+ // 1 byte prefix + 2 bytes uint16
409
+ encode: (cursor) => {
410
+ cursor.pushUint8(25);
411
+ cursor.pushUint16(value);
412
+ }
413
+ };
414
+ if (value <= 4294967295)
415
+ return {
416
+ length: 5,
417
+ // 1 byte prefix + 4 bytes uint32
418
+ encode: (cursor) => {
419
+ cursor.pushUint8(26);
420
+ cursor.pushUint32(value);
421
+ }
422
+ };
423
+ throw new NumberTooLargeError({ number: value.toString(10) });
424
+ }
425
+ const positiveNumber = -1 - value;
426
+ if (value >= -24)
427
+ return {
428
+ length: 1,
429
+ encode: (cursor) => cursor.pushUint8(32 + positiveNumber)
430
+ };
431
+ if (positiveNumber <= 255)
432
+ return {
433
+ length: 2,
434
+ // 1 byte prefix + 1 byte uint8
435
+ encode: (cursor) => {
436
+ cursor.pushUint8(56);
437
+ cursor.pushUint8(positiveNumber);
438
+ }
439
+ };
440
+ if (positiveNumber <= 65535)
441
+ return {
442
+ length: 3,
443
+ // 1 byte prefix + 2 bytes uint16
444
+ encode: (cursor) => {
445
+ cursor.pushUint8(57);
446
+ cursor.pushUint16(positiveNumber);
447
+ }
448
+ };
449
+ if (positiveNumber <= 4294967295)
450
+ return {
451
+ length: 5,
452
+ // 1 byte prefix + 4 bytes uint32
453
+ encode: (cursor) => {
454
+ cursor.pushUint8(58);
455
+ cursor.pushUint32(positiveNumber);
456
+ }
457
+ };
458
+ throw new NumberTooLargeError({ number: value.toString(10) });
459
+ }
460
+ getEncodable2.number = number;
461
+ function string(value) {
462
+ const encoded = fromString(value);
463
+ const size2 = encoded.length;
464
+ if (size2 <= 23)
465
+ return {
466
+ length: 1 + size2,
467
+ // 1 byte prefix + size bytes
468
+ encode(cursor) {
469
+ cursor.pushUint8(96 + size2);
470
+ if (size2 > 0)
471
+ cursor.pushBytes(encoded);
472
+ }
473
+ };
474
+ if (size2 <= 255)
475
+ return {
476
+ length: 2 + size2,
477
+ // 1 byte prefix + 1 byte uint8 + size bytes
478
+ encode(cursor) {
479
+ cursor.pushUint8(120);
480
+ cursor.pushUint8(size2);
481
+ cursor.pushBytes(encoded);
482
+ }
483
+ };
484
+ if (size2 <= 65535)
485
+ return {
486
+ length: 3 + size2,
487
+ // 1 byte prefix + 2 bytes uint16 + size bytes
488
+ encode(cursor) {
489
+ cursor.pushUint8(121);
490
+ cursor.pushUint16(size2);
491
+ cursor.pushBytes(encoded);
492
+ }
493
+ };
494
+ if (size2 <= 4294967295)
495
+ return {
496
+ length: 5 + size2,
497
+ // 1 byte prefix + 4 bytes uint32 + size bytes
498
+ encode(cursor) {
499
+ cursor.pushUint8(122);
500
+ cursor.pushUint32(size2);
501
+ cursor.pushBytes(encoded);
502
+ }
503
+ };
504
+ throw new StringTooLargeError({ size: size2 });
505
+ }
506
+ getEncodable2.string = string;
507
+ function array(value) {
508
+ const items = value.map((item) => getEncodable2(item));
509
+ const bodyLength = items.reduce((acc, item) => acc + item.length, 0);
510
+ const size2 = value.length;
511
+ if (size2 <= 23)
512
+ return {
513
+ length: 1 + bodyLength,
514
+ // 1 byte prefix + body length
515
+ encode(cursor) {
516
+ cursor.pushUint8(128 + size2);
517
+ for (const item of items)
518
+ item.encode(cursor);
519
+ }
520
+ };
521
+ if (size2 <= 255)
522
+ return {
523
+ length: 2 + bodyLength,
524
+ // 1 byte prefix + 1 byte uint8 + body length
525
+ encode(cursor) {
526
+ cursor.pushUint8(152);
527
+ cursor.pushUint8(size2);
528
+ for (const item of items)
529
+ item.encode(cursor);
530
+ }
531
+ };
532
+ if (size2 <= 65535)
533
+ return {
534
+ length: 3 + bodyLength,
535
+ // 1 byte prefix + 2 bytes uint16 + body length
536
+ encode(cursor) {
537
+ cursor.pushUint8(153);
538
+ cursor.pushUint16(size2);
539
+ for (const item of items)
540
+ item.encode(cursor);
541
+ }
542
+ };
543
+ if (size2 <= 4294967295)
544
+ return {
545
+ length: 5 + bodyLength,
546
+ // 1 byte prefix + 4 bytes uint32 + body length
547
+ encode(cursor) {
548
+ cursor.pushUint8(154);
549
+ cursor.pushUint32(size2);
550
+ for (const item of items)
551
+ item.encode(cursor);
552
+ }
553
+ };
554
+ throw new ArrayTooLargeError({ size: size2 });
555
+ }
556
+ getEncodable2.array = array;
557
+ function byteString(value) {
558
+ const size2 = value.byteLength;
559
+ if (size2 <= 23)
560
+ return {
561
+ length: 1 + size2,
562
+ // 1 byte prefix + size bytes
563
+ encode(cursor) {
564
+ cursor.pushUint8(64 + size2);
565
+ cursor.pushBytes(value);
566
+ }
567
+ };
568
+ if (size2 <= 255)
569
+ return {
570
+ length: 2 + size2,
571
+ // 1 byte prefix + 1 byte uint8 + size bytes
572
+ encode(cursor) {
573
+ cursor.pushUint8(88);
574
+ cursor.pushUint8(size2);
575
+ cursor.pushBytes(value);
576
+ }
577
+ };
578
+ if (size2 <= 65535)
579
+ return {
580
+ length: 3 + size2,
581
+ // 1 byte prefix + 2 bytes uint16 + size bytes
582
+ encode(cursor) {
583
+ cursor.pushUint8(89);
584
+ cursor.pushUint16(size2);
585
+ cursor.pushBytes(value);
586
+ }
587
+ };
588
+ if (size2 <= 4294967295)
589
+ return {
590
+ length: 5 + size2,
591
+ // 1 byte prefix + 4 bytes uint32 + size bytes
592
+ encode(cursor) {
593
+ cursor.pushUint8(90);
594
+ cursor.pushUint32(size2);
595
+ cursor.pushBytes(value);
596
+ }
597
+ };
598
+ throw new ByteStringTooLargeError({ size: size2 });
599
+ }
600
+ getEncodable2.byteString = byteString;
601
+ function object(value) {
602
+ const keys = Object.keys(value);
603
+ const entries = keys.map((key) => ({
604
+ key: getEncodable2(key),
605
+ value: getEncodable2(value[key])
606
+ }));
607
+ const bodyLength = entries.reduce((acc, entry) => acc + entry.key.length + entry.value.length, 0);
608
+ const size2 = keys.length;
609
+ if (size2 <= 23)
610
+ return {
611
+ length: 1 + bodyLength,
612
+ // 1 byte prefix + body length
613
+ encode(cursor) {
614
+ cursor.pushUint8(160 + size2);
615
+ for (const entry of entries) {
616
+ entry.key.encode(cursor);
617
+ entry.value.encode(cursor);
618
+ }
619
+ }
620
+ };
621
+ if (size2 <= 255)
622
+ return {
623
+ length: 2 + bodyLength,
624
+ // 1 byte prefix + 1 byte uint8 + body length
625
+ encode(cursor) {
626
+ cursor.pushUint8(184);
627
+ cursor.pushUint8(size2);
628
+ for (const entry of entries) {
629
+ entry.key.encode(cursor);
630
+ entry.value.encode(cursor);
631
+ }
632
+ }
633
+ };
634
+ if (size2 <= 65535)
635
+ return {
636
+ length: 3 + bodyLength,
637
+ // 1 byte prefix + 2 bytes uint16 + body length
638
+ encode(cursor) {
639
+ cursor.pushUint8(185);
640
+ cursor.pushUint16(size2);
641
+ for (const entry of entries) {
642
+ entry.key.encode(cursor);
643
+ entry.value.encode(cursor);
644
+ }
645
+ }
646
+ };
647
+ if (size2 <= 4294967295)
648
+ return {
649
+ length: 5 + bodyLength,
650
+ // 1 byte prefix + 4 bytes uint32 + body length
651
+ encode(cursor) {
652
+ cursor.pushUint8(186);
653
+ cursor.pushUint32(size2);
654
+ for (const entry of entries) {
655
+ entry.key.encode(cursor);
656
+ entry.value.encode(cursor);
657
+ }
658
+ }
659
+ };
660
+ throw new ObjectTooLargeError({ size: size2 });
661
+ }
662
+ getEncodable2.object = object;
663
+ function map(value) {
664
+ const entries = [];
665
+ for (const [k, v] of value)
666
+ entries.push({ key: getEncodable2(k), value: getEncodable2(v) });
667
+ const bodyLength = entries.reduce((acc, entry) => acc + entry.key.length + entry.value.length, 0);
668
+ const size2 = value.size;
669
+ if (size2 <= 23)
670
+ return {
671
+ length: 1 + bodyLength,
672
+ encode(cursor) {
673
+ cursor.pushUint8(160 + size2);
674
+ for (const entry of entries) {
675
+ entry.key.encode(cursor);
676
+ entry.value.encode(cursor);
677
+ }
678
+ }
679
+ };
680
+ if (size2 <= 255)
681
+ return {
682
+ length: 2 + bodyLength,
683
+ encode(cursor) {
684
+ cursor.pushUint8(184);
685
+ cursor.pushUint8(size2);
686
+ for (const entry of entries) {
687
+ entry.key.encode(cursor);
688
+ entry.value.encode(cursor);
689
+ }
690
+ }
691
+ };
692
+ if (size2 <= 65535)
693
+ return {
694
+ length: 3 + bodyLength,
695
+ encode(cursor) {
696
+ cursor.pushUint8(185);
697
+ cursor.pushUint16(size2);
698
+ for (const entry of entries) {
699
+ entry.key.encode(cursor);
700
+ entry.value.encode(cursor);
701
+ }
702
+ }
703
+ };
704
+ if (size2 <= 4294967295)
705
+ return {
706
+ length: 5 + bodyLength,
707
+ encode(cursor) {
708
+ cursor.pushUint8(186);
709
+ cursor.pushUint32(size2);
710
+ for (const entry of entries) {
711
+ entry.key.encode(cursor);
712
+ entry.value.encode(cursor);
713
+ }
714
+ }
715
+ };
716
+ throw new ObjectTooLargeError({ size: size2 });
717
+ }
718
+ getEncodable2.map = map;
719
+ })(getEncodable || (getEncodable = {}));
720
+ function decodeCursor(cursor) {
721
+ const initialByte = cursor.readUint8();
722
+ const majorType = initialByte >> 5;
723
+ const additionalInfo = initialByte & 31;
724
+ switch (majorType) {
725
+ // Major type 0: Unsigned integer
726
+ case 0:
727
+ return decodeCursor.readUnsignedInteger(cursor, additionalInfo);
728
+ // Major type 1: Negative integer
729
+ case 1:
730
+ return decodeCursor.readNegativeInteger(cursor, additionalInfo);
731
+ // Major type 2: Byte string
732
+ case 2:
733
+ return decodeCursor.readByteString(cursor, additionalInfo);
734
+ // Major type 3: Text string
735
+ case 3:
736
+ return decodeCursor.readTextString(cursor, additionalInfo);
737
+ // Major type 4: Array
738
+ case 4:
739
+ return decodeCursor.readArray(cursor, additionalInfo);
740
+ // Major type 5: Map
741
+ case 5:
742
+ return decodeCursor.readMap(cursor, additionalInfo);
743
+ // Major type 6: Tagged data (not yet supported)
744
+ case 6:
745
+ throw new UnsupportedTagError({ tag: additionalInfo });
746
+ // Major type 7: Simple values and floats
747
+ case 7:
748
+ return decodeCursor.readSimpleOrFloat(cursor, additionalInfo);
749
+ default:
750
+ throw new InvalidMajorTypeError({ majorType });
751
+ }
752
+ }
753
+ (function(decodeCursor2) {
754
+ function readLength(cursor, additionalInfo) {
755
+ if (additionalInfo < 24)
756
+ return additionalInfo;
757
+ if (additionalInfo === 24)
758
+ return cursor.readUint8();
759
+ if (additionalInfo === 25)
760
+ return cursor.readUint16();
761
+ if (additionalInfo === 26)
762
+ return cursor.readUint32();
763
+ if (additionalInfo === 27)
764
+ throw new Unsupported64BitIntegerError();
765
+ throw new InvalidAdditionalInfoError({ additionalInfo });
766
+ }
767
+ function readUnsignedInteger(cursor, additionalInfo) {
768
+ return readLength(cursor, additionalInfo);
769
+ }
770
+ decodeCursor2.readUnsignedInteger = readUnsignedInteger;
771
+ function readNegativeInteger(cursor, additionalInfo) {
772
+ const value = readLength(cursor, additionalInfo);
773
+ return -1 - value;
774
+ }
775
+ decodeCursor2.readNegativeInteger = readNegativeInteger;
776
+ function readByteString(cursor, additionalInfo) {
777
+ if (additionalInfo === 31) {
778
+ const chunks = [];
779
+ let totalLength = 0;
780
+ while (true) {
781
+ const byte = cursor.inspectUint8();
782
+ if (byte === 255) {
783
+ cursor.readUint8();
784
+ break;
785
+ }
786
+ const chunk = decodeCursor2(cursor);
787
+ if (!(chunk instanceof Uint8Array))
788
+ throw new InvalidIndefiniteLengthChunkError({ type: "byte string" });
789
+ chunks.push(chunk);
790
+ totalLength += chunk.length;
791
+ }
792
+ const result = new Uint8Array(totalLength);
793
+ let offset = 0;
794
+ for (const chunk of chunks) {
795
+ result.set(chunk, offset);
796
+ offset += chunk.length;
797
+ }
798
+ return result;
799
+ }
800
+ const length = readLength(cursor, additionalInfo);
801
+ return cursor.readBytes(length);
802
+ }
803
+ decodeCursor2.readByteString = readByteString;
804
+ function readTextString(cursor, additionalInfo) {
805
+ if (additionalInfo === 31) {
806
+ const chunks = [];
807
+ while (true) {
808
+ const byte = cursor.inspectUint8();
809
+ if (byte === 255) {
810
+ cursor.readUint8();
811
+ break;
812
+ }
813
+ const chunk = decodeCursor2(cursor);
814
+ if (typeof chunk !== "string")
815
+ throw new InvalidIndefiniteLengthChunkError({ type: "text string" });
816
+ chunks.push(chunk);
817
+ }
818
+ return chunks.join("");
819
+ }
820
+ const length = readLength(cursor, additionalInfo);
821
+ const bytes = cursor.readBytes(length);
822
+ return toString(bytes);
823
+ }
824
+ decodeCursor2.readTextString = readTextString;
825
+ function readArray(cursor, additionalInfo) {
826
+ if (additionalInfo === 31) {
827
+ const result2 = [];
828
+ while (true) {
829
+ const byte = cursor.inspectUint8();
830
+ if (byte === 255) {
831
+ cursor.readUint8();
832
+ break;
833
+ }
834
+ result2.push(decodeCursor2(cursor));
835
+ }
836
+ return result2;
837
+ }
838
+ const length = readLength(cursor, additionalInfo);
839
+ const result = [];
840
+ for (let i = 0; i < length; i++) {
841
+ result.push(decodeCursor2(cursor));
842
+ }
843
+ return result;
844
+ }
845
+ decodeCursor2.readArray = readArray;
846
+ function readMap(cursor, additionalInfo) {
847
+ if (additionalInfo === 31) {
848
+ const result2 = {};
849
+ while (true) {
850
+ const byte = cursor.inspectUint8();
851
+ if (byte === 255) {
852
+ cursor.readUint8();
853
+ break;
854
+ }
855
+ const key = decodeCursor2(cursor);
856
+ const keyStr = typeof key === "string" ? key : typeof key === "number" ? String(key) : String(key);
857
+ const value = decodeCursor2(cursor);
858
+ result2[keyStr] = value;
859
+ }
860
+ return result2;
861
+ }
862
+ const length = readLength(cursor, additionalInfo);
863
+ const result = {};
864
+ for (let i = 0; i < length; i++) {
865
+ const key = decodeCursor2(cursor);
866
+ const keyStr = typeof key === "string" ? key : typeof key === "number" ? String(key) : String(key);
867
+ const value = decodeCursor2(cursor);
868
+ result[keyStr] = value;
869
+ }
870
+ return result;
871
+ }
872
+ decodeCursor2.readMap = readMap;
873
+ function readSimpleOrFloat(cursor, additionalInfo) {
874
+ if (additionalInfo === 20)
875
+ return false;
876
+ if (additionalInfo === 21)
877
+ return true;
878
+ if (additionalInfo === 22)
879
+ return null;
880
+ if (additionalInfo === 23)
881
+ return void 0;
882
+ if (additionalInfo === 25) {
883
+ const bits = cursor.readUint16();
884
+ return getFloat16(bits);
885
+ }
886
+ if (additionalInfo === 26) {
887
+ const value = cursor.dataView.getFloat32(cursor.position, false);
888
+ cursor.position += 4;
889
+ return value;
890
+ }
891
+ if (additionalInfo === 27) {
892
+ const value = cursor.dataView.getFloat64(cursor.position, false);
893
+ cursor.position += 8;
894
+ return value;
895
+ }
896
+ if (additionalInfo === 24) {
897
+ const simpleValue = cursor.readUint8();
898
+ if (simpleValue < 32)
899
+ throw new InvalidSimpleValueError({ value: simpleValue });
900
+ return void 0;
901
+ }
902
+ throw new InvalidAdditionalInfoError({ additionalInfo });
903
+ }
904
+ decodeCursor2.readSimpleOrFloat = readSimpleOrFloat;
905
+ function getFloat16(bits) {
906
+ const sign5 = bits >> 15 & 1;
907
+ const exponent = bits >> 10 & 31;
908
+ const fraction = bits & 1023;
909
+ if (exponent === 0) {
910
+ if (fraction === 0)
911
+ return sign5 ? -0 : 0;
912
+ const value2 = 2 ** -14 * (fraction / 1024);
913
+ return sign5 ? -value2 : value2;
914
+ }
915
+ if (exponent === 31) {
916
+ if (fraction === 0)
917
+ return sign5 ? -Infinity : Infinity;
918
+ return NaN;
919
+ }
920
+ const value = 2 ** (exponent - 15) * (1 + fraction / 1024);
921
+ return sign5 ? -value : value;
922
+ }
923
+ })(decodeCursor || (decodeCursor = {}));
924
+
925
+ // node_modules/ox/_esm/core/CoseKey.js
926
+ function fromPublicKey(publicKey) {
927
+ const pkBytes = toBytes(publicKey);
928
+ const x = pkBytes.slice(1, 33);
929
+ const y = pkBytes.slice(33, 65);
930
+ return encode(/* @__PURE__ */ new Map([
931
+ [1, 2],
932
+ // kty: EC2
933
+ [3, -7],
934
+ // alg: ES256
935
+ [-1, 1],
936
+ // crv: P-256
937
+ [-2, x],
938
+ // x coordinate
939
+ [-3, y]
940
+ // y coordinate
941
+ ]));
942
+ }
943
+
944
+ // node_modules/ox/_esm/core/internal/webauthn.js
945
+ function parseAsn1Signature(bytes) {
946
+ const sig = p2562.Signature.fromDER(bytes).normalizeS();
947
+ return { r: sig.r, s: sig.s };
948
+ }
949
+
950
+ // node_modules/ox/_esm/webauthn/Authenticator.js
951
+ function getAuthenticatorData(options = {}) {
952
+ const { credential, flag = 5, rpId = window.location.hostname, signCount = 0 } = options;
953
+ const rpIdHash = sha2562(fromString2(rpId));
954
+ const flag_bytes = fromNumber(flag, { size: 1 });
955
+ const signCount_bytes = fromNumber(signCount, { size: 4 });
956
+ const base = concat2(rpIdHash, flag_bytes, signCount_bytes);
957
+ if (!credential)
958
+ return base;
959
+ const aaguid = fromBytes(new Uint8Array(16));
960
+ const credentialId = fromBytes(credential.id);
961
+ const credIdLen = fromNumber(credential.id.length, { size: 2 });
962
+ const coseKey = fromPublicKey(credential.publicKey);
963
+ return concat2(base, aaguid, credIdLen, credentialId, coseKey);
964
+ }
965
+ function getClientDataJSON(options) {
966
+ const { challenge, crossOrigin = false, extraClientData, origin = window.location.origin, type = "webauthn.get" } = options;
967
+ return JSON.stringify({
968
+ type,
969
+ challenge: fromHex2(challenge, { url: true, pad: false }),
970
+ origin,
971
+ crossOrigin,
972
+ ...extraClientData
973
+ });
974
+ }
975
+
976
+ // node_modules/ox/_esm/webauthn/Authentication.js
977
+ function getOptions(options) {
978
+ const { credentialId, challenge, extensions, rpId = window.location.hostname, userVerification = "required" } = options;
979
+ return {
980
+ publicKey: {
981
+ ...credentialId ? {
982
+ allowCredentials: Array.isArray(credentialId) ? credentialId.map((id) => ({
983
+ id: toBytes2(id),
984
+ type: "public-key"
985
+ })) : [
986
+ {
987
+ id: toBytes2(credentialId),
988
+ type: "public-key"
989
+ }
990
+ ]
991
+ } : {},
992
+ challenge: fromHex(challenge),
993
+ ...extensions && { extensions },
994
+ rpId,
995
+ userVerification
996
+ }
997
+ };
998
+ }
999
+ function getSignPayload(options) {
1000
+ const { challenge, crossOrigin, extraClientData, flag, origin, rpId, signCount, userVerification = "required" } = options;
1001
+ const authenticatorData = getAuthenticatorData({
1002
+ flag,
1003
+ rpId,
1004
+ signCount
1005
+ });
1006
+ const clientDataJSON = getClientDataJSON({
1007
+ challenge,
1008
+ crossOrigin,
1009
+ extraClientData,
1010
+ origin
1011
+ });
1012
+ const clientDataJSONHash = sha2562(fromString2(clientDataJSON));
1013
+ const challengeIndex = clientDataJSON.indexOf('"challenge"');
1014
+ const typeIndex = clientDataJSON.indexOf('"type"');
1015
+ const metadata = {
1016
+ authenticatorData,
1017
+ clientDataJSON,
1018
+ challengeIndex,
1019
+ typeIndex,
1020
+ userVerificationRequired: userVerification === "required"
1021
+ };
1022
+ const payload = concat2(authenticatorData, clientDataJSONHash);
1023
+ return { metadata, payload };
1024
+ }
1025
+ async function sign2(options) {
1026
+ const { getFn = (opts) => window.navigator.credentials.get(opts), ...rest } = options;
1027
+ const requestOptions = "publicKey" in rest ? rest : getOptions(rest);
1028
+ try {
1029
+ const credential = await getFn(requestOptions);
1030
+ if (!credential)
1031
+ throw new SignFailedError();
1032
+ const response = credential.response;
1033
+ const clientDataJSONBytes = new Uint8Array(response.clientDataJSON);
1034
+ const authenticatorDataBytes = new Uint8Array(response.authenticatorData);
1035
+ const signatureBytes = new Uint8Array(response.signature);
1036
+ const id = credential.id;
1037
+ const clientDataJSON = String.fromCharCode(...clientDataJSONBytes);
1038
+ const challengeIndex = clientDataJSON.indexOf('"challenge"');
1039
+ const typeIndex = clientDataJSON.indexOf('"type"');
1040
+ const signature = parseAsn1Signature(signatureBytes);
1041
+ return {
1042
+ id,
1043
+ metadata: {
1044
+ authenticatorData: fromBytes(authenticatorDataBytes),
1045
+ clientDataJSON,
1046
+ challengeIndex,
1047
+ typeIndex,
1048
+ userVerificationRequired: requestOptions.publicKey.userVerification === "required"
1049
+ },
1050
+ signature,
1051
+ raw: credential
1052
+ };
1053
+ } catch (error) {
1054
+ throw new SignFailedError({
1055
+ cause: error
1056
+ });
1057
+ }
1058
+ }
1059
+ var SignFailedError = class extends BaseError {
1060
+ constructor({ cause } = {}) {
1061
+ super("Failed to request credential.", {
1062
+ cause
1063
+ });
1064
+ Object.defineProperty(this, "name", {
1065
+ enumerable: true,
1066
+ configurable: true,
1067
+ writable: true,
1068
+ value: "Authentication.SignFailedError"
1069
+ });
1070
+ }
1071
+ };
1072
+ function verify2(options) {
1073
+ const { challenge, metadata, origin, publicKey, rpId, signature } = options;
1074
+ const { authenticatorData, clientDataJSON, userVerificationRequired } = metadata;
1075
+ const authenticatorDataBytes = fromHex(authenticatorData);
1076
+ if (authenticatorDataBytes.length < 37)
1077
+ return false;
1078
+ if (rpId !== void 0) {
1079
+ const rpIdHash = authenticatorDataBytes.slice(0, 32);
1080
+ const expectedRpIdHash = sha2562(fromString2(rpId), { as: "Bytes" });
1081
+ if (!isEqual(rpIdHash, expectedRpIdHash))
1082
+ return false;
1083
+ }
1084
+ const flag = authenticatorDataBytes[32];
1085
+ if ((flag & 1) !== 1)
1086
+ return false;
1087
+ if (userVerificationRequired && (flag & 4) !== 4)
1088
+ return false;
1089
+ if ((flag & 8) !== 8 && (flag & 16) === 16)
1090
+ return false;
1091
+ const clientData = JSON.parse(clientDataJSON);
1092
+ if (clientData.type !== "webauthn.get")
1093
+ return false;
1094
+ if (!clientData.challenge || fromBytes(toBytes2(clientData.challenge)) !== challenge)
1095
+ return false;
1096
+ if (origin !== void 0) {
1097
+ const origins = Array.isArray(origin) ? origin : [origin];
1098
+ if (!origins.includes(clientData.origin))
1099
+ return false;
1100
+ }
1101
+ const clientDataJSONHash = sha2562(fromString(clientDataJSON), {
1102
+ as: "Bytes"
1103
+ });
1104
+ const payload = concat(authenticatorDataBytes, clientDataJSONHash);
1105
+ return verify({
1106
+ hash: true,
1107
+ payload,
1108
+ publicKey,
1109
+ signature
1110
+ });
1111
+ }
1112
+
1113
+ // node_modules/ox/_esm/core/WebAuthnP256.js
1114
+ var getSignPayload2 = getSignPayload;
1115
+ async function sign3(options) {
1116
+ return sign2(options);
1117
+ }
1118
+ function verify3(options) {
1119
+ return verify2(options);
1120
+ }
1121
+
1122
+ // node_modules/ox/_esm/core/Transaction.js
1123
+ var toRpcType = {
1124
+ legacy: "0x0",
1125
+ eip2930: "0x1",
1126
+ eip1559: "0x2",
1127
+ eip4844: "0x3",
1128
+ eip7702: "0x4"
1129
+ };
1130
+ var fromRpcType = {
1131
+ "0x0": "legacy",
1132
+ "0x1": "eip2930",
1133
+ "0x2": "eip1559",
1134
+ "0x3": "eip4844",
1135
+ "0x4": "eip7702"
1136
+ };
1137
+ function fromRpc(transaction, _options = {}) {
1138
+ if (!transaction)
1139
+ return null;
1140
+ const signature = extract(transaction);
1141
+ const transaction_ = {
1142
+ ...transaction,
1143
+ ...signature
1144
+ };
1145
+ transaction_.blockNumber = transaction.blockNumber ? BigInt(transaction.blockNumber) : null;
1146
+ if ("blockTimestamp" in transaction)
1147
+ transaction_.blockTimestamp = transaction.blockTimestamp ? BigInt(transaction.blockTimestamp) : transaction.blockTimestamp === null ? null : void 0;
1148
+ transaction_.data = transaction.input;
1149
+ transaction_.gas = BigInt(transaction.gas ?? 0n);
1150
+ transaction_.nonce = BigInt(transaction.nonce ?? 0n);
1151
+ transaction_.transactionIndex = transaction.transactionIndex ? Number(transaction.transactionIndex) : null;
1152
+ transaction_.value = BigInt(transaction.value ?? 0n);
1153
+ if (transaction.authorizationList)
1154
+ transaction_.authorizationList = fromRpcList(transaction.authorizationList);
1155
+ if (transaction.chainId)
1156
+ transaction_.chainId = Number(transaction.chainId);
1157
+ if (transaction.gasPrice)
1158
+ transaction_.gasPrice = BigInt(transaction.gasPrice);
1159
+ if (transaction.maxFeePerBlobGas)
1160
+ transaction_.maxFeePerBlobGas = BigInt(transaction.maxFeePerBlobGas);
1161
+ if (transaction.maxFeePerGas)
1162
+ transaction_.maxFeePerGas = BigInt(transaction.maxFeePerGas);
1163
+ if (transaction.maxPriorityFeePerGas)
1164
+ transaction_.maxPriorityFeePerGas = BigInt(transaction.maxPriorityFeePerGas);
1165
+ if (transaction.type)
1166
+ transaction_.type = fromRpcType[transaction.type] ?? transaction.type;
1167
+ if (signature)
1168
+ transaction_.v = yParityToV(signature.yParity);
1169
+ return transaction_;
1170
+ }
1171
+ function toRpc(transaction, _options) {
1172
+ const rpc = {};
1173
+ rpc.blockHash = transaction.blockHash;
1174
+ rpc.blockNumber = typeof transaction.blockNumber === "bigint" ? fromNumber(transaction.blockNumber) : null;
1175
+ if (typeof transaction.blockTimestamp === "bigint")
1176
+ rpc.blockTimestamp = fromNumber(transaction.blockTimestamp);
1177
+ else if (transaction.blockTimestamp === null)
1178
+ rpc.blockTimestamp = null;
1179
+ rpc.from = transaction.from;
1180
+ rpc.gas = fromNumber(transaction.gas ?? 0n);
1181
+ rpc.hash = transaction.hash;
1182
+ rpc.input = transaction.input;
1183
+ rpc.nonce = fromNumber(transaction.nonce ?? 0n);
1184
+ rpc.to = transaction.to;
1185
+ rpc.transactionIndex = transaction.transactionIndex ? fromNumber(transaction.transactionIndex) : null;
1186
+ rpc.type = toRpcType[transaction.type] ?? transaction.type;
1187
+ rpc.value = fromNumber(transaction.value ?? 0n);
1188
+ if (transaction.accessList)
1189
+ rpc.accessList = transaction.accessList;
1190
+ if (transaction.authorizationList)
1191
+ rpc.authorizationList = toRpcList(transaction.authorizationList);
1192
+ if (transaction.blobVersionedHashes)
1193
+ rpc.blobVersionedHashes = transaction.blobVersionedHashes;
1194
+ if (transaction.chainId)
1195
+ rpc.chainId = fromNumber(transaction.chainId);
1196
+ if (typeof transaction.gasPrice === "bigint")
1197
+ rpc.gasPrice = fromNumber(transaction.gasPrice);
1198
+ if (typeof transaction.maxFeePerBlobGas === "bigint")
1199
+ rpc.maxFeePerBlobGas = fromNumber(transaction.maxFeePerBlobGas);
1200
+ if (typeof transaction.maxFeePerGas === "bigint")
1201
+ rpc.maxFeePerGas = fromNumber(transaction.maxFeePerGas);
1202
+ if (typeof transaction.maxPriorityFeePerGas === "bigint")
1203
+ rpc.maxPriorityFeePerGas = fromNumber(transaction.maxPriorityFeePerGas);
1204
+ if (typeof transaction.r === "bigint")
1205
+ rpc.r = fromNumber(transaction.r, { size: 32 });
1206
+ if (typeof transaction.s === "bigint")
1207
+ rpc.s = fromNumber(transaction.s, { size: 32 });
1208
+ if (typeof transaction.v === "number")
1209
+ rpc.v = fromNumber(transaction.v, { size: 1 });
1210
+ if (typeof transaction.yParity === "number")
1211
+ rpc.yParity = transaction.yParity === 0 ? "0x0" : "0x1";
1212
+ return rpc;
1213
+ }
1214
+
1215
+ // node_modules/ox/_esm/core/TransactionRequest.js
1216
+ function fromRpc2(request) {
1217
+ const request_ = request;
1218
+ if (typeof request.authorizationList !== "undefined")
1219
+ request_.authorizationList = fromRpcList(request.authorizationList);
1220
+ if (typeof request.chainId !== "undefined")
1221
+ request_.chainId = toNumber(request.chainId);
1222
+ if (typeof request.gas !== "undefined")
1223
+ request_.gas = toBigInt2(request.gas);
1224
+ if (typeof request.gasPrice !== "undefined")
1225
+ request_.gasPrice = toBigInt2(request.gasPrice);
1226
+ if (typeof request.maxFeePerBlobGas !== "undefined")
1227
+ request_.maxFeePerBlobGas = toBigInt2(request.maxFeePerBlobGas);
1228
+ if (typeof request.maxFeePerGas !== "undefined")
1229
+ request_.maxFeePerGas = toBigInt2(request.maxFeePerGas);
1230
+ if (typeof request.maxPriorityFeePerGas !== "undefined")
1231
+ request_.maxPriorityFeePerGas = toBigInt2(request.maxPriorityFeePerGas);
1232
+ if (typeof request.nonce !== "undefined")
1233
+ request_.nonce = toBigInt2(request.nonce);
1234
+ if (typeof request.type !== "undefined")
1235
+ request_.type = fromRpcType[request.type] || request.type;
1236
+ if (typeof request.value !== "undefined")
1237
+ request_.value = toBigInt2(request.value);
1238
+ return request_;
1239
+ }
1240
+ function toRpc2(request) {
1241
+ const request_rpc = {};
1242
+ if (typeof request.accessList !== "undefined")
1243
+ request_rpc.accessList = request.accessList;
1244
+ if (typeof request.authorizationList !== "undefined")
1245
+ request_rpc.authorizationList = toRpcList(request.authorizationList);
1246
+ if (typeof request.blobVersionedHashes !== "undefined")
1247
+ request_rpc.blobVersionedHashes = request.blobVersionedHashes;
1248
+ if (typeof request.blobs !== "undefined")
1249
+ request_rpc.blobs = request.blobs;
1250
+ if (typeof request.chainId !== "undefined")
1251
+ request_rpc.chainId = fromNumber(request.chainId);
1252
+ if (typeof request.data !== "undefined") {
1253
+ request_rpc.data = request.data;
1254
+ request_rpc.input = request.data;
1255
+ } else if (typeof request.input !== "undefined") {
1256
+ request_rpc.data = request.input;
1257
+ request_rpc.input = request.input;
1258
+ }
1259
+ if (typeof request.from !== "undefined")
1260
+ request_rpc.from = request.from;
1261
+ if (typeof request.gas !== "undefined")
1262
+ request_rpc.gas = fromNumber(request.gas);
1263
+ if (typeof request.gasPrice !== "undefined")
1264
+ request_rpc.gasPrice = fromNumber(request.gasPrice);
1265
+ if (typeof request.maxFeePerBlobGas !== "undefined")
1266
+ request_rpc.maxFeePerBlobGas = fromNumber(request.maxFeePerBlobGas);
1267
+ if (typeof request.maxFeePerGas !== "undefined")
1268
+ request_rpc.maxFeePerGas = fromNumber(request.maxFeePerGas);
1269
+ if (typeof request.maxPriorityFeePerGas !== "undefined")
1270
+ request_rpc.maxPriorityFeePerGas = fromNumber(request.maxPriorityFeePerGas);
1271
+ if (typeof request.maxPriorityFeePerGas !== "undefined")
1272
+ request_rpc.maxPriorityFeePerGas = fromNumber(request.maxPriorityFeePerGas);
1273
+ if (typeof request.nonce !== "undefined")
1274
+ request_rpc.nonce = fromNumber(request.nonce);
1275
+ if (typeof request.to !== "undefined")
1276
+ request_rpc.to = request.to;
1277
+ if (typeof request.type !== "undefined")
1278
+ request_rpc.type = toRpcType[request.type] || request.type;
1279
+ if (typeof request.value !== "undefined")
1280
+ request_rpc.value = fromNumber(request.value);
1281
+ return request_rpc;
1282
+ }
1283
+
1284
+ // node_modules/ox/_esm/core/AccessList.js
1285
+ function fromTupleList(accessList) {
1286
+ const list = [];
1287
+ for (let i = 0; i < accessList.length; i++) {
1288
+ const [address, storageKeys] = accessList[i];
1289
+ if (address)
1290
+ assert(address, { strict: false });
1291
+ list.push({
1292
+ address,
1293
+ storageKeys: storageKeys.map((key) => validate(key) ? key : trimLeft(key))
1294
+ });
1295
+ }
1296
+ return list;
1297
+ }
1298
+ function toTupleList(accessList) {
1299
+ if (!accessList || accessList.length === 0)
1300
+ return [];
1301
+ const tuple = [];
1302
+ for (const { address, storageKeys } of accessList) {
1303
+ for (let j = 0; j < storageKeys.length; j++)
1304
+ if (size(storageKeys[j]) !== 32)
1305
+ throw new InvalidStorageKeySizeError({
1306
+ storageKey: storageKeys[j]
1307
+ });
1308
+ if (address)
1309
+ assert(address, { strict: false });
1310
+ tuple.push([address, storageKeys]);
1311
+ }
1312
+ return tuple;
1313
+ }
1314
+ var InvalidStorageKeySizeError = class extends BaseError {
1315
+ constructor({ storageKey }) {
1316
+ super(`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${size(storageKey)} bytes.`);
1317
+ Object.defineProperty(this, "name", {
1318
+ enumerable: true,
1319
+ configurable: true,
1320
+ writable: true,
1321
+ value: "AccessList.InvalidStorageKeySizeError"
1322
+ });
1323
+ }
1324
+ };
1325
+
1326
+ // node_modules/ox/_esm/core/Value.js
1327
+ var exponents = {
1328
+ wei: 0,
1329
+ gwei: 9,
1330
+ szabo: 12,
1331
+ finney: 15,
1332
+ ether: 18
1333
+ };
1334
+ function format(value, decimals = 0) {
1335
+ let display = value.toString();
1336
+ const negative = display.startsWith("-");
1337
+ if (negative)
1338
+ display = display.slice(1);
1339
+ display = display.padStart(decimals, "0");
1340
+ let [integer, fraction] = [
1341
+ display.slice(0, display.length - decimals),
1342
+ display.slice(display.length - decimals)
1343
+ ];
1344
+ fraction = fraction.replace(/(0+)$/, "");
1345
+ return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
1346
+ }
1347
+ function formatGwei(wei, unit = "wei") {
1348
+ return format(wei, exponents.gwei - exponents[unit]);
1349
+ }
1350
+
1351
+ // node_modules/ox/_esm/core/TxEnvelope.js
1352
+ var FeeCapTooHighError = class extends BaseError {
1353
+ constructor({ feeCap } = {}) {
1354
+ super(`The fee cap (\`maxFeePerGas\`/\`maxPriorityFeePerGas\`${feeCap ? ` = ${formatGwei(feeCap)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`);
1355
+ Object.defineProperty(this, "name", {
1356
+ enumerable: true,
1357
+ configurable: true,
1358
+ writable: true,
1359
+ value: "TransactionEnvelope.FeeCapTooHighError"
1360
+ });
1361
+ }
1362
+ };
1363
+ var InvalidChainIdError = class extends BaseError {
1364
+ constructor({ chainId }) {
1365
+ super(typeof chainId !== "undefined" ? `Chain ID "${chainId}" is invalid.` : "Chain ID is invalid.");
1366
+ Object.defineProperty(this, "name", {
1367
+ enumerable: true,
1368
+ configurable: true,
1369
+ writable: true,
1370
+ value: "TransactionEnvelope.InvalidChainIdError"
1371
+ });
1372
+ }
1373
+ };
1374
+ var InvalidSerializedError = class extends BaseError {
1375
+ constructor({ attributes, serialized, type }) {
1376
+ const missing = Object.entries(attributes).map(([key, value]) => typeof value === "undefined" ? key : void 0).filter(Boolean);
1377
+ super(`Invalid serialized transaction of type "${type}" was provided.`, {
1378
+ metaMessages: [
1379
+ `Serialized Transaction: "${serialized}"`,
1380
+ missing.length > 0 ? `Missing Attributes: ${missing.join(", ")}` : ""
1381
+ ].filter(Boolean)
1382
+ });
1383
+ Object.defineProperty(this, "name", {
1384
+ enumerable: true,
1385
+ configurable: true,
1386
+ writable: true,
1387
+ value: "TransactionEnvelope.InvalidSerializedError"
1388
+ });
1389
+ }
1390
+ };
1391
+ var TipAboveFeeCapError = class extends BaseError {
1392
+ constructor({ maxPriorityFeePerGas, maxFeePerGas } = {}) {
1393
+ super([
1394
+ `The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).`
1395
+ ].join("\n"));
1396
+ Object.defineProperty(this, "name", {
1397
+ enumerable: true,
1398
+ configurable: true,
1399
+ writable: true,
1400
+ value: "TransactionEnvelope.TipAboveFeeCapError"
1401
+ });
1402
+ }
1403
+ };
1404
+
1405
+ // node_modules/ox/_esm/core/WebCryptoP256.js
1406
+ async function sign4(options) {
1407
+ const { payload, privateKey } = options;
1408
+ const signature = await globalThis.crypto.subtle.sign({
1409
+ name: "ECDSA",
1410
+ hash: "SHA-256"
1411
+ }, privateKey, from(payload));
1412
+ const signature_bytes = fromArray(new Uint8Array(signature));
1413
+ const r = toBigInt(slice(signature_bytes, 0, 32));
1414
+ let s = toBigInt(slice(signature_bytes, 32, 64));
1415
+ if (s > p2562.CURVE.n / 2n)
1416
+ s = p2562.CURVE.n - s;
1417
+ return { r, s };
1418
+ }
1419
+
1420
+ export {
1421
+ getPublicKey,
1422
+ sign,
1423
+ verify,
1424
+ Base64_exports,
1425
+ getSignPayload2 as getSignPayload,
1426
+ sign3 as sign2,
1427
+ verify3 as verify2,
1428
+ toRpcType,
1429
+ fromRpcType,
1430
+ fromRpc,
1431
+ toRpc,
1432
+ fromRpc2,
1433
+ toRpc2,
1434
+ fromTupleList,
1435
+ toTupleList,
1436
+ FeeCapTooHighError,
1437
+ InvalidChainIdError,
1438
+ InvalidSerializedError,
1439
+ TipAboveFeeCapError,
1440
+ sign4 as sign3
1441
+ };
1442
+ /*! Bundled license information:
1443
+
1444
+ @noble/curves/esm/nist.js:
1445
+ @noble/curves/esm/p256.js:
1446
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
1447
+ */