@mherod/get-cookie 4.1.0 โ†’ 4.2.2

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.
Files changed (51) hide show
  1. package/.env.example +5 -0
  2. package/.husky/commit-msg +6 -2
  3. package/.husky/pre-commit +6 -4
  4. package/.husky/pre-push +6 -4
  5. package/README.md +76 -117
  6. package/dist/cli.cjs +1 -3
  7. package/dist/cli.cjs.map +1 -1
  8. package/dist/index.cjs +1 -3
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +220 -41
  11. package/dist/index.d.ts +220 -41
  12. package/dist/index.js +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/tsconfig.tsbuildinfo +1 -0
  15. package/eslint.config.js +8 -18
  16. package/examples/README.md +37 -0
  17. package/examples/advanced-usage.ts +56 -0
  18. package/examples/basic-usage.ts +43 -0
  19. package/examples/cli-examples.sh +51 -0
  20. package/package.json +13 -4
  21. package/tsconfig.build.json +2 -2
  22. package/tsconfig.cli.json +12 -0
  23. package/tsconfig.tsup.json +12 -0
  24. package/tsup.cli.ts +1 -0
  25. package/tsup.lib.ts +1 -0
  26. package/dist/chunk-3FVH4L25.js +0 -2
  27. package/dist/chunk-3FVH4L25.js.map +0 -1
  28. package/dist/chunk-56Z35D5R.js +0 -2
  29. package/dist/chunk-56Z35D5R.js.map +0 -1
  30. package/dist/chunk-7XZ7PCDJ.js +0 -2
  31. package/dist/chunk-7XZ7PCDJ.js.map +0 -1
  32. package/dist/chunk-DVWQBWUF.js +0 -4
  33. package/dist/chunk-DVWQBWUF.js.map +0 -1
  34. package/dist/chunk-I6AYGFSQ.js +0 -2
  35. package/dist/chunk-I6AYGFSQ.js.map +0 -1
  36. package/dist/chunk-U27I5BLR.js +0 -2
  37. package/dist/chunk-U27I5BLR.js.map +0 -1
  38. package/dist/chunk-YOZOS2YM.js +0 -2
  39. package/dist/chunk-YOZOS2YM.js.map +0 -1
  40. package/dist/getChromeCookie-2ROVM47V.js +0 -2
  41. package/dist/getChromeCookie-2ROVM47V.js.map +0 -1
  42. package/dist/getChromePassword-O452VQWI.js +0 -2
  43. package/dist/getChromePassword-O452VQWI.js.map +0 -1
  44. package/dist/getCookie-CRE6M3GI.js +0 -2
  45. package/dist/getCookie-CRE6M3GI.js.map +0 -1
  46. package/dist/getFirefoxCookie-5P74VDC7.js +0 -2
  47. package/dist/getFirefoxCookie-5P74VDC7.js.map +0 -1
  48. package/dist/getGroupedRenderedCookies-DFEJTTC6.js +0 -2
  49. package/dist/getGroupedRenderedCookies-DFEJTTC6.js.map +0 -1
  50. package/dist/getMergedRenderedCookies-W5GSSHQQ.js +0 -2
  51. package/dist/getMergedRenderedCookies-W5GSSHQQ.js.map +0 -1
package/.env.example ADDED
@@ -0,0 +1,5 @@
1
+ # Logging
2
+ LOG_LEVEL=info # Set to 'debug' for verbose logging
3
+
4
+ # System Paths
5
+ # HOME=/path/to/home # Uncomment to override system HOME directory
package/.husky/commit-msg CHANGED
@@ -1,2 +1,6 @@
1
- #!/bin/sh
2
- npx --no -- commitlint --edit ${1}
1
+ # Try pnpm first, fallback to npx if pnpm not found
2
+ if command -v pnpm >/dev/null 2>&1; then
3
+ pnpm exec commitlint --edit ${1}
4
+ else
5
+ npx --no -- commitlint --edit ${1}
6
+ fi
package/.husky/pre-commit CHANGED
@@ -1,4 +1,6 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- pnpm lint-staged
1
+ # Try pnpm first, fallback to npx if pnpm not found
2
+ if command -v pnpm >/dev/null 2>&1; then
3
+ pnpm lint-staged
4
+ else
5
+ npx --no -- lint-staged
6
+ fi
package/.husky/pre-push CHANGED
@@ -1,4 +1,6 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- pnpm run type-check && pnpm run test
1
+ # Try pnpm first, fallback to npx if pnpm not found
2
+ if command -v pnpm >/dev/null 2>&1; then
3
+ pnpm run validate
4
+ else
5
+ npm run validate
6
+ fi
package/README.md CHANGED
@@ -1,151 +1,101 @@
1
1
  # get-cookie ๐Ÿช
