livedesk 0.1.63 → 0.1.64

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/bin/livedesk.js CHANGED
@@ -55,7 +55,7 @@ Usage:
55
55
  npx -y livedesk client 3
56
56
 
57
57
  Default flow:
58
- Opens Google sign-in, waits for the signed-in LiveDesk Hub, and connects locally.
58
+ Opens a LiveDesk connection page with Google sign-in or a 6-digit PIN.
59
59
  Omit the number for first-available placement, or pass 1-999 to pin a slot.
60
60
 
61
61
  Common options:
@@ -157,6 +157,10 @@ function safeString(value, maxLength = 200) {
157
157
  return String(value ?? '').replace(/[\r\n\t]/g, ' ').trim().slice(0, maxLength);
158
158
  }
159
159
 
160
+ function generatePairingPin() {
161
+ return crypto.randomInt(0, 1000000).toString().padStart(6, '0');
162
+ }
163
+
160
164
  function normalizeRemoteFrameMode(value, fallback = DEFAULT_REMOTE_FRAME_MODE, { allowUnimplemented = false } = {}) {
161
165
  const requested = safeString(value, 80).toLowerCase();
162
166
  const fallbackMode = REMOTE_FRAME_MODE_PROFILES[fallback] ? fallback : DEFAULT_REMOTE_FRAME_MODE;
@@ -1179,6 +1183,10 @@ export function createRemoteHub(options = {}) {
1179
1183
  const pairToken = safeString(
1180
1184
  options.pairToken || env.REMOTE_HUB_PAIR_TOKEN || env.LIVEDESK_CLIENT_PAIR_TOKEN || env.MINDEXEC_REMOTE_PAIR_TOKEN || crypto.randomBytes(6).toString('hex'),
1181
1185
  256);
1186
+ let pairingPin = /^\d{6}$/.test(String(options.pairingPin || env.LIVEDESK_PAIRING_PIN || '').trim())
1187
+ ? String(options.pairingPin || env.LIVEDESK_PAIRING_PIN).trim()
1188
+ : generatePairingPin();
1189
+ let pairingPinUpdatedAt = new Date().toISOString();
1182
1190
  const duplicateDeviceLogThrottleMs = clampNumber(
1183
1191
  env.MINDEXEC_REMOTE_DUPLICATE_DEVICE_LOG_MS || env.REMOTE_HUB_DUPLICATE_DEVICE_LOG_MS,
1184
1192
  5000,
@@ -1511,6 +1519,8 @@ export function createRemoteHub(options = {}) {
1511
1519
  agentEndpointCandidateDetails: routeInfo.candidateDetails,
1512
1520
  pairToken: includeSecrets ? pairToken : undefined,
1513
1521
  pairTokenPreview: maskToken(pairToken),
1522
+ pairingPin: includeSecrets ? pairingPin : '',
1523
+ pairingPinUpdatedAt,
1514
1524
  deviceCount: devices.size,
1515
1525
  connectedDeviceCount: connectedDevices,
1516
1526
  canvasDeviceListMode: 'all-devices',
@@ -1532,6 +1542,19 @@ export function createRemoteHub(options = {}) {
1532
1542
  };
1533
1543
  }
1534
1544
 
1545
+ function rotatePairingPin() {
1546
+ pairingPin = generatePairingPin();
1547
+ pairingPinUpdatedAt = new Date().toISOString();
1548
+ emitRemoteEvent('RemotePairingPinRotated', null, {
1549
+ pairingPinUpdatedAt
1550
+ });
1551
+ return {
1552
+ ok: true,
1553
+ pairingPin,
1554
+ pairingPinUpdatedAt
1555
+ };
1556
+ }
1557
+
1535
1558
  function listDevices(options = {}) {
1536
1559
  const serializeOptions = {
1537
1560
  includeDataUrl: options.includeDataUrl === true
@@ -4111,6 +4134,7 @@ export function createRemoteHub(options = {}) {
4111
4134
  requestAgentTask,
4112
4135
  requestAgentTaskBatch,
4113
4136
  setHostTarget,
4137
+ rotatePairingPin,
4114
4138
  requestThumbnail,
4115
4139
  startLiveStream,
4116
4140
  stopLiveStream,
@@ -4121,7 +4145,8 @@ export function createRemoteHub(options = {}) {
4121
4145
  getFramePayload,
4122
4146
  seedSyntheticFleet,
4123
4147
  clearSyntheticFleet,
4124
- getPairToken: () => pairToken
4148
+ getPairToken: () => pairToken,
4149
+ getPairingPin: () => pairingPin
4125
4150
  };
4126
4151
  }
4127
4152
 
package/hub/src/server.js CHANGED
@@ -395,6 +395,15 @@ app.get('/api/remote/status', (_req, res) => {
395
395
  });
396
396
  });
397
397
 
398
+ app.post('/api/remote/pairing-pin', (_req, res) => {
399
+ noStore(res);
400
+ try {
401
+ res.json(remoteHub.rotatePairingPin());
402
+ } catch (err) {
403
+ res.status(500).json({ ok: false, error: err instanceof Error ? err.message : String(err) });
404
+ }
405
+ });
406
+
398
407
  app.get('/api/remote/devices', (req, res) => {
399
408
  noStore(res);
400
409
  const includeDataUrl = /^(1|true|yes|on|data|base64)$/i.test(String(req.query?.includeDataUrl ?? ''));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livedesk",
3
- "version": "0.1.63",
3
+ "version": "0.1.64",
4
4
  "description": "LiveDesk Hub and client launcher",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "node": ">=20"
31
31
  },
32
32
  "dependencies": {
33
- "@livedesk/client": "0.1.48",
33
+ "@livedesk/client": "0.1.49",
34
34
  "cors": "^2.8.5",
35
35
  "express": "^4.21.2",
36
36
  "ws": "^8.18.3"