@mherod/get-cookie 4.0.2 → 4.0.4

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 (50) hide show
  1. package/.husky/commit-msg +0 -0
  2. package/.husky/pre-commit +0 -0
  3. package/.husky/pre-push +0 -0
  4. package/.idea/prettier.xml +2 -1
  5. package/dist/chunk-A6MIB6FP.js +2 -0
  6. package/dist/chunk-A6MIB6FP.js.map +1 -0
  7. package/dist/chunk-CFMK2YSL.js +2 -0
  8. package/dist/chunk-CFMK2YSL.js.map +1 -0
  9. package/dist/chunk-IRERRCUF.js +2 -0
  10. package/dist/chunk-IRERRCUF.js.map +1 -0
  11. package/dist/chunk-UPNW543B.js +2 -0
  12. package/dist/chunk-UPNW543B.js.map +1 -0
  13. package/dist/cli.cjs +3 -4
  14. package/dist/cli.cjs.map +1 -1
  15. package/dist/{getChromeCookie-4ZWACG6M.js → getChromeCookie-CL3SRRWX.js} +2 -2
  16. package/dist/getChromeCookie-CL3SRRWX.js.map +1 -0
  17. package/dist/getCookie-WV5KDZN7.js +2 -0
  18. package/dist/getFirefoxCookie-BXQ2GXAW.js +2 -0
  19. package/dist/getFirefoxCookie-BXQ2GXAW.js.map +1 -0
  20. package/dist/getGroupedRenderedCookies-FNJ6FQVQ.js +2 -0
  21. package/dist/getGroupedRenderedCookies-FNJ6FQVQ.js.map +1 -0
  22. package/dist/getMergedRenderedCookies-PNC2LHSD.js +2 -0
  23. package/dist/getMergedRenderedCookies-PNC2LHSD.js.map +1 -0
  24. package/dist/index.cjs +3 -3
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +164 -152
  27. package/dist/index.d.ts +164 -152
  28. package/dist/index.js +1 -1
  29. package/dist/index.js.map +1 -1
  30. package/eslint.config.js +2 -1
  31. package/package.json +23 -19
  32. package/typedoc.json +3 -8
  33. package/dist/chunk-5ZT2G45S.js +0 -2
  34. package/dist/chunk-5ZT2G45S.js.map +0 -1
  35. package/dist/chunk-FR2MKDHT.js +0 -2
  36. package/dist/chunk-FR2MKDHT.js.map +0 -1
  37. package/dist/chunk-HMKSQBDC.js +0 -2
  38. package/dist/chunk-HMKSQBDC.js.map +0 -1
  39. package/dist/chunk-W3JALMAX.js +0 -2
  40. package/dist/chunk-W3JALMAX.js.map +0 -1
  41. package/dist/getChromeCookie-4ZWACG6M.js.map +0 -1
  42. package/dist/getCookie-43FKMQEZ.js +0 -2
  43. package/dist/getFirefoxCookie-OJYYZFZP.js +0 -2
  44. package/dist/getFirefoxCookie-OJYYZFZP.js.map +0 -1
  45. package/dist/getGroupedRenderedCookies-P5VZXZUC.js +0 -2
  46. package/dist/getGroupedRenderedCookies-P5VZXZUC.js.map +0 -1
  47. package/dist/getMergedRenderedCookies-C6TXK2I4.js +0 -2
  48. package/dist/getMergedRenderedCookies-C6TXK2I4.js.map +0 -1
  49. package/tsup.config.ts +0 -27
  50. /package/dist/{getCookie-43FKMQEZ.js.map → getCookie-WV5KDZN7.js.map} +0 -0
@@ -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 +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,b}from"./chunk-W3JALMAX.js";import"./chunk-5ZT2G45S.js";import"./chunk-HMKSQBDC.js";import"./chunk-5FUMK7M3.js";import"./chunk-56Z35D5R.js";import"./chunk-VMBA4NVU.js";export{b as default,a as getCookie};
2
- //# sourceMappingURL=getCookie-43FKMQEZ.js.map
@@ -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
- });