@decentnetwork/peer 0.1.43 → 0.1.44

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.
Files changed (2) hide show
  1. package/dist/peer.js +10 -0
  2. package/package.json +1 -1
package/dist/peer.js CHANGED
@@ -1537,6 +1537,16 @@ export class Peer {
1537
1537
  if (!opened) {
1538
1538
  continue;
1539
1539
  }
1540
+ // De-duplicate. The dual-send path delivers each lossless packet over
1541
+ // BOTH the UDP and relay transports with the SAME packet number, so
1542
+ // without this guard every chat message (and every file-data chunk) is
1543
+ // dispatched — and stored / shown / appended — twice. Drop anything at or
1544
+ // below the receive low-water mark, like toxcore net_crypto drops packets
1545
+ // below buffer_start. Must run BEFORE the nonce advance below so a
1546
+ // duplicate doesn't desync the receive nonce.
1547
+ if (opened.packetNumber < (state.receiveBufferStart ?? 0)) {
1548
+ continue;
1549
+ }
1540
1550
  state.peerBaseNonce[state.peerBaseNonce.length - 2] = packet[1];
1541
1551
  state.peerBaseNonce[state.peerBaseNonce.length - 1] = packet[2];
1542
1552
  incrementNonce(state.peerBaseNonce);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
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",