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

byu-jwt

Package Overview
Dependencies
Maintainers
13
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

byu-jwt - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

96

lib/index.js

@@ -31,2 +31,3 @@ /**

function ByuJWT(options) {
const byuJwt = {};

@@ -45,61 +46,64 @@ // normalize options

if (!(this instanceof ByuJWT)) return new ByuJWT(options)
this.options = Object.assign({}, options)
// store options
byuJwt.options = Object.assign({}, options)
// set cache TTL
this.cache = Cache()
this.cache.setTTL(options.cacheTTL)
byuJwt.cache = Cache()
byuJwt.cache.setTTL(options.cacheTTL)
}
byuJwt.authenticate = headers => {
return init(byuJwt.cache)
.then(openIdConfig => authenticate(byuJwt.options, openIdConfig, headers))
}
ByuJWT.prototype.authenticate = function(headers) {
return init(this.cache)
.then(openIdConfig => authenticate(this.options, openIdConfig, headers))
}
byuJwt.authenticateUAPIMiddleware = function(req, res, next) {
this.authenticate(req.headers)
.then(verifiedJWTs => {
req.verifiedJWTs = verifiedJWTs
next()
})
.catch(err => {
console.error(err.stack)
const response = err instanceof AuthenticationError
? { code: 401, message: err.message }
: { code: 500, message: 'Error determining authentication' }
res.status(response.code).send({ metadata: { validation_response: response } })
})
}
ByuJWT.prototype.authenticateUAPIMiddleware = function(req, res, next) {
this.authenticate(req.headers)
.then(verifiedJWTs => {
req.verifiedJWTs = verifiedJWTs
next()
})
.catch(err => {
console.error(err.stack)
const response = err instanceof AuthenticationError
? { code: 401, message: err.message }
: { code: 500, message: 'Error determining authentication' }
res.status(response.code).send({ metadata: { validation_response: response } })
})
}
byuJwt.decodeJWT = function(jwt) {
return init(this.cache)
.then(openIdConfig => decodeJWT(this.options, openIdConfig, jwt))
}
ByuJWT.prototype.decodeJWT = function(jwt) {
return init(this.cache)
.then(openIdConfig => decodeJWT(this.options, openIdConfig, jwt))
}
byuJwt.getOpenIdConfiguration = function() {
return getOpenIdConfiguration(this.cache)
}
ByuJWT.prototype.getOpenIdConfiguration = function() {
return getOpenIdConfiguration(this.cache)
}
byuJwt.getPublicKey = function() {
return init(this.cache)
.then(getPublicKey)
}
ByuJWT.prototype.getPublicKey = function() {
return init(this.cache)
.then(getPublicKey)
}
byuJwt.verifyJWT = function(jwt) {
return init(this.cache)
.then(openIdConfig => verifyJWT(this.options, openIdConfig, jwt))
.then(() => true)
.catch(() => false)
}
ByuJWT.prototype.verifyJWT = function(jwt) {
return init(this.cache)
.then(openIdConfig => verifyJWT(this.options, openIdConfig, jwt))
.then(() => true)
.catch(() => false)
Object.defineProperties(byuJwt, {
cacheTTL: {
get: function() { return this.cache.getTTL() },
set: function(ttl) { this.cache.setTTL(ttl) }
}
});
return byuJwt;
}
Object.defineProperties(ByuJWT.prototype, {
cacheTTL: {
get: function() { return this.cache.getTTL() },
set: function(ttl) { this.cache.setTTL(ttl) }
}
});
Object.defineProperties(ByuJWT, {

@@ -106,0 +110,0 @@ 'BYU_JWT_HEADER_CURRENT': {

{
"name": "byu-jwt",
"version": "1.0.0",
"version": "1.0.1",
"description": "The byu-jwt module provides helpful functions to retrieve a specified BYU .well-known URL and verify BYU signed JWTs.",

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

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