2
2
 
3
- ## What is it? ๐Ÿค”
3
+ Tired of manually copying cookies for API testing? `get-cookie` extracts authentication cookies directly from Chrome, Firefox, and Safari - perfect for testing, debugging, and automation.
4
4
 
5
- get-cookie is a powerful command-line utility and Node.js module that allows you to securely retrieve browser cookies from your locally installed browsers. Perfect for:
5
+ ## Quick Start ๐Ÿš€
6
6
 
7
- - ๐Ÿ” Testing authenticated web applications
8
- - ๐Ÿ” Debugging cookie-related issues
9
- - ๐Ÿค– Automating browser cookie extraction
10
- - ๐Ÿงช Integration testing with real browser cookies
11
-
12
- ## Documentation ๐Ÿ“š
13
-
14
- Visit our [comprehensive documentation](https://mherod.github.io/get-cookie/) for:
15
-
16
- - Detailed API reference
17
- - Getting started guides
18
- - Advanced usage examples
19
- - TypeScript type definitions
20
-
21
- ## Features โœจ
22
-
23
- - ๐ŸŒ **Multi-Browser Support**: Works with Chrome, Firefox, and Safari
24
- - ๐Ÿ”’ **Secure**: Safe cookie extraction with proper encryption handling
25
- - ๐Ÿ“ **TypeScript Ready**: Built with TypeScript for excellent type safety
26
- - ๐ŸŽฏ **Flexible Querying**: Search by name, domain, or URL pattern
27
- - ๐Ÿ”„ **Multiple Output Formats**: JSON, rendered, or grouped results
28
- - ๐Ÿ‘ฅ **Profile Support**: Query cookies from different browser profiles
29
-
30
- ## Installation ๐Ÿ“ฆ
7
+ ```bash
8
+ # Install globally
9
+ pnpm add -g @mherod/get-cookie
31
10
 
32
- Install from npm registry using your preferred package manager:
11
+ # Get a cookie
12
+ get-cookie auth example.com
33
13
 
34
- ```bash
35
- # Using pnpm (recommended)
36
- pnpm add @mherod/get-cookie
14
+ # Get all cookies for a domain
15
+ get-cookie % example.com
16
+ ```
37
17
 
38
- # Using npm
39
- npm install @mherod/get-cookie
18
+ ```typescript
19
+ // Node.js usage
20
+ import { getCookie } from "@mherod/get-cookie";
40
21
 
41
- # Using yarn
42
- yarn add @mherod/get-cookie
22
+ const cookies = await getCookie({
23
+ name: "auth",
24
+ domain: "example.com",
25
+ });
43
26
  ```
44
27
 
45
- For global installation:
28
+ โš ๏ธ **Platform Support**:
46
29
 
47
- ```bash
48
- # Using pnpm (recommended)
49
- pnpm add -g @mherod/get-cookie
30
+ - Chrome: macOS only
31
+ - Firefox: macOS and Linux
32
+ - Safari: macOS only
50
33
 
51
- # Using npm
52
- npm install -g @mherod/get-cookie
34
+ ## Installation ๐Ÿ“ฆ
53
35
 
54
- # Using yarn
55
- yarn global add @mherod/get-cookie
36
+ ```bash
37
+ pnpm add @mherod/get-cookie # recommended
38
+ npm install @mherod/get-cookie # or npm
39
+ yarn add @mherod/get-cookie # or yarn
56
40
  ```
57
41
 
58
- **Note: Currently only macOS is supported. Windows support is planned for a future release.** ๐Ÿšง
42
+ ## Common Use Cases ๐ŸŽฏ
59
43
 
60
- ## How do I use it? ๐Ÿš€
44
+ - ๐Ÿ” Get auth cookies for API testing
45
+ - ๐Ÿ” Debug cookie issues across browsers
46
+ - ๐Ÿค– Automate cookie extraction
47
+ - ๐Ÿงช Use real cookies in integration tests
61
48
 
62
- ### CLI Usage ๐Ÿ’ป
49
+ ## Basic Usage Examples ๐Ÿ’ก
63
50
 
64
- Basic cookie retrieval:
51
+ ### CLI
65
52
 
66
53
  ```bash
67
- # Get a specific cookie
54
+ # Get specific cookie
68
55
  get-cookie auth example.com
69
56
 
70
- # Get all cookies for a domain
71
- get-cookie % example.com
72
-
73
- # Get cookies with output formatting
57
+ # Pretty print
74
58
  get-cookie auth example.com --render
75
- get-cookie auth example.com --dump-grouped
76
59
 
77
- # Get cookies from a specific URL
60
+ # From URL
78
61
  get-cookie --url https://example.com/path
79
62
  ```
80
63
 
81
- ### Node.js Module Usage ๐Ÿ“š
82
-
83
- Basic usage:
84
-
85
- ```typescript
86
- import { getCookie } from "@mherod/get-cookie";
87
-
88
- // Get a specific cookie
89
- const authCookies = await getCookie({
90
- name: "auth",
91
- domain: "example.com",
92
- });
93
-
94
- // Get all cookies for a domain
95
- const allCookies = await getCookie({
96
- name: "%",
97
- domain: "example.com",
98
- });
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:
64
+ ### Node.js
118
65
 
119
66
  ```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
- );
67
+ import { getCookie, type CookieSpec } from "@mherod/get-cookie";
68
+
69
+ try {
70
+ // Get specific cookie
71
+ const authCookie = await getCookie({
72
+ name: "auth",
73
+ domain: "example.com",
74
+ });
75
+
76
+ // Get multiple cookies
77
+ const cookies = await getCookie({
78
+ name: "%", // all cookies
79
+ domain: "example.com",
80
+ });
81
+ } catch (error) {
82
+ console.error("Failed:", error);
83
+ }
138
84
  ```
139
85
 
140
- Using URL-based cookie extraction:
86
+ ## Features โœจ
141
87
 
142
- ```typescript
143
- import { cookieSpecsFromUrl } from "@mherod/get-cookie";
88
+ - ๐ŸŒ **Multi-Browser Support**:
89
+ - Chrome (macOS)
90
+ - Firefox (macOS, Linux)
91
+ - Safari (macOS)
92
+ - ๐Ÿ”’ **Secure**: Browser-specific encryption handling
93
+ - ๐Ÿ“ **TypeScript Ready**: Full type safety with exported type definitions
94
+ - ๐ŸŽฏ **Flexible Querying**: Search by name, domain, or use wildcards
95
+ - ๐Ÿ”„ **Multiple Output Formats**: JSON, rendered, or grouped results
96
+ - ๐Ÿ‘ฅ **Profile Support**: Chrome and Firefox multi-profile support
144
97
 
