@mherod/get-cookie 2.0.0-beta.1 → 2.0.0-beta.4

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.
Files changed (35) hide show
  1. package/.idea/codeStyles/Project.xml +59 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/get-cookie.iml +1 -0
  4. package/.prettierrc.json +1 -0
  5. package/dist/cli.js +1 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/index.js +3 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/main.js +196 -220
  10. package/dist/main.js.map +1 -1
  11. package/dist/module.js +466 -0
  12. package/dist/module.js.map +1 -0
  13. package/dist/types.d.ts +25 -0
  14. package/dist/types.d.ts.map +1 -0
  15. package/package.json +27 -12
  16. package/src/CookieRow.ts +21 -0
  17. package/src/argv.ts +1 -0
  18. package/src/browsers/{AbstractCookieQueryStrategy.js → AbstractCookieQueryStrategy.ts} +3 -1
  19. package/src/browsers/ChromeCookieQueryStrategy.ts +256 -0
  20. package/src/browsers/{CompositeCookieQueryStrategy.js → CompositeCookieQueryStrategy.ts} +5 -2
  21. package/src/browsers/{FirefoxCookieQueryStrategy.js → FirefoxCookieQueryStrategy.ts} +28 -13
  22. package/src/browsers/{SafariCookieQueryStrategy.js → SafariCookieQueryStrategy.ts} +0 -0
  23. package/src/cli.ts +85 -0
  24. package/src/doSqliteQuery1.ts +47 -0
  25. package/src/{findAllFiles.js → findAllFiles.ts} +15 -20
  26. package/src/{global.js → global.ts} +2 -2
  27. package/src/{index.js → index.ts} +3 -8
  28. package/src/{isValidJwt.js → isValidJwt.ts} +1 -4
  29. package/src/queryCookies.ts +29 -0
  30. package/src/utils.ts +118 -0
  31. package/tsconfig.json +23 -0
  32. package/src/browsers/ChromeCookieQueryStrategy.js +0 -263
  33. package/src/cli.js +0 -70
  34. package/src/queryCookies.js +0 -28
  35. package/src/utils.js +0 -181
package/dist/main.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- var $bU6Ve$lodash = require("lodash");
3
- var $bU6Ve$fs = require("fs");
4
- var $bU6Ve$crypto = require("crypto");
5
- var $bU6Ve$path = require("path");
6
- var $bU6Ve$child_process = require("child_process");
7
- var $bU6Ve$sqlite3 = require("sqlite3");
8
- var $bU6Ve$jsonwebtoken = require("jsonwebtoken");
2
+ var $7oI3p$lodash = require("lodash");
3
+ var $7oI3p$fs = require("fs");
4
+ var $7oI3p$crypto = require("crypto");
5
+ var $7oI3p$path = require("path");
6
+ var $7oI3p$child_process = require("child_process");
7
+ var $7oI3p$sqlite3 = require("sqlite3");
8
+ var $7oI3p$jsonwebtoken = require("jsonwebtoken");
9
9
 
