@mherod/get-cookie 2.0.0-rc.31 → 2.0.0-rc.32
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/index.js +1 -1
- package/dist/module.js +83 -51
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -6
- package/src/CookieStore.ts +1 -1
- package/src/FetchResponse.ts +1 -2
- package/src/FileCookieStore.ts +13 -10
- package/src/browsers/ChromeApplicationSupport.ts +1 -1
- package/src/browsers/ChromeCookieQueryStrategy.ts +4 -4
- package/src/browsers/CompositeCookieQueryStrategy.ts +28 -32
- package/src/browsers/CookieStoreQueryStrategy.ts +2 -2
- package/src/browsers/DoSqliteQueryWithTransform.ts +3 -3
- package/src/browsers/FirefoxCookieQueryStrategy.ts +3 -3
- package/src/browsers/decrypt.ts +4 -4
- package/src/browsers/getChromePassword.ts +1 -1
- package/src/cli.ts +3 -46
- package/src/cliQueryCookies.ts +62 -0
- package/src/comboQueryCookieSpec.ts +10 -13
- package/src/fetchWithCookies.ts +11 -13
- package/src/findAllFiles.ts +1 -1
- package/src/getChromeCookie.ts +2 -2
- package/src/getCookie.ts +2 -2
- package/src/getFirefoxCookie.ts +2 -2
- package/src/getGroupedRenderedCookies.ts +1 -1
- package/src/getMergedRenderedCookies.test.ts +25 -0
- package/src/getMergedRenderedCookies.ts +1 -1
- package/src/queryCookies.ts +5 -2
- package/src/util/flatMapAsync.ts +2 -2
- package/tsconfig.json +9 -2
package/src/findAllFiles.ts
CHANGED
package/src/getChromeCookie.ts
CHANGED
|
@@ -5,11 +5,11 @@ import ChromeCookieQueryStrategy from "./browsers/ChromeCookieQueryStrategy";
|
|
|
5
5
|
import { isExportedCookie } from "./ExportedCookie";
|
|
6
6
|
|
|
7
7
|
export async function getChromeCookie(
|
|
8
|
-
params: CookieSpec
|
|
8
|
+
params: CookieSpec,
|
|
9
9
|
): Promise<ExportedCookie | undefined> {
|
|
10
10
|
const cookies = await queryCookies(
|
|
11
11
|
params,
|
|
12
|
-
new ChromeCookieQueryStrategy()
|
|
12
|
+
new ChromeCookieQueryStrategy(),
|
|
13
13
|
//
|
|
14
14
|
);
|
|
15
15
|
if (cookies.length == 0) {
|
package/src/getCookie.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { queryCookies } from "./queryCookies";
|
|
|
4
4
|
import CompositeCookieQueryStrategy from "./browsers/CompositeCookieQueryStrategy";
|
|
5
5
|
|
|
6
6
|
export async function getCookie(
|
|
7
|
-
params: CookieSpec
|
|
7
|
+
params: CookieSpec,
|
|
8
8
|
): Promise<ExportedCookie | undefined> {
|
|
9
9
|
//
|
|
10
10
|
const cookies = await queryCookies(
|
|
11
11
|
params,
|
|
12
|
-
new CompositeCookieQueryStrategy()
|
|
12
|
+
new CompositeCookieQueryStrategy(),
|
|
13
13
|
//
|
|
14
14
|
);
|
|
15
15
|
if (Array.isArray(cookies) && cookies.length > 0) {
|
package/src/getFirefoxCookie.ts
CHANGED
|
@@ -4,11 +4,11 @@ import { queryCookies } from "./queryCookies";
|
|
|
4
4
|
import FirefoxCookieQueryStrategy from "./browsers/FirefoxCookieQueryStrategy";
|
|
5
5
|
|
|
6
6
|
export async function getFirefoxCookie(
|
|
7
|
-
params: CookieSpec
|
|
7
|
+
params: CookieSpec,
|
|
8
8
|
): Promise<ExportedCookie | undefined> {
|
|
9
9
|
const cookies: ExportedCookie[] = await queryCookies(
|
|
10
10
|
params,
|
|
11
|
-
new FirefoxCookieQueryStrategy()
|
|
11
|
+
new FirefoxCookieQueryStrategy(),
|
|
12
12
|
//
|
|
13
13
|
);
|
|
14
14
|
if (Array.isArray(cookies) && cookies.length > 0) {
|
|
@@ -5,7 +5,7 @@ import ExportedCookie from "./ExportedCookie";
|
|
|
5
5
|
import { comboQueryCookieSpec } from "./comboQueryCookieSpec";
|
|
6
6
|
|
|
7
7
|
export async function getGroupedRenderedCookies(
|
|
8
|
-
cookieSpec: MultiCookieSpec
|
|
8
|
+
cookieSpec: MultiCookieSpec,
|
|
9
9
|
): Promise<string[]> {
|
|
10
10
|
const cookies: ExportedCookie[] = await comboQueryCookieSpec(cookieSpec);
|
|
11
11
|
if (cookies.length == 0) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getMergedRenderedCookies } from "./getMergedRenderedCookies";
|
|
2
|
+
import { MultiCookieSpec } from "./CookieSpec";
|
|
3
|
+
|
|
4
|
+
describe("getMergedRenderedCookies", () => {
|
|
5
|
+
it("should return empty string if no cookies are present", async () => {
|
|
6
|
+
const cookieSpec: MultiCookieSpec = [];
|
|
7
|
+
const result = await getMergedRenderedCookies(cookieSpec);
|
|
8
|
+
expect(result).toBe("");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("should return rendered cookies if cookies are present", async () => {
|
|
12
|
+
const cookieSpec: MultiCookieSpec = [
|
|
13
|
+
{
|
|
14
|
+
name: "sessionCookie",
|
|
15
|
+
domain: "www.example.com",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "persistentCookie",
|
|
19
|
+
domain: "www.example.com",
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
const result = await getMergedRenderedCookies(cookieSpec);
|
|
23
|
+
expect(result).not.toBe("");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -5,7 +5,7 @@ import ExportedCookie from "./ExportedCookie";
|
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
|
|
7
7
|
export async function getMergedRenderedCookies(
|
|
8
|
-
cookieSpec: MultiCookieSpec
|
|
8
|
+
cookieSpec: MultiCookieSpec,
|
|
9
9
|
): Promise<string> {
|
|
10
10
|
const cookies: ExportedCookie[] = await comboQueryCookieSpec(cookieSpec);
|
|
11
11
|
return cookies.length > 0 ? resultsRendered(cookies) : "";
|
package/src/queryCookies.ts
CHANGED
|
@@ -10,9 +10,12 @@ export async function queryCookies(
|
|
|
10
10
|
{
|
|
11
11
|
name,
|
|
12
12
|
domain,
|
|
13
|
+
limit,
|
|
13
14
|
}: //
|
|
14
|
-
CookieSpec
|
|
15
|
-
|
|
15
|
+
CookieSpec & {
|
|
16
|
+
limit?: number;
|
|
17
|
+
},
|
|
18
|
+
strategy: CookieQueryStrategy = new CompositeCookieQueryStrategy(),
|
|
16
19
|
): Promise<ExportedCookie[]> {
|
|
17
20
|
//
|
|
18
21
|
const results: ExportedCookie[] = await strategy.queryCookies(name, domain);
|
package/src/util/flatMapAsync.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export async function flatMapAsync<T, O>(
|
|
5
5
|
array: T[], // The input array to transform.
|
|
6
6
|
callback: (value: T, index: number, array: T[]) => Promise<O[]>, // The async function to apply to each input array element.,
|
|
7
|
-
or?: O[] | ((error: any) => O[] | Promise<O[]>) // An optional callback to handle errors.
|
|
7
|
+
or?: O[] | ((error: any) => O[] | Promise<O[]>), // An optional callback to handle errors.
|
|
8
8
|
): Promise<O[]> {
|
|
9
9
|
if (or) {
|
|
10
10
|
return flatMapAsync(
|
|
@@ -15,7 +15,7 @@ export async function flatMapAsync<T, O>(
|
|
|
15
15
|
} catch (error) {
|
|
16
16
|
return typeof or == "function" ? or(error) : or;
|
|
17
17
|
}
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
19
|
//
|
|
20
20
|
);
|
|
21
21
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
"include": [
|
|
2
|
+
"include": [
|
|
3
|
+
"src/**.ts",
|
|
4
|
+
"src/**.tsx",
|
|
5
|
+
"src/**.js",
|
|
6
|
+
"src/**.jsx",
|
|
7
|
+
"src/**.test.ts",
|
|
8
|
+
"src/**.test.js"
|
|
9
|
+
],
|
|
3
10
|
"compilerOptions": {
|
|
4
11
|
"moduleResolution": "node",
|
|
5
12
|
"target": "es6",
|
|
6
|
-
"types": ["node"],
|
|
13
|
+
"types": ["node", "jest"],
|
|
7
14
|
"lib": ["es2015", "es2017", "es2021", "dom"],
|
|
8
15
|
"strict": true,
|
|
9
16
|
"skipDefaultLibCheck": true,
|