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

@av3rgun/authy

v0.1.2

Published

Framework-independent JWT client for XHOST auth

Readme

@av3rgun/authy

Framework-independent client for the XHOST auth service. Requires Axios 1.x.

import axios from 'axios';
import { createAuthClient } from '@av3rgun/authy';

let currentSession = null;
const auth = createAuthClient({
  baseURL: '/api/auth',
  axios,
  session: {
    get: () => currentSession,
    set: (value) => { currentSession = value; },
    clear: () => { currentSession = null; },
  },
  onSessionExpired: (error) => console.log(error.message),
});

await auth.login({ email, password });
const api = axios.create({ baseURL: '/api' });
const detach = auth.attach(api);
await api.get('/accounts');
detach();

Methods: login(credentials), register(payload), refresh(), me(), setMasterDevice({ device_id, device_name }), revoke(refreshToken), logout(), attach(axiosInstance) (returns interceptor cleanup). Registration does not log in. Login and refresh save the full server session, including user fields. Expiry timestamps are Unix seconds. Refresh rotates both tokens and is coalesced per client.

Payloads are plain objects: the library adds { data: payload } and unwraps { status: 'success', body }. Errors are AuthError with code, status, cause. The current server returns messages without machine codes; those errors receive http_401, http_403, etc. Network failures have status: null.

Attach only to trusted API instances: credentials are sent to their requests. Use { authy: false } on an individual request to skip auth/retry. A 401 triggers at most one replay; 403 on resource endpoints does not trigger refresh. A rejected refresh (401/403) clears the session and calls onSessionExpired. Network and 5xx errors keep credentials. Logout clears locally before revoking and still rejects if the revocation failed. In-flight login/refresh cannot restore a logged-out session.

Session callbacks are synchronous. Storage, routing and notifications belong to the application. Prefer memory by default; persistent browser storage exposes tokens to scripts. Refresh coordination is per client, not across browser tabs. The client does not verify JWT signatures; authorization belongs to the backend.

Development

From the monorepo root:

npm install
npm test --workspace @av3rgun/authy
npm run build --workspace @av3rgun/authy
npm pack --workspace @av3rgun/authy
npm run play

Playground uses a local /auth-api proxy to https://id.xho.st; restart Vite after changing AUTHY_AUTH_TARGET. Tokens in the playground stay in memory and are hidden; reloading clears them. Do not use real credentials in shared demos.

When ready to publish, inspect the tarball then run npm publish --workspace @av3rgun/authy --access public. Publication requires ownership of the npm scope. Consumers should pin "@av3rgun/authy": "0.1.0" to use the same version across projects.