@visulima/email 1.0.0-alpha.42 → 1.0.0-alpha.44
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.
- package/CHANGELOG.md +42 -0
- package/README.md +10 -191
- package/dist/index.js +1 -1
- package/dist/packem_shared/DraftMailMessage-BxqGSLMN.js +1 -0
- package/dist/packem_shared/Mail-BEuzrB00.js +1 -0
- package/dist/packem_shared/MailMessage-D9k5gYrd.js +1 -0
- package/dist/packem_shared/ahaSendProvider-D81_wUA1.js +1 -0
- package/dist/packem_shared/{attachment-processor-BjTNoMyb.js → attachment-processor-CMp7qqMI.js} +1 -1
- package/dist/packem_shared/{azureProvider-DlM6UWUv.js → azureProvider-CmcK4bsf.js} +1 -1
- package/dist/packem_shared/brevoProvider-C1BDXr41.js +1 -0
- package/dist/packem_shared/{build-mime-message-Be6TOi1T.js → build-mime-message-B6927SQy.js} +2 -2
- package/dist/packem_shared/{cloudflareEmailProvider-D4adkOjA.js → cloudflareEmailProvider-Bv-ty-74.js} +1 -1
- package/dist/packem_shared/{createTestEmail-BM3iNznm.js → createTestEmail-CF_RUjqo.js} +1 -1
- package/dist/packem_shared/infobipProvider-lHyGrXgZ.js +1 -0
- package/dist/packem_shared/{loopsProvider-BXr0KSjB.js → loopsProvider-DyloxzNC.js} +1 -1
- package/dist/packem_shared/{mailCrabProvider-C7Ao5H9p.js → mailCrabProvider-CPtBT6Th.js} +1 -1
- package/dist/packem_shared/{mailPaceProvider-DklGeGEM.js → mailPaceProvider-CJEvOFBh.js} +1 -1
- package/dist/packem_shared/{mailchannelsProvider-DPfQVzUd.js → mailchannelsProvider-osRkW_tz.js} +1 -1
- package/dist/packem_shared/mailerSendProvider-C_6LzARK.js +1 -0
- package/dist/packem_shared/{mailgunProvider-Ctyrs9d0.js → mailgunProvider-DkISvMPe.js} +1 -1
- package/dist/packem_shared/mailjetProvider-CV0i4Xzh.js +1 -0
- package/dist/packem_shared/mailomatProvider-B5YFonEO.js +1 -0
- package/dist/packem_shared/mailtrapProvider-C4ZquIPz.js +1 -0
- package/dist/packem_shared/mandrillProvider-DWPFh_Sj.js +1 -0
- package/dist/packem_shared/{netcoreProvider-XMWO_Aoa.js → netcoreProvider-C5TEciaN.js} +1 -1
- package/dist/packem_shared/{outlook365Provider-BoNtxqIx.js → outlook365Provider-63ggDpqV.js} +1 -1
- package/dist/packem_shared/plunkProvider-yTlrJVEp.js +1 -0
- package/dist/packem_shared/postalProvider-CRX_bMYD.js +1 -0
- package/dist/packem_shared/{postmarkProvider-DWQJv5_M.js → postmarkProvider-CDx85Yge.js} +1 -1
- package/dist/packem_shared/{provider-base-gIoUu9so.js → provider-base-C7PuopYK.js} +1 -1
- package/dist/packem_shared/resendProvider-CiclWxzr.js +1 -0
- package/dist/packem_shared/scalewayProvider-BcND48qO.js +1 -0
- package/dist/packem_shared/{sendGridProvider-CChhLr7s.js → sendGridProvider-D8ZLgY62.js} +1 -1
- package/dist/packem_shared/{smtpProvider-x4WBN-3W.js → smtpProvider-Bm0yP97W.js} +1 -1
- package/dist/packem_shared/{sparkpostProvider-BytvwqjP.js → sparkpostProvider-CTYfSRaV.js} +1 -1
- package/dist/packem_shared/sweegoProvider-DOoin_vi.js +1 -0
- package/dist/packem_shared/{zeptomailProvider-D3nQKXRf.js → zeptomailProvider-DKBPSHPj.js} +1 -1
- package/dist/providers/ahasend/index.js +1 -1
- package/dist/providers/azure/index.js +1 -1
- package/dist/providers/brevo/index.js +1 -1
- package/dist/providers/cloudflare-email/index.js +1 -1
- package/dist/providers/infobip/index.js +1 -1
- package/dist/providers/loops/index.js +1 -1
- package/dist/providers/mailchannels/index.js +1 -1
- package/dist/providers/mailcrab/index.js +1 -1
- package/dist/providers/mailersend/index.js +1 -1
- package/dist/providers/mailgun/index.js +1 -1
- package/dist/providers/mailjet/index.js +1 -1
- package/dist/providers/mailomat/index.js +1 -1
- package/dist/providers/mailpace/index.js +1 -1
- package/dist/providers/mailtrap/index.js +1 -1
- package/dist/providers/mandrill/index.js +1 -1
- package/dist/providers/netcore/index.js +1 -1
- package/dist/providers/outlook365/index.js +1 -1
- package/dist/providers/plunk/index.js +1 -1
- package/dist/providers/postal/index.js +1 -1
- package/dist/providers/postmark/index.js +1 -1
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/scaleway/index.js +1 -1
- package/dist/providers/sendgrid/index.js +1 -1
- package/dist/providers/smtp/index.js +1 -1
- package/dist/providers/sparkpost/index.js +1 -1
- package/dist/providers/sweego/index.js +1 -1
- package/dist/providers/zeptomail/index.js +1 -1
- package/dist/test/index.d.ts +0 -4
- package/dist/test/index.js +1 -1
- package/dist/utils/parse-eml.js +2 -2
- package/package.json +5 -28
- package/dist/packem_shared/DraftMailMessage-C9tevR8K.js +0 -1
- package/dist/packem_shared/Mail-DpjH0Exh.js +0 -1
- package/dist/packem_shared/MailMessage-L-Q9yc5v.js +0 -1
- package/dist/packem_shared/ahaSendProvider-Dq5mElHZ.js +0 -1
- package/dist/packem_shared/brevoProvider-D_Hhc0Z-.js +0 -1
- package/dist/packem_shared/infobipProvider-oOL-ThpP.js +0 -1
- package/dist/packem_shared/mailerSendProvider-B8iT5Uhb.js +0 -1
- package/dist/packem_shared/mailjetProvider-v55nFDsr.js +0 -1
- package/dist/packem_shared/mailomatProvider-BCyB4Q4B.js +0 -1
- package/dist/packem_shared/mailtrapProvider-DcVw3sxR.js +0 -1
- package/dist/packem_shared/mandrillProvider-gqMFMwgs.js +0 -1
- package/dist/packem_shared/plunkProvider-C0LO-1E3.js +0 -1
- package/dist/packem_shared/postalProvider-B26IqgxE.js +0 -1
- package/dist/packem_shared/resendProvider-DhvKVyCD.js +0 -1
- package/dist/packem_shared/scalewayProvider-D8dmHuwZ.js +0 -1
- package/dist/packem_shared/sweegoProvider-7xhOvagC.js +0 -1
- package/dist/utils/validation/check-mx-records.d.ts +0 -43
- package/dist/utils/validation/check-mx-records.js +0 -1
- package/dist/utils/validation/disposable-email-domains.d.ts +0 -1
- package/dist/utils/validation/disposable-email-domains.js +0 -1
- package/dist/utils/validation/role-accounts.d.ts +0 -21
- package/dist/utils/validation/role-accounts.js +0 -1
- package/dist/utils/validation/verify-email.d.ts +0 -50
- package/dist/utils/validation/verify-email.js +0 -1
- package/dist/utils/validation/verify-smtp.d.ts +0 -40
- package/dist/utils/validation/verify-smtp.js +0 -4
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as P}from"node:module";import c from"./EmailError-B-sEf3bp.js";import S from"./RequiredOptionError-DuNNY_a5.js";import{e as _}from"./generate-message-id-gXAuMz4g.js";import{s as k}from"./headers-to-record-De1Eg951.js";import{m as y}from"./make-request-BlK_B72c.js";import{u as w}from"./retry-3pnxTuNs.js";import{f as z}from"./validate-email-options-mCM9dVug.js";import{defineProvider as q}from"./defineProvider-C9q-7iwt.js";import{P as B,h as T,c as K}from"./provider-base-gIoUu9so.js";import{f as g,a as h}from"./address-formatter-BWR2Dddx.js";const j=P(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=o=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[d,s]=p.versions.node.split(".").map(Number);if(d>22||d===22&&s>=3||d===20&&s>=16)return p.getBuiltinModule(o)}return j(o)},{Buffer:E}=C("node:buffer"),a="brevo",x="https://api.brevo.com/v3",D=3e4,G=3,W=q((o={})=>{if(!o.apiKey)throw new S(a,"apiKey");const d=o.endpoint??x,s={apiKey:o.apiKey,debug:o.debug??!1,endpoint:d,hardValidation:o.hardValidation??!1,retries:o.retries??G,timeout:o.timeout??D,...o.logger&&{logger:o.logger}},f=new B,n=K(a,o.logger);return{endpoint:s.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(a,"Email ID is required to retrieve email details"),success:!1};await f.ensureInitialized(()=>this.initialize(),a);const t={"api-key":s.apiKey,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const l=await w(async()=>y(`${s.endpoint}/smtp/emails/${e}`,{headers:t,method:"GET",timeout:s.timeout}),s.retries);return l.success?(n.debug("Email details retrieved successfully"),{data:l.data?.body,success:!0}):(n.debug("API request failed when retrieving email",l.error),{error:new c(a,`Failed to retrieve email: ${l.error instanceof Error?l.error.message:"Unknown error"}`,{cause:l.error}),success:!1})}catch(t){return{error:T(a,"retrieve email",t,n),success:!1}}},async initialize(){await f.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(a,"Brevo API not available or invalid API key");n.debug("Provider initialized successfully")},a)},async isAvailable(){try{const e={"api-key":s.apiKey,"Content-Type":"application/json"};n.debug("Checking Brevo API availability");const t=await y(`${s.endpoint}/account`,{headers:e,method:"GET",timeout:s.timeout});return n.debug("Brevo API availability check response:",{error:t.error instanceof Error?t.error.message:void 0,statusCode:t.data?.statusCode,success:t.success}),!!(t.success&&t.data&&typeof t.data=="object"&&"statusCode"in t.data&&typeof t.data.statusCode=="number"&&t.data.statusCode>=200&&t.data.statusCode<300)}catch(e){return n.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{let t;Array.isArray(e.replyTo)?t=e.replyTo.length>0?e.replyTo[0]:void 0:t=e.replyTo;const l={...e,replyTo:t},b=z(l);if(b.length>0)return{error:new c(a,`Invalid email options: ${b.join(", ")}`),success:!1};await f.ensureInitialized(()=>this.initialize(),a);const i={sender:h(e.from),subject:e.subject,to:g(e.to)};if(e.html&&(i.htmlContent=e.html),e.text&&(i.textContent=e.text),e.cc&&(i.cc=g(e.cc)),e.bcc&&(i.bcc=g(e.bcc)),e.replyTo)if(Array.isArray(e.replyTo)){if(s.hardValidation)return{error:new c(a,"Only one replyTo address is allowed"),success:!1};if(e.replyTo.length===0)return{error:new c(a,"replyTo array cannot be empty"),success:!1};const r=e.replyTo[0];if(!r)return{error:new c(a,"replyTo array cannot be empty"),success:!1};i.replyTo=h(r)}else i.replyTo=h(e.replyTo);if(e.templateId&&(i.templateId=e.templateId,e.templateParams&&(i.params=e.templateParams)),e.tags&&e.tags.length>0&&(i.tags=e.tags),e.scheduledAt){const r=typeof e.scheduledAt=="number"?new Date(e.scheduledAt*1e3).toISOString():e.scheduledAt;i.scheduledAt=r}if(e.batchId&&(i.batchId=e.batchId),e.headers){const r=k(e.headers);i.headers=r}e.attachments&&e.attachments.length>0&&(i.attachment=await Promise.all(e.attachments.map(async r=>{let m;if(r.content)if(typeof r.content=="string")m=r.content;else if(r.content instanceof Promise){const I=await r.content;m=E.from(I).toString("base64")}else m=r.content.toString("base64");else if(r.raw)m=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new c(a,`Attachment ${r.filename} has no content`);return{content:m,name:r.filename,...r.contentType&&{type:r.contentType}}}))),n.debug("Sending email via Brevo API",{subject:i.subject,to:i.to});const A={"api-key":s.apiKey,"Content-Type":"application/json"},u=await w(async()=>y(`${s.endpoint}/smtp/email`,{headers:A,method:"POST",timeout:s.timeout},JSON.stringify(i)),s.retries);if(!u.success)return n.debug("API request failed when sending email",u.error),{error:u.error??new c(a,"Failed to send email"),success:!1};const v=u.data?.body?.messageId??_();return n.debug("Email sent successfully",{messageId:v}),{data:{messageId:v,provider:a,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:T(a,"send email",t,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{W as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as A}from"node:module";import c from"./EmailError-B-sEf3bp.js";import _ from"./RequiredOptionError-DuNNY_a5.js";import{e as z}from"./generate-message-id-gXAuMz4g.js";import{s as E}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-BlK_B72c.js";import{u as b}from"./retry-3pnxTuNs.js";import{f as U}from"./validate-email-options-mCM9dVug.js";import{defineProvider as k}from"./defineProvider-C9q-7iwt.js";import{P as S,h as w,c as q}from"./provider-base-gIoUu9so.js";import{d as y}from"./address-formatter-BWR2Dddx.js";const T=A(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=a=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[l,p]=d.versions.node.split(".").map(Number);if(l>22||l===22&&p>=3||l===20&&p>=16)return d.getBuiltinModule(a)}return T(a)},{Buffer:j}=P("node:buffer"),i="infobip",K="https://api.infobip.com",R=3e4,C=3,L=k((a={})=>{if(!a.apiKey)throw new _(i,"apiKey");const l=a.baseUrl??K,p=a.endpoint??`${l}/email/3/send`,s={apiKey:a.apiKey,baseUrl:l,debug:a.debug??!1,endpoint:p,retries:a.retries??C,timeout:a.timeout??R,...a.logger&&{logger:a.logger}},f=new S,o=q(i,a.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!1,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(i,"Email ID is required to retrieve email details"),success:!1};await f.ensureInitialized(()=>this.initialize(),i);const n={Authorization:`App ${s.apiKey}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const t=await b(async()=>g(`${s.baseUrl}/email/3/reports/${e}`,{headers:n,method:"GET",timeout:s.timeout}),s.retries);return t.success?(o.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(o.debug("API request failed when retrieving email",t.error),{error:new c(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(n){return{error:w(i,"retrieve email",n,o),success:!1}}},async initialize(){await f.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(i,"Infobip API not available or invalid API key");o.debug("Provider initialized successfully")},i)},async isAvailable(){try{o.debug("Checking Infobip API availability");const e={Authorization:`App ${s.apiKey}`,"Content-Type":"application/json"};return(await g(`${s.baseUrl}/account/1/me`,{headers:e,method:"GET",timeout:s.timeout})).success}catch(e){return o.debug("Error checking availability:",e),!1}},name:i,options:s,async sendEmail(e){try{const n=U(e);if(n.length>0)return{error:new c(i,`Invalid email options: ${n.join(", ")}`),success:!1};await f.ensureInitialized(()=>this.initialize(),i);const t={from:typeof e.from=="string"?e.from:e.from.email,subject:e.subject,to:y(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=y(e.cc)),e.bcc&&(t.bcc=y(e.bcc)),e.replyTo&&(t.replyTo=typeof e.replyTo=="string"?e.replyTo:e.replyTo.email),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateData=e.templateVariables)),e.trackingUrl&&(t.trackingUrl=e.trackingUrl),e.notifyUrl&&(t.notifyUrl=e.notifyUrl),e.intermediateReport!==void 0&&(t.intermediateReport=e.intermediateReport),e.sendAt&&(t.sendAt=e.sendAt),e.headers){const r=E(e.headers);t.headers=r}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async r=>{let u;if(r.content)if(typeof r.content=="string")u=r.content;else if(r.content instanceof Promise){const I=await r.content;u=j.from(I).toString("base64")}else u=r.content.toString("base64");else if(r.raw)u=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new c(i,`Attachment ${r.filename} has no content`);return{content:u,contentType:r.contentType??"application/octet-stream",name:r.filename}}))),o.debug("Sending email via Infobip API",{subject:t.subject,to:t.to});const v={Authorization:`App ${s.apiKey}`,"Content-Type":"application/json"},m=await b(async()=>g(s.endpoint,{headers:v,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!m.success)return o.debug("API request failed when sending email",m.error),{error:m.error??new c(i,"Failed to send email"),success:!1};const h=m.data?.body?.messages?.[0]?.messageId??z();return o.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:i,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:w(i,"send email",n,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as w}from"node:module";import l from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as _}from"./generate-message-id-gXAuMz4g.js";import{s as k}from"./headers-to-record-De1Eg951.js";import{m as p}from"./make-request-BlK_B72c.js";import{u as h}from"./retry-3pnxTuNs.js";import{f as z}from"./validate-email-options-mCM9dVug.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";import{P as S,h as b,c as C}from"./provider-base-gIoUu9so.js";import{f,a as E}from"./address-formatter-BWR2Dddx.js";const T=w(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=o=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[i,c]=m.versions.node.split(".").map(Number);if(i>22||i===22&&c>=3||i===20&&c>=16)return m.getBuiltinModule(o)}return T(o)},{Buffer:I}=A("node:buffer"),s="mailersend",q="https://api.mailersend.com",M=3e4,B=3,U=j((o={})=>{if(!o.apiToken)throw new P(s,"apiToken");const i={apiToken:o.apiToken,debug:o.debug??!1,endpoint:o.endpoint??q,retries:o.retries??B,timeout:o.timeout??M,...o.logger&&{logger:o.logger}},c=new S,n=C(s,o.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new l(s,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const r={Authorization:`Bearer ${i.apiToken}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await h(async()=>p(`${i.endpoint}/v1/activity/${e}`,{headers:r,method:"GET",timeout:i.timeout}),i.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new l(s,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(r){return{error:b(s,"retrieve email",r,n),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(s,"MailerSend API not available or invalid API token");n.debug("Provider initialized successfully")},s)},async isAvailable(){try{const e={Authorization:`Bearer ${i.apiToken}`,"Content-Type":"application/json"};n.debug("Checking MailerSend API availability");const r=await p(`${i.endpoint}/v1/tokens/verify`,{headers:e,method:"GET",timeout:i.timeout});return n.debug("MailerSend API availability check response:",{error:r.error instanceof Error?r.error.message:void 0,statusCode:r.data?.statusCode,success:r.success}),!!(r.success&&r.data&&typeof r.data=="object"&&"statusCode"in r.data&&typeof r.data.statusCode=="number"&&r.data.statusCode>=200&&r.data.statusCode<300)}catch(e){return n.debug("Error checking availability:",e),!1}},name:s,options:i,async sendEmail(e){try{const r=z(e);if(r.length>0)return{error:new l(s,`Invalid email options: ${r.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:f(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=f(e.cc)),e.bcc&&(t.bcc=f(e.bcc)),e.replyTo&&(t.reply_to=E(e.replyTo)),e.templateId&&(t.template_id=e.templateId,e.templateVariables&&(t.variables=e.templateVariables)),e.personalization&&e.personalization.length>0&&(t.personalization=e.personalization),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.scheduledAt&&(t.send_at=e.scheduledAt),e.domainId&&(t.domain_id=e.domainId),e.headers){const a=k(e.headers);t.headers=a}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async a=>{let u;if(a.content)if(typeof a.content=="string")u=a.content;else if(a.content instanceof Promise){const v=await a.content;u=I.from(v).toString("base64")}else u=a.content.toString("base64");else if(a.raw)u=typeof a.raw=="string"?a.raw:a.raw.toString("base64");else throw new l(s,`Attachment ${a.filename} has no content`);return{content:u,filename:a.filename,...a.contentType&&{type:a.contentType},...a.cid&&{id:a.cid}}}))),n.debug("Sending email via MailerSend API",{subject:t.subject,to:t.to});const y={Authorization:`Bearer ${i.apiToken}`,"Content-Type":"application/json"},d=await h(async()=>p(`${i.endpoint}/v1/email`,{headers:y,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!d.success)return n.debug("API request failed when sending email",d.error),{error:d.error??new l(s,"Failed to send email"),success:!1};const g=d.data?.body?.message_id??_();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:s,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:b(s,"send email",r,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as I}from"node:module";import d from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as E}from"./generate-message-id-gXAuMz4g.js";import{s as M}from"./headers-to-record-De1Eg951.js";import{m as f}from"./make-request-BlK_B72c.js";import{u as v}from"./retry-3pnxTuNs.js";import{f as _}from"./validate-email-options-mCM9dVug.js";import{defineProvider as z}from"./defineProvider-C9q-7iwt.js";import{P as D,h as w,c as B}from"./provider-base-gIoUu9so.js";import{h as y,i as T}from"./address-formatter-BWR2Dddx.js";const P=I(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=n=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[a,l]=m.versions.node.split(".").map(Number);if(a>22||a===22&&l>=3||a===20&&l>=16)return m.getBuiltinModule(n)}return P(n)},{Buffer:p}=A("node:buffer"),s="mailjet",R="https://api.mailjet.com",k=3e4,q=3,Q=z((n={})=>{if(!n.apiKey)throw new b(s,"apiKey");if(!n.apiSecret)throw new b(s,"apiSecret");const a={apiKey:n.apiKey,apiSecret:n.apiSecret,debug:n.debug??!1,endpoint:n.endpoint??R,retries:n.retries??q,timeout:n.timeout??k,...n.logger&&{logger:n.logger}},l=new D,o=B(s,n.logger);return{endpoint:a.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new d(s,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),s);const i={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const t=await v(async()=>f(`${a.endpoint}/v3.1/REST/message/${e}`,{headers:i,method:"GET",timeout:a.timeout}),a.retries);return t.success?(o.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(o.debug("API request failed when retrieving email",t.error),{error:new d(s,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(i){return{error:w(s,"retrieve email",i,o),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(s,"Mailjet API not available or invalid API credentials");o.debug("Provider initialized successfully")},s)},async isAvailable(){try{const e={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Checking Mailjet API availability");const i=await f(`${a.endpoint}/v3.1/REST/user`,{headers:e,method:"GET",timeout:a.timeout});return o.debug("Mailjet API availability check response:",{error:i.error instanceof Error?i.error.message:void 0,statusCode:i.data?.statusCode,success:i.success}),!!(i.success&&i.data&&typeof i.data=="object"&&"statusCode"in i.data&&typeof i.data.statusCode=="number"&&i.data.statusCode>=200&&i.data.statusCode<300)}catch(e){return o.debug("Error checking availability:",e),!1}},name:s,options:a,async sendEmail(e){try{const i=_(e);if(i.length>0)return{error:new d(s,`Invalid email options: ${i.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),s);const t={From:T(e.from),Subject:e.subject,To:y(e.to)};if(e.html&&(t.HTMLPart=e.html),e.text&&(t.TextPart=e.text),e.cc&&(t.Cc=y(e.cc)),e.bcc&&(t.Bcc=y(e.bcc)),e.replyTo&&(t.ReplyTo=T(e.replyTo)),e.templateId&&(t.TemplateID=e.templateId,t.TemplateLanguage=e.templateLanguage??!0,e.templateVariables&&(t.Variables=e.templateVariables)),e.customId&&(t.CustomID=e.customId),e.eventPayload&&(t.EventPayload=e.eventPayload),e.campaign&&(t.Campaign=e.campaign),e.deduplicateCampaign!==void 0&&(t.DeduplicateCampaign=e.deduplicateCampaign),e.deliveryTime&&(t.Deliverytime=new Date(e.deliveryTime*1e3).toISOString()),e.priority!==void 0&&(t.Priority=e.priority),e.urlTags&&(t.URLTags=e.urlTags),e.tags&&e.tags.length>0&&(t.CustomCampaign=e.tags.join(",")),e.headers){const r=M(e.headers),c=[];for(const[g,C]of Object.entries(r))c.push({Name:g,Value:String(C)});c.length>0&&(t.Headers=c)}e.attachments&&e.attachments.length>0&&(t.Attachments=await Promise.all(e.attachments.map(async r=>{let c;if(r.content)if(typeof r.content=="string")c=r.content;else if(r.content instanceof Promise){const g=await r.content;c=p.from(g).toString("base64")}else c=r.content.toString("base64");else if(r.raw)c=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new d(s,`Attachment ${r.filename} has no content`);return{Base64Content:c,ContentType:r.contentType??"application/octet-stream",Filename:r.filename,...r.cid&&{ContentID:r.cid}}})));const S={Messages:[t]};o.debug("Sending email via Mailjet API",{subject:t.Subject,to:t.To});const j={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"},u=await v(async()=>f(`${a.endpoint}/v3.1/send`,{headers:j,method:"POST",timeout:a.timeout},JSON.stringify(S)),a.retries);if(!u.success)return o.debug("API request failed when sending email",u.error),{error:u.error??new d(s,"Failed to send email"),success:!1};const h=u.data?.body?.Messages?.[0]?.To?.[0]?.MessageID?.toString()??E();return o.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:s,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(i){return{error:w(s,"send email",i,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as I}from"node:module";import c from"./EmailError-B-sEf3bp.js";import T from"./RequiredOptionError-DuNNY_a5.js";import{e as _}from"./generate-message-id-gXAuMz4g.js";import{s as S}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-BlK_B72c.js";import{u as y}from"./retry-3pnxTuNs.js";import{f as E}from"./validate-email-options-mCM9dVug.js";import{defineProvider as K}from"./defineProvider-C9q-7iwt.js";import{P as k,h as b,c as q}from"./provider-base-gIoUu9so.js";import{f,a as z}from"./address-formatter-BWR2Dddx.js";const P=I(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=s=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[i,l]=u.versions.node.split(".").map(Number);if(i>22||i===22&&l>=3||i===20&&l>=16)return u.getBuiltinModule(s)}return P(s)},{Buffer:j}=A("node:buffer"),a="mailomat",C="https://api.mailomat.com",M=3e4,x=3,L=K((s={})=>{if(!s.apiKey)throw new T(a,"apiKey");const i={apiKey:s.apiKey,debug:s.debug??!1,endpoint:s.endpoint??C,retries:s.retries??x,timeout:s.timeout??M,...s.logger&&{logger:s.logger}},l=new k,n=q(a,s.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(a,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),a);const o={"Content-Type":"application/json","X-API-Key":i.apiKey};n.debug("Retrieving email details",{id:e});const t=await y(async()=>h(`${i.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:i.timeout}),i.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new c(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:b(a,"retrieve email",o,n),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(a,"Mailomat API not available or invalid API key");n.debug("Provider initialized successfully")},a)},async isAvailable(){try{return n.debug("Checking Mailomat API availability"),!0}catch(e){return n.debug("Error checking availability:",e),!1}},name:a,options:i,async sendEmail(e){try{const o=E(e);if(o.length>0)return{error:new c(a,`Invalid email options: ${o.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),a);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:f(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=f(e.cc)),e.bcc&&(t.bcc=f(e.bcc)),e.replyTo&&(t.replyTo=z(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const r=S(e.headers);t.headers=r}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async r=>{let d;if(r.content)if(typeof r.content=="string")d=r.content;else if(r.content instanceof Promise){const v=await r.content;d=j.from(v).toString("base64")}else d=r.content.toString("base64");else if(r.raw)d=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new c(a,`Attachment ${r.filename} has no content`);return{content:d,contentType:r.contentType??"application/octet-stream",filename:r.filename,...r.cid&&{cid:r.cid}}}))),n.debug("Sending email via Mailomat API",{subject:t.subject,to:t.to});const w={"Content-Type":"application/json","X-API-Key":i.apiKey},m=await y(async()=>h(`${i.endpoint}/send`,{headers:w,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!m.success)return n.debug("API request failed when sending email",m.error),{error:m.error??new c(a,"Failed to send email"),success:!1};const p=m.data?.body,g=p?.messageId??p?.id??_();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:b(a,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as w}from"node:module";import l from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as A}from"./generate-message-id-gXAuMz4g.js";import{s as I}from"./headers-to-record-De1Eg951.js";import{m as p}from"./make-request-BlK_B72c.js";import{u as b}from"./retry-3pnxTuNs.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{P as E,h,c as S}from"./provider-base-gIoUu9so.js";import{f,a as q}from"./address-formatter-BWR2Dddx.js";const T=w(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=o=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[s,c]=m.versions.node.split(".").map(Number);if(s>22||s===22&&c>=3||s===20&&c>=16)return m.getBuiltinModule(o)}return T(o)},{Buffer:k}=_("node:buffer"),i="mailtrap",z="https://send.api.mailtrap.io",M=3e4,x=3,L=C((o={})=>{if(!o.apiToken)throw new P(i,"apiToken");const s={apiToken:o.apiToken,debug:o.debug??!1,endpoint:o.endpoint??z,retries:o.retries??x,timeout:o.timeout??M,...o.logger&&{logger:o.logger}},c=new E,n=S(i,o.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new l(i,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const r={"Api-Token":s.apiToken,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await b(async()=>p(`${s.endpoint}/api/send/${e}`,{headers:r,method:"GET",timeout:s.timeout}),s.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new l(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(r){return{error:h(i,"retrieve email",r,n),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(i,"Mailtrap API not available or invalid API token");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={"Api-Token":s.apiToken,"Content-Type":"application/json"};n.debug("Checking Mailtrap API availability");const r=await p(`${s.endpoint}/api/account`,{headers:e,method:"GET",timeout:s.timeout});return n.debug("Mailtrap API availability check response:",{error:r.error instanceof Error?r.error.message:void 0,statusCode:r.data?.statusCode,success:r.success}),!!(r.success&&r.data&&typeof r.data=="object"&&"statusCode"in r.data&&typeof r.data.statusCode=="number"&&r.data.statusCode>=200&&r.data.statusCode<300)}catch(e){return n.debug("Error checking availability:",e),!1}},name:i,options:s,async sendEmail(e){try{const r=j(e);if(r.length>0)return{error:new l(i,`Invalid email options: ${r.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:f(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=f(e.cc)),e.bcc&&(t.bcc=f(e.bcc)),e.replyTo&&(t.reply_to=q(e.replyTo)),e.templateUuid&&(t.template_uuid=e.templateUuid,e.templateVariables&&(t.template_variables=e.templateVariables)),e.category&&(t.category=e.category),e.customVariables&&(t.custom_variables=e.customVariables),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const a=I(e.headers);t.headers=a}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async a=>{let u;if(a.content)if(typeof a.content=="string")u=a.content;else if(a.content instanceof Promise){const v=await a.content;u=k.from(v).toString("base64")}else u=a.content.toString("base64");else if(a.raw)u=typeof a.raw=="string"?a.raw:a.raw.toString("base64");else throw new l(i,`Attachment ${a.filename} has no content`);return{content:u,filename:a.filename,type:a.contentType??"application/octet-stream",...a.cid&&{cid:a.cid}}}))),n.debug("Sending email via Mailtrap API",{subject:t.subject,to:t.to});const y={"Api-Token":s.apiToken,"Content-Type":"application/json"},d=await b(async()=>p(`${s.endpoint}/api/send`,{headers:y,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!d.success)return n.debug("API request failed when sending email",d.error),{error:d.error??new l(i,"Failed to send email"),success:!1};const g=d.data?.body?.message_ids?.[0]??A();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:i,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:h(i,"send email",r,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as P}from"node:module";import d from"./EmailError-B-sEf3bp.js";import I from"./RequiredOptionError-DuNNY_a5.js";import{e as S}from"./generate-message-id-gXAuMz4g.js";import{s as k}from"./headers-to-record-De1Eg951.js";import{m as f}from"./make-request-BlK_B72c.js";import{u as h}from"./retry-3pnxTuNs.js";import{s as v,a as z}from"./sanitize-header-DJhgZl3y.js";import{f as E}from"./validate-email-options-mCM9dVug.js";import{defineProvider as M}from"./defineProvider-C9q-7iwt.js";import{P as q,h as w,c as K}from"./provider-base-gIoUu9so.js";import{k as y}from"./address-formatter-BWR2Dddx.js";const A=P(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=i=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[r,m]=g.versions.node.split(".").map(Number);if(r>22||r===22&&m>=3||r===20&&m>=16)return g.getBuiltinModule(i)}return A(i)},{Buffer:C}=T("node:buffer"),s="mandrill",N="https://mandrillapp.com/api/1.0",O=3e4,V=3,X=M((i={})=>{if(!i.apiKey)throw new I(s,"apiKey");const r={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??N,retries:i.retries??V,timeout:i.timeout??O,...i.logger&&{logger:i.logger}},m=new q,o=K(s,i.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new d(s,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),s),o.debug("Retrieving email details",{id:e});const l={id:e,key:r.apiKey},t={"Content-Type":"application/json"},n=await h(async()=>f(`${r.endpoint}/messages/info.json`,{headers:t,method:"POST",timeout:r.timeout},JSON.stringify(l)),r.retries);return n.success?(o.debug("Email details retrieved successfully"),{data:n.data?.body,success:!0}):(o.debug("API request failed when retrieving email",n.error),{error:new d(s,`Failed to retrieve email: ${n.error instanceof Error?n.error.message:"Unknown error"}`,{cause:n.error}),success:!1})}catch(l){return{error:w(s,"retrieve email",l,o),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(s,"Mandrill API not available or invalid API key");o.debug("Provider initialized successfully")},s)},async isAvailable(){try{o.debug("Checking Mandrill API availability");const e={key:r.apiKey},l={"Content-Type":"application/json"},t=await f(`${r.endpoint}/users/info.json`,{headers:l,method:"POST",timeout:r.timeout},JSON.stringify(e));return o.debug("Mandrill API availability check response:",{error:t.error instanceof Error?t.error.message:void 0,statusCode:t.data?.statusCode,success:t.success}),!!(t.success&&t.data&&typeof t.data=="object"&&"statusCode"in t.data&&typeof t.data.statusCode=="number"&&t.data.statusCode>=200&&t.data.statusCode<300)}catch(e){return o.debug("Error checking availability:",e),!1}},name:s,options:r,async sendEmail(e){try{const l=E(e);if(l.length>0)return{error:new d(s,`Invalid email options: ${l.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),s);const t={from_email:e.from.email,html:e.html??"",subject:e.subject,text:e.text??"",...e.from.name&&{from_name:e.from.name},to:y(e.to,"to")};if(e.cc){const a=y(e.cc,"cc");for(const c of a)c.type="cc";t.to=[...t.to,...a]}if(e.bcc){const a=y(e.bcc,"bcc");for(const c of a)c.type="bcc";t.to=[...t.to,...a]}if(e.replyTo){const a=e.replyTo.name?`${v(e.replyTo.name)} <${e.replyTo.email}>`:e.replyTo.email;t.headers={"Reply-To":a}}if(e.headers){const a=k(e.headers),c={};Object.entries(a).forEach(([p,j])=>{c[z(p)]=v(j)}),t.headers={...t.headers,...c}}e.tags&&e.tags.length>0&&(t.tags=e.tags),e.metadata&&(t.metadata=e.metadata),(e.googleAnalyticsDomains||e.googleAnalyticsCampaign)&&(t.google_analytics_domains=e.googleAnalyticsDomains,t.google_analytics_campaign=e.googleAnalyticsCampaign),e.subaccount&&(t.subaccount=e.subaccount),e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async a=>{let c;if(a.content)if(typeof a.content=="string")c=a.content;else if(a.content instanceof Promise){const p=await a.content;c=C.from(p).toString("base64")}else c=a.content.toString("base64");else if(a.raw)c=typeof a.raw=="string"?a.raw:a.raw.toString("base64");else throw new d(s,`Attachment ${a.filename} has no content`);return{content:c,name:a.filename,type:a.contentType??"application/octet-stream"}})));const n={key:r.apiKey,message:t};e.templateName&&(n.template_name=e.templateName,e.templateContent&&(n.template_content=e.templateContent),e.templateVariables&&(n.template_vars=e.templateVariables)),e.globalMergeVars&&(t.global_merge_vars=e.globalMergeVars),e.mergeVars&&(t.merge_vars=e.mergeVars),e.sendAt&&(n.send_at=e.sendAt),o.debug("Sending email via Mandrill API",{subject:t.subject,to:t.to});const _={"Content-Type":"application/json"},u=await h(async()=>f(`${r.endpoint}/messages/send.json`,{headers:_,method:"POST",timeout:r.timeout},JSON.stringify(n)),r.retries);if(!u.success)return o.debug("API request failed when sending email",u.error),{error:u.error??new d(s,"Failed to send email"),success:!1};const b=u.data?.body?.[0]?.id??S();return o.debug("Email sent successfully",{messageId:b}),{data:{messageId:b,provider:s,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(l){return{error:w(s,"send email",l,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import d from"./EmailError-B-sEf3bp.js";import k from"./RequiredOptionError-DuNNY_a5.js";import{e as b}from"./generate-message-id-gXAuMz4g.js";import{s as z}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-BlK_B72c.js";import{u as w}from"./retry-3pnxTuNs.js";import{a as E,s as K}from"./sanitize-header-DJhgZl3y.js";import{f as S}from"./validate-email-options-mCM9dVug.js";import{defineProvider as q}from"./defineProvider-C9q-7iwt.js";import{P as x,h as v,c as B}from"./provider-base-gIoUu9so.js";const A=_(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=s=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[a,m]=f.versions.node.split(".").map(Number);if(a>22||a===22&&m>=3||a===20&&m>=16)return f.getBuiltinModule(s)}return A(s)},{Buffer:T}=j("node:buffer"),i="plunk",C="https://api.useplunk.com/v1",R=3e4,D=3,W=q((s={})=>{if(!s.apiKey)throw new k(i,"apiKey");const a={apiKey:s.apiKey,debug:s.debug??!1,endpoint:s.endpoint??C,logger:s.logger,retries:s.retries??D,timeout:s.timeout??R},m=new x,n=B(i,s.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new d(i,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),i);const c={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const l=await w(async()=>h(`${a.endpoint}/emails/${e}`,{headers:c,method:"GET",timeout:a.timeout}),a.retries);return l.success?(n.debug("Email details retrieved successfully"),{data:l.data?.body,success:!0}):(n.debug("API request failed when retrieving email",l.error),{error:new d(i,`Failed to retrieve email: ${l.error instanceof Error?l.error.message:"Unknown error"}`,{cause:l.error}),success:!1})}catch(c){return{error:v(i,"retrieve email",c,n),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(i,"Plunk API not available or invalid API key");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{return a.apiKey&&a.apiKey.length>0?(n.debug("API key exists, assuming Plunk is available"),!0):!1}catch(e){return n.debug("Error checking availability:",e),!1}},name:i,options:a,async sendEmail(e){try{const c=S(e);if(c.length>0)return{error:new d(i,`Invalid email options: ${c.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),i);const l=t=>Array.isArray(t)?t.map(o=>o.email):[t.email],r={to:e.subscriber??(Array.isArray(e.to)?e.to[0]?.email:e.to.email)};if(e.from&&(r.from=e.from.email,e.from.name&&(r.from_name=e.from.name)),e.subject&&(r.subject=e.subject),e.html?r.body=e.html:e.text&&(r.body=e.text),e.html&&e.text&&(r.text=e.text),e.cc&&(r.cc=l(e.cc)),e.bcc&&(r.bcc=l(e.bcc)),e.replyTo&&(r.reply_to=e.replyTo.email,e.replyTo.name&&(r.reply_to_name=e.replyTo.name)),e.templateId&&(r.template=e.templateId),e.data&&(r.data=e.data),e.subscriberId&&(r.subscriber_id=e.subscriberId),e.headers){const t=z(e.headers),o={};Object.entries(t).forEach(([y,I])=>{o[E(y)]=K(I)}),r.headers=o}e.attachments&&e.attachments.length>0&&(r.attachments=await Promise.all(e.attachments.map(async t=>{let o;if(t.content)if(typeof t.content=="string")o=t.content;else if(t.content instanceof Promise){const y=await t.content;o=T.from(y).toString("base64")}else o=t.content.toString("base64");else if(t.raw)o=typeof t.raw=="string"?t.raw:t.raw.toString("base64");else throw new d(i,`Attachment ${t.filename} has no content`);return{content:o,filename:t.filename,type:t.contentType??"application/octet-stream"}}))),n.debug("Sending email via Plunk API",{subject:r.subject,to:r.to});const P={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},u=await w(async()=>h(`${a.endpoint}/send`,{headers:P,method:"POST",timeout:a.timeout},JSON.stringify(r)),a.retries);if(!u.success)return n.debug("API request failed when sending email",u.error),{error:u.error??new d(i,"Failed to send email"),success:!1};const p=u.data,g=p?.body&&typeof p.body=="object"?p.body.id??p.body.messageId??b():b();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:i,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(c){return{error:v(i,"send email",c,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{W as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import c from"./EmailError-B-sEf3bp.js";import y from"./RequiredOptionError-DuNNY_a5.js";import{e as S}from"./generate-message-id-gXAuMz4g.js";import{s as T}from"./headers-to-record-De1Eg951.js";import{m as f}from"./make-request-BlK_B72c.js";import{u as b}from"./retry-3pnxTuNs.js";import{f as E}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{P as K,c as k}from"./provider-base-gIoUu9so.js";import{l as g,m as v}from"./address-formatter-BWR2Dddx.js";const I=_(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=i=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[l,n]=m.versions.node.split(".").map(Number);if(l>22||l===22&&n>=3||l===20&&n>=16)return m.getBuiltinModule(i)}return I(i)},{Buffer:j}=A("node:buffer"),r="postal",q=3e4,z=3,H=C((i={})=>{if(!i.host)throw new y(r,"host");if(!i.apiKey)throw new y(r,"apiKey");const l=i.endpoint??`https://${i.host}/api/v1`,n={apiKey:i.apiKey,debug:i.debug??!1,endpoint:l,host:i.host,retries:i.retries??z,timeout:i.timeout??q,...i.logger&&{logger:i.logger}},p=new K,o=k(r,i.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await p.ensureInitialized(()=>this.initialize(),r);const t={"Content-Type":"application/json","X-Server-API-Key":n.apiKey};o.debug("Retrieving email details",{id:e});const a=await b(async()=>f(`${n.endpoint}/messages/${e}`,{headers:t,method:"GET",timeout:n.timeout}),n.retries);return a.success?(o.debug("Email details retrieved successfully"),{data:a.data?.body,success:!0}):(o.debug("API request failed when retrieving email",a.error),{error:new c(r,`Failed to retrieve email: ${a.error instanceof Error?a.error.message:"Unknown error"}`,{cause:a.error}),success:!1})}catch(t){return o.debug("Exception retrieving email",t),{error:new c(r,`Failed to retrieve email: ${t.message}`,{cause:t}),success:!1}}},async initialize(){await p.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Postal API not available or invalid API key");o.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={"Content-Type":"application/json","X-Server-API-Key":n.apiKey};o.debug("Checking Postal API availability");const t=await f(`${n.endpoint}/server`,{headers:e,method:"GET",timeout:n.timeout});return o.debug("Postal API availability check response:",{error:t.error instanceof Error?t.error.message:void 0,statusCode:t.data?.statusCode,success:t.success}),!!(t.success&&t.data&&typeof t.data=="object"&&"statusCode"in t.data&&typeof t.data.statusCode=="number"&&t.data.statusCode>=200&&t.data.statusCode<300)}catch(e){return o.debug("Error checking availability:",e),!1}},name:r,options:n,async sendEmail(e){try{const t=E(e);if(t.length>0)return{error:new c(r,`Invalid email options: ${t.join(", ")}`),success:!1};await p.ensureInitialized(()=>this.initialize(),r);const a={from:v(e.from).address,subject:e.subject,to:g(e.to).map(s=>s.address)};if(e.html&&(a.html_body=e.html),e.text&&(a.plain_body=e.text),e.cc&&(a.cc=g(e.cc).map(s=>s.address)),e.bcc&&(a.bcc=g(e.bcc).map(s=>s.address)),e.replyTo&&(a.reply_to=v(e.replyTo).address),e.templateId&&(a.template_id=e.templateId,e.templateVariables&&(a.template_variables=e.templateVariables)),e.tags&&e.tags.length>0&&(a.tag=e.tags.join(",")),e.headers){const s=T(e.headers);a.headers=s}e.attachments&&e.attachments.length>0&&(a.attachments=await Promise.all(e.attachments.map(async s=>{let u;if(s.content)if(typeof s.content=="string")u=s.content;else if(s.content instanceof Promise){const P=await s.content;u=j.from(P).toString("base64")}else u=s.content.toString("base64");else if(s.raw)u=typeof s.raw=="string"?s.raw:s.raw.toString("base64");else throw new c(r,`Attachment ${s.filename} has no content`);return{content_type:s.contentType??"application/octet-stream",data:u,name:s.filename}}))),o.debug("Sending email via Postal API",{subject:a.subject,to:a.to});const w={"Content-Type":"application/json","X-Server-API-Key":n.apiKey},d=await b(async()=>f(`${n.endpoint}/send/message`,{headers:w,method:"POST",timeout:n.timeout},JSON.stringify(a)),n.retries);if(!d.success)return o.debug("API request failed when sending email",d.error),{error:d.error??new c(r,"Failed to send email"),success:!1};const h=d.data?.body?.message_id?.toString()??S();return o.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:r,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return o.debug("Exception sending email",t),{error:new c(r,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import c from"./EmailError-B-sEf3bp.js";import A from"./RequiredOptionError-DuNNY_a5.js";import{e as I}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m as f}from"./make-request-BlK_B72c.js";import{u as h}from"./retry-3pnxTuNs.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as E}from"./defineProvider-C9q-7iwt.js";import{P as C,h as y,c as S}from"./provider-base-gIoUu9so.js";import{e as T,g as b,d as v}from"./address-formatter-BWR2Dddx.js";const n="resend",z="https://api.resend.com",k=3e4,K=3,R=i=>{const a=[],l=/^[\w-]+$/;return l.test(i.name)||a.push(`Tag name '${i.name}' must only contain ASCII letters, numbers, underscores, or dashes`),i.name.length>256&&a.push(`Tag name '${i.name}' exceeds maximum length of 256 characters`),l.test(i.value)||a.push(`Tag value '${i.value}' for tag '${i.name}' must only contain ASCII letters, numbers, underscores, or dashes`),a},L=E((i={})=>{if(!i.apiKey)throw new A(n,"apiKey");const a={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??z,logger:i.logger,retries:i.retries??K,timeout:i.timeout??k},l=new C,o=S(n,i.logger);return{endpoint:a.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(n,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),n);const t={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const s=await h(async()=>f(`${a.endpoint}/emails/${e}`,{headers:t,method:"GET",timeout:a.timeout}),a.retries);return s.success?(o.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(o.debug("API request failed when retrieving email",s.error),{error:new c(n,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(t){return{error:y(n,"retrieve email",t,o),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(n,"Resend API not available or invalid API key");o.debug("Provider initialized successfully")},n)},async isAvailable(){try{if(a.apiKey&&a.apiKey.startsWith("re_"))return o.debug("API key format is valid, assuming Resend is available"),!0;const e={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};o.debug("Checking Resend API availability");const t=await f(`${a.endpoint}/domains`,{headers:e,method:"GET",timeout:a.timeout});return t.data&&typeof t.data=="object"&&"body"in t.data&&t.data.body&&typeof t.data.body=="object"&&"name"in t.data.body&&t.data.body.name==="restricted_api_key"?(o.debug("API key is valid but restricted to only sending emails"),!0):(o.debug("Resend API availability check response:",{error:t.error instanceof Error?t.error.message:void 0,statusCode:t.data?.statusCode,success:t.success}),!!(t.success&&t.data&&typeof t.data=="object"&&"statusCode"in t.data&&typeof t.data.statusCode=="number"&&t.data.statusCode>=200&&t.data.statusCode<300))}catch(e){return o.debug("Error checking availability:",e),!1}},name:n,options:a,async sendEmail(e){try{const t=j(e);if(t.length>0)return{error:new c(n,`Invalid email options: ${t.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),n);const s={from:b(e.from),headers:e.headers?P(e.headers):{},html:e.html,subject:e.subject,text:e.text,to:T(e.to)};if(e.cc&&(s.cc=v(e.cc)),e.bcc&&(s.bcc=v(e.bcc)),e.replyTo&&(s.reply_to=b(e.replyTo)),e.templateId&&(s.template=e.templateId,e.templateData&&(s.data=e.templateData)),e.scheduledAt&&(s.scheduled_at=typeof e.scheduledAt=="string"?e.scheduledAt:e.scheduledAt.toISOString()),e.tags&&e.tags.length>0){const r=[];if(e.tags.forEach(d=>{const p=R(d);p.length>0&&r.push(...p)}),r.length>0)return{error:new c(n,`Invalid email tags: ${r.join(", ")}`),success:!1};s.tags=e.tags.map(d=>({name:d.name,value:d.value}))}e.attachments&&e.attachments.length>0&&(s.attachments=await Promise.all(e.attachments.map(async r=>{let d;if(r.content)if(typeof r.content=="string")d=r.content;else if(r.content instanceof Promise){const p=await r.content;d=Buffer.from(p).toString("base64")}else d=r.content.toString("base64");else if(r.raw)d=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new c(n,`Attachment ${r.filename} has no content`);return{content:d,content_type:r.contentType,filename:r.filename,...r.path&&{path:r.path}}}))),o.debug("Sending email via Resend API",{subject:s.subject,to:s.to});const w={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},u=await h(async()=>f(`${a.endpoint}/emails`,{headers:w,method:"POST",timeout:a.timeout},JSON.stringify(s)),a.retries);if(!u.success)return o.debug("API request failed when sending email",u.error),{error:u.error??new c(n,"Failed to send email"),success:!1};const m=u.data,g=m?.body&&typeof m.body=="object"&&m.body.id?m.body.id:I();return o.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:n,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:y(n,"send email",t,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as j}from"node:module";import l from"./EmailError-B-sEf3bp.js";import h from"./RequiredOptionError-DuNNY_a5.js";import{e as S}from"./generate-message-id-gXAuMz4g.js";import{s as _}from"./headers-to-record-De1Eg951.js";import{m as y}from"./make-request-BlK_B72c.js";import{u as b}from"./retry-3pnxTuNs.js";import{f as E}from"./validate-email-options-mCM9dVug.js";import{defineProvider as k}from"./defineProvider-C9q-7iwt.js";import{P as z,h as w,c as q}from"./provider-base-gIoUu9so.js";import{f as p,a as K}from"./address-formatter-BWR2Dddx.js";const P=j(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=i=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[c,s]=u.versions.node.split(".").map(Number);if(c>22||c===22&&s>=3||c===20&&s>=16)return u.getBuiltinModule(i)}return P(i)},{Buffer:T}=A("node:buffer"),r="scaleway",C="https://api.scaleway.com/transactional-email/v1alpha1",x=3e4,R=3,L=k((i={})=>{if(!i.apiKey)throw new h(r,"apiKey");if(!i.region)throw new h(r,"region");const c=i.endpoint??C,s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:c,region:i.region,retries:i.retries??R,timeout:i.timeout??x,...i.logger&&{logger:i.logger}},f=new z,n=q(r,i.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new l(r,"Email ID is required to retrieve email details"),success:!1};await f.ensureInitialized(()=>this.initialize(),r);const o={"Content-Type":"application/json","X-Auth-Token":s.apiKey};n.debug("Retrieving email details",{id:e});const t=await b(async()=>y(`${s.endpoint}/regions/${s.region}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new l(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:w(r,"retrieve email",o,n),success:!1}}},async initialize(){await f.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(r,"Scaleway API not available or invalid API key");n.debug("Provider initialized successfully")},r)},async isAvailable(){try{return n.debug("Checking Scaleway API availability"),!0}catch(e){return n.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const o=E(e);if(o.length>0)return{error:new l(r,`Invalid email options: ${o.join(", ")}`),success:!1};await f.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,...e.from.name&&{name:e.from.name}},subject:e.subject,to:p(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=p(e.cc)),e.bcc&&(t.bcc=p(e.bcc)),e.replyTo&&(t.replyTo=K(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.projectId&&(t.projectId=e.projectId),e.headers){const a=_(e.headers);t.headers=a}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async a=>{let d;if(a.content)if(typeof a.content=="string")d=a.content;else if(a.content instanceof Promise){const I=await a.content;d=T.from(I).toString("base64")}else d=a.content.toString("base64");else if(a.raw)d=typeof a.raw=="string"?a.raw:a.raw.toString("base64");else throw new l(r,`Attachment ${a.filename} has no content`);return{content:d,name:a.filename,type:a.contentType??"application/octet-stream"}}))),n.debug("Sending email via Scaleway API",{subject:t.subject,to:t.to});const v={"Content-Type":"application/json","X-Auth-Token":s.apiKey},m=await b(async()=>y(`${s.endpoint}/regions/${s.region}/emails`,{headers:v,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!m.success)return n.debug("API request failed when sending email",m.error),{error:m.error??new l(r,"Failed to send email"),success:!1};const g=m.data?.body?.id??S();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:r,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:w(r,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as I}from"node:module";import l from"./EmailError-B-sEf3bp.js";import S from"./RequiredOptionError-DuNNY_a5.js";import{e as T}from"./generate-message-id-gXAuMz4g.js";import{s as _}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-BlK_B72c.js";import{u as y}from"./retry-3pnxTuNs.js";import{f as z}from"./validate-email-options-mCM9dVug.js";import{defineProvider as E}from"./defineProvider-C9q-7iwt.js";import{P as k,h as b,c as q}from"./provider-base-gIoUu9so.js";import{f,a as K}from"./address-formatter-BWR2Dddx.js";const P=I(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=s=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[a,c]=u.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return u.getBuiltinModule(s)}return P(s)},{Buffer:j}=A("node:buffer"),i="sweego",B="https://api.sweego.com",x=3e4,C=3,U=E((s={})=>{if(!s.apiKey)throw new S(i,"apiKey");const a={apiKey:s.apiKey,debug:s.debug??!1,endpoint:s.endpoint??B,retries:s.retries??C,timeout:s.timeout??x,...s.logger&&{logger:s.logger}},c=new k,n=q(i,s.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new l(i,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const o={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await y(async()=>h(`${a.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:a.timeout}),a.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new l(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:b(i,"retrieve email",o,n),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(i,"Sweego API not available or invalid API key");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{return n.debug("Checking Sweego API availability"),!0}catch(e){return n.debug("Error checking availability:",e),!1}},name:i,options:a,async sendEmail(e){try{const o=z(e);if(o.length>0)return{error:new l(i,`Invalid email options: ${o.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:f(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=f(e.cc)),e.bcc&&(t.bcc=f(e.bcc)),e.replyTo&&(t.replyTo=K(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const r=_(e.headers);t.headers=r}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async r=>{let d;if(r.content)if(typeof r.content=="string")d=r.content;else if(r.content instanceof Promise){const v=await r.content;d=j.from(v).toString("base64")}else d=r.content.toString("base64");else if(r.raw)d=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new l(i,`Attachment ${r.filename} has no content`);return{content:d,contentType:r.contentType??"application/octet-stream",filename:r.filename,...r.cid&&{cid:r.cid}}}))),n.debug("Sending email via Sweego API",{subject:t.subject,to:t.to});const w={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},m=await y(async()=>h(`${a.endpoint}/send`,{headers:w,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!m.success)return n.debug("API request failed when sending email",m.error),{error:m.error??new l(i,"Failed to send email"),success:!1};const g=m.data?.body,p=g?.messageId??g?.id??T();return n.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:i,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:b(i,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Cache } from "../cache.js";
|
|
2
|
-
export type { InMemoryCache } from "../cache.js";
|
|
3
|
-
/**
|
|
4
|
-
* MX record information.
|
|
5
|
-
*/
|
|
6
|
-
interface MxRecord {
|
|
7
|
-
exchange: string;
|
|
8
|
-
priority: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Result of MX record check.
|
|
12
|
-
*/
|
|
13
|
-
interface MxCheckResult {
|
|
14
|
-
error?: string;
|
|
15
|
-
records?: MxRecord[];
|
|
16
|
-
valid: boolean;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Options for MX record checking.
|
|
20
|
-
*/
|
|
21
|
-
interface MxCheckOptions {
|
|
22
|
-
cache?: Cache<MxCheckResult>;
|
|
23
|
-
ttl?: number;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Checks MX records for a domain.
|
|
27
|
-
* @param domain The domain to check MX records for.
|
|
28
|
-
* @param options Options for MX record checking, including caching.
|
|
29
|
-
* @returns Result containing MX records or error.
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* import { checkMxRecords } from "@visulima/email/validation/check-mx-records";
|
|
33
|
-
* import { InMemoryCache } from "@visulima/email/utils/cache";
|
|
34
|
-
*
|
|
35
|
-
* const cache = new InMemoryCache();
|
|
36
|
-
* const result = await checkMxRecords("example.com", { cache });
|
|
37
|
-
* if (result.valid) {
|
|
38
|
-
* console.log("MX records:", result.records);
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
declare const checkMxRecords: (domain: string, options?: MxCheckOptions) => Promise<MxCheckResult>;
|
|
43
|
-
export { type Cache, MxCheckOptions, MxCheckResult, MxRecord, checkMxRecords };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as a}from"node:module";const d=a(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=o=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[e,s]=c.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return c.getBuiltinModule(o)}return d(o)},{resolveMx:p}=l("node:dns/promises"),h=async(o,e={})=>{const s=e.ttl??36e5;if(e.cache){const r=await e.cache.get(o);if(r!==void 0)return r}try{const r=(await p(o)).map(i=>({exchange:i.exchange,priority:i.priority})),t={records:r.toSorted((i,n)=>i.priority-n.priority),valid:r.length>0};return e.cache&&await e.cache.set(o,t,s),t}catch(r){const t={error:r instanceof Error?r.message:String(r),valid:!1};return e.cache&&await e.cache.set(o,t,s),t}};export{h as checkMxRecords};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@visulima/disposable-email-domains';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from"@visulima/disposable-email-domains";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common role account prefixes that indicate non-personal email addresses.
|
|
3
|
-
* Includes RFC 2142 standard role accounts and common business/operational prefixes.
|
|
4
|
-
*/
|
|
5
|
-
declare const ROLE_ACCOUNT_PREFIXES: Set<string>;
|
|
6
|
-
/**
|
|
7
|
-
* Checks if an email address is a role account (non-personal).
|
|
8
|
-
* @param email The email address to check.
|
|
9
|
-
* @param customPrefixes Optional set of additional role account prefixes.
|
|
10
|
-
* @returns True if the email is a role account, false otherwise.
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { isRoleAccount } from "@visulima/email/validation/role-accounts";
|
|
14
|
-
*
|
|
15
|
-
* if (isRoleAccount("noreply@example.com")) {
|
|
16
|
-
* console.log("This is a role account");
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
declare const isRoleAccount: (email: string, customPrefixes?: Set<string>) => boolean;
|
|
21
|
-
export { ROLE_ACCOUNT_PREFIXES, isRoleAccount };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const c=new Set(["abuse","accounts","admin","adminhelp","administrator","adminoffice","adminteam","affiliates","alarms","alert","alternative","analytics","anonymous","archive","audit","automated","autoreply","backoffice","backup","batch","billing","board","bot","bounce","bug","bugreport","build","careers","cert","chapter","chatbot","ci","compliance","contact","continuousintegration","cron","csirt","customer-care","customercare","customerservice","customersupport","cvs","daemon","default","demo","deploy","deployment","dev","development","devops","digest","director","dnsadmin","docs","donotreply","enquiry","errors","events","executive","faculty","failover","feed","feedback","finance","forensics","ftp","git","guardian","guest","help","helpdesk","helpsec","hostmaster","hr","incident","incidents","indexer","info","ingest","inquiry","issues","it","jobs","legal","list","list-request","log","logistics","logs","maildaemon","mailer-daemon","malicious","management","manager","marketing","media","membership","metrics","mod","moderator","mods","monitor","network","news","newsletter","no-reply","noc","noreply","notifications","notify","operations","operator","owner","owners","parent","partners","patches","payments","phish","phishing","pipeline","post","postmaster","pr","press","privacy","procurement","qa","recruitment","redundancy","registrar","releases","reminder","reminders","reply","report","reports","request","resource","root","sales","scheduler","secondary","secops","secretariat","secretary","security","server","service","spam","spamreport","staff","standby","student","subscribe","subscriptions","summaries","supervisor","supplychain","support","supportteam","svn","sync","sysadmin","system","system-alert","system-msg","team","tech","techsupport","temp","tertiary","test","threat","threats","tracker","trial","unknown","unsubscribe","update","updates","usenet","usergroup","uucp","volunteer","vuln","vulnerability","webinars","webmaster","www"]),o=(e,r)=>c.has(e)||(r?.has(e)??!1),u=(e,r)=>{if(e.length<2)return!1;const t=["-",".","_"];for(const s of t){const n=`${e[0]}${s}${e[1]}`;if(o(n,r))return!0}return!1},p=(e,r)=>{for(const t of e)if(!o(t,r))return!1;return!0},l=(e,r)=>{if(!e||typeof e!="string")return!1;const t=e.toLowerCase().trim(),s=t.indexOf("@");if(s===-1||s===0)return!1;const n=t.slice(0,s);if(o(n,r))return!0;const a=n.split(/[+._-]/);if(a.length===1){const i=a[0];return i===void 0?!1:o(i,r)}return u(a,r)?!0:p(a,r)};export{c as ROLE_ACCOUNT_PREFIXES,l as isRoleAccount};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { SmtpVerificationOptions } from "./verify-smtp.js";
|
|
2
|
-
import "../cache.js";
|
|
3
|
-
import "./check-mx-records.js";
|
|
4
|
-
/**
|
|
5
|
-
* Options for comprehensive email verification.
|
|
6
|
-
*/
|
|
7
|
-
interface EmailVerificationOptions extends SmtpVerificationOptions {
|
|
8
|
-
checkDisposable?: boolean;
|
|
9
|
-
checkMx?: boolean;
|
|
10
|
-
checkRoleAccount?: boolean;
|
|
11
|
-
checkSmtp?: boolean;
|
|
12
|
-
customDisposableDomains?: Set<string>;
|
|
13
|
-
customRolePrefixes?: Set<string>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Result of comprehensive email verification.
|
|
17
|
-
*/
|
|
18
|
-
interface EmailVerificationResult {
|
|
19
|
-
disposable?: boolean;
|
|
20
|
-
errors: string[];
|
|
21
|
-
formatValid: boolean;
|
|
22
|
-
mxValid?: boolean;
|
|
23
|
-
roleAccount?: boolean;
|
|
24
|
-
smtpValid?: boolean;
|
|
25
|
-
valid: boolean;
|
|
26
|
-
warnings: string[];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Comprehensive email verification combining multiple checks.
|
|
30
|
-
* @param email The email address to verify.
|
|
31
|
-
* @param options Verification options.
|
|
32
|
-
* @returns Detailed verification result.
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* import { verifyEmail } from "@visulima/email/validation/verify-email";
|
|
36
|
-
*
|
|
37
|
-
* const result = await verifyEmail("user@example.com", {
|
|
38
|
-
* checkDisposable: true,
|
|
39
|
-
* checkRoleAccount: true,
|
|
40
|
-
* checkMx: true,
|
|
41
|
-
* checkSmtp: false
|
|
42
|
-
* });
|
|
43
|
-
*
|
|
44
|
-
* if (result.valid) {
|
|
45
|
-
* console.log("Email is valid!");
|
|
46
|
-
* }
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
declare const verifyEmail: (email: string, options?: EmailVerificationOptions) => Promise<EmailVerificationResult>;
|
|
50
|
-
export { EmailVerificationOptions, EmailVerificationResult, verifyEmail };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{checkMxRecords as x}from"./check-mx-records.js";import{isRoleAccount as g}from"./role-accounts.js";import k from"./validate-email.js";import{verifySmtp as w}from"./verify-smtp.js";import{isDisposableEmail as y}from"@visulima/disposable-email-domains";const S=async(r,s={})=>{const{checkDisposable:f=!0,checkMx:p=!0,checkRoleAccount:d=!0,checkSmtp:u=!1,customDisposableDomains:h,customRolePrefixes:v,...b}=s,c=k(r),a=[],e=[];if(!c)return a.push("Invalid email format"),{errors:a,formatValid:!1,valid:!1,warnings:e};let o,l,m,n;if(f)try{o=y(r,h),o&&e.push("Email is from a disposable email service")}catch{}if(d&&(l=g(r,v),l&&e.push("Email appears to be a role account (non-personal)")),p){const i=r.split("@")[1];if(!i)return a.push("Invalid email format: missing domain"),{disposable:o,errors:a,formatValid:!1,mxValid:!1,roleAccount:l,valid:!1,warnings:e};const t=await x(i,{cache:s.cache});m=t.valid,t.valid||a.push(t.error??"No valid MX records found")}if(u){const i=await w(r,{...b,cache:s.cache,smtpCache:s.smtpCache});n=i.valid,!i.valid&&i.error&&a.push(`SMTP verification failed: ${i.error}`)}const V=c&&a.length===0;return{disposable:o,errors:a,formatValid:c,mxValid:m,roleAccount:l,smtpValid:n,valid:V,warnings:e}};export{S as verifyEmail};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Cache } from "../cache.js";
|
|
2
|
-
import { MxCheckResult, MxRecord } from "./check-mx-records.js";
|
|
3
|
-
/**
|
|
4
|
-
* Options for SMTP verification.
|
|
5
|
-
*/
|
|
6
|
-
interface SmtpVerificationOptions {
|
|
7
|
-
cache?: Cache<MxCheckResult>;
|
|
8
|
-
fromEmail?: string;
|
|
9
|
-
port?: number;
|
|
10
|
-
smtpCache?: Cache<SmtpVerificationResult>;
|
|
11
|
-
timeout?: number;
|
|
12
|
-
ttl?: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Detailed result of SMTP verification attempt.
|
|
16
|
-
*/
|
|
17
|
-
interface SmtpVerificationResult {
|
|
18
|
-
error?: string;
|
|
19
|
-
mxRecords?: MxRecord[];
|
|
20
|
-
smtpResponse?: string;
|
|
21
|
-
valid: boolean;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Verifies an email address by checking MX records and attempting SMTP verification.
|
|
25
|
-
* Note: Many mail servers block SMTP verification to prevent email harvesting.
|
|
26
|
-
* @param email The email address to verify.
|
|
27
|
-
* @param options Verification options.
|
|
28
|
-
* @returns Result containing verification status.
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* import { verifySmtp } from "@visulima/email/validation/verify-smtp";
|
|
32
|
-
*
|
|
33
|
-
* const result = await verifySmtp("user@example.com", {
|
|
34
|
-
* timeout: 5000,
|
|
35
|
-
* fromEmail: "test@example.com"
|
|
36
|
-
* });
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare const verifySmtp: (email: string, options?: SmtpVerificationOptions) => Promise<SmtpVerificationResult>;
|
|
40
|
-
export { SmtpVerificationOptions, SmtpVerificationResult, verifySmtp };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{createRequire as T}from"node:module";import{checkMxRecords as S}from"./check-mx-records.js";const $=T(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=c=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[o,d]=p.versions.node.split(".").map(Number);if(o>22||o===22&&d>=3||o===20&&d>=16)return p.getBuiltinModule(c)}return $(c)},{Socket:j}=b("node:net"),O=async(c,o={})=>{const{fromEmail:d="test@example.com",port:g=25,timeout:w=5e3,ttl:R=36e5}=o;if(!c||typeof c!="string")return{error:"Invalid email address",valid:!1};const l=c.toLowerCase().trim(),h=l.indexOf("@");if(h===-1||h===l.length-1)return{error:"Invalid email format",valid:!1};const{smtpCache:n}=o,v=`smtp:${l}:${d}:${g}`;if(n){const i=await n.get(v);if(i!==void 0)return i}const x=l.slice(h+1),M=o.cache,e=await S(x,{cache:M});if(!e.valid||!e.records||e.records.length===0){const i={error:e.error??"No MX records found",mxRecords:e.records,valid:!1};return n&&await n.set(v,i,R),i}const _=e.records[0];return new Promise(i=>{const r=new j;let u="",t="connected";const m=()=>{r.removeAllListeners(),r.destroy()},f=a=>{n&&n.set(v,a,R).catch(()=>{}),i(a)},W=a=>{m(),f({error:a.message,mxRecords:e.records,valid:!1})},y=()=>{m(),f({error:"SMTP connection timeout",mxRecords:e.records,valid:!1})};r.setTimeout(w),r.on("error",W),r.on("timeout",y),r.on("data",a=>{u+=a.toString();const s=u.slice(-3);t==="connected"&&(s.startsWith("220")||s.startsWith("250"))?(t="helo",r.write(`HELO ${x}\r
|
|
2
|
-
`)):t==="helo"&&s.startsWith("250")?(t="mail-from",r.write(`MAIL FROM:<${d}>\r
|
|
3
|
-
`)):t==="mail-from"&&s.startsWith("250")?(t="rcpt-to",r.write(`RCPT TO:<${l}>\r
|
|
4
|
-
`)):t==="rcpt-to"&&s.startsWith("250")?(m(),f({mxRecords:e.records,smtpResponse:u,valid:!0})):t==="rcpt-to"&&(s.startsWith("550")||s.startsWith("551")||s.startsWith("553"))&&(m(),f({error:"Email address does not exist",mxRecords:e.records,smtpResponse:u,valid:!1}))}),_?r.connect(g,_.exchange):(m(),f({error:"No MX record available",mxRecords:e.records,valid:!1}))})};export{O as verifySmtp};
|