@mherod/get-cookie 2.0.0-beta.7 → 2.0.0-beta.9
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.map +1 -1
- package/dist/index.js +561 -1
- package/dist/index.js.map +1 -1
- package/dist/module.js +29 -15
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +18 -33
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -3
- package/src/CookieRequest.ts +1 -2
- package/src/CookieRow.ts +5 -5
- package/src/ExportedCookie.ts +1 -1
- package/src/IsCookieRow.ts +1 -1
- package/src/IsExportedCookie.ts +1 -1
- package/src/browsers/ChromeCookieQueryStrategy.ts +2 -2
- package/src/browsers/CompositeCookieQueryStrategy.ts +1 -1
- package/src/browsers/CookieQueryStrategy.ts +1 -1
- package/src/browsers/FirefoxCookieQueryStrategy.ts +1 -1
- package/src/browsers/SafariCookieQueryStrategy.ts +1 -1
- package/src/cli.ts +1 -1
- package/src/doSqliteQuery1.ts +1 -1
- package/src/fetchWithCookies.ts +21 -7
- package/src/getGroupedRenderedCookies.ts +2 -2
- package/src/index.ts +12 -19
- package/src/queryCookies.ts +2 -2
- package/src/resultsRendered.ts +1 -1
- package/dist/main.js +0 -534
- package/dist/main.js.map +0 -1
|
@@ -5,7 +5,7 @@ import { toStringOrNull } from "../utils";
|
|
|
5
5
|
import { findAllFiles } from "../findAllFiles";
|
|
6
6
|
import * as path from "path";
|
|
7
7
|
import { doSqliteQuery1 } from "../doSqliteQuery1";
|
|
8
|
-
import ExportedCookie from "../ExportedCookie";
|
|
8
|
+
import { ExportedCookie } from "../ExportedCookie";
|
|
9
9
|
|
|
10
10
|
export default class FirefoxCookieQueryStrategy implements CookieQueryStrategy {
|
|
11
11
|
async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import CookieQueryStrategy from "./CookieQueryStrategy";
|
|
2
|
-
import ExportedCookie from "../ExportedCookie";
|
|
2
|
+
import { ExportedCookie } from "../ExportedCookie";
|
|
3
3
|
|
|
4
4
|
export default class SafariCookieQueryStrategy implements CookieQueryStrategy {
|
|
5
5
|
async queryCookies(name: string, domain: string): Promise<ExportedCookie[]> {
|
package/src/cli.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { queryCookies } from "./queryCookies";
|
|
|
5
5
|
import { argv } from "./argv";
|
|
6
6
|
import { groupBy } from "lodash";
|
|
7
7
|
import { blue, green } from "colorette";
|
|
8
|
-
import ExportedCookie from "./ExportedCookie";
|
|
9
8
|
import { resultsRendered } from "./resultsRendered";
|
|
9
|
+
import { ExportedCookie } from "./ExportedCookie";
|
|
10
10
|
|
|
11
11
|
function combinedString(results: ExportedCookie[]) {
|
|
12
12
|
return blue(resultsRendered(results));
|
package/src/doSqliteQuery1.ts
CHANGED
package/src/fetchWithCookies.ts
CHANGED
|
@@ -11,19 +11,33 @@ export async function fetchWithCookies(
|
|
|
11
11
|
url: RequestInfo | URL,
|
|
12
12
|
options: RequestInit | undefined = {}
|
|
13
13
|
): Promise<FetchResponse> {
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const defaultOptions: RequestInit = {
|
|
15
|
+
headers: {
|
|
16
|
+
"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"
|
|
17
|
+
},
|
|
18
|
+
redirect: "manual"
|
|
19
|
+
};
|
|
20
|
+
const url2: string = `${url}`;
|
|
21
|
+
const url1: URL = new URL(url2);
|
|
22
|
+
const domain = url1.hostname.replace(/^.*(\.\w+\.\w+)$/, (match, p1) => {
|
|
23
|
+
return `%${p1}`;
|
|
24
|
+
});
|
|
25
|
+
const cookies: string[] = await getGroupedRenderedCookies({
|
|
16
26
|
name: "%",
|
|
17
|
-
domain:
|
|
27
|
+
domain: domain
|
|
18
28
|
});
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
const cookie = cookies.pop();
|
|
30
|
+
const newOptions1: RequestInit = merge(defaultOptions, options, {
|
|
21
31
|
headers: {
|
|
22
|
-
Cookie: cookie
|
|
32
|
+
Cookie: cookie
|
|
23
33
|
}
|
|
24
34
|
});
|
|
25
35
|
try {
|
|
26
|
-
const res = await fetch(
|
|
36
|
+
const res = await fetch(url2, newOptions1);
|
|
37
|
+
const newUrl = res.headers.get("location") as string;
|
|
38
|
+
if (res.redirected || newUrl && newUrl !== url2) {
|
|
39
|
+
return fetchWithCookies(newUrl, newOptions1);
|
|
40
|
+
}
|
|
27
41
|
const arrayBuffer1 = res.arrayBuffer();
|
|
28
42
|
const arrayBuffer = async () => arrayBuffer1;
|
|
29
43
|
const buffer = async () => arrayBuffer().then(Buffer.from);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import ExportedCookie from "./ExportedCookie";
|
|
2
1
|
import { queryCookies } from "./queryCookies";
|
|
3
2
|
import CompositeCookieQueryStrategy from "./browsers/CompositeCookieQueryStrategy";
|
|
4
3
|
import { groupBy } from "lodash";
|
|
5
4
|
import { resultsRendered } from "./resultsRendered";
|
|
6
|
-
import CookieRequest from "./CookieRequest";
|
|
5
|
+
import { CookieRequest } from "./CookieRequest";
|
|
6
|
+
import { ExportedCookie } from "./ExportedCookie";
|
|
7
7
|
|
|
8
8
|
export async function getGroupedRenderedCookies(
|
|
9
9
|
//
|
package/src/index.ts
CHANGED
|
@@ -5,10 +5,12 @@ 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 { CookieRequest } from "./CookieRequest";
|
|
9
|
+
import { ExportedCookie } from "./ExportedCookie";
|
|
8
10
|
import { getGroupedRenderedCookies } from "./getGroupedRenderedCookies";
|
|
9
11
|
import { fetchWithCookies } from "./fetchWithCookies";
|
|
10
12
|
|
|
11
|
-
export async function getCookie(params:
|
|
13
|
+
export async function getCookie(params: CookieRequest): Promise<ExportedCookie | undefined> {
|
|
12
14
|
const cookies = await queryCookies(
|
|
13
15
|
params,
|
|
14
16
|
new CompositeCookieQueryStrategy()
|
|
@@ -21,12 +23,7 @@ export async function getCookie(params: { name: string; domain: string; }) {
|
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
* @param params
|
|
27
|
-
* @returns {Promise<*>}
|
|
28
|
-
*/
|
|
29
|
-
export async function getFirefoxCookie(params: { name: string; domain: string; }) {
|
|
26
|
+
export async function getFirefoxCookie(params: CookieRequest): Promise<ExportedCookie | undefined> {
|
|
30
27
|
const cookies = await queryCookies(
|
|
31
28
|
params,
|
|
32
29
|
new FirefoxCookieQueryStrategy()
|
|
@@ -39,12 +36,7 @@ export async function getFirefoxCookie(params: { name: string; domain: string; }
|
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
* @param params
|
|
45
|
-
* @returns {Promise<*>}
|
|
46
|
-
*/
|
|
47
|
-
export async function getChromeCookie(params: { name: string; domain: string; }) {
|
|
39
|
+
export async function getChromeCookie(params: CookieRequest): Promise<ExportedCookie | undefined> {
|
|
48
40
|
const cookies = await queryCookies(
|
|
49
41
|
params,
|
|
50
42
|
new ChromeCookieQueryStrategy()
|
|
@@ -57,10 +49,11 @@ export async function getChromeCookie(params: { name: string; domain: string; })
|
|
|
57
49
|
}
|
|
58
50
|
}
|
|
59
51
|
|
|
60
|
-
export
|
|
61
|
-
getCookie,
|
|
62
|
-
getFirefoxCookie,
|
|
63
|
-
getChromeCookie,
|
|
52
|
+
export {
|
|
64
53
|
getGroupedRenderedCookies,
|
|
65
|
-
fetchWithCookies
|
|
66
|
-
}
|
|
54
|
+
fetchWithCookies,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export * from "./CookieRequest";
|
|
58
|
+
export * from "./CookieRow";
|
|
59
|
+
export * from "./ExportedCookie";
|
package/src/queryCookies.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { uniqBy } from "lodash";
|
|
|
3
3
|
import CompositeCookieQueryStrategy from "./browsers/CompositeCookieQueryStrategy";
|
|
4
4
|
import CookieQueryStrategy from "./browsers/CookieQueryStrategy";
|
|
5
5
|
import isValidJwt from "./isValidJwt";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import { CookieRequest } from "./CookieRequest";
|
|
7
|
+
import { ExportedCookie } from "./ExportedCookie";
|
|
8
8
|
|
|
9
9
|
export async function queryCookies(
|
|
10
10
|
{
|
package/src/resultsRendered.ts
CHANGED