@itsliaaa/baileys 0.2.5 → 0.3.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/README.md +2 -1
  2. package/WAProto/index.d.ts +15686 -0
  3. package/WAProto/index.js +12992 -3569
  4. package/lib/Defaults/index.d.ts +144 -0
  5. package/lib/Defaults/index.d.ts.map +1 -0
  6. package/lib/Defaults/index.js +11 -10
  7. package/lib/Defaults/index.js.map +1 -0
  8. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  9. package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
  10. package/lib/Signal/Group/ciphertext-message.js +2 -1
  11. package/lib/Signal/Group/ciphertext-message.js.map +1 -0
  12. package/lib/Signal/Group/group-session-builder.d.ts +8 -0
  13. package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
  14. package/lib/Signal/Group/group-session-builder.js +2 -1
  15. package/lib/Signal/Group/group-session-builder.js.map +1 -0
  16. package/lib/Signal/Group/group_cipher.d.ts +11 -0
  17. package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
  18. package/lib/Signal/Group/group_cipher.js +2 -1
  19. package/lib/Signal/Group/group_cipher.js.map +1 -0
  20. package/lib/Signal/Group/index.d.ts +12 -0
  21. package/lib/Signal/Group/index.d.ts.map +1 -0
  22. package/lib/Signal/Group/index.js +2 -1
  23. package/lib/Signal/Group/index.js.map +1 -0
  24. package/lib/Signal/Group/keyhelper.d.ts +7 -0
  25. package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
  26. package/lib/Signal/Group/keyhelper.js +2 -1
  27. package/lib/Signal/Group/keyhelper.js.map +1 -0
  28. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  29. package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
  30. package/lib/Signal/Group/sender-chain-key.js +2 -1
  31. package/lib/Signal/Group/sender-chain-key.js.map +1 -0
  32. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  33. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
  34. package/lib/Signal/Group/sender-key-distribution-message.js +2 -1
  35. package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
  36. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  37. package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
  38. package/lib/Signal/Group/sender-key-message.js +2 -1
  39. package/lib/Signal/Group/sender-key-message.js.map +1 -0
  40. package/lib/Signal/Group/sender-key-name.d.ts +12 -0
  41. package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
  42. package/lib/Signal/Group/sender-key-name.js +2 -1
  43. package/lib/Signal/Group/sender-key-name.js.map +1 -0
  44. package/lib/Signal/Group/sender-key-record.d.ts +13 -0
  45. package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
  46. package/lib/Signal/Group/sender-key-record.js +2 -1
  47. package/lib/Signal/Group/sender-key-record.js.map +1 -0
  48. package/lib/Signal/Group/sender-key-state.d.ts +17 -0
  49. package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
  50. package/lib/Signal/Group/sender-key-state.js +2 -1
  51. package/lib/Signal/Group/sender-key-state.js.map +1 -0
  52. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  53. package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
  54. package/lib/Signal/Group/sender-message-key.js +2 -1
  55. package/lib/Signal/Group/sender-message-key.js.map +1 -0
  56. package/lib/Signal/libsignal.d.ts +42 -0
  57. package/lib/Signal/libsignal.d.ts.map +1 -0
  58. package/lib/Signal/libsignal.js +2 -5
  59. package/lib/Signal/libsignal.js.map +1 -0
  60. package/lib/Signal/lid-mapping.d.ts +17 -0
  61. package/lib/Signal/lid-mapping.d.ts.map +1 -0
  62. package/lib/Signal/lid-mapping.js +2 -7
  63. package/lib/Signal/lid-mapping.js.map +1 -0
  64. package/lib/Socket/Client/index.d.ts +3 -0
  65. package/lib/Socket/Client/index.d.ts.map +1 -0
  66. package/lib/Socket/Client/index.js +2 -1
  67. package/lib/Socket/Client/index.js.map +1 -0
  68. package/lib/Socket/Client/types.d.ts +6 -0
  69. package/lib/Socket/Client/types.d.ts.map +1 -0
  70. package/lib/Socket/Client/types.js +2 -1
  71. package/lib/Socket/Client/types.js.map +1 -0
  72. package/lib/Socket/Client/websocket.d.ts +13 -0
  73. package/lib/Socket/Client/websocket.d.ts.map +1 -0
  74. package/lib/Socket/Client/websocket.js +2 -1
  75. package/lib/Socket/Client/websocket.js.map +1 -0
  76. package/lib/Socket/business.d.ts +376 -0
  77. package/lib/Socket/business.d.ts.map +1 -0
  78. package/lib/Socket/business.js +2 -1
  79. package/lib/Socket/business.js.map +1 -0
  80. package/lib/Socket/chats.d.ts +128 -0
  81. package/lib/Socket/chats.d.ts.map +1 -0
  82. package/lib/Socket/chats.js +25 -49
  83. package/lib/Socket/chats.js.map +1 -0
  84. package/lib/Socket/communities.d.ts +542 -0
  85. package/lib/Socket/communities.d.ts.map +1 -0
  86. package/lib/Socket/communities.js +2 -1
  87. package/lib/Socket/communities.js.map +1 -0
  88. package/lib/Socket/groups.d.ts +276 -0
  89. package/lib/Socket/groups.d.ts.map +1 -0
  90. package/lib/Socket/groups.js +18 -5
  91. package/lib/Socket/groups.js.map +1 -0
  92. package/lib/Socket/index.d.ts +510 -0
  93. package/lib/Socket/index.d.ts.map +1 -0
  94. package/lib/Socket/index.js +2 -1
  95. package/lib/Socket/index.js.map +1 -0
  96. package/lib/Socket/messages-recv.d.ts +316 -0
  97. package/lib/Socket/messages-recv.d.ts.map +1 -0
  98. package/lib/Socket/messages-recv.js +63 -209
  99. package/lib/Socket/messages-recv.js.map +1 -0
  100. package/lib/Socket/messages-send.d.ts +312 -0
  101. package/lib/Socket/messages-send.d.ts.map +1 -0
  102. package/lib/Socket/messages-send.js +24 -40
  103. package/lib/Socket/messages-send.js.map +1 -0
  104. package/lib/Socket/mex.d.ts +2 -0
  105. package/lib/Socket/mex.d.ts.map +1 -0
  106. package/lib/Socket/mex.js +2 -1
  107. package/lib/Socket/mex.js.map +1 -0
  108. package/lib/Socket/newsletter.d.ts +270 -0
  109. package/lib/Socket/newsletter.d.ts.map +1 -0
  110. package/lib/Socket/newsletter.js +17 -59
  111. package/lib/Socket/newsletter.js.map +1 -0
  112. package/lib/Socket/socket.d.ts +53 -0
  113. package/lib/Socket/socket.d.ts.map +1 -0
  114. package/lib/Socket/socket.js +3 -17
  115. package/lib/Socket/socket.js.map +1 -0
  116. package/lib/Store/index.d.ts +4 -0
  117. package/lib/Store/index.d.ts.map +1 -0
  118. package/lib/Store/index.js +2 -1
  119. package/lib/Store/index.js.map +1 -0
  120. package/lib/Store/make-in-memory-store.d.ts +63 -0
  121. package/lib/Store/make-in-memory-store.d.ts.map +1 -0
  122. package/lib/Store/make-in-memory-store.js +2 -1
  123. package/lib/Store/make-in-memory-store.js.map +1 -0
  124. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  125. package/lib/Store/make-ordered-dictionary.d.ts.map +1 -0
  126. package/lib/Store/make-ordered-dictionary.js +2 -1
  127. package/lib/Store/make-ordered-dictionary.js.map +1 -0
  128. package/lib/Store/object-repository.d.ts +11 -0
  129. package/lib/Store/object-repository.d.ts.map +1 -0
  130. package/lib/Store/object-repository.js +2 -1
  131. package/lib/Store/object-repository.js.map +1 -0
  132. package/lib/Types/Auth.d.ts +2 -0
  133. package/lib/Types/Auth.d.ts.map +1 -0
  134. package/lib/Types/Auth.js +2 -1
  135. package/lib/Types/Auth.js.map +1 -0
  136. package/lib/Types/Bussines.d.ts +2 -0
  137. package/lib/Types/Bussines.d.ts.map +1 -0
  138. package/lib/Types/Bussines.js +2 -1
  139. package/lib/Types/Bussines.js.map +1 -0
  140. package/lib/Types/Call.d.ts +2 -0
  141. package/lib/Types/Call.d.ts.map +1 -0
  142. package/lib/Types/Call.js +2 -1
  143. package/lib/Types/Call.js.map +1 -0
  144. package/lib/Types/Chat.d.ts +2 -0
  145. package/lib/Types/Chat.d.ts.map +1 -0
  146. package/lib/Types/Chat.js +2 -1
  147. package/lib/Types/Chat.js.map +1 -0
  148. package/lib/Types/Contact.d.ts +2 -0
  149. package/lib/Types/Contact.d.ts.map +1 -0
  150. package/lib/Types/Contact.js +2 -1
  151. package/lib/Types/Contact.js.map +1 -0
  152. package/lib/Types/Events.d.ts +2 -0
  153. package/lib/Types/Events.d.ts.map +1 -0
  154. package/lib/Types/Events.js +2 -1
  155. package/lib/Types/Events.js.map +1 -0
  156. package/lib/Types/GroupMetadata.d.ts +2 -0
  157. package/lib/Types/GroupMetadata.d.ts.map +1 -0
  158. package/lib/Types/GroupMetadata.js +2 -1
  159. package/lib/Types/GroupMetadata.js.map +1 -0
  160. package/lib/Types/Label.d.ts +3 -0
  161. package/lib/Types/Label.d.ts.map +1 -0
  162. package/lib/Types/Label.js +2 -1
  163. package/lib/Types/Label.js.map +1 -0
  164. package/lib/Types/LabelAssociation.d.ts +3 -0
  165. package/lib/Types/LabelAssociation.d.ts.map +1 -0
  166. package/lib/Types/LabelAssociation.js +2 -1
  167. package/lib/Types/LabelAssociation.js.map +1 -0
  168. package/lib/Types/Message.d.ts +12 -0
  169. package/lib/Types/Message.d.ts.map +1 -0
  170. package/lib/Types/Message.js +2 -1
  171. package/lib/Types/Message.js.map +1 -0
  172. package/lib/Types/Newsletter.d.ts +3 -0
  173. package/lib/Types/Newsletter.d.ts.map +1 -0
  174. package/lib/Types/Newsletter.js +6 -4
  175. package/lib/Types/Newsletter.js.map +1 -0
  176. package/lib/Types/Product.d.ts +2 -0
  177. package/lib/Types/Product.d.ts.map +1 -0
  178. package/lib/Types/Product.js +2 -1
  179. package/lib/Types/Product.js.map +1 -0
  180. package/lib/Types/RichType.d.ts +3 -0
  181. package/lib/Types/RichType.d.ts.map +1 -0
  182. package/lib/Types/RichType.js +2 -1
  183. package/lib/Types/RichType.js.map +1 -0
  184. package/lib/Types/Signal.d.ts +2 -0
  185. package/lib/Types/Signal.d.ts.map +1 -0
  186. package/lib/Types/Signal.js +2 -1
  187. package/lib/Types/Signal.js.map +1 -0
  188. package/lib/Types/Socket.d.ts +2 -0
  189. package/lib/Types/Socket.d.ts.map +1 -0
  190. package/lib/Types/Socket.js +1 -1
  191. package/lib/Types/Socket.js.map +1 -0
  192. package/lib/Types/State.d.ts +2 -0
  193. package/lib/Types/State.d.ts.map +1 -0
  194. package/lib/Types/State.js +2 -1
  195. package/lib/Types/State.js.map +1 -0
  196. package/lib/Types/USync.d.ts +2 -0
  197. package/lib/Types/USync.d.ts.map +1 -0
  198. package/lib/Types/USync.js +2 -1
  199. package/lib/Types/USync.js.map +1 -0
  200. package/lib/Types/index.d.ts +14 -0
  201. package/lib/Types/index.d.ts.map +1 -0
  202. package/lib/Types/index.js +2 -1
  203. package/lib/Types/index.js.map +1 -0
  204. package/lib/Utils/auth-utils.d.ts +58 -0
  205. package/lib/Utils/auth-utils.d.ts.map +1 -0
  206. package/lib/Utils/auth-utils.js +14 -1
  207. package/lib/Utils/auth-utils.js.map +1 -0
  208. package/lib/Utils/browser-utils.d.ts +9 -0
  209. package/lib/Utils/browser-utils.d.ts.map +1 -0
  210. package/lib/Utils/browser-utils.js +3 -3
  211. package/lib/Utils/browser-utils.js.map +1 -0
  212. package/lib/Utils/business.d.ts +50 -0
  213. package/lib/Utils/business.d.ts.map +1 -0
  214. package/lib/Utils/business.js +2 -1
  215. package/lib/Utils/business.js.map +1 -0
  216. package/lib/Utils/chat-utils.d.ts +409 -0
  217. package/lib/Utils/chat-utils.d.ts.map +1 -0
  218. package/lib/Utils/chat-utils.js +25 -25
  219. package/lib/Utils/chat-utils.js.map +1 -0
  220. package/lib/Utils/companion-reg-client-utils.d.ts +5 -0
  221. package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
  222. package/lib/Utils/companion-reg-client-utils.js +22 -14
  223. package/lib/Utils/companion-reg-client-utils.js.map +1 -0
  224. package/lib/Utils/crypto.d.ts +40 -0
  225. package/lib/Utils/crypto.d.ts.map +1 -0
  226. package/lib/Utils/crypto.js +2 -1
  227. package/lib/Utils/crypto.js.map +1 -0
  228. package/lib/Utils/decode-wa-message.d.ts +82 -0
  229. package/lib/Utils/decode-wa-message.d.ts.map +1 -0
  230. package/lib/Utils/decode-wa-message.js +11 -2
  231. package/lib/Utils/decode-wa-message.js.map +1 -0
  232. package/lib/Utils/event-buffer.d.ts +12 -0
  233. package/lib/Utils/event-buffer.d.ts.map +1 -0
  234. package/lib/Utils/event-buffer.js +3 -18
  235. package/lib/Utils/event-buffer.js.map +1 -0
  236. package/lib/Utils/generics.d.ts +64 -0
  237. package/lib/Utils/generics.d.ts.map +1 -0
  238. package/lib/Utils/generics.js +395 -394
  239. package/lib/Utils/generics.js.map +1 -0
  240. package/lib/Utils/history.d.ts +74 -0
  241. package/lib/Utils/history.d.ts.map +1 -0
  242. package/lib/Utils/history.js +2 -1
  243. package/lib/Utils/history.js.map +1 -0
  244. package/lib/Utils/identity-change-handler.d.ts +14 -0
  245. package/lib/Utils/identity-change-handler.d.ts.map +1 -0
  246. package/lib/Utils/identity-change-handler.js +2 -1
  247. package/lib/Utils/identity-change-handler.js.map +1 -0
  248. package/lib/Utils/index.d.ts +24 -0
  249. package/lib/Utils/index.d.ts.map +1 -0
  250. package/lib/Utils/index.js +3 -2
  251. package/lib/Utils/index.js.map +1 -0
  252. package/lib/Utils/link-preview.d.ts +13 -0
  253. package/lib/Utils/link-preview.d.ts.map +1 -0
  254. package/lib/Utils/link-preview.js +2 -1
  255. package/lib/Utils/link-preview.js.map +1 -0
  256. package/lib/Utils/logger.d.ts +3 -0
  257. package/lib/Utils/logger.d.ts.map +1 -0
  258. package/lib/Utils/logger.js +2 -1
  259. package/lib/Utils/logger.js.map +1 -0
  260. package/lib/Utils/lt-hash.d.ts +7 -0
  261. package/lib/Utils/lt-hash.d.ts.map +1 -0
  262. package/lib/Utils/lt-hash.js +2 -1
  263. package/lib/Utils/lt-hash.js.map +1 -0
  264. package/lib/Utils/make-mutex.d.ts +7 -0
  265. package/lib/Utils/make-mutex.d.ts.map +1 -0
  266. package/lib/Utils/make-mutex.js +2 -1
  267. package/lib/Utils/make-mutex.js.map +1 -0
  268. package/lib/Utils/message-retry-manager.d.ts +75 -0
  269. package/lib/Utils/message-retry-manager.d.ts.map +1 -0
  270. package/lib/Utils/message-retry-manager.js +3 -19
  271. package/lib/Utils/message-retry-manager.js.map +1 -0
  272. package/lib/Utils/messages-media.d.ts +136 -0
  273. package/lib/Utils/messages-media.d.ts.map +1 -0
  274. package/lib/Utils/messages-media.js +12 -10
  275. package/lib/Utils/messages-media.js.map +1 -0
  276. package/lib/Utils/messages.d.ts +46 -0
  277. package/lib/Utils/messages.d.ts.map +1 -0
  278. package/lib/Utils/messages.js +240 -251
  279. package/lib/Utils/messages.js.map +1 -0
  280. package/lib/Utils/noise-handler.d.ts +21 -0
  281. package/lib/Utils/noise-handler.d.ts.map +1 -0
  282. package/lib/Utils/noise-handler.js +2 -1
  283. package/lib/Utils/noise-handler.js.map +1 -0
  284. package/lib/Utils/offline-node-processor.d.ts +10 -0
  285. package/lib/Utils/offline-node-processor.d.ts.map +1 -0
  286. package/lib/Utils/offline-node-processor.js +2 -1
  287. package/lib/Utils/offline-node-processor.js.map +1 -0
  288. package/lib/Utils/pre-key-manager.d.ts +26 -0
  289. package/lib/Utils/pre-key-manager.d.ts.map +1 -0
  290. package/lib/Utils/pre-key-manager.js +2 -1
  291. package/lib/Utils/pre-key-manager.js.map +1 -0
  292. package/lib/Utils/process-message.d.ts +52 -0
  293. package/lib/Utils/process-message.d.ts.map +1 -0
  294. package/lib/Utils/process-message.js +21 -3
  295. package/lib/Utils/process-message.js.map +1 -0
  296. package/lib/Utils/reporting-utils.d.ts +13 -0
  297. package/lib/Utils/reporting-utils.d.ts.map +1 -0
  298. package/lib/Utils/reporting-utils.js +2 -1
  299. package/lib/Utils/reporting-utils.js.map +1 -0
  300. package/lib/Utils/rich-message-utils.d.ts +81 -0
  301. package/lib/Utils/rich-message-utils.d.ts.map +1 -0
  302. package/lib/Utils/rich-message-utils.js +127 -128
  303. package/lib/Utils/rich-message-utils.js.map +1 -0
  304. package/lib/Utils/signal.d.ts +70 -0
  305. package/lib/Utils/signal.d.ts.map +1 -0
  306. package/lib/Utils/signal.js +2 -1
  307. package/lib/Utils/signal.js.map +1 -0
  308. package/lib/Utils/stanza-ack.d.ts +17 -0
  309. package/lib/Utils/stanza-ack.d.ts.map +1 -0
  310. package/lib/Utils/stanza-ack.js +2 -1
  311. package/lib/Utils/stanza-ack.js.map +1 -0
  312. package/lib/Utils/sync-action-utils.d.ts +3 -0
  313. package/lib/Utils/sync-action-utils.d.ts.map +1 -0
  314. package/lib/Utils/sync-action-utils.js +2 -1
  315. package/lib/Utils/sync-action-utils.js.map +1 -0
  316. package/lib/Utils/tc-token-utils.d.ts +30 -0
  317. package/lib/Utils/tc-token-utils.d.ts.map +1 -0
  318. package/lib/Utils/tc-token-utils.js.map +1 -0
  319. package/lib/Utils/use-multi-file-auth-state.d.ts +11 -0
  320. package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
  321. package/lib/Utils/use-multi-file-auth-state.js +2 -1
  322. package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
  323. package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
  324. package/lib/Utils/use-single-file-auth-state.d.ts.map +1 -0
  325. package/lib/Utils/use-single-file-auth-state.js +6 -3
  326. package/lib/Utils/use-single-file-auth-state.js.map +1 -0
  327. package/lib/Utils/validate-connection.d.ts +44 -0
  328. package/lib/Utils/validate-connection.d.ts.map +1 -0
  329. package/lib/Utils/validate-connection.js +4 -10
  330. package/lib/Utils/validate-connection.js.map +1 -0
  331. package/lib/WABinary/constants.d.ts +46 -0
  332. package/lib/WABinary/constants.d.ts.map +1 -0
  333. package/lib/WABinary/constants.js +2 -1
  334. package/lib/WABinary/constants.js.map +1 -0
  335. package/lib/WABinary/decode.d.ts +10 -0
  336. package/lib/WABinary/decode.d.ts.map +1 -0
  337. package/lib/WABinary/decode.js +2 -1
  338. package/lib/WABinary/decode.js.map +1 -0
  339. package/lib/WABinary/encode.d.ts +3 -0
  340. package/lib/WABinary/encode.d.ts.map +1 -0
  341. package/lib/WABinary/encode.js +2 -1
  342. package/lib/WABinary/encode.js.map +1 -0
  343. package/lib/WABinary/generic-utils.d.ts +77 -0
  344. package/lib/WABinary/generic-utils.d.ts.map +1 -0
  345. package/lib/WABinary/generic-utils.js +8 -9
  346. package/lib/WABinary/generic-utils.js.map +1 -0
  347. package/lib/WABinary/index.d.ts +6 -0
  348. package/lib/WABinary/index.d.ts.map +1 -0
  349. package/lib/WABinary/index.js +2 -1
  350. package/lib/WABinary/index.js.map +1 -0
  351. package/lib/WABinary/jid-utils.d.ts +29 -0
  352. package/lib/WABinary/jid-utils.d.ts.map +1 -0
  353. package/lib/WABinary/jid-utils.js +2 -1
  354. package/lib/WABinary/jid-utils.js.map +1 -0
  355. package/lib/WABinary/types.d.ts +2 -0
  356. package/lib/WABinary/types.d.ts.map +1 -0
  357. package/lib/WABinary/types.js +2 -1
  358. package/lib/WABinary/types.js.map +1 -0
  359. package/lib/WAM/BinaryInfo.d.ts +8 -0
  360. package/lib/WAM/BinaryInfo.d.ts.map +1 -0
  361. package/lib/WAM/BinaryInfo.js +2 -1
  362. package/lib/WAM/BinaryInfo.js.map +1 -0
  363. package/lib/WAM/constants.d.ts +34927 -0
  364. package/lib/WAM/constants.d.ts.map +1 -0
  365. package/lib/WAM/constants.js +2 -1
  366. package/lib/WAM/constants.js.map +1 -0
  367. package/lib/WAM/encode.d.ts +2 -0
  368. package/lib/WAM/encode.d.ts.map +1 -0
  369. package/lib/WAM/encode.js +2 -1
  370. package/lib/WAM/encode.js.map +1 -0
  371. package/lib/WAM/index.d.ts +4 -0
  372. package/lib/WAM/index.d.ts.map +1 -0
  373. package/lib/WAM/index.js +2 -1
  374. package/lib/WAM/index.js.map +1 -0
  375. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +37 -0
  376. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
  377. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -1
  378. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
  379. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  380. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
  381. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -1
  382. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
  383. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  384. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
  385. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -1
  386. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
  387. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  388. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
  389. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -1
  390. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
  391. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  392. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
  393. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +5 -2
  394. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
  395. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
  396. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
  397. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +2 -1
  398. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
  399. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +15 -0
  400. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
  401. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +2 -1
  402. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
  403. package/lib/WAUSync/Protocols/index.d.ts +6 -0
  404. package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
  405. package/lib/WAUSync/Protocols/index.js +2 -1
  406. package/lib/WAUSync/Protocols/index.js.map +1 -0
  407. package/lib/WAUSync/USyncQuery.d.ts +21 -0
  408. package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
  409. package/lib/WAUSync/USyncQuery.js +2 -1
  410. package/lib/WAUSync/USyncQuery.js.map +1 -0
  411. package/lib/WAUSync/USyncUser.d.ts +17 -0
  412. package/lib/WAUSync/USyncUser.d.ts.map +1 -0
  413. package/lib/WAUSync/USyncUser.js +2 -1
  414. package/lib/WAUSync/USyncUser.js.map +1 -0
  415. package/lib/WAUSync/index.d.ts +4 -0
  416. package/lib/WAUSync/index.d.ts.map +1 -0
  417. package/lib/WAUSync/index.js +2 -1
  418. package/lib/WAUSync/index.js.map +1 -0
  419. package/lib/index.d.ts +12 -0
  420. package/lib/index.d.ts.map +1 -0
  421. package/lib/index.js +3 -2
  422. package/lib/index.js.map +1 -0
  423. package/package.json +3 -2
