@mherod/get-cookie 2.0.0-rc.2 → 2.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/runConfigurations/build.xml +12 -0
- package/.prettierignore +5 -0
- package/README.md +2 -2
- package/dist/cli.js +1110 -2
- package/dist/index.js +642 -231
- package/dist/index.js.map +1 -1
- package/dist/module.js +634 -224
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +246 -34
- package/dist/types.d.ts.map +1 -1
- package/package-lock.json +7539 -0
- package/package.json +24 -22
- package/src/CookieRow.ts +2 -1
- package/src/CookieSpec.ts +4 -2
- package/src/CookieStore.ts +27 -0
- package/src/ExportedCookie.ts +2 -1
- package/src/FetchResponse.ts +2 -0
- package/src/FileCookieStore.ts +170 -0
- package/src/IsCookieRow.ts +1 -1
- package/src/IsExportedCookie.ts +1 -1
- package/src/SpecialCases.ts +1 -1
- package/src/StringToRegex.ts +6 -0
- package/src/argv.ts +19 -0
- package/src/browsers/ChromeCookieQueryStrategy.ts +106 -24
- package/src/browsers/CompositeCookieQueryStrategy.ts +32 -8
- package/src/browsers/CookieQueryStrategy.ts +3 -1
- package/src/browsers/CookieStoreQueryStrategy.ts +99 -0
- package/src/browsers/FirefoxCookieQueryStrategy.ts +57 -9
- package/src/browsers/SafariCookieQueryStrategy.ts +4 -1
- package/src/cli.ts +101 -93
- package/src/comboQueryCookieSpec.ts +24 -0
- package/src/cookieSpecsFromUrl.ts +26 -0
- package/src/doSqliteQuery1Params.ts +8 -0
- package/src/fetchWithCookies.ts +131 -40
- package/src/findAllFiles.ts +5 -9
- package/src/getChromeCookie.ts +19 -0
- package/src/getCookie.ts +19 -0
- package/src/getFirefoxCookie.ts +19 -0
- package/src/getGroupedRenderedCookies.ts +12 -25
- package/src/getMergedRenderedCookies.ts +14 -0
- package/src/index.ts +13 -52
- package/src/isValidJwt.ts +2 -2
- package/src/queryCookies.ts +16 -12
- package/src/resultsRendered.ts +7 -4
- package/src/unpackHeaders.ts +7 -4
- package/src/utils.ts +0 -25
- package/tsconfig.json +11 -15
- package/.github/dependabot.yml +0 -6
- package/dist/cli.js.map +0 -1
- package/src/doSqliteQuery1.ts +0 -51
package/dist/module.js
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {uniqBy as $
|
|
3
|
-
import $
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import $
|
|
10
|
-
import {
|
|
11
|
-
import $
|
|
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, readdirSync as $6B8p2$readdirSync, statSync as $6B8p2$statSync, readFileSync as $6B8p2$readFileSync, writeFile as $6B8p2$writeFile} from "fs";
|
|
7
|
+
import {pbkdf2 as $6B8p2$pbkdf2, createDecipheriv as $6B8p2$createDecipheriv} from "crypto";
|
|
8
|
+
import {join as $6B8p2$join} from "path";
|
|
9
|
+
import {Database as $6B8p2$Database} from "sqlite3";
|
|
10
|
+
import {exec as $6B8p2$exec} from "child_process";
|
|
11
|
+
import {MemoryCookieStore as $6B8p2$MemoryCookieStore, CookieJar as $6B8p2$CookieJar, Cookie as $6B8p2$Cookie, Store as $6B8p2$Store} from "tough-cookie";
|
|
12
|
+
import $6B8p2$destr from "destr";
|
|
13
|
+
import $6B8p2$jsonwebtoken from "jsonwebtoken";
|
|
14
|
+
import {fetch as $6B8p2$fetch} from "cross-fetch";
|
|
15
|
+
import $6B8p2$useragents from "user-agents";
|
|
12
16
|
|
|
13
17
|
|
|
14
|
-
const $672ffeb43f5a0a33$export$a7b6bc01c63cdfc3 = {};
|
|
15
|
-
(0, $cE5Fr$merge)($672ffeb43f5a0a33$export$a7b6bc01c63cdfc3, process.env);
|
|
16
|
-
const $672ffeb43f5a0a33$export$a7c5707626fc90f = $672ffeb43f5a0a33$export$a7b6bc01c63cdfc3["HOME"];
|
|
17
|
-
if (!$672ffeb43f5a0a33$export$a7c5707626fc90f) throw new Error("HOME environment variable is not set");
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
const $105ddf345d82788c$export$6f4ae1207c703045 = process.argv ?? [];
|
|
21
|
+
const $105ddf345d82788c$var$minimistArgs = (0, $6B8p2$minimist)($105ddf345d82788c$export$6f4ae1207c703045.slice(2));
|
|
22
|
+
const $105ddf345d82788c$var$defaultOptions = {
|
|
23
|
+
verbose: false
|
|
24
|
+
};
|
|
25
|
+
const $105ddf345d82788c$export$c348dfaf65040d9b = (0, $6B8p2$merge)($105ddf345d82788c$var$defaultOptions, $105ddf345d82788c$var$minimistArgs);
|
|
20
26
|
|
|
21
27
|
|
|
22
|
-
|
|
28
|
+
|
|
29
|
+
async function $5487dc2a77024e5b$export$8d71c74f97c0202e(command) {
|
|
23
30
|
return new Promise((resolve, reject)=>{
|
|
24
|
-
(0, $
|
|
31
|
+
(0, $6B8p2$exec)(command, {
|
|
25
32
|
encoding: "binary",
|
|
26
33
|
maxBuffer: 5120
|
|
27
34
|
}, (error, stdout, stderr)=>{
|
|
@@ -37,60 +44,51 @@ async function $94d34fb9fc1942e3$export$8d71c74f97c0202e(command) {
|
|
|
37
44
|
});
|
|
38
45
|
});
|
|
39
46
|
}
|
|
40
|
-
function $94d34fb9fc1942e3$export$d53bf2de587a369(result) {
|
|
41
|
-
if (result == null) return null;
|
|
42
|
-
if (process.env.VERBOSE) console.log("result", result);
|
|
43
|
-
if (typeof result === "string" && result.length > 0) return result;
|
|
44
|
-
if (result.slice && result.toString) // noinspection JSCheckFunctionSignatures
|
|
45
|
-
return result.toString("utf8");
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
function $94d34fb9fc1942e3$export$99ce3e33a555daf1(input) {
|
|
49
|
-
return typeof input !== "string" || input.length === 0;
|
|
50
|
-
}
|
|
51
|
-
function $94d34fb9fc1942e3$export$5348b46700dd771c(input) {
|
|
52
|
-
return typeof input == "string" && input.length > 0;
|
|
53
|
-
}
|
|
54
47
|
|
|
55
48
|
|
|
56
49
|
|
|
50
|
+
const $27811734c054cd51$export$a7b6bc01c63cdfc3 = {};
|
|
51
|
+
(0, $6B8p2$merge)($27811734c054cd51$export$a7b6bc01c63cdfc3, process.env);
|
|
52
|
+
const $27811734c054cd51$export$a7c5707626fc90f = $27811734c054cd51$export$a7b6bc01c63cdfc3["HOME"];
|
|
53
|
+
if (!$27811734c054cd51$export$a7c5707626fc90f) throw new Error("HOME environment variable is not set");
|
|
54
|
+
|
|
57
55
|
|
|
58
56
|
|
|
59
57
|
|
|
60
|
-
|
|
58
|
+
|
|
59
|
+
async function $5ddc6ac5caa391cf$export$2c9faf86071156ae({ path: path , name: name , maxDepth: maxDepth = 2 }) {
|
|
61
60
|
const rootSegments = path.split("/").length;
|
|
62
|
-
if ((0, $672ffeb43f5a0a33$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Searching for ${name} in ${path}`);
|
|
63
61
|
const files = [];
|
|
64
62
|
let readdirSync;
|
|
65
63
|
try {
|
|
66
|
-
readdirSync = $
|
|
64
|
+
readdirSync = $6B8p2$readdirSync(path);
|
|
67
65
|
} catch (e) {
|
|
68
|
-
if ((0, $
|
|
66
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log(`Error reading ${path}`, e);
|
|
69
67
|
return [];
|
|
70
68
|
}
|
|
71
69
|
for (const file of readdirSync){
|
|
72
70
|
const filePath = path + "/" + file;
|
|
73
71
|
let stat;
|
|
74
72
|
try {
|
|
75
|
-
stat = $
|
|
73
|
+
stat = $6B8p2$statSync(filePath);
|
|
76
74
|
} catch (e1) {
|
|
77
|
-
if ((0, $
|
|
75
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.error(`Error getting stat for ${filePath}`, e1);
|
|
78
76
|
continue;
|
|
79
77
|
}
|
|
80
78
|
if (stat.isDirectory()) {
|
|
81
79
|
if (filePath.split("/").length < rootSegments + maxDepth) try {
|
|
82
|
-
const subFiles = await $
|
|
80
|
+
const subFiles = await $5ddc6ac5caa391cf$export$2c9faf86071156ae({
|
|
83
81
|
path: filePath,
|
|
84
82
|
name: name,
|
|
85
83
|
maxDepth: 2
|
|
86
84
|
});
|
|
87
85
|
files.push(...subFiles);
|
|
88
86
|
} catch (e2) {
|
|
89
|
-
if ((0, $
|
|
87
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.error(e2);
|
|
90
88
|
}
|
|
91
89
|
} else if (file === name) files.push(filePath);
|
|
92
90
|
}
|
|
93
|
-
if ((0, $
|
|
91
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) {
|
|
94
92
|
if (files.length > 0) {
|
|
95
93
|
console.log(`Found ${files.length} ${name} files`);
|
|
96
94
|
console.log(files);
|
|
@@ -103,158 +101,157 @@ async function $1ad80752da39350f$export$2c9faf86071156ae({ path: path , name: na
|
|
|
103
101
|
|
|
104
102
|
|
|
105
103
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
async function $9d2c7aa42fa2ecf2$export$f19f611d1fa7c6f3({ file: file , sql: sql , rowTransform: rowTransform }) {
|
|
109
|
-
if (!file || file && !$cE5Fr$existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
|
|
110
|
-
const db = new $cE5Fr$Database(file);
|
|
111
|
-
return new Promise((resolve, reject)=>{
|
|
112
|
-
db.all(sql, (err, rows)=>{
|
|
113
|
-
if (err) {
|
|
114
|
-
reject(err);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const rows1 = rows;
|
|
118
|
-
if (rows1 == null || rows1.length === 0) {
|
|
119
|
-
resolve([]);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (Array.isArray(rows1)) {
|
|
123
|
-
const cookieRows = rows1.map((row)=>{
|
|
124
|
-
const newVar = {
|
|
125
|
-
meta: {
|
|
126
|
-
file: file
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const cookieRow = rowTransform(row);
|
|
130
|
-
return (0, $cE5Fr$merge)(newVar, cookieRow);
|
|
131
|
-
});
|
|
132
|
-
resolve(cookieRows);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (process.env.VERBOSE) console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);
|
|
136
|
-
resolve([
|
|
137
|
-
rows1
|
|
138
|
-
]);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
104
|
+
function $0128ed33064d0b33$export$bc926c43858bd3cb(obj) {
|
|
105
|
+
return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
|
|
141
106
|
}
|
|
142
107
|
|
|
143
108
|
|
|
144
|
-
|
|
145
|
-
function $067a4422f38d620c$export$bc926c43858bd3cb(obj) {
|
|
109
|
+
function $954720edc83b2219$export$963c8d651337e4a4(obj) {
|
|
146
110
|
return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
|
|
147
111
|
}
|
|
148
112
|
|
|
149
113
|
|
|
150
|
-
function $
|
|
151
|
-
|
|
114
|
+
function $8a525b77a45adb9e$export$4eadcf0bf35a2ddb(s) {
|
|
115
|
+
const s1 = s.replaceAll(/\./gi, ".");
|
|
116
|
+
const s2 = s1.replace(/%/g, ".*");
|
|
117
|
+
const s3 = s2.replace(/\*/g, ".*");
|
|
118
|
+
return new RegExp(s3);
|
|
152
119
|
}
|
|
153
120
|
|
|
154
121
|
|
|
155
|
-
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class $245d30db16a07938$export$2e2bcd8739ae039 {
|
|
125
|
+
browserName = "Chrome";
|
|
156
126
|
async queryCookies(name, domain) {
|
|
157
127
|
if (process.platform !== "darwin") throw new Error("This only works on macOS");
|
|
158
|
-
if ((0, $
|
|
159
|
-
return $
|
|
128
|
+
if ((0, $27811734c054cd51$export$a7b6bc01c63cdfc3).FIREFOX_ONLY) return [];
|
|
129
|
+
return $245d30db16a07938$var$getChromeCookies({
|
|
160
130
|
requireJwt: false,
|
|
161
131
|
name: name,
|
|
162
132
|
domain: domain
|
|
163
133
|
});
|
|
164
134
|
}
|
|
165
135
|
}
|
|
166
|
-
async function $
|
|
136
|
+
async function $245d30db16a07938$var$getPromise1(name, domain, file) {
|
|
167
137
|
try {
|
|
168
|
-
return await $
|
|
138
|
+
return await $245d30db16a07938$var$getEncryptedChromeCookie({
|
|
169
139
|
name: name,
|
|
170
140
|
domain: domain,
|
|
171
141
|
file: file
|
|
172
142
|
});
|
|
173
143
|
} catch (e) {
|
|
174
|
-
if ((0, $
|
|
144
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("Error getting encrypted cookie", e);
|
|
175
145
|
return [];
|
|
176
146
|
}
|
|
177
147
|
}
|
|
178
|
-
async function $
|
|
148
|
+
async function $245d30db16a07938$var$getPromise(name, domain) {
|
|
179
149
|
try {
|
|
180
|
-
const files = await (0, $
|
|
181
|
-
path: $
|
|
150
|
+
const files = await (0, $5ddc6ac5caa391cf$export$2c9faf86071156ae)({
|
|
151
|
+
path: $245d30db16a07938$var$chromeLocal,
|
|
182
152
|
name: "Cookies"
|
|
183
153
|
});
|
|
184
|
-
const promises = files.map((file)=>$
|
|
154
|
+
const promises = files.map((file)=>$245d30db16a07938$var$getPromise1(name, domain, file));
|
|
185
155
|
const results1 = await Promise.all(promises);
|
|
186
|
-
return results1.flat().filter((0, $
|
|
156
|
+
return results1.flat().filter((0, $0128ed33064d0b33$export$bc926c43858bd3cb));
|
|
187
157
|
} catch (error) {
|
|
188
|
-
if ((0, $
|
|
158
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("error", error);
|
|
189
159
|
return [];
|
|
190
160
|
}
|
|
191
161
|
}
|
|
192
|
-
async function $
|
|
162
|
+
async function $245d30db16a07938$var$decryptValue(password, encryptedValue) {
|
|
193
163
|
let d;
|
|
194
164
|
try {
|
|
195
|
-
d = await $
|
|
165
|
+
d = await $245d30db16a07938$var$decrypt(password, encryptedValue);
|
|
196
166
|
} catch (e) {
|
|
197
|
-
if ((0, $
|
|
167
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("Error decrypting cookie", e);
|
|
198
168
|
d = null;
|
|
199
169
|
}
|
|
200
170
|
return d ?? encryptedValue.toString("utf-8");
|
|
201
171
|
}
|
|
202
|
-
async function $
|
|
203
|
-
const encryptedDataItems = await $
|
|
204
|
-
const password = await $
|
|
172
|
+
async function $245d30db16a07938$var$getChromeCookies({ name: name , domain: domain = "%" , requireJwt: requireJwt = false }) {
|
|
173
|
+
const encryptedDataItems = await $245d30db16a07938$var$getPromise(name, domain);
|
|
174
|
+
const password = await $245d30db16a07938$var$getChromePassword();
|
|
205
175
|
const decrypted = encryptedDataItems.filter(({ value: value })=>value != null && value.length > 0).map(async (cookieRow)=>{
|
|
206
176
|
const encryptedValue = cookieRow.value;
|
|
207
|
-
const decryptedValue = await $
|
|
177
|
+
const decryptedValue = await $245d30db16a07938$var$decryptValue(password, encryptedValue);
|
|
208
178
|
const meta = {};
|
|
209
|
-
(0, $
|
|
210
|
-
|
|
179
|
+
(0, $6B8p2$merge)(meta, cookieRow.meta ?? {});
|
|
180
|
+
const exportedCookie = {
|
|
211
181
|
domain: cookieRow.domain,
|
|
212
182
|
name: cookieRow.name,
|
|
213
183
|
value: decryptedValue,
|
|
214
184
|
meta: meta
|
|
215
185
|
};
|
|
186
|
+
const expiry = cookieRow.expiry;
|
|
187
|
+
const mergeExpiry = expiry != null && expiry > 0 ? {
|
|
188
|
+
expiry: new Date(expiry)
|
|
189
|
+
} : {
|
|
190
|
+
expiry: "Infinity"
|
|
191
|
+
};
|
|
192
|
+
(0, $6B8p2$merge)(exportedCookie, mergeExpiry);
|
|
193
|
+
return exportedCookie;
|
|
216
194
|
});
|
|
217
|
-
const results = (await Promise.all(decrypted)).filter((0, $
|
|
218
|
-
if ((0, $
|
|
195
|
+
const results = (await Promise.all(decrypted)).filter((0, $954720edc83b2219$export$963c8d651337e4a4));
|
|
196
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("results", results);
|
|
219
197
|
return results;
|
|
220
198
|
}
|
|
221
|
-
const $
|
|
222
|
-
async function $
|
|
223
|
-
if (!(0, $
|
|
224
|
-
if ((0, $
|
|
199
|
+
const $245d30db16a07938$var$chromeLocal = $6B8p2$join((0, $27811734c054cd51$export$a7c5707626fc90f), "Library", "Application Support", "Google", "Chrome");
|
|
200
|
+
async function $245d30db16a07938$var$getEncryptedChromeCookie({ name: name , domain: domain , file: file = $6B8p2$join($245d30db16a07938$var$chromeLocal, "Default", "Cookies") }) {
|
|
201
|
+
if (!(0, $6B8p2$existsSync)(file)) throw new Error(`File ${file} does not exist`);
|
|
202
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) {
|
|
225
203
|
const s = file.split("/").slice(-3).join("/");
|
|
226
204
|
console.log(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);
|
|
227
205
|
}
|
|
228
206
|
let sql;
|
|
229
207
|
//language=SQL
|
|
230
|
-
sql = "SELECT
|
|
208
|
+
sql = "SELECT * FROM cookies";
|
|
209
|
+
// sql = "SELECT encrypted_value, name, host_key FROM cookies";
|
|
231
210
|
const wildcardRegexp = /^([*%])$/i;
|
|
232
211
|
const specifiedName = name.match(wildcardRegexp) == null;
|
|
233
212
|
const specifiedDomain = domain.match(wildcardRegexp) == null;
|
|
234
|
-
|
|
213
|
+
const wildcardDomain = domain.match(/[%*]/) != null;
|
|
214
|
+
const queryDomain = specifiedDomain && !wildcardDomain;
|
|
215
|
+
// if we have a wildcard domain, we need to use a regexp
|
|
216
|
+
if (specifiedName || queryDomain) {
|
|
235
217
|
sql += ` WHERE `;
|
|
236
218
|
if (specifiedName) {
|
|
237
219
|
sql += `name = '${name}'`;
|
|
238
|
-
if (
|
|
220
|
+
if (queryDomain) sql += ` AND `;
|
|
221
|
+
}
|
|
222
|
+
if (queryDomain) {
|
|
223
|
+
// leading dot replaced with % to match subdomains
|
|
224
|
+
const sqlEmbedDomain = domain.replace(/^[.%]?/, "%");
|
|
225
|
+
sql += `host_key LIKE '${sqlEmbedDomain}';`;
|
|
239
226
|
}
|
|
240
|
-
if (specifiedDomain) sql += `host_key LIKE '${domain}';`;
|
|
241
227
|
}
|
|
242
|
-
|
|
228
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("sql", sql);
|
|
229
|
+
const domainRegexp = (0, $8a525b77a45adb9e$export$4eadcf0bf35a2ddb)(domain);
|
|
230
|
+
const sqliteQuery1 = await $245d30db16a07938$export$bd52b72df8d0d261({
|
|
243
231
|
file: file,
|
|
244
232
|
sql: sql,
|
|
233
|
+
rowFilter: (row)=>{
|
|
234
|
+
return row["host_key"].match(domainRegexp) != null;
|
|
235
|
+
},
|
|
245
236
|
rowTransform: (row)=>{
|
|
246
|
-
|
|
237
|
+
const cookieRow = {
|
|
238
|
+
expiry: (row["expires_utc"] / 1000000 - 11644473600) * 1000,
|
|
247
239
|
domain: row["host_key"],
|
|
248
240
|
name: row["name"],
|
|
249
241
|
value: row["encrypted_value"]
|
|
250
242
|
};
|
|
243
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("CookieRow", cookieRow);
|
|
244
|
+
return cookieRow;
|
|
251
245
|
}
|
|
252
246
|
});
|
|
247
|
+
return sqliteQuery1.filter((row)=>{
|
|
248
|
+
return row.domain.match(domainRegexp) != null;
|
|
249
|
+
});
|
|
253
250
|
}
|
|
254
|
-
async function $
|
|
255
|
-
return (0, $
|
|
251
|
+
async function $245d30db16a07938$var$getChromePassword() {
|
|
252
|
+
return (0, $5487dc2a77024e5b$export$8d71c74f97c0202e)('security find-generic-password -w -s "Chrome Safe Storage"');
|
|
256
253
|
}
|
|
257
|
-
async function $
|
|
254
|
+
async function $245d30db16a07938$var$decrypt(password, encryptedData) {
|
|
258
255
|
if (typeof password !== "string") throw new Error("password must be a string: " + password);
|
|
259
256
|
let encryptedData1;
|
|
260
257
|
encryptedData1 = encryptedData;
|
|
@@ -262,31 +259,31 @@ async function $179cc8ad79464497$var$decrypt(password, encryptedData) {
|
|
|
262
259
|
if (!(encryptedData1 instanceof Buffer)) {
|
|
263
260
|
if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {
|
|
264
261
|
[encryptedData1] = encryptedData1;
|
|
265
|
-
if ((0, $
|
|
262
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log(`encryptedData is an array of buffers, selected first: ${encryptedData1}`);
|
|
266
263
|
} else throw new Error("encryptedData must be a Buffer: " + encryptedData1);
|
|
267
264
|
encryptedData1 = Buffer.from(encryptedData1);
|
|
268
265
|
}
|
|
269
|
-
if ((0, $
|
|
266
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log(`Trying to decrypt with password ${password}`);
|
|
270
267
|
return new Promise((resolve, reject)=>{
|
|
271
|
-
$
|
|
268
|
+
$6B8p2$pbkdf2(password, "saltysalt", 1003, 16, "sha1", (error, buffer)=>{
|
|
272
269
|
try {
|
|
273
270
|
if (error) {
|
|
274
|
-
if ((0, $
|
|
271
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("Error doing pbkdf2", error);
|
|
275
272
|
reject(error);
|
|
276
273
|
return;
|
|
277
274
|
}
|
|
278
275
|
if (buffer.length !== 16) {
|
|
279
|
-
if ((0, $
|
|
276
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("Error doing pbkdf2, buffer length is not 16", buffer.length);
|
|
280
277
|
reject(new Error("Buffer length is not 16"));
|
|
281
278
|
return;
|
|
282
279
|
}
|
|
283
280
|
const str = new Array(17).join(" ");
|
|
284
281
|
const iv = Buffer.from(str, "binary");
|
|
285
|
-
const decipher = $
|
|
282
|
+
const decipher = $6B8p2$createDecipheriv("aes-128-cbc", buffer, iv);
|
|
286
283
|
decipher.setAutoPadding(false);
|
|
287
284
|
if (encryptedData1 && encryptedData1.slice) encryptedData1 = encryptedData1.slice(3);
|
|
288
285
|
if (encryptedData1.length % 16 !== 0) {
|
|
289
|
-
if ((0, $
|
|
286
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("Error doing pbkdf2, encryptedData length is not a multiple of 16", encryptedData1.length);
|
|
290
287
|
reject(new Error("encryptedData length is not a multiple of 16"));
|
|
291
288
|
return;
|
|
292
289
|
}
|
|
@@ -294,7 +291,7 @@ async function $179cc8ad79464497$var$decrypt(password, encryptedData) {
|
|
|
294
291
|
try {
|
|
295
292
|
decipher.final("utf-8");
|
|
296
293
|
} catch (e) {
|
|
297
|
-
if ((0, $
|
|
294
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("Error doing decipher.final()", e);
|
|
298
295
|
reject(e);
|
|
299
296
|
return;
|
|
300
297
|
}
|
|
@@ -309,14 +306,47 @@ async function $179cc8ad79464497$var$decrypt(password, encryptedData) {
|
|
|
309
306
|
});
|
|
310
307
|
});
|
|
311
308
|
}
|
|
309
|
+
async function $245d30db16a07938$export$bd52b72df8d0d261({ file: file , sql: sql , rowFilter: rowFilter = ()=>true , rowTransform: rowTransform }) {
|
|
310
|
+
if (!file || file && !(0, $6B8p2$fs).existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
|
|
311
|
+
const db = new $6B8p2$Database(file);
|
|
312
|
+
return new Promise((resolve, reject)=>{
|
|
313
|
+
db.all(sql, (err, rows)=>{
|
|
314
|
+
if (err) {
|
|
315
|
+
reject(err);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const rows1 = rows;
|
|
319
|
+
if (rows1 == null || rows1.length === 0) {
|
|
320
|
+
resolve([]);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (Array.isArray(rows1)) {
|
|
324
|
+
const cookieRows = rows1.filter(rowFilter).map((row)=>{
|
|
325
|
+
const newVar = {
|
|
326
|
+
meta: {
|
|
327
|
+
file: file
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const cookieRow = rowTransform(row);
|
|
331
|
+
return (0, $6B8p2$merge)(newVar, cookieRow);
|
|
332
|
+
});
|
|
333
|
+
resolve(cookieRows);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);
|
|
337
|
+
resolve([
|
|
338
|
+
rows1
|
|
339
|
+
]);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
}
|
|
312
343
|
|
|
313
344
|
|
|
314
345
|
|
|
315
346
|
|
|
316
347
|
|
|
317
348
|
|
|
318
|
-
|
|
319
|
-
function $17de5893b0e5738e$export$da22813e5a2ec500({ name: name , domain: domain }) {
|
|
349
|
+
function $043534331646fe99$export$da22813e5a2ec500({ name: name , domain: domain }) {
|
|
320
350
|
const wildcardRegexp = /^([*%])$/i;
|
|
321
351
|
return {
|
|
322
352
|
specifiedName: name.match(wildcardRegexp) == null,
|
|
@@ -325,10 +355,49 @@ function $17de5893b0e5738e$export$da22813e5a2ec500({ name: name , domain: domain
|
|
|
325
355
|
}
|
|
326
356
|
|
|
327
357
|
|
|
328
|
-
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
async function $ded29c0fa27637d3$export$f19f611d1fa7c6f3({ file: file , sql: sql , rowTransform: rowTransform }) {
|
|
362
|
+
if (!file || file && !(0, $6B8p2$fs).existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
|
|
363
|
+
const db = new $6B8p2$Database(file);
|
|
364
|
+
return new Promise((resolve, reject)=>{
|
|
365
|
+
db.all(sql, (err, rows)=>{
|
|
366
|
+
if (err) {
|
|
367
|
+
reject(err);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const rows1 = rows;
|
|
371
|
+
if (rows1 == null || rows1.length === 0) {
|
|
372
|
+
resolve([]);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (Array.isArray(rows1)) {
|
|
376
|
+
const cookieRows = rows1.map((row)=>{
|
|
377
|
+
const newVar = {
|
|
378
|
+
meta: {
|
|
379
|
+
file: file
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
const cookieRow = rowTransform(row);
|
|
383
|
+
return (0, $6B8p2$merge)(newVar, cookieRow);
|
|
384
|
+
});
|
|
385
|
+
resolve(cookieRows);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);
|
|
389
|
+
resolve([
|
|
390
|
+
rows1
|
|
391
|
+
]);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
class $ded29c0fa27637d3$export$2e2bcd8739ae039 {
|
|
396
|
+
browserName = "Firefox";
|
|
329
397
|
async queryCookies(name, domain) {
|
|
330
|
-
if (process.platform !== "darwin")
|
|
331
|
-
|
|
398
|
+
if (process.platform !== "darwin") // TODO: implement
|
|
399
|
+
return [];
|
|
400
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).browser !== "firefox") return [];
|
|
332
401
|
const cookies = await this.#getFirefoxCookie({
|
|
333
402
|
name: name,
|
|
334
403
|
domain: domain
|
|
@@ -344,22 +413,23 @@ class $e2bb11114a5548c6$export$2e2bcd8739ae039 {
|
|
|
344
413
|
}
|
|
345
414
|
async #getFirefoxCookie({ name: name , domain: domain } //
|
|
346
415
|
) {
|
|
347
|
-
const files = await (0, $
|
|
348
|
-
path: $
|
|
416
|
+
const files = await (0, $5ddc6ac5caa391cf$export$2c9faf86071156ae)({
|
|
417
|
+
path: $6B8p2$join((0, $27811734c054cd51$export$a7c5707626fc90f), "Library", "Application Support", "Firefox", "Profiles"),
|
|
349
418
|
name: "cookies.sqlite"
|
|
350
419
|
});
|
|
351
420
|
const fn = async (file)=>{
|
|
352
421
|
return await this.#queryCookiesDb(file, name, domain);
|
|
353
422
|
};
|
|
354
423
|
const all = await Promise.all(files.map(fn));
|
|
424
|
+
// flatten
|
|
355
425
|
return all.flat();
|
|
356
426
|
}
|
|
357
427
|
async #queryCookiesDb(file, name1, domain1) {
|
|
358
|
-
if (file && !(0, $
|
|
428
|
+
if (file && !(0, $6B8p2$existsSync)(file)) throw new Error(`File ${file} does not exist`);
|
|
359
429
|
let sql;
|
|
360
430
|
//language=SQL
|
|
361
431
|
sql = "SELECT value, name, host FROM moz_cookies";
|
|
362
|
-
const { specifiedName: specifiedName , specifiedDomain: specifiedDomain } = (0, $
|
|
432
|
+
const { specifiedName: specifiedName , specifiedDomain: specifiedDomain } = (0, $043534331646fe99$export$da22813e5a2ec500)({
|
|
363
433
|
name: name1,
|
|
364
434
|
domain: domain1
|
|
365
435
|
});
|
|
@@ -381,7 +451,7 @@ class $e2bb11114a5548c6$export$2e2bcd8739ae039 {
|
|
|
381
451
|
};
|
|
382
452
|
};
|
|
383
453
|
try {
|
|
384
|
-
return await
|
|
454
|
+
return await $ded29c0fa27637d3$export$f19f611d1fa7c6f3({
|
|
385
455
|
file: file,
|
|
386
456
|
sql: sql,
|
|
387
457
|
rowTransform: rowTransform
|
|
@@ -394,40 +464,256 @@ class $e2bb11114a5548c6$export$2e2bcd8739ae039 {
|
|
|
394
464
|
}
|
|
395
465
|
|
|
396
466
|
|
|
397
|
-
class $
|
|
467
|
+
class $68ef79184bd02203$export$2e2bcd8739ae039 {
|
|
468
|
+
browserName = "Safari";
|
|
398
469
|
async queryCookies(name, domain) {
|
|
470
|
+
// TODO: implement
|
|
399
471
|
return [];
|
|
400
472
|
}
|
|
401
473
|
}
|
|
402
474
|
|
|
403
475
|
|
|
404
476
|
|
|
405
|
-
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
class $703b18edcf62c952$export$55374e421ca433de extends (0, $6B8p2$Store) {
|
|
485
|
+
synchronous = false;
|
|
486
|
+
tasks = [];
|
|
487
|
+
constructor(filePath, internalStore = new (0, $6B8p2$MemoryCookieStore)()){
|
|
488
|
+
super();
|
|
489
|
+
this.filePath = filePath;
|
|
490
|
+
this.internalStore = internalStore ?? new (0, $6B8p2$MemoryCookieStore)();
|
|
491
|
+
console.log("Importing cookies from", filePath, internalStore);
|
|
492
|
+
this.tasks.push(this.importSaved(filePath, internalStore).then(console.log, console.error));
|
|
493
|
+
}
|
|
494
|
+
async importSaved(filePath, store) {
|
|
495
|
+
const cookies = [];
|
|
496
|
+
if ((0, $6B8p2$existsSync)(filePath)) {
|
|
497
|
+
const data = (0, $6B8p2$readFileSync)(filePath, "utf8");
|
|
498
|
+
const cookies1 = Object.values((0, $6B8p2$destr)(data)).flatMap((domainCookies)=>Object.values(domainCookies)).flatMap((domainCookies)=>Object.values(domainCookies));
|
|
499
|
+
console.log("Importing", cookies1.length, "cookies");
|
|
500
|
+
const array = Array.isArray(cookies1) ? cookies1 : Object.values(cookies1);
|
|
501
|
+
const put = await Promise.all(array.map((cookie)=>{
|
|
502
|
+
const fromJSON = (0, $6B8p2$Cookie).fromJSON(cookie);
|
|
503
|
+
if (fromJSON) return this.putCookieInternal(fromJSON, store);
|
|
504
|
+
}));
|
|
505
|
+
cookies1.push(...put);
|
|
506
|
+
}
|
|
507
|
+
return cookies;
|
|
508
|
+
}
|
|
509
|
+
findCookie(domain, path, key, cb) {
|
|
510
|
+
this.waitUntilIdle().finally(()=>{
|
|
511
|
+
this.internalStore.findCookie(domain, path, key, cb);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
findCookies(domain, path, allowSpecialUseDomain, cb) {
|
|
515
|
+
this.waitUntilIdle().finally(()=>{
|
|
516
|
+
this.internalStore.findCookies(domain, path, allowSpecialUseDomain, cb);
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
putCookie(cookie, cb) {
|
|
520
|
+
this.internalStore.putCookie(cookie, cb);
|
|
521
|
+
this.internalStore.getAllCookies((err, cookies)=>{
|
|
522
|
+
this.serializeCallback(err, cookies);
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
updateCookie(oldCookie, newCookie, cb) {
|
|
526
|
+
this.internalStore.updateCookie(oldCookie, newCookie, cb);
|
|
527
|
+
this.internalStore.getAllCookies((err, cookies)=>{
|
|
528
|
+
this.serializeCallback(err, cookies);
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
removeCookie(domain, path, key, cb) {
|
|
532
|
+
this.internalStore.removeCookie(domain, path, key, cb);
|
|
533
|
+
this.internalStore.getAllCookies((err, cookies)=>{
|
|
534
|
+
this.serializeCallback(err, cookies);
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
removeCookies(domain, path, cb) {
|
|
538
|
+
this.internalStore.removeCookies(domain, path, cb);
|
|
539
|
+
this.internalStore.getAllCookies((err, cookies)=>{
|
|
540
|
+
this.serializeCallback(err, cookies);
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
getAllCookies(cb) {
|
|
544
|
+
this.waitUntilIdle().finally(()=>{
|
|
545
|
+
this.internalStore.getAllCookies(cb);
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
waitUntilIdle() {
|
|
549
|
+
return Promise.allSettled(this.tasks).catch(console.error);
|
|
550
|
+
}
|
|
551
|
+
async putCookieInternal(cookie, store) {
|
|
552
|
+
await this.waitUntilIdle();
|
|
553
|
+
return await new Promise((resolve, reject)=>{
|
|
554
|
+
store.putCookie(cookie, (err)=>{
|
|
555
|
+
if (err) reject(err);
|
|
556
|
+
else resolve(cookie);
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
serializeCallback(err, cookies) {
|
|
561
|
+
if (err) {
|
|
562
|
+
console.error(err);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const cookieObjs = cookies.map((cookie)=>cookie);
|
|
566
|
+
const idx = {};
|
|
567
|
+
for (const cookie of cookieObjs){
|
|
568
|
+
const domain = cookie.domain;
|
|
569
|
+
if (typeof domain === "string") {
|
|
570
|
+
const path = cookie.path ?? "/";
|
|
571
|
+
const key = cookie.key;
|
|
572
|
+
(0, $6B8p2$merge)(idx, {
|
|
573
|
+
[domain]: {
|
|
574
|
+
[path]: {
|
|
575
|
+
[key]: cookie.toJSON()
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
const stringify = JSON.stringify(idx, null, 2);
|
|
582
|
+
(0, $6B8p2$writeFile)(this.filePath, stringify, (err)=>{
|
|
583
|
+
if (err) console.error(err);
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
const $7e7374355a590069$var$memoryCookieStore = new (0, $6B8p2$MemoryCookieStore)();
|
|
590
|
+
async function $7e7374355a590069$var$getCookieStore() {
|
|
591
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b)["cs"] == "memory") return $7e7374355a590069$var$memoryCookieStore;
|
|
592
|
+
const fileCookieStore = new (0, $703b18edcf62c952$export$55374e421ca433de)(`${(0, $27811734c054cd51$export$a7b6bc01c63cdfc3)["HOME"]}/cookie-star.json`, $7e7374355a590069$var$memoryCookieStore);
|
|
593
|
+
await fileCookieStore.waitUntilIdle();
|
|
594
|
+
return fileCookieStore;
|
|
595
|
+
}
|
|
596
|
+
const $7e7374355a590069$export$2c043f03eceff4e8 = new Promise((resolve)=>{
|
|
597
|
+
$7e7374355a590069$var$getCookieStore().then(resolve);
|
|
598
|
+
});
|
|
599
|
+
const $7e7374355a590069$export$eced8873dedbb4c0 = new Promise((resolve)=>{
|
|
600
|
+
$7e7374355a590069$export$2c043f03eceff4e8.then((store)=>new (0, $6B8p2$CookieJar)(store)).then(resolve);
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
class $6f21bbb0b106370d$export$2e2bcd8739ae039 {
|
|
606
|
+
browserName = "internal";
|
|
607
|
+
async queryCookies(name, domain) {
|
|
608
|
+
const exportedCookies = [];
|
|
609
|
+
// if (name.match(/[%*]/) || domain.match(/[%*]/)) {
|
|
610
|
+
const cookies = await this.#getAllCookies();
|
|
611
|
+
const allExportedCookies = cookies.map((cookie)=>{
|
|
612
|
+
return this.#extracted(cookie, {
|
|
613
|
+
name: name,
|
|
614
|
+
domain: domain
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
exportedCookies.push(...allExportedCookies);
|
|
618
|
+
// }
|
|
619
|
+
const wildcardRegexp = /^([*%])$/i;
|
|
620
|
+
if (name.match(wildcardRegexp) && domain.match(wildcardRegexp)) return exportedCookies;
|
|
621
|
+
const path = "/";
|
|
622
|
+
if (domain != "%") {
|
|
623
|
+
const domain1 = domain.match(/(\w+.+\w+)/gi)?.pop() ?? domain;
|
|
624
|
+
const url = new URL("https://" + domain1);
|
|
625
|
+
url.pathname = path;
|
|
626
|
+
const cookies1 = await this.#getCookies(url.href);
|
|
627
|
+
const domainCookies = cookies1.map((cookie)=>{
|
|
628
|
+
return this.#extracted(cookie, {
|
|
629
|
+
domain: domain,
|
|
630
|
+
name: name
|
|
631
|
+
});
|
|
632
|
+
});
|
|
633
|
+
exportedCookies.push(...domainCookies);
|
|
634
|
+
}
|
|
635
|
+
if (name == "%") return exportedCookies.filter((cookie)=>{
|
|
636
|
+
return cookie.domain.match((0, $8a525b77a45adb9e$export$4eadcf0bf35a2ddb)(domain));
|
|
637
|
+
});
|
|
638
|
+
return exportedCookies.filter((cookie)=>{
|
|
639
|
+
return cookie.name.match((0, $8a525b77a45adb9e$export$4eadcf0bf35a2ddb)(name)) && cookie.domain.match((0, $8a525b77a45adb9e$export$4eadcf0bf35a2ddb)(domain));
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
#extracted(cookie, cookieSpec) {
|
|
643
|
+
return {
|
|
644
|
+
domain: cookie.domain ?? cookieSpec.domain,
|
|
645
|
+
name: cookie.key ?? cookieSpec.name,
|
|
646
|
+
value: cookie.value,
|
|
647
|
+
expiry: cookie.expires ?? "Infinity",
|
|
648
|
+
meta: {
|
|
649
|
+
file: "tough-cookie"
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
async #getCookies(url) {
|
|
654
|
+
const cookieJar = await (0, $7e7374355a590069$export$eced8873dedbb4c0);
|
|
655
|
+
return new Promise((resolve, reject)=>{
|
|
656
|
+
return cookieJar.getCookies(url, (err, cookies)=>{
|
|
657
|
+
if (err) reject(err);
|
|
658
|
+
else resolve(cookies ?? []);
|
|
659
|
+
});
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
async #getAllCookies() {
|
|
663
|
+
const cookieStore = await (0, $7e7374355a590069$export$2c043f03eceff4e8);
|
|
664
|
+
return new Promise((resolve, reject)=>{
|
|
665
|
+
return cookieStore.getAllCookies((err, cookies)=>{
|
|
666
|
+
if (err) reject(err);
|
|
667
|
+
else resolve(cookies ?? []);
|
|
668
|
+
});
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
const $4ad2c96545f22a92$var$cache = new (0, $6B8p2$lrucache)({
|
|
406
678
|
ttl: 2000,
|
|
407
679
|
max: 10
|
|
408
680
|
});
|
|
409
|
-
class $
|
|
681
|
+
class $4ad2c96545f22a92$export$2e2bcd8739ae039 {
|
|
682
|
+
browserName = "all";
|
|
410
683
|
#strategies;
|
|
411
684
|
constructor(){
|
|
412
685
|
this.#strategies = [
|
|
413
|
-
(0, $
|
|
414
|
-
(0, $
|
|
415
|
-
(0, $
|
|
686
|
+
(0, $6f21bbb0b106370d$export$2e2bcd8739ae039),
|
|
687
|
+
(0, $245d30db16a07938$export$2e2bcd8739ae039),
|
|
688
|
+
(0, $ded29c0fa27637d3$export$2e2bcd8739ae039),
|
|
689
|
+
(0, $68ef79184bd02203$export$2e2bcd8739ae039),
|
|
416
690
|
].map((strategy)=>{
|
|
417
691
|
return new strategy();
|
|
418
692
|
});
|
|
419
693
|
}
|
|
420
694
|
async queryCookies(name, domain) {
|
|
695
|
+
// domain = domain.match(/(\w+.+\w+)/gi)?.pop() ?? domain;
|
|
421
696
|
const key = `${name}:${domain}`;
|
|
422
|
-
const cached = $
|
|
697
|
+
const cached = $4ad2c96545f22a92$var$cache.get(key);
|
|
423
698
|
if (cached) return cached;
|
|
699
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log("Querying cookies:", name, domain);
|
|
424
700
|
const results = await Promise.all(this.#strategies.map(async (strategy)=>{
|
|
425
701
|
// @ts-ignore
|
|
426
|
-
|
|
427
|
-
|
|
702
|
+
return strategy.queryCookies(name, domain).then((cookies)=>{
|
|
703
|
+
return cookies.map((cookie)=>{
|
|
704
|
+
return (0, $6B8p2$merge)(cookie, {
|
|
705
|
+
meta: {
|
|
706
|
+
browser: strategy.browserName
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
});
|
|
710
|
+
}).catch((e)=>{
|
|
711
|
+
console.log((0, $6B8p2$red)(`Error querying ${strategy.browserName} cookies`), e);
|
|
712
|
+
return [];
|
|
713
|
+
});
|
|
428
714
|
}));
|
|
429
715
|
const flat = results.flat();
|
|
430
|
-
$
|
|
716
|
+
$4ad2c96545f22a92$var$cache.set(`${name}:${domain}`, flat);
|
|
431
717
|
return flat;
|
|
432
718
|
}
|
|
433
719
|
}
|
|
@@ -435,12 +721,12 @@ class $e4dc93e15167afaf$export$2e2bcd8739ae039 {
|
|
|
435
721
|
|
|
436
722
|
|
|
437
723
|
|
|
438
|
-
function $
|
|
724
|
+
function $382bb98116581c98$export$2e2bcd8739ae039(token) {
|
|
439
725
|
try {
|
|
440
|
-
const result = (0, $
|
|
726
|
+
const result = (0, $6B8p2$jsonwebtoken).decode(token, {
|
|
441
727
|
complete: true
|
|
442
728
|
});
|
|
443
|
-
if ((0, $
|
|
729
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose && result) console.log(result);
|
|
444
730
|
const payload = result?.payload;
|
|
445
731
|
if (payload) {
|
|
446
732
|
const exp = payload.exp;
|
|
@@ -456,131 +742,255 @@ function $c0e0097c98ba1117$export$2e2bcd8739ae039(token) {
|
|
|
456
742
|
}
|
|
457
743
|
|
|
458
744
|
|
|
459
|
-
async function $
|
|
745
|
+
async function $894f0031f9c297b7$export$e6d428437cf2cacb({ name: name , domain: domain }, strategy = new (0, $4ad2c96545f22a92$export$2e2bcd8739ae039)()) {
|
|
460
746
|
const results = await strategy.queryCookies(name, domain);
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
747
|
+
const allCookies = (0, $6B8p2$uniqBy)(results, JSON.stringify);
|
|
748
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b)["require-jwt"]) {
|
|
749
|
+
const jwtCookies = [];
|
|
750
|
+
for (const result of allCookies){
|
|
751
|
+
const value = result.value;
|
|
752
|
+
if ((0, $382bb98116581c98$export$2e2bcd8739ae039)(value)) jwtCookies.push(result);
|
|
753
|
+
}
|
|
754
|
+
return (0, $105ddf345d82788c$export$c348dfaf65040d9b)["single"] ? [
|
|
755
|
+
jwtCookies[0]
|
|
756
|
+
] : jwtCookies;
|
|
757
|
+
} else return (0, $105ddf345d82788c$export$c348dfaf65040d9b)["single"] ? [
|
|
758
|
+
allCookies[0]
|
|
759
|
+
] : allCookies;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
async function $ee90d6e46afee441$export$4be65e66cfa2648a(params) {
|
|
765
|
+
const cookies = await (0, $894f0031f9c297b7$export$e6d428437cf2cacb)(params, new (0, $4ad2c96545f22a92$export$2e2bcd8739ae039)());
|
|
766
|
+
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
767
|
+
else throw new Error("Cookie not found");
|
|
471
768
|
}
|
|
472
769
|
|
|
473
770
|
|
|
474
771
|
|
|
475
772
|
|
|
476
773
|
|
|
774
|
+
async function $acf32070bfa1e556$export$e5637297e9eb6f2e(params) {
|
|
775
|
+
const cookies = await (0, $894f0031f9c297b7$export$e6d428437cf2cacb)(params, new (0, $245d30db16a07938$export$2e2bcd8739ae039)());
|
|
776
|
+
if (cookies.length == 0) throw new Error("Cookie not found");
|
|
777
|
+
return cookies.find((0, $954720edc83b2219$export$963c8d651337e4a4));
|
|
778
|
+
}
|
|
477
779
|
|
|
478
780
|
|
|
479
781
|
|
|
480
782
|
|
|
481
|
-
function $
|
|
482
|
-
|
|
783
|
+
async function $d3544dba87d45eaf$export$c44c5fdef43f0941(params) {
|
|
784
|
+
const cookies = await (0, $894f0031f9c297b7$export$e6d428437cf2cacb)(params, new (0, $ded29c0fa27637d3$export$2e2bcd8739ae039)());
|
|
785
|
+
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
786
|
+
else throw new Error("Cookie not found");
|
|
483
787
|
}
|
|
484
788
|
|
|
485
789
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
const results = groupedByFile[file];
|
|
500
|
-
return (0, $1b5a89e5cded5e9b$export$9abc0a414b0d8b8f)(results);
|
|
501
|
-
});
|
|
502
|
-
} else throw new Error("Cookie not found");
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
function $c874cfe31b9a966d$export$9abc0a414b0d8b8f(results) {
|
|
793
|
+
// sort by name and expiry descending
|
|
794
|
+
// takes the latest expiry for each name
|
|
795
|
+
const orderedResults = (0, $6B8p2$orderBy)(results, [
|
|
796
|
+
"name",
|
|
797
|
+
"expiry"
|
|
798
|
+
], [
|
|
799
|
+
"asc",
|
|
800
|
+
"desc"
|
|
801
|
+
]);
|
|
802
|
+
return (0, $6B8p2$uniqBy)(orderedResults, (r)=>r.name).map((r)=>r.name + "=" + r.value).join("; ");
|
|
503
803
|
}
|
|
504
804
|
|
|
505
805
|
|
|
506
806
|
|
|
507
807
|
|
|
808
|
+
async function $0452c1feb4ebc7da$export$a65902517ae87ba8(cookieSpec) {
|
|
809
|
+
const cookies = [];
|
|
810
|
+
if (Array.isArray(cookieSpec)) {
|
|
811
|
+
const results = await Promise.all(cookieSpec.map((cs)=>{
|
|
812
|
+
return (0, $894f0031f9c297b7$export$e6d428437cf2cacb)(cs);
|
|
813
|
+
}));
|
|
814
|
+
for (const exportedCookie of results.flat())cookies.push(exportedCookie);
|
|
815
|
+
} else {
|
|
816
|
+
const singleQuery = await (0, $894f0031f9c297b7$export$e6d428437cf2cacb)(cookieSpec);
|
|
817
|
+
cookies.push(...singleQuery);
|
|
818
|
+
}
|
|
819
|
+
return (0, $6B8p2$uniqBy)(cookies, JSON.stringify);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
async function $4f706a2b35459230$export$4d2e9997e2c23417(cookieSpec) {
|
|
824
|
+
const cookies = await (0, $0452c1feb4ebc7da$export$a65902517ae87ba8)(cookieSpec);
|
|
825
|
+
if (cookies.length == 0) throw new Error("Cookie not found");
|
|
826
|
+
const groupedByFile = (0, $6B8p2$groupBy)(cookies, (r)=>r.meta?.file);
|
|
827
|
+
return Object.keys(groupedByFile).map((file)=>{
|
|
828
|
+
const results = groupedByFile[file];
|
|
829
|
+
return (0, $c874cfe31b9a966d$export$9abc0a414b0d8b8f)(results);
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
async function $dc47e52699aadc0c$export$cfc0723de5712e57(cookieSpec) {
|
|
837
|
+
const cookies = await (0, $0452c1feb4ebc7da$export$a65902517ae87ba8)(cookieSpec);
|
|
838
|
+
if (cookies.length > 0) return (0, $c874cfe31b9a966d$export$9abc0a414b0d8b8f)(cookies);
|
|
839
|
+
return "";
|
|
840
|
+
}
|
|
841
|
+
|
|
508
842
|
|
|
509
843
|
|
|
510
|
-
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
function $2fa260a31891b0ed$export$f266452a5050185d(url) {
|
|
853
|
+
const url1 = typeof url == "string" ? new URL(url) : url;
|
|
854
|
+
const cookieSpecs = [];
|
|
855
|
+
const splits = url1.hostname.split(".");
|
|
856
|
+
const tld = splits.slice(-2).join(".");
|
|
857
|
+
const cookieSpec = {
|
|
858
|
+
name: "%",
|
|
859
|
+
domain: "%." + tld
|
|
860
|
+
};
|
|
861
|
+
cookieSpecs.push(cookieSpec);
|
|
862
|
+
const cookieSpec1 = {
|
|
863
|
+
name: "%",
|
|
864
|
+
domain: url1.hostname
|
|
865
|
+
};
|
|
866
|
+
cookieSpecs.push(cookieSpec1);
|
|
867
|
+
// const isWww = splits.slice(-3)[0] === "www";
|
|
868
|
+
const cookieSpec2 = {
|
|
869
|
+
name: "%",
|
|
870
|
+
domain: tld
|
|
871
|
+
};
|
|
872
|
+
cookieSpecs.push(cookieSpec2);
|
|
873
|
+
return (0, $6B8p2$uniqBy)(cookieSpecs, JSON.stringify);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
const $a1c21070f1cf1867$var$userAgent = new (0, $6B8p2$useragents)().toString();
|
|
878
|
+
async function $a1c21070f1cf1867$export$b24a545a0b39f491(url, options = {}, fetch = (0, $6B8p2$fetch), originalRequest) {
|
|
879
|
+
const originalRequest1 = originalRequest || {
|
|
880
|
+
url: url,
|
|
881
|
+
options: options
|
|
882
|
+
};
|
|
883
|
+
const headers = {
|
|
884
|
+
"User-Agent": $a1c21070f1cf1867$var$userAgent
|
|
885
|
+
};
|
|
511
886
|
const defaultOptions = {
|
|
512
|
-
headers:
|
|
513
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
|
|
514
|
-
},
|
|
887
|
+
headers: headers,
|
|
515
888
|
redirect: "manual"
|
|
516
889
|
};
|
|
517
890
|
const url2 = `${url}`;
|
|
518
891
|
const url1 = new URL(url2);
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
headers: {
|
|
529
|
-
Cookie: cookie
|
|
530
|
-
}
|
|
531
|
-
});
|
|
892
|
+
const cookieSpecs = (0, $2fa260a31891b0ed$export$f266452a5050185d)(url1);
|
|
893
|
+
headers["Cookie"] = await (0, $dc47e52699aadc0c$export$cfc0723de5712e57)(cookieSpecs).catch(()=>"");
|
|
894
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b)["dump-request-headers"]) {
|
|
895
|
+
console.log((0, $6B8p2$redBright)("Request URL:"), url1.href);
|
|
896
|
+
console.log((0, $6B8p2$blue)("Request headers:"), headers);
|
|
897
|
+
}
|
|
898
|
+
const newOptions1 = (0, $6B8p2$merge)(defaultOptions, {
|
|
899
|
+
headers: headers
|
|
900
|
+
}, options);
|
|
532
901
|
try {
|
|
533
|
-
const res = await
|
|
534
|
-
const
|
|
535
|
-
|
|
902
|
+
const res = await fetch(url1, newOptions1);
|
|
903
|
+
const headers1 = [];
|
|
904
|
+
res.headers.forEach((value, key)=>{
|
|
905
|
+
headers1.push([
|
|
906
|
+
key,
|
|
907
|
+
value
|
|
908
|
+
]);
|
|
909
|
+
});
|
|
910
|
+
for (const [key, value] of headers1)if (key === "set-cookie") {
|
|
911
|
+
const cookieJar1 = await (0, $7e7374355a590069$export$eced8873dedbb4c0);
|
|
912
|
+
await cookieJar1.setCookie(value, url2);
|
|
913
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log((0, $6B8p2$blue)(`Set-Cookie:`), (0, $6B8p2$yellow)(value), (0, $6B8p2$yellow)(url2));
|
|
914
|
+
}
|
|
915
|
+
const newUrl = res.headers.get("location") ?? res.url;
|
|
916
|
+
// const sameHost = new URL(newUrl).host === url1.host;
|
|
917
|
+
if (res.status == 301 || res.status == 302) // follow the redirect
|
|
918
|
+
{
|
|
919
|
+
if (newUrl && newUrl !== url2) {
|
|
920
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose || (0, $105ddf345d82788c$export$c348dfaf65040d9b)["dump-response-headers"]) console.log((0, $6B8p2$blue)(`Redirected to `), (0, $6B8p2$yellow)(newUrl));
|
|
921
|
+
return $a1c21070f1cf1867$export$b24a545a0b39f491(//
|
|
922
|
+
newUrl, newOptions1, fetch, originalRequest1);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
if (res.status == 303 && newUrl && newUrl !== url2) {
|
|
926
|
+
// follow the redirect with GET
|
|
927
|
+
let newOptions2 = {};
|
|
928
|
+
switch(newOptions1.method){
|
|
929
|
+
case "POST":
|
|
930
|
+
case "PUT":
|
|
931
|
+
case "DELETE":
|
|
932
|
+
(0, $6B8p2$merge)(newOptions2, newOptions1, {
|
|
933
|
+
method: "GET"
|
|
934
|
+
});
|
|
935
|
+
newOptions2.body = undefined; // TODO: is this needed?
|
|
936
|
+
break;
|
|
937
|
+
case "HEAD":
|
|
938
|
+
case "GET":
|
|
939
|
+
(0, $6B8p2$merge)(newOptions2, newOptions1);
|
|
940
|
+
newOptions2.body = undefined; // TODO: is this needed?
|
|
941
|
+
break;
|
|
942
|
+
default:
|
|
943
|
+
(0, $6B8p2$merge)(newOptions2, newOptions1);
|
|
944
|
+
break;
|
|
945
|
+
}
|
|
946
|
+
if ((0, $105ddf345d82788c$export$c348dfaf65040d9b).verbose) console.log((0, $6B8p2$blue)(`Redirected to `), (0, $6B8p2$yellow)(newUrl));
|
|
947
|
+
return $a1c21070f1cf1867$export$b24a545a0b39f491(//
|
|
948
|
+
newUrl, newOptions2, fetch, originalRequest1);
|
|
949
|
+
}
|
|
536
950
|
const arrayBuffer1 = res.arrayBuffer();
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
951
|
+
async function arrayBuffer() {
|
|
952
|
+
return arrayBuffer1;
|
|
953
|
+
}
|
|
954
|
+
async function buffer() {
|
|
955
|
+
return arrayBuffer().then(Buffer.from);
|
|
956
|
+
}
|
|
957
|
+
async function text() {
|
|
958
|
+
return buffer().then((buffer)=>buffer.toString("utf8"));
|
|
959
|
+
}
|
|
960
|
+
async function json() {
|
|
961
|
+
return text().then((text)=>(0, $6B8p2$destr)(text));
|
|
962
|
+
}
|
|
963
|
+
async function formData() {
|
|
964
|
+
const urlSearchParams = await text().then((text)=>new URLSearchParams(text));
|
|
965
|
+
const formData = new FormData();
|
|
966
|
+
for (const [key, value] of urlSearchParams.entries())formData.append(key, value);
|
|
967
|
+
return formData;
|
|
968
|
+
}
|
|
969
|
+
const res1 = res;
|
|
542
970
|
const source2 = {
|
|
543
|
-
status: res.status,
|
|
544
|
-
statusText: res.statusText,
|
|
545
|
-
headers: res.headers,
|
|
546
971
|
arrayBuffer: arrayBuffer,
|
|
547
|
-
buffer: buffer,
|
|
548
972
|
text: text,
|
|
549
973
|
json: json,
|
|
974
|
+
buffer: buffer,
|
|
550
975
|
formData: formData
|
|
551
976
|
};
|
|
552
|
-
return (0, $
|
|
977
|
+
return (0, $6B8p2$merge)(res1, source2);
|
|
553
978
|
} catch (e) {
|
|
554
979
|
throw e;
|
|
555
980
|
}
|
|
556
981
|
}
|
|
557
982
|
|
|
558
983
|
|
|
559
|
-
var $
|
|
984
|
+
var $a37c3808491b8fab$exports = {};
|
|
560
985
|
|
|
561
986
|
|
|
562
|
-
var $
|
|
987
|
+
var $801bca016ea3ef3e$exports = {};
|
|
563
988
|
|
|
564
989
|
|
|
565
|
-
var $
|
|
990
|
+
var $e3cac67a6cf22070$exports = {};
|
|
566
991
|
|
|
567
992
|
|
|
568
|
-
async function $32bf08fc0ad0b0fe$export$4be65e66cfa2648a(params) {
|
|
569
|
-
const cookies = await (0, $bea00efd5f6bccda$export$e6d428437cf2cacb)(params, new (0, $e4dc93e15167afaf$export$2e2bcd8739ae039)());
|
|
570
|
-
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
571
|
-
else throw new Error("Cookie not found");
|
|
572
|
-
}
|
|
573
|
-
async function $32bf08fc0ad0b0fe$export$c44c5fdef43f0941(params) {
|
|
574
|
-
const cookies = await (0, $bea00efd5f6bccda$export$e6d428437cf2cacb)(params, new (0, $e2bb11114a5548c6$export$2e2bcd8739ae039)());
|
|
575
|
-
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
576
|
-
else throw new Error("Cookie not found");
|
|
577
|
-
}
|
|
578
|
-
async function $32bf08fc0ad0b0fe$export$e5637297e9eb6f2e(params) {
|
|
579
|
-
const cookies = await (0, $bea00efd5f6bccda$export$e6d428437cf2cacb)(params, new (0, $179cc8ad79464497$export$2e2bcd8739ae039)());
|
|
580
|
-
if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
|
|
581
|
-
else throw new Error("Cookie not found");
|
|
582
|
-
}
|
|
583
993
|
|
|
584
994
|
|
|
585
|
-
export {$
|
|
995
|
+
export {$ee90d6e46afee441$export$4be65e66cfa2648a as getCookie, $acf32070bfa1e556$export$e5637297e9eb6f2e as getChromeCookie, $d3544dba87d45eaf$export$c44c5fdef43f0941 as getFirefoxCookie, $dc47e52699aadc0c$export$cfc0723de5712e57 as getMergedRenderedCookies, $4f706a2b35459230$export$4d2e9997e2c23417 as getGroupedRenderedCookies, $a1c21070f1cf1867$export$b24a545a0b39f491 as fetchWithCookies};
|
|
586
996
|
//# sourceMappingURL=module.js.map
|