@mherod/get-cookie 2.0.0-rc.9 → 2.1.1
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/.parcelrc +12 -0
- package/.prettierignore +5 -0
- package/.prettierrc +12 -0
- package/.terserrc +26 -0
- package/README.md +2 -2
- package/build-indexes.ts +108 -0
- package/dist/cli.js +2 -0
- package/dist/index.js +1235 -621
- package/dist/index.js.map +1 -0
- package/dist/module.js +1446 -0
- package/dist/module.js.map +1 -0
- package/dist/prompt.2b8c61c0.js +40 -0
- package/dist/prompt.536a2c51.js +40 -0
- package/dist/prompt.fb2c7dad.js.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -0
- package/jest.config.ts +14 -0
- package/package-lock.json +3862 -8098
- package/package.json +46 -34
- package/src/CookieRow.ts +8 -0
- package/src/CookieSpec.ts +20 -0
- package/src/CookieStore.ts +24 -7
- package/src/ExportedCookie.ts +12 -0
- package/src/FetchResponse.ts +1 -3
- package/src/FileCookieStore.ts +178 -0
- package/src/StringToRegex.ts +10 -0
- package/src/argv.ts +27 -2
- package/src/browsers/CompositeCookieQueryStrategy.ts +36 -38
- package/src/browsers/CookieQueryStrategy.ts +1 -0
- package/src/browsers/CookieStoreQueryStrategy.ts +29 -22
- package/src/browsers/QuerySqliteThenTransform.ts +85 -0
- package/src/browsers/chrome/ChromeApplicationSupport.ts +10 -0
- package/src/browsers/chrome/ChromeCookieQueryStrategy.ts +131 -0
- package/src/browsers/chrome/decrypt.ts +118 -0
- package/src/browsers/chrome/getChromePassword.ts +11 -0
- package/src/browsers/{FirefoxCookieQueryStrategy.ts → firefox/FirefoxCookieQueryStrategy.ts} +19 -16
- package/src/browsers/getEncryptedChromeCookie.ts +87 -0
- package/src/browsers/index.ts +12 -0
- package/src/browsers/mock/MockCookieQueryStrategy.ts +18 -0
- package/src/browsers/{SafariCookieQueryStrategy.ts → safari/SafariCookieQueryStrategy.ts} +3 -2
- package/src/cli.ts +43 -67
- package/src/cliQueryCookies.ts +55 -0
- package/src/comboQueryCookieSpec.test.ts +92 -0
- package/src/comboQueryCookieSpec.ts +29 -0
- package/src/cookieQueryOptions.ts +20 -0
- package/src/cookieSpecsFromUrl.test.ts +65 -0
- package/src/cookieSpecsFromUrl.ts +27 -0
- package/src/execSimple.ts +13 -0
- package/src/fetchWithCookies.test.ts +32 -0
- package/src/fetchWithCookies.ts +123 -49
- package/src/findAllFiles.ts +25 -49
- package/src/getChromeCookie.ts +6 -4
- package/src/getCookie.ts +6 -3
- package/src/getFirefoxCookie.ts +6 -4
- package/src/getGroupedRenderedCookies.ts +7 -17
- package/src/getMergedRenderedCookies.test.ts +43 -0
- package/src/getMergedRenderedCookies.ts +13 -21
- package/src/global.ts +1 -1
- package/src/index.ts +0 -7
- package/src/isValidJwt.ts +2 -2
- package/src/listChromeProfiles.ts +45 -0
- package/src/logger.ts +13 -0
- package/src/processBeforeReturn.ts +26 -0
- package/src/queryCookies.ts +11 -3
- package/src/util/flatMapAsync.test.ts +55 -0
- package/src/util/flatMapAsync.ts +37 -0
- package/src/util/index.ts +1 -0
- package/tsconfig.json +14 -11
- package/.github/dependabot.yml +0 -6
- package/.prettierrc.json +0 -1
- package/src/IsCookieRow.ts +0 -9
- package/src/IsExportedCookie.ts +0 -9
- package/src/browsers/ChromeCookieQueryStrategy.ts +0 -343
- package/src/doSqliteQuery1.ts +0 -47
- package/src/doSqliteQuery1Params.ts +0 -7
- package/src/utils.ts +0 -25
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
|
2
|
+
<configuration default="false" name="build" type="js.build_tools.npm" nameIsGenerated="true">
|
|
3
|
+
<package-json value="$PROJECT_DIR$/package.json" />
|
|
4
|
+
<command value="run" />
|
|
5
|
+
<scripts>
|
|
6
|
+
<script value="build" />
|
|
7
|
+
</scripts>
|
|
8
|
+
<node-interpreter value="project" />
|
|
9
|
+
<envs />
|
|
10
|
+
<method v="2" />
|
|
11
|
+
</configuration>
|
|
12
|
+
</component>
|
package/.parcelrc
ADDED
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/.terserrc
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"toplevel": true,
|
|
3
|
+
"keep_fnames": true,
|
|
4
|
+
"keep_classnames": true,
|
|
5
|
+
"parse": {
|
|
6
|
+
"bare_returns": true,
|
|
7
|
+
"html5_comments": true,
|
|
8
|
+
"shebang": true,
|
|
9
|
+
},
|
|
10
|
+
"compress": {
|
|
11
|
+
"drop_console": false,
|
|
12
|
+
"toplevel": true,
|
|
13
|
+
"evaluate": true,
|
|
14
|
+
"passes": 3,
|
|
15
|
+
"keep_fnames": true,
|
|
16
|
+
"keep_classnames": true,
|
|
17
|
+
"hoist_funs": true,
|
|
18
|
+
},
|
|
19
|
+
"mangle": {
|
|
20
|
+
"toplevel": true,
|
|
21
|
+
},
|
|
22
|
+
"format": {
|
|
23
|
+
"comments": false,
|
|
24
|
+
"beautify": false,
|
|
25
|
+
}
|
|
26
|
+
}
|
package/README.md
CHANGED
|
@@ -28,6 +28,6 @@ The output of the command will be the value of the cookie.
|
|
|
28
28
|
The library can also be used as a module.
|
|
29
29
|
|
|
30
30
|
```javascript
|
|
31
|
-
const {getCookie} = require(
|
|
32
|
-
getCookie(
|
|
31
|
+
const { getCookie } = require("@mherod/get-cookie");
|
|
32
|
+
getCookie("auth", "www.example.com").then(console.log);
|
|
33
33
|
```
|
package/build-indexes.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
//#!/usr/bin/env bun run
|
|
2
|
+
|
|
3
|
+
import consola from "consola";
|
|
4
|
+
import { groupBy, orderBy } from "lodash";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
7
|
+
import { sync } from "fast-glob";
|
|
8
|
+
import prettier from "prettier";
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
// find all ts files in src and build indexes
|
|
12
|
+
|
|
13
|
+
const files = sync("src/**/*.ts", {
|
|
14
|
+
dot: true,
|
|
15
|
+
onlyFiles: true,
|
|
16
|
+
ignore: [
|
|
17
|
+
"**/index.ts",
|
|
18
|
+
"**/*.d.ts",
|
|
19
|
+
"**/*.test.{ts,tsx}",
|
|
20
|
+
"**/*.spec.{ts,tsx}",
|
|
21
|
+
"**/*.stories.tsx",
|
|
22
|
+
],
|
|
23
|
+
//
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// group files by directory
|
|
27
|
+
const groups = groupBy(files, (file: string) => {
|
|
28
|
+
const parts = file.split("/");
|
|
29
|
+
parts.pop();
|
|
30
|
+
return parts.join("/");
|
|
31
|
+
});
|
|
32
|
+
// order by depth, so that we build indexes for subdirectories first
|
|
33
|
+
const dirs = orderBy(
|
|
34
|
+
Object.keys(groups),
|
|
35
|
+
(dir) => dir.split("/").length,
|
|
36
|
+
//
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// build index for each directory
|
|
40
|
+
for (const dir of dirs) {
|
|
41
|
+
consola.info(`building index for ${dir}`);
|
|
42
|
+
const files = groups[dir].filter((file: string) => file.match(/\.ts$/));
|
|
43
|
+
const indexes = files
|
|
44
|
+
.map((file: string) => {
|
|
45
|
+
const content = readFileSync(file, "utf-8").split("\n");
|
|
46
|
+
if (!content.some((line) => line.trim().startsWith("export"))) {
|
|
47
|
+
// if none of the lines in the file start with an export, then we should not include it in the index
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
const name = path
|
|
51
|
+
.relative(dir, file) //
|
|
52
|
+
.replace(/\.ts$/, ""); //
|
|
53
|
+
return `export * from './${name}';`;
|
|
54
|
+
})
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.sort() as string[];
|
|
57
|
+
|
|
58
|
+
// then find subdirectories and build index for them
|
|
59
|
+
|
|
60
|
+
const subIndex = sync(`${dir}/*/index.ts`, {
|
|
61
|
+
dot: true,
|
|
62
|
+
onlyFiles: true,
|
|
63
|
+
//
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (subIndex.length > 0) {
|
|
67
|
+
indexes.push(
|
|
68
|
+
...subIndex.map((file: string) => {
|
|
69
|
+
const name = path
|
|
70
|
+
.relative(dir, file) //
|
|
71
|
+
.replace(/\/index\.ts$/, ""); //
|
|
72
|
+
return `export * from './${name}';`;
|
|
73
|
+
}),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const index = indexes.join("\n");
|
|
78
|
+
|
|
79
|
+
// const indexFile = `${dir}/index.ts`
|
|
80
|
+
const indexFile = path.join(dir, "index.ts");
|
|
81
|
+
|
|
82
|
+
const output = await prettier.format(index, { parser: "babel" });
|
|
83
|
+
|
|
84
|
+
if (existsSync(indexFile)) {
|
|
85
|
+
const existingContent = readFileSync(indexFile, "utf8");
|
|
86
|
+
if (existingContent === output) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const lines = existingContent.split("\n");
|
|
90
|
+
if (lines.every((line) => line.startsWith("export * from")) == false) {
|
|
91
|
+
// if the existing index file is not an export index, then we should not overwrite it
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (output.length > 0) {
|
|
97
|
+
console.log(`writing ${dir}/index.ts`, output.length);
|
|
98
|
+
|
|
99
|
+
writeFileSync(
|
|
100
|
+
indexFile,
|
|
101
|
+
output,
|
|
102
|
+
//
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
main().catch(consola.error);
|