New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

byu-jwt

Package Overview
Dependencies
Maintainers
1
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 0.0.7 to 0.0.8

64

index.js

@@ -33,39 +33,49 @@ var Promise = require('bluebird');

exports.verifyJWT = function (jwt, wellKnownURL) {
var algorithms;
// Just return the public key.
exports.getPublicKey = function(wellKnownURL) {
return exports.getWellKnown(wellKnownURL)
.then(function (result) {
return getPublicKeyUtil(result);
}
);
};
var openid_configuration = result;
var jwks_uri = openid_configuration["jwks_uri"];
algorithms = openid_configuration["id_token_signing_alg_values_supported"];
function getPublicKeyUtil(wellKnownResult) {
var openid_configuration = wellKnownResult;
var jwks_uri = openid_configuration["jwks_uri"];
algorithms = openid_configuration["id_token_signing_alg_values_supported"];
var options = {
url: jwks_uri,
method: 'GET'
};
var options = {
url: jwks_uri,
method: 'GET'
};
return promised_request(options);
})
return promised_request(options)
.then(function (result) {
var keys = JSON.parse(result.body).keys;
var cert = keys[0].x5c[0];
var keys = JSON.parse(result.body).keys;
var cert = keys[0].x5c[0];
//format cert
cert = cert.replace(/(.{64})/g, "$1\n");
var prefix = "-----BEGIN CERTIFICATE-----\n";
var postfix = "\n-----END CERTIFICATE-----";
cert = prefix + cert + postfix;
//format cert
cert = cert.replace(/(.{64})/g, "$1\n");
var prefix = "-----BEGIN CERTIFICATE-----\n";
var postfix = "\n-----END CERTIFICATE-----";
cert = prefix + cert + postfix;
//extract public key
return promisedGetPublicKey(cert);
}
)
//extract public key
return promisedGetPublicKey(cert);
});
}
exports.verifyJWT = function (jwt, wellKnownURL) {
var algorithms;
return exports.getWellKnown(wellKnownURL)
.then(function (result) {
var key = result.publicKey;
return getPublicKeyUtil(result)
.then(function (result) {
var key = result.publicKey;
//verify jwt and returns decoded jwt
return jsonwebtoken.verify(jwt, key, {algorithms: algorithms});
}
);
//verify jwt and returns decoded jwt
return jsonwebtoken.verify(jwt, key, {algorithms: algorithms});
});
});
};
{
"name": "byu-jwt",
"version": "0.0.7",
"version": "0.0.8",
"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",

@@ -6,7 +6,12 @@ # byu-jwt

* getWellKnown
* getPublicKey
* verifyJWT
* getPublicKeyUtil
## getWellKnown(wellKnownURL)
getWellKnown retrieves the response of the specified *.well-known* URL and if *cachWellKnowns* is set to *true* returns the previously retrieved response in the form of a promise.
getWellKnown retrieves the response of the specified *.well-known* URL and if *cacheWellKnowns* is set to *true* returns the previously retrieved response in the form of a promise.
## getPublicKey(wellKnownURL)
getPublicKey retrieves the PEM formatted X509 certificate
## verifyJWT(jwt, wellKnownURL)

@@ -16,2 +21,5 @@ verifyJWT uses the URLs and values found from the specified *.well-known* URL to verify and decode the provided signed JWT.

## cacheWellknowns
cacheWellknowns is a boolean variable provided to set whether to cache the response of previously requested *.well-known* URLs.
cacheWellknowns is a boolean variable provided to set whether to cache the response of previously requested *.well-known* URLs.
## getPublicKeyUtil(resultFromGetWellKnown)
getPublicKeyUtil is a private reusable function the takes the result from a getWellKnown request and does the actual work of PEM formatting the X509 certificate
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