|
| 1 | +// imported from `cookie@1.0.2` (https://www.npmjs.com/package/cookie/v/1.0.2) |
| 2 | + |
| 3 | +/** |
| 4 | + * Serialize options. |
| 5 | + */ |
| 6 | +export interface CookieSerializeOptions { |
| 7 | + /** |
| 8 | + * Specifies a function that will be used to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). |
| 9 | + * Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode |
| 10 | + * a value into a string suited for a cookie's value, and should mirror `decode` when parsing. |
| 11 | + * |
| 12 | + * @default encodeURIComponent |
| 13 | + */ |
| 14 | + encode?: (str: string) => string; |
| 15 | + /** |
| 16 | + * 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). |
| 17 | + * |
| 18 | + * The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and |
| 19 | + * `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this, |
| 20 | + * so if both are set, they should point to the same date and time. |
| 21 | + */ |
| 22 | + maxAge?: number; |
| 23 | + /** |
| 24 | + * Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1). |
| 25 | + * When no expiration is set clients consider this a "non-persistent cookie" and delete it the current session is over. |
| 26 | + * |
| 27 | + * The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and |
| 28 | + * `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this, |
| 29 | + * so if both are set, they should point to the same date and time. |
| 30 | + */ |
| 31 | + expires?: Date; |
| 32 | + /** |
| 33 | + * Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3). |
| 34 | + * When no domain is set clients consider the cookie to apply to the current domain only. |
| 35 | + */ |
| 36 | + domain?: string; |
| 37 | + /** |
| 38 | + * Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4). |
| 39 | + * When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4). |
| 40 | + */ |
| 41 | + path?: string; |
| 42 | + /** |
| 43 | + * Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6). |
| 44 | + * When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`. |
| 45 | + */ |
| 46 | + httpOnly?: boolean; |
| 47 | + /** |
| 48 | + * Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5). |
| 49 | + * When enabled, clients will only send the cookie back if the browser has a HTTPS connection. |
| 50 | + */ |
| 51 | + secure?: boolean; |
| 52 | + /** |
| 53 | + * Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/). |
| 54 | + * When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches. |
| 55 | + * |
| 56 | + * This is an attribute that has not yet been fully standardized, and may change in the future. |
| 57 | + * This also means clients may ignore this attribute until they understand it. More information |
| 58 | + * about can be found in [the proposal](https://github.com/privacycg/CHIPS). |
| 59 | + */ |
| 60 | + partitioned?: boolean; |
| 61 | + /** |
| 62 | + * Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-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 priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1). |
| 69 | + */ |
| 70 | + priority?: "low" | "medium" | "high"; |
| 71 | + /** |
| 72 | + * Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7). |
| 73 | + * |
| 74 | + * - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement. |
| 75 | + * - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement. |
| 76 | + * - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie. |
| 77 | + * - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement. |
| 78 | + * |
| 79 | + * 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). |
| 80 | + */ |
| 81 | + sameSite?: boolean | "lax" | "strict" | "none"; |
| 82 | +} |
0 commit comments