10
10
  function $parcel$export(e, n, v, s) {
11
11
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
@@ -14,10 +14,10 @@ function $parcel$interopDefault(a) {
14
14
  return a && a.__esModule ? a.default : a;
15
15
  }
16
16
 
17
- $parcel$export(module.exports, "getCookie", () => $af7abeb0794bd6fa$export$4be65e66cfa2648a);
18
- $parcel$export(module.exports, "getFirefoxCookie", () => $af7abeb0794bd6fa$export$c44c5fdef43f0941);
19
- $parcel$export(module.exports, "getChromeCookie", () => $af7abeb0794bd6fa$export$e5637297e9eb6f2e);
20
- class $36bba8acd7b702be$export$2e2bcd8739ae039 {
17
+ $parcel$export(module.exports, "getCookie", () => $cd1ba0160120c006$export$4be65e66cfa2648a);
18
+ $parcel$export(module.exports, "getFirefoxCookie", () => $cd1ba0160120c006$export$c44c5fdef43f0941);
19
+ $parcel$export(module.exports, "getChromeCookie", () => $cd1ba0160120c006$export$e5637297e9eb6f2e);
20
+ class $503d2a3d296fcf21$export$2e2bcd8739ae039 {
21
21
  async queryCookies(name, domain) {
22
22
  if (process.env.NODE_ENV === "development") console.log("queryCookie", name, domain);
23
23
  return [];
@@ -26,12 +26,10 @@ class $36bba8acd7b702be$export$2e2bcd8739ae039 {
26
26
 
27
27
 
28
28
 
29
-
30
- async function $c0cdc003fbf917f0$export$8d71c74f97c0202e(command) {
31
- if (typeof command !== "string") throw new TypeError("execSimple: command must be a string");
29
+ async function $25b78d6746d4ad48$export$8d71c74f97c0202e(command) {
32
30
  if (process.env.VERBOSE) console.log(command);
33
31
  return new Promise((resolve, reject)=>{
34
- (0, $bU6Ve$child_process.exec)(command, {
32
+ (0, $7oI3p$child_process.exec)(command, {
35
33
  encoding: "binary",
36
34
  maxBuffer: 5120
37
35
  }, (error, stdout, stderr)=>{
@@ -43,34 +41,11 @@ async function $c0cdc003fbf917f0$export$8d71c74f97c0202e(command) {
43
41
  reject(error);
44
42
  return;
45
43
  }
46
- if (stdout) resolve(stdout.toString("utf8").trim());
44
+ if (stdout) resolve(stdout.trim());
47
45
  });
48
46
  });
49
47
  }
50
- async function $c0cdc003fbf917f0$export$1704cc27537f7088(command) {
51
- if (typeof command !== "string") throw new TypeError("execAsBuffer: command must be a string");
52
- if (process.env.VERBOSE) console.log(command);
53
- return await new Promise((resolve, reject)=>{
54
- (0, $bU6Ve$child_process.exec)(command, {
55
- encoding: "binary",
56
- maxBuffer: 5120
57
- }, (error, stdout, stderr)=>{
58
- if (error) {
59
- reject(error);
60
- return;
61
- }
62
- if (stderr) {
63
- reject(error);
64
- return;
65
- }
66
- let stdoutAsBuffer = stdout;
67
- if (typeof stdoutAsBuffer === "string" && stdoutAsBuffer.length > 0) // noinspection JSCheckFunctionSignatures
68
- stdoutAsBuffer = Buffer.from(stdoutAsBuffer, "binary").slice(0, -1);
69
- if (stdoutAsBuffer && stdoutAsBuffer.length > 0) resolve(stdoutAsBuffer);
70
- });
71
- });
72
- }
73
- function $c0cdc003fbf917f0$export$33d3adc27420eed5(r) {
48
+ function $25b78d6746d4ad48$export$33d3adc27420eed5(r) {
74
49
  if (process.env.VERBOSE) console.log("Printing value", r);
75
50
  if (r) {
76
51
  if (typeof r === "string") return r;
@@ -78,7 +53,7 @@ function $c0cdc003fbf917f0$export$33d3adc27420eed5(r) {
78
53
  return r.toString("utf8");
79
54
  }
80
55
  }
81
- function $c0cdc003fbf917f0$export$1ed1ce2ec2b4f5a3(r) {
56
+ function $25b78d6746d4ad48$export$1ed1ce2ec2b4f5a3(r) {
82
57
  if (process.env.VERBOSE) console.log("Printing value", r);
83
58
  if (r) {
84
59
  if (typeof r === "string") console.log(r);
@@ -86,7 +61,7 @@ function $c0cdc003fbf917f0$export$1ed1ce2ec2b4f5a3(r) {
86
61
  console.log(r.toString("utf8"));
87
62
  }
88
63
  }
89
- function $c0cdc003fbf917f0$export$d53bf2de587a369(result) {
64
+ function $25b78d6746d4ad48$export$d53bf2de587a369(result) {
90
65
  if (result == null) return null;
91
66
  if (process.env.VERBOSE) console.log("result", result);
92
67
  if (typeof result === "string" && result.length > 0) return result;
@@ -94,98 +69,59 @@ function $c0cdc003fbf917f0$export$d53bf2de587a369(result) {
94
69
  return result.toString("utf8");
95
70
  return null;
96
71
  }
97
-
98
- async function $c0cdc003fbf917f0$export$f19f611d1fa7c6f3(file, sql) {
99
- if (typeof sql !== "string") throw new TypeError("doSqliteQuery1: sql must be a string");
100
- if (typeof file !== "string") throw new TypeError("doSqliteQuery1: file must be a string");
101
- if (!(0, ($parcel$interopDefault($bU6Ve$fs))).existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
102
- if (process.env.VERBOSE) {
103
- console.log(`doSqliteQuery1: file ${file}`);
104
- console.log(`doSqliteQuery1: sql ${sql}`);
105
- }
106
- const sqlite3 = $bU6Ve$sqlite3;
107
- const db = new sqlite3.Database(file);
108
- return new Promise((resolve, reject)=>{
109
- db.all(sql, (err, rows)=>{
110
- if (err) {
111
- if (process.env.VERBOSE) console.log(`doSqliteQuery1: error ${err}`);
112
- reject(err);
113
- return;
114
- }
115
- const rows1 = rows;
116
- if (rows1 == null || rows1.length === 0) {
117
- if (process.env.VERBOSE) console.log(`doSqliteQuery1: no rows`);
118
- resolve([]);
119
- return;
120
- }
121
- if (Array.isArray(rows1)) {
122
- if (process.env.VERBOSE) console.log(`doSqliteQuery1: ${rows1.length} rows`);
123
- // noinspection JSCheckFunctionSignatures
124
- const buffers = rows1.flatMap((row)=>Object.values(row)).map((v)=>Buffer.from(v, "binary"));
125
- if (process.env.VERBOSE) console.log(`doSqliteQuery1: ${buffers.length} buffers`);
126
- resolve(buffers);
127
- return;
128
- }
129
- if (process.env.VERBOSE) console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);
130
- resolve([
131
- rows1
132
- ]);
133
- });
134
- });
135
- }
136
- function $c0cdc003fbf917f0$export$99ce3e33a555daf1(input) {
72
+ function $25b78d6746d4ad48$export$99ce3e33a555daf1(input) {
137
73
  return typeof input !== "string" || input.length === 0;
138
74
  }
75
+ function $25b78d6746d4ad48$export$5348b46700dd771c(input) {
76
+ return typeof input == "string" && input.length > 0;
77
+ }
139
78
 
140
79
 
141
80
 
142
- var $fa5ed5287f8fdf72$require$merge = $bU6Ve$lodash.merge;
143
- const $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3 = {};
144
- $fa5ed5287f8fdf72$require$merge($fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3, process.env);
145
- const $fa5ed5287f8fdf72$export$a7c5707626fc90f = $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3["HOME"];
146
- if (!$fa5ed5287f8fdf72$export$a7c5707626fc90f) throw new Error("HOME environment variable is not set");
81
+ var $fac425c10fbbada5$require$merge = $7oI3p$lodash.merge;
82
+ const $fac425c10fbbada5$export$a7b6bc01c63cdfc3 = {};
83
+ $fac425c10fbbada5$require$merge($fac425c10fbbada5$export$a7b6bc01c63cdfc3, process.env);
84
+ const $fac425c10fbbada5$export$a7c5707626fc90f = $fac425c10fbbada5$export$a7b6bc01c63cdfc3["HOME"];
85
+ if (!$fac425c10fbbada5$export$a7c5707626fc90f) throw new Error("HOME environment variable is not set");
147
86
 
148
87
 
149
88
 
150
89
 
151
90
 
152
- async function $d6c2e79f3cdd498d$export$2c9faf86071156ae({ path: path , name: name , maxDepth: maxDepth = 2 }) {
153
- if (typeof path !== "string") throw new Error("path must be a string");
154
- if (typeof name !== "string") throw new Error("name must be a string");
91
+ async function $e62c2c56eb720f29$export$2c9faf86071156ae({ path: path , name: name , maxDepth: maxDepth = 2 }) {
155
92
  const rootSegments = path.split("/").length;
156
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Searching for ${name} in ${path}`);
93
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Searching for ${name} in ${path}`);
157
94
  const files = [];
158
95
  let readdirSync;
159
96
  try {
160
- readdirSync = (0, ($parcel$interopDefault($bU6Ve$fs))).readdirSync(path);
97
+ readdirSync = $7oI3p$fs.readdirSync(path);
161
98
  } catch (e) {
162
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Error reading ${path}`, e);
163
- return files;
99
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Error reading ${path}`, e);
100
+ return [];
164
101
  }
165
102
  for (const file of readdirSync){
166
103
  const filePath = path + "/" + file;
167
104
  let stat;
168
105
  try {
169
- stat = (0, ($parcel$interopDefault($bU6Ve$fs))).statSync(filePath);
106
+ stat = $7oI3p$fs.statSync(filePath);
170
107
  } catch (e1) {
171
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.error(`Error getting stat for ${filePath}`, e1);
108
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.error(`Error getting stat for ${filePath}`, e1);
172
109
  continue;
173
110
  }
174
111
  if (stat.isDirectory()) {
175
112
  if (filePath.split("/").length < rootSegments + maxDepth) try {
176
- const subFiles = await $d6c2e79f3cdd498d$export$2c9faf86071156ae({
113
+ const subFiles = await $e62c2c56eb720f29$export$2c9faf86071156ae({
177
114
  path: filePath,
178
115
  name: name,
179
- rootSegments: rootSegments,
180
116
  maxDepth: 2
181
117
  });
182
118
  files.push(...subFiles);
183
119
  } catch (e2) {
184
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.error(e2);
120
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.error(e2);
185
121
  }
186
122
  } else if (file === name) files.push(filePath);
187
123
  }
188
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) {
124
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) {
189
125
  if (files.length > 0) {
190
126
  console.log(`Found ${files.length} ${name} files`);
191
127
  console.log(files);
@@ -197,111 +133,148 @@ async function $d6c2e79f3cdd498d$export$2c9faf86071156ae({ path: path , name: na
197
133
 
198
134
 
199
135
 
200
- class $1c57ad353fa3519e$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$export$2e2bcd8739ae039) {
136
+ function $3d7e27b54f670f46$export$bc926c43858bd3cb(obj) {
137
+ return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
138
+ }
139
+ function $3d7e27b54f670f46$export$963c8d651337e4a4(obj) {
140
+ return obj.domain !== undefined && obj.name !== undefined && obj.value !== undefined;
141
+ }
142
+
143
+
144
+
145
+
146
+ async function $a085b524d8ee9fce$export$f19f611d1fa7c6f3(file, sql) {
147
+ if (!$7oI3p$fs.existsSync(file)) throw new Error(`doSqliteQuery1: file ${file} does not exist`);
148
+ const db = new $7oI3p$sqlite3.Database(file);
149
+ return new Promise((resolve, reject)=>{
150
+ db.all(sql, (err, rows)=>{
151
+ if (err) {
152
+ if (process.env.VERBOSE) console.log(`doSqliteQuery1: error ${err}`);
153
+ reject(err);
154
+ return;
155
+ }
156
+ const rows1 = rows;
157
+ if (rows1 == null || rows1.length === 0) {
158
+ if (process.env.VERBOSE) console.log(`doSqliteQuery1: no rows`);
159
+ resolve([]);
160
+ return;
161
+ }
162
+ if (Array.isArray(rows1)) {
163
+ const cookieRows = rows1.map((row)=>{
164
+ return {
165
+ domain: row["host_key"],
166
+ name: row["name"],
167
+ value: row["encrypted_value"],
168
+ meta: {
169
+ file: file
170
+ }
171
+ };
172
+ });
173
+ resolve(cookieRows);
174
+ return;
175
+ }
176
+ if (process.env.VERBOSE) console.log(`doSqliteQuery1: rows ${JSON.stringify(rows1)}`);
177
+ resolve([
178
+ rows1
179
+ ]);
180
+ });
181
+ });
182
+ }
183
+
184
+
185
+
186
+ class $269fe42bfd555305$export$2e2bcd8739ae039 extends (0, $503d2a3d296fcf21$export$2e2bcd8739ae039) {
201
187
  async queryCookies(name, domain) {
202
188
  if (process.platform !== "darwin") throw new Error("This only works on macOS");
203
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).FIREFOX_ONLY) return [];
204
- const cookies = await $1c57ad353fa3519e$var$getChromeCookies({
189
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).FIREFOX_ONLY) return [];
190
+ return $269fe42bfd555305$var$getChromeCookies({
191
+ requireJwt: false,
205
192
  name: name,
206
193
  domain: domain
207
194
  });
208
- return cookies.map((0, $c0cdc003fbf917f0$export$33d3adc27420eed5));
209
195
  }
210
196
  }
211
- async function $1c57ad353fa3519e$var$getPromise1(name, domain, file) {
197
+ async function $269fe42bfd555305$var$getPromise1(name, domain, file) {
212
198
  try {
213
- return await $1c57ad353fa3519e$var$getEncryptedChromeCookie({
199
+ return await $269fe42bfd555305$var$getEncryptedChromeCookie({
214
200
  name: name,
215
201
  domain: domain,
216
202
  file: file
217
203
  });
218
204
  } catch (e) {
219
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error getting encrypted cookie", e);
205
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error getting encrypted cookie", e);
220
206
  return [];
221
207
  }
222
208
  }
223
- async function $1c57ad353fa3519e$var$getPromise(name, domain) {
209
+ async function $269fe42bfd555305$var$getPromise(name, domain) {
224
210
  try {
225
- const files = await (0, $d6c2e79f3cdd498d$export$2c9faf86071156ae)({
226
- path: $1c57ad353fa3519e$var$chromeLocal,
211
+ const files = await (0, $e62c2c56eb720f29$export$2c9faf86071156ae)({
212
+ path: $269fe42bfd555305$var$chromeLocal,
227
213
  name: "Cookies"
228
214
  });
229
- const promises = files.map((file)=>$1c57ad353fa3519e$var$getPromise1(name, domain, file));
215
+ const promises = files.map((file)=>$269fe42bfd555305$var$getPromise1(name, domain, file));
230
216
  const results1 = await Promise.all(promises);
231
- const results2 = results1.flat();
232
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("getEncryptedChromeCookie results", results2);
233
- return results2.filter((result)=>result);
217
+ return results1.flat().filter((0, $3d7e27b54f670f46$export$bc926c43858bd3cb));
234
218
  } catch (error) {
235
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("error", error);
219
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("error", error);
236
220
  return [];
237
221
  }
238
222
  }
239
- /**
240
- *
241
- * @param {string|undefined} name
242
- * @param {string} domain
243
- * @param {boolean} requireJwt
244
- * @returns {Promise<[string]>}
245
- */ async function $1c57ad353fa3519e$var$getChromeCookies({ name: name , domain: domain = "%" , requireJwt: requireJwt = false }) {
246
- if ((0, $c0cdc003fbf917f0$export$99ce3e33a555daf1)(name)) throw new Error("name must be a string");
247
- if ((0, $c0cdc003fbf917f0$export$99ce3e33a555daf1)(domain)) throw new Error("domain must be a string");
248
- const encryptedDataItems = await $1c57ad353fa3519e$var$getPromise(name, domain);
249
- const password = await $1c57ad353fa3519e$var$getChromePassword();
250
- const decrypted = encryptedDataItems.filter((encryptedData)=>{
251
- return encryptedData != null && encryptedData.length > 0;
252
- }).map(async (encryptedData)=>{
253
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Received encrypted", encryptedData);
254
- let d;
255
- try {
256
- d = await $1c57ad353fa3519e$var$decrypt(password, encryptedData);
257
- } catch (e) {
258
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error decrypting cookie", e);
259
- return null;
260
- }
261
- if (d) {
262
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Decrypted", d);
263
- return d;
264
- }
265
- return null;
223
+ async function $269fe42bfd555305$var$decryptValue(password, encryptedValue) {
224
+ let d;
225
+ try {
226
+ d = await $269fe42bfd555305$var$decrypt(password, encryptedValue);
227
+ } catch (e) {
228
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error decrypting cookie", e);
229
+ d = null;
230
+ }
231
+ return d ?? encryptedValue.toString("utf-8");
232
+ }
233
+ async function $269fe42bfd555305$var$getChromeCookies({ name: name , domain: domain = "%" , requireJwt: requireJwt = false }) {
234
+ const encryptedDataItems = await $269fe42bfd555305$var$getPromise(name, domain);
235
+ const password = await $269fe42bfd555305$var$getChromePassword();
236
+ const decrypted = encryptedDataItems.filter(({ value: value })=>value != null && value.length > 0).map(async (cookieRow)=>{
237
+ const encryptedValue = cookieRow.value;
238
+ const decryptedValue = await $269fe42bfd555305$var$decryptValue(password, encryptedValue);
239
+ const meta = {};
240
+ (0, $7oI3p$lodash.merge)(meta, cookieRow.meta ?? {});
241
+ return {
242
+ domain: cookieRow.domain,
243
+ name: cookieRow.name,
244
+ value: decryptedValue,
245
+ meta: meta
246
+ };
266
247
  });
267
- const results = await Promise.all(decrypted);
268
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("results", results);
269
- return results.map((0, $c0cdc003fbf917f0$export$d53bf2de587a369));
248
+ const results = (await Promise.all(decrypted)).filter((0, $3d7e27b54f670f46$export$963c8d651337e4a4));
249
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("results", results);
250
+ return results;
270
251
  }
271
- const $1c57ad353fa3519e$var$chromeLocal = $bU6Ve$path.join((0, $fa5ed5287f8fdf72$export$a7c5707626fc90f), "Library", "Application Support", "Google", "Chrome");
272
- async function $1c57ad353fa3519e$var$getEncryptedChromeCookie({ name: name , domain: domain , file: file = $bU6Ve$path.join($1c57ad353fa3519e$var$chromeLocal, "Default", "Cookies") , }) {
273
- if (name && typeof name !== "string") throw new Error("name must be a string");
274
- if (domain && typeof domain !== "string") throw new Error("domain must be a string");
275
- if (file && typeof file !== "string") throw new Error("file must be a string");
276
- if (!(0, $bU6Ve$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
277
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) {
252
+ const $269fe42bfd555305$var$chromeLocal = $7oI3p$path.join((0, $fac425c10fbbada5$export$a7c5707626fc90f), "Library", "Application Support", "Google", "Chrome");
253
+ async function $269fe42bfd555305$var$getEncryptedChromeCookie({ name: name , domain: domain , file: file = $7oI3p$path.join($269fe42bfd555305$var$chromeLocal, "Default", "Cookies") }) {
254
+ if (!(0, $7oI3p$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
255
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) {
278
256
  const s = file.split("/").slice(-3).join("/");
279
257
  console.log(`Trying Chrome (at ${s}) cookie ${name} for domain ${domain}`);
280
258
  }
281
259
  let sql;
282
- sql = `SELECT encrypted_value FROM cookies`;
283
- if (typeof name === "string" || typeof domain === "string") {
260
+ sql = `SELECT encrypted_value, name, host_key FROM cookies`;
261
+ const wildcardRegexp = /^([*%])$/i;
262
+ const specifiedName = name.match(wildcardRegexp) == null;
263
+ const specifiedDomain = domain.match(wildcardRegexp) == null;
264
+ if (specifiedName || specifiedDomain) {
284
265
  sql += ` WHERE `;
285
- if (typeof name === "string") {
266
+ if (specifiedName) {
286
267
  sql += `name = '${name}'`;
287
- if (typeof domain === "string") sql += ` AND `;
268
+ if (specifiedDomain) sql += ` AND `;
288
269
  }
289
- if (typeof domain === "string") sql += `host_key LIKE '${domain}';`;
270
+ if (specifiedDomain) sql += `host_key LIKE '${domain}';`;
290
271
  }
291
- return (0, $c0cdc003fbf917f0$export$f19f611d1fa7c6f3)(file, sql);
272
+ return (0, $a085b524d8ee9fce$export$f19f611d1fa7c6f3)(file, sql);
292
273
  }
293
- /**
294
- *
295
- * @returns {Promise<string>}
296
- */ async function $1c57ad353fa3519e$var$getChromePassword() {
297
- return (0, $c0cdc003fbf917f0$export$8d71c74f97c0202e)('security find-generic-password -w -s "Chrome Safe Storage"');
274
+ async function $269fe42bfd555305$var$getChromePassword() {
275
+ return (0, $25b78d6746d4ad48$export$8d71c74f97c0202e)('security find-generic-password -w -s "Chrome Safe Storage"');
298
276
  }
299
- /**
300
- *
301
- * @param {string} password
302
- * @param {Buffer} encryptedData
303
- * @returns {Promise<string>}
304
- */ async function $1c57ad353fa3519e$var$decrypt(password, encryptedData) {
277
+ async function $269fe42bfd555305$var$decrypt(password, encryptedData) {
305
278
  if (typeof password !== "string") throw new Error("password must be a string: " + password);
306
279
  let encryptedData1;
307
280
  encryptedData1 = encryptedData;
@@ -309,30 +282,31 @@ async function $1c57ad353fa3519e$var$getEncryptedChromeCookie({ name: name , dom
309
282
  if (!(encryptedData1 instanceof Buffer)) {
310
283
  if (Array.isArray(encryptedData1) && encryptedData1[0] instanceof Buffer) {
311
284
  [encryptedData1] = encryptedData1;
312
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`encryptedData is an array of buffers, selected first: ${encryptedData1}`);
285
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`encryptedData is an array of buffers, selected first: ${encryptedData1}`);
313
286
  } else throw new Error("encryptedData must be a Buffer: " + encryptedData1);
314
287
  encryptedData1 = Buffer.from(encryptedData1);
315
288
  }
316
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Trying to decrypt with password ${password}`);
289
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Trying to decrypt with password ${password}`);
317
290
  return new Promise((resolve, reject)=>{
318
- (0, ($parcel$interopDefault($bU6Ve$crypto))).pbkdf2(password, "saltysalt", 1003, 16, "sha1", (error, buffer)=>{
291
+ $7oI3p$crypto.pbkdf2(password, "saltysalt", 1003, 16, "sha1", (error, buffer)=>{
319
292
  try {
320
293
  if (error) {
321
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing pbkdf2", error);
294
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing pbkdf2", error);
322
295
  reject(error);
323
296
  return;
324
297
  }
325
298
  if (buffer.length !== 16) {
326
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing pbkdf2, buffer length is not 16", buffer.length);
299
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing pbkdf2, buffer length is not 16", buffer.length);
327
300
  reject(new Error("Buffer length is not 16"));
328
301
  return;
329
302
  }
330
- const iv = new Buffer.from(new Array(17).join(" "), "binary");
331
- const decipher = (0, ($parcel$interopDefault($bU6Ve$crypto))).createDecipheriv("aes-128-cbc", buffer, iv);
303
+ const str = new Array(17).join(" ");
304
+ const iv = Buffer.from(str, "binary");
305
+ const decipher = $7oI3p$crypto.createDecipheriv("aes-128-cbc", buffer, iv);
332
306
  decipher.setAutoPadding(false);
333
307
  if (encryptedData1 && encryptedData1.slice) encryptedData1 = encryptedData1.slice(3);
334
308
  if (encryptedData1.length % 16 !== 0) {
335
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing pbkdf2, encryptedData length is not a multiple of 16", encryptedData1.length);
309
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing pbkdf2, encryptedData length is not a multiple of 16", encryptedData1.length);
336
310
  reject(new Error("encryptedData length is not a multiple of 16"));
337
311
  return;
338
312
  }
@@ -340,15 +314,15 @@ async function $1c57ad353fa3519e$var$getEncryptedChromeCookie({ name: name , dom
340
314
  try {
341
315
  decipher.final("utf-8");
342
316
  } catch (e) {
343
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing decipher.final()", e);
317
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log("Error doing decipher.final()", e);
344
318
  reject(e);
345
319
  return;
346
320
  }
347
321
  const padding = decoded[decoded.length - 1];
348
322
  if (padding) decoded = decoded.slice(0, 0 - padding);
349
323
  // noinspection JSCheckFunctionSignatures
350
- decoded = decoded.toString("utf8");
351
- resolve(decoded);
324
+ const decodedString = decoded.toString("utf8");
325
+ resolve(decodedString);
352
326
  } catch (e1) {
353
327
  reject(e1);
354
328
  }
@@ -363,36 +337,36 @@ async function $1c57ad353fa3519e$var$getEncryptedChromeCookie({ name: name , dom
363
337
 
364
338
 
365
339
 
366
- class $d66ab4010a2fe667$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$export$2e2bcd8739ae039) {
340
+
341
+ class $7bb7da9a77b2fd99$export$2e2bcd8739ae039 extends (0, $503d2a3d296fcf21$export$2e2bcd8739ae039) {
367
342
  async queryCookies(name, domain) {
368
343
  if (process.platform !== "darwin") throw new Error("This only works on macOS");
369
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).CHROME_ONLY) return [];
344
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).CHROME_ONLY) return [];
370
345
  const cookies = await this.#getFirefoxCookie({
371
346
  name: name,
372
347
  domain: domain
373
348
  });
374
- return Array.isArray(cookies) ? cookies.map((0, $c0cdc003fbf917f0$export$d53bf2de587a369)) : [];
349
+ return Array.isArray(cookies) ? cookies.map((0, $25b78d6746d4ad48$export$d53bf2de587a369)) : [];
375
350
  }
376
351
  /**
377
352
  *
378
353
  * @param name
379
354
  * @param domain
380
355
  * @returns {Promise<Buffer>}
381
- */ async #getFirefoxCookie({ name: name , domain: domain }) {
382
- if (name && typeof name !== "string") throw new Error("name must be a string");
383
- if (domain && typeof domain !== "string") throw new Error("domain must be a string");
384
- const files = await (0, $d6c2e79f3cdd498d$export$2c9faf86071156ae)({
385
- path: $bU6Ve$path.join((0, $fa5ed5287f8fdf72$export$a7c5707626fc90f), "Library", "Application Support", "Firefox", "Profiles"),
356
+ */ async #getFirefoxCookie(//
357
+ { name: name , domain: domain }) {
358
+ const files = await (0, $e62c2c56eb720f29$export$2c9faf86071156ae)({
359
+ path: $7oI3p$path.join((0, $fac425c10fbbada5$export$a7c5707626fc90f), "Library", "Application Support", "Firefox", "Profiles"),
386
360
  name: "cookies.sqlite"
387
361
  });
388
- const all = Promise.all(files.map((file)=>{
362
+ const all = await Promise.all(files.map((file)=>{
389
363
  return this.#queryCookiesDb(file, name, domain);
390
364
  }));
391
365
  return all.flat();
392
366
  }
393
367
  #queryCookiesDb(file, name1, domain1) {
394
- if (file && !(0, $bU6Ve$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
395
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Trying Firefox cookie ${name1} for domain ${domain1}`);
368
+ if (file && !(0, $7oI3p$fs.existsSync)(file)) throw new Error(`File ${file} does not exist`);
369
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(`Trying Firefox cookie ${name1} for domain ${domain1}`);
396
370
  let sql;
397
371
  //language=SQL
398
372
  sql = "SELECT value FROM moz_cookies";
@@ -404,32 +378,42 @@ class $d66ab4010a2fe667$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$exp
404
378
  }
405
379
  if (typeof domain1 === "string") sql += `host LIKE '${domain1}';`;
406
380
  }
407
- return (0, $c0cdc003fbf917f0$export$f19f611d1fa7c6f3)(file, sql).then((rows)=>rows.map((0, $c0cdc003fbf917f0$export$d53bf2de587a369))).catch(()=>[]);
381
+ return (0, $a085b524d8ee9fce$export$f19f611d1fa7c6f3)(file, sql).then((rows)=>{
382
+ return rows.map((row)=>{
383
+ return {
384
+ domain: row.domain,
385
+ name: row.name,
386
+ value: row.value.toString("utf8")
387
+ };
388
+ });
389
+ }).catch(()=>[]);
408
390
  }
409
391
  }
410
392
 
411
393
 
412
394
 
413
- class $ebf338ffba2ec9e7$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$export$2e2bcd8739ae039) {
395
+ class $fad6f51bd5c7bae2$export$2e2bcd8739ae039 extends (0, $503d2a3d296fcf21$export$2e2bcd8739ae039) {
414
396
  }
415
397
 
416
398
 
417
399
 
418
- class $b4be7ecb8cbd1374$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$export$2e2bcd8739ae039) {
400
+ class $f72befa528c23ca7$export$2e2bcd8739ae039 extends (0, $503d2a3d296fcf21$export$2e2bcd8739ae039) {
419
401
  #strategies;
420
402
  constructor(){
421
403
  super();
422
404
  this.#strategies = [
423
- (0, $1c57ad353fa3519e$export$2e2bcd8739ae039),
424
- (0, $d66ab4010a2fe667$export$2e2bcd8739ae039),
425
- (0, $ebf338ffba2ec9e7$export$2e2bcd8739ae039),
405
+ (0, $269fe42bfd555305$export$2e2bcd8739ae039),
406
+ (0, $7bb7da9a77b2fd99$export$2e2bcd8739ae039),
407
+ (0, $fad6f51bd5c7bae2$export$2e2bcd8739ae039),
426
408
  ].map((strategy)=>{
427
409
  return new strategy();
428
410
  });
429
411
  }
430
412
  async queryCookies(name, domain) {
431
413
  const results = await Promise.all(this.#strategies.map(async (strategy)=>{
432
- return strategy.queryCookies(name, domain).catch(()=>[]);
414
+ // @ts-ignore
415
+ const cookies = strategy.queryCookies(name, domain);
416
+ return cookies.catch(()=>[]);
433
417
  }));
434
418
  return results.flat();
435
419
  }
@@ -440,13 +424,12 @@ class $b4be7ecb8cbd1374$export$2e2bcd8739ae039 extends (0, $36bba8acd7b702be$exp
440
424
 
441
425
 
442
426
 
443
- function $e0bc45c44166a2ff$export$2e2bcd8739ae039(token) {
444
- if (typeof token !== "string") return false;
427
+ function $9a6b2ace073cf1d7$export$2e2bcd8739ae039(token) {
445
428
  try {
446
- const result = (0, ($parcel$interopDefault($bU6Ve$jsonwebtoken))).decode(token, {
429
+ const result = (0, ($parcel$interopDefault($7oI3p$jsonwebtoken))).decode(token, {
447
430
  complete: true
448
431
  });
449
- if ((0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).VERBOSE) console.log(result);
432
+ if ((0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).VERBOSE) console.log(result);
450
433
  return true;
451
434
  } catch (err) {
452
435
  return false;
@@ -454,23 +437,16 @@ function $e0bc45c44166a2ff$export$2e2bcd8739ae039(token) {
454
437
  }
455
438
 
456
439
 
457
- async function $8dc1bcea169affbc$export$e6d428437cf2cacb({ name: name , domain: domain }, strategy = new (0, $b4be7ecb8cbd1374$export$2e2bcd8739ae039)()) {
440
+ async function $7a068a32d4710f0b$export$e6d428437cf2cacb({ name: name , domain: domain }, strategy = new (0, $f72befa528c23ca7$export$2e2bcd8739ae039)()) {
458
441
  const results = await strategy.queryCookies(name, domain);
459
- const results1 = (0, $bU6Ve$lodash.uniq)(results).map((cookie)=>{
460
- return {
461
- name: name,
462
- domain: domain,
463
- value: cookie
464
- };
465
- });
442
+ const results1 = (0, $7oI3p$lodash.uniqBy)(results, JSON.stringify);
466
443
  const jwtCookies = [];
467
444
  for (const result of results1){
468
445
  const value = result.value;
469
- if ((0, $e0bc45c44166a2ff$export$2e2bcd8739ae039)(value)) jwtCookies.push(result);
446
+ if ((0, $9a6b2ace073cf1d7$export$2e2bcd8739ae039)(value)) jwtCookies.push(result);
470
447
  }
471
- const results2 = (0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).REQUIRE_JWT ? jwtCookies : results1;
472
- const resultsUniq = (0, $bU6Ve$lodash.uniq)(results2).map((cookie)=>cookie.value);
473
- return (0, $fa5ed5287f8fdf72$export$a7b6bc01c63cdfc3).SINGLE ? [
448
+ const resultsUniq = (0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).REQUIRE_JWT ? jwtCookies : results1;
449
+ return (0, $fac425c10fbbada5$export$a7b6bc01c63cdfc3).SINGLE ? [
474
450
  resultsUniq[0]
475
451
  ] : resultsUniq;
476
452
  }
@@ -479,18 +455,18 @@ async function $8dc1bcea169affbc$export$e6d428437cf2cacb({ name: name , domain:
479
455
 
480
456
 
481
457
 
482
- async function $af7abeb0794bd6fa$export$4be65e66cfa2648a(params) {
483
- const cookies = await (0, $8dc1bcea169affbc$export$e6d428437cf2cacb)(params, new (0, $b4be7ecb8cbd1374$export$2e2bcd8739ae039)());
458
+ async function $cd1ba0160120c006$export$4be65e66cfa2648a(params) {
459
+ const cookies = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)(params, new (0, $f72befa528c23ca7$export$2e2bcd8739ae039)());
484
460
  if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
485
461
  else throw new Error("Cookie not found");
486
462
  }
487
- async function $af7abeb0794bd6fa$export$c44c5fdef43f0941(params) {
488
- const cookies = await (0, $8dc1bcea169affbc$export$e6d428437cf2cacb)(params, new (0, $d66ab4010a2fe667$export$2e2bcd8739ae039)());
463
+ async function $cd1ba0160120c006$export$c44c5fdef43f0941(params) {
464
+ const cookies = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)(params, new (0, $7bb7da9a77b2fd99$export$2e2bcd8739ae039)());
489
465
  if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
490
466
  else throw new Error("Cookie not found");
491
467
  }
492
- async function $af7abeb0794bd6fa$export$e5637297e9eb6f2e(params) {
493
- const cookies = await (0, $8dc1bcea169affbc$export$e6d428437cf2cacb)(params, new (0, $1c57ad353fa3519e$export$2e2bcd8739ae039)());
468
+ async function $cd1ba0160120c006$export$e5637297e9eb6f2e(params) {
469
+ const cookies = await (0, $7a068a32d4710f0b$export$e6d428437cf2cacb)(params, new (0, $269fe42bfd555305$export$2e2bcd8739ae039)());
494
470
  if (Array.isArray(cookies) && cookies.length > 0) return cookies.find((cookie)=>cookie != null);
495
471
  else throw new Error("Cookie not found");
496
472
  }