Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

passport-raindrop

1.0.3 • Public • Published

Raindrop Passport Module

The 'raindrop' strategy authenticates a user by confirming the user has input an API-generated message into the Hydro mobile app.

Installation

$ npm install passport-raindrop

Configuration

The verify callback is required to verify a valid site user is being authenticated. Authentication fails if no user is found.

const passport = require('passport'),
      RaindropStrategy = require('passport-raindrop')      

// Initialize the raindrop. Declared as a variable in order to access Raindrop SDK functions later.   
let raindrop = new RaindropStrategy({
    environment: ENVIRONMENT,
    clientId: CLIENT_ID,
    clientSecret: CLIENT_SECRET,
    applicationId: APPLICATION_ID
}, function (authUser, done) {   
    // This verifies the user and returns it to the authentication
    let user = userDB.find(usr => usr.hydroId === authUser.hydroId);
    return user ? done(null, user) : done(new Error('User not found.'), null);
});

// Pass the strategy into passport
passport.use(raindrop);

Usage

Authenticate Requests

Use passport.authenticate() and specify the 'raindrop' strategy.

passport.authenticate('raindrop', {
    successRedirect: '/pass',
    failureRedirect: '/fail'
})(req, res, next);

Generate Verification Message

let message = HydrogenAPI.raindrop.generateMessage();

In this example HydrogenAPI is the export from the above 'Configuration'. See the 'Complete Example' below for the full in-context configuration.

Complete Example

A complete example of using this library.

Documentation

Hydrogen API

Passport JS

Author

Red-Maximus

License

Unlicensed

Keywords

none

install

npm i passport-raindrop

Downloadsweekly downloads

6

version

1.0.3

license

none

last publish

collaborators

  • avatar
Report a vulnerability