Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export cookie types #221

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import type * as Fastify from 'fastify';
import { FastifyPluginCallback } from 'fastify';
import { SerializeOptions } from "@fastify/cookie"

declare module 'fastify' {
interface FastifyInstance {
decryptSession<Request extends Record<string, any> = FastifyRequest>(sessionId: string, request: Request, cookieOpts: fastifySession.CookieOptions, callback: Callback): void;
decryptSession<Request extends Record<string, any> = FastifyRequest>(sessionId: string, request: Request, cookieOpts: SerializeOptions, callback: Callback): void;
decryptSession<Request extends Record<string, any> = FastifyRequest>(sessionId: string, request: Request, callback: Callback): void;
}

Expand Down Expand Up @@ -141,7 +142,7 @@ declare namespace fastifySession {
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
*/
cookie?: CookieOptions;
cookie?: SerializeOptions;

/**
* A session store.
Expand Down Expand Up @@ -173,29 +174,6 @@ declare namespace fastifySession {
cookiePrefix?: string;
}

export interface CookieOptions {
/** The `Path` attribute. Defaults to `/` (the root path). */
path?: string;

/** A `number` in milliseconds that specifies the `Expires` attribute by adding the specified milliseconds to the current date. If both `expires` and `maxAge` are set, then `expires` is used. */
maxAge?: number;

/** The `boolean` value of the `HttpOnly` attribute. Defaults to true. */
httpOnly?: boolean;

/** The `boolean` value of the `Secure` attribute. Set this option to false when communicating over an unencrypted (HTTP) connection. Value can be set to `auto`; in this case the `Secure` attribute will be set to false for HTTP request, in case of HTTPS it will be set to true. Defaults to true. */
secure?: boolean | 'auto';

/** The expiration `date` used for the `Expires` attribute. If both `expires` and `maxAge` are set, then `expires` is used. */
expires?: Date;

/** A `boolean` or one of the `SameSite` string attributes. E.g.: `lax`, `node` or `strict`. */
sameSite?: 'lax' | 'none' | 'strict' | boolean;

/** The `Domain` attribute. */
domain?: string;
}

export class MemoryStore implements fastifySession.SessionStore {
constructor(map?: Map<string, Fastify.Session>);
set(
Expand Down
Loading