iron-session 7.0.6 → 8.0.0-beta.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../node_modules/.pnpm/cookie@0.6.0/node_modules/cookie/index.js","../src/core.ts","../node_modules/.pnpm/iron-webcrypto@1.0.0/node_modules/iron-webcrypto/dist/index.js","../src/index.ts"],"names":["parse","serialize","decode","seal","sealData","unsealData","getIronSession","getServerActionIronSession"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAcA,YAAQ,QAAQA;AAChB,YAAQ,YAAYC;AAOpB,QAAI,aAAa,OAAO,UAAU;AAUlC,QAAI,qBAAqB;AAczB,aAASD,OAAM,KAAK,SAAS;AAC3B,UAAI,OAAO,QAAQ,UAAU;AAC3B,cAAM,IAAI,UAAU,+BAA+B;AAAA,MACrD;AAEA,UAAI,MAAM,CAAC;AACX,UAAI,MAAM,WAAW,CAAC;AACtB,UAAI,MAAM,IAAI,UAAU;AAExB,UAAI,QAAQ;AACZ,aAAO,QAAQ,IAAI,QAAQ;AACzB,YAAI,QAAQ,IAAI,QAAQ,KAAK,KAAK;AAGlC,YAAI,UAAU,IAAI;AAChB;AAAA,QACF;AAEA,YAAI,SAAS,IAAI,QAAQ,KAAK,KAAK;AAEnC,YAAI,WAAW,IAAI;AACjB,mBAAS,IAAI;AAAA,QACf,WAAW,SAAS,OAAO;AAEzB,kBAAQ,IAAI,YAAY,KAAK,QAAQ,CAAC,IAAI;AAC1C;AAAA,QACF;AAEA,YAAI,MAAM,IAAI,MAAM,OAAO,KAAK,EAAE,KAAK;AAGvC,YAAI,WAAc,IAAI,GAAG,GAAG;AAC1B,cAAI,MAAM,IAAI,MAAM,QAAQ,GAAG,MAAM,EAAE,KAAK;AAG5C,cAAI,IAAI,WAAW,CAAC,MAAM,IAAM;AAC9B,kBAAM,IAAI,MAAM,GAAG,EAAE;AAAA,UACv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AAgB,IAAI,QAAQ;AAClC,cAAY,QAAQ,CAAC,YAAY;AAC/B,QAAI,QAAQ,OAAO,EAAE,QAAQ,CAAC,OAAO,QAAQ;AAC3C,oBAAc,OAAO,KAAK,KAAK;AAAA,IACjC,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAEO,SAAS,eACd,kBACA,YACA,SACU;AACV,SAAO,IAAI,SAAS,YAAY;AAAA,IAC9B,QAAQ,SAAS,UAAU,iBAAiB;AAAA,IAC5C,YAAY,SAAS,cAAc,iBAAiB;AAAA,IACpD,SAAS,aAAa,SAAS,SAAS,iBAAiB,OAAO;AAAA,EAClE,CAAC;AACH;;;AE5gBO,IAAM,WAAW,eAAe;AAChC,IAAM,aAAa,iBAAiB;AACpC,IAAM,iBAAiB,qBAAqB,UAAU,UAAU;AAChE,IAAM,6BAA6B;AAAA,EACxC;AAAA,EACA;AACF","sourcesContent":["/*!\n * cookie\n * Copyright(c) 2012-2014 Roman Shtylman\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module exports.\n * @public\n */\n\nexports.parse = parse;\nexports.serialize = serialize;\n\n/**\n * Module variables.\n * @private\n */\n\nvar __toString = Object.prototype.toString\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\n\nvar fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\n/**\n * Parse a cookie header.\n *\n * Parse the given cookie header string into an object\n * The object has the various cookies as keys(names) => values\n *\n * @param {string} str\n * @param {object} [options]\n * @return {object}\n * @public\n */\n\nfunction parse(str, options) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {}\n var opt = options || {};\n var dec = opt.decode || decode;\n\n var index = 0\n while (index < str.length) {\n var eqIdx = str.indexOf('=', index)\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break\n }\n\n var endIdx = str.indexOf(';', index)\n\n if (endIdx === -1) {\n endIdx = str.length\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1\n continue\n }\n\n var key = str.slice(index, eqIdx).trim()\n\n // only assign once\n if (undefined === obj[key]) {\n var val = str.slice(eqIdx + 1, endIdx).trim()\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1)\n }\n\n obj[key] = tryDecode(val, dec);\n }\n\n index = endIdx + 1\n }\n\n return obj;\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * serialize('foo', 'bar', { httpOnly: true })\n * => \"foo=bar; httpOnly\"\n *\n * @param {string} name\n * @param {string} val\n * @param {object} [options]\n * @return {string}\n * @public\n */\n\nfunction serialize(name, val, options) {\n var opt = options || {};\n var enc = opt.encode || encode;\n\n if (typeof enc !== 'function') {\n throw new TypeError('option encode is invalid');\n }\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n var value = enc(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n var str = name + '=' + value;\n\n if (null != opt.maxAge) {\n var maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid')\n }\n\n str += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n str += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n str += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n var expires = opt.expires\n\n if (!isDate(expires) || isNaN(expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n str += '; Expires=' + expires.toUTCString()\n }\n\n if (opt.httpOnly) {\n str += '; HttpOnly';\n }\n\n if (opt.secure) {\n str += '; Secure';\n }\n\n if (opt.partitioned) {\n str += '; Partitioned'\n }\n\n if (opt.priority) {\n var priority = typeof opt.priority === 'string'\n ? opt.priority.toLowerCase()\n : opt.priority\n\n switch (priority) {\n case 'low':\n str += '; Priority=Low'\n break\n case 'medium':\n str += '; Priority=Medium'\n break\n case 'high':\n str += '; Priority=High'\n break\n default:\n throw new TypeError('option priority is invalid')\n }\n }\n\n if (opt.sameSite) {\n var sameSite = typeof opt.sameSite === 'string'\n ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n str += '; SameSite=Strict';\n break;\n case 'lax':\n str += '; SameSite=Lax';\n break;\n case 'strict':\n str += '; SameSite=Strict';\n break;\n case 'none':\n str += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return str;\n}\n\n/**\n * URL-decode string value. Optimized to skip native call when no %.\n *\n * @param {string} str\n * @returns {string}\n */\n\nfunction decode (str) {\n return str.indexOf('%') !== -1\n ? decodeURIComponent(str)\n : str\n}\n\n/**\n * URL-encode value.\n *\n * @param {string} val\n * @returns {string}\n */\n\nfunction encode (val) {\n return encodeURIComponent(val)\n}\n\n/**\n * Determine if value is a Date.\n *\n * @param {*} val\n * @private\n */\n\nfunction isDate (val) {\n return __toString.call(val) === '[object Date]' ||\n val instanceof Date\n}\n\n/**\n * Try decoding a string using a decoding function.\n *\n * @param {string} str\n * @param {function} decode\n * @private\n */\n\nfunction tryDecode(str, decode) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n","import type { IncomingMessage, ServerResponse } from \"http\";\nimport { parse, serialize, type CookieSerializeOptions } from \"cookie\";\nimport {\n defaults as ironDefaults,\n seal as ironSeal,\n unseal as ironUnseal,\n} from \"iron-webcrypto\";\n\ntype PasswordsMap = Record<string, string>;\ntype Password = PasswordsMap | string;\n\ntype RequestType = IncomingMessage | Request;\ntype ResponseType = Response | ServerResponse;\n\n/**\n * {@link https://wicg.github.io/cookie-store/#dictdef-cookielistitem CookieListItem}\n * as specified by W3C.\n */\ninterface CookieListItem\n extends Pick<\n CookieSerializeOptions,\n \"domain\" | \"path\" | \"sameSite\" | \"secure\"\n > {\n /** A string with the name of a cookie. */\n name: string;\n /** A string containing the value of the cookie. */\n value: string;\n /** A number of milliseconds or Date interface containing the expires of the cookie. */\n expires?: CookieSerializeOptions[\"expires\"] | number;\n}\n\n/**\n * Superset of {@link CookieListItem} extending it with\n * the `httpOnly`, `maxAge` and `priority` properties.\n */\ntype ResponseCookie = CookieListItem &\n Pick<CookieSerializeOptions, \"httpOnly\" | \"maxAge\" | \"priority\">;\n\n/**\n * The high-level type definition of the .get() and .set() methods\n * of { cookies() } from \"next/headers\"\n */\nexport interface ICookieHandler {\n get: (name: string) => { name: string; value: string } | undefined;\n set: {\n (name: string, value: string, cookie?: Partial<ResponseCookie>): void;\n (options: ResponseCookie): void;\n };\n}\n\n/**\n * Set-Cookie Attributes do not include `encode`. We omit this from our `cookieOptions` type.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie\n * @see https://developer.chrome.com/docs/devtools/application/cookies/\n */\ntype CookieOptions = Omit<CookieSerializeOptions, \"encode\">;\n\nexport interface IronSessionOptions {\n /**\n * The cookie name that will be used inside the browser. Make sure it's unique\n * given your application.\n *\n * @example 'vercel-session'\n */\n cookieName: string;\n\n /**\n * The password(s) that will be used to encrypt the cookie. Can either be a string\n * or an object.\n *\n * When you provide multiple passwords then all of them will be used to decrypt\n * the cookie. But only the most recent (`= highest key`, `2` in the example)\n * password will be used to encrypt the cookie. This allows password rotation.\n *\n * @example { 1: 'password-1', 2: 'password-2' }\n */\n password: Password;\n\n /**\n * The time (in seconds) that the session will be valid for. Also sets the\n * `max-age` attribute of the cookie automatically (`= ttl - 60s`, so that the\n * cookie always expire before the session).\n *\n * `ttl = 0` means no expiration.\n *\n * @default 1209600\n */\n ttl?: number;\n\n /**\n * The options that will be passed to the cookie library.\n *\n * If you want to use \"session cookies\" (cookies that are deleted when the browser\n * is closed) then you need to pass `cookieOptions: { maxAge: undefined }`\n *\n * @see https://github.com/jshttp/cookie#options-1\n */\n cookieOptions?: CookieOptions;\n}\n\ntype OverridableOptions = Pick<IronSessionOptions, \"cookieOptions\" | \"ttl\">;\n\nexport type IronSession<T> = T & {\n /**\n * Destroys the session data and removes the cookie.\n */\n readonly destroy: (destroyOptions?: OverridableOptions) => Promise<void>;\n\n /**\n * Encrypts the session data and sets the cookie.\n */\n readonly save: (saveOptions?: OverridableOptions) => Promise<void>;\n};\n\n// default time allowed to check for iron seal validity when ttl passed\n// see https://hapi.dev/module/iron/api/?v=7.0.1#options\nconst timestampSkewSec = 60;\nconst fourteenDaysInSeconds = 14 * 24 * 3600;\n\n// We store a token major version to handle data format changes so that the cookies\n// can be kept alive between upgrades, no need to disconnect everyone.\nconst currentMajorVersion = 2;\nconst versionDelimiter = \"~\";\n\nconst defaultOptions: Required<OverridableOptions> = {\n ttl: fourteenDaysInSeconds,\n cookieOptions: { httpOnly: true, secure: true, sameSite: \"lax\", path: \"/\" },\n};\n\nfunction normalizeStringPasswordToMap(password: Password): PasswordsMap {\n return typeof password === \"string\" ? { 1: password } : password;\n}\n\nfunction parseSeal(seal: string): {\n sealWithoutVersion: string;\n tokenVersion: number | null;\n} {\n const [sealWithoutVersion, tokenVersionAsString] =\n seal.split(versionDelimiter);\n const tokenVersion =\n tokenVersionAsString == null ? null : parseInt(tokenVersionAsString, 10);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return { sealWithoutVersion: sealWithoutVersion!, tokenVersion };\n}\n\nfunction computeCookieMaxAge(ttl: number): number {\n if (ttl === 0) {\n // ttl = 0 means no expiration\n // but in reality cookies have to expire (can't have no max-age)\n // 2147483647 is the max value for max-age in cookies\n // see https://stackoverflow.com/a/11685301/147079\n return 2147483647;\n }\n\n // The next line makes sure browser will expire cookies before seals are considered expired by the server.\n // It also allows for clock difference of 60 seconds between server and clients.\n return ttl - timestampSkewSec;\n}\n\nfunction getCookie(req: RequestType, cookieName: string): string {\n return (\n parse(\n (\"headers\" in req && typeof req.headers.get === \"function\"\n ? req.headers.get(\"cookie\")\n : (req as IncomingMessage).headers.cookie) ?? \"\",\n )[cookieName] ?? \"\"\n );\n}\n\nfunction getServerActionCookie(\n cookieName: string,\n cookieHandler: ICookieHandler,\n): string {\n const cookieObject = cookieHandler.get(cookieName);\n const cookie = cookieObject?.value;\n if (typeof cookie === \"string\") {\n return cookie;\n }\n return \"\";\n}\n\nfunction setCookie(res: ResponseType, cookieValue: string): void {\n if (\"headers\" in res && typeof res.headers.append === \"function\") {\n res.headers.append(\"set-cookie\", cookieValue);\n return;\n }\n let existingSetCookie = (res as ServerResponse).getHeader(\"set-cookie\") ?? [];\n if (!Array.isArray(existingSetCookie)) {\n existingSetCookie = [existingSetCookie.toString()];\n }\n (res as ServerResponse).setHeader(\"set-cookie\", [\n ...existingSetCookie,\n cookieValue,\n ]);\n}\n\nexport function createSealData(_crypto: Crypto = globalThis.crypto) {\n return async function sealData(\n data: unknown,\n {\n password,\n ttl = fourteenDaysInSeconds,\n }: { password: Password; ttl?: number },\n ): Promise<string> {\n const passwordsMap = normalizeStringPasswordToMap(password);\n\n const mostRecentPasswordId = Math.max(\n ...Object.keys(passwordsMap).map(Number),\n );\n const passwordForSeal = {\n id: mostRecentPasswordId.toString(),\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n secret: passwordsMap[mostRecentPasswordId]!,\n };\n\n const seal = await ironSeal(_crypto, data, passwordForSeal, {\n ...ironDefaults,\n ttl: ttl * 1000,\n });\n\n return `${seal}${versionDelimiter}${currentMajorVersion}`;\n };\n}\n\nexport function createUnsealData(_crypto: Crypto = globalThis.crypto) {\n // eslint-disable-next-line @typescript-eslint/ban-types\n return async function unsealData<T extends {} = {}>(\n seal: string,\n {\n password,\n ttl = fourteenDaysInSeconds,\n }: { password: Password; ttl?: number },\n ): Promise<T> {\n const passwordsMap = normalizeStringPasswordToMap(password);\n const { sealWithoutVersion, tokenVersion } = parseSeal(seal);\n\n try {\n const data =\n (await ironUnseal(_crypto, sealWithoutVersion, passwordsMap, {\n ...ironDefaults,\n ttl: ttl * 1000,\n })) /* c8 ignore next */ ?? {};\n\n if (tokenVersion === 2) {\n return data as T;\n }\n\n // @ts-expect-error `persistent` does not exist on newer tokens\n return { ...data.persistent } as T;\n } catch (error) {\n if (\n error instanceof Error &&\n /^(Expired seal|Bad hmac value|Cannot find password|Incorrect number of sealed components)/.test(\n error.message,\n )\n ) {\n // if seal expired or\n // if seal is not valid (encrypted using a different password, when passwords are badly rotated) or\n // if we can't find back the password in the seal\n // then we just start a new session over\n return {} as T;\n }\n\n /* c8 ignore next 2 */\n throw error;\n }\n };\n}\n\nfunction mergeOptions(\n userSessionOptions: IronSessionOptions,\n overrides?: OverridableOptions,\n): Required<IronSessionOptions> {\n const options: Required<IronSessionOptions> = {\n ...defaultOptions,\n ...userSessionOptions,\n ...overrides,\n cookieOptions: {\n ...defaultOptions.cookieOptions,\n ...userSessionOptions.cookieOptions,\n ...overrides?.cookieOptions,\n },\n };\n\n if (\n userSessionOptions.cookieOptions &&\n \"maxAge\" in userSessionOptions.cookieOptions\n ) {\n if (userSessionOptions.cookieOptions.maxAge === undefined) {\n // session cookies, do not set maxAge, consider token as infinite\n options.ttl = 0;\n }\n } else {\n options.cookieOptions.maxAge = computeCookieMaxAge(options.ttl);\n }\n\n return options;\n}\n\nexport function createGetIronSession(\n sealData: ReturnType<typeof createSealData>,\n unsealData: ReturnType<typeof createUnsealData>,\n) {\n // eslint-disable-next-line @typescript-eslint/ban-types\n return async function getIronSession<T extends {} = {}>(\n req: RequestType,\n res: ResponseType,\n userSessionOptions: IronSessionOptions,\n ): Promise<IronSession<T>> {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions\n if (!req) {\n throw new Error(\"iron-session: Bad usage. Missing request parameter.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions\n if (!res) {\n throw new Error(\"iron-session: Bad usage. Missing response parameter.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions\n if (!userSessionOptions) {\n throw new Error(\"iron-session: Bad usage. Missing options.\");\n }\n\n if (!userSessionOptions.cookieName) {\n throw new Error(\"iron-session: Bad usage. Missing cookie name.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (!userSessionOptions.password) {\n throw new Error(\"iron-session: Bad usage. Missing password.\");\n }\n\n const passwordsMap = normalizeStringPasswordToMap(\n userSessionOptions.password,\n );\n if (Object.values(passwordsMap).some((password) => password.length < 32)) {\n throw new Error(\n \"iron-session: Bad usage. Password must be at least 32 characters long.\",\n );\n }\n\n const options = mergeOptions(userSessionOptions);\n const sealFromCookies = getCookie(req, options.cookieName);\n const session = sealFromCookies\n ? await unsealData<T>(sealFromCookies, {\n password: passwordsMap,\n ttl: options.ttl,\n })\n : ({} as T);\n\n Object.defineProperties(session, {\n save: {\n value: async function save(saveOptions?: OverridableOptions) {\n if (\"headersSent\" in res && res.headersSent) {\n throw new Error(\n \"iron-session: Cannot set session cookie: session.save() was called after headers were sent. Make sure to call it before any res.send() or res.end()\",\n );\n }\n\n const mergedOptions = mergeOptions(userSessionOptions, saveOptions);\n const seal = await sealData(session, {\n password: passwordsMap,\n ttl: mergedOptions.ttl,\n });\n const cookieValue = serialize(\n mergedOptions.cookieName,\n seal,\n mergedOptions.cookieOptions,\n );\n\n if (cookieValue.length > 4096) {\n throw new Error(\n `iron-session: Cookie length is too big (${cookieValue.length} bytes), browsers will refuse it. Try to remove some data.`,\n );\n }\n\n setCookie(res, cookieValue);\n },\n },\n\n destroy: {\n value: async function destroy(destroyOptions?: OverridableOptions) {\n Object.keys(session).forEach((key) => {\n // @ts-expect-error ...\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete session[key];\n });\n\n const mergedOptions = mergeOptions(\n userSessionOptions,\n destroyOptions,\n );\n const cookieValue = serialize(mergedOptions.cookieName, \"\", {\n ...mergedOptions.cookieOptions,\n maxAge: 0,\n });\n\n setCookie(res, cookieValue);\n },\n },\n });\n\n return session as IronSession<T>;\n };\n}\n\nexport function createGetServerActionIronSession(\n sealData: ReturnType<typeof createSealData>,\n unsealData: ReturnType<typeof createUnsealData>,\n) {\n // eslint-disable-next-line @typescript-eslint/ban-types\n return async function getServerActionIronSession<T extends {} = {}>(\n userSessionOptions: IronSessionOptions,\n cookieHandler: ICookieHandler,\n ): Promise<IronSession<T>> {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions\n if (!userSessionOptions) {\n throw new Error(\"iron-session: Bad usage. Missing options.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions\n if (!cookieHandler) {\n throw new Error(\n \"iron-session: Bad usage. Missing NextJS cookies() handler.\",\n );\n }\n\n if (!userSessionOptions.cookieName) {\n throw new Error(\"iron-session: Bad usage. Missing cookie name.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (!userSessionOptions.password) {\n throw new Error(\"iron-session: Bad usage. Missing password.\");\n }\n\n const passwordsMap = normalizeStringPasswordToMap(\n userSessionOptions.password,\n );\n if (Object.values(passwordsMap).some((password) => password.length < 32)) {\n throw new Error(\n \"iron-session: Bad usage. Password must be at least 32 characters long.\",\n );\n }\n\n const options = mergeOptions(userSessionOptions);\n const sealFromCookies = getServerActionCookie(\n options.cookieName,\n cookieHandler,\n );\n const session = sealFromCookies\n ? await unsealData<T>(sealFromCookies, {\n password: passwordsMap,\n ttl: options.ttl,\n })\n : ({} as T);\n\n Object.defineProperties(session, {\n save: {\n value: async function save(saveOptions?: OverridableOptions) {\n const mergedOptions = mergeOptions(userSessionOptions, saveOptions);\n const seal = await sealData(session, {\n password: passwordsMap,\n ttl: mergedOptions.ttl,\n });\n\n const cookieLength =\n mergedOptions.cookieName.length +\n seal.length +\n JSON.stringify(mergedOptions.cookieOptions).length;\n\n if (cookieLength > 4096) {\n throw new Error(\n `iron-session: Cookie length is too big (${cookieLength} bytes), browsers will refuse it. Try to remove some data.`,\n );\n }\n\n cookieHandler.set(\n mergedOptions.cookieName,\n seal,\n mergedOptions.cookieOptions,\n );\n },\n },\n\n destroy: {\n value: async function destroy(destroyOptions: OverridableOptions) {\n Object.keys(session).forEach((key) => {\n // @ts-expect-error ...\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete session[key];\n });\n const mergedOptions = mergeOptions(\n userSessionOptions,\n destroyOptions,\n );\n const cookieOptions = { ...mergedOptions.cookieOptions, maxAge: 0 };\n\n cookieHandler.set(mergedOptions.cookieName, \"\", cookieOptions);\n },\n },\n });\n\n return session as IronSession<T>;\n };\n}\n\nexport function mergeHeaders(\n ...headersList: (HeadersInit | undefined)[]\n): Headers {\n const mergedHeaders = new Headers();\n headersList.forEach((headers) => {\n new Headers(headers).forEach((value, key) => {\n mergedHeaders.append(key, value);\n });\n });\n return mergedHeaders;\n}\n\nexport function createResponse(\n originalResponse: Response,\n bodyString: string,\n options?: ResponseInit,\n): Response {\n return new Response(bodyString, {\n status: options?.status ?? originalResponse.status,\n statusText: options?.statusText ?? originalResponse.statusText,\n headers: mergeHeaders(options?.headers, originalResponse.headers),\n });\n}\n","// node_modules/.pnpm/@smithy+util-base64@2.0.0/node_modules/@smithy/util-base64/dist-es/constants.browser.js\nvar alphabetByEncoding = {};\nvar alphabetByValue = new Array(64);\nfor (let i = 0, start = \"A\".charCodeAt(0), limit = \"Z\".charCodeAt(0); i + start <= limit; i++) {\n const char = String.fromCharCode(i + start);\n alphabetByEncoding[char] = i;\n alphabetByValue[i] = char;\n}\nfor (let i = 0, start = \"a\".charCodeAt(0), limit = \"z\".charCodeAt(0); i + start <= limit; i++) {\n const char = String.fromCharCode(i + start);\n const index = i + 26;\n alphabetByEncoding[char] = index;\n alphabetByValue[index] = char;\n}\nfor (let i = 0; i < 10; i++) {\n alphabetByEncoding[i.toString(10)] = i + 52;\n const char = i.toString(10);\n const index = i + 52;\n alphabetByEncoding[char] = index;\n alphabetByValue[index] = char;\n}\nalphabetByEncoding[\"+\"] = 62;\nalphabetByValue[62] = \"+\";\nalphabetByEncoding[\"/\"] = 63;\nalphabetByValue[63] = \"/\";\nvar bitsPerLetter = 6;\nvar bitsPerByte = 8;\nvar maxLetterValue = 63;\n\n// node_modules/.pnpm/@smithy+util-base64@2.0.0/node_modules/@smithy/util-base64/dist-es/fromBase64.browser.js\nvar fromBase64 = (input) => {\n let totalByteLength = input.length / 4 * 3;\n if (input.slice(-2) === \"==\") {\n totalByteLength -= 2;\n } else if (input.slice(-1) === \"=\") {\n totalByteLength--;\n }\n const out = new ArrayBuffer(totalByteLength);\n const dataView = new DataView(out);\n for (let i = 0; i < input.length; i += 4) {\n let bits = 0;\n let bitLength = 0;\n for (let j = i, limit = i + 3; j <= limit; j++) {\n if (input[j] !== \"=\") {\n if (!(input[j] in alphabetByEncoding)) {\n throw new TypeError(`Invalid character ${input[j]} in base64 string.`);\n }\n bits |= alphabetByEncoding[input[j]] << (limit - j) * bitsPerLetter;\n bitLength += bitsPerLetter;\n } else {\n bits >>= bitsPerLetter;\n }\n }\n const chunkOffset = i / 4 * 3;\n bits >>= bitLength % bitsPerByte;\n const byteLength = Math.floor(bitLength / bitsPerByte);\n for (let k = 0; k < byteLength; k++) {\n const offset = (byteLength - k - 1) * bitsPerByte;\n dataView.setUint8(chunkOffset + k, (bits & 255 << offset) >> offset);\n }\n }\n return new Uint8Array(out);\n};\n\n// node_modules/.pnpm/@smithy+util-base64@2.0.0/node_modules/@smithy/util-base64/dist-es/toBase64.browser.js\nfunction toBase64(input) {\n let str = \"\";\n for (let i = 0; i < input.length; i += 3) {\n let bits = 0;\n let bitLength = 0;\n for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) {\n bits |= input[j] << (limit - j - 1) * bitsPerByte;\n bitLength += bitsPerByte;\n }\n const bitClusterCount = Math.ceil(bitLength / bitsPerLetter);\n bits <<= bitClusterCount * bitsPerLetter - bitLength;\n for (let k = 1; k <= bitClusterCount; k++) {\n const offset = (bitClusterCount - k) * bitsPerLetter;\n str += alphabetByValue[(bits & maxLetterValue << offset) >> offset];\n }\n str += \"==\".slice(0, 4 - bitClusterCount);\n }\n return str;\n}\n\n// src/index.ts\nvar stringToBuffer = (value) => {\n return new TextEncoder().encode(value);\n};\nvar bufferToString = (value) => {\n return new TextDecoder().decode(value);\n};\nvar base64urlEncode = (value) => toBase64(typeof value === \"string\" ? stringToBuffer(value) : value).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=/g, \"\");\nvar base64urlDecode = (value) => fromBase64(\n value.replace(/-/g, \"+\").replace(/_/g, \"/\") + Array((4 - value.length % 4) % 4 + 1).join(\"=\")\n);\nvar defaults = {\n encryption: { saltBits: 256, algorithm: \"aes-256-cbc\", iterations: 1, minPasswordlength: 32 },\n integrity: { saltBits: 256, algorithm: \"sha256\", iterations: 1, minPasswordlength: 32 },\n ttl: 0,\n timestampSkewSec: 60,\n localtimeOffsetMsec: 0\n};\nvar clone = (options) => ({\n ...options,\n encryption: { ...options.encryption },\n integrity: { ...options.integrity }\n});\nvar algorithms = {\n \"aes-128-ctr\": { keyBits: 128, ivBits: 128, name: \"AES-CTR\" },\n \"aes-256-cbc\": { keyBits: 256, ivBits: 128, name: \"AES-CBC\" },\n sha256: { keyBits: 256, name: \"SHA-256\" }\n};\nvar macFormatVersion = \"2\";\nvar macPrefix = `Fe26.${macFormatVersion}`;\nvar randomBytes = (_crypto, size) => {\n const bytes = new Uint8Array(size);\n _crypto.getRandomValues(bytes);\n return bytes;\n};\nvar randomBits = (_crypto, bits) => {\n if (bits < 1)\n throw Error(\"Invalid random bits count\");\n const bytes = Math.ceil(bits / 8);\n return randomBytes(_crypto, bytes);\n};\nvar pbkdf2 = async (_crypto, password, salt, iterations, keyLength, hash) => {\n const passwordBuffer = stringToBuffer(password);\n const importedKey = await _crypto.subtle.importKey(\"raw\", passwordBuffer, \"PBKDF2\", false, [\n \"deriveBits\"\n ]);\n const saltBuffer = stringToBuffer(salt);\n const params = { name: \"PBKDF2\", hash, salt: saltBuffer, iterations };\n const derivation = await _crypto.subtle.deriveBits(params, importedKey, keyLength * 8);\n return derivation;\n};\nvar generateKey = async (_crypto, password, options) => {\n var _a;\n if (!(password == null ? void 0 : password.length))\n throw new Error(\"Empty password\");\n if (options == null || typeof options !== \"object\")\n throw new Error(\"Bad options\");\n if (!(options.algorithm in algorithms))\n throw new Error(`Unknown algorithm: ${options.algorithm}`);\n const algorithm = algorithms[options.algorithm];\n const result = {};\n const hmac = (_a = options.hmac) != null ? _a : false;\n const id = hmac ? { name: \"HMAC\", hash: algorithm.name } : { name: algorithm.name };\n const usage = hmac ? [\"sign\", \"verify\"] : [\"encrypt\", \"decrypt\"];\n if (typeof password === \"string\") {\n if (password.length < options.minPasswordlength)\n throw new Error(\n `Password string too short (min ${options.minPasswordlength} characters required)`\n );\n let { salt = \"\" } = options;\n if (!salt) {\n const { saltBits = 0 } = options;\n if (!saltBits)\n throw new Error(\"Missing salt and saltBits options\");\n const randomSalt = randomBits(_crypto, saltBits);\n salt = [...new Uint8Array(randomSalt)].map((x) => x.toString(16).padStart(2, \"0\")).join(\"\");\n }\n const derivedKey = await pbkdf2(\n _crypto,\n password,\n salt,\n options.iterations,\n algorithm.keyBits / 8,\n \"SHA-1\"\n );\n const importedEncryptionKey = await _crypto.subtle.importKey(\n \"raw\",\n derivedKey,\n id,\n false,\n usage\n );\n result.key = importedEncryptionKey;\n result.salt = salt;\n } else {\n if (password.length < algorithm.keyBits / 8)\n throw new Error(\"Key buffer (password) too small\");\n result.key = await _crypto.subtle.importKey(\"raw\", password, id, false, usage);\n result.salt = \"\";\n }\n if (options.iv)\n result.iv = options.iv;\n else if (\"ivBits\" in algorithm)\n result.iv = randomBits(_crypto, algorithm.ivBits);\n return result;\n};\nvar encrypt = async (_crypto, password, options, data) => {\n const key = await generateKey(_crypto, password, options);\n const textBuffer = stringToBuffer(data);\n const encrypted = await _crypto.subtle.encrypt(\n { name: algorithms[options.algorithm].name, iv: key.iv },\n key.key,\n textBuffer\n );\n return { encrypted: new Uint8Array(encrypted), key };\n};\nvar decrypt = async (_crypto, password, options, data) => {\n const key = await generateKey(_crypto, password, options);\n const decrypted = await _crypto.subtle.decrypt(\n { name: algorithms[options.algorithm].name, iv: key.iv },\n key.key,\n typeof data === \"string\" ? stringToBuffer(data) : data\n );\n return bufferToString(new Uint8Array(decrypted));\n};\nvar hmacWithPassword = async (_crypto, password, options, data) => {\n const key = await generateKey(_crypto, password, { ...options, hmac: true });\n const textBuffer = stringToBuffer(data);\n const signed = await _crypto.subtle.sign({ name: \"HMAC\" }, key.key, textBuffer);\n const digest = base64urlEncode(new Uint8Array(signed));\n return { digest, salt: key.salt };\n};\nvar normalizePassword = (password) => {\n if (typeof password === \"string\" || password instanceof Uint8Array)\n return { encryption: password, integrity: password };\n if (\"secret\" in password)\n return { id: password.id, encryption: password.secret, integrity: password.secret };\n return { id: password.id, encryption: password.encryption, integrity: password.integrity };\n};\nvar seal = async (_crypto, object, password, options) => {\n if (!password)\n throw Error(\"Empty password\");\n const opts = clone(options);\n const now = Date.now() + (opts.localtimeOffsetMsec || 0);\n const objectString = JSON.stringify(object);\n const pass = normalizePassword(password);\n const { id = \"\" } = pass;\n if (id && !/^\\w+$/.test(id))\n throw new Error(\"Invalid password id\");\n const { encrypted, key } = await encrypt(_crypto, pass.encryption, opts.encryption, objectString);\n const encryptedB64 = base64urlEncode(new Uint8Array(encrypted));\n const iv = base64urlEncode(key.iv);\n const expiration = opts.ttl ? now + opts.ttl : \"\";\n const macBaseString = `${macPrefix}*${id}*${key.salt}*${iv}*${encryptedB64}*${expiration}`;\n const mac = await hmacWithPassword(_crypto, pass.integrity, opts.integrity, macBaseString);\n const sealed = `${macBaseString}*${mac.salt}*${mac.digest}`;\n return sealed;\n};\nvar fixedTimeComparison = (a, b) => {\n let mismatch = a.length === b.length ? 0 : 1;\n if (mismatch)\n b = a;\n for (let i = 0; i < a.length; i += 1)\n mismatch |= a.charCodeAt(i) ^ b.charCodeAt(i);\n return mismatch === 0;\n};\nvar unseal = async (_crypto, sealed, password, options) => {\n if (!password)\n throw Error(\"Empty password\");\n const opts = clone(options);\n const now = Date.now() + (opts.localtimeOffsetMsec || 0);\n const parts = sealed.split(\"*\");\n if (parts.length !== 8)\n throw new Error(\"Incorrect number of sealed components\");\n const prefix = parts[0];\n let passwordId = parts[1];\n const encryptionSalt = parts[2];\n const encryptionIv = parts[3];\n const encryptedB64 = parts[4];\n const expiration = parts[5];\n const hmacSalt = parts[6];\n const hmac = parts[7];\n const macBaseString = `${prefix}*${passwordId}*${encryptionSalt}*${encryptionIv}*${encryptedB64}*${expiration}`;\n if (macPrefix !== prefix)\n throw new Error(\"Wrong mac prefix\");\n if (expiration) {\n if (!/^\\d+$/.exec(expiration))\n throw new Error(\"Invalid expiration\");\n const exp = parseInt(expiration, 10);\n if (exp <= now - opts.timestampSkewSec * 1e3)\n throw new Error(\"Expired seal\");\n }\n if (typeof password === \"undefined\" || typeof password === \"string\" && password.length === 0)\n throw new Error(\"Empty password\");\n let pass = \"\";\n passwordId = passwordId || \"default\";\n if (typeof password === \"string\" || password instanceof Uint8Array)\n pass = password;\n else if (!(passwordId in password))\n throw new Error(`Cannot find password: ${passwordId}`);\n else\n pass = password[passwordId];\n pass = normalizePassword(pass);\n const macOptions = opts.integrity;\n macOptions.salt = hmacSalt;\n const mac = await hmacWithPassword(_crypto, pass.integrity, macOptions, macBaseString);\n if (!fixedTimeComparison(mac.digest, hmac))\n throw new Error(\"Bad hmac value\");\n const encrypted = base64urlDecode(encryptedB64);\n const decryptOptions = opts.encryption;\n decryptOptions.salt = encryptionSalt;\n decryptOptions.iv = base64urlDecode(encryptionIv);\n const decrypted = await decrypt(_crypto, pass.encryption, decryptOptions, encrypted);\n if (decrypted)\n return JSON.parse(decrypted);\n return null;\n};\n\nexport { algorithms, base64urlDecode, base64urlEncode, bufferToString, clone, decrypt, defaults, encrypt, generateKey, hmacWithPassword, macFormatVersion, macPrefix, randomBits, seal, stringToBuffer, unseal };\n","import {\n createGetIronSession,\n createGetServerActionIronSession,\n createSealData,\n createUnsealData,\n} from \"./core.js\";\n\nexport * from \"./core.js\";\nexport const sealData = createSealData();\nexport const unsealData = createUnsealData();\nexport const getIronSession = createGetIronSession(sealData, unsealData);\nexport const getServerActionIronSession = createGetServerActionIronSession(\n sealData,\n unsealData,\n);\n"]}
@@ -0,0 +1,230 @@
1
+ import * as http from 'http';
2
+ import { IncomingMessage, ServerResponse } from 'http';
3
+
4
+ /**
5
+ * Basic HTTP cookie parser and serializer for HTTP servers.
6
+ */
7
+
8
+ /**
9
+ * Additional serialization options
10
+ */
11
+ interface CookieSerializeOptions {
12
+ /**
13
+ * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3|Domain Set-Cookie attribute}. By default, no
14
+ * domain is set, and most clients will consider the cookie to apply to only
15
+ * the current domain.
16
+ */
17
+ domain?: string | undefined;
18
+
19
+ /**
20
+ * Specifies a function that will be used to encode a cookie's value. Since
21
+ * value of a cookie has a limited character set (and must be a simple
22
+ * string), this function can be used to encode a value into a string suited
23
+ * for a cookie's value.
24
+ *
25
+ * The default function is the global `encodeURIComponent`, which will
26
+ * encode a JavaScript string into UTF-8 byte sequences and then URL-encode
27
+ * any that fall outside of the cookie range.
28
+ */
29
+ encode?(value: string): string;
30
+
31
+ /**
32
+ * 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,
33
+ * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
34
+ * it on a condition like exiting a web browser application.
35
+ *
36
+ * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
37
+ * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
38
+ * possible not all clients by obey this, so if both are set, they should
39
+ * point to the same date and time.
40
+ */
41
+ expires?: Date | undefined;
42
+ /**
43
+ * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6|`HttpOnly` `Set-Cookie` attribute}.
44
+ * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
45
+ * default, the `HttpOnly` attribute is not set.
46
+ *
47
+ * *Note* be careful when setting this to true, as compliant clients will
48
+ * not allow client-side JavaScript to see the cookie in `document.cookie`.
49
+ */
50
+ httpOnly?: boolean | undefined;
51
+ /**
52
+ * Specifies the number (in seconds) to be the value for the `Max-Age`
53
+ * `Set-Cookie` attribute. The given number will be converted to an integer
54
+ * by rounding down. By default, no maximum age is set.
55
+ *
56
+ * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
57
+ * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
58
+ * possible not all clients by obey this, so if both are set, they should
59
+ * point to the same date and time.
60
+ */
61
+ maxAge?: number | undefined;
62
+ /**
63
+ * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
64
+ * By default, the path is considered the "default path".
65
+ */
66
+ path?: string | undefined;
67
+ /**
68
+ * Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].
69
+ *
70
+ * - `'low'` will set the `Priority` attribute to `Low`.
71
+ * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
72
+ * - `'high'` will set the `Priority` attribute to `High`.
73
+ *
74
+ * More information about the different priority levels can be found in
75
+ * [the specification][rfc-west-cookie-priority-00-4.1].
76
+ *
77
+ * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
78
+ * This also means many clients may ignore this attribute until they understand it.
79
+ */
80
+ priority?: "low" | "medium" | "high" | undefined;
81
+ /**
82
+ * 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}.
83
+ *
84
+ * - `true` will set the `SameSite` attribute to `Strict` for strict same
85
+ * site enforcement.
86
+ * - `false` will not set the `SameSite` attribute.
87
+ * - `'lax'` will set the `SameSite` attribute to Lax for lax same site
88
+ * enforcement.
89
+ * - `'strict'` will set the `SameSite` attribute to Strict for strict same
90
+ * site enforcement.
91
+ * - `'none'` will set the SameSite attribute to None for an explicit
92
+ * cross-site cookie.
93
+ *
94
+ * 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}.
95
+ *
96
+ * *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.
97
+ */
98
+ sameSite?: true | false | "lax" | "strict" | "none" | undefined;
99
+ /**
100
+ * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5|`Secure` `Set-Cookie` attribute}. When truthy, the
101
+ * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
102
+ *
103
+ * *Note* be careful when setting this to `true`, as compliant clients will
104
+ * not send the cookie back to the server in the future if the browser does
105
+ * not have an HTTPS connection.
106
+ */
107
+ secure?: boolean | undefined;
108
+ }
109
+
110
+ type PasswordsMap = Record<string, string>;
111
+ type Password = PasswordsMap | string;
112
+ type RequestType = IncomingMessage | Request;
113
+ type ResponseType = Response | ServerResponse;
114
+ /**
115
+ * {@link https://wicg.github.io/cookie-store/#dictdef-cookielistitem CookieListItem}
116
+ * as specified by W3C.
117
+ */
118
+ interface CookieListItem extends Pick<CookieSerializeOptions, "domain" | "path" | "sameSite" | "secure"> {
119
+ /** A string with the name of a cookie. */
120
+ name: string;
121
+ /** A string containing the value of the cookie. */
122
+ value: string;
123
+ /** A number of milliseconds or Date interface containing the expires of the cookie. */
124
+ expires?: CookieSerializeOptions["expires"] | number;
125
+ }
126
+ /**
127
+ * Superset of {@link CookieListItem} extending it with
128
+ * the `httpOnly`, `maxAge` and `priority` properties.
129
+ */
130
+ type ResponseCookie = CookieListItem & Pick<CookieSerializeOptions, "httpOnly" | "maxAge" | "priority">;
131
+ /**
132
+ * The high-level type definition of the .get() and .set() methods
133
+ * of { cookies() } from "next/headers"
134
+ */
135
+ interface ICookieHandler {
136
+ get: (name: string) => {
137
+ name: string;
138
+ value: string;
139
+ } | undefined;
140
+ set: {
141
+ (name: string, value: string, cookie?: Partial<ResponseCookie>): void;
142
+ (options: ResponseCookie): void;
143
+ };
144
+ }
145
+ /**
146
+ * Set-Cookie Attributes do not include `encode`. We omit this from our `cookieOptions` type.
147
+ *
148
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
149
+ * @see https://developer.chrome.com/docs/devtools/application/cookies/
150
+ */
151
+ type CookieOptions = Omit<CookieSerializeOptions, "encode">;
152
+ interface IronSessionOptions {
153
+ /**
154
+ * The cookie name that will be used inside the browser. Make sure it's unique
155
+ * given your application.
156
+ *
157
+ * @example 'vercel-session'
158
+ */
159
+ cookieName: string;
160
+ /**
161
+ * The password(s) that will be used to encrypt the cookie. Can either be a string
162
+ * or an object.
163
+ *
164
+ * When you provide multiple passwords then all of them will be used to decrypt
165
+ * the cookie. But only the most recent (`= highest key`, `2` in the example)
166
+ * password will be used to encrypt the cookie. This allows password rotation.
167
+ *
168
+ * @example { 1: 'password-1', 2: 'password-2' }
169
+ */
170
+ password: Password;
171
+ /**
172
+ * The time (in seconds) that the session will be valid for. Also sets the
173
+ * `max-age` attribute of the cookie automatically (`= ttl - 60s`, so that the
174
+ * cookie always expire before the session).
175
+ *
176
+ * `ttl = 0` means no expiration.
177
+ *
178
+ * @default 1209600
179
+ */
180
+ ttl?: number;
181
+ /**
182
+ * The options that will be passed to the cookie library.
183
+ *
184
+ * If you want to use "session cookies" (cookies that are deleted when the browser
185
+ * is closed) then you need to pass `cookieOptions: { maxAge: undefined }`
186
+ *
187
+ * @see https://github.com/jshttp/cookie#options-1
188
+ */
189
+ cookieOptions?: CookieOptions;
190
+ }
191
+ type OverridableOptions = Pick<IronSessionOptions, "cookieOptions" | "ttl">;
192
+ type IronSession<T> = T & {
193
+ /**
194
+ * Destroys the session data and removes the cookie.
195
+ */
196
+ readonly destroy: (destroyOptions?: OverridableOptions) => Promise<void>;
197
+ /**
198
+ * Encrypts the session data and sets the cookie.
199
+ */
200
+ readonly save: (saveOptions?: OverridableOptions) => Promise<void>;
201
+ };
202
+ declare function createSealData(_crypto?: Crypto): (data: unknown, { password, ttl, }: {
203
+ password: Password;
204
+ ttl?: number;
205
+ }) => Promise<string>;
206
+ declare function createUnsealData(_crypto?: Crypto): <T extends {} = {}>(seal: string, { password, ttl, }: {
207
+ password: Password;
208
+ ttl?: number;
209
+ }) => Promise<T>;
210
+ declare function createGetIronSession(sealData: ReturnType<typeof createSealData>, unsealData: ReturnType<typeof createUnsealData>): <T extends {} = {}>(req: RequestType, res: ResponseType, userSessionOptions: IronSessionOptions) => Promise<IronSession<T>>;
211
+ declare function createGetServerActionIronSession(sealData: ReturnType<typeof createSealData>, unsealData: ReturnType<typeof createUnsealData>): <T extends {} = {}>(userSessionOptions: IronSessionOptions, cookieHandler: ICookieHandler) => Promise<IronSession<T>>;
212
+ declare function mergeHeaders(...headersList: (HeadersInit | undefined)[]): Headers;
213
+ declare function createResponse(originalResponse: Response, bodyString: string, options?: ResponseInit): Response;
214
+
215
+ declare const sealData: (data: unknown, { password, ttl, }: {
216
+ password: string | {
217
+ [x: string]: string;
218
+ };
219
+ ttl?: number;
220
+ }) => Promise<string>;
221
+ declare const unsealData: <T extends {} = {}>(seal: string, { password, ttl, }: {
222
+ password: string | {
223
+ [x: string]: string;
224
+ };
225
+ ttl?: number;
226
+ }) => Promise<T>;
227
+ declare const getIronSession: <T extends {} = {}>(req: http.IncomingMessage | Request, res: Response | http.ServerResponse<http.IncomingMessage>, userSessionOptions: IronSessionOptions) => Promise<IronSession<T>>;
228
+ declare const getServerActionIronSession: <T extends {} = {}>(userSessionOptions: IronSessionOptions, cookieHandler: ICookieHandler) => Promise<IronSession<T>>;
229
+
230
+ export { ICookieHandler, IronSession, IronSessionOptions, createGetIronSession, createGetServerActionIronSession, createResponse, createSealData, createUnsealData, getIronSession, getServerActionIronSession, mergeHeaders, sealData, unsealData };
package/dist/index.d.ts CHANGED
@@ -1,66 +1,230 @@
1
- import { CookieSerializeOptions } from 'cookie';
1
+ import * as http from 'http';
2
2
  import { IncomingMessage, ServerResponse } from 'http';
