All files / src/config secret.ts

55% Statements 11/20
100% Branches 0/0
0% Functions 0/4
55% Lines 11/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 212x 2x 2x 2x 2x     2x 2x     2x 2x     2x 2x        
import * as vscode from 'vscode';
 
const SECRET_KEY = 'vscode-code-reviewer.apiKey';
 
export async function getApiKey(context: vscode.ExtensionContext): Promise<string | undefined> {
  return context.secrets.get(SECRET_KEY);
}
 
export async function setApiKey(context: vscode.ExtensionContext, value: string): Promise<void> {
  await context.secrets.store(SECRET_KEY, value);
}
 
export async function deleteApiKey(context: vscode.ExtensionContext): Promise<void> {
  await context.secrets.delete(SECRET_KEY);
}
 
export async function isApiKeyConfigured(context: vscode.ExtensionContext): Promise<boolean> {
  const key = await getApiKey(context);
  return !!key;
}