@visulima/email 1.0.0-alpha.34 → 1.0.0-alpha.35
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 +19 -0
- package/README.md +77 -0
- package/dist/crypto/index.d.ts +160 -3
- package/dist/crypto/index.js +1 -1
- package/dist/deliverability/dmarc-report.d.ts +95 -0
- package/dist/deliverability/dmarc-report.js +1 -0
- package/dist/deliverability/index.d.ts +360 -0
- package/dist/deliverability/index.js +1 -0
- package/dist/events/index.d.ts +31 -0
- package/dist/events/index.js +1 -0
- package/dist/inbound/index.d.ts +375 -0
- package/dist/inbound/index.js +1 -0
- package/dist/index.d.ts +11 -734
- package/dist/index.js +1 -1
- package/dist/middleware/index.d.ts +346 -0
- package/dist/middleware/index.js +1 -0
- package/dist/packem_shared/ALL_EVENTS-A0nTVOo0.js +1 -0
- package/dist/packem_shared/DkimSigner-dKZ45Csc.js +18 -0
- package/dist/packem_shared/Mail-B2QII2P9.js +1 -0
- package/dist/packem_shared/{MailMessage-BvaH5tZZ.js → MailMessage-DB1zaWfM.js} +1 -1
- package/dist/packem_shared/MemoryEventStore-BEKPxa-I.js +1 -0
- package/dist/packem_shared/MemoryQueue-C-CtRRG7.js +1 -0
- package/dist/packem_shared/MemorySuppressionStore-BKY1FrA1.js +1 -0
- package/dist/packem_shared/RATE_LIMIT_PRESETS-DQF78mdO.js +1 -0
- package/dist/packem_shared/{SmimeEncrypter-ZhHEgDwY.js → SmimeEncrypter-BirIsrip.js} +2 -2
- package/dist/packem_shared/{SmimeSigner-CYSVF6ez.js → SmimeSigner-CkyaShTs.js} +2 -2
- package/dist/packem_shared/addDarkModeSupport-Ys9U2-GH.js +1 -0
- package/dist/packem_shared/address-formatter-CnPg51_n.js +1 -0
- package/dist/packem_shared/ahaSendProvider-yuqYMW0n.js +1 -0
- package/dist/packem_shared/arcMessageSignatureBase-Cpdnv-H8.js +17 -0
- package/dist/packem_shared/attachment-processor-CFUC3V45.js +1 -0
- package/dist/packem_shared/azureProvider-CK_Wuw4r.js +1 -0
- package/dist/packem_shared/brevoProvider-CNwuzzBA.js +1 -0
- package/dist/packem_shared/build-mime-message-D8WEZejb.js +3 -0
- package/dist/packem_shared/buildListUnsubscribe-CIbz0rtk.js +1 -0
- package/dist/packem_shared/circuitBreakerMiddleware-B7DlzZSG.js +1 -0
- package/dist/packem_shared/cloudflareEmailProvider-C-G821Hg.js +1 -0
- package/dist/packem_shared/composeMiddleware-CkEhbDjL.js +1 -0
- package/dist/packem_shared/createTestEmail-hHdtgmUM.js +1 -0
- package/dist/packem_shared/createWorker-Nkc1GHet.js +1 -0
- package/dist/packem_shared/dedupeMiddleware-JeJbff46.js +1 -0
- package/dist/packem_shared/{detectMimeType-bo5oxfnt.js → detectMimeType-B4QMh7k8.js} +1 -1
- package/dist/packem_shared/emailMatchers-CLANeU71.js +1 -0
- package/dist/packem_shared/event-bus.d-DEl3w_EW.d.ts +104 -0
- package/dist/packem_shared/extractReply-CCWnNRWe.js +5 -0
- package/dist/packem_shared/filterSuppressed-DntqRV0q.js +1 -0
- package/dist/packem_shared/format-address-Cv6uWTS5.js +1 -0
- package/dist/packem_shared/infobipProvider-DdV62IAG.js +1 -0
- package/dist/packem_shared/injectPreheader-BxPjb0eJ.js +1 -0
- package/dist/packem_shared/inlineCss-BLaEi337.js +1 -0
- package/dist/packem_shared/isValidSigningCertUrl-CF_KuCAi.js +3 -0
- package/dist/packem_shared/loggingMiddleware-CyHzn37U.js +1 -0
- package/dist/packem_shared/loopsProvider-DSedSU3q.js +1 -0
- package/dist/packem_shared/mail.d-LmrdSngG.d.ts +861 -0
- package/dist/packem_shared/{mailCrabProvider-B7H6HwWu.js → mailCrabProvider-xSLhA1CY.js} +1 -1
- package/dist/packem_shared/mailPaceProvider-CWBIjvvJ.js +1 -0
- package/dist/packem_shared/mailchannelsProvider-zKcunGDQ.js +1 -0
- package/dist/packem_shared/mailerSendProvider-BEvPlBKB.js +1 -0
- package/dist/packem_shared/mailgunProvider-CfQAINTC.js +1 -0
- package/dist/packem_shared/mailjetProvider-DEfKptWc.js +1 -0
- package/dist/packem_shared/mailomatProvider-D5sHlxZh.js +1 -0
- package/dist/packem_shared/mailtrapProvider-DwgMKakk.js +1 -0
- package/dist/packem_shared/mandrillProvider-CdGjO3Td.js +1 -0
- package/dist/packem_shared/normalizeMessageId-B_9mXlh4.js +1 -0
- package/dist/packem_shared/oauth2Middleware-B1xz58iP.js +1 -0
- package/dist/packem_shared/parseAddress-CrYOac3K.js +1 -0
- package/dist/packem_shared/parseArfReport-CUHb8WVj.js +6 -0
- package/dist/packem_shared/parseCloudflareInbound-BGgH5u7M.js +1 -0
- package/dist/packem_shared/parseDmarcRecord-DjNqCMZc.js +1 -0
- package/dist/packem_shared/parseInbound-BP-gEjhh.js +1 -0
- package/dist/packem_shared/parseMailgunInbound-C3sZ1TiH.js +1 -0
- package/dist/packem_shared/parseMtaStsPolicy-rFOOVXXK.js +6 -0
- package/dist/packem_shared/parsePostmarkInbound-C0Ttfroo.js +1 -0
- package/dist/packem_shared/parseSendGridInbound-BkvaoYRl.js +4 -0
- package/dist/packem_shared/parseSesInbound-BFS--T8X.js +1 -0
- package/dist/packem_shared/parseTlsRptRecord-DnLwAWsk.js +1 -0
- package/dist/packem_shared/plunkProvider-BIhMU2b5.js +1 -0
- package/dist/packem_shared/postProcessHtml-C73e0b9H.js +1 -0
- package/dist/packem_shared/postalProvider-CmmbCZSi.js +1 -0
- package/dist/packem_shared/postmarkProvider-i9u0h26U.js +1 -0
- package/dist/packem_shared/provider-base-BpHE_uK8.js +1 -0
- package/dist/packem_shared/{provider.d-DcfYeGJJ.d.ts → provider.d-J-y6iogK.d.ts} +1 -1
- package/dist/packem_shared/{readFile-BAVMZg5e-C4whBIPd.js → readFile-BkNfutxp-BS8Q2183.js} +1 -1
- package/dist/packem_shared/resendProvider-BNduBn0w.js +1 -0
- package/dist/packem_shared/retry-UPd8F62N.js +1 -0
- package/dist/packem_shared/retryMiddleware-DHespsU2.js +1 -0
- package/dist/packem_shared/rewriteCidLinks-B-Sd5XHs.js +1 -0
- package/dist/packem_shared/scalewayProvider-8gb4sIOB.js +1 -0
- package/dist/packem_shared/sendGridProvider-CayLXvPO.js +1 -0
- package/dist/packem_shared/smtpProvider-DoXVsN4p.js +24 -0
- package/dist/packem_shared/sweegoProvider-C0g9Ajdn.js +1 -0
- package/dist/packem_shared/toEmailSnapshot-CYpMmnAA.js +1 -0
- package/dist/packem_shared/tracer.d-MU42G1jG.d.ts +494 -0
- package/dist/packem_shared/{types.d-CNnnk-Ya.d.ts → types.d-BId55FW2.d.ts} +6 -1
- package/dist/packem_shared/types.d-BMpI2UXj.d.ts +51 -0
- package/dist/packem_shared/types.d-CmoWvdZi.d.ts +61 -0
- package/dist/packem_shared/types.d-Mpu0HZoG.d.ts +24 -0
- package/dist/packem_shared/{types.d-wwpgA3to.d.ts → types.d-ejzh-xBP.d.ts} +6 -1
- package/dist/packem_shared/types.d-lcJZmwRK.d.ts +69 -0
- package/dist/packem_shared/utils-BwolsGlK.js +1 -0
- package/dist/packem_shared/verifyMailgunWebhook-Df7n2Quh.js +1 -0
- package/dist/packem_shared/verifyPostmarkWebhook-D_eXt_Lq.js +1 -0
- package/dist/packem_shared/verifySendGridWebhook-XOSj5yTe.js +1 -0
- package/dist/packem_shared/verifyStandardWebhook-DdUTlIVh.js +1 -0
- package/dist/packem_shared/withEvents-Q9bwpCFG.js +1 -0
- package/dist/packem_shared/withMetrics-BPs3Kdxn.js +1 -0
- package/dist/packem_shared/withRender-DQM2zbbI.js +1 -0
- package/dist/packem_shared/withSuppression-DfjV_tbI.js +1 -0
- package/dist/packem_shared/withTelemetry-CsQsv1DV.js +1 -0
- package/dist/packem_shared/zeptomailProvider-BIbHieGJ.js +1 -0
- package/dist/providers/ahasend/index.d.ts +3 -3
- package/dist/providers/ahasend/index.js +1 -1
- package/dist/providers/aws-ses/index.d.ts +3 -3
- package/dist/providers/azure/index.d.ts +3 -3
- package/dist/providers/azure/index.js +1 -1
- package/dist/providers/brevo/index.d.ts +3 -3
- package/dist/providers/brevo/index.js +1 -1
- package/dist/providers/cloudflare-email/index.d.ts +36 -0
- package/dist/providers/cloudflare-email/index.js +1 -0
- package/dist/providers/failover/index.d.ts +3 -3
- package/dist/providers/http/index.d.ts +3 -3
- package/dist/providers/infobip/index.d.ts +3 -3
- package/dist/providers/infobip/index.js +1 -1
- package/dist/providers/loops/index.d.ts +47 -0
- package/dist/providers/loops/index.js +1 -0
- package/dist/providers/mailchannels/index.d.ts +26 -0
- package/dist/providers/mailchannels/index.js +1 -0
- package/dist/providers/mailcrab/index.d.ts +3 -3
- package/dist/providers/mailcrab/index.js +1 -1
- package/dist/providers/mailersend/index.d.ts +3 -3
- package/dist/providers/mailersend/index.js +1 -1
- package/dist/providers/mailgun/index.d.ts +3 -3
- package/dist/providers/mailgun/index.js +1 -1
- package/dist/providers/mailjet/index.d.ts +3 -3
- package/dist/providers/mailjet/index.js +1 -1
- package/dist/providers/mailomat/index.d.ts +3 -3
- package/dist/providers/mailomat/index.js +1 -1
- package/dist/providers/mailpace/index.d.ts +3 -3
- package/dist/providers/mailpace/index.js +1 -1
- package/dist/providers/mailtrap/index.d.ts +3 -3
- package/dist/providers/mailtrap/index.js +1 -1
- package/dist/providers/mandrill/index.d.ts +3 -3
- package/dist/providers/mandrill/index.js +1 -1
- package/dist/providers/mock/index.d.ts +6 -53
- package/dist/providers/nodemailer/index.d.ts +3 -3
- package/dist/providers/opentelemetry/index.d.ts +3 -495
- package/dist/providers/plunk/index.d.ts +3 -3
- package/dist/providers/plunk/index.js +1 -1
- package/dist/providers/postal/index.d.ts +3 -3
- package/dist/providers/postal/index.js +1 -1
- package/dist/providers/postmark/index.d.ts +3 -3
- package/dist/providers/postmark/index.js +1 -1
- package/dist/providers/resend/index.d.ts +3 -3
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/roundrobin/index.d.ts +3 -3
- package/dist/providers/scaleway/index.d.ts +3 -3
- package/dist/providers/scaleway/index.js +1 -1
- package/dist/providers/sendgrid/index.d.ts +3 -3
- package/dist/providers/sendgrid/index.js +1 -1
- package/dist/providers/smtp/index.d.ts +3 -3
- package/dist/providers/smtp/index.js +1 -1
- package/dist/providers/sweego/index.d.ts +3 -3
- package/dist/providers/sweego/index.js +1 -1
- package/dist/providers/zeptomail/index.d.ts +3 -3
- package/dist/providers/zeptomail/index.js +1 -1
- package/dist/queue/bullmq-queue.d.ts +46 -0
- package/dist/queue/bullmq-queue.js +1 -0
- package/dist/queue/index.d.ts +148 -0
- package/dist/queue/index.js +1 -0
- package/dist/queue/pg-boss-queue.d.ts +41 -0
- package/dist/queue/pg-boss-queue.js +1 -0
- package/dist/queue/sqs-queue.d.ts +72 -0
- package/dist/queue/sqs-queue.js +1 -0
- package/dist/queue/unstorage-queue.d.ts +81 -0
- package/dist/queue/unstorage-queue.js +1 -0
- package/dist/render/index.d.ts +107 -0
- package/dist/render/index.js +1 -0
- package/dist/template-engines/i18n.d.ts +61 -0
- package/dist/template-engines/i18n.js +1 -0
- package/dist/template-engines/jsx-email.d.ts +11 -0
- package/dist/template-engines/jsx-email.js +1 -0
- package/dist/template-engines/liquid.d.ts +12 -0
- package/dist/template-engines/liquid.js +1 -0
- package/dist/test/index.d.ts +159 -0
- package/dist/test/index.js +1 -0
- package/dist/utils/format-email-address.d.ts +1 -1
- package/dist/utils/format-email-address.js +1 -1
- package/dist/utils/parse-address.d.ts +1 -1
- package/dist/utils/result.d.ts +49 -0
- package/dist/utils/result.js +1 -0
- package/dist/utils/validation/check-feature-support.d.ts +1 -1
- package/dist/webhooks/index.d.ts +231 -0
- package/dist/webhooks/index.js +1 -0
- package/package.json +115 -3
- package/dist/packem_shared/DkimSigner-CT2DSHD1.js +0 -18
- package/dist/packem_shared/Mail-BWSWWq6m.js +0 -1
- package/dist/packem_shared/address-formatter-Cm_E_ZMa.js +0 -1
- package/dist/packem_shared/ahaSendProvider-DOAAW65O.js +0 -1
- package/dist/packem_shared/attachment-processor-DsmIomKc.js +0 -1
- package/dist/packem_shared/azureProvider-EkNYKAiF.js +0 -1
- package/dist/packem_shared/brevoProvider-CkR4U4RD.js +0 -1
- package/dist/packem_shared/build-mime-message-6xstxaUV.js +0 -2
- package/dist/packem_shared/infobipProvider-BhTsWi7e.js +0 -1
- package/dist/packem_shared/mailPaceProvider-DRt6Z9Hr.js +0 -1
- package/dist/packem_shared/mailerSendProvider-Dx_iHInH.js +0 -1
- package/dist/packem_shared/mailgunProvider-ChkLGZZW.js +0 -1
- package/dist/packem_shared/mailjetProvider-BMRhNe6H.js +0 -1
- package/dist/packem_shared/mailomatProvider-CydV-JB6.js +0 -1
- package/dist/packem_shared/mailtrapProvider-CuAfJWDr.js +0 -1
- package/dist/packem_shared/mandrillProvider-BBeLbaw0.js +0 -1
- package/dist/packem_shared/plunkProvider-BQyjG6YT.js +0 -1
- package/dist/packem_shared/postalProvider-DPHQ620q.js +0 -1
- package/dist/packem_shared/postmarkProvider-bMTC2gdJ.js +0 -1
- package/dist/packem_shared/provider-base-Cmzx6BTO.js +0 -1
- package/dist/packem_shared/resendProvider-Cns1tvF5.js +0 -1
- package/dist/packem_shared/scalewayProvider-O1dHz7iJ.js +0 -1
- package/dist/packem_shared/sendGridProvider-DmywC-eT.js +0 -1
- package/dist/packem_shared/smtpProvider-Unjao_fn.js +0 -23
- package/dist/packem_shared/sweegoProvider-D086G6xG.js +0 -1
- package/dist/packem_shared/zeptomailProvider-DKKEpEsW.js +0 -1
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var v=Object.defineProperty;var m=(o,e)=>v(o,"name",{value:e,configurable:!0});import{createRequire as w}from"node:module";import{B as x}from"./readFile-BAVMZg5e-C4whBIPd.js";import{i as z}from"./headers-to-record-Qo124ImV.js";const C=w(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=m(o=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,t]=p.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return p.getBuiltinModule(o)}return C(o)},"__cjs_getBuiltinModule"),{createHash:M,createSign:S,createPrivateKey:_}=T("node:crypto");var H=Object.defineProperty,d=m((o,e)=>H(o,"name",{value:e,configurable:!0}),"l");const I=d((o,e="simple")=>{const t=[];for(const[r,a]of Object.entries(o)){const n=e==="relaxed"?r.toLowerCase().trim():r,s=e==="relaxed"?a.replaceAll(/\s+/g," ").trim():a;t.push(`${n}:${s}`)}return t.join(`\r
|
|
2
|
-
`)},"canonicalizeHeaders"),K=d((o,e="simple")=>{if(e==="simple"){const n=o.replace(/(\r\n|\r|\n)$/,`
|
|
3
|
-
`);let s=n.length;for(;s>0&&n[s-1]===`
|
|
4
|
-
`;)s-=1;const c=n.slice(0,s);return c?`${c}
|
|
5
|
-
`:`
|
|
6
|
-
`}let t=o.replaceAll(`\r
|
|
7
|
-
`,`
|
|
8
|
-
`).replaceAll("\r",`
|
|
9
|
-
`);t=t.split(`
|
|
10
|
-
`).map(n=>n.replaceAll(/\s+/g," ").replace(/[ \t]+$/,"")).join(`
|
|
11
|
-
`);let r=t.length;for(;r>0&&t[r-1]===`
|
|
12
|
-
`;)r-=1;const a=t.slice(0,r);return a?`${a}
|
|
13
|
-
`:`
|
|
14
|
-
`},"canonicalizeBody"),B=d((o,e,t)=>{const r=e.headerCanon??"simple",a=e.bodyCanon??"simple",n=Object.keys(o).filter(s=>!e.headersToIgnore?.some(c=>c.toLowerCase()===s.toLowerCase())).map(s=>s.toLowerCase()).join(":");return["v=1","a=rsa-sha256",`c=${r}/${a}`,`d=${e.domainName}`,`s=${e.keySelector}`,`h=${n}`,`bh=${t}`,"b="].join("; ")},"createDkimSignatureHeader");class i{static{m(this,"DkimSigner")}static{d(this,"DkimSigner")}static sanitizeDisplayName(e){let t=e.replaceAll(/[\r\n\t]+/g," ");t=[...t].filter(n=>{const s=n.codePointAt(0);return s===void 0?!1:s>=32&&s<=126||s>159}).join("");const r="\\",a='"';return t=t.replaceAll(r,r+r).replaceAll(a,r+a),t=t.trim().replaceAll(/\s+/g," "),t}static formatAddress(e){if(e.name){const t=i.sanitizeDisplayName(e.name);return t?`"${t}" <${e.email}>`:e.email}return e.email}static formatAddresses(e){return(Array.isArray(e)?e:[e]).map(t=>i.formatAddress(t)).join(", ")}options;constructor(e){this.options=e}async sign(e){let t=this.options.privateKey;if(t.startsWith("file://")){const l=t.slice(7);t=await x(l,{encoding:"utf8"})}const r={...e.headers?z(e.headers):{},From:i.formatAddress(e.from),To:i.formatAddresses(e.to)};e.cc&&(r.Cc=i.formatAddresses(e.cc)),e.replyTo&&(r["Reply-To"]=i.formatAddress(e.replyTo)),r.Subject=e.subject,r["MIME-Version"]="1.0";const a=[];e.text&&a.push(e.text),e.html&&a.push(e.html);const n=a.join(`
|
|
15
|
-
|
|
16
|
-
`),s=this.options.headerCanon??"simple",c=this.options.bodyCanon??"simple",g=I(r,s),y=K(n,c),A=M("sha256").update(y).digest("base64"),h=B(r,this.options,A),$=`${g}\r
|
|
17
|
-
DKIM-Signature: ${h}`,f=S("RSA-SHA256");f.update($);let u;try{const l=_({key:t,passphrase:this.options.passphrase});u=f.sign(l,"base64")}catch(l){throw new Error(`Failed to create DKIM signature: ${l.message}`)}const j=u.match(/.{1,72}/g)?.join(`\r
|
|
18
|
-
`)??u,b={...r,"DKIM-Signature":`${h}${j}`};return{...e,headers:b}}}const R=d(o=>new i(o),"createDkimSigner");export{i as DkimSigner,R as createDkimSigner};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var p=Object.defineProperty;var n=(a,e)=>p(a,"name",{value:e,configurable:!0});import{MailMessage as c}from"./MailMessage-BvaH5tZZ.js";import m from"./EmailError-zm2ffVav.js";import{z as b}from"./build-mime-message-6xstxaUV.js";import{c as y}from"./create-logger-BiWdqFNg.js";import{i as d}from"./headers-to-record-Qo124ImV.js";import C from"../utils/validation/check-feature-support.js";var v=Object.defineProperty,M=n((a,e)=>v(a,"name",{value:e,configurable:!0}),"s");class f extends c{static{n(this,"DraftMailMessage")}static{M(this,"DraftMailMessage")}constructor(){super(),this.header("X-Unsent","1")}}var w=Object.defineProperty,u=n((a,e)=>w(a,"name",{value:e,configurable:!0}),"d");const T=u((a,e,r)=>{e.success&&e.data?a&&a.info("Email sent successfully",{messageId:e.data.messageId,provider:e.data.provider}):a&&a.error("Email send failed",{error:e.error,provider:r})},"logSendResult");class h{static{n(this,"Mail")}static{u(this,"Mail")}static extractErrorMessages(e){return e instanceof Error?[e.message]:[String(e??"Unknown error")]}provider;logger;loggerInstance;globalConfig;featureCheck;constructor(e,r){this.provider=e,this.featureCheck=r?.featureCheck??"error"}setLogger(e){return this.loggerInstance=e,this.logger=y("Mail",e),this}setFrom(e){return this.globalConfig??={},this.globalConfig.from=e,this.logger&&this.logger.debug("Default from address updated",{from:e.email}),this}setReplyTo(e){return this.globalConfig??={},this.globalConfig.replyTo=e,this.logger&&this.logger.debug("Default reply-to address updated",{replyTo:e.email}),this}setHeaders(e){if(this.globalConfig??={},this.globalConfig.headers=e,this.logger){const r=d(e);this.logger.debug("Default headers updated",{count:Object.keys(r).length,headers:Object.keys(r)})}return this}async draft(e){let r=e instanceof c||e instanceof f?await this.buildDraftFromMessage(e):await this.buildDraftFromOptions(e);r=this.applyGlobalConfig(r);const t=r.headers?d(r.headers):{};r.headers={...t,"X-Unsent":"1"};const s=await b(r);return this.logger&&this.logger.debug("Draft created successfully in EML format",{from:r.from.email,size:s.length,subject:r.subject,to:Array.isArray(r.to)?r.to.length:1}),s}async send(e){if(e instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");let r;if(e instanceof c)this.logger&&this.logger.debug("Sending MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),r=await e.build();else{const o=e;this.logger&&this.logger.debug("Sending email with options",{subject:o.subject,to:Array.isArray(o.to)?o.to.length:1}),r=o}r=this.applyGlobalConfig(r);const t=this.assertFeatureSupport(r);if(t)return{error:t,success:!1};const s=await this.provider.sendEmail(r);return T(this.logger,s,this.provider.name??"unknown"),s}async*sendMany(e,r){const t=this.provider.name;let s=0,o=0,g=0;this.logger&&this.logger.debug("Starting batch email send",{provider:t});for await(const l of e){if(l instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");if(r?.signal?.aborted){this.logger&&this.logger.warn("Batch send operation was aborted",{failed:g,processed:s,successful:o}),yield{errorMessages:["Send operation was aborted"],provider:t,successful:!1};return}s+=1;try{const i=await this.send(l);i.success&&i.data?(o+=1,this.logger&&this.logger.debug(`Email ${s} sent successfully`,{messageId:i.data.messageId}),yield{messageId:i.data.messageId,provider:i.data.provider??t,response:i.data.response,successful:!0,timestamp:i.data.timestamp}):(g+=1,this.logger&&this.logger.error(`Email ${s} send failed`,{error:i.error}),yield{errorMessages:h.extractErrorMessages(i.error),provider:t,successful:!1})}catch(i){g+=1,this.logger&&this.logger.error(`Email ${s} send failed with exception`,i),yield{errorMessages:h.extractErrorMessages(i),provider:t,successful:!1}}}this.logger&&this.logger.debug("Batch email send completed",{failureCount:g,processedCount:s,provider:t,successCount:o})}assertFeatureSupport(e){if(this.featureCheck==="off")return;const{supported:r,violations:t}=C(e,this.provider.features);if(r)return;const s=this.provider.name??"unknown",o=t.map(l=>l.field),g=t.map(l=>l.message);if(this.featureCheck==="warn"){this.logger&&this.logger.warn("Message uses capabilities the provider does not support",{fields:o,provider:s});return}return this.logger&&this.logger.error("Message rejected by capability guard",{fields:o,provider:s}),new m(s,`Provider does not support the following message fields: ${o.join(", ")}`,{code:"UNSUPPORTED_FEATURES",hint:g})}async buildDraftFromMessage(e){return this.logger&&this.logger.debug("Creating draft from MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),this.applyGlobalConfigToMessage(e),await e.build()}async buildDraftFromOptions(e){return this.logger&&this.logger.debug("Creating draft from email options",{subject:e.subject,to:Array.isArray(e.to)?e.to.length:1}),e}applyGlobalConfigToMessage(e){const r=this.globalConfig?.from;r&&!e.getFrom()&&e.from(r);const t=this.globalConfig?.replyTo;if(t&&!e.getReplyTo()&&e.replyTo(t),this.globalConfig?.headers){const s=d(this.globalConfig.headers);Object.entries(s).forEach(([o,g])=>{e.header(o,g)})}}applyGlobalConfig(e){if(!this.globalConfig)return e;const r={...e};if(!r.from&&this.globalConfig.from&&(r.from=this.globalConfig.from,this.logger&&this.logger.debug("Applied global from address",{from:this.globalConfig.from.email})),!r.replyTo&&this.globalConfig.replyTo&&(r.replyTo=this.globalConfig.replyTo,this.logger&&this.logger.debug("Applied global reply-to address",{replyTo:this.globalConfig.replyTo.email})),this.globalConfig.headers){const t=d(this.globalConfig.headers),s=r.headers?d(r.headers):{};r.headers={...t,...s},this.logger&&this.logger.debug("Merged global headers",{globalCount:Object.keys(t).length,messageCount:Object.keys(s).length})}return r}}const A=u((a,e)=>new h(a,e),"createMail");export{h as Mail,A as createMail};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=Object.defineProperty;var r=(a,s)=>t(a,"name",{value:s,configurable:!0});var A=Object.defineProperty,e=r((a,s)=>A(a,"name",{value:s,configurable:!0}),"t");const o=e(a=>a.name?`${a.name} <${a.email}>`:a.email,"formatAddress"),i=e(a=>(Array.isArray(a)?a:[a]).map(s=>o(s)),"formatAddresses"),l=e(a=>{const s={email:a.email};return a.name&&(s.name=a.name),s},"formatSendGridAddress"),u=e(a=>(Array.isArray(a)?a:[a]).map(s=>l(s)),"formatSendGridAddresses"),c=e(a=>(Array.isArray(a)?a:[a]).map(s=>s.email),"formatAddressEmails"),f=e(a=>({email:a.email,...a.name&&{displayName:a.name}}),"formatAzureAddress"),j=e(a=>(Array.isArray(a)?a:[a]).map(s=>f(s)),"formatAzureAddresses"),n=e(a=>{const s={Email:a.email};return a.name&&(s.Name=a.name),s},"formatMailjetAddress"),P=e(a=>(Array.isArray(a)?a:[a]).map(s=>n(s)),"formatMailjetAddresses"),y=e((a,s="to")=>({email:a.email,...a.name&&{name:a.name},type:s}),"formatMandrillAddress"),z=e((a,s="to")=>(Array.isArray(a)?a:[a]).map(m=>y(m,s)),"formatMandrillAddresses"),d=e(a=>({address:a.email,...a.name&&{name:a.name}}),"formatPostalAddress"),G=e(a=>(Array.isArray(a)?a:[a]).map(s=>d(s)),"formatPostalAddresses"),S=e(a=>i(a),"formatMailpaceAddresses"),p=e(a=>d(a),"formatZeptomailAddress");e(a=>(Array.isArray(a)?a:[a]).map(s=>({email_address:p(s)})),"formatZeptomailAddresses");export{l as a,i as b,o as c,P as d,n as e,u as f,z as g,G as h,d as i,j,f as k,c as l,p as m,S as n};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var P=Object.defineProperty;var y=(i,r)=>P(i,"name",{value:r,configurable:!0});import{createRequire as I}from"node:module";import c from"./EmailError-zm2ffVav.js";import S from"./RequiredOptionError-CevW3u2K.js";import{s as _}from"./generate-message-id-D4uA8gkj.js";import{i as E}from"./headers-to-record-Qo124ImV.js";import{m as f}from"./make-request-CaT4d5oC.js";import{c as z,u as b,h as w,P as k}from"./provider-base-Cmzx6BTO.js";import{d as q}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as K}from"./defineProvider-CtLH0VBE.js";import{f as p,a as B}from"./address-formatter-Cm_E_ZMa.js";const T=I(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=y(i=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[r,u]=m.versions.node.split(".").map(Number);if(r>22||r===22&&u>=3||r===20&&u>=16)return m.getBuiltinModule(i)}return T(i)},"__cjs_getBuiltinModule"),{Buffer:j}=$("node:buffer"),s="ahasend",C="https://api.ahasend.com",x=3e4,G=3,Q=K((i={})=>{if(!i.apiKey)throw new S(s,"apiKey");const r={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??C,retries:i.retries??G,timeout:i.timeout??x,...i.logger&&{logger:i.logger}},u=new k,n=z(s,i.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(s,"Email ID is required to retrieve email details"),success:!1};await this.initialize();const o={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await b(async()=>f(`${r.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:r.timeout}),r.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(s,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:w(s,"retrieve email",o,n),success:!1}}},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(s,"AhaSend API not available or invalid API key");n.debug("Provider initialized successfully")},s)},async isAvailable(){try{return n.debug("Checking AhaSend API availability"),!!(await f(`${r.endpoint}/v2/ping`,{headers:{Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},method:"GET",timeout:r.timeout})).success}catch(e){return n.debug("Error checking availability:",e),!1}},name:s,options:r,async sendEmail(e){try{const o=q(e);if(o.length>0)return{error:new c(s,`Invalid email options: ${o.join(", ")}`),success:!1};await this.initialize();const t={from:{email:e.from.email,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=B(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 a=E(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 A=await a.content;d=j.from(A).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 c(s,`Attachment ${a.filename} has no content`);return{content:d,contentType:a.contentType??"application/octet-stream",filename:a.filename,...a.cid&&{cid:a.cid}}}))),n.debug("Sending email via AhaSend API",{subject:t.subject,to:t.to});const v={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},l=await b(async()=>f(`${r.endpoint}/send`,{headers:v,method:"POST",timeout:r.timeout},JSON.stringify(t)),r.retries);if(!l.success)return n.debug("API request failed when sending email",l.error),{error:l.error??new c(s,"Failed to send email"),success:!1};const g=l.data?.body,h=g?.messageId??g?.id??_();return n.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:s,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:w(s,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var r=Object.defineProperty;var i=(e,t)=>r(e,"name",{value:t,configurable:!0});import{createRequire as m}from"node:module";import d from"./EmailError-zm2ffVav.js";const p=m(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=i(e=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[t,n]=a.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return a.getBuiltinModule(e)}return p(e)},"__cjs_getBuiltinModule"),{Buffer:l}=f("node:buffer");var u=Object.defineProperty,o=i((e,t)=>u(e,"name",{value:t,configurable:!0}),"o");const c=o(async(e,t)=>{let n;if(e.content)if(typeof e.content=="string")n=e.content;else if(e.content instanceof Promise){const s=await e.content;n=l.from(s).toString("base64")}else n=e.content.toString("base64");else if(e.raw)n=typeof e.raw=="string"?e.raw:e.raw.toString("base64");else throw new d(t,`Attachment ${e.filename} has no content`);return n},"processAttachmentContent");o(async(e,t)=>({content:await c(e,t),contentType:e.contentType??"application/octet-stream",disposition:e.contentDisposition??"attachment",filename:e.filename,...e.cid&&{contentId:e.cid}}),"createStandardAttachment");const _=o(async(e,t)=>({content:await c(e,t),disposition:e.contentDisposition??"attachment",filename:e.filename,type:e.contentType??"application/octet-stream",...e.cid&&{content_id:e.cid}}),"createSendGridAttachment"),b=o(async(e,t)=>({Content:await c(e,t),ContentType:e.contentType??"application/octet-stream",Name:e.filename,...e.cid&&{ContentID:e.cid}}),"createPostmarkAttachment"),w=o(async(e,t,n)=>({content:await c(e,t),key:`attachment[${n}]`}),"createMailgunAttachment");export{w as a,b,_ as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var k=Object.defineProperty;var w=(n,l)=>k(n,"name",{value:l,configurable:!0});import{createRequire as z}from"node:module";import u from"./EmailError-zm2ffVav.js";import v from"./RequiredOptionError-CevW3u2K.js";import{s as j}from"./generate-message-id-D4uA8gkj.js";import{i as _}from"./headers-to-record-Qo124ImV.js";import{m as h}from"./make-request-CaT4d5oC.js";import{c as B,P as C,u as T,h as S}from"./provider-base-Cmzx6BTO.js";import{d as E}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as q}from"./defineProvider-CtLH0VBE.js";import{j as y,k as R}from"./address-formatter-Cm_E_ZMa.js";const I=z(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=w(n=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[l,t]=f.versions.node.split(".").map(Number);if(l>22||l===22&&t>=3||l===20&&t>=16)return f.getBuiltinModule(n)}return I(n)},"__cjs_getBuiltinModule"),{Buffer:p}=P("node:buffer"),i="azure",x=3e4,O=3,Q=q((n={})=>{if(!n.region)throw new v(i,"region");if(!n.connectionString&&!n.accessToken)throw new v(i,"connectionString or accessToken");const l=n.endpoint??`https://${n.region}.communication.azure.com`,t={debug:n.debug??!1,endpoint:l,region:n.region,retries:n.retries??O,timeout:n.timeout??x,...n.connectionString&&{connectionString:n.connectionString},...n.accessToken&&{accessToken:n.accessToken},...n.logger&&{logger:n.logger}},g=new C,a=B(i,n.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 u(i,"Email ID is required to retrieve email details"),success:!1};await g.ensureInitialized(()=>this.initialize(),i);const o={"Content-Type":"application/json"};if(t.accessToken)o.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const c=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);c&&(o.Authorization=`Bearer ${c[2]}`)}a.debug("Retrieving email details",{id:e});const r=await T(async()=>h(`${t.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:t.timeout}),t.retries);return r.success?(a.debug("Email details retrieved successfully"),{data:r.data?.body,success:!0}):(a.debug("API request failed when retrieving email",r.error),{error:new u(i,`Failed to retrieve email: ${r.error instanceof Error?r.error.message:"Unknown error"}`,{cause:r.error}),success:!1})}catch(o){return{error:S(i,"retrieve email",o,a),success:!1}}},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(i,"Azure Communication Services API not available or invalid credentials");a.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={"Content-Type":"application/json"};if(t.accessToken)e.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const c=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(c)e.Authorization=`Bearer ${c[2]}`;else return!1}else return!1;a.debug("Checking Azure Communication Services API availability");const o=await h(`${t.endpoint}/emails:send`,{headers:e,method:"POST",timeout:t.timeout},JSON.stringify({}));if(o.success)return!0;const r=o.data?.statusCode;return r===401||r===403?!1:r===400}catch(e){if(a.debug("Error checking availability:",e),e instanceof Error){const o=e.message;if(o.includes("401")||o.includes("403"))return!1}return!1}},name:i,options:t,async sendEmail(e){try{const o=E(e);if(o.length>0)return{error:new u(i,`Invalid email options: ${o.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),i);const r={content:{subject:e.subject},recipients:{to:y(e.to)},senderAddress:e.from.email};if(e.html&&(r.content.html=e.html),e.text&&(r.content.plainText=e.text),e.cc&&(r.recipients.cc=y(e.cc)),e.bcc&&(r.recipients.bcc=y(e.bcc)),e.replyTo&&(r.replyTo=R(e.replyTo).email),e.importance&&(r.importance=e.importance),e.headers){const s=_(e.headers);r.headers=s}e.attachments&&e.attachments.length>0&&(r.attachments=await Promise.all(e.attachments.map(async s=>{let d;if(s.content)if(typeof s.content=="string")d=p.from(s.content,"utf8").toString("base64");else if(s.content&&typeof s.content.then=="function"){const A=await s.content;d=p.from(A).toString("base64")}else d=s.content.toString("base64");else if(s.raw)d=typeof s.raw=="string"?p.from(s.raw,"utf8").toString("base64"):s.raw.toString("base64");else throw new u(i,`Attachment ${s.filename} has no content`);return{contentInBase64:d,contentType:s.contentType??"application/octet-stream",name:s.filename}}))),a.debug("Sending email via Azure Communication Services API",{subject:r.content.subject,to:r.recipients.to});const c={"Content-Type":"application/json"};if(t.accessToken)c.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const s=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(s)c.Authorization=`Bearer ${s[2]}`;else return{error:new u(i,"Invalid connection string format"),success:!1}}const m=await T(async()=>h(`${t.endpoint}/emails:send`,{headers:c,method:"POST",timeout:t.timeout},JSON.stringify(r)),t.retries);if(!m.success)return a.debug("API request failed when sending email",m.error),{error:m.error??new u(i,"Failed to send email"),success:!1};const b=m.data?.body?.messageId??j();return a.debug("Email sent successfully",{messageId:b}),{data:{messageId:b,provider:i,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:S(i,"send email",o,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var j=Object.defineProperty;var w=(o,d)=>j(o,"name",{value:d,configurable:!0});import{createRequire as C}from"node:module";import c from"./EmailError-zm2ffVav.js";import k from"./RequiredOptionError-CevW3u2K.js";import{s as z}from"./generate-message-id-D4uA8gkj.js";import{i as q}from"./headers-to-record-Qo124ImV.js";import{m as y}from"./make-request-CaT4d5oC.js";import{c as B,P as K,u as T,h as A}from"./provider-base-Cmzx6BTO.js";import{d as x}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as D}from"./defineProvider-CtLH0VBE.js";import{f as g,a as h}from"./address-formatter-Cm_E_ZMa.js";const E=C(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=w(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 E(o)},"__cjs_getBuiltinModule"),{Buffer:_}=S("node:buffer"),a="brevo",G="https://api.brevo.com/v3",O=3e4,R=3,X=D((o={})=>{if(!o.apiKey)throw new k(a,"apiKey");const d=o.endpoint??G,s={apiKey:o.apiKey,debug:o.debug??!1,endpoint:d,hardValidation:o.hardValidation??!1,retries:o.retries??R,timeout:o.timeout??O,...o.logger&&{logger:o.logger}},f=new K,n=B(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 T(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:A(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=x(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=q(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 P=await r.content;m=_.from(P).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 I={"api-key":s.apiKey,"Content-Type":"application/json"},u=await T(async()=>y(`${s.endpoint}/smtp/email`,{headers:I,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??z();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:A(a,"send email",t,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var v=Object.defineProperty;var u=(e,o)=>v(e,"name",{value:o,configurable:!0});import C from"./EmailError-zm2ffVav.js";import m from"../utils/format-email-address.js";import{a as w}from"./generate-boundary-Cx8nXYS0.js";import{i as j}from"./headers-to-record-Qo124ImV.js";import{s as h,a as b}from"./sanitize-header-wWav-Scu.js";var x=Object.defineProperty,E=u((e,o)=>x(e,"name",{value:o,configurable:!0}),"m");const l=E(e=>Array.isArray(e)?e.map(o=>m(o)).join(", "):m(e),"formatEmailAddresses");var B=Object.defineProperty,M=u((e,o)=>B(e,"name",{value:o,configurable:!0}),"g$1");const d=globalThis.Buffer!==void 0,g=M(e=>{if(typeof e=="string"){if(d)return Buffer.from(e,"utf8").toString("base64");const t=new TextEncoder().encode(e);let r="";const s=8192;for(let a=0;a<t.length;a+=s){const f=t.subarray(a,Math.min(a+s,t.length));r+=String.fromCharCode(...f)}return btoa(r)}if(d&&e instanceof Buffer)return e.toString("base64");const o=e instanceof Uint8Array?e:new Uint8Array(e);if(d)return Buffer.from(o).toString("base64");let n="";const c=8192;for(let t=0;t<o.length;t+=c){const r=o.subarray(t,Math.min(t+c,o.length));n+=String.fromCharCode(...r)}return btoa(n)},"toBase64");var S=Object.defineProperty,A=u((e,o)=>S(e,"name",{value:o,configurable:!0}),"h");const O=globalThis.Buffer!==void 0,H=A(async e=>{const o=w(),n=[`From: ${m(e.from)}`,`To: ${l(e.to)}`];if(e.cc&&n.push(`Cc: ${l(e.cc)}`),e.bcc&&n.push(`Bcc: ${l(e.bcc)}`),e.replyTo&&n.push(`Reply-To: ${m(e.replyTo)}`),n.push(`Subject: ${h(e.subject)}`,"MIME-Version: 1.0"),e.headers){const c=j(e.headers);Object.entries(c).forEach(([t,r])=>{const s=b(t),a=h(r);n.push(`${s}: ${a}`)})}if(n.push(`Content-Type: multipart/mixed; boundary="${o}"`,""),e.text&&n.push(`--${o}`,"Content-Type: text/plain; charset=UTF-8","Content-Transfer-Encoding: 7bit","",e.text,""),e.html&&n.push(`--${o}`,"Content-Type: text/html; charset=UTF-8","Content-Transfer-Encoding: 7bit","",e.html,""),e.attachments&&e.attachments.length>0){const c=await Promise.all(e.attachments.map(async t=>{let r;if(t.raw!==void 0)r=t.raw;else{if(t.content===void 0)throw new C("attachment",`Attachment '${t.filename}' must have content, raw, or be resolved from path/href before building MIME message`);r=t.content instanceof Promise?await t.content:t.content}return{...t,resolvedContent:r}}));for(const t of c){n.push(`--${o}`);const r=t.contentType??"application/octet-stream",s=h(t.filename);n.push(`Content-Type: ${r}; name="${s}"`);const a=t.contentDisposition??"attachment";n.push(`Content-Disposition: ${a}; filename="${s}"`),t.cid&&n.push(`Content-ID: <${t.cid}>`),t.headers&&Object.entries(t.headers).forEach(([p,$])=>{const y=b(p),T=h($);n.push(`${y}: ${T}`)});const f=t.encoding??"base64";n.push(`Content-Transfer-Encoding: ${f}`,"");const i=t.resolvedContent;if(f==="base64")n.push(g(i));else if(f==="7bit"||f==="8bit")if(typeof i=="string")n.push(i);else if(O&&i instanceof Buffer)n.push(i.toString("utf8"));else{const p=new TextDecoder;n.push(p.decode(i))}else n.push(g(i));n.push("")}}return n.push(`--${o}--`),n.join(`\r
|
|
2
|
-
`)},"buildMimeMessage");export{H as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var T=Object.defineProperty;var b=(r,n)=>T(r,"name",{value:n,configurable:!0});import{createRequire as P}from"node:module";import c from"./EmailError-zm2ffVav.js";import z from"./RequiredOptionError-CevW3u2K.js";import{s as E}from"./generate-message-id-D4uA8gkj.js";import{i as U}from"./headers-to-record-Qo124ImV.js";import{m as g}from"./make-request-CaT4d5oC.js";import{c as k,P as S,u as w,h as v}from"./provider-base-Cmzx6BTO.js";import{d as q}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as K}from"./defineProvider-CtLH0VBE.js";import{l as y}from"./address-formatter-Cm_E_ZMa.js";const $=P(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=b(r=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[n,p]=d.versions.node.split(".").map(Number);if(n>22||n===22&&p>=3||n===20&&p>=16)return d.getBuiltinModule(r)}return $(r)},"__cjs_getBuiltinModule"),{Buffer:_}=j("node:buffer"),a="infobip",R="https://api.infobip.com",C=3e4,x=3,Q=K((r={})=>{if(!r.apiKey)throw new z(a,"apiKey");const n=r.baseUrl??R,p=r.endpoint??`${n}/email/3/send`,s={apiKey:r.apiKey,baseUrl:n,debug:r.debug??!1,endpoint:p,retries:r.retries??x,timeout:r.timeout??C,...r.logger&&{logger:r.logger}},f=new S,o=k(a,r.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(a,"Email ID is required to retrieve email details"),success:!1};await f.ensureInitialized(()=>this.initialize(),a);const l={Authorization:`App ${s.apiKey}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const t=await w(async()=>g(`${s.baseUrl}/email/3/reports/${e}`,{headers:l,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(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(l){return{error:v(a,"retrieve email",l,o),success:!1}}},async initialize(){await f.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(a,"Infobip API not available or invalid API key");o.debug("Provider initialized successfully")},a)},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:a,options:s,async sendEmail(e){try{const l=q(e);if(l.length>0)return{error:new c(a,`Invalid email options: ${l.join(", ")}`),success:!1};await f.ensureInitialized(()=>this.initialize(),a);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 i=U(e.headers);t.headers=i}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async i=>{let u;if(i.content)if(typeof i.content=="string")u=i.content;else if(i.content instanceof Promise){const A=await i.content;u=_.from(A).toString("base64")}else u=i.content.toString("base64");else if(i.raw)u=typeof i.raw=="string"?i.raw:i.raw.toString("base64");else throw new c(a,`Attachment ${i.filename} has no content`);return{content:u,contentType:i.contentType??"application/octet-stream",name:i.filename}}))),o.debug("Sending email via Infobip API",{subject:t.subject,to:t.to});const I={Authorization:`App ${s.apiKey}`,"Content-Type":"application/json"},m=await w(async()=>g(s.endpoint,{headers:I,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(a,"Failed to send email"),success:!1};const h=m.data?.body?.messages?.[0]?.messageId??E();return o.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(l){return{error:v(a,"send email",l,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import c from"./EmailError-zm2ffVav.js";import P from"./RequiredOptionError-CevW3u2K.js";import{s as I}from"./generate-message-id-D4uA8gkj.js";import{i as T}from"./headers-to-record-Qo124ImV.js";import{m as d}from"./make-request-CaT4d5oC.js";import{c as A,P as k,u as g,h as f}from"./provider-base-Cmzx6BTO.js";import{a as $,s as z}from"./sanitize-header-wWav-Scu.js";import{d as E}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as j}from"./defineProvider-CtLH0VBE.js";import{n as u,c as h}from"./address-formatter-Cm_E_ZMa.js";const r="mailpace",C="https://app.mailpace.com/api/v1",M=3e4,S=3,G=j((n={})=>{if(!n.apiToken)throw new P(r,"apiToken");const s={apiToken:n.apiToken,debug:n.debug??!1,endpoint:n.endpoint??C,retries:n.retries??S,timeout:n.timeout??M,...n.logger&&{logger:n.logger}},l=new k,i=A(r,n.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),r);const a={Authorization:`Bearer ${s.apiToken}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const t=await g(async()=>d(`${s.endpoint}/emails/${e}`,{headers:a,method:"GET",timeout:s.timeout}),s.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:f(r,"retrieve email",a,i),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"MailPace API not available or invalid API token");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={Authorization:`Bearer ${s.apiToken}`,"Content-Type":"application/json"};i.debug("Checking MailPace API availability");const a=await d(`${s.endpoint}/account`,{headers:e,method:"GET",timeout:s.timeout});return i.debug("MailPace API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const a=E(e);if(a.length>0)return{error:new c(r,`Invalid email options: ${a.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),r);const t={from:h(e.from),subject:e.subject,to:u(e.to)};if(e.html&&(t.htmlbody=e.html),e.text&&(t.textbody=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.replyto=h(e.replyTo)),e.templateId&&(t.template_id=e.templateId,e.templateVariables&&(t.template_variables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.listUnsubscribe&&(t.list_unsubscribe=e.listUnsubscribe),e.headers){const y=T(e.headers),p={};Object.entries(y).forEach(([v,w])=>{p[$(v)]=z(w)}),t.headers=p}e.attachments&&e.attachments.length>0&&(t.attachments=e.attachments),i.debug("Sending email via MailPace API",{subject:t.subject,to:t.to});const b={Authorization:`Bearer ${s.apiToken}`,"Content-Type":"application/json"},o=await g(async()=>d(`${s.endpoint}/send`,{headers:b,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!o.success)return i.debug("API request failed when sending email",o.error),{error:o.error??new c(r,"Failed to send email"),success:!1};const m=o.data?.body?.id??I();return i.debug("Email sent successfully",{messageId:m}),{data:{messageId:m,provider:r,response:o.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:f(r,"send email",a,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{G as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var T=Object.defineProperty;var h=(o,a)=>T(o,"name",{value:a,configurable:!0});import{createRequire as A}from"node:module";import l from"./EmailError-zm2ffVav.js";import k from"./RequiredOptionError-CevW3u2K.js";import{s as z}from"./generate-message-id-D4uA8gkj.js";import{i as j}from"./headers-to-record-Qo124ImV.js";import{m as p}from"./make-request-CaT4d5oC.js";import{c as S,P as $,u as b,h as y}from"./provider-base-Cmzx6BTO.js";import{d as C}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as E}from"./defineProvider-CtLH0VBE.js";import{f,a as q}from"./address-formatter-Cm_E_ZMa.js";const I=A(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=h(o=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[a,c]=m.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return m.getBuiltinModule(o)}return I(o)},"__cjs_getBuiltinModule"),{Buffer:_}=P("node:buffer"),s="mailersend",M="https://api.mailersend.com",B=3e4,R=3,K=E((o={})=>{if(!o.apiToken)throw new k(s,"apiToken");const a={apiToken:o.apiToken,debug:o.debug??!1,endpoint:o.endpoint??M,retries:o.retries??R,timeout:o.timeout??B,...o.logger&&{logger:o.logger}},c=new $,n=S(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 ${a.apiToken}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await b(async()=>p(`${a.endpoint}/v1/activity/${e}`,{headers:r,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(s,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(r){return{error:y(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 ${a.apiToken}`,"Content-Type":"application/json"};n.debug("Checking MailerSend API availability");const r=await p(`${a.endpoint}/v1/tokens/verify`,{headers:e,method:"GET",timeout:a.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:a,async sendEmail(e){try{const r=C(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=q(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 i=j(e.headers);t.headers=i}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async i=>{let u;if(i.content)if(typeof i.content=="string")u=i.content;else if(i.content instanceof Promise){const w=await i.content;u=_.from(w).toString("base64")}else u=i.content.toString("base64");else if(i.raw)u=typeof i.raw=="string"?i.raw:i.raw.toString("base64");else throw new l(s,`Attachment ${i.filename} has no content`);return{content:u,filename:i.filename,...i.contentType&&{type:i.contentType},...i.cid&&{id:i.cid}}}))),n.debug("Sending email via MailerSend API",{subject:t.subject,to:t.to});const v={Authorization:`Bearer ${a.apiToken}`,"Content-Type":"application/json"},d=await b(async()=>p(`${a.endpoint}/v1/email`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.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??z();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:y(s,"send email",r,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{K as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var A=Object.defineProperty;var y=(i,r)=>A(i,"name",{value:r,configurable:!0});import{createRequire as P}from"node:module";import m from"./EmailError-zm2ffVav.js";import T from"./RequiredOptionError-CevW3u2K.js";import{s as R}from"./generate-message-id-D4uA8gkj.js";import{i as S}from"./headers-to-record-Qo124ImV.js";import{m as h}from"./make-request-CaT4d5oC.js";import{c as _,P as z,u as j,h as I}from"./provider-base-Cmzx6BTO.js";import{d as E}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as q}from"./defineProvider-CtLH0VBE.js";import{b as v,c as k}from"./address-formatter-Cm_E_ZMa.js";import{a as U}from"./attachment-processor-DsmIomKc.js";const C=P(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=y(i=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[r,n]=u.versions.node.split(".").map(Number);if(r>22||r===22&&n>=3||r===20&&n>=16)return u.getBuiltinModule(i)}return C(i)},"__cjs_getBuiltinModule"),{Buffer:b}=$("node:buffer");var M=Object.defineProperty,K=y((i,r)=>M(i,"name",{value:r,configurable:!0}),"T");const s="mailgun",B="https://api.mailgun.net",O=3e4,x=3,D=K(i=>{const r=[];for(const[n,o]of Object.entries(i))if(o!=null)if(Array.isArray(o))for(const e of o)r.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(e))}`);else typeof o=="object"?r.push(`${encodeURIComponent(n)}=${encodeURIComponent(JSON.stringify(o))}`):r.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(o))}`);return r.join("&")},"objectToFormData"),ee=q((i={})=>{if(!i.apiKey)throw new T(s,"apiKey");if(!i.domain)throw new T(s,"domain");const r={apiKey:i.apiKey,debug:i.debug??!1,domain:i.domain,endpoint:i.endpoint??B,retries:i.retries??x,timeout:i.timeout??O,...i.logger&&{logger:i.logger}},n=new z,o=_(s,i.logger);return{endpoint:r.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 m(s,"Email ID is required to retrieve email details"),success:!1};await n.ensureInitialized(()=>this.initialize(),s);const a={Authorization:`Basic ${b.from(`api:${r.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const t=await j(async()=>h(`${r.endpoint}/v3/${r.domain}/events?message-id=${encodeURIComponent(e)}&limit=1`,{headers:a,method:"GET",timeout:r.timeout}),r.retries);if(!t.success)return o.debug("API request failed when retrieving email",t.error),{error:new m(s,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1};o.debug("Email details retrieved successfully");const p=t.data?.items??[],g=p.length>0?p[0]:void 0;return{data:g?.message?.headers??g?.storage??void 0,success:!0}}catch(a){return{error:I(s,"retrieve email",a,o),success:!1}}},async initialize(){await n.ensureInitialized(async()=>{if(!await this.isAvailable())throw new m(s,"Mailgun API not available or invalid API key/domain");o.debug("Provider initialized successfully")},s)},async isAvailable(){try{const e={Authorization:`Basic ${b.from(`api:${r.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Checking Mailgun API availability");const a=await h(`${r.endpoint}/v3/domains/${r.domain}`,{headers:e,method:"GET",timeout:r.timeout});if(o.debug("Mailgun API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!a.success||!a.data||typeof a.data!="object")return!1;const{statusCode:t}=a.data;return typeof t=="number"&&t>=200&&t<300}catch(e){return o.debug("Error checking availability:",e),!1}},name:s,options:r,async sendEmail(e){try{const a=E(e);if(a.length>0)return{error:new m(s,`Invalid email options: ${a.join(", ")}`),success:!1};await n.ensureInitialized(()=>this.initialize(),s);const t={from:k(e.from),to:v(e.to).join(",")};if(e.subject&&(t.subject=e.subject),e.cc&&(t.cc=v(e.cc).join(",")),e.bcc&&(t.bcc=v(e.bcc).join(",")),e.replyTo&&(t["h:Reply-To"]=k(e.replyTo)),e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.template&&(t.template=e.template,e.templateVariables))for(const[d,c]of Object.entries(e.templateVariables))t[`v:${d}`]=c;if(e.tags&&e.tags.length>0&&(t["o:tag"]=e.tags),e.campaignId&&(t["o:campaign"]=e.campaignId),e.deliveryTime&&(t["o:deliverytime"]=typeof e.deliveryTime=="number"?new Date(e.deliveryTime*1e3).toUTCString():e.deliveryTime),e.clickTracking!==void 0&&(t["o:clicktracking"]=e.clickTracking?"yes":"no"),e.openTracking!==void 0&&(t["o:tracking"]=e.openTracking?"yes":"no"),e.unsubscribeTracking!==void 0&&(t["o:tracking-clicks"]=e.unsubscribeTracking?"yes":"no"),e.testMode&&(t["o:testmode"]="yes"),e.requireTls&&(t["o:require-tls"]="yes"),e.skipVerification&&(t["o:skip-verification"]="yes"),e.headers){const d=S(e.headers);for(const[c,f]of Object.entries(d))t[`h:${c}`]=f}if(e.attachments&&e.attachments.length>0){const d=await Promise.all(e.attachments.map((c,f)=>U(c,s,f)));for(const c of d)t[c.key]=c.content}o.debug("Sending email via Mailgun API",{subject:t.subject,to:t.to});const p={Authorization:`Basic ${b.from(`api:${r.apiKey}`).toString("base64")}`,"Content-Type":"application/x-www-form-urlencoded"},g=D(t),l=await j(async()=>h(`${r.endpoint}/v3/${r.domain}/messages`,{headers:p,method:"POST",timeout:r.timeout},g),r.retries);if(!l.success)return o.debug("API request failed when sending email",l.error),{error:l.error??new m(s,"Failed to send email"),success:!1};const w=l.data?.body?.id??R();return o.debug("Email sent successfully",{messageId:w}),{data:{messageId:w,provider:s,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:I(s,"send email",a,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{ee as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var P=Object.defineProperty;var b=(s,a)=>P(s,"name",{value:a,configurable:!0});import{createRequire as $}from"node:module";import d from"./EmailError-zm2ffVav.js";import v from"./RequiredOptionError-CevW3u2K.js";import{s as M}from"./generate-message-id-D4uA8gkj.js";import{i as _}from"./headers-to-record-Qo124ImV.js";import{m as f}from"./make-request-CaT4d5oC.js";import{c as z,P as D,u as w,h as T}from"./provider-base-Cmzx6BTO.js";import{d as B}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as R}from"./defineProvider-CtLH0VBE.js";import{d as y,e as S}from"./address-formatter-Cm_E_ZMa.js";const A=$(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=b(s=>{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(s)}return A(s)},"__cjs_getBuiltinModule"),{Buffer:p}=E("node:buffer"),n="mailjet",k="https://api.mailjet.com",q=3e4,K=3,W=R((s={})=>{if(!s.apiKey)throw new v(n,"apiKey");if(!s.apiSecret)throw new v(n,"apiSecret");const a={apiKey:s.apiKey,apiSecret:s.apiSecret,debug:s.debug??!1,endpoint:s.endpoint??k,retries:s.retries??K,timeout:s.timeout??q,...s.logger&&{logger:s.logger}},l=new D,o=z(n,s.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(n,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),n);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 w(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(n,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(i){return{error:T(n,"retrieve email",i,o),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(n,"Mailjet API not available or invalid API credentials");o.debug("Provider initialized successfully")},n)},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:n,options:a,async sendEmail(e){try{const i=B(e);if(i.length>0)return{error:new d(n,`Invalid email options: ${i.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),n);const t={From:S(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=S(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=_(e.headers),c=[];for(const[g,I]of Object.entries(r))c.push({Name:g,Value:String(I)});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(n,`Attachment ${r.filename} has no content`);return{Base64Content:c,ContentType:r.contentType??"application/octet-stream",Filename:r.filename,...r.cid&&{ContentID:r.cid}}})));const j={Messages:[t]};o.debug("Sending email via Mailjet API",{subject:t.Subject,to:t.To});const C={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"},u=await w(async()=>f(`${a.endpoint}/v3.1/send`,{headers:C,method:"POST",timeout:a.timeout},JSON.stringify(j)),a.retries);if(!u.success)return o.debug("API request failed when sending email",u.error),{error:u.error??new d(n,"Failed to send email"),success:!1};const h=u.data?.body?.Messages?.[0]?.To?.[0]?.MessageID?.toString()??M();return o.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:n,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(i){return{error:T(n,"send email",i,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{W as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var P=Object.defineProperty;var h=(s,a)=>P(s,"name",{value:a,configurable:!0});import{createRequire as A}from"node:module";import c from"./EmailError-zm2ffVav.js";import S from"./RequiredOptionError-CevW3u2K.js";import{s as E}from"./generate-message-id-D4uA8gkj.js";import{i as K}from"./headers-to-record-Qo124ImV.js";import{m as y}from"./make-request-CaT4d5oC.js";import{c as k,P as q,u as b,h as w}from"./provider-base-Cmzx6BTO.js";import{d as z}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as C}from"./defineProvider-CtLH0VBE.js";import{f,a as M}from"./address-formatter-Cm_E_ZMa.js";const j=A(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=h(s=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[a,l]=u.versions.node.split(".").map(Number);if(a>22||a===22&&l>=3||a===20&&l>=16)return u.getBuiltinModule(s)}return j(s)},"__cjs_getBuiltinModule"),{Buffer:_}=T("node:buffer"),i="mailomat",x="https://api.mailomat.com",R=3e4,B=3,$=C((s={})=>{if(!s.apiKey)throw new S(i,"apiKey");const a={apiKey:s.apiKey,debug:s.debug??!1,endpoint:s.endpoint??x,retries:s.retries??B,timeout:s.timeout??R,...s.logger&&{logger:s.logger}},l=new q,n=k(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 c(i,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),i);const o={"Content-Type":"application/json","X-API-Key":a.apiKey};n.debug("Retrieving email details",{id:e});const t=await b(async()=>y(`${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 c(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:w(i,"retrieve email",o,n),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(i,"Mailomat API not available or invalid API key");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{return n.debug("Checking Mailomat 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 c(i,`Invalid email options: ${o.join(", ")}`),success:!1};await l.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=M(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=K(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 I=await r.content;d=_.from(I).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(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 Mailomat API",{subject:t.subject,to:t.to});const v={"Content-Type":"application/json","X-API-Key":a.apiKey},m=await b(async()=>y(`${a.endpoint}/send`,{headers:v,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 c(i,"Failed to send email"),success:!1};const p=m.data?.body,g=p?.messageId??p?.id??E();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:i,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:w(i,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{$ as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var T=Object.defineProperty;var b=(o,a)=>T(o,"name",{value:a,configurable:!0});import{createRequire as _}from"node:module";import l from"./EmailError-zm2ffVav.js";import I from"./RequiredOptionError-CevW3u2K.js";import{s as j}from"./generate-message-id-D4uA8gkj.js";import{i as C}from"./headers-to-record-Qo124ImV.js";import{m as p}from"./make-request-CaT4d5oC.js";import{c as E,P as S,u as h,h as y}from"./provider-base-Cmzx6BTO.js";import{d as $}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as q}from"./defineProvider-CtLH0VBE.js";import{f,a as z}from"./address-formatter-Cm_E_ZMa.js";const k=_(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=b(o=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[a,c]=m.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return m.getBuiltinModule(o)}return k(o)},"__cjs_getBuiltinModule"),{Buffer:A}=P("node:buffer"),i="mailtrap",M="https://send.api.mailtrap.io",x=3e4,G=3,K=q((o={})=>{if(!o.apiToken)throw new I(i,"apiToken");const a={apiToken:o.apiToken,debug:o.debug??!1,endpoint:o.endpoint??M,retries:o.retries??G,timeout:o.timeout??x,...o.logger&&{logger:o.logger}},c=new S,n=E(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":a.apiToken,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await h(async()=>p(`${a.endpoint}/api/send/${e}`,{headers:r,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(r){return{error:y(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":a.apiToken,"Content-Type":"application/json"};n.debug("Checking Mailtrap API availability");const r=await p(`${a.endpoint}/api/account`,{headers:e,method:"GET",timeout:a.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:a,async sendEmail(e){try{const r=$(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=z(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 s=C(e.headers);t.headers=s}e.attachments&&e.attachments.length>0&&(t.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 w=await s.content;u=A.from(w).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 l(i,`Attachment ${s.filename} has no content`);return{content:u,filename:s.filename,type:s.contentType??"application/octet-stream",...s.cid&&{cid:s.cid}}}))),n.debug("Sending email via Mailtrap API",{subject:t.subject,to:t.to});const v={"Api-Token":a.apiToken,"Content-Type":"application/json"},d=await h(async()=>p(`${a.endpoint}/api/send`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.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]??j();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:y(i,"send email",r,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{K as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var A=Object.defineProperty;var h=(i,s)=>A(i,"name",{value:s,configurable:!0});import{createRequire as T}from"node:module";import d from"./EmailError-zm2ffVav.js";import k from"./RequiredOptionError-CevW3u2K.js";import{s as z}from"./generate-message-id-D4uA8gkj.js";import{i as E}from"./headers-to-record-Qo124ImV.js";import{m as f}from"./make-request-CaT4d5oC.js";import{c as M,P as q,u as v,h as w}from"./provider-base-Cmzx6BTO.js";import{s as _,a as K}from"./sanitize-header-wWav-Scu.js";import{d as N}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as O}from"./defineProvider-CtLH0VBE.js";import{g as y}from"./address-formatter-Cm_E_ZMa.js";const C=T(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=h(i=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,m]=g.versions.node.split(".").map(Number);if(s>22||s===22&&m>=3||s===20&&m>=16)return g.getBuiltinModule(i)}return C(i)},"__cjs_getBuiltinModule"),{Buffer:S}=I("node:buffer"),r="mandrill",V="https://mandrillapp.com/api/1.0",D=3e4,R=3,Y=O((i={})=>{if(!i.apiKey)throw new k(r,"apiKey");const s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??V,retries:i.retries??R,timeout:i.timeout??D,...i.logger&&{logger:i.logger}},m=new q,n=M(r,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(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r),n.debug("Retrieving email details",{id:e});const l={id:e,key:s.apiKey},t={"Content-Type":"application/json"},o=await v(async()=>f(`${s.endpoint}/messages/info.json`,{headers:t,method:"POST",timeout:s.timeout},JSON.stringify(l)),s.retries);return o.success?(n.debug("Email details retrieved successfully"),{data:o.data?.body,success:!0}):(n.debug("API request failed when retrieving email",o.error),{error:new d(r,`Failed to retrieve email: ${o.error instanceof Error?o.error.message:"Unknown error"}`,{cause:o.error}),success:!1})}catch(l){return{error:w(r,"retrieve email",l,n),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(r,"Mandrill API not available or invalid API key");n.debug("Provider initialized successfully")},r)},async isAvailable(){try{n.debug("Checking Mandrill API availability");const e={key:s.apiKey},l={"Content-Type":"application/json"},t=await f(`${s.endpoint}/users/info.json`,{headers:l,method:"POST",timeout:s.timeout},JSON.stringify(e));return n.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 n.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const l=N(e);if(l.length>0)return{error:new d(r,`Invalid email options: ${l.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);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?`${_(e.replyTo.name)} <${e.replyTo.email}>`:e.replyTo.email;t.headers={"Reply-To":a}}if(e.headers){const a=E(e.headers),c={};Object.entries(a).forEach(([p,P])=>{c[K(p)]=_(P)}),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=S.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(r,`Attachment ${a.filename} has no content`);return{content:c,name:a.filename,type:a.contentType??"application/octet-stream"}})));const o={key:s.apiKey,message:t};e.templateName&&(o.template_name=e.templateName,e.templateContent&&(o.template_content=e.templateContent),e.templateVariables&&(o.template_vars=e.templateVariables)),e.globalMergeVars&&(t.global_merge_vars=e.globalMergeVars),e.mergeVars&&(t.merge_vars=e.mergeVars),e.sendAt&&(o.send_at=e.sendAt),n.debug("Sending email via Mandrill API",{subject:t.subject,to:t.to});const j={"Content-Type":"application/json"},u=await v(async()=>f(`${s.endpoint}/messages/send.json`,{headers:j,method:"POST",timeout:s.timeout},JSON.stringify(o)),s.retries);if(!u.success)return n.debug("API request failed when sending email",u.error),{error:u.error??new d(r,"Failed to send email"),success:!1};const b=u.data?.body?.[0]?.id??z();return n.debug("Email sent successfully",{messageId:b}),{data:{messageId:b,provider:r,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(l){return{error:w(r,"send email",l,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Y as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var j=Object.defineProperty;var b=(i,t)=>j(i,"name",{value:t,configurable:!0});import{createRequire as A}from"node:module";import m from"./EmailError-zm2ffVav.js";import z from"./RequiredOptionError-CevW3u2K.js";import{s as h}from"./generate-message-id-D4uA8gkj.js";import{i as E}from"./headers-to-record-Qo124ImV.js";import{m as v}from"./make-request-CaT4d5oC.js";import{c as K,P as x,u as w,h as P}from"./provider-base-Cmzx6BTO.js";import{a as S,s as q}from"./sanitize-header-wWav-Scu.js";import{d as B}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as R}from"./defineProvider-CtLH0VBE.js";const $=A(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=b(i=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,u]=f.versions.node.split(".").map(Number);if(t>22||t===22&&u>=3||t===20&&u>=16)return f.getBuiltinModule(i)}return $(i)},"__cjs_getBuiltinModule"),{Buffer:k}=T("node:buffer");var O=Object.defineProperty,C=b((i,t)=>O(i,"name",{value:t,configurable:!0}),"b");const s="plunk",D="https://api.useplunk.com/v1",H=3e4,N=3,Z=R((i={})=>{if(!i.apiKey)throw new z(s,"apiKey");const t={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??D,logger:i.logger,retries:i.retries??N,timeout:i.timeout??H},u=new x,n=K(s,i.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 m(s,"Email ID is required to retrieve email details"),success:!1};await u.ensureInitialized(()=>this.initialize(),s);const c={Authorization:`Bearer ${t.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const l=await w(async()=>v(`${t.endpoint}/emails/${e}`,{headers:c,method:"GET",timeout:t.timeout}),t.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 m(s,`Failed to retrieve email: ${l.error instanceof Error?l.error.message:"Unknown error"}`,{cause:l.error}),success:!1})}catch(c){return{error:P(s,"retrieve email",c,n),success:!1}}},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new m(s,"Plunk API not available or invalid API key");n.debug("Provider initialized successfully")},s)},async isAvailable(){try{return t.apiKey&&t.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:s,options:t,async sendEmail(e){try{const c=B(e);if(c.length>0)return{error:new m(s,`Invalid email options: ${c.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),s);const l=C(r=>Array.isArray(r)?r.map(o=>o.email):[r.email],"formatRecipients"),a={to:e.subscriber??(Array.isArray(e.to)?e.to[0]?.email:e.to.email)};if(e.from&&(a.from=e.from.email,e.from.name&&(a.from_name=e.from.name)),e.subject&&(a.subject=e.subject),e.html?a.body=e.html:e.text&&(a.body=e.text),e.html&&e.text&&(a.text=e.text),e.cc&&(a.cc=l(e.cc)),e.bcc&&(a.bcc=l(e.bcc)),e.replyTo&&(a.reply_to=e.replyTo.email,e.replyTo.name&&(a.reply_to_name=e.replyTo.name)),e.templateId&&(a.template=e.templateId),e.data&&(a.data=e.data),e.subscriberId&&(a.subscriber_id=e.subscriberId),e.headers){const r=E(e.headers),o={};Object.entries(r).forEach(([y,_])=>{o[S(y)]=q(_)}),a.headers=o}e.attachments&&e.attachments.length>0&&(a.attachments=await Promise.all(e.attachments.map(async r=>{let o;if(r.content)if(typeof r.content=="string")o=r.content;else if(r.content instanceof Promise){const y=await r.content;o=k.from(y).toString("base64")}else o=r.content.toString("base64");else if(r.raw)o=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new m(s,`Attachment ${r.filename} has no content`);return{content:o,filename:r.filename,type:r.contentType??"application/octet-stream"}}))),n.debug("Sending email via Plunk API",{subject:a.subject,to:a.to});const I={Authorization:`Bearer ${t.apiKey}`,"Content-Type":"application/json"},d=await w(async()=>v(`${t.endpoint}/send`,{headers:I,method:"POST",timeout:t.timeout},JSON.stringify(a)),t.retries);if(!d.success)return n.debug("API request failed when sending email",d.error),{error:d.error??new m(s,"Failed to send email"),success:!1};const p=d.data,g=p?.body&&typeof p.body=="object"?p.body.id??p.body.messageId??h():h();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:s,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(c){return{error:P(s,"send email",c,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Z as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var I=Object.defineProperty;var y=(r,l)=>I(r,"name",{value:l,configurable:!0});import{createRequire as A}from"node:module";import c from"./EmailError-zm2ffVav.js";import b from"./RequiredOptionError-CevW3u2K.js";import{s as T}from"./generate-message-id-D4uA8gkj.js";import{i as E}from"./headers-to-record-Qo124ImV.js";import{m as g}from"./make-request-CaT4d5oC.js";import{c as C,P as K,u as v}from"./provider-base-Cmzx6BTO.js";import{d as k}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as q}from"./defineProvider-CtLH0VBE.js";import{h as f,i as w}from"./address-formatter-Cm_E_ZMa.js";const j=A(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=y(r=>{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(r)}return j(r)},"__cjs_getBuiltinModule"),{Buffer:S}=$("node:buffer"),i="postal",z=3e4,x=3,J=q((r={})=>{if(!r.host)throw new b(i,"host");if(!r.apiKey)throw new b(i,"apiKey");const l=r.endpoint??`https://${r.host}/api/v1`,n={apiKey:r.apiKey,debug:r.debug??!1,endpoint:l,host:r.host,retries:r.retries??x,timeout:r.timeout??z,...r.logger&&{logger:r.logger}},p=new K,o=C(i,r.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(i,"Email ID is required to retrieve email details"),success:!1};await p.ensureInitialized(()=>this.initialize(),i);const t={"Content-Type":"application/json","X-Server-API-Key":n.apiKey};o.debug("Retrieving email details",{id:e});const a=await v(async()=>g(`${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(i,`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(i,`Failed to retrieve email: ${t.message}`,{cause:t}),success:!1}}},async initialize(){await p.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(i,"Postal API not available or invalid API key");o.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={"Content-Type":"application/json","X-Server-API-Key":n.apiKey};o.debug("Checking Postal API availability");const t=await g(`${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:i,options:n,async sendEmail(e){try{const t=k(e);if(t.length>0)return{error:new c(i,`Invalid email options: ${t.join(", ")}`),success:!1};await p.ensureInitialized(()=>this.initialize(),i);const a={from:w(e.from).address,subject:e.subject,to:f(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=f(e.cc).map(s=>s.address)),e.bcc&&(a.bcc=f(e.bcc).map(s=>s.address)),e.replyTo&&(a.reply_to=w(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=E(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 _=await s.content;u=S.from(_).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(i,`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 P={"Content-Type":"application/json","X-Server-API-Key":n.apiKey},d=await v(async()=>g(`${n.endpoint}/send/message`,{headers:P,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(i,"Failed to send email"),success:!1};const h=d.data?.body?.message_id?.toString()??T();return o.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:i,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return o.debug("Exception sending email",t),{error:new c(i,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{J as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import d from"./EmailError-zm2ffVav.js";import T from"./RequiredOptionError-CevW3u2K.js";import{s as P}from"./generate-message-id-D4uA8gkj.js";import{i as w}from"./headers-to-record-Qo124ImV.js";import{m as u}from"./make-request-CaT4d5oC.js";import{c as I,P as A,u as f,h}from"./provider-base-Cmzx6BTO.js";import{s as C,a as S}from"./sanitize-header-wWav-Scu.js";import{d as j}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as E}from"./defineProvider-CtLH0VBE.js";import{b as p,c as v}from"./address-formatter-Cm_E_ZMa.js";import{b as z}from"./attachment-processor-DsmIomKc.js";const r="postmark",M="https://api.postmarkapp.com",$=3e4,O=3,V=E((o={})=>{if(!o.serverToken)throw new T(r,"serverToken");const s={debug:o.debug??!1,endpoint:o.endpoint??M,retries:o.retries??O,serverToken:o.serverToken,timeout:o.timeout??$,...o.logger&&{logger:o.logger}},m=new A,i=I(r,o.logger);return{endpoint:s.endpoint,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 d(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const a={"Content-Type":"application/json","X-Postmark-Server-Token":s.serverToken};i.debug("Retrieving email details",{id:e});const t=await f(async()=>u(`${s.endpoint}/messages/outbound/${e}/details`,{headers:a,method:"GET",timeout:s.timeout}),s.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new d(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:h(r,"retrieve email",a,i),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(r,"Postmark API not available or invalid server token");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={"Content-Type":"application/json","X-Postmark-Server-Token":s.serverToken};i.debug("Checking Postmark API availability");const a=await u(`${s.endpoint}/server`,{headers:e,method:"GET",timeout:s.timeout});return i.debug("Postmark API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const a=j(e);if(a.length>0)return{error:new d(r,`Invalid email options: ${a.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={From:v(e.from),Subject:e.subject,To:p(e.to).join(",")};if(e.html&&(t.HtmlBody=e.html),e.text&&(t.TextBody=e.text),e.cc&&(t.Cc=p(e.cc).join(",")),e.bcc&&(t.Bcc=p(e.bcc).join(",")),e.replyTo&&(t.ReplyTo=v(e.replyTo)),e.templateId?(t.TemplateId=e.templateId,e.templateModel&&(t.TemplateModel=e.templateModel)):e.templateAlias&&(t.TemplateAlias=e.templateAlias,e.templateModel&&(t.TemplateModel=e.templateModel)),e.trackOpens!==void 0&&(t.TrackOpens=e.trackOpens),e.trackLinks!==void 0&&(t.TrackLinks=e.trackLinks),e.inlineCss!==void 0&&(t.InlineCss=e.inlineCss),e.messageStream&&(t.MessageStream=e.messageStream),e.metadata&&(t.Metadata=e.metadata),e.tags&&e.tags.length>0){const[l]=e.tags;t.Tag=l}if(e.headers){const l=w(e.headers),c=[];for(const[b,y]of Object.entries(l))c.push({Name:S(b),Value:C(String(y))});c.length>0&&(t.Headers=c)}e.attachments&&e.attachments.length>0&&(t.Attachments=await Promise.all(e.attachments.map(async l=>z(l,r)))),i.debug("Sending email via Postmark API",{subject:t.Subject,to:t.To});const k={"Content-Type":"application/json","X-Postmark-Server-Token":s.serverToken},n=await f(async()=>u(`${s.endpoint}/email`,{headers:k,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!n.success)return i.debug("API request failed when sending email",n.error),{error:n.error??new d(r,"Failed to send email"),success:!1};const g=n.data?.body?.MessageID??P();return i.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:r,response:n.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:h(r,"send email",a,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{V as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var u=Object.defineProperty;var s=(t,e)=>u(t,"name",{value:e,configurable:!0});import c from"./EmailError-zm2ffVav.js";import{c as d}from"./create-logger-BiWdqFNg.js";var l=Object.defineProperty,f=s((t,e)=>l(t,"name",{value:e,configurable:!0}),"i");const o=f(async(t,e=3,i=300)=>{try{const r=await t();return r.success||e<=0?r:(await new Promise(a=>{setTimeout(()=>{a()},i)}),o(t,e-1,i*2))}catch(r){return e<=0?{error:r instanceof Error?r:new Error(String(r)),success:!1}:(await new Promise(a=>{setTimeout(()=>{a()},i)}),o(t,e-1,i*2))}},"retry");var g=Object.defineProperty,n=s((t,e)=>g(t,"name",{value:e,configurable:!0}),"o");class P{static{s(this,"ProviderState")}static{n(this,"ProviderState")}isInitialized=!1;get initialized(){return this.isInitialized}setInitialized(){this.isInitialized=!0}async ensureInitialized(e,i){if(!this.isInitialized)try{await e(),this.isInitialized=!0}catch(r){throw new c(i,`Failed to initialize: ${r.message}`,{cause:r})}}}const w=n((t,e)=>d(t,e),"createProviderLogger");n(t=>{if(!t.success||!t.data)return!1;const e=t.data;return typeof e.statusCode=="number"&&e.statusCode>=200&&e.statusCode<300},"isSuccessfulResponse");const z=n((t,e,i,r)=>{const a=`Failed to ${e}: ${i.message}`;return r&&r.debug(`Exception ${e}`,i),new c(t,a,{cause:i})},"handleProviderError");export{P,w as c,z as h,o as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var I=Object.defineProperty;var h=(r,a)=>I(r,"name",{value:a,configurable:!0});import c from"./EmailError-zm2ffVav.js";import P from"./RequiredOptionError-CevW3u2K.js";import{s as $}from"./generate-message-id-D4uA8gkj.js";import{i as j}from"./headers-to-record-Qo124ImV.js";import{m as f}from"./make-request-CaT4d5oC.js";import{c as T,P as C,u as y,h as b}from"./provider-base-Cmzx6BTO.js";import{d as E}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as S}from"./defineProvider-CtLH0VBE.js";import{b as z,c as v,l as w}from"./address-formatter-Cm_E_ZMa.js";var k=Object.defineProperty,K=h((r,a)=>k(r,"name",{value:a,configurable:!0}),"p");const n="resend",R="https://api.resend.com",_=3e4,x=3,D=K(r=>{const a=[],l=/^[\w-]+$/;return l.test(r.name)||a.push(`Tag name '${r.name}' must only contain ASCII letters, numbers, underscores, or dashes`),r.name.length>256&&a.push(`Tag name '${r.name}' exceeds maximum length of 256 characters`),l.test(r.value)||a.push(`Tag value '${r.value}' for tag '${r.name}' must only contain ASCII letters, numbers, underscores, or dashes`),a},"validateTag"),W=S((r={})=>{if(!r.apiKey)throw new P(n,"apiKey");const a={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??R,logger:r.logger,retries:r.retries??x,timeout:r.timeout??_},l=new C,o=T(n,r.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 i=await y(async()=>f(`${a.endpoint}/emails/${e}`,{headers:t,method:"GET",timeout:a.timeout}),a.retries);return i.success?(o.debug("Email details retrieved successfully"),{data:i.data?.body,success:!0}):(o.debug("API request failed when retrieving email",i.error),{error:new c(n,`Failed to retrieve email: ${i.error instanceof Error?i.error.message:"Unknown error"}`,{cause:i.error}),success:!1})}catch(t){return{error:b(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=E(e);if(t.length>0)return{error:new c(n,`Invalid email options: ${t.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),n);const i={from:v(e.from),headers:e.headers?j(e.headers):{},html:e.html,subject:e.subject,text:e.text,to:z(e.to)};if(e.cc&&(i.cc=w(e.cc)),e.bcc&&(i.bcc=w(e.bcc)),e.replyTo&&(i.reply_to=v(e.replyTo)),e.templateId&&(i.template=e.templateId,e.templateData&&(i.data=e.templateData)),e.scheduledAt&&(i.scheduled_at=typeof e.scheduledAt=="string"?e.scheduledAt:e.scheduledAt.toISOString()),e.tags&&e.tags.length>0){const s=[];if(e.tags.forEach(d=>{const p=D(d);p.length>0&&s.push(...p)}),s.length>0)return{error:new c(n,`Invalid email tags: ${s.join(", ")}`),success:!1};i.tags=e.tags.map(d=>({name:d.name,value:d.value}))}e.attachments&&e.attachments.length>0&&(i.attachments=await Promise.all(e.attachments.map(async s=>{let d;if(s.content)if(typeof s.content=="string")d=s.content;else if(s.content instanceof Promise){const p=await s.content;d=Buffer.from(p).toString("base64")}else d=s.content.toString("base64");else if(s.raw)d=typeof s.raw=="string"?s.raw:s.raw.toString("base64");else throw new c(n,`Attachment ${s.filename} has no content`);return{content:d,content_type:s.contentType,filename:s.filename,...s.path&&{path:s.path}}}))),o.debug("Sending email via Resend API",{subject:i.subject,to:i.to});const A={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},u=await y(async()=>f(`${a.endpoint}/emails`,{headers:A,method:"POST",timeout:a.timeout},JSON.stringify(i)),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:$();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:b(n,"send email",t,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{W as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var P=Object.defineProperty;var h=(r,l)=>P(r,"name",{value:l,configurable:!0});import{createRequire as A}from"node:module";import c from"./EmailError-zm2ffVav.js";import y from"./RequiredOptionError-CevW3u2K.js";import{s as E}from"./generate-message-id-D4uA8gkj.js";import{i as k}from"./headers-to-record-Qo124ImV.js";import{m as b}from"./make-request-CaT4d5oC.js";import{c as z,P as q,u as w,h as v}from"./provider-base-Cmzx6BTO.js";import{d as K}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as C}from"./defineProvider-CtLH0VBE.js";import{f as p,a as x}from"./address-formatter-Cm_E_ZMa.js";const T=A(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=h(r=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[l,s]=u.versions.node.split(".").map(Number);if(l>22||l===22&&s>=3||l===20&&s>=16)return u.getBuiltinModule(r)}return T(r)},"__cjs_getBuiltinModule"),{Buffer:_}=S("node:buffer"),a="scaleway",R="https://api.scaleway.com/transactional-email/v1alpha1",B=3e4,G=3,U=C((r={})=>{if(!r.apiKey)throw new y(a,"apiKey");if(!r.region)throw new y(a,"region");const l=r.endpoint??R,s={apiKey:r.apiKey,debug:r.debug??!1,endpoint:l,region:r.region,retries:r.retries??G,timeout:r.timeout??B,...r.logger&&{logger:r.logger}},f=new q,n=z(a,r.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 c(a,"Email ID is required to retrieve email details"),success:!1};await f.ensureInitialized(()=>this.initialize(),a);const o={"Content-Type":"application/json","X-Auth-Token":s.apiKey};n.debug("Retrieving email details",{id:e});const t=await w(async()=>b(`${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 c(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:v(a,"retrieve email",o,n),success:!1}}},async initialize(){await f.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(a,"Scaleway API not available or invalid API key");n.debug("Provider initialized successfully")},a)},async isAvailable(){try{return n.debug("Checking Scaleway API availability"),!0}catch(e){return n.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{const o=K(e);if(o.length>0)return{error:new c(a,`Invalid email options: ${o.join(", ")}`),success:!1};await f.ensureInitialized(()=>this.initialize(),a);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=x(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.projectId&&(t.projectId=e.projectId),e.headers){const i=k(e.headers);t.headers=i}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async i=>{let d;if(i.content)if(typeof i.content=="string")d=i.content;else if(i.content instanceof Promise){const j=await i.content;d=_.from(j).toString("base64")}else d=i.content.toString("base64");else if(i.raw)d=typeof i.raw=="string"?i.raw:i.raw.toString("base64");else throw new c(a,`Attachment ${i.filename} has no content`);return{content:d,name:i.filename,type:i.contentType??"application/octet-stream"}}))),n.debug("Sending email via Scaleway API",{subject:t.subject,to:t.to});const I={"Content-Type":"application/json","X-Auth-Token":s.apiKey},m=await w(async()=>b(`${s.endpoint}/regions/${s.region}/emails`,{headers:I,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 c(a,"Failed to send email"),success:!1};const g=m.data?.body?.id??E();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:v(a,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import l from"./EmailError-zm2ffVav.js";import A from"./RequiredOptionError-CevW3u2K.js";import{s as P}from"./generate-message-id-D4uA8gkj.js";import{i as S}from"./headers-to-record-Qo124ImV.js";import{m as h}from"./make-request-CaT4d5oC.js";import{c as $,P as j,u as b,h as v}from"./provider-base-Cmzx6BTO.js";import{d as G}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as k}from"./defineProvider-CtLH0VBE.js";import{f,a as I}from"./address-formatter-Cm_E_ZMa.js";import{c as z}from"./attachment-processor-DsmIomKc.js";const s="sendgrid",C="https://api.sendgrid.com/v3",E=3e4,_=3,R=k((o={})=>{if(!o.apiKey)throw new A(s,"apiKey");const a={apiKey:o.apiKey,debug:o.debug??!1,endpoint:o.endpoint??C,...o.logger&&{logger:o.logger},retries:o.retries??_,timeout:o.timeout??E},p=new j,i=$(s,o.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 l(s,"Email ID is required to retrieve email details"),success:!1};await p.ensureInitialized(()=>this.initialize(),s);const t={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const r=await b(async()=>h(`${a.endpoint}/messages/${e}`,{headers:t,method:"GET",timeout:a.timeout}),a.retries);return r.success?(i.debug("Email details retrieved successfully"),{data:r.data?.body,success:!0}):(i.debug("API request failed when retrieving email",r.error),{error:new l(s,`Failed to retrieve email: ${r.error instanceof Error?r.error.message:"Unknown error"}`,{cause:r.error}),success:!1})}catch(t){return{error:v(s,"retrieve email",t,i),success:!1}}},async initialize(){await p.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(s,"SendGrid API not available or invalid API key");i.debug("Provider initialized successfully")},s)},async isAvailable(){try{if(a.apiKey&&a.apiKey.startsWith("SG."))return i.debug("API key format is valid, assuming SendGrid is available"),!0;const e={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Checking SendGrid API availability");const t=await h(`${a.endpoint}/user/profile`,{headers:e,method:"GET",timeout:a.timeout});return i.debug("SendGrid 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 i.debug("Error checking availability:",e),!1}},name:s,options:a,async sendEmail(e){try{const t=G(e);if(t.length>0)return{error:new l(s,`Invalid email options: ${t.join(", ")}`),success:!1};await p.ensureInitialized(()=>this.initialize(),s);const r={to:f(e.to)};if(e.cc&&(r.cc=f(e.cc)),e.bcc&&(r.bcc=f(e.bcc)),e.subject&&(r.subject=e.subject),e.tags&&e.tags.length>0){const d={};for(let m=0;m<e.tags.length;m+=1)d[`tag_${m}`]=e.tags[m];r.customArgs=d}const n={from:I(e.from),personalizations:[r]},u=[];if(e.html&&u.push({type:"text/html",value:e.html}),e.text&&u.push({type:"text/plain",value:e.text}),u.length>0&&(n.content=u),e.replyTo&&(n.reply_to=I(e.replyTo)),e.subject&&(n.subject=e.subject),e.templateId&&(n.template_id=e.templateId,e.templateData&&(r.dynamicTemplateData=e.templateData)),e.sendAt&&(r.send_at=e.sendAt),e.batchId&&(n.batch_id=e.batchId),e.asmGroupId&&(n.asm={group_id:e.asmGroupId}),e.ipPoolName&&(n.ip_pool_name=e.ipPoolName),e.mailSettings&&(n.mail_settings=e.mailSettings),e.trackingSettings&&(n.tracking_settings=e.trackingSettings),e.headers){const d=S(e.headers);n.headers=d}e.attachments&&e.attachments.length>0&&(n.attachments=await Promise.all(e.attachments.map(async d=>z(d,s)))),i.debug("Sending email via SendGrid API",{subject:n.subject,to:r.to});const w={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},c=await b(async()=>h(`${a.endpoint}/mail/send`,{headers:w,method:"POST",timeout:a.timeout},JSON.stringify(n)),a.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new l(s,"Failed to send email"),success:!1};const g=c.data?.headers,y=(g&&g instanceof Headers?g.get("X-Message-Id"):void 0)??P();return i.debug("Email sent successfully",{messageId:y}),{data:{messageId:y,provider:s,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:v(s,"send email",t,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{R as default};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var X=Object.defineProperty;var C=(u,r)=>X(u,"name",{value:r,configurable:!0});import{createRequire as q}from"node:module";import m from"./EmailError-zm2ffVav.js";import J from"./RequiredOptionError-CevW3u2K.js";import{z as ee}from"./build-mime-message-6xstxaUV.js";import{s as te}from"./generate-message-id-D4uA8gkj.js";import{d as re}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as oe}from"./defineProvider-CtLH0VBE.js";const W=q(import.meta.url),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=C(u=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[r,y]=O.versions.node.split(".").map(Number);if(r>22||r===22&&y>=3||r===20&&y>=16)return O.getBuiltinModule(u)}return W(u)},"__cjs_getBuiltinModule"),{Buffer:v}=M("node:buffer"),{createHmac:K,createHash:Y,createSign:Q}=M("node:crypto"),{Socket:V,createConnection:Z}=M("node:net"),{connect:z}=M("node:tls");var se=Object.defineProperty,_=C((u,r)=>se(u,"name",{value:r,configurable:!0}),"n");const ae=_((u,r)=>new Promise(y=>{const f=new V,g=_(()=>{f.destroy(),y(!1)},"onError");f.setTimeout(1e3),f.on("error",g),f.on("timeout",g),f.connect(r,u,()=>{f.end(),y(!0)})}),"isPortAvailable");var ne=Object.defineProperty,p=C((u,r)=>ne(u,"name",{value:r,configurable:!0}),"h");const l="smtp",ie=25,ce=465,ue=1e4,le=!1,me=5,x=3e4,be=oe((u={})=>{if(!u.host)throw new J(l,"host");const r={authMethod:u.authMethod??"LOGIN",debug:u.debug??!1,dkim:u.dkim,host:u.host,maxConnections:u.maxConnections??me,oauth2:u.oauth2,password:u.password,pool:u.pool??!1,port:u.port!==void 0?u.port:u.secure?ce:ie,rejectUnauthorized:u.rejectUnauthorized??!0,retries:u.retries??0,secure:u.secure??le,timeout:u.timeout??ue,user:u.user,...u.logger&&{logger:u.logger}};let y=!1;const f=[],g=[],b=p(e=>e.replaceAll(/[\r\n\t\v\f]/g," ").trim(),"sanitizeHeaderValue"),U=p(e=>{const c=e.split(`\r
|
|
2
|
-
`),s={};for(const i of c)if(i.startsWith("250-")||i.startsWith("250 ")){const n=i.slice(4).trim().split(" "),o=n[0];o&&(s[o]=n.slice(1))}return s},"parseEhloResponse"),h=p(async(e,c,s)=>new Promise((i,n)=>{const o=Array.isArray(s)?s:[s];let a="",t="";const d=setTimeout(()=>{w(),n(new m(l,`Command timeout after ${r.timeout}ms: ${c?.slice(0,50)}...`))},r.timeout),w=p(()=>{e.removeListener("data",$),e.removeListener("error",L),d&&clearTimeout(d)},"cleanup"),$=p(S=>{a+=S.toString();const k=a.split(`\r
|
|
3
|
-
`).filter(Boolean);if(k.length>0){const j=k.at(-1);if(j){const I=j.match(/^(\d{3})[\s-]/);if(I){const[,R]=I;t=R,j[3]===" "&&(w(),o.includes(t)?i(a):n(new m(l,`Expected ${o.join(" or ")}, got ${t}: ${a.trim()}`)))}}}},"onData"),L=p(S=>{w(),n(new m(l,`Socket error: ${S.message}`,{cause:S}))},"onError");e.on("data",$),e.on("error",L),c&&e.write(`${c}\r
|
|
4
|
-
`)}),"sendSmtpCommand"),H=p(async()=>{if(r.pool&&f.length>0){const e=f.pop();if(e&&!e.destroyed)return e}return r.pool&&f.length+1>=r.maxConnections?new Promise((e,c)=>{const s={reject:c,resolve:e};s.timeout=setTimeout(()=>{const i=g.indexOf(s);i!==-1&&g.splice(i,1),c(new m(l,`Connection queue timeout after ${x}ms`))},x),g.push(s)}):new Promise((e,c)=>{let s,i=!1,n;const o=p(()=>{s&&clearTimeout(s)},"cleanup");s=setTimeout(()=>{i||(i=!0,n&&!n.destroyed&&n.destroy(),o(),c(new m(l,`Connection timeout to ${r.host}:${r.port} after ${r.timeout}ms`)))},r.timeout);try{n=r.secure?z({host:r.host,port:r.port,rejectUnauthorized:r.rejectUnauthorized}):Z(r.port,r.host),n.on("error",a=>{i||(i=!0,o(),c(new m(l,`Connection error: ${a.message}`,{cause:a})))}),n.once("data",a=>{if(!i&&n){i=!0,o();const t=a.toString();t.slice(0,3)==="220"?e(n):(n.destroy(),c(new m(l,`Unexpected server greeting: ${t.trim()}`)))}})}catch(a){i||(i=!0,o(),c(new m(l,`Failed to create connection: ${a.message}`,{cause:a})))}})},"createSmtpConnection"),D=p(async e=>new Promise((c,s)=>{let i,n=!1,o;const a=p(()=>{i&&clearTimeout(i)},"cleanup");i=setTimeout(()=>{n||(n=!0,o&&!o.destroyed&&o.destroy(),a(),s(new m(l,`TLS connection timeout after ${r.timeout}ms`)))},r.timeout);try{const t={host:r.host,rejectUnauthorized:r.rejectUnauthorized,socket:e};o=z(t),o.on("error",d=>{n||(n=!0,a(),s(new m(l,`TLS connection error: ${d.message}`,{cause:d})))}),o.once("secure",()=>{!n&&o&&(n=!0,a(),c(o))})}catch(t){n||(n=!0,a(),s(new m(l,`Failed to upgrade to TLS: ${t.message}`,{cause:t})))}}),"upgradeToTLS"),F=p(e=>{if(e.destroyed||!r.pool){try{e.destroy()}catch{}return}if(g.length>0){const c=g.shift();if(c){clearTimeout(c.timeout),c.resolve(e);return}}f.push(e)},"releaseConnection"),T=p(async(e,c=!1)=>new Promise(s=>{try{if(c){e.write(`RSET\r
|
|
5
|
-
`),F(e),s();return}e.write(`QUIT\r
|
|
6
|
-
`),e.end(),e.once("close",()=>{s()})}catch{s()}}),"closeConnection"),E=p(async e=>{if(!r.user)return;const c=await h(e,`EHLO ${r.host}`,"250"),s=U(c),i=Object.keys(s).find(a=>a.toUpperCase()==="AUTH");if(!i&&(r.user||r.password))throw new m(l,"Server does not support authentication");const n=i?s[i]??[]:[];let{authMethod:o}=r;if(o||(n.includes("CRAM-MD5")?o="CRAM-MD5":n.includes("LOGIN")?o="LOGIN":n.includes("PLAIN")&&(o="PLAIN")),!o)throw new m(l,"No supported authentication methods");if(o==="OAUTH2"&&r.oauth2)try{const{accessToken:a,user:t}=r.oauth2,d=`user=${t}auth=Bearer ${a}`,w=v.from(d).toString("base64");await h(e,`AUTH XOAUTH2 ${w}`,"235");return}catch(a){const t=a.message;throw t.includes("535")||t.includes("Authentication failed")?new m(l,"Authentication failed: Invalid OAuth2 credentials"):a}if(o==="CRAM-MD5"&&r.password)try{const a=(await h(e,"AUTH CRAM-MD5","334")).split(" ")[1];if(!a)throw new m(l,"Invalid CRAM-MD5 challenge response");const t=v.from(a,"base64").toString("utf8"),d=K("md5",r.password);d.update(t);const w=d.digest("hex"),$=`${r.user} ${w}`;await h(e,v.from($).toString("base64"),"235");return}catch(a){const t=a.message;throw t.includes("535")||t.includes("Authentication failed")?new m(l,"Authentication failed: Invalid username or password"):a}if(o==="LOGIN"&&r.password)try{await h(e,"AUTH LOGIN","334"),await h(e,v.from(r.user).toString("base64"),"334"),await h(e,v.from(r.password).toString("base64"),"235");return}catch(a){const t=a.message;throw t.includes("535")||t.includes("Authentication failed")?new m(l,"Authentication failed: Invalid username or password"):a}if(o==="PLAIN"&&r.password)try{const a=v.from(`\0${r.user}\0${r.password}`).toString("base64");await h(e,`AUTH PLAIN ${a}`,"235");return}catch(a){const t=a.message;throw t.includes("535")||t.includes("Authentication failed")?new m(l,"Authentication failed: Invalid username or password"):a}throw new m(l,"Authentication failed - no valid credentials or method")},"authenticate"),G=p(e=>{if(!r.dkim)return e;const{domainName:c,keySelector:s,privateKey:i}=r.dkim;try{const[n,o]=e.split(`\r
|
|
7
|
-
\r
|
|
8
|
-
`);if(!n||!o)return e;const a=n.split(`\r
|
|
9
|
-
`),t=p(A=>A.replaceAll(`\r
|
|
10
|
-
`,`
|
|
11
|
-
`).replaceAll(/\s+/g," ").trim(),"canonicalize"),d=t(o),w=Y("sha256").update(d).digest("base64"),$=["from","to","subject","date"],L=a.filter(A=>$.some(P=>A.toLowerCase().startsWith(`${P}:`))),S=L.map(A=>A.split(":")[0]?.toLowerCase()??"").filter(Boolean).join(":"),k=Math.floor(Date.now()/1e3),j={a:"rsa-sha256",bh:w,c:"relaxed/relaxed",d:c,h:S,s,t:k.toString(),v:"1"},I=`DKIM-Signature: ${Object.entries(j).map(([A,P])=>`${A}=${P}`).join("; ")}; b=`,R=[...L,I].map(A=>t(A)).join(`\r
|
|
12
|
-
`),N=Q("RSA-SHA256");N.update(R);const B=N.sign(i,"base64");return`${`${I}${B}`}\r
|
|
13
|
-
${a.join(`\r
|
|
14
|
-
`)}\r
|
|
15
|
-
\r
|
|
16
|
-
${o}`}catch(n){return console.error(`[${l}] DKIM signing error:`,n),e}},"signWithDkim");return{features:{attachments:!0,batchSending:r.pool,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!y)try{if(!await this.isAvailable())throw new m(l,`SMTP server not available at ${r.host}:${r.port}`);y=!0}catch(e){throw new m(l,`Failed to initialize: ${e.message}`,{cause:e})}},async isAvailable(){try{if(!await ae(r.host,r.port))return!1;const e=await H();return await T(e),!0}catch{return!1}},name:l,options:r,async sendEmail(e){try{const c=re(e);if(c.length>0)return{error:new m(l,`Invalid email options: ${c.join(", ")}`),success:!1};y||await this.initialize();let s=await H();try{if(await h(s,`EHLO ${r.host}`,"250"),!r.secure)try{const t=await h(s,`EHLO ${r.host}`,"250"),d=U(t);Object.keys(d).includes("STARTTLS")&&(await h(s,"STARTTLS","220"),s=await D(s),await h(s,`EHLO ${r.host}`,"250"))}catch(t){if(r.rejectUnauthorized)throw new m(l,`STARTTLS failed or not supported: ${t.message}`,{cause:t})}await E(s),await h(s,`MAIL FROM:<${e.from.email}>`,"250");const i=[];Array.isArray(e.to)?i.push(...e.to.map(t=>t.email)):i.push(e.to.email),e.cc&&(Array.isArray(e.cc)?i.push(...e.cc.map(t=>t.email)):i.push(e.cc.email)),e.bcc&&(Array.isArray(e.bcc)?i.push(...e.bcc.map(t=>t.email)):i.push(e.bcc.email));for(const t of i)await h(s,`RCPT TO:<${t}>`,"250");await h(s,"DATA","354");let n=await ee(e);const o=[];if(e.dsn){const t=[];e.dsn.success&&t.push("SUCCESS"),e.dsn.failure&&t.push("FAILURE"),e.dsn.delay&&t.push("DELAY"),t.length>0&&o.push(`X-DSN-NOTIFY: ${t.join(",")}`)}if(e.priority){let t="";switch(e.priority){case"high":{t="1 (Highest)",o.push("Importance: High");break}case"low":{t="5 (Lowest)",o.push("Importance: Low");break}case"normal":{t="3 (Normal)",o.push("Importance: Normal");break}default:{t="3 (Normal)";break}}o.push(`X-Priority: ${t}`)}if(e.inReplyTo&&o.push(`In-Reply-To: ${b(e.inReplyTo)}`),e.references){const t=Array.isArray(e.references)?e.references.map(d=>b(d)).join(" "):b(e.references);o.push(`References: ${t}`)}if(e.listUnsubscribe){const t=Array.isArray(e.listUnsubscribe)?e.listUnsubscribe.map(d=>`<${b(d)}>`).join(", "):`<${b(e.listUnsubscribe)}>`;o.push(`List-Unsubscribe: ${t}`)}if(e.googleMailHeaders){const{googleMailHeaders:t}=e;t.feedbackId&&o.push(`Feedback-ID: ${b(t.feedbackId)}`),t.promotionalContent&&o.push("X-Google-Promotion: promotional"),t.category&&o.push(`X-Gmail-Labels: ${t.category}`)}if(o.length>0){const t=n.indexOf(`\r
|
|
17
|
-
\r
|
|
18
|
-
`);if(t!==-1){const d=n.slice(0,t),w=n.slice(t+4);n=`${d}\r
|
|
19
|
-
${o.join(`\r
|
|
20
|
-
`)}\r
|
|
21
|
-
\r
|
|
22
|
-
${w}`}}r.dkim&&(e.useDkim||e.useDkim===void 0)&&(n=G(n)),await h(s,`${n}\r
|
|
23
|
-
.`,"250");const a=te();return await T(s,r.pool),{data:{messageId:a,provider:l,response:"Message accepted",sent:!0,timestamp:new Date},success:!0}}catch(i){try{await T(s)}catch{}throw i}}catch(c){return{error:new m(l,`Failed to send email: ${c.message}`,{cause:c}),success:!1}}},async shutdown(){for(const e of f)try{await T(e)}catch{}f.length=0;for(const e of g)clearTimeout(e.timeout),e.reject(new Error("Provider shutdown"));g.length=0},async validateCredentials(){try{if(!await this.isAvailable())return!1;const e=await H();try{if(await h(e,`EHLO ${r.host}`,"250"),!r.secure)try{const c=await h(e,`EHLO ${r.host}`,"250"),s=U(c);if(Object.keys(s).includes("STARTTLS")){await h(e,"STARTTLS","220");const i=await D(e);Object.assign(e,i),await h(e,`EHLO ${r.host}`,"250")}}catch{if(r.rejectUnauthorized)return!1}return await E(e),await T(e),!0}catch{return await T(e),!1}}catch{return!1}}}});export{be as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var P=Object.defineProperty;var h=(s,a)=>P(s,"name",{value:a,configurable:!0});import{createRequire as A}from"node:module";import l from"./EmailError-zm2ffVav.js";import T from"./RequiredOptionError-CevW3u2K.js";import{s as _}from"./generate-message-id-D4uA8gkj.js";import{i as z}from"./headers-to-record-Qo124ImV.js";import{m as y}from"./make-request-CaT4d5oC.js";import{c as E,P as k,u as b,h as w}from"./provider-base-Cmzx6BTO.js";import{d as q}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as K}from"./defineProvider-CtLH0VBE.js";import{f,a as B}from"./address-formatter-Cm_E_ZMa.js";const $=A(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=h(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 $(s)},"__cjs_getBuiltinModule"),{Buffer:S}=j("node:buffer"),i="sweego",x="https://api.sweego.com",C=3e4,R=3,Q=K((s={})=>{if(!s.apiKey)throw new T(i,"apiKey");const a={apiKey:s.apiKey,debug:s.debug??!1,endpoint:s.endpoint??x,retries:s.retries??R,timeout:s.timeout??C,...s.logger&&{logger:s.logger}},c=new k,n=E(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 b(async()=>y(`${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:w(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=q(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=B(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=z(e.headers);t.headers=r}e.attachments&&e.attachments.length>0&&(t.attachments=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=S.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 l(i,`Attachment ${r.filename} has no content`);return{content:m,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 v={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},d=await b(async()=>y(`${a.endpoint}/send`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.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,p=g?.messageId??g?.id??_();return n.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:i,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:w(i,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import l from"./EmailError-zm2ffVav.js";import y from"./RequiredOptionError-CevW3u2K.js";import{s as b}from"./generate-message-id-D4uA8gkj.js";import{i as k}from"./headers-to-record-Qo124ImV.js";import{m as v}from"./make-request-CaT4d5oC.js";import{c as w,P as A,u as z,h as _}from"./provider-base-Cmzx6BTO.js";import{a as j,s as P}from"./sanitize-header-wWav-Scu.js";import{d as I}from"./validate-email-options-DPo3SgC0.js";import{defineProvider as T}from"./defineProvider-CtLH0VBE.js";import{m as h}from"./address-formatter-Cm_E_ZMa.js";const i="zeptomail",O="https://api.zeptomail.com/v1.1",$=3e4,Z=3,F=T((s={})=>{if(!s.token)throw new y(i,"token");if(!s.token.startsWith("Zoho-enczapikey "))throw new l(i,'Token should be in the format "Zoho-enczapikey <your_api_key>"');const n={debug:s.debug??!1,endpoint:s.endpoint??O,logger:s.logger,retries:s.retries??Z,timeout:s.timeout??$,token:s.token},u=new A,o=w(i,s.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!0},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(i,"Zeptomail API not available or invalid token");o.debug("Provider initialized successfully")},i)},async isAvailable(){try{return n.token&&n.token.startsWith("Zoho-enczapikey ")?(o.debug("Token format is valid, assuming Zeptomail is available"),!0):!1}catch(e){return o.debug("Error checking availability:",e),!1}},name:i,options:n,async sendEmail(e){try{const m=I(e);if(m.length>0)return{error:new l(i,`Invalid email options: ${m.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),i);const a={from:h(e.from).address,subject:e.subject};if(Array.isArray(e.to)?a.to=e.to.length===1?e.to[0].email:e.to.map(t=>t.email):a.to=e.to.email,e.text&&(a.textbody=e.text),e.html&&(a.htmlbody=e.html),e.cc&&(Array.isArray(e.cc)?a.cc=e.cc.length===1?e.cc[0].email:e.cc.map(t=>t.email):a.cc=e.cc.email),e.bcc&&(Array.isArray(e.bcc)?a.bcc=e.bcc.length===1?e.bcc[0].email:e.bcc.map(t=>t.email):a.bcc=e.bcc.email),e.replyTo&&(a.reply_to=[h(e.replyTo).address]),e.trackClicks!==void 0&&(a.track_clicks=e.trackClicks),e.trackOpens!==void 0&&(a.track_opens=e.trackOpens),e.clientReference&&(a.client_reference=e.clientReference),e.mimeHeaders&&Object.keys(e.mimeHeaders).length>0){const t={};for(const[r,d]of Object.entries(e.mimeHeaders))t[r]=d;a.mime_headers=t}if(e.headers){const t=k(e.headers);Object.keys(t).length>0&&(a.mime_headers??={},Object.entries(t).forEach(([r,d])=>{a.mime_headers&&(a.mime_headers[j(r)]=P(d))}))}e.attachments&&e.attachments.length>0&&(a.attachments=e.attachments.map(t=>{const r={name:t.filename};return t.content?(r.content=typeof t.content=="string"?t.content:t.content.toString("base64"),t.contentType&&(r.mime_type=t.contentType)):t.path&&(r.file_cache_key=t.path),r})),o.debug("Sending email via Zeptomail API",{subject:a.subject,to:a.to});const g={Accept:"application/json",Authorization:n.token,"Content-Type":"application/json"},c=await z(async()=>v(`${n.endpoint}/email`,{headers:g,method:"POST",timeout:n.timeout},JSON.stringify(a)),n.retries);if(!c.success){o.debug("API request failed",c.error);let t=c.error instanceof Error?c.error.message:"Unknown error";const r=c.data;return r?.body?.message?t+=` Details: ${r.body.message}`:r?.body?.error?.message&&(t+=` Details: ${r.body.error.message}`),{error:new l(i,`Failed to send email: ${t}`,{cause:c.error}),success:!1}}const p=c.data?.body,f=p?.request_id??b();return o.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:i,response:p,sent:!0,timestamp:new Date},success:!0}}catch(m){return{error:_(i,"send email",m,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{F as default};
|