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

nostr-passkey

v0.4.0

Published

Nostr authentication and key management using WebAuthn Passkeys PRF extension

Readme

nostr-passkey

Nostr authentication and key management using WebAuthn Passkeys PRF (Pseudo-Random Function) extension.

Securely encrypt your Nostr private keys (nsec) locally on the client using hardware-backed cryptographic keys (FaceID, TouchID, Windows Hello, YubiKeys) and decrypt them purely in-memory.

Install

Install nostr-passkey along with its peer dependency nostr-tools:

npm install nostr-passkey nostr-tools

Note: If you are using the Applesauce account adapter, ensure you have applesauce-accounts and applesauce-signers installed.


Core Features

  • Zero-Password Login: Derives symmetric encryption keys directly from your authenticator chip using the WebAuthn PRF extension.
  • In-Memory Signers: Decrypts the private key on-demand into memory; the decrypted key is never written to disk, can be proactively zeroed via destroy(), and is wiped on page refresh.
  • NIP-07 Shim: Exports a standard NIP-07 (window.nostr) shim to easily drop into existing applications.
  • Applesauce Integration: Native adapters for applesauce-accounts (PasskeyAccount and PasskeySigner).

Browser Requirements

This library requires browser support for WebAuthn PRF (Pseudo-Random Function). You can check for capability at runtime:

import { isPRFSupported } from 'nostr-passkey';

if (await isPRFSupported()) {
  console.log("Hardware-backed encryption is supported!");
}

Quick Start (Core API)

1. Register a new Passkey and generate a Nostr Key

import { registerPasskeyIdentity } from 'nostr-passkey';

// Prompts WebAuthn registration and generates a new random Nostr key pair
const { secretKey, pubkey, record } = await registerPasskeyIdentity({
  rpName: "My Nostr App"
});

2. Import an existing nsec into a Passkey

import { importPasskeyIdentityFromNsec } from 'nostr-passkey';

const { secretKey, pubkey } = await importPasskeyIdentityFromNsec("nsec1...", {
  rpName: "My Nostr App"
});

3. Unlock a stored identity

import { unlockPasskeyIdentity, buildPasskeySignerShim } from 'nostr-passkey';

// Prompts user for biometrics/PIN and decrypts nsec
const { secretKey, pubkey } = await unlockPasskeyIdentity();

// Build a standard window.nostr shim
const nostrSigner = buildPasskeySignerShim(secretKey);
window.nostr = nostrSigner;

// When done, zero the key from memory
nostrSigner.destroy();

Applesauce Accounts Integration

If you use the applesauce state and accounts framework:

import { PasskeyAccount, getStoredPasskeyAccount } from 'nostr-passkey/applesauce';

// 1. Retrieve the stored account from device identity
const account = getStoredPasskeyAccount();

if (account) {
  // 2. Prompt user biometrics to unlock the signer
  await account.unlock();
  
  // 3. Ready to sign events!
  const event = await account.signer.signEvent({
    kind: 1,
    content: "Hello from a Passkey-secured account!",
    tags: [],
    created_at: Math.floor(Date.now() / 1000)
  });
}

Running the Example

A working example app is available in the example/ directory:

# Build the library first
npm run build

# Serve the example directory
npx serve example

Open the URL printed by serve (typically http://localhost:3000). The demo lets you register a new passkey identity, import an existing nsec, unlock, and sign test events.


License

MIT