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

@chest-gate/auth-flow

v0.2.0

Published

OAuth 2.0 Device Authorization Grant (RFC 8628) login flow for Chest Gate clients (CLI, install, SDK). Mints a per-device agent token via chest.sh.

Readme

@chest-gate/auth-flow

npm license

OAuth 2.0 Device Authorization Grant (RFC 8628) login flow for Chest Gate clients. Used by chest-gate login and npx @chest-gate/install to mint a per-device agent token via chest.sh without copy-pasting keys.

Install

npm install @chest-gate/auth-flow

Usage

import { runDeviceGrant } from "@chest-gate/auth-flow";
import { hostname } from "node:os";

const { token, ownerWallet, tokenId, label } = await runDeviceGrant({
  gateUrl: "https://gate.chest.sh",
  hostname: hostname(),
  onCodeIssued: ({ userCode, verificationUriComplete }) => {
    console.log(`Code: ${userCode}`);
    console.log(`Visit: ${verificationUriComplete}`);
  },
});

// token is a `ca_live_…` agent token, the same kind paste-flow users
// mint at chest.sh/dashboard/agent-wallet. Save it however you like.

The flow:

  1. POST /v1/oauth/device/code to request a short user code and a device code.
  2. Print the user code and chest.sh/device URL (and optionally open the browser).
  3. User signs in via their existing Privy session and approves the device.
  4. The library polls POST /v1/oauth/token with the device code until the user approves (or it expires).
  5. On approval, the server returns the minted ca_live_… token.

The plaintext token only crosses the wire once (in the final token response). The device code never leaves your process. User codes are single-use and expire in a few minutes.

The device grant works under SSH, Docker, CI, and any environment without a usable 127.0.0.1 — there's no local HTTP server, no port to bind, and no browser redirect target.

API

function runDeviceGrant(args: DeviceGrantArgs): Promise<DeviceGrantResult>;

interface DeviceGrantArgs {
  gateUrl: string;       // gate.chest.sh base
  hostname: string;      // appears in token label
  openBrowser?: boolean; // default: true
  onCodeIssued?: (info: {
    userCode: string;
    verificationUri: string;
    verificationUriComplete: string;
    expiresInSec: number;
  }) => void;
  timeoutMs?: number;    // default: 15 * 60 * 1000
}

interface DeviceGrantResult {
  token: string;         // ca_live_…
  ownerWallet: string;
  tokenId: string;
  label: string;
}

Throws DeviceGrantError (with a kind discriminator) on any failure.

Why this exists

Chest Gate clients used to ask the user to paste a ca_live_… token from chest.sh/dashboard/agent-wallet. The CLI graduated to a proper browser-confirm flow, and now uses the device grant so it works the same on every machine — desktop, SSH, Docker, CI. This package extracts that flow so the install CLI and any other client gets it for free, with the same UX the user already saw once.

Related

License

MIT © Chest Gate