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

@autonomous2026/auth-sdk

v1.0.2

Published

Client SDK for auth-service SSO flow with OAuth2 PKCE

Readme

@autonomous2026/auth-sdk

Client SDK for auth-service SSO OAuth2 flow with PKCE support.

Installation

npm install @autonomous2026/auth-sdk

Or link locally:

cd sdk && npm install && npm run build
cd .. && npm link ./sdk

Quick Start (React)

1. Wrap your app with AuthProvider

import { AuthProvider } from "@autonomous2026/auth-sdk/react";

const authConfig = {
  ssoUrl: "https://sso.example.com",
  clientId: "my-app",
  redirectUri: "https://app.example.com/callback",
  scope: "openid profile email",
};

function App() {
  return (
    <AuthProvider config={authConfig}>
      <YourApp />
    </AuthProvider>
  );
}

2. Use the hooks

import { useAuth, useUser } from "@autonomous2026/auth-sdk/react";

function LoginButton() {
  const { isAuthenticated, login, logout, isLoading } = useAuth();

  if (isLoading) return <div>Loading...</div>;

  if (isAuthenticated) {
    return <button onClick={() => logout()}>Logout</button>;
  }

  return <button onClick={() => login()}>Login with SSO</button>;
}

function UserProfile() {
  const user = useUser();

  if (!user) return null;

  return (
    <div>
      <p>Welcome, {user.fullName || user.email}!</p>
    </div>
  );
}

3. Handle OAuth2 callback

import { useAuthCallback } from "@autonomous2026/auth-sdk/react";
import { useNavigate } from "react-router-dom";

function CallbackPage() {
  const navigate = useNavigate();
  const { isLoading, error, success } = useAuthCallback(authConfig);

  useEffect(() => {
    if (success) {
      navigate("/dashboard");
    }
  }, [success, navigate]);

  if (isLoading) return <div>Processing login...</div>;
  if (error) return <div>Login failed: {error}</div>;

  return null;
}

Vanilla JavaScript Usage

import { AuthClient } from "@autonomous2026/auth-sdk";

const client = new AuthClient({
  ssoUrl: "https://sso.example.com",
  clientId: "my-app",
  redirectUri: "https://app.example.com/callback",
  scope: "openid profile email",
});

// Start login
await client.authorize();

// Handle callback (on callback page)
const result = await client.handleCallback(code, state);
if (result.success) {
  console.log("Logged in!", result.tokens);
}

// Check auth status
if (client.isAuthenticated()) {
  const user = client.getUser();
  console.log("User:", user);
}

// Get access token (auto-refreshes if expired)
const token = await client.getValidAccessToken();

// Logout
client.logout();

API Reference

AuthClient

| Method | Description | | ----------------------------- | ------------------------------- | | authorize(options?) | Start OAuth2 login flow | | handleCallback(code, state) | Exchange code for tokens | | refreshToken() | Refresh access token | | logout(redirectUri?) | Logout and redirect to SSO | | isAuthenticated() | Check if user is logged in | | getAccessToken() | Get current access token | | getUser() | Get decoded user from JWT | | getValidAccessToken() | Get token, refresh if expired | | clearTokens() | Clear tokens without SSO logout |

AuthorizeOptions

| Option | Type | Description | | ----------- | --------------------------------------- | -------------------------------------- | | prompt | 'select_account' \| 'none' \| 'login' | Force account selection or silent auth | | loginHint | string | Pre-fill email for login |

User Object

| Field | Type | Description | | --------------- | ----------- | --------------- | | id | string | User ID | | email | string | User email | | fullName | string? | Full name | | roles | string[]? | User roles | | companyDomain | string? | Company domain | | isEppUser | boolean? | EPP user status |

React Hooks

| Hook | Returns | Description | | ------------------------- | ------------------ | ---------------------- | | useAuth() | AuthContextValue | Auth state and actions | | useUser() | User \| null | Current user info | | useAuthCallback(config) | Callback state | Handle OAuth2 callback |

AuthProvider Props

| Prop | Type | Default | Description | | --------------- | ------------ | -------- | -------------------------------- | | config | AuthConfig | required | Auth configuration | | autoRefresh | boolean | true | Auto-refresh tokens | | refreshBuffer | number | 60 | Seconds before expiry to refresh | | onAuthChange | function | - | Callback on auth state change |

Custom Storage

By default, tokens are stored in localStorage. You can provide a custom storage:

const client = new AuthClient({
  ...config,
  storage: {
    getItem: (key) => sessionStorage.getItem(key),
    setItem: (key, value) => sessionStorage.setItem(key, value),
    removeItem: (key) => sessionStorage.removeItem(key),
  },
});

Security

  • Uses PKCE (S256) to prevent authorization code interception
  • State parameter for CSRF protection
  • PKCE verifier stored in sessionStorage (not localStorage)
  • Automatic token refresh before expiry