meta-cloud-api 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +216 -0
  2. package/dist/api/base.d.mts +1 -1
  3. package/dist/api/base.d.ts +1 -1
  4. package/dist/api/businessProfile.d.mts +142 -0
  5. package/dist/api/businessProfile.d.ts +142 -0
  6. package/dist/api/businessProfile.js +2 -0
  7. package/dist/api/businessProfile.js.map +1 -0
  8. package/dist/api/businessProfile.mjs +2 -0
  9. package/dist/api/businessProfile.mjs.map +1 -0
  10. package/dist/api/encryption.d.mts +1 -1
  11. package/dist/api/encryption.d.ts +1 -1
  12. package/dist/api/encryption.js +1 -1
  13. package/dist/api/encryption.mjs +1 -1
  14. package/dist/api/flow.d.mts +1 -1
  15. package/dist/api/flow.d.ts +1 -1
  16. package/dist/api/flow.js +1 -1
  17. package/dist/api/flow.mjs +1 -1
  18. package/dist/api/index.d.mts +16 -14
  19. package/dist/api/index.d.ts +16 -14
  20. package/dist/api/index.js +1 -1
  21. package/dist/api/index.js.map +1 -1
  22. package/dist/api/index.mjs +1 -1
  23. package/dist/api/index.mjs.map +1 -1
  24. package/dist/api/media.d.mts +1 -1
  25. package/dist/api/media.d.ts +1 -1
  26. package/dist/api/media.js +1 -1
  27. package/dist/api/media.mjs +1 -1
  28. package/dist/api/messages.d.mts +1 -1
  29. package/dist/api/messages.d.ts +1 -1
  30. package/dist/api/messages.js +1 -1
  31. package/dist/api/messages.mjs +1 -1
  32. package/dist/api/phoneNumber.d.mts +1 -1
  33. package/dist/api/phoneNumber.d.ts +1 -1
  34. package/dist/api/phoneNumber.js +1 -1
  35. package/dist/api/phoneNumber.mjs +1 -1
  36. package/dist/api/qrCode.d.mts +1 -1
  37. package/dist/api/qrCode.d.ts +1 -1
  38. package/dist/api/qrCode.js +1 -1
  39. package/dist/api/qrCode.mjs +1 -1
  40. package/dist/api/registration.d.mts +1 -1
  41. package/dist/api/registration.d.ts +1 -1
  42. package/dist/api/registration.js +1 -1
  43. package/dist/api/registration.mjs +1 -1
  44. package/dist/api/template.d.mts +1 -1
  45. package/dist/api/template.d.ts +1 -1
  46. package/dist/api/template.js +1 -1
  47. package/dist/api/template.mjs +1 -1
  48. package/dist/api/twoStepVerification.d.mts +1 -1
  49. package/dist/api/twoStepVerification.d.ts +1 -1
  50. package/dist/api/twoStepVerification.js +1 -1
  51. package/dist/api/twoStepVerification.mjs +1 -1
  52. package/dist/api/waba.d.mts +1 -1
  53. package/dist/api/waba.d.ts +1 -1
  54. package/dist/api/waba.js +1 -1
  55. package/dist/api/waba.mjs +1 -1
  56. package/dist/{enums-D6WRUWH9.d.mts → enums-Dn5Y1Nom.d.mts} +94 -2
  57. package/dist/{enums-D6WRUWH9.d.ts → enums-Dn5Y1Nom.d.ts} +94 -2
  58. package/dist/httpsClient.d.mts +1 -1
  59. package/dist/httpsClient.d.ts +1 -1
  60. package/dist/index.d.mts +20 -18
  61. package/dist/index.d.ts +20 -18
  62. package/dist/index.js +1 -1
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +1 -1
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/request.d.mts +1 -1
  67. package/dist/request.d.ts +1 -1
  68. package/dist/types/base.d.mts +1 -1
  69. package/dist/types/base.d.ts +1 -1
  70. package/dist/types/businessProfile.d.mts +147 -0
  71. package/dist/types/businessProfile.d.ts +147 -0
  72. package/dist/types/businessProfile.js +2 -0
  73. package/dist/types/businessProfile.js.map +1 -0
  74. package/dist/types/businessProfile.mjs +1 -0
  75. package/dist/types/businessProfile.mjs.map +1 -0
  76. package/dist/types/config.d.mts +1 -1
  77. package/dist/types/config.d.ts +1 -1
  78. package/dist/types/encryption.d.mts +1 -1
  79. package/dist/types/encryption.d.ts +1 -1
  80. package/dist/types/enums.d.mts +1 -1
  81. package/dist/types/enums.d.ts +1 -1
  82. package/dist/types/enums.js +1 -1
  83. package/dist/types/enums.js.map +1 -1
  84. package/dist/types/enums.mjs +1 -1
  85. package/dist/types/enums.mjs.map +1 -1
  86. package/dist/types/flow.d.mts +1 -1
  87. package/dist/types/flow.d.ts +1 -1
  88. package/dist/types/httpsClient.d.mts +1 -1
  89. package/dist/types/httpsClient.d.ts +1 -1
  90. package/dist/types/index.d.mts +3 -1
  91. package/dist/types/index.d.ts +3 -1
  92. package/dist/types/index.js +1 -1
  93. package/dist/types/index.js.map +1 -1
  94. package/dist/types/index.mjs +1 -1
  95. package/dist/types/index.mjs.map +1 -1
  96. package/dist/types/media.d.mts +1 -1
  97. package/dist/types/media.d.ts +1 -1
  98. package/dist/types/messages.d.mts +1 -1
  99. package/dist/types/messages.d.ts +1 -1
  100. package/dist/types/phoneNumber.d.mts +1 -1
  101. package/dist/types/phoneNumber.d.ts +1 -1
  102. package/dist/types/qrCode.d.mts +1 -1
  103. package/dist/types/qrCode.d.ts +1 -1
  104. package/dist/types/registration.d.mts +1 -1
  105. package/dist/types/registration.d.ts +1 -1
  106. package/dist/types/request.d.mts +1 -1
  107. package/dist/types/request.d.ts +1 -1
  108. package/dist/types/template.d.mts +1 -1
  109. package/dist/types/template.d.ts +1 -1
  110. package/dist/types/twoStepVerification.d.mts +1 -1
  111. package/dist/types/twoStepVerification.d.ts +1 -1
  112. package/dist/types/waba.d.mts +1 -1
  113. package/dist/types/waba.d.ts +1 -1
  114. package/dist/types/whatsapp.d.mts +28 -0
  115. package/dist/types/whatsapp.d.ts +28 -0
  116. package/dist/types/whatsapp.js +1 -1
  117. package/dist/types/whatsapp.js.map +1 -1
  118. package/dist/utils/importConfig.d.mts +14 -1
  119. package/dist/utils/importConfig.d.ts +14 -1
  120. package/dist/utils/importConfig.js +1 -1
  121. package/dist/utils/importConfig.mjs +1 -1
  122. package/dist/utils/index.d.mts +14 -1
  123. package/dist/utils/index.d.ts +14 -1
  124. package/dist/utils/index.js +1 -1
  125. package/dist/utils/index.mjs +1 -1
  126. package/dist/whatsapp.d.mts +21 -18
  127. package/dist/whatsapp.d.ts +21 -18
  128. package/dist/whatsapp.js +1 -1
  129. package/dist/whatsapp.js.map +1 -1
  130. package/dist/whatsapp.mjs +1 -1
  131. package/dist/whatsapp.mjs.map +1 -1
  132. package/package.json +2 -2
  133. package/src/api/base.ts +0 -19
  134. package/src/api/encryption.ts +0 -34
  135. package/src/api/flow.ts +0 -253
  136. package/src/api/index.ts +0 -24
  137. package/src/api/media.ts +0 -52
  138. package/src/api/messages.ts +0 -160
  139. package/src/api/phoneNumber.ts +0 -59
  140. package/src/api/qrCode.ts +0 -64
  141. package/src/api/registration.ts +0 -38
  142. package/src/api/template.ts +0 -70
  143. package/src/api/twoStepVerification.ts +0 -24
  144. package/src/api/waba.ts +0 -55
  145. package/src/httpsClient.ts +0 -83
  146. package/src/index.ts +0 -3
  147. package/src/request.ts +0 -104
  148. package/src/types/base.ts +0 -5
  149. package/src/types/config.ts +0 -68
  150. package/src/types/encryption.ts +0 -11
  151. package/src/types/enums.ts +0 -563
  152. package/src/types/flow.ts +0 -274
  153. package/src/types/httpsClient.ts +0 -28
  154. package/src/types/index.ts +0 -16
  155. package/src/types/logger.ts +0 -7
  156. package/src/types/media.ts +0 -31
  157. package/src/types/messages.ts +0 -453
  158. package/src/types/phoneNumber.ts +0 -111
  159. package/src/types/qrCode.ts +0 -30
  160. package/src/types/registration.ts +0 -17
  161. package/src/types/request.ts +0 -66
  162. package/src/types/template.ts +0 -134
  163. package/src/types/twoStepVerification.ts +0 -9
  164. package/src/types/waba.ts +0 -18
  165. package/src/types/whatsapp.ts +0 -31
  166. package/src/utils/.gitkeep +0 -0
  167. package/src/utils/generateXHub256Sig.ts +0 -5
  168. package/src/utils/importConfig.ts +0 -55
  169. package/src/utils/index.ts +0 -2
  170. package/src/utils/isMetaError.ts +0 -44
  171. package/src/utils/logger.ts +0 -46
  172. package/src/utils/objectToQueryString.ts +0 -16
  173. package/src/whatsapp.ts +0 -96
