@decentnetwork/peer 0.1.145 → 0.1.146

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.
@@ -12,6 +12,7 @@ export declare class LegacyExpressClient {
12
12
  selfUserId: string;
13
13
  selfAddress: string;
14
14
  callbacks: PullCallbacks;
15
+ debug?: boolean;
15
16
  });
16
17
  hasNodes(): boolean;
17
18
  sendOfflineFriendRequest(address: string, hello: Uint8Array): Promise<void>;
@@ -12,8 +12,13 @@ export class LegacyExpressClient {
12
12
  #selfAddress;
13
13
  #currNode = 0;
14
14
  #callbacks;
15
+ // Own gate, and env-only until now — so in a browser this client was mute
16
+ // whatever the peer's debug setting was. That is why a stalled pull looked
17
+ // identical to a pull that never ran.
15
18
  #debug = process.env.DECENT_DEBUG === "1";
16
19
  constructor(opts) {
20
+ if (opts.debug)
21
+ this.#debug = true;
17
22
  this.#selfKeyPair = opts.selfKeyPair;
18
23
  this.#selfUserId = opts.selfUserId;
19
24
  this.#selfAddress = opts.selfAddress;
@@ -63,8 +68,12 @@ export class LegacyExpressClient {
63
68
  try {
64
69
  body = await this.#http(node, "GET", encodeURIComponent(this.#selfUserId));
65
70
  }
66
- catch {
67
- continue; // relay unreachable right now try the next
71
+ catch (error) {
72
+ // Say so. Swallowing this made an unreachable relay indistinguishable
73
+ // from an empty inbox, and offline mail piled up on the server with
74
+ // nothing anywhere reporting why.
75
+ this.#debugLog(`pull from ${node.host}:${node.port} failed: ${error?.message ?? error}`);
76
+ continue;
68
77
  }
69
78
  const messages = parseExpressResponseFrames(body);
70
79
  if (messages.length === 0) {
package/dist/peer.js CHANGED
@@ -598,6 +598,7 @@ export class Peer {
598
598
  selfKeyPair: this.#keyPair,
599
599
  selfUserId: this.userid(),
600
600
  selfAddress: this.address(),
601
+ debug: this.#debug,
601
602
  callbacks: {
602
603
  onOfflineFriendRequest: (fromUserId, packet) => {
603
604
  this.#emitOfflineFriendRequest(fromUserId, packet);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.145",
3
+ "version": "0.1.146",
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",