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

@agentmail/agentid-better-auth

v0.1.1

Published

AgentID provider helper for Better Auth's Generic OAuth plugin

Readme

AgentID for Better Auth

@agentmail/agentid-better-auth is an AgentID provider helper for Better Auth's Generic OAuth plugin. It lets AI agents sign in with their AgentMail identity while Better Auth handles the OAuth callback and session.

Requirements

Install

pnpm add @agentmail/agentid-better-auth

Configure

Register this callback URL in the AgentID console:

https://yourapp.com/api/auth/callback/agentid

Then add the helper to Better Auth:

import { agentid } from "@agentmail/agentid-better-auth";
import { betterAuth } from "better-auth";
import { genericOAuth } from "better-auth/plugins";

export const auth = betterAuth({
	plugins: [
		genericOAuth({
			config: [
				agentid({
					clientId: process.env.AGENTID_CLIENT_ID!,
					clientSecret: process.env.AGENTID_CLIENT_SECRET!,
				}),
			],
		}),
	],
});

Use your existing Better Auth client, or create one. No client plugin is required:

import { createAuthClient } from "better-auth/react";

export const authClient = createAuthClient();

Start sign-in with the standard social-provider API:

await authClient.signIn.social({
	provider: "agentid",
	callbackURL: "/",
});

See the AgentID Better Auth guide for the complete setup.

Scopes and owner claims

The default scopes are openid, email, and profile. These identify the agent and expose its AgentMail address. To also request information about the human who owns the agent, add owner_profile and owner_email:

agentid({
	clientId: process.env.AGENTID_CLIENT_ID!,
	clientSecret: process.env.AGENTID_CLIENT_SECRET!,
	scopes: ["openid", "email", "profile", "owner_profile", "owner_email"],
});

Owner claims are returned by AgentID's UserInfo endpoint and are available to Better Auth callbacks in the raw OAuth profile. See the AgentID guide for an example of reading them later with the stored access token.

Protocol details

  • Discovery: https://auth.agentid.com/.well-known/openid-configuration
  • Token endpoint authentication: client_secret_basic
  • PKCE: required (S256)
  • Callback path: /api/auth/callback/agentid
  • ID tokens: verified through AgentID's discovery metadata and JWKS

AgentID does not echo an OIDC nonce in authorization-code ID tokens. The helper therefore disables Better Auth's nonce binding for this provider and requires PKCE instead. Signature, issuer, audience, algorithm, and expiry validation remain enabled.

Development

pnpm install
pnpm check