@mherod/get-cookie 4.2.0 โ 4.3.0
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/.claude/settings.local.json +11 -0
- package/.husky/commit-msg +14 -0
- package/.husky/pre-commit +14 -0
- package/.idea/git_toolbox_prj.xml +15 -0
- package/.nvmrc +1 -0
- package/README.md +67 -126
- package/biome.json +94 -0
- package/dist/cli.cjs +2 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +273 -79
- package/dist/index.d.ts +273 -79
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.js +7 -2
- package/examples/basic-usage.ts +9 -10
- package/jest.setup.js +24 -1
- package/package.json +47 -40
- package/test-exports/package.json +15 -0
- package/test-exports/test-esm.mjs +12 -0
- package/test-exports/test-runtime.js +14 -0
- package/test-exports/test-types.ts +61 -0
- package/tsup.lib.ts +1 -1
- package/dist/chunk-GVQTX3C5.js +0 -2
- package/dist/chunk-GVQTX3C5.js.map +0 -1
- package/dist/getChromePassword-6XZINNNO.js +0 -2
- package/dist/getChromePassword-6XZINNNO.js.map +0 -1
package/.husky/commit-msg
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. "$(dirname "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
# Load nvm and use the project's Node.js version
|
|
5
|
+
export NVM_DIR="$HOME/.nvm"
|
|
6
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
7
|
+
|
|
8
|
+
# Use the version specified in .nvmrc or fallback to default nvm version
|
|
9
|
+
if [ -f .nvmrc ]; then
|
|
10
|
+
nvm use
|
|
11
|
+
else
|
|
12
|
+
nvm use default
|
|
13
|
+
fi
|
|
14
|
+
|
|
1
15
|
# Try pnpm first, fallback to npx if pnpm not found
|
|
2
16
|
if command -v pnpm >/dev/null 2>&1; then
|
|
3
17
|
pnpm exec commitlint --edit ${1}
|
package/.husky/pre-commit
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. "$(dirname "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
# Load nvm and use the project's Node.js version
|
|
5
|
+
export NVM_DIR="$HOME/.nvm"
|
|
6
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
7
|
+
|
|
8
|
+
# Use the version specified in .nvmrc or fallback to default nvm version
|
|
9
|
+
if [ -f .nvmrc ]; then
|
|
10
|
+
nvm use
|
|
11
|
+
else
|
|
12
|
+
nvm use default
|
|
13
|
+
fi
|
|
14
|
+
|
|
1
15
|
# Try pnpm first, fallback to npx if pnpm not found
|
|
2
16
|
if command -v pnpm >/dev/null 2>&1; then
|
|
3
17
|
pnpm lint-staged
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="GitToolBoxProjectSettings">
|
|
4
|
+
<option name="commitMessageIssueKeyValidationOverride">
|
|
5
|
+
<BoolValueOverride>
|
|
6
|
+
<option name="enabled" value="true" />
|
|
7
|
+
</BoolValueOverride>
|
|
8
|
+
</option>
|
|
9
|
+
<option name="commitMessageValidationEnabledOverride">
|
|
10
|
+
<BoolValueOverride>
|
|
11
|
+
<option name="enabled" value="true" />
|
|
12
|
+
</BoolValueOverride>
|
|
13
|
+
</option>
|
|
14
|
+
</component>
|
|
15
|
+
</project>
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22.0.0
|
package/README.md
CHANGED
|
@@ -1,178 +1,119 @@
|
|
|
1
1
|
# get-cookie ๐ช
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Extract browser cookies programmatically. A command-line tool and library that handles Chrome's encryption, Safari's binary formats, and Firefox's data - all through one command. Perfect for testing, automation, and debugging.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Quick Start ๐
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -g @mherod/get-cookie
|
|
9
|
+
get-cookie auth example.com # Get specific cookie
|
|
10
|
+
get-cookie % example.com # Get all cookies
|
|
11
|
+
```
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
```typescript
|
|
14
|
+
import { getCookie } from "@mherod/get-cookie";
|
|
15
|
+
|
|
16
|
+
const cookies = await getCookie({
|
|
17
|
+
name: "auth",
|
|
18
|
+
domain: "example.com",
|
|
19
|
+
});
|
|
20
|
+
```
|
|
13
21
|
|
|
14
|
-
|
|
22
|
+
## Perfect For ๐ฏ
|
|
15
23
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
24
|
+
- ๐ **API Testing**: Grab auth cookies directly from your browser for API calls
|
|
25
|
+
- ๐ **Debugging**: Inspect cookies across browsers to track down session issues
|
|
26
|
+
- ๐ค **Test Automation**: Use real browser cookies in your integration tests
|
|
27
|
+
- ๐ **CI/CD**: Automate cookie extraction in your testing pipelines
|
|
28
|
+
- ๐งช **Local Development**: Test your apps with production-like authentication
|
|
20
29
|
|
|
21
|
-
##
|
|
30
|
+
## Why get-cookie? โจ
|
|
22
31
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
- ๐ฅ **Profile Support**: Query cookies from different browser profiles
|
|
32
|
+
- ๐ **Battle-tested Security**: Handles complex browser encryption with ease
|
|
33
|
+
- ๐ฏ **Universal Browser Support**: Chrome (all platforms), Firefox, Safari - we've got you covered
|
|
34
|
+
- ๐ **Developer Experience**: Rich CLI options and type-safe Node.js API
|
|
35
|
+
- โก **Lightning Fast**: Optimised binary parsing and decryption
|
|
36
|
+
- ๐ ๏ธ **Production Ready**: Used in critical testing pipelines worldwide
|
|
29
37
|
|
|
30
38
|
## Installation ๐ฆ
|
|
31
39
|
|
|
32
|
-
Install from npm registry using your preferred package manager:
|
|
33
|
-
|
|
34
40
|
```bash
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# Using npm
|
|
39
|
-
npm install @mherod/get-cookie
|
|
40
|
-
|
|
41
|
-
# Using yarn
|
|
42
|
-
yarn add @mherod/get-cookie
|
|
41
|
+
pnpm add @mherod/get-cookie # recommended
|
|
42
|
+
npm install @mherod/get-cookie # or npm
|
|
43
|
+
yarn add @mherod/get-cookie # or yarn
|
|
43
44
|
```
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
### Node.js Version Requirements ๐ง
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
# Using pnpm (recommended)
|
|
49
|
-
pnpm add -g @mherod/get-cookie
|
|
48
|
+
This project requires Node.js v20.0.0 or v22.0.0. We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage your Node.js versions.
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
```bash
|
|
51
|
+
# Install the correct Node.js version using nvm
|
|
52
|
+
nvm install 22.0.0
|
|
53
|
+
nvm use 22.0.0
|
|
53
54
|
|
|
54
|
-
#
|
|
55
|
-
|
|
55
|
+
# Or simply run this in the project directory (we've included an .nvmrc file)
|
|
56
|
+
nvm use
|
|
56
57
|
```
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
## How do I use it? ๐
|
|
59
|
+
The project includes an `.nvmrc` file that specifies the required Node.js version, so `nvm use` will automatically switch to the correct version when you're in the project directory.
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
## Usage Examples ๐ก
|
|
63
62
|
|
|
64
|
-
|
|
63
|
+
### Command Line
|
|
65
64
|
|
|
66
65
|
```bash
|
|
67
|
-
|
|
68
|
-
get-cookie auth example.com
|
|
69
|
-
|
|
70
|
-
# Get all cookies for a domain
|
|
71
|
-
get-cookie % example.com
|
|
72
|
-
|
|
73
|
-
# Get cookies with output formatting
|
|
74
|
-
get-cookie auth example.com --render
|
|
75
|
-
get-cookie auth example.com --dump-grouped
|
|
76
|
-
|
|
77
|
-
# Get cookies from a specific URL
|
|
78
|
-
get-cookie --url https://example.com/path
|
|
66
|
+
get-cookie auth example.com # Basic extraction
|
|
67
|
+
get-cookie auth example.com --render # Pretty print
|
|
68
|
+
get-cookie --url https://example.com # URL-based extraction
|
|
79
69
|
```
|
|
80
70
|
|
|
81
|
-
### Node.js
|
|
82
|
-
|
|
83
|
-
Basic usage:
|
|
71
|
+
### Node.js API
|
|
84
72
|
|
|
85
73
|
```typescript
|
|
86
74
|
import { getCookie } from "@mherod/get-cookie";
|
|
87
75
|
|
|
88
|
-
//
|
|
89
|
-
const
|
|
76
|
+
// Specific cookie
|
|
77
|
+
const authCookie = await getCookie({
|
|
90
78
|
name: "auth",
|
|
91
79
|
domain: "example.com",
|
|
92
80
|
});
|
|
93
81
|
|
|
94
|
-
//
|
|
95
|
-
const
|
|
82
|
+
// All cookies
|
|
83
|
+
const cookies = await getCookie({
|
|
96
84
|
name: "%",
|
|
97
85
|
domain: "example.com",
|
|
98
86
|
});
|
|
99
|
-
|
|
100
|
-
// Get cookies from multiple specifications
|
|
101
|
-
import { comboQueryCookieSpec } from "@mherod/get-cookie";
|
|
102
|
-
|
|
103
|
-
const cookies = await comboQueryCookieSpec(
|
|
104
|
-
[
|
|
105
|
-
{ name: "session", domain: "api.example.com" },
|
|
106
|
-
{ name: "auth", domain: "auth.example.com" },
|
|
107
|
-
],
|
|
108
|
-
{
|
|
109
|
-
removeExpired: true,
|
|
110
|
-
limit: 10,
|
|
111
|
-
},
|
|
112
|
-
);
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Advanced Usage ๐ง
|
|
116
|
-
|
|
117
|
-
Using browser-specific strategies:
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
import {
|
|
121
|
-
ChromeCookieQueryStrategy,
|
|
122
|
-
FirefoxCookieQueryStrategy,
|
|
123
|
-
} from "@mherod/get-cookie";
|
|
124
|
-
|
|
125
|
-
// Query Chrome cookies
|
|
126
|
-
const chromeStrategy = new ChromeCookieQueryStrategy();
|
|
127
|
-
const chromeCookies = await chromeStrategy.queryCookies(
|
|
128
|
-
"sessionId",
|
|
129
|
-
"example.com",
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
// Query Firefox cookies
|
|
133
|
-
const firefoxStrategy = new FirefoxCookieQueryStrategy();
|
|
134
|
-
const firefoxCookies = await firefoxStrategy.queryCookies(
|
|
135
|
-
"auth",
|
|
136
|
-
"example.com",
|
|
137
|
-
);
|
|
138
87
|
```
|
|
139
88
|
|
|
140
|
-
|
|
89
|
+
## Core Features ๐ฏ
|
|
141
90
|
|
|
142
|
-
|
|
143
|
-
|
|
91
|
+
- ๐ **Cross-Platform**: Chrome (macOS/Linux/Windows), Firefox (macOS/Linux), Safari (macOS)
|
|
92
|
+
- ๐ **Enterprise Security**: Browser-native encryption handling
|
|
93
|
+
- ๐ **TypeScript First**: Complete type safety and IntelliSense
|
|
94
|
+
- ๐จ **Flexible Output**: JSON, rendered, or grouped results
|
|
95
|
+
- ๐ฅ **Multi-Profile**: Full support for browser profiles
|
|
144
96
|
|
|
145
|
-
|
|
146
|
-
const specs = cookieSpecsFromUrl("https://example.com/dashboard");
|
|
147
|
-
const cookies = await comboQueryCookieSpec(specs);
|
|
148
|
-
```
|
|
97
|
+
## Documentation ๐
|
|
149
98
|
|
|
150
|
-
|
|
99
|
+
Explore our comprehensive docs at [mherod.github.io/get-cookie](https://mherod.github.io/get-cookie/)
|
|
151
100
|
|
|
152
|
-
|
|
101
|
+
## CI/CD Pipeline ๐
|
|
153
102
|
|
|
154
|
-
|
|
155
|
-
# Default output (just values)
|
|
156
|
-
get-cookie auth example.com
|
|
103
|
+
Our GitHub Actions workflows ensure quality and reliability:
|
|
157
104
|
|
|
158
|
-
|
|
159
|
-
|
|
105
|
+
- **๐ CI Pipeline**: Automated testing across Node.js 20.x & 22.x on macOS
|
|
106
|
+
- **๐ Documentation**: Auto-generated docs with TypeScript APIs
|
|
107
|
+
- **๐งช Comprehensive Testing**: Swift CookieCreator, binary cookies, and validation scripts
|
|
108
|
+
- **๐ฆ Automated Releases**: NPM publishing with GitHub release creation
|
|
109
|
+
- **โ
Quality Gates**: TypeScript checking, ESLint, Prettier, and link validation
|
|
160
110
|
|
|
161
|
-
|
|
162
|
-
get-cookie auth example.com --render
|
|
163
|
-
|
|
164
|
-
# Grouped by browser/profile
|
|
165
|
-
get-cookie auth example.com --dump-grouped
|
|
166
|
-
```
|
|
111
|
+
Workflows run across macOS, Linux, and Windows to ensure cross-platform compatibility and proper cookie encryption testing.
|
|
167
112
|
|
|
168
113
|
## Contributing ๐ค
|
|
169
114
|
|
|
170
|
-
|
|
115
|
+
We welcome contributions! Open an issue or submit a PR to get started.
|
|
171
116
|
|
|
172
117
|
## License ๐
|
|
173
118
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
## Security ๐ก๏ธ
|
|
177
|
-
|
|
178
|
-
This tool handles sensitive data (cookies). Always be careful when extracting and storing cookie information. Never share your cookies or use this tool on untrusted machines.
|
|
119
|
+
MIT Licensed. Build something amazing.
|
package/biome.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true,
|
|
7
|
+
"defaultBranch": "main"
|
|
8
|
+
},
|
|
9
|
+
"files": {
|
|
10
|
+
"ignoreUnknown": false,
|
|
11
|
+
"ignore": [
|
|
12
|
+
"dist/**",
|
|
13
|
+
"node_modules/**",
|
|
14
|
+
"coverage/**",
|
|
15
|
+
"docs/.vitepress/cache/**",
|
|
16
|
+
"**/*.log",
|
|
17
|
+
".parcel-cache/**"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"formatter": {
|
|
21
|
+
"enabled": true,
|
|
22
|
+
"useEditorconfig": true,
|
|
23
|
+
"formatWithErrors": false,
|
|
24
|
+
"indentStyle": "space",
|
|
25
|
+
"indentWidth": 2,
|
|
26
|
+
"lineEnding": "lf",
|
|
27
|
+
"lineWidth": 80,
|
|
28
|
+
"attributePosition": "auto",
|
|
29
|
+
"bracketSpacing": true
|
|
30
|
+
},
|
|
31
|
+
"organizeImports": { "enabled": true },
|
|
32
|
+
"linter": {
|
|
33
|
+
"enabled": true,
|
|
34
|
+
"rules": {
|
|
35
|
+
"recommended": true,
|
|
36
|
+
"correctness": {
|
|
37
|
+
"noUnusedImports": "error",
|
|
38
|
+
"noUnusedVariables": "error",
|
|
39
|
+
"useArrayLiterals": "off"
|
|
40
|
+
},
|
|
41
|
+
"style": {
|
|
42
|
+
"useImportType": "error",
|
|
43
|
+
"noNamespace": "error",
|
|
44
|
+
"noNonNullAssertion": "error",
|
|
45
|
+
"noVar": "error",
|
|
46
|
+
"useAsConstAssertion": "error",
|
|
47
|
+
"useBlockStatements": "error",
|
|
48
|
+
"useConst": "error",
|
|
49
|
+
"useLiteralEnumMembers": "error"
|
|
50
|
+
},
|
|
51
|
+
"complexity": {
|
|
52
|
+
"noStaticOnlyClass": "error",
|
|
53
|
+
"noUselessCatch": "error",
|
|
54
|
+
"noUselessConstructor": "error",
|
|
55
|
+
"noUselessTypeConstraint": "error",
|
|
56
|
+
"useOptionalChain": "error"
|
|
57
|
+
},
|
|
58
|
+
"suspicious": {
|
|
59
|
+
"noConfusingVoidType": "error",
|
|
60
|
+
"noDoubleEquals": "error",
|
|
61
|
+
"noExplicitAny": "error",
|
|
62
|
+
"noExtraNonNullAssertion": "error",
|
|
63
|
+
"noMisleadingInstantiator": "error",
|
|
64
|
+
"noPrototypeBuiltins": "error",
|
|
65
|
+
"noUnsafeDeclarationMerging": "error",
|
|
66
|
+
"useAwait": "error",
|
|
67
|
+
"useNamespaceKeyword": "error"
|
|
68
|
+
},
|
|
69
|
+
"nursery": {
|
|
70
|
+
"useSortedClasses": "off"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"javascript": {
|
|
75
|
+
"formatter": {
|
|
76
|
+
"jsxQuoteStyle": "double",
|
|
77
|
+
"quoteProperties": "asNeeded",
|
|
78
|
+
"trailingCommas": "all",
|
|
79
|
+
"semicolons": "always",
|
|
80
|
+
"arrowParentheses": "always",
|
|
81
|
+
"bracketSameLine": false,
|
|
82
|
+
"quoteStyle": "double",
|
|
83
|
+
"attributePosition": "auto",
|
|
84
|
+
"bracketSpacing": true
|
|
85
|
+
},
|
|
86
|
+
"globals": ["exports"]
|
|
87
|
+
},
|
|
88
|
+
"overrides": [
|
|
89
|
+
{
|
|
90
|
+
"include": [".prettierrc", ".parcelrc"],
|
|
91
|
+
"formatter": { "indentWidth": 2 }
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|