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

@agentkeychain/web

v0.2.1

Published

Web SDK for AgentKeychain — drop-in "Sign in with AgentKeychain" button and OIDC redirect flow for browser apps.

Readme

@agentkeychain/web

Web SDK for AgentKeychain — a drop-in "Sign in with AgentKeychain" button and OIDC redirect flow for browser apps.

This package handles the browser side of the OIDC authorization-code flow with PKCE: generating a code verifier, kicking off the redirect to the authorize page, and parsing the callback. The token exchange step runs on your backend using @agentkeychain/server.

Installation

npm install @agentkeychain/web
# or
bun add @agentkeychain/web

react is an optional peer dependency — only install it if you use the React entry point.


Vanilla JS

Setup

import { AgentKeychainWeb } from "@agentkeychain/web";

const akc = new AgentKeychainWeb({
  clientId: "akc_client_...",
  redirectUri: "https://yourapp.com/auth/callback",
  scope: "openid profile",
  // endpoint defaults to https://api.agentkeychain.com
});

Kick off sign-in

document.getElementById("login")!.addEventListener("click", () => {
  akc.signIn(); // full-page redirect to the authorize page
});

signIn() generates a PKCE code_verifier, stores it in sessionStorage along with the CSRF state, then navigates the window to /v1/authorize. It never resolves — the page is gone.

Drop-in button

import { AgentKeychainWeb, renderButton } from "@agentkeychain/web";

const akc = new AgentKeychainWeb({ clientId, redirectUri });
renderButton(akc, document.getElementById("login-slot")!);

Handle the redirect callback

On your redirect_uri page:

import { AgentKeychainWeb, AgentKeychainWebError } from "@agentkeychain/web";

const akc = new AgentKeychainWeb({ clientId, redirectUri });

try {
  const { code, codeVerifier, redirectUri } = akc.handleRedirectCallback();
  // POST to your backend — the backend does the code exchange with client_secret
  await fetch("/auth/exchange", {
    method: "POST",
    body: JSON.stringify({ code, codeVerifier, redirectUri }),
  });
} catch (err) {
  if (err instanceof AgentKeychainWebError) {
    // err.code: STATE_MISMATCH | MISSING_PENDING_REQUEST | MISSING_CODE | AUTHORIZE_ERROR
  }
}

Your backend then calls @agentkeychain/server's AgentKeychain.exchangeCode({ code, redirect_uri, code_verifier }) to get the tokens.


React

import { AgentKeychainWeb } from "@agentkeychain/web";
import { AgentKeychainButton } from "@agentkeychain/web/react";

const akc = new AgentKeychainWeb({
  clientId: "akc_client_...",
  redirectUri: "https://yourapp.com/auth/callback",
});

export function LoginPage() {
  return (
    <AgentKeychainButton
      client={akc}
      scope="openid profile"
      onError={(err) => console.error(err)}
    />
  );
}

Pass children or label to customize the button text, className or style to restyle.


Why redirect and not popup?

This version uses full-page redirects for simplicity — no postMessage, no popup-blocker edge cases, no callback HTML to serve. If you need popup UX later, a signInWithPopup() API can be added as a second option without breaking the redirect flow.


License

Apache-2.0