UNPKG

chrome-cookie-extractor

Version:

Extract and decrypt Chrome cookies with curl integration - includes auth-curl command for authenticated requests

109 lines 4.26 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProfileDetector = void 0; const os = __importStar(require("os")); const path = __importStar(require("path")); const fs = __importStar(require("fs")); const types_1 = require("./types"); class ProfileDetector { static detectChromeProfiles() { const platform = os.platform(); const homeDir = os.homedir(); let chromeBasePath; switch (platform) { case types_1.Platform.DARWIN: chromeBasePath = path.join(homeDir, 'Library/Application Support/Google/Chrome'); break; case types_1.Platform.WIN32: chromeBasePath = path.join(homeDir, 'AppData/Local/Google/Chrome/User Data'); break; case types_1.Platform.LINUX: chromeBasePath = path.join(homeDir, '.config/google-chrome'); break; default: throw new Error(`Unsupported platform: ${platform}`); } if (!fs.existsSync(chromeBasePath)) { return []; } const profiles = []; for (const profileName of this.PROFILE_NAMES) { const profilePath = path.join(chromeBasePath, profileName); const cookiesPath = path.join(profilePath, 'Cookies'); if (fs.existsSync(cookiesPath)) { profiles.push({ name: profileName, path: profilePath, cookiesPath }); } } return profiles; } static detectBraveProfiles() { const platform = os.platform(); const homeDir = os.homedir(); let braveBasePath; switch (platform) { case types_1.Platform.DARWIN: braveBasePath = path.join(homeDir, 'Library/Application Support/BraveSoftware/Brave-Browser'); break; case types_1.Platform.WIN32: braveBasePath = path.join(homeDir, 'AppData/Local/BraveSoftware/Brave-Browser/User Data'); break; case types_1.Platform.LINUX: braveBasePath = path.join(homeDir, '.config/BraveSoftware/Brave-Browser'); break; default: return []; } if (!fs.existsSync(braveBasePath)) { return []; } const profiles = []; for (const profileName of this.PROFILE_NAMES) { const profilePath = path.join(braveBasePath, profileName); const cookiesPath = path.join(profilePath, 'Cookies'); if (fs.existsSync(cookiesPath)) { profiles.push({ name: `Brave-${profileName}`, path: profilePath, cookiesPath }); } } return profiles; } static detectAllProfiles() { return [ ...this.detectChromeProfiles(), ...this.detectBraveProfiles() ]; } } exports.ProfileDetector = ProfileDetector; ProfileDetector.PROFILE_NAMES = ['Default', 'Profile 1', 'Profile 2', 'Profile 3', 'Profile 4']; //# sourceMappingURL=profile-detector.js.map