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

fastify-jwt

Package Overview
Dependencies
Maintainers
9
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-jwt - npm Package Compare versions

Comparing version 0.9.3 to 0.9.4

8

jwt.js

@@ -33,3 +33,3 @@ 'use strict'

if (typeof secret === 'object') {
if (typeof secret === 'object' && !Buffer.isBuffer(secret)) {
if (!secret.private || !secret.public) {

@@ -57,3 +57,4 @@ return next(new Error('missing private key and/or public key'))

signOptions.algorithm.includes('RS') &&
typeof secret === 'string'
(typeof secret === 'string' ||
secret instanceof Buffer)
) {

@@ -66,3 +67,4 @@ return next(new Error(`RSA Signatures set as Algorithm in the options require a private and public key to be set as the secret`))

signOptions.algorithm.includes('ES') &&
typeof secret === 'string'
(typeof secret === 'string' ||
secret instanceof Buffer)
) {

@@ -69,0 +71,0 @@ return next(new Error(`ECDSA Signatures set as Algorithm in the options require a private and public key to be set as the secret`))

{
"name": "fastify-jwt",
"version": "0.9.3",
"version": "0.9.4",
"description": "JWT utils for Fastify",

@@ -38,3 +38,3 @@ "main": "jwt.js",

"@types/jsonwebtoken": "^8.3.0",
"fastify": "^1.11.2",
"fastify": "^2.0.0",
"standard": "^12.0.1",

@@ -41,0 +41,0 @@ "tap": "^12.0.1",

@@ -26,3 +26,3 @@ 'use strict'

test('register', function (t) {
t.plan(9)
t.plan(11)

@@ -67,2 +67,12 @@ t.test('Expose jwt methods', function (t) {

t.test('secret as a Buffer', function (t) {
t.plan(1)
const fastify = Fastify()
fastify.register(jwt, {
secret: Buffer.from('some secret', 'base64')
}).ready(function (error) {
t.is(error, null)
})
})
t.test('deprecated use of options prefix', function (t) {

@@ -237,2 +247,39 @@ t.plan(1)

t.test('RS/ES algorithm in sign options and secret as a Buffer', function (t) {
t.plan(2)
t.test('RS algorithm (Must return an error)', function (t) {
t.plan(1)
const fastify = Fastify()
fastify.register(jwt, {
secret: Buffer.from('some secret', 'base64'),
sign: {
algorithm: 'RS256',
audience: 'Some audience',
issuer: 'Some issuer',
subject: 'Some subject'
}
}).ready(function (error) {
t.is(error.message, 'RSA Signatures set as Algorithm in the options require a private and public key to be set as the secret')
})
})
t.test('ES algorithm (Must return an error)', function (t) {
t.plan(1)
const fastify = Fastify()
fastify.register(jwt, {
secret: Buffer.from('some secret', 'base64'),
sign: {
algorithm: 'ES256',
audience: 'Some audience',
issuer: 'Some issuer',
subject: 'Some subject'
}
}).ready(function (error) {
t.is(error.message, 'ECDSA Signatures set as Algorithm in the options require a private and public key to be set as the secret')
})
})
})
t.test('secret as a function', function (t) {

@@ -239,0 +286,0 @@ t.plan(2)

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