sn-auth

0.0.1 • Public • Published

sn-auth

Basic Authentication Middleware

Introduction

The sn-auth package provides a simple interface into the crypto.pbekdf2 function suitable for use with the sn-persist package. It provides a simplified interface to create a hashed password entry and to validate a password.

Installation

The simplest way to install the package is via npm:

    npm install sn-auth

Or via GIT:

    git clone git@github.com:smithee-us/sn-auth.git

Usage

To create a password entry, create a new instance of the pbkdf2 object, then call the generateSecret() function:

    var pbkdf2 = require( 'sn-auth' ).pbkdf2;
    var password_entry = new pbkdf2( { password: "whatever" }, function( err ) {
      if( ! err ) {
        this.generateSecret( function( err ) {
          console.log( this );
        } );
      }
    } );

To validate a trial password, do this:

    password_entry.validate( "whatever", function( err, valid ) {
      if( valid ) {
        console.log( "password matches" );
      } else {
        console.log( "password doesn't match" );
      }
    } );

Readme

Keywords

none

Package Sidebar

Install

npm i sn-auth

Weekly Downloads

0

Version

0.0.1

License

none

Last publish

Collaborators

  • meadhbh