passport-cognito
Advanced tools
Comparing version 0.1.2 to 0.1.3
// Load modules. | ||
var AWS = require('aws-sdk'); | ||
var util = require('util'); | ||
var Strategy = require('passport-strategy').Strategy; | ||
var passport = require('passport-strategy'); | ||
@@ -51,7 +51,7 @@ var AuthenticationDetails = require('./cognito/AuthenticationDetails'); | ||
if (!options) throw new Error('Cognito strategy requires options'); | ||
if (!verify) throw new Error('Cognito strategy requires a verify function'); | ||
if (!verify) throw new Error('Cognito strategy requires a verify callback'); | ||
AWS.config.region = 'ap-northeast-1'; | ||
Strategy.call(this); | ||
passport.Strategy.call(this); | ||
this.name = 'cognito'; | ||
@@ -61,2 +61,5 @@ this._userPoolId = options.userPoolId; | ||
this._verify = verify; | ||
this.accessToken; | ||
this.idToken; | ||
this.refreshToken; | ||
} | ||
@@ -66,3 +69,3 @@ | ||
// Inherit from `passport-strategy`. | ||
util.inherits(CognitoStrategy, Strategy); | ||
util.inherits(CognitoStrategy, passport.Strategy); | ||
@@ -91,3 +94,2 @@ | ||
var self = this; | ||
@@ -103,6 +105,7 @@ | ||
onSuccess: function (result) { | ||
accessToken = result.getAccessToken().getJwtToken(); | ||
idToken = result.getIdToken().getJwtToken(); | ||
refreshToken = result.getRefreshToken().getToken(); | ||
self.accessToken = result.getAccessToken().getJwtToken(); | ||
self.idToken = result.getIdToken().getJwtToken(); | ||
self.refreshToken = result.getRefreshToken().getToken(); | ||
if (!accessToken || !idToken) { | ||
@@ -114,3 +117,3 @@ return self.fail({ message: options.badRequestMessage || 'Missing token' }, 400); | ||
try { | ||
self._verify(accessToken, idToken, refreshToken, profile, verified); | ||
self._verify(self.accessToken, self.idToken, self.refreshToken, profile, verified); | ||
} catch (ex) { | ||
@@ -117,0 +120,0 @@ return self.error(ex); |
{ | ||
"name": "passport-cognito", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Express passport module for Cognito User Pools", | ||
"main": "./lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha --require test/bootstrap/node test/*.test.js --timeout 10000" | ||
}, | ||
@@ -34,3 +34,9 @@ "repository": { | ||
"util": "^0.10.3" | ||
}, | ||
"devDependencies": { | ||
"assert": "^1.4.1", | ||
"chai": "^3.5.0", | ||
"chai-passport-strategy": "^1.0.0", | ||
"mocha": "^3.1.2" | ||
} | ||
} |
@@ -18,3 +18,3 @@ # passport-cognito | ||
### Confiture Strategy | ||
### Configure Strategy | ||
@@ -29,3 +29,3 @@ ```javascript | ||
}, | ||
function(accessToken, refreshToken, profile, cb) { | ||
function(accessToken, idToken, refreshToken, profile, cb) { | ||
process.nextTick(function() { | ||
@@ -40,3 +40,3 @@ ... | ||
### Authenticate Requests | ||
To authenticate a user, send username and password by POST request like the following. | ||
To authenticate a user, send username and password to serser-side by POST request like the following. | ||
@@ -43,0 +43,0 @@ ```javascript |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
79654
20
2072
1
4