@vinzsocket/baileys 2.8.30 → 2.8.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/lib/Defaults/index.js +38 -31
  2. package/lib/Signal/Group/ciphertext-message.js +9 -2
  3. package/lib/Signal/Group/group-session-builder.js +15 -7
  4. package/lib/Signal/Group/group_cipher.js +21 -13
  5. package/lib/Signal/Group/index.js +79 -12
  6. package/lib/Signal/Group/keyhelper.js +16 -6
  7. package/lib/Signal/Group/queue-job.js +9 -2
  8. package/lib/Signal/Group/sender-chain-key.js +14 -6
  9. package/lib/Signal/Group/sender-key-distribution-message.js +13 -6
  10. package/lib/Signal/Group/sender-key-message.js +17 -9
  11. package/lib/Signal/Group/sender-key-name.js +9 -2
  12. package/lib/Signal/Group/sender-key-record.js +16 -9
  13. package/lib/Signal/Group/sender-key-state.js +13 -6
  14. package/lib/Signal/Group/sender-message-key.js +12 -4
  15. package/lib/Signal/libsignal.js +35 -26
  16. package/lib/Signal/lid-mapping.js +27 -19
  17. package/lib/Socket/Client/index.js +27 -3
  18. package/lib/Socket/Client/types.js +11 -4
  19. package/lib/Socket/Client/websocket.js +19 -11
  20. package/lib/Socket/business.js +41 -34
  21. package/lib/Socket/chats.js +103 -95
  22. package/lib/Socket/communities.js +58 -49
  23. package/lib/Socket/groups.js +59 -51
  24. package/lib/Socket/index.js +11 -6
  25. package/lib/Socket/messages-recv.js +153 -145
  26. package/lib/Socket/messages-send.js +112 -104
  27. package/lib/Socket/mex.js +15 -8
  28. package/lib/Socket/newsletter.js +30 -23
  29. package/lib/Socket/socket.js +112 -105
  30. package/lib/Store/index.js +49 -4
  31. package/lib/Store/make-cache-manager-store.js +19 -11
  32. package/lib/Store/make-in-memory-store.js +38 -29
  33. package/lib/Store/make-ordered-dictionary.js +9 -2
  34. package/lib/Store/object-repository.js +9 -2
  35. package/lib/Types/Auth.js +5 -2
  36. package/lib/Types/Bussines.js +5 -2
  37. package/lib/Types/Call.js +5 -2
  38. package/lib/Types/Chat.js +7 -1
  39. package/lib/Types/Contact.js +5 -2
  40. package/lib/Types/Events.js +3 -2
  41. package/lib/Types/GroupMetadata.js +5 -2
  42. package/lib/Types/Label.js +8 -2
  43. package/lib/Types/LabelAssociation.js +8 -2
  44. package/lib/Types/Message.js +18 -6
  45. package/lib/Types/Newsletter.js +10 -4
  46. package/lib/Types/Product.js +5 -2
  47. package/lib/Types/Signal.js +3 -2
  48. package/lib/Types/Socket.js +4 -3
  49. package/lib/Types/State.js +9 -3
  50. package/lib/Types/USync.js +3 -2
  51. package/lib/Types/index.js +155 -14
  52. package/lib/Utils/auth-utils.js +35 -25
  53. package/lib/Utils/baileys-event-stream.js +24 -15
  54. package/lib/Utils/business.js +72 -59
  55. package/lib/Utils/chat-utils.js +94 -77
  56. package/lib/Utils/crypto.js +55 -30
  57. package/lib/Utils/decode-wa-message.js +47 -37
  58. package/lib/Utils/event-buffer.js +25 -17
  59. package/lib/Utils/extended-messages.js +16 -9
  60. package/lib/Utils/generics.js +101 -62
  61. package/lib/Utils/history.js +33 -23
  62. package/lib/Utils/index.js +236 -22
  63. package/lib/Utils/lid-resolver.js +14 -5
  64. package/lib/Utils/link-preview.js +14 -7
  65. package/lib/Utils/logger.js +10 -4
  66. package/lib/Utils/lt-hash.js +10 -4
  67. package/lib/Utils/make-mutex.js +11 -3
  68. package/lib/Utils/mention.js +14 -4
  69. package/lib/Utils/message-retry-manager.js +13 -6
  70. package/lib/Utils/messages-media.js +128 -93
  71. package/lib/Utils/messages.js +125 -98
  72. package/lib/Utils/noise-handler.js +28 -21
  73. package/lib/Utils/process-message.js +74 -63
  74. package/lib/Utils/signal.js +48 -33
  75. package/lib/Utils/use-multi-file-auth-state.js +27 -20
  76. package/lib/Utils/validate-connection.js +57 -47
  77. package/lib/WABinary/constants.js +10 -4
  78. package/lib/WABinary/decode.js +20 -10
  79. package/lib/WABinary/encode.js +12 -4
  80. package/lib/WABinary/generic-utils.js +32 -15
  81. package/lib/WABinary/index.js +60 -6
  82. package/lib/WABinary/jid-utils.js +39 -20
  83. package/lib/WABinary/types.js +4 -2
  84. package/lib/WAM/BinaryInfo.js +9 -2
  85. package/lib/WAM/constants.js +13001 -1
  86. package/lib/WAM/encode.js +17 -10
  87. package/lib/WAM/index.js +38 -4
  88. package/lib/WAUSync/Protocols/USyncContactProtocol.js +12 -5
  89. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +13 -6
  90. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +11 -4
  91. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +11 -4
  92. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +11 -4
  93. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +26 -19
  94. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +9 -2
  95. package/lib/WAUSync/Protocols/index.js +60 -6
  96. package/lib/WAUSync/USyncQuery.js +24 -17
  97. package/lib/WAUSync/USyncUser.js +9 -2
  98. package/lib/WAUSync/index.js +38 -4
  99. package/lib/index.js +114 -12
  100. package/package.json +3 -1
  101. package/lib/Defaults/index.d.ts +0 -58
  102. package/lib/Defaults/index.d.ts.map +0 -1
  103. package/lib/Defaults/index.js.map +0 -1
  104. package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
  105. package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
  106. package/lib/Signal/Group/ciphertext-message.js.map +0 -1
  107. package/lib/Signal/Group/group-session-builder.d.ts +0 -15
  108. package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
  109. package/lib/Signal/Group/group-session-builder.js.map +0 -1
  110. package/lib/Signal/Group/group_cipher.d.ts +0 -18
  111. package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
  112. package/lib/Signal/Group/group_cipher.js.map +0 -1
  113. package/lib/Signal/Group/index.d.ts +0 -12
  114. package/lib/Signal/Group/index.d.ts.map +0 -1
  115. package/lib/Signal/Group/index.js.map +0 -1
  116. package/lib/Signal/Group/keyhelper.d.ts +0 -11
  117. package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
  118. package/lib/Signal/Group/keyhelper.js.map +0 -1
  119. package/lib/Signal/Group/queue-job.d.ts +0 -2
  120. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  121. package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
  122. package/lib/Signal/Group/sender-chain-key.js.map +0 -1
  123. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  124. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
  125. package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
  126. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  127. package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
  128. package/lib/Signal/Group/sender-key-message.js.map +0 -1
  129. package/lib/Signal/Group/sender-key-name.d.ts +0 -18
  130. package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
  131. package/lib/Signal/Group/sender-key-name.js.map +0 -1
  132. package/lib/Signal/Group/sender-key-record.d.ts +0 -31
  133. package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
  134. package/lib/Signal/Group/sender-key-record.js.map +0 -1
  135. package/lib/Signal/Group/sender-key-state.d.ts +0 -39
  136. package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
  137. package/lib/Signal/Group/sender-key-state.js.map +0 -1
  138. package/lib/Signal/Group/sender-message-key.d.ts +0 -12
  139. package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
  140. package/lib/Signal/Group/sender-message-key.js.map +0 -1
  141. package/lib/Signal/libsignal.d.ts +0 -8
  142. package/lib/Signal/libsignal.d.ts.map +0 -1
  143. package/lib/Signal/libsignal.js.map +0 -1
  144. package/lib/Signal/lid-mapping.d.ts +0 -30
  145. package/lib/Signal/lid-mapping.d.ts.map +0 -1
  146. package/lib/Signal/lid-mapping.js.map +0 -1
  147. package/lib/Socket/Client/index.d.ts +0 -3
  148. package/lib/Socket/Client/index.d.ts.map +0 -1
  149. package/lib/Socket/Client/index.js.map +0 -1
  150. package/lib/Socket/Client/types.d.ts +0 -16
  151. package/lib/Socket/Client/types.d.ts.map +0 -1
  152. package/lib/Socket/Client/types.js.map +0 -1
  153. package/lib/Socket/Client/websocket.d.ts +0 -13
  154. package/lib/Socket/Client/websocket.d.ts.map +0 -1
  155. package/lib/Socket/Client/websocket.js.map +0 -1
  156. package/lib/Socket/business.d.ts +0 -188
  157. package/lib/Socket/business.d.ts.map +0 -1
  158. package/lib/Socket/business.js.map +0 -1
  159. package/lib/Socket/chats.d.ts +0 -98
  160. package/lib/Socket/chats.d.ts.map +0 -1
  161. package/lib/Socket/chats.js.map +0 -1
  162. package/lib/Socket/communities.d.ts +0 -233
  163. package/lib/Socket/communities.d.ts.map +0 -1
  164. package/lib/Socket/communities.js.map +0 -1
  165. package/lib/Socket/groups.d.ts +0 -137
  166. package/lib/Socket/groups.d.ts.map +0 -1
  167. package/lib/Socket/groups.js.map +0 -1
  168. package/lib/Socket/index.d.ts +0 -220
  169. package/lib/Socket/index.d.ts.map +0 -1
  170. package/lib/Socket/index.js.map +0 -1
  171. package/lib/Socket/messages-recv.d.ts +0 -173
  172. package/lib/Socket/messages-recv.d.ts.map +0 -1
  173. package/lib/Socket/messages-recv.js.map +0 -1
  174. package/lib/Socket/messages-send.d.ts +0 -169
  175. package/lib/Socket/messages-send.d.ts.map +0 -1
  176. package/lib/Socket/messages-send.js.map +0 -1
  177. package/lib/Socket/mex.d.ts +0 -3
  178. package/lib/Socket/mex.d.ts.map +0 -1
  179. package/lib/Socket/mex.js.map +0 -1
  180. package/lib/Socket/newsletter.d.ts +0 -147
  181. package/lib/Socket/newsletter.d.ts.map +0 -1
  182. package/lib/Socket/newsletter.js.map +0 -1
  183. package/lib/Socket/socket.d.ts +0 -50
  184. package/lib/Socket/socket.d.ts.map +0 -1
  185. package/lib/Socket/socket.js.map +0 -1
  186. package/lib/Store/index.d.ts +0 -4
  187. package/lib/Store/make-cache-manager-store.d.ts +0 -17
  188. package/lib/Store/make-in-memory-store.d.ts +0 -118
  189. package/lib/Store/make-ordered-dictionary.d.ts +0 -14
  190. package/lib/Store/object-repository.d.ts +0 -10
  191. package/lib/Types/Auth.d.ts +0 -105
  192. package/lib/Types/Auth.d.ts.map +0 -1
  193. package/lib/Types/Auth.js.map +0 -1
  194. package/lib/Types/Bussines.d.ts +0 -25
  195. package/lib/Types/Bussines.d.ts.map +0 -1
  196. package/lib/Types/Bussines.js.map +0 -1
  197. package/lib/Types/Call.d.ts +0 -14
  198. package/lib/Types/Call.d.ts.map +0 -1
  199. package/lib/Types/Call.js.map +0 -1
  200. package/lib/Types/Chat.d.ts +0 -123
  201. package/lib/Types/Chat.d.ts.map +0 -1
  202. package/lib/Types/Chat.js.map +0 -1
  203. package/lib/Types/Contact.d.ts +0 -24
  204. package/lib/Types/Contact.d.ts.map +0 -1
  205. package/lib/Types/Contact.js.map +0 -1
  206. package/lib/Types/Events.d.ts +0 -199
  207. package/lib/Types/Events.d.ts.map +0 -1
  208. package/lib/Types/Events.js.map +0 -1
  209. package/lib/Types/GroupMetadata.d.ts +0 -66
  210. package/lib/Types/GroupMetadata.d.ts.map +0 -1
  211. package/lib/Types/GroupMetadata.js.map +0 -1
  212. package/lib/Types/Label.d.ts +0 -47
  213. package/lib/Types/Label.d.ts.map +0 -1
  214. package/lib/Types/Label.js.map +0 -1
  215. package/lib/Types/LabelAssociation.d.ts +0 -30
  216. package/lib/Types/LabelAssociation.d.ts.map +0 -1
  217. package/lib/Types/LabelAssociation.js.map +0 -1
  218. package/lib/Types/Message.d.ts +0 -300
  219. package/lib/Types/Message.d.ts.map +0 -1
  220. package/lib/Types/Message.js.map +0 -1
  221. package/lib/Types/Newsletter.d.ts +0 -135
  222. package/lib/Types/Newsletter.d.ts.map +0 -1
  223. package/lib/Types/Newsletter.js.map +0 -1
  224. package/lib/Types/Product.d.ts +0 -79
  225. package/lib/Types/Product.d.ts.map +0 -1
  226. package/lib/Types/Product.js.map +0 -1
  227. package/lib/Types/Signal.d.ts +0 -82
  228. package/lib/Types/Signal.d.ts.map +0 -1
  229. package/lib/Types/Signal.js.map +0 -1
  230. package/lib/Types/Socket.d.ts +0 -130
  231. package/lib/Types/Socket.d.ts.map +0 -1
  232. package/lib/Types/Socket.js.map +0 -1
  233. package/lib/Types/State.d.ts +0 -39
  234. package/lib/Types/State.d.ts.map +0 -1
  235. package/lib/Types/State.js.map +0 -1
  236. package/lib/Types/USync.d.ts +0 -26
  237. package/lib/Types/USync.d.ts.map +0 -1
  238. package/lib/Types/USync.js.map +0 -1
  239. package/lib/Types/index.d.ts +0 -65
  240. package/lib/Types/index.d.ts.map +0 -1
  241. package/lib/Types/index.js.map +0 -1
  242. package/lib/Utils/auth-utils.d.ts +0 -19
  243. package/lib/Utils/auth-utils.d.ts.map +0 -1
  244. package/lib/Utils/auth-utils.js.map +0 -1
  245. package/lib/Utils/baileys-event-stream.d.ts +0 -17
  246. package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
  247. package/lib/Utils/baileys-event-stream.js.map +0 -1
  248. package/lib/Utils/business.d.ts +0 -23
  249. package/lib/Utils/business.d.ts.map +0 -1
  250. package/lib/Utils/business.js.map +0 -1
  251. package/lib/Utils/chat-utils.d.ts +0 -71
  252. package/lib/Utils/chat-utils.d.ts.map +0 -1
  253. package/lib/Utils/chat-utils.js.map +0 -1
  254. package/lib/Utils/crypto.d.ts +0 -41
  255. package/lib/Utils/crypto.d.ts.map +0 -1
  256. package/lib/Utils/crypto.js.map +0 -1
  257. package/lib/Utils/decode-wa-message.d.ts +0 -46
  258. package/lib/Utils/decode-wa-message.d.ts.map +0 -1
  259. package/lib/Utils/decode-wa-message.js.map +0 -1
  260. package/lib/Utils/event-buffer.d.ts +0 -34
  261. package/lib/Utils/event-buffer.d.ts.map +0 -1
  262. package/lib/Utils/event-buffer.js.map +0 -1
  263. package/lib/Utils/extended-messages.d.ts +0 -73
  264. package/lib/Utils/generics.d.ts +0 -92
  265. package/lib/Utils/generics.d.ts.map +0 -1
  266. package/lib/Utils/generics.js.map +0 -1
  267. package/lib/Utils/history.d.ts +0 -20
  268. package/lib/Utils/history.d.ts.map +0 -1
  269. package/lib/Utils/history.js.map +0 -1
  270. package/lib/Utils/index.d.ts +0 -22
  271. package/lib/Utils/index.d.ts.map +0 -1
  272. package/lib/Utils/index.js.map +0 -1
  273. package/lib/Utils/lid-resolver.d.ts +0 -17
  274. package/lib/Utils/link-preview.d.ts +0 -22
  275. package/lib/Utils/link-preview.d.ts.map +0 -1
  276. package/lib/Utils/link-preview.js.map +0 -1
  277. package/lib/Utils/logger.d.ts +0 -12
  278. package/lib/Utils/logger.d.ts.map +0 -1
  279. package/lib/Utils/logger.js.map +0 -1
  280. package/lib/Utils/lt-hash.d.ts +0 -13
  281. package/lib/Utils/lt-hash.d.ts.map +0 -1
  282. package/lib/Utils/lt-hash.js.map +0 -1
  283. package/lib/Utils/make-mutex.d.ts +0 -8
  284. package/lib/Utils/make-mutex.d.ts.map +0 -1
  285. package/lib/Utils/make-mutex.js.map +0 -1
  286. package/lib/Utils/mention.d.ts +0 -27
  287. package/lib/Utils/message-retry-manager.d.ts +0 -82
  288. package/lib/Utils/message-retry-manager.d.ts.map +0 -1
  289. package/lib/Utils/message-retry-manager.js.map +0 -1
  290. package/lib/Utils/messages-media.d.ts +0 -113
  291. package/lib/Utils/messages-media.d.ts.map +0 -1
  292. package/lib/Utils/messages-media.js.map +0 -1
  293. package/lib/Utils/messages.d.ts +0 -76
  294. package/lib/Utils/messages.d.ts.map +0 -1
  295. package/lib/Utils/messages.js.map +0 -1
  296. package/lib/Utils/noise-handler.d.ts +0 -20
  297. package/lib/Utils/noise-handler.d.ts.map +0 -1
  298. package/lib/Utils/noise-handler.js.map +0 -1
  299. package/lib/Utils/process-message.d.ts +0 -43
  300. package/lib/Utils/process-message.d.ts.map +0 -1
  301. package/lib/Utils/process-message.js.map +0 -1
  302. package/lib/Utils/signal.d.ts +0 -34
  303. package/lib/Utils/signal.d.ts.map +0 -1
  304. package/lib/Utils/signal.js.map +0 -1
  305. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  306. package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
  307. package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
  308. package/lib/Utils/validate-connection.d.ts +0 -11
  309. package/lib/Utils/validate-connection.d.ts.map +0 -1
  310. package/lib/Utils/validate-connection.js.map +0 -1
  311. package/lib/WABinary/constants.d.ts +0 -28
  312. package/lib/WABinary/constants.d.ts.map +0 -1
  313. package/lib/WABinary/constants.js.map +0 -1
  314. package/lib/WABinary/decode.d.ts +0 -7
  315. package/lib/WABinary/decode.d.ts.map +0 -1
  316. package/lib/WABinary/decode.js.map +0 -1
  317. package/lib/WABinary/encode.d.ts +0 -3
  318. package/lib/WABinary/encode.d.ts.map +0 -1
  319. package/lib/WABinary/encode.js.map +0 -1
  320. package/lib/WABinary/generic-utils.d.ts +0 -15
  321. package/lib/WABinary/generic-utils.d.ts.map +0 -1
  322. package/lib/WABinary/generic-utils.js.map +0 -1
  323. package/lib/WABinary/index.d.ts +0 -6
  324. package/lib/WABinary/index.d.ts.map +0 -1
  325. package/lib/WABinary/index.js.map +0 -1
  326. package/lib/WABinary/jid-utils.d.ts +0 -37
  327. package/lib/WABinary/jid-utils.d.ts.map +0 -1
  328. package/lib/WABinary/jid-utils.js.map +0 -1
  329. package/lib/WABinary/types.d.ts +0 -19
  330. package/lib/WABinary/types.d.ts.map +0 -1
  331. package/lib/WABinary/types.js.map +0 -1
  332. package/lib/WAM/BinaryInfo.d.ts +0 -9
  333. package/lib/WAM/BinaryInfo.d.ts.map +0 -1
  334. package/lib/WAM/BinaryInfo.js.map +0 -1
  335. package/lib/WAM/constants.d.ts +0 -40
  336. package/lib/WAM/constants.d.ts.map +0 -1
  337. package/lib/WAM/constants.js.map +0 -1
  338. package/lib/WAM/encode.d.ts +0 -3
  339. package/lib/WAM/encode.d.ts.map +0 -1
  340. package/lib/WAM/encode.js.map +0 -1
  341. package/lib/WAM/index.d.ts +0 -4
  342. package/lib/WAM/index.d.ts.map +0 -1
  343. package/lib/WAM/index.js.map +0 -1
  344. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  345. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
  346. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
  347. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -23
  348. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
  349. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
  350. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -13
  351. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
  352. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
  353. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -13
  354. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
  355. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
  356. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -8
  357. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
  358. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
  359. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
  360. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -9
  361. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
  362. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
  363. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  364. package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
  365. package/lib/WAUSync/Protocols/index.js.map +0 -1
  366. package/lib/WAUSync/USyncQuery.d.ts +0 -30
  367. package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
  368. package/lib/WAUSync/USyncQuery.js.map +0 -1
  369. package/lib/WAUSync/USyncUser.d.ts +0 -13
  370. package/lib/WAUSync/USyncUser.d.ts.map +0 -1
  371. package/lib/WAUSync/USyncUser.js.map +0 -1
  372. package/lib/WAUSync/index.d.ts +0 -4
  373. package/lib/WAUSync/index.d.ts.map +0 -1
  374. package/lib/WAUSync/index.js.map +0 -1
  375. package/lib/index.d.ts +0 -13
  376. package/lib/index.d.ts.map +0 -1
  377. package/lib/index.js.map +0 -1