@@ -2,11 +2,10 @@ import { Boom } from '@hapi/boom';
2
2
  import { randomBytes } from 'crypto';
3
3
  import { zip } from 'fflate';
4
4
  import { promises as fs } from 'fs';
5
- import {} from 'stream';
6
5
  import { proto } from '../../WAProto/index.js';
7
6
  import { CALL_AUDIO_PREFIX, CALL_VIDEO_PREFIX, DONATE_URL, LIBRARY_NAME, MEDIA_KEYS, URL_REGEX, WA_DEFAULT_EPHEMERAL } from '../Defaults/index.js';
8
7
  import { AssociationType, ButtonHeaderType, ButtonType, CarouselCardType, ListType, ProtocolType, WAMessageStatus, WAProto } from '../Types/index.js';
9
- import { isPnUser, isLidUser, isJidGroup, isJidNewsletter, isJidStatusBroadcast, jidNormalizedUser } from '../WABinary/index.js';
8
+ import { isLidUser, isPnUser, isJidGroup, isJidNewsletter, isJidStatusBroadcast, jidNormalizedUser } from '../WABinary/index.js';
10
9
  import { sha256 } from './crypto.js';
11
10
  import { generateMessageIDV2, getKeyAuthor, unixTimestampSeconds } from './generics.js';
