@mherod/get-cookie 2.0.0-beta.8 → 2.0.0-rc.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.
package/dist/index.js CHANGED
@@ -1,3 +1,616 @@
1
1
  #!/usr/bin/env node
2
- var r=require("lodash"),e=(require("fs"),require("crypto"),require("path"));require("child_process"),require("sqlite3"),require("jsonwebtoken"),require("cross-fetch"),require("destr");var i=r.merge;const o={};i(o,process.env);const s=o.HOME;if(!s)throw new Error("HOME environment variable is not set");e.join(s,"Library","Application Support","Google","Chrome");
2
+ var $7oI3p$lodash = require("lodash");
3
+ var $7oI3p$lrucache = require("lru-cache");
4
+ var $7oI3p$fs = require("fs");
5
+ var $7oI3p$crypto = require("crypto");
6
+ var $7oI3p$path = require("path");
7
+ var $7oI3p$child_process = require("child_process");
8
+ var $7oI3p$sqlite3 = require("sqlite3");
9
+ var $7oI3p$jsonwebtoken = require("jsonwebtoken");
10
+ var $7oI3p$crossfetch = require("cross-fetch");
11
+ var $7oI3p$destr = require("destr");
12
+
13
+ function $parcel$export(e, n, v, s) {
14
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
15
+ }
16
+ function $parcel$exportWildcard(dest, source) {
17
+ Object.keys(source).forEach(function(key) {
18
+ if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
19
+ return;
20
+ }
21
+
22
+ Object.defineProperty(dest, key, {
23
+ enumerable: true,
24
+ get: function get() {
25
+ return source[key];
26
+ }
27
+ });
28
+ });
29
+
30
+ return dest;
31
+ }
32
+ function $parcel$interopDefault(a) {
33
+ return a && a.__esModule ? a.default : a;
34
+ }
35
+
36
+ $parcel$export(module.exports, "getCookie", () => $cd1ba0160120c006$export$4be65e66cfa2648a);
37
+ $parcel$export(module.exports, "getFirefoxCookie", () => $cd1ba0160120c006$export$c44c5fdef43f0941);
38
+ $parcel$export(module.exports, "getChromeCookie", () => $cd1ba0160120c006$export$e5637297e9eb6f2e);
39
+ $parcel$export(module.exports, "getGroupedRenderedCookies", () => $300d8b33187a203c$export$4d2e9997e2c23417);
40
+ $parcel$export(module.exports, "fetchWithCookies", () => $cfc07ae4aa2c7e44$export$b24a545a0b39f491);
41
+
42
+ const $fac425c10fbbada5$export$a7b6bc01c63cdfc3 = {};
43
+ (0, $7oI3p$lodash.merge)($fac425c10fbbada5$export$a7b6bc01c63cdfc3, process.env);
44
+ const $fac425c10fbbada5$export$a7c5707626fc90f = $fac425c10fbbada5$export$a7b6bc01c63cdfc3["HOME"];
45
+ if (!$fac425c10fbbada5$export$a7c5707626fc90f) throw new Error("HOME environment variable is not set");
46
+
47
+
48
+
49
+
50
+ async function $25b78d6746d4ad48$export$8d71c74f97c0202e(command) {
51
+ return new Promise((resolve, reject)=>{
52
+ (0, $7oI3p$child_process.exec)(command, {
53
+ encoding: "binary",
54
+ maxBuffer: 5120
55
+ }, (error, stdout, stderr)=>{
56
+ if (error) {
57
+ reject(error);
58
+ return;
59
+ }
60
+ if (stderr) {
61
+ reject(error);
62
+ return;
63
+ }
64
+ if (stdout) resolve(stdout.trim());
65
+ });
66
+ });
67
+ }
68
+ function $25b78d6746d4ad48$export$d53bf2de587a369(result) {
69
+ if (result == null) return null;
70
+ if (process.env.VERBOSE) console.log("result", result);
71
+ if (typeof result === "string" && result.length > 0) return result;
72
+ if (result.slice && result.toString) // noinspection JSCheckFunctionSignatures
73
+ return result.toString("utf8");
74
+ return null;
75
+ }
76
+ function $25b78d6746d4ad48$export$99ce3e33a555daf1(input) {
77
+ return typeof input !== "string" || input.length === 0;
78
+ }
79
+ function $25b78d6746d4ad48$export$5348b46700dd771c(input) {
80
+ return typeof input == "string" && input.length > 0;
81
+ }
82
+
83
+
84
+
85
+
86
+
87
+
88
+ async function $e62c2c56eb720f29$export$2c9faf86071156ae({ path: path , name: name , maxDepth: maxDepth = 2 }) {
89
+ const rootSegments = path.split("/").length;
90
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Searching for ${name} in ${path}`);
91
+ const files = [];
92
+ let readdirSync;
93
+ try {
94
+ readdirSync = $7oI3p$fs.readdirSync(path);
95
+ } catch (e) {
96
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Error reading ${path}`, e);
97
+ return [];
98
+ }
99
+ for (const file of readdirSync){
100
+ const filePath = path + "/" + file;
101
+ let stat;
102
+ try {
103
+ stat = $7oI3p$fs.statSync(filePath);
104
+ } catch (e1) {
105
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.error(`Error getting stat for ${filePath}`, e1);
106
+ continue;
107
+ }
108
+ if (stat.isDirectory()) {
109
+ if (filePath.split("/").length < rootSegments + maxDepth) try {
110
+ const subFiles = await $e62c2c56eb720f29$export$2c9faf86071156ae({
111
+ path: filePath,
112
+ name: name,
113
+ maxDepth: 2
114
+ });
115
+ files.push(...subFiles);
116
+ } catch (e2) {
117
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.error(e2);
118
+ }
119
+ } else if (file === name) files.push(filePath);
120
+ }
121
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) {
122
+ if (files.length > 0) {
123
+ console.log(`Found ${files.length} ${name} files`);
124
+ console.log(files);
125
+ }
126
+ }
127
+ return files;
128
+ }
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+ async function $a085b524d8ee9fce$export$f19f611d1fa7c6f3({ file: file , sql: sql , rowTransform: rowTransform }) {
137
+ if (!file || file && !$7oI3p$fs.existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
138
+ const db = new $7oI3p$sqlite3.Database(file);
139
+ return new Promise((resolve, reject)=>{
140
+ db.all(sql, (err, rows)=>{
141
+ if (err) {
142
+ reject(err);
143
+ return;
144
+ }
145
+ const rows1 = rows;
146
+ if (rows1 == null || rows1.length === 0) {
147
+ resolve([]);
148
+ return;
149
+ }
150
+ if (Array.isArray(rows1)) {
151
+ const cookieRows = rows1.map((row)=>{
152
+ const newVar = {
153
+ meta: {
154
+ file: file
155
+ }
156
+ };
157
+ const cookieRow = rowTransform(row);
158
+ return (0, $7oI3p$lodash.merge)(newVar, cookieRow);
159
+ });
160
+ resolve(cookieRows);
161
+ return;
162
+ }
163
+ if (process.env.VERBOSE) console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);
164
+ resolve([
165
+ rows1
166
+ ]);
167
+ });
168
+ });
169
+ }
170
+
171
+
172
+
173
+ function $af69dfb8766652d8$export$bc926c43858bd3cb(obj) {
174
+ return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
175
+ }
176
+
177
+
178
+ function $d66f40b581ba8bfa$export$963c8d651337e4a4(obj) {
179
+ return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
180
+ }
181
+
182
+
183
+ class $269fe42bfd555305$export$2e2bcd8739ae039 {
184
+ async queryCookies(name, domain) {
185
+ if (process.platform !== "darwin") throw new Error("This only works on macOS");
186
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).FIREFOX_ONLY) return [];
187
+ return $269fe42bfd555305$var$getChromeCookies({
188
+ requireJwt: false,
189
+ name: name,
190
+ domain: domain
191
+ });
192
+ }
193
+ }
194
+ async function $269fe42bfd555305$var$getPromise1(name, domain, file) {
195
+ try {
196
+ return await $269fe42bfd555305$var$getEncryptedChromeCookie({
197
+ name: name,
198
+ domain: domain,
199
+ file: file
200
+ });
201
+ } catch (e) {
202
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error getting encrypted cookie", e);
203
+ return [];
204
+ }
205
+ }
206
+ async function $269fe42bfd555305$var$getPromise(name, domain) {
207
+ try {
208
+ const files = await (0, $e62c2c56eb720f29$export$2c9faf86071156ae)({
209
+ path: $269fe42bfd555305$var$chromeLocal,
210
+ name: "Cookies"
211
+ });
212
+ const promises = files.map((file)=>$269fe42bfd555305$var$getPromise1(name, domain, file));
213
+ const results1 = await Promise.all(promises);
214
+ return results1.flat().filter((0, $af69dfb8766652d8$export$bc926c43858bd3cb));
215
+ } catch (error) {
216
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("error", error);
217
+ return [];
218
+ }
219
+ }
220
+ async function $269fe42bfd555305$var$decryptValue(password, encryptedValue) {
221
+ let d;
222
+ try {
223
+ d = await $269fe42bfd555305$var$decrypt(password, encryptedValue);
224
+ } catch (e) {
225
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error decrypting cookie", e);
226
+ d = null;
227
+ }
228
+ return d ?? encryptedValue.toString("utf-8");
229
+ }
230
+ async function $269fe42bfd555305$var$getChromeCookies({ name: name , domain: domain = "%" , requireJwt: requireJwt = false }) {
231
+ const encryptedDataItems = await $269fe42bfd555305$var$getPromise(name, domain);
232
+ const password = await $269fe42bfd555305$var$getChromePassword();
233
+ const decrypted = encryptedDataItems.filter(({ value: value })=>value != null && value.length > 0).map(async (cookieRow)=>{
234
+ const encryptedValue = cookieRow.value;
235
+ const decryptedValue = await $269fe42bfd555305$var$decryptValue(password, encryptedValue);
236
+ const meta = {};
237
+ (0, $7oI3p$lodash.merge)(meta, cookieRow.meta ?? {});
238
+ return {
239
+ domain: cookieRow.domain,
240
+ name: cookieRow.name,
241
+ value: decryptedValue,
242
+ meta: meta
243
+ };
244
+ });
245
+ const results = (await Promise.all(decrypted)).filter((0, $d66f40b581ba8bfa$export$963c8d651337e4a4));
246
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("results", results);
247
+ return results;
248
+ }
249
+ const $269fe42bfd555305$var$chromeLocal = $7oI3p$path.join((0, $fac425c10fbbada5$export$a7c5707626fc90f), "Library", "Application Support", "Google", "Chrome");
250
+ async function $269fe42bfd555305$var$getEncryptedChromeCookie({ name: name , domain: domain , file: file = $7oI3p$path.join($269fe42bfd555305$var$chromeLocal, "Default", "Cookies") }) {
251
+ if (!(0, $7oI3p$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
252
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) {
253
+ const s = file.split("/").slice(-3).join("/");
254
+ console.log(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);
255
+ }
256
+ let sql;
257
+ //language=SQL
258
+ sql = "SELECT encrypted_value, name, host_key FROM cookies";
259
+ const wildcardRegexp = /^([*%])$/i;
260
+ const specifiedName = name.match(wildcardRegexp) == null;
261
+ const specifiedDomain = domain.match(wildcardRegexp) == null;
262
+ if (specifiedName || specifiedDomain) {
263
+ sql += ` WHERE `;
264
+ if (specifiedName) {
265
+ sql += `name = '${name}'`;
266
+ if (specifiedDomain) sql += ` AND `;
267
+ }
268
+ if (specifiedDomain) sql += `host_key LIKE '${domain}';`;
269
+ }
270
+ return (0, $a085b524d8ee9fce$export$f19f611d1fa7c6f3)({
271
+ file: file,
272
+ sql: sql,
273
+ rowTransform: (row)=>{
274
+ return {
275
+ domain: row["host_key"],
276
+ name: row["name"],
277
+ value: row["encrypted_value"]
278
+ };
279
+ }
280
+ });
281
+ }
282
+ async function $269fe42bfd555305$var$getChromePassword() {
283
+ return (0, $25b78d6746d4ad48$export$8d71c74f97c0202e)('security find-generic-password -w -s "Chrome Safe Storage"');
284
+ }
285
+ async function $269fe42bfd555305$var$decrypt(password, encryptedData) {
286
+ if (typeof password !== "string") throw new Error("password must be a string: " + password);
287
+ let encryptedData1;
288
+ encryptedData1 = encryptedData;
289
+ if (encryptedData1 == null || typeof encryptedData1 !== "object") throw new Error("encryptedData must be a object: " + encryptedData1);
290
+ if (!(encryptedData1 instanceof Buffer)) {
291
+ if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {
292
+ [encryptedData1] = encryptedData1;
293
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`encryptedData is an array of buffers, selected first: ${encryptedData1}`);
294
+ } else throw new Error("encryptedData must be a Buffer: " + encryptedData1);
295
+ encryptedData1 = Buffer.from(encryptedData1);
296
+ }
297
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Trying to decrypt with password ${password}`);
298
+ return new Promise((resolve, reject)=>{
299
+ $7oI3p$crypto.pbkdf2(password, "saltysalt", 1003, 16, "sha1", (error, buffer)=>{
300
+ try {
301
+ if (error) {
302
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing pbkdf2", error);
303
+ reject(error);
304
+ return;
305
+ }
306
+ if (buffer.length !== 16) {
307
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing pbkdf2, buffer length is not 16", buffer.length);
308
+ reject(new Error("Buffer length is not 16"));
309
+ return;
310
+ }
311
+ const str = new Array(17).join(" ");
312
+ const iv = Buffer.from(str, "binary");
313
+ const decipher = $7oI3p$crypto.createDecipheriv("aes-128-cbc", buffer, iv);
314
+ decipher.setAutoPadding(false);
315
+ if (encryptedData1 && encryptedData1.slice) encryptedData1 = encryptedData1.slice(3);
316
+ if (encryptedData1.length % 16 !== 0) {
317
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing pbkdf2, encryptedData length is not a multiple of 16", encryptedData1.length);
318
+ reject(new Error("encryptedData length is not a multiple of 16"));
319
+ return;
320
+ }
321
+ let decoded = decipher.update(encryptedData1);
322
+ try {
323
+ decipher.final("utf-8");
324
+ } catch (e) {
325
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing decipher.final()", e);
326
+ reject(e);
327
+ return;
328
+ }
329
+ const padding = decoded[decoded.length - 1];
330
+ if (padding) decoded = decoded.slice(0, 0 - padding);
331
+ // noinspection JSCheckFunctionSignatures
332
+ const decodedString = decoded.toString("utf8");
333
+ resolve(decodedString);
334
+ } catch (e1) {
335
+ reject(e1);
336
+ }
337
+ });
338
+ });
339
+ }
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+ function $b744d19cc39f964e$export$da22813e5a2ec500({ name: name , domain: domain }) {
348
+ const wildcardRegexp = /^([*%])$/i;
349
+ return {
350
+ specifiedName: name.match(wildcardRegexp) == null,
351
+ specifiedDomain: domain.match(wildcardRegexp) == null
352
+ };
353
+ }
354
+
355
+
356
+ class $7bb7da9a77b2fd99$export$2e2bcd8739ae039 {
357
+ async queryCookies(name, domain) {
358
+ if (process.platform !== "darwin") throw new Error("This only works on macOS");
359
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).CHROME_ONLY) return [];
360
+ const cookies = await this.#getFirefoxCookie({
361
+ name: name,
362
+ domain: domain
363
+ });
364
+ if (Array.isArray(cookies)) return cookies.map((cookie)=>{
365
+ return {
366
+ domain: cookie.domain,
367
+ name: cookie.name,
368
+ value: cookie.value.toString("utf8")
369
+ };
370
+ });
371
+ else return [];
372
+ }
373
+ async #getFirefoxCookie({ name: name , domain: domain } //
374
+ ) {
375
+ const files = await (0, $e62c2c56eb720f29$export$2c9faf86071156ae)({
376
+ path: $7oI3p$path.join((0, $fac425c10fbbada5$export$a7c5707626fc90f), "Library", "Application Support", "Firefox", "Profiles"),
377
+ name: "cookies.sqlite"
378
+ });
379
+ const fn = async (file)=>{
380
+ return await this.#queryCookiesDb(file, name, domain);
381
+ };
382
+ const all = await Promise.all(files.map(fn));
383
+ return all.flat();
384
+ }
385
+ async #queryCookiesDb(file, name1, domain1) {
386
+ if (file && !(0, $7oI3p$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
387
+ let sql;
388
+ //language=SQL
389
+ sql = "SELECT value, name, host FROM moz_cookies";
390
+ const { specifiedName: specifiedName , specifiedDomain: specifiedDomain } = (0, $b744d19cc39f964e$export$da22813e5a2ec500)({
391
+ name: name1,
392
+ domain: domain1
393
+ });
394
+ if (specifiedName || specifiedDomain) {
395
+ sql += ` WHERE `;
396
+ if (specifiedName) {
397
+ sql += `name = '${name1}'`;
398
+ if (specifiedDomain) sql += ` AND `;
399
+ }
400
+ if (specifiedDomain) sql += `host LIKE '${domain1}';`;
401
+ }
402
+ const rowTransform = (row)=>{
403
+ // row is object key by column name
404
+ const value = row.value;
405
+ return {
406
+ domain: row.domain,
407
+ name: row.name,
408
+ value: Buffer.from(value, "utf8")
409
+ };
410
+ };
411
+ try {
412
+ return await (0, $a085b524d8ee9fce$export$f19f611d1fa7c6f3)({
413
+ file: file,
414
+ sql: sql,
415
+ rowTransform: rowTransform
416
+ });
417
+ } catch (e) {
418
+ console.error(`Error querying ${file}`, e);
419
+ return [];
420
+ }
421
+ }
422
+ }
423
+
424
+
425
+ class $fad6f51bd5c7bae2$export$2e2bcd8739ae039 {
426
+ async queryCookies(name, domain) {
427
+ return [];
428
+ }
429
+ }
430
+
431
+
432
+
433
+ const $f72befa528c23ca7$var$cache = new (0, ($parcel$interopDefault($7oI3p$lrucache)))({
434
+ ttl: 2000,
435
+ max: 10
436
+ });
437
+ class $f72befa528c23ca7$export$2e2bcd8739ae039 {
438
+ #strategies;
439
+ constructor(){
440
+ this.#strategies = [
441
+ (0, $269fe42bfd555305$export$2e2bcd8739ae039),
442
+ (0, $7bb7da9a77b2fd99$export$2e2bcd8739ae039),
443
+ (0, $fad6f51bd5c7bae2$export$2e2bcd8739ae039),
444
+ ].map((strategy)=>{
445
+ return new strategy();
446
+ });
447
+ }
448
+ async queryCookies(name, domain) {
449
+ const key = `${name}:${domain}`;
450
+ const cached = $f72befa528c23ca7$var$cache.get(key);
451
+ if (cached) return cached;
452
+ const results = await Promise.all(this.#strategies.map(async (strategy)=>{
453
+ // @ts-ignore
454
+ const cookies = strategy.queryCookies(name, domain);
455
+ return cookies.catch(()=>[]);
456
+ }));
457
+ const flat = results.flat();
458
+ $f72befa528c23ca7$var$cache.set(`${name}:${domain}`, flat);
459
+ return flat;
460
+ }
461
+ }
462
+
463
+
464
+
465
+
466
+ function $9a6b2ace073cf1d7$export$2e2bcd8739ae039(token) {
467
+ try {
468
+ const result = (0, ($parcel$interopDefault($7oI3p$jsonwebtoken))).decode(token, {
469
+ complete: true
470
+ });
471
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(result);
472
+ const payload = result?.payload;
473
+ if (payload) {
474
+ const exp = payload.exp;
475
+ if (exp) {
476
+ const now = new Date().getTime() / 1000;
477
+ if (now > exp) return false;
478
+ }
479
+ }
480
+ return true;
481
+ } catch (err) {
482
+ return false;
483
+ }
484
+ }
485
+
486
+
487
+ async function $7a068a32d4710f0b$export$e6d428437cf2cacb({ name: name , domain: domain }, strategy = new (0, $f72befa528c23ca7$export$2e2bcd8739ae039)()) {
488
+ const results = await strategy.queryCookies(name, domain);
489
+ const results1 = (0, $7oI3p$lodash.uniqBy)(results, JSON.stringify);
490
+ const jwtCookies = [];
491
+ for (const result of results1){
492
+ const value = result.value;
493
+ if ((0, $9a6b2ace073cf1d7$export$2e2bcd8739ae039)(value)) jwtCookies.push(result);
494
+ }
495
+ const resultsUniq = (0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).REQUIRE_JWT ? jwtCookies : results1;
496
+ return (0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).SINGLE ? [
497
+ resultsUniq[0]
498
+ ] : resultsUniq;
499
+ }
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+ function $9c43c2ed82e63570$export$9abc0a414b0d8b8f(results) {
510
+ return (0, $7oI3p$lodash.uniqBy)(results, (r)=>r.name).map((r)=>r.name + "=" + r.value).join("; ");
511
+ }
512
+
513
+
514
+ async function $300d8b33187a203c$export$4d2e9997e2c23417(//
515
+ { name: name , domain: domain }) {
516
+ const cookies = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)({
517
+ name: name,
518
+ domain: domain
519
+ }, new (0, $f72befa528c23ca7$export$2e2bcd8739ae039)());
520
+ if (Array.isArray(cookies) && cookies.length > 0) {
521
+ const results = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)({
522
+ name: name,
523
+ domain: domain
524
+ });
525
+ const groupedByFile = (0, $7oI3p$lodash.groupBy)(results, (r)=>r.meta?.file);
526
+ return Object.keys(groupedByFile).map((file)=>{
527
+ const results = groupedByFile[file];
528
+ return (0, $9c43c2ed82e63570$export$9abc0a414b0d8b8f)(results);
529
+ });
530
+ } else throw new Error("Cookie not found");
531
+ }
532
+
533
+
534
+
535
+
536
+
537
+
538
+ async function $cfc07ae4aa2c7e44$export$b24a545a0b39f491(url, options = {}) {
539
+ const defaultOptions = {
540
+ headers: {
541
+ "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"
542
+ },
543
+ redirect: "manual"
544
+ };
545
+ const url2 = `${url}`;
546
+ const url1 = new URL(url2);
547
+ const domain = url1.hostname.replace(/^.*(\.\w+\.\w+)$/, (match, p1)=>{
548
+ return `%${p1}`;
549
+ });
550
+ const cookies = await (0, $300d8b33187a203c$export$4d2e9997e2c23417)({
551
+ name: "%",
552
+ domain: domain
553
+ });
554
+ const cookie = cookies.pop();
555
+ const newOptions1 = (0, $7oI3p$lodash.merge)(defaultOptions, options, {
556
+ headers: {
557
+ Cookie: cookie
558
+ }
559
+ });
560
+ try {
561
+ const res = await (0, $7oI3p$crossfetch.fetch)(url2, newOptions1);
562
+ const newUrl = res.headers.get("location");
563
+ if (res.redirected || newUrl && newUrl !== url2) return $cfc07ae4aa2c7e44$export$b24a545a0b39f491(newUrl, newOptions1);
564
+ const arrayBuffer1 = res.arrayBuffer();
565
+ const arrayBuffer = async ()=>arrayBuffer1;
566
+ const buffer = async ()=>arrayBuffer().then(Buffer.from);
567
+ const text = async ()=>buffer().then((buffer)=>buffer.toString("utf8"));
568
+ const json = async ()=>text().then((0, ($parcel$interopDefault($7oI3p$destr))));
569
+ const formData = async ()=>text().then((text)=>new URLSearchParams(text));
570
+ const source2 = {
571
+ status: res.status,
572
+ statusText: res.statusText,
573
+ headers: res.headers,
574
+ arrayBuffer: arrayBuffer,
575
+ buffer: buffer,
576
+ text: text,
577
+ json: json,
578
+ formData: formData
579
+ };
580
+ return (0, $7oI3p$lodash.merge)({}, res, source2);
581
+ } catch (e) {
582
+ throw e;
583
+ }
584
+ }
585
+
586
+
587
+ var $d5b6386167d289d2$exports = {};
588
+
589
+
590
+ var $3d7e27b54f670f46$exports = {};
591
+
592
+
593
+ var $6c197c88880e045c$exports = {};
594
+
595
+
596
+ async function $cd1ba0160120c006$export$4be65e66cfa2648a(params) {
597
+ const cookies = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)(params, new (0, $f72befa528c23ca7$export$2e2bcd8739ae039)());
598
+ if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
599
+ else throw new Error("Cookie not found");
600
+ }
601
+ async function $cd1ba0160120c006$export$c44c5fdef43f0941(params) {
602
+ const cookies = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)(params, new (0, $7bb7da9a77b2fd99$export$2e2bcd8739ae039)());
603
+ if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
604
+ else throw new Error("Cookie not found");
605
+ }
606
+ async function $cd1ba0160120c006$export$e5637297e9eb6f2e(params) {
607
+ const cookies = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)(params, new (0, $269fe42bfd555305$export$2e2bcd8739ae039)());
608
+ if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
609
+ else throw new Error("Cookie not found");
610
+ }
611
+ $parcel$exportWildcard(module.exports, $d5b6386167d289d2$exports);
612
+ $parcel$exportWildcard(module.exports, $3d7e27b54f670f46$exports);
613
+ $parcel$exportWildcard(module.exports, $6c197c88880e045c$exports);
614
+
615
+
3
616
  //# sourceMappingURL=index.js.map