npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

apb-auth-client

v0.4.2

Published

a promise based user authentication package for javascript

Readme

APB-auth-client

JWT User authentication

APB-auth-client is a promise based user authentication package for javascript clients, or frontends, using JWT and localStorage.

This package avoids the use of cookies and request headers which are problematic when making cross-origin requests. ie. When the client and the server (or frontend and backend) are on different machines or ports. This package is designed to work with the auth-server package which actually implements the JWT side of things.

APB-auth-client uses Axios to handle ajax requests.

Setup:

import { AuthClient } from './apb-auth-client/auth-client.js';
const auth = new AuthClient("http://127.0.0.1:3000");

Login

auth.login('/login', this.state.uname, this.state.psw)
.then(function(data){
  console.log("login result:",data);
})
.catch(function (error) {
  console.log(error);
});

Use the login method to request a new token from the server and automatically store it in localStorage to be used in future authorized requests.

Returns a promise.
Resolves with data on success.
Rejects with error.

Logout

auth.logout("/logout")
.then(function(data){
  console.log("logout result:",data);
})
.catch(function (error) {
  console.log(error);
});

User the logout method to request invalidation of the JWT token by the server, and to overwrite the existing stored token.

Returns a promise.
Resolves with confirmation message on success.
Rejects with error.

Authorized requests

auth.post("/secrets", {
  "show me secrets":"please"
})
.then(function (response) {
  console.log(response);
})
.catch(function (error) {
  console.log(error);
});
auth.get("/secrets")
.then(function (response) {
  console.log(response);
})
.catch(function (error) {
  console.log(error);
});

Make post / get requests using apb-auth-client to include the user authentication token in every request automatically. If no token is found the promise immediately rejects.

For post requests, include the data object as the second parameter. Get requests should not contain a data object.

Unauthorized requests

auth.post("/secrets", {
  "show me secrets":"please"
}, false)
.then(function (response) {
  console.log(response);
})
.catch(function (error) {
  console.log(error);
});

Make post / get requests with a third argument set to false to prevent the inclusion of a token. This option just passes on the request to Axios directly. Useful for creating accounts or doing other stuff without authentication and without including Axios directly.

Run Tests

Start by building the browser bundle:

npm run-script build

Then open the test.html file in your favourite browser.