| 1 |
|
| 2 | import { CookieParseOptions as CookieParseOptions$1, CookieSerializeOptions as CookieSerializeOptions$1 } from "cookie-es";
|
| 3 |
|
| 4 | //#region lib/server-runtime/cookies.d.ts
|
| 5 | interface CookieSignatureOptions {
|
| 6 | /**
|
| 7 | * An array of secrets that may be used to sign/unsign the value of a cookie.
|
| 8 | *
|
| 9 | * The array makes it easy to rotate secrets. New secrets should be added to
|
| 10 | * the beginning of the array. `cookie.serialize()` will always use the first
|
| 11 | * value in the array, but `cookie.parse()` may use any of them so that
|
| 12 | * cookies that were signed with older secrets still work.
|
| 13 | */
|
| 14 | secrets?: string[];
|
| 15 | }
|
| 16 | type CookieOptions = CookieParseOptions$1 & CookieSerializeOptions$1 & CookieSignatureOptions;
|
| 17 | /**
|
| 18 | * A HTTP cookie.
|
| 19 | *
|
| 20 | * A Cookie is a logical container for metadata about a HTTP cookie; its name
|
| 21 | * and options. But it doesn't contain a value. Instead, it has `parse()` and
|
| 22 | * `serialize()` methods that allow a single instance to be reused for
|
| 23 | * parsing/encoding multiple different values.
|
| 24 | *
|
| 25 | * @see https://remix.run/utils/cookies#cookie-api
|
| 26 | */
|
| 27 | interface Cookie {
|
| 28 | /**
|
| 29 | * The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
|
| 30 | */
|
| 31 | readonly name: string;
|
| 32 | /**
|
| 33 | * True if this cookie uses one or more secrets for verification.
|
| 34 | */
|
| 35 | readonly isSigned: boolean;
|
| 36 | /**
|
| 37 | * The Date this cookie expires.
|
| 38 | *
|
| 39 | * Note: This is calculated at access time using `maxAge` when no `expires`
|
| 40 | * option is provided to `createCookie()`.
|
| 41 | */
|
| 42 | readonly expires?: Date;
|
| 43 | /**
|
| 44 | * Parses a raw `Cookie` header and returns the value of this cookie or
|
| 45 | * `null` if it's not present.
|
| 46 | */
|
| 47 | parse(cookieHeader: string | null, options?: CookieParseOptions$1): Promise<any>;
|
| 48 | /**
|
| 49 | * Serializes the given value to a string and returns the `Set-Cookie`
|
| 50 | * header.
|
| 51 | */
|
| 52 | serialize(value: any, options?: CookieSerializeOptions$1): Promise<string>;
|
| 53 | }
|
| 54 | /**
|
| 55 | * Creates a logical container for managing a browser cookie from the server.
|
| 56 | */
|
| 57 | declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
|
| 58 | type IsCookieFunction = (object: any) => object is Cookie;
|
| 59 | /**
|
| 60 | * Returns true if an object is a Remix cookie container.
|
| 61 | *
|
| 62 | * @see https://remix.run/utils/cookies#iscookie
|
| 63 | */
|
| 64 | declare const isCookie: IsCookieFunction;
|
| 65 | //#endregion
|
| 66 | export { Cookie, CookieOptions, type CookieParseOptions$1 as CookieParseOptions, type CookieSerializeOptions$1 as CookieSerializeOptions, CookieSignatureOptions, IsCookieFunction, createCookie, isCookie }; |
| \ | No newline at end of file |