diff --git a/index.d.ts b/index.d.ts index fdc8465..dc6704b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -18,14 +18,24 @@ declare module 'fastify' { } export interface FastifyBasicAuthOptions { - validate( - this: FastifyInstance, - username: string, - password: string, - req: FastifyRequest, - reply: FastifyReply, - done: (err?: Error) => void - ): void | Promise; + validate: ( + ( + this: FastifyInstance, + username: string, + password: string, + req: FastifyRequest, + reply: FastifyReply, + ) => Promise + ) | ( + ( + this: FastifyInstance, + username: string, + password: string, + req: FastifyRequest, + reply: FastifyReply, + done: (err?: Error) => void + ) => void + ); authenticate?: boolean | { realm: string | ((req: FastifyRequest) => string) }; header?: string; } diff --git a/index.test-d.ts b/index.test-d.ts index e24a56c..efd46ad 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -19,6 +19,7 @@ app.register(fastifyBasicAuth, { expectType(req) expectType(reply) expectType(this) + if (Math.random() > 0.5) return new Error() }, header: 'x-forwarded-authorization' })