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

cognito-express

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cognito-express - npm Package Compare versions

Comparing version 2.0.18 to 2.0.19

60

lib/strategy.js

@@ -51,38 +51,42 @@ "use strict";

let decodedJwt = jwt.decode(token, { complete: true });
try {
if (!decodedJwt) throw new TypeError('Not a valid JWT token');
if (!decodedJwt) return callback(`Not a valid JWT token`, null);
if (decodedJwt.payload.iss !== this.iss)
throw new TypeError('token is not from your User Pool');
if (decodedJwt.payload.iss !== this.iss)
return callback(`token is not from your User Pool`, null);
if (decodedJwt.payload.token_use !== this.tokenUse)
throw new TypeError(`Not an ${this.tokenUse} token`);
if (decodedJwt.payload.token_use !== this.tokenUse)
return callback(`Not an ${this.tokenUse} token`, null);
let kid = decodedJwt.header.kid;
let pem = this.pems[kid];
let kid = decodedJwt.header.kid;
let pem = this.pems[kid];
if (!pem) throw new TypeError(`Invalid ${this.tokenUse} token`);
if (!pem) return callback(`Invalid ${this.tokenUse} token`, null);
let params = {
token: token,
pem: pem,
iss: this.iss,
maxAge: this.tokenExpiration
};
if (callback) {
jwtVerify(params, callback);
} else {
return new Promise((resolve, reject) => {
jwtVerify(params, (err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});
}
} catch(err) {
if(!callback) throw err;
let params = {
token: token,
pem: pem,
iss: this.iss,
maxAge: this.tokenExpiration
};
if (callback) {
jwtVerify(params, callback);
} else {
return new Promise((resolve, reject) => {
jwtVerify(params, (err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});
callback(err.message, null);
}
});
if (!callback) {

@@ -89,0 +93,0 @@ return p;

{
"name": "cognito-express",
"version": "2.0.18",
"version": "2.0.19",
"description": "cognito-express authenticates API requests on a Node-Express application by verifying the signature of AccessToken or IDToken generated by Amazon Cognito.",

@@ -5,0 +5,0 @@ "main": "./lib/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