UNPKG

@visulima/email

Version:

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

49 lines (48 loc) 1.89 kB
import type { EmailOptions } from "../types.d.ts"; import type { EmailSigner, SmimeSignOptions } from "./types.d.ts"; /** * S/MIME signer implementation using PKIjs * Note: Requires pkijs and asn1js for S/MIME operations * Uses Node.js crypto for all cryptographic operations */ export declare class SmimeSigner implements EmailSigner { /** * Formats an email address for use in email headers. * @param address The email address object to format. * @param address.email The email address string. * @param address.name Optional display name for the email address. * @returns The formatted email address string in RFC 5322 format. */ private static formatAddress; private readonly options; /** * Creates a new S/MIME signer. * @param options S/MIME signing options. */ constructor(options: SmimeSignOptions); /** * Signs an email message with S/MIME. * @param email The email options to sign. * @returns The email options with S/MIME signature. * @throws {Error} When signing fails (e.g., invalid certificate/key). */ sign(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; /** * Formats email addresses for use in email headers. * @param addresses The email addresses to format (single or array). * @returns The formatted email addresses string (comma-separated if multiple). */ private formatAddresses; } /** * Creates a new S/MIME signer instance. * @param options The S/MIME signing options. * @returns A new SmimeSigner instance ready to sign emails. */ export declare const createSmimeSigner: (options: SmimeSignOptions) => SmimeSigner;