@tinycloud/sdk-core 2.7.0-beta.2 → 2.7.0-beta.4

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.
@@ -1,21 +1,33 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
9
  var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
10
+ for (var name2 in all)
11
+ __defProp(target, name2, { get: all[name2], enumerable: true });
9
12
  };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
+ var __copyProps = (to, from3, except, desc) => {
14
+ if (from3 && typeof from3 === "object" || typeof from3 === "function") {
15
+ for (let key of __getOwnPropNames(from3))
13
16
  if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ __defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
15
18
  }
16
19
  return to;
17
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
18
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
31
 
20
32
  // src/requester/index.ts
21
33
  var requester_exports = {};
@@ -41,16 +53,921 @@ __export(requester_exports, {
41
53
  module.exports = __toCommonJS(requester_exports);
42
54
  var import_viem4 = require("viem");
43
55
  var import_blake3 = require("@noble/hashes/blake3");
44
- var import_cid = require("multiformats/cid");
45
- var import_digest = require("multiformats/hashes/digest");
56
+
57
+ // ../../node_modules/multiformats/dist/src/bases/base32.js
58
+ var base32_exports = {};
59
+ __export(base32_exports, {
60
+ base32: () => base32,
61
+ base32hex: () => base32hex,
62
+ base32hexpad: () => base32hexpad,
63
+ base32hexpadupper: () => base32hexpadupper,
64
+ base32hexupper: () => base32hexupper,
65
+ base32pad: () => base32pad,
66
+ base32padupper: () => base32padupper,
67
+ base32upper: () => base32upper,
68
+ base32z: () => base32z
69
+ });
70
+
71
+ // ../../node_modules/multiformats/dist/src/bytes.js
72
+ var empty = new Uint8Array(0);
73
+ function equals(aa, bb) {
74
+ if (aa === bb) {
75
+ return true;
76
+ }
77
+ if (aa.byteLength !== bb.byteLength) {
78
+ return false;
79
+ }
80
+ for (let ii = 0; ii < aa.byteLength; ii++) {
81
+ if (aa[ii] !== bb[ii]) {
82
+ return false;
83
+ }
84
+ }
85
+ return true;
86
+ }
87
+ function coerce(o) {
88
+ if (o instanceof Uint8Array && o.constructor.name === "Uint8Array") {
89
+ return o;
90
+ }
91
+ if (o instanceof ArrayBuffer) {
92
+ return new Uint8Array(o);
93
+ }
94
+ if (ArrayBuffer.isView(o)) {
95
+ return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
96
+ }
97
+ throw new Error("Unknown type, must be binary type");
98
+ }
99
+ function fromString(str) {
100
+ return new TextEncoder().encode(str);
101
+ }
102
+ function toString(b) {
103
+ return new TextDecoder().decode(b);
104
+ }
105
+
106
+ // ../../node_modules/multiformats/dist/src/vendor/base-x.js
107
+ function base(ALPHABET, name2) {
108
+ if (ALPHABET.length >= 255) {
109
+ throw new TypeError("Alphabet too long");
110
+ }
111
+ var BASE_MAP = new Uint8Array(256);
112
+ for (var j = 0; j < BASE_MAP.length; j++) {
113
+ BASE_MAP[j] = 255;
114
+ }
115
+ for (var i = 0; i < ALPHABET.length; i++) {
116
+ var x = ALPHABET.charAt(i);
117
+ var xc = x.charCodeAt(0);
118
+ if (BASE_MAP[xc] !== 255) {
119
+ throw new TypeError(x + " is ambiguous");
120
+ }
121
+ BASE_MAP[xc] = i;
122
+ }
123
+ var BASE = ALPHABET.length;
124
+ var LEADER = ALPHABET.charAt(0);
125
+ var FACTOR = Math.log(BASE) / Math.log(256);
126
+ var iFACTOR = Math.log(256) / Math.log(BASE);
127
+ function encode5(source) {
128
+ if (source instanceof Uint8Array)
129
+ ;
130
+ else if (ArrayBuffer.isView(source)) {
131
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
132
+ } else if (Array.isArray(source)) {
133
+ source = Uint8Array.from(source);
134
+ }
135
+ if (!(source instanceof Uint8Array)) {
136
+ throw new TypeError("Expected Uint8Array");
137
+ }
138
+ if (source.length === 0) {
139
+ return "";
140
+ }
141
+ var zeroes = 0;
142
+ var length2 = 0;
143
+ var pbegin = 0;
144
+ var pend = source.length;
145
+ while (pbegin !== pend && source[pbegin] === 0) {
146
+ pbegin++;
147
+ zeroes++;
148
+ }
149
+ var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
150
+ var b58 = new Uint8Array(size);
151
+ while (pbegin !== pend) {
152
+ var carry = source[pbegin];
153
+ var i2 = 0;
154
+ for (var it1 = size - 1; (carry !== 0 || i2 < length2) && it1 !== -1; it1--, i2++) {
155
+ carry += 256 * b58[it1] >>> 0;
156
+ b58[it1] = carry % BASE >>> 0;
157
+ carry = carry / BASE >>> 0;
158
+ }
159
+ if (carry !== 0) {
160
+ throw new Error("Non-zero carry");
161
+ }
162
+ length2 = i2;
163
+ pbegin++;
164
+ }
165
+ var it2 = size - length2;
166
+ while (it2 !== size && b58[it2] === 0) {
167
+ it2++;
168
+ }
169
+ var str = LEADER.repeat(zeroes);
170
+ for (; it2 < size; ++it2) {
171
+ str += ALPHABET.charAt(b58[it2]);
172
+ }
173
+ return str;
174
+ }
175
+ function decodeUnsafe(source) {
176
+ if (typeof source !== "string") {
177
+ throw new TypeError("Expected String");
178
+ }
179
+ if (source.length === 0) {
180
+ return new Uint8Array();
181
+ }
182
+ var psz = 0;
183
+ if (source[psz] === " ") {
184
+ return;
185
+ }
186
+ var zeroes = 0;
187
+ var length2 = 0;
188
+ while (source[psz] === LEADER) {
189
+ zeroes++;
190
+ psz++;
191
+ }
192
+ var size = (source.length - psz) * FACTOR + 1 >>> 0;
193
+ var b256 = new Uint8Array(size);
194
+ while (source[psz]) {
195
+ var carry = BASE_MAP[source.charCodeAt(psz)];
196
+ if (carry === 255) {
197
+ return;
198
+ }
199
+ var i2 = 0;
200
+ for (var it3 = size - 1; (carry !== 0 || i2 < length2) && it3 !== -1; it3--, i2++) {
201
+ carry += BASE * b256[it3] >>> 0;
202
+ b256[it3] = carry % 256 >>> 0;
203
+ carry = carry / 256 >>> 0;
204
+ }
205
+ if (carry !== 0) {
206
+ throw new Error("Non-zero carry");
207
+ }
208
+ length2 = i2;
209
+ psz++;
210
+ }
211
+ if (source[psz] === " ") {
212
+ return;
213
+ }
214
+ var it4 = size - length2;
215
+ while (it4 !== size && b256[it4] === 0) {
216
+ it4++;
217
+ }
218
+ var vch = new Uint8Array(zeroes + (size - it4));
219
+ var j2 = zeroes;
220
+ while (it4 !== size) {
221
+ vch[j2++] = b256[it4++];
222
+ }
223
+ return vch;
224
+ }
225
+ function decode6(string) {
226
+ var buffer = decodeUnsafe(string);
227
+ if (buffer) {
228
+ return buffer;
229
+ }
230
+ throw new Error(`Non-${name2} character`);
231
+ }
232
+ return {
233
+ encode: encode5,
234
+ decodeUnsafe,
235
+ decode: decode6
236
+ };
237
+ }
238
+ var src = base;
239
+ var _brrp__multiformats_scope_baseX = src;
240
+ var base_x_default = _brrp__multiformats_scope_baseX;
241
+
242
+ // ../../node_modules/multiformats/dist/src/bases/base.js
243
+ var Encoder = class {
244
+ constructor(name2, prefix, baseEncode) {
245
+ __publicField(this, "name");
246
+ __publicField(this, "prefix");
247
+ __publicField(this, "baseEncode");
248
+ this.name = name2;
249
+ this.prefix = prefix;
250
+ this.baseEncode = baseEncode;
251
+ }
252
+ encode(bytes) {
253
+ if (bytes instanceof Uint8Array) {
254
+ return `${this.prefix}${this.baseEncode(bytes)}`;
255
+ } else {
256
+ throw Error("Unknown type, must be binary type");
257
+ }
258
+ }
259
+ };
260
+ var Decoder = class {
261
+ constructor(name2, prefix, baseDecode) {
262
+ __publicField(this, "name");
263
+ __publicField(this, "prefix");
264
+ __publicField(this, "baseDecode");
265
+ __publicField(this, "prefixCodePoint");
266
+ this.name = name2;
267
+ this.prefix = prefix;
268
+ const prefixCodePoint = prefix.codePointAt(0);
269
+ if (prefixCodePoint === void 0) {
270
+ throw new Error("Invalid prefix character");
271
+ }
272
+ this.prefixCodePoint = prefixCodePoint;
273
+ this.baseDecode = baseDecode;
274
+ }
275
+ decode(text) {
276
+ if (typeof text === "string") {
277
+ if (text.codePointAt(0) !== this.prefixCodePoint) {
278
+ throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
279
+ }
280
+ return this.baseDecode(text.slice(this.prefix.length));
281
+ } else {
282
+ throw Error("Can only multibase decode strings");
283
+ }
284
+ }
285
+ or(decoder) {
286
+ return or(this, decoder);
287
+ }
288
+ };
289
+ var ComposedDecoder = class {
290
+ constructor(decoders) {
291
+ __publicField(this, "decoders");
292
+ this.decoders = decoders;
293
+ }
294
+ or(decoder) {
295
+ return or(this, decoder);
296
+ }
297
+ decode(input) {
298
+ const prefix = input[0];
299
+ const decoder = this.decoders[prefix];
300
+ if (decoder != null) {
301
+ return decoder.decode(input);
302
+ } else {
303
+ throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
304
+ }
305
+ }
306
+ };
307
+ function or(left, right) {
308
+ return new ComposedDecoder({
309
+ ...left.decoders ?? { [left.prefix]: left },
310
+ ...right.decoders ?? { [right.prefix]: right }
311
+ });
312
+ }
313
+ var Codec = class {
314
+ constructor(name2, prefix, baseEncode, baseDecode) {
315
+ __publicField(this, "name");
316
+ __publicField(this, "prefix");
317
+ __publicField(this, "baseEncode");
318
+ __publicField(this, "baseDecode");
319
+ __publicField(this, "encoder");
320
+ __publicField(this, "decoder");
321
+ this.name = name2;
322
+ this.prefix = prefix;
323
+ this.baseEncode = baseEncode;
324
+ this.baseDecode = baseDecode;
325
+ this.encoder = new Encoder(name2, prefix, baseEncode);
326
+ this.decoder = new Decoder(name2, prefix, baseDecode);
327
+ }
328
+ encode(input) {
329
+ return this.encoder.encode(input);
330
+ }
331
+ decode(input) {
332
+ return this.decoder.decode(input);
333
+ }
334
+ };
335
+ function from({ name: name2, prefix, encode: encode5, decode: decode6 }) {
336
+ return new Codec(name2, prefix, encode5, decode6);
337
+ }
338
+ function baseX({ name: name2, prefix, alphabet: alphabet2 }) {
339
+ const { encode: encode5, decode: decode6 } = base_x_default(alphabet2, name2);
340
+ return from({
341
+ prefix,
342
+ name: name2,
343
+ encode: encode5,
344
+ decode: (text) => coerce(decode6(text))
345
+ });
346
+ }
347
+ function decode(string, alphabetIdx, bitsPerChar, name2) {
348
+ let end = string.length;
349
+ while (string[end - 1] === "=") {
350
+ --end;
351
+ }
352
+ const out = new Uint8Array(end * bitsPerChar / 8 | 0);
353
+ let bits = 0;
354
+ let buffer = 0;
355
+ let written = 0;
356
+ for (let i = 0; i < end; ++i) {
357
+ const value = alphabetIdx[string[i]];
358
+ if (value === void 0) {
359
+ throw new SyntaxError(`Non-${name2} character`);
360
+ }
361
+ buffer = buffer << bitsPerChar | value;
362
+ bits += bitsPerChar;
363
+ if (bits >= 8) {
364
+ bits -= 8;
365
+ out[written++] = 255 & buffer >> bits;
366
+ }
367
+ }
368
+ if (bits >= bitsPerChar || (255 & buffer << 8 - bits) !== 0) {
369
+ throw new SyntaxError("Unexpected end of data");
370
+ }
371
+ return out;
372
+ }
373
+ function encode(data, alphabet2, bitsPerChar) {
374
+ const pad = alphabet2[alphabet2.length - 1] === "=";
375
+ const mask = (1 << bitsPerChar) - 1;
376
+ let out = "";
377
+ let bits = 0;
378
+ let buffer = 0;
379
+ for (let i = 0; i < data.length; ++i) {
380
+ buffer = buffer << 8 | data[i];
381
+ bits += 8;
382
+ while (bits > bitsPerChar) {
383
+ bits -= bitsPerChar;
384
+ out += alphabet2[mask & buffer >> bits];
385
+ }
386
+ }
387
+ if (bits !== 0) {
388
+ out += alphabet2[mask & buffer << bitsPerChar - bits];
389
+ }
390
+ if (pad) {
391
+ while ((out.length * bitsPerChar & 7) !== 0) {
392
+ out += "=";
393
+ }
394
+ }
395
+ return out;
396
+ }
397
+ function createAlphabetIdx(alphabet2) {
398
+ const alphabetIdx = {};
399
+ for (let i = 0; i < alphabet2.length; ++i) {
400
+ alphabetIdx[alphabet2[i]] = i;
401
+ }
402
+ return alphabetIdx;
403
+ }
404
+ function rfc4648({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) {
405
+ const alphabetIdx = createAlphabetIdx(alphabet2);
406
+ return from({
407
+ prefix,
408
+ name: name2,
409
+ encode(input) {
410
+ return encode(input, alphabet2, bitsPerChar);
411
+ },
412
+ decode(input) {
413
+ return decode(input, alphabetIdx, bitsPerChar, name2);
414
+ }
415
+ });
416
+ }
417
+
418
+ // ../../node_modules/multiformats/dist/src/bases/base32.js
419
+ var base32 = rfc4648({
420
+ prefix: "b",
421
+ name: "base32",
422
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567",
423
+ bitsPerChar: 5
424
+ });
425
+ var base32upper = rfc4648({
426
+ prefix: "B",
427
+ name: "base32upper",
428
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
429
+ bitsPerChar: 5
430
+ });
431
+ var base32pad = rfc4648({
432
+ prefix: "c",
433
+ name: "base32pad",
434
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
435
+ bitsPerChar: 5
436
+ });
437
+ var base32padupper = rfc4648({
438
+ prefix: "C",
439
+ name: "base32padupper",
440
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
441
+ bitsPerChar: 5
442
+ });
443
+ var base32hex = rfc4648({
444
+ prefix: "v",
445
+ name: "base32hex",
446
+ alphabet: "0123456789abcdefghijklmnopqrstuv",
447
+ bitsPerChar: 5
448
+ });
449
+ var base32hexupper = rfc4648({
450
+ prefix: "V",
451
+ name: "base32hexupper",
452
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
453
+ bitsPerChar: 5
454
+ });
455
+ var base32hexpad = rfc4648({
456
+ prefix: "t",
457
+ name: "base32hexpad",
458
+ alphabet: "0123456789abcdefghijklmnopqrstuv=",
459
+ bitsPerChar: 5
460
+ });
461
+ var base32hexpadupper = rfc4648({
462
+ prefix: "T",
463
+ name: "base32hexpadupper",
464
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
465
+ bitsPerChar: 5
466
+ });
467
+ var base32z = rfc4648({
468
+ prefix: "h",
469
+ name: "base32z",
470
+ alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
471
+ bitsPerChar: 5
472
+ });
473
+
474
+ // ../../node_modules/multiformats/dist/src/bases/base36.js
475
+ var base36_exports = {};
476
+ __export(base36_exports, {
477
+ base36: () => base36,
478
+ base36upper: () => base36upper
479
+ });
480
+ var base36 = baseX({
481
+ prefix: "k",
482
+ name: "base36",
483
+ alphabet: "0123456789abcdefghijklmnopqrstuvwxyz"
484
+ });
485
+ var base36upper = baseX({
486
+ prefix: "K",
487
+ name: "base36upper",
488
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
489
+ });
490
+
491
+ // ../../node_modules/multiformats/dist/src/bases/base58.js
492
+ var base58_exports = {};
493
+ __export(base58_exports, {
494
+ base58btc: () => base58btc,
495
+ base58flickr: () => base58flickr
496
+ });
497
+ var base58btc = baseX({
498
+ name: "base58btc",
499
+ prefix: "z",
500
+ alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
501
+ });
502
+ var base58flickr = baseX({
503
+ name: "base58flickr",
504
+ prefix: "Z",
505
+ alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
506
+ });
507
+
508
+ // ../../node_modules/multiformats/dist/src/vendor/varint.js
509
+ var encode_1 = encode2;
510
+ var MSB = 128;
511
+ var REST = 127;
512
+ var MSBALL = ~REST;
513
+ var INT = Math.pow(2, 31);
514
+ function encode2(num, out, offset) {
515
+ out = out || [];
516
+ offset = offset || 0;
517
+ var oldOffset = offset;
518
+ while (num >= INT) {
519
+ out[offset++] = num & 255 | MSB;
520
+ num /= 128;
521
+ }
522
+ while (num & MSBALL) {
523
+ out[offset++] = num & 255 | MSB;
524
+ num >>>= 7;
525
+ }
526
+ out[offset] = num | 0;
527
+ encode2.bytes = offset - oldOffset + 1;
528
+ return out;
529
+ }
530
+ var decode2 = read;
531
+ var MSB$1 = 128;
532
+ var REST$1 = 127;
533
+ function read(buf, offset) {
534
+ var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
535
+ do {
536
+ if (counter >= l) {
537
+ read.bytes = 0;
538
+ throw new RangeError("Could not decode varint");
539
+ }
540
+ b = buf[counter++];
541
+ res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift);
542
+ shift += 7;
543
+ } while (b >= MSB$1);
544
+ read.bytes = counter - offset;
545
+ return res;
546
+ }
547
+ var N1 = Math.pow(2, 7);
548
+ var N2 = Math.pow(2, 14);
549
+ var N3 = Math.pow(2, 21);
550
+ var N4 = Math.pow(2, 28);
551
+ var N5 = Math.pow(2, 35);
552
+ var N6 = Math.pow(2, 42);
553
+ var N7 = Math.pow(2, 49);
554
+ var N8 = Math.pow(2, 56);
555
+ var N9 = Math.pow(2, 63);
556
+ var length = function(value) {
557
+ return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
558
+ };
559
+ var varint = {
560
+ encode: encode_1,
561
+ decode: decode2,
562
+ encodingLength: length
563
+ };
564
+ var _brrp_varint = varint;
565
+ var varint_default = _brrp_varint;
566
+
567
+ // ../../node_modules/multiformats/dist/src/varint.js
568
+ function decode3(data, offset = 0) {
569
+ const code2 = varint_default.decode(data, offset);
570
+ return [code2, varint_default.decode.bytes];
571
+ }
572
+ function encodeTo(int, target, offset = 0) {
573
+ varint_default.encode(int, target, offset);
574
+ return target;
575
+ }
576
+ function encodingLength(int) {
577
+ return varint_default.encodingLength(int);
578
+ }
579
+
580
+ // ../../node_modules/multiformats/dist/src/hashes/digest.js
581
+ function create(code2, digest2) {
582
+ const size = digest2.byteLength;
583
+ const sizeOffset = encodingLength(code2);
584
+ const digestOffset = sizeOffset + encodingLength(size);
585
+ const bytes = new Uint8Array(digestOffset + size);
586
+ encodeTo(code2, bytes, 0);
587
+ encodeTo(size, bytes, sizeOffset);
588
+ bytes.set(digest2, digestOffset);
589
+ return new Digest(code2, size, digest2, bytes);
590
+ }
591
+ function decode4(multihash) {
592
+ const bytes = coerce(multihash);
593
+ const [code2, sizeOffset] = decode3(bytes);
594
+ const [size, digestOffset] = decode3(bytes.subarray(sizeOffset));
595
+ const digest2 = bytes.subarray(sizeOffset + digestOffset);
596
+ if (digest2.byteLength !== size) {
597
+ throw new Error("Incorrect length");
598
+ }
599
+ return new Digest(code2, size, digest2, bytes);
600
+ }
601
+ function equals2(a, b) {
602
+ if (a === b) {
603
+ return true;
604
+ } else {
605
+ const data = b;
606
+ return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equals(a.bytes, data.bytes);
607
+ }
608
+ }
609
+ var Digest = class {
610
+ /**
611
+ * Creates a multihash digest.
612
+ */
613
+ constructor(code2, size, digest2, bytes) {
614
+ __publicField(this, "code");
615
+ __publicField(this, "size");
616
+ __publicField(this, "digest");
617
+ __publicField(this, "bytes");
618
+ this.code = code2;
619
+ this.size = size;
620
+ this.digest = digest2;
621
+ this.bytes = bytes;
622
+ }
623
+ };
624
+
625
+ // ../../node_modules/multiformats/dist/src/cid.js
626
+ function format(link, base3) {
627
+ const { bytes, version } = link;
628
+ switch (version) {
629
+ case 0:
630
+ return toStringV0(bytes, baseCache(link), base3 ?? base58btc.encoder);
631
+ default:
632
+ return toStringV1(bytes, baseCache(link), base3 ?? base32.encoder);
633
+ }
634
+ }
635
+ var cache = /* @__PURE__ */ new WeakMap();
636
+ function baseCache(cid) {
637
+ const baseCache2 = cache.get(cid);
638
+ if (baseCache2 == null) {
639
+ const baseCache3 = /* @__PURE__ */ new Map();
640
+ cache.set(cid, baseCache3);
641
+ return baseCache3;
642
+ }
643
+ return baseCache2;
644
+ }
645
+ var _a;
646
+ var CID = class _CID {
647
+ /**
648
+ * @param version - Version of the CID
649
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
650
+ * @param multihash - (Multi)hash of the of the content.
651
+ */
652
+ constructor(version, code2, multihash, bytes) {
653
+ __publicField(this, "code");
654
+ __publicField(this, "version");
655
+ __publicField(this, "multihash");
656
+ __publicField(this, "bytes");
657
+ __publicField(this, "/");
658
+ __publicField(this, _a, "CID");
659
+ this.code = code2;
660
+ this.version = version;
661
+ this.multihash = multihash;
662
+ this.bytes = bytes;
663
+ this["/"] = bytes;
664
+ }
665
+ /**
666
+ * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
667
+ * please either use `CID.asCID(cid)` or switch to new signalling mechanism
668
+ *
669
+ * @deprecated
670
+ */
671
+ get asCID() {
672
+ return this;
673
+ }
674
+ // ArrayBufferView
675
+ get byteOffset() {
676
+ return this.bytes.byteOffset;
677
+ }
678
+ // ArrayBufferView
679
+ get byteLength() {
680
+ return this.bytes.byteLength;
681
+ }
682
+ toV0() {
683
+ switch (this.version) {
684
+ case 0: {
685
+ return this;
686
+ }
687
+ case 1: {
688
+ const { code: code2, multihash } = this;
689
+ if (code2 !== DAG_PB_CODE) {
690
+ throw new Error("Cannot convert a non dag-pb CID to CIDv0");
691
+ }
692
+ if (multihash.code !== SHA_256_CODE) {
693
+ throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
694
+ }
695
+ return _CID.createV0(multihash);
696
+ }
697
+ default: {
698
+ throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
699
+ }
700
+ }
701
+ }
702
+ toV1() {
703
+ switch (this.version) {
704
+ case 0: {
705
+ const { code: code2, digest: digest2 } = this.multihash;
706
+ const multihash = create(code2, digest2);
707
+ return _CID.createV1(this.code, multihash);
708
+ }
709
+ case 1: {
710
+ return this;
711
+ }
712
+ default: {
713
+ throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
714
+ }
715
+ }
716
+ }
717
+ equals(other) {
718
+ return _CID.equals(this, other);
719
+ }
720
+ static equals(self, other) {
721
+ const unknown = other;
722
+ return unknown != null && self.code === unknown.code && self.version === unknown.version && equals2(self.multihash, unknown.multihash);
723
+ }
724
+ toString(base3) {
725
+ return format(this, base3);
726
+ }
727
+ toJSON() {
728
+ return { "/": format(this) };
729
+ }
730
+ link() {
731
+ return this;
732
+ }
733
+ // Legacy
734
+ [(_a = Symbol.toStringTag, /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom"))]() {
735
+ return `CID(${this.toString()})`;
736
+ }
737
+ /**
738
+ * Takes any input `value` and returns a `CID` instance if it was
739
+ * a `CID` otherwise returns `null`. If `value` is instanceof `CID`
740
+ * it will return value back. If `value` is not instance of this CID
741
+ * class, but is compatible CID it will return new instance of this
742
+ * `CID` class. Otherwise returns null.
743
+ *
744
+ * This allows two different incompatible versions of CID library to
745
+ * co-exist and interop as long as binary interface is compatible.
746
+ */
747
+ static asCID(input) {
748
+ if (input == null) {
749
+ return null;
750
+ }
751
+ const value = input;
752
+ if (value instanceof _CID) {
753
+ return value;
754
+ } else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) {
755
+ const { version, code: code2, multihash, bytes } = value;
756
+ return new _CID(version, code2, multihash, bytes ?? encodeCID(version, code2, multihash.bytes));
757
+ } else if (value[cidSymbol] === true) {
758
+ const { version, multihash, code: code2 } = value;
759
+ const digest2 = decode4(multihash);
760
+ return _CID.create(version, code2, digest2);
761
+ } else {
762
+ return null;
763
+ }
764
+ }
765
+ /**
766
+ * @param version - Version of the CID
767
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
768
+ * @param digest - (Multi)hash of the of the content.
769
+ */
770
+ static create(version, code2, digest2) {
771
+ if (typeof code2 !== "number") {
772
+ throw new Error("String codecs are no longer supported");
773
+ }
774
+ if (!(digest2.bytes instanceof Uint8Array)) {
775
+ throw new Error("Invalid digest");
776
+ }
777
+ switch (version) {
778
+ case 0: {
779
+ if (code2 !== DAG_PB_CODE) {
780
+ throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
781
+ } else {
782
+ return new _CID(version, code2, digest2, digest2.bytes);
783
+ }
784
+ }
785
+ case 1: {
786
+ const bytes = encodeCID(version, code2, digest2.bytes);
787
+ return new _CID(version, code2, digest2, bytes);
788
+ }
789
+ default: {
790
+ throw new Error("Invalid version");
791
+ }
792
+ }
793
+ }
794
+ /**
795
+ * Simplified version of `create` for CIDv0.
796
+ */
797
+ static createV0(digest2) {
798
+ return _CID.create(0, DAG_PB_CODE, digest2);
799
+ }
800
+ /**
801
+ * Simplified version of `create` for CIDv1.
802
+ *
803
+ * @param code - Content encoding format code.
804
+ * @param digest - Multihash of the content.
805
+ */
806
+ static createV1(code2, digest2) {
807
+ return _CID.create(1, code2, digest2);
808
+ }
809
+ /**
810
+ * Decoded a CID from its binary representation. The byte array must contain
811
+ * only the CID with no additional bytes.
812
+ *
813
+ * An error will be thrown if the bytes provided do not contain a valid
814
+ * binary representation of a CID.
815
+ */
816
+ static decode(bytes) {
817
+ const [cid, remainder] = _CID.decodeFirst(bytes);
818
+ if (remainder.length !== 0) {
819
+ throw new Error("Incorrect length");
820
+ }
821
+ return cid;
822
+ }
823
+ /**
824
+ * Decoded a CID from its binary representation at the beginning of a byte
825
+ * array.
826
+ *
827
+ * Returns an array with the first element containing the CID and the second
828
+ * element containing the remainder of the original byte array. The remainder
829
+ * will be a zero-length byte array if the provided bytes only contained a
830
+ * binary CID representation.
831
+ */
832
+ static decodeFirst(bytes) {
833
+ const specs = _CID.inspectBytes(bytes);
834
+ const prefixSize = specs.size - specs.multihashSize;
835
+ const multihashBytes = coerce(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
836
+ if (multihashBytes.byteLength !== specs.multihashSize) {
837
+ throw new Error("Incorrect length");
838
+ }
839
+ const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
840
+ const digest2 = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
841
+ const cid = specs.version === 0 ? _CID.createV0(digest2) : _CID.createV1(specs.codec, digest2);
842
+ return [cid, bytes.subarray(specs.size)];
843
+ }
844
+ /**
845
+ * Inspect the initial bytes of a CID to determine its properties.
846
+ *
847
+ * Involves decoding up to 4 varints. Typically this will require only 4 to 6
848
+ * bytes but for larger multicodec code values and larger multihash digest
849
+ * lengths these varints can be quite large. It is recommended that at least
850
+ * 10 bytes be made available in the `initialBytes` argument for a complete
851
+ * inspection.
852
+ */
853
+ static inspectBytes(initialBytes) {
854
+ let offset = 0;
855
+ const next = () => {
856
+ const [i, length2] = decode3(initialBytes.subarray(offset));
857
+ offset += length2;
858
+ return i;
859
+ };
860
+ let version = next();
861
+ let codec = DAG_PB_CODE;
862
+ if (version === 18) {
863
+ version = 0;
864
+ offset = 0;
865
+ } else {
866
+ codec = next();
867
+ }
868
+ if (version !== 0 && version !== 1) {
869
+ throw new RangeError(`Invalid CID version ${version}`);
870
+ }
871
+ const prefixSize = offset;
872
+ const multihashCode = next();
873
+ const digestSize = next();
874
+ const size = offset + digestSize;
875
+ const multihashSize = size - prefixSize;
876
+ return { version, codec, multihashCode, digestSize, multihashSize, size };
877
+ }
878
+ /**
879
+ * Takes cid in a string representation and creates an instance. If `base`
880
+ * decoder is not provided will use a default from the configuration. It will
881
+ * throw an error if encoding of the CID is not compatible with supplied (or
882
+ * a default decoder).
883
+ */
884
+ static parse(source, base3) {
885
+ const [prefix, bytes] = parseCIDtoBytes(source, base3);
886
+ const cid = _CID.decode(bytes);
887
+ if (cid.version === 0 && source[0] !== "Q") {
888
+ throw Error("Version 0 CID string must not include multibase prefix");
889
+ }
890
+ baseCache(cid).set(prefix, source);
891
+ return cid;
892
+ }
893
+ };
894
+ function parseCIDtoBytes(source, base3) {
895
+ switch (source[0]) {
896
+ // CIDv0 is parsed differently
897
+ case "Q": {
898
+ const decoder = base3 ?? base58btc;
899
+ return [
900
+ base58btc.prefix,
901
+ decoder.decode(`${base58btc.prefix}${source}`)
902
+ ];
903
+ }
904
+ case base58btc.prefix: {
905
+ const decoder = base3 ?? base58btc;
906
+ return [base58btc.prefix, decoder.decode(source)];
907
+ }
908
+ case base32.prefix: {
909
+ const decoder = base3 ?? base32;
910
+ return [base32.prefix, decoder.decode(source)];
911
+ }
912
+ case base36.prefix: {
913
+ const decoder = base3 ?? base36;
914
+ return [base36.prefix, decoder.decode(source)];
915
+ }
916
+ default: {
917
+ if (base3 == null) {
918
+ throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");
919
+ }
920
+ return [source[0], base3.decode(source)];
921
+ }
922
+ }
923
+ }
924
+ function toStringV0(bytes, cache2, base3) {
925
+ const { prefix } = base3;
926
+ if (prefix !== base58btc.prefix) {
927
+ throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
928
+ }
929
+ const cid = cache2.get(prefix);
930
+ if (cid == null) {
931
+ const cid2 = base3.encode(bytes).slice(1);
932
+ cache2.set(prefix, cid2);
933
+ return cid2;
934
+ } else {
935
+ return cid;
936
+ }
937
+ }
938
+ function toStringV1(bytes, cache2, base3) {
939
+ const { prefix } = base3;
940
+ const cid = cache2.get(prefix);
941
+ if (cid == null) {
942
+ const cid2 = base3.encode(bytes);
943
+ cache2.set(prefix, cid2);
944
+ return cid2;
945
+ } else {
946
+ return cid;
947
+ }
948
+ }
949
+ var DAG_PB_CODE = 112;
950
+ var SHA_256_CODE = 18;
951
+ function encodeCID(version, code2, multihash) {
952
+ const codeOffset = encodingLength(version);
953
+ const hashOffset = codeOffset + encodingLength(code2);
954
+ const bytes = new Uint8Array(hashOffset + multihash.byteLength);
955
+ encodeTo(version, bytes, 0);
956
+ encodeTo(code2, bytes, codeOffset);
957
+ bytes.set(multihash, hashOffset);
958
+ return bytes;
959
+ }
960
+ var cidSymbol = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
961
+
962
+ // src/requester/index.ts
46
963
  var import_zod = require("zod");
47
964
 
48
965
  // src/policy/errors.ts
49
966
  var SignedObjectProfileError = class extends Error {
50
- constructor(code, message) {
967
+ constructor(code2, message) {
51
968
  super(message);
52
969
  this.name = "SignedObjectProfileError";
53
- this.code = code;
970
+ this.code = code2;
54
971
  }
55
972
  };
56
973
  var SignedObjectSchemaError = class extends SignedObjectProfileError {
@@ -239,35 +1156,33 @@ function assertNoSymbolKeys(input, path) {
239
1156
  );
240
1157
  }
241
1158
  }
242
- function isArrayIndexKey(key, length) {
1159
+ function isArrayIndexKey(key, length2) {
243
1160
  if (!/^(0|[1-9]\d*)$/.test(key)) {
244
1161
  return false;
245
1162
  }
246
1163
  const index = Number(key);
247
- return Number.isSafeInteger(index) && index >= 0 && index < length;
1164
+ return Number.isSafeInteger(index) && index >= 0 && index < length2;
248
1165
  }
249
1166
  function serializeObject(value) {
250
- const keys = Object.keys(value).sort(compareCodePoints);
1167
+ const keys = Object.keys(value).sort(compareUtf16CodeUnits);
251
1168
  const parts = keys.map((key) => `${JSON.stringify(key)}:${serialize(value[key])}`);
252
1169
  return `{${parts.join(",")}}`;
253
1170
  }
254
- function compareCodePoints(a, b) {
255
- const left = Array.from(a);
256
- const right = Array.from(b);
257
- const max = Math.min(left.length, right.length);
1171
+ function compareUtf16CodeUnits(a, b) {
1172
+ const max = Math.min(a.length, b.length);
258
1173
  for (let index = 0; index < max; index++) {
259
- const leftPoint = left[index].codePointAt(0) ?? 0;
260
- const rightPoint = right[index].codePointAt(0) ?? 0;
261
- if (leftPoint !== rightPoint) {
262
- return leftPoint - rightPoint;
1174
+ const leftCodeUnit = a.charCodeAt(index);
1175
+ const rightCodeUnit = b.charCodeAt(index);
1176
+ if (leftCodeUnit !== rightCodeUnit) {
1177
+ return leftCodeUnit - rightCodeUnit;
263
1178
  }
264
1179
  }
265
- return left.length - right.length;
1180
+ return a.length - b.length;
266
1181
  }
267
1182
  function assertUnicodeScalarString(value, path) {
268
1183
  for (let index = 0; index < value.length; index++) {
269
- const code = value.charCodeAt(index);
270
- if (code >= 55296 && code <= 56319) {
1184
+ const code2 = value.charCodeAt(index);
1185
+ if (code2 >= 55296 && code2 <= 56319) {
271
1186
  const next = value.charCodeAt(index + 1);
272
1187
  if (Number.isNaN(next) || next < 56320 || next > 57343) {
273
1188
  throw new SignedObjectCanonicalizationError(
@@ -277,7 +1192,7 @@ function assertUnicodeScalarString(value, path) {
277
1192
  index++;
278
1193
  continue;
279
1194
  }
280
- if (code >= 56320 && code <= 57343) {
1195
+ if (code2 >= 56320 && code2 <= 57343) {
281
1196
  throw new SignedObjectCanonicalizationError(
282
1197
  `${path} contains a lone low surrogate`
283
1198
  );
@@ -290,10 +1205,10 @@ var import_bootstrap = require("@tinycloud/bootstrap");
290
1205
  var import_viem = require("viem");
291
1206
  var textEncoder = new TextEncoder();
292
1207
  var PolicyCapabilityError = class extends Error {
293
- constructor(code, message) {
1208
+ constructor(code2, message) {
294
1209
  super(message);
295
1210
  this.name = "PolicyCapabilityError";
296
- this.code = code;
1211
+ this.code = code2;
297
1212
  }
298
1213
  };
299
1214
  var objectHasOwn2 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
@@ -419,23 +1334,23 @@ function assertExactKeys(object, allowed, path) {
419
1334
  }
420
1335
  }
421
1336
  }
422
- function requiredValue(object, key, path, code) {
1337
+ function requiredValue(object, key, path, code2) {
423
1338
  if (!hasOwn(object, key)) {
424
- throw new PolicyCapabilityError(code, `${path}.${key} is required`);
1339
+ throw new PolicyCapabilityError(code2, `${path}.${key} is required`);
425
1340
  }
426
1341
  return object[key];
427
1342
  }
428
- function requiredString(object, key, path, code) {
429
- const value = requiredValue(object, key, path, code);
1343
+ function requiredString(object, key, path, code2) {
1344
+ const value = requiredValue(object, key, path, code2);
430
1345
  if (typeof value !== "string" || value.length === 0) {
431
- throw new PolicyCapabilityError(code, `${path}.${key} must be a non-empty string`);
1346
+ throw new PolicyCapabilityError(code2, `${path}.${key} must be a non-empty string`);
432
1347
  }
433
1348
  return value;
434
1349
  }
435
- function requiredArray(object, key, path, code) {
436
- const value = requiredValue(object, key, path, code);
1350
+ function requiredArray(object, key, path, code2) {
1351
+ const value = requiredValue(object, key, path, code2);
437
1352
  if (!Array.isArray(value)) {
438
- throw new PolicyCapabilityError(code, `${path}.${key} must be an array`);
1353
+ throw new PolicyCapabilityError(code2, `${path}.${key} must be an array`);
439
1354
  }
440
1355
  return value;
441
1356
  }
@@ -666,7 +1581,248 @@ function hasOwn(object, key) {
666
1581
 
667
1582
  // src/policy/signed-object.ts
668
1583
  var import_ed25519 = require("@noble/curves/ed25519");
669
- var import_basics = require("multiformats/basics");
1584
+
1585
+ // ../../node_modules/multiformats/dist/src/bases/base10.js
1586
+ var base10_exports = {};
1587
+ __export(base10_exports, {
1588
+ base10: () => base10
1589
+ });
1590
+ var base10 = baseX({
1591
+ prefix: "9",
1592
+ name: "base10",
1593
+ alphabet: "0123456789"
1594
+ });
1595
+
1596
+ // ../../node_modules/multiformats/dist/src/bases/base16.js
1597
+ var base16_exports = {};
1598
+ __export(base16_exports, {
1599
+ base16: () => base16,
1600
+ base16upper: () => base16upper
1601
+ });
1602
+ var base16 = rfc4648({
1603
+ prefix: "f",
1604
+ name: "base16",
1605
+ alphabet: "0123456789abcdef",
1606
+ bitsPerChar: 4
1607
+ });
1608
+ var base16upper = rfc4648({
1609
+ prefix: "F",
1610
+ name: "base16upper",
1611
+ alphabet: "0123456789ABCDEF",
1612
+ bitsPerChar: 4
1613
+ });
1614
+
1615
+ // ../../node_modules/multiformats/dist/src/bases/base2.js
1616
+ var base2_exports = {};
1617
+ __export(base2_exports, {
1618
+ base2: () => base2
1619
+ });
1620
+ var base2 = rfc4648({
1621
+ prefix: "0",
1622
+ name: "base2",
1623
+ alphabet: "01",
1624
+ bitsPerChar: 1
1625
+ });
1626
+
1627
+ // ../../node_modules/multiformats/dist/src/bases/base256emoji.js
1628
+ var base256emoji_exports = {};
1629
+ __export(base256emoji_exports, {
1630
+ base256emoji: () => base256emoji
1631
+ });
1632
+ var alphabet = Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}");
1633
+ var alphabetBytesToChars = alphabet.reduce((p, c, i) => {
1634
+ p[i] = c;
1635
+ return p;
1636
+ }, []);
1637
+ var alphabetCharsToBytes = alphabet.reduce((p, c, i) => {
1638
+ const codePoint = c.codePointAt(0);
1639
+ if (codePoint == null) {
1640
+ throw new Error(`Invalid character: ${c}`);
1641
+ }
1642
+ p[codePoint] = i;
1643
+ return p;
1644
+ }, []);
1645
+ function encode3(data) {
1646
+ return data.reduce((p, c) => {
1647
+ p += alphabetBytesToChars[c];
1648
+ return p;
1649
+ }, "");
1650
+ }
1651
+ function decode5(str) {
1652
+ const byts = [];
1653
+ for (const char of str) {
1654
+ const codePoint = char.codePointAt(0);
1655
+ if (codePoint == null) {
1656
+ throw new Error(`Invalid character: ${char}`);
1657
+ }
1658
+ const byt = alphabetCharsToBytes[codePoint];
1659
+ if (byt == null) {
1660
+ throw new Error(`Non-base256emoji character: ${char}`);
1661
+ }
1662
+ byts.push(byt);
1663
+ }
1664
+ return new Uint8Array(byts);
1665
+ }
1666
+ var base256emoji = from({
1667
+ prefix: "\u{1F680}",
1668
+ name: "base256emoji",
1669
+ encode: encode3,
1670
+ decode: decode5
1671
+ });
1672
+
1673
+ // ../../node_modules/multiformats/dist/src/bases/base64.js
1674
+ var base64_exports = {};
1675
+ __export(base64_exports, {
1676
+ base64: () => base64,
1677
+ base64pad: () => base64pad,
1678
+ base64url: () => base64url,
1679
+ base64urlpad: () => base64urlpad
1680
+ });
1681
+ var base64 = rfc4648({
1682
+ prefix: "m",
1683
+ name: "base64",
1684
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
1685
+ bitsPerChar: 6
1686
+ });
1687
+ var base64pad = rfc4648({
1688
+ prefix: "M",
1689
+ name: "base64pad",
1690
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
1691
+ bitsPerChar: 6
1692
+ });
1693
+ var base64url = rfc4648({
1694
+ prefix: "u",
1695
+ name: "base64url",
1696
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
1697
+ bitsPerChar: 6
1698
+ });
1699
+ var base64urlpad = rfc4648({
1700
+ prefix: "U",
1701
+ name: "base64urlpad",
1702
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
1703
+ bitsPerChar: 6
1704
+ });
1705
+
1706
+ // ../../node_modules/multiformats/dist/src/bases/base8.js
1707
+ var base8_exports = {};
1708
+ __export(base8_exports, {
1709
+ base8: () => base8
1710
+ });
1711
+ var base8 = rfc4648({
1712
+ prefix: "7",
1713
+ name: "base8",
1714
+ alphabet: "01234567",
1715
+ bitsPerChar: 3
1716
+ });
1717
+
1718
+ // ../../node_modules/multiformats/dist/src/bases/identity.js
1719
+ var identity_exports = {};
1720
+ __export(identity_exports, {
1721
+ identity: () => identity
1722
+ });
1723
+ var identity = from({
1724
+ prefix: "\0",
1725
+ name: "identity",
1726
+ encode: (buf) => toString(buf),
1727
+ decode: (str) => fromString(str)
1728
+ });
1729
+
1730
+ // ../../node_modules/multiformats/dist/src/codecs/json.js
1731
+ var textEncoder2 = new TextEncoder();
1732
+ var textDecoder = new TextDecoder();
1733
+
1734
+ // ../../node_modules/multiformats/dist/src/hashes/identity.js
1735
+ var identity_exports2 = {};
1736
+ __export(identity_exports2, {
1737
+ identity: () => identity2
1738
+ });
1739
+ var code = 0;
1740
+ var name = "identity";
1741
+ var encode4 = coerce;
1742
+ function digest(input, options) {
1743
+ if (options?.truncate != null && options.truncate !== input.byteLength) {
1744
+ if (options.truncate < 0 || options.truncate > input.byteLength) {
1745
+ throw new Error(`Invalid truncate option, must be less than or equal to ${input.byteLength}`);
1746
+ }
1747
+ input = input.subarray(0, options.truncate);
1748
+ }
1749
+ return create(code, encode4(input));
1750
+ }
1751
+ var identity2 = { code, name, encode: encode4, digest };
1752
+
1753
+ // ../../node_modules/multiformats/dist/src/hashes/sha2.js
1754
+ var sha2_exports = {};
1755
+ __export(sha2_exports, {
1756
+ sha256: () => sha2562,
1757
+ sha512: () => sha512
1758
+ });
1759
+ var import_crypto = __toESM(require("crypto"), 1);
1760
+
1761
+ // ../../node_modules/multiformats/dist/src/hashes/hasher.js
1762
+ var DEFAULT_MIN_DIGEST_LENGTH = 20;
1763
+ function from2({ name: name2, code: code2, encode: encode5, minDigestLength, maxDigestLength }) {
1764
+ return new Hasher(name2, code2, encode5, minDigestLength, maxDigestLength);
1765
+ }
1766
+ var Hasher = class {
1767
+ constructor(name2, code2, encode5, minDigestLength, maxDigestLength) {
1768
+ __publicField(this, "name");
1769
+ __publicField(this, "code");
1770
+ __publicField(this, "encode");
1771
+ __publicField(this, "minDigestLength");
1772
+ __publicField(this, "maxDigestLength");
1773
+ this.name = name2;
1774
+ this.code = code2;
1775
+ this.encode = encode5;
1776
+ this.minDigestLength = minDigestLength ?? DEFAULT_MIN_DIGEST_LENGTH;
1777
+ this.maxDigestLength = maxDigestLength;
1778
+ }
1779
+ digest(input, options) {
1780
+ if (options?.truncate != null) {
1781
+ if (options.truncate < this.minDigestLength) {
1782
+ throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);
1783
+ }
1784
+ if (this.maxDigestLength != null && options.truncate > this.maxDigestLength) {
1785
+ throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`);
1786
+ }
1787
+ }
1788
+ if (input instanceof Uint8Array) {
1789
+ const result = this.encode(input);
1790
+ if (result instanceof Uint8Array) {
1791
+ return createDigest(result, this.code, options?.truncate);
1792
+ }
1793
+ return result.then((digest2) => createDigest(digest2, this.code, options?.truncate));
1794
+ } else {
1795
+ throw Error("Unknown type, must be binary type");
1796
+ }
1797
+ }
1798
+ };
1799
+ function createDigest(digest2, code2, truncate) {
1800
+ if (truncate != null && truncate !== digest2.byteLength) {
1801
+ if (truncate > digest2.byteLength) {
1802
+ throw new Error(`Invalid truncate option, must be less than or equal to ${digest2.byteLength}`);
1803
+ }
1804
+ digest2 = digest2.subarray(0, truncate);
1805
+ }
1806
+ return create(code2, digest2);
1807
+ }
1808
+
1809
+ // ../../node_modules/multiformats/dist/src/hashes/sha2.js
1810
+ var sha2562 = from2({
1811
+ name: "sha2-256",
1812
+ code: 18,
1813
+ encode: (input) => coerce(import_crypto.default.createHash("sha256").update(input).digest())
1814
+ });
1815
+ var sha512 = from2({
1816
+ name: "sha2-512",
1817
+ code: 19,
1818
+ encode: (input) => coerce(import_crypto.default.createHash("sha512").update(input).digest())
1819
+ });
1820
+
1821
+ // ../../node_modules/multiformats/dist/src/basics.js
1822
+ var bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
1823
+ var hashes = { ...sha2_exports, ...identity_exports2 };
1824
+
1825
+ // src/policy/signed-object.ts
670
1826
  var import_viem3 = require("viem");
671
1827
 
672
1828
  // src/identity.ts
@@ -734,7 +1890,7 @@ var DESCRIPTORS = {
734
1890
  domain: POLICY_ENGINE_RECORD_SCHEMA
735
1891
  }
736
1892
  };
737
- var textEncoder2 = new TextEncoder();
1893
+ var textEncoder3 = new TextEncoder();
738
1894
  var BASE32_ALPHABET = "abcdefghijklmnopqrstuvwxyz234567";
739
1895
  var BASE64URL_RE = /^[A-Za-z0-9_-]+$/;
740
1896
  var objectHasOwn3 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
@@ -1046,9 +2202,9 @@ function validateAudit(input, path) {
1046
2202
  }
1047
2203
  function materialForUnsigned(unsigned, descriptor) {
1048
2204
  const jcs = jcsCanonicalize(unsigned);
1049
- const jcsBytes = textEncoder2.encode(jcs);
1050
- const digest = sha256Bytes(concatBytes(textEncoder2.encode(`${descriptor.domain}\0`), jcsBytes));
1051
- const id = `${descriptor.idPrefix}${base32LowerNoPad(digest)}`;
2205
+ const jcsBytes = textEncoder3.encode(jcs);
2206
+ const digest2 = sha256Bytes(concatBytes(textEncoder3.encode(`${descriptor.domain}\0`), jcsBytes));
2207
+ const id = `${descriptor.idPrefix}${base32LowerNoPad(digest2)}`;
1052
2208
  return {
1053
2209
  kind: descriptor.kind,
1054
2210
  idField: descriptor.idField,
@@ -1057,8 +2213,8 @@ function materialForUnsigned(unsigned, descriptor) {
1057
2213
  unsigned,
1058
2214
  jcs,
1059
2215
  jcsBytes,
1060
- digest,
1061
- digestHex: (0, import_viem3.bytesToHex)(digest).slice(2)
2216
+ digest: digest2,
2217
+ digestHex: (0, import_viem3.bytesToHex)(digest2).slice(2)
1062
2218
  };
1063
2219
  }
1064
2220
  function assertIdMatches(signed, material, descriptor) {
@@ -1084,12 +2240,12 @@ function assertSigningKeyBindingForVerify(signed, signature) {
1084
2240
  );
1085
2241
  }
1086
2242
  }
1087
- async function verifySignature(signature, digest) {
2243
+ async function verifySignature(signature, digest2) {
1088
2244
  if (signature.suite === ED25519_JCS_SIGNATURE_SUITE) {
1089
2245
  const publicKey = ed25519PublicKeyFromDidKey(signature.signerDid);
1090
2246
  const signatureBytes = decodeSignatureValue(signature.value, signature.suite);
1091
2247
  try {
1092
- return import_ed25519.ed25519.verify(signatureBytes, digest, publicKey);
2248
+ return import_ed25519.ed25519.verify(signatureBytes, digest2, publicKey);
1093
2249
  } catch {
1094
2250
  throw new SignatureVerificationError("Ed25519 signature verification failed");
1095
2251
  }
@@ -1100,7 +2256,7 @@ async function verifySignature(signature, digest) {
1100
2256
  try {
1101
2257
  return (0, import_viem3.verifyMessage)({
1102
2258
  address: pkh.address,
1103
- message: { raw: digest },
2259
+ message: { raw: digest2 },
1104
2260
  signature: (0, import_viem3.bytesToHex)(signatureBytes)
1105
2261
  });
1106
2262
  } catch {
@@ -1119,7 +2275,7 @@ function ed25519PublicKeyFromDidKey(did) {
1119
2275
  }
1120
2276
  let bytes;
1121
2277
  try {
1122
- bytes = import_basics.bases.base58btc.decode(identifier);
2278
+ bytes = bases.base58btc.decode(identifier);
1123
2279
  } catch {
1124
2280
  throw new SignatureMaterialError("did:key signerDid is undecodable");
1125
2281
  }
@@ -1318,20 +2474,20 @@ function base32LowerNoPad(bytes) {
1318
2474
  return output;
1319
2475
  }
1320
2476
  function base64UrlEncode(bytes) {
1321
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
2477
+ const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1322
2478
  let output = "";
1323
2479
  for (let index = 0; index < bytes.length; index += 3) {
1324
2480
  const a = bytes[index];
1325
2481
  const b = bytes[index + 1];
1326
2482
  const c = bytes[index + 2];
1327
2483
  const triplet = a << 16 | (b ?? 0) << 8 | (c ?? 0);
1328
- output += alphabet[triplet >> 18 & 63];
1329
- output += alphabet[triplet >> 12 & 63];
2484
+ output += alphabet2[triplet >> 18 & 63];
2485
+ output += alphabet2[triplet >> 12 & 63];
1330
2486
  if (index + 1 < bytes.length) {
1331
- output += alphabet[triplet >> 6 & 63];
2487
+ output += alphabet2[triplet >> 6 & 63];
1332
2488
  }
1333
2489
  if (index + 2 < bytes.length) {
1334
- output += alphabet[triplet & 63];
2490
+ output += alphabet2[triplet & 63];
1335
2491
  }
1336
2492
  }
1337
2493
  return output;
@@ -1340,12 +2496,12 @@ function base64UrlDecode(value) {
1340
2496
  if (value.length % 4 === 1) {
1341
2497
  throw new SignatureMaterialError("signature value is not canonical base64url");
1342
2498
  }
1343
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
2499
+ const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1344
2500
  const bytes = [];
1345
2501
  let buffer = 0;
1346
2502
  let bits = 0;
1347
2503
  for (const char of value) {
1348
- const index = alphabet.indexOf(char);
2504
+ const index = alphabet2.indexOf(char);
1349
2505
  if (index < 0) {
1350
2506
  throw new SignatureMaterialError("signature value is not base64url");
1351
2507
  }
@@ -1369,10 +2525,10 @@ var OWNER_NODE_ENDPOINT_SCHEMA = "xyz.tinycloud.exchange/owner-node-endpoint/v1"
1369
2525
  var POLICY_VERSION_V0 = "v0";
1370
2526
  var W3C_VC_CREDENTIAL_VERIFIER = "w3c.vc/credential/v1";
1371
2527
  var PolicyAuthoringError = class extends Error {
1372
- constructor(code, message) {
2528
+ constructor(code2, message) {
1373
2529
  super(message);
1374
2530
  this.name = "PolicyAuthoringError";
1375
- this.code = code;
2531
+ this.code = code2;
1376
2532
  }
1377
2533
  };
1378
2534
  async function verifyPolicyEngineRecordForRequester(options) {
@@ -1483,11 +2639,11 @@ async function verifyPolicyEngineRecordForRequester(options) {
1483
2639
  }
1484
2640
  return verified;
1485
2641
  }
1486
- function expectObject2(input, path, code) {
2642
+ function expectObject2(input, path, code2) {
1487
2643
  try {
1488
2644
  const normalized = normalizeJson(input);
1489
2645
  if (normalized === null || typeof normalized !== "object" || Array.isArray(normalized)) {
1490
- throw new PolicyAuthoringError(code, `${path} must be an object`);
2646
+ throw new PolicyAuthoringError(code2, `${path} must be an object`);
1491
2647
  }
1492
2648
  return normalized;
1493
2649
  } catch (error) {
@@ -1495,7 +2651,7 @@ function expectObject2(input, path, code) {
1495
2651
  throw error;
1496
2652
  }
1497
2653
  throw new PolicyAuthoringError(
1498
- code,
2654
+ code2,
1499
2655
  error instanceof Error ? error.message : String(error)
1500
2656
  );
1501
2657
  }
@@ -1530,14 +2686,14 @@ function requiredString3(object, key, path) {
1530
2686
  }
1531
2687
  return value;
1532
2688
  }
1533
- function fieldString(object, key, path, code) {
2689
+ function fieldString(object, key, path, code2) {
1534
2690
  if (!hasOwn3(object, key)) {
1535
- throw new PolicyAuthoringError(code, `${path}.${key} is required`);
2691
+ throw new PolicyAuthoringError(code2, `${path}.${key} is required`);
1536
2692
  }
1537
2693
  const value = object[key];
1538
2694
  if (typeof value !== "string" || value.length === 0) {
1539
2695
  throw new PolicyAuthoringError(
1540
- code,
2696
+ code2,
1541
2697
  `${path}.${key} must be a non-empty string`
1542
2698
  );
1543
2699
  }
@@ -1643,10 +2799,10 @@ var POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES = [
1643
2799
  "rate-limited"
1644
2800
  ];
1645
2801
  var TranscriptRequesterError = class extends Error {
1646
- constructor(code, message, state = "invalid", denialCode, status) {
2802
+ constructor(code2, message, state = "invalid", denialCode, status) {
1647
2803
  super(message);
1648
2804
  this.name = "TranscriptRequesterError";
1649
- this.code = code;
2805
+ this.code = code2;
1650
2806
  this.state = state;
1651
2807
  this.denialCode = denialCode;
1652
2808
  this.status = status;
@@ -2420,23 +3576,23 @@ async function verifyRecordBeforeEgress(bootstrap, options) {
2420
3576
  requiredEvidenceVerifier: W3C_VC_CREDENTIAL_VERIFIER
2421
3577
  });
2422
3578
  } catch (error) {
2423
- const code = errorCodeForRecordFailure(error);
3579
+ const code2 = errorCodeForRecordFailure(error);
2424
3580
  throw new TranscriptRequesterError(
2425
- code,
3581
+ code2,
2426
3582
  error instanceof Error ? error.message : String(error),
2427
3583
  "bootstrap-invalid"
2428
3584
  );
2429
3585
  }
2430
3586
  }
2431
3587
  function errorCodeForRecordFailure(error) {
2432
- const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
2433
- if (code === "policy-engine-record-signature-invalid") {
3588
+ const code2 = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
3589
+ if (code2 === "policy-engine-record-signature-invalid") {
2434
3590
  return "requester-engine-record-signature-invalid";
2435
3591
  }
2436
- if (code === "policy-engine-record-owner-mismatch") {
3592
+ if (code2 === "policy-engine-record-owner-mismatch") {
2437
3593
  return "requester-engine-record-owner-mismatch";
2438
3594
  }
2439
- if (code === "policy-engine-record-audience-mismatch") {
3595
+ if (code2 === "policy-engine-record-audience-mismatch") {
2440
3596
  return "requester-engine-record-audience-mismatch";
2441
3597
  }
2442
3598
  return "requester-engine-record-invalid";
@@ -2736,16 +3892,16 @@ function nodeErrorMessage(body) {
2736
3892
  if (typeof body === "string") return body;
2737
3893
  if (body !== null && typeof body === "object") {
2738
3894
  const record = body;
2739
- const code = typeof record.code === "string" ? record.code : void 0;
3895
+ const code2 = typeof record.code === "string" ? record.code : void 0;
2740
3896
  const message = typeof record.message === "string" ? record.message : void 0;
2741
- if (code !== void 0)
2742
- return message === void 0 ? code : `${code}: ${message}`;
3897
+ if (code2 !== void 0)
3898
+ return message === void 0 ? code2 : `${code2}: ${message}`;
2743
3899
  }
2744
3900
  return "native node refusal";
2745
3901
  }
2746
3902
  function deriveDelegationCid(encoded) {
2747
- const digest = (0, import_digest.create)(30, (0, import_blake3.blake3)(new TextEncoder().encode(encoded)));
2748
- return import_cid.CID.createV1(85, digest).toString();
3903
+ const digest2 = create(30, (0, import_blake3.blake3)(new TextEncoder().encode(encoded)));
3904
+ return CID.createV1(85, digest2).toString();
2749
3905
  }
2750
3906
  function headersRecord(headers) {
2751
3907
  return Array.isArray(headers) ? Object.fromEntries(headers) : headers;
@@ -2856,21 +4012,21 @@ function errorForDenial(denial, status) {
2856
4012
  );
2857
4013
  }
2858
4014
  function retryDelay(attempt, random) {
2859
- const base = Math.min(REQUESTER_ENGINE_RETRY_MAX_DELAY_MS, 50 * 2 ** attempt);
4015
+ const base3 = Math.min(REQUESTER_ENGINE_RETRY_MAX_DELAY_MS, 50 * 2 ** attempt);
2860
4016
  return Math.min(
2861
4017
  REQUESTER_ENGINE_RETRY_MAX_DELAY_MS,
2862
- Math.floor(base * (0.5 + random))
4018
+ Math.floor(base3 * (0.5 + random))
2863
4019
  );
2864
4020
  }
2865
4021
  function trimTrailingSlash(value) {
2866
4022
  return value.endsWith("/") ? value.slice(0, -1) : value;
2867
4023
  }
2868
- function normalizeExternal(input, code) {
4024
+ function normalizeExternal(input, code2) {
2869
4025
  try {
2870
4026
  return normalizeJson(input);
2871
4027
  } catch (error) {
2872
4028
  throw new TranscriptRequesterError(
2873
- code,
4029
+ code2,
2874
4030
  error instanceof Error ? error.message : String(error)
2875
4031
  );
2876
4032
  }