junexbaileys 0.0.0-stage → 1.0.3

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 (405) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1358 -2
  3. package/WAProto/GenerateStatics.sh +3 -0
  4. package/WAProto/WAProto.proto +5479 -0
  5. package/WAProto/fix-imports.js +85 -0
  6. package/WAProto/index.d.ts +14017 -0
  7. package/WAProto/index.js +97691 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/index.d.ts +75 -0
  10. package/lib/Defaults/index.d.ts.map +1 -0
  11. package/lib/Defaults/index.js +129 -0
  12. package/lib/Defaults/index.js.map +1 -0
  13. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  14. package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
  15. package/lib/Signal/Group/ciphertext-message.js +12 -0
  16. package/lib/Signal/Group/ciphertext-message.js.map +1 -0
  17. package/lib/Signal/Group/group-session-builder.d.ts +15 -0
  18. package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
  19. package/lib/Signal/Group/group-session-builder.js +30 -0
  20. package/lib/Signal/Group/group-session-builder.js.map +1 -0
  21. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  22. package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
  23. package/lib/Signal/Group/group_cipher.js +82 -0
  24. package/lib/Signal/Group/group_cipher.js.map +1 -0
  25. package/lib/Signal/Group/index.d.ts +12 -0
  26. package/lib/Signal/Group/index.d.ts.map +1 -0
  27. package/lib/Signal/Group/index.js +12 -0
  28. package/lib/Signal/Group/index.js.map +1 -0
  29. package/lib/Signal/Group/keyhelper.d.ts +11 -0
  30. package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
  31. package/lib/Signal/Group/keyhelper.js +18 -0
  32. package/lib/Signal/Group/keyhelper.js.map +1 -0
  33. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  34. package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
  35. package/lib/Signal/Group/sender-chain-key.js +26 -0
  36. package/lib/Signal/Group/sender-chain-key.js.map +1 -0
  37. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  38. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
  39. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  40. package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
  41. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  42. package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
  43. package/lib/Signal/Group/sender-key-message.js +66 -0
  44. package/lib/Signal/Group/sender-key-message.js.map +1 -0
  45. package/lib/Signal/Group/sender-key-name.d.ts +18 -0
  46. package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
  47. package/lib/Signal/Group/sender-key-name.js +48 -0
  48. package/lib/Signal/Group/sender-key-name.js.map +1 -0
  49. package/lib/Signal/Group/sender-key-record.d.ts +31 -0
  50. package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
  51. package/lib/Signal/Group/sender-key-record.js +41 -0
  52. package/lib/Signal/Group/sender-key-record.js.map +1 -0
  53. package/lib/Signal/Group/sender-key-state.d.ts +39 -0
  54. package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
  55. package/lib/Signal/Group/sender-key-state.js +84 -0
  56. package/lib/Signal/Group/sender-key-state.js.map +1 -0
  57. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  58. package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
  59. package/lib/Signal/Group/sender-message-key.js +26 -0
  60. package/lib/Signal/Group/sender-message-key.js.map +1 -0
  61. package/lib/Signal/libsignal.d.ts +5 -0
  62. package/lib/Signal/libsignal.d.ts.map +1 -0
  63. package/lib/Signal/libsignal.js +431 -0
  64. package/lib/Signal/libsignal.js.map +1 -0
  65. package/lib/Signal/lid-mapping.d.ts +23 -0
  66. package/lib/Signal/lid-mapping.d.ts.map +1 -0
  67. package/lib/Signal/lid-mapping.js +277 -0
  68. package/lib/Signal/lid-mapping.js.map +1 -0
  69. package/lib/Socket/Client/index.d.ts +3 -0
  70. package/lib/Socket/Client/index.d.ts.map +1 -0
  71. package/lib/Socket/Client/index.js +3 -0
  72. package/lib/Socket/Client/index.js.map +1 -0
  73. package/lib/Socket/Client/types.d.ts +16 -0
  74. package/lib/Socket/Client/types.d.ts.map +1 -0
  75. package/lib/Socket/Client/types.js +11 -0
  76. package/lib/Socket/Client/types.js.map +1 -0
  77. package/lib/Socket/Client/websocket.d.ts +13 -0
  78. package/lib/Socket/Client/websocket.d.ts.map +1 -0
  79. package/lib/Socket/Client/websocket.js +54 -0
  80. package/lib/Socket/Client/websocket.js.map +1 -0
  81. package/lib/Socket/business.d.ts +218 -0
  82. package/lib/Socket/business.d.ts.map +1 -0
  83. package/lib/Socket/business.js +379 -0
  84. package/lib/Socket/business.js.map +1 -0
  85. package/lib/Socket/chats.d.ts +125 -0
  86. package/lib/Socket/chats.d.ts.map +1 -0
  87. package/lib/Socket/chats.js +1198 -0
  88. package/lib/Socket/chats.js.map +1 -0
  89. package/lib/Socket/communities.d.ts +274 -0
  90. package/lib/Socket/communities.d.ts.map +1 -0
  91. package/lib/Socket/communities.js +431 -0
  92. package/lib/Socket/communities.js.map +1 -0
  93. package/lib/Socket/groupStatus.d.ts +18 -0
  94. package/lib/Socket/groupStatus.d.ts.map +1 -0
  95. package/lib/Socket/groupStatus.js +30 -0
  96. package/lib/Socket/groupStatus.js.map +1 -0
  97. package/lib/Socket/groups.d.ts +161 -0
  98. package/lib/Socket/groups.d.ts.map +1 -0
  99. package/lib/Socket/groups.js +347 -0
  100. package/lib/Socket/groups.js.map +1 -0
  101. package/lib/Socket/index.d.ts +261 -0
  102. package/lib/Socket/index.d.ts.map +1 -0
  103. package/lib/Socket/index.js +12 -0
  104. package/lib/Socket/index.js.map +1 -0
  105. package/lib/Socket/messages-recv.d.ts +204 -0
  106. package/lib/Socket/messages-recv.d.ts.map +1 -0
  107. package/lib/Socket/messages-recv.js +1772 -0
  108. package/lib/Socket/messages-recv.js.map +1 -0
  109. package/lib/Socket/messages-send.d.ts +200 -0
  110. package/lib/Socket/messages-send.d.ts.map +1 -0
  111. package/lib/Socket/messages-send.js +1151 -0
  112. package/lib/Socket/messages-send.js.map +1 -0
  113. package/lib/Socket/mex.d.ts +3 -0
  114. package/lib/Socket/mex.d.ts.map +1 -0
  115. package/lib/Socket/mex.js +42 -0
  116. package/lib/Socket/mex.js.map +1 -0
  117. package/lib/Socket/newsletter.d.ts +170 -0
  118. package/lib/Socket/newsletter.d.ts.map +1 -0
  119. package/lib/Socket/newsletter.js +181 -0
  120. package/lib/Socket/newsletter.js.map +1 -0
  121. package/lib/Socket/socket.d.ts +59 -0
  122. package/lib/Socket/socket.d.ts.map +1 -0
  123. package/lib/Socket/socket.js +970 -0
  124. package/lib/Socket/socket.js.map +1 -0
  125. package/lib/Types/Auth.d.ts +117 -0
  126. package/lib/Types/Auth.d.ts.map +1 -0
  127. package/lib/Types/Auth.js +2 -0
  128. package/lib/Types/Auth.js.map +1 -0
  129. package/lib/Types/Bussines.d.ts +25 -0
  130. package/lib/Types/Bussines.d.ts.map +1 -0
  131. package/lib/Types/Bussines.js +2 -0
  132. package/lib/Types/Bussines.js.map +1 -0
  133. package/lib/Types/Call.d.ts +15 -0
  134. package/lib/Types/Call.d.ts.map +1 -0
  135. package/lib/Types/Call.js +2 -0
  136. package/lib/Types/Call.js.map +1 -0
  137. package/lib/Types/Chat.d.ts +124 -0
  138. package/lib/Types/Chat.d.ts.map +1 -0
  139. package/lib/Types/Chat.js +8 -0
  140. package/lib/Types/Chat.js.map +1 -0
  141. package/lib/Types/Contact.d.ts +26 -0
  142. package/lib/Types/Contact.d.ts.map +1 -0
  143. package/lib/Types/Contact.js +2 -0
  144. package/lib/Types/Contact.js.map +1 -0
  145. package/lib/Types/Events.d.ts +256 -0
  146. package/lib/Types/Events.d.ts.map +1 -0
  147. package/lib/Types/Events.js +2 -0
  148. package/lib/Types/Events.js.map +1 -0
  149. package/lib/Types/GroupMetadata.d.ts +71 -0
  150. package/lib/Types/GroupMetadata.d.ts.map +1 -0
  151. package/lib/Types/GroupMetadata.js +2 -0
  152. package/lib/Types/GroupMetadata.js.map +1 -0
  153. package/lib/Types/Label.d.ts +47 -0
  154. package/lib/Types/Label.d.ts.map +1 -0
  155. package/lib/Types/Label.js +25 -0
  156. package/lib/Types/Label.js.map +1 -0
  157. package/lib/Types/LabelAssociation.d.ts +30 -0
  158. package/lib/Types/LabelAssociation.d.ts.map +1 -0
  159. package/lib/Types/LabelAssociation.js +7 -0
  160. package/lib/Types/LabelAssociation.js.map +1 -0
  161. package/lib/Types/Message.d.ts +320 -0
  162. package/lib/Types/Message.d.ts.map +1 -0
  163. package/lib/Types/Message.js +11 -0
  164. package/lib/Types/Message.js.map +1 -0
  165. package/lib/Types/Mex.d.ts +141 -0
  166. package/lib/Types/Mex.d.ts.map +1 -0
  167. package/lib/Types/Mex.js +37 -0
  168. package/lib/Types/Mex.js.map +1 -0
  169. package/lib/Types/Product.d.ts +79 -0
  170. package/lib/Types/Product.d.ts.map +1 -0
  171. package/lib/Types/Product.js +2 -0
  172. package/lib/Types/Product.js.map +1 -0
  173. package/lib/Types/Signal.d.ts +87 -0
  174. package/lib/Types/Signal.d.ts.map +1 -0
  175. package/lib/Types/Signal.js +2 -0
  176. package/lib/Types/Signal.js.map +1 -0
  177. package/lib/Types/Socket.d.ts +136 -0
  178. package/lib/Types/Socket.d.ts.map +1 -0
  179. package/lib/Types/Socket.js +3 -0
  180. package/lib/Types/Socket.js.map +1 -0
  181. package/lib/Types/State.d.ts +97 -0
  182. package/lib/Types/State.d.ts.map +1 -0
  183. package/lib/Types/State.js +56 -0
  184. package/lib/Types/State.js.map +1 -0
  185. package/lib/Types/USync.d.ts +26 -0
  186. package/lib/Types/USync.d.ts.map +1 -0
  187. package/lib/Types/USync.js +2 -0
  188. package/lib/Types/USync.js.map +1 -0
  189. package/lib/Types/index.d.ts +66 -0
  190. package/lib/Types/index.d.ts.map +1 -0
  191. package/lib/Types/index.js +26 -0
  192. package/lib/Types/index.js.map +1 -0
  193. package/lib/Utils/auth-utils.d.ts +24 -0
  194. package/lib/Utils/auth-utils.d.ts.map +1 -0
  195. package/lib/Utils/auth-utils.js +302 -0
  196. package/lib/Utils/auth-utils.js.map +1 -0
  197. package/lib/Utils/browser-utils.d.ts +4 -0
  198. package/lib/Utils/browser-utils.d.ts.map +1 -0
  199. package/lib/Utils/browser-utils.js +29 -0
  200. package/lib/Utils/browser-utils.js.map +1 -0
  201. package/lib/Utils/business.d.ts +23 -0
  202. package/lib/Utils/business.d.ts.map +1 -0
  203. package/lib/Utils/business.js +231 -0
  204. package/lib/Utils/business.js.map +1 -0
  205. package/lib/Utils/chat-utils.d.ts +100 -0
  206. package/lib/Utils/chat-utils.d.ts.map +1 -0
  207. package/lib/Utils/chat-utils.js +872 -0
  208. package/lib/Utils/chat-utils.js.map +1 -0
  209. package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
  210. package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
  211. package/lib/Utils/companion-reg-client-utils.js +35 -0
  212. package/lib/Utils/companion-reg-client-utils.js.map +1 -0
  213. package/lib/Utils/crypto.d.ts +37 -0
  214. package/lib/Utils/crypto.d.ts.map +1 -0
  215. package/lib/Utils/crypto.js +118 -0
  216. package/lib/Utils/crypto.js.map +1 -0
  217. package/lib/Utils/decode-wa-message.d.ts +66 -0
  218. package/lib/Utils/decode-wa-message.d.ts.map +1 -0
  219. package/lib/Utils/decode-wa-message.js +317 -0
  220. package/lib/Utils/decode-wa-message.js.map +1 -0
  221. package/lib/Utils/event-buffer.d.ts +36 -0
  222. package/lib/Utils/event-buffer.d.ts.map +1 -0
  223. package/lib/Utils/event-buffer.js +622 -0
  224. package/lib/Utils/event-buffer.js.map +1 -0
  225. package/lib/Utils/generics.d.ts +92 -0
  226. package/lib/Utils/generics.d.ts.map +1 -0
  227. package/lib/Utils/generics.js +393 -0
  228. package/lib/Utils/generics.js.map +1 -0
  229. package/lib/Utils/history.d.ts +24 -0
  230. package/lib/Utils/history.d.ts.map +1 -0
  231. package/lib/Utils/history.js +134 -0
  232. package/lib/Utils/history.js.map +1 -0
  233. package/lib/Utils/identity-change-handler.d.ts +44 -0
  234. package/lib/Utils/identity-change-handler.d.ts.map +1 -0
  235. package/lib/Utils/identity-change-handler.js +50 -0
  236. package/lib/Utils/identity-change-handler.js.map +1 -0
  237. package/lib/Utils/index.d.ts +22 -0
  238. package/lib/Utils/index.d.ts.map +1 -0
  239. package/lib/Utils/index.js +22 -0
  240. package/lib/Utils/index.js.map +1 -0
  241. package/lib/Utils/link-preview.d.ts +21 -0
  242. package/lib/Utils/link-preview.d.ts.map +1 -0
  243. package/lib/Utils/link-preview.js +85 -0
  244. package/lib/Utils/link-preview.js.map +1 -0
  245. package/lib/Utils/logger.d.ts +12 -0
  246. package/lib/Utils/logger.d.ts.map +1 -0
  247. package/lib/Utils/logger.js +3 -0
  248. package/lib/Utils/logger.js.map +1 -0
  249. package/lib/Utils/lt-hash.d.ts +8 -0
  250. package/lib/Utils/lt-hash.d.ts.map +1 -0
  251. package/lib/Utils/lt-hash.js +8 -0
  252. package/lib/Utils/lt-hash.js.map +1 -0
  253. package/lib/Utils/make-mutex.d.ts +9 -0
  254. package/lib/Utils/make-mutex.d.ts.map +1 -0
  255. package/lib/Utils/make-mutex.js +33 -0
  256. package/lib/Utils/make-mutex.js.map +1 -0
  257. package/lib/Utils/message-retry-manager.d.ts +115 -0
  258. package/lib/Utils/message-retry-manager.d.ts.map +1 -0
  259. package/lib/Utils/message-retry-manager.js +265 -0
  260. package/lib/Utils/message-retry-manager.js.map +1 -0
  261. package/lib/Utils/messages-media.d.ts +133 -0
  262. package/lib/Utils/messages-media.d.ts.map +1 -0
  263. package/lib/Utils/messages-media.js +788 -0
  264. package/lib/Utils/messages-media.js.map +1 -0
  265. package/lib/Utils/messages.d.ts +91 -0
  266. package/lib/Utils/messages.d.ts.map +1 -0
  267. package/lib/Utils/messages.js +893 -0
  268. package/lib/Utils/messages.js.map +1 -0
  269. package/lib/Utils/noise-handler.d.ts +20 -0
  270. package/lib/Utils/noise-handler.d.ts.map +1 -0
  271. package/lib/Utils/noise-handler.js +201 -0
  272. package/lib/Utils/noise-handler.js.map +1 -0
  273. package/lib/Utils/offline-node-processor.d.ts +17 -0
  274. package/lib/Utils/offline-node-processor.d.ts.map +1 -0
  275. package/lib/Utils/offline-node-processor.js +40 -0
  276. package/lib/Utils/offline-node-processor.js.map +1 -0
  277. package/lib/Utils/pre-key-manager.d.ts +28 -0
  278. package/lib/Utils/pre-key-manager.d.ts.map +1 -0
  279. package/lib/Utils/pre-key-manager.js +106 -0
  280. package/lib/Utils/pre-key-manager.js.map +1 -0
  281. package/lib/Utils/process-message.d.ts +60 -0
  282. package/lib/Utils/process-message.d.ts.map +1 -0
  283. package/lib/Utils/process-message.js +630 -0
  284. package/lib/Utils/process-message.js.map +1 -0
  285. package/lib/Utils/reporting-utils.d.ts +11 -0
  286. package/lib/Utils/reporting-utils.d.ts.map +1 -0
  287. package/lib/Utils/reporting-utils.js +258 -0
  288. package/lib/Utils/reporting-utils.js.map +1 -0
  289. package/lib/Utils/signal.d.ts +47 -0
  290. package/lib/Utils/signal.d.ts.map +1 -0
  291. package/lib/Utils/signal.js +201 -0
  292. package/lib/Utils/signal.js.map +1 -0
  293. package/lib/Utils/stanza-ack.d.ts +11 -0
  294. package/lib/Utils/stanza-ack.d.ts.map +1 -0
  295. package/lib/Utils/stanza-ack.js +38 -0
  296. package/lib/Utils/stanza-ack.js.map +1 -0
  297. package/lib/Utils/sync-action-utils.d.ts +19 -0
  298. package/lib/Utils/sync-action-utils.d.ts.map +1 -0
  299. package/lib/Utils/sync-action-utils.js +49 -0
  300. package/lib/Utils/sync-action-utils.js.map +1 -0
  301. package/lib/Utils/tc-token-utils.d.ts +37 -0
  302. package/lib/Utils/tc-token-utils.d.ts.map +1 -0
  303. package/lib/Utils/tc-token-utils.js +164 -0
  304. package/lib/Utils/tc-token-utils.js.map +1 -0
  305. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  306. package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
  307. package/lib/Utils/use-multi-file-auth-state.js +121 -0
  308. package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
  309. package/lib/Utils/validate-connection.d.ts +11 -0
  310. package/lib/Utils/validate-connection.d.ts.map +1 -0
  311. package/lib/Utils/validate-connection.js +210 -0
  312. package/lib/Utils/validate-connection.js.map +1 -0
  313. package/lib/WABinary/constants.d.ts +28 -0
  314. package/lib/WABinary/constants.d.ts.map +1 -0
  315. package/lib/WABinary/constants.js +1301 -0
  316. package/lib/WABinary/constants.js.map +1 -0
  317. package/lib/WABinary/decode.d.ts +7 -0
  318. package/lib/WABinary/decode.d.ts.map +1 -0
  319. package/lib/WABinary/decode.js +262 -0
  320. package/lib/WABinary/decode.js.map +1 -0
  321. package/lib/WABinary/encode.d.ts +3 -0
  322. package/lib/WABinary/encode.d.ts.map +1 -0
  323. package/lib/WABinary/encode.js +220 -0
  324. package/lib/WABinary/encode.js.map +1 -0
  325. package/lib/WABinary/generic-utils.d.ts +15 -0
  326. package/lib/WABinary/generic-utils.d.ts.map +1 -0
  327. package/lib/WABinary/generic-utils.js +113 -0
  328. package/lib/WABinary/generic-utils.js.map +1 -0
  329. package/lib/WABinary/index.d.ts +6 -0
  330. package/lib/WABinary/index.d.ts.map +1 -0
  331. package/lib/WABinary/index.js +6 -0
  332. package/lib/WABinary/index.js.map +1 -0
  333. package/lib/WABinary/jid-utils.d.ts +48 -0
  334. package/lib/WABinary/jid-utils.d.ts.map +1 -0
  335. package/lib/WABinary/jid-utils.js +96 -0
  336. package/lib/WABinary/jid-utils.js.map +1 -0
  337. package/lib/WABinary/types.d.ts +19 -0
  338. package/lib/WABinary/types.d.ts.map +1 -0
  339. package/lib/WABinary/types.js +2 -0
  340. package/lib/WABinary/types.js.map +1 -0
  341. package/lib/WAM/BinaryInfo.d.ts +9 -0
  342. package/lib/WAM/BinaryInfo.d.ts.map +1 -0
  343. package/lib/WAM/BinaryInfo.js +10 -0
  344. package/lib/WAM/BinaryInfo.js.map +1 -0
  345. package/lib/WAM/constants.d.ts +40 -0
  346. package/lib/WAM/constants.d.ts.map +1 -0
  347. package/lib/WAM/constants.js +22853 -0
  348. package/lib/WAM/constants.js.map +1 -0
  349. package/lib/WAM/encode.d.ts +3 -0
  350. package/lib/WAM/encode.d.ts.map +1 -0
  351. package/lib/WAM/encode.js +150 -0
  352. package/lib/WAM/encode.js.map +1 -0
  353. package/lib/WAM/index.d.ts +4 -0
  354. package/lib/WAM/index.d.ts.map +1 -0
  355. package/lib/WAM/index.js +4 -0
  356. package/lib/WAM/index.js.map +1 -0
  357. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  358. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
  359. package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
  360. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
  361. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  362. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
  363. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
  364. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
  365. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  366. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
  367. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  368. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
  369. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  370. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
  371. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  372. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
  373. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  374. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
  375. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  376. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
  377. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
  378. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
  379. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  380. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
  381. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  382. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
  383. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  384. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
  385. package/lib/WAUSync/Protocols/index.d.ts +6 -0
  386. package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
  387. package/lib/WAUSync/Protocols/index.js +6 -0
  388. package/lib/WAUSync/Protocols/index.js.map +1 -0
  389. package/lib/WAUSync/USyncQuery.d.ts +30 -0
  390. package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
  391. package/lib/WAUSync/USyncQuery.js +98 -0
  392. package/lib/WAUSync/USyncQuery.js.map +1 -0
  393. package/lib/WAUSync/USyncUser.d.ts +17 -0
  394. package/lib/WAUSync/USyncUser.d.ts.map +1 -0
  395. package/lib/WAUSync/USyncUser.js +31 -0
  396. package/lib/WAUSync/USyncUser.js.map +1 -0
  397. package/lib/WAUSync/index.d.ts +4 -0
  398. package/lib/WAUSync/index.d.ts.map +1 -0
  399. package/lib/WAUSync/index.js +4 -0
  400. package/lib/WAUSync/index.js.map +1 -0
  401. package/lib/index.d.ts +12 -0
  402. package/lib/index.d.ts.map +1 -0
  403. package/lib/index.js +11 -0
  404. package/lib/index.js.map +1 -0
  405. package/package.json +137 -4