@@ -1,2 +1,2 @@
1
- "use strict";var B=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var l=(S,t)=>{for(var R in t)B(S,R,{get:t[R],enumerable:!0})},I=(S,t,R,N)=>{if(t&&typeof t=="object"||typeof t=="function")for(let D of G(t))!K.call(S,D)&&D!==R&&B(S,D,{get:()=>t[D],enumerable:!(N=U(t,D))||N.enumerable});return S};var O=S=>I(B({},"__esModule",{value:!0}),S);var F={};l(F,{default:()=>P});module.exports=O(F);var i=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var M="BaseAPI",p=!1,T=new i(M,process.env.DEBUG==="true"||p),A=class{config;client;constructor(t,R){this.config=t,this.client=R,T.log("Initialized with HTTPSClient")}};var P=class extends A{constructor(t,R){super(t,R)}async setTwoStepVerificationCode(t){let R={pin:t};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(R))}};
1
+ "use strict";var U=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var i=(t,R)=>{for(var A in R)U(t,A,{get:R[A],enumerable:!0})},T=(t,R,A,G)=>{if(R&&typeof R=="object"||typeof R=="function")for(let S of O(R))!I.call(t,S)&&S!==A&&U(t,S,{get:()=>R[S],enumerable:!(G=B(R,S))||G.enumerable});return t};var K=t=>T(U({},"__esModule",{value:!0}),t);var H={};i(H,{default:()=>N});module.exports=K(H);var D=class{name;debug;constructor(R,A=!1){this.name=R,this.debug=A}log(...R){if(this.debug){let A=`[ ${Date.now()} ]`;this.name&&(A+=` - ${this.name}`),console.log.apply(console,[A,": ",...R])}}error(...R){let A=`[ ${Date.now()} ] - ERROR`;this.name&&(A+=` - ${this.name}`),console.error.apply(console,[A,": ",...R])}warn(...R){let A=`[ ${Date.now()} ] - WARN`;this.name&&(A+=` - ${this.name}`),console.warn.apply(console,[A,": ",...R])}info(...R){let A=`[ ${Date.now()} ] - INFO`;this.name&&(A+=` - ${this.name}`),console.info.apply(console,[A,": ",...R])}};var M="BaseAPI",p=!1,_=new D(M,process.env.DEBUG==="true"||p),P=class{config;client;constructor(R,A){this.config=R,this.client=A,_.log("Initialized with HTTPSClient")}};var N=class extends P{constructor(R,A){super(R,A)}async setTwoStepVerificationCode(R){let A={pin:R};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(A))}};
2
2
  //# sourceMappingURL=twoStepVerification.js.map
@@ -1,2 +1,2 @@
1
- var S=class{name;debug;constructor(R,t=!1){this.name=R,this.debug=t}log(...R){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...R])}}error(...R){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...R])}warn(...R){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...R])}info(...R){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...R])}};var P="BaseAPI",B=!1,N=new S(P,process.env.DEBUG==="true"||B),D=class{config;client;constructor(R,t){this.config=R,this.client=t,N.log("Initialized with HTTPSClient")}};var i=class extends D{constructor(R,t){super(R,t)}async setTwoStepVerificationCode(R){let t={pin:R};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};export{i as default};
1
+ var t=class{name;debug;constructor(A,R=!1){this.name=A,this.debug=R}log(...A){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...A])}}error(...A){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...A])}warn(...A){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...A])}info(...A){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...A])}};var N="BaseAPI",U=!1,G=new t(N,process.env.DEBUG==="true"||U),S=class{config;client;constructor(A,R){this.config=A,this.client=R,G.log("Initialized with HTTPSClient")}};var D=class extends S{constructor(A,R){super(A,R)}async setTwoStepVerificationCode(A){let R={pin:A};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(R))}};export{D as default};
2
2
  //# sourceMappingURL=twoStepVerification.mjs.map
@@ -2,7 +2,7 @@ import { WabaConfigType } from '../types/config.mjs';
2
2
  import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
3
3
  import BaseAPI from './base.mjs';
4
4
  import { WABAClass, WabaSubscriptions } from '../types/waba.mjs';
5
- import '../enums-D6WRUWH9.mjs';
5
+ import '../enums-Dn5Y1Nom.mjs';
6
6
  import '../types/base.mjs';
7
7
 
