@robinmordasiewicz/f5xc-xcsh 6.42.0 → 6.44.0
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 +172 -9
- 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 ("6.
|
|
45358
|
-
return "6.
|
|
45357
|
+
if ("6.44.0") {
|
|
45358
|
+
return "6.44.0";
|
|
45359
45359
|
}
|
|
45360
45360
|
if (process.env.XCSH_VERSION) {
|
|
45361
45361
|
return process.env.XCSH_VERSION;
|
|
@@ -45830,21 +45830,35 @@ var APIClient = class {
|
|
|
45830
45830
|
this._validationError = null;
|
|
45831
45831
|
return { valid: true };
|
|
45832
45832
|
} catch (error) {
|
|
45833
|
-
this._isValidated = false;
|
|
45834
45833
|
if (error instanceof APIError) {
|
|
45835
45834
|
if (error.statusCode === 401) {
|
|
45835
|
+
this._isValidated = false;
|
|
45836
45836
|
this._validationError = "Invalid or expired API token";
|
|
45837
|
+
return { valid: false, error: this._validationError };
|
|
45837
45838
|
} else if (error.statusCode === 403) {
|
|
45839
|
+
this._isValidated = false;
|
|
45838
45840
|
this._validationError = "Token lacks required permissions";
|
|
45839
|
-
|
|
45840
|
-
this._validationError = "Network error - could not reach server";
|
|
45841
|
+
return { valid: false, error: this._validationError };
|
|
45841
45842
|
} else {
|
|
45842
|
-
this.
|
|
45843
|
+
if (this.debug) {
|
|
45844
|
+
console.error(
|
|
45845
|
+
`DEBUG: Validation endpoint returned ${error.statusCode}, assuming token is valid`
|
|
45846
|
+
);
|
|
45847
|
+
}
|
|
45848
|
+
this._isValidated = true;
|
|
45849
|
+
this._validationError = null;
|
|
45850
|
+
return { valid: true };
|
|
45843
45851
|
}
|
|
45844
45852
|
} else {
|
|
45845
|
-
this.
|
|
45853
|
+
if (this.debug) {
|
|
45854
|
+
console.error(
|
|
45855
|
+
`DEBUG: Validation error: ${error instanceof Error ? error.message : "Unknown"}, assuming token is valid`
|
|
45856
|
+
);
|
|
45857
|
+
}
|
|
45858
|
+
this._isValidated = true;
|
|
45859
|
+
this._validationError = null;
|
|
45860
|
+
return { valid: true };
|
|
45846
45861
|
}
|
|
45847
|
-
return { valid: false, error: this._validationError };
|
|
45848
45862
|
}
|
|
45849
45863
|
}
|
|
45850
45864
|
/**
|
|
@@ -46805,6 +46819,135 @@ function getCommandSpec(commandPath) {
|
|
|
46805
46819
|
return void 0;
|
|
46806
46820
|
}
|
|
46807
46821
|
|
|
46822
|
+
// src/debug/protocol.ts
|
|
46823
|
+
function getDebugFormat() {
|
|
46824
|
+
const envValue = process.env[`${ENV_PREFIX}_DEBUG_EVENTS`];
|
|
46825
|
+
if (envValue === "jsonl" || envValue === "human") {
|
|
46826
|
+
return envValue;
|
|
46827
|
+
}
|
|
46828
|
+
if (process.env[`${ENV_PREFIX}_DEBUG`] === "true") {
|
|
46829
|
+
return "human";
|
|
46830
|
+
}
|
|
46831
|
+
return "none";
|
|
46832
|
+
}
|
|
46833
|
+
var DebugProtocolImpl = class {
|
|
46834
|
+
format;
|
|
46835
|
+
events = [];
|
|
46836
|
+
startTime;
|
|
46837
|
+
constructor() {
|
|
46838
|
+
this.format = getDebugFormat();
|
|
46839
|
+
this.startTime = Date.now();
|
|
46840
|
+
}
|
|
46841
|
+
/**
|
|
46842
|
+
* Check if debug events are enabled
|
|
46843
|
+
*/
|
|
46844
|
+
isEnabled() {
|
|
46845
|
+
return this.format !== "none";
|
|
46846
|
+
}
|
|
46847
|
+
/**
|
|
46848
|
+
* Check if JSONL format is enabled
|
|
46849
|
+
*/
|
|
46850
|
+
isJsonl() {
|
|
46851
|
+
return this.format === "jsonl";
|
|
46852
|
+
}
|
|
46853
|
+
/**
|
|
46854
|
+
* Emit a debug event
|
|
46855
|
+
*/
|
|
46856
|
+
emit(type, event, data = {}) {
|
|
46857
|
+
if (!this.isEnabled()) return;
|
|
46858
|
+
const entry = {
|
|
46859
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
46860
|
+
type,
|
|
46861
|
+
event,
|
|
46862
|
+
data: {
|
|
46863
|
+
...data,
|
|
46864
|
+
elapsedMs: Date.now() - this.startTime
|
|
46865
|
+
}
|
|
46866
|
+
};
|
|
46867
|
+
this.events.push(entry);
|
|
46868
|
+
if (this.format === "jsonl") {
|
|
46869
|
+
console.error(JSON.stringify(entry));
|
|
46870
|
+
} else if (this.format === "human") {
|
|
46871
|
+
const prefix = `DEBUG [${type}:${event}]`;
|
|
46872
|
+
const dataStr = Object.keys(data).length > 0 ? ` ${JSON.stringify(data)}` : "";
|
|
46873
|
+
console.error(`${prefix}${dataStr}`);
|
|
46874
|
+
}
|
|
46875
|
+
}
|
|
46876
|
+
/**
|
|
46877
|
+
* Emit session-related event
|
|
46878
|
+
*/
|
|
46879
|
+
session(event, data = {}) {
|
|
46880
|
+
this.emit("session", event, data);
|
|
46881
|
+
}
|
|
46882
|
+
/**
|
|
46883
|
+
* Emit API-related event
|
|
46884
|
+
*/
|
|
46885
|
+
api(event, data = {}) {
|
|
46886
|
+
this.emit("api", event, data);
|
|
46887
|
+
}
|
|
46888
|
+
/**
|
|
46889
|
+
* Emit authentication-related event
|
|
46890
|
+
*/
|
|
46891
|
+
auth(event, data = {}) {
|
|
46892
|
+
this.emit("auth", event, data);
|
|
46893
|
+
}
|
|
46894
|
+
/**
|
|
46895
|
+
* Emit profile-related event
|
|
46896
|
+
*/
|
|
46897
|
+
profile(event, data = {}) {
|
|
46898
|
+
this.emit("profile", event, data);
|
|
46899
|
+
}
|
|
46900
|
+
/**
|
|
46901
|
+
* Emit UI-related event
|
|
46902
|
+
*/
|
|
46903
|
+
ui(event, data = {}) {
|
|
46904
|
+
this.emit("ui", event, data);
|
|
46905
|
+
}
|
|
46906
|
+
/**
|
|
46907
|
+
* Emit error event
|
|
46908
|
+
*/
|
|
46909
|
+
error(event, error, data = {}) {
|
|
46910
|
+
this.emit("error", event, {
|
|
46911
|
+
...data,
|
|
46912
|
+
error: error instanceof Error ? error.message : String(error),
|
|
46913
|
+
stack: error instanceof Error ? error.stack : void 0
|
|
46914
|
+
});
|
|
46915
|
+
}
|
|
46916
|
+
/**
|
|
46917
|
+
* Get all captured events
|
|
46918
|
+
*/
|
|
46919
|
+
getEvents() {
|
|
46920
|
+
return [...this.events];
|
|
46921
|
+
}
|
|
46922
|
+
/**
|
|
46923
|
+
* Dump session state on exit (for --dump-state-on-exit)
|
|
46924
|
+
*/
|
|
46925
|
+
dumpState(state) {
|
|
46926
|
+
if (!this.isEnabled()) return;
|
|
46927
|
+
console.error("\n=== Session State Dump ===");
|
|
46928
|
+
console.error(JSON.stringify(state, null, 2));
|
|
46929
|
+
console.error("=== End Session State ===\n");
|
|
46930
|
+
}
|
|
46931
|
+
};
|
|
46932
|
+
var debugProtocol = new DebugProtocolImpl();
|
|
46933
|
+
function emitSessionState(session) {
|
|
46934
|
+
debugProtocol.auth("session_state", {
|
|
46935
|
+
isAuthenticated: session.isAuthenticated(),
|
|
46936
|
+
isTokenValidated: session.isTokenValidated(),
|
|
46937
|
+
validationError: session.getValidationError(),
|
|
46938
|
+
serverUrl: session.getServerUrl(),
|
|
46939
|
+
activeProfile: session.getActiveProfileName(),
|
|
46940
|
+
hasApiClient: session.getAPIClient() !== null
|
|
46941
|
+
});
|
|
46942
|
+
const showsWarning = session.isAuthenticated() && !session.isTokenValidated() && session.getValidationError();
|
|
46943
|
+
debugProtocol.auth("warning_check", {
|
|
46944
|
+
shouldShowWarning: !!showsWarning,
|
|
46945
|
+
isAuthenticated: session.isAuthenticated(),
|
|
46946
|
+
isTokenValidated: session.isTokenValidated(),
|
|
46947
|
+
hasValidationError: !!session.getValidationError()
|
|
46948
|
+
});
|
|
46949
|
+
}
|
|
46950
|
+
|
|
46808
46951
|
// src/repl/session.ts
|
|
46809
46952
|
var NAMESPACE_CACHE_TTL = 5 * 60 * 1e3;
|
|
46810
46953
|
var REPLSession = class {
|
|
@@ -46863,9 +47006,19 @@ var REPLSession = class {
|
|
|
46863
47006
|
}
|
|
46864
47007
|
await this.loadActiveProfile();
|
|
46865
47008
|
if (this._apiClient?.isAuthenticated()) {
|
|
47009
|
+
debugProtocol.auth("token_validation_start", {
|
|
47010
|
+
serverUrl: this._serverUrl,
|
|
47011
|
+
hasApiClient: true
|
|
47012
|
+
});
|
|
46866
47013
|
const result = await this._apiClient.validateToken();
|
|
46867
47014
|
this._tokenValidated = result.valid;
|
|
46868
47015
|
this._validationError = result.error ?? null;
|
|
47016
|
+
debugProtocol.auth("token_validation_complete", {
|
|
47017
|
+
valid: result.valid,
|
|
47018
|
+
error: result.error,
|
|
47019
|
+
tokenValidated: this._tokenValidated,
|
|
47020
|
+
validationError: this._validationError
|
|
47021
|
+
});
|
|
46869
47022
|
if (result.valid) {
|
|
46870
47023
|
await this.fetchUserInfo();
|
|
46871
47024
|
}
|
|
@@ -46927,7 +47080,10 @@ var REPLSession = class {
|
|
|
46927
47080
|
}
|
|
46928
47081
|
}
|
|
46929
47082
|
}
|
|
46930
|
-
} catch {
|
|
47083
|
+
} catch (error) {
|
|
47084
|
+
debugProtocol.error("profile_load_failed", error, {
|
|
47085
|
+
activeProfile: this._activeProfileName
|
|
47086
|
+
});
|
|
46931
47087
|
}
|
|
46932
47088
|
}
|
|
46933
47089
|
/**
|
|
@@ -53187,6 +53343,8 @@ program2.name(CLI_NAME).description("F5 Distributed Cloud Shell - Interactive CL
|
|
|
53187
53343
|
process.stdout.write("Initializing...");
|
|
53188
53344
|
const session = new REPLSession();
|
|
53189
53345
|
await session.initialize();
|
|
53346
|
+
debugProtocol.session("init", { mode: "repl" });
|
|
53347
|
+
emitSessionState(session);
|
|
53190
53348
|
process.stdout.write("\r\x1B[K");
|
|
53191
53349
|
renderBanner(cliLogoMode, "startup");
|
|
53192
53350
|
if (session.isAuthenticated() && !session.isTokenValidated() && session.getValidationError()) {
|
|
@@ -53232,6 +53390,11 @@ program2.name(CLI_NAME).description("F5 Distributed Cloud Shell - Interactive CL
|
|
|
53232
53390
|
async function executeNonInteractive(args) {
|
|
53233
53391
|
const session = new REPLSession();
|
|
53234
53392
|
await session.initialize();
|
|
53393
|
+
debugProtocol.session("init", {
|
|
53394
|
+
mode: "non-interactive",
|
|
53395
|
+
command: args.join(" ")
|
|
53396
|
+
});
|
|
53397
|
+
emitSessionState(session);
|
|
53235
53398
|
if (session.isAuthenticated() && !session.isTokenValidated() && session.getValidationError()) {
|
|
53236
53399
|
console.error(
|
|
53237
53400
|
`${colors.yellow}Warning: ${session.getValidationError()}${colors.reset}`
|