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

@authagonal/bff

v0.16.2

Published

Backend-for-Frontend for SPAs using Authagonal. Runs the OIDC auth-code + PKCE flow server-side, holds tokens in a server-side session, and exposes the browser only an httpOnly cookie. Express + Next.js adapters.

Readme

@authagonal/bff

Backend-for-Frontend (BFF) for SPAs that authenticate with Authagonal, for Node — Express and Next.js.

Your React/Vue/Svelte app should never hold access or refresh tokens: anything in JS-reachable storage is exposed to XSS. This package is a confidential OIDC client you run on your own backend. It runs the authorization-code + PKCE flow server-side, keeps the tokens in a server-side session, and gives the browser nothing but an httpOnly session cookie — the pattern the IETF OAuth 2.0 for Browser-Based Apps BCP recommends. It's the Node twin of the .NET Authagonal.Bff package and speaks the same protocol.

npm install @authagonal/bff

Express

import express from 'express';
import { authagonalBff } from '@authagonal/bff/express';

const app = express();
app.set('trust proxy', 1); // if behind a reverse proxy / ingress

app.use(authagonalBff({
  authority:     'https://acme.authagonal.io',   // your tenant auth host
  clientId:      process.env.BFF_CLIENT_ID!,
  clientSecret:  process.env.BFF_CLIENT_SECRET!,
  scope:         ['openid', 'profile', 'email', 'offline_access'], // offline_access enables refresh
  cookieSecret:  process.env.BFF_COOKIE_SECRET!, // used to encrypt the session cookie
  postLogoutRedirectUri: 'https://app.acme.com/',
}));

app.use(express.static('dist')); // your SPA
app.listen(3000);

Next.js (App Router)

app/bff/[...bff]/route.ts:

import { createBffRoute } from '@authagonal/bff/next';

export const { GET, POST } = createBffRoute({
  authority:    'https://acme.authagonal.io',
  clientId:     process.env.BFF_CLIENT_ID!,
  clientSecret: process.env.BFF_CLIENT_SECRET!,
  scope:        ['openid', 'profile', 'email', 'offline_access'],
  cookieSecret: process.env.BFF_COOKIE_SECRET!,
  postLogoutRedirectUri: 'https://app.acme.com/',
});

export const runtime = 'nodejs'; // server-side session + client secret

Endpoints (mounted under /bff)

| Route | Purpose | |---|---| | GET /bff/login?returnUrl=/ | Start login; redirects to Authagonal. | | GET /bff/callback | OIDC redirect URI (handled for you). | | GET /bff/user | { isAuthenticated, claims, sessionExpiresAt }. Requires the anti-forgery header. | | GET\|POST /bff/logout | Ends the session locally + at Authagonal. | | POST /bff/backchannel-logout | OIDC back-channel logout consumer (kills sessions). |

Register a BFF client in the Authagonal portal (confidential + PKCE + offline_access) with redirect URI https://app.acme.com/bff/callback and post-logout redirect https://app.acme.com/. For subject-wide "log out everywhere", register it with BackChannelLogoutSessionRequired=false.

From the browser

Every non-navigation call must carry a static anti-forgery header (defends against CSRF alongside SameSite=Lax):

const me = await fetch('/bff/user', { headers: { 'X-Authagonal-Bff': '1' } }).then(r => r.json());
if (!me.isAuthenticated) location.href = '/bff/login?returnUrl=' + encodeURIComponent(location.pathname);

Log in / out by navigating (not fetching): location.href = '/bff/login' / '/bff/logout'.

Sessions & scaling

Sessions default to an in-memory store, fine for a single instance. Pass a shared sessionStore (implement IBffSessionStore, e.g. over Redis) to run more than one instance.

Extension points (the hosted seam)

sessionStore (IBffSessionStore), cookieProtector (ICookieProtector), and the core OidcClient are all replaceable. See docs/bff.md in the authagonal-cloud repo for the full protocol contract.