meta-cloud-api 0.1.0 → 0.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/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/messages.js +1 -1
- package/dist/api/messages.js.map +1 -1
- package/dist/api/messages.mjs +1 -1
- package/dist/api/messages.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/importConfig.js +1 -1
- package/dist/utils/importConfig.js.map +1 -1
- package/dist/utils/importConfig.mjs +1 -1
- package/dist/utils/importConfig.mjs.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/whatsapp.js +1 -1
- package/dist/whatsapp.js.map +1 -1
- package/dist/whatsapp.mjs +1 -1
- package/dist/whatsapp.mjs.map +1 -1
- package/package.json +3 -2
package/dist/whatsapp.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var fe=Object.defineProperty;var le=(a,t)=>{for(var s in t)fe(a,s,{get:t[s],enumerable:!0})};var W={};le(W,{AudioMediaTypesEnum:()=>E,BusinessVerticalEnum:()=>ae,ButtonPositionEnum:()=>Y,ButtonTypesEnum:()=>X,CategoryEnum:()=>x,ComponentTypesEnum:()=>k,ConversationTypesEnum:()=>y,CurrencyCodesEnum:()=>oe,DataLocalizationRegionEnum:()=>re,DocumentMediaTypesEnum:()=>u,HttpMethodsEnum:()=>I,ImageMediaTypesEnum:()=>z,InteractiveTypesEnum:()=>j,LanguagesEnum:()=>ie,MessageTypesEnum:()=>L,ParametersTypesEnum:()=>$,ReferralSourceTypesEnum:()=>te,RequestCodeMethodsEnum:()=>se,StatusEnum:()=>V,StickerMediaTypesEnum:()=>Q,SystemChangeTypesEnum:()=>ee,TemplateStatusEnum:()=>v,VideoMediaTypesEnum:()=>Z,WabaConfigEnum:()=>h,WebhookTypesEnum:()=>C});var x=(i=>(i.Authentication="AUTHENTICATION",i.Marketing="MARKETING",i.Utility="UTILITY",i))(x||{}),v=(i=>(i.Approved="APPROVED",i.Pending="PENDING",i.Rejected="REJECTED",i))(v||{}),I=(r=>(r.Get="GET",r.Post="POST",r.Put="PUT",r.Delete="DELETE",r))(I||{}),L=(l=>(l.Audio="audio",l.Contacts="contacts",l.Document="document",l.Image="image",l.Interactive="interactive",l.Location="location",l.Reaction="sticker",l.Sticker="sticker",l.Template="template",l.Text="text",l.Video="video",l))(L||{}),$=(c=>(c.Currency="currency",c.DateTime="date_time",c.Document="document",c.Image="image",c.Text="text",c.Video="video",c.Payload="payload",c))($||{}),j=(R=>(R.Button="button",R.List="list",R.Product="product",R.ProductList="product_list",R.CtaUrl="cta_url",R.LocationRequest="location_request_message",R.AddressMessage="address_message",R.Flow="flow",R))(j||{}),X=(s=>(s.QuickReply="quick_reply",s.URL="url",s))(X||{}),Y=(i=>(i[i.First=0]="First",i[i.Second=1]="Second",i[i.Third=2]="Third",i))(Y||{}),k=(r=>(r.Header="HEADER",r.Body="BODY",r.Button="BUTTON",r.Footer="FOOTER",r))(k||{}),h=(n=>(n.BaseURL="WA_BASE_URL",n.AppId="M4D_APP_ID",n.Port="WA_PORT",n.AppSecret="M4D_APP_SECRET",n.PhoneNumberId="WA_PHONE_NUMBER_ID",n.BusinessAcctId="WA_BUSINESS_ACCOUNT_ID",n.APIVersion="CLOUD_API_VERSION",n.AccessToken="CLOUD_API_ACCESS_TOKEN",n.WebhookEndpoint="WEBHOOK_ENDPOINT",n.WebhookVerificationToken="WEBHOOK_VERIFICATION_TOKEN",n.ListenerPort="LISTENER_PORT",n.MaxRetriesAfterWait="MAX_RETRIES_AFTER_WAIT",n.RequestTimeout="REQUEST_TIMEOUT",n.Debug="DEBUG",n))(h||{}),y=(i=>(i.BusinessInitiated="business_initiated",i.CustomerInitiated="customer_initiated",i.ReferralConversion="referral_conversion",i))(y||{}),V=(i=>(i.Delivered="delivered",i.Read="read",i.Sent="sent",i))(V||{}),Z=(s=>(s.Mp4="video/mp4",s.Threegp="video/3gp",s))(Z||{}),Q=(t=>(t.Webp="image/webp",t))(Q||{}),z=(s=>(s.Jpeg="image/jpeg",s.Png="image/png",s))(z||{}),u=(R=>(R.Text="text/plain",R.Pdf="application/pdf",R.Ppt="application/vnd.ms-powerpoint",R.Word="application/msword",R.Excel="application/vnd.ms-excel",R.OpenDoc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",R.OpenPres="application/vnd.openxmlformats-officedocument.presentationml.presentation",R.OpenSheet="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",R))(u||{}),E=(f=>(f.Aac="audio/aac",f.Mp4="audio/mp4",f.Mpeg="audio/mpeg",f.Amr="audio/amr",f.Ogg="audio/ogg",f))(E||{}),C=(l=>(l.Audio="audio",l.Button="button",l.Document="document",l.Text="text",l.Image="image",l.Interactive="interactive",l.Order="order",l.Sticker="sticker",l.System="system",l.Unknown="unknown",l.Video="video",l))(C||{}),ee=(s=>(s.CustomerChangedNumber="customer_changed_number",s.CustomerIdentityChanged="customer_identity_changed",s))(ee||{}),te=(s=>(s.Ad="ad",s.Post="post",s))(te||{}),se=(s=>(s.Sms="SMS",s.Voice="VOICE",s))(se||{}),ie=(o=>(o.Afrikaans="af",o.Albanian="sq",o.Arabic="ar",o.Azerbaijani="az",o.Bengali="bn",o.Bulgarian="bg",o.Catalan="ca",o.Chinese_CHN="zh_CN",o.Chinese_HKG="zh_HK",o.Chinese_TAI="zh_TW",o.Croatian="hr",o.Czech="cs",o.Danish="da",o.Dutch="nl",o.English="en",o.English_UK="en_GB",o.English_US="en_US",o.Estonian="et",o.Filipino="fil",o.Finnish="fi",o.French="fr",o.Georgian="ka",o.German="de",o.Greek="el",o.Gujarati="gu",o.Hausa="ha",o.Hebrew="he",o.Hindi="hi",o.Hungarian="hu",o.Indonesian="id",o.Irish="ga",o.Italian="it",o.Japanese="ja",o.Kannada="kn",o.Kazakh="kk",o.Kinyarwanda="rw_RW",o.Korean="ko",o.Kyrgyz_Kyrgyzstan="ky_KG",o.Lao="lo",o.Latvian="lv",o.Lithuanian="lt",o.Macedonian="mk",o.Malay="ms",o.Malayalam="ml",o.Marathi="mr",o.Norwegian="nb",o.Persian="fa",o.Polish="pl",o.Portuguese_BR="pt_BR",o.Portuguese_POR="pt_PT",o.Punjabi="pa",o.Romanian="ro",o.Russian="ru",o.Serbian="sr",o.Slovak="sk",o.Slovenian="sl",o.Spanish="es",o.Spanish_ARG="es_AR",o.Spanish_SPA="es_ES",o.Spanish_MEX="es_MX",o.Swahili="sw",o.Swedish="sv",o.Tamil="ta",o.Telugu="te",o.Thai="th",o.Turkish="tr",o.Ukrainian="uk",o.Urdu="ur",o.Uzbek="uz",o.Vietnamese="vi",o.Zulu="zu",o))(ie||{}),oe=(e=>(e.AFN="AFN",e.EUR="EUR",e.ALL="ALL",e.DZD="DZD",e.USD="USD",e.AOA="AOA",e.XCD="XCD",e.ARS="ARS",e.AMD="AMD",e.AWG="AWG",e.AUD="AUD",e.AZN="AZN",e.BSD="BSD",e.BHD="BHD",e.BDT="BDT",e.BBD="BBD",e.BYN="BYN",e.BZD="BZD",e.XOF="XOF",e.BMD="BMD",e.INR="INR",e.BTN="BTN",e.BOB="BOB",e.BOV="BOV",e.BAM="BAM",e.BWP="BWP",e.NOK="NOK",e.BRL="BRL",e.BND="BND",e.BGN="BGN",e.BIF="BIF",e.CVE="CVE",e.KHR="KHR",e.XAF="XAF",e.CAD="CAD",e.KYD="KYD",e.CLP="CLP",e.CLF="CLF",e.CNY="CNY",e.COP="COP",e.COU="COU",e.KMF="KMF",e.CDF="CDF",e.NZD="NZD",e.CRC="CRC",e.HRK="HRK",e.CUP="CUP",e.CUC="CUC",e.ANG="ANG",e.CZK="CZK",e.DKK="DKK",e.DJF="DJF",e.DOP="DOP",e.EGP="EGP",e.SVC="SVC",e.ERN="ERN",e.SZL="SZL",e.ETB="ETB",e.FKP="FKP",e.FJD="FJD",e.XPF="XPF",e.GMD="GMD",e.GEL="GEL",e.GHS="GHS",e.GIP="GIP",e.GTQ="GTQ",e.GBP="GBP",e.GNF="GNF",e.GYD="GYD",e.HTG="HTG",e.HNL="HNL",e.HKD="HKD",e.HUF="HUF",e.ISK="ISK",e.IDR="IDR",e.XDR="XDR",e.IRR="IRR",e.IQD="IQD",e.ILS="ILS",e.JMD="JMD",e.JPY="JPY",e.JOD="JOD",e.KZT="KZT",e.KES="KES",e.KPW="KPW",e.KRW="KRW",e.KWD="KWD",e.KGS="KGS",e.LAK="LAK",e.LBP="LBP",e.LSL="LSL",e.ZAR="ZAR",e.LRD="LRD",e.LYD="LYD",e.CHF="CHF",e.MOP="MOP",e.MKD="MKD",e.MGA="MGA",e.MWK="MWK",e.MYR="MYR",e.MVR="MVR",e.MRU="MRU",e.MUR="MUR",e.XUA="XUA",e.MXN="MXN",e.MXV="MXV",e.MDL="MDL",e.MNT="MNT",e.MAD="MAD",e.MZN="MZN",e.MMK="MMK",e.NAD="NAD",e.NPR="NPR",e.NIO="NIO",e.NGN="NGN",e.OMR="OMR",e.PKR="PKR",e.PAB="PAB",e.PGK="PGK",e.PYG="PYG",e.PEN="PEN",e.PHP="PHP",e.PLN="PLN",e.QAR="QAR",e.RON="RON",e.RUB="RUB",e.RWF="RWF",e.SHP="SHP",e.WST="WST",e.STN="STN",e.SAR="SAR",e.RSD="RSD",e.SCR="SCR",e.SLL="SLL",e.SGD="SGD",e.XSU="XSU",e.SBD="SBD",e.SOS="SOS",e.SSP="SSP",e.LKR="LKR",e.SDG="SDG",e.SRD="SRD",e.SEK="SEK",e.CHE="CHE",e.CHW="CHW",e.SYP="SYP",e.TWD="TWD",e.TJS="TJS",e.TZS="TZS",e.THB="THB",e.TOP="TOP",e.TTD="TTD",e.TND="TND",e.TRY="TRY",e.TMT="TMT",e.UGX="UGX",e.UAH="UAH",e.AED="AED",e.USN="USN",e.UYU="UYU",e.UYI="UYI",e.UYW="UYW",e.UZS="UZS",e.VUV="VUV",e.VES="VES",e.VND="VND",e.YER="YER",e.ZMW="ZMW",e.ZWL="ZWL",e.XBA="XBA",e.XBB="XBB",e.XBC="XBC",e.XBD="XBD",e.XTS="XTS",e.XXX="XXX",e.XAU="XAU",e.XPD="XPD",e.XPT="XPT",e.XAG="XAG",e.AFA="AFA",e.FIM="FIM",e.ALK="ALK",e.ADP="ADP",e.ESP="ESP",e.FRF="FRF",e.AOK="AOK",e.AON="AON",e.AOR="AOR",e.ARA="ARA",e.ARP="ARP",e.ARY="ARY",e.RUR="RUR",e.ATS="ATS",e.AYM="AYM",e.AZM="AZM",e.BYB="BYB",e.BYR="BYR",e.BEC="BEC",e.BEF="BEF",e.BEL="BEL",e.BOP="BOP",e.BAD="BAD",e.BRB="BRB",e.BRC="BRC",e.BRE="BRE",e.BRN="BRN",e.BRR="BRR",e.BGJ="BGJ",e.BGK="BGK",e.BGL="BGL",e.BUK="BUK",e.HRD="HRD",e.CYP="CYP",e.CSJ="CSJ",e.CSK="CSK",e.ECS="ECS",e.ECV="ECV",e.GQE="GQE",e.EEK="EEK",e.XEU="XEU",e.GEK="GEK",e.DDM="DDM",e.DEM="DEM",e.GHC="GHC",e.GHP="GHP",e.GRD="GRD",e.GNE="GNE",e.GNS="GNS",e.GWE="GWE",e.GWP="GWP",e.ITL="ITL",e.ISJ="ISJ",e.IEP="IEP",e.ILP="ILP",e.ILR="ILR",e.LAJ="LAJ",e.LVL="LVL",e.LVR="LVR",e.LSM="LSM",e.ZAL="ZAL",e.LTL="LTL",e.LTT="LTT",e.LUC="LUC",e.LUF="LUF",e.LUL="LUL",e.MGF="MGF",e.MVQ="MVQ",e.MLF="MLF",e.MTL="MTL",e.MTP="MTP",e.MRO="MRO",e.MXP="MXP",e.MZE="MZE",e.MZM="MZM",e.NLG="NLG",e.NIC="NIC",e.PEH="PEH",e.PEI="PEI",e.PES="PES",e.PLZ="PLZ",e.PTE="PTE",e.ROK="ROK",e.ROL="ROL",e.STD="STD",e.CSD="CSD",e.SKK="SKK",e.SIT="SIT",e.RHD="RHD",e.ESA="ESA",e.ESB="ESB",e.SDD="SDD",e.SDP="SDP",e.SRG="SRG",e.CHC="CHC",e.TJR="TJR",e.TPE="TPE",e.TRL="TRL",e.TMM="TMM",e.UGS="UGS",e.UGW="UGW",e.UAK="UAK",e.SUR="SUR",e.USS="USS",e.UYN="UYN",e.UYP="UYP",e.VEB="VEB",e.VEF="VEF",e.VNC="VNC",e.YDD="YDD",e.YUD="YUD",e.YUM="YUM",e.YUN="YUN",e.ZRN="ZRN",e.ZRZ="ZRZ",e.ZMK="ZMK",e.ZWC="ZWC",e.ZWD="ZWD",e.ZWN="ZWN",e.ZWR="ZWR",e.XFO="XFO",e.XRE="XRE",e.XFU="XFU",e))(oe||{}),re=(n=>(n.AU="AU",n.ID="ID",n.IN="IN",n.JP="JP",n.SG="SG",n.KR="KR",n.DE="DE",n.CH="CH",n.GB="GB",n.BR="BR",n.BH="BH",n.ZA="ZA",n.AE="AE",n.CA="CA",n))(re||{}),ae=(g=>(g.ALCOHOL="ALCOHOL",g.APPAREL="APPAREL",g.AUTO="AUTO",g.BEAUTY="BEAUTY",g.EDU="EDU",g.ENTERTAIN="ENTERTAIN",g.EVENT_PLAN="EVENT_PLAN",g.FINANCE="FINANCE",g.GOVT="GOVT",g.GROCERY="GROCERY",g.HEALTH="HEALTH",g.HOTEL="HOTEL",g.NONPROFIT="NONPROFIT",g.ONLINE_GAMBLING="ONLINE_GAMBLING",g.OTC_DRUGS="OTC_DRUGS",g.OTHER="OTHER",g.PHYSICAL_GAMBLING="PHYSICAL_GAMBLING",g.PROF_SERVICES="PROF_SERVICES",g.RESTAURANT="RESTAURANT",g.RETAIL="RETAIL",g.TRAVEL="TRAVEL",g))(ae||{});var P=class{name;debug;constructor(t,s=!1){this.name=t,this.debug=s}log(...t){if(this.debug){let s=`[ ${Date.now()} ]`;this.name&&(s+=` - ${this.name}`),console.log.apply(console,[s,": ",...t])}}error(...t){let s=`[ ${Date.now()} ] - ERROR`;this.name&&(s+=` - ${this.name}`),console.error.apply(console,[s,": ",...t])}warn(...t){let s=`[ ${Date.now()} ] - WARN`;this.name&&(s+=` - ${this.name}`),console.warn.apply(console,[s,": ",...t])}info(...t){let s=`[ ${Date.now()} ] - INFO`;this.name&&(s+=` - ${this.name}`),console.info.apply(console,[s,": ",...t])}};var ce="BaseAPI",ge=!1,he=new P(ce,process.env.DEBUG==="true"||ge),p=class{config;client;constructor(t,s){this.config=t,this.client=s,he.log("Initialized with HTTPSClient")}sendJson(t,s,i,r){return this.client.getJson(t,s,i,r)}};var A=a=>{if(!a||Object.keys(a).length===0)return"";let t=new URLSearchParams;for(let[i,r]of Object.entries(a))r!==void 0&&t.append(i,String(r));let s=t.toString();return s?`?${s}`:""};var S=class extends p{endpoint="whatsapp_business_profile";constructor(t,s){super(t,s)}async getBusinessProfile(t){let s=t?A({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${s}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,s,i){let r=A({file_length:t,file_type:s,file_name:i});return this.sendJson("POST",`app/uploads/${r}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,s)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var T=class extends p{endpoint="whatsapp_business_encryption";constructor(t,s){super(t,s)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let s=new FormData;return s.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}};var Pe="FlowAPI",Ie=!1,de=new P(Pe,process.env.DEBUG==="true"||Ie),m=class extends p{constructor(t,s){super(t,s),de.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,s){let i=new FormData;return s.name&&i.append("name",s.name),s.categories&&i.append("categories",JSON.stringify(s.categories)),s.endpoint_uri&&i.append("endpoint_uri",s.endpoint_uri),s.clone_flow_id&&i.append("clone_flow_id",s.clone_flow_id),s.flow_json&&i.append("flow_json",s.flow_json),s.publish!==void 0&&i.append("publish",String(s.publish)),this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,i)}async getFlow(t,s,i){let r=new URLSearchParams;s&&r.append("fields",s),i&&r.append("date_format",i);let f=r.toString()?`?${r.toString()}`:"";return this.sendJson("GET",`/${t}${f}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(t,s){let i=new FormData;return s.name&&i.append("name",s.name),s.categories&&i.append("categories",JSON.stringify(s.categories)),s.endpoint_uri&&i.append("endpoint_uri",s.endpoint_uri),s.application_id&&i.append("application_id",s.application_id),this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,i)}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,s){let i=new FormData;return i.append("asset_type",s.asset_type),i.append("file",s.file),i.append("name",s.name),this.sendJson("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,i)}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,s){let i=new FormData;return i.append("source_waba_id",s.source_waba_id),s.source_flow_names&&i.append("source_flow_names",JSON.stringify(s.source_flow_names)),this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,i)}};var b=class extends p{endpoint="media";constructor(t,s){super(t,s)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s="whatsapp"){let i=new FormData;return i.append("file",t),i.append("messaging_product",s),i.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,i)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var _=class extends p{commonMethod="POST";commonEndpoint="messages";constructor(t,s){super(t,s)}bodyBuilder(t,s,i,r){let f={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:s};return r&&(f.context={message_id:r}),f}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",s,i,r)))}async contacts(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",s,i,r)))}async document(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("document",s,i,r)))}async image(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("image",s,i,r)))}async interactive(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async location(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("location",s,i,r)))}async sticker(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",s,i,r)))}async template(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("template",s,i,r)))}async text(t){let{body:s,previewUrl:i,to:r,replyMessageId:f}=t,d;return typeof s=="string"?d={body:s,preview_url:i}:d=s,this.send(JSON.stringify(this.bodyBuilder("text",d,r,f)))}async video(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("video",s,i,r)))}async status(t){let{status:s,messageId:i,typingIndicator:r}=t,f={messaging_product:"whatsapp",status:s,message_id:i,...r&&{typing_indicator:r}};return this.send(JSON.stringify(f))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveCtaUrl(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveLocationRequest(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveAddressMessage(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveReplyButtons(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveFlow(t){let{body:s,to:i,replyMessageId:r}=t;return s.action.parameters.flow_message_version===void 0&&(s.action.parameters.flow_message_version="3"),s.action.parameters.mode===void 0&&(s.action.parameters.mode="published"),s.action.parameters.flow_action===void 0&&(s.action.parameters.flow_action="navigate"),s.action.parameters.flow_action_payload?.screen===void 0&&(s.action.parameters.flow_action_payload={...s.action.parameters.flow_action_payload,screen:"FIRST_ENTRY_SCREEN"}),this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async reaction(t){let{messageId:s,emoji:i,to:r}=t,f={messaging_product:"whatsapp",recipient_type:"individual",to:r,type:"reaction",reaction:{message_id:s,emoji:i}};return this.send(JSON.stringify(f))}};var N=class extends p{endpoint="phone_numbers";constructor(t,s){super(t,s)}async getPhoneNumberById(t){let s=t?A({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var M=class extends p{endpoint="message_qrdls";constructor(t,s){super(t,s)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var q=class extends p{constructor(t,s){super(t,s)}async register(t,s){let i={messaging_product:"whatsapp",pin:t,...s&&{data_localization_region:s}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var O=class extends p{endpoint="message_templates";constructor(t,s){super(t,s)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,s){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}};var D=class extends p{constructor(t,s){super(t,s)}async setTwoStepVerificationCode(t){let s={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var B=class extends p{constructor(t,s){super(t,s)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:s}){let i={override_callback_uri:t,verify_token:s};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};import{Agent as Ae}from"https";var Se="HttpsClient",Te=!1,me=new P(Se,process.env.DEBUG==="true"||Te),U=class{agent;constructor(){this.agent=new Ae({keepAlive:!0})}clearSockets(){return this.agent.destroy(),!0}async sendRequest(t,s,i,r,f,d){let c=`https://${t}/${s}`,R=new AbortController,Re=setTimeout(()=>R.abort(),f);try{let F=await fetch(c,{method:i,headers:r,body:d,signal:R.signal});return me.log(`${i} : ${c} - ${JSON.stringify(F)}`),clearTimeout(Re),new J(F)}catch(F){throw F}}},J=class{res;respStatusCode;respHeaders;constructor(t){this.res=t,this.respStatusCode=t.status,this.respHeaders=Object.fromEntries(t.headers.entries())}statusCode(){return this.respStatusCode}headers(){return this.respHeaders}rawResponse(){return this.res}async json(){try{return await this.res.json()}catch(t){throw new Error("Failed to parse response body to JSON: "+t.message)}}};function K(a){return a!=null&&typeof a=="object"&&"error"in a&&typeof a.error=="object"&&a.error!=null&&"message"in a.error&&typeof a.error.message=="string"&&"type"in a.error&&typeof a.error.type=="string"&&"code"in a.error&&typeof a.error.code=="number"&&"fbtrace_id"in a.error&&typeof a.error.fbtrace_id=="string"&&(!("error_data"in a.error)||typeof a.error.error_data=="object"&&a.error.error_data!=null&&"messaging_product"in a.error.error_data&&a.error.error_data.messaging_product==="whatsapp"&&"details"in a.error.error_data&&typeof a.error.error_data.details=="string")&&(!("error_subcode"in a.error)||typeof a.error.error_subcode=="number")}var be="REQUESTER",_e=!1,Ne=new P(be,process.env.DEBUG==="true"||_e),w=class{client;accessToken;phoneNumberId;businessAcctId;apiVersion;userAgent;host;protocol="https:";constructor(t,s,i,r,f,d){this.client=new U,this.host=t||"graph.facebook.com",this.apiVersion=s||"22",this.phoneNumberId=i,this.accessToken=r,this.businessAcctId=f,this.userAgent=d}buildHeader(t){return{"Content-Type":t,Authorization:`Bearer ${this.accessToken}`,"User-Agent":this.userAgent}}buildCAPIPath(t){return`v${this.apiVersion}.0/${t}`}async sendRequest(t,s,i,r){let f="application/json",d=`${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(s)}`;Ne.log(`${t} : ${d}`);try{let c=await this.client.sendRequest(this.host,this.buildCAPIPath(s),t,this.buildHeader(f),i,t==="POST"||t==="PUT"?r:void 0);if(!c.rawResponse().ok){let R=await c.json();throw K(R)?R:{name:"MetaError",message:"Unknown error occurred",error:{message:R.message||"Unknown error occurred",type:"UnknownError",code:c.statusCode(),fbtrace_id:""}}}return c}catch(c){throw K(c)?c:{name:"MetaError",message:c instanceof Error?c.message:"Network error occurred",error:{message:c instanceof Error?c.message:"Network error occurred",type:"NetworkError",code:500,fbtrace_id:""}}}}async getJson(t,s,i,r){return await(await this.sendRequest(t,s,i,r)).json()}};var Me="UTILS",qe=!1,ne=new P(Me,process.env.DEBUG==="true"||qe),Oe="graph.facebook.com",De=3e3,Be=30,Ue=2e4,we=a=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!a?.accessToken)throw ne.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},pe=a=>{we(a);let t={WA_BASE_URL:process.env.WA_BASE_URL||Oe,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:a?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:a?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:a?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||De,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||Be,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||Ue,DEBUG:process.env.DEBUG==="true"};return ne.log(`Configuration loaded for App Id ${t.M4D_APP_ID}`),t};var Ge="WHATSAPP",Fe=!1,G=new P(Ge,process.env.DEBUG==="true"||Fe),Le="WA_SDK",H=class{config;requester;messages;templates;phoneNumber;qrCode;encryption;twoStepVerification;registration;media;waba;flow;businessProfile;static Enums=W;constructor(t){this.config=pe(t),this.requester=new w(this.config.WA_BASE_URL,this.config.CLOUD_API_VERSION,this.config.WA_PHONE_NUMBER_ID,this.config.CLOUD_API_ACCESS_TOKEN,this.config.WA_BUSINESS_ACCOUNT_ID,this.userAgent()),this.messages=new _(this.config,this.requester),this.templates=new O(this.config,this.requester),this.phoneNumber=new N(this.config,this.requester),this.qrCode=new M(this.config,this.requester),this.encryption=new T(this.config,this.requester),this.twoStepVerification=new D(this.config,this.requester),this.registration=new q(this.config,this.requester),this.media=new b(this.config,this.requester),this.waba=new B(this.config,this.requester),this.flow=new m(this.config,this.requester),this.businessProfile=new S(this.config,this.requester),G.log("WhatsApp Node.js SDK instantiated!")}userAgent(){return`${Le}/0.0.1 (Node.js ${process.version})`}updateTimeout(t){return this.config.REQUEST_TIMEOUT=t,G.log(`Updated request timeout to ${t}ms`),!0}updatePhoneNumberId(t){return this.config.WA_PHONE_NUMBER_ID=t,G.log(`Updated sender phone number id to ${t}`),!0}updateAccessToken(t){return this.config.CLOUD_API_ACCESS_TOKEN=t,G.log("Updated access token"),!0}updateWabaId(t){return this.config.WA_BUSINESS_ACCOUNT_ID=t,G.log(`Updated business account id to ${t}`),!0}};export{H as default};
|
|
1
|
+
var fe=Object.defineProperty;var le=(a,t)=>{for(var s in t)fe(a,s,{get:t[s],enumerable:!0})};var W={};le(W,{AudioMediaTypesEnum:()=>E,BusinessVerticalEnum:()=>ae,ButtonPositionEnum:()=>Y,ButtonTypesEnum:()=>X,CategoryEnum:()=>H,ComponentTypesEnum:()=>y,ConversationTypesEnum:()=>k,CurrencyCodesEnum:()=>oe,DataLocalizationRegionEnum:()=>re,DocumentMediaTypesEnum:()=>u,HttpMethodsEnum:()=>I,ImageMediaTypesEnum:()=>z,InteractiveTypesEnum:()=>j,LanguagesEnum:()=>ie,MessageTypesEnum:()=>L,ParametersTypesEnum:()=>$,ReferralSourceTypesEnum:()=>te,RequestCodeMethodsEnum:()=>se,StatusEnum:()=>V,StickerMediaTypesEnum:()=>Q,SystemChangeTypesEnum:()=>ee,TemplateStatusEnum:()=>v,VideoMediaTypesEnum:()=>Z,WabaConfigEnum:()=>h,WebhookTypesEnum:()=>C});var H=(i=>(i.Authentication="AUTHENTICATION",i.Marketing="MARKETING",i.Utility="UTILITY",i))(H||{}),v=(i=>(i.Approved="APPROVED",i.Pending="PENDING",i.Rejected="REJECTED",i))(v||{}),I=(r=>(r.Get="GET",r.Post="POST",r.Put="PUT",r.Delete="DELETE",r))(I||{}),L=(l=>(l.Audio="audio",l.Contacts="contacts",l.Document="document",l.Image="image",l.Interactive="interactive",l.Location="location",l.Reaction="sticker",l.Sticker="sticker",l.Template="template",l.Text="text",l.Video="video",l))(L||{}),$=(c=>(c.Currency="currency",c.DateTime="date_time",c.Document="document",c.Image="image",c.Text="text",c.Video="video",c.Payload="payload",c))($||{}),j=(R=>(R.Button="button",R.List="list",R.Product="product",R.ProductList="product_list",R.CtaUrl="cta_url",R.LocationRequest="location_request_message",R.AddressMessage="address_message",R.Flow="flow",R))(j||{}),X=(s=>(s.QuickReply="quick_reply",s.URL="url",s))(X||{}),Y=(i=>(i[i.First=0]="First",i[i.Second=1]="Second",i[i.Third=2]="Third",i))(Y||{}),y=(r=>(r.Header="HEADER",r.Body="BODY",r.Button="BUTTON",r.Footer="FOOTER",r))(y||{}),h=(n=>(n.BaseURL="WA_BASE_URL",n.AppId="M4D_APP_ID",n.Port="WA_PORT",n.AppSecret="M4D_APP_SECRET",n.PhoneNumberId="WA_PHONE_NUMBER_ID",n.BusinessAcctId="WA_BUSINESS_ACCOUNT_ID",n.APIVersion="CLOUD_API_VERSION",n.AccessToken="CLOUD_API_ACCESS_TOKEN",n.WebhookEndpoint="WEBHOOK_ENDPOINT",n.WebhookVerificationToken="WEBHOOK_VERIFICATION_TOKEN",n.ListenerPort="LISTENER_PORT",n.MaxRetriesAfterWait="MAX_RETRIES_AFTER_WAIT",n.RequestTimeout="REQUEST_TIMEOUT",n.Debug="DEBUG",n))(h||{}),k=(i=>(i.BusinessInitiated="business_initiated",i.CustomerInitiated="customer_initiated",i.ReferralConversion="referral_conversion",i))(k||{}),V=(i=>(i.Delivered="delivered",i.Read="read",i.Sent="sent",i))(V||{}),Z=(s=>(s.Mp4="video/mp4",s.Threegp="video/3gp",s))(Z||{}),Q=(t=>(t.Webp="image/webp",t))(Q||{}),z=(s=>(s.Jpeg="image/jpeg",s.Png="image/png",s))(z||{}),u=(R=>(R.Text="text/plain",R.Pdf="application/pdf",R.Ppt="application/vnd.ms-powerpoint",R.Word="application/msword",R.Excel="application/vnd.ms-excel",R.OpenDoc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",R.OpenPres="application/vnd.openxmlformats-officedocument.presentationml.presentation",R.OpenSheet="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",R))(u||{}),E=(f=>(f.Aac="audio/aac",f.Mp4="audio/mp4",f.Mpeg="audio/mpeg",f.Amr="audio/amr",f.Ogg="audio/ogg",f))(E||{}),C=(l=>(l.Audio="audio",l.Button="button",l.Document="document",l.Text="text",l.Image="image",l.Interactive="interactive",l.Order="order",l.Sticker="sticker",l.System="system",l.Unknown="unknown",l.Video="video",l))(C||{}),ee=(s=>(s.CustomerChangedNumber="customer_changed_number",s.CustomerIdentityChanged="customer_identity_changed",s))(ee||{}),te=(s=>(s.Ad="ad",s.Post="post",s))(te||{}),se=(s=>(s.Sms="SMS",s.Voice="VOICE",s))(se||{}),ie=(o=>(o.Afrikaans="af",o.Albanian="sq",o.Arabic="ar",o.Azerbaijani="az",o.Bengali="bn",o.Bulgarian="bg",o.Catalan="ca",o.Chinese_CHN="zh_CN",o.Chinese_HKG="zh_HK",o.Chinese_TAI="zh_TW",o.Croatian="hr",o.Czech="cs",o.Danish="da",o.Dutch="nl",o.English="en",o.English_UK="en_GB",o.English_US="en_US",o.Estonian="et",o.Filipino="fil",o.Finnish="fi",o.French="fr",o.Georgian="ka",o.German="de",o.Greek="el",o.Gujarati="gu",o.Hausa="ha",o.Hebrew="he",o.Hindi="hi",o.Hungarian="hu",o.Indonesian="id",o.Irish="ga",o.Italian="it",o.Japanese="ja",o.Kannada="kn",o.Kazakh="kk",o.Kinyarwanda="rw_RW",o.Korean="ko",o.Kyrgyz_Kyrgyzstan="ky_KG",o.Lao="lo",o.Latvian="lv",o.Lithuanian="lt",o.Macedonian="mk",o.Malay="ms",o.Malayalam="ml",o.Marathi="mr",o.Norwegian="nb",o.Persian="fa",o.Polish="pl",o.Portuguese_BR="pt_BR",o.Portuguese_POR="pt_PT",o.Punjabi="pa",o.Romanian="ro",o.Russian="ru",o.Serbian="sr",o.Slovak="sk",o.Slovenian="sl",o.Spanish="es",o.Spanish_ARG="es_AR",o.Spanish_SPA="es_ES",o.Spanish_MEX="es_MX",o.Swahili="sw",o.Swedish="sv",o.Tamil="ta",o.Telugu="te",o.Thai="th",o.Turkish="tr",o.Ukrainian="uk",o.Urdu="ur",o.Uzbek="uz",o.Vietnamese="vi",o.Zulu="zu",o))(ie||{}),oe=(e=>(e.AFN="AFN",e.EUR="EUR",e.ALL="ALL",e.DZD="DZD",e.USD="USD",e.AOA="AOA",e.XCD="XCD",e.ARS="ARS",e.AMD="AMD",e.AWG="AWG",e.AUD="AUD",e.AZN="AZN",e.BSD="BSD",e.BHD="BHD",e.BDT="BDT",e.BBD="BBD",e.BYN="BYN",e.BZD="BZD",e.XOF="XOF",e.BMD="BMD",e.INR="INR",e.BTN="BTN",e.BOB="BOB",e.BOV="BOV",e.BAM="BAM",e.BWP="BWP",e.NOK="NOK",e.BRL="BRL",e.BND="BND",e.BGN="BGN",e.BIF="BIF",e.CVE="CVE",e.KHR="KHR",e.XAF="XAF",e.CAD="CAD",e.KYD="KYD",e.CLP="CLP",e.CLF="CLF",e.CNY="CNY",e.COP="COP",e.COU="COU",e.KMF="KMF",e.CDF="CDF",e.NZD="NZD",e.CRC="CRC",e.HRK="HRK",e.CUP="CUP",e.CUC="CUC",e.ANG="ANG",e.CZK="CZK",e.DKK="DKK",e.DJF="DJF",e.DOP="DOP",e.EGP="EGP",e.SVC="SVC",e.ERN="ERN",e.SZL="SZL",e.ETB="ETB",e.FKP="FKP",e.FJD="FJD",e.XPF="XPF",e.GMD="GMD",e.GEL="GEL",e.GHS="GHS",e.GIP="GIP",e.GTQ="GTQ",e.GBP="GBP",e.GNF="GNF",e.GYD="GYD",e.HTG="HTG",e.HNL="HNL",e.HKD="HKD",e.HUF="HUF",e.ISK="ISK",e.IDR="IDR",e.XDR="XDR",e.IRR="IRR",e.IQD="IQD",e.ILS="ILS",e.JMD="JMD",e.JPY="JPY",e.JOD="JOD",e.KZT="KZT",e.KES="KES",e.KPW="KPW",e.KRW="KRW",e.KWD="KWD",e.KGS="KGS",e.LAK="LAK",e.LBP="LBP",e.LSL="LSL",e.ZAR="ZAR",e.LRD="LRD",e.LYD="LYD",e.CHF="CHF",e.MOP="MOP",e.MKD="MKD",e.MGA="MGA",e.MWK="MWK",e.MYR="MYR",e.MVR="MVR",e.MRU="MRU",e.MUR="MUR",e.XUA="XUA",e.MXN="MXN",e.MXV="MXV",e.MDL="MDL",e.MNT="MNT",e.MAD="MAD",e.MZN="MZN",e.MMK="MMK",e.NAD="NAD",e.NPR="NPR",e.NIO="NIO",e.NGN="NGN",e.OMR="OMR",e.PKR="PKR",e.PAB="PAB",e.PGK="PGK",e.PYG="PYG",e.PEN="PEN",e.PHP="PHP",e.PLN="PLN",e.QAR="QAR",e.RON="RON",e.RUB="RUB",e.RWF="RWF",e.SHP="SHP",e.WST="WST",e.STN="STN",e.SAR="SAR",e.RSD="RSD",e.SCR="SCR",e.SLL="SLL",e.SGD="SGD",e.XSU="XSU",e.SBD="SBD",e.SOS="SOS",e.SSP="SSP",e.LKR="LKR",e.SDG="SDG",e.SRD="SRD",e.SEK="SEK",e.CHE="CHE",e.CHW="CHW",e.SYP="SYP",e.TWD="TWD",e.TJS="TJS",e.TZS="TZS",e.THB="THB",e.TOP="TOP",e.TTD="TTD",e.TND="TND",e.TRY="TRY",e.TMT="TMT",e.UGX="UGX",e.UAH="UAH",e.AED="AED",e.USN="USN",e.UYU="UYU",e.UYI="UYI",e.UYW="UYW",e.UZS="UZS",e.VUV="VUV",e.VES="VES",e.VND="VND",e.YER="YER",e.ZMW="ZMW",e.ZWL="ZWL",e.XBA="XBA",e.XBB="XBB",e.XBC="XBC",e.XBD="XBD",e.XTS="XTS",e.XXX="XXX",e.XAU="XAU",e.XPD="XPD",e.XPT="XPT",e.XAG="XAG",e.AFA="AFA",e.FIM="FIM",e.ALK="ALK",e.ADP="ADP",e.ESP="ESP",e.FRF="FRF",e.AOK="AOK",e.AON="AON",e.AOR="AOR",e.ARA="ARA",e.ARP="ARP",e.ARY="ARY",e.RUR="RUR",e.ATS="ATS",e.AYM="AYM",e.AZM="AZM",e.BYB="BYB",e.BYR="BYR",e.BEC="BEC",e.BEF="BEF",e.BEL="BEL",e.BOP="BOP",e.BAD="BAD",e.BRB="BRB",e.BRC="BRC",e.BRE="BRE",e.BRN="BRN",e.BRR="BRR",e.BGJ="BGJ",e.BGK="BGK",e.BGL="BGL",e.BUK="BUK",e.HRD="HRD",e.CYP="CYP",e.CSJ="CSJ",e.CSK="CSK",e.ECS="ECS",e.ECV="ECV",e.GQE="GQE",e.EEK="EEK",e.XEU="XEU",e.GEK="GEK",e.DDM="DDM",e.DEM="DEM",e.GHC="GHC",e.GHP="GHP",e.GRD="GRD",e.GNE="GNE",e.GNS="GNS",e.GWE="GWE",e.GWP="GWP",e.ITL="ITL",e.ISJ="ISJ",e.IEP="IEP",e.ILP="ILP",e.ILR="ILR",e.LAJ="LAJ",e.LVL="LVL",e.LVR="LVR",e.LSM="LSM",e.ZAL="ZAL",e.LTL="LTL",e.LTT="LTT",e.LUC="LUC",e.LUF="LUF",e.LUL="LUL",e.MGF="MGF",e.MVQ="MVQ",e.MLF="MLF",e.MTL="MTL",e.MTP="MTP",e.MRO="MRO",e.MXP="MXP",e.MZE="MZE",e.MZM="MZM",e.NLG="NLG",e.NIC="NIC",e.PEH="PEH",e.PEI="PEI",e.PES="PES",e.PLZ="PLZ",e.PTE="PTE",e.ROK="ROK",e.ROL="ROL",e.STD="STD",e.CSD="CSD",e.SKK="SKK",e.SIT="SIT",e.RHD="RHD",e.ESA="ESA",e.ESB="ESB",e.SDD="SDD",e.SDP="SDP",e.SRG="SRG",e.CHC="CHC",e.TJR="TJR",e.TPE="TPE",e.TRL="TRL",e.TMM="TMM",e.UGS="UGS",e.UGW="UGW",e.UAK="UAK",e.SUR="SUR",e.USS="USS",e.UYN="UYN",e.UYP="UYP",e.VEB="VEB",e.VEF="VEF",e.VNC="VNC",e.YDD="YDD",e.YUD="YUD",e.YUM="YUM",e.YUN="YUN",e.ZRN="ZRN",e.ZRZ="ZRZ",e.ZMK="ZMK",e.ZWC="ZWC",e.ZWD="ZWD",e.ZWN="ZWN",e.ZWR="ZWR",e.XFO="XFO",e.XRE="XRE",e.XFU="XFU",e))(oe||{}),re=(n=>(n.AU="AU",n.ID="ID",n.IN="IN",n.JP="JP",n.SG="SG",n.KR="KR",n.DE="DE",n.CH="CH",n.GB="GB",n.BR="BR",n.BH="BH",n.ZA="ZA",n.AE="AE",n.CA="CA",n))(re||{}),ae=(g=>(g.ALCOHOL="ALCOHOL",g.APPAREL="APPAREL",g.AUTO="AUTO",g.BEAUTY="BEAUTY",g.EDU="EDU",g.ENTERTAIN="ENTERTAIN",g.EVENT_PLAN="EVENT_PLAN",g.FINANCE="FINANCE",g.GOVT="GOVT",g.GROCERY="GROCERY",g.HEALTH="HEALTH",g.HOTEL="HOTEL",g.NONPROFIT="NONPROFIT",g.ONLINE_GAMBLING="ONLINE_GAMBLING",g.OTC_DRUGS="OTC_DRUGS",g.OTHER="OTHER",g.PHYSICAL_GAMBLING="PHYSICAL_GAMBLING",g.PROF_SERVICES="PROF_SERVICES",g.RESTAURANT="RESTAURANT",g.RETAIL="RETAIL",g.TRAVEL="TRAVEL",g))(ae||{});var P=class{name;debug;constructor(t,s=!1){this.name=t,this.debug=s}log(...t){if(this.debug){let s=`[ ${Date.now()} ]`;this.name&&(s+=` - ${this.name}`),console.log.apply(console,[s,": ",...t])}}error(...t){let s=`[ ${Date.now()} ] - ERROR`;this.name&&(s+=` - ${this.name}`),console.error.apply(console,[s,": ",...t])}warn(...t){let s=`[ ${Date.now()} ] - WARN`;this.name&&(s+=` - ${this.name}`),console.warn.apply(console,[s,": ",...t])}info(...t){let s=`[ ${Date.now()} ] - INFO`;this.name&&(s+=` - ${this.name}`),console.info.apply(console,[s,": ",...t])}};var ce="BaseAPI",ge=!1,he=new P(ce,process.env.DEBUG==="true"||ge),p=class{config;client;constructor(t,s){this.config=t,this.client=s,he.log("Initialized with HTTPSClient")}sendJson(t,s,i,r){return this.client.getJson(t,s,i,r)}};var A=a=>{if(!a||Object.keys(a).length===0)return"";let t=new URLSearchParams;for(let[i,r]of Object.entries(a))r!==void 0&&t.append(i,String(r));let s=t.toString();return s?`?${s}`:""};var T=class extends p{endpoint="whatsapp_business_profile";constructor(t,s){super(t,s)}async getBusinessProfile(t){let s=t?A({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${s}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,s,i){let r=A({file_length:t,file_type:s,file_name:i});return this.sendJson("POST",`app/uploads/${r}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,s)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var S=class extends p{endpoint="whatsapp_business_encryption";constructor(t,s){super(t,s)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let s=new FormData;return s.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}};var Pe="FlowAPI",Ie=!1,de=new P(Pe,process.env.DEBUG==="true"||Ie),m=class extends p{constructor(t,s){super(t,s),de.log("FlowAPI initialized")}async listFlows(t){return this.sendJson("GET",`/${t}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(t,s){let i=new FormData;return s.name&&i.append("name",s.name),s.categories&&i.append("categories",JSON.stringify(s.categories)),s.endpoint_uri&&i.append("endpoint_uri",s.endpoint_uri),s.clone_flow_id&&i.append("clone_flow_id",s.clone_flow_id),s.flow_json&&i.append("flow_json",s.flow_json),s.publish!==void 0&&i.append("publish",String(s.publish)),this.sendJson("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,i)}async getFlow(t,s,i){let r=new URLSearchParams;s&&r.append("fields",s),i&&r.append("date_format",i);let f=r.toString()?`?${r.toString()}`:"";return this.sendJson("GET",`/${t}${f}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(t,s){let i=new FormData;return s.name&&i.append("name",s.name),s.categories&&i.append("categories",JSON.stringify(s.categories)),s.endpoint_uri&&i.append("endpoint_uri",s.endpoint_uri),s.application_id&&i.append("application_id",s.application_id),this.sendJson("POST",`/${t}`,this.config.REQUEST_TIMEOUT,i)}async deleteFlow(t){return this.sendJson("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.sendJson("GET",`/${t}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(t,s){let i=new FormData;return i.append("asset_type",s.asset_type),i.append("file",s.file),i.append("name",s.name),this.sendJson("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,i)}async publishFlow(t){return this.sendJson("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.sendJson("POST",`/${t}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(t,s){let i=new FormData;return i.append("source_waba_id",s.source_waba_id),s.source_flow_names&&i.append("source_flow_names",JSON.stringify(s.source_flow_names)),this.sendJson("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,i)}};var b=class extends p{endpoint="media";constructor(t,s){super(t,s)}async getMediaById(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s="whatsapp"){let i=new FormData;return i.append("file",t),i.append("messaging_product",s),i.append("type",t.type),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,i)}async deleteMedia(t){return this.sendJson("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.sendJson("GET",t,this.config.REQUEST_TIMEOUT,null)}};var _=class extends p{commonMethod="POST";commonEndpoint="messages";constructor(t,s){super(t,s)}bodyBuilder(t,s,i,r){let f={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:s};return r&&(f.context={message_id:r}),f}send(t){return this.sendJson(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("audio",s,i,r)))}async contacts(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("contacts",s,i,r)))}async document(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("document",s,i,r)))}async image(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("image",s,i,r)))}async interactive(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async location(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("location",s,i,r)))}async sticker(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("sticker",s,i,r)))}async template(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("template",s,i,r)))}async text(t){let{body:s,previewUrl:i,to:r,replyMessageId:f}=t,d;return typeof s=="string"?d={body:s,preview_url:i}:d=s,this.send(JSON.stringify(this.bodyBuilder("text",d,r,f)))}async video(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("video",s,i,r)))}async status(t){let{status:s,messageId:i,typingIndicator:r}=t,f={messaging_product:"whatsapp",status:s,message_id:i,...r&&{typing_indicator:r}};return this.send(JSON.stringify(f))}async markAsRead(t){return this.status({status:"read",messageId:t.messageId})}async showTypingIndicator(t){return this.status({status:"read",messageId:t.messageId,typingIndicator:{type:"text"}})}async interactiveList(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveCtaUrl(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveLocationRequest(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveAddressMessage(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveReplyButtons(t){let{body:s,to:i,replyMessageId:r}=t;return this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async interactiveFlow(t){let{body:s,to:i,replyMessageId:r}=t;return s.action.parameters.flow_message_version===void 0&&(s.action.parameters.flow_message_version="3"),s.action.parameters.mode===void 0&&(s.action.parameters.mode="published"),s.action.parameters.flow_action===void 0&&(s.action.parameters.flow_action="navigate"),s.action.parameters.flow_action==="navigate"?s.action.parameters.flow_action_payload?.screen===void 0&&(s.action.parameters.flow_action_payload={...s.action.parameters.flow_action_payload,screen:"INIT"}):s.action.parameters.flow_action==="data_exchange"&&delete s.action.parameters.flow_action_payload,this.send(JSON.stringify(this.bodyBuilder("interactive",s,i,r)))}async reaction(t){let{messageId:s,emoji:i,to:r}=t,f={messaging_product:"whatsapp",recipient_type:"individual",to:r,type:"reaction",reaction:{message_id:s,emoji:i}};return this.send(JSON.stringify(f))}};var N=class extends p{endpoint="phone_numbers";constructor(t,s){super(t,s)}async getPhoneNumberById(t){let s=t?A({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var M=class extends p{endpoint="message_qrdls";constructor(t,s){super(t,s)}async createQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.sendJson("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var q=class extends p{constructor(t,s){super(t,s)}async register(t,s){let i={messaging_product:"whatsapp",pin:t,...s&&{data_localization_region:s}};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deregister(){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var O=class extends p{endpoint="message_templates";constructor(t,s){super(t,s)}async getTemplate(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,s){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getTemplates(t){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${A(t)}`,this.config.REQUEST_TIMEOUT,null)}};var D=class extends p{constructor(t,s){super(t,s)}async setTwoStepVerificationCode(t){let s={pin:t};return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var B=class extends p{constructor(t,s){super(t,s)}async getAllWabaSubscriptions(){return this.sendJson("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async updateWabaSubscription({override_callback_uri:t,verify_token:s}){let i={override_callback_uri:t,verify_token:s};return this.sendJson("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async unsubscribeFromWaba(){return this.sendJson("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}};import{Agent as Ae}from"https";var Te="HttpsClient",Se=!1,me=new P(Te,process.env.DEBUG==="true"||Se),U=class{agent;constructor(){this.agent=new Ae({keepAlive:!0})}clearSockets(){return this.agent.destroy(),!0}async sendRequest(t,s,i,r,f,d){let c=`https://${t}/${s}`,R=new AbortController,Re=setTimeout(()=>R.abort(),f);try{let F=await fetch(c,{method:i,headers:r,body:d,signal:R.signal});return me.log(`${i} : ${c} - ${JSON.stringify(F)}`),clearTimeout(Re),new J(F)}catch(F){throw F}}},J=class{res;respStatusCode;respHeaders;constructor(t){this.res=t,this.respStatusCode=t.status,this.respHeaders=Object.fromEntries(t.headers.entries())}statusCode(){return this.respStatusCode}headers(){return this.respHeaders}rawResponse(){return this.res}async json(){try{return await this.res.json()}catch(t){throw new Error("Failed to parse response body to JSON: "+t.message)}}};function K(a){return a!=null&&typeof a=="object"&&"error"in a&&typeof a.error=="object"&&a.error!=null&&"message"in a.error&&typeof a.error.message=="string"&&"type"in a.error&&typeof a.error.type=="string"&&"code"in a.error&&typeof a.error.code=="number"&&"fbtrace_id"in a.error&&typeof a.error.fbtrace_id=="string"&&(!("error_data"in a.error)||typeof a.error.error_data=="object"&&a.error.error_data!=null&&"messaging_product"in a.error.error_data&&a.error.error_data.messaging_product==="whatsapp"&&"details"in a.error.error_data&&typeof a.error.error_data.details=="string")&&(!("error_subcode"in a.error)||typeof a.error.error_subcode=="number")}var be="REQUESTER",_e=!1,Ne=new P(be,process.env.DEBUG==="true"||_e),w=class{client;accessToken;phoneNumberId;businessAcctId;apiVersion;userAgent;host;protocol="https:";constructor(t,s,i,r,f,d){this.client=new U,this.host=t||"graph.facebook.com",this.apiVersion=s||"22",this.phoneNumberId=i,this.accessToken=r,this.businessAcctId=f,this.userAgent=d}buildHeader(t){return{"Content-Type":t,Authorization:`Bearer ${this.accessToken}`,"User-Agent":this.userAgent}}buildCAPIPath(t){return`v${this.apiVersion}.0/${t}`}async sendRequest(t,s,i,r){let f="application/json",d=`${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(s)}`;Ne.log(`${t} : ${d}`);try{let c=await this.client.sendRequest(this.host,this.buildCAPIPath(s),t,this.buildHeader(f),i,t==="POST"||t==="PUT"?r:void 0);if(!c.rawResponse().ok){let R=await c.json();throw K(R)?R:{name:"MetaError",message:"Unknown error occurred",error:{message:R.message||"Unknown error occurred",type:"UnknownError",code:c.statusCode(),fbtrace_id:""}}}return c}catch(c){throw K(c)?c:{name:"MetaError",message:c instanceof Error?c.message:"Network error occurred",error:{message:c instanceof Error?c.message:"Network error occurred",type:"NetworkError",code:500,fbtrace_id:""}}}}async getJson(t,s,i,r){return await(await this.sendRequest(t,s,i,r)).json()}};var Me="UTILS",qe=!1,ne=new P(Me,process.env.DEBUG==="true"||qe),Oe="graph.facebook.com",De=3e3,Be=30,Ue=2e4,we=a=>{if(!process.env.CLOUD_API_ACCESS_TOKEN&&!a?.accessToken)throw ne.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.")},pe=a=>{we(a);let t={WA_BASE_URL:process.env.WA_BASE_URL||Oe,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:a?.phoneNumberId||Number(process.env.WA_PHONE_NUMBER_ID),WA_BUSINESS_ACCOUNT_ID:a?.businessAcctId||process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||"",CLOUD_API_ACCESS_TOKEN:a?.accessToken||process.env.CLOUD_API_ACCESS_TOKEN||"",WEBHOOK_ENDPOINT:process.env.WEBHOOK_ENDPOINT||"",WEBHOOK_VERIFICATION_TOKEN:process.env.WEBHOOK_VERIFICATION_TOKEN||"",LISTENER_PORT:parseInt(process.env.LISTENER_PORT||"")||De,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||Be,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||Ue,DEBUG:process.env.DEBUG==="true"};return ne.log(`Configuration loaded for App Id ${t.M4D_APP_ID}`),t};var Ge="WHATSAPP",Fe=!1,G=new P(Ge,process.env.DEBUG==="true"||Fe),Le="WA_SDK",x=class{config;requester;messages;templates;phoneNumber;qrCode;encryption;twoStepVerification;registration;media;waba;flow;businessProfile;static Enums=W;constructor(t){this.config=pe(t),this.requester=new w(this.config.WA_BASE_URL,this.config.CLOUD_API_VERSION,this.config.WA_PHONE_NUMBER_ID,this.config.CLOUD_API_ACCESS_TOKEN,this.config.WA_BUSINESS_ACCOUNT_ID,this.userAgent()),this.messages=new _(this.config,this.requester),this.templates=new O(this.config,this.requester),this.phoneNumber=new N(this.config,this.requester),this.qrCode=new M(this.config,this.requester),this.encryption=new S(this.config,this.requester),this.twoStepVerification=new D(this.config,this.requester),this.registration=new q(this.config,this.requester),this.media=new b(this.config,this.requester),this.waba=new B(this.config,this.requester),this.flow=new m(this.config,this.requester),this.businessProfile=new T(this.config,this.requester),G.log("WhatsApp Node.js SDK instantiated!")}userAgent(){return`${Le}/0.0.1 (Node.js ${process.version})`}updateTimeout(t){return this.config.REQUEST_TIMEOUT=t,G.log(`Updated request timeout to ${t}ms`),!0}updatePhoneNumberId(t){return this.config.WA_PHONE_NUMBER_ID=t,G.log(`Updated sender phone number id to ${t}`),!0}updateAccessToken(t){return this.config.CLOUD_API_ACCESS_TOKEN=t,G.log("Updated access token"),!0}updateWabaId(t){return this.config.WA_BUSINESS_ACCOUNT_ID=t,G.log(`Updated business account id to ${t}`),!0}};export{x as default};
|
|
2
2
|
//# sourceMappingURL=whatsapp.mjs.map
|