@mherod/get-cookie 2.0.0-beta.5 → 2.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +67 -52
- package/dist/main.js.map +1 -1
- package/dist/module.js +63 -54
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +15 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/CookieRequest.ts +5 -0
- package/src/CookieRow.ts +0 -1
- package/src/argv.ts +1 -1
- package/src/getGroupedRenderedCookies.ts +32 -0
- package/src/index.ts +6 -32
- package/src/queryCookies.ts +2 -4
- package/src/utils.ts +0 -62
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
interface CookieRequest {
|
|
3
|
+
name: string;
|
|
4
|
+
domain: string;
|
|
5
|
+
}
|
|
6
|
+
declare function getGroupedRenderedCookies({ name, domain }: CookieRequest): Promise<string[]>;
|
|
2
7
|
export function getCookie(params: {
|
|
3
8
|
name: string;
|
|
4
9
|
domain: string;
|
|
5
|
-
}): Promise<import("
|
|
10
|
+
}): Promise<import("ExportedCookie").default | undefined>;
|
|
6
11
|
/**
|
|
7
12
|
*
|
|
8
13
|
* @param params
|
|
@@ -11,7 +16,7 @@ export function getCookie(params: {
|
|
|
11
16
|
export function getFirefoxCookie(params: {
|
|
12
17
|
name: string;
|
|
13
18
|
domain: string;
|
|
14
|
-
}): Promise<import("
|
|
19
|
+
}): Promise<import("ExportedCookie").default | undefined>;
|
|
15
20
|
/**
|
|
16
21
|
*
|
|
17
22
|
* @param params
|
|
@@ -20,6 +25,13 @@ export function getFirefoxCookie(params: {
|
|
|
20
25
|
export function getChromeCookie(params: {
|
|
21
26
|
name: string;
|
|
22
27
|
domain: string;
|
|
23
|
-
}): Promise<import("
|
|
28
|
+
}): Promise<import("ExportedCookie").default | undefined>;
|
|
29
|
+
declare const _default: {
|
|
30
|
+
getCookie: typeof getCookie;
|
|
31
|
+
getFirefoxCookie: typeof getFirefoxCookie;
|
|
32
|
+
getChromeCookie: typeof getChromeCookie;
|
|
33
|
+
getGroupedRenderedCookies: typeof getGroupedRenderedCookies;
|
|
34
|
+
};
|
|
35
|
+
export default _default;
|
|
24
36
|
|
|
25
37
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";
|
|
1
|
+
{"mappings":";AcAA;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AGID,2CAEE,EACE,IAAI,EACJ,MAAM,EAEP,EAAE,aAAa,GAEf,OAAO,CAAC,MAAM,EAAE,CAAC,CAgBnB;ACtBD,0BAAgC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;CAAE,yDAWxE;AAED;;;;GAIG;AACH,iCAAuC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;CAAE,yDAW/E;AAED;;;;GAIG;AACH,gCAAsC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;CAAE,yDAW9E;;;;;;;AAED,wBAKC","sources":["src/src/global.ts","src/src/ExportedCookie.ts","src/src/browsers/CookieQueryStrategy.ts","src/src/utils.ts","src/src/findAllFiles.ts","src/src/CookieRow.ts","src/src/doSqliteQuery1.ts","src/src/IsCookieRow.ts","src/src/IsExportedCookie.ts","src/src/browsers/ChromeCookieQueryStrategy.ts","src/src/browsers/FirefoxCookieQueryStrategy.ts","src/src/browsers/SafariCookieQueryStrategy.ts","src/src/browsers/CompositeCookieQueryStrategy.ts","src/src/isValidJwt.ts","src/src/CookieRequest.ts","src/src/queryCookies.ts","src/src/resultsRendered.ts","src/src/getGroupedRenderedCookies.ts","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"#!/usr/bin/env node\n// noinspection JSUnusedGlobalSymbols\n\nimport { queryCookies } from \"./queryCookies\";\nimport FirefoxCookieQueryStrategy from \"./browsers/FirefoxCookieQueryStrategy\";\nimport ChromeCookieQueryStrategy from \"./browsers/ChromeCookieQueryStrategy\";\nimport CompositeCookieQueryStrategy from \"./browsers/CompositeCookieQueryStrategy\";\nimport { getGroupedRenderedCookies } from \"./getGroupedRenderedCookies\";\n\nexport async function getCookie(params: { name: string; domain: string; }) {\n const cookies = await queryCookies(\n params,\n new CompositeCookieQueryStrategy()\n //\n );\n if (Array.isArray(cookies) && cookies.length > 0) {\n return cookies.find((cookie) => cookie != null);\n } else {\n throw new Error(\"Cookie not found\");\n }\n}\n\n/**\n *\n * @param params\n * @returns {Promise<*>}\n */\nexport async function getFirefoxCookie(params: { name: string; domain: string; }) {\n const cookies = await queryCookies(\n params,\n new FirefoxCookieQueryStrategy()\n //\n );\n if (Array.isArray(cookies) && cookies.length > 0) {\n return cookies.find((cookie) => cookie != null);\n } else {\n throw new Error(\"Cookie not found\");\n }\n}\n\n/**\n *\n * @param params\n * @returns {Promise<*>}\n */\nexport async function getChromeCookie(params: { name: string; domain: string; }) {\n const cookies = await queryCookies(\n params,\n new ChromeCookieQueryStrategy()\n //\n );\n if (Array.isArray(cookies) && cookies.length > 0) {\n return cookies.find((cookie) => cookie != null);\n } else {\n throw new Error(\"Cookie not found\");\n }\n}\n\nexport default {\n getCookie,\n getFirefoxCookie,\n getChromeCookie,\n getGroupedRenderedCookies,\n}\n"],"names":[],"version":3,"file":"types.d.ts.map","sourceRoot":"../"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mherod/get-cookie",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.6",
|
|
4
4
|
"description": "Node.js module for querying a local user's Chrome cookie",
|
|
5
|
+
"source": "src/index.ts",
|
|
5
6
|
"bin": "dist/cli.js",
|
|
6
7
|
"main": "dist/main.js",
|
|
7
8
|
"module": "dist/module.js",
|
package/src/CookieRow.ts
CHANGED
package/src/argv.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const argv = process.argv ?? [];
|
|
1
|
+
export const argv: string[] = process.argv ?? [];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ExportedCookie from "./ExportedCookie";
|
|
2
|
+
import { queryCookies } from "./queryCookies";
|
|
3
|
+
import CompositeCookieQueryStrategy from "./browsers/CompositeCookieQueryStrategy";
|
|
4
|
+
import { groupBy } from "lodash";
|
|
5
|
+
import { resultsRendered } from "./resultsRendered";
|
|
6
|
+
import CookieRequest from "./CookieRequest";
|
|
7
|
+
|
|
8
|
+
export async function getGroupedRenderedCookies(
|
|
9
|
+
//
|
|
10
|
+
{
|
|
11
|
+
name,
|
|
12
|
+
domain
|
|
13
|
+
//
|
|
14
|
+
}: CookieRequest
|
|
15
|
+
//
|
|
16
|
+
): Promise<string[]> {
|
|
17
|
+
const cookies: ExportedCookie[] = await queryCookies(
|
|
18
|
+
{ name, domain },
|
|
19
|
+
new CompositeCookieQueryStrategy()
|
|
20
|
+
//
|
|
21
|
+
);
|
|
22
|
+
if (Array.isArray(cookies) && cookies.length > 0) {
|
|
23
|
+
const results: ExportedCookie[] = await queryCookies({ name, domain });
|
|
24
|
+
const groupedByFile = groupBy(results, (r) => r.meta?.file);
|
|
25
|
+
return Object.keys(groupedByFile).map((file: string) => {
|
|
26
|
+
const results: ExportedCookie[] = groupedByFile[file];
|
|
27
|
+
return resultsRendered(results);
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
throw new Error("Cookie not found");
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,9 +5,7 @@ import { queryCookies } from "./queryCookies";
|
|
|
5
5
|
import FirefoxCookieQueryStrategy from "./browsers/FirefoxCookieQueryStrategy";
|
|
6
6
|
import ChromeCookieQueryStrategy from "./browsers/ChromeCookieQueryStrategy";
|
|
7
7
|
import CompositeCookieQueryStrategy from "./browsers/CompositeCookieQueryStrategy";
|
|
8
|
-
import
|
|
9
|
-
import { groupBy } from "lodash";
|
|
10
|
-
import { resultsRendered } from "./resultsRendered";
|
|
8
|
+
import { getGroupedRenderedCookies } from "./getGroupedRenderedCookies";
|
|
11
9
|
|
|
12
10
|
export async function getCookie(params: { name: string; domain: string; }) {
|
|
13
11
|
const cookies = await queryCookies(
|
|
@@ -58,33 +56,9 @@ export async function getChromeCookie(params: { name: string; domain: string; })
|
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
);
|
|
67
|
-
if (Array.isArray(cookies) && cookies.length > 0) {
|
|
68
|
-
const results = await queryCookies({ name, domain });
|
|
69
|
-
const groupedByFile = groupBy(results, (r) => r.meta?.file);
|
|
70
|
-
return Object.keys(groupedByFile).map((file) => {
|
|
71
|
-
const results = groupedByFile[file];
|
|
72
|
-
return resultsRendered(results);
|
|
73
|
-
});
|
|
74
|
-
} else {
|
|
75
|
-
throw new Error("Cookie not found");
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export async function getRenderedCookie(params: { name: string; domain: string; }) {
|
|
80
|
-
const cookies = await queryCookies(
|
|
81
|
-
params,
|
|
82
|
-
new CompositeCookieQueryStrategy()
|
|
83
|
-
//
|
|
84
|
-
);
|
|
85
|
-
if (Array.isArray(cookies) && cookies.length > 0) {
|
|
86
|
-
return cookies.find((cookie) => cookie != null);
|
|
87
|
-
} else {
|
|
88
|
-
throw new Error("Cookie not found");
|
|
89
|
-
}
|
|
59
|
+
export default {
|
|
60
|
+
getCookie,
|
|
61
|
+
getFirefoxCookie,
|
|
62
|
+
getChromeCookie,
|
|
63
|
+
getGroupedRenderedCookies,
|
|
90
64
|
}
|
package/src/queryCookies.ts
CHANGED
|
@@ -4,15 +4,13 @@ import CompositeCookieQueryStrategy from "./browsers/CompositeCookieQueryStrateg
|
|
|
4
4
|
import CookieQueryStrategy from "./browsers/CookieQueryStrategy";
|
|
5
5
|
import isValidJwt from "./isValidJwt";
|
|
6
6
|
import ExportedCookie from "./ExportedCookie";
|
|
7
|
+
import CookieRequest from "./CookieRequest";
|
|
7
8
|
|
|
8
9
|
export async function queryCookies(
|
|
9
10
|
{
|
|
10
11
|
name,
|
|
11
12
|
domain
|
|
12
|
-
}:
|
|
13
|
-
name: string;
|
|
14
|
-
domain: string;
|
|
15
|
-
},
|
|
13
|
+
}: CookieRequest,
|
|
16
14
|
strategy: CookieQueryStrategy = new CompositeCookieQueryStrategy()
|
|
17
15
|
) {
|
|
18
16
|
const results: ExportedCookie[] = await strategy.queryCookies(name, domain);
|
package/src/utils.ts
CHANGED
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
import {exec, ExecException} from "child_process";
|
|
4
4
|
|
|
5
5
|
export async function execSimple(command: string): Promise<string> {
|
|
6
|
-
if (process.env.VERBOSE) {
|
|
7
|
-
console.log(command);
|
|
8
|
-
}
|
|
9
6
|
return new Promise((resolve, reject) => {
|
|
10
7
|
exec(
|
|
11
8
|
command,
|
|
@@ -27,65 +24,6 @@ export async function execSimple(command: string): Promise<string> {
|
|
|
27
24
|
});
|
|
28
25
|
}
|
|
29
26
|
|
|
30
|
-
// export async function execAsBuffer(command: string) {
|
|
31
|
-
// if (process.env.VERBOSE) {
|
|
32
|
-
// console.log(command);
|
|
33
|
-
// }
|
|
34
|
-
// return await new Promise((resolve, reject) => {
|
|
35
|
-
// exec(
|
|
36
|
-
// command,
|
|
37
|
-
// { encoding: "binary", maxBuffer: 5 * 1024 },
|
|
38
|
-
// (error: ExecException | null, stdout: string, stderr: string) => {
|
|
39
|
-
// if (error) {
|
|
40
|
-
// reject(error);
|
|
41
|
-
// return;
|
|
42
|
-
// }
|
|
43
|
-
// if (stderr) {
|
|
44
|
-
// reject(error);
|
|
45
|
-
// return;
|
|
46
|
-
// }
|
|
47
|
-
// let stdoutAsBuffer: string = stdout;
|
|
48
|
-
// if (typeof stdoutAsBuffer === "string" && stdoutAsBuffer.length > 0) {
|
|
49
|
-
// // noinspection JSCheckFunctionSignatures
|
|
50
|
-
// stdoutAsBuffer = Buffer.from(stdoutAsBuffer, "binary").slice(0, -1);
|
|
51
|
-
// }
|
|
52
|
-
// if (stdoutAsBuffer && stdoutAsBuffer.length > 0) {
|
|
53
|
-
// resolve(stdoutAsBuffer);
|
|
54
|
-
// }
|
|
55
|
-
// }
|
|
56
|
-
// );
|
|
57
|
-
// });
|
|
58
|
-
// }
|
|
59
|
-
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
export function toStringValue(r: any): string {
|
|
62
|
-
if (process.env.VERBOSE) {
|
|
63
|
-
console.log("Printing value", r);
|
|
64
|
-
}
|
|
65
|
-
if (r) {
|
|
66
|
-
if (typeof r === "string") {
|
|
67
|
-
return r;
|
|
68
|
-
} else if (r.toString) {
|
|
69
|
-
// noinspection JSCheckFunctionSignatures
|
|
70
|
-
return r.toString("utf8");
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function printStringValue(r: any) {
|
|
76
|
-
if (process.env.VERBOSE) {
|
|
77
|
-
console.log("Printing value", r);
|
|
78
|
-
}
|
|
79
|
-
if (r) {
|
|
80
|
-
if (typeof r === "string") {
|
|
81
|
-
console.log(r);
|
|
82
|
-
} else if (r.toString) {
|
|
83
|
-
// noinspection JSCheckFunctionSignatures
|
|
84
|
-
console.log(r.toString("utf8"));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
27
|
/**
|
|
90
28
|
*
|
|
91
29
|
* @param result
|