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

@openai/auth

v0.1.0

Published

Branded Sign in with ChatGPT UI and interaction lifecycle for existing authentication systems

Readme

@openai/auth

Add Sign in with ChatGPT buttons to a JavaScript application without React. The package provides DOM buttons, shared interaction state, and TypeScript contracts for connecting your authentication system.

Use @openai/auth/client to mount buttons in the browser. Import portable types and ChatGPTAuthError from @openai/auth. Both entry points support ESM and CommonJS. For React components, use @openai/auth-react.

Light and dark Sign in with ChatGPT buttons in outlined and contained variants.

Both packages share button styles. The profile components shown above are available in @openai/auth-react.

Install

npm install @openai/auth

This package does not require React. See the getting-started guide for authentication setup.

Mount a sign-in button

Add a container to your page:

<div id="sign-in"></div>
<p id="sign-in-error" role="alert"></p>

Mount the button after the elements exist:

import { createChatGPTAuth } from '@openai/auth/client';

const auth = createChatGPTAuth({
  authPath: '/auth/chatgpt',
  onError: () => {
    document.getElementById('sign-in-error')!.textContent =
      'Unable to start sign-in. Please try again.';
  },
});

const button = auth.mountSignInButton(document.getElementById('sign-in')!, { width: 'full' });

// To remove this button: await button.destroy();
// When the client is no longer needed: await auth.destroy();

/auth/chatgpt must be a same-origin GET route in your application that starts sign-in. Replace it with your real route. The SDK does not register OAuth clients, create the route, verify tokens, or establish an application session. Your backend or auth framework owns those operations.

If your auth client starts sign-in through JavaScript, pass adapter instead of authPath. The adapter guide explains how to map its outcomes. An SDK complete result describes the interaction. Read your application's session to determine whether the user is signed in.

Try the runnable browser example for navigation, popups, progress, and retry behavior with a simulated local session.

Customize the button

Default styles load automatically. Choose a supported appearance and layout. Use className and style for placement and width only:

button.update({
  appearance: 'dark',
  variant: 'contained',
  layout: 'spread',
  text: 'sign-in',
  className: 'login-button',
  style: { marginBlock: 8, maxWidth: '24rem' },
});

Updates are patches: omitted fields keep their values. A supplied style object replaces all previous inline overrides. undefined removes a customization:

button.update({ className: undefined, style: undefined });

Keep the SDK's logo, light/dark palette, typography, and shape. Both renderers reject unsupported inline style keys, including fonts, colors, and custom properties. Host CSS must follow the same rules. Language font fallbacks and user accessibility settings remain supported. See the branding contract. For a Content Security Policy that blocks inline styles, load @openai/auth/styles.css and set stylesheet: 'external' when mounting. See CSP setup.

The presentation reference covers all options, including language, right-to-left layout, sizes, and accessible labels.

Observe progress and allow another attempt

const unsubscribe = auth.subscribe(() => {
  const { state } = auth.getSnapshot();
  console.info('Sign-in interaction:', state.status);
});

// Stop this observer when you no longer need it: unsubscribe();

To allow another attempt:

  1. Check your app's session.
  2. Reconcile any external sign-in operation.
  3. Call auth.recover() to return the interaction to idle.

Recovery preserves the mounted button and subscriptions. Recovery of a pending attempt requires an explicit option and does not cancel external authentication. Follow the recovery guide.

Mount multiple buttons on the same client to share one attempt. Removing a button leaves the client and its active attempt available to the other views. Destroying the client removes every view and subscription. Framework authors can also bind an existing button or use the visual model.

Observe the app session

An adapter can provide a session source that reads your app's verified session. The core client exposes this state without React:

import { createChatGPTAuth } from '@openai/auth/client';
import { chatgptAuth } from './chatgpt-auth'; // Your adapter with a session source.

const auth = createChatGPTAuth({ adapter: chatgptAuth });
const unsubscribe = auth.subscribeSession(() => {
  const { status, profile } = auth.getSessionSnapshot();
  console.info('App session:', status, profile?.name);
});

await auth.refreshSession(); // Optional explicit refresh.
// When finished: unsubscribe(); await auth.destroy();

The first subscriber starts the session read. The last unsubscribe stops observation. Snapshots distinguish unavailable, loading, authenticated, unauthenticated, and error states. Your auth system still owns identity verification, credentials, and the session. See the session API.

Learn more