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

@truflect/jwt-authentication

v0.1.1

Published

Simple JWT authentication helper library for browser UI apps.

Readme

JWT Authentication

Minimal browser-side JWT auth library with:

  • login (username/password)
  • access token in sessionStorage
  • refresh token in localStorage
  • axios auth header injection
  • automatic token refresh on 401
  • startup session bootstrap (verify access, then refresh fallback)
  • logout clears both local tokens by default (no server endpoint needed)

Install

npm install @truflect/jwt-authentication

Default Auth Paths

  • AUTH_LOGIN_PATH: /v2/auth/token/
  • AUTH_REFRESH_PATH: /v2/auth/token/refresh/
  • AUTH_VERIFY_PATH: /v2/auth/token/verify/

AUTH_LOGOUT_PATH is optional and empty by default.

Basic Setup

import { createAuthSystem } from '@truflect/jwt-authentication';

const auth = createAuthSystem({
  baseUrl: 'https://your-api.example.com',
  env: process.env,
});

Override Config At Setup Time

const auth = createAuthSystem({
  baseUrl: 'https://api.example.com',
  env: process.env,
  configOverrides: {
    AUTH_LOGIN_PATH: '/custom/auth/login/',
    AUTH_REFRESH_PATH: '/custom/auth/refresh/',
    AUTH_VERIFY_PATH: '/custom/auth/verify/',
    AUTH_HEADER_PREFIX: 'Bearer',
    REFRESH_REQUEST_KEY: 'refresh_token',
    VERIFY_REQUEST_KEY: 'access_token',

    // Optional only if backend supports logout API
    AUTH_LOGOUT_PATH: '/custom/auth/logout/',
    LOGOUT_REQUEST_KEY: 'refresh_token',
    ENABLE_LOGOUT_API_CALL: false,

    // Customize the key for the username/phone field in login request
    LOGIN_USERNAME_KEY: 'username', 
  },
  tokenKeys: {
    accessTokenKey: 'my_access_token',
    refreshTokenKey: 'my_refresh_token',
  },
});

Usage

const { authService, client, session } = createAuthSystem({
  baseUrl: 'http://localhost:8000',
  env: process.env,
});

await session.initialize();
await authService.login({ username: 'demo', password: 'demo123' });

const response = await client.get('/v2/user/profile/');
console.log(response.data);

await authService.logout();

Publish Scripts

npm run pack:check
npm run publish:npm
npm run publish:github

GitHub Actions Release + Publish

Workflow file:

  • .github/workflows/release.yml

On push to main, it:

  1. runs pre-release checks (npm run pack:check)
  2. reads version from package.json
  3. creates tag v<version> if not already present
  4. creates a GitHub release
  5. publishes package to GitHub Packages (npm.pkg.github.com)

For GitHub Packages, ensure repository/package permissions allow publish.

Browser Demo

A minimal browser demo is included:

  • example/index.html
  • example/browser-demo.js

Run it with any static server from project root:

npx serve .

Then open:

  • http://localhost:3000/example/

Update username, password, and API URL in example/browser-demo.js for your backend.

License

Licensed under the Apache License 2.0.

Copyright 2026 Build From Bits Pvt Ltd.