Skip to content

oldlam/superagent-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SuperAgent JWT Plugin

a superagent plugin to retrieve/add JWT from/to headers, storing with localStorage.

this plugin:

  • tries to retrieve JWT from response header and store it to localStorage
  • set JWT in request Authorization header if any was saved to localStorage before

Installation

$ npm i superagent-jwt -S

Usage

var request = require('superagent');
var JWT = require('superagent-jwt');

var jwt = JWT({
  header: 'jwt', // header name to try reading JWT from responses, default to 'jwt'
  local: 'jwt'   // key to store the JWT in localStorage, also default to 'jwt'
});

request
  .get('/some-url')
  .use(jwt)
  .end(function(err, res) {
    /**
     * JWT will be sent along with the request
     * if one was received from server header before
     */
  });

License

MIT

About

a superagent plugin to retrieve/add JWT from/to headers, storing with localStorage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published