@fastify/auth
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -1,27 +0,7 @@ | ||
import { ContextConfigDefault, FastifyInstance, FastifyPluginCallback, FastifyReply, FastifyRequest, FastifySchema, preHandlerHookHandler } from 'fastify'; | ||
import { RouteGenericInterface } from 'fastify/types/route'; | ||
import { ContextConfigDefault, RouteGenericInterface, FastifyInstance, FastifyPluginCallback, FastifyReply, FastifyRequest, FastifySchema, preHandlerHookHandler } from 'fastify'; | ||
export type FastifyAuthFunction = ( | ||
this: FastifyInstance, | ||
request: FastifyRequest, | ||
reply: FastifyReply, | ||
done: (error?: Error) => void | ||
) => void; | ||
/** | ||
* @link [`fastify-auth` options documentation](https://github.com/fastify/fastify-auth#options) | ||
*/ | ||
export interface FastifyAuthPluginOptions { | ||
/** | ||
* The default relation between the functions. It can be either `or` or `and`. | ||
* | ||
* - Default value: `or` | ||
*/ | ||
defaultRelation?: 'and' | 'or', | ||
} | ||
declare module 'fastify' { | ||
interface FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider> { | ||
auth( | ||
functions: FastifyAuthFunction[], | ||
functions: fastifyAuth.FastifyAuthFunction[], | ||
options?: { | ||
@@ -35,3 +15,29 @@ relation?: 'and' | 'or', | ||
declare const fastifyAuth: FastifyPluginCallback<FastifyAuthPluginOptions> | ||
export default fastifyAuth; | ||
type FastifyAuth = FastifyPluginCallback<fastifyAuth.FastifyAuthPluginOptions> | ||
declare namespace fastifyAuth { | ||
export type FastifyAuthFunction = ( | ||
this: FastifyInstance, | ||
request: FastifyRequest, | ||
reply: FastifyReply, | ||
done: (error?: Error) => void | ||
) => void; | ||
/** | ||
* @link [`fastify-auth` options documentation](https://github.com/fastify/fastify-auth#options) | ||
*/ | ||
export interface FastifyAuthPluginOptions { | ||
/** | ||
* The default relation between the functions. It can be either `or` or `and`. | ||
* | ||
* - Default value: `or` | ||
*/ | ||
defaultRelation?: 'and' | 'or', | ||
} | ||
export const fastifyAuth: FastifyAuth | ||
export { fastifyAuth as default } | ||
} | ||
declare function fastifyAuth(...params: Parameters<FastifyAuth>): ReturnType<FastifyAuth> | ||
export = fastifyAuth |
@@ -8,3 +8,3 @@ 'use strict' | ||
function checkAuth (fastify, opts, next) { | ||
function fastifyAuth (fastify, opts, next) { | ||
if (opts.defaultRelation && opts.defaultRelation !== 'or' && opts.defaultRelation !== 'and') { | ||
@@ -136,5 +136,7 @@ return next(new Error("The value of default relation should be one of ['or', 'and']")) | ||
module.exports = fp(checkAuth, { | ||
module.exports = fp(fastifyAuth, { | ||
fastify: '4.x', | ||
name: '@fastify/auth' | ||
}) | ||
module.exports.default = fastifyAuth | ||
module.exports.fastifyAuth = fastifyAuth |
{ | ||
"name": "@fastify/auth", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Run multiple auth functions in Fastify", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
50505
1523
0
16