@mherod/get-cookie 2.0.0-rc.2 → 2.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/runConfigurations/build.xml +12 -0
- package/.prettierignore +5 -0
- package/README.md +2 -2
- package/dist/cli.js +1110 -2
- package/dist/index.js +642 -231
- package/dist/index.js.map +1 -1
- package/dist/module.js +634 -224
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +246 -34
- package/dist/types.d.ts.map +1 -1
- package/package-lock.json +7539 -0
- package/package.json +24 -22
- package/src/CookieRow.ts +2 -1
- package/src/CookieSpec.ts +4 -2
- package/src/CookieStore.ts +27 -0
- package/src/ExportedCookie.ts +2 -1
- package/src/FetchResponse.ts +2 -0
- package/src/FileCookieStore.ts +170 -0
- package/src/IsCookieRow.ts +1 -1
- package/src/IsExportedCookie.ts +1 -1
- package/src/SpecialCases.ts +1 -1
- package/src/StringToRegex.ts +6 -0
- package/src/argv.ts +19 -0
- package/src/browsers/ChromeCookieQueryStrategy.ts +106 -24
- package/src/browsers/CompositeCookieQueryStrategy.ts +32 -8
- package/src/browsers/CookieQueryStrategy.ts +3 -1
- package/src/browsers/CookieStoreQueryStrategy.ts +99 -0
- package/src/browsers/FirefoxCookieQueryStrategy.ts +57 -9
- package/src/browsers/SafariCookieQueryStrategy.ts +4 -1
- package/src/cli.ts +101 -93
- package/src/comboQueryCookieSpec.ts +24 -0
- package/src/cookieSpecsFromUrl.ts +26 -0
- package/src/doSqliteQuery1Params.ts +8 -0
- package/src/fetchWithCookies.ts +131 -40
- package/src/findAllFiles.ts +5 -9
- package/src/getChromeCookie.ts +19 -0
- package/src/getCookie.ts +19 -0
- package/src/getFirefoxCookie.ts +19 -0
- package/src/getGroupedRenderedCookies.ts +12 -25
- package/src/getMergedRenderedCookies.ts +14 -0
- package/src/index.ts +13 -52
- package/src/isValidJwt.ts +2 -2
- package/src/queryCookies.ts +16 -12
- package/src/resultsRendered.ts +7 -4
- package/src/unpackHeaders.ts +7 -4
- package/src/utils.ts +0 -25
- package/tsconfig.json +11 -15
- package/.github/dependabot.yml +0 -6
- package/dist/cli.js.map +0 -1
- package/src/doSqliteQuery1.ts +0 -51
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,1111 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var e=require("minimist"),r=require("lodash"),n=require("lru-cache"),t=require("fs"),o=require("crypto"),i=require("path"),a=require("child_process"),s=require("sqlite3"),c=require("jsonwebtoken"),l=require("tty"),u=require("cross-fetch"),g=require("destr");function f(e){return e&&e.__esModule?e.default:e}const d=process.argv??[],h={};(0,r.merge)(h,process.env);const m=h.HOME;if(!m)throw new Error("HOME environment variable is not set");async function y(e){return new Promise(((r,n)=>{(0,a.exec)(e,{encoding:"binary",maxBuffer:5120},((e,t,o)=>{e||o?n(e):t&&r(t.trim())}))}))}async function w({path:e,name:r,maxDepth:n=2}){const o=e.split("/").length;h.VERBOSE&&console.log(`Searching for ${r} in ${e}`);const i=[];let a;try{a=t.readdirSync(e)}catch(r){return h.VERBOSE&&console.log(`Error reading ${e}`,r),[]}for(const s of a){const a=e+"/"+s;let c;try{c=t.statSync(a)}catch(e){h.VERBOSE&&console.error(`Error getting stat for ${a}`,e);continue}if(c.isDirectory()){if(a.split("/").length<o+n)try{const e=await w({path:a,name:r,maxDepth:2});i.push(...e)}catch(e){h.VERBOSE&&console.error(e)}}else s===r&&i.push(a)}return h.VERBOSE&&i.length>0&&(console.log(`Found ${i.length} ${r} files`),console.log(i)),i}async function E({file:e,sql:n,rowTransform:o}){if(!e||e&&!t.existsSync(e))throw new Error(`doSqliteQuery1: file ${e} does not exist`);const i=new s.Database(e);return new Promise(((t,a)=>{i.all(n,((n,i)=>{if(n)return void a(n);const s=i;if(null!=s&&0!==s.length)if(Array.isArray(s)){const n=s.map((n=>{const t={meta:{file:e}},i=o(n);return(0,r.merge)(t,i)}));t(n)}else process.env.VERBOSE&&console.log(`doSqliteQuery1: rows ${JSON.stringify(s)}`),t([s]);else t([])}))}))}function p(e){return void 0!==e.domain&&void 0!==e.name&&void 0!==e.value}function B(e){return void 0!==e.domain&&void 0!==e.name&&void 0!==e.value}class b{async queryCookies(e,n){if("darwin"!==process.platform)throw new Error("This only works on macOS");return h.FIREFOX_ONLY?[]:async function({name:e,domain:n="%",requireJwt:a=!1}){const s=await async function(e,r){try{const n=(await w({path:O,name:"Cookies"})).map((n=>async function(e,r,n){try{return await async function({name:e,domain:r,file:n=i.join(O,"Default","Cookies")}){if(!(0,t.existsSync)(n))throw new Error(`File ${n} does not exist`);if(h.VERBOSE){const t=n.split("/").slice(-3).join("/");console.log(`Trying Chrome (at ${t}) cookie ${e} for domain ${r}`)}let o;o="SELECT encrypted_value, name, host_key FROM cookies";const a=/^([*%])$/i,s=null==e.match(a),c=null==r.match(a);(s||c)&&(o+=" WHERE ",s&&(o+=`name = '${e}'`,c&&(o+=" AND ")),c&&(o+=`host_key LIKE '${r}';`));return E({file:n,sql:o,rowTransform:e=>({domain:e.host_key,name:e.name,value:e.encrypted_value})})}({name:e,domain:r,file:n})}catch(e){return h.VERBOSE&&console.log("Error getting encrypted cookie",e),[]}}(e,r,n)));return(await Promise.all(n)).flat().filter(p)}catch(e){return h.VERBOSE&&console.log("error",e),[]}}(e,n),c=await async function(){return y('security find-generic-password -w -s "Chrome Safe Storage"')}(),l=s.filter((({value:e})=>null!=e&&e.length>0)).map((async e=>{const n=e.value,t=await async function(e,r){let n;try{n=await async function(e,r){if("string"!=typeof e)throw new Error("password must be a string: "+e);let n;if(n=r,null==n||"object"!=typeof n)throw new Error("encryptedData must be a object: "+n);if(!(n instanceof Buffer)){if(!(Array.isArray(n)&&n[0]instanceof Buffer))throw new Error("encryptedData must be a Buffer: "+n);[n]=n,h.VERBOSE&&console.log(`encryptedData is an array of buffers, selected first: ${n}`),n=Buffer.from(n)}h.VERBOSE&&console.log(`Trying to decrypt with password ${e}`);return new Promise(((r,t)=>{o.pbkdf2(e,"saltysalt",1003,16,"sha1",((e,i)=>{try{if(e)return h.VERBOSE&&console.log("Error doing pbkdf2",e),void t(e);if(16!==i.length)return h.VERBOSE&&console.log("Error doing pbkdf2, buffer length is not 16",i.length),void t(new Error("Buffer length is not 16"));const a=new Array(17).join(" "),s=Buffer.from(a,"binary"),c=o.createDecipheriv("aes-128-cbc",i,s);if(c.setAutoPadding(!1),n&&n.slice&&(n=n.slice(3)),n.length%16!=0)return h.VERBOSE&&console.log("Error doing pbkdf2, encryptedData length is not a multiple of 16",n.length),void t(new Error("encryptedData length is not a multiple of 16"));let l=c.update(n);try{c.final("utf-8")}catch(e){return h.VERBOSE&&console.log("Error doing decipher.final()",e),void t(e)}const u=l[l.length-1];u&&(l=l.slice(0,0-u));const g=l.toString("utf8");r(g)}catch(e){t(e)}}))}))}(e,r)}catch(e){h.VERBOSE&&console.log("Error decrypting cookie",e),n=null}return n??r.toString("utf-8")}(c,n),i={};return(0,r.merge)(i,e.meta??{}),{domain:e.domain,name:e.name,value:t,meta:i}})),u=(await Promise.all(l)).filter(B);h.VERBOSE&&console.log("results",u);return u}({requireJwt:!1,name:e,domain:n})}}const O=i.join(m,"Library","Application Support","Google","Chrome");function S({name:e,domain:r}){const n=/^([*%])$/i;return{specifiedName:null==e.match(n),specifiedDomain:null==r.match(n)}}class R{async queryCookies(e,r){if("darwin"!==process.platform)throw new Error("This only works on macOS");if(h.CHROME_ONLY)return[];const n=await this.#e({name:e,domain:r});return Array.isArray(n)?n.map((e=>({domain:e.domain,name:e.name,value:e.value.toString("utf8")}))):[]}async#e({name:e,domain:r}){const n=await w({path:i.join(m,"Library","Application Support","Firefox","Profiles"),name:"cookies.sqlite"});return(await Promise.all(n.map((async n=>await this.#r(n,e,r))))).flat()}async#r(e,r,n){if(e&&!(0,t.existsSync)(e))throw new Error(`File ${e} does not exist`);let o;o="SELECT value, name, host FROM moz_cookies";const{specifiedName:i,specifiedDomain:a}=S({name:r,domain:n});(i||a)&&(o+=" WHERE ",i&&(o+=`name = '${r}'`,a&&(o+=" AND ")),a&&(o+=`host LIKE '${n}';`));const s=e=>{const r=e.value;return{domain:e.domain,name:e.name,value:Buffer.from(r,"utf8")}};try{return await E({file:e,sql:o,rowTransform:s})}catch(r){return console.error(`Error querying ${e}`,r),[]}}}class k{async queryCookies(e,r){return[]}}const v=new(f(n))({ttl:2e3,max:10});class C{#n;constructor(){this.#n=[b,R,k].map((e=>new e))}async queryCookies(e,r){const n=`${e}:${r}`,t=v.get(n);if(t)return t;const o=(await Promise.all(this.#n.map((async n=>n.queryCookies(e,r).catch((()=>[])))))).flat();return v.set(`${e}:${r}`,o),o}}function q(e){try{const r=f(c).decode(e,{complete:!0});h.VERBOSE&&console.log(r);const n=r?.payload;if(n){const e=n.exp;if(e){if((new Date).getTime()/1e3>e)return!1}}return!0}catch(e){return!1}}async function $({name:e,domain:n},t=new C){const o=await t.queryCookies(e,n),i=(0,r.uniqBy)(o,JSON.stringify),a=[];for(const e of i){q(e.value)&&a.push(e)}const s=h.REQUIRE_JWT?a:i;return h.SINGLE?[s[0]]:s}const{env:x={},argv:L=[],platform:T=""}="undefined"==typeof process?{}:process,V="NO_COLOR"in x||L.includes("--no-color"),A="FORCE_COLOR"in x||L.includes("--color"),D="win32"===T,_="dumb"===x.TERM,I=l&&l.isatty&&l.isatty(1)&&x.TERM&&!_,N=!V&&(A||D&&!_||I||"CI"in x&&("GITHUB_ACTIONS"in x||"GITLAB_CI"in x||"CIRCLECI"in x)),M=(e,r,n,t,o=r.substring(0,e)+t,i=r.substring(e+n.length),a=i.indexOf(n))=>o+(a<0?i:M(a,i,n,t)),j=(e,r,n=e,t=e.length+1)=>o=>o||""!==o&&void 0!==o?((e,r,n,t,o)=>e<0?n+r+t:n+M(e,r,t,o)+t)((""+o).indexOf(r,t),o,e,r,n):"",F=(e,r,n)=>j(`[${e}m`,`[${r}m`,n),G={reset:F(0,0),bold:F(1,22,"[22m[1m"),dim:F(2,22,"[22m[2m"),italic:F(3,23),underline:F(4,24),inverse:F(7,27),hidden:F(8,28),strikethrough:F(9,29),black:F(30,39),red:F(31,39),green:F(32,39),yellow:F(33,39),blue:F(34,39),magenta:F(35,39),cyan:F(36,39),white:F(37,39),gray:F(90,39),bgBlack:F(40,49),bgRed:F(41,49),bgGreen:F(42,49),bgYellow:F(43,49),bgBlue:F(44,49),bgMagenta:F(45,49),bgCyan:F(46,49),bgWhite:F(47,49),blackBright:F(90,39),redBright:F(91,39),greenBright:F(92,39),yellowBright:F(93,39),blueBright:F(94,39),magentaBright:F(95,39),cyanBright:F(96,39),whiteBright:F(97,39),bgBlackBright:F(100,49),bgRedBright:F(101,49),bgGreenBright:F(102,49),bgYellowBright:F(103,49),bgBlueBright:F(104,49),bgMagentaBright:F(105,49),bgCyanBright:F(106,49),bgWhiteBright:F(107,49)},{reset:P,bold:W,dim:H,italic:U,underline:Y,inverse:J,hidden:K,strikethrough:Q,black:X,red:z,green:Z,yellow:ee,blue:re,magenta:ne,cyan:te,white:oe,gray:ie,bgBlack:ae,bgRed:se,bgGreen:ce,bgYellow:le,bgBlue:ue,bgMagenta:ge,bgCyan:fe,bgWhite:de,blackBright:he,redBright:me,greenBright:ye,yellowBright:we,blueBright:Ee,magentaBright:pe,cyanBright:Be,whiteBright:be,bgBlackBright:Oe,bgRedBright:Se,bgGreenBright:Re,bgYellowBright:ke,bgBlueBright:ve,bgMagentaBright:Ce,bgCyanBright:qe,bgWhiteBright:$e}=(({useColor:e=N}={})=>e?G:Object.keys(G).reduce(((e,r)=>({...e,[r]:String})),{}))();function xe(e){return(0,r.uniqBy)(e,(e=>e.name)).map((e=>e.name+"="+e.value)).join("; ")}async function Le({name:e,domain:n}){const t=await $({name:e,domain:n},new C);if(Array.isArray(t)&&t.length>0){const t=await $({name:e,domain:n}),o=(0,r.groupBy)(t,(e=>e.meta?.file));return Object.keys(o).map((e=>xe(o[e])))}throw new Error("Cookie not found")}async function Te(e,n={}){const t=`${e}`,o=new URL(t).hostname.replace(/^.*(\.\w+\.\w+)$/,((e,r)=>`%${r}`)),i=(await Le({name:"%",domain:o}).catch((()=>[]))).pop(),a=(0,r.merge)({headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"},redirect:"manual"},n,{headers:{Cookie:i}});try{const e=await(0,u.fetch)(t,a),n=e.headers.get("location");if(e.redirected||n&&n!==t)return Te(n,a);const o=e.arrayBuffer(),i=async()=>o,s=async()=>i().then(Buffer.from),c=async()=>s().then((e=>e.toString("utf8"))),l=async()=>c().then(f(g)),d=async()=>c().then((e=>new URLSearchParams(e))),h={status:e.status,statusText:e.statusText,headers:e.headers,arrayBuffer:i,buffer:s,text:c,json:l,formData:d};return(0,r.merge)({},e,h)}catch(e){throw e}}function Ve(e){const r={};if(Array.isArray(e))for(const n of e){const[e,t]=n.split("=");r[e]=t}else{const[n,t]=e.split("=");r[n]=t}return r}const Ae=f(e)(d);!function(){if(d&&d.length>2){const e=d[2],n=d[3];if("--fetch"==e||"-f"==e){const e=Ae.f;let r;try{r=new URL(e)}catch(e){return void console.error("Invalid URL",n)}const t=e=>e.text().then((e=>{console.log(e)}));return void Te(r,{headers:Ve(Ae.H)}).then(t,console.error)}let t;t=null!=n&&n.indexOf(".")>-1?n:"%";const o="true";d.includes("--require-jwt")&&(h.REQUIRE_JWT=o),d.includes("--verbose")&&(h.VERBOSE=o),d.includes("--chrome-only")&&(h.CHROME_ONLY=o),d.includes("--firefox-only")&&(h.FIREFOX_ONLY=o),d.includes("--ignore-expired")&&(h.IGNORE_EXPIRED=o),d.includes("--single")&&(h.SINGLE=o),h.VERBOSE&&console.log("Verbose mode",d),async function(e,n){try{const t=await $({name:e,domain:n});if(t.length>0)if(d.includes("--combined-string"))console.log(ee(xe(t)));else if(d.includes("--render")||d.includes("-r"))console.log(ee(xe(t)));else if(d.includes("--dump")||d.includes("-d"))console.log(t);else if(d.includes("--dump-grouped")){const e=(0,r.groupBy)(t,(e=>e.meta?.file));console.log(Z(JSON.stringify(e,null,2)))}else if(d.includes("--combined-string-grouped")){const e=(0,r.groupBy)(t,(e=>e.meta?.file));for(const r of Object.keys(e)){let n=e[r];console.log(Z(r)+": ",ee(xe(n)))}}else for(const e of t)console.log(e.value);else console.error("No results")}catch(e){console.error(e)}}(e,t).catch(console.error)}}();
|
|
3
|
-
|
|
2
|
+
var $cMsgG$lodash = require("lodash");
|
|
3
|
+
var $cMsgG$minimist = require("minimist");
|
|
4
|
+
var $cMsgG$tty = require("tty");
|
|
5
|
+
var $cMsgG$crossfetch = require("cross-fetch");
|
|
6
|
+
var $cMsgG$destr = require("destr");
|
|
7
|
+
var $cMsgG$useragents = require("user-agents");
|
|
8
|
+
var $cMsgG$toughcookie = require("tough-cookie");
|
|
9
|
+
var $cMsgG$fs = require("fs");
|
|
10
|
+
var $cMsgG$lrucache = require("lru-cache");
|
|
11
|
+
var $cMsgG$crypto = require("crypto");
|
|
12
|
+
var $cMsgG$path = require("path");
|
|
13
|
+
var $cMsgG$sqlite3 = require("sqlite3");
|
|
14
|
+
var $cMsgG$child_process = require("child_process");
|
|
15
|
+
var $cMsgG$jsonwebtoken = require("jsonwebtoken");
|
|
16
|
+
|
|
17
|
+
function $parcel$interopDefault(a) {
|
|
18
|
+
return a && a.__esModule ? a.default : a;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const $75ef4a5a80896531$export$6f4ae1207c703045 = process.argv ?? [];
|
|
23
|
+
const $75ef4a5a80896531$var$minimistArgs = (0, ($parcel$interopDefault($cMsgG$minimist)))($75ef4a5a80896531$export$6f4ae1207c703045.slice(2));
|
|
24
|
+
const $75ef4a5a80896531$var$defaultOptions = {
|
|
25
|
+
verbose: false
|
|
26
|
+
};
|
|
27
|
+
const $75ef4a5a80896531$export$c348dfaf65040d9b = (0, $cMsgG$lodash.merge)($75ef4a5a80896531$var$defaultOptions, $75ef4a5a80896531$var$minimistArgs);
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const { env: $14c38dc11beadfaf$var$env = {} , argv: $14c38dc11beadfaf$var$argv = [] , platform: $14c38dc11beadfaf$var$platform = "" , } = typeof process === "undefined" ? {} : process;
|
|
33
|
+
const $14c38dc11beadfaf$var$isDisabled = "NO_COLOR" in $14c38dc11beadfaf$var$env || $14c38dc11beadfaf$var$argv.includes("--no-color");
|
|
34
|
+
const $14c38dc11beadfaf$var$isForced = "FORCE_COLOR" in $14c38dc11beadfaf$var$env || $14c38dc11beadfaf$var$argv.includes("--color");
|
|
35
|
+
const $14c38dc11beadfaf$var$isWindows = $14c38dc11beadfaf$var$platform === "win32";
|
|
36
|
+
const $14c38dc11beadfaf$var$isDumbTerminal = $14c38dc11beadfaf$var$env.TERM === "dumb";
|
|
37
|
+
const $14c38dc11beadfaf$var$isCompatibleTerminal = $cMsgG$tty && $cMsgG$tty.isatty && $cMsgG$tty.isatty(1) && $14c38dc11beadfaf$var$env.TERM && !$14c38dc11beadfaf$var$isDumbTerminal;
|
|
38
|
+
const $14c38dc11beadfaf$var$isCI = "CI" in $14c38dc11beadfaf$var$env && ("GITHUB_ACTIONS" in $14c38dc11beadfaf$var$env || "GITLAB_CI" in $14c38dc11beadfaf$var$env || "CIRCLECI" in $14c38dc11beadfaf$var$env);
|
|
39
|
+
const $14c38dc11beadfaf$export$ba7eaac21c385de8 = !$14c38dc11beadfaf$var$isDisabled && ($14c38dc11beadfaf$var$isForced || $14c38dc11beadfaf$var$isWindows && !$14c38dc11beadfaf$var$isDumbTerminal || $14c38dc11beadfaf$var$isCompatibleTerminal || $14c38dc11beadfaf$var$isCI);
|
|
40
|
+
const $14c38dc11beadfaf$var$replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close))=>head + (next < 0 ? tail : $14c38dc11beadfaf$var$replaceClose(next, tail, close, replace));
|
|
41
|
+
const $14c38dc11beadfaf$var$clearBleed = (index, string, open, close, replace)=>index < 0 ? open + string + close : open + $14c38dc11beadfaf$var$replaceClose(index, string, close, replace) + close;
|
|
42
|
+
const $14c38dc11beadfaf$var$filterEmpty = (open, close, replace = open, at = open.length + 1)=>(string)=>string || !(string === "" || string === undefined) ? $14c38dc11beadfaf$var$clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
43
|
+
const $14c38dc11beadfaf$var$init = (open, close, replace)=>$14c38dc11beadfaf$var$filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
44
|
+
const $14c38dc11beadfaf$var$colors = {
|
|
45
|
+
reset: $14c38dc11beadfaf$var$init(0, 0),
|
|
46
|
+
bold: $14c38dc11beadfaf$var$init(1, 22, "\x1b[22m\x1b[1m"),
|
|
47
|
+
dim: $14c38dc11beadfaf$var$init(2, 22, "\x1b[22m\x1b[2m"),
|
|
48
|
+
italic: $14c38dc11beadfaf$var$init(3, 23),
|
|
49
|
+
underline: $14c38dc11beadfaf$var$init(4, 24),
|
|
50
|
+
inverse: $14c38dc11beadfaf$var$init(7, 27),
|
|
51
|
+
hidden: $14c38dc11beadfaf$var$init(8, 28),
|
|
52
|
+
strikethrough: $14c38dc11beadfaf$var$init(9, 29),
|
|
53
|
+
black: $14c38dc11beadfaf$var$init(30, 39),
|
|
54
|
+
red: $14c38dc11beadfaf$var$init(31, 39),
|
|
55
|
+
green: $14c38dc11beadfaf$var$init(32, 39),
|
|
56
|
+
yellow: $14c38dc11beadfaf$var$init(33, 39),
|
|
57
|
+
blue: $14c38dc11beadfaf$var$init(34, 39),
|
|
58
|
+
magenta: $14c38dc11beadfaf$var$init(35, 39),
|
|
59
|
+
cyan: $14c38dc11beadfaf$var$init(36, 39),
|
|
60
|
+
white: $14c38dc11beadfaf$var$init(37, 39),
|
|
61
|
+
gray: $14c38dc11beadfaf$var$init(90, 39),
|
|
62
|
+
bgBlack: $14c38dc11beadfaf$var$init(40, 49),
|
|
63
|
+
bgRed: $14c38dc11beadfaf$var$init(41, 49),
|
|
64
|
+
bgGreen: $14c38dc11beadfaf$var$init(42, 49),
|
|
65
|
+
bgYellow: $14c38dc11beadfaf$var$init(43, 49),
|
|
66
|
+
bgBlue: $14c38dc11beadfaf$var$init(44, 49),
|
|
67
|
+
bgMagenta: $14c38dc11beadfaf$var$init(45, 49),
|
|
68
|
+
bgCyan: $14c38dc11beadfaf$var$init(46, 49),
|
|
69
|
+
bgWhite: $14c38dc11beadfaf$var$init(47, 49),
|
|
70
|
+
blackBright: $14c38dc11beadfaf$var$init(90, 39),
|
|
71
|
+
redBright: $14c38dc11beadfaf$var$init(91, 39),
|
|
72
|
+
greenBright: $14c38dc11beadfaf$var$init(92, 39),
|
|
73
|
+
yellowBright: $14c38dc11beadfaf$var$init(93, 39),
|
|
74
|
+
blueBright: $14c38dc11beadfaf$var$init(94, 39),
|
|
75
|
+
magentaBright: $14c38dc11beadfaf$var$init(95, 39),
|
|
76
|
+
cyanBright: $14c38dc11beadfaf$var$init(96, 39),
|
|
77
|
+
whiteBright: $14c38dc11beadfaf$var$init(97, 39),
|
|
78
|
+
bgBlackBright: $14c38dc11beadfaf$var$init(100, 49),
|
|
79
|
+
bgRedBright: $14c38dc11beadfaf$var$init(101, 49),
|
|
80
|
+
bgGreenBright: $14c38dc11beadfaf$var$init(102, 49),
|
|
81
|
+
bgYellowBright: $14c38dc11beadfaf$var$init(103, 49),
|
|
82
|
+
bgBlueBright: $14c38dc11beadfaf$var$init(104, 49),
|
|
83
|
+
bgMagentaBright: $14c38dc11beadfaf$var$init(105, 49),
|
|
84
|
+
bgCyanBright: $14c38dc11beadfaf$var$init(106, 49),
|
|
85
|
+
bgWhiteBright: $14c38dc11beadfaf$var$init(107, 49)
|
|
86
|
+
};
|
|
87
|
+
const $14c38dc11beadfaf$export$fc3cc093e161d064 = ({ useColor: useColor = $14c38dc11beadfaf$export$ba7eaac21c385de8 } = {})=>useColor ? $14c38dc11beadfaf$var$colors : Object.keys($14c38dc11beadfaf$var$colors).reduce((colors, key)=>({
|
|
88
|
+
...colors,
|
|
89
|
+
[key]: String
|
|
90
|
+
}), {});
|
|
91
|
+
const { reset: $14c38dc11beadfaf$export$aad8462122ac592b , bold: $14c38dc11beadfaf$export$73ba5813cda80a49 , dim: $14c38dc11beadfaf$export$c96e90b4bcb7d4ca , italic: $14c38dc11beadfaf$export$5540da1282cbf565 , underline: $14c38dc11beadfaf$export$425327af25286e5e , inverse: $14c38dc11beadfaf$export$70ae2c07e401031b , hidden: $14c38dc11beadfaf$export$73920f18ca706874 , strikethrough: $14c38dc11beadfaf$export$19426ff118fe8be , black: $14c38dc11beadfaf$export$c073df10e766abfa , red: $14c38dc11beadfaf$export$a90204d1394caf30 , green: $14c38dc11beadfaf$export$955a2ebd2fb142ae , yellow: $14c38dc11beadfaf$export$594c5a8758200c32 , blue: $14c38dc11beadfaf$export$2aa0182783e7e9de , magenta: $14c38dc11beadfaf$export$2a9ca2e383622e18 , cyan: $14c38dc11beadfaf$export$7474046f446842ee , white: $14c38dc11beadfaf$export$8fa4e5556fd77a60 , gray: $14c38dc11beadfaf$export$3e2c219d3ab79d01 , bgBlack: $14c38dc11beadfaf$export$a91ca5b79f5fb26c , bgRed: $14c38dc11beadfaf$export$74a89e4512e7c91 , bgGreen: $14c38dc11beadfaf$export$8137d14243d019b3 , bgYellow: $14c38dc11beadfaf$export$3d3dcf8beff00fe1 , bgBlue: $14c38dc11beadfaf$export$ec69fb4048854b4 , bgMagenta: $14c38dc11beadfaf$export$76507b7995de3038 , bgCyan: $14c38dc11beadfaf$export$1b1236a85ae1b824 , bgWhite: $14c38dc11beadfaf$export$2fbae6ef3123e0b0 , blackBright: $14c38dc11beadfaf$export$c442bbc3ef058f3e , redBright: $14c38dc11beadfaf$export$6f940151fac4d6e4 , greenBright: $14c38dc11beadfaf$export$9e103086f7204459 , yellowBright: $14c38dc11beadfaf$export$106f17ac3545b17c , blueBright: $14c38dc11beadfaf$export$7aa4c9ef25eb1086 , magentaBright: $14c38dc11beadfaf$export$76b6abffe88e3179 , cyanBright: $14c38dc11beadfaf$export$c609d1d25ac1cc71 , whiteBright: $14c38dc11beadfaf$export$38b81c3a7de495d7 , bgBlackBright: $14c38dc11beadfaf$export$5c9c56f63b47e15b , bgRedBright: $14c38dc11beadfaf$export$26735259ab854b4f , bgGreenBright: $14c38dc11beadfaf$export$d5483c19744b2fc2 , bgYellowBright: $14c38dc11beadfaf$export$f8c17ad4aac14a99 , bgBlueBright: $14c38dc11beadfaf$export$6038eb5fdc315c12 , bgMagentaBright: $14c38dc11beadfaf$export$41148066f4812842 , bgCyanBright: $14c38dc11beadfaf$export$eb0dc7973d30eea7 , bgWhiteBright: $14c38dc11beadfaf$export$fde769fa8262c0d6 , } = $14c38dc11beadfaf$export$fc3cc093e161d064();
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
function $499e45cddca8ee5f$export$9abc0a414b0d8b8f(results) {
|
|
96
|
+
// sort by name and expiry descending
|
|
97
|
+
// takes the latest expiry for each name
|
|
98
|
+
const orderedResults = (0, $cMsgG$lodash.orderBy)(results, [
|
|
99
|
+
"name",
|
|
100
|
+
"expiry"
|
|
101
|
+
], [
|
|
102
|
+
"asc",
|
|
103
|
+
"desc"
|
|
104
|
+
]);
|
|
105
|
+
return (0, $cMsgG$lodash.uniqBy)(orderedResults, (r)=>r.name).map((r)=>r.name + "=" + r.value).join("; ");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
const $ab6a835953d78a50$export$a7b6bc01c63cdfc3 = {};
|
|
114
|
+
(0, $cMsgG$lodash.merge)($ab6a835953d78a50$export$a7b6bc01c63cdfc3, process.env);
|
|
115
|
+
const $ab6a835953d78a50$export$a7c5707626fc90f = $ab6a835953d78a50$export$a7b6bc01c63cdfc3["HOME"];
|
|
116
|
+
if (!$ab6a835953d78a50$export$a7c5707626fc90f) throw new Error("HOME environment variable is not set");
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class $d6ba105dc47b157f$export$55374e421ca433de extends (0, $cMsgG$toughcookie.Store) {
|
|
126
|
+
synchronous = false;
|
|
127
|
+
tasks = [];
|
|
128
|
+
constructor(filePath, internalStore = new (0, $cMsgG$toughcookie.MemoryCookieStore)()){
|
|
129
|
+
super();
|
|
130
|
+
this.filePath = filePath;
|
|
131
|
+
this.internalStore = internalStore ?? new (0, $cMsgG$toughcookie.MemoryCookieStore)();
|
|
132
|
+
console.log("Importing cookies from", filePath, internalStore);
|
|
133
|
+
this.tasks.push(this.importSaved(filePath, internalStore).then(console.log, console.error));
|
|
134
|
+
}
|
|
135
|
+
async importSaved(filePath, store) {
|
|
136
|
+
const cookies = [];
|
|
137
|
+
if ((0, $cMsgG$fs.existsSync)(filePath)) {
|
|
138
|
+
const data = (0, $cMsgG$fs.readFileSync)(filePath, "utf8");
|
|
139
|
+
const cookies1 = Object.values((0, ($parcel$interopDefault($cMsgG$destr)))(data)).flatMap((domainCookies)=>Object.values(domainCookies)).flatMap((domainCookies)=>Object.values(domainCookies));
|
|
140
|
+
console.log("Importing", cookies1.length, "cookies");
|
|
141
|
+
const array = Array.isArray(cookies1) ? cookies1 : Object.values(cookies1);
|
|
142
|
+
const put = await Promise.all(array.map((cookie)=>{
|
|
143
|
+
const fromJSON = (0, $cMsgG$toughcookie.Cookie).fromJSON(cookie);
|
|
144
|
+
if (fromJSON) return this.putCookieInternal(fromJSON, store);
|
|
145
|
+
}));
|
|
146
|
+
cookies1.push(...put);
|
|
147
|
+
}
|
|
148
|
+
return cookies;
|
|
149
|
+
}
|
|
150
|
+
findCookie(domain, path, key, cb) {
|
|
151
|
+
this.waitUntilIdle().finally(()=>{
|
|
152
|
+
this.internalStore.findCookie(domain, path, key, cb);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
findCookies(domain, path, allowSpecialUseDomain, cb) {
|
|
156
|
+
this.waitUntilIdle().finally(()=>{
|
|
157
|
+
this.internalStore.findCookies(domain, path, allowSpecialUseDomain, cb);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
putCookie(cookie, cb) {
|
|
161
|
+
this.internalStore.putCookie(cookie, cb);
|
|
162
|
+
this.internalStore.getAllCookies((err, cookies)=>{
|
|
163
|
+
this.serializeCallback(err, cookies);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
updateCookie(oldCookie, newCookie, cb) {
|
|
167
|
+
this.internalStore.updateCookie(oldCookie, newCookie, cb);
|
|
168
|
+
this.internalStore.getAllCookies((err, cookies)=>{
|
|
169
|
+
this.serializeCallback(err, cookies);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
removeCookie(domain, path, key, cb) {
|
|
173
|
+
this.internalStore.removeCookie(domain, path, key, cb);
|
|
174
|
+
this.internalStore.getAllCookies((err, cookies)=>{
|
|
175
|
+
this.serializeCallback(err, cookies);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
removeCookies(domain, path, cb) {
|
|
179
|
+
this.internalStore.removeCookies(domain, path, cb);
|
|
180
|
+
this.internalStore.getAllCookies((err, cookies)=>{
|
|
181
|
+
this.serializeCallback(err, cookies);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
getAllCookies(cb) {
|
|
185
|
+
this.waitUntilIdle().finally(()=>{
|
|
186
|
+
this.internalStore.getAllCookies(cb);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
waitUntilIdle() {
|
|
190
|
+
return Promise.allSettled(this.tasks).catch(console.error);
|
|
191
|
+
}
|
|
192
|
+
async putCookieInternal(cookie, store) {
|
|
193
|
+
await this.waitUntilIdle();
|
|
194
|
+
return await new Promise((resolve, reject)=>{
|
|
195
|
+
store.putCookie(cookie, (err)=>{
|
|
196
|
+
if (err) reject(err);
|
|
197
|
+
else resolve(cookie);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
serializeCallback(err, cookies) {
|
|
202
|
+
if (err) {
|
|
203
|
+
console.error(err);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const cookieObjs = cookies.map((cookie)=>cookie);
|
|
207
|
+
const idx = {};
|
|
208
|
+
for (const cookie of cookieObjs){
|
|
209
|
+
const domain = cookie.domain;
|
|
210
|
+
if (typeof domain === "string") {
|
|
211
|
+
const path = cookie.path ?? "/";
|
|
212
|
+
const key = cookie.key;
|
|
213
|
+
(0, $cMsgG$lodash.merge)(idx, {
|
|
214
|
+
[domain]: {
|
|
215
|
+
[path]: {
|
|
216
|
+
[key]: cookie.toJSON()
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const stringify = JSON.stringify(idx, null, 2);
|
|
223
|
+
(0, $cMsgG$fs.writeFile)(this.filePath, stringify, (err)=>{
|
|
224
|
+
if (err) console.error(err);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
const $fad025d072e806d0$var$memoryCookieStore = new (0, $cMsgG$toughcookie.MemoryCookieStore)();
|
|
231
|
+
async function $fad025d072e806d0$var$getCookieStore() {
|
|
232
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["cs"] == "memory") return $fad025d072e806d0$var$memoryCookieStore;
|
|
233
|
+
const fileCookieStore = new (0, $d6ba105dc47b157f$export$55374e421ca433de)(`${(0, $ab6a835953d78a50$export$a7b6bc01c63cdfc3)["HOME"]}/cookie-star.json`, $fad025d072e806d0$var$memoryCookieStore);
|
|
234
|
+
await fileCookieStore.waitUntilIdle();
|
|
235
|
+
return fileCookieStore;
|
|
236
|
+
}
|
|
237
|
+
const $fad025d072e806d0$export$2c043f03eceff4e8 = new Promise((resolve)=>{
|
|
238
|
+
$fad025d072e806d0$var$getCookieStore().then(resolve);
|
|
239
|
+
});
|
|
240
|
+
const $fad025d072e806d0$export$eced8873dedbb4c0 = new Promise((resolve)=>{
|
|
241
|
+
$fad025d072e806d0$export$2c043f03eceff4e8.then((store)=>new (0, $cMsgG$toughcookie.CookieJar)(store)).then(resolve);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
async function $85bf79029ec33db0$export$8d71c74f97c0202e(command) {
|
|
253
|
+
return new Promise((resolve, reject)=>{
|
|
254
|
+
(0, $cMsgG$child_process.exec)(command, {
|
|
255
|
+
encoding: "binary",
|
|
256
|
+
maxBuffer: 5120
|
|
257
|
+
}, (error, stdout, stderr)=>{
|
|
258
|
+
if (error) {
|
|
259
|
+
reject(error);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (stderr) {
|
|
263
|
+
reject(error);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (stdout) resolve(stdout.trim());
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
async function $0f9e65bbe95be4b5$export$2c9faf86071156ae({ path: path , name: name , maxDepth: maxDepth = 2 }) {
|
|
277
|
+
const rootSegments = path.split("/").length;
|
|
278
|
+
const files = [];
|
|
279
|
+
let readdirSync;
|
|
280
|
+
try {
|
|
281
|
+
readdirSync = $cMsgG$fs.readdirSync(path);
|
|
282
|
+
} catch (e) {
|
|
283
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log(`Error reading ${path}`, e);
|
|
284
|
+
return [];
|
|
285
|
+
}
|
|
286
|
+
for (const file of readdirSync){
|
|
287
|
+
const filePath = path + "/" + file;
|
|
288
|
+
let stat;
|
|
289
|
+
try {
|
|
290
|
+
stat = $cMsgG$fs.statSync(filePath);
|
|
291
|
+
} catch (e1) {
|
|
292
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.error(`Error getting stat for ${filePath}`, e1);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (stat.isDirectory()) {
|
|
296
|
+
if (filePath.split("/").length < rootSegments + maxDepth) try {
|
|
297
|
+
const subFiles = await $0f9e65bbe95be4b5$export$2c9faf86071156ae({
|
|
298
|
+
path: filePath,
|
|
299
|
+
name: name,
|
|
300
|
+
maxDepth: 2
|
|
301
|
+
});
|
|
302
|
+
files.push(...subFiles);
|
|
303
|
+
} catch (e2) {
|
|
304
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.error(e2);
|
|
305
|
+
}
|
|
306
|
+
} else if (file === name) files.push(filePath);
|
|
307
|
+
}
|
|
308
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) {
|
|
309
|
+
if (files.length > 0) {
|
|
310
|
+
console.log(`Found ${files.length} ${name} files`);
|
|
311
|
+
console.log(files);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return files;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
function $8f9775edfb331e8f$export$bc926c43858bd3cb(obj) {
|
|
322
|
+
return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
function $6190e43d7270fb00$export$963c8d651337e4a4(obj) {
|
|
327
|
+
return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
function $804e67849976ffdb$export$4eadcf0bf35a2ddb(s) {
|
|
332
|
+
const s1 = s.replaceAll(/\./gi, ".");
|
|
333
|
+
const s2 = s1.replace(/%/g, ".*");
|
|
334
|
+
const s3 = s2.replace(/\*/g, ".*");
|
|
335
|
+
return new RegExp(s3);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
class $50e0b48eb429d6c2$export$2e2bcd8739ae039 {
|
|
342
|
+
browserName = "Chrome";
|
|
343
|
+
async queryCookies(name, domain) {
|
|
344
|
+
if (process.platform !== "darwin") throw new Error("This only works on macOS");
|
|
345
|
+
if ((0, $ab6a835953d78a50$export$a7b6bc01c63cdfc3).FIREFOX_ONLY) return [];
|
|
346
|
+
return $50e0b48eb429d6c2$var$getChromeCookies({
|
|
347
|
+
requireJwt: false,
|
|
348
|
+
name: name,
|
|
349
|
+
domain: domain
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
async function $50e0b48eb429d6c2$var$getPromise1(name, domain, file) {
|
|
354
|
+
try {
|
|
355
|
+
return await $50e0b48eb429d6c2$var$getEncryptedChromeCookie({
|
|
356
|
+
name: name,
|
|
357
|
+
domain: domain,
|
|
358
|
+
file: file
|
|
359
|
+
});
|
|
360
|
+
} catch (e) {
|
|
361
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("Error getting encrypted cookie", e);
|
|
362
|
+
return [];
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
async function $50e0b48eb429d6c2$var$getPromise(name, domain) {
|
|
366
|
+
try {
|
|
367
|
+
const files = await (0, $0f9e65bbe95be4b5$export$2c9faf86071156ae)({
|
|
368
|
+
path: $50e0b48eb429d6c2$var$chromeLocal,
|
|
369
|
+
name: "Cookies"
|
|
370
|
+
});
|
|
371
|
+
const promises = files.map((file)=>$50e0b48eb429d6c2$var$getPromise1(name, domain, file));
|
|
372
|
+
const results1 = await Promise.all(promises);
|
|
373
|
+
return results1.flat().filter((0, $8f9775edfb331e8f$export$bc926c43858bd3cb));
|
|
374
|
+
} catch (error) {
|
|
375
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("error", error);
|
|
376
|
+
return [];
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
async function $50e0b48eb429d6c2$var$decryptValue(password, encryptedValue) {
|
|
380
|
+
let d;
|
|
381
|
+
try {
|
|
382
|
+
d = await $50e0b48eb429d6c2$var$decrypt(password, encryptedValue);
|
|
383
|
+
} catch (e) {
|
|
384
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("Error decrypting cookie", e);
|
|
385
|
+
d = null;
|
|
386
|
+
}
|
|
387
|
+
return d ?? encryptedValue.toString("utf-8");
|
|
388
|
+
}
|
|
389
|
+
async function $50e0b48eb429d6c2$var$getChromeCookies({ name: name , domain: domain = "%" , requireJwt: requireJwt = false }) {
|
|
390
|
+
const encryptedDataItems = await $50e0b48eb429d6c2$var$getPromise(name, domain);
|
|
391
|
+
const password = await $50e0b48eb429d6c2$var$getChromePassword();
|
|
392
|
+
const decrypted = encryptedDataItems.filter(({ value: value })=>value != null && value.length > 0).map(async (cookieRow)=>{
|
|
393
|
+
const encryptedValue = cookieRow.value;
|
|
394
|
+
const decryptedValue = await $50e0b48eb429d6c2$var$decryptValue(password, encryptedValue);
|
|
395
|
+
const meta = {};
|
|
396
|
+
(0, $cMsgG$lodash.merge)(meta, cookieRow.meta ?? {});
|
|
397
|
+
const exportedCookie = {
|
|
398
|
+
domain: cookieRow.domain,
|
|
399
|
+
name: cookieRow.name,
|
|
400
|
+
value: decryptedValue,
|
|
401
|
+
meta: meta
|
|
402
|
+
};
|
|
403
|
+
const expiry = cookieRow.expiry;
|
|
404
|
+
const mergeExpiry = expiry != null && expiry > 0 ? {
|
|
405
|
+
expiry: new Date(expiry)
|
|
406
|
+
} : {
|
|
407
|
+
expiry: "Infinity"
|
|
408
|
+
};
|
|
409
|
+
(0, $cMsgG$lodash.merge)(exportedCookie, mergeExpiry);
|
|
410
|
+
return exportedCookie;
|
|
411
|
+
});
|
|
412
|
+
const results = (await Promise.all(decrypted)).filter((0, $6190e43d7270fb00$export$963c8d651337e4a4));
|
|
413
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("results", results);
|
|
414
|
+
return results;
|
|
415
|
+
}
|
|
416
|
+
const $50e0b48eb429d6c2$var$chromeLocal = $cMsgG$path.join((0, $ab6a835953d78a50$export$a7c5707626fc90f), "Library", "Application Support", "Google", "Chrome");
|
|
417
|
+
async function $50e0b48eb429d6c2$var$getEncryptedChromeCookie({ name: name , domain: domain , file: file = $cMsgG$path.join($50e0b48eb429d6c2$var$chromeLocal, "Default", "Cookies") }) {
|
|
418
|
+
if (!(0, $cMsgG$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
|
|
419
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) {
|
|
420
|
+
const s = file.split("/").slice(-3).join("/");
|
|
421
|
+
console.log(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);
|
|
422
|
+
}
|
|
423
|
+
let sql;
|
|
424
|
+
//language=SQL
|
|
425
|
+
sql = "SELECT * FROM cookies";
|
|
426
|
+
// sql = "SELECT encrypted_value, name, host_key FROM cookies";
|
|
427
|
+
const wildcardRegexp = /^([*%])$/i;
|
|
428
|
+
const specifiedName = name.match(wildcardRegexp) == null;
|
|
429
|
+
const specifiedDomain = domain.match(wildcardRegexp) == null;
|
|
430
|
+
const wildcardDomain = domain.match(/[%*]/) != null;
|
|
431
|
+
const queryDomain = specifiedDomain && !wildcardDomain;
|
|
432
|
+
// if we have a wildcard domain, we need to use a regexp
|
|
433
|
+
if (specifiedName || queryDomain) {
|
|
434
|
+
sql += ` WHERE `;
|
|
435
|
+
if (specifiedName) {
|
|
436
|
+
sql += `name = '${name}'`;
|
|
437
|
+
if (queryDomain) sql += ` AND `;
|
|
438
|
+
}
|
|
439
|
+
if (queryDomain) {
|
|
440
|
+
// leading dot replaced with % to match subdomains
|
|
441
|
+
const sqlEmbedDomain = domain.replace(/^[.%]?/, "%");
|
|
442
|
+
sql += `host_key LIKE '${sqlEmbedDomain}';`;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("sql", sql);
|
|
446
|
+
const domainRegexp = (0, $804e67849976ffdb$export$4eadcf0bf35a2ddb)(domain);
|
|
447
|
+
const sqliteQuery1 = await $50e0b48eb429d6c2$export$bd52b72df8d0d261({
|
|
448
|
+
file: file,
|
|
449
|
+
sql: sql,
|
|
450
|
+
rowFilter: (row)=>{
|
|
451
|
+
return row["host_key"].match(domainRegexp) != null;
|
|
452
|
+
},
|
|
453
|
+
rowTransform: (row)=>{
|
|
454
|
+
const cookieRow = {
|
|
455
|
+
expiry: (row["expires_utc"] / 1000000 - 11644473600) * 1000,
|
|
456
|
+
domain: row["host_key"],
|
|
457
|
+
name: row["name"],
|
|
458
|
+
value: row["encrypted_value"]
|
|
459
|
+
};
|
|
460
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("CookieRow", cookieRow);
|
|
461
|
+
return cookieRow;
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
return sqliteQuery1.filter((row)=>{
|
|
465
|
+
return row.domain.match(domainRegexp) != null;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
async function $50e0b48eb429d6c2$var$getChromePassword() {
|
|
469
|
+
return (0, $85bf79029ec33db0$export$8d71c74f97c0202e)('security find-generic-password -w -s "Chrome Safe Storage"');
|
|
470
|
+
}
|
|
471
|
+
async function $50e0b48eb429d6c2$var$decrypt(password, encryptedData) {
|
|
472
|
+
if (typeof password !== "string") throw new Error("password must be a string: " + password);
|
|
473
|
+
let encryptedData1;
|
|
474
|
+
encryptedData1 = encryptedData;
|
|
475
|
+
if (encryptedData1 == null || typeof encryptedData1 !== "object") throw new Error("encryptedData must be a object: " + encryptedData1);
|
|
476
|
+
if (!(encryptedData1 instanceof Buffer)) {
|
|
477
|
+
if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {
|
|
478
|
+
[encryptedData1] = encryptedData1;
|
|
479
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log(`encryptedData is an array of buffers, selected first: ${encryptedData1}`);
|
|
480
|
+
} else throw new Error("encryptedData must be a Buffer: " + encryptedData1);
|
|
481
|
+
encryptedData1 = Buffer.from(encryptedData1);
|
|
482
|
+
}
|
|
483
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log(`Trying to decrypt with password ${password}`);
|
|
484
|
+
return new Promise((resolve, reject)=>{
|
|
485
|
+
$cMsgG$crypto.pbkdf2(password, "saltysalt", 1003, 16, "sha1", (error, buffer)=>{
|
|
486
|
+
try {
|
|
487
|
+
if (error) {
|
|
488
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("Error doing pbkdf2", error);
|
|
489
|
+
reject(error);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (buffer.length !== 16) {
|
|
493
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("Error doing pbkdf2, buffer length is not 16", buffer.length);
|
|
494
|
+
reject(new Error("Buffer length is not 16"));
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const str = new Array(17).join(" ");
|
|
498
|
+
const iv = Buffer.from(str, "binary");
|
|
499
|
+
const decipher = $cMsgG$crypto.createDecipheriv("aes-128-cbc", buffer, iv);
|
|
500
|
+
decipher.setAutoPadding(false);
|
|
501
|
+
if (encryptedData1 && encryptedData1.slice) encryptedData1 = encryptedData1.slice(3);
|
|
502
|
+
if (encryptedData1.length % 16 !== 0) {
|
|
503
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("Error doing pbkdf2, encryptedData length is not a multiple of 16", encryptedData1.length);
|
|
504
|
+
reject(new Error("encryptedData length is not a multiple of 16"));
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
let decoded = decipher.update(encryptedData1);
|
|
508
|
+
try {
|
|
509
|
+
decipher.final("utf-8");
|
|
510
|
+
} catch (e) {
|
|
511
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("Error doing decipher.final()", e);
|
|
512
|
+
reject(e);
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
const padding = decoded[decoded.length - 1];
|
|
516
|
+
if (padding) decoded = decoded.slice(0, 0 - padding);
|
|
517
|
+
// noinspection JSCheckFunctionSignatures
|
|
518
|
+
const decodedString = decoded.toString("utf8");
|
|
519
|
+
resolve(decodedString);
|
|
520
|
+
} catch (e1) {
|
|
521
|
+
reject(e1);
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
async function $50e0b48eb429d6c2$export$bd52b72df8d0d261({ file: file , sql: sql , rowFilter: rowFilter = ()=>true , rowTransform: rowTransform }) {
|
|
527
|
+
if (!file || file && !(0, ($parcel$interopDefault($cMsgG$fs))).existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
|
|
528
|
+
const db = new $cMsgG$sqlite3.Database(file);
|
|
529
|
+
return new Promise((resolve, reject)=>{
|
|
530
|
+
db.all(sql, (err, rows)=>{
|
|
531
|
+
if (err) {
|
|
532
|
+
reject(err);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
const rows1 = rows;
|
|
536
|
+
if (rows1 == null || rows1.length === 0) {
|
|
537
|
+
resolve([]);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (Array.isArray(rows1)) {
|
|
541
|
+
const cookieRows = rows1.filter(rowFilter).map((row)=>{
|
|
542
|
+
const newVar = {
|
|
543
|
+
meta: {
|
|
544
|
+
file: file
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
const cookieRow = rowTransform(row);
|
|
548
|
+
return (0, $cMsgG$lodash.merge)(newVar, cookieRow);
|
|
549
|
+
});
|
|
550
|
+
resolve(cookieRows);
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);
|
|
554
|
+
resolve([
|
|
555
|
+
rows1
|
|
556
|
+
]);
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
function $21b9a65cfb44c163$export$da22813e5a2ec500({ name: name , domain: domain }) {
|
|
567
|
+
const wildcardRegexp = /^([*%])$/i;
|
|
568
|
+
return {
|
|
569
|
+
specifiedName: name.match(wildcardRegexp) == null,
|
|
570
|
+
specifiedDomain: domain.match(wildcardRegexp) == null
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
async function $31b10c081e582091$export$f19f611d1fa7c6f3({ file: file , sql: sql , rowTransform: rowTransform }) {
|
|
579
|
+
if (!file || file && !(0, ($parcel$interopDefault($cMsgG$fs))).existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
|
|
580
|
+
const db = new $cMsgG$sqlite3.Database(file);
|
|
581
|
+
return new Promise((resolve, reject)=>{
|
|
582
|
+
db.all(sql, (err, rows)=>{
|
|
583
|
+
if (err) {
|
|
584
|
+
reject(err);
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
const rows1 = rows;
|
|
588
|
+
if (rows1 == null || rows1.length === 0) {
|
|
589
|
+
resolve([]);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (Array.isArray(rows1)) {
|
|
593
|
+
const cookieRows = rows1.map((row)=>{
|
|
594
|
+
const newVar = {
|
|
595
|
+
meta: {
|
|
596
|
+
file: file
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
const cookieRow = rowTransform(row);
|
|
600
|
+
return (0, $cMsgG$lodash.merge)(newVar, cookieRow);
|
|
601
|
+
});
|
|
602
|
+
resolve(cookieRows);
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);
|
|
606
|
+
resolve([
|
|
607
|
+
rows1
|
|
608
|
+
]);
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
class $31b10c081e582091$export$2e2bcd8739ae039 {
|
|
613
|
+
browserName = "Firefox";
|
|
614
|
+
async queryCookies(name, domain) {
|
|
615
|
+
if (process.platform !== "darwin") // TODO: implement
|
|
616
|
+
return [];
|
|
617
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).browser !== "firefox") return [];
|
|
618
|
+
const cookies = await this.#getFirefoxCookie({
|
|
619
|
+
name: name,
|
|
620
|
+
domain: domain
|
|
621
|
+
});
|
|
622
|
+
if (Array.isArray(cookies)) return cookies.map((cookie)=>{
|
|
623
|
+
return {
|
|
624
|
+
domain: cookie.domain,
|
|
625
|
+
name: cookie.name,
|
|
626
|
+
value: cookie.value.toString("utf8")
|
|
627
|
+
};
|
|
628
|
+
});
|
|
629
|
+
else return [];
|
|
630
|
+
}
|
|
631
|
+
async #getFirefoxCookie({ name: name , domain: domain } //
|
|
632
|
+
) {
|
|
633
|
+
const files = await (0, $0f9e65bbe95be4b5$export$2c9faf86071156ae)({
|
|
634
|
+
path: $cMsgG$path.join((0, $ab6a835953d78a50$export$a7c5707626fc90f), "Library", "Application Support", "Firefox", "Profiles"),
|
|
635
|
+
name: "cookies.sqlite"
|
|
636
|
+
});
|
|
637
|
+
const fn = async (file)=>{
|
|
638
|
+
return await this.#queryCookiesDb(file, name, domain);
|
|
639
|
+
};
|
|
640
|
+
const all = await Promise.all(files.map(fn));
|
|
641
|
+
// flatten
|
|
642
|
+
return all.flat();
|
|
643
|
+
}
|
|
644
|
+
async #queryCookiesDb(file, name1, domain1) {
|
|
645
|
+
if (file && !(0, $cMsgG$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
|
|
646
|
+
let sql;
|
|
647
|
+
//language=SQL
|
|
648
|
+
sql = "SELECT value, name, host FROM moz_cookies";
|
|
649
|
+
const { specifiedName: specifiedName , specifiedDomain: specifiedDomain } = (0, $21b9a65cfb44c163$export$da22813e5a2ec500)({
|
|
650
|
+
name: name1,
|
|
651
|
+
domain: domain1
|
|
652
|
+
});
|
|
653
|
+
if (specifiedName || specifiedDomain) {
|
|
654
|
+
sql += ` WHERE `;
|
|
655
|
+
if (specifiedName) {
|
|
656
|
+
sql += `name = '${name1}'`;
|
|
657
|
+
if (specifiedDomain) sql += ` AND `;
|
|
658
|
+
}
|
|
659
|
+
if (specifiedDomain) sql += `host LIKE '${domain1}';`;
|
|
660
|
+
}
|
|
661
|
+
const rowTransform = (row)=>{
|
|
662
|
+
// row is object key by column name
|
|
663
|
+
const value = row.value;
|
|
664
|
+
return {
|
|
665
|
+
domain: row.domain,
|
|
666
|
+
name: row.name,
|
|
667
|
+
value: Buffer.from(value, "utf8")
|
|
668
|
+
};
|
|
669
|
+
};
|
|
670
|
+
try {
|
|
671
|
+
return await $31b10c081e582091$export$f19f611d1fa7c6f3({
|
|
672
|
+
file: file,
|
|
673
|
+
sql: sql,
|
|
674
|
+
rowTransform: rowTransform
|
|
675
|
+
});
|
|
676
|
+
} catch (e) {
|
|
677
|
+
console.error(`Error querying ${file}`, e);
|
|
678
|
+
return [];
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
class $6f1d09c5ec49fdc6$export$2e2bcd8739ae039 {
|
|
685
|
+
browserName = "Safari";
|
|
686
|
+
async queryCookies(name, domain) {
|
|
687
|
+
// TODO: implement
|
|
688
|
+
return [];
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
class $6f131982bdd0218c$export$2e2bcd8739ae039 {
|
|
697
|
+
browserName = "internal";
|
|
698
|
+
async queryCookies(name, domain) {
|
|
699
|
+
const exportedCookies = [];
|
|
700
|
+
// if (name.match(/[%*]/) || domain.match(/[%*]/)) {
|
|
701
|
+
const cookies = await this.#getAllCookies();
|
|
702
|
+
const allExportedCookies = cookies.map((cookie)=>{
|
|
703
|
+
return this.#extracted(cookie, {
|
|
704
|
+
name: name,
|
|
705
|
+
domain: domain
|
|
706
|
+
});
|
|
707
|
+
});
|
|
708
|
+
exportedCookies.push(...allExportedCookies);
|
|
709
|
+
// }
|
|
710
|
+
const wildcardRegexp = /^([*%])$/i;
|
|
711
|
+
if (name.match(wildcardRegexp) && domain.match(wildcardRegexp)) return exportedCookies;
|
|
712
|
+
const path = "/";
|
|
713
|
+
if (domain != "%") {
|
|
714
|
+
const domain1 = domain.match(/(\w+.+\w+)/gi)?.pop() ?? domain;
|
|
715
|
+
const url = new URL("https://" + domain1);
|
|
716
|
+
url.pathname = path;
|
|
717
|
+
const cookies1 = await this.#getCookies(url.href);
|
|
718
|
+
const domainCookies = cookies1.map((cookie)=>{
|
|
719
|
+
return this.#extracted(cookie, {
|
|
720
|
+
domain: domain,
|
|
721
|
+
name: name
|
|
722
|
+
});
|
|
723
|
+
});
|
|
724
|
+
exportedCookies.push(...domainCookies);
|
|
725
|
+
}
|
|
726
|
+
if (name == "%") return exportedCookies.filter((cookie)=>{
|
|
727
|
+
return cookie.domain.match((0, $804e67849976ffdb$export$4eadcf0bf35a2ddb)(domain));
|
|
728
|
+
});
|
|
729
|
+
return exportedCookies.filter((cookie)=>{
|
|
730
|
+
return cookie.name.match((0, $804e67849976ffdb$export$4eadcf0bf35a2ddb)(name)) && cookie.domain.match((0, $804e67849976ffdb$export$4eadcf0bf35a2ddb)(domain));
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
#extracted(cookie, cookieSpec) {
|
|
734
|
+
return {
|
|
735
|
+
domain: cookie.domain ?? cookieSpec.domain,
|
|
736
|
+
name: cookie.key ?? cookieSpec.name,
|
|
737
|
+
value: cookie.value,
|
|
738
|
+
expiry: cookie.expires ?? "Infinity",
|
|
739
|
+
meta: {
|
|
740
|
+
file: "tough-cookie"
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
async #getCookies(url) {
|
|
745
|
+
const cookieJar = await (0, $fad025d072e806d0$export$eced8873dedbb4c0);
|
|
746
|
+
return new Promise((resolve, reject)=>{
|
|
747
|
+
return cookieJar.getCookies(url, (err, cookies)=>{
|
|
748
|
+
if (err) reject(err);
|
|
749
|
+
else resolve(cookies ?? []);
|
|
750
|
+
});
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
async #getAllCookies() {
|
|
754
|
+
const cookieStore = await (0, $fad025d072e806d0$export$2c043f03eceff4e8);
|
|
755
|
+
return new Promise((resolve, reject)=>{
|
|
756
|
+
return cookieStore.getAllCookies((err, cookies)=>{
|
|
757
|
+
if (err) reject(err);
|
|
758
|
+
else resolve(cookies ?? []);
|
|
759
|
+
});
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
const $27eb81da92769162$var$cache = new (0, ($parcel$interopDefault($cMsgG$lrucache)))({
|
|
769
|
+
ttl: 2000,
|
|
770
|
+
max: 10
|
|
771
|
+
});
|
|
772
|
+
class $27eb81da92769162$export$2e2bcd8739ae039 {
|
|
773
|
+
browserName = "all";
|
|
774
|
+
#strategies;
|
|
775
|
+
constructor(){
|
|
776
|
+
this.#strategies = [
|
|
777
|
+
(0, $6f131982bdd0218c$export$2e2bcd8739ae039),
|
|
778
|
+
(0, $50e0b48eb429d6c2$export$2e2bcd8739ae039),
|
|
779
|
+
(0, $31b10c081e582091$export$2e2bcd8739ae039),
|
|
780
|
+
(0, $6f1d09c5ec49fdc6$export$2e2bcd8739ae039),
|
|
781
|
+
].map((strategy)=>{
|
|
782
|
+
return new strategy();
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
async queryCookies(name, domain) {
|
|
786
|
+
// domain = domain.match(/(\w+.+\w+)/gi)?.pop() ?? domain;
|
|
787
|
+
const key = `${name}:${domain}`;
|
|
788
|
+
const cached = $27eb81da92769162$var$cache.get(key);
|
|
789
|
+
if (cached) return cached;
|
|
790
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("Querying cookies:", name, domain);
|
|
791
|
+
const results = await Promise.all(this.#strategies.map(async (strategy)=>{
|
|
792
|
+
// @ts-ignore
|
|
793
|
+
return strategy.queryCookies(name, domain).then((cookies)=>{
|
|
794
|
+
return cookies.map((cookie)=>{
|
|
795
|
+
return (0, $cMsgG$lodash.merge)(cookie, {
|
|
796
|
+
meta: {
|
|
797
|
+
browser: strategy.browserName
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
});
|
|
801
|
+
}).catch((e)=>{
|
|
802
|
+
console.log((0, $14c38dc11beadfaf$export$a90204d1394caf30)(`Error querying ${strategy.browserName} cookies`), e);
|
|
803
|
+
return [];
|
|
804
|
+
});
|
|
805
|
+
}));
|
|
806
|
+
const flat = results.flat();
|
|
807
|
+
$27eb81da92769162$var$cache.set(`${name}:${domain}`, flat);
|
|
808
|
+
return flat;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
function $57733ace45e3aeb7$export$2e2bcd8739ae039(token) {
|
|
816
|
+
try {
|
|
817
|
+
const result = (0, ($parcel$interopDefault($cMsgG$jsonwebtoken))).decode(token, {
|
|
818
|
+
complete: true
|
|
819
|
+
});
|
|
820
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose && result) console.log(result);
|
|
821
|
+
const payload = result?.payload;
|
|
822
|
+
if (payload) {
|
|
823
|
+
const exp = payload.exp;
|
|
824
|
+
if (exp) {
|
|
825
|
+
const now = new Date().getTime() / 1000;
|
|
826
|
+
if (now > exp) return false;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
return true;
|
|
830
|
+
} catch (err) {
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
async function $aa936ebb6e4b9688$export$e6d428437cf2cacb({ name: name , domain: domain }, strategy = new (0, $27eb81da92769162$export$2e2bcd8739ae039)()) {
|
|
837
|
+
const results = await strategy.queryCookies(name, domain);
|
|
838
|
+
const allCookies = (0, $cMsgG$lodash.uniqBy)(results, JSON.stringify);
|
|
839
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["require-jwt"]) {
|
|
840
|
+
const jwtCookies = [];
|
|
841
|
+
for (const result of allCookies){
|
|
842
|
+
const value = result.value;
|
|
843
|
+
if ((0, $57733ace45e3aeb7$export$2e2bcd8739ae039)(value)) jwtCookies.push(result);
|
|
844
|
+
}
|
|
845
|
+
return (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["single"] ? [
|
|
846
|
+
jwtCookies[0]
|
|
847
|
+
] : jwtCookies;
|
|
848
|
+
} else return (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["single"] ? [
|
|
849
|
+
allCookies[0]
|
|
850
|
+
] : allCookies;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
async function $0277fbedbad8c779$export$a65902517ae87ba8(cookieSpec) {
|
|
856
|
+
const cookies = [];
|
|
857
|
+
if (Array.isArray(cookieSpec)) {
|
|
858
|
+
const results = await Promise.all(cookieSpec.map((cs)=>{
|
|
859
|
+
return (0, $aa936ebb6e4b9688$export$e6d428437cf2cacb)(cs);
|
|
860
|
+
}));
|
|
861
|
+
for (const exportedCookie of results.flat())cookies.push(exportedCookie);
|
|
862
|
+
} else {
|
|
863
|
+
const singleQuery = await (0, $aa936ebb6e4b9688$export$e6d428437cf2cacb)(cookieSpec);
|
|
864
|
+
cookies.push(...singleQuery);
|
|
865
|
+
}
|
|
866
|
+
return (0, $cMsgG$lodash.uniqBy)(cookies, JSON.stringify);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
async function $ac4289810ee8650c$export$cfc0723de5712e57(cookieSpec) {
|
|
871
|
+
const cookies = await (0, $0277fbedbad8c779$export$a65902517ae87ba8)(cookieSpec);
|
|
872
|
+
if (cookies.length > 0) return (0, $499e45cddca8ee5f$export$9abc0a414b0d8b8f)(cookies);
|
|
873
|
+
return "";
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
function $b32860efe238f1f1$export$f266452a5050185d(url) {
|
|
879
|
+
const url1 = typeof url == "string" ? new URL(url) : url;
|
|
880
|
+
const cookieSpecs = [];
|
|
881
|
+
const splits = url1.hostname.split(".");
|
|
882
|
+
const tld = splits.slice(-2).join(".");
|
|
883
|
+
const cookieSpec = {
|
|
884
|
+
name: "%",
|
|
885
|
+
domain: "%." + tld
|
|
886
|
+
};
|
|
887
|
+
cookieSpecs.push(cookieSpec);
|
|
888
|
+
const cookieSpec1 = {
|
|
889
|
+
name: "%",
|
|
890
|
+
domain: url1.hostname
|
|
891
|
+
};
|
|
892
|
+
cookieSpecs.push(cookieSpec1);
|
|
893
|
+
// const isWww = splits.slice(-3)[0] === "www";
|
|
894
|
+
const cookieSpec2 = {
|
|
895
|
+
name: "%",
|
|
896
|
+
domain: tld
|
|
897
|
+
};
|
|
898
|
+
cookieSpecs.push(cookieSpec2);
|
|
899
|
+
return (0, $cMsgG$lodash.uniqBy)(cookieSpecs, JSON.stringify);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
const $72b72bc713ce1262$var$userAgent = new (0, ($parcel$interopDefault($cMsgG$useragents)))().toString();
|
|
904
|
+
async function $72b72bc713ce1262$export$b24a545a0b39f491(url, options = {}, fetch = (0, $cMsgG$crossfetch.fetch), originalRequest) {
|
|
905
|
+
const originalRequest1 = originalRequest || {
|
|
906
|
+
url: url,
|
|
907
|
+
options: options
|
|
908
|
+
};
|
|
909
|
+
const headers = {
|
|
910
|
+
"User-Agent": $72b72bc713ce1262$var$userAgent
|
|
911
|
+
};
|
|
912
|
+
const defaultOptions = {
|
|
913
|
+
headers: headers,
|
|
914
|
+
redirect: "manual"
|
|
915
|
+
};
|
|
916
|
+
const url2 = `${url}`;
|
|
917
|
+
const url1 = new URL(url2);
|
|
918
|
+
const cookieSpecs = (0, $b32860efe238f1f1$export$f266452a5050185d)(url1);
|
|
919
|
+
headers["Cookie"] = await (0, $ac4289810ee8650c$export$cfc0723de5712e57)(cookieSpecs).catch(()=>"");
|
|
920
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["dump-request-headers"]) {
|
|
921
|
+
console.log((0, $14c38dc11beadfaf$export$6f940151fac4d6e4)("Request URL:"), url1.href);
|
|
922
|
+
console.log((0, $14c38dc11beadfaf$export$2aa0182783e7e9de)("Request headers:"), headers);
|
|
923
|
+
}
|
|
924
|
+
const newOptions1 = (0, $cMsgG$lodash.merge)(defaultOptions, {
|
|
925
|
+
headers: headers
|
|
926
|
+
}, options);
|
|
927
|
+
try {
|
|
928
|
+
const res = await fetch(url1, newOptions1);
|
|
929
|
+
const headers1 = [];
|
|
930
|
+
res.headers.forEach((value, key)=>{
|
|
931
|
+
headers1.push([
|
|
932
|
+
key,
|
|
933
|
+
value
|
|
934
|
+
]);
|
|
935
|
+
});
|
|
936
|
+
for (const [key, value] of headers1)if (key === "set-cookie") {
|
|
937
|
+
const cookieJar1 = await (0, $fad025d072e806d0$export$eced8873dedbb4c0);
|
|
938
|
+
await cookieJar1.setCookie(value, url2);
|
|
939
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log((0, $14c38dc11beadfaf$export$2aa0182783e7e9de)(`Set-Cookie:`), (0, $14c38dc11beadfaf$export$594c5a8758200c32)(value), (0, $14c38dc11beadfaf$export$594c5a8758200c32)(url2));
|
|
940
|
+
}
|
|
941
|
+
const newUrl = res.headers.get("location") ?? res.url;
|
|
942
|
+
// const sameHost = new URL(newUrl).host === url1.host;
|
|
943
|
+
if (res.status == 301 || res.status == 302) // follow the redirect
|
|
944
|
+
{
|
|
945
|
+
if (newUrl && newUrl !== url2) {
|
|
946
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["dump-response-headers"]) console.log((0, $14c38dc11beadfaf$export$2aa0182783e7e9de)(`Redirected to `), (0, $14c38dc11beadfaf$export$594c5a8758200c32)(newUrl));
|
|
947
|
+
return $72b72bc713ce1262$export$b24a545a0b39f491(//
|
|
948
|
+
newUrl, newOptions1, fetch, originalRequest1);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
if (res.status == 303 && newUrl && newUrl !== url2) {
|
|
952
|
+
// follow the redirect with GET
|
|
953
|
+
let newOptions2 = {};
|
|
954
|
+
switch(newOptions1.method){
|
|
955
|
+
case "POST":
|
|
956
|
+
case "PUT":
|
|
957
|
+
case "DELETE":
|
|
958
|
+
(0, $cMsgG$lodash.merge)(newOptions2, newOptions1, {
|
|
959
|
+
method: "GET"
|
|
960
|
+
});
|
|
961
|
+
newOptions2.body = undefined; // TODO: is this needed?
|
|
962
|
+
break;
|
|
963
|
+
case "HEAD":
|
|
964
|
+
case "GET":
|
|
965
|
+
(0, $cMsgG$lodash.merge)(newOptions2, newOptions1);
|
|
966
|
+
newOptions2.body = undefined; // TODO: is this needed?
|
|
967
|
+
break;
|
|
968
|
+
default:
|
|
969
|
+
(0, $cMsgG$lodash.merge)(newOptions2, newOptions1);
|
|
970
|
+
break;
|
|
971
|
+
}
|
|
972
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log((0, $14c38dc11beadfaf$export$2aa0182783e7e9de)(`Redirected to `), (0, $14c38dc11beadfaf$export$594c5a8758200c32)(newUrl));
|
|
973
|
+
return $72b72bc713ce1262$export$b24a545a0b39f491(//
|
|
974
|
+
newUrl, newOptions2, fetch, originalRequest1);
|
|
975
|
+
}
|
|
976
|
+
const arrayBuffer1 = res.arrayBuffer();
|
|
977
|
+
async function arrayBuffer() {
|
|
978
|
+
return arrayBuffer1;
|
|
979
|
+
}
|
|
980
|
+
async function buffer() {
|
|
981
|
+
return arrayBuffer().then(Buffer.from);
|
|
982
|
+
}
|
|
983
|
+
async function text() {
|
|
984
|
+
return buffer().then((buffer)=>buffer.toString("utf8"));
|
|
985
|
+
}
|
|
986
|
+
async function json() {
|
|
987
|
+
return text().then((text)=>(0, ($parcel$interopDefault($cMsgG$destr)))(text));
|
|
988
|
+
}
|
|
989
|
+
async function formData() {
|
|
990
|
+
const urlSearchParams = await text().then((text)=>new URLSearchParams(text));
|
|
991
|
+
const formData = new FormData();
|
|
992
|
+
for (const [key, value] of urlSearchParams.entries())formData.append(key, value);
|
|
993
|
+
return formData;
|
|
994
|
+
}
|
|
995
|
+
const res1 = res;
|
|
996
|
+
const source2 = {
|
|
997
|
+
arrayBuffer: arrayBuffer,
|
|
998
|
+
text: text,
|
|
999
|
+
json: json,
|
|
1000
|
+
buffer: buffer,
|
|
1001
|
+
formData: formData
|
|
1002
|
+
};
|
|
1003
|
+
return (0, $cMsgG$lodash.merge)(res1, source2);
|
|
1004
|
+
} catch (e) {
|
|
1005
|
+
throw e;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
function $b221da94e3dc8880$export$e7dabf85f0a9f9c(headerArgs) {
|
|
1011
|
+
const headers = {};
|
|
1012
|
+
if (headerArgs == null) return headers;
|
|
1013
|
+
if (Array.isArray(headerArgs)) {
|
|
1014
|
+
for (const h of headerArgs){
|
|
1015
|
+
const [key, value] = h.split("=");
|
|
1016
|
+
headers[key] = value;
|
|
1017
|
+
}
|
|
1018
|
+
return headers;
|
|
1019
|
+
}
|
|
1020
|
+
const [key1, value1] = headerArgs.split("=");
|
|
1021
|
+
headers[key1] = value1;
|
|
1022
|
+
return headers;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
async function $2691feac21fe7c6d$var$cliQueryCookies(cookieSpec) {
|
|
1029
|
+
try {
|
|
1030
|
+
const results = await (0, $0277fbedbad8c779$export$a65902517ae87ba8)(cookieSpec);
|
|
1031
|
+
if (results == null || results.length == 0) {
|
|
1032
|
+
console.error((0, $14c38dc11beadfaf$export$a90204d1394caf30)("No results"));
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["dump"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["d"]) {
|
|
1036
|
+
console.log(results);
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["dump-grouped"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["D"]) {
|
|
1040
|
+
const groupedByFile = (0, $cMsgG$lodash.groupBy)(results, (r)=>r.meta?.file);
|
|
1041
|
+
console.log((0, $14c38dc11beadfaf$export$955a2ebd2fb142ae)(JSON.stringify(groupedByFile, null, 2)));
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["render"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["render-merged"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["r"]) {
|
|
1045
|
+
console.log((0, $14c38dc11beadfaf$export$594c5a8758200c32)((0, $499e45cddca8ee5f$export$9abc0a414b0d8b8f)(results)));
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["render-grouped"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["R"]) {
|
|
1049
|
+
const groupedByFile1 = (0, $cMsgG$lodash.groupBy)(results, (r)=>r.meta?.file);
|
|
1050
|
+
for (const file of Object.keys(groupedByFile1)){
|
|
1051
|
+
let results1 = groupedByFile1[file];
|
|
1052
|
+
console.log((0, $14c38dc11beadfaf$export$955a2ebd2fb142ae)(file) + ": ", (0, $14c38dc11beadfaf$export$594c5a8758200c32)((0, $499e45cddca8ee5f$export$9abc0a414b0d8b8f)(results1)));
|
|
1053
|
+
}
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
for (const result of results)console.log(result.value);
|
|
1057
|
+
} catch (e) {
|
|
1058
|
+
console.error(e);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
async function $2691feac21fe7c6d$var$main() {
|
|
1062
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["help"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["h"]) {
|
|
1063
|
+
console.log(`Usage: ${(0, $75ef4a5a80896531$export$6f4ae1207c703045)[1]} [name] [domain] [options] `);
|
|
1064
|
+
console.log(`Options:`);
|
|
1065
|
+
console.log(` -h, --help: Show this help`);
|
|
1066
|
+
console.log(` -v, --verbose: Show verbose output`);
|
|
1067
|
+
console.log(` -d, --dump: Dump all results`);
|
|
1068
|
+
console.log(` -D, --dump-grouped: Dump all results, grouped by profile`);
|
|
1069
|
+
console.log(` -r, --render: Render all results`);
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
(0, $75ef4a5a80896531$export$c348dfaf65040d9b)["verbose"] = (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["verbose"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["v"];
|
|
1073
|
+
const fetchUrl = (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["fetch"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["F"];
|
|
1074
|
+
if (fetchUrl) {
|
|
1075
|
+
let url;
|
|
1076
|
+
try {
|
|
1077
|
+
url = new URL(fetchUrl);
|
|
1078
|
+
} catch (e) {
|
|
1079
|
+
console.error("Invalid URL", fetchUrl);
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
const headerArgs = (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["H"];
|
|
1083
|
+
const headers = (0, $b221da94e3dc8880$export$e7dabf85f0a9f9c)(headerArgs);
|
|
1084
|
+
const onfulfilled = (res)=>{
|
|
1085
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["dump-response-headers"]) res.headers.forEach((value, key)=>{
|
|
1086
|
+
console.log(`${key}: ${value}`);
|
|
1087
|
+
});
|
|
1088
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b)["dump-response-body"]) res.text().then((r)=>{
|
|
1089
|
+
console.log(r);
|
|
1090
|
+
});
|
|
1091
|
+
return;
|
|
1092
|
+
};
|
|
1093
|
+
(0, $72b72bc713ce1262$export$b24a545a0b39f491)(url, {
|
|
1094
|
+
headers: //
|
|
1095
|
+
headers
|
|
1096
|
+
}).then(onfulfilled, console.error);
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
const cookieSpecs = [];
|
|
1100
|
+
const argUrl = (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["url"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["u"];
|
|
1101
|
+
if (argUrl) for (const cookieSpec of (0, $b32860efe238f1f1$export$f266452a5050185d)(argUrl))cookieSpecs.push(cookieSpec);
|
|
1102
|
+
else cookieSpecs.push({
|
|
1103
|
+
name: (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["name"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["_"][0] || "%",
|
|
1104
|
+
domain: (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["domain"] || (0, $75ef4a5a80896531$export$c348dfaf65040d9b)["_"][1] || "%"
|
|
1105
|
+
});
|
|
1106
|
+
if ((0, $75ef4a5a80896531$export$c348dfaf65040d9b).verbose) console.log("cookieSpecs", cookieSpecs);
|
|
1107
|
+
await $2691feac21fe7c6d$var$cliQueryCookies(cookieSpecs).catch(console.error);
|
|
1108
|
+
}
|
|
1109
|
+
$2691feac21fe7c6d$var$main().then((r)=>r, console.error);
|
|
1110
|
+
|
|
1111
|
+
|