@mherod/get-cookie 4.0.3 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/commit-msg +0 -0
- package/.husky/pre-commit +0 -0
- package/.husky/pre-push +0 -0
- package/.idea/prettier.xml +2 -1
- package/dist/chunk-3FVH4L25.js +2 -0
- package/dist/chunk-3FVH4L25.js.map +1 -0
- package/dist/chunk-7XZ7PCDJ.js +2 -0
- package/dist/chunk-7XZ7PCDJ.js.map +1 -0
- package/dist/chunk-DVWQBWUF.js +4 -0
- package/dist/chunk-DVWQBWUF.js.map +1 -0
- package/dist/{chunk-VMBA4NVU.js → chunk-I6AYGFSQ.js} +2 -2
- package/dist/chunk-U27I5BLR.js +2 -0
- package/dist/chunk-U27I5BLR.js.map +1 -0
- package/dist/chunk-YOZOS2YM.js +2 -0
- package/dist/chunk-YOZOS2YM.js.map +1 -0
- package/dist/cli.cjs +3 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/getChromeCookie-2ROVM47V.js +2 -0
- package/dist/getChromeCookie-2ROVM47V.js.map +1 -0
- package/dist/{getChromePassword-GTIXL733.js → getChromePassword-O452VQWI.js} +2 -2
- package/dist/getCookie-CRE6M3GI.js +2 -0
- package/dist/getFirefoxCookie-5P74VDC7.js +2 -0
- package/dist/getFirefoxCookie-5P74VDC7.js.map +1 -0
- package/dist/getGroupedRenderedCookies-DFEJTTC6.js +2 -0
- package/dist/getGroupedRenderedCookies-DFEJTTC6.js.map +1 -0
- package/dist/getMergedRenderedCookies-W5GSSHQQ.js +2 -0
- package/dist/getMergedRenderedCookies-W5GSSHQQ.js.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +164 -152
- package/dist/index.d.ts +164 -152
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/eslint.config.js +2 -1
- package/package.json +23 -22
- package/typedoc.json +3 -8
- package/dist/chunk-5FUMK7M3.js +0 -4
- package/dist/chunk-5FUMK7M3.js.map +0 -1
- package/dist/chunk-5ZT2G45S.js +0 -2
- package/dist/chunk-5ZT2G45S.js.map +0 -1
- package/dist/chunk-FR2MKDHT.js +0 -2
- package/dist/chunk-FR2MKDHT.js.map +0 -1
- package/dist/chunk-HMKSQBDC.js +0 -2
- package/dist/chunk-HMKSQBDC.js.map +0 -1
- package/dist/chunk-W3JALMAX.js +0 -2
- package/dist/chunk-W3JALMAX.js.map +0 -1
- package/dist/getChromeCookie-4ZWACG6M.js +0 -2
- package/dist/getChromeCookie-4ZWACG6M.js.map +0 -1
- package/dist/getCookie-43FKMQEZ.js +0 -2
- package/dist/getFirefoxCookie-OJYYZFZP.js +0 -2
- package/dist/getFirefoxCookie-OJYYZFZP.js.map +0 -1
- package/dist/getGroupedRenderedCookies-P5VZXZUC.js +0 -2
- package/dist/getGroupedRenderedCookies-P5VZXZUC.js.map +0 -1
- package/dist/getMergedRenderedCookies-C6TXK2I4.js +0 -2
- package/dist/getMergedRenderedCookies-C6TXK2I4.js.map +0 -1
- package/tsup.config.ts +0 -27
- /package/dist/{chunk-VMBA4NVU.js.map → chunk-I6AYGFSQ.js.map} +0 -0
- /package/dist/{getChromePassword-GTIXL733.js.map → getChromePassword-O452VQWI.js.map} +0 -0
- /package/dist/{getCookie-43FKMQEZ.js.map → getCookie-CRE6M3GI.js.map} +0 -0
package/dist/chunk-5ZT2G45S.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as C,b as w}from"./chunk-5FUMK7M3.js";import{a as d,b as p,c,d as l,e as y}from"./chunk-56Z35D5R.js";async function k(r,e,o=[]){return r.length===0?o:(await Promise.all(r.map(async i=>{try{return await e(i)}catch(n){return o}}))).flat()}import{existsSync as T}from"fs";import{join as h}from"path";import L from"fast-glob";import{join as q}from"path";import{merge as D}from"lodash-es";var E={};D(E,process.env);var u=E.HOME;if(typeof u!="string"||u.length===0)throw new Error("HOME environment variable is not set or empty");var x,m=q((x=u)!=null?x:"","Library","Application Support","Google","Chrome");function M(r){if(typeof r!="string")return!1;let e=r.trim();return e.length===0?!1:T(e)}async function Q(){let r=[h(m,"Default/Cookies"),h(m,"Profile */Cookies"),h(m,"Profile Default/Cookies")],e=[];for(let o of r){let t=await L(o);e.push(...t)}return l("ChromeCookies","Found cookie files",{count:e.length,files:e}),e}function A(r,e){let o=r==="%",t=o?"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE host_key LIKE ?":"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE name = ? AND host_key LIKE ?",i=o?[`%${e}%`]:[r,`%${e}%`];return{sql:t,params:i}}async function I(r,e,o){try{let{sql:t,params:i}=A(e,o);l("ChromeCookies","Executing query",{sql:t,params:i});let n=await C({file:r,sql:t,params:i,rowTransform:s=>({name:s.name,domain:s.host_key,value:s.encrypted_value,expiry:s.expires_utc})});return p("QueryCookies",!0,{file:r,count:n.length}),n}catch(t){return c("Failed to read cookie file",t,{file:r}),[]}}async function P({name:r,domain:e,file:o}){let t=typeof o=="string"&&o.length>0?[o]:await Q();if(t.length===0)return l("ChromeCookies","No cookie files found"),[];let i=[];for(let n of t){if(!M(n)){l("ChromeCookies","Cookie file missing or invalid",{file:n});continue}let s=await I(n,r,e);i.push(...s)}return l("ChromeCookies","Query complete",{totalCookies:i.length}),i}import{readFileSync as lr}from"fs";import{join as fr}from"path";var N=d.withTag("listChromeProfiles");function _(){let r=w("./**/Cookies",{cwd:m,absolute:!0});return N.debug("Found cookie files:",r),r}import{createDecipheriv as H,pbkdf2 as $}from"crypto";import{memoize as S}from"lodash-es";var U=S(r=>r.length>=3&&r[0]===118&&r[1]===49&&r[2]===48?r.slice(3):r,r=>r.toString("hex")),z=S(r=>{let e=r[r.length-1];return e&&e<=16?r.slice(0,-e):r},r=>r.toString("hex"));function G(r){var o;let e=[/.*?0t(.+)$/,/.*?1e`(.+)$/,/.*?[`'](.+)$/,/[^\x20-\x7E]*([\x20-\x7E].+)$/];for(let t of e){let i=r.match(t),n=(o=i==null?void 0:i[1])!=null?o:"";if(n.length>0)return n}return r}async function v(r,e){if(typeof e!="string")throw new Error("password must be a string");if(!Buffer.isBuffer(r))throw new Error("encryptedData must be a Buffer");return new Promise((o,t)=>{$(e,"saltysalt",1003,16,"sha1",(i,n)=>{try{if(i){t(new Error("Failed to derive key: "+i.message));return}let s=U(r);if(s.length%16!==0){t(new Error("Encrypted data length is not a multiple of 16"));return}let f=Buffer.alloc(16," "),a=H("aes-128-cbc",n,f);a.setAutoPadding(!1);let g=a.update(s);try{a.final()}catch(O){t(new Error("Failed to finalize decryption: "+O.message));return}g=z(g);let B=g.toString("utf8");o(G(B))}catch(s){t(new Error("Decryption failed: "+s.message))}})})}import{memoize as W}from"lodash-es";var b=W(async()=>{if(process.platform!=="darwin")throw c("Chrome password retrieval failed",new Error("This only works on macOS"),{platform:process.platform}),new Error("This only works on macOS");try{let{getChromePassword:r}=await import("./getChromePassword-GTIXL733.js"),e=await r();return l("ChromePassword","Retrieved password successfully",{platform:"macOS"}),e}catch(r){throw c("Chrome password retrieval failed",r,{platform:"macOS"}),r}});function K(r){return typeof r!="number"||r<=0?"Infinity":new Date(r)}function R(r,e,o,t,i,n){return{domain:r,name:e,value:o,expiry:K(t),meta:{file:i,browser:"Chrome",decrypted:n}}}var F=class{constructor(){this.logger=y("ChromeCookieQueryStrategy");this.browserName="Chrome"}async queryCookies(e,o){try{if(this.logger.info("Querying cookies",{name:e,domain:o}),process.platform!=="darwin")return this.logger.warn("Platform not supported",{platform:process.platform}),[];let i=_().map(f=>f),n=await b(),s=await k(i,f=>this.processFile(f,e,o,n),[]);return p("Cookie query",!0,{count:s.length}),s}catch(t){return c("Failed to query cookies",t,{name:e,domain:o}),[]}}async processFile(e,o,t,i){try{let n=await P({name:o,domain:t,file:e}),s={file:e,password:i};return(await Promise.allSettled(n.map(a=>this.processCookie(a,s)))).map(a=>a.status==="fulfilled"?a.value:null).filter(a=>a!==null)}catch(n){return this.logger.error("Failed to process cookie file",{error:n,file:e}),[]}}async processCookie(e,o){try{let t=Buffer.isBuffer(e.value)?e.value:Buffer.from(String(e.value)),i=await v(t,o.password);return R(e.domain,e.name,i,e.expiry,o.file,!0)}catch(t){return this.logger.warn("Failed to decrypt cookie",{error:t}),R(e.domain,e.name,e.value.toString("utf-8"),e.expiry,o.file,!1)}}};export{F as a};
|
|
2
|
-
//# sourceMappingURL=chunk-5ZT2G45S.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/flatMapAsync.ts","../src/core/browsers/getEncryptedChromeCookie.ts","../src/core/browsers/chrome/ChromeApplicationSupport.ts","../src/global.ts","../src/core/browsers/listChromeProfiles.ts","../src/core/browsers/chrome/decrypt.ts","../src/core/browsers/chrome/getChromePassword.ts","../src/core/browsers/chrome/ChromeCookieQueryStrategy.ts"],"sourcesContent":["/**\n * Asynchronously maps over an array and flattens the result.\n * Similar to Array.prototype.flatMap but for async operations.\n * @param array - The input array to map over\n * @param callback - The async mapping function to apply to each element\n * @param defaultValue - The default value to return if the array is empty\n * @returns A flattened array of results\n * @example\n * // Basic usage with number arrays\n * const numbers = [1, 2, 3];\n * const result = await flatMapAsync(\n * numbers,\n * async (num) => [num, num * 2]\n * );\n * console.log(result); // [1, 2, 2, 4, 3, 6]\n * @example\n * // Error handling with default value\n * const data = ['valid', 'invalid'];\n * const result = await flatMapAsync(\n * data,\n * async (item) => {\n * if (item === 'invalid') throw new Error();\n * return [item.toUpperCase()];\n * },\n * ['DEFAULT']\n * );\n * console.log(result); // ['VALID', 'DEFAULT']\n */\nexport async function flatMapAsync<T, U>(\n array: T[],\n callback: (item: T) => Promise<U[]>,\n defaultValue: U[] = [],\n): Promise<U[]> {\n if (array.length === 0) {\n return defaultValue;\n }\n\n const results = await Promise.all(\n array.map(async (item) => {\n try {\n return await callback(item);\n } catch (_error) {\n return defaultValue;\n }\n }),\n );\n return results.flat();\n}\n","import { existsSync } from \"fs\";\nimport { join } from \"path\";\n\nimport glob from \"fast-glob\";\n\nimport { logError, logDebug, logOperationResult } from \"@utils/logHelpers\";\n\nimport type { CookieRow } from \"../../types/CookieRow\";\n\nimport { chromeApplicationSupport } from \"./chrome/ChromeApplicationSupport\";\nimport { querySqliteThenTransform } from \"./QuerySqliteThenTransform\";\n\ninterface ChromeCookieRow {\n encrypted_value: Buffer;\n name: string;\n host_key: string;\n expires_utc: number;\n}\n\ninterface GetEncryptedCookieOptions {\n name: string;\n domain: string;\n file?: string;\n}\n\ninterface SqlQuery {\n sql: string;\n params: string[];\n}\n\n/**\n * Validates if a path is a valid, existing file\n * @param path - Path to validate\n * @returns true if path is valid and file exists, false otherwise\n */\nfunction isValidFilePath(path: unknown): path is string {\n if (typeof path !== \"string\") {\n return false;\n }\n\n const trimmedPath = path.trim();\n if (trimmedPath.length === 0) {\n return false;\n }\n\n return existsSync(trimmedPath);\n}\n\n/**\n * Get paths to Chrome cookie files\n * @returns A promise that resolves to an array of file paths\n */\nasync function getCookieFiles(): Promise<string[]> {\n const patterns = [\n join(chromeApplicationSupport, \"Default/Cookies\"),\n join(chromeApplicationSupport, \"Profile */Cookies\"),\n join(chromeApplicationSupport, \"Profile Default/Cookies\"),\n ];\n\n const files: string[] = [];\n for (const pattern of patterns) {\n const matches = await glob(pattern);\n files.push(...matches);\n }\n\n logDebug(\"ChromeCookies\", \"Found cookie files\", {\n count: files.length,\n files,\n });\n return files;\n}\n\n/**\n * Builds the SQL query for retrieving cookies\n * @param name - Cookie name to search for\n * @param domain - Domain to filter by\n * @returns SQL query and parameters\n */\nfunction buildSqlQuery(name: string, domain: string): SqlQuery {\n const isWildcard = name === \"%\";\n const sql = isWildcard\n ? `SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE host_key LIKE ?`\n : `SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE name = ? AND host_key LIKE ?`;\n const params = isWildcard ? [`%${domain}%`] : [name, `%${domain}%`];\n\n return { sql, params };\n}\n\n/**\n * Processes a single cookie file to extract matching cookies\n * @param cookieFile - Path to the cookie file\n * @param name - Cookie name to search for\n * @param domain - Domain to filter by\n * @returns Array of matching cookies\n */\nasync function processCookieFile(\n cookieFile: string,\n name: string,\n domain: string,\n): Promise<CookieRow[]> {\n try {\n const { sql, params } = buildSqlQuery(name, domain);\n logDebug(\"ChromeCookies\", \"Executing query\", { sql, params });\n\n const rows = await querySqliteThenTransform<ChromeCookieRow, CookieRow>({\n file: cookieFile,\n sql,\n params,\n rowTransform: (row: ChromeCookieRow): CookieRow => ({\n name: row.name,\n domain: row.host_key,\n value: row.encrypted_value,\n expiry: row.expires_utc,\n }),\n });\n\n logOperationResult(\"QueryCookies\", true, {\n file: cookieFile,\n count: rows.length,\n });\n return rows;\n } catch (error) {\n logError(\"Failed to read cookie file\", error, { file: cookieFile });\n return [];\n }\n}\n\n/**\n * Retrieve encrypted cookies from Chrome's cookie store\n * @param options - Options for querying Chrome cookies\n * @param options.name - The name of the cookie to retrieve\n * @param options.domain - The domain to retrieve cookies from\n * @param options.file - Optional specific cookie file to query\n * @returns Promise resolving to array of encrypted cookies\n */\nexport async function getEncryptedChromeCookie({\n name,\n domain,\n file,\n}: GetEncryptedCookieOptions): Promise<CookieRow[]> {\n const cookieFiles =\n typeof file === \"string\" && file.length > 0\n ? [file]\n : await getCookieFiles();\n\n if (cookieFiles.length === 0) {\n logDebug(\"ChromeCookies\", \"No cookie files found\");\n return [];\n }\n\n const results: CookieRow[] = [];\n for (const cookieFile of cookieFiles) {\n if (!isValidFilePath(cookieFile)) {\n logDebug(\"ChromeCookies\", \"Cookie file missing or invalid\", {\n file: cookieFile,\n });\n continue;\n }\n\n const cookies = await processCookieFile(cookieFile, name, domain);\n results.push(...cookies);\n }\n\n logDebug(\"ChromeCookies\", \"Query complete\", { totalCookies: results.length });\n return results;\n}\n","import { join } from \"path\";\n\nimport { HOME } from \"../../../global\";\n\n/**\n * The path to Chrome's application support directory on macOS\n * This constant is used to locate Chrome's profile and cookie storage directories\n * @example\n */\nexport const chromeApplicationSupport = join(\n HOME ?? \"\",\n \"Library\",\n \"Application Support\",\n \"Google\",\n \"Chrome\",\n);\n","import { merge } from \"lodash-es\";\n\n/**\n * Global environment variables object that merges with process.env\n * @example\n * // Access environment variables\n * const nodeEnv = env.NODE_ENV; // 'development'\n * const apiKey = env.API_KEY; // 'abc123'\n *\n * // Check if variable exists\n * if (env.DATABASE_URL) {\n * // Use database URL\n * }\n *\n * // Add new environment variables\n * env.CUSTOM_VAR = 'my-value';\n */\nexport const env: { [key: string]: string | undefined } = {};\nmerge(env, process.env);\n\n/**\n * User's home directory path from environment variables\n * @throws Error if HOME environment variable is not set\n * @example\n * // Access home directory path\n * const homePath = HOME; // '/home/username' or 'C:\\Users\\username'\n *\n * // Use in file path construction\n * const configPath = `${homePath}/.config/app`;\n *\n * // Error handling\n * if (typeof homePath === 'string' && homePath.length > 0) {\n * // Use home path\n * } else {\n * throw new Error('HOME environment variable is not set or empty');\n * }\n */\nexport const HOME: string | undefined = env[\"HOME\"];\nif (typeof HOME !== \"string\" || HOME.length === 0) {\n throw new Error(\"HOME environment variable is not set or empty\");\n}\n","// External imports\nimport { readFileSync } from \"fs\";\nimport { join } from \"path\";\n\nimport { sync } from \"glob\";\n\n// Internal imports\nimport logger from \"@utils/logger\";\n\nimport { chromeApplicationSupport } from \"./chrome/ChromeApplicationSupport\";\n\nconst consola = logger.withTag(\"listChromeProfiles\");\n\n/**\n * Lists all Chrome profile paths that contain cookie files\n * @internal\n * @returns An array of absolute paths to Chrome cookie files\n * @throws {Error} If Chrome's application support directory cannot be accessed\n * @example\n * ```typescript\n * // Get all Chrome cookie file paths\n * const cookiePaths = listChromeProfilePaths();\n * // Returns: [\n * // '/Users/name/Library/Application Support/Chrome/Profile 1/Cookies',\n * // '/Users/name/Library/Application Support/Chrome/Profile 2/Cookies'\n * // ]\n *\n * // Handle errors\n * try {\n * const paths = listChromeProfilePaths();\n * } catch (error) {\n * console.error('Failed to access Chrome profiles:', error);\n * }\n * ```\n */\nexport function listChromeProfilePaths(): string[] {\n const files: string[] = sync(`./**/Cookies`, {\n cwd: chromeApplicationSupport,\n absolute: true,\n });\n\n consola.debug(\"Found cookie files:\", files);\n return files;\n}\n\n/**\n * Chrome Local State file structure\n * @internal\n */\ninterface ChromeLocalState {\n profile: {\n info_cache: Record<string, ChromeProfileInfo>;\n };\n}\n\n/**\n * Chrome profile information structure\n * @property {string} name - The name of the profile\n * @property {number} active_time - Unix timestamp of last profile activity\n * @property {string} account_id - Unique identifier for the Chrome profile\n * @property {Record<string, unknown>} accountcapabilities - Account feature flags\n * @property {string} email - User's email address\n * @property {string} full_name - User's full name\n * @property {boolean} is_using_default_avatar - Whether using default profile picture\n * @property {boolean} is_using_default_name - Whether using default profile name\n * @property {string} last_downloaded_gaia_picture_url_with_size - Profile picture URL\n * @property {string} local_auth_credentials - Authentication credentials\n * @property {string} shortcut_name - Profile shortcut name\n * @property {string} user_name - Username associated with profile\n */\ninterface ChromeProfileInfo {\n /** The name of the profile */\n name: string;\n /** Unix timestamp of last profile activity */\n active_time: number;\n /** Unique identifier for the Chrome profile */\n account_id: string;\n /** Account feature flags */\n accountcapabilities: Record<string, unknown>;\n /** User's email address */\n email: string;\n /** User's full name */\n full_name: string;\n /** Whether using default profile picture */\n is_using_default_avatar: boolean;\n /** Whether using default profile name */\n is_using_default_name: boolean;\n /** Profile picture URL */\n last_downloaded_gaia_picture_url_with_size: string;\n /** Authentication credentials */\n local_auth_credentials: string;\n /** Profile shortcut name */\n shortcut_name: string;\n /** Username associated with profile */\n user_name: string;\n}\n\n/**\n * Lists all Chrome profiles and their associated information\n * @internal\n * @returns An array of Chrome profile information objects. Returns empty array if profiles cannot be read\n * @throws {Error} If Chrome's application support directory cannot be accessed\n * @example\n * ```typescript\n * // Get all Chrome profiles\n * const profiles = listChromeProfiles();\n * // Returns: [\n * // {\n * // name: \"Default\",\n * // email: \"user@example.com\",\n * // full_name: \"John Doe\",\n * // ...\n * // },\n * // ...\n * // ]\n *\n * // Handle empty or error case\n * const profiles = listChromeProfiles();\n * if (profiles.length === 0) {\n * console.log('No Chrome profiles found or error occurred');\n * }\n * ```\n */\nexport function listChromeProfiles(): ChromeProfileInfo[] {\n try {\n const localStatePath = join(chromeApplicationSupport, \"Local State\");\n const localState = JSON.parse(\n readFileSync(localStatePath, \"utf8\"),\n ) as ChromeLocalState;\n return Object.values(localState.profile.info_cache);\n } catch (error) {\n if (error instanceof Error) {\n consola.error(\"Failed to read Chrome profiles:\", error.message);\n } else {\n consola.error(\"Failed to read Chrome profiles: Unknown error\");\n }\n return [];\n }\n}\n","// External imports\nimport { createDecipheriv, pbkdf2 } from \"crypto\";\n\nimport { memoize } from \"lodash-es\";\n\n/**\n * Removes the v10 prefix from the encrypted value if present\n * @param value - The encrypted value\n * @returns The value without the v10 prefix\n */\nconst removeV10Prefix = memoize(\n (value: Buffer): Buffer => {\n if (\n value.length >= 3 &&\n value[0] === 0x76 && // 'v'\n value[1] === 0x31 && // '1'\n value[2] === 0x30\n ) {\n // '0'\n return value.slice(3);\n }\n return value;\n },\n (value: Buffer) => value.toString(\"hex\"),\n);\n\n/**\n * Removes PKCS7 padding from the decrypted value\n * @param decrypted - The decrypted buffer\n * @returns The buffer without padding\n */\nconst removePadding = memoize(\n (decrypted: Buffer): Buffer => {\n const padding = decrypted[decrypted.length - 1];\n if (padding && padding <= 16) {\n return decrypted.slice(0, -padding);\n }\n return decrypted;\n },\n (decrypted: Buffer) => decrypted.toString(\"hex\"),\n);\n\n/**\n * Extracts the actual value from the decoded string by removing Chrome's prefixes\n * @param decodedString - The decoded string to clean up\n * @returns The cleaned up value\n */\nfunction extractValue(decodedString: string): string {\n const cleanupPatterns = [\n /.*?0t(.+)$/, // Pattern ending in \"0t\" followed by value\n /.*?1e`(.+)$/, // Pattern ending in \"1e`\" followed by value\n /.*?[`'](.+)$/, // Any backtick or quote followed by value\n /[^\\x20-\\x7E]*([\\x20-\\x7E].+)$/, // Non-printable chars followed by printable chars\n ];\n\n for (const pattern of cleanupPatterns) {\n const match = decodedString.match(pattern);\n const value = match?.[1] ?? \"\";\n if (value.length > 0) {\n return value;\n }\n }\n return decodedString;\n}\n\n/**\n * Decrypts Chrome's encrypted cookie values\n * @param encryptedValue - The encrypted cookie value as a Buffer\n * @param password - The Chrome encryption password\n * @returns A promise that resolves to the decrypted cookie value\n * @throws {Error} If decryption fails\n * @example\n */\nexport async function decrypt(\n encryptedValue: Buffer,\n password: string,\n): Promise<string> {\n if (typeof password !== \"string\") {\n throw new Error(\"password must be a string\");\n }\n if (!Buffer.isBuffer(encryptedValue)) {\n throw new Error(\"encryptedData must be a Buffer\");\n }\n\n return new Promise((resolve, reject) => {\n pbkdf2(password, \"saltysalt\", 1003, 16, \"sha1\", (error, key) => {\n try {\n if (error) {\n reject(new Error(\"Failed to derive key: \" + error.message));\n return;\n }\n\n const value = removeV10Prefix(encryptedValue);\n if (value.length % 16 !== 0) {\n reject(new Error(\"Encrypted data length is not a multiple of 16\"));\n return;\n }\n\n // Chrome's encryption parameters\n const iv = Buffer.alloc(16, \" \"); // 16 spaces\n const decipher = createDecipheriv(\"aes-128-cbc\", key, iv);\n decipher.setAutoPadding(false);\n\n // Decrypt the value\n let decrypted = decipher.update(value);\n try {\n decipher.final();\n } catch (e) {\n reject(\n new Error(\"Failed to finalize decryption: \" + (e as Error).message),\n );\n return;\n }\n\n decrypted = removePadding(decrypted);\n const decodedString = decrypted.toString(\"utf8\");\n resolve(extractValue(decodedString));\n } catch (e) {\n reject(new Error(\"Decryption failed: \" + (e as Error).message));\n }\n });\n });\n}\n","import { memoize } from \"lodash-es\";\n\nimport { logError, logDebug } from \"@utils/logHelpers\";\n\n/**\n * Retrieves the Chrome password for decrypting cookies\n * This is only supported on macOS\n * @returns A promise that resolves to the Chrome password\n * @throws {Error} If the platform is not macOS or if password retrieval fails\n * @example\n */\nexport const getChromePassword: () => Promise<string> = memoize(async () => {\n if (process.platform !== \"darwin\") {\n logError(\n \"Chrome password retrieval failed\",\n new Error(\"This only works on macOS\"),\n {\n platform: process.platform,\n },\n );\n throw new Error(\"This only works on macOS\");\n }\n\n try {\n const { getChromePassword: getMacOSPassword } = await import(\n \"./macos/getChromePassword\"\n );\n const password = await getMacOSPassword();\n logDebug(\"ChromePassword\", \"Retrieved password successfully\", {\n platform: \"macOS\",\n });\n return password;\n } catch (error) {\n logError(\"Chrome password retrieval failed\", error, { platform: \"macOS\" });\n throw error;\n }\n});\n","import { flatMapAsync } from \"@utils/flatMapAsync\";\nimport {\n createTaggedLogger,\n logOperationResult,\n logError,\n} from \"@utils/logHelpers\";\n\nimport type { BrowserName } from \"../../../types/BrowserName\";\nimport type { CookieQueryStrategy } from \"../../../types/CookieQueryStrategy\";\nimport type { CookieRow } from \"../../../types/CookieRow\";\nimport type { ExportedCookie } from \"../../../types/ExportedCookie\";\nimport { getEncryptedChromeCookie } from \"../getEncryptedChromeCookie\";\nimport { listChromeProfilePaths } from \"../listChromeProfiles\";\n\nimport { decrypt } from \"./decrypt\";\nimport { getChromePassword } from \"./getChromePassword\";\n\ninterface DecryptionContext {\n file: string;\n password: string;\n}\n\nfunction getExpiryDate(expiry: number | undefined | null): Date | \"Infinity\" {\n if (typeof expiry !== \"number\" || expiry <= 0) {\n return \"Infinity\";\n }\n return new Date(expiry);\n}\n\nfunction createExportedCookie(\n domain: string,\n name: string,\n value: string,\n expiry: number | undefined | null,\n file: string,\n decrypted: boolean,\n): ExportedCookie {\n return {\n domain,\n name,\n value,\n expiry: getExpiryDate(expiry),\n meta: {\n file,\n browser: \"Chrome\",\n decrypted,\n },\n };\n}\n\n/**\n * Strategy for querying cookies from Chrome browser\n * @example\n */\nexport class ChromeCookieQueryStrategy implements CookieQueryStrategy {\n private readonly logger = createTaggedLogger(\"ChromeCookieQueryStrategy\");\n\n /**\n *\n */\n public readonly browserName: BrowserName = \"Chrome\";\n\n /**\n * Queries cookies from Chrome's cookie store\n * @param name - The name pattern to match cookies against\n * @param domain - The domain pattern to match cookies against\n * @returns A promise that resolves to an array of exported cookies\n */\n public async queryCookies(\n name: string,\n domain: string,\n ): Promise<ExportedCookie[]> {\n try {\n this.logger.info(\"Querying cookies\", { name, domain });\n\n if (process.platform !== \"darwin\") {\n this.logger.warn(\"Platform not supported\", {\n platform: process.platform,\n });\n return [];\n }\n\n const profilePaths = listChromeProfilePaths();\n const cookieFiles = profilePaths.map((path) => path);\n const password = await getChromePassword();\n\n const cookies = await flatMapAsync(\n cookieFiles,\n (file) => this.processFile(file, name, domain, password),\n [],\n );\n logOperationResult(\"Cookie query\", true, { count: cookies.length });\n return cookies;\n } catch (error) {\n logError(\"Failed to query cookies\", error, { name, domain });\n return [];\n }\n }\n\n private async processFile(\n file: string,\n name: string,\n domain: string,\n password: string,\n ): Promise<ExportedCookie[]> {\n try {\n const encryptedCookies = await getEncryptedChromeCookie({\n name,\n domain,\n file,\n });\n\n const context: DecryptionContext = { file, password };\n const results = await Promise.allSettled(\n encryptedCookies.map((cookie) => this.processCookie(cookie, context)),\n );\n\n return results\n .map((result) => (result.status === \"fulfilled\" ? result.value : null))\n .filter((cookie): cookie is ExportedCookie => cookie !== null);\n } catch (error) {\n this.logger.error(\"Failed to process cookie file\", { error, file });\n return [];\n }\n }\n\n private async processCookie(\n cookie: CookieRow,\n context: DecryptionContext,\n ): Promise<ExportedCookie> {\n try {\n const value = Buffer.isBuffer(cookie.value)\n ? cookie.value\n : Buffer.from(String(cookie.value));\n\n const decryptedValue = await decrypt(value, context.password);\n return createExportedCookie(\n cookie.domain,\n cookie.name,\n decryptedValue,\n cookie.expiry,\n context.file,\n true,\n );\n } catch (error) {\n this.logger.warn(\"Failed to decrypt cookie\", { error });\n return createExportedCookie(\n cookie.domain,\n cookie.name,\n cookie.value.toString(\"utf-8\"),\n cookie.expiry,\n context.file,\n false,\n );\n }\n }\n}\n"],"mappings":"8GA4BA,eAAsBA,EACpBC,EACAC,EACAC,EAAoB,CAAC,EACP,CACd,OAAIF,EAAM,SAAW,EACZE,GAGO,MAAM,QAAQ,IAC5BF,EAAM,IAAI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O,MAAM,gCAAiC,CAAE,MAAAA,EAAO,KAAAZ,CAAK,CAAC,EAC3D,CAAC,CACV,CACF,CAEA,MAAc,cACZiB,EACAD,EACyB,CACzB,GAAI,CACF,IAAMjB,EAAQ,OAAO,SAASkB,EAAO,KAAK,EACtCA,EAAO,MACP,OAAO,KAAK,OAAOA,EAAO,KAAK,CAAC,EAE9BE,EAAiB,MAAMC,EAAQrB,EAAOiB,EAAQ,QAAQ,EAC5D,OAAOpB,EACLqB,EAAO,OACPA,EAAO,KACPE,EACAF,EAAO,OACPD,EAAQ,KACR,EACF,CACF,OAASJ,EAAO,CACd,YAAK,OAAO,KAAK,2BAA4B,CAAE,MAAAA,CAAM,CAAC,EAC/ChB,EACLqB,EAAO,OACPA,EAAO,KACPA,EAAO,MAAM,SAAS,OAAO,EAC7BA,EAAO,OACPD,EAAQ,KACR,EACF,CACF,CACF,CACF","names":["flatMapAsync","array","callback","defaultValue","item","_error","existsSync","join","glob","join","merge","env","HOME","_a","chromeApplicationSupport","join","HOME","isValidFilePath","path","trimmedPath","existsSync","getCookieFiles","patterns","join","chromeApplicationSupport","files","pattern","matches","glob","logDebug","buildSqlQuery","name","domain","isWildcard","sql","params","processCookieFile","cookieFile","rows","querySqliteThenTransform","row","logOperationResult","error","logError","getEncryptedChromeCookie","file","cookieFiles","results","cookies","readFileSync","join","consola","logger_default","listChromeProfilePaths","files","sync","chromeApplicationSupport","createDecipheriv","pbkdf2","memoize","removeV10Prefix","value","removePadding","decrypted","padding","extractValue","decodedString","_a","cleanupPatterns","pattern","match","decrypt","encryptedValue","password","resolve","reject","error","key","iv","decipher","e","memoize","getChromePassword","memoize","logError","getMacOSPassword","password","logDebug","error","getExpiryDate","expiry","createExportedCookie","domain","name","value","file","decrypted","ChromeCookieQueryStrategy","createTaggedLogger","cookieFiles","listChromeProfilePaths","path","password","getChromePassword","cookies","flatMapAsync","logOperationResult","error","logError","encryptedCookies","getEncryptedChromeCookie","context","cookie","result","decryptedValue","decrypt"]}
|
package/dist/chunk-FR2MKDHT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{groupBy as a}from"lodash-es";function f(o,p={}){let{format:n="merged",showFilePaths:m=!0,separator:i="; "}=p;if(o.length===0)return n==="merged"?"":[];if(n==="merged")return o.map(e=>e.value).join(i);let s=a(o,e=>{var t,r;return(r=(t=e.meta)==null?void 0:t.file)!=null?r:"unknown"});return Object.entries(s).map(([e,t])=>{let r=t.map(u=>u.value).join(i);return m?`${e}: ${r}`:r})}export{f as a};
|
|
2
|
-
//# sourceMappingURL=chunk-FR2MKDHT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/cookies/renderCookies.ts"],"sourcesContent":["import { groupBy } from \"lodash-es\";\n\nimport type { RenderOptions } from \"../../types/CookieRender\";\nimport type { ExportedCookie } from \"../../types/ExportedCookie\";\n\n/**\n * Renders cookies as a string or array of strings based on the provided format option.\n * Supports merged format for single string output or grouped format for file-based grouping.\n * @param cookies - The cookies to render\n * @param options - Options for rendering\n * @param options.format - The output format ('merged' or 'grouped')\n * @param options.showFilePaths - Whether to include file paths in grouped output\n * @param options.separator - Custom separator for cookie values\n * @returns A string for merged format, or array of strings for grouped format\n * @example\n * ```typescript\n * // Merged format (default)\n * const cookies = [\n * { value: 'sessionId=abc123' },\n * { value: 'theme=dark' }\n * ];\n * renderCookies(cookies);\n * // Returns: \"sessionId=abc123; theme=dark\"\n *\n * // Grouped format with file paths\n * const groupedCookies = [\n * { value: 'sessionId=abc123', meta: { file: 'auth.ts' } },\n * { value: 'theme=dark', meta: { file: 'preferences.ts' } }\n * ];\n * renderCookies(groupedCookies, { format: 'grouped', showFilePaths: true });\n * // Returns: [\"auth.ts: sessionId=abc123\", \"preferences.ts: theme=dark\"]\n * ```\n */\nexport function renderCookies(\n cookies: ExportedCookie[],\n options: RenderOptions = {},\n): string | string[] {\n const { format = \"merged\", showFilePaths = true, separator = \"; \" } = options;\n\n if (cookies.length === 0) {\n return format === \"merged\" ? \"\" : [];\n }\n\n if (format === \"merged\") {\n return cookies.map((c) => c.value).join(separator);\n }\n\n const groupedByFile = groupBy(cookies, (c) => c.meta?.file ?? \"unknown\");\n return Object.entries(groupedByFile).map(([file, fileCookies]) => {\n const values = fileCookies.map((c) => c.value).join(separator);\n return showFilePaths ? `${file}: ${values}` : values;\n });\n}\n"],"mappings":"AAAA,OAAS,WAAAA,MAAe,YAiCjB,SAASC,EACdC,EACAC,EAAyB,CAAC,EACP,CACnB,GAAM,CAAE,OAAAC,EAAS,SAAU,cAAAC,EAAgB,GAAM,UAAAC,EAAY,IAAK,EAAIH,EAEtE,GAAID,EAAQ,SAAW,EACrB,OAAOE,IAAW,SAAW,GAAK,CAAC,EAGrC,GAAIA,IAAW,SACb,OAAOF,EAAQ,IAAKK,GAAMA,EAAE,KAAK,EAAE,KAAKD,CAAS,EAGnD,IAAME,EAAgBR,EAAQE,EAAUK,GAAG,CA/C7C,IAAAE,EAAAC,EA+CgD,OAAAA,GAAAD,EAAAF,EAAE,OAAF,YAAAE,EAAQ,OAAR,KAAAC,EAAgB,UAAS,EACvE,OAAO,OAAO,QAAQF,CAAa,EAAE,IAAI,CAAC,CAACG,EAAMC,CAAW,IAAM,CAChE,IAAMC,EAASD,EAAY,IAAKL,GAAMA,EAAE,KAAK,EAAE,KAAKD,CAAS,EAC7D,OAAOD,EAAgB,GAAGM,CAAI,KAAKE,CAAM,GAAKA,CAChD,CAAC,CACH","names":["groupBy","renderCookies","cookies","options","format","showFilePaths","separator","c","groupedByFile","_a","_b","file","fileCookies","values"]}
|
package/dist/chunk-HMKSQBDC.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as p,b as l}from"./chunk-5FUMK7M3.js";import{d as m,f as n}from"./chunk-56Z35D5R.js";import{join as c}from"path";function u(){let o=[],e=process.env.HOME;if(typeof e!="string"||e.length===0)return n("FirefoxCookieQuery","HOME environment variable not set"),o;let a=[c(e,"Library/Application Support/Firefox/Profiles/*/cookies.sqlite"),c(e,".mozilla/firefox/*/cookies.sqlite")];for(let f of a){let i=l(f);o.push(...i)}return m("FirefoxCookieQuery","Found Firefox cookie files",{files:o}),o}var y=class{constructor(){this.browserName="Firefox"}async queryCookies(e,a){let f=u(),i=[];for(let t of f)try{let s=await p({file:t,sql:"SELECT name, value, host as domain, expiry FROM moz_cookies WHERE name = ? AND host LIKE ?",params:[e,`%${a}%`],rowTransform:r=>({name:r.name,value:r.value,domain:r.domain,expiry:r.expiry>0?new Date(r.expiry*1e3):"Infinity",meta:{file:t,browser:"Firefox",decrypted:!1}})});i.push(...s)}catch(s){s instanceof Error?n("FirefoxCookieQuery",`Error reading Firefox cookie file ${t}`,{error:s.message}):n("FirefoxCookieQuery",`Error reading Firefox cookie file ${t}`)}return i}};export{y as a};
|
|
2
|
-
//# sourceMappingURL=chunk-HMKSQBDC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/browsers/firefox/FirefoxCookieQueryStrategy.ts"],"sourcesContent":["import { join } from \"path\";\n\nimport { sync } from \"glob\";\n\nimport { logDebug, logWarn } from \"@utils/logHelpers\";\n\nimport type { BrowserName } from \"../../../types/BrowserName\";\nimport type { CookieQueryStrategy } from \"../../../types/CookieQueryStrategy\";\nimport type { ExportedCookie } from \"../../../types/ExportedCookie\";\nimport { querySqliteThenTransform } from \"../QuerySqliteThenTransform\";\n\ninterface FirefoxCookieRow {\n name: string;\n value: string;\n domain: string;\n expiry: number;\n}\n\n/**\n * Find all Firefox cookie database files\n * @returns An array of file paths to Firefox cookie databases\n */\nfunction findFirefoxCookieFiles(): string[] {\n const files: string[] = [];\n const homedir = process.env.HOME;\n\n if (typeof homedir !== \"string\" || homedir.length === 0) {\n logWarn(\"FirefoxCookieQuery\", \"HOME environment variable not set\");\n return files;\n }\n\n const patterns = [\n join(\n homedir,\n \"Library/Application Support/Firefox/Profiles/*/cookies.sqlite\",\n ),\n join(homedir, \".mozilla/firefox/*/cookies.sqlite\"),\n ];\n\n for (const pattern of patterns) {\n const matches = sync(pattern);\n files.push(...matches);\n }\n\n logDebug(\"FirefoxCookieQuery\", \"Found Firefox cookie files\", { files });\n return files;\n}\n\n/**\n * Strategy for querying cookies from Firefox browser\n * @example\n */\nexport class FirefoxCookieQueryStrategy implements CookieQueryStrategy {\n /**\n *\n */\n public readonly browserName: BrowserName = \"Firefox\";\n\n /**\n * Queries cookies from Firefox's cookie store\n * @param name - The name pattern to match cookies against\n * @param domain - The domain pattern to match cookies against\n * @returns A promise that resolves to an array of exported cookies\n */\n public async queryCookies(\n name: string,\n domain: string,\n ): Promise<ExportedCookie[]> {\n const files = findFirefoxCookieFiles();\n const results: ExportedCookie[] = [];\n\n for (const file of files) {\n try {\n const cookies = await querySqliteThenTransform<\n FirefoxCookieRow,\n ExportedCookie\n >({\n file,\n sql: \"SELECT name, value, host as domain, expiry FROM moz_cookies WHERE name = ? AND host LIKE ?\",\n params: [name, `%${domain}%`],\n rowTransform: (row) => ({\n name: row.name,\n value: row.value,\n domain: row.domain,\n expiry: row.expiry > 0 ? new Date(row.expiry * 1000) : \"Infinity\",\n meta: {\n file,\n browser: \"Firefox\",\n decrypted: false,\n },\n }),\n });\n\n results.push(...cookies);\n } catch (error) {\n if (error instanceof Error) {\n logWarn(\n \"FirefoxCookieQuery\",\n `Error reading Firefox cookie file ${file}`,\n { error: error.message },\n );\n } else {\n logWarn(\n \"FirefoxCookieQuery\",\n `Error reading Firefox cookie file ${file}`,\n );\n }\n }\n }\n\n return results;\n }\n}\n"],"mappings":"8FAAA,OAAS,QAAAA,MAAY,OAsBrB,SAASC,GAAmC,CAC1C,IAAMC,EAAkB,CAAC,EACnBC,EAAU,QAAQ,IAAI,KAE5B,GAAI,OAAOA,GAAY,UAAYA,EAAQ,SAAW,EACpD,OAAAC,EAAQ,qBAAsB,mCAAmC,EAC1DF,EAGT,IAAMG,EAAW,CACfC,EACEH,EACA,+DACF,EACAG,EAAKH,EAAS,mCAAmC,CACnD,EAEA,QAAWI,KAAWF,EAAU,CAC9B,IAAMG,EAAUC,EAAKF,CAAO,EAC5BL,EAAM,KAAK,GAAGM,CAAO,CACvB,CAEA,OAAAE,EAAS,qBAAsB,6BAA8B,CAAE,MAAAR,CAAM,CAAC,EAC/DA,CACT,CAMO,IAAMS,EAAN,KAAgE,CAAhE,cAIL,KAAgB,YAA2B,UAQ3C,MAAa,aACXC,EACAC,EAC2B,CAC3B,IAAMX,EAAQD,EAAuB,EAC/Ba,EAA4B,CAAC,EAEnC,QAAWC,KAAQb,EACjB,GAAI,CACF,IAAMc,EAAU,MAAMC,EAGpB,CACA,KAAAF,EACA,IAAK,6FACL,OAAQ,CAACH,EAAM,IAAIC,CAAM,GAAG,EAC5B,aAAeK,IAAS,CACtB,KAAMA,EAAI,KACV,MAAOA,EAAI,MACX,OAAQA,EAAI,OACZ,OAAQA,EAAI,OAAS,EAAI,IAAI,KAAKA,EAAI,OAAS,GAAI,EAAI,WACvD,KAAM,CACJ,KAAAH,EACA,QAAS,UACT,UAAW,EACb,CACF,EACF,CAAC,EAEDD,EAAQ,KAAK,GAAGE,CAAO,CACzB,OAASG,EAAO,CACVA,aAAiB,MACnBf,EACE,qBACA,qCAAqCW,CAAI,GACzC,CAAE,MAAOI,EAAM,OAAQ,CACzB,EAEAf,EACE,qBACA,qCAAqCW,CAAI,EAC3C,CAEJ,CAGF,OAAOD,CACT,CACF","names":["join","findFirefoxCookieFiles","files","homedir","logWarn","patterns","join","pattern","matches","sync","logDebug","FirefoxCookieQueryStrategy","name","domain","results","file","cookies","querySqliteThenTransform","row","error"]}
|
package/dist/chunk-W3JALMAX.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-5ZT2G45S.js";import{a as p}from"./chunk-HMKSQBDC.js";import{a as t}from"./chunk-56Z35D5R.js";async function s(r){let o=[new i,new p];return(await Promise.allSettled(o.map(e=>e.queryCookies(r.name,r.domain)))).filter(e=>e.status==="fulfilled").flatMap(e=>e.value)}async function m(r){try{return await s(r)}catch(o){return t.warn("Error querying cookies:",o instanceof Error?o.message:String(o)),[]}}var l=m;export{m as a,l as b};
|
|
2
|
-
//# sourceMappingURL=chunk-W3JALMAX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/cookies/queryCookies.ts","../src/core/cookies/getCookie.ts"],"sourcesContent":["import type { CookieSpec } from \"../../types/CookieSpec\";\nimport type { ExportedCookie } from \"../../types/ExportedCookie\";\nimport { ChromeCookieQueryStrategy } from \"../browsers/chrome/ChromeCookieQueryStrategy\";\nimport { FirefoxCookieQueryStrategy } from \"../browsers/firefox/FirefoxCookieQueryStrategy\";\n\n/**\n * Queries cookies from both Chrome and Firefox browsers.\n * @param cookieSpec - The cookie specification containing search criteria\n * @param cookieSpec.name - The name of the cookie to search for\n * @param cookieSpec.domain - (optional) The domain to filter cookies by\n * @returns An array of ExportedCookie objects that match the specification\n * @example\n * ```typescript\n * const cookies = await queryCookies({\n * name: 'sessionId',\n * domain: 'example.com'\n * });\n * ```\n */\nexport async function queryCookies(\n cookieSpec: CookieSpec,\n): Promise<ExportedCookie[]> {\n const strategies = [\n new ChromeCookieQueryStrategy(),\n new FirefoxCookieQueryStrategy(),\n ];\n\n const results = await Promise.allSettled(\n strategies.map((strategy) =>\n strategy.queryCookies(cookieSpec.name, cookieSpec.domain),\n ),\n );\n\n return results\n .filter(\n (result): result is PromiseFulfilledResult<ExportedCookie[]> =>\n result.status === \"fulfilled\",\n )\n .flatMap((result) => result.value);\n}\n\n/**\n * Default export of the queryCookies function.\n * @example\n * ```typescript\n * import { queryCookies } from './queryCookies';\n * const cookies = await queryCookies({\n * name: 'sessionId',\n * domain: 'example.com'\n * });\n * ```\n */\nexport default queryCookies;\n","import type { CookieSpec } from \"../../types/CookieSpec\";\nimport type { ExportedCookie } from \"../../types/ExportedCookie\";\nimport logger from \"../../utils/logger\";\n\nimport { queryCookies } from \"./queryCookies\";\n\n/**\n * Retrieves browser cookies that match the specified cookie name and domain criteria.\n * This function provides a way to search and filter cookies based on given specifications.\n * @param cookieSpec - The cookie specification containing search criteria\n * @param cookieSpec.name - The name of the cookie to search for\n * @param cookieSpec.domain - (optional) The domain to filter cookies by\n * @returns An array of ExportedCookie objects that match the specification\n * @throws Will catch and handle any errors during cookie querying, logging a warning\n * to the console without throwing to the caller\n * @example\n * ```typescript\n * // Get all cookies named \"sessionId\"\n * const cookies = await getCookie({ name: \"sessionId\" });\n * // Returns: [{ name: \"sessionId\", value: \"abc123\", domain: \".example.com\", ... }]\n *\n * // Get cookies named \"userPref\" from specific domain\n * const domainCookies = await getCookie({\n * name: \"userPref\",\n * domain: \"example.com\"\n * });\n * // Returns: [{ name: \"userPref\", value: \"darkMode\", domain: \"example.com\", ... }]\n * ```\n */\nexport async function getCookie(\n cookieSpec: CookieSpec,\n): Promise<ExportedCookie[]> {\n try {\n const cookies = await queryCookies(cookieSpec);\n return cookies;\n } catch (error: unknown) {\n logger.warn(\n \"Error querying cookies:\",\n error instanceof Error ? error.message : String(error),\n );\n return [];\n }\n}\n\n/**\n * Default export of the getCookie function.\n * @example\n * ```typescript\n * import getCookie from './getCookie';\n * const authCookies = await getCookie({\n * name: \"auth-token\",\n * domain: \"api.example.com\"\n * });\n * ```\n */\nexport default getCookie;\n"],"mappings":"wHAmBA,eAAsBA,EACpBC,EAC2B,CAC3B,IAAMC,EAAa,CACjB,IAAIC,EACJ,IAAIC,CACN,EAQA,OANgB,MAAM,QAAQ,WAC5BF,EAAW,IAAKG,GACdA,EAAS,aAAaJ,EAAW,KAAMA,EAAW,MAAM,CAC1D,CACF,GAGG,OACEK,GACCA,EAAO,SAAW,WACtB,EACC,QAASA,GAAWA,EAAO,KAAK,CACrC,CCVA,eAAsBC,EACpBC,EAC2B,CAC3B,GAAI,CAEF,OADgB,MAAMC,EAAaD,CAAU,CAE/C,OAASE,EAAgB,CACvB,OAAAC,EAAO,KACL,0BACAD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CACvD,EACO,CAAC,CACV,CACF,CAaA,IAAOE,EAAQL","names":["queryCookies","cookieSpec","strategies","ChromeCookieQueryStrategy","FirefoxCookieQueryStrategy","strategy","result","getCookie","cookieSpec","queryCookies","error","logger_default","getCookie_default"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-5ZT2G45S.js";import"./chunk-5FUMK7M3.js";import{a as r}from"./chunk-56Z35D5R.js";import"./chunk-VMBA4NVU.js";async function i(o){try{return await new t().queryCookies(o.name,o.domain)}catch(e){return r.warn("Error querying Chrome cookies:",e),[]}}var k=i;export{k as default,i as getChromeCookie};
|
|
2
|
-
//# sourceMappingURL=getChromeCookie-4ZWACG6M.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/cookies/getChromeCookie.ts"],"sourcesContent":["import type { CookieSpec } from \"../../types/CookieSpec\";\nimport type { ExportedCookie } from \"../../types/ExportedCookie\";\nimport logger from \"../../utils/logger\";\nimport { ChromeCookieQueryStrategy } from \"../browsers/chrome/ChromeCookieQueryStrategy\";\n\n/**\n * Retrieves cookies from Chrome browser storage that match the specified criteria.\n * @param cookieSpec - The cookie specification containing search criteria\n * @param cookieSpec.name - The name of the cookie to search for\n * @param cookieSpec.domain - (optional) The domain to filter cookies by\n * @returns An array of ExportedCookie objects that match the specification\n * @throws Will catch and handle any errors during cookie querying, logging a warning\n * to the console without throwing to the caller\n * @example\n * ```typescript\n * // Get all cookies named \"sessionId\" from Chrome\n * const cookies = await getChromeCookie({ name: \"sessionId\" });\n *\n * // Get cookies named \"userPref\" from specific domain in Chrome\n * const domainCookies = await getChromeCookie({\n * name: \"userPref\",\n * domain: \"example.com\"\n * });\n * ```\n */\nexport async function getChromeCookie(\n cookieSpec: CookieSpec,\n): Promise<ExportedCookie[]> {\n try {\n const strategy = new ChromeCookieQueryStrategy();\n const cookies = await strategy.queryCookies(\n cookieSpec.name,\n cookieSpec.domain,\n );\n return cookies;\n } catch (error: unknown) {\n logger.warn(\"Error querying Chrome cookies:\", error);\n return [];\n }\n}\n\n/**\n * Default export of the getChromeCookie function.\n * @example\n * ```typescript\n * import getChromeCookie from './getChromeCookie';\n * const cookies = await getChromeCookie({\n * name: \"sessionId\",\n * domain: \"example.com\"\n * });\n * ```\n */\nexport default getChromeCookie;\n"],"mappings":"wIAyBA,eAAsBA,EACpBC,EAC2B,CAC3B,GAAI,CAMF,OAJgB,MADC,IAAIC,EAA0B,EAChB,aAC7BD,EAAW,KACXA,EAAW,MACb,CAEF,OAASE,EAAgB,CACvB,OAAAC,EAAO,KAAK,iCAAkCD,CAAK,EAC5C,CAAC,CACV,CACF,CAaA,IAAOE,EAAQL","names":["getChromeCookie","cookieSpec","ChromeCookieQueryStrategy","error","logger_default","getChromeCookie_default"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-HMKSQBDC.js";import"./chunk-5FUMK7M3.js";import{a as r}from"./chunk-56Z35D5R.js";import"./chunk-VMBA4NVU.js";async function i(e){try{return await new t().queryCookies(e.name,e.domain)}catch(o){return r.warn("Error querying Firefox cookies:",o instanceof Error?o.message:String(o)),[]}}var a=i;export{a as default,i as getFirefoxCookie};
|
|
2
|
-
//# sourceMappingURL=getFirefoxCookie-OJYYZFZP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/cookies/getFirefoxCookie.ts"],"sourcesContent":["import type { CookieSpec } from \"../../types/CookieSpec\";\nimport type { ExportedCookie } from \"../../types/ExportedCookie\";\nimport logger from \"../../utils/logger\";\nimport { FirefoxCookieQueryStrategy } from \"../browsers/firefox/FirefoxCookieQueryStrategy\";\n\n/**\n * Retrieves cookies from Firefox browser storage that match the specified criteria.\n * @param cookieSpec - The cookie specification containing search criteria\n * @param cookieSpec.name - The name of the cookie to search for\n * @param cookieSpec.domain - (optional) The domain to filter cookies by\n * @returns An array of ExportedCookie objects that match the specification\n * @throws Will catch and handle any errors during cookie querying, logging a warning\n * to the console without throwing to the caller\n * @example\n * ```typescript\n * // Get all cookies named \"sessionId\" from Firefox\n * const cookies = await getFirefoxCookie({ name: \"sessionId\" });\n *\n * // Get cookies named \"userPref\" from specific domain in Firefox\n * const domainCookies = await getFirefoxCookie({\n * name: \"userPref\",\n * domain: \"example.com\"\n * });\n * ```\n */\nexport async function getFirefoxCookie(\n cookieSpec: CookieSpec,\n): Promise<ExportedCookie[]> {\n try {\n const strategy = new FirefoxCookieQueryStrategy();\n const cookies = await strategy.queryCookies(\n cookieSpec.name,\n cookieSpec.domain,\n );\n return cookies;\n } catch (error: unknown) {\n logger.warn(\n \"Error querying Firefox cookies:\",\n error instanceof Error ? error.message : String(error),\n );\n return [];\n }\n}\n\n/**\n * Default export of the getFirefoxCookie function.\n * @example\n * ```typescript\n * import getFirefoxCookie from './getFirefoxCookie';\n * const sessionCookies = await getFirefoxCookie({\n * name: \"PHPSESSID\",\n * domain: \"example.com\"\n * });\n * ```\n */\nexport default getFirefoxCookie;\n"],"mappings":"wIAyBA,eAAsBA,EACpBC,EAC2B,CAC3B,GAAI,CAMF,OAJgB,MADC,IAAIC,EAA2B,EACjB,aAC7BD,EAAW,KACXA,EAAW,MACb,CAEF,OAASE,EAAgB,CACvB,OAAAC,EAAO,KACL,kCACAD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CACvD,EACO,CAAC,CACV,CACF,CAaA,IAAOE,EAAQL","names":["getFirefoxCookie","cookieSpec","FirefoxCookieQueryStrategy","error","logger_default","getFirefoxCookie_default"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-FR2MKDHT.js";import{a as r}from"./chunk-W3JALMAX.js";import"./chunk-5ZT2G45S.js";import"./chunk-HMKSQBDC.js";import"./chunk-5FUMK7M3.js";import{a as o}from"./chunk-56Z35D5R.js";import"./chunk-VMBA4NVU.js";async function p(i,n={}){try{let e=await r(i);return t(e,{...n,format:"grouped"})}catch(e){return o.warn("Error getting grouped rendered cookies:",e instanceof Error?e.message:String(e)),[]}}var g=p;export{g as default,p as getGroupedRenderedCookies};
|
|
2
|
-
//# sourceMappingURL=getGroupedRenderedCookies-P5VZXZUC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/cookies/getGroupedRenderedCookies.ts"],"sourcesContent":["import type { RenderOptions } from \"../../types/CookieRender\";\nimport type { CookieSpec } from \"../../types/CookieSpec\";\nimport logger from \"../../utils/logger\";\n\nimport { getCookie } from \"./getCookie\";\nimport { renderCookies } from \"./renderCookies\";\n\n/**\n * Retrieves and renders cookies in a grouped format based on their source files.\n * @param cookieSpec - The cookie specification containing search criteria\n * @param cookieSpec.name - The name of the cookie to search for\n * @param cookieSpec.domain - (optional) The domain to filter cookies by\n * @param options - Options for rendering the cookies\n * @param options.showFilePaths - Whether to include file paths in the output\n * @param options.separator - Custom separator for cookie values\n * @returns An array of strings, each representing a group of cookies from a source file\n * @example\n * ```typescript\n * // Basic usage - get all cookies named \"sessionId\" grouped by source file\n * const cookies = await getGroupedRenderedCookies({ name: \"sessionId\" });\n *\n * // Get cookies with domain filter and custom rendering options\n * const domainCookies = await getGroupedRenderedCookies(\n * {\n * name: \"userPref\",\n * domain: \"example.com\"\n * },\n * {\n * showFilePaths: true,\n * separator: \" | \"\n * }\n * );\n * ```\n */\nexport async function getGroupedRenderedCookies(\n cookieSpec: CookieSpec,\n options: Omit<RenderOptions, \"format\"> = {},\n): Promise<string[]> {\n try {\n const cookies = await getCookie(cookieSpec);\n return renderCookies(cookies, {\n ...options,\n format: \"grouped\",\n }) as string[];\n } catch (error: unknown) {\n logger.warn(\n \"Error getting grouped rendered cookies:\",\n error instanceof Error ? error.message : String(error),\n );\n return [];\n }\n}\n\n/**\n * Default export of the getGroupedRenderedCookies function\n * @example\n * ```typescript\n * import getGroupedCookies from './getGroupedRenderedCookies';\n *\n * // Get all session cookies with custom separator\n * const sessionCookies = await getGroupedCookies(\n * { name: \"session_*\" },\n * { separator: \"\\n\" }\n * );\n *\n * // Get cookies from multiple domains\n * const multiDomainCookies = await getGroupedCookies({\n * name: \"tracking\",\n * domain: [\"site1.com\", \"site2.com\"]\n * });\n * ```\n */\nexport default getGroupedRenderedCookies;\n"],"mappings":"wOAkCA,eAAsBA,EACpBC,EACAC,EAAyC,CAAC,EACvB,CACnB,GAAI,CACF,IAAMC,EAAU,MAAMC,EAAUH,CAAU,EAC1C,OAAOI,EAAcF,EAAS,CAC5B,GAAGD,EACH,OAAQ,SACV,CAAC,CACH,OAASI,EAAgB,CACvB,OAAAC,EAAO,KACL,0CACAD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CACvD,EACO,CAAC,CACV,CACF,CAqBA,IAAOE,EAAQR","names":["getGroupedRenderedCookies","cookieSpec","options","cookies","getCookie","renderCookies","error","logger_default","getGroupedRenderedCookies_default"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-FR2MKDHT.js";import{a as o}from"./chunk-W3JALMAX.js";import"./chunk-5ZT2G45S.js";import"./chunk-HMKSQBDC.js";import"./chunk-5FUMK7M3.js";import{a as r}from"./chunk-56Z35D5R.js";import"./chunk-VMBA4NVU.js";async function m(i,n={}){try{let e=await o(i);return t(e,{...n,format:"merged"})}catch(e){return r.warn("Error getting merged rendered cookies:",e instanceof Error?e.message:String(e)),""}}var d=m;export{d as default,m as getMergedRenderedCookies};
|
|
2
|
-
//# sourceMappingURL=getMergedRenderedCookies-C6TXK2I4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/cookies/getMergedRenderedCookies.ts"],"sourcesContent":["import type { RenderOptions } from \"../../types/CookieRender\";\nimport type { CookieSpec } from \"../../types/CookieSpec\";\nimport logger from \"../../utils/logger\";\n\nimport { getCookie } from \"./getCookie\";\nimport { renderCookies } from \"./renderCookies\";\n\n/**\n * Retrieves and renders cookies in a merged format.\n * @param cookieSpec - The cookie specification containing search criteria\n * @param cookieSpec.name - The name of the cookie to search for\n * @param cookieSpec.domain - (optional) The domain to filter cookies by\n * @param options - Options for rendering the cookies\n * @param options.showFilePaths - Whether to include file paths in the output\n * @param options.separator - Custom separator for cookie values\n * @returns A string containing all cookie values merged with the specified separator\n * @example\n * ```typescript\n * const cookies = await getMergedRenderedCookies({\n * name: \"sessionId\",\n * domain: \"example.com\"\n * });\n * ```\n */\nexport async function getMergedRenderedCookies(\n cookieSpec: CookieSpec,\n options: Omit<RenderOptions, \"format\"> = {},\n): Promise<string> {\n try {\n const cookies = await getCookie(cookieSpec);\n return renderCookies(cookies, { ...options, format: \"merged\" }) as string;\n } catch (error: unknown) {\n logger.warn(\n \"Error getting merged rendered cookies:\",\n error instanceof Error ? error.message : String(error),\n );\n return \"\";\n }\n}\n\n/**\n * Default export of the getMergedRenderedCookies function.\n * @example\n * ```typescript\n * import { getMergedRenderedCookies } from './getMergedRenderedCookies';\n * const cookies = await getMergedRenderedCookies({\n * name: 'sessionId',\n * domain: 'example.com'\n * });\n * ```\n */\nexport default getMergedRenderedCookies;\n"],"mappings":"wOAwBA,eAAsBA,EACpBC,EACAC,EAAyC,CAAC,EACzB,CACjB,GAAI,CACF,IAAMC,EAAU,MAAMC,EAAUH,CAAU,EAC1C,OAAOI,EAAcF,EAAS,CAAE,GAAGD,EAAS,OAAQ,QAAS,CAAC,CAChE,OAASI,EAAgB,CACvB,OAAAC,EAAO,KACL,yCACAD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CACvD,EACO,EACT,CACF,CAaA,IAAOE,EAAQR","names":["getMergedRenderedCookies","cookieSpec","options","cookies","getCookie","renderCookies","error","logger_default","getMergedRenderedCookies_default"]}
|
package/tsup.config.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Main configuration for building both library and CLI bundles
|
|
5
|
-
* @example
|
|
6
|
-
* ```typescript
|
|
7
|
-
* // Build both library and CLI bundles
|
|
8
|
-
* import config from './tsup.config';
|
|
9
|
-
* await build(config);
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export default defineConfig({
|
|
13
|
-
entry: ["src/index.ts", "src/cli/cli.ts"],
|
|
14
|
-
format: ["cjs", "esm"],
|
|
15
|
-
dts: true,
|
|
16
|
-
clean: true,
|
|
17
|
-
sourcemap: true,
|
|
18
|
-
minify: true,
|
|
19
|
-
platform: "node",
|
|
20
|
-
bundle: true,
|
|
21
|
-
external: ["fs", "path", "crypto", "os", "child_process"],
|
|
22
|
-
esbuildOptions(options) {
|
|
23
|
-
options.alias = {
|
|
24
|
-
lodash: "lodash-es",
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|