@leofcoin/peernet 0.12.2 → 0.13.1

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.
@@ -6,42 +6,14 @@
6
6
 
7
7
  // EXPORTS
8
8
  __webpack_require__.d(__webpack_exports__, {
9
- "V9": function() { return /* reexport */ codec_namespaceObject; },
10
- "N6": function() { return /* reexport */ codec_hash_namespaceObject; },
11
- "L1": function() { return /* reexport */ codec_format_interface_namespaceObject; },
12
- "QB": function() { return /* reexport */ codecs_namespaceObject; }
9
+ "V9": function() { return /* reexport */ PeernetCodec; },
10
+ "N6": function() { return /* reexport */ CodecHash; },
11
+ "L1": function() { return /* reexport */ FormatInterface; },
12
+ "QB": function() { return /* reexport */ codecs; }
13
13
  });
14
14
 
15
15
  // UNUSED EXPORTS: BasicInterface
16
16
 
17
- // NAMESPACE OBJECT: ./node_modules/@leofcoin/codec-format-interface/src/codecs.js
18
- var codecs_namespaceObject = {};
19
- __webpack_require__.r(codecs_namespaceObject);
20
- __webpack_require__.d(codecs_namespaceObject, {
21
- "default": function() { return codecs; }
22
- });
23
-
24
- // NAMESPACE OBJECT: ./node_modules/@leofcoin/codec-format-interface/src/codec.js
25
- var codec_namespaceObject = {};
26
- __webpack_require__.r(codec_namespaceObject);
27
- __webpack_require__.d(codec_namespaceObject, {
28
- "default": function() { return PeernetCodec; }
29
- });
30
-
31
- // NAMESPACE OBJECT: ./node_modules/@leofcoin/codec-format-interface/src/codec-hash.js
32
- var codec_hash_namespaceObject = {};
33
- __webpack_require__.r(codec_hash_namespaceObject);
34
- __webpack_require__.d(codec_hash_namespaceObject, {
35
- "default": function() { return CodecHash; }
36
- });
37
-
38
- // NAMESPACE OBJECT: ./node_modules/@leofcoin/codec-format-interface/src/codec-format-interface.js
39
- var codec_format_interface_namespaceObject = {};
40
- __webpack_require__.r(codec_format_interface_namespaceObject);
41
- __webpack_require__.d(codec_format_interface_namespaceObject, {
42
- "default": function() { return FormatInterface; }
43
- });
44
-
45
17
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base-x/src/base-x.js
46
18
  // base-x encoding / decoding
47
19
  // Copyright (c) 2018 base-x contributors