package/README.md CHANGED
@@ -1,3 +1,1359 @@
1
- # Temporary Holding Version
1
+ <h1 align='center'><img alt="Baileys logo" src="https://raw.githubusercontent.com/WhiskeySockets/Baileys/refs/heads/master/Media/logo.png" height="75"/></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
+ <div align='center'>Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API.</div>
4
+
5
+
6
+ > [!CAUTION]
7
+ > NOTICE OF BREAKING CHANGE.
8
+ >
9
+ > As of 7.0.0, multiple breaking changes were introduced into the library.
10
+ >
11
+ > Please check out https://whiskey.so/migrate-latest for more information.
12
+
13
+ # Important Note
14
+ This is a temporary README.md, the new guide is in development and will this file will be replaced with .github/README.md (already a default on GitHub).
15
+
16
+ New guide link: https://baileys.wiki
17
+
18
+ # Get Support
19
+
20
+ If you'd like business to enterprise-level support from Rajeh, the current maintainer of Baileys, you can book a video chat. Book a 1 hour time slot by contacting him on Discord or pre-ordering [here](https://purpshell.dev/book). The earlier you pre-order the better, as his time slots usually fill up very quickly. He offers immense value per hour and will answer all your questions before the time runs out.
21
+
22
+ If you are a business, we encourage you to contribute back to the high development costs of the project and to feed the maintainers who dump tens of hours a week on this. You can do so by booking meetings or sponsoring below. All support, even in bona fide / contribution hours, is welcome by businesses of all sizes. This is not condoning or endorsing businesses to use the library. See the Disclaimer below.
23
+
24
+ # Sponsor
25
+ If you'd like to financially support this project, you can do so by supporting the current maintainer [here](https://purpshell.dev/sponsor).
26
+
27
+ # Disclaimer
28
+ This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates.
29
+ The official WhatsApp website can be found at whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
30
+
31
+ The maintainers of Baileys do not in any way condone the use of this application in practices that violate the Terms of Service of WhatsApp. The maintainers of this application call upon the personal responsibility of its users to use this application in a fair way, as it is intended to be used.
32
+ Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
33
+
34
+ ##
35
+
36
+ - Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
37
+ - Not running Selenium or Chromium saves you like **half a gig** of ram :/
38
+ - Baileys supports interacting with the multi-device & web versions of WhatsApp.
39
+ - Thank you to [@pokearaujo](https://github.com/pokearaujo/multidevice) for writing his observations on the workings of WhatsApp Multi-Device. Also, thank you to [@Sigalor](https://github.com/sigalor/whatsapp-web-reveng) for writing his observations on the workings of WhatsApp Web and thanks to [@Rhymen](https://github.com/Rhymen/go-whatsapp/) for the __go__ implementation.
40
+
41
+ > [!IMPORTANT]
42
+ > The original repository had to be removed by the original author - we now continue development in this repository here.
43
+ This is the only official repository and is maintained by the community.
44
+ > **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
45
+
46
+ ## Example
47
+
48
+ Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
49
+ The script covers most common use cases.
50
+ To run the example script, download or clone the repo and then type the following in a terminal:
51
+ 1. ``` cd path/to/Baileys ```
52
+ 2. ``` yarn ```
53
+ 3. ``` yarn example ```
54
+
55
+ ## Install
56
+
57
+ Use the stable version:
58
+ ```
59
+ yarn add @whiskeysockets/baileys
60
+ ```
61
+
62
+ Use the edge version (no guarantee of stability, but latest fixes + features)
63
+ ```
64
+ yarn add github:WhiskeySockets/Baileys
65
+ ```
66
+
67
+ Then import your code using:
68
+ ```ts
69
+ import makeWASocket from '@whiskeysockets/baileys'
70
+ ```
71
+
72
+ This modified fork is packaged as `junexbaileys@1.0.1`. After publishing it, install it directly with `npm install junexbaileys`. To keep the upstream import name in an application, use this dependency entry in that application's `package.json`:
73
+
74
+ ```json
75
+ {
76
+ "dependencies": {
77
+ "@whiskeysockets/baileys": "npm:junexbaileys@1.0.1"
78
+ }
79
+ }
80
+ ```
81
+
82
+ # Links
83
+
84
+ - [Discord](https://discord.gg/WeJM5FP9GG)
85
+ - [Docs](https://baileys.wiki/docs/intro/)
86
+
87
+ # Index
88
+
89
+ - [Connecting Account](#connecting-account)
90
+ - [Connect with QR-CODE](#starting-socket-with-qr-code)
91
+ - [Connect with Pairing Code](#starting-socket-with-pairing-code)
92
+ - [Receive Full History](#receive-full-history)
93
+ - [Important Notes About Socket Config](#important-notes-about-socket-config)
94
+ - [Caching Group Metadata (Recommended)](#caching-group-metadata-recommended)
95
+ - [Improve Retry System & Decrypt Poll Votes](#improve-retry-system--decrypt-poll-votes)
96
+ - [Receive Notifications in Whatsapp App](#receive-notifications-in-whatsapp-app)
97
+
98
+ - [Save Auth Info](#saving--restoring-sessions)
99
+ - [Handling Events](#handling-events)
100
+ - [Example to Start](#example-to-start)
101
+ - [Decrypt Poll Votes](#decrypt-poll-votes)
102
+ - [Summary of Events on First Connection](#summary-of-events-on-first-connection)
103
+ - [Implementing a Data Store](#implementing-a-data-store)
104
+ - [Whatsapp IDs Explain](#whatsapp-ids-explain)
105
+ - [Utility Functions](#utility-functions)
106
+ - [Sending Messages](#sending-messages)
107
+ - [Non-Media Messages](#non-media-messages)
108
+ - [Text Message](#text-message)
109
+ - [Quote Message](#quote-message-works-with-all-types)
110
+ - [Mention User](#mention-user-works-with-most-types)
111
+ - [Forward Messages](#forward-messages)
112
+ - [Location Message](#location-message)
113
+ - [Contact Message](#contact-message)
114
+ - [Reaction Message](#reaction-message)
115
+ - [Pin Message](#pin-message)
116
+ - [Poll Message](#poll-message)
117
+ - [Sending with Link Preview](#sending-messages-with-link-previews)
118
+ - [Media Messages](#media-messages)
119
+ - [Gif Message](#gif-message)
120
+ - [Video Message](#video-message)
121
+ - [Audio Message](#audio-message)
122
+ - [Image Message](#image-message)
123
+ - [ViewOnce Message](#view-once-message)
124
+ - [Modify Messages](#modify-messages)
125
+ - [Delete Messages (for everyone)](#deleting-messages-for-everyone)
126
+ - [Edit Messages](#editing-messages)
127
+ - [Manipulating Media Messages](#manipulating-media-messages)
128
+ - [Thumbnail in Media Messages](#thumbnail-in-media-messages)
129
+ - [Downloading Media Messages](#downloading-media-messages)
130
+ - [Re-upload Media Message to Whatsapp](#re-upload-media-message-to-whatsapp)
131
+ - [Reject Call](#reject-call)
132
+ - [Send States in Chat](#send-states-in-chat)
133
+ - [Reading Messages](#reading-messages)
134
+ - [Update Presence](#update-presence)
135
+ - [Modifying Chats](#modifying-chats)
136
+ - [Archive a Chat](#archive-a-chat)
137
+ - [Mute/Unmute a Chat](#muteunmute-a-chat)
138
+ - [Mark a Chat Read/Unread](#mark-a-chat-readunread)
139
+ - [Delete a Message for Me](#delete-a-message-for-me)
140
+ - [Delete a Chat](#delete-a-chat)
141
+ - [Star/Unstar a Message](#starunstar-a-message)
142
+ - [Disappearing Messages](#disappearing-messages)
143
+ - [User Querys](#user-querys)
144
+ - [Check If ID Exists in Whatsapp](#check-if-id-exists-in-whatsapp)
145
+ - [Query Chat History (groups too)](#query-chat-history-groups-too)
146
+ - [Fetch Status](#fetch-status)
147
+ - [Fetch Profile Picture (groups too)](#fetch-profile-picture-groups-too)
148
+ - [Fetch Bussines Profile (such as description or category)](#fetch-bussines-profile-such-as-description-or-category)
149
+ - [Fetch Someone's Presence (if they're typing or online)](#fetch-someones-presence-if-theyre-typing-or-online)
150
+ - [Change Profile](#change-profile)
151
+ - [Change Profile Status](#change-profile-status)
152
+ - [Change Profile Name](#change-profile-name)
153
+ - [Change Display Picture (groups too)](#change-display-picture-groups-too)
154
+ - [Remove display picture (groups too)](#remove-display-picture-groups-too)
155
+ - [Groups](#groups)
156
+ - [Create a Group](#create-a-group)
157
+ - [Add/Remove or Demote/Promote](#addremove-or-demotepromote)
158
+ - [Change Subject (name)](#change-subject-name)
159
+ - [Change Description](#change-description)
160
+ - [Change Settings](#change-settings)
161
+ - [Leave a Group](#leave-a-group)
162
+ - [Get Invite Code](#get-invite-code)
163
+ - [Revoke Invite Code](#revoke-invite-code)
164
+ - [Join Using Invitation Code](#join-using-invitation-code)
165
+ - [Get Group Info by Invite Code](#get-group-info-by-invite-code)
166
+ - [Query Metadata (participants, name, description...)](#query-metadata-participants-name-description)
167
+ - [Join using groupInviteMessage](#join-using-groupinvitemessage)
168
+ - [Get Request Join List](#get-request-join-list)
169
+ - [Approve/Reject Request Join](#approvereject-request-join)
170
+ - [Get All Participating Groups Metadata](#get-all-participating-groups-metadata)
171
+ - [Toggle Ephemeral](#toggle-ephemeral)
172
+ - [Change Add Mode](#change-add-mode)
173
+ - [Privacy](#privacy)
174
+ - [Block/Unblock User](#blockunblock-user)
175
+ - [Get Privacy Settings](#get-privacy-settings)
176
+ - [Get BlockList](#get-blocklist)
177
+ - [Update LastSeen Privacy](#update-lastseen-privacy)
178
+ - [Update Online Privacy](#update-online-privacy)
179
+ - [Update Profile Picture Privacy](#update-profile-picture-privacy)
180
+ - [Update Status Privacy](#update-status-privacy)
181
+ - [Update Read Receipts Privacy](#update-read-receipts-privacy)
182
+ - [Update Groups Add Privacy](#update-groups-add-privacy)
183
+ - [Update Default Disappearing Mode](#update-default-disappearing-mode)
184
+ - [Broadcast Lists & Stories](#broadcast-lists--stories)
185
+ - [Send Broadcast & Stories](#send-broadcast--stories)
186
+ - [Experimental Group Status Media](#experimental-group-status-media)
187
+ - [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
188
+ - [Writing Custom Functionality](#writing-custom-functionality)
189
+ - [Enabling Debug Level in Baileys Logs](#enabling-debug-level-in-baileys-logs)
190
+ - [How Whatsapp Communicate With Us](#how-whatsapp-communicate-with-us)
191
+ - [Register a Callback for Websocket Events](#register-a-callback-for-websocket-events)
192
+
193
+ ## Connecting Account
194
+
195
+ WhatsApp provides a multi-device API that allows Baileys to be authenticated as a second WhatsApp client by scanning a **QR code** or **Pairing Code** with WhatsApp on your phone.
196
+
197
+ > [!NOTE]
198
+ > **[Here](#example-to-start) is a simple example of event handling**
199
+
200
+ > [!TIP]
201
+ > **You can see all supported socket configs in the [SocketConfig type alias](https://baileys.wiki/docs/api/type-aliases/SocketConfig/) (Recommended)**
202
+
203
+ ### Starting socket with **QR-CODE**
204
+
205
+ > [!TIP]
206
+ > You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see the [BrowsersMap type alias](https://baileys.wiki/docs/api/type-aliases/BrowsersMap/)**
207
+
208
+ ```ts
209
+ import makeWASocket from '@whiskeysockets/baileys'
210
+
211
+ const sock = makeWASocket({
212
+ // can provide additional config here
213
+ browser: Browsers.ubuntu('My App'),
214
+ printQRInTerminal: true
215
+ })
216
+ ```
217
+
218
+ If the connection is successful, you will see a QR code printed on your terminal screen, scan it with WhatsApp on your phone and you'll be logged in!
219
+
220
+ ### Starting socket with **Pairing Code**
221
+
222
+
223
+ > [!IMPORTANT]
224
+ > Pairing Code isn't Mobile API, it's a method to connect Whatsapp Web without QR-CODE, you can connect only with one device, see [here](https://faq.whatsapp.com/1324084875126592/?cms_platform=web)
225
+
226
+ The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
227
+
228
+ ```ts
229
+ import makeWASocket from '@whiskeysockets/baileys'
230
+
231
+ const sock = makeWASocket({
232
+ // can provide additional config here
233
+ printQRInTerminal: false //need to be false
234
+ })
235
+
236
+ if (!sock.authState.creds.registered) {
237
+ const number = 'XXXXXXXXXXX'
238
+ const code = await sock.requestPairingCode(number)
239
+ console.log(code)
240
+ }
241
+ ```
242
+
243
+ ### Receive Full History
244
+
245
+ 1. Set `syncFullHistory` as `true`
246
+ 2. Baileys, by default, use chrome browser config
247
+ - If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
248
+
249
+ ```ts
250
+ const sock = makeWASocket({
251
+ ...otherOpts,
252
+ // can use Windows, Ubuntu here too
253
+ browser: Browsers.macOS('Desktop'),
254
+ syncFullHistory: true
255
+ })
256
+ ```
257
+
258
+ ## Important Notes About Socket Config
259
+
260
+ ### Caching Group Metadata (Recommended)
261
+ - If you use baileys for groups, we recommend you to set `cachedGroupMetadata` in socket config, you need to implement a cache like this:
262
+
263
+ ```ts
264
+ const groupCache = new NodeCache({stdTTL: 5 * 60, useClones: false})
265
+
266
+ const sock = makeWASocket({
267
+ cachedGroupMetadata: async (jid) => groupCache.get(jid)
268
+ })
269
+
270
+ sock.ev.on('groups.update', async ([event]) => {
271
+ const metadata = await sock.groupMetadata(event.id)
272
+ groupCache.set(event.id, metadata)
273
+ })
274
+
275
+ sock.ev.on('group-participants.update', async (event) => {
276
+ const metadata = await sock.groupMetadata(event.id)
277
+ groupCache.set(event.id, metadata)
278
+ })
279
+ ```
280
+
281
+ ### Improve Retry System & Decrypt Poll Votes
282
+ - If you want to improve sending message, retrying when error occurs and decrypt poll votes, you need to have a store and set `getMessage` config in socket like this:
283
+ ```ts
284
+ const sock = makeWASocket({
285
+ getMessage: async (key) => await getMessageFromStore(key)
286
+ })
287
+ ```
288
+
289
+ ### Receive Notifications in Whatsapp App
290
+ - If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
291
+ ```ts
292
+ const sock = makeWASocket({
293
+ markOnlineOnConnect: false
294
+ })
295
+ ```
296
+ ## Saving & Restoring Sessions
297
+
298
+ You obviously don't want to keep scanning the QR code every time you want to connect.
299
+
300
+ So, you can load the credentials to log back in:
301
+ ```ts
302
+ import makeWASocket, { useMultiFileAuthState } from '@whiskeysockets/baileys'
303
+
304
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
305
+
306
+ // will use the given state to connect
307
+ // so if valid credentials are available -- it'll connect without QR
308
+ const sock = makeWASocket({ auth: state })
309
+
310
+ // this will be called as soon as the credentials are updated
311
+ sock.ev.on('creds.update', saveCreds)
312
+ ```
313
+
314
+ > [!IMPORTANT]
315
+ > `useMultiFileAuthState` is a utility function to help save the auth state in a single folder, this function serves as a good guide to help write auth & key states for SQL/no-SQL databases, which I would recommend in any production grade system.
316
+
317
+ > [!NOTE]
318
+ > When a message is received/sent, due to signal sessions needing updating, the auth keys (`authState.keys`) will update. Whenever that happens, you must save the updated keys (`authState.keys.set()` is called). Not doing so will prevent your messages from reaching the recipient & cause other unexpected consequences. The `useMultiFileAuthState` function automatically takes care of that, but for any other serious implementation -- you will need to be very careful with the key state management.
319
+
320
+ ## Handling Events
321
+
322
+ - Baileys uses the EventEmitter syntax for events.
323
+ They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
324
+
325
+ > [!IMPORTANT]
326
+ > **The events are in the [BaileysEventMap type alias](https://baileys.wiki/docs/api/type-aliases/BaileysEventMap/)**, it's important you see all events
327
+
328
+ You can listen to these events like this:
329
+ ```ts
330
+ const sock = makeWASocket()
331
+ sock.ev.on('messages.upsert', ({ messages }) => {
332
+ console.log('got messages', messages)
333
+ })
334
+ ```
335
+
336
+ ### Example to Start
337
+
338
+ > [!NOTE]
339
+ > This example includes basic auth storage too
340
+
341
+ > [!NOTE]
342
+ > For reliable serialization of the authentication state, especially when storing as JSON, always use the BufferJSON utility.
343
+
344
+ ```ts
345
+ import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@whiskeysockets/baileys'
346
+ import { Boom } from '@hapi/boom'
347
+
348
+ async function connectToWhatsApp () {
349
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
350
+ const sock = makeWASocket({
351
+ // can provide additional config here
352
+ auth: state,
353
+ printQRInTerminal: true
354
+ })
355
+ sock.ev.on('connection.update', (update) => {
356
+ const { connection, lastDisconnect } = update
357
+ if(connection === 'close') {
358
+ const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
359
+ console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect)
360
+ // reconnect if not logged out
361
+ if(shouldReconnect) {
362
+ connectToWhatsApp()
363
+ }
364
+ } else if(connection === 'open') {
365
+ console.log('opened connection')
366
+ }
367
+ })
368
+ sock.ev.on('messages.upsert', event => {
369
+ for (const m of event.messages) {
370
+ console.log(JSON.stringify(m, undefined, 2))
371
+
372
+ console.log('replying to', m.key.remoteJid)
373
+ await sock.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
374
+ }
375
+ })
376
+
377
+ // to storage creds (session info) when it updates
378
+ sock.ev.on('creds.update', saveCreds)
379
+ }
380
+ // run in main file
381
+ connectToWhatsApp()
382
+ ```
383
+
384
+ > [!IMPORTANT]
385
+ > In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
386
+
387
+ ### Decrypt Poll Votes
388
+
389
+ - By default poll votes are encrypted and handled in `messages.update`
390
+ - That's a simple example
391
+ ```ts
392
+ sock.ev.on('messages.update', event => {
393
+ for(const { key, update } of event) {
394
+ if(update.pollUpdates) {
395
+ const pollCreation = await getMessage(key)
396
+ if(pollCreation) {
397
+ console.log(
398
+ 'got poll update, aggregation: ',
399
+ getAggregateVotesInPollMessage({
400
+ message: pollCreation,
401
+ pollUpdates: update.pollUpdates,
402
+ })
403
+ )
404
+ }
405
+ }
406
+ }
407
+ })
408
+ ```
409
+
410
+ - `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)
411
+
412
+ ### Summary of Events on First Connection
413
+
414
+ 1. When you connect first time, `connection.update` will be fired requesting you to restart sock
415
+ 2. Then, history messages will be received in `messaging.history-set`
416
+
417
+ ## Implementing a Data Store
418
+
419
+ - Baileys does not come with a defacto storage for chats, contacts, or messages. However, a simple in-memory implementation has been provided. The store listens for chat updates, new messages, message updates, etc., to always have an up-to-date version of the data.
420
+
421
+ > [!IMPORTANT]
422
+ > I highly recommend building your own data store, as storing someone's entire chat history in memory is a terrible waste of RAM.
423
+
424
+ It can be used as follows:
425
+
426
+ ```ts
427
+ import makeWASocket, { makeInMemoryStore } from '@whiskeysockets/baileys'
428
+ // the store maintains the data of the WA connection in memory
429
+ // can be written out to a file & read from it
430
+ const store = makeInMemoryStore({ })
431
+ // can be read from a file
432
+ store.readFromFile('./baileys_store.json')
433
+ // saves the state to a file every 10s
434
+ setInterval(() => {
435
+ store.writeToFile('./baileys_store.json')
436
+ }, 10_000)
437
+
438
+ const sock = makeWASocket({ })
439
+ // will listen from this socket
440
+ // the store can listen from a new socket once the current socket outlives its lifetime
441
+ store.bind(sock.ev)
442
+
443
+ sock.ev.on('chats.upsert', () => {
444
+ // can use 'store.chats' however you want, even after the socket dies out
445
+ // 'chats' => a KeyedDB instance
446
+ console.log('got chats', store.chats.all())
447
+ })
448
+
449
+ sock.ev.on('contacts.upsert', () => {
450
+ console.log('got contacts', Object.values(store.contacts))
451
+ })
452
+
453
+ ```
454
+
455
+ The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
456
+
457
+ ## Whatsapp IDs Explain
458
+
459
+ - `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
460
+ - It must be in the format ```[country code][phone number]@s.whatsapp.net```
461
+ - Example for people: ```+19999999999@s.whatsapp.net```.
462
+ - For groups, it must be in the format ``` 123456789-123345@g.us ```.
463
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
464
+ - For stories, the ID is `status@broadcast`.
465
+
466
+ ## Utility Functions
467
+
468
+ - `getContentType`, returns the content type for any message
469
+ - `getDevice`, returns the device from message
470
+ - `makeCacheableSignalKeyStore`, make auth store more fast
471
+ - `downloadContentFromMessage`, download content from any message
472
+
473
+ ## Sending Messages
474
+
475
+ - Send all types of messages with a single function
476
+ - **In the [AnyMessageContent type alias](https://baileys.wiki/docs/api/type-aliases/AnyMessageContent/) you can see all message contents supported, like text message**
477
+ - **In the [MiscMessageGenerationOptions type alias](https://baileys.wiki/docs/api/type-aliases/MiscMessageGenerationOptions/) you can see all options supported, like quote message**
478
+
479
+ ```ts
480
+ const jid: string
481
+ const content: AnyMessageContent
482
+ const options: MiscMessageGenerationOptions
483
+
484
+ sock.sendMessage(jid, content, options)
485
+ ```
486
+
487
+ ### Non-Media Messages
488
+
489
+ #### Text Message
490
+ ```ts
491
+ await sock.sendMessage(jid, { text: 'hello word' })
492
+ ```
493
+
494
+ #### Quote Message (works with all types)
495
+ ```ts
496
+ await sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })
497
+ ```
498
+
499
+ #### Mention User (works with most types)
500
+ - @number is to mention in text, it's optional
501
+ ```ts
502
+ await sock.sendMessage(
503
+ jid,
504
+ {
505
+ text: '@12345678901',
506
+ mentions: ['12345678901@s.whatsapp.net']
507
+ }
508
+ )
509
+ ```
510
+
511
+ #### Forward Messages
512
+ - You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://baileys.wiki/docs/api/type-aliases/WAMessage/) object
513
+ ```ts
514
+ const msg = getMessageFromStore() // implement this on your end
515
+ await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
516
+ ```
517
+
518
+ #### Location Message
519
+ ```ts
520
+ await sock.sendMessage(
521
+ jid,
522
+ {
523
+ location: {
524
+ degreesLatitude: 24.121231,
525
+ degreesLongitude: 55.1121221
526
+ }
527
+ }
528
+ )
529
+ ```
530
+ #### Contact Message
531
+ ```ts
532
+ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
533
+ + 'VERSION:3.0\n'
534
+ + 'FN:Jeff Singh\n' // full name
535
+ + 'ORG:Ashoka Uni;\n' // the organization of the contact
536
+ + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
537
+ + 'END:VCARD'
538
+
539
+ await sock.sendMessage(
540
+ id,
541
+ {
542
+ contacts: {
543
+ displayName: 'Jeff',
544
+ contacts: [{ vcard }]
545
+ }
546
+ }
547
+ )
548
+ ```
549
+
550
+ #### Reaction Message
551
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.wiki/docs/api/type-aliases/WAMessageKey/) object
552
+ ```ts
553
+ await sock.sendMessage(
554
+ jid,
555
+ {
556
+ react: {
557
+ text: '💖', // use an empty string to remove the reaction
558
+ key: message.key
559
+ }
560
+ }
561
+ )
562
+ ```
563
+
564
+ #### Pin Message
565
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.wiki/docs/api/type-aliases/WAMessageKey/) object
566
+
567
+ - Time can be:
568
+
569
+ | Time | Seconds |
570
+ |-------|----------------|
571
+ | 24h | 86.400 |
572
+ | 7d | 604.800 |
573
+ | 30d | 2.592.000 |
574
+
575
+ ```ts
576
+ await sock.sendMessage(
577
+ jid,
578
+ {
579
+ pin: {
580
+ type: 1, // 0 to remove
581
+ time: 86400
582
+ key: message.key
583
+ }
584
+ }
585
+ )
586
+ ```
587
+
588
+ #### Poll Message
589
+ ```ts
590
+ await sock.sendMessage(
591
+ jid,
592
+ {
593
+ poll: {
594
+ name: 'My Poll',
595
+ values: ['Option 1', 'Option 2', ...],
596
+ selectableCount: 1,
597
+ toAnnouncementGroup: false // or true
598
+ }
599
+ }
600
+ )
601
+ ```
602
+
603
+ ### Sending Messages with Link Previews
604
+
605
+ 1. By default, wa does not have link generation when sent from the web
606
+ 2. Baileys has a function to generate the content for these link previews
607
+ 3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
608
+ 4. Send a link:
609
+ ```ts
610
+ await sock.sendMessage(
611
+ jid,
612
+ {
613
+ text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
614
+ }
615
+ )
616
+ ```
617
+
618
+ ### Media Messages
619
+
620
+ Sending media (video, stickers, images) is easier & more efficient than ever.
621
+
622
+ > [!NOTE]
623
+ > In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more in the [WAMediaUpload type alias](https://baileys.wiki/docs/api/type-aliases/WAMediaUpload/)
624
+
625
+ - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
626
+
627
+ > [!TIP]
628
+ > It's recommended to use Stream or Url to save memory
629
+
630
+ #### Gif Message
631
+ - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
632
+ ```ts
633
+ await sock.sendMessage(
634
+ jid,
635
+ {
636
+ video: fs.readFileSync('Media/ma_gif.mp4'),
637
+ caption: 'hello word',
638
+ gifPlayback: true
639
+ }
640
+ )
641
+ ```
642
+
643
+ #### Video Message
644
+ ```ts
645
+ await sock.sendMessage(
646
+ id,
647
+ {
648
+ video: {
649
+ url: './Media/ma_gif.mp4'
650
+ },
651
+ caption: 'hello word',
652
+ ptv: false // if set to true, will send as a `video note`
653
+ }
654
+ )
655
+ ```
656
+
657
+ #### Audio Message
658
+ - To audio message work in all devices you need to convert with some tool like `ffmpeg` with this flags:
659
+ ```bash
660
+ codec: libopus //ogg file
661
+ ac: 1 //one channel
662
+ avoid_negative_ts
663
+ make_zero
664
+ ```
665
+ - Example:
666
+ ```bash
667
+ ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
668
+ ```
669
+ ```ts
670
+ await sock.sendMessage(
671
+ jid,
672
+ {
673
+ audio: {
674
+ url: './Media/audio.mp3'
675
+ },
676
+ mimetype: 'audio/mp4'
677
+ }
678
+ )
679
+ ```
680
+
681
+ #### Image Message
682
+ ```ts
683
+ await sock.sendMessage(
684
+ id,
685
+ {
686
+ image: {
687
+ url: './Media/ma_img.png'
688
+ },
689
+ caption: 'hello word'
690
+ }
691
+ )
692
+ ```
693
+
694
+ #### View Once Message
695
+
696
+ - You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
697
+
698
+ ```ts
699
+ await sock.sendMessage(
700
+ id,
701
+ {
702
+ image: {
703
+ url: './Media/ma_img.png'
704
+ },
705
+ viewOnce: true, //works with video, audio too
706
+ caption: 'hello word'
707
+ }
708
+ )
709
+ ```
710
+
711
+ ## Modify Messages
712
+
713
+ ### Deleting Messages (for everyone)
714
+
715
+ ```ts
716
+ const msg = await sock.sendMessage(jid, { text: 'hello word' })
717
+ await sock.sendMessage(jid, { delete: msg.key })
718
+ ```
719
+
720
+ **Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
721
+
722
+ ### Editing Messages
723
+
724
+ - You can pass all editable contents here
725
+ ```ts
726
+ await sock.sendMessage(jid, {
727
+ text: 'updated text goes here',
728
+ edit: response.key,
729
+ });
730
+ ```
731
+
732
+ ## Manipulating Media Messages
733
+
734
+ ### Thumbnail in Media Messages
735
+ - For media messages, the thumbnail can be generated automatically for images & stickers provided you add `jimp` or `sharp` as a dependency in your project using `yarn add jimp` or `yarn add sharp`.
736
+ - Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
737
+
738
+ ### Downloading Media Messages
739
+
740
+ If you want to save the media you received
741
+ ```ts
742
+ import { createWriteStream } from 'fs'
743
+ import { downloadMediaMessage, getContentType } from '@whiskeysockets/baileys'
744
+
745
+ sock.ev.on('messages.upsert', async ({ [m] }) => {
746
+ if (!m.message) return // if there is no text or media message
747
+ const messageType = getContentType(m) // get what type of message it is (text, image, video...)
748
+
749
+ // if the message is an image
750
+ if (messageType === 'imageMessage') {
751
+ // download the message
752
+ const stream = await downloadMediaMessage(
753
+ m,
754
+ 'stream', // can be 'buffer' too
755
+ { },
756
+ {
757
+ logger,
758
+ // pass this so that baileys can request a reupload of media
759
+ // that has been deleted
760
+ reuploadRequest: sock.updateMediaMessage
761
+ }
762
+ )
763
+ // save to file
764
+ const writeStream = createWriteStream('./my-download.jpeg')
765
+ stream.pipe(writeStream)
766
+ }
767
+ }
768
+ ```
769
+
770
+ ### Re-upload Media Message to Whatsapp
771
+
772
+ - WhatsApp automatically removes old media from their servers. For the device to access said media -- a re-upload is required by another device that has it. This can be accomplished using:
773
+ ```ts
774
+ await sock.updateMediaMessage(msg)
775
+ ```
776
+
777
+ ## Reject Call
778
+
779
+ - You can obtain `callId` and `callFrom` from `call` event
780
+
781
+ ```ts
782
+ await sock.rejectCall(callId, callFrom)
783
+ ```
784
+
785
+ ## Send States in Chat
786
+
787
+ ### Reading Messages
788
+ - A set of message [keys](https://baileys.wiki/docs/api/type-aliases/WAMessageKey/) must be explicitly marked read now.
789
+ - You cannot mark an entire 'chat' read as it were with Baileys Web.
790
+ This means you have to keep track of unread messages.
791
+
792
+ ```ts
793
+ const key: WAMessageKey
794
+ // can pass multiple keys to read multiple messages as well
795
+ await sock.readMessages([key])
796
+ ```
797
+
798
+ The message ID is the unique identifier of the message that you are marking as read.
799
+ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
800
+
801
+ ### Update Presence
802
+
803
+ - ``` presence ``` can be one of the values in the [WAPresence type alias](https://baileys.wiki/docs/api/type-aliases/WAPresence/)
804
+ - The presence expires after about 10 seconds.
805
+ - This lets the person/group with `jid` know whether you're online, offline, typing etc.
806
+
807
+ ```ts
808
+ await sock.sendPresenceUpdate('available', jid)
809
+ ```
810
+
811
+ > [!NOTE]
812
+ > If a desktop client is active, WA doesn't send push notifications to the device. If you would like to receive said notifications -- mark your Baileys client offline using `sock.sendPresenceUpdate('unavailable')`
813
+
814
+ ## Modifying Chats
815
+
816
+ WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
817
+
818
+ > [!IMPORTANT]
819
+ > If you mess up one of your updates, WA can log you out of all your devices and you'll have to log in again.
820
+
821
+ ### Archive a Chat
822
+ ```ts
823
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
824
+ await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
825
+ ```
826
+ ### Mute/Unmute a Chat
827
+
828
+ - Supported times:
829
+
830
+ | Time | Miliseconds |
831
+ |-------|-----------------|
832
+ | Remove | null |
833
+ | 8h | 86.400.000 |
834
+ | 7d | 604.800.000 |
835
+
836
+ ```ts
837
+ // mute for 8 hours
838
+ await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
839
+ // unmute
840
+ await sock.chatModify({ mute: null }, jid)
841
+ ```
842
+ ### Mark a Chat Read/Unread
843
+ ```ts
844
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
845
+ // mark it unread
846
+ await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
847
+ ```
848
+
849
+ ### Delete a Message for Me
850
+ ```ts
851
+ await sock.chatModify(
852
+ {
853
+ clear: {
854
+ messages: [
855
+ {
856
+ id: 'ATWYHDNNWU81732J',
857
+ fromMe: true,
858
+ timestamp: '1654823909'
859
+ }
860
+ ]
861
+ }
862
+ },
863
+ jid
864
+ )
865
+
866
+ ```
867
+ ### Delete a Chat
868
+ ```ts
869
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
870
+ await sock.chatModify({
871
+ delete: true,
872
+ lastMessages: [
873
+ {
874
+ key: lastMsgInChat.key,
875
+ messageTimestamp: lastMsgInChat.messageTimestamp
876
+ }
877
+ ]
878
+ },
879
+ jid
880
+ )
881
+ ```
882
+ ### Pin/Unpin a Chat
883
+ ```ts
884
+ await sock.chatModify({
885
+ pin: true // or `false` to unpin
886
+ },
887
+ jid
888
+ )
889
+ ```
890
+ ### Star/Unstar a Message
891
+ ```ts
892
+ await sock.chatModify({
893
+ star: {
894
+ messages: [
895
+ {
896
+ id: 'messageID',
897
+ fromMe: true // or `false`
898
+ }
899
+ ],
900
+ star: true // - true: Star Message; false: Unstar Message
901
+ }
902
+ },
903
+ jid
904
+ )
905
+ ```
906
+
907
+ ### Disappearing Messages
908
+
909
+ - Ephemeral can be:
910
+
911
+ | Time | Seconds |
912
+ |-------|----------------|
913
+ | Remove | 0 |
914
+ | 24h | 86.400 |
915
+ | 7d | 604.800 |
916
+ | 90d | 7.776.000 |
917
+
918
+ - You need to pass in **Seconds**, default is 7 days
919
+
920
+ ```ts
921
+ // turn on disappearing messages
922
+ await sock.sendMessage(
923
+ jid,
924
+ // this is 1 week in seconds -- how long you want messages to appear for
925
+ { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
926
+ )
927
+
928
+ // will send as a disappearing message
929
+ await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
930
+
931
+ // turn off disappearing messages
932
+ await sock.sendMessage(
933
+ jid,
934
+ { disappearingMessagesInChat: false }
935
+ )
936
+ ```
937
+
938
+ ## User Querys
939
+
940
+ ### Check If ID Exists in Whatsapp
941
+ ```ts
942
+ const [result] = await sock.onWhatsApp(jid)
943
+ if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
944
+ ```
945
+
946
+ ### Query Chat History (groups too)
947
+
948
+ - You need to have oldest message in chat
949
+ ```ts
950
+ const msg = await getOldestMessageInChat(jid) // implement this on your end
951
+ await sock.fetchMessageHistory(
952
+ 50, //quantity (max: 50 per query)
953
+ msg.key,
954
+ msg.messageTimestamp
955
+ )
956
+ ```
957
+ - Messages will be received in `messaging.history-set` event
958
+
959
+ ### Fetch Status
960
+ ```ts
961
+ const status = await sock.fetchStatus(jid)
962
+ console.log('status: ' + status)
963
+ ```
964
+
965
+ ### Fetch Profile Picture (groups too)
966
+ - To get the display picture of some person/group
967
+ ```ts
968
+ // for low res picture
969
+ const ppUrl = await sock.profilePictureUrl(jid)
970
+ console.log(ppUrl)
971
+
972
+ // for high res picture
973
+ const ppUrl = await sock.profilePictureUrl(jid, 'image')
974
+ ```
975
+
976
+ ### Fetch Bussines Profile (such as description or category)
977
+ ```ts
978
+ const profile = await sock.getBusinessProfile(jid)
979
+ console.log('business description: ' + profile.description + ', category: ' + profile.category)
980
+ ```
981
+
982
+ ### Fetch Someone's Presence (if they're typing or online)
983
+ ```ts
984
+ // the presence update is fetched and called here
985
+ sock.ev.on('presence.update', console.log)
986
+
987
+ // request updates for a chat
988
+ await sock.presenceSubscribe(jid)
989
+ ```
990
+
991
+ ## Change Profile
992
+
993
+ ### Change Profile Status
994
+ ```ts
995
+ await sock.updateProfileStatus('Hello World!')
996
+ ```
997
+ ### Change Profile Name
998
+ ```ts
999
+ await sock.updateProfileName('My name')
1000
+ ```
1001
+ ### Change Display Picture (groups too)
1002
+ - To change your display picture or a group's
1003
+
1004
+ > [!NOTE]
1005
+ > Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more in the [WAMediaUpload type alias](https://baileys.wiki/docs/api/type-aliases/WAMediaUpload/)
1006
+
1007
+ ```ts
1008
+ await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
1009
+ ```
1010
+ ### Remove display picture (groups too)
1011
+ ```ts
1012
+ await sock.removeProfilePicture(jid)
1013
+ ```
1014
+
1015
+ ## Groups
1016
+
1017
+ - To change group properties you need to be admin
1018
+
1019
+ ### Create a Group
1020
+ ```ts
1021
+ // title & participants
1022
+ const group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
1023
+ console.log('created group with id: ' + group.gid)
1024
+ await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
1025
+ ```
1026
+ ### Add/Remove or Demote/Promote
1027
+ ```ts
1028
+ // id & people to add to the group (will throw error if it fails)
1029
+ await sock.groupParticipantsUpdate(
1030
+ jid,
1031
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1032
+ 'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1033
+ )
1034
+ ```
1035
+ ### Change Subject (name)
1036
+ ```ts
1037
+ await sock.groupUpdateSubject(jid, 'New Subject!')
1038
+ ```
1039
+ ### Change Description
1040
+ ```ts
1041
+ await sock.groupUpdateDescription(jid, 'New Description!')
1042
+ ```
1043
+ ### Change Settings
1044
+ ```ts
1045
+ // only allow admins to send messages
1046
+ await sock.groupSettingUpdate(jid, 'announcement')
1047
+ // allow everyone to send messages
1048
+ await sock.groupSettingUpdate(jid, 'not_announcement')
1049
+ // allow everyone to modify the group's settings -- like display picture etc.
1050
+ await sock.groupSettingUpdate(jid, 'unlocked')
1051
+ // only allow admins to modify the group's settings
1052
+ await sock.groupSettingUpdate(jid, 'locked')
1053
+ ```
1054
+ ### Leave a Group
1055
+ ```ts
1056
+ // will throw error if it fails
1057
+ await sock.groupLeave(jid)
1058
+ ```
1059
+ ### Get Invite Code
1060
+ - To create link with code use `'https://chat.whatsapp.com/' + code`
1061
+ ```ts
1062
+ const code = await sock.groupInviteCode(jid)
1063
+ console.log('group code: ' + code)
1064
+ ```
1065
+ ### Revoke Invite Code
1066
+ ```ts
1067
+ const code = await sock.groupRevokeInvite(jid)
1068
+ console.log('New group code: ' + code)
1069
+ ```
1070
+ ### Join Using Invitation Code
1071
+ - Code can't have `https://chat.whatsapp.com/`, only code
1072
+ ```ts
1073
+ const response = await sock.groupAcceptInvite(code)
1074
+ console.log('joined to: ' + response)
1075
+ ```
1076
+ ### Get Group Info by Invite Code
1077
+ ```ts
1078
+ const response = await sock.groupGetInviteInfo(code)
1079
+ console.log('group information: ' + response)
1080
+ ```
1081
+ ### Query Metadata (participants, name, description...)
1082
+ ```ts
1083
+ const metadata = await sock.groupMetadata(jid)
1084
+ console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1085
+ ```
1086
+ ### Join using `groupInviteMessage`
1087
+ ```ts
1088
+ const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
1089
+ console.log('joined to: ' + response)
1090
+ ```
1091
+ ### Get Request Join List
1092
+ ```ts
1093
+ const response = await sock.groupRequestParticipantsList(jid)
1094
+ console.log(response)
1095
+ ```
1096
+ ### Approve/Reject Request Join
1097
+ ```ts
1098
+ const response = await sock.groupRequestParticipantsUpdate(
1099
+ jid, // group id
1100
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1101
+ 'approve' // or 'reject'
1102
+ )
1103
+ console.log(response)
1104
+ ```
1105
+ ### Get All Participating Groups Metadata
1106
+ ```ts
1107
+ const response = await sock.groupFetchAllParticipating()
1108
+ console.log(response)
1109
+ ```
1110
+ ### Toggle Ephemeral
1111
+
1112
+ - Ephemeral can be:
1113
+
1114
+ | Time | Seconds |
1115
+ |-------|----------------|
1116
+ | Remove | 0 |
1117
+ | 24h | 86.400 |
1118
+ | 7d | 604.800 |
1119
+ | 90d | 7.776.000 |
1120
+
1121
+ ```ts
1122
+ await sock.groupToggleEphemeral(jid, 86400)
1123
+ ```
1124
+
1125
+ ### Change Add Mode
1126
+ ```ts
1127
+ await sock.groupMemberAddMode(
1128
+ jid,
1129
+ 'all_member_add' // or 'admin_add'
1130
+ )
1131
+ ```
1132
+
1133
+ ## Privacy
1134
+
1135
+ ### Block/Unblock User
1136
+ ```ts
1137
+ await sock.updateBlockStatus(jid, 'block') // Block user
1138
+ await sock.updateBlockStatus(jid, 'unblock') // Unblock user
1139
+ ```
1140
+ ### Get Privacy Settings
1141
+ ```ts
1142
+ const privacySettings = await sock.fetchPrivacySettings(true)
1143
+ console.log('privacy settings: ' + privacySettings)
1144
+ ```
1145
+ ### Get BlockList
1146
+ ```ts
1147
+ const response = await sock.fetchBlocklist()
1148
+ console.log(response)
1149
+ ```
1150
+ ### Update LastSeen Privacy
1151
+ ```ts
1152
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1153
+ await sock.updateLastSeenPrivacy(value)
1154
+ ```
1155
+ ### Update Online Privacy
1156
+ ```ts
1157
+ const value = 'all' // 'match_last_seen'
1158
+ await sock.updateOnlinePrivacy(value)
1159
+ ```
1160
+ ### Update Profile Picture Privacy
1161
+ ```ts
1162
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1163
+ await sock.updateProfilePicturePrivacy(value)
1164
+ ```
1165
+ ### Update Status Privacy
1166
+ ```ts
1167
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1168
+ await sock.updateStatusPrivacy(value)
1169
+ ```
1170
+ ### Update Read Receipts Privacy
1171
+ ```ts
1172
+ const value = 'all' // 'none'
1173
+ await sock.updateReadReceiptsPrivacy(value)
1174
+ ```
1175
+ ### Update Groups Add Privacy
1176
+ ```ts
1177
+ const value = 'all' // 'contacts' | 'contact_blacklist'
1178
+ await sock.updateGroupsAddPrivacy(value)
1179
+ ```
1180
+ ### Update Default Disappearing Mode
1181
+
1182
+ - Like [this](#disappearing-messages), ephemeral can be:
1183
+
1184
+ | Time | Seconds |
1185
+ |-------|----------------|
1186
+ | Remove | 0 |
1187
+ | 24h | 86.400 |
1188
+ | 7d | 604.800 |
1189
+ | 90d | 7.776.000 |
1190
+
1191
+ ```ts
1192
+ const ephemeral = 86400
1193
+ await sock.updateDefaultDisappearingMode(ephemeral)
1194
+ ```
1195
+
1196
+ ## Broadcast Lists & Stories
1197
+
1198
+ ### Send Broadcast & Stories
1199
+ - Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
1200
+ ```ts
1201
+ await sock.sendMessage(
1202
+ jid,
1203
+ {
1204
+ image: {
1205
+ url: url
1206
+ },
1207
+ caption: caption
1208
+ },
1209
+ {
1210
+ backgroundColor: backgroundColor,
1211
+ font: font,
1212
+ statusJidList: statusJidList,
1213
+ broadcast: true
1214
+ }
1215
+ )
1216
+ ```
1217
+ - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see the [AnyRegularMessageContent type alias](https://baileys.wiki/docs/api/type-aliases/AnyRegularMessageContent/)
1218
+ - You can add `backgroundColor` and other options in the message options, see the [MiscMessageGenerationOptions type alias](https://baileys.wiki/docs/api/type-aliases/MiscMessageGenerationOptions/)
1219
+ - `broadcast: true` enables broadcast mode
1220
+ - `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.
1221
+
1222
+ - You can send messages to broadcast lists the same way you send messages to groups & individual chats.
1223
+ - Right now, WA Web does not support creating broadcast lists, but you can still delete them.
1224
+ - Broadcast IDs are in the format `12345678@broadcast`
1225
+
1226
+ ### Experimental Group Status Media
1227
+
1228
+ This fork includes `sock.sendGroupStatus` for attempting to post a text, image, video, audio, or sticker status to a group. This is an **experimental, undocumented WhatsApp protocol path** and is not part of the official Baileys API. The presence of the protobuf fields in Baileys does not guarantee that WhatsApp will accept or display the post. Test with a non-critical linked account and group, and verify the result in the official WhatsApp app before relying on it.
1229
+
1230
+ ```ts
1231
+ import makeWASocket from '@whiskeysockets/baileys'
1232
+
1233
+ const sock = makeWASocket({ /* your socket config */ })
1234
+ const groupJid = '120363000000000000@g.us'
1235
+
1236
+ // Text status
1237
+ await sock.sendGroupStatus(groupJid, { text: 'A group status update' })
1238
+
1239
+ // Image status with a caption
1240
+ await sock.sendGroupStatus(groupJid, {
1241
+ image: { url: './Media/status.jpg' },
1242
+ caption: 'A group status update'
1243
+ })
1244
+
1245
+ // Video status
1246
+ await sock.sendGroupStatus(groupJid, {
1247
+ video: { url: './Media/status.mp4' },
1248
+ caption: 'Video update'
1249
+ })
1250
+
1251
+ // Audio status
1252
+ await sock.sendGroupStatus(groupJid, {
1253
+ audio: { url: './Media/status.ogg' },
1254
+ mimetype: 'audio/ogg; codecs=opus',
1255
+ ptt: true
1256
+ })
1257
+ ```
1258
+
1259
+ The group JID must end in `@g.us`. `sock.sendGroupStatus` builds the inner message with the normal Baileys content generator, adds the required shared message secret, and relays it in a `groupStatusMessageV2` wrapper. It does not bypass group membership, WhatsApp privacy controls, or server-side restrictions, and may not be available in published Baileys packages.
1260
+
1261
+ ### Query a Broadcast List's Recipients & Name
1262
+ ```ts
1263
+ const bList = await sock.getBroadcastListInfo('1234@broadcast')
1264
+ console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
1265
+ ```
1266
+
1267
+ ## Writing Custom Functionality
1268
+ Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
1269
+
1270
+ ### Enabling Debug Level in Baileys Logs
1271
+ First, enable the logging of unhandled messages from WhatsApp by setting:
1272
+ ```ts
1273
+ const sock = makeWASocket({
1274
+ logger: P({ level: 'debug' }),
1275
+ })
1276
+ ```
1277
+ This will enable you to see all sorts of messages WhatsApp sends in the console.
1278
+
1279
+ ### How Whatsapp Communicate With Us
1280
+
1281
+ > [!TIP]
1282
+ > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1283
+
1284
+ - **Example:** Functionality to track the battery percentage of your phone. You enable logging and you'll see a message about your battery pop up in the console:
1285
+ ```
1286
+ {
1287
+ "level": 10,
1288
+ "fromMe": false,
1289
+ "frame": {
1290
+ "tag": "ib",
1291
+ "attrs": {
1292
+ "from": "@s.whatsapp.net"
1293
+ },
1294
+ "content": [
1295
+ {
1296
+ "tag": "edge_routing",
1297
+ "attrs": {},
1298
+ "content": [
1299
+ {
1300
+ "tag": "routing_info",
1301
+ "attrs": {},
1302
+ "content": {
1303
+ "type": "Buffer",
1304
+ "data": [8,2,8,5]
1305
+ }
1306
+ }
1307
+ ]
1308
+ }
1309
+ ]
1310
+ },
1311
+ "msg":"communication"
1312
+ }
1313
+ ```
1314
+
1315
+ The `'frame'` is what the message received is, it has three components:
1316
+ - `tag` -- what this frame is about (eg. message will have 'message')
1317
+ - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
1318
+ - `content` -- the actual data (eg. a message node will have the actual message content in it)
1319
+ - read more about this format [here](/src/WABinary/readme.md)
1320
+
1321
+ ### Register a Callback for Websocket Events
1322
+
1323
+ > [!TIP]
1324
+ > Recommended to see `onMessageReceived` function in `socket.ts` file to understand how websockets events are fired
1325
+
1326
+ ```ts
1327
+ // for any message with tag 'edge_routing'
1328
+ sock.ws.on('CB:edge_routing', (node: BinaryNode) => { })
1329
+
1330
+ // for any message with tag 'edge_routing' and id attribute = abcd
1331
+ sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
1332
+
1333
+ // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
1334
+ sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
1335
+ ```
1336
+
1337
+ # License
1338
+ Copyright (c) 2025 Rajeh Taher/WhiskeySockets
1339
+
1340
+ Licensed under the MIT License:
1341
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1342
+ of this software and associated documentation files (the "Software"), to deal
1343
+ in the Software without restriction, including without limitation the rights
1344
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1345
+ copies of the Software, and to permit persons to whom the Software is
1346
+ furnished to do so, subject to the following conditions:
1347
+
1348
+ The above copyright notice and this permission notice shall be included in all
1349
+ copies or substantial portions of the Software.
1350
+
1351
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1352
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1353
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1354
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1355
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1356
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1357
+ SOFTWARE.
1358
+
1359
+ Thus, the maintainers of the project can't be held liable for any potential misuse of this project.