livedesk 0.1.385 → 0.1.386
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/hub/src/live-desk-update.js +18 -12
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
|
|
3
3
|
export const LIVE_DESK_UPDATE_COMMAND = 'livedesk.client-update';
|
|
4
|
-
// 0.1.
|
|
5
|
-
//
|
|
6
|
-
|
|
4
|
+
// 0.1.170 contains the exact-version, identity-preserving supervised updater.
|
|
5
|
+
// Older dedicated handlers can spawn the new package but cannot prove that the
|
|
6
|
+
// same device returned, so the Hub-owned compatibility bridge upgrades them.
|
|
7
|
+
export const LIVE_DESK_DEDICATED_CLIENT_UPDATE_MIN_VERSION = '0.1.170';
|
|
7
8
|
export const LIVE_DESK_UPDATE_CLIENT_BATCH_SIZE = 5;
|
|
8
9
|
export const LIVE_DESK_UPDATE_TARGET_TIMEOUT_MS = 300_000;
|
|
9
10
|
export const LIVE_DESK_UPDATE_TIMEOUT_MS = 60 * 60_000;
|
|
@@ -68,7 +69,7 @@ function quotePowerShell(value) {
|
|
|
68
69
|
return `'${String(value ?? '').replaceAll("'", "''")}'`;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
function buildWindowsLegacyUpdateCommand({ manager, pair, name, slot, targetVersion, targetProductVersion }) {
|
|
72
|
+
function buildWindowsLegacyUpdateCommand({ manager, pair, name, deviceId, slot, targetVersion, targetProductVersion }) {
|
|
72
73
|
const script = [
|
|
73
74
|
'$ErrorActionPreference = "Stop"',
|
|
74
75
|
'$cursor = Get-CimInstance Win32_Process -Filter ("ProcessId={0}" -f $PID)',
|
|
@@ -86,8 +87,9 @@ function buildWindowsLegacyUpdateCommand({ manager, pair, name, slot, targetVers
|
|
|
86
87
|
'}',
|
|
87
88
|
'if ($launcherPid -le 0) { throw "LiveDesk client launcher process was not found." }',
|
|
88
89
|
`$env:LIVEDESK_CLIENT_MANAGER = ${quotePowerShell(manager)}`,
|
|
89
|
-
`$env:LIVEDESK_CLIENT_PAIR_TOKEN = ${quotePowerShell(pair)}`,
|
|
90
|
-
`$env:LIVEDESK_CLIENT_NAME = ${quotePowerShell(name)}`,
|
|
90
|
+
`$env:LIVEDESK_CLIENT_PAIR_TOKEN = ${quotePowerShell(pair)}`,
|
|
91
|
+
`$env:LIVEDESK_CLIENT_NAME = ${quotePowerShell(name)}`,
|
|
92
|
+
`$env:LIVEDESK_DEVICE_ID = ${quotePowerShell(deviceId)}`,
|
|
91
93
|
`$env:LIVEDESK_CLIENT_SLOT = ${quotePowerShell(slot || '')}`,
|
|
92
94
|
`$env:LIVEDESK_CLIENT_UPDATE_TARGET_VERSION = ${quotePowerShell(targetVersion)}`,
|
|
93
95
|
`$env:LIVEDESK_CLIENT_UPDATE_TARGET_PRODUCT_VERSION = ${quotePowerShell(targetProductVersion)}`,
|
|
@@ -126,6 +128,8 @@ function buildUnixClientUpdateBootstrapScript() {
|
|
|
126
128
|
'const targetProductVersion = String(process.env.LIVEDESK_CLIENT_UPDATE_TARGET_PRODUCT_VERSION || "").trim();',
|
|
127
129
|
'const packageSpec = /^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(targetProductVersion) ? "livedesk@" + targetProductVersion : "livedesk@latest";',
|
|
128
130
|
'const npxArgs = ["-y", "--prefer-online", packageSpec, "--force-role", "client", "--no-login", "--no-open"];',
|
|
131
|
+
'const preservedDeviceId = String(process.env.LIVEDESK_DEVICE_ID || "").trim();',
|
|
132
|
+
'if (preservedDeviceId) npxArgs.push("--device-id", preservedDeviceId);',
|
|
129
133
|
'const command = npxCli ? process.execPath : (process.platform === "win32" ? (process.env.ComSpec || "cmd.exe") : npx);',
|
|
130
134
|
'const commandArgs = npxCli ? [npxCli, ...npxArgs] : (process.platform === "win32" ? ["/d", "/s", "/c", "call \\"" + npx + "\\" " + npxArgs.join(" ")] : npxArgs);',
|
|
131
135
|
'process.env.LIVEDESK_SKIP_BROWSER_OPEN = "1";',
|
|
@@ -134,7 +138,7 @@ function buildUnixClientUpdateBootstrapScript() {
|
|
|
134
138
|
].join('\n');
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
function buildUnixLegacyUpdateCommand({ manager, pair, name, slot, targetVersion, targetProductVersion }) {
|
|
141
|
+
function buildUnixLegacyUpdateCommand({ manager, pair, name, deviceId, slot, targetVersion, targetProductVersion }) {
|
|
138
142
|
const script = [
|
|
139
143
|
'const { execFileSync, spawn } = require("node:child_process");',
|
|
140
144
|
'const fs = require("node:fs");',
|
|
@@ -150,8 +154,9 @@ function buildUnixLegacyUpdateCommand({ manager, pair, name, slot, targetVersion
|
|
|
150
154
|
'if (launcherPid <= 1) throw new Error("LiveDesk client launcher process was not found.");',
|
|
151
155
|
'const waitPid = launcherPid;',
|
|
152
156
|
`process.env.LIVEDESK_CLIENT_MANAGER = ${JSON.stringify(String(manager || ''))};`,
|
|
153
|
-
`process.env.LIVEDESK_CLIENT_PAIR_TOKEN = ${JSON.stringify(String(pair || ''))};`,
|
|
154
|
-
`process.env.LIVEDESK_CLIENT_NAME = ${JSON.stringify(String(name || ''))};`,
|
|
157
|
+
`process.env.LIVEDESK_CLIENT_PAIR_TOKEN = ${JSON.stringify(String(pair || ''))};`,
|
|
158
|
+
`process.env.LIVEDESK_CLIENT_NAME = ${JSON.stringify(String(name || ''))};`,
|
|
159
|
+
`process.env.LIVEDESK_DEVICE_ID = ${JSON.stringify(String(deviceId || ''))};`,
|
|
155
160
|
`process.env.LIVEDESK_CLIENT_SLOT = ${JSON.stringify(String(slot || ''))};`,
|
|
156
161
|
`process.env.LIVEDESK_CLIENT_UPDATE_TARGET_VERSION = ${JSON.stringify(String(targetVersion || ''))};`,
|
|
157
162
|
`process.env.LIVEDESK_CLIENT_UPDATE_TARGET_PRODUCT_VERSION = ${JSON.stringify(String(targetProductVersion || ''))};`,
|
|
@@ -171,9 +176,10 @@ function buildUnixLegacyUpdateCommand({ manager, pair, name, slot, targetVersion
|
|
|
171
176
|
function buildLegacyUpdateCommand(device, credentials, targetVersion, targetProductVersion) {
|
|
172
177
|
const payload = {
|
|
173
178
|
manager: credentials.agentEndpoint || credentials.manager,
|
|
174
|
-
pair: credentials.pairToken,
|
|
175
|
-
name: device.deviceName || device.hostname || '',
|
|
176
|
-
|
|
179
|
+
pair: credentials.pairToken,
|
|
180
|
+
name: device.deviceName || device.hostname || '',
|
|
181
|
+
deviceId: device.deviceId || '',
|
|
182
|
+
slot: device.slotNumber || '',
|
|
177
183
|
targetVersion,
|
|
178
184
|
targetProductVersion
|
|
179
185
|
};
|