@decentnetwork/peer 0.1.41 → 0.1.42

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 CHANGED
@@ -147,4 +147,34 @@ export declare class Peer {
147
147
  cookieRequestSentMs: number | null;
148
148
  } | null;
149
149
  waitForFriendRequest(timeoutMs?: number): Promise<FriendRequest>;
150
+ /**
151
+ * After a friend sends us PACKET_ID_ONLINE, push our nickname + status
152
+ * message so their UI replaces "unknown" with our actual display name,
153
+ * and optionally fire off a configured greeting message. Idempotent —
154
+ * tracked per friend so we don't spam every keepalive cycle.
155
+ *
156
+ * Sends are sequenced with small delays so the receiving peer's UI layer
157
+ * doesn't process three messenger packets in the same render frame —
158
+ * iOS Beagle 1.8.6 has a SwiftUI use-after-free in
159
+ * `_UIHostingView.beginTransaction()` when nickname / status / message
160
+ * arrive in rapid succession at session establishment, observed as
161
+ * EXC_BAD_ACCESS in the iOS app's main thread.
162
+ */
163
+ /**
164
+ * Update our own profile (display name / status-message description) at
165
+ * runtime and re-push it to friends. `name` maps to the toxcore nickname
166
+ * (PACKET_ID_NICKNAME) and the Carrier USERINFO `name`; `description` maps to
167
+ * the USERINFO descr / status message. Re-arms the per-friend "profile sent"
168
+ * flag so every friend receives the update, and proactively pushes to anyone
169
+ * currently online. The greeting is NOT re-sent (its flag is left intact).
170
+ */
171
+ setUserInfo(info: {
172
+ name?: string;
173
+ description?: string;
174
+ }): void;
175
+ /** Our current display name + status-message description. */
176
+ userInfo(): {
177
+ name: string;
178
+ description: string;
179
+ };
150
180
  }
package/dist/peer.js CHANGED
@@ -2832,6 +2832,34 @@ export class Peer {
2832
2832
  * arrive in rapid succession at session establishment, observed as
2833
2833
  * EXC_BAD_ACCESS in the iOS app's main thread.
2834
2834
  */
2835
+ /**
2836
+ * Update our own profile (display name / status-message description) at
2837
+ * runtime and re-push it to friends. `name` maps to the toxcore nickname
2838
+ * (PACKET_ID_NICKNAME) and the Carrier USERINFO `name`; `description` maps to
2839
+ * the USERINFO descr / status message. Re-arms the per-friend "profile sent"
2840
+ * flag so every friend receives the update, and proactively pushes to anyone
2841
+ * currently online. The greeting is NOT re-sent (its flag is left intact).
2842
+ */
2843
+ setUserInfo(info) {
2844
+ const opts = this.#opts;
2845
+ if (info.name !== undefined)
2846
+ opts.nickname = info.name;
2847
+ if (info.description !== undefined)
2848
+ opts.statusMessage = info.description;
2849
+ this.#profileSentTo.clear();
2850
+ for (const [friendId, s] of this.#friendSessions.entries()) {
2851
+ if (s.established)
2852
+ this.#sendProfileAndGreeting(friendId);
2853
+ }
2854
+ }
2855
+ /** Our current display name + status-message description. */
2856
+ userInfo() {
2857
+ const opts = this.#opts;
2858
+ return {
2859
+ name: opts.nickname ?? PEER_NICKNAME,
2860
+ description: opts.statusMessage ?? PEER_STATUS_MESSAGE,
2861
+ };
2862
+ }
2835
2863
  #sendProfileAndGreeting(friendId) {
2836
2864
  if (!this.#profileSentTo.has(friendId)) {
2837
2865
  this.#profileSentTo.add(friendId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
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",