-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.d.ts
48 lines (39 loc) · 1.47 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
import { type FastifyJWTOptions, type VerifyPayloadType } from '@fastify/jwt'
import { type FastifyPluginCallback, type FastifyReply, type FastifyRequest } from 'fastify'
import { type GetJwksOptions } from 'get-jwks'
import { type URL, type UrlObject } from 'url'
export interface JWTOptions extends FastifyJWTOptions {
namespace?: string
jwks?: boolean | GetJwksOptions
}
export interface WebhookOptions {
url: string | URL | UrlObject
}
export type CreateSession = (request?: FastifyRequest, reply?: FastifyReply) => Promise<void>
export interface AuthStrategy {
name: string,
createSession: CreateSession
}
export interface FastifyUserPluginOptions {
jwt?: JWTOptions
webhook?: WebhookOptions
authStrategies?: AuthStrategy[]
}
export type AddAuthStrategyDecorator = (strategy: AuthStrategy) => void
export type ExtractUserDecorator = () => Promise<any>
export type CreateSessionDecorator = () => Promise<void>
export type CreateJWTSessionDecorator = () => Promise<VerifyPayloadType>
export type CreateWebhookSessionDecorator = () => Promise<void>
declare module 'fastify' {
interface FastifyInstance {
addAuthStrategy: AddAuthStrategyDecorator
}
interface FastifyRequest {
extractUser: ExtractUserDecorator
createSession: CreateSessionDecorator
createJWTSession: CreateJWTSessionDecorator
createWebhookSession: CreateWebhookSessionDecorator
}
}
declare const fastifyUser: FastifyPluginCallback<FastifyUserPluginOptions>
export default fastifyUser