@decentnetwork/peer 0.1.30 → 0.1.32
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 +17 -2
- package/dist/types/peer.d.ts +11 -0
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -586,7 +586,18 @@ export class Peer {
|
|
|
586
586
|
const routes = await this.#discoverFriendRoutes(friendAddress.publicKey);
|
|
587
587
|
this.#debugLog(`friend route discovery done routes=${routes.length}`);
|
|
588
588
|
if (routes.length === 0) {
|
|
589
|
-
|
|
589
|
+
// The direct net_crypto send needs a known endpoint for the target; to
|
|
590
|
+
// a peer we've never connected to (a dora, an exit) it throws. The old
|
|
591
|
+
// code `await`ed it bare, so that throw skipped the express push below
|
|
592
|
+
// and the friend-request never went out by ANY channel — the exact
|
|
593
|
+
// reason callpass never reached dora-mac. Make it best-effort so the
|
|
594
|
+
// express fallback always runs.
|
|
595
|
+
try {
|
|
596
|
+
await this.#sendDirectCryptoFriendRequest(friendAddress.publicKey, friendReqPayload);
|
|
597
|
+
}
|
|
598
|
+
catch (error) {
|
|
599
|
+
this.#debugLog(`direct crypto friend-request to ${friendId} failed: ${error.message}`);
|
|
600
|
+
}
|
|
590
601
|
this.#lastFriendRequestDispatch = {
|
|
591
602
|
transport: "direct",
|
|
592
603
|
routes: 0,
|
|
@@ -840,7 +851,11 @@ export class Peer {
|
|
|
840
851
|
return;
|
|
841
852
|
}
|
|
842
853
|
// Offline / fallback path via Carrier express HTTP store-and-forward.
|
|
843
|
-
|
|
854
|
+
// Skipped entirely in control-plane-only mode (decentlan's data plane):
|
|
855
|
+
// a VPN-style daemon must fail fast when a friend is offline rather than
|
|
856
|
+
// silently queue IP packets into HTTPS storage that never get forwarded
|
|
857
|
+
// in real time. Express there is reserved for friend-request bootstrap.
|
|
858
|
+
if (this.#express?.hasNodes() && !this.#opts.expressControlPlaneOnly) {
|
|
844
859
|
await this.#express.sendOfflineText(pubkey, packet);
|
|
845
860
|
this.#debugLog(`sendText: queued via express for ${pubkey}`);
|
|
846
861
|
return;
|
package/dist/types/peer.d.ts
CHANGED
|
@@ -17,6 +17,17 @@ export type PeerOptions = {
|
|
|
17
17
|
friendStoreFile?: string;
|
|
18
18
|
bootstrapNodes: NetworkNode[];
|
|
19
19
|
expressNodes?: NetworkNode[];
|
|
20
|
+
/**
|
|
21
|
+
* When true, the express relay is used ONLY for friend-request
|
|
22
|
+
* bootstrap (a one-time control-plane handshake) and NEVER as a
|
|
23
|
+
* fallback for runtime `sendText` data. This lets a VPN-style data
|
|
24
|
+
* plane stay fail-fast (an offline friend surfaces as offline, IP
|
|
25
|
+
* packets don't silently pile into HTTPS store-and-forward) while
|
|
26
|
+
* still letting the initial friend-request reach a peer whose onion
|
|
27
|
+
* announce hasn't propagated. decentlan's daemon sets this; chat-style
|
|
28
|
+
* apps that genuinely want offline message delivery leave it false.
|
|
29
|
+
*/
|
|
30
|
+
expressControlPlaneOnly?: boolean;
|
|
20
31
|
compatibilityMode?: CompatibilityMode;
|
|
21
32
|
debugLabel?: string;
|
|
22
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
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",
|