shogun-core 3.3.2 → 3.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_axios_index_js.shogun-core.js +4078 -0
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_axios_index_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_is-ipfs_dist_src_index_js.shogun-core.js +4908 -0
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_is-ipfs_dist_src_index_js.shogun-core.js.map +1 -0
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_uint8-varint_dist_src_index_js-node_modu-0db5ba.shogun-core.js +2109 -0
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_uint8-varint_dist_src_index_js-node_modu-0db5ba.shogun-core.js.map +1 -0
- package/dist/browser/shogun-core.js +154301 -43558
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/ship/examples/identity-cli.js +12 -4
- package/dist/ship/examples/vault-cli.js +2 -2
- package/dist/ship/implementation/SHIP_06.js +574 -289
- package/dist/ship/interfaces/ISHIP_06.js +135 -85
- package/dist/src/gundb/db.js +7 -49
- package/dist/src/index.js +1 -0
- package/dist/types/ship/implementation/SHIP_06.d.ts +90 -55
- package/dist/types/ship/interfaces/ISHIP_06.d.ts +383 -231
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +14 -5
- package/dist/ship/examples/ephemeral-cli.js +0 -234
- package/dist/ship/implementation/SHIP_07.js +0 -635
- package/dist/ship/interfaces/ISHIP_07.js +0 -194
- package/dist/types/ship/examples/ephemeral-cli.d.ts +0 -13
- package/dist/types/ship/implementation/SHIP_07.d.ts +0 -101
- package/dist/types/ship/interfaces/ISHIP_07.d.ts +0 -522
|
@@ -0,0 +1,2109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(this["webpackChunkShogunCore"] = this["webpackChunkShogunCore"] || []).push([["defaultVendors-node_modules_shogun-ipfs_node_modules_uint8-varint_dist_src_index_js-node_modu-0db5ba"],{
|
|
3
|
+
|
|
4
|
+
/***/ "./node_modules/shogun-ipfs/node_modules/uint8-varint/dist/src/index.js":
|
|
5
|
+
/*!******************************************************************************!*\
|
|
6
|
+
!*** ./node_modules/shogun-ipfs/node_modules/uint8-varint/dist/src/index.js ***!
|
|
7
|
+
\******************************************************************************/
|
|
8
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
9
|
+
|
|
10
|
+
__webpack_require__.r(__webpack_exports__);
|
|
11
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
12
|
+
/* harmony export */ decode: () => (/* binding */ decode),
|
|
13
|
+
/* harmony export */ decodeUint8Array: () => (/* binding */ decodeUint8Array),
|
|
14
|
+
/* harmony export */ decodeUint8ArrayList: () => (/* binding */ decodeUint8ArrayList),
|
|
15
|
+
/* harmony export */ encode: () => (/* binding */ encode),
|
|
16
|
+
/* harmony export */ encodeUint8Array: () => (/* binding */ encodeUint8Array),
|
|
17
|
+
/* harmony export */ encodeUint8ArrayList: () => (/* binding */ encodeUint8ArrayList),
|
|
18
|
+
/* harmony export */ encodingLength: () => (/* binding */ encodingLength)
|
|
19
|
+
/* harmony export */ });
|
|
20
|
+
/* harmony import */ var uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uint8arrays/alloc */ "./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/alloc.js");
|
|
21
|
+
/* eslint-disable no-fallthrough */
|
|
22
|
+
|
|
23
|
+
const N1 = Math.pow(2, 7);
|
|
24
|
+
const N2 = Math.pow(2, 14);
|
|
25
|
+
const N3 = Math.pow(2, 21);
|
|
26
|
+
const N4 = Math.pow(2, 28);
|
|
27
|
+
const N5 = Math.pow(2, 35);
|
|
28
|
+
const N6 = Math.pow(2, 42);
|
|
29
|
+
const N7 = Math.pow(2, 49);
|
|
30
|
+
/** Most significant bit of a byte */
|
|
31
|
+
const MSB = 0x80;
|
|
32
|
+
/** Rest of the bits in a byte */
|
|
33
|
+
const REST = 0x7f;
|
|
34
|
+
function encodingLength(value) {
|
|
35
|
+
if (value < N1) {
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
if (value < N2) {
|
|
39
|
+
return 2;
|
|
40
|
+
}
|
|
41
|
+
if (value < N3) {
|
|
42
|
+
return 3;
|
|
43
|
+
}
|
|
44
|
+
if (value < N4) {
|
|
45
|
+
return 4;
|
|
46
|
+
}
|
|
47
|
+
if (value < N5) {
|
|
48
|
+
return 5;
|
|
49
|
+
}
|
|
50
|
+
if (value < N6) {
|
|
51
|
+
return 6;
|
|
52
|
+
}
|
|
53
|
+
if (value < N7) {
|
|
54
|
+
return 7;
|
|
55
|
+
}
|
|
56
|
+
if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) {
|
|
57
|
+
throw new RangeError('Could not encode varint');
|
|
58
|
+
}
|
|
59
|
+
return 8;
|
|
60
|
+
}
|
|
61
|
+
function encodeUint8Array(value, buf, offset = 0) {
|
|
62
|
+
switch (encodingLength(value)) {
|
|
63
|
+
case 8: {
|
|
64
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
|
65
|
+
value /= 128;
|
|
66
|
+
}
|
|
67
|
+
case 7: {
|
|
68
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
|
69
|
+
value /= 128;
|
|
70
|
+
}
|
|
71
|
+
case 6: {
|
|
72
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
|
73
|
+
value /= 128;
|
|
74
|
+
}
|
|
75
|
+
case 5: {
|
|
76
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
|
77
|
+
value /= 128;
|
|
78
|
+
}
|
|
79
|
+
case 4: {
|
|
80
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
|
81
|
+
value >>>= 7;
|
|
82
|
+
}
|
|
83
|
+
case 3: {
|
|
84
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
|
85
|
+
value >>>= 7;
|
|
86
|
+
}
|
|
87
|
+
case 2: {
|
|
88
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
|
89
|
+
value >>>= 7;
|
|
90
|
+
}
|
|
91
|
+
case 1: {
|
|
92
|
+
buf[offset++] = (value & 0xFF);
|
|
93
|
+
value >>>= 7;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
default: throw new Error('unreachable');
|
|
97
|
+
}
|
|
98
|
+
return buf;
|
|
99
|
+
}
|
|
100
|
+
function encodeUint8ArrayList(value, buf, offset = 0) {
|
|
101
|
+
switch (encodingLength(value)) {
|
|
102
|
+
case 8: {
|
|
103
|
+
buf.set(offset++, (value & 0xFF) | MSB);
|
|
104
|
+
value /= 128;
|
|
105
|
+
}
|
|
106
|
+
case 7: {
|
|
107
|
+
buf.set(offset++, (value & 0xFF) | MSB);
|
|
108
|
+
value /= 128;
|
|
109
|
+
}
|
|
110
|
+
case 6: {
|
|
111
|
+
buf.set(offset++, (value & 0xFF) | MSB);
|
|
112
|
+
value /= 128;
|
|
113
|
+
}
|
|
114
|
+
case 5: {
|
|
115
|
+
buf.set(offset++, (value & 0xFF) | MSB);
|
|
116
|
+
value /= 128;
|
|
117
|
+
}
|
|
118
|
+
case 4: {
|
|
119
|
+
buf.set(offset++, (value & 0xFF) | MSB);
|
|
120
|
+
value >>>= 7;
|
|
121
|
+
}
|
|
122
|
+
case 3: {
|
|
123
|
+
buf.set(offset++, (value & 0xFF) | MSB);
|
|
124
|
+
value >>>= 7;
|
|
125
|
+
}
|
|
126
|
+
case 2: {
|
|
127
|
+
buf.set(offset++, (value & 0xFF) | MSB);
|
|
128
|
+
value >>>= 7;
|
|
129
|
+
}
|
|
130
|
+
case 1: {
|
|
131
|
+
buf.set(offset++, (value & 0xFF));
|
|
132
|
+
value >>>= 7;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
default: throw new Error('unreachable');
|
|
136
|
+
}
|
|
137
|
+
return buf;
|
|
138
|
+
}
|
|
139
|
+
function decodeUint8Array(buf, offset) {
|
|
140
|
+
let b = buf[offset];
|
|
141
|
+
let res = 0;
|
|
142
|
+
res += b & REST;
|
|
143
|
+
if (b < MSB) {
|
|
144
|
+
return res;
|
|
145
|
+
}
|
|
146
|
+
b = buf[offset + 1];
|
|
147
|
+
res += (b & REST) << 7;
|
|
148
|
+
if (b < MSB) {
|
|
149
|
+
return res;
|
|
150
|
+
}
|
|
151
|
+
b = buf[offset + 2];
|
|
152
|
+
res += (b & REST) << 14;
|
|
153
|
+
if (b < MSB) {
|
|
154
|
+
return res;
|
|
155
|
+
}
|
|
156
|
+
b = buf[offset + 3];
|
|
157
|
+
res += (b & REST) << 21;
|
|
158
|
+
if (b < MSB) {
|
|
159
|
+
return res;
|
|
160
|
+
}
|
|
161
|
+
b = buf[offset + 4];
|
|
162
|
+
res += (b & REST) * N4;
|
|
163
|
+
if (b < MSB) {
|
|
164
|
+
return res;
|
|
165
|
+
}
|
|
166
|
+
b = buf[offset + 5];
|
|
167
|
+
res += (b & REST) * N5;
|
|
168
|
+
if (b < MSB) {
|
|
169
|
+
return res;
|
|
170
|
+
}
|
|
171
|
+
b = buf[offset + 6];
|
|
172
|
+
res += (b & REST) * N6;
|
|
173
|
+
if (b < MSB) {
|
|
174
|
+
return res;
|
|
175
|
+
}
|
|
176
|
+
b = buf[offset + 7];
|
|
177
|
+
res += (b & REST) * N7;
|
|
178
|
+
if (b < MSB) {
|
|
179
|
+
return res;
|
|
180
|
+
}
|
|
181
|
+
throw new RangeError('Could not decode varint');
|
|
182
|
+
}
|
|
183
|
+
function decodeUint8ArrayList(buf, offset) {
|
|
184
|
+
let b = buf.get(offset);
|
|
185
|
+
let res = 0;
|
|
186
|
+
res += b & REST;
|
|
187
|
+
if (b < MSB) {
|
|
188
|
+
return res;
|
|
189
|
+
}
|
|
190
|
+
b = buf.get(offset + 1);
|
|
191
|
+
res += (b & REST) << 7;
|
|
192
|
+
if (b < MSB) {
|
|
193
|
+
return res;
|
|
194
|
+
}
|
|
195
|
+
b = buf.get(offset + 2);
|
|
196
|
+
res += (b & REST) << 14;
|
|
197
|
+
if (b < MSB) {
|
|
198
|
+
return res;
|
|
199
|
+
}
|
|
200
|
+
b = buf.get(offset + 3);
|
|
201
|
+
res += (b & REST) << 21;
|
|
202
|
+
if (b < MSB) {
|
|
203
|
+
return res;
|
|
204
|
+
}
|
|
205
|
+
b = buf.get(offset + 4);
|
|
206
|
+
res += (b & REST) * N4;
|
|
207
|
+
if (b < MSB) {
|
|
208
|
+
return res;
|
|
209
|
+
}
|
|
210
|
+
b = buf.get(offset + 5);
|
|
211
|
+
res += (b & REST) * N5;
|
|
212
|
+
if (b < MSB) {
|
|
213
|
+
return res;
|
|
214
|
+
}
|
|
215
|
+
b = buf.get(offset + 6);
|
|
216
|
+
res += (b & REST) * N6;
|
|
217
|
+
if (b < MSB) {
|
|
218
|
+
return res;
|
|
219
|
+
}
|
|
220
|
+
b = buf.get(offset + 7);
|
|
221
|
+
res += (b & REST) * N7;
|
|
222
|
+
if (b < MSB) {
|
|
223
|
+
return res;
|
|
224
|
+
}
|
|
225
|
+
throw new RangeError('Could not decode varint');
|
|
226
|
+
}
|
|
227
|
+
function encode(value, buf, offset = 0) {
|
|
228
|
+
if (buf == null) {
|
|
229
|
+
buf = (0,uint8arrays_alloc__WEBPACK_IMPORTED_MODULE_0__.allocUnsafe)(encodingLength(value));
|
|
230
|
+
}
|
|
231
|
+
if (buf instanceof Uint8Array) {
|
|
232
|
+
return encodeUint8Array(value, buf, offset);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return encodeUint8ArrayList(value, buf, offset);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function decode(buf, offset = 0) {
|
|
239
|
+
if (buf instanceof Uint8Array) {
|
|
240
|
+
return decodeUint8Array(buf, offset);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
return decodeUint8ArrayList(buf, offset);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=index.js.map
|
|
247
|
+
|
|
248
|
+
/***/ }),
|
|
249
|
+
|
|
250
|
+
/***/ "./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/alloc.js":
|
|
251
|
+
/*!*****************************************************************************!*\
|
|
252
|
+
!*** ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/alloc.js ***!
|
|
253
|
+
\*****************************************************************************/
|
|
254
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
255
|
+
|
|
256
|
+
__webpack_require__.r(__webpack_exports__);
|
|
257
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
258
|
+
/* harmony export */ alloc: () => (/* binding */ alloc),
|
|
259
|
+
/* harmony export */ allocUnsafe: () => (/* binding */ allocUnsafe)
|
|
260
|
+
/* harmony export */ });
|
|
261
|
+
/**
|
|
262
|
+
* Returns a `Uint8Array` of the requested size. Referenced memory will
|
|
263
|
+
* be initialized to 0.
|
|
264
|
+
*/
|
|
265
|
+
function alloc(size = 0) {
|
|
266
|
+
return new Uint8Array(size);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Where possible returns a Uint8Array of the requested size that references
|
|
270
|
+
* uninitialized memory. Only use if you are certain you will immediately
|
|
271
|
+
* overwrite every value in the returned `Uint8Array`.
|
|
272
|
+
*/
|
|
273
|
+
function allocUnsafe(size = 0) {
|
|
274
|
+
return new Uint8Array(size);
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=alloc.js.map
|
|
277
|
+
|
|
278
|
+
/***/ }),
|
|
279
|
+
|
|
280
|
+
/***/ "./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/concat.js":
|
|
281
|
+
/*!******************************************************************************************!*\
|
|
282
|
+
!*** ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/concat.js + 1 modules ***!
|
|
283
|
+
\******************************************************************************************/
|
|
284
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
285
|
+
|
|
286
|
+
// ESM COMPAT FLAG
|
|
287
|
+
__webpack_require__.r(__webpack_exports__);
|
|
288
|
+
|
|
289
|
+
// EXPORTS
|
|
290
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
291
|
+
concat: () => (/* binding */ concat)
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// EXTERNAL MODULE: ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/alloc.js
|
|
295
|
+
var alloc = __webpack_require__("./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/alloc.js");
|
|
296
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/util/as-uint8array.js
|
|
297
|
+
/**
|
|
298
|
+
* To guarantee Uint8Array semantics, convert nodejs Buffers
|
|
299
|
+
* into vanilla Uint8Arrays
|
|
300
|
+
*/
|
|
301
|
+
function asUint8Array(buf) {
|
|
302
|
+
return buf;
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=as-uint8array.js.map
|
|
305
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/concat.js
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Returns a new Uint8Array created by concatenating the passed Uint8Arrays
|
|
310
|
+
*/
|
|
311
|
+
function concat(arrays, length) {
|
|
312
|
+
if (length == null) {
|
|
313
|
+
length = arrays.reduce((acc, curr) => acc + curr.length, 0);
|
|
314
|
+
}
|
|
315
|
+
const output = (0,alloc.allocUnsafe)(length);
|
|
316
|
+
let offset = 0;
|
|
317
|
+
for (const arr of arrays) {
|
|
318
|
+
output.set(arr, offset);
|
|
319
|
+
offset += arr.length;
|
|
320
|
+
}
|
|
321
|
+
return asUint8Array(output);
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=concat.js.map
|
|
324
|
+
|
|
325
|
+
/***/ }),
|
|
326
|
+
|
|
327
|
+
/***/ "./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/equals.js":
|
|
328
|
+
/*!******************************************************************************!*\
|
|
329
|
+
!*** ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/equals.js ***!
|
|
330
|
+
\******************************************************************************/
|
|
331
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
332
|
+
|
|
333
|
+
__webpack_require__.r(__webpack_exports__);
|
|
334
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
335
|
+
/* harmony export */ equals: () => (/* binding */ equals)
|
|
336
|
+
/* harmony export */ });
|
|
337
|
+
/**
|
|
338
|
+
* Returns true if the two passed Uint8Arrays have the same content
|
|
339
|
+
*/
|
|
340
|
+
function equals(a, b) {
|
|
341
|
+
if (a === b) {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
if (a.byteLength !== b.byteLength) {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
for (let i = 0; i < a.byteLength; i++) {
|
|
348
|
+
if (a[i] !== b[i]) {
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
//# sourceMappingURL=equals.js.map
|
|
355
|
+
|
|
356
|
+
/***/ }),
|
|
357
|
+
|
|
358
|
+
/***/ "./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/from-string.js":
|
|
359
|
+
/*!***********************************************************************************!*\
|
|
360
|
+
!*** ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/from-string.js ***!
|
|
361
|
+
\***********************************************************************************/
|
|
362
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
363
|
+
|
|
364
|
+
__webpack_require__.r(__webpack_exports__);
|
|
365
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
366
|
+
/* harmony export */ fromString: () => (/* binding */ fromString)
|
|
367
|
+
/* harmony export */ });
|
|
368
|
+
/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ "./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/util/bases.js");
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Create a `Uint8Array` from the passed string
|
|
372
|
+
*
|
|
373
|
+
* Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.
|
|
374
|
+
*
|
|
375
|
+
* Also `ascii` which is similar to node's 'binary' encoding.
|
|
376
|
+
*/
|
|
377
|
+
function fromString(string, encoding = 'utf8') {
|
|
378
|
+
const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__["default"][encoding];
|
|
379
|
+
if (base == null) {
|
|
380
|
+
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
381
|
+
}
|
|
382
|
+
// add multibase prefix
|
|
383
|
+
return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=from-string.js.map
|
|
386
|
+
|
|
387
|
+
/***/ }),
|
|
388
|
+
|
|
389
|
+
/***/ "./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/to-string.js":
|
|
390
|
+
/*!*********************************************************************************!*\
|
|
391
|
+
!*** ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/to-string.js ***!
|
|
392
|
+
\*********************************************************************************/
|
|
393
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
394
|
+
|
|
395
|
+
__webpack_require__.r(__webpack_exports__);
|
|
396
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
397
|
+
/* harmony export */ toString: () => (/* binding */ toString)
|
|
398
|
+
/* harmony export */ });
|
|
399
|
+
/* harmony import */ var _util_bases_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/bases.js */ "./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/util/bases.js");
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Turns a `Uint8Array` into a string.
|
|
403
|
+
*
|
|
404
|
+
* Supports `utf8`, `utf-8` and any encoding supported by the multibase module.
|
|
405
|
+
*
|
|
406
|
+
* Also `ascii` which is similar to node's 'binary' encoding.
|
|
407
|
+
*/
|
|
408
|
+
function toString(array, encoding = 'utf8') {
|
|
409
|
+
const base = _util_bases_js__WEBPACK_IMPORTED_MODULE_0__["default"][encoding];
|
|
410
|
+
if (base == null) {
|
|
411
|
+
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
412
|
+
}
|
|
413
|
+
// strip multibase prefix
|
|
414
|
+
return base.encoder.encode(array).substring(1);
|
|
415
|
+
}
|
|
416
|
+
//# sourceMappingURL=to-string.js.map
|
|
417
|
+
|
|
418
|
+
/***/ }),
|
|
419
|
+
|
|
420
|
+
/***/ "./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/util/bases.js":
|
|
421
|
+
/*!***********************************************************************************************!*\
|
|
422
|
+
!*** ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/util/bases.js + 30 modules ***!
|
|
423
|
+
\***********************************************************************************************/
|
|
424
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
425
|
+
|
|
426
|
+
// ESM COMPAT FLAG
|
|
427
|
+
__webpack_require__.r(__webpack_exports__);
|
|
428
|
+
|
|
429
|
+
// EXPORTS
|
|
430
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
431
|
+
"default": () => (/* binding */ util_bases)
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base10.js
|
|
435
|
+
var base10_namespaceObject = {};
|
|
436
|
+
__webpack_require__.r(base10_namespaceObject);
|
|
437
|
+
__webpack_require__.d(base10_namespaceObject, {
|
|
438
|
+
base10: () => (base10)
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base16.js
|
|
442
|
+
var base16_namespaceObject = {};
|
|
443
|
+
__webpack_require__.r(base16_namespaceObject);
|
|
444
|
+
__webpack_require__.d(base16_namespaceObject, {
|
|
445
|
+
base16: () => (base16),
|
|
446
|
+
base16upper: () => (base16upper)
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base2.js
|
|
450
|
+
var base2_namespaceObject = {};
|
|
451
|
+
__webpack_require__.r(base2_namespaceObject);
|
|
452
|
+
__webpack_require__.d(base2_namespaceObject, {
|
|
453
|
+
base2: () => (base2)
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base256emoji.js
|
|
457
|
+
var base256emoji_namespaceObject = {};
|
|
458
|
+
__webpack_require__.r(base256emoji_namespaceObject);
|
|
459
|
+
__webpack_require__.d(base256emoji_namespaceObject, {
|
|
460
|
+
base256emoji: () => (base256emoji)
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base32.js
|
|
464
|
+
var base32_namespaceObject = {};
|
|
465
|
+
__webpack_require__.r(base32_namespaceObject);
|
|
466
|
+
__webpack_require__.d(base32_namespaceObject, {
|
|
467
|
+
base32: () => (base32),
|
|
468
|
+
base32hex: () => (base32hex),
|
|
469
|
+
base32hexpad: () => (base32hexpad),
|
|
470
|
+
base32hexpadupper: () => (base32hexpadupper),
|
|
471
|
+
base32hexupper: () => (base32hexupper),
|
|
472
|
+
base32pad: () => (base32pad),
|
|
473
|
+
base32padupper: () => (base32padupper),
|
|
474
|
+
base32upper: () => (base32upper),
|
|
475
|
+
base32z: () => (base32z)
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base36.js
|
|
479
|
+
var base36_namespaceObject = {};
|
|
480
|
+
__webpack_require__.r(base36_namespaceObject);
|
|
481
|
+
__webpack_require__.d(base36_namespaceObject, {
|
|
482
|
+
base36: () => (base36),
|
|
483
|
+
base36upper: () => (base36upper)
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base58.js
|
|
487
|
+
var base58_namespaceObject = {};
|
|
488
|
+
__webpack_require__.r(base58_namespaceObject);
|
|
489
|
+
__webpack_require__.d(base58_namespaceObject, {
|
|
490
|
+
base58btc: () => (base58btc),
|
|
491
|
+
base58flickr: () => (base58flickr)
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base64.js
|
|
495
|
+
var base64_namespaceObject = {};
|
|
496
|
+
__webpack_require__.r(base64_namespaceObject);
|
|
497
|
+
__webpack_require__.d(base64_namespaceObject, {
|
|
498
|
+
base64: () => (base64),
|
|
499
|
+
base64pad: () => (base64pad),
|
|
500
|
+
base64url: () => (base64url),
|
|
501
|
+
base64urlpad: () => (base64urlpad)
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base8.js
|
|
505
|
+
var base8_namespaceObject = {};
|
|
506
|
+
__webpack_require__.r(base8_namespaceObject);
|
|
507
|
+
__webpack_require__.d(base8_namespaceObject, {
|
|
508
|
+
base8: () => (base8)
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/identity.js
|
|
512
|
+
var identity_namespaceObject = {};
|
|
513
|
+
__webpack_require__.r(identity_namespaceObject);
|
|
514
|
+
__webpack_require__.d(identity_namespaceObject, {
|
|
515
|
+
identity: () => (identity)
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/codecs/json.js
|
|
519
|
+
var json_namespaceObject = {};
|
|
520
|
+
__webpack_require__.r(json_namespaceObject);
|
|
521
|
+
__webpack_require__.d(json_namespaceObject, {
|
|
522
|
+
code: () => (code),
|
|
523
|
+
decode: () => (json_decode),
|
|
524
|
+
encode: () => (json_encode),
|
|
525
|
+
name: () => (json_name)
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/codecs/raw.js
|
|
529
|
+
var raw_namespaceObject = {};
|
|
530
|
+
__webpack_require__.r(raw_namespaceObject);
|
|
531
|
+
__webpack_require__.d(raw_namespaceObject, {
|
|
532
|
+
code: () => (raw_code),
|
|
533
|
+
decode: () => (raw_decode),
|
|
534
|
+
encode: () => (raw_encode),
|
|
535
|
+
name: () => (raw_name)
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/hashes/identity.js
|
|
539
|
+
var hashes_identity_namespaceObject = {};
|
|
540
|
+
__webpack_require__.r(hashes_identity_namespaceObject);
|
|
541
|
+
__webpack_require__.d(hashes_identity_namespaceObject, {
|
|
542
|
+
identity: () => (identity_identity)
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
// NAMESPACE OBJECT: ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/hashes/sha2-browser.js
|
|
546
|
+
var sha2_browser_namespaceObject = {};
|
|
547
|
+
__webpack_require__.r(sha2_browser_namespaceObject);
|
|
548
|
+
__webpack_require__.d(sha2_browser_namespaceObject, {
|
|
549
|
+
sha256: () => (sha256),
|
|
550
|
+
sha512: () => (sha512)
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bytes.js
|
|
554
|
+
const empty = new Uint8Array(0);
|
|
555
|
+
function toHex(d) {
|
|
556
|
+
return d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), '');
|
|
557
|
+
}
|
|
558
|
+
function fromHex(hex) {
|
|
559
|
+
const hexes = hex.match(/../g);
|
|
560
|
+
return hexes != null ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty;
|
|
561
|
+
}
|
|
562
|
+
function equals(aa, bb) {
|
|
563
|
+
if (aa === bb)
|
|
564
|
+
return true;
|
|
565
|
+
if (aa.byteLength !== bb.byteLength) {
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
for (let ii = 0; ii < aa.byteLength; ii++) {
|
|
569
|
+
if (aa[ii] !== bb[ii]) {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
function coerce(o) {
|
|
576
|
+
if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')
|
|
577
|
+
return o;
|
|
578
|
+
if (o instanceof ArrayBuffer)
|
|
579
|
+
return new Uint8Array(o);
|
|
580
|
+
if (ArrayBuffer.isView(o)) {
|
|
581
|
+
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
582
|
+
}
|
|
583
|
+
throw new Error('Unknown type, must be binary type');
|
|
584
|
+
}
|
|
585
|
+
function isBinary(o) {
|
|
586
|
+
return o instanceof ArrayBuffer || ArrayBuffer.isView(o);
|
|
587
|
+
}
|
|
588
|
+
function fromString(str) {
|
|
589
|
+
return new TextEncoder().encode(str);
|
|
590
|
+
}
|
|
591
|
+
function bytes_toString(b) {
|
|
592
|
+
return new TextDecoder().decode(b);
|
|
593
|
+
}
|
|
594
|
+
//# sourceMappingURL=bytes.js.map
|
|
595
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/vendor/base-x.js
|
|
596
|
+
/* eslint-disable */
|
|
597
|
+
// base-x encoding / decoding
|
|
598
|
+
// Copyright (c) 2018 base-x contributors
|
|
599
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
600
|
+
// Distributed under the MIT software license, see the accompanying
|
|
601
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
602
|
+
/**
|
|
603
|
+
* @param {string} ALPHABET
|
|
604
|
+
* @param {any} name
|
|
605
|
+
*/
|
|
606
|
+
function base(ALPHABET, name) {
|
|
607
|
+
if (ALPHABET.length >= 255) {
|
|
608
|
+
throw new TypeError('Alphabet too long');
|
|
609
|
+
}
|
|
610
|
+
var BASE_MAP = new Uint8Array(256);
|
|
611
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
612
|
+
BASE_MAP[j] = 255;
|
|
613
|
+
}
|
|
614
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
|
615
|
+
var x = ALPHABET.charAt(i);
|
|
616
|
+
var xc = x.charCodeAt(0);
|
|
617
|
+
if (BASE_MAP[xc] !== 255) {
|
|
618
|
+
throw new TypeError(x + ' is ambiguous');
|
|
619
|
+
}
|
|
620
|
+
BASE_MAP[xc] = i;
|
|
621
|
+
}
|
|
622
|
+
var BASE = ALPHABET.length;
|
|
623
|
+
var LEADER = ALPHABET.charAt(0);
|
|
624
|
+
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
625
|
+
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
626
|
+
/**
|
|
627
|
+
* @param {any[] | Iterable<number>} source
|
|
628
|
+
*/
|
|
629
|
+
function encode(source) {
|
|
630
|
+
// @ts-ignore
|
|
631
|
+
if (source instanceof Uint8Array)
|
|
632
|
+
;
|
|
633
|
+
else if (ArrayBuffer.isView(source)) {
|
|
634
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
635
|
+
}
|
|
636
|
+
else if (Array.isArray(source)) {
|
|
637
|
+
source = Uint8Array.from(source);
|
|
638
|
+
}
|
|
639
|
+
if (!(source instanceof Uint8Array)) {
|
|
640
|
+
throw new TypeError('Expected Uint8Array');
|
|
641
|
+
}
|
|
642
|
+
if (source.length === 0) {
|
|
643
|
+
return '';
|
|
644
|
+
}
|
|
645
|
+
// Skip & count leading zeroes.
|
|
646
|
+
var zeroes = 0;
|
|
647
|
+
var length = 0;
|
|
648
|
+
var pbegin = 0;
|
|
649
|
+
var pend = source.length;
|
|
650
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
651
|
+
pbegin++;
|
|
652
|
+
zeroes++;
|
|
653
|
+
}
|
|
654
|
+
// Allocate enough space in big-endian base58 representation.
|
|
655
|
+
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
656
|
+
var b58 = new Uint8Array(size);
|
|
657
|
+
// Process the bytes.
|
|
658
|
+
while (pbegin !== pend) {
|
|
659
|
+
var carry = source[pbegin];
|
|
660
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
661
|
+
var i = 0;
|
|
662
|
+
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
663
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
664
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
665
|
+
carry = (carry / BASE) >>> 0;
|
|
666
|
+
}
|
|
667
|
+
if (carry !== 0) {
|
|
668
|
+
throw new Error('Non-zero carry');
|
|
669
|
+
}
|
|
670
|
+
length = i;
|
|
671
|
+
pbegin++;
|
|
672
|
+
}
|
|
673
|
+
// Skip leading zeroes in base58 result.
|
|
674
|
+
var it2 = size - length;
|
|
675
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
676
|
+
it2++;
|
|
677
|
+
}
|
|
678
|
+
// Translate the result into a string.
|
|
679
|
+
var str = LEADER.repeat(zeroes);
|
|
680
|
+
for (; it2 < size; ++it2) {
|
|
681
|
+
str += ALPHABET.charAt(b58[it2]);
|
|
682
|
+
}
|
|
683
|
+
return str;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* @param {string | string[]} source
|
|
687
|
+
*/
|
|
688
|
+
function decodeUnsafe(source) {
|
|
689
|
+
if (typeof source !== 'string') {
|
|
690
|
+
throw new TypeError('Expected String');
|
|
691
|
+
}
|
|
692
|
+
if (source.length === 0) {
|
|
693
|
+
return new Uint8Array();
|
|
694
|
+
}
|
|
695
|
+
var psz = 0;
|
|
696
|
+
// Skip leading spaces.
|
|
697
|
+
if (source[psz] === ' ') {
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
// Skip and count leading '1's.
|
|
701
|
+
var zeroes = 0;
|
|
702
|
+
var length = 0;
|
|
703
|
+
while (source[psz] === LEADER) {
|
|
704
|
+
zeroes++;
|
|
705
|
+
psz++;
|
|
706
|
+
}
|
|
707
|
+
// Allocate enough space in big-endian base256 representation.
|
|
708
|
+
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
709
|
+
var b256 = new Uint8Array(size);
|
|
710
|
+
// Process the characters.
|
|
711
|
+
while (source[psz]) {
|
|
712
|
+
// Decode character
|
|
713
|
+
var carry = BASE_MAP[source.charCodeAt(psz)];
|
|
714
|
+
// Invalid character
|
|
715
|
+
if (carry === 255) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
var i = 0;
|
|
719
|
+
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
720
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
721
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
722
|
+
carry = (carry / 256) >>> 0;
|
|
723
|
+
}
|
|
724
|
+
if (carry !== 0) {
|
|
725
|
+
throw new Error('Non-zero carry');
|
|
726
|
+
}
|
|
727
|
+
length = i;
|
|
728
|
+
psz++;
|
|
729
|
+
}
|
|
730
|
+
// Skip trailing spaces.
|
|
731
|
+
if (source[psz] === ' ') {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
// Skip leading zeroes in b256.
|
|
735
|
+
var it4 = size - length;
|
|
736
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
737
|
+
it4++;
|
|
738
|
+
}
|
|
739
|
+
var vch = new Uint8Array(zeroes + (size - it4));
|
|
740
|
+
var j = zeroes;
|
|
741
|
+
while (it4 !== size) {
|
|
742
|
+
vch[j++] = b256[it4++];
|
|
743
|
+
}
|
|
744
|
+
return vch;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* @param {string | string[]} string
|
|
748
|
+
*/
|
|
749
|
+
function decode(string) {
|
|
750
|
+
var buffer = decodeUnsafe(string);
|
|
751
|
+
if (buffer) {
|
|
752
|
+
return buffer;
|
|
753
|
+
}
|
|
754
|
+
throw new Error(`Non-${name} character`);
|
|
755
|
+
}
|
|
756
|
+
return {
|
|
757
|
+
encode: encode,
|
|
758
|
+
decodeUnsafe: decodeUnsafe,
|
|
759
|
+
decode: decode
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
var src = base;
|
|
763
|
+
var _brrp__multiformats_scope_baseX = src;
|
|
764
|
+
/* harmony default export */ const base_x = (_brrp__multiformats_scope_baseX);
|
|
765
|
+
//# sourceMappingURL=base-x.js.map
|
|
766
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base.js
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Class represents both BaseEncoder and MultibaseEncoder meaning it
|
|
771
|
+
* can be used to encode to multibase or base encode without multibase
|
|
772
|
+
* prefix.
|
|
773
|
+
*/
|
|
774
|
+
class Encoder {
|
|
775
|
+
name;
|
|
776
|
+
prefix;
|
|
777
|
+
baseEncode;
|
|
778
|
+
constructor(name, prefix, baseEncode) {
|
|
779
|
+
this.name = name;
|
|
780
|
+
this.prefix = prefix;
|
|
781
|
+
this.baseEncode = baseEncode;
|
|
782
|
+
}
|
|
783
|
+
encode(bytes) {
|
|
784
|
+
if (bytes instanceof Uint8Array) {
|
|
785
|
+
return `${this.prefix}${this.baseEncode(bytes)}`;
|
|
786
|
+
}
|
|
787
|
+
else {
|
|
788
|
+
throw Error('Unknown type, must be binary type');
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Class represents both BaseDecoder and MultibaseDecoder so it could be used
|
|
794
|
+
* to decode multibases (with matching prefix) or just base decode strings
|
|
795
|
+
* with corresponding base encoding.
|
|
796
|
+
*/
|
|
797
|
+
class Decoder {
|
|
798
|
+
name;
|
|
799
|
+
prefix;
|
|
800
|
+
baseDecode;
|
|
801
|
+
prefixCodePoint;
|
|
802
|
+
constructor(name, prefix, baseDecode) {
|
|
803
|
+
this.name = name;
|
|
804
|
+
this.prefix = prefix;
|
|
805
|
+
const prefixCodePoint = prefix.codePointAt(0);
|
|
806
|
+
/* c8 ignore next 3 */
|
|
807
|
+
if (prefixCodePoint === undefined) {
|
|
808
|
+
throw new Error('Invalid prefix character');
|
|
809
|
+
}
|
|
810
|
+
this.prefixCodePoint = prefixCodePoint;
|
|
811
|
+
this.baseDecode = baseDecode;
|
|
812
|
+
}
|
|
813
|
+
decode(text) {
|
|
814
|
+
if (typeof text === 'string') {
|
|
815
|
+
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
|
816
|
+
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
|
817
|
+
}
|
|
818
|
+
return this.baseDecode(text.slice(this.prefix.length));
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
throw Error('Can only multibase decode strings');
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
or(decoder) {
|
|
825
|
+
return or(this, decoder);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
class ComposedDecoder {
|
|
829
|
+
decoders;
|
|
830
|
+
constructor(decoders) {
|
|
831
|
+
this.decoders = decoders;
|
|
832
|
+
}
|
|
833
|
+
or(decoder) {
|
|
834
|
+
return or(this, decoder);
|
|
835
|
+
}
|
|
836
|
+
decode(input) {
|
|
837
|
+
const prefix = input[0];
|
|
838
|
+
const decoder = this.decoders[prefix];
|
|
839
|
+
if (decoder != null) {
|
|
840
|
+
return decoder.decode(input);
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
function or(left, right) {
|
|
848
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
849
|
+
return new ComposedDecoder({
|
|
850
|
+
...(left.decoders ?? { [left.prefix]: left }),
|
|
851
|
+
...(right.decoders ?? { [right.prefix]: right })
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
class Codec {
|
|
855
|
+
name;
|
|
856
|
+
prefix;
|
|
857
|
+
baseEncode;
|
|
858
|
+
baseDecode;
|
|
859
|
+
encoder;
|
|
860
|
+
decoder;
|
|
861
|
+
constructor(name, prefix, baseEncode, baseDecode) {
|
|
862
|
+
this.name = name;
|
|
863
|
+
this.prefix = prefix;
|
|
864
|
+
this.baseEncode = baseEncode;
|
|
865
|
+
this.baseDecode = baseDecode;
|
|
866
|
+
this.encoder = new Encoder(name, prefix, baseEncode);
|
|
867
|
+
this.decoder = new Decoder(name, prefix, baseDecode);
|
|
868
|
+
}
|
|
869
|
+
encode(input) {
|
|
870
|
+
return this.encoder.encode(input);
|
|
871
|
+
}
|
|
872
|
+
decode(input) {
|
|
873
|
+
return this.decoder.decode(input);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
function from({ name, prefix, encode, decode }) {
|
|
877
|
+
return new Codec(name, prefix, encode, decode);
|
|
878
|
+
}
|
|
879
|
+
function baseX({ name, prefix, alphabet }) {
|
|
880
|
+
const { encode, decode } = base_x(alphabet, name);
|
|
881
|
+
return from({
|
|
882
|
+
prefix,
|
|
883
|
+
name,
|
|
884
|
+
encode,
|
|
885
|
+
decode: (text) => coerce(decode(text))
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
function decode(string, alphabet, bitsPerChar, name) {
|
|
889
|
+
// Build the character lookup table:
|
|
890
|
+
const codes = {};
|
|
891
|
+
for (let i = 0; i < alphabet.length; ++i) {
|
|
892
|
+
codes[alphabet[i]] = i;
|
|
893
|
+
}
|
|
894
|
+
// Count the padding bytes:
|
|
895
|
+
let end = string.length;
|
|
896
|
+
while (string[end - 1] === '=') {
|
|
897
|
+
--end;
|
|
898
|
+
}
|
|
899
|
+
// Allocate the output:
|
|
900
|
+
const out = new Uint8Array((end * bitsPerChar / 8) | 0);
|
|
901
|
+
// Parse the data:
|
|
902
|
+
let bits = 0; // Number of bits currently in the buffer
|
|
903
|
+
let buffer = 0; // Bits waiting to be written out, MSB first
|
|
904
|
+
let written = 0; // Next byte to write
|
|
905
|
+
for (let i = 0; i < end; ++i) {
|
|
906
|
+
// Read one character from the string:
|
|
907
|
+
const value = codes[string[i]];
|
|
908
|
+
if (value === undefined) {
|
|
909
|
+
throw new SyntaxError(`Non-${name} character`);
|
|
910
|
+
}
|
|
911
|
+
// Append the bits to the buffer:
|
|
912
|
+
buffer = (buffer << bitsPerChar) | value;
|
|
913
|
+
bits += bitsPerChar;
|
|
914
|
+
// Write out some bits if the buffer has a byte's worth:
|
|
915
|
+
if (bits >= 8) {
|
|
916
|
+
bits -= 8;
|
|
917
|
+
out[written++] = 0xff & (buffer >> bits);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
// Verify that we have received just enough bits:
|
|
921
|
+
if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {
|
|
922
|
+
throw new SyntaxError('Unexpected end of data');
|
|
923
|
+
}
|
|
924
|
+
return out;
|
|
925
|
+
}
|
|
926
|
+
function encode(data, alphabet, bitsPerChar) {
|
|
927
|
+
const pad = alphabet[alphabet.length - 1] === '=';
|
|
928
|
+
const mask = (1 << bitsPerChar) - 1;
|
|
929
|
+
let out = '';
|
|
930
|
+
let bits = 0; // Number of bits currently in the buffer
|
|
931
|
+
let buffer = 0; // Bits waiting to be written out, MSB first
|
|
932
|
+
for (let i = 0; i < data.length; ++i) {
|
|
933
|
+
// Slurp data into the buffer:
|
|
934
|
+
buffer = (buffer << 8) | data[i];
|
|
935
|
+
bits += 8;
|
|
936
|
+
// Write out as much as we can:
|
|
937
|
+
while (bits > bitsPerChar) {
|
|
938
|
+
bits -= bitsPerChar;
|
|
939
|
+
out += alphabet[mask & (buffer >> bits)];
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
// Partial character:
|
|
943
|
+
if (bits !== 0) {
|
|
944
|
+
out += alphabet[mask & (buffer << (bitsPerChar - bits))];
|
|
945
|
+
}
|
|
946
|
+
// Add padding characters until we hit a byte boundary:
|
|
947
|
+
if (pad) {
|
|
948
|
+
while (((out.length * bitsPerChar) & 7) !== 0) {
|
|
949
|
+
out += '=';
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
return out;
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* RFC4648 Factory
|
|
956
|
+
*/
|
|
957
|
+
function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
|
|
958
|
+
return from({
|
|
959
|
+
prefix,
|
|
960
|
+
name,
|
|
961
|
+
encode(input) {
|
|
962
|
+
return encode(input, alphabet, bitsPerChar);
|
|
963
|
+
},
|
|
964
|
+
decode(input) {
|
|
965
|
+
return decode(input, alphabet, bitsPerChar, name);
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
//# sourceMappingURL=base.js.map
|
|
970
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base10.js
|
|
971
|
+
|
|
972
|
+
const base10 = baseX({
|
|
973
|
+
prefix: '9',
|
|
974
|
+
name: 'base10',
|
|
975
|
+
alphabet: '0123456789'
|
|
976
|
+
});
|
|
977
|
+
//# sourceMappingURL=base10.js.map
|
|
978
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base16.js
|
|
979
|
+
|
|
980
|
+
const base16 = rfc4648({
|
|
981
|
+
prefix: 'f',
|
|
982
|
+
name: 'base16',
|
|
983
|
+
alphabet: '0123456789abcdef',
|
|
984
|
+
bitsPerChar: 4
|
|
985
|
+
});
|
|
986
|
+
const base16upper = rfc4648({
|
|
987
|
+
prefix: 'F',
|
|
988
|
+
name: 'base16upper',
|
|
989
|
+
alphabet: '0123456789ABCDEF',
|
|
990
|
+
bitsPerChar: 4
|
|
991
|
+
});
|
|
992
|
+
//# sourceMappingURL=base16.js.map
|
|
993
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base2.js
|
|
994
|
+
|
|
995
|
+
const base2 = rfc4648({
|
|
996
|
+
prefix: '0',
|
|
997
|
+
name: 'base2',
|
|
998
|
+
alphabet: '01',
|
|
999
|
+
bitsPerChar: 1
|
|
1000
|
+
});
|
|
1001
|
+
//# sourceMappingURL=base2.js.map
|
|
1002
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base256emoji.js
|
|
1003
|
+
|
|
1004
|
+
const alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');
|
|
1005
|
+
const alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));
|
|
1006
|
+
const alphabetCharsToBytes = (alphabet.reduce((p, c, i) => {
|
|
1007
|
+
const codePoint = c.codePointAt(0);
|
|
1008
|
+
if (codePoint == null) {
|
|
1009
|
+
throw new Error(`Invalid character: ${c}`);
|
|
1010
|
+
}
|
|
1011
|
+
p[codePoint] = i;
|
|
1012
|
+
return p;
|
|
1013
|
+
}, ([])));
|
|
1014
|
+
function base256emoji_encode(data) {
|
|
1015
|
+
return data.reduce((p, c) => {
|
|
1016
|
+
p += alphabetBytesToChars[c];
|
|
1017
|
+
return p;
|
|
1018
|
+
}, '');
|
|
1019
|
+
}
|
|
1020
|
+
function base256emoji_decode(str) {
|
|
1021
|
+
const byts = [];
|
|
1022
|
+
for (const char of str) {
|
|
1023
|
+
const codePoint = char.codePointAt(0);
|
|
1024
|
+
if (codePoint == null) {
|
|
1025
|
+
throw new Error(`Invalid character: ${char}`);
|
|
1026
|
+
}
|
|
1027
|
+
const byt = alphabetCharsToBytes[codePoint];
|
|
1028
|
+
if (byt == null) {
|
|
1029
|
+
throw new Error(`Non-base256emoji character: ${char}`);
|
|
1030
|
+
}
|
|
1031
|
+
byts.push(byt);
|
|
1032
|
+
}
|
|
1033
|
+
return new Uint8Array(byts);
|
|
1034
|
+
}
|
|
1035
|
+
const base256emoji = from({
|
|
1036
|
+
prefix: '🚀',
|
|
1037
|
+
name: 'base256emoji',
|
|
1038
|
+
encode: base256emoji_encode,
|
|
1039
|
+
decode: base256emoji_decode
|
|
1040
|
+
});
|
|
1041
|
+
//# sourceMappingURL=base256emoji.js.map
|
|
1042
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base32.js
|
|
1043
|
+
|
|
1044
|
+
const base32 = rfc4648({
|
|
1045
|
+
prefix: 'b',
|
|
1046
|
+
name: 'base32',
|
|
1047
|
+
alphabet: 'abcdefghijklmnopqrstuvwxyz234567',
|
|
1048
|
+
bitsPerChar: 5
|
|
1049
|
+
});
|
|
1050
|
+
const base32upper = rfc4648({
|
|
1051
|
+
prefix: 'B',
|
|
1052
|
+
name: 'base32upper',
|
|
1053
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',
|
|
1054
|
+
bitsPerChar: 5
|
|
1055
|
+
});
|
|
1056
|
+
const base32pad = rfc4648({
|
|
1057
|
+
prefix: 'c',
|
|
1058
|
+
name: 'base32pad',
|
|
1059
|
+
alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',
|
|
1060
|
+
bitsPerChar: 5
|
|
1061
|
+
});
|
|
1062
|
+
const base32padupper = rfc4648({
|
|
1063
|
+
prefix: 'C',
|
|
1064
|
+
name: 'base32padupper',
|
|
1065
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',
|
|
1066
|
+
bitsPerChar: 5
|
|
1067
|
+
});
|
|
1068
|
+
const base32hex = rfc4648({
|
|
1069
|
+
prefix: 'v',
|
|
1070
|
+
name: 'base32hex',
|
|
1071
|
+
alphabet: '0123456789abcdefghijklmnopqrstuv',
|
|
1072
|
+
bitsPerChar: 5
|
|
1073
|
+
});
|
|
1074
|
+
const base32hexupper = rfc4648({
|
|
1075
|
+
prefix: 'V',
|
|
1076
|
+
name: 'base32hexupper',
|
|
1077
|
+
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',
|
|
1078
|
+
bitsPerChar: 5
|
|
1079
|
+
});
|
|
1080
|
+
const base32hexpad = rfc4648({
|
|
1081
|
+
prefix: 't',
|
|
1082
|
+
name: 'base32hexpad',
|
|
1083
|
+
alphabet: '0123456789abcdefghijklmnopqrstuv=',
|
|
1084
|
+
bitsPerChar: 5
|
|
1085
|
+
});
|
|
1086
|
+
const base32hexpadupper = rfc4648({
|
|
1087
|
+
prefix: 'T',
|
|
1088
|
+
name: 'base32hexpadupper',
|
|
1089
|
+
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',
|
|
1090
|
+
bitsPerChar: 5
|
|
1091
|
+
});
|
|
1092
|
+
const base32z = rfc4648({
|
|
1093
|
+
prefix: 'h',
|
|
1094
|
+
name: 'base32z',
|
|
1095
|
+
alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',
|
|
1096
|
+
bitsPerChar: 5
|
|
1097
|
+
});
|
|
1098
|
+
//# sourceMappingURL=base32.js.map
|
|
1099
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base36.js
|
|
1100
|
+
|
|
1101
|
+
const base36 = baseX({
|
|
1102
|
+
prefix: 'k',
|
|
1103
|
+
name: 'base36',
|
|
1104
|
+
alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'
|
|
1105
|
+
});
|
|
1106
|
+
const base36upper = baseX({
|
|
1107
|
+
prefix: 'K',
|
|
1108
|
+
name: 'base36upper',
|
|
1109
|
+
alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
1110
|
+
});
|
|
1111
|
+
//# sourceMappingURL=base36.js.map
|
|
1112
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base58.js
|
|
1113
|
+
|
|
1114
|
+
const base58btc = baseX({
|
|
1115
|
+
name: 'base58btc',
|
|
1116
|
+
prefix: 'z',
|
|
1117
|
+
alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
|
1118
|
+
});
|
|
1119
|
+
const base58flickr = baseX({
|
|
1120
|
+
name: 'base58flickr',
|
|
1121
|
+
prefix: 'Z',
|
|
1122
|
+
alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
|
|
1123
|
+
});
|
|
1124
|
+
//# sourceMappingURL=base58.js.map
|
|
1125
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base64.js
|
|
1126
|
+
|
|
1127
|
+
const base64 = rfc4648({
|
|
1128
|
+
prefix: 'm',
|
|
1129
|
+
name: 'base64',
|
|
1130
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
|
1131
|
+
bitsPerChar: 6
|
|
1132
|
+
});
|
|
1133
|
+
const base64pad = rfc4648({
|
|
1134
|
+
prefix: 'M',
|
|
1135
|
+
name: 'base64pad',
|
|
1136
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
1137
|
+
bitsPerChar: 6
|
|
1138
|
+
});
|
|
1139
|
+
const base64url = rfc4648({
|
|
1140
|
+
prefix: 'u',
|
|
1141
|
+
name: 'base64url',
|
|
1142
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
|
1143
|
+
bitsPerChar: 6
|
|
1144
|
+
});
|
|
1145
|
+
const base64urlpad = rfc4648({
|
|
1146
|
+
prefix: 'U',
|
|
1147
|
+
name: 'base64urlpad',
|
|
1148
|
+
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',
|
|
1149
|
+
bitsPerChar: 6
|
|
1150
|
+
});
|
|
1151
|
+
//# sourceMappingURL=base64.js.map
|
|
1152
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/base8.js
|
|
1153
|
+
|
|
1154
|
+
const base8 = rfc4648({
|
|
1155
|
+
prefix: '7',
|
|
1156
|
+
name: 'base8',
|
|
1157
|
+
alphabet: '01234567',
|
|
1158
|
+
bitsPerChar: 3
|
|
1159
|
+
});
|
|
1160
|
+
//# sourceMappingURL=base8.js.map
|
|
1161
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/identity.js
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
const identity = from({
|
|
1165
|
+
prefix: '\x00',
|
|
1166
|
+
name: 'identity',
|
|
1167
|
+
encode: (buf) => bytes_toString(buf),
|
|
1168
|
+
decode: (str) => fromString(str)
|
|
1169
|
+
});
|
|
1170
|
+
//# sourceMappingURL=identity.js.map
|
|
1171
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/codecs/json.js
|
|
1172
|
+
const textEncoder = new TextEncoder();
|
|
1173
|
+
const textDecoder = new TextDecoder();
|
|
1174
|
+
const json_name = 'json';
|
|
1175
|
+
const code = 0x0200;
|
|
1176
|
+
function json_encode(node) {
|
|
1177
|
+
return textEncoder.encode(JSON.stringify(node));
|
|
1178
|
+
}
|
|
1179
|
+
function json_decode(data) {
|
|
1180
|
+
return JSON.parse(textDecoder.decode(data));
|
|
1181
|
+
}
|
|
1182
|
+
//# sourceMappingURL=json.js.map
|
|
1183
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/codecs/raw.js
|
|
1184
|
+
|
|
1185
|
+
const raw_name = 'raw';
|
|
1186
|
+
const raw_code = 0x55;
|
|
1187
|
+
function raw_encode(node) {
|
|
1188
|
+
return coerce(node);
|
|
1189
|
+
}
|
|
1190
|
+
function raw_decode(data) {
|
|
1191
|
+
return coerce(data);
|
|
1192
|
+
}
|
|
1193
|
+
//# sourceMappingURL=raw.js.map
|
|
1194
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/vendor/varint.js
|
|
1195
|
+
/* eslint-disable */
|
|
1196
|
+
var encode_1 = varint_encode;
|
|
1197
|
+
var MSB = 0x80, REST = 0x7F, MSBALL = ~REST, INT = Math.pow(2, 31);
|
|
1198
|
+
/**
|
|
1199
|
+
* @param {number} num
|
|
1200
|
+
* @param {number[]} out
|
|
1201
|
+
* @param {number} offset
|
|
1202
|
+
*/
|
|
1203
|
+
function varint_encode(num, out, offset) {
|
|
1204
|
+
out = out || [];
|
|
1205
|
+
offset = offset || 0;
|
|
1206
|
+
var oldOffset = offset;
|
|
1207
|
+
while (num >= INT) {
|
|
1208
|
+
out[offset++] = (num & 0xFF) | MSB;
|
|
1209
|
+
num /= 128;
|
|
1210
|
+
}
|
|
1211
|
+
while (num & MSBALL) {
|
|
1212
|
+
out[offset++] = (num & 0xFF) | MSB;
|
|
1213
|
+
num >>>= 7;
|
|
1214
|
+
}
|
|
1215
|
+
out[offset] = num | 0;
|
|
1216
|
+
// @ts-ignore
|
|
1217
|
+
varint_encode.bytes = offset - oldOffset + 1;
|
|
1218
|
+
return out;
|
|
1219
|
+
}
|
|
1220
|
+
var varint_decode = read;
|
|
1221
|
+
var MSB$1 = 0x80, REST$1 = 0x7F;
|
|
1222
|
+
/**
|
|
1223
|
+
* @param {string | any[]} buf
|
|
1224
|
+
* @param {number} offset
|
|
1225
|
+
*/
|
|
1226
|
+
function read(buf, offset) {
|
|
1227
|
+
var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
|
|
1228
|
+
do {
|
|
1229
|
+
if (counter >= l) {
|
|
1230
|
+
// @ts-ignore
|
|
1231
|
+
read.bytes = 0;
|
|
1232
|
+
throw new RangeError('Could not decode varint');
|
|
1233
|
+
}
|
|
1234
|
+
b = buf[counter++];
|
|
1235
|
+
res += shift < 28
|
|
1236
|
+
? (b & REST$1) << shift
|
|
1237
|
+
: (b & REST$1) * Math.pow(2, shift);
|
|
1238
|
+
shift += 7;
|
|
1239
|
+
} while (b >= MSB$1);
|
|
1240
|
+
// @ts-ignore
|
|
1241
|
+
read.bytes = counter - offset;
|
|
1242
|
+
return res;
|
|
1243
|
+
}
|
|
1244
|
+
var N1 = Math.pow(2, 7);
|
|
1245
|
+
var N2 = Math.pow(2, 14);
|
|
1246
|
+
var N3 = Math.pow(2, 21);
|
|
1247
|
+
var N4 = Math.pow(2, 28);
|
|
1248
|
+
var N5 = Math.pow(2, 35);
|
|
1249
|
+
var N6 = Math.pow(2, 42);
|
|
1250
|
+
var N7 = Math.pow(2, 49);
|
|
1251
|
+
var N8 = Math.pow(2, 56);
|
|
1252
|
+
var N9 = Math.pow(2, 63);
|
|
1253
|
+
var varint_length = function (/** @type {number} */ value) {
|
|
1254
|
+
return (value < N1 ? 1
|
|
1255
|
+
: value < N2 ? 2
|
|
1256
|
+
: value < N3 ? 3
|
|
1257
|
+
: value < N4 ? 4
|
|
1258
|
+
: value < N5 ? 5
|
|
1259
|
+
: value < N6 ? 6
|
|
1260
|
+
: value < N7 ? 7
|
|
1261
|
+
: value < N8 ? 8
|
|
1262
|
+
: value < N9 ? 9
|
|
1263
|
+
: 10);
|
|
1264
|
+
};
|
|
1265
|
+
var varint = {
|
|
1266
|
+
encode: encode_1,
|
|
1267
|
+
decode: varint_decode,
|
|
1268
|
+
encodingLength: varint_length
|
|
1269
|
+
};
|
|
1270
|
+
var _brrp_varint = varint;
|
|
1271
|
+
/* harmony default export */ const vendor_varint = (_brrp_varint);
|
|
1272
|
+
//# sourceMappingURL=varint.js.map
|
|
1273
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/varint.js
|
|
1274
|
+
|
|
1275
|
+
function src_varint_decode(data, offset = 0) {
|
|
1276
|
+
const code = vendor_varint.decode(data, offset);
|
|
1277
|
+
return [code, vendor_varint.decode.bytes];
|
|
1278
|
+
}
|
|
1279
|
+
function encodeTo(int, target, offset = 0) {
|
|
1280
|
+
vendor_varint.encode(int, target, offset);
|
|
1281
|
+
return target;
|
|
1282
|
+
}
|
|
1283
|
+
function encodingLength(int) {
|
|
1284
|
+
return vendor_varint.encodingLength(int);
|
|
1285
|
+
}
|
|
1286
|
+
//# sourceMappingURL=varint.js.map
|
|
1287
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/hashes/digest.js
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* Creates a multihash digest.
|
|
1292
|
+
*/
|
|
1293
|
+
function create(code, digest) {
|
|
1294
|
+
const size = digest.byteLength;
|
|
1295
|
+
const sizeOffset = encodingLength(code);
|
|
1296
|
+
const digestOffset = sizeOffset + encodingLength(size);
|
|
1297
|
+
const bytes = new Uint8Array(digestOffset + size);
|
|
1298
|
+
encodeTo(code, bytes, 0);
|
|
1299
|
+
encodeTo(size, bytes, sizeOffset);
|
|
1300
|
+
bytes.set(digest, digestOffset);
|
|
1301
|
+
return new Digest(code, size, digest, bytes);
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Turns bytes representation of multihash digest into an instance.
|
|
1305
|
+
*/
|
|
1306
|
+
function digest_decode(multihash) {
|
|
1307
|
+
const bytes = coerce(multihash);
|
|
1308
|
+
const [code, sizeOffset] = src_varint_decode(bytes);
|
|
1309
|
+
const [size, digestOffset] = src_varint_decode(bytes.subarray(sizeOffset));
|
|
1310
|
+
const digest = bytes.subarray(sizeOffset + digestOffset);
|
|
1311
|
+
if (digest.byteLength !== size) {
|
|
1312
|
+
throw new Error('Incorrect length');
|
|
1313
|
+
}
|
|
1314
|
+
return new Digest(code, size, digest, bytes);
|
|
1315
|
+
}
|
|
1316
|
+
function digest_equals(a, b) {
|
|
1317
|
+
if (a === b) {
|
|
1318
|
+
return true;
|
|
1319
|
+
}
|
|
1320
|
+
else {
|
|
1321
|
+
const data = b;
|
|
1322
|
+
return (a.code === data.code &&
|
|
1323
|
+
a.size === data.size &&
|
|
1324
|
+
data.bytes instanceof Uint8Array &&
|
|
1325
|
+
equals(a.bytes, data.bytes));
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Represents a multihash digest which carries information about the
|
|
1330
|
+
* hashing algorithm and an actual hash digest.
|
|
1331
|
+
*/
|
|
1332
|
+
class Digest {
|
|
1333
|
+
code;
|
|
1334
|
+
size;
|
|
1335
|
+
digest;
|
|
1336
|
+
bytes;
|
|
1337
|
+
/**
|
|
1338
|
+
* Creates a multihash digest.
|
|
1339
|
+
*/
|
|
1340
|
+
constructor(code, size, digest, bytes) {
|
|
1341
|
+
this.code = code;
|
|
1342
|
+
this.size = size;
|
|
1343
|
+
this.digest = digest;
|
|
1344
|
+
this.bytes = bytes;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Used to check that the passed multihash has the passed code
|
|
1349
|
+
*/
|
|
1350
|
+
function hasCode(digest, code) {
|
|
1351
|
+
return digest.code === code;
|
|
1352
|
+
}
|
|
1353
|
+
//# sourceMappingURL=digest.js.map
|
|
1354
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/hashes/identity.js
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
const identity_code = 0x0;
|
|
1358
|
+
const identity_name = 'identity';
|
|
1359
|
+
const identity_encode = coerce;
|
|
1360
|
+
function digest(input) {
|
|
1361
|
+
return create(identity_code, identity_encode(input));
|
|
1362
|
+
}
|
|
1363
|
+
const identity_identity = { code: identity_code, name: identity_name, encode: identity_encode, digest };
|
|
1364
|
+
//# sourceMappingURL=identity.js.map
|
|
1365
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/hashes/hasher.js
|
|
1366
|
+
|
|
1367
|
+
function hasher_from({ name, code, encode }) {
|
|
1368
|
+
return new Hasher(name, code, encode);
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Hasher represents a hashing algorithm implementation that produces as
|
|
1372
|
+
* `MultihashDigest`.
|
|
1373
|
+
*/
|
|
1374
|
+
class Hasher {
|
|
1375
|
+
name;
|
|
1376
|
+
code;
|
|
1377
|
+
encode;
|
|
1378
|
+
constructor(name, code, encode) {
|
|
1379
|
+
this.name = name;
|
|
1380
|
+
this.code = code;
|
|
1381
|
+
this.encode = encode;
|
|
1382
|
+
}
|
|
1383
|
+
digest(input) {
|
|
1384
|
+
if (input instanceof Uint8Array) {
|
|
1385
|
+
const result = this.encode(input);
|
|
1386
|
+
return result instanceof Uint8Array
|
|
1387
|
+
? create(this.code, result)
|
|
1388
|
+
/* c8 ignore next 1 */
|
|
1389
|
+
: result.then(digest => create(this.code, digest));
|
|
1390
|
+
}
|
|
1391
|
+
else {
|
|
1392
|
+
throw Error('Unknown type, must be binary type');
|
|
1393
|
+
/* c8 ignore next 1 */
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
//# sourceMappingURL=hasher.js.map
|
|
1398
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/hashes/sha2-browser.js
|
|
1399
|
+
/* global crypto */
|
|
1400
|
+
|
|
1401
|
+
function sha(name) {
|
|
1402
|
+
return async (data) => new Uint8Array(await crypto.subtle.digest(name, data));
|
|
1403
|
+
}
|
|
1404
|
+
const sha256 = hasher_from({
|
|
1405
|
+
name: 'sha2-256',
|
|
1406
|
+
code: 0x12,
|
|
1407
|
+
encode: sha('SHA-256')
|
|
1408
|
+
});
|
|
1409
|
+
const sha512 = hasher_from({
|
|
1410
|
+
name: 'sha2-512',
|
|
1411
|
+
code: 0x13,
|
|
1412
|
+
encode: sha('SHA-512')
|
|
1413
|
+
});
|
|
1414
|
+
//# sourceMappingURL=sha2-browser.js.map
|
|
1415
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/link/interface.js
|
|
1416
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
|
|
1417
|
+
/* eslint-disable no-use-before-define */
|
|
1418
|
+
|
|
1419
|
+
//# sourceMappingURL=interface.js.map
|
|
1420
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/cid.js
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
// This way TS will also expose all the types from module
|
|
1428
|
+
|
|
1429
|
+
function format(link, base) {
|
|
1430
|
+
const { bytes, version } = link;
|
|
1431
|
+
switch (version) {
|
|
1432
|
+
case 0:
|
|
1433
|
+
return toStringV0(bytes, baseCache(link), base ?? base58btc.encoder);
|
|
1434
|
+
default:
|
|
1435
|
+
return toStringV1(bytes, baseCache(link), (base ?? base32.encoder));
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
function toJSON(link) {
|
|
1439
|
+
return {
|
|
1440
|
+
'/': format(link)
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
function fromJSON(json) {
|
|
1444
|
+
return CID.parse(json['/']);
|
|
1445
|
+
}
|
|
1446
|
+
const cache = new WeakMap();
|
|
1447
|
+
function baseCache(cid) {
|
|
1448
|
+
const baseCache = cache.get(cid);
|
|
1449
|
+
if (baseCache == null) {
|
|
1450
|
+
const baseCache = new Map();
|
|
1451
|
+
cache.set(cid, baseCache);
|
|
1452
|
+
return baseCache;
|
|
1453
|
+
}
|
|
1454
|
+
return baseCache;
|
|
1455
|
+
}
|
|
1456
|
+
class CID {
|
|
1457
|
+
code;
|
|
1458
|
+
version;
|
|
1459
|
+
multihash;
|
|
1460
|
+
bytes;
|
|
1461
|
+
'/';
|
|
1462
|
+
/**
|
|
1463
|
+
* @param version - Version of the CID
|
|
1464
|
+
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
1465
|
+
* @param multihash - (Multi)hash of the of the content.
|
|
1466
|
+
*/
|
|
1467
|
+
constructor(version, code, multihash, bytes) {
|
|
1468
|
+
this.code = code;
|
|
1469
|
+
this.version = version;
|
|
1470
|
+
this.multihash = multihash;
|
|
1471
|
+
this.bytes = bytes;
|
|
1472
|
+
// flag to serializers that this is a CID and
|
|
1473
|
+
// should be treated specially
|
|
1474
|
+
this['/'] = bytes;
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
|
|
1478
|
+
* please either use `CID.asCID(cid)` or switch to new signalling mechanism
|
|
1479
|
+
*
|
|
1480
|
+
* @deprecated
|
|
1481
|
+
*/
|
|
1482
|
+
get asCID() {
|
|
1483
|
+
return this;
|
|
1484
|
+
}
|
|
1485
|
+
// ArrayBufferView
|
|
1486
|
+
get byteOffset() {
|
|
1487
|
+
return this.bytes.byteOffset;
|
|
1488
|
+
}
|
|
1489
|
+
// ArrayBufferView
|
|
1490
|
+
get byteLength() {
|
|
1491
|
+
return this.bytes.byteLength;
|
|
1492
|
+
}
|
|
1493
|
+
toV0() {
|
|
1494
|
+
switch (this.version) {
|
|
1495
|
+
case 0: {
|
|
1496
|
+
return this;
|
|
1497
|
+
}
|
|
1498
|
+
case 1: {
|
|
1499
|
+
const { code, multihash } = this;
|
|
1500
|
+
if (code !== DAG_PB_CODE) {
|
|
1501
|
+
throw new Error('Cannot convert a non dag-pb CID to CIDv0');
|
|
1502
|
+
}
|
|
1503
|
+
// sha2-256
|
|
1504
|
+
if (multihash.code !== SHA_256_CODE) {
|
|
1505
|
+
throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');
|
|
1506
|
+
}
|
|
1507
|
+
return (CID.createV0(multihash));
|
|
1508
|
+
}
|
|
1509
|
+
default: {
|
|
1510
|
+
throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
toV1() {
|
|
1515
|
+
switch (this.version) {
|
|
1516
|
+
case 0: {
|
|
1517
|
+
const { code, digest } = this.multihash;
|
|
1518
|
+
const multihash = create(code, digest);
|
|
1519
|
+
return (CID.createV1(this.code, multihash));
|
|
1520
|
+
}
|
|
1521
|
+
case 1: {
|
|
1522
|
+
return this;
|
|
1523
|
+
}
|
|
1524
|
+
default: {
|
|
1525
|
+
throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
equals(other) {
|
|
1530
|
+
return CID.equals(this, other);
|
|
1531
|
+
}
|
|
1532
|
+
static equals(self, other) {
|
|
1533
|
+
const unknown = other;
|
|
1534
|
+
return (unknown != null &&
|
|
1535
|
+
self.code === unknown.code &&
|
|
1536
|
+
self.version === unknown.version &&
|
|
1537
|
+
digest_equals(self.multihash, unknown.multihash));
|
|
1538
|
+
}
|
|
1539
|
+
toString(base) {
|
|
1540
|
+
return format(this, base);
|
|
1541
|
+
}
|
|
1542
|
+
toJSON() {
|
|
1543
|
+
return { '/': format(this) };
|
|
1544
|
+
}
|
|
1545
|
+
link() {
|
|
1546
|
+
return this;
|
|
1547
|
+
}
|
|
1548
|
+
[Symbol.toStringTag] = 'CID';
|
|
1549
|
+
// Legacy
|
|
1550
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
1551
|
+
return `CID(${this.toString()})`;
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Takes any input `value` and returns a `CID` instance if it was
|
|
1555
|
+
* a `CID` otherwise returns `null`. If `value` is instanceof `CID`
|
|
1556
|
+
* it will return value back. If `value` is not instance of this CID
|
|
1557
|
+
* class, but is compatible CID it will return new instance of this
|
|
1558
|
+
* `CID` class. Otherwise returns null.
|
|
1559
|
+
*
|
|
1560
|
+
* This allows two different incompatible versions of CID library to
|
|
1561
|
+
* co-exist and interop as long as binary interface is compatible.
|
|
1562
|
+
*/
|
|
1563
|
+
static asCID(input) {
|
|
1564
|
+
if (input == null) {
|
|
1565
|
+
return null;
|
|
1566
|
+
}
|
|
1567
|
+
const value = input;
|
|
1568
|
+
if (value instanceof CID) {
|
|
1569
|
+
// If value is instance of CID then we're all set.
|
|
1570
|
+
return value;
|
|
1571
|
+
}
|
|
1572
|
+
else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {
|
|
1573
|
+
// If value isn't instance of this CID class but `this.asCID === this` or
|
|
1574
|
+
// `value['/'] === value.bytes` is true it is CID instance coming from a
|
|
1575
|
+
// different implementation (diff version or duplicate). In that case we
|
|
1576
|
+
// rebase it to this `CID` implementation so caller is guaranteed to get
|
|
1577
|
+
// instance with expected API.
|
|
1578
|
+
const { version, code, multihash, bytes } = value;
|
|
1579
|
+
return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));
|
|
1580
|
+
}
|
|
1581
|
+
else if (value[cidSymbol] === true) {
|
|
1582
|
+
// If value is a CID from older implementation that used to be tagged via
|
|
1583
|
+
// symbol we still rebase it to the this `CID` implementation by
|
|
1584
|
+
// delegating that to a constructor.
|
|
1585
|
+
const { version, multihash, code } = value;
|
|
1586
|
+
const digest = digest_decode(multihash);
|
|
1587
|
+
return CID.create(version, code, digest);
|
|
1588
|
+
}
|
|
1589
|
+
else {
|
|
1590
|
+
// Otherwise value is not a CID (or an incompatible version of it) in
|
|
1591
|
+
// which case we return `null`.
|
|
1592
|
+
return null;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* @param version - Version of the CID
|
|
1597
|
+
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
1598
|
+
* @param digest - (Multi)hash of the of the content.
|
|
1599
|
+
*/
|
|
1600
|
+
static create(version, code, digest) {
|
|
1601
|
+
if (typeof code !== 'number') {
|
|
1602
|
+
throw new Error('String codecs are no longer supported');
|
|
1603
|
+
}
|
|
1604
|
+
if (!(digest.bytes instanceof Uint8Array)) {
|
|
1605
|
+
throw new Error('Invalid digest');
|
|
1606
|
+
}
|
|
1607
|
+
switch (version) {
|
|
1608
|
+
case 0: {
|
|
1609
|
+
if (code !== DAG_PB_CODE) {
|
|
1610
|
+
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
|
|
1611
|
+
}
|
|
1612
|
+
else {
|
|
1613
|
+
return new CID(version, code, digest, digest.bytes);
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
case 1: {
|
|
1617
|
+
const bytes = encodeCID(version, code, digest.bytes);
|
|
1618
|
+
return new CID(version, code, digest, bytes);
|
|
1619
|
+
}
|
|
1620
|
+
default: {
|
|
1621
|
+
throw new Error('Invalid version');
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Simplified version of `create` for CIDv0.
|
|
1627
|
+
*/
|
|
1628
|
+
static createV0(digest) {
|
|
1629
|
+
return CID.create(0, DAG_PB_CODE, digest);
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* Simplified version of `create` for CIDv1.
|
|
1633
|
+
*
|
|
1634
|
+
* @param code - Content encoding format code.
|
|
1635
|
+
* @param digest - Multihash of the content.
|
|
1636
|
+
*/
|
|
1637
|
+
static createV1(code, digest) {
|
|
1638
|
+
return CID.create(1, code, digest);
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Decoded a CID from its binary representation. The byte array must contain
|
|
1642
|
+
* only the CID with no additional bytes.
|
|
1643
|
+
*
|
|
1644
|
+
* An error will be thrown if the bytes provided do not contain a valid
|
|
1645
|
+
* binary representation of a CID.
|
|
1646
|
+
*/
|
|
1647
|
+
static decode(bytes) {
|
|
1648
|
+
const [cid, remainder] = CID.decodeFirst(bytes);
|
|
1649
|
+
if (remainder.length !== 0) {
|
|
1650
|
+
throw new Error('Incorrect length');
|
|
1651
|
+
}
|
|
1652
|
+
return cid;
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Decoded a CID from its binary representation at the beginning of a byte
|
|
1656
|
+
* array.
|
|
1657
|
+
*
|
|
1658
|
+
* Returns an array with the first element containing the CID and the second
|
|
1659
|
+
* element containing the remainder of the original byte array. The remainder
|
|
1660
|
+
* will be a zero-length byte array if the provided bytes only contained a
|
|
1661
|
+
* binary CID representation.
|
|
1662
|
+
*/
|
|
1663
|
+
static decodeFirst(bytes) {
|
|
1664
|
+
const specs = CID.inspectBytes(bytes);
|
|
1665
|
+
const prefixSize = specs.size - specs.multihashSize;
|
|
1666
|
+
const multihashBytes = coerce(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
1667
|
+
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
1668
|
+
throw new Error('Incorrect length');
|
|
1669
|
+
}
|
|
1670
|
+
const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
1671
|
+
const digest = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
|
|
1672
|
+
const cid = specs.version === 0
|
|
1673
|
+
? CID.createV0(digest)
|
|
1674
|
+
: CID.createV1(specs.codec, digest);
|
|
1675
|
+
return [cid, bytes.subarray(specs.size)];
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Inspect the initial bytes of a CID to determine its properties.
|
|
1679
|
+
*
|
|
1680
|
+
* Involves decoding up to 4 varints. Typically this will require only 4 to 6
|
|
1681
|
+
* bytes but for larger multicodec code values and larger multihash digest
|
|
1682
|
+
* lengths these varints can be quite large. It is recommended that at least
|
|
1683
|
+
* 10 bytes be made available in the `initialBytes` argument for a complete
|
|
1684
|
+
* inspection.
|
|
1685
|
+
*/
|
|
1686
|
+
static inspectBytes(initialBytes) {
|
|
1687
|
+
let offset = 0;
|
|
1688
|
+
const next = () => {
|
|
1689
|
+
const [i, length] = src_varint_decode(initialBytes.subarray(offset));
|
|
1690
|
+
offset += length;
|
|
1691
|
+
return i;
|
|
1692
|
+
};
|
|
1693
|
+
let version = next();
|
|
1694
|
+
let codec = DAG_PB_CODE;
|
|
1695
|
+
if (version === 18) {
|
|
1696
|
+
// CIDv0
|
|
1697
|
+
version = 0;
|
|
1698
|
+
offset = 0;
|
|
1699
|
+
}
|
|
1700
|
+
else {
|
|
1701
|
+
codec = next();
|
|
1702
|
+
}
|
|
1703
|
+
if (version !== 0 && version !== 1) {
|
|
1704
|
+
throw new RangeError(`Invalid CID version ${version}`);
|
|
1705
|
+
}
|
|
1706
|
+
const prefixSize = offset;
|
|
1707
|
+
const multihashCode = next(); // multihash code
|
|
1708
|
+
const digestSize = next(); // multihash length
|
|
1709
|
+
const size = offset + digestSize;
|
|
1710
|
+
const multihashSize = size - prefixSize;
|
|
1711
|
+
return { version, codec, multihashCode, digestSize, multihashSize, size };
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Takes cid in a string representation and creates an instance. If `base`
|
|
1715
|
+
* decoder is not provided will use a default from the configuration. It will
|
|
1716
|
+
* throw an error if encoding of the CID is not compatible with supplied (or
|
|
1717
|
+
* a default decoder).
|
|
1718
|
+
*/
|
|
1719
|
+
static parse(source, base) {
|
|
1720
|
+
const [prefix, bytes] = parseCIDtoBytes(source, base);
|
|
1721
|
+
const cid = CID.decode(bytes);
|
|
1722
|
+
if (cid.version === 0 && source[0] !== 'Q') {
|
|
1723
|
+
throw Error('Version 0 CID string must not include multibase prefix');
|
|
1724
|
+
}
|
|
1725
|
+
// Cache string representation to avoid computing it on `this.toString()`
|
|
1726
|
+
baseCache(cid).set(prefix, source);
|
|
1727
|
+
return cid;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
function parseCIDtoBytes(source, base) {
|
|
1731
|
+
switch (source[0]) {
|
|
1732
|
+
// CIDv0 is parsed differently
|
|
1733
|
+
case 'Q': {
|
|
1734
|
+
const decoder = base ?? base58btc;
|
|
1735
|
+
return [
|
|
1736
|
+
base58btc.prefix,
|
|
1737
|
+
decoder.decode(`${base58btc.prefix}${source}`)
|
|
1738
|
+
];
|
|
1739
|
+
}
|
|
1740
|
+
case base58btc.prefix: {
|
|
1741
|
+
const decoder = base ?? base58btc;
|
|
1742
|
+
return [base58btc.prefix, decoder.decode(source)];
|
|
1743
|
+
}
|
|
1744
|
+
case base32.prefix: {
|
|
1745
|
+
const decoder = base ?? base32;
|
|
1746
|
+
return [base32.prefix, decoder.decode(source)];
|
|
1747
|
+
}
|
|
1748
|
+
case base36.prefix: {
|
|
1749
|
+
const decoder = base ?? base36;
|
|
1750
|
+
return [base36.prefix, decoder.decode(source)];
|
|
1751
|
+
}
|
|
1752
|
+
default: {
|
|
1753
|
+
if (base == null) {
|
|
1754
|
+
throw Error('To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided');
|
|
1755
|
+
}
|
|
1756
|
+
return [source[0], base.decode(source)];
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
function toStringV0(bytes, cache, base) {
|
|
1761
|
+
const { prefix } = base;
|
|
1762
|
+
if (prefix !== base58btc.prefix) {
|
|
1763
|
+
throw Error(`Cannot string encode V0 in ${base.name} encoding`);
|
|
1764
|
+
}
|
|
1765
|
+
const cid = cache.get(prefix);
|
|
1766
|
+
if (cid == null) {
|
|
1767
|
+
const cid = base.encode(bytes).slice(1);
|
|
1768
|
+
cache.set(prefix, cid);
|
|
1769
|
+
return cid;
|
|
1770
|
+
}
|
|
1771
|
+
else {
|
|
1772
|
+
return cid;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
function toStringV1(bytes, cache, base) {
|
|
1776
|
+
const { prefix } = base;
|
|
1777
|
+
const cid = cache.get(prefix);
|
|
1778
|
+
if (cid == null) {
|
|
1779
|
+
const cid = base.encode(bytes);
|
|
1780
|
+
cache.set(prefix, cid);
|
|
1781
|
+
return cid;
|
|
1782
|
+
}
|
|
1783
|
+
else {
|
|
1784
|
+
return cid;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
const DAG_PB_CODE = 0x70;
|
|
1788
|
+
const SHA_256_CODE = 0x12;
|
|
1789
|
+
function encodeCID(version, code, multihash) {
|
|
1790
|
+
const codeOffset = encodingLength(version);
|
|
1791
|
+
const hashOffset = codeOffset + encodingLength(code);
|
|
1792
|
+
const bytes = new Uint8Array(hashOffset + multihash.byteLength);
|
|
1793
|
+
encodeTo(version, bytes, 0);
|
|
1794
|
+
encodeTo(code, bytes, codeOffset);
|
|
1795
|
+
bytes.set(multihash, hashOffset);
|
|
1796
|
+
return bytes;
|
|
1797
|
+
}
|
|
1798
|
+
const cidSymbol = Symbol.for('@ipld/js-cid/CID');
|
|
1799
|
+
//# sourceMappingURL=cid.js.map
|
|
1800
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/bases/interface.js
|
|
1801
|
+
// Base encoders / decoders just base encode / decode between binary and
|
|
1802
|
+
// textual representation. They are unaware of multibase.
|
|
1803
|
+
|
|
1804
|
+
//# sourceMappingURL=interface.js.map
|
|
1805
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/hashes/interface.js
|
|
1806
|
+
// # Multihash
|
|
1807
|
+
|
|
1808
|
+
//# sourceMappingURL=interface.js.map
|
|
1809
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/codecs/interface.js
|
|
1810
|
+
|
|
1811
|
+
//# sourceMappingURL=interface.js.map
|
|
1812
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/block/interface.js
|
|
1813
|
+
|
|
1814
|
+
//# sourceMappingURL=interface.js.map
|
|
1815
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/interface.js
|
|
1816
|
+
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
|
|
1821
|
+
//# sourceMappingURL=interface.js.map
|
|
1822
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/index.js
|
|
1823
|
+
/**
|
|
1824
|
+
* @packageDocumentation
|
|
1825
|
+
*
|
|
1826
|
+
* 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.
|
|
1827
|
+
*
|
|
1828
|
+
* This library provides implementations for most basics and many others can be found in linked repositories.
|
|
1829
|
+
*
|
|
1830
|
+
* ```TypeScript
|
|
1831
|
+
* import { CID } from 'multiformats/cid'
|
|
1832
|
+
* import * as json from 'multiformats/codecs/json'
|
|
1833
|
+
* import { sha256 } from 'multiformats/hashes/sha2'
|
|
1834
|
+
*
|
|
1835
|
+
* const bytes = json.encode({ hello: 'world' })
|
|
1836
|
+
*
|
|
1837
|
+
* const hash = await sha256.digest(bytes)
|
|
1838
|
+
* const cid = CID.create(1, json.code, hash)
|
|
1839
|
+
* //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
|
|
1840
|
+
* ```
|
|
1841
|
+
*
|
|
1842
|
+
* ## Creating Blocks
|
|
1843
|
+
*
|
|
1844
|
+
* ```TypeScript
|
|
1845
|
+
* import * as Block from 'multiformats/block'
|
|
1846
|
+
* import * as codec from '@ipld/dag-cbor'
|
|
1847
|
+
* import { sha256 as hasher } from 'multiformats/hashes/sha2'
|
|
1848
|
+
*
|
|
1849
|
+
* const value = { hello: 'world' }
|
|
1850
|
+
*
|
|
1851
|
+
* // encode a block
|
|
1852
|
+
* let block = await Block.encode({ value, codec, hasher })
|
|
1853
|
+
*
|
|
1854
|
+
* block.value // { hello: 'world' }
|
|
1855
|
+
* block.bytes // Uint8Array
|
|
1856
|
+
* block.cid // CID() w/ sha2-256 hash address and dag-cbor codec
|
|
1857
|
+
*
|
|
1858
|
+
* // you can also decode blocks from their binary state
|
|
1859
|
+
* block = await Block.decode({ bytes: block.bytes, codec, hasher })
|
|
1860
|
+
*
|
|
1861
|
+
* // if you have the cid you can also verify the hash on decode
|
|
1862
|
+
* block = await Block.create({ bytes: block.bytes, cid: block.cid, codec, hasher })
|
|
1863
|
+
* ```
|
|
1864
|
+
*
|
|
1865
|
+
* ## Multibase Encoders / Decoders / Codecs
|
|
1866
|
+
*
|
|
1867
|
+
* 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:
|
|
1868
|
+
*
|
|
1869
|
+
* ```TypeScript
|
|
1870
|
+
* import { base64 } from "multiformats/bases/base64"
|
|
1871
|
+
* cid.toString(base64.encoder)
|
|
1872
|
+
* //> 'mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA'
|
|
1873
|
+
* ```
|
|
1874
|
+
*
|
|
1875
|
+
* 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:
|
|
1876
|
+
*
|
|
1877
|
+
* ```TypeScript
|
|
1878
|
+
* CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)
|
|
1879
|
+
* //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
|
|
1880
|
+
* ```
|
|
1881
|
+
*
|
|
1882
|
+
* Dual of multibase encoder & decoder is defined as multibase codec and it exposes
|
|
1883
|
+
* them as `encoder` and `decoder` properties. For added convenience codecs also
|
|
1884
|
+
* implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be
|
|
1885
|
+
* used as either or both:
|
|
1886
|
+
*
|
|
1887
|
+
* ```TypeScript
|
|
1888
|
+
* cid.toString(base64)
|
|
1889
|
+
* CID.parse(cid.toString(base64), base64)
|
|
1890
|
+
* ```
|
|
1891
|
+
*
|
|
1892
|
+
* **Note:** CID implementation comes bundled with `base32` and `base58btc`
|
|
1893
|
+
* multibase codecs so that CIDs can be base serialized to (version specific)
|
|
1894
|
+
* default base encoding and parsed without having to supply base encoders/decoders:
|
|
1895
|
+
*
|
|
1896
|
+
* ```TypeScript
|
|
1897
|
+
* const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')
|
|
1898
|
+
* v1.toString()
|
|
1899
|
+
* //> 'bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea'
|
|
1900
|
+
*
|
|
1901
|
+
* const v0 = CID.parse('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n')
|
|
1902
|
+
* v0.toString()
|
|
1903
|
+
* //> 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'
|
|
1904
|
+
* v0.toV1().toString()
|
|
1905
|
+
* //> 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'
|
|
1906
|
+
* ```
|
|
1907
|
+
*
|
|
1908
|
+
* ## Multicodec Encoders / Decoders / Codecs
|
|
1909
|
+
*
|
|
1910
|
+
* This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).
|
|
1911
|
+
* Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.
|
|
1912
|
+
* Here is an example implementation of JSON `BlockCodec`.
|
|
1913
|
+
*
|
|
1914
|
+
* ```TypeScript
|
|
1915
|
+
* export const { name, code, encode, decode } = {
|
|
1916
|
+
* name: 'json',
|
|
1917
|
+
* code: 0x0200,
|
|
1918
|
+
* encode: json => new TextEncoder().encode(JSON.stringify(json)),
|
|
1919
|
+
* decode: bytes => JSON.parse(new TextDecoder().decode(bytes))
|
|
1920
|
+
* }
|
|
1921
|
+
* ```
|
|
1922
|
+
*
|
|
1923
|
+
* ## Multihash Hashers
|
|
1924
|
+
*
|
|
1925
|
+
* 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:
|
|
1926
|
+
*
|
|
1927
|
+
* ```TypeScript
|
|
1928
|
+
* import * as hasher from 'multiformats/hashes/hasher'
|
|
1929
|
+
*
|
|
1930
|
+
* const sha256 = hasher.from({
|
|
1931
|
+
* // As per multiformats table
|
|
1932
|
+
* // https://github.com/multiformats/multicodec/blob/master/table.csv#L9
|
|
1933
|
+
* name: 'sha2-256',
|
|
1934
|
+
* code: 0x12,
|
|
1935
|
+
*
|
|
1936
|
+
* encode: (input) => new Uint8Array(crypto.createHash('sha256').update(input).digest())
|
|
1937
|
+
* })
|
|
1938
|
+
*
|
|
1939
|
+
* const hash = await sha256.digest(json.encode({ hello: 'world' }))
|
|
1940
|
+
* CID.create(1, json.code, hash)
|
|
1941
|
+
*
|
|
1942
|
+
* //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
|
|
1943
|
+
* ```
|
|
1944
|
+
*
|
|
1945
|
+
* ## Traversal
|
|
1946
|
+
*
|
|
1947
|
+
* This library contains higher-order functions for traversing graphs of data easily.
|
|
1948
|
+
*
|
|
1949
|
+
* `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()`.
|
|
1950
|
+
*
|
|
1951
|
+
* ```TypeScript
|
|
1952
|
+
* import { walk } from 'multiformats/traversal'
|
|
1953
|
+
* import * as Block from 'multiformats/block'
|
|
1954
|
+
* import * as codec from 'multiformats/codecs/json'
|
|
1955
|
+
* import { sha256 as hasher } from 'multiformats/hashes/sha2'
|
|
1956
|
+
*
|
|
1957
|
+
* // build a DAG (a single block for this simple example)
|
|
1958
|
+
* const value = { hello: 'world' }
|
|
1959
|
+
* const block = await Block.encode({ value, codec, hasher })
|
|
1960
|
+
* const { cid } = block
|
|
1961
|
+
* console.log(cid)
|
|
1962
|
+
* //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
|
|
1963
|
+
*
|
|
1964
|
+
* // create a loader function that also collects CIDs of blocks in
|
|
1965
|
+
* // their traversal order
|
|
1966
|
+
* const load = (cid, blocks) => async (cid) => {
|
|
1967
|
+
* // fetch a block using its cid
|
|
1968
|
+
* // e.g.: const block = await fetchBlockByCID(cid)
|
|
1969
|
+
* blocks.push(cid)
|
|
1970
|
+
* return block
|
|
1971
|
+
* }
|
|
1972
|
+
*
|
|
1973
|
+
* // collect blocks in this DAG starting from the root `cid`
|
|
1974
|
+
* const blocks = []
|
|
1975
|
+
* await walk({ cid, load: load(cid, blocks) })
|
|
1976
|
+
*
|
|
1977
|
+
* console.log(blocks)
|
|
1978
|
+
* //> [CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)]
|
|
1979
|
+
* ```
|
|
1980
|
+
*
|
|
1981
|
+
* ## Legacy interface
|
|
1982
|
+
*
|
|
1983
|
+
* [`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
|
|
1984
|
+
* [`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.
|
|
1985
|
+
*
|
|
1986
|
+
* ## Implementations
|
|
1987
|
+
*
|
|
1988
|
+
* By default, no base encodings (other than base32 & base58btc), hash functions,
|
|
1989
|
+
* or codec implementations are exposed by `multiformats`, you need to
|
|
1990
|
+
* import the ones you need yourself.
|
|
1991
|
+
*
|
|
1992
|
+
* ### Multibase codecs
|
|
1993
|
+
*
|
|
1994
|
+
* | bases | import | repo |
|
|
1995
|
+
* | ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
1996
|
+
* | `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
|
|
1997
|
+
* | `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
|
|
1998
|
+
* | `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
|
|
1999
|
+
* | `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
|
|
2000
|
+
*
|
|
2001
|
+
* 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`.
|
|
2002
|
+
*
|
|
2003
|
+
* ### Multihash hashers
|
|
2004
|
+
*
|
|
2005
|
+
* | hashes | import | repo |
|
|
2006
|
+
* | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
|
|
2007
|
+
* | `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) |
|
|
2008
|
+
* | `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) |
|
|
2009
|
+
* | `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) |
|
|
2010
|
+
* | `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) |
|
|
2011
|
+
* | `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) |
|
|
2012
|
+
*
|
|
2013
|
+
* ### IPLD codecs (multicodec)
|
|
2014
|
+
*
|
|
2015
|
+
* | codec | import | repo |
|
|
2016
|
+
* | ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
2017
|
+
* | `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |
|
|
2018
|
+
* | `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |
|
|
2019
|
+
* | `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) |
|
|
2020
|
+
* | `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) |
|
|
2021
|
+
* | `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) |
|
|
2022
|
+
* | `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) |
|
|
2023
|
+
*/
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
|
|
2027
|
+
|
|
2028
|
+
|
|
2029
|
+
// This way TS will also expose all the types from module
|
|
2030
|
+
|
|
2031
|
+
|
|
2032
|
+
//# sourceMappingURL=index.js.map
|
|
2033
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/node_modules/multiformats/dist/src/basics.js
|
|
2034
|
+
|
|
2035
|
+
|
|
2036
|
+
|
|
2037
|
+
|
|
2038
|
+
|
|
2039
|
+
|
|
2040
|
+
|
|
2041
|
+
|
|
2042
|
+
|
|
2043
|
+
|
|
2044
|
+
|
|
2045
|
+
|
|
2046
|
+
|
|
2047
|
+
|
|
2048
|
+
|
|
2049
|
+
const bases = { ...identity_namespaceObject, ...base2_namespaceObject, ...base8_namespaceObject, ...base10_namespaceObject, ...base16_namespaceObject, ...base32_namespaceObject, ...base36_namespaceObject, ...base58_namespaceObject, ...base64_namespaceObject, ...base256emoji_namespaceObject };
|
|
2050
|
+
const hashes = { ...sha2_browser_namespaceObject, ...hashes_identity_namespaceObject };
|
|
2051
|
+
const codecs = { raw: raw_namespaceObject, json: json_namespaceObject };
|
|
2052
|
+
|
|
2053
|
+
//# sourceMappingURL=basics.js.map
|
|
2054
|
+
// EXTERNAL MODULE: ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/alloc.js
|
|
2055
|
+
var alloc = __webpack_require__("./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/alloc.js");
|
|
2056
|
+
;// ./node_modules/shogun-ipfs/node_modules/uint8arrays/dist/src/util/bases.js
|
|
2057
|
+
|
|
2058
|
+
|
|
2059
|
+
function createCodec(name, prefix, encode, decode) {
|
|
2060
|
+
return {
|
|
2061
|
+
name,
|
|
2062
|
+
prefix,
|
|
2063
|
+
encoder: {
|
|
2064
|
+
name,
|
|
2065
|
+
prefix,
|
|
2066
|
+
encode
|
|
2067
|
+
},
|
|
2068
|
+
decoder: {
|
|
2069
|
+
decode
|
|
2070
|
+
}
|
|
2071
|
+
};
|
|
2072
|
+
}
|
|
2073
|
+
const string = createCodec('utf8', 'u', (buf) => {
|
|
2074
|
+
const decoder = new TextDecoder('utf8');
|
|
2075
|
+
return 'u' + decoder.decode(buf);
|
|
2076
|
+
}, (str) => {
|
|
2077
|
+
const encoder = new TextEncoder();
|
|
2078
|
+
return encoder.encode(str.substring(1));
|
|
2079
|
+
});
|
|
2080
|
+
const ascii = createCodec('ascii', 'a', (buf) => {
|
|
2081
|
+
let string = 'a';
|
|
2082
|
+
for (let i = 0; i < buf.length; i++) {
|
|
2083
|
+
string += String.fromCharCode(buf[i]);
|
|
2084
|
+
}
|
|
2085
|
+
return string;
|
|
2086
|
+
}, (str) => {
|
|
2087
|
+
str = str.substring(1);
|
|
2088
|
+
const buf = (0,alloc.allocUnsafe)(str.length);
|
|
2089
|
+
for (let i = 0; i < str.length; i++) {
|
|
2090
|
+
buf[i] = str.charCodeAt(i);
|
|
2091
|
+
}
|
|
2092
|
+
return buf;
|
|
2093
|
+
});
|
|
2094
|
+
const BASES = {
|
|
2095
|
+
utf8: string,
|
|
2096
|
+
'utf-8': string,
|
|
2097
|
+
hex: bases.base16,
|
|
2098
|
+
latin1: ascii,
|
|
2099
|
+
ascii,
|
|
2100
|
+
binary: ascii,
|
|
2101
|
+
...bases
|
|
2102
|
+
};
|
|
2103
|
+
/* harmony default export */ const util_bases = (BASES);
|
|
2104
|
+
//# sourceMappingURL=bases.js.map
|
|
2105
|
+
|
|
2106
|
+
/***/ })
|
|
2107
|
+
|
|
2108
|
+
}]);
|
|
2109
|
+
//# sourceMappingURL=defaultVendors-node_modules_shogun-ipfs_node_modules_uint8-varint_dist_src_index_js-node_modu-0db5ba.shogun-core.js.map
|