@mherod/get-cookie 2.0.0-rc.3 → 2.0.0-rc.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/runConfigurations/build.xml +12 -0
- package/.parcelrc +12 -0
- package/.prettierignore +5 -0
- package/.prettierrc +12 -0
- package/.terserrc +26 -0
- package/README.md +2 -2
- package/dist/cli.js +2 -0
- package/dist/index.js +2 -687
- package/dist/index.js.map +1 -0
- package/dist/module.js +1323 -0
- package/dist/module.js.map +1 -0
- package/dist/prompt.2b8c61c0.js +40 -0
- package/dist/prompt.536a2c51.js +40 -0
- package/dist/prompt.fb2c7dad.js.map +1 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -0
- package/jest.config.ts +14 -0
- package/package-lock.json +2688 -6684
- package/package.json +47 -35
- package/src/CookieRow.ts +1 -0
- package/src/CookieSpec.ts +3 -1
- package/src/CookieStore.ts +27 -0
- package/src/ExportedCookie.ts +13 -0
- package/src/FetchResponse.ts +1 -2
- package/src/FileCookieStore.ts +175 -0
- package/src/StringToRegex.ts +16 -0
- package/src/argv.ts +29 -0
- package/src/browsers/ChromeApplicationSupport.ts +10 -0
- package/src/browsers/ChromeCookieQueryStrategy.ts +71 -131
- package/src/browsers/CompositeCookieQueryStrategy.ts +35 -11
- package/src/browsers/CookieQueryStrategy.ts +2 -0
- package/src/browsers/CookieStoreQueryStrategy.ts +99 -0
- package/src/browsers/DoSqliteQueryWithTransform.ts +85 -0
- package/src/browsers/FirefoxCookieQueryStrategy.ts +12 -7
- package/src/browsers/SafariCookieQueryStrategy.ts +3 -0
- package/src/browsers/decrypt.ts +118 -0
- package/src/browsers/getChromePassword.ts +9 -0
- package/src/cli.ts +52 -36
- package/src/comboQueryCookieSpec.ts +24 -0
- package/src/cookieSpecsFromUrl.ts +26 -0
- package/src/execSimple.ts +13 -0
- package/src/fetchWithCookies.ts +105 -38
- package/src/findAllFiles.ts +26 -54
- package/src/getChromeCookie.ts +19 -0
- package/src/getCookie.ts +20 -0
- package/src/getFirefoxCookie.ts +19 -0
- package/src/getGroupedRenderedCookies.ts +11 -24
- package/src/getMergedRenderedCookies.ts +12 -0
- package/src/global.ts +1 -1
- package/src/index.ts +14 -58
- package/src/isValidJwt.ts +4 -4
- package/src/listChromeProfiles.ts +45 -0
- package/src/logger.ts +3 -0
- package/src/queryCookies.ts +20 -11
- package/src/resultsRendered.ts +6 -3
- package/src/util/flatMapAsync.test.ts +55 -0
- package/src/util/flatMapAsync.ts +37 -0
- package/tsconfig.json +12 -16
- package/.github/dependabot.yml +0 -6
- package/.prettierrc.json +0 -1
- package/src/IsExportedCookie.ts +0 -9
- package/src/MemoryCookieStore.ts +0 -5
- package/src/browsers/MemoryCookieJarQueryStrategy.ts +0 -53
- package/src/doSqliteQuery1.ts +0 -51
- package/src/utils.ts +0 -50
package/dist/module.js
ADDED
|
@@ -0,0 +1,1323 @@
|
|
|
1
|
+
#!/usr/bin/env bun run
|
|
2
|
+
import {uniqBy as $6B8p2$uniqBy, merge as $6B8p2$merge, groupBy as $6B8p2$groupBy, orderBy as $6B8p2$orderBy} from "lodash";
|
|
3
|
+
import $6B8p2$minimist from "minimist";
|
|
4
|
+
import $6B8p2$lrucache from "lru-cache";
|
|
5
|
+
import {red as $6B8p2$red, redBright as $6B8p2$redBright, blue as $6B8p2$blue, yellow as $6B8p2$yellow} from "colorette";
|
|
6
|
+
import $6B8p2$fs, {existsSync as $6B8p2$existsSync} from "fs";
|
|
7
|
+
import {join as $6B8p2$join} from "path";
|
|
8
|
+
import $6B8p2$consola from "consola";
|
|
9
|
+
import {sync as $6B8p2$sync} from "fast-glob";
|
|
10
|
+
import {execSync as $6B8p2$execSync} from "child_process";
|
|
11
|
+
import {pbkdf2 as $6B8p2$pbkdf2, createDecipheriv as $6B8p2$createDecipheriv} from "crypto";
|
|
12
|
+
import {Database as $6B8p2$Database} from "sqlite3";
|
|
13
|
+
import $6B8p2$jsonwebtoken from "jsonwebtoken";
|
|
14
|
+
import {fetch as $6B8p2$fetch} from "cross-fetch";
|
|
15
|
+
import $6B8p2$destr from "destr";
|
|
16
|
+
import $6B8p2$useragents from "user-agents";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var $01f4cf98d50740c6$var$_a;
|
|
22
|
+
const $01f4cf98d50740c6$export$6f4ae1207c703045 = ($01f4cf98d50740c6$var$_a = process.argv) !== null && $01f4cf98d50740c6$var$_a !== void 0 ? $01f4cf98d50740c6$var$_a : [];
|
|
23
|
+
const $01f4cf98d50740c6$var$minimistArgs = (0, $6B8p2$minimist)($01f4cf98d50740c6$export$6f4ae1207c703045.slice(2));
|
|
24
|
+
const $01f4cf98d50740c6$var$defaultOptions = {
|
|
25
|
+
verbose: false
|
|
26
|
+
};
|
|
27
|
+
const $01f4cf98d50740c6$export$c348dfaf65040d9b = (0, $6B8p2$merge)($01f4cf98d50740c6$var$defaultOptions, $01f4cf98d50740c6$var$minimistArgs);
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var $ebc8f9a71f429261$var$_a;
|
|
32
|
+
const $ebc8f9a71f429261$export$a7b6bc01c63cdfc3 = {};
|
|
33
|
+
(0, $6B8p2$merge)($ebc8f9a71f429261$export$a7b6bc01c63cdfc3, ($ebc8f9a71f429261$var$_a = process === null || process === void 0 ? void 0 : process.env) !== null && $ebc8f9a71f429261$var$_a !== void 0 ? $ebc8f9a71f429261$var$_a : {});
|
|
34
|
+
const $ebc8f9a71f429261$export$a7c5707626fc90f = $ebc8f9a71f429261$export$a7b6bc01c63cdfc3["HOME"];
|
|
35
|
+
if (!$ebc8f9a71f429261$export$a7c5707626fc90f) throw new Error("HOME environment variable is not set");
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
function $a6c1a5673fde1c2b$export$2c9faf86071156ae(//
|
|
44
|
+
{ path: path, name: name, maxDepth: maxDepth = 2 }) {
|
|
45
|
+
if (!(0, $6B8p2$existsSync)(path)) throw new Error(`Path ${path} does not exist`);
|
|
46
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) (0, $6B8p2$consola).start(`Searching for ${name} files in ${path}`);
|
|
47
|
+
const files = (0, $6B8p2$sync)(`${path}/**/${name}`, {
|
|
48
|
+
onlyFiles: true,
|
|
49
|
+
deep: maxDepth
|
|
50
|
+
});
|
|
51
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) {
|
|
52
|
+
if (files.length > 0) {
|
|
53
|
+
(0, $6B8p2$consola).success(`Found ${files.length} ${name} files`);
|
|
54
|
+
(0, $6B8p2$consola).info(files);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return files;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function $63d6ce571e62efc6$export$bc926c43858bd3cb(obj) {
|
|
64
|
+
return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
function $cf39947f238e32e1$export$963c8d651337e4a4(obj) {
|
|
69
|
+
return typeof obj.domain === "string" && typeof obj.name === "string" && typeof obj.value === "string" && (obj.expiry === undefined || obj.expiry instanceof Date || obj.expiry === "Infinity") && (obj.meta === undefined || typeof obj.meta === "object");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
// This function converts a string into a regular expression
|
|
74
|
+
function $78efb18fcf7b6c2c$export$4eadcf0bf35a2ddb(s) {
|
|
75
|
+
// Replace all occurrences of '.' with a literal '.'
|
|
76
|
+
const s1 = s.replaceAll(/\./gi, ".");
|
|
77
|
+
// Replace all occurrences of '%' with '.*' to match any number of any characters
|
|
78
|
+
const s2 = s1.replace(/%/g, ".*");
|
|
79
|
+
// Replace all occurrences of '*' with '.*' to match any number of any characters
|
|
80
|
+
const s3 = s2.replace(/\*/g, ".*");
|
|
81
|
+
// Return the new string as a RegExp object
|
|
82
|
+
return new RegExp(s3);
|
|
83
|
+
} /*
|
|
84
|
+
%.example.com -> .*\.example\.com
|
|
85
|
+
example.com -> example\.com
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
var $9854e148a157cf4f$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
93
|
+
function adopt(value) {
|
|
94
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
95
|
+
resolve(value);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
99
|
+
function fulfilled(value) {
|
|
100
|
+
try {
|
|
101
|
+
step(generator.next(value));
|
|
102
|
+
} catch (e) {
|
|
103
|
+
reject(e);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function rejected(value) {
|
|
107
|
+
try {
|
|
108
|
+
step(generator["throw"](value));
|
|
109
|
+
} catch (e) {
|
|
110
|
+
reject(e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function step(result) {
|
|
114
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
115
|
+
}
|
|
116
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
function $9854e148a157cf4f$export$8d71c74f97c0202e(command) {
|
|
120
|
+
return $9854e148a157cf4f$var$__awaiter(this, void 0, void 0, function*() {
|
|
121
|
+
try {
|
|
122
|
+
const stdout = (0, $6B8p2$execSync)(command, {
|
|
123
|
+
encoding: "binary",
|
|
124
|
+
maxBuffer: 5120
|
|
125
|
+
});
|
|
126
|
+
return stdout.trim();
|
|
127
|
+
} catch (error) {
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
var $b40272b017401e2b$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
135
|
+
function adopt(value) {
|
|
136
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
137
|
+
resolve(value);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
141
|
+
function fulfilled(value) {
|
|
142
|
+
try {
|
|
143
|
+
step(generator.next(value));
|
|
144
|
+
} catch (e) {
|
|
145
|
+
reject(e);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function rejected(value) {
|
|
149
|
+
try {
|
|
150
|
+
step(generator["throw"](value));
|
|
151
|
+
} catch (e) {
|
|
152
|
+
reject(e);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function step(result) {
|
|
156
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
157
|
+
}
|
|
158
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
const $b40272b017401e2b$var$chromePassword = (0, $9854e148a157cf4f$export$8d71c74f97c0202e)('security find-generic-password -w -s "Chrome Safe Storage"');
|
|
162
|
+
function $b40272b017401e2b$export$91552cff7edf316() {
|
|
163
|
+
return $b40272b017401e2b$var$__awaiter(this, void 0, void 0, function*() {
|
|
164
|
+
return yield $b40272b017401e2b$var$chromePassword;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
const $89c1e78462503bf7$export$6c123efa52771cfa = (0, $6B8p2$join)((0, $ebc8f9a71f429261$export$a7c5707626fc90f), "Library", "Application Support", "Google", "Chrome");
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
var $1776b4cc4877131a$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
178
|
+
function adopt(value) {
|
|
179
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
180
|
+
resolve(value);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
184
|
+
function fulfilled(value) {
|
|
185
|
+
try {
|
|
186
|
+
step(generator.next(value));
|
|
187
|
+
} catch (e) {
|
|
188
|
+
reject(e);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function rejected(value) {
|
|
192
|
+
try {
|
|
193
|
+
step(generator["throw"](value));
|
|
194
|
+
} catch (e) {
|
|
195
|
+
reject(e);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function step(result) {
|
|
199
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
200
|
+
}
|
|
201
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
function $1776b4cc4877131a$export$e85a0c9a1067c5d3(password, encryptedData // The data to decrypt
|
|
205
|
+
) {
|
|
206
|
+
return $1776b4cc4877131a$var$__awaiter(this, void 0, void 0, function*() {
|
|
207
|
+
// Returns a promise that resolves with the decrypted string
|
|
208
|
+
// Check if password is a string
|
|
209
|
+
if (typeof password !== "string") throw new Error("password must be a string: " + password);
|
|
210
|
+
let encryptedData1;
|
|
211
|
+
encryptedData1 = encryptedData;
|
|
212
|
+
// Check if encryptedData is an object
|
|
213
|
+
if (encryptedData1 == null || typeof encryptedData1 !== "object") throw new Error("encryptedData must be a object: " + encryptedData1);
|
|
214
|
+
// Check if encryptedData is a Buffer or an array of Buffers
|
|
215
|
+
if (!(encryptedData1 instanceof Buffer)) {
|
|
216
|
+
if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {
|
|
217
|
+
[encryptedData1] = encryptedData1;
|
|
218
|
+
// Log if encryptedData is an array of buffers
|
|
219
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log(`encryptedData is an array of buffers, selected first: ${encryptedData1}`);
|
|
220
|
+
} else throw new Error("encryptedData must be a Buffer: " + encryptedData1);
|
|
221
|
+
encryptedData1 = Buffer.from(encryptedData1);
|
|
222
|
+
}
|
|
223
|
+
// Log the password being used for decryption
|
|
224
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) (0, $6B8p2$consola).start(`Trying to decrypt with password: ${password}`);
|
|
225
|
+
// Return a promise that resolves with the decrypted string
|
|
226
|
+
return new Promise((resolve, reject)=>{
|
|
227
|
+
// Use pbkdf2 to derive a key from the password
|
|
228
|
+
(0, $6B8p2$pbkdf2)(password, "saltysalt", 1003, 16, "sha1", (error, buffer)=>{
|
|
229
|
+
try {
|
|
230
|
+
// Handle any errors from pbkdf2
|
|
231
|
+
if (error) {
|
|
232
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log("Error doing pbkdf2", error);
|
|
233
|
+
reject(error);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
// Check if the buffer length is 16
|
|
237
|
+
if (buffer.length !== 16) {
|
|
238
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log("Error doing pbkdf2, buffer length is not 16", buffer.length);
|
|
239
|
+
reject(new Error("Buffer length is not 16"));
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
// Create an initialization vector
|
|
243
|
+
const str = new Array(17).join(" ");
|
|
244
|
+
const iv = Buffer.from(str, "binary");
|
|
245
|
+
// Create a decipher using the derived key and initialization vector
|
|
246
|
+
const decipher = (0, $6B8p2$createDecipheriv)("aes-128-cbc", buffer, iv);
|
|
247
|
+
decipher.setAutoPadding(false);
|
|
248
|
+
// Remove the first 3 bytes from the encrypted data
|
|
249
|
+
if (encryptedData1 && encryptedData1.slice) encryptedData1 = encryptedData1.slice(3);
|
|
250
|
+
// Check if the encrypted data length is a multiple of 16
|
|
251
|
+
if (encryptedData1.length % 16 !== 0) {
|
|
252
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log("Error doing pbkdf2, encryptedData length is not a multiple of 16", encryptedData1.length);
|
|
253
|
+
reject(new Error("encryptedData length is not a multiple of 16"));
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
// Update the decipher with the encrypted data
|
|
257
|
+
let decoded = decipher.update(encryptedData1);
|
|
258
|
+
try {
|
|
259
|
+
// Finalize the decipher
|
|
260
|
+
decipher.final("utf-8");
|
|
261
|
+
} catch (e) {
|
|
262
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log("Error doing decipher.final()", e);
|
|
263
|
+
reject(e);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
// Remove padding from the decoded data
|
|
267
|
+
const padding = decoded[decoded.length - 1];
|
|
268
|
+
if (padding) decoded = decoded.slice(0, 0 - padding);
|
|
269
|
+
// Convert the decoded data to a string
|
|
270
|
+
const decodedString = decoded.toString("utf8");
|
|
271
|
+
// Resolve the promise with the decrypted string
|
|
272
|
+
resolve(decodedString);
|
|
273
|
+
} catch (e) {
|
|
274
|
+
// Reject the promise if there is an error
|
|
275
|
+
reject(e);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
var $314d38a8021f1e34$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
289
|
+
function adopt(value) {
|
|
290
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
291
|
+
resolve(value);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
295
|
+
function fulfilled(value) {
|
|
296
|
+
try {
|
|
297
|
+
step(generator.next(value));
|
|
298
|
+
} catch (e) {
|
|
299
|
+
reject(e);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function rejected(value) {
|
|
303
|
+
try {
|
|
304
|
+
step(generator["throw"](value));
|
|
305
|
+
} catch (e) {
|
|
306
|
+
reject(e);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function step(result) {
|
|
310
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
311
|
+
}
|
|
312
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
function $314d38a8021f1e34$var$checkFileExistence(file) {
|
|
316
|
+
if (!file || !(0, $6B8p2$fs).existsSync(file)) throw new Error(`File ${file} does not exist`);
|
|
317
|
+
}
|
|
318
|
+
function $314d38a8021f1e34$var$createDatabase(file) {
|
|
319
|
+
return new (0, $6B8p2$Database)(file);
|
|
320
|
+
}
|
|
321
|
+
function $314d38a8021f1e34$var$transformRows(//
|
|
322
|
+
rows, rowFilter, rowTransform, file) {
|
|
323
|
+
return rows.filter(rowFilter).map((row)=>{
|
|
324
|
+
const metaData = {
|
|
325
|
+
meta: {
|
|
326
|
+
file: file
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const cookieRow = rowTransform(row);
|
|
330
|
+
return (0, $6B8p2$merge)(metaData, cookieRow);
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function $314d38a8021f1e34$export$a24b988c49ded60e(//
|
|
334
|
+
{ file: //
|
|
335
|
+
file, sql: sql, rowFilter: rowFilter = ()=>true, rowTransform: rowTransform }) {
|
|
336
|
+
return $314d38a8021f1e34$var$__awaiter(this, void 0, void 0, function*() {
|
|
337
|
+
$314d38a8021f1e34$var$checkFileExistence(file);
|
|
338
|
+
const db = $314d38a8021f1e34$var$createDatabase(file);
|
|
339
|
+
return new Promise((resolve, reject)=>{
|
|
340
|
+
db.all(sql, (err, rows)=>{
|
|
341
|
+
if (err) return reject(err);
|
|
342
|
+
if (!rows || rows.length === 0) return resolve([]);
|
|
343
|
+
const cookieRows = $314d38a8021f1e34$var$transformRows(rows, rowFilter, rowTransform, file);
|
|
344
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) (0, $6B8p2$consola).log(`Rows: ${JSON.stringify(rows)}`);
|
|
345
|
+
return resolve(cookieRows);
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
var $a6f61760d01c3afd$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
353
|
+
function adopt(value) {
|
|
354
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
355
|
+
resolve(value);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
359
|
+
function fulfilled(value) {
|
|
360
|
+
try {
|
|
361
|
+
step(generator.next(value));
|
|
362
|
+
} catch (e) {
|
|
363
|
+
reject(e);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
function rejected(value) {
|
|
367
|
+
try {
|
|
368
|
+
step(generator["throw"](value));
|
|
369
|
+
} catch (e) {
|
|
370
|
+
reject(e);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function step(result) {
|
|
374
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
375
|
+
}
|
|
376
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
class $a6f61760d01c3afd$export$2e2bcd8739ae039 {
|
|
380
|
+
constructor(){
|
|
381
|
+
this.browserName = "Chrome";
|
|
382
|
+
}
|
|
383
|
+
queryCookies(name, domain) {
|
|
384
|
+
return $a6f61760d01c3afd$var$__awaiter(this, void 0, void 0, function*() {
|
|
385
|
+
if (process.platform !== "darwin") throw new Error("This only works on macOS");
|
|
386
|
+
if ((0, $ebc8f9a71f429261$export$a7b6bc01c63cdfc3).FIREFOX_ONLY) return [];
|
|
387
|
+
return $a6f61760d01c3afd$var$getChromeCookies({
|
|
388
|
+
requireJwt: false,
|
|
389
|
+
name: name,
|
|
390
|
+
domain: domain
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function $a6f61760d01c3afd$var$getPromise1(name, domain, file) {
|
|
396
|
+
return $a6f61760d01c3afd$var$__awaiter(this, void 0, void 0, function*() {
|
|
397
|
+
try {
|
|
398
|
+
return yield $a6f61760d01c3afd$var$getEncryptedChromeCookie({
|
|
399
|
+
name: name,
|
|
400
|
+
domain: domain,
|
|
401
|
+
file: file
|
|
402
|
+
});
|
|
403
|
+
} catch (e) {
|
|
404
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log("Error getting encrypted cookie", e);
|
|
405
|
+
return [];
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
function $a6f61760d01c3afd$var$getPromise(name, domain) {
|
|
410
|
+
return $a6f61760d01c3afd$var$__awaiter(this, void 0, void 0, function*() {
|
|
411
|
+
try {
|
|
412
|
+
const files = yield (0, $a6c1a5673fde1c2b$export$2c9faf86071156ae)({
|
|
413
|
+
path: (0, $89c1e78462503bf7$export$6c123efa52771cfa),
|
|
414
|
+
name: "Cookies"
|
|
415
|
+
});
|
|
416
|
+
const promises = files.map((file)=>$a6f61760d01c3afd$var$getPromise1(name, domain, file));
|
|
417
|
+
const results1 = yield Promise.all(promises);
|
|
418
|
+
return results1.flat().filter((0, $63d6ce571e62efc6$export$bc926c43858bd3cb));
|
|
419
|
+
} catch (error) {
|
|
420
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log("error", error);
|
|
421
|
+
return [];
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function $a6f61760d01c3afd$var$decryptValue(password, encryptedValue) {
|
|
426
|
+
return $a6f61760d01c3afd$var$__awaiter(this, void 0, void 0, function*() {
|
|
427
|
+
let d;
|
|
428
|
+
try {
|
|
429
|
+
d = yield (0, $1776b4cc4877131a$export$e85a0c9a1067c5d3)(password, encryptedValue);
|
|
430
|
+
} catch (e) {
|
|
431
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log("Error decrypting cookie", e);
|
|
432
|
+
d = null;
|
|
433
|
+
}
|
|
434
|
+
return d !== null && d !== void 0 ? d : encryptedValue.toString("utf-8");
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
function $a6f61760d01c3afd$var$getChromeCookies({ name: name, domain: domain = "%", requireJwt: requireJwt = false }) {
|
|
438
|
+
return $a6f61760d01c3afd$var$__awaiter(this, void 0, void 0, function*() {
|
|
439
|
+
const encryptedDataItems = yield $a6f61760d01c3afd$var$getPromise(name, domain);
|
|
440
|
+
const password = yield (0, $b40272b017401e2b$export$91552cff7edf316)();
|
|
441
|
+
const decrypted = encryptedDataItems.filter(({ value: value })=>value != null && value.length > 0).map((cookieRow)=>$a6f61760d01c3afd$var$__awaiter(this, void 0, void 0, function*() {
|
|
442
|
+
var _a;
|
|
443
|
+
const encryptedValue = cookieRow.value;
|
|
444
|
+
const decryptedValue = yield $a6f61760d01c3afd$var$decryptValue(password, encryptedValue);
|
|
445
|
+
const meta = {};
|
|
446
|
+
(0, $6B8p2$merge)(meta, (_a = cookieRow.meta) !== null && _a !== void 0 ? _a : {});
|
|
447
|
+
const exportedCookie = {
|
|
448
|
+
domain: cookieRow.domain,
|
|
449
|
+
name: cookieRow.name,
|
|
450
|
+
value: decryptedValue,
|
|
451
|
+
meta: meta
|
|
452
|
+
};
|
|
453
|
+
const expiry = cookieRow.expiry;
|
|
454
|
+
const mergeExpiry = expiry != null && expiry > 0 ? {
|
|
455
|
+
expiry: new Date(expiry)
|
|
456
|
+
} : {
|
|
457
|
+
expiry: "Infinity"
|
|
458
|
+
};
|
|
459
|
+
(0, $6B8p2$merge)(exportedCookie, mergeExpiry);
|
|
460
|
+
return exportedCookie;
|
|
461
|
+
}));
|
|
462
|
+
const results = (yield Promise.all(decrypted)).filter((0, $cf39947f238e32e1$export$963c8d651337e4a4));
|
|
463
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log("results", results);
|
|
464
|
+
return results;
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function $a6f61760d01c3afd$var$getEncryptedChromeCookie({ name: name, domain: domain, file: file = (0, $6B8p2$join)((0, $89c1e78462503bf7$export$6c123efa52771cfa), "Default", "Cookies") }) {
|
|
468
|
+
return $a6f61760d01c3afd$var$__awaiter(this, void 0, void 0, function*() {
|
|
469
|
+
if (!(0, $6B8p2$existsSync)(file)) throw new Error(`File ${file} does not exist`);
|
|
470
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) {
|
|
471
|
+
const s = file.split("/").slice(-3).join("/");
|
|
472
|
+
(0, $6B8p2$consola).start(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);
|
|
473
|
+
}
|
|
474
|
+
let sql;
|
|
475
|
+
//language=SQL
|
|
476
|
+
sql = "SELECT encrypted_value, name, host_key, expires_utc FROM cookies";
|
|
477
|
+
// Define a regular expression to match wildcard characters
|
|
478
|
+
const wildcardRegexp = /^([*%])$/i;
|
|
479
|
+
// Check if the name does not contain wildcard characters
|
|
480
|
+
const specifiedName = name.match(wildcardRegexp) == null;
|
|
481
|
+
// Check if the domain does not contain wildcard characters
|
|
482
|
+
const specifiedDomain = domain.match(wildcardRegexp) == null;
|
|
483
|
+
// Check if the domain contains wildcard characters
|
|
484
|
+
const wildcardDomain = domain.match(/[%*]/) != null;
|
|
485
|
+
// Determine if we should query the domain based on the previous checks
|
|
486
|
+
const queryDomain = specifiedDomain && !wildcardDomain;
|
|
487
|
+
// if we have a wildcard domain, we need to use a regexp
|
|
488
|
+
// If the name is specified or we need to query the domain, we add a WHERE clause to the SQL query
|
|
489
|
+
if (specifiedName || queryDomain) {
|
|
490
|
+
sql += ` WHERE `;
|
|
491
|
+
// If the name is specified, we add a condition to the SQL query to match the name
|
|
492
|
+
if (specifiedName) {
|
|
493
|
+
sql += `name = '${name}'`;
|
|
494
|
+
// If we also need to query the domain, we add an AND operator to the SQL query
|
|
495
|
+
if (queryDomain) sql += ` AND `;
|
|
496
|
+
}
|
|
497
|
+
// If we need to query the domain, we add a condition to the SQL query to match the domain
|
|
498
|
+
if (queryDomain) {
|
|
499
|
+
// The leading dot is replaced with % to match subdomains
|
|
500
|
+
const sqlEmbedDomain = domain.replace(/^[.%]?/, "%");
|
|
501
|
+
sql += `host_key LIKE '${sqlEmbedDomain}';`;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) (0, $6B8p2$consola).info("Querying:", sql);
|
|
505
|
+
const domainRegexp = (0, $78efb18fcf7b6c2c$export$4eadcf0bf35a2ddb)(domain);
|
|
506
|
+
const sqliteQuery1 = yield (0, $314d38a8021f1e34$export$a24b988c49ded60e)({
|
|
507
|
+
file: file,
|
|
508
|
+
sql: sql,
|
|
509
|
+
rowFilter: (row)=>{
|
|
510
|
+
return row["host_key"].match(domainRegexp) != null;
|
|
511
|
+
},
|
|
512
|
+
rowTransform: (row)=>{
|
|
513
|
+
const cookieRow = {
|
|
514
|
+
expiry: (row["expires_utc"] / 1000000 - 11644473600) * 1000,
|
|
515
|
+
domain: row["host_key"],
|
|
516
|
+
name: row["name"],
|
|
517
|
+
value: row["encrypted_value"]
|
|
518
|
+
};
|
|
519
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) (0, $6B8p2$consola).info("Found", cookieRow);
|
|
520
|
+
return cookieRow;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
return sqliteQuery1.filter((row)=>{
|
|
524
|
+
// TODO: is this needed?
|
|
525
|
+
return row.domain.match(domainRegexp) != null;
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
function $81d2f9cb974d13de$export$da22813e5a2ec500({ name: name, domain: domain }) {
|
|
536
|
+
const wildcardRegexp = /^([*%])$/i;
|
|
537
|
+
return {
|
|
538
|
+
specifiedName: name.match(wildcardRegexp) == null,
|
|
539
|
+
specifiedDomain: domain.match(wildcardRegexp) == null
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
var $62dcb7ce199205be$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
547
|
+
function adopt(value) {
|
|
548
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
549
|
+
resolve(value);
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
553
|
+
function fulfilled(value) {
|
|
554
|
+
try {
|
|
555
|
+
step(generator.next(value));
|
|
556
|
+
} catch (e) {
|
|
557
|
+
reject(e);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function rejected(value) {
|
|
561
|
+
try {
|
|
562
|
+
step(generator["throw"](value));
|
|
563
|
+
} catch (e) {
|
|
564
|
+
reject(e);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
function step(result) {
|
|
568
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
569
|
+
}
|
|
570
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
var $62dcb7ce199205be$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
|
|
574
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
575
|
+
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");
|
|
576
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
577
|
+
};
|
|
578
|
+
var $62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_instances, $62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_getFirefoxCookie, $62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_queryCookiesDb;
|
|
579
|
+
class $62dcb7ce199205be$var$FirefoxCookieQueryStrategy {
|
|
580
|
+
constructor(){
|
|
581
|
+
$62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_instances.add(this);
|
|
582
|
+
this.browserName = "Firefox";
|
|
583
|
+
}
|
|
584
|
+
queryCookies(name, domain) {
|
|
585
|
+
return $62dcb7ce199205be$var$__awaiter(this, void 0, void 0, function*() {
|
|
586
|
+
if (process.platform !== "darwin") // TODO: implement
|
|
587
|
+
return [];
|
|
588
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).browser !== "firefox") return [];
|
|
589
|
+
const cookies = yield $62dcb7ce199205be$var$__classPrivateFieldGet(this, $62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_instances, "m", $62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_getFirefoxCookie).call(this, {
|
|
590
|
+
name: name,
|
|
591
|
+
domain: domain
|
|
592
|
+
});
|
|
593
|
+
if (Array.isArray(cookies)) return cookies.map((cookie)=>{
|
|
594
|
+
return {
|
|
595
|
+
domain: cookie.domain,
|
|
596
|
+
name: cookie.name,
|
|
597
|
+
value: cookie.value.toString("utf8")
|
|
598
|
+
};
|
|
599
|
+
});
|
|
600
|
+
else return [];
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
$62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_instances = new WeakSet(), $62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_getFirefoxCookie = function _FirefoxCookieQueryStrategy_getFirefoxCookie({ name: name, domain: domain } //
|
|
605
|
+
) {
|
|
606
|
+
return $62dcb7ce199205be$var$__awaiter(this, void 0, void 0, function*() {
|
|
607
|
+
const files = (0, $a6c1a5673fde1c2b$export$2c9faf86071156ae)({
|
|
608
|
+
path: $6B8p2$join((0, $ebc8f9a71f429261$export$a7c5707626fc90f), "Library", "Application Support", "Firefox", "Profiles"),
|
|
609
|
+
name: "cookies.sqlite"
|
|
610
|
+
});
|
|
611
|
+
const fn = (file)=>$62dcb7ce199205be$var$__awaiter(this, void 0, void 0, function*() {
|
|
612
|
+
return yield $62dcb7ce199205be$var$__classPrivateFieldGet(this, $62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_instances, "m", $62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_queryCookiesDb).call(this, file, name, domain);
|
|
613
|
+
});
|
|
614
|
+
const all = yield Promise.all(files.map(fn));
|
|
615
|
+
// flatten
|
|
616
|
+
return all.flat();
|
|
617
|
+
});
|
|
618
|
+
}, $62dcb7ce199205be$var$_FirefoxCookieQueryStrategy_queryCookiesDb = function _FirefoxCookieQueryStrategy_queryCookiesDb(file, name, domain) {
|
|
619
|
+
return $62dcb7ce199205be$var$__awaiter(this, void 0, void 0, function*() {
|
|
620
|
+
if (file && !(0, $6B8p2$existsSync)(file)) throw new Error(`File ${file} does not exist`);
|
|
621
|
+
let sql;
|
|
622
|
+
//language=SQL
|
|
623
|
+
sql = "SELECT value, name, host FROM moz_cookies";
|
|
624
|
+
const { specifiedName: specifiedName, specifiedDomain: specifiedDomain } = (0, $81d2f9cb974d13de$export$da22813e5a2ec500)({
|
|
625
|
+
name: name,
|
|
626
|
+
domain: domain
|
|
627
|
+
});
|
|
628
|
+
if (specifiedName || specifiedDomain) {
|
|
629
|
+
sql += ` WHERE `;
|
|
630
|
+
if (specifiedName) {
|
|
631
|
+
sql += `name = '${name}'`;
|
|
632
|
+
if (specifiedDomain) sql += ` AND `;
|
|
633
|
+
}
|
|
634
|
+
if (specifiedDomain) sql += `host LIKE '${domain}';`;
|
|
635
|
+
}
|
|
636
|
+
const rowTransform = (row)=>{
|
|
637
|
+
// row is object key by column name
|
|
638
|
+
const value = row.value;
|
|
639
|
+
return {
|
|
640
|
+
domain: row.domain,
|
|
641
|
+
name: row.name,
|
|
642
|
+
value: Buffer.from(value, "utf8")
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
try {
|
|
646
|
+
return yield (0, $314d38a8021f1e34$export$a24b988c49ded60e)({
|
|
647
|
+
file: file,
|
|
648
|
+
sql: sql,
|
|
649
|
+
rowTransform: rowTransform
|
|
650
|
+
});
|
|
651
|
+
} catch (e) {
|
|
652
|
+
console.error(`Error querying ${file}`, e);
|
|
653
|
+
return [];
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
};
|
|
657
|
+
var $62dcb7ce199205be$export$2e2bcd8739ae039 = $62dcb7ce199205be$var$FirefoxCookieQueryStrategy;
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
var $b470ee3b0b06a25e$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
661
|
+
function adopt(value) {
|
|
662
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
663
|
+
resolve(value);
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
667
|
+
function fulfilled(value) {
|
|
668
|
+
try {
|
|
669
|
+
step(generator.next(value));
|
|
670
|
+
} catch (e) {
|
|
671
|
+
reject(e);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function rejected(value) {
|
|
675
|
+
try {
|
|
676
|
+
step(generator["throw"](value));
|
|
677
|
+
} catch (e) {
|
|
678
|
+
reject(e);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function step(result) {
|
|
682
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
683
|
+
}
|
|
684
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
685
|
+
});
|
|
686
|
+
};
|
|
687
|
+
class $b470ee3b0b06a25e$export$2e2bcd8739ae039 {
|
|
688
|
+
constructor(){
|
|
689
|
+
this.browserName = "Safari";
|
|
690
|
+
}
|
|
691
|
+
queryCookies(name, domain) {
|
|
692
|
+
return $b470ee3b0b06a25e$var$__awaiter(this, void 0, void 0, function*() {
|
|
693
|
+
// TODO: implement
|
|
694
|
+
return [];
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
var $49168e685ea38e19$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
705
|
+
function adopt(value) {
|
|
706
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
707
|
+
resolve(value);
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
711
|
+
function fulfilled(value) {
|
|
712
|
+
try {
|
|
713
|
+
step(generator.next(value));
|
|
714
|
+
} catch (e) {
|
|
715
|
+
reject(e);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
function rejected(value) {
|
|
719
|
+
try {
|
|
720
|
+
step(generator["throw"](value));
|
|
721
|
+
} catch (e) {
|
|
722
|
+
reject(e);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
function step(result) {
|
|
726
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
727
|
+
}
|
|
728
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
729
|
+
});
|
|
730
|
+
};
|
|
731
|
+
var $49168e685ea38e19$var$__classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
|
|
732
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
733
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
734
|
+
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");
|
|
735
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
736
|
+
};
|
|
737
|
+
var $49168e685ea38e19$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
|
|
738
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
739
|
+
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");
|
|
740
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
741
|
+
};
|
|
742
|
+
var $49168e685ea38e19$var$_CompositeCookieQueryStrategy_strategies;
|
|
743
|
+
const $49168e685ea38e19$var$cache = new (0, $6B8p2$lrucache)({
|
|
744
|
+
ttl: 10000,
|
|
745
|
+
max: 10
|
|
746
|
+
});
|
|
747
|
+
class $49168e685ea38e19$var$CompositeCookieQueryStrategy {
|
|
748
|
+
constructor(){
|
|
749
|
+
this.browserName = "all";
|
|
750
|
+
$49168e685ea38e19$var$_CompositeCookieQueryStrategy_strategies.set(this, void 0);
|
|
751
|
+
$49168e685ea38e19$var$__classPrivateFieldSet(this, $49168e685ea38e19$var$_CompositeCookieQueryStrategy_strategies, [
|
|
752
|
+
// CookieStoreQueryStrategy,
|
|
753
|
+
(0, $a6f61760d01c3afd$export$2e2bcd8739ae039),
|
|
754
|
+
(0, $62dcb7ce199205be$export$2e2bcd8739ae039),
|
|
755
|
+
(0, $b470ee3b0b06a25e$export$2e2bcd8739ae039)
|
|
756
|
+
].map((strategy)=>{
|
|
757
|
+
return new strategy();
|
|
758
|
+
}), "f");
|
|
759
|
+
}
|
|
760
|
+
queryCookies(name, domain) {
|
|
761
|
+
return $49168e685ea38e19$var$__awaiter(this, void 0, void 0, function*() {
|
|
762
|
+
// domain = domain.match(/(\w+.+\w+)/gi)?.pop() ?? domain;
|
|
763
|
+
const key = `${name}:${domain}`;
|
|
764
|
+
const cached = $49168e685ea38e19$var$cache.get(key);
|
|
765
|
+
if (cached) return cached;
|
|
766
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log("Querying cookies:", name, domain);
|
|
767
|
+
const results = yield Promise.all($49168e685ea38e19$var$__classPrivateFieldGet(this, $49168e685ea38e19$var$_CompositeCookieQueryStrategy_strategies, "f").map((strategy)=>$49168e685ea38e19$var$__awaiter(this, void 0, void 0, function*() {
|
|
768
|
+
// @ts-ignore
|
|
769
|
+
return strategy.queryCookies(name, domain).then((cookies)=>{
|
|
770
|
+
return cookies.map((cookie)=>{
|
|
771
|
+
return (0, $6B8p2$merge)(cookie, {
|
|
772
|
+
meta: {
|
|
773
|
+
browser: strategy.browserName
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
}).catch((e)=>{
|
|
778
|
+
console.log((0, $6B8p2$red)(`Error querying ${strategy.browserName} cookies`), e);
|
|
779
|
+
return [];
|
|
780
|
+
});
|
|
781
|
+
})));
|
|
782
|
+
const flat = results.flat();
|
|
783
|
+
$49168e685ea38e19$var$cache.set(`${name}:${domain}`, flat);
|
|
784
|
+
return flat;
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
$49168e685ea38e19$var$_CompositeCookieQueryStrategy_strategies = new WeakMap();
|
|
789
|
+
var $49168e685ea38e19$export$2e2bcd8739ae039 = $49168e685ea38e19$var$CompositeCookieQueryStrategy;
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
function $459cd094c935086e$export$2e2bcd8739ae039(token) {
|
|
795
|
+
try {
|
|
796
|
+
const result = (0, $6B8p2$jsonwebtoken).decode(token, {
|
|
797
|
+
complete: true
|
|
798
|
+
});
|
|
799
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose && result) console.debug(result);
|
|
800
|
+
const payload = result === null || result === void 0 ? void 0 : result.payload;
|
|
801
|
+
if (payload) {
|
|
802
|
+
const exp = payload.exp;
|
|
803
|
+
if (exp) {
|
|
804
|
+
const now = new Date().getTime() / 1000;
|
|
805
|
+
if (now > exp) return false;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return true;
|
|
809
|
+
} catch (err) {
|
|
810
|
+
return false;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
var $f382029733f65752$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
816
|
+
function adopt(value) {
|
|
817
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
818
|
+
resolve(value);
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
822
|
+
function fulfilled(value) {
|
|
823
|
+
try {
|
|
824
|
+
step(generator.next(value));
|
|
825
|
+
} catch (e) {
|
|
826
|
+
reject(e);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
function rejected(value) {
|
|
830
|
+
try {
|
|
831
|
+
step(generator["throw"](value));
|
|
832
|
+
} catch (e) {
|
|
833
|
+
reject(e);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
function step(result) {
|
|
837
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
838
|
+
}
|
|
839
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
840
|
+
});
|
|
841
|
+
};
|
|
842
|
+
function $f382029733f65752$export$e6d428437cf2cacb({ name: name, domain: domain }, strategy = new (0, $49168e685ea38e19$export$2e2bcd8739ae039)()) {
|
|
843
|
+
return $f382029733f65752$var$__awaiter(this, void 0, void 0, function*() {
|
|
844
|
+
//
|
|
845
|
+
const results = yield strategy.queryCookies(name, domain);
|
|
846
|
+
const allCookies = (0, $6B8p2$uniqBy)(results, JSON.stringify);
|
|
847
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b)["require-jwt"]) {
|
|
848
|
+
const jwtCookies = [];
|
|
849
|
+
for (const result of allCookies){
|
|
850
|
+
const value = result.value;
|
|
851
|
+
if ((0, $459cd094c935086e$export$2e2bcd8739ae039)(value)) jwtCookies.push(result);
|
|
852
|
+
}
|
|
853
|
+
return (0, $01f4cf98d50740c6$export$c348dfaf65040d9b)["single"] ? [
|
|
854
|
+
jwtCookies[0]
|
|
855
|
+
] : jwtCookies;
|
|
856
|
+
} else return (0, $01f4cf98d50740c6$export$c348dfaf65040d9b)["single"] ? [
|
|
857
|
+
allCookies[0]
|
|
858
|
+
] : allCookies;
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
var $3a892f71b64103f5$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
865
|
+
function adopt(value) {
|
|
866
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
867
|
+
resolve(value);
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
871
|
+
function fulfilled(value) {
|
|
872
|
+
try {
|
|
873
|
+
step(generator.next(value));
|
|
874
|
+
} catch (e) {
|
|
875
|
+
reject(e);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
function rejected(value) {
|
|
879
|
+
try {
|
|
880
|
+
step(generator["throw"](value));
|
|
881
|
+
} catch (e) {
|
|
882
|
+
reject(e);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function step(result) {
|
|
886
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
887
|
+
}
|
|
888
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
889
|
+
});
|
|
890
|
+
};
|
|
891
|
+
function $3a892f71b64103f5$export$4be65e66cfa2648a(params) {
|
|
892
|
+
return $3a892f71b64103f5$var$__awaiter(this, void 0, void 0, function*() {
|
|
893
|
+
//
|
|
894
|
+
const cookies = yield (0, $f382029733f65752$export$e6d428437cf2cacb)(params, new (0, $49168e685ea38e19$export$2e2bcd8739ae039)());
|
|
895
|
+
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
896
|
+
else throw new Error("Cookie not found");
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
var $c23eafaef8340cc3$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
905
|
+
function adopt(value) {
|
|
906
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
907
|
+
resolve(value);
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
911
|
+
function fulfilled(value) {
|
|
912
|
+
try {
|
|
913
|
+
step(generator.next(value));
|
|
914
|
+
} catch (e) {
|
|
915
|
+
reject(e);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function rejected(value) {
|
|
919
|
+
try {
|
|
920
|
+
step(generator["throw"](value));
|
|
921
|
+
} catch (e) {
|
|
922
|
+
reject(e);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
function step(result) {
|
|
926
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
927
|
+
}
|
|
928
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
929
|
+
});
|
|
930
|
+
};
|
|
931
|
+
function $c23eafaef8340cc3$export$e5637297e9eb6f2e(params) {
|
|
932
|
+
return $c23eafaef8340cc3$var$__awaiter(this, void 0, void 0, function*() {
|
|
933
|
+
const cookies = yield (0, $f382029733f65752$export$e6d428437cf2cacb)(params, new (0, $a6f61760d01c3afd$export$2e2bcd8739ae039)());
|
|
934
|
+
if (cookies.length == 0) throw new Error("Cookie not found");
|
|
935
|
+
return cookies.find((0, $cf39947f238e32e1$export$963c8d651337e4a4));
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
var $bea34252b8e17f8d$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
943
|
+
function adopt(value) {
|
|
944
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
945
|
+
resolve(value);
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
949
|
+
function fulfilled(value) {
|
|
950
|
+
try {
|
|
951
|
+
step(generator.next(value));
|
|
952
|
+
} catch (e) {
|
|
953
|
+
reject(e);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
function rejected(value) {
|
|
957
|
+
try {
|
|
958
|
+
step(generator["throw"](value));
|
|
959
|
+
} catch (e) {
|
|
960
|
+
reject(e);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
function step(result) {
|
|
964
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
965
|
+
}
|
|
966
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
967
|
+
});
|
|
968
|
+
};
|
|
969
|
+
function $bea34252b8e17f8d$export$c44c5fdef43f0941(params) {
|
|
970
|
+
return $bea34252b8e17f8d$var$__awaiter(this, void 0, void 0, function*() {
|
|
971
|
+
const cookies = yield (0, $f382029733f65752$export$e6d428437cf2cacb)(params, new (0, $62dcb7ce199205be$export$2e2bcd8739ae039)());
|
|
972
|
+
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
973
|
+
else throw new Error("Cookie not found");
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
function $8227023f453bcf31$export$9abc0a414b0d8b8f(results) {
|
|
981
|
+
// sort by name and expiry descending
|
|
982
|
+
// takes the latest expiry for each name
|
|
983
|
+
const orderedResults = (0, $6B8p2$orderBy)(results, [
|
|
984
|
+
"name",
|
|
985
|
+
"expiry"
|
|
986
|
+
], [
|
|
987
|
+
"asc",
|
|
988
|
+
"desc"
|
|
989
|
+
]);
|
|
990
|
+
return (0, $6B8p2$uniqBy)(orderedResults, (r)=>r.name).map((r)=>r.name + "=" + r.value).join("; ");
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
var $0f113de605a2ef1d$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
997
|
+
function adopt(value) {
|
|
998
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
999
|
+
resolve(value);
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1003
|
+
function fulfilled(value) {
|
|
1004
|
+
try {
|
|
1005
|
+
step(generator.next(value));
|
|
1006
|
+
} catch (e) {
|
|
1007
|
+
reject(e);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
function rejected(value) {
|
|
1011
|
+
try {
|
|
1012
|
+
step(generator["throw"](value));
|
|
1013
|
+
} catch (e) {
|
|
1014
|
+
reject(e);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
function step(result) {
|
|
1018
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1019
|
+
}
|
|
1020
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1021
|
+
});
|
|
1022
|
+
};
|
|
1023
|
+
function $0f113de605a2ef1d$export$a65902517ae87ba8(cookieSpec) {
|
|
1024
|
+
return $0f113de605a2ef1d$var$__awaiter(this, void 0, void 0, function*() {
|
|
1025
|
+
const cookies = [];
|
|
1026
|
+
if (Array.isArray(cookieSpec)) {
|
|
1027
|
+
const results = yield Promise.all(cookieSpec.map((cs)=>{
|
|
1028
|
+
return (0, $f382029733f65752$export$e6d428437cf2cacb)(cs);
|
|
1029
|
+
}));
|
|
1030
|
+
for (const exportedCookie of results.flat())cookies.push(exportedCookie);
|
|
1031
|
+
} else {
|
|
1032
|
+
const singleQuery = yield (0, $f382029733f65752$export$e6d428437cf2cacb)(cookieSpec);
|
|
1033
|
+
cookies.push(...singleQuery);
|
|
1034
|
+
}
|
|
1035
|
+
return (0, $6B8p2$uniqBy)(cookies, JSON.stringify);
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
var $9bb85405e96c1fbc$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1041
|
+
function adopt(value) {
|
|
1042
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
1043
|
+
resolve(value);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1047
|
+
function fulfilled(value) {
|
|
1048
|
+
try {
|
|
1049
|
+
step(generator.next(value));
|
|
1050
|
+
} catch (e) {
|
|
1051
|
+
reject(e);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
function rejected(value) {
|
|
1055
|
+
try {
|
|
1056
|
+
step(generator["throw"](value));
|
|
1057
|
+
} catch (e) {
|
|
1058
|
+
reject(e);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
function step(result) {
|
|
1062
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1063
|
+
}
|
|
1064
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1065
|
+
});
|
|
1066
|
+
};
|
|
1067
|
+
function $9bb85405e96c1fbc$export$4d2e9997e2c23417(cookieSpec) {
|
|
1068
|
+
return $9bb85405e96c1fbc$var$__awaiter(this, void 0, void 0, function*() {
|
|
1069
|
+
const cookies = yield (0, $0f113de605a2ef1d$export$a65902517ae87ba8)(cookieSpec);
|
|
1070
|
+
if (cookies.length == 0) throw new Error("Cookie not found");
|
|
1071
|
+
const groupedByFile = (0, $6B8p2$groupBy)(cookies, (r)=>{
|
|
1072
|
+
var _a;
|
|
1073
|
+
return (_a = r.meta) === null || _a === void 0 ? void 0 : _a.file;
|
|
1074
|
+
});
|
|
1075
|
+
return Object.keys(groupedByFile).map((file)=>{
|
|
1076
|
+
const results = groupedByFile[file];
|
|
1077
|
+
return (0, $8227023f453bcf31$export$9abc0a414b0d8b8f)(results);
|
|
1078
|
+
});
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
var $0b27779070651c3e$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1086
|
+
function adopt(value) {
|
|
1087
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
1088
|
+
resolve(value);
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1092
|
+
function fulfilled(value) {
|
|
1093
|
+
try {
|
|
1094
|
+
step(generator.next(value));
|
|
1095
|
+
} catch (e) {
|
|
1096
|
+
reject(e);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function rejected(value) {
|
|
1100
|
+
try {
|
|
1101
|
+
step(generator["throw"](value));
|
|
1102
|
+
} catch (e) {
|
|
1103
|
+
reject(e);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function step(result) {
|
|
1107
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1108
|
+
}
|
|
1109
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1110
|
+
});
|
|
1111
|
+
};
|
|
1112
|
+
function $0b27779070651c3e$export$cfc0723de5712e57(cookieSpec) {
|
|
1113
|
+
return $0b27779070651c3e$var$__awaiter(this, void 0, void 0, function*() {
|
|
1114
|
+
const cookies = yield (0, $0f113de605a2ef1d$export$a65902517ae87ba8)(cookieSpec);
|
|
1115
|
+
return cookies.length > 0 ? (0, $8227023f453bcf31$export$9abc0a414b0d8b8f)(cookies) : "";
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
// noinspection JSUnusedGlobalSymbols,ExceptionCaughtLocallyJS
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
function $bd973abb63c1ed35$export$f266452a5050185d(url) {
|
|
1130
|
+
const url1 = typeof url == "string" ? new URL(url) : url;
|
|
1131
|
+
const cookieSpecs = [];
|
|
1132
|
+
const splits = url1.hostname.split(".");
|
|
1133
|
+
const tld = splits.slice(-2).join(".");
|
|
1134
|
+
const cookieSpec = {
|
|
1135
|
+
name: "%",
|
|
1136
|
+
domain: "%." + tld
|
|
1137
|
+
};
|
|
1138
|
+
cookieSpecs.push(cookieSpec);
|
|
1139
|
+
const cookieSpec1 = {
|
|
1140
|
+
name: "%",
|
|
1141
|
+
domain: url1.hostname
|
|
1142
|
+
};
|
|
1143
|
+
cookieSpecs.push(cookieSpec1);
|
|
1144
|
+
// const isWww = splits.slice(-3)[0] === "www";
|
|
1145
|
+
const cookieSpec2 = {
|
|
1146
|
+
name: "%",
|
|
1147
|
+
domain: tld
|
|
1148
|
+
};
|
|
1149
|
+
cookieSpecs.push(cookieSpec2);
|
|
1150
|
+
return (0, $6B8p2$uniqBy)(cookieSpecs, JSON.stringify);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
|
|
1155
|
+
var $7d6c43a28f2485bc$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1156
|
+
function adopt(value) {
|
|
1157
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
1158
|
+
resolve(value);
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1162
|
+
function fulfilled(value) {
|
|
1163
|
+
try {
|
|
1164
|
+
step(generator.next(value));
|
|
1165
|
+
} catch (e) {
|
|
1166
|
+
reject(e);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
function rejected(value) {
|
|
1170
|
+
try {
|
|
1171
|
+
step(generator["throw"](value));
|
|
1172
|
+
} catch (e) {
|
|
1173
|
+
reject(e);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
function step(result) {
|
|
1177
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1178
|
+
}
|
|
1179
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1180
|
+
});
|
|
1181
|
+
};
|
|
1182
|
+
if (typeof (0, $6B8p2$fetch) !== "function") {
|
|
1183
|
+
(0, $6B8p2$consola).error("fetch is not a function");
|
|
1184
|
+
throw new Error("fetch is not a function");
|
|
1185
|
+
}
|
|
1186
|
+
const $7d6c43a28f2485bc$var$userAgent = new (0, $6B8p2$useragents)().toString();
|
|
1187
|
+
function $7d6c43a28f2485bc$export$b24a545a0b39f491(url, options = {}, fetch = (0, $6B8p2$fetch), originalRequest) {
|
|
1188
|
+
var _a;
|
|
1189
|
+
return $7d6c43a28f2485bc$var$__awaiter(this, void 0, void 0, function*() {
|
|
1190
|
+
if (typeof fetch !== "function") {
|
|
1191
|
+
const message = "fetch is not a function";
|
|
1192
|
+
(0, $6B8p2$consola).error(message);
|
|
1193
|
+
throw new Error(message);
|
|
1194
|
+
}
|
|
1195
|
+
const originalRequest1 = originalRequest || {
|
|
1196
|
+
url: url,
|
|
1197
|
+
options: options
|
|
1198
|
+
};
|
|
1199
|
+
const headers = {
|
|
1200
|
+
"User-Agent": $7d6c43a28f2485bc$var$userAgent
|
|
1201
|
+
};
|
|
1202
|
+
const defaultOptions = {
|
|
1203
|
+
headers: headers,
|
|
1204
|
+
redirect: "manual"
|
|
1205
|
+
};
|
|
1206
|
+
const url2 = `${url}`;
|
|
1207
|
+
const url1 = new URL(url2);
|
|
1208
|
+
(0, $6B8p2$consola).start("fetchWithCookies", url2);
|
|
1209
|
+
const cookieSpecs = (0, $bd973abb63c1ed35$export$f266452a5050185d)(url1);
|
|
1210
|
+
headers["Cookie"] = yield (0, $0b27779070651c3e$export$cfc0723de5712e57)(cookieSpecs).catch((err)=>{
|
|
1211
|
+
(0, $6B8p2$consola).error(err);
|
|
1212
|
+
return "";
|
|
1213
|
+
});
|
|
1214
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b)["dump-request-headers"]) {
|
|
1215
|
+
(0, $6B8p2$consola).info((0, $6B8p2$redBright)("Request URL:"), url1.href);
|
|
1216
|
+
(0, $6B8p2$consola).info((0, $6B8p2$blue)("Request headers:"), headers);
|
|
1217
|
+
}
|
|
1218
|
+
const newOptions1 = (0, $6B8p2$merge)(defaultOptions, {
|
|
1219
|
+
headers: headers
|
|
1220
|
+
}, options);
|
|
1221
|
+
try {
|
|
1222
|
+
const res = yield fetch(url1, newOptions1);
|
|
1223
|
+
// noinspection JSMismatchedCollectionQueryUpdate
|
|
1224
|
+
const headers = [];
|
|
1225
|
+
res.headers.forEach((value, key)=>{
|
|
1226
|
+
headers.push([
|
|
1227
|
+
key,
|
|
1228
|
+
value
|
|
1229
|
+
]);
|
|
1230
|
+
});
|
|
1231
|
+
// for (const [key, value] of headers) {
|
|
1232
|
+
// if (key === "set-cookie") {
|
|
1233
|
+
// const cookieJar1 = await cookieJarPromise;
|
|
1234
|
+
// await cookieJar1.setCookie(value, url2);
|
|
1235
|
+
// if (parsedArgs.verbose) {
|
|
1236
|
+
// console.log(blue(`Set-Cookie:`), yellow(value), yellow(url2));
|
|
1237
|
+
// }
|
|
1238
|
+
// }
|
|
1239
|
+
// }
|
|
1240
|
+
const newUrl = (_a = res.headers.get("location")) !== null && _a !== void 0 ? _a : res.url;
|
|
1241
|
+
// const sameHost = new URL(newUrl).host === url1.host;
|
|
1242
|
+
if (res.status == 301 || res.status == 302) // follow the redirect
|
|
1243
|
+
{
|
|
1244
|
+
if (newUrl && newUrl !== url2) {
|
|
1245
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose || (0, $01f4cf98d50740c6$export$c348dfaf65040d9b)["dump-response-headers"]) console.log((0, $6B8p2$blue)(`Redirected to `), (0, $6B8p2$yellow)(newUrl));
|
|
1246
|
+
return $7d6c43a28f2485bc$export$b24a545a0b39f491(//
|
|
1247
|
+
newUrl, newOptions1, fetch, originalRequest1);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
if (res.status == 303 && newUrl && newUrl !== url2) {
|
|
1251
|
+
// follow the redirect with GET
|
|
1252
|
+
let newOptions2 = {};
|
|
1253
|
+
switch(newOptions1.method){
|
|
1254
|
+
case "POST":
|
|
1255
|
+
case "PUT":
|
|
1256
|
+
case "DELETE":
|
|
1257
|
+
(0, $6B8p2$merge)(newOptions2, newOptions1, {
|
|
1258
|
+
method: "GET"
|
|
1259
|
+
});
|
|
1260
|
+
newOptions2.body = undefined; // TODO: is this needed?
|
|
1261
|
+
break;
|
|
1262
|
+
case "HEAD":
|
|
1263
|
+
case "GET":
|
|
1264
|
+
(0, $6B8p2$merge)(newOptions2, newOptions1);
|
|
1265
|
+
newOptions2.body = undefined; // TODO: is this needed?
|
|
1266
|
+
break;
|
|
1267
|
+
default:
|
|
1268
|
+
(0, $6B8p2$merge)(newOptions2, newOptions1);
|
|
1269
|
+
break;
|
|
1270
|
+
}
|
|
1271
|
+
if ((0, $01f4cf98d50740c6$export$c348dfaf65040d9b).verbose) console.log((0, $6B8p2$blue)(`Redirected to `), (0, $6B8p2$yellow)(newUrl));
|
|
1272
|
+
return $7d6c43a28f2485bc$export$b24a545a0b39f491(//
|
|
1273
|
+
newUrl, newOptions2, fetch, originalRequest1);
|
|
1274
|
+
}
|
|
1275
|
+
const arrayBuffer1 = res.arrayBuffer();
|
|
1276
|
+
function arrayBuffer() {
|
|
1277
|
+
return $7d6c43a28f2485bc$var$__awaiter(this, void 0, void 0, function*() {
|
|
1278
|
+
return arrayBuffer1;
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
function buffer() {
|
|
1282
|
+
return $7d6c43a28f2485bc$var$__awaiter(this, void 0, void 0, function*() {
|
|
1283
|
+
return arrayBuffer().then(Buffer.from);
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
function text() {
|
|
1287
|
+
return $7d6c43a28f2485bc$var$__awaiter(this, void 0, void 0, function*() {
|
|
1288
|
+
return buffer().then((buffer)=>buffer.toString("utf8"));
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
function json() {
|
|
1292
|
+
return $7d6c43a28f2485bc$var$__awaiter(this, void 0, void 0, function*() {
|
|
1293
|
+
return text().then((text)=>(0, $6B8p2$destr)(text));
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
function formData() {
|
|
1297
|
+
return $7d6c43a28f2485bc$var$__awaiter(this, void 0, void 0, function*() {
|
|
1298
|
+
const urlSearchParams = yield text().then((text)=>new URLSearchParams(text));
|
|
1299
|
+
const formData = new FormData();
|
|
1300
|
+
for (const [key, value] of urlSearchParams.entries())formData.append(key, value);
|
|
1301
|
+
return formData;
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
const res1 = res;
|
|
1305
|
+
const source2 = {
|
|
1306
|
+
arrayBuffer: arrayBuffer,
|
|
1307
|
+
text: text,
|
|
1308
|
+
json: json,
|
|
1309
|
+
buffer: buffer,
|
|
1310
|
+
formData: formData
|
|
1311
|
+
};
|
|
1312
|
+
return (0, $6B8p2$merge)(res1, source2);
|
|
1313
|
+
} catch (e) {
|
|
1314
|
+
throw e;
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
export {$3a892f71b64103f5$export$4be65e66cfa2648a as getCookie, $c23eafaef8340cc3$export$e5637297e9eb6f2e as getChromeCookie, $bea34252b8e17f8d$export$c44c5fdef43f0941 as getFirefoxCookie, $0b27779070651c3e$export$cfc0723de5712e57 as getMergedRenderedCookies, $9bb85405e96c1fbc$export$4d2e9997e2c23417 as getGroupedRenderedCookies, $7d6c43a28f2485bc$export$b24a545a0b39f491 as fetchWithCookies};
|
|
1323
|
+
//# sourceMappingURL=module.js.map
|