@leofcoin/peernet 0.12.3 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -141,17 +141,17 @@ const base = ALPHABET => {
141
141
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base32/src/base32.js
142
142
 
143
143
 
144
- const base32_base32 = 'abcdefghijklmnopqrstuvwxyz234567'
144
+ const base32 = 'abcdefghijklmnopqrstuvwxyz234567'
145
145
  const base32Hex = '0123456789abcdefghijklmnopqrstuv'
146
146
 
147
147
  const decode = (uint8Array, hex = false) => {
148
- const decoder = hex ? base_x(base32Hex) : base_x(base32_base32)
148
+ const decoder = hex ? base_x(base32Hex) : base_x(base32)
149
149
  return decoder.decode(uint8Array)
150
150
  }
151
151
 
152
152
  /* harmony default export */ var src_base32 = ({
153
153
  encode: (uint8Array, hex = false) => {
154
- const encoder = hex ? base_x(base32Hex) : base_x(base32_base32)
154
+ const encoder = hex ? base_x(base32Hex) : base_x(base32)
155
155
  return encoder.encode(uint8Array)
156
156
  },
157
157
  decode,
@@ -168,12 +168,12 @@ const decode = (uint8Array, hex = false) => {
168
168
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base58/src/base58.js
169
169
 
170
170
 
171
- const base58_base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
171
+ const base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
172
172
 
173
- const base58_decode = uint8Array => base_x(base58_base58).decode(uint8Array)
173
+ const base58_decode = uint8Array => base_x(base58).decode(uint8Array)
174
174
 
175
175
  /* harmony default export */ var src_base58 = ({
176
- encode: uint8Array => base_x(base58_base58).encode(uint8Array),
176
+ encode: uint8Array => base_x(base58).encode(uint8Array),
177
177
  decode: base58_decode,
178
178
  isBase58: uint8Array => {
179
179
  try {
@@ -208,10 +208,10 @@ class BasicInterface {
208
208
  return is_hex(string)
209
209
  }
210
210
  isBase32(string) {
211
- return base32.isBase32(string)
211
+ return src_base32.isBase32(string)
212
212
  }
213
213
  isBase58(string) {
214
- return base58.isBase32(string)
214
+ return src_base58.isBase58(string)
215
215
  }
216
216
  /**
217
217
  * @param {String} encoded
@@ -396,6 +396,14 @@ var varint_default = /*#__PURE__*/__webpack_require__.n(varint);
396
396
  codec: parseInt('636d', 16),
397
397
  hashAlg: 'dbl-keccak-256',
398
398
  },
399
+ 'peernet-file' : {
400
+ codec: parseInt('7066', 16),
401
+ hashAlg: 'keccak-256',
402
+ },
403
+ 'peernet-file-response' : {
404
+ codec: parseInt('706672', 16),
405
+ hashAlg: 'keccak-256',
406
+ }
399
407
  });
400
408
 
401
409
  ;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codec.js
@@ -4176,6 +4184,543 @@ exports.Headers = global.Headers;
4176
4184
  exports.Request = global.Request;
4177
4185
  exports.Response = global.Response;
4178
4186
 
4187
+ /***/ }),
4188
+
4189
+ /***/ 6470:
4190
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
4191
+
4192
+ /* provided dependency */ var process = __webpack_require__(4406);
4193
+ // 'path' module extracted from Node.js v8.11.1 (only the posix part)
4194
+ // transplited with Babel
4195
+
4196
+ // Copyright Joyent, Inc. and other Node contributors.
4197
+ //
4198
+ // Permission is hereby granted, free of charge, to any person obtaining a
4199
+ // copy of this software and associated documentation files (the
4200
+ // "Software"), to deal in the Software without restriction, including
4201
+ // without limitation the rights to use, copy, modify, merge, publish,
4202
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
4203
+ // persons to whom the Software is furnished to do so, subject to the
4204
+ // following conditions:
4205
+ //
4206
+ // The above copyright notice and this permission notice shall be included
4207
+ // in all copies or substantial portions of the Software.
4208
+ //
4209
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
4210
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4211
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
4212
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
4213
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
4214
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
4215
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
4216
+
4217
+
4218
+
4219
+ function assertPath(path) {
4220
+ if (typeof path !== 'string') {
4221
+ throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
4222
+ }
4223
+ }
4224
+
4225
+ // Resolves . and .. elements in a path with directory names
4226
+ function normalizeStringPosix(path, allowAboveRoot) {
4227
+ var res = '';
4228
+ var lastSegmentLength = 0;
4229
+ var lastSlash = -1;
4230
+ var dots = 0;
4231
+ var code;
4232
+ for (var i = 0; i <= path.length; ++i) {
4233
+ if (i < path.length)
4234
+ code = path.charCodeAt(i);
4235
+ else if (code === 47 /*/*/)
4236
+ break;
4237
+ else
4238
+ code = 47 /*/*/;
4239
+ if (code === 47 /*/*/) {
4240
+ if (lastSlash === i - 1 || dots === 1) {
4241
+ // NOOP
4242
+ } else if (lastSlash !== i - 1 && dots === 2) {
4243
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
4244
+ if (res.length > 2) {
4245
+ var lastSlashIndex = res.lastIndexOf('/');
4246
+ if (lastSlashIndex !== res.length - 1) {
4247
+ if (lastSlashIndex === -1) {
4248
+ res = '';
4249
+ lastSegmentLength = 0;
4250
+ } else {
4251
+ res = res.slice(0, lastSlashIndex);
4252
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
4253
+ }
4254
+ lastSlash = i;
4255
+ dots = 0;
4256
+ continue;
4257
+ }
4258
+ } else if (res.length === 2 || res.length === 1) {
4259
+ res = '';
4260
+ lastSegmentLength = 0;
4261
+ lastSlash = i;
4262
+ dots = 0;
4263
+ continue;
4264
+ }
4265
+ }
4266
+ if (allowAboveRoot) {
4267
+ if (res.length > 0)
4268
+ res += '/..';
4269
+ else
4270
+ res = '..';
4271
+ lastSegmentLength = 2;
4272
+ }
4273
+ } else {
4274
+ if (res.length > 0)
4275
+ res += '/' + path.slice(lastSlash + 1, i);
4276
+ else
4277
+ res = path.slice(lastSlash + 1, i);
4278
+ lastSegmentLength = i - lastSlash - 1;
4279
+ }
4280
+ lastSlash = i;
4281
+ dots = 0;
4282
+ } else if (code === 46 /*.*/ && dots !== -1) {
4283
+ ++dots;
4284
+ } else {
4285
+ dots = -1;
4286
+ }
4287
+ }
4288
+ return res;
4289
+ }
4290
+
4291
+ function _format(sep, pathObject) {
4292
+ var dir = pathObject.dir || pathObject.root;
4293
+ var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
4294
+ if (!dir) {
4295
+ return base;
4296
+ }
4297
+ if (dir === pathObject.root) {
4298
+ return dir + base;
4299
+ }
4300
+ return dir + sep + base;
4301
+ }
4302
+
4303
+ var posix = {
4304
+ // path.resolve([from ...], to)
4305
+ resolve: function resolve() {
4306
+ var resolvedPath = '';
4307
+ var resolvedAbsolute = false;
4308
+ var cwd;
4309
+
4310
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
4311
+ var path;
4312
+ if (i >= 0)
4313
+ path = arguments[i];
4314
+ else {
4315
+ if (cwd === undefined)
4316
+ cwd = process.cwd();
4317
+ path = cwd;
4318
+ }
4319
+
4320
+ assertPath(path);
4321
+
4322
+ // Skip empty entries
4323
+ if (path.length === 0) {
4324
+ continue;
4325
+ }
4326
+
4327
+ resolvedPath = path + '/' + resolvedPath;
4328
+ resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
4329
+ }
4330
+
4331
+ // At this point the path should be resolved to a full absolute path, but
4332
+ // handle relative paths to be safe (might happen when process.cwd() fails)
4333
+
4334
+ // Normalize the path
4335
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
4336
+
4337
+ if (resolvedAbsolute) {
4338
+ if (resolvedPath.length > 0)
4339
+ return '/' + resolvedPath;
4340
+ else
4341
+ return '/';
4342
+ } else if (resolvedPath.length > 0) {
4343
+ return resolvedPath;
4344
+ } else {
4345
+ return '.';
4346
+ }
4347
+ },
4348
+
4349
+ normalize: function normalize(path) {
4350
+ assertPath(path);
4351
+
4352
+ if (path.length === 0) return '.';
4353
+
4354
+ var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
4355
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
4356
+
4357
+ // Normalize the path
4358
+ path = normalizeStringPosix(path, !isAbsolute);
4359
+
4360
+ if (path.length === 0 && !isAbsolute) path = '.';
4361
+ if (path.length > 0 && trailingSeparator) path += '/';
4362
+
4363
+ if (isAbsolute) return '/' + path;
4364
+ return path;
4365
+ },
4366
+
4367
+ isAbsolute: function isAbsolute(path) {
4368
+ assertPath(path);
4369
+ return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
4370
+ },
4371
+
4372
+ join: function join() {
4373
+ if (arguments.length === 0)
4374
+ return '.';
4375
+ var joined;
4376
+ for (var i = 0; i < arguments.length; ++i) {
4377
+ var arg = arguments[i];
4378
+ assertPath(arg);
4379
+ if (arg.length > 0) {
4380
+ if (joined === undefined)
4381
+ joined = arg;
4382
+ else
4383
+ joined += '/' + arg;
4384
+ }
4385
+ }
4386
+ if (joined === undefined)
4387
+ return '.';
4388
+ return posix.normalize(joined);
4389
+ },
4390
+
4391
+ relative: function relative(from, to) {
4392
+ assertPath(from);
4393
+ assertPath(to);
4394
+
4395
+ if (from === to) return '';
4396
+
4397
+ from = posix.resolve(from);
4398
+ to = posix.resolve(to);
4399
+
4400
+ if (from === to) return '';
4401
+
4402
+ // Trim any leading backslashes
4403
+ var fromStart = 1;
4404
+ for (; fromStart < from.length; ++fromStart) {
4405
+ if (from.charCodeAt(fromStart) !== 47 /*/*/)
4406
+ break;
4407
+ }
4408
+ var fromEnd = from.length;
4409
+ var fromLen = fromEnd - fromStart;
4410
+
4411
+ // Trim any leading backslashes
4412
+ var toStart = 1;
4413
+ for (; toStart < to.length; ++toStart) {
4414
+ if (to.charCodeAt(toStart) !== 47 /*/*/)
4415
+ break;
4416
+ }
4417
+ var toEnd = to.length;
4418
+ var toLen = toEnd - toStart;
4419
+
4420
+ // Compare paths to find the longest common path from root
4421
+ var length = fromLen < toLen ? fromLen : toLen;
4422
+ var lastCommonSep = -1;
4423
+ var i = 0;
4424
+ for (; i <= length; ++i) {
4425
+ if (i === length) {
4426
+ if (toLen > length) {
4427
+ if (to.charCodeAt(toStart + i) === 47 /*/*/) {
4428
+ // We get here if `from` is the exact base path for `to`.
4429
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
4430
+ return to.slice(toStart + i + 1);
4431
+ } else if (i === 0) {
4432
+ // We get here if `from` is the root
4433
+ // For example: from='/'; to='/foo'
4434
+ return to.slice(toStart + i);
4435
+ }
4436
+ } else if (fromLen > length) {
4437
+ if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
4438
+ // We get here if `to` is the exact base path for `from`.
4439
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
4440
+ lastCommonSep = i;
4441
+ } else if (i === 0) {
4442
+ // We get here if `to` is the root.
4443
+ // For example: from='/foo'; to='/'
4444
+ lastCommonSep = 0;
4445
+ }
4446
+ }
4447
+ break;
4448
+ }
4449
+ var fromCode = from.charCodeAt(fromStart + i);
4450
+ var toCode = to.charCodeAt(toStart + i);
4451
+ if (fromCode !== toCode)
4452
+ break;
4453
+ else if (fromCode === 47 /*/*/)
4454
+ lastCommonSep = i;
4455
+ }
4456
+
4457
+ var out = '';
4458
+ // Generate the relative path based on the path difference between `to`
4459
+ // and `from`
4460
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
4461
+ if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
4462
+ if (out.length === 0)
4463
+ out += '..';
4464
+ else
4465
+ out += '/..';
4466
+ }
4467
+ }
4468
+
4469
+ // Lastly, append the rest of the destination (`to`) path that comes after
4470
+ // the common path parts
4471
+ if (out.length > 0)
4472
+ return out + to.slice(toStart + lastCommonSep);
4473
+ else {
4474
+ toStart += lastCommonSep;
4475
+ if (to.charCodeAt(toStart) === 47 /*/*/)
4476
+ ++toStart;
4477
+ return to.slice(toStart);
4478
+ }
4479
+ },
4480
+
4481
+ _makeLong: function _makeLong(path) {
4482
+ return path;
4483
+ },
4484
+
4485
+ dirname: function dirname(path) {
4486
+ assertPath(path);
4487
+ if (path.length === 0) return '.';
4488
+ var code = path.charCodeAt(0);
4489
+ var hasRoot = code === 47 /*/*/;
4490
+ var end = -1;
4491
+ var matchedSlash = true;
4492
+ for (var i = path.length - 1; i >= 1; --i) {
4493
+ code = path.charCodeAt(i);
4494
+ if (code === 47 /*/*/) {
4495
+ if (!matchedSlash) {
4496
+ end = i;
4497
+ break;
4498
+ }
4499
+ } else {
4500
+ // We saw the first non-path separator
4501
+ matchedSlash = false;
4502
+ }
4503
+ }
4504
+
4505
+ if (end === -1) return hasRoot ? '/' : '.';
4506
+ if (hasRoot && end === 1) return '//';
4507
+ return path.slice(0, end);
4508
+ },
4509
+
4510
+ basename: function basename(path, ext) {
4511
+ if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
4512
+ assertPath(path);
4513
+
4514
+ var start = 0;
4515
+ var end = -1;
4516
+ var matchedSlash = true;
4517
+ var i;
4518
+
4519
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
4520
+ if (ext.length === path.length && ext === path) return '';
4521
+ var extIdx = ext.length - 1;
4522
+ var firstNonSlashEnd = -1;
4523
+ for (i = path.length - 1; i >= 0; --i) {
4524
+ var code = path.charCodeAt(i);
4525
+ if (code === 47 /*/*/) {
4526
+ // If we reached a path separator that was not part of a set of path
4527
+ // separators at the end of the string, stop now
4528
+ if (!matchedSlash) {
4529
+ start = i + 1;
4530
+ break;
4531
+ }
4532
+ } else {
4533
+ if (firstNonSlashEnd === -1) {
4534
+ // We saw the first non-path separator, remember this index in case
4535
+ // we need it if the extension ends up not matching
4536
+ matchedSlash = false;
4537
+ firstNonSlashEnd = i + 1;
4538
+ }
4539
+ if (extIdx >= 0) {
4540
+ // Try to match the explicit extension
4541
+ if (code === ext.charCodeAt(extIdx)) {
4542
+ if (--extIdx === -1) {
4543
+ // We matched the extension, so mark this as the end of our path
4544
+ // component
4545
+ end = i;
4546
+ }
4547
+ } else {
4548
+ // Extension does not match, so our result is the entire path
4549
+ // component
4550
+ extIdx = -1;
4551
+ end = firstNonSlashEnd;
4552
+ }
4553
+ }
4554
+ }
4555
+ }
4556
+
4557
+ if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
4558
+ return path.slice(start, end);
4559
+ } else {
4560
+ for (i = path.length - 1; i >= 0; --i) {
4561
+ if (path.charCodeAt(i) === 47 /*/*/) {
4562
+ // If we reached a path separator that was not part of a set of path
4563
+ // separators at the end of the string, stop now
4564
+ if (!matchedSlash) {
4565
+ start = i + 1;
4566
+ break;
4567
+ }
4568
+ } else if (end === -1) {
4569
+ // We saw the first non-path separator, mark this as the end of our
4570
+ // path component
4571
+ matchedSlash = false;
4572
+ end = i + 1;
4573
+ }
4574
+ }
4575
+
4576
+ if (end === -1) return '';
4577
+ return path.slice(start, end);
4578
+ }
4579
+ },
4580
+
4581
+ extname: function extname(path) {
4582
+ assertPath(path);
4583
+ var startDot = -1;
4584
+ var startPart = 0;
4585
+ var end = -1;
4586
+ var matchedSlash = true;
4587
+ // Track the state of characters (if any) we see before our first dot and
4588
+ // after any path separator we find
4589
+ var preDotState = 0;
4590
+ for (var i = path.length - 1; i >= 0; --i) {
4591
+ var code = path.charCodeAt(i);
4592
+ if (code === 47 /*/*/) {
4593
+ // If we reached a path separator that was not part of a set of path
4594
+ // separators at the end of the string, stop now
4595
+ if (!matchedSlash) {
4596
+ startPart = i + 1;
4597
+ break;
4598
+ }
4599
+ continue;
4600
+ }
4601
+ if (end === -1) {
4602
+ // We saw the first non-path separator, mark this as the end of our
4603
+ // extension
4604
+ matchedSlash = false;
4605
+ end = i + 1;
4606
+ }
4607
+ if (code === 46 /*.*/) {
4608
+ // If this is our first dot, mark it as the start of our extension
4609
+ if (startDot === -1)
4610
+ startDot = i;
4611
+ else if (preDotState !== 1)
4612
+ preDotState = 1;
4613
+ } else if (startDot !== -1) {
4614
+ // We saw a non-dot and non-path separator before our dot, so we should
4615
+ // have a good chance at having a non-empty extension
4616
+ preDotState = -1;
4617
+ }
4618
+ }
4619
+
4620
+ if (startDot === -1 || end === -1 ||
4621
+ // We saw a non-dot character immediately before the dot
4622
+ preDotState === 0 ||
4623
+ // The (right-most) trimmed path component is exactly '..'
4624
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
4625
+ return '';
4626
+ }
4627
+ return path.slice(startDot, end);
4628
+ },
4629
+
4630
+ format: function format(pathObject) {
4631
+ if (pathObject === null || typeof pathObject !== 'object') {
4632
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
4633
+ }
4634
+ return _format('/', pathObject);
4635
+ },
4636
+
4637
+ parse: function parse(path) {
4638
+ assertPath(path);
4639
+
4640
+ var ret = { root: '', dir: '', base: '', ext: '', name: '' };
4641
+ if (path.length === 0) return ret;
4642
+ var code = path.charCodeAt(0);
4643
+ var isAbsolute = code === 47 /*/*/;
4644
+ var start;
4645
+ if (isAbsolute) {
4646
+ ret.root = '/';
4647
+ start = 1;
4648
+ } else {
4649
+ start = 0;
4650
+ }
4651
+ var startDot = -1;
4652
+ var startPart = 0;
4653
+ var end = -1;
4654
+ var matchedSlash = true;
4655
+ var i = path.length - 1;
4656
+
4657
+ // Track the state of characters (if any) we see before our first dot and
4658
+ // after any path separator we find
4659
+ var preDotState = 0;
4660
+
4661
+ // Get non-dir info
4662
+ for (; i >= start; --i) {
4663
+ code = path.charCodeAt(i);
4664
+ if (code === 47 /*/*/) {
4665
+ // If we reached a path separator that was not part of a set of path
4666
+ // separators at the end of the string, stop now
4667
+ if (!matchedSlash) {
4668
+ startPart = i + 1;
4669
+ break;
4670
+ }
4671
+ continue;
4672
+ }
4673
+ if (end === -1) {
4674
+ // We saw the first non-path separator, mark this as the end of our
4675
+ // extension
4676
+ matchedSlash = false;
4677
+ end = i + 1;
4678
+ }
4679
+ if (code === 46 /*.*/) {
4680
+ // If this is our first dot, mark it as the start of our extension
4681
+ if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
4682
+ } else if (startDot !== -1) {
4683
+ // We saw a non-dot and non-path separator before our dot, so we should
4684
+ // have a good chance at having a non-empty extension
4685
+ preDotState = -1;
4686
+ }
4687
+ }
4688
+
4689
+ if (startDot === -1 || end === -1 ||
4690
+ // We saw a non-dot character immediately before the dot
4691
+ preDotState === 0 ||
4692
+ // The (right-most) trimmed path component is exactly '..'
4693
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
4694
+ if (end !== -1) {
4695
+ if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
4696
+ }
4697
+ } else {
4698
+ if (startPart === 0 && isAbsolute) {
4699
+ ret.name = path.slice(1, startDot);
4700
+ ret.base = path.slice(1, end);
4701
+ } else {
4702
+ ret.name = path.slice(startPart, startDot);
4703
+ ret.base = path.slice(startPart, end);
4704
+ }
4705
+ ret.ext = path.slice(startDot, end);
4706
+ }
4707
+
4708
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
4709
+
4710
+ return ret;
4711
+ },
4712
+
4713
+ sep: '/',
4714
+ delimiter: ':',
4715
+ win32: null,
4716
+ posix: null
4717
+ };
4718
+
4719
+ posix.posix = posix;
4720
+
4721
+ module.exports = posix;
4722
+
4723
+
4179
4724
  /***/ }),
