From 32e977e16ef1a076bdbd17ee4518385cbe1ed77b Mon Sep 17 00:00:00 2001 From: "Kuang-Chen (KC) Lu" Date: Mon, 9 Nov 2026 17:07:29 -0500 Subject: [PATCH] Keep server credentials out of the messages exchanged with the language server The client returned the resolved ServerSpec, credentials included, to the server, which echoed it back on every REST request; the verbose trace printed the password each time. The server never uses the credentials, so send the spec without them and re-attach them from the client's resolvedServerSpecs cache when the server asks for a request. Fixes #429 --- client/src/extension.ts | 42 +++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/client/src/extension.ts b/client/src/extension.ts index 607d063..de264ee 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -103,6 +103,19 @@ const resolvedServerSpecs = new (class { } })(); +/** `server` as the language server gets it: credentials stay in `resolvedServerSpecs`, off the LSP channel and its trace. */ +function withoutCredentials(server: ServerSpec): ServerSpec { + const copy: ServerSpec & { password?: string } = { ...server }; + delete copy.credentials; + delete copy.password; + return copy; +} + +/** `server` with the credentials `resolvedServerSpecs` holds for it, for making a request on the language server's behalf. */ +function withCredentials(server: ServerSpec): ServerSpec { + return { ...server, credentials: resolvedServerSpecs.list(server)[0]?.credentials }; +} + export async function activate(context: ExtensionContext) { // Get the main extension exported API const objectScriptExt = extensions.getExtension("intersystems-community.vscode-objectscript")!; @@ -259,7 +272,10 @@ export async function activate(context: ExtensionContext) { const textDecoder = new TextDecoder(); context.subscriptions.push( // Register custom request handlers - client.onRequest("intersystems/server/resolveFromUri", (uri) => resolveServerSpec(Uri.parse(uri))), + client.onRequest("intersystems/server/resolveFromUri", async (uri) => { + const server = await resolveServerSpec(Uri.parse(uri)); + return server && withoutCredentials(server); + }), client.onRequest("intersystems/uri/localToVirtual", (uri) => { const newuri: Uri = objectScriptApi.serverDocumentUriForUri(Uri.parse(uri)); return newuri.toString(); @@ -283,14 +299,20 @@ export async function activate(context: ExtensionContext) { }), client.onRequest("intersystems/server/makeRESTRequest", async (args) => { // As of version 2.0.0, REST requests are made on the client side - return makeRESTRequest(args.method, args.api, args.path, args.server, args.data, args.checksum, args.params).then( - (respdata) => { - if (respdata) { - // Can't return the entire AxiosResponse object because it's not JSON.stringify-able due to circularity - return { data: respdata.data }; - } - }, - ); + return makeRESTRequest( + args.method, + args.api, + args.path, + withCredentials(args.server), + args.data, + args.checksum, + args.params, + ).then((respdata) => { + if (respdata) { + // Can't return the entire AxiosResponse object because it's not JSON.stringify-able due to circularity + return { data: respdata.data }; + } + }); }), client.onRequest( "intersystems/uri/getText", @@ -318,7 +340,7 @@ export async function activate(context: ExtensionContext) { "GET", 1, `/doc/${fileName}`, - params.server, + withCredentials(params.server), undefined, undefined, docParams,