@mherod/get-cookie 4.1.0 → 4.2.2

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.
Files changed (51) hide show
  1. package/.env.example +5 -0
  2. package/.husky/commit-msg +6 -2
  3. package/.husky/pre-commit +6 -4
  4. package/.husky/pre-push +6 -4
  5. package/README.md +76 -117
  6. package/dist/cli.cjs +1 -3
  7. package/dist/cli.cjs.map +1 -1
  8. package/dist/index.cjs +1 -3
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +220 -41
  11. package/dist/index.d.ts +220 -41
  12. package/dist/index.js +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/tsconfig.tsbuildinfo +1 -0
  15. package/eslint.config.js +8 -18
  16. package/examples/README.md +37 -0
  17. package/examples/advanced-usage.ts +56 -0
  18. package/examples/basic-usage.ts +43 -0
  19. package/examples/cli-examples.sh +51 -0
  20. package/package.json +13 -4
  21. package/tsconfig.build.json +2 -2
  22. package/tsconfig.cli.json +12 -0
  23. package/tsconfig.tsup.json +12 -0
  24. package/tsup.cli.ts +1 -0
  25. package/tsup.lib.ts +1 -0
  26. package/dist/chunk-3FVH4L25.js +0 -2
  27. package/dist/chunk-3FVH4L25.js.map +0 -1
  28. package/dist/chunk-56Z35D5R.js +0 -2
  29. package/dist/chunk-56Z35D5R.js.map +0 -1
  30. package/dist/chunk-7XZ7PCDJ.js +0 -2
  31. package/dist/chunk-7XZ7PCDJ.js.map +0 -1
  32. package/dist/chunk-DVWQBWUF.js +0 -4
  33. package/dist/chunk-DVWQBWUF.js.map +0 -1
  34. package/dist/chunk-I6AYGFSQ.js +0 -2
  35. package/dist/chunk-I6AYGFSQ.js.map +0 -1
  36. package/dist/chunk-U27I5BLR.js +0 -2
  37. package/dist/chunk-U27I5BLR.js.map +0 -1
  38. package/dist/chunk-YOZOS2YM.js +0 -2
  39. package/dist/chunk-YOZOS2YM.js.map +0 -1
  40. package/dist/getChromeCookie-2ROVM47V.js +0 -2
  41. package/dist/getChromeCookie-2ROVM47V.js.map +0 -1
  42. package/dist/getChromePassword-O452VQWI.js +0 -2
  43. package/dist/getChromePassword-O452VQWI.js.map +0 -1
  44. package/dist/getCookie-CRE6M3GI.js +0 -2
  45. package/dist/getCookie-CRE6M3GI.js.map +0 -1
  46. package/dist/getFirefoxCookie-5P74VDC7.js +0 -2
  47. package/dist/getFirefoxCookie-5P74VDC7.js.map +0 -1
  48. package/dist/getGroupedRenderedCookies-DFEJTTC6.js +0 -2
  49. package/dist/getGroupedRenderedCookies-DFEJTTC6.js.map +0 -1
  50. package/dist/getMergedRenderedCookies-W5GSSHQQ.js +0 -2
  51. package/dist/getMergedRenderedCookies-W5GSSHQQ.js.map +0 -1
