@robinmordasiewicz/f5xc-xcsh 1.0.82-2512312156 → 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.
Files changed (2) hide show
  1. package/dist/index.js +75 -7
  2. 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-2512312156") {
45358
- return "v1.0.82-2512312156";
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;
@@ -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
- this._serverUrl = config.serverUrl ?? process.env[`${ENV_PREFIX}_API_URL`] ?? "";
47829
- this._apiToken = config.apiToken ?? process.env[`${ENV_PREFIX}_API_TOKEN`] ?? "";
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
  */
@@ -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(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robinmordasiewicz/f5xc-xcsh",
3
- "version": "1.0.82-2512312156",
3
+ "version": "1.0.82-2512312318",
4
4
  "description": "F5 Distributed Cloud Shell - Interactive CLI for F5 XC",
5
5
  "type": "module",
6
6
  "bin": {