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

@mostajs/pdf-sign

v0.1.0

Published

Signature numérique de PDF pour @mostajs — moteur HYBRIDE : cœur Node (PKCS#7 via @signpdf) + bascule pyhanko (PAdES + permissions AES-256) si disponible. Config .env, CLI, API. Réutilise le pipeline éprouvé pyhanko+pikepdf.

Readme

@mostajs/pdf-sign

Auteur : Dr Hamid MADANI [email protected] Licence : AGPL-3.0-or-later

Signature numérique de PDF pour l'écosystème @mostajs/*. Moteur hybride :

  • cœur Node — signature PKCS#7 détachée via @signpdf, cachet invisible, aucune dépendance Python ;
  • bascule pyhanko — signature PAdES visible + permissions restrictives (chiffrement AES-256, R=6) quand un venv Python est disponible.

Configuration 100 % .env (via @mostajs/config), API + CLI. Portage générique et paramétré du pipeline pyhanko + pikepdf éprouvé.

Pourquoi — valeur probante (SIH & documents officiels)

La signature électronique de PDF apporte la preuve médico-légale et la valeur probante exigées par l'interopérabilité et la sécurité d'un Système d'Information Hospitalier :

| Domaine | Documents | |---|---| | Clinique | CRH, CRO, comptes rendus d'imagerie / biologie signés par le praticien | | Administratif | certificats de séjour, ordonnances, dossiers de sortie | | Financier / CNAS-CASNOS | factures, bordereaux de remboursement, prises en charge |

Le module reste générique : il ne connaît aucun métier. La sémantique (quel document, quel signataire) est portée par l'appelant.

Installation

pnpm add @mostajs/pdf-sign
# Moteur pyhanko (optionnel : PAdES + permissions) :
bash node_modules/@mostajs/pdf-sign/python/setup-venv.sh
export PDF_SIGN_PYTHON="$(pwd)/node_modules/@mostajs/pdf-sign/python/.venv/bin/python"

API

import { signPdf, verifyPdf, detectEngines } from "@mostajs/pdf-sign";

// Signature (auto : pyhanko si dispo, sinon Node)
await signPdf({
  input: "crh.pdf",
  output: "crh.signe.pdf",
  p12: "praticien.p12",
  passphrase: process.env.P12_PASS,
  meta: { reason: "Compte rendu d'hospitalisation", name: "Dr H. Madani", location: "Alger, DZ" },
});

// Signature restreinte (PAdES + chiffrement AES-256 — exige pyhanko)
await signPdf({
  input: "facture-cnas.pdf",
  output: "facture-cnas.signe.pdf",
  p12: "etablissement.p12",
  passphrase: process.env.P12_PASS,
  permissions: { extract: false, modifyOther: false, printHighres: true },
  field: { page: 1, box: [320, 40, 575, 140], stampImage: "logo-chu.png" }, // cachet visible image + texte
  engine: "pyhanko",
});

// Vérification
const r = verifyPdf({ input: "crh.signe.pdf", trustPem: "ac-racine.pem" });
console.log(r.signed, r.signatures);

// État des moteurs
console.log(detectEngines());

CLI

mosta-pdf-sign sign in.pdf out.pdf --p12 cert.p12 --pass secret \
    --reason "Ordonnance" --name "Dr H. Madani" --location "Alger, DZ"
mosta-pdf-sign sign in.pdf out.pdf --p12 cert.p12 --pass secret --restrict --engine pyhanko
mosta-pdf-sign verify out.pdf --trust ac-racine.pem
mosta-pdf-sign engines

Configuration (.env)

| Clé | Rôle | |---|---| | PDF_SIGN_P12 / PDF_SIGN_PASSPHRASE / PDF_SIGN_PASSPHRASE_FILE | certificat PKCS#12 et secret | | PDF_SIGN_ENGINE | auto (défaut) · node · pyhanko | | PDF_SIGN_PYTHON | binaire Python du venv pyhanko | | PDF_SIGN_REASON / _LOCATION / _NAME / _CONTACT | métadonnées du cachet | | PDF_SIGN_FIELD_PAGE / PDF_SIGN_FIELD_BOX | page (0-based) et boîte x1,y1,x2,y2 (points, origine bas-gauche) | | PDF_SIGN_STAMP_IMAGE | image de fond du cachet visible (logo/tampon derrière le texte ; moteur pyhanko) | | PDF_SIGN_RESTRICT | true → permissions restrictives (pyhanko) | | PDF_SIGN_TRUST_PEM | certificat de confiance pour la vérification |

Moteurs

| Moteur | PKCS#7 | PAdES visible | Permissions AES-256 | Dépendance | |---|:---:|:---:|:---:|---| | node | ✅ | ❌ | ❌ | aucune (JS pur) | | pyhanko | ✅ | ✅ | ✅ | venv pyhanko>=0.25, pikepdf>=8 |

Le cœur Node lève une erreur si des permissions sont demandées : le PAdES et le chiffrement exigent pyhanko.

Voir aussi

  • @mostajs/pdf-sign-ui — couche de présentation (formulaire de signature, vérification, headless + composants).