3
3
 
4
- declare type passwordsMap = {
5
- [id: string]: string;
6
- };
7
- declare type password = string | passwordsMap;
4
+ /**
5
+ * Basic HTTP cookie parser and serializer for HTTP servers.
6
+ */
7
+
8
+ /**
9
+ * Additional serialization options
10
+ */
11
+ interface CookieSerializeOptions {
12
+ /**
13
+ * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3|Domain Set-Cookie attribute}. By default, no
14
+ * domain is set, and most clients will consider the cookie to apply to only
15
+ * the current domain.
16
+ */
17
+ domain?: string | undefined;
18
+
19
+ /**
20
+ * Specifies a function that will be used to encode a cookie's value. Since
21
+ * value of a cookie has a limited character set (and must be a simple
22
+ * string), this function can be used to encode a value into a string suited
23
+ * for a cookie's value.
24
+ *
25
+ * The default function is the global `encodeURIComponent`, which will
26
+ * encode a JavaScript string into UTF-8 byte sequences and then URL-encode
27
+ * any that fall outside of the cookie range.
28
+ */
29
+ encode?(value: string): string;
30
+
31
+ /**
32
+ * 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,
33
+ * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
34
+ * it on a condition like exiting a web browser application.
35
+ *
36
+ * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
37
+ * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
38
+ * possible not all clients by obey this, so if both are set, they should
39
+ * point to the same date and time.
40
+ */
41
+ expires?: Date | undefined;
42
+ /**
43
+ * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6|`HttpOnly` `Set-Cookie` attribute}.
44
+ * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
45
+ * default, the `HttpOnly` attribute is not set.
46
+ *
47
+ * *Note* be careful when setting this to true, as compliant clients will
48
+ * not allow client-side JavaScript to see the cookie in `document.cookie`.
49
+ */
50
+ httpOnly?: boolean | undefined;
51
+ /**
52
+ * Specifies the number (in seconds) to be the value for the `Max-Age`
53
+ * `Set-Cookie` attribute. The given number will be converted to an integer
54
+ * by rounding down. By default, no maximum age is set.
55
+ *
56
+ * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
57
+ * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
58
+ * possible not all clients by obey this, so if both are set, they should
59
+ * point to the same date and time.
60
+ */
61
+ maxAge?: number | undefined;
62
+ /**
63
+ * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
64
+ * By default, the path is considered the "default path".
65
+ */
66
+ path?: string | undefined;
67
+ /**
68
+ * Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].
69
+ *
70
+ * - `'low'` will set the `Priority` attribute to `Low`.
71
+ * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
72
+ * - `'high'` will set the `Priority` attribute to `High`.
73
+ *
74
+ * More information about the different priority levels can be found in
75
+ * [the specification][rfc-west-cookie-priority-00-4.1].
76
+ *
77
+ * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
78
+ * This also means many clients may ignore this attribute until they understand it.
79
+ */
80
+ priority?: "low" | "medium" | "high" | undefined;
81
+ /**
82
+ * 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}.
83
+ *
84
+ * - `true` will set the `SameSite` attribute to `Strict` for strict same
85
+ * site enforcement.
86
+ * - `false` will not set the `SameSite` attribute.
87
+ * - `'lax'` will set the `SameSite` attribute to Lax for lax same site
88
+ * enforcement.
89
+ * - `'strict'` will set the `SameSite` attribute to Strict for strict same
90
+ * site enforcement.
91
+ * - `'none'` will set the SameSite attribute to None for an explicit
92
+ * cross-site cookie.
93
+ *
94
+ * 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}.
95
+ *
96
+ * *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.
97
+ */
98
+ sameSite?: true | false | "lax" | "strict" | "none" | undefined;
99
+ /**
100
+ * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5|`Secure` `Set-Cookie` attribute}. When truthy, the
101
+ * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
102
+ *
103
+ * *Note* be careful when setting this to `true`, as compliant clients will
104
+ * not send the cookie back to the server in the future if the browser does
105
+ * not have an HTTPS connection.
106
+ */
107
+ secure?: boolean | undefined;
108
+ }
109
+
110
+ type PasswordsMap = Record<string, string>;
111
+ type Password = PasswordsMap | string;
112
+ type RequestType = IncomingMessage | Request;
113
+ type ResponseType = Response | ServerResponse;
114
+ /**
115
+ * {@link https://wicg.github.io/cookie-store/#dictdef-cookielistitem CookieListItem}
116
+ * as specified by W3C.
117
+ */
118
+ interface CookieListItem extends Pick<CookieSerializeOptions, "domain" | "path" | "sameSite" | "secure"> {
119
+ /** A string with the name of a cookie. */
120
+ name: string;
121
+ /** A string containing the value of the cookie. */
122
+ value: string;
123
+ /** A number of milliseconds or Date interface containing the expires of the cookie. */
124
+ expires?: CookieSerializeOptions["expires"] | number;
125
+ }
126
+ /**
127
+ * Superset of {@link CookieListItem} extending it with
128
+ * the `httpOnly`, `maxAge` and `priority` properties.
129
+ */
130
+ type ResponseCookie = CookieListItem & Pick<CookieSerializeOptions, "httpOnly" | "maxAge" | "priority">;
131
+ /**
132
+ * The high-level type definition of the .get() and .set() methods
133
+ * of { cookies() } from "next/headers"
134
+ */
135
+ interface ICookieHandler {
136
+ get: (name: string) => {
137
+ name: string;
138
+ value: string;
139
+ } | undefined;
140
+ set: {
141
+ (name: string, value: string, cookie?: Partial<ResponseCookie>): void;
142
+ (options: ResponseCookie): void;
143
+ };
144
+ }
145
+ /**
146
+ * Set-Cookie Attributes do not include `encode`. We omit this from our `cookieOptions` type.
147
+ *
148
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
149
+ * @see https://developer.chrome.com/docs/devtools/application/cookies/
150
+ */
151
+ type CookieOptions = Omit<CookieSerializeOptions, "encode">;
8
152
  interface IronSessionOptions {
9
153
  /**
10
- * This is the cookie name that will be used inside the browser. You should make sure it's unique given
11
- * your application. Example: vercel-session
154
+ * The cookie name that will be used inside the browser. Make sure it's unique
155
+ * given your application.
156
+ *
157
+ * @example 'vercel-session'
12
158
  */
13
159
  cookieName: string;
14
160
  /**
15
- * This is the password(s) that will be used to encrypt the cookie. It can be either a string or an object
16
- * like {1: "password", 2: password}.
161
+ * The password(s) that will be used to encrypt the cookie. Can either be a string
162
+ * or an object.
163
+ *
164
+ * When you provide multiple passwords then all of them will be used to decrypt
165
+ * the cookie. But only the most recent (`= highest key`, `2` in the example)
166
+ * password will be used to encrypt the cookie. This allows password rotation.
17
167
  *
18
- * When you provide multiple passwords then all of them will be used to decrypt the cookie and only the most
19
- * recent (= highest key, 2 in this example) password will be used to encrypt the cookie. This allow you
20
- * to use password rotation (security)
168
+ * @example { 1: 'password-1', 2: 'password-2' }
21
169
  */
22
- password: password;
170
+ password: Password;
23
171
  /**
24
- * This is the time in seconds that the session will be valid for. This also set the max-age attribute of
25
- * the cookie automatically (minus 60 seconds so that the cookie always expire before the session).
172
+ * The time (in seconds) that the session will be valid for. Also sets the
173
+ * `max-age` attribute of the cookie automatically (`= ttl - 60s`, so that the
174
+ * cookie always expire before the session).
175
+ *
176
+ * `ttl = 0` means no expiration.
177
+ *
178
+ * @default 1209600
26
179
  */
27
180
  ttl?: number;
28
181
  /**
29
- * This is the options that will be passed to the cookie library.
30
- * You can see all of them here: https://github.com/jshttp/cookie#options-1.
182
+ * The options that will be passed to the cookie library.
183
+ *
184
+ * If you want to use "session cookies" (cookies that are deleted when the browser
185
+ * is closed) then you need to pass `cookieOptions: { maxAge: undefined }`
31
186
  *
32
- * If you want to use "session cookies" (cookies that are deleted when the browser is closed) then you need
33
- * to pass cookieOptions: { maxAge: undefined }.
187
+ * @see https://github.com/jshttp/cookie#options-1
34
188
  */
35
- cookieOptions?: CookieSerializeOptions;
189
+ cookieOptions?: CookieOptions;
36
190
  }
