@mherod/get-cookie 1.2.0 → 2.0.0-beta.1

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.
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;AIAe;IACb,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE;QAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EACxC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAE3C,OAAO,EAAE,CAAC;KACX;CACF;;ADPD;AEEA;;AAIO,eAAe,yCAAU,CAAC,OAAO,EAAE;IACxC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAC7B,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;IAE9D,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EACrB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,GAAK;QACtC,CAAA,GAAA,yBAAI,CAAA,CACF,OAAO,EACP;YAAE,QAAQ,EAAE,QAAQ;YAAE,SAAS,EAAE,IAAQ;SAAE,EAC3C,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAK;YACzB,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,KAAK,CAAC,CAAC;gBACd,OAAO;aACR;YACD,IAAI,MAAM,EAAE;gBACV,MAAM,CAAC,KAAK,CAAC,CAAC;gBACd,OAAO;aACR;YACD,IAAI,MAAM,EACR,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;SAE3C,CACF,CAAC;KACH,CAAC,CAAC;CACJ;AAEM,eAAe,yCAAY,CAAC,OAAO,EAAE;IAC1C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAC7B,MAAM,IAAI,SAAS,C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,CAAA,GAAA,wCAA0B,CAAA,EAAE,CAEjC,AAAC;IACF,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,GAAK,MAAM,IAAI,IAAI,CAAC,CAAC;SAEhD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;CAEvC;AAOM,eAAe,yCAAe,CAAC,MAAM,EAAE;IAC5C,MAAM,OAAO,GAAG,MAAM,CAAA,GAAA,yCAAY,CAAA,CAChC,MAAM,EACN,IAAI,CAAA,GAAA,wCAAyB,CAAA,EAAE,CAEhC,AAAC;IACF,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,GAAK,MAAM,IAAI,IAAI,CAAC,CAAC;SAEhD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;CAEvC","sources":["src/index.js","src/queryCookies.js","src/browsers/CompositeCookieQueryStrategy.js","src/browsers/ChromeCookieQueryStrategy.js","src/browsers/AbstractCookieQueryStrategy.js","src/utils.js","src/global.js","src/findAllFiles.js","src/browsers/FirefoxCookieQueryStrategy.js","src/browsers/SafariCookieQueryStrategy.js","src/isValidJwt.js"],"sourcesContent":["#!/usr/bin/env node\n// noinspection JSUnusedGlobalSymbols\n\nimport { queryCookies } from \"./queryCookies\";\nimport FirefoxCookieQueryStrategy from \"./browsers/FirefoxCookieQueryStrategy\";\nimport ChromeCookieQueryStrategy from \"./browsers/ChromeCookieQueryStrategy\";\nimport CompositeCookieQueryStrategy from \"./browsers/CompositeCookieQueryStrategy\";\n\n/**\n *\n * @param params\n * @returns {Promise<string>}\n */\nexport async function getCookie(params) {\n const cookies = await queryCookies(\n params,\n new CompositeCookieQueryStrategy()\n //\n );\n if (Array.isArray(cookies) && cookies.length > 0) {\n return cookies.find((cookie) => cookie != null);\n } else {\n throw new Error(\"Cookie not found\");\n }\n}\n\n/**\n *\n * @param params\n * @returns {Promise<*>}\n */\nexport async function getFirefoxCookie(params) {\n const cookies = await queryCookies(\n params,\n new FirefoxCookieQueryStrategy()\n //\n );\n if (Array.isArray(cookies) && cookies.length > 0) {\n return cookies.find((cookie) => cookie != null);\n } else {\n throw new Error(\"Cookie not found\");\n }\n}\n\n/**\n *\n * @param params\n * @returns {Promise<*>}\n */\nexport async function getChromeCookie(params) {\n const cookies = await queryCookies(\n params,\n new ChromeCookieQueryStrategy()\n //\n );\n if (Array.isArray(cookies) && cookies.length > 0) {\n return cookies.find((cookie) => cookie != null);\n } else {\n throw new Error(\"Cookie not found\");\n }\n}\n","import CompositeCookieQueryStrategy from \"./browsers/CompositeCookieQueryStrategy\";\nimport { uniq } from \"lodash\";\nimport { env } from \"./global\";\nimport isValidJwt from \"./isValidJwt\";\n\nexport async function queryCookies(\n { name, domain },\n strategy = new CompositeCookieQueryStrategy()\n) {\n const results = await strategy.queryCookies(name, domain);\n const results1 = uniq(results).map((cookie) => {\n return {\n name: name,\n domain: domain,\n value: cookie,\n };\n });\n const jwtCookies = [];\n for (const result of results1) {\n const value = result.value;\n if (isValidJwt(value)) {\n jwtCookies.push(result);\n }\n }\n const results2 = env.REQUIRE_JWT ? jwtCookies : results1;\n const resultsUniq = uniq(results2).map((cookie) => cookie.value);\n return env.SINGLE ? [resultsUniq[0]] : resultsUniq;\n}\n","import ChromeCookieQueryStrategy from \"./ChromeCookieQueryStrategy\";\nimport FirefoxCookieQueryStrategy from \"./FirefoxCookieQueryStrategy\";\nimport SafariCookieQueryStrategy from \"./SafariCookieQueryStrategy\";\nimport AbstractCookieQueryStrategy from \"./AbstractCookieQueryStrategy\";\n\nexport default class CompositeCookieQueryStrategy extends AbstractCookieQueryStrategy {\n #strategies;\n\n constructor() {\n super();\n this.#strategies = [\n ChromeCookieQueryStrategy,\n FirefoxCookieQueryStrategy,\n SafariCookieQueryStrategy,\n ].map((strategy) => {\n return new strategy();\n });\n }\n\n async queryCookies(name, domain) {\n const results = await Promise.all(\n this.#strategies.map(async (strategy) => {\n return strategy.queryCookies(name, domain).catch(() => []);\n })\n );\n return results.flat();\n }\n}\n","import AbstractCookieQueryStrategy from \"./AbstractCookieQueryStrategy\";\nimport {\n doSqliteQuery1,\n execSimple,\n invalidString,\n toStringOrNull,\n toStringValue,\n} from \"../utils\";\nimport { env, HOME } from \"../global\";\nimport { existsSync } from \"fs\";\nimport { findAllFiles } from \"../findAllFiles\";\nimport crypto from \"crypto\";\nimport * as path from \"path\";\n\nexport default class ChromeCookieQueryStrategy extends AbstractCookieQueryStrategy {\n async queryCookies(name, domain) {\n if (process.platform !== \"darwin\") {\n throw new Error(\"This only works on macOS\");\n }\n if (env.FIREFOX_ONLY) {\n return [];\n }\n const cookies = await getChromeCookies({ name, domain });\n return cookies.map(toStringValue);\n }\n}\n\nasync function getPromise1(name, domain, file) {\n try {\n return await getEncryptedChromeCookie({\n name: name,\n domain: domain,\n file: file,\n });\n } catch (e) {\n if (env.VERBOSE) {\n console.log(\"Error getting encrypted cookie\", e);\n }\n return [];\n }\n}\n\nasync function getPromise(name, domain) {\n try {\n const files = await findAllFiles({\n path: chromeLocal,\n name: \"Cookies\",\n });\n const promises = files.map((file) => getPromise1(name, domain, file));\n const results1 = await Promise.all(promises);\n const results2 = results1.flat();\n if (env.VERBOSE) {\n console.log(\"getEncryptedChromeCookie results\", results2);\n }\n return results2.filter((result) => result);\n } catch (error) {\n if (env.VERBOSE) {\n console.log(\"error\", error);\n }\n return [];\n }\n}\n\n/**\n *\n * @param {string|undefined} name\n * @param {string} domain\n * @param {boolean} requireJwt\n * @returns {Promise<[string]>}\n */\nasync function getChromeCookies({ name, domain = \"%\", requireJwt = false }) {\n if (invalidString(name)) {\n throw new Error(\"name must be a string\");\n }\n if (invalidString(domain)) {\n throw new Error(\"domain must be a string\");\n }\n const encryptedDataItems = await getPromise(name, domain);\n const password = await getChromePassword();\n const decrypted = encryptedDataItems\n .filter((encryptedData) => {\n return encryptedData != null && encryptedData.length > 0;\n })\n .map(async (encryptedData) => {\n if (env.VERBOSE) {\n console.log(\"Received encrypted\", encryptedData);\n }\n let d;\n try {\n d = await decrypt(password, encryptedData);\n } catch (e) {\n if (env.VERBOSE) {\n console.log(\"Error decrypting cookie\", e);\n }\n return null;\n }\n if (d) {\n if (env.VERBOSE) {\n console.log(\"Decrypted\", d);\n }\n return d;\n }\n return null;\n });\n const results = await Promise.all(decrypted);\n if (env.VERBOSE) {\n console.log(\"results\", results);\n }\n return results.map(toStringOrNull);\n}\n\nconst chromeLocal = path.join(\n HOME,\n \"Library\",\n \"Application Support\",\n \"Google\",\n \"Chrome\"\n);\n\nasync function getEncryptedChromeCookie({\n name,\n domain,\n file = path.join(chromeLocal, \"Default\", \"Cookies\"),\n}) {\n if (name && typeof name !== \"string\") {\n throw new Error(\"name must be a string\");\n }\n if (domain && typeof domain !== \"string\") {\n throw new Error(\"domain must be a string\");\n }\n if (file && typeof file !== \"string\") {\n throw new Error(\"file must be a string\");\n }\n if (!existsSync(file)) {\n throw new Error(`File ${file} does not exist`);\n }\n if (env.VERBOSE) {\n const s = file.split(\"/\").slice(-3).join(\"/\");\n console.log(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);\n }\n let sql;\n sql = `SELECT encrypted_value FROM cookies`;\n if (typeof name === \"string\" || typeof domain === \"string\") {\n sql += ` WHERE `;\n if (typeof name === \"string\") {\n sql += `name = '${name}'`;\n if (typeof domain === \"string\") {\n sql += ` AND `;\n }\n }\n if (typeof domain === \"string\") {\n sql += `host_key LIKE '${domain}';`;\n }\n }\n return doSqliteQuery1(file, sql);\n}\n\n/**\n *\n * @returns {Promise<string>}\n */\nasync function getChromePassword() {\n return execSimple(\n 'security find-generic-password -w -s \"Chrome Safe Storage\"'\n );\n}\n\n/**\n *\n * @param {string} password\n * @param {Buffer} encryptedData\n * @returns {Promise<string>}\n */\nasync function decrypt(password, encryptedData) {\n if (typeof password !== \"string\") {\n throw new Error(\"password must be a string: \" + password);\n }\n let encryptedData1;\n encryptedData1 = encryptedData;\n if (encryptedData1 == null || typeof encryptedData1 !== \"object\") {\n throw new Error(\"encryptedData must be a object: \" + encryptedData1);\n }\n if (!(encryptedData1 instanceof Buffer)) {\n if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {\n [encryptedData1] = encryptedData1;\n if (env.VERBOSE) {\n console.log(\n `encryptedData is an array of buffers, selected first: ${encryptedData1}`\n );\n }\n } else {\n throw new Error(\"encryptedData must be a Buffer: \" + encryptedData1);\n }\n encryptedData1 = Buffer.from(encryptedData1);\n }\n if (env.VERBOSE) {\n console.log(`Trying to decrypt with password ${password}`);\n }\n return new Promise((resolve, reject) => {\n crypto.pbkdf2(password, \"saltysalt\", 1003, 16, \"sha1\", (error, buffer) => {\n try {\n if (error) {\n if (env.VERBOSE) {\n console.log(\"Error doing pbkdf2\", error);\n }\n reject(error);\n return;\n }\n\n if (buffer.length !== 16) {\n if (env.VERBOSE) {\n console.log(\n \"Error doing pbkdf2, buffer length is not 16\",\n buffer.length\n );\n }\n reject(new Error(\"Buffer length is not 16\"));\n return;\n }\n\n const iv = new Buffer.from(new Array(17).join(\" \"), \"binary\");\n const decipher = crypto.createDecipheriv(\"aes-128-cbc\", buffer, iv);\n decipher.setAutoPadding(false);\n\n if (encryptedData1 && encryptedData1.slice) {\n encryptedData1 = encryptedData1.slice(3);\n }\n\n if (encryptedData1.length % 16 !== 0) {\n if (env.VERBOSE) {\n console.log(\n \"Error doing pbkdf2, encryptedData length is not a multiple of 16\",\n encryptedData1.length\n );\n }\n reject(new Error(\"encryptedData length is not a multiple of 16\"));\n return;\n }\n\n let decoded = decipher.update(encryptedData1);\n try {\n decipher.final(\"utf-8\");\n } catch (e) {\n if (env.VERBOSE) {\n console.log(\"Error doing decipher.final()\", e);\n }\n reject(e);\n return;\n }\n\n const padding = decoded[decoded.length - 1];\n if (padding) {\n decoded = decoded.slice(0, 0 - padding);\n }\n // noinspection JSCheckFunctionSignatures\n decoded = decoded.toString(\"utf8\");\n resolve(decoded);\n } catch (e) {\n reject(e);\n }\n });\n });\n}\n","export default class AbstractCookieQueryStrategy {\n async queryCookies(name, domain) {\n if (process.env.NODE_ENV === \"development\") {\n console.log(\"queryCookie\", name, domain);\n }\n return [];\n }\n}\n","// noinspection JSUnusedGlobalSymbols\n\nimport { exec } from \"child_process\";\n\nimport fs from \"fs\";\n\nexport async function execSimple(command) {\n if (typeof command !== \"string\") {\n throw new TypeError(\"execSimple: command must be a string\");\n }\n if (process.env.VERBOSE) {\n console.log(command);\n }\n return new Promise((resolve, reject) => {\n exec(\n command,\n { encoding: \"binary\", maxBuffer: 5 * 1024 },\n (error, stdout, stderr) => {\n if (error) {\n reject(error);\n return;\n }\n if (stderr) {\n reject(error);\n return;\n }\n if (stdout) {\n resolve(stdout.toString(\"utf8\").trim());\n }\n }\n );\n });\n}\n\nexport async function execAsBuffer(command) {\n if (typeof command !== \"string\") {\n throw new TypeError(\"execAsBuffer: command must be a string\");\n }\n if (process.env.VERBOSE) {\n console.log(command);\n }\n return await new Promise((resolve, reject) => {\n exec(\n command,\n { encoding: \"binary\", maxBuffer: 5 * 1024 },\n (error, stdout, stderr) => {\n if (error) {\n reject(error);\n return;\n }\n if (stderr) {\n reject(error);\n return;\n }\n let stdoutAsBuffer = stdout;\n if (typeof stdoutAsBuffer === \"string\" && stdoutAsBuffer.length > 0) {\n // noinspection JSCheckFunctionSignatures\n stdoutAsBuffer = Buffer.from(stdoutAsBuffer, \"binary\").slice(0, -1);\n }\n if (stdoutAsBuffer && stdoutAsBuffer.length > 0) {\n resolve(stdoutAsBuffer);\n }\n }\n );\n });\n}\n\nexport function toStringValue(r) {\n if (process.env.VERBOSE) {\n console.log(\"Printing value\", r);\n }\n if (r) {\n if (typeof r === \"string\") {\n return r;\n } else if (r.toString) {\n // noinspection JSCheckFunctionSignatures\n return r.toString(\"utf8\");\n }\n }\n}\n\nexport function printStringValue(r) {\n if (process.env.VERBOSE) {\n console.log(\"Printing value\", r);\n }\n if (r) {\n if (typeof r === \"string\") {\n console.log(r);\n } else if (r.toString) {\n // noinspection JSCheckFunctionSignatures\n console.log(r.toString(\"utf8\"));\n }\n }\n}\n\n/**\n *\n * @param result\n * @returns {string|null}\n */\nexport function toStringOrNull(result) {\n if (result == null) {\n return null;\n }\n if (process.env.VERBOSE) {\n console.log(\"result\", result);\n }\n if (typeof result === \"string\" && result.length > 0) {\n return result;\n }\n if (result.slice && result.toString) {\n // noinspection JSCheckFunctionSignatures\n return result.toString(\"utf8\");\n }\n return null;\n}\n\n/**\n *\n * @param {string} file\n * @param {string} sql\n * @returns {Promise<Buffer[]>}\n */\nexport async function doSqliteQuery1(file, sql) {\n if (typeof sql !== \"string\") {\n throw new TypeError(\"doSqliteQuery1: sql must be a string\");\n }\n if (typeof file !== \"string\") {\n throw new TypeError(\"doSqliteQuery1: file must be a string\");\n }\n if (!fs.existsSync(file)) {\n throw new Error(`doSqliteQuery1: file ${file} does not exist`);\n }\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: file ${file}`);\n console.log(`doSqliteQuery1: sql ${sql}`);\n }\n const sqlite3 = require(\"sqlite3\");\n const db = new sqlite3.Database(file);\n return new Promise((resolve, reject) => {\n db.all(sql, (err, rows) => {\n if (err) {\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: error ${err}`);\n }\n reject(err);\n return;\n }\n const rows1 = rows;\n if (rows1 == null || rows1.length === 0) {\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: no rows`);\n }\n resolve([]);\n return;\n }\n if (Array.isArray(rows1)) {\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: ${rows1.length} rows`);\n }\n // noinspection JSCheckFunctionSignatures\n const buffers = rows1\n .flatMap((row) => Object.values(row))\n .map((v) => Buffer.from(v, \"binary\"));\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: ${buffers.length} buffers`);\n }\n resolve(buffers);\n return;\n }\n if (process.env.VERBOSE) {\n console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);\n }\n resolve([rows1]);\n });\n });\n}\n\nexport function invalidString(input) {\n return typeof input !== \"string\" || input.length === 0;\n}\n","const { merge } = require(\"lodash\");\nexport const env = {};\nmerge(env, process.env);\nexport const HOME = env[\"HOME\"];\nif (!HOME) {\n throw new Error(\"HOME environment variable is not set\");\n}\n","import { env } from \"./global\";\nimport fs from \"fs\";\n\n/**\n *\n * @param path\n * @param name\n * @param rootSegments\n * @param maxDepth\n * @returns {Promise<[string]>}\n */\nexport async function findAllFiles({ path, name, maxDepth = 2 }) {\n if (typeof path !== \"string\") {\n throw new Error(\"path must be a string\");\n }\n if (typeof name !== \"string\") {\n throw new Error(\"name must be a string\");\n }\n\n const rootSegments = path.split(\"/\").length;\n\n if (env.VERBOSE) {\n console.log(`Searching for ${name} in ${path}`);\n }\n const files = [];\n let readdirSync;\n try {\n readdirSync = fs.readdirSync(path);\n } catch (e) {\n if (env.VERBOSE) {\n console.log(`Error reading ${path}`, e);\n }\n return files;\n }\n for (const file of readdirSync) {\n const filePath = path + \"/\" + file;\n let stat;\n try {\n stat = fs.statSync(filePath);\n } catch (e) {\n if (env.VERBOSE) {\n console.error(`Error getting stat for ${filePath}`, e);\n }\n continue;\n }\n if (stat.isDirectory()) {\n if (filePath.split(\"/\").length < rootSegments + maxDepth) {\n try {\n const subFiles = await findAllFiles({\n path: filePath,\n name: name,\n rootSegments: rootSegments,\n maxDepth: 2,\n });\n files.push(...subFiles);\n } catch (e) {\n if (env.VERBOSE) {\n console.error(e);\n }\n }\n }\n } else if (file === name) {\n files.push(filePath);\n }\n }\n if (env.VERBOSE) {\n if (files.length > 0) {\n console.log(`Found ${files.length} ${name} files`);\n console.log(files);\n }\n }\n return files;\n}\n","import AbstractCookieQueryStrategy from \"./AbstractCookieQueryStrategy\";\nimport { env, HOME } from \"../global\";\nimport { existsSync } from \"fs\";\nimport { doSqliteQuery1, toStringOrNull } from \"../utils\";\nimport { findAllFiles } from \"../findAllFiles\";\nimport * as path from \"path\";\n\nexport default class FirefoxCookieQueryStrategy extends AbstractCookieQueryStrategy {\n async queryCookies(name, domain) {\n if (process.platform !== \"darwin\") {\n throw new Error(\"This only works on macOS\");\n }\n if (env.CHROME_ONLY) {\n return [];\n }\n const cookies = await this.#getFirefoxCookie({ name, domain });\n return Array.isArray(cookies) ? cookies.map(toStringOrNull) : [];\n }\n\n /**\n *\n * @param name\n * @param domain\n * @returns {Promise<Buffer>}\n */\n async #getFirefoxCookie({ name, domain }) {\n if (name && typeof name !== \"string\") {\n throw new Error(\"name must be a string\");\n }\n if (domain && typeof domain !== \"string\") {\n throw new Error(\"domain must be a string\");\n }\n const files = await findAllFiles({\n path: path.join(\n HOME,\n \"Library\",\n \"Application Support\",\n \"Firefox\",\n \"Profiles\"\n ),\n name: \"cookies.sqlite\",\n });\n const all = Promise.all(\n files.map((file) => {\n return this.#queryCookiesDb(file, name, domain);\n })\n );\n return all.flat();\n }\n\n #queryCookiesDb(file, name, domain) {\n if (file && !existsSync(file)) {\n throw new Error(`File ${file} does not exist`);\n }\n if (env.VERBOSE) {\n console.log(`Trying Firefox cookie ${name} for domain ${domain}`);\n }\n let sql;\n //language=SQL\n sql = \"SELECT value FROM moz_cookies\";\n if (typeof name === \"string\" || typeof domain === \"string\") {\n sql += ` WHERE `;\n if (typeof name === \"string\") {\n sql += `name = '${name}'`;\n if (typeof domain === \"string\") {\n sql += ` AND `;\n }\n }\n if (typeof domain === \"string\") {\n sql += `host LIKE '${domain}';`;\n }\n }\n return doSqliteQuery1(file, sql)\n .then((rows) => rows.map(toStringOrNull))\n .catch(() => []);\n }\n}\n","import AbstractCookieQueryStrategy from \"./AbstractCookieQueryStrategy\";\n\nexport default class SafariCookieQueryStrategy extends AbstractCookieQueryStrategy {}\n","import jsonwebtoken from \"jsonwebtoken\";\nimport { env } from \"./global\";\n\nexport default function isValidJwt(token) {\n if (typeof token !== \"string\") {\n return false;\n }\n try {\n const result = jsonwebtoken.decode(token, { complete: true });\n if (env.VERBOSE) {\n console.log(result);\n }\n return true;\n } catch (err) {\n return false;\n }\n}\n"],"names":[],"version":3,"file":"main.js.map","sourceRoot":"../"}
package/package.json CHANGED
@@ -1,24 +1,57 @@
1
1
  {
2
2
  "name": "@mherod/get-cookie",
3
- "version": "1.2.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Node.js module for querying a local user's Chrome cookie",
5
- "main": "index.js",
6
- "bin": "cli.js",
5
+ "source": "src/index.js",
6
+ "bin": "dist/cli.js",
7
+ "main": "dist/main.js",
8
+ "module": "dist/module.js",
7
9
  "publishConfig": {
8
10
  "access": "public"
9
11
  },
10
12
  "scripts": {
13
+ "clean": "git clean -fXd",
14
+ "build": "parcel build",
11
15
  "test": "jest",
12
- "installGlobal": "rm -rf /usr/local/bin/get-cookie ; npm install --force --global ."
16
+ "postbuild": "npm run install:global",
17
+ "prepublish": "npm run build",
18
+ "install:global": "npm install --force --global .",
19
+ "postinstall:global": "find $NVM_BIN -exec chmod +x {} \\; || true",
20
+ "prettier": "prettier --write 'src/{**/*,*}.{js,json}'"
21
+ },
22
+ "targets": {
23
+ "main": {
24
+ "source": "src/index.js",
25
+ "distDir": "dist",
26
+ "engines": {
27
+ "node": "16"
28
+ }
29
+ },
30
+ "cli": {
31
+ "source": "src/cli.js",
32
+ "distDir": "dist",
33
+ "engines": {
34
+ "node": "16"
35
+ }
36
+ }
37
+ },
38
+ "@parcel/transformer-js": {
39
+ "inlineFS": false,
40
+ "inlineEnvironment": false
41
+ },
42
+ "engines": {
43
+ "node": "16"
13
44
  },
14
45
  "keywords": [],
15
46
  "author": "Matthew Herod",
16
47
  "license": "ISC",
17
48
  "dependencies": {
18
49
  "jsonwebtoken": "^8.5.1",
50
+ "lodash": "^4.17.21",
19
51
  "sqlite3": "^5.0.8"
20
52
  },
21
53
  "devDependencies": {
22
- "jest": "^28.1.0"
54
+ "jest": "^28.1.0",
55
+ "prettier": "^2.7.1"
23
56
  }
24
57
  }
