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

@rxtech-lab/authjs-rxlab

v1.6.1

Published

Auth.js integration for RxLab OIDC with refresh-token rotation and typed sessions.

Readme

@rxtech-lab/authjs-rxlab

Auth.js v5 integration for the RxLab OIDC service. It configures the RxLab provider, keeps the OAuth access token and app-specific roles on the session, and rotates expired access tokens without shortening the Auth.js session.

Install

bun add @rxtech-lab/authjs-rxlab next-auth@beta

Usage

// lib/auth.ts
import { createRxLabAuth } from "@rxtech-lab/authjs-rxlab";

export const { handlers, signIn, signOut, auth, proxy } = createRxLabAuth({
  issuer: process.env.AUTH_ISSUER!,
  clientId: process.env.AUTH_CLIENT_ID!,
  clientSecret: process.env.AUTH_CLIENT_SECRET!,
  signInPage: "/login",
});
// app/api/auth/[...nextauth]/route.ts
import { handlers } from "@/lib/auth";

export const { GET, POST } = handlers;

Add a root src/proxy.ts so Auth.js owns an outgoing response on application requests and can persist rotated refresh tokens:

// src/proxy.ts
export { proxy as default } from "@/lib/auth";

export const config = {
  matcher: [
    "/((?!api/auth|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
  ],
};

The matcher excludes Auth.js endpoints, Next.js static/image requests, and common metadata or image assets. Keep the proxy enabled for every route that may read the session.

Sign in with the provider ID rxlab:

await signIn("rxlab", { redirectTo: "/admin" });

The resulting session includes the access token and RxLab roles:

const session = await auth();
const bearer = session?.accessToken;
const isAdmin = session?.user?.roles?.includes("admin") ?? false;

Environment

The application still owns Auth.js's standard AUTH_SECRET and public base URL configuration. Pass the RxLab client values explicitly so missing configuration fails at startup instead of during an OAuth callback.

AUTH_ISSUER=https://auth.rxlab.app
AUTH_CLIENT_ID=your-client-id
AUTH_CLIENT_SECRET=your-client-secret
AUTH_SECRET=replace-with-a-random-secret

The RxLab OAuth client must allow your Auth.js callback URL and the scopes openid email profile offline_access.

Refresh behavior

Exporting proxy is required for reliable refresh-token rotation. Auth.js 5.0.0-beta.31's no-argument auth() path for React Server Components reads the session response body but does not copy its Set-Cookie header to a browser response. An RSC call can therefore refresh successfully in that invocation while the browser keeps the old JWT cookie. Once RxLab's grace window for the old refresh token closes, a later refresh fails with invalid_grant.

The package's proxy is pre-wrapped through Auth.js's request/response path, which copies the refreshed session cookie to the outgoing response. Continue using auth() in Server Components to read the session, but do not rely on RSC auth() calls alone to persist token rotation.

  • Uses an encrypted Auth.js JWT session lasting 30 days by default.
  • Stores OAuth expiry in expiresAt, separate from Auth.js's reserved exp.
  • Refreshes access tokens 60 seconds before expiry.
  • Persists a rotated refresh token, or keeps the previous token when the server does not return a replacement.
  • Exposes RefreshTokenError on session.error when re-authentication is required.
  • Logs only token presence, expiry, event, HTTP status, and sanitized OAuth error/error_description details. Known token and client-secret values are redacted and all other response fields are discarded.

All defaults can be adjusted through RxLabAuthOptions. Advanced applications can call createRxLabAuthConfig(options) and inspect or extend the resulting Auth.js configuration before passing it to NextAuth.