@cloudblob/auth

1.0.0 • Public • Published

cloudblob-auth

Build status Coverage Status

JWT authorization helpers running on cloudblob-store. Use this library in a serverless project or with cloudblob-server.

Getting Started

Install the library with npm

npm install @cloudblob/auth

If your using yarn

yarn add @cloudblob/auth

And then simply configure your cloudblob-store and use the helpers.

var clobauth = require('@cloudblob/auth')


var auth = clobauth.configure({
    storeDB: store, // *Required - an instance of cloudblob-store
    secret: "CbYc5mSAaAZW82YxXR40TqoX", // *Required - secret to use for JWT signing
    authNamespace: "auth", // (Optional) - this defaults to 'auth',
    tokenExpiry: 12 * 60 * 60 // (Optional) In seconds - defaults to 1 day/86400 seconds
})

auth.register(username, password, function(err, res) {
    if (err) {
        console.error(err.msg)
    } else {
        // print the JWT token for the newly registered user's session
        console.log(res)
        /*
        {
            token: "eyJhbGciOi...."
        }
        */
    }
})

auth.login(username, password, function(err, res) {
    if (err) {
        console.error(err.msg)
    } else {
        // print the JWT token for the user login session.
        console.log(res)
        /*
        {
            token: "eyJhbGciOi...."
        }
        */
    }
})

Improvements

  • Add token refresh helper
  • Add token verify helper
  • Add password reset helper

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.00latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.00

Package Sidebar

Install

npm i @cloudblob/auth

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

209 kB

Total Files

9

Last publish

Collaborators

  • loubserian