@visulima/email 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/LICENSE.md +1266 -0
  3. package/README.md +1084 -0
  4. package/dist/attachment-helpers.d.ts +64 -0
  5. package/dist/crypto/dkim-signer.d.ts +48 -0
  6. package/dist/crypto/index.d.ts +4 -0
  7. package/dist/crypto/index.js +1 -0
  8. package/dist/crypto/smime-encrypter.d.ts +53 -0
  9. package/dist/crypto/smime-signer.d.ts +48 -0
  10. package/dist/crypto/types.d.ts +101 -0
  11. package/dist/errors/email-error.d.ts +17 -0
  12. package/dist/errors/required-option-error.d.ts +10 -0
  13. package/dist/index.d.ts +22 -0
  14. package/dist/index.js +1 -0
  15. package/dist/mail.d.ts +357 -0
  16. package/dist/packem_shared/DkimSigner-Z8D4Il10.js +18 -0
  17. package/dist/packem_shared/EmailError-zm2ffVav.js +1 -0
  18. package/dist/packem_shared/MailMessage-Hdgowmvi.js +1 -0
  19. package/dist/packem_shared/RequiredOptionError-CevW3u2K.js +1 -0
  20. package/dist/packem_shared/SmimeEncrypter-CBevU534.js +6 -0
  21. package/dist/packem_shared/SmimeSigner-02aXVi90.js +8 -0
  22. package/dist/packem_shared/address-formatter-Cm_E_ZMa.js +1 -0
  23. package/dist/packem_shared/ahaSendProvider-NUD_kwyT.js +1 -0
  24. package/dist/packem_shared/attachment-processor-2rHmfa7j.js +1 -0
  25. package/dist/packem_shared/awsSesProvider-CkuFOzb0.js +32 -0
  26. package/dist/packem_shared/azureProvider-Ckdrpmw9.js +1 -0
  27. package/dist/packem_shared/brevoProvider-CB3IYW4n.js +1 -0
  28. package/dist/packem_shared/buildMimeMessage-BPtd0pno.js +2 -0
  29. package/dist/packem_shared/comparePriority-BfiwjVsV.js +1 -0
  30. package/dist/packem_shared/createLogger-DlElSVQP.js +1 -0
  31. package/dist/packem_shared/defineProvider-B9rSklAJ.js +1 -0
  32. package/dist/packem_shared/detectMimeType-S8WRsNtY.js +1 -0
  33. package/dist/packem_shared/failoverProvider-sam9n1AG.js +1 -0
  34. package/dist/packem_shared/formatEmailAddress-CHeME3Vk.js +1 -0
  35. package/dist/packem_shared/formatEmailAddresses-UegVOe5A.js +1 -0
  36. package/dist/packem_shared/generateBoundary-CZ8kJuY6.js +1 -0
  37. package/dist/packem_shared/generateMessageId-11Ls5JsR.js +1 -0
  38. package/dist/packem_shared/headersToRecord-BKUTr40L.js +1 -0
  39. package/dist/packem_shared/httpProvider-BhN0RrK-.js +1 -0
  40. package/dist/packem_shared/infobipProvider-D8vYTHV4.js +1 -0
  41. package/dist/packem_shared/isPortAvailable-5kfsfo8u.js +1 -0
  42. package/dist/packem_shared/mailCrabProvider-BEwRjB3F.js +1 -0
  43. package/dist/packem_shared/mailPaceProvider-C47Izgaj.js +1 -0
  44. package/dist/packem_shared/mailerSendProvider-C4uAo-fc.js +1 -0
  45. package/dist/packem_shared/mailgunProvider-B7upu_OV.js +1 -0
  46. package/dist/packem_shared/mailjetProvider-ReErm08u.js +1 -0
  47. package/dist/packem_shared/mailomatProvider-OlCT_O2i.js +1 -0
  48. package/dist/packem_shared/mailtrapProvider-hVMV3h6r.js +1 -0
  49. package/dist/packem_shared/makeRequest-DwxHX0xo.js +1 -0
  50. package/dist/packem_shared/mandrillProvider-DdnbkHZI.js +1 -0
  51. package/dist/packem_shared/mockProvider-BDWZJpea.js +1 -0
  52. package/dist/packem_shared/nodemailerProvider-BV21eRGX.js +1 -0
  53. package/dist/packem_shared/opentelemetryProvider-kAz62mKm.js +1 -0
  54. package/dist/packem_shared/parseAddress-CATTKGe_.js +1 -0
  55. package/dist/packem_shared/plunkProvider-Bs6K51lT.js +1 -0
  56. package/dist/packem_shared/postalProvider-Bcsxp-z6.js +1 -0
  57. package/dist/packem_shared/postmarkProvider-BUq3wuYD.js +1 -0
  58. package/dist/packem_shared/provider-base-_hbWXBdK.js +1 -0
  59. package/dist/packem_shared/readFile-BlZxbhCU-C8bCdiA2.js +1 -0
  60. package/dist/packem_shared/resendProvider-D-_HQpN_.js +1 -0
  61. package/dist/packem_shared/retry-D1MBqS49.js +1 -0
  62. package/dist/packem_shared/roundRobinProvider-CejLM1rZ.js +1 -0
  63. package/dist/packem_shared/sanitize-header-wWav-Scu.js +1 -0
  64. package/dist/packem_shared/scalewayProvider-1n6ePiGl.js +1 -0
  65. package/dist/packem_shared/sendGridProvider-B1T62dyX.js +1 -0
  66. package/dist/packem_shared/smtpProvider-CcAoRrkt.js +23 -0
  67. package/dist/packem_shared/sweegoProvider-CxFmEUh6.js +1 -0
  68. package/dist/packem_shared/validateEmail-BkVdVioP.js +1 -0
  69. package/dist/packem_shared/validateEmailOptions-BzlJECG5.js +1 -0
  70. package/dist/packem_shared/zeptomailProvider-CWYQPAJk.js +1 -0
  71. package/dist/providers/ahasend/index.d.ts +3 -0
  72. package/dist/providers/ahasend/index.js +1 -0
  73. package/dist/providers/ahasend/provider.d.ts +7 -0
  74. package/dist/providers/ahasend/types.d.ts +28 -0
  75. package/dist/providers/aws-ses/index.d.ts +3 -0
  76. package/dist/providers/aws-ses/index.js +1 -0
  77. package/dist/providers/aws-ses/provider.d.ts +8 -0
  78. package/dist/providers/aws-ses/types.d.ts +38 -0
  79. package/dist/providers/azure/index.d.ts +3 -0
  80. package/dist/providers/azure/index.js +1 -0
  81. package/dist/providers/azure/provider.d.ts +7 -0
  82. package/dist/providers/azure/types.d.ts +44 -0
  83. package/dist/providers/brevo/index.d.ts +3 -0
  84. package/dist/providers/brevo/index.js +1 -0
  85. package/dist/providers/brevo/provider.d.ts +7 -0
  86. package/dist/providers/brevo/types.d.ts +50 -0
  87. package/dist/providers/failover/index.d.ts +3 -0
  88. package/dist/providers/failover/index.js +1 -0
  89. package/dist/providers/failover/provider.d.ts +7 -0
  90. package/dist/providers/failover/types.d.ts +19 -0
  91. package/dist/providers/http/index.d.ts +3 -0
  92. package/dist/providers/http/index.js +1 -0
  93. package/dist/providers/http/provider.d.ts +7 -0
  94. package/dist/providers/http/types.d.ts +27 -0
  95. package/dist/providers/infobip/index.d.ts +3 -0
  96. package/dist/providers/infobip/index.js +1 -0
  97. package/dist/providers/infobip/provider.d.ts +7 -0
  98. package/dist/providers/infobip/types.d.ts +48 -0
  99. package/dist/providers/mailcrab/index.d.ts +3 -0
  100. package/dist/providers/mailcrab/index.js +1 -0
  101. package/dist/providers/mailcrab/provider.d.ts +9 -0
  102. package/dist/providers/mailcrab/types.d.ts +22 -0
  103. package/dist/providers/mailersend/index.d.ts +3 -0
  104. package/dist/providers/mailersend/index.js +1 -0
  105. package/dist/providers/mailersend/provider.d.ts +7 -0
  106. package/dist/providers/mailersend/types.d.ts +43 -0
  107. package/dist/providers/mailgun/index.d.ts +3 -0
  108. package/dist/providers/mailgun/index.js +1 -0
  109. package/dist/providers/mailgun/provider.d.ts +7 -0
  110. package/dist/providers/mailgun/types.d.ts +65 -0
  111. package/dist/providers/mailjet/index.d.ts +3 -0
  112. package/dist/providers/mailjet/index.js +1 -0
  113. package/dist/providers/mailjet/provider.d.ts +7 -0
  114. package/dist/providers/mailjet/types.d.ts +64 -0
  115. package/dist/providers/mailomat/index.d.ts +3 -0
  116. package/dist/providers/mailomat/index.js +1 -0
  117. package/dist/providers/mailomat/provider.d.ts +7 -0
  118. package/dist/providers/mailomat/types.d.ts +32 -0
  119. package/dist/providers/mailpace/index.d.ts +3 -0
  120. package/dist/providers/mailpace/index.js +1 -0
  121. package/dist/providers/mailpace/provider.d.ts +7 -0
  122. package/dist/providers/mailpace/types.d.ts +44 -0
  123. package/dist/providers/mailtrap/index.d.ts +3 -0
  124. package/dist/providers/mailtrap/index.js +1 -0
  125. package/dist/providers/mailtrap/provider.d.ts +7 -0
  126. package/dist/providers/mailtrap/types.d.ts +36 -0
  127. package/dist/providers/mandrill/index.d.ts +3 -0
  128. package/dist/providers/mandrill/index.js +1 -0
  129. package/dist/providers/mandrill/provider.d.ts +7 -0
  130. package/dist/providers/mandrill/types.d.ts +79 -0
  131. package/dist/providers/mock/index.d.ts +3 -0
  132. package/dist/providers/mock/index.js +1 -0
  133. package/dist/providers/mock/provider.d.ts +8 -0
  134. package/dist/providers/mock/types.d.ts +50 -0
  135. package/dist/providers/nodemailer/index.d.ts +3 -0
  136. package/dist/providers/nodemailer/index.js +1 -0
  137. package/dist/providers/nodemailer/provider.d.ts +7 -0
  138. package/dist/providers/nodemailer/types.d.ts +30 -0
  139. package/dist/providers/opentelemetry/index.d.ts +3 -0
  140. package/dist/providers/opentelemetry/index.js +1 -0
  141. package/dist/providers/opentelemetry/provider.d.ts +8 -0
  142. package/dist/providers/opentelemetry/types.d.ts +31 -0
  143. package/dist/providers/plunk/index.d.ts +3 -0
  144. package/dist/providers/plunk/index.js +1 -0
  145. package/dist/providers/plunk/provider.d.ts +7 -0
  146. package/dist/providers/plunk/types.d.ts +30 -0
  147. package/dist/providers/postal/index.d.ts +3 -0
  148. package/dist/providers/postal/index.js +1 -0
  149. package/dist/providers/postal/provider.d.ts +7 -0
  150. package/dist/providers/postal/types.d.ts +40 -0
  151. package/dist/providers/postmark/index.d.ts +3 -0
  152. package/dist/providers/postmark/index.js +1 -0
  153. package/dist/providers/postmark/provider.d.ts +7 -0
  154. package/dist/providers/postmark/types.d.ts +52 -0
  155. package/dist/providers/provider.d.ts +27 -0
  156. package/dist/providers/resend/index.d.ts +3 -0
  157. package/dist/providers/resend/index.js +1 -0
  158. package/dist/providers/resend/provider.d.ts +7 -0
  159. package/dist/providers/resend/types.d.ts +43 -0
  160. package/dist/providers/roundrobin/index.d.ts +3 -0
  161. package/dist/providers/roundrobin/index.js +1 -0
  162. package/dist/providers/roundrobin/provider.d.ts +7 -0
  163. package/dist/providers/roundrobin/types.d.ts +19 -0
  164. package/dist/providers/scaleway/index.d.ts +3 -0
  165. package/dist/providers/scaleway/index.js +1 -0
  166. package/dist/providers/scaleway/provider.d.ts +7 -0
  167. package/dist/providers/scaleway/types.d.ts +36 -0
  168. package/dist/providers/sendgrid/index.d.ts +3 -0
  169. package/dist/providers/sendgrid/index.js +1 -0
  170. package/dist/providers/sendgrid/provider.d.ts +7 -0
  171. package/dist/providers/sendgrid/types.d.ts +76 -0
  172. package/dist/providers/smtp/index.d.ts +3 -0
  173. package/dist/providers/smtp/index.js +1 -0
  174. package/dist/providers/smtp/provider.d.ts +7 -0
  175. package/dist/providers/smtp/types.d.ts +63 -0
  176. package/dist/providers/sweego/index.d.ts +3 -0
  177. package/dist/providers/sweego/index.js +1 -0
  178. package/dist/providers/sweego/provider.d.ts +7 -0
  179. package/dist/providers/sweego/types.d.ts +32 -0
  180. package/dist/providers/utils/address-formatter.d.ts +139 -0
  181. package/dist/providers/utils/attachment-processor.d.ts +58 -0
  182. package/dist/providers/utils/index.d.ts +4 -0
  183. package/dist/providers/utils/payload-builder.d.ts +78 -0
  184. package/dist/providers/utils/provider-base.d.ts +69 -0
  185. package/dist/providers/zeptomail/index.d.ts +3 -0
  186. package/dist/providers/zeptomail/index.js +1 -0
  187. package/dist/providers/zeptomail/provider.d.ts +7 -0
  188. package/dist/providers/zeptomail/types.d.ts +29 -0
  189. package/dist/template-engines/handlebars.d.ts +25 -0
  190. package/dist/template-engines/handlebars.js +1 -0
  191. package/dist/template-engines/html-to-text.d.ts +27 -0
  192. package/dist/template-engines/html-to-text.js +1 -0
  193. package/dist/template-engines/mjml.d.ts +12 -0
  194. package/dist/template-engines/mjml.js +1 -0
  195. package/dist/template-engines/react-email.d.ts +11 -0
  196. package/dist/template-engines/react-email.js +1 -0
  197. package/dist/template-engines/types.d.ts +8 -0
  198. package/dist/template-engines/vue-email.d.ts +11 -0
  199. package/dist/template-engines/vue-email.js +1 -0
  200. package/dist/types.d.ts +185 -0
  201. package/dist/utils/build-mime-message.d.ts +8 -0
  202. package/dist/utils/compare-priority.d.ts +16 -0
  203. package/dist/utils/create-logger.d.ts +18 -0
  204. package/dist/utils/format-email-address.d.ts +9 -0
  205. package/dist/utils/format-email-addresses.d.ts +8 -0
  206. package/dist/utils/generate-boundary.d.ts +7 -0
  207. package/dist/utils/generate-message-id.d.ts +6 -0
  208. package/dist/utils/headers-to-record.d.ts +9 -0
  209. package/dist/utils/is-port-available.d.ts +9 -0
  210. package/dist/utils/make-request.d.ts +18 -0
  211. package/dist/utils/parse-address.d.ts +19 -0
  212. package/dist/utils/retry.d.ts +10 -0
  213. package/dist/utils/sanitize-header.d.ts +14 -0
  214. package/dist/utils/to-base64.d.ts +8 -0
  215. package/dist/utils/validate-email-options.d.ts +8 -0
  216. package/dist/utils/validate-email.d.ts +7 -0
  217. package/package.json +269 -0
