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

@longrun-ai/codex-auth

v0.4.0

Published

ChatGPT OAuth helpers compatible with Codex auth.json

Readme

codex-auth

Node-friendly helpers for ChatGPT OAuth that are compatible with Codex auth.json storage.

Install

pnpm add @longrun-ai/codex-auth

Library Usage

import {
  AuthManager,
  createChatGptClientFromManager,
  createChatGptStartRequest,
  runLoginServer,
} from '@longrun-ai/codex-auth';

const manager = new AuthManager();
const auth = await manager.auth();

if (!auth) {
  const server = await runLoginServer({ openBrowser: true });
  console.log(`Open this URL if your browser did not open: ${server.authUrl}`);
  await server.waitForCompletion();
}

const client = await createChatGptClientFromManager(manager);
const payload = createChatGptStartRequest({
  model: 'gpt-5.3-codex',
  instructions: 'You are Codex CLI.',
  tools: [{ type: 'web_search', external_web_access: true }],
  userText: 'hello',
});
const response = await client.responses(payload);
const raw = await response.text();
console.log(raw);

Continue a conversation from stored history:

import { createChatGptContinuationRequest } from '@longrun-ai/codex-auth';

const history = JSON.parse(historyJson);
const followup = createChatGptContinuationRequest({
  model: 'gpt-5.3-codex',
  instructions: 'You are Codex CLI.',
  history,
  userText: 'continue',
});
await client.trigger(followup, receiver);

responses() returns an SSE stream; parse each data: payload as ChatGptResponsesStreamEvent.

import type { ChatGptEventReceiver, ChatGptResponsesStreamEvent } from '@longrun-ai/codex-auth';

const receiver: ChatGptEventReceiver = {
  onEvent(event: ChatGptResponsesStreamEvent) {
    switch (event.type) {
      case 'response.created':
        console.log('created', event.response.id);
        break;
      case 'response.completed':
        console.log('completed', event.response.id);
        break;
      case 'response.output_text.delta':
        process.stdout.write(event.delta);
        break;
      default: {
        const _exhaustive: never = event;
        return _exhaustive;
      }
    }
  },
};

Use the receiver with the streaming helper:

await client.trigger(payload, receiver);

Device code flow (headless):

import { runDeviceCodeLogin } from 'codex-auth';

await runDeviceCodeLogin({
  onDeviceCode: (code) => {
    console.log('Visit:', code.verificationUrl);
    console.log('User code:', code.userCode);
  },
});

Auth Doctor (CLI)

The package ships a CLI that inspects auth.json and reports status. It runs a ChatGPT chat probe unless --no-verify is used.

npx @longrun-ai/codex-auth --json

Refresh tokens (if available):

npx @longrun-ai/codex-auth --refresh

Skip the verification request (no LLM call):

npx @longrun-ai/codex-auth --no-verify

Dump SSE events from the verification request:

npx @longrun-ai/codex-auth --verbose

Probe remote /models (enabled by default) and print model metadata:

npx @longrun-ai/codex-auth --probe-models

Disable /models probe:

npx @longrun-ai/codex-auth --no-probe-models

Override model or base URL:

npx @longrun-ai/codex-auth --model gpt-5.3-codex \
  --chatgpt-base-url https://chatgpt.com/backend-api/

Override CODEX_HOME:

npx @longrun-ai/codex-auth --codex-home /path/to/.codex

Notes

  • Default CODEX_HOME is ~/.codex unless overridden.
  • The CLI uses the same file schema as Codex Rust.
  • Reasoning/thinking SSE events (response.reasoning_*) only stream when the request enables reasoning (and typically includes reasoning.encrypted_content).
  • Built-in tool payloads are supported, including native web_search / local_shell and function/custom tools via the tools field.
  • Proxy env vars are detected via HTTP_PROXY, HTTPS_PROXY, and NO_PROXY (case-insensitive). If set, the verification request uses them.