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

@humanlayer/agentlayer-provider-auth

v0.0.81

Published

Storage and normalization for provider credentials (OAuth tokens and API keys) used by AgentLayer's model providers. It defines a small `AuthStore` interface with an in-memory implementation for tests and a file-backed implementation that persists to `~/.

Readme

@humanlayer/agentlayer-provider-auth

Storage and normalization for provider credentials (OAuth tokens and API keys) used by AgentLayer's model providers. It defines a small AuthStore interface with an in-memory implementation for tests and a file-backed implementation that persists to ~/.local/share/agentlayer/auth.json (or $XDG_DATA_HOME), with automatic import from AgentSDK's and OpenCode's auth files so existing logins keep working.

Install

bun add @humanlayer/agentlayer-provider-auth

Usage

import { ensureFileAuthStore, requireAuth, type AuthInfo } from '@humanlayer/agentlayer-provider-auth'

// Creates the store, importing from the Agent SDK auth file on first use if
// the AgentLayer auth file doesn't exist yet.
const authStore = await ensureFileAuthStore()

await authStore.set('copilot', { kind: 'api', apiKey: 'sk-...' })

const auth = await authStore.get('codex') // AuthInfo | undefined
const apiAuth = await requireAuth(authStore, 'copilot', 'api') // throws if missing/wrong kind

For tests, use createMemoryAuthStore(initialAuth?) instead — same AuthStore interface, nothing touches disk.

Key exports

  • AuthStore — interface with get/set/delete/getAll, all async; get/getAll return deep clones of stored data, and set stores a deep clone of its input, so callers can't mutate stored state.
  • AuthInfo — discriminated union: OAuthAuthInfo (kind: 'oauth', accessToken, optional refreshToken/expiresAt/idToken/scope/tokenType/accountId/enterpriseUrl) or ApiAuthInfo (kind: 'api', apiKey, optional metadata).
  • createMemoryAuthStore(initialAuth?) — in-memory AuthStore.
  • createFileAuthStore(options?) — file-backed AuthStore. options.filePath defaults to getDefaultAgentLayerAuthPath().
  • ensureFileAuthStore(options?) — like createFileAuthStore, but first seeds the AgentLayer auth file from the Agent SDK auth file (getDefaultAgentSdkAuthPath()) if the AgentLayer file doesn't exist yet. Use this at startup.
  • readAuth / writeAuth / removeAuth / readAllAuth — one-shot convenience wrappers around createFileAuthStore(options).get/set/delete/getAll.
  • requireAuth(store, providerId, expectedKind?) — fetches auth or throws; with expectedKind it also narrows the return type and throws on a kind mismatch.
  • normalizeProviderId(providerId) — trims trailing slashes and maps known aliases/subpaths (openai, openai.codex, codex.*codex; github-copilotcopilot; github-copilot-enterprisecopilot-enterprise) to their canonical id; unrecognized ids pass through unchanged. Returns string (not CanonicalAuthProviderId). All store methods normalize the id internally.
  • getDefaultAgentLayerAuthPath() / getDefaultAgentSdkAuthPath() / getDefaultOpenCodeAuthPath() — resolve default file locations, each overridable via AGENTLAYER_AUTH_PATH, AGENT_SDK_AUTH_PATH, OPENCODE_AUTH_PATH.

Notes

  • File stores are written with mode 0o600.
  • Pass openCodeAuthFilePath (or set enableOpenCodeFallback: true) to have get/getAll fall back to and import entries from an OpenCode auth.json, translating its type/access/refresh/expires/key fields into AuthInfo. Imported entries are written back to the AgentLayer file but never overwrite existing entries.
  • Consumers: @humanlayer/agentlayer-provider-openai-codex, @humanlayer/agentlayer-provider-github-copilot, and agents/codelayer all read credentials through this package (see agents/codelayer/src/providers.ts).