@cardanowall/poe-standard 0.0.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.
@@ -0,0 +1,3283 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
5
+ // src/validator.ts
6
+
7
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/constants.js
8
+ var f = { POS_INT: 0, NEG_INT: 1, BYTE_STRING: 2, UTF8_STRING: 3, ARRAY: 4, MAP: 5, TAG: 6, SIMPLE_FLOAT: 7 };
9
+ var T = { DATE_STRING: 0, DATE_EPOCH: 1, POS_BIGINT: 2, NEG_BIGINT: 3, CBOR: 24, URI: 32, BASE64URL: 33, BASE64: 34, DATE_EPOCH_DAYS: 100, SET: 258, JSON: 262, WTF8: 273, SYMBOL: 280, DATE_FULL: 1004, REGEXP: 21066, SELF_DESCRIBED: 55799, INVALID_16: 65535, INVALID_32: 4294967295, INVALID_64: 0xffffffffffffffffn };
10
+ var I = { ZERO: 0, ONE: 24, TWO: 25, FOUR: 26, EIGHT: 27, INDEFINITE: 31 };
11
+ var o = { FALSE: 20, TRUE: 21, NULL: 22, UNDEFINED: 23 };
12
+ var A = class {
13
+ static BREAK = /* @__PURE__ */ Symbol.for("github.com/hildjj/cbor2/break");
14
+ static ENCODED = /* @__PURE__ */ Symbol.for("github.com/hildjj/cbor2/cbor-encoded");
15
+ static LENGTH = /* @__PURE__ */ Symbol.for("github.com/hildjj/cbor2/length");
16
+ };
17
+ var S = { MIN: -(2n ** 63n), MAX: 2n ** 64n - 1n };
18
+
19
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/tag.js
20
+ var o2 = class _o {
21
+ static #e = /* @__PURE__ */ new Map();
22
+ tag;
23
+ contents;
24
+ constructor(e2, t3 = void 0) {
25
+ this.tag = e2, this.contents = t3;
26
+ }
27
+ get noChildren() {
28
+ return !!_o.#e.get(this.tag)?.noChildren;
29
+ }
30
+ static registerDecoder(e2, t3, n2) {
31
+ const i = this.#e.get(e2);
32
+ return this.#e.set(e2, t3), i && ("comment" in t3 || (t3.comment = i.comment), "noChildren" in t3 || (t3.noChildren = i.noChildren)), n2 && !t3.comment && (t3.comment = () => `(${n2})`), i;
33
+ }
34
+ static clearDecoder(e2) {
35
+ const t3 = this.#e.get(e2);
36
+ return this.#e.delete(e2), t3;
37
+ }
38
+ static getDecoder(e2) {
39
+ return this.#e.get(e2);
40
+ }
41
+ static getAllDecoders() {
42
+ return new Map(this.#e);
43
+ }
44
+ *[Symbol.iterator]() {
45
+ yield this.contents;
46
+ }
47
+ push(e2) {
48
+ return this.contents = e2, 1;
49
+ }
50
+ decode(e2) {
51
+ const t3 = e2?.tags?.get(this.tag) ?? (e2?.ignoreGlobalTags ? void 0 : _o.#e.get(this.tag));
52
+ return t3 ? t3(this, e2) : this;
53
+ }
54
+ comment(e2, t3) {
55
+ const n2 = e2?.tags?.get(this.tag) ?? (e2?.ignoreGlobalTags ? void 0 : _o.#e.get(this.tag));
56
+ if (n2?.comment) return n2.comment(this, e2, t3);
57
+ }
58
+ toCBOR() {
59
+ return [this.tag, this.contents];
60
+ }
61
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](e2, t3, n2) {
62
+ return `${this.tag}(${n2(this.contents, t3)})`;
63
+ }
64
+ };
65
+
66
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/box.js
67
+ function f2(n2) {
68
+ if (n2 != null && typeof n2 == "object") return n2[A.ENCODED];
69
+ }
70
+ function s(n2) {
71
+ if (n2 != null && typeof n2 == "object") return n2[A.LENGTH];
72
+ }
73
+ function u(n2, e2) {
74
+ Object.defineProperty(n2, A.ENCODED, { configurable: true, enumerable: false, value: e2 });
75
+ }
76
+ function d(n2, e2) {
77
+ const r2 = Object(n2);
78
+ return u(r2, e2), r2;
79
+ }
80
+
81
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/utils.js
82
+ var g = /* @__PURE__ */ Symbol("CBOR_RANGES");
83
+ function c(r2, n2) {
84
+ Object.defineProperty(r2, g, { configurable: false, enumerable: false, writable: false, value: n2 });
85
+ }
86
+ function f3(r2) {
87
+ return r2[g];
88
+ }
89
+ function l(r2) {
90
+ return f3(r2) !== void 0;
91
+ }
92
+ function R(r2, n2 = 0, t3 = r2.length - 1) {
93
+ const o5 = r2.subarray(n2, t3), a4 = f3(r2);
94
+ if (a4) {
95
+ const s3 = [];
96
+ for (const e2 of a4) if (e2[0] >= n2 && e2[0] + e2[1] <= t3) {
97
+ const i = [...e2];
98
+ i[0] -= n2, s3.push(i);
99
+ }
100
+ s3.length && c(o5, s3);
101
+ }
102
+ return o5;
103
+ }
104
+ function b(r2) {
105
+ let n2 = Math.ceil(r2.length / 2);
106
+ const t3 = new Uint8Array(n2);
107
+ n2--;
108
+ for (let o5 = r2.length, a4 = o5 - 2; o5 >= 0; o5 = a4, a4 -= 2, n2--) t3[n2] = parseInt(r2.substring(a4, o5), 16);
109
+ return t3;
110
+ }
111
+ function A2(r2) {
112
+ return r2.reduce((n2, t3) => n2 + t3.toString(16).padStart(2, "0"), "");
113
+ }
114
+ function d2(r2) {
115
+ const n2 = r2.reduce((e2, i) => e2 + i.length, 0), t3 = r2.some((e2) => l(e2)), o5 = [], a4 = new Uint8Array(n2);
116
+ let s3 = 0;
117
+ for (const e2 of r2) {
118
+ if (!(e2 instanceof Uint8Array)) throw new TypeError(`Invalid array: ${e2}`);
119
+ if (a4.set(e2, s3), t3) {
120
+ const i = e2[g] ?? [[0, e2.length]];
121
+ for (const u3 of i) u3[0] += s3;
122
+ o5.push(...i);
123
+ }
124
+ s3 += e2.length;
125
+ }
126
+ return t3 && c(a4, o5), a4;
127
+ }
128
+ function y(r2) {
129
+ const n2 = atob(r2);
130
+ return Uint8Array.from(n2, (t3) => t3.codePointAt(0));
131
+ }
132
+ var p = { "-": "+", _: "/" };
133
+ function x(r2) {
134
+ const n2 = r2.replace(/[_-]/g, (t3) => p[t3]);
135
+ return y(n2.padEnd(Math.ceil(n2.length / 4) * 4, "="));
136
+ }
137
+ function h() {
138
+ const r2 = new Uint8Array(4), n2 = new Uint32Array(r2.buffer);
139
+ return !((n2[0] = 1) & r2[0]);
140
+ }
141
+ function U(r2) {
142
+ let n2 = "";
143
+ for (const t3 of r2) {
144
+ const o5 = t3.codePointAt(0)?.toString(16).padStart(4, "0");
145
+ n2 && (n2 += ", "), n2 += `U+${o5}`;
146
+ }
147
+ return n2;
148
+ }
149
+
150
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/typeEncoderMap.js
151
+ var s2 = class {
152
+ #e = /* @__PURE__ */ new Map();
153
+ registerEncoder(e2, t3) {
154
+ const n2 = this.#e.get(e2);
155
+ return this.#e.set(e2, t3), n2;
156
+ }
157
+ get(e2) {
158
+ return this.#e.get(e2);
159
+ }
160
+ delete(e2) {
161
+ return this.#e.delete(e2);
162
+ }
163
+ clear() {
164
+ this.#e.clear();
165
+ }
166
+ };
167
+
168
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/sorts.js
169
+ function f4(c5, d6) {
170
+ const [u3, a4, n2] = c5, [l6, s3, t3] = d6, r2 = Math.min(n2.length, t3.length);
171
+ for (let o5 = 0; o5 < r2; o5++) {
172
+ const e2 = n2[o5] - t3[o5];
173
+ if (e2 !== 0) return e2;
174
+ }
175
+ return 0;
176
+ }
177
+
178
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/writer.js
179
+ var e = class _e {
180
+ static defaultOptions = { chunkSize: 4096 };
181
+ #r;
182
+ #i = [];
183
+ #s = null;
184
+ #t = 0;
185
+ #a = 0;
186
+ constructor(t3 = {}) {
187
+ if (this.#r = { ..._e.defaultOptions, ...t3 }, this.#r.chunkSize < 8) throw new RangeError(`Expected size >= 8, got ${this.#r.chunkSize}`);
188
+ this.#n();
189
+ }
190
+ get length() {
191
+ return this.#a;
192
+ }
193
+ read() {
194
+ this.#o();
195
+ const t3 = new Uint8Array(this.#a);
196
+ let i = 0;
197
+ for (const s3 of this.#i) t3.set(s3, i), i += s3.length;
198
+ return this.#n(), t3;
199
+ }
200
+ write(t3) {
201
+ const i = t3.length;
202
+ i > this.#l() ? (this.#o(), i > this.#r.chunkSize ? (this.#i.push(t3), this.#n()) : (this.#n(), this.#i[this.#i.length - 1].set(t3), this.#t = i)) : (this.#i[this.#i.length - 1].set(t3, this.#t), this.#t += i), this.#a += i;
203
+ }
204
+ writeUint8(t3) {
205
+ this.#e(1), this.#s.setUint8(this.#t, t3), this.#h(1);
206
+ }
207
+ writeUint16(t3, i = false) {
208
+ this.#e(2), this.#s.setUint16(this.#t, t3, i), this.#h(2);
209
+ }
210
+ writeUint32(t3, i = false) {
211
+ this.#e(4), this.#s.setUint32(this.#t, t3, i), this.#h(4);
212
+ }
213
+ writeBigUint64(t3, i = false) {
214
+ this.#e(8), this.#s.setBigUint64(this.#t, t3, i), this.#h(8);
215
+ }
216
+ writeInt16(t3, i = false) {
217
+ this.#e(2), this.#s.setInt16(this.#t, t3, i), this.#h(2);
218
+ }
219
+ writeInt32(t3, i = false) {
220
+ this.#e(4), this.#s.setInt32(this.#t, t3, i), this.#h(4);
221
+ }
222
+ writeBigInt64(t3, i = false) {
223
+ this.#e(8), this.#s.setBigInt64(this.#t, t3, i), this.#h(8);
224
+ }
225
+ writeFloat32(t3, i = false) {
226
+ this.#e(4), this.#s.setFloat32(this.#t, t3, i), this.#h(4);
227
+ }
228
+ writeFloat64(t3, i = false) {
229
+ this.#e(8), this.#s.setFloat64(this.#t, t3, i), this.#h(8);
230
+ }
231
+ clear() {
232
+ this.#a = 0, this.#i = [], this.#n();
233
+ }
234
+ #n() {
235
+ const t3 = new Uint8Array(this.#r.chunkSize);
236
+ this.#i.push(t3), this.#t = 0, this.#s = new DataView(t3.buffer, t3.byteOffset, t3.byteLength);
237
+ }
238
+ #o() {
239
+ if (this.#t === 0) {
240
+ this.#i.pop();
241
+ return;
242
+ }
243
+ const t3 = this.#i.length - 1;
244
+ this.#i[t3] = this.#i[t3].subarray(0, this.#t), this.#t = 0, this.#s = null;
245
+ }
246
+ #l() {
247
+ const t3 = this.#i.length - 1;
248
+ return this.#i[t3].length - this.#t;
249
+ }
250
+ #e(t3) {
251
+ this.#l() < t3 && (this.#o(), this.#n());
252
+ }
253
+ #h(t3) {
254
+ this.#t += t3, this.#a += t3;
255
+ }
256
+ };
257
+
258
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/float.js
259
+ var w = 1n << 15n;
260
+ var f5 = 0b11111n << 10n;
261
+ var b2 = 1n << 9n;
262
+ var d3 = b2 - 1n;
263
+ var I2 = b2 | d3;
264
+ var g2 = 1n << 31n;
265
+ var l2 = 0b11111111n << 23n;
266
+ var A3 = 1n << 22n;
267
+ var E = A3 - 1n;
268
+ var p2 = A3 | E;
269
+ var N = 1n << 63n;
270
+ var a = 0b11111111111n << 52n;
271
+ var c2 = 1n << 51n;
272
+ var u2 = c2 - 1n;
273
+ var F = c2 | u2;
274
+ var _ = u2 - (d3 << 42n);
275
+ var S2 = u2 - (E << 29n);
276
+ var m = { 2: "0b", 8: "0o", 16: "0x" };
277
+ var x2 = ((t3) => (t3[t3.NATURAL = -2] = "NATURAL", t3[t3.UNKNOWN = -1] = "UNKNOWN", t3[t3.F16 = 2] = "F16", t3[t3.F32 = 4] = "F32", t3[t3.F64 = 8] = "F64", t3))(x2 || {});
278
+ function U2(i, n2, e2, r2) {
279
+ let o5 = "nan'";
280
+ return i.quiet || (o5 += "!"), i.sign === -1 && (o5 += "-"), o5 += r2(Math.abs(i.payload), e2), o5 += "'", o5 += i.encodingIndicator, o5;
281
+ }
282
+ var O = class extends Number {
283
+ #n;
284
+ #t = -1;
285
+ constructor(n2, e2 = true, r2 = -1) {
286
+ super(NaN);
287
+ const o5 = n2;
288
+ if (typeof n2 == "number") {
289
+ if (!Number.isSafeInteger(n2)) throw new Error(`Invalid NAN payload: ${n2}`);
290
+ n2 = BigInt(n2);
291
+ let t3 = 0n;
292
+ if (n2 < 0 && (t3 = N, n2 = -n2), n2 >= c2) throw new Error(`Payload too large: ${o5}`);
293
+ const s3 = e2 ? c2 : 0n;
294
+ switch (this.#n = t3 | a | s3 | n2, r2) {
295
+ case -2:
296
+ throw new Error("NAN_SIZE.NATURAL only valid for bigint constructor");
297
+ case -1:
298
+ r2 = this.preferredSize;
299
+ break;
300
+ case 2:
301
+ if (this.#n & _) throw new Error("Invalid size for payload");
302
+ break;
303
+ case 4:
304
+ if (this.#n & S2) throw new Error("Invalid size for payload");
305
+ break;
306
+ case 8:
307
+ break;
308
+ default:
309
+ throw new Error(`Invalid size: ${r2}`);
310
+ }
311
+ this.#t = r2;
312
+ } else if (typeof n2 == "bigint") {
313
+ let t3 = -1;
314
+ if ((n2 & a) === a) this.#n = n2, t3 = 8;
315
+ else if ((n2 & l2) === l2) {
316
+ const s3 = (n2 & g2) << 32n;
317
+ this.#n = s3 | a | (n2 & p2) << 29n, t3 = 4;
318
+ } else if ((n2 & f5) === f5) {
319
+ const s3 = (n2 & w) << 48n;
320
+ this.#n = s3 | a | (n2 & I2) << 42n, t3 = 2;
321
+ } else throw new Error(`Invalid raw NaN value: ${n2}`);
322
+ if (r2 === -1) this.#t = this.preferredSize;
323
+ else if (r2 === -2) this.#t = t3;
324
+ else {
325
+ if (r2 < t3) throw new Error("Invalid bigint NaN size");
326
+ this.#t = r2;
327
+ }
328
+ } else {
329
+ const t3 = new DataView(n2.buffer, n2.byteOffset, n2.byteLength);
330
+ switch (n2.length) {
331
+ case 3: {
332
+ if (n2[0] !== 249) throw new Error("Invalid CBOR encoding for half float");
333
+ const s3 = BigInt(t3.getUint16(1, false));
334
+ if ((s3 & f5) !== f5) throw new Error("Not a NaN");
335
+ const h5 = (s3 & w) << 48n;
336
+ this.#n = h5 | a | (s3 & I2) << 42n, this.#t = 2;
337
+ break;
338
+ }
339
+ case 5: {
340
+ if (n2[0] !== 250) throw new Error("Invalid CBOR encoding for single float");
341
+ const s3 = BigInt(t3.getUint32(1, false));
342
+ if ((s3 & l2) !== l2) throw new Error("Not a NaN");
343
+ const h5 = (s3 & g2) << 32n;
344
+ this.#n = h5 | a | (s3 & p2) << 29n, this.#t = 4;
345
+ break;
346
+ }
347
+ case 9: {
348
+ if (n2[0] !== 251) throw new Error("Invalid CBOR encoding for double float");
349
+ if (this.#n = t3.getBigUint64(1, false), (this.#n & a) !== a) throw new Error("Not a NaN (NaNaN)");
350
+ this.#t = 8;
351
+ break;
352
+ }
353
+ default:
354
+ throw new RangeError(`Invalid NAN size (should be 2, 4, or 8): ${n2.length - 1}`);
355
+ }
356
+ }
357
+ if (!this.payload && !this.quiet) throw new Error("Signalling NaN with zero payload");
358
+ }
359
+ get bytes() {
360
+ const n2 = new ArrayBuffer(this.#t + 1), e2 = new DataView(n2);
361
+ switch (this.#t) {
362
+ case 2: {
363
+ e2.setUint8(0, 249);
364
+ const o5 = (this.#n & N ? w : 0n) | f5 | (this.#n & F) >> 42n;
365
+ e2.setUint16(1, Number(o5), false);
366
+ break;
367
+ }
368
+ case 4: {
369
+ e2.setUint8(0, 250);
370
+ const o5 = (this.#n & N ? g2 : 0n) | l2 | (this.#n & F) >> 29n;
371
+ e2.setUint32(1, Number(o5), false);
372
+ break;
373
+ }
374
+ case 8:
375
+ e2.setUint8(0, 251), e2.setBigUint64(1, this.#n);
376
+ break;
377
+ }
378
+ return new Uint8Array(n2);
379
+ }
380
+ get quiet() {
381
+ return !!(this.#n & c2);
382
+ }
383
+ get sign() {
384
+ return this.#n & N ? -1 : 1;
385
+ }
386
+ get payload() {
387
+ return Number(this.#n & u2) * this.sign;
388
+ }
389
+ get raw() {
390
+ return this.#n;
391
+ }
392
+ get encodingIndicator() {
393
+ switch (this.#t) {
394
+ case 2:
395
+ return "_1";
396
+ case 4:
397
+ return "_2";
398
+ }
399
+ return "_3";
400
+ }
401
+ get size() {
402
+ return this.#t;
403
+ }
404
+ get preferredSize() {
405
+ return (this.#n & _) === 0n ? 2 : (this.#n & S2) === 0n ? 4 : 8;
406
+ }
407
+ get isShortestEncoding() {
408
+ return this.preferredSize === this.#t;
409
+ }
410
+ toCBOR(n2) {
411
+ n2.write(this.bytes);
412
+ }
413
+ toString(n2 = 10) {
414
+ return U2(this, 1, {}, (e2) => (m[n2] ?? "") + e2.toString(n2));
415
+ }
416
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](n2, e2, r2) {
417
+ return U2(this, n2, e2, r2);
418
+ }
419
+ };
420
+ function v(i, n2 = 0, e2 = false) {
421
+ const r2 = i[n2] & 128 ? -1 : 1, o5 = (i[n2] & 124) >> 2, t3 = (i[n2] & 3) << 8 | i[n2 + 1];
422
+ if (o5 === 0) {
423
+ if (e2 && t3 !== 0) throw new Error(`Unwanted subnormal: ${r2 * 5960464477539063e-23 * t3}`);
424
+ return r2 * 5960464477539063e-23 * t3;
425
+ } else if (o5 === 31) return t3 ? NaN : r2 * (1 / 0);
426
+ return r2 * 2 ** (o5 - 25) * (1024 + t3);
427
+ }
428
+ function Z(i) {
429
+ const n2 = new DataView(new ArrayBuffer(4));
430
+ n2.setFloat32(0, i, false);
431
+ const e2 = n2.getUint32(0, false);
432
+ if ((e2 & 8191) !== 0) return null;
433
+ let r2 = e2 >> 16 & 32768;
434
+ const o5 = e2 >> 23 & 255, t3 = e2 & 8388607;
435
+ if (!(o5 === 0 && t3 === 0)) if (o5 >= 113 && o5 <= 142) r2 += (o5 - 112 << 10) + (t3 >> 13);
436
+ else if (o5 >= 103 && o5 < 113) {
437
+ if (t3 & (1 << 126 - o5) - 1) return null;
438
+ r2 += t3 + 8388608 >> 126 - o5;
439
+ } else if (o5 === 255) r2 |= 31744, r2 |= t3 >> 13;
440
+ else return null;
441
+ return r2;
442
+ }
443
+ function k(i) {
444
+ if (i !== 0) {
445
+ const n2 = new ArrayBuffer(8), e2 = new DataView(n2);
446
+ e2.setFloat64(0, i, false);
447
+ const r2 = e2.getBigUint64(0, false);
448
+ if ((r2 & 0x7ff0000000000000n) === 0n) return r2 & 0x8000000000000000n ? -0 : 0;
449
+ }
450
+ return i;
451
+ }
452
+ function B(i) {
453
+ switch (i.length) {
454
+ case 2:
455
+ v(i, 0, true);
456
+ break;
457
+ case 4: {
458
+ const n2 = new DataView(i.buffer, i.byteOffset, i.byteLength), e2 = n2.getUint32(0, false);
459
+ if ((e2 & 2139095040) === 0 && e2 & 8388607) throw new Error(`Unwanted subnormal: ${n2.getFloat32(0, false)}`);
460
+ break;
461
+ }
462
+ case 8: {
463
+ const n2 = new DataView(i.buffer, i.byteOffset, i.byteLength), e2 = n2.getBigUint64(0, false);
464
+ if ((e2 & 0x7ff0000000000000n) === 0n && e2 & 0x000fffffffffffn) throw new Error(`Unwanted subnormal: ${n2.getFloat64(0, false)}`);
465
+ break;
466
+ }
467
+ default:
468
+ throw new TypeError(`Bad input to isSubnormal: ${i}`);
469
+ }
470
+ }
471
+
472
+ // ../../node_modules/.pnpm/@cto.af+wtf8@0.0.5/node_modules/@cto.af/wtf8/lib/errors.js
473
+ var DecodeError = class extends TypeError {
474
+ code = "ERR_ENCODING_INVALID_ENCODED_DATA";
475
+ constructor() {
476
+ super("The encoded data was not valid for encoding wtf-8");
477
+ }
478
+ };
479
+ var InvalidEncodingError = class extends RangeError {
480
+ code = "ERR_ENCODING_NOT_SUPPORTED";
481
+ constructor(label) {
482
+ super(`Invalid encoding: "${label}"`);
483
+ }
484
+ };
485
+
486
+ // ../../node_modules/.pnpm/@cto.af+wtf8@0.0.5/node_modules/@cto.af/wtf8/lib/const.js
487
+ var BOM = 65279;
488
+ var EMPTY = new Uint8Array(0);
489
+ var MIN_HIGH_SURROGATE = 55296;
490
+ var MIN_LOW_SURROGATE = 56320;
491
+ var REPLACEMENT = 65533;
492
+ var WTF8 = "wtf-8";
493
+
494
+ // ../../node_modules/.pnpm/@cto.af+wtf8@0.0.5/node_modules/@cto.af/wtf8/lib/decode.js
495
+ function isArrayBufferView(input) {
496
+ return input && typeof input === "object" && !(input instanceof ArrayBuffer) && !(input instanceof SharedArrayBuffer) && input.buffer instanceof ArrayBuffer;
497
+ }
498
+ function getUint8(input) {
499
+ if (!input) {
500
+ return EMPTY;
501
+ }
502
+ if (input instanceof Uint8Array) {
503
+ return input;
504
+ }
505
+ if (isArrayBufferView(input)) {
506
+ return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
507
+ }
508
+ return new Uint8Array(input);
509
+ }
510
+ var REMAINDER = [
511
+ 0,
512
+ 0,
513
+ 0,
514
+ 0,
515
+ 0,
516
+ 0,
517
+ 0,
518
+ 0,
519
+ -1,
520
+ -1,
521
+ -1,
522
+ -1,
523
+ 1,
524
+ 1,
525
+ 2,
526
+ 3
527
+ ];
528
+ var Wtf8Decoder = class _Wtf8Decoder {
529
+ static DEFAULT_BUFFERSIZE = 4096;
530
+ encoding = WTF8;
531
+ fatal;
532
+ ignoreBOM;
533
+ bufferSize;
534
+ #left = 0;
535
+ #cur = 0;
536
+ #pending = 0;
537
+ #first = true;
538
+ #buf;
539
+ constructor(label = "wtf8", options = void 0) {
540
+ if (label.toLowerCase().replace("-", "") !== "wtf8") {
541
+ throw new InvalidEncodingError(label);
542
+ }
543
+ this.fatal = Boolean(options?.fatal);
544
+ this.ignoreBOM = Boolean(options?.ignoreBOM);
545
+ this.bufferSize = Math.floor(options?.bufferSize ?? _Wtf8Decoder.DEFAULT_BUFFERSIZE);
546
+ if (isNaN(this.bufferSize) || this.bufferSize < 1) {
547
+ throw new RangeError(`Invalid buffer size: ${options?.bufferSize}`);
548
+ }
549
+ this.#buf = new Uint16Array(this.bufferSize);
550
+ }
551
+ decode(input, options) {
552
+ const streaming = Boolean(options?.stream);
553
+ const bytes = getUint8(input);
554
+ const res = [];
555
+ const out = this.#buf;
556
+ const maxSize = this.bufferSize - 3;
557
+ let pos = 0;
558
+ const fatal = () => {
559
+ this.#cur = 0;
560
+ this.#left = 0;
561
+ this.#pending = 0;
562
+ if (this.fatal) {
563
+ throw new DecodeError();
564
+ }
565
+ out[pos++] = REPLACEMENT;
566
+ };
567
+ const fatals = () => {
568
+ const p5 = this.#pending;
569
+ for (let i = 0; i < p5; i++) {
570
+ fatal();
571
+ }
572
+ };
573
+ const oneByte = (b5) => {
574
+ if (this.#left === 0) {
575
+ const n2 = REMAINDER[b5 >> 4];
576
+ switch (n2) {
577
+ case -1:
578
+ fatal();
579
+ break;
580
+ case 0:
581
+ out[pos++] = b5;
582
+ break;
583
+ case 1:
584
+ this.#cur = b5 & 31;
585
+ if ((this.#cur & 30) === 0) {
586
+ fatal();
587
+ } else {
588
+ this.#left = 1;
589
+ this.#pending = 1;
590
+ }
591
+ break;
592
+ case 2:
593
+ this.#cur = b5 & 15;
594
+ this.#left = 2;
595
+ this.#pending = 1;
596
+ break;
597
+ case 3:
598
+ if (b5 & 8) {
599
+ fatal();
600
+ } else {
601
+ this.#cur = b5 & 7;
602
+ this.#left = 3;
603
+ this.#pending = 1;
604
+ }
605
+ break;
606
+ }
607
+ } else {
608
+ if ((b5 & 192) !== 128) {
609
+ fatals();
610
+ return oneByte(b5);
611
+ }
612
+ if (this.#pending === 1 && this.#left === 2 && this.#cur === 0 && (b5 & 32) === 0) {
613
+ fatals();
614
+ return oneByte(b5);
615
+ }
616
+ if (this.#left === 3 && this.#cur === 0 && (b5 & 48) === 0) {
617
+ fatals();
618
+ return oneByte(b5);
619
+ }
620
+ this.#cur = this.#cur << 6 | b5 & 63;
621
+ this.#pending++;
622
+ if (--this.#left === 0) {
623
+ if (this.ignoreBOM || !this.#first || this.#cur !== BOM) {
624
+ if (this.#cur < 65536) {
625
+ out[pos++] = this.#cur;
626
+ } else {
627
+ const cp = this.#cur - 65536;
628
+ out[pos++] = cp >>> 10 & 1023 | MIN_HIGH_SURROGATE;
629
+ out[pos++] = cp & 1023 | MIN_LOW_SURROGATE;
630
+ }
631
+ }
632
+ this.#cur = 0;
633
+ this.#pending = 0;
634
+ this.#first = false;
635
+ }
636
+ }
637
+ };
638
+ for (const b5 of bytes) {
639
+ if (pos >= maxSize) {
640
+ res.push(String.fromCharCode.apply(null, out.subarray(0, pos)));
641
+ pos = 0;
642
+ }
643
+ oneByte(b5);
644
+ }
645
+ if (!streaming) {
646
+ this.#first = true;
647
+ if (this.#cur || this.#left) {
648
+ fatals();
649
+ }
650
+ }
651
+ if (pos > 0) {
652
+ res.push(String.fromCharCode.apply(null, out.subarray(0, pos)));
653
+ }
654
+ return res.join("");
655
+ }
656
+ };
657
+
658
+ // ../../node_modules/.pnpm/@cto.af+wtf8@0.0.5/node_modules/@cto.af/wtf8/lib/encode.js
659
+ function utf8length(str) {
660
+ let len = 0;
661
+ for (const s3 of str) {
662
+ const cp = s3.codePointAt(0);
663
+ if (cp < 128) {
664
+ len++;
665
+ } else if (cp < 2048) {
666
+ len += 2;
667
+ } else if (cp < 65536) {
668
+ len += 3;
669
+ } else {
670
+ len += 4;
671
+ }
672
+ }
673
+ return len;
674
+ }
675
+ var Wtf8Encoder = class {
676
+ encoding = WTF8;
677
+ encode(input) {
678
+ if (!input) {
679
+ return EMPTY;
680
+ }
681
+ const buf = new Uint8Array(utf8length(String(input)));
682
+ this.encodeInto(input, buf);
683
+ return buf;
684
+ }
685
+ encodeInto(source, destination) {
686
+ const str = String(source);
687
+ const len = str.length;
688
+ const outLen = destination.length;
689
+ let written = 0;
690
+ let read = 0;
691
+ for (read = 0; read < len; read++) {
692
+ const c5 = str.codePointAt(read);
693
+ if (c5 < 128) {
694
+ if (written >= outLen) {
695
+ break;
696
+ }
697
+ destination[written++] = c5;
698
+ } else if (c5 < 2048) {
699
+ if (written >= outLen - 1) {
700
+ break;
701
+ }
702
+ destination[written++] = 192 | c5 >> 6;
703
+ destination[written++] = 128 | c5 & 63;
704
+ } else if (c5 < 65536) {
705
+ if (written >= outLen - 2) {
706
+ break;
707
+ }
708
+ destination[written++] = 224 | c5 >> 12;
709
+ destination[written++] = 128 | c5 >> 6 & 63;
710
+ destination[written++] = 128 | c5 & 63;
711
+ } else {
712
+ if (written >= outLen - 3) {
713
+ break;
714
+ }
715
+ destination[written++] = 240 | c5 >> 18;
716
+ destination[written++] = 128 | c5 >> 12 & 63;
717
+ destination[written++] = 128 | c5 >> 6 & 63;
718
+ destination[written++] = 128 | c5 & 63;
719
+ read++;
720
+ }
721
+ }
722
+ return {
723
+ read,
724
+ written
725
+ };
726
+ }
727
+ };
728
+ var U3 = f.SIMPLE_FLOAT << 5 | I.TWO;
729
+ var h2 = f.SIMPLE_FLOAT << 5 | I.FOUR;
730
+ var B2 = f.SIMPLE_FLOAT << 5 | I.EIGHT;
731
+ var j = f.SIMPLE_FLOAT << 5 | o.TRUE;
732
+ var q = f.SIMPLE_FLOAT << 5 | o.FALSE;
733
+ var $ = f.SIMPLE_FLOAT << 5 | o.UNDEFINED;
734
+ var z = f.SIMPLE_FLOAT << 5 | o.NULL;
735
+ var H = new TextEncoder();
736
+ var K = new Wtf8Encoder();
737
+ var k2 = { ...e.defaultOptions, avoidInts: false, cde: false, collapseBigInts: true, dateTag: T.DATE_EPOCH, dcbor: false, float64: false, flushToZero: false, forceEndian: null, ignoreOriginalEncoding: false, largeNegativeAsBigInt: false, reduceUnsafeNumbers: false, rejectBigInts: false, rejectCustomSimples: false, rejectDuplicateKeys: false, rejectFloats: false, rejectUndefined: false, simplifyNegativeZero: false, sortKeys: null, stringNormalization: null, types: null, wtf8: false, ignoreGlobalTags: false };
738
+ var F2 = { cde: true, ignoreOriginalEncoding: true, sortKeys: f4 };
739
+ var Y = { ...F2, dcbor: true, largeNegativeAsBigInt: true, reduceUnsafeNumbers: true, rejectCustomSimples: true, rejectDuplicateKeys: true, rejectUndefined: true, simplifyNegativeZero: true, stringNormalization: "NFC" };
740
+ function y2(e2) {
741
+ const n2 = e2 < 0;
742
+ return typeof e2 == "bigint" ? [n2 ? -e2 - 1n : e2, n2] : [n2 ? -e2 - 1 : e2, n2];
743
+ }
744
+ function N2(e2, n2, i) {
745
+ if (i.rejectFloats) throw new Error(`Attempt to encode an unwanted floating point number: ${e2}`);
746
+ if (isNaN(e2)) n2.writeUint8(U3), n2.writeUint16(32256);
747
+ else if (!i.float64 && Math.fround(e2) === e2) {
748
+ const r2 = Z(e2);
749
+ r2 === null ? (n2.writeUint8(h2), n2.writeFloat32(e2)) : (n2.writeUint8(U3), n2.writeUint16(r2));
750
+ } else n2.writeUint8(B2), n2.writeFloat64(e2);
751
+ }
752
+ function a2(e2, n2, i) {
753
+ const [r2, t3] = y2(e2);
754
+ if (t3 && i) throw new TypeError(`Negative size: ${e2}`);
755
+ i ??= t3 ? f.NEG_INT : f.POS_INT, i <<= 5, r2 < 24 ? n2.writeUint8(i | r2) : r2 <= 255 ? (n2.writeUint8(i | I.ONE), n2.writeUint8(r2)) : r2 <= 65535 ? (n2.writeUint8(i | I.TWO), n2.writeUint16(r2)) : r2 <= 4294967295 ? (n2.writeUint8(i | I.FOUR), n2.writeUint32(r2)) : (n2.writeUint8(i | I.EIGHT), n2.writeBigUint64(BigInt(r2)));
756
+ }
757
+ function m2(e2, n2, i) {
758
+ typeof e2 == "number" ? a2(e2, n2, f.TAG) : typeof e2 == "object" && !i.ignoreOriginalEncoding && A.ENCODED in e2 ? n2.write(e2[A.ENCODED]) : e2 <= Number.MAX_SAFE_INTEGER ? a2(Number(e2), n2, f.TAG) : (n2.writeUint8(f.TAG << 5 | I.EIGHT), n2.writeBigUint64(BigInt(e2)));
759
+ }
760
+ function O2(e2, n2, i) {
761
+ const [r2, t3] = y2(e2);
762
+ if (i.collapseBigInts && (!i.largeNegativeAsBigInt || e2 >= -0x8000000000000000n)) {
763
+ if (r2 <= 0xffffffffn) {
764
+ a2(Number(e2), n2);
765
+ return;
766
+ }
767
+ if (r2 <= 0xffffffffffffffffn) {
768
+ const l6 = (t3 ? f.NEG_INT : f.POS_INT) << 5;
769
+ n2.writeUint8(l6 | I.EIGHT), n2.writeBigUint64(r2);
770
+ return;
771
+ }
772
+ }
773
+ if (i.rejectBigInts) throw new Error(`Attempt to encode unwanted bigint: ${e2}`);
774
+ const o5 = t3 ? T.NEG_BIGINT : T.POS_BIGINT, c5 = r2.toString(16), s3 = c5.length % 2 ? "0" : "";
775
+ m2(o5, n2, i);
776
+ const u3 = b(s3 + c5);
777
+ a2(u3.length, n2, f.BYTE_STRING), n2.write(u3);
778
+ }
779
+ function Z2(e2, n2, i) {
780
+ i.flushToZero && (e2 = k(e2)), Object.is(e2, -0) ? i.simplifyNegativeZero ? i.avoidInts ? N2(0, n2, i) : a2(0, n2) : N2(e2, n2, i) : !i.avoidInts && Number.isSafeInteger(e2) ? a2(e2, n2) : i.reduceUnsafeNumbers && Math.floor(e2) === e2 && e2 >= S.MIN && e2 <= S.MAX ? O2(BigInt(e2), n2, i) : N2(e2, n2, i);
781
+ }
782
+ function R2(e2, n2, i) {
783
+ const r2 = i.stringNormalization ? e2.normalize(i.stringNormalization) : e2;
784
+ if (i.wtf8 && !e2.isWellFormed()) {
785
+ const t3 = K.encode(r2);
786
+ m2(T.WTF8, n2, i), a2(t3.length, n2, f.BYTE_STRING), n2.write(t3);
787
+ } else {
788
+ const t3 = H.encode(r2);
789
+ a2(t3.length, n2, f.UTF8_STRING), n2.write(t3);
790
+ }
791
+ }
792
+ function J(e2, n2, i) {
793
+ const r2 = e2;
794
+ L(r2, r2.length, f.ARRAY, n2, i);
795
+ for (const t3 of r2) g3(t3, n2, i);
796
+ }
797
+ function V(e2, n2) {
798
+ a2(e2.length, n2, f.BYTE_STRING), n2.write(e2);
799
+ }
800
+ var b3 = new s2();
801
+ b3.registerEncoder(Array, J), b3.registerEncoder(Uint8Array, V);
802
+ function ue(e2, n2) {
803
+ return b3.registerEncoder(e2, n2);
804
+ }
805
+ function L(e2, n2, i, r2, t3) {
806
+ const o5 = s(e2);
807
+ o5 && !t3.ignoreOriginalEncoding ? r2.write(o5) : a2(n2, r2, i);
808
+ }
809
+ function X(e2, n2, i) {
810
+ if (e2 === null) {
811
+ n2.writeUint8(z);
812
+ return;
813
+ }
814
+ if (!i.ignoreOriginalEncoding && A.ENCODED in e2) {
815
+ n2.write(e2[A.ENCODED]);
816
+ return;
817
+ }
818
+ const r2 = e2.constructor;
819
+ if (r2) {
820
+ const o5 = i.types?.get(r2) ?? (i.ignoreGlobalTags ? void 0 : b3.get(r2));
821
+ if (o5) {
822
+ const c5 = o5(e2, n2, i);
823
+ if (c5 !== void 0) {
824
+ if (!Array.isArray(c5) || c5.length !== 2) throw new Error("Invalid encoder return value");
825
+ (typeof c5[0] == "bigint" || isFinite(Number(c5[0]))) && m2(c5[0], n2, i), g3(c5[1], n2, i);
826
+ }
827
+ return;
828
+ }
829
+ }
830
+ if (typeof e2.toCBOR == "function") {
831
+ const o5 = e2.toCBOR(n2, i);
832
+ o5 && ((typeof o5[0] == "bigint" || isFinite(Number(o5[0]))) && m2(o5[0], n2, i), g3(o5[1], n2, i));
833
+ return;
834
+ }
835
+ if (typeof e2.toJSON == "function") {
836
+ g3(e2.toJSON(), n2, i);
837
+ return;
838
+ }
839
+ const t3 = Object.entries(e2).map((o5) => [o5[0], o5[1], v2(o5[0], i)]);
840
+ i.sortKeys && t3.sort(i.sortKeys), L(e2, t3.length, f.MAP, n2, i);
841
+ for (const [o5, c5, s3] of t3) n2.write(s3), g3(c5, n2, i);
842
+ }
843
+ function Q(e2, n2, i) {
844
+ if (!e2.description || e2 !== Symbol.for(e2.description)) throw new TypeError(`Private or empty symbol: ${e2.toString()}`);
845
+ m2(280, n2, i), R2(e2.description, n2, i);
846
+ }
847
+ function g3(e2, n2, i) {
848
+ switch (typeof e2) {
849
+ case "number":
850
+ Z2(e2, n2, i);
851
+ break;
852
+ case "bigint":
853
+ O2(e2, n2, i);
854
+ break;
855
+ case "string":
856
+ R2(e2, n2, i);
857
+ break;
858
+ case "boolean":
859
+ n2.writeUint8(e2 ? j : q);
860
+ break;
861
+ case "undefined":
862
+ if (i.rejectUndefined) throw new Error("Attempt to encode unwanted undefined.");
863
+ n2.writeUint8($);
864
+ break;
865
+ case "object":
866
+ X(e2, n2, i);
867
+ break;
868
+ case "symbol":
869
+ Q(e2, n2, i);
870
+ break;
871
+ default:
872
+ throw new TypeError(`Unknown type: ${typeof e2}, ${String(e2)}`);
873
+ }
874
+ }
875
+ function v2(e2, n2 = {}) {
876
+ const i = { ...k2 };
877
+ n2.dcbor ? Object.assign(i, Y) : n2.cde && Object.assign(i, F2), Object.assign(i, n2);
878
+ const r2 = new e(i);
879
+ return g3(e2, r2, i), r2.read();
880
+ }
881
+
882
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/options.js
883
+ var o3 = ((e2) => (e2[e2.NEVER = -1] = "NEVER", e2[e2.PREFERRED = 0] = "PREFERRED", e2[e2.ALWAYS = 1] = "ALWAYS", e2))(o3 || {});
884
+
885
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/simple.js
886
+ var t = class _t {
887
+ static KnownSimple = /* @__PURE__ */ new Map([[o.FALSE, false], [o.TRUE, true], [o.NULL, null], [o.UNDEFINED, void 0]]);
888
+ value;
889
+ constructor(e2) {
890
+ this.value = e2;
891
+ }
892
+ static create(e2) {
893
+ return _t.KnownSimple.has(e2) ? _t.KnownSimple.get(e2) : new _t(e2);
894
+ }
895
+ toCBOR(e2, i) {
896
+ if (i.rejectCustomSimples) throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);
897
+ a2(this.value, e2, f.SIMPLE_FLOAT);
898
+ }
899
+ toString() {
900
+ return `simple(${this.value})`;
901
+ }
902
+ decode() {
903
+ return _t.KnownSimple.has(this.value) ? _t.KnownSimple.get(this.value) : this;
904
+ }
905
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](e2, i, r2) {
906
+ return `simple(${r2(this.value, i)})`;
907
+ }
908
+ };
909
+
910
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/decodeStream.js
911
+ var p3 = new TextDecoder("utf8", { fatal: true, ignoreBOM: true });
912
+ var y3 = class _y {
913
+ static defaultOptions = { maxDepth: 1024, encoding: "hex", requirePreferred: false };
914
+ #t;
915
+ #r;
916
+ #e = 0;
917
+ #i;
918
+ constructor(t3, r2) {
919
+ if (this.#i = { ..._y.defaultOptions, ...r2 }, typeof t3 == "string") switch (this.#i.encoding) {
920
+ case "hex":
921
+ this.#t = b(t3);
922
+ break;
923
+ case "base64":
924
+ this.#t = y(t3);
925
+ break;
926
+ default:
927
+ throw new TypeError(`Encoding not implemented: "${this.#i.encoding}"`);
928
+ }
929
+ else this.#t = t3;
930
+ this.#r = new DataView(this.#t.buffer, this.#t.byteOffset, this.#t.byteLength);
931
+ }
932
+ toHere(t3) {
933
+ return R(this.#t, t3, this.#e);
934
+ }
935
+ *[Symbol.iterator]() {
936
+ if (yield* this.#n(0), this.#e !== this.#t.length) throw new Error("Extra data in input");
937
+ }
938
+ *seq() {
939
+ for (; this.#e < this.#t.length; ) yield* this.#n(0);
940
+ }
941
+ *#n(t3) {
942
+ if (t3++ > this.#i.maxDepth) throw new Error(`Maximum depth ${this.#i.maxDepth} exceeded`);
943
+ const r2 = this.#e, c5 = this.#r.getUint8(this.#e++), i = c5 >> 5, n2 = c5 & 31;
944
+ let e2 = n2, f7 = false, a4 = 0;
945
+ switch (n2) {
946
+ case I.ONE:
947
+ if (a4 = 1, e2 = this.#r.getUint8(this.#e), i === f.SIMPLE_FLOAT) {
948
+ if (e2 < 32) throw new Error(`Invalid simple encoding in extra byte: ${e2}`);
949
+ f7 = true;
950
+ } else if (this.#i.requirePreferred && e2 < 24) throw new Error(`Unexpectedly long integer encoding (1) for ${e2}`);
951
+ break;
952
+ case I.TWO:
953
+ if (a4 = 2, i === f.SIMPLE_FLOAT) e2 = v(this.#t, this.#e);
954
+ else if (e2 = this.#r.getUint16(this.#e, false), this.#i.requirePreferred && e2 <= 255) throw new Error(`Unexpectedly long integer encoding (2) for ${e2}`);
955
+ break;
956
+ case I.FOUR:
957
+ if (a4 = 4, i === f.SIMPLE_FLOAT) e2 = this.#r.getFloat32(this.#e, false);
958
+ else if (e2 = this.#r.getUint32(this.#e, false), this.#i.requirePreferred && e2 <= 65535) throw new Error(`Unexpectedly long integer encoding (4) for ${e2}`);
959
+ break;
960
+ case I.EIGHT: {
961
+ if (a4 = 8, i === f.SIMPLE_FLOAT) e2 = this.#r.getFloat64(this.#e, false);
962
+ else if (e2 = this.#r.getBigUint64(this.#e, false), e2 <= Number.MAX_SAFE_INTEGER && (e2 = Number(e2)), this.#i.requirePreferred && e2 <= 4294967295) throw new Error(`Unexpectedly long integer encoding (8) for ${e2}`);
963
+ break;
964
+ }
965
+ case 28:
966
+ case 29:
967
+ case 30:
968
+ throw new Error(`Additional info not implemented: ${n2}`);
969
+ case I.INDEFINITE:
970
+ switch (i) {
971
+ case f.POS_INT:
972
+ case f.NEG_INT:
973
+ case f.TAG:
974
+ throw new Error(`Invalid indefinite encoding for MT ${i}`);
975
+ case f.SIMPLE_FLOAT:
976
+ yield [i, n2, A.BREAK, r2, 0];
977
+ return;
978
+ }
979
+ e2 = 1 / 0;
980
+ break;
981
+ default:
982
+ f7 = true;
983
+ }
984
+ switch (this.#e += a4, i) {
985
+ case f.POS_INT:
986
+ yield [i, n2, e2, r2, a4];
987
+ break;
988
+ case f.NEG_INT:
989
+ yield [i, n2, typeof e2 == "bigint" ? -1n - e2 : -1 - Number(e2), r2, a4];
990
+ break;
991
+ case f.BYTE_STRING:
992
+ e2 === 1 / 0 ? yield* this.#s(i, t3, r2) : yield [i, n2, this.#a(e2), r2, e2];
993
+ break;
994
+ case f.UTF8_STRING:
995
+ e2 === 1 / 0 ? yield* this.#s(i, t3, r2) : yield [i, n2, p3.decode(this.#a(e2)), r2, e2];
996
+ break;
997
+ case f.ARRAY:
998
+ if (e2 === 1 / 0) yield* this.#s(i, t3, r2, false);
999
+ else {
1000
+ const o5 = Number(e2);
1001
+ yield [i, n2, o5, r2, a4];
1002
+ for (let h5 = 0; h5 < o5; h5++) yield* this.#n(t3 + 1);
1003
+ }
1004
+ break;
1005
+ case f.MAP:
1006
+ if (e2 === 1 / 0) yield* this.#s(i, t3, r2, false);
1007
+ else {
1008
+ const o5 = Number(e2);
1009
+ yield [i, n2, o5, r2, a4];
1010
+ for (let h5 = 0; h5 < o5; h5++) yield* this.#n(t3), yield* this.#n(t3);
1011
+ }
1012
+ break;
1013
+ case f.TAG:
1014
+ yield [i, n2, e2, r2, a4], yield* this.#n(t3);
1015
+ break;
1016
+ case f.SIMPLE_FLOAT: {
1017
+ const o5 = e2;
1018
+ f7 && (e2 = t.create(Number(e2))), yield [i, n2, e2, r2, o5];
1019
+ break;
1020
+ }
1021
+ }
1022
+ }
1023
+ #a(t3) {
1024
+ const r2 = R(this.#t, this.#e, this.#e += t3);
1025
+ if (r2.length !== t3) throw new Error(`Unexpected end of stream reading ${t3} bytes, got ${r2.length}`);
1026
+ return r2;
1027
+ }
1028
+ *#s(t3, r2, c5, i = true) {
1029
+ for (yield [t3, I.INDEFINITE, 1 / 0, c5, 1 / 0]; ; ) {
1030
+ const n2 = this.#n(r2), e2 = n2.next(), [f7, a4, o5] = e2.value;
1031
+ if (o5 === A.BREAK) {
1032
+ yield e2.value, n2.next();
1033
+ return;
1034
+ }
1035
+ if (i) {
1036
+ if (f7 !== t3) throw new Error(`Unmatched major type. Expected ${t3}, got ${f7}.`);
1037
+ if (a4 === I.INDEFINITE) throw new Error("New stream started in typed stream");
1038
+ }
1039
+ yield e2.value, yield* n2;
1040
+ }
1041
+ }
1042
+ };
1043
+
1044
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/container.js
1045
+ var A4 = /* @__PURE__ */ new Map([[I.ZERO, 1], [I.ONE, 2], [I.TWO, 3], [I.FOUR, 5], [I.EIGHT, 9]]);
1046
+ var R3 = new Uint8Array(0);
1047
+ function F3(h5, r2) {
1048
+ return !r2.boxed && !r2.preferMap && h5.every(([i]) => typeof i == "string") ? Object.fromEntries(h5) : new Map(h5);
1049
+ }
1050
+ var y4 = class _y {
1051
+ static defaultDecodeOptions = { ...y3.defaultOptions, ParentType: _y, boxed: false, cde: false, dcbor: false, diagnosticSizes: o3.PREFERRED, collapseBigInts: false, convertUnsafeIntsToFloat: false, createObject: F3, keepNanPayloads: false, pretty: false, preferBigInt: false, preferMap: false, rejectLargeNegatives: false, rejectBigInts: false, rejectDuplicateKeys: false, rejectFloats: false, rejectInts: false, rejectLongLoundNaN: false, rejectLongFloats: false, rejectNegativeZero: false, rejectSimple: false, rejectStreaming: false, rejectStringsNotNormalizedAs: null, rejectSubnormals: false, rejectUndefined: false, rejectUnsafeFloatInts: false, saveOriginal: false, sortKeys: null, tags: null, ignoreGlobalTags: false };
1052
+ static cdeDecodeOptions = { cde: true, rejectStreaming: true, requirePreferred: true, sortKeys: f4 };
1053
+ static dcborDecodeOptions = { ...this.cdeDecodeOptions, dcbor: true, convertUnsafeIntsToFloat: true, rejectDuplicateKeys: true, rejectLargeNegatives: true, rejectLongLoundNaN: true, rejectLongFloats: true, rejectNegativeZero: true, rejectSimple: true, rejectUndefined: true, rejectUnsafeFloatInts: true, rejectStringsNotNormalizedAs: "NFC" };
1054
+ parent;
1055
+ mt;
1056
+ ai;
1057
+ left;
1058
+ offset;
1059
+ count = 0;
1060
+ children = [];
1061
+ depth = 0;
1062
+ #e;
1063
+ #t = null;
1064
+ constructor(r2, i, e2, t3) {
1065
+ if ([this.mt, this.ai, , this.offset] = r2, this.left = i, this.parent = e2, this.#e = t3, e2 && (this.depth = e2.depth + 1), this.mt === f.MAP && (this.#e.sortKeys || this.#e.rejectDuplicateKeys) && (this.#t = []), this.#e.rejectStreaming && this.ai === I.INDEFINITE) throw new Error("Streaming not supported");
1066
+ }
1067
+ get isStreaming() {
1068
+ return this.left === 1 / 0;
1069
+ }
1070
+ get done() {
1071
+ return this.left === 0;
1072
+ }
1073
+ static create(r2, i, e2, t3) {
1074
+ const [s3, u3, n2, c5] = r2;
1075
+ switch (s3) {
1076
+ case f.POS_INT:
1077
+ case f.NEG_INT: {
1078
+ if (e2.rejectInts) throw new Error(`Unexpected integer: ${n2}`);
1079
+ if (e2.rejectLargeNegatives && n2 < -0x8000000000000000n) throw new Error(`Invalid 65bit negative number: ${n2}`);
1080
+ let o5 = n2;
1081
+ return e2.preferBigInt ? o5 = BigInt(o5) : e2.convertUnsafeIntsToFloat && o5 >= S.MIN && o5 <= S.MAX && (o5 = Number(n2)), e2.boxed ? d(o5, t3.toHere(c5)) : o5;
1082
+ }
1083
+ case f.SIMPLE_FLOAT:
1084
+ if (u3 > I.ONE) {
1085
+ if (typeof n2 == "symbol") return n2;
1086
+ if (e2.rejectFloats) throw new Error(`Decoding unwanted floating point number: ${n2}`);
1087
+ if (e2.rejectNegativeZero && Object.is(n2, -0)) throw new Error("Decoding negative zero");
1088
+ if (isNaN(n2)) {
1089
+ const o5 = t3.toHere(c5), f7 = new O(o5);
1090
+ if (e2.rejectLongLoundNaN) {
1091
+ if (f7.payload || o5.length > 3) throw new Error(`Invalid NaN encoding: "${A2(o5)}"`);
1092
+ } else if (e2.keepNanPayloads && (f7.payload || f7.sign === -1)) {
1093
+ if (e2.rejectLongFloats && !f7.isShortestEncoding) throw new Error(`NaN should have been encoded shorter: ${n2}`);
1094
+ return f7;
1095
+ }
1096
+ }
1097
+ if (e2.rejectSubnormals && B(t3.toHere(c5 + 1)), e2.rejectLongFloats) {
1098
+ const o5 = v2(n2, { chunkSize: 9, reduceUnsafeNumbers: e2.rejectUnsafeFloatInts });
1099
+ if (o5[0] >> 5 !== s3) throw new Error(`Should have been encoded as int, not float: ${n2}`);
1100
+ if (o5.length < A4.get(u3)) throw new Error(`Number should have been encoded shorter: ${n2}`);
1101
+ }
1102
+ if (typeof n2 == "number" && e2.boxed) return d(n2, t3.toHere(c5));
1103
+ } else {
1104
+ if (e2.rejectSimple && n2 instanceof t) throw new Error(`Invalid simple value: ${n2}`);
1105
+ if (e2.rejectUndefined && n2 === void 0) throw new Error("Unexpected undefined");
1106
+ }
1107
+ return n2;
1108
+ case f.BYTE_STRING:
1109
+ case f.UTF8_STRING:
1110
+ if (n2 === 1 / 0) return new e2.ParentType(r2, 1 / 0, i, e2);
1111
+ if (e2.rejectStringsNotNormalizedAs && typeof n2 == "string") {
1112
+ const o5 = n2.normalize(e2.rejectStringsNotNormalizedAs);
1113
+ if (n2 !== o5) throw new Error(`String not normalized as "${e2.rejectStringsNotNormalizedAs}", got [${U(n2)}] instead of [${U(o5)}]`);
1114
+ }
1115
+ return e2.boxed ? d(n2, t3.toHere(c5)) : n2;
1116
+ case f.ARRAY:
1117
+ return new e2.ParentType(r2, n2, i, e2);
1118
+ case f.MAP:
1119
+ return new e2.ParentType(r2, n2 * 2, i, e2);
1120
+ case f.TAG: {
1121
+ const o5 = new e2.ParentType(r2, 1, i, e2);
1122
+ return o5.children = new o2(n2), o5;
1123
+ }
1124
+ }
1125
+ throw new TypeError(`Invalid major type: ${s3}`);
1126
+ }
1127
+ static decodeToEncodeOpts(r2) {
1128
+ return { ...k2, avoidInts: r2.rejectInts, float64: !r2.rejectLongFloats, flushToZero: r2.rejectSubnormals, largeNegativeAsBigInt: r2.rejectLargeNegatives, sortKeys: r2.sortKeys };
1129
+ }
1130
+ push(r2, i, e2) {
1131
+ if (this.children.push(r2), this.#t) {
1132
+ const t3 = f2(r2) || i.toHere(e2);
1133
+ this.#t.push(t3);
1134
+ }
1135
+ return --this.left;
1136
+ }
1137
+ replaceLast(r2, i, e2) {
1138
+ let t3, s3 = -1 / 0;
1139
+ if (this.children instanceof o2 ? (s3 = 0, t3 = this.children.contents, this.children.contents = r2) : (s3 = this.children.length - 1, t3 = this.children[s3], this.children[s3] = r2), this.#t) {
1140
+ const u3 = f2(r2) || e2.toHere(i.offset);
1141
+ this.#t[s3] = u3;
1142
+ }
1143
+ return t3;
1144
+ }
1145
+ convert(r2) {
1146
+ let i;
1147
+ switch (this.mt) {
1148
+ case f.ARRAY:
1149
+ i = this.children;
1150
+ break;
1151
+ case f.MAP: {
1152
+ const e2 = this.#r();
1153
+ if (this.#e.sortKeys) {
1154
+ let t3;
1155
+ for (const s3 of e2) {
1156
+ if (t3 && this.#e.sortKeys(t3, s3) >= 0) throw new Error(`Duplicate or out of order key: "0x${s3[2]}"`);
1157
+ t3 = s3;
1158
+ }
1159
+ } else if (this.#e.rejectDuplicateKeys) {
1160
+ const t3 = /* @__PURE__ */ new Set();
1161
+ for (const [s3, u3, n2] of e2) {
1162
+ const c5 = A2(n2);
1163
+ if (t3.has(c5)) throw new Error(`Duplicate key: "0x${c5}"`);
1164
+ t3.add(c5);
1165
+ }
1166
+ }
1167
+ i = this.#e.createObject(e2, this.#e);
1168
+ break;
1169
+ }
1170
+ case f.BYTE_STRING:
1171
+ return d2(this.children);
1172
+ case f.UTF8_STRING: {
1173
+ const e2 = this.children.join("");
1174
+ i = this.#e.boxed ? d(e2, r2.toHere(this.offset)) : e2;
1175
+ break;
1176
+ }
1177
+ case f.TAG:
1178
+ i = this.children.decode(this.#e);
1179
+ break;
1180
+ default:
1181
+ throw new TypeError(`Invalid mt on convert: ${this.mt}`);
1182
+ }
1183
+ return this.#e.saveOriginal && i && typeof i == "object" && u(i, r2.toHere(this.offset)), i;
1184
+ }
1185
+ #r() {
1186
+ const r2 = this.children, i = r2.length;
1187
+ if (i % 2) throw new Error("Missing map value");
1188
+ const e2 = new Array(i / 2);
1189
+ if (this.#t) for (let t3 = 0; t3 < i; t3 += 2) e2[t3 >> 1] = [r2[t3], r2[t3 + 1], this.#t[t3]];
1190
+ else for (let t3 = 0; t3 < i; t3 += 2) e2[t3 >> 1] = [r2[t3], r2[t3 + 1], R3];
1191
+ return e2;
1192
+ }
1193
+ };
1194
+
1195
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/diagnostic.js
1196
+ var O3 = " ";
1197
+ var y5 = new TextEncoder();
1198
+ var g4 = class extends y4 {
1199
+ close = "";
1200
+ quote = '"';
1201
+ get isEmptyStream() {
1202
+ return (this.mt === f.UTF8_STRING || this.mt === f.BYTE_STRING) && this.count === 0;
1203
+ }
1204
+ };
1205
+ function a3(m4, l6, n2, p5) {
1206
+ let t3 = "";
1207
+ if (l6 === I.INDEFINITE) t3 += "_";
1208
+ else {
1209
+ if (p5.diagnosticSizes === o3.NEVER) return "";
1210
+ {
1211
+ let r2 = p5.diagnosticSizes === o3.ALWAYS;
1212
+ if (!r2) {
1213
+ let e2 = I.ZERO;
1214
+ if (Object.is(n2, -0)) e2 = I.TWO;
1215
+ else if (m4 === f.POS_INT || m4 === f.NEG_INT) {
1216
+ const T2 = n2 < 0, u3 = typeof n2 == "bigint" ? 1n : 1, o5 = T2 ? -n2 - u3 : n2;
1217
+ o5 <= 23 ? e2 = Number(o5) : o5 <= 255 ? e2 = I.ONE : o5 <= 65535 ? e2 = I.TWO : o5 <= 4294967295 ? e2 = I.FOUR : e2 = I.EIGHT;
1218
+ } else isFinite(n2) ? Math.fround(n2) === n2 ? Z(n2) == null ? e2 = I.FOUR : e2 = I.TWO : e2 = I.EIGHT : e2 = I.TWO;
1219
+ r2 = e2 !== l6;
1220
+ }
1221
+ r2 && (t3 += "_", l6 < I.ONE ? t3 += "i" : t3 += String(l6 - 24));
1222
+ }
1223
+ }
1224
+ return t3;
1225
+ }
1226
+ function M(m4, l6) {
1227
+ const n2 = { ...y4.defaultDecodeOptions, ...l6, ParentType: g4 }, p5 = new y3(m4, n2);
1228
+ let t3, r2, e2 = "";
1229
+ for (const T2 of p5) {
1230
+ const [u3, o5, i] = T2;
1231
+ switch (t3 && (t3.count > 0 && i !== A.BREAK && (t3.mt === f.MAP && t3.count % 2 ? e2 += ": " : (e2 += ",", n2.pretty || (e2 += " "))), n2.pretty && (t3.mt !== f.MAP || t3.count % 2 === 0) && (e2 += `
1232
+ ${O3.repeat(t3.depth + 1)}`)), r2 = y4.create(T2, t3, n2, p5), u3) {
1233
+ case f.POS_INT:
1234
+ case f.NEG_INT:
1235
+ e2 += String(i), e2 += a3(u3, o5, i, n2);
1236
+ break;
1237
+ case f.SIMPLE_FLOAT:
1238
+ if (i !== A.BREAK) if (typeof i == "number") {
1239
+ const c5 = Object.is(i, -0) ? "-0.0" : String(i);
1240
+ e2 += c5, isFinite(i) && !/[.e]/.test(c5) && (e2 += ".0"), e2 += a3(u3, o5, i, n2);
1241
+ } else i instanceof t ? (e2 += "simple(", e2 += String(i.value), e2 += a3(f.POS_INT, o5, i.value, n2), e2 += ")") : e2 += String(i);
1242
+ break;
1243
+ case f.BYTE_STRING:
1244
+ i === 1 / 0 ? (e2 += "(_ ", r2.close = ")", r2.quote = "'") : (e2 += "h'", e2 += A2(i), e2 += "'", e2 += a3(f.POS_INT, o5, i.length, n2));
1245
+ break;
1246
+ case f.UTF8_STRING:
1247
+ i === 1 / 0 ? (e2 += "(_ ", r2.close = ")") : (e2 += JSON.stringify(i), e2 += a3(f.POS_INT, o5, y5.encode(i).length, n2));
1248
+ break;
1249
+ case f.ARRAY: {
1250
+ e2 += "[";
1251
+ const c5 = a3(f.POS_INT, o5, i, n2);
1252
+ e2 += c5, c5 && (e2 += " "), n2.pretty && i ? r2.close = `
1253
+ ${O3.repeat(r2.depth)}]` : r2.close = "]";
1254
+ break;
1255
+ }
1256
+ case f.MAP: {
1257
+ e2 += "{";
1258
+ const c5 = a3(f.POS_INT, o5, i, n2);
1259
+ e2 += c5, c5 && (e2 += " "), n2.pretty && i ? r2.close = `
1260
+ ${O3.repeat(r2.depth)}}` : r2.close = "}";
1261
+ break;
1262
+ }
1263
+ case f.TAG:
1264
+ e2 += String(i), e2 += a3(f.POS_INT, o5, i, n2), e2 += "(", r2.close = ")";
1265
+ break;
1266
+ }
1267
+ if (r2 === A.BREAK) if (t3?.isStreaming) t3.left = 0;
1268
+ else throw new Error("Unexpected BREAK");
1269
+ else t3 && (t3.count++, t3.left--);
1270
+ for (r2 instanceof g4 && (t3 = r2); t3?.done; ) {
1271
+ if (t3.isEmptyStream) e2 = e2.slice(0, -3), e2 += `${t3.quote}${t3.quote}_`;
1272
+ else {
1273
+ if (t3.mt === f.MAP && t3.count % 2 !== 0) throw new Error(`Odd streaming map size: ${t3.count}`);
1274
+ e2 += t3.close;
1275
+ }
1276
+ t3 = t3.parent;
1277
+ }
1278
+ }
1279
+ return e2;
1280
+ }
1281
+
1282
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/comment.js
1283
+ var H2 = new TextDecoder();
1284
+ var A5 = class extends y4 {
1285
+ depth = 0;
1286
+ leaf = false;
1287
+ value;
1288
+ length;
1289
+ [A.ENCODED];
1290
+ constructor(a4, f7, e2, n2) {
1291
+ super(a4, f7, e2, n2), this.parent ? this.depth = this.parent.depth + 1 : this.depth = n2.initialDepth, [, , this.value, , this.length] = a4;
1292
+ }
1293
+ numBytes() {
1294
+ switch (this.ai) {
1295
+ case I.ONE:
1296
+ return 1;
1297
+ case I.TWO:
1298
+ return 2;
1299
+ case I.FOUR:
1300
+ return 4;
1301
+ case I.EIGHT:
1302
+ return 8;
1303
+ }
1304
+ return 0;
1305
+ }
1306
+ };
1307
+ function k3(t3) {
1308
+ return t3 instanceof A5;
1309
+ }
1310
+ function O4(t3, a4) {
1311
+ return t3 === 1 / 0 ? "Indefinite" : a4 ? `${t3} ${a4}${t3 !== 1 && t3 !== 1n ? "s" : ""}` : String(t3);
1312
+ }
1313
+ function y6(t3) {
1314
+ return "".padStart(t3, " ");
1315
+ }
1316
+ function x3(t3, a4, f7) {
1317
+ let e2 = "";
1318
+ e2 += y6(t3.depth * 2);
1319
+ const n2 = f2(t3);
1320
+ e2 += A2(n2.subarray(0, 1));
1321
+ const r2 = t3.numBytes();
1322
+ r2 && (e2 += " ", e2 += A2(n2.subarray(1, r2 + 1))), e2 = e2.padEnd(a4.minCol + 1, " "), e2 += "-- ", f7 !== void 0 && (e2 += y6(t3.depth * 2), f7 !== "" && (e2 += `[${f7}] `));
1323
+ let p5 = false;
1324
+ const [s3] = t3.children;
1325
+ switch (t3.mt) {
1326
+ case f.POS_INT:
1327
+ e2 += `Unsigned: ${s3}`, typeof s3 == "bigint" && (e2 += "n");
1328
+ break;
1329
+ case f.NEG_INT:
1330
+ e2 += `Negative: ${s3}`, typeof s3 == "bigint" && (e2 += "n");
1331
+ break;
1332
+ case f.BYTE_STRING:
1333
+ e2 += `Bytes (Length: ${O4(t3.length)})`;
1334
+ break;
1335
+ case f.UTF8_STRING:
1336
+ e2 += `UTF8 (Length: ${O4(t3.length)})`, t3.length !== 1 / 0 && (e2 += `: ${JSON.stringify(s3)}`);
1337
+ break;
1338
+ case f.ARRAY:
1339
+ e2 += `Array (Length: ${O4(t3.value, "item")})`;
1340
+ break;
1341
+ case f.MAP:
1342
+ e2 += `Map (Length: ${O4(t3.value, "pair")})`;
1343
+ break;
1344
+ case f.TAG: {
1345
+ e2 += `Tag #${t3.value}`;
1346
+ const o5 = t3.children, [m4] = o5.contents.children, i = new o2(o5.tag, m4);
1347
+ u(i, n2);
1348
+ const l6 = i.comment(a4, t3.depth);
1349
+ l6 && (e2 += ": ", e2 += l6), p5 ||= i.noChildren;
1350
+ break;
1351
+ }
1352
+ case f.SIMPLE_FLOAT:
1353
+ s3 === A.BREAK ? e2 += "BREAK" : t3.ai > I.ONE ? Object.is(s3, -0) ? e2 += "Float: -0" : e2 += `Float: ${s3}` : (e2 += "Simple: ", s3 instanceof t ? e2 += s3.value : e2 += s3);
1354
+ break;
1355
+ }
1356
+ if (!p5) if (t3.leaf) {
1357
+ if (e2 += `
1358
+ `, n2.length > r2 + 1) {
1359
+ const o5 = y6((t3.depth + 1) * 2), m4 = f3(n2);
1360
+ if (m4?.length) {
1361
+ m4.sort((l6, c5) => {
1362
+ const g5 = l6[0] - c5[0];
1363
+ return g5 || c5[1] - l6[1];
1364
+ });
1365
+ let i = 0;
1366
+ for (const [l6, c5, g5] of m4) if (!(l6 < i)) {
1367
+ if (i = l6 + c5, g5 === "<<") {
1368
+ e2 += y6(a4.minCol + 1), e2 += "--", e2 += o5, e2 += "<< ";
1369
+ const d6 = R(n2, l6, l6 + c5), h5 = f3(d6);
1370
+ if (h5) {
1371
+ const $3 = h5.findIndex(([w3, D, v3]) => w3 === 0 && D === c5 && v3 === "<<");
1372
+ $3 >= 0 && h5.splice($3, 1);
1373
+ }
1374
+ e2 += M(d6), e2 += ` >>
1375
+ `, e2 += L2(d6, { initialDepth: t3.depth + 1, minCol: a4.minCol, noPrefixHex: true });
1376
+ continue;
1377
+ } else g5 === "'" && (e2 += y6(a4.minCol + 1), e2 += "--", e2 += o5, e2 += "'", e2 += H2.decode(n2.subarray(l6, l6 + c5)), e2 += `'
1378
+ `);
1379
+ if (l6 > r2) for (let d6 = l6; d6 < l6 + c5; d6 += 8) {
1380
+ const h5 = Math.min(d6 + 8, l6 + c5);
1381
+ e2 += o5, e2 += A2(n2.subarray(d6, h5)), e2 += `
1382
+ `;
1383
+ }
1384
+ }
1385
+ } else for (let i = r2 + 1; i < n2.length; i += 8) e2 += o5, e2 += A2(n2.subarray(i, i + 8)), e2 += `
1386
+ `;
1387
+ }
1388
+ } else {
1389
+ e2 += `
1390
+ `;
1391
+ let o5 = 0;
1392
+ for (const m4 of t3.children) {
1393
+ if (k3(m4)) {
1394
+ let i = String(o5);
1395
+ t3.mt === f.MAP ? i = o5 % 2 ? `val ${(o5 - 1) / 2}` : `key ${o5 / 2}` : t3.mt === f.TAG && (i = ""), e2 += x3(m4, a4, i);
1396
+ }
1397
+ o5++;
1398
+ }
1399
+ }
1400
+ return e2;
1401
+ }
1402
+ var q2 = { ...y4.defaultDecodeOptions, initialDepth: 0, noPrefixHex: false, minCol: 0 };
1403
+ function L2(t3, a4) {
1404
+ const f7 = { ...q2, ...a4, ParentType: A5, saveOriginal: true }, e2 = new y3(t3, f7);
1405
+ let n2, r2;
1406
+ for (const s3 of e2) {
1407
+ if (r2 = y4.create(s3, n2, f7, e2), s3[2] === A.BREAK) if (n2?.isStreaming) n2.left = 1;
1408
+ else throw new Error("Unexpected BREAK");
1409
+ if (!k3(r2)) {
1410
+ const i = new A5(s3, 0, n2, f7);
1411
+ i.leaf = true, i.children.push(r2), u(i, e2.toHere(s3[3])), r2 = i;
1412
+ }
1413
+ let o5 = (r2.depth + 1) * 2;
1414
+ const m4 = r2.numBytes();
1415
+ for (m4 && (o5 += 1, o5 += m4 * 2), f7.minCol = Math.max(f7.minCol, o5), n2 && n2.push(r2, e2, s3[3]), n2 = r2; n2?.done; ) r2 = n2, r2.leaf || u(r2, e2.toHere(r2.offset)), { parent: n2 } = n2;
1416
+ }
1417
+ a4 && (a4.minCol = f7.minCol);
1418
+ let p5 = f7.noPrefixHex ? "" : `0x${A2(e2.toHere(0))}
1419
+ `;
1420
+ return p5 += x3(r2, f7), p5;
1421
+ }
1422
+
1423
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/types.js
1424
+ var U4 = !h();
1425
+ function I3(e2) {
1426
+ if (typeof e2 == "object" && e2) {
1427
+ if (e2.constructor !== Number) throw new Error(`Expected number: ${e2}`);
1428
+ } else if (typeof e2 != "number") throw new Error(`Expected number: ${e2}`);
1429
+ }
1430
+ function f6(e2) {
1431
+ if (typeof e2 == "object" && e2) {
1432
+ if (e2.constructor !== String) throw new Error(`Expected string: ${e2}`);
1433
+ } else if (typeof e2 != "string") throw new Error(`Expected string: ${e2}`);
1434
+ }
1435
+ function E2(e2) {
1436
+ if (!(e2 instanceof Uint8Array)) throw new Error(`Expected Uint8Array: ${e2}`);
1437
+ }
1438
+ function _2(e2) {
1439
+ if (!Array.isArray(e2)) throw new Error(`Expected Array: ${e2}`);
1440
+ }
1441
+ ue(Map, (e2, r2, n2) => {
1442
+ const i = [...e2.entries()].map((a4) => [a4[0], a4[1], v2(a4[0], n2)]);
1443
+ if (n2.rejectDuplicateKeys) {
1444
+ const a4 = /* @__PURE__ */ new Set();
1445
+ for (const [d6, u3, g5] of i) {
1446
+ const y7 = A2(g5);
1447
+ if (a4.has(y7)) throw new Error(`Duplicate map key: 0x${y7}`);
1448
+ a4.add(y7);
1449
+ }
1450
+ }
1451
+ n2.sortKeys && i.sort(n2.sortKeys), L(e2, e2.size, f.MAP, r2, n2);
1452
+ for (const [a4, d6, u3] of i) r2.write(u3), g3(d6, r2, n2);
1453
+ });
1454
+ function w2(e2) {
1455
+ return f6(e2.contents), new Date(e2.contents);
1456
+ }
1457
+ w2.comment = (e2) => {
1458
+ f6(e2.contents);
1459
+ const r2 = new Date(e2.contents);
1460
+ return `(String ${e2.tag === T.DATE_FULL ? "Full " : ""}Date) ${r2.toISOString()}`;
1461
+ }, o2.registerDecoder(T.DATE_STRING, w2), o2.registerDecoder(T.DATE_FULL, w2);
1462
+ function N3(e2) {
1463
+ return I3(e2.contents), new Date(e2.contents * 1e3);
1464
+ }
1465
+ N3.comment = (e2) => (I3(e2.contents), `(Epoch Date) ${new Date(e2.contents * 1e3).toISOString()}`), o2.registerDecoder(T.DATE_EPOCH, N3);
1466
+ var S3 = 1e3 * 60 * 60 * 24;
1467
+ function $2(e2) {
1468
+ return I3(e2.contents), new Date(e2.contents * S3);
1469
+ }
1470
+ $2.comment = (e2) => (I3(e2.contents), `(Epoch Date) ${new Date(e2.contents * S3).toISOString()}`), o2.registerDecoder(T.DATE_EPOCH_DAYS, $2), ue(Date, (e2, r2, n2) => {
1471
+ switch (n2.dateTag) {
1472
+ case T.DATE_EPOCH:
1473
+ return [n2.dateTag, e2.valueOf() / 1e3];
1474
+ case T.DATE_STRING:
1475
+ return [n2.dateTag, e2.toISOString().replace(/\.000Z$/, "Z")];
1476
+ case T.DATE_EPOCH_DAYS:
1477
+ return [n2.dateTag, Math.floor(e2.valueOf() / S3)];
1478
+ case T.DATE_FULL:
1479
+ return [n2.dateTag, e2.toISOString().split("T")[0]];
1480
+ default:
1481
+ throw new Error(`Unsupported date tag: ${n2.dateTag}`);
1482
+ }
1483
+ });
1484
+ function m3(e2, r2, n2) {
1485
+ if (E2(r2.contents), n2.rejectBigInts) throw new Error(`Decoding unwanted big integer: ${r2}(h'${A2(r2.contents)}')`);
1486
+ if (n2.requirePreferred && r2.contents[0] === 0) throw new Error(`Decoding overly-large bigint: ${r2.tag}(h'${A2(r2.contents)})`);
1487
+ let i = r2.contents.reduce((d6, u3) => d6 << 8n | BigInt(u3), 0n);
1488
+ e2 && (i = -1n - i);
1489
+ const a4 = i >= Number.MIN_SAFE_INTEGER && i <= Number.MAX_SAFE_INTEGER;
1490
+ if (n2.requirePreferred && a4) throw new Error(`Decoding bigint that could have been int: ${i}n`);
1491
+ return n2.collapseBigInts && a4 && (i = Number(i)), n2.boxed ? d(i, r2.contents) : i;
1492
+ }
1493
+ var L3 = m3.bind(null, false);
1494
+ var x4 = m3.bind(null, true);
1495
+ L3.comment = (e2, r2) => `(Positive BigInt) ${m3(false, e2, r2)}n`, x4.comment = (e2, r2) => `(Negative BigInt) ${m3(true, e2, r2)}n`, o2.registerDecoder(T.POS_BIGINT, L3), o2.registerDecoder(T.NEG_BIGINT, x4);
1496
+ function R4(e2, r2) {
1497
+ return E2(e2.contents), e2;
1498
+ }
1499
+ R4.comment = (e2, r2, n2) => {
1500
+ E2(e2.contents);
1501
+ const i = { ...r2, initialDepth: n2 + 2, noPrefixHex: true }, a4 = f2(e2);
1502
+ let u3 = 2 ** ((a4[0] & 31) - 24) + 1;
1503
+ const g5 = a4[u3] & 31;
1504
+ let y7 = A2(a4.subarray(u3, ++u3));
1505
+ g5 >= 24 && (y7 += " ", y7 += A2(a4.subarray(u3, u3 + 2 ** (g5 - 24)))), i.minCol = Math.max(i.minCol, (n2 + 1) * 2 + y7.length);
1506
+ const D = L2(e2.contents, i);
1507
+ let T2 = `Embedded CBOR
1508
+ `;
1509
+ return T2 += `${"".padStart((n2 + 1) * 2, " ")}${y7}`.padEnd(i.minCol + 1, " "), T2 += `-- Bytes (Length: ${e2.contents.length})
1510
+ `, T2 += D, T2;
1511
+ }, R4.noChildren = true, o2.registerDecoder(T.CBOR, R4), o2.registerDecoder(T.URI, (e2) => (f6(e2.contents), new URL(e2.contents)), "URI"), ue(URL, (e2) => [T.URI, e2.toString()]), o2.registerDecoder(T.BASE64URL, (e2) => (f6(e2.contents), x(e2.contents)), "Base64url-encoded"), o2.registerDecoder(T.BASE64, (e2) => (f6(e2.contents), y(e2.contents)), "Base64-encoded"), o2.registerDecoder(35, (e2) => (f6(e2.contents), new RegExp(e2.contents)), "RegExp"), o2.registerDecoder(21065, (e2) => {
1512
+ f6(e2.contents);
1513
+ const r2 = `^(?:${e2.contents})$`;
1514
+ return new RegExp(r2, "u");
1515
+ }, "I-RegExp"), o2.registerDecoder(T.REGEXP, (e2) => {
1516
+ if (_2(e2.contents), e2.contents.length < 1 || e2.contents.length > 2) throw new Error(`Invalid RegExp Array: ${e2.contents}`);
1517
+ return new RegExp(e2.contents[0], e2.contents[1]);
1518
+ }, "RegExp"), ue(RegExp, (e2) => [T.REGEXP, [e2.source, e2.flags]]), o2.registerDecoder(64, (e2) => (E2(e2.contents), e2.contents), "uint8 Typed Array");
1519
+ function c3(e2, r2, n2) {
1520
+ E2(e2.contents);
1521
+ let i = e2.contents.length;
1522
+ if (i % r2.BYTES_PER_ELEMENT !== 0) throw new Error(`Number of bytes must be divisible by ${r2.BYTES_PER_ELEMENT}, got: ${i}`);
1523
+ i /= r2.BYTES_PER_ELEMENT;
1524
+ const a4 = new r2(i), d6 = new DataView(e2.contents.buffer, e2.contents.byteOffset, e2.contents.byteLength), u3 = d6[`get${r2.name.replace(/Array/, "")}`].bind(d6);
1525
+ for (let g5 = 0; g5 < i; g5++) a4[g5] = u3(g5 * r2.BYTES_PER_ELEMENT, n2);
1526
+ return a4;
1527
+ }
1528
+ function l3(e2, r2, n2, i, a4) {
1529
+ const d6 = a4.forceEndian ?? U4;
1530
+ if (m2(d6 ? r2 : n2, e2, a4), a2(i.byteLength, e2, f.BYTE_STRING), U4 === d6) e2.write(new Uint8Array(i.buffer, i.byteOffset, i.byteLength));
1531
+ else {
1532
+ const g5 = `write${i.constructor.name.replace(/Array/, "")}`, y7 = e2[g5].bind(e2);
1533
+ for (const D of i) y7(D, d6);
1534
+ }
1535
+ }
1536
+ o2.registerDecoder(65, (e2) => c3(e2, Uint16Array, false), "uint16, big endian, Typed Array"), o2.registerDecoder(66, (e2) => c3(e2, Uint32Array, false), "uint32, big endian, Typed Array"), o2.registerDecoder(67, (e2) => c3(e2, BigUint64Array, false), "uint64, big endian, Typed Array"), o2.registerDecoder(68, (e2) => (E2(e2.contents), new Uint8ClampedArray(e2.contents)), "uint8 Typed Array, clamped arithmetic"), ue(Uint8ClampedArray, (e2) => [68, new Uint8Array(e2.buffer, e2.byteOffset, e2.byteLength)]), o2.registerDecoder(69, (e2) => c3(e2, Uint16Array, true), "uint16, little endian, Typed Array"), ue(Uint16Array, (e2, r2, n2) => l3(r2, 69, 65, e2, n2)), o2.registerDecoder(70, (e2) => c3(e2, Uint32Array, true), "uint32, little endian, Typed Array"), ue(Uint32Array, (e2, r2, n2) => l3(r2, 70, 66, e2, n2)), o2.registerDecoder(71, (e2) => c3(e2, BigUint64Array, true), "uint64, little endian, Typed Array"), ue(BigUint64Array, (e2, r2, n2) => l3(r2, 71, 67, e2, n2)), o2.registerDecoder(72, (e2) => (E2(e2.contents), new Int8Array(e2.contents)), "sint8 Typed Array"), ue(Int8Array, (e2) => [72, new Uint8Array(e2.buffer, e2.byteOffset, e2.byteLength)]), o2.registerDecoder(73, (e2) => c3(e2, Int16Array, false), "sint16, big endian, Typed Array"), o2.registerDecoder(74, (e2) => c3(e2, Int32Array, false), "sint32, big endian, Typed Array"), o2.registerDecoder(75, (e2) => c3(e2, BigInt64Array, false), "sint64, big endian, Typed Array"), o2.registerDecoder(77, (e2) => c3(e2, Int16Array, true), "sint16, little endian, Typed Array"), ue(Int16Array, (e2, r2, n2) => l3(r2, 77, 73, e2, n2)), o2.registerDecoder(78, (e2) => c3(e2, Int32Array, true), "sint32, little endian, Typed Array"), ue(Int32Array, (e2, r2, n2) => l3(r2, 78, 74, e2, n2)), o2.registerDecoder(79, (e2) => c3(e2, BigInt64Array, true), "sint64, little endian, Typed Array"), ue(BigInt64Array, (e2, r2, n2) => l3(r2, 79, 75, e2, n2)), o2.registerDecoder(81, (e2) => c3(e2, Float32Array, false), "IEEE 754 binary32, big endian, Typed Array"), o2.registerDecoder(82, (e2) => c3(e2, Float64Array, false), "IEEE 754 binary64, big endian, Typed Array"), o2.registerDecoder(85, (e2) => c3(e2, Float32Array, true), "IEEE 754 binary32, little endian, Typed Array"), ue(Float32Array, (e2, r2, n2) => l3(r2, 85, 81, e2, n2)), o2.registerDecoder(86, (e2) => c3(e2, Float64Array, true), "IEEE 754 binary64, big endian, Typed Array"), ue(Float64Array, (e2, r2, n2) => l3(r2, 86, 82, e2, n2)), o2.registerDecoder(T.SET, (e2, r2) => {
1537
+ if (_2(e2.contents), r2.sortKeys) {
1538
+ const n2 = y4.decodeToEncodeOpts(r2);
1539
+ let i = null;
1540
+ for (const a4 of e2.contents) {
1541
+ const d6 = [a4, void 0, v2(a4, n2)];
1542
+ if (i && r2.sortKeys(i, d6) >= 0) throw new Error(`Set items out of order in tag #${T.SET}`);
1543
+ i = d6;
1544
+ }
1545
+ }
1546
+ return new Set(e2.contents);
1547
+ }, "Set"), ue(Set, (e2, r2, n2) => {
1548
+ let i = [...e2];
1549
+ if (n2.sortKeys) {
1550
+ const a4 = i.map((d6) => [d6, void 0, v2(d6, n2)]);
1551
+ a4.sort(n2.sortKeys), i = a4.map(([d6]) => d6);
1552
+ }
1553
+ return [T.SET, i];
1554
+ }), o2.registerDecoder(T.JSON, (e2) => (f6(e2.contents), JSON.parse(e2.contents)), "JSON-encoded");
1555
+ function C(e2) {
1556
+ return E2(e2.contents), new Wtf8Decoder().decode(e2.contents);
1557
+ }
1558
+ C.comment = (e2) => {
1559
+ E2(e2.contents);
1560
+ const r2 = new Wtf8Decoder();
1561
+ return `(WTF8 string): ${JSON.stringify(r2.decode(e2.contents))}`;
1562
+ }, o2.registerDecoder(T.WTF8, C), o2.registerDecoder(T.SELF_DESCRIBED, (e2) => e2.contents, "Self-Described"), o2.registerDecoder(T.INVALID_16, () => {
1563
+ throw new Error(`Tag always invalid: ${T.INVALID_16}`);
1564
+ }, "Invalid"), o2.registerDecoder(T.INVALID_32, () => {
1565
+ throw new Error(`Tag always invalid: ${T.INVALID_32}`);
1566
+ }, "Invalid"), o2.registerDecoder(T.INVALID_64, () => {
1567
+ throw new Error(`Tag always invalid: ${T.INVALID_64}`);
1568
+ }, "Invalid"), o2.registerDecoder(T.SYMBOL, (e2) => {
1569
+ let r2 = e2.contents;
1570
+ if (Array.isArray(e2.contents)) {
1571
+ if (e2.contents.length !== 1) throw new Error(`Expected Array of size 1: ${e2.contents}`);
1572
+ [r2] = e2.contents;
1573
+ }
1574
+ if (f6(r2), !r2.length) throw new Error(`Expected non-empty string: ${e2.contents}`);
1575
+ return Symbol.for(r2);
1576
+ }, "Symbol");
1577
+ function h3(e2) {
1578
+ throw new Error(`Encoding ${e2.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`);
1579
+ }
1580
+ ue(ArrayBuffer, h3), ue(DataView, h3), typeof SharedArrayBuffer < "u" && ue(SharedArrayBuffer, h3);
1581
+ function p4(e2) {
1582
+ return [NaN, e2.valueOf()];
1583
+ }
1584
+ ue(Boolean, p4), ue(Number, p4), ue(String, p4), ue(BigInt, p4);
1585
+
1586
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/decoder.js
1587
+ function c4(i) {
1588
+ const e2 = { ...y4.defaultDecodeOptions };
1589
+ if (i.dcbor ? Object.assign(e2, y4.dcborDecodeOptions) : i.cde && Object.assign(e2, y4.cdeDecodeOptions), Object.assign(e2, i), Object.hasOwn(e2, "rejectLongNumbers")) throw new TypeError("rejectLongNumbers has changed to requirePreferred");
1590
+ return e2.boxed && (e2.saveOriginal = true), e2;
1591
+ }
1592
+ var d4 = class {
1593
+ parent = void 0;
1594
+ ret = void 0;
1595
+ step(e2, n2, t3) {
1596
+ if (this.ret = y4.create(e2, this.parent, n2, t3), e2[2] === A.BREAK) if (this.parent?.isStreaming) this.parent.left = 0;
1597
+ else throw new Error("Unexpected BREAK");
1598
+ else this.parent && this.parent.push(this.ret, t3, e2[3]);
1599
+ for (this.ret instanceof y4 && (this.parent = this.ret); this.parent?.done; ) {
1600
+ this.ret = this.parent.convert(t3);
1601
+ const r2 = this.parent.parent;
1602
+ r2?.replaceLast(this.ret, this.parent, t3), this.parent = r2;
1603
+ }
1604
+ }
1605
+ };
1606
+ function l4(i, e2 = {}) {
1607
+ const n2 = c4(e2), t3 = new y3(i, n2), r2 = new d4();
1608
+ for (const o5 of t3) r2.step(o5, n2, t3);
1609
+ return r2.ret;
1610
+ }
1611
+
1612
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/index.js
1613
+ var { cdeDecodeOptions: r, dcborDecodeOptions: n, defaultDecodeOptions: d5 } = y4;
1614
+
1615
+ // ../crypto-core/dist/cbor.js
1616
+ var CanonicalCborError = class extends Error {
1617
+ code;
1618
+ constructor(code, message, options) {
1619
+ super(message, options);
1620
+ this.name = "CanonicalCborError";
1621
+ this.code = code;
1622
+ }
1623
+ };
1624
+ function decodeCanonicalCbor(bytes) {
1625
+ try {
1626
+ return l4(bytes, {
1627
+ ...r,
1628
+ rejectStreaming: true,
1629
+ rejectDuplicateKeys: true,
1630
+ // A CIP-309 record carries integers, byte/text strings, arrays, maps and
1631
+ // `null` — and nothing else. Without these rejections the major-type-7
1632
+ // surface leaks into the decoder: a float16/32/64 that happens to hold an
1633
+ // integral value (e.g. 1.0) silently decodes to the integer 1 and passes
1634
+ // a `z.literal(1)` / Number.isInteger schema check, so two byte strings
1635
+ // that are NOT byte-identical canonicalise to the same record. That
1636
+ // breaks the cross-implementation parity invariant (the Python twin
1637
+ // already rejects non-integer `v` / `enc.scheme` outright). Reject the
1638
+ // whole non-record surface — floats, negative zero, undefined, and
1639
+ // non-{true,false,null} simple values — so any such input surfaces as
1640
+ // MALFORMED_CBOR via mapDecodeError rather than decoding to a look-alike.
1641
+ rejectFloats: true,
1642
+ rejectNegativeZero: true,
1643
+ rejectUndefined: true,
1644
+ rejectSimple: true
1645
+ });
1646
+ } catch (cause) {
1647
+ throw mapDecodeError(cause);
1648
+ }
1649
+ }
1650
+ function mapDecodeError(cause) {
1651
+ const message = cause instanceof Error ? cause.message : String(cause);
1652
+ const lower = message.toLowerCase();
1653
+ const isIndefinite = lower.includes("streaming") || lower.includes("indefinite");
1654
+ const detail = isIndefinite ? `indefinite-length items are not permitted in canonical CBOR: ${message}` : message;
1655
+ return new CanonicalCborError("MALFORMED_CBOR", `cbor decode failed: ${detail}`, { cause });
1656
+ }
1657
+
1658
+ // ../../node_modules/.pnpm/@noble+ed25519@3.1.0/node_modules/@noble/ed25519/index.js
1659
+ var ed25519_CURVE = Object.freeze({
1660
+ p: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,
1661
+ n: 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,
1662
+ h: 8n,
1663
+ a: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,
1664
+ d: 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,
1665
+ Gx: 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,
1666
+ Gy: 0x6666666666666666666666666666666666666666666666666666666666666658n
1667
+ });
1668
+ var { p: P, n: N4, Gx, Gy, a: _a, d: _d, h: h4 } = ed25519_CURVE;
1669
+ var L4 = 32;
1670
+ var captureTrace = (...args) => {
1671
+ if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
1672
+ Error.captureStackTrace(...args);
1673
+ }
1674
+ };
1675
+ var err = (message = "") => {
1676
+ const e2 = new Error(message);
1677
+ captureTrace(e2, err);
1678
+ throw e2;
1679
+ };
1680
+ var isBig = (n2) => typeof n2 === "bigint";
1681
+ var isStr = (s3) => typeof s3 === "string";
1682
+ var isBytes2 = (a4) => a4 instanceof Uint8Array || ArrayBuffer.isView(a4) && a4.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a4 && a4.BYTES_PER_ELEMENT === 1;
1683
+ var abytes2 = (value, length, title = "") => {
1684
+ const bytes = isBytes2(value);
1685
+ const len = value?.length;
1686
+ const needsLen = length !== void 0;
1687
+ if (!bytes || needsLen && len !== length) {
1688
+ const prefix = title && `"${title}" `;
1689
+ const ofLen = needsLen ? ` of length ${length}` : "";
1690
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
1691
+ const msg = prefix + "expected Uint8Array" + ofLen + ", got " + got;
1692
+ throw bytes ? new RangeError(msg) : new TypeError(msg);
1693
+ }
1694
+ return value;
1695
+ };
1696
+ var u8n = (len) => new Uint8Array(len);
1697
+ var u8fr = (buf) => Uint8Array.from(buf);
1698
+ var padh = (n2, pad) => n2.toString(16).padStart(pad, "0");
1699
+ var bytesToHex = (b5) => Array.from(abytes2(b5)).map((e2) => padh(e2, 2)).join("");
1700
+ var C2 = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
1701
+ var _ch = (ch) => {
1702
+ if (ch >= C2._0 && ch <= C2._9)
1703
+ return ch - C2._0;
1704
+ if (ch >= C2.A && ch <= C2.F)
1705
+ return ch - (C2.A - 10);
1706
+ if (ch >= C2.a && ch <= C2.f)
1707
+ return ch - (C2.a - 10);
1708
+ return;
1709
+ };
1710
+ var hexToBytes = (hex) => {
1711
+ const e2 = "hex invalid";
1712
+ if (!isStr(hex))
1713
+ return err(e2);
1714
+ const hl = hex.length;
1715
+ const al = hl / 2;
1716
+ if (hl % 2)
1717
+ return err(e2);
1718
+ const array = u8n(al);
1719
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
1720
+ const n1 = _ch(hex.charCodeAt(hi));
1721
+ const n2 = _ch(hex.charCodeAt(hi + 1));
1722
+ if (n1 === void 0 || n2 === void 0)
1723
+ return err(e2);
1724
+ array[ai] = n1 * 16 + n2;
1725
+ }
1726
+ return array;
1727
+ };
1728
+ var big = BigInt;
1729
+ var assertRange = (n2, min, max, msg = "bad number: out of range") => {
1730
+ if (!isBig(n2))
1731
+ throw new TypeError(msg);
1732
+ if (min <= n2 && n2 < max)
1733
+ return n2;
1734
+ throw new RangeError(msg);
1735
+ };
1736
+ var M2 = (a4, b5 = P) => {
1737
+ const r2 = a4 % b5;
1738
+ return r2 >= 0n ? r2 : b5 + r2;
1739
+ };
1740
+ var P_MASK = (1n << 255n) - 1n;
1741
+ var modP = (num) => {
1742
+ if (num < 0n)
1743
+ err("negative coordinate");
1744
+ let r2 = (num >> 255n) * 19n + (num & P_MASK);
1745
+ r2 = (r2 >> 255n) * 19n + (r2 & P_MASK);
1746
+ return r2 % P;
1747
+ };
1748
+ var invert = (num, md) => {
1749
+ if (num === 0n || md <= 0n)
1750
+ err("no inverse n=" + num + " mod=" + md);
1751
+ let a4 = M2(num, md), b5 = md, x5 = 0n, u3 = 1n;
1752
+ while (a4 !== 0n) {
1753
+ const q3 = b5 / a4, r2 = b5 % a4;
1754
+ const m4 = x5 - u3 * q3;
1755
+ b5 = a4, a4 = r2, x5 = u3, u3 = m4;
1756
+ }
1757
+ return b5 === 1n ? M2(x5, md) : err("no inverse");
1758
+ };
1759
+ var apoint = (p5) => p5 instanceof Point ? p5 : err("Point expected");
1760
+ var B256 = 2n ** 256n;
1761
+ var Point = class _Point {
1762
+ static BASE;
1763
+ static ZERO;
1764
+ X;
1765
+ Y;
1766
+ Z;
1767
+ T;
1768
+ // Constructor only bounds-checks and freezes XYZT coordinates; it does not prove the point is
1769
+ // on-curve or that T matches X*Y/Z.
1770
+ constructor(X2, Y2, Z3, T2) {
1771
+ const max = B256;
1772
+ this.X = assertRange(X2, 0n, max);
1773
+ this.Y = assertRange(Y2, 0n, max);
1774
+ this.Z = assertRange(Z3, 1n, max);
1775
+ this.T = assertRange(T2, 0n, max);
1776
+ Object.freeze(this);
1777
+ }
1778
+ static CURVE() {
1779
+ return ed25519_CURVE;
1780
+ }
1781
+ static fromAffine(p5) {
1782
+ return new _Point(p5.x, p5.y, 1n, modP(p5.x * p5.y));
1783
+ }
1784
+ /** RFC8032 5.1.3: Bytes to Point. */
1785
+ static fromBytes(hex, zip215 = false) {
1786
+ const d6 = _d;
1787
+ const normed = u8fr(abytes2(hex, L4));
1788
+ const lastByte = hex[31];
1789
+ normed[31] = lastByte & -129;
1790
+ const y7 = bytesToNumberLE(normed);
1791
+ const max = zip215 ? B256 : P;
1792
+ assertRange(y7, 0n, max);
1793
+ const y22 = modP(y7 * y7);
1794
+ const u3 = M2(y22 - 1n);
1795
+ const v3 = modP(d6 * y22 + 1n);
1796
+ let { isValid, value: x5 } = uvRatio(u3, v3);
1797
+ if (!isValid)
1798
+ err("bad point: y not sqrt");
1799
+ const isXOdd = (x5 & 1n) === 1n;
1800
+ const isLastByteOdd = (lastByte & 128) !== 0;
1801
+ if (!zip215 && x5 === 0n && isLastByteOdd)
1802
+ err("bad point: x==0, isLastByteOdd");
1803
+ if (isLastByteOdd !== isXOdd)
1804
+ x5 = M2(-x5);
1805
+ return new _Point(x5, y7, 1n, modP(x5 * y7));
1806
+ }
1807
+ static fromHex(hex, zip215) {
1808
+ return _Point.fromBytes(hexToBytes(hex), zip215);
1809
+ }
1810
+ get x() {
1811
+ return this.toAffine().x;
1812
+ }
1813
+ get y() {
1814
+ return this.toAffine().y;
1815
+ }
1816
+ /** Checks if the point is valid and on-curve. */
1817
+ assertValidity() {
1818
+ const a4 = _a;
1819
+ const d6 = _d;
1820
+ const p5 = this;
1821
+ if (p5.is0())
1822
+ return err("bad point: ZERO");
1823
+ const { X: X2, Y: Y2, Z: Z3, T: T2 } = p5;
1824
+ const X22 = modP(X2 * X2);
1825
+ const Y22 = modP(Y2 * Y2);
1826
+ const Z22 = modP(Z3 * Z3);
1827
+ const Z4 = modP(Z22 * Z22);
1828
+ const aX2 = modP(X22 * a4);
1829
+ const left = modP(Z22 * (aX2 + Y22));
1830
+ const right = M2(Z4 + modP(d6 * modP(X22 * Y22)));
1831
+ if (left !== right)
1832
+ return err("bad point: equation left != right (1)");
1833
+ const XY = modP(X2 * Y2);
1834
+ const ZT = modP(Z3 * T2);
1835
+ if (XY !== ZT)
1836
+ return err("bad point: equation left != right (2)");
1837
+ return this;
1838
+ }
1839
+ /** Equality check: compare points P&Q. */
1840
+ equals(other) {
1841
+ const { X: X1, Y: Y1, Z: Z1 } = this;
1842
+ const { X: X2, Y: Y2, Z: Z22 } = apoint(other);
1843
+ const X1Z2 = modP(X1 * Z22);
1844
+ const X2Z1 = modP(X2 * Z1);
1845
+ const Y1Z2 = modP(Y1 * Z22);
1846
+ const Y2Z1 = modP(Y2 * Z1);
1847
+ return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
1848
+ }
1849
+ is0() {
1850
+ return this.equals(I4);
1851
+ }
1852
+ /** Flip point over y coordinate. */
1853
+ negate() {
1854
+ return new _Point(M2(-this.X), this.Y, this.Z, M2(-this.T));
1855
+ }
1856
+ /** Point doubling. Complete formula. Cost: `4M + 4S + 1*a + 6add + 1*2`. */
1857
+ double() {
1858
+ const { X: X1, Y: Y1, Z: Z1 } = this;
1859
+ const a4 = _a;
1860
+ const A6 = modP(X1 * X1);
1861
+ const B3 = modP(Y1 * Y1);
1862
+ const C3 = modP(2n * Z1 * Z1);
1863
+ const D = modP(a4 * A6);
1864
+ const x1y1 = M2(X1 + Y1);
1865
+ const E3 = M2(modP(x1y1 * x1y1) - A6 - B3);
1866
+ const G2 = M2(D + B3);
1867
+ const F4 = M2(G2 - C3);
1868
+ const H3 = M2(D - B3);
1869
+ const X3 = modP(E3 * F4);
1870
+ const Y3 = modP(G2 * H3);
1871
+ const T3 = modP(E3 * H3);
1872
+ const Z3 = modP(F4 * G2);
1873
+ return new _Point(X3, Y3, Z3, T3);
1874
+ }
1875
+ /** Point addition. Complete formula. Cost: `8M + 1*k + 8add + 1*2`. */
1876
+ add(other) {
1877
+ const { X: X1, Y: Y1, Z: Z1, T: T1 } = this;
1878
+ const { X: X2, Y: Y2, Z: Z22, T: T2 } = apoint(other);
1879
+ const a4 = _a;
1880
+ const d6 = _d;
1881
+ const A6 = modP(X1 * X2);
1882
+ const B3 = modP(Y1 * Y2);
1883
+ const C3 = modP(modP(T1 * d6) * T2);
1884
+ const D = modP(Z1 * Z22);
1885
+ const E3 = M2(modP(M2(X1 + Y1) * M2(X2 + Y2)) - A6 - B3);
1886
+ const F4 = M2(D - C3);
1887
+ const G2 = M2(D + C3);
1888
+ const H3 = M2(B3 - modP(a4 * A6));
1889
+ const X3 = modP(E3 * F4);
1890
+ const Y3 = modP(G2 * H3);
1891
+ const T3 = modP(E3 * H3);
1892
+ const Z3 = modP(F4 * G2);
1893
+ return new _Point(X3, Y3, Z3, T3);
1894
+ }
1895
+ subtract(other) {
1896
+ return this.add(apoint(other).negate());
1897
+ }
1898
+ /**
1899
+ * Point-by-scalar multiplication. Safe mode requires `1 <= n < CURVE.n`.
1900
+ * Unsafe mode additionally permits `n = 0` and returns the identity point for that case.
1901
+ * Uses {@link wNAF} for base point.
1902
+ * Uses fake point to mitigate side-channel leakage.
1903
+ * @param n - scalar by which point is multiplied
1904
+ * @param safe - safe mode guards against timing attacks; unsafe mode is faster
1905
+ */
1906
+ multiply(n2, safe = true) {
1907
+ if (!safe && n2 === 0n)
1908
+ return I4;
1909
+ assertRange(n2, 1n, N4);
1910
+ if (!safe && this.is0())
1911
+ return I4;
1912
+ if (n2 === 1n)
1913
+ return this;
1914
+ if (this.equals(G))
1915
+ return wNAF(n2).p;
1916
+ let p5 = I4;
1917
+ let f7 = G;
1918
+ for (let d6 = this; n2 > 0n; d6 = d6.double(), n2 >>= 1n) {
1919
+ if (n2 & 1n)
1920
+ p5 = p5.add(d6);
1921
+ else if (safe)
1922
+ f7 = f7.add(d6);
1923
+ }
1924
+ return p5;
1925
+ }
1926
+ multiplyUnsafe(scalar) {
1927
+ return this.multiply(scalar, false);
1928
+ }
1929
+ /** Convert point to 2d xy affine point. (X, Y, Z) ∋ (x=X/Z, y=Y/Z) */
1930
+ toAffine() {
1931
+ const { X: X2, Y: Y2, Z: Z3 } = this;
1932
+ if (this.equals(I4))
1933
+ return { x: 0n, y: 1n };
1934
+ const iz = invert(Z3, P);
1935
+ if (modP(Z3 * iz) !== 1n)
1936
+ err("invalid inverse");
1937
+ const x5 = modP(X2 * iz);
1938
+ const y7 = modP(Y2 * iz);
1939
+ return { x: x5, y: y7 };
1940
+ }
1941
+ toBytes() {
1942
+ const { x: x5, y: y7 } = this.toAffine();
1943
+ const b5 = numTo32bLE(y7);
1944
+ b5[31] |= x5 & 1n ? 128 : 0;
1945
+ return b5;
1946
+ }
1947
+ toHex() {
1948
+ return bytesToHex(this.toBytes());
1949
+ }
1950
+ clearCofactor() {
1951
+ return this.multiply(big(h4), false);
1952
+ }
1953
+ isSmallOrder() {
1954
+ return this.clearCofactor().is0();
1955
+ }
1956
+ isTorsionFree() {
1957
+ let p5 = this.multiply(N4 / 2n, false).double();
1958
+ if (N4 % 2n)
1959
+ p5 = p5.add(this);
1960
+ return p5.is0();
1961
+ }
1962
+ };
1963
+ var G = new Point(Gx, Gy, 1n, M2(Gx * Gy));
1964
+ var I4 = new Point(0n, 1n, 1n, 0n);
1965
+ Point.BASE = G;
1966
+ Point.ZERO = I4;
1967
+ var numTo32bLE = (num) => hexToBytes(padh(assertRange(num, 0n, B256), 64)).reverse();
1968
+ var bytesToNumberLE = (b5) => big("0x" + bytesToHex(u8fr(abytes2(b5)).reverse()));
1969
+ var pow2 = (x5, power) => {
1970
+ let r2 = x5;
1971
+ while (power-- > 0n) {
1972
+ r2 = modP(r2 * r2);
1973
+ }
1974
+ return r2;
1975
+ };
1976
+ var pow_2_252_3 = (x5) => {
1977
+ const x22 = modP(x5 * x5);
1978
+ const b22 = modP(x22 * x5);
1979
+ const b42 = modP(pow2(b22, 2n) * b22);
1980
+ const b5 = modP(pow2(b42, 1n) * x5);
1981
+ const b10 = modP(pow2(b5, 5n) * b5);
1982
+ const b20 = modP(pow2(b10, 10n) * b10);
1983
+ const b40 = modP(pow2(b20, 20n) * b20);
1984
+ const b80 = modP(pow2(b40, 40n) * b40);
1985
+ const b160 = modP(pow2(b80, 80n) * b80);
1986
+ const b240 = modP(pow2(b160, 80n) * b80);
1987
+ const b250 = modP(pow2(b240, 10n) * b10);
1988
+ const pow_p_5_8 = modP(pow2(b250, 2n) * x5);
1989
+ return { pow_p_5_8, b2: b22 };
1990
+ };
1991
+ var RM1 = 0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n;
1992
+ var uvRatio = (u3, v3) => {
1993
+ const v32 = modP(v3 * modP(v3 * v3));
1994
+ const v7 = modP(modP(v32 * v32) * v3);
1995
+ const pow = pow_2_252_3(modP(u3 * v7)).pow_p_5_8;
1996
+ let x5 = modP(u3 * modP(v32 * pow));
1997
+ const vx2 = modP(v3 * modP(x5 * x5));
1998
+ const root1 = x5;
1999
+ const root2 = modP(x5 * RM1);
2000
+ const useRoot1 = vx2 === u3;
2001
+ const useRoot2 = vx2 === M2(-u3);
2002
+ const noRoot = vx2 === M2(-u3 * RM1);
2003
+ if (useRoot1)
2004
+ x5 = root1;
2005
+ if (useRoot2 || noRoot)
2006
+ x5 = root2;
2007
+ if ((M2(x5) & 1n) === 1n)
2008
+ x5 = M2(-x5);
2009
+ return { isValid: useRoot1 || useRoot2, value: x5 };
2010
+ };
2011
+ var W = 8;
2012
+ var scalarBits = 256;
2013
+ var pwindows = Math.ceil(scalarBits / W) + 1;
2014
+ var pwindowSize = 2 ** (W - 1);
2015
+ var precompute = () => {
2016
+ const points = [];
2017
+ let p5 = G;
2018
+ let b5 = p5;
2019
+ for (let w3 = 0; w3 < pwindows; w3++) {
2020
+ b5 = p5;
2021
+ points.push(b5);
2022
+ for (let i = 1; i < pwindowSize; i++) {
2023
+ b5 = b5.add(p5);
2024
+ points.push(b5);
2025
+ }
2026
+ p5 = b5.double();
2027
+ }
2028
+ return points;
2029
+ };
2030
+ var Gpows = void 0;
2031
+ var ctneg = (cnd, p5) => {
2032
+ const n2 = p5.negate();
2033
+ return cnd ? n2 : p5;
2034
+ };
2035
+ var wNAF = (n2) => {
2036
+ const comp = Gpows || (Gpows = precompute());
2037
+ let p5 = I4;
2038
+ let f7 = G;
2039
+ const pow_2_w = 2 ** W;
2040
+ const maxNum = pow_2_w;
2041
+ const mask = big(pow_2_w - 1);
2042
+ const shiftBy = big(W);
2043
+ for (let w3 = 0; w3 < pwindows; w3++) {
2044
+ let wbits = Number(n2 & mask);
2045
+ n2 >>= shiftBy;
2046
+ if (wbits > pwindowSize) {
2047
+ wbits -= maxNum;
2048
+ n2 += 1n;
2049
+ }
2050
+ const off = w3 * pwindowSize;
2051
+ const offF = off;
2052
+ const offP = off + Math.abs(wbits) - 1;
2053
+ const isEven = w3 % 2 !== 0;
2054
+ const isNeg = wbits < 0;
2055
+ if (wbits === 0) {
2056
+ f7 = f7.add(ctneg(isEven, comp[offF]));
2057
+ } else {
2058
+ p5 = p5.add(ctneg(isNeg, comp[offP]));
2059
+ }
2060
+ }
2061
+ if (n2 !== 0n)
2062
+ err("invalid wnaf");
2063
+ return { p: p5, f: f7 };
2064
+ };
2065
+
2066
+ // ../crypto-core/dist/cose.js
2067
+ var CanonicalCborError2 = class extends Error {
2068
+ code;
2069
+ constructor(code, message, options) {
2070
+ super(message, options);
2071
+ this.name = "CanonicalCborError";
2072
+ this.code = code;
2073
+ }
2074
+ };
2075
+ function decodeCanonicalCbor2(bytes) {
2076
+ try {
2077
+ return l4(bytes, {
2078
+ ...r,
2079
+ rejectStreaming: true,
2080
+ rejectDuplicateKeys: true,
2081
+ // A CIP-309 record carries integers, byte/text strings, arrays, maps and
2082
+ // `null` — and nothing else. Without these rejections the major-type-7
2083
+ // surface leaks into the decoder: a float16/32/64 that happens to hold an
2084
+ // integral value (e.g. 1.0) silently decodes to the integer 1 and passes
2085
+ // a `z.literal(1)` / Number.isInteger schema check, so two byte strings
2086
+ // that are NOT byte-identical canonicalise to the same record. That
2087
+ // breaks the cross-implementation parity invariant (the Python twin
2088
+ // already rejects non-integer `v` / `enc.scheme` outright). Reject the
2089
+ // whole non-record surface — floats, negative zero, undefined, and
2090
+ // non-{true,false,null} simple values — so any such input surfaces as
2091
+ // MALFORMED_CBOR via mapDecodeError rather than decoding to a look-alike.
2092
+ rejectFloats: true,
2093
+ rejectNegativeZero: true,
2094
+ rejectUndefined: true,
2095
+ rejectSimple: true
2096
+ });
2097
+ } catch (cause) {
2098
+ throw mapDecodeError2(cause);
2099
+ }
2100
+ }
2101
+ function mapDecodeError2(cause) {
2102
+ const message = cause instanceof Error ? cause.message : String(cause);
2103
+ const lower = message.toLowerCase();
2104
+ const isIndefinite = lower.includes("streaming") || lower.includes("indefinite");
2105
+ const detail = isIndefinite ? `indefinite-length items are not permitted in canonical CBOR: ${message}` : message;
2106
+ return new CanonicalCborError2("MALFORMED_CBOR", `cbor decode failed: ${detail}`, { cause });
2107
+ }
2108
+ Point.CURVE().n;
2109
+ var CoseVerifyError = class extends Error {
2110
+ code;
2111
+ constructor(code, message, options) {
2112
+ super(message, options);
2113
+ this.name = "CoseVerifyError";
2114
+ this.code = code;
2115
+ }
2116
+ };
2117
+ var CARDANO_POE_SIG_DOMAIN_PREFIX = "cardano-poe-record-sig-v1";
2118
+ var CARDANO_POE_SIG_DOMAIN_PREFIX_BYTES = new TextEncoder().encode(
2119
+ CARDANO_POE_SIG_DOMAIN_PREFIX
2120
+ );
2121
+ if (CARDANO_POE_SIG_DOMAIN_PREFIX_BYTES.length !== 25) {
2122
+ throw new Error(
2123
+ `cardano-poe-record-sig-v1 prefix must encode to exactly 25 UTF-8 bytes, got ${CARDANO_POE_SIG_DOMAIN_PREFIX_BYTES.length}`
2124
+ );
2125
+ }
2126
+ function asCoseHeader(value) {
2127
+ if (value instanceof Map) return value;
2128
+ if (value !== null && typeof value === "object" && value.constructor === Object) {
2129
+ return new Map(Object.entries(value));
2130
+ }
2131
+ return null;
2132
+ }
2133
+ function decodeCoseSign1(bytes) {
2134
+ let arr;
2135
+ try {
2136
+ arr = decodeCanonicalCbor2(bytes);
2137
+ } catch (cause) {
2138
+ throw new CoseVerifyError("MALFORMED_SIG_COSE", "cose decode failed", { cause });
2139
+ }
2140
+ if (!Array.isArray(arr) || arr.length !== 4) {
2141
+ throw new CoseVerifyError("MALFORMED_SIG_COSE", "expected 4-element array");
2142
+ }
2143
+ const [protectedBytesRaw, unprotectedRaw, payloadRaw, signatureRaw] = arr;
2144
+ if (!(protectedBytesRaw instanceof Uint8Array)) {
2145
+ throw new CoseVerifyError("MALFORMED_SIG_COSE", "protected_bytes must be bytes");
2146
+ }
2147
+ const unprotectedHeader = asCoseHeader(unprotectedRaw);
2148
+ if (unprotectedHeader === null) {
2149
+ throw new CoseVerifyError("MALFORMED_SIG_COSE", "unprotected header must be map");
2150
+ }
2151
+ if (payloadRaw !== null && !(payloadRaw instanceof Uint8Array)) {
2152
+ throw new CoseVerifyError("MALFORMED_SIG_COSE", "payload must be bytes or null");
2153
+ }
2154
+ if (!(signatureRaw instanceof Uint8Array) || signatureRaw.length !== 64) {
2155
+ throw new CoseVerifyError("MALFORMED_SIG_COSE", "signature must be 64 bytes");
2156
+ }
2157
+ let protectedHeader;
2158
+ if (protectedBytesRaw.length === 0) {
2159
+ protectedHeader = /* @__PURE__ */ new Map();
2160
+ } else {
2161
+ let decodedProtected;
2162
+ try {
2163
+ decodedProtected = decodeCanonicalCbor2(protectedBytesRaw);
2164
+ } catch (cause) {
2165
+ throw new CoseVerifyError("MALFORMED_SIG_COSE", "protected header decode failed", { cause });
2166
+ }
2167
+ const ph = asCoseHeader(decodedProtected);
2168
+ if (ph === null) {
2169
+ throw new CoseVerifyError("MALFORMED_SIG_COSE", "protected header must decode to map");
2170
+ }
2171
+ if (ph.size === 0) {
2172
+ throw new CoseVerifyError(
2173
+ "MALFORMED_SIG_COSE",
2174
+ "empty protected header must encode as 0x40 (zero-length bstr), not as an empty map"
2175
+ );
2176
+ }
2177
+ protectedHeader = ph;
2178
+ }
2179
+ return {
2180
+ protectedHeader,
2181
+ protectedBytes: protectedBytesRaw,
2182
+ unprotectedHeader,
2183
+ payload: payloadRaw,
2184
+ signature: signatureRaw
2185
+ };
2186
+ }
2187
+
2188
+ // src/chunked.ts
2189
+ var UTF8_ENCODER = new TextEncoder();
2190
+ function bytesChunkArrayConcat(chunks) {
2191
+ let total = 0;
2192
+ for (const c5 of chunks) total += c5.length;
2193
+ const out = new Uint8Array(total);
2194
+ let offset = 0;
2195
+ for (const c5 of chunks) {
2196
+ out.set(c5, offset);
2197
+ offset += c5.length;
2198
+ }
2199
+ return out;
2200
+ }
2201
+ function reconstructChunkedUri(chunks) {
2202
+ const merged = bytesChunkArrayConcat(chunks.map((c5) => UTF8_ENCODER.encode(c5)));
2203
+ try {
2204
+ const uri = new TextDecoder("utf-8", { fatal: true }).decode(merged);
2205
+ return { ok: true, uri };
2206
+ } catch (cause) {
2207
+ return {
2208
+ ok: false,
2209
+ code: "INVALID_URI",
2210
+ reason: cause instanceof Error ? cause.message : String(cause)
2211
+ };
2212
+ }
2213
+ }
2214
+ var SEVERITY = Object.freeze({
2215
+ // --- Part A ---
2216
+ MALFORMED_CBOR: "error",
2217
+ SCHEMA_TYPE_MISMATCH: "error",
2218
+ SCHEMA_MISSING_REQUIRED: "error",
2219
+ SCHEMA_UNKNOWN_FIELD: "error",
2220
+ SCHEMA_INVALID_LITERAL: "error",
2221
+ SCHEMA_EMPTY_RECORD: "error",
2222
+ HASH_DIGEST_LENGTH_MISMATCH: "error",
2223
+ UNSUPPORTED_HASH_ALG: "error",
2224
+ UNSUPPORTED_MERKLE_COMMIT_ALG: "error",
2225
+ INVALID_URI: "error",
2226
+ CHUNK_TOO_LARGE: "error",
2227
+ UNAUTHENTICATED_CIPHER_FORBIDDEN: "error",
2228
+ UNSUPPORTED_AEAD_ALG: "error",
2229
+ NONCE_LENGTH_MISMATCH: "error",
2230
+ UNSUPPORTED_ENVELOPE_SCHEME: "error",
2231
+ ENC_SLOTS_EMPTY: "error",
2232
+ ENC_SLOT_INVALID_SHAPE: "error",
2233
+ UNSUPPORTED_KEM_ALG: "error",
2234
+ ENC_KEM_REQUIRED: "error",
2235
+ KEM_EPK_LENGTH_MISMATCH: "error",
2236
+ KEM_CT_LENGTH_MISMATCH: "error",
2237
+ WRAP_LENGTH_MISMATCH: "error",
2238
+ ENC_SLOTS_MAC_INVALID_LENGTH: "error",
2239
+ ENC_SLOTS_MAC_REQUIRED: "error",
2240
+ ENC_SLOTS_REQUIRED: "error",
2241
+ ENC_EXCLUSIVITY_VIOLATION: "error",
2242
+ ENC_NO_KEY_PATH: "error",
2243
+ ENC_REQUIRES_CONTENT_HASH: "error",
2244
+ ENC_PASSPHRASE_ALG_UNSUPPORTED: "error",
2245
+ ENC_PASSPHRASE_SALT_TOO_SHORT: "error",
2246
+ ENC_PASSPHRASE_SALT_TOO_LONG: "error",
2247
+ ENC_PASSPHRASE_ARGON2_PARAMS_TOO_LOW: "error",
2248
+ ENC_PASSPHRASE_PARAMS_EXCEED_POLICY: "error",
2249
+ MALFORMED_SIG_COSE_SIGN1: "error",
2250
+ SIGNATURE_UNSUPPORTED: "info",
2251
+ SIG_ENTRY_INVALID_SHAPE: "error",
2252
+ SIG_ENTRY_KID_COSE_KEY_CONFLICT: "error",
2253
+ SIG_PRIVATE_KEY_LEAKED: "error",
2254
+ SUPERSEDES_TX_INVALID_LENGTH: "error",
2255
+ EXTENSION_UNSUPPORTED_CRITICAL: "error",
2256
+ CRIT_SHAPE_INVALID: "error",
2257
+ // --- Part B ---
2258
+ METADATA_NOT_FOUND: "error",
2259
+ INSUFFICIENT_CONFIRMATIONS: "info",
2260
+ SIGNATURE_INVALID: "error",
2261
+ SIGNER_KEY_UNRESOLVED: "error",
2262
+ WALLET_ADDRESS_MISMATCH: "error",
2263
+ URI_TARGET_FORBIDDEN: "error",
2264
+ URI_INTEGRITY_MISMATCH: "error",
2265
+ URI_FETCH_FAILED: "warning",
2266
+ CONTENT_UNAVAILABLE: "error",
2267
+ CIPHERTEXT_UNAVAILABLE: "error",
2268
+ PROVIDER_UNAVAILABLE: "error",
2269
+ SERVICE_INDEPENDENCE_VIOLATION: "error",
2270
+ WRONG_DECRYPTION_INPUT_SHAPE: "error",
2271
+ WRONG_RECIPIENT_KEY: "error",
2272
+ TAMPERED_HEADER: "error",
2273
+ TAMPERED_CIPHERTEXT: "error",
2274
+ KDF_DERIVATION_FAILED: "error",
2275
+ SCHEMA_MERKLE_LEAF_COUNT_MISMATCH: "error",
2276
+ SCHEMA_MERKLE_LEAVES_FORMAT_UNSUPPORTED: "error",
2277
+ SCHEMA_MERKLE_LEAVES_MALFORMED: "error",
2278
+ MERKLE_ROOT_MISMATCH: "error",
2279
+ MERKLE_LEAVES_UNAVAILABLE: "warning",
2280
+ MERKLE_LEAVES_INFORMATIVE_FORM: "info",
2281
+ // Dual-severity — default reading is `info`; the verifier promotes to
2282
+ // `error` for merkle-only records (no `items[]` content claim was
2283
+ // validated in the same record).
2284
+ MERKLE_UNSUPPORTED: "info",
2285
+ // Dual-severity — default reading is `info` (render mode); strict
2286
+ // end-to-end verifiers promote to `error`.
2287
+ OUT_OF_PROFILE_SKIPPED: "info"
2288
+ });
2289
+ var ChunkedBytesArraySchema = zod.z.array(
2290
+ zod.z.instanceof(Uint8Array).refine((b5) => b5.length >= 1 && b5.length <= 64, {
2291
+ params: { code: "CHUNK_TOO_LARGE" }
2292
+ })
2293
+ ).min(1);
2294
+ var UTF8_ENCODER2 = new TextEncoder();
2295
+ var UriChunkArraySchema = zod.z.array(
2296
+ zod.z.string().refine(
2297
+ (s3) => {
2298
+ const n2 = UTF8_ENCODER2.encode(s3).length;
2299
+ return n2 >= 1 && n2 <= 64;
2300
+ },
2301
+ { params: { code: "CHUNK_TOO_LARGE" } }
2302
+ )
2303
+ ).min(1);
2304
+ var HashDigestSchema = zod.z.instanceof(Uint8Array);
2305
+ var HashesMapSchema = zod.z.record(zod.z.string(), HashDigestSchema);
2306
+ var MerkleCommitSchema = zod.z.object({
2307
+ alg: zod.z.string(),
2308
+ root: zod.z.instanceof(Uint8Array),
2309
+ leaf_count: zod.z.number().int().min(1),
2310
+ uris: zod.z.array(UriChunkArraySchema).min(1).optional()
2311
+ }).strict();
2312
+ var SlotSchema = zod.z.object({
2313
+ epk: zod.z.instanceof(Uint8Array).optional(),
2314
+ kem_ct: ChunkedBytesArraySchema.optional(),
2315
+ wrap: zod.z.instanceof(Uint8Array).optional()
2316
+ });
2317
+ zod.z.object({
2318
+ m: zod.z.number().int(),
2319
+ t: zod.z.number().int(),
2320
+ p: zod.z.number().int()
2321
+ }).strict();
2322
+ var PassphraseBlockSchema = zod.z.object({
2323
+ alg: zod.z.string(),
2324
+ salt: zod.z.instanceof(Uint8Array).superRefine((bytes, ctx) => {
2325
+ if (bytes.length < 16) {
2326
+ ctx.addIssue({
2327
+ code: "custom",
2328
+ path: [],
2329
+ message: `passphrase.salt length ${bytes.length} < 16`,
2330
+ params: { code: "ENC_PASSPHRASE_SALT_TOO_SHORT" }
2331
+ });
2332
+ } else if (bytes.length > 64) {
2333
+ ctx.addIssue({
2334
+ code: "custom",
2335
+ path: [],
2336
+ message: `passphrase.salt length ${bytes.length} > 64`,
2337
+ params: { code: "ENC_PASSPHRASE_SALT_TOO_LONG" }
2338
+ });
2339
+ }
2340
+ }),
2341
+ params: zod.z.record(zod.z.string(), zod.z.unknown())
2342
+ }).strict();
2343
+ var EncryptionEnvelopeSchema = zod.z.object({
2344
+ scheme: zod.z.unknown(),
2345
+ aead: zod.z.string(),
2346
+ kem: zod.z.string().optional(),
2347
+ nonce: zod.z.instanceof(Uint8Array),
2348
+ slots: zod.z.array(SlotSchema).optional(),
2349
+ slots_mac: zod.z.instanceof(Uint8Array).refine((b5) => b5.length === 32, {
2350
+ params: { code: "ENC_SLOTS_MAC_INVALID_LENGTH" }
2351
+ }).optional(),
2352
+ passphrase: PassphraseBlockSchema.optional()
2353
+ }).strict();
2354
+ var ItemEntrySchema = zod.z.object({
2355
+ hashes: HashesMapSchema,
2356
+ uris: zod.z.array(UriChunkArraySchema).min(1).optional(),
2357
+ // Captured as `unknown` so the validator can run the
2358
+ // `ENC_REQUIRES_CONTENT_HASH` pre-check ahead of any inner-shape errors
2359
+ // and surface the most informative code first.
2360
+ enc: zod.z.unknown().optional()
2361
+ }).strict();
2362
+ var SigEntrySchema = zod.z.object({
2363
+ cose_key: ChunkedBytesArraySchema.optional(),
2364
+ cose_sign1: ChunkedBytesArraySchema
2365
+ }).strict();
2366
+ var SupersedesSchema = zod.z.instanceof(Uint8Array).refine((b5) => b5.length === 32, {
2367
+ params: { code: "SUPERSEDES_TX_INVALID_LENGTH" }
2368
+ });
2369
+ var VersionLiteralSchema = zod.z.literal(1);
2370
+ var PoeRecordSchema = zod.z.looseObject({
2371
+ v: VersionLiteralSchema,
2372
+ items: zod.z.array(ItemEntrySchema).optional(),
2373
+ merkle: zod.z.array(MerkleCommitSchema).optional(),
2374
+ supersedes: SupersedesSchema.optional(),
2375
+ sigs: zod.z.array(SigEntrySchema).optional(),
2376
+ crit: zod.z.array(zod.z.string()).optional()
2377
+ });
2378
+ var TOP_LEVEL_BASE_KEYS = /* @__PURE__ */ new Set([
2379
+ "v",
2380
+ "items",
2381
+ "merkle",
2382
+ "supersedes",
2383
+ "sigs",
2384
+ "crit"
2385
+ ]);
2386
+ var EXTENSION_KEY_VENDOR_RE = /^x-.+\n?$/;
2387
+ var EXTENSION_KEY_COMPANION_RE = /^[a-z]+-.+\n?$/;
2388
+ function isExtensionKey(k4) {
2389
+ return EXTENSION_KEY_VENDOR_RE.test(k4) || EXTENSION_KEY_COMPANION_RE.test(k4);
2390
+ }
2391
+
2392
+ // src/validator.ts
2393
+ var HASH_ALG_LENGTHS = {
2394
+ "sha2-256": 32,
2395
+ "blake2b-256": 32
2396
+ };
2397
+ var MERKLE_COMMIT_ALG_LENGTHS = {
2398
+ "rfc9162-sha256": 32
2399
+ };
2400
+ var AEAD_NONCE_LENGTHS = {
2401
+ "xchacha20-poly1305": 24
2402
+ };
2403
+ var UNAUTHENTICATED_CIPHER_RE = /(?:^|[-_])(?:cbc|ctr|ecb|cfb|ofb)(?:[-_]|\n?$)|^(?:rc4|des|3des)(?:[-_]|\n?$)/i;
2404
+ var KEM_SLOT_DESCRIPTORS = {
2405
+ x25519: { field: "epk", fieldLength: 32, wrapLength: 48 },
2406
+ mlkem768x25519: { field: "kem_ct", fieldLength: 1120, wrapLength: 48 }
2407
+ };
2408
+ var KEM_FIELD_LENGTH_CODE = {
2409
+ epk: "KEM_EPK_LENGTH_MISMATCH",
2410
+ kem_ct: "KEM_CT_LENGTH_MISMATCH"
2411
+ };
2412
+ var PASSPHRASE_KDF_ALGS = /* @__PURE__ */ new Set(["argon2id"]);
2413
+ var KNOWN_SIG_ALG_IDS = /* @__PURE__ */ new Set([-8, -19]);
2414
+ function validatePoeRecord(bytes) {
2415
+ let decoded;
2416
+ try {
2417
+ decoded = decodeCanonicalCbor(bytes);
2418
+ } catch (cause) {
2419
+ return {
2420
+ ok: false,
2421
+ issues: [
2422
+ {
2423
+ code: "MALFORMED_CBOR",
2424
+ path: [],
2425
+ message: cause instanceof Error ? cause.message : String(cause),
2426
+ severity: "error"
2427
+ }
2428
+ ]
2429
+ };
2430
+ }
2431
+ const parse = PoeRecordSchema.safeParse(decoded);
2432
+ if (!parse.success) {
2433
+ const issues = parse.error.issues.map((issue2) => mapZodIssue(issue2, decoded)).sort(compareIssuePath);
2434
+ return { ok: false, issues };
2435
+ }
2436
+ const record = parse.data;
2437
+ const errors = [];
2438
+ const warnings = [];
2439
+ const info = [];
2440
+ const itemsLen = Array.isArray(record.items) ? record.items.length : 0;
2441
+ const merkleLen = Array.isArray(record.merkle) ? record.merkle.length : 0;
2442
+ if (itemsLen === 0 && merkleLen === 0) {
2443
+ errors.push(
2444
+ issue(
2445
+ "SCHEMA_EMPTY_RECORD",
2446
+ [],
2447
+ "record must carry at least one of items[] or merkle[] non-empty"
2448
+ )
2449
+ );
2450
+ }
2451
+ const decodedTopKeys = topLevelKeysOf(decoded);
2452
+ const critShapeInvalidIndices = checkCritShape(record, decodedTopKeys, errors);
2453
+ for (const k4 of decodedTopKeys) {
2454
+ if (TOP_LEVEL_BASE_KEYS.has(k4)) continue;
2455
+ if (isExtensionKey(k4)) continue;
2456
+ errors.push(issue("SCHEMA_UNKNOWN_FIELD", [k4], `unknown top-level field: ${k4}`));
2457
+ }
2458
+ if (Array.isArray(record.crit)) {
2459
+ for (let i = 0; i < record.crit.length; i++) {
2460
+ if (critShapeInvalidIndices.has(i)) continue;
2461
+ const critName = record.crit[i];
2462
+ errors.push(
2463
+ issue(
2464
+ "EXTENSION_UNSUPPORTED_CRITICAL",
2465
+ ["crit", i],
2466
+ `crit lists extension '${critName}' that this validator does not implement`
2467
+ )
2468
+ );
2469
+ }
2470
+ }
2471
+ for (let i = 0; i < (record.items ?? []).length; i++) {
2472
+ const item = record.items[i];
2473
+ checkItemHashes(item, i, errors);
2474
+ if (item.uris) checkItemUris(item.uris, ["items", i, "uris"], errors);
2475
+ if (item.enc !== void 0) checkItemEnc(item, i, errors);
2476
+ }
2477
+ for (let i = 0; i < (record.merkle ?? []).length; i++) {
2478
+ const commit = record.merkle[i];
2479
+ checkMerkleCommit(commit, i, errors);
2480
+ }
2481
+ if (record.sigs) {
2482
+ for (let i = 0; i < record.sigs.length; i++) {
2483
+ checkSigEntry(record.sigs[i], i, errors, info);
2484
+ }
2485
+ }
2486
+ if (errors.length > 0) {
2487
+ return { ok: false, issues: errors.sort(compareIssuePath) };
2488
+ }
2489
+ const result = {
2490
+ ok: true,
2491
+ record
2492
+ };
2493
+ if (warnings.length > 0) result.warnings = warnings.sort(compareIssuePath);
2494
+ if (info.length > 0) result.info = info.sort(compareIssuePath);
2495
+ return result;
2496
+ }
2497
+ function mapZodIssue(zissue, decoded) {
2498
+ const path = zissue.path;
2499
+ const explicit = zissue.params?.code;
2500
+ if (explicit !== void 0) {
2501
+ return issue(explicit, path, zissue.message);
2502
+ }
2503
+ const inSigsEntry = path.length >= 2 && path[0] === "sigs" && typeof path[1] === "number";
2504
+ const isInSlotEntry = (() => {
2505
+ if (path.length >= 5 && path[0] === "items" && typeof path[1] === "number" && path[2] === "enc" && path[3] === "slots" && typeof path[4] === "number") {
2506
+ return true;
2507
+ }
2508
+ if (path.length >= 2 && path[0] === "slots" && typeof path[1] === "number") {
2509
+ return true;
2510
+ }
2511
+ return false;
2512
+ })();
2513
+ const valueAtIssue = valueAtPath(decoded, path);
2514
+ const isMissing = valueAtIssue === void 0;
2515
+ switch (zissue.code) {
2516
+ case "invalid_type":
2517
+ if (isInSlotEntry) return issue("ENC_SLOT_INVALID_SHAPE", path, zissue.message);
2518
+ if (isMissing) {
2519
+ if (inSigsEntry) return issue("SIG_ENTRY_INVALID_SHAPE", path, zissue.message);
2520
+ return issue("SCHEMA_MISSING_REQUIRED", path, zissue.message);
2521
+ }
2522
+ if (inSigsEntry) return issue("SIG_ENTRY_INVALID_SHAPE", path, zissue.message);
2523
+ return issue("SCHEMA_TYPE_MISMATCH", path, zissue.message);
2524
+ case "invalid_value":
2525
+ if (path.length === 1 && path[0] === "v") {
2526
+ return issue(
2527
+ isMissing ? "SCHEMA_MISSING_REQUIRED" : "SCHEMA_INVALID_LITERAL",
2528
+ path,
2529
+ zissue.message
2530
+ );
2531
+ }
2532
+ return issue("SCHEMA_INVALID_LITERAL", path, zissue.message);
2533
+ case "unrecognized_keys":
2534
+ if (isInSlotEntry) return issue("ENC_SLOT_INVALID_SHAPE", path, zissue.message);
2535
+ if (inSigsEntry) return issue("SIG_ENTRY_INVALID_SHAPE", path, zissue.message);
2536
+ return issue("SCHEMA_UNKNOWN_FIELD", path, zissue.message);
2537
+ case "invalid_format":
2538
+ case "too_big":
2539
+ case "too_small":
2540
+ if (inSigsEntry) return issue("SIG_ENTRY_INVALID_SHAPE", path, zissue.message);
2541
+ return issue("SCHEMA_TYPE_MISMATCH", path, zissue.message);
2542
+ case "invalid_union":
2543
+ case "invalid_key":
2544
+ case "invalid_element":
2545
+ case "custom":
2546
+ default:
2547
+ if (isInSlotEntry) return issue("ENC_SLOT_INVALID_SHAPE", path, zissue.message);
2548
+ if (inSigsEntry) return issue("SIG_ENTRY_INVALID_SHAPE", path, zissue.message);
2549
+ return issue("SCHEMA_TYPE_MISMATCH", path, zissue.message);
2550
+ }
2551
+ }
2552
+ function checkItemHashes(item, idx, errors) {
2553
+ const entries = Object.entries(item.hashes);
2554
+ if (entries.length === 0) {
2555
+ errors.push(
2556
+ issue(
2557
+ "SCHEMA_TYPE_MISMATCH",
2558
+ ["items", idx, "hashes"],
2559
+ "hashes must be a non-empty CBOR map of <alg-id> -> <digest>"
2560
+ )
2561
+ );
2562
+ return;
2563
+ }
2564
+ for (const [alg, digest] of entries) {
2565
+ if (!(alg in HASH_ALG_LENGTHS)) {
2566
+ errors.push(
2567
+ issue("UNSUPPORTED_HASH_ALG", ["items", idx, "hashes", alg], `unknown hash alg: ${alg}`)
2568
+ );
2569
+ continue;
2570
+ }
2571
+ const expected = HASH_ALG_LENGTHS[alg];
2572
+ if (digest.length !== expected) {
2573
+ errors.push(
2574
+ issue(
2575
+ "HASH_DIGEST_LENGTH_MISMATCH",
2576
+ ["items", idx, "hashes", alg],
2577
+ `hashes['${alg}'] digest length ${digest.length} != ${expected}`
2578
+ )
2579
+ );
2580
+ }
2581
+ }
2582
+ }
2583
+ function checkItemUris(uris, basePath, errors) {
2584
+ uris.forEach((chunks, ui) => validateOneUri(chunks, [...basePath, ui], errors));
2585
+ }
2586
+ function validateOneUri(chunks, path, errors) {
2587
+ const reconstructed = reconstructChunkedUri(chunks);
2588
+ if (!reconstructed.ok) {
2589
+ errors.push(issue(reconstructed.code, path, reconstructed.reason));
2590
+ return;
2591
+ }
2592
+ const uri = reconstructed.uri;
2593
+ if (uri.includes("#")) {
2594
+ errors.push(
2595
+ issue(
2596
+ "INVALID_URI",
2597
+ path,
2598
+ "URI contains a fragment identifier ('#'), which is forbidden"
2599
+ )
2600
+ );
2601
+ return;
2602
+ }
2603
+ const sepIdx = uri.indexOf("://");
2604
+ if (sepIdx <= 0 || !/^[a-z][a-z0-9+.-]*$/i.test(uri.slice(0, sepIdx))) {
2605
+ errors.push(
2606
+ issue("INVALID_URI", path, "URI is not absolute (missing scheme://hierarchical-part)")
2607
+ );
2608
+ return;
2609
+ }
2610
+ const scheme = uri.slice(0, sepIdx).toLowerCase();
2611
+ const rest = uri.slice(sepIdx + "://".length);
2612
+ if (scheme === "ar") {
2613
+ if (!/^ar:\/\/[A-Za-z0-9_-]{43}$/.test("ar://" + rest)) {
2614
+ errors.push(
2615
+ issue(
2616
+ "INVALID_URI",
2617
+ path,
2618
+ "ar:// URI does not match `^ar://[A-Za-z0-9_-]{43}$` (43-char base64url txid, no path/query/fragment)"
2619
+ )
2620
+ );
2621
+ }
2622
+ return;
2623
+ }
2624
+ if (scheme === "ipfs") {
2625
+ const slashIdx = rest.indexOf("/");
2626
+ const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
2627
+ if (!validateCidProfile(cid)) {
2628
+ errors.push(
2629
+ issue(
2630
+ "INVALID_URI",
2631
+ path,
2632
+ "ipfs:// URI is not a valid CID under the CIP-309 profile"
2633
+ )
2634
+ );
2635
+ }
2636
+ return;
2637
+ }
2638
+ errors.push(
2639
+ issue(
2640
+ "INVALID_URI",
2641
+ path,
2642
+ "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}"
2643
+ )
2644
+ );
2645
+ }
2646
+ function checkItemEnc(item, idx, errors) {
2647
+ const hasContentHash = Object.keys(item.hashes).some((alg) => alg in HASH_ALG_LENGTHS);
2648
+ if (!hasContentHash) {
2649
+ errors.push(
2650
+ issue(
2651
+ "ENC_REQUIRES_CONTENT_HASH",
2652
+ ["items", idx, "enc"],
2653
+ "item carries `enc` but `hashes` has no content-hash entry (sha2-256 or blake2b-256)"
2654
+ )
2655
+ );
2656
+ return;
2657
+ }
2658
+ const encParse = EncryptionEnvelopeSchema.safeParse(item.enc);
2659
+ if (!encParse.success) {
2660
+ for (const zissue of encParse.error.issues) {
2661
+ const mapped = mapZodIssue(zissue, item.enc);
2662
+ errors.push({
2663
+ ...mapped,
2664
+ path: ["items", idx, "enc", ...mapped.path]
2665
+ });
2666
+ }
2667
+ return;
2668
+ }
2669
+ const enc = encParse.data;
2670
+ const basePath = ["items", idx, "enc"];
2671
+ if (typeof enc.scheme !== "number" || !Number.isInteger(enc.scheme) || enc.scheme !== 1) {
2672
+ errors.push(
2673
+ issue(
2674
+ "UNSUPPORTED_ENVELOPE_SCHEME",
2675
+ [...basePath, "scheme"],
2676
+ `enc.scheme must be the unsigned integer 1; got ${String(enc.scheme)}`
2677
+ )
2678
+ );
2679
+ }
2680
+ if (UNAUTHENTICATED_CIPHER_RE.test(enc.aead)) {
2681
+ errors.push(
2682
+ issue(
2683
+ "UNAUTHENTICATED_CIPHER_FORBIDDEN",
2684
+ [...basePath, "aead"],
2685
+ `'${enc.aead}' is an unauthenticated cipher; CIP-309 mandates an authenticated (AEAD) cipher`
2686
+ )
2687
+ );
2688
+ return;
2689
+ }
2690
+ if (!(enc.aead in AEAD_NONCE_LENGTHS)) {
2691
+ errors.push(
2692
+ issue("UNSUPPORTED_AEAD_ALG", [...basePath, "aead"], `unknown aead alg: ${enc.aead}`)
2693
+ );
2694
+ return;
2695
+ }
2696
+ const expectedNonceLen = AEAD_NONCE_LENGTHS[enc.aead];
2697
+ if (enc.nonce.length !== expectedNonceLen) {
2698
+ errors.push(
2699
+ issue(
2700
+ "NONCE_LENGTH_MISMATCH",
2701
+ [...basePath, "nonce"],
2702
+ `nonce length ${enc.nonce.length} != ${expectedNonceLen} for ${enc.aead}`
2703
+ )
2704
+ );
2705
+ }
2706
+ if (enc.kem !== void 0 && !(enc.kem in KEM_SLOT_DESCRIPTORS)) {
2707
+ errors.push(issue("UNSUPPORTED_KEM_ALG", [...basePath, "kem"], `unknown kem alg: ${enc.kem}`));
2708
+ }
2709
+ const hasSlots = enc.slots !== void 0;
2710
+ const hasSlotsMac = enc.slots_mac !== void 0;
2711
+ const hasPassphrase = enc.passphrase !== void 0;
2712
+ if (hasSlots && hasPassphrase) {
2713
+ errors.push(
2714
+ issue("ENC_EXCLUSIVITY_VIOLATION", basePath, "enc combines slots with passphrase; pick one")
2715
+ );
2716
+ }
2717
+ if (hasSlots && !hasSlotsMac) {
2718
+ errors.push(
2719
+ issue("ENC_SLOTS_MAC_REQUIRED", basePath, "enc.slots present but enc.slots_mac absent")
2720
+ );
2721
+ }
2722
+ if (hasSlotsMac && !hasSlots) {
2723
+ errors.push(
2724
+ issue("ENC_SLOTS_REQUIRED", basePath, "enc.slots_mac present but enc.slots absent")
2725
+ );
2726
+ }
2727
+ if (hasSlots && enc.kem === void 0) {
2728
+ errors.push(issue("ENC_KEM_REQUIRED", basePath, "enc.slots present but enc.kem absent"));
2729
+ }
2730
+ if (!hasSlots && !hasPassphrase) {
2731
+ errors.push(
2732
+ issue(
2733
+ "ENC_NO_KEY_PATH",
2734
+ basePath,
2735
+ "enc requires either slots or passphrase \u2014 no on-chain key path otherwise"
2736
+ )
2737
+ );
2738
+ }
2739
+ if (hasSlots) {
2740
+ if (enc.slots.length < 1) {
2741
+ errors.push(
2742
+ issue("ENC_SLOTS_EMPTY", [...basePath, "slots"], `slots length ${enc.slots.length} < 1`)
2743
+ );
2744
+ }
2745
+ const descriptor = enc.kem !== void 0 ? KEM_SLOT_DESCRIPTORS[enc.kem] : void 0;
2746
+ if (descriptor !== void 0) {
2747
+ const rawSlotKeys = rawSlotKeySets(item.enc);
2748
+ enc.slots.forEach((slot, si) => {
2749
+ checkSlotShape(
2750
+ slot,
2751
+ rawSlotKeys[si] ?? /* @__PURE__ */ new Set(),
2752
+ descriptor,
2753
+ enc.kem,
2754
+ [...basePath, "slots", si],
2755
+ errors
2756
+ );
2757
+ });
2758
+ }
2759
+ }
2760
+ if (hasPassphrase) {
2761
+ const pp = enc.passphrase;
2762
+ const ppPath = [...basePath, "passphrase"];
2763
+ if (!PASSPHRASE_KDF_ALGS.has(pp.alg)) {
2764
+ errors.push(
2765
+ issue(
2766
+ "ENC_PASSPHRASE_ALG_UNSUPPORTED",
2767
+ [...ppPath, "alg"],
2768
+ `unknown passphrase kdf alg: ${pp.alg}`
2769
+ )
2770
+ );
2771
+ return;
2772
+ }
2773
+ if (pp.alg === "argon2id") {
2774
+ const allowed = /* @__PURE__ */ new Set(["m", "t", "p"]);
2775
+ for (const k4 of Object.keys(pp.params)) {
2776
+ if (!allowed.has(k4)) {
2777
+ errors.push(
2778
+ issue(
2779
+ "SCHEMA_UNKNOWN_FIELD",
2780
+ [...ppPath, "params", k4],
2781
+ `unknown argon2id params field: ${k4}`
2782
+ )
2783
+ );
2784
+ }
2785
+ }
2786
+ const p5 = pp.params;
2787
+ const argonInt = (val, name) => {
2788
+ if (typeof val !== "number" || !Number.isInteger(val)) {
2789
+ errors.push(
2790
+ issue(
2791
+ "SCHEMA_TYPE_MISMATCH",
2792
+ [...ppPath, "params", name],
2793
+ `argon2id params.${name} must be a CBOR unsigned integer`
2794
+ )
2795
+ );
2796
+ return null;
2797
+ }
2798
+ return val;
2799
+ };
2800
+ const mVal = argonInt(p5.m, "m");
2801
+ const tVal = argonInt(p5.t, "t");
2802
+ const pVal = argonInt(p5.p, "p");
2803
+ if (mVal !== null && mVal < 65536) {
2804
+ errors.push(
2805
+ issue(
2806
+ "ENC_PASSPHRASE_ARGON2_PARAMS_TOO_LOW",
2807
+ [...ppPath, "params", "m"],
2808
+ "argon2id requires m >= 65536 KiB"
2809
+ )
2810
+ );
2811
+ }
2812
+ if (tVal !== null && tVal < 3) {
2813
+ errors.push(
2814
+ issue(
2815
+ "ENC_PASSPHRASE_ARGON2_PARAMS_TOO_LOW",
2816
+ [...ppPath, "params", "t"],
2817
+ "argon2id requires t >= 3"
2818
+ )
2819
+ );
2820
+ }
2821
+ if (pVal !== null && pVal < 1) {
2822
+ errors.push(
2823
+ issue(
2824
+ "ENC_PASSPHRASE_ARGON2_PARAMS_TOO_LOW",
2825
+ [...ppPath, "params", "p"],
2826
+ "argon2id requires p >= 1"
2827
+ )
2828
+ );
2829
+ }
2830
+ }
2831
+ }
2832
+ }
2833
+ var SLOT_KEY_UNIVERSE = /* @__PURE__ */ new Set(["epk", "kem_ct", "wrap"]);
2834
+ function checkSlotShape(slot, rawKeys, descriptor, kem, slotPath, errors) {
2835
+ const foreignField = descriptor.field === "epk" ? "kem_ct" : "epk";
2836
+ if (rawKeys.has(foreignField)) {
2837
+ errors.push(
2838
+ issue(
2839
+ "ENC_SLOT_INVALID_SHAPE",
2840
+ [...slotPath, foreignField],
2841
+ `slot carries '${foreignField}' but kem='${kem}' expects '${descriptor.field}'`
2842
+ )
2843
+ );
2844
+ }
2845
+ for (const k4 of rawKeys) {
2846
+ if (!SLOT_KEY_UNIVERSE.has(k4)) {
2847
+ errors.push(
2848
+ issue(
2849
+ "ENC_SLOT_INVALID_SHAPE",
2850
+ [...slotPath, k4],
2851
+ `slot carries unexpected key '${k4}'; a slot is a 2-key map {${descriptor.field}, wrap}`
2852
+ )
2853
+ );
2854
+ }
2855
+ }
2856
+ if (descriptor.field === "epk") {
2857
+ if (slot.epk === void 0) {
2858
+ errors.push(
2859
+ issue(
2860
+ "ENC_SLOT_INVALID_SHAPE",
2861
+ [...slotPath, "epk"],
2862
+ `slot for kem='${kem}' is missing required 'epk'`
2863
+ )
2864
+ );
2865
+ } else if (slot.epk.length !== descriptor.fieldLength) {
2866
+ errors.push(
2867
+ issue(
2868
+ KEM_FIELD_LENGTH_CODE.epk,
2869
+ [...slotPath, "epk"],
2870
+ `slot.epk length ${slot.epk.length} != ${descriptor.fieldLength} for ${kem}`
2871
+ )
2872
+ );
2873
+ }
2874
+ } else {
2875
+ if (slot.kem_ct === void 0) {
2876
+ errors.push(
2877
+ issue(
2878
+ "ENC_SLOT_INVALID_SHAPE",
2879
+ [...slotPath, "kem_ct"],
2880
+ `slot for kem='${kem}' is missing required 'kem_ct'`
2881
+ )
2882
+ );
2883
+ } else {
2884
+ const reassembled = bytesChunkArrayConcat(slot.kem_ct).length;
2885
+ if (reassembled !== descriptor.fieldLength) {
2886
+ errors.push(
2887
+ issue(
2888
+ KEM_FIELD_LENGTH_CODE.kem_ct,
2889
+ [...slotPath, "kem_ct"],
2890
+ `slot.kem_ct reassembles to ${reassembled} bytes != ${descriptor.fieldLength} for ${kem}`
2891
+ )
2892
+ );
2893
+ }
2894
+ }
2895
+ }
2896
+ if (slot.wrap === void 0) {
2897
+ errors.push(
2898
+ issue(
2899
+ "ENC_SLOT_INVALID_SHAPE",
2900
+ [...slotPath, "wrap"],
2901
+ `slot for kem='${kem}' is missing required 'wrap'`
2902
+ )
2903
+ );
2904
+ } else if (slot.wrap.length !== descriptor.wrapLength) {
2905
+ errors.push(
2906
+ issue(
2907
+ "WRAP_LENGTH_MISMATCH",
2908
+ [...slotPath, "wrap"],
2909
+ `slot.wrap length ${slot.wrap.length} != ${descriptor.wrapLength}`
2910
+ )
2911
+ );
2912
+ }
2913
+ }
2914
+ function rawSlotKeySets(rawEnc) {
2915
+ const slots = mapLikeGet(rawEnc, "slots");
2916
+ if (!Array.isArray(slots)) return [];
2917
+ return slots.map((slot) => {
2918
+ const keys = /* @__PURE__ */ new Set();
2919
+ if (slot instanceof Map) {
2920
+ for (const k4 of slot.keys()) if (typeof k4 === "string") keys.add(k4);
2921
+ } else if (typeof slot === "object" && slot !== null) {
2922
+ for (const k4 of Object.keys(slot)) keys.add(k4);
2923
+ }
2924
+ return keys;
2925
+ });
2926
+ }
2927
+ function mapLikeGet(value, key) {
2928
+ if (value instanceof Map) return value.get(key);
2929
+ if (typeof value === "object" && value !== null) {
2930
+ return value[key];
2931
+ }
2932
+ return void 0;
2933
+ }
2934
+ function checkMerkleCommit(commit, idx, errors) {
2935
+ const basePath = ["merkle", idx];
2936
+ if (!(commit.alg in MERKLE_COMMIT_ALG_LENGTHS)) {
2937
+ errors.push(
2938
+ issue(
2939
+ "UNSUPPORTED_MERKLE_COMMIT_ALG",
2940
+ [...basePath, "alg"],
2941
+ `unknown merkle commitment alg: ${commit.alg}`
2942
+ )
2943
+ );
2944
+ return;
2945
+ }
2946
+ const expected = MERKLE_COMMIT_ALG_LENGTHS[commit.alg];
2947
+ if (commit.root.length !== expected) {
2948
+ errors.push(
2949
+ issue(
2950
+ "HASH_DIGEST_LENGTH_MISMATCH",
2951
+ [...basePath, "root"],
2952
+ `merkle entry root length ${commit.root.length} != ${expected} for ${commit.alg}`
2953
+ )
2954
+ );
2955
+ }
2956
+ if (commit.uris) {
2957
+ checkItemUris(commit.uris, [...basePath, "uris"], errors);
2958
+ }
2959
+ }
2960
+ function checkSigEntry(entry, idx, errors, info) {
2961
+ if (entry.cose_key !== void 0) {
2962
+ const keyIssue = inspectCoseKey(entry.cose_key, idx);
2963
+ if (keyIssue !== null) {
2964
+ errors.push(keyIssue);
2965
+ return;
2966
+ }
2967
+ }
2968
+ const merged = bytesChunkArrayConcat(entry.cose_sign1);
2969
+ let cose;
2970
+ try {
2971
+ cose = decodeCoseSign1(merged);
2972
+ } catch (cause) {
2973
+ errors.push(
2974
+ issue(
2975
+ "MALFORMED_SIG_COSE_SIGN1",
2976
+ ["sigs", idx],
2977
+ cause instanceof CoseVerifyError || cause instanceof Error ? cause.message : String(cause)
2978
+ )
2979
+ );
2980
+ return;
2981
+ }
2982
+ if (cose.payload !== null) {
2983
+ errors.push(
2984
+ issue(
2985
+ "MALFORMED_SIG_COSE_SIGN1",
2986
+ ["sigs", idx],
2987
+ "COSE_Sign1 payload must be null (detached); attached form forbidden"
2988
+ )
2989
+ );
2990
+ return;
2991
+ }
2992
+ const alg = cose.protectedHeader.get(1);
2993
+ if (typeof alg !== "number" || !KNOWN_SIG_ALG_IDS.has(alg)) {
2994
+ info.push(
2995
+ issue(
2996
+ "SIGNATURE_UNSUPPORTED",
2997
+ ["sigs", idx],
2998
+ `COSE_Sign1 protected alg ${String(alg)} not in {-8, -19}`
2999
+ )
3000
+ );
3001
+ }
3002
+ const protectedKid = cose.protectedHeader.get(4);
3003
+ if (protectedKid instanceof Uint8Array && protectedKid.length === 32 && entry.cose_key !== void 0) {
3004
+ errors.push(
3005
+ issue(
3006
+ "SIG_ENTRY_KID_COSE_KEY_CONFLICT",
3007
+ ["sigs", idx],
3008
+ "sigs[i] carries both a 32-byte protected `kid` (path 1) and an inline `cose_key` (path 2); paths are mutually exclusive"
3009
+ )
3010
+ );
3011
+ }
3012
+ }
3013
+ function inspectCoseKey(keyChunks, i) {
3014
+ let decoded;
3015
+ try {
3016
+ decoded = decodeCanonicalCbor(bytesChunkArrayConcat(keyChunks));
3017
+ } catch (cause) {
3018
+ return issue(
3019
+ "MALFORMED_SIG_COSE_SIGN1",
3020
+ ["sigs", i, "cose_key"],
3021
+ `sigs[${i}].cose_key failed to decode as cbor<COSE_Key>: ${cause instanceof Error ? cause.message : String(cause)}`
3022
+ );
3023
+ }
3024
+ const getLabel = (label) => {
3025
+ if (decoded instanceof Map) return decoded.get(label);
3026
+ if (typeof decoded === "object" && decoded !== null) {
3027
+ return decoded[String(label)];
3028
+ }
3029
+ return void 0;
3030
+ };
3031
+ const hasLabel = (label) => {
3032
+ if (decoded instanceof Map) return decoded.has(label);
3033
+ if (typeof decoded === "object" && decoded !== null) {
3034
+ return Object.prototype.hasOwnProperty.call(decoded, String(label));
3035
+ }
3036
+ return false;
3037
+ };
3038
+ if (hasLabel(-4)) {
3039
+ return issue(
3040
+ "SIG_PRIVATE_KEY_LEAKED",
3041
+ ["sigs", i, "cose_key"],
3042
+ "cose_key carries COSE_Key private-key material (label -4, the OKP/EC2 private scalar d); publishing a private key on the permanent ledger is forbidden"
3043
+ );
3044
+ }
3045
+ const kty = getLabel(1);
3046
+ if (kty !== 1) {
3047
+ return issue(
3048
+ "MALFORMED_SIG_COSE_SIGN1",
3049
+ ["sigs", i, "cose_key"],
3050
+ `sigs[${i}].cose_key COSE_Key kty (label 1) must be 1 (OKP); got ${String(kty)}`
3051
+ );
3052
+ }
3053
+ const crv = getLabel(-1);
3054
+ if (crv !== 6) {
3055
+ return issue(
3056
+ "MALFORMED_SIG_COSE_SIGN1",
3057
+ ["sigs", i, "cose_key"],
3058
+ `sigs[${i}].cose_key COSE_Key crv (label -1) must be 6 (Ed25519); got ${String(crv)}`
3059
+ );
3060
+ }
3061
+ if (!hasLabel(-2)) {
3062
+ return issue(
3063
+ "MALFORMED_SIG_COSE_SIGN1",
3064
+ ["sigs", i, "cose_key"],
3065
+ `sigs[${i}].cose_key COSE_Key missing label -2 (Ed25519 public-key bytes)`
3066
+ );
3067
+ }
3068
+ const x5 = getLabel(-2);
3069
+ if (!(x5 instanceof Uint8Array) || x5.length !== 32) {
3070
+ const got = x5 instanceof Uint8Array ? `${x5.length}-byte bstr` : typeof x5;
3071
+ return issue(
3072
+ "MALFORMED_SIG_COSE_SIGN1",
3073
+ ["sigs", i, "cose_key"],
3074
+ `sigs[${i}].cose_key COSE_Key label -2 must be a 32-byte byte string (Ed25519 public key); got ${got}`
3075
+ );
3076
+ }
3077
+ return null;
3078
+ }
3079
+ var ACCEPTED_CIDV1_MULTIBASE = /* @__PURE__ */ new Set(["b", "B", "f", "F", "z"]);
3080
+ var ACCEPTED_MULTICODECS = /* @__PURE__ */ new Set([85, 112, 113]);
3081
+ var ACCEPTED_MULTIHASHES = /* @__PURE__ */ new Map([
3082
+ [18, 32],
3083
+ [45600, 32]
3084
+ ]);
3085
+ function validateCidProfile(cid) {
3086
+ if (cid.length === 0) return false;
3087
+ if (cid.startsWith("Qm")) {
3088
+ let decoded;
3089
+ try {
3090
+ decoded = decodeBase58btc(cid);
3091
+ } catch {
3092
+ return false;
3093
+ }
3094
+ return decoded.length === 34 && decoded[0] === 18 && decoded[1] === 32;
3095
+ }
3096
+ const mbPrefix = cid[0];
3097
+ if (!ACCEPTED_CIDV1_MULTIBASE.has(mbPrefix)) return false;
3098
+ let bytes;
3099
+ try {
3100
+ bytes = decodeMultibase(mbPrefix, cid.slice(1));
3101
+ } catch {
3102
+ return false;
3103
+ }
3104
+ if (bytes.length < 4) return false;
3105
+ const versionParse = readVarint(bytes, 0);
3106
+ if (versionParse === null || versionParse.value !== 1) return false;
3107
+ const codecParse = readVarint(bytes, versionParse.next);
3108
+ if (codecParse === null) return false;
3109
+ if (!ACCEPTED_MULTICODECS.has(codecParse.value)) return false;
3110
+ const mhParse = readVarint(bytes, codecParse.next);
3111
+ if (mhParse === null) return false;
3112
+ const lenParse = readVarint(bytes, mhParse.next);
3113
+ if (lenParse === null) return false;
3114
+ const digestLen = lenParse.value;
3115
+ const expectedLen = ACCEPTED_MULTIHASHES.get(mhParse.value);
3116
+ if (expectedLen === void 0 || digestLen !== expectedLen) return false;
3117
+ if (lenParse.next + digestLen !== bytes.length) return false;
3118
+ return true;
3119
+ }
3120
+ function readVarint(bytes, start) {
3121
+ let value = 0;
3122
+ let shift = 0;
3123
+ let i = start;
3124
+ while (i < bytes.length) {
3125
+ const b5 = bytes[i];
3126
+ value |= (b5 & 127) << shift;
3127
+ i++;
3128
+ if ((b5 & 128) === 0) return { value, next: i };
3129
+ shift += 7;
3130
+ if (shift > 28) return null;
3131
+ }
3132
+ return null;
3133
+ }
3134
+ function decodeMultibase(prefix, body) {
3135
+ switch (prefix) {
3136
+ case "b":
3137
+ return decodeBase32(body.toLowerCase(), "rfc4648-lower");
3138
+ case "B":
3139
+ return decodeBase32(body.toUpperCase(), "rfc4648-upper");
3140
+ case "f":
3141
+ return decodeBase16(body.toLowerCase());
3142
+ case "F":
3143
+ return decodeBase16(body.toUpperCase());
3144
+ case "z":
3145
+ return decodeBase58btc(body);
3146
+ default:
3147
+ throw new Error(`unsupported multibase prefix ${prefix}`);
3148
+ }
3149
+ }
3150
+ var BASE16_LOWER = "0123456789abcdef";
3151
+ var BASE16_UPPER = "0123456789ABCDEF";
3152
+ function decodeBase16(s3) {
3153
+ if (s3.length % 2 !== 0) throw new Error("base16: odd-length");
3154
+ const out = new Uint8Array(s3.length / 2);
3155
+ const alphabet = s3 === s3.toLowerCase() ? BASE16_LOWER : BASE16_UPPER;
3156
+ for (let i = 0; i < out.length; i++) {
3157
+ const hi = alphabet.indexOf(s3[i * 2]);
3158
+ const lo = alphabet.indexOf(s3[i * 2 + 1]);
3159
+ if (hi < 0 || lo < 0) throw new Error(`base16: non-hex char at ${i * 2}`);
3160
+ out[i] = hi << 4 | lo;
3161
+ }
3162
+ return out;
3163
+ }
3164
+ var BASE32_RFC4648_LOWER = "abcdefghijklmnopqrstuvwxyz234567";
3165
+ var BASE32_RFC4648_UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
3166
+ function decodeBase32(s3, variant) {
3167
+ const alphabet = variant === "rfc4648-lower" ? BASE32_RFC4648_LOWER : BASE32_RFC4648_UPPER;
3168
+ const trimmed = s3.replace(/=+$/, "");
3169
+ const out = [];
3170
+ let buf = 0;
3171
+ let bits = 0;
3172
+ for (const ch of trimmed) {
3173
+ const idx = alphabet.indexOf(ch);
3174
+ if (idx < 0) throw new Error(`base32: invalid char '${ch}'`);
3175
+ buf = buf << 5 | idx;
3176
+ bits += 5;
3177
+ if (bits >= 8) {
3178
+ bits -= 8;
3179
+ out.push(buf >> bits & 255);
3180
+ }
3181
+ }
3182
+ return Uint8Array.from(out);
3183
+ }
3184
+ var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
3185
+ function decodeBase58btc(s3) {
3186
+ if (s3.length === 0) return new Uint8Array(0);
3187
+ let zeros = 0;
3188
+ while (zeros < s3.length && s3[zeros] === "1") zeros++;
3189
+ const size = Math.floor((s3.length - zeros) * 733 / 1e3) + 1;
3190
+ const b256 = new Uint8Array(size);
3191
+ let length = 0;
3192
+ for (let i = zeros; i < s3.length; i++) {
3193
+ const ch = s3[i];
3194
+ const carryIdx = BASE58_ALPHABET.indexOf(ch);
3195
+ if (carryIdx < 0) throw new Error(`base58: invalid char '${ch}'`);
3196
+ let carry = carryIdx;
3197
+ let k4 = 0;
3198
+ for (let j3 = size - 1; (carry !== 0 || k4 < length) && j3 >= 0; j3--, k4++) {
3199
+ carry += 58 * b256[j3];
3200
+ b256[j3] = carry % 256;
3201
+ carry = Math.floor(carry / 256);
3202
+ }
3203
+ length = k4;
3204
+ }
3205
+ let it = size - length;
3206
+ while (it < size && b256[it] === 0) it++;
3207
+ const out = new Uint8Array(zeros + (size - it));
3208
+ let j2 = zeros;
3209
+ while (it < size) {
3210
+ out[j2++] = b256[it++];
3211
+ }
3212
+ return out;
3213
+ }
3214
+ function checkCritShape(record, decodedTopKeys, errors) {
3215
+ const invalid = /* @__PURE__ */ new Set();
3216
+ if (!Array.isArray(record.crit)) return invalid;
3217
+ if (record.crit.length === 0) {
3218
+ errors.push(
3219
+ issue("SCHEMA_TYPE_MISMATCH", ["crit"], "crit[] must carry at least one entry when present")
3220
+ );
3221
+ return invalid;
3222
+ }
3223
+ const seen = /* @__PURE__ */ new Set();
3224
+ for (let i = 0; i < record.crit.length; i++) {
3225
+ const critName = record.crit[i];
3226
+ let reason = null;
3227
+ if (TOP_LEVEL_BASE_KEYS.has(critName)) {
3228
+ reason = `'${critName}' is a base key and MUST NOT appear in crit[]`;
3229
+ } else if (!isExtensionKey(critName)) {
3230
+ reason = `'${critName}' does not match the extension-key regex (^x-.+ or ^[a-z]+-.+)`;
3231
+ } else if (!decodedTopKeys.has(critName)) {
3232
+ reason = `'${critName}' is named in crit but absent from the record map`;
3233
+ } else if (seen.has(critName)) {
3234
+ reason = `'${critName}' appears more than once in crit[]`;
3235
+ }
3236
+ seen.add(critName);
3237
+ if (reason !== null) {
3238
+ invalid.add(i);
3239
+ errors.push(issue("CRIT_SHAPE_INVALID", ["crit", i], reason));
3240
+ }
3241
+ }
3242
+ return invalid;
3243
+ }
3244
+ function topLevelKeysOf(decoded) {
3245
+ if (decoded === null || typeof decoded !== "object") return /* @__PURE__ */ new Set();
3246
+ if (decoded instanceof Map) {
3247
+ const out = /* @__PURE__ */ new Set();
3248
+ for (const k4 of decoded.keys()) {
3249
+ if (typeof k4 === "string") out.add(k4);
3250
+ }
3251
+ return out;
3252
+ }
3253
+ return new Set(Object.keys(decoded));
3254
+ }
3255
+ function issue(code, path, message) {
3256
+ return { code, path, message, severity: SEVERITY[code] };
3257
+ }
3258
+ function compareIssuePath(a4, b5) {
3259
+ return a4.path.join(".").localeCompare(b5.path.join("."));
3260
+ }
3261
+ function valueAtPath(root, path) {
3262
+ let cur = root;
3263
+ for (const seg of path) {
3264
+ if (cur === null || cur === void 0) return void 0;
3265
+ if (cur instanceof Map) {
3266
+ cur = cur.get(seg);
3267
+ continue;
3268
+ }
3269
+ if (typeof cur !== "object") return void 0;
3270
+ cur = cur[seg];
3271
+ }
3272
+ return cur;
3273
+ }
3274
+ /*! Bundled license information:
3275
+
3276
+ @noble/ed25519/index.js:
3277
+ (*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
3278
+ */
3279
+
3280
+ exports.validateCidProfile = validateCidProfile;
3281
+ exports.validatePoeRecord = validatePoeRecord;
3282
+ //# sourceMappingURL=validator.cjs.map
3283
+ //# sourceMappingURL=validator.cjs.map