@leofcoin/peernet 1.2.26 → 1.2.27
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-U5AYtQje.js → client-BVhUamQG.js} +32 -2
- package/exports/browser/{messages-Dr5w-bq6.js → messages-UKnuelZ7.js} +1 -1
- package/exports/browser/{peernet-DHQj_MFb.js → peernet-r_9IyzTe.js} +2 -2
- package/exports/browser/peernet.js +1 -1
- package/exports/types/peernet.d.ts +36 -3
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LittlePubSub, d as deflate_1, i as inflate_1, c as createDebugger } from './peernet-
|
|
1
|
+
import { L as LittlePubSub, d as deflate_1, i as inflate_1, c as createDebugger } from './peernet-r_9IyzTe.js';
|
|
2
2
|
import './identity-ChyyZSve.js';
|
|
3
3
|
import 'crypto';
|
|
4
4
|
import './value-C3vAp-wb.js';
|
|
@@ -1104,6 +1104,27 @@ class CircuitPeer {
|
|
|
1104
1104
|
}
|
|
1105
1105
|
}
|
|
1106
1106
|
|
|
1107
|
+
/** Normalize current star announcements and the legacy peer-id-only format. */
|
|
1108
|
+
const normalizePeerAnnouncement = (value) => {
|
|
1109
|
+
if (typeof value === 'string') {
|
|
1110
|
+
const peerId = value.trim();
|
|
1111
|
+
return peerId && peerId !== 'undefined' ? { peerId } : null;
|
|
1112
|
+
}
|
|
1113
|
+
if (!value || typeof value !== 'object')
|
|
1114
|
+
return null;
|
|
1115
|
+
const candidate = value;
|
|
1116
|
+
if (typeof candidate.peerId !== 'string')
|
|
1117
|
+
return null;
|
|
1118
|
+
const peerId = candidate.peerId.trim();
|
|
1119
|
+
if (!peerId || peerId === 'undefined')
|
|
1120
|
+
return null;
|
|
1121
|
+
return {
|
|
1122
|
+
peerId,
|
|
1123
|
+
version: typeof candidate.version === 'string' ? candidate.version : undefined,
|
|
1124
|
+
transport: candidate.transport
|
|
1125
|
+
};
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1107
1128
|
// Simple CRC32 implementation
|
|
1108
1129
|
const crc32 = (data) => {
|
|
1109
1130
|
let crc = 0xffffffff;
|
|
@@ -1853,7 +1874,16 @@ class Client {
|
|
|
1853
1874
|
this.#peerTransportKinds.set(peerId, 'webrtc');
|
|
1854
1875
|
return peer;
|
|
1855
1876
|
};
|
|
1856
|
-
#peerJoined = async (
|
|
1877
|
+
#peerJoined = async (announcement, star) => {
|
|
1878
|
+
const normalized = normalizePeerAnnouncement(announcement);
|
|
1879
|
+
if (!normalized) {
|
|
1880
|
+
debug('ignored malformed peer announcement');
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
const { peerId, transport } = normalized;
|
|
1884
|
+
// Legacy stars announce only the peer id. This value is used for transport
|
|
1885
|
+
// negotiation; applications still perform their own version handshake.
|
|
1886
|
+
const version = normalized.version ?? this.version;
|
|
1857
1887
|
if (this.peerId === peerId)
|
|
1858
1888
|
return;
|
|
1859
1889
|
// Stars can announce the same peer more than once while its transport is
|
|
@@ -8615,7 +8615,7 @@ class Peernet {
|
|
|
8615
8615
|
await getAddress();
|
|
8616
8616
|
this.storePrefix = options.storePrefix;
|
|
8617
8617
|
this.root = options.root;
|
|
8618
|
-
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-
|
|
8618
|
+
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-UKnuelZ7.js');
|
|
8619
8619
|
/**
|
|
8620
8620
|
* proto Object containing protos
|
|
8621
8621
|
* @type {Object}
|
|
@@ -8662,7 +8662,7 @@ class Peernet {
|
|
|
8662
8662
|
if (this.#starting || this.#started)
|
|
8663
8663
|
return;
|
|
8664
8664
|
this.#starting = true;
|
|
8665
|
-
const importee = await import('./client-
|
|
8665
|
+
const importee = await import('./client-BVhUamQG.js');
|
|
8666
8666
|
/**
|
|
8667
8667
|
* @access public
|
|
8668
8668
|
* @type {PeernetClient}
|
|
@@ -86,14 +86,47 @@ export default class Peernet {
|
|
|
86
86
|
*
|
|
87
87
|
* @return {Array} peerId
|
|
88
88
|
*/
|
|
89
|
-
get peers(): [string,
|
|
89
|
+
get peers(): [string, {
|
|
90
|
+
connected: boolean;
|
|
91
|
+
initiator: boolean;
|
|
92
|
+
peerId: string;
|
|
93
|
+
channelName: string;
|
|
94
|
+
on: (event: string, handler: (...args: unknown[]) => void) => unknown;
|
|
95
|
+
off: (event: string, handler: (...args: unknown[]) => void) => unknown;
|
|
96
|
+
signal: (signalData: unknown) => void;
|
|
97
|
+
destroy: () => void;
|
|
98
|
+
send: (data: Uint8Array, id?: string) => void;
|
|
99
|
+
request: (data: Uint8Array, id?: string) => Promise<Uint8Array>;
|
|
100
|
+
}][];
|
|
90
101
|
get connections(): {
|
|
91
|
-
[index: string]:
|
|
102
|
+
[index: string]: {
|
|
103
|
+
connected: boolean;
|
|
104
|
+
initiator: boolean;
|
|
105
|
+
peerId: string;
|
|
106
|
+
channelName: string;
|
|
107
|
+
on: (event: string, handler: (...args: unknown[]) => void) => unknown;
|
|
108
|
+
off: (event: string, handler: (...args: unknown[]) => void) => unknown;
|
|
109
|
+
signal: (signalData: unknown) => void;
|
|
110
|
+
destroy: () => void;
|
|
111
|
+
send: (data: Uint8Array, id?: string) => void;
|
|
112
|
+
request: (data: Uint8Array, id?: string) => Promise<Uint8Array>;
|
|
113
|
+
};
|
|
92
114
|
};
|
|
93
115
|
/**
|
|
94
116
|
* @return {String} id - peerId
|
|
95
117
|
*/
|
|
96
|
-
getConnection(id: any):
|
|
118
|
+
getConnection(id: any): {
|
|
119
|
+
connected: boolean;
|
|
120
|
+
initiator: boolean;
|
|
121
|
+
peerId: string;
|
|
122
|
+
channelName: string;
|
|
123
|
+
on: (event: string, handler: (...args: unknown[]) => void) => unknown;
|
|
124
|
+
off: (event: string, handler: (...args: unknown[]) => void) => unknown;
|
|
125
|
+
signal: (signalData: unknown) => void;
|
|
126
|
+
destroy: () => void;
|
|
127
|
+
send: (data: Uint8Array, id?: string) => void;
|
|
128
|
+
request: (data: Uint8Array, id?: string) => Promise<Uint8Array>;
|
|
129
|
+
};
|
|
97
130
|
/**
|
|
98
131
|
* @private
|
|
99
132
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/peernet",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"@leofcoin/multi-wallet": "^3.1.8",
|
|
113
113
|
"@leofcoin/storage": "^3.5.38",
|
|
114
114
|
"@mapbox/node-pre-gyp": "^2.0.3",
|
|
115
|
-
"@netpeer/swarm": "^0.9.
|
|
115
|
+
"@netpeer/swarm": "^0.9.11",
|
|
116
116
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
117
117
|
"@vandeurenglenn/debug": "^1.4.0",
|
|
118
118
|
"@vandeurenglenn/little-pubsub": "^1.5.2",
|