@leofcoin/peernet 1.2.21 → 1.2.23
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/{browser-8BFql6K9.js → browser-BKlRwB0A.js} +1 -1
- package/exports/browser/{browser-FVp_QbaL.js → browser-Dx3X9MHO.js} +1 -1
- package/exports/browser/{client-lPe0SUWx.js → client-eYBPUrVq.js} +19 -14
- package/exports/browser/{identity-BeVZQ2Dp.js → identity-BS_eDrwh.js} +1830 -1806
- package/exports/browser/identity.js +1 -1
- package/exports/browser/{index-D6qd-AUn.js → index-B91mcwxm.js} +1 -1
- package/exports/browser/{messages-BfDvXW-x.js → messages-D0Goitr6.js} +2 -2
- package/exports/browser/{peernet-DFiLLjUD.js → peernet-CgU-ZdIe.js} +154 -82
- package/exports/browser/peernet.js +2 -2
- package/exports/identity.js +25 -1
- package/exports/peernet.js +5 -1
- package/exports/store.js +3 -0
- package/exports/types/identity.d.ts +1 -1
- package/exports/types/peernet.d.ts +2 -0
- package/package.json +4 -3
- package/src/identity.ts +30 -1
- package/src/peernet.ts +5 -1
- package/test/peernet.test.js +11 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LittlePubSub, d as deflate_1, i as inflate_1, c as createDebugger } from './peernet-
|
|
2
|
-
import './identity-
|
|
1
|
+
import { L as LittlePubSub, d as deflate_1, i as inflate_1, c as createDebugger } from './peernet-CgU-ZdIe.js';
|
|
2
|
+
import './identity-BS_eDrwh.js';
|
|
3
3
|
import 'crypto';
|
|
4
4
|
import './value-C3vAp-wb.js';
|
|
5
5
|
|
|
@@ -232,7 +232,7 @@ class SocketRequestClient {
|
|
|
232
232
|
const init = async () => {
|
|
233
233
|
// @ts-ignore
|
|
234
234
|
if (!globalThis.WebSocket && !this.#experimentalWebsocket)
|
|
235
|
-
globalThis.WebSocket = (await import('./browser-
|
|
235
|
+
globalThis.WebSocket = (await import('./browser-BKlRwB0A.js').then(function (n) { return n.b; })).default.w3cwebsocket;
|
|
236
236
|
const client = new WebSocket(this.#url, this.#protocol);
|
|
237
237
|
if (this.#experimentalWebsocket) {
|
|
238
238
|
client.addEventListener('error', this.onerror);
|
|
@@ -1303,7 +1303,7 @@ class Client {
|
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
1305
|
async #loadNodeWebrtcImplementation() {
|
|
1306
|
-
const koushWrtcModule = await import('./browser-
|
|
1306
|
+
const koushWrtcModule = await import('./browser-Dx3X9MHO.js').then(function (n) { return n.b; });
|
|
1307
1307
|
const koushWrtc = koushWrtcModule.default;
|
|
1308
1308
|
if (!isWrtcImplementation(koushWrtc)) {
|
|
1309
1309
|
throw new Error('@koush/wrtc does not match required wrtc contract');
|
|
@@ -1854,14 +1854,15 @@ class Client {
|
|
|
1854
1854
|
return peer;
|
|
1855
1855
|
};
|
|
1856
1856
|
#peerJoined = async ({ peerId, version, transport }, star) => {
|
|
1857
|
-
// check if peer rejoined before the previous connection closed
|
|
1858
|
-
if (this.#connections[peerId]) {
|
|
1859
|
-
this.#connections[peerId].destroy();
|
|
1860
|
-
delete this.#connections[peerId];
|
|
1861
|
-
}
|
|
1862
1857
|
if (this.peerId === peerId)
|
|
1863
1858
|
return;
|
|
1864
|
-
|
|
1859
|
+
// Stars can announce the same peer more than once while its transport is
|
|
1860
|
+
// still negotiating. Keep that connection/attempt alive; destroying it
|
|
1861
|
+
// here makes simultaneous joins continually reset each other.
|
|
1862
|
+
// Both sides receive the discovery event. Elect exactly one offerer so
|
|
1863
|
+
// simultaneous joins do not create competing channels/SDP negotiations.
|
|
1864
|
+
const initiator = String(this.peerId) < String(peerId);
|
|
1865
|
+
this.#startPeerTransportAttempt(peerId, star, version, initiator, transport);
|
|
1865
1866
|
debug(`peer ${peerId} joined`);
|
|
1866
1867
|
};
|
|
1867
1868
|
#inComingSignal = async ({ from, signal, channelName, version }, star) => {
|
|
@@ -1927,12 +1928,16 @@ class Client {
|
|
|
1927
1928
|
});
|
|
1928
1929
|
};
|
|
1929
1930
|
#peerClose = (peer) => {
|
|
1931
|
+
// A failed transport can finish closing after fallback has already placed a
|
|
1932
|
+
// replacement in the connection map. Never let that stale close delete or
|
|
1933
|
+
// advance the replacement's active attempt.
|
|
1934
|
+
if (this.#connections[peer.peerId] !== peer) {
|
|
1935
|
+
debug(`ignored stale close for ${peer.peerId}`);
|
|
1936
|
+
return;
|
|
1937
|
+
}
|
|
1930
1938
|
const wasConnected = peer.connected;
|
|
1931
1939
|
this.#peerTransportKinds.delete(peer.peerId);
|
|
1932
|
-
|
|
1933
|
-
peer.destroy();
|
|
1934
|
-
delete this.#connections[peer.peerId];
|
|
1935
|
-
}
|
|
1940
|
+
delete this.#connections[peer.peerId];
|
|
1936
1941
|
if (!wasConnected && this.#peerTransportAttempts.has(peer.peerId)) {
|
|
1937
1942
|
this.#advanceTransportAttempt(peer.peerId);
|
|
1938
1943
|
}
|