@queenanya/baileys 7.3.5 → 7.3.7

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 (395) hide show
  1. package/.anya-md/.replit +2 -0
  2. package/.anya-md/.temp/.temp +1 -0
  3. package/.anya-md/Dockerfile +16 -0
  4. package/.anya-md/LICENCE +674 -0
  5. package/.anya-md/README.md +301 -0
  6. package/.anya-md/app.json +81 -0
  7. package/.anya-md/config.js +74 -0
  8. package/.anya-md/heroku.yml +5 -0
  9. package/.anya-md/index.js +47 -0
  10. package/.anya-md/koyeb.yaml +14 -0
  11. package/.anya-md/lib/.dev.js +47 -0
  12. package/.anya-md/lib/Assets/aliveMedia.mp4 +0 -0
  13. package/.anya-md/lib/Assets/goodbyeBG.jpg +0 -0
  14. package/.anya-md/lib/Assets/image_1.jpg +0 -0
  15. package/.anya-md/lib/Assets/image_2.jpg +0 -0
  16. package/.anya-md/lib/Assets/menuMedia.mp4 +0 -0
  17. package/.anya-md/lib/Assets/ownerMentionMp3.mp3 +0 -0
  18. package/.anya-md/lib/Assets/port.html +36 -0
  19. package/.anya-md/lib/Assets/reaction/angry/angry108202410.jpeg +0 -0
  20. package/.anya-md/lib/Assets/reaction/angry/angry108202412.jpeg +0 -0
  21. package/.anya-md/lib/Assets/reaction/angry/angry108202413.jpeg +0 -0
  22. package/.anya-md/lib/Assets/reaction/angry/angry108202414.jpeg +0 -0
  23. package/.anya-md/lib/Assets/reaction/angry/angry108202415.jpeg +0 -0
  24. package/.anya-md/lib/Assets/reaction/angry/angry108202416.jpeg +0 -0
  25. package/.anya-md/lib/Assets/reaction/angry/angry108202417.jpeg +0 -0
  26. package/.anya-md/lib/Assets/reaction/angry/angry108202418.jpeg +0 -0
  27. package/.anya-md/lib/Assets/reaction/angry/angry108202419.jpeg +0 -0
  28. package/.anya-md/lib/Assets/reaction/angry/angry108202420.jpeg +0 -0
  29. package/.anya-md/lib/Assets/reaction/angry/angry108202421.jpeg +0 -0
  30. package/.anya-md/lib/Assets/reaction/angry/angry108202423.jpeg +0 -0
  31. package/.anya-md/lib/Assets/reaction/angry/angry108202425.jpeg +0 -0
  32. package/.anya-md/lib/Assets/reaction/angry/angry108202426.jpeg +0 -0
  33. package/.anya-md/lib/Assets/reaction/angry/angry108202427.jpeg +0 -0
  34. package/.anya-md/lib/Assets/reaction/angry/angry108202428.jpeg +0 -0
  35. package/.anya-md/lib/Assets/reaction/angry/angry108202429.jpeg +0 -0
  36. package/.anya-md/lib/Assets/reaction/angry/angry108202430.jpeg +0 -0
  37. package/.anya-md/lib/Assets/reaction/angry/angry108202431.jpeg +0 -0
  38. package/.anya-md/lib/Assets/reaction/angry/angry108202469.jpeg +0 -0
  39. package/.anya-md/lib/Assets/reaction/angry/angry10820249.jpeg +0 -0
  40. package/.anya-md/lib/Assets/reaction/angry/angry11.mp4 +0 -0
  41. package/.anya-md/lib/Assets/reaction/angry/angry12.mp4 +0 -0
  42. package/.anya-md/lib/Assets/reaction/angry/angry14.jpg +0 -0
  43. package/.anya-md/lib/Assets/reaction/angry/angry2.mp4 +0 -0
  44. package/.anya-md/lib/Assets/reaction/angry/angry3.mp4 +0 -0
  45. package/.anya-md/lib/Assets/reaction/angry/angry5.jpg +0 -0
  46. package/.anya-md/lib/Assets/reaction/angry/angry6.png +0 -0
  47. package/.anya-md/lib/Assets/reaction/angry/angry8.png +0 -0
  48. package/.anya-md/lib/Assets/reaction/angry/angry9.jpg +0 -0
  49. package/.anya-md/lib/Assets/reaction/confused/confused1.png +0 -0
  50. package/.anya-md/lib/Assets/reaction/confused/confused2.jpg +0 -0
  51. package/.anya-md/lib/Assets/reaction/confused/confused3.jpg +0 -0
  52. package/.anya-md/lib/Assets/reaction/confused/confused4.mp4 +0 -0
  53. package/.anya-md/lib/Assets/reaction/confused/confused5.jpg +0 -0
  54. package/.anya-md/lib/Assets/reaction/confused/confused6.webp +0 -0
  55. package/.anya-md/lib/Assets/reaction/confused/confused7.png +0 -0
  56. package/.anya-md/lib/Assets/reaction/confused/confused8.jpg +0 -0
  57. package/.anya-md/lib/Assets/reaction/cry/cry1.jpeg +0 -0
  58. package/.anya-md/lib/Assets/reaction/cry/cry12.jpeg +0 -0
  59. package/.anya-md/lib/Assets/reaction/cry/cry13.jpeg +0 -0
  60. package/.anya-md/lib/Assets/reaction/cry/cry14.jpeg +0 -0
  61. package/.anya-md/lib/Assets/reaction/cry/cry15.jpeg +0 -0
  62. package/.anya-md/lib/Assets/reaction/cry/cry16.jpeg +0 -0
  63. package/.anya-md/lib/Assets/reaction/cry/cry17.jpeg +0 -0
  64. package/.anya-md/lib/Assets/reaction/cry/cry18.jpeg +0 -0
  65. package/.anya-md/lib/Assets/reaction/cry/cry19.jpeg +0 -0
  66. package/.anya-md/lib/Assets/reaction/cry/cry22.jpeg +0 -0
  67. package/.anya-md/lib/Assets/reaction/cry/cry23.jpeg +0 -0
  68. package/.anya-md/lib/Assets/reaction/cry/cry5.jpeg +0 -0
  69. package/.anya-md/lib/Assets/reaction/cry/cry9.jpeg +0 -0
  70. package/.anya-md/lib/Assets/reaction/happy/happyrect1.jpeg +0 -0
  71. package/.anya-md/lib/Assets/reaction/no/_pika +1 -0
  72. package/.anya-md/lib/Assets/reaction/no/no1.jpg +0 -0
  73. package/.anya-md/lib/Assets/reaction/no/no2.png +0 -0
  74. package/.anya-md/lib/Assets/reaction/no/no3.jpg +0 -0
  75. package/.anya-md/lib/Assets/reaction/no/no4.png +0 -0
  76. package/.anya-md/lib/Assets/reaction/no/no5.png +0 -0
  77. package/.anya-md/lib/Assets/reaction/no/no6.jpg +0 -0
  78. package/.anya-md/lib/Assets/reaction/no/no7.jpg +0 -0
  79. package/.anya-md/lib/Assets/reaction/no/no8.jpg +0 -0
  80. package/.anya-md/lib/Assets/reaction/no/no9.mp4 +0 -0
  81. package/.anya-md/lib/Assets/reaction/smug/059e1bdc-e62a-4943-b85e-ea372709f6a7.jpeg +0 -0
  82. package/.anya-md/lib/Assets/reaction/smug/8fda90b3-bc98-4d24-ac10-4402c4e7be93.jpeg +0 -0
  83. package/.anya-md/lib/Assets/reaction/smug/Aqua.jpeg +0 -0
  84. package/.anya-md/lib/Assets/reaction/smug/Karasuma Chitose.jpeg +0 -0
  85. package/.anya-md/lib/Assets/reaction/smug/Smug Face - Fibel Sistine.jpeg +0 -0
  86. package/.anya-md/lib/Assets/reaction/smug/bf8d78ec-4fcc-4ff7-b3c3-91a0c5f22567.jpeg +0 -0
  87. package/.anya-md/lib/Assets/reaction/smug//330/247/330/255/331/204/330/247/331/213 /330/247/330/250/330/252/330/263/330/247/331/205/331/207 /330/264/330/261/331/212/330/261/331/207/360/237/230/255/360/237/230/255/360/237/230/255.jpeg +0 -0
  88. package/.anya-md/lib/Assets/verifyIMG.jpg +0 -0
  89. package/.anya-md/lib/Assets/welcomeGIF.mp4 +0 -0
  90. package/.anya-md/lib/database/categories.json +77 -0
  91. package/.anya-md/lib/database/cooldown.json +1 -0
  92. package/.anya-md/lib/database/disk/main.js +43 -0
  93. package/.anya-md/lib/database/emoji.js +23 -0
  94. package/.anya-md/lib/database/games/quiz/Questions.js +44 -0
  95. package/.anya-md/lib/database/games/quiz/Quiz.js +169 -0
  96. package/.anya-md/lib/database/games/quiz/database.json +1 -0
  97. package/.anya-md/lib/database/games/quiz/index.js +7 -0
  98. package/.anya-md/lib/database/json/.pika.js +3 -0
  99. package/.anya-md/lib/database/json/animeQuotes.json +51062 -0
  100. package/.anya-md/lib/database/json/bioQuotes.json +5744 -0
  101. package/.anya-md/lib/database/json/cogan.json +102 -0
  102. package/.anya-md/lib/database/json/countries.json +21210 -0
  103. package/.anya-md/lib/database/json/countries2.json +1 -0
  104. package/.anya-md/lib/database/json/couplepp.json +725 -0
  105. package/.anya-md/lib/database/json/flaming.json +7 -0
  106. package/.anya-md/lib/database/json/ganpati.json +102 -0
  107. package/.anya-md/lib/database/json/husbu.json +1967 -0
  108. package/.anya-md/lib/database/json/islamicWall.json +501 -0
  109. package/.anya-md/lib/database/json/pickupLines.json +118 -0
  110. package/.anya-md/lib/database/json/shreeram.json +49 -0
  111. package/.anya-md/lib/database/json/truthDare.json +643 -0
  112. package/.anya-md/lib/database/mongodb/README.md +142 -0
  113. package/.anya-md/lib/database/mongodb/bot.js +12 -0
  114. package/.anya-md/lib/database/mongodb/cmd.js +17 -0
  115. package/.anya-md/lib/database/mongodb/group.js +22 -0
  116. package/.anya-md/lib/database/mongodb/index.js +24 -0
  117. package/.anya-md/lib/database/mongodb/plugins.js +124 -0
  118. package/.anya-md/lib/database/mongodb/system.js +34 -0
  119. package/.anya-md/lib/database/mongodb/ui.js +15 -0
  120. package/.anya-md/lib/database/mongodb/user.js +17 -0
  121. package/.anya-md/lib/database/mongodb/warn.js +136 -0
  122. package/.anya-md/lib/database/sessions/.pika.js +3 -0
  123. package/.anya-md/lib/frameworks/index.js +5 -0
  124. package/.anya-md/lib/frameworks/reactionMedia.js +91 -0
  125. package/.anya-md/lib/lib/README.md +29 -0
  126. package/.anya-md/lib/lib/ai/README.md +35 -0
  127. package/.anya-md/lib/lib/ai/aiArt.js +47 -0
  128. package/.anya-md/lib/lib/ai/index.js +7 -0
  129. package/.anya-md/lib/lib/buttons.js +530 -0
  130. package/.anya-md/lib/lib/connectionMsg.js +72 -0
  131. package/.anya-md/lib/lib/converter.js +355 -0
  132. package/.anya-md/lib/lib/cooldown.js +46 -0
  133. package/.anya-md/lib/lib/events.js +47 -0
  134. package/.anya-md/lib/lib/functions.js +47 -0
  135. package/.anya-md/lib/lib/greeting.js +115 -0
  136. package/.anya-md/lib/lib/index.js +381 -0
  137. package/.anya-md/lib/lib/logger.js +7 -0
  138. package/.anya-md/lib/lib/maker/remini.js +35 -0
  139. package/.anya-md/lib/lib/mongoUrlFix.js +46 -0
  140. package/.anya-md/lib/lib/myfunc.js +47 -0
  141. package/.anya-md/lib/lib/plugins.js +20 -0
  142. package/.anya-md/lib/lib/prefix.js +47 -0
  143. package/.anya-md/lib/lib/scraper/README.md +35 -0
  144. package/.anya-md/lib/lib/scraper/SoundCloud.js +47 -0
  145. package/.anya-md/lib/lib/scraper/WebToons.js +47 -0
  146. package/.anya-md/lib/lib/scraper/android1.js +47 -0
  147. package/.anya-md/lib/lib/scraper/happymodSearch.js +47 -0
  148. package/.anya-md/lib/lib/scraper/index.js +27 -0
  149. package/.anya-md/lib/lib/scraper/konaChanSearch.js +47 -0
  150. package/.anya-md/lib/lib/scraper/pinterest.js +47 -0
  151. package/.anya-md/lib/lib/scraper/playstore.js +47 -0
  152. package/.anya-md/lib/lib/scraper/ringtone.js +47 -0
  153. package/.anya-md/lib/lib/scraper/steam.js +47 -0
  154. package/.anya-md/lib/lib/scraper/trendingTwitter.js +51 -0
  155. package/.anya-md/lib/lib/scraper/wattpad.js +61 -0
  156. package/.anya-md/lib/lib/scraper/wikipediaSearch.js +42 -0
  157. package/.anya-md/lib/lib/scraper.js +47 -0
  158. package/.anya-md/lib/lib/session.js +47 -0
  159. package/.anya-md/lib/lib/session2.js +47 -0
  160. package/.anya-md/lib/lib/similar.js +47 -0
  161. package/.anya-md/lib/lib/stylish-font.js +2302 -0
  162. package/.anya-md/lib/lib/unicode.js +877 -0
  163. package/.anya-md/lib/lib/upload/index.js +3 -0
  164. package/.anya-md/lib/lib/upload/webp2mp4File.js +56 -0
  165. package/.anya-md/lib/lib/ytdl-core.js +47 -0
  166. package/.anya-md/lib/plugins/README.md +83 -0
  167. package/.anya-md/lib/plugins/_menu.js +810 -0
  168. package/.anya-md/lib/plugins/_plugins.js +239 -0
  169. package/.anya-md/lib/plugins/admins.js +689 -0
  170. package/.anya-md/lib/plugins/ai.js +160 -0
  171. package/.anya-md/lib/plugins/autoreply.js +101 -0
  172. package/.anya-md/lib/plugins/broadcast.js +204 -0
  173. package/.anya-md/lib/plugins/convert.js +293 -0
  174. package/.anya-md/lib/plugins/core.js +941 -0
  175. package/.anya-md/lib/plugins/download.js +373 -0
  176. package/.anya-md/lib/plugins/fun.js +75 -0
  177. package/.anya-md/lib/plugins/games.js +33 -0
  178. package/.anya-md/lib/plugins/gcswitches.js +204 -0
  179. package/.anya-md/lib/plugins/general.js +456 -0
  180. package/.anya-md/lib/plugins/maker.js +41 -0
  181. package/.anya-md/lib/plugins/owner.js +1049 -0
  182. package/.anya-md/lib/plugins/religious.js +81 -0
  183. package/.anya-md/lib/plugins/search.js +902 -0
  184. package/.anya-md/lib/plugins/stalker.js +187 -0
  185. package/.anya-md/lib/plugins/sticker.js +125 -0
  186. package/.anya-md/lib/plugins/tools.js +193 -0
  187. package/.anya-md/lib/plugins/youtube.js +204 -0
  188. package/.anya-md/package.json +75 -0
  189. package/.anya-md/railway.json +12 -0
  190. package/.anya-md/render.yaml +48 -0
  191. package/.anya-md/replit.nix +18 -0
  192. package/.bash_history +500 -0
  193. package/.config/gh/config.yml +19 -0
  194. package/.config/gh/hosts.yml +11 -0
  195. package/.config/ngrok/ngrok.yml +3 -0
  196. package/.config/yarn/global/package.json +5 -0
  197. package/.gitconfig +772 -0
  198. package/.node_repl_history +0 -0
  199. package/.npm/_cacache/content-v2/sha512/02/b3/d1abf5af06222f7de440ab1b057deb21f9dfb0ce0a8f5064b2ba00595933bbcbbaa040b4616f951d9f8ba48d67491df1198a4831fbd8ee26eb27dde36511 +0 -0
  200. package/.npm/_cacache/content-v2/sha512/49/7b/0cdbb4861f7c9358a7367ca478498371b269efb8143d75de901ed1169a267f56a68e60f008952f3ebcc727dbb60bb401011af3514a1dd33cdbed8d981fa8 +0 -0
  201. package/.npm/_cacache/content-v2/sha512/54/3a/647bceb49b7632e6e700cb9f1b66f0f528d4ca71f4f73e76a1e7c8c50b563a2d0bb7734c18f93e6c03b7ea93167db35db0e1999ab13b08ed6b250eed2d2a +1 -0
  202. package/.npm/_cacache/content-v2/sha512/56/7c/4d5820233a7278225351642f7355d9889af42e7efbbfe27d6b201727efad972a59fa32063c7e1159d01dbf27ba014095ca1349ec0d0767746c39441178fa +1 -0
  203. package/.npm/_cacache/content-v2/sha512/89/88/d295c7e4f4d0f4621676d4c499bea2a1c72b0c31a84ff78a8bb8f83042da2bcf596e664c021d21025b296cdd4aecb57a036ea366e39466df5a129fa471df +0 -0
  204. package/.npm/_cacache/content-v2/sha512/8b/46/42882ebb46a975b0ce6b9cdea357190c41b51bb59a21df41c575418850b28115921e130709846d8ff9cabeae72544ec37a48ee7ccb074fe94da925250e55 +1 -0
  205. package/.npm/_cacache/content-v2/sha512/dd/0d/f856b793da0619d18260556498dfff13391593abb6d6a582bf052f03ba35a03a1444bf5c2d40b7515d268ec2cb3e67a17a42f09f5e668c3bb9b743e3b8a7 +1 -0
  206. package/.npm/_cacache/content-v2/sha512/dd/15/702501c36ce653a003d2b101034a0cb9c0fd262fa77797f1a286a161a0b2dce51ef13199e9a3fa58008bdbbf4646a33b6f1a24a2807691093cb89beefb00 +1 -0
  207. package/.npm/_cacache/index-v5/35/f9/e8cc076ef93c1bc40804d3fe05171053366095c922f515b1fab2b580116f +4 -0
  208. package/.npm/_cacache/index-v5/6a/a2/780c77f928115d4dad58a9dc4fa241de8d914abfff994e44602cc93a697c +2 -0
  209. package/.npm/_cacache/index-v5/71/ba/d0bb16fddeb617bbbb3713f46750d1bf5b57742abb6feb6dee4d16c68da4 +4 -0
  210. package/.npm/_cacache/index-v5/72/ae/c69532318093b3bd13618450ca5c26adc018a4afc0e020786207068593cf +2 -0
  211. package/.npm/_cacache/index-v5/7e/5e/9683ad4854f4201d7e53bf9beb2aefafa7b1efbb2c6ac7b36b78d0b218c8 +2 -0
  212. package/.npm/_cacache/index-v5/eb/a0/19e529094c594367a9e1aa68096a313d3dc5509d410761bf50122826a6d2 +4 -0
  213. package/.npm/_cacache/index-v5/f1/fa/2d2f12de549683d1275ec0f2ff15610b408fd89d1b7a755ddb7b77c00371 +2 -0
  214. package/.npm/_logs/2024-10-03T05_52_01_853Z-debug-0.log +52 -0
  215. package/.npm/_logs/2024-10-03T05_52_08_135Z-debug-0.log +52 -0
  216. package/.npm/_logs/2024-10-03T05_52_14_087Z-debug-0.log +52 -0
  217. package/.npm/_logs/2024-10-03T05_52_22_730Z-debug-0.log +52 -0
  218. package/.npm/_logs/2024-10-03T05_52_29_410Z-debug-0.log +52 -0
  219. package/.npm/_logs/2024-10-03T05_52_35_375Z-debug-0.log +52 -0
  220. package/.npm/_logs/2024-10-03T15_32_57_465Z-debug-0.log +20 -0
  221. package/.npm/_logs/2024-10-10T05_40_23_847Z-debug-0.log +254 -0
  222. package/.npm/_logs/2024-10-10T05_40_50_397Z-debug-0.log +73 -0
  223. package/.npm/_logs/2024-10-10T05_40_59_931Z-debug-0.log +52 -0
  224. package/.npm/_logs/2024-10-10T05_42_07_969Z-debug-0.log +52 -0
  225. package/.pm2/logs/anya-error.log +0 -0
  226. package/.pm2/logs/anya-out.log +59 -0
  227. package/.pm2/logs/anya-v2-error.log +2184 -0
  228. package/.pm2/logs/anya-v2-out.log +362 -0
  229. package/.pm2/module_conf.json +1 -0
  230. package/.pm2/pm2.log +919 -0
  231. package/.pm2/pm2.pid +1 -0
  232. package/.pm2/touch +1 -0
  233. package/.ssh/authorized_keys +0 -0
  234. package/.termux/termux.properties +180 -0
  235. package/.wget-hsts +5 -0
  236. package/package.json +2 -102
  237. package/LICENSE +0 -21
  238. package/README.md +0 -941
  239. package/WAProto/GenerateStatics.sh +0 -4
  240. package/WAProto/WAProto.proto +0 -3344
  241. package/WAProto/index.d.ts +0 -37016
  242. package/WAProto/index.js +0 -101044
  243. package/WASignalGroup/GroupProtocol.js +0 -1697
  244. package/WASignalGroup/ciphertext_message.js +0 -16
  245. package/WASignalGroup/group_cipher.js +0 -120
  246. package/WASignalGroup/group_session_builder.js +0 -46
  247. package/WASignalGroup/index.js +0 -5
  248. package/WASignalGroup/keyhelper.js +0 -21
  249. package/WASignalGroup/protobufs.js +0 -3
  250. package/WASignalGroup/queue_job.js +0 -69
  251. package/WASignalGroup/sender_chain_key.js +0 -50
  252. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  253. package/WASignalGroup/sender_key_message.js +0 -92
  254. package/WASignalGroup/sender_key_name.js +0 -70
  255. package/WASignalGroup/sender_key_record.js +0 -56
  256. package/WASignalGroup/sender_key_state.js +0 -129
  257. package/WASignalGroup/sender_message_key.js +0 -39
  258. package/lib/Defaults/baileys-version.json +0 -3
  259. package/lib/Defaults/index.d.ts +0 -284
  260. package/lib/Defaults/index.js +0 -122
  261. package/lib/Defaults/phonenumber-mcc.json +0 -223
  262. package/lib/Signal/libsignal.d.ts +0 -3
  263. package/lib/Signal/libsignal.js +0 -152
  264. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  265. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  266. package/lib/Socket/Client/index.d.ts +0 -3
  267. package/lib/Socket/Client/index.js +0 -19
  268. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  269. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  270. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  271. package/lib/Socket/Client/web-socket-client.js +0 -62
  272. package/lib/Socket/business.d.ts +0 -177
  273. package/lib/Socket/business.js +0 -260
  274. package/lib/Socket/chats.d.ts +0 -91
  275. package/lib/Socket/chats.js +0 -948
  276. package/lib/Socket/groups.d.ts +0 -137
  277. package/lib/Socket/groups.js +0 -314
  278. package/lib/Socket/index.d.ts +0 -179
  279. package/lib/Socket/index.js +0 -10
  280. package/lib/Socket/messages-recv.d.ts +0 -164
  281. package/lib/Socket/messages-recv.js +0 -921
  282. package/lib/Socket/messages-send.d.ts +0 -157
  283. package/lib/Socket/messages-send.js +0 -779
  284. package/lib/Socket/newsletter.d.ts +0 -143
  285. package/lib/Socket/newsletter.js +0 -249
  286. package/lib/Socket/registration.d.ts +0 -271
  287. package/lib/Socket/registration.js +0 -166
  288. package/lib/Socket/socket.d.ts +0 -44
  289. package/lib/Socket/socket.js +0 -620
  290. package/lib/Store/index.d.ts +0 -3
  291. package/lib/Store/index.js +0 -10
  292. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  293. package/lib/Store/make-cache-manager-store.js +0 -83
  294. package/lib/Store/make-in-memory-store.d.ts +0 -118
  295. package/lib/Store/make-in-memory-store.js +0 -422
  296. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  297. package/lib/Store/make-ordered-dictionary.js +0 -81
  298. package/lib/Store/object-repository.d.ts +0 -10
  299. package/lib/Store/object-repository.js +0 -27
  300. package/lib/Types/Auth.d.ts +0 -111
  301. package/lib/Types/Auth.js +0 -2
  302. package/lib/Types/Call.d.ts +0 -13
  303. package/lib/Types/Call.js +0 -2
  304. package/lib/Types/Chat.d.ts +0 -107
  305. package/lib/Types/Chat.js +0 -4
  306. package/lib/Types/Contact.d.ts +0 -19
  307. package/lib/Types/Contact.js +0 -2
  308. package/lib/Types/Events.d.ts +0 -199
  309. package/lib/Types/Events.js +0 -2
  310. package/lib/Types/GroupMetadata.d.ts +0 -56
  311. package/lib/Types/GroupMetadata.js +0 -2
  312. package/lib/Types/Label.d.ts +0 -46
  313. package/lib/Types/Label.js +0 -27
  314. package/lib/Types/LabelAssociation.d.ts +0 -29
  315. package/lib/Types/LabelAssociation.js +0 -9
  316. package/lib/Types/Message.d.ts +0 -278
  317. package/lib/Types/Message.js +0 -9
  318. package/lib/Types/Newsletter.d.ts +0 -79
  319. package/lib/Types/Newsletter.js +0 -18
  320. package/lib/Types/Product.d.ts +0 -78
  321. package/lib/Types/Product.js +0 -2
  322. package/lib/Types/Signal.d.ts +0 -57
  323. package/lib/Types/Signal.js +0 -2
  324. package/lib/Types/Socket.d.ts +0 -118
  325. package/lib/Types/Socket.js +0 -2
  326. package/lib/Types/State.d.ts +0 -27
  327. package/lib/Types/State.js +0 -2
  328. package/lib/Types/index.d.ts +0 -65
  329. package/lib/Types/index.js +0 -42
  330. package/lib/Utils/auth-utils.d.ts +0 -18
  331. package/lib/Utils/auth-utils.js +0 -206
  332. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  333. package/lib/Utils/baileys-event-stream.js +0 -63
  334. package/lib/Utils/business.d.ts +0 -22
  335. package/lib/Utils/business.js +0 -234
  336. package/lib/Utils/chat-utils.d.ts +0 -72
  337. package/lib/Utils/chat-utils.js +0 -740
  338. package/lib/Utils/crypto.d.ts +0 -42
  339. package/lib/Utils/crypto.js +0 -153
  340. package/lib/Utils/decode-wa-message.d.ts +0 -20
  341. package/lib/Utils/decode-wa-message.js +0 -207
  342. package/lib/Utils/event-buffer.d.ts +0 -35
  343. package/lib/Utils/event-buffer.js +0 -520
  344. package/lib/Utils/generics.d.ts +0 -115
  345. package/lib/Utils/generics.js +0 -440
  346. package/lib/Utils/history.d.ts +0 -19
  347. package/lib/Utils/history.js +0 -94
  348. package/lib/Utils/index.d.ts +0 -17
  349. package/lib/Utils/index.js +0 -33
  350. package/lib/Utils/link-preview.d.ts +0 -21
  351. package/lib/Utils/link-preview.js +0 -93
  352. package/lib/Utils/logger.d.ts +0 -2
  353. package/lib/Utils/logger.js +0 -7
  354. package/lib/Utils/lt-hash.d.ts +0 -12
  355. package/lib/Utils/lt-hash.js +0 -51
  356. package/lib/Utils/make-mutex.d.ts +0 -7
  357. package/lib/Utils/make-mutex.js +0 -43
  358. package/lib/Utils/messages-media.d.ts +0 -131
  359. package/lib/Utils/messages-media.js +0 -793
  360. package/lib/Utils/messages.d.ts +0 -78
  361. package/lib/Utils/messages.js +0 -771
  362. package/lib/Utils/noise-handler.d.ts +0 -22
  363. package/lib/Utils/noise-handler.js +0 -155
  364. package/lib/Utils/process-message.d.ts +0 -42
  365. package/lib/Utils/process-message.js +0 -354
  366. package/lib/Utils/signal.d.ts +0 -32
  367. package/lib/Utils/signal.js +0 -156
  368. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
  369. package/lib/Utils/use-multi-file-auth-state.js +0 -93
  370. package/lib/Utils/validate-connection.d.ts +0 -11
  371. package/lib/Utils/validate-connection.js +0 -205
  372. package/lib/WABinary/constants.d.ts +0 -27
  373. package/lib/WABinary/constants.js +0 -40
  374. package/lib/WABinary/decode.d.ts +0 -8
  375. package/lib/WABinary/decode.js +0 -254
  376. package/lib/WABinary/encode.d.ts +0 -2
  377. package/lib/WABinary/encode.js +0 -228
  378. package/lib/WABinary/generic-utils.d.ts +0 -16
  379. package/lib/WABinary/generic-utils.js +0 -110
  380. package/lib/WABinary/index.d.ts +0 -5
  381. package/lib/WABinary/index.js +0 -21
  382. package/lib/WABinary/jid-utils.d.ts +0 -31
  383. package/lib/WABinary/jid-utils.js +0 -62
  384. package/lib/WABinary/types.d.ts +0 -18
  385. package/lib/WABinary/types.js +0 -2
  386. package/lib/WAM/BinaryInfo.d.ts +0 -18
  387. package/lib/WAM/BinaryInfo.js +0 -13
  388. package/lib/WAM/constants.d.ts +0 -38
  389. package/lib/WAM/constants.js +0 -15350
  390. package/lib/WAM/encode.d.ts +0 -4
  391. package/lib/WAM/encode.js +0 -155
  392. package/lib/WAM/index.d.ts +0 -3
  393. package/lib/WAM/index.js +0 -19
  394. package/lib/index.d.ts +0 -11
  395. package/lib/index.js +0 -30
