GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - doscientos-es/verifactu: Toolkit para Veri*Factu de la AEAT: registros de facturaci?n, validaci?n XSD, encadenado hash SIF y c?digos QR para Node.js.

BranchesTags
Open more actions menu

Latest commit

 

History

62 Commits
62 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
docs
docs
 
 
scripts
scripts
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
config.example.ts
config.example.ts
 
 
oxlint.config.ts
oxlint.config.ts
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
pnpm-workspace.yaml
pnpm-workspace.yaml
 
 
tsconfig.json
tsconfig.json
 
 
tsup.config.ts
tsup.config.ts
 
 
vitest.config.ts
vitest.config.ts
 
 

Repository files navigation

@doscientos/verifactu

Framework-agnostic Verifactu (AEAT) toolkit for Node.js: billing-record registration (RegistroAlta and RegistroAnulacion), official AEAT XSD validation, the SIF SHA-256 hash chain, and tributary QR generation.

  • Server-first. The root, /durable and /nif entry points use Node APIs. Run them from Server Actions / Route Handlers or a Node server. The isolated /errors entry point is browser-safe for operational UI.
  • 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.

For a production ledger/outbox integration, follow the complete Spanish guide: docs/INTEGRATION.es.md.

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: {
    producerName: string
    producerNif: string
    name: string
    id: string
    version: string
    installationNumber: string
    onlyVerifactu: boolean
    multipleTaxpayers: boolean
  }
  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, cancelInvoice, QR helpers.
submitToVerifactu(input, config, logger?) Free function behind registerInvoice.
cancelInVerifactu(input, config, logger?) Free function behind cancelInvoice; creates a RegistroAnulacion.
buildVerifactuXml(input, hash, software) Build the RegistroAlta XML payload.
buildQrUrl(params, config) / buildQrDataUrl(url) QR helpers.
validateVerifactuXml(xml) XML well-formedness check.
validateVerifactuXsd(xml) Validation against the bundled AEAT SuministroLR/SuministroInformacion schemas.
prepareDurableVerifactuRecord(record, legacySoftware) Decode and verify an immutable Alta/Anulación ledger record before delivery.
deliverDurableVerifactuRecord(record, config, logger?) Verify and deliver one immutable Alta/Anulación with a single call.
isRetryableVerifactuDelivery(result) Storage-agnostic retry classification for AEAT delivery results.
validateSpanishFiscalIdentity(identity, certificate, options?) Read-only VNif census validation with official endpoint fallback.
getAeatErrorMetadata(code, detail?) Classify official AEAT errors by operational effect.
noopLogger / VerifactuLogger Optional logging port (pino-compatible).

Use @doscientos/verifactu/errors from browser bundles. Server integrations can use @doscientos/verifactu, /durable and /nif without pulling those modules into client code.

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

Scripts

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

Releases

Cada push directo a main valida el paquete, incrementa automáticamente la versión de parche, crea el commit y tag vX.Y.Z, y publica ese artefacto en npm con Trusted Publishing y provenance. No modifiques version manualmente.

El trusted publisher de npm debe estar asociado al repositorio y al workflow .github/workflows/publish.yml; no se almacena un token de npm en GitHub. Proteged main para exigir CI. El commit de versión se realiza con github-actions[bot] y el workflow lo ignora para evitar un ciclo de publicación.

Licencia y crédito

Licencia propia DAL v1.0: uso gratuito, también comercial, instalando el paquete desde npm sin modificarlo, a cambio de dar crédito visible a Doscientos (por ejemplo: «Built with @doscientos/verifactu by Doscientos — https://doscientos.es»). No se permite modificar, redistribuir ni ofrecer el paquete como servicio. Las versiones publicadas antes bajo MIT siguen siendo MIT.

About

Toolkit para Veri*Factu de la AEAT: registros de facturaci?n, validaci?n XSD, encadenado hash SIF y c?digos QR para Node.js.

Topics

aeatdoscientosinvoicingnodejsverifactu

Resources

Readme
License
Activity
Custom properties

Stars

2 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.