UNPKG

@taxum/cookie

Version:
45 lines (44 loc) 1.5 kB
import type { Cookie } from "./cookie.js"; /** * A child cookie jar that authenticates its cookies. * * A _signed_ child jar signs all the cookies added to it and verifies cookies * retrieved from it. Any cookies stored in the `SignedJar` are provided * integrity and authenticity. In other words, clients cannot tamper with the * contents of a cookie, nor can they fabricate cookie values, but the data is * visible in plaintext. */ export declare class SignedJar { private readonly parent; private readonly key; /** * Returns a {@link Cookie} with the name `name` from the parent jar. * * It verifies the authenticity and integrity of the cookie's value, * returning a `Cookie` with the authenticated value. If the cookie cannot * be found, or the cookie fails to verify, `null` is returned. * * @see {@link CookieJar.get} */ get(name: string): Cookie | null; /** * Adds a {@link Cookie} to the parent jar. * * The cookie's value is signed assuring integrity and authenticity. * * @see {@link CookieJar.add} */ add(cookie: Cookie): void; /** * Removes a {@link Cookie} from the parent jar. * * For correct removal, the passed in `cookie` must contain the same `path` * and `domain` as the cookie that was initially set. * * @see {@link CookieJar.remove} */ remove(cookie: Cookie): void; private sign; private verify; private verifyValue; }