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

koa-passport

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-passport - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

36

lib/framework/koa.js

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

var passport = require('passport')
var co = require('co')

@@ -44,7 +45,7 @@ /**

/**
* assport's authenticate middleware for Koa.
* Passport's authenticate middleware for Koa.
*
* @param {String|Array} name
* @param {Object} options
* @param {Function} callback
* @param {GeneratorFunction} callback
* @return {GeneratorFunction}

@@ -54,2 +55,29 @@ * @api private

function authenticate(passport, name, options, callback) {
// normalize arguments
if (typeof options === 'function') {
callback = options
options = {}
}
options = options || {}
if (callback) {
if (callback.constructor.name !== 'GeneratorFunction') {
throw TypeError('Your custom authentication callback must be a Generator Function')
}
// When the callback is set, neither `next`, `res.redirect` or `res.end`
// are called. That is, a workaround to catch the `callback` is required.
// The `passportAuthenticate()` method below will therefore set
// `callback.done`. Then, once the authentication finishes, the modified
// callback yields the original one and afterwards triggers `callback.done`
// to inform `passportAuthenticate()` that we are ready.
var _callback = callback
callback = function callback(err, user, info) {
co(function*() {
yield _callback(err, user, info)
callback.done(null, false)
})()
}
}
var middleware = _authenticate(passport, name, options, callback)

@@ -81,2 +109,6 @@ return function* passportAuthenticate(next) {

if (callback) {
callback.done = done
}
// call the connect middleware

@@ -83,0 +115,0 @@ middleware(ctx.req, res, done)

3

package.json

@@ -7,3 +7,3 @@ {

},
"version": "0.3.2",
"version": "0.4.0",
"description": "Passport middleware for Koa",

@@ -19,2 +19,3 @@ "keywords": [

"dependencies": {
"co": "^3.0.6",
"passport": ">=0.2.x"

@@ -21,0 +22,0 @@ },

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