@decentnetwork/peer 0.1.79 → 0.1.82

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.
@@ -14,4 +14,9 @@ export type FriendRecord = {
14
14
  * has been pending. */
15
15
  requestedAt?: number;
16
16
  acceptedAt?: number;
17
+ /** Base58 DHT pubkey the friend last announced (native peers handshake
18
+ * relays with this key, NOT their identity key). Persisted so a restart
19
+ * can immediately park relay ROUTING_REQUESTs under the right key
20
+ * instead of waiting for the friend's next DHT-PK announce. */
21
+ dhtPubkey?: string;
17
22
  };
@@ -11,6 +11,13 @@ export type NetworkNode = {
11
11
  * relays this way in DHT-PK extras.
12
12
  */
13
13
  isTcp?: boolean;
14
+ /** Express relays only: transport scheme. Defaults to HTTPS. Set `false` to
15
+ * reach an express node over plain HTTP — the express payload is already
16
+ * end-to-end encrypted (nacl.secretbox), so HTTP keeps CONTENT private from
17
+ * on-path observers; it does expose the userIDs in the request path. Lets a
18
+ * relay run on a raw IP with no TLS cert / domain / ICP filing, exactly like
19
+ * a bootstrap node. */
20
+ tls?: boolean;
14
21
  /** Decoded 32-byte form of `pk`, cached lazily on first use so the hot
15
22
  * DHT-distance sort (#closestKnownNodes, run on every get_nodes we answer)
16
23
  * doesn't base58-decode the whole table on every call. */
@@ -87,6 +94,10 @@ export type FriendInfoEvent = {
87
94
  export type TextMessage = {
88
95
  pubkey: string;
89
96
  text: string;
97
+ /** Delivery path: "online" = live net_crypto session (direct/relay), "offline"
98
+ * = express store-and-forward. Lets the UI color the two differently so a user
99
+ * can see when online delivery is failing and only offline messages land. */
100
+ via?: "online" | "offline";
90
101
  };
91
102
  /**
92
103
  * An application-defined custom packet received from a friend, over the
@@ -103,6 +114,22 @@ export type CustomPacketEvent = {
103
114
  id: number;
104
115
  data: Uint8Array;
105
116
  };
117
+ /**
118
+ * A file received INLINE over the message channel — the way iOS/C Carrier
119
+ * apps send images/audio online: a FileModel JSON envelope
120
+ * ({data: base64, fileExtension, fileName, type}) carried as a
121
+ * (bulk)message. Distinct from the toxcore file-transfer path (sendFile),
122
+ * which native Carrier clients cannot see.
123
+ */
124
+ export type InlineFileEvent = {
125
+ pubkey: string;
126
+ /** File name including extension. */
127
+ name: string;
128
+ /** The sender's declared type ("image" | "audio" | "text" | …), if any. */
129
+ fileType?: string;
130
+ data: Uint8Array;
131
+ via: "online" | "offline";
132
+ };
106
133
  export type LookupResult = {
107
134
  pubkey: string;
108
135
  status: "unknown";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.79",
3
+ "version": "0.1.82",
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",
@@ -68,7 +68,8 @@
68
68
  "demo:tox-dht-crypto": "pnpm run build && node scripts/tox-dht-crypto-demo.mjs",
69
69
  "test:compat": "pnpm run build && node scripts/compat-selftest.mjs",
70
70
  "smoke:join": "node scripts/smoke-join.mjs",
71
- "typecheck": "tsc -p tsconfig.json --noEmit"
71
+ "typecheck": "tsc -p tsconfig.json --noEmit",
72
+ "test:express": "pnpm run build && node scripts/express-scheme-selftest.mjs"
72
73
  },
73
74
  "dependencies": {
74
75
  "flatbuffers": "^25.9.23",