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-ui

v0.1.0

Published

Couche de présentation de @mostajs/pdf-sign — logique headless (validation du formulaire de signature, préréglages de documents officiels/SIH, view-models de vérification, contrôleur). Framework-agnostique, zéro dépendance.

Readme

@mostajs/pdf-sign-ui

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

Couche de présentation de @mostajs/pdf-sign. Logique headless (framework-agnostique, zéro dépendance, testable sans navigateur) : validation du formulaire de signature, préréglages de documents officiels, view-models d'état moteur et de vérification, contrôleur orchestrant le moteur.

Le module ne signe pas lui-même : il pilote @mostajs/pdf-sign via un service injecté (in-process ou handlers HTTP).

Cadrage SIH (générique, surchargeable)

Des préréglages couvrent les documents à valeur probante d'un SIH — tout en restant génériques :

  • clinique : crh, cro, imagerie, biologie
  • administratif : ordonnance, certificat_sejour, dossier_sortie
  • financier / CNAS-CASNOS : facture, bordereau, prise_en_charge

Chaque préréglage propose un motif (reason) et une recommandation restrict (permissions AES-256, moteur pyhanko). L'appelant peut tout surcharger.

API

import {
  validateSignForm, buildSignRequest, buildVerifyViewModel,
  buildEngineViewModel, createPdfSignUiController, listPresets,
} from "@mostajs/pdf-sign-ui";
import * as engine from "@mostajs/pdf-sign"; // service in-process

const ctl = createPdfSignUiController({ service: engine, t: monI18n });

// Bandeau moteur
console.log(ctl.engines.label, ctl.engines.canRestrict);

// Soumission d'un formulaire (validation intégrée)
const res = await ctl.submit({
  input: "crh.pdf", output: "crh.signe.pdf",
  p12: "praticien.p12", passphrase: process.env.P12_PASS,
  preset: "crh",           // motif + permissions par défaut
  name: "Dr H. Madani", location: "Alger, DZ",
});
if (!res.ok) console.error(res.errors); else console.log(res.result);

// Vérification (view-model prêt pour un tableau)
console.log(ctl.verify("crh.signe.pdf", { trustPem: "ac-racine.pem" }));

Fonctions pures (sans contrôleur)

const { valid, errors } = validateSignForm(formData, { engines: { node: true, pyhanko: true } });
const signOptions = buildSignRequest(formData);        // → SignOptions de @mostajs/pdf-sign
const vm = buildVerifyViewModel(verifyResult);          // → { signed, status, rows[] }
const badge = buildEngineViewModel(detectEnginesResult);

Contrat du service

createPdfSignUiController exige un objet exposant :

| Méthode | Signature | Origine | |---|---|---| | signPdf(opts) | Promise<SignResult> | @mostajs/pdf-sign | | verifyPdf(opts) | VerifyResult | @mostajs/pdf-sign | | detectEngines() | EngineAvailability | @mostajs/pdf-sign |

En architecture web, ces méthodes peuvent être des appels à des handlers serveur (le moteur — Node + Python — reste côté serveur).

Composants React (@mostajs/pdf-sign-ui/react)

Peer optionnelle react >=18. Composants en React.createElement (aucune syntaxe JSX ; un bundler résout les .jsx), pilotés par la logique headless.

| Composant | Rôle | |---|---| | <EngineBadge availability|engines t /> | bandeau d'état du moteur (PAdES / permissions disponibles) | | <SignForm service t presets initialData onSigned /> | formulaire de signature : préréglage de document, certificat, métadonnées, moteur, permissions, cachet image ; validation intégrée | | <VerifyPanel service t input trustPem auto /> | vérification d'un PDF + tableau des signatures (intègre / valide / confiance / signataire) |

import { SignForm, VerifyPanel, EngineBadge } from "@mostajs/pdf-sign-ui/react";

<SignForm service={engine} t={t} onSigned={(r) => console.log(r)} />
<VerifyPanel service={engine} t={t} trustPem="ac-racine.pem" />

Le service est le même contrat que le contrôleur (signPdf/verifyPdf/detectEngines). En web, ce sont typiquement des appels aux handlers serveur (le moteur Node + Python reste côté serveur).

Tests

npm test         # logique headless (@mostajs/mjs-unit)
npm run test:react  # rendu SSR des composants (react + react-dom requis)