Repository navigation
Digital Signing
Government tenders, tax filings, and legal agreements require cryptographic signatures that preserve every byte signed earlier while letting downstream officers add co-signatures cleanly.
Full-rewrite PDF libraries alter object numbering and cross-reference offsets every time they save a file—instantly breaking existing digital signatures. ONEX includes writePdfIncremental(), which keeps the original PDF prefix untouched down to the last byte, appends /AcroForm + /Widget + /Type /Sig objects, chains a new xref section back to the previous startxref via /Prev, and computes exact /ByteRange hashes over the updated bytes.
-
PKCS#12 / PFX containers:
signer: { p12Path | p12Buffer, passphrase }parsed via pure TypeScript ASN.1 safe-bag extraction plus Node OpenSSL PKCS#8 decryption. -
PEM key pairs:
signer: { keyPem, certPem, chainPem?, passphrase? }. -
External HSM / USB eToken / Aadhaar eSign callback: Pass
signer: { certPem, chainPem?, sign(data, meta) }to sign CMS attributes asynchronously on external hardware.
import { signPdf, verifyPdfSignatures } from 'onex-pdf';
const signed = await signPdf(pdfBuffer, {
signer: { p12Path: 'officer.p12', passphrase: 'secret' },
reason: 'Procurement Approval',
location: 'New Delhi, IN',
docMdp: 'formFillAndSign',
tsaUrl: 'https://tsa.example.in',
appearance: { position: 'bottomRight', includeDate: true },
});
const result = verifyPdfSignatures(signed, {
trustedCaPem: rootCaPem,
checkExpiry: true,
});Inspecting result gives you per-signature digest status, hasTimestamp, docMdpPermission (1, 2, or 3), certificate validity at verification time, and trust-chain verification (chainValid). Note that tsaUrl passes through ONEX's SSRF validator (checkUrlAsync), blocking internal/loopback URLs by default unless explicitly permitted in security.
- Home
- Architecture & Render Pipeline
- PDF Internals & Extraction
- Unicode 16, Fonts & Legacy Indic
- Security & SSRF Model
- Digital Signing (
signPdf) - True Redaction (
redactPdf) - Semantic Diff & Redlines (
diffPdfs) - Self-Auditing Renders (
renderVerified) - PDF/A-3b & E-Invoices (
renderEInvoice) - HTTP, MCP, CLI & Puppeteer
Handbook & Deep Analysis: bahubalisid.github.io/onex