import { PdfDocumentSecurityStoreObject } from './document-security-store.js'; import { PdfSignatureObject } from './signatures/index.js'; import { PdfSignatureVerificationResult, CertificateValidationOptions, PdfSignatureSubType } from './types.js'; import { PdfDocument } from '../pdf/pdf-document.js'; /** * Result of verifying all signatures in a this.document. */ export type PdfDocumentVerificationResult = { /** Whether all signatures in the document are valid. */ valid: boolean; /** Individual signature verification results. */ signatures: { /** The signature subfilter type. */ type: PdfSignatureSubType; /** Index of the signature in the this.document. */ index: number; /** The signature object. */ signature: PdfSignatureObject; /** The verification result. */ result: PdfSignatureVerificationResult; }[]; }; /** * Handles digital signing operations for PDF documents. * Processes signature objects and optionally stores revocation information in the DSS. * * @example * ```typescript * const signer = new PdfSigner() * const signedDoc = await signer.sign(document) * ``` */ export declare class PdfSigner { /** The PDF document to be signed. */ document: PdfDocument; /** Whether to use the Document Security Store for revocation information. */ useDocumentSecurityStore: boolean; constructor(options: { useDocumentSecurityStore?: boolean; document: PdfDocument; }); /** * Signs all signature objects in the this.document. * Computes byte ranges, generates signatures, and optionally adds revocation info to DSS. * * @param document - The PDF document to sign. * @returns The signed this.document. */ sign(): Promise; /** * Instantiates the appropriate signature object based on SubFilter type. * * @param signatureDict - The signature dictionary. * @returns A properly typed PdfSignatureObject subclass. */ private instantiateSignatureObject; /** * Verifies all signatures in the this.document. * First serializes the document to bytes and reloads it to ensure signatures * are properly deserialized into the correct classes before verification. * Then searches for signature objects, computes their byte ranges, and verifies each one. * * @param document - The PDF document to verify. * @param options - Optional verification options. * @returns The verification result for all signatures. * * @example * ```typescript * const signer = new PdfSigner() * const result = await signer.verify(document) * if (result.valid) { * console.log('All signatures are valid') * } else { * result.signatures.forEach(sig => { * if (!sig.result.valid) { * console.log(`Signature ${sig.index} invalid:`, sig.result.reasons) * } * }) * } * ``` */ verify(options?: { certificateValidation?: CertificateValidationOptions | boolean; }): Promise; /** * Sets the Document Security Store (DSS) for the this.document. * Used for long-term validation of digital signatures. * * @param dss - The Document Security Store object to set * @throws Error if the document has no root dictionary */ setDocumentSecurityStore(dss: PdfDocumentSecurityStoreObject): void; }