@mherod/get-cookie 2.0.0-rc.10 → 2.0.0-rc.12
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/.fleet/settings.json +3 -0
- package/.prettierrc.json +1 -1
- package/dist/index.js +96 -64
- package/package-lock.json +2106 -6865
- package/package.json +5 -7
- package/src/CookieSpec.ts +2 -0
- package/src/CookieStore.ts +9 -5
- package/src/argv.ts +17 -2
- package/src/browsers/ChromeCookieQueryStrategy.ts +30 -18
- package/src/browsers/CookieQueryStrategy.ts +1 -0
- package/src/browsers/CookieStoreQueryStrategy.ts +2 -2
- package/src/browsers/FirefoxCookieQueryStrategy.ts +52 -6
- package/src/browsers/SafariCookieQueryStrategy.ts +1 -0
- package/src/cli.ts +25 -10
- package/src/comboQueryCookieSpec.ts +24 -0
- package/src/cookieSpecsFromUrl.ts +26 -0
- package/src/doSqliteQuery1Params.ts +1 -0
- package/src/fetchWithCookies.ts +22 -22
- package/src/getGroupedRenderedCookies.ts +7 -17
- package/src/getMergedRenderedCookies.ts +9 -20
- package/src/doSqliteQuery1.ts +0 -47
package/.prettierrc.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{}
|
|
1
|
+
{}
|
package/dist/index.js
CHANGED
|
@@ -46,8 +46,13 @@ $parcel$export(module.exports, "getGroupedRenderedCookies", () => $300d8b33187a2
|
|
|
46
46
|
$parcel$export(module.exports, "fetchWithCookies", () => $cfc07ae4aa2c7e44$export$b24a545a0b39f491);
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
|
|
49
50
|
const $ef3d5dc2fd8022f5$export$6f4ae1207c703045 = process.argv ?? [];
|
|
50
|
-
const $ef3d5dc2fd8022f5$
|
|
51
|
+
const $ef3d5dc2fd8022f5$var$minimistArgs = (0, ($parcel$interopDefault($7oI3p$minimist)))($ef3d5dc2fd8022f5$export$6f4ae1207c703045.slice(2));
|
|
52
|
+
const $ef3d5dc2fd8022f5$var$defaultOptions = {
|
|
53
|
+
verbose: false
|
|
54
|
+
};
|
|
55
|
+
const $ef3d5dc2fd8022f5$export$c348dfaf65040d9b = (0, $7oI3p$lodash.merge)($ef3d5dc2fd8022f5$var$defaultOptions, $ef3d5dc2fd8022f5$var$minimistArgs);
|
|
51
56
|
|
|
52
57
|
|
|
53
58
|
|
|
@@ -146,7 +151,6 @@ function $68c0ed99fadee6ca$export$4eadcf0bf35a2ddb(s) {
|
|
|
146
151
|
|
|
147
152
|
|
|
148
153
|
|
|
149
|
-
|
|
150
154
|
class $269fe42bfd555305$export$2e2bcd8739ae039 {
|
|
151
155
|
browserName = "Chrome";
|
|
152
156
|
async queryCookies(name, domain) {
|
|
@@ -210,9 +214,12 @@ async function $269fe42bfd555305$var$getChromeCookies({ name: name , domain: dom
|
|
|
210
214
|
meta: meta
|
|
211
215
|
};
|
|
212
216
|
const expiry = cookieRow.expiry;
|
|
213
|
-
|
|
217
|
+
const mergeExpiry = expiry != null && expiry > 0 ? {
|
|
214
218
|
expiry: new Date(expiry)
|
|
215
|
-
}
|
|
219
|
+
} : {
|
|
220
|
+
expiry: "Infinity"
|
|
221
|
+
};
|
|
222
|
+
(0, $7oI3p$lodash.merge)(exportedCookie, mergeExpiry);
|
|
216
223
|
return exportedCookie;
|
|
217
224
|
});
|
|
218
225
|
const results = (await Promise.all(decrypted)).filter((0, $d66f40b581ba8bfa$export$963c8d651337e4a4));
|
|
@@ -248,9 +255,14 @@ async function $269fe42bfd555305$var$getEncryptedChromeCookie({ name: name , dom
|
|
|
248
255
|
sql += `host_key LIKE '${sqlEmbedDomain}';`;
|
|
249
256
|
}
|
|
250
257
|
}
|
|
258
|
+
if ((0, $ef3d5dc2fd8022f5$export$c348dfaf65040d9b).verbose) console.log("sql", sql);
|
|
259
|
+
const domainRegexp = (0, $68c0ed99fadee6ca$export$4eadcf0bf35a2ddb)(domain);
|
|
251
260
|
const sqliteQuery1 = await $269fe42bfd555305$export$bd52b72df8d0d261({
|
|
252
261
|
file: file,
|
|
253
262
|
sql: sql,
|
|
263
|
+
rowFilter: (row)=>{
|
|
264
|
+
return row["host_key"].match(domainRegexp) != null;
|
|
265
|
+
},
|
|
254
266
|
rowTransform: (row)=>{
|
|
255
267
|
const cookieRow = {
|
|
256
268
|
expiry: (row["expires_utc"] / 1000000 - 11644473600) * 1000,
|
|
@@ -263,7 +275,7 @@ async function $269fe42bfd555305$var$getEncryptedChromeCookie({ name: name , dom
|
|
|
263
275
|
}
|
|
264
276
|
});
|
|
265
277
|
return sqliteQuery1.filter((row)=>{
|
|
266
|
-
return row.domain.match(
|
|
278
|
+
return row.domain.match(domainRegexp) != null;
|
|
267
279
|
});
|
|
268
280
|
}
|
|
269
281
|
async function $269fe42bfd555305$var$getChromePassword() {
|
|
@@ -324,7 +336,7 @@ async function $269fe42bfd555305$var$decrypt(password, encryptedData) {
|
|
|
324
336
|
});
|
|
325
337
|
});
|
|
326
338
|
}
|
|
327
|
-
async function $269fe42bfd555305$export$bd52b72df8d0d261({ file: file , sql: sql , rowTransform: rowTransform }) {
|
|
339
|
+
async function $269fe42bfd555305$export$bd52b72df8d0d261({ file: file , sql: sql , rowFilter: rowFilter = ()=>true , rowTransform: rowTransform }) {
|
|
328
340
|
if (!file || file && !(0, ($parcel$interopDefault($7oI3p$fs))).existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
|
|
329
341
|
const db = new $7oI3p$sqlite3.Database(file);
|
|
330
342
|
return new Promise((resolve, reject)=>{
|
|
@@ -339,7 +351,7 @@ async function $269fe42bfd555305$export$bd52b72df8d0d261({ file: file , sql: sql
|
|
|
339
351
|
return;
|
|
340
352
|
}
|
|
341
353
|
if (Array.isArray(rows1)) {
|
|
342
|
-
const cookieRows = rows1.map((row)=>{
|
|
354
|
+
const cookieRows = rows1.filter(rowFilter).map((row)=>{
|
|
343
355
|
const newVar = {
|
|
344
356
|
meta: {
|
|
345
357
|
file: file
|
|
@@ -364,12 +376,20 @@ async function $269fe42bfd555305$export$bd52b72df8d0d261({ file: file , sql: sql
|
|
|
364
376
|
|
|
365
377
|
|
|
366
378
|
|
|
379
|
+
function $b744d19cc39f964e$export$da22813e5a2ec500({ name: name , domain: domain }) {
|
|
380
|
+
const wildcardRegexp = /^([*%])$/i;
|
|
381
|
+
return {
|
|
382
|
+
specifiedName: name.match(wildcardRegexp) == null,
|
|
383
|
+
specifiedDomain: domain.match(wildcardRegexp) == null
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
367
387
|
|
|
368
388
|
|
|
369
389
|
|
|
370
390
|
|
|
371
|
-
async function $
|
|
372
|
-
if (!file || file &&
|
|
391
|
+
async function $7bb7da9a77b2fd99$export$f19f611d1fa7c6f3({ file: file , sql: sql , rowTransform: rowTransform }) {
|
|
392
|
+
if (!file || file && !(0, ($parcel$interopDefault($7oI3p$fs))).existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
|
|
373
393
|
const db = new $7oI3p$sqlite3.Database(file);
|
|
374
394
|
return new Promise((resolve, reject)=>{
|
|
375
395
|
db.all(sql, (err, rows)=>{
|
|
@@ -402,22 +422,12 @@ async function $a085b524d8ee9fce$export$f19f611d1fa7c6f3({ file: file , sql: sql
|
|
|
402
422
|
});
|
|
403
423
|
});
|
|
404
424
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
function $b744d19cc39f964e$export$da22813e5a2ec500({ name: name , domain: domain }) {
|
|
408
|
-
const wildcardRegexp = /^([*%])$/i;
|
|
409
|
-
return {
|
|
410
|
-
specifiedName: name.match(wildcardRegexp) == null,
|
|
411
|
-
specifiedDomain: domain.match(wildcardRegexp) == null
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
416
425
|
class $7bb7da9a77b2fd99$export$2e2bcd8739ae039 {
|
|
417
426
|
browserName = "Firefox";
|
|
418
427
|
async queryCookies(name, domain) {
|
|
419
|
-
if (process.platform !== "darwin")
|
|
420
|
-
|
|
428
|
+
if (process.platform !== "darwin") // TODO: implement
|
|
429
|
+
return [];
|
|
430
|
+
if ((0, $ef3d5dc2fd8022f5$export$c348dfaf65040d9b).browser !== "firefox") return [];
|
|
421
431
|
const cookies = await this.#getFirefoxCookie({
|
|
422
432
|
name: name,
|
|
423
433
|
domain: domain
|
|
@@ -441,6 +451,7 @@ class $7bb7da9a77b2fd99$export$2e2bcd8739ae039 {
|
|
|
441
451
|
return await this.#queryCookiesDb(file, name, domain);
|
|
442
452
|
};
|
|
443
453
|
const all = await Promise.all(files.map(fn));
|
|
454
|
+
// flatten
|
|
444
455
|
return all.flat();
|
|
445
456
|
}
|
|
446
457
|
async #queryCookiesDb(file, name1, domain1) {
|
|
@@ -470,7 +481,7 @@ class $7bb7da9a77b2fd99$export$2e2bcd8739ae039 {
|
|
|
470
481
|
};
|
|
471
482
|
};
|
|
472
483
|
try {
|
|
473
|
-
return await
|
|
484
|
+
return await $7bb7da9a77b2fd99$export$f19f611d1fa7c6f3({
|
|
474
485
|
file: file,
|
|
475
486
|
sql: sql,
|
|
476
487
|
rowTransform: rowTransform
|
|
@@ -486,6 +497,7 @@ class $7bb7da9a77b2fd99$export$2e2bcd8739ae039 {
|
|
|
486
497
|
class $fad6f51bd5c7bae2$export$2e2bcd8739ae039 {
|
|
487
498
|
browserName = "Safari";
|
|
488
499
|
async queryCookies(name, domain) {
|
|
500
|
+
// TODO: implement
|
|
489
501
|
return [];
|
|
490
502
|
}
|
|
491
503
|
}
|
|
@@ -495,8 +507,11 @@ class $fad6f51bd5c7bae2$export$2e2bcd8739ae039 {
|
|
|
495
507
|
|
|
496
508
|
|
|
497
509
|
|
|
510
|
+
|
|
498
511
|
var $53a3bcc99a05dfcf$require$FileCookieStore = $7oI3p$toughcookiefilestore.FileCookieStore;
|
|
499
|
-
|
|
512
|
+
let $53a3bcc99a05dfcf$export$6c62df16f2e9c7e8;
|
|
513
|
+
if ((0, $ef3d5dc2fd8022f5$export$c348dfaf65040d9b)["cs"] == "memory") $53a3bcc99a05dfcf$export$6c62df16f2e9c7e8 = new (0, $7oI3p$toughcookie.MemoryCookieStore)();
|
|
514
|
+
else $53a3bcc99a05dfcf$export$6c62df16f2e9c7e8 = new $53a3bcc99a05dfcf$require$FileCookieStore(`${(0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3)["HOME"]}/cookie-star.json`);
|
|
500
515
|
const $53a3bcc99a05dfcf$export$928a906645f9d018 = new (0, $7oI3p$toughcookie.CookieJar)($53a3bcc99a05dfcf$export$6c62df16f2e9c7e8);
|
|
501
516
|
|
|
502
517
|
|
|
@@ -543,7 +558,7 @@ class $e4efb16e005540de$export$2e2bcd8739ae039 {
|
|
|
543
558
|
domain: cookie.domain ?? cookieSpec.domain,
|
|
544
559
|
name: cookie.key ?? cookieSpec.name,
|
|
545
560
|
value: cookie.value,
|
|
546
|
-
expiry: cookie.expires ?? Infinity,
|
|
561
|
+
expiry: cookie.expires ?? "Infinity",
|
|
547
562
|
meta: {
|
|
548
563
|
file: "tough-cookie"
|
|
549
564
|
}
|
|
@@ -688,7 +703,6 @@ async function $f9b70200901ad17d$export$c44c5fdef43f0941(params) {
|
|
|
688
703
|
|
|
689
704
|
|
|
690
705
|
|
|
691
|
-
|
|
692
706
|
function $9c43c2ed82e63570$export$9abc0a414b0d8b8f(results) {
|
|
693
707
|
// sort by name and expiry descending
|
|
694
708
|
// takes the latest expiry for each name
|
|
@@ -704,17 +718,26 @@ function $9c43c2ed82e63570$export$9abc0a414b0d8b8f(results) {
|
|
|
704
718
|
|
|
705
719
|
|
|
706
720
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
721
|
+
|
|
722
|
+
async function $8ef2ebdbd659489d$export$a65902517ae87ba8(cookieSpec) {
|
|
723
|
+
const cookies = [];
|
|
724
|
+
if (Array.isArray(cookieSpec)) {
|
|
725
|
+
const results = await Promise.all(cookieSpec.map((cs)=>{
|
|
726
|
+
return (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)(cs);
|
|
727
|
+
}));
|
|
728
|
+
for (const exportedCookie of results.flat())cookies.push(exportedCookie);
|
|
729
|
+
} else {
|
|
730
|
+
const singleQuery = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)(cookieSpec);
|
|
731
|
+
cookies.push(...singleQuery);
|
|
732
|
+
}
|
|
733
|
+
return (0, $7oI3p$lodash.uniqBy)(cookies, JSON.stringify);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
async function $300d8b33187a203c$export$4d2e9997e2c23417(cookieSpec) {
|
|
738
|
+
const cookies = await (0, $8ef2ebdbd659489d$export$a65902517ae87ba8)(cookieSpec);
|
|
712
739
|
if (cookies.length == 0) throw new Error("Cookie not found");
|
|
713
|
-
const
|
|
714
|
-
name: name,
|
|
715
|
-
domain: domain
|
|
716
|
-
});
|
|
717
|
-
const groupedByFile = (0, $7oI3p$lodash.groupBy)(results, (r)=>r.meta?.file);
|
|
740
|
+
const groupedByFile = (0, $7oI3p$lodash.groupBy)(cookies, (r)=>r.meta?.file);
|
|
718
741
|
return Object.keys(groupedByFile).map((file)=>{
|
|
719
742
|
const results = groupedByFile[file];
|
|
720
743
|
return (0, $9c43c2ed82e63570$export$9abc0a414b0d8b8f)(results);
|
|
@@ -724,18 +747,10 @@ async function $300d8b33187a203c$export$4d2e9997e2c23417({ name: name , domain:
|
|
|
724
747
|
|
|
725
748
|
|
|
726
749
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
domain: domain
|
|
732
|
-
}, new (0, $f72befa528c23ca7$export$2e2bcd8739ae039)());
|
|
733
|
-
if (cookies.length == 0) throw new Error("Cookie not found");
|
|
734
|
-
const results = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)({
|
|
735
|
-
name: name,
|
|
736
|
-
domain: domain
|
|
737
|
-
});
|
|
738
|
-
return (0, $9c43c2ed82e63570$export$9abc0a414b0d8b8f)(results);
|
|
750
|
+
async function $4ffeaeb7bb3c0319$export$cfc0723de5712e57(cookieSpec) {
|
|
751
|
+
const cookies = await (0, $8ef2ebdbd659489d$export$a65902517ae87ba8)(cookieSpec);
|
|
752
|
+
if (cookies.length > 0) return (0, $9c43c2ed82e63570$export$9abc0a414b0d8b8f)(cookies);
|
|
753
|
+
return "";
|
|
739
754
|
}
|
|
740
755
|
|
|
741
756
|
|
|
@@ -747,31 +762,48 @@ async function $4ffeaeb7bb3c0319$export$cfc0723de5712e57({ name: name , domain:
|
|
|
747
762
|
|
|
748
763
|
|
|
749
764
|
|
|
765
|
+
|
|
766
|
+
function $2d84054eb5f070a6$export$f266452a5050185d(url) {
|
|
767
|
+
const url1 = typeof url == "string" ? new URL(url) : url;
|
|
768
|
+
const cookieSpecs = [];
|
|
769
|
+
const splits = url1.hostname.split(".");
|
|
770
|
+
const tld = splits.slice(-2).join(".");
|
|
771
|
+
const cookieSpec = {
|
|
772
|
+
name: "%",
|
|
773
|
+
domain: "%." + tld
|
|
774
|
+
};
|
|
775
|
+
cookieSpecs.push(cookieSpec);
|
|
776
|
+
const cookieSpec1 = {
|
|
777
|
+
name: "%",
|
|
778
|
+
domain: url1.hostname
|
|
779
|
+
};
|
|
780
|
+
cookieSpecs.push(cookieSpec1);
|
|
781
|
+
// const isWww = splits.slice(-3)[0] === "www";
|
|
782
|
+
const cookieSpec2 = {
|
|
783
|
+
name: "%",
|
|
784
|
+
domain: tld
|
|
785
|
+
};
|
|
786
|
+
cookieSpecs.push(cookieSpec2);
|
|
787
|
+
return (0, $7oI3p$lodash.uniqBy)(cookieSpecs, JSON.stringify);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
|
|
750
791
|
async function $cfc07ae4aa2c7e44$export$b24a545a0b39f491(url, options = {}, fetch = (0, $7oI3p$crossfetch.fetch)) {
|
|
792
|
+
const headers = {
|
|
793
|
+
"User-Agent": new (0, ($parcel$interopDefault($7oI3p$useragents)))().toString()
|
|
794
|
+
};
|
|
751
795
|
const defaultOptions = {
|
|
752
|
-
headers:
|
|
753
|
-
"User-Agent": new (0, ($parcel$interopDefault($7oI3p$useragents)))().toString()
|
|
754
|
-
},
|
|
796
|
+
headers: headers,
|
|
755
797
|
redirect: "manual"
|
|
756
798
|
};
|
|
757
799
|
const url2 = `${url}`;
|
|
758
800
|
const url1 = new URL(url2);
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
});
|
|
762
|
-
const cookieSpec = {
|
|
763
|
-
name: "%",
|
|
764
|
-
domain: domain
|
|
765
|
-
};
|
|
766
|
-
// const cookies: string[] = await getGroupedRenderedCookies(cookieSpec).catch(
|
|
767
|
-
// () => []
|
|
768
|
-
// );
|
|
769
|
-
// const cookie = cookies.pop();
|
|
770
|
-
const cookie = await (0, $4ffeaeb7bb3c0319$export$cfc0723de5712e57)(cookieSpec).catch(()=>"");
|
|
771
|
-
const headers = {};
|
|
801
|
+
const cookieSpecs = (0, $2d84054eb5f070a6$export$f266452a5050185d)(url1);
|
|
802
|
+
const cookie = await (0, $4ffeaeb7bb3c0319$export$cfc0723de5712e57)(cookieSpecs).catch(()=>"");
|
|
772
803
|
if (cookie.length > 0) (0, $7oI3p$lodash.merge)(headers, {
|
|
773
804
|
Cookie: cookie
|
|
774
805
|
});
|
|
806
|
+
if ((0, $ef3d5dc2fd8022f5$export$c348dfaf65040d9b)["dump-request-headers"]) console.log((0, $7oI3p$colorette.blue)("Request headers:"), headers);
|
|
775
807
|
const newOptions1 = (0, $7oI3p$lodash.merge)(defaultOptions, options, {
|
|
776
808
|
headers: headers
|
|
777
809
|
});
|