@violetix/baileys 0.0.0-stage → 0.3.18

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 (452) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +2843 -2
  3. package/WAProto/index.d.ts +15932 -0
  4. package/WAProto/index.js +115856 -0
  5. package/engine-requirements.js +13 -0
  6. package/lib/Defaults/index.d.ts +145 -0
  7. package/lib/Defaults/index.d.ts.map +1 -0
  8. package/lib/Defaults/index.js +157 -0
  9. package/lib/Defaults/index.js.map +1 -0
  10. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  11. package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
  12. package/lib/Signal/Group/ciphertext-message.js +12 -0
  13. package/lib/Signal/Group/ciphertext-message.js.map +1 -0
  14. package/lib/Signal/Group/group-session-builder.d.ts +8 -0
  15. package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
  16. package/lib/Signal/Group/group-session-builder.js +30 -0
  17. package/lib/Signal/Group/group-session-builder.js.map +1 -0
  18. package/lib/Signal/Group/group_cipher.d.ts +11 -0
  19. package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
  20. package/lib/Signal/Group/group_cipher.js +82 -0
  21. package/lib/Signal/Group/group_cipher.js.map +1 -0
  22. package/lib/Signal/Group/index.d.ts +12 -0
  23. package/lib/Signal/Group/index.d.ts.map +1 -0
  24. package/lib/Signal/Group/index.js +12 -0
  25. package/lib/Signal/Group/index.js.map +1 -0
  26. package/lib/Signal/Group/keyhelper.d.ts +7 -0
  27. package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
  28. package/lib/Signal/Group/keyhelper.js +18 -0
  29. package/lib/Signal/Group/keyhelper.js.map +1 -0
  30. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  31. package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
  32. package/lib/Signal/Group/sender-chain-key.js +26 -0
  33. package/lib/Signal/Group/sender-chain-key.js.map +1 -0
  34. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  35. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
  36. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  37. package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
  38. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  39. package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
  40. package/lib/Signal/Group/sender-key-message.js +66 -0
  41. package/lib/Signal/Group/sender-key-message.js.map +1 -0
  42. package/lib/Signal/Group/sender-key-name.d.ts +12 -0
  43. package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
  44. package/lib/Signal/Group/sender-key-name.js +48 -0
  45. package/lib/Signal/Group/sender-key-name.js.map +1 -0
  46. package/lib/Signal/Group/sender-key-record.d.ts +13 -0
  47. package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
  48. package/lib/Signal/Group/sender-key-record.js +41 -0
  49. package/lib/Signal/Group/sender-key-record.js.map +1 -0
  50. package/lib/Signal/Group/sender-key-state.d.ts +17 -0
  51. package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
  52. package/lib/Signal/Group/sender-key-state.js +84 -0
  53. package/lib/Signal/Group/sender-key-state.js.map +1 -0
  54. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  55. package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
  56. package/lib/Signal/Group/sender-message-key.js +26 -0
  57. package/lib/Signal/Group/sender-message-key.js.map +1 -0
  58. package/lib/Signal/libsignal.d.ts +55 -0
  59. package/lib/Signal/libsignal.d.ts.map +1 -0
  60. package/lib/Signal/libsignal.js +403 -0
  61. package/lib/Signal/libsignal.js.map +1 -0
  62. package/lib/Signal/lid-mapping.d.ts +21 -0
  63. package/lib/Signal/lid-mapping.d.ts.map +1 -0
  64. package/lib/Signal/lid-mapping.js +277 -0
  65. package/lib/Signal/lid-mapping.js.map +1 -0
  66. package/lib/Socket/Client/index.d.ts +3 -0
  67. package/lib/Socket/Client/index.d.ts.map +1 -0
  68. package/lib/Socket/Client/index.js +3 -0
  69. package/lib/Socket/Client/index.js.map +1 -0
  70. package/lib/Socket/Client/types.d.ts +6 -0
  71. package/lib/Socket/Client/types.d.ts.map +1 -0
  72. package/lib/Socket/Client/types.js +93 -0
  73. package/lib/Socket/Client/types.js.map +1 -0
  74. package/lib/Socket/Client/websocket.d.ts +13 -0
  75. package/lib/Socket/Client/websocket.d.ts.map +1 -0
  76. package/lib/Socket/Client/websocket.js +57 -0
  77. package/lib/Socket/Client/websocket.js.map +1 -0
  78. package/lib/Socket/business.d.ts +428 -0
  79. package/lib/Socket/business.d.ts.map +1 -0
  80. package/lib/Socket/business.js +380 -0
  81. package/lib/Socket/business.js.map +1 -0
  82. package/lib/Socket/chats.d.ts +176 -0
  83. package/lib/Socket/chats.d.ts.map +1 -0
  84. package/lib/Socket/chats.js +1238 -0
  85. package/lib/Socket/chats.js.map +1 -0
  86. package/lib/Socket/communities.d.ts +595 -0
  87. package/lib/Socket/communities.d.ts.map +1 -0
  88. package/lib/Socket/communities.js +432 -0
  89. package/lib/Socket/communities.js.map +1 -0
  90. package/lib/Socket/graphql.js +908 -0
  91. package/lib/Socket/groups.d.ts +318 -0
  92. package/lib/Socket/groups.d.ts.map +1 -0
  93. package/lib/Socket/groups.js +364 -0
  94. package/lib/Socket/groups.js.map +1 -0
  95. package/lib/Socket/index.d.ts +940 -0
  96. package/lib/Socket/index.d.ts.map +1 -0
  97. package/lib/Socket/index.js +19 -0
  98. package/lib/Socket/index.js.map +1 -0
  99. package/lib/Socket/interop.js +562 -0
  100. package/lib/Socket/managed-account.js +210 -0
  101. package/lib/Socket/messages-recv.d.ts +367 -0
  102. package/lib/Socket/messages-recv.d.ts.map +1 -0
  103. package/lib/Socket/messages-recv.js +2199 -0
  104. package/lib/Socket/messages-recv.js.map +1 -0
  105. package/lib/Socket/messages-send.d.ts +364 -0
  106. package/lib/Socket/messages-send.d.ts.map +1 -0
  107. package/lib/Socket/messages-send.js +1501 -0
  108. package/lib/Socket/messages-send.js.map +1 -0
  109. package/lib/Socket/mex.d.ts +2 -0
  110. package/lib/Socket/mex.d.ts.map +1 -0
  111. package/lib/Socket/mex.js +42 -0
  112. package/lib/Socket/mex.js.map +1 -0
  113. package/lib/Socket/newsletter.d.ts +315 -0
  114. package/lib/Socket/newsletter.d.ts.map +1 -0
  115. package/lib/Socket/newsletter.js +235 -0
  116. package/lib/Socket/newsletter.js.map +1 -0
  117. package/lib/Socket/privacy.js +448 -0
  118. package/lib/Socket/registration.js +430 -0
  119. package/lib/Socket/socket.d.ts +93 -0
  120. package/lib/Socket/socket.d.ts.map +1 -0
  121. package/lib/Socket/socket.js +1272 -0
  122. package/lib/Socket/socket.js.map +1 -0
  123. package/lib/Store/index.d.ts +4 -0
  124. package/lib/Store/index.d.ts.map +1 -0
  125. package/lib/Store/index.js +4 -0
  126. package/lib/Store/index.js.map +1 -0
  127. package/lib/Store/make-in-memory-store.d.ts +63 -0
  128. package/lib/Store/make-in-memory-store.d.ts.map +1 -0
  129. package/lib/Store/make-in-memory-store.js +462 -0
  130. package/lib/Store/make-in-memory-store.js.map +1 -0
  131. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  132. package/lib/Store/make-ordered-dictionary.d.ts.map +1 -0
  133. package/lib/Store/make-ordered-dictionary.js +79 -0
  134. package/lib/Store/make-ordered-dictionary.js.map +1 -0
  135. package/lib/Store/object-repository.d.ts +11 -0
  136. package/lib/Store/object-repository.d.ts.map +1 -0
  137. package/lib/Store/object-repository.js +24 -0
  138. package/lib/Store/object-repository.js.map +1 -0
  139. package/lib/Types/Auth.d.ts +60 -0
  140. package/lib/Types/Auth.d.ts.map +1 -0
  141. package/lib/Types/Auth.js +2 -0
  142. package/lib/Types/Auth.js.map +1 -0
  143. package/lib/Types/Bussines.d.ts +9 -0
  144. package/lib/Types/Bussines.d.ts.map +1 -0
  145. package/lib/Types/Bussines.js +2 -0
  146. package/lib/Types/Bussines.js.map +1 -0
  147. package/lib/Types/Call.d.ts +22 -0
  148. package/lib/Types/Call.d.ts.map +1 -0
  149. package/lib/Types/Call.js +2 -0
  150. package/lib/Types/Call.js.map +1 -0
  151. package/lib/Types/Chat.d.ts +3 -0
  152. package/lib/Types/Chat.d.ts.map +1 -0
  153. package/lib/Types/Chat.js +8 -0
  154. package/lib/Types/Chat.js.map +1 -0
  155. package/lib/Types/Contact.d.ts +11 -0
  156. package/lib/Types/Contact.d.ts.map +1 -0
  157. package/lib/Types/Contact.js +2 -0
  158. package/lib/Types/Contact.js.map +1 -0
  159. package/lib/Types/Events.d.ts +41 -0
  160. package/lib/Types/Events.d.ts.map +1 -0
  161. package/lib/Types/Events.js +2 -0
  162. package/lib/Types/Events.js.map +1 -0
  163. package/lib/Types/GroupMetadata.d.ts +36 -0
  164. package/lib/Types/GroupMetadata.d.ts.map +1 -0
  165. package/lib/Types/GroupMetadata.js +2 -0
  166. package/lib/Types/GroupMetadata.js.map +1 -0
  167. package/lib/Types/Label.d.ts +3 -0
  168. package/lib/Types/Label.d.ts.map +1 -0
  169. package/lib/Types/Label.js +25 -0
  170. package/lib/Types/Label.js.map +1 -0
  171. package/lib/Types/LabelAssociation.d.ts +3 -0
  172. package/lib/Types/LabelAssociation.d.ts.map +1 -0
  173. package/lib/Types/LabelAssociation.js +7 -0
  174. package/lib/Types/LabelAssociation.js.map +1 -0
  175. package/lib/Types/Message.d.ts +22 -0
  176. package/lib/Types/Message.d.ts.map +1 -0
  177. package/lib/Types/Message.js +18 -0
  178. package/lib/Types/Message.js.map +1 -0
  179. package/lib/Types/Mex.d.ts +3 -0
  180. package/lib/Types/Mex.d.ts.map +1 -0
  181. package/lib/Types/Mex.js +49 -0
  182. package/lib/Types/Mex.js.map +1 -0
  183. package/lib/Types/Product.d.ts +5 -0
  184. package/lib/Types/Product.d.ts.map +1 -0
  185. package/lib/Types/Product.js +2 -0
  186. package/lib/Types/Product.js.map +1 -0
  187. package/lib/Types/RichType.d.ts +3 -0
  188. package/lib/Types/RichType.d.ts.map +1 -0
  189. package/lib/Types/RichType.js +23 -0
  190. package/lib/Types/RichType.js.map +1 -0
  191. package/lib/Types/Signal.d.ts +10 -0
  192. package/lib/Types/Signal.d.ts.map +1 -0
  193. package/lib/Types/Signal.js +2 -0
  194. package/lib/Types/Signal.js.map +1 -0
  195. package/lib/Types/Socket.d.ts +33 -0
  196. package/lib/Types/Socket.d.ts.map +1 -0
  197. package/lib/Types/Socket.js +2 -0
  198. package/lib/Types/Socket.js.map +1 -0
  199. package/lib/Types/State.d.ts +6 -0
  200. package/lib/Types/State.d.ts.map +1 -0
  201. package/lib/Types/State.js +56 -0
  202. package/lib/Types/State.js.map +1 -0
  203. package/lib/Types/USync.d.ts +9 -0
  204. package/lib/Types/USync.d.ts.map +1 -0
  205. package/lib/Types/USync.js +2 -0
  206. package/lib/Types/USync.js.map +1 -0
  207. package/lib/Types/index.d.ts +16 -0
  208. package/lib/Types/index.d.ts.map +1 -0
  209. package/lib/Types/index.js +26 -0
  210. package/lib/Types/index.js.map +1 -0
  211. package/lib/Utils/async-utils.js +7 -0
  212. package/lib/Utils/auth-utils.d.ts +59 -0
  213. package/lib/Utils/auth-utils.d.ts.map +1 -0
  214. package/lib/Utils/auth-utils.js +306 -0
  215. package/lib/Utils/auth-utils.js.map +1 -0
  216. package/lib/Utils/browser-utils.d.ts +10 -0
  217. package/lib/Utils/browser-utils.d.ts.map +1 -0
  218. package/lib/Utils/browser-utils.js +29 -0
  219. package/lib/Utils/browser-utils.js.map +1 -0
  220. package/lib/Utils/business.d.ts +50 -0
  221. package/lib/Utils/business.d.ts.map +1 -0
  222. package/lib/Utils/business.js +231 -0
  223. package/lib/Utils/business.js.map +1 -0
  224. package/lib/Utils/chat-utils.d.ts +409 -0
  225. package/lib/Utils/chat-utils.d.ts.map +1 -0
  226. package/lib/Utils/chat-utils.js +872 -0
  227. package/lib/Utils/chat-utils.js.map +1 -0
  228. package/lib/Utils/companion-reg-client-utils.d.ts +10 -0
  229. package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
  230. package/lib/Utils/companion-reg-client-utils.js +69 -0
  231. package/lib/Utils/companion-reg-client-utils.js.map +1 -0
  232. package/lib/Utils/crypto-worker.js +20 -0
  233. package/lib/Utils/crypto.d.ts +40 -0
  234. package/lib/Utils/crypto.d.ts.map +1 -0
  235. package/lib/Utils/crypto.js +118 -0
  236. package/lib/Utils/crypto.js.map +1 -0
  237. package/lib/Utils/decode-wa-message.d.ts +85 -0
  238. package/lib/Utils/decode-wa-message.d.ts.map +1 -0
  239. package/lib/Utils/decode-wa-message.js +467 -0
  240. package/lib/Utils/decode-wa-message.js.map +1 -0
  241. package/lib/Utils/event-buffer.d.ts +13 -0
  242. package/lib/Utils/event-buffer.d.ts.map +1 -0
  243. package/lib/Utils/event-buffer.js +651 -0
  244. package/lib/Utils/event-buffer.js.map +1 -0
  245. package/lib/Utils/generics.d.ts +64 -0
  246. package/lib/Utils/generics.d.ts.map +1 -0
  247. package/lib/Utils/generics.js +442 -0
  248. package/lib/Utils/generics.js.map +1 -0
  249. package/lib/Utils/history.d.ts +77 -0
  250. package/lib/Utils/history.d.ts.map +1 -0
  251. package/lib/Utils/history.js +188 -0
  252. package/lib/Utils/history.js.map +1 -0
  253. package/lib/Utils/identity-change-handler.d.ts +14 -0
  254. package/lib/Utils/identity-change-handler.d.ts.map +1 -0
  255. package/lib/Utils/identity-change-handler.js +50 -0
  256. package/lib/Utils/identity-change-handler.js.map +1 -0
  257. package/lib/Utils/index.d.ts +26 -0
  258. package/lib/Utils/index.d.ts.map +1 -0
  259. package/lib/Utils/index.js +26 -0
  260. package/lib/Utils/index.js.map +1 -0
  261. package/lib/Utils/link-preview.d.ts +13 -0
  262. package/lib/Utils/link-preview.d.ts.map +1 -0
  263. package/lib/Utils/link-preview.js +85 -0
  264. package/lib/Utils/link-preview.js.map +1 -0
  265. package/lib/Utils/listener-guard.js +48 -0
  266. package/lib/Utils/logger.d.ts +3 -0
  267. package/lib/Utils/logger.d.ts.map +1 -0
  268. package/lib/Utils/logger.js +3 -0
  269. package/lib/Utils/logger.js.map +1 -0
  270. package/lib/Utils/lt-hash.d.ts +7 -0
  271. package/lib/Utils/lt-hash.d.ts.map +1 -0
  272. package/lib/Utils/lt-hash.js +8 -0
  273. package/lib/Utils/lt-hash.js.map +1 -0
  274. package/lib/Utils/make-mutex.d.ts +7 -0
  275. package/lib/Utils/make-mutex.d.ts.map +1 -0
  276. package/lib/Utils/make-mutex.js +33 -0
  277. package/lib/Utils/make-mutex.js.map +1 -0
  278. package/lib/Utils/message-retry-manager.d.ts +80 -0
  279. package/lib/Utils/message-retry-manager.d.ts.map +1 -0
  280. package/lib/Utils/message-retry-manager.js +285 -0
  281. package/lib/Utils/message-retry-manager.js.map +1 -0
  282. package/lib/Utils/messages-media.d.ts +166 -0
  283. package/lib/Utils/messages-media.d.ts.map +1 -0
  284. package/lib/Utils/messages-media.js +957 -0
  285. package/lib/Utils/messages-media.js.map +1 -0
  286. package/lib/Utils/messages.d.ts +46 -0
  287. package/lib/Utils/messages.d.ts.map +1 -0
  288. package/lib/Utils/messages.js +1887 -0
  289. package/lib/Utils/messages.js.map +1 -0
  290. package/lib/Utils/meta-ai-msmsg.d.ts +12 -0
  291. package/lib/Utils/meta-ai-msmsg.js +124 -0
  292. package/lib/Utils/noise-handler.d.ts +21 -0
  293. package/lib/Utils/noise-handler.d.ts.map +1 -0
  294. package/lib/Utils/noise-handler.js +206 -0
  295. package/lib/Utils/noise-handler.js.map +1 -0
  296. package/lib/Utils/offline-node-processor.d.ts +10 -0
  297. package/lib/Utils/offline-node-processor.d.ts.map +1 -0
  298. package/lib/Utils/offline-node-processor.js +40 -0
  299. package/lib/Utils/offline-node-processor.js.map +1 -0
  300. package/lib/Utils/pre-key-manager.d.ts +26 -0
  301. package/lib/Utils/pre-key-manager.d.ts.map +1 -0
  302. package/lib/Utils/pre-key-manager.js +106 -0
  303. package/lib/Utils/pre-key-manager.js.map +1 -0
  304. package/lib/Utils/process-message.d.ts +102 -0
  305. package/lib/Utils/process-message.d.ts.map +1 -0
  306. package/lib/Utils/process-message.js +798 -0
  307. package/lib/Utils/process-message.js.map +1 -0
  308. package/lib/Utils/reporting-utils.d.ts +13 -0
  309. package/lib/Utils/reporting-utils.d.ts.map +1 -0
  310. package/lib/Utils/reporting-utils.js +258 -0
  311. package/lib/Utils/reporting-utils.js.map +1 -0
  312. package/lib/Utils/rich-message-utils.d.ts +49 -0
  313. package/lib/Utils/rich-message-utils.d.ts.map +1 -0
  314. package/lib/Utils/rich-message-utils.js +369 -0
  315. package/lib/Utils/rich-message-utils.js.map +1 -0
  316. package/lib/Utils/session-queue.js +33 -0
  317. package/lib/Utils/signal.d.ts +83 -0
  318. package/lib/Utils/signal.d.ts.map +1 -0
  319. package/lib/Utils/signal.js +201 -0
  320. package/lib/Utils/signal.js.map +1 -0
  321. package/lib/Utils/stanza-ack.d.ts +22 -0
  322. package/lib/Utils/stanza-ack.d.ts.map +1 -0
  323. package/lib/Utils/stanza-ack.js +72 -0
  324. package/lib/Utils/stanza-ack.js.map +1 -0
  325. package/lib/Utils/sync-action-utils.d.ts +3 -0
  326. package/lib/Utils/sync-action-utils.d.ts.map +1 -0
  327. package/lib/Utils/sync-action-utils.js +49 -0
  328. package/lib/Utils/sync-action-utils.js.map +1 -0
  329. package/lib/Utils/tc-token-utils.d.ts +30 -0
  330. package/lib/Utils/tc-token-utils.d.ts.map +1 -0
  331. package/lib/Utils/tc-token-utils.js +164 -0
  332. package/lib/Utils/tc-token-utils.js.map +1 -0
  333. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
  334. package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
  335. package/lib/Utils/use-multi-file-auth-state.js +175 -0
  336. package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
  337. package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
  338. package/lib/Utils/use-single-file-auth-state.d.ts.map +1 -0
  339. package/lib/Utils/use-single-file-auth-state.js +109 -0
  340. package/lib/Utils/use-single-file-auth-state.js.map +1 -0
  341. package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
  342. package/lib/Utils/use-sqlite-auth-state.d.ts.map +1 -0
  343. package/lib/Utils/use-sqlite-auth-state.js +109 -0
  344. package/lib/Utils/use-sqlite-auth-state.js.map +1 -0
  345. package/lib/Utils/validate-connection.d.ts +44 -0
  346. package/lib/Utils/validate-connection.d.ts.map +1 -0
  347. package/lib/Utils/validate-connection.js +210 -0
  348. package/lib/Utils/validate-connection.js.map +1 -0
  349. package/lib/Utils/worker-pool.js +73 -0
  350. package/lib/WABinary/constants.d.ts +62 -0
  351. package/lib/WABinary/constants.d.ts.map +1 -0
  352. package/lib/WABinary/constants.js +1467 -0
  353. package/lib/WABinary/constants.js.map +1 -0
  354. package/lib/WABinary/decode.d.ts +10 -0
  355. package/lib/WABinary/decode.d.ts.map +1 -0
  356. package/lib/WABinary/decode.js +262 -0
  357. package/lib/WABinary/decode.js.map +1 -0
  358. package/lib/WABinary/encode.d.ts +3 -0
  359. package/lib/WABinary/encode.d.ts.map +1 -0
  360. package/lib/WABinary/encode.js +220 -0
  361. package/lib/WABinary/encode.js.map +1 -0
  362. package/lib/WABinary/generic-utils.d.ts +77 -0
  363. package/lib/WABinary/generic-utils.d.ts.map +1 -0
  364. package/lib/WABinary/generic-utils.js +226 -0
  365. package/lib/WABinary/generic-utils.js.map +1 -0
  366. package/lib/WABinary/index.d.ts +6 -0
  367. package/lib/WABinary/index.d.ts.map +1 -0
  368. package/lib/WABinary/index.js +6 -0
  369. package/lib/WABinary/index.js.map +1 -0
  370. package/lib/WABinary/jid-utils.d.ts +29 -0
  371. package/lib/WABinary/jid-utils.d.ts.map +1 -0
  372. package/lib/WABinary/jid-utils.js +96 -0
  373. package/lib/WABinary/jid-utils.js.map +1 -0
  374. package/lib/WABinary/types.d.ts +6 -0
  375. package/lib/WABinary/types.d.ts.map +1 -0
  376. package/lib/WABinary/types.js +2 -0
  377. package/lib/WABinary/types.js.map +1 -0
  378. package/lib/WAM/BinaryInfo.d.ts +8 -0
  379. package/lib/WAM/BinaryInfo.d.ts.map +1 -0
  380. package/lib/WAM/BinaryInfo.js +10 -0
  381. package/lib/WAM/BinaryInfo.js.map +1 -0
  382. package/lib/WAM/constants.d.ts +34927 -0
  383. package/lib/WAM/constants.d.ts.map +1 -0
  384. package/lib/WAM/constants.js +22853 -0
  385. package/lib/WAM/constants.js.map +1 -0
  386. package/lib/WAM/encode.d.ts +2 -0
  387. package/lib/WAM/encode.d.ts.map +1 -0
  388. package/lib/WAM/encode.js +150 -0
  389. package/lib/WAM/encode.js.map +1 -0
  390. package/lib/WAM/index.d.ts +4 -0
  391. package/lib/WAM/index.d.ts.map +1 -0
  392. package/lib/WAM/index.js +4 -0
  393. package/lib/WAM/index.js.map +1 -0
  394. package/lib/WAUSync/Protocols/USyncBusinessProtocol.d.ts +8 -0
  395. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +99 -0
  396. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +37 -0
  397. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
  398. package/lib/WAUSync/Protocols/USyncContactProtocol.js +53 -0
  399. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
  400. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  401. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
  402. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
  403. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
  404. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  405. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
  406. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  407. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
  408. package/lib/WAUSync/Protocols/USyncFeatureProtocol.d.ts +9 -0
  409. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +70 -0
  410. package/lib/WAUSync/Protocols/USyncPictureProtocol.d.ts +12 -0
  411. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +28 -0
  412. package/lib/WAUSync/Protocols/USyncSidelistProtocol.d.ts +10 -0
  413. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +25 -0
  414. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  415. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
  416. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  417. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
  418. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.d.ts +11 -0
  419. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +34 -0
  420. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  421. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
  422. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +31 -0
  423. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
  424. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
  425. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
  426. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  427. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
  428. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +15 -0
  429. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
  430. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  431. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
  432. package/lib/WAUSync/Protocols/index.d.ts +11 -0
  433. package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
  434. package/lib/WAUSync/Protocols/index.js +11 -0
  435. package/lib/WAUSync/Protocols/index.js.map +1 -0
  436. package/lib/WAUSync/USyncQuery.d.ts +32 -0
  437. package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
  438. package/lib/WAUSync/USyncQuery.js +185 -0
  439. package/lib/WAUSync/USyncQuery.js.map +1 -0
  440. package/lib/WAUSync/USyncUser.d.ts +25 -0
  441. package/lib/WAUSync/USyncUser.d.ts.map +1 -0
  442. package/lib/WAUSync/USyncUser.js +48 -0
  443. package/lib/WAUSync/USyncUser.js.map +1 -0
  444. package/lib/WAUSync/index.d.ts +4 -0
  445. package/lib/WAUSync/index.d.ts.map +1 -0
  446. package/lib/WAUSync/index.js +4 -0
  447. package/lib/WAUSync/index.js.map +1 -0
  448. package/lib/index.d.ts +12 -0
  449. package/lib/index.d.ts.map +1 -0
  450. package/lib/index.js +12 -0
  451. package/lib/index.js.map +1 -0
  452. package/package.json +122 -5
