UNPKG

@mercury-labs/auth

Version:

Mercury framework auth library. It supports local auth, jwt with both bearer token and cookie, basic auth.

28 lines (27 loc) 1.15 kB
import { ExecutionContext } from '@nestjs/common'; export interface ICookieSerializeOptions { domain?: string; expires?: Date; httpOnly?: boolean; maxAge?: number; path?: string; sameSite?: boolean | 'lax' | 'strict' | 'none'; secure?: boolean; signed?: boolean; encode?(val: string): string; } export interface IHttpRequest { headers: Record<string, any>; cookies?: Record<string, any>; } export declare type IHttpResponse = { httpAdaptorType: 'fastify'; setCookie?: (key: string, value: string, options: ICookieSerializeOptions) => void; } | { httpAdaptorType: 'express'; cookie?: (key: string, value: string, options: ICookieSerializeOptions) => void; }; export declare function getRequestFromContext(context: ExecutionContext): IHttpRequest; export declare function getResponseFromContext(context: ExecutionContext): IHttpResponse; export declare function getRequestHeader(request: IHttpRequest, key?: string): string | IHttpRequest['headers'] | undefined; export declare function getRequestCookie(request: IHttpRequest, key?: string): string | IHttpRequest['cookies'] | undefined;