145
- // Get all cookies needed for a specific URL
146
- const specs = cookieSpecsFromUrl("https://example.com/dashboard");
147
- const cookies = await comboQueryCookieSpec(specs);
148
- ```
98
+ โš ๏ธ **Note: Platform support varies by browser. See our [Platform Support Guide](https://mherod.github.io/get-cookie/guide/platform-support.html) for details.**
149
99
 
150
100
  ## Output Formats ๐Ÿ“Š
151
101
 
@@ -165,6 +115,15 @@ get-cookie auth example.com --render
165
115
  get-cookie auth example.com --dump-grouped
166
116
  ```
167
117
 
118
+ ## Documentation ๐Ÿ“š
119
+
120
+ Full docs at [mherod.github.io/get-cookie](https://mherod.github.io/get-cookie/)
121
+
122
+ - API Reference
123
+ - Advanced Usage
124
+ - TypeScript Types
125
+ - [Security Guide](https://mherod.github.io/get-cookie/guide/security.html) โš ๏ธ
126
+
168
127
  ## Contributing ๐Ÿค
169
128
 
170
129
  Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
@@ -173,6 +132,6 @@ Contributions are welcome! Please feel free to submit a Pull Request. For major
173
132
 
174
133
  This project is licensed under the MIT License - see the LICENSE file for details.
175
134
 
176
- ## Security ๐Ÿ›ก๏ธ
135
+ ## Known Limitations ๐Ÿšง
177
136
 
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.
137
+ For a comprehensive list of limitations and known issues, please see our [Known Limitations Guide](https://mherod.github.io/get-cookie/guide/limitations.html).