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

bsv-x402

v0.10.0

Published

x402 payment protocol client — a fetch() wrapper that handles 402 payment flows transparently

Readme

bsv-x402

A JavaScript client library and browser extension for BSV micropayments over HTTP 402. Wraps fetch() to transparently handle payment flows using multiple protocols (Custom X402, BRC-105, BRC-121).

How It Works

import { createX402Fetch } from 'bsv-x402'

const x402Fetch = createX402Fetch({ brc105Wallet: window.CWI })
const response = await x402Fetch('https://api.example.com/paid-endpoint')

When the server responds with 402 Payment Required, the library:

  1. Detects the protocol from response headers (X402-Challenge, BRC-105, or BRC-121)
  2. Constructs a payment transaction via the browser wallet (BRC-100 / window.CWI)
  3. Sends the proof to the server and retries the request
  4. On server 200: broadcasts the transaction (transitioning nosendunproven)
  5. On server 4xx: aborts the transaction (freeing locked UTXOs)

The app developer just uses x402Fetch in place of fetch. The browser wallet handles key management and signing.

Browser Extension

The repository also includes browser extensions (Chromium, Firefox, Safari) that provide a full BRC-100 wallet with native x402 support:

  • window.CWI injection (all 28 BRC-100 wallet methods)
  • Built-in wallet via @bsv/wallet-toolbox-client
  • Autospend controls with Doom II difficulty tiers
  • UTXO Admin view for wallet diagnostics

Installation

npm install bsv-x402

Development

npm install          # Install dependencies
npm run build        # Compile TypeScript → dist/
npm test             # Run tests (vitest)
npm run typecheck    # Type-check without emitting
npm run build:all    # Build library + all browser extensions

Documentation

Status

Active development (v0.9.1). Library core: multi-protocol 402 handling (Custom X402, BRC-105, BRC-121), adversarial noSend payment flow with broadcast-on-200, BEEF acknowledgement mechanism. Browser extensions: full BRC-100 wallet, autospend controls, UTXO recovery tools.

Server counterpart: x402-rack (Ruby/Rack middleware).