@visulima/email 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/README.md +48 -5
- package/dist/index.js +1 -1
- package/dist/middleware/index.d.ts +9 -2
- package/dist/middleware/index.js +1 -1
- package/dist/packem_shared/{Mail-C1zp-fqt.js → Mail-CYAwMRnX.js} +1 -1
- package/dist/packem_shared/{ahaSendProvider-D81_wUA1.js → ahaSendProvider-DSuZIzaQ.js} +1 -1
- package/dist/packem_shared/autoSendProvider-DqAoelWR.js +1 -0
- package/dist/packem_shared/{awsSesProvider-BGZJUIep.js → awsSesProvider-ClK1FUln.js} +1 -1
- package/dist/packem_shared/{azureProvider-CmcK4bsf.js → azureProvider-Cw_Tmde6.js} +1 -1
- package/dist/packem_shared/{brevoProvider-C1BDXr41.js → brevoProvider-CIzuIDlt.js} +1 -1
- package/dist/packem_shared/{build-mime-message-B6927SQy.js → build-mime-message-BW5FQ2Bt.js} +1 -1
- package/dist/packem_shared/{cloudflareEmailProvider-Bv-ty-74.js → cloudflareEmailProvider-B8mOEl3N.js} +1 -1
- package/dist/packem_shared/create-token-cache-D56KQGVQ.js +1 -0
- package/dist/packem_shared/{createTestEmail-D3XPGiHY.js → createTestEmail-f12yLlWn.js} +1 -1
- package/dist/packem_shared/{httpProvider-DJAsYSun.js → httpProvider-aBfTXyCT.js} +1 -1
- package/dist/packem_shared/{infobipProvider-lHyGrXgZ.js → infobipProvider-DxzsONUX.js} +1 -1
- package/dist/packem_shared/{loopsProvider-DyloxzNC.js → loopsProvider-QBsAH6Ee.js} +1 -1
- package/dist/packem_shared/{mailCrabProvider-CPtBT6Th.js → mailCrabProvider-DRE5snM9.js} +1 -1
- package/dist/packem_shared/{mailPaceProvider-CJEvOFBh.js → mailPaceProvider-DCa-4ghl.js} +1 -1
- package/dist/packem_shared/{mailchannelsProvider-osRkW_tz.js → mailchannelsProvider-GiwkYBdD.js} +1 -1
- package/dist/packem_shared/{mailerSendProvider-C_6LzARK.js → mailerSendProvider-RK6IbUrL.js} +1 -1
- package/dist/packem_shared/{mailgunProvider-DkISvMPe.js → mailgunProvider-D9HUWGKN.js} +1 -1
- package/dist/packem_shared/{mailjetProvider-CV0i4Xzh.js → mailjetProvider-DelLs2Vt.js} +1 -1
- package/dist/packem_shared/{mailomatProvider-B5YFonEO.js → mailomatProvider-DPDpVS8r.js} +1 -1
- package/dist/packem_shared/{mailtrapProvider-C4ZquIPz.js → mailtrapProvider-DtrS4Q34.js} +1 -1
- package/dist/packem_shared/make-request-B9XjBynA.js +1 -0
- package/dist/packem_shared/{mandrillProvider-DWPFh_Sj.js → mandrillProvider-B84zH-eV.js} +1 -1
- package/dist/packem_shared/{netcoreProvider-C5TEciaN.js → netcoreProvider-D-wtCyJj.js} +1 -1
- package/dist/packem_shared/oauth2Middleware-DQh-hIkv.js +1 -0
- package/dist/packem_shared/outlook365Provider-Btk4Emig.js +1 -0
- package/dist/packem_shared/{plunkProvider-yTlrJVEp.js → plunkProvider-Bw8e6460.js} +1 -1
- package/dist/packem_shared/{postalProvider-CRX_bMYD.js → postalProvider-CT8zr89z.js} +1 -1
- package/dist/packem_shared/{postmarkProvider-CDx85Yge.js → postmarkProvider-CQSqZWDs.js} +1 -1
- package/dist/packem_shared/{resendProvider-CiclWxzr.js → resendProvider-drJYlvLP.js} +1 -1
- package/dist/packem_shared/retry-ipI5DRJ8.js +1 -0
- package/dist/packem_shared/{sanitize-header-DJhgZl3y.js → sanitize-header-DtQwAnzg.js} +1 -1
- package/dist/packem_shared/{scalewayProvider-BcND48qO.js → scalewayProvider-DU5gXQrl.js} +1 -1
- package/dist/packem_shared/{sendGridProvider-D8ZLgY62.js → sendGridProvider-BuTbEXW8.js} +1 -1
- package/dist/packem_shared/{smtpProvider-Bm0yP97W.js → smtpProvider-5MI3-EPh.js} +1 -1
- package/dist/packem_shared/{sparkpostProvider-CTYfSRaV.js → sparkpostProvider-UAsFYIjP.js} +1 -1
- package/dist/packem_shared/{sweegoProvider-DOoin_vi.js → sweegoProvider-SUz0LIcA.js} +1 -1
- package/dist/packem_shared/{zeptomailProvider-DKBPSHPj.js → zeptomailProvider-DXNX9mG_.js} +1 -1
- package/dist/providers/ahasend/index.js +1 -1
- package/dist/providers/autosend/index.d.ts +56 -0
- package/dist/providers/autosend/index.js +1 -0
- package/dist/providers/aws-ses/index.js +1 -1
- package/dist/providers/azure/index.js +1 -1
- package/dist/providers/brevo/index.js +1 -1
- package/dist/providers/cloudflare-email/index.js +1 -1
- package/dist/providers/http/index.js +1 -1
- package/dist/providers/infobip/index.js +1 -1
- package/dist/providers/loops/index.js +1 -1
- package/dist/providers/mailchannels/index.js +1 -1
- package/dist/providers/mailcrab/index.js +1 -1
- package/dist/providers/mailersend/index.js +1 -1
- package/dist/providers/mailgun/index.js +1 -1
- package/dist/providers/mailjet/index.js +1 -1
- package/dist/providers/mailomat/index.js +1 -1
- package/dist/providers/mailpace/index.js +1 -1
- package/dist/providers/mailtrap/index.js +1 -1
- package/dist/providers/mandrill/index.js +1 -1
- package/dist/providers/netcore/index.js +1 -1
- package/dist/providers/outlook365/index.d.ts +83 -5
- package/dist/providers/outlook365/index.js +1 -1
- package/dist/providers/plunk/index.js +1 -1
- package/dist/providers/postal/index.js +1 -1
- package/dist/providers/postmark/index.js +1 -1
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/scaleway/index.js +1 -1
- package/dist/providers/sendgrid/index.js +1 -1
- package/dist/providers/smtp/index.js +1 -1
- package/dist/providers/sparkpost/index.js +1 -1
- package/dist/providers/sweego/index.js +1 -1
- package/dist/providers/zeptomail/index.js +1 -1
- package/dist/test/index.js +1 -1
- package/package.json +5 -1
- package/dist/packem_shared/make-request-BlK_B72c.js +0 -1
- package/dist/packem_shared/oauth2Middleware-CodqXkyj.js +0 -1
- package/dist/packem_shared/outlook365Provider-63ggDpqV.js +0 -1
- package/dist/packem_shared/retry-3pnxTuNs.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as v}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-
|
|
1
|
+
import c from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as v}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-B9XjBynA.js";import{i as f}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{P as A,h,c as T}from"./provider-base-C7PuopYK.js";import{f as d,a as E}from"./address-formatter-BWR2Dddx.js";import{p as K}from"./attachment-processor-CMp7qqMI.js";const a="mailomat",S="https://api.mailomat.com",j=3e4,k=3,X=P((i={})=>{if(!i.apiKey)throw new b(a,"apiKey");const s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??S,retries:i.retries??k,timeout:i.timeout??j,...i.logger&&{logger:i.logger}},m=new A,r=T(a,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(a,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),a);const o={"Content-Type":"application/json","X-API-Key":s.apiKey};r.debug("Retrieving email details",{id:e});const t=await f(async()=>g(`${s.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(r.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(r.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:h(a,"retrieve email",o,r),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(a,"Mailomat API not available or invalid API key");r.debug("Provider initialized successfully")},a)},async isAvailable(){try{return r.debug("Checking Mailomat API availability"),!0}catch(e){return r.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{const o=I(e);if(o.length>0)return{error:new c(a,`Invalid email options: ${o.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),a);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=E(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 n=w(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await K(n,a),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),r.debug("Sending email via Mailomat API",{subject:t.subject,to:t.to});const y={"Content-Type":"application/json","X-API-Key":s.apiKey},l=await f(async()=>g(`${s.endpoint}/send`,{headers:y,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!l.success)return r.debug("API request failed when sending email",l.error),{error:l.error??new c(a,"Failed to send email"),success:!1};const u=l.data?.body,p=u?.messageId??u?.id??v();return r.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:a,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:h(a,"send email",o,r),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import l from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-
|
|
1
|
+
import l from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{f as w}from"./validate-email-options-mCM9dVug.js";import{defineProvider as T}from"./defineProvider-C9q-7iwt.js";import{P as k,h as f,c as A}from"./provider-base-C7PuopYK.js";import{f as u,a as I}from"./address-formatter-BWR2Dddx.js";import{p as P}from"./attachment-processor-CMp7qqMI.js";const r="mailtrap",C="https://send.api.mailtrap.io",E=3e4,j=3,F=T((o={})=>{if(!o.apiToken)throw new b(r,"apiToken");const i={apiToken:o.apiToken,debug:o.debug??!1,endpoint:o.endpoint??C,retries:o.retries??j,timeout:o.timeout??E,...o.logger&&{logger:o.logger}},d=new k,s=A(r,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(r,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),r);const a={"Api-Token":i.apiToken,"Content-Type":"application/json"};s.debug("Retrieving email details",{id:e});const t=await g(async()=>m(`${i.endpoint}/api/send/${e}`,{headers:a,method:"GET",timeout:i.timeout}),i.retries);return t.success?(s.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(s.debug("API request failed when retrieving email",t.error),{error:new l(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:f(r,"retrieve email",a,s),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(r,"Mailtrap API not available or invalid API token");s.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={"Api-Token":i.apiToken,"Content-Type":"application/json"};s.debug("Checking Mailtrap API availability");const a=await m(`${i.endpoint}/api/account`,{headers:e,method:"GET",timeout:i.timeout});return s.debug("Mailtrap 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 s.debug("Error checking availability:",e),!1}},name:r,options:i,async sendEmail(e){try{const a=w(e);if(a.length>0)return{error:new l(r,`Invalid email options: ${a.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:u(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.reply_to=I(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 n=v(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await P(n,r),filename:n.filename,type:n.contentType??"application/octet-stream",...n.cid&&{cid:n.cid}})))),s.debug("Sending email via Mailtrap API",{subject:t.subject,to:t.to});const h={"Api-Token":i.apiToken,"Content-Type":"application/json"},c=await g(async()=>m(`${i.endpoint}/api/send`,{headers:h,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!c.success)return s.debug("API request failed when sending email",c.error),{error:c.error??new l(r,"Failed to send email"),success:!1};const p=c.data?.body?.message_ids?.[0]??y();return s.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:f(r,"send email",a,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{F as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import d from"./EmailError-B-sEf3bp.js";const y=globalThis.Buffer!==void 0,E="ETIMEDOUT",T=async(i,s={},r)=>{const l=typeof i=="string"?new URL(i):i;try{const e=new Headers;s.headers&&Object.entries(s.headers).forEach(([t,u])=>{e.set(t,u)});const o={headers:e,method:s.method??(r?"POST":"GET")};r&&(typeof r=="string"||r instanceof Uint8Array?o.body=r:y&&r instanceof globalThis.Buffer?o.body=new Uint8Array(r):o.body=new Uint8Array(r));let c,a;s.timeout&&(c=new AbortController,a=setTimeout(()=>{c?.abort()},s.timeout),o.signal=c.signal);try{const t=await fetch(l.toString(),o);a&&clearTimeout(a);const u=(t.headers.get("content-type")??"").includes("application/json");let n;if(u)try{n=await t.json()}catch{n=await t.text()}else n=await t.text();const f=t.status>=200&&t.status<300,h={};return t.headers.forEach((m,w)=>{h[w]=m}),{data:{body:n,headers:h,statusCode:t.status},error:f?void 0:new d("http",`Request failed with status ${t.status}`,{code:t.status.toString()}),success:f}}catch(t){if(a&&clearTimeout(a),t instanceof Error&&t.name==="AbortError")return{error:new d("http",`Request timed out after ${s.timeout}ms`,{code:E}),success:!1};throw t}}catch(e){return{error:new d("http",`Request failed: ${e instanceof Error?e.message:String(e)}`,{cause:e instanceof Error?e:new Error(String(e))}),success:!1}}};export{E as R,T as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import d from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as C}from"./generate-message-id-gXAuMz4g.js";import{s as j}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-
|
|
1
|
+
import d from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as C}from"./generate-message-id-gXAuMz4g.js";import{s as j}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-B9XjBynA.js";import{i as y}from"./retry-ipI5DRJ8.js";import{a as h,s as I}from"./sanitize-header-DtQwAnzg.js";import{f as T}from"./validate-email-options-mCM9dVug.js";import{defineProvider as _}from"./defineProvider-C9q-7iwt.js";import{P as k,h as b,c as z}from"./provider-base-C7PuopYK.js";import{k as p}from"./address-formatter-BWR2Dddx.js";import{p as E}from"./attachment-processor-CMp7qqMI.js";const a="mandrill",S="https://mandrillapp.com/api/1.0",K=3e4,M=3,B=_((l={})=>{if(!l.apiKey)throw new P(a,"apiKey");const s={apiKey:l.apiKey,debug:l.debug??!1,endpoint:l.endpoint??S,retries:l.retries??M,timeout:l.timeout??K,...l.logger&&{logger:l.logger}},u=new k,i=z(a,l.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(a,"Email ID is required to retrieve email details"),success:!1};await u.ensureInitialized(()=>this.initialize(),a),i.debug("Retrieving email details",{id:e});const n={id:e,key:s.apiKey},t={"Content-Type":"application/json"},o=await y(async()=>g(`${s.endpoint}/messages/info.json`,{headers:t,method:"POST",timeout:s.timeout},JSON.stringify(n)),s.retries);return o.success?(i.debug("Email details retrieved successfully"),{data:o.data?.body,success:!0}):(i.debug("API request failed when retrieving email",o.error),{error:new d(a,`Failed to retrieve email: ${o.error instanceof Error?o.error.message:"Unknown error"}`,{cause:o.error}),success:!1})}catch(n){return{error:b(a,"retrieve email",n,i),success:!1}}},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(a,"Mandrill API not available or invalid API key");i.debug("Provider initialized successfully")},a)},async isAvailable(){try{i.debug("Checking Mandrill API availability");const e={key:s.apiKey},n={"Content-Type":"application/json"},t=await g(`${s.endpoint}/users/info.json`,{headers:n,method:"POST",timeout:s.timeout},JSON.stringify(e));return i.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 i.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{const n=T(e);if(n.length>0)return{error:new d(a,`Invalid email options: ${n.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),a);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:p(e.to,"to")};if(e.cc){const r=p(e.cc,"cc");for(const c of r)c.type="cc";t.to=[...t.to,...r]}if(e.bcc){const r=p(e.bcc,"bcc");for(const c of r)c.type="bcc";t.to=[...t.to,...r]}if(e.replyTo){const r=e.replyTo.name?`${h(e.replyTo.name)} <${e.replyTo.email}>`:e.replyTo.email;t.headers={"Reply-To":r}}if(e.headers){const r=j(e.headers),c={};Object.entries(r).forEach(([w,A])=>{c[I(w)]=h(A)}),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 r=>({content:await E(r,a),name:r.filename,type:r.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),i.debug("Sending email via Mandrill API",{subject:t.subject,to:t.to});const v={"Content-Type":"application/json"},m=await y(async()=>g(`${s.endpoint}/messages/send.json`,{headers:v,method:"POST",timeout:s.timeout},JSON.stringify(o)),s.retries);if(!m.success)return i.debug("API request failed when sending email",m.error),{error:m.error??new d(a,"Failed to send email"),success:!1};const f=m.data?.body?.[0]?.id??C();return i.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:b(a,"send email",n,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import p from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{m as v}from"./make-request-
|
|
1
|
+
import p from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{m as v}from"./make-request-B9XjBynA.js";import{i as b}from"./retry-ipI5DRJ8.js";import{f as w}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{P as I,h as A,c as z}from"./provider-base-C7PuopYK.js";import{a as l}from"./address-formatter-BWR2Dddx.js";import{c as K}from"./attachment-processor-CMp7qqMI.js";const a="netcore",S="https://emailapi.netcorecloud.net/v5.1",T=3e4,_=3,m=r=>[r].flat(),F=P((r={})=>{if(!r.apiKey)throw new g(a,"apiKey");const i={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??S,logger:r.logger,retries:r.retries??_,timeout:r.timeout??T},d=new I,u=z(a,r.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new p(a,"Netcore API not available or invalid API key");u.debug("Provider initialized successfully")},a)},async isAvailable(){return i.apiKey.length>0},name:a,options:i,async sendEmail(t){try{const n=w(t);if(n.length>0)return{error:new p(a,`Invalid email options: ${n.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),a);const o={to:m(t.to).map(e=>l(e))};t.cc&&(o.cc=m(t.cc).map(e=>l(e))),t.bcc&&(o.bcc=m(t.bcc).map(e=>l(e)));const s={from:l(t.from),personalizations:[o],subject:t.subject};if(t.templateId)s.template_id=t.templateId,t.templateData&&(o.attributes=t.templateData);else{const e=[];t.html&&e.push({type:"html",value:t.html}),t.text&&e.push({type:"plain",value:t.text}),e.length>0&&(s.content=e)}if(t.replyTo){const e=m(t.replyTo)[0];e&&(s.reply_to=e.email)}t.attachments&&t.attachments.length>0&&(s.attachments=await Promise.all(t.attachments.map(async e=>{const h=await K(e,a);return{content:h.content,name:h.filename}})));const c=await b(async()=>v(`${i.endpoint}/mail/send`,{headers:{api_key:i.apiKey,"Content-Type":"application/json"},method:"POST",timeout:i.timeout},JSON.stringify(s)),i.retries);if(!c.success)return{error:c.error??new p(a,"Failed to send email"),success:!1};const{body:f}=c.data;return{data:{messageId:f?.data?.message_id??f?.message_id??y(),provider:a,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:A(a,"send email",n,u),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{F as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as k}from"./create-token-cache-D56KQGVQ.js";import{s as m}from"./headers-to-record-De1Eg951.js";const p=r=>{const{fetchToken:o,headerName:a="Authorization",now:n=Date.now,onToken:s,scheme:t="Bearer",skewMs:c=6e4}=r,h=k(async()=>{const e=await o();return s?.(e),e},{now:n,skewMs:c});return async(e,i)=>{const w=await h(),d=e.headers?m(e.headers):{};return i({...e,headers:{...d,[a]:`${t} ${w.accessToken}`}})}};export{p as oauth2Middleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import m from"./EmailError-B-sEf3bp.js";import{e as _}from"./generate-message-id-gXAuMz4g.js";import{m as S}from"./make-request-B9XjBynA.js";import{i as v}from"./retry-ipI5DRJ8.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import p from"./RequiredOptionError-DuNNY_a5.js";import{d as x}from"./create-token-cache-D56KQGVQ.js";import{c as M}from"./attachment-processor-CMp7qqMI.js";import{h as P,P as R,c as j}from"./provider-base-C7PuopYK.js";const b="https://login.microsoftonline.com",E=6e4,O=3e4,L=3,q=300,z="https://graph.microsoft.com/.default",D=["https://graph.microsoft.com/Mail.Send","offline_access"],F={accessToken:["clientId","clientSecret","refreshToken","tenantId"],clientCredentials:["refreshToken"],getAccessToken:["accessToken","clientId","clientSecret","refreshToken","tenantId"],refreshToken:[]},N=e=>{let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)},U=(e,t)=>{if(e.getAccessToken)return"getAccessToken";if(e.accessToken)return"accessToken";if(e.refreshToken)return"refreshToken";if(e.clientSecret)return"clientCredentials";throw new p(t,["accessToken","getAccessToken","clientSecret","refreshToken"])},B=(e,t,i)=>{const n=e.authMode??U(e,t),h=F[n].filter(a=>e[a]!==void 0);if(h.length>0&&i.warn(`The '${n}' auth mode ignores these configured options: ${h.join(", ")}. Set 'authMode' to pin the intended flow.`),n==="getAccessToken"){const{getAccessToken:a}=e;if(!a)throw new p(t,"getAccessToken");return{getToken:async()=>a(),mode:n}}if(n==="accessToken"){const{accessToken:a}=e;if(!a)throw new p(t,"accessToken");return{getToken:()=>Promise.resolve(a),mode:n}}const{clientId:f,clientSecret:r,refreshToken:c,tenantId:d}=e,o=[];if(d||o.push("tenantId"),f||o.push("clientId"),n==="clientCredentials"&&!r&&o.push("clientSecret"),n==="refreshToken"&&!c&&o.push("refreshToken"),!d||!f)throw new p(t,o);if(n==="clientCredentials"){if(!r)throw new p(t,o);return{clientId:f,clientSecret:r,mode:n,tenantId:d}}if(!c)throw new p(t,o);return{clientId:f,clientSecret:r,mode:n,refreshToken:c,tenantId:d}},H=(e,t,i)=>{if(typeof e!="object"||e===null)throw new m(t,`Token endpoint returned a non-JSON response (status ${String(i)})`);const n=e;if(typeof n.error=="string"){const h=typeof n.error_description=="string"?n.error_description:"no description provided";throw new m(t,`Token request failed: ${n.error} — ${h}`,{code:n.error,hint:"Check the tenantId, clientId and client secret / refresh token in the Azure app registration."})}if(typeof n.access_token!="string")throw new m(t,`Token endpoint response did not contain an access_token (status ${String(i)})`);return{accessToken:n.access_token,expiresIn:typeof n.expires_in=="number"?n.expires_in:q,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0}},J=e=>e===0||e===408||e===429||e>=500,$=(e,t,i,n)=>{if(e.mode==="accessToken"||e.mode==="getAccessToken")return e.getToken;const h=`${N(t.authority??b)}/${e.tenantId}/oauth2/v2.0/token`,f=t.timeout??O,r=t.retries??L,c=t.now??Date.now;let d=e.mode==="refreshToken"?e.refreshToken:void 0;const o=()=>{const s=new URLSearchParams({client_id:e.clientId,scope:(t.scopes??(e.mode==="clientCredentials"?[z]:D)).join(" ")});return e.clientSecret&&s.set("client_secret",e.clientSecret),e.mode==="clientCredentials"?s.set("grant_type","client_credentials"):(s.set("grant_type","refresh_token"),s.set("refresh_token",d)),s.toString()},a=s=>s.data?.statusCode??0,k=async()=>{const s=await S(h,{headers:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST",timeout:f},o());return!s.success&&J(a(s))?s:{data:s.data,success:!0}},T=async s=>{if(d=s,!!t.onRefreshToken)try{await t.onRefreshToken(s)}catch(u){n.error(`Failed to persist the rotated refresh token — the stored token is stale and sending will fail after a restart: ${u instanceof Error?u.message:String(u)}`)}},g=x(async()=>{const s=await v(k,r),u=s.data?.body;if(!s.success&&(typeof u!="object"||u===null))throw s.error instanceof Error?s.error:new m(i,"Token request failed");const w=H(u,i,a(s));return w.refreshToken&&w.refreshToken!==d&&await T(w.refreshToken),{accessToken:w.accessToken,expiresAt:c()+w.expiresIn*1e3}},{now:c,skewMs:t.tokenRefreshSkewMs??E});return async()=>(await g()).accessToken},l="outlook365",G="https://graph.microsoft.com/v1.0",K=3e4,Q=3,y=e=>[e].flat(),I=e=>e.map(t=>({emailAddress:{address:t.email,...t.name?{name:t.name}:{}}})),V=e=>{if(e instanceof m)return e;const t=e instanceof Error?e.message:String(e);return new m(l,`Failed to obtain access token: ${t}`,{cause:e})},ae=C((e={})=>{const t=j(l,e.logger),i=B(e,l,t);if(i.mode==="clientCredentials"&&(e.userId===void 0||e.userId==="me"))throw new m(l,"The app-only (client credentials) flow requires an explicit 'userId'",{hint:"Set 'userId' to the sender's mailbox id or UPN — app-only tokens have no 'me' mailbox."});const n={authMode:i.mode,authority:e.authority??b,clientId:e.clientId,debug:e.debug??!1,endpoint:e.endpoint??G,logger:e.logger,now:e.now,retries:e.retries??Q,saveToSentItems:e.saveToSentItems??!0,scopes:e.scopes,tenantId:e.tenantId,timeout:e.timeout??K,tokenRefreshSkewMs:e.tokenRefreshSkewMs,userId:e.userId??"me"},h=new R,f=$(i,e,l,t);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){h.setInitialized()},async isAvailable(){return!0},name:l,options:n,async sendEmail(r){try{const c=A(r);if(c.length>0)return{error:new m(l,`Invalid email options: ${c.join(", ")}`),success:!1};let d;try{d=await f()}catch(T){return{error:V(T),success:!1}}const o={body:{content:r.html??r.text??"",contentType:r.html?"HTML":"Text"},subject:r.subject,toRecipients:I(y(r.to))};r.cc&&(o.ccRecipients=I(y(r.cc))),r.bcc&&(o.bccRecipients=I(y(r.bcc))),r.replyTo&&(o.replyTo=I(y(r.replyTo))),r.importance&&(o.importance=r.importance),r.attachments&&r.attachments.length>0&&(o.attachments=await Promise.all(r.attachments.map(async T=>{const g=await M(T,l);return{"@odata.type":"#microsoft.graph.fileAttachment",contentBytes:g.content,contentType:g.contentType,name:g.filename}})));const a=n.userId==="me"?"me":`users/${n.userId}`,k=await v(async()=>S(`${n.endpoint}/${a}/sendMail`,{headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},method:"POST",timeout:n.timeout},JSON.stringify({message:o,saveToSentItems:n.saveToSentItems})),n.retries);return k.success?{data:{messageId:_(),provider:l,response:k.data,sent:!0,timestamp:new Date},success:!0}:{error:k.error??new m(l,"Failed to send email"),success:!1}}catch(c){return{error:P(l,"send email",c,t),success:!1}}},async validateCredentials(){try{return await f(),!0}catch(r){return t.warn(`Credential validation failed: ${r instanceof Error?r.message:String(r)}`),!1}}}});export{ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import m from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{s as A}from"./headers-to-record-De1Eg951.js";import{m as b}from"./make-request-
|
|
1
|
+
import m from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{s as A}from"./headers-to-record-De1Eg951.js";import{m as b}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{s as k,a as z}from"./sanitize-header-DtQwAnzg.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as E}from"./defineProvider-C9q-7iwt.js";import{P as T,h,c as K}from"./provider-base-C7PuopYK.js";import{p as x}from"./attachment-processor-CMp7qqMI.js";const r="plunk",_="https://api.useplunk.com/v1",S=3e4,q=3,U=E((n={})=>{if(!n.apiKey)throw new P(r,"apiKey");const a={apiKey:n.apiKey,debug:n.debug??!1,endpoint:n.endpoint??_,logger:n.logger,retries:n.retries??q,timeout:n.timeout??S},p=new T,i=K(r,n.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(r,"Email ID is required to retrieve email details"),success:!1};await p.ensureInitialized(()=>this.initialize(),r);const l={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const s=await g(async()=>b(`${a.endpoint}/emails/${e}`,{headers:l,method:"GET",timeout:a.timeout}),a.retries);return s.success?(i.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(i.debug("API request failed when retrieving email",s.error),{error:new m(r,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(l){return{error:h(r,"retrieve email",l,i),success:!1}}},async initialize(){await p.ensureInitialized(async()=>{if(!await this.isAvailable())throw new m(r,"Plunk API not available or invalid API key");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{return a.apiKey&&a.apiKey.length>0?(i.debug("API key exists, assuming Plunk is available"),!0):!1}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:a,async sendEmail(e){try{const l=j(e);if(l.length>0)return{error:new m(r,`Invalid email options: ${l.join(", ")}`),success:!1};await p.ensureInitialized(()=>this.initialize(),r);const s=o=>Array.isArray(o)?o.map(d=>d.email):[o.email],t={to:e.subscriber??(Array.isArray(e.to)?e.to[0]?.email:e.to.email)};if(e.from&&(t.from=e.from.email,e.from.name&&(t.from_name=e.from.name)),e.subject&&(t.subject=e.subject),e.html?t.body=e.html:e.text&&(t.body=e.text),e.html&&e.text&&(t.text=e.text),e.cc&&(t.cc=s(e.cc)),e.bcc&&(t.bcc=s(e.bcc)),e.replyTo&&(t.reply_to=e.replyTo.email,e.replyTo.name&&(t.reply_to_name=e.replyTo.name)),e.templateId&&(t.template=e.templateId),e.data&&(t.data=e.data),e.subscriberId&&(t.subscriber_id=e.subscriberId),e.headers){const o=A(e.headers),d={};Object.entries(o).forEach(([w,I])=>{d[k(w)]=z(I)}),t.headers=d}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async o=>({content:await x(o,r),filename:o.filename,type:o.contentType??"application/octet-stream"})))),i.debug("Sending email via Plunk API",{subject:t.subject,to:t.to});const v={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},c=await g(async()=>b(`${a.endpoint}/send`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new m(r,"Failed to send email"),success:!1};const u=c.data,f=u?.body&&typeof u.body=="object"?u.body.id??u.body.messageId??y():y();return i.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:r,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(l){return{error:h(r,"send email",l,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import l from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-
|
|
1
|
+
import l from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-B9XjBynA.js";import{i as f}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P as C,c as E}from"./provider-base-C7PuopYK.js";import{l as u,m as h}from"./address-formatter-BWR2Dddx.js";import{p as T}from"./attachment-processor-CMp7qqMI.js";const a="postal",j=3e4,K=3,R=A((r={})=>{if(!r.host)throw new g(a,"host");if(!r.apiKey)throw new g(a,"apiKey");const y=r.endpoint??`https://${r.host}/api/v1`,i={apiKey:r.apiKey,debug:r.debug??!1,endpoint:y,host:r.host,retries:r.retries??K,timeout:r.timeout??j,...r.logger&&{logger:r.logger}},d=new C,o=E(a,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 l(a,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),a);const t={"Content-Type":"application/json","X-Server-API-Key":i.apiKey};o.debug("Retrieving email details",{id:e});const s=await f(async()=>m(`${i.endpoint}/messages/${e}`,{headers:t,method:"GET",timeout:i.timeout}),i.retries);return s.success?(o.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(o.debug("API request failed when retrieving email",s.error),{error:new l(a,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(t){return o.debug("Exception retrieving email",t),{error:new l(a,`Failed to retrieve email: ${t.message}`,{cause:t}),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(a,"Postal API not available or invalid API key");o.debug("Provider initialized successfully")},a)},async isAvailable(){try{const e={"Content-Type":"application/json","X-Server-API-Key":i.apiKey};o.debug("Checking Postal API availability");const t=await m(`${i.endpoint}/server`,{headers:e,method:"GET",timeout:i.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:a,options:i,async sendEmail(e){try{const t=I(e);if(t.length>0)return{error:new l(a,`Invalid email options: ${t.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),a);const s={from:h(e.from).address,subject:e.subject,to:u(e.to).map(n=>n.address)};if(e.html&&(s.html_body=e.html),e.text&&(s.plain_body=e.text),e.cc&&(s.cc=u(e.cc).map(n=>n.address)),e.bcc&&(s.bcc=u(e.bcc).map(n=>n.address)),e.replyTo&&(s.reply_to=h(e.replyTo).address),e.templateId&&(s.template_id=e.templateId,e.templateVariables&&(s.template_variables=e.templateVariables)),e.tags&&e.tags.length>0&&(s.tag=e.tags.join(",")),e.headers){const n=P(e.headers);s.headers=n}e.attachments&&e.attachments.length>0&&(s.attachments=await Promise.all(e.attachments.map(async n=>{const v=await T(n,a);return{content_type:n.contentType??"application/octet-stream",data:v,name:n.filename}}))),o.debug("Sending email via Postal API",{subject:s.subject,to:s.to});const b={"Content-Type":"application/json","X-Server-API-Key":i.apiKey},c=await f(async()=>m(`${i.endpoint}/send/message`,{headers:b,method:"POST",timeout:i.timeout},JSON.stringify(s)),i.retries);if(!c.success)return o.debug("API request failed when sending email",c.error),{error:c.error??new l(a,"Failed to send email"),success:!1};const p=c.data?.body?.message_id?.toString()??w();return o.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:a,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return o.debug("Exception sending email",t),{error:new l(a,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{R as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import d from"./EmailError-B-sEf3bp.js";import T from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m as u}from"./make-request-
|
|
1
|
+
import d from"./EmailError-B-sEf3bp.js";import T from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m as u}from"./make-request-B9XjBynA.js";import{i as f}from"./retry-ipI5DRJ8.js";import{a as I,s as A}from"./sanitize-header-DtQwAnzg.js";import{f as C}from"./validate-email-options-mCM9dVug.js";import{defineProvider as S}from"./defineProvider-C9q-7iwt.js";import{P as j,h,c as E}from"./provider-base-C7PuopYK.js";import{e as p,g as v}from"./address-formatter-BWR2Dddx.js";import{b as z}from"./attachment-processor-CMp7qqMI.js";const r="postmark",M="https://api.postmarkapp.com",O=3e4,H=3,U=S((o={})=>{if(!o.serverToken)throw new T(r,"serverToken");const s={debug:o.debug??!1,endpoint:o.endpoint??M,retries:o.retries??H,serverToken:o.serverToken,timeout:o.timeout??O,...o.logger&&{logger:o.logger}},m=new j,i=E(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=C(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:A(b),Value:I(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{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as I}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m as p}from"./make-request-
|
|
1
|
+
import c from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as I}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m as p}from"./make-request-B9XjBynA.js";import{i as y}from"./retry-ipI5DRJ8.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{P as E,h as f,c as T}from"./provider-base-C7PuopYK.js";import{e as z,g as b,d as v}from"./address-formatter-BWR2Dddx.js";import{p as k}from"./attachment-processor-CMp7qqMI.js";const i="resend",S="https://api.resend.com",K=3e4,R=3,_=r=>{const a=[],d=/^[\w-]+$/;return d.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`),d.test(r.value)||a.push(`Tag value '${r.value}' for tag '${r.name}' must only contain ASCII letters, numbers, underscores, or dashes`),a},U=C((r={})=>{if(!r.apiKey)throw new w(i,"apiKey");const a={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??S,logger:r.logger,retries:r.retries??R,timeout:r.timeout??K},d=new E,n=T(i,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(i,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),i);const t={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const s=await y(async()=>p(`${a.endpoint}/emails/${e}`,{headers:t,method:"GET",timeout:a.timeout}),a.retries);return s.success?(n.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(n.debug("API request failed when retrieving email",s.error),{error:new c(i,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(t){return{error:f(i,"retrieve email",t,n),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(i,"Resend API not available or invalid API key");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{if(a.apiKey&&a.apiKey.startsWith("re_"))return n.debug("API key format is valid, assuming Resend is available"),!0;const e={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};n.debug("Checking Resend API availability");const t=await p(`${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"?(n.debug("API key is valid but restricted to only sending emails"),!0):(n.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 n.debug("Error checking availability:",e),!1}},name:i,options:a,async sendEmail(e){try{const t=j(e);if(t.length>0)return{error:new c(i,`Invalid email options: ${t.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),i);const s={from:b(e.from),headers:e.headers?P(e.headers):{},html:e.html,subject:e.subject,text:e.text,to:z(e.to)};if(e.cc&&(s.cc=v(e.cc)),e.bcc&&(s.bcc=v(e.bcc)),e.replyTo&&(s.reply_to=b(e.replyTo)),e.templateId&&(s.template=e.templateId,e.templateData&&(s.data=e.templateData)),e.scheduledAt&&(s.scheduled_at=typeof e.scheduledAt=="string"?e.scheduledAt:e.scheduledAt.toISOString()),e.tags&&e.tags.length>0){const o=[];if(e.tags.forEach(m=>{const g=_(m);g.length>0&&o.push(...g)}),o.length>0)return{error:new c(i,`Invalid email tags: ${o.join(", ")}`),success:!1};s.tags=e.tags.map(m=>({name:m.name,value:m.value}))}e.attachments&&e.attachments.length>0&&(s.attachments=await Promise.all(e.attachments.map(async o=>({content:await k(o,i),content_type:o.contentType,filename:o.filename,...o.path&&{path:o.path}})))),n.debug("Sending email via Resend API",{subject:s.subject,to:s.to});const A={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},l=await y(async()=>p(`${a.endpoint}/emails`,{headers:A,method:"POST",timeout:a.timeout},JSON.stringify(s)),a.retries);if(!l.success)return n.debug("API request failed when sending email",l.error),{error:l.error??new c(i,"Failed to send email"),success:!1};const u=l.data,h=u?.body&&typeof u.body=="object"&&u.body.id?u.body.id:I();return n.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:i,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:f(i,"send email",t,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import c from"./EmailError-B-sEf3bp.js";import{R as i}from"./make-request-B9XjBynA.js";const m=new Set([408,429,503]),u=r=>{const{statusCode:t}=r.data??{};return t!==void 0?m.has(t):!(r.error instanceof c&&r.error.code===i)},a=async(r,t=3,s=300,e=u)=>{try{const o=await r();return o.success||t<=0||!e(o)?o:(await new Promise(n=>{setTimeout(()=>{n()},s)}),a(r,t-1,s*2,e))}catch(o){return t<=0?{error:o instanceof Error?o:new Error(String(o)),success:!1}:(await new Promise(n=>{setTimeout(()=>{n()},s)}),a(r,t-1,s*2,e))}};export{a as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const r=/[\r\n]/,s=e=>{const a=e.search(r);return a===-1?e:e.slice(0,a)},n=e=>e.replaceAll(/[\r\n]/g,"");export{
|
|
1
|
+
const r=/[\r\n]/,s=e=>{const a=e.search(r);return a===-1?e:e.slice(0,a)},n=e=>e.replaceAll(/[\r\n]/g,"");export{s as a,n as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"./EmailError-B-sEf3bp.js";import p from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as f}from"./make-request-
|
|
1
|
+
import c from"./EmailError-B-sEf3bp.js";import p from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as f}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P,h,c as j}from"./provider-base-C7PuopYK.js";import{f as d,a as T}from"./address-formatter-BWR2Dddx.js";import{p as S}from"./attachment-processor-CMp7qqMI.js";const r="scaleway",k="https://api.scaleway.com/transactional-email/v1alpha1",E=3e4,z=3,H=A((a={})=>{if(!a.apiKey)throw new p(r,"apiKey");if(!a.region)throw new p(r,"region");const y=a.endpoint??k,i={apiKey:a.apiKey,debug:a.debug??!1,endpoint:y,region:a.region,retries:a.retries??z,timeout:a.timeout??E,...a.logger&&{logger:a.logger}},m=new P,s=j(r,a.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(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const n={"Content-Type":"application/json","X-Auth-Token":i.apiKey};s.debug("Retrieving email details",{id:e});const t=await g(async()=>f(`${i.endpoint}/regions/${i.region}/emails/${e}`,{headers:n,method:"GET",timeout:i.timeout}),i.retries);return t.success?(s.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(s.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(n){return{error:h(r,"retrieve email",n,s),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Scaleway API not available or invalid API key");s.debug("Provider initialized successfully")},r)},async isAvailable(){try{return s.debug("Checking Scaleway API availability"),!0}catch(e){return s.debug("Error checking availability:",e),!1}},name:r,options:i,async sendEmail(e){try{const n=I(e);if(n.length>0)return{error:new c(r,`Invalid email options: ${n.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,...e.from.name&&{name:e.from.name}},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=T(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.projectId&&(t.projectId=e.projectId),e.headers){const l=v(e.headers);t.headers=l}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async l=>({content:await S(l,r),name:l.filename,type:l.contentType??"application/octet-stream"})))),s.debug("Sending email via Scaleway API",{subject:t.subject,to:t.to});const b={"Content-Type":"application/json","X-Auth-Token":i.apiKey},o=await g(async()=>f(`${i.endpoint}/regions/${i.region}/emails`,{headers:b,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!o.success)return s.debug("API request failed when sending email",o.error),{error:o.error??new c(r,"Failed to send email"),success:!1};const u=o.data?.body?.id??w();return s.debug("Email sent successfully",{messageId:u}),{data:{messageId:u,provider:r,response:o.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:h(r,"send email",n,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import l from"./EmailError-B-sEf3bp.js";import A from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as S}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-
|
|
1
|
+
import l from"./EmailError-B-sEf3bp.js";import A from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as S}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-B9XjBynA.js";import{i as b}from"./retry-ipI5DRJ8.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as G}from"./defineProvider-C9q-7iwt.js";import{P as k,h as v,c as z}from"./provider-base-C7PuopYK.js";import{f,a as I}from"./address-formatter-BWR2Dddx.js";import{d as C}from"./attachment-processor-CMp7qqMI.js";const s="sendgrid",E="https://api.sendgrid.com/v3",_=3e4,T=3,L=G((o={})=>{if(!o.apiKey)throw new A(s,"apiKey");const a={apiKey:o.apiKey,debug:o.debug??!1,endpoint:o.endpoint??E,...o.logger&&{logger:o.logger},retries:o.retries??T,timeout:o.timeout??_},p=new k,i=z(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=j(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=>C(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{L as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as x}from"node:module";import f from"./EmailError-B-sEf3bp.js";import W from"./RequiredOptionError-DuNNY_a5.js";import{F as Q}from"./build-mime-message-
|
|
1
|
+
import{createRequire as x}from"node:module";import f from"./EmailError-B-sEf3bp.js";import W from"./RequiredOptionError-DuNNY_a5.js";import{F as Q}from"./build-mime-message-BW5FQ2Bt.js";import{e as Z}from"./generate-message-id-gXAuMz4g.js";import{f as J}from"./validate-email-options-mCM9dVug.js";import{defineProvider as V}from"./defineProvider-C9q-7iwt.js";const G=x(import.meta.url),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=h=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[t,A]=O.versions.node.split(".").map(Number);if(t>22||t===22&&A>=3||t===20&&A>=16)return O.getBuiltinModule(h)}return G(h)},{Buffer:I}=k("node:buffer"),{createHmac:B,createHash:X,createSign:Y}=k("node:crypto"),{Socket:q,createConnection:K}=k("node:net"),{connect:E}=k("node:tls"),ee=(h,t)=>new Promise(A=>{const w=new q,y=()=>{w.destroy(),A(!1)};w.setTimeout(1e3),w.on("error",y),w.on("timeout",y),w.connect(t,h,()=>{w.end(),A(!0)})}),l="smtp",te=25,re=465,se=1e4,oe=!1,ae=5,P=3e4,ie=/^\./,pe=V((h={})=>{if(!h.host)throw new W(l,"host");const t={authMethod:h.authMethod??"LOGIN",debug:h.debug??!1,dkim:h.dkim,host:h.host,maxConnections:h.maxConnections??ae,oauth2:h.oauth2,password:h.password,pool:h.pool??!1,port:h.port!==void 0?h.port:h.secure?re:te,rejectUnauthorized:h.rejectUnauthorized??!0,retries:h.retries??0,secure:h.secure??oe,timeout:h.timeout??se,user:h.user,...h.logger&&{logger:h.logger}};let A=!1;const w=[],y=[],S=e=>e.replaceAll(/[\r\n\t\v\f]/g," ").trim(),v=e=>{const u=e.split(`\r
|
|
2
2
|
`),o={};for(const c of u)if(c.startsWith("250-")||c.startsWith("250 ")){const i=c.slice(4).trim().split(" "),n=i[0];n&&(o[n]=i.slice(1))}return o},p=async(e,u,o)=>new Promise((c,i)=>{const n=Array.isArray(o)?o:[o];let s="",a="";const d=setTimeout(()=>{g(),i(new f(l,`Command timeout after ${t.timeout}ms: ${u?.slice(0,50)}...`))},t.timeout),g=()=>{e.removeListener("data",b),e.removeListener("error",r),d&&clearTimeout(d)},b=m=>{s+=m.toString();const j=s.split(`\r
|
|
3
3
|
`).filter(Boolean);if(j.length>0){const $=j.at(-1);if($){const U=$.match(/^(\d{3})[\s-]/);if(U){const[,M]=U;a=M,$[3]===" "&&(g(),n.includes(a)?c(s):i(new f(l,`Expected ${n.join(" or ")}, got ${a}: ${s.trim()}`)))}}}},r=m=>{g(),i(new f(l,`Socket error: ${m.message}`,{cause:m}))};e.on("data",b),e.on("error",r),u&&e.write(`${u}\r
|
|
4
4
|
`)}),C=async()=>{if(t.pool&&w.length>0){const e=w.pop();if(e&&!e.destroyed)return e}return t.pool&&w.length+1>=t.maxConnections?new Promise((e,u)=>{const o={reject:u,resolve:e};o.timeout=setTimeout(()=>{const c=y.indexOf(o);c!==-1&&y.splice(c,1),u(new f(l,`Connection queue timeout after ${P}ms`))},P),y.push(o)}):new Promise((e,u)=>{let o,c=!1,i;const n=()=>{o&&clearTimeout(o)};o=setTimeout(()=>{c||(c=!0,i&&!i.destroyed&&i.destroy(),n(),u(new f(l,`Connection timeout to ${t.host}:${t.port} after ${t.timeout}ms`)))},t.timeout);try{i=t.secure?E({host:t.host,port:t.port,rejectUnauthorized:t.rejectUnauthorized}):K(t.port,t.host),i.on("error",s=>{c||(c=!0,n(),u(new f(l,`Connection error: ${s.message}`,{cause:s})))}),i.once("data",s=>{if(!c&&i){c=!0,n();const a=s.toString();a.slice(0,3)==="220"?e(i):(i.destroy(),u(new f(l,`Unexpected server greeting: ${a.trim()}`)))}})}catch(s){c||(c=!0,n(),u(new f(l,`Failed to create connection: ${s.message}`,{cause:s})))}})},R=async e=>new Promise((u,o)=>{let c,i=!1,n;const s=()=>{c&&clearTimeout(c)};c=setTimeout(()=>{i||(i=!0,n&&!n.destroyed&&n.destroy(),s(),o(new f(l,`TLS connection timeout after ${t.timeout}ms`)))},t.timeout);try{const a={host:t.host,rejectUnauthorized:t.rejectUnauthorized,socket:e};n=E(a),n.on("error",d=>{i||(i=!0,s(),o(new f(l,`TLS connection error: ${d.message}`,{cause:d})))}),n.once("secure",()=>{!i&&n&&(i=!0,s(),u(n))})}catch(a){i||(i=!0,s(),o(new f(l,`Failed to upgrade to TLS: ${a.message}`,{cause:a})))}}),z=e=>{if(e.destroyed||!t.pool){try{e.destroy()}catch{}return}if(y.length>0){const u=y.shift();if(u){clearTimeout(u.timeout),u.resolve(e);return}}w.push(e)},L=async(e,u=!1)=>new Promise(o=>{try{if(u){e.write(`RSET\r
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import h from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{m as j}from"./make-request-
|
|
1
|
+
import h from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{m as j}from"./make-request-B9XjBynA.js";import{i as I}from"./retry-ipI5DRJ8.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as S}from"./defineProvider-C9q-7iwt.js";import{P as z,h as _,c as C}from"./provider-base-C7PuopYK.js";import{a as l}from"./address-formatter-BWR2Dddx.js";import{c as K}from"./attachment-processor-CMp7qqMI.js";const a="sparkpost",O="https://api.sparkpost.com/api/v1",T=3e4,x=3,d=r=>[r].flat(),B=S((r={})=>{if(!r.apiKey)throw new w(a,"apiKey");const n={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??O,logger:r.logger,retries:r.retries??x,timeout:r.timeout??T},g=new z,y=C(a,r.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new h(a,"SparkPost API not available or invalid API key");y.debug("Provider initialized successfully")},a)},async isAvailable(){return n.apiKey.length>0},name:a,options:n,async sendEmail(t){try{const o=A(t);if(o.length>0)return{error:new h(a,`Invalid email options: ${o.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),a);const p=d(t.to),u=t.cc?d(t.cc):[],k=t.bcc?d(t.bcc):[],v=[...p.map(e=>({address:l(e)})),...u.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}})),...k.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}}))],s={from:l(t.from),subject:t.subject};if(t.html&&(s.html=t.html),t.text&&(s.text=t.text),t.replyTo){const e=d(t.replyTo)[0];e&&(s.reply_to=e.email)}const c={};if(u.length>0&&(c.CC=u.map(e=>e.email).join(", ")),t.headers)for(const[e,i]of Object.entries(t.headers))c[e]=String(i);Object.keys(c).length>0&&(s.headers=c),t.templateId&&(s.template_id=t.templateId),t.attachments&&t.attachments.length>0&&(s.attachments=await Promise.all(t.attachments.map(async e=>{const i=await K(e,a);return{data:i.content,name:i.filename,type:i.contentType}})));const f={content:s,recipients:v};t.campaignId&&(f.campaign_id=t.campaignId),(t.trackOpens!==void 0||t.trackClicks!==void 0)&&(f.options={click_tracking:t.trackClicks??!0,open_tracking:t.trackOpens??!0});const m=await I(async()=>j(`${n.endpoint}/transmissions`,{headers:{Authorization:n.apiKey,"Content-Type":"application/json"},method:"POST",timeout:n.timeout},JSON.stringify(f)),n.retries);if(!m.success)return{error:m.error??new h(a,"Failed to send email"),success:!1};const{body:b}=m.data;return{data:{messageId:b?.results?.id??P(),provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:_(a,"send email",o,y),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-
|
|
1
|
+
import c from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-B9XjBynA.js";import{i as f}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P,h,c as T}from"./provider-base-C7PuopYK.js";import{f as d,a as z}from"./address-formatter-BWR2Dddx.js";import{p as S}from"./attachment-processor-CMp7qqMI.js";const r="sweego",E="https://api.sweego.com",j=3e4,k=3,H=A((i={})=>{if(!i.apiKey)throw new b(r,"apiKey");const s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??E,retries:i.retries??k,timeout:i.timeout??j,...i.logger&&{logger:i.logger}},m=new P,a=T(r,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(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const o={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"};a.debug("Retrieving email details",{id:e});const t=await f(async()=>g(`${s.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(a.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(a.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(o){return{error:h(r,"retrieve email",o,a),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Sweego API not available or invalid API key");a.debug("Provider initialized successfully")},r)},async isAvailable(){try{return a.debug("Checking Sweego API availability"),!0}catch(e){return a.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const o=I(e);if(o.length>0)return{error:new c(r,`Invalid email options: ${o.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=z(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const n=v(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await S(n,r),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),a.debug("Sending email via Sweego API",{subject:t.subject,to:t.to});const y={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"},l=await f(async()=>g(`${s.endpoint}/send`,{headers:y,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!l.success)return a.debug("API request failed when sending email",l.error),{error:l.error??new c(r,"Failed to send email"),success:!1};const u=l.data?.body,p=u?.messageId??u?.id??w();return a.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:h(r,"send email",o,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import l from"./EmailError-B-sEf3bp.js";import y from"./RequiredOptionError-DuNNY_a5.js";import{e as b}from"./generate-message-id-gXAuMz4g.js";import{s as k}from"./headers-to-record-De1Eg951.js";import{m as v}from"./make-request-
|
|
1
|
+
import l from"./EmailError-B-sEf3bp.js";import y from"./RequiredOptionError-DuNNY_a5.js";import{e as b}from"./generate-message-id-gXAuMz4g.js";import{s as k}from"./headers-to-record-De1Eg951.js";import{m as v}from"./make-request-B9XjBynA.js";import{i as w}from"./retry-ipI5DRJ8.js";import{s as A,a as z}from"./sanitize-header-DtQwAnzg.js";import{f as _}from"./validate-email-options-mCM9dVug.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";import{P,h as I,c as T}from"./provider-base-C7PuopYK.js";import{n as h}from"./address-formatter-BWR2Dddx.js";const i="zeptomail",O="https://api.zeptomail.com/v1.1",Z=3e4,E=3,L=j((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 o={debug:s.debug??!1,endpoint:s.endpoint??O,logger:s.logger,retries:s.retries??E,timeout:s.timeout??Z,token:s.token},u=new P,n=T(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");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{return o.token&&o.token.startsWith("Zoho-enczapikey ")?(n.debug("Token format is valid, assuming Zeptomail is available"),!0):!1}catch(e){return n.debug("Error checking availability:",e),!1}},name:i,options:o,async sendEmail(e){try{const m=_(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[A(r)]=z(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})),n.debug("Sending email via Zeptomail API",{subject:a.subject,to:a.to});const g={Accept:"application/json",Authorization:o.token,"Content-Type":"application/json"},c=await w(async()=>v(`${o.endpoint}/email`,{headers:g,method:"POST",timeout:o.timeout},JSON.stringify(a)),o.retries);if(!c.success){n.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 n.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(i,"send email",m,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"../../packem_shared/ahaSendProvider-
|
|
1
|
+
import{default as r}from"../../packem_shared/ahaSendProvider-DSuZIzaQ.js";export{r as ahaSendProvider};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-J-y6iogK.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-J-y6iogK.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-ejzh-xBP.js";
|
|
4
|
+
import 'node:buffer';
|
|
5
|
+
/**
|
|
6
|
+
* AutoSend configuration.
|
|
7
|
+
*/
|
|
8
|
+
interface AutoSendConfig extends BaseConfig {
|
|
9
|
+
/**
|
|
10
|
+
* AutoSend API key (sent as a Bearer token).
|
|
11
|
+
*/
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/**
|
|
14
|
+
* API endpoint override (default `https://api.autosend.com/v1`).
|
|
15
|
+
*/
|
|
16
|
+
endpoint?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* AutoSend-specific email options.
|
|
20
|
+
*
|
|
21
|
+
* See the [send reference](https://docs.autosend.com/api-reference/mails/send). AutoSend's
|
|
22
|
+
* `/mails/send` takes exactly one `to` recipient — pass a single address, and use `cc`/`bcc`
|
|
23
|
+
* for additional ones.
|
|
24
|
+
*/
|
|
25
|
+
interface AutoSendEmailOptions extends EmailOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Sends even if the recipient is on the suppression list. Use sparingly: suppressions exist
|
|
28
|
+
* to protect the sending domain's reputation.
|
|
29
|
+
*/
|
|
30
|
+
bypassSuppressions?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Values substituted into Handlebars placeholders (`{{ name }}`) in the template or `html`.
|
|
33
|
+
*/
|
|
34
|
+
dynamicData?: Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* An AutoSend template id, used instead of `html` / `text`.
|
|
37
|
+
*/
|
|
38
|
+
templateId?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Enables click tracking for this message.
|
|
41
|
+
*/
|
|
42
|
+
trackingClick?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Enables open tracking for this message.
|
|
45
|
+
*/
|
|
46
|
+
trackingOpen?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The unsubscribe group this message belongs to.
|
|
49
|
+
*/
|
|
50
|
+
unsubscribeGroupId?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* AutoSend provider — sends through the [AutoSend send endpoint](https://docs.autosend.com/api-reference/mails/send).
|
|
54
|
+
*/
|
|
55
|
+
declare const autoSendProvider: ProviderFactory<AutoSendConfig, unknown, AutoSendEmailOptions>;
|
|
56
|
+
export { type AutoSendConfig, type AutoSendEmailOptions, type ProviderFactory, autoSendProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as r}from"../../packem_shared/autoSendProvider-DqAoelWR.js";export{r as autoSendProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"../../packem_shared/awsSesProvider-
|
|
1
|
+
import{default as a}from"../../packem_shared/awsSesProvider-ClK1FUln.js";export{a as awsSesProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"../../packem_shared/azureProvider-
|
|
1
|
+
import{default as a}from"../../packem_shared/azureProvider-Cw_Tmde6.js";export{a as azureProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../../packem_shared/brevoProvider-
|
|
1
|
+
import{default as o}from"../../packem_shared/brevoProvider-CIzuIDlt.js";export{o as brevoProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../packem_shared/cloudflareEmailProvider-
|
|
1
|
+
import{default as e}from"../../packem_shared/cloudflareEmailProvider-B8mOEl3N.js";export{e as cloudflareEmailProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../packem_shared/httpProvider-
|
|
1
|
+
import{default as e}from"../../packem_shared/httpProvider-aBfTXyCT.js";export{e as httpProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../packem_shared/infobipProvider-
|
|
1
|
+
import{default as e}from"../../packem_shared/infobipProvider-DxzsONUX.js";export{e as infobipProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../packem_shared/loopsProvider-
|
|
1
|
+
import{default as e}from"../../packem_shared/loopsProvider-QBsAH6Ee.js";export{e as loopsProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"../../packem_shared/mailchannelsProvider-
|
|
1
|
+
import{default as r}from"../../packem_shared/mailchannelsProvider-GiwkYBdD.js";export{r as mailchannelsProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../packem_shared/mailCrabProvider-
|
|
1
|
+
import{default as e}from"../../packem_shared/mailCrabProvider-DRE5snM9.js";export{e as mailCrabProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"../../packem_shared/mailerSendProvider-
|
|
1
|
+
import{default as a}from"../../packem_shared/mailerSendProvider-RK6IbUrL.js";export{a as mailerSendProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../packem_shared/mailgunProvider-
|
|
1
|
+
import{default as e}from"../../packem_shared/mailgunProvider-D9HUWGKN.js";export{e as mailgunProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"../../packem_shared/mailjetProvider-
|
|
1
|
+
import{default as a}from"../../packem_shared/mailjetProvider-DelLs2Vt.js";export{a as mailjetProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"../../packem_shared/mailomatProvider-
|
|
1
|
+
import{default as r}from"../../packem_shared/mailomatProvider-DPDpVS8r.js";export{r as mailomatProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"../../packem_shared/mailPaceProvider-
|
|
1
|
+
import{default as r}from"../../packem_shared/mailPaceProvider-DCa-4ghl.js";export{r as mailPaceProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../packem_shared/mailtrapProvider-
|
|
1
|
+
import{default as e}from"../../packem_shared/mailtrapProvider-DtrS4Q34.js";export{e as mailtrapProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as d}from"../../packem_shared/mandrillProvider-
|
|
1
|
+
import{default as d}from"../../packem_shared/mandrillProvider-B84zH-eV.js";export{d as mandrillProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../../packem_shared/netcoreProvider-
|
|
1
|
+
import{default as o}from"../../packem_shared/netcoreProvider-D-wtCyJj.js";export{o as netcoreProvider};
|