import { PdfArray } from '../core/objects/pdf-array.js'; import { PdfBoolean } from '../core/objects/pdf-boolean.js'; import { PdfDictionary } from '../core/objects/pdf-dictionary.js'; import { PdfHexadecimal } from '../core/objects/pdf-hexadecimal.js'; import { PdfIndirectObject } from '../core/objects/pdf-indirect-object.js'; import { PdfName } from '../core/objects/pdf-name.js'; import { PdfNumber } from '../core/objects/pdf-number.js'; import { PdfString } from '../core/objects/pdf-string.js'; import { ByteArray } from '../types.js'; /** * Represents the PDF document ID array containing two hexadecimal identifiers. * The first element is the permanent ID assigned when the document is created, * and the second is updated when the document is modified. */ export type PdfId = PdfArray; /** * Dictionary defining a crypt filter for PDF encryption. * Specifies the encryption method and authentication event trigger. */ export type PdfCryptFilterDictionary = PdfDictionary<{ AuthEvent?: PdfName<'DocOpen' | 'EFOpen'>; CFM: PdfName<'None' | 'V2' | 'AESV2' | 'AESV3'>; Length?: PdfNumber; }>; /** * The encryption dictionary stored in the PDF trailer. * Contains all encryption parameters including filter type, version, revision, * owner/user keys, permissions, and crypt filter configurations. */ export type PdfEncryptionDictionary = PdfDictionary<{ Filter: PdfName<'Standard' | 'Adobe.PubSec'>; SubFilter?: PdfName<'adbe.pkcs7.s3' | 'adbe.pkcs7.s4' | 'adbe.pkcs7.s5'>; V: PdfNumber; R: PdfNumber; O: PdfString | PdfHexadecimal; OE?: PdfString | PdfHexadecimal; U: PdfString | PdfHexadecimal; UE?: PdfString | PdfHexadecimal; P: PdfNumber; Perms?: PdfString | PdfHexadecimal; Length: PdfNumber; CF?: PdfDictionary<{ [key: string]: PdfCryptFilterDictionary; }>; StmF?: PdfName; StrF?: PdfName; EFF?: PdfName; EncryptMetadata?: PdfBoolean; ID?: PdfArray; Recipients?: PdfArray; }>; /** * An indirect object containing the encryption dictionary. */ export type PdfEncryptionDictionaryObject = PdfIndirectObject; /** * Specifies the type of content being encrypted. * - 'string': PDF string objects * - 'stream': PDF stream objects * - 'file': Embedded file streams */ export type CryptFilterType = 'string' | 'stream' | 'file'; /** * Recipient information for public key encryption. * Contains the certificate for encryption and optional private key for decryption. */ export type PdfEncryptionRecipient = { certificate?: ByteArray; privateKey?: ByteArray; }; /** * Supported encryption algorithm types. * - 'RC4-40': 40-bit RC4 encryption (weak, legacy) * - 'RC4-128': 128-bit RC4 encryption (legacy) * - 'AES-128-CBC': 128-bit AES in CBC mode * - 'AES-256-CBC': 256-bit AES in CBC mode (recommended) * - 'none': No encryption (identity filter) */ export type PdfEncryptionAlgorithmType = 'RC4-40' | 'RC4-128' | 'AES-128-CBC' | 'AES-256-CBC' | 'none'; /** * RC4-40 encryption configuration. */ type Rc40 = { default: 'RC4-40'; }; /** * RC4-128 encryption configuration. */ type Rc128 = { default: 'RC4-128'; }; /** * AES-128 encryption configuration with optional per-type crypt filters. */ type Aes128WithCryptFilters = { default: 'AES-128-CBC'; streams?: 'AES-128-CBC' | 'RC4-128' | 'RC4-40' | 'none'; strings?: 'AES-128-CBC' | 'RC4-128' | 'RC4-40' | 'none'; }; /** * AES-256 encryption configuration with optional per-type crypt filters. */ type Aes256 = { default: 'AES-256-CBC' | 'none'; streams?: 'AES-256-CBC' | 'AES-128-CBC' | 'RC4-128' | 'none'; files?: 'AES-256-CBC' | 'AES-128-CBC' | 'RC4-128' | 'none'; strings?: 'AES-256-CBC' | 'AES-128-CBC' | 'RC4-128' | 'none'; }; /** * Union of all encryption algorithm configuration options. */ export type PdfEncryptionAlgorithmOptions = Rc40 | Rc128 | Aes128WithCryptFilters | Aes256; /** * Options for configuring PDF encryption. * Includes encryption method, passwords, document ID, and permission settings. */ export type PdfEncryptionOptions = { method?: PdfEncryptionAlgorithmOptions; password?: ByteArray | string; ownerPassword?: ByteArray | string; documentId?: PdfId | ByteArray | string; encryptMetadata?: boolean; recipients?: PdfEncryptionRecipient[]; permissions?: { print?: boolean; modify?: boolean; copy?: boolean; annotate?: boolean; fill?: boolean; extract?: boolean; assemble?: boolean; printHighQuality?: boolean; all?: boolean; }; }; export {};