@robinmordasiewicz/f5xc-xcsh 1.0.82-2512312131 → 1.0.82-2512312318
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 +79 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45354,8 +45354,8 @@ function getLogoModeFromEnv(envPrefix) {
|
|
|
45354
45354
|
var CLI_NAME = "xcsh";
|
|
45355
45355
|
var CLI_FULL_NAME = "F5 Distributed Cloud Shell";
|
|
45356
45356
|
function getVersion() {
|
|
45357
|
-
if ("v1.0.82-
|
|
45358
|
-
return "v1.0.82-
|
|
45357
|
+
if ("v1.0.82-2512312318") {
|
|
45358
|
+
return "v1.0.82-2512312318";
|
|
45359
45359
|
}
|
|
45360
45360
|
if (process.env.XCSH_VERSION) {
|
|
45361
45361
|
return process.env.XCSH_VERSION;
|
|
@@ -46618,7 +46618,7 @@ function wrapText3(text, width, indent) {
|
|
|
46618
46618
|
function formatRootHelp() {
|
|
46619
46619
|
return [
|
|
46620
46620
|
"",
|
|
46621
|
-
colorBoldWhite(`${CLI_NAME} - ${CLI_FULL_NAME}
|
|
46621
|
+
colorBoldWhite(`${CLI_NAME} - ${CLI_FULL_NAME} ${CLI_VERSION}`),
|
|
46622
46622
|
"",
|
|
46623
46623
|
"DESCRIPTION",
|
|
46624
46624
|
...wrapText3(CLI_DESCRIPTION_LONG, 80, 2),
|
|
@@ -47820,13 +47820,22 @@ var REPLSession = class {
|
|
|
47820
47820
|
// Token validation state
|
|
47821
47821
|
_tokenValidated = false;
|
|
47822
47822
|
_validationError = null;
|
|
47823
|
+
// Authentication source tracking
|
|
47824
|
+
_authSource = "none";
|
|
47823
47825
|
constructor(config = {}) {
|
|
47824
47826
|
this._namespace = config.namespace ?? this.getDefaultNamespace();
|
|
47825
47827
|
this._contextPath = new ContextPath();
|
|
47826
47828
|
this._validator = new ContextValidator();
|
|
47827
47829
|
this._profileManager = getProfileManager();
|
|
47828
|
-
|
|
47829
|
-
|
|
47830
|
+
const envUrl = process.env[`${ENV_PREFIX}_API_URL`];
|
|
47831
|
+
const envToken = process.env[`${ENV_PREFIX}_API_TOKEN`];
|
|
47832
|
+
this._serverUrl = config.serverUrl ?? envUrl ?? "";
|
|
47833
|
+
this._apiToken = config.apiToken ?? envToken ?? "";
|
|
47834
|
+
if (envUrl && envToken) {
|
|
47835
|
+
this._authSource = "env";
|
|
47836
|
+
} else if (envUrl || envToken) {
|
|
47837
|
+
this._authSource = "mixed";
|
|
47838
|
+
}
|
|
47830
47839
|
this._outputFormat = config.outputFormat ?? getOutputFormatFromEnv() ?? "table";
|
|
47831
47840
|
this._debug = config.debug ?? process.env[`${ENV_PREFIX}_DEBUG`] === "true";
|
|
47832
47841
|
if (this._serverUrl) {
|
|
@@ -47857,7 +47866,8 @@ var REPLSession = class {
|
|
|
47857
47866
|
if (this._apiClient?.isAuthenticated()) {
|
|
47858
47867
|
debugProtocol.auth("token_validation_start", {
|
|
47859
47868
|
serverUrl: this._serverUrl,
|
|
47860
|
-
hasApiClient: true
|
|
47869
|
+
hasApiClient: true,
|
|
47870
|
+
authSource: this._authSource
|
|
47861
47871
|
});
|
|
47862
47872
|
const result = await this._apiClient.validateToken();
|
|
47863
47873
|
this._tokenValidated = result.valid;
|
|
@@ -47866,9 +47876,44 @@ var REPLSession = class {
|
|
|
47866
47876
|
valid: result.valid,
|
|
47867
47877
|
error: result.error,
|
|
47868
47878
|
tokenValidated: this._tokenValidated,
|
|
47869
|
-
validationError: this._validationError
|
|
47879
|
+
validationError: this._validationError,
|
|
47880
|
+
authSource: this._authSource
|
|
47870
47881
|
});
|
|
47871
|
-
if (result.valid) {
|
|
47882
|
+
if (!result.valid && (this._authSource === "env" || this._authSource === "mixed") && this._activeProfile?.apiToken && this._activeProfile.apiToken !== this._apiToken) {
|
|
47883
|
+
debugProtocol.auth("token_fallback_attempt", {
|
|
47884
|
+
fromSource: this._authSource,
|
|
47885
|
+
hasProfileToken: true,
|
|
47886
|
+
profileName: this._activeProfileName
|
|
47887
|
+
});
|
|
47888
|
+
this._apiToken = this._activeProfile.apiToken;
|
|
47889
|
+
if (this._authSource === "mixed" && !process.env[`${ENV_PREFIX}_API_URL`] && this._activeProfile.apiUrl) {
|
|
47890
|
+
this._serverUrl = this._activeProfile.apiUrl;
|
|
47891
|
+
this._tenant = this.extractTenant(
|
|
47892
|
+
this._activeProfile.apiUrl
|
|
47893
|
+
);
|
|
47894
|
+
}
|
|
47895
|
+
this._apiClient = new APIClient({
|
|
47896
|
+
serverUrl: this._serverUrl,
|
|
47897
|
+
apiToken: this._apiToken,
|
|
47898
|
+
debug: this._debug
|
|
47899
|
+
});
|
|
47900
|
+
const fallbackResult = await this._apiClient.validateToken();
|
|
47901
|
+
if (fallbackResult.valid) {
|
|
47902
|
+
this._tokenValidated = true;
|
|
47903
|
+
this._validationError = null;
|
|
47904
|
+
this._authSource = "profile-fallback";
|
|
47905
|
+
debugProtocol.auth("token_fallback_success", {
|
|
47906
|
+
authSource: this._authSource,
|
|
47907
|
+
profileName: this._activeProfileName
|
|
47908
|
+
});
|
|
47909
|
+
} else {
|
|
47910
|
+
debugProtocol.auth("token_fallback_failed", {
|
|
47911
|
+
error: fallbackResult.error,
|
|
47912
|
+
profileName: this._activeProfileName
|
|
47913
|
+
});
|
|
47914
|
+
}
|
|
47915
|
+
}
|
|
47916
|
+
if (this._tokenValidated) {
|
|
47872
47917
|
await this.fetchUserInfo();
|
|
47873
47918
|
}
|
|
47874
47919
|
}
|
|
@@ -47910,16 +47955,25 @@ var REPLSession = class {
|
|
|
47910
47955
|
const envUrl = process.env[`${ENV_PREFIX}_API_URL`];
|
|
47911
47956
|
const envToken = process.env[`${ENV_PREFIX}_API_TOKEN`];
|
|
47912
47957
|
const envNamespace = process.env[`${ENV_PREFIX}_NAMESPACE`];
|
|
47958
|
+
let usingProfileUrl = false;
|
|
47959
|
+
let usingProfileToken = false;
|
|
47913
47960
|
if (!envUrl && profile.apiUrl) {
|
|
47914
47961
|
this._serverUrl = profile.apiUrl;
|
|
47915
47962
|
this._tenant = this.extractTenant(profile.apiUrl);
|
|
47963
|
+
usingProfileUrl = true;
|
|
47916
47964
|
}
|
|
47917
47965
|
if (!envToken && profile.apiToken) {
|
|
47918
47966
|
this._apiToken = profile.apiToken;
|
|
47967
|
+
usingProfileToken = true;
|
|
47919
47968
|
}
|
|
47920
47969
|
if (!envNamespace && profile.defaultNamespace) {
|
|
47921
47970
|
this._namespace = profile.defaultNamespace;
|
|
47922
47971
|
}
|
|
47972
|
+
if (usingProfileUrl && usingProfileToken) {
|
|
47973
|
+
this._authSource = "profile";
|
|
47974
|
+
} else if (usingProfileUrl || usingProfileToken) {
|
|
47975
|
+
this._authSource = "mixed";
|
|
47976
|
+
}
|
|
47923
47977
|
if (this._serverUrl) {
|
|
47924
47978
|
this._apiClient = new APIClient({
|
|
47925
47979
|
serverUrl: this._serverUrl,
|
|
@@ -48047,6 +48101,13 @@ var REPLSession = class {
|
|
|
48047
48101
|
getValidationError() {
|
|
48048
48102
|
return this._validationError;
|
|
48049
48103
|
}
|
|
48104
|
+
/**
|
|
48105
|
+
* Get the authentication source
|
|
48106
|
+
* Indicates where credentials were obtained from
|
|
48107
|
+
*/
|
|
48108
|
+
getAuthSource() {
|
|
48109
|
+
return this._authSource;
|
|
48110
|
+
}
|
|
48050
48111
|
/**
|
|
48051
48112
|
* Get the API client
|
|
48052
48113
|
*/
|
|
@@ -49383,7 +49444,7 @@ function printImageBanner(imageSeq, imageHeight, imageWidth) {
|
|
|
49383
49444
|
const TEXT_COL_WIDTH = INNER_WIDTH - IMAGE_COL_WIDTH;
|
|
49384
49445
|
const HELP_LINES = wrapText4(CLI_DESCRIPTION_MEDIUM, TEXT_COL_WIDTH - 2);
|
|
49385
49446
|
const helpStartRow = Math.floor((imageHeight - HELP_LINES.length) / 2);
|
|
49386
|
-
const title = ` ${CLI_FULL_NAME}
|
|
49447
|
+
const title = ` ${CLI_FULL_NAME} ${CLI_VERSION} `;
|
|
49387
49448
|
const leftDashes = 3;
|
|
49388
49449
|
const rightDashes = TOTAL_WIDTH - 1 - leftDashes - title.length - 1;
|
|
49389
49450
|
process.stdout.write("\n");
|
|
@@ -49434,7 +49495,7 @@ function printAsciiBanner() {
|
|
|
49434
49495
|
const helpColumnWidth = INNER_WIDTH - logoWidth - 1;
|
|
49435
49496
|
const HELP_LINES = wrapText4(CLI_DESCRIPTION_MEDIUM, helpColumnWidth - 2);
|
|
49436
49497
|
const HELP_START_ROW = 8;
|
|
49437
|
-
const title = ` ${CLI_FULL_NAME}
|
|
49498
|
+
const title = ` ${CLI_FULL_NAME} ${CLI_VERSION} `;
|
|
49438
49499
|
const leftDashes = 3;
|
|
49439
49500
|
const rightDashes = TOTAL_WIDTH - 1 - leftDashes - title.length - 1;
|
|
49440
49501
|
const output = [];
|
|
@@ -49480,7 +49541,7 @@ function getBannerLines(logoMode, useImage) {
|
|
|
49480
49541
|
const TOTAL_WIDTH = Math.max(80, logoWidth + 4);
|
|
49481
49542
|
const INNER_WIDTH = TOTAL_WIDTH - 2;
|
|
49482
49543
|
const helpColumnWidth = INNER_WIDTH - logoWidth - 1;
|
|
49483
|
-
const title = ` ${CLI_FULL_NAME}
|
|
49544
|
+
const title = ` ${CLI_FULL_NAME} ${CLI_VERSION} `;
|
|
49484
49545
|
const leftDashes = 3;
|
|
49485
49546
|
const rightDashes = TOTAL_WIDTH - 1 - leftDashes - title.length - 1;
|
|
49486
49547
|
const output = [];
|
|
@@ -53689,6 +53750,12 @@ var HeadlessController = class {
|
|
|
53689
53750
|
"session_initialized",
|
|
53690
53751
|
this.getSessionState()
|
|
53691
53752
|
);
|
|
53753
|
+
if (this.session.isAuthenticated() && !this.session.isTokenValidated() && this.session.getValidationError()) {
|
|
53754
|
+
this.emitEvent("warning", {
|
|
53755
|
+
message: this.session.getValidationError(),
|
|
53756
|
+
type: "token_validation"
|
|
53757
|
+
});
|
|
53758
|
+
}
|
|
53692
53759
|
}
|
|
53693
53760
|
/**
|
|
53694
53761
|
* Get current session state for output
|
|
@@ -53698,6 +53765,7 @@ var HeadlessController = class {
|
|
|
53698
53765
|
return {
|
|
53699
53766
|
authenticated: this.session.isAuthenticated(),
|
|
53700
53767
|
tokenValidated: this.session.isTokenValidated(),
|
|
53768
|
+
authSource: this.session.getAuthSource(),
|
|
53701
53769
|
namespace: this.session.getNamespace(),
|
|
53702
53770
|
serverUrl: this.session.getServerUrl(),
|
|
53703
53771
|
activeProfile: this.session.getActiveProfileName(),
|