UNPKG

@visulima/email

Version:

A comprehensive email library with multi-provider support, crypto utilities, and template engines

54 lines (53 loc) 2.21 kB
import type { EmailOptions } from "../types.d.ts"; import type { EmailEncrypter, SmimeEncryptOptions } from "./types.d.ts"; /** * S/MIME encrypter implementation using PKIjs * Note: Requires pkijs and asn1js for S/MIME operations * Uses Node.js crypto for all cryptographic operations */ export declare class SmimeEncrypter implements EmailEncrypter { /** * Collects and normalizes all recipients (to, cc, bcc) from email options. * Normalizes each to an array, extracts email addresses, and deduplicates. * @param email The email options containing recipients. * @returns An array of unique email addresses (strings). */ private static collectRecipients; /** * Formats an email address for use in email headers. * @param address The email address to format (string or EmailAddress object). * @returns The formatted email address string in RFC 5322 format. */ private static formatAddress; /** * Formats email addresses for use in email headers. * @param addresses The email addresses to format (single or array, string or EmailAddress objects). * @returns The formatted email addresses string (comma-separated if multiple). */ private static formatAddresses; private readonly options; /** * Creates a new S/MIME encrypter. * @param options S/MIME encryption options. */ constructor(options: SmimeEncryptOptions); /** * Encrypts an email message with S/MIME. * @param email The email options to encrypt. * @returns The encrypted email options. * @throws {Error} When encryption fails (e.g., invalid certificate). */ encrypt(email: EmailOptions): Promise<EmailOptions>; /** * Builds the email message string from email options. * @param email The email options to build the message from. * @returns The formatted email message as a string. */ private buildMessage; } /** * Creates a new S/MIME encrypter instance. * @param options The S/MIME encryption options. * @returns A new SmimeEncrypter instance ready to encrypt emails. */ export declare const createSmimeEncrypter: (options: SmimeEncryptOptions) => SmimeEncrypter;