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/client

v3.1.0

Published

Software WebAuthn authenticator and DPoP client for headless API access

Readme

@localwebauthn/client

A WebAuthn authenticator in software, for programs that have no browser and no human.

Install this only if your deployment issues API credentials. A server operator never needs it, and a browser application never needs it either — @localwebauthn/browser drives the platform authenticator for people.

npm install @localwebauthn/client

Two entry points

| Import | Contains | | -------------------------------- | ------------------------------------------------------------------------------ | | @localwebauthn/client | MachineClient, DPoP proofs, ceremony construction — all via an opaque signer | | @localwebauthn/client/file-key | generateKeyStore, importKeyStore, and the credential-file format |

The default entry point never handles private key bytes: it asks a MachineKeyStore for a public key and for signatures, so the same code runs over a file, an SSH-style agent, a TPM, a Secure Enclave or a cloud KMS. Raw key generation, import and the .env format are behind the second import, so a reviewer can see from the import line that a key is being created, read or written — and a deployment backed by a platform keystore never reaches them.

Nothing behind /file-key is discouraged. A file-based credential is how a CLI holds a key, and it is the same shape as any API key a service hands out from a web page. It is separate because it deserves a decision. If you use it, remember that a key which has reached a file has copies you cannot see (clipboard history, Downloads, backups), that WebCrypto promises no erasure, and that rotation is the answer rather than perfect custody: mint a replacement, deploy it, revoke the old credential — both work in between, so there is no downtime.

What it is for

A WebAuthn assertion is a signature over authenticatorData ‖ SHA-256(clientDataJSON). Producing one requires a private key and about sixty lines of code — not a browser, not a biometric, not a human. So a nightly export script can authenticate with the same mechanism a person's passkey uses, and the server verifies it through the same code path.

This package is that key holder: the ceremony construction, the two-line credential file, and RFC 9449 DPoP proofs.

The script side, in full

import { MachineClient, parseCredentialPayload } from '@localwebauthn/client';
import { importKeyStore, parseCredentialFile } from '@localwebauthn/client/file-key';
import { readFile } from 'node:fs/promises';

const file = parseCredentialFile(await readFile('.env', 'utf8'));
if (!file) {
  throw new Error('No LWA_CREDENTIAL / LWA_CREDENTIAL_KEY pair.');
}
const payload = parseCredentialPayload(file.payload);
const client = new MachineClient({
  payload,
  keyStore: await importKeyStore(file.key, payload.alg),
});

await client.authenticate(); // one full WebAuthn ceremony, in software
const me = await client.fetch('/api/machine/v1/whoami'); // DPoP proof per request

authenticate() runs the ceremony and receives an ordinary session token. Every request after it carries a DPoP proof signed by the same key, so a captured session token is not enough on its own. MachineClient retains the server's latest DPoP-Nonce and retries once when challenged, and re-authenticates on 401.

The credential file

Two lines: public metadata as JSON, private key as base64.

# nightly export -- created 2026-08-08T21:00:00.000Z
LWA_CREDENTIAL='{"v":1,"baseUrl":"https://app.example.com","rpId":"app.example.com", ... }'
LWA_CREDENTIAL_KEY=MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg...

One piece of private key material, in one place. formatCredentialFile writes it (from the browser page that generated the key), parseCredentialFile reads it, and isKeystoreReference recognises a keystore: value for deployments that keep the key in a platform store rather than the file.

Lower-level pieces

Use these when building the mint page, or when debugging a rejected assertion. Raw-key and credential-file helpers are exported by @localwebauthn/client/file-key; the ceremony and DPoP helpers are exported by @localwebauthn/client.

| Export | Purpose | | ---------------------------------------------- | --------------------------------------------- | | generateKeyStore(ES256 \| EDDSA) | a new key pair, with exportPrivateKey() | | importKeyStore(key, alg) | reopen one from a credential file | | createRegistrationResponse({ ... }) | an attestation the server will accept | | createAssertionResponse({ ... }) | a sign-in assertion | | createDpopProof({ ... }) | one per-request proof | | formatCredentialFile / parseCredentialFile | the two-line .env | | rawSignatureToDer | WebCrypto returns raw r‖s; WebAuthn wants DER |

Both algorithms work end to end: ES256 (COSE -7, DER signatures) and Ed25519 (COSE -8, raw 64-byte signatures).

What the server sees

Nothing it can mistake for a person. A credential minted this way carries a host-declared kind, and the server treats userVerified, origin, the backup flags and the signature counter as claims the signer makes about itself — because a key holder can set any of them. kind is the only class fact it cannot forge.

The counter stays at 0 deliberately: a strictly increasing counter would make concurrent sessions from one credential contend on a single compare-and-swap, and unlimited concurrent sessions is the point. (Apple's passkeys report 0 forever too.)

More