diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-06-03 11:33:05 -0400 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-06-03 11:33:05 -0400 |
commit | 22f6e4a01aed7955f608fcaa2198dc7da7902f3e (patch) | |
tree | 1a54b9c2456ad5b58d4b9b11050a1c686cbdc2cb /extension/src | |
parent | fe22fcefa370e8a609123490ceeb7e646d949af3 (diff) | |
download | sncontinue-22f6e4a01aed7955f608fcaa2198dc7da7902f3e.tar.gz sncontinue-22f6e4a01aed7955f608fcaa2198dc7da7902f3e.tar.bz2 sncontinue-22f6e4a01aed7955f608fcaa2198dc7da7902f3e.zip |
API tokens set through global Vsc settings
Diffstat (limited to 'extension/src')
-rw-r--r-- | extension/src/continueIdeClient.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index 03e5fbc5..a5a1c5dc 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -74,6 +74,12 @@ class IdeProtocolClient { this.messenger?.send("workspaceDirectory", { workspaceDirectory: this.getWorkspaceDirectory(), }); + break; + case "getUserSecret": + this.messenger?.send("getUserSecret", { + value: await this.getUserSecret(data.key), + }); + break; case "openFiles": this.messenger?.send("openFiles", { openFiles: this.getOpenFiles(), @@ -130,6 +136,27 @@ class IdeProtocolClient { openEditorAndRevealRange(filepath, undefined, vscode.ViewColumn.One); } + async getUserSecret(key: string) { + // Check if secret already exists in VS Code settings (global) + let secret = vscode.workspace.getConfiguration("continue").get(key); + if (secret && secret !== "") return secret; + + // If not, ask user for secret + while (typeof secret === "undefined" || secret === "") { + secret = await vscode.window.showInputBox({ + prompt: `Enter secret for ${key}`, + password: true, + }); + } + + // Add secret to VS Code settings + vscode.workspace + .getConfiguration("continue") + .update(key, secret, vscode.ConfigurationTarget.Global); + + return secret; + } + // ------------------------------------ // // Initiate Request |