4180
4725
 
4181
4726
  /***/ 4281:
@@ -8858,6 +9403,8 @@ const nothingFoundError = (hash) => {
8858
9403
  return new Error(`nothing found for ${hash}`)
8859
9404
  }
8860
9405
 
9406
+ // EXTERNAL MODULE: ./node_modules/path-browserify/index.js
9407
+ var path_browserify = __webpack_require__(6470);
8861
9408
  ;// CONCATENATED MODULE: ./src/peernet.js
8862
9409
  /* provided dependency */ var peernet_Buffer = __webpack_require__(8764)["Buffer"];
8863
9410
 
@@ -8870,6 +9417,7 @@ const nothingFoundError = (hash) => {
8870
9417
 
8871
9418
 
8872
9419
 
9420
+
8873
9421
  globalThis.leofcoin = globalThis.leofcoin || {}
8874
9422
  globalThis.pubsub = globalThis.pubsub || new LittlePubSub()
8875
9423
  globalThis.globalSub = globalThis.globalSub || new LittlePubSub({verbose: true})
@@ -9018,8 +9566,10 @@ class Peernet {
9018
9566
  DataMessage,
9019
9567
  DataMessageResponse,
9020
9568
  PsMessage,
9021
- ChatMessage
9022
- } = await __webpack_require__.e(/* import() | messages */ 158).then(__webpack_require__.bind(__webpack_require__, 7782))
9569
+ ChatMessage,
9570
+ PeernetFile
9571
+ // FolderMessageResponse
9572
+ } = await __webpack_require__.e(/* import() | messages */ 158).then(__webpack_require__.bind(__webpack_require__, 1331))
9023
9573
 