8
8
  declare class WabaAPI extends BaseAPI implements WABAClass {
@@ -2,7 +2,7 @@ import { WabaConfigType } from '../types/config.js';
2
2
  import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
3
3
  import BaseAPI from './base.js';
4
4
  import { WABAClass, WabaSubscriptions } from '../types/waba.js';
5
- import '../enums-D6WRUWH9.js';
5
+ import '../enums-Dn5Y1Nom.js';
6
6
  import '../types/base.js';
7
7
 
8
8
  declare class WabaAPI extends BaseAPI implements WABAClass {
package/dist/api/waba.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var N=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var K=(i,t)=>{for(var R in t)N(i,R,{get:t[R],enumerable:!0})},I=(i,t,R,P)=>{if(t&&typeof t=="object"||typeof t=="function")for(let S of l(t))!G.call(i,S)&&S!==R&&N(i,S,{get:()=>t[S],enumerable:!(P=U(t,S))||P.enumerable});return i};var p=i=>I(N({},"__esModule",{value:!0}),i);var T={};K(T,{default:()=>B});module.exports=p(T);var A=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var O="BaseAPI",M=!1,_=new A(O,process.env.DEBUG==="true"||M),D=class{config;client;constructor(t,R){this.config=t,this.client=R,_.log("Initialized with HTTPSClient")}};var B=class extends D{constructor(t,R){super(t,R)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async subscribeToWaba(){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async overrideWabaWebhook(t,R){let P={url:t,verify_token:R};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/webhooks`,this.config.REQUEST_TIMEOUT,JSON.stringify(P))}};
1
+ "use strict";var B=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var O=(A,t)=>{for(var R in t)B(A,R,{get:t[R],enumerable:!0})},T=(A,t,R,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let S of U(t))!I.call(A,S)&&S!==R&&B(A,S,{get:()=>t[S],enumerable:!(i=G(t,S))||i.enumerable});return A};var K=A=>T(B({},"__esModule",{value:!0}),A);var _={};O(_,{default:()=>N});module.exports=K(_);var D=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var p="BaseAPI",l=!1,M=new D(p,process.env.DEBUG==="true"||l),P=class{config;client;constructor(t,R){this.config=t,this.client=R,M.log("Initialized with HTTPSClient")}};var N=class extends P{constructor(t,R){super(t,R)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async subscribeToWaba(){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async overrideWabaWebhook(t,R){let i={url:t,verify_token:R};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/webhooks`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}};
2
2
  //# sourceMappingURL=waba.js.map
package/dist/api/waba.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var i=class{name;debug;constructor(R,t=!1){this.name=R,this.debug=t}log(...R){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...R])}}error(...R){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...R])}warn(...R){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...R])}info(...R){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...R])}};var B="BaseAPI",N=!1,U=new i(B,process.env.DEBUG==="true"||N),S=class{config;client;constructor(R,t){this.config=R,this.client=t,U.log("Initialized with HTTPSClient")}};var A=class extends S{constructor(R,t){super(R,t)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async subscribeToWaba(){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async overrideWabaWebhook(R,t){let P={url:R,verify_token:t};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/webhooks`,this.config.REQUEST_TIMEOUT,JSON.stringify(P))}};export{A as default};
1
+ var A=class{name;debug;constructor(R,t=!1){this.name=R,this.debug=t}log(...R){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...R])}}error(...R){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...R])}warn(...R){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...R])}info(...R){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...R])}};var N="BaseAPI",B=!1,G=new A(N,process.env.DEBUG==="true"||B),S=class{config;client;constructor(R,t){this.config=R,this.client=t,G.log("Initialized with HTTPSClient")}};var D=class extends S{constructor(R,t){super(R,t)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async subscribeToWaba(){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async overrideWabaWebhook(R,t){let i={url:R,verify_token:t};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/webhooks`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}};export{D as default};
2
2
  //# sourceMappingURL=waba.mjs.map
@@ -529,9 +529,101 @@ declare enum DataLocalizationRegionEnum {
529
529
  AE = "AE",// United Arab Emirates
530
530
  CA = "CA"
531
531
  }
532
+ /**
533
+ * Business category values for WhatsApp Business Profile.
534
+ * These values map to specific strings displayed in the WhatsApp client.
535
+ */
536
+ declare enum BusinessVerticalEnum {
537
+ /**
538
+ * Alcoholic Beverages
539
+ */
540
+ ALCOHOL = "ALCOHOL",
541
+ /**
542
+ * Clothing and Apparel
543
+ */
544
+ APPAREL = "APPAREL",
545
+ /**
546
+ * Automotive
547
+ */
548
+ AUTO = "AUTO",
549
+ /**
550
+ * Beauty, Spa and Salon
551
+ */
552
+ BEAUTY = "BEAUTY",
553
+ /**
554
+ * Education
555
+ */
556
+ EDU = "EDU",
557
+ /**
558
+ * Entertainment
559
+ */
560
+ ENTERTAIN = "ENTERTAIN",
561
+ /**
562
+ * Event Planning and Service
563
+ */
564
+ EVENT_PLAN = "EVENT_PLAN",
565
+ /**
566
+ * Finance and Banking
567
+ */
568
+ FINANCE = "FINANCE",
569
+ /**
570
+ * Public Service
571
+ */
572
+ GOVT = "GOVT",
573
+ /**
574
+ * Food and Grocery
575
+ */
576
+ GROCERY = "GROCERY",
577
+ /**
578
+ * Medical and Health
579
+ */
580
+ HEALTH = "HEALTH",
581
+ /**
582
+ * Hotel and Lodging
583
+ */
584
+ HOTEL = "HOTEL",
585
+ /**
586
+ * Non-profit
587
+ */
588
+ NONPROFIT = "NONPROFIT",
589
+ /**
590
+ * Online Gambling & Gaming
591
+ */
592
+ ONLINE_GAMBLING = "ONLINE_GAMBLING",
593
+ /**
594
+ * Over-the-Counter Drugs
595
+ */
596
+ OTC_DRUGS = "OTC_DRUGS",
597
+ /**
598
+ * Other
599
+ */
600
+ OTHER = "OTHER",
601
+ /**
602
+ * Non-Online Gambling & Gaming (E.g. Brick and mortar)
603
+ */
604
+ PHYSICAL_GAMBLING = "PHYSICAL_GAMBLING",
605
+ /**
606
+ * Professional Services
607
+ */
608
+ PROF_SERVICES = "PROF_SERVICES",
609
+ /**
610
+ * Restaurant
611
+ */
612
+ RESTAURANT = "RESTAURANT",
613
+ /**
614
+ * Shopping and Retail
615
+ */
616
+ RETAIL = "RETAIL",
617
+ /**
618
+ * Travel and Transportation
619
+ */
620
+ TRAVEL = "TRAVEL"
621
+ }
532
622
 
533
623
  type SDKEnums_AudioMediaTypesEnum = AudioMediaTypesEnum;
534
624
  declare const SDKEnums_AudioMediaTypesEnum: typeof AudioMediaTypesEnum;
625
+ type SDKEnums_BusinessVerticalEnum = BusinessVerticalEnum;
626
+ declare const SDKEnums_BusinessVerticalEnum: typeof BusinessVerticalEnum;
535
627
  type SDKEnums_ButtonPositionEnum = ButtonPositionEnum;
536
628
  declare const SDKEnums_ButtonPositionEnum: typeof ButtonPositionEnum;
537
629
  type SDKEnums_ButtonTypesEnum = ButtonTypesEnum;
@@ -579,7 +671,7 @@ declare const SDKEnums_WabaConfigEnum: typeof WabaConfigEnum;
579
671
  type SDKEnums_WebhookTypesEnum = WebhookTypesEnum;
580
672
  declare const SDKEnums_WebhookTypesEnum: typeof WebhookTypesEnum;
581
673
  declare namespace SDKEnums {
582
- export { SDKEnums_AudioMediaTypesEnum as AudioMediaTypesEnum, SDKEnums_ButtonPositionEnum as ButtonPositionEnum, SDKEnums_ButtonTypesEnum as ButtonTypesEnum, SDKEnums_CategoryEnum as CategoryEnum, SDKEnums_ComponentTypesEnum as ComponentTypesEnum, SDKEnums_ConversationTypesEnum as ConversationTypesEnum, SDKEnums_CurrencyCodesEnum as CurrencyCodesEnum, SDKEnums_DataLocalizationRegionEnum as DataLocalizationRegionEnum, SDKEnums_DocumentMediaTypesEnum as DocumentMediaTypesEnum, SDKEnums_HttpMethodsEnum as HttpMethodsEnum, SDKEnums_ImageMediaTypesEnum as ImageMediaTypesEnum, SDKEnums_InteractiveTypesEnum as InteractiveTypesEnum, SDKEnums_LanguagesEnum as LanguagesEnum, SDKEnums_MessageTypesEnum as MessageTypesEnum, SDKEnums_ParametersTypesEnum as ParametersTypesEnum, SDKEnums_ReferralSourceTypesEnum as ReferralSourceTypesEnum, SDKEnums_RequestCodeMethodsEnum as RequestCodeMethodsEnum, SDKEnums_StatusEnum as StatusEnum, SDKEnums_StickerMediaTypesEnum as StickerMediaTypesEnum, SDKEnums_SystemChangeTypesEnum as SystemChangeTypesEnum, SDKEnums_TemplateStatusEnum as TemplateStatusEnum, SDKEnums_VideoMediaTypesEnum as VideoMediaTypesEnum, SDKEnums_WabaConfigEnum as WabaConfigEnum, SDKEnums_WebhookTypesEnum as WebhookTypesEnum };
674
+ export { SDKEnums_AudioMediaTypesEnum as AudioMediaTypesEnum, SDKEnums_BusinessVerticalEnum as BusinessVerticalEnum, SDKEnums_ButtonPositionEnum as ButtonPositionEnum, SDKEnums_ButtonTypesEnum as ButtonTypesEnum, SDKEnums_CategoryEnum as CategoryEnum, SDKEnums_ComponentTypesEnum as ComponentTypesEnum, SDKEnums_ConversationTypesEnum as ConversationTypesEnum, SDKEnums_CurrencyCodesEnum as CurrencyCodesEnum, SDKEnums_DataLocalizationRegionEnum as DataLocalizationRegionEnum, SDKEnums_DocumentMediaTypesEnum as DocumentMediaTypesEnum, SDKEnums_HttpMethodsEnum as HttpMethodsEnum, SDKEnums_ImageMediaTypesEnum as ImageMediaTypesEnum, SDKEnums_InteractiveTypesEnum as InteractiveTypesEnum, SDKEnums_LanguagesEnum as LanguagesEnum, SDKEnums_MessageTypesEnum as MessageTypesEnum, SDKEnums_ParametersTypesEnum as ParametersTypesEnum, SDKEnums_ReferralSourceTypesEnum as ReferralSourceTypesEnum, SDKEnums_RequestCodeMethodsEnum as RequestCodeMethodsEnum, SDKEnums_StatusEnum as StatusEnum, SDKEnums_StickerMediaTypesEnum as StickerMediaTypesEnum, SDKEnums_SystemChangeTypesEnum as SystemChangeTypesEnum, SDKEnums_TemplateStatusEnum as TemplateStatusEnum, SDKEnums_VideoMediaTypesEnum as VideoMediaTypesEnum, SDKEnums_WabaConfigEnum as WabaConfigEnum, SDKEnums_WebhookTypesEnum as WebhookTypesEnum };
583
675
  }
584
676
 
585
- export { AudioMediaTypesEnum as A, ButtonTypesEnum as B, CategoryEnum as C, DocumentMediaTypesEnum as D, HttpMethodsEnum as H, InteractiveTypesEnum as I, LanguagesEnum as L, MessageTypesEnum as M, ParametersTypesEnum as P, ReferralSourceTypesEnum as R, StatusEnum as S, TemplateStatusEnum as T, VideoMediaTypesEnum as V, WabaConfigEnum as W, ButtonPositionEnum as a, ComponentTypesEnum as b, ConversationTypesEnum as c, StickerMediaTypesEnum as d, ImageMediaTypesEnum as e, WebhookTypesEnum as f, SystemChangeTypesEnum as g, RequestCodeMethodsEnum as h, CurrencyCodesEnum as i, DataLocalizationRegionEnum as j, SDKEnums as k };
677
+ export { AudioMediaTypesEnum as A, ButtonTypesEnum as B, CategoryEnum as C, DocumentMediaTypesEnum as D, HttpMethodsEnum as H, InteractiveTypesEnum as I, LanguagesEnum as L, MessageTypesEnum as M, ParametersTypesEnum as P, ReferralSourceTypesEnum as R, StatusEnum as S, TemplateStatusEnum as T, VideoMediaTypesEnum as V, WabaConfigEnum as W, ButtonPositionEnum as a, ComponentTypesEnum as b, ConversationTypesEnum as c, StickerMediaTypesEnum as d, ImageMediaTypesEnum as e, WebhookTypesEnum as f, SystemChangeTypesEnum as g, RequestCodeMethodsEnum as h, CurrencyCodesEnum as i, DataLocalizationRegionEnum as j, BusinessVerticalEnum as k, SDKEnums as l };
@@ -529,9 +529,101 @@ declare enum DataLocalizationRegionEnum {
529
529
  AE = "AE",// United Arab Emirates
530
530
  CA = "CA"
531
531
  }
532
+ /**
533
+ * Business category values for WhatsApp Business Profile.
534
+ * These values map to specific strings displayed in the WhatsApp client.
535
+ */
536
+ declare enum BusinessVerticalEnum {
537
+ /**
538
+ * Alcoholic Beverages
539
+ */
540
+ ALCOHOL = "ALCOHOL",
541
+ /**
542
+ * Clothing and Apparel
543
+ */
544
+ APPAREL = "APPAREL",
545
+ /**
546
+ * Automotive
547
+ */
548
+ AUTO = "AUTO",
549
+ /**
550
+ * Beauty, Spa and Salon
551
+ */
552
+ BEAUTY = "BEAUTY",
553
+ /**
554
+ * Education
555
+ */
556
+ EDU = "EDU",
557
+ /**
558
+ * Entertainment
559
+ */
560
+ ENTERTAIN = "ENTERTAIN",
561
+ /**
562
+ * Event Planning and Service
563
+ */
564
+ EVENT_PLAN = "EVENT_PLAN",
565
+ /**
566
+ * Finance and Banking
567
+ */
568
+ FINANCE = "FINANCE",
569
+ /**
570
+ * Public Service
571
+ */
572
+ GOVT = "GOVT",
573
+ /**
574
+ * Food and Grocery
575
+ */
576
+ GROCERY = "GROCERY",
577
+ /**
578
+ * Medical and Health
579
+ */
580
+ HEALTH = "HEALTH",
581
+ /**
582
+ * Hotel and Lodging
583
+ */
584
+ HOTEL = "HOTEL",
585
+ /**
586
+ * Non-profit
587
+ */
588
+ NONPROFIT = "NONPROFIT",
589
+ /**
590
+ * Online Gambling & Gaming
591
+ */
592
+ ONLINE_GAMBLING = "ONLINE_GAMBLING",
593
+ /**
594
+ * Over-the-Counter Drugs
595
+ */
596
+ OTC_DRUGS = "OTC_DRUGS",
597
+ /**
598
+ * Other
599
+ */
600
+ OTHER = "OTHER",
601
+ /**
602
+ * Non-Online Gambling & Gaming (E.g. Brick and mortar)
603
+ */
604
+ PHYSICAL_GAMBLING = "PHYSICAL_GAMBLING",
605
+ /**
606
+ * Professional Services
607
+ */
608
+ PROF_SERVICES = "PROF_SERVICES",
609
+ /**
610
+ * Restaurant
611
+ */
612
+ RESTAURANT = "RESTAURANT",
613
+ /**
614
+ * Shopping and Retail
615
+ */
616
+ RETAIL = "RETAIL",
617
+ /**
618
+ * Travel and Transportation
619
+ */
620
+ TRAVEL = "TRAVEL"
621
+ }
532
622
 
533
623
  type SDKEnums_AudioMediaTypesEnum = AudioMediaTypesEnum;
534
624
  declare const SDKEnums_AudioMediaTypesEnum: typeof AudioMediaTypesEnum;
625
+ type SDKEnums_BusinessVerticalEnum = BusinessVerticalEnum;
626
+ declare const SDKEnums_BusinessVerticalEnum: typeof BusinessVerticalEnum;
535
627
  type SDKEnums_ButtonPositionEnum = ButtonPositionEnum;
536
628
  declare const SDKEnums_ButtonPositionEnum: typeof ButtonPositionEnum;
537
629
  type SDKEnums_ButtonTypesEnum = ButtonTypesEnum;
@@ -579,7 +671,7 @@ declare const SDKEnums_WabaConfigEnum: typeof WabaConfigEnum;
579
671
  type SDKEnums_WebhookTypesEnum = WebhookTypesEnum;
580
672
  declare const SDKEnums_WebhookTypesEnum: typeof WebhookTypesEnum;
581
673
  declare namespace SDKEnums {
582
- export { SDKEnums_AudioMediaTypesEnum as AudioMediaTypesEnum, SDKEnums_ButtonPositionEnum as ButtonPositionEnum, SDKEnums_ButtonTypesEnum as ButtonTypesEnum, SDKEnums_CategoryEnum as CategoryEnum, SDKEnums_ComponentTypesEnum as ComponentTypesEnum, SDKEnums_ConversationTypesEnum as ConversationTypesEnum, SDKEnums_CurrencyCodesEnum as CurrencyCodesEnum, SDKEnums_DataLocalizationRegionEnum as DataLocalizationRegionEnum, SDKEnums_DocumentMediaTypesEnum as DocumentMediaTypesEnum, SDKEnums_HttpMethodsEnum as HttpMethodsEnum, SDKEnums_ImageMediaTypesEnum as ImageMediaTypesEnum, SDKEnums_InteractiveTypesEnum as InteractiveTypesEnum, SDKEnums_LanguagesEnum as LanguagesEnum, SDKEnums_MessageTypesEnum as MessageTypesEnum, SDKEnums_ParametersTypesEnum as ParametersTypesEnum, SDKEnums_ReferralSourceTypesEnum as ReferralSourceTypesEnum, SDKEnums_RequestCodeMethodsEnum as RequestCodeMethodsEnum, SDKEnums_StatusEnum as StatusEnum, SDKEnums_StickerMediaTypesEnum as StickerMediaTypesEnum, SDKEnums_SystemChangeTypesEnum as SystemChangeTypesEnum, SDKEnums_TemplateStatusEnum as TemplateStatusEnum, SDKEnums_VideoMediaTypesEnum as VideoMediaTypesEnum, SDKEnums_WabaConfigEnum as WabaConfigEnum, SDKEnums_WebhookTypesEnum as WebhookTypesEnum };
674
+ export { SDKEnums_AudioMediaTypesEnum as AudioMediaTypesEnum, SDKEnums_BusinessVerticalEnum as BusinessVerticalEnum, SDKEnums_ButtonPositionEnum as ButtonPositionEnum, SDKEnums_ButtonTypesEnum as ButtonTypesEnum, SDKEnums_CategoryEnum as CategoryEnum, SDKEnums_ComponentTypesEnum as ComponentTypesEnum, SDKEnums_ConversationTypesEnum as ConversationTypesEnum, SDKEnums_CurrencyCodesEnum as CurrencyCodesEnum, SDKEnums_DataLocalizationRegionEnum as DataLocalizationRegionEnum, SDKEnums_DocumentMediaTypesEnum as DocumentMediaTypesEnum, SDKEnums_HttpMethodsEnum as HttpMethodsEnum, SDKEnums_ImageMediaTypesEnum as ImageMediaTypesEnum, SDKEnums_InteractiveTypesEnum as InteractiveTypesEnum, SDKEnums_LanguagesEnum as LanguagesEnum, SDKEnums_MessageTypesEnum as MessageTypesEnum, SDKEnums_ParametersTypesEnum as ParametersTypesEnum, SDKEnums_ReferralSourceTypesEnum as ReferralSourceTypesEnum, SDKEnums_RequestCodeMethodsEnum as RequestCodeMethodsEnum, SDKEnums_StatusEnum as StatusEnum, SDKEnums_StickerMediaTypesEnum as StickerMediaTypesEnum, SDKEnums_SystemChangeTypesEnum as SystemChangeTypesEnum, SDKEnums_TemplateStatusEnum as TemplateStatusEnum, SDKEnums_VideoMediaTypesEnum as VideoMediaTypesEnum, SDKEnums_WabaConfigEnum as WabaConfigEnum, SDKEnums_WebhookTypesEnum as WebhookTypesEnum };
583
675
  }
584
676
 
585
- export { AudioMediaTypesEnum as A, ButtonTypesEnum as B, CategoryEnum as C, DocumentMediaTypesEnum as D, HttpMethodsEnum as H, InteractiveTypesEnum as I, LanguagesEnum as L, MessageTypesEnum as M, ParametersTypesEnum as P, ReferralSourceTypesEnum as R, StatusEnum as S, TemplateStatusEnum as T, VideoMediaTypesEnum as V, WabaConfigEnum as W, ButtonPositionEnum as a, ComponentTypesEnum as b, ConversationTypesEnum as c, StickerMediaTypesEnum as d, ImageMediaTypesEnum as e, WebhookTypesEnum as f, SystemChangeTypesEnum as g, RequestCodeMethodsEnum as h, CurrencyCodesEnum as i, DataLocalizationRegionEnum as j, SDKEnums as k };
677
+ export { AudioMediaTypesEnum as A, ButtonTypesEnum as B, CategoryEnum as C, DocumentMediaTypesEnum as D, HttpMethodsEnum as H, InteractiveTypesEnum as I, LanguagesEnum as L, MessageTypesEnum as M, ParametersTypesEnum as P, ReferralSourceTypesEnum as R, StatusEnum as S, TemplateStatusEnum as T, VideoMediaTypesEnum as V, WabaConfigEnum as W, ButtonPositionEnum as a, ComponentTypesEnum as b, ConversationTypesEnum as c, StickerMediaTypesEnum as d, ImageMediaTypesEnum as e, WebhookTypesEnum as f, SystemChangeTypesEnum as g, RequestCodeMethodsEnum as h, CurrencyCodesEnum as i, DataLocalizationRegionEnum as j, BusinessVerticalEnum as k, SDKEnums as l };
@@ -1,5 +1,5 @@
1
1
  import { Agent } from 'https';
2
- import { H as HttpMethodsEnum } from './enums-D6WRUWH9.mjs';
2
+ import { H as HttpMethodsEnum } from './enums-Dn5Y1Nom.mjs';
3
3
  import { HttpsClientClass, HttpsClientResponseClass, ResponseHeaders, ResponseJSONBody } from './types/httpsClient.mjs';
4
4
 
5
5
  declare class HttpsClient implements HttpsClientClass {
@@ -1,5 +1,5 @@
1
1
  import { Agent } from 'https';
2
- import { H as HttpMethodsEnum } from './enums-D6WRUWH9.js';
2
+ import { H as HttpMethodsEnum } from './enums-Dn5Y1Nom.js';
3
3
  import { HttpsClientClass, HttpsClientResponseClass, ResponseHeaders, ResponseJSONBody } from './types/httpsClient.js';
4
4
 
5
5
  declare class HttpsClient implements HttpsClientClass {
package/dist/index.d.mts CHANGED
@@ -1,34 +1,36 @@
1
1
  import WhatsApp from './whatsapp.mjs';
2
2
  import './types/config.mjs';
3
- import './enums-D6WRUWH9.mjs';
4
- import './request.mjs';
5
- import './types/httpsClient.mjs';
6
- import './httpsClient.mjs';
7
- import 'https';
3
+ import './enums-Dn5Y1Nom.mjs';
4
+ import './api/businessProfile.mjs';
5
+ import './types/businessProfile.mjs';
8
6
  import './types/request.mjs';
9
- import './types/whatsapp.mjs';
7
+ import './api/base.mjs';
8
+ import './types/base.mjs';
9
+ import './api/encryption.mjs';
10
+ import './types/encryption.mjs';
11
+ import './api/flow.mjs';
12
+ import './types/flow.mjs';
13
+ import './api/media.mjs';
14
+ import './types/media.mjs';
10
15
  import './api/messages.mjs';
11
16
  import './types/messages.mjs';
12
- import './types/base.mjs';
13
- import './api/base.mjs';
14
17
  import './api/phoneNumber.mjs';
15
18
  import './types/phoneNumber.mjs';
16
- import './api/template.mjs';
17
- import './types/template.mjs';
19
+ import './api/qrCode.mjs';
20
+ import './types/qrCode.mjs';
18
21
  import './api/registration.mjs';
19
22
  import './types/registration.mjs';
23
+ import './api/template.mjs';
24
+ import './types/template.mjs';
20
25
  import './api/twoStepVerification.mjs';
21
26
  import './types/twoStepVerification.mjs';
22
- import './api/qrCode.mjs';
23
- import './types/qrCode.mjs';
24
- import './api/encryption.mjs';
25
- import './types/encryption.mjs';
26
27
  import './api/waba.mjs';
27
28
  import './types/waba.mjs';
28
- import './api/media.mjs';
29
- import './types/media.mjs';
30
- import './api/flow.mjs';
31
- import './types/flow.mjs';
29
+ import './request.mjs';
30
+ import './types/httpsClient.mjs';
31
+ import './httpsClient.mjs';
32
+ import 'https';
33
+ import './types/whatsapp.mjs';
32
34
 
33
35
 
34
36
 
package/dist/index.d.ts CHANGED
@@ -1,34 +1,36 @@
1
1
  import WhatsApp from './whatsapp.js';
2
2
  import './types/config.js';
3
- import './enums-D6WRUWH9.js';
4
- import './request.js';
5
- import './types/httpsClient.js';
6
- import './httpsClient.js';
7
- import 'https';
3
+ import './enums-Dn5Y1Nom.js';
4
+ import './api/businessProfile.js';
5
+ import './types/businessProfile.js';
8
6
  import './types/request.js';
9
- import './types/whatsapp.js';
7
+ import './api/base.js';
8
+ import './types/base.js';
9
+ import './api/encryption.js';
10
+ import './types/encryption.js';
11
+ import './api/flow.js';
12
+ import './types/flow.js';
13
+ import './api/media.js';
14
+ import './types/media.js';
10
15
  import './api/messages.js';
11
16
  import './types/messages.js';
12
- import './types/base.js';
13
- import './api/base.js';
14
17
  import './api/phoneNumber.js';
15
18
  import './types/phoneNumber.js';
16
- import './api/template.js';
17
- import './types/template.js';
19
+ import './api/qrCode.js';
20
+ import './types/qrCode.js';
18
21
  import './api/registration.js';
19
22
  import './types/registration.js';
23
+ import './api/template.js';
24
+ import './types/template.js';
20
25
  import './api/twoStepVerification.js';
21
26
  import './types/twoStepVerification.js';
22
- import './api/qrCode.js';
23
- import './types/qrCode.js';
24
- import './api/encryption.js';
25
- import './types/encryption.js';
26
27
  import './api/waba.js';
27
28
  import './types/waba.js';
28
- import './api/media.js';
29
- import './types/media.js';
30
- import './api/flow.js';
31
- import './types/flow.js';
29
+ import './request.js';
30
+ import './types/httpsClient.js';
31
+ import './httpsClient.js';
32
+ import 'https';
33
+ import './types/whatsapp.js';
32
34
 
33
35
 
34
36
 
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var K=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ce=Object.prototype.hasOwnProperty;var x=(r,t)=>{for(var s in t)K(r,s,{get:t[s],enumerable:!0})},he=(r,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of fe(t))!ce.call(r,p)&&p!==s&&K(r,p,{get:()=>t[p],enumerable:!(i=le(t,p))||i.enumerable});return r};var Pe=r=>he(K({},"__esModule",{value:!0}),r);var xe={};x(xe,{default:()=>$e});module.exports=Pe(xe);var H={};x(H,{AudioMediaTypesEnum:()=>C,ButtonPositionEnum:()=>Z,ButtonTypesEnum:()=>k,CategoryEnum:()=>v,ComponentTypesEnum:()=>Y,ConversationTypesEnum:()=>j,CurrencyCodesEnum:()=>re,DataLocalizationRegionEnum:()=>pe,DocumentMediaTypesEnum:()=>E,HttpMethodsEnum:()=>g,ImageMediaTypesEnum:()=>u,InteractiveTypesEnum:()=>X,LanguagesEnum:()=>oe,MessageTypesEnum:()=>F,ParametersTypesEnum:()=>J,ReferralSourceTypesEnum:()=>se,RequestCodeMethodsEnum:()=>ie,StatusEnum:()=>Q,StickerMediaTypesEnum:()=>y,SystemChangeTypesEnum:()=>te,TemplateStatusEnum:()=>V,VideoMediaTypesEnum:()=>z,WabaConfigEnum:()=>P,WebhookTypesEnum:()=>ee});var v=(i=>(i.Authentication="AUTHENTICATION",i.Marketing="MARKETING",i.Utility="UTILITY",i))(v||{}),V=(i=>(i.Approved="APPROVED",i.Pending="PENDING",i.Rejected="REJECTED",i))(V||{}),g=(p=>(p.Get="GET",p.Post="POST",p.Put="PUT",p.Delete="DELETE",p))(g||{}),F=(R=>(R.Audio="audio",R.Contacts="contacts",R.Document="document",R.Image="image",R.Interactive="interactive",R.Location="location",R.Reaction="sticker",R.Sticker="sticker",R.Template="template",R.Text="text",R.Video="video",R))(F||{}),J=(l=>(l.Currency="currency",l.DateTime="date_time",l.Document="document",l.Image="image",l.Text="text",l.Video="video",l.Payload="payload",l))(J||{}),X=(p=>(p.Button="button",p.List="list",p.Product="product",p.ProductList="product_list",p))(X||{}),k=(s=>(s.QuickReply="quick_reply",s.URL="url",s))(k||{}),Z=(i=>(i[i.First=0]="First",i[i.Second=1]="Second",i[i.Third=2]="Third",i))(Z||{}),Y=(p=>(p.Header="HEADER",p.Body="BODY",p.Button="BUTTON",p.Footer="FOOTER",p))(Y||{}),P=(a=>(a.BaseURL="WA_BASE_URL",a.AppId="M4D_APP_ID",a.Port="WA_PORT",a.AppSecret="M4D_APP_SECRET",a.PhoneNumberId="WA_PHONE_NUMBER_ID",a.BusinessAcctId="WA_BUSINESS_ACCOUNT_ID",a.APIVersion="CLOUD_API_VERSION",a.AccessToken="CLOUD_API_ACCESS_TOKEN",a.WebhookEndpoint="WEBHOOK_ENDPOINT",a.WebhookVerificationToken="WEBHOOK_VERIFICATION_TOKEN",a.ListenerPort="LISTENER_PORT",a.MaxRetriesAfterWait="MAX_RETRIES_AFTER_WAIT",a.RequestTimeout="REQUEST_TIMEOUT",a.Debug="DEBUG",a))(P||{}),j=(i=>(i.BusinessInitiated="business_initiated",i.CustomerInitiated="customer_initiated",i.ReferralConversion="referral_conversion",i))(j||{}),Q=(i=>(i.Delivered="delivered",i.Read="read",i.Sent="sent",i))(Q||{}),z=(s=>(s.Mp4="video/mp4",s.Threegp="video/3gp",s))(z||{}),y=(t=>(t.Webp="image/webp",t))(y||{}),u=(s=>(s.Jpeg="image/jpeg",s.Png="image/png",s))(u||{}),E=(c=>(c.Text="text/plain",c.Pdf="application/pdf",c.Ppt="application/vnd.ms-powerpoint",c.Word="application/msword",c.Excel="application/vnd.ms-excel",c.OpenDoc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",c.OpenPres="application/vnd.openxmlformats-officedocument.presentationml.presentation",c.OpenSheet="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",c))(E||{}),C=(f=>(f.Aac="audio/aac",f.Mp4="audio/mp4",f.Mpeg="audio/mpeg",f.Amr="audio/amr",f.Ogg="audio/ogg",f))(C||{}),ee=(R=>(R.Audio="audio",R.Button="button",R.Document="document",R.Text="text",R.Image="image",R.Interactive="interactive",R.Order="order",R.Sticker="sticker",R.System="system",R.Unknown="unknown",R.Video="video",R))(ee||{}),te=(s=>(s.CustomerChangedNumber="customer_changed_number",s.CustomerIdentityChanged="customer_identity_changed",s))(te||{}),se=(s=>(s.Ad="ad",s.Post="post",s))(se||{}),ie=(s=>(s.Sms="SMS",s.Voice="VOICE",s))(ie||{}),oe=(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))(oe||{}),re=(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))(re||{}),pe=(a=>(a.AU="AU",a.ID="ID",a.IN="IN",a.JP="JP",a.SG="SG",a.KR="KR",a.DE="DE",a.CH="CH",a.GB="GB",a.BR="BR",a.BH="BH",a.ZA="ZA",a.AE="AE",a.CA="CA",a))(pe||{});var h=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 ge="UTILS",Ae=!1,W=new h(ge,process.env.DEBUG==="true"||Ae),Se="graph.facebook.com",Ie="v22.0",be=3e3,qe=30,Te=2e4,De=(r,t)=>{if(!process.env.WA_PHONE_NUMBER_ID&&!r)throw W.log("Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined."),new Error("Missing WhatsApp sender phone number Id.");if(!process.env.CLOUD_API_ACCESS_TOKEN&&!t)throw W.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.");if(!process.env.CLOUD_API_VERSION)throw W.log("Environmental variable: CLOUD_API_VERSION is undefined."),new Error("Missing WhatsApp API version.")},ae=r=>{De(r?.phoneNumberId,r?.accessToken);let t={WA_BASE_URL:process.env.WA_BASE_URL||Se,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:r?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||Ie,CLOUD_API_ACCESS_TOKEN:r?.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||"")||be,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||qe,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||Te,DEBUG:process.env.DEBUG==="true"};return W.log(`Configuration loaded for App Id ${t.M4D_APP_ID}`),t};var ne=require("https");var _e="HttpsClient",Ne=!1,de=new h(_e,process.env.DEBUG==="true"||Ne),O=class{agent;constructor(){this.agent=new ne.Agent({keepAlive:!0})}clearSockets(){return this.agent.destroy(),!0}async sendRequest(t,s,i,p,f,B){let l=`https://${t}/${s}`,c=new AbortController,Re=setTimeout(()=>c.abort(),f);try{let G=await fetch(l,{method:i,headers:p,body:B,signal:c.signal});return de.log(`${i} : ${l} - ${JSON.stringify(G)}`),clearTimeout(Re),new L(G)}catch(G){throw G}}},L=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 $(r){return r!=null&&typeof r=="object"&&"error"in r&&typeof r.error=="object"&&r.error!=null&&"message"in r.error&&typeof r.error.message=="string"&&"type"in r.error&&typeof r.error.type=="string"&&"code"in r.error&&typeof r.error.code=="number"&&"fbtrace_id"in r.error&&typeof r.error.fbtrace_id=="string"&&(!("error_data"in r.error)||typeof r.error.error_data=="object"&&r.error.error_data!=null&&"messaging_product"in r.error.error_data&&r.error.error_data.messaging_product==="whatsapp"&&"details"in r.error.error_data&&typeof r.error.error_data.details=="string")&&(!("error_subcode"in r.error)||typeof r.error.error_subcode=="number")}var Be="REQUESTER",Oe=!1,me=new h(Be,process.env.DEBUG==="true"||Oe),m=class{client;accessToken;phoneNumberId;businessAcctId;apiVersion;userAgent;host;protocol="https:";constructor(t,s,i,p,f,B){this.client=new O,this.host=t,this.apiVersion=s,this.phoneNumberId=i,this.accessToken=p,this.businessAcctId=f,this.userAgent=B}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,p){let f="application/json",B=`${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(s)}`;me.log(`${t} : ${B}`);try{let l=await this.client.sendRequest(this.host,this.buildCAPIPath(s),t,this.buildHeader(f),i,t==="POST"||t==="PUT"?p:void 0);if(!l.rawResponse().ok){let c=await l.json();throw $(c)?c:{name:"MetaError",message:"Unknown error occurred",error:{message:c.message||"Unknown error occurred",type:"UnknownError",code:l.statusCode(),fbtrace_id:""}}}return l}catch(l){throw $(l)?l:{name:"MetaError",message:l instanceof Error?l.message:"Network error occurred",error:{message:l instanceof Error?l.message:"Network error occurred",type:"NetworkError",code:500,fbtrace_id:""}}}}};var Me="BaseAPI",Ue=!1,we=new h(Me,process.env.DEBUG==="true"||Ue),n=class{config;client;constructor(t,s){this.config=t,this.client=s,we.log("Initialized with HTTPSClient")}};var A=class extends n{commonMethod="POST";commonEndpoint="messages";constructor(t,s){super(t,s)}bodyBuilder(t,s,i,p){let f={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:s};return p&&(f.context={message_id:p}),f}send(t){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("audio",t,s.toString(),i)))}async contacts(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("contacts",t,s.toString(),i)))}async document(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("document",t,s.toString(),i)))}async image(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("image",t,s.toString(),i)))}async interactive(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,s.toString(),i)))}async location(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("location",t,s.toString(),i)))}async sticker(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("sticker",t,s.toString(),i)))}async template(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("template",t,s.toString(),i)))}async text(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("text",t,s.toString(),i)))}async video(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("video",t,s.toString(),i)))}async status(t){let i=Object.assign({messaging_product:"whatsapp"},t);return this.send(JSON.stringify(i))}};var M=r=>{if(!r||Object.keys(r).length===0)return"";let t=new URLSearchParams;for(let[i,p]of Object.entries(r))p!==void 0&&t.append(i,String(p));let s=t.toString();return s?`?${s}`:""};var S=class extends n{endpoint="phone_numbers";constructor(t,s){super(t,s)}async getPhoneNumberById(t){let s=t?M({fields:t}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var I=class extends n{endpoint="message_templates";constructor(t,s){super(t,s)}async getTemplate(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,s){return this.client.sendRequest("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getTemplates(t){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${M(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${M(t)}`,this.config.REQUEST_TIMEOUT,null)}};var b=class extends n{constructor(t,s){super(t,s)}async register(t,s){let i={messaging_product:"whatsapp",pin:t,...s&&{data_localization_region:s}};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deregister(){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var q=class extends n{constructor(t,s){super(t,s)}async setTwoStepVerificationCode(t){let s={pin:t};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var T=class extends n{endpoint="message_qrdls";constructor(t,s){super(t,s)}async createQrCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.client.sendRequest("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var D=class extends n{endpoint="whatsapp_business_encryption";constructor(t,s){super(t,s)}async getEncryptionPublicKey(){return this.client.sendRequest("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.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}};var _=class extends n{constructor(t,s){super(t,s)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async subscribeToWaba(){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async overrideWabaWebhook(t,s){let i={url:t,verify_token:s};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/webhooks`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}};var N=class extends n{endpoint="media";constructor(t,s){super(t,s)}async getMediaById(t){return this.client.sendRequest("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.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,i)}async deleteMedia(t){return this.client.sendRequest("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.client.sendRequest("GET",t,this.config.REQUEST_TIMEOUT,null)}};var Ge="FlowAPI",We=!1,Ke=new h(Ge,process.env.DEBUG==="true"||We),d=class extends n{constructor(t,s){super(t,s),Ke.log("FlowAPI initialized")}async listFlows(t){return this.client.sendRequest("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.client.sendRequest("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,i)}async getFlow(t,s,i){let p=new URLSearchParams;s&&p.append("fields",s),i&&p.append("date_format",i);let f=p.toString()?`?${p.toString()}`:"";return this.client.sendRequest("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.client.sendRequest("POST",`/${t}`,this.config.REQUEST_TIMEOUT,i)}async deleteFlow(t){return this.client.sendRequest("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.client.sendRequest("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.client.sendRequest("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,i)}async publishFlow(t){return this.client.sendRequest("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.client.sendRequest("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.client.sendRequest("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,i)}};var Fe="WHATSAPP",He=!1,U=new h(Fe,process.env.DEBUG==="true"||He),Le="WA_SDK",w=class{config;requester;messages;templates;phoneNumber;qrCode;encryption;twoStepVerification;registration;media;waba;flow;static Enums=H;constructor(t){this.config=ae(t),this.requester=new m(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 A(this.config,this.requester),this.templates=new I(this.config,this.requester),this.phoneNumber=new S(this.config,this.requester),this.qrCode=new T(this.config,this.requester),this.encryption=new D(this.config,this.requester),this.twoStepVerification=new q(this.config,this.requester),this.registration=new b(this.config,this.requester),this.media=new N(this.config,this.requester),this.waba=new _(this.config,this.requester),this.flow=new d(this.config,this.requester),U.log("WhatsApp Node.js SDK instantiated!")}userAgent(){return`${Le}/0.0.1 (Node.js ${process.version})`}updateTimeout(t){return this.config.REQUEST_TIMEOUT=t,U.log(`Updated request timeout to ${t}ms`),!0}updatePhoneNumberId(t){return this.config.WA_PHONE_NUMBER_ID=t,U.log(`Updated sender phone number id to ${t}`),!0}updateAccessToken(t){return this.config.CLOUD_API_ACCESS_TOKEN=t,U.log("Updated access token"),!0}updateWabaId(t){return this.config.WA_BUSINESS_ACCOUNT_ID=t,U.log(`Updated business account id to ${t}`),!0}};var $e=w;
1
+ "use strict";var L=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var J=(r,t)=>{for(var s in t)L(r,s,{get:t[s],enumerable:!0})},ge=(r,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of Pe(t))!Ae.call(r,p)&&p!==s&&L(r,p,{get:()=>t[p],enumerable:!(i=he(t,p))||i.enumerable});return r};var Ie=r=>ge(L({},"__esModule",{value:!0}),r);var Xe={};J(Xe,{default:()=>Je});module.exports=Ie(Xe);var $={};J($,{AudioMediaTypesEnum:()=>te,BusinessVerticalEnum:()=>Re,ButtonPositionEnum:()=>j,ButtonTypesEnum:()=>Z,CategoryEnum:()=>X,ComponentTypesEnum:()=>Q,ConversationTypesEnum:()=>z,CurrencyCodesEnum:()=>ne,DataLocalizationRegionEnum:()=>ae,DocumentMediaTypesEnum:()=>ee,HttpMethodsEnum:()=>g,ImageMediaTypesEnum:()=>C,InteractiveTypesEnum:()=>k,LanguagesEnum:()=>pe,MessageTypesEnum:()=>H,ParametersTypesEnum:()=>V,ReferralSourceTypesEnum:()=>oe,RequestCodeMethodsEnum:()=>re,StatusEnum:()=>y,StickerMediaTypesEnum:()=>E,SystemChangeTypesEnum:()=>ie,TemplateStatusEnum:()=>Y,VideoMediaTypesEnum:()=>u,WabaConfigEnum:()=>P,WebhookTypesEnum:()=>se});var X=(i=>(i.Authentication="AUTHENTICATION",i.Marketing="MARKETING",i.Utility="UTILITY",i))(X||{}),Y=(i=>(i.Approved="APPROVED",i.Pending="PENDING",i.Rejected="REJECTED",i))(Y||{}),g=(p=>(p.Get="GET",p.Post="POST",p.Put="PUT",p.Delete="DELETE",p))(g||{}),H=(R=>(R.Audio="audio",R.Contacts="contacts",R.Document="document",R.Image="image",R.Interactive="interactive",R.Location="location",R.Reaction="sticker",R.Sticker="sticker",R.Template="template",R.Text="text",R.Video="video",R))(H||{}),V=(l=>(l.Currency="currency",l.DateTime="date_time",l.Document="document",l.Image="image",l.Text="text",l.Video="video",l.Payload="payload",l))(V||{}),k=(p=>(p.Button="button",p.List="list",p.Product="product",p.ProductList="product_list",p))(k||{}),Z=(s=>(s.QuickReply="quick_reply",s.URL="url",s))(Z||{}),j=(i=>(i[i.First=0]="First",i[i.Second=1]="Second",i[i.Third=2]="Third",i))(j||{}),Q=(p=>(p.Header="HEADER",p.Body="BODY",p.Button="BUTTON",p.Footer="FOOTER",p))(Q||{}),P=(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))(P||{}),z=(i=>(i.BusinessInitiated="business_initiated",i.CustomerInitiated="customer_initiated",i.ReferralConversion="referral_conversion",i))(z||{}),y=(i=>(i.Delivered="delivered",i.Read="read",i.Sent="sent",i))(y||{}),u=(s=>(s.Mp4="video/mp4",s.Threegp="video/3gp",s))(u||{}),E=(t=>(t.Webp="image/webp",t))(E||{}),C=(s=>(s.Jpeg="image/jpeg",s.Png="image/png",s))(C||{}),ee=(h=>(h.Text="text/plain",h.Pdf="application/pdf",h.Ppt="application/vnd.ms-powerpoint",h.Word="application/msword",h.Excel="application/vnd.ms-excel",h.OpenDoc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",h.OpenPres="application/vnd.openxmlformats-officedocument.presentationml.presentation",h.OpenSheet="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",h))(ee||{}),te=(c=>(c.Aac="audio/aac",c.Mp4="audio/mp4",c.Mpeg="audio/mpeg",c.Amr="audio/amr",c.Ogg="audio/ogg",c))(te||{}),se=(R=>(R.Audio="audio",R.Button="button",R.Document="document",R.Text="text",R.Image="image",R.Interactive="interactive",R.Order="order",R.Sticker="sticker",R.System="system",R.Unknown="unknown",R.Video="video",R))(se||{}),ie=(s=>(s.CustomerChangedNumber="customer_changed_number",s.CustomerIdentityChanged="customer_identity_changed",s))(ie||{}),oe=(s=>(s.Ad="ad",s.Post="post",s))(oe||{}),re=(s=>(s.Sms="SMS",s.Voice="VOICE",s))(re||{}),pe=(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))(pe||{}),ne=(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))(ne||{}),ae=(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))(ae||{}),Re=(f=>(f.ALCOHOL="ALCOHOL",f.APPAREL="APPAREL",f.AUTO="AUTO",f.BEAUTY="BEAUTY",f.EDU="EDU",f.ENTERTAIN="ENTERTAIN",f.EVENT_PLAN="EVENT_PLAN",f.FINANCE="FINANCE",f.GOVT="GOVT",f.GROCERY="GROCERY",f.HEALTH="HEALTH",f.HOTEL="HOTEL",f.NONPROFIT="NONPROFIT",f.ONLINE_GAMBLING="ONLINE_GAMBLING",f.OTC_DRUGS="OTC_DRUGS",f.OTHER="OTHER",f.PHYSICAL_GAMBLING="PHYSICAL_GAMBLING",f.PROF_SERVICES="PROF_SERVICES",f.RESTAURANT="RESTAURANT",f.RETAIL="RETAIL",f.TRAVEL="TRAVEL",f))(Re||{});var A=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 Se="BaseAPI",Te=!1,be=new A(Se,process.env.DEBUG==="true"||Te),a=class{config;client;constructor(t,s){this.config=t,this.client=s,be.log("Initialized with HTTPSClient")}};var I=r=>{if(!r||Object.keys(r).length===0)return"";let t=new URLSearchParams;for(let[i,p]of Object.entries(r))p!==void 0&&t.append(i,String(p));let s=t.toString();return s?`?${s}`:""};var S=class extends a{endpoint="whatsapp_business_profile";constructor(t,s){super(t,s)}async getBusinessProfile(t){let s=t?I({fields:t}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${s}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,s,i){let p=I({file_length:t,file_type:s,file_name:i});return this.client.sendRequest("POST",`app/uploads/${p}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,s){return this.client.sendRequest("POST",`${t}`,this.config.REQUEST_TIMEOUT,s)}async getUploadHandle(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};var T=class extends a{endpoint="whatsapp_business_encryption";constructor(t,s){super(t,s)}async getEncryptionPublicKey(){return this.client.sendRequest("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.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,s)}};var qe="FlowAPI",Ne=!1,de=new A(qe,process.env.DEBUG==="true"||Ne),b=class extends a{constructor(t,s){super(t,s),de.log("FlowAPI initialized")}async listFlows(t){return this.client.sendRequest("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.client.sendRequest("POST",`/${t}/flows`,this.config.REQUEST_TIMEOUT,i)}async getFlow(t,s,i){let p=new URLSearchParams;s&&p.append("fields",s),i&&p.append("date_format",i);let c=p.toString()?`?${p.toString()}`:"";return this.client.sendRequest("GET",`/${t}${c}`,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.client.sendRequest("POST",`/${t}`,this.config.REQUEST_TIMEOUT,i)}async deleteFlow(t){return this.client.sendRequest("DELETE",`/${t}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(t){return this.client.sendRequest("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.client.sendRequest("POST",`/${t}/assets`,this.config.REQUEST_TIMEOUT,i)}async publishFlow(t){return this.client.sendRequest("POST",`/${t}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(t){return this.client.sendRequest("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.client.sendRequest("POST",`/${t}/migrate_flows`,this.config.REQUEST_TIMEOUT,i)}};var q=class extends a{endpoint="media";constructor(t,s){super(t,s)}async getMediaById(t){return this.client.sendRequest("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.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,i)}async deleteMedia(t){return this.client.sendRequest("DELETE",`${t}`,this.config.REQUEST_TIMEOUT,null)}async downloadMedia(t){return this.client.sendRequest("GET",t,this.config.REQUEST_TIMEOUT,null)}};var N=class extends a{commonMethod="POST";commonEndpoint="messages";constructor(t,s){super(t,s)}bodyBuilder(t,s,i,p){let c={messaging_product:"whatsapp",recipient_type:"individual",to:i,type:t,[t]:s};return p&&(c.context={message_id:p}),c}send(t){return this.client.sendRequest(this.commonMethod,`${this.config.WA_PHONE_NUMBER_ID}/${this.commonEndpoint}`,this.config.REQUEST_TIMEOUT,t)}async audio(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("audio",t,s.toString(),i)))}async contacts(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("contacts",t,s.toString(),i)))}async document(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("document",t,s.toString(),i)))}async image(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("image",t,s.toString(),i)))}async interactive(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("interactive",t,s.toString(),i)))}async location(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("location",t,s.toString(),i)))}async sticker(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("sticker",t,s.toString(),i)))}async template(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("template",t,s.toString(),i)))}async text(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("text",t,s.toString(),i)))}async video(t,s,i){return this.send(JSON.stringify(this.bodyBuilder("video",t,s.toString(),i)))}async status(t){let i=Object.assign({messaging_product:"whatsapp"},t);return this.send(JSON.stringify(i))}};var d=class extends a{endpoint="phone_numbers";constructor(t,s){super(t,s)}async getPhoneNumberById(t){let s=t?I({fields:t}):"";return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}${s}`,this.config.REQUEST_TIMEOUT,null)}async getPhoneNumbers(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async requestVerificationCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/request_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async verifyCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/verify_code`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}};var _=class extends a{endpoint="message_qrdls";constructor(t,s){super(t,s)}async createQrCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async getQrCodes(){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async getQrCode(t){return this.client.sendRequest("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}async updateQrCode(t){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteQrCode(t){return this.client.sendRequest("DELETE",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}/${t}`,this.config.REQUEST_TIMEOUT,null)}};var D=class extends a{constructor(t,s){super(t,s)}async register(t,s){let i={messaging_product:"whatsapp",pin:t,...s&&{data_localization_region:s}};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/register`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}async deregister(){return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}/deregister`,this.config.REQUEST_TIMEOUT,null)}};var O=class extends a{endpoint="message_templates";constructor(t,s){super(t,s)}async getTemplate(t){return this.client.sendRequest("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}async updateTemplate(t,s){return this.client.sendRequest("POST",`${t}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}async getTemplates(t){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${I(t)}`,this.config.REQUEST_TIMEOUT,null)}async createTemplate(t){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async deleteTemplate(t){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/${this.endpoint}${I(t)}`,this.config.REQUEST_TIMEOUT,null)}};var B=class extends a{constructor(t,s){super(t,s)}async setTwoStepVerificationCode(t){let s={pin:t};return this.client.sendRequest("POST",`${this.config.WA_PHONE_NUMBER_ID}`,this.config.REQUEST_TIMEOUT,JSON.stringify(s))}};var m=class extends a{constructor(t,s){super(t,s)}async getAllWabaSubscriptions(){return this.client.sendRequest("GET",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async subscribeToWaba(){return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async unsubscribeFromWaba(){return this.client.sendRequest("DELETE",`${this.config.WA_BUSINESS_ACCOUNT_ID}/subscribed_apps`,this.config.REQUEST_TIMEOUT,null)}async overrideWabaWebhook(t,s){let i={url:t,verify_token:s};return this.client.sendRequest("POST",`${this.config.WA_BUSINESS_ACCOUNT_ID}/webhooks`,this.config.REQUEST_TIMEOUT,JSON.stringify(i))}};var le=require("https");var _e="HttpsClient",De=!1,Oe=new A(_e,process.env.DEBUG==="true"||De),U=class{agent;constructor(){this.agent=new le.Agent({keepAlive:!0})}clearSockets(){return this.agent.destroy(),!0}async sendRequest(t,s,i,p,c,M){let l=`https://${t}/${s}`,h=new AbortController,ce=setTimeout(()=>h.abort(),c);try{let F=await fetch(l,{method:i,headers:p,body:M,signal:h.signal});return Oe.log(`${i} : ${l} - ${JSON.stringify(F)}`),clearTimeout(ce),new x(F)}catch(F){throw F}}},x=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 v(r){return r!=null&&typeof r=="object"&&"error"in r&&typeof r.error=="object"&&r.error!=null&&"message"in r.error&&typeof r.error.message=="string"&&"type"in r.error&&typeof r.error.type=="string"&&"code"in r.error&&typeof r.error.code=="number"&&"fbtrace_id"in r.error&&typeof r.error.fbtrace_id=="string"&&(!("error_data"in r.error)||typeof r.error.error_data=="object"&&r.error.error_data!=null&&"messaging_product"in r.error.error_data&&r.error.error_data.messaging_product==="whatsapp"&&"details"in r.error.error_data&&typeof r.error.error_data.details=="string")&&(!("error_subcode"in r.error)||typeof r.error.error_subcode=="number")}var Be="REQUESTER",me=!1,Me=new A(Be,process.env.DEBUG==="true"||me),G=class{client;accessToken;phoneNumberId;businessAcctId;apiVersion;userAgent;host;protocol="https:";constructor(t,s,i,p,c,M){this.client=new U,this.host=t,this.apiVersion=s,this.phoneNumberId=i,this.accessToken=p,this.businessAcctId=c,this.userAgent=M}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,p){let c="application/json",M=`${this.protocol.toLowerCase()}//${this.host}/${this.buildCAPIPath(s)}`;Me.log(`${t} : ${M}`);try{let l=await this.client.sendRequest(this.host,this.buildCAPIPath(s),t,this.buildHeader(c),i,t==="POST"||t==="PUT"?p:void 0);if(!l.rawResponse().ok){let h=await l.json();throw v(h)?h:{name:"MetaError",message:"Unknown error occurred",error:{message:h.message||"Unknown error occurred",type:"UnknownError",code:l.statusCode(),fbtrace_id:""}}}return l}catch(l){throw v(l)?l:{name:"MetaError",message:l instanceof Error?l.message:"Network error occurred",error:{message:l instanceof Error?l.message:"Network error occurred",type:"NetworkError",code:500,fbtrace_id:""}}}}};var Ue="UTILS",Ge=!1,K=new A(Ue,process.env.DEBUG==="true"||Ge),we="graph.facebook.com",We="v22.0",Fe=3e3,Ke=30,Le=2e4,He=(r,t)=>{if(!process.env.WA_PHONE_NUMBER_ID&&!r)throw K.log("Environmental variable: WA_PHONE_NUMBER_ID and/or sender phone number id argument is undefined."),new Error("Missing WhatsApp sender phone number Id.");if(!process.env.CLOUD_API_ACCESS_TOKEN&&!t)throw K.log("Environmental variable: CLOUD_API_ACCESS_TOKEN and/or access token argument is undefined."),new Error("Missing WhatsApp access token.");if(!process.env.CLOUD_API_VERSION)throw K.log("Environmental variable: CLOUD_API_VERSION is undefined."),new Error("Missing WhatsApp API version.")},fe=r=>{He(r?.phoneNumberId,r?.accessToken);let t={WA_BASE_URL:process.env.WA_BASE_URL||we,M4D_APP_ID:process.env.M4D_APP_ID||"",M4D_APP_SECRET:process.env.M4D_APP_SECRET||"",WA_PHONE_NUMBER_ID:r?.phoneNumberId||parseInt(process.env.WA_PHONE_NUMBER_ID||""),WA_BUSINESS_ACCOUNT_ID:process.env.WA_BUSINESS_ACCOUNT_ID||"",CLOUD_API_VERSION:process.env.CLOUD_API_VERSION||We,CLOUD_API_ACCESS_TOKEN:r?.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||"")||Fe,MAX_RETRIES_AFTER_WAIT:parseInt(process.env.MAX_RETRIES_AFTER_WAIT||"")||Ke,REQUEST_TIMEOUT:parseInt(process.env.REQUEST_TIMEOUT||"")||Le,DEBUG:process.env.DEBUG==="true"};return K.log(`Configuration loaded for App Id ${t.M4D_APP_ID}`),t};var $e="WHATSAPP",xe=!1,w=new A($e,process.env.DEBUG==="true"||xe),ve="WA_SDK",W=class{config;requester;messages;templates;phoneNumber;qrCode;encryption;twoStepVerification;registration;media;waba;flow;businessProfile;static Enums=$;constructor(t){this.config=fe(t),this.requester=new G(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 N(this.config,this.requester),this.templates=new O(this.config,this.requester),this.phoneNumber=new d(this.config,this.requester),this.qrCode=new _(this.config,this.requester),this.encryption=new T(this.config,this.requester),this.twoStepVerification=new B(this.config,this.requester),this.registration=new D(this.config,this.requester),this.media=new q(this.config,this.requester),this.waba=new m(this.config,this.requester),this.flow=new b(this.config,this.requester),this.businessProfile=new S(this.config,this.requester),w.log("WhatsApp Node.js SDK instantiated!")}userAgent(){return`${ve}/0.0.1 (Node.js ${process.version})`}updateTimeout(t){return this.config.REQUEST_TIMEOUT=t,w.log(`Updated request timeout to ${t}ms`),!0}updatePhoneNumberId(t){return this.config.WA_PHONE_NUMBER_ID=t,w.log(`Updated sender phone number id to ${t}`),!0}updateAccessToken(t){return this.config.CLOUD_API_ACCESS_TOKEN=t,w.log("Updated access token"),!0}updateWabaId(t){return this.config.WA_BUSINESS_ACCOUNT_ID=t,w.log(`Updated business account id to ${t}`),!0}};var Je=W;
2
2
  //# sourceMappingURL=index.js.map