-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathindex.d.ts
54 lines (47 loc) · 1.95 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/// <reference types="node" />
import { CookieSerializeOptions } from '@fastify/cookie'
import { FastifyPluginCallback, FastifyBaseLogger } from 'fastify'
declare module 'fastify' {
interface FastifyInstance {
createSecureSession(data?: Record<string, any>): fastifySecureSession.Session
decodeSecureSession(cookie: string, log?: FastifyBaseLogger, sessionName?: string): fastifySecureSession.Session | null
encodeSecureSession(session: fastifySecureSession.Session, sessionName?: string): string
}
interface FastifyRequest {
session: fastifySecureSession.Session;
}
}
type FastifySecureSession = FastifyPluginCallback<fastifySecureSession.SecureSessionPluginOptions | (fastifySecureSession.SecureSessionPluginOptions & Required<Pick<fastifySecureSession.SecureSessionPluginOptions, 'sessionName'>>)[]>
interface SessionData {}
declare namespace fastifySecureSession {
export type Session<T = SessionData> = Partial<T> & {
changed: boolean;
deleted: boolean;
get<Key extends keyof T>(key: Key): T[Key] | undefined;
get(key: string): any | undefined;
set<Key extends keyof T>(key: Key, value: T[Key] | undefined): void;
data(): T | undefined;
delete(): void;
options(opts: CookieSerializeOptions): void;
touch(): void;
/**
* Regenerates the session
*
* ignoreFields specifies which fields should be kept in the new session object.
*/
regenerate(ignoreFields?: string[]): void;
}
export type SecureSessionPluginOptions = {
cookie?: CookieSerializeOptions
cookieName?: string
sessionName?: string
expiry?: number
} & ({ key: string | Buffer | (string | Buffer)[] } | {
secret: string | Buffer,
salt: string | Buffer
})
export const fastifySecureSession: FastifySecureSession
export { fastifySecureSession as default }
}
declare function fastifySecureSession (...params: Parameters<FastifySecureSession>): ReturnType<FastifySecureSession>
export = fastifySecureSession