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 | b2fbe075b5ba91636d643f88be1c04ea576e2622 (patch) | |
tree | 000a5262118f2479f5ee41b7bae37e8133d11dbd /extension/src | |
parent | 917ba983d604bf9f590265b38e65be5c75643828 (diff) | |
download | sncontinue-b2fbe075b5ba91636d643f88be1c04ea576e2622.tar.gz sncontinue-b2fbe075b5ba91636d643f88be1c04ea576e2622.tar.bz2 sncontinue-b2fbe075b5ba91636d643f88be1c04ea576e2622.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 |