@@ -1,2 +0,0 @@
1
- var i=Object.create;var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var h=a=>{throw TypeError(a)};var n=(a,b,c)=>b in a?f(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c;var r=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var o=(a,b,c,d)=>{if(b&&typeof b=="object"||typeof b=="function")for(let e of k(b))!m.call(a,e)&&e!==c&&f(a,e,{get:()=>b[e],enumerable:!(d=j(b,e))||d.enumerable});return a};var s=(a,b,c)=>(c=a!=null?i(l(a)):{},o(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a));var t=(a,b,c)=>n(a,typeof b!="symbol"?b+"":b,c),g=(a,b,c)=>b.has(a)||h("Cannot "+c);var p=(a,b,c)=>(g(a,b,"read from private field"),c?c.call(a):b.get(a)),u=(a,b,c)=>b.has(a)?h("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(a):b.set(a,c),q=(a,b,c,d)=>(g(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c),v=(a,b,c)=>(g(a,b,"access private method"),c);var w=(a,b,c,d)=>({set _(e){q(a,b,e,c)},get _(){return p(a,b,d)}});export{r as a,s as b,t as c,p as d,u as e,q as f,v as g,w as h};
2
- //# sourceMappingURL=chunk-I6AYGFSQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,2 +0,0 @@
1
- import{a as S}from"./chunk-7XZ7PCDJ.js";import{a as E}from"./chunk-3FVH4L25.js";import{a as x,c as y}from"./chunk-56Z35D5R.js";import{join as Z}from"path";import{readFileSync as Q}from"fs";import{homedir as ne}from"os";import{join as ae}from"path";import A from"destr";import{z as o}from"zod";var d=o.string().trim().min(1,"Domain cannot be empty").refine(t=>/^\.?[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(t),"Invalid domain format"),g=o.string().trim().min(1,"Cookie name cannot be empty").refine(t=>/^[\x21\x23-\x27\x2A\x2B\x2D-\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+$/.test(t),"Invalid cookie name format - must contain only valid characters (letters, numbers, and certain symbols)"),w=o.string().trim().min(1,"Path cannot be empty").refine(t=>t.startsWith("/"),"Path must start with /").refine(t=>/^\/[!#$%&'()*+,\-./:=@\w]*$/.test(t),"Invalid path format - must contain only valid URL path characters").default("/"),b=o.string().trim().transform(t=>A(t)).pipe(o.any()),v=o.object({name:g,value:b,domain:d,path:w,expiry:o.number().int(),creation:o.number().int(),flags:o.number().optional(),version:o.number().int().optional(),port:o.number().int().optional(),comment:o.string().optional(),commentURL:o.string().optional()}),Y=o.object({name:g,domain:d}).strict(),F=o.object({file:o.string().trim().min(1,"File path cannot be empty").optional(),browser:o.string().trim().optional(),decrypted:o.boolean().optional(),secure:o.boolean().optional(),httpOnly:o.boolean().optional(),path:w.optional()}).catchall(o.unknown()).strict(),M=o.object({domain:d,name:g,value:b,expiry:o.union([o.literal("Infinity"),o.date(),o.number().int().positive("Expiry must be a positive number")]).optional(),meta:F.optional()}).strict(),J=o.object({expiry:o.number().int().optional(),domain:d,name:g,value:o.union([o.string(),o.instanceof(Buffer)])}).strict(),X=o.object({format:o.enum(["merged","grouped"]).optional(),separator:o.string().optional(),showFilePaths:o.boolean().optional()}).strict(),_=o.enum(["Chrome","Firefox","Safari","internal","unknown"]),ee=o.object({browserName:_,queryCookies:o.function().args(o.string(),o.string()).returns(o.promise(o.array(M)))}).strict();var j="cook",$=510912288576766e3,R=978307200;function H(t,e){let n=e;for(;n<t.length&&t[n]!==0;)n++;return[t.toString("utf8",e,n),n+1]}function q(t,e){let n=t.readUInt32LE(e),i=t.readUInt32LE(e+4),s=t.readUInt32LE(e+8),r=t.readUInt32LE(e+12),c=t.readUInt32LE(e+16),l=t.readUInt32LE(e+20),a=t.readUInt32LE(e+24),p=t.readUInt32LE(e+28),I=t.readUInt32LE(e+32),O=t.readUInt32LE(e+36),U=t.readDoubleLE(e+40)+R,z=t.readDoubleLE(e+48)+R,f=e+56,h;r&&(h=t.readUInt16LE(f),f+=2);let D=[{field:"url",offset:c},{field:"name",offset:l},{field:"path",offset:a},{field:"value",offset:p},{field:"comment",offset:I},{field:"commentURL",offset:O}].sort((C,u)=>C.offset-u.offset),m={};for(let{field:C,offset:u}of D)if(u>0){let[N,P]=H(t,e+u);m[C]=N,f=Math.max(f,P)}return[v.parse({name:m.name,value:m.value,domain:m.url.startsWith(".")?m.url.slice(1):m.url,path:m.path||"/",expiry:Math.floor(U),creation:Math.floor(z),flags:s,version:i,port:h,comment:m.comment,commentURL:m.commentURL}),n]}function T(t,e,n){let i=e+5,s=t.readUInt32BE(i),r=e+s,c=[],l=e+n;for(;r<l-8;)try{let[a,p]=q(t,r);c.push(a),r+=p}catch(a){console.warn(`Error decoding cookie at offset ${r}:`,a);break}return c}function B(t){let e=Q(t);if(e.toString("utf8",0,4)!==j)throw new Error("Invalid cookie file format: wrong magic header");let i=e.readUInt32BE(4),s=[];for(let a=0;a<i;a++)s.push(e.readUInt32BE(8+a*4));let r=8+i*4,c=[];for(let a=0;a<i;a++)try{let p=T(e,r,s[a]);c.push(...p),r+=s[a]}catch(p){console.warn(`Error decoding page ${a}:`,p),r+=s[a]}return Number(e.readBigUInt64BE(e.length-8))!==$&&console.warn("Invalid cookie file format: wrong footer"),c}var k=class{constructor(){this.browserName="Safari"}getHomeDir(){let e=process.env.HOME;return typeof e!="string"||e.trim().length===0?(y("SafariCookieQueryStrategy","HOME environment variable not set"),""):e}getCookieDbPath(e){return Z(e,"Library","Containers","com.apple.Safari","Data","Library","Cookies","Cookies.binarycookies")}decodeCookies(e,n,i){try{return B(e).filter(r=>r.name===n&&r.domain.includes(i)).map(r=>({domain:r.domain,name:r.name,value:Buffer.isBuffer(r.value)?r.value.toString():String(r.value),expiry:typeof r.expiry=="number"&&r.expiry>0?new Date(r.expiry*1e3):"Infinity",meta:{file:e,browser:"Safari",decrypted:!1}}))}catch(s){return s instanceof Error?y("SafariCookieQueryStrategy",`Error decoding ${e}`,{error:s,name:n,domain:i}):y("SafariCookieQueryStrategy",`Error decoding ${e}`,{error:"Unknown error",name:n,domain:i}),[]}}async queryCookies(e,n){let i=this.getHomeDir();if(typeof i!="string"||i.length===0)return Promise.resolve([]);let s=this.getCookieDbPath(i);return Promise.resolve(this.decodeCookies(s,e,n))}};async function L(t){if(!t.name||!t.domain)return[];let{name:e,domain:n}=t;if(typeof e!="string"||typeof n!="string")return[];let i=[new S,new E,new k];return(await Promise.allSettled(i.map(r=>r.queryCookies(e,n)))).filter(r=>r.status==="fulfilled").flatMap(r=>r.value)}async function W(t){try{return await L(t)}catch(e){return x.warn("Error querying cookies:",e instanceof Error?e.message:String(e)),[]}}var he=W;export{M as a,W as b,he as c};
2
- //# sourceMappingURL=chunk-U27I5BLR.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/browsers/safari/SafariCookieQueryStrategy.ts","../src/core/browsers/decodeBinaryCookies.ts","../src/types/schemas.ts","../src/core/cookies/queryCookies.ts","../src/core/cookies/getCookie.ts"],"sourcesContent":["import { join } from \"path\";\n\nimport { logError } from \"@utils/logHelpers\";\n\nimport type {\n BrowserName,\n CookieQueryStrategy,\n ExportedCookie,\n} from \"../../../types/schemas\";\nimport { decodeBinaryCookies } from \"../decodeBinaryCookies\";\n\n/**\n * Strategy for querying cookies from Safari browser\n */\nexport class SafariCookieQueryStrategy implements CookieQueryStrategy {\n /**\n * The browser name for this strategy\n */\n public readonly browserName: BrowserName = \"Safari\";\n\n /**\n * Gets the user's home directory\n * @returns The home directory path or empty string if not found\n */\n private getHomeDir(): string {\n const homeDir = process.env.HOME;\n if (typeof homeDir !== \"string\" || homeDir.trim().length === 0) {\n logError(\n \"SafariCookieQueryStrategy\",\n \"HOME environment variable not set\",\n );\n return \"\";\n }\n return homeDir;\n }\n\n /**\n * Gets the path to Safari's cookie database\n * @param homeDir - The user's home directory\n * @returns Path to the cookie database\n */\n private getCookieDbPath(homeDir: string): string {\n return join(\n homeDir,\n \"Library\",\n \"Containers\",\n \"com.apple.Safari\",\n \"Data\",\n \"Library\",\n \"Cookies\",\n \"Cookies.binarycookies\",\n );\n }\n\n /**\n * Decodes cookies from Safari's binary cookie file\n * @param cookieDbPath - Path to the cookie database\n * @param name - Name of the cookie to find\n * @param domain - Domain to filter cookies by\n * @returns Array of exported cookies\n */\n private decodeCookies(\n cookieDbPath: string,\n name: string,\n domain: string,\n ): ExportedCookie[] {\n try {\n const cookies = decodeBinaryCookies(cookieDbPath);\n return cookies\n .filter(\n (cookie) => cookie.name === name && cookie.domain.includes(domain),\n )\n .map((cookie) => ({\n domain: cookie.domain,\n name: cookie.name,\n value: Buffer.isBuffer(cookie.value)\n ? cookie.value.toString()\n : String(cookie.value),\n expiry:\n typeof cookie.expiry === \"number\" && cookie.expiry > 0\n ? new Date(cookie.expiry * 1000)\n : \"Infinity\",\n meta: {\n file: cookieDbPath,\n browser: \"Safari\" as const,\n decrypted: false,\n },\n }));\n } catch (error) {\n if (error instanceof Error) {\n logError(\n \"SafariCookieQueryStrategy\",\n `Error decoding ${cookieDbPath}`,\n { error, name, domain },\n );\n } else {\n logError(\n \"SafariCookieQueryStrategy\",\n `Error decoding ${cookieDbPath}`,\n { error: \"Unknown error\", name, domain },\n );\n }\n return [];\n }\n }\n\n /**\n * Query Safari's cookie storage for cookies matching the given criteria\n * @param name - Name of the cookie to find\n * @param domain - Domain to filter cookies by\n * @returns Array of matching cookies, or empty array if none found\n */\n public async queryCookies(\n name: string,\n domain: string,\n ): Promise<ExportedCookie[]> {\n const homeDir = this.getHomeDir();\n if (typeof homeDir !== \"string\" || homeDir.length === 0) {\n return Promise.resolve([]);\n }\n\n const cookieDbPath = this.getCookieDbPath(homeDir);\n return Promise.resolve(this.decodeCookies(cookieDbPath, name, domain));\n }\n}\n","import { readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { join } from \"path\";\n\nimport type { BinaryCookieRow } from \"../../types/schemas\";\nimport { BinaryCookieRowSchema } from \"../../types/schemas\";\n\n// Cookie flag constants\nconst _COOKIE_FLAGS = {\n SECURE: 0x1,\n HTTP_ONLY: 0x4,\n UNKNOWN1: 0x8,\n UNKNOWN2: 0x10,\n} as const;\n\n// File structure constants\nconst _FILE_HEADER_MAGIC = \"cook\";\nconst _FILE_FOOTER = 0x071720050000004b;\n\n// The date offset for Safari cookies (until 2017)\nconst _SAFARI_DATE_OFFSET = 978307200; // Difference between Unix epoch and Mac epoch (2001-01-01 00:00:00)\n\nfunction readNullTerminatedString(\n buffer: Buffer,\n offset: number,\n): [string, number] {\n let end = offset;\n while (end < buffer.length && buffer[end] !== 0) {\n end++;\n }\n return [buffer.toString(\"utf8\", offset, end), end + 1];\n}\n\nfunction decodeCookieHeader(\n buffer: Buffer,\n offset: number,\n): [BinaryCookieRow, number] {\n // First 4 bytes are the cookie size in little-endian\n const size = buffer.readUInt32LE(offset);\n\n // Read version and flags\n const version = buffer.readUInt32LE(offset + 4);\n const flags = buffer.readUInt32LE(offset + 8);\n\n // Check for port\n const hasPort = buffer.readUInt32LE(offset + 12);\n\n // Read offsets for dynamic fields\n const urlOffset = buffer.readUInt32LE(offset + 16);\n const nameOffset = buffer.readUInt32LE(offset + 20);\n const pathOffset = buffer.readUInt32LE(offset + 24);\n const valueOffset = buffer.readUInt32LE(offset + 28);\n const commentOffset = buffer.readUInt32LE(offset + 32);\n const commentURLOffset = buffer.readUInt32LE(offset + 36);\n\n // Read dates and adjust for Safari epoch\n const expiryDate = buffer.readDoubleLE(offset + 40) + _SAFARI_DATE_OFFSET;\n const creationDate = buffer.readDoubleLE(offset + 48) + _SAFARI_DATE_OFFSET;\n\n let currentOffset = offset + 56; // Fixed header size\n\n // Read port if present\n let port: number | undefined;\n if (hasPort) {\n port = buffer.readUInt16LE(currentOffset);\n currentOffset += 2;\n }\n\n // Read strings in order of their offsets\n const offsets = [\n { field: \"url\", offset: urlOffset },\n { field: \"name\", offset: nameOffset },\n { field: \"path\", offset: pathOffset },\n { field: \"value\", offset: valueOffset },\n { field: \"comment\", offset: commentOffset },\n { field: \"commentURL\", offset: commentURLOffset },\n ].sort((a, b) => a.offset - b.offset);\n\n const fields: Record<string, string> = {};\n\n for (const { field, offset: stringOffset } of offsets) {\n if (stringOffset > 0) {\n const [value, nextOffset] = readNullTerminatedString(\n buffer,\n offset + stringOffset,\n );\n fields[field] = value;\n currentOffset = Math.max(currentOffset, nextOffset);\n }\n }\n\n // Create and validate the cookie row\n const cookieRow = BinaryCookieRowSchema.parse({\n name: fields.name,\n value: fields.value,\n domain: fields.url.startsWith(\".\") ? fields.url.slice(1) : fields.url,\n path: fields.path || \"/\",\n expiry: Math.floor(expiryDate),\n creation: Math.floor(creationDate),\n flags,\n version,\n port,\n comment: fields.comment,\n commentURL: fields.commentURL,\n });\n\n return [cookieRow, size];\n}\n\nfunction decodePage(\n buffer: Buffer,\n offset: number,\n pageSize: number,\n): BinaryCookieRow[] {\n // Skip first 5 bytes\n const headerLengthOffset = offset + 5;\n // Next 4 bytes contain header length\n const headerLength = buffer.readUInt32BE(headerLengthOffset);\n\n let currentOffset = offset + headerLength;\n const cookies: BinaryCookieRow[] = [];\n const pageEnd = offset + pageSize;\n\n // Read cookies until we reach the page end\n while (currentOffset < pageEnd - 8) {\n try {\n const [cookie, size] = decodeCookieHeader(buffer, currentOffset);\n cookies.push(cookie);\n currentOffset += size;\n } catch (error) {\n console.warn(`Error decoding cookie at offset ${currentOffset}:`, error);\n break;\n }\n }\n\n return cookies;\n}\n\n/**\n * Decodes a Safari binary cookie file into an array of cookie objects.\n * @param cookieDbPath - Path to the Safari Cookies.binarycookies file\n * @returns Array of decoded cookie objects\n * @throws {Error} If the file cannot be read or has invalid format\n */\nexport function decodeBinaryCookies(cookieDbPath: string): BinaryCookieRow[] {\n const buffer = readFileSync(cookieDbPath);\n\n // Validate magic header\n const magic = buffer.toString(\"utf8\", 0, 4);\n if (magic !== _FILE_HEADER_MAGIC) {\n throw new Error(\"Invalid cookie file format: wrong magic header\");\n }\n\n // Read number of pages\n const numPages = buffer.readUInt32BE(4);\n\n // Read the page sizes array (4 bytes per page)\n const pageSizes: number[] = [];\n for (let i = 0; i < numPages; i++) {\n pageSizes.push(buffer.readUInt32BE(8 + i * 4));\n }\n\n // Skip the page sizes array\n let offset = 8 + numPages * 4;\n const cookies: BinaryCookieRow[] = [];\n\n // Process each page\n for (let i = 0; i < numPages; i++) {\n try {\n const pageCookies = decodePage(buffer, offset, pageSizes[i]);\n cookies.push(...pageCookies);\n offset += pageSizes[i];\n } catch (error) {\n console.warn(`Error decoding page ${i}:`, error);\n offset += pageSizes[i];\n }\n }\n\n // Validate footer\n const footer = Number(buffer.readBigUInt64BE(buffer.length - 8));\n if (footer !== _FILE_FOOTER) {\n console.warn(\"Invalid cookie file format: wrong footer\");\n }\n\n return cookies;\n}\n\n/**\n * Retrieves cookies from Safari's binary cookie store.\n * @returns Array of decoded Safari cookies\n */\nexport function getSafariCookies(): BinaryCookieRow[] {\n const cookieDbPath = join(\n homedir(),\n \"Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies\",\n );\n return decodeBinaryCookies(cookieDbPath);\n}\n","import destr from \"destr\";\nimport { z } from \"zod\";\n\n/**\n * Zod schema for cookie domain validation.\n * Enforces standard cookie domain rules.\n * @example\n * ```typescript\n * // Valid domains\n * CookieDomainSchema.parse(\"example.com\"); // OK\n * CookieDomainSchema.parse(\".example.com\"); // OK - leading dot is valid\n * CookieDomainSchema.parse(\"sub.example.com\"); // OK\n *\n * // Invalid domains\n * CookieDomainSchema.parse(\"\"); // Error: Domain cannot be empty\n * CookieDomainSchema.parse(\"invalid domain\"); // Error: Invalid domain format\n * ```\n */\nexport const CookieDomainSchema = z\n .string()\n .trim()\n .min(1, \"Domain cannot be empty\")\n .refine(\n (domain) =>\n /^\\.?[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(\n domain,\n ),\n \"Invalid domain format\",\n );\n\n/**\n * Zod schema for cookie name validation.\n * Enforces standard cookie name rules according to RFC 6265.\n * @example\n * ```typescript\n * // Valid names\n * CookieNameSchema.parse(\"session\"); // OK\n * CookieNameSchema.parse(\"auth_token\"); // OK\n * CookieNameSchema.parse(\"user-preference\"); // OK\n *\n * // Invalid names\n * CookieNameSchema.parse(\"\"); // Error: Cookie name cannot be empty\n * CookieNameSchema.parse(\"session;\"); // Error: Invalid cookie name format\n * CookieNameSchema.parse(\"my cookie\"); // Error: Invalid cookie name format\n * ```\n */\nexport const CookieNameSchema = z\n .string()\n .trim()\n .min(1, \"Cookie name cannot be empty\")\n .refine(\n (name) =>\n /^[\\x21\\x23-\\x27\\x2A\\x2B\\x2D-\\x2E\\x30-\\x39\\x41-\\x5A\\x5E-\\x7E]+$/.test(\n name,\n ),\n \"Invalid cookie name format - must contain only valid characters (letters, numbers, and certain symbols)\",\n );\n\n/**\n * Zod schema for cookie path validation.\n * Enforces standard cookie path rules according to RFC 6265.\n * @example\n * ```typescript\n * // Valid paths\n * CookiePathSchema.parse(\"/\"); // OK\n * CookiePathSchema.parse(\"/api\"); // OK\n * CookiePathSchema.parse(\"/path/to/page\"); // OK\n *\n * // Invalid paths\n * CookiePathSchema.parse(\"\"); // Error: Path cannot be empty\n * CookiePathSchema.parse(\"invalid\"); // Error: Path must start with /\n * CookiePathSchema.parse(\"/path?query\"); // Error: Invalid path format\n * ```\n */\nexport const CookiePathSchema = z\n .string()\n .trim()\n .min(1, \"Path cannot be empty\")\n .refine((path) => path.startsWith(\"/\"), \"Path must start with /\")\n .refine(\n (path) => /^\\/[!#$%&'()*+,\\-./:=@\\w]*$/.test(path),\n \"Invalid path format - must contain only valid URL path characters\",\n )\n .default(\"/\");\n\n/**\n * Zod schema for cookie value.\n * Attempts to parse JSON values using destr for better readability.\n */\nexport const CookieValueSchema = z\n .string()\n .trim()\n .transform((value) => destr(value))\n .pipe(z.any());\n\n/**\n * Zod schema for Safari binary cookie row.\n * Validates and enforces the structure of cookie data read from Safari's Cookies.binarycookies file.\n * @example\n * ```typescript\n * const cookieData = {\n * name: \"session\",\n * value: \"abc123\",\n * domain: \"example.com\",\n * path: \"/\",\n * expiry: 1735689600,\n * creation: 1672531200,\n * flags: 0x5, // Secure + HTTPOnly\n * };\n * const validCookie = BinaryCookieRowSchema.parse(cookieData);\n * ```\n */\nexport const BinaryCookieRowSchema = z.object({\n name: CookieNameSchema,\n value: CookieValueSchema,\n domain: CookieDomainSchema,\n path: CookiePathSchema,\n expiry: z.number().int(),\n creation: z.number().int(),\n flags: z.number().optional(),\n version: z.number().int().optional(),\n port: z.number().int().optional(),\n comment: z.string().optional(),\n commentURL: z.string().optional(),\n});\n\n/**\n * Type representing a decoded Safari binary cookie.\n * This type is inferred from the BinaryCookieRowSchema and includes all cookie properties.\n * @property name - The name of the cookie (non-empty string)\n * @property value - The value stored in the cookie\n * @property domain - The domain the cookie belongs to (non-empty string)\n * @property path - The path where the cookie is valid (defaults to \"/\")\n * @property expiry - Unix timestamp when the cookie expires\n * @property creation - Unix timestamp when the cookie was created\n * @property flags - Optional bit flags (e.g., Secure, HTTPOnly)\n * @property version - Optional cookie version number\n * @property port - Optional port number restriction\n * @property comment - Optional cookie comment\n * @property commentURL - Optional URL for the cookie's comment\n */\nexport type BinaryCookieRow = z.infer<typeof BinaryCookieRowSchema>;\n\n/**\n * Schema for cookie specification parameters\n * Defines the required fields for identifying a cookie\n * @example\n * ```typescript\n * // Validate a cookie specification\n * const spec = {\n * name: 'session',\n * domain: 'example.com'\n * };\n * const result = CookieSpecSchema.safeParse(spec);\n * if (result.success) {\n * console.log('Valid cookie spec:', result.data);\n * } else {\n * console.error('Invalid cookie spec:', result.error);\n * }\n *\n * // Invalid spec (empty name)\n * const invalidSpec = {\n * name: '',\n * domain: 'example.com'\n * };\n * // Throws: \"Cookie name cannot be empty\"\n * CookieSpecSchema.parse(invalidSpec);\n * ```\n */\nexport const CookieSpecSchema = z\n .object({\n name: CookieNameSchema,\n domain: CookieDomainSchema,\n })\n .strict();\n\n/**\n * Type definition for cookie specification\n * Used for specifying which cookie to query\n * @example\n * ```typescript\n * // Basic cookie spec\n * const spec: CookieSpec = {\n * name: 'auth',\n * domain: 'api.example.com'\n * };\n *\n * // Use in function parameters\n * function queryCookie(spec: CookieSpec): Promise<ExportedCookie[]> {\n * return getCookie(spec);\n * }\n *\n * // Array of specs\n * const specs: CookieSpec[] = [\n * { name: 'session', domain: 'app.example.com' },\n * { name: 'theme', domain: 'example.com' }\n * ];\n * ```\n */\nexport type CookieSpec = z.infer<typeof CookieSpecSchema>;\n\n/**\n * Schema for metadata about a cookie\n */\nexport const CookieMetaSchema = z\n .object({\n file: z.string().trim().min(1, \"File path cannot be empty\").optional(),\n browser: z.string().trim().optional(),\n decrypted: z.boolean().optional(),\n secure: z.boolean().optional(),\n httpOnly: z.boolean().optional(),\n path: CookiePathSchema.optional(),\n })\n .catchall(z.unknown())\n .strict();\n\n/**\n * Type definition for cookie metadata\n */\nexport type CookieMeta = z.infer<typeof CookieMetaSchema>;\n\n/**\n * Schema for exported cookie data\n * Represents a cookie with all its properties and metadata\n * @example\n * ```typescript\n * // Validate an exported cookie\n * const cookie = {\n * domain: 'example.com',\n * name: 'session',\n * value: 'abc123',\n * expiry: new Date('2024-12-31'),\n * meta: {\n * file: '/path/to/cookies.db'\n * }\n * };\n * const result = ExportedCookieSchema.safeParse(cookie);\n * if (result.success) {\n * console.log('Valid cookie:', result.data);\n * } else {\n * console.error('Invalid cookie:', result.error);\n * }\n *\n * // Cookie with infinite expiry\n * const infiniteCookie = {\n * ...cookie,\n * expiry: \"Infinity\"\n * };\n * ExportedCookieSchema.parse(infiniteCookie); // OK\n * ```\n */\nexport const ExportedCookieSchema = z\n .object({\n domain: CookieDomainSchema,\n name: CookieNameSchema,\n value: CookieValueSchema,\n expiry: z\n .union([\n z.literal(\"Infinity\"),\n z.date(),\n z.number().int().positive(\"Expiry must be a positive number\"),\n ])\n .optional(),\n meta: CookieMetaSchema.optional(),\n })\n .strict();\n\n/**\n * Type definition for exported cookie data\n * Represents the structure of a cookie after it has been retrieved\n * @example\n * ```typescript\n * // Basic exported cookie\n * const cookie: ExportedCookie = {\n * domain: 'example.com',\n * name: 'session',\n * value: 'abc123',\n * expiry: new Date('2024-12-31'),\n * meta: {\n * file: '/path/to/cookies.db'\n * }\n * };\n *\n * // Process exported cookies\n * function processCookies(cookies: ExportedCookie[]): string[] {\n * return cookies.map(cookie => `${cookie.name}=${cookie.value}`);\n * }\n *\n * // Filter expired cookies\n * function filterExpired(cookies: ExportedCookie[]): ExportedCookie[] {\n * const now = new Date();\n * return cookies.filter(cookie =>\n * cookie.expiry === \"Infinity\" ||\n * (cookie.expiry instanceof Date && cookie.expiry > now)\n * );\n * }\n * ```\n */\nexport type ExportedCookie = z.infer<typeof ExportedCookieSchema>;\n\n/**\n * Schema for raw cookie data from browser stores\n */\nexport const CookieRowSchema = z\n .object({\n expiry: z.number().int().optional(),\n domain: CookieDomainSchema,\n name: CookieNameSchema,\n value: z.union([z.string(), z.instanceof(Buffer)]),\n })\n .strict();\n\n/**\n * Type definition for raw cookie data\n */\nexport type CookieRow = z.infer<typeof CookieRowSchema>;\n\n/**\n * Schema for cookie render options\n */\nexport const RenderOptionsSchema = z\n .object({\n format: z.enum([\"merged\", \"grouped\"]).optional(),\n separator: z.string().optional(),\n showFilePaths: z.boolean().optional(),\n })\n .strict();\n\n/**\n * Type definition for render options\n */\nexport type RenderOptions = z.infer<typeof RenderOptionsSchema>;\n\n/**\n * Schema for browser names\n */\nexport const BrowserNameSchema = z.enum([\n \"Chrome\",\n \"Firefox\",\n \"Safari\",\n \"internal\",\n \"unknown\",\n]);\n\n/**\n * Type definition for browser names\n */\nexport type BrowserName = z.infer<typeof BrowserNameSchema>;\n\n/**\n * Schema for cookie query strategy\n */\nexport const CookieQueryStrategySchema = z\n .object({\n browserName: BrowserNameSchema,\n queryCookies: z\n .function()\n .args(z.string(), z.string())\n .returns(z.promise(z.array(ExportedCookieSchema))),\n })\n .strict();\n\n/**\n * Type definition for cookie query strategy\n */\nexport type CookieQueryStrategy = z.infer<typeof CookieQueryStrategySchema>;\n\n/**\n * Type representing either a single cookie specification or an array of specifications.\n * Useful when you need to query multiple cookies in a single operation.\n * @example\n * ```typescript\n * // Single cookie spec\n * const single: MultiCookieSpec = {\n * domain: \"example.com\",\n * name: \"sessionId\"\n * };\n *\n * // Multiple cookie specs\n * const multiple: MultiCookieSpec = [\n * { domain: \"example.com\", name: \"sessionId\" },\n * { domain: \"api.example.com\", name: \"authToken\" }\n * ];\n * ```\n */\nexport type MultiCookieSpec = CookieSpec | CookieSpec[];\n","import type { CookieSpec, ExportedCookie } from \"../../types/schemas\";\nimport { ChromeCookieQueryStrategy } from \"../browsers/chrome/ChromeCookieQueryStrategy\";\nimport { FirefoxCookieQueryStrategy } from \"../browsers/firefox/FirefoxCookieQueryStrategy\";\nimport { SafariCookieQueryStrategy } from \"../browsers/safari/SafariCookieQueryStrategy\";\n\n/**\n * Queries cookies from all available browser strategies (Chrome, Firefox, Safari).\n * This function acts as a unified interface to retrieve cookies across different browsers.\n * @param cookieSpec - The cookie specification to query\n * @param cookieSpec.name - The name pattern to match cookies against (can include '%' as wildcard)\n * @param cookieSpec.domain - The domain to match cookies against\n * @returns Promise resolving to array of exported cookies from all available browsers\n * @remarks\n * - Returns empty array if cookieSpec is invalid or missing required fields\n * - Aggregates results from all available browser strategies\n * - Failed browser queries are gracefully handled and excluded from results\n * - Both name and domain fields are required and must be strings\n * @example\n * ```typescript\n * const cookies = await queryCookies({\n * name: 'sessionId',\n * domain: 'example.com'\n * });\n * console.log(cookies); // Array of matching cookies from all browsers\n * ```\n */\nexport async function queryCookies(\n cookieSpec: CookieSpec,\n): Promise<ExportedCookie[]> {\n if (!cookieSpec.name || !cookieSpec.domain) {\n return [];\n }\n\n const { name, domain } = cookieSpec;\n if (typeof name !== \"string\" || typeof domain !== \"string\") {\n return [];\n }\n\n /**\n * Initialize all available browser-specific strategies\n * The order of strategies can affect performance but not functionality\n * Each strategy is responsible for its own error handling\n */\n const strategies = [\n new ChromeCookieQueryStrategy(),\n new FirefoxCookieQueryStrategy(),\n new SafariCookieQueryStrategy(),\n ];\n\n /**\n * Query all strategies in parallel and handle failures gracefully\n * Using Promise.allSettled ensures that failures in one strategy\n * don't prevent results from other strategies\n */\n const results = await Promise.allSettled(\n strategies.map((strategy) => strategy.queryCookies(name, domain)),\n );\n\n /**\n * Filter out failed promises and flatten successful results\n * Using PromiseFulfilledResult<ExportedCookie[]> ensures that only successful results are included\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 * This is the recommended way to import the function for most use cases.\n * @example\n * ```typescript\n * import queryCookies from './queryCookies';\n *\n * // Query cookies with specific name\n * const sessionCookies = await queryCookies({\n * name: 'sessionId',\n * domain: 'example.com'\n * });\n *\n * // Query all cookies for a domain using wildcard\n * const allCookies = await queryCookies({\n * name: '%',\n * domain: 'example.com'\n * });\n * ```\n */\nexport default queryCookies;\n","import type { CookieSpec, ExportedCookie } from \"../../types/schemas\";\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":"+HAAA,OAAS,QAAAA,MAAY,OCArB,OAAS,gBAAAC,MAAoB,KAC7B,OAAS,WAAAC,OAAe,KACxB,OAAS,QAAAC,OAAY,OCFrB,OAAOC,MAAW,QAClB,OAAS,KAAAC,MAAS,MAiBX,IAAMC,EAAqBD,EAC/B,OAAO,EACP,KAAK,EACL,IAAI,EAAG,wBAAwB,EAC/B,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KAAK,WAAW,EAChC,GAAI,OAAOA,GAAY,UAAYA,EAAQ,SAAW,EACpD,OAAO,QAAQ,QAAQ,CAAC,CAAC,EAG3B,IAAMG,EAAe,KAAK,gBAAgBH,CAAO,EACjD,OAAO,QAAQ,QAAQ,KAAK,cAAcG,EAAcC,EAAMC,CAAM,CAAC,CACvE,CACF,EGlGA,eAAsBI,EACpBC,EAC2B,CAC3B,GAAI,CAACA,EAAW,MAAQ,CAACA,EAAW,OAClC,MAAO,CAAC,EAGV,GAAM,CAAE,KAAAC,EAAM,OAAAC,CAAO,EAAIF,EACzB,GAAI,OAAOC,GAAS,UAAY,OAAOC,GAAW,SAChD,MAAO,CAAC,EAQV,IAAMC,EAAa,CACjB,IAAIC,EACJ,IAAIC,EACJ,IAAIC,CACN,EAeA,OARgB,MAAM,QAAQ,WAC5BH,EAAW,IAAKI,GAAaA,EAAS,aAAaN,EAAMC,CAAM,CAAC,CAClE,GAOG,OACEM,GACCA,EAAO,SAAW,WACtB,EACC,QAASA,GAAWA,EAAO,KAAK,CACrC,CCxCA,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,GAAQL","names":["join","readFileSync","homedir","join","destr","z","CookieDomainSchema","domain","CookieNameSchema","name","CookiePathSchema","path","CookieValueSchema","value","BinaryCookieRowSchema","CookieSpecSchema","CookieMetaSchema","ExportedCookieSchema","CookieRowSchema","RenderOptionsSchema","BrowserNameSchema","CookieQueryStrategySchema","_FILE_HEADER_MAGIC","_FILE_FOOTER","_SAFARI_DATE_OFFSET","readNullTerminatedString","buffer","offset","end","decodeCookieHeader","size","version","flags","hasPort","urlOffset","nameOffset","pathOffset","valueOffset","commentOffset","commentURLOffset","expiryDate","creationDate","currentOffset","port","offsets","a","b","fields","field","stringOffset","value","nextOffset","BinaryCookieRowSchema","decodePage","pageSize","headerLengthOffset","headerLength","cookies","pageEnd","cookie","error","decodeBinaryCookies","cookieDbPath","readFileSync","numPages","pageSizes","i","pageCookies","SafariCookieQueryStrategy","homeDir","logError","join","cookieDbPath","name","domain","decodeBinaryCookies","cookie","error","queryCookies","cookieSpec","name","domain","strategies","ChromeCookieQueryStrategy","FirefoxCookieQueryStrategy","SafariCookieQueryStrategy","strategy","result","getCookie","cookieSpec","queryCookies","error","logger_default","getCookie_default"]}
@@ -1,2 +0,0 @@
1
- import{groupBy as u}from"lodash-es";function d(n,s={}){let{format:o="merged",showFilePaths:a=!0,separator:i="; "}=s;if(n.length===0)return o==="merged"?"":[];if(o==="merged")return n.map(e=>e.value).join(i);let p=u(n,e=>{var t,r;return(r=(t=e.meta)==null?void 0:t.file)!=null?r:"unknown"});return Object.entries(p).map(([e,t])=>{let r=t.map(m=>m.value).join(i);return a?`${e}: ${r}`:r})}export{d as a};
2
- //# sourceMappingURL=chunk-YOZOS2YM.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/cookies/renderCookies.ts"],"sourcesContent":["import { groupBy } from \"lodash-es\";\n\nimport { ExportedCookie, RenderOptions } from \"../../types/schemas\";\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 as string).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 as string).join(separator);\n return showFilePaths ? `${file}: ${values}` : values;\n });\n}\n"],"mappings":"AAAA,OAAS,WAAAA,MAAe,YAgCjB,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,KAAe,EAAE,KAAKD,CAAS,EAG7D,IAAME,EAAgBR,EAAQE,EAAUK,GAAG,CA9C7C,IAAAE,EAAAC,EA8CgD,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,KAAe,EAAE,KAAKD,CAAS,EACvE,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"]}
@@ -1,2 +0,0 @@
1
- import{a as t}from"./chunk-7XZ7PCDJ.js";import"./chunk-DVWQBWUF.js";import{a as r}from"./chunk-56Z35D5R.js";import"./chunk-I6AYGFSQ.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 a=i;export{a as default,i as getChromeCookie};
2
- //# sourceMappingURL=getChromeCookie-2ROVM47V.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/cookies/getChromeCookie.ts"],"sourcesContent":["import type { CookieSpec, ExportedCookie } from \"../../types/schemas\";\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":"wIAwBA,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{c as i}from"./chunk-56Z35D5R.js";import"./chunk-I6AYGFSQ.js";import{memoize as l}from"lodash-es";import{exec as m}from"child_process";import{promisify as u}from"util";var f=u(m),o=class extends Error{constructor(n,e,s){super(n);this.command=e;this.originalError=s;this.name="CommandExecutionError"}};function d(t,r){if(t instanceof o)throw i("Command execution failed",t,{command:t.command,originalError:t.originalError}),t;if(t instanceof Error){let e=new o(t.message,r,t);throw i("Failed to execute command",t,{command:r,stack:t.stack}),e}let n=new o("Unknown error occurred during command execution",r);throw i("Failed to execute command",null,{error:t,command:r}),n}async function a(t,r={}){if(!t||typeof t!="string")throw new o("Command must be a non-empty string",t);let n={encoding:"utf8",maxBuffer:5*1024*1024,timeout:3e4};try{let{stdout:e,stderr:s}=await f(t,{...n,...r}),c=e.trim();if(!c)throw s?new o(`Command failed with stderr: ${s}`,t):new o("Command returned empty result",t);return c}catch(e){d(e,t)}}var g=async()=>a('security find-generic-password -w -s "Chrome Safe Storage"'),P=l(g);export{P as getChromePassword};
2
- //# sourceMappingURL=getChromePassword-O452VQWI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/browsers/chrome/macos/getChromePassword.ts","../src/utils/execSimple.ts"],"sourcesContent":["import { memoize } from \"lodash-es\";\n\nimport { execSimple } from \"@utils/execSimple\";\n\n/**\n * Retrieves the Chrome Safe Storage password from the macOS keychain\n * @returns A promise that resolves to the Chrome Safe Storage password\n * @throws {Error} If the password cannot be retrieved from the keychain\n */\nconst getChromeSafeStoragePassword = async (): Promise<string> => {\n const command = 'security find-generic-password -w -s \"Chrome Safe Storage\"';\n return execSimple(command);\n};\n\n/**\n * Memoized version of getChromeSafeStoragePassword that caches the result\n * to avoid repeated keychain queries\n * @returns A promise that resolves to the Chrome Safe Storage password\n * @throws {Error} If the password cannot be retrieved from the keychain\n * @example\n */\nexport const getChromePassword: () => Promise<string> = memoize(\n getChromeSafeStoragePassword,\n);\n","// External imports\nimport { exec, ExecOptions } from \"child_process\";\nimport { promisify } from \"util\";\n\n// Internal imports\nimport { logError } from \"@utils/logHelpers\";\n\nconst execPromise = promisify(exec);\n\n/**\n * Custom error class for command execution failures.\n * @property {string} command - The command that failed to execute\n * @property {Error} [originalError] - The underlying error that caused the failure\n * @throws CommandExecutionError Always throws with appropriate error context\n * @example\n * ```typescript\n * throw new CommandExecutionError(\n * 'Command timed out',\n * 'git status',\n * originalError\n * );\n * ```\n */\nclass CommandExecutionError extends Error {\n public constructor(\n message: string,\n public readonly command: string,\n public readonly originalError?: Error,\n ) {\n super(message);\n this.name = \"CommandExecutionError\";\n }\n}\n\n/**\n * Handles execution errors and throws appropriate CommandExecutionError.\n * @internal\n * @param error - The error that occurred during command execution\n * @param command - The command that was being executed when the error occurred\n * @throws CommandExecutionError Always throws with appropriate error context\n * @example\n * ```typescript\n * try {\n * await execPromise('invalid-command');\n * } catch (error) {\n * handleExecutionError(error, 'invalid-command');\n * }\n * ```\n */\nfunction handleExecutionError(error: unknown, command: string): never {\n if (error instanceof CommandExecutionError) {\n logError(\"Command execution failed\", error, {\n command: error.command,\n originalError: error.originalError,\n });\n throw error;\n }\n\n if (error instanceof Error) {\n const commandError = new CommandExecutionError(\n error.message,\n command,\n error,\n );\n logError(\"Failed to execute command\", error, {\n command,\n stack: error.stack,\n });\n throw commandError;\n }\n\n // Handle unknown error types\n const commandError = new CommandExecutionError(\n \"Unknown error occurred during command execution\",\n command,\n );\n logError(\"Failed to execute command\", null, {\n error,\n command,\n });\n throw commandError;\n}\n\n/**\n * Executes a shell command asynchronously and returns its output as a string.\n * @param command - The shell command to execute\n * @param options - Optional execution options that override the defaults\n * @returns A promise that resolves to the trimmed command output\n * @throws CommandExecutionError if the command returns an empty result, times out, or fails to execute\n * @example\n * ```typescript\n * // Basic usage\n * const gitStatus = await execSimple('git status');\n *\n * // With custom timeout\n * const output = await execSimple('long-running-command', { timeout: 60000 });\n *\n * // Error handling\n * try {\n * const result = await execSimple('git push');\n * } catch (error) {\n * if (error instanceof CommandExecutionError) {\n * console.error('Push failed:', error.message);\n * }\n * }\n * ```\n */\nexport async function execSimple(\n command: string,\n options: Partial<ExecOptions> = {},\n): Promise<string> {\n if (!command || typeof command !== \"string\") {\n throw new CommandExecutionError(\n \"Command must be a non-empty string\",\n command,\n );\n }\n\n const defaultOptions = {\n encoding: \"utf8\" as BufferEncoding,\n maxBuffer: 5 * 1024 * 1024, // 5MB buffer\n timeout: 30000, // 30 second timeout\n };\n\n try {\n const { stdout, stderr } = await execPromise(command, {\n ...defaultOptions,\n ...options,\n });\n const result = stdout.trim();\n\n if (!result) {\n if (stderr) {\n throw new CommandExecutionError(\n `Command failed with stderr: ${stderr}`,\n command,\n );\n }\n throw new CommandExecutionError(\"Command returned empty result\", command);\n }\n\n return result;\n } catch (error) {\n handleExecutionError(error, command);\n }\n}\n"],"mappings":"oEAAA,OAAS,WAAAA,MAAe,YCCxB,OAAS,QAAAC,MAAyB,gBAClC,OAAS,aAAAC,MAAiB,OAK1B,IAAMC,EAAcC,EAAUC,CAAI,EAgB5BC,EAAN,cAAoC,KAAM,CACjC,YACLC,EACgBC,EACAC,EAChB,CACA,MAAMF,CAAO,EAHG,aAAAC,EACA,mBAAAC,EAGhB,KAAK,KAAO,uBACd,CACF,EAiBA,SAASC,EAAqBC,EAAgBH,EAAwB,CACpE,GAAIG,aAAiBL,EACnB,MAAAM,EAAS,2BAA4BD,EAAO,CAC1C,QAASA,EAAM,QACf,cAAeA,EAAM,aACvB,CAAC,EACKA,EAGR,GAAIA,aAAiB,MAAO,CAC1B,IAAME,EAAe,IAAIP,EACvBK,EAAM,QACNH,EACAG,CACF,EACA,MAAAC,EAAS,4BAA6BD,EAAO,CAC3C,QAAAH,EACA,MAAOG,EAAM,KACf,CAAC,EACKE,CACR,CAGA,IAAMA,EAAe,IAAIP,EACvB,kDACAE,CACF,EACA,MAAAI,EAAS,4BAA6B,KAAM,CAC1C,MAAAD,EACA,QAAAH,CACF,CAAC,EACKK,CACR,CA0BA,eAAsBC,EACpBN,EACAO,EAAgC,CAAC,EAChB,CACjB,GAAI,CAACP,GAAW,OAAOA,GAAY,SACjC,MAAM,IAAIF,EACR,qCACAE,CACF,EAGF,IAAMQ,EAAiB,CACrB,SAAU,OACV,UAAW,EAAI,KAAO,KACtB,QAAS,GACX,EAEA,GAAI,CACF,GAAM,CAAE,OAAAC,EAAQ,OAAAC,CAAO,EAAI,MAAMf,EAAYK,EAAS,CACpD,GAAGQ,EACH,GAAGD,CACL,CAAC,EACKI,EAASF,EAAO,KAAK,EAE3B,GAAI,CAACE,EACH,MAAID,EACI,IAAIZ,EACR,+BAA+BY,CAAM,GACrCV,CACF,EAEI,IAAIF,EAAsB,gCAAiCE,CAAO,EAG1E,OAAOW,CACT,OAASR,EAAO,CACdD,EAAqBC,EAAOH,CAAO,CACrC,CACF,CDxIA,IAAMY,EAA+B,SAE5BC,EADS,4DACS,EAUdC,EAA2CC,EACtDH,CACF","names":["memoize","exec","promisify","execPromise","promisify","exec","CommandExecutionError","message","command","originalError","handleExecutionError","error","logError","commandError","execSimple","options","defaultOptions","stdout","stderr","result","getChromeSafeStoragePassword","execSimple","getChromePassword","memoize"]}
@@ -1,2 +0,0 @@
1
- import{b as a,c as b}from"./chunk-U27I5BLR.js";import"./chunk-7XZ7PCDJ.js";import"./chunk-3FVH4L25.js";import"./chunk-DVWQBWUF.js";import"./chunk-56Z35D5R.js";import"./chunk-I6AYGFSQ.js";export{b as default,a as getCookie};
2
- //# sourceMappingURL=getCookie-CRE6M3GI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,2 +0,0 @@
1
- import{a as t}from"./chunk-3FVH4L25.js";import"./chunk-DVWQBWUF.js";import{a as r}from"./chunk-56Z35D5R.js";import"./chunk-I6AYGFSQ.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 c=i;export{c as default,i as getFirefoxCookie};
2
- //# sourceMappingURL=getFirefoxCookie-5P74VDC7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/cookies/getFirefoxCookie.ts"],"sourcesContent":["import type { CookieSpec, ExportedCookie } from \"../../types/schemas\";\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":"wIAwBA,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 n}from"./chunk-YOZOS2YM.js";import{a as t,b as i}from"./chunk-U27I5BLR.js";import"./chunk-7XZ7PCDJ.js";import"./chunk-3FVH4L25.js";import"./chunk-DVWQBWUF.js";import{a as e}from"./chunk-56Z35D5R.js";import"./chunk-I6AYGFSQ.js";async function c(s,a={}){try{let r=await i(s);if(!Array.isArray(r))return[];let m=r.filter(p=>{let o=t.safeParse(p);return o.success?!0:(e.warn("Invalid cookie format:",o.error.format()),!1)});return n(m,{...a,format:"grouped"})}catch(r){return e.warn("Error getting grouped rendered cookies:",r instanceof Error?r.message:String(r)),[]}}var g=c;export{g as default,c as getGroupedRenderedCookies};
2
- //# sourceMappingURL=getGroupedRenderedCookies-DFEJTTC6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/cookies/getGroupedRenderedCookies.ts"],"sourcesContent":["import type {\n RenderOptions,\n CookieSpec,\n ExportedCookie,\n} from \"../../types/schemas\";\nimport { ExportedCookieSchema } from \"../../types/schemas\";\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 if (!Array.isArray(cookies)) {\n return [];\n }\n\n // Validate each cookie against the schema\n const validatedCookies = cookies.filter(\n (cookie): cookie is ExportedCookie => {\n const result = ExportedCookieSchema.safeParse(cookie);\n if (!result.success) {\n logger.warn(\"Invalid cookie format:\", result.error.format());\n return false;\n }\n return true;\n },\n );\n\n return renderCookies(validatedCookies, {\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":"+OAsCA,eAAsBA,EACpBC,EACAC,EAAyC,CAAC,EACvB,CACnB,GAAI,CACF,IAAMC,EAAU,MAAMC,EAAUH,CAAU,EAC1C,GAAI,CAAC,MAAM,QAAQE,CAAO,EACxB,MAAO,CAAC,EAIV,IAAME,EAAmBF,EAAQ,OAC9BG,GAAqC,CACpC,IAAMC,EAASC,EAAqB,UAAUF,CAAM,EACpD,OAAKC,EAAO,QAIL,IAHLE,EAAO,KAAK,yBAA0BF,EAAO,MAAM,OAAO,CAAC,EACpD,GAGX,CACF,EAEA,OAAOG,EAAcL,EAAkB,CACrC,GAAGH,EACH,OAAQ,SACV,CAAC,CACH,OAASS,EAAgB,CACvB,OAAAF,EAAO,KACL,0CACAE,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CACvD,EACO,CAAC,CACV,CACF,CAqBA,IAAOC,EAAQZ","names":["getGroupedRenderedCookies","cookieSpec","options","cookies","getCookie","validatedCookies","cookie","result","ExportedCookieSchema","logger_default","renderCookies","error","getGroupedRenderedCookies_default"]}
@@ -1,2 +0,0 @@
1
- import{a as s}from"./chunk-YOZOS2YM.js";import{a as i,b as n}from"./chunk-U27I5BLR.js";import"./chunk-7XZ7PCDJ.js";import"./chunk-3FVH4L25.js";import"./chunk-DVWQBWUF.js";import{a as r}from"./chunk-56Z35D5R.js";import"./chunk-I6AYGFSQ.js";async function d(a,m){try{let e=await n(a);if(!Array.isArray(e))return"";let c=e.filter(f=>{let t=i.safeParse(f);return t.success?!0:(r.warn("Invalid cookie format:",t.error.format()),!1)}),o=s(c,{...m,format:"merged"});return typeof o=="string"?o:""}catch(e){return r.warn("Error getting merged rendered cookies:",e instanceof Error?e.message:String(e)),""}}var C=d;export{C as default,d as getMergedRenderedCookies};
2
- //# sourceMappingURL=getMergedRenderedCookies-W5GSSHQQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/cookies/getMergedRenderedCookies.ts"],"sourcesContent":["import type {\n RenderOptions,\n CookieSpec,\n ExportedCookie,\n} from \"../../types/schemas\";\nimport { ExportedCookieSchema } from \"../../types/schemas\";\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 to query\n * @param options - Optional rendering options\n * @returns Promise resolving to rendered cookie string\n * @example\n * ```typescript\n * const cookieString = await getMergedRenderedCookies(\n * { name: 'session', domain: 'example.com' },\n * { separator: '; ' }\n * );\n * console.log(cookieString); // \"session=abc123; auth=xyz789\"\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 if (!Array.isArray(cookies)) {\n return \"\";\n }\n\n // Validate each cookie against the schema\n const validatedCookies = cookies.filter(\n (cookie): cookie is ExportedCookie => {\n const result = ExportedCookieSchema.safeParse(cookie);\n if (!result.success) {\n logger.warn(\"Invalid cookie format:\", result.error.format());\n return false;\n }\n return true;\n },\n );\n\n const result = renderCookies(validatedCookies, {\n ...options,\n format: \"merged\",\n });\n return typeof result === \"string\" ? result : \"\";\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":"+OAyBA,eAAsBA,EACpBC,EACAC,EACiB,CACjB,GAAI,CACF,IAAMC,EAAU,MAAMC,EAAUH,CAAU,EAC1C,GAAI,CAAC,MAAM,QAAQE,CAAO,EACxB,MAAO,GAIT,IAAME,EAAmBF,EAAQ,OAC9BG,GAAqC,CACpC,IAAMC,EAASC,EAAqB,UAAUF,CAAM,EACpD,OAAKC,EAAO,QAIL,IAHLE,EAAO,KAAK,yBAA0BF,EAAO,MAAM,OAAO,CAAC,EACpD,GAGX,CACF,EAEMA,EAASG,EAAcL,EAAkB,CAC7C,GAAGH,EACH,OAAQ,QACV,CAAC,EACD,OAAO,OAAOK,GAAW,SAAWA,EAAS,EAC/C,OAASI,EAAgB,CACvB,OAAAF,EAAO,KACL,yCACAE,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CACvD,EACO,EACT,CACF,CAaA,IAAOC,EAAQZ","names":["getMergedRenderedCookies","cookieSpec","options","cookies","getCookie","validatedCookies","cookie","result","ExportedCookieSchema","logger_default","renderCookies","error","getMergedRenderedCookies_default"]}