@@ -0,0 +1,64 @@
1
+ import type { Buffer } from "node:buffer";
2
+ /**
3
+ * Detects MIME type from filename using mime package.
4
+ * Falls back to application/octet-stream if not found.
5
+ * @param filename The filename or path.
6
+ * @returns MIME type or application/octet-stream as fallback.
7
+ */
8
+ export declare const detectMimeType: (filename: string) => string;
9
+ /**
10
+ * Generates a Content-ID for inline attachments.
11
+ * @param filename The filename to generate CID from.
12
+ * @returns A unique Content-ID string.
13
+ */
14
+ export declare const generateContentId: (filename: string) => string;
15
+ /**
16
+ * Reads file and returns its content as Buffer.
17
+ * @param filePath Path to the file.
18
+ * @returns Buffer containing file content.
19
+ */
20
+ export declare const readFileAsBuffer: (filePath: string) => Promise<Buffer>;
21
+ /**
22
+ * Attachment options for helper methods
23
+ */
24
+ export interface AttachmentOptions {
25
+ /**
26
+ * Content-ID for inline attachments (used in HTML with cid:).
27
+ * If not provided and contentDisposition is 'inline', will be auto-generated.
28
+ */
29
+ cid?: string;
30
+ /**
31
+ * Content disposition type.
32
+ * 'attachment' (default) or 'inline'.
33
+ */
34
+ contentDisposition?: "attachment" | "inline";
35
+ /**
36
+ * MIME type of the attachment.
37
+ * If not provided, will be detected from filename.
38
+ */
39
+ contentType?: string;
40
+ /**
41
+ * Content transfer encoding.
42
+ * Examples: 'base64', '7bit', 'quoted-printable'.
43
+ */
44
+ encoding?: string;
45
+ /**
46
+ * Custom filename.
47
+ * Used when different from the file path.
48
+ */
49
+ filename?: string;
50
+ /**
51
+ * Custom headers for this attachment.
52
+ */
53
+ headers?: Record<string, string>;
54
+ }
55
+ /**
56
+ * Attachment data options (for raw data attachments)
57
+ */
58
+ export interface AttachmentDataOptions extends AttachmentOptions {
59
+ /**
60
+ * Filename for the attachment.
61
+ * Required for raw data attachments.
62
+ */
63
+ filename: string;
64
+ }
@@ -0,0 +1,48 @@
1
+ import type { EmailOptions } from "../types.d.ts";
2
+ import type { DkimOptions, EmailSigner } from "./types.d.ts";
3
+ /**
4
+ * DKIM signer implementation
5
+ */
6
+ export declare class DkimSigner implements EmailSigner {
7
+ /**
8
+ * Sanitizes a display name for use in quoted email headers per RFC 5322.
9
+ * Removes/replaces CR, LF, tabs with space, escapes backslashes and quotes,
10
+ * and strips non-printable control characters.
11
+ * @param name The display name to sanitize.
12
+ * @returns The sanitized display name, or empty string if nothing remains.
13
+ */
14
+ private static sanitizeDisplayName;
15
+ /**
16
+ * Formats an email address for use in email headers.
17
+ * @param address The email address object to format.
18
+ * @param address.email The email address string.
19
+ * @param address.name Optional display name for the email address.
20
+ * @returns The formatted email address string in RFC 5322 format.
21
+ */
22
+ private static formatAddress;
23
+ /**
24
+ * Formats email addresses for headers.
25
+ * @param addresses The email address(es) to format (single or array).
26
+ * @returns The formatted email addresses string (comma-separated if multiple).
27
+ */
28
+ private static formatAddresses;
29
+ private readonly options;
30
+ /**
31
+ * Creates a new DKIM signer.
32
+ * @param options DKIM signing options.
33
+ */
34
+ constructor(options: DkimOptions);
35
+ /**
36
+ * Signs an email message with DKIM.
37
+ * @param email The email options to sign.
38
+ * @returns The email options with DKIM signature header added.
39
+ * @throws {Error} When signing fails (e.g., invalid private key).
40
+ */
41
+ sign(email: EmailOptions): Promise<EmailOptions>;
42
+ }
43
+ /**
44
+ * Creates a DKIM signer instance.
45
+ * @param options DKIM signing options.
46
+ * @returns A new DkimSigner instance.
47
+ */
48
+ export declare const createDkimSigner: (options: DkimOptions) => DkimSigner;
@@ -0,0 +1,4 @@
1
+ export { createDkimSigner, DkimSigner } from "./dkim-signer.d.ts";
2
+ export { createSmimeEncrypter, SmimeEncrypter } from "./smime-encrypter.d.ts";
3
+ export { createSmimeSigner, SmimeSigner } from "./smime-signer.d.ts";
4
+ export type { DkimOptions, EmailEncrypter, EmailSigner, SmimeEncryptOptions, SmimeSignOptions } from "./types.d.ts";
@@ -0,0 +1 @@
1
+ import{DkimSigner as m,createDkimSigner as i}from"../packem_shared/DkimSigner-Z8D4Il10.js";import{SmimeEncrypter as S,createSmimeEncrypter as n}from"../packem_shared/SmimeEncrypter-CBevU534.js";import{SmimeSigner as c,createSmimeSigner as p}from"../packem_shared/SmimeSigner-02aXVi90.js";export{m as DkimSigner,S as SmimeEncrypter,c as SmimeSigner,i as createDkimSigner,n as createSmimeEncrypter,p as createSmimeSigner};
@@ -0,0 +1,53 @@
1
+ import type { EmailOptions } from "../types.d.ts";
2
+ import type { EmailEncrypter, SmimeEncryptOptions } from "./types.d.ts";
3
+ /**
4
+ * S/MIME encrypter implementation using PKIjs
5
+ * Note: Requires pkijs and asn1js for S/MIME operations
6
+ * Uses Node.js crypto for all cryptographic operations
7
+ */
8
+ export declare class SmimeEncrypter implements EmailEncrypter {
9
+ /**
10
+ * Collects and normalizes all recipients (to, cc, bcc) from email options.
11
+ * Normalizes each to an array, extracts email addresses, and deduplicates.
12
+ * @param email The email options containing recipients.
13
+ * @returns An array of unique email addresses (strings).
14
+ */
15
+ private static collectRecipients;
16
+ /**
17
+ * Formats an email address for use in email headers.
18
+ * @param address The email address to format (string or EmailAddress object).
19
+ * @returns The formatted email address string in RFC 5322 format.
20
+ */
21
+ private static formatAddress;
22
+ /**
23
+ * Formats email addresses for use in email headers.
24
+ * @param addresses The email addresses to format (single or array, string or EmailAddress objects).
25
+ * @returns The formatted email addresses string (comma-separated if multiple).
26
+ */
27
+ private static formatAddresses;
28
+ private readonly options;
29
+ /**
30
+ * Creates a new S/MIME encrypter.
31
+ * @param options S/MIME encryption options.
32
+ */
33
+ constructor(options: SmimeEncryptOptions);
34
+ /**
35
+ * Encrypts an email message with S/MIME.
36
+ * @param email The email options to encrypt.
37
+ * @returns The encrypted email options.
38
+ * @throws {Error} When encryption fails (e.g., invalid certificate).
39
+ */
40
+ encrypt(email: EmailOptions): Promise<EmailOptions>;
41
+ /**
42
+ * Builds the email message string from email options.
43
+ * @param email The email options to build the message from.
44
+ * @returns The formatted email message as a string.
45
+ */
46
+ private buildMessage;
47
+ }
48
+ /**
49
+ * Creates a new S/MIME encrypter instance.
50
+ * @param options The S/MIME encryption options.
51
+ * @returns A new SmimeEncrypter instance ready to encrypt emails.
52
+ */
53
+ export declare const createSmimeEncrypter: (options: SmimeEncryptOptions) => SmimeEncrypter;
@@ -0,0 +1,48 @@
1
+ import type { EmailOptions } from "../types.d.ts";
2
+ import type { EmailSigner, SmimeSignOptions } from "./types.d.ts";
3
+ /**
4
+ * S/MIME signer implementation using PKIjs
5
+ * Note: Requires pkijs and asn1js for S/MIME operations
6
+ * Uses Node.js crypto for all cryptographic operations
7
+ */
8
+ export declare class SmimeSigner implements EmailSigner {
9
+ /**
10
+ * Formats an email address for use in email headers.
11
+ * @param address The email address object to format.
12
+ * @param address.email The email address string.
13
+ * @param address.name Optional display name for the email address.
14
+ * @returns The formatted email address string in RFC 5322 format.
15
+ */
16
+ private static formatAddress;
17
+ private readonly options;
18
+ /**
19
+ * Creates a new S/MIME signer.
20
+ * @param options S/MIME signing options.
21
+ */
22
+ constructor(options: SmimeSignOptions);
23
+ /**
24
+ * Signs an email message with S/MIME.
25
+ * @param email The email options to sign.
26
+ * @returns The email options with S/MIME signature.
27
+ * @throws {Error} When signing fails (e.g., invalid certificate/key).
28
+ */
29
+ sign(email: EmailOptions): Promise<EmailOptions>;
30
+ /**
31
+ * Builds the email message string from email options.
32
+ * @param email The email options to build the message from.
33
+ * @returns The formatted email message as a string.
34
+ */
35
+ private buildMessage;
36
+ /**
37
+ * Formats email addresses for use in email headers.
38
+ * @param addresses The email addresses to format (single or array).
39
+ * @returns The formatted email addresses string (comma-separated if multiple).
40
+ */
41
+ private formatAddresses;
42
+ }
43
+ /**
44
+ * Creates a new S/MIME signer instance.
45
+ * @param options The S/MIME signing options.
46
+ * @returns A new SmimeSigner instance ready to sign emails.
47
+ */
48
+ export declare const createSmimeSigner: (options: SmimeSignOptions) => SmimeSigner;
@@ -0,0 +1,101 @@
1
+ import type { EmailOptions } from "../types.d.ts";
2
+ /**
3
+ * Options for DKIM signing
4
+ */
5
+ export interface DkimOptions {
6
+ /**
7
+ * Body canonicalization algorithm ('simple' or 'relaxed')
8
+ * Default: 'simple'
9
+ */
10
+ bodyCanon?: "relaxed" | "simple";
11
+ /**
12
+ * Domain name used for DKIM signing
13
+ */
14
+ domainName: string;
15
+ /**
16
+ * Header canonicalization algorithm ('simple' or 'relaxed')
17
+ * Default: 'simple'
18
+ */
19
+ headerCanon?: "relaxed" | "simple";
20
+ /**
21
+ * List of header names to ignore when signing
22
+ */
23
+ headersToIgnore?: string[];
24
+ /**
25
+ * Key selector used for DNS lookup
26
+ */
27
+ keySelector: string;
28
+ /**
29
+ * Passphrase for the private key (if encrypted)
30
+ */
31
+ passphrase?: string;
32
+ /**
33
+ * Private key for signing (PEM format)
34
+ * Can be a string with the key content or a path prefixed with 'file://'
35
+ */
36
+ privateKey: string;
37
+ }
38
+ /**
39
+ * Options for S/MIME signing
40
+ */
41
+ export interface SmimeSignOptions {
42
+ /**
43
+ * Path to the certificate file (PEM format)
44
+ */
45
+ certificate: string;
46
+ /**
47
+ * Path to intermediate certificates (optional)
48
+ */
49
+ intermediateCerts?: string[];
50
+ /**
51
+ * Signing options flags
52
+ * Reserved for future use
53
+ */
54
+ options?: number;
55
+ /**
56
+ * Passphrase for the private key (if encrypted)
57
+ */
58
+ passphrase?: string;
59
+ /**
60
+ * Path to the private key file (PEM format)
61
+ */
62
+ privateKey: string;
63
+ }
64
+ /**
65
+ * Options for S/MIME encryption
66
+ */
67
+ export interface SmimeEncryptOptions {
68
+ /**
69
+ * Encryption algorithm (cipher)
70
+ * Supported: 'aes-256-cbc', 'aes-192-cbc', 'aes-128-cbc'
71
+ * Default: 'aes-256-cbc'
72
+ */
73
+ algorithm?: string;
74
+ /**
75
+ * Certificate(s) for encryption
76
+ * Can be a single certificate path or a map of email -> certificate path
77
+ */
78
+ certificates: string | Record<string, string>;
79
+ }
80
+ /**
81
+ * Interface for email signers
82
+ */
83
+ export interface EmailSigner {
84
+ /**
85
+ * Sign an email message
86
+ * @param email The email options to sign
87
+ * @returns The signed email options (may include additional headers or modified content)
88
+ */
89
+ sign: (email: EmailOptions) => Promise<EmailOptions>;
90
+ }
91
+ /**
92
+ * Interface for email encrypters
93
+ */
94
+ export interface EmailEncrypter {
95
+ /**
96
+ * Encrypt an email message
97
+ * @param email The email options to encrypt
98
+ * @returns The encrypted email options (content will be encrypted)
99
+ */
100
+ encrypt: (email: EmailOptions) => Promise<EmailOptions>;
101
+ }
@@ -0,0 +1,17 @@
1
+ import { VisulimaError } from "@visulima/error";
2
+ /**
3
+ * Base error class for email package operations.
4
+ * @param component The component name where the error occurred.
5
+ * @param message The error message describing what went wrong.
6
+ * @param options Optional error options including cause, code, and hint.
7
+ */
8
+ declare class EmailError extends VisulimaError {
9
+ readonly component: string;
10
+ readonly code?: string;
11
+ constructor(component: string, message: string, options?: {
12
+ cause?: Error | unknown;
13
+ code?: string;
14
+ hint?: string | string[];
15
+ });
16
+ }
17
+ export default EmailError;
@@ -0,0 +1,10 @@
1
+ import EmailError from "./email-error.d.ts";
2
+ /**
3
+ * Error for missing required options
4
+ * @param component The component name where the error occurred
5
+ * @param name The name(s) of the missing required option(s)
6
+ */
7
+ declare class RequiredOptionError extends EmailError {
8
+ constructor(component: string, name: string | string[]);
9
+ }
10
+ export default RequiredOptionError;
@@ -0,0 +1,22 @@
1
+ export { type AttachmentDataOptions, type AttachmentOptions, detectMimeType, generateContentId, readFileAsBuffer } from "./attachment-helpers.d.ts";
2
+ export { default as EmailError } from "./errors/email-error.d.ts";
3
+ export { default as RequiredOptionError } from "./errors/required-option-error.d.ts";
4
+ export { createMail, Mail, type Mailable, MailMessage } from "./mail.d.ts";
5
+ export type { Provider, ProviderFactory } from "./providers/provider.d.ts";
6
+ export { defineProvider } from "./providers/provider.d.ts";
7
+ export type { TemplateRenderer } from "./template-engines/types.d.ts";
8
+ export type { Attachment, BaseConfig, EmailAddress, EmailHeaders, EmailOptions, EmailResult, EmailTag, FeatureFlags, ImmutableHeaders, MaybePromise, Priority, Receipt, Result, } from "./types.d.ts";
9
+ export { default as buildMimeMessage } from "./utils/build-mime-message.d.ts";
10
+ export { default as comparePriority } from "./utils/compare-priority.d.ts";
11
+ export { default as createLogger } from "./utils/create-logger.d.ts";
12
+ export { default as formatEmailAddress } from "./utils/format-email-address.d.ts";
13
+ export { default as formatEmailAddresses } from "./utils/format-email-addresses.d.ts";
14
+ export { default as generateBoundary } from "./utils/generate-boundary.d.ts";
15
+ export { default as generateMessageId } from "./utils/generate-message-id.d.ts";
16
+ export { default as headersToRecord } from "./utils/headers-to-record.d.ts";
17
+ export { default as isPortAvailable } from "./utils/is-port-available.d.ts";
18
+ export { makeRequest, type RequestOptions } from "./utils/make-request.d.ts";
19
+ export { default as parseAddress } from "./utils/parse-address.d.ts";
20
+ export { default as retry } from "./utils/retry.d.ts";
21
+ export { default as validateEmail } from "./utils/validate-email.d.ts";
22
+ export { default as validateEmailOptions } from "./utils/validate-email-options.d.ts";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{detectMimeType as a,generateContentId as o,readFileAsBuffer as t}from"./packem_shared/detectMimeType-S8WRsNtY.js";import{default as d}from"./packem_shared/EmailError-zm2ffVav.js";import{default as m}from"./packem_shared/RequiredOptionError-CevW3u2K.js";import{Mail as p,MailMessage as i,createMail as u}from"./packem_shared/MailMessage-Hdgowmvi.js";import{defineProvider as n}from"./packem_shared/defineProvider-B9rSklAJ.js";import{default as M}from"./packem_shared/buildMimeMessage-BPtd0pno.js";import{default as c}from"./packem_shared/comparePriority-BfiwjVsV.js";import{default as v}from"./packem_shared/createLogger-DlElSVQP.js";import{default as P}from"./packem_shared/formatEmailAddress-CHeME3Vk.js";import{default as b}from"./packem_shared/formatEmailAddresses-UegVOe5A.js";import{default as B}from"./packem_shared/generateBoundary-CZ8kJuY6.js";import{default as O}from"./packem_shared/generateMessageId-11Ls5JsR.js";import{default as h}from"./packem_shared/headersToRecord-BKUTr40L.js";import{default as C}from"./packem_shared/isPortAvailable-5kfsfo8u.js";import{makeRequest as L}from"./packem_shared/makeRequest-DwxHX0xo.js";import{default as w}from"./packem_shared/parseAddress-CATTKGe_.js";import{default as D}from"./packem_shared/retry-D1MBqS49.js";import{default as H}from"./packem_shared/validateEmail-BkVdVioP.js";import{default as K}from"./packem_shared/validateEmailOptions-BzlJECG5.js";export{d as EmailError,p as Mail,i as MailMessage,m as RequiredOptionError,M as buildMimeMessage,c as comparePriority,v as createLogger,u as createMail,n as defineProvider,a as detectMimeType,P as formatEmailAddress,b as formatEmailAddresses,B as generateBoundary,o as generateContentId,O as generateMessageId,h as headersToRecord,C as isPortAvailable,L as makeRequest,w as parseAddress,t as readFileAsBuffer,D as retry,H as validateEmail,K as validateEmailOptions};