@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/policy/index.ts
21
33
  var policy_exports = {};
@@ -78,10 +90,10 @@ module.exports = __toCommonJS(policy_exports);
78
90
 
79
91
  // src/policy/errors.ts
80
92
  var SignedObjectProfileError = class extends Error {
81
- constructor(code, message) {
93
+ constructor(code2, message) {
82
94
  super(message);
83
95
  this.name = "SignedObjectProfileError";
84
- this.code = code;
96
+ this.code = code2;
85
97
  }
86
98
  };
87
99
  var SignedObjectSchemaError = class extends SignedObjectProfileError {
@@ -279,35 +291,33 @@ function assertNoSymbolKeys(input, path) {
279
291
  );
280
292
  }
281
293
  }
282
- function isArrayIndexKey(key, length) {
294
+ function isArrayIndexKey(key, length2) {
283
295
  if (!/^(0|[1-9]\d*)$/.test(key)) {
284
296
  return false;
285
297
  }
286
298
  const index = Number(key);
287
- return Number.isSafeInteger(index) && index >= 0 && index < length;
299
+ return Number.isSafeInteger(index) && index >= 0 && index < length2;
288
300
  }
289
301
  function serializeObject(value) {
290
- const keys = Object.keys(value).sort(compareCodePoints);
302
+ const keys = Object.keys(value).sort(compareUtf16CodeUnits);
291
303
  const parts = keys.map((key) => `${JSON.stringify(key)}:${serialize(value[key])}`);
292
304
  return `{${parts.join(",")}}`;
293
305
  }
294
- function compareCodePoints(a, b) {
295
- const left = Array.from(a);
296
- const right = Array.from(b);
297
- const max = Math.min(left.length, right.length);
306
+ function compareUtf16CodeUnits(a, b) {
307
+ const max = Math.min(a.length, b.length);
298
308
  for (let index = 0; index < max; index++) {
299
- const leftPoint = left[index].codePointAt(0) ?? 0;
300
- const rightPoint = right[index].codePointAt(0) ?? 0;
301
- if (leftPoint !== rightPoint) {
302
- return leftPoint - rightPoint;
309
+ const leftCodeUnit = a.charCodeAt(index);
310
+ const rightCodeUnit = b.charCodeAt(index);
311
+ if (leftCodeUnit !== rightCodeUnit) {
312
+ return leftCodeUnit - rightCodeUnit;
303
313
  }
304
314
  }
305
- return left.length - right.length;
315
+ return a.length - b.length;
306
316
  }
307
317
  function assertUnicodeScalarString(value, path) {
308
318
  for (let index = 0; index < value.length; index++) {
309
- const code = value.charCodeAt(index);
310
- if (code >= 55296 && code <= 56319) {
319
+ const code2 = value.charCodeAt(index);
320
+ if (code2 >= 55296 && code2 <= 56319) {
311
321
  const next = value.charCodeAt(index + 1);
312
322
  if (Number.isNaN(next) || next < 56320 || next > 57343) {
313
323
  throw new SignedObjectCanonicalizationError(
@@ -317,7 +327,7 @@ function assertUnicodeScalarString(value, path) {
317
327
  index++;
318
328
  continue;
319
329
  }
320
- if (code >= 56320 && code <= 57343) {
330
+ if (code2 >= 56320 && code2 <= 57343) {
321
331
  throw new SignedObjectCanonicalizationError(
322
332
  `${path} contains a lone low surrogate`
323
333
  );
@@ -331,10 +341,10 @@ var import_viem = require("viem");
331
341
  var POLICY_CAPABILITY_DOMAIN = "xyz.tinycloud.policy/PolicyCapability/v0";
332
342
  var textEncoder = new TextEncoder();
333
343
  var PolicyCapabilityError = class extends Error {
334
- constructor(code, message) {
344
+ constructor(code2, message) {
335
345
  super(message);
336
346
  this.name = "PolicyCapabilityError";
337
- this.code = code;
347
+ this.code = code2;
338
348
  }
339
349
  };
340
350
  var objectHasOwn2 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
@@ -469,23 +479,23 @@ function assertExactKeys(object, allowed, path) {
469
479
  }
470
480
  }
471
481
  }
472
- function requiredValue(object, key, path, code) {
482
+ function requiredValue(object, key, path, code2) {
473
483
  if (!hasOwn(object, key)) {
474
- throw new PolicyCapabilityError(code, `${path}.${key} is required`);
484
+ throw new PolicyCapabilityError(code2, `${path}.${key} is required`);
475
485
  }
476
486
  return object[key];
477
487
  }
478
- function requiredString(object, key, path, code) {
479
- const value = requiredValue(object, key, path, code);
488
+ function requiredString(object, key, path, code2) {
489
+ const value = requiredValue(object, key, path, code2);
480
490
  if (typeof value !== "string" || value.length === 0) {
481
- throw new PolicyCapabilityError(code, `${path}.${key} must be a non-empty string`);
491
+ throw new PolicyCapabilityError(code2, `${path}.${key} must be a non-empty string`);
482
492
  }
483
493
  return value;
484
494
  }
485
- function requiredArray(object, key, path, code) {
486
- const value = requiredValue(object, key, path, code);
495
+ function requiredArray(object, key, path, code2) {
496
+ const value = requiredValue(object, key, path, code2);
487
497
  if (!Array.isArray(value)) {
488
- throw new PolicyCapabilityError(code, `${path}.${key} must be an array`);
498
+ throw new PolicyCapabilityError(code2, `${path}.${key} must be an array`);
489
499
  }
490
500
  return value;
491
501
  }
@@ -716,7 +726,1155 @@ function hasOwn(object, key) {
716
726
 
717
727
  // src/policy/signed-object.ts
718
728
  var import_ed25519 = require("@noble/curves/ed25519");
719
- var import_basics = require("multiformats/basics");
729
+
730
+ // ../../node_modules/multiformats/dist/src/bases/base10.js
731
+ var base10_exports = {};
732
+ __export(base10_exports, {
733
+ base10: () => base10
734
+ });
735
+
736
+ // ../../node_modules/multiformats/dist/src/bytes.js
737
+ var empty = new Uint8Array(0);
738
+ function equals(aa, bb) {
739
+ if (aa === bb) {
740
+ return true;
741
+ }
742
+ if (aa.byteLength !== bb.byteLength) {
743
+ return false;
744
+ }
745
+ for (let ii = 0; ii < aa.byteLength; ii++) {
746
+ if (aa[ii] !== bb[ii]) {
747
+ return false;
748
+ }
749
+ }
750
+ return true;
751
+ }
752
+ function coerce(o) {
753
+ if (o instanceof Uint8Array && o.constructor.name === "Uint8Array") {
754
+ return o;
755
+ }
756
+ if (o instanceof ArrayBuffer) {
757
+ return new Uint8Array(o);
758
+ }
759
+ if (ArrayBuffer.isView(o)) {
760
+ return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
761
+ }
762
+ throw new Error("Unknown type, must be binary type");
763
+ }
764
+ function fromString(str) {
765
+ return new TextEncoder().encode(str);
766
+ }
767
+ function toString(b) {
768
+ return new TextDecoder().decode(b);
769
+ }
770
+
771
+ // ../../node_modules/multiformats/dist/src/vendor/base-x.js
772
+ function base(ALPHABET, name2) {
773
+ if (ALPHABET.length >= 255) {
774
+ throw new TypeError("Alphabet too long");
775
+ }
776
+ var BASE_MAP = new Uint8Array(256);
777
+ for (var j = 0; j < BASE_MAP.length; j++) {
778
+ BASE_MAP[j] = 255;
779
+ }
780
+ for (var i = 0; i < ALPHABET.length; i++) {
781
+ var x = ALPHABET.charAt(i);
782
+ var xc = x.charCodeAt(0);
783
+ if (BASE_MAP[xc] !== 255) {
784
+ throw new TypeError(x + " is ambiguous");
785
+ }
786
+ BASE_MAP[xc] = i;
787
+ }
788
+ var BASE = ALPHABET.length;
789
+ var LEADER = ALPHABET.charAt(0);
790
+ var FACTOR = Math.log(BASE) / Math.log(256);
791
+ var iFACTOR = Math.log(256) / Math.log(BASE);
792
+ function encode5(source) {
793
+ if (source instanceof Uint8Array)
794
+ ;
795
+ else if (ArrayBuffer.isView(source)) {
796
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
797
+ } else if (Array.isArray(source)) {
798
+ source = Uint8Array.from(source);
799
+ }
800
+ if (!(source instanceof Uint8Array)) {
801
+ throw new TypeError("Expected Uint8Array");
802
+ }
803
+ if (source.length === 0) {
804
+ return "";
805
+ }
806
+ var zeroes = 0;
807
+ var length2 = 0;
808
+ var pbegin = 0;
809
+ var pend = source.length;
810
+ while (pbegin !== pend && source[pbegin] === 0) {
811
+ pbegin++;
812
+ zeroes++;
813
+ }
814
+ var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
815
+ var b58 = new Uint8Array(size);
816
+ while (pbegin !== pend) {
817
+ var carry = source[pbegin];
818
+ var i2 = 0;
819
+ for (var it1 = size - 1; (carry !== 0 || i2 < length2) && it1 !== -1; it1--, i2++) {
820
+ carry += 256 * b58[it1] >>> 0;
821
+ b58[it1] = carry % BASE >>> 0;
822
+ carry = carry / BASE >>> 0;
823
+ }
824
+ if (carry !== 0) {
825
+ throw new Error("Non-zero carry");
826
+ }
827
+ length2 = i2;
828
+ pbegin++;
829
+ }
830
+ var it2 = size - length2;
831
+ while (it2 !== size && b58[it2] === 0) {
832
+ it2++;
833
+ }
834
+ var str = LEADER.repeat(zeroes);
835
+ for (; it2 < size; ++it2) {
836
+ str += ALPHABET.charAt(b58[it2]);
837
+ }
838
+ return str;
839
+ }
840
+ function decodeUnsafe(source) {
841
+ if (typeof source !== "string") {
842
+ throw new TypeError("Expected String");
843
+ }
844
+ if (source.length === 0) {
845
+ return new Uint8Array();
846
+ }
847
+ var psz = 0;
848
+ if (source[psz] === " ") {
849
+ return;
850
+ }
851
+ var zeroes = 0;
852
+ var length2 = 0;
853
+ while (source[psz] === LEADER) {
854
+ zeroes++;
855
+ psz++;
856
+ }
857
+ var size = (source.length - psz) * FACTOR + 1 >>> 0;
858
+ var b256 = new Uint8Array(size);
859
+ while (source[psz]) {
860
+ var carry = BASE_MAP[source.charCodeAt(psz)];
861
+ if (carry === 255) {
862
+ return;
863
+ }
864
+ var i2 = 0;
865
+ for (var it3 = size - 1; (carry !== 0 || i2 < length2) && it3 !== -1; it3--, i2++) {
866
+ carry += BASE * b256[it3] >>> 0;
867
+ b256[it3] = carry % 256 >>> 0;
868
+ carry = carry / 256 >>> 0;
869
+ }
870
+ if (carry !== 0) {
871
+ throw new Error("Non-zero carry");
872
+ }
873
+ length2 = i2;
874
+ psz++;
875
+ }
876
+ if (source[psz] === " ") {
877
+ return;
878
+ }
879
+ var it4 = size - length2;
880
+ while (it4 !== size && b256[it4] === 0) {
881
+ it4++;
882
+ }
883
+ var vch = new Uint8Array(zeroes + (size - it4));
884
+ var j2 = zeroes;
885
+ while (it4 !== size) {
886
+ vch[j2++] = b256[it4++];
887
+ }
888
+ return vch;
889
+ }
890
+ function decode6(string) {
891
+ var buffer = decodeUnsafe(string);
892
+ if (buffer) {
893
+ return buffer;
894
+ }
895
+ throw new Error(`Non-${name2} character`);
896
+ }
897
+ return {
898
+ encode: encode5,
899
+ decodeUnsafe,
900
+ decode: decode6
901
+ };
902
+ }
903
+ var src = base;
904
+ var _brrp__multiformats_scope_baseX = src;
905
+ var base_x_default = _brrp__multiformats_scope_baseX;
906
+
907
+ // ../../node_modules/multiformats/dist/src/bases/base.js
908
+ var Encoder = class {
909
+ constructor(name2, prefix, baseEncode) {
910
+ __publicField(this, "name");
911
+ __publicField(this, "prefix");
912
+ __publicField(this, "baseEncode");
913
+ this.name = name2;
914
+ this.prefix = prefix;
915
+ this.baseEncode = baseEncode;
916
+ }
917
+ encode(bytes) {
918
+ if (bytes instanceof Uint8Array) {
919
+ return `${this.prefix}${this.baseEncode(bytes)}`;
920
+ } else {
921
+ throw Error("Unknown type, must be binary type");
922
+ }
923
+ }
924
+ };
925
+ var Decoder = class {
926
+ constructor(name2, prefix, baseDecode) {
927
+ __publicField(this, "name");
928
+ __publicField(this, "prefix");
929
+ __publicField(this, "baseDecode");
930
+ __publicField(this, "prefixCodePoint");
931
+ this.name = name2;
932
+ this.prefix = prefix;
933
+ const prefixCodePoint = prefix.codePointAt(0);
934
+ if (prefixCodePoint === void 0) {
935
+ throw new Error("Invalid prefix character");
936
+ }
937
+ this.prefixCodePoint = prefixCodePoint;
938
+ this.baseDecode = baseDecode;
939
+ }
940
+ decode(text) {
941
+ if (typeof text === "string") {
942
+ if (text.codePointAt(0) !== this.prefixCodePoint) {
943
+ throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
944
+ }
945
+ return this.baseDecode(text.slice(this.prefix.length));
946
+ } else {
947
+ throw Error("Can only multibase decode strings");
948
+ }
949
+ }
950
+ or(decoder) {
951
+ return or(this, decoder);
952
+ }
953
+ };
954
+ var ComposedDecoder = class {
955
+ constructor(decoders) {
956
+ __publicField(this, "decoders");
957
+ this.decoders = decoders;
958
+ }
959
+ or(decoder) {
960
+ return or(this, decoder);
961
+ }
962
+ decode(input) {
963
+ const prefix = input[0];
964
+ const decoder = this.decoders[prefix];
965
+ if (decoder != null) {
966
+ return decoder.decode(input);
967
+ } else {
968
+ throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
969
+ }
970
+ }
971
+ };
972
+ function or(left, right) {
973
+ return new ComposedDecoder({
974
+ ...left.decoders ?? { [left.prefix]: left },
975
+ ...right.decoders ?? { [right.prefix]: right }
976
+ });
977
+ }
978
+ var Codec = class {
979
+ constructor(name2, prefix, baseEncode, baseDecode) {
980
+ __publicField(this, "name");
981
+ __publicField(this, "prefix");
982
+ __publicField(this, "baseEncode");
983
+ __publicField(this, "baseDecode");
984
+ __publicField(this, "encoder");
985
+ __publicField(this, "decoder");
986
+ this.name = name2;
987
+ this.prefix = prefix;
988
+ this.baseEncode = baseEncode;
989
+ this.baseDecode = baseDecode;
990
+ this.encoder = new Encoder(name2, prefix, baseEncode);
991
+ this.decoder = new Decoder(name2, prefix, baseDecode);
992
+ }
993
+ encode(input) {
994
+ return this.encoder.encode(input);
995
+ }
996
+ decode(input) {
997
+ return this.decoder.decode(input);
998
+ }
999
+ };
1000
+ function from({ name: name2, prefix, encode: encode5, decode: decode6 }) {
1001
+ return new Codec(name2, prefix, encode5, decode6);
1002
+ }
1003
+ function baseX({ name: name2, prefix, alphabet: alphabet2 }) {
1004
+ const { encode: encode5, decode: decode6 } = base_x_default(alphabet2, name2);
1005
+ return from({
1006
+ prefix,
1007
+ name: name2,
1008
+ encode: encode5,
1009
+ decode: (text) => coerce(decode6(text))
1010
+ });
1011
+ }
1012
+ function decode(string, alphabetIdx, bitsPerChar, name2) {
1013
+ let end = string.length;
1014
+ while (string[end - 1] === "=") {
1015
+ --end;
1016
+ }
1017
+ const out = new Uint8Array(end * bitsPerChar / 8 | 0);
1018
+ let bits = 0;
1019
+ let buffer = 0;
1020
+ let written = 0;
1021
+ for (let i = 0; i < end; ++i) {
1022
+ const value = alphabetIdx[string[i]];
1023
+ if (value === void 0) {
1024
+ throw new SyntaxError(`Non-${name2} character`);
1025
+ }
1026
+ buffer = buffer << bitsPerChar | value;
1027
+ bits += bitsPerChar;
1028
+ if (bits >= 8) {
1029
+ bits -= 8;
1030
+ out[written++] = 255 & buffer >> bits;
1031
+ }
1032
+ }
1033
+ if (bits >= bitsPerChar || (255 & buffer << 8 - bits) !== 0) {
1034
+ throw new SyntaxError("Unexpected end of data");
1035
+ }
1036
+ return out;
1037
+ }
1038
+ function encode(data, alphabet2, bitsPerChar) {
1039
+ const pad = alphabet2[alphabet2.length - 1] === "=";
1040
+ const mask = (1 << bitsPerChar) - 1;
1041
+ let out = "";
1042
+ let bits = 0;
1043
+ let buffer = 0;
1044
+ for (let i = 0; i < data.length; ++i) {
1045
+ buffer = buffer << 8 | data[i];
1046
+ bits += 8;
1047
+ while (bits > bitsPerChar) {
1048
+ bits -= bitsPerChar;
1049
+ out += alphabet2[mask & buffer >> bits];
1050
+ }
1051
+ }
1052
+ if (bits !== 0) {
1053
+ out += alphabet2[mask & buffer << bitsPerChar - bits];
1054
+ }
1055
+ if (pad) {
1056
+ while ((out.length * bitsPerChar & 7) !== 0) {
1057
+ out += "=";
1058
+ }
1059
+ }
1060
+ return out;
1061
+ }
1062
+ function createAlphabetIdx(alphabet2) {
1063
+ const alphabetIdx = {};
1064
+ for (let i = 0; i < alphabet2.length; ++i) {
1065
+ alphabetIdx[alphabet2[i]] = i;
1066
+ }
1067
+ return alphabetIdx;
1068
+ }
1069
+ function rfc4648({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) {
1070
+ const alphabetIdx = createAlphabetIdx(alphabet2);
1071
+ return from({
1072
+ prefix,
1073
+ name: name2,
1074
+ encode(input) {
1075
+ return encode(input, alphabet2, bitsPerChar);
1076
+ },
1077
+ decode(input) {
1078
+ return decode(input, alphabetIdx, bitsPerChar, name2);
1079
+ }
1080
+ });
1081
+ }
1082
+
1083
+ // ../../node_modules/multiformats/dist/src/bases/base10.js
1084
+ var base10 = baseX({
1085
+ prefix: "9",
1086
+ name: "base10",
1087
+ alphabet: "0123456789"
1088
+ });
1089
+
1090
+ // ../../node_modules/multiformats/dist/src/bases/base16.js
1091
+ var base16_exports = {};
1092
+ __export(base16_exports, {
1093
+ base16: () => base16,
1094
+ base16upper: () => base16upper
1095
+ });
1096
+ var base16 = rfc4648({
1097
+ prefix: "f",
1098
+ name: "base16",
1099
+ alphabet: "0123456789abcdef",
1100
+ bitsPerChar: 4
1101
+ });
1102
+ var base16upper = rfc4648({
1103
+ prefix: "F",
1104
+ name: "base16upper",
1105
+ alphabet: "0123456789ABCDEF",
1106
+ bitsPerChar: 4
1107
+ });
1108
+
1109
+ // ../../node_modules/multiformats/dist/src/bases/base2.js
1110
+ var base2_exports = {};
1111
+ __export(base2_exports, {
1112
+ base2: () => base2
1113
+ });
1114
+ var base2 = rfc4648({
1115
+ prefix: "0",
1116
+ name: "base2",
1117
+ alphabet: "01",
1118
+ bitsPerChar: 1
1119
+ });
1120
+
1121
+ // ../../node_modules/multiformats/dist/src/bases/base256emoji.js
1122
+ var base256emoji_exports = {};
1123
+ __export(base256emoji_exports, {
1124
+ base256emoji: () => base256emoji
1125
+ });
1126
+ 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}");
1127
+ var alphabetBytesToChars = alphabet.reduce((p, c, i) => {
1128
+ p[i] = c;
1129
+ return p;
1130
+ }, []);
1131
+ var alphabetCharsToBytes = alphabet.reduce((p, c, i) => {
1132
+ const codePoint = c.codePointAt(0);
1133
+ if (codePoint == null) {
1134
+ throw new Error(`Invalid character: ${c}`);
1135
+ }
1136
+ p[codePoint] = i;
1137
+ return p;
1138
+ }, []);
1139
+ function encode2(data) {
1140
+ return data.reduce((p, c) => {
1141
+ p += alphabetBytesToChars[c];
1142
+ return p;
1143
+ }, "");
1144
+ }
1145
+ function decode2(str) {
1146
+ const byts = [];
1147
+ for (const char of str) {
1148
+ const codePoint = char.codePointAt(0);
1149
+ if (codePoint == null) {
1150
+ throw new Error(`Invalid character: ${char}`);
1151
+ }
1152
+ const byt = alphabetCharsToBytes[codePoint];
1153
+ if (byt == null) {
1154
+ throw new Error(`Non-base256emoji character: ${char}`);
1155
+ }
1156
+ byts.push(byt);
1157
+ }
1158
+ return new Uint8Array(byts);
1159
+ }
1160
+ var base256emoji = from({
1161
+ prefix: "\u{1F680}",
1162
+ name: "base256emoji",
1163
+ encode: encode2,
1164
+ decode: decode2
1165
+ });
1166
+
1167
+ // ../../node_modules/multiformats/dist/src/bases/base32.js
1168
+ var base32_exports = {};
1169
+ __export(base32_exports, {
1170
+ base32: () => base32,
1171
+ base32hex: () => base32hex,
1172
+ base32hexpad: () => base32hexpad,
1173
+ base32hexpadupper: () => base32hexpadupper,
1174
+ base32hexupper: () => base32hexupper,
1175
+ base32pad: () => base32pad,
1176
+ base32padupper: () => base32padupper,
1177
+ base32upper: () => base32upper,
1178
+ base32z: () => base32z
1179
+ });
1180
+ var base32 = rfc4648({
1181
+ prefix: "b",
1182
+ name: "base32",
1183
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567",
1184
+ bitsPerChar: 5
1185
+ });
1186
+ var base32upper = rfc4648({
1187
+ prefix: "B",
1188
+ name: "base32upper",
1189
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
1190
+ bitsPerChar: 5
1191
+ });
1192
+ var base32pad = rfc4648({
1193
+ prefix: "c",
1194
+ name: "base32pad",
1195
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
1196
+ bitsPerChar: 5
1197
+ });
1198
+ var base32padupper = rfc4648({
1199
+ prefix: "C",
1200
+ name: "base32padupper",
1201
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
1202
+ bitsPerChar: 5
1203
+ });
1204
+ var base32hex = rfc4648({
1205
+ prefix: "v",
1206
+ name: "base32hex",
1207
+ alphabet: "0123456789abcdefghijklmnopqrstuv",
1208
+ bitsPerChar: 5
1209
+ });
1210
+ var base32hexupper = rfc4648({
1211
+ prefix: "V",
1212
+ name: "base32hexupper",
1213
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
1214
+ bitsPerChar: 5
1215
+ });
1216
+ var base32hexpad = rfc4648({
1217
+ prefix: "t",
1218
+ name: "base32hexpad",
1219
+ alphabet: "0123456789abcdefghijklmnopqrstuv=",
1220
+ bitsPerChar: 5
1221
+ });
1222
+ var base32hexpadupper = rfc4648({
1223
+ prefix: "T",
1224
+ name: "base32hexpadupper",
1225
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
1226
+ bitsPerChar: 5
1227
+ });
1228
+ var base32z = rfc4648({
1229
+ prefix: "h",
1230
+ name: "base32z",
1231
+ alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
1232
+ bitsPerChar: 5
1233
+ });
1234
+
1235
+ // ../../node_modules/multiformats/dist/src/bases/base36.js
1236
+ var base36_exports = {};
1237
+ __export(base36_exports, {
1238
+ base36: () => base36,
1239
+ base36upper: () => base36upper
1240
+ });
1241
+ var base36 = baseX({
1242
+ prefix: "k",
1243
+ name: "base36",
1244
+ alphabet: "0123456789abcdefghijklmnopqrstuvwxyz"
1245
+ });
1246
+ var base36upper = baseX({
1247
+ prefix: "K",
1248
+ name: "base36upper",
1249
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1250
+ });
1251
+
1252
+ // ../../node_modules/multiformats/dist/src/bases/base58.js
1253
+ var base58_exports = {};
1254
+ __export(base58_exports, {
1255
+ base58btc: () => base58btc,
1256
+ base58flickr: () => base58flickr
1257
+ });
1258
+ var base58btc = baseX({
1259
+ name: "base58btc",
1260
+ prefix: "z",
1261
+ alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
1262
+ });
1263
+ var base58flickr = baseX({
1264
+ name: "base58flickr",
1265
+ prefix: "Z",
1266
+ alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
1267
+ });
1268
+
1269
+ // ../../node_modules/multiformats/dist/src/bases/base64.js
1270
+ var base64_exports = {};
1271
+ __export(base64_exports, {
1272
+ base64: () => base64,
1273
+ base64pad: () => base64pad,
1274
+ base64url: () => base64url,
1275
+ base64urlpad: () => base64urlpad
1276
+ });
1277
+ var base64 = rfc4648({
1278
+ prefix: "m",
1279
+ name: "base64",
1280
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
1281
+ bitsPerChar: 6
1282
+ });
1283
+ var base64pad = rfc4648({
1284
+ prefix: "M",
1285
+ name: "base64pad",
1286
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
1287
+ bitsPerChar: 6
1288
+ });
1289
+ var base64url = rfc4648({
1290
+ prefix: "u",
1291
+ name: "base64url",
1292
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
1293
+ bitsPerChar: 6
1294
+ });
1295
+ var base64urlpad = rfc4648({
1296
+ prefix: "U",
1297
+ name: "base64urlpad",
1298
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
1299
+ bitsPerChar: 6
1300
+ });
1301
+
1302
+ // ../../node_modules/multiformats/dist/src/bases/base8.js
1303
+ var base8_exports = {};
1304
+ __export(base8_exports, {
1305
+ base8: () => base8
1306
+ });
1307
+ var base8 = rfc4648({
1308
+ prefix: "7",
1309
+ name: "base8",
1310
+ alphabet: "01234567",
1311
+ bitsPerChar: 3
1312
+ });
1313
+
1314
+ // ../../node_modules/multiformats/dist/src/bases/identity.js
1315
+ var identity_exports = {};
1316
+ __export(identity_exports, {
1317
+ identity: () => identity
1318
+ });
1319
+ var identity = from({
1320
+ prefix: "\0",
1321
+ name: "identity",
1322
+ encode: (buf) => toString(buf),
1323
+ decode: (str) => fromString(str)
1324
+ });
1325
+
1326
+ // ../../node_modules/multiformats/dist/src/codecs/json.js
1327
+ var textEncoder2 = new TextEncoder();
1328
+ var textDecoder = new TextDecoder();
1329
+
1330
+ // ../../node_modules/multiformats/dist/src/hashes/identity.js
1331
+ var identity_exports2 = {};
1332
+ __export(identity_exports2, {
1333
+ identity: () => identity2
1334
+ });
1335
+
1336
+ // ../../node_modules/multiformats/dist/src/vendor/varint.js
1337
+ var encode_1 = encode3;
1338
+ var MSB = 128;
1339
+ var REST = 127;
1340
+ var MSBALL = ~REST;
1341
+ var INT = Math.pow(2, 31);
1342
+ function encode3(num, out, offset) {
1343
+ out = out || [];
1344
+ offset = offset || 0;
1345
+ var oldOffset = offset;
1346
+ while (num >= INT) {
1347
+ out[offset++] = num & 255 | MSB;
1348
+ num /= 128;
1349
+ }
1350
+ while (num & MSBALL) {
1351
+ out[offset++] = num & 255 | MSB;
1352
+ num >>>= 7;
1353
+ }
1354
+ out[offset] = num | 0;
1355
+ encode3.bytes = offset - oldOffset + 1;
1356
+ return out;
1357
+ }
1358
+ var decode3 = read;
1359
+ var MSB$1 = 128;
1360
+ var REST$1 = 127;
1361
+ function read(buf, offset) {
1362
+ var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
1363
+ do {
1364
+ if (counter >= l) {
1365
+ read.bytes = 0;
1366
+ throw new RangeError("Could not decode varint");
1367
+ }
1368
+ b = buf[counter++];
1369
+ res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift);
1370
+ shift += 7;
1371
+ } while (b >= MSB$1);
1372
+ read.bytes = counter - offset;
1373
+ return res;
1374
+ }
1375
+ var N1 = Math.pow(2, 7);
1376
+ var N2 = Math.pow(2, 14);
1377
+ var N3 = Math.pow(2, 21);
1378
+ var N4 = Math.pow(2, 28);
1379
+ var N5 = Math.pow(2, 35);
1380
+ var N6 = Math.pow(2, 42);
1381
+ var N7 = Math.pow(2, 49);
1382
+ var N8 = Math.pow(2, 56);
1383
+ var N9 = Math.pow(2, 63);
1384
+ var length = function(value) {
1385
+ 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;
1386
+ };
1387
+ var varint = {
1388
+ encode: encode_1,
1389
+ decode: decode3,
1390
+ encodingLength: length
1391
+ };
1392
+ var _brrp_varint = varint;
1393
+ var varint_default = _brrp_varint;
1394
+
1395
+ // ../../node_modules/multiformats/dist/src/varint.js
1396
+ function decode4(data, offset = 0) {
1397
+ const code2 = varint_default.decode(data, offset);
1398
+ return [code2, varint_default.decode.bytes];
1399
+ }
1400
+ function encodeTo(int, target, offset = 0) {
1401
+ varint_default.encode(int, target, offset);
1402
+ return target;
1403
+ }
1404
+ function encodingLength(int) {
1405
+ return varint_default.encodingLength(int);
1406
+ }
1407
+
1408
+ // ../../node_modules/multiformats/dist/src/hashes/digest.js
1409
+ function create(code2, digest2) {
1410
+ const size = digest2.byteLength;
1411
+ const sizeOffset = encodingLength(code2);
1412
+ const digestOffset = sizeOffset + encodingLength(size);
1413
+ const bytes = new Uint8Array(digestOffset + size);
1414
+ encodeTo(code2, bytes, 0);
1415
+ encodeTo(size, bytes, sizeOffset);
1416
+ bytes.set(digest2, digestOffset);
1417
+ return new Digest(code2, size, digest2, bytes);
1418
+ }
1419
+ function decode5(multihash) {
1420
+ const bytes = coerce(multihash);
1421
+ const [code2, sizeOffset] = decode4(bytes);
1422
+ const [size, digestOffset] = decode4(bytes.subarray(sizeOffset));
1423
+ const digest2 = bytes.subarray(sizeOffset + digestOffset);
1424
+ if (digest2.byteLength !== size) {
1425
+ throw new Error("Incorrect length");
1426
+ }
1427
+ return new Digest(code2, size, digest2, bytes);
1428
+ }
1429
+ function equals2(a, b) {
1430
+ if (a === b) {
1431
+ return true;
1432
+ } else {
1433
+ const data = b;
1434
+ return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equals(a.bytes, data.bytes);
1435
+ }
1436
+ }
1437
+ var Digest = class {
1438
+ /**
1439
+ * Creates a multihash digest.
1440
+ */
1441
+ constructor(code2, size, digest2, bytes) {
1442
+ __publicField(this, "code");
1443
+ __publicField(this, "size");
1444
+ __publicField(this, "digest");
1445
+ __publicField(this, "bytes");
1446
+ this.code = code2;
1447
+ this.size = size;
1448
+ this.digest = digest2;
1449
+ this.bytes = bytes;
1450
+ }
1451
+ };
1452
+
1453
+ // ../../node_modules/multiformats/dist/src/hashes/identity.js
1454
+ var code = 0;
1455
+ var name = "identity";
1456
+ var encode4 = coerce;
1457
+ function digest(input, options) {
1458
+ if (options?.truncate != null && options.truncate !== input.byteLength) {
1459
+ if (options.truncate < 0 || options.truncate > input.byteLength) {
1460
+ throw new Error(`Invalid truncate option, must be less than or equal to ${input.byteLength}`);
1461
+ }
1462
+ input = input.subarray(0, options.truncate);
1463
+ }
1464
+ return create(code, encode4(input));
1465
+ }
1466
+ var identity2 = { code, name, encode: encode4, digest };
1467
+
1468
+ // ../../node_modules/multiformats/dist/src/hashes/sha2.js
1469
+ var sha2_exports = {};
1470
+ __export(sha2_exports, {
1471
+ sha256: () => sha2562,
1472
+ sha512: () => sha512
1473
+ });
1474
+ var import_crypto = __toESM(require("crypto"), 1);
1475
+
1476
+ // ../../node_modules/multiformats/dist/src/hashes/hasher.js
1477
+ var DEFAULT_MIN_DIGEST_LENGTH = 20;
1478
+ function from2({ name: name2, code: code2, encode: encode5, minDigestLength, maxDigestLength }) {
1479
+ return new Hasher(name2, code2, encode5, minDigestLength, maxDigestLength);
1480
+ }
1481
+ var Hasher = class {
1482
+ constructor(name2, code2, encode5, minDigestLength, maxDigestLength) {
1483
+ __publicField(this, "name");
1484
+ __publicField(this, "code");
1485
+ __publicField(this, "encode");
1486
+ __publicField(this, "minDigestLength");
1487
+ __publicField(this, "maxDigestLength");
1488
+ this.name = name2;
1489
+ this.code = code2;
1490
+ this.encode = encode5;
1491
+ this.minDigestLength = minDigestLength ?? DEFAULT_MIN_DIGEST_LENGTH;
1492
+ this.maxDigestLength = maxDigestLength;
1493
+ }
1494
+ digest(input, options) {
1495
+ if (options?.truncate != null) {
1496
+ if (options.truncate < this.minDigestLength) {
1497
+ throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);
1498
+ }
1499
+ if (this.maxDigestLength != null && options.truncate > this.maxDigestLength) {
1500
+ throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`);
1501
+ }
1502
+ }
1503
+ if (input instanceof Uint8Array) {
1504
+ const result = this.encode(input);
1505
+ if (result instanceof Uint8Array) {
1506
+ return createDigest(result, this.code, options?.truncate);
1507
+ }
1508
+ return result.then((digest2) => createDigest(digest2, this.code, options?.truncate));
1509
+ } else {
1510
+ throw Error("Unknown type, must be binary type");
1511
+ }
1512
+ }
1513
+ };
1514
+ function createDigest(digest2, code2, truncate) {
1515
+ if (truncate != null && truncate !== digest2.byteLength) {
1516
+ if (truncate > digest2.byteLength) {
1517
+ throw new Error(`Invalid truncate option, must be less than or equal to ${digest2.byteLength}`);
1518
+ }
1519
+ digest2 = digest2.subarray(0, truncate);
1520
+ }
1521
+ return create(code2, digest2);
1522
+ }
1523
+
1524
+ // ../../node_modules/multiformats/dist/src/hashes/sha2.js
1525
+ var sha2562 = from2({
1526
+ name: "sha2-256",
1527
+ code: 18,
1528
+ encode: (input) => coerce(import_crypto.default.createHash("sha256").update(input).digest())
1529
+ });
1530
+ var sha512 = from2({
1531
+ name: "sha2-512",
1532
+ code: 19,
1533
+ encode: (input) => coerce(import_crypto.default.createHash("sha512").update(input).digest())
1534
+ });
1535
+
1536
+ // ../../node_modules/multiformats/dist/src/cid.js
1537
+ function format(link, base3) {
1538
+ const { bytes, version } = link;
1539
+ switch (version) {
1540
+ case 0:
1541
+ return toStringV0(bytes, baseCache(link), base3 ?? base58btc.encoder);
1542
+ default:
1543
+ return toStringV1(bytes, baseCache(link), base3 ?? base32.encoder);
1544
+ }
1545
+ }
1546
+ var cache = /* @__PURE__ */ new WeakMap();
1547
+ function baseCache(cid) {
1548
+ const baseCache2 = cache.get(cid);
1549
+ if (baseCache2 == null) {
1550
+ const baseCache3 = /* @__PURE__ */ new Map();
1551
+ cache.set(cid, baseCache3);
1552
+ return baseCache3;
1553
+ }
1554
+ return baseCache2;
1555
+ }
1556
+ var _a;
1557
+ var CID = class _CID {
1558
+ /**
1559
+ * @param version - Version of the CID
1560
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
1561
+ * @param multihash - (Multi)hash of the of the content.
1562
+ */
1563
+ constructor(version, code2, multihash, bytes) {
1564
+ __publicField(this, "code");
1565
+ __publicField(this, "version");
1566
+ __publicField(this, "multihash");
1567
+ __publicField(this, "bytes");
1568
+ __publicField(this, "/");
1569
+ __publicField(this, _a, "CID");
1570
+ this.code = code2;
1571
+ this.version = version;
1572
+ this.multihash = multihash;
1573
+ this.bytes = bytes;
1574
+ this["/"] = bytes;
1575
+ }
1576
+ /**
1577
+ * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
1578
+ * please either use `CID.asCID(cid)` or switch to new signalling mechanism
1579
+ *
1580
+ * @deprecated
1581
+ */
1582
+ get asCID() {
1583
+ return this;
1584
+ }
1585
+ // ArrayBufferView
1586
+ get byteOffset() {
1587
+ return this.bytes.byteOffset;
1588
+ }
1589
+ // ArrayBufferView
1590
+ get byteLength() {
1591
+ return this.bytes.byteLength;
1592
+ }
1593
+ toV0() {
1594
+ switch (this.version) {
1595
+ case 0: {
1596
+ return this;
1597
+ }
1598
+ case 1: {
1599
+ const { code: code2, multihash } = this;
1600
+ if (code2 !== DAG_PB_CODE) {
1601
+ throw new Error("Cannot convert a non dag-pb CID to CIDv0");
1602
+ }
1603
+ if (multihash.code !== SHA_256_CODE) {
1604
+ throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
1605
+ }
1606
+ return _CID.createV0(multihash);
1607
+ }
1608
+ default: {
1609
+ throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
1610
+ }
1611
+ }
1612
+ }
1613
+ toV1() {
1614
+ switch (this.version) {
1615
+ case 0: {
1616
+ const { code: code2, digest: digest2 } = this.multihash;
1617
+ const multihash = create(code2, digest2);
1618
+ return _CID.createV1(this.code, multihash);
1619
+ }
1620
+ case 1: {
1621
+ return this;
1622
+ }
1623
+ default: {
1624
+ throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
1625
+ }
1626
+ }
1627
+ }
1628
+ equals(other) {
1629
+ return _CID.equals(this, other);
1630
+ }
1631
+ static equals(self, other) {
1632
+ const unknown = other;
1633
+ return unknown != null && self.code === unknown.code && self.version === unknown.version && equals2(self.multihash, unknown.multihash);
1634
+ }
1635
+ toString(base3) {
1636
+ return format(this, base3);
1637
+ }
1638
+ toJSON() {
1639
+ return { "/": format(this) };
1640
+ }
1641
+ link() {
1642
+ return this;
1643
+ }
1644
+ // Legacy
1645
+ [(_a = Symbol.toStringTag, /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom"))]() {
1646
+ return `CID(${this.toString()})`;
1647
+ }
1648
+ /**
1649
+ * Takes any input `value` and returns a `CID` instance if it was
1650
+ * a `CID` otherwise returns `null`. If `value` is instanceof `CID`
1651
+ * it will return value back. If `value` is not instance of this CID
1652
+ * class, but is compatible CID it will return new instance of this
1653
+ * `CID` class. Otherwise returns null.
1654
+ *
1655
+ * This allows two different incompatible versions of CID library to
1656
+ * co-exist and interop as long as binary interface is compatible.
1657
+ */
1658
+ static asCID(input) {
1659
+ if (input == null) {
1660
+ return null;
1661
+ }
1662
+ const value = input;
1663
+ if (value instanceof _CID) {
1664
+ return value;
1665
+ } else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) {
1666
+ const { version, code: code2, multihash, bytes } = value;
1667
+ return new _CID(version, code2, multihash, bytes ?? encodeCID(version, code2, multihash.bytes));
1668
+ } else if (value[cidSymbol] === true) {
1669
+ const { version, multihash, code: code2 } = value;
1670
+ const digest2 = decode5(multihash);
1671
+ return _CID.create(version, code2, digest2);
1672
+ } else {
1673
+ return null;
1674
+ }
1675
+ }
1676
+ /**
1677
+ * @param version - Version of the CID
1678
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
1679
+ * @param digest - (Multi)hash of the of the content.
1680
+ */
1681
+ static create(version, code2, digest2) {
1682
+ if (typeof code2 !== "number") {
1683
+ throw new Error("String codecs are no longer supported");
1684
+ }
1685
+ if (!(digest2.bytes instanceof Uint8Array)) {
1686
+ throw new Error("Invalid digest");
1687
+ }
1688
+ switch (version) {
1689
+ case 0: {
1690
+ if (code2 !== DAG_PB_CODE) {
1691
+ throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
1692
+ } else {
1693
+ return new _CID(version, code2, digest2, digest2.bytes);
1694
+ }
1695
+ }
1696
+ case 1: {
1697
+ const bytes = encodeCID(version, code2, digest2.bytes);
1698
+ return new _CID(version, code2, digest2, bytes);
1699
+ }
1700
+ default: {
1701
+ throw new Error("Invalid version");
1702
+ }
1703
+ }
1704
+ }
1705
+ /**
1706
+ * Simplified version of `create` for CIDv0.
1707
+ */
1708
+ static createV0(digest2) {
1709
+ return _CID.create(0, DAG_PB_CODE, digest2);
1710
+ }
1711
+ /**
1712
+ * Simplified version of `create` for CIDv1.
1713
+ *
1714
+ * @param code - Content encoding format code.
1715
+ * @param digest - Multihash of the content.
1716
+ */
1717
+ static createV1(code2, digest2) {
1718
+ return _CID.create(1, code2, digest2);
1719
+ }
1720
+ /**
1721
+ * Decoded a CID from its binary representation. The byte array must contain
1722
+ * only the CID with no additional bytes.
1723
+ *
1724
+ * An error will be thrown if the bytes provided do not contain a valid
1725
+ * binary representation of a CID.
1726
+ */
1727
+ static decode(bytes) {
1728
+ const [cid, remainder] = _CID.decodeFirst(bytes);
1729
+ if (remainder.length !== 0) {
1730
+ throw new Error("Incorrect length");
1731
+ }
1732
+ return cid;
1733
+ }
1734
+ /**
1735
+ * Decoded a CID from its binary representation at the beginning of a byte
1736
+ * array.
1737
+ *
1738
+ * Returns an array with the first element containing the CID and the second
1739
+ * element containing the remainder of the original byte array. The remainder
1740
+ * will be a zero-length byte array if the provided bytes only contained a
1741
+ * binary CID representation.
1742
+ */
1743
+ static decodeFirst(bytes) {
1744
+ const specs = _CID.inspectBytes(bytes);
1745
+ const prefixSize = specs.size - specs.multihashSize;
1746
+ const multihashBytes = coerce(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
1747
+ if (multihashBytes.byteLength !== specs.multihashSize) {
1748
+ throw new Error("Incorrect length");
1749
+ }
1750
+ const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
1751
+ const digest2 = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
1752
+ const cid = specs.version === 0 ? _CID.createV0(digest2) : _CID.createV1(specs.codec, digest2);
1753
+ return [cid, bytes.subarray(specs.size)];
1754
+ }
1755
+ /**
1756
+ * Inspect the initial bytes of a CID to determine its properties.
1757
+ *
1758
+ * Involves decoding up to 4 varints. Typically this will require only 4 to 6
1759
+ * bytes but for larger multicodec code values and larger multihash digest
1760
+ * lengths these varints can be quite large. It is recommended that at least
1761
+ * 10 bytes be made available in the `initialBytes` argument for a complete
1762
+ * inspection.
1763
+ */
1764
+ static inspectBytes(initialBytes) {
1765
+ let offset = 0;
1766
+ const next = () => {
1767
+ const [i, length2] = decode4(initialBytes.subarray(offset));
1768
+ offset += length2;
1769
+ return i;
1770
+ };
1771
+ let version = next();
1772
+ let codec = DAG_PB_CODE;
1773
+ if (version === 18) {
1774
+ version = 0;
1775
+ offset = 0;
1776
+ } else {
1777
+ codec = next();
1778
+ }
1779
+ if (version !== 0 && version !== 1) {
1780
+ throw new RangeError(`Invalid CID version ${version}`);
1781
+ }
1782
+ const prefixSize = offset;
1783
+ const multihashCode = next();
1784
+ const digestSize = next();
1785
+ const size = offset + digestSize;
1786
+ const multihashSize = size - prefixSize;
1787
+ return { version, codec, multihashCode, digestSize, multihashSize, size };
1788
+ }
1789
+ /**
1790
+ * Takes cid in a string representation and creates an instance. If `base`
1791
+ * decoder is not provided will use a default from the configuration. It will
1792
+ * throw an error if encoding of the CID is not compatible with supplied (or
1793
+ * a default decoder).
1794
+ */
1795
+ static parse(source, base3) {
1796
+ const [prefix, bytes] = parseCIDtoBytes(source, base3);
1797
+ const cid = _CID.decode(bytes);
1798
+ if (cid.version === 0 && source[0] !== "Q") {
1799
+ throw Error("Version 0 CID string must not include multibase prefix");
1800
+ }
1801
+ baseCache(cid).set(prefix, source);
1802
+ return cid;
1803
+ }
1804
+ };
1805
+ function parseCIDtoBytes(source, base3) {
1806
+ switch (source[0]) {
1807
+ // CIDv0 is parsed differently
1808
+ case "Q": {
1809
+ const decoder = base3 ?? base58btc;
1810
+ return [
1811
+ base58btc.prefix,
1812
+ decoder.decode(`${base58btc.prefix}${source}`)
1813
+ ];
1814
+ }
1815
+ case base58btc.prefix: {
1816
+ const decoder = base3 ?? base58btc;
1817
+ return [base58btc.prefix, decoder.decode(source)];
1818
+ }
1819
+ case base32.prefix: {
1820
+ const decoder = base3 ?? base32;
1821
+ return [base32.prefix, decoder.decode(source)];
1822
+ }
1823
+ case base36.prefix: {
1824
+ const decoder = base3 ?? base36;
1825
+ return [base36.prefix, decoder.decode(source)];
1826
+ }
1827
+ default: {
1828
+ if (base3 == null) {
1829
+ throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");
1830
+ }
1831
+ return [source[0], base3.decode(source)];
1832
+ }
1833
+ }
1834
+ }
1835
+ function toStringV0(bytes, cache2, base3) {
1836
+ const { prefix } = base3;
1837
+ if (prefix !== base58btc.prefix) {
1838
+ throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
1839
+ }
1840
+ const cid = cache2.get(prefix);
1841
+ if (cid == null) {
1842
+ const cid2 = base3.encode(bytes).slice(1);
1843
+ cache2.set(prefix, cid2);
1844
+ return cid2;
1845
+ } else {
1846
+ return cid;
1847
+ }
1848
+ }
1849
+ function toStringV1(bytes, cache2, base3) {
1850
+ const { prefix } = base3;
1851
+ const cid = cache2.get(prefix);
1852
+ if (cid == null) {
1853
+ const cid2 = base3.encode(bytes);
1854
+ cache2.set(prefix, cid2);
1855
+ return cid2;
1856
+ } else {
1857
+ return cid;
1858
+ }
1859
+ }
1860
+ var DAG_PB_CODE = 112;
1861
+ var SHA_256_CODE = 18;
1862
+ function encodeCID(version, code2, multihash) {
1863
+ const codeOffset = encodingLength(version);
1864
+ const hashOffset = codeOffset + encodingLength(code2);
1865
+ const bytes = new Uint8Array(hashOffset + multihash.byteLength);
1866
+ encodeTo(version, bytes, 0);
1867
+ encodeTo(code2, bytes, codeOffset);
1868
+ bytes.set(multihash, hashOffset);
1869
+ return bytes;
1870
+ }
1871
+ var cidSymbol = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
1872
+
1873
+ // ../../node_modules/multiformats/dist/src/basics.js
1874
+ var bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
1875
+ var hashes = { ...sha2_exports, ...identity_exports2 };
1876
+
1877
+ // src/policy/signed-object.ts
720
1878
  var import_viem3 = require("viem");
721
1879
 
722
1880
  // src/identity.ts
@@ -784,7 +1942,7 @@ var DESCRIPTORS = {
784
1942
  domain: POLICY_ENGINE_RECORD_SCHEMA
785
1943
  }
786
1944
  };
787
- var textEncoder2 = new TextEncoder();
1945
+ var textEncoder3 = new TextEncoder();
788
1946
  var BASE32_ALPHABET = "abcdefghijklmnopqrstuvwxyz234567";
789
1947
  var BASE64URL_RE = /^[A-Za-z0-9_-]+$/;
790
1948
  var objectHasOwn3 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
@@ -1233,9 +2391,9 @@ function validateAudit(input, path) {
1233
2391
  }
1234
2392
  function materialForUnsigned(unsigned, descriptor) {
1235
2393
  const jcs = jcsCanonicalize(unsigned);
1236
- const jcsBytes = textEncoder2.encode(jcs);
1237
- const digest = sha256Bytes(concatBytes(textEncoder2.encode(`${descriptor.domain}\0`), jcsBytes));
1238
- const id = `${descriptor.idPrefix}${base32LowerNoPad(digest)}`;
2394
+ const jcsBytes = textEncoder3.encode(jcs);
2395
+ const digest2 = sha256Bytes(concatBytes(textEncoder3.encode(`${descriptor.domain}\0`), jcsBytes));
2396
+ const id = `${descriptor.idPrefix}${base32LowerNoPad(digest2)}`;
1239
2397
  return {
1240
2398
  kind: descriptor.kind,
1241
2399
  idField: descriptor.idField,
@@ -1244,8 +2402,8 @@ function materialForUnsigned(unsigned, descriptor) {
1244
2402
  unsigned,
1245
2403
  jcs,
1246
2404
  jcsBytes,
1247
- digest,
1248
- digestHex: (0, import_viem3.bytesToHex)(digest).slice(2)
2405
+ digest: digest2,
2406
+ digestHex: (0, import_viem3.bytesToHex)(digest2).slice(2)
1249
2407
  };
1250
2408
  }
1251
2409
  function assertIdMatches(signed, material, descriptor) {
@@ -1293,12 +2451,12 @@ function assertSignerDidMatchesSuite(signerDid, suite) {
1293
2451
  }
1294
2452
  throw new UnsupportedSignatureSuiteError(`unsupported signature suite: ${suite}`);
1295
2453
  }
1296
- async function verifySignature(signature, digest) {
2454
+ async function verifySignature(signature, digest2) {
1297
2455
  if (signature.suite === ED25519_JCS_SIGNATURE_SUITE) {
1298
2456
  const publicKey = ed25519PublicKeyFromDidKey(signature.signerDid);
1299
2457
  const signatureBytes = decodeSignatureValue(signature.value, signature.suite);
1300
2458
  try {
1301
- return import_ed25519.ed25519.verify(signatureBytes, digest, publicKey);
2459
+ return import_ed25519.ed25519.verify(signatureBytes, digest2, publicKey);
1302
2460
  } catch {
1303
2461
  throw new SignatureVerificationError("Ed25519 signature verification failed");
1304
2462
  }
@@ -1309,7 +2467,7 @@ async function verifySignature(signature, digest) {
1309
2467
  try {
1310
2468
  return (0, import_viem3.verifyMessage)({
1311
2469
  address: pkh.address,
1312
- message: { raw: digest },
2470
+ message: { raw: digest2 },
1313
2471
  signature: (0, import_viem3.bytesToHex)(signatureBytes)
1314
2472
  });
1315
2473
  } catch {
@@ -1328,7 +2486,7 @@ function ed25519PublicKeyFromDidKey(did) {
1328
2486
  }
1329
2487
  let bytes;
1330
2488
  try {
1331
- bytes = import_basics.bases.base58btc.decode(identifier);
2489
+ bytes = bases.base58btc.decode(identifier);
1332
2490
  } catch {
1333
2491
  throw new SignatureMaterialError("did:key signerDid is undecodable");
1334
2492
  }
@@ -1541,20 +2699,20 @@ function base32LowerNoPad(bytes) {
1541
2699
  return output;
1542
2700
  }
1543
2701
  function base64UrlEncode(bytes) {
1544
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
2702
+ const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1545
2703
  let output = "";
1546
2704
  for (let index = 0; index < bytes.length; index += 3) {
1547
2705
  const a = bytes[index];
1548
2706
  const b = bytes[index + 1];
1549
2707
  const c = bytes[index + 2];
1550
2708
  const triplet = a << 16 | (b ?? 0) << 8 | (c ?? 0);
1551
- output += alphabet[triplet >> 18 & 63];
1552
- output += alphabet[triplet >> 12 & 63];
2709
+ output += alphabet2[triplet >> 18 & 63];
2710
+ output += alphabet2[triplet >> 12 & 63];
1553
2711
  if (index + 1 < bytes.length) {
1554
- output += alphabet[triplet >> 6 & 63];
2712
+ output += alphabet2[triplet >> 6 & 63];
1555
2713
  }
1556
2714
  if (index + 2 < bytes.length) {
1557
- output += alphabet[triplet & 63];
2715
+ output += alphabet2[triplet & 63];
1558
2716
  }
1559
2717
  }
1560
2718
  return output;
@@ -1563,12 +2721,12 @@ function base64UrlDecode(value) {
1563
2721
  if (value.length % 4 === 1) {
1564
2722
  throw new SignatureMaterialError("signature value is not canonical base64url");
1565
2723
  }
1566
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
2724
+ const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1567
2725
  const bytes = [];
1568
2726
  let buffer = 0;
1569
2727
  let bits = 0;
1570
2728
  for (const char of value) {
1571
- const index = alphabet.indexOf(char);
2729
+ const index = alphabet2.indexOf(char);
1572
2730
  if (index < 0) {
1573
2731
  throw new SignatureMaterialError("signature value is not base64url");
1574
2732
  }
@@ -1603,10 +2761,10 @@ var OWNER_NODE_ENDPOINT_SCHEMA = "xyz.tinycloud.exchange/owner-node-endpoint/v1"
1603
2761
  var POLICY_VERSION_V0 = "v0";
1604
2762
  var W3C_VC_CREDENTIAL_VERIFIER = "w3c.vc/credential/v1";
1605
2763
  var PolicyAuthoringError = class extends Error {
1606
- constructor(code, message) {
2764
+ constructor(code2, message) {
1607
2765
  super(message);
1608
2766
  this.name = "PolicyAuthoringError";
1609
- this.code = code;
2767
+ this.code = code2;
1610
2768
  }
1611
2769
  };
1612
2770
  async function createAndSignTranscriptSharePolicy(input, signer) {
@@ -1910,11 +3068,11 @@ async function verifyPolicyEngineRecordForRequester(options) {
1910
3068
  }
1911
3069
  return verified;
1912
3070
  }
1913
- function expectObject2(input, path, code) {
3071
+ function expectObject2(input, path, code2) {
1914
3072
  try {
1915
3073
  const normalized = normalizeJson(input);
1916
3074
  if (normalized === null || typeof normalized !== "object" || Array.isArray(normalized)) {
1917
- throw new PolicyAuthoringError(code, `${path} must be an object`);
3075
+ throw new PolicyAuthoringError(code2, `${path} must be an object`);
1918
3076
  }
1919
3077
  return normalized;
1920
3078
  } catch (error) {
@@ -1922,7 +3080,7 @@ function expectObject2(input, path, code) {
1922
3080
  throw error;
1923
3081
  }
1924
3082
  throw new PolicyAuthoringError(
1925
- code,
3083
+ code2,
1926
3084
  error instanceof Error ? error.message : String(error)
1927
3085
  );
1928
3086
  }
@@ -1973,14 +3131,14 @@ function requiredString3(object, key, path) {
1973
3131
  }
1974
3132
  return value;
1975
3133
  }
1976
- function fieldString(object, key, path, code) {
3134
+ function fieldString(object, key, path, code2) {
1977
3135
  if (!hasOwn3(object, key)) {
1978
- throw new PolicyAuthoringError(code, `${path}.${key} is required`);
3136
+ throw new PolicyAuthoringError(code2, `${path}.${key} is required`);
1979
3137
  }
1980
3138
  const value = object[key];
1981
3139
  if (typeof value !== "string" || value.length === 0) {
1982
3140
  throw new PolicyAuthoringError(
1983
- code,
3141
+ code2,
1984
3142
  `${path}.${key} must be a non-empty string`
1985
3143
  );
1986
3144
  }