@mherod/get-cookie 4.0.3 → 4.1.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/.husky/commit-msg +0 -0
- package/.husky/pre-commit +0 -0
- package/.husky/pre-push +0 -0
- package/.idea/prettier.xml +2 -1
- package/dist/chunk-3FVH4L25.js +2 -0
- package/dist/chunk-3FVH4L25.js.map +1 -0
- package/dist/chunk-7XZ7PCDJ.js +2 -0
- package/dist/chunk-7XZ7PCDJ.js.map +1 -0
- package/dist/chunk-DVWQBWUF.js +4 -0
- package/dist/chunk-DVWQBWUF.js.map +1 -0
- package/dist/{chunk-VMBA4NVU.js → chunk-I6AYGFSQ.js} +2 -2
- package/dist/chunk-U27I5BLR.js +2 -0
- package/dist/chunk-U27I5BLR.js.map +1 -0
- package/dist/chunk-YOZOS2YM.js +2 -0
- package/dist/chunk-YOZOS2YM.js.map +1 -0
- package/dist/cli.cjs +3 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/getChromeCookie-2ROVM47V.js +2 -0
- package/dist/getChromeCookie-2ROVM47V.js.map +1 -0
- package/dist/{getChromePassword-GTIXL733.js → getChromePassword-O452VQWI.js} +2 -2
- package/dist/getCookie-CRE6M3GI.js +2 -0
- package/dist/getFirefoxCookie-5P74VDC7.js +2 -0
- package/dist/getFirefoxCookie-5P74VDC7.js.map +1 -0
- package/dist/getGroupedRenderedCookies-DFEJTTC6.js +2 -0
- package/dist/getGroupedRenderedCookies-DFEJTTC6.js.map +1 -0
- package/dist/getMergedRenderedCookies-W5GSSHQQ.js +2 -0
- package/dist/getMergedRenderedCookies-W5GSSHQQ.js.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +164 -152
- package/dist/index.d.ts +164 -152
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/eslint.config.js +2 -1
- package/package.json +23 -22
- package/typedoc.json +3 -8
- package/dist/chunk-5FUMK7M3.js +0 -4
- package/dist/chunk-5FUMK7M3.js.map +0 -1
- package/dist/chunk-5ZT2G45S.js +0 -2
- package/dist/chunk-5ZT2G45S.js.map +0 -1
- package/dist/chunk-FR2MKDHT.js +0 -2
- package/dist/chunk-FR2MKDHT.js.map +0 -1
- package/dist/chunk-HMKSQBDC.js +0 -2
- package/dist/chunk-HMKSQBDC.js.map +0 -1
- package/dist/chunk-W3JALMAX.js +0 -2
- package/dist/chunk-W3JALMAX.js.map +0 -1
- package/dist/getChromeCookie-4ZWACG6M.js +0 -2
- package/dist/getChromeCookie-4ZWACG6M.js.map +0 -1
- package/dist/getCookie-43FKMQEZ.js +0 -2
- package/dist/getFirefoxCookie-OJYYZFZP.js +0 -2
- package/dist/getFirefoxCookie-OJYYZFZP.js.map +0 -1
- package/dist/getGroupedRenderedCookies-P5VZXZUC.js +0 -2
- package/dist/getGroupedRenderedCookies-P5VZXZUC.js.map +0 -1
- package/dist/getMergedRenderedCookies-C6TXK2I4.js +0 -2
- package/dist/getMergedRenderedCookies-C6TXK2I4.js.map +0 -1
- package/tsup.config.ts +0 -27
- /package/dist/{chunk-VMBA4NVU.js.map → chunk-I6AYGFSQ.js.map} +0 -0
- /package/dist/{getChromePassword-GTIXL733.js.map → getChromePassword-O452VQWI.js.map} +0 -0
- /package/dist/{getCookie-43FKMQEZ.js.map → getCookie-CRE6M3GI.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,189 +1,201 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @param obj - The object to check.
|
|
5
|
-
* @returns True if the object contains valid render options.
|
|
4
|
+
* Schema for cookie specification parameters
|
|
5
|
+
* Defines the required fields for identifying a cookie
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* }
|
|
8
|
+
* // Validate a cookie specification
|
|
9
|
+
* const spec = {
|
|
10
|
+
* name: 'session',
|
|
11
|
+
* domain: 'example.com'
|
|
12
|
+
* };
|
|
13
|
+
* const result = CookieSpecSchema.safeParse(spec);
|
|
14
|
+
* if (result.success) {
|
|
15
|
+
* console.log('Valid cookie spec:', result.data);
|
|
16
|
+
* } else {
|
|
17
|
+
* console.error('Invalid cookie spec:', result.error);
|
|
18
|
+
* }
|
|
17
19
|
*
|
|
18
|
-
* // Invalid
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* // Invalid spec (empty name)
|
|
21
|
+
* const invalidSpec = {
|
|
22
|
+
* name: '',
|
|
23
|
+
* domain: 'example.com'
|
|
24
|
+
* };
|
|
25
|
+
* // Throws: "Cookie name cannot be empty"
|
|
26
|
+
* CookieSpecSchema.parse(invalidSpec);
|
|
22
27
|
* ```
|
|
23
28
|
*/
|
|
24
|
-
|
|
29
|
+
declare const CookieSpecSchema: z.ZodObject<{
|
|
30
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
|
31
|
+
domain: z.ZodEffects<z.ZodString, string, string>;
|
|
32
|
+
}, "strict", z.ZodTypeAny, {
|
|
33
|
+
name: string;
|
|
34
|
+
domain: string;
|
|
35
|
+
}, {
|
|
36
|
+
name: string;
|
|
37
|
+
domain: string;
|
|
38
|
+
}>;
|
|
25
39
|
/**
|
|
26
|
-
*
|
|
40
|
+
* Type definition for cookie specification
|
|
41
|
+
* Used for specifying which cookie to query
|
|
27
42
|
* @example
|
|
28
43
|
* ```typescript
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* format: 'merged',
|
|
34
|
-
* separator: '; ',
|
|
35
|
-
* showFilePaths: false
|
|
44
|
+
* // Basic cookie spec
|
|
45
|
+
* const spec: CookieSpec = {
|
|
46
|
+
* name: 'auth',
|
|
47
|
+
* domain: 'api.example.com'
|
|
36
48
|
* };
|
|
37
49
|
*
|
|
38
|
-
* //
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* showFilePaths: true
|
|
43
|
-
* };
|
|
50
|
+
* // Use in function parameters
|
|
51
|
+
* function queryCookie(spec: CookieSpec): Promise<ExportedCookie[]> {
|
|
52
|
+
* return getCookie(spec);
|
|
53
|
+
* }
|
|
44
54
|
*
|
|
45
|
-
* //
|
|
46
|
-
* const
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* };
|
|
55
|
+
* // Array of specs
|
|
56
|
+
* const specs: CookieSpec[] = [
|
|
57
|
+
* { name: 'session', domain: 'app.example.com' },
|
|
58
|
+
* { name: 'theme', domain: 'example.com' }
|
|
59
|
+
* ];
|
|
51
60
|
* ```
|
|
52
61
|
*/
|
|
53
|
-
|
|
54
|
-
/** The format to use when rendering cookies. */
|
|
55
|
-
format?: RenderFormat;
|
|
56
|
-
/** The separator to use between cookies. */
|
|
57
|
-
separator?: string;
|
|
58
|
-
/** Whether to show file paths in the output. */
|
|
59
|
-
showFilePaths?: boolean;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
+
type CookieSpec = z.infer<typeof CookieSpecSchema>;
|
|
62
63
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @remarks
|
|
66
|
-
* - Domain matching is exact unless using wildcards.
|
|
67
|
-
* - Name can be "*" to match all cookies for a domain.
|
|
68
|
-
* - Leading dots in domains match all subdomains.
|
|
64
|
+
* Schema for exported cookie data
|
|
65
|
+
* Represents a cookie with all its properties and metadata
|
|
69
66
|
* @example
|
|
70
67
|
* ```typescript
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* const allCookies: CookieSpec = {
|
|
81
|
-
* domain: "example.com",
|
|
82
|
-
* name: "*" // Match all cookies for example.com
|
|
83
|
-
* };
|
|
84
|
-
*
|
|
85
|
-
* // Subdomain specification
|
|
86
|
-
* const apiCookies: CookieSpec = {
|
|
87
|
-
* domain: "api.example.com",
|
|
88
|
-
* name: "auth"
|
|
89
|
-
* };
|
|
90
|
-
*
|
|
91
|
-
* // Match cookies across all subdomains
|
|
92
|
-
* const allSubdomainCookies: CookieSpec = {
|
|
93
|
-
* domain: ".example.com", // Note the leading dot
|
|
94
|
-
* name: "tracking"
|
|
68
|
+
* // Validate an exported cookie
|
|
69
|
+
* const cookie = {
|
|
70
|
+
* domain: 'example.com',
|
|
71
|
+
* name: 'session',
|
|
72
|
+
* value: 'abc123',
|
|
73
|
+
* expiry: new Date('2024-12-31'),
|
|
74
|
+
* meta: {
|
|
75
|
+
* file: '/path/to/cookies.db'
|
|
76
|
+
* }
|
|
95
77
|
* };
|
|
78
|
+
* const result = ExportedCookieSchema.safeParse(cookie);
|
|
79
|
+
* if (result.success) {
|
|
80
|
+
* console.log('Valid cookie:', result.data);
|
|
81
|
+
* } else {
|
|
82
|
+
* console.error('Invalid cookie:', result.error);
|
|
83
|
+
* }
|
|
96
84
|
*
|
|
97
|
-
* //
|
|
98
|
-
* const
|
|
99
|
-
*
|
|
100
|
-
*
|
|
85
|
+
* // Cookie with infinite expiry
|
|
86
|
+
* const infiniteCookie = {
|
|
87
|
+
* ...cookie,
|
|
88
|
+
* expiry: "Infinity"
|
|
101
89
|
* };
|
|
90
|
+
* ExportedCookieSchema.parse(infiniteCookie); // OK
|
|
102
91
|
* ```
|
|
103
92
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
declare const ExportedCookieSchema: z.ZodObject<{
|
|
94
|
+
domain: z.ZodEffects<z.ZodString, string, string>;
|
|
95
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
|
96
|
+
value: z.ZodPipeline<z.ZodEffects<z.ZodString, unknown, string>, z.ZodAny>;
|
|
97
|
+
expiry: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Infinity">, z.ZodDate, z.ZodNumber]>>;
|
|
98
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
99
|
+
file: z.ZodOptional<z.ZodString>;
|
|
100
|
+
browser: z.ZodOptional<z.ZodString>;
|
|
101
|
+
decrypted: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
103
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
+
path: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
|
|
105
|
+
}, "strict", z.ZodUnknown, z.objectOutputType<{
|
|
106
|
+
file: z.ZodOptional<z.ZodString>;
|
|
107
|
+
browser: z.ZodOptional<z.ZodString>;
|
|
108
|
+
decrypted: z.ZodOptional<z.ZodBoolean>;
|
|
109
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
111
|
+
path: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
|
|
112
|
+
}, z.ZodUnknown, "strict">, z.objectInputType<{
|
|
113
|
+
file: z.ZodOptional<z.ZodString>;
|
|
114
|
+
browser: z.ZodOptional<z.ZodString>;
|
|
115
|
+
decrypted: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
117
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
118
|
+
path: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
|
|
119
|
+
}, z.ZodUnknown, "strict">>>;
|
|
120
|
+
}, "strict", z.ZodTypeAny, {
|
|
121
|
+
name: string;
|
|
106
122
|
domain: string;
|
|
107
|
-
|
|
123
|
+
value?: any;
|
|
124
|
+
expiry?: number | Date | "Infinity" | undefined;
|
|
125
|
+
meta?: z.objectOutputType<{
|
|
126
|
+
file: z.ZodOptional<z.ZodString>;
|
|
127
|
+
browser: z.ZodOptional<z.ZodString>;
|
|
128
|
+
decrypted: z.ZodOptional<z.ZodBoolean>;
|
|
129
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
130
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
131
|
+
path: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
|
|
132
|
+
}, z.ZodUnknown, "strict"> | undefined;
|
|
133
|
+
}, {
|
|
108
134
|
name: string;
|
|
109
|
-
|
|
110
|
-
|
|
135
|
+
value: string;
|
|
136
|
+
domain: string;
|
|
137
|
+
expiry?: number | Date | "Infinity" | undefined;
|
|
138
|
+
meta?: z.objectInputType<{
|
|
139
|
+
file: z.ZodOptional<z.ZodString>;
|
|
140
|
+
browser: z.ZodOptional<z.ZodString>;
|
|
141
|
+
decrypted: z.ZodOptional<z.ZodBoolean>;
|
|
142
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
143
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
144
|
+
path: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
|
|
145
|
+
}, z.ZodUnknown, "strict"> | undefined;
|
|
146
|
+
}>;
|
|
111
147
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* retrieved from various browser storage mechanisms (Chrome, Firefox, etc.).
|
|
115
|
-
* @remarks
|
|
116
|
-
* - All cookies must have domain, name, and value properties.
|
|
117
|
-
* - Expiry is optional and can be a Date, "Infinity", or undefined.
|
|
118
|
-
* - Meta information is useful for tracking the cookie's origin and state.
|
|
148
|
+
* Type definition for exported cookie data
|
|
149
|
+
* Represents the structure of a cookie after it has been retrieved
|
|
119
150
|
* @example
|
|
120
151
|
* ```typescript
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* value: "abc123"
|
|
128
|
-
* };
|
|
129
|
-
*
|
|
130
|
-
* // Cookie with expiry and metadata
|
|
131
|
-
* const detailedCookie: ExportedCookie = {
|
|
132
|
-
* domain: "api.example.com",
|
|
133
|
-
* name: "authToken",
|
|
134
|
-
* value: "xyz789",
|
|
135
|
-
* expiry: new Date("2024-12-31"),
|
|
152
|
+
* // Basic exported cookie
|
|
153
|
+
* const cookie: ExportedCookie = {
|
|
154
|
+
* domain: 'example.com',
|
|
155
|
+
* name: 'session',
|
|
156
|
+
* value: 'abc123',
|
|
157
|
+
* expiry: new Date('2024-12-31'),
|
|
136
158
|
* meta: {
|
|
137
|
-
* file:
|
|
138
|
-
* browser: "Firefox",
|
|
139
|
-
* decrypted: true,
|
|
140
|
-
* secure: true,
|
|
141
|
-
* httpOnly: true,
|
|
142
|
-
* path: "/"
|
|
159
|
+
* file: '/path/to/cookies.db'
|
|
143
160
|
* }
|
|
144
161
|
* };
|
|
145
162
|
*
|
|
146
|
-
* //
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* value: "theme=dark",
|
|
151
|
-
* expiry: "Infinity"
|
|
152
|
-
* };
|
|
163
|
+
* // Process exported cookies
|
|
164
|
+
* function processCookies(cookies: ExportedCookie[]): string[] {
|
|
165
|
+
* return cookies.map(cookie => `${cookie.name}=${cookie.value}`);
|
|
166
|
+
* }
|
|
153
167
|
*
|
|
154
|
-
* //
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* }
|
|
163
|
-
* };
|
|
168
|
+
* // Filter expired cookies
|
|
169
|
+
* function filterExpired(cookies: ExportedCookie[]): ExportedCookie[] {
|
|
170
|
+
* const now = new Date();
|
|
171
|
+
* return cookies.filter(cookie =>
|
|
172
|
+
* cookie.expiry === "Infinity" ||
|
|
173
|
+
* (cookie.expiry instanceof Date && cookie.expiry > now)
|
|
174
|
+
* );
|
|
175
|
+
* }
|
|
164
176
|
* ```
|
|
165
177
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
178
|
+
type ExportedCookie = z.infer<typeof ExportedCookieSchema>;
|
|
179
|
+
/**
|
|
180
|
+
* Schema for cookie render options
|
|
181
|
+
*/
|
|
182
|
+
declare const RenderOptionsSchema: z.ZodObject<{
|
|
183
|
+
format: z.ZodOptional<z.ZodEnum<["merged", "grouped"]>>;
|
|
184
|
+
separator: z.ZodOptional<z.ZodString>;
|
|
185
|
+
showFilePaths: z.ZodOptional<z.ZodBoolean>;
|
|
186
|
+
}, "strict", z.ZodTypeAny, {
|
|
187
|
+
format?: "merged" | "grouped" | undefined;
|
|
188
|
+
separator?: string | undefined;
|
|
189
|
+
showFilePaths?: boolean | undefined;
|
|
190
|
+
}, {
|
|
191
|
+
format?: "merged" | "grouped" | undefined;
|
|
192
|
+
separator?: string | undefined;
|
|
193
|
+
showFilePaths?: boolean | undefined;
|
|
194
|
+
}>;
|
|
195
|
+
/**
|
|
196
|
+
* Type definition for render options
|
|
197
|
+
*/
|
|
198
|
+
type RenderOptions = z.infer<typeof RenderOptionsSchema>;
|
|
187
199
|
|
|
188
200
|
/**
|
|
189
201
|
* Dynamic import for the getCookie function.
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-I6AYGFSQ.js";var o=()=>import("./getCookie-CRE6M3GI.js").then(e=>e.getCookie),i=()=>import("./getChromeCookie-2ROVM47V.js").then(e=>e.getChromeCookie),r=()=>import("./getFirefoxCookie-5P74VDC7.js").then(e=>e.getFirefoxCookie),t=()=>import("./getGroupedRenderedCookies-DFEJTTC6.js").then(e=>e.getGroupedRenderedCookies),p=()=>import("./getMergedRenderedCookies-W5GSSHQQ.js").then(e=>e.getMergedRenderedCookies);export{i as getChromeCookie,o as getCookie,r as getFirefoxCookie,t as getGroupedRenderedCookies,p as getMergedRenderedCookies};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/cookies/dynamicImports.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/core/cookies/dynamicImports.ts"],"sourcesContent":["import type {\n RenderOptions,\n CookieSpec,\n ExportedCookie,\n} from \"../../types/schemas\";\n\n/**\n * Dynamic import for the getCookie function.\n * @internal\n * @returns Promise resolving to the getCookie function\n * @example\n * ```typescript\n * const getCookieFn = await getCookie();\n * const cookies = await getCookieFn({ domain: 'example.com' });\n * // Returns: [{ name: 'sessionId', value: 'abc123', domain: 'example.com' }, ...]\n * ```\n */\nexport const getCookie = (): Promise<\n (cookieSpec: CookieSpec) => Promise<ExportedCookie[]>\n> => import(\"./getCookie\").then((module) => module.getCookie);\n\n/**\n * Dynamic import for Chrome-specific cookie retrieval.\n * @internal\n * @returns Promise resolving to the getChromeCookie function\n * @example\n * ```typescript\n * const chromeCookieFn = await getChromeCookie();\n * const cookies = await chromeCookieFn({ domain: 'example.com', secure: true });\n * // Returns Chrome-format cookies: [{ name: 'auth', value: 'xyz789', secure: true }, ...]\n * ```\n */\nexport const getChromeCookie = (): Promise<\n (cookieSpec: CookieSpec) => Promise<ExportedCookie[]>\n> => import(\"./getChromeCookie\").then((module) => module.getChromeCookie);\n\n/**\n * Dynamic import for Firefox-specific cookie retrieval.\n * @internal\n * @returns Promise resolving to the getFirefoxCookie function\n * @example\n * ```typescript\n * const firefoxCookieFn = await getFirefoxCookie();\n * const cookies = await firefoxCookieFn({ path: '/api' });\n * // Returns Firefox-format cookies: [{ name: 'token', value: 'def456', path: '/api' }, ...]\n * ```\n */\nexport const getFirefoxCookie = (): Promise<\n (cookieSpec: CookieSpec) => Promise<ExportedCookie[]>\n> => import(\"./getFirefoxCookie\").then((module) => module.getFirefoxCookie);\n\n/**\n * Dynamic import for retrieving grouped and rendered cookies.\n * @internal\n * @returns Promise resolving to the getGroupedRenderedCookies function\n * @example\n * ```typescript\n * const groupedCookiesFn = await getGroupedRenderedCookies();\n * const cookieStrings = await groupedCookiesFn({ domain: 'example.com' });\n * // Returns: ['sessionId=abc123; Domain=example.com', 'auth=xyz789; Domain=example.com']\n * ```\n */\nexport const getGroupedRenderedCookies = (): Promise<\n (cookieSpec: CookieSpec) => Promise<string[]>\n> =>\n import(\"./getGroupedRenderedCookies\").then(\n (module) => module.getGroupedRenderedCookies,\n );\n\n/**\n * Dynamic import for retrieving merged and rendered cookies.\n * @internal\n * @returns Promise resolving to the getMergedRenderedCookies function\n * @example\n * ```typescript\n * const mergedCookiesFn = await getMergedRenderedCookies();\n * const cookieString = await mergedCookiesFn(\n * { domain: 'example.com' },\n * { separator: '; ' }\n * );\n * // Returns: \"sessionId=abc123; auth=xyz789\"\n * ```\n */\nexport const getMergedRenderedCookies = (): Promise<\n (\n cookieSpec: CookieSpec,\n options?: Omit<RenderOptions, \"format\">,\n ) => Promise<string>\n> =>\n import(\"./getMergedRenderedCookies\").then(\n (module) => module.getMergedRenderedCookies,\n );\n"],"mappings":"4BAiBO,IAAMA,EAAY,IAEpB,OAAO,yBAAa,EAAE,KAAMC,GAAWA,EAAO,SAAS,EAa/CC,EAAkB,IAE1B,OAAO,+BAAmB,EAAE,KAAMD,GAAWA,EAAO,eAAe,EAa3DE,EAAmB,IAE3B,OAAO,gCAAoB,EAAE,KAAMF,GAAWA,EAAO,gBAAgB,EAa7DG,EAA4B,IAGvC,OAAO,yCAA6B,EAAE,KACnCH,GAAWA,EAAO,yBACrB,EAgBWI,EAA2B,IAMtC,OAAO,wCAA4B,EAAE,KAClCJ,GAAWA,EAAO,wBACrB","names":["getCookie","module","getChromeCookie","getFirefoxCookie","getGroupedRenderedCookies","getMergedRenderedCookies"]}
|
package/eslint.config.js
CHANGED
|
@@ -6,7 +6,7 @@ import globals from "globals";
|
|
|
6
6
|
|
|
7
7
|
export default [
|
|
8
8
|
{
|
|
9
|
-
ignores: ["dist/**/*", "node_modules/**/*"],
|
|
9
|
+
ignores: ["dist/**/*", "node_modules/**/*", "coverage/**/*"],
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
files: ["**/*.js", "**/*.mjs"],
|
|
@@ -238,6 +238,7 @@ export default [
|
|
|
238
238
|
rules: {
|
|
239
239
|
"jsdoc/require-example": "off",
|
|
240
240
|
"jsdoc/require-description": "off",
|
|
241
|
+
"max-lines-per-function": ["error", { max: 100 }],
|
|
241
242
|
},
|
|
242
243
|
},
|
|
243
244
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mherod/get-cookie",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Node.js module for querying a local user's Chrome cookie",
|
|
5
|
+
"packageManager": "pnpm@9.15.2",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"source": "src/index.ts",
|
|
7
8
|
"bin": {
|
|
@@ -24,6 +25,26 @@
|
|
|
24
25
|
"publishConfig": {
|
|
25
26
|
"access": "public"
|
|
26
27
|
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"build:lib": "tsup --config tsup.lib.ts",
|
|
31
|
+
"build:cli": "tsup --config tsup.cli.ts",
|
|
32
|
+
"build": "pnpm run build:lib && pnpm run build:cli",
|
|
33
|
+
"test": "jest",
|
|
34
|
+
"type-check": "tsc --noEmit",
|
|
35
|
+
"lint": "eslint . --format=codeframe",
|
|
36
|
+
"lint:fix": "eslint . --format=codeframe --fix",
|
|
37
|
+
"validate": "pnpm run type-check && pnpm run lint && pnpm run test",
|
|
38
|
+
"prepack": "pnpm run validate",
|
|
39
|
+
"prepublishOnly": "pnpm run clean && pnpm run validate && pnpm run build",
|
|
40
|
+
"format": "prettier --write .",
|
|
41
|
+
"dev": "tsc -w -p tsconfig.json & tsc-alias -w -p tsconfig.json",
|
|
42
|
+
"read-github": "NODE_OPTIONS=\"-r tsconfig-paths/register\" tsx scripts/read-github-cookies.ts",
|
|
43
|
+
"prepare": "husky install",
|
|
44
|
+
"docs": "typedoc && ./scripts/fix-typedoc.sh && vitepress build docs",
|
|
45
|
+
"docs:dev": "vitepress dev docs",
|
|
46
|
+
"docs:preview": "vitepress preview docs"
|
|
47
|
+
},
|
|
27
48
|
"engines": {
|
|
28
49
|
"node": "^20.0.0 || ^22.0.0"
|
|
29
50
|
},
|
|
@@ -37,9 +58,7 @@
|
|
|
37
58
|
"fast-glob": "^3.3.2",
|
|
38
59
|
"jsonwebtoken": "^9.0.2",
|
|
39
60
|
"lodash-es": "^4.17.21",
|
|
40
|
-
"lru-cache": "^11.0.2",
|
|
41
61
|
"minimist": "^1.2.8",
|
|
42
|
-
"tough-cookie": "^5.0.0",
|
|
43
62
|
"tsconfig-paths": "^4.2.0",
|
|
44
63
|
"zod": "^3.24.1"
|
|
45
64
|
},
|
|
@@ -54,7 +73,6 @@
|
|
|
54
73
|
"@types/lodash-es": "4.17.12",
|
|
55
74
|
"@types/minimist": "^1.2.5",
|
|
56
75
|
"@types/node": "^22.10.4",
|
|
57
|
-
"@types/tough-cookie": "^4.0.5",
|
|
58
76
|
"@typescript-eslint/eslint-plugin": "^8.19.0",
|
|
59
77
|
"@typescript-eslint/parser": "^8.19.0",
|
|
60
78
|
"eslint": "^9.17.0",
|
|
@@ -86,22 +104,5 @@
|
|
|
86
104
|
"*.{json,md,yml,yaml}": [
|
|
87
105
|
"prettier --write"
|
|
88
106
|
]
|
|
89
|
-
},
|
|
90
|
-
"scripts": {
|
|
91
|
-
"clean": "rm -rf dist",
|
|
92
|
-
"build:lib": "tsup --config tsup.lib.ts",
|
|
93
|
-
"build:cli": "tsup --config tsup.cli.ts",
|
|
94
|
-
"build": "pnpm run build:lib && pnpm run build:cli",
|
|
95
|
-
"test": "jest",
|
|
96
|
-
"type-check": "tsc --noEmit",
|
|
97
|
-
"lint": "eslint . --format=codeframe",
|
|
98
|
-
"lint:fix": "eslint . --format=codeframe --fix",
|
|
99
|
-
"validate": "pnpm run type-check && pnpm run lint && pnpm run test",
|
|
100
|
-
"format": "prettier --write .",
|
|
101
|
-
"dev": "tsc -w -p tsconfig.json & tsc-alias -w -p tsconfig.json",
|
|
102
|
-
"read-github": "NODE_OPTIONS=\"-r tsconfig-paths/register\" tsx scripts/readGithubCookies.ts",
|
|
103
|
-
"docs": "typedoc && ./scripts/fix-typedoc.sh && vitepress build docs",
|
|
104
|
-
"docs:dev": "vitepress dev docs",
|
|
105
|
-
"docs:preview": "vitepress preview docs"
|
|
106
107
|
}
|
|
107
|
-
}
|
|
108
|
+
}
|
package/typedoc.json
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://typedoc.org/schema.json",
|
|
3
|
-
"entryPoints": [
|
|
4
|
-
"src/index.ts",
|
|
5
|
-
"src/cli/cli.ts",
|
|
6
|
-
"src/types/ExportedCookie.ts",
|
|
7
|
-
"src/types/CookieSpec.ts",
|
|
8
|
-
"src/types/CookieRender.ts"
|
|
9
|
-
],
|
|
3
|
+
"entryPoints": ["src/index.ts", "src/cli/cli.ts"],
|
|
10
4
|
"out": "docs/reference",
|
|
11
5
|
"plugin": ["typedoc-plugin-markdown"],
|
|
12
6
|
"readme": "none",
|
|
@@ -18,5 +12,6 @@
|
|
|
18
12
|
"excludeExternals": true,
|
|
19
13
|
"includeVersion": true,
|
|
20
14
|
"categorizeByGroup": true,
|
|
21
|
-
"categoryOrder": ["Core", "Browsers", "CLI", "*"]
|
|
15
|
+
"categoryOrder": ["Core", "Browsers", "CLI", "*"],
|
|
16
|
+
"tsconfig": "tsconfig.json"
|
|
22
17
|
}
|