@decentnetwork/beagle 0.1.69 → 0.1.71

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.
@@ -91,9 +91,13 @@ export declare class CarrierNode extends EventEmitter {
91
91
  sessionStatus(pubkey: string): unknown;
92
92
  dhtHealth(): unknown;
93
93
  sendText(userid: string, text: string): Promise<void>;
94
- sendFriendRequest(address: string, hello?: string): Promise<void>;
94
+ sendFriendRequest(address: string, hello?: string, opts?: {
95
+ force?: boolean;
96
+ }): Promise<void>;
95
97
  acceptFriendRequest(pubkey: string): Promise<void>;
96
98
  removeFriend(userid: string): boolean;
99
+ /** Decline an inbound request and clear what it created in the SDK. */
100
+ rejectFriendRequest(pubkey: string): void;
97
101
  setUserInfo(info: {
98
102
  name?: string;
99
103
  description?: string;
@@ -180,8 +180,8 @@ export class CarrierNode extends EventEmitter {
180
180
  sendText(userid, text) {
181
181
  return this.#require().sendText(userid, text);
182
182
  }
183
- sendFriendRequest(address, hello) {
184
- return this.#require().sendFriendRequest(address, hello);
183
+ sendFriendRequest(address, hello, opts) {
184
+ return this.#require().sendFriendRequest(address, hello, opts);
185
185
  }
186
186
  acceptFriendRequest(pubkey) {
187
187
  return this.#require().acceptFriendRequest(pubkey);
@@ -189,6 +189,10 @@ export class CarrierNode extends EventEmitter {
189
189
  removeFriend(userid) {
190
190
  return this.#require().removeFriend(userid);
191
191
  }
192
+ /** Decline an inbound request and clear what it created in the SDK. */
193
+ rejectFriendRequest(pubkey) {
194
+ this.#require().rejectFriendRequest(pubkey);
195
+ }
192
196
  setUserInfo(info) {
193
197
  this.#require().setUserInfo(info);
194
198
  }
@@ -1,4 +1,4 @@
1
- window.__DK_UI_VERSION="0.1.69";
1
+ window.__DK_UI_VERSION="0.1.71";
2
2
  "use strict";
3
3
  (() => {
4
4
  // packages/beagle-ui/dist/beagle-ui.js
@@ -474,7 +474,12 @@ export class EmbeddedHost {
474
474
  if (!address)
475
475
  throw new Error("friend-request requires an address");
476
476
  void this.#node
477
- .sendFriendRequest(address, req.hello)
477
+ // force: this op only runs because a person pressed Add. The SDK's
478
+ // idempotency guard is for automatic retries; here it would silently
479
+ // swallow the one case that needs to get through — re-adding someone
480
+ // whose earlier request was rejected, where the two sides' notions
481
+ // of "friend" have come apart and only a real send can fix it.
482
+ .sendFriendRequest(address, req.hello, { force: true })
478
483
  .catch((e) => this.#logger.info(`friend-request to ${address.slice(0, 8)} failed: ${e.message}`));
479
484
  return {};
480
485
  }
@@ -499,9 +504,23 @@ export class EmbeddedHost {
499
504
  }
500
505
  return {};
501
506
  }
502
- case "friends-reject":
507
+ case "friends-reject": {
508
+ // Read BEFORE deleting — the pubkey is what the SDK is keyed on.
509
+ const entry = this.#pending.get(uid);
503
510
  this.#pending.delete(uid);
511
+ // Tell the PEER too. Dropping only this map left the SDK holding the
512
+ // friend record the request created, so the next request from that
513
+ // person hit its "already a friend — treat as reconnection" path and
514
+ // was swallowed before the app ever saw it. Reject once and they could
515
+ // never reach you again, with nothing on either side saying why.
516
+ try {
517
+ this.#node.rejectFriendRequest(entry?.pubkey ?? uid);
518
+ }
519
+ catch (e) {
520
+ this.#logger.info(`reject cleanup failed for ${uid}: ${e.message}`);
521
+ }
504
522
  return {};
523
+ }
505
524
  case "friends-autoaccept": {
506
525
  // Without an explicit boolean this is a READ — a bare call must never
507
526
  // flip the switch off (Boolean(undefined) === false).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/beagle",
3
- "version": "0.1.69",
3
+ "version": "0.1.71",
4
4
  "description": "Beagle — P2P chat, file transfer and calls for regular users, on the Decent Network. No admin privilege required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -27,9 +27,10 @@
27
27
  "dependencies": {
28
28
  "@decentnetwork/chat-components": "^0.1.3",
29
29
  "@decentnetwork/lan": "^0.1.283",
30
- "@decentnetwork/peer": "0.1.151",
30
+ "@decentnetwork/peer": "0.1.152",
31
31
  "@decentnetwork/peer-webrtc": "^0.2.16",
32
32
  "js-yaml": "^4.1.0",
33
+ "ws": "^8.21.1",
33
34
  "yargs": "^17.7.2"
34
35
  },
35
36
  "devDependencies": {