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

@doscientos/verifactu

v0.1.10

Published

Framework-agnostic Verifactu (AEAT) invoice submission, SIF hash chain and QR generation for Node.js.

Readme

@doscientos/verifactu

Framework-agnostic Verifactu (AEAT) toolkit for Node.js: invoice registration (RegistroAlta), the SIF SHA-256 hash chain, and tributary QR generation.

  • Server-only. Uses node:crypto, mutual-TLS and node-forge. Run it from Next.js Server Actions / Route Handlers, a Node server, or a worker — never from a browser / React client component.
  • No env access. Configuration is injected as plain data (VerifactuConfig), so the package is portable across apps. Each app keeps its own adapter that maps its env into a VerifactuConfig (see config.example.ts).
  • Dual ESM/CJS build with type declarations.

Install

pnpm add @doscientos/verifactu
# or: npm i @doscientos/verifactu / yarn add @doscientos/verifactu

Usage

The recommended entry point is createVerifactuClient: bind a config once and reuse the returned client across requests.

import { createVerifactuClient } from "@doscientos/verifactu";
import { verifactuConfigFromEnv } from "./verifactu-config"; // your adapter

const client = createVerifactuClient(verifactuConfigFromEnv());

const result = await client.registerInvoice({
  nif: "B12345678",
  invoiceNumber: "FAC-2026-001",
  invoiceType: "F1",
  issueDate: new Date("2026-03-15"),
  taxAmount: 21,
  total: 121,
  previousHash: null, // first invoice of the chain
  generatedAt: new Date(),
  emisorName: "Acme S.L.",
  clientNif: "12345678Z",
  clientName: "Cliente Ejemplo",
  descriptionOperacion: "Servicios de consultoría",
  vatLines: [{ rate: 21, base: 100, tax: 21 }],
  previousInvoiceNumber: null,
  previousIssueDate: null,
});

// Never throws — inspect the typed result:
if (result.status === "accepted") {
  console.log("CSV:", result.csv, "hash:", result.hash);
} else {
  console.error(result.errorCode, result.aeatCode, result.errorMessage);
}

QR code

const qrUrl = client.buildQrUrl({
  nif: "B12345678",
  invoiceNumber: "FAC-2026-001",
  issueDate: new Date("2026-03-15"),
  total: 121,
});

const pngDataUrl = await client.buildQrDataUrl({
  nif: "B12345678",
  invoiceNumber: "FAC-2026-001",
  issueDate: new Date("2026-03-15"),
  total: 121,
}); // "data:image/png;base64,…"

Configuration

VerifactuConfig is plain, serialisable data — build it however you like. A reference adapter that reads environment variables is provided in config.example.ts.

type VerifactuConfig = {
  environment: "mock" | "test" | "prod";
  certificate: { p12Base64: string; password: string };
  software: { name: string; id: string; version: string; installationNumber: string };
  appUrl: string; // used to build the mock QR verify route
};
  • mock — no AEAT call; QR points to ${appUrl}/p/verify. Ideal for local/dev.
  • test — AEAT preproduction endpoints (requires a valid test certificate).
  • prod — AEAT production endpoints.

Public API

| Export | Description | | --- | --- | | createVerifactuClient(config, logger?) | Recommended facade → registerInvoice, buildQrUrl, buildQrDataUrl. | | submitToVerifactu(input, config, logger?) | Free function behind registerInvoice. | | buildVerifactuXml(input, hash, software) | Build the RegistroAlta XML payload. | | buildQrUrl(params, config) / buildQrDataUrl(url) | QR helpers. | | validateVerifactuXml(xml) | XML well-formedness check. | | noopLogger / VerifactuLogger | Optional logging port (pino-compatible). |

Types: VerifactuConfig, VerifactuCertificate, VerifactuSoftware, VerifactuEnvironment, VerifactuQrConfig, VerifactuSubmitInput, VerifactuSubmitResult, VerifactuErrorCode, VatLine, QrParams, XmlValidationResult, VerifactuClient.

Scripts

pnpm build      # dual ESM/CJS bundle + .d.ts (tsup)
pnpm typecheck  # tsc --noEmit
pnpm test       # vitest run

License

MIT