@buoy-gg/sync-broker 7.0.22 → 7.0.23

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/index.d.mts CHANGED
@@ -152,6 +152,11 @@ interface DevToolActionMessage {
152
152
  action: string;
153
153
  params?: unknown;
154
154
  }
155
+ /**
156
+ * A client's access tier. Mirrors `BuoyTier` in @buoy-gg/license; redeclared
157
+ * here because the broker is a standalone node process with no client deps.
158
+ */
159
+ type BuoyTier = "anonymous" | "free" | "pro";
155
160
  /**
156
161
  * A connected client (device or dashboard) as tracked by the broker.
157
162
  * Mirrors the desktop dashboard's `User` type; the dashboard UI carries a few
@@ -180,9 +185,23 @@ interface User {
180
185
  lastDisconnectReason?: string;
181
186
  /** Epoch ms of the last connect/reconnect/disconnect; drives age-out. */
182
187
  lastSeenAt?: number;
183
- /** Whether the device announced an active Buoy Pro license. */
188
+ /**
189
+ * Whether the device announced an active Buoy **Pro** license.
190
+ * Equivalent to `tier === "pro"`; kept as the wire field older clients send.
191
+ */
184
192
  isPro?: boolean;
185
- /** The device's Buoy Pro license key, if any. Local dev connection only. */
193
+ /**
194
+ * The device's access tier. Absent from clients older than the tier split —
195
+ * derive it from `isPro` in that case (see `tierFromLicensePayload`).
196
+ */
197
+ tier?: BuoyTier;
198
+ /**
199
+ * The device's Buoy license key, if any. Local dev connection only.
200
+ *
201
+ * Forwarded for free keys too, not just Pro ones, so the desktop dashboard
202
+ * can mirror the device's tier instead of sitting at anonymous while the
203
+ * phone it is attached to is signed in.
204
+ */
186
205
  licenseKey?: string;
187
206
  }
188
207
 
package/dist/index.d.ts CHANGED
@@ -152,6 +152,11 @@ interface DevToolActionMessage {
152
152
  action: string;
153
153
  params?: unknown;
154
154
  }
155
+ /**
156
+ * A client's access tier. Mirrors `BuoyTier` in @buoy-gg/license; redeclared
157
+ * here because the broker is a standalone node process with no client deps.
158
+ */
159
+ type BuoyTier = "anonymous" | "free" | "pro";
155
160
  /**
156
161
  * A connected client (device or dashboard) as tracked by the broker.
157
162
  * Mirrors the desktop dashboard's `User` type; the dashboard UI carries a few
@@ -180,9 +185,23 @@ interface User {
180
185
  lastDisconnectReason?: string;
181
186
  /** Epoch ms of the last connect/reconnect/disconnect; drives age-out. */
182
187
  lastSeenAt?: number;
183
- /** Whether the device announced an active Buoy Pro license. */
188
+ /**
189
+ * Whether the device announced an active Buoy **Pro** license.
190
+ * Equivalent to `tier === "pro"`; kept as the wire field older clients send.
191
+ */
184
192
  isPro?: boolean;
185
- /** The device's Buoy Pro license key, if any. Local dev connection only. */
193
+ /**
194
+ * The device's access tier. Absent from clients older than the tier split —
195
+ * derive it from `isPro` in that case (see `tierFromLicensePayload`).
196
+ */
197
+ tier?: BuoyTier;
198
+ /**
199
+ * The device's Buoy license key, if any. Local dev connection only.
200
+ *
201
+ * Forwarded for free keys too, not just Pro ones, so the desktop dashboard
202
+ * can mirror the device's tier instead of sitting at anonymous while the
203
+ * phone it is attached to is signed in.
204
+ */
186
205
  licenseKey?: string;
187
206
  }
188
207
 
package/dist/index.js CHANGED
@@ -40,6 +40,12 @@ module.exports = __toCommonJS(index_exports);
40
40
 
41
41
  // src/protocol.ts
42
42
  var SYNC_PROTOCOL_VERSION = 1;
43
+ function tierFromLicensePayload(payload) {
44
+ if (payload?.tier === "pro" || payload?.tier === "free" || payload?.tier === "anonymous") {
45
+ return payload.tier;
46
+ }
47
+ return payload?.isPro === "1" || payload?.isPro === true ? "pro" : "anonymous";
48
+ }
43
49
 
44
50
  // src/watchRegistry.ts
