@decentnetwork/peer 0.1.143 → 0.1.144
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 +13 -0
- package/dist/types/peer.d.ts +4 -0
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -373,6 +373,10 @@ export class Peer {
|
|
|
373
373
|
#knownNodes;
|
|
374
374
|
#announceDataKey;
|
|
375
375
|
#lastSelfAnnounceMs = 0;
|
|
376
|
+
// Env vars OR an explicit option. A browser has no process.env, so peer
|
|
377
|
+
// debugging there was simply unreachable — which is why the browser client
|
|
378
|
+
// has been a black box every time it misbehaved. The option is the only way
|
|
379
|
+
// in from a page.
|
|
376
380
|
#debug = process.env.DECENT_DEBUG === "1" || process.env.DECENT_DEBUG_VERBOSE === "1";
|
|
377
381
|
#debugVerbose = process.env.DECENT_DEBUG_VERBOSE === "1";
|
|
378
382
|
#packetTrace = process.env.DECENT_PACKET_TRACE === "1";
|
|
@@ -538,6 +542,15 @@ export class Peer {
|
|
|
538
542
|
...opts,
|
|
539
543
|
compatibilityMode: opts.compatibilityMode ?? "legacy"
|
|
540
544
|
};
|
|
545
|
+
// A browser has no process.env, so the env-var switches above can never
|
|
546
|
+
// be set there and peer debugging was unreachable from a page. That is
|
|
547
|
+
// why every browser misbehaviour has had to be diagnosed by inference.
|
|
548
|
+
if (opts.debug)
|
|
549
|
+
this.#debug = true;
|
|
550
|
+
if (opts.debugVerbose) {
|
|
551
|
+
this.#debug = true;
|
|
552
|
+
this.#debugVerbose = true;
|
|
553
|
+
}
|
|
541
554
|
this.#knownNodes = [...opts.bootstrapNodes];
|
|
542
555
|
this.#friendStoreFile = opts.friendStoreFile ?? `${opts.keyFile}.friends.json`;
|
|
543
556
|
// Enable resumable (断点续传) receives when the app gives us a directory to
|
package/dist/types/peer.d.ts
CHANGED
|
@@ -100,6 +100,10 @@ export type PeerOptions = {
|
|
|
100
100
|
* of it never runs: self-announce (so nobody can find this peer) and the
|
|
101
101
|
* express pull loop (so offline messages are never collected). */
|
|
102
102
|
tcpOnlyBootstrap?: boolean;
|
|
103
|
+
/** Turn on peer debug logging without env vars — the only route in from a
|
|
104
|
+
* browser, where process.env does not exist. */
|
|
105
|
+
debug?: boolean;
|
|
106
|
+
debugVerbose?: boolean;
|
|
103
107
|
compatibilityMode?: CompatibilityMode;
|
|
104
108
|
debugLabel?: string;
|
|
105
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.144",
|
|
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",
|