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

@versini/auth-provider

v8.1.2

Published

High-level React authentication components & hooks supporting password (PKCE Code) and Passkey (WebAuthn) flows. Built on the primitives from `@versini/auth-common`.

Downloads

521

Readme

@versini/auth-provider

High-level React authentication components & hooks supporting password (PKCE Code) and Passkey (WebAuthn) flows. Built on the primitives from @versini/auth-common.

Install

pnpm add @versini/auth-provider @versini/auth-common react react-dom

Peer deps: react (>= 19) & react-dom.

Packages Relationship

@versini/auth-provider  ->  @versini/auth-common (utilities, constants)
												 ->  @versini/ui-hooks (local storage abstraction)

Features

  • PKCE Code + Refresh token flow
  • Passkey (WebAuthn) registration & authentication
  • Silent access token refresh with refresh token rotation
  • Role / permission helpers (re-export of isGranted & AUTH_TYPES)
  • Local storage isolation per clientId
  • Timezone & build metadata banner injection (in distributed bundles)

Quick Start (Custom Auth Backend)

import { AuthProvider } from "@versini/auth-provider";

function App() {
  return (
    <AuthProvider clientId="my-web-app" sessionExpiration="3600" debug>
      <MainRoutes />
    </AuthProvider>
  );
}

Inside your components:

import { useAuth } from "@versini/auth-provider/hooks";

export function Profile() {
  const { user, isAuthenticated, login, logout, getAccessToken } = useAuth();

  if (!isAuthenticated) {
    return <button onClick={() => login("alice", "p@ssw0rd")}>Login</button>;
  }
  return (
    <div>
      <p>User: {user?.username}</p>
      <button onClick={logout}>Logout</button>
      <button
        onClick={async () => {
          const token = await getAccessToken();
          console.log("access", token.slice(0, 20) + "...");
        }}
      >
        Get Access Token
      </button>
    </div>
  );
}

Passkey (WebAuthn) Flow

const { registeringForPasskey, loginWithPasskey } = useAuth();

// After user authenticates with password you can offer passkey registration:
await registeringForPasskey();

// Later, user can login directly with passkey:
await loginWithPasskey();

Public API Summary

  • <AuthProvider /> – Core provider. Props:
    • clientId: string (required)
    • sessionExpiration?: string (TTL hint sent to backend)
    • domain?: string (multi-tenant / custom domain support)
    • debug?: boolean (enables internal logging via useLogger)
    • endpoint?: string (override default auth service URL)
  • Hooks (from hooks entry):
    • useAuth() – Returns AuthContextProps:
      • state: isLoading, isAuthenticated, user, logoutReason, authenticationType
      • methods: login(username, password), logout(), getAccessToken(), getIdToken(), registeringForPasskey(), loginWithPasskey()
  • Re-exports from @versini/auth-common:
    • AUTH_TYPES, isGranted

Storage Strategy

Local storage keys are namespaced: @@auth@@::<clientId>::@@<token-type>@@. On logout or token invalidation all related keys are purged atomically (removeStateAndLocalStorage).

Token Refresh

getAccessToken() validates the existing access token; if expired/invalid it attempts a silent refresh via TokenManager.refreshtoken(). Failure triggers a forced logout (security-first principle).

Error & Security Principles

  • Deny-by-default: unauthorized or invalid token state leads to logout.
  • All network operations funnel through typed helpers; unexpected responses cause cleanup.
  • No sensitive values are logged unless debug is enabled (still avoid including raw tokens in production logs).
  • PKCE flow ensures authorization code interception resistance.

Bundling Notes

Entry files are emitted without hashes (index.js, auth.js, hooks.js) for stable package exports; internal split chunks are hashed (chunks/[name].[hash].js). This is intentional for library consumption stability.

TypeScript

Distributed ESM with full .d.ts declarations; strict types encourage safe usage. Avoid any; leverage AuthContextProps for context consumers.

Roadmap / Ideas

  • SSR helpers for preloading user session
  • Optional cookie-based storage abstraction
  • Enhanced role/permission model (attribute-based access)

License

MIT © gizmette.com