@@ -169,17 +141,17 @@ const base = ALPHABET => {
169
141
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base32/src/base32.js
170
142
 
171
143
 
172
- const base32_base32 = 'abcdefghijklmnopqrstuvwxyz234567'
144
+ const base32 = 'abcdefghijklmnopqrstuvwxyz234567'
173
145
  const base32Hex = '0123456789abcdefghijklmnopqrstuv'
174
146
 
175
147
  const decode = (uint8Array, hex = false) => {
176
- const decoder = hex ? base_x(base32Hex) : base_x(base32_base32)
148
+ const decoder = hex ? base_x(base32Hex) : base_x(base32)
177
149
  return decoder.decode(uint8Array)
178
150
  }
179
151
 
180
152
  /* harmony default export */ var src_base32 = ({
181
153
  encode: (uint8Array, hex = false) => {
182
- const encoder = hex ? base_x(base32Hex) : base_x(base32_base32)
154
+ const encoder = hex ? base_x(base32Hex) : base_x(base32)
183
155
  return encoder.encode(uint8Array)
184
156
  },
185
157
  decode,
@@ -196,12 +168,12 @@ const decode = (uint8Array, hex = false) => {
196
168
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base58/src/base58.js
197
169
 
198
170
 
199
- const base58_base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
171
+ const base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
200
172
 
201
- const base58_decode = uint8Array => base_x(base58_base58).decode(uint8Array)
173
+ const base58_decode = uint8Array => base_x(base58).decode(uint8Array)
202
174
 
203
175
  /* harmony default export */ var src_base58 = ({
204
- encode: uint8Array => base_x(base58_base58).encode(uint8Array),
176
+ encode: uint8Array => base_x(base58).encode(uint8Array),
205
177
  decode: base58_decode,
206
178
  isBase58: uint8Array => {
207
179
  try {
@@ -236,10 +208,10 @@ class BasicInterface {
236
208
  return is_hex(string)
237
209
  }
238
210
  isBase32(string) {
239
- return base32.isBase32(string)
211
+ return src_base32.isBase32(string)
240
212
  }
241
213
  isBase58(string) {
242
- return base58.isBase32(string)
214
+ return src_base58.isBase58(string)
243
215
  }
244
216
  /**
245
217
  * @param {String} encoded
@@ -424,6 +396,14 @@ var varint_default = /*#__PURE__*/__webpack_require__.n(varint);
424
396
  codec: parseInt('636d', 16),
425
397
  hashAlg: 'dbl-keccak-256',
426
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
+ }
427
407
  });
428
408
 
429
409
  ;// CONCATENATED MODULE: ./node_modules/@leofcoin/codec-format-interface/src/codec.js
@@ -4204,6 +4184,543 @@ exports.Headers = global.Headers;
4204
4184
  exports.Request = global.Request;
4205
4185
  exports.Response = global.Response;
4206
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
+
4207
4724
  /***/ }),
4208
4725
 
4209
4726
  /***/ 4281:
@@ -8460,6 +8977,63 @@ __webpack_require__.d(__webpack_exports__, {
8460
8977
 
8461
8978
  // EXTERNAL MODULE: ./node_modules/@vandeurenglenn/debug/debug.js
8462
8979
  var debug_debug = __webpack_require__(307);
8980
+ ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/little-pubsub/src/index.js
8981
+ class LittlePubSub {
8982
+
8983
+ /**
8984
+ * Creates handlers
8985
+ */
8986
+ constructor(verbose = true) {
8987
+ this.subscribers = {};
8988
+ this.verbose = verbose
8989
+ }
8990
+
8991
+ /**
8992
+ * @param {String} event
8993
+ * @param {Method} handler
8994
+ * @param {HTMLElement} context
8995
+ */
8996
+ subscribe(event, handler, context) {
8997
+ if (typeof context === 'undefined') {
8998
+ context = handler;
8999
+ }
9000
+ this.subscribers[event] = this.subscribers[event] || { handlers: [], value: null};
9001
+ this.subscribers[event].handlers.push(handler.bind(context))
9002
+ }
9003
+
9004
+ /**
9005
+ * @param {String} event
9006
+ * @param {Method} handler
9007
+ * @param {HTMLElement} context
9008
+ */
9009
+ unsubscribe(event, handler, context) {
9010
+ if (typeof context === 'undefined') {
9011
+ context = handler;
9012
+ }
9013
+ if (this.subscribers[event]) {
9014
+ const index = this.subscribers[event].handlers.indexOf(handler.bind(context));
9015
+ this.subscribers[event].handlers.splice(index);
9016
+ if (this.subscribers[event].handlers.length === 0) delete this.subscribers[event];
9017
+ }
9018
+
9019
+ }
9020
+
9021
+ /**
9022
+ * @param {String} event
9023
+ * @param {String|Number|Boolean|Object|Array} change
9024
+ */
9025
+ publish(event, change) {
9026
+ if (this.subscribers[event]) {
9027
+ if (this.verbose || this.subscribers[event].value !== change) {
9028
+ this.subscribers[event].value = change;
9029
+ this.subscribers[event].handlers.forEach(handler => {
9030
+ handler(change, this.subscribers[event].value)
9031
+ })
9032
+ }
9033
+ }
9034
+ }
9035
+ }
9036
+
8463
9037
  // EXTERNAL MODULE: ./node_modules/node-fetch/browser.js
8464
9038
  var browser = __webpack_require__(3300);
8465
9039
  var browser_default = /*#__PURE__*/__webpack_require__.n(browser);
@@ -8829,6 +9403,8 @@ const nothingFoundError = (hash) => {
8829
9403
  return new Error(`nothing found for ${hash}`)
8830
9404
  }
8831
9405
 
9406
+ // EXTERNAL MODULE: ./node_modules/path-browserify/index.js
9407
+ var path_browserify = __webpack_require__(6470);
8832
9408
  ;// CONCATENATED MODULE: ./src/peernet.js
8833
9409
  /* provided dependency */ var peernet_Buffer = __webpack_require__(8764)["Buffer"];
8834
9410
 
@@ -8840,8 +9416,11 @@ const nothingFoundError = (hash) => {
8840
9416
 
8841
9417
 
8842
9418
 
9419
+
9420
+
8843
9421
  globalThis.leofcoin = globalThis.leofcoin || {}
8844
- globalThis.globalSub = globalThis.globalSub || new PubSub({verbose: true})
9422
+ globalThis.pubsub = globalThis.pubsub || new LittlePubSub()
9423
+ globalThis.globalSub = globalThis.globalSub || new LittlePubSub({verbose: true})
8845
9424
 
8846
9425
  /**
8847
9426
  * @access public
@@ -8887,16 +9466,12 @@ class Peernet {
8887
9466
  return ['account', 'wallet', 'block', 'transaction', 'chain', 'data', 'message']
8888
9467
  }
8889
9468
 
8890
- get protos() {
8891
- return globalThis.peernet.protos
8892
- }
8893
-
8894
9469
  get codecs() {
8895
9470
  return src/* codecs */.QB
8896
9471
  }
8897
9472
 
8898
9473
  addProto(name, proto) {
8899
- if (!this.protos[name]) this.protos[name] = proto
9474
+ if (!globalThis.peernet.protos[name]) globalThis.peernet.protos[name] = proto
8900
9475
  }
8901
9476
 
8902
9477
  addCodec(name, codec) {
@@ -8991,8 +9566,10 @@ class Peernet {
8991
9566
  DataMessage,
8992
9567
  DataMessageResponse,
8993
9568
  PsMessage,
8994
- ChatMessage
8995
- } = 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))
8996
9573
 
8997
9574
  /**
8998
9575
  * proto Object containing protos
@@ -9016,6 +9593,7 @@ class Peernet {
9016
9593
  'peernet-data-response': DataMessageResponse,
9017
9594
  'peernet-ps': PsMessage,
9018
9595
  'chat-message': ChatMessage,
9596
+ 'peernet-file': PeernetFile
9019
9597
  }
9020
9598
 
9021
9599
  this._messageHandler = new MessageHandler(this.network)
@@ -9126,7 +9704,7 @@ class Peernet {
9126
9704
  if (store.private) has = false
9127
9705
  else has = await store.has(hash)
9128
9706
  }
9129
- const data = await new this.protos['peernet-dht-response']({hash, has})
9707
+ const data = await new globalThis.peernet.protos['peernet-dht-response']({hash, has})
9130
9708
  const node = await this.prepareMessage(from, data.encoded)
9131
9709
 
9132
9710
  this.sendMessage(peer, id, node.encoded)
@@ -9142,7 +9720,7 @@ class Peernet {
9142
9720
  data = await store.get(hash)
9143
9721
 
9144
9722
  if (data) {
9145
- data = await new this.protos['peernet-data-response']({hash, data});
9723
+ data = await new globalThis.peernet.protos['peernet-data-response']({hash, data});
9146
9724
 
9147
9725
  const node = await this.prepareMessage(from, data.encoded)
9148
9726
  this.sendMessage(peer, id, node.encoded)
@@ -9171,7 +9749,7 @@ class Peernet {
9171
9749
  */
9172
9750
  async walk(hash) {
9173
9751
  if (!hash) throw new Error('hash expected, received undefined')
9174
- const data = await new this.protos['peernet-dht']({hash})
9752
+ const data = await new globalThis.peernet.protos['peernet-dht']({hash})
9175
9753
  const clientId = this.client.id
9176
9754
  const walk = async peer => {
9177
9755
  const node = await this.prepareMessage(peer.peerId, data.encoded)
@@ -9279,7 +9857,7 @@ class Peernet {
9279
9857
  if (peer.peerId === id) return peer
9280
9858
  })
9281
9859
 
9282
- let data = await new this.protos['peernet-data']({hash, store: store?.name ? store?.name : store});
9860
+ let data = await new globalThis.peernet.protos['peernet-data']({hash, store: store?.name ? store?.name : store});
9283
9861
 
9284
9862
  const node = await this.prepareMessage(id, data.encoded)
9285
9863
  if (closest[0]) data = await closest[0].request(node.encoded)
@@ -9357,6 +9935,76 @@ class Peernet {
9357
9935
  }
9358
9936
  }
9359
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
+
9360
10008
  /**
9361
10009
  * goes trough given stores and tries to find data for given hash
9362
10010
  * @param {Array} stores
@@ -9425,7 +10073,7 @@ class Peernet {
9425
10073
  if (topic instanceof Uint8Array === false) topic = new TextEncoder().encode(topic)
9426
10074
  if (data instanceof Uint8Array === false) data = new TextEncoder().encode(JSON.stringify(data))
9427
10075
  const id = Math.random().toString(36).slice(-12)
9428
- data = await new this.protos['peernet-ps']({data, topic})
10076
+ data = await new globalThis.peernet.protos['peernet-ps']({data, topic})
9429
10077
  for (const peer of this.connections) {
9430
10078
  if (peer.peerId !== this.peerId) {
9431
10079
  const node = await this.prepareMessage(peer.peerId, data.encoded)