45
51
  var toWatchKey = (targetDeviceId, toolId) => JSON.stringify([targetDeviceId, toolId]);
@@ -448,24 +454,27 @@ function socketHandle({ io }) {
448
454
  socket.on(
449
455
  "device-license",
450
456
  (payload) => {
451
- const nextIsPro = payload?.isPro === "1" || payload?.isPro === true;
452
- const nextKey = payload?.licenseKey || void 0;
457
+ const nextTier = tierFromLicensePayload(payload ?? {});
458
+ const nextIsPro = nextTier === "pro";
459
+ const nextKey = nextTier === "anonymous" ? void 0 : payload?.licenseKey || void 0;
453
460
  const user = users.find((u) => u.id === socket.id);
454
461
  if (user) {
455
462
  user.isPro = nextIsPro;
456
- user.licenseKey = nextIsPro ? nextKey : void 0;
463
+ user.tier = nextTier;
464
+ user.licenseKey = nextKey;
457
465
  }
458
466
  const did = user?.deviceId || deviceIdMap.get(socket.id);
459
467
  if (did) {
460
468
  const device = allDevices.find((d) => d.deviceId === did);
461
469
  if (device) {
462
470
  device.isPro = nextIsPro;
463
- device.licenseKey = nextIsPro ? nextKey : void 0;
471
+ device.tier = nextTier;
472
+ device.licenseKey = nextKey;
464
473
  }
465
474
  }
466
475
  brokerLog(
467
476
  "debug",
468
- `device-license from ${user?.deviceName || socket.id}: isPro=${nextIsPro}${nextKey ? ", key set" : ""}`,
477
+ `device-license from ${user?.deviceName || socket.id}: tier=${nextTier}${nextKey ? ", key set" : ""}`,
469
478
  { socketId: socket.id }
470
479
  );
471
480
  emitAllDevices();
package/dist/index.mjs CHANGED
@@ -1,5 +1,11 @@
1
1
  // src/protocol.ts
2
2
  var SYNC_PROTOCOL_VERSION = 1;
3
+ function tierFromLicensePayload(payload) {
4
+ if (payload?.tier === "pro" || payload?.tier === "free" || payload?.tier === "anonymous") {
5
+ return payload.tier;
6
+ }
7
+ return payload?.isPro === "1" || payload?.isPro === true ? "pro" : "anonymous";
8
+ }
3
9
 
4
10
  // src/watchRegistry.ts
5
11
  var toWatchKey = (targetDeviceId, toolId) => JSON.stringify([targetDeviceId, toolId]);
@@ -408,24 +414,27 @@ function socketHandle({ io }) {
408
414
  socket.on(
409
415
  "device-license",
410
416
  (payload) => {
411
- const nextIsPro = payload?.isPro === "1" || payload?.isPro === true;
412
- const nextKey = payload?.licenseKey || void 0;
417
+ const nextTier = tierFromLicensePayload(payload ?? {});
418
+ const nextIsPro = nextTier === "pro";
419
+ const nextKey = nextTier === "anonymous" ? void 0 : payload?.licenseKey || void 0;
413
420
  const user = users.find((u) => u.id === socket.id);
414
421
  if (user) {
415
422
  user.isPro = nextIsPro;
416
- user.licenseKey = nextIsPro ? nextKey : void 0;
423
+ user.tier = nextTier;
424
+ user.licenseKey = nextKey;
417
425
  }
418
426
  const did = user?.deviceId || deviceIdMap.get(socket.id);
419
427
  if (did) {
420
428
  const device = allDevices.find((d) => d.deviceId === did);
421
429
  if (device) {
422
430
  device.isPro = nextIsPro;
423
- device.licenseKey = nextIsPro ? nextKey : void 0;
431
+ device.tier = nextTier;
432
+ device.licenseKey = nextKey;
424
433
  }
425
434
  }
426
435
  brokerLog(
427
436
  "debug",
428
- `device-license from ${user?.deviceName || socket.id}: isPro=${nextIsPro}${nextKey ? ", key set" : ""}`,
437
+ `device-license from ${user?.deviceName || socket.id}: tier=${nextTier}${nextKey ? ", key set" : ""}`,
429
438
  { socketId: socket.id }
430
439
  );
431
440
  emitAllDevices();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/sync-broker",
3
- "version": "7.0.22",
3
+ "version": "7.0.23",
4
4
  "description": "Headless Socket.IO broker for the Buoy devtool sync protocol (v1) — routes messages between devices and dashboard/MCP clients",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",