import { PdfDictionary } from '../../core/objects/pdf-dictionary.js'; import { PdfSignatureDictionaryEntries, PdfSignatureSubType, PdfSignatureVerificationOptions, PdfSignatureVerificationResult, RevocationInfo } from '../types.js'; import { PdfHexadecimal } from '../../core/objects/pdf-hexadecimal.js'; import { PdfIndirectObject } from '../../core/objects/pdf-indirect-object.js'; import { ByteArray } from '../../types.js'; /** * PDF signature dictionary containing all signature-related entries. * Manages the ByteRange and Contents fields with appropriate placeholder sizing. */ export declare class PdfSignatureDictionary extends PdfDictionary { /** * Creates a new signature dictionary. * * @param entries - The signature dictionary entries, ByteRange and Contents are auto-populated if not provided. */ constructor(entries: Omit & { ByteRange?: PdfSignatureDictionaryEntries['ByteRange']; Contents?: PdfSignatureDictionaryEntries['Contents']; }); } /** * Options for signature metadata. */ export type PdfSignatureSignOptions = { /** Signing date. */ date?: Date; /** Signer name. */ name?: string; /** Reason for signing. */ reason?: string; /** Contact information. */ contactInfo?: string; /** Signing location. */ location?: string; }; /** * Abstract base class for PDF signature objects. * Subclasses implement specific signature formats (PKCS#7, CAdES, etc.). * * @example * ```typescript * const signature = new PdfAdbePkcs7DetachedSignatureObject({ * privateKey, * certificate, * reason: 'Approval' * }) * document.add(signature) * await document.commit() * ``` */ export declare abstract class PdfSignatureObject extends PdfIndirectObject { /** * Creates a new signature object. * * @param content - Either a signature dictionary or options to create one. */ constructor(content: PdfSignatureDictionary | (PdfSignatureSignOptions & { subfilter: PdfSignatureSubType; certs?: ByteArray[]; })); /** * Signs the document bytes and returns the signature. * * @param options - Signing options including bytes to sign. * @returns The signed bytes and optional revocation information. */ abstract sign(options: { bytes: ByteArray; embedRevocationInfo?: boolean; }): Promise<{ signedBytes: ByteArray; revocationInfo?: RevocationInfo; }>; /** * Verifies the signature against the provided document bytes. * * @param options - Verification options including the signed bytes. * @returns The verification result. */ abstract verify(options: PdfSignatureVerificationOptions): Promise; /** * Gets the signature hexadecimal content. * * @returns The Contents entry as hexadecimal. * @throws Error if Contents entry is missing. */ get signedHexadecimal(): PdfHexadecimal; /** * Gets the raw signature bytes. * * @returns The signature bytes. */ get signedBytes(): ByteArray; /** * Sets the signed bytes in the signature dictionary. * * @param signedBytes - The signature bytes to set. * @throws Error if Contents entry is missing. */ setSignedBytes(signedBytes: ByteArray): void; /** * Sets the byte range array for the signature. * * @param byteRange - Array of [offset1, length1, offset2, length2]. * @throws Error if ByteRange entry is missing. */ setByteRange(byteRange: number[]): void; /** * Gets the insertion order for this object in the PDF. * * @returns High order value to place signature near end of document. */ order(): number; /** * Compares two byte arrays for equality. * * @param a - First byte array. * @param b - Second byte array. * @returns True if arrays are equal, false otherwise. */ protected compareArrays(a: ByteArray, b: ByteArray): boolean; }