@robinmordasiewicz/f5xc-xcsh 1.0.82-2601012015 → 1.0.82-2601012039
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/dist/index.js +117 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45392,8 +45392,8 @@ function getLogoModeFromEnv(envPrefix) {
|
|
|
45392
45392
|
var CLI_NAME = "xcsh";
|
|
45393
45393
|
var CLI_FULL_NAME = "F5 Distributed Cloud Shell";
|
|
45394
45394
|
function getVersion() {
|
|
45395
|
-
if ("v1.0.82-
|
|
45396
|
-
return "v1.0.82-
|
|
45395
|
+
if ("v1.0.82-2601012039") {
|
|
45396
|
+
return "v1.0.82-2601012039";
|
|
45397
45397
|
}
|
|
45398
45398
|
if (process.env.XCSH_VERSION) {
|
|
45399
45399
|
return process.env.XCSH_VERSION;
|
|
@@ -48051,6 +48051,9 @@ var REPLSession = class {
|
|
|
48051
48051
|
_validationError = null;
|
|
48052
48052
|
// Authentication source tracking
|
|
48053
48053
|
_authSource = "none";
|
|
48054
|
+
// Fallback tracking for improved error messages
|
|
48055
|
+
_fallbackAttempted = false;
|
|
48056
|
+
_fallbackReason = null;
|
|
48054
48057
|
constructor(config = {}) {
|
|
48055
48058
|
this._namespace = config.namespace ?? this.getDefaultNamespace();
|
|
48056
48059
|
this._contextPath = new ContextPath();
|
|
@@ -48108,36 +48111,57 @@ var REPLSession = class {
|
|
|
48108
48111
|
validationError: this._validationError,
|
|
48109
48112
|
authSource: this._authSource
|
|
48110
48113
|
});
|
|
48111
|
-
if (!result.valid && (this._authSource === "env" || this._authSource === "mixed")
|
|
48112
|
-
|
|
48113
|
-
|
|
48114
|
-
|
|
48115
|
-
|
|
48116
|
-
|
|
48117
|
-
this._apiToken = this._activeProfile.apiToken;
|
|
48118
|
-
if (this._authSource === "mixed" && !process.env[`${ENV_PREFIX}_API_URL`] && this._activeProfile.apiUrl) {
|
|
48119
|
-
this._serverUrl = this._activeProfile.apiUrl;
|
|
48120
|
-
this._tenant = this.extractTenant(
|
|
48121
|
-
this._activeProfile.apiUrl
|
|
48122
|
-
);
|
|
48123
|
-
}
|
|
48124
|
-
this._apiClient = new APIClient({
|
|
48125
|
-
serverUrl: this._serverUrl,
|
|
48126
|
-
apiToken: this._apiToken,
|
|
48127
|
-
debug: this._debug
|
|
48128
|
-
});
|
|
48129
|
-
const fallbackResult = await this._apiClient.validateToken();
|
|
48130
|
-
if (fallbackResult.valid) {
|
|
48131
|
-
this._tokenValidated = true;
|
|
48132
|
-
this._validationError = null;
|
|
48133
|
-
this._authSource = "profile-fallback";
|
|
48134
|
-
debugProtocol.auth("token_fallback_success", {
|
|
48135
|
-
authSource: this._authSource,
|
|
48114
|
+
if (!result.valid && (this._authSource === "env" || this._authSource === "mixed")) {
|
|
48115
|
+
if (this._activeProfile?.apiToken && this._activeProfile.apiToken !== this._apiToken) {
|
|
48116
|
+
this._fallbackAttempted = true;
|
|
48117
|
+
debugProtocol.auth("token_fallback_attempt", {
|
|
48118
|
+
fromSource: this._authSource,
|
|
48119
|
+
hasProfileToken: true,
|
|
48136
48120
|
profileName: this._activeProfileName
|
|
48137
48121
|
});
|
|
48138
|
-
|
|
48139
|
-
|
|
48140
|
-
|
|
48122
|
+
this._apiToken = this._activeProfile.apiToken;
|
|
48123
|
+
if (this._authSource === "mixed" && !process.env[`${ENV_PREFIX}_API_URL`] && this._activeProfile.apiUrl) {
|
|
48124
|
+
this._serverUrl = this._activeProfile.apiUrl;
|
|
48125
|
+
this._tenant = this.extractTenant(
|
|
48126
|
+
this._activeProfile.apiUrl
|
|
48127
|
+
);
|
|
48128
|
+
}
|
|
48129
|
+
this._apiClient = new APIClient({
|
|
48130
|
+
serverUrl: this._serverUrl,
|
|
48131
|
+
apiToken: this._apiToken,
|
|
48132
|
+
debug: this._debug
|
|
48133
|
+
});
|
|
48134
|
+
const fallbackResult = await this._apiClient.validateToken();
|
|
48135
|
+
if (fallbackResult.valid) {
|
|
48136
|
+
this._tokenValidated = true;
|
|
48137
|
+
this._validationError = null;
|
|
48138
|
+
this._authSource = "profile-fallback";
|
|
48139
|
+
this._fallbackReason = null;
|
|
48140
|
+
debugProtocol.auth("token_fallback_success", {
|
|
48141
|
+
authSource: this._authSource,
|
|
48142
|
+
profileName: this._activeProfileName
|
|
48143
|
+
});
|
|
48144
|
+
} else {
|
|
48145
|
+
this._fallbackReason = `Profile '${this._activeProfileName}' credentials are also invalid`;
|
|
48146
|
+
debugProtocol.auth("token_fallback_failed", {
|
|
48147
|
+
error: fallbackResult.error,
|
|
48148
|
+
profileName: this._activeProfileName
|
|
48149
|
+
});
|
|
48150
|
+
}
|
|
48151
|
+
} else if (this._activeProfile?.apiToken && this._activeProfile.apiToken === this._apiToken) {
|
|
48152
|
+
this._fallbackReason = `Profile '${this._activeProfileName}' has the same credentials - please update`;
|
|
48153
|
+
debugProtocol.auth("token_fallback_skipped", {
|
|
48154
|
+
reason: "same_token",
|
|
48155
|
+
profileName: this._activeProfileName
|
|
48156
|
+
});
|
|
48157
|
+
} else if (!this._activeProfile?.apiToken) {
|
|
48158
|
+
if (this._activeProfileName) {
|
|
48159
|
+
this._fallbackReason = `Profile '${this._activeProfileName}' has no saved credentials`;
|
|
48160
|
+
} else {
|
|
48161
|
+
this._fallbackReason = "No saved profiles available for fallback";
|
|
48162
|
+
}
|
|
48163
|
+
debugProtocol.auth("token_fallback_skipped", {
|
|
48164
|
+
reason: "no_profile_token",
|
|
48141
48165
|
profileName: this._activeProfileName
|
|
48142
48166
|
});
|
|
48143
48167
|
}
|
|
@@ -48337,6 +48361,18 @@ var REPLSession = class {
|
|
|
48337
48361
|
getAuthSource() {
|
|
48338
48362
|
return this._authSource;
|
|
48339
48363
|
}
|
|
48364
|
+
/**
|
|
48365
|
+
* Check if a credential fallback was attempted
|
|
48366
|
+
*/
|
|
48367
|
+
getFallbackAttempted() {
|
|
48368
|
+
return this._fallbackAttempted;
|
|
48369
|
+
}
|
|
48370
|
+
/**
|
|
48371
|
+
* Get the reason why fallback failed or was skipped (for user messaging)
|
|
48372
|
+
*/
|
|
48373
|
+
getFallbackReason() {
|
|
48374
|
+
return this._fallbackReason;
|
|
48375
|
+
}
|
|
48340
48376
|
/**
|
|
48341
48377
|
* Get the API client
|
|
48342
48378
|
*/
|
|
@@ -48394,6 +48430,8 @@ var REPLSession = class {
|
|
|
48394
48430
|
this.clearNamespaceCache();
|
|
48395
48431
|
this._tokenValidated = false;
|
|
48396
48432
|
this._validationError = null;
|
|
48433
|
+
this._fallbackAttempted = false;
|
|
48434
|
+
this._fallbackReason = null;
|
|
48397
48435
|
this._activeProfileName = profileName;
|
|
48398
48436
|
this._activeProfile = profile;
|
|
48399
48437
|
if (profile.apiUrl) {
|
|
@@ -54379,12 +54417,35 @@ program2.name(CLI_NAME).description("F5 Distributed Cloud Shell - Interactive CL
|
|
|
54379
54417
|
emitSessionState(session);
|
|
54380
54418
|
process.stdout.write("\r\x1B[K");
|
|
54381
54419
|
renderBanner(cliLogoMode, "startup");
|
|
54382
|
-
if (session.
|
|
54420
|
+
if (session.getAuthSource() === "profile-fallback") {
|
|
54421
|
+
const profileName = session.getActiveProfileName();
|
|
54383
54422
|
console.log("");
|
|
54384
54423
|
console.log(
|
|
54385
|
-
`${colors.
|
|
54424
|
+
`${colors.blue}Info: Using credentials from profile '${profileName}' (environment variables were invalid)${colors.reset}`
|
|
54386
54425
|
);
|
|
54387
54426
|
}
|
|
54427
|
+
if (session.isAuthenticated() && !session.isTokenValidated() && session.getValidationError()) {
|
|
54428
|
+
const authSource = session.getAuthSource();
|
|
54429
|
+
const fallbackReason = session.getFallbackReason();
|
|
54430
|
+
console.log("");
|
|
54431
|
+
if (authSource === "env" || authSource === "mixed") {
|
|
54432
|
+
console.log(
|
|
54433
|
+
`${colors.yellow}Warning: Environment variable credentials are invalid or expired${colors.reset}`
|
|
54434
|
+
);
|
|
54435
|
+
if (fallbackReason) {
|
|
54436
|
+
console.log(
|
|
54437
|
+
`${colors.dim} ${fallbackReason}${colors.reset}`
|
|
54438
|
+
);
|
|
54439
|
+
}
|
|
54440
|
+
console.log(
|
|
54441
|
+
`${colors.dim} Run 'login' to authenticate or update your F5XC_API_TOKEN environment variable${colors.reset}`
|
|
54442
|
+
);
|
|
54443
|
+
} else {
|
|
54444
|
+
console.log(
|
|
54445
|
+
`${colors.yellow}Warning: ${session.getValidationError()}${colors.reset}`
|
|
54446
|
+
);
|
|
54447
|
+
}
|
|
54448
|
+
}
|
|
54388
54449
|
const profiles = await session.getProfileManager().list();
|
|
54389
54450
|
const envConfigured = process.env[`${ENV_PREFIX}_API_URL`] && process.env[`${ENV_PREFIX}_API_TOKEN`];
|
|
54390
54451
|
if (profiles.length === 0 && !envConfigured) {
|
|
@@ -54427,11 +54488,33 @@ async function executeNonInteractive(args) {
|
|
|
54427
54488
|
command: args.join(" ")
|
|
54428
54489
|
});
|
|
54429
54490
|
emitSessionState(session);
|
|
54430
|
-
if (session.
|
|
54491
|
+
if (session.getAuthSource() === "profile-fallback") {
|
|
54492
|
+
const profileName = session.getActiveProfileName();
|
|
54431
54493
|
console.error(
|
|
54432
|
-
`${colors.
|
|
54494
|
+
`${colors.blue}Info: Using credentials from profile '${profileName}' (environment variables were invalid)${colors.reset}`
|
|
54433
54495
|
);
|
|
54434
54496
|
}
|
|
54497
|
+
if (session.isAuthenticated() && !session.isTokenValidated() && session.getValidationError()) {
|
|
54498
|
+
const authSource = session.getAuthSource();
|
|
54499
|
+
const fallbackReason = session.getFallbackReason();
|
|
54500
|
+
if (authSource === "env" || authSource === "mixed") {
|
|
54501
|
+
console.error(
|
|
54502
|
+
`${colors.yellow}Warning: Environment variable credentials are invalid or expired${colors.reset}`
|
|
54503
|
+
);
|
|
54504
|
+
if (fallbackReason) {
|
|
54505
|
+
console.error(
|
|
54506
|
+
`${colors.dim} ${fallbackReason}${colors.reset}`
|
|
54507
|
+
);
|
|
54508
|
+
}
|
|
54509
|
+
console.error(
|
|
54510
|
+
`${colors.dim} Run 'login' to authenticate or update your F5XC_API_TOKEN environment variable${colors.reset}`
|
|
54511
|
+
);
|
|
54512
|
+
} else {
|
|
54513
|
+
console.error(
|
|
54514
|
+
`${colors.yellow}Warning: ${session.getValidationError()}${colors.reset}`
|
|
54515
|
+
);
|
|
54516
|
+
}
|
|
54517
|
+
}
|
|
54435
54518
|
const command = args.join(" ");
|
|
54436
54519
|
const result = await executeCommand(command, session);
|
|
54437
54520
|
result.output.forEach((line) => {
|