@leofcoin/peernet 1.1.64 → 1.1.66
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/exports/browser/{client-d602421d.js → client-493cbd83.js} +160 -128
- package/exports/browser/{index-20ad607b.js → index-34c93510.js} +1 -1
- package/exports/browser/{messages-29f5675b.js → messages-b7f41cba.js} +1 -1
- package/exports/browser/{peernet-8bfe60c5.js → peernet-72528dd9.js} +37 -32
- package/exports/browser/peernet.js +1 -1
- package/package.json +3 -2
|
@@ -103,15 +103,18 @@ class LittlePubSub {
|
|
|
103
103
|
if (this.subscribers[event].handlers.length === 0)
|
|
104
104
|
delete this.subscribers[event];
|
|
105
105
|
}
|
|
106
|
-
publish(event,
|
|
106
|
+
publish(event, value) {
|
|
107
|
+
// always set value even when having no subscribers
|
|
107
108
|
if (!this.hasSubscribers(event))
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
this.subscribers[event] = {
|
|
110
|
+
handlers: []
|
|
111
|
+
};
|
|
112
|
+
const oldValue = this.subscribers[event]?.value;
|
|
113
|
+
this.subscribers[event].value = value;
|
|
114
|
+
if (this.verbose || oldValue !== value)
|
|
115
|
+
for (const handler of this.subscribers[event].handlers) {
|
|
116
|
+
handler(value, oldValue);
|
|
117
|
+
}
|
|
115
118
|
}
|
|
116
119
|
once(event) {
|
|
117
120
|
return new Promise((resolve) => {
|
|
@@ -270,53 +273,61 @@ const base = (ALPHABET) => {
|
|
|
270
273
|
const ALPHABET$3 = '0123456789ABCDEF';
|
|
271
274
|
base(ALPHABET$3);
|
|
272
275
|
|
|
273
|
-
const ALPHABET$2 =
|
|
274
|
-
const ALPHABET_HEX$1 =
|
|
275
|
-
base(ALPHABET$2);
|
|
276
|
+
const ALPHABET$2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
277
|
+
const ALPHABET_HEX$1 = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
278
|
+
base(ALPHABET$2);
|
|
276
279
|
base(ALPHABET_HEX$1);
|
|
277
280
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
try {
|
|
288
|
-
decode(string);
|
|
289
|
-
return true;
|
|
290
|
-
}
|
|
291
|
-
catch (e) {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
try {
|
|
297
|
-
decodeHex(string);
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
catch (e) {
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
try {
|
|
306
|
-
decode(string);
|
|
307
|
-
return
|
|
308
|
-
}
|
|
309
|
-
catch (e) {
|
|
310
|
-
try {
|
|
311
|
-
decodeHex(string);
|
|
312
|
-
return
|
|
313
|
-
}
|
|
314
|
-
catch
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
var base58$1 = {
|
|
281
|
+
const ALPHABET$1 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
282
|
+
const ALPHABET_HEX = "0123456789ABCDEFGHJKLMNPQRSTUVabcdefghijklmnopqrstuv";
|
|
283
|
+
const base58 = base(ALPHABET$1);
|
|
284
|
+
const base58Hex = base(ALPHABET_HEX);
|
|
285
|
+
const encode = base58.encode;
|
|
286
|
+
const decode = base58.decode;
|
|
287
|
+
const encodeHex = base58Hex.encode;
|
|
288
|
+
const decodeHex = base58Hex.decode;
|
|
289
|
+
const isBase58 = (string) => {
|
|
290
|
+
try {
|
|
291
|
+
decode(string);
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
catch (e) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
const isBase58Hex = (string) => {
|
|
299
|
+
try {
|
|
300
|
+
decodeHex(string);
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
catch (e) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
const whatType = (string) => {
|
|
308
|
+
try {
|
|
309
|
+
decode(string);
|
|
310
|
+
return "base58";
|
|
311
|
+
}
|
|
312
|
+
catch (e) {
|
|
313
|
+
try {
|
|
314
|
+
decodeHex(string);
|
|
315
|
+
return "base58Hex";
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
var base58$1 = {
|
|
323
|
+
encode,
|
|
324
|
+
decode,
|
|
325
|
+
isBase58,
|
|
326
|
+
isBase58Hex,
|
|
327
|
+
encodeHex,
|
|
328
|
+
decodeHex,
|
|
329
|
+
whatType,
|
|
330
|
+
};
|
|
320
331
|
|
|
321
332
|
const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
|
322
333
|
base(ALPHABET);
|
|
@@ -467,18 +478,20 @@ let P2PT$1 = class P2PT extends EventEmitter {
|
|
|
467
478
|
infoHash;
|
|
468
479
|
_infoHashBuffer;
|
|
469
480
|
_infoHashBinary;
|
|
481
|
+
#maxPeerChannels;
|
|
470
482
|
/**
|
|
471
483
|
*
|
|
472
484
|
* @param array announceURLs List of announce tracker URLs
|
|
473
485
|
* @param string identifierString Identifier used to discover peers in the network
|
|
474
486
|
*/
|
|
475
|
-
constructor(announceURLs = [], identifierString = '', peerId) {
|
|
487
|
+
constructor(announceURLs = [], identifierString = '', peerId, maxPeerChannels = 5) {
|
|
476
488
|
super();
|
|
477
489
|
this.announceURLs = announceURLs;
|
|
478
490
|
this.trackers = {};
|
|
479
491
|
this.peers = {};
|
|
480
492
|
this.msgChunks = {};
|
|
481
493
|
this.responseWaiting = {};
|
|
494
|
+
this.#maxPeerChannels = maxPeerChannels;
|
|
482
495
|
if (identifierString) {
|
|
483
496
|
this.setIdentifier(identifierString);
|
|
484
497
|
}
|
|
@@ -497,83 +510,94 @@ let P2PT$1 = class P2PT extends EventEmitter {
|
|
|
497
510
|
this._infoHashBuffer = hex2arr(this.infoHash);
|
|
498
511
|
this._infoHashBinary = hex2bin(this.infoHash);
|
|
499
512
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
this._destroyChunks(data.id);
|
|
554
|
-
}
|
|
513
|
+
#onPeerConnect = (peer) => {
|
|
514
|
+
let newpeer = false;
|
|
515
|
+
/**
|
|
516
|
+
* peer connected or reconnected
|
|
517
|
+
* Sometimes peers reconnect so need to handle the newpeer here
|
|
518
|
+
*/
|
|
519
|
+
if (!this.peers[peer.id]) {
|
|
520
|
+
newpeer = true;
|
|
521
|
+
this.peers[peer.id] = {};
|
|
522
|
+
if (!this.responseWaiting[peer.id])
|
|
523
|
+
this.responseWaiting[peer.id] = {};
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Multiple data channels to one peer is possible
|
|
527
|
+
* The `peer` object actually refers to a peer with a data channel. Even though it may have same `id` (peerID) property, the data channel will be different. Different trackers giving the same "peer" will give the `peer` object with different channels.
|
|
528
|
+
* We will store all channels as backups in case any one of them fails
|
|
529
|
+
* A peer is removed if all data channels become unavailable
|
|
530
|
+
*/
|
|
531
|
+
for (const channelName in this.peers[peer.id]) {
|
|
532
|
+
if (!this.peers[peer.id][channelName].connected) {
|
|
533
|
+
this.peers[peer.id][channelName].destroy();
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (Object.keys(this.peers[peer.id]).length < this.#maxPeerChannels)
|
|
537
|
+
this.peers[peer.id][peer.channelName] = peer;
|
|
538
|
+
else
|
|
539
|
+
peer.destroy();
|
|
540
|
+
if (newpeer) {
|
|
541
|
+
this.emit('peerconnect', peer);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
#onPeerData = (peer, data) => {
|
|
545
|
+
this.emit('data', peer, data);
|
|
546
|
+
data = data.toString();
|
|
547
|
+
debug('got a message from ' + peer.id);
|
|
548
|
+
if (data[0] === JSON_MESSAGE_IDENTIFIER) {
|
|
549
|
+
try {
|
|
550
|
+
data = JSON.parse(data.slice(1));
|
|
551
|
+
// A respond function
|
|
552
|
+
peer.respond = this._peerRespond(peer, data.id);
|
|
553
|
+
let msg = this._chunkHandler(data);
|
|
554
|
+
// msg fully retrieved
|
|
555
|
+
if (msg !== false) {
|
|
556
|
+
if (data.o) {
|
|
557
|
+
msg = JSON.parse(msg);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* If there's someone waiting for a response, call them
|
|
561
|
+
*/
|
|
562
|
+
if (this.responseWaiting[peer.id] && this.responseWaiting[peer.id][data.id]) {
|
|
563
|
+
this.responseWaiting[peer.id][data.id]([peer, msg]);
|
|
564
|
+
delete this.responseWaiting[peer.id][data.id];
|
|
555
565
|
}
|
|
556
|
-
|
|
557
|
-
|
|
566
|
+
else {
|
|
567
|
+
this.emit('msg', peer, msg, data.id, data.from);
|
|
558
568
|
}
|
|
569
|
+
this._destroyChunks(data.id);
|
|
559
570
|
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
571
|
+
}
|
|
572
|
+
catch (e) {
|
|
573
|
+
console.log(e);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
#onPeer = (peer) => {
|
|
578
|
+
peer.on('connect', () => this.#onPeerConnect(peer));
|
|
579
|
+
peer.on('data', (data) => this.#onPeerData(peer, data));
|
|
580
|
+
peer.on('error', (err) => {
|
|
581
|
+
this._removePeer(peer);
|
|
582
|
+
debug('Error in connection : ' + err);
|
|
569
583
|
});
|
|
584
|
+
peer.on('close', () => {
|
|
585
|
+
this._removePeer(peer);
|
|
586
|
+
debug('Connection closed with ' + peer.id);
|
|
587
|
+
});
|
|
588
|
+
};
|
|
589
|
+
/**
|
|
590
|
+
* Connect to network and start discovering peers
|
|
591
|
+
*/
|
|
592
|
+
start() {
|
|
593
|
+
this.on('peer', this.#onPeer);
|
|
570
594
|
// Tracker responded to the announce request
|
|
571
|
-
this.on('update', response => {
|
|
595
|
+
this.on('update', (response) => {
|
|
572
596
|
const tracker = this.trackers[this.announceURLs.indexOf(response.announce)];
|
|
573
597
|
this.emit('trackerconnect', tracker, this.getTrackerStats());
|
|
574
598
|
});
|
|
575
599
|
// Errors in tracker connection
|
|
576
|
-
this.on('warning', err => {
|
|
600
|
+
this.on('warning', (err) => {
|
|
577
601
|
this.emit('trackerwarning', err, this.getTrackerStats());
|
|
578
602
|
});
|
|
579
603
|
this._fetchPeers();
|
|
@@ -611,7 +635,10 @@ let P2PT$1 = class P2PT extends EventEmitter {
|
|
|
611
635
|
if (!this.peers[peer.id]) {
|
|
612
636
|
return false;
|
|
613
637
|
}
|
|
614
|
-
|
|
638
|
+
if (this.peers[peer.id][peer.channelName]) {
|
|
639
|
+
this.peers[peer.id][peer.channelName].destroy();
|
|
640
|
+
delete this.peers[peer.id][peer.channelName];
|
|
641
|
+
}
|
|
615
642
|
// All data channels are gone. Peer lost
|
|
616
643
|
if (Object.keys(this.peers[peer.id]).length === 0) {
|
|
617
644
|
this.emit('peerclose', peer);
|
|
@@ -665,8 +692,13 @@ let P2PT$1 = class P2PT extends EventEmitter {
|
|
|
665
692
|
* Array should atleast have one channel, otherwise peer connection is closed
|
|
666
693
|
*/
|
|
667
694
|
if (!peer.connected) {
|
|
668
|
-
for (const index in this.peers[peer.id]) {
|
|
695
|
+
for (const index in { ...this.peers[peer.id] }) {
|
|
669
696
|
peer = this.peers[peer.id][index];
|
|
697
|
+
/**
|
|
698
|
+
* directly cleanup channels
|
|
699
|
+
*/
|
|
700
|
+
if (!peer.connected)
|
|
701
|
+
this._removePeer(peer);
|
|
670
702
|
if (peer.connected)
|
|
671
703
|
break;
|
|
672
704
|
}
|
|
@@ -687,7 +719,7 @@ let P2PT$1 = class P2PT extends EventEmitter {
|
|
|
687
719
|
* Request more peers
|
|
688
720
|
*/
|
|
689
721
|
requestMorePeers() {
|
|
690
|
-
return new Promise(resolve => {
|
|
722
|
+
return new Promise((resolve) => {
|
|
691
723
|
for (const key in this.trackers) {
|
|
692
724
|
this.trackers[key].announce(this._defaultAnnounceOpts());
|
|
693
725
|
}
|
|
@@ -729,7 +761,7 @@ let P2PT$1 = class P2PT extends EventEmitter {
|
|
|
729
761
|
* @param integer msgID Message ID
|
|
730
762
|
*/
|
|
731
763
|
_peerRespond(peer, msgID) {
|
|
732
|
-
return msg => {
|
|
764
|
+
return (msg) => {
|
|
733
765
|
return this.send(peer, msg, msgID);
|
|
734
766
|
};
|
|
735
767
|
}
|
|
@@ -763,7 +795,7 @@ let P2PT$1 = class P2PT extends EventEmitter {
|
|
|
763
795
|
*/
|
|
764
796
|
_defaultAnnounceOpts(options = {}) {
|
|
765
797
|
if (options.numwant === undefined)
|
|
766
|
-
options.numwant =
|
|
798
|
+
options.numwant = 5;
|
|
767
799
|
if (options.uploaded === undefined)
|
|
768
800
|
options.uploaded = 0;
|
|
769
801
|
if (options.downloaded === undefined)
|
|
@@ -1231,7 +1263,7 @@ class WebSocketTracker extends Tracker {
|
|
|
1231
1263
|
if (data.complete != null) {
|
|
1232
1264
|
const response = Object.assign({}, data, {
|
|
1233
1265
|
announce: this.announceUrl,
|
|
1234
|
-
infoHash: data.info_hash
|
|
1266
|
+
infoHash: common.binaryToHex(data.info_hash)
|
|
1235
1267
|
});
|
|
1236
1268
|
this.client.emit('update', response);
|
|
1237
1269
|
}
|
|
@@ -11658,25 +11658,23 @@ var pako = {
|
|
|
11658
11658
|
};
|
|
11659
11659
|
|
|
11660
11660
|
const { fromString, toString } = index$3;
|
|
11661
|
-
const isJson = (type) => type ===
|
|
11662
|
-
const isString = (type) => type ===
|
|
11663
|
-
const isNumber = (type) => type ===
|
|
11664
|
-
const isBoolean = (type) => type ===
|
|
11665
|
-
const isUint8Array$1 = (type) => type ===
|
|
11666
|
-
const isBigNumber = (type) => type ===
|
|
11661
|
+
const isJson = (type) => type === 'object' || 'array';
|
|
11662
|
+
const isString = (type) => type === 'string';
|
|
11663
|
+
const isNumber = (type) => type === 'number';
|
|
11664
|
+
const isBoolean = (type) => type === 'boolean';
|
|
11665
|
+
const isUint8Array$1 = (type) => type === 'uint8Array';
|
|
11666
|
+
const isBigNumber = (type) => type === 'bigNumber';
|
|
11667
11667
|
const tokenize = (key, value) => {
|
|
11668
|
-
const optional = key.endsWith(
|
|
11668
|
+
const optional = key.endsWith('?');
|
|
11669
11669
|
let type = value === undefined ? key : value;
|
|
11670
11670
|
if (type instanceof Uint8Array)
|
|
11671
|
-
type =
|
|
11671
|
+
type = 'uint8Array';
|
|
11672
11672
|
else if (type instanceof BigNumber)
|
|
11673
|
-
type =
|
|
11673
|
+
type = 'bigNumber';
|
|
11674
11674
|
else
|
|
11675
|
-
type = Array.isArray(type) ?
|
|
11676
|
-
const parts = key.split(
|
|
11677
|
-
const minimumLength = parts[2]?.includes(
|
|
11678
|
-
? parts[2].split["min:"][1]
|
|
11679
|
-
: 0;
|
|
11675
|
+
type = Array.isArray(type) ? 'array' : typeof type;
|
|
11676
|
+
const parts = key.split('?');
|
|
11677
|
+
const minimumLength = parts[2]?.includes('min') ? parts[2].split['min:'][1] : 0;
|
|
11680
11678
|
return { type, optional, key: parts[0], minimumLength };
|
|
11681
11679
|
};
|
|
11682
11680
|
const toType = (data) => {
|
|
@@ -11690,13 +11688,13 @@ const toType = (data) => {
|
|
|
11690
11688
|
if (data instanceof BigNumber)
|
|
11691
11689
|
return new TextEncoder().encode(data._hex || data.toHexString());
|
|
11692
11690
|
// returns the string as a UintArray
|
|
11693
|
-
if (typeof data ===
|
|
11691
|
+
if (typeof data === 'string')
|
|
11694
11692
|
return new TextEncoder().encode(data);
|
|
11695
11693
|
// returns the object as a UintArray
|
|
11696
|
-
if (typeof data ===
|
|
11694
|
+
if (typeof data === 'object')
|
|
11697
11695
|
return new TextEncoder().encode(JSON.stringify(data));
|
|
11698
11696
|
// returns the number as a UintArray
|
|
11699
|
-
if (typeof data ===
|
|
11697
|
+
if (typeof data === 'number' || typeof data === 'boolean')
|
|
11700
11698
|
return new TextEncoder().encode(data.toString());
|
|
11701
11699
|
throw new Error(`unsuported type ${typeof data || data}`);
|
|
11702
11700
|
};
|
|
@@ -11709,17 +11707,14 @@ const encode$3 = (proto, input, compress) => {
|
|
|
11709
11707
|
const data = input[token.key];
|
|
11710
11708
|
if (!token.optional && data === undefined)
|
|
11711
11709
|
throw new Error(`missing required property: ${token.key}`);
|
|
11712
|
-
if ((token.type ===
|
|
11713
|
-
(token.type ===
|
|
11714
|
-
token.minimumLength > Object.keys(data).length))
|
|
11710
|
+
if ((token.type === 'array' && token.minimumLength > data?.length) ||
|
|
11711
|
+
(token.type === 'object' && token.minimumLength > Object.keys(data).length))
|
|
11715
11712
|
throw new Error(`minimumLength for ${token.key} is set to ${token.minimumLength} but got ${data.length}`);
|
|
11716
11713
|
// always push data to the set.
|
|
11717
11714
|
// when data is undefined push the default value of the proto
|
|
11718
11715
|
set.push(toType(data || values[i]));
|
|
11719
11716
|
}
|
|
11720
|
-
return compress
|
|
11721
|
-
? pako.deflate(index$7(set))
|
|
11722
|
-
: index$7(set);
|
|
11717
|
+
return compress ? pako.deflate(index$7(set)) : index$7(set);
|
|
11723
11718
|
};
|
|
11724
11719
|
const decode$4 = (proto, uint8Array, compressed) => {
|
|
11725
11720
|
if (compressed)
|
|
@@ -11737,7 +11732,7 @@ const decode$4 = (proto, uint8Array, compressed) => {
|
|
|
11737
11732
|
else if (isString(token.type))
|
|
11738
11733
|
output[token.key] = toString(deconcated[i]);
|
|
11739
11734
|
else if (isBoolean(token.type))
|
|
11740
|
-
output[token.key] =
|
|
11735
|
+
output[token.key] = new TextDecoder().decode(deconcated[i]) === 'true';
|
|
11741
11736
|
else if (isNumber(token.type))
|
|
11742
11737
|
output[token.key] = Number(new TextDecoder().decode(deconcated[i]));
|
|
11743
11738
|
else if (isBigNumber(token.type))
|
|
@@ -11755,7 +11750,7 @@ const decode$4 = (proto, uint8Array, compressed) => {
|
|
|
11755
11750
|
};
|
|
11756
11751
|
var index$2 = {
|
|
11757
11752
|
encode: encode$3,
|
|
11758
|
-
decode: decode$4
|
|
11753
|
+
decode: decode$4
|
|
11759
11754
|
};
|
|
11760
11755
|
|
|
11761
11756
|
class BasicInterface {
|
|
@@ -12306,6 +12301,13 @@ class CodecHash extends BasicInterface {
|
|
|
12306
12301
|
let FormatInterface$1 = class FormatInterface extends BasicInterface {
|
|
12307
12302
|
hashFormat;
|
|
12308
12303
|
#hash;
|
|
12304
|
+
#encoded;
|
|
12305
|
+
get encoded() {
|
|
12306
|
+
return this.#encoded || this.encode();
|
|
12307
|
+
}
|
|
12308
|
+
set encoded(value) {
|
|
12309
|
+
this.#encoded = value;
|
|
12310
|
+
}
|
|
12309
12311
|
init(buffer) {
|
|
12310
12312
|
if (buffer instanceof FormatInterface && buffer?.name === this.name)
|
|
12311
12313
|
return buffer;
|
|
@@ -12313,7 +12315,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
|
|
|
12313
12315
|
this.fromUint8Array(buffer);
|
|
12314
12316
|
else if (buffer instanceof ArrayBuffer)
|
|
12315
12317
|
this.fromArrayBuffer(buffer);
|
|
12316
|
-
else if (typeof buffer ===
|
|
12318
|
+
else if (typeof buffer === 'string') {
|
|
12317
12319
|
if (this.isHex(buffer))
|
|
12318
12320
|
this.fromHex(buffer);
|
|
12319
12321
|
else if (this.isBase58(buffer))
|
|
@@ -12379,7 +12381,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
|
|
|
12379
12381
|
constructor(buffer, proto, options) {
|
|
12380
12382
|
super();
|
|
12381
12383
|
this.proto = proto;
|
|
12382
|
-
this.hashFormat = options?.hashFormat ? options.hashFormat :
|
|
12384
|
+
this.hashFormat = options?.hashFormat ? options.hashFormat : 'bs32';
|
|
12383
12385
|
if (options?.name)
|
|
12384
12386
|
this.name = options.name;
|
|
12385
12387
|
this.init(buffer);
|
|
@@ -12388,13 +12390,16 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
|
|
|
12388
12390
|
const upper = this.hashFormat.charAt(0).toUpperCase();
|
|
12389
12391
|
return `${upper}${this.hashFormat.substring(1, this.hashFormat.length)}`;
|
|
12390
12392
|
}
|
|
12393
|
+
beforeHashing(decoded) {
|
|
12394
|
+
delete decoded.hash;
|
|
12395
|
+
return decoded;
|
|
12396
|
+
}
|
|
12391
12397
|
/**
|
|
12392
12398
|
* @return {PeernetHash}
|
|
12393
12399
|
*/
|
|
12394
12400
|
get peernetHash() {
|
|
12395
|
-
const decoded = this.decoded;
|
|
12401
|
+
const decoded = this.beforeHashing({ ...this.decoded });
|
|
12396
12402
|
// @ts-ignore
|
|
12397
|
-
delete decoded.hash;
|
|
12398
12403
|
return new CodecHash(decoded, { name: this.name });
|
|
12399
12404
|
}
|
|
12400
12405
|
/**
|
|
@@ -27083,7 +27088,7 @@ class Identity {
|
|
|
27083
27088
|
this.selectedAccount = new TextDecoder().decode(selected);
|
|
27084
27089
|
}
|
|
27085
27090
|
else {
|
|
27086
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
27091
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-34c93510.js');
|
|
27087
27092
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
27088
27093
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
27089
27094
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -27275,7 +27280,7 @@ class Peernet {
|
|
|
27275
27280
|
this.root = options.root;
|
|
27276
27281
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
27277
27282
|
// FolderMessageResponse
|
|
27278
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
27283
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-b7f41cba.js');
|
|
27279
27284
|
/**
|
|
27280
27285
|
* proto Object containing protos
|
|
27281
27286
|
* @type {Object}
|
|
@@ -27366,7 +27371,7 @@ class Peernet {
|
|
|
27366
27371
|
if (this.#starting || this.#started)
|
|
27367
27372
|
return;
|
|
27368
27373
|
this.#starting = true;
|
|
27369
|
-
const importee = await import('./client-
|
|
27374
|
+
const importee = await import('./client-493cbd83.js');
|
|
27370
27375
|
/**
|
|
27371
27376
|
* @access public
|
|
27372
27377
|
* @type {PeernetClient}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { P as default } from './peernet-
|
|
1
|
+
export { P as default } from './peernet-72528dd9.js';
|
|
2
2
|
import './value-4e80eeeb.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/peernet",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.66",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/peernet.js",
|
|
6
6
|
"exports": {
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
"@leofcoin/generate-account": "^2.0.0",
|
|
34
34
|
"@leofcoin/identity-utils": "^1.0.2",
|
|
35
35
|
"@leofcoin/multi-wallet": "^3.1.4",
|
|
36
|
+
"@leofcoin/p2pt": "^1.7.6",
|
|
36
37
|
"@leofcoin/peernet-swarm": "^1.1.0",
|
|
37
38
|
"@leofcoin/storage": "^3.0.0",
|
|
38
|
-
"@netpeer/p2pt-swarm": "^1.3.
|
|
39
|
+
"@netpeer/p2pt-swarm": "^1.3.5",
|
|
39
40
|
"@types/node": "^18.11.18",
|
|
40
41
|
"@vandeurenglenn/base32": "^1.1.0",
|
|
41
42
|
"@vandeurenglenn/base58": "^1.1.0",
|