@@ -0,0 +1,8 @@
1
+ export default class AbstractCookieQueryStrategy {
2
+ async queryCookies(name, domain) {
3
+ if (process.env.NODE_ENV === "development") {
4
+ console.log("queryCookie", name, domain);
5
+ }
6
+ return [];
7
+ }
8
+ }
@@ -0,0 +1,263 @@
1
+ import AbstractCookieQueryStrategy from "./AbstractCookieQueryStrategy";
2
+ import {
3
+ doSqliteQuery1,
4
+ execSimple,
5
+ invalidString,
6
+ toStringOrNull,
7
+ toStringValue,
8
+ } from "../utils";
9
+ import { env, HOME } from "../global";
10
+ import { existsSync } from "fs";
11
+ import { findAllFiles } from "../findAllFiles";
12
+ import crypto from "crypto";
13
+ import * as path from "path";
14
+
15
+ export default class ChromeCookieQueryStrategy extends AbstractCookieQueryStrategy {
16
+ async queryCookies(name, domain) {
17
+ if (process.platform !== "darwin") {
18
+ throw new Error("This only works on macOS");
19
+ }
20
+ if (env.FIREFOX_ONLY) {
21
+ return [];
22
+ }
23
+ const cookies = await getChromeCookies({ name, domain });
24
+ return cookies.map(toStringValue);
25
+ }
26
+ }
27
+
28
+ async function getPromise1(name, domain, file) {
29
+ try {
30
+ return await getEncryptedChromeCookie({
31
+ name: name,
32
+ domain: domain,
33
+ file: file,
34
+ });
35
+ } catch (e) {
36
+ if (env.VERBOSE) {
37
+ console.log("Error getting encrypted cookie", e);
38
+ }
39
+ return [];
40
+ }
41
+ }
42
+
43
+ async function getPromise(name, domain) {
44
+ try {
45
+ const files = await findAllFiles({
46
+ path: chromeLocal,
47
+ name: "Cookies",
48
+ });
49
+ const promises = files.map((file) => getPromise1(name, domain, file));
50
+ const results1 = await Promise.all(promises);
51
+ const results2 = results1.flat();
52
+ if (env.VERBOSE) {
53
+ console.log("getEncryptedChromeCookie results", results2);
54
+ }
55
+ return results2.filter((result) => result);
56
+ } catch (error) {
57
+ if (env.VERBOSE) {
58
+ console.log("error", error);
59
+ }
60
+ return [];
61
+ }
62
+ }
63
+
64
+ /**
65
+ *
66
+ * @param {string|undefined} name
67
+ * @param {string} domain
68
+ * @param {boolean} requireJwt
69
+ * @returns {Promise<[string]>}
70
+ */
71
+ async function getChromeCookies({ name, domain = "%", requireJwt = false }) {
72
+ if (invalidString(name)) {
73
+ throw new Error("name must be a string");
74
+ }
75
+ if (invalidString(domain)) {
76
+ throw new Error("domain must be a string");
77
+ }
78
+ const encryptedDataItems = await getPromise(name, domain);
79
+ const password = await getChromePassword();
80
+ const decrypted = encryptedDataItems
81
+ .filter((encryptedData) => {
82
+ return encryptedData != null && encryptedData.length > 0;
83
+ })
84
+ .map(async (encryptedData) => {
85
+ if (env.VERBOSE) {
86
+ console.log("Received encrypted", encryptedData);
87
+ }
88
+ let d;
89
+ try {
90
+ d = await decrypt(password, encryptedData);
91
+ } catch (e) {
92
+ if (env.VERBOSE) {
93
+ console.log("Error decrypting cookie", e);
94
+ }
95
+ return null;
96
+ }
97
+ if (d) {
98
+ if (env.VERBOSE) {
99
+ console.log("Decrypted", d);
100
+ }
101
+ return d;
102
+ }
103
+ return null;
104
+ });
105
+ const results = await Promise.all(decrypted);
106
+ if (env.VERBOSE) {
107
+ console.log("results", results);
108
+ }
109
+ return results.map(toStringOrNull);
110
+ }
111
+
112
+ const chromeLocal = path.join(
113
+ HOME,
114
+ "Library",
115
+ "Application Support",
116
+ "Google",
117
+ "Chrome"
118
+ );
119
+
120
+ async function getEncryptedChromeCookie({
121
+ name,
122
+ domain,
123
+ file = path.join(chromeLocal, "Default", "Cookies"),
124
+ }) {
125
+ if (name && typeof name !== "string") {
126
+ throw new Error("name must be a string");
127
+ }
128
+ if (domain && typeof domain !== "string") {
129
+ throw new Error("domain must be a string");
130
+ }
131
+ if (file && typeof file !== "string") {
132
+ throw new Error("file must be a string");
133
+ }
134
+ if (!existsSync(file)) {
135
+ throw new Error(`File ${file} does not exist`);
136
+ }
137
+ if (env.VERBOSE) {
138
+ const s = file.split("/").slice(-3).join("/");
139
+ console.log(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);
140
+ }
141
+ let sql;
142
+ sql = `SELECT encrypted_value FROM cookies`;
143
+ if (typeof name === "string" || typeof domain === "string") {
144
+ sql += ` WHERE `;
145
+ if (typeof name === "string") {
146
+ sql += `name = '${name}'`;
147
+ if (typeof domain === "string") {
148
+ sql += ` AND `;
149
+ }
150
+ }
151
+ if (typeof domain === "string") {
152
+ sql += `host_key LIKE '${domain}';`;
153
+ }
154
+ }
155
+ return doSqliteQuery1(file, sql);
156
+ }
157
+
158
+ /**
159
+ *
160
+ * @returns {Promise<string>}
161
+ */
162
+ async function getChromePassword() {
163
+ return execSimple(
164
+ 'security find-generic-password -w -s "Chrome Safe Storage"'
165
+ );
166
+ }
167
+
168
+ /**
169
+ *
170
+ * @param {string} password
171
+ * @param {Buffer} encryptedData
172
+ * @returns {Promise<string>}
173
+ */
174
+ async function decrypt(password, encryptedData) {
175
+ if (typeof password !== "string") {
176
+ throw new Error("password must be a string: " + password);
177
+ }
178
+ let encryptedData1;
179
+ encryptedData1 = encryptedData;
180
+ if (encryptedData1 == null || typeof encryptedData1 !== "object") {
181
+ throw new Error("encryptedData must be a object: " + encryptedData1);
182
+ }
183
+ if (!(encryptedData1 instanceof Buffer)) {
184
+ if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {
185
+ [encryptedData1] = encryptedData1;
186
+ if (env.VERBOSE) {
187
+ console.log(
188
+ `encryptedData is an array of buffers, selected first: ${encryptedData1}`
189
+ );
190
+ }
191
+ } else {
192
+ throw new Error("encryptedData must be a Buffer: " + encryptedData1);
193
+ }
194
+ encryptedData1 = Buffer.from(encryptedData1);
195
+ }
196
+ if (env.VERBOSE) {
197
+ console.log(`Trying to decrypt with password ${password}`);
198
+ }
199
+ return new Promise((resolve, reject) => {
200
+ crypto.pbkdf2(password, "saltysalt", 1003, 16, "sha1", (error, buffer) => {
201
+ try {
202
+ if (error) {
203
+ if (env.VERBOSE) {
204
+ console.log("Error doing pbkdf2", error);
205
+ }
206
+ reject(error);
207
+ return;
208
+ }
209
+
210
+ if (buffer.length !== 16) {
211
+ if (env.VERBOSE) {
212
+ console.log(
213
+ "Error doing pbkdf2, buffer length is not 16",
214
+ buffer.length
215
+ );
216
+ }
217
+ reject(new Error("Buffer length is not 16"));
218
+ return;
219
+ }
220
+
221
+ const iv = new Buffer.from(new Array(17).join(" "), "binary");
222
+ const decipher = crypto.createDecipheriv("aes-128-cbc", buffer, iv);
223
+ decipher.setAutoPadding(false);
224
+
225
+ if (encryptedData1 && encryptedData1.slice) {
226
+ encryptedData1 = encryptedData1.slice(3);
227
+ }
228
+
229
+ if (encryptedData1.length % 16 !== 0) {
230
+ if (env.VERBOSE) {
231
+ console.log(
232
+ "Error doing pbkdf2, encryptedData length is not a multiple of 16",
233
+ encryptedData1.length
234
+ );
235
+ }
236
+ reject(new Error("encryptedData length is not a multiple of 16"));
237
+ return;
238
+ }
239
+
240
+ let decoded = decipher.update(encryptedData1);
241
+ try {
242
+ decipher.final("utf-8");
243
+ } catch (e) {
244
+ if (env.VERBOSE) {
245
+ console.log("Error doing decipher.final()", e);
246
+ }
247
+ reject(e);
248
+ return;
249
+ }
250
+
251
+ const padding = decoded[decoded.length - 1];
252
+ if (padding) {
253
+ decoded = decoded.slice(0, 0 - padding);
254
+ }
255
+ // noinspection JSCheckFunctionSignatures
256
+ decoded = decoded.toString("utf8");
257
+ resolve(decoded);
258
+ } catch (e) {
259
+ reject(e);
260
+ }
261
+ });
262
+ });
263
+ }
@@ -0,0 +1,28 @@
1
+ import ChromeCookieQueryStrategy from "./ChromeCookieQueryStrategy";
2
+ import FirefoxCookieQueryStrategy from "./FirefoxCookieQueryStrategy";
3
+ import SafariCookieQueryStrategy from "./SafariCookieQueryStrategy";
4
+ import AbstractCookieQueryStrategy from "./AbstractCookieQueryStrategy";
5
+
6
+ export default class CompositeCookieQueryStrategy extends AbstractCookieQueryStrategy {
7
+ #strategies;
8
+
9
+ constructor() {
10
+ super();
11
+ this.#strategies = [
12
+ ChromeCookieQueryStrategy,
13
+ FirefoxCookieQueryStrategy,
14
+ SafariCookieQueryStrategy,
15
+ ].map((strategy) => {
16
+ return new strategy();
17
+ });
18
+ }
19
+
20
+ async queryCookies(name, domain) {
21
+ const results = await Promise.all(
22
+ this.#strategies.map(async (strategy) => {
23
+ return strategy.queryCookies(name, domain).catch(() => []);
24
+ })
25
+ );
26
+ return results.flat();
27
+ }
28
+ }
@@ -0,0 +1,77 @@
1
+ import AbstractCookieQueryStrategy from "./AbstractCookieQueryStrategy";
2
+ import { env, HOME } from "../global";
3
+ import { existsSync } from "fs";
4
+ import { doSqliteQuery1, toStringOrNull } from "../utils";
5
+ import { findAllFiles } from "../findAllFiles";
6
+ import * as path from "path";
7
+
8
+ export default class FirefoxCookieQueryStrategy extends AbstractCookieQueryStrategy {
9
+ async queryCookies(name, domain) {
10
+ if (process.platform !== "darwin") {
11
+ throw new Error("This only works on macOS");
12
+ }
13
+ if (env.CHROME_ONLY) {
14
+ return [];
15
+ }
16
+ const cookies = await this.#getFirefoxCookie({ name, domain });
17
+ return Array.isArray(cookies) ? cookies.map(toStringOrNull) : [];
18
+ }
19
+
20
+ /**
21
+ *
22
+ * @param name
23
+ * @param domain
24
+ * @returns {Promise<Buffer>}
25
+ */
26
+ async #getFirefoxCookie({ name, domain }) {
27
+ if (name && typeof name !== "string") {
28
+ throw new Error("name must be a string");
29
+ }
30
+ if (domain && typeof domain !== "string") {
31
+ throw new Error("domain must be a string");
32
+ }
33
+ const files = await findAllFiles({
34
+ path: path.join(
35
+ HOME,
36
+ "Library",
37
+ "Application Support",
38
+ "Firefox",
39
+ "Profiles"
40
+ ),
41
+ name: "cookies.sqlite",
42
+ });
43
+ const all = Promise.all(
44
+ files.map((file) => {
45
+ return this.#queryCookiesDb(file, name, domain);
46
+ })
47
+ );
48
+ return all.flat();
49
+ }
50
+
51
+ #queryCookiesDb(file, name, domain) {
52
+ if (file && !existsSync(file)) {
53
+ throw new Error(`File ${file} does not exist`);
54
+ }
55
+ if (env.VERBOSE) {
56
+ console.log(`Trying Firefox cookie ${name} for domain ${domain}`);
57
+ }
58
+ let sql;
59
+ //language=SQL
60
+ sql = "SELECT value FROM moz_cookies";
61
+ if (typeof name === "string" || typeof domain === "string") {
62
+ sql += ` WHERE `;
63
+ if (typeof name === "string") {
64
+ sql += `name = '${name}'`;
65
+ if (typeof domain === "string") {
66
+ sql += ` AND `;
67
+ }
68
+ }
69
+ if (typeof domain === "string") {
70
+ sql += `host LIKE '${domain}';`;
71
+ }
72
+ }
73
+ return doSqliteQuery1(file, sql)
74
+ .then((rows) => rows.map(toStringOrNull))
75
+ .catch(() => []);
76
+ }
77
+ }
@@ -0,0 +1,3 @@
1
+ import AbstractCookieQueryStrategy from "./AbstractCookieQueryStrategy";
2
+
3
+ export default class SafariCookieQueryStrategy extends AbstractCookieQueryStrategy {}
package/src/cli.js ADDED
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { version } from "../package.json";
4
+ import { env } from "./global";
5
+ import { queryCookies } from "./queryCookies";
6
+
7
+ const argv = process.argv;
8
+
9
+ async function cliQueryCookies(name, domain) {
10
+ try {
11
+ const results = await queryCookies({ name, domain });
12
+ if (results.length > 0) {
13
+ for (const result of results) {
14
+ console.log(result);
15
+ }
16
+ } else {
17
+ console.error("No results");
18
+ }
19
+ } catch (e) {
20
+ console.error(e);
21
+ }
22
+ }
23
+
24
+ if (argv && argv.length > 2) {
25
+ if (argv.includes("--version") || argv.includes("-v")) {
26
+ console.log(version);
27
+ return;
28
+ }
29
+
30
+ const name = argv[2];
31
+
32
+ let domain;
33
+ if (argv[3] != null && argv[3].indexOf(".") > -1) {
34
+ domain = argv[3];
35
+ } else {
36
+ domain = "%";
37
+ }
38
+
39
+ const tru = `${true}`;
40
+
41
+ if (argv.includes("--require-jwt")) {
42
+ env.REQUIRE_JWT = tru;
43
+ }
44
+ if (argv.includes("--verbose")) {
45
+ env.VERBOSE = tru;
46
+ }
47
+ if (argv.includes("--chrome-only")) {
48
+ env.CHROME_ONLY = tru;
49
+ }
50
+ if (argv.includes("--firefox-only")) {
51
+ env.FIREFOX_ONLY = tru;
52
+ }
53
+ if (argv.includes("--ignore-expired")) {
54
+ env.IGNORE_EXPIRED = tru;
55
+ }
56
+
57
+ if (argv.includes("--single")) {
58
+ env.SINGLE = tru;
59
+ }
60
+
61
+ if (env.VERBOSE) {
62
+ console.log("Verbose mode", argv);
63
+ }
64
+
65
+ cliQueryCookies(name, domain)
66
+ .then(() => {
67
+ //
68
+ })
69
+ .catch(console.error);
70
+ }
@@ -0,0 +1,73 @@
1
+ import { env } from "./global";
2
+ import fs from "fs";
3
+
4
+ /**
5
+ *
6
+ * @param path
7
+ * @param name
8
+ * @param rootSegments
9
+ * @param maxDepth
10
+ * @returns {Promise<[string]>}
11
+ */
12
+ export async function findAllFiles({ path, name, maxDepth = 2 }) {
13
+ if (typeof path !== "string") {
14
+ throw new Error("path must be a string");
15
+ }
16
+ if (typeof name !== "string") {
17
+ throw new Error("name must be a string");
18
+ }
19
+
20
+ const rootSegments = path.split("/").length;
21
+
22
+ if (env.VERBOSE) {
23
+ console.log(`Searching for ${name} in ${path}`);
24
+ }
25
+ const files = [];
26
+ let readdirSync;
27
+ try {
28
+ readdirSync = fs.readdirSync(path);
29
+ } catch (e) {
30
+ if (env.VERBOSE) {
31
+ console.log(`Error reading ${path}`, e);
32
+ }
33
+ return files;
34
+ }
35
+ for (const file of readdirSync) {
36
+ const filePath = path + "/" + file;
37
+ let stat;
38
+ try {
39
+ stat = fs.statSync(filePath);
40
+ } catch (e) {
41
+ if (env.VERBOSE) {
42
+ console.error(`Error getting stat for ${filePath}`, e);
43
+ }
44
+ continue;
45
+ }
46
+ if (stat.isDirectory()) {
47
+ if (filePath.split("/").length < rootSegments + maxDepth) {
48
+ try {
49
+ const subFiles = await findAllFiles({
50
+ path: filePath,
51
+ name: name,
52
+ rootSegments: rootSegments,
53
+ maxDepth: 2,
54
+ });
55
+ files.push(...subFiles);
56
+ } catch (e) {
57
+ if (env.VERBOSE) {
58
+ console.error(e);
59
+ }
60
+ }
61
+ }
62
+ } else if (file === name) {
63
+ files.push(filePath);
64
+ }
65
+ }
66
+ if (env.VERBOSE) {
67
+ if (files.length > 0) {
68
+ console.log(`Found ${files.length} ${name} files`);
69
+ console.log(files);
70
+ }
71
+ }
72
+ return files;
73
+ }