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

@proteles/js

v0.1.1

Published

Framework-agnostic OAuth2/OIDC client core (PKCE, code exchange, refresh rotation, revoke, userinfo) for the Proteles identity platform.

Readme

@proteles/js

Framework-agnostic OAuth2/OIDC client core for the Proteles identity platform.

This is the substrate the framework SDKs build on. Most apps should use a higher-level package instead:

  • @proteles/next — a Backend-for-Frontend for Next.js. Tokens live in encrypted, httpOnly cookies on your own server and never reach the browser. Recommended.
  • @proteles/react — drop-in components (<SignInButton>, <UserButton>, useUser()) that talk to the BFF.

Reach for @proteles/js directly only when integrating a runtime that doesn't yet have a dedicated SDK.

It is a TypeScript port of the reference webapp/oauth_client.go: the same mandatory PKCE, state/nonce binding, refresh-with-rotation, best-effort revoke, and userinfo fetch — validated against the same authorization server.

Install

npm install @proteles/js

Requires a runtime with fetch and Web Crypto (Node 18.12+, modern browsers, edge runtimes). Node 18 is supported via a node:crypto fallback.

Usage

The client holds no session state. You generate an authorization request, persist the returned state / codeVerifier / nonce somewhere only your server can read (an encrypted cookie — exactly what @proteles/next does), then complete the exchange on the callback.

import { OAuthClient } from "@proteles/js";

const client = new OAuthClient({
  issuer: "https://auth.example.com", // your tenant's issuer
  clientId: process.env.OAUTH_CLIENT_ID!,
  clientSecret: process.env.OAUTH_CLIENT_SECRET, // omit for a public (PKCE-only) client
  redirectUri: "https://app.example.com/api/auth/callback",
  scopes: ["openid", "profile", "email", "offline_access"],
});

// 1. Start login — redirect the browser to `url`, persist the rest server-side.
const { url, state, codeVerifier, nonce } = await client.createAuthorizationUrl();

// 2. On the callback: verify `state` matches, then exchange the code.
const tokens = await client.exchangeCode({ code, codeVerifier });

// 3. Read the user.
const user = await client.fetchUserInfo(tokens.accessToken);

// 4. Later: refresh (rotation-aware) and revoke on logout.
const refreshed = await client.refresh(tokens.refreshToken!);
await client.revoke(tokens.refreshToken!);

Confidential vs. public clients

  • With a clientSecret, the token endpoint is called with HTTP Basic (client_secret_basic).
  • Without one, the client is public: it sends client_id in the request body and relies on PKCE. The server must allow token_endpoint_auth_method: none for that client.

Endpoints

Endpoints are derived from issuer using the server's conventional paths (/oauth/authorize, /oauth/token, /oauth/userinfo, /oauth/revoke). Pass endpoints to override any of them.

Security notes

  • state, codeVerifier, and nonce are secrets for the duration of a login; never expose them to the browser. Validate state on the callback with the provided timingSafeEqual.
  • OAuthError.message is diagnostic only — never surface it to end users.
  • Every network call has a 10s default timeout (timeoutMs) so a slow AS can't hang your request.

Develop

npm install      # from the sdk/ workspace root
npm run build    # tsc -> dist
npm test         # tsx + node:test