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

@darkhorseone/x402-core

v1.0.0

Published

Core framework-agnostic implementation of the x402 HTTP payment protocol.

Readme

x402-core

Framework-agnostic core for the x402 HTTP payment standard. This package builds 402 Payment Required responses, extracts payment credentials, and verifies payments through a facilitator API — all without any framework or storage dependencies (Phase 0 is fully stateless).

Status

  • Phase 0 scope only: no DB, Redis, queues, or credit fallback; fallbackMode must be "deny".
  • Node.js ≥ 20, TypeScript ≥ 5, strict mode enabled.

Install

npm install @darkhorseone/x402-core

Quick Start

import {
  PaymentRequirementBuilder,
  PaymentCredentialExtractor,
  HttpFacilitatorAdapter,
  type X402Config,
} from "@darkhorseone/x402-core";

const config: X402Config = {
  facilitatorUrl: "https://facilitator.example.com",
  defaultNetwork: "base-mainnet",
  defaultAsset: "USDC",
  sellerWallet: "0x123...",
  fallbackMode: "deny",
};

const builder = new PaymentRequirementBuilder(config);
const requirement = builder.build({ price: "1.0", description: "API access" });

const extractor = new PaymentCredentialExtractor();
const credential = extractor.extract(request); // header, body, or query param

const facilitator = new HttpFacilitatorAdapter(config);
const result = await facilitator.verifyPayment(credential);

Project Layout

  • src/config/ config types and helpers (e.g., X402Config).
  • src/payment/ payment requirement builder, credential extraction, verification interfaces.
  • src/facilitator/ facilitator client contracts and HTTP adapter.
  • src/errors/ typed errors (PaymentRequiredError, PaymentInvalidError, etc.).
  • src/utils/ shared utilities (logger, request ids).
  • docs/DESIGN.md architecture and Phase 0 scope; docs/DEV_STANDARDS.md coding/testing standards.

Configuration (core fields)

X402Config includes facilitatorUrl, defaultNetwork, defaultAsset, sellerWallet, optional apiKey, and optional tenantResolver/logger. Phase 0 enforces fallbackMode: "deny". Use validateConfig(config) to guard required fields early.

Development

  • npm run build — compile with tsc (ES2022 output, declarations + source maps to dist/).
  • npm test — run Vitest suite (credential extraction, requirement builder, verifier, HTTP facilitator adapter).
  • Export new modules through src/index.ts to keep the public API consistent.

Error Handling

Use the provided typed errors from src/errors/ rather than generic Error. Facilitator outages should map to PaymentNetworkError.

Contributing

Follow the architecture and style rules in docs/DESIGN.md and docs/DEV_STANDARDS.md. Keep implementations stateless, framework-agnostic, and free of external runtime dependencies.