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

@gleanwork/auth

v0.5.1

Published

OAuth authentication and tenant discovery for Glean developer tools.

Downloads

0

Readme

@gleanwork/auth

Prerelease npm version CI License: MIT

Authenticate with Glean from the command line or JavaScript, with tenant discovery, OAuth login, and automatic token refresh.

Installation

Requires Node.js 22.12.0 or newer.

npm install @gleanwork/auth

The JavaScript API is ESM-only.

Quick Start

Sign in with your work email and request the scopes your application needs:

npx glean-auth login --email [email protected] --scopes search

Print the current token for a shell command or non-JavaScript application:

export GLEAN_API_TOKEN="$(
  npx glean-auth token --email [email protected] --scopes search
)"

You can also run the CLI without installing it in a project:

npx -y @gleanwork/auth login --email [email protected] --scopes search

CLI

| Command | Description | | -------- | -------------------------------------------------------------- | | login | Sign in with OAuth and save credentials. | | status | Show local authentication status without printing credentials. | | token | Print the current access token. | | logout | Remove the matching saved OAuth credentials. |

npx glean-auth status --email [email protected] --scopes search
npx glean-auth status --email [email protected] --scopes search --json
npx glean-auth token --email [email protected] --scopes search
npx glean-auth logout --email [email protected] --scopes search

token prints only the token and a trailing newline to stdout. It does not start an interactive login. Run login first or set GLEAN_API_TOKEN.

Options

| Option | Description | | ---------------------- | ------------------------------------------------------------------- | | --email <address> | Discover the Glean tenant associated with an email address. | | --server-url <url> | Use the complete Glean backend origin instead of tenant discovery. | | --scopes <scope,...> | Request OAuth scopes. This option is repeatable and case-sensitive. |

Use the lowercase scope names advertised by the Glean OAuth server, such as search, chat, or mcp.

Run npx glean-auth --help for shared options and the command list. Run npx glean-auth <command> --help for command-specific options.

Authentication

OAuth is the recommended authentication method. login uses Authorization Code with PKCE and opens a browser for approval. If the tenant permits Dynamic Client Registration, the CLI registers a client automatically. Set GLEAN_OAUTH_CLIENT_ID when an administrator has provisioned a public OAuth client instead.

For CI or another non-interactive environment, set a user-scoped API token and the Glean backend URL:

export GLEAN_SERVER_URL=https://your-company-be.glean.com
export GLEAN_API_TOKEN=your-api-token

A non-empty GLEAN_API_TOKEN takes precedence when the package retrieves a token. The package does not validate the scopes or expiration of an API token.

The CLI chooses a tenant in this order:

  1. --server-url
  2. --email
  3. GLEAN_SERVER_URL

OAuth always requests openid and offline_access in addition to the scopes passed through --scopes. A saved OAuth grant is reused only when it includes every requested scope.

JavaScript API

The package exports two runtime functions and their supporting TypeScript types.

import { createGleanTokenProvider, discoverGleanTenant } from "@gleanwork/auth";

const tenant = await discoverGleanTenant("[email protected]");
const getAccessToken = createGleanTokenProvider({
  serverUrl: tenant.serverUrl,
  scopes: ["search"],
});

const token = await getAccessToken();

discoverGleanTenant(email) returns the authoritative backend origin and a display identity for the tenant associated with an email address. Canonical *-be.glean.com and custom vanity backend origins are preserved exactly.

When using --server-url or GLEAN_SERVER_URL, pass the complete backend origin shown under Server instance (QE) on the Glean About page. Do not pass the Glean web app URL or derive a backend hostname from it.

createGleanTokenProvider(options) returns a non-interactive () => Promise<string> callback. It uses GLEAN_API_TOKEN when set. Otherwise, it reuses or refreshes credentials created by glean-auth login.

The callback can be passed directly to the Glean TypeScript SDK:

import { Glean } from "@gleanwork/api-client";
import { createGleanTokenProvider } from "@gleanwork/auth";

const glean = new Glean({
  serverURL: "https://your-company-be.glean.com",
  apiToken: createGleanTokenProvider({
    serverUrl: "https://your-company-be.glean.com",
    scopes: ["search"],
  }),
});

Credential Storage

The CLI stores OAuth credentials under $XDG_STATE_HOME/glean-auth when XDG_STATE_HOME is an absolute path. Otherwise, it uses ~/.local/state/glean-auth.

On Unix, state directories use mode 0700 and credential files use mode 0600. The package does not read or write project .env files. status never prints tokens; token intentionally writes a token to stdout for scripts and pipelines.

Contributing

See CONTRIBUTING.md for development setup and quality checks.

License

MIT, see LICENSE.