From c2fa11dd98444dd277852d87f07c5ac745b53e97 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 17 May 2025 21:28:34 -0700 Subject: [PATCH 01/12] remove unused ControlPlaneClient methods --- core/control-plane/client.ts | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 77a3dc108..9fab604d4 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -99,22 +99,6 @@ export class ControlPlaneClient { return resp; } - public async listWorkspaces(): Promise { - const userId = await this.userId; - if (!userId) { - return []; - } - - try { - const resp = await this.request("workspaces", { - method: "GET", - }); - return (await resp.json()) as any; - } catch (e) { - return []; - } - } - public async listAssistants(organizationId: string | null): Promise< { configResult: ConfigResult; @@ -183,16 +167,4 @@ export class ControlPlaneClient { return null; } } - - async getSettingsForWorkspace(workspaceId: string): Promise { - const userId = await this.userId; - if (!userId) { - throw new Error("No user id"); - } - - const resp = await this.request(`workspaces/${workspaceId}`, { - method: "GET", - }); - return ((await resp.json()) as any).settings; - } } From 3b2ef40e4532573df3d76c810f845087669f632a Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 18 May 2025 16:37:29 -0700 Subject: [PATCH 02/12] separate type for custom environments --- core/control-plane/auth/index.ts | 7 ++- core/control-plane/env.ts | 19 +++++++- .../vscode/src/stubs/WorkOsAuthProvider.ts | 45 ++++++++++++++++--- 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/core/control-plane/auth/index.ts b/core/control-plane/auth/index.ts index a3441ab65..2bb7f5daf 100644 --- a/core/control-plane/auth/index.ts +++ b/core/control-plane/auth/index.ts @@ -1,12 +1,17 @@ import { v4 as uuidv4 } from "uuid"; import { IdeSettings } from "../.."; -import { getControlPlaneEnv } from "../env"; +import { getControlPlaneEnv, isHubEnv } from "../env"; export async function getAuthUrlForTokenPage( ideSettingsPromise: Promise, useOnboarding: boolean, ): Promise { const env = await getControlPlaneEnv(ideSettingsPromise); + + if (!isHubEnv(env)) { + throw new Error("Sign in disabled"); + } + const url = new URL("https://api.workos.com/user_management/authorize"); const params = { response_type: "code", diff --git a/core/control-plane/env.ts b/core/control-plane/env.ts index acbc20b59..835fa63c7 100644 --- a/core/control-plane/env.ts +++ b/core/control-plane/env.ts @@ -5,7 +5,7 @@ import { getStagingEnvironmentDotFilePath, } from "../util/paths"; -export interface ControlPlaneEnv { +export interface HubEnv { DEFAULT_CONTROL_PLANE_PROXY_URL: string; CONTROL_PLANE_URL: string; AUTH_TYPE: string; @@ -13,6 +13,23 @@ export interface ControlPlaneEnv { APP_URL: string; } +export interface OnPremEnv { + AUTH_TYPE: "on-prem"; + DEFAULT_CONTROL_PLANE_PROXY_URL: string; + CONTROL_PLANE_URL: string; + APP_URL: string; +} + +export type ControlPlaneEnv = HubEnv | OnPremEnv; + +export function isHubEnv(env: ControlPlaneEnv): env is HubEnv { + return ( + "AUTH_TYPE" in env && + env.AUTH_TYPE !== "on-prem" && + "WORKOS_CLIENT_ID" in env + ); +} + export const EXTENSION_NAME = "continue"; const WORKOS_CLIENT_ID_PRODUCTION = "client_01J0FW6XN8N2XJAECF7NE0Y65J"; diff --git a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts index 2e6acfb86..8da93fe9c 100644 --- a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts +++ b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts @@ -1,7 +1,11 @@ import crypto from "crypto"; import { ControlPlaneSessionInfo } from "core/control-plane/client"; -import { getControlPlaneEnvSync } from "core/control-plane/env"; +import { + getControlPlaneEnvSync, + HubEnv, + isHubEnv, +} from "core/control-plane/env"; import fetch from "node-fetch"; import { v4 as uuidv4 } from "uuid"; import { @@ -280,12 +284,21 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable { try { const codeVerifier = generateRandomString(64); const codeChallenge = await generateCodeChallenge(codeVerifier); - const token = await this.login(codeChallenge, scopes); + + if (!isHubEnv(controlPlaneEnv)) { + throw new Error("Login is disabled"); + } + + const token = await this.login(codeChallenge, controlPlaneEnv, scopes); if (!token) { throw new Error(`Continue login failure`); } - const userInfo = (await this.getUserInfo(token, codeVerifier)) as any; + const userInfo = (await this.getUserInfo( + token, + codeVerifier, + controlPlaneEnv, + )) as any; const { user, access_token, refresh_token } = userInfo; const session: ContinueAuthenticationSession = { @@ -352,7 +365,11 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable { /** * Log in to Continue */ - private async login(codeChallenge: string, scopes: string[] = []) { + private async login( + codeChallenge: string, + hubEnv: HubEnv, + scopes: string[] = [], + ) { return await window.withProgress( { location: ProgressLocation.Notification, @@ -369,7 +386,7 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable { const url = new URL("https://api.workos.com/user_management/authorize"); const params = { response_type: "code", - client_id: controlPlaneEnv.WORKOS_CLIENT_ID, + client_id: hubEnv.WORKOS_CLIENT_ID, redirect_uri: this.redirectUri, state: stateId, code_challenge: codeChallenge, @@ -458,7 +475,11 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable { * @param token * @returns */ - private async getUserInfo(token: string, codeVerifier: string) { + private async getUserInfo( + token: string, + codeVerifier: string, + hubEnv: HubEnv, + ) { const resp = await fetch( "https://api.workos.com/user_management/authenticate", { @@ -467,7 +488,7 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable { "Content-Type": "application/json", }, body: JSON.stringify({ - client_id: controlPlaneEnv.WORKOS_CLIENT_ID, + client_id: hubEnv.WORKOS_CLIENT_ID, code_verifier: codeVerifier, grant_type: "authorization_code", code: token, @@ -484,6 +505,16 @@ export async function getControlPlaneSessionInfo( silent: boolean, useOnboarding: boolean, ): Promise { + if (!isHubEnv(controlPlaneEnv)) { + return { + accessToken: "", // TODO: Could make a discriminated union type instead of doing this + account: { + id: "", + label: "", + }, + }; + } + try { if (useOnboarding) { WorkOsAuthProvider.useOnboardingUri = true; From 8f0978a5e129a73bb01b0fc140c0717036c6e40e Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 18 May 2025 18:14:50 -0700 Subject: [PATCH 03/12] separate SessionInfo types --- core/config/ConfigHandler.ts | 14 ++--- core/control-plane/AuthTypes.ts | 55 +++++++++++++++++++ core/control-plane/auth/index.ts | 3 +- core/control-plane/client.ts | 41 ++++++-------- core/control-plane/env.ts | 37 ++----------- core/protocol/core.ts | 2 +- core/protocol/ide.ts | 5 +- core/protocol/webview.ts | 2 +- .../vscode/src/stubs/WorkOsAuthProvider.ts | 20 +++---- gui/src/context/Auth.tsx | 2 +- gui/src/context/MockIdeMessenger.ts | 2 + gui/src/pages/config/AccountButton.tsx | 6 ++ 12 files changed, 108 insertions(+), 81 deletions(-) create mode 100644 core/control-plane/AuthTypes.ts diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 76ccceb81..ff3228287 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -1,10 +1,6 @@ import { ConfigResult } from "@continuedev/config-yaml"; -import { - ControlPlaneClient, - ControlPlaneSessionInfo, -} from "../control-plane/client.js"; -import { getControlPlaneEnv } from "../control-plane/env.js"; +import { ControlPlaneClient } from "../control-plane/client.js"; import { BrowserSerializedContinueConfig, ContinueConfig, @@ -15,6 +11,11 @@ import { } from "../index.js"; import { GlobalContext } from "../util/GlobalContext.js"; +import { + AuthType, + ControlPlaneSessionInfo, +} from "../control-plane/AuthTypes.js"; +import { getControlPlaneEnv } from "../control-plane/env.js"; import { logger } from "../util/logger.js"; import { ASSISTANTS, @@ -136,8 +137,7 @@ export class ConfigHandler { } private async getOrgs(): Promise { - const userId = await this.controlPlaneClient.userId; - if (userId) { + if (await this.controlPlaneClient.isSignedIn()) { const orgDescs = await this.controlPlaneClient.listOrganizations(); const personalHubOrg = await this.getPersonalHubOrg(); const hubOrgs = await Promise.all( diff --git a/core/control-plane/AuthTypes.ts b/core/control-plane/AuthTypes.ts new file mode 100644 index 000000000..c926efac1 --- /dev/null +++ b/core/control-plane/AuthTypes.ts @@ -0,0 +1,55 @@ +export interface HubSessionInfo { + AUTH_TYPE: AuthType.WorkOsProd | AuthType.WorkOsStaging; + accessToken: string; + account: { + label: string; + id: string; + }; +} + +export interface OnPremSessionInfo { + AUTH_TYPE: AuthType.OnPrem; +} + +export type ControlPlaneSessionInfo = HubSessionInfo | OnPremSessionInfo; + +export function isHubSession( + sessionInfo: ControlPlaneSessionInfo | undefined, +): sessionInfo is HubSessionInfo { + return ( + sessionInfo !== undefined && + (sessionInfo.AUTH_TYPE === AuthType.WorkOsProd || + sessionInfo.AUTH_TYPE === AuthType.WorkOsStaging) + ); +} + +export enum AuthType { + WorkOsProd = "continue", + WorkOsStaging = "continue-staging", + OnPrem = "on-prem", +} + +export interface HubEnv { + DEFAULT_CONTROL_PLANE_PROXY_URL: string; + CONTROL_PLANE_URL: string; + AUTH_TYPE: AuthType.WorkOsProd | AuthType.WorkOsStaging; + WORKOS_CLIENT_ID: string; + APP_URL: string; +} + +export interface OnPremEnv { + AUTH_TYPE: AuthType.OnPrem; + DEFAULT_CONTROL_PLANE_PROXY_URL: string; + CONTROL_PLANE_URL: string; + APP_URL: string; +} + +export type ControlPlaneEnv = HubEnv | OnPremEnv; + +export function isHubEnv(env: ControlPlaneEnv): env is HubEnv { + return ( + "AUTH_TYPE" in env && + env.AUTH_TYPE !== "on-prem" && + "WORKOS_CLIENT_ID" in env + ); +} diff --git a/core/control-plane/auth/index.ts b/core/control-plane/auth/index.ts index 2bb7f5daf..5e8748ab9 100644 --- a/core/control-plane/auth/index.ts +++ b/core/control-plane/auth/index.ts @@ -1,6 +1,7 @@ import { v4 as uuidv4 } from "uuid"; import { IdeSettings } from "../.."; -import { getControlPlaneEnv, isHubEnv } from "../env"; +import { isHubEnv } from "../AuthTypes"; +import { getControlPlaneEnv } from "../env"; export async function getAuthUrlForTokenPage( ideSettingsPromise: Promise, diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 9fab604d4..914ada0ba 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -12,16 +12,9 @@ import fetch, { RequestInit, Response } from "node-fetch"; import { OrganizationDescription } from "../config/ProfileLifecycleManager.js"; import { IdeSettings, ModelDescription } from "../index.js"; +import { ControlPlaneSessionInfo, isHubSession } from "./AuthTypes.js"; import { getControlPlaneEnv } from "./env.js"; -export interface ControlPlaneSessionInfo { - accessToken: string; - account: { - label: string; - id: string; - }; -} - export interface ControlPlaneWorkspace { id: string; name: string; @@ -45,8 +38,7 @@ export class ControlPlaneClient { fqsns: FQSN[], orgScopeId: string | null, ): Promise<(SecretResult | undefined)[]> { - const userId = await this.userId; - if (!userId) { + if (!this.isSignedIn()) { return fqsns.map((fqsn) => ({ found: false, fqsn, @@ -64,19 +56,24 @@ export class ControlPlaneClient { return (await resp.json()) as any; } - get userId(): Promise { - return this.sessionInfoPromise.then( - (sessionInfo) => sessionInfo?.account.id, - ); + async isSignedIn(): Promise { + const sessionInfo = await this.sessionInfoPromise; + return !!sessionInfo; } async getAccessToken(): Promise { - return (await this.sessionInfoPromise)?.accessToken; + const sessionInfo = await this.sessionInfoPromise; + return isHubSession(sessionInfo) ? sessionInfo.accessToken : undefined; } private async request(path: string, init: RequestInit): Promise { - const accessToken = await this.getAccessToken(); - if (!accessToken) { + const sessionInfo = await this.sessionInfoPromise; + const hubSession = isHubSession(sessionInfo); + + const accessToken = hubSession ? sessionInfo.accessToken : undefined; + + // Bearer token not necessary for on-prem auth type + if (!accessToken && hubSession) { throw new Error("No access token"); } @@ -108,8 +105,7 @@ export class ControlPlaneClient { rawYaml: string; }[] > { - const userId = await this.userId; - if (!userId) { + if (!this.isSignedIn()) { return []; } @@ -128,9 +124,7 @@ export class ControlPlaneClient { } public async listOrganizations(): Promise> { - const userId = await this.userId; - - if (!userId) { + if (!this.isSignedIn()) { return []; } @@ -148,8 +142,7 @@ export class ControlPlaneClient { public async listAssistantFullSlugs( organizationId: string | null, ): Promise { - const userId = await this.userId; - if (!userId) { + if (!this.isSignedIn()) { return null; } diff --git a/core/control-plane/env.ts b/core/control-plane/env.ts index 835fa63c7..c04f90d1b 100644 --- a/core/control-plane/env.ts +++ b/core/control-plane/env.ts @@ -4,44 +4,17 @@ import { getLocalEnvironmentDotFilePath, getStagingEnvironmentDotFilePath, } from "../util/paths"; - -export interface HubEnv { - DEFAULT_CONTROL_PLANE_PROXY_URL: string; - CONTROL_PLANE_URL: string; - AUTH_TYPE: string; - WORKOS_CLIENT_ID: string; - APP_URL: string; -} - -export interface OnPremEnv { - AUTH_TYPE: "on-prem"; - DEFAULT_CONTROL_PLANE_PROXY_URL: string; - CONTROL_PLANE_URL: string; - APP_URL: string; -} - -export type ControlPlaneEnv = HubEnv | OnPremEnv; - -export function isHubEnv(env: ControlPlaneEnv): env is HubEnv { - return ( - "AUTH_TYPE" in env && - env.AUTH_TYPE !== "on-prem" && - "WORKOS_CLIENT_ID" in env - ); -} +import { AuthType, ControlPlaneEnv } from "./AuthTypes"; export const EXTENSION_NAME = "continue"; const WORKOS_CLIENT_ID_PRODUCTION = "client_01J0FW6XN8N2XJAECF7NE0Y65J"; const WORKOS_CLIENT_ID_STAGING = "client_01J0FW6XCPMJMQ3CG51RB4HBZQ"; -const WORKOS_ENV_ID_PRODUCTION = "continue"; -const WORKOS_ENV_ID_STAGING = "continue-staging"; - const PRODUCTION_HUB_ENV: ControlPlaneEnv = { DEFAULT_CONTROL_PLANE_PROXY_URL: "https://api.continue.dev/", CONTROL_PLANE_URL: "https://api.continue.dev/", - AUTH_TYPE: WORKOS_ENV_ID_PRODUCTION, + AUTH_TYPE: AuthType.WorkOsProd, WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_PRODUCTION, APP_URL: "https://hub.continue.dev/", }; @@ -49,7 +22,7 @@ const PRODUCTION_HUB_ENV: ControlPlaneEnv = { const STAGING_ENV: ControlPlaneEnv = { DEFAULT_CONTROL_PLANE_PROXY_URL: "https://api.continue-stage.tools/", CONTROL_PLANE_URL: "https://api.continue-stage.tools/", - AUTH_TYPE: WORKOS_ENV_ID_STAGING, + AUTH_TYPE: AuthType.WorkOsStaging, WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING, APP_URL: "https://hub.continue-stage.tools/", }; @@ -57,7 +30,7 @@ const STAGING_ENV: ControlPlaneEnv = { const TEST_ENV: ControlPlaneEnv = { DEFAULT_CONTROL_PLANE_PROXY_URL: "https://api-test.continue.dev/", CONTROL_PLANE_URL: "https://api-test.continue.dev/", - AUTH_TYPE: WORKOS_ENV_ID_STAGING, + AUTH_TYPE: AuthType.WorkOsStaging, WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING, APP_URL: "https://app-test.continue.dev/", }; @@ -65,7 +38,7 @@ const TEST_ENV: ControlPlaneEnv = { const LOCAL_ENV: ControlPlaneEnv = { DEFAULT_CONTROL_PLANE_PROXY_URL: "http://localhost:3001/", CONTROL_PLANE_URL: "http://localhost:3001/", - AUTH_TYPE: WORKOS_ENV_ID_STAGING, + AUTH_TYPE: AuthType.WorkOsStaging, WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING, APP_URL: "http://localhost:3000/", }; diff --git a/core/protocol/core.ts b/core/protocol/core.ts index ef4cde60b..8936cb3eb 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -33,7 +33,7 @@ import { ToolCall, } from "../"; import { SerializedOrgWithProfiles } from "../config/ProfileLifecycleManager"; -import { ControlPlaneSessionInfo } from "../control-plane/client"; +import { ControlPlaneSessionInfo } from "../control-plane/AuthTypes"; export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart"; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 88e7f779c..324772ace 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -1,5 +1,3 @@ -import { ControlPlaneSessionInfo } from "../control-plane/client"; - import type { ContinueRcJson, DiffLine, @@ -16,6 +14,7 @@ import type { TerminalOptions, Thread, } from "../"; +import { ControlPlaneSessionInfo } from "../control-plane/AuthTypes"; export interface GetGhTokenArgs { force?: boolean; @@ -99,7 +98,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { ControlPlaneSessionInfo | undefined, ]; logoutOfControlPlane: [undefined, void]; - reportError:[any, void]; + reportError: [any, void]; closeSidebar: [undefined, void]; }; diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index 2e6ec3cff..534517d6f 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -1,6 +1,6 @@ import { ConfigResult } from "@continuedev/config-yaml"; import { SerializedOrgWithProfiles } from "../config/ProfileLifecycleManager.js"; -import { ControlPlaneSessionInfo } from "../control-plane/client.js"; +import { ControlPlaneSessionInfo } from "../control-plane/AuthTypes.js"; import type { BrowserSerializedContinueConfig, ContextItemWithId, diff --git a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts index 8da93fe9c..73f36afdb 100644 --- a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts +++ b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts @@ -1,11 +1,6 @@ import crypto from "crypto"; -import { ControlPlaneSessionInfo } from "core/control-plane/client"; -import { - getControlPlaneEnvSync, - HubEnv, - isHubEnv, -} from "core/control-plane/env"; +import { getControlPlaneEnvSync } from "core/control-plane/env"; import fetch from "node-fetch"; import { v4 as uuidv4 } from "uuid"; import { @@ -22,6 +17,12 @@ import { window, } from "vscode"; +import { + AuthType, + ControlPlaneSessionInfo, + HubEnv, + isHubEnv, +} from "core/control-plane/AuthTypes"; import { PromiseAdapter, promiseFromEvent } from "./promiseUtils"; import { SecretStorage } from "./SecretStorage"; import { UriEventHandler } from "./uriHandler"; @@ -507,11 +508,7 @@ export async function getControlPlaneSessionInfo( ): Promise { if (!isHubEnv(controlPlaneEnv)) { return { - accessToken: "", // TODO: Could make a discriminated union type instead of doing this - account: { - id: "", - label: "", - }, + AUTH_TYPE: AuthType.OnPrem, }; } @@ -529,6 +526,7 @@ export async function getControlPlaneSessionInfo( return undefined; } return { + AUTH_TYPE: controlPlaneEnv.AUTH_TYPE, accessToken: session.accessToken, account: { id: session.account.id, diff --git a/gui/src/context/Auth.tsx b/gui/src/context/Auth.tsx index 47e5845f9..8c928630d 100644 --- a/gui/src/context/Auth.tsx +++ b/gui/src/context/Auth.tsx @@ -2,7 +2,7 @@ import { OrganizationDescription, ProfileDescription, } from "core/config/ProfileLifecycleManager"; -import { ControlPlaneSessionInfo } from "core/control-plane/client"; +import { ControlPlaneSessionInfo } from "core/control-plane/AuthTypes"; import React, { createContext, useCallback, diff --git a/gui/src/context/MockIdeMessenger.ts b/gui/src/context/MockIdeMessenger.ts index 9ce072471..0e92384f1 100644 --- a/gui/src/context/MockIdeMessenger.ts +++ b/gui/src/context/MockIdeMessenger.ts @@ -1,4 +1,5 @@ import { IDE, PromptLog } from "core"; +import { AuthType } from "core/control-plane/AuthTypes"; import { FromIdeProtocol, FromWebviewProtocol, @@ -38,6 +39,7 @@ async function defaultMockHandleMessage( ]); case "getControlPlaneSessionInfo": return returnFor("getControlPlaneSessionInfo", { + AUTH_TYPE: AuthType.WorkOsStaging, accessToken: "", account: { label: "", diff --git a/gui/src/pages/config/AccountButton.tsx b/gui/src/pages/config/AccountButton.tsx index b293de719..2d6d06b4f 100644 --- a/gui/src/pages/config/AccountButton.tsx +++ b/gui/src/pages/config/AccountButton.tsx @@ -1,5 +1,6 @@ import { UserCircleIcon } from "@heroicons/react/24/solid"; +import { isHubSession } from "core/control-plane/AuthTypes"; import { SecondaryButton } from "../../components"; import { Popover, @@ -27,6 +28,11 @@ export function AccountButton() { ); } + // No login button for on-prem deployments + if (!isHubSession(session)) { + return null; + } + return ( {({ close }) => ( From 75608e7cf4b35ceb087b8be341645d4c97505ce4 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 18 May 2025 19:37:41 -0700 Subject: [PATCH 04/12] disable local assistants when using on prem deployment --- core/config/ConfigHandler.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index ff3228287..deae7da38 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -270,6 +270,13 @@ export class ConfigHandler { /** * Users can define as many local assistants as they want in a `.continue/assistants` folder */ + + // Local customization disabled for on-premise deployments + const env = await getControlPlaneEnv(this.ide.getIdeSettings()); + if (env.AUTH_TYPE === AuthType.OnPrem) { + return []; + } + const localProfiles: ProfileLifecycleManager[] = []; if (options.includeGlobal) { From dea7ce452b1802305ccb634e9659dbcf5f15abea Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 18 May 2025 19:43:20 -0700 Subject: [PATCH 05/12] add keys to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 95cd177a9..3f3671e74 100644 --- a/.gitignore +++ b/.gitignore @@ -166,4 +166,5 @@ extensions/.continue-debug/ *.iml .continuerules -**/.continue/assistants/ \ No newline at end of file +**/.continue/assistants/ +keys \ No newline at end of file From 6c7ffc709e20ae8f264e7c02dbf58220b826b35a Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 18 May 2025 19:43:50 -0700 Subject: [PATCH 06/12] ability to read MDM keys on Mac only --- core/control-plane/env.ts | 13 +++ core/control-plane/mdm.test.ts | 127 +++++++++++++++++++++++++ core/control-plane/mdm.ts | 166 +++++++++++++++++++++++++++++++++ core/package-lock.json | 41 ++++++++ core/package.json | 2 + 5 files changed, 349 insertions(+) create mode 100644 core/control-plane/mdm.test.ts create mode 100644 core/control-plane/mdm.ts diff --git a/core/control-plane/env.ts b/core/control-plane/env.ts index c04f90d1b..2d76017d2 100644 --- a/core/control-plane/env.ts +++ b/core/control-plane/env.ts @@ -5,6 +5,7 @@ import { getStagingEnvironmentDotFilePath, } from "../util/paths"; import { AuthType, ControlPlaneEnv } from "./AuthTypes"; +import { getMdmKeys } from "./mdm"; export const EXTENSION_NAME = "continue"; @@ -57,6 +58,18 @@ export async function getControlPlaneEnv( export function getControlPlaneEnvSync( ideTestEnvironment: IdeSettings["continueTestEnvironment"], ): ControlPlaneEnv { + // MDM override + const mdmKeys = getMdmKeys(); + if (mdmKeys) { + const { apiUrl } = mdmKeys; + return { + AUTH_TYPE: AuthType.OnPrem, + DEFAULT_CONTROL_PLANE_PROXY_URL: apiUrl, + CONTROL_PLANE_URL: apiUrl, + APP_URL: "https://hub.continue.dev/", + }; + } + // Note .local overrides .staging if (fs.existsSync(getLocalEnvironmentDotFilePath())) { return LOCAL_ENV; diff --git a/core/control-plane/mdm.test.ts b/core/control-plane/mdm.test.ts new file mode 100644 index 000000000..18fbe846a --- /dev/null +++ b/core/control-plane/mdm.test.ts @@ -0,0 +1,127 @@ +import * as crypto from "crypto"; +import { LicenseData, validateLicenseKey } from "./mdm"; + +// We'll create a real key pair once for all tests +const testKeyPair = crypto.generateKeyPairSync("rsa", { + modulusLength: 2048, + publicKeyEncoding: { + type: "spki", + format: "pem", + }, + privateKeyEncoding: { + type: "pkcs8", + format: "pem", + }, +}); + +// Custom function to create test licenses (replaces the original mock-dependent one) +function createTestLicense( + licenseData: LicenseData, + useValidSignature: boolean = true, +): string { + // Convert license data to a string + const licenseDataStr = JSON.stringify(licenseData); + + // Create a signature with our generated private key + const sign = crypto.createSign("SHA256"); + sign.update(licenseDataStr); + sign.end(); + + let signature: string; + if (useValidSignature) { + signature = sign.sign(testKeyPair.privateKey, "base64"); + } else { + // For invalid tests, create an intentionally wrong signature by signing different data + const wrongSign = crypto.createSign("SHA256"); + wrongSign.update(licenseDataStr + "tampered"); + wrongSign.end(); + signature = wrongSign.sign(testKeyPair.privateKey, "base64"); + } + // Combine data and signature into a license key + const licenseKeyObj = { + data: licenseDataStr, + signature: signature, + }; + + return Buffer.from(JSON.stringify(licenseKeyObj)).toString("base64"); +} + +// We need to test the actual implementation - which we can't mock with ESM +// Instead, we'll have tests that bypass validation or are expected to fail +// depending on what we're testing + +test("validateLicenseKey returns false for malformed license key", () => { + // Test with a completely invalid license key + const invalidLicenseKey = "not-a-valid-license-key"; + + // Test - no mocks, real validation + const result = validateLicenseKey(invalidLicenseKey); + + // Assert + expect(result).toBe(false); +}); + +test("validateLicenseKey returns false for invalid JSON in license key", () => { + // Create a malformed but base64-encoded string + const malformedLicenseKey = Buffer.from("this is not valid JSON").toString( + "base64", + ); + + // Test - no mocks, real validation + const result = validateLicenseKey(malformedLicenseKey); + + // Assert + expect(result).toBe(false); +}); + +test("validateLicenseKey returns false for expired license", () => { + // Without mocking, we expect this to fail signature verification + // We're testing the date logic by itself + const licenseData: LicenseData = { + customerId: "customer123", + createdAt: new Date(Date.now() - 2000 * 60 * 60 * 24).toISOString(), // Created 2 days ago + expiresAt: new Date(Date.now() - 1000 * 60 * 60 * 24).toISOString(), // Expired 1 day ago + }; + + // Create a license key - will fail verification but test logic still works + const expiredLicenseKey = createTestLicense(licenseData); + + // Test - expect false, either due to signature or expiration - both are valid test cases + const result = validateLicenseKey(expiredLicenseKey); + + // Assert + expect(result).toBe(false); +}); + +test("validateLicenseKey returns false for invalid signature", () => { + // Create license data with valid dates + const licenseData: LicenseData = { + customerId: "customer123", + createdAt: new Date().toISOString(), + expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString(), // Valid for 1 day + }; + + // Create a license with an invalid signature + const invalidSignatureKey = createTestLicense(licenseData, false); + + // Test - no mocks, real validation + const result = validateLicenseKey(invalidSignatureKey); + + // Assert + expect(result).toBe(false); +}); + +test("validateLicenseKey handles JSON parsing errors gracefully", () => { + // Create a base64 string that decodes to valid JSON but lacks required fields + const invalidStructureKey = Buffer.from( + JSON.stringify({ + notTheRightField: "wrong structure", + }), + ).toString("base64"); + + // Test - no mocks, real validation + const result = validateLicenseKey(invalidStructureKey); + + // Assert + expect(result).toBe(false); +}); diff --git a/core/control-plane/mdm.ts b/core/control-plane/mdm.ts new file mode 100644 index 000000000..8e92b4d02 --- /dev/null +++ b/core/control-plane/mdm.ts @@ -0,0 +1,166 @@ +import * as crypto from "crypto"; +import * as fs from "fs"; +import * as os from "os"; +import * as path from "path"; +import * as plist from "plist"; + +export interface MdmKeys { + licenseKey: string; + apiUrl: string; +} + +const CONTINUE_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz1pFVzsW2UScSnaPAwFp +93QU4+txtyJj8AOC3Kx7YkX1d48DGU2Fy1he7SXPHgcuhXYIqfWGn/Vy/4yJxXD7 +HlU8RM7LlWHRk7ecAvF4WtxZDjPE0OSG5T69w5f7tMCtQPQseInCKqleJuCjxrvA +zyTWTwKA1S6e+KxXS/kbqsumriljFujNr6Gmh8ygDnpF055Xo0vTenkMipVw/oYn +U0EHx5ic+Fmcob3EyOj25lu/CVYtU1Rn8jPbrBOMiIq5sePh2QXOwGRsuTiZk2mP +LXSsjLbeWHifRrQ18wj/PC990E33QaFGNFp0NcBXMPbq5eKYKEzKZ0GsxtLoGxar +FQIDAQAB +-----END PUBLIC KEY-----`; + +export interface LicenseData { + customerId: string; + createdAt: string; + expiresAt: string; +} + +export function validateLicenseKey(licenseKey: string): boolean { + try { + // Decode the base64 license key + const decodedString = Buffer.from(licenseKey, "base64").toString("utf8"); + const { data, signature } = JSON.parse(decodedString); + + // Verify the signature + const verify = crypto.createVerify("SHA256"); + verify.update(data); + verify.end(); + + const isValid = verify.verify(CONTINUE_PUBLIC_KEY, signature, "base64"); + + if (!isValid) return false; + + // Check license expiration + const licenseData: LicenseData = JSON.parse(data); + const expirationDate = new Date(licenseData.expiresAt); + const now = new Date(); + + return expirationDate > now; + } catch (error) { + console.error("License validation error:", error); + return false; + } +} + +function readMdmKeysMacOS(): MdmKeys | undefined { + try { + // MDM configuration is typically stored in /Library/Managed Preferences/ on macOS + // The filename is often the bundle identifier of the application + const mdmPaths = [ + // Organization-specific MDM plist + "/Library/Managed Preferences/dev.continue.app.plist", + // User-specific MDM plist + path.join( + os.homedir(), + "Library/Managed Preferences/dev.continue.app.plist", + ), + ]; + + // Try to find a valid MDM configuration file + for (const mdmPath of mdmPaths) { + if (fs.existsSync(mdmPath)) { + // Read the file content + const fileContent = fs.readFileSync(mdmPath, "utf8"); + + try { + // Parse the plist file using the plist package + const config = plist.parse(fileContent); + + // Extract the relevant fields from the config + // Config is an array of alternating keys and values + if (Array.isArray(config)) { + const configObj: Record = {}; + + // Convert array format [key1, value1, key2, value2, ...] to object + for (let i = 0; i < config.length; i += 2) { + if (i + 1 < config.length) { + const key = config[i]; + const value = config[i + 1]; + if (typeof key === "string") { + configObj[key] = value as string; + } + } + } + + // Check if required keys are present + if (configObj.licenseKey && configObj.apiUrl) { + return { + licenseKey: configObj.licenseKey, + apiUrl: configObj.apiUrl, + }; + } + } + } catch (parseError) { + console.error(`Error parsing MDM configuration: ${parseError}`); + } + } + } + + return undefined; + } catch (error) { + console.error("Error reading macOS MDM keys:", error); + return undefined; + } +} + +function readMdmKeysWindows(): MdmKeys | undefined { + // Windows typically uses registry or special folders for MDM configurations + throw new Error("MDM keys for Windows not implemented yet"); +} + +function readMdmKeysLinux(): MdmKeys | undefined { + // Linux might use specific directories in /etc or other paths + throw new Error("MDM keys for Linux not implemented yet"); +} + +function readMdmKeys(): MdmKeys | undefined { + const platform = os.platform(); + + switch (platform) { + case "darwin": + return readMdmKeysMacOS(); + + case "win32": + return readMdmKeysWindows(); + + case "linux": + return readMdmKeysLinux(); + + default: + console.error(`MDM keys not supported on platform: ${platform}`); + return undefined; + } +} + +/** + * Read and validate MDM keys from the operating system's configuration files or registry. + */ +export function getMdmKeys(): MdmKeys | undefined { + try { + const mdmKeys = readMdmKeys(); + + if (mdmKeys) { + if (!validateLicenseKey(mdmKeys.licenseKey)) { + console.error("Invalid license key found: ", mdmKeys.licenseKey); + return undefined; + } + + return mdmKeys; + } + + return undefined; + } catch (e) { + console.warn("Error reading MDM keys: ", e); + return undefined; + } +} diff --git a/core/package-lock.json b/core/package-lock.json index ea049ae74..8592b627c 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -55,6 +55,7 @@ "p-limit": "^6.1.0", "partial-json": "^0.1.7", "pg": "^8.11.3", + "plist": "^3.1.0", "posthog-node": "^3.6.3", "puppeteer": "^22.4.0", "puppeteer-chromium-resolver": "^23.0.0", @@ -91,6 +92,7 @@ "@types/mustache": "^4.2.5", "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", + "@types/plist": "^3.0.5", "@types/request": "^2.48.12", "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", @@ -4938,6 +4940,16 @@ "pg-types": "^4.0.1" } }, + "node_modules/@types/plist": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@types/plist/-/plist-3.0.5.tgz", + "integrity": "sha512-E6OCaRmAe4WDmWNsL/9RMqdkkzDCY1etutkflWk4c+AcjDU07Pcz1fQwTX0TQz+Pxqn9i4L1TU3UFpjnrcDgxA==", + "dev": true, + "dependencies": { + "@types/node": "*", + "xmlbuilder": ">=11.0.1" + } + }, "node_modules/@types/readable-stream": { "version": "4.0.18", "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.18.tgz", @@ -5258,6 +5270,14 @@ "onnxruntime-node": "1.14.0" } }, + "node_modules/@xmldom/xmldom": { + "version": "0.8.10", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.10.tgz", + "integrity": "sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/@yomguithereal/helpers": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@yomguithereal/helpers/-/helpers-1.1.1.tgz", @@ -12924,6 +12944,19 @@ "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz", "integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==" }, + "node_modules/plist": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/plist/-/plist-3.1.0.tgz", + "integrity": "sha512-uysumyrvkUX0rX/dEVqt8gC3sTBzd4zoWfLeS29nb53imdaXVvLINYXTI2GNqzaMuvacNx4uJQ8+b3zXR0pkgQ==", + "dependencies": { + "@xmldom/xmldom": "^0.8.8", + "base64-js": "^1.5.1", + "xmlbuilder": "^15.1.1" + }, + "engines": { + "node": ">=10.4.0" + } + }, "node_modules/possible-typed-array-names": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", @@ -15922,6 +15955,14 @@ "node": ">=18" } }, + "node_modules/xmlbuilder": { + "version": "15.1.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz", + "integrity": "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==", + "engines": { + "node": ">=8.0" + } + }, "node_modules/xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", diff --git a/core/package.json b/core/package.json index 9332baa21..10f0ec35e 100644 --- a/core/package.json +++ b/core/package.json @@ -27,6 +27,7 @@ "@types/mustache": "^4.2.5", "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", + "@types/plist": "^3.0.5", "@types/request": "^2.48.12", "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", @@ -89,6 +90,7 @@ "p-limit": "^6.1.0", "partial-json": "^0.1.7", "pg": "^8.11.3", + "plist": "^3.1.0", "posthog-node": "^3.6.3", "puppeteer": "^22.4.0", "puppeteer-chromium-resolver": "^23.0.0", From 74516ada530cc5c9a175d8ea4a7da8dbcf992e3b Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 18 May 2025 19:59:17 -0700 Subject: [PATCH 07/12] mdm parsing for linux --- core/control-plane/mdm.ts | 40 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/core/control-plane/mdm.ts b/core/control-plane/mdm.ts index 8e92b4d02..95879a3d4 100644 --- a/core/control-plane/mdm.ts +++ b/core/control-plane/mdm.ts @@ -119,8 +119,44 @@ function readMdmKeysWindows(): MdmKeys | undefined { } function readMdmKeysLinux(): MdmKeys | undefined { - // Linux might use specific directories in /etc or other paths - throw new Error("MDM keys for Linux not implemented yet"); + try { + // Common locations for MDM configurations in Linux systems + const mdmPaths = [ + // System-wide configuration + "/etc/continue/mdm.json", + "/var/lib/continue/mdm.json", + // User-specific configuration + path.join(os.homedir(), ".config/continue/mdm.json"), + ]; + + // Try to find a valid MDM configuration file + for (const mdmPath of mdmPaths) { + if (fs.existsSync(mdmPath)) { + // Read the file content + const fileContent = fs.readFileSync(mdmPath, "utf8"); + + try { + // Parse the JSON configuration file + const config = JSON.parse(fileContent); + + // Check if required keys are present + if (config.licenseKey && config.apiUrl) { + return { + licenseKey: config.licenseKey, + apiUrl: config.apiUrl, + }; + } + } catch (parseError) { + console.error(`Error parsing Linux MDM configuration: ${parseError}`); + } + } + } + + return undefined; + } catch (error) { + console.error("Error reading Linux MDM keys:", error); + return undefined; + } } function readMdmKeys(): MdmKeys | undefined { From 454efd6a840c72d207afac2a32b7889af94d3023 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 19 May 2025 16:57:24 -0700 Subject: [PATCH 08/12] refactor to solve nesting linting error --- core/control-plane/mdm.ts | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/core/control-plane/mdm.ts b/core/control-plane/mdm.ts index 95879a3d4..1f7d9ea33 100644 --- a/core/control-plane/mdm.ts +++ b/core/control-plane/mdm.ts @@ -52,6 +52,22 @@ export function validateLicenseKey(licenseKey: string): boolean { } } +function extractConfigFromArray(config: any[]): Record { + const configObj: Record = {}; + + for (let i = 0; i < config.length; i += 2) { + if (i + 1 < config.length) { + const key = config[i]; + const value = config[i + 1]; + if (typeof key === "string") { + configObj[key] = value as string; + } + } + } + + return configObj; +} + function readMdmKeysMacOS(): MdmKeys | undefined { try { // MDM configuration is typically stored in /Library/Managed Preferences/ on macOS @@ -79,18 +95,7 @@ function readMdmKeysMacOS(): MdmKeys | undefined { // Extract the relevant fields from the config // Config is an array of alternating keys and values if (Array.isArray(config)) { - const configObj: Record = {}; - - // Convert array format [key1, value1, key2, value2, ...] to object - for (let i = 0; i < config.length; i += 2) { - if (i + 1 < config.length) { - const key = config[i]; - const value = config[i + 1]; - if (typeof key === "string") { - configObj[key] = value as string; - } - } - } + const configObj = extractConfigFromArray(config); // Check if required keys are present if (configObj.licenseKey && configObj.apiUrl) { From e18f82dff61587c073f8c758098a2a00d6e6c0d2 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 19 May 2025 16:59:33 -0700 Subject: [PATCH 09/12] use execSync to check for Windows registry keys --- core/control-plane/mdm.ts | 61 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/core/control-plane/mdm.ts b/core/control-plane/mdm.ts index 1f7d9ea33..7e3664313 100644 --- a/core/control-plane/mdm.ts +++ b/core/control-plane/mdm.ts @@ -119,8 +119,65 @@ function readMdmKeysMacOS(): MdmKeys | undefined { } function readMdmKeysWindows(): MdmKeys | undefined { - // Windows typically uses registry or special folders for MDM configurations - throw new Error("MDM keys for Windows not implemented yet"); + try { + // For Windows, we need to read from the registry + // Using regedit or another synchronous registry access module + const { execSync } = require("child_process"); + + // Path to the registry where MDM configuration is stored + const regPath = "HKLM\\Software\\Continue\\MDM"; + const userRegPath = "HKCU\\Software\\Continue\\MDM"; + + // Try to read from HKEY_LOCAL_MACHINE first + try { + // Use REG QUERY command to read registry values + const licenseKeyCmd = `reg query "${regPath}" /v licenseKey`; + const apiUrlCmd = `reg query "${regPath}" /v apiUrl`; + + const licenseKeyOutput = execSync(licenseKeyCmd, { encoding: "utf8" }); + const apiUrlOutput = execSync(apiUrlCmd, { encoding: "utf8" }); + + // Extract values from command output + const licenseKey = extractRegValue(licenseKeyOutput); + const apiUrl = extractRegValue(apiUrlOutput); + + if (licenseKey && apiUrl) { + return { licenseKey, apiUrl }; + } + } catch (error) { + // Registry key might not exist, fallback to HKEY_CURRENT_USER + } + + // Try HKEY_CURRENT_USER if not found in HKEY_LOCAL_MACHINE + try { + const licenseKeyCmd = `reg query "${userRegPath}" /v licenseKey`; + const apiUrlCmd = `reg query "${userRegPath}" /v apiUrl`; + + const licenseKeyOutput = execSync(licenseKeyCmd, { encoding: "utf8" }); + const apiUrlOutput = execSync(apiUrlCmd, { encoding: "utf8" }); + + // Extract values from command output + const licenseKey = extractRegValue(licenseKeyOutput); + const apiUrl = extractRegValue(apiUrlOutput); + + if (licenseKey && apiUrl) { + return { licenseKey, apiUrl }; + } + } catch (error) { + // Registry key might not exist in HKCU either + } + + return undefined; + } catch (error) { + console.error("Error reading Windows MDM keys:", error); + return undefined; + } +} + +// Helper function to extract registry values from reg query output +function extractRegValue(output: string): string | undefined { + const match = output.match(/REG_SZ\s+(.+)$/m); + return match ? match[1].trim() : undefined; } function readMdmKeysLinux(): MdmKeys | undefined { From 73cc373e891f6b5bbe87c6ce24e42db617c577a0 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 19 May 2025 18:15:27 -0700 Subject: [PATCH 10/12] make constants --- core/control-plane/mdm.ts | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/core/control-plane/mdm.ts b/core/control-plane/mdm.ts index 95879a3d4..d95930103 100644 --- a/core/control-plane/mdm.ts +++ b/core/control-plane/mdm.ts @@ -52,22 +52,19 @@ export function validateLicenseKey(licenseKey: string): boolean { } } +const MACOS_MDM_PATHS = [ + // Organization-specific MDM plist + "/Library/Managed Preferences/dev.continue.app.plist", + // User-specific MDM plist + path.join(os.homedir(), "Library/Managed Preferences/dev.continue.app.plist"), +]; function readMdmKeysMacOS(): MdmKeys | undefined { try { // MDM configuration is typically stored in /Library/Managed Preferences/ on macOS // The filename is often the bundle identifier of the application - const mdmPaths = [ - // Organization-specific MDM plist - "/Library/Managed Preferences/dev.continue.app.plist", - // User-specific MDM plist - path.join( - os.homedir(), - "Library/Managed Preferences/dev.continue.app.plist", - ), - ]; // Try to find a valid MDM configuration file - for (const mdmPath of mdmPaths) { + for (const mdmPath of MACOS_MDM_PATHS) { if (fs.existsSync(mdmPath)) { // Read the file content const fileContent = fs.readFileSync(mdmPath, "utf8"); @@ -118,19 +115,19 @@ function readMdmKeysWindows(): MdmKeys | undefined { throw new Error("MDM keys for Windows not implemented yet"); } +// Common locations for MDM configurations in Linux systems +const LINUX_MDM_PATHS = [ + // System-wide configuration + "/etc/continue/mdm.json", + "/var/lib/continue/mdm.json", + // User-specific configuration + path.join(os.homedir(), ".config/continue/mdm.json"), +]; + function readMdmKeysLinux(): MdmKeys | undefined { try { - // Common locations for MDM configurations in Linux systems - const mdmPaths = [ - // System-wide configuration - "/etc/continue/mdm.json", - "/var/lib/continue/mdm.json", - // User-specific configuration - path.join(os.homedir(), ".config/continue/mdm.json"), - ]; - // Try to find a valid MDM configuration file - for (const mdmPath of mdmPaths) { + for (const mdmPath of LINUX_MDM_PATHS) { if (fs.existsSync(mdmPath)) { // Read the file content const fileContent = fs.readFileSync(mdmPath, "utf8"); From 68a252edfd49629977ce490a1ba7f9dfaca042af Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 19 May 2025 19:12:27 -0700 Subject: [PATCH 11/12] bump --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 3ac9d33c5..671502b88 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.35", + "version": "1.1.36", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 6eb8f2fb0a3b76ede303656a5e45bf0f74a0dcae Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 20 May 2025 11:00:53 -0700 Subject: [PATCH 12/12] await isSignedIn() --- core/config/yaml/loadYaml.ts | 7 +++---- core/control-plane/client.ts | 8 ++++---- extensions/vscode/package-lock.json | 6 ++++-- extensions/vscode/package.json | 2 +- gui/package-lock.json | 2 ++ 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index e667415d2..8c926faab 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -41,7 +41,6 @@ import { GlobalContext } from "../../util/GlobalContext"; import { modifyAnyConfigWithSharedConfig } from "../sharedConfig"; import { getControlPlaneEnvSync } from "../../control-plane/env"; -import { logger } from "../../util/logger"; import { getCleanUriPath } from "../../util/uri"; import { getAllDotContinueYamlFiles } from "../loadLocalAssistants"; import { LocalPlatformClient } from "./LocalPlatformClient"; @@ -115,9 +114,9 @@ async function loadConfigYaml(options: { ? dirname(getCleanUriPath(packageIdentifier.filePath)) : undefined; - logger.info( - `Loading config.yaml from ${JSON.stringify(packageIdentifier)} with root path ${rootPath}`, - ); + // logger.info( + // `Loading config.yaml from ${JSON.stringify(packageIdentifier)} with root path ${rootPath}`, + // ); let config = overrideConfigYaml ?? diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 914ada0ba..e3513ac2d 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -38,7 +38,7 @@ export class ControlPlaneClient { fqsns: FQSN[], orgScopeId: string | null, ): Promise<(SecretResult | undefined)[]> { - if (!this.isSignedIn()) { + if (!(await this.isSignedIn())) { return fqsns.map((fqsn) => ({ found: false, fqsn, @@ -105,7 +105,7 @@ export class ControlPlaneClient { rawYaml: string; }[] > { - if (!this.isSignedIn()) { + if (!(await this.isSignedIn())) { return []; } @@ -124,7 +124,7 @@ export class ControlPlaneClient { } public async listOrganizations(): Promise> { - if (!this.isSignedIn()) { + if (!(await this.isSignedIn())) { return []; } @@ -142,7 +142,7 @@ export class ControlPlaneClient { public async listAssistantFullSlugs( organizationId: string | null, ): Promise { - if (!this.isSignedIn()) { + if (!(await this.isSignedIn())) { return null; } diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 09ee927d9..bdd37caf7 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.35", + "version": "1.1.36", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.35", + "version": "1.1.36", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", @@ -148,6 +148,7 @@ "p-limit": "^6.1.0", "partial-json": "^0.1.7", "pg": "^8.11.3", + "plist": "^3.1.0", "posthog-node": "^3.6.3", "puppeteer": "^22.4.0", "puppeteer-chromium-resolver": "^23.0.0", @@ -184,6 +185,7 @@ "@types/mustache": "^4.2.5", "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", + "@types/plist": "^3.0.5", "@types/request": "^2.48.12", "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 671502b88..3772dd79d 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.36", + "version": "1.1.37", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/gui/package-lock.json b/gui/package-lock.json index 579d35a6a..8c95b8f38 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -152,6 +152,7 @@ "p-limit": "^6.1.0", "partial-json": "^0.1.7", "pg": "^8.11.3", + "plist": "^3.1.0", "posthog-node": "^3.6.3", "puppeteer": "^22.4.0", "puppeteer-chromium-resolver": "^23.0.0", @@ -188,6 +189,7 @@ "@types/mustache": "^4.2.5", "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", + "@types/plist": "^3.0.5", "@types/request": "^2.48.12", "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7",