@livedesk/client 0.1.205 → 0.1.206

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.
@@ -3301,6 +3301,8 @@ async function chooseClientConnection(supabase, options = {}) {
3301
3301
  deviceId: options.deviceId,
3302
3302
  engine: options.engine,
3303
3303
  slot: options.slot,
3304
+ assignedHubId: process.env.LIVEDESK_ASSIGNED_HUB_ID,
3305
+ roleVersion: process.env.LIVEDESK_ROLE_VERSION,
3304
3306
  savedSession: options.savedSession,
3305
3307
  initialChoice: options.initialChoice,
3306
3308
  initialChoiceMessage: options.initialChoiceMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/client",
3
- "version": "0.1.205",
3
+ "version": "0.1.206",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {
@@ -150,6 +150,11 @@ function normalizeSlotNumber(value) {
150
150
  : 0;
151
151
  }
152
152
 
153
+ function normalizeRoleVersion(value) {
154
+ const roleVersion = Number(String(value ?? '').trim());
155
+ return Number.isInteger(roleVersion) && roleVersion >= 0 ? roleVersion : 0;
156
+ }
157
+
153
158
  function readCpuTotals() {
154
159
  return os.cpus().reduce((totals, cpu) => {
155
160
  const times = Object.values(cpu.times || {}).map(Number);
@@ -655,9 +660,9 @@ export function createClientRuntimeServer(options = {}) {
655
660
  manager: '',
656
661
  pairToken: '',
657
662
  slotNumber: normalizeSlotNumber(options.slot),
658
- assignedHubId: '',
663
+ assignedHubId: normalizeString(options.assignedHubId ?? process.env.LIVEDESK_ASSIGNED_HUB_ID, 160),
659
664
  endpointCandidates: [],
660
- roleVersion: 0,
665
+ roleVersion: normalizeRoleVersion(options.roleVersion ?? process.env.LIVEDESK_ROLE_VERSION),
661
666
  connectedAt: '',
662
667
  message: 'Sign in with Google or enter a Hub PIN to start this Client.',
663
668
  startup: false,
@@ -788,6 +793,12 @@ export function createClientRuntimeServer(options = {}) {
788
793
  name: accountProfile.name || state.auth.name,
789
794
  avatarUrl: accountProfile.avatarUrl || state.auth.avatarUrl
790
795
  };
796
+ state.lastError = '';
797
+ if (state.message.startsWith('Client authentication needs attention:')) {
798
+ state.message = state.agent.state === 'running'
799
+ ? 'Connected to the LiveDesk Hub.'
800
+ : normalizeString(message, 1000) || 'Client credentials accepted. Finding the Hub.';
801
+ }
791
802
  }
792
803
  return;
793
804
  }
@@ -795,7 +806,9 @@ export function createClientRuntimeServer(options = {}) {
795
806
  loggedOut = false;
796
807
  state.connectedAt = new Date().toISOString();
797
808
  state.manager = normalizeString(choice?.manager, 256);
798
- state.assignedHubId = normalizeString(choice?.hubDeviceId, 160);
809
+ if (Object.prototype.hasOwnProperty.call(choice || {}, 'hubDeviceId')) {
810
+ state.assignedHubId = normalizeString(choice?.hubDeviceId, 160);
811
+ }
799
812
  state.endpointCandidates = Array.isArray(choice?.endpointCandidates)
800
813
  ? choice.endpointCandidates.map(value => normalizeString(value, 256)).filter(Boolean)
801
814
  : [];
@@ -1337,7 +1350,9 @@ export function createClientRuntimeServer(options = {}) {
1337
1350
  if (patch.manager) state.manager = normalizeString(patch.manager, 256);
1338
1351
  if (patch.pairToken) state.pairToken = normalizeString(patch.pairToken, 256);
1339
1352
  if (normalizeSlotNumber(patch.slotNumber)) state.slotNumber = normalizeSlotNumber(patch.slotNumber);
1340
- if (patch.assignedHubId) state.assignedHubId = normalizeString(patch.assignedHubId, 160);
1353
+ if (Object.prototype.hasOwnProperty.call(patch, 'assignedHubId')) {
1354
+ state.assignedHubId = normalizeString(patch.assignedHubId, 160);
1355
+ }
1341
1356
  if (patch.message) state.message = normalizeString(patch.message, 1000);
1342
1357
  if (Number.isInteger(patch.roleVersion)) state.roleVersion = patch.roleVersion;
1343
1358
  if (Array.isArray(patch.endpointCandidates)) state.endpointCandidates = patch.endpointCandidates;