Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fastify/bearer-auth

Package Overview
Dependencies
Maintainers
20
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/bearer-auth - npm Package Compare versions

Comparing version 9.2.0 to 9.2.1

examples/example.js

2

index.js
'use strict'
const fp = require('fastify-plugin')
const verifyBearerAuthFactory = require('./lib/verifyBearerAuthFactory')
const verifyBearerAuthFactory = require('./lib/verify-bearer-auth-factory')

@@ -6,0 +6,0 @@ function fastifyBearerAuth (fastify, options, done) {

{
"name": "@fastify/bearer-auth",
"version": "9.2.0",
"version": "9.2.1",
"description": "An authentication plugin for Fastify",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -46,2 +46,18 @@ 'use strict'

test('missing space between bearerType and key fails correctly', (t) => {
t.plan(2)
fastify.inject({
method: 'GET',
url: '/test',
headers: {
authorization: 'Bearer123456'
}
}).then(response => {
t.equal(response.statusCode, 401)
t.match(JSON.parse(response.body).error, /invalid authorization header/)
}).catch(err => {
t.error(err)
})
})
test('missing header route fails correctly', (t) => {

@@ -62,3 +78,3 @@ t.plan(2)

await fastify.register(plugin, { addHook: false, keys: new Set(['123456']) })
await fastify.decorate('allowAnonymous', function (request, _, done) {
fastify.decorate('allowAnonymous', function (request, _, done) {
if (!request.headers.authorization) {

@@ -124,3 +140,3 @@ return done()

await fastify.register(plugin, { addHook: false, keys: new Set(['123456']) })
await fastify.decorate('alwaysValidAuth', function (request, _, done) {
fastify.decorate('alwaysValidAuth', function (request, _, done) {
return done()

@@ -127,0 +143,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc