@decentnetwork/peer 0.1.33 → 0.1.34

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 CHANGED
@@ -2671,7 +2671,12 @@ export class Peer {
2671
2671
  // re-punch survive a UDP outage. Brief UDP gaps just drop a few data
2672
2672
  // packets (the proxied TCP stream retransmits) and the re-punch loop
2673
2673
  // restores the direct path within a few seconds.
2674
- const isBulkData = kind === PACKET_ID_MESSAGE;
2674
+ // Native chat (64) is always bulk; an app can register one extra custom
2675
+ // id (decentlan's IP channel = 163) via bulkDataPacketId so its
2676
+ // high-volume traffic gets the same single-transport routing instead of
2677
+ // fanning out over UDP + relay + TCP relay (which delivers 3-4 duplicates).
2678
+ const isBulkData = kind === PACKET_ID_MESSAGE ||
2679
+ (this.#opts.bulkDataPacketId !== undefined && kind === this.#opts.bulkDataPacketId);
2675
2680
  await this.#sendToFriend(friendId, encrypted, session, isBulkData);
2676
2681
  }
2677
2682
  /**
@@ -28,6 +28,18 @@ export type PeerOptions = {
28
28
  * apps that genuinely want offline message delivery leave it false.
29
29
  */
30
30
  expressControlPlaneOnly?: boolean;
31
+ /**
32
+ * Custom packet id carrying the app's high-volume "bulk data" stream
33
+ * (e.g. decentlan's IP-forwarding channel). Packets sent on this id get
34
+ * the same single-transport routing as native chat (PACKET_ID_MESSAGE):
35
+ * they ride the fresh direct UDP path exclusively, or bridge over the
36
+ * relay when it's stale — instead of fanning out over UDP + relay + TCP
37
+ * relay at once (which delivers 3-4 duplicates of every packet and backs
38
+ * up the relay). Apps that put bulk traffic on a custom id (decentlan
39
+ * uses 163) MUST set this so the SDK recognises it; otherwise the bulk
40
+ * optimisation only applies to packet 64 and custom-id data is duplicated.
41
+ */
42
+ bulkDataPacketId?: number;
31
43
  compatibilityMode?: CompatibilityMode;
32
44
  debugLabel?: string;
33
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
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",