[]previous and next page

createCookieSigner

Creates a signer.

Creates a signer. The first secret signs; every secret verifies, so a secret can be rotated by putting the new one first and keeping the old one until its cookies expire. The signature covers the cookie name too, so a value cannot be moved to another cookie.

Import#

ts
import { createCookieSigner } from "@shadow-js/dusk/server";

Signature#

ts
function createCookieSigner(secrets: readonly string[]): CookieSigner

Parameters#

Name Description
secrets One or more secrets of at least 32 characters.

Returns#

The signer.

Throws#

  • Error with code COOKIE_SECRET_MISSING or COOKIE_SECRET_WEAK.

Examples#

ts
const signer = createCookieSigner([process.env.COOKIE_SECRET]);
const cookie = await signer.sign("sid", "abc");