@oussema_mili/test-pkg-123 1.1.40 → 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 +17 -1
- package/package.json +1 -1
- package/setup/setupWizard.js +30 -2
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:
|
|
916
|
+
userEntityRef: userEntityRef,
|
|
901
917
|
deviceName: deviceMetadata.deviceName,
|
|
902
918
|
platform: deviceMetadata.platform,
|
|
903
919
|
agentVersion: deviceMetadata.agentVersion,
|
package/package.json
CHANGED
package/setup/setupWizard.js
CHANGED
|
@@ -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,
|
|
@@ -254,11 +255,27 @@ export class SetupWizard {
|
|
|
254
255
|
{ timeout: 10000 }
|
|
255
256
|
);
|
|
256
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
|
+
|
|
257
274
|
return {
|
|
258
275
|
deviceId: response.data.deviceId,
|
|
259
276
|
deviceCredential: response.data.deviceCredential,
|
|
260
277
|
registryConfig: response.data.registryConfig,
|
|
261
|
-
userEntityRef:
|
|
278
|
+
userEntityRef: userEntityRef,
|
|
262
279
|
};
|
|
263
280
|
} catch (error) {
|
|
264
281
|
if (error.response?.status === 401) {
|
|
@@ -367,11 +384,22 @@ export class SetupWizard {
|
|
|
367
384
|
console.log("");
|
|
368
385
|
displayHeader("Setup Summary");
|
|
369
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
|
+
|
|
370
398
|
displayKeyValue({
|
|
371
399
|
"Device ID": registrationData.deviceId,
|
|
372
400
|
"Device Name": registrationData.deviceName || "N/A",
|
|
373
401
|
Platform: registrationData.platform || "N/A",
|
|
374
|
-
User:
|
|
402
|
+
User: displayUser,
|
|
375
403
|
});
|
|
376
404
|
|
|
377
405
|
console.log("");
|