cookie-es 1.2.2 → 3.0.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/README.md CHANGED
@@ -1,82 +1,160 @@
1
-
2
1
  # 🍪 cookie-es
3
2
 
4
- <!-- automd:badges bundlejs -->
3
+ <!-- automd:badges bundlejs packagephobia codecov -->
5
4
 
6
5
  [![npm version](https://img.shields.io/npm/v/cookie-es)](https://npmjs.com/package/cookie-es)
7
- [![npm downloads](https://img.shields.io/npm/dm/cookie-es)](https://npmjs.com/package/cookie-es)
6
+ [![npm downloads](https://img.shields.io/npm/dm/cookie-es)](https://npm.chart.dev/cookie-es)
8
7
  [![bundle size](https://img.shields.io/bundlejs/size/cookie-es)](https://bundlejs.com/?q=cookie-es)
8
+ [![install size](https://badgen.net/packagephobia/install/cookie-es)](https://packagephobia.com/result?p=cookie-es)
9
+ [![codecov](https://img.shields.io/codecov/c/gh/unjs/cookie-es)](https://codecov.io/gh/unjs/cookie-es)
9
10
 
10
11
  <!-- /automd -->
11
12
 
12
- 🍪 [`Cookie`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie) and [`Set-Cookie`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) parser and serializer based on [cookie](https://github.com/jshttp/cookie) and [set-cookie-parser](https://github.com/nfriedly/set-cookie-parser) with dual ESM/CJS exports and bundled types. 🎁
13
-
14
- ## Usage
13
+ ESM-ready [`Cookie`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie) and [`Set-Cookie`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) parser and serializer based on [cookie](https://github.com/jshttp/cookie) and [set-cookie-parser](https://github.com/nfriedly/set-cookie-parser) with built-in TypeScript types. Compliant with [RFC 6265bis](https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html).
15
14
 
16
- Install:
17
-
18
- <!-- automd:pm-install -->
15
+ ## Install
19
16
 
20
17
  ```sh
21
- # ✨ Auto-detect
18
+ # ✨ Auto-detect (npm, yarn, pnpm, bun, deno)
22
19
  npx nypm install cookie-es
20
+ ```
23
21
 
24
- # npm
25
- npm install cookie-es
22
+ ## Import
26
23
 
27
- # yarn
28
- yarn add cookie-es
24
+ **ESM** (Node.js, Bun, Deno)
29
25
 
30
- # pnpm
31
- pnpm install cookie-es
26
+ ```js
27
+ import {
28
+ parseCookie,
29
+ parseSetCookie,
30
+ serializeCookie,
31
+ stringifyCookie,
32
+ splitSetCookieString,
33
+ } from "cookie-es";
34
+ ```
32
35
 
33
- # bun
34
- bun install cookie-es
36
+ **CDN** (Deno, Bun and Browsers)
37
+
38
+ ```js
39
+ import {
40
+ parseCookie,
41
+ parseSetCookie,
42
+ serializeCookie,
43
+ stringifyCookie,
44
+ splitSetCookieString,
45
+ } from "https://esm.sh/cookie-es";
35
46
  ```
36
47
 
37
- <!-- /automd-->
48
+ ## API
38
49
 
39
- Import:
50
+ ### `parseCookie(str, options?)`
40
51
 
52
+ Parse a `Cookie` header string into an object. First occurrence wins for duplicate names.
41
53
 
42
- <!-- automd:jsimport cdn cjs src=./src/index.ts -->
54
+ ```js
55
+ parseCookie("foo=bar; equation=E%3Dmc%5E2");
56
+ // { foo: "bar", equation: "E=mc^2" }
57
+
58
+ // Custom decoder
59
+ parseCookie("foo=bar", { decode: (v) => v });
43
60
 
44
- **ESM** (Node.js, Bun)
61
+ // Only parse specific keys
62
+ parseCookie("a=1; b=2; c=3", { filter: (key) => key !== "b" });
63
+ // { a: "1", c: "3" }
64
+ ```
65
+
66
+ ### `parseSetCookie(str, options?)`
67
+
68
+ Parse a `Set-Cookie` header string into an object with all cookie attributes.
45
69
 
46
70
  ```js
47
- import {
48
- parse,
49
- serialize,
50
- parseSetCookie,
51
- splitSetCookieString,
52
- } from "cookie-es";
71
+ parseSetCookie(
72
+ "id=abc; Domain=example.com; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=3600; Partitioned; Priority=High",
73
+ );
74
+ // {
75
+ // name: "id",
76
+ // value: "abc",
77
+ // domain: "example.com",
78
+ // path: "/",
79
+ // httpOnly: true,
80
+ // secure: true,
81
+ // sameSite: "lax",
82
+ // maxAge: 3600,
83
+ // partitioned: true,
84
+ // priority: "high",
85
+ // }
53
86
  ```
54
87
 
55
- **CommonJS** (Legacy Node.js)
88
+ Supports `decode` option (custom function or `false` to skip decoding). Returns `undefined` for cookies with forbidden names (prototype pollution protection) or when both name and value are empty ([RFC 6265bis](https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html) sec 5.7).
89
+
90
+ ### `serializeCookie(name, value, options?)`
91
+
92
+ Serialize a cookie name-value pair into a `Set-Cookie` header string.
56
93
 
57
94
  ```js
58
- const {
59
- parse,
60
- serialize,
61
- parseSetCookie,
62
- splitSetCookieString,
63
- } = require("cookie-es");
95
+ serializeCookie("foo", "bar", { httpOnly: true, secure: true, maxAge: 3600 });
96
+ // "foo=bar; Max-Age=3600; HttpOnly; Secure"
97
+
98
+ // Also accepts a cookie object
99
+ serializeCookie({
100
+ name: "foo",
101
+ value: "bar",
102
+ domain: "example.com",
103
+ path: "/",
104
+ sameSite: "lax",
105
+ });
106
+ // "foo=bar; Domain=example.com; Path=/; SameSite=Lax"
64
107
  ```
65
108
 
66
- **CDN** (Deno, Bun and Browsers)
109
+ Supported attributes: `maxAge`, `expires`, `domain`, `path`, `httpOnly`, `secure`, `sameSite`, `priority`, `partitioned`. Use `encode` option for custom value encoding (default: `encodeURIComponent`).
110
+
111
+ > [!NOTE]
112
+ > `parse` and `serialize` are available as shorter aliases for `parseCookie` and `serializeCookie`.
113
+
114
+ ### `stringifyCookie(cookies, options?)`
115
+
116
+ Stringify a cookies object into an HTTP `Cookie` header string.
67
117
 
68
118
  ```js
69
- import {
70
- parse,
71
- serialize,
72
- parseSetCookie,
73
- splitSetCookieString,
74
- } from "https://esm.sh/cookie-es";
119
+ stringifyCookie({ foo: "bar", baz: "qux" });
120
+ // "foo=bar; baz=qux"
75
121
  ```
76
122
 
77
- <!-- /automd -->
123
+ ### `splitSetCookieString(input)`
78
124
 
125
+ Split comma-joined `Set-Cookie` headers into individual strings. Correctly handles commas within cookie attributes like `Expires` dates.
126
+
127
+ ```js
128
+ splitSetCookieString(
129
+ "foo=bar; Expires=Thu, 01 Jan 2026 00:00:00 GMT, baz=qux",
130
+ );
131
+ // ["foo=bar; Expires=Thu, 01 Jan 2026 00:00:00 GMT", "baz=qux"]
132
+
133
+ // Also accepts an array
134
+ splitSetCookieString(["a=1, b=2", "c=3"]);
135
+ // ["a=1", "b=2", "c=3"]
136
+ ```
137
+
138
+ ## Parsing Options
139
+
140
+ ### `allowMultiple`
141
+
142
+ By default, when a cookie name appears more than once, only the first value is kept. Set `allowMultiple: true` to collect all values into an array:
143
+
144
+ ```js
145
+ import { parseCookie } from "cookie-es";
146
+
147
+ // Default: first value wins
148
+ parseCookie("foo=a;bar=b;foo=c");
149
+ // => { foo: "a", bar: "b" }
150
+
151
+ // With allowMultiple: duplicates return arrays
152
+ parseCookie("foo=a;bar=b;foo=c", { allowMultiple: true });
153
+ // => { foo: ["a", "c"], bar: "b" }
154
+ ```
79
155
 
80
156
  ## License
81
157
 
82
158
  [MIT](./LICENSE)
159
+
160
+ Based on [jshttp/cookie](https://github.com/jshttp/cookie) (Roman Shtylman and Douglas Christopher Wilson) and [nfriedly/set-cookie-parser](https://github.com/nfriedly/set-cookie-parser) (Nathan Friedly).
package/dist/index.d.mts CHANGED
@@ -1,216 +1,238 @@
1
+ //#region src/cookie/types.d.ts
1
2
  /**
2
- * Basic HTTP cookie parser and serializer for HTTP servers.
3
+ * Parse options.
3
4
  */
5
+ interface CookieParseOptions {
6
+ /**
7
+ * Specifies a function that will be used to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
8
+ * Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode
9
+ * a previously-encoded cookie value into a JavaScript string.
10
+ *
11
+ * The default function is the global `decodeURIComponent`, wrapped in a `try..catch`. If an error
12
+ * is thrown it will return the cookie's original value. If you provide your own encode/decode
13
+ * scheme you must ensure errors are appropriately handled.
14
+ *
15
+ * @default decode
16
+ */
17
+ decode?: (str: string) => string | undefined;
18
+ /**
19
+ * Custom function to filter parsing specific keys.
20
+ */
21
+ filter?(key: string): boolean;
22
+ /**
23
+ * When enabled, duplicate cookie names will return an array of values
24
+ * instead of only the first value.
25
+ */
26
+ allowMultiple?: boolean;
27
+ }
28
+ /**
29
+ * Cookies object.
30
+ */
31
+ type Cookies = Record<string, string | undefined>;
4
32
  /**
5
- * Additional serialization options
33
+ * Cookies object when `allowMultiple` is enabled.
6
34
  */
7
- interface CookieSerializeOptions {
8
- /**
9
- * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3|Domain Set-Cookie attribute}. By default, no
10
- * domain is set, and most clients will consider the cookie to apply to only
11
- * the current domain.
12
- */
13
- domain?: string | undefined;
14
- /**
15
- * Specifies a function that will be used to encode a cookie's value. Since
16
- * value of a cookie has a limited character set (and must be a simple
17
- * string), this function can be used to encode a value into a string suited
18
- * for a cookie's value.
19
- *
20
- * The default function is the global `encodeURIComponent`, which will
21
- * encode a JavaScript string into UTF-8 byte sequences and then URL-encode
22
- * any that fall outside of the cookie range.
23
- */
24
- encode?(value: string): string;
25
- /**
26
- * Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1|`Expires` `Set-Cookie` attribute}. By default,
27
- * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
28
- * it on a condition like exiting a web browser application.
29
- *
30
- * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
31
- * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
32
- * possible not all clients by obey this, so if both are set, they should
33
- * point to the same date and time.
34
- */
35
- expires?: Date | undefined;
36
- /**
37
- * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6|`HttpOnly` `Set-Cookie` attribute}.
38
- * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
39
- * default, the `HttpOnly` attribute is not set.
40
- *
41
- * *Note* be careful when setting this to true, as compliant clients will
42
- * not allow client-side JavaScript to see the cookie in `document.cookie`.
43
- */
44
- httpOnly?: boolean | undefined;
45
- /**
46
- * Specifies the number (in seconds) to be the value for the `Max-Age`
47
- * `Set-Cookie` attribute. The given number will be converted to an integer
48
- * by rounding down. By default, no maximum age is set.
49
- *
50
- * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
51
- * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
52
- * possible not all clients by obey this, so if both are set, they should
53
- * point to the same date and time.
54
- */
55
- maxAge?: number | undefined;
56
- /**
57
- * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
58
- * By default, the path is considered the "default path".
59
- */
60
- path?: string | undefined;
61
- /**
62
- * Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].
63
- *
64
- * - `'low'` will set the `Priority` attribute to `Low`.
65
- * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
66
- * - `'high'` will set the `Priority` attribute to `High`.
67
- *
68
- * More information about the different priority levels can be found in
69
- * [the specification][rfc-west-cookie-priority-00-4.1].
70
- *
71
- * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
72
- * This also means many clients may ignore this attribute until they understand it.
73
- */
74
- priority?: "low" | "medium" | "high" | undefined;
75
- /**
76
- * Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}.
77
- *
78
- * - `true` will set the `SameSite` attribute to `Strict` for strict same
79
- * site enforcement.
80
- * - `false` will not set the `SameSite` attribute.
81
- * - `'lax'` will set the `SameSite` attribute to Lax for lax same site
82
- * enforcement.
83
- * - `'strict'` will set the `SameSite` attribute to Strict for strict same
84
- * site enforcement.
85
- * - `'none'` will set the SameSite attribute to None for an explicit
86
- * cross-site cookie.
87
- *
88
- * More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.
89
- *
90
- * *note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
91
- */
92
- sameSite?: true | false | "lax" | "strict" | "none" | undefined;
93
- /**
94
- * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5|`Secure` `Set-Cookie` attribute}. When truthy, the
95
- * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
96
- *
97
- * *Note* be careful when setting this to `true`, as compliant clients will
98
- * not send the cookie back to the server in the future if the browser does
99
- * not have an HTTPS connection.
100
- */
101
- secure?: boolean | undefined;
102
- /**
103
- * Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1)
104
- * attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the
105
- * `Partitioned` attribute is not set.
106
- *
107
- * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
108
- * This also means many clients may ignore this attribute until they understand it.
109
- *
110
- * More information can be found in the [proposal](https://github.com/privacycg/CHIPS).
111
- */
112
- partitioned?: boolean;
35
+ type MultiCookies = Record<string, string | string[] | undefined>;
36
+ /**
37
+ * Stringify options.
38
+ */
39
+ interface CookieStringifyOptions {
40
+ /**
41
+ * Specifies a function that will be used to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
42
+ * Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode
43
+ * a value into a string suited for a cookie's value, and should mirror `decode` when parsing.
44
+ *
45
+ * @default encodeURIComponent
46
+ */
47
+ encode?: (str: string) => string;
113
48
  }
114
49
  /**
115
- * Additional parsing options
50
+ * Set-Cookie object.
116
51
  */
117
- interface CookieParseOptions {
118
- /**
119
- * Specifies a function that will be used to decode a cookie's value. Since
120
- * the value of a cookie has a limited character set (and must be a simple
121
- * string), this function can be used to decode a previously-encoded cookie
122
- * value into a JavaScript string or other object.
123
- *
124
- * The default function is the global `decodeURIComponent`, which will decode
125
- * any URL-encoded sequences into their byte representations.
126
- *
127
- * *Note* if an error is thrown from this function, the original, non-decoded
128
- * cookie value will be returned as the cookie's value.
129
- */
130
- decode?(value: string): string;
131
- /**
132
- * Custom function to filter parsing specific keys.
133
- */
134
- filter?(key: string): boolean;
52
+ interface SetCookie {
53
+ /**
54
+ * Specifies the name of the cookie.
55
+ */
56
+ name: string;
57
+ /**
58
+ * Specifies the string to be the value for the cookie.
59
+ */
60
+ value: string | undefined;
61
+ /**
62
+ * Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2).
63
+ *
64
+ * The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
65
+ * `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
66
+ * so if both are set, they should point to the same date and time.
67
+ */
68
+ maxAge?: number;
69
+ /**
70
+ * Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1).
71
+ * When no expiration is set, clients consider this a "non-persistent cookie" and delete it when the current session is over.
72
+ *
73
+ * The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
74
+ * `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
75
+ * so if both are set, they should point to the same date and time.
76
+ */
77
+ expires?: Date;
78
+ /**
79
+ * Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3).
80
+ * When no domain is set, clients consider the cookie to apply to the current domain only.
81
+ */
82
+ domain?: string;
83
+ /**
84
+ * Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
85
+ * When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4).
86
+ */
87
+ path?: string;
88
+ /**
89
+ * Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6).
90
+ * When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`.
91
+ */
92
+ httpOnly?: boolean;
93
+ /**
94
+ * Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5).
95
+ * When enabled, clients will only send the cookie back if the browser has an HTTPS connection.
96
+ */
97
+ secure?: boolean;
98
+ /**
99
+ * Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/).
100
+ * When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches.
101
+ *
102
+ * This is an attribute that has not yet been fully standardized, and may change in the future.
103
+ * This also means clients may ignore this attribute until they understand it. More information
104
+ * about can be found in [the proposal](https://github.com/privacycg/CHIPS).
105
+ */
106
+ partitioned?: boolean;
107
+ /**
108
+ * Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
109
+ *
110
+ * - `'low'` will set the `Priority` attribute to `Low`.
111
+ * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
112
+ * - `'high'` will set the `Priority` attribute to `High`.
113
+ *
114
+ * More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
115
+ */
116
+ priority?: "low" | "medium" | "high";
117
+ /**
118
+ * Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
119
+ *
120
+ * - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
121
+ * - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
122
+ * - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
123
+ * - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
124
+ *
125
+ * More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
126
+ */
127
+ sameSite?: boolean | "lax" | "strict" | "none";
135
128
  }
136
-
137
129
  /**
138
- * Parse an HTTP Cookie header string and returning an object of all cookie
139
- * name-value pairs.
130
+ * Backward compatibility serialize options.
131
+ */
132
+ type CookieSerializeOptions = CookieStringifyOptions & Omit<SetCookie, "name" | "value">;
133
+ //#endregion
134
+ //#region src/cookie/parse.d.ts
135
+ /**
136
+ * Parse a `Cookie` header.
140
137
  *
141
- * @param str the string representing a `Cookie` header value
142
- * @param [options] object containing parsing options
138
+ * Parse the given cookie header string into an object
139
+ * The object has the various cookies as keys(names) => values
143
140
  */
144
- declare function parse(str: string, options?: CookieParseOptions): Record<string, string>;
145
-
141
+ declare function parse(str: string, options: CookieParseOptions & {
142
+ allowMultiple: true;
143
+ }): MultiCookies;
144
+ declare function parse(str: string, options?: CookieParseOptions): Cookies;
145
+ //#endregion
146
+ //#region src/cookie/serialize.d.ts
146
147
  /**
147
- * Serialize a cookie name-value pair into a `Set-Cookie` header string.
148
+ * Stringifies an object into an HTTP `Cookie` header.
149
+ */
150
+ declare function stringifyCookie(cookie: Cookies, options?: CookieStringifyOptions): string;
151
+ /**
152
+ * Serialize data into a cookie header.
153
+ *
154
+ * Serialize a name value pair into a cookie string suitable for
155
+ * http headers. An optional options object specifies cookie parameters.
148
156
  *
149
- * @param name the name for the cookie
150
- * @param value value to set the cookie to
151
- * @param [options] object containing serialization options
152
- * @throws {TypeError} when `maxAge` options is invalid
157
+ * serialize('foo', 'bar', { httpOnly: true })
158
+ * => "foo=bar; httpOnly"
153
159
  */
154
- declare function serialize(name: string, value: string, options?: CookieSerializeOptions): string;
155
-
160
+ declare function serialize(cookie: SetCookie, options?: CookieStringifyOptions): string;
161
+ declare function serialize(name: string, val: string, options?: CookieSerializeOptions): string;
162
+ //#endregion
163
+ //#region src/set-cookie/types.d.ts
156
164
  interface SetCookieParseOptions {
157
- /**
158
- * Custom decode function to use on cookie values.
159
- *
160
- * By default, `decodeURIComponent` is used.
161
- *
162
- * **Note:** If decoding fails, the original (undecoded) value will be used
163
- */
164
- decode?: false | ((value: string) => string);
165
+ /**
166
+ * Custom decode function to use on cookie values.
167
+ *
168
+ * By default, `decodeURIComponent` is used.
169
+ *
170
+ * **Note:** If decoding fails, the original (undecoded) value will be used
171
+ */
172
+ decode?: false | ((value: string) => string);
165
173
  }
166
- interface SetCookie {
167
- /**
168
- * Cookie name
169
- */
170
- name: string;
171
- /**
172
- * Cookie value
173
- */
174
- value: string;
175
- /**
176
- * Cookie path
177
- */
178
- path?: string | undefined;
179
- /**
180
- * Absolute expiration date for the cookie
181
- */
182
- expires?: Date | undefined;
183
- /**
184
- * Relative max age of the cookie in seconds from when the client receives it (integer or undefined)
185
- *
186
- * Note: when using with express's res.cookie() method, multiply maxAge by 1000 to convert to milliseconds
187
- */
188
- maxAge?: number | undefined;
189
- /**
190
- * Domain for the cookie,
191
- * May begin with "." to indicate the named domain or any subdomain of it
192
- */
193
- domain?: string | undefined;
194
- /**
195
- * Indicates that this cookie should only be sent over HTTPs
196
- */
197
- secure?: boolean | undefined;
198
- /**
199
- * Indicates that this cookie should not be accessible to client-side JavaScript
200
- */
201
- httpOnly?: boolean | undefined;
202
- /**
203
- * Indicates a cookie ought not to be sent along with cross-site requests
204
- */
205
- sameSite?: true | false | "lax" | "strict" | "none" | undefined;
206
- [key: string]: unknown;
174
+ interface SetCookie$1 {
175
+ /**
176
+ * Cookie name
177
+ */
178
+ name: string;
179
+ /**
180
+ * Cookie value
181
+ */
182
+ value: string;
183
+ /**
184
+ * Cookie path
185
+ */
186
+ path?: string | undefined;
187
+ /**
188
+ * Absolute expiration date for the cookie
189
+ */
190
+ expires?: Date | undefined;
191
+ /**
192
+ * Relative max age of the cookie in seconds from when the client receives it (integer or undefined)
193
+ *
194
+ * Note: when using with express's res.cookie() method, multiply maxAge by 1000 to convert to milliseconds
195
+ */
196
+ maxAge?: number | undefined;
197
+ /**
198
+ * Domain for the cookie,
199
+ * May begin with "." to indicate the named domain or any subdomain of it
200
+ */
201
+ domain?: string | undefined;
202
+ /**
203
+ * Indicates that this cookie should only be sent over HTTPs
204
+ */
205
+ secure?: boolean | undefined;
206
+ /**
207
+ * Indicates that this cookie should not be accessible to client-side JavaScript
208
+ */
209
+ httpOnly?: boolean | undefined;
210
+ /**
211
+ * Indicates a cookie ought not to be sent along with cross-site requests
212
+ */
213
+ sameSite?: true | false | "lax" | "strict" | "none" | undefined;
214
+ /**
215
+ * Indicates that the cookie should be stored using partitioned storage
216
+ *
217
+ * See https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
218
+ */
219
+ partitioned?: boolean | undefined;
220
+ /**
221
+ * Indicates the priority of the cookie
222
+ *
223
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#prioritylow_medium_high
224
+ */
225
+ priority?: "low" | "medium" | "high" | undefined;
226
+ [key: string]: unknown;
207
227
  }
208
-
228
+ //#endregion
229
+ //#region src/set-cookie/parse.d.ts
209
230
  /**
210
231
  * Parse a [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) header string into an object.
211
232
  */
212
- declare function parseSetCookie(setCookieValue: string, options?: SetCookieParseOptions): SetCookie;
213
-
233
+ declare function parseSetCookie(str: string, options?: SetCookieParseOptions): SetCookie$1 | undefined;
234
+ //#endregion
235
+ //#region src/set-cookie/split.d.ts
214
236
  /**
215
237
  * Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
216
238
  * that are within a single set-cookie field-value, such as in the Expires portion.
@@ -218,5 +240,5 @@ declare function parseSetCookie(setCookieValue: string, options?: SetCookieParse
218
240
  * See https://tools.ietf.org/html/rfc2616#section-4.2
219
241
  */
220
242
  declare function splitSetCookieString(cookiesString: string | string[]): string[];
221
-
222
- export { type CookieParseOptions, type CookieSerializeOptions, type SetCookie, type SetCookieParseOptions, parse, parseSetCookie, serialize, splitSetCookieString };
243
+ //#endregion
244
+ export { type CookieParseOptions, type CookieSerializeOptions, type CookieStringifyOptions, type Cookies, type MultiCookies, type SetCookie, type SetCookieParseOptions, parse, parse as parseCookie, parseSetCookie, serialize, serialize as serializeCookie, splitSetCookieString, stringifyCookie };