12
11
  import { downloadContentFromMessage, encryptedStream, generateThumbnail, getAudioDuration, getAudioWaveform, getImageProcessingLibrary, getRawMediaUploadData, getStream, toBuffer } from './messages-media.js';
@@ -83,26 +82,33 @@ const assertColor = async (color) => {
83
82
  return assertedColor;
84
83
  }
85
84
  };
86
- // Lia@Changes 21-04-26 --- Refactor prepareWAMessageMedia function
87
85
  export const prepareWAMessageMedia = async (message, options) => {
88
86
  const logger = options.logger;
89
- const mediaType = MEDIA_KEYS.find(key => key in message);
87
+ let mediaType;
88
+ for (const key of MEDIA_KEYS) {
89
+ if (key in message) {
90
+ mediaType = key;
91
+ }
92
+ }
90
93
  if (!mediaType) {
91
94
  throw new Boom('Invalid media type', { statusCode: 400 });
92
95
  }
93
- const uploadData = { ...message };
94
- const mediaPayload = uploadData[mediaType];
95
- delete uploadData[mediaType];
96
+ const uploadData = {
97
+ ...message,
98
+ media: message[mediaType]
99
+ };
100
+ delete uploadData[mediaType];
96
101
  if (uploadData.image || uploadData.video) {
97
102
  uploadData.annotations = mediaAnnotation;
98
103
  }
99
- const cacheableKey = typeof mediaPayload === 'object' &&
100
- 'url' in mediaPayload &&
101
- !!mediaPayload.url &&
104
+ // check if cacheable + generate cache key
105
+ const cacheableKey = typeof uploadData.media === 'object' &&
106
+ 'url' in uploadData.media &&
107
+ !!uploadData.media.url &&
102
108
  !!options.mediaCache &&
103
- `${mediaType}:${mediaPayload.url}`;
109
+ mediaType + ':' + uploadData.media.url.toString();
104
110
  if (mediaType === 'document' && !uploadData.fileName) {
105
- uploadData.fileName = LIBRARY_NAME;
111
+ uploadData.fileName = 'file';
106
112
  }
107
113
  if (!uploadData.mimetype) {
108
114
  uploadData.mimetype = MIMETYPE_MAP[mediaType];
@@ -113,156 +119,133 @@ export const prepareWAMessageMedia = async (message, options) => {
113
119
  logger?.debug({ cacheableKey }, 'got media cache hit');
114
120
  const obj = proto.Message.decode(mediaBuff);
115
121
  const key = `${mediaType}Message`;
116
- Object.assign(obj[key], uploadData);
122
+ Object.assign(obj[key], { ...uploadData, media: undefined });
117
123
  return obj;
118
124
  }
119
125
  }
120
- const isNewsletter = isJidNewsletter(options.jid);
121
- const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined';
122
- const requiresThumbnailComputation = (mediaType === 'image' || mediaType === 'video') && typeof uploadData.jpegThumbnail === 'undefined';
123
- const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true && typeof uploadData.waveform === 'undefined';
124
- const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true;
125
- const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation || requiresWaveformProcessing;
126
- let mediaUrl,
127
- directPath,
128
- thumbnailDirectPath,
129
- thumbnailSha256,
130
- fileSha256,
131
- fileLength,
132
- mediaKey,
133
- fileEncSha256;
134
- // Lia@Changes 06-02-26 --- Add few support for sending media to newsletter (⁠≧⁠▽⁠≦⁠)
126
+ const isNewsletter = !!options.jid && isJidNewsletter(options.jid);
135
127
  if (isNewsletter) {
136
128
  logger?.info({ key: cacheableKey }, 'Preparing raw media for newsletter');
137
- const rawData = await getRawMediaUploadData(mediaPayload, options.mediaTypeOverride || mediaType, logger);
138
- fileSha256 = rawData.fileSha256;
139
- fileLength = rawData.fileLength;
140
- const filePath = rawData.filePath;
129
+ const { filePath, fileSha256, fileLength } = await getRawMediaUploadData(uploadData.media, options.mediaTypeOverride || mediaType, logger);
141
130
  const fileSha256B64 = fileSha256.toString('base64');
142
- const [uploadResult] = await Promise.all([
143
- options.upload(filePath, {
144
- fileEncSha256B64: fileSha256B64,
145
- mediaType,
146
- timeoutMs: options.mediaUploadTimeoutMs,
147
- newsletter: true
148
- }),
149
- (async () => {
150
- try {
151
- if (requiresThumbnailComputation) {
152
- const { thumbnail } = await generateThumbnail(filePath, mediaType, options);
153
- uploadData.jpegThumbnail = thumbnail;
154
- }
155
- if (requiresDurationComputation) {
156
- uploadData.seconds = await getAudioDuration(filePath);
157
- }
158
- }
159
- catch (error) {
160
- logger?.warn({ trace: error.stack }, 'failed to obtain extra info');
161
- }
162
- })()
163
- ]);
164
- // todo: add more support here
165
- mediaUrl = uploadResult.mediaUrl;
166
- directPath = uploadResult.directPath;
167
- thumbnailDirectPath = uploadResult.thumbnailDirectPath;
168
- thumbnailSha256 = uploadResult.thumbnailSha256;
169
- fs.unlink(filePath).catch(() => logger?.warn('failed to remove tmp file'));
170
- }
171
- else {
172
- const encryptedData = await encryptedStream(mediaPayload, options.mediaTypeOverride || mediaType, {
173
- logger,
174
- saveOriginalFileIfRequired: requiresOriginalForSomeProcessing,
175
- opts: options.options
131
+ const { mediaUrl, directPath, thumbnailDirectPath, thumbnailSha256 } = await options.upload(filePath, {
132
+ fileEncSha256B64: fileSha256B64,
133
+ mediaType: mediaType,
134
+ timeoutMs: options.mediaUploadTimeoutMs,
135
+ newsletter: isNewsletter
136
+ });
137
+ await fs.unlink(filePath);
138
+ const obj = WAProto.Message.fromObject({
139
+ // todo: add more support here
140
+ [`${mediaType}Message`]: MessageTypeProto[mediaType].fromObject({
141
+ url: mediaUrl,
142
+ directPath,
143
+ fileSha256,
144
+ fileLength,
145
+ thumbnailDirectPath,
146
+ thumbnailSha256,
147
+ ...uploadData,
148
+ media: undefined
149
+ })
176
150
  });
177
- mediaKey = encryptedData.mediaKey;
178
- fileEncSha256 = encryptedData.fileEncSha256;
179
- fileSha256 = encryptedData.fileSha256;
180
- fileLength = encryptedData.fileLength;
181
- const encFilePath = encryptedData.encFilePath;
182
- const originalFilePath = encryptedData.originalFilePath;
183
- const fileEncSha256B64 = fileEncSha256.toString('base64');
184
- const [uploadResult] = await Promise.all([
185
- options.upload(encFilePath, {
151
+ if (uploadData.ptv) {
152
+ obj.ptvMessage = obj.videoMessage;
153
+ delete obj.videoMessage;
154
+ }
155
+ if (obj.stickerMessage) {
156
+ obj.stickerMessage.stickerSentTs = Date.now();
157
+ }
158
+ if (cacheableKey) {
159
+ logger?.debug({ cacheableKey }, 'set cache');
160
+ await options.mediaCache.set(cacheableKey, WAProto.Message.encode(obj).finish());
161
+ }
162
+ return obj;
163
+ }
164
+ const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined';
165
+ const requiresThumbnailComputation = (mediaType === 'image' || mediaType === 'video') && typeof uploadData['jpegThumbnail'] === 'undefined';
166
+ const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true && typeof uploadData.waveform === 'undefined';
167
+ const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true;
168
+ const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation;
169
+ const { mediaKey, encFilePath, originalFilePath, fileEncSha256, fileSha256, fileLength } = await encryptedStream(uploadData.media, options.mediaTypeOverride || mediaType, {
170
+ logger,
171
+ saveOriginalFileIfRequired: requiresOriginalForSomeProcessing,
172
+ opts: options.options
173
+ });
174
+ const fileEncSha256B64 = fileEncSha256.toString('base64');
175
+ const [{ mediaUrl, directPath }] = await Promise.all([
176
+ (async () => {
177
+ const result = await options.upload(encFilePath, {
186
178
  fileEncSha256B64,
187
179
  mediaType,
188
180
  timeoutMs: options.mediaUploadTimeoutMs
189
- }),
190
- (async () => {
191
- try {
192
- if (requiresThumbnailComputation) {
193
- const { thumbnail, originalImageDimensions } = await generateThumbnail(originalFilePath, mediaType, options);
194
- uploadData.jpegThumbnail = thumbnail;
195
- if (!uploadData.width && originalImageDimensions) {
196
- uploadData.width = originalImageDimensions.width;
197
- uploadData.height = originalImageDimensions.height;
198
- }
199
- }
200
- if (requiresDurationComputation) {
201
- uploadData.seconds = await getAudioDuration(originalFilePath);
202
- }
203
- if (requiresWaveformProcessing) {
204
- uploadData.waveform = await getAudioWaveform(originalFilePath, logger);
205
- }
206
- if (requiresAudioBackground) {
207
- uploadData.backgroundArgb = await assertColor(options.backgroundColor);
181
+ });
182
+ logger?.debug({ mediaType, cacheableKey }, 'uploaded media');
183
+ return result;
184
+ })(),
185
+ (async () => {
186
+ try {
187
+ if (requiresThumbnailComputation) {
188
+ const { thumbnail, originalImageDimensions } = await generateThumbnail(originalFilePath, mediaType, options);
189
+ uploadData.jpegThumbnail = thumbnail;
190
+ if (!uploadData.width && originalImageDimensions) {
191
+ uploadData.width = originalImageDimensions.width;
192
+ uploadData.height = originalImageDimensions.height;
193
+ logger?.debug('set dimensions');
208
194
  }
195
+ logger?.debug('generated thumbnail');
209
196
  }
210
- catch (error) {
211
- logger?.warn({ trace: error.stack }, 'failed to obtain extra info');
197
+ if (requiresDurationComputation) {
198
+ uploadData.seconds = await getAudioDuration(originalFilePath);
199
+ logger?.debug('computed audio duration');
212
200
  }
213
- })()
214
- ]);
215
- mediaUrl = uploadResult.mediaUrl;
216
- directPath = uploadResult.directPath;
217
- fs.unlink(encFilePath).catch(() => logger?.warn('failed to remove tmp file'));
218
- fs.unlink(originalFilePath).catch(() => logger?.warn('failed to remove tmp file'));
219
- }
220
- const messagePayload = {
221
- url: mediaUrl,
222
- directPath,
223
- fileSha256,
224
- fileLength,
225
- ...uploadData
226
- };
227
- if (isNewsletter) {
228
- messagePayload.thumbnailDirectPath = thumbnailDirectPath;
229
- messagePayload.thumbnailSha256 = thumbnailSha256;
230
- }
231
- else {
232
- messagePayload.mediaKey = mediaKey;
233
- messagePayload.fileEncSha256 = fileEncSha256;
234
- messagePayload.mediaKeyTimestamp = unixTimestampSeconds();
235
- }
236
- const obj = proto.Message.create({
237
- [`${mediaType}Message`]: MessageTypeProto[mediaType].fromObject(messagePayload)
201
+ if (requiresWaveformProcessing) {
202
+ uploadData.waveform = await getAudioWaveform(originalFilePath, logger);
203
+ logger?.debug('processed waveform');
204
+ }
205
+ if (requiresAudioBackground) {
206
+ uploadData.backgroundArgb = await assertColor(options.backgroundColor);
207
+ logger?.debug('computed backgroundColor audio status');
208
+ }
209
+ }
210
+ catch (error) {
211
+ logger?.warn({ trace: error.stack }, 'failed to obtain extra info');
212
+ }
213
+ })()
214
+ ]).finally(async () => {
215
+ try {
216
+ await fs.unlink(encFilePath);
217
+ if (originalFilePath) {
218
+ await fs.unlink(originalFilePath);
219
+ }
220
+ logger?.debug('removed tmp files');
221
+ }
222
+ catch (error) {
223
+ logger?.warn('failed to remove tmp file');
224
+ }
225
+ });
226
+ const obj = WAProto.Message.fromObject({
227
+ [`${mediaType}Message`]: MessageTypeProto[mediaType].fromObject({
228
+ url: mediaUrl,
229
+ directPath,
230
+ mediaKey,
231
+ fileEncSha256,
232
+ fileSha256,
233
+ fileLength,
234
+ mediaKeyTimestamp: unixTimestampSeconds(),
235
+ ...uploadData,
236
+ media: undefined
237
+ })
238
238
  });
239
239
  if (uploadData.ptv) {
240
240
  obj.ptvMessage = obj.videoMessage;
241
241
  delete obj.videoMessage;
242
242
  }
243
- if (obj.stickerMessage) {
244
- obj.stickerMessage.stickerSentTs = Date.now();
245
- }
246
243
  if (cacheableKey) {
247
- logger?.debug({ cacheableKey }, 'set cache (background)');
248
- options.mediaCache.set(cacheableKey, WAProto.Message.encode(obj).finish());
244
+ logger?.debug({ cacheableKey }, 'set cache');
245
+ await options.mediaCache.set(cacheableKey, WAProto.Message.encode(obj).finish());
249
246
  }
250
247
  return obj;
251
248
  };
252
- export const prepareDisappearingMessageSettingContent = (ephemeralExpiration) => {
253
- ephemeralExpiration = ephemeralExpiration || 0;
254
- const content = {
255
- ephemeralMessage: {
256
- message: {
257
- protocolMessage: {
258
- type: ProtocolType.EPHEMERAL_SETTING,
259
- ephemeralExpiration
260
- }
261
- }
262
- }
263
- };
264
- return content;
265
- };
266
249
  // Lia@Changes 31-01-26 --- Extract product message into a standalone function so it can also be reused as the header for interactive messages
267
250
  const prepareProductMessage = async (message, options) => {
268
251
  if (!message.businessOwnerJid) {
@@ -359,7 +342,7 @@ const prepareStickerPackMessage = async (message, options) => {
359
342
  .webp(80);
360
343
  }
361
344
  if (webpBuffer.length > 1024 * 1024) {
362
- throw new Boom(`Sticker at index ${index} exceeds the 1MB size limit`, { statusCode: 400 });
345
+ throw new Boom(`Sticker at index ${index} exceeds the 1MB size limit`, { statusCode: 400 });
363
346
  }
364
347
  const hash = sha256(webpBuffer).toString('base64').replace(/\//g, '-');
365
348
  const fileName = `${hash}.webp`;
@@ -482,7 +465,7 @@ const prepareStickerPackMessage = async (message, options) => {
482
465
  };
483
466
  // Lia@Changes 30-01-26 --- Add native flow button helper for interactive message
484
467
  const prepareNativeFlowButtons = (message) => {
485
- const buttons = message.nativeFlow
468
+ const buttons = message.nativeFlow;
486
469
  const isButtonsFieldArray = Array.isArray(buttons);
487
470
  const correctedField = isButtonsFieldArray ? buttons : buttons.buttons;
488
471
  const messageParamsJson = {};
@@ -501,10 +484,7 @@ const prepareNativeFlowButtons = (message) => {
501
484
  Object.assign(messageParamsJson, {
502
485
  bottom_sheet: {
503
486
  in_thread_buttons_limit: 1,
504
- divider_indices: Array.from(
505
- { length: correctedField.length },
506
- (_, index) => index
507
- ),
487
+ divider_indices: Array.from({ length: correctedField.length }, (_, index) => index),
508
488
  list_title: message.optionTitle || '📄 Select Options',
509
489
  button_title: message.optionText
510
490
  }
@@ -573,13 +553,27 @@ const prepareNativeFlowButtons = (message) => {
573
553
  messageVersion: 1
574
554
  };
575
555
  };
556
+ export const prepareDisappearingMessageSettingContent = (ephemeralExpiration) => {
557
+ ephemeralExpiration = ephemeralExpiration || 0;
558
+ const content = {
559
+ ephemeralMessage: {
560
+ message: {
561
+ protocolMessage: {
562
+ type: WAProto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING,
563
+ ephemeralExpiration
564
+ }
565
+ }
566
+ }
567
+ };
568
+ return WAProto.Message.fromObject(content);
569
+ };
576
570
  /**
577
571
  * Generate forwarded message content like WA does
578
572
  * @param message the message to forward
579
573
  * @param options.forceForward will show the message as forwarded even if it is from you
580
574
  */
581
575
  export const generateForwardMessageContent = (message, forceForward) => {
582
- let content = message.message || message;
576
+ let content = message.message;
583
577
  if (!content) {
584
578
  throw new Boom('no content in message', { statusCode: 400 });
585
579
  }
@@ -595,24 +589,12 @@ export const generateForwardMessageContent = (message, forceForward) => {
595
589
  key = 'extendedTextMessage';
596
590
  }
597
591
  const key_ = content?.[key];
598
- const contextInfo = {};
599
592
  if (score > 0) {
600
- contextInfo.forwardingScore = score;
601
- contextInfo.isForwarded = true;
602
- }
603
- // when forwarding a newsletter/channel message, add the newsletter context
604
- // so the server knows where to find the original media
605
- const remoteJid = message.key?.remoteJid;
606
- if (remoteJid && isJidNewsletter(remoteJid)) {
607
- contextInfo.forwardedNewsletterMessageInfo = {
608
- newsletterJid: remoteJid,
609
- serverMessageId: message.key?.server_id ? parseInt(message.key.server_id) : null,
610
- newsletterName: null
611
- };
612
- // strip messageContextInfo (contains messageSecret etc.) as WA Web does
613
- delete content.messageContextInfo;
593
+ key_.contextInfo = { forwardingScore: score, isForwarded: true };
594
+ }
595
+ else {
596
+ key_.contextInfo = {};
614
597
  }
615
- key_.contextInfo = contextInfo;
616
598
  return content;
617
599
  };
618
600
  export const hasNonNullishProperty = (message, key) => {
@@ -713,25 +695,25 @@ export const generateWAMessageContent = async (message, options) => {
713
695
  throw new Boom('require atleast 1 contact', { statusCode: 400 });
714
696
  }
715
697
  if (contactLen === 1) {
716
- m.contactMessage = message.contacts.contacts[0];
698
+ m.contactMessage = WAProto.Message.ContactMessage.create(message.contacts.contacts[0]);
717
699
  }
718
700
  else {
719
- m.contactsArrayMessage = message.contacts;
701
+ m.contactsArrayMessage = WAProto.Message.ContactsArrayMessage.create(message.contacts);
720
702
  }
721
703
  }
722
704
  else if (hasNonNullishProperty(message, 'location')) {
723
- m.locationMessage = message.location;
705
+ m.locationMessage = WAProto.Message.LocationMessage.create(message.location);
724
706
  }
725
707
  else if (hasNonNullishProperty(message, 'react')) {
726
708
  if (!message.react.senderTimestampMs) {
727
709
  message.react.senderTimestampMs = Date.now();
728
710
  }
729
- m.reactionMessage = message.react;
711
+ m.reactionMessage = WAProto.Message.ReactionMessage.create(message.react);
730
712
  }
731
713
  else if (hasNonNullishProperty(message, 'delete')) {
732
714
  m.protocolMessage = {
733
715
  key: message.delete,
734
- type: ProtocolType.REVOKE
716
+ type: WAProto.Message.ProtocolMessage.Type.REVOKE
735
717
  };
736
718
  }
737
719
  else if (hasNonNullishProperty(message, 'forward')) {
@@ -933,25 +915,6 @@ export const generateWAMessageContent = async (message, options) => {
933
915
  vote: message.pollUpdate.vote
934
916
  };
935
917
  }
936
- else if (hasNonNullishProperty(message, 'sharePhoneNumber')) {
937
- m.protocolMessage = {
938
- type: ProtocolType.SHARE_PHONE_NUMBER
939
- };
940
- }
941
- else if (hasNonNullishProperty(message, 'requestPhoneNumber')) {
942
- m.requestPhoneNumberMessage = {};
943
- }
944
- else if (hasNonNullishProperty(message, 'limitSharing')) {
945
- m.protocolMessage = {
946
- type: ProtocolType.LIMIT_SHARING,
947
- limitSharing: {
948
- sharingLimited: message.limitSharing === true,
949
- trigger: 1,
950
- limitSharingSettingTimestamp: Date.now(),
951
- initiatedByMe: true
952
- }
953
- };
954
- }
955
918
  // Lia@Changes 01-02-26 --- Add payment invite message
956
919
  else if (hasNonNullishProperty(message, 'paymentInviteServiceType')) {
957
920
  m.paymentInviteMessage = {
@@ -985,12 +948,16 @@ export const generateWAMessageContent = async (message, options) => {
985
948
  }
986
949
  let videoCount = 0;
987
950
  for (let i = 0; i < message.album.length; i++) {
988
- if (message.album[i].video) videoCount++;
989
- };
951
+ if (message.album[i].video)
952
+ videoCount++;
953
+ }
954
+ ;
990
955
  let imageCount = 0;
991
956
  for (let i = 0; i < message.album.length; i++) {
992
- if (message.album[i].image) imageCount++;
993
- };
957
+ if (message.album[i].image)
958
+ imageCount++;
959
+ }
960
+ ;
994
961
  if ((videoCount + imageCount) < 2) {
995
962
  throw new Boom('Minimum provide 2 media to upload album message', { statusCode: 400 });
996
963
  }
@@ -999,6 +966,25 @@ export const generateWAMessageContent = async (message, options) => {
999
966
  expectedVideoCount: videoCount
1000
967
  };
1001
968
  }
969
+ else if (hasNonNullishProperty(message, 'sharePhoneNumber')) {
970
+ m.protocolMessage = {
971
+ type: proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER
972
+ };
973
+ }
974
+ else if (hasNonNullishProperty(message, 'requestPhoneNumber')) {
975
+ m.requestPhoneNumberMessage = {};
976
+ }
977
+ else if (hasNonNullishProperty(message, 'limitSharing')) {
978
+ m.protocolMessage = {
979
+ type: proto.Message.ProtocolMessage.Type.LIMIT_SHARING,
980
+ limitSharing: {
981
+ sharingLimited: message.limitSharing === true,
982
+ trigger: 1,
983
+ limitSharingSettingTimestamp: Date.now(),
984
+ initiatedByMe: true
985
+ }
986
+ };
987
+ }
1002
988
  else {
1003
989
  m = await prepareWAMessageMedia(message, options);
1004
990
  }
@@ -1011,11 +997,11 @@ export const generateWAMessageContent = async (message, options) => {
1011
997
  if (hasOptionalProperty(button, 'sections')) {
1012
998
  return {
1013
999
  nativeFlowInfo: {
1014
- name: 'single_select',
1015
- paramsJson: JSON.stringify({
1016
- title: buttonText,
1017
- sections: button.sections
1018
- })
1000
+ name: 'single_select',
1001
+ paramsJson: JSON.stringify({
1002
+ title: buttonText,
1003
+ sections: button.sections
1004
+ })
1019
1005
  },
1020
1006
  type: ButtonType.NATIVE_FLOW
1021
1007
  };
@@ -1023,8 +1009,8 @@ export const generateWAMessageContent = async (message, options) => {
1023
1009
  else if (hasOptionalProperty(button, 'name')) {
1024
1010
  return {
1025
1011
  nativeFlowInfo: {
1026
- name: button.name,
1027
- paramsJson: button.paramsJson
1012
+ name: button.name,
1013
+ paramsJson: button.paramsJson
1028
1014
  },
1029
1015
  type: ButtonType.NATIVE_FLOW
1030
1016
  };
@@ -1107,7 +1093,8 @@ export const generateWAMessageContent = async (message, options) => {
1107
1093
  if (hasOptionalProperty(message, 'caption')) {
1108
1094
  hydratedTemplate.hydratedTitleText = message.title;
1109
1095
  hydratedTemplate.hydratedContentText = message.caption;
1110
- };
1096
+ }
1097
+ ;
1111
1098
  Object.assign(hydratedTemplate, m);
1112
1099
  }
1113
1100
  if (hasOptionalProperty(message, 'footer')) {
@@ -1119,7 +1106,7 @@ export const generateWAMessageContent = async (message, options) => {
1119
1106
  hydratedFourRowTemplate: hydratedTemplate,
1120
1107
  hydratedTemplate: hydratedTemplate
1121
1108
  }
1122
- }
1109
+ };
1123
1110
  }
1124
1111
  else if (hasNonNullishProperty(message, 'nativeFlow')) {
1125
1112
  const interactiveMessage = {
@@ -1144,9 +1131,9 @@ export const generateWAMessageContent = async (message, options) => {
1144
1131
  }
1145
1132
  else {
1146
1133
  if (hasOptionalProperty(message, 'caption')) {
1147
- const isValidHeader = hasValidInteractiveHeader(m)
1134
+ const isValidHeader = hasValidInteractiveHeader(m);
1148
1135
  if (!isValidHeader) {
1149
- throw new Boom('Invalid media type for interactive message header', { statusCode: 400 });
1136
+ throw new Boom('Invalid media type for interactive message header', { statusCode: 400 });
1150
1137
  }
1151
1138
  interactiveMessage.header = {
1152
1139
  title: message.title || '',
@@ -1177,17 +1164,17 @@ export const generateWAMessageContent = async (message, options) => {
1177
1164
  else if (hasNonNullishProperty(message, 'cards')) {
1178
1165
  const interactiveMessage = {
1179
1166
  carouselMessage: {
1180
- cards: await Promise.all(message.cards.map(async card => {
1167
+ cards: await Promise.all(message.cards.map(async (card) => {
1181
1168
  let carouselHeader = {};
1182
1169
  if (hasNonNullishProperty(card, 'product')) {
1183
1170
  carouselHeader.productMessage = await prepareProductMessage(card, options);
1184
1171
  }
1185
1172
  else {
1186
- carouselHeader = await prepareWAMessageMedia(card, options).catch(() => ({ }));
1173
+ carouselHeader = await prepareWAMessageMedia(card, options).catch(() => ({}));
1187
1174
  }
1188
- const isValidHeader = hasValidCarouselHeader(carouselHeader)
1175
+ const isValidHeader = hasValidCarouselHeader(carouselHeader);
1189
1176
  if (!isValidHeader) {
1190
- throw new Boom('Invalid media type for carousel card', { statusCode: 400 });
1177
+ throw new Boom('Invalid media type for carousel card', { statusCode: 400 });
1191
1178
  }
1192
1179
  const carouselCard = {
1193
1180
  nativeFlowMessage: prepareNativeFlowButtons(card.nativeFlow ? card : [])
@@ -1221,7 +1208,7 @@ export const generateWAMessageContent = async (message, options) => {
1221
1208
  else if (hasOptionalProperty(card, 'footer')) {
1222
1209
  carouselCard.footer = { text: card.footer };
1223
1210
  }
1224
- return carouselCard
1211
+ return carouselCard;
1225
1212
  })),
1226
1213
  carouselCardType: CarouselCardType.UNKNOWN,
1227
1214
  messageVersion: 1
@@ -1239,9 +1226,9 @@ export const generateWAMessageContent = async (message, options) => {
1239
1226
  else if (hasNonNullishProperty(message, 'requestPaymentFrom')) {
1240
1227
  const requestPaymentMessage = {
1241
1228
  amount: {
1242
- currencyCode: 'IDR',
1243
- offset: 1000,
1244
- value: 1000
1229
+ currencyCode: 'IDR',
1230
+ offset: 1000,
1231
+ value: 1000
1245
1232
  },
1246
1233
  amount1000: 1000,
1247
1234
  currencyCodeIso4217: 'IDR',
@@ -1321,18 +1308,21 @@ export const generateWAMessageContent = async (message, options) => {
1321
1308
  (hasOptionalProperty(message, 'mentionAll') && message.mentionAll)) {
1322
1309
  const messageType = Object.keys(m)[0];
1323
1310
  const key = m[messageType];
1324
- if ('contextInfo' in key && !!key.contextInfo) {
1325
- key.contextInfo.mentionedJid = message.mentions || [];
1311
+ if (key && 'contextInfo' in key) {
1312
+ key.contextInfo = key.contextInfo || {};
1313
+ if (message.mentions?.length) {
1314
+ key.contextInfo.mentionedJid = message.mentions;
1315
+ }
1316
+ if (message.mentionAll) {
1317
+ key.contextInfo.nonJidMentions = 1;
1318
+ }
1326
1319
  }
1327
1320
  else if (key) {
1328
1321
  key.contextInfo = {
1329
- mentionedJid: message.mentions || []
1322
+ mentionedJid: message.mentions,
1323
+ nonJidMentions: message.mentionAll ? 1 : 0
1330
1324
  };
1331
1325
  }
1332
- if (message.mentionAll) {
1333
- key.contextInfo.mentionedJid = [];
1334
- key.contextInfo.nonJidMentions = 1;
1335
- }
1336
1326
  }
1337
1327
  if (hasOptionalProperty(message, 'contextInfo') && !!message.contextInfo) {
1338
1328
  const messageType = Object.keys(m)[0];
@@ -1354,7 +1344,7 @@ export const generateWAMessageContent = async (message, options) => {
1354
1344
  else if (key) {
1355
1345
  key.contextInfo = {
1356
1346
  isGroupStatus: message.groupStatus
1357
- }
1347
+ };
1358
1348
  }
1359
1349
  m = { groupStatusMessageV2: { message: m } };
1360
1350
  delete message.groupStatus;
@@ -1396,9 +1386,9 @@ export const generateWAMessageContent = async (message, options) => {
1396
1386
  key: message.edit,
1397
1387
  editedMessage: m,
1398
1388
  timestampMs: Date.now(),
1399
- type: ProtocolType.MESSAGE_EDIT
1389
+ type: WAProto.Message.ProtocolMessage.Type.MESSAGE_EDIT
1400
1390
  }
1401
- }
1391
+ };
1402
1392
  }
1403
1393
  if (shouldIncludeReportingToken(m)) {
1404
1394
  m.messageContextInfo = m.messageContextInfo || {};
@@ -1406,7 +1396,7 @@ export const generateWAMessageContent = async (message, options) => {
1406
1396
  m.messageContextInfo.messageSecret = randomBytes(32);
1407
1397
  }
1408
1398
  }
1409
- return proto.Message.create(m);
1399
+ return WAProto.Message.create(m);
1410
1400
  };
1411
1401
  export const generateWAMessageFromContent = (jid, message, options) => {
1412
1402
  // set timestamp to now
@@ -1414,8 +1404,8 @@ export const generateWAMessageFromContent = (jid, message, options) => {
1414
1404
  if (!options.timestamp) {
1415
1405
  options.timestamp = Date.now();
1416
1406
  }
1417
- const messageContextInfo = message.messageContextInfo
1418
1407
  const innerMessage = normalizeMessageContent(message);
1408
+ const messageContextInfo = message.messageContextInfo;
1419
1409
  const key = getContentType(innerMessage);
1420
1410
  const timestamp = unixTimestampSeconds(options.timestamp);
1421
1411
  const isNewsletter = isJidNewsletter(jid);
@@ -1468,9 +1458,9 @@ export const generateWAMessageFromContent = (jid, message, options) => {
1468
1458
  recipientKeyHash: randomBytes(10),
1469
1459
  recipientTimestamp: unixTimestampSeconds()
1470
1460
  };
1471
- messageContextInfo.deviceListMetadataVersion = 2
1461
+ messageContextInfo.deviceListMetadataVersion = 2;
1472
1462
  }
1473
- message = proto.Message.create(message);
1463
+ message = WAProto.Message.create(message);
1474
1464
  const messageJSON = {
1475
1465
  key: {
1476
1466
  remoteJid: jid,
@@ -1485,14 +1475,11 @@ export const generateWAMessageFromContent = (jid, message, options) => {
1485
1475
  };
1486
1476
  return WAProto.WebMessageInfo.fromObject(messageJSON);
1487
1477
  };
1488
- export const generateWAMessage = async (jid, content, options = {}) => {
1478
+ export const generateWAMessage = async (jid, content, options) => {
1489
1479
  // ensure msg ID is with every log
1490
1480
  options.logger = options?.logger?.child({ msgId: options.messageId });
1491
1481
  // Pass jid in the options to generateWAMessageContent
1492
- if (jid && typeof options === 'object') {
1493
- options.jid = jid;
1494
- }
1495
- return generateWAMessageFromContent(jid, await generateWAMessageContent(content, options), options);
1482
+ return generateWAMessageFromContent(jid, await generateWAMessageContent(content, { ...options, jid }), options);
1496
1483
  };
1497
1484
  /** Get the key to access the true type of content */
1498
1485
  export const getContentType = (content) => {
@@ -1521,10 +1508,8 @@ export const normalizeMessageContent = (content) => {
1521
1508
  content = inner.message;
1522
1509
  }
1523
1510
  return content;
1524
- // Lia@Changes 03-02-26 --- Add all futureProofMessage into getFutureProofMessage()
1525
1511
  function getFutureProofMessage(message) {
1526
- return (
1527
- message?.associatedChildMessage ||
1512
+ return (message?.associatedChildMessage ||
1528
1513
  message?.botForwardedMessage ||
1529
1514
  message?.botInvokeMessage ||
1530
1515
  message?.botTaskMessage ||
@@ -1538,16 +1523,18 @@ export const normalizeMessageContent = (content) => {
1538
1523
  message?.groupStatusMessageV2 ||
1539
1524
  message?.limitSharingMessage ||
1540
1525
  message?.lottieStickerMessage ||
1526
+ message?.newsletterAdminProfileMessage ||
1527
+ message?.newsletterAdminProfileMessageV2 ||
1541
1528
  message?.pollCreationMessageV4 ||
1542
1529
  message?.pollCreationOptionImageMessage ||
1543
1530
  message?.questionMessage ||
1544
1531
  message?.questionReplyMessage ||
1532
+ message?.spoilerMessage ||
1545
1533
  message?.statusAddYours ||
1546
1534
  message?.statusMentionMessage ||
1547
1535
  message?.viewOnceMessage ||
1548
1536
  message?.viewOnceMessageV2 ||
1549
- message?.viewOnceMessageV2Extension
1550
- );
1537
+ message?.viewOnceMessageV2Extension);
1551
1538
  }
1552
1539
  };
1553
1540
  /**
@@ -1786,8 +1773,7 @@ export const assertMediaContent = (content) => {
1786
1773
  */
1787
1774
  const isAnimatedWebP = (buffer) => {
1788
1775
  // WebP must start with RIFF....WEBP
1789
- if (
1790
- buffer.length < 12 ||
1776
+ if (buffer.length < 12 ||
1791
1777
  buffer[0] !== 0x52 ||
1792
1778
  buffer[1] !== 0x49 ||
1793
1779
  buffer[2] !== 0x46 ||
@@ -1795,10 +1781,10 @@ const isAnimatedWebP = (buffer) => {
1795
1781
  buffer[8] !== 0x57 ||
1796
1782
  buffer[9] !== 0x45 ||
1797
1783
  buffer[10] !== 0x42 ||
1798
- buffer[11] !== 0x50
1799
- ) {
1784
+ buffer[11] !== 0x50) {
1800
1785
  return false;
1801
- };
1786
+ }
1787
+ ;
1802
1788
  // Parse chunks starting after RIFF header (12 bytes)
1803
1789
  let offset = 12;
1804
1790
  while (offset < buffer.length - 8) {
@@ -1811,23 +1797,27 @@ const isAnimatedWebP = (buffer) => {
1811
1797
  const flags = buffer[flagsOffset];
1812
1798
  if (flags & 0x02) {
1813
1799
  return true;
1814
- };
1815
- };
1816
- } else if (chunkFourCC === 'ANIM' || chunkFourCC === 'ANMF') {
1800
+ }
1801
+ ;
1802
+ }
1803
+ ;
1804
+ }
1805
+ else if (chunkFourCC === 'ANIM' || chunkFourCC === 'ANMF') {
1817
1806
  // ANIM or ANMF chunks indicate animation
1818
1807
  return true;
1819
- };
1808
+ }
1809
+ ;
1820
1810
  // Move to next chunk (chunk size + 8 bytes header, padded to even)
1821
1811
  offset += 8 + chunkSize + (chunkSize % 2);
1822
- };
1812
+ }
1813
+ ;
1823
1814
  return false;
1824
1815
  };
1825
1816
  /**
1826
1817
  * Checks if a buffer is a WebP file
1827
1818
  */
1828
1819
  const isWebPBuffer = (buffer) => {
1829
- return (
1830
- buffer.length >= 12 &&
1820
+ return (buffer.length >= 12 &&
1831
1821
  buffer[0] === 0x52 &&
1832
1822
  buffer[1] === 0x49 &&
1833
1823
  buffer[2] === 0x46 &&
@@ -1835,8 +1825,7 @@ const isWebPBuffer = (buffer) => {
1835
1825
  buffer[8] === 0x57 &&
1836
1826
  buffer[9] === 0x45 &&
1837
1827
  buffer[10] === 0x42 &&
1838
- buffer[11] === 0x50
1839
- );
1828
+ buffer[11] === 0x50);
1840
1829
  };
1841
1830
  /**
1842
1831
  * Lia@Changes 30-01-26
@@ -1846,8 +1835,7 @@ const isWebPBuffer = (buffer) => {
1846
1835
  * such as buttons or other supported interactive types.
1847
1836
  */
1848
1837
  export const shouldIncludeBizBinaryNode = (message) => {
1849
- const hasValidInteractive =
1850
- message.interactiveMessage &&
1838
+ const hasValidInteractive = message.interactiveMessage &&
1851
1839
  !message.interactiveMessage.carouselMessage &&
1852
1840
  !message.interactiveMessage.collectionMessage &&
1853
1841
  !message.interactiveMessage.shopStorefrontMessage;
@@ -1855,4 +1843,5 @@ export const shouldIncludeBizBinaryNode = (message) => {
1855
1843
  message.interactiveMessage ||
1856
1844
  message.listMessage ||
1857
1845
  hasValidInteractive);
1858
- };
1846
+ };
1847
+ //# sourceMappingURL=messages.js.map