@@ -1,771 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.assertMediaContent = exports.downloadMediaMessage = exports.aggregateMessageKeysNotFromMe = exports.getAggregateVotesInPollMessage = exports.updateMessageWithPollUpdate = exports.updateMessageWithReaction = exports.updateMessageWithReceipt = exports.getDevice = exports.extractMessageContent = exports.normalizeMessageContent = exports.getContentType = exports.generateWAMessage = exports.generateWAMessageFromContent = exports.generateWAMessageContent = exports.generateForwardMessageContent = exports.prepareDisappearingMessageSettingContent = exports.prepareWAMessageMedia = exports.generateLinkPreviewIfRequired = exports.extractUrlFromText = void 0;
7
- const boom_1 = require("@hapi/boom");
8
- const axios_1 = __importDefault(require("axios"));
9
- const crypto_1 = require("crypto");
10
- const fs_1 = require("fs");
11
- const WAProto_1 = require("../../WAProto");
12
- const Defaults_1 = require("../Defaults");
13
- const Types_1 = require("../Types");
14
- const WABinary_1 = require("../WABinary");
15
- const crypto_2 = require("./crypto");
16
- const generics_1 = require("./generics");
17
- const messages_media_1 = require("./messages-media");
18
- const MIMETYPE_MAP = {
19
- image: 'image/jpeg',
20
- video: 'video/mp4',
21
- document: 'application/pdf',
22
- audio: 'audio/ogg; codecs=opus',
23
- sticker: 'image/webp',
24
- 'product-catalog-image': 'image/jpeg',
25
- };
26
- const MessageTypeProto = {
27
- 'image': Types_1.WAProto.Message.ImageMessage,
28
- 'video': Types_1.WAProto.Message.VideoMessage,
29
- 'audio': Types_1.WAProto.Message.AudioMessage,
30
- 'sticker': Types_1.WAProto.Message.StickerMessage,
31
- 'document': Types_1.WAProto.Message.DocumentMessage,
32
- };
33
- /**
34
- * Uses a regex to test whether the string contains a URL, and returns the URL if it does.
35
- * @param text eg. hello https://google.com
36
- * @returns the URL, eg. https://google.com
37
- */
38
- const extractUrlFromText = (text) => { var _a; return (_a = text.match(Defaults_1.URL_REGEX)) === null || _a === void 0 ? void 0 : _a[0]; };
39
- exports.extractUrlFromText = extractUrlFromText;
40
- const generateLinkPreviewIfRequired = async (text, getUrlInfo, logger) => {
41
- const url = (0, exports.extractUrlFromText)(text);
42
- if (!!getUrlInfo && url) {
43
- try {
44
- const urlInfo = await getUrlInfo(url);
45
- return urlInfo;
46
- }
47
- catch (error) { // ignore if fails
48
- logger === null || logger === void 0 ? void 0 : logger.warn({ trace: error.stack }, 'url generation failed');
49
- }
50
- }
51
- };
52
- exports.generateLinkPreviewIfRequired = generateLinkPreviewIfRequired;
53
- const assertColor = async (color) => {
54
- let assertedColor;
55
- if (typeof color === 'number') {
56
- assertedColor = color > 0 ? color : 0xffffffff + Number(color) + 1;
57
- }
58
- else {
59
- let hex = color.trim().replace('#', '');
60
- if (hex.length <= 6) {
61
- hex = 'FF' + hex.padStart(6, '0');
62
- }
63
- assertedColor = parseInt(hex, 16);
64
- return assertedColor;
65
- }
66
- };
67
- const prepareWAMessageMedia = async (message, options) => {
68
- const logger = options.logger;
69
- let mediaType;
70
- for (const key of Defaults_1.MEDIA_KEYS) {
71
- if (key in message) {
72
- mediaType = key;
73
- }
74
- }
75
- if (!mediaType) {
76
- throw new boom_1.Boom('Invalid media type', { statusCode: 400 });
77
- }
78
- const uploadData = {
79
- ...message,
80
- media: message[mediaType]
81
- };
82
- delete uploadData[mediaType];
83
- // check if cacheable + generate cache key
84
- const cacheableKey = typeof uploadData.media === 'object' &&
85
- ('url' in uploadData.media) &&
86
- !!uploadData.media.url &&
87
- !!options.mediaCache && (
88
- // generate the key
89
- mediaType + ':' + uploadData.media.url.toString());
90
- if (mediaType === 'document' && !uploadData.fileName) {
91
- uploadData.fileName = 'file';
92
- }
93
- if (!uploadData.mimetype) {
94
- uploadData.mimetype = MIMETYPE_MAP[mediaType];
95
- }
96
- // check for cache hit
97
- if (cacheableKey) {
98
- const mediaBuff = options.mediaCache.get(cacheableKey);
99
- if (mediaBuff) {
100
- logger === null || logger === void 0 ? void 0 : logger.debug({ cacheableKey }, 'got media cache hit');
101
- const obj = Types_1.WAProto.Message.decode(mediaBuff);
102
- const key = `${mediaType}Message`;
103
- Object.assign(obj[key], { ...uploadData, media: undefined });
104
- return obj;
105
- }
106
- }
107
- const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined';
108
- const requiresThumbnailComputation = (mediaType === 'image' || mediaType === 'video') &&
109
- (typeof uploadData['jpegThumbnail'] === 'undefined');
110
- const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true;
111
- const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true;
112
- const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation;
113
- const { mediaKey, encWriteStream, bodyPath, fileEncSha256, fileSha256, fileLength, didSaveToTmpPath, } = await (options.newsletter ? messages_media_1.prepareStream : messages_media_1.encryptedStream)(uploadData.media, options.mediaTypeOverride || mediaType, {
114
- logger,
115
- saveOriginalFileIfRequired: requiresOriginalForSomeProcessing,
116
- opts: options.options
117
- });
118
- // url safe Base64 encode the SHA256 hash of the body
119
- const fileEncSha256B64 = (options.newsletter ? fileSha256 : fileEncSha256 !== null && fileEncSha256 !== void 0 ? fileEncSha256 : fileSha256).toString('base64');
120
- const [{ mediaUrl, directPath, handle }] = await Promise.all([
121
- (async () => {
122
- const result = await options.upload(encWriteStream, { fileEncSha256B64, mediaType, timeoutMs: options.mediaUploadTimeoutMs });
123
- logger === null || logger === void 0 ? void 0 : logger.debug({ mediaType, cacheableKey }, 'uploaded media');
124
- return result;
125
- })(),
126
- (async () => {
127
- try {
128
- if (requiresThumbnailComputation) {
129
- const { thumbnail, originalImageDimensions } = await (0, messages_media_1.generateThumbnail)(bodyPath, mediaType, options);
130
- uploadData.jpegThumbnail = thumbnail;
131
- if (!uploadData.width && originalImageDimensions) {
132
- uploadData.width = originalImageDimensions.width;
133
- uploadData.height = originalImageDimensions.height;
134
- logger === null || logger === void 0 ? void 0 : logger.debug('set dimensions');
135
- }
136
- logger === null || logger === void 0 ? void 0 : logger.debug('generated thumbnail');
137
- }
138
- if (requiresDurationComputation) {
139
- uploadData.seconds = await (0, messages_media_1.getAudioDuration)(bodyPath);
140
- logger === null || logger === void 0 ? void 0 : logger.debug('computed audio duration');
141
- }
142
- if (requiresWaveformProcessing) {
143
- uploadData.waveform = await (0, messages_media_1.getAudioWaveform)(bodyPath, logger);
144
- logger === null || logger === void 0 ? void 0 : logger.debug('processed waveform');
145
- }
146
- if (requiresWaveformProcessing) {
147
- uploadData.waveform = await (0, messages_media_1.getAudioWaveform)(bodyPath, logger);
148
- logger === null || logger === void 0 ? void 0 : logger.debug('processed waveform');
149
- }
150
- if (requiresAudioBackground) {
151
- uploadData.backgroundArgb = await assertColor(options.backgroundColor);
152
- logger === null || logger === void 0 ? void 0 : logger.debug('computed backgroundColor audio status');
153
- }
154
- }
155
- catch (error) {
156
- logger === null || logger === void 0 ? void 0 : logger.warn({ trace: error.stack }, 'failed to obtain extra info');
157
- }
158
- })(),
159
- ])
160
- .finally(async () => {
161
- if (!Buffer.isBuffer(encWriteStream)) {
162
- encWriteStream.destroy();
163
- }
164
- // remove tmp files
165
- if (didSaveToTmpPath && bodyPath) {
166
- await fs_1.promises.unlink(bodyPath);
167
- logger === null || logger === void 0 ? void 0 : logger.debug('removed tmp files');
168
- }
169
- });
170
- const obj = Types_1.WAProto.Message.fromObject({
171
- [`${mediaType}Message`]: MessageTypeProto[mediaType].fromObject({
172
- url: handle ? undefined : mediaUrl,
173
- directPath,
174
- mediaKey: mediaKey,
175
- fileEncSha256: fileEncSha256,
176
- fileSha256,
177
- fileLength,
178
- mediaKeyTimestamp: handle ? undefined : (0, generics_1.unixTimestampSeconds)(),
179
- ...uploadData,
180
- media: undefined
181
- })
182
- });
183
- if (uploadData.ptv) {
184
- obj.ptvMessage = obj.videoMessage;
185
- delete obj.videoMessage;
186
- }
187
- if (cacheableKey) {
188
- logger === null || logger === void 0 ? void 0 : logger.debug({ cacheableKey }, 'set cache');
189
- options.mediaCache.set(cacheableKey, Types_1.WAProto.Message.encode(obj).finish());
190
- }
191
- return obj;
192
- };
193
- exports.prepareWAMessageMedia = prepareWAMessageMedia;
194
- const prepareDisappearingMessageSettingContent = (ephemeralExpiration) => {
195
- ephemeralExpiration = ephemeralExpiration || 0;
196
- const content = {
197
- ephemeralMessage: {
198
- message: {
199
- protocolMessage: {
200
- type: Types_1.WAProto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING,
201
- ephemeralExpiration
202
- }
203
- }
204
- }
205
- };
206
- return Types_1.WAProto.Message.fromObject(content);
207
- };
208
- exports.prepareDisappearingMessageSettingContent = prepareDisappearingMessageSettingContent;
209
- /**
210
- * Generate forwarded message content like WA does
211
- * @param message the message to forward
212
- * @param options.forceForward will show the message as forwarded even if it is from you
213
- */
214
- const generateForwardMessageContent = (message, forceForward) => {
215
- var _a;
216
- let content = message.message;
217
- if (!content) {
218
- throw new boom_1.Boom('no content in message', { statusCode: 400 });
219
- }
220
- // hacky copy
221
- content = (0, exports.normalizeMessageContent)(content);
222
- content = WAProto_1.proto.Message.decode(WAProto_1.proto.Message.encode(content).finish());
223
- let key = Object.keys(content)[0];
224
- let score = ((_a = content[key].contextInfo) === null || _a === void 0 ? void 0 : _a.forwardingScore) || 0;
225
- score += message.key.fromMe && !forceForward ? 0 : 1;
226
- if (key === 'conversation') {
227
- content.extendedTextMessage = { text: content[key] };
228
- delete content.conversation;
229
- key = 'extendedTextMessage';
230
- }
231
- if (score > 0) {
232
- content[key].contextInfo = { forwardingScore: score, isForwarded: true };
233
- }
234
- else {
235
- content[key].contextInfo = {};
236
- }
237
- return content;
238
- };
239
- exports.generateForwardMessageContent = generateForwardMessageContent;
240
- const generateWAMessageContent = async (message, options) => {
241
- var _a;
242
- var _b, _c;
243
- let m = {};
244
- if ('text' in message) {
245
- const extContent = { text: message.text };
246
- let urlInfo = message.linkPreview;
247
- if (typeof urlInfo === 'undefined') {
248
- urlInfo = await (0, exports.generateLinkPreviewIfRequired)(message.text, options.getUrlInfo, options.logger);
249
- }
250
- if (urlInfo) {
251
- extContent.canonicalUrl = urlInfo['canonical-url'];
252
- extContent.matchedText = urlInfo['matched-text'];
253
- extContent.jpegThumbnail = urlInfo.jpegThumbnail;
254
- extContent.description = urlInfo.description;
255
- extContent.title = urlInfo.title;
256
- extContent.previewType = 0;
257
- const img = urlInfo.highQualityThumbnail;
258
- if (img) {
259
- extContent.thumbnailDirectPath = img.directPath;
260
- extContent.mediaKey = img.mediaKey;
261
- extContent.mediaKeyTimestamp = img.mediaKeyTimestamp;
262
- extContent.thumbnailWidth = img.width;
263
- extContent.thumbnailHeight = img.height;
264
- extContent.thumbnailSha256 = img.fileSha256;
265
- extContent.thumbnailEncSha256 = img.fileEncSha256;
266
- }
267
- }
268
- if (options.backgroundColor) {
269
- extContent.backgroundArgb = await assertColor(options.backgroundColor);
270
- }
271
- if (options.font) {
272
- extContent.font = options.font;
273
- }
274
- m.extendedTextMessage = extContent;
275
- }
276
- else if ('contacts' in message) {
277
- const contactLen = message.contacts.contacts.length;
278
- if (!contactLen) {
279
- throw new boom_1.Boom('require atleast 1 contact', { statusCode: 400 });
280
- }
281
- if (contactLen === 1) {
282
- m.contactMessage = Types_1.WAProto.Message.ContactMessage.fromObject(message.contacts.contacts[0]);
283
- }
284
- else {
285
- m.contactsArrayMessage = Types_1.WAProto.Message.ContactsArrayMessage.fromObject(message.contacts);
286
- }
287
- }
288
- else if ('location' in message) {
289
- m.locationMessage = Types_1.WAProto.Message.LocationMessage.fromObject(message.location);
290
- }
291
- else if ('react' in message) {
292
- if (!message.react.senderTimestampMs) {
293
- message.react.senderTimestampMs = Date.now();
294
- }
295
- m.reactionMessage = Types_1.WAProto.Message.ReactionMessage.fromObject(message.react);
296
- }
297
- else if ('delete' in message) {
298
- m.protocolMessage = {
299
- key: message.delete,
300
- type: Types_1.WAProto.Message.ProtocolMessage.Type.REVOKE
301
- };
302
- }
303
- else if ('forward' in message) {
304
- m = (0, exports.generateForwardMessageContent)(message.forward, message.force);
305
- }
306
- else if ('disappearingMessagesInChat' in message) {
307
- const exp = typeof message.disappearingMessagesInChat === 'boolean' ?
308
- (message.disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
309
- message.disappearingMessagesInChat;
310
- m = (0, exports.prepareDisappearingMessageSettingContent)(exp);
311
- }
312
- else if ('groupInvite' in message) {
313
- m.groupInviteMessage = {};
314
- m.groupInviteMessage.inviteCode = message.groupInvite.inviteCode;
315
- m.groupInviteMessage.inviteExpiration = message.groupInvite.inviteExpiration;
316
- m.groupInviteMessage.caption = message.groupInvite.text;
317
- m.groupInviteMessage.groupJid = message.groupInvite.jid;
318
- m.groupInviteMessage.groupName = message.groupInvite.subject;
319
- //TODO: use built-in interface and get disappearing mode info etc.
320
- //TODO: cache / use store!?
321
- if (options.getProfilePicUrl) {
322
- const pfpUrl = await options.getProfilePicUrl(message.groupInvite.jid, 'preview');
323
- if (pfpUrl) {
324
- const resp = await axios_1.default.get(pfpUrl, { responseType: 'arraybuffer' });
325
- if (resp.status === 200) {
326
- m.groupInviteMessage.jpegThumbnail = resp.data;
327
- }
328
- }
329
- }
330
- }
331
- else if ('pin' in message) {
332
- m.pinInChatMessage = {};
333
- m.messageContextInfo = {};
334
- m.pinInChatMessage.key = message.pin;
335
- m.pinInChatMessage.type = 1;
336
- m.pinInChatMessage.senderTimestampMs = Date.now();
337
- m.messageContextInfo.messageAddOnDurationInSecs = message.time || 86400;
338
- }
339
- else if ('unpin' in message) {
340
- m.pinInChatMessage = {};
341
- m.messageContextInfo = {};
342
- m.pinInChatMessage.key = message.unpin;
343
- m.pinInChatMessage.type = 2;
344
- m.pinInChatMessage.senderTimestampMs = Date.now();
345
- m.messageContextInfo.messageAddOnDurationInSecs = 0;
346
- }
347
- else if ('buttonReply' in message) {
348
- switch (message.type) {
349
- case 'template':
350
- m.templateButtonReplyMessage = {
351
- selectedDisplayText: message.buttonReply.displayText,
352
- selectedId: message.buttonReply.id,
353
- selectedIndex: message.buttonReply.index,
354
- };
355
- break;
356
- case 'plain':
357
- m.buttonsResponseMessage = {
358
- selectedButtonId: message.buttonReply.id,
359
- selectedDisplayText: message.buttonReply.displayText,
360
- type: WAProto_1.proto.Message.ButtonsResponseMessage.Type.DISPLAY_TEXT,
361
- };
362
- break;
363
- }
364
- }
365
- else if ('ptv' in message && message.ptv) {
366
- const { videoMessage } = await (0, exports.prepareWAMessageMedia)({ video: message.video }, options);
367
- m.ptvMessage = videoMessage;
368
- }
369
- else if ('product' in message) {
370
- const { imageMessage } = await (0, exports.prepareWAMessageMedia)({ image: message.product.productImage }, options);
371
- m.productMessage = Types_1.WAProto.Message.ProductMessage.fromObject({
372
- ...message,
373
- product: {
374
- ...message.product,
375
- productImage: imageMessage,
376
- }
377
- });
378
- }
379
- else if ('listReply' in message) {
380
- m.listResponseMessage = { ...message.listReply };
381
- }
382
- else if ('poll' in message) {
383
- (_b = message.poll).selectableCount || (_b.selectableCount = 0);
384
- (_c = message.poll).toAnnouncementGroup || (_c.toAnnouncementGroup = false);
385
- if (!Array.isArray(message.poll.values)) {
386
- throw new boom_1.Boom('Invalid poll values', { statusCode: 400 });
387
- }
388
- if (message.poll.selectableCount < 0
389
- || message.poll.selectableCount > message.poll.values.length) {
390
- throw new boom_1.Boom(`poll.selectableCount in poll should be >= 0 and <= ${message.poll.values.length}`, { statusCode: 400 });
391
- }
392
- m.messageContextInfo = {
393
- // encKey
394
- messageSecret: message.poll.messageSecret || (0, crypto_1.randomBytes)(32),
395
- };
396
- const pollCreationMessage = {
397
- name: message.poll.name,
398
- selectableOptionsCount: message.poll.selectableCount,
399
- options: message.poll.values.map(optionName => ({ optionName })),
400
- };
401
- if (message.poll.toAnnouncementGroup) {
402
- // poll v2 is for community announcement groups (single select and multiple)
403
- m.pollCreationMessageV2 = pollCreationMessage;
404
- }
405
- else {
406
- if (message.poll.selectableCount > 0) {
407
- //poll v3 is for single select polls
408
- m.pollCreationMessageV3 = pollCreationMessage;
409
- }
410
- else {
411
- // poll v3 for multiple choice polls
412
- m.pollCreationMessage = pollCreationMessage;
413
- }
414
- }
415
- }
416
- else if ('sharePhoneNumber' in message) {
417
- m.protocolMessage = {
418
- type: WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER
419
- };
420
- }
421
- else if ('requestPhoneNumber' in message) {
422
- m.requestPhoneNumberMessage = {};
423
- }
424
- else {
425
- m = await (0, exports.prepareWAMessageMedia)(message, options);
426
- }
427
- if ('viewOnce' in message && !!message.viewOnce) {
428
- m = { viewOnceMessage: { message: m } };
429
- }
430
- if ('mentions' in message && ((_a = message.mentions) === null || _a === void 0 ? void 0 : _a.length)) {
431
- const [messageType] = Object.keys(m);
432
- m[messageType].contextInfo = m[messageType] || {};
433
- m[messageType].contextInfo.mentionedJid = message.mentions;
434
- }
435
- if ('edit' in message) {
436
- m = {
437
- protocolMessage: {
438
- key: message.edit,
439
- editedMessage: m,
440
- timestampMs: Date.now(),
441
- type: Types_1.WAProto.Message.ProtocolMessage.Type.MESSAGE_EDIT
442
- }
443
- };
444
- }
445
- if ('contextInfo' in message && !!message.contextInfo) {
446
- const [messageType] = Object.keys(m);
447
- m[messageType] = m[messageType] || {};
448
- m[messageType].contextInfo = message.contextInfo;
449
- }
450
- return Types_1.WAProto.Message.fromObject(m);
451
- };
452
- exports.generateWAMessageContent = generateWAMessageContent;
453
- const generateWAMessageFromContent = (jid, message, options) => {
454
- // set timestamp to now
455
- // if not specified
456
- if (!options.timestamp) {
457
- options.timestamp = new Date();
458
- }
459
- const innerMessage = (0, exports.normalizeMessageContent)(message);
460
- const key = (0, exports.getContentType)(innerMessage);
461
- const timestamp = (0, generics_1.unixTimestampSeconds)(options.timestamp);
462
- const { quoted, userJid } = options;
463
- // only set quoted if isn't a newsletter message
464
- if (quoted && !(0, WABinary_1.isJidNewsletter)(jid)) {
465
- const participant = quoted.key.fromMe ? userJid : (quoted.participant || quoted.key.participant || quoted.key.remoteJid);
466
- let quotedMsg = (0, exports.normalizeMessageContent)(quoted.message);
467
- const msgType = (0, exports.getContentType)(quotedMsg);
468
- // strip any redundant properties
469
- quotedMsg = WAProto_1.proto.Message.fromObject({ [msgType]: quotedMsg[msgType] });
470
- const quotedContent = quotedMsg[msgType];
471
- if (typeof quotedContent === 'object' && quotedContent && 'contextInfo' in quotedContent) {
472
- delete quotedContent.contextInfo;
473
- }
474
- const contextInfo = innerMessage[key].contextInfo || {};
475
- contextInfo.participant = (0, WABinary_1.jidNormalizedUser)(participant);
476
- contextInfo.stanzaId = quoted.key.id;
477
- contextInfo.quotedMessage = quotedMsg;
478
- // if a participant is quoted, then it must be a group
479
- // hence, remoteJid of group must also be entered
480
- if (jid !== quoted.key.remoteJid) {
481
- contextInfo.remoteJid = quoted.key.remoteJid;
482
- }
483
- innerMessage[key].contextInfo = contextInfo;
484
- }
485
- if (
486
- // if we want to send a disappearing message
487
- !!(options === null || options === void 0 ? void 0 : options.ephemeralExpiration) &&
488
- // and it's not a protocol message -- delete, toggle disappear message
489
- key !== 'protocolMessage' &&
490
- // already not converted to disappearing message
491
- key !== 'ephemeralMessage' &&
492
- // newsletter not accept disappearing messages
493
- !(0, WABinary_1.isJidNewsletter)(jid)) {
494
- innerMessage[key].contextInfo = {
495
- ...(innerMessage[key].contextInfo || {}),
496
- expiration: options.ephemeralExpiration || Defaults_1.WA_DEFAULT_EPHEMERAL,
497
- //ephemeralSettingTimestamp: options.ephemeralOptions.eph_setting_ts?.toString()
498
- };
499
- }
500
- message = Types_1.WAProto.Message.fromObject(message);
501
- const messageJSON = {
502
- key: {
503
- remoteJid: jid,
504
- fromMe: true,
505
- id: (options === null || options === void 0 ? void 0 : options.messageId) || (0, generics_1.generateMessageID)(),
506
- },
507
- message: message,
508
- messageTimestamp: timestamp,
509
- messageStubParameters: [],
510
- participant: (0, WABinary_1.isJidGroup)(jid) || (0, WABinary_1.isJidStatusBroadcast)(jid) ? userJid : undefined,
511
- status: Types_1.WAMessageStatus.PENDING
512
- };
513
- return Types_1.WAProto.WebMessageInfo.fromObject(messageJSON);
514
- };
515
- exports.generateWAMessageFromContent = generateWAMessageFromContent;
516
- const generateWAMessage = async (jid, content, options) => {
517
- var _a;
518
- // ensure msg ID is with every log
519
- options.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.child({ msgId: options.messageId });
520
- return (0, exports.generateWAMessageFromContent)(jid, await (0, exports.generateWAMessageContent)(content, { newsletter: (0, WABinary_1.isJidNewsletter)(jid), ...options }), options);
521
- };
522
- exports.generateWAMessage = generateWAMessage;
523
- /** Get the key to access the true type of content */
524
- const getContentType = (content) => {
525
- if (content) {
526
- const keys = Object.keys(content);
527
- const key = keys.find(k => (k === 'conversation' || k.includes('Message')) && k !== 'senderKeyDistributionMessage');
528
- return key;
529
- }
530
- };
531
- exports.getContentType = getContentType;
532
- /**
533
- * Normalizes ephemeral, view once messages to regular message content
534
- * Eg. image messages in ephemeral messages, in view once messages etc.
535
- * @param content
536
- * @returns
537
- */
538
- const normalizeMessageContent = (content) => {
539
- if (!content) {
540
- return undefined;
541
- }
542
- // set max iterations to prevent an infinite loop
543
- for (let i = 0; i < 5; i++) {
544
- const inner = getFutureProofMessage(content);
545
- if (!inner) {
546
- break;
547
- }
548
- content = inner.message;
549
- }
550
- return content;
551
- function getFutureProofMessage(message) {
552
- return ((message === null || message === void 0 ? void 0 : message.ephemeralMessage)
553
- || (message === null || message === void 0 ? void 0 : message.viewOnceMessage)
554
- || (message === null || message === void 0 ? void 0 : message.documentWithCaptionMessage)
555
- || (message === null || message === void 0 ? void 0 : message.viewOnceMessageV2)
556
- || (message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension)
557
- || (message === null || message === void 0 ? void 0 : message.editedMessage));
558
- }
559
- };
560
- exports.normalizeMessageContent = normalizeMessageContent;
561
- /**
562
- * Extract the true message content from a message
563
- * Eg. extracts the inner message from a disappearing message/view once message
564
- */
565
- const extractMessageContent = (content) => {
566
- var _a, _b, _c, _d, _e, _f;
567
- const extractFromTemplateMessage = (msg) => {
568
- if (msg.imageMessage) {
569
- return { imageMessage: msg.imageMessage };
570
- }
571
- else if (msg.documentMessage) {
572
- return { documentMessage: msg.documentMessage };
573
- }
574
- else if (msg.videoMessage) {
575
- return { videoMessage: msg.videoMessage };
576
- }
577
- else if (msg.locationMessage) {
578
- return { locationMessage: msg.locationMessage };
579
- }
580
- else {
581
- return {
582
- conversation: 'contentText' in msg
583
- ? msg.contentText
584
- : ('hydratedContentText' in msg ? msg.hydratedContentText : '')
585
- };
586
- }
587
- };
588
- content = (0, exports.normalizeMessageContent)(content);
589
- if (content === null || content === void 0 ? void 0 : content.buttonsMessage) {
590
- return extractFromTemplateMessage(content.buttonsMessage);
591
- }
592
- if ((_a = content === null || content === void 0 ? void 0 : content.templateMessage) === null || _a === void 0 ? void 0 : _a.hydratedFourRowTemplate) {
593
- return extractFromTemplateMessage((_b = content === null || content === void 0 ? void 0 : content.templateMessage) === null || _b === void 0 ? void 0 : _b.hydratedFourRowTemplate);
594
- }
595
- if ((_c = content === null || content === void 0 ? void 0 : content.templateMessage) === null || _c === void 0 ? void 0 : _c.hydratedTemplate) {
596
- return extractFromTemplateMessage((_d = content === null || content === void 0 ? void 0 : content.templateMessage) === null || _d === void 0 ? void 0 : _d.hydratedTemplate);
597
- }
598
- if ((_e = content === null || content === void 0 ? void 0 : content.templateMessage) === null || _e === void 0 ? void 0 : _e.fourRowTemplate) {
599
- return extractFromTemplateMessage((_f = content === null || content === void 0 ? void 0 : content.templateMessage) === null || _f === void 0 ? void 0 : _f.fourRowTemplate);
600
- }
601
- return content;
602
- };
603
- exports.extractMessageContent = extractMessageContent;
604
- /**
605
- * Returns the device predicted by message ID
606
- */
607
- const getDevice = (id) => /^3A.{18}$/.test(id) ? 'ios' : /^3E.{20}$/.test(id) ? 'web' : /^(.{21}|.{32})$/.test(id) ? 'android' : /^.{18}$/.test(id) ? 'desktop' : 'unknown';
608
- exports.getDevice = getDevice;
609
- /** Upserts a receipt in the message */
610
- const updateMessageWithReceipt = (msg, receipt) => {
611
- msg.userReceipt = msg.userReceipt || [];
612
- const recp = msg.userReceipt.find(m => m.userJid === receipt.userJid);
613
- if (recp) {
614
- Object.assign(recp, receipt);
615
- }
616
- else {
617
- msg.userReceipt.push(receipt);
618
- }
619
- };
620
- exports.updateMessageWithReceipt = updateMessageWithReceipt;
621
- /** Update the message with a new reaction */
622
- const updateMessageWithReaction = (msg, reaction) => {
623
- const authorID = (0, generics_1.getKeyAuthor)(reaction.key);
624
- const reactions = (msg.reactions || [])
625
- .filter(r => (0, generics_1.getKeyAuthor)(r.key) !== authorID);
626
- if (reaction.text) {
627
- reactions.push(reaction);
628
- }
629
- msg.reactions = reactions;
630
- };
631
- exports.updateMessageWithReaction = updateMessageWithReaction;
632
- /** Update the message with a new poll update */
633
- const updateMessageWithPollUpdate = (msg, update) => {
634
- var _a, _b;
635
- const authorID = (0, generics_1.getKeyAuthor)(update.pollUpdateMessageKey);
636
- const reactions = (msg.pollUpdates || [])
637
- .filter(r => (0, generics_1.getKeyAuthor)(r.pollUpdateMessageKey) !== authorID);
638
- if ((_b = (_a = update.vote) === null || _a === void 0 ? void 0 : _a.selectedOptions) === null || _b === void 0 ? void 0 : _b.length) {
639
- reactions.push(update);
640
- }
641
- msg.pollUpdates = reactions;
642
- };
643
- exports.updateMessageWithPollUpdate = updateMessageWithPollUpdate;
644
- /**
645
- * Aggregates all poll updates in a poll.
646
- * @param msg the poll creation message
647
- * @param meId your jid
648
- * @returns A list of options & their voters
649
- */
650
- function getAggregateVotesInPollMessage({ message, pollUpdates }, meId) {
651
- var _a, _b, _c;
652
- const opts = ((_a = message === null || message === void 0 ? void 0 : message.pollCreationMessage) === null || _a === void 0 ? void 0 : _a.options) || ((_b = message === null || message === void 0 ? void 0 : message.pollCreationMessageV2) === null || _b === void 0 ? void 0 : _b.options) || ((_c = message === null || message === void 0 ? void 0 : message.pollCreationMessageV3) === null || _c === void 0 ? void 0 : _c.options) || [];
653
- const voteHashMap = opts.reduce((acc, opt) => {
654
- const hash = (0, crypto_2.sha256)(Buffer.from(opt.optionName || '')).toString();
655
- acc[hash] = {
656
- name: opt.optionName || '',
657
- voters: []
658
- };
659
- return acc;
660
- }, {});
661
- for (const update of pollUpdates || []) {
662
- const { vote } = update;
663
- if (!vote) {
664
- continue;
665
- }
666
- for (const option of vote.selectedOptions || []) {
667
- const hash = option.toString();
668
- let data = voteHashMap[hash];
669
- if (!data) {
670
- voteHashMap[hash] = {
671
- name: 'Unknown',
672
- voters: []
673
- };
674
- data = voteHashMap[hash];
675
- }
676
- voteHashMap[hash].voters.push((0, generics_1.getKeyAuthor)(update.pollUpdateMessageKey, meId));
677
- }
678
- }
679
- return Object.values(voteHashMap);
680
- }
681
- exports.getAggregateVotesInPollMessage = getAggregateVotesInPollMessage;
682
- /** Given a list of message keys, aggregates them by chat & sender. Useful for sending read receipts in bulk */
683
- const aggregateMessageKeysNotFromMe = (keys) => {
684
- const keyMap = {};
685
- for (const { remoteJid, id, participant, fromMe } of keys) {
686
- if (!fromMe) {
687
- const uqKey = `${remoteJid}:${participant || ''}`;
688
- if (!keyMap[uqKey]) {
689
- keyMap[uqKey] = {
690
- jid: remoteJid,
691
- participant: participant,
692
- messageIds: []
693
- };
694
- }
695
- keyMap[uqKey].messageIds.push(id);
696
- }
697
- }
698
- return Object.values(keyMap);
699
- };
700
- exports.aggregateMessageKeysNotFromMe = aggregateMessageKeysNotFromMe;
701
- const REUPLOAD_REQUIRED_STATUS = [410, 404];
702
- /**
703
- * Downloads the given message. Throws an error if it's not a media message
704
- */
705
- const downloadMediaMessage = async (message, type, options, ctx) => {
706
- const result = await downloadMsg()
707
- .catch(async (error) => {
708
- var _a;
709
- if (ctx) {
710
- if (axios_1.default.isAxiosError(error)) {
711
- // check if the message requires a reupload
712
- if (REUPLOAD_REQUIRED_STATUS.includes((_a = error.response) === null || _a === void 0 ? void 0 : _a.status)) {
713
- ctx.logger.info({ key: message.key }, 'sending reupload media request...');
714
- // request reupload
715
- message = await ctx.reuploadRequest(message);
716
- const result = await downloadMsg();
717
- return result;
718
- }
719
- }
720
- }
721
- throw error;
722
- });
723
- return result;
724
- async function downloadMsg() {
725
- const mContent = (0, exports.extractMessageContent)(message.message);
726
- if (!mContent) {
727
- throw new boom_1.Boom('No message present', { statusCode: 400, data: message });
728
- }
729
- const contentType = (0, exports.getContentType)(mContent);
730
- let mediaType = contentType === null || contentType === void 0 ? void 0 : contentType.replace('Message', '');
731
- const media = mContent[contentType];
732
- if (!media || typeof media !== 'object' || (!('url' in media) && !('thumbnailDirectPath' in media))) {
733
- throw new boom_1.Boom(`"${contentType}" message is not a media message`);
734
- }
735
- let download;
736
- if ('thumbnailDirectPath' in media && !('url' in media)) {
737
- download = {
738
- directPath: media.thumbnailDirectPath,
739
- mediaKey: media.mediaKey
740
- };
741
- mediaType = 'thumbnail-link';
742
- }
743
- else {
744
- download = media;
745
- }
746
- const stream = await (0, messages_media_1.downloadContentFromMessage)(download, mediaType, options);
747
- if (type === 'buffer') {
748
- const bufferArray = [];
749
- for await (const chunk of stream) {
750
- bufferArray.push(chunk);
751
- }
752
- return Buffer.concat(bufferArray);
753
- }
754
- return stream;
755
- }
756
- };
757
- exports.downloadMediaMessage = downloadMediaMessage;
758
- /** Checks whether the given message is a media message; if it is returns the inner content */
759
- const assertMediaContent = (content) => {
760
- content = (0, exports.extractMessageContent)(content);
761
- const mediaContent = (content === null || content === void 0 ? void 0 : content.documentMessage)
762
- || (content === null || content === void 0 ? void 0 : content.imageMessage)
763
- || (content === null || content === void 0 ? void 0 : content.videoMessage)
764
- || (content === null || content === void 0 ? void 0 : content.audioMessage)
765
- || (content === null || content === void 0 ? void 0 : content.stickerMessage);
766
- if (!mediaContent) {
767
- throw new boom_1.Boom('given message is not a media message', { statusCode: 400, data: content });
768
- }
769
- return mediaContent;
770
- };
771
- exports.assertMediaContent = assertMediaContent;