@leofcoin/peernet 1.1.101 → 1.1.102
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LittlePubSub } from './peernet-
|
|
1
|
+
import { L as LittlePubSub } from './peernet-sNy5OxPV.js';
|
|
2
2
|
import './identity-Cn0iQbY3.js';
|
|
3
3
|
import './value-C3vAp-wb.js';
|
|
4
4
|
|
|
@@ -450,15 +450,6 @@ class Client {
|
|
|
450
450
|
getPeer(peerId) {
|
|
451
451
|
return this.#connections[peerId];
|
|
452
452
|
}
|
|
453
|
-
/**
|
|
454
|
-
*
|
|
455
|
-
* @param options {object}
|
|
456
|
-
* @param options.peerId {string}
|
|
457
|
-
* @param options.networkVersion {string}
|
|
458
|
-
* @param options.version {string}
|
|
459
|
-
* @param options.stars {string[]}
|
|
460
|
-
* @param options.connectEvent {string} defaults to peer:connected, can be renamed to handle different protocols, like peer:discovered (setup peer props before fireing the connect event)
|
|
461
|
-
*/
|
|
462
453
|
constructor(options) {
|
|
463
454
|
const { peerId, networkVersion, version, connectEvent, stars } = {
|
|
464
455
|
...defaultOptions,
|
|
@@ -485,7 +476,6 @@ class Client {
|
|
|
485
476
|
debug('reinit: start');
|
|
486
477
|
try {
|
|
487
478
|
await this.close();
|
|
488
|
-
// clear internal maps so setupStar starts fresh
|
|
489
479
|
this.#stars = {};
|
|
490
480
|
this.#connections = {};
|
|
491
481
|
for (const star of this.starsConfig) {
|
|
@@ -494,8 +484,7 @@ class Client {
|
|
|
494
484
|
}
|
|
495
485
|
catch (e) {
|
|
496
486
|
// If last star fails and none connected, surface error
|
|
497
|
-
if (
|
|
498
|
-
Object.keys(this.#stars).length === 0)
|
|
487
|
+
if (Object.keys(this.#stars).length === 0)
|
|
499
488
|
throw new Error(`No star available to connect`);
|
|
500
489
|
}
|
|
501
490
|
}
|
|
@@ -537,7 +526,6 @@ class Client {
|
|
|
537
526
|
throw lastErr;
|
|
538
527
|
}
|
|
539
528
|
async _init() {
|
|
540
|
-
// reconnectJob()
|
|
541
529
|
if (!globalThis.RTCPeerConnection)
|
|
542
530
|
globalThis.wrtc = (await import('./browser-Cjcx-T47.js').then(function (n) { return n.b; })).default;
|
|
543
531
|
for (const star of this.starsConfig) {
|
|
@@ -676,6 +664,7 @@ class Client {
|
|
|
676
664
|
debug(`peer ${from} already connected`);
|
|
677
665
|
return;
|
|
678
666
|
}
|
|
667
|
+
// peer.channels[channelName]
|
|
679
668
|
if (String(peer.channelName) !== String(channelName)) {
|
|
680
669
|
console.warn(`channelNames don't match: got ${peer.channelName}, expected: ${channelName}.`);
|
|
681
670
|
// Destroy the existing peer connection
|
|
@@ -757,30 +746,29 @@ class Client {
|
|
|
757
746
|
peer.destroy();
|
|
758
747
|
};
|
|
759
748
|
async close() {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
this._resumeInterval = null;
|
|
749
|
+
for (const peerId in this.#connections) {
|
|
750
|
+
const peer = this.#connections[peerId];
|
|
751
|
+
if (peer) {
|
|
752
|
+
peer.destroy();
|
|
753
|
+
delete this.#connections[peerId];
|
|
754
|
+
}
|
|
767
755
|
}
|
|
768
756
|
for (const star in this.#stars) {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
const listeners
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
catch (e) {
|
|
779
|
-
// ignore
|
|
780
|
-
}
|
|
757
|
+
// unsubscribe handlers we registered earlier
|
|
758
|
+
const listeners = this.#starListeners[star];
|
|
759
|
+
if (listeners && listeners.length) {
|
|
760
|
+
for (const { topic, handler } of listeners) {
|
|
761
|
+
try {
|
|
762
|
+
this.#stars[star].pubsub.unsubscribe(topic, handler);
|
|
763
|
+
}
|
|
764
|
+
catch (e) {
|
|
765
|
+
// ignore
|
|
781
766
|
}
|
|
782
767
|
}
|
|
783
768
|
}
|
|
769
|
+
if (this.#stars[star].connectionState() === 'open') {
|
|
770
|
+
await this.#stars[star].send({ url: 'leave', params: this.peerId });
|
|
771
|
+
}
|
|
784
772
|
}
|
|
785
773
|
const peerClosers = Object.values(this.#connections).map((connection) => {
|
|
786
774
|
try {
|
|
@@ -8366,7 +8366,7 @@ class Peernet {
|
|
|
8366
8366
|
this.root = options.root;
|
|
8367
8367
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
8368
8368
|
// FolderMessageResponse
|
|
8369
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
8369
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-C3VxYRj3.js');
|
|
8370
8370
|
/**
|
|
8371
8371
|
* proto Object containing protos
|
|
8372
8372
|
* @type {Object}
|
|
@@ -8460,7 +8460,7 @@ class Peernet {
|
|
|
8460
8460
|
if (this.#starting || this.#started)
|
|
8461
8461
|
return;
|
|
8462
8462
|
this.#starting = true;
|
|
8463
|
-
const importee = await import('./client-
|
|
8463
|
+
const importee = await import('./client-bgSiSUVr.js');
|
|
8464
8464
|
/**
|
|
8465
8465
|
* @access public
|
|
8466
8466
|
* @type {PeernetClient}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/peernet",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.102",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "./exports/browser/peernet.js",
|
|
6
6
|
"exports": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@leofcoin/identity-utils": "^1.0.2",
|
|
38
38
|
"@leofcoin/multi-wallet": "^3.1.8",
|
|
39
39
|
"@leofcoin/storage": "^3.5.38",
|
|
40
|
-
"@netpeer/swarm": "^0.8.
|
|
40
|
+
"@netpeer/swarm": "^0.8.32",
|
|
41
41
|
"@vandeurenglenn/base32": "^1.2.4",
|
|
42
42
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
43
43
|
"@vandeurenglenn/debug": "^1.2.6",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@jest/globals": "^30.2.0",
|
|
55
|
-
"@rollup/plugin-commonjs": "^
|
|
55
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
56
56
|
"@rollup/plugin-json": "^6.1.0",
|
|
57
57
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
58
58
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
59
59
|
"@rollup/plugin-wasm": "^6.2.2",
|
|
60
60
|
"@types/bs58check": "^3.0.1",
|
|
61
|
-
"@types/node": "^24.9.
|
|
62
|
-
"@types/qrcode": "^1.5.
|
|
61
|
+
"@types/node": "^24.9.2",
|
|
62
|
+
"@types/qrcode": "^1.5.6",
|
|
63
63
|
"@types/secp256k1": "^4.0.7",
|
|
64
64
|
"@types/varint": "^6.0.3",
|
|
65
65
|
"chai": "^6.2.0",
|