From 7baa5f8983162c66ee00affeac957682db32942b Mon Sep 17 00:00:00 2001 From: Luke Watts Date: Fri, 10 Apr 2020 14:52:00 +0200 Subject: [PATCH] feat: adds Command to remove auth token from local config It should be possible to remove your API token from the IDE --- package.json | 4 ++++ src/extension.js | 12 +++++++++++- src/getImports/snykAPI.js | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ff91489..d7fc62c 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,10 @@ "command": "vulnCost.signIn", "title": "Snyk: Signup/create a Snyk account" }, + { + "command": "vulnCost.signOut", + "title": "Snyk: Sign out" + }, { "command": "vulnCost.showOutput", "title": "Snyk: Show vulnerability report" diff --git a/src/extension.js b/src/extension.js index 41eb370..5bd01a7 100644 --- a/src/extension.js +++ b/src/extension.js @@ -9,7 +9,7 @@ import * as vscode from 'vscode'; import { calculated, flushDecorations, clearDecorations, clearShown} from './decorator'; import logger from './logger'; import { SnykVulnInfo } from './SnykAction'; -import { isAuthed, setToken } from './getImports/snykAPI'; +import { isAuthed, setToken, clearToken } from './getImports/snykAPI'; import { refreshDiagnostics } from './diagnostics'; import { v4 as uuidv4 } from 'uuid'; import authenticate from './authenticate'; @@ -88,6 +88,16 @@ export function activate(context) { }) ); + context.subscriptions.push( + commands.registerCommand('vulnCost.signOut', () => { + window.showInformationMessage('Removing auth token'); + + clearToken(); + + return; + }) + ); + context.subscriptions.push( commands.registerCommand('vulnCost.signIn', () => { if (isAuthed()) { diff --git a/src/getImports/snykAPI.js b/src/getImports/snykAPI.js index 142c41a..5383b30 100644 --- a/src/getImports/snykAPI.js +++ b/src/getImports/snykAPI.js @@ -12,4 +12,8 @@ export const setToken = t => { export const getToken = () => token; +export const clearToken = () => { + userConfig.delete('api'); +} + export default token;