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

pdf-firma-pades

v1.0.1

Published

Libreria Node.js para firma digital de PDF con PAdES Baseline (B-B).

Readme

PDF Firma

Solucion minima para firmar PDFs con PAdES-B-B usando Node.js.

Uso como libreria

const fs = require('fs');
const PdfSigner = require('pdf-firma-pades');

async function main() {
  const signer = new PdfSigner('./certificado.pfx', 'TU_PASSWORD_PFX');
  const input = fs.readFileSync('./documento.pdf');
  const signed = await signer.sign(input);
  fs.writeFileSync('./documento-firmado.pdf', signed);
}

main();

Levantar en local

Requisitos

  • Node.js 20+
  • npm

1) Instalar dependencias

npm install

2) Ejecutar firma por CLI

npm run sign:cli -- \
  --p12 ./certificado.pfx \
  --password TU_PASSWORD_PFX \
  --input ./documento.pdf \
  --output ./documento-firmado.pdf

Salida esperada:

  • documento-firmado.pdf

3) Verificar que la firma incluya SigningCertificateV2

npm run sign:verify -- ./data/documento-firmado-nodered.pdf

Variables de entorno (alternativa)

P12_PASSWORD=TU_PASSWORD_PFX \
P12_PATH=./certificado.pfx \
INPUT_PDF=./documento.pdf \
OUTPUT_PDF=./documento-firmado.pdf \
npm run sign:cli

Ejecucion con Docker

1) Preparar archivos

Crea una carpeta data/ en la raiz del proyecto y coloca:

  • data/certificado.pfx
  • data/documento.pdf

2) Definir contraseña del certificado

Crea un archivo .env en la raiz:

P12_PASSWORD=tu_password_pfx

3) Ejecutar firma con Docker Compose

docker compose run --rm pdf-firma

Salida esperada:

  • data/documento-firmado.pdf

4) Cambiar nombres/rutas de archivos (opcional)

docker compose run --rm \
  -e P12_PATH=/data/mi-cert.pfx \
  -e INPUT_PDF=/data/mi-doc.pdf \
  -e OUTPUT_PDF=/data/mi-doc-firmado.pdf \
  pdf-firma

Uso directo con docker run

docker build -t pdf-firma .
docker run --rm \
  --user "$(id -u):$(id -g)" \
  -v "$(pwd)/data:/data" \
  -e P12_PASSWORD=tu_password_pfx \
  -e P12_PATH=/data/certificado.pfx \
  -e INPUT_PDF=/data/documento.pdf \
  -e OUTPUT_PDF=/data/documento-firmado.pdf \
  pdf-firma

Node-RED basico con la libreria

Este proyecto incluye una instancia Node-RED preconfigurada para usar PdfSigner.

1) Levantar Node-RED

docker compose up -d nodered

2) Abrir editor

  • URL: http://localhost:1880

3) Ejecutar flow de firma

En el tab PDF Firma:

  1. Haz clic en Deploy.
  2. Presiona el nodo Firmar documento.

Entrada/salida por defecto:

  • Entrada: /documents/documento.pdf
  • Certificado: /documents/certificado.pfx
  • Salida: /documents/documento-firmado-nodered.pdf

/documents apunta a la carpeta local ./data.

4) Contraseña del certificado

Node-RED usa P12_PASSWORD del .env del proyecto.