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 🙏

© 2025 – Pkg Stats / Ryan Hefner

usernameless-webauthn-classes

v1.0.1

Published

Helpers for usernameless WebAuthn flows with PRF-based credential decryption and server verification utilities.

Readme

usernameless-webauthn-classes

Helpers for a niche WebAuthn flow where credentials are usernameless, verifiers are not pre-bound to accounts, and the PRF extension output is reused to decrypt an encrypted credential blob that holds the account pointer and keys.

What this library assumes

  • Anyone can submit a PublicKeyCredentialJSON verifier to your DB. You later look it up by credentialId at assertion time.
  • The credential you return to the client should be encrypted and hold: a signing-capable private key, a symmetric key for account data, and the account id/url. Decrypt it with the PRF extension result from the assertion.
  • Assertion flow: fetch verifier by claimed credential id -> check challenge + signature -> fetch encrypted credential by credential id -> decrypt with PRF result -> sign account id/url with the private key so the server can verify ownership (401 otherwise). Repeat the pattern for other resources, layering ACLs as needed to allow revocation even when someone still holds a resource key.
  • Challenge generation is yours to own; use generateNonce from bytecodec to produce a 256-bit random Base64URL string.

Requirements

  • Browser/WebAuthn with the PRF extension available.
  • Server runtime with WebCrypto (Node.js >= 18 works; if needed set globalThis.crypto = require("node:crypto").webcrypto before calling the server helpers).
  • You handle transport, persistence, ACLs, and actual credential encryption/decryption.

API

Browser: WebAuthnBrowserAgent

  • generateVerifierOptions(displayName, authenticatorAttachment) -> PublicKeyCredentialCreationOptions with resident key required, PRF first input set to "credential-encryption-key", UV required, and a 60s timeout.
  • generateVerifier(publicKey, signal?) -> awaits navigator.credentials.create and returns PublicKeyCredentialJSON.
  • generateAssertionPublicKeyParam(challengeBase64) -> PublicKeyCredentialRequestOptions for usernameless flows (empty allowCredentials, PRF extension, UV required, 60s timeout) using the server-issued challenge.
  • getAssertion(publicKey, mediation, signal?) -> awaits navigator.credentials.get and returns PublicKeyCredentialJSON plus the base64url challenge you passed in.

Server: WebAuthnServerAgent

  • getVerifierReadyForStorage(verifierJson) -> extracts credentialId, rpId, publicKeyJwk, and createdAt (shape: StoredVerifier).
  • resolveCredentialOwnershipAssertion(assertionJsonWithChallenge, storedVerifier, challengeStoredByServer) -> checks the challenge, parses client/authenticator data, enforces UV, validates rpId hash, and verifies the ES256 signature against the stored JWK.

StoredVerifier is small and storage-friendly:

type StoredVerifier = {
  credentialId: Base64URLString;
  rpId: string;
  publicKeyJwk: {
    kty: "EC";
    crv: "P-256";
    x: Base64URLString;
    y: Base64URLString;
    ext: true;
  };
  createdAt: number;
};

Quick usage

// Registration (browser)
import { WebAuthnBrowserAgent } from "usernameless-webauthn-classes";
const publicKey = WebAuthnBrowserAgent.generateVerifierOptions(
  "Alice",
  "platform"
);
const verifierJson = await WebAuthnBrowserAgent.generateVerifier(publicKey);
// send verifierJson to the server for storage (anyone can post one)

// Registration (server)
import { WebAuthnServerAgent } from "usernameless-webauthn-classes";
const storedVerifier =
  WebAuthnServerAgent.getVerifierReadyForStorage(verifierJson);
// persist storedVerifier so assertions can be matched by credentialId

// Assertion (server)
import { generateNonce } from "bytecodec";
const challenge = generateNonce(); // 256-bit Base64URL string from your server

// Assertion (browser)
const assertionOptions =
  WebAuthnBrowserAgent.generateAssertionPublicKeyParam(challenge);
const assertionJson = await WebAuthnBrowserAgent.getAssertion(
  assertionOptions,
  "required"
);

// Assertion (server)
const ok = await WebAuthnServerAgent.resolveCredentialOwnershipAssertion(
  assertionJson,
  storedVerifier,
  challenge
);
if (!ok) return res.status(401).end();
// derive PRF output from the assertion to decrypt the credential payload, then continue with your ACL logic

Development

  • Tests: npm test (node test runner; browser APIs are stubbed/mocked).
  • Benchmarks: npm run bench (quick sanity timings for option generation and assertion verification).

Everything is ESM, tree-shakeable, and ships with TypeScript definitions for IntelliSense. Minimal changes were made to stay focused on the core usernameless WebAuthn flow described above.