37
- interface IronSessionData {
38
- }
39
- declare type IronSession = IronSessionData & {
191
+ type OverridableOptions = Pick<IronSessionOptions, "cookieOptions" | "ttl">;
192
+ type IronSession<T> = T & {
40
193
  /**
41
194
  * Destroys the session data and removes the cookie.
42
195
  */
43
- destroy: () => void;
196
+ readonly destroy: (destroyOptions?: OverridableOptions) => Promise<void>;
44
197
  /**
45
198
  * Encrypts the session data and sets the cookie.
46
199
  */
47
- save: () => Promise<void>;
200
+ readonly save: (saveOptions?: OverridableOptions) => Promise<void>;
48
201
  };
49
- declare module "http" {
50
- interface IncomingMessage {
51
- session: IronSession;
52
- }
53
- }
54
- declare type RequestType = IncomingMessage | Request;
55
- declare type ResponseType = ServerResponse | Response;
56
- declare function getIronSession(req: RequestType, res: ResponseType, userSessionOptions: IronSessionOptions): Promise<IronSession>;
57
- declare function unsealData<T = Record<string, unknown>>(seal: string, { password, ttl, }: {
58
- password: password;
202
+ declare function createSealData(_crypto?: Crypto): (data: unknown, { password, ttl, }: {
203
+ password: Password;
204
+ ttl?: number;
205
+ }) => Promise<string>;
206
+ declare function createUnsealData(_crypto?: Crypto): <T extends {} = {}>(seal: string, { password, ttl, }: {
207
+ password: Password;
208
+ ttl?: number;
209
+ }) => Promise<T>;
210
+ declare function createGetIronSession(sealData: ReturnType<typeof createSealData>, unsealData: ReturnType<typeof createUnsealData>): <T extends {} = {}>(req: RequestType, res: ResponseType, userSessionOptions: IronSessionOptions) => Promise<IronSession<T>>;
211
+ declare function createGetServerActionIronSession(sealData: ReturnType<typeof createSealData>, unsealData: ReturnType<typeof createUnsealData>): <T extends {} = {}>(userSessionOptions: IronSessionOptions, cookieHandler: ICookieHandler) => Promise<IronSession<T>>;
212
+ declare function mergeHeaders(...headersList: (HeadersInit | undefined)[]): Headers;
213
+ declare function createResponse(originalResponse: Response, bodyString: string, options?: ResponseInit): Response;
214
+
215
+ declare const sealData: (data: unknown, { password, ttl, }: {
216
+ password: string | {
217
+ [x: string]: string;
218
+ };
59
219
  ttl?: number;
60
- }): Promise<T>;
61
- declare function sealData(data: unknown, { password, ttl, }: {
62
- password: password;
220
+ }) => Promise<string>;
221
+ declare const unsealData: <T extends {} = {}>(seal: string, { password, ttl, }: {
222
+ password: string | {
223
+ [x: string]: string;
224
+ };
63
225
  ttl?: number;
64
- }): Promise<string>;
226
+ }) => Promise<T>;
227
+ declare const getIronSession: <T extends {} = {}>(req: http.IncomingMessage | Request, res: Response | http.ServerResponse<http.IncomingMessage>, userSessionOptions: IronSessionOptions) => Promise<IronSession<T>>;
228
+ declare const getServerActionIronSession: <T extends {} = {}>(userSessionOptions: IronSessionOptions, cookieHandler: ICookieHandler) => Promise<IronSession<T>>;
65
229
 
66
- export { IronSession, IronSessionData, IronSessionOptions, getIronSession, sealData, unsealData };
230
+ export { ICookieHandler, IronSession, IronSessionOptions, createGetIronSession, createGetServerActionIronSession, createResponse, createSealData, createUnsealData, getIronSession, getServerActionIronSession, mergeHeaders, sealData, unsealData };