From 73cc373e891f6b5bbe87c6ce24e42db617c577a0 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 19 May 2025 18:15:27 -0700 Subject: [PATCH] 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");