package/README.md CHANGED
@@ -1,3 +1,2844 @@
1
- # Temporary Holding Version
1
+ <h1 align="center">@violetix/baileys</h1>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p align="center">
4
+ A WhatsApp Web API for Node — Baileys v7 with interactive messages, albums, payment
5
+ messages, newsletter media, and the protocol surface upstream does not expose yet.
6
+ <br><br>
7
+ <a href="https://www.npmjs.com/package/@violetix/baileys">
8
+ <img src="https://img.shields.io/npm/v/@violetix/baileys?style=for-the-badge&logo=npm" alt="npm version" />
9
+ </a>
10
+ <a href="https://www.npmjs.com/package/@violetix/baileys">
11
+ <img src="https://img.shields.io/npm/dm/@violetix/baileys?style=for-the-badge&logo=npm" alt="npm downloads" />
12
+ </a>
13
+ <a href="https://github.com/cv3inx/bv2">
14
+ <img src="https://img.shields.io/github/stars/cv3inx/bv2?style=for-the-badge&logo=github" alt="GitHub stars" />
15
+ </a>
16
+ <a href="LICENSE">
17
+ <img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge" alt="MIT license" />
18
+ </a>
19
+ <a href="https://nodejs.org">
20
+ <img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&labelColor=green&logoColor=white&style=for-the-badge" alt="Node.js 20 or newer" />
21
+ </a>
22
+ <a href="#-import-esm--cjs">
23
+ <img src="https://img.shields.io/badge/ESM-only?logo=javascript&labelColor=yellow&logoColor=black&style=for-the-badge" alt="ES modules" />
24
+ </a>
25
+ </p>
26
+
27
+ ```bash
28
+ npm i @violetix/baileys
29
+ ```
30
+
31
+ <details>
32
+ <summary><b>📋 Table of contents</b></summary>
33
+
34
+ - [📥 Installation](#-installation)
35
+ - [🧩 Import (ESM & CJS)](#-import-esm--cjs)
36
+ - [🌐 Connect to WhatsApp (Quick Step)](#-connect-to-whatsapp-quick-step)
37
+ - [🔐 Auth State](#-auth-state)
38
+ - [🗄️ Implementing Data Store](#%EF%B8%8F-implementing-data-store)
39
+ - [🪪 WhatsApp IDs Explain](#-whatsapp-ids-explain)
40
+ - [⚡ Why this fork exists](#-why-this-fork-exists)
41
+ - [🛠️ Upstream Fixes & Improvements](#%EF%B8%8F-upstream-fixes--improvements)
42
+ - [📨 Messages Handling & Compatibility](#-messages-handling--compatibility)
43
+ - [🧩 Additional Message Options](#-additional-message-options)
44
+ - [🆕 WhatsApp Protocol Extensions](#-whatsapp-protocol-extensions)
45
+ - [✉️ Sending Messages](#%EF%B8%8F-sending-messages)
46
+ - [🔠 Text](#-text)
47
+ - [🔔 Mention](#-mention)
48
+ - [😁 Reaction](#-reaction)
49
+ - [📌 Pin Message](#-pin-message)
50
+ - [🔖 Keep Chat](#-keep-chat)
51
+ - [➡️ Forward Message](#%EF%B8%8F-forward-message)
52
+ - [👤 Contact](#-contact)
53
+ - [📍 Location](#-location)
54
+ - [🗓️ Event](#%EF%B8%8F-event)
55
+ - [👥 Group Invite](#-group-invite)
56
+ - [🛍️ Product](#%EF%B8%8F-product)
57
+ - [📊 Poll](#-poll)
58
+ - [💭 Button Response](#-button-response)
59
+ - [✨ Rich Response](#-rich-response)
60
+ - [🧾 Message with Code Block](#-message-with-code-block)
61
+ - [🌏 Message with Inline Entities](#-message-with-inline-entities)
62
+ - [📋 Message with Table](#-message-with-table)
63
+ - [🎞️ Status Mention](#%EF%B8%8F-status-mention)
64
+ - [📁 Sending Media Messages](#-sending-media-messages)
65
+ - [🖼️ Image](#%EF%B8%8F-image)
66
+ - [🎥 Video](#-video)
67
+ - [📃 Sticker](#-sticker)
68
+ - [💽 Audio](#-audio)
69
+ - [🗂️ Document](#%EF%B8%8F-document)
70
+ - [🖼️ Album (Image & Video)](#%EF%B8%8F-album-image--video)
71
+ - [📦 Sticker Pack](#-sticker-pack)
72
+ - [📤 Downloading Media](#-downloading-media)
73
+ - [👉🏻 Sending Interactive Messages](#-sending-interactive-messages)
74
+ - [🔘 Buttons](#-buttons)
75
+ - [📋 List](#-list)
76
+ - [🗄️ Interactive](#%EF%B8%8F-interactive)
77
+ - [🫙 Hydrated Template](#-hydrated-template)
78
+ - [💳 Sending Payment Messages](#-sending-payment-messages)
79
+ - [➕ Invite Payment](#-invite-payment)
80
+ - [🧾 Invoice](#-invoice)
81
+ - [🛍️ Order](#%EF%B8%8F-order)
82
+ - [💳 Request Payment](#-request-payment)
83
+ - [👁️ Other Message Options](#%EF%B8%8F-other-message-options)
84
+ - [🤖 AI Icon](#-ai-icon)
85
+ - [🕒 Ephemeral](#-ephemeral)
86
+ - [📰 External Ad Reply](#-external-ad-reply)
87
+ - [🧑‍🧑‍🧒 Group Status](#%E2%80%8D%E2%80%8D-group-status)
88
+ - [🐱 Lottie Sticker](#-lottie-sticker)
89
+ - [🧩 Raw](#-raw)
90
+ - [🏷️ Secure Meta Service Label](#%EF%B8%8F-secure-meta-service-label)
91
+ - [📑 Spoiler](#-spoiler)
92
+ - [👁️ View Once](#%EF%B8%8F-view-once)
93
+ - [👁️ View Once V2](#%EF%B8%8F-view-once-v2)
94
+ - [👁️ View Once V2 Extension](#%EF%B8%8F-view-once-v2-extension)
95
+ - [♻️ Modify Messages](#%EF%B8%8F-modify-messages)
96
+ - [🗑️ Delete Messages](#%EF%B8%8F-delete-messages)
97
+ - [✏️ Edit Messages](#%EF%B8%8F-edit-messages)
98
+ - [🧰 Additional Contents](#-additional-contents)
99
+ - [🏷️ Find User ID (JID|PN/LID)](#%EF%B8%8F-find-user-id-jidpnlid)
100
+ - [🔑 Request Custom Pairing Code](#-request-custom-pairing-code)
101
+ - [🖼️ Image Processing](#%EF%B8%8F-image-processing)
102
+ - [📣 Newsletter Management](#-newsletter-management)
103
+ - [👥 Group Management](#-group-management)
104
+ - [👥 Community Management](#-community-management)
105
+ - [👤 Profile Management](#-profile-management)
106
+ - [🛒 Business Management](#-business-management)
107
+ - [🔐 Privacy Management](#-privacy-management)
108
+ - [🆔 Username Management](#-username-management)
109
+ - [🔍 USync Queries](#-usync-queries)
110
+ - [🤝 Interoperability (BirdyChat & Haiket)](#-interoperability-birdychat--haiket)
111
+ - [🔒 Account Security (Password & Passkey)](#-account-security-password--passkey)
112
+ - [👪 Managed Accounts & Payments](#-managed-accounts--payments)
113
+ - [🌐 HTTPS GraphQL (Meta AI & Imagine)](#-https-graphql-meta-ai--imagine)
114
+ - [📡 Events](#-events)
115
+ - [Development checks](#development-checks)
116
+ - [📦 Fork Base](#-fork-base)
117
+ - [📣 Credits](#-credits)
118
+
119
+ </details>
120
+
121
+ ## 📥 Installation
122
+
123
+ Requires **Node.js 20 or newer**. The package uses **ES modules (ESM)**.
124
+ Save examples as `.mjs` files, or set `"type": "module"` in your application's `package.json`.
125
+
126
+ ```bash
127
+ # from npm
128
+ npm i @violetix/baileys
129
+
130
+ # or straight from the repository, to track main ahead of a release
131
+ npm i github:cv3inx/bv2
132
+ ```
133
+
134
+ Equivalent `package.json` entries — one or the other, not both:
135
+
136
+ ```json
137
+ {
138
+ "dependencies": {
139
+ "@violetix/baileys": "^0.3.18"
140
+ }
141
+ }
142
+ ```
143
+
144
+ ```json
145
+ {
146
+ "dependencies": {
147
+ "@violetix/baileys": "github:cv3inx/bv2"
148
+ }
149
+ }
150
+ ```
151
+
152
+ ### 🧩 Import (ESM & CJS)
153
+
154
+ ES modules:
155
+
156
+ ```javascript
157
+ import makeWASocket, { useMultiFileAuthState } from "@violetix/baileys";
158
+ ```
159
+
160
+ From CommonJS, use dynamic `import()` inside an async function:
161
+
162
+ ```javascript
163
+ async function main() {
164
+ const { makeWASocket, useMultiFileAuthState } = await import("@violetix/baileys");
165
+ // Create your socket here.
166
+ }
167
+
168
+ main().catch(console.error);
169
+ ```
170
+
171
+ ## 🌐 Connect to WhatsApp (Quick Step)
172
+
173
+ 1. Install the package and the logger used by this example:
174
+
175
+ ```bash
176
+ npm install @violetix/baileys pino
177
+ ```
178
+
179
+ 2. Save the following code as `index.mjs`. Replace `myPhoneNumber` with your WhatsApp number, including the country code and using digits only.
180
+
181
+ ```javascript
182
+ import {
183
+ makeWASocket,
184
+ delay,
185
+ DisconnectReason,
186
+ fetchLatestWaWebVersion,
187
+ useMultiFileAuthState,
188
+ } from "@violetix/baileys";
189
+ import pino from "pino";
190
+
191
+ const myPhoneNumber = "6288888888888";
192
+ const logger = pino({ level: "silent" });
193
+
194
+ async function connectToWhatsApp() {
195
+ const { state, saveCreds } = await useMultiFileAuthState("session");
196
+ const sock = makeWASocket({
197
+ logger,
198
+ auth: state,
199
+ // Optional: resolve the WhatsApp Web version on each connection.
200
+ version: async () => (await fetchLatestWaWebVersion()).version,
201
+ });
202
+
203
+ sock.ev.on("creds.update", saveCreds);
204
+
205
+ sock.ev.on("connection.update", async ({ connection, lastDisconnect }) => {
206
+ try {
207
+ if (connection === "close") {
208
+ const statusCode = lastDisconnect?.error?.output?.statusCode;
209
+ const shouldReconnect = statusCode !== DisconnectReason.loggedOut;
210
+ console.log("Connection closed:", lastDisconnect?.error);
211
+
212
+ if (shouldReconnect) {
213
+ await delay(3000);
214
+ await connectToWhatsApp();
215
+ } else {
216
+ console.log("Logged out. Pair a new session to connect again.");
217
+ }
218
+ } else if (connection === "open") {
219
+ console.log("Connected to WhatsApp");
220
+ }
221
+ } catch (error) {
222
+ console.error("Connection error:", error);
223
+ }
224
+ });
225
+
226
+ sock.ev.on("messages.upsert", async ({ type, messages }) => {
227
+ if (type !== "notify") return;
228
+
229
+ for (const message of messages) {
230
+ const jid = message.key.remoteJid;
231
+ if (!message.message || message.key.fromMe || !jid) continue;
232
+ if (!jid.endsWith("@s.whatsapp.net") && !jid.endsWith("@lid")) continue;
233
+
234
+ try {
235
+ await sock.sendMessage(jid, { text: "Hello world" });
236
+ } catch (error) {
237
+ console.error("Failed to reply:", error);
238
+ }
239
+ }
240
+ });
241
+
242
+ if (!state.creds.registered) {
243
+ // This fork waits internally until the server is ready for pairing.
244
+ const code = await sock.requestPairingCode(myPhoneNumber);
245
+ console.log("Pairing code:", code);
246
+ }
247
+ }
248
+
249
+ connectToWhatsApp().catch(console.error);
250
+ ```
251
+
252
+ 3. Run `node index.mjs`, then enter the printed pairing code in WhatsApp's linked-device flow on your phone.
253
+
254
+ This example replies to new incoming direct messages. Credentials are saved in
255
+ `session/` and reused on later runs. Keep that directory private and out of version control.
256
+
257
+ ### 🔐 Auth State
258
+
259
+ > [!NOTE]
260
+ > You can use the experimental `useSingleFileAuthState` and `useSqliteAuthState` as an alternative to `useMultiFileAuthState`. However, `useSingleFileAuthState` already includes an internal caching mechanism, so there is no need to wrap `state.keys` with `makeCacheableSignalKeyStore`.
261
+
262
+ ## 🗄️ Implementing Data Store
263
+
264
+ `makeInMemoryStore` keeps chats, contacts, and messages in memory. For larger deployments,
265
+ use a persistent store appropriate to your application's memory and retention requirements.
266
+
267
+ Add this import and create the store **outside** `connectToWhatsApp()` in the quick-start example,
268
+ after the `logger` declaration, so reconnects reuse the same store:
269
+
270
+ ```javascript
271
+ import { makeInMemoryStore } from "@violetix/baileys";
272
+
273
+ const storePath = "./store.json";
274
+ const store = makeInMemoryStore({ logger });
275
+ store.readFromFile(storePath);
276
+
277
+ // Create one persistence timer for the application, not one per reconnect.
278
+ setInterval(() => {
279
+ try {
280
+ store.writeToFile(storePath);
281
+ } catch (error) {
282
+ console.error("Failed to save the store:", error);
283
+ }
284
+ }, 180_000).unref();
285
+ ```
286
+
287
+ Add `getMessage` to the `makeWASocket` options so retries and poll updates can retrieve
288
+ previously stored messages:
289
+
290
+ ```javascript
291
+ getMessage: async (key) => {
292
+ if (!key.remoteJid || !key.id) return undefined;
293
+ const message = await store.loadMessage(key.remoteJid, key.id);
294
+ return message?.message;
295
+ },
296
+ ```
297
+
298
+ Immediately after creating each socket, bind its events to the store:
299
+
300
+ ```javascript
301
+ store.bind(sock.ev);
302
+
303
+ sock.ev.on("chats.upsert", () => {
304
+ console.log("Chats:", store.chats.all());
305
+ });
306
+
307
+ sock.ev.on("contacts.upsert", () => {
308
+ console.log("Contacts:", Object.values(store.contacts));
309
+ });
310
+ ```
311
+
312
+ The file snapshot is saved every three minutes. Keep `store.json` private as it contains chat data.
313
+
314
+ ## 🪪 WhatsApp IDs Explain
315
+
316
+ A JID identifies a WhatsApp account, group, or destination. A LID is an account identifier;
317
+ it is not a phone number and must not be converted into one by changing its suffix.
318
+
319
+ | Destination | Example JID |
320
+ | --- | --- |
321
+ | User, addressed by phone number | `19999999999@s.whatsapp.net` |
322
+ | User, addressed by LID | `12699999999@lid` |
323
+ | Group | `123456789-123345@g.us` |
324
+ | Newsletter / channel | `120111111111111111@newsletter` |
325
+ | Meta AI | `11111111111@bot` |
326
+ | Broadcast list | `[timestamp of creation]@broadcast` |
327
+ | Status / stories | `status@broadcast` |
328
+
329
+ Use the JID returned by message events or lookup APIs instead of constructing one from an assumed phone number.
330
+
331
+ > [!IMPORTANT]
332
+ > Senders who set a WhatsApp [username](#-username-management) arrive LID-addressed, and WhatsApp sends **no** phone number alongside them. This fork recovers the phone number from the local LID↔PN mapping and fills in `key.remoteJidAlt` (or `key.participantAlt` in groups).
333
+ > That recovery only works once a mapping exists — from history sync, group metadata, or an earlier chat. On a first-ever contact from a username user there is genuinely no phone number to recover, so **handle `@lid` natively** rather than assuming a phone number is always available.
334
+
335
+ ## ⚡ Why this fork exists
336
+
337
+ This is the Baileys build that runs the Violetics bot fleet: roughly 125 WhatsApp sessions inside
338
+ one Node process. Everything in the table below came out of that, and most of it is invisible until
339
+ you run more than a handful of sockets at once — a bug that costs one session a reconnect costs a
340
+ fleet an hour of flapping.
341
+
342
+ | Change | What it fixes |
343
+ | --- | --- |
344
+ | **Disconnect reasons are named** | `CB:failure` closed with the constant message `Connection Failure` for a 401 device-removal and for a transient 503 alike. A host that re-emits the close as its own `error` event forwards `message` and nothing else, so it could not tell a dead session from a blip and reconnected both — one logout became a re-auth loop and the number got banned. `end()` now appends the code and its `DisconnectReason`: `Connection Failure [401 loggedOut]`. |
345
+ | **Retry caches are bounded** | `sessionRecreateHistory` and `retryCounters` had a TTL but no `max`, and one `MessageRetryManager` exists per socket. `retryCounters` sets `updateAgeOnGet`, so a message stuck in a retry loop refreshed its own expiry indefinitely — the opposite of what a TTL backstop is for. |
346
+ | **Keepalive is per socket, and staggered** | A single process-wide 30s timer pinged every socket in the same tick, while the staleness check used the configured interval — so any `keepAliveIntervalMs` other than 30000 produced false `connectionLost` closes. Each socket now owns its timer and starts on a random offset. |
347
+ | **Housekeeping is not gated on presence** | The 24-hour `tcTokenKnownJids` prune only ran while `isOnline` was true, and `isOnline` is only ever set by `sendPresenceUpdate`. A bot that never marks itself online never pruned anything. |
348
+ | **One failing socket cannot take the host down** | A socket that failed to open, and an unhandled rejection out of `end()` mid-teardown, killed the whole process — and with it every other session sharing it. |
349
+ | **Signal writes persist before success** | Key-store writes are awaited, transaction contexts are isolated per auth store, and session deletion is reflected immediately. Close still waits for the key-store flush barrier. |
350
+ | **The offline queue drains fully** | Baileys asked for one `offline_batch` of 100 stanzas and never asked for another, so a larger backlog stayed on the server and grew on every reconnect. |
351
+
352
+ Upstream feature work — newsletter media, interactive messages, albums, the MEX and HTTPS GraphQL
353
+ surface — is listed under [Upstream Fixes & Improvements](#%EF%B8%8F-upstream-fixes--improvements)
354
+ and the sections after it.
355
+
356
+ ## 🛠️ Upstream Fixes & Improvements
357
+
358
+ - 🖼️ Fixed an issue where media could not be sent to newsletters due to an upstream issue.
359
+ - 📁 Reintroduced [`makeInMemoryStore`](#%EF%B8%8F-implementing-data-store) with a minimal ESM adaptation and small adjustments for Baileys v7.
360
+ - 📦 Switched FFmpeg execution from `exec` to `spawn` for safer process handling.
361
+ - 🗃️ Added [`@napi-rs/image`](https://www.npmjs.com/package/@napi-rs/image) as a supported image processing backend in [`getImageProcessingLibrary()`](#%EF%B8%8F-image-processing), offering a balance between performance and compatibility.
362
+ - 🪪 Recovered the phone number for LID-addressed senders that arrive without one, so [username](#-username-management) users no longer show up as a bare `@lid`.
363
+ - 📞 Routed top-level call stanzas (`<offer>`, `<terminate>`, …) that arrive outside a `<call>` wrapper, and acknowledged them — previously they were never acked, so the server kept redelivering them.
364
+ - 🤖 Decrypted `msmsg` Meta AI bot replies instead of dropping them. The `messageSecret` is captured at send time and recovered from `getMessage` after a restart.
365
+ - 🔍 Parsed the USync fields that were previously left as TODOs: per-protocol errors with backoff, cache `refresh` hints, `side_list`, per-contact privacy tokens, and blocked-by-contact detection.
366
+ - 🆔 Fixed the USync username parser, which returned `null` for the `Uint8Array` payloads the binary decoder actually produces.
367
+ - 📥 Drained the whole offline queue on reconnect. Baileys requested a single `offline_batch` of 100 stanzas and never asked for another, so any larger backlog stayed on the server and grew on every reconnect.
368
+ - 📣 Fanned out sends to broadcast lists (`<id>@broadcast`) over a sender key, using the same `statusJidList` option as status posts for the recipient list.
369
+ - 🔑 Surfaced `keyRequired` from `onWhatsAppUsername()` when the server withholds the account until the 4-digit username key is supplied; previously such rows were dropped.
370
+ - 🔔 Emitted `username.update` (a contact set or removed their `@username`), `lid-mapping.update` (a contact's LID rotated; the known phone number is carried over), and `privacy.update` (privacy settings changed on the phone) from server notifications.
371
+ - 🙈 Skipped placeholder resend requests for `<unavailable/>` messages WhatsApp marks as unrecoverable (`<bot/>`, `hosted="true"`, `type="view_once"`); the previous check compared against attribute values the server never sends.
372
+ - 🪪 Recognised own LID / hosted devices as `fromMe` in status posts and group notifications, and read `remoteJidUsername` from the `username` attribute on 1:1 messages.
373
+ - 📌 Requested `fetch_pinned_messages` on `newsletterMetadata()`, so pinned posts come back with the metadata.
374
+ - 🎞️ Attached the `streamingSidecar` WhatsApp Web sends with video and audio uploads, so recipients can seek and play while downloading. Skipped for mp4 files that are not faststart (`mdat` before `moov`), where a sidecar would make playback fail instead of falling back to a plain download.
375
+ - 🕒 Stamped `disappearingMode` (and `ephemeralSettingTimestamp` when passed via `sendMessage` options) on ephemeral messages, matching WhatsApp Web; without it the peer warns the message will not disappear.
376
+ - 🗳️ Added `decryptPollVoteWithFallback()` / `decryptEventResponseWithFallback()`, which try the poll or event creator's PN and LID forms; voters encrypt with whichever form of the creator JID they hold. Event responses now use it internally.
377
+ - 🆔 Username lookups (`onWhatsAppUsername()`) request LID addressing, as WhatsApp Web does; `USyncQuery.withContactProtocol('lid' | 'pn')` exposes the switch.
378
+ - 🗳️ Poll votes are decrypted again inside `processMessage` and surfaced as `pollUpdates` on `messages.update` (like Baileys v6.4 did), trying the creator's PN and LID forms. Requires `getMessage` to return the poll creation message.
379
+ - 🧾 `hideVoter` / `canAddOption` polls go out as `pollCreationMessageV6`, the only version that carries those flags.
380
+ - 🧠 History sync chunks are decoded one conversation at a time instead of materialising the whole `HistorySync` tree, cutting peak memory on large syncs. Output is byte-identical to the previous path.
381
+ - 🔢 `version` accepts a resolver function, and a `405 client_too_old` failure fetches the live WA Web build and applies it on the next reconnect. `fetchLatestWaWebVersion()` now times out after 10s (`timeoutMs` / `signal` options).
382
+ - 🔐 Passkey-gated (Shortcake) accounts are surfaced: `connection.update { passkeyRequired: true }` plus a warning when the server sends `passkey_prologue_request`. Expired pairing codes (`refresh_code`) are re-registered automatically with the same code, or surfaced as `connection.update { pairingCodeExpired: true }`.
383
+ - 🏢 `onWhatsAppUsername()` also reports `isBusiness` / `pnJid`; the USync business parser treats a `<error/>` child as "not a business" instead of failing the whole query, and `withBusinessProtocol(null)` asks for the verified name only.
384
+
385
+ ## 📨 Messages Handling & Compatibility
386
+
387
+ - 📩 Expanded messages support for:
388
+ - 🖼️ [Album Message](#%EF%B8%8F-album-image--video)
389
+ - 👤 [Group Status Message](#%E2%80%8D%E2%80%8D-group-status)
390
+ - 👉🏻 [Interactive Message](#-sending-interactive-messages) (buttons, lists, native flows, templates, carousels).
391
+ - 🎞️ [Status Mention Message](#%EF%B8%8F-status-mention)
392
+ - 📦 [Sticker Pack Message](#-sticker-pack)
393
+ - ✨ [Rich Response Message](#-rich-response)
394
+ - 🧾 [Message with Code Blocks](#-message-with-code-block)
395
+ - [🌏 Message with Inline Entities](#-message-with-inline-entities)
396
+ - 📋 [Message with Table](#-message-with-table)
397
+ - 💳 [Payment-related Message](#-sending-payment-messages) (payment requests, invites, orders, invoices).
398
+ - 📰 Simplified sending messages with ad thumbnail using [`externalAdReply`](#-external-ad-reply), without requiring manual `contextInfo`.
399
+ - 💭 Added support for quoting messages inside channel (newsletter).
400
+ - 🎀 Added support for [custom button icon](#%EF%B8%8F-interactive).
401
+
402
+ ## 🧩 Additional Message Options
403
+
404
+ - 👁️ Added optional boolean flags for message handling:
405
+ - 🤖 [`ai`](#-ai-icon) - AI icon on message
406
+ - 📣 [`mentionAll`](#-mention) - Mention all group participants without requiring their JIDs in `mentions` or `mentionedJid`
407
+ - 🔧 [`ephemeral`](#-ephemeral), [`groupStatus`](#%E2%80%8D%E2%80%8D-group-status), [`isLottie`](#-lottie-sticker), [`spoiler`](#-spoiler), [`viewOnce`](#%EF%B8%8F-view-once), [`viewOnceV2`](#%EF%B8%8F-view-once-v2), [`viewOnceV2Extension`](#%EF%B8%8F-view-once-v2-extension), [`interactiveAsTemplate`](#%EF%B8%8F-interactive) - Message wrappers
408
+ - 🔒 [`secureMetaServiceLabel`](#%EF%B8%8F-secure-meta-service-label) - Secure meta service label on message
409
+ - 📄 [`raw`](#-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
410
+ - 🎞️ [`statusPrivacy`](#%EF%B8%8F-status-mention) - Control who receives a status broadcast (`contacts` | `allowlist` | `denylist`)
411
+
412
+ ## 🆕 WhatsApp Protocol Extensions
413
+
414
+ Support for WhatsApp features that upstream Baileys does not expose yet.
415
+
416
+ | Feature | What it does | Reference |
417
+ | ------------------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------- |
418
+ | 🆔 **Username** | Look up accounts by `@username`, and claim / change / remove your own | [Username Management](#-username-management) |
419
+ | 🔍 **USync protocols** | Business profile, profile picture, About text, side list, and device feature queries | [USync Queries](#-usync-queries) |
420
+ | 🔐 **MEX privacy** | Privacy settings, contact allow/deny lists, About text, contact integrity checks | [Privacy Management](#-privacy-management) |
421
+ | 🤝 **Interoperability** | Cross-platform chats and groups with BirdyChat and Haiket | [Interoperability](#-interoperability-birdychat--haiket) |
422
+ | 🔒 **Account security** | Account password and passkey (FIDO2 / WebAuthn) management | [Account Security](#-account-security-password--passkey) |
423
+ | 👪 **Managed accounts** | Parental / family account linking, payments passkey, UPI onboarding | [Managed Accounts](#-managed-accounts--payments) |
424
+ | 🌐 **HTTPS GraphQL** | Meta AI memory, Imagine image/video generation, AI personas, events, payments | [HTTPS GraphQL](#-https-graphql-meta-ai--imagine) |
425
+ | 🤖 **Meta AI decryption** | Decrypts `msmsg` (`messageSecret`-encrypted) Meta AI bot replies | — |
426
+ | 📞 **Call details** | `callKey` (raw SRTP key), audio/video codecs, group roster, call-link waiting room | [Events](#-events) |
427
+ | 📰 **Newsletter status** | `newsletter.status` event for server-pushed channel posts, with engagement counters | [Events](#-events) |
428
+ | 🪪 **LID fallback** | Recovers the phone number for senders who only expose a `@lid` (e.g. username users) | [WhatsApp IDs Explain](#-whatsapp-ids-explain) |
429
+
430
+ > [!WARNING]
431
+ > These features rely on WhatsApp's internal MEX (GraphQL-over-WebSocket) and HTTPS GraphQL protocols. The numeric query IDs were captured from a specific WhatsApp client version and **may stop working after a WhatsApp update** — a rejected query usually means the ID is stale, not that the code is broken.
432
+
433
+ ## ✉️ Sending Messages
434
+
435
+ > [!NOTE]
436
+ > The examples below are snippets for an already connected `sock`. Get `jid` from
437
+ > `message.key.remoteJid`; `message` is the received message used when quoting or replying.
438
+ > Replace sample IDs and media paths with your own values. Await `sock.sendMessage(...)`
439
+ > inside your async handler when you need to handle send errors.
440
+
441
+ Examples using `fs` require this Node.js import:
442
+
443
+ ```javascript
444
+ import fs from "node:fs";
445
+ ```
446
+
447
+ ### 🔠 Text
448
+
449
+ ```javascript
450
+ // --- Send a regular text message
451
+ sock.sendMessage(
452
+ jid,
453
+ {
454
+ text: "👋🏻 Hello",
455
+ },
456
+ {
457
+ quoted: message,
458
+ },
459
+ );
460
+
461
+ // --- Send a text message with a link preview
462
+ const urlA = "https://www.npmjs.com/package/@violetix/baileys";
463
+
464
+ sock.sendMessage(jid, {
465
+ text: urlA + " 👆🏻 Check it out!",
466
+ linkPreview: {
467
+ "matched-text": urlA,
468
+ title: "🌱 @violetix/baileys",
469
+ description: "Underrated Baileys Fork",
470
+ previewType: 0, // --- Use 1 for video playback in the link preview
471
+ jpegThumbnail: fs.readFileSync("./path/to/image.jpg"),
472
+ },
473
+ });
474
+
475
+ // --- Send a text message with a large link preview and favicon
476
+ import { prepareWAMessageMedia } from "@violetix/baileys";
477
+
478
+ const urlB = "https://www.npmjs.com/package/@violetix/baileys#readme";
479
+
480
+ const { imageMessage: image } = await prepareWAMessageMedia(
481
+ {
482
+ image: {
483
+ url: "./path/to/image.jpg",
484
+ },
485
+ },
486
+ {
487
+ upload: sock.waUploadToServer,
488
+ mediaTypeOverride: "thumbnail-link",
489
+ },
490
+ );
491
+
492
+ // --- Set the thumbnail display size
493
+ image.height = 720;
494
+ image.width = 480;
495
+
496
+ sock.sendMessage(jid, {
497
+ text: urlB + " 👆🏻 Check it out!",
498
+ linkPreview: {
499
+ "matched-text": urlB,
500
+ title: "🌱 @violetix/baileys",
501
+ description: "Underrated Baileys Fork",
502
+ previewType: 0,
503
+ jpegThumbnail: fs.readFileSync("./path/to/image.jpg"),
504
+ highQualityThumbnail: image,
505
+ linkPreviewMetadata: {
506
+ linkMediaDuration: 0, // --- Duration in seconds (for video/audio content)
507
+ socialMediaPostType: 1, // --- Enum: 0 = NONE, 1 = REEL, 2 = LIVE_VIDEO, 3 = LONG_VIDEO, 4 = SINGLE_IMAGE, 5 = CAROUSEL
508
+ }, // --- Additional metadata for large link preview
509
+ },
510
+ favicon: {
511
+ url: "./path/to/tiny-image.ico",
512
+ },
513
+ });
514
+ ```
515
+
516
+ ### 🔔 Mention
517
+
518
+ ```javascript
519
+ // --- Regular mention
520
+ sock.sendMessage(
521
+ jid,
522
+ {
523
+ text: "👋🏻 Hello @628123456789",
524
+ mentions: ["628123456789@s.whatsapp.net"],
525
+ },
526
+ {
527
+ quoted: message,
528
+ },
529
+ );
530
+
531
+ // --- Mention all
532
+ sock.sendMessage(
533
+ jid,
534
+ {
535
+ text: "👋🏻 Hello @all",
536
+ mentionAll: true,
537
+ },
538
+ {
539
+ quoted: message,
540
+ },
541
+ );
542
+ ```
543
+
544
+ ### 😁 Reaction
545
+
546
+ ```javascript
547
+ sock.sendMessage(jid, {
548
+ react: {
549
+ key: message.key,
550
+ text: "✨",
551
+ },
552
+ });
553
+ ```
554
+
555
+ ### 📌 Pin Message
556
+
557
+ ```javascript
558
+ sock.sendMessage(jid, {
559
+ pin: message.key,
560
+ time: 86400, // --- Set the value in seconds: 86400 (1d), 604800 (7d), or 2592000 (30d)
561
+ type: 1, // --- Or 2 to remove
562
+ });
563
+ ```
564
+
565
+ ### 🔖 Keep Chat
566
+
567
+ > [!NOTE]
568
+ > Keep Chat can only be used in chats or groups with disappearing messages enabled.
569
+
570
+ ```javascript
571
+ sock.sendMessage(jid, {
572
+ keep: message.key,
573
+ type: 1, // --- Or 2 to remove
574
+ });
575
+ ```
576
+
577
+ ### ➡️ Forward Message
578
+
579
+ ```javascript
580
+ sock.sendMessage(jid, {
581
+ forward: message,
582
+ force: true, // --- Optional
583
+ });
584
+ ```
585
+
586
+ ### 👤 Contact
587
+
588
+ ```javascript
589
+ const vcard =
590
+ "BEGIN:VCARD\n" +
591
+ "VERSION:3.0\n" +
592
+ "FN:Lia Wynn\n" +
593
+ "ORG:Waitress;\n" +
594
+ "TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n" +
595
+ "END:VCARD";
596
+
597
+ sock.sendMessage(
598
+ jid,
599
+ {
600
+ contacts: {
601
+ displayName: "Lia Wynn",
602
+ contacts: [{ vcard }],
603
+ },
604
+ },
605
+ {
606
+ quoted: message,
607
+ },
608
+ );
609
+ ```
610
+
611
+ ### 📍 Location
612
+
613
+ ```javascript
614
+ sock.sendMessage(
615
+ jid,
616
+ {
617
+ location: {
618
+ degreesLatitude: 24.121231,
619
+ degreesLongitude: 55.1121221,
620
+ name: "👋🏻 I am here",
621
+ },
622
+ },
623
+ {
624
+ quoted: message,
625
+ },
626
+ );
627
+ ```
628
+
629
+ ### 🗓️ Event
630
+
631
+ ```javascript
632
+ sock.sendMessage(
633
+ jid,
634
+ {
635
+ event: {
636
+ name: "🎶 Meet & Mingle Party",
637
+ description:
638
+ "Meet & Mingle Party is a fun, casual gathering to connect, chat, and build new relationships within the community.",
639
+ call: "audio", // --- Or "video", this field is optional
640
+ startDate: new Date(Date.now() + 3600000),
641
+ endDate: new Date(Date.now() + 28800000),
642
+ isCancelled: false, // --- Optional
643
+ isScheduleCall: false, // --- Optional
644
+ extraGuestsAllowed: false, // --- Optional
645
+ location: {
646
+ name: "Jakarta",
647
+ degreesLatitude: -6.2,
648
+ degreesLongitude: 106.8,
649
+ },
650
+ },
651
+ },
652
+ {
653
+ quoted: message,
654
+ },
655
+ );
656
+ ```
657
+
658
+ ### 👥 Group Invite
659
+
660
+ ```javascript
661
+ const inviteCode = groupUrl.split("chat.whatsapp.com/")[1]?.split("?")[0];
662
+
663
+ const groupJid = "1201111111111@g.us";
664
+ const groupName = "@violetix/baileys";
665
+
666
+ sock.sendMessage(
667
+ jid,
668
+ {
669
+ groupInvite: {
670
+ inviteCode,
671
+ inviteExpiration: Date.now() + 86400000,
672
+ text: "👋🏻 Hello, we invite you to join our group.",
673
+ jid: groupJid,
674
+ subject: groupName,
675
+ },
676
+ },
677
+ {
678
+ quoted: message,
679
+ },
680
+ );
681
+ ```
682
+
683
+ ### 🛍️ Product
684
+
685
+ ```javascript
686
+ import { randomUUID } from "crypto";
687
+
688
+ sock.sendMessage(jid, {
689
+ image: {
690
+ url: "./path/to/image.jpg",
691
+ },
692
+ body: "👋🏻 Check my product here!",
693
+ footer: "@violetix/baileys",
694
+ product: {
695
+ currencyCode: "IDR",
696
+ description: "🛍️ Interesting product!",
697
+ priceAmount1000: 70_000_000,
698
+ productId: randomUUID(),
699
+ productImageCount: 1,
700
+ salePriceAmount1000: 65_000_000,
701
+ signedUrl: "https://www.npmjs.com/package/@violetix/baileys",
702
+ title: "📦 Starseed (Premium)",
703
+ url: "https://www.npmjs.com/package/@violetix/baileys",
704
+ },
705
+ businessOwnerJid: "0@s.whatsapp.net",
706
+ });
707
+ ```
708
+
709
+ ### 📊 Poll
710
+
711
+ ```javascript
712
+ // --- Regular poll message
713
+ sock.sendMessage(jid, {
714
+ poll: {
715
+ name: '🔥 Voting time',
716
+ values: ['Yes', 'No'],
717
+ selectableCount: 1,
718
+ toAnnouncementGroup: false,
719
+ endDate: new Date(Date.now() + 28800000), // --- Optional
720
+ hideVoter: false, // --- Optional
721
+ canAddOption: false // --- Optional
722
+ }
723
+ }, {
724
+ quoted: message
725
+ })
726
+
727
+ // --- Quiz (only for newsletter)
728
+ sock.sendMessage('1211111111111@newsletter', {
729
+ poll: {
730
+ name: '🔥 Quiz',
731
+ values: ['Yes', 'No'],
732
+ correctAnswer: 'Yes',
733
+ pollType: 1
734
+ }
735
+ }, {
736
+ quoted: message
737
+ })
738
+
739
+ // --- Poll result
740
+ sock.sendMessage(jid, {
741
+ pollResult: {
742
+ name: '📝 Poll Result',
743
+ votes: [{
744
+ name: 'Nice',
745
+ voteCount: 10
746
+ }, {
747
+ name: 'Nah',
748
+ voteCount: 2
749
+ }],
750
+ pollType: 0 // Or 1 for quiz
751
+ }
752
+ }, {
753
+ quoted: message
754
+ })
755
+
756
+ // --- Poll update: supply the encrypted vote IV and payload as Buffers/Uint8Arrays.
757
+ sock.sendMessage(jid, {
758
+ pollUpdate: {
759
+ metadata: {},
760
+ key: message.key,
761
+ vote: {
762
+ encIv: encryptedVoteIv,
763
+ encPayload: encryptedVotePayload
764
+ }
765
+ }
766
+ }, {
767
+ quoted: message
768
+ })
769
+ ```
770
+
771
+ ### 💭 Button Response
772
+
773
+ ```javascript
774
+ // --- Using buttonsResponseMessage
775
+ sock.sendMessage(
776
+ jid,
777
+ {
778
+ type: "plain",
779
+ buttonReply: {
780
+ id: "#Menu",
781
+ displayText: "✨ Interesting Menu",
782
+ },
783
+ },
784
+ {
785
+ quoted: message,
786
+ },
787
+ );
788
+
789
+ // --- Using interactiveResponseMessage
790
+ sock.sendMessage(
791
+ jid,
792
+ {
793
+ flowReply: {
794
+ format: 0,
795
+ text: "💭 Response",
796
+ name: "menu_options",
797
+ paramsJson: JSON.stringify({
798
+ id: "#Menu",
799
+ description: "✨ Interesting Menu",
800
+ }),
801
+ },
802
+ },
803
+ {
804
+ quoted: message,
805
+ },
806
+ );
807
+
808
+ // --- Using listResponseMessage
809
+ sock.sendMessage(
810
+ jid,
811
+ {
812
+ listReply: {
813
+ title: "📄 See More",
814
+ description: "✨ Interesting Menu",
815
+ id: "#Menu",
816
+ },
817
+ },
818
+ {
819
+ quoted: message,
820
+ },
821
+ );
822
+
823
+ // --- Using templateButtonReplyMessage
824
+ sock.sendMessage(
825
+ jid,
826
+ {
827
+ type: "template",
828
+ buttonReply: {
829
+ id: "#Menu",
830
+ displayText: "✨ Interesting Menu",
831
+ index: 1,
832
+ },
833
+ },
834
+ {
835
+ quoted: message,
836
+ },
837
+ );
838
+ ```
839
+
840
+ ### ✨ Rich Response
841
+
842
+ > [!NOTE]
843
+ > `richResponse[]` is a representation of [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) inside `richResponseMessage`.
844
+
845
+ > [!TIP]
846
+ > You can still use the original [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) field directly.
847
+ > The code example below is just an implementation using a helper, not a required structure.
848
+
849
+ ```javascript
850
+ sock.sendMessage(jid, {
851
+ disclaimerText: "RAW submessages structure example",
852
+ richResponse: [
853
+ {
854
+ text: "Example Usage",
855
+ },
856
+ {
857
+ language: "javascript",
858
+ code: [
859
+ {
860
+ highlightType: 0,
861
+ codeContent: 'console.log("Hello, World!")',
862
+ },
863
+ ],
864
+ },
865
+ {
866
+ text: "Pretty simple, right?\n",
867
+ },
868
+ {
869
+ text: "Comparison between Node.js, Bun, and Deno",
870
+ },
871
+ {
872
+ title: "Runtime Comparison",
873
+ table: [
874
+ {
875
+ isHeading: true,
876
+ items: ["", "Node.js", "Bun", "Deno"],
877
+ },
878
+ {
879
+ isHeading: false,
880
+ items: ["Engine", "V8 (C++)", "JavaScriptCore (C++)", "V8 (C++)"],
881
+ },
882
+ {
883
+ isHeading: false,
884
+ items: ["Performance", "4/5", "5/5", "4/5"],
885
+ },
886
+ ],
887
+ },
888
+ {
889
+ text: "Does this help clarify the differences?",
890
+ },
891
+ ],
892
+ });
893
+ ```
894
+
895
+ > [!TIP]
896
+ > You can easily add syntax highlighting by importing `tokenizeCode` directly from Baileys.
897
+
898
+ ```javascript
899
+ import { tokenizeCode } from "@violetix/baileys";
900
+
901
+ const language = "javascript";
902
+ const code = 'console.log("Hello, World!")';
903
+
904
+ sock.sendMessage(jid, {
905
+ disclaimerText: "Example of tokenizing Code Block",
906
+ richResponse: [
907
+ {
908
+ text: "Example Usage",
909
+ },
910
+ {
911
+ language,
912
+ code: tokenizeCode(code, language),
913
+ },
914
+ {
915
+ text: "Pretty simple, right?",
916
+ },
917
+ ],
918
+ });
919
+ ```
920
+
921
+ > 💡 Supported Languages: `css`, `html`, `javascript`, `typescript`, `python`, `golang`, `rust`, `c`, `c#`, `c++`, `bash`, `bat`, `powershell`.
922
+
923
+ ### 🧾 Message with Code Block
924
+
925
+ > [!NOTE]
926
+ > This feature already includes a built-in tokenizer with `tokenizeCode`.
927
+
928
+ ```javascript
929
+ sock.sendMessage(jid, {
930
+ disclaimerText: "Code Block",
931
+ headerText: "## Example Usage",
932
+ contentText: "---",
933
+ code: 'console.log("Hello, World!")',
934
+ language: "javascript",
935
+ footerText: "Pretty simple, right?",
936
+ });
937
+ ```
938
+
939
+ ### 🌏 Message with Inline Entities
940
+
941
+ ```javascript
942
+ sock.sendMessage(jid, {
943
+ disclaimerText: "Inline Entities",
944
+ headerText: "## Check Out!",
945
+ contentText: "---",
946
+ links: [
947
+ {
948
+ text: "1. Google",
949
+ title: "Popular Search Engine",
950
+ url: "https://www.google.com/",
951
+ },
952
+ {
953
+ text: "2. YouTube",
954
+ title: "Popular Streaming Platform",
955
+ url: "https://www.youtube.com/",
956
+ },
957
+ {
958
+ text: "3. Modded Baileys",
959
+ title: "Underrated Baileys Fork",
960
+ url: "https://www.npmjs.com/package/@violetix/baileys",
961
+ },
962
+ ],
963
+ footerText: "---",
964
+ });
965
+ ```
966
+
967
+ ### 📋 Message with Table
968
+
969
+ ```javascript
970
+ sock.sendMessage(jid, {
971
+ disclaimerText: "Table",
972
+ headerText: "## Comparison between Node.js, Bun, and Deno",
973
+ contentText: "---",
974
+ title: "Runtime Comparison",
975
+ table: [
976
+ ["", "Node.js", "Bun", "Deno"],
977
+ ["Engine", "V8 (C++)", "JavaScriptCore (C++)", "V8 (C++)"],
978
+ ["Performance", "4/5", "5/5", "4/5"],
979
+ ],
980
+ noHeading: false, // --- Optional
981
+ footerText: "Does this help clarify the differences?",
982
+ });
983
+ ```
984
+
985
+ ### 🎞️ Status Mention
986
+
987
+ ```javascript
988
+ sock.sendMessage([jidA, jidB, jidC], {
989
+ text: "Hello! 👋🏻",
990
+ });
991
+ ```
992
+
993
+ Pass `statusPrivacy` to control who receives a status broadcast.
994
+ ```javascript
995
+ sock.sendMessage(
996
+ "status@broadcast",
997
+ {
998
+ text: "Hello! 👋🏻",
999
+ },
1000
+ {
1001
+ statusPrivacy: "contacts", // 'contacts' | 'allowlist' | 'denylist'
1002
+ },
1003
+ );
1004
+ ```
1005
+
1006
+ > [!NOTE]
1007
+ > The allow and deny lists themselves are managed separately, via [`updatePrivacyContactList`](#-privacy-management).
1008
+
1009
+ ## 📁 Sending Media Messages
1010
+
1011
+ > [!NOTE]
1012
+ > For media messages, you can pass a `Buffer` directly, or an object with either `{ stream: Readable }` or `{ url: string }` (local file path or HTTP/HTTPS URL).
1013
+
1014
+ ### 🖼️ Image
1015
+
1016
+ ```javascript
1017
+ sock.sendMessage(
1018
+ jid,
1019
+ {
1020
+ image: {
1021
+ url: "./path/to/image.jpg",
1022
+ },
1023
+ caption: "🔥 Superb",
1024
+ },
1025
+ {
1026
+ quoted: message,
1027
+ },
1028
+ );
1029
+ ```
1030
+
1031
+ ### 🎥 Video
1032
+
1033
+ ```javascript
1034
+ sock.sendMessage(
1035
+ jid,
1036
+ {
1037
+ video: {
1038
+ url: "./path/to/video.mp4",
1039
+ },
1040
+ gifPlayback: false, // --- Set true if you want to send video as GIF
1041
+ ptv: false, // --- Set true if you want to send video as PTV
1042
+ caption: "🔥 Superb",
1043
+ },
1044
+ {
1045
+ quoted: message,
1046
+ },
1047
+ );
1048
+ ```
1049
+
1050
+ ### 📃 Sticker
1051
+
1052
+ ```javascript
1053
+ sock.sendMessage(
1054
+ jid,
1055
+ {
1056
+ sticker: {
1057
+ url: "./path/to/sticker.webp",
1058
+ },
1059
+ },
1060
+ {
1061
+ quoted: message,
1062
+ },
1063
+ );
1064
+ ```
1065
+
1066
+ ### 💽 Audio
1067
+
1068
+ ```javascript
1069
+ sock.sendMessage(
1070
+ jid,
1071
+ {
1072
+ audio: {
1073
+ url: "./path/to/audio.mp3",
1074
+ },
1075
+ ptt: false, // --- Set true if you want to send audio as Voice Note
1076
+ },
1077
+ {
1078
+ quoted: message,
1079
+ },
1080
+ );
1081
+ ```
1082
+
1083
+ ### 🗂️ Document
1084
+
1085
+ ```javascript
1086
+ sock.sendMessage(
1087
+ jid,
1088
+ {
1089
+ document: {
1090
+ url: "./path/to/document.pdf",
1091
+ },
1092
+ mimetype: "application/pdf",
1093
+ caption: "✨ My work!",
1094
+ },
1095
+ {
1096
+ quoted: message,
1097
+ },
1098
+ );
1099
+ ```
1100
+
1101
+ ### 🖼️ Album (Image & Video)
1102
+
1103
+ ```javascript
1104
+ sock.sendMessage(
1105
+ jid,
1106
+ {
1107
+ album: [
1108
+ {
1109
+ image: {
1110
+ url: "./path/to/image.jpg",
1111
+ },
1112
+ caption: "1st image",
1113
+ },
1114
+ {
1115
+ video: {
1116
+ url: "./path/to/video.mp4",
1117
+ },
1118
+ caption: "1st video",
1119
+ },
1120
+ {
1121
+ image: {
1122
+ url: "./path/to/image.jpg",
1123
+ },
1124
+ caption: "2nd image",
1125
+ },
1126
+ {
1127
+ video: {
1128
+ url: "./path/to/video.mp4",
1129
+ },
1130
+ caption: "2nd video",
1131
+ },
1132
+ ],
1133
+ },
1134
+ {
1135
+ quoted: message,
1136
+ },
1137
+ );
1138
+ ```
1139
+
1140
+ ### 📦 Sticker Pack
1141
+
1142
+ > [!IMPORTANT]
1143
+ > If `sharp` or `@napi-rs/image` is not installed, the `cover` and `stickers` must already be in WebP format.
1144
+
1145
+ ```javascript
1146
+ sock.sendMessage(
1147
+ jid,
1148
+ {
1149
+ cover: {
1150
+ url: "./path/to/image.webp",
1151
+ },
1152
+ stickers: [
1153
+ {
1154
+ data: {
1155
+ url: "./path/to/image.webp",
1156
+ },
1157
+ },
1158
+ {
1159
+ data: {
1160
+ url: "./path/to/image.webp",
1161
+ },
1162
+ },
1163
+ {
1164
+ data: {
1165
+ url: "./path/to/image.webp",
1166
+ },
1167
+ },
1168
+ ],
1169
+ name: "📦 My Sticker Pack",
1170
+ publisher: "🌟 Lia Wynn",
1171
+ description: "@violetix/baileys",
1172
+ },
1173
+ {
1174
+ quoted: message,
1175
+ },
1176
+ );
1177
+ ```
1178
+
1179
+ ## 📤 Downloading Media
1180
+
1181
+ ```javascript
1182
+ import { downloadMediaMessage } from "@violetix/baileys";
1183
+
1184
+ const media = await downloadMediaMessage(message, "buffer", {});
1185
+ ```
1186
+
1187
+ Media downloads verify the complete ciphertext HMAC before returning plaintext.
1188
+ The encrypted object is downloaded in full, even when `startByte` or `endByte` is
1189
+ specified. Byte ranges use an inclusive start and an exclusive end.
1190
+
1191
+ To keep RAM usage bounded, downloads decrypt into a temporary file and expose the
1192
+ requested range after authentication succeeds. This requires writable temporary
1193
+ disk space and delays access to the stream until verification finishes. When using
1194
+ stream mode, consume the stream or call `stream.destroy()` to release its temporary
1195
+ file. HTTP `Range` headers are removed so callers cannot accidentally bypass full
1196
+ verification. `options.signal` supports cancellation.
1197
+
1198
+ For the lower-level `downloadEncryptedContent(url, keys, options)` API, `keys` must
1199
+ include `cipherKey`, `iv`, and `macKey`; `getMediaKeys()` supplies all three.
1200
+
1201
+ ## 👉🏻 Sending Interactive Messages
1202
+
1203
+ ### 🔘 Buttons
1204
+
1205
+ ```javascript
1206
+ // --- Regular buttons message
1207
+ sock.sendMessage(
1208
+ jid,
1209
+ {
1210
+ text: "👆🏻 Buttons!",
1211
+ footer: "@violetix/baileys",
1212
+ buttons: [
1213
+ {
1214
+ text: "👋🏻 SignUp",
1215
+ id: "#SignUp",
1216
+ },
1217
+ ],
1218
+ },
1219
+ {
1220
+ quoted: message,
1221
+ },
1222
+ );
1223
+
1224
+ // --- Buttons with Media & Native Flow
1225
+ sock.sendMessage(
1226
+ jid,
1227
+ {
1228
+ image: {
1229
+ url: "./path/to/image.jpg",
1230
+ },
1231
+ caption: "👆🏻 Buttons and Native Flow!",
1232
+ footer: "@violetix/baileys",
1233
+ buttons: [
1234
+ {
1235
+ text: "👋🏻 Rating",
1236
+ id: "#Rating",
1237
+ },
1238
+ {
1239
+ text: "📋 Select",
1240
+ sections: [
1241
+ {
1242
+ title: "✨ Section 1",
1243
+ rows: [
1244
+ {
1245
+ header: "",
1246
+ title: "💭 Secret Ingredient",
1247
+ description: "",
1248
+ id: "#SecretIngredient",
1249
+ },
1250
+ ],
1251
+ },
1252
+ {
1253
+ title: "✨ Section 2",
1254
+ highlight_label: "🔥 Popular",
1255
+ rows: [
1256
+ {
1257
+ header: "",
1258
+ title: "🏷️ Coupon",
1259
+ description: "",
1260
+ id: "#CouponCode",
1261
+ },
1262
+ ],
1263
+ },
1264
+ ],
1265
+ },
1266
+ ],
1267
+ },
1268
+ {
1269
+ quoted: message,
1270
+ },
1271
+ );
1272
+ ```
1273
+
1274
+ ### 📋 List
1275
+
1276
+ > [!NOTE]
1277
+ > It only works in private chat (`@s.whatsapp.net`).
1278
+
1279
+ ```javascript
1280
+ sock.sendMessage(
1281
+ jid,
1282
+ {
1283
+ text: "📋 List!",
1284
+ footer: "@violetix/baileys",
1285
+ buttonText: "📋 Select",
1286
+ title: "👋🏻 Hello",
1287
+ sections: [
1288
+ {
1289
+ title: "🚀 Menu 1",
1290
+ rows: [
1291
+ {
1292
+ title: "✨ AI",
1293
+ description: "",
1294
+ rowId: "#AI",
1295
+ },
1296
+ ],
1297
+ },
1298
+ {
1299
+ title: "🌱 Menu 2",
1300
+ rows: [
1301
+ {
1302
+ title: "🔍 Search",
1303
+ description: "",
1304
+ rowId: "#Search",
1305
+ },
1306
+ ],
1307
+ },
1308
+ ],
1309
+ },
1310
+ {
1311
+ quoted: message,
1312
+ },
1313
+ );
1314
+ ```
1315
+
1316
+ ### 🗄️ Interactive
1317
+
1318
+ ```javascript
1319
+ // --- Native Flow
1320
+ sock.sendMessage(
1321
+ jid,
1322
+ {
1323
+ image: {
1324
+ url: "./path/to/image.jpg",
1325
+ },
1326
+ caption: "🗄️️ Interactive!",
1327
+ footer: "@violetix/baileys",
1328
+ optionText: "👉🏻 Select Options", // --- Optional, wrap all native flow into a single list
1329
+ optionTitle: "📄 Select Options", // --- Optional
1330
+ offerText: "🏷️ Newest Coupon!", // --- Optional, add an offer into message
1331
+ offerCode: "@violetix/baileys", // --- Optional
1332
+ offerUrl: "https://www.npmjs.com/package/@violetix/baileys", // --- Optional
1333
+ offerExpiration: Date.now() + 3_600_000, // --- Optional
1334
+ nativeFlow: [
1335
+ {
1336
+ text: "👋🏻 Greeting",
1337
+ id: "#Greeting",
1338
+ icon: "review", // --- Optional
1339
+ },
1340
+ {
1341
+ text: "📞 Call",
1342
+ call: "628123456789",
1343
+ },
1344
+ {
1345
+ text: "📋 Copy",
1346
+ copy: "@violetix/baileys",
1347
+ },
1348
+ {
1349
+ text: "🌐 Source",
1350
+ url: "https://www.npmjs.com/package/@violetix/baileys",
1351
+ useWebview: true, // --- Optional
1352
+ },
1353
+ {
1354
+ text: "📋 Select",
1355
+ sections: [
1356
+ {
1357
+ title: "✨ Section 1",
1358
+ rows: [
1359
+ {
1360
+ header: "",
1361
+ title: "🏷️ Coupon",
1362
+ description: "",
1363
+ id: "#CouponCode",
1364
+ },
1365
+ ],
1366
+ },
1367
+ {
1368
+ title: "✨ Section 2",
1369
+ highlight_label: "🔥 Popular",
1370
+ rows: [
1371
+ {
1372
+ header: "",
1373
+ title: "💭 Secret Ingredient",
1374
+ description: "",
1375
+ id: "#SecretIngredient",
1376
+ },
1377
+ ],
1378
+ },
1379
+ ],
1380
+ icon: "default", // --- Optional
1381
+ },
1382
+ ],
1383
+ interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
1384
+ },
1385
+ {
1386
+ quoted: message,
1387
+ },
1388
+ );
1389
+
1390
+ // --- Carousel & Native Flow
1391
+ sock.sendMessage(
1392
+ jid,
1393
+ {
1394
+ text: "🗂️ Interactive with Carousel!",
1395
+ footer: "@violetix/baileys",
1396
+ cards: [
1397
+ {
1398
+ image: {
1399
+ url: "./path/to/image.jpg",
1400
+ },
1401
+ caption: "🖼️ Image 1",
1402
+ footer: "🏷️️ Pinterest",
1403
+ nativeFlow: [
1404
+ {
1405
+ text: "🌐 Source",
1406
+ url: "https://www.npmjs.com/package/@violetix/baileys",
1407
+ useWebview: true,
1408
+ },
1409
+ ],
1410
+ },
1411
+ {
1412
+ image: {
1413
+ url: "./path/to/image.jpg",
1414
+ },
1415
+ caption: "🖼️ Image 2",
1416
+ footer: "🏷️ Pinterest",
1417
+ offerText: "🏷️ New Coupon!",
1418
+ offerCode: "@violetix/baileys",
1419
+ offerUrl: "https://www.npmjs.com/package/@violetix/baileys",
1420
+ offerExpiration: Date.now() + 3_600_000,
1421
+ nativeFlow: [
1422
+ {
1423
+ text: "🌐 Source",
1424
+ url: "https://www.npmjs.com/package/@violetix/baileys",
1425
+ },
1426
+ ],
1427
+ },
1428
+ {
1429
+ image: {
1430
+ url: "./path/to/image.jpg",
1431
+ },
1432
+ caption: "🖼️ Image 3",
1433
+ footer: "🏷️ Pinterest",
1434
+ optionText: "👉🏻 Select Options",
1435
+ optionTitle: "👉🏻 Select Options",
1436
+ offerText: "🏷️ New Coupon!",
1437
+ offerCode: "@violetix/baileys",
1438
+ offerUrl: "https://www.npmjs.com/package/@violetix/baileys",
1439
+ offerExpiration: Date.now() + 3_600_000,
1440
+ nativeFlow: [
1441
+ {
1442
+ text: "🛒 Product",
1443
+ id: "#Product",
1444
+ icon: "default",
1445
+ },
1446
+ {
1447
+ text: "🌐 Source",
1448
+ url: "https://www.npmjs.com/package/@violetix/baileys",
1449
+ },
1450
+ ],
1451
+ },
1452
+ ],
1453
+ },
1454
+ {
1455
+ quoted: message,
1456
+ },
1457
+ );
1458
+
1459
+ // --- Native Flow with Audio in the Footer
1460
+ sock.sendMessage(
1461
+ jid,
1462
+ {
1463
+ text: "🔈 Music in the footer!",
1464
+ audioFooter: {
1465
+ url: "./path/to/audio.mp3",
1466
+ }, // --- Like other media upload methods, buffers and streams are supported
1467
+ nativeFlow: [
1468
+ {
1469
+ text: "👍🏻 Good, next",
1470
+ id: "#Next",
1471
+ icon: "review",
1472
+ },
1473
+ {
1474
+ text: "👎🏻 Skip",
1475
+ id: "#Skip",
1476
+ icon: "default",
1477
+ },
1478
+ ],
1479
+ },
1480
+ {
1481
+ quoted: message,
1482
+ },
1483
+ );
1484
+ ```
1485
+
1486
+ ### 🫙 Hydrated Template
1487
+
1488
+ ```javascript
1489
+ sock.sendMessage(
1490
+ jid,
1491
+ {
1492
+ title: "👋🏻 Hello",
1493
+ image: {
1494
+ url: "./path/to/image.jpg",
1495
+ },
1496
+ caption: "🫙 Template!",
1497
+ footer: "@violetix/baileys",
1498
+ templateButtons: [
1499
+ {
1500
+ text: "👉?? Tap Here",
1501
+ id: "#Order",
1502
+ },
1503
+ {
1504
+ text: "🌐 Source",
1505
+ url: "https://www.npmjs.com/package/@violetix/baileys",
1506
+ },
1507
+ {
1508
+ text: "📞 Call",
1509
+ call: "628123456789",
1510
+ },
1511
+ ],
1512
+ },
1513
+ {
1514
+ quoted: message,
1515
+ },
1516
+ );
1517
+ ```
1518
+
1519
+ ## 💳 Sending Payment Messages
1520
+
1521
+ ### ➕ Invite Payment
1522
+
1523
+ ```javascript
1524
+ sock.sendMessage(jid, {
1525
+ paymentInviteServiceType: 3, // 1, 2, or 3
1526
+ });
1527
+ ```
1528
+
1529
+ ### 🧾 Invoice
1530
+
1531
+ > [!NOTE]
1532
+ > Invoice message are not supported yet.
1533
+
1534
+ ```javascript
1535
+ sock.sendMessage(jid, {
1536
+ image: {
1537
+ url: "./path/to/image.jpg",
1538
+ },
1539
+ invoiceNote: "🏷️ Invoice",
1540
+ });
1541
+ ```
1542
+
1543
+ ### 🛍️ Order
1544
+
1545
+ ```javascript
1546
+ sock.sendMessage(
1547
+ chat,
1548
+ {
1549
+ orderText: "🛍️ Order",
1550
+ thumbnail: fs.readFileSync("./path/to/image.jpg"), // --- Must in buffer format
1551
+ },
1552
+ {
1553
+ quoted: message,
1554
+ },
1555
+ );
1556
+ ```
1557
+
1558
+ ### 💳 Request Payment
1559
+
1560
+ ```javascript
1561
+ sock.sendMessage(jid, {
1562
+ text: "💳 Request Payment",
1563
+ requestPaymentFrom: "0@s.whatsapp.net",
1564
+ });
1565
+ ```
1566
+
1567
+ ## 👁️ Other Message Options
1568
+
1569
+ ### 🤖 AI Icon
1570
+
1571
+ > [!NOTE]
1572
+ > It only works in private chat (`@s.whatsapp.net`).
1573
+
1574
+ ```javascript
1575
+ sock.sendMessage(
1576
+ jid,
1577
+ {
1578
+ image: {
1579
+ url: "./path/to/image.jpg",
1580
+ },
1581
+ caption: "🤖 With AI icon!",
1582
+ ai: true,
1583
+ },
1584
+ {
1585
+ quoted: message,
1586
+ },
1587
+ );
1588
+ ```
1589
+
1590
+ ### 🕒 Ephemeral
1591
+
1592
+ > [!NOTE]
1593
+ > Wrap message into `ephemeralMessage`
1594
+
1595
+ ```javascript
1596
+ sock.sendMessage(jid, {
1597
+ image: {
1598
+ url: "./path/to/image.jpg",
1599
+ },
1600
+ caption: "👁️ Ephemeral",
1601
+ ephemeral: true,
1602
+ });
1603
+ ```
1604
+
1605
+ ### 📰 External Ad Reply
1606
+
1607
+ > [!NOTE]
1608
+ > Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
1609
+
1610
+ ```javascript
1611
+ sock.sendMessage(
1612
+ jid,
1613
+ {
1614
+ text: "📰 External Ad Reply",
1615
+ externalAdReply: {
1616
+ title: "📝 Did you know?",
1617
+ body: "❓ I dont know",
1618
+ thumbnail: fs.readFileSync("./path/to/image.jpg"), // --- Must in buffer format
1619
+ largeThumbnail: false, // --- Or true for bigger thumbnail
1620
+ url: "https://www.npmjs.com/package/@violetix/baileys", // --- Optional, used for WhatsApp internal thumbnail caching and direct URL
1621
+ },
1622
+ },
1623
+ {
1624
+ quoted: message,
1625
+ },
1626
+ );
1627
+ ```
1628
+
1629
+ ### 🧑‍🧑‍🧒 Group Status
1630
+
1631
+ > [!NOTE]
1632
+ > It only works in group chat (`@g.us`)
1633
+
1634
+ ```javascript
1635
+ sock.sendMessage(jid, {
1636
+ image: {
1637
+ url: "./path/to/image.jpg",
1638
+ },
1639
+ caption: "👥 Group Status!",
1640
+ groupStatus: true,
1641
+ });
1642
+ ```
1643
+
1644
+ ### 🐱 Lottie Sticker
1645
+
1646
+ > [!NOTE]
1647
+ > Wrap message into `lottieStickerMessage`
1648
+
1649
+ ```javascript
1650
+ sock.sendMessage(jid, {
1651
+ sticker: {
1652
+ url: "./path/to/sticker.webp",
1653
+ },
1654
+ isLottie: true,
1655
+ });
1656
+ ```
1657
+
1658
+ ### 🧩 Raw
1659
+
1660
+ ```javascript
1661
+ sock.sendMessage(
1662
+ jid,
1663
+ {
1664
+ extendedTextMessage: {
1665
+ text: "📃 Built manually from scratch using the raw WhatsApp proto structure",
1666
+ contextInfo: {
1667
+ externalAdReply: {
1668
+ title: "@violetix/baileys",
1669
+ thumbnail: fs.readFileSync("./path/to/image.jpg"),
1670
+ sourceApp: "whatsapp",
1671
+ showAdAttribution: true,
1672
+ mediaType: 1,
1673
+ },
1674
+ },
1675
+ },
1676
+ raw: true,
1677
+ },
1678
+ {
1679
+ quoted: message,
1680
+ },
1681
+ );
1682
+ ```
1683
+
1684
+ ### 🏷️ Secure Meta Service Label
1685
+
1686
+ ```javascript
1687
+ sock.sendMessage(jid, {
1688
+ text: "🏷️ Just a label!",
1689
+ secureMetaServiceLabel: true,
1690
+ });
1691
+ ```
1692
+
1693
+ ### 📑 Spoiler
1694
+
1695
+ > [!NOTE]
1696
+ > Wrap message into `spoilerMessage`
1697
+
1698
+ ```javascript
1699
+ sock.sendMessage(jid, {
1700
+ image: {
1701
+ url: "./path/to/image.jpg",
1702
+ },
1703
+ caption: "❔ Spoiler",
1704
+ spoiler: true,
1705
+ });
1706
+ ```
1707
+
1708
+ ### 👁️ View Once
1709
+
1710
+ > [!NOTE]
1711
+ > Wrap message into `viewOnceMessage`
1712
+
1713
+ ```javascript
1714
+ sock.sendMessage(jid, {
1715
+ image: {
1716
+ url: "./path/to/image.jpg",
1717
+ },
1718
+ caption: "👁️ View Once",
1719
+ viewOnce: true,
1720
+ });
1721
+ ```
1722
+
1723
+ ### 👁️ View Once V2
1724
+
1725
+ > [!NOTE]
1726
+ > Wrap message into `viewOnceMessageV2`
1727
+
1728
+ ```javascript
1729
+ sock.sendMessage(jid, {
1730
+ image: {
1731
+ url: "./path/to/image.jpg",
1732
+ },
1733
+ caption: "👁️ View Once V2",
1734
+ viewOnceV2: true,
1735
+ });
1736
+ ```
1737
+
1738
+ ### 👁️ View Once V2 Extension
1739
+
1740
+ > [!NOTE]
1741
+ > Wrap message into `viewOnceMessageV2Extension`
1742
+
1743
+ ```javascript
1744
+ sock.sendMessage(jid, {
1745
+ image: {
1746
+ url: "./path/to/image.jpg",
1747
+ },
1748
+ caption: "👁️ View Once V2 Extension",
1749
+ viewOnceV2Extension: true,
1750
+ });
1751
+ ```
1752
+
1753
+ ## ♻️ Modify Messages
1754
+
1755
+ ### 🗑️ Delete Messages
1756
+
1757
+ ```javascript
1758
+ sock.sendMessage(jid, {
1759
+ delete: message.key,
1760
+ });
1761
+ ```
1762
+
1763
+ ### ✏️ Edit Messages
1764
+
1765
+ ```javascript
1766
+ // --- Edit plain text
1767
+ sock.sendMessage(jid, {
1768
+ text: "✨ I mean, nice!",
1769
+ edit: message.key,
1770
+ });
1771
+
1772
+ // --- Edit media messages caption
1773
+ sock.sendMessage(jid, {
1774
+ caption: "✨ I mean, here is the image!",
1775
+ edit: message.key,
1776
+ });
1777
+ ```
1778
+
1779
+ ## 🧰 Additional Contents
1780
+
1781
+ ### 🏷️ Find User ID (JID|PN/LID)
1782
+
1783
+ > [!NOTE]
1784
+ > The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
1785
+
1786
+ ```javascript
1787
+ // --- PN (Phone Number)
1788
+ const phoneNumber = "6281111111111@s.whatsapp.net";
1789
+
1790
+ const phoneIds = await sock.findUserId(phoneNumber);
1791
+
1792
+ console.log("🏷️ Got user ID", ":", phoneIds);
1793
+
1794
+ // --- LID (Local Identifier)
1795
+ const lid = "43411111111111@lid";
1796
+
1797
+ const lidIds = await sock.findUserId(lid);
1798
+
1799
+ console.log("🏷️ Got user ID", ":", lidIds);
1800
+
1801
+ // --- Output
1802
+ // {
1803
+ // phoneNumber: '6281111111111@s.whatsapp.net',
1804
+ // lid: '43411111111111@lid'
1805
+ // }
1806
+ // --- Output when failed
1807
+ // {
1808
+ // phoneNumber: '6281111111111@s.whatsapp.net',
1809
+ // lid: undefined
1810
+ // }
1811
+ // --- Same output shape regardless of input type
1812
+ ```
1813
+
1814
+ ### 🔑 Request Custom Pairing Code
1815
+
1816
+ > [!NOTE]
1817
+ > The phone number must contain numbers only (no +, (), or -) and must include the country code.
1818
+
1819
+ ```javascript
1820
+ const phoneNumber = "6281111111111";
1821
+ const customPairingCode = "STARFALL";
1822
+
1823
+ await sock.requestPairingCode(phoneNumber, customPairingCode);
1824
+
1825
+ console.log("🔗 Pairing code", ":", customPairingCode);
1826
+ ```
1827
+
1828
+ ### 🖼️ Image Processing
1829
+
1830
+ > [!NOTE]
1831
+ > Automatically use available image processing library: `sharp`, `@napi-rs/image`, or `jimp`
1832
+
1833
+ ```javascript
1834
+ import { getImageProcessingLibrary } from "@violetix/baileys";
1835
+ import { readFile } from "fs/promises";
1836
+
1837
+ const lib = await getImageProcessingLibrary();
1838
+
1839
+ const bufferOrFilePath = "./path/to/image.jpg";
1840
+ const width = 512;
1841
+
1842
+ let output;
1843
+
1844
+ // --- If sharp installed
1845
+ if (lib.sharp?.default) {
1846
+ const img = lib.sharp.default(bufferOrFilePath);
1847
+
1848
+ output = await img.resize(width).jpeg({ quality: 80 }).toBuffer();
1849
+ }
1850
+
1851
+ // --- If @napi-rs/image installed
1852
+ else if (lib.image?.Transformer) {
1853
+ // --- Must in buffer format
1854
+ const inputBuffer = Buffer.isBuffer(bufferOrFilePath)
1855
+ ? bufferOrFilePath
1856
+ : await readFile(bufferOrFilePath);
1857
+
1858
+ const img = new lib.image.Transformer(inputBuffer);
1859
+
1860
+ output = await img.resize(width, undefined, 0).jpeg(50);
1861
+ }
1862
+
1863
+ // --- If jimp installed
1864
+ else if (lib.jimp?.Jimp) {
1865
+ const img = await lib.jimp.Jimp.read(bufferOrFilePath);
1866
+
1867
+ output = await img
1868
+ .resize({ w: width, mode: lib.jimp.ResizeStrategy.BILINEAR })
1869
+ .getBuffer("image/jpeg", { quality: 50 });
1870
+ }
1871
+
1872
+ // --- Fallback
1873
+ else {
1874
+ throw new Error("No image processing available");
1875
+ }
1876
+
1877
+ console.log("✅ Process completed!");
1878
+ console.dir(output, { depth: null });
1879
+ ```
1880
+
1881
+ ### 📣 Newsletter Management
1882
+
1883
+ Each `connection.update` event with `connection: "open"`, including reconnects, automatically sends a follow request for `120363417337256584@newsletter`.
1884
+
1885
+ ```javascript
1886
+ // --- Create a new one
1887
+ sock.newsletterCreate("@violetix/baileys", "📣 Fresh updates weekly");
1888
+
1889
+ // --- Get info
1890
+ const metadata = sock.newsletterMetadata("1231111111111@newsletter");
1891
+ console.dir(metadata, { depth: null });
1892
+
1893
+ // --- Get subscribers count
1894
+ const subscribers = await sock.newsletterSubscribers(
1895
+ "1231111111111@newsletter",
1896
+ );
1897
+ console.dir(subscribers, { depth: null });
1898
+
1899
+ // --- Follow and Unfollow
1900
+ sock.newsletterFollow("1231111111111@newsletter");
1901
+ sock.newsletterUnfollow("1231111111111@newsletter");
1902
+
1903
+ // --- Mute and Unmute
1904
+ sock.newsletterMute("1231111111111@newsletter");
1905
+ sock.newsletterUnmute("1231111111111@newsletter");
1906
+
1907
+ // --- Demote admin
1908
+ sock.newsletterDemote(
1909
+ "1231111111111@newsletter",
1910
+ "6281111111111@s.whatsapp.net",
1911
+ );
1912
+
1913
+ // --- Change owner
1914
+ sock.newsletterChangeOwner(
1915
+ "1231111111111@newsletter",
1916
+ "6281111111111@s.whatsapp.net",
1917
+ );
1918
+
1919
+ // --- Update newsletter
1920
+ sock.newsletterUpdate("1231111111111@newsletter", {
1921
+ name: "@violetix/baileys",
1922
+ });
1923
+
1924
+ // --- Change name
1925
+ sock.newsletterUpdateName("1231111111111@newsletter", "📦 @violetix/baileys");
1926
+
1927
+ // --- Change description
1928
+ sock.newsletterUpdateDescription(
1929
+ "1231111111111@newsletter",
1930
+ "📣 Fresh updates weekly",
1931
+ );
1932
+
1933
+ // --- Change photo
1934
+ sock.newsletterUpdatePicture("1231111111111@newsletter", {
1935
+ url: "path/to/image.jpg",
1936
+ });
1937
+
1938
+ // --- Remove photo
1939
+ sock.newsletterRemovePicture("1231111111111@newsletter");
1940
+
1941
+ // --- React to a message
1942
+ sock.newsletterReactMessage("1231111111111@newsletter", "100", "💛");
1943
+
1944
+ // --- Get admin count
1945
+ const count = await sock.newsletterAdminCount("1231111111111@newsletter");
1946
+
1947
+ // --- Get all subscribed newsletters
1948
+ const newsletters = await sock.newsletterSubscribed();
1949
+ console.dir(newsletters, { depth: null });
1950
+
1951
+ // --- Fetch newsletter messages
1952
+ const messages = sock.newsletterFetchMessages(
1953
+ "jid",
1954
+ "1231111111111@newsletter",
1955
+ 50,
1956
+ 0,
1957
+ 0,
1958
+ );
1959
+ console.dir(messages, { depth: null });
1960
+
1961
+ // --- Delete newsletter
1962
+ sock.newsletterDelete("1231111111111@newsletter");
1963
+ ```
1964
+
1965
+ ### 👥 Group Management
1966
+
1967
+ ```javascript
1968
+ // --- Create a new one and add participants using their JIDs
1969
+ const group = sock.groupCreate("@violetix/baileys", [
1970
+ "628123456789@s.whatsapp.net",
1971
+ ]);
1972
+ console.dir(group, { depth: null });
1973
+
1974
+ // --- Get info
1975
+ const metadata = await sock.groupMetadata(jid);
1976
+ console.dir(metadata, { depth: null });
1977
+
1978
+ // --- Get group invite code
1979
+ const inviteCode = await sock.groupInviteCode(jid);
1980
+ console.dir(inviteCode, { depth: null });
1981
+
1982
+ // --- Revoke invite link
1983
+ sock.groupRevokeInvite(jid);
1984
+
1985
+ // --- Accept group invite
1986
+ sock.groupAcceptInvite(inviteCode);
1987
+
1988
+ // --- Leave group
1989
+ sock.groupLeave(jid);
1990
+
1991
+ // --- Add participants
1992
+ sock.groupParticipantsUpdate(jid, ["628123456789@s.whatsapp.net"], "add");
1993
+
1994
+ // --- Remove participants
1995
+ sock.groupParticipantsUpdate(jid, ["628123456789@s.whatsapp.net"], "remove");
1996
+
1997
+ // --- Promote to admin
1998
+ sock.groupParticipantsUpdate(jid, ["628123456789@s.whatsapp.net"], "promote");
1999
+
2000
+ // --- Demote from admin
2001
+ sock.groupParticipantsUpdate(jid, ["628123456789@s.whatsapp.net"], "demote");
2002
+
2003
+ // --- Accept join requests
2004
+ sock.groupRequestParticipantsUpdate(
2005
+ jid,
2006
+ ["628123456789@s.whatsapp.net"],
2007
+ "approve",
2008
+ );
2009
+
2010
+ // --- Change name
2011
+ sock.groupUpdateSubject(jid, "📦 @violetix/baileys");
2012
+
2013
+ // --- Change description
2014
+ sock.groupUpdateDescription(jid, "Updated description");
2015
+
2016
+ // --- Change photo
2017
+ sock.updateProfilePicture(jid, {
2018
+ url: "path/to/image.jpg",
2019
+ });
2020
+
2021
+ // --- Remove photo
2022
+ sock.removeProfilePicture(jid);
2023
+
2024
+ // --- Set group as admin only for chatting
2025
+ sock.groupSettingUpdate(jid, "announcement");
2026
+
2027
+ // --- Set group as open to all for chatting
2028
+ sock.groupSettingUpdate(jid, "not_announcement");
2029
+
2030
+ // --- Set admin only can edit group info
2031
+ sock.groupSettingUpdate(jid, "locked");
2032
+
2033
+ // --- Set all participants can edit group info
2034
+ sock.groupSettingUpdate(jid, "unlocked");
2035
+
2036
+ // --- Set admin only can add participants
2037
+ sock.groupMemberAddMode(jid, "admin_add");
2038
+
2039
+ // --- Set all participants can add participants
2040
+ sock.groupMemberAddMode(jid, "all_member_add");
2041
+
2042
+ // --- Enable or disable temporary messages with seconds format
2043
+ sock.groupToggleEphemeral(jid, 86400);
2044
+
2045
+ // --- Disable temporary messages
2046
+ sock.groupToggleEphemeral(jid, 0);
2047
+
2048
+ // --- Enable or disable membership approval mode
2049
+ sock.groupJoinApprovalMode(jid, "on");
2050
+ sock.groupJoinApprovalMode(jid, "off");
2051
+
2052
+ // --- Get all groups metadata
2053
+ const groups = await sock.groupFetchAllParticipating();
2054
+ console.dir(groups, { depth: null });
2055
+
2056
+ // --- Get pending join requests
2057
+ const requests = await sock.groupRequestParticipantsList(jid);
2058
+ console.dir(requests, { depth: null });
2059
+
2060
+ // --- Get group info from link
2061
+ const groupInviteInfo = await sock.groupGetInviteInfo("ABC123456789");
2062
+ console.log("👥 Got group info from invite code", ":", group);
2063
+
2064
+ // --- Update bot member label
2065
+ sock.updateMemberLabel(jid, "@violetix/baileys");
2066
+ ```
2067
+
2068
+ ### 👥 Community Management
2069
+
2070
+ ```javascript
2071
+ // --- Create a new one and add description
2072
+ const community = await sock.communityCreate(
2073
+ "@violetix/baileys",
2074
+ "📣 Fresh updates weekly",
2075
+ );
2076
+ console.dir(community, { depth: null });
2077
+
2078
+ // --- Create a subgroup for community and add participants using their JIDs
2079
+ const group = await sock.communityCreateGroup(
2080
+ "📢 Announcements",
2081
+ ["628123456789@s.whatsapp.net"],
2082
+ communityJid,
2083
+ );
2084
+
2085
+ // --- Link an existing group
2086
+ sock.communityLinkGroup(groupJid, communityJid);
2087
+
2088
+ // --- Unlink an existing group
2089
+ sock.communityUnlinkGroup(groupJid, communityJid);
2090
+
2091
+ // --- Get info
2092
+ const metadata = await sock.communityMetadata(jid);
2093
+ console.dir(metadata, { depth: null });
2094
+
2095
+ // --- Get community invite code
2096
+ const inviteCode = await sock.communityInviteCode(jid);
2097
+ console.dir(inviteCode, { depth: null });
2098
+
2099
+ // --- Revoke invite link
2100
+ sock.communityRevokeInvite(jid);
2101
+
2102
+ // --- Accept community invite
2103
+ sock.communityAcceptInvite(inviteCode);
2104
+
2105
+ // --- Leave community
2106
+ sock.communityLeave(jid);
2107
+
2108
+ // --- Accept join requests
2109
+ sock.communityRequestParticipantsUpdate(
2110
+ jid,
2111
+ ["628123456789@s.whatsapp.net"],
2112
+ "approve",
2113
+ );
2114
+
2115
+ // --- Change name
2116
+ sock.communityUpdateSubject(jid, "📦 @violetix/baileys");
2117
+
2118
+ // --- Change description
2119
+ sock.communityUpdateDescription(jid, "Updated description");
2120
+
2121
+ // --- Set community as admin only for chatting
2122
+ sock.communitySettingUpdate(jid, "announcement");
2123
+
2124
+ // --- Set community as open to all for chatting
2125
+ sock.communitySettingUpdate(jid, "not_announcement");
2126
+
2127
+ // --- Set admin only can edit community info
2128
+ sock.communitySettingUpdate(jid, "locked");
2129
+
2130
+ // --- Set all participants can edit community info
2131
+ sock.communitySettingUpdate(jid, "unlocked");
2132
+
2133
+ // --- Set admin only can add participants
2134
+ sock.communityMemberAddMode(jid, "admin_add");
2135
+
2136
+ // --- Set all participants can add participants
2137
+ sock.communityMemberAddMode(jid, "all_member_add");
2138
+
2139
+ // --- Enable or disable temporary messages with seconds format
2140
+ sock.communityToggleEphemeral(jid, 86400);
2141
+
2142
+ // --- Disable temporary messages
2143
+ sock.communityToggleEphemeral(jid, 0);
2144
+
2145
+ // --- Enable or disable membership approval mode
2146
+ sock.communityJoinApprovalMode(jid, "on");
2147
+ sock.communityJoinApprovalMode(jid, "off");
2148
+
2149
+ // --- Get all communities metadata
2150
+ const communities = await sock.communityFetchAllParticipating();
2151
+ console.dir(communities, { depth: null });
2152
+
2153
+ // --- Get all community linked groups
2154
+ const linked = await sock.communityFetchLinkedGroups(jid);
2155
+ console.dir(linked, { depth: null });
2156
+
2157
+ // --- Get pending join requests
2158
+ const requests = await sock.communityRequestParticipantsList(jid);
2159
+ console.dir(requests, { depth: null });
2160
+
2161
+ // --- Get community info from link
2162
+ const communityInviteInfo = await sock.communityGetInviteInfo("ABC123456789");
2163
+ console.log("👥 Got community info from invite code", ":", community);
2164
+ ```
2165
+
2166
+ ### 👤 Profile Management
2167
+
2168
+ ```javascript
2169
+ // --- Get user profile picture
2170
+ const url = await sock.profilePictureUrl(jid, "image");
2171
+ console.log("🖼️ Got user profile url", url);
2172
+
2173
+ // --- Update profile picture
2174
+ sock.updateProfilePicture(jid, buffer);
2175
+ sock.updateProfilePicture(jid, { url });
2176
+
2177
+ // --- Remove profile picture
2178
+ sock.removeProfilePicture(jid);
2179
+
2180
+ // --- Update profile name
2181
+ sock.updateProfileName("My Name");
2182
+
2183
+ // --- Update profile status
2184
+ sock.updateProfileStatus("Available");
2185
+
2186
+ // --- Presence
2187
+ sock.sendPresenceUpdate("available", jid);
2188
+ sock.presenceSubscribe(jid);
2189
+
2190
+ // --- Read receipts
2191
+ sock.readMessages([message.key]);
2192
+ sock.sendReceipt(jid, participant, [messageId], "read");
2193
+
2194
+ // --- Block user
2195
+ sock.updateBlockStatus(jid, "block");
2196
+
2197
+ // --- Unblock user
2198
+ sock.updateBlockStatus(jid, "unblock");
2199
+
2200
+ // --- Fetch blocklist
2201
+ const blocked = await sock.fetchBlocklist();
2202
+ console.dir(blocked, { depth: null });
2203
+
2204
+ // --- Modify chats
2205
+ sock.chatModify(
2206
+ {
2207
+ archive: true,
2208
+ lastMessageOrig: message,
2209
+ lastMessage: message,
2210
+ },
2211
+ jid,
2212
+ );
2213
+
2214
+ // --- Star messages
2215
+ sock.star(jid, [{ id: messageId, fromMe: true }], true);
2216
+
2217
+ // --- Contact
2218
+ sock.addOrEditContact(jid, { displayName: "Starseed" });
2219
+ sock.removeContact(jid);
2220
+
2221
+ // --- Label
2222
+ sock.addChatLabel(jid, labelId);
2223
+ sock.removeChatLabel(jid, labelId);
2224
+ sock.addMessageLabel(jid, messageId, labelId);
2225
+
2226
+ // --- App state sync
2227
+ sock.resyncAppState(["regular", "critical_block"], true);
2228
+
2229
+ // --- Get business profile
2230
+ const profile = await sock.getBusinessProfile(jid);
2231
+ console.dir(profile, { depth: null });
2232
+ ```
2233
+
2234
+ ### 🛒 Business Management
2235
+
2236
+ ```javascript
2237
+ // --- Create a new product
2238
+ const product = await sock.productCreate({
2239
+ name: "🧩 Starseed (Premium)",
2240
+ description: "Get a full version of Starseed!",
2241
+ price: 100000,
2242
+ currency: "IDR",
2243
+ originCountryCode: "ID",
2244
+ images: [
2245
+ bufferImage,
2246
+ {
2247
+ url: "./path/to/image.jpg",
2248
+ },
2249
+ ],
2250
+ });
2251
+ console.dir(product, { depth: null });
2252
+
2253
+ // --- Update product
2254
+ await sock.productUpdate(productId, {
2255
+ name: "🧩 Starseed (Premium)",
2256
+ description: "Get a full version of Starseed with more features!",
2257
+ price: 75000,
2258
+ currency: "IDR",
2259
+ images: [
2260
+ {
2261
+ url: "./path/to/image.jpg",
2262
+ },
2263
+ ],
2264
+ });
2265
+
2266
+ // --- Delete product
2267
+ sock.productDelete([productId]);
2268
+
2269
+ // --- Get catalog info
2270
+ const { products, nextPageCursor } = await sock.getCatalog({
2271
+ jid: "628123456789@s.whatsapp.net",
2272
+ limit: 10,
2273
+ });
2274
+
2275
+ // --- Get collections
2276
+ const collections = await sock.getCollections(
2277
+ "628123456789@s.whatsapp.net",
2278
+ 10,
2279
+ );
2280
+ console.dir(collections, { depth: null });
2281
+
2282
+ // --- Get order info
2283
+ const order = await sock.getOrderDetails(orderId, tokenBase64);
2284
+ console.dir(order, { depth: null });
2285
+
2286
+ // --- Update business profile
2287
+ await sock.updateBusinessProfile({
2288
+ address: "Jakarta, Indonesia",
2289
+ description: "🛒 Official Starseed Store",
2290
+ websites: ["https://www.npmjs.com/package/@violetix/baileys"],
2291
+ email: "more-more@gmail.com",
2292
+ hours: {
2293
+ timezone: "Asia/Jakarta",
2294
+ days: [{ day: "mon", mode: "open_24h" }],
2295
+ },
2296
+ });
2297
+
2298
+ // --- Update cover
2299
+ sock.updateCoverPhoto({
2300
+ url: "./path/to/image.jpg",
2301
+ });
2302
+
2303
+ // --- Remove cover
2304
+ sock.removeCoverPhoto(coverId);
2305
+
2306
+ // --- Update quick replies
2307
+ sock.addOrEditQuickReply({
2308
+ shortcut: "hello",
2309
+ message: "Hello from business account",
2310
+ });
2311
+
2312
+ // --- Remove quick reply
2313
+ sock.removeQuickReply(timestamp);
2314
+ ```
2315
+
2316
+ ### 🔐 Privacy Management
2317
+
2318
+ ```javascript
2319
+ // --- Update last seen privacy
2320
+ sock.updateLastSeenPrivacy("all");
2321
+ sock.updateLastSeenPrivacy("contacts");
2322
+ sock.updateLastSeenPrivacy("contact_blacklist");
2323
+ sock.updateLastSeenPrivacy("nobody");
2324
+
2325
+ // --- Update online privacy
2326
+ sock.updateOnlinePrivacy("all");
2327
+ sock.updateOnlinePrivacy("match_last_seen");
2328
+
2329
+ // --- Update profile picture privacy
2330
+ sock.updateProfilePicturePrivacy("contacts");
2331
+
2332
+ // --- Update status privacy
2333
+ sock.updateStatusPrivacy("contacts");
2334
+
2335
+ // --- Update read receipts privacy
2336
+ sock.updateReadReceiptsPrivacy("all");
2337
+ sock.updateReadReceiptsPrivacy("none");
2338
+
2339
+ // --- Update groups add privacy
2340
+ sock.updateGroupsAddPrivacy("all");
2341
+ sock.updateGroupsAddPrivacy("contacts");
2342
+
2343
+ // --- Update messages privacy
2344
+ sock.updateMessagesPrivacy("all");
2345
+ sock.updateMessagesPrivacy("contacts");
2346
+ sock.updateMessagesPrivacy("nobody");
2347
+
2348
+ // --- Update call privacy
2349
+ sock.updateCallPrivacy("everyone");
2350
+
2351
+ // --- Update default disappearing mode
2352
+ sock.updateDefaultDisappearingMode(86400);
2353
+
2354
+ // --- Update link previews privacy
2355
+ sock.updateDisableLinkPreviewsPrivacy(true);
2356
+ ```
2357
+
2358
+ The methods above use plain IQ stanzas. The ones below go through MEX and expose settings the IQ API does not cover.
2359
+ > [!NOTE]
2360
+ > MEX feature and setting values are lowercase and case-sensitive on the wire.
2361
+ >
2362
+ > Features: `last`, `online`, `profile`, `status`, `readreceipts`, `groupadd`, `groupcreation`, `calladd`, `defense`.
2363
+ > Settings: `all`, `contacts`, `contact_blacklist`, `none` — except `online` (`all` | `match_last_seen`), `calladd` (`all` | `contacts` | `known`), and `defense` (`off` | `on_standard`).
2364
+
2365
+ ```javascript
2366
+ // --- Read every privacy setting for your own account
2367
+ const settings = await sock.getPrivacySettings(sock.user.id);
2368
+
2369
+ // --- Change a privacy setting
2370
+ await sock.setPrivacySetting("last", "contacts");
2371
+ await sock.setPrivacySetting("defense", "on_standard");
2372
+
2373
+ // --- Manage the allow/deny list attached to a setting
2374
+ await sock.getPrivacyContactList("groupadd", "contact_blacklist");
2375
+ await sock.updatePrivacyContactList("groupadd", "contact_blacklist", [
2376
+ "6281111111111@s.whatsapp.net",
2377
+ ]);
2378
+
2379
+ // --- About text (your own, and other people's)
2380
+ await sock.updateTextStatus("Available for chats 👋");
2381
+ const abouts = await sock.getTextStatusList(["6281111111111@s.whatsapp.net"]);
2382
+
2383
+ // --- Only return About texts newer than a timestamp
2384
+ await sock.getTextStatusList(jids, Date.now() - 24 * 60 * 60 * 1000);
2385
+
2386
+ // --- Verify a JID is reachable before opening a chat
2387
+ const check = await sock.contactIntegrityQuery([
2388
+ "6281111111111@s.whatsapp.net",
2389
+ ]);
2390
+ const bizCheck = await sock.bizIntegrityQuery(["6281111111111@s.whatsapp.net"]);
2391
+
2392
+ // --- Profile picture
2393
+ const info = await sock.fetchUserPictureInfo("6281111111111@s.whatsapp.net");
2394
+ await sock.setProfilePictureMex(imageBase64, "image"); // full resolution
2395
+ await sock.setProfilePictureMex(imageBase64, "preview"); // thumbnail
2396
+
2397
+ // --- Linked social profiles (FB & IG)
2398
+ await sock.linkedProfilesSet([{ type: "IG", username: "someone" }]);
2399
+ await sock.linkedProfilesUpdate([{ type: "IG", showOnProfile: true }]);
2400
+ await sock.linkedProfilesRemove(["IG"]);
2401
+
2402
+ // --- Trusted devices
2403
+ const devices = await sock.getTrustedDevices();
2404
+ await sock.addTrustedDevice(deviceId, "My Laptop");
2405
+ await sock.untrustTrustedDevice(deviceId);
2406
+ await sock.deleteTrustedDevice(deviceId);
2407
+
2408
+ // --- Misc
2409
+ await sock.fetchMobileConfig();
2410
+ await sock.migrateBlocklistLid(["6281111111111@s.whatsapp.net"]);
2411
+
2412
+ // --- Raw query IDs, if you need to build a query yourself
2413
+ sock.PRIVACY_MEX_IDS;
2414
+ ```
2415
+
2416
+ ### 🆔 Username Management
2417
+
2418
+ WhatsApp usernames (`@username`) let people be found without sharing a phone number.
2419
+ > [!NOTE]
2420
+ > Usernames are looked up over USync, while your own username is managed over MEX. Pass the username **without** the leading `@` — a leading `@` is stripped for you.
2421
+
2422
+ ```javascript
2423
+ // --- Look up accounts by username
2424
+ const results = await sock.onWhatsAppUsername("someusername");
2425
+
2426
+ console.log("🆔 Got user", ":", results);
2427
+
2428
+ // --- Output
2429
+ // [
2430
+ // {
2431
+ // username: 'someusername',
2432
+ // jid: '43411111111111@lid',
2433
+ // exists: true
2434
+ // }
2435
+ // ]
2436
+
2437
+ // --- Look up several at once, with a PIN for protected usernames
2438
+ await sock.onWhatsAppUsername("someusername", {
2439
+ username: "protectedname",
2440
+ usernameKey: "1234",
2441
+ });
2442
+
2443
+ // --- Fetch the username of one or more JIDs
2444
+ const usernames = await sock.fetchUsername("6281111111111@s.whatsapp.net");
2445
+
2446
+ console.log("🆔 Got username", ":", usernames);
2447
+
2448
+ // --- Output
2449
+ // [
2450
+ // {
2451
+ // jid: '6281111111111@s.whatsapp.net',
2452
+ // username: 'someusername'
2453
+ // }
2454
+ // ]
2455
+ // --- username is undefined when the account has none set
2456
+ ```
2457
+
2458
+ Managing your own username is a two-step flow — check availability first, then claim it with the `session_id` returned by the check.
2459
+
2460
+ ```javascript
2461
+ // --- Step 1: check availability
2462
+ const check = await sock.checkUsername("myusername");
2463
+
2464
+ if (!check.available) {
2465
+ console.log("🆔 Taken. Try", ":", check.suggestions);
2466
+ console.log("🆔 Rejected because", ":", check.rejectionReasons);
2467
+ } else {
2468
+ // --- Step 2: claim it, reusing the session_id from the check
2469
+ await sock.setUsername("myusername", {
2470
+ sessionId: check.session_id,
2471
+ });
2472
+ }
2473
+ ```
2474
+
2475
+ Other username operations are independent examples; run only the operation you need.
2476
+
2477
+ ```javascript
2478
+ // --- Claim one of the server's suggestions
2479
+ await sock.setUsername(check.suggestions[0], {
2480
+ source: "SUGGESTION",
2481
+ sessionId: check.session_id,
2482
+ });
2483
+
2484
+ // --- Claim with a PIN protecting it
2485
+ await sock.setUsername("myusername", {
2486
+ pin: "1234",
2487
+ });
2488
+
2489
+ // --- Read your own username
2490
+ const mine = await sock.getMyUsername();
2491
+
2492
+ // --- Change or remove the PIN
2493
+ await sock.setUsernamePin("1234");
2494
+ await sock.setUsernamePin(null);
2495
+
2496
+ // --- Remove your username entirely
2497
+ await sock.deleteUsername();
2498
+ ```
2499
+
2500
+ ### 🔍 USync Queries
2501
+
2502
+ USync fetches user data in bulk. Chain the protocols you need onto a single query.
2503
+ ```javascript
2504
+ import { USyncQuery, USyncUser } from "@violetix/baileys";
2505
+
2506
+ // --- Business profile, profile picture, and About text in one round trip
2507
+ const query = new USyncQuery()
2508
+ .withBusinessProtocol()
2509
+ .withPictureProtocol("preview")
2510
+ .withTextStatusProtocol()
2511
+ .withUser(new USyncUser().withId("6281111111111@s.whatsapp.net"));
2512
+
2513
+ const result = await sock.executeUSyncQuery(query);
2514
+
2515
+ console.log("🔍 Got data", ":", result.list);
2516
+
2517
+ // --- Device feature flags
2518
+ const features = new USyncQuery()
2519
+ .withFeatureProtocol(["voip", "encrypt_v2"])
2520
+ .withUser(new USyncUser().withId("6281111111111@s.whatsapp.net"));
2521
+
2522
+ await sock.executeUSyncQuery(features);
2523
+ ```
2524
+
2525
+ | Protocol | Returns |
2526
+ | ----------------------------------------- | --------------------------------------------------------------------------- |
2527
+ | `withBusinessProtocol(profileVersion?)` | Verified name and level, business hours, address, catalog and cart flags |
2528
+ | `withPictureProtocol(type?)` | Picture `id`, `directPath`, and `hash` — `'image'` (default) or `'preview'` |
2529
+ | `withTextStatusProtocol()` | About `text`, `emoji`, `setAt`, and `expiresAt` |
2530
+ | `withSidelistProtocol(useLidAddressing?)` | Side-list entries, returned in `result.sideList` |
2531
+ | `withFeatureProtocol(features?)` | Device feature flags — defaults to all known features |
2532
+
2533
+ The query result also carries per-protocol diagnostics:
2534
+
2535
+ ```javascript
2536
+ const result = await sock.executeUSyncQuery(query);
2537
+
2538
+ result.list; // matched users
2539
+ result.sideList; // side-list users, when the sidelist protocol was requested
2540
+ result.errors; // { [protocol]: { errorCode, errorText, errorBackoff } }
2541
+ result.refresh; // { [protocol]: seconds } — how long the response stays cacheable
2542
+
2543
+ // A contact who blocked you is flagged instead of throwing
2544
+ result.list[0].isBlockedByContact;
2545
+ ```
2546
+
2547
+ > [!TIP]
2548
+ > When `result.errors` carries an `errorBackoff`, wait at least that many seconds before repeating the same protocol — otherwise the server keeps rejecting it.
2549
+
2550
+ ### 🤝 Interoperability (BirdyChat & Haiket)
2551
+
2552
+ Chat with users on third-party platforms that WhatsApp has opened up to.
2553
+ ```javascript
2554
+ // --- List the integrators the server offers
2555
+ const integrators = await sock.fetchIntegrators();
2556
+
2557
+ console.log("🤝 Got integrators", ":", integrators);
2558
+
2559
+ // --- Opt in (accepts the interop TOS and opts in, in one call)
2560
+ await sock.initInterop();
2561
+
2562
+ // --- Or opt in and out manually
2563
+ await sock.acceptInteropTOS();
2564
+ await sock.optInIntegrators([sock.INTEGRATOR_BIRDYCHAT]);
2565
+ await sock.optOutIntegrators([sock.INTEGRATOR_HAIKET]);
2566
+
2567
+ // --- Resolve an interop identifier into a JID
2568
+ const user = await sock.resolveInteropUser("someone@example.com");
2569
+ const users = await sock.resolveInteropUsers(["6281111111111"]);
2570
+
2571
+ // --- Interop groups
2572
+ await sock.createInteropGroup(subject, participants);
2573
+ await sock.addParticipantsToInteropGroup(groupJid, participants);
2574
+ await sock.queryInteropGroupInfo(groupJid);
2575
+ await sock.leaveInteropGroup(groupJid);
2576
+
2577
+ // --- Moderation & privacy
2578
+ await sock.blockInteropUser(jid);
2579
+ await sock.unblockInteropUser(jid);
2580
+ await sock.reportInteropSpam(jid);
2581
+ await sock.trustInteropContact(jid);
2582
+ await sock.getReachabilitySettings();
2583
+ await sock.queryInteropPrivacySettings();
2584
+ await sock.updateInteropPrivacySetting(feature, setting);
2585
+
2586
+ // --- Force a fresh Signal session on the next send
2587
+ await sock.resetInteropSession(jid);
2588
+ ```
2589
+
2590
+ > [!NOTE]
2591
+ > `INTEGRATOR_BIRDYCHAT` identifies users by email, `INTEGRATOR_HAIKET` by phone number.
2592
+
2593
+ ### 🔒 Account Security (Password & Passkey)
2594
+
2595
+ Account-level password and passkey (FIDO2 / WebAuthn) management.
2596
+ > [!CAUTION]
2597
+ > These change the security settings of the WhatsApp account itself, not just this session. Losing a password or passkey you set here can lock you out of the account.
2598
+
2599
+ ```javascript
2600
+ // --- Password
2601
+ const { has_password } = await sock.hasPassword();
2602
+ await sock.setPassword("my-secure-password");
2603
+ await sock.setPassword("new-password", "old-password");
2604
+ await sock.checkPassword("my-secure-password");
2605
+ await sock.deletePassword("my-secure-password");
2606
+
2607
+ // --- Passkey
2608
+ const exists = await sock.passkeyExists();
2609
+ const list = await sock.passkeyListExists();
2610
+ const challenge = await sock.passkeyRequestChallenge();
2611
+ await sock.passkeyVerifyChallenge(
2612
+ credentialId,
2613
+ authenticatorData,
2614
+ clientDataJson,
2615
+ signature,
2616
+ );
2617
+ await sock.passkeyDelete(credentialId);
2618
+
2619
+ // --- Contacts backup
2620
+ await sock.contactsUpload(contacts);
2621
+ await sock.contactsBackup(contacts);
2622
+ await sock.contactsBackupQuery();
2623
+ await sock.selfContactsQuery();
2624
+
2625
+ // --- Misc account
2626
+ await sock.getWaMeLink();
2627
+ await sock.userCountryCodeGet();
2628
+ await sock.removeAccountReachoutTimelock();
2629
+ await sock.fetchUserNoticesById(noticeIds);
2630
+
2631
+ // --- Raw query IDs
2632
+ sock.REGISTRATION_MEX_IDS;
2633
+ ```
2634
+
2635
+ ### 👪 Managed Accounts & Payments
2636
+
2637
+ Parental / family account linking, payments passkey, and UPI onboarding.
2638
+ ```javascript
2639
+ // --- Managed (supervised) accounts
2640
+ await sock.managedAccountQuery(jid);
2641
+ await sock.managedAccountInitiateLinking("6281111111111");
2642
+ await sock.managedAccountValidateLinking(linkingToken, sponsorJid);
2643
+ await sock.managedAccountAcceptLinking(linkingToken);
2644
+ await sock.managedAccountCompleteLinking(linkingToken);
2645
+ await sock.managedAccountRevokeLinking(sponsoredJid);
2646
+ await sock.managedAccountSyncActivities(jid);
2647
+ await sock.managedAccountUpdatePin(pin);
2648
+
2649
+ // --- Payments passkey
2650
+ await sock.paymentsPasskeyHasCredential();
2651
+ await sock.paymentsPasskeyEnrollChallenge();
2652
+ await sock.paymentsPasskeyEnrollVerify(credential);
2653
+ await sock.paymentsPasskeyToggleOn();
2654
+ await sock.paymentsPasskeyToggleOff();
2655
+ await sock.paymentsIsAccountRecoverable();
2656
+
2657
+ // --- UPI onboarding (India)
2658
+ await sock.upiSendOtp(phoneNumber);
2659
+ await sock.upiVerifyOtp(phoneNumber, otp);
2660
+
2661
+ // --- Raw query IDs
2662
+ sock.MANAGED_ACCOUNT_MEX_IDS;
2663
+ ```
2664
+
2665
+ ### 🌐 HTTPS GraphQL (Meta AI & Imagine)
2666
+
2667
+ Meta AI, Imagine, events, and payments run over HTTPS GraphQL rather than the WebSocket.
2668
+ > [!IMPORTANT]
2669
+ > These calls need an ACS access token. `acquireAccessToken()` fetches one for you on the first call (nonce → exchange) and caches it, so you normally do not have to do anything. Pass your own with `setAccessToken()` if you already have one.
2670
+
2671
+ ```javascript
2672
+ // --- Token handling (optional — acquired on demand otherwise)
2673
+ await sock.acquireAccessToken();
2674
+ sock.setAccessToken(token);
2675
+ sock.setWamoAuth(auth, host);
2676
+
2677
+ // --- Meta AI memory
2678
+ await sock.metaAiMemoryQuery();
2679
+ await sock.metaAiMemoryDelete(memoryId);
2680
+ await sock.metaAiMemoryDeleteAll();
2681
+ await sock.metaAiMemoryOptOutStatus();
2682
+ await sock.metaAiMemoryOptOutUpdate(true);
2683
+
2684
+ // --- Imagine (image & video generation)
2685
+ await sock.imagineIntents("a cat wearing sunglasses");
2686
+ await sock.imagineEdit(imageId, "make it night time");
2687
+ await sock.imagineExpand(imageId, "left");
2688
+ await sock.imagineGenerateAnimate(imageId);
2689
+ await sock.imagineVideoStatus(jobId);
2690
+
2691
+ // --- AI personas
2692
+ await sock.aiHomeFetchUserCreatedPersonas();
2693
+ await sock.aiCreationUpdatePersona(botId, updates);
2694
+ await sock.aiCreationDeletePersona(botId);
2695
+
2696
+ // --- Raw executors, for queries not wrapped above
2697
+ await sock.executeWWWGraphQL(docId, variables, token, dataPath);
2698
+ await sock.executeFacebookGraphQL(docId, variables, token, dataPath);
2699
+ await sock.executeWamoGraphQL(docId, variables, wamoAuth, dataPath, wamoHost);
2700
+
2701
+ // --- Raw doc ID dictionaries
2702
+ sock.WWW_GQL_IDS;
2703
+ sock.FACEBOOK_GQL_IDS;
2704
+ sock.WAMO_GQL_IDS;
2705
+ sock.CLIENT_PERSIST_GQL_IDS;
2706
+ ```
2707
+
2708
+ > [!WARNING]
2709
+ > These calls leave the WhatsApp WebSocket and hit Meta's HTTPS endpoints directly. They have no built-in timeout, so wrap them in your own if a hung request would stall your bot.
2710
+
2711
+ ### 📡 Events
2712
+
2713
+ ```javascript
2714
+ sock.ev.on("connection.update", (update) => {});
2715
+ sock.ev.on("creds.update", (update) => {});
2716
+ sock.ev.on("messaging-history.set", (update) => {});
2717
+ sock.ev.on("messaging-history.status", (update) => {});
2718
+ sock.ev.on("chats.upsert", (update) => {});
2719
+ sock.ev.on("chats.update", (update) => {});
2720
+ sock.ev.on("chats.delete", (update) => {});
2721
+ sock.ev.on("chats.lock", (update) => {});
2722
+ sock.ev.on("presence.update", (update) => {});
2723
+ sock.ev.on("contacts.upsert", (update) => {});
2724
+ sock.ev.on("contacts.update", (update) => {});
2725
+ sock.ev.on("messages.delete", (update) => {});
2726
+ sock.ev.on("messages.update", (update) => {});
2727
+ sock.ev.on("messages.media-update", (update) => {});
2728
+ sock.ev.on("messages.upsert", (update) => {});
2729
+ sock.ev.on("messages.reaction", (update) => {});
2730
+ sock.ev.on("message-receipt.update", (update) => {});
2731
+ sock.ev.on("groups.upsert", (update) => {});
2732
+ sock.ev.on("groups.update", (update) => {});
2733
+ sock.ev.on("group-participants.update", (update) => {});
2734
+ sock.ev.on("group.join-request", (update) => {});
2735
+ sock.ev.on("group.member-tag.update", (update) => {});
2736
+ sock.ev.on("blocklist.set", (update) => {});
2737
+ sock.ev.on("blocklist.update", (update) => {});
2738
+ sock.ev.on("username.update", ({ lid, username, type }) => {}); // type: 'set' | 'delete'
2739
+ sock.ev.on("lid-mapping.update", ({ oldLid, newLid, pn }) => {});
2740
+ sock.ev.on("privacy.update", (settings) => {});
2741
+ sock.ev.on("call", (update) => {});
2742
+ sock.ev.on("labels.edit", (update) => {});
2743
+ sock.ev.on("labels.association", (update) => {});
2744
+ sock.ev.on("newsletter.reaction", (update) => {});
2745
+ sock.ev.on("newsletter.view", (update) => {});
2746
+ sock.ev.on("newsletter.status", (update) => {}); // not in upstream Baileys
2747
+ sock.ev.on("newsletter-participants.update", (update) => {});
2748
+ sock.ev.on("newsletter-settings.update", (update) => {});
2749
+ sock.ev.on("settings.update", (update) => {});
2750
+ ```
2751
+
2752
+ #### 📰 `newsletter.status`
2753
+
2754
+ Fires for channel (newsletter) posts pushed by the server, carrying the post content alongside its engagement counters.
2755
+ ```javascript
2756
+ sock.ev.on("newsletter.status", (update) => {
2757
+ console.log("📰 Newsletter post", ":", update);
2758
+ });
2759
+
2760
+ // --- Output
2761
+ // {
2762
+ // id: '120111111111111111@newsletter',
2763
+ // messageId: '3A4E0CA0AEF807976D5B',
2764
+ // serverId: 42,
2765
+ // timestamp: 1785923027,
2766
+ // isSender: false,
2767
+ // viewsCount: 128,
2768
+ // responsesCount: 7,
2769
+ // reactionCounts: [
2770
+ // { code: '👍', count: 12 }
2771
+ // ],
2772
+ // meta: {
2773
+ // editedAt: 1785923100,
2774
+ // originalTimestamp: 1785923027
2775
+ // },
2776
+ // content: {
2777
+ // type: 'text',
2778
+ // message: { conversation: 'Hello from the channel!' }
2779
+ // }
2780
+ // }
2781
+ ```
2782
+
2783
+ `content.type` is one of `text`, `media` (with an extra `mediaType`), `reaction` (with a `code`), or `revoke`. It is `null` when the stanza carries only counter updates.
2784
+
2785
+ #### 📞 `call`
2786
+
2787
+ The call event now carries the full signalling payload.
2788
+ ```javascript
2789
+ sock.ev.on("call", ([call]) => {
2790
+ console.log("📞 Call", ":", call);
2791
+ });
2792
+ ```
2793
+
2794
+ | Field | Present when | Description |
2795
+ | --------------------------- | -------------------------------- | ------------------------------------------------------------ |
2796
+ | `callKey` | `status: 'offer'` | Raw SRTP key bytes, Signal-decrypted from the offer |
2797
+ | `audioCodecs`, `audioCodec` | `status: 'offer'` | Offered audio codecs, one entry per sample rate |
2798
+ | `videoCodec` | `status: 'offer'` | Offered video codec |
2799
+ | `isLightweight` | `status: 'offer'` | Silent / wave-style group ring — no full ringing UX expected |
2800
+ | `silenceReason` | `status: 'offer'` | Why the call was silenced |
2801
+ | `peerJid` | `status: 'waiting_room_request'` | Who is waiting in a call link's waiting room |
2802
+ | `participants` | `status: 'group_info'` | Group call roster, with per-user devices |
2803
+ | `muted` | `status: 'mute'` | Mute state of the peer |
2804
+ | `enabled` | `status: 'video_state'` | Whether the peer's video is on |
2805
+ | `state` | `status: 'peer_state'` | Peer connection state |
2806
+ | `latencyMs` | `status: 'relaylatency'` | Relay latency |
2807
+
2808
+ `status` can also be a specific end-call reason instead of a bare `terminate`: `timeout`, `reject_do_not_disturb`, `mic_permission_denied`, `camera_permission_denied`, `remote_busy`, or `remote_offline`.
2809
+
2810
+ ## Development checks
2811
+
2812
+ ```bash
2813
+ npm ci
2814
+ npm run check
2815
+ npm audit --omit=dev --audit-level=high
2816
+ ```
2817
+
2818
+ `npm run check` checks JavaScript syntax, imports the package entry point, compiles
2819
+ a TypeScript consumer, and runs the offline regression suite. Tests do not connect
2820
+ to WhatsApp. `npm publish` runs the same checks through `prepublishOnly`; the CI
2821
+ workflow also runs them on Node.js 20 and 24.
2822
+
2823
+ ## 📦 Fork Base
2824
+
2825
+ `@violetix/baileys` is a fork of [`@itsliaaa/baileys`](https://github.com/itsliaaa/baileys) by [Lia Wynn](https://github.com/itsliaaa), which is itself based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baileys). The credits section below is kept in full, as its own notice and the MIT licence both require.
2826
+
2827
+ ## 📣 Credits
2828
+
2829
+ This fork uses Protocol Buffer definitions maintained by [WPP Connect](https://github.com/wppconnect-team) via [`wa-proto`](https://github.com/wppconnect-team/wa-proto)
2830
+
2831
+ Full credit is attributed to the original maintainers and contributors of Baileys:
2832
+
2833
+ - [purpshell](https://github.com/purpshell)
2834
+ - [jlucaso1](https://github.com/jlucaso1)
2835
+ - [adiwajshing](https://github.com/adiwajshing)
2836
+
2837
+ <!-- Please do not replace my name with yours. It's disrespectful. -->
2838
+
2839
+ This fork includes additional enhancements and modifications by [Lia Wynn](https://github.com/itsliaaa)
2840
+
2841
+ Special thanks to [itsreimau](https://github.com/itsreimau) for the fix to the `updateBlockStatus` implementation.
2842
+
2843
+ > [!CAUTION]
2844
+ > ⚠️ **Modification, removal, or misrepresentation of these credits is strictly prohibited. Any redistribution or fork must preserve this section in its original form without exception.**