@livedesk/client 0.1.135 → 0.1.137

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.
@@ -1301,7 +1301,9 @@ function remotePolicyAllows(options, command) {
1301
1301
  ? ['allowFileTransfer']
1302
1302
  : command === 'audio.start'
1303
1303
  ? ['allowRemoteAudio']
1304
- : command === 'agent.task' || command === 'livedesk.client-update' || NODE_AGENT_OPERATIONS.has(command)
1304
+ : command === 'livedesk.client-update'
1305
+ ? []
1306
+ : command === 'agent.task' || NODE_AGENT_OPERATIONS.has(command)
1305
1307
  ? ['allowAgent']
1306
1308
  : [];
1307
1309
  const denied = required.find(key => policy[key] === false);
@@ -1311,37 +1313,39 @@ function remotePolicyAllows(options, command) {
1311
1313
  function scheduleClientUpdate(options, payload = {}) {
1312
1314
  const parentPid = Number(process.env.LIVEDESK_CLIENT_PARENT_PID || process.ppid);
1313
1315
  if (!Number.isInteger(parentPid) || parentPid <= 1) {
1314
- throw new Error('LiveDesk client launcher process id is unavailable.');
1316
+ return Promise.reject(new Error('LiveDesk client launcher process id is unavailable.'));
1315
1317
  }
1316
1318
  const command = process.platform === 'win32' ? 'npx.cmd' : 'npx';
1317
- const child = spawn(command, [
1318
- '-y',
1319
- '--prefer-online',
1320
- 'livedesk@latest',
1321
- 'client',
1322
- '--no-login',
1323
- '--update-wait-pid',
1324
- String(parentPid)
1325
- ], {
1326
- env: {
1327
- ...process.env,
1328
- LIVEDESK_CLIENT_UPDATE_TARGET_VERSION: String(payload.targetVersion || process.env.LIVEDESK_CLIENT_UPDATE_TARGET_VERSION || '')
1329
- },
1330
- detached: true,
1331
- stdio: 'ignore',
1332
- windowsHide: true
1333
- });
1334
- child.once('error', error => {
1335
- console.error(`LiveDesk client updater failed to start: ${error.message}`);
1319
+ return new Promise((resolve, reject) => {
1320
+ const child = spawn(command, [
1321
+ '-y',
1322
+ '--prefer-online',
1323
+ 'livedesk@latest',
1324
+ 'client',
1325
+ '--no-login',
1326
+ '--update-wait-pid',
1327
+ String(parentPid)
1328
+ ], {
1329
+ env: {
1330
+ ...process.env,
1331
+ LIVEDESK_CLIENT_UPDATE_TARGET_VERSION: String(payload.targetVersion || process.env.LIVEDESK_CLIENT_UPDATE_TARGET_VERSION || '')
1332
+ },
1333
+ detached: true,
1334
+ stdio: 'ignore',
1335
+ windowsHide: true
1336
+ });
1337
+ child.once('error', reject);
1338
+ child.once('spawn', () => {
1339
+ child.unref();
1340
+ resolve({
1341
+ ok: true,
1342
+ status: 'update-scheduled',
1343
+ targetVersion: String(payload.targetVersion || ''),
1344
+ parentPid,
1345
+ restartAfterMs: 500
1346
+ });
1347
+ });
1336
1348
  });
1337
- child.unref();
1338
- return {
1339
- ok: true,
1340
- status: 'update-scheduled',
1341
- targetVersion: String(payload.targetVersion || ''),
1342
- parentPid,
1343
- restartAfterMs: 500
1344
- };
1345
1349
  }
1346
1350
 
1347
1351
  async function handleRemoteCommand(socket, options, message, nextFrameSeq, activeStreams) {
@@ -1371,7 +1375,7 @@ async function handleRemoteCommand(socket, options, message, nextFrameSeq, activ
1371
1375
 
1372
1376
  if (command === 'livedesk.client-update') {
1373
1377
  try {
1374
- const result = scheduleClientUpdate(options, message.payload || {});
1378
+ const result = await scheduleClientUpdate(options, message.payload || {});
1375
1379
  writeJsonLine(socket, {
1376
1380
  type: 'command.result',
1377
1381
  commandId: message.commandId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/client",
3
- "version": "0.1.135",
3
+ "version": "0.1.137",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {