@oussema_mili/test-pkg-123 1.1.39 → 1.1.41

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/cli-commands.js CHANGED
@@ -893,11 +893,27 @@ function setupCLICommands(program, startServerFunction) {
893
893
  { timeout: 10000 },
894
894
  );
895
895
 
896
+ // Debug: Log the actual response
897
+ console.log(chalk.gray('\n Debug - Backend response:'), JSON.stringify(response.data, null, 2));
898
+
899
+ // Try to get userEntityRef from backend, fallback to session, then "unknown"
900
+ let userEntityRef = response.data.userEntityRef;
901
+
902
+ if (!userEntityRef || userEntityRef === 'unknown') {
903
+ const session = loadSession();
904
+ if (session && isSessionValid(session) && session.userEntityRef) {
905
+ userEntityRef = session.userEntityRef;
906
+ console.log(chalk.gray(' Using userEntityRef from session: ' + userEntityRef));
907
+ } else {
908
+ userEntityRef = "unknown";
909
+ }
910
+ }
911
+
896
912
  // Save credentials
897
913
  saveDeviceCredential({
898
914
  deviceId: response.data.deviceId,
899
915
  deviceCredential: response.data.deviceCredential,
900
- userEntityRef: response.data.userEntityRef || "unknown",
916
+ userEntityRef: userEntityRef,
901
917
  deviceName: deviceMetadata.deviceName,
902
918
  platform: deviceMetadata.platform,
903
919
  agentVersion: deviceMetadata.agentVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oussema_mili/test-pkg-123",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "description": "Fenwave Docker Agent and CLI",
5
5
  "keywords": [
6
6
  "fenwave",
@@ -6,6 +6,7 @@ import {
6
6
  displayPrerequisites,
7
7
  getMissingPrerequisites,
8
8
  } from "../utils/prerequisites.js";
9
+ import { loadSession, isSessionValid } from "../auth.js";
9
10
  import {
10
11
  promptRegistrationToken,
11
12
  promptConfirmation,
@@ -231,7 +232,6 @@ export class SetupWizard {
231
232
  ...registrationData,
232
233
  deviceName: deviceMetadata.deviceName,
233
234
  platform: deviceMetadata.platform,
234
- userEntityRef: deviceMetadata.userEntityRef,
235
235
  };
236
236
  }
237
237
 
@@ -255,11 +255,27 @@ export class SetupWizard {
255
255
  { timeout: 10000 }
256
256
  );
257
257
 
258
+ // Debug: Log the actual response to understand what backend returns
259
+ console.log(chalk.gray(' Debug - Backend response:'), JSON.stringify(response.data, null, 2));
260
+
261
+ // Try to get userEntityRef from backend, fallback to session, then "unknown"
262
+ let userEntityRef = response.data.userEntityRef;
263
+
264
+ if (!userEntityRef || userEntityRef === 'unknown') {
265
+ const session = loadSession();
266
+ if (session && isSessionValid(session) && session.userEntityRef) {
267
+ userEntityRef = session.userEntityRef;
268
+ console.log(chalk.gray(' Using userEntityRef from session: ' + userEntityRef));
269
+ } else {
270
+ userEntityRef = "unknown";
271
+ }
272
+ }
273
+
258
274
  return {
259
275
  deviceId: response.data.deviceId,
260
276
  deviceCredential: response.data.deviceCredential,
261
277
  registryConfig: response.data.registryConfig,
262
- userEntityRef: response.data.userEntityRef || "unknown",
278
+ userEntityRef: userEntityRef,
263
279
  };
264
280
  } catch (error) {
265
281
  if (error.response?.status === 401) {
@@ -368,11 +384,22 @@ export class SetupWizard {
368
384
  console.log("");
369
385
  displayHeader("Setup Summary");
370
386
 
387
+ // Use session userEntityRef if device credential has unknown
388
+ let displayUser = registrationData.userEntityRef;
389
+ if (!displayUser || displayUser === "unknown") {
390
+ const session = loadSession();
391
+ if (session && isSessionValid(session) && session.userEntityRef) {
392
+ displayUser = session.userEntityRef;
393
+ } else {
394
+ displayUser = "N/A";
395
+ }
396
+ }
397
+
371
398
  displayKeyValue({
372
399
  "Device ID": registrationData.deviceId,
373
400
  "Device Name": registrationData.deviceName || "N/A",
374
401
  Platform: registrationData.platform || "N/A",
375
- User: registrationData.userEntityRef || "N/A",
402
+ User: displayUser,
376
403
  });
377
404
 
378
405
  console.log("");