@decentnetwork/peer 0.1.148 → 0.1.150
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 +7 -1
- package/dist/types/peer.d.ts +10 -0
- package/package.json +4 -2
package/dist/peer.js
CHANGED
|
@@ -571,7 +571,13 @@ export class Peer {
|
|
|
571
571
|
if (this.#started) {
|
|
572
572
|
return;
|
|
573
573
|
}
|
|
574
|
-
|
|
574
|
+
// An explicit keypair wins over the file. A browser holds its key in
|
|
575
|
+
// IndexedDB and passes it here; loading from keyFile regardless made the
|
|
576
|
+
// peer run as a DIFFERENT identity than the app thought it had — it
|
|
577
|
+
// announced under one userid, showed the user another, polled express for
|
|
578
|
+
// the wrong inbox, and every friend request sent to the visible userid
|
|
579
|
+
// reached an identity nobody was listening as.
|
|
580
|
+
this.#keyPair = this.#opts.keyPair ?? await loadOrCreateKeyPair(this.#opts.keyFile);
|
|
575
581
|
this.#bootstrap = new LegacyBootstrapClient({
|
|
576
582
|
nodes: this.#opts.bootstrapNodes,
|
|
577
583
|
keyPair: this.#keyPair,
|
package/dist/types/peer.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { KeyPair } from "../crypto/keypair.js";
|
|
1
2
|
export type CompatibilityMode = "legacy";
|
|
2
3
|
export type NetworkNode = {
|
|
3
4
|
host: string;
|
|
@@ -99,6 +100,15 @@ export type PeerOptions = {
|
|
|
99
100
|
* waits 30s for a datagram that cannot arrive, and everything downstream
|
|
100
101
|
* of it never runs: self-announce (so nobody can find this peer) and the
|
|
101
102
|
* express pull loop (so offline messages are never collected). */
|
|
103
|
+
/** Use THIS keypair instead of loading one from keyFile.
|
|
104
|
+
*
|
|
105
|
+
* For hosts where the key does not live on a filesystem — a browser holds
|
|
106
|
+
* it in IndexedDB. Without it, start() loaded from keyFile regardless and
|
|
107
|
+
* the peer ran as a DIFFERENT identity than the app believed it was: it
|
|
108
|
+
* announced under one userid while showing the user another, so friend
|
|
109
|
+
* requests sent to the visible one reached nobody and offline mail was
|
|
110
|
+
* polled for the wrong inbox. */
|
|
111
|
+
keyPair?: KeyPair;
|
|
102
112
|
tcpOnlyBootstrap?: boolean;
|
|
103
113
|
/** Turn on peer debug logging without env vars — the only route in from a
|
|
104
114
|
* browser, where process.env does not exist. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.150",
|
|
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",
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
|
-
}
|
|
12
|
+
},
|
|
13
|
+
"./dist/*": "./dist/*",
|
|
14
|
+
"./package.json": "./package.json"
|
|
13
15
|
},
|
|
14
16
|
"bin": {
|
|
15
17
|
"decent-peer": "dist/cli.js"
|