@decentnetwork/peer 0.1.88 → 0.1.89
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.d.ts +1 -0
- package/dist/peer.js +7 -3
- package/package.json +1 -1
package/dist/peer.d.ts
CHANGED
|
@@ -131,6 +131,7 @@ export declare class Peer {
|
|
|
131
131
|
sendInvite(pubkey: string, data: Uint8Array | string, opts?: {
|
|
132
132
|
ext?: string | null;
|
|
133
133
|
bundle?: string;
|
|
134
|
+
establishTimeoutMs?: number;
|
|
134
135
|
}): Promise<bigint>;
|
|
135
136
|
/**
|
|
136
137
|
* Send an application-defined custom packet to a friend. `id` selects the
|
package/dist/peer.js
CHANGED
|
@@ -174,7 +174,7 @@ const AGENTNET_PROTO_VERSION = 1;
|
|
|
174
174
|
// Peer package version, advertised as the default appVersion when the embedder
|
|
175
175
|
// doesn't override it. Read lazily so a bundler that inlines this file doesn't
|
|
176
176
|
// need the package.json at runtime.
|
|
177
|
-
const PEER_PKG_VERSION = "0.1.
|
|
177
|
+
const PEER_PKG_VERSION = "0.1.89";
|
|
178
178
|
// Toxcore Messenger.h packet IDs (live inside encrypted 0x1b crypto data plain payload)
|
|
179
179
|
const PACKET_ID_PADDING = 0;
|
|
180
180
|
const PACKET_ID_REQUEST = 1; // request retransmission of unreceived packets
|
|
@@ -1217,10 +1217,14 @@ export class Peer {
|
|
|
1217
1217
|
// extension the native WebRTC SDK registers under.
|
|
1218
1218
|
const ext = opts.ext === null ? undefined : (opts.ext ?? CARRIER_EXTENSION_NAME);
|
|
1219
1219
|
const bundle = opts.bundle;
|
|
1220
|
+
// How long to wait for a session to (re)establish before giving up. A caller
|
|
1221
|
+
// that wants to FAIL FAST (e.g. to fall back to an offline transport instead
|
|
1222
|
+
// of blocking the UI ~5s per signal) passes establishTimeoutMs: 0.
|
|
1223
|
+
const establishTimeoutMs = opts.establishTimeoutMs ?? 5000;
|
|
1220
1224
|
let session = this.#friendSessions.get(pubkey);
|
|
1221
|
-
if (!session?.established) {
|
|
1225
|
+
if (!session?.established && establishTimeoutMs > 0) {
|
|
1222
1226
|
await this.#initiateSession(pubkey).catch(() => { });
|
|
1223
|
-
const established = await this.#waitForFriendConnected(pubkey,
|
|
1227
|
+
const established = await this.#waitForFriendConnected(pubkey, establishTimeoutMs).catch(() => false);
|
|
1224
1228
|
if (established)
|
|
1225
1229
|
session = this.#friendSessions.get(pubkey);
|
|
1226
1230
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.89",
|
|
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",
|