@decentnetwork/peer 0.1.22 → 0.1.24
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/dist/peer.js +21 -0
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -792,6 +792,17 @@ export class Peer {
|
|
|
792
792
|
this.#debugLog(`sendText: in-session send failed for ${pubkey}, falling back to express: ${emsg}`);
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
|
+
// Never queue an EMPTY message to express. Empty text is used purely as
|
|
796
|
+
// a connection-trigger (e.g. the dora server's 8s session-kick
|
|
797
|
+
// `sendText(target, "")`, which exists only to nudge #initiateSession on
|
|
798
|
+
// a live transport). Offline it carries no data, and queuing one every 8s
|
|
799
|
+
// for every offline friend floods the relay with junk — the observed
|
|
800
|
+
// 80+-message-per-peer piles that timed out every pull. A kick that finds
|
|
801
|
+
// no session is simply a no-op.
|
|
802
|
+
if (text.length === 0) {
|
|
803
|
+
this.#debugLog(`sendText: empty connection-kick to ${pubkey} with no live session — dropping (not flooding express)`);
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
795
806
|
// Offline / fallback path via Carrier express HTTP store-and-forward.
|
|
796
807
|
if (this.#express?.hasNodes()) {
|
|
797
808
|
await this.#express.sendOfflineText(pubkey, packet);
|
|
@@ -1773,6 +1784,16 @@ export class Peer {
|
|
|
1773
1784
|
catch {
|
|
1774
1785
|
return;
|
|
1775
1786
|
}
|
|
1787
|
+
// Already an established friend? Ignore this (re-)request. Auto-friend
|
|
1788
|
+
// re-sends and reconnect retries pile up offline friend-requests on the
|
|
1789
|
+
// express relay; once we've accepted them, re-emitting would re-run the
|
|
1790
|
+
// accept path and churn. The express pull still ack-deletes the stale R
|
|
1791
|
+
// via its timestamp watermark — we just don't act on it again.
|
|
1792
|
+
const existingFriend = this.#friends.get(fromUserId);
|
|
1793
|
+
if (existingFriend?.acceptedAt || existingFriend?.status === "online") {
|
|
1794
|
+
this.#debugLog(`ignoring offline friend-request from already-accepted friend ${fromUserId}`);
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1776
1797
|
if (this.#pendingFriendRequests.has(fromUserId)) {
|
|
1777
1798
|
return;
|
|
1778
1799
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "Pure TypeScript port of Elastos Carrier (toxcore-derived) P2P messaging. DHT, onion routing, TCP relay, FlatBuffers app payloads, Express offline relay. Wire-compatible with iOS Beagle and the Carrier C SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|