@@ -1,19 +1,35 @@
1
- import { Boom } from '@hapi/boom';
2
- import axios from 'axios';
3
- import { exec } from 'child_process';
4
- import * as Crypto from 'crypto';
5
- import { once } from 'events';
6
- import { createReadStream, createWriteStream, promises as fs, WriteStream } from 'fs';
7
- import { tmpdir } from 'os';
8
- import { join } from 'path';
9
- import { Readable, Transform } from 'stream';
10
- import { URL } from 'url';
11
- import { proto } from '../../WAProto/index.js';
12
- import { DEFAULT_ORIGIN, MEDIA_HKDF_KEY_MAPPING, MEDIA_PATH_MAP } from '../Defaults/index.js';
13
- import { getBinaryNodeChild, getBinaryNodeChildBuffer, jidNormalizedUser } from '../WABinary/index.js';
14
- import { aesDecryptGCM, aesEncryptGCM, hkdf } from './crypto.js';
15
- import { generateMessageIDV2 } from './generics.js';
16
- const getTmpFilesDirectory = () => tmpdir();
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.encryptedStream = exports.encryptMediaRetryRequest = exports.encodeBase64EncodedStringForUpload = exports.downloadEncryptedContent = exports.downloadContentFromMessage = exports.decryptMediaRetryData = exports.decodeMediaRetryNode = void 0;
7
+ exports.extensionForMediaMessage = extensionForMediaMessage;
8
+ exports.generateProfilePicture = exports.extractImageThumb = void 0;
9
+ exports.generateThumbnail = generateThumbnail;
10
+ exports.getAudioDuration = getAudioDuration;
11
+ exports.getAudioWaveform = getAudioWaveform;
12
+ exports.getHttpStream = void 0;
13
+ exports.getMediaKeys = getMediaKeys;
14
+ exports.toReadable = exports.toBuffer = exports.mediaMessageSHA256B64 = exports.hkdfInfoKey = exports.getWAUploadToServer = exports.getUrlFromDirectPath = exports.getStream = exports.getStatusCodeForMediaRetry = exports.getRawMediaUploadData = void 0;
15
+ var _boom = require("@hapi/boom");
16
+ var _axios = _interopRequireDefault(require("axios"));
17
+ var _child_process = require("child_process");
18
+ var Crypto = _interopRequireWildcard(require("crypto"));
19
+ var _events = require("events");
20
+ var _fs = require("fs");
21
+ var _os = require("os");
22
+ var _path = require("path");
23
+ var _stream = require("stream");
24
+ var _url = require("url");
25
+ var _index = require("../../WAProto/index.js");
26
+ var _index2 = require("../Defaults/index.js");
27
+ var _index3 = require("../WABinary/index.js");
28
+ var _crypto2 = require("./crypto.js");
29
+ var _generics = require("./generics.js");
30
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
31
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
32
+ const getTmpFilesDirectory = () => (0, _os.tmpdir)();
17
33
  const getImageProcessingLibrary = async () => {
18
34
  //@ts-ignore
19
35
  const [jimp, sharp] = await Promise.all([import('jimp').catch(() => {}), import('sharp').catch(() => {})]);
@@ -27,31 +43,32 @@ const getImageProcessingLibrary = async () => {
27
43
  jimp
28
44
  };
29
45
  }
