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

@localwebauthn/server

v3.1.0

Published

Self-hosted, invitation-first passkey authentication lifecycle

Readme

@localwebauthn/server

Framework-neutral, self-hosted passkey enrollment and authentication built on @simplewebauthn/server.

import { createUserHandle, LocalWebAuthn } from '@localwebauthn/server';
import { migrateSqlite, SqliteLocalWebAuthnStore } from '@localwebauthn/server/sqlite';

migrateSqlite(database);

const auth = new LocalWebAuthn({
  rpName: 'Example',
  rpId: 'app.example.com',
  expectedOrigins: 'https://app.example.com',
  store: new SqliteLocalWebAuthnStore(database),
  users: {
    async getUser(userId) {
      const user = await applicationUsers.get(userId);
      return user
        ? {
            id: user.id,
            name: user.email,
            displayName: user.name,
            webAuthnUserHandle: user.webAuthnUserHandle,
            active: user.active,
          }
        : null;
    },
  },
});

const userHandle = createUserHandle();
const enrollment = await auth.issueEnrollment('application-user-id');

The package deliberately does not prescribe an HTTP framework. Route handlers translate cookies and JSON into the service methods. See the repository security policy before deploying.

Storage adapters

All three pass the same conformance suite and are interchangeable via the store option.

| Import | Store | Migration | | -------------------------------- | ---------------------------- | ----------------- | | @localwebauthn/server/sqlite | SqliteLocalWebAuthnStore | migrateSqlite | | @localwebauthn/server/postgres | PostgresLocalWebAuthnStore | migratePostgres | | @localwebauthn/server/d1 | D1LocalWebAuthnStore | migrateD1 |

import { Pool } from 'pg';
import { migratePostgres, PostgresLocalWebAuthnStore } from '@localwebauthn/server/postgres';

const pool = new Pool({ connectionString: process.env.DATABASE_URL });
await migratePostgres(pool);
// store: new PostgresLocalWebAuthnStore(pool)

better-sqlite3 and pg are optional peer dependencies — install only the one you use. Pass a pg.Pool rather than a single client so transactions get their own connection.

SQLite and PostgreSQL wrap multi-statement operations in interactive transactions. D1 uses a transactional batch whose row-count guard makes each dependent statement fail closed; see the D1 section of the repository security policy.

Schedule periodic cleanup() on any adapter (every few minutes is fine). It reaps expired grants, finished challenges, and dead sessions. Credentials are not part of cleanup.

The SQLite adapter enables PRAGMA foreign_keys = ON on the connection it is given and uses UPDATE ... RETURNING (SQLite 3.35 or newer). Every transaction runs BEGIN IMMEDIATE, so concurrent connections (a test harness, a migration, a bootstrap script alongside the server) queue at the write lock instead of failing mid-transaction with an unretryable SQLITE_BUSY_SNAPSHOT. Set PRAGMA busy_timeout on the connection you pass (the demo uses 5000 ms) so that queueing waits instead of erroring; writers still execute one at a time — that is SQLite's model, not a limitation this adapter adds.

HTTP and signup helpers

Host adapters should not re-invent cookie flags or origin checks:

import {
  authCookieNames,
  cookieAttributes,
  isExactOrigin,
  signupPhase,
} from '@localwebauthn/server';

const names = authCookieNames('https://app.example.com'); // __Host-lwa_* on HTTPS
const attrs = cookieAttributes({ publicOrigin, expiresAt });
if (!isExactOrigin(request.headers.get('Origin'), publicOrigin)) {
  /* 403 */
}
const phase = signupPhase({
  hasActiveCredential: credentials.length > 0,
  hasPendingEnrollmentGrant: pending,
  hasEnrollmentSession: Boolean(enrollmentCookie),
});

The repository lifecycle demo and Hono starter use these helpers. See docs/COMPARISON.md for the broader starter-kit roadmap (recovery, dual-channel signup, Next.js, ops snippets).