Skip to content

Commit

Permalink
export cookie types (#221)
Browse files Browse the repository at this point in the history
* try to export cookie's type

* avoid deep require

* update
  • Loading branch information
gurgunday authored Nov 21, 2023
1 parent a36a4e2 commit fad6a8f
Showing 1 changed file with 3 additions and 25 deletions.
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

0 comments on commit fad6a8f

Please sign in to comment.