@@ -708,21 +708,27 @@ export class CliManager {
708708 /**
709709 * Configure the CLI for the deployment with the provided hostname.
710710 *
711- * Falsey URLs and null tokens are a no-op; we avoid unconfiguring the CLI to
712- * avoid breaking existing connections.
711+ * Stores credentials in the OS keyring when available, otherwise falls back
712+ * to writing plaintext files under --global-config for the CLI.
713+ *
714+ * Both URL and token are required. Empty tokens are allowed (e.g. mTLS
715+ * authentication) but the URL must be a non-empty string.
713716 */
714717 public async configure (
715718 safeHostname : string ,
716- url : string | undefined ,
717- token : string | null ,
719+ url : string ,
720+ token : string ,
718721 featureSet : FeatureSet ,
719722 ) {
723+ if ( ! url ) {
724+ throw new Error ( "URL is required to configure the CLI" ) ;
725+ }
726+
720727 const configs = vscode . workspace . getConfiguration ( ) ;
721- if ( shouldUseKeyring ( configs , featureSet ) && url && token !== null ) {
728+ if ( shouldUseKeyring ( configs , featureSet ) ) {
722729 try {
723730 this . keyringStore . setToken ( url , token ) ;
724731 this . output . info ( "Stored token in OS keyring for" , url ) ;
725- return ;
726732 } catch ( error ) {
727733 this . output . error ( "Failed to store token in OS keyring:" , error ) ;
728734 vscode . window
@@ -741,11 +747,12 @@ export class CliManager {
741747 } ) ;
742748 throw error ;
743749 }
750+ } else {
751+ await Promise . all ( [
752+ this . writeUrlToGlobalConfig ( safeHostname , url ) ,
753+ this . writeTokenToGlobalConfig ( safeHostname , token ) ,
754+ ] ) ;
744755 }
745- await Promise . all ( [
746- this . updateUrlForCli ( safeHostname , url ) ,
747- this . updateTokenForCli ( safeHostname , token ) ,
748- ] ) ;
749756 }
750757
751758 /**
@@ -774,33 +781,22 @@ export class CliManager {
774781 }
775782
776783 /**
777- * Update the URL for the deployment with the provided hostname on disk which
778- * can be used by the CLI via --url-file. If the URL is falsey, do nothing.
779- *
780- * If the hostname is empty, read the old deployment-unaware config instead.
784+ * Write the URL to the --global-config directory for the CLI.
781785 */
782- private async updateUrlForCli (
786+ private async writeUrlToGlobalConfig (
783787 safeHostname : string ,
784- url : string | undefined ,
788+ url : string ,
785789 ) : Promise < void > {
786- if ( url ) {
787- const urlPath = this . pathResolver . getUrlPath ( safeHostname ) ;
788- await this . atomicWriteFile ( urlPath , url ) ;
789- }
790+ const urlPath = this . pathResolver . getUrlPath ( safeHostname ) ;
791+ await this . atomicWriteFile ( urlPath , url ) ;
790792 }
791793
792794 /**
793- * Update the session token for a deployment with the provided hostname on
794- * disk which can be used by the CLI via --session-token-file. If the token
795- * is null, do nothing.
796- *
797- * If the hostname is empty, read the old deployment-unaware config instead.
795+ * Write the session token to the --global-config directory for the CLI.
798796 */
799- private async updateTokenForCli ( safeHostname : string , token : string | null ) {
800- if ( token !== null ) {
801- const tokenPath = this . pathResolver . getSessionTokenPath ( safeHostname ) ;
802- await this . atomicWriteFile ( tokenPath , token ) ;
803- }
797+ private async writeTokenToGlobalConfig ( safeHostname : string , token : string ) {
798+ const tokenPath = this . pathResolver . getSessionTokenPath ( safeHostname ) ;
799+ await this . atomicWriteFile ( tokenPath , token ) ;
804800 }
805801
806802 /**
0 commit comments