shogun-core 3.3.2 → 3.3.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.
@@ -0,0 +1,4908 @@
1
+ "use strict";
2
+ (this["webpackChunkShogunCore"] = this["webpackChunkShogunCore"] || []).push([["defaultVendors-node_modules_shogun-ipfs_node_modules_is-ipfs_dist_src_index_js"],{
3
+
4
+ /***/ "./node_modules/shogun-ipfs/node_modules/is-ipfs/dist/src/index.js":
5
+ /*!**************************************************************************************!*\
6
+ !*** ./node_modules/shogun-ipfs/node_modules/is-ipfs/dist/src/index.js + 57 modules ***!
7
+ \**************************************************************************************/
8
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9
+
10
+ // ESM COMPAT FLAG
11
+ __webpack_require__.r(__webpack_exports__);
12
+
13
+ // EXPORTS
14
+ __webpack_require__.d(__webpack_exports__, {
15
+ base32cid: () => (/* binding */ base32cid),
16
+ cid: () => (/* binding */ isCID),
17
+ cidPath: () => (/* binding */ cidPath),
18
+ ipfsPath: () => (/* binding */ ipfsPath),
19
+ ipfsSubdomain: () => (/* binding */ ipfsSubdomain),
20
+ ipfsUrl: () => (/* binding */ ipfsUrl),
21
+ ipnsPath: () => (/* binding */ ipnsPath),
22
+ ipnsSubdomain: () => (/* binding */ ipnsSubdomain),
23
+ ipnsUrl: () => (/* binding */ ipnsUrl),
24
+ multiaddr: () => (/* binding */ src_isMultiaddr),
25
+ multihash: () => (/* binding */ isMultihash),
26
+ path: () => (/* binding */ path),
27
+ pathGatewayPattern: () => (/* binding */ pathGatewayPattern),
28
+ pathPattern: () => (/* binding */ pathPattern),
29
+ peerMultiaddr: () => (/* binding */ isPeerMultiaddr),
30
+ subdomain: () => (/* binding */ subdomain),
31
+ subdomainGatewayPattern: () => (/* binding */ subdomainGatewayPattern),
32
+ url: () => (/* binding */ url),
33
+ urlOrPath: () => (/* binding */ urlOrPath)
34
+ });
35
+
36
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base32.js
37
+ var base32_namespaceObject = {};
38
+ __webpack_require__.r(base32_namespaceObject);
39
+ __webpack_require__.d(base32_namespaceObject, {
40
+ base32: () => (base32),
41
+ base32hex: () => (base32hex),
42
+ base32hexpad: () => (base32hexpad),
43
+ base32hexpadupper: () => (base32hexpadupper),
44
+ base32hexupper: () => (base32hexupper),
45
+ base32pad: () => (base32pad),
46
+ base32padupper: () => (base32padupper),
47
+ base32upper: () => (base32upper),
48
+ base32z: () => (base32z)
49
+ });
50
+
51
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base58.js
52
+ var base58_namespaceObject = {};
53
+ __webpack_require__.r(base58_namespaceObject);
54
+ __webpack_require__.d(base58_namespaceObject, {
55
+ base58btc: () => (base58btc),
56
+ base58flickr: () => (base58flickr)
57
+ });
58
+
59
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base10.js
60
+ var base10_namespaceObject = {};
61
+ __webpack_require__.r(base10_namespaceObject);
62
+ __webpack_require__.d(base10_namespaceObject, {
63
+ base10: () => (base10)
64
+ });
65
+
66
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base16.js
67
+ var base16_namespaceObject = {};
68
+ __webpack_require__.r(base16_namespaceObject);
69
+ __webpack_require__.d(base16_namespaceObject, {
70
+ base16: () => (base16),
71
+ base16upper: () => (base16upper)
72
+ });
73
+
74
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base2.js
75
+ var base2_namespaceObject = {};
76
+ __webpack_require__.r(base2_namespaceObject);
77
+ __webpack_require__.d(base2_namespaceObject, {
78
+ base2: () => (base2)
79
+ });
80
+
81
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base256emoji.js
82
+ var base256emoji_namespaceObject = {};
83
+ __webpack_require__.r(base256emoji_namespaceObject);
84
+ __webpack_require__.d(base256emoji_namespaceObject, {
85
+ base256emoji: () => (base256emoji)
86
+ });
87
+
88
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base36.js
89
+ var base36_namespaceObject = {};
90
+ __webpack_require__.r(base36_namespaceObject);
91
+ __webpack_require__.d(base36_namespaceObject, {
92
+ base36: () => (base36),
93
+ base36upper: () => (base36upper)
94
+ });
95
+
96
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base64.js
97
+ var base64_namespaceObject = {};
98
+ __webpack_require__.r(base64_namespaceObject);
99
+ __webpack_require__.d(base64_namespaceObject, {
100
+ base64: () => (base64),
101
+ base64pad: () => (base64pad),
102
+ base64url: () => (base64url),
103
+ base64urlpad: () => (base64urlpad)
104
+ });
105
+
106
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base8.js
107
+ var base8_namespaceObject = {};
108
+ __webpack_require__.r(base8_namespaceObject);
109
+ __webpack_require__.d(base8_namespaceObject, {
110
+ base8: () => (base8)
111
+ });
112
+
113
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/identity.js
114
+ var identity_namespaceObject = {};
115
+ __webpack_require__.r(identity_namespaceObject);
116
+ __webpack_require__.d(identity_namespaceObject, {
117
+ identity: () => (identity)
118
+ });
119
+
120
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/json.js
121
+ var json_namespaceObject = {};
122
+ __webpack_require__.r(json_namespaceObject);
123
+ __webpack_require__.d(json_namespaceObject, {
124
+ code: () => (code),
125
+ decode: () => (json_decode),
126
+ encode: () => (json_encode),
127
+ name: () => (json_name)
128
+ });
129
+
130
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/raw.js
131
+ var raw_namespaceObject = {};
132
+ __webpack_require__.r(raw_namespaceObject);
133
+ __webpack_require__.d(raw_namespaceObject, {
134
+ code: () => (raw_code),
135
+ decode: () => (raw_decode),
136
+ encode: () => (raw_encode),
137
+ name: () => (raw_name)
138
+ });
139
+
140
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/identity.js
141
+ var hashes_identity_namespaceObject = {};
142
+ __webpack_require__.r(hashes_identity_namespaceObject);
143
+ __webpack_require__.d(hashes_identity_namespaceObject, {
144
+ identity: () => (identity_identity)
145
+ });
146
+
147
+ // NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/sha2-browser.js
148
+ var sha2_browser_namespaceObject = {};
149
+ __webpack_require__.r(sha2_browser_namespaceObject);
150
+ __webpack_require__.d(sha2_browser_namespaceObject, {
151
+ sha256: () => (sha256),
152
+ sha512: () => (sha512)
153
+ });
154
+
155
+ // EXTERNAL MODULE: ./node_modules/shogun-ipfs/node_modules/uint8-varint/dist/src/index.js
156
+ var src = __webpack_require__("./node_modules/shogun-ipfs/node_modules/uint8-varint/dist/src/index.js");
157
+ // EXTERNAL MODULE: ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/concat.js + 1 modules
158
+ var concat = __webpack_require__("./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/concat.js");
159
+ // EXTERNAL MODULE: ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/to-string.js
160
+ var to_string = __webpack_require__("./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/to-string.js");
161
+ ;// ./node_modules/shogun-ipfs/node_modules/@chainsafe/is-ip/lib/parser.js
162
+ /* eslint-disable @typescript-eslint/no-unsafe-return */
163
+ class Parser {
164
+ index = 0;
165
+ input = "";
166
+ new(input) {
167
+ this.index = 0;
168
+ this.input = input;
169
+ return this;
170
+ }
171
+ /** Run a parser, and restore the pre-parse state if it fails. */
172
+ readAtomically(fn) {
173
+ const index = this.index;
174
+ const result = fn();
175
+ if (result === undefined) {
176
+ this.index = index;
177
+ }
178
+ return result;
179
+ }
180
+ /** Run a parser, but fail if the entire input wasn't consumed. Doesn't run atomically. */
181
+ parseWith(fn) {
182
+ const result = fn();
183
+ if (this.index !== this.input.length) {
184
+ return undefined;
185
+ }
186
+ return result;
187
+ }
188
+ /** Peek the next character from the input */
189
+ peekChar() {
190
+ if (this.index >= this.input.length) {
191
+ return undefined;
192
+ }
193
+ return this.input[this.index];
194
+ }
195
+ /** Read the next character from the input */
196
+ readChar() {
197
+ if (this.index >= this.input.length) {
198
+ return undefined;
199
+ }
200
+ return this.input[this.index++];
201
+ }
202
+ /** Read the next character from the input if it matches the target. */
203
+ readGivenChar(target) {
204
+ return this.readAtomically(() => {
205
+ const char = this.readChar();
206
+ if (char !== target) {
207
+ return undefined;
208
+ }
209
+ return char;
210
+ });
211
+ }
212
+ /**
213
+ * Helper for reading separators in an indexed loop. Reads the separator
214
+ * character iff index > 0, then runs the parser. When used in a loop,
215
+ * the separator character will only be read on index > 0 (see
216
+ * readIPv4Addr for an example)
217
+ */
218
+ readSeparator(sep, index, inner) {
219
+ return this.readAtomically(() => {
220
+ if (index > 0) {
221
+ if (this.readGivenChar(sep) === undefined) {
222
+ return undefined;
223
+ }
224
+ }
225
+ return inner();
226
+ });
227
+ }
228
+ /**
229
+ * Read a number off the front of the input in the given radix, stopping
230
+ * at the first non-digit character or eof. Fails if the number has more
231
+ * digits than max_digits or if there is no number.
232
+ */
233
+ readNumber(radix, maxDigits, allowZeroPrefix, maxBytes) {
234
+ return this.readAtomically(() => {
235
+ let result = 0;
236
+ let digitCount = 0;
237
+ const leadingChar = this.peekChar();
238
+ if (leadingChar === undefined) {
239
+ return undefined;
240
+ }
241
+ const hasLeadingZero = leadingChar === "0";
242
+ const maxValue = 2 ** (8 * maxBytes) - 1;
243
+ // eslint-disable-next-line no-constant-condition
244
+ while (true) {
245
+ const digit = this.readAtomically(() => {
246
+ const char = this.readChar();
247
+ if (char === undefined) {
248
+ return undefined;
249
+ }
250
+ const num = Number.parseInt(char, radix);
251
+ if (Number.isNaN(num)) {
252
+ return undefined;
253
+ }
254
+ return num;
255
+ });
256
+ if (digit === undefined) {
257
+ break;
258
+ }
259
+ result *= radix;
260
+ result += digit;
261
+ if (result > maxValue) {
262
+ return undefined;
263
+ }
264
+ digitCount += 1;
265
+ if (maxDigits !== undefined) {
266
+ if (digitCount > maxDigits) {
267
+ return undefined;
268
+ }
269
+ }
270
+ }
271
+ if (digitCount === 0) {
272
+ return undefined;
273
+ }
274
+ else if (!allowZeroPrefix && hasLeadingZero && digitCount > 1) {
275
+ return undefined;
276
+ }
277
+ else {
278
+ return result;
279
+ }
280
+ });
281
+ }
282
+ /** Read an IPv4 address. */
283
+ readIPv4Addr() {
284
+ return this.readAtomically(() => {
285
+ const out = new Uint8Array(4);
286
+ for (let i = 0; i < out.length; i++) {
287
+ const ix = this.readSeparator(".", i, () => this.readNumber(10, 3, false, 1));
288
+ if (ix === undefined) {
289
+ return undefined;
290
+ }
291
+ out[i] = ix;
292
+ }
293
+ return out;
294
+ });
295
+ }
296
+ /** Read an IPv6 Address. */
297
+ readIPv6Addr() {
298
+ /**
299
+ * Read a chunk of an IPv6 address into `groups`. Returns the number
300
+ * of groups read, along with a bool indicating if an embedded
301
+ * trailing IPv4 address was read. Specifically, read a series of
302
+ * colon-separated IPv6 groups (0x0000 - 0xFFFF), with an optional
303
+ * trailing embedded IPv4 address.
304
+ */
305
+ const readGroups = (groups) => {
306
+ for (let i = 0; i < groups.length / 2; i++) {
307
+ const ix = i * 2;
308
+ // Try to read a trailing embedded IPv4 address. There must be at least 4 groups left.
309
+ if (i < groups.length - 3) {
310
+ const ipv4 = this.readSeparator(":", i, () => this.readIPv4Addr());
311
+ if (ipv4 !== undefined) {
312
+ groups[ix] = ipv4[0];
313
+ groups[ix + 1] = ipv4[1];
314
+ groups[ix + 2] = ipv4[2];
315
+ groups[ix + 3] = ipv4[3];
316
+ return [ix + 4, true];
317
+ }
318
+ }
319
+ const group = this.readSeparator(":", i, () => this.readNumber(16, 4, true, 2));
320
+ if (group === undefined) {
321
+ return [ix, false];
322
+ }
323
+ groups[ix] = group >> 8;
324
+ groups[ix + 1] = group & 255;
325
+ }
326
+ return [groups.length, false];
327
+ };
328
+ return this.readAtomically(() => {
329
+ // Read the front part of the address; either the whole thing, or up to the first ::
330
+ const head = new Uint8Array(16);
331
+ const [headSize, headIp4] = readGroups(head);
332
+ if (headSize === 16) {
333
+ return head;
334
+ }
335
+ // IPv4 part is not allowed before `::`
336
+ if (headIp4) {
337
+ return undefined;
338
+ }
339
+ // Read `::` if previous code parsed less than 8 groups.
340
+ // `::` indicates one or more groups of 16 bits of zeros.
341
+ if (this.readGivenChar(":") === undefined) {
342
+ return undefined;
343
+ }
344
+ if (this.readGivenChar(":") === undefined) {
345
+ return undefined;
346
+ }
347
+ // Read the back part of the address. The :: must contain at least one
348
+ // set of zeroes, so our max length is 7.
349
+ const tail = new Uint8Array(14);
350
+ const limit = 16 - (headSize + 2);
351
+ const [tailSize] = readGroups(tail.subarray(0, limit));
352
+ // Concat the head and tail of the IP address
353
+ head.set(tail.subarray(0, tailSize), 16 - tailSize);
354
+ return head;
355
+ });
356
+ }
357
+ /** Read an IP Address, either IPv4 or IPv6. */
358
+ readIPAddr() {
359
+ return this.readIPv4Addr() ?? this.readIPv6Addr();
360
+ }
361
+ }
362
+ //# sourceMappingURL=parser.js.map
363
+ ;// ./node_modules/shogun-ipfs/node_modules/@chainsafe/is-ip/lib/parse.js
364
+
365
+ // See https://stackoverflow.com/questions/166132/maximum-length-of-the-textual-representation-of-an-ipv6-address
366
+ const MAX_IPV6_LENGTH = 45;
367
+ const MAX_IPV4_LENGTH = 15;
368
+ const parser = new Parser();
369
+ /** Parse `input` into IPv4 bytes. */
370
+ function parseIPv4(input) {
371
+ if (input.length > MAX_IPV4_LENGTH) {
372
+ return undefined;
373
+ }
374
+ return parser.new(input).parseWith(() => parser.readIPv4Addr());
375
+ }
376
+ /** Parse IPv4 `input` into IPv6 with IPv4-mapped bytes, eg ::ffff:1.2.3.4 */
377
+ function parseIPv4Mapped(input) {
378
+ if (input.length > MAX_IPV4_LENGTH) {
379
+ return undefined;
380
+ }
381
+ const ipv4 = parser.new(input).parseWith(() => parser.readIPv4Addr());
382
+ if (ipv4 === undefined) {
383
+ return undefined;
384
+ }
385
+ return Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, ipv4[0], ipv4[1], ipv4[2], ipv4[3]]);
386
+ }
387
+ /** Parse `input` into IPv6 bytes. */
388
+ function parseIPv6(input) {
389
+ // strip zone index if it is present
390
+ if (input.includes("%")) {
391
+ input = input.split("%")[0];
392
+ }
393
+ if (input.length > MAX_IPV6_LENGTH) {
394
+ return undefined;
395
+ }
396
+ return parser.new(input).parseWith(() => parser.readIPv6Addr());
397
+ }
398
+ /** Parse `input` into IPv4 or IPv6 bytes. */
399
+ function parseIP(input, mapIPv4ToIPv6 = false) {
400
+ // strip zone index if it is present
401
+ if (input.includes("%")) {
402
+ input = input.split("%")[0];
403
+ }
404
+ if (input.length > MAX_IPV6_LENGTH) {
405
+ return undefined;
406
+ }
407
+ const addr = parser.new(input).parseWith(() => parser.readIPAddr());
408
+ if (!addr) {
409
+ return undefined;
410
+ }
411
+ if (mapIPv4ToIPv6 && addr.length === 4) {
412
+ return Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, addr[0], addr[1], addr[2], addr[3]]);
413
+ }
414
+ return addr;
415
+ }
416
+ //# sourceMappingURL=parse.js.map
417
+ ;// ./node_modules/shogun-ipfs/node_modules/@chainsafe/netmask/dist/src/util.js
418
+
419
+ function allFF(a, from, to) {
420
+ let i = 0;
421
+ for (const e of a) {
422
+ if (i < from)
423
+ continue;
424
+ if (i > to)
425
+ break;
426
+ if (e !== 0xff)
427
+ return false;
428
+ i++;
429
+ }
430
+ return true;
431
+ }
432
+ function deepEqual(a, b, from, to) {
433
+ let i = 0;
434
+ for (const e of a) {
435
+ if (i < from)
436
+ continue;
437
+ if (i > to)
438
+ break;
439
+ if (e !== b[i])
440
+ return false;
441
+ i++;
442
+ }
443
+ return true;
444
+ }
445
+ /***
446
+ * Returns long ip format
447
+ */
448
+ function ipToString(ip) {
449
+ switch (ip.length) {
450
+ case IPv4Len: {
451
+ return ip.join(".");
452
+ }
453
+ case IPv6Len: {
454
+ const result = [];
455
+ for (let i = 0; i < ip.length; i++) {
456
+ if (i % 2 === 0) {
457
+ result.push(ip[i].toString(16).padStart(2, "0") +
458
+ ip[i + 1].toString(16).padStart(2, "0"));
459
+ }
460
+ }
461
+ return result.join(":");
462
+ }
463
+ default: {
464
+ throw new Error("Invalid ip length");
465
+ }
466
+ }
467
+ }
468
+ /**
469
+ * If mask is a sequence of 1 bits followed by 0 bits, return number of 1 bits else -1
470
+ */
471
+ function simpleMaskLength(mask) {
472
+ let ones = 0;
473
+ // eslint-disable-next-line prefer-const
474
+ for (let [index, byte] of mask.entries()) {
475
+ if (byte === 0xff) {
476
+ ones += 8;
477
+ continue;
478
+ }
479
+ while ((byte & 0x80) != 0) {
480
+ ones++;
481
+ byte = byte << 1;
482
+ }
483
+ if ((byte & 0x80) != 0) {
484
+ return -1;
485
+ }
486
+ for (let i = index + 1; i < mask.length; i++) {
487
+ if (mask[i] != 0) {
488
+ return -1;
489
+ }
490
+ }
491
+ break;
492
+ }
493
+ return ones;
494
+ }
495
+ function maskToHex(mask) {
496
+ let hex = "0x";
497
+ for (const byte of mask) {
498
+ hex += (byte >> 4).toString(16) + (byte & 0x0f).toString(16);
499
+ }
500
+ return hex;
501
+ }
502
+ //# sourceMappingURL=util.js.map
503
+ ;// ./node_modules/shogun-ipfs/node_modules/@chainsafe/netmask/dist/src/ip.js
504
+
505
+
506
+ const IPv4Len = 4;
507
+ const IPv6Len = 16;
508
+ const maxIPv6Octet = parseInt("0xFFFF", 16);
509
+ const ipv4Prefix = new Uint8Array([
510
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255,
511
+ ]);
512
+ function maskIp(ip, mask) {
513
+ if (mask.length === IPv6Len && ip.length === IPv4Len && allFF(mask, 0, 11)) {
514
+ mask = mask.slice(12);
515
+ }
516
+ if (mask.length === IPv4Len &&
517
+ ip.length === IPv6Len &&
518
+ deepEqual(ip, ipv4Prefix, 0, 11)) {
519
+ ip = ip.slice(12);
520
+ }
521
+ const n = ip.length;
522
+ if (n != mask.length) {
523
+ throw new Error("Failed to mask ip");
524
+ }
525
+ const out = new Uint8Array(n);
526
+ for (let i = 0; i < n; i++) {
527
+ out[i] = ip[i] & mask[i];
528
+ }
529
+ return out;
530
+ }
531
+ function containsIp(net, ip) {
532
+ if (typeof ip === "string") {
533
+ ip = parseIP(ip);
534
+ }
535
+ if (ip == null)
536
+ throw new Error("Invalid ip");
537
+ if (ip.length !== net.network.length) {
538
+ return false;
539
+ }
540
+ for (let i = 0; i < ip.length; i++) {
541
+ if ((net.network[i] & net.mask[i]) !== (ip[i] & net.mask[i])) {
542
+ return false;
543
+ }
544
+ }
545
+ return true;
546
+ }
547
+ function iPv4FromIPv6(ip) {
548
+ if (!isIPv4mappedIPv6(ip)) {
549
+ throw new Error("Must have 0xffff prefix");
550
+ }
551
+ return ip.slice(12);
552
+ }
553
+ function isIPv4mappedIPv6(ip) {
554
+ return deepEqual(ip, ipv4Prefix, 0, 11);
555
+ }
556
+ //# sourceMappingURL=ip.js.map
557
+ ;// ./node_modules/shogun-ipfs/node_modules/@chainsafe/netmask/dist/src/cidr.js
558
+
559
+
560
+ function parseCidr(s) {
561
+ const [address, maskString] = s.split("/");
562
+ if (!address || !maskString)
563
+ throw new Error("Failed to parse given CIDR: " + s);
564
+ let ipLength = IPv4Len;
565
+ let ip = parseIPv4(address);
566
+ if (ip == null) {
567
+ ipLength = IPv6Len;
568
+ ip = parseIPv6(address);
569
+ if (ip == null)
570
+ throw new Error("Failed to parse given CIDR: " + s);
571
+ }
572
+ const m = parseInt(maskString, 10);
573
+ if (Number.isNaN(m) ||
574
+ String(m).length !== maskString.length ||
575
+ m < 0 ||
576
+ m > ipLength * 8) {
577
+ throw new Error("Failed to parse given CIDR: " + s);
578
+ }
579
+ const mask = cidrMask(m, 8 * ipLength);
580
+ return {
581
+ network: maskIp(ip, mask),
582
+ mask,
583
+ };
584
+ }
585
+ function cidrMask(ones, bits) {
586
+ if (bits !== 8 * IPv4Len && bits !== 8 * IPv6Len)
587
+ throw new Error("Invalid CIDR mask");
588
+ if (ones < 0 || ones > bits)
589
+ throw new Error("Invalid CIDR mask");
590
+ const l = bits / 8;
591
+ const m = new Uint8Array(l);
592
+ for (let i = 0; i < l; i++) {
593
+ if (ones >= 8) {
594
+ m[i] = 0xff;
595
+ ones -= 8;
596
+ continue;
597
+ }
598
+ m[i] = 255 - (0xff >> ones);
599
+ ones = 0;
600
+ }
601
+ return m;
602
+ }
603
+ //# sourceMappingURL=cidr.js.map
604
+ ;// ./node_modules/shogun-ipfs/node_modules/@chainsafe/netmask/dist/src/ipnet.js
605
+
606
+
607
+
608
+
609
+ class IpNet {
610
+ /**
611
+ *
612
+ * @param ipOrCidr either network ip or full cidr address
613
+ * @param mask in case ipOrCidr is network this can be either mask in decimal format or as ip address
614
+ */
615
+ constructor(ipOrCidr, mask) {
616
+ if (mask == null) {
617
+ ({ network: this.network, mask: this.mask } = parseCidr(ipOrCidr));
618
+ }
619
+ else {
620
+ const ipResult = parseIP(ipOrCidr);
621
+ if (ipResult == null) {
622
+ throw new Error("Failed to parse network");
623
+ }
624
+ mask = String(mask);
625
+ const m = parseInt(mask, 10);
626
+ if (Number.isNaN(m) ||
627
+ String(m).length !== mask.length ||
628
+ m < 0 ||
629
+ m > ipResult.length * 8) {
630
+ const maskResult = parseIP(mask);
631
+ if (maskResult == null) {
632
+ throw new Error("Failed to parse mask");
633
+ }
634
+ this.mask = maskResult;
635
+ }
636
+ else {
637
+ this.mask = cidrMask(m, 8 * ipResult.length);
638
+ }
639
+ this.network = maskIp(ipResult, this.mask);
640
+ }
641
+ }
642
+ /**
643
+ * Checks if netmask contains ip address
644
+ * @param ip
645
+ * @returns
646
+ */
647
+ contains(ip) {
648
+ return containsIp({ network: this.network, mask: this.mask }, ip);
649
+ }
650
+ /**Serializes back to string format */
651
+ toString() {
652
+ const l = simpleMaskLength(this.mask);
653
+ const mask = l !== -1 ? String(l) : maskToHex(this.mask);
654
+ return ipToString(this.network) + "/" + mask;
655
+ }
656
+ }
657
+ //# sourceMappingURL=ipnet.js.map
658
+ ;// ./node_modules/shogun-ipfs/node_modules/@chainsafe/netmask/dist/src/index.js
659
+
660
+
661
+
662
+
663
+
664
+ /**
665
+ * Checks if cidr block contains ip address
666
+ * @param cidr ipv4 or ipv6 formatted cidr . Example 198.51.100.14/24 or 2001:db8::/48
667
+ * @param ip ipv4 or ipv6 address Example 198.51.100.14 or 2001:db8::
668
+ *
669
+ */
670
+ function cidrContains(cidr, ip) {
671
+ const ipnet = new IpNet(cidr);
672
+ return ipnet.contains(ip);
673
+ }
674
+ //# sourceMappingURL=index.js.map
675
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bytes.js
676
+ const empty = new Uint8Array(0);
677
+ function toHex(d) {
678
+ return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '');
679
+ }
680
+ function fromHex(hex) {
681
+ const hexes = hex.match(/../g);
682
+ return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty;
683
+ }
684
+ function equals(aa, bb) {
685
+ if (aa === bb)
686
+ return true;
687
+ if (aa.byteLength !== bb.byteLength) {
688
+ return false;
689
+ }
690
+ for (let ii = 0; ii < aa.byteLength; ii++) {
691
+ if (aa[ii] !== bb[ii]) {
692
+ return false;
693
+ }
694
+ }
695
+ return true;
696
+ }
697
+ function coerce(o) {
698
+ if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')
699
+ return o;
700
+ if (o instanceof ArrayBuffer)
701
+ return new Uint8Array(o);
702
+ if (ArrayBuffer.isView(o)) {
703
+ return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
704
+ }
705
+ throw new Error('Unknown type, must be binary type');
706
+ }
707
+ function isBinary(o) {
708
+ return o instanceof ArrayBuffer || ArrayBuffer.isView(o);
709
+ }
710
+ function fromString(str) {
711
+ return new TextEncoder().encode(str);
712
+ }
713
+ function bytes_toString(b) {
714
+ return new TextDecoder().decode(b);
715
+ }
716
+ //# sourceMappingURL=bytes.js.map
717
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/base-x.js
718
+ /* eslint-disable */
719
+ // base-x encoding / decoding
720
+ // Copyright (c) 2018 base-x contributors
721
+ // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
722
+ // Distributed under the MIT software license, see the accompanying
723
+ // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
724
+ /**
725
+ * @param {string} ALPHABET
726
+ * @param {any} name
727
+ */
728
+ function base(ALPHABET, name) {
729
+ if (ALPHABET.length >= 255) {
730
+ throw new TypeError('Alphabet too long');
731
+ }
732
+ var BASE_MAP = new Uint8Array(256);
733
+ for (var j = 0; j < BASE_MAP.length; j++) {
734
+ BASE_MAP[j] = 255;
735
+ }
736
+ for (var i = 0; i < ALPHABET.length; i++) {
737
+ var x = ALPHABET.charAt(i);
738
+ var xc = x.charCodeAt(0);
739
+ if (BASE_MAP[xc] !== 255) {
740
+ throw new TypeError(x + ' is ambiguous');
741
+ }
742
+ BASE_MAP[xc] = i;
743
+ }
744
+ var BASE = ALPHABET.length;
745
+ var LEADER = ALPHABET.charAt(0);
746
+ var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
747
+ var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
748
+ /**
749
+ * @param {any[] | Iterable<number>} source
750
+ */
751
+ function encode(source) {
752
+ // @ts-ignore
753
+ if (source instanceof Uint8Array)
754
+ ;
755
+ else if (ArrayBuffer.isView(source)) {
756
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
757
+ }
758
+ else if (Array.isArray(source)) {
759
+ source = Uint8Array.from(source);
760
+ }
761
+ if (!(source instanceof Uint8Array)) {
762
+ throw new TypeError('Expected Uint8Array');
763
+ }
764
+ if (source.length === 0) {
765
+ return '';
766
+ }
767
+ // Skip & count leading zeroes.
768
+ var zeroes = 0;
769
+ var length = 0;
770
+ var pbegin = 0;
771
+ var pend = source.length;
772
+ while (pbegin !== pend && source[pbegin] === 0) {
773
+ pbegin++;
774
+ zeroes++;
775
+ }
776
+ // Allocate enough space in big-endian base58 representation.
777
+ var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
778
+ var b58 = new Uint8Array(size);
779
+ // Process the bytes.
780
+ while (pbegin !== pend) {
781
+ var carry = source[pbegin];
782
+ // Apply "b58 = b58 * 256 + ch".
783
+ var i = 0;
784
+ for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
785
+ carry += (256 * b58[it1]) >>> 0;
786
+ b58[it1] = (carry % BASE) >>> 0;
787
+ carry = (carry / BASE) >>> 0;
788
+ }
789
+ if (carry !== 0) {
790
+ throw new Error('Non-zero carry');
791
+ }
792
+ length = i;
793
+ pbegin++;
794
+ }
795
+ // Skip leading zeroes in base58 result.
796
+ var it2 = size - length;
797
+ while (it2 !== size && b58[it2] === 0) {
798
+ it2++;
799
+ }
800
+ // Translate the result into a string.
801
+ var str = LEADER.repeat(zeroes);
802
+ for (; it2 < size; ++it2) {
803
+ str += ALPHABET.charAt(b58[it2]);
804
+ }
805
+ return str;
806
+ }
807
+ /**
808
+ * @param {string | string[]} source
809
+ */
810
+ function decodeUnsafe(source) {
811
+ if (typeof source !== 'string') {
812
+ throw new TypeError('Expected String');
813
+ }
814
+ if (source.length === 0) {
815
+ return new Uint8Array();
816
+ }
817
+ var psz = 0;
818
+ // Skip leading spaces.
819
+ if (source[psz] === ' ') {
820
+ return;
821
+ }
822
+ // Skip and count leading '1's.
823
+ var zeroes = 0;
824
+ var length = 0;
825
+ while (source[psz] === LEADER) {
826
+ zeroes++;
827
+ psz++;
828
+ }
829
+ // Allocate enough space in big-endian base256 representation.
830
+ var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
831
+ var b256 = new Uint8Array(size);
832
+ // Process the characters.
833
+ while (source[psz]) {
834
+ // Decode character
835
+ var carry = BASE_MAP[source.charCodeAt(psz)];
836
+ // Invalid character
837
+ if (carry === 255) {
838
+ return;
839
+ }
840
+ var i = 0;
841
+ for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
842
+ carry += (BASE * b256[it3]) >>> 0;
843
+ b256[it3] = (carry % 256) >>> 0;
844
+ carry = (carry / 256) >>> 0;
845
+ }
846
+ if (carry !== 0) {
847
+ throw new Error('Non-zero carry');
848
+ }
849
+ length = i;
850
+ psz++;
851
+ }
852
+ // Skip trailing spaces.
853
+ if (source[psz] === ' ') {
854
+ return;
855
+ }
856
+ // Skip leading zeroes in b256.
857
+ var it4 = size - length;
858
+ while (it4 !== size && b256[it4] === 0) {
859
+ it4++;
860
+ }
861
+ var vch = new Uint8Array(zeroes + (size - it4));
862
+ var j = zeroes;
863
+ while (it4 !== size) {
864
+ vch[j++] = b256[it4++];
865
+ }
866
+ return vch;
867
+ }
868
+ /**
869
+ * @param {string | string[]} string
870
+ */
871
+ function decode(string) {
872
+ var buffer = decodeUnsafe(string);
873
+ if (buffer) {
874
+ return buffer;
875
+ }
876
+ throw new Error(`Non-${name} character`);
877
+ }
878
+ return {
879
+ encode: encode,
880
+ decodeUnsafe: decodeUnsafe,
881
+ decode: decode
882
+ };
883
+ }
884
+ var base_x_src = base;
885
+ var _brrp__multiformats_scope_baseX = base_x_src;
886
+ /* harmony default export */ const base_x = (_brrp__multiformats_scope_baseX);
887
+ //# sourceMappingURL=base-x.js.map
888
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base.js
889
+
890
+
891
+ /**
892
+ * Class represents both BaseEncoder and MultibaseEncoder meaning it
893
+ * can be used to encode to multibase or base encode without multibase
894
+ * prefix.
895
+ */
896
+ class Encoder {
897
+ name;
898
+ prefix;
899
+ baseEncode;
900
+ constructor(name, prefix, baseEncode) {
901
+ this.name = name;
902
+ this.prefix = prefix;
903
+ this.baseEncode = baseEncode;
904
+ }
905
+ encode(bytes) {
906
+ if (bytes instanceof Uint8Array) {
907
+ return `${this.prefix}${this.baseEncode(bytes)}`;
908
+ }
909
+ else {
910
+ throw Error('Unknown type, must be binary type');
911
+ }
912
+ }
913
+ }
914
+ /**
915
+ * Class represents both BaseDecoder and MultibaseDecoder so it could be used
916
+ * to decode multibases (with matching prefix) or just base decode strings
917
+ * with corresponding base encoding.
918
+ */
919
+ class Decoder {
920
+ name;
921
+ prefix;
922
+ baseDecode;
923
+ prefixCodePoint;
924
+ constructor(name, prefix, baseDecode) {
925
+ this.name = name;
926
+ this.prefix = prefix;
927
+ const prefixCodePoint = prefix.codePointAt(0);
928
+ /* c8 ignore next 3 */
929
+ if (prefixCodePoint === undefined) {
930
+ throw new Error('Invalid prefix character');
931
+ }
932
+ this.prefixCodePoint = prefixCodePoint;
933
+ this.baseDecode = baseDecode;
934
+ }
935
+ decode(text) {
936
+ if (typeof text === 'string') {
937
+ if (text.codePointAt(0) !== this.prefixCodePoint) {
938
+ throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
939
+ }
940
+ return this.baseDecode(text.slice(this.prefix.length));
941
+ }
942
+ else {
943
+ throw Error('Can only multibase decode strings');
944
+ }
945
+ }
946
+ or(decoder) {
947
+ return or(this, decoder);
948
+ }
949
+ }
950
+ class ComposedDecoder {
951
+ decoders;
952
+ constructor(decoders) {
953
+ this.decoders = decoders;
954
+ }
955
+ or(decoder) {
956
+ return or(this, decoder);
957
+ }
958
+ decode(input) {
959
+ const prefix = input[0];
960
+ const decoder = this.decoders[prefix];
961
+ if (decoder != null) {
962
+ return decoder.decode(input);
963
+ }
964
+ else {
965
+ throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
966
+ }
967
+ }
968
+ }
969
+ function or(left, right) {
970
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
971
+ return new ComposedDecoder({
972
+ ...(left.decoders ?? { [left.prefix]: left }),
973
+ ...(right.decoders ?? { [right.prefix]: right })
974
+ });
975
+ }
976
+ class Codec {
977
+ name;
978
+ prefix;
979
+ baseEncode;
980
+ baseDecode;
981
+ encoder;
982
+ decoder;
983
+ constructor(name, prefix, baseEncode, baseDecode) {
984
+ this.name = name;
985
+ this.prefix = prefix;
986
+ this.baseEncode = baseEncode;
987
+ this.baseDecode = baseDecode;
988
+ this.encoder = new Encoder(name, prefix, baseEncode);
989
+ this.decoder = new Decoder(name, prefix, baseDecode);
990
+ }
991
+ encode(input) {
992
+ return this.encoder.encode(input);
993
+ }
994
+ decode(input) {
995
+ return this.decoder.decode(input);
996
+ }
997
+ }
998
+ function from({ name, prefix, encode, decode }) {
999
+ return new Codec(name, prefix, encode, decode);
1000
+ }
1001
+ function baseX({ name, prefix, alphabet }) {
1002
+ const { encode, decode } = base_x(alphabet, name);
1003
+ return from({
1004
+ prefix,
1005
+ name,
1006
+ encode,
1007
+ decode: (text) => coerce(decode(text))
1008
+ });
1009
+ }
1010
+ function decode(string, alphabet, bitsPerChar, name) {
1011
+ // Build the character lookup table:
1012
+ const codes = {};
1013
+ for (let i = 0; i < alphabet.length; ++i) {
1014
+ codes[alphabet[i]] = i;
1015
+ }
1016
+ // Count the padding bytes:
1017
+ let end = string.length;
1018
+ while (string[end - 1] === '=') {
1019
+ --end;
1020
+ }
1021
+ // Allocate the output:
1022
+ const out = new Uint8Array((end * bitsPerChar / 8) | 0);
1023
+ // Parse the data:
1024
+ let bits = 0; // Number of bits currently in the buffer
1025
+ let buffer = 0; // Bits waiting to be written out, MSB first
1026
+ let written = 0; // Next byte to write
1027
+ for (let i = 0; i < end; ++i) {
1028
+ // Read one character from the string:
1029
+ const value = codes[string[i]];
1030
+ if (value === undefined) {
1031
+ throw new SyntaxError(`Non-${name} character`);
1032
+ }
1033
+ // Append the bits to the buffer:
1034
+ buffer = (buffer << bitsPerChar) | value;
1035
+ bits += bitsPerChar;
1036
+ // Write out some bits if the buffer has a byte's worth:
1037
+ if (bits >= 8) {
1038
+ bits -= 8;
1039
+ out[written++] = 0xff & (buffer >> bits);
1040
+ }
1041
+ }
1042
+ // Verify that we have received just enough bits:
1043
+ if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {
1044
+ throw new SyntaxError('Unexpected end of data');
1045
+ }
1046
+ return out;
1047
+ }
1048
+ function encode(data, alphabet, bitsPerChar) {
1049
+ const pad = alphabet[alphabet.length - 1] === '=';
1050
+ const mask = (1 << bitsPerChar) - 1;
1051
+ let out = '';
1052
+ let bits = 0; // Number of bits currently in the buffer
1053
+ let buffer = 0; // Bits waiting to be written out, MSB first
1054
+ for (let i = 0; i < data.length; ++i) {
1055
+ // Slurp data into the buffer:
1056
+ buffer = (buffer << 8) | data[i];
1057
+ bits += 8;
1058
+ // Write out as much as we can:
1059
+ while (bits > bitsPerChar) {
1060
+ bits -= bitsPerChar;
1061
+ out += alphabet[mask & (buffer >> bits)];
1062
+ }
1063
+ }
1064
+ // Partial character:
1065
+ if (bits !== 0) {
1066
+ out += alphabet[mask & (buffer << (bitsPerChar - bits))];
1067
+ }
1068
+ // Add padding characters until we hit a byte boundary:
1069
+ if (pad) {
1070
+ while (((out.length * bitsPerChar) & 7) !== 0) {
1071
+ out += '=';
1072
+ }
1073
+ }
1074
+ return out;
1075
+ }
1076
+ /**
1077
+ * RFC4648 Factory
1078
+ */
1079
+ function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
1080
+ return from({
1081
+ prefix,
1082
+ name,
1083
+ encode(input) {
1084
+ return encode(input, alphabet, bitsPerChar);
1085
+ },
1086
+ decode(input) {
1087
+ return decode(input, alphabet, bitsPerChar, name);
1088
+ }
1089
+ });
1090
+ }
1091
+ //# sourceMappingURL=base.js.map
1092
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base32.js
1093
+
1094
+ const base32 = rfc4648({
1095
+ prefix: 'b',
1096
+ name: 'base32',
1097
+ alphabet: 'abcdefghijklmnopqrstuvwxyz234567',
1098
+ bitsPerChar: 5
1099
+ });
1100
+ const base32upper = rfc4648({
1101
+ prefix: 'B',
1102
+ name: 'base32upper',
1103
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',
1104
+ bitsPerChar: 5
1105
+ });
1106
+ const base32pad = rfc4648({
1107
+ prefix: 'c',
1108
+ name: 'base32pad',
1109
+ alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',
1110
+ bitsPerChar: 5
1111
+ });
1112
+ const base32padupper = rfc4648({
1113
+ prefix: 'C',
1114
+ name: 'base32padupper',
1115
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',
1116
+ bitsPerChar: 5
1117
+ });
1118
+ const base32hex = rfc4648({
1119
+ prefix: 'v',
1120
+ name: 'base32hex',
1121
+ alphabet: '0123456789abcdefghijklmnopqrstuv',
1122
+ bitsPerChar: 5
1123
+ });
1124
+ const base32hexupper = rfc4648({
1125
+ prefix: 'V',
1126
+ name: 'base32hexupper',
1127
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',
1128
+ bitsPerChar: 5
1129
+ });
1130
+ const base32hexpad = rfc4648({
1131
+ prefix: 't',
1132
+ name: 'base32hexpad',
1133
+ alphabet: '0123456789abcdefghijklmnopqrstuv=',
1134
+ bitsPerChar: 5
1135
+ });
1136
+ const base32hexpadupper = rfc4648({
1137
+ prefix: 'T',
1138
+ name: 'base32hexpadupper',
1139
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',
1140
+ bitsPerChar: 5
1141
+ });
1142
+ const base32z = rfc4648({
1143
+ prefix: 'h',
1144
+ name: 'base32z',
1145
+ alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',
1146
+ bitsPerChar: 5
1147
+ });
1148
+ //# sourceMappingURL=base32.js.map
1149
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base58.js
1150
+
1151
+ const base58btc = baseX({
1152
+ name: 'base58btc',
1153
+ prefix: 'z',
1154
+ alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
1155
+ });
1156
+ const base58flickr = baseX({
1157
+ name: 'base58flickr',
1158
+ prefix: 'Z',
1159
+ alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
1160
+ });
1161
+ //# sourceMappingURL=base58.js.map
1162
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base10.js
1163
+
1164
+ const base10 = baseX({
1165
+ prefix: '9',
1166
+ name: 'base10',
1167
+ alphabet: '0123456789'
1168
+ });
1169
+ //# sourceMappingURL=base10.js.map
1170
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base16.js
1171
+
1172
+ const base16 = rfc4648({
1173
+ prefix: 'f',
1174
+ name: 'base16',
1175
+ alphabet: '0123456789abcdef',
1176
+ bitsPerChar: 4
1177
+ });
1178
+ const base16upper = rfc4648({
1179
+ prefix: 'F',
1180
+ name: 'base16upper',
1181
+ alphabet: '0123456789ABCDEF',
1182
+ bitsPerChar: 4
1183
+ });
1184
+ //# sourceMappingURL=base16.js.map
1185
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base2.js
1186
+
1187
+ const base2 = rfc4648({
1188
+ prefix: '0',
1189
+ name: 'base2',
1190
+ alphabet: '01',
1191
+ bitsPerChar: 1
1192
+ });
1193
+ //# sourceMappingURL=base2.js.map
1194
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base256emoji.js
1195
+
1196
+ const alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');
1197
+ const alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));
1198
+ const alphabetCharsToBytes = (alphabet.reduce((p, c, i) => {
1199
+ const codePoint = c.codePointAt(0);
1200
+ if (codePoint == null) {
1201
+ throw new Error(`Invalid character: ${c}`);
1202
+ }
1203
+ p[codePoint] = i;
1204
+ return p;
1205
+ }, ([])));
1206
+ function base256emoji_encode(data) {
1207
+ return data.reduce((p, c) => {
1208
+ p += alphabetBytesToChars[c];
1209
+ return p;
1210
+ }, '');
1211
+ }
1212
+ function base256emoji_decode(str) {
1213
+ const byts = [];
1214
+ for (const char of str) {
1215
+ const codePoint = char.codePointAt(0);
1216
+ if (codePoint == null) {
1217
+ throw new Error(`Invalid character: ${char}`);
1218
+ }
1219
+ const byt = alphabetCharsToBytes[codePoint];
1220
+ if (byt == null) {
1221
+ throw new Error(`Non-base256emoji character: ${char}`);
1222
+ }
1223
+ byts.push(byt);
1224
+ }
1225
+ return new Uint8Array(byts);
1226
+ }
1227
+ const base256emoji = from({
1228
+ prefix: '🚀',
1229
+ name: 'base256emoji',
1230
+ encode: base256emoji_encode,
1231
+ decode: base256emoji_decode
1232
+ });
1233
+ //# sourceMappingURL=base256emoji.js.map
1234
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base36.js
1235
+
1236
+ const base36 = baseX({
1237
+ prefix: 'k',
1238
+ name: 'base36',
1239
+ alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'
1240
+ });
1241
+ const base36upper = baseX({
1242
+ prefix: 'K',
1243
+ name: 'base36upper',
1244
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1245
+ });
1246
+ //# sourceMappingURL=base36.js.map
1247
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base64.js
1248
+
1249
+ const base64 = rfc4648({
1250
+ prefix: 'm',
1251
+ name: 'base64',
1252
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
1253
+ bitsPerChar: 6
1254
+ });
1255
+ const base64pad = rfc4648({
1256
+ prefix: 'M',
1257
+ name: 'base64pad',
1258
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
1259
+ bitsPerChar: 6
1260
+ });
1261
+ const base64url = rfc4648({
1262
+ prefix: 'u',
1263
+ name: 'base64url',
1264
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
1265
+ bitsPerChar: 6
1266
+ });
1267
+ const base64urlpad = rfc4648({
1268
+ prefix: 'U',
1269
+ name: 'base64urlpad',
1270
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',
1271
+ bitsPerChar: 6
1272
+ });
1273
+ //# sourceMappingURL=base64.js.map
1274
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/base8.js
1275
+
1276
+ const base8 = rfc4648({
1277
+ prefix: '7',
1278
+ name: 'base8',
1279
+ alphabet: '01234567',
1280
+ bitsPerChar: 3
1281
+ });
1282
+ //# sourceMappingURL=base8.js.map
1283
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/identity.js
1284
+
1285
+
1286
+ const identity = from({
1287
+ prefix: '\x00',
1288
+ name: 'identity',
1289
+ encode: (buf) => bytes_toString(buf),
1290
+ decode: (str) => fromString(str)
1291
+ });
1292
+ //# sourceMappingURL=identity.js.map
1293
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/json.js
1294
+ const textEncoder = new TextEncoder();
1295
+ const textDecoder = new TextDecoder();
1296
+ const json_name = 'json';
1297
+ const code = 0x0200;
1298
+ function json_encode(node) {
1299
+ return textEncoder.encode(JSON.stringify(node));
1300
+ }
1301
+ function json_decode(data) {
1302
+ return JSON.parse(textDecoder.decode(data));
1303
+ }
1304
+ //# sourceMappingURL=json.js.map
1305
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/raw.js
1306
+
1307
+ const raw_name = 'raw';
1308
+ const raw_code = 0x55;
1309
+ function raw_encode(node) {
1310
+ return coerce(node);
1311
+ }
1312
+ function raw_decode(data) {
1313
+ return coerce(data);
1314
+ }
1315
+ //# sourceMappingURL=raw.js.map
1316
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/vendor/varint.js
1317
+ /* eslint-disable */
1318
+ var encode_1 = varint_encode;
1319
+ var MSB = 0x80, REST = 0x7F, MSBALL = ~REST, INT = Math.pow(2, 31);
1320
+ /**
1321
+ * @param {number} num
1322
+ * @param {number[]} out
1323
+ * @param {number} offset
1324
+ */
1325
+ function varint_encode(num, out, offset) {
1326
+ out = out || [];
1327
+ offset = offset || 0;
1328
+ var oldOffset = offset;
1329
+ while (num >= INT) {
1330
+ out[offset++] = (num & 0xFF) | MSB;
1331
+ num /= 128;
1332
+ }
1333
+ while (num & MSBALL) {
1334
+ out[offset++] = (num & 0xFF) | MSB;
1335
+ num >>>= 7;
1336
+ }
1337
+ out[offset] = num | 0;
1338
+ // @ts-ignore
1339
+ varint_encode.bytes = offset - oldOffset + 1;
1340
+ return out;
1341
+ }
1342
+ var varint_decode = read;
1343
+ var MSB$1 = 0x80, REST$1 = 0x7F;
1344
+ /**
1345
+ * @param {string | any[]} buf
1346
+ * @param {number} offset
1347
+ */
1348
+ function read(buf, offset) {
1349
+ var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
1350
+ do {
1351
+ if (counter >= l) {
1352
+ // @ts-ignore
1353
+ read.bytes = 0;
1354
+ throw new RangeError('Could not decode varint');
1355
+ }
1356
+ b = buf[counter++];
1357
+ res += shift < 28
1358
+ ? (b & REST$1) << shift
1359
+ : (b & REST$1) * Math.pow(2, shift);
1360
+ shift += 7;
1361
+ } while (b >= MSB$1);
1362
+ // @ts-ignore
1363
+ read.bytes = counter - offset;
1364
+ return res;
1365
+ }
1366
+ var N1 = Math.pow(2, 7);
1367
+ var N2 = Math.pow(2, 14);
1368
+ var N3 = Math.pow(2, 21);
1369
+ var N4 = Math.pow(2, 28);
1370
+ var N5 = Math.pow(2, 35);
1371
+ var N6 = Math.pow(2, 42);
1372
+ var N7 = Math.pow(2, 49);
1373
+ var N8 = Math.pow(2, 56);
1374
+ var N9 = Math.pow(2, 63);
1375
+ var varint_length = function (/** @type {number} */ value) {
1376
+ return (value < N1 ? 1
1377
+ : value < N2 ? 2
1378
+ : value < N3 ? 3
1379
+ : value < N4 ? 4
1380
+ : value < N5 ? 5
1381
+ : value < N6 ? 6
1382
+ : value < N7 ? 7
1383
+ : value < N8 ? 8
1384
+ : value < N9 ? 9
1385
+ : 10);
1386
+ };
1387
+ var varint = {
1388
+ encode: encode_1,
1389
+ decode: varint_decode,
1390
+ encodingLength: varint_length
1391
+ };
1392
+ var _brrp_varint = varint;
1393
+ /* harmony default export */ const vendor_varint = (_brrp_varint);
1394
+ //# sourceMappingURL=varint.js.map
1395
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/varint.js
1396
+
1397
+ function src_varint_decode(data, offset = 0) {
1398
+ const code = vendor_varint.decode(data, offset);
1399
+ return [code, vendor_varint.decode.bytes];
1400
+ }
1401
+ function encodeTo(int, target, offset = 0) {
1402
+ vendor_varint.encode(int, target, offset);
1403
+ return target;
1404
+ }
1405
+ function encodingLength(int) {
1406
+ return vendor_varint.encodingLength(int);
1407
+ }
1408
+ //# sourceMappingURL=varint.js.map
1409
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/digest.js
1410
+
1411
+
1412
+ /**
1413
+ * Creates a multihash digest.
1414
+ */
1415
+ function create(code, digest) {
1416
+ const size = digest.byteLength;
1417
+ const sizeOffset = encodingLength(code);
1418
+ const digestOffset = sizeOffset + encodingLength(size);
1419
+ const bytes = new Uint8Array(digestOffset + size);
1420
+ encodeTo(code, bytes, 0);
1421
+ encodeTo(size, bytes, sizeOffset);
1422
+ bytes.set(digest, digestOffset);
1423
+ return new Digest(code, size, digest, bytes);
1424
+ }
1425
+ /**
1426
+ * Turns bytes representation of multihash digest into an instance.
1427
+ */
1428
+ function digest_decode(multihash) {
1429
+ const bytes = coerce(multihash);
1430
+ const [code, sizeOffset] = src_varint_decode(bytes);
1431
+ const [size, digestOffset] = src_varint_decode(bytes.subarray(sizeOffset));
1432
+ const digest = bytes.subarray(sizeOffset + digestOffset);
1433
+ if (digest.byteLength !== size) {
1434
+ throw new Error('Incorrect length');
1435
+ }
1436
+ return new Digest(code, size, digest, bytes);
1437
+ }
1438
+ function digest_equals(a, b) {
1439
+ if (a === b) {
1440
+ return true;
1441
+ }
1442
+ else {
1443
+ const data = b;
1444
+ return (a.code === data.code &&
1445
+ a.size === data.size &&
1446
+ data.bytes instanceof Uint8Array &&
1447
+ equals(a.bytes, data.bytes));
1448
+ }
1449
+ }
1450
+ /**
1451
+ * Represents a multihash digest which carries information about the
1452
+ * hashing algorithm and an actual hash digest.
1453
+ */
1454
+ class Digest {
1455
+ code;
1456
+ size;
1457
+ digest;
1458
+ bytes;
1459
+ /**
1460
+ * Creates a multihash digest.
1461
+ */
1462
+ constructor(code, size, digest, bytes) {
1463
+ this.code = code;
1464
+ this.size = size;
1465
+ this.digest = digest;
1466
+ this.bytes = bytes;
1467
+ }
1468
+ }
1469
+ /**
1470
+ * Used to check that the passed multihash has the passed code
1471
+ */
1472
+ function hasCode(digest, code) {
1473
+ return digest.code === code;
1474
+ }
1475
+ //# sourceMappingURL=digest.js.map
1476
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/identity.js
1477
+
1478
+
1479
+ const identity_code = 0x0;
1480
+ const identity_name = 'identity';
1481
+ const identity_encode = coerce;
1482
+ function digest(input) {
1483
+ return create(identity_code, identity_encode(input));
1484
+ }
1485
+ const identity_identity = { code: identity_code, name: identity_name, encode: identity_encode, digest };
1486
+ //# sourceMappingURL=identity.js.map
1487
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/hasher.js
1488
+
1489
+ function hasher_from({ name, code, encode }) {
1490
+ return new Hasher(name, code, encode);
1491
+ }
1492
+ /**
1493
+ * Hasher represents a hashing algorithm implementation that produces as
1494
+ * `MultihashDigest`.
1495
+ */
1496
+ class Hasher {
1497
+ name;
1498
+ code;
1499
+ encode;
1500
+ constructor(name, code, encode) {
1501
+ this.name = name;
1502
+ this.code = code;
1503
+ this.encode = encode;
1504
+ }
1505
+ digest(input) {
1506
+ if (input instanceof Uint8Array) {
1507
+ const result = this.encode(input);
1508
+ return result instanceof Uint8Array
1509
+ ? create(this.code, result)
1510
+ /* c8 ignore next 1 */
1511
+ : result.then(digest => create(this.code, digest));
1512
+ }
1513
+ else {
1514
+ throw Error('Unknown type, must be binary type');
1515
+ /* c8 ignore next 1 */
1516
+ }
1517
+ }
1518
+ }
1519
+ //# sourceMappingURL=hasher.js.map
1520
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/sha2-browser.js
1521
+ /* global crypto */
1522
+
1523
+ function sha(name) {
1524
+ return async (data) => new Uint8Array(await crypto.subtle.digest(name, data));
1525
+ }
1526
+ const sha256 = hasher_from({
1527
+ name: 'sha2-256',
1528
+ code: 0x12,
1529
+ encode: sha('SHA-256')
1530
+ });
1531
+ const sha512 = hasher_from({
1532
+ name: 'sha2-512',
1533
+ code: 0x13,
1534
+ encode: sha('SHA-512')
1535
+ });
1536
+ //# sourceMappingURL=sha2-browser.js.map
1537
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/link/interface.js
1538
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
1539
+ /* eslint-disable no-use-before-define */
1540
+
1541
+ //# sourceMappingURL=interface.js.map
1542
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/cid.js
1543
+
1544
+
1545
+
1546
+
1547
+
1548
+
1549
+ // This way TS will also expose all the types from module
1550
+
1551
+ function format(link, base) {
1552
+ const { bytes, version } = link;
1553
+ switch (version) {
1554
+ case 0:
1555
+ return toStringV0(bytes, baseCache(link), base ?? base58btc.encoder);
1556
+ default:
1557
+ return toStringV1(bytes, baseCache(link), (base ?? base32.encoder));
1558
+ }
1559
+ }
1560
+ function toJSON(link) {
1561
+ return {
1562
+ '/': format(link)
1563
+ };
1564
+ }
1565
+ function fromJSON(json) {
1566
+ return CID.parse(json['/']);
1567
+ }
1568
+ const cache = new WeakMap();
1569
+ function baseCache(cid) {
1570
+ const baseCache = cache.get(cid);
1571
+ if (baseCache == null) {
1572
+ const baseCache = new Map();
1573
+ cache.set(cid, baseCache);
1574
+ return baseCache;
1575
+ }
1576
+ return baseCache;
1577
+ }
1578
+ class CID {
1579
+ code;
1580
+ version;
1581
+ multihash;
1582
+ bytes;
1583
+ '/';
1584
+ /**
1585
+ * @param version - Version of the CID
1586
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
1587
+ * @param multihash - (Multi)hash of the of the content.
1588
+ */
1589
+ constructor(version, code, multihash, bytes) {
1590
+ this.code = code;
1591
+ this.version = version;
1592
+ this.multihash = multihash;
1593
+ this.bytes = bytes;
1594
+ // flag to serializers that this is a CID and
1595
+ // should be treated specially
1596
+ this['/'] = bytes;
1597
+ }
1598
+ /**
1599
+ * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
1600
+ * please either use `CID.asCID(cid)` or switch to new signalling mechanism
1601
+ *
1602
+ * @deprecated
1603
+ */
1604
+ get asCID() {
1605
+ return this;
1606
+ }
1607
+ // ArrayBufferView
1608
+ get byteOffset() {
1609
+ return this.bytes.byteOffset;
1610
+ }
1611
+ // ArrayBufferView
1612
+ get byteLength() {
1613
+ return this.bytes.byteLength;
1614
+ }
1615
+ toV0() {
1616
+ switch (this.version) {
1617
+ case 0: {
1618
+ return this;
1619
+ }
1620
+ case 1: {
1621
+ const { code, multihash } = this;
1622
+ if (code !== DAG_PB_CODE) {
1623
+ throw new Error('Cannot convert a non dag-pb CID to CIDv0');
1624
+ }
1625
+ // sha2-256
1626
+ if (multihash.code !== SHA_256_CODE) {
1627
+ throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');
1628
+ }
1629
+ return (CID.createV0(multihash));
1630
+ }
1631
+ default: {
1632
+ throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
1633
+ }
1634
+ }
1635
+ }
1636
+ toV1() {
1637
+ switch (this.version) {
1638
+ case 0: {
1639
+ const { code, digest } = this.multihash;
1640
+ const multihash = create(code, digest);
1641
+ return (CID.createV1(this.code, multihash));
1642
+ }
1643
+ case 1: {
1644
+ return this;
1645
+ }
1646
+ default: {
1647
+ throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
1648
+ }
1649
+ }
1650
+ }
1651
+ equals(other) {
1652
+ return CID.equals(this, other);
1653
+ }
1654
+ static equals(self, other) {
1655
+ const unknown = other;
1656
+ return (unknown != null &&
1657
+ self.code === unknown.code &&
1658
+ self.version === unknown.version &&
1659
+ digest_equals(self.multihash, unknown.multihash));
1660
+ }
1661
+ toString(base) {
1662
+ return format(this, base);
1663
+ }
1664
+ toJSON() {
1665
+ return { '/': format(this) };
1666
+ }
1667
+ link() {
1668
+ return this;
1669
+ }
1670
+ [Symbol.toStringTag] = 'CID';
1671
+ // Legacy
1672
+ [Symbol.for('nodejs.util.inspect.custom')]() {
1673
+ return `CID(${this.toString()})`;
1674
+ }
1675
+ /**
1676
+ * Takes any input `value` and returns a `CID` instance if it was
1677
+ * a `CID` otherwise returns `null`. If `value` is instanceof `CID`
1678
+ * it will return value back. If `value` is not instance of this CID
1679
+ * class, but is compatible CID it will return new instance of this
1680
+ * `CID` class. Otherwise returns null.
1681
+ *
1682
+ * This allows two different incompatible versions of CID library to
1683
+ * co-exist and interop as long as binary interface is compatible.
1684
+ */
1685
+ static asCID(input) {
1686
+ if (input == null) {
1687
+ return null;
1688
+ }
1689
+ const value = input;
1690
+ if (value instanceof CID) {
1691
+ // If value is instance of CID then we're all set.
1692
+ return value;
1693
+ }
1694
+ else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {
1695
+ // If value isn't instance of this CID class but `this.asCID === this` or
1696
+ // `value['/'] === value.bytes` is true it is CID instance coming from a
1697
+ // different implementation (diff version or duplicate). In that case we
1698
+ // rebase it to this `CID` implementation so caller is guaranteed to get
1699
+ // instance with expected API.
1700
+ const { version, code, multihash, bytes } = value;
1701
+ return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));
1702
+ }
1703
+ else if (value[cidSymbol] === true) {
1704
+ // If value is a CID from older implementation that used to be tagged via
1705
+ // symbol we still rebase it to the this `CID` implementation by
1706
+ // delegating that to a constructor.
1707
+ const { version, multihash, code } = value;
1708
+ const digest = digest_decode(multihash);
1709
+ return CID.create(version, code, digest);
1710
+ }
1711
+ else {
1712
+ // Otherwise value is not a CID (or an incompatible version of it) in
1713
+ // which case we return `null`.
1714
+ return null;
1715
+ }
1716
+ }
1717
+ /**
1718
+ * @param version - Version of the CID
1719
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
1720
+ * @param digest - (Multi)hash of the of the content.
1721
+ */
1722
+ static create(version, code, digest) {
1723
+ if (typeof code !== 'number') {
1724
+ throw new Error('String codecs are no longer supported');
1725
+ }
1726
+ if (!(digest.bytes instanceof Uint8Array)) {
1727
+ throw new Error('Invalid digest');
1728
+ }
1729
+ switch (version) {
1730
+ case 0: {
1731
+ if (code !== DAG_PB_CODE) {
1732
+ throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
1733
+ }
1734
+ else {
1735
+ return new CID(version, code, digest, digest.bytes);
1736
+ }
1737
+ }
1738
+ case 1: {
1739
+ const bytes = encodeCID(version, code, digest.bytes);
1740
+ return new CID(version, code, digest, bytes);
1741
+ }
1742
+ default: {
1743
+ throw new Error('Invalid version');
1744
+ }
1745
+ }
1746
+ }
1747
+ /**
1748
+ * Simplified version of `create` for CIDv0.
1749
+ */
1750
+ static createV0(digest) {
1751
+ return CID.create(0, DAG_PB_CODE, digest);
1752
+ }
1753
+ /**
1754
+ * Simplified version of `create` for CIDv1.
1755
+ *
1756
+ * @param code - Content encoding format code.
1757
+ * @param digest - Multihash of the content.
1758
+ */
1759
+ static createV1(code, digest) {
1760
+ return CID.create(1, code, digest);
1761
+ }
1762
+ /**
1763
+ * Decoded a CID from its binary representation. The byte array must contain
1764
+ * only the CID with no additional bytes.
1765
+ *
1766
+ * An error will be thrown if the bytes provided do not contain a valid
1767
+ * binary representation of a CID.
1768
+ */
1769
+ static decode(bytes) {
1770
+ const [cid, remainder] = CID.decodeFirst(bytes);
1771
+ if (remainder.length !== 0) {
1772
+ throw new Error('Incorrect length');
1773
+ }
1774
+ return cid;
1775
+ }
1776
+ /**
1777
+ * Decoded a CID from its binary representation at the beginning of a byte
1778
+ * array.
1779
+ *
1780
+ * Returns an array with the first element containing the CID and the second
1781
+ * element containing the remainder of the original byte array. The remainder
1782
+ * will be a zero-length byte array if the provided bytes only contained a
1783
+ * binary CID representation.
1784
+ */
1785
+ static decodeFirst(bytes) {
1786
+ const specs = CID.inspectBytes(bytes);
1787
+ const prefixSize = specs.size - specs.multihashSize;
1788
+ const multihashBytes = coerce(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
1789
+ if (multihashBytes.byteLength !== specs.multihashSize) {
1790
+ throw new Error('Incorrect length');
1791
+ }
1792
+ const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
1793
+ const digest = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
1794
+ const cid = specs.version === 0
1795
+ ? CID.createV0(digest)
1796
+ : CID.createV1(specs.codec, digest);
1797
+ return [cid, bytes.subarray(specs.size)];
1798
+ }
1799
+ /**
1800
+ * Inspect the initial bytes of a CID to determine its properties.
1801
+ *
1802
+ * Involves decoding up to 4 varints. Typically this will require only 4 to 6
1803
+ * bytes but for larger multicodec code values and larger multihash digest
1804
+ * lengths these varints can be quite large. It is recommended that at least
1805
+ * 10 bytes be made available in the `initialBytes` argument for a complete
1806
+ * inspection.
1807
+ */
1808
+ static inspectBytes(initialBytes) {
1809
+ let offset = 0;
1810
+ const next = () => {
1811
+ const [i, length] = src_varint_decode(initialBytes.subarray(offset));
1812
+ offset += length;
1813
+ return i;
1814
+ };
1815
+ let version = next();
1816
+ let codec = DAG_PB_CODE;
1817
+ if (version === 18) {
1818
+ // CIDv0
1819
+ version = 0;
1820
+ offset = 0;
1821
+ }
1822
+ else {
1823
+ codec = next();
1824
+ }
1825
+ if (version !== 0 && version !== 1) {
1826
+ throw new RangeError(`Invalid CID version ${version}`);
1827
+ }
1828
+ const prefixSize = offset;
1829
+ const multihashCode = next(); // multihash code
1830
+ const digestSize = next(); // multihash length
1831
+ const size = offset + digestSize;
1832
+ const multihashSize = size - prefixSize;
1833
+ return { version, codec, multihashCode, digestSize, multihashSize, size };
1834
+ }
1835
+ /**
1836
+ * Takes cid in a string representation and creates an instance. If `base`
1837
+ * decoder is not provided will use a default from the configuration. It will
1838
+ * throw an error if encoding of the CID is not compatible with supplied (or
1839
+ * a default decoder).
1840
+ */
1841
+ static parse(source, base) {
1842
+ const [prefix, bytes] = parseCIDtoBytes(source, base);
1843
+ const cid = CID.decode(bytes);
1844
+ if (cid.version === 0 && source[0] !== 'Q') {
1845
+ throw Error('Version 0 CID string must not include multibase prefix');
1846
+ }
1847
+ // Cache string representation to avoid computing it on `this.toString()`
1848
+ baseCache(cid).set(prefix, source);
1849
+ return cid;
1850
+ }
1851
+ }
1852
+ function parseCIDtoBytes(source, base) {
1853
+ switch (source[0]) {
1854
+ // CIDv0 is parsed differently
1855
+ case 'Q': {
1856
+ const decoder = base ?? base58btc;
1857
+ return [
1858
+ base58btc.prefix,
1859
+ decoder.decode(`${base58btc.prefix}${source}`)
1860
+ ];
1861
+ }
1862
+ case base58btc.prefix: {
1863
+ const decoder = base ?? base58btc;
1864
+ return [base58btc.prefix, decoder.decode(source)];
1865
+ }
1866
+ case base32.prefix: {
1867
+ const decoder = base ?? base32;
1868
+ return [base32.prefix, decoder.decode(source)];
1869
+ }
1870
+ case base36.prefix: {
1871
+ const decoder = base ?? base36;
1872
+ return [base36.prefix, decoder.decode(source)];
1873
+ }
1874
+ default: {
1875
+ if (base == null) {
1876
+ throw Error('To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided');
1877
+ }
1878
+ return [source[0], base.decode(source)];
1879
+ }
1880
+ }
1881
+ }
1882
+ function toStringV0(bytes, cache, base) {
1883
+ const { prefix } = base;
1884
+ if (prefix !== base58btc.prefix) {
1885
+ throw Error(`Cannot string encode V0 in ${base.name} encoding`);
1886
+ }
1887
+ const cid = cache.get(prefix);
1888
+ if (cid == null) {
1889
+ const cid = base.encode(bytes).slice(1);
1890
+ cache.set(prefix, cid);
1891
+ return cid;
1892
+ }
1893
+ else {
1894
+ return cid;
1895
+ }
1896
+ }
1897
+ function toStringV1(bytes, cache, base) {
1898
+ const { prefix } = base;
1899
+ const cid = cache.get(prefix);
1900
+ if (cid == null) {
1901
+ const cid = base.encode(bytes);
1902
+ cache.set(prefix, cid);
1903
+ return cid;
1904
+ }
1905
+ else {
1906
+ return cid;
1907
+ }
1908
+ }
1909
+ const DAG_PB_CODE = 0x70;
1910
+ const SHA_256_CODE = 0x12;
1911
+ function encodeCID(version, code, multihash) {
1912
+ const codeOffset = encodingLength(version);
1913
+ const hashOffset = codeOffset + encodingLength(code);
1914
+ const bytes = new Uint8Array(hashOffset + multihash.byteLength);
1915
+ encodeTo(version, bytes, 0);
1916
+ encodeTo(code, bytes, codeOffset);
1917
+ bytes.set(multihash, hashOffset);
1918
+ return bytes;
1919
+ }
1920
+ const cidSymbol = Symbol.for('@ipld/js-cid/CID');
1921
+ //# sourceMappingURL=cid.js.map
1922
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/bases/interface.js
1923
+ // Base encoders / decoders just base encode / decode between binary and
1924
+ // textual representation. They are unaware of multibase.
1925
+
1926
+ //# sourceMappingURL=interface.js.map
1927
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/hashes/interface.js
1928
+ // # Multihash
1929
+
1930
+ //# sourceMappingURL=interface.js.map
1931
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/codecs/interface.js
1932
+
1933
+ //# sourceMappingURL=interface.js.map
1934
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/block/interface.js
1935
+
1936
+ //# sourceMappingURL=interface.js.map
1937
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/interface.js
1938
+
1939
+
1940
+
1941
+
1942
+
1943
+ //# sourceMappingURL=interface.js.map
1944
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/index.js
1945
+ /**
1946
+ * @packageDocumentation
1947
+ *
1948
+ * This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.
1949
+ *
1950
+ * This library provides implementations for most basics and many others can be found in linked repositories.
1951
+ *
1952
+ * ```TypeScript
1953
+ * import { CID } from 'multiformats/cid'
1954
+ * import * as json from 'multiformats/codecs/json'
1955
+ * import { sha256 } from 'multiformats/hashes/sha2'
1956
+ *
1957
+ * const bytes = json.encode({ hello: 'world' })
1958
+ *
1959
+ * const hash = await sha256.digest(bytes)
1960
+ * const cid = CID.create(1, json.code, hash)
1961
+ * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
1962
+ * ```
1963
+ *
1964
+ * ## Creating Blocks
1965
+ *
1966
+ * ```TypeScript
1967
+ * import * as Block from 'multiformats/block'
1968
+ * import * as codec from '@ipld/dag-cbor'
1969
+ * import { sha256 as hasher } from 'multiformats/hashes/sha2'
1970
+ *
1971
+ * const value = { hello: 'world' }
1972
+ *
1973
+ * // encode a block
1974
+ * let block = await Block.encode({ value, codec, hasher })
1975
+ *
1976
+ * block.value // { hello: 'world' }
1977
+ * block.bytes // Uint8Array
1978
+ * block.cid // CID() w/ sha2-256 hash address and dag-cbor codec
1979
+ *
1980
+ * // you can also decode blocks from their binary state
1981
+ * block = await Block.decode({ bytes: block.bytes, codec, hasher })
1982
+ *
1983
+ * // if you have the cid you can also verify the hash on decode
1984
+ * block = await Block.create({ bytes: block.bytes, cid: block.cid, codec, hasher })
1985
+ * ```
1986
+ *
1987
+ * ## Multibase Encoders / Decoders / Codecs
1988
+ *
1989
+ * CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:
1990
+ *
1991
+ * ```TypeScript
1992
+ * import { base64 } from "multiformats/bases/base64"
1993
+ * cid.toString(base64.encoder)
1994
+ * //> 'mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA'
1995
+ * ```
1996
+ *
1997
+ * Parsing CID string serialized CIDs requires multibase decoder that implements [`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides a decoder for every encoder it provides:
1998
+ *
1999
+ * ```TypeScript
2000
+ * CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)
2001
+ * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
2002
+ * ```
2003
+ *
2004
+ * Dual of multibase encoder & decoder is defined as multibase codec and it exposes
2005
+ * them as `encoder` and `decoder` properties. For added convenience codecs also
2006
+ * implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be
2007
+ * used as either or both:
2008
+ *
2009
+ * ```TypeScript
2010
+ * cid.toString(base64)
2011
+ * CID.parse(cid.toString(base64), base64)
2012
+ * ```
2013
+ *
2014
+ * **Note:** CID implementation comes bundled with `base32` and `base58btc`
2015
+ * multibase codecs so that CIDs can be base serialized to (version specific)
2016
+ * default base encoding and parsed without having to supply base encoders/decoders:
2017
+ *
2018
+ * ```TypeScript
2019
+ * const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')
2020
+ * v1.toString()
2021
+ * //> 'bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea'
2022
+ *
2023
+ * const v0 = CID.parse('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n')
2024
+ * v0.toString()
2025
+ * //> 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'
2026
+ * v0.toV1().toString()
2027
+ * //> 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'
2028
+ * ```
2029
+ *
2030
+ * ## Multicodec Encoders / Decoders / Codecs
2031
+ *
2032
+ * This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).
2033
+ * Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.
2034
+ * Here is an example implementation of JSON `BlockCodec`.
2035
+ *
2036
+ * ```TypeScript
2037
+ * export const { name, code, encode, decode } = {
2038
+ * name: 'json',
2039
+ * code: 0x0200,
2040
+ * encode: json => new TextEncoder().encode(JSON.stringify(json)),
2041
+ * decode: bytes => JSON.parse(new TextDecoder().decode(bytes))
2042
+ * }
2043
+ * ```
2044
+ *
2045
+ * ## Multihash Hashers
2046
+ *
2047
+ * This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:
2048
+ *
2049
+ * ```TypeScript
2050
+ * import * as hasher from 'multiformats/hashes/hasher'
2051
+ *
2052
+ * const sha256 = hasher.from({
2053
+ * // As per multiformats table
2054
+ * // https://github.com/multiformats/multicodec/blob/master/table.csv#L9
2055
+ * name: 'sha2-256',
2056
+ * code: 0x12,
2057
+ *
2058
+ * encode: (input) => new Uint8Array(crypto.createHash('sha256').update(input).digest())
2059
+ * })
2060
+ *
2061
+ * const hash = await sha256.digest(json.encode({ hello: 'world' }))
2062
+ * CID.create(1, json.code, hash)
2063
+ *
2064
+ * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
2065
+ * ```
2066
+ *
2067
+ * ## Traversal
2068
+ *
2069
+ * This library contains higher-order functions for traversing graphs of data easily.
2070
+ *
2071
+ * `walk()` walks through the links in each block of a DAG calling a user-supplied loader function for each one, in depth-first order with no duplicate block visits. The loader should return a `Block` object and can be used to inspect and collect block ordering for a full DAG walk. The loader should `throw` on error, and return `null` if a block should be skipped by `walk()`.
2072
+ *
2073
+ * ```TypeScript
2074
+ * import { walk } from 'multiformats/traversal'
2075
+ * import * as Block from 'multiformats/block'
2076
+ * import * as codec from 'multiformats/codecs/json'
2077
+ * import { sha256 as hasher } from 'multiformats/hashes/sha2'
2078
+ *
2079
+ * // build a DAG (a single block for this simple example)
2080
+ * const value = { hello: 'world' }
2081
+ * const block = await Block.encode({ value, codec, hasher })
2082
+ * const { cid } = block
2083
+ * console.log(cid)
2084
+ * //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
2085
+ *
2086
+ * // create a loader function that also collects CIDs of blocks in
2087
+ * // their traversal order
2088
+ * const load = (cid, blocks) => async (cid) => {
2089
+ * // fetch a block using its cid
2090
+ * // e.g.: const block = await fetchBlockByCID(cid)
2091
+ * blocks.push(cid)
2092
+ * return block
2093
+ * }
2094
+ *
2095
+ * // collect blocks in this DAG starting from the root `cid`
2096
+ * const blocks = []
2097
+ * await walk({ cid, load: load(cid, blocks) })
2098
+ *
2099
+ * console.log(blocks)
2100
+ * //> [CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)]
2101
+ * ```
2102
+ *
2103
+ * ## Legacy interface
2104
+ *
2105
+ * [`blockcodec-to-ipld-format`](https://github.com/ipld/js-blockcodec-to-ipld-format) converts a multiformats [`BlockCodec`](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts#L21) into an
2106
+ * [`interface-ipld-format`](https://github.com/ipld/interface-ipld-format) for use with the [`ipld`](https://github.com/ipld/ipld) package. This can help bridge IPLD codecs implemented using the structure and interfaces defined here to existing code that assumes, or requires `interface-ipld-format`. This bridge also includes the relevant TypeScript definitions.
2107
+ *
2108
+ * ## Implementations
2109
+ *
2110
+ * By default, no base encodings (other than base32 & base58btc), hash functions,
2111
+ * or codec implementations are exposed by `multiformats`, you need to
2112
+ * import the ones you need yourself.
2113
+ *
2114
+ * ### Multibase codecs
2115
+ *
2116
+ * | bases | import | repo |
2117
+ * | ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- |
2118
+ * | `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
2119
+ * | `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
2120
+ * | `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
2121
+ * | `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
2122
+ *
2123
+ * Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`.
2124
+ *
2125
+ * ### Multihash hashers
2126
+ *
2127
+ * | hashes | import | repo |
2128
+ * | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
2129
+ * | `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) |
2130
+ * | `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) |
2131
+ * | `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) |
2132
+ * | `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) |
2133
+ * | `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) |
2134
+ *
2135
+ * ### IPLD codecs (multicodec)
2136
+ *
2137
+ * | codec | import | repo |
2138
+ * | ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ |
2139
+ * | `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |
2140
+ * | `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |
2141
+ * | `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) |
2142
+ * | `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) |
2143
+ * | `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) |
2144
+ * | `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) |
2145
+ */
2146
+
2147
+
2148
+
2149
+
2150
+
2151
+ // This way TS will also expose all the types from module
2152
+
2153
+
2154
+ //# sourceMappingURL=index.js.map
2155
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/node_modules/multiformats/dist/src/basics.js
2156
+
2157
+
2158
+
2159
+
2160
+
2161
+
2162
+
2163
+
2164
+
2165
+
2166
+
2167
+
2168
+
2169
+
2170
+
2171
+ const bases = { ...identity_namespaceObject, ...base2_namespaceObject, ...base8_namespaceObject, ...base10_namespaceObject, ...base16_namespaceObject, ...base32_namespaceObject, ...base36_namespaceObject, ...base58_namespaceObject, ...base64_namespaceObject, ...base256emoji_namespaceObject };
2172
+ const hashes = { ...sha2_browser_namespaceObject, ...hashes_identity_namespaceObject };
2173
+ const codecs = { raw: raw_namespaceObject, json: json_namespaceObject };
2174
+
2175
+ //# sourceMappingURL=basics.js.map
2176
+ // EXTERNAL MODULE: ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/from-string.js
2177
+ var from_string = __webpack_require__("./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/from-string.js");
2178
+ ;// ./node_modules/shogun-ipfs/node_modules/@chainsafe/is-ip/lib/is-ip.js
2179
+
2180
+ /** Check if `input` is IPv4. */
2181
+ function isIPv4(input) {
2182
+ return Boolean(parseIPv4(input));
2183
+ }
2184
+ /** Check if `input` is IPv6. */
2185
+ function isIPv6(input) {
2186
+ return Boolean(parseIPv6(input));
2187
+ }
2188
+ /** Check if `input` is IPv4 or IPv6. */
2189
+ function isIP(input) {
2190
+ return Boolean(parseIP(input));
2191
+ }
2192
+ /**
2193
+ * @returns `6` if `input` is IPv6, `4` if `input` is IPv4, or `undefined` if `input` is neither.
2194
+ */
2195
+ function ipVersion(input) {
2196
+ if (isIPv4(input)) {
2197
+ return 4;
2198
+ }
2199
+ else if (isIPv6(input)) {
2200
+ return 6;
2201
+ }
2202
+ else {
2203
+ return undefined;
2204
+ }
2205
+ }
2206
+ //# sourceMappingURL=is-ip.js.map
2207
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/dist/src/ip.js
2208
+
2209
+
2210
+
2211
+ const isV4 = isIPv4;
2212
+ const isV6 = isIPv6;
2213
+ // Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7
2214
+ // but with buf/offset args removed because we don't use them
2215
+ const toBytes = function (ip) {
2216
+ let offset = 0;
2217
+ ip = ip.toString().trim();
2218
+ if (isV4(ip)) {
2219
+ const bytes = new Uint8Array(offset + 4);
2220
+ ip.split(/\./g).forEach((byte) => {
2221
+ bytes[offset++] = parseInt(byte, 10) & 0xff;
2222
+ });
2223
+ return bytes;
2224
+ }
2225
+ if (isV6(ip)) {
2226
+ const sections = ip.split(':', 8);
2227
+ let i;
2228
+ for (i = 0; i < sections.length; i++) {
2229
+ const isv4 = isV4(sections[i]);
2230
+ let v4Buffer;
2231
+ if (isv4) {
2232
+ v4Buffer = toBytes(sections[i]);
2233
+ sections[i] = (0,to_string.toString)(v4Buffer.slice(0, 2), 'base16');
2234
+ }
2235
+ if (v4Buffer != null && ++i < 8) {
2236
+ sections.splice(i, 0, (0,to_string.toString)(v4Buffer.slice(2, 4), 'base16'));
2237
+ }
2238
+ }
2239
+ if (sections[0] === '') {
2240
+ while (sections.length < 8)
2241
+ sections.unshift('0');
2242
+ }
2243
+ else if (sections[sections.length - 1] === '') {
2244
+ while (sections.length < 8)
2245
+ sections.push('0');
2246
+ }
2247
+ else if (sections.length < 8) {
2248
+ for (i = 0; i < sections.length && sections[i] !== ''; i++)
2249
+ ;
2250
+ const argv = [i, 1];
2251
+ for (i = 9 - sections.length; i > 0; i--) {
2252
+ argv.push('0');
2253
+ }
2254
+ sections.splice.apply(sections, argv);
2255
+ }
2256
+ const bytes = new Uint8Array(offset + 16);
2257
+ for (i = 0; i < sections.length; i++) {
2258
+ const word = parseInt(sections[i], 16);
2259
+ bytes[offset++] = (word >> 8) & 0xff;
2260
+ bytes[offset++] = word & 0xff;
2261
+ }
2262
+ return bytes;
2263
+ }
2264
+ throw new Error('invalid ip address');
2265
+ };
2266
+ // Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L63
2267
+ const ip_toString = function (buf, offset = 0, length) {
2268
+ offset = ~~offset;
2269
+ length = length ?? (buf.length - offset);
2270
+ const view = new DataView(buf.buffer);
2271
+ if (length === 4) {
2272
+ const result = [];
2273
+ // IPv4
2274
+ for (let i = 0; i < length; i++) {
2275
+ result.push(buf[offset + i]);
2276
+ }
2277
+ return result.join('.');
2278
+ }
2279
+ if (length === 16) {
2280
+ const result = [];
2281
+ // IPv6
2282
+ for (let i = 0; i < length; i += 2) {
2283
+ result.push(view.getUint16(offset + i).toString(16));
2284
+ }
2285
+ return result.join(':')
2286
+ .replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3')
2287
+ .replace(/:{3,4}/, '::');
2288
+ }
2289
+ return '';
2290
+ };
2291
+ //# sourceMappingURL=ip.js.map
2292
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js
2293
+ const V = -1;
2294
+ const names = {};
2295
+ const codes = {};
2296
+ const table = [
2297
+ [4, 32, 'ip4'],
2298
+ [6, 16, 'tcp'],
2299
+ [33, 16, 'dccp'],
2300
+ [41, 128, 'ip6'],
2301
+ [42, V, 'ip6zone'],
2302
+ [43, 8, 'ipcidr'],
2303
+ [53, V, 'dns', true],
2304
+ [54, V, 'dns4', true],
2305
+ [55, V, 'dns6', true],
2306
+ [56, V, 'dnsaddr', true],
2307
+ [132, 16, 'sctp'],
2308
+ [273, 16, 'udp'],
2309
+ [275, 0, 'p2p-webrtc-star'],
2310
+ [276, 0, 'p2p-webrtc-direct'],
2311
+ [277, 0, 'p2p-stardust'],
2312
+ [280, 0, 'webrtc-direct'],
2313
+ [281, 0, 'webrtc'],
2314
+ [290, 0, 'p2p-circuit'],
2315
+ [301, 0, 'udt'],
2316
+ [302, 0, 'utp'],
2317
+ [400, V, 'unix', false, true],
2318
+ // `ipfs` is added before `p2p` for legacy support.
2319
+ // All text representations will default to `p2p`, but `ipfs` will
2320
+ // still be supported
2321
+ [421, V, 'ipfs'],
2322
+ // `p2p` is the preferred name for 421, and is now the default
2323
+ [421, V, 'p2p'],
2324
+ [443, 0, 'https'],
2325
+ [444, 96, 'onion'],
2326
+ [445, 296, 'onion3'],
2327
+ [446, V, 'garlic64'],
2328
+ [448, 0, 'tls'],
2329
+ [449, V, 'sni'],
2330
+ [460, 0, 'quic'],
2331
+ [461, 0, 'quic-v1'],
2332
+ [465, 0, 'webtransport'],
2333
+ [466, V, 'certhash'],
2334
+ [477, 0, 'ws'],
2335
+ [478, 0, 'wss'],
2336
+ [479, 0, 'p2p-websocket-star'],
2337
+ [480, 0, 'http'],
2338
+ [481, V, 'http-path'],
2339
+ [777, V, 'memory']
2340
+ ];
2341
+ // populate tables
2342
+ table.forEach(row => {
2343
+ const proto = createProtocol(...row);
2344
+ codes[proto.code] = proto;
2345
+ names[proto.name] = proto;
2346
+ });
2347
+ function createProtocol(code, size, name, resolvable, path) {
2348
+ return {
2349
+ code,
2350
+ size,
2351
+ name,
2352
+ resolvable: Boolean(resolvable),
2353
+ path: Boolean(path)
2354
+ };
2355
+ }
2356
+ /**
2357
+ * For the passed proto string or number, return a {@link Protocol}
2358
+ *
2359
+ * @example
2360
+ *
2361
+ * ```js
2362
+ * import { protocol } from '@multiformats/multiaddr'
2363
+ *
2364
+ * console.info(protocol(4))
2365
+ * // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }
2366
+ * ```
2367
+ */
2368
+ function getProtocol(proto) {
2369
+ if (typeof proto === 'number') {
2370
+ if (codes[proto] != null) {
2371
+ return codes[proto];
2372
+ }
2373
+ throw new Error(`no protocol with code: ${proto}`);
2374
+ }
2375
+ else if (typeof proto === 'string') {
2376
+ if (names[proto] != null) {
2377
+ return names[proto];
2378
+ }
2379
+ throw new Error(`no protocol with name: ${proto}`);
2380
+ }
2381
+ throw new Error(`invalid protocol id type: ${typeof proto}`);
2382
+ }
2383
+ //# sourceMappingURL=protocols-table.js.map
2384
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/dist/src/convert.js
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
2391
+
2392
+
2393
+
2394
+
2395
+
2396
+
2397
+ const ip4Protocol = getProtocol('ip4');
2398
+ const ip6Protocol = getProtocol('ip6');
2399
+ const ipcidrProtocol = getProtocol('ipcidr');
2400
+ function convert(proto, a) {
2401
+ if (a instanceof Uint8Array) {
2402
+ return convertToString(proto, a);
2403
+ }
2404
+ else {
2405
+ return convertToBytes(proto, a);
2406
+ }
2407
+ }
2408
+ /**
2409
+ * Convert [code,Uint8Array] to string
2410
+ */
2411
+ // eslint-disable-next-line complexity
2412
+ function convertToString(proto, buf) {
2413
+ const protocol = getProtocol(proto);
2414
+ switch (protocol.code) {
2415
+ case 4: // ipv4
2416
+ case 41: // ipv6
2417
+ return bytes2ip(buf);
2418
+ case 42: // ipv6zone
2419
+ return bytes2str(buf);
2420
+ case 43: // ipcidr
2421
+ return (0,to_string.toString)(buf, 'base10');
2422
+ case 6: // tcp
2423
+ case 273: // udp
2424
+ case 33: // dccp
2425
+ case 132: // sctp
2426
+ return bytes2port(buf).toString();
2427
+ case 53: // dns
2428
+ case 54: // dns4
2429
+ case 55: // dns6
2430
+ case 56: // dnsaddr
2431
+ case 400: // unix
2432
+ case 449: // sni
2433
+ case 777: // memory
2434
+ return bytes2str(buf);
2435
+ case 421: // ipfs
2436
+ return bytes2mh(buf);
2437
+ case 444: // onion
2438
+ return bytes2onion(buf);
2439
+ case 445: // onion3
2440
+ return bytes2onion(buf);
2441
+ case 466: // certhash
2442
+ return bytes2mb(buf);
2443
+ case 481: // http-path
2444
+ return globalThis.encodeURIComponent(bytes2str(buf));
2445
+ default:
2446
+ return (0,to_string.toString)(buf, 'base16'); // no clue. convert to hex
2447
+ }
2448
+ }
2449
+ // eslint-disable-next-line complexity
2450
+ function convertToBytes(proto, str) {
2451
+ const protocol = getProtocol(proto);
2452
+ switch (protocol.code) {
2453
+ case 4: // ipv4
2454
+ return ip2bytes(str);
2455
+ case 41: // ipv6
2456
+ return ip2bytes(str);
2457
+ case 42: // ipv6zone
2458
+ return str2bytes(str);
2459
+ case 43: // ipcidr
2460
+ return (0,from_string.fromString)(str, 'base10');
2461
+ case 6: // tcp
2462
+ case 273: // udp
2463
+ case 33: // dccp
2464
+ case 132: // sctp
2465
+ return port2bytes(parseInt(str, 10));
2466
+ case 53: // dns
2467
+ case 54: // dns4
2468
+ case 55: // dns6
2469
+ case 56: // dnsaddr
2470
+ case 400: // unix
2471
+ case 449: // sni
2472
+ case 777: // memory
2473
+ return str2bytes(str);
2474
+ case 421: // ipfs
2475
+ return mh2bytes(str);
2476
+ case 444: // onion
2477
+ return onion2bytes(str);
2478
+ case 445: // onion3
2479
+ return onion32bytes(str);
2480
+ case 466: // certhash
2481
+ return mb2bytes(str);
2482
+ case 481: // http-path
2483
+ return str2bytes(globalThis.decodeURIComponent(str));
2484
+ default:
2485
+ return (0,from_string.fromString)(str, 'base16'); // no clue. convert from hex
2486
+ }
2487
+ }
2488
+ function convertToIpNet(multiaddr) {
2489
+ let mask;
2490
+ let addr;
2491
+ multiaddr.stringTuples().forEach(([code, value]) => {
2492
+ if (code === ip4Protocol.code || code === ip6Protocol.code) {
2493
+ addr = value;
2494
+ }
2495
+ if (code === ipcidrProtocol.code) {
2496
+ mask = value;
2497
+ }
2498
+ });
2499
+ if (mask == null || addr == null) {
2500
+ throw new Error('Invalid multiaddr');
2501
+ }
2502
+ return new IpNet(addr, mask);
2503
+ }
2504
+ const decoders = Object.values(bases).map((c) => c.decoder);
2505
+ const anybaseDecoder = (function () {
2506
+ let acc = decoders[0].or(decoders[1]);
2507
+ decoders.slice(2).forEach((d) => (acc = acc.or(d)));
2508
+ return acc;
2509
+ })();
2510
+ function ip2bytes(ipString) {
2511
+ if (!isIP(ipString)) {
2512
+ throw new Error('invalid ip address');
2513
+ }
2514
+ return toBytes(ipString);
2515
+ }
2516
+ function bytes2ip(ipBuff) {
2517
+ const ipString = ip_toString(ipBuff, 0, ipBuff.length);
2518
+ if (ipString == null) {
2519
+ throw new Error('ipBuff is required');
2520
+ }
2521
+ if (!isIP(ipString)) {
2522
+ throw new Error('invalid ip address');
2523
+ }
2524
+ return ipString;
2525
+ }
2526
+ function port2bytes(port) {
2527
+ const buf = new ArrayBuffer(2);
2528
+ const view = new DataView(buf);
2529
+ view.setUint16(0, port);
2530
+ return new Uint8Array(buf);
2531
+ }
2532
+ function bytes2port(buf) {
2533
+ const view = new DataView(buf.buffer);
2534
+ return view.getUint16(buf.byteOffset);
2535
+ }
2536
+ function str2bytes(str) {
2537
+ const buf = (0,from_string.fromString)(str);
2538
+ const size = Uint8Array.from(src.encode(buf.length));
2539
+ return (0,concat.concat)([size, buf], size.length + buf.length);
2540
+ }
2541
+ function bytes2str(buf) {
2542
+ const size = src.decode(buf);
2543
+ buf = buf.slice(src.encodingLength(size));
2544
+ if (buf.length !== size) {
2545
+ throw new Error('inconsistent lengths');
2546
+ }
2547
+ return (0,to_string.toString)(buf);
2548
+ }
2549
+ function mh2bytes(hash) {
2550
+ let mh;
2551
+ if (hash[0] === 'Q' || hash[0] === '1') {
2552
+ mh = digest_decode(base58btc.decode(`z${hash}`)).bytes;
2553
+ }
2554
+ else {
2555
+ mh = CID.parse(hash).multihash.bytes;
2556
+ }
2557
+ // the address is a varint prefixed multihash string representation
2558
+ const size = Uint8Array.from(src.encode(mh.length));
2559
+ return (0,concat.concat)([size, mh], size.length + mh.length);
2560
+ }
2561
+ function mb2bytes(mbstr) {
2562
+ const mb = anybaseDecoder.decode(mbstr);
2563
+ const size = Uint8Array.from(src.encode(mb.length));
2564
+ return (0,concat.concat)([size, mb], size.length + mb.length);
2565
+ }
2566
+ function bytes2mb(buf) {
2567
+ const size = src.decode(buf);
2568
+ const hash = buf.slice(src.encodingLength(size));
2569
+ if (hash.length !== size) {
2570
+ throw new Error('inconsistent lengths');
2571
+ }
2572
+ return 'u' + (0,to_string.toString)(hash, 'base64url');
2573
+ }
2574
+ /**
2575
+ * Converts bytes to bas58btc string
2576
+ */
2577
+ function bytes2mh(buf) {
2578
+ const size = src.decode(buf);
2579
+ const address = buf.slice(src.encodingLength(size));
2580
+ if (address.length !== size) {
2581
+ throw new Error('inconsistent lengths');
2582
+ }
2583
+ return (0,to_string.toString)(address, 'base58btc');
2584
+ }
2585
+ function onion2bytes(str) {
2586
+ const addr = str.split(':');
2587
+ if (addr.length !== 2) {
2588
+ throw new Error(`failed to parse onion addr: ["'${addr.join('", "')}'"]' does not contain a port number`);
2589
+ }
2590
+ if (addr[0].length !== 16) {
2591
+ throw new Error(`failed to parse onion addr: ${addr[0]} not a Tor onion address.`);
2592
+ }
2593
+ // onion addresses do not include the multibase prefix, add it before decoding
2594
+ const buf = base32.decode('b' + addr[0]);
2595
+ // onion port number
2596
+ const port = parseInt(addr[1], 10);
2597
+ if (port < 1 || port > 65536) {
2598
+ throw new Error('Port number is not in range(1, 65536)');
2599
+ }
2600
+ const portBuf = port2bytes(port);
2601
+ return (0,concat.concat)([buf, portBuf], buf.length + portBuf.length);
2602
+ }
2603
+ function onion32bytes(str) {
2604
+ const addr = str.split(':');
2605
+ if (addr.length !== 2) {
2606
+ throw new Error(`failed to parse onion addr: ["'${addr.join('", "')}'"]' does not contain a port number`);
2607
+ }
2608
+ if (addr[0].length !== 56) {
2609
+ throw new Error(`failed to parse onion addr: ${addr[0]} not a Tor onion3 address.`);
2610
+ }
2611
+ // onion addresses do not include the multibase prefix, add it before decoding
2612
+ const buf = base32.decode(`b${addr[0]}`);
2613
+ // onion port number
2614
+ const port = parseInt(addr[1], 10);
2615
+ if (port < 1 || port > 65536) {
2616
+ throw new Error('Port number is not in range(1, 65536)');
2617
+ }
2618
+ const portBuf = port2bytes(port);
2619
+ return (0,concat.concat)([buf, portBuf], buf.length + portBuf.length);
2620
+ }
2621
+ function bytes2onion(buf) {
2622
+ const addrBytes = buf.slice(0, buf.length - 2);
2623
+ const portBytes = buf.slice(buf.length - 2);
2624
+ const addr = (0,to_string.toString)(addrBytes, 'base32');
2625
+ const port = bytes2port(portBytes);
2626
+ return `${addr}:${port}`;
2627
+ }
2628
+ //# sourceMappingURL=convert.js.map
2629
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/dist/src/codec.js
2630
+
2631
+
2632
+
2633
+
2634
+
2635
+ function stringToMultiaddrParts(str) {
2636
+ str = cleanPath(str);
2637
+ const tuples = [];
2638
+ const stringTuples = [];
2639
+ let path = null;
2640
+ const parts = str.split('/').slice(1);
2641
+ if (parts.length === 1 && parts[0] === '') {
2642
+ return {
2643
+ bytes: new Uint8Array(),
2644
+ string: '/',
2645
+ tuples: [],
2646
+ stringTuples: [],
2647
+ path: null
2648
+ };
2649
+ }
2650
+ for (let p = 0; p < parts.length; p++) {
2651
+ const part = parts[p];
2652
+ const proto = getProtocol(part);
2653
+ if (proto.size === 0) {
2654
+ tuples.push([proto.code]);
2655
+ stringTuples.push([proto.code]);
2656
+ // eslint-disable-next-line no-continue
2657
+ continue;
2658
+ }
2659
+ p++; // advance addr part
2660
+ if (p >= parts.length) {
2661
+ throw new ParseError('invalid address: ' + str);
2662
+ }
2663
+ // if it's a path proto, take the rest
2664
+ if (proto.path === true) {
2665
+ // should we need to check each path part to see if it's a proto?
2666
+ // This would allow for other protocols to be added after a unix path,
2667
+ // however it would have issues if the path had a protocol name in the path
2668
+ path = cleanPath(parts.slice(p).join('/'));
2669
+ tuples.push([proto.code, convertToBytes(proto.code, path)]);
2670
+ stringTuples.push([proto.code, path]);
2671
+ break;
2672
+ }
2673
+ const bytes = convertToBytes(proto.code, parts[p]);
2674
+ tuples.push([proto.code, bytes]);
2675
+ stringTuples.push([proto.code, convertToString(proto.code, bytes)]);
2676
+ }
2677
+ return {
2678
+ string: stringTuplesToString(stringTuples),
2679
+ bytes: tuplesToBytes(tuples),
2680
+ tuples,
2681
+ stringTuples,
2682
+ path
2683
+ };
2684
+ }
2685
+ function bytesToMultiaddrParts(bytes) {
2686
+ const tuples = [];
2687
+ const stringTuples = [];
2688
+ let path = null;
2689
+ let i = 0;
2690
+ while (i < bytes.length) {
2691
+ const code = src.decode(bytes, i);
2692
+ const n = src.encodingLength(code);
2693
+ const p = getProtocol(code);
2694
+ const size = sizeForAddr(p, bytes.slice(i + n));
2695
+ if (size === 0) {
2696
+ tuples.push([code]);
2697
+ stringTuples.push([code]);
2698
+ i += n;
2699
+ // eslint-disable-next-line no-continue
2700
+ continue;
2701
+ }
2702
+ const addr = bytes.slice(i + n, i + n + size);
2703
+ i += (size + n);
2704
+ if (i > bytes.length) { // did not end _exactly_ at buffer.length
2705
+ throw new ParseError('Invalid address Uint8Array: ' + (0,to_string.toString)(bytes, 'base16'));
2706
+ }
2707
+ // ok, tuple seems good.
2708
+ tuples.push([code, addr]);
2709
+ const stringAddr = convertToString(code, addr);
2710
+ stringTuples.push([code, stringAddr]);
2711
+ if (p.path === true) {
2712
+ // should we need to check each path part to see if it's a proto?
2713
+ // This would allow for other protocols to be added after a unix path,
2714
+ // however it would have issues if the path had a protocol name in the path
2715
+ path = stringAddr;
2716
+ break;
2717
+ }
2718
+ }
2719
+ return {
2720
+ bytes: Uint8Array.from(bytes),
2721
+ string: stringTuplesToString(stringTuples),
2722
+ tuples,
2723
+ stringTuples,
2724
+ path
2725
+ };
2726
+ }
2727
+ /**
2728
+ * [[num code, str value?]... ] -> Tuple[]
2729
+ */
2730
+ function stringTuplesToTuples(stringTuples) {
2731
+ const tuples = [];
2732
+ stringTuples.forEach(([code, value]) => {
2733
+ const tuple = [code];
2734
+ if (value != null) {
2735
+ tuple[1] = convertToBytes(code, value);
2736
+ }
2737
+ tuples.push(tuple);
2738
+ });
2739
+ return tuples;
2740
+ }
2741
+ /**
2742
+ * [[num code, str value?]... ] -> string
2743
+ */
2744
+ function stringTuplesToString(tuples) {
2745
+ const parts = [];
2746
+ tuples.map((tup) => {
2747
+ const proto = getProtocol(tup[0]);
2748
+ parts.push(proto.name);
2749
+ if (tup.length > 1 && tup[1] != null) {
2750
+ parts.push(tup[1]);
2751
+ }
2752
+ return null;
2753
+ });
2754
+ return cleanPath(parts.join('/'));
2755
+ }
2756
+ /**
2757
+ * [[int code, Uint8Array ]... ] -> Uint8Array
2758
+ */
2759
+ function tuplesToBytes(tuples) {
2760
+ return (0,concat.concat)(tuples.map((tup) => {
2761
+ const proto = getProtocol(tup[0]);
2762
+ let buf = Uint8Array.from(src.encode(proto.code));
2763
+ if (tup.length > 1 && tup[1] != null) {
2764
+ buf = (0,concat.concat)([buf, tup[1]]); // add address buffer
2765
+ }
2766
+ return buf;
2767
+ }));
2768
+ }
2769
+ /**
2770
+ * For the passed address, return the serialized size
2771
+ */
2772
+ function sizeForAddr(p, addr) {
2773
+ if (p.size > 0) {
2774
+ return p.size / 8;
2775
+ }
2776
+ else if (p.size === 0) {
2777
+ return 0;
2778
+ }
2779
+ else {
2780
+ const size = src.decode(addr instanceof Uint8Array ? addr : Uint8Array.from(addr));
2781
+ return size + src.encodingLength(size);
2782
+ }
2783
+ }
2784
+ function bytesToTuples(buf) {
2785
+ const tuples = [];
2786
+ let i = 0;
2787
+ while (i < buf.length) {
2788
+ const code = src.decode(buf, i);
2789
+ const n = src.encodingLength(code);
2790
+ const p = getProtocol(code);
2791
+ const size = sizeForAddr(p, buf.slice(i + n));
2792
+ if (size === 0) {
2793
+ tuples.push([code]);
2794
+ i += n;
2795
+ // eslint-disable-next-line no-continue
2796
+ continue;
2797
+ }
2798
+ const addr = buf.slice(i + n, i + n + size);
2799
+ i += (size + n);
2800
+ if (i > buf.length) { // did not end _exactly_ at buffer.length
2801
+ throw new ParseError('Invalid address Uint8Array: ' + (0,to_string.toString)(buf, 'base16'));
2802
+ }
2803
+ // ok, tuple seems good.
2804
+ tuples.push([code, addr]);
2805
+ }
2806
+ return tuples;
2807
+ }
2808
+ function cleanPath(str) {
2809
+ return '/' + str.trim().split('/').filter((a) => a).join('/');
2810
+ }
2811
+ class ParseError extends Error {
2812
+ static name = 'ParseError';
2813
+ name = 'ParseError';
2814
+ constructor(str) {
2815
+ super(`Error parsing address: ${str}`);
2816
+ }
2817
+ }
2818
+ //# sourceMappingURL=codec.js.map
2819
+ // EXTERNAL MODULE: ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/equals.js
2820
+ var src_equals = __webpack_require__("./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/equals.js");
2821
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js
2822
+ /* eslint-disable complexity */
2823
+
2824
+
2825
+
2826
+
2827
+
2828
+
2829
+
2830
+ const inspect = Symbol.for('nodejs.util.inspect.custom');
2831
+ const symbol = Symbol.for('@multiformats/js-multiaddr/multiaddr');
2832
+ const DNS_CODES = [
2833
+ getProtocol('dns').code,
2834
+ getProtocol('dns4').code,
2835
+ getProtocol('dns6').code,
2836
+ getProtocol('dnsaddr').code
2837
+ ];
2838
+ class NoAvailableResolverError extends Error {
2839
+ constructor(message = 'No available resolver') {
2840
+ super(message);
2841
+ this.name = 'NoAvailableResolverError';
2842
+ }
2843
+ }
2844
+ /**
2845
+ * Creates a {@link Multiaddr} from a {@link MultiaddrInput}
2846
+ */
2847
+ class Multiaddr {
2848
+ bytes;
2849
+ #string;
2850
+ #tuples;
2851
+ #stringTuples;
2852
+ #path;
2853
+ [symbol] = true;
2854
+ constructor(addr) {
2855
+ // default
2856
+ if (addr == null) {
2857
+ addr = '';
2858
+ }
2859
+ let parts;
2860
+ if (addr instanceof Uint8Array) {
2861
+ parts = bytesToMultiaddrParts(addr);
2862
+ }
2863
+ else if (typeof addr === 'string') {
2864
+ if (addr.length > 0 && addr.charAt(0) !== '/') {
2865
+ throw new Error(`multiaddr "${addr}" must start with a "/"`);
2866
+ }
2867
+ parts = stringToMultiaddrParts(addr);
2868
+ }
2869
+ else if (isMultiaddr(addr)) { // Multiaddr
2870
+ parts = bytesToMultiaddrParts(addr.bytes);
2871
+ }
2872
+ else {
2873
+ throw new Error('addr must be a string, Buffer, or another Multiaddr');
2874
+ }
2875
+ this.bytes = parts.bytes;
2876
+ this.#string = parts.string;
2877
+ this.#tuples = parts.tuples;
2878
+ this.#stringTuples = parts.stringTuples;
2879
+ this.#path = parts.path;
2880
+ }
2881
+ toString() {
2882
+ return this.#string;
2883
+ }
2884
+ toJSON() {
2885
+ return this.toString();
2886
+ }
2887
+ toOptions() {
2888
+ let family;
2889
+ let transport;
2890
+ let host;
2891
+ let port;
2892
+ let zone = '';
2893
+ const tcp = getProtocol('tcp');
2894
+ const udp = getProtocol('udp');
2895
+ const ip4 = getProtocol('ip4');
2896
+ const ip6 = getProtocol('ip6');
2897
+ const dns6 = getProtocol('dns6');
2898
+ const ip6zone = getProtocol('ip6zone');
2899
+ for (const [code, value] of this.stringTuples()) {
2900
+ if (code === ip6zone.code) {
2901
+ zone = `%${value ?? ''}`;
2902
+ }
2903
+ // default to https when protocol & port are omitted from DNS addrs
2904
+ if (DNS_CODES.includes(code)) {
2905
+ transport = tcp.name === 'tcp' ? 'tcp' : 'udp';
2906
+ port = 443;
2907
+ host = `${value ?? ''}${zone}`;
2908
+ family = code === dns6.code ? 6 : 4;
2909
+ }
2910
+ if (code === tcp.code || code === udp.code) {
2911
+ transport = getProtocol(code).name === 'tcp' ? 'tcp' : 'udp';
2912
+ port = parseInt(value ?? '');
2913
+ }
2914
+ if (code === ip4.code || code === ip6.code) {
2915
+ transport = getProtocol(code).name === 'tcp' ? 'tcp' : 'udp';
2916
+ host = `${value ?? ''}${zone}`;
2917
+ family = code === ip6.code ? 6 : 4;
2918
+ }
2919
+ }
2920
+ if (family == null || transport == null || host == null || port == null) {
2921
+ throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');
2922
+ }
2923
+ const opts = {
2924
+ family,
2925
+ host,
2926
+ transport,
2927
+ port
2928
+ };
2929
+ return opts;
2930
+ }
2931
+ protos() {
2932
+ return this.#tuples.map(([code]) => Object.assign({}, getProtocol(code)));
2933
+ }
2934
+ protoCodes() {
2935
+ return this.#tuples.map(([code]) => code);
2936
+ }
2937
+ protoNames() {
2938
+ return this.#tuples.map(([code]) => getProtocol(code).name);
2939
+ }
2940
+ tuples() {
2941
+ return this.#tuples.map(([code, value]) => {
2942
+ if (value == null) {
2943
+ return [code];
2944
+ }
2945
+ return [code, value];
2946
+ });
2947
+ }
2948
+ stringTuples() {
2949
+ return this.#stringTuples.map(([code, value]) => {
2950
+ if (value == null) {
2951
+ return [code];
2952
+ }
2953
+ return [code, value];
2954
+ });
2955
+ }
2956
+ encapsulate(addr) {
2957
+ addr = new Multiaddr(addr);
2958
+ return new Multiaddr(this.toString() + addr.toString());
2959
+ }
2960
+ decapsulate(addr) {
2961
+ const addrString = addr.toString();
2962
+ const s = this.toString();
2963
+ const i = s.lastIndexOf(addrString);
2964
+ if (i < 0) {
2965
+ throw new Error(`Address ${this.toString()} does not contain subaddress: ${addr.toString()}`);
2966
+ }
2967
+ return new Multiaddr(s.slice(0, i));
2968
+ }
2969
+ decapsulateCode(code) {
2970
+ const tuples = this.tuples();
2971
+ for (let i = tuples.length - 1; i >= 0; i--) {
2972
+ if (tuples[i][0] === code) {
2973
+ return new Multiaddr(tuplesToBytes(tuples.slice(0, i)));
2974
+ }
2975
+ }
2976
+ return this;
2977
+ }
2978
+ getPeerId() {
2979
+ try {
2980
+ let tuples = [];
2981
+ this.stringTuples().forEach(([code, name]) => {
2982
+ if (code === names.p2p.code) {
2983
+ tuples.push([code, name]);
2984
+ }
2985
+ // if this is a p2p-circuit address, return the target peer id if present
2986
+ // not the peer id of the relay
2987
+ if (code === names['p2p-circuit'].code) {
2988
+ tuples = [];
2989
+ }
2990
+ });
2991
+ // Get the last ipfs tuple ['p2p', 'peerid string']
2992
+ const tuple = tuples.pop();
2993
+ if (tuple?.[1] != null) {
2994
+ const peerIdStr = tuple[1];
2995
+ // peer id is base58btc encoded string but not multibase encoded so add the `z`
2996
+ // prefix so we can validate that it is correctly encoded
2997
+ if (peerIdStr[0] === 'Q' || peerIdStr[0] === '1') {
2998
+ return (0,to_string.toString)(base58btc.decode(`z${peerIdStr}`), 'base58btc');
2999
+ }
3000
+ // try to parse peer id as CID
3001
+ return (0,to_string.toString)(CID.parse(peerIdStr).multihash.bytes, 'base58btc');
3002
+ }
3003
+ return null;
3004
+ }
3005
+ catch (e) {
3006
+ return null;
3007
+ }
3008
+ }
3009
+ getPath() {
3010
+ return this.#path;
3011
+ }
3012
+ equals(addr) {
3013
+ return (0,src_equals.equals)(this.bytes, addr.bytes);
3014
+ }
3015
+ async resolve(options) {
3016
+ const resolvableProto = this.protos().find((p) => p.resolvable);
3017
+ // Multiaddr is not resolvable?
3018
+ if (resolvableProto == null) {
3019
+ return [this];
3020
+ }
3021
+ const resolver = resolvers.get(resolvableProto.name);
3022
+ if (resolver == null) {
3023
+ throw new NoAvailableResolverError(`no available resolver for ${resolvableProto.name}`);
3024
+ }
3025
+ const result = await resolver(this, options);
3026
+ return result.map(str => multiaddr(str));
3027
+ }
3028
+ nodeAddress() {
3029
+ const options = this.toOptions();
3030
+ if (options.transport !== 'tcp' && options.transport !== 'udp') {
3031
+ throw new Error(`multiaddr must have a valid format - no protocol with name: "${options.transport}". Must have a valid transport protocol: "{tcp, udp}"`);
3032
+ }
3033
+ return {
3034
+ family: options.family,
3035
+ address: options.host,
3036
+ port: options.port
3037
+ };
3038
+ }
3039
+ isThinWaistAddress(addr) {
3040
+ const protos = (addr ?? this).protos();
3041
+ if (protos.length !== 2) {
3042
+ return false;
3043
+ }
3044
+ if (protos[0].code !== 4 && protos[0].code !== 41) {
3045
+ return false;
3046
+ }
3047
+ if (protos[1].code !== 6 && protos[1].code !== 273) {
3048
+ return false;
3049
+ }
3050
+ return true;
3051
+ }
3052
+ /**
3053
+ * Returns Multiaddr as a human-readable string
3054
+ * https://nodejs.org/api/util.html#utilinspectcustom
3055
+ *
3056
+ * @example
3057
+ * ```js
3058
+ * import { multiaddr } from '@multiformats/multiaddr'
3059
+ *
3060
+ * console.info(multiaddr('/ip4/127.0.0.1/tcp/4001'))
3061
+ * // 'Multiaddr(/ip4/127.0.0.1/tcp/4001)'
3062
+ * ```
3063
+ */
3064
+ [inspect]() {
3065
+ return `Multiaddr(${this.#string})`;
3066
+ }
3067
+ }
3068
+ //# sourceMappingURL=multiaddr.js.map
3069
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.js
3070
+
3071
+
3072
+ /**
3073
+ * A utility class to determine if a Multiaddr contains another
3074
+ * multiaddr.
3075
+ *
3076
+ * This can be used with ipcidr ranges to determine if a given
3077
+ * multiaddr is in a ipcidr range.
3078
+ *
3079
+ * @example
3080
+ *
3081
+ * ```js
3082
+ * import { multiaddr, MultiaddrFilter } from '@multiformats/multiaddr'
3083
+ *
3084
+ * const range = multiaddr('/ip4/192.168.10.10/ipcidr/24')
3085
+ * const filter = new MultiaddrFilter(range)
3086
+ *
3087
+ * const input = multiaddr('/ip4/192.168.10.2/udp/60')
3088
+ * console.info(filter.contains(input)) // true
3089
+ * ```
3090
+ */
3091
+ class MultiaddrFilter {
3092
+ multiaddr;
3093
+ netmask;
3094
+ constructor(input) {
3095
+ this.multiaddr = multiaddr(input);
3096
+ this.netmask = convertToIpNet(this.multiaddr);
3097
+ }
3098
+ contains(input) {
3099
+ if (input == null)
3100
+ return false;
3101
+ const m = multiaddr(input);
3102
+ let ip;
3103
+ for (const [code, value] of m.stringTuples()) {
3104
+ if (code === 4 || code === 41) {
3105
+ ip = value;
3106
+ break;
3107
+ }
3108
+ }
3109
+ if (ip === undefined)
3110
+ return false;
3111
+ return this.netmask.contains(ip);
3112
+ }
3113
+ }
3114
+ //# sourceMappingURL=multiaddr-filter.js.map
3115
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/multiaddr/dist/src/index.js
3116
+ /**
3117
+ * @packageDocumentation
3118
+ *
3119
+ * A standard way to represent addresses that
3120
+ *
3121
+ * - support any standard network protocol
3122
+ * - are self-describing
3123
+ * - have a binary packed format
3124
+ * - have a nice string representation
3125
+ * - encapsulate well
3126
+ *
3127
+ * @example
3128
+ *
3129
+ * ```TypeScript
3130
+ * import { multiaddr } from '@multiformats/multiaddr'
3131
+ *
3132
+ * const addr = multiaddr('/ip4/127.0.0.1/udp/1234')
3133
+ * // Multiaddr(/ip4/127.0.0.1/udp/1234)
3134
+ *
3135
+ * addr.bytes
3136
+ * // <Uint8Array 04 7f 00 00 01 11 04 d2>
3137
+ *
3138
+ * addr.toString()
3139
+ * // '/ip4/127.0.0.1/udp/1234'
3140
+ *
3141
+ * addr.protos()
3142
+ * // [
3143
+ * // {code: 4, name: 'ip4', size: 32},
3144
+ * // {code: 273, name: 'udp', size: 16}
3145
+ * // ]
3146
+ *
3147
+ * // gives you an object that is friendly with what Node.js core modules expect for addresses
3148
+ * addr.nodeAddress()
3149
+ * // {
3150
+ * // family: 4,
3151
+ * // port: 1234,
3152
+ * // address: "127.0.0.1"
3153
+ * // }
3154
+ *
3155
+ * addr.encapsulate('/sctp/5678')
3156
+ * // Multiaddr(/ip4/127.0.0.1/udp/1234/sctp/5678)
3157
+ * ```
3158
+ *
3159
+ * ## Resolving DNSADDR addresses
3160
+ *
3161
+ * [DNSADDR](https://github.com/multiformats/multiaddr/blob/master/protocols/DNSADDR.md) is a spec that allows storing a TXT DNS record that contains a Multiaddr.
3162
+ *
3163
+ * To resolve DNSADDR addresses, call the `.resolve()` function the multiaddr, optionally passing a `DNS` resolver.
3164
+ *
3165
+ * DNSADDR addresses can resolve to multiple multiaddrs, since there is no limit to the number of TXT records that can be stored.
3166
+ *
3167
+ * @example Resolving DNSADDR Multiaddrs
3168
+ *
3169
+ * ```TypeScript
3170
+ * import { multiaddr, resolvers } from '@multiformats/multiaddr'
3171
+ * import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
3172
+ *
3173
+ * resolvers.set('dnsaddr', dnsaddrResolver)
3174
+ *
3175
+ * const ma = multiaddr('/dnsaddr/bootstrap.libp2p.io')
3176
+ *
3177
+ * // resolve with a 5s timeout
3178
+ * const resolved = await ma.resolve({
3179
+ * signal: AbortSignal.timeout(5000)
3180
+ * })
3181
+ *
3182
+ * console.info(resolved)
3183
+ * // [Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...')...]
3184
+ * ```
3185
+ *
3186
+ * @example Using a custom DNS resolver to resolve DNSADDR Multiaddrs
3187
+ *
3188
+ * See the docs for [@multiformats/dns](https://www.npmjs.com/package/@multiformats/dns) for a full breakdown of how to specify multiple resolvers or resolvers that can be used for specific TLDs.
3189
+ *
3190
+ * ```TypeScript
3191
+ * import { multiaddr } from '@multiformats/multiaddr'
3192
+ * import { dns } from '@multiformats/dns'
3193
+ * import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'
3194
+ *
3195
+ * const resolver = dns({
3196
+ * resolvers: {
3197
+ * '.': dnsJsonOverHttps('https://cloudflare-dns.com/dns-query')
3198
+ * }
3199
+ * })
3200
+ *
3201
+ * const ma = multiaddr('/dnsaddr/bootstrap.libp2p.io')
3202
+ * const resolved = await ma.resolve({
3203
+ * dns: resolver
3204
+ * })
3205
+ *
3206
+ * console.info(resolved)
3207
+ * // [Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...')...]
3208
+ * ```
3209
+ */
3210
+
3211
+
3212
+
3213
+ /**
3214
+ * All configured {@link Resolver}s
3215
+ */
3216
+ const resolvers = new Map();
3217
+
3218
+ /**
3219
+ * Creates a Multiaddr from a node-friendly address object
3220
+ *
3221
+ * @example
3222
+ * ```js
3223
+ * import { fromNodeAddress } from '@multiformats/multiaddr'
3224
+ *
3225
+ * fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')
3226
+ * // Multiaddr(/ip4/127.0.0.1/tcp/4001)
3227
+ * ```
3228
+ */
3229
+ function fromNodeAddress(addr, transport) {
3230
+ if (addr == null) {
3231
+ throw new Error('requires node address object');
3232
+ }
3233
+ if (transport == null) {
3234
+ throw new Error('requires transport protocol');
3235
+ }
3236
+ let ip;
3237
+ let host = addr.address;
3238
+ switch (addr.family) {
3239
+ case 4:
3240
+ ip = 'ip4';
3241
+ break;
3242
+ case 6:
3243
+ ip = 'ip6';
3244
+ if (host.includes('%')) {
3245
+ const parts = host.split('%');
3246
+ if (parts.length !== 2) {
3247
+ throw Error('Multiple ip6 zones in multiaddr');
3248
+ }
3249
+ host = parts[0];
3250
+ const zone = parts[1];
3251
+ ip = `/ip6zone/${zone}/ip6`;
3252
+ }
3253
+ break;
3254
+ default:
3255
+ throw Error('Invalid addr family, should be 4 or 6.');
3256
+ }
3257
+ return new Multiaddr('/' + [ip, host, transport, addr.port].join('/'));
3258
+ }
3259
+ /**
3260
+ * Create a {@link Multiaddr} from an array of {@link Tuple}s
3261
+ *
3262
+ * @example
3263
+ *
3264
+ * ```ts
3265
+ * import { fromTuples, multiaddr } from '@multiformats/multiaddr'
3266
+ *
3267
+ * const ma = multiaddr('/ip4/127.0.0.1')
3268
+ * const tuples = ma.tuples()
3269
+ *
3270
+ * const ma2 = fromTuples(tuples)
3271
+ *
3272
+ * console.info(ma2)
3273
+ * // '/ip4/127.0.0.1'
3274
+ * ```
3275
+ */
3276
+ function fromTuples(tuples) {
3277
+ return multiaddr(tuplesToBytes(tuples));
3278
+ }
3279
+ /**
3280
+ * Create a {@link Multiaddr} from an array of {@link StringTuple}s
3281
+ *
3282
+ * @example
3283
+ *
3284
+ * ```ts
3285
+ * import { fromStringTuples, multiaddr } from '@multiformats/multiaddr'
3286
+ *
3287
+ * const ma = multiaddr('/ip4/127.0.0.1')
3288
+ * const tuples = ma.stringTuples()
3289
+ *
3290
+ * const ma2 = fromStringTuples(tuples)
3291
+ *
3292
+ * console.info(ma2)
3293
+ * // '/ip4/127.0.0.1'
3294
+ * ```
3295
+ */
3296
+ function fromStringTuples(tuples) {
3297
+ return fromTuples(stringTuplesToTuples(tuples));
3298
+ }
3299
+ /**
3300
+ * Returns if something is a {@link Multiaddr} that is a resolvable name
3301
+ *
3302
+ * @example
3303
+ *
3304
+ * ```js
3305
+ * import { isName, multiaddr } from '@multiformats/multiaddr'
3306
+ *
3307
+ * isName(multiaddr('/ip4/127.0.0.1'))
3308
+ * // false
3309
+ * isName(multiaddr('/dns/ipfs.io'))
3310
+ * // true
3311
+ * ```
3312
+ */
3313
+ function isName(addr) {
3314
+ if (!isMultiaddr(addr)) {
3315
+ return false;
3316
+ }
3317
+ // if a part of the multiaddr is resolvable, then return true
3318
+ return addr.protos().some((proto) => proto.resolvable);
3319
+ }
3320
+ /**
3321
+ * Check if object is a {@link Multiaddr} instance
3322
+ *
3323
+ * @example
3324
+ *
3325
+ * ```js
3326
+ * import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'
3327
+ *
3328
+ * isMultiaddr(5)
3329
+ * // false
3330
+ * isMultiaddr(multiaddr('/ip4/127.0.0.1'))
3331
+ * // true
3332
+ * ```
3333
+ */
3334
+ function isMultiaddr(value) {
3335
+ return Boolean(value?.[symbol]);
3336
+ }
3337
+ /**
3338
+ * A function that takes a {@link MultiaddrInput} and returns a {@link Multiaddr}
3339
+ *
3340
+ * @example
3341
+ * ```js
3342
+ * import { multiaddr } from '@libp2p/multiaddr'
3343
+ *
3344
+ * multiaddr('/ip4/127.0.0.1/tcp/4001')
3345
+ * // Multiaddr(/ip4/127.0.0.1/tcp/4001)
3346
+ * ```
3347
+ *
3348
+ * @param {MultiaddrInput} [addr] - If String or Uint8Array, needs to adhere to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)
3349
+ */
3350
+ function multiaddr(addr) {
3351
+ return new Multiaddr(addr);
3352
+ }
3353
+
3354
+ //# sourceMappingURL=index.js.map
3355
+ ;// ./node_modules/shogun-ipfs/node_modules/@multiformats/mafmt/dist/src/index.js
3356
+
3357
+ /*
3358
+ * Valid combinations
3359
+ */
3360
+ const DNS4 = src_base('dns4');
3361
+ const DNS6 = src_base('dns6');
3362
+ const DNSADDR = src_base('dnsaddr');
3363
+ const DNS = src_or(src_base('dns'), DNSADDR, DNS4, DNS6);
3364
+ const IP = src_or(src_base('ip4'), src_base('ip6'));
3365
+ const TCP = src_or(and(IP, src_base('tcp')), and(DNS, src_base('tcp')));
3366
+ const UDP = and(IP, src_base('udp'));
3367
+ const UTP = and(UDP, src_base('utp'));
3368
+ const QUIC = and(UDP, src_base('quic'));
3369
+ const QUICV1 = and(UDP, src_base('quic-v1'));
3370
+ const _WebSockets = src_or(and(TCP, src_base('ws')), and(DNS, src_base('ws')));
3371
+ const WebSockets = src_or(and(_WebSockets, src_base('p2p')), _WebSockets);
3372
+ const _WebSocketsSecure = src_or(and(TCP, src_base('wss')), and(DNS, src_base('wss')), and(TCP, src_base('tls'), src_base('ws')), and(DNS, src_base('tls'), src_base('ws')));
3373
+ const WebSocketsSecure = src_or(and(_WebSocketsSecure, src_base('p2p')), _WebSocketsSecure);
3374
+ const HTTP = src_or(and(TCP, src_base('http')), and(IP, src_base('http')), and(DNS, src_base('http')));
3375
+ const HTTPS = src_or(and(TCP, src_base('https')), and(IP, src_base('https')), and(DNS, src_base('https')));
3376
+ const _WebRTCDirect = and(UDP, src_base('webrtc-direct'), src_base('certhash'));
3377
+ const WebRTCDirect = src_or(and(_WebRTCDirect, src_base('p2p')), _WebRTCDirect);
3378
+ const _WebTransport = and(QUICV1, src_base('webtransport'), src_base('certhash'), src_base('certhash'));
3379
+ const WebTransport = src_or(and(_WebTransport, src_base('p2p')), _WebTransport);
3380
+ /**
3381
+ * @deprecated
3382
+ */
3383
+ const P2PWebRTCStar = src_or(and(WebSockets, src_base('p2p-webrtc-star'), src_base('p2p')), and(WebSocketsSecure, src_base('p2p-webrtc-star'), src_base('p2p')), and(WebSockets, src_base('p2p-webrtc-star')), and(WebSocketsSecure, src_base('p2p-webrtc-star')));
3384
+ const WebSocketStar = src_or(and(WebSockets, src_base('p2p-websocket-star'), src_base('p2p')), and(WebSocketsSecure, src_base('p2p-websocket-star'), src_base('p2p')), and(WebSockets, src_base('p2p-websocket-star')), and(WebSocketsSecure, src_base('p2p-websocket-star')));
3385
+ /**
3386
+ * @deprecated
3387
+ */
3388
+ const P2PWebRTCDirect = src_or(and(HTTP, src_base('p2p-webrtc-direct'), src_base('p2p')), and(HTTPS, src_base('p2p-webrtc-direct'), src_base('p2p')), and(HTTP, src_base('p2p-webrtc-direct')), and(HTTPS, src_base('p2p-webrtc-direct')));
3389
+ const Reliable = src_or(_WebSockets, _WebSocketsSecure, HTTP, HTTPS, P2PWebRTCStar, P2PWebRTCDirect, TCP, UTP, QUIC, DNS, WebRTCDirect, WebTransport);
3390
+ // Unlike ws-star, stardust can run over any transport thus removing the requirement for websockets (but don't even think about running a stardust server over webrtc-star ;) )
3391
+ const Stardust = src_or(and(Reliable, src_base('p2p-stardust'), src_base('p2p')), and(Reliable, src_base('p2p-stardust')));
3392
+ const _P2P = src_or(and(Reliable, src_base('p2p')), P2PWebRTCStar, P2PWebRTCDirect, WebRTCDirect, WebTransport, src_base('p2p'));
3393
+ const _Circuit = src_or(and(_P2P, src_base('p2p-circuit'), _P2P), and(_P2P, src_base('p2p-circuit')), and(src_base('p2p-circuit'), _P2P), and(Reliable, src_base('p2p-circuit')), and(src_base('p2p-circuit'), Reliable), src_base('p2p-circuit'));
3394
+ const CircuitRecursive = () => src_or(and(_Circuit, CircuitRecursive), _Circuit);
3395
+ const Circuit = CircuitRecursive();
3396
+ const P2P = src_or(and(Circuit, _P2P, Circuit), and(_P2P, Circuit), and(Circuit, _P2P), Circuit, _P2P);
3397
+ const IPFS = P2P;
3398
+ const WebRTC = src_or(and(Circuit, src_base('webrtc'), src_base('p2p')), and(Circuit, src_base('webrtc')), and(Reliable, src_base('webrtc'), src_base('p2p')), and(Reliable, src_base('webrtc')), src_base('webrtc'));
3399
+ /*
3400
+ * Validation funcs
3401
+ */
3402
+ function makeMatchesFunction(partialMatch) {
3403
+ function matches(a) {
3404
+ let ma;
3405
+ try {
3406
+ ma = multiaddr(a);
3407
+ }
3408
+ catch (err) { // catch error
3409
+ return false; // also if it's invalid it's probably not matching as well so return false
3410
+ }
3411
+ const out = partialMatch(ma.protoNames());
3412
+ if (out === null) {
3413
+ return false;
3414
+ }
3415
+ if (out === true || out === false) {
3416
+ return out;
3417
+ }
3418
+ return out.length === 0;
3419
+ }
3420
+ return matches;
3421
+ }
3422
+ function and(...args) {
3423
+ function partialMatch(a) {
3424
+ if (a.length < args.length) {
3425
+ return null;
3426
+ }
3427
+ let out = a;
3428
+ args.some((arg) => {
3429
+ out = typeof arg === 'function'
3430
+ ? arg().partialMatch(a)
3431
+ : arg.partialMatch(a);
3432
+ if (Array.isArray(out)) {
3433
+ a = out;
3434
+ }
3435
+ if (out === null) {
3436
+ return true;
3437
+ }
3438
+ return false;
3439
+ });
3440
+ return out;
3441
+ }
3442
+ return {
3443
+ toString: function () { return '{ ' + args.join(' ') + ' }'; },
3444
+ input: args,
3445
+ matches: makeMatchesFunction(partialMatch),
3446
+ partialMatch
3447
+ };
3448
+ }
3449
+ function src_or(...args) {
3450
+ function partialMatch(a) {
3451
+ let out = null;
3452
+ args.some((arg) => {
3453
+ const res = typeof arg === 'function'
3454
+ ? arg().partialMatch(a)
3455
+ : arg.partialMatch(a);
3456
+ if (res != null) {
3457
+ out = res;
3458
+ return true;
3459
+ }
3460
+ return false;
3461
+ });
3462
+ return out;
3463
+ }
3464
+ const result = {
3465
+ toString: function () { return '{ ' + args.join(' ') + ' }'; },
3466
+ input: args,
3467
+ matches: makeMatchesFunction(partialMatch),
3468
+ partialMatch
3469
+ };
3470
+ return result;
3471
+ }
3472
+ function src_base(n) {
3473
+ const name = n;
3474
+ function matches(a) {
3475
+ let ma;
3476
+ try {
3477
+ ma = multiaddr(a);
3478
+ }
3479
+ catch (err) { // catch error
3480
+ return false; // also if it's invalid it's probably not matching as well so return false
3481
+ }
3482
+ const pnames = ma.protoNames();
3483
+ if (pnames.length === 1 && pnames[0] === name) {
3484
+ return true;
3485
+ }
3486
+ return false;
3487
+ }
3488
+ function partialMatch(protos) {
3489
+ if (protos.length === 0) {
3490
+ return null;
3491
+ }
3492
+ if (protos[0] === name) {
3493
+ return protos.slice(1);
3494
+ }
3495
+ return null;
3496
+ }
3497
+ return {
3498
+ toString: function () { return name; },
3499
+ matches,
3500
+ partialMatch
3501
+ };
3502
+ }
3503
+ //# sourceMappingURL=index.js.map
3504
+ // EXTERNAL MODULE: ./node_modules/shogun-ipfs/node_modules/iso-url/index.js
3505
+ var iso_url = __webpack_require__("./node_modules/shogun-ipfs/node_modules/iso-url/index.js");
3506
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/bytes.js
3507
+ const bytes_empty = new Uint8Array(0);
3508
+ function bytes_toHex(d) {
3509
+ return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '');
3510
+ }
3511
+ function bytes_fromHex(hex) {
3512
+ const hexes = hex.match(/../g);
3513
+ return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : bytes_empty;
3514
+ }
3515
+ function bytes_equals(aa, bb) {
3516
+ if (aa === bb)
3517
+ return true;
3518
+ if (aa.byteLength !== bb.byteLength) {
3519
+ return false;
3520
+ }
3521
+ for (let ii = 0; ii < aa.byteLength; ii++) {
3522
+ if (aa[ii] !== bb[ii]) {
3523
+ return false;
3524
+ }
3525
+ }
3526
+ return true;
3527
+ }
3528
+ function bytes_coerce(o) {
3529
+ if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')
3530
+ return o;
3531
+ if (o instanceof ArrayBuffer)
3532
+ return new Uint8Array(o);
3533
+ if (ArrayBuffer.isView(o)) {
3534
+ return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
3535
+ }
3536
+ throw new Error('Unknown type, must be binary type');
3537
+ }
3538
+ function bytes_isBinary(o) {
3539
+ return o instanceof ArrayBuffer || ArrayBuffer.isView(o);
3540
+ }
3541
+ function bytes_fromString(str) {
3542
+ return new TextEncoder().encode(str);
3543
+ }
3544
+ function src_bytes_toString(b) {
3545
+ return new TextDecoder().decode(b);
3546
+ }
3547
+ //# sourceMappingURL=bytes.js.map
3548
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/vendor/base-x.js
3549
+ /* eslint-disable */
3550
+ // base-x encoding / decoding
3551
+ // Copyright (c) 2018 base-x contributors
3552
+ // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
3553
+ // Distributed under the MIT software license, see the accompanying
3554
+ // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
3555
+ /**
3556
+ * @param {string} ALPHABET
3557
+ * @param {any} name
3558
+ */
3559
+ function base_x_base(ALPHABET, name) {
3560
+ if (ALPHABET.length >= 255) {
3561
+ throw new TypeError('Alphabet too long');
3562
+ }
3563
+ var BASE_MAP = new Uint8Array(256);
3564
+ for (var j = 0; j < BASE_MAP.length; j++) {
3565
+ BASE_MAP[j] = 255;
3566
+ }
3567
+ for (var i = 0; i < ALPHABET.length; i++) {
3568
+ var x = ALPHABET.charAt(i);
3569
+ var xc = x.charCodeAt(0);
3570
+ if (BASE_MAP[xc] !== 255) {
3571
+ throw new TypeError(x + ' is ambiguous');
3572
+ }
3573
+ BASE_MAP[xc] = i;
3574
+ }
3575
+ var BASE = ALPHABET.length;
3576
+ var LEADER = ALPHABET.charAt(0);
3577
+ var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
3578
+ var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
3579
+ /**
3580
+ * @param {any[] | Iterable<number>} source
3581
+ */
3582
+ function encode(source) {
3583
+ // @ts-ignore
3584
+ if (source instanceof Uint8Array)
3585
+ ;
3586
+ else if (ArrayBuffer.isView(source)) {
3587
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
3588
+ }
3589
+ else if (Array.isArray(source)) {
3590
+ source = Uint8Array.from(source);
3591
+ }
3592
+ if (!(source instanceof Uint8Array)) {
3593
+ throw new TypeError('Expected Uint8Array');
3594
+ }
3595
+ if (source.length === 0) {
3596
+ return '';
3597
+ }
3598
+ // Skip & count leading zeroes.
3599
+ var zeroes = 0;
3600
+ var length = 0;
3601
+ var pbegin = 0;
3602
+ var pend = source.length;
3603
+ while (pbegin !== pend && source[pbegin] === 0) {
3604
+ pbegin++;
3605
+ zeroes++;
3606
+ }
3607
+ // Allocate enough space in big-endian base58 representation.
3608
+ var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
3609
+ var b58 = new Uint8Array(size);
3610
+ // Process the bytes.
3611
+ while (pbegin !== pend) {
3612
+ var carry = source[pbegin];
3613
+ // Apply "b58 = b58 * 256 + ch".
3614
+ var i = 0;
3615
+ for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
3616
+ carry += (256 * b58[it1]) >>> 0;
3617
+ b58[it1] = (carry % BASE) >>> 0;
3618
+ carry = (carry / BASE) >>> 0;
3619
+ }
3620
+ if (carry !== 0) {
3621
+ throw new Error('Non-zero carry');
3622
+ }
3623
+ length = i;
3624
+ pbegin++;
3625
+ }
3626
+ // Skip leading zeroes in base58 result.
3627
+ var it2 = size - length;
3628
+ while (it2 !== size && b58[it2] === 0) {
3629
+ it2++;
3630
+ }
3631
+ // Translate the result into a string.
3632
+ var str = LEADER.repeat(zeroes);
3633
+ for (; it2 < size; ++it2) {
3634
+ str += ALPHABET.charAt(b58[it2]);
3635
+ }
3636
+ return str;
3637
+ }
3638
+ /**
3639
+ * @param {string | string[]} source
3640
+ */
3641
+ function decodeUnsafe(source) {
3642
+ if (typeof source !== 'string') {
3643
+ throw new TypeError('Expected String');
3644
+ }
3645
+ if (source.length === 0) {
3646
+ return new Uint8Array();
3647
+ }
3648
+ var psz = 0;
3649
+ // Skip leading spaces.
3650
+ if (source[psz] === ' ') {
3651
+ return;
3652
+ }
3653
+ // Skip and count leading '1's.
3654
+ var zeroes = 0;
3655
+ var length = 0;
3656
+ while (source[psz] === LEADER) {
3657
+ zeroes++;
3658
+ psz++;
3659
+ }
3660
+ // Allocate enough space in big-endian base256 representation.
3661
+ var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
3662
+ var b256 = new Uint8Array(size);
3663
+ // Process the characters.
3664
+ while (source[psz]) {
3665
+ // Decode character
3666
+ var carry = BASE_MAP[source.charCodeAt(psz)];
3667
+ // Invalid character
3668
+ if (carry === 255) {
3669
+ return;
3670
+ }
3671
+ var i = 0;
3672
+ for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
3673
+ carry += (BASE * b256[it3]) >>> 0;
3674
+ b256[it3] = (carry % 256) >>> 0;
3675
+ carry = (carry / 256) >>> 0;
3676
+ }
3677
+ if (carry !== 0) {
3678
+ throw new Error('Non-zero carry');
3679
+ }
3680
+ length = i;
3681
+ psz++;
3682
+ }
3683
+ // Skip trailing spaces.
3684
+ if (source[psz] === ' ') {
3685
+ return;
3686
+ }
3687
+ // Skip leading zeroes in b256.
3688
+ var it4 = size - length;
3689
+ while (it4 !== size && b256[it4] === 0) {
3690
+ it4++;
3691
+ }
3692
+ var vch = new Uint8Array(zeroes + (size - it4));
3693
+ var j = zeroes;
3694
+ while (it4 !== size) {
3695
+ vch[j++] = b256[it4++];
3696
+ }
3697
+ return vch;
3698
+ }
3699
+ /**
3700
+ * @param {string | string[]} string
3701
+ */
3702
+ function decode(string) {
3703
+ var buffer = decodeUnsafe(string);
3704
+ if (buffer) {
3705
+ return buffer;
3706
+ }
3707
+ throw new Error(`Non-${name} character`);
3708
+ }
3709
+ return {
3710
+ encode: encode,
3711
+ decodeUnsafe: decodeUnsafe,
3712
+ decode: decode
3713
+ };
3714
+ }
3715
+ var vendor_base_x_src = base_x_base;
3716
+ var base_x_brrp_multiformats_scope_baseX = vendor_base_x_src;
3717
+ /* harmony default export */ const vendor_base_x = (base_x_brrp_multiformats_scope_baseX);
3718
+ //# sourceMappingURL=base-x.js.map
3719
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/bases/base.js
3720
+
3721
+
3722
+ /**
3723
+ * Class represents both BaseEncoder and MultibaseEncoder meaning it
3724
+ * can be used to encode to multibase or base encode without multibase
3725
+ * prefix.
3726
+ */
3727
+ class base_Encoder {
3728
+ name;
3729
+ prefix;
3730
+ baseEncode;
3731
+ constructor(name, prefix, baseEncode) {
3732
+ this.name = name;
3733
+ this.prefix = prefix;
3734
+ this.baseEncode = baseEncode;
3735
+ }
3736
+ encode(bytes) {
3737
+ if (bytes instanceof Uint8Array) {
3738
+ return `${this.prefix}${this.baseEncode(bytes)}`;
3739
+ }
3740
+ else {
3741
+ throw Error('Unknown type, must be binary type');
3742
+ }
3743
+ }
3744
+ }
3745
+ /**
3746
+ * Class represents both BaseDecoder and MultibaseDecoder so it could be used
3747
+ * to decode multibases (with matching prefix) or just base decode strings
3748
+ * with corresponding base encoding.
3749
+ */
3750
+ class base_Decoder {
3751
+ name;
3752
+ prefix;
3753
+ baseDecode;
3754
+ prefixCodePoint;
3755
+ constructor(name, prefix, baseDecode) {
3756
+ this.name = name;
3757
+ this.prefix = prefix;
3758
+ const prefixCodePoint = prefix.codePointAt(0);
3759
+ /* c8 ignore next 3 */
3760
+ if (prefixCodePoint === undefined) {
3761
+ throw new Error('Invalid prefix character');
3762
+ }
3763
+ this.prefixCodePoint = prefixCodePoint;
3764
+ this.baseDecode = baseDecode;
3765
+ }
3766
+ decode(text) {
3767
+ if (typeof text === 'string') {
3768
+ if (text.codePointAt(0) !== this.prefixCodePoint) {
3769
+ throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
3770
+ }
3771
+ return this.baseDecode(text.slice(this.prefix.length));
3772
+ }
3773
+ else {
3774
+ throw Error('Can only multibase decode strings');
3775
+ }
3776
+ }
3777
+ or(decoder) {
3778
+ return base_or(this, decoder);
3779
+ }
3780
+ }
3781
+ class base_ComposedDecoder {
3782
+ decoders;
3783
+ constructor(decoders) {
3784
+ this.decoders = decoders;
3785
+ }
3786
+ or(decoder) {
3787
+ return base_or(this, decoder);
3788
+ }
3789
+ decode(input) {
3790
+ const prefix = input[0];
3791
+ const decoder = this.decoders[prefix];
3792
+ if (decoder != null) {
3793
+ return decoder.decode(input);
3794
+ }
3795
+ else {
3796
+ throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
3797
+ }
3798
+ }
3799
+ }
3800
+ function base_or(left, right) {
3801
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
3802
+ return new base_ComposedDecoder({
3803
+ ...(left.decoders ?? { [left.prefix]: left }),
3804
+ ...(right.decoders ?? { [right.prefix]: right })
3805
+ });
3806
+ }
3807
+ class base_Codec {
3808
+ name;
3809
+ prefix;
3810
+ baseEncode;
3811
+ baseDecode;
3812
+ encoder;
3813
+ decoder;
3814
+ constructor(name, prefix, baseEncode, baseDecode) {
3815
+ this.name = name;
3816
+ this.prefix = prefix;
3817
+ this.baseEncode = baseEncode;
3818
+ this.baseDecode = baseDecode;
3819
+ this.encoder = new base_Encoder(name, prefix, baseEncode);
3820
+ this.decoder = new base_Decoder(name, prefix, baseDecode);
3821
+ }
3822
+ encode(input) {
3823
+ return this.encoder.encode(input);
3824
+ }
3825
+ decode(input) {
3826
+ return this.decoder.decode(input);
3827
+ }
3828
+ }
3829
+ function base_from({ name, prefix, encode, decode }) {
3830
+ return new base_Codec(name, prefix, encode, decode);
3831
+ }
3832
+ function base_baseX({ name, prefix, alphabet }) {
3833
+ const { encode, decode } = vendor_base_x(alphabet, name);
3834
+ return base_from({
3835
+ prefix,
3836
+ name,
3837
+ encode,
3838
+ decode: (text) => bytes_coerce(decode(text))
3839
+ });
3840
+ }
3841
+ function base_decode(string, alphabet, bitsPerChar, name) {
3842
+ // Build the character lookup table:
3843
+ const codes = {};
3844
+ for (let i = 0; i < alphabet.length; ++i) {
3845
+ codes[alphabet[i]] = i;
3846
+ }
3847
+ // Count the padding bytes:
3848
+ let end = string.length;
3849
+ while (string[end - 1] === '=') {
3850
+ --end;
3851
+ }
3852
+ // Allocate the output:
3853
+ const out = new Uint8Array((end * bitsPerChar / 8) | 0);
3854
+ // Parse the data:
3855
+ let bits = 0; // Number of bits currently in the buffer
3856
+ let buffer = 0; // Bits waiting to be written out, MSB first
3857
+ let written = 0; // Next byte to write
3858
+ for (let i = 0; i < end; ++i) {
3859
+ // Read one character from the string:
3860
+ const value = codes[string[i]];
3861
+ if (value === undefined) {
3862
+ throw new SyntaxError(`Non-${name} character`);
3863
+ }
3864
+ // Append the bits to the buffer:
3865
+ buffer = (buffer << bitsPerChar) | value;
3866
+ bits += bitsPerChar;
3867
+ // Write out some bits if the buffer has a byte's worth:
3868
+ if (bits >= 8) {
3869
+ bits -= 8;
3870
+ out[written++] = 0xff & (buffer >> bits);
3871
+ }
3872
+ }
3873
+ // Verify that we have received just enough bits:
3874
+ if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {
3875
+ throw new SyntaxError('Unexpected end of data');
3876
+ }
3877
+ return out;
3878
+ }
3879
+ function base_encode(data, alphabet, bitsPerChar) {
3880
+ const pad = alphabet[alphabet.length - 1] === '=';
3881
+ const mask = (1 << bitsPerChar) - 1;
3882
+ let out = '';
3883
+ let bits = 0; // Number of bits currently in the buffer
3884
+ let buffer = 0; // Bits waiting to be written out, MSB first
3885
+ for (let i = 0; i < data.length; ++i) {
3886
+ // Slurp data into the buffer:
3887
+ buffer = (buffer << 8) | data[i];
3888
+ bits += 8;
3889
+ // Write out as much as we can:
3890
+ while (bits > bitsPerChar) {
3891
+ bits -= bitsPerChar;
3892
+ out += alphabet[mask & (buffer >> bits)];
3893
+ }
3894
+ }
3895
+ // Partial character:
3896
+ if (bits !== 0) {
3897
+ out += alphabet[mask & (buffer << (bitsPerChar - bits))];
3898
+ }
3899
+ // Add padding characters until we hit a byte boundary:
3900
+ if (pad) {
3901
+ while (((out.length * bitsPerChar) & 7) !== 0) {
3902
+ out += '=';
3903
+ }
3904
+ }
3905
+ return out;
3906
+ }
3907
+ /**
3908
+ * RFC4648 Factory
3909
+ */
3910
+ function base_rfc4648({ name, prefix, bitsPerChar, alphabet }) {
3911
+ return base_from({
3912
+ prefix,
3913
+ name,
3914
+ encode(input) {
3915
+ return base_encode(input, alphabet, bitsPerChar);
3916
+ },
3917
+ decode(input) {
3918
+ return base_decode(input, alphabet, bitsPerChar, name);
3919
+ }
3920
+ });
3921
+ }
3922
+ //# sourceMappingURL=base.js.map
3923
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/bases/base32.js
3924
+
3925
+ const base32_base32 = base_rfc4648({
3926
+ prefix: 'b',
3927
+ name: 'base32',
3928
+ alphabet: 'abcdefghijklmnopqrstuvwxyz234567',
3929
+ bitsPerChar: 5
3930
+ });
3931
+ const base32_base32upper = base_rfc4648({
3932
+ prefix: 'B',
3933
+ name: 'base32upper',
3934
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',
3935
+ bitsPerChar: 5
3936
+ });
3937
+ const base32_base32pad = base_rfc4648({
3938
+ prefix: 'c',
3939
+ name: 'base32pad',
3940
+ alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',
3941
+ bitsPerChar: 5
3942
+ });
3943
+ const base32_base32padupper = base_rfc4648({
3944
+ prefix: 'C',
3945
+ name: 'base32padupper',
3946
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',
3947
+ bitsPerChar: 5
3948
+ });
3949
+ const base32_base32hex = base_rfc4648({
3950
+ prefix: 'v',
3951
+ name: 'base32hex',
3952
+ alphabet: '0123456789abcdefghijklmnopqrstuv',
3953
+ bitsPerChar: 5
3954
+ });
3955
+ const base32_base32hexupper = base_rfc4648({
3956
+ prefix: 'V',
3957
+ name: 'base32hexupper',
3958
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',
3959
+ bitsPerChar: 5
3960
+ });
3961
+ const base32_base32hexpad = base_rfc4648({
3962
+ prefix: 't',
3963
+ name: 'base32hexpad',
3964
+ alphabet: '0123456789abcdefghijklmnopqrstuv=',
3965
+ bitsPerChar: 5
3966
+ });
3967
+ const base32_base32hexpadupper = base_rfc4648({
3968
+ prefix: 'T',
3969
+ name: 'base32hexpadupper',
3970
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',
3971
+ bitsPerChar: 5
3972
+ });
3973
+ const base32_base32z = base_rfc4648({
3974
+ prefix: 'h',
3975
+ name: 'base32z',
3976
+ alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',
3977
+ bitsPerChar: 5
3978
+ });
3979
+ //# sourceMappingURL=base32.js.map
3980
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/bases/base58.js
3981
+
3982
+ const base58_base58btc = base_baseX({
3983
+ name: 'base58btc',
3984
+ prefix: 'z',
3985
+ alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
3986
+ });
3987
+ const base58_base58flickr = base_baseX({
3988
+ name: 'base58flickr',
3989
+ prefix: 'Z',
3990
+ alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
3991
+ });
3992
+ //# sourceMappingURL=base58.js.map
3993
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/bases/base36.js
3994
+
3995
+ const base36_base36 = base_baseX({
3996
+ prefix: 'k',
3997
+ name: 'base36',
3998
+ alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'
3999
+ });
4000
+ const base36_base36upper = base_baseX({
4001
+ prefix: 'K',
4002
+ name: 'base36upper',
4003
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
4004
+ });
4005
+ //# sourceMappingURL=base36.js.map
4006
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/vendor/varint.js
4007
+ /* eslint-disable */
4008
+ var varint_encode_1 = vendor_varint_encode;
4009
+ var varint_MSB = 0x80, varint_REST = 0x7F, varint_MSBALL = ~varint_REST, varint_INT = Math.pow(2, 31);
4010
+ /**
4011
+ * @param {number} num
4012
+ * @param {number[]} out
4013
+ * @param {number} offset
4014
+ */
4015
+ function vendor_varint_encode(num, out, offset) {
4016
+ out = out || [];
4017
+ offset = offset || 0;
4018
+ var oldOffset = offset;
4019
+ while (num >= varint_INT) {
4020
+ out[offset++] = (num & 0xFF) | varint_MSB;
4021
+ num /= 128;
4022
+ }
4023
+ while (num & varint_MSBALL) {
4024
+ out[offset++] = (num & 0xFF) | varint_MSB;
4025
+ num >>>= 7;
4026
+ }
4027
+ out[offset] = num | 0;
4028
+ // @ts-ignore
4029
+ vendor_varint_encode.bytes = offset - oldOffset + 1;
4030
+ return out;
4031
+ }
4032
+ var vendor_varint_decode = varint_read;
4033
+ var varint_MSB$1 = 0x80, varint_REST$1 = 0x7F;
4034
+ /**
4035
+ * @param {string | any[]} buf
4036
+ * @param {number} offset
4037
+ */
4038
+ function varint_read(buf, offset) {
4039
+ var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
4040
+ do {
4041
+ if (counter >= l) {
4042
+ // @ts-ignore
4043
+ varint_read.bytes = 0;
4044
+ throw new RangeError('Could not decode varint');
4045
+ }
4046
+ b = buf[counter++];
4047
+ res += shift < 28
4048
+ ? (b & varint_REST$1) << shift
4049
+ : (b & varint_REST$1) * Math.pow(2, shift);
4050
+ shift += 7;
4051
+ } while (b >= varint_MSB$1);
4052
+ // @ts-ignore
4053
+ varint_read.bytes = counter - offset;
4054
+ return res;
4055
+ }
4056
+ var varint_N1 = Math.pow(2, 7);
4057
+ var varint_N2 = Math.pow(2, 14);
4058
+ var varint_N3 = Math.pow(2, 21);
4059
+ var varint_N4 = Math.pow(2, 28);
4060
+ var varint_N5 = Math.pow(2, 35);
4061
+ var varint_N6 = Math.pow(2, 42);
4062
+ var varint_N7 = Math.pow(2, 49);
4063
+ var varint_N8 = Math.pow(2, 56);
4064
+ var varint_N9 = Math.pow(2, 63);
4065
+ var vendor_varint_length = function (/** @type {number} */ value) {
4066
+ return (value < varint_N1 ? 1
4067
+ : value < varint_N2 ? 2
4068
+ : value < varint_N3 ? 3
4069
+ : value < varint_N4 ? 4
4070
+ : value < varint_N5 ? 5
4071
+ : value < varint_N6 ? 6
4072
+ : value < varint_N7 ? 7
4073
+ : value < varint_N8 ? 8
4074
+ : value < varint_N9 ? 9
4075
+ : 10);
4076
+ };
4077
+ var varint_varint = {
4078
+ encode: varint_encode_1,
4079
+ decode: vendor_varint_decode,
4080
+ encodingLength: vendor_varint_length
4081
+ };
4082
+ var varint_brrp_varint = varint_varint;
4083
+ /* harmony default export */ const src_vendor_varint = (varint_brrp_varint);
4084
+ //# sourceMappingURL=varint.js.map
4085
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/varint.js
4086
+
4087
+ function dist_src_varint_decode(data, offset = 0) {
4088
+ const code = src_vendor_varint.decode(data, offset);
4089
+ return [code, src_vendor_varint.decode.bytes];
4090
+ }
4091
+ function varint_encodeTo(int, target, offset = 0) {
4092
+ src_vendor_varint.encode(int, target, offset);
4093
+ return target;
4094
+ }
4095
+ function varint_encodingLength(int) {
4096
+ return src_vendor_varint.encodingLength(int);
4097
+ }
4098
+ //# sourceMappingURL=varint.js.map
4099
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/hashes/digest.js
4100
+
4101
+
4102
+ /**
4103
+ * Creates a multihash digest.
4104
+ */
4105
+ function digest_create(code, digest) {
4106
+ const size = digest.byteLength;
4107
+ const sizeOffset = varint_encodingLength(code);
4108
+ const digestOffset = sizeOffset + varint_encodingLength(size);
4109
+ const bytes = new Uint8Array(digestOffset + size);
4110
+ varint_encodeTo(code, bytes, 0);
4111
+ varint_encodeTo(size, bytes, sizeOffset);
4112
+ bytes.set(digest, digestOffset);
4113
+ return new digest_Digest(code, size, digest, bytes);
4114
+ }
4115
+ /**
4116
+ * Turns bytes representation of multihash digest into an instance.
4117
+ */
4118
+ function hashes_digest_decode(multihash) {
4119
+ const bytes = bytes_coerce(multihash);
4120
+ const [code, sizeOffset] = dist_src_varint_decode(bytes);
4121
+ const [size, digestOffset] = dist_src_varint_decode(bytes.subarray(sizeOffset));
4122
+ const digest = bytes.subarray(sizeOffset + digestOffset);
4123
+ if (digest.byteLength !== size) {
4124
+ throw new Error('Incorrect length');
4125
+ }
4126
+ return new digest_Digest(code, size, digest, bytes);
4127
+ }
4128
+ function hashes_digest_equals(a, b) {
4129
+ if (a === b) {
4130
+ return true;
4131
+ }
4132
+ else {
4133
+ const data = b;
4134
+ return (a.code === data.code &&
4135
+ a.size === data.size &&
4136
+ data.bytes instanceof Uint8Array &&
4137
+ bytes_equals(a.bytes, data.bytes));
4138
+ }
4139
+ }
4140
+ /**
4141
+ * Represents a multihash digest which carries information about the
4142
+ * hashing algorithm and an actual hash digest.
4143
+ */
4144
+ class digest_Digest {
4145
+ code;
4146
+ size;
4147
+ digest;
4148
+ bytes;
4149
+ /**
4150
+ * Creates a multihash digest.
4151
+ */
4152
+ constructor(code, size, digest, bytes) {
4153
+ this.code = code;
4154
+ this.size = size;
4155
+ this.digest = digest;
4156
+ this.bytes = bytes;
4157
+ }
4158
+ }
4159
+ /**
4160
+ * Used to check that the passed multihash has the passed code
4161
+ */
4162
+ function digest_hasCode(digest, code) {
4163
+ return digest.code === code;
4164
+ }
4165
+ //# sourceMappingURL=digest.js.map
4166
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/link/interface.js
4167
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
4168
+ /* eslint-disable no-use-before-define */
4169
+
4170
+ //# sourceMappingURL=interface.js.map
4171
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/node_modules/multiformats/dist/src/cid.js
4172
+
4173
+
4174
+
4175
+
4176
+
4177
+
4178
+ // This way TS will also expose all the types from module
4179
+
4180
+ function cid_format(link, base) {
4181
+ const { bytes, version } = link;
4182
+ switch (version) {
4183
+ case 0:
4184
+ return cid_toStringV0(bytes, cid_baseCache(link), base ?? base58_base58btc.encoder);
4185
+ default:
4186
+ return cid_toStringV1(bytes, cid_baseCache(link), (base ?? base32_base32.encoder));
4187
+ }
4188
+ }
4189
+ function cid_toJSON(link) {
4190
+ return {
4191
+ '/': cid_format(link)
4192
+ };
4193
+ }
4194
+ function cid_fromJSON(json) {
4195
+ return cid_CID.parse(json['/']);
4196
+ }
4197
+ const cid_cache = new WeakMap();
4198
+ function cid_baseCache(cid) {
4199
+ const baseCache = cid_cache.get(cid);
4200
+ if (baseCache == null) {
4201
+ const baseCache = new Map();
4202
+ cid_cache.set(cid, baseCache);
4203
+ return baseCache;
4204
+ }
4205
+ return baseCache;
4206
+ }
4207
+ class cid_CID {
4208
+ code;
4209
+ version;
4210
+ multihash;
4211
+ bytes;
4212
+ '/';
4213
+ /**
4214
+ * @param version - Version of the CID
4215
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
4216
+ * @param multihash - (Multi)hash of the of the content.
4217
+ */
4218
+ constructor(version, code, multihash, bytes) {
4219
+ this.code = code;
4220
+ this.version = version;
4221
+ this.multihash = multihash;
4222
+ this.bytes = bytes;
4223
+ // flag to serializers that this is a CID and
4224
+ // should be treated specially
4225
+ this['/'] = bytes;
4226
+ }
4227
+ /**
4228
+ * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
4229
+ * please either use `CID.asCID(cid)` or switch to new signalling mechanism
4230
+ *
4231
+ * @deprecated
4232
+ */
4233
+ get asCID() {
4234
+ return this;
4235
+ }
4236
+ // ArrayBufferView
4237
+ get byteOffset() {
4238
+ return this.bytes.byteOffset;
4239
+ }
4240
+ // ArrayBufferView
4241
+ get byteLength() {
4242
+ return this.bytes.byteLength;
4243
+ }
4244
+ toV0() {
4245
+ switch (this.version) {
4246
+ case 0: {
4247
+ return this;
4248
+ }
4249
+ case 1: {
4250
+ const { code, multihash } = this;
4251
+ if (code !== cid_DAG_PB_CODE) {
4252
+ throw new Error('Cannot convert a non dag-pb CID to CIDv0');
4253
+ }
4254
+ // sha2-256
4255
+ if (multihash.code !== cid_SHA_256_CODE) {
4256
+ throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');
4257
+ }
4258
+ return (cid_CID.createV0(multihash));
4259
+ }
4260
+ default: {
4261
+ throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
4262
+ }
4263
+ }
4264
+ }
4265
+ toV1() {
4266
+ switch (this.version) {
4267
+ case 0: {
4268
+ const { code, digest } = this.multihash;
4269
+ const multihash = digest_create(code, digest);
4270
+ return (cid_CID.createV1(this.code, multihash));
4271
+ }
4272
+ case 1: {
4273
+ return this;
4274
+ }
4275
+ default: {
4276
+ throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
4277
+ }
4278
+ }
4279
+ }
4280
+ equals(other) {
4281
+ return cid_CID.equals(this, other);
4282
+ }
4283
+ static equals(self, other) {
4284
+ const unknown = other;
4285
+ return (unknown != null &&
4286
+ self.code === unknown.code &&
4287
+ self.version === unknown.version &&
4288
+ hashes_digest_equals(self.multihash, unknown.multihash));
4289
+ }
4290
+ toString(base) {
4291
+ return cid_format(this, base);
4292
+ }
4293
+ toJSON() {
4294
+ return { '/': cid_format(this) };
4295
+ }
4296
+ link() {
4297
+ return this;
4298
+ }
4299
+ [Symbol.toStringTag] = 'CID';
4300
+ // Legacy
4301
+ [Symbol.for('nodejs.util.inspect.custom')]() {
4302
+ return `CID(${this.toString()})`;
4303
+ }
4304
+ /**
4305
+ * Takes any input `value` and returns a `CID` instance if it was
4306
+ * a `CID` otherwise returns `null`. If `value` is instanceof `CID`
4307
+ * it will return value back. If `value` is not instance of this CID
4308
+ * class, but is compatible CID it will return new instance of this
4309
+ * `CID` class. Otherwise returns null.
4310
+ *
4311
+ * This allows two different incompatible versions of CID library to
4312
+ * co-exist and interop as long as binary interface is compatible.
4313
+ */
4314
+ static asCID(input) {
4315
+ if (input == null) {
4316
+ return null;
4317
+ }
4318
+ const value = input;
4319
+ if (value instanceof cid_CID) {
4320
+ // If value is instance of CID then we're all set.
4321
+ return value;
4322
+ }
4323
+ else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {
4324
+ // If value isn't instance of this CID class but `this.asCID === this` or
4325
+ // `value['/'] === value.bytes` is true it is CID instance coming from a
4326
+ // different implementation (diff version or duplicate). In that case we
4327
+ // rebase it to this `CID` implementation so caller is guaranteed to get
4328
+ // instance with expected API.
4329
+ const { version, code, multihash, bytes } = value;
4330
+ return new cid_CID(version, code, multihash, bytes ?? cid_encodeCID(version, code, multihash.bytes));
4331
+ }
4332
+ else if (value[cid_cidSymbol] === true) {
4333
+ // If value is a CID from older implementation that used to be tagged via
4334
+ // symbol we still rebase it to the this `CID` implementation by
4335
+ // delegating that to a constructor.
4336
+ const { version, multihash, code } = value;
4337
+ const digest = hashes_digest_decode(multihash);
4338
+ return cid_CID.create(version, code, digest);
4339
+ }
4340
+ else {
4341
+ // Otherwise value is not a CID (or an incompatible version of it) in
4342
+ // which case we return `null`.
4343
+ return null;
4344
+ }
4345
+ }
4346
+ /**
4347
+ * @param version - Version of the CID
4348
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
4349
+ * @param digest - (Multi)hash of the of the content.
4350
+ */
4351
+ static create(version, code, digest) {
4352
+ if (typeof code !== 'number') {
4353
+ throw new Error('String codecs are no longer supported');
4354
+ }
4355
+ if (!(digest.bytes instanceof Uint8Array)) {
4356
+ throw new Error('Invalid digest');
4357
+ }
4358
+ switch (version) {
4359
+ case 0: {
4360
+ if (code !== cid_DAG_PB_CODE) {
4361
+ throw new Error(`Version 0 CID must use dag-pb (code: ${cid_DAG_PB_CODE}) block encoding`);
4362
+ }
4363
+ else {
4364
+ return new cid_CID(version, code, digest, digest.bytes);
4365
+ }
4366
+ }
4367
+ case 1: {
4368
+ const bytes = cid_encodeCID(version, code, digest.bytes);
4369
+ return new cid_CID(version, code, digest, bytes);
4370
+ }
4371
+ default: {
4372
+ throw new Error('Invalid version');
4373
+ }
4374
+ }
4375
+ }
4376
+ /**
4377
+ * Simplified version of `create` for CIDv0.
4378
+ */
4379
+ static createV0(digest) {
4380
+ return cid_CID.create(0, cid_DAG_PB_CODE, digest);
4381
+ }
4382
+ /**
4383
+ * Simplified version of `create` for CIDv1.
4384
+ *
4385
+ * @param code - Content encoding format code.
4386
+ * @param digest - Multihash of the content.
4387
+ */
4388
+ static createV1(code, digest) {
4389
+ return cid_CID.create(1, code, digest);
4390
+ }
4391
+ /**
4392
+ * Decoded a CID from its binary representation. The byte array must contain
4393
+ * only the CID with no additional bytes.
4394
+ *
4395
+ * An error will be thrown if the bytes provided do not contain a valid
4396
+ * binary representation of a CID.
4397
+ */
4398
+ static decode(bytes) {
4399
+ const [cid, remainder] = cid_CID.decodeFirst(bytes);
4400
+ if (remainder.length !== 0) {
4401
+ throw new Error('Incorrect length');
4402
+ }
4403
+ return cid;
4404
+ }
4405
+ /**
4406
+ * Decoded a CID from its binary representation at the beginning of a byte
4407
+ * array.
4408
+ *
4409
+ * Returns an array with the first element containing the CID and the second
4410
+ * element containing the remainder of the original byte array. The remainder
4411
+ * will be a zero-length byte array if the provided bytes only contained a
4412
+ * binary CID representation.
4413
+ */
4414
+ static decodeFirst(bytes) {
4415
+ const specs = cid_CID.inspectBytes(bytes);
4416
+ const prefixSize = specs.size - specs.multihashSize;
4417
+ const multihashBytes = bytes_coerce(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
4418
+ if (multihashBytes.byteLength !== specs.multihashSize) {
4419
+ throw new Error('Incorrect length');
4420
+ }
4421
+ const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
4422
+ const digest = new digest_Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
4423
+ const cid = specs.version === 0
4424
+ ? cid_CID.createV0(digest)
4425
+ : cid_CID.createV1(specs.codec, digest);
4426
+ return [cid, bytes.subarray(specs.size)];
4427
+ }
4428
+ /**
4429
+ * Inspect the initial bytes of a CID to determine its properties.
4430
+ *
4431
+ * Involves decoding up to 4 varints. Typically this will require only 4 to 6
4432
+ * bytes but for larger multicodec code values and larger multihash digest
4433
+ * lengths these varints can be quite large. It is recommended that at least
4434
+ * 10 bytes be made available in the `initialBytes` argument for a complete
4435
+ * inspection.
4436
+ */
4437
+ static inspectBytes(initialBytes) {
4438
+ let offset = 0;
4439
+ const next = () => {
4440
+ const [i, length] = dist_src_varint_decode(initialBytes.subarray(offset));
4441
+ offset += length;
4442
+ return i;
4443
+ };
4444
+ let version = next();
4445
+ let codec = cid_DAG_PB_CODE;
4446
+ if (version === 18) {
4447
+ // CIDv0
4448
+ version = 0;
4449
+ offset = 0;
4450
+ }
4451
+ else {
4452
+ codec = next();
4453
+ }
4454
+ if (version !== 0 && version !== 1) {
4455
+ throw new RangeError(`Invalid CID version ${version}`);
4456
+ }
4457
+ const prefixSize = offset;
4458
+ const multihashCode = next(); // multihash code
4459
+ const digestSize = next(); // multihash length
4460
+ const size = offset + digestSize;
4461
+ const multihashSize = size - prefixSize;
4462
+ return { version, codec, multihashCode, digestSize, multihashSize, size };
4463
+ }
4464
+ /**
4465
+ * Takes cid in a string representation and creates an instance. If `base`
4466
+ * decoder is not provided will use a default from the configuration. It will
4467
+ * throw an error if encoding of the CID is not compatible with supplied (or
4468
+ * a default decoder).
4469
+ */
4470
+ static parse(source, base) {
4471
+ const [prefix, bytes] = cid_parseCIDtoBytes(source, base);
4472
+ const cid = cid_CID.decode(bytes);
4473
+ if (cid.version === 0 && source[0] !== 'Q') {
4474
+ throw Error('Version 0 CID string must not include multibase prefix');
4475
+ }
4476
+ // Cache string representation to avoid computing it on `this.toString()`
4477
+ cid_baseCache(cid).set(prefix, source);
4478
+ return cid;
4479
+ }
4480
+ }
4481
+ function cid_parseCIDtoBytes(source, base) {
4482
+ switch (source[0]) {
4483
+ // CIDv0 is parsed differently
4484
+ case 'Q': {
4485
+ const decoder = base ?? base58_base58btc;
4486
+ return [
4487
+ base58_base58btc.prefix,
4488
+ decoder.decode(`${base58_base58btc.prefix}${source}`)
4489
+ ];
4490
+ }
4491
+ case base58_base58btc.prefix: {
4492
+ const decoder = base ?? base58_base58btc;
4493
+ return [base58_base58btc.prefix, decoder.decode(source)];
4494
+ }
4495
+ case base32_base32.prefix: {
4496
+ const decoder = base ?? base32_base32;
4497
+ return [base32_base32.prefix, decoder.decode(source)];
4498
+ }
4499
+ case base36_base36.prefix: {
4500
+ const decoder = base ?? base36_base36;
4501
+ return [base36_base36.prefix, decoder.decode(source)];
4502
+ }
4503
+ default: {
4504
+ if (base == null) {
4505
+ throw Error('To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided');
4506
+ }
4507
+ return [source[0], base.decode(source)];
4508
+ }
4509
+ }
4510
+ }
4511
+ function cid_toStringV0(bytes, cache, base) {
4512
+ const { prefix } = base;
4513
+ if (prefix !== base58_base58btc.prefix) {
4514
+ throw Error(`Cannot string encode V0 in ${base.name} encoding`);
4515
+ }
4516
+ const cid = cache.get(prefix);
4517
+ if (cid == null) {
4518
+ const cid = base.encode(bytes).slice(1);
4519
+ cache.set(prefix, cid);
4520
+ return cid;
4521
+ }
4522
+ else {
4523
+ return cid;
4524
+ }
4525
+ }
4526
+ function cid_toStringV1(bytes, cache, base) {
4527
+ const { prefix } = base;
4528
+ const cid = cache.get(prefix);
4529
+ if (cid == null) {
4530
+ const cid = base.encode(bytes);
4531
+ cache.set(prefix, cid);
4532
+ return cid;
4533
+ }
4534
+ else {
4535
+ return cid;
4536
+ }
4537
+ }
4538
+ const cid_DAG_PB_CODE = 0x70;
4539
+ const cid_SHA_256_CODE = 0x12;
4540
+ function cid_encodeCID(version, code, multihash) {
4541
+ const codeOffset = varint_encodingLength(version);
4542
+ const hashOffset = codeOffset + varint_encodingLength(code);
4543
+ const bytes = new Uint8Array(hashOffset + multihash.byteLength);
4544
+ varint_encodeTo(version, bytes, 0);
4545
+ varint_encodeTo(code, bytes, codeOffset);
4546
+ bytes.set(multihash, hashOffset);
4547
+ return bytes;
4548
+ }
4549
+ const cid_cidSymbol = Symbol.for('@ipld/js-cid/CID');
4550
+ //# sourceMappingURL=cid.js.map
4551
+ ;// ./node_modules/shogun-ipfs/node_modules/is-ipfs/dist/src/index.js
4552
+ /**
4553
+ * @packageDocumentation
4554
+ *
4555
+ * A suite of util methods that provides efficient validation.
4556
+ *
4557
+ * Detection of IPFS Paths and identifiers in URLs is a two-stage process:
4558
+ *
4559
+ * 1. `pathPattern`/`pathGatewayPattern`/`subdomainGatewayPattern` regex is applied to quickly identify potential candidates
4560
+ * 2. proper CID validation is applied to remove false-positives
4561
+ *
4562
+ * @example
4563
+ *
4564
+ * ```TypeScript
4565
+ * import * as isIPFS from 'is-ipfs'
4566
+ *
4567
+ * isIPFS.multihash('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true
4568
+ * isIPFS.multihash('noop') // false
4569
+ *
4570
+ * isIPFS.cid('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true (CIDv0)
4571
+ * isIPFS.cid('bafybeiasb5vpmaounyilfuxbd3lryvosl4yefqrfahsb2esg46q6tu6y5q') // true (CIDv1 in Base32)
4572
+ * isIPFS.cid('zdj7WWeQ43G6JJvLWQWZpyHuAMq6uYWRjkBXFad11vE2LHhQ7') // true (CIDv1 in Base58btc)
4573
+ * isIPFS.cid('noop') // false
4574
+ *
4575
+ * isIPFS.base32cid('bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va') // true
4576
+ * isIPFS.base32cid('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // false
4577
+ *
4578
+ * isIPFS.url('https://ipfs.io/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true
4579
+ * isIPFS.url('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?filename=guardian.jpg') // true
4580
+ * isIPFS.url('https://ipfs.io/ipns/github.com') // true
4581
+ * isIPFS.url('https://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.ipfs.dweb.link') // true
4582
+ * isIPFS.url('http://en.wikipedia-on-ipfs.org.ipfs.localhost:8080') // true
4583
+ * isIPFS.url('https://github.com/ipfs/js-ipfs/blob/master/README.md') // false
4584
+ * isIPFS.url('https://google.com') // false
4585
+ *
4586
+ * isIPFS.path('/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true
4587
+ * isIPFS.path('/ipfs/QmbcBPAwCDxRMB1Qe7CRQmxdrTSkxKwM9y6rZw2FjGtbsb/?weird-filename=test.jpg') // true
4588
+ * isIPFS.path('/ipns/github.com') // true
4589
+ * isIPFS.path('/ipfs/js-ipfs/blob/master/README.md') // false
4590
+ *
4591
+ * isIPFS.urlOrPath('https://ipfs.io/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true
4592
+ * isIPFS.urlOrPath('https://ipfs.io/ipns/github.com') // true
4593
+ * isIPFS.urlOrPath('/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true
4594
+ * isIPFS.urlOrPath('/ipns/github.com') // true
4595
+ * isIPFS.urlOrPath('https://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.ipfs.dweb.link') // true
4596
+ * isIPFS.urlOrPath('https://google.com') // false
4597
+ *
4598
+ * isIPFS.ipfsUrl('https://ipfs.io/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true
4599
+ * isIPFS.ipfsUrl('https://ipfs.io/ipfs/invalid-hash') // false
4600
+ *
4601
+ * isIPFS.ipnsUrl('https://ipfs.io/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // false
4602
+ * isIPFS.ipnsUrl('https://ipfs.io/ipns/github.com') // true
4603
+ *
4604
+ * isIPFS.ipfsPath('/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true
4605
+ * isIPFS.ipfsPath('/ipfs/invalid-hash') // false
4606
+ *
4607
+ * isIPFS.ipnsPath('/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // false
4608
+ * isIPFS.ipnsPath('/ipns/github.com') // true
4609
+ *
4610
+ * isIPFS.cidPath('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o/path/to/file') // true
4611
+ * isIPFS.cidPath('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o/') // true
4612
+ * isIPFS.cidPath('QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // false
4613
+ * isIPFS.cidPath('/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // false
4614
+ * isIPFS.cidPath('/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o/file') // false
4615
+ *
4616
+ * isIPFS.subdomain('http://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.ipfs.dweb.link') // true
4617
+ * isIPFS.subdomain('http://bafybeiabc2xofh6tdi6vutusorpumwcikw3hf3st4ecjugo6j52f6xwc6q.ipns.dweb.link') // true
4618
+ * isIPFS.subdomain('http://www.bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.ipfs.dweb.link') // false
4619
+ * isIPFS.subdomain('http://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.dweb.link') // false
4620
+ *
4621
+ * isIPFS.ipfsSubdomain('http://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.ipfs.dweb.link') // true
4622
+ * isIPFS.ipfsSubdomain('http://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.dweb.link') // false
4623
+ *
4624
+ * isIPFS.ipnsSubdomain('http://bafybeiabc2xofh6tdi6vutusorpumwcikw3hf3st4ecjugo6j52f6xwc6q.ipns.dweb.link') // true
4625
+ * isIPFS.ipnsSubdomain('http://bafybeiabc2xofh6tdi6vutusorpumwcikw3hf3st4ecjugo6j52f6xwc6q.dweb.link') // false
4626
+ * isIPFS.ipnsSubdomain('http://QmcNioXSC1bfJj1dcFErhUfyjFzoX2HodkRccsFFVJJvg8.ipns.dweb.link') // false
4627
+ * isIPFS.ipnsSubdomain('http://en.wikipedia-on-ipfs.org.ipns.localhost:8080') // true (assuming DNSLink)
4628
+ * isIPFS.ipnsSubdomain('http://en-wikipedia--on--ipfs-org.ipns.localhost:8080') // true (assuming inlined DNSLink)
4629
+ * isIPFS.ipnsSubdomain('http://hostname-without-tld-.ipns.dweb.link') // false (not a CID, invalid DNS label)
4630
+ *
4631
+ * isIPFS.multiaddr('/ip4/127.0.0.1/udp/1234') // true
4632
+ * isIPFS.multiaddr('/ip4/127.0.0.1/udp/1234/http') // true
4633
+ * isIPFS.multiaddr('/ip6/::1/udp/1234') // true
4634
+ * isIPFS.multiaddr('ip6/::1/udp/1234') // false
4635
+ * isIPFS.multiaddr('/yoloinvalid/::1/udp/1234') // false
4636
+ *
4637
+ * isIPFS.peerMultiaddr('/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4') // true
4638
+ * isIPFS.peerMultiaddr('/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4') // true (legacy notation)
4639
+ * isIPFS.peerMultiaddr('/ip4/127.0.0.1/tcp/1234/ws/p2p/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj') // true
4640
+ * isIPFS.peerMultiaddr('/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4/p2p-circuit/p2p/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj') // true
4641
+ * isIPFS.peerMultiaddr('/dnsaddr/bootstrap.libp2p.io') // false (key missing, needs additional DNS lookup to tell if this is valid)
4642
+ * isIPFS.peerMultiaddr('/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN') // true (key present, ip and port can be resolved later)
4643
+ * isIPFS.peerMultiaddr('/ip4/127.0.0.1/udp/1234') // false (key missing)
4644
+ * ```
4645
+ */
4646
+
4647
+
4648
+
4649
+
4650
+
4651
+
4652
+
4653
+
4654
+ const pathGatewayPattern = /^https?:\/\/[^/]+\/(ip[fn]s)\/([^/?#]+)/;
4655
+ const pathPattern = /^\/(ip[fn]s)\/([^/?#]+)/;
4656
+ const defaultProtocolMatch = 1;
4657
+ const defaultHashMath = 2;
4658
+ // CID, libp2p-key or DNSLink
4659
+ const subdomainGatewayPattern = /^https?:\/\/([^/]+)\.(ip[fn]s)\.[^/?]+/;
4660
+ const subdomainIdMatch = 1;
4661
+ const subdomainProtocolMatch = 2;
4662
+ // Fully qualified domain name (FQDN) that has an explicit .tld suffix
4663
+ const fqdnWithTld = /^(([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)+([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])$/;
4664
+ function isMultihash(hash) {
4665
+ const formatted = src_convertToString(hash);
4666
+ if (formatted === false) {
4667
+ return false;
4668
+ }
4669
+ try {
4670
+ hashes_digest_decode(base58_base58btc.decode(`z${formatted}`));
4671
+ }
4672
+ catch {
4673
+ return false;
4674
+ }
4675
+ return true;
4676
+ }
4677
+ function src_isMultiaddr(input) {
4678
+ try {
4679
+ return Boolean(multiaddr(input));
4680
+ }
4681
+ catch {
4682
+ return false;
4683
+ }
4684
+ }
4685
+ function isBase32EncodedMultibase(hash) {
4686
+ try {
4687
+ let cid;
4688
+ if (isString(hash)) {
4689
+ cid = cid_CID.parse(hash);
4690
+ }
4691
+ else {
4692
+ cid = cid_CID.asCID(hash);
4693
+ }
4694
+ if (cid == null) {
4695
+ return false;
4696
+ }
4697
+ base32_base32.decode(cid.toString());
4698
+ }
4699
+ catch {
4700
+ return false;
4701
+ }
4702
+ return true;
4703
+ }
4704
+ function isCID(hash) {
4705
+ try {
4706
+ if (isString(hash)) {
4707
+ return Boolean(cid_CID.parse(hash));
4708
+ }
4709
+ if (hash instanceof Uint8Array) {
4710
+ return Boolean(cid_CID.decode(hash));
4711
+ }
4712
+ return Boolean(cid_CID.asCID(hash)); // eslint-disable-line no-new
4713
+ }
4714
+ catch {
4715
+ return false;
4716
+ }
4717
+ }
4718
+ /**
4719
+ * @param {string | Uint8Array | Multiaddr} input
4720
+ */
4721
+ function isPeerMultiaddr(input) {
4722
+ return src_isMultiaddr(input) && P2P.matches(input);
4723
+ }
4724
+ /**
4725
+ * @param {string | Uint8Array} input
4726
+ * @param {RegExp | string} pattern
4727
+ * @param {number} [protocolMatch=1]
4728
+ * @param {number} [hashMatch=2]
4729
+ */
4730
+ function isIpfs(input, pattern, protocolMatch = defaultProtocolMatch, hashMatch = defaultHashMath) {
4731
+ const formatted = src_convertToString(input);
4732
+ if (formatted === false) {
4733
+ return false;
4734
+ }
4735
+ const match = formatted.match(pattern);
4736
+ if (match == null) {
4737
+ return false;
4738
+ }
4739
+ if (match[protocolMatch] !== 'ipfs') {
4740
+ return false;
4741
+ }
4742
+ let hash = match[hashMatch];
4743
+ if (hash != null && pattern === subdomainGatewayPattern) {
4744
+ // when doing checks for subdomain context
4745
+ // ensure hash is case-insensitive
4746
+ // (browsers force-lowercase authority component anyway)
4747
+ hash = hash.toLowerCase();
4748
+ }
4749
+ return isCID(hash);
4750
+ }
4751
+ /**
4752
+ *
4753
+ * @param {string | Uint8Array} input
4754
+ * @param {string | RegExp} pattern
4755
+ * @param {number} [protocolMatch=1]
4756
+ * @param {number} [hashMatch=1]
4757
+ */
4758
+ function isIpns(input, pattern, protocolMatch = defaultProtocolMatch, hashMatch = defaultHashMath) {
4759
+ const formatted = src_convertToString(input);
4760
+ if (formatted === false) {
4761
+ return false;
4762
+ }
4763
+ const match = formatted.match(pattern);
4764
+ if (match == null) {
4765
+ return false;
4766
+ }
4767
+ if (match[protocolMatch] !== 'ipns') {
4768
+ return false;
4769
+ }
4770
+ let ipnsId = match[hashMatch];
4771
+ if (ipnsId != null && pattern === subdomainGatewayPattern) {
4772
+ // when doing checks for subdomain context
4773
+ // ensure ipnsId is case-insensitive
4774
+ // (browsers force-lowercase authority compotent anyway)
4775
+ ipnsId = ipnsId.toLowerCase();
4776
+ // Check if it is cidv1
4777
+ if (isCID(ipnsId))
4778
+ return true;
4779
+ // Check if it looks like FQDN
4780
+ try {
4781
+ if (!ipnsId.includes('.') && ipnsId.includes('-')) {
4782
+ // name without tld, assuming its inlined into a single DNS label
4783
+ // (https://github.com/ipfs/in-web-browsers/issues/169)
4784
+ // en-wikipedia--on--ipfs-org → en.wikipedia-on-ipfs.org
4785
+ ipnsId = ipnsId.replace(/--/g, '@').replace(/-/g, '.').replace(/@/g, '-');
4786
+ }
4787
+ // URL implementation in web browsers forces lowercase of the hostname
4788
+ const { hostname } = new iso_url.URL(`http://${ipnsId}`); // eslint-disable-line no-new
4789
+ // Check if potential FQDN has an explicit TLD
4790
+ return fqdnWithTld.test(hostname);
4791
+ }
4792
+ catch (e) {
4793
+ return false;
4794
+ }
4795
+ }
4796
+ return true;
4797
+ }
4798
+ /**
4799
+ * @param {any} input
4800
+ */
4801
+ function isString(input) {
4802
+ return typeof input === 'string';
4803
+ }
4804
+ /**
4805
+ * @param {Uint8Array | string} input
4806
+ */
4807
+ function src_convertToString(input) {
4808
+ if (input instanceof Uint8Array) {
4809
+ return (0,to_string.toString)(input, 'base58btc');
4810
+ }
4811
+ if (isString(input)) {
4812
+ return input;
4813
+ }
4814
+ return false;
4815
+ }
4816
+ /**
4817
+ * Returns `true` if the provided `url` string includes a valid IPFS subdomain
4818
+ * (case-insensitive CIDv1) or `false` otherwise.
4819
+ */
4820
+ const ipfsSubdomain = (url) => isIpfs(url, subdomainGatewayPattern, subdomainProtocolMatch, subdomainIdMatch);
4821
+ /**
4822
+ * Returns `true` if the provided `url` string looks like a valid IPNS subdomain
4823
+ * (CIDv1 with `libp2p-key` multicodec or something that looks like a FQDN, for
4824
+ * example `en.wikipedia-on-ipfs.org.ipns.localhost:8080`) or `false` otherwise.
4825
+ *
4826
+ * **Note:** `ipnsSubdomain` method works in offline mode: it does not perform
4827
+ * actual IPNS record lookup over DHT or other content routing method. It may
4828
+ * return false-positives:
4829
+ *
4830
+ * - To ensure IPNS record exists, make a call to `/api/v0/name/resolve?arg=<ipnsid>`
4831
+ * - To ensure DNSLink exists, make a call to `/api/v0/dns?arg=<fqdn>`
4832
+ */
4833
+ const ipnsSubdomain = (url) => isIpns(url, subdomainGatewayPattern, subdomainProtocolMatch, subdomainIdMatch);
4834
+ /**
4835
+ * Returns `true` if the provided `url` string includes a valid IPFS, looks like
4836
+ * an IPNS/DNSLink subdomain or `false` otherwise.
4837
+ */
4838
+ const subdomain = (url) => ipfsSubdomain(url) || ipnsSubdomain(url);
4839
+ /**
4840
+ * Returns `true` if the provided string is a valid IPFS url or `false`
4841
+ * otherwise.
4842
+ */
4843
+ const ipfsUrl = (url) => isIpfs(url, pathGatewayPattern) || ipfsSubdomain(url);
4844
+ /**
4845
+ * Returns `true` if the provided string is a valid IPNS url or `false`
4846
+ * otherwise.
4847
+ */
4848
+ const ipnsUrl = (url) => isIpns(url, pathGatewayPattern) || ipnsSubdomain(url);
4849
+ /**
4850
+ * Returns `true` if the provided string is a valid IPFS or IPNS url or `false`
4851
+ * otherwise.
4852
+ */
4853
+ const url = (url) => ipfsUrl(url) || ipnsUrl(url) || subdomain(url);
4854
+ const path = (path) => isIpfs(path, pathPattern) || isIpns(path, pathPattern);
4855
+ /**
4856
+ * Returns `true` if the provided string or `Uint8Array` is a valid `multihash`
4857
+ * or `false` otherwise.
4858
+ */
4859
+
4860
+ /**
4861
+ * Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr)
4862
+ * or `Uint8Array` represents a valid multiaddr or `false` otherwise.
4863
+ */
4864
+
4865
+ /**
4866
+ * Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr)
4867
+ * or `Uint8Array` represents a valid libp2p peer multiaddr (matching [`P2P`
4868
+ * format from `mafmt`](https://github.com/multiformats/js-mafmt#api)) or
4869
+ * `false` otherwise.
4870
+ */
4871
+
4872
+ /**
4873
+ * Returns `true` if the provided string, `Uint8Array` or [`CID`](https://github.com/multiformats/js-multiformats/#readme)
4874
+ * object represents a valid [CID](https://docs.ipfs.io/guides/concepts/cid/) or
4875
+ * `false` otherwise.
4876
+ */
4877
+
4878
+ /**
4879
+ * Returns `true` if the provided string is a valid `CID` in Base32 encoding or
4880
+ * `false` otherwise.
4881
+ */
4882
+ const base32cid = (cid) => (isCID(cid) && isBase32EncodedMultibase(cid));
4883
+ /**
4884
+ * Returns `true` if the provided string is a valid IPFS or IPNS path or `false`
4885
+ * otherwise.
4886
+ */
4887
+ const ipfsPath = (path) => isIpfs(path, pathPattern);
4888
+ /**
4889
+ * Returns `true` if the provided string is a valid IPNS path or `false`
4890
+ * otherwise.
4891
+ */
4892
+ const ipnsPath = (path) => isIpns(path, pathPattern);
4893
+ /**
4894
+ * Returns `true` if the provided string is a valid IPFS or IPNS url or path or
4895
+ * `false` otherwise.
4896
+ */
4897
+ const urlOrPath = (x) => url(x) || path(x);
4898
+ /**
4899
+ * Returns `true` if the provided string is a valid "CID path" (IPFS path
4900
+ * without `/ipfs/` prefix) or `false` otherwise.
4901
+ */
4902
+ const cidPath = (path) => isString(path) && !isCID(path) && isIpfs(`/ipfs/${path}`, pathPattern);
4903
+ //# sourceMappingURL=index.js.map
4904
+
4905
+ /***/ })
4906
+
4907
+ }]);
4908
+ //# sourceMappingURL=defaultVendors-node_modules_shogun-ipfs_node_modules_is-ipfs_dist_src_index_js.shogun-core.js.map