9024
9574
  /**
9025
9575
  * proto Object containing protos
@@ -9043,6 +9593,7 @@ class Peernet {
9043
9593
  'peernet-data-response': DataMessageResponse,
9044
9594
  'peernet-ps': PsMessage,
9045
9595
  'chat-message': ChatMessage,
9596
+ 'peernet-file': PeernetFile
9046
9597
  }
9047
9598
 
9048
9599
  this._messageHandler = new MessageHandler(this.network)
@@ -9384,6 +9935,76 @@ class Peernet {
9384
9935
  }
9385
9936
  }
9386
9937
 
9938
+ get folder() {
9939
+ return {
9940
+ /**
9941
+ * Get content for given data hash
9942
+ *
9943
+ * @param {String} hash
9944
+ */
9945
+ get: async (hash) => {
9946
+ debug(`get data ${hash}`)
9947
+ const data = await dataStore.has(hash)
9948
+ if (data) return await dataStore.get(hash)
9949
+ return this.requestData(hash, 'data')
9950
+ },
9951
+ /**
9952
+ * put data content
9953
+ *
9954
+ * @param {String} hash
9955
+ * @param {Buffer} data
9956
+ */
9957
+ put: async (hash, data) => await dataStore.put(hash, data),
9958
+ /**
9959
+ * @param {String} hash
9960
+ * @return {Boolean}
9961
+ */
9962
+ has: async (hash) => await dataStore.has(hash),
9963
+ }
9964
+ }
9965
+
9966
+ async addFolder(files) {
9967
+ const links = []
9968
+ for (const file of files) {
9969
+ const fileNode = await new globalThis.peernet.protos['peernet-file'](file)
9970
+ const hash = await fileNode.hash
9971
+ await dataStore.put(hash, fileNode.encoded)
9972
+ links.push({hash, path: file.path})
9973
+ }
9974
+ const node = await new globalThis.peernet.protos['peernet-file']({path: '/', links})
9975
+ const hash = await node.hash
9976
+ await dataStore.put(hash, node.encoded)
9977
+
9978
+ return hash
9979
+ }
9980
+
9981
+ async ls(hash) {
9982
+ let data
9983
+ const has = await dataStore.has(hash)
9984
+ if (has) data = await dataStore.get(hash)
9985
+ else data = await this.requestData(hash, 'data')
9986
+
9987
+ const node = await new peernet.protos['peernet-file'](data)
9988
+ const paths = []
9989
+ if (node.decoded?.links.length === 0) throw new Error(`${hash} is a file`)
9990
+ for (const {path, hash} of node.decoded.links) {
9991
+ paths.push({path, hash})
9992
+ }
9993
+
9994
+ return paths
9995
+ }
9996
+
9997
+ async cat(hash) {
9998
+ let data
9999
+ const has = await dataStore.has(hash)
10000
+ if (has) data = await dataStore.get(hash)
10001
+ else data = await this.requestData(hash, 'data')
10002
+ const node = await new peernet.protos['peernet-file'](data)
10003
+ const paths = []
10004
+ if (node.decoded?.links.length > 0) throw new Error(`${hash} is a directory`)
10005
+ return node.decoded.content
10006
+ }
10007
+
9387
10008
  /**
9388
10009
  * goes trough given stores and tries to find data for given hash
9389
10010
  * @param {Array} stores