diff --git a/package.json b/package.json index 47d41bd..7fe6ee5 100644 --- a/package.json +++ b/package.json @@ -80,11 +80,6 @@ "title": "Stop LocalStack", "category": "LocalStack" }, - { - "command": "localstack.authenticate", - "title": "Authenticate", - "category": "LocalStack" - }, { "command": "localstack.openLicensePage", "title": "Open license page", diff --git a/src/extension.ts b/src/extension.ts index f4f02c2..059251c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -2,7 +2,6 @@ import ms from "ms"; import { StatusBarAlignment, window } from "vscode"; import type { ExtensionContext } from "vscode"; -import authenticate from "./plugins/authenticate.ts"; import configureAws from "./plugins/configure-aws.ts"; import logs from "./plugins/logs.ts"; import manage from "./plugins/manage.ts"; @@ -18,7 +17,6 @@ import { createTimeTracker } from "./utils/time-tracker.ts"; const plugins = new PluginManager([ setup, - authenticate, configureAws, manage, statusBar, diff --git a/src/plugins/authenticate.ts b/src/plugins/authenticate.ts deleted file mode 100644 index ed5329e..0000000 --- a/src/plugins/authenticate.ts +++ /dev/null @@ -1,149 +0,0 @@ -import pMinDelay from "p-min-delay"; -import { commands, ProgressLocation, window } from "vscode"; - -import { createPlugin } from "../plugins.ts"; -import { requestAuthentication, saveAuthToken } from "../utils/authenticate.ts"; - -const MIN_TIME_BETWEEN_STEPS_MS = 1_000; // 1s - -export default createPlugin( - "authenticate", - ({ context, outputChannel, telemetry }) => { - context.subscriptions.push( - commands.registerCommand("localstack.authenticate", async () => { - const startedAt = new Date().toISOString(); - const selection = await window.showInformationMessage( - "Choose authentication method", - "Sign in to LocalStack", - "Enter auth token", - ); - if (selection === "Sign in to LocalStack") { - window.withProgress( - { - location: ProgressLocation.Notification, - title: "Authenticate", - cancellable: true, - }, - async (progress, cancellationToken) => { - ///////////////////////////////////////////////////////////////////// - progress.report({ - message: - "Waiting for authentication response from the browser...", - }); - const { authToken } = await pMinDelay( - requestAuthentication(context, undefined), - MIN_TIME_BETWEEN_STEPS_MS, - ); - if (cancellationToken.isCancellationRequested) { - telemetry.track({ - name: "auth_token_configured", - payload: { - namespace: "onboarding", - origin: "manual_trigger", - position: 2, - started_at: startedAt, - ended_at: new Date().toISOString(), - status: "CANCELLED", - }, - }); - return; - } - - ///////////////////////////////////////////////////////////////////// - progress.report({ - message: "Authenticating to file...", - }); - await pMinDelay( - saveAuthToken(authToken, outputChannel), - MIN_TIME_BETWEEN_STEPS_MS, - ); - - ///////////////////////////////////////////////////////////////////// - window.showInformationMessage("Authentication successful."); - telemetry.track({ - name: "auth_token_configured", - payload: { - namespace: "onboarding", - origin: "manual_trigger", - position: 2, - auth_token: authToken, - started_at: startedAt, - ended_at: new Date().toISOString(), - status: "COMPLETED", - }, - }); - }, - ); - } else if (selection === "Enter auth token") { - const token = await window.showInputBox({ - prompt: "Enter your LocalStack Auth Token", - placeHolder: "Paste your auth token here", - ignoreFocusOut: true, - }); - - if (!token) { - telemetry.track({ - name: "auth_token_configured", - payload: { - namespace: "onboarding", - origin: "manual_trigger", - position: 2, - started_at: startedAt, - ended_at: new Date().toISOString(), - status: "FAILED", - errors: ["No token was provided."], - }, - }); - return; - } - - if (!token.startsWith("ls-")) { - const error_msg = 'The auth token should start with "ls-".'; - window.showErrorMessage(error_msg); - - telemetry.track({ - name: "auth_token_configured", - payload: { - namespace: "onboarding", - origin: "manual_trigger", - position: 2, - started_at: startedAt, - ended_at: new Date().toISOString(), - status: "FAILED", - errors: [error_msg], - }, - }); - return; - } - - await saveAuthToken(token, outputChannel); - window.showInformationMessage("Authentication successful."); - telemetry.track({ - name: "auth_token_configured", - payload: { - namespace: "onboarding", - origin: "manual_trigger", - position: 2, - auth_token: token, - started_at: startedAt, - ended_at: new Date().toISOString(), - status: "COMPLETED", - }, - }); - } else if (selection === undefined) { - telemetry.track({ - name: "auth_token_configured", - payload: { - namespace: "onboarding", - origin: "manual_trigger", - position: 2, - started_at: startedAt, - ended_at: new Date().toISOString(), - status: "CANCELLED", - }, - }); - } - }), - ); - }, -);