adhdev 0.9.10 → 0.9.11

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/cli/index.js CHANGED
@@ -78282,6 +78282,7 @@ var init_server_connection = __esm({
78282
78282
  reconnectTimer = null;
78283
78283
  pingTimer = null;
78284
78284
  pongTimeout = null;
78285
+ authTimeout = null;
78285
78286
  missedPongCount = 0;
78286
78287
  messageHandlers = /* @__PURE__ */ new Map();
78287
78288
  stateChangeCallbacks = [];
@@ -78291,6 +78292,9 @@ var init_server_connection = __esm({
78291
78292
  iceServers = null;
78292
78293
  planLimits = null;
78293
78294
  compatBlocked = false;
78295
+ get authTimeoutMs() {
78296
+ return Math.max(1, this.options.authTimeoutMs ?? 15e3);
78297
+ }
78294
78298
  constructor(options) {
78295
78299
  this.options = options;
78296
78300
  }
@@ -78393,6 +78397,7 @@ var init_server_connection = __esm({
78393
78397
  },
78394
78398
  timestamp: Date.now()
78395
78399
  });
78400
+ this.startAuthTimeout();
78396
78401
  }
78397
78402
  onMessage(text) {
78398
78403
  try {
@@ -78400,6 +78405,7 @@ var init_server_connection = __esm({
78400
78405
  this.missedPongCount = 0;
78401
78406
  const message = JSON.parse(text);
78402
78407
  if (message.type === "auth_ok") {
78408
+ this.clearAuthTimeout();
78403
78409
  this.reconnectAttempts = 0;
78404
78410
  this.compatBlocked = false;
78405
78411
  const payload = message.payload;
@@ -78414,6 +78420,7 @@ var init_server_connection = __esm({
78414
78420
  LOG.info("Server", `[ServerConn] \u2713 Authenticated (plan: ${this.userPlan})`);
78415
78421
  this.startHeartbeat();
78416
78422
  } else if (message.type === "auth_error") {
78423
+ this.clearAuthTimeout();
78417
78424
  LOG.error("Server", `Auth failed: ${message.payload.reason}`);
78418
78425
  this.setState("error");
78419
78426
  return;
@@ -78508,9 +78515,25 @@ var init_server_connection = __esm({
78508
78515
  clearTimeout(this.reconnectTimer);
78509
78516
  this.reconnectTimer = null;
78510
78517
  }
78518
+ this.clearAuthTimeout();
78511
78519
  this.stopHeartbeat();
78512
78520
  this.missedPongCount = 0;
78513
78521
  }
78522
+ startAuthTimeout() {
78523
+ this.clearAuthTimeout();
78524
+ this.authTimeout = setTimeout(() => {
78525
+ this.authTimeout = null;
78526
+ if (this.state !== "authenticating" || !this.ws) return;
78527
+ LOG.warn("Server", `[ServerConn] Auth timeout after ${(this.authTimeoutMs / 1e3).toFixed(1)}s \u2014 reconnecting`);
78528
+ this.ws.terminate();
78529
+ }, this.authTimeoutMs);
78530
+ }
78531
+ clearAuthTimeout() {
78532
+ if (this.authTimeout) {
78533
+ clearTimeout(this.authTimeout);
78534
+ this.authTimeout = null;
78535
+ }
78536
+ }
78514
78537
  // ─── WS Heartbeat (ping/pong) ─────────────────────
78515
78538
  startHeartbeat() {
78516
78539
  this.stopHeartbeat();
@@ -87093,7 +87116,7 @@ var init_adhdev_daemon = __esm({
87093
87116
  init_version();
87094
87117
  init_src();
87095
87118
  init_runtime_defaults();
87096
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.10" });
87119
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.11" });
87097
87120
  AdhdevDaemon = class _AdhdevDaemon {
87098
87121
  localHttpServer = null;
87099
87122
  localWss = null;