30
- throw new Boom('No image processing library available');
46
+ throw new _boom.Boom('No image processing library available');
31
47
  };
32
- export const hkdfInfoKey = type => {
33
- const hkdfInfo = MEDIA_HKDF_KEY_MAPPING[type];
48
+ const hkdfInfoKey = type => {
49
+ const hkdfInfo = _index2.MEDIA_HKDF_KEY_MAPPING[type];
34
50
  return `WhatsApp ${hkdfInfo} Keys`;
35
51
  };
36
- export const getRawMediaUploadData = async (media, mediaType, logger) => {
52
+ exports.hkdfInfoKey = hkdfInfoKey;
53
+ const getRawMediaUploadData = async (media, mediaType, logger) => {
37
54
  const {
38
55
  stream
39
56
  } = await getStream(media);
40
57
  logger?.debug('got stream for raw upload');
41
58
  const hasher = Crypto.createHash('sha256');
42
- const filePath = join(tmpdir(), mediaType + generateMessageIDV2());
43
- const fileWriteStream = createWriteStream(filePath);
59
+ const filePath = (0, _path.join)((0, _os.tmpdir)(), mediaType + (0, _generics.generateMessageIDV2)());
60
+ const fileWriteStream = (0, _fs.createWriteStream)(filePath);
44
61
  let fileLength = 0;
45
62
  try {
46
63
  for await (const data of stream) {
47
64
  fileLength += data.length;
48
65
  hasher.update(data);
49
66
  if (!fileWriteStream.write(data)) {
50
- await once(fileWriteStream, 'drain');
67
+ await (0, _events.once)(fileWriteStream, 'drain');
51
68
  }
52
69
  }
53
70
  fileWriteStream.end();
54
- await once(fileWriteStream, 'finish');
71
+ await (0, _events.once)(fileWriteStream, 'finish');
55
72
  stream.destroy();
56
73
  const fileSha256 = hasher.digest();
57
74
  logger?.debug('hashed data for raw upload');
@@ -64,7 +81,7 @@ export const getRawMediaUploadData = async (media, mediaType, logger) => {
64
81
  fileWriteStream.destroy();
65
82
  stream.destroy();
66
83
  try {
67
- await fs.unlink(filePath);
84
+ await _fs.promises.unlink(filePath);
68
85
  } catch {
69
86
  //
70
87
  }
@@ -72,15 +89,16 @@ export const getRawMediaUploadData = async (media, mediaType, logger) => {
72
89
  }
73
90
  };
74
91
  /** generates all the keys required to encrypt/decrypt & sign a media message */
75
- export async function getMediaKeys(buffer, mediaType) {
92
+ exports.getRawMediaUploadData = getRawMediaUploadData;
93
+ async function getMediaKeys(buffer, mediaType) {
76
94
  if (!buffer) {
77
- throw new Boom('Cannot derive from empty media key');
95
+ throw new _boom.Boom('Cannot derive from empty media key');
78
96
  }
79
97
  if (typeof buffer === 'string') {
80
98
  buffer = Buffer.from(buffer.replace('data:;base64,', ''), 'base64');
81
99
  }
82
100
  // expand using HKDF to 112 bytes, also pass in the relevant app info
83
- const expandedMediaKey = await hkdf(buffer, 112, {
101
+ const expandedMediaKey = await (0, _crypto2.hkdf)(buffer, 112, {
84
102
  info: hkdfInfoKey(mediaType)
85
103
  });
86
104
  return {
@@ -92,7 +110,7 @@ export async function getMediaKeys(buffer, mediaType) {
92
110
  /** Extracts video thumb using FFMPEG */
93
111
  const extractVideoThumb = async (path, destPath, time, size) => new Promise((resolve, reject) => {
94
112
  const cmd = `ffmpeg -ss ${time} -i ${path} -y -vf scale=${size.width}:-1 -vframes 1 -f image2 ${destPath}`;
95
- exec(cmd, err => {
113
+ (0, _child_process.exec)(cmd, err => {
96
114
  if (err) {
97
115
  reject(err);
98
116
  } else {
@@ -100,10 +118,10 @@ const extractVideoThumb = async (path, destPath, time, size) => new Promise((res
100
118
  }
101
119
  });
102
120
  });
103
- export const extractImageThumb = async (bufferOrFilePath, width = 32) => {
121
+ const extractImageThumb = async (bufferOrFilePath, width = 32) => {
104
122
  // TODO: Move entirely to sharp, removing jimp as it supports readable streams
105
123
  // This will have positive speed and performance impacts as well as minimizing RAM usage.
106
- if (bufferOrFilePath instanceof Readable) {
124
+ if (bufferOrFilePath instanceof _stream.Readable) {
107
125
  bufferOrFilePath = await toBuffer(bufferOrFilePath);
108
126
  }
109
127
  const lib = await getImageProcessingLibrary();
@@ -137,11 +155,13 @@ export const extractImageThumb = async (bufferOrFilePath, width = 32) => {
137
155
  original: dimensions
138
156
  };
139
157
  } else {
140
- throw new Boom('No image processing library available');
158
+ throw new _boom.Boom('No image processing library available');
141
159
  }
142
160
  };
143
- export const encodeBase64EncodedStringForUpload = b64 => encodeURIComponent(b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, ''));
144
- export const generateProfilePicture = async (mediaUpload, dimensions) => {
161
+ exports.extractImageThumb = extractImageThumb;
162
+ const encodeBase64EncodedStringForUpload = b64 => encodeURIComponent(b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, ''));
163
+ exports.encodeBase64EncodedStringForUpload = encodeBase64EncodedStringForUpload;
164
+ const generateProfilePicture = async (mediaUpload, dimensions) => {
145
165
  let buffer;
146
166
  const {
147
167
  width: w = 640,
@@ -180,18 +200,20 @@ export const generateProfilePicture = async (mediaUpload, dimensions) => {
180
200
  quality: 50
181
201
  });
182
202
  } else {
183
- throw new Boom('No image processing library available');
203
+ throw new _boom.Boom('No image processing library available');
184
204
  }
185
205
  return {
186
206
  img: await img
187
207
  };
188
208
  };
189
209
  /** gets the SHA256 of the given media message */
190
- export const mediaMessageSHA256B64 = message => {
210
+ exports.generateProfilePicture = generateProfilePicture;
211
+ const mediaMessageSHA256B64 = message => {
191
212
  const media = Object.values(message)[0];
192
213
  return media?.fileSha256 && Buffer.from(media.fileSha256).toString('base64');
193
214
  };
194
- export async function getAudioDuration(buffer) {
215
+ exports.mediaMessageSHA256B64 = mediaMessageSHA256B64;
216
+ async function getAudioDuration(buffer) {
195
217
  const musicMetadata = await import('music-metadata');
196
218
  let metadata;
197
219
  const options = {
@@ -209,7 +231,7 @@ export async function getAudioDuration(buffer) {
209
231
  /**
210
232
  referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
211
233
  */
212
- export async function getAudioWaveform(buffer, logger) {
234
+ async function getAudioWaveform(buffer, logger) {
213
235
  try {
214
236
  // @ts-ignore
215
237
  const {
@@ -219,7 +241,7 @@ export async function getAudioWaveform(buffer, logger) {
219
241
  if (Buffer.isBuffer(buffer)) {
220
242
  audioData = buffer;
221
243
  } else if (typeof buffer === 'string') {
222
- const rStream = createReadStream(buffer);
244
+ const rStream = (0, _fs.createReadStream)(buffer);
223
245
  audioData = await toBuffer(rStream);
224
246
  } else {
225
247
  audioData = await toBuffer(buffer);
@@ -247,15 +269,16 @@ export async function getAudioWaveform(buffer, logger) {
247
269
  logger?.debug('Failed to generate waveform: ' + e);
248
270
  }
249
271
  }
250
- export const toReadable = buffer => {
251
- const readable = new Readable({
272
+ const toReadable = buffer => {
273
+ const readable = new _stream.Readable({
252
274
  read: () => {}
253
275
  });
254
276
  readable.push(buffer);
255
277
  readable.push(null);
256
278
  return readable;
257
279
  };
258
- export const toBuffer = async stream => {
280
+ exports.toReadable = toReadable;
281
+ const toBuffer = async stream => {
259
282
  const chunks = [];
260
283
  for await (const chunk of stream) {
261
284
  chunks.push(chunk);
@@ -263,7 +286,8 @@ export const toBuffer = async stream => {
263
286
  stream.destroy();
264
287
  return Buffer.concat(chunks);
265
288
  };
266
- export const getStream = async (item, opts) => {
289
+ exports.toBuffer = toBuffer;
290
+ const getStream = async (item, opts) => {
267
291
  if (Buffer.isBuffer(item)) {
268
292
  return {
269
293
  stream: toReadable(item),
@@ -291,12 +315,13 @@ export const getStream = async (item, opts) => {
291
315
  };
292
316
  }
293
317
  return {
294
- stream: createReadStream(item.url),
318
+ stream: (0, _fs.createReadStream)(item.url),
295
319
  type: 'file'
296
320
  };
297
321
  };
298
322
  /** generates a thumbnail for a given media, if required */
299
- export async function generateThumbnail(file, mediaType, options) {
323
+ exports.getStream = getStream;
324
+ async function generateThumbnail(file, mediaType, options) {
300
325
  let thumbnail;
301
326
  let originalImageDimensions;
302
327
  if (mediaType === 'image') {
@@ -312,15 +337,15 @@ export async function generateThumbnail(file, mediaType, options) {
312
337
  };
313
338
  }
314
339
  } else if (mediaType === 'video') {
315
- const imgFilename = join(getTmpFilesDirectory(), generateMessageIDV2() + '.jpg');
340
+ const imgFilename = (0, _path.join)(getTmpFilesDirectory(), (0, _generics.generateMessageIDV2)() + '.jpg');
316
341
  try {
317
342
  await extractVideoThumb(file, imgFilename, '00:00:00', {
318
343
  width: 32,
319
344
  height: 32
320
345
  });
321
- const buff = await fs.readFile(imgFilename);
346
+ const buff = await _fs.promises.readFile(imgFilename);
322
347
  thumbnail = buff.toString('base64');
323
- await fs.unlink(imgFilename);
348
+ await _fs.promises.unlink(imgFilename);
324
349
  } catch (err) {
325
350
  options.logger?.debug('could not generate video thumb: ' + err);
326
351
  }
@@ -330,14 +355,15 @@ export async function generateThumbnail(file, mediaType, options) {
330
355
  originalImageDimensions
331
356
  };
332
357
  }
333
- export const getHttpStream = async (url, options = {}) => {
334
- const fetched = await axios.get(url.toString(), {
358
+ const getHttpStream = async (url, options = {}) => {
359
+ const fetched = await _axios.default.get(url.toString(), {
335
360
  ...options,
336
361
  responseType: 'stream'
337
362
  });
338
363
  return fetched.data;
339
364
  };
340
- export const encryptedStream = async (media, mediaType, {
365
+ exports.getHttpStream = getHttpStream;
366
+ const encryptedStream = async (media, mediaType, {
341
367
  logger,
342
368
  saveOriginalFileIfRequired,
343
369
  opts
@@ -353,13 +379,13 @@ export const encryptedStream = async (media, mediaType, {
353
379
  iv,
354
380
  macKey
355
381
  } = await getMediaKeys(mediaKey, mediaType);
356
- const encFilePath = join(getTmpFilesDirectory(), mediaType + generateMessageIDV2() + '-enc');
357
- const encFileWriteStream = createWriteStream(encFilePath);
382
+ const encFilePath = (0, _path.join)(getTmpFilesDirectory(), mediaType + (0, _generics.generateMessageIDV2)() + '-enc');
383
+ const encFileWriteStream = (0, _fs.createWriteStream)(encFilePath);
358
384
  let originalFileStream;
359
385
  let originalFilePath;
360
386
  if (saveOriginalFileIfRequired) {
361
- originalFilePath = join(getTmpFilesDirectory(), mediaType + generateMessageIDV2() + '-original');
362
- originalFileStream = createWriteStream(originalFilePath);
387
+ originalFilePath = (0, _path.join)(getTmpFilesDirectory(), mediaType + (0, _generics.generateMessageIDV2)() + '-original');
388
+ originalFileStream = (0, _fs.createWriteStream)(originalFilePath);
363
389
  }
364
390
  let fileLength = 0;
365
391
  const aes = Crypto.createCipheriv('aes-256-cbc', cipherKey, iv);
@@ -375,7 +401,7 @@ export const encryptedStream = async (media, mediaType, {
375
401
  for await (const data of stream) {
376
402
  fileLength += data.length;
377
403
  if (type === 'remote' && opts?.maxContentLength && fileLength + data.length > opts.maxContentLength) {
378
- throw new Boom(`content length exceeded when encrypting "${type}"`, {
404
+ throw new _boom.Boom(`content length exceeded when encrypting "${type}"`, {
379
405
  data: {
380
406
  media,
381
407
  type
@@ -384,7 +410,7 @@ export const encryptedStream = async (media, mediaType, {
384
410
  }
385
411
  if (originalFileStream) {
386
412
  if (!originalFileStream.write(data)) {
387
- await once(originalFileStream, 'drain');
413
+ await (0, _events.once)(originalFileStream, 'drain');
388
414
  }
389
415
  }
390
416
  sha256Plain.update(data);
@@ -419,9 +445,9 @@ export const encryptedStream = async (media, mediaType, {
419
445
  sha256Enc.destroy();
420
446
  stream.destroy();
421
447
  try {
422
- await fs.unlink(encFilePath);
448
+ await _fs.promises.unlink(encFilePath);
423
449
  if (originalFilePath) {
424
- await fs.unlink(originalFilePath);
450
+ await _fs.promises.unlink(originalFilePath);
425
451
  }
426
452
  } catch (err) {
427
453
  logger?.error({
@@ -431,13 +457,15 @@ export const encryptedStream = async (media, mediaType, {
431
457
  throw error;
432
458
  }
433
459
  };
460
+ exports.encryptedStream = encryptedStream;
434
461
  const DEF_HOST = 'mmg.whatsapp.net';
435
462
  const AES_CHUNK_SIZE = 16;
436
463
  const toSmallestChunkSize = num => {
437
464
  return Math.floor(num / AES_CHUNK_SIZE) * AES_CHUNK_SIZE;
438
465
  };
439
- export const getUrlFromDirectPath = directPath => `https://${DEF_HOST}${directPath}`;
440
- export const downloadContentFromMessage = async ({
466
+ const getUrlFromDirectPath = directPath => `https://${DEF_HOST}${directPath}`;
467
+ exports.getUrlFromDirectPath = getUrlFromDirectPath;
468
+ const downloadContentFromMessage = async ({
441
469
  mediaKey,
442
470
  directPath,
443
471
  url
@@ -445,7 +473,7 @@ export const downloadContentFromMessage = async ({
445
473
  const isValidMediaUrl = url?.startsWith('https://mmg.whatsapp.net/');
446
474
  const downloadUrl = isValidMediaUrl ? url : getUrlFromDirectPath(directPath);
447
475
  if (!downloadUrl) {
448
- throw new Boom('No valid media URL or directPath present in message', {
476
+ throw new _boom.Boom('No valid media URL or directPath present in message', {
449
477
  statusCode: 400
450
478
  });
451
479
  }
@@ -456,7 +484,8 @@ export const downloadContentFromMessage = async ({
456
484
  * Decrypts and downloads an AES256-CBC encrypted file given the keys.
457
485
  * Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
458
486
  * */
459
- export const downloadEncryptedContent = async (downloadUrl, {
487
+ exports.downloadContentFromMessage = downloadContentFromMessage;
488
+ const downloadEncryptedContent = async (downloadUrl, {
460
489
  cipherKey,
461
490
  iv
462
491
  }, {
@@ -479,7 +508,7 @@ export const downloadEncryptedContent = async (downloadUrl, {
479
508
  const endChunk = endByte ? toSmallestChunkSize(endByte || 0) + AES_CHUNK_SIZE : undefined;
480
509
  const headers = {
481
510
  ...(options?.headers || {}),
482
- Origin: DEFAULT_ORIGIN
511
+ Origin: _index2.DEFAULT_ORIGIN
483
512
  };
484
513
  if (startChunk || endChunk) {
485
514
  headers.Range = `bytes=${startChunk}-`;
@@ -506,7 +535,7 @@ export const downloadEncryptedContent = async (downloadUrl, {
506
535
  push(bytes);
507
536
  }
508
537
  };
509
- const output = new Transform({
538
+ const output = new _stream.Transform({
510
539
  transform(chunk, _, callback) {
511
540
  let data = Buffer.concat([remainingBytes, chunk]);
512
541
  const decryptLength = toSmallestChunkSize(data.length);
@@ -545,7 +574,8 @@ export const downloadEncryptedContent = async (downloadUrl, {
545
574
  end: true
546
575
  });
547
576
  };
548
- export function extensionForMediaMessage(message) {
577
+ exports.downloadEncryptedContent = downloadEncryptedContent;
578
+ function extensionForMediaMessage(message) {
549
579
  const getExtension = mimetype => mimetype.split(';')[0]?.split('/')[1];
550
580
  const type = Object.keys(message)[0];
551
581
  let extension;
@@ -557,7 +587,7 @@ export function extensionForMediaMessage(message) {
557
587
  }
558
588
  return extension;
559
589
  }
560
- export const getWAUploadToServer = ({
590
+ const getWAUploadToServer = ({
561
591
  customUploadHosts,
562
592
  fetchAgent,
563
593
  logger,
@@ -578,17 +608,17 @@ export const getWAUploadToServer = ({
578
608
  } of hosts) {
579
609
  logger.debug(`uploading to "${hostname}"`);
580
610
  const auth = encodeURIComponent(uploadInfo.auth); // the auth token
581
- const url = `https://${hostname}${MEDIA_PATH_MAP[mediaType]}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
611
+ const url = `https://${hostname}${_index2.MEDIA_PATH_MAP[mediaType]}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
582
612
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
583
613
  let result;
584
614
  try {
585
- const body = await axios.post(url, createReadStream(filePath), {
615
+ const body = await _axios.default.post(url, (0, _fs.createReadStream)(filePath), {
586
616
  ...options,
587
617
  maxRedirects: 0,
588
618
  headers: {
589
619
  ...(options.headers || {}),
590
620
  'Content-Type': 'application/octet-stream',
591
- Origin: DEFAULT_ORIGIN
621
+ Origin: _index2.DEFAULT_ORIGIN
592
622
  },
593
623
  httpsAgent: fetchAgent,
594
624
  timeout: timeoutMs,
@@ -611,7 +641,7 @@ export const getWAUploadToServer = ({
611
641
  throw new Error(`upload failed, reason: ${JSON.stringify(result)}`);
612
642
  }
613
643
  } catch (error) {
614
- if (axios.isAxiosError(error)) {
644
+ if (_axios.default.isAxiosError(error)) {
615
645
  result = error.response?.data;
616
646
  }
617
647
  const isLast = hostname === hosts[uploadInfo.hosts.length - 1]?.hostname;
@@ -622,34 +652,35 @@ export const getWAUploadToServer = ({
622
652
  }
623
653
  }
624
654
  if (!urls) {
625
- throw new Boom('Media upload failed on all hosts', {
655
+ throw new _boom.Boom('Media upload failed on all hosts', {
626
656
  statusCode: 500
627
657
  });
628
658
  }
629
659
  return urls;
630
660
  };
631
661
  };
662
+ exports.getWAUploadToServer = getWAUploadToServer;
632
663
  const getMediaRetryKey = mediaKey => {
633
- return hkdf(mediaKey, 32, {
664
+ return (0, _crypto2.hkdf)(mediaKey, 32, {
634
665
  info: 'WhatsApp Media Retry Notification'
635
666
  });
636
667
  };
637
668
  /**
638
669
  * Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
639
670
  */
640
- export const encryptMediaRetryRequest = async (key, mediaKey, meId) => {
671
+ const encryptMediaRetryRequest = async (key, mediaKey, meId) => {
641
672
  const recp = {
642
673
  stanzaId: key.id
643
674
  };
644
- const recpBuffer = proto.ServerErrorReceipt.encode(recp).finish();
675
+ const recpBuffer = _index.proto.ServerErrorReceipt.encode(recp).finish();
645
676
  const iv = Crypto.randomBytes(12);
646
677
  const retryKey = await getMediaRetryKey(mediaKey);
647
- const ciphertext = aesEncryptGCM(recpBuffer, retryKey, iv, Buffer.from(key.id));
678
+ const ciphertext = (0, _crypto2.aesEncryptGCM)(recpBuffer, retryKey, iv, Buffer.from(key.id));
648
679
  const req = {
649
680
  tag: 'receipt',
650
681
  attrs: {
651
682
  id: key.id,
652
- to: jidNormalizedUser(meId),
683
+ to: (0, _index3.jidNormalizedUser)(meId),
653
684
  type: 'server-error'
654
685
  },
655
686
  content: [
@@ -680,8 +711,9 @@ export const encryptMediaRetryRequest = async (key, mediaKey, meId) => {
680
711
  };
681
712
  return req;
682
713
  };
683
- export const decodeMediaRetryNode = node => {
684
- const rmrNode = getBinaryNodeChild(node, 'rmr');
714
+ exports.encryptMediaRetryRequest = encryptMediaRetryRequest;
715
+ const decodeMediaRetryNode = node => {
716
+ const rmrNode = (0, _index3.getBinaryNodeChild)(node, 'rmr');
685
717
  const event = {
686
718
  key: {
687
719
  id: node.attrs.id,
@@ -690,43 +722,46 @@ export const decodeMediaRetryNode = node => {
690
722
  participant: rmrNode.attrs.participant
691
723
  }
692
724
  };
693
- const errorNode = getBinaryNodeChild(node, 'error');
725
+ const errorNode = (0, _index3.getBinaryNodeChild)(node, 'error');
694
726
  if (errorNode) {
695
727
  const errorCode = +errorNode.attrs.code;
696
- event.error = new Boom(`Failed to re-upload media (${errorCode})`, {
728
+ event.error = new _boom.Boom(`Failed to re-upload media (${errorCode})`, {
697
729
  data: errorNode.attrs,
698
730
  statusCode: getStatusCodeForMediaRetry(errorCode)
699
731
  });
700
732
  } else {
701
- const encryptedInfoNode = getBinaryNodeChild(node, 'encrypt');
702
- const ciphertext = getBinaryNodeChildBuffer(encryptedInfoNode, 'enc_p');
703
- const iv = getBinaryNodeChildBuffer(encryptedInfoNode, 'enc_iv');
733
+ const encryptedInfoNode = (0, _index3.getBinaryNodeChild)(node, 'encrypt');
734
+ const ciphertext = (0, _index3.getBinaryNodeChildBuffer)(encryptedInfoNode, 'enc_p');
735
+ const iv = (0, _index3.getBinaryNodeChildBuffer)(encryptedInfoNode, 'enc_iv');
704
736
  if (ciphertext && iv) {
705
737
  event.media = {
706
738
  ciphertext,
707
739
  iv
708
740
  };
709
741
  } else {
710
- event.error = new Boom('Failed to re-upload media (missing ciphertext)', {
742
+ event.error = new _boom.Boom('Failed to re-upload media (missing ciphertext)', {
711
743
  statusCode: 404
712
744
  });
713
745
  }
714
746
  }
715
747
  return event;
716
748
  };
717
- export const decryptMediaRetryData = async ({
749
+ exports.decodeMediaRetryNode = decodeMediaRetryNode;
750
+ const decryptMediaRetryData = async ({
718
751
  ciphertext,
719
752
  iv
720
753
  }, mediaKey, msgId) => {
721
754
  const retryKey = await getMediaRetryKey(mediaKey);
722
- const plaintext = aesDecryptGCM(ciphertext, retryKey, iv, Buffer.from(msgId));
723
- return proto.MediaRetryNotification.decode(plaintext);
755
+ const plaintext = (0, _crypto2.aesDecryptGCM)(ciphertext, retryKey, iv, Buffer.from(msgId));
756
+ return _index.proto.MediaRetryNotification.decode(plaintext);
724
757
  };
725
- export const getStatusCodeForMediaRetry = code => MEDIA_RETRY_STATUS_MAP[code];
758
+ exports.decryptMediaRetryData = decryptMediaRetryData;
759
+ const getStatusCodeForMediaRetry = code => MEDIA_RETRY_STATUS_MAP[code];
760
+ exports.getStatusCodeForMediaRetry = getStatusCodeForMediaRetry;
726
761
  const MEDIA_RETRY_STATUS_MAP = {
727
- [proto.MediaRetryNotification.ResultType.SUCCESS]: 200,
728
- [proto.MediaRetryNotification.ResultType.DECRYPTION_ERROR]: 412,
729
- [proto.MediaRetryNotification.ResultType.NOT_FOUND]: 404,
730
- [proto.MediaRetryNotification.ResultType.GENERAL_ERROR]: 418
762
+ [_index.proto.MediaRetryNotification.ResultType.SUCCESS]: 200,
763
+ [_index.proto.MediaRetryNotification.ResultType.DECRYPTION_ERROR]: 412,
764
+ [_index.proto.MediaRetryNotification.ResultType.NOT_FOUND]: 404,
765
+ [_index.proto.MediaRetryNotification.ResultType.GENERAL_ERROR]: 418
731
766
  };
732
767
  //# sourceMappingURL=messages-media.js.map