@dsh-mobile/mobile-remote 3.4.1-beta.0 → 3.4.1-beta.1

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.
@@ -422,7 +422,9 @@ class GuestSession {
422
422
  }
423
423
  this.mux.receive(plain);
424
424
  } catch (err) {
425
- this.kick(err instanceof MuxError ? `protocol: ${err.message}` : "bad frame");
425
+
426
+
427
+ this.kick(err instanceof MuxError ? `protocol: ${err.message}` : `bad frame: ${err?.code ?? err?.name ?? "error"}${err?.message ? ` ${err.message}` : ""}`);
426
428
  }
427
429
  }
428
430
 
@@ -448,6 +450,8 @@ class GuestSession {
448
450
 
449
451
  const result = devices.authorize(rs, this.signal || this.standby ? { ...info, otp: undefined } : info);
450
452
  if (!result) return this.kick("unauthorized device");
453
+
454
+ if (result.refused === "full") return this.kick("设备已满:已配对的手机到了上限,配对码未作废", "full");
451
455
  this.device = result.device;
452
456
  const reply = this.noise.writeMessage2(enc.encode(JSON.stringify({ v: 1, ok: true, server: serverName, device: { id: result.device.id, name: result.device.name }, newlyPaired: result.newlyPaired })));
453
457
  this.cipherOut = reply.send;
@@ -540,10 +544,14 @@ class GuestSession {
540
544
 
541
545
 
542
546
 
547
+
543
548
  kick(reason = "kicked", why = "") {
544
549
  if (this.state === "closed") return;
545
550
  this.link.o.log(`relay: 断开访客 ${this.connId.slice(0, 6)}…(${reason})`);
546
- if (this.link.control(why ? { t: "kick", c: this.connId, why } : { t: "kick", c: this.connId })) this.link.pendingKicks.add(this.connId);
551
+
552
+
553
+ const detail = this.link instanceof DirectLink ? { detail: reason } : {};
554
+ if (this.link.control(why ? { t: "kick", c: this.connId, why, ...detail } : { t: "kick", c: this.connId, ...detail })) this.link.pendingKicks?.add(this.connId);
547
555
  this.dispose(reason);
548
556
  }
549
557
  dispose(reason = "closed") {
@@ -567,6 +575,13 @@ class GuestSession {
567
575
 
568
576
 
569
577
 
578
+
579
+ export function closeReason(text) {
580
+ let s = String(text);
581
+ while (Buffer.byteLength(s, "utf8") > 120) s = s.slice(0, -1);
582
+ return s;
583
+ }
584
+
570
585
  class DirectLink {
571
586
  constructor(owner, ws, ip = "") {
572
587
  this.o = owner;
@@ -619,8 +634,8 @@ class DirectLink {
619
634
  control(obj) {
620
635
  if (this.closed) return false;
621
636
  if (obj?.t === "kick") {
622
- const code = obj.why === "busy" ? 4430 : obj.why === "replaced" ? 4409 : 4401;
623
- this.ws.close(code, obj.why || "kicked");
637
+ const code = obj.why === "busy" ? 4430 : obj.why === "replaced" ? 4409 : obj.why === "full" ? 4433 : 4401;
638
+ this.ws.close(code, closeReason(obj.why || obj.detail || "kicked"));
624
639
  return true;
625
640
  }
626
641
  if (obj?.t === "verified") return true;
@@ -144,6 +144,8 @@ export class DeviceStore {
144
144
 
145
145
 
146
146
 
147
+
148
+
147
149
  authorize(pub, info = {}) {
148
150
  const known = this.find(pub);
149
151
  if (known) {
@@ -167,8 +169,9 @@ export class DeviceStore {
167
169
  const key = hex(sha256(otp));
168
170
  const entry = this.otps.get(key);
169
171
  if (!entry) return null;
172
+
173
+ if (this.devices.length >= this.maxDevices) return { refused: "full" };
170
174
  this.otps.delete(key);
171
- if (this.devices.length >= this.maxDevices) return null;
172
175
  const device = {
173
176
  id: fingerprint(pub),
174
177
  name: cleanName(info.name ?? entry.name),
@@ -205,7 +205,7 @@ export function connectPhone({ relayUrl, room, pcPub, device, name = "Phone", ot
205
205
  phone._shutdown(e.code ?? 1006, e.reason ?? "");
206
206
  if (!opened) {
207
207
  clearTimeout(timer);
208
- reject(Object.assign(new Error(`relay closed during ${stage} (${e.code})`), { code: e.code }));
208
+ reject(Object.assign(new Error(`relay closed during ${stage} (${e.code})`), { code: e.code, reason: e.reason }));
209
209
  }
210
210
  });
211
211
  ws.addEventListener("error", () => {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-mobile/mobile-remote",
3
- "version": "3.4.1-beta.0",
3
+ "version": "3.4.1-beta.1",
4
4
  "description": "DSH Mobile:把 DeepSeek Harness 变成随身控制台——手机远程发消息派活、看进度、收通知、审批决策、管理会话;配套 Flutter App(Android、iPhone / iPad)",
5
5
  "homepage": "https://dsh.claud.ing/",
6
6
  "repository": {