passport-strategy-runner
What is it?
This lets you run a Passport strategy without having Passport involved:
;; const strategy = { ;}; const req = {}; // If no callback is supplied, will return a promise.;
Why would you want this?
Maybe you want to write unit tests for your strategy, maybe you want to make a passport competitor that works with Passport strategies, maybe you just decided you wanted to figure out how Passport works. :)
API
runStrategy(strategy, request[, options][, done])
Runs the specified strategy, with the specified request
and the specified options
.
options
here is the options object that would be passed to passport.authenticate(strategy, options)
.
If you do not pass a callback to this function, it will return a Promise which
resolves to the result. The result will be an object of one of the following
forms:
{type: 'success', user, info}
{type: 'fail', challenge, status, message, messageType}
{type: 'redirect', url, status}
{type: 'pass'}