@mherod/get-cookie 2.0.0-rc.24 → 2.0.0-rc.26

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