@dhilzzkz/baileys 0.0.0-stage → 0.1.0

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 (241) hide show
  1. package/LICENSE +23 -0
  2. package/NOTICE.md +37 -0
  3. package/README.md +2083 -2
  4. package/WAProto/index.d.ts +22220 -0
  5. package/WAProto/index.js +5 -0
  6. package/lib/Addon/http-error.d.ts +18 -0
  7. package/lib/Addon/http-error.js +40 -0
  8. package/lib/Addon/index.d.ts +3 -0
  9. package/lib/Addon/index.js +4 -0
  10. package/lib/Addon/keyed-db.d.ts +14 -0
  11. package/lib/Addon/keyed-db.js +241 -0
  12. package/lib/Addon/link-preview.d.ts +15 -0
  13. package/lib/Addon/link-preview.js +79 -0
  14. package/lib/Defaults/index.d.ts +188 -0
  15. package/lib/Defaults/index.js +185 -0
  16. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  17. package/lib/Signal/Group/ciphertext-message.js +11 -0
  18. package/lib/Signal/Group/group-cipher.d.ts +10 -0
  19. package/lib/Signal/Group/group-cipher.js +81 -0
  20. package/lib/Signal/Group/group-session-builder.d.ts +7 -0
  21. package/lib/Signal/Group/group-session-builder.js +29 -0
  22. package/lib/Signal/Group/index.d.ts +11 -0
  23. package/lib/Signal/Group/index.js +11 -0
  24. package/lib/Signal/Group/keyhelper.d.ts +6 -0
  25. package/lib/Signal/Group/keyhelper.js +17 -0
  26. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  27. package/lib/Signal/Group/sender-chain-key.js +25 -0
  28. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  29. package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
  30. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  31. package/lib/Signal/Group/sender-key-message.js +65 -0
  32. package/lib/Signal/Group/sender-key-name.d.ts +11 -0
  33. package/lib/Signal/Group/sender-key-name.js +47 -0
  34. package/lib/Signal/Group/sender-key-record.d.ts +12 -0
  35. package/lib/Signal/Group/sender-key-record.js +40 -0
  36. package/lib/Signal/Group/sender-key-state.d.ts +16 -0
  37. package/lib/Signal/Group/sender-key-state.js +83 -0
  38. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  39. package/lib/Signal/Group/sender-message-key.js +25 -0
  40. package/lib/Signal/Protocol/crypto.d.ts +6 -0
  41. package/lib/Signal/Protocol/crypto.js +61 -0
  42. package/lib/Signal/Protocol/curve.d.ts +8 -0
  43. package/lib/Signal/Protocol/curve.js +61 -0
  44. package/lib/Signal/Protocol/index.d.ts +16 -0
  45. package/lib/Signal/Protocol/index.js +9 -0
  46. package/lib/Signal/Protocol/internals.d.ts +57 -0
  47. package/lib/Signal/Protocol/internals.js +155 -0
  48. package/lib/Signal/Protocol/session-builder.d.ts +40 -0
  49. package/lib/Signal/Protocol/session-builder.js +143 -0
  50. package/lib/Signal/Protocol/session-cipher.d.ts +26 -0
  51. package/lib/Signal/Protocol/session-cipher.js +301 -0
  52. package/lib/Signal/Protocol/session-record.d.ts +55 -0
  53. package/lib/Signal/Protocol/session-record.js +272 -0
  54. package/lib/Signal/libsignal.d.ts +54 -0
  55. package/lib/Signal/libsignal.js +426 -0
  56. package/lib/Signal/lid-mapping.d.ts +20 -0
  57. package/lib/Signal/lid-mapping.js +274 -0
  58. package/lib/Socket/Client/index.d.ts +2 -0
  59. package/lib/Socket/Client/index.js +2 -0
  60. package/lib/Socket/Client/types.d.ts +5 -0
  61. package/lib/Socket/Client/types.js +10 -0
  62. package/lib/Socket/Client/websocket.d.ts +12 -0
  63. package/lib/Socket/Client/websocket.js +119 -0
  64. package/lib/Socket/business.d.ts +387 -0
  65. package/lib/Socket/business.js +380 -0
  66. package/lib/Socket/chats.d.ts +144 -0
  67. package/lib/Socket/chats.js +1216 -0
  68. package/lib/Socket/communities.d.ts +554 -0
  69. package/lib/Socket/communities.js +431 -0
  70. package/lib/Socket/groups.d.ts +286 -0
  71. package/lib/Socket/groups.js +347 -0
  72. package/lib/Socket/index.d.ts +522 -0
  73. package/lib/Socket/index.js +11 -0
  74. package/lib/Socket/messages-recv.d.ts +326 -0
  75. package/lib/Socket/messages-recv.js +1822 -0
  76. package/lib/Socket/messages-send.d.ts +321 -0
  77. package/lib/Socket/messages-send.js +1378 -0
  78. package/lib/Socket/mex.d.ts +1 -0
  79. package/lib/Socket/mex.js +41 -0
  80. package/lib/Socket/newsletter.d.ts +283 -0
  81. package/lib/Socket/newsletter.js +225 -0
  82. package/lib/Socket/socket.d.ts +61 -0
  83. package/lib/Socket/socket.js +992 -0
  84. package/lib/Store/index.d.ts +3 -0
  85. package/lib/Store/index.js +3 -0
  86. package/lib/Store/make-in-memory-store.d.ts +63 -0
  87. package/lib/Store/make-in-memory-store.js +418 -0
  88. package/lib/Store/make-ordered-dictionary.d.ts +12 -0
  89. package/lib/Store/make-ordered-dictionary.js +78 -0
  90. package/lib/Store/object-repository.d.ts +10 -0
  91. package/lib/Store/object-repository.js +23 -0
  92. package/lib/Types/Auth.d.ts +1 -0
  93. package/lib/Types/Auth.js +1 -0
  94. package/lib/Types/Business.d.ts +1 -0
  95. package/lib/Types/Business.js +1 -0
  96. package/lib/Types/Call.d.ts +1 -0
  97. package/lib/Types/Call.js +1 -0
  98. package/lib/Types/Chat.d.ts +1 -0
  99. package/lib/Types/Chat.js +7 -0
  100. package/lib/Types/Contact.d.ts +1 -0
  101. package/lib/Types/Contact.js +1 -0
  102. package/lib/Types/Events.d.ts +1 -0
  103. package/lib/Types/Events.js +1 -0
  104. package/lib/Types/GroupMetadata.d.ts +1 -0
  105. package/lib/Types/GroupMetadata.js +1 -0
  106. package/lib/Types/Label.d.ts +2 -0
  107. package/lib/Types/Label.js +24 -0
  108. package/lib/Types/LabelAssociation.d.ts +2 -0
  109. package/lib/Types/LabelAssociation.js +6 -0
  110. package/lib/Types/Message.d.ts +11 -0
  111. package/lib/Types/Message.js +17 -0
  112. package/lib/Types/Mex.d.ts +2 -0
  113. package/lib/Types/Mex.js +38 -0
  114. package/lib/Types/Product.d.ts +1 -0
  115. package/lib/Types/Product.js +1 -0
  116. package/lib/Types/RichType.d.ts +2 -0
  117. package/lib/Types/RichType.js +22 -0
  118. package/lib/Types/Signal.d.ts +1 -0
  119. package/lib/Types/Signal.js +1 -0
  120. package/lib/Types/Socket.d.ts +1 -0
  121. package/lib/Types/Socket.js +1 -0
  122. package/lib/Types/State.d.ts +5 -0
  123. package/lib/Types/State.js +54 -0
  124. package/lib/Types/USync.d.ts +1 -0
  125. package/lib/Types/USync.js +1 -0
  126. package/lib/Types/index.d.ts +13 -0
  127. package/lib/Types/index.js +25 -0
  128. package/lib/Utils/Auth/auth-utils.d.ts +58 -0
  129. package/lib/Utils/Auth/auth-utils.js +316 -0
  130. package/lib/Utils/Auth/companion-reg-client-utils.d.ts +4 -0
  131. package/lib/Utils/Auth/companion-reg-client-utils.js +39 -0
  132. package/lib/Utils/Auth/pre-key-manager.d.ts +25 -0
  133. package/lib/Utils/Auth/pre-key-manager.js +105 -0
  134. package/lib/Utils/Auth/use-multi-file-auth-state.d.ts +10 -0
  135. package/lib/Utils/Auth/use-multi-file-auth-state.js +116 -0
  136. package/lib/Utils/Auth/use-single-file-auth-state.d.ts +11 -0
  137. package/lib/Utils/Auth/use-single-file-auth-state.js +94 -0
  138. package/lib/Utils/Auth/use-sqlite-auth-state.d.ts +11 -0
  139. package/lib/Utils/Auth/use-sqlite-auth-state.js +109 -0
  140. package/lib/Utils/Auth/validate-connection.d.ts +44 -0
  141. package/lib/Utils/Auth/validate-connection.js +210 -0
  142. package/lib/Utils/Common/browser-utils.d.ts +9 -0
  143. package/lib/Utils/Common/browser-utils.js +28 -0
  144. package/lib/Utils/Common/generics.d.ts +63 -0
  145. package/lib/Utils/Common/generics.js +392 -0
  146. package/lib/Utils/Common/logger.d.ts +12 -0
  147. package/lib/Utils/Common/logger.js +12 -0
  148. package/lib/Utils/Common/make-mutex.d.ts +6 -0
  149. package/lib/Utils/Common/make-mutex.js +32 -0
  150. package/lib/Utils/Crypto/crypto.d.ts +39 -0
  151. package/lib/Utils/Crypto/crypto.js +117 -0
  152. package/lib/Utils/Crypto/lt-hash.d.ts +6 -0
  153. package/lib/Utils/Crypto/lt-hash.js +7 -0
  154. package/lib/Utils/Crypto/noise-handler.d.ts +20 -0
  155. package/lib/Utils/Crypto/noise-handler.js +200 -0
  156. package/lib/Utils/Crypto/signal.d.ts +82 -0
  157. package/lib/Utils/Crypto/signal.js +200 -0
  158. package/lib/Utils/Message/business.d.ts +49 -0
  159. package/lib/Utils/Message/business.js +230 -0
  160. package/lib/Utils/Message/decode-wa-message.d.ts +83 -0
  161. package/lib/Utils/Message/decode-wa-message.js +316 -0
  162. package/lib/Utils/Message/history.d.ts +75 -0
  163. package/lib/Utils/Message/history.js +133 -0
  164. package/lib/Utils/Message/link-preview.d.ts +13 -0
  165. package/lib/Utils/Message/link-preview.js +73 -0
  166. package/lib/Utils/Message/message-retry-manager.d.ts +79 -0
  167. package/lib/Utils/Message/message-retry-manager.js +259 -0
  168. package/lib/Utils/Message/messages-media.d.ts +134 -0
  169. package/lib/Utils/Message/messages-media.js +802 -0
  170. package/lib/Utils/Message/messages.d.ts +47 -0
  171. package/lib/Utils/Message/messages.js +1907 -0
  172. package/lib/Utils/Message/offline-node-processor.d.ts +10 -0
  173. package/lib/Utils/Message/offline-node-processor.js +40 -0
  174. package/lib/Utils/Message/process-message.d.ts +83 -0
  175. package/lib/Utils/Message/process-message.js +748 -0
  176. package/lib/Utils/Message/reporting-utils.d.ts +12 -0
  177. package/lib/Utils/Message/reporting-utils.js +257 -0
  178. package/lib/Utils/Message/rich-message-utils.d.ts +48 -0
  179. package/lib/Utils/Message/rich-message-utils.js +366 -0
  180. package/lib/Utils/Message/stanza-ack.d.ts +16 -0
  181. package/lib/Utils/Message/stanza-ack.js +37 -0
  182. package/lib/Utils/State/chat-utils.d.ts +408 -0
  183. package/lib/Utils/State/chat-utils.js +871 -0
  184. package/lib/Utils/State/event-buffer.d.ts +12 -0
  185. package/lib/Utils/State/event-buffer.js +621 -0
  186. package/lib/Utils/State/identity-change-handler.d.ts +13 -0
  187. package/lib/Utils/State/identity-change-handler.js +48 -0
  188. package/lib/Utils/State/sync-action-utils.d.ts +2 -0
  189. package/lib/Utils/State/sync-action-utils.js +48 -0
  190. package/lib/Utils/State/tc-token-utils.d.ts +29 -0
  191. package/lib/Utils/State/tc-token-utils.js +163 -0
  192. package/lib/Utils/index.d.ts +24 -0
  193. package/lib/Utils/index.js +24 -0
  194. package/lib/WABinary/constants.d.ts +61 -0
  195. package/lib/WABinary/constants.js +1466 -0
  196. package/lib/WABinary/decode.d.ts +9 -0
  197. package/lib/WABinary/decode.js +261 -0
  198. package/lib/WABinary/encode.d.ts +2 -0
  199. package/lib/WABinary/encode.js +219 -0
  200. package/lib/WABinary/generic-utils.d.ts +79 -0
  201. package/lib/WABinary/generic-utils.js +226 -0
  202. package/lib/WABinary/index.d.ts +5 -0
  203. package/lib/WABinary/index.js +5 -0
  204. package/lib/WABinary/jid-utils.d.ts +28 -0
  205. package/lib/WABinary/jid-utils.js +95 -0
  206. package/lib/WABinary/types.d.ts +1 -0
  207. package/lib/WABinary/types.js +1 -0
  208. package/lib/WAM/BinaryInfo.d.ts +7 -0
  209. package/lib/WAM/BinaryInfo.js +9 -0
  210. package/lib/WAM/constants.d.ts +34926 -0
  211. package/lib/WAM/constants.js +22852 -0
  212. package/lib/WAM/encode.d.ts +1 -0
  213. package/lib/WAM/encode.js +149 -0
  214. package/lib/WAM/index.d.ts +3 -0
  215. package/lib/WAM/index.js +3 -0
  216. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +38 -0
  217. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +50 -0
  218. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
  219. package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
  220. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  221. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
  222. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  223. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  224. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +14 -0
  225. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +28 -0
  226. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  227. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  228. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
  229. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  230. package/lib/WAUSync/Protocols/index.d.ts +5 -0
  231. package/lib/WAUSync/Protocols/index.js +5 -0
  232. package/lib/WAUSync/USyncQuery.d.ts +20 -0
  233. package/lib/WAUSync/USyncQuery.js +97 -0
  234. package/lib/WAUSync/USyncUser.d.ts +16 -0
  235. package/lib/WAUSync/USyncUser.js +30 -0
  236. package/lib/WAUSync/index.d.ts +3 -0
  237. package/lib/WAUSync/index.js +3 -0
  238. package/lib/index.d.ts +11 -0
  239. package/lib/index.js +11 -0
  240. package/package.json +120 -5
  241. package/scripts/engine-requirements.js +16 -0
package/README.md CHANGED
@@ -1,3 +1,2084 @@
1
- # Temporary Holding Version
1
+ # 🌱 @dhilzzkz/baileys
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
+ [![Logo](https://files.catbox.moe/c5s9g0.jpg)](https://www.npmjs.com/package/@dhilzzkz/baileys)
4
+
5
+ <p align="center">
6
+ A lightweight, dependency-minimal Baileys v7 fork with newsletter media upload fixes, interactive messages, albums, and extended message type support.
7
+ <br><br>
8
+ <a href="https://www.npmjs.com/package/@dhilzzkz/baileys">
9
+ <img src="https://img.shields.io/npm/v/@dhilzzkz/baileys?style=for-the-badge&logo=npm"/>
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@dhilzzkz/baileys">
12
+ <img src="https://img.shields.io/npm/dm/@dhilzzkz/baileys?style=for-the-badge&logo=npm"/>
13
+ </a>
14
+ <a href="https://github.com/kazamaofficial-git/baileys">
15
+ <img src="https://img.shields.io/github/stars/kazamaofficial-git/baileys?style=for-the-badge&logo=github"/>
16
+ </a>
17
+ <a href="LICENSE">
18
+ <img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge"/>
19
+ </a>
20
+ <a href="https://nodejs.org">
21
+ <img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&labelColor=green&logoColor=white&style=for-the-badge"/>
22
+ </a>
23
+ <a href="https://bun.sh">
24
+ <img src="https://img.shields.io/badge/bun-%3E%3D1.2-fbf0df?logo=bun&labelColor=14151a&logoColor=white&style=for-the-badge"/>
25
+ </a>
26
+ <a href="#">
27
+ <img src="https://img.shields.io/badge/ESM-only?logo=javascript&labelColor=yellow&logoColor=black&style=for-the-badge"/>
28
+ </a>
29
+ </p>
30
+
31
+ > [!IMPORTANT]
32
+ > To be clear, I am **NOT** the original maintainer of Baileys. Full credit and respect belong to:
33
+ >
34
+ > https://github.com/WhiskeySockets/Baileys
35
+ >
36
+ > **Forking is completely acceptable. Removing attribution, contributor credits, or modification history is not.**
37
+ >
38
+ > **Read [NOTICE.md](https://github.com/kazamaofficial-git/baileys/blob/main/NOTICE.md) for important attribution requirements and future maintenance plans.**
39
+ >
40
+ > Thank you. 🤍
41
+
42
+ ☕ For donation: [Saweria](https://saweria.co/itsliaaa)
43
+
44
+ ### 📋 Table of Contents
45
+ - [📋 Table of Contents](#-table-of-contents)
46
+ - [✨ Highlights](#-highlights)
47
+ - [🛠️ Internal Adjustments](#%EF%B8%8F-internal-adjustments)
48
+ - [📨 Messages Handling & Compatibility](#-highlights)
49
+ - [🧩 Additional Message Options](#-additional-message-options)
50
+ - [📥 Installation](#-installation)
51
+ - [🧩 Import (ESM & CJS)](#-import-esm--cjs)
52
+ - [🌐 Connect to WhatsApp (Quick Step)](#-connect-to-whatsapp-quick-step)
53
+ - [🔐 Auth State](#-auth-state)
54
+ - [🗄️ Implementing Data Store](#%EF%B8%8F-implementing-data-store)
55
+ - [🪪 WhatsApp IDs Explain](#-whatsapp-ids-explain)
56
+ - [✉️ Sending Messages](#%EF%B8%8F-sending-messages)
57
+ - [🔠 Text](#-text)
58
+ - [🔔 Mention](#-mention)
59
+ - [😁 Reaction](#-reaction)
60
+ - [📌 Pin Message](#-pin-message)
61
+ - [🔖 Keep Chat](#-keep-chat)
62
+ - [➡️ Forward Message](#%EF%B8%8F-forward-message)
63
+ - [👤 Contact](#-contact)
64
+ - [📍 Location](#-location)
65
+ - [🗓️ Event](#%EF%B8%8F-event)
66
+ - [👥 Group Invite](#-group-invite)
67
+ - [🛍️ Product](#%EF%B8%8F-product)
68
+ - [📊 Poll](#-poll)
69
+ - [💭 Button Response](#-button-response)
70
+ - [✨ Rich Response](#-rich-response)
71
+ - [🧾 Message with Code Block](#-message-with-code-block)
72
+ - [🌏 Message with Inline Entities](#-message-with-inline-entities)
73
+ - [📋 Message with Table](#-message-with-table)
74
+ - [🎞️ Status Mention](#%EF%B8%8F-status-mention)
75
+ - [📁 Sending Media Messages](#-sending-media-messages)
76
+ - [🖼️ Image](#%EF%B8%8F-image)
77
+ - [🎥 Video](#-video)
78
+ - [📃 Sticker](#-sticker)
79
+ - [💽 Audio](#-audio)
80
+ - [🗂️ Document](#%EF%B8%8F-document)
81
+ - [🖼️ Album (Image & Video)](#%EF%B8%8F-album-image--video)
82
+ - [📦 Sticker Pack](#-sticker-pack)
83
+ - [👉🏻 Sending Interactive Messages](#-sending-interactive-messages)
84
+ - [🔘 Buttons](#-buttons)
85
+ - [📋 List](#-list)
86
+ - [🗄️ Interactive](#%EF%B8%8F-interactive)
87
+ - [🫙 Hydrated Template](#-hydrated-template)
88
+ - [💳 Sending Payment Messages](#-sending-payment-messages)
89
+ - [➕ Invite Payment](#-invite-payment)
90
+ - [🧾 Invoice](#-invoice)
91
+ - [🛍️ Order](#%EF%B8%8F-order)
92
+ - [💳 Request Payment](#-request-payment)
93
+ - [👁️ Other Message Options](#%EF%B8%8F-other-message-options)
94
+ - [🤖 AI Icon](#-ai-icon)
95
+ - [🕒 Ephemeral](#-ephemeral)
96
+ - [📰 External Ad Reply](#-external-ad-reply)
97
+ - [🧑‍🧑‍🧒 Group Status](#%E2%80%8D%E2%80%8D-group-status)
98
+ - [🐱 Lottie Sticker](#-lottie-sticker)
99
+ - [🧩 Raw](#-raw)
100
+ - [🏷️ Secure Meta Service Label](#%EF%B8%8F-secure-meta-service-label)
101
+ - [📑 Spoiler](#-spoiler)
102
+ - [👁️ View Once](#%EF%B8%8F-view-once)
103
+ - [👁️ View Once V2](#%EF%B8%8F-view-once-v2)
104
+ - [👁️ View Once V2 Extension](#%EF%B8%8F-view-once-v2-extension)
105
+ - [♻️ Modify Messages](#%EF%B8%8F-modify-messages)
106
+ - [🗑️ Delete Messages](#%EF%B8%8F-delete-messages)
107
+ - [✏️ Edit Messages](#%EF%B8%8F-edit-messages)
108
+ - [🧰 Additional Contents](#-additional-contents)
109
+ - [🏷️ Find User ID (JID|PN/LID)](#%EF%B8%8F-find-user-id-jidpnlid)
110
+ - [🔑 Request Custom Pairing Code](#-request-custom-pairing-code)
111
+ - [🖼️ Image Processing](#%EF%B8%8F-image-processing)
112
+ - [📣 Newsletter Management](#-newsletter-management)
113
+ - [👥 Group Management](#-group-management)
114
+ - [👥 Community Management](#-community-management)
115
+ - [👤 Profile Management](#-profile-management)
116
+ - [🛒 Business Management](#-business-management)
117
+ - [🔐 Privacy Management](#-privacy-management)
118
+ - [📡 Events](#-events)
119
+ - [🗂️ Project Structure](#%EF%B8%8F-project-structure)
120
+ - [📦 Fork Base](#-fork-base)
121
+ - [📣 Credits](#-credits)
122
+
123
+ ### ✨ Highlights
124
+
125
+ This fork designed for production use with a focus on clarity and safety:
126
+
127
+ - 🚫 No obfuscation. Easy to read and audit.
128
+ - 🚫 No auto-follow channel (newsletter) behavior.
129
+
130
+ ### 🛠️ Internal Adjustments
131
+ - 🖼️ Fixed an issue where media could not be sent to newsletters due to an upstream issue.
132
+ - 📁 Reintroduced [`makeInMemoryStore`](#%EF%B8%8F-implementing-data-store) with a minimal ESM adaptation and small adjustments for Baileys v7.
133
+ - 📦 Switched FFmpeg execution from `exec` to `spawn` for safer process handling.
134
+ - 🗃️ 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.
135
+ - ◻️ Reintroduced `printQRInTerminal` in `makeWASocket()`.
136
+ - 📡 Migrated signal transport to a Rust-based WASM.
137
+ - 🌱 Reduced transitive dependencies from 13 to just 2 with optional peer integrations.
138
+
139
+ ### 📨 Messages Handling & Compatibility
140
+ - 📩 Expanded messages support for:
141
+ - 🖼️ [Album Message](#%EF%B8%8F-album-image--video)
142
+ - 👤 [Group Status Message](#%E2%80%8D%E2%80%8D-group-status)
143
+ - 👉🏻 [Interactive Message](#-sending-interactive-messages) (buttons, lists, native flows, templates, carousels).
144
+ - 🎞️ [Status Mention Message](#%EF%B8%8F-status-mention)
145
+ - 📦 [Sticker Pack Message](#-sticker-pack)
146
+ - ✨ [Rich Response Message](#-rich-response)
147
+ - 🧾 [Message with Code Blocks](#-message-with-code-block)
148
+ - [🌏 Message with Inline Entities](#-message-with-inline-entities)
149
+ - 📋 [Message with Table](#-message-with-table)
150
+ - 💳 [Payment-related Message](#-sending-payment-messages) (payment requests, invites, orders, invoices).
151
+ - 📰 Simplified sending messages with ad thumbnail using [`externalAdReply`](#-external-ad-reply), without requiring manual `contextInfo`.
152
+ - 💭 Added support for quoting messages inside channel (newsletter).
153
+ - 🎀 Added support for [custom button icon](#%EF%B8%8F-interactive).
154
+
155
+ ### 🧩 Additional Message Options
156
+ - 👁️ Added optional boolean flags for message handling:
157
+ - 🤖 [`ai`](#-ai-icon) - AI icon on message
158
+ - 📣 [`mentionAll`](#-mention) - Mention all group participants without requiring their JIDs in `mentions` or `mentionedJid`
159
+ - 🔧 [`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
160
+ - 🔒 [`secureMetaServiceLabel`](#%EF%B8%8F-secure-meta-service-label) - Secure meta service label on message
161
+ - 📄 [`raw`](#-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
162
+
163
+ ### 📥 Installation
164
+
165
+ Choose one of the following methods to install `@dhilzzkz/baileys`.
166
+
167
+ - 📄 Via `package.json`
168
+
169
+ ```json
170
+ # NPM
171
+ "dependencies": {
172
+ "@dhilzzkz/baileys": "latest"
173
+ }
174
+
175
+ # GitHub
176
+ "dependencies": {
177
+ "@dhilzzkz/baileys": "github:kazamaofficial-git/baileys"
178
+ }
179
+ ```
180
+
181
+ - ⌨️ Via terminal
182
+
183
+ ```bash
184
+ # NPM
185
+ npm i @dhilzzkz/baileys@latest
186
+
187
+ # GitHub
188
+ npm i github:kazamaofficial-git/baileys
189
+ ```
190
+
191
+ - 🔗 Peer Dependencies
192
+ - One of `@napi-rs/image@^1.12.0`, `jimp@^1.6.0`, or `sharp@>=0.33.0` is required for thumbnail generation and other image processing operations.
193
+ - `better-sqlite3@>=11.0.0` is required for `useSqliteAuthState` when using Node.js versions below `22.13`.
194
+ - `qr@>=0.5.0` is required for `printQRInTerminal`.
195
+ - `ws@^8.13.0` is required when using Node.js versions below `22.0`.
196
+
197
+ - ⚙️ System Dependencies
198
+ - `ffmpeg` is required for video thumbnail extraction, audio waveform generation, and other media processing operations.
199
+ - `ffprobe` is required for media metadata inspection (MediaInfo).
200
+
201
+ #### 🧩 Import (ESM & CJS)
202
+
203
+ ```javascript
204
+ // --- ESM
205
+ import { makeWASocket } from '@dhilzzkz/baileys'
206
+
207
+ // --- CJS (tested and working on Node.js 24 ✅)
208
+ const { makeWASocket } = require('@dhilzzkz/baileys')
209
+ ```
210
+
211
+ ### 🌐 Connect to WhatsApp (Quick Step)
212
+
213
+ ```javascript
214
+ import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@dhilzzkz/baileys'
215
+
216
+ // --- Connect with pairing code
217
+ const myPhoneNumber = '6288888888888'
218
+
219
+ const connectToWhatsApp = async () => {
220
+ const { state, saveCreds } = await useMultiFileAuthState('session')
221
+
222
+ const sock = makeWASocket({
223
+ // Optional, "qr" must be installed
224
+ printQRInTerminal: true,
225
+
226
+ auth: state
227
+ })
228
+
229
+ sock.ev.on('creds.update', saveCreds)
230
+
231
+ sock.ev.on('connection.update', (update) => {
232
+ const { connection, lastDisconnect, qr } = update
233
+ if (qr && !sock.authState.creds.registered) {
234
+ await delay(1500)
235
+ const code = await sock.requestPairingCode(myPhoneNumber)
236
+ console.log('🔗 Pairing code', ':', code)
237
+ }
238
+ else if (connection === 'close') {
239
+ const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
240
+ console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
241
+ if (shouldReconnect) {
242
+ connectToWhatsApp()
243
+ }
244
+ }
245
+ else if (connection === 'open') {
246
+ console.log('✅ Successfully connected to WhatsApp')
247
+ }
248
+ })
249
+
250
+ sock.ev.on('messages.upsert', async ({ messages }) => {
251
+ for (const message of messages) {
252
+ if (!message.message) continue
253
+
254
+ console.log('🔔 Got new message', ':', message)
255
+ await sock.sendMessage(message.key.remoteJid, {
256
+ text: '👋🏻 Hello world'
257
+ })
258
+ }
259
+ })
260
+ }
261
+
262
+ connectToWhatsApp()
263
+ ```
264
+
265
+ #### 🔐 Auth State
266
+
267
+ ```javascript
268
+ import {
269
+ useMultiFileAuthState,
270
+ useSingleFileAuthState,
271
+ useSqliteAuthState
272
+ } from '@dhilzzkz/baileys'
273
+ ```
274
+
275
+ - 🗒️ `useMultiFileAuthState(folder?: string)`
276
+ Stores authentication credentials and keys in separate JSON files within a directory. Suitable for users who prefer the traditional multi-file storage approach.
277
+
278
+ - 📄 `useSingleFileAuthState(fileName?: string)`
279
+ Stores all authentication credentials and keys in a single JSON file for simpler file management.
280
+
281
+ - 🗄️ `useSqliteAuthState(dbPath?: string, ownedDatabase?: object)`
282
+ Stores authentication credentials and keys in an SQLite database. No external SQLite dependency is required when using Bun or Node.js `>=22.13`. For older Node.js versions, install `better-sqlite3`.
283
+
284
+ ### 🗄️ Implementing Data Store
285
+
286
+ > [!CAUTION]
287
+ > I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
288
+
289
+ ```javascript
290
+ import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from '@dhilzzkz/baileys'
291
+
292
+ const myPhoneNumber = '6288888888888'
293
+
294
+ // --- Create your store path
295
+ const storePath = './store.json'
296
+
297
+ const connectToWhatsApp = async () => {
298
+ const { state, saveCreds } = await useMultiFileAuthState('session')
299
+
300
+ const sock = makeWASocket({
301
+ auth: state
302
+ })
303
+
304
+ const store = makeInMemoryStore({
305
+ socket: sock
306
+ })
307
+
308
+ store.bind(sock.ev)
309
+
310
+ sock.ev.on('creds.update', saveCreds)
311
+
312
+ sock.ev.on('connection.update', (update) => {
313
+ const { connection, lastDisconnect } = update
314
+ if (connection === 'connecting' && !sock.authState.creds.registered) {
315
+ await delay(1500)
316
+ const code = await sock.requestPairingCode(myPhoneNumber)
317
+ console.log('🔗 Pairing code', ':', code)
318
+ }
319
+ else if (connection === 'close') {
320
+ const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
321
+ console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
322
+ if (shouldReconnect) {
323
+ connectToWhatsApp()
324
+ }
325
+ }
326
+ else if (connection === 'open') {
327
+ console.log('✅ Successfully connected to WhatsApp')
328
+ }
329
+ })
330
+
331
+ sock.ev.on('chats.upsert', () => {
332
+ console.log('✉️ Got chats', store.chats.all())
333
+ })
334
+
335
+ sock.ev.on('contacts.upsert', () => {
336
+ console.log('👥 Got contacts', Object.values(store.contacts))
337
+ })
338
+
339
+ // --- Read store from file
340
+ store.readFromFile(storePath)
341
+
342
+ // --- Save store every 3 minutes
343
+ setInterval(() => {
344
+ store.writeToFile(storePath)
345
+ }, 180000)
346
+ }
347
+
348
+ connectToWhatsApp()
349
+ ```
350
+
351
+ ### 🪪 WhatsApp IDs Explain
352
+
353
+ `id` is the WhatsApp ID, called `jid` and `lid` too, of the person or group you're sending the message to.
354
+ - It must be in the format `[country code][phone number]@s.whatsapp.net`
355
+ - Example for people: `19999999999@s.whatsapp.net` and `12699999999@lid`.
356
+ - For groups, it must be in the format `123456789-123345@g.us`.
357
+ - For Meta AI, it's `11111111111@bot`.
358
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
359
+ - For stories, the ID is `status@broadcast`.
360
+
361
+ ### ✉️ Sending Messages
362
+
363
+ > [!NOTE]
364
+ > You can get the `jid` from `message.key.remoteJid` in the first example.
365
+
366
+ #### 🔠 Text
367
+
368
+ ```javascript
369
+ // --- Send a regular text message
370
+ sock.sendMessage(jid, {
371
+ text: '👋🏻 Hello'
372
+ }, {
373
+ quoted: message
374
+ })
375
+
376
+ // --- Send a text message with a link preview
377
+ const urlA = 'https://www.npmjs.com/package/@dhilzzkz/baileys'
378
+
379
+ sock.sendMessage(jid, {
380
+ text: urlA + ' 👆🏻 Check it out!',
381
+ linkPreview: {
382
+ 'matched-text': urlA,
383
+ title: '🌱 @dhilzzkz/baileys',
384
+ description: 'Underrated Baileys Fork',
385
+ previewType: 0, // --- Use 1 for video playback in the link preview
386
+ jpegThumbnail: fs.readFileSync('./path/to/image.jpg')
387
+ }
388
+ })
389
+
390
+ // --- Send a text message with a large link preview and favicon
391
+ import { prepareWAMessageMedia } from '@dhilzzkz/baileys'
392
+
393
+ const urlB = 'https://www.npmjs.com/package/@dhilzzkz/baileys#readme'
394
+
395
+ const { imageMessage: image } = await prepareWAMessageMedia({
396
+ image: {
397
+ url: './path/to/image.jpg'
398
+ }
399
+ }, {
400
+ upload: sock.waUploadToServer,
401
+ mediaTypeOverride: 'thumbnail-link'
402
+ })
403
+
404
+ // --- Set the thumbnail display size
405
+ image.height = 720
406
+ image.width = 480
407
+
408
+ sock.sendMessage(jid, {
409
+ text: urlB + ' 👆🏻 Check it out!',
410
+ linkPreview: {
411
+ 'matched-text': urlB,
412
+ title: '🌱 @dhilzzkz/baileys',
413
+ description: 'Underrated Baileys Fork',
414
+ previewType: 0,
415
+ jpegThumbnail: fs.readFileSync('./path/to/image.jpg'),
416
+ highQualityThumbnail: image,
417
+ linkPreviewMetadata: {
418
+ linkMediaDuration: 0, // --- Duration in seconds (for video/audio content)
419
+ socialMediaPostType: 1, // --- Enum: 0 = NONE, 1 = REEL, 2 = LIVE_VIDEO, 3 = LONG_VIDEO, 4 = SINGLE_IMAGE, 5 = CAROUSEL
420
+ } // --- Additional metadata for large link preview
421
+ },
422
+ favicon: {
423
+ url: './path/to/tiny-image.ico'
424
+ }
425
+ })
426
+ ```
427
+
428
+ #### 🔔 Mention
429
+
430
+ ```javascript
431
+ // --- Regular mention
432
+ sock.sendMessage(jid, {
433
+ text: '👋🏻 Hello @628123456789',
434
+ mentions: ['628123456789@s.whatsapp.net']
435
+ }, {
436
+ quoted: message
437
+ })
438
+
439
+ // --- Mention all
440
+ sock.sendMessage(jid, {
441
+ text: '👋🏻 Hello @all',
442
+ mentionAll: true
443
+ }, {
444
+ quoted: message
445
+ })
446
+ ```
447
+
448
+ #### 😁 Reaction
449
+
450
+ ```javascript
451
+ sock.sendMessage(jid, {
452
+ react: {
453
+ key: message.key,
454
+ text: '✨'
455
+ }
456
+ })
457
+ ```
458
+
459
+ #### 📌 Pin Message
460
+
461
+ ```javascript
462
+ sock.sendMessage(jid, {
463
+ pin: message.key,
464
+ time: 86400, // --- Set the value in seconds: 86400 (1d), 604800 (7d), or 2592000 (30d)
465
+ type: 1 // --- Or 2 to remove
466
+ })
467
+ ```
468
+
469
+ #### 🔖 Keep Chat
470
+
471
+ > [!NOTE]
472
+ > Keep Chat can only be used in chats or groups with disappearing messages enabled.
473
+
474
+ ```javascript
475
+ sock.sendMessage(jid, {
476
+ keep: message.key,
477
+ type: 1 // --- Or 2 to remove
478
+ })
479
+ ```
480
+
481
+ #### ➡️ Forward Message
482
+
483
+ ```javascript
484
+ sock.sendMessage(jid, {
485
+ forward: message,
486
+ force: true // --- Optional
487
+ })
488
+ ```
489
+
490
+ #### 👤 Contact
491
+
492
+ ```javascript
493
+ const vcard = 'BEGIN:VCARD\n'
494
+ + 'VERSION:3.0\n'
495
+ + 'FN:Dhilzzkz\n'
496
+ + 'ORG:Waitress;\n'
497
+ + 'TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n'
498
+ + 'END:VCARD'
499
+
500
+ sock.sendMessage(jid, {
501
+ contacts: {
502
+ displayName: 'Dhilzzkz',
503
+ contacts: [
504
+ { vcard }
505
+ ]
506
+ }
507
+ }, {
508
+ quoted: message
509
+ })
510
+ ```
511
+
512
+ #### 📍 Location
513
+
514
+ ```javascript
515
+ sock.sendMessage(jid, {
516
+ location: {
517
+ degreesLatitude: 24.121231,
518
+ degreesLongitude: 55.1121221,
519
+ name: '👋🏻 I am here'
520
+ }
521
+ }, {
522
+ quoted: message
523
+ })
524
+ ```
525
+
526
+ #### 🗓️ Event
527
+
528
+ ```javascript
529
+ sock.sendMessage(jid, {
530
+ event: {
531
+ name: '🎶 Meet & Mingle Party',
532
+ description: 'Meet & Mingle Party is a fun, casual gathering to connect, chat, and build new relationships within the community.',
533
+ call: 'audio', // --- Or "video", this field is optional
534
+ startDate: new Date(Date.now() + 3600000),
535
+ endDate: new Date(Date.now() + 28800000),
536
+ isCancelled: false, // --- Optional
537
+ isScheduleCall: false, // --- Optional
538
+ extraGuestsAllowed: false, // --- Optional
539
+ location: {
540
+ name: 'Jakarta',
541
+ degreesLatitude: -6.2,
542
+ degreesLongitude: 106.8
543
+ }
544
+ }
545
+ }, {
546
+ quoted: message
547
+ })
548
+ ```
549
+
550
+ #### 👥 Group Invite
551
+
552
+ ```javascript
553
+ const inviteCode = groupUrl
554
+ .split('chat.whatsapp.com/')[1]
555
+ ?.split('?')[0]
556
+
557
+ const groupJid = '1201111111111@g.us'
558
+ const groupName = '@dhilzzkz/baileys'
559
+
560
+ sock.sendMessage(jid, {
561
+ groupInvite: {
562
+ inviteCode,
563
+ inviteExpiration: Date.now() + 86400000,
564
+ text: '👋🏻 Hello, we invite you to join our group.',
565
+ jid: groupJid,
566
+ subject: groupName,
567
+ }
568
+ }, {
569
+ quoted: message
570
+ })
571
+ ```
572
+
573
+ #### 🛍️ Product
574
+
575
+ ```javascript
576
+ import { randomUUID } from 'crypto'
577
+
578
+ sock.sendMessage(jid, {
579
+ image: {
580
+ url: './path/to/image.jpg'
581
+ },
582
+ body: '👋🏻 Check my product here!',
583
+ footer: '@dhilzzkz/baileys',
584
+ product: {
585
+ currencyCode: 'IDR',
586
+ description: '🛍️ Interesting product!',
587
+ priceAmount1000: 70_000_000,
588
+ productId: randomUUID(),
589
+ productImageCount: 1,
590
+ salePriceAmount1000: 65_000_000,
591
+ signedUrl: 'https://www.npmjs.com/package/@dhilzzkz/baileys',
592
+ title: '📦 Starseed (Premium)',
593
+ url: 'https://www.npmjs.com/package/@dhilzzkz/baileys'
594
+ },
595
+ businessOwnerJid: '0@s.whatsapp.net'
596
+ })
597
+ ```
598
+
599
+ #### 📊 Poll
600
+
601
+ ```javascript
602
+ // --- Regular poll message
603
+ sock.sendMessage(jid, {
604
+ poll: {
605
+ name: '🔥 Voting time',
606
+ values: ['Yes', 'No'],
607
+ selectableCount: 1,
608
+ toAnnouncementGroup: false,
609
+ endDate: new Date(Date.now() + 28800000), // --- Optional
610
+ hideVoter: false, // --- Optional
611
+ canAddOption: false // --- Optional
612
+ }
613
+ }, {
614
+ quoted: message
615
+ })
616
+
617
+ // --- Quiz (only for newsletter)
618
+ sock.sendMessage('1211111111111@newsletter', {
619
+ poll: {
620
+ name: '🔥 Quiz',
621
+ values: ['Yes', 'No'],
622
+ correctAnswer: 'Yes',
623
+ pollType: 1
624
+ }
625
+ }, {
626
+ quoted: message
627
+ })
628
+
629
+ // --- Poll result
630
+ sock.sendMessage(jid, {
631
+ pollResult: {
632
+ name: '📝 Poll Result',
633
+ votes: [{
634
+ name: 'Nice',
635
+ voteCount: 10
636
+ }, {
637
+ name: 'Nah',
638
+ voteCount: 2
639
+ }],
640
+ pollType: 0 // Or 1 for quiz
641
+ }
642
+ }, {
643
+ quoted: message
644
+ })
645
+
646
+ // --- Poll update
647
+ sock.sendMessage(jid, {
648
+ pollUpdate: {
649
+ metadata: {},
650
+ key: message.key,
651
+ vote: {
652
+ enclv: /* <Buffer> */,
653
+ encPayload: /* <Buffer> */
654
+ }
655
+ }
656
+ }, {
657
+ quoted: message
658
+ })
659
+ ```
660
+
661
+ #### 💭 Button Response
662
+
663
+ ```javascript
664
+ // --- Using buttonsResponseMessage
665
+ sock.sendMessage(jid, {
666
+ type: 'plain',
667
+ buttonReply: {
668
+ id: '#Menu',
669
+ displayText: '✨ Interesting Menu'
670
+ }
671
+ }, {
672
+ quoted: message
673
+ })
674
+
675
+ // --- Using interactiveResponseMessage
676
+ sock.sendMessage(jid, {
677
+ flowReply: {
678
+ format: 0,
679
+ text: '💭 Response',
680
+ name: 'menu_options',
681
+ paramsJson: JSON.stringify({
682
+ id: '#Menu',
683
+ description: '✨ Interesting Menu'
684
+ })
685
+ }
686
+ }, {
687
+ quoted: message
688
+ })
689
+
690
+ // --- Using listResponseMessage
691
+ sock.sendMessage(jid, {
692
+ listReply: {
693
+ title: '📄 See More',
694
+ description: '✨ Interesting Menu',
695
+ id: '#Menu'
696
+ }
697
+ }, {
698
+ quoted: message
699
+ })
700
+
701
+ // --- Using templateButtonReplyMessage
702
+ sock.sendMessage(jid, {
703
+ type: 'template',
704
+ buttonReply: {
705
+ id: '#Menu',
706
+ displayText: '✨ Interesting Menu',
707
+ index: 1
708
+ }
709
+ }, {
710
+ quoted: message
711
+ })
712
+ ```
713
+
714
+ #### ✨ Rich Response
715
+
716
+ > [!NOTE]
717
+ > `richResponse[]` is a representation of [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) inside `richResponseMessage`.
718
+
719
+ > [!TIP]
720
+ > You can still use the original [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) field directly.
721
+ > The code example below is just an implementation using a helper, not a required structure.
722
+
723
+ ```javascript
724
+ sock.sendMessage(jid, {
725
+ disclaimerText: 'RAW submessages structure example',
726
+ richResponse: [{
727
+ text: 'Example Usage',
728
+ }, {
729
+ language: 'javascript',
730
+ code: [{
731
+ highlightType: 0,
732
+ codeContent: 'console.log("Hello, World!")'
733
+ }]
734
+ }, {
735
+ text: 'Pretty simple, right?\n'
736
+ }, {
737
+ text: 'Comparison between Node.js, Bun, and Deno',
738
+ }, {
739
+ title: 'Runtime Comparison',
740
+ table: [{
741
+ isHeading: true,
742
+ items: ['', 'Node.js', 'Bun', 'Deno']
743
+ }, {
744
+ isHeading: false,
745
+ items: ['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)']
746
+ }, {
747
+ isHeading: false,
748
+ items: ['Performance', '4/5', '5/5', '4/5']
749
+ }]
750
+ }, {
751
+ text: 'Does this help clarify the differences?'
752
+ }]
753
+ })
754
+ ```
755
+
756
+ > [!TIP]
757
+ > You can easily add syntax highlighting by importing `tokenizeCode` directly from Baileys.
758
+
759
+ ```javascript
760
+ import { tokenizeCode } from '@dhilzzkz/baileys'
761
+
762
+ const language = 'javascript'
763
+ const code = 'console.log("Hello, World!")'
764
+
765
+ sock.sendMessage(jid, {
766
+ disclaimerText: 'Example of tokenizing Code Block',
767
+ richResponse: [{
768
+ text: 'Example Usage',
769
+ }, {
770
+ language,
771
+ code: tokenizeCode(code, language)
772
+ }, {
773
+ text: 'Pretty simple, right?'
774
+ }]
775
+ })
776
+ ```
777
+
778
+ > 💡 Supported Languages: `css`, `html`, `javascript`, `typescript`, `python`, `golang`, `rust`, `c`, `c#`, `c++`, `bash`, `bat`, `powershell`.
779
+
780
+ #### 🧾 Message with Code Block
781
+
782
+ > [!NOTE]
783
+ > This feature already includes a built-in tokenizer with `tokenizeCode`.
784
+
785
+ ```javascript
786
+ sock.sendMessage(jid, {
787
+ disclaimerText: 'Code Block',
788
+ headerText: '## Example Usage',
789
+ contentText: '---',
790
+ code: 'console.log("Hello, World!")',
791
+ language: 'javascript',
792
+ footerText: 'Pretty simple, right?'
793
+ })
794
+ ```
795
+
796
+ #### 🌏 Message with Inline Entities
797
+
798
+ ```javascript
799
+ sock.sendMessage(jid, {
800
+ disclaimerText: 'Inline Entities',
801
+ headerText: '## Check Out!',
802
+ contentText: '---',
803
+ links: [{
804
+ text: '1. Google',
805
+ title: 'Popular Search Engine',
806
+ url: 'https://www.google.com/'
807
+ }, {
808
+ text: '2. YouTube',
809
+ title: 'Popular Streaming Platform',
810
+ url: 'https://www.youtube.com/'
811
+ }, {
812
+ text: '3. Modded Baileys',
813
+ title: 'Underrated Baileys Fork',
814
+ url: 'https://www.npmjs.com/package/@dhilzzkz/baileys'
815
+ }],
816
+ footerText: '---'
817
+ })
818
+ ```
819
+
820
+ #### 📋 Message with Table
821
+
822
+ ```javascript
823
+ sock.sendMessage(jid, {
824
+ disclaimerText: 'Table',
825
+ headerText: '## Comparison between Node.js, Bun, and Deno',
826
+ contentText: '---',
827
+ title: 'Runtime Comparison',
828
+ table: [
829
+ ['', 'Node.js', 'Bun', 'Deno'],
830
+ ['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)'],
831
+ ['Performance', '4/5', '5/5', '4/5']
832
+ ],
833
+ noHeading: false, // --- Optional
834
+ footerText: 'Does this help clarify the differences?'
835
+ })
836
+ ```
837
+
838
+ #### 🎞️ Status Mention
839
+
840
+ ```javascript
841
+ sock.sendMessage([jidA, jidB, jidC], {
842
+ text: 'Hello! 👋🏻'
843
+ })
844
+ ```
845
+
846
+ ### 📁 Sending Media Messages
847
+
848
+ > [!NOTE]
849
+ > 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).
850
+
851
+ #### 🖼️ Image
852
+
853
+ ```javascript
854
+ sock.sendMessage(jid, {
855
+ image: {
856
+ url: './path/to/image.jpg'
857
+ },
858
+ caption: '🔥 Superb'
859
+ }, {
860
+ quoted: message
861
+ })
862
+ ```
863
+
864
+ #### 🎥 Video
865
+
866
+ ```javascript
867
+ sock.sendMessage(jid, {
868
+ video: {
869
+ url: './path/to/video.mp4'
870
+ },
871
+ gifPlayback: false, // --- Set true if you want to send video as GIF
872
+ ptv: false, // --- Set true if you want to send video as PTV
873
+ caption: '🔥 Superb'
874
+ }, {
875
+ quoted: message
876
+ })
877
+ ```
878
+
879
+ #### 📃 Sticker
880
+
881
+ ```javascript
882
+ sock.sendMessage(jid, {
883
+ sticker: {
884
+ url: './path/to/sticker.webp'
885
+ }
886
+ }, {
887
+ quoted: message
888
+ })
889
+ ```
890
+
891
+ #### 💽 Audio
892
+
893
+ ```javascript
894
+ sock.sendMessage(jid, {
895
+ audio: {
896
+ url: './path/to/audio.mp3'
897
+ },
898
+ ptt: false // --- Set true if you want to send audio as Voice Note
899
+ }, {
900
+ quoted: message
901
+ })
902
+ ```
903
+
904
+ #### 🗂️ Document
905
+
906
+ ```javascript
907
+ sock.sendMessage(jid, {
908
+ document: {
909
+ url: './path/to/document.pdf'
910
+ },
911
+ mimetype: 'application/pdf',
912
+ caption: '✨ My work!'
913
+ }, {
914
+ quoted: message
915
+ })
916
+ ```
917
+
918
+ #### 🖼️ Album (Image & Video)
919
+
920
+ ```javascript
921
+ sock.sendMessage(jid, {
922
+ album: [{
923
+ image: {
924
+ url: './path/to/image.jpg'
925
+ },
926
+ caption: '1st image'
927
+ }, {
928
+ video: {
929
+ url: './path/to/video.mp4'
930
+ },
931
+ caption: '1st video'
932
+ }, {
933
+ image: {
934
+ url: './path/to/image.jpg'
935
+ },
936
+ caption: '2nd image'
937
+ }, {
938
+ video: {
939
+ url: './path/to/video.mp4'
940
+ },
941
+ caption: '2nd video'
942
+ }]
943
+ }, {
944
+ quoted: message
945
+ })
946
+ ```
947
+
948
+ #### 📦 Sticker Pack
949
+
950
+ > [!IMPORTANT]
951
+ > If `sharp` or `@napi-rs/image` is not installed, the `cover` and `stickers` must already be in WebP format.
952
+
953
+ ```javascript
954
+ sock.sendMessage(jid, {
955
+ cover: {
956
+ url: './path/to/image.webp'
957
+ },
958
+ stickers: [{
959
+ data: {
960
+ url: './path/to/image.webp'
961
+ }
962
+ }, {
963
+ data: {
964
+ url: './path/to/image.webp'
965
+ }
966
+ }, {
967
+ data: {
968
+ url: './path/to/image.webp'
969
+ }
970
+ }],
971
+ name: '📦 My Sticker Pack',
972
+ publisher: '🌟 Dhilzzkz',
973
+ description: '@dhilzzkz/baileys'
974
+ }, {
975
+ quoted: message
976
+ })
977
+ ```
978
+
979
+ ### 👉🏻 Sending Interactive Messages
980
+
981
+ #### 🔘 Buttons
982
+
983
+ ```javascript
984
+ // --- Regular buttons message
985
+ sock.sendMessage(jid, {
986
+ text: '👆🏻 Buttons!',
987
+ footer: '@dhilzzkz/baileys',
988
+ buttons: [{
989
+ text: '👋🏻 SignUp',
990
+ id: '#SignUp'
991
+ }]
992
+ }, {
993
+ quoted: message
994
+ })
995
+
996
+ // --- Buttons with Media & Native Flow
997
+ sock.sendMessage(jid, {
998
+ image: {
999
+ url: './path/to/image.jpg'
1000
+ },
1001
+ caption: '👆🏻 Buttons and Native Flow!',
1002
+ footer: '@dhilzzkz/baileys',
1003
+ buttons: [{
1004
+ text: '👋🏻 Rating',
1005
+ id: '#Rating'
1006
+ }, {
1007
+ text: '📋 Select',
1008
+ sections: [{
1009
+ title: '✨ Section 1',
1010
+ rows: [{
1011
+ header: '',
1012
+ title: '💭 Secret Ingredient',
1013
+ description: '',
1014
+ id: '#SecretIngredient'
1015
+ }]
1016
+ }, {
1017
+ title: '✨ Section 2',
1018
+ highlight_label: '🔥 Popular',
1019
+ rows: [{
1020
+ header: '',
1021
+ title: '🏷️ Coupon',
1022
+ description: '',
1023
+ id: '#CouponCode'
1024
+ }]
1025
+ }]
1026
+ }]
1027
+ }, {
1028
+ quoted: message
1029
+ })
1030
+ ```
1031
+
1032
+ #### 📋 List
1033
+
1034
+ > [!NOTE]
1035
+ > It only works in private chat (`@s.whatsapp.net`).
1036
+
1037
+ ```javascript
1038
+ sock.sendMessage(jid, {
1039
+ text: '📋 List!',
1040
+ footer: '@dhilzzkz/baileys',
1041
+ buttonText: '📋 Select',
1042
+ title: '👋🏻 Hello',
1043
+ sections: [{
1044
+ title: '🚀 Menu 1',
1045
+ rows: [{
1046
+ title: '✨ AI',
1047
+ description: '',
1048
+ rowId: '#AI'
1049
+ }]
1050
+ }, {
1051
+ title: '🌱 Menu 2',
1052
+ rows: [{
1053
+ title: '🔍 Search',
1054
+ description: '',
1055
+ rowId: '#Search'
1056
+ }]
1057
+ }]
1058
+ }, {
1059
+ quoted: message
1060
+ })
1061
+ ```
1062
+
1063
+ #### 🗄️ Interactive
1064
+
1065
+ ```javascript
1066
+ // --- Native Flow
1067
+ sock.sendMessage(jid, {
1068
+ image: {
1069
+ url: './path/to/image.jpg'
1070
+ },
1071
+ caption: '🗄️️ Interactive!',
1072
+ footer: '@dhilzzkz/baileys',
1073
+ optionText: '👉🏻 Select Options', // --- Optional, wrap all native flow into a single list
1074
+ optionTitle: '📄 Select Options', // --- Optional
1075
+ offerText: '🏷️ Newest Coupon!', // --- Optional, add an offer into message
1076
+ offerCode: '@dhilzzkz/baileys', // --- Optional
1077
+ offerUrl: 'https://www.npmjs.com/package/@dhilzzkz/baileys', // --- Optional
1078
+ offerExpiration: Date.now() + 3_600_000, // --- Optional
1079
+ nativeFlow: [{
1080
+ text: '👋🏻 Greeting',
1081
+ id: '#Greeting',
1082
+ icon: 'review' // --- Optional
1083
+ }, {
1084
+ text: '📞 Call',
1085
+ call: '628123456789'
1086
+ }, {
1087
+ text: '📋 Copy',
1088
+ copy: '@dhilzzkz/baileys'
1089
+ }, {
1090
+ text: '🌐 Source',
1091
+ url: 'https://www.npmjs.com/package/@dhilzzkz/baileys',
1092
+ useWebview: true // --- Optional
1093
+ }, {
1094
+ text: '📋 Select',
1095
+ sections: [{
1096
+ title: '✨ Section 1',
1097
+ rows: [{
1098
+ header: '',
1099
+ title: '🏷️ Coupon',
1100
+ description: '',
1101
+ id: '#CouponCode'
1102
+ }]
1103
+ }, {
1104
+ title: '✨ Section 2',
1105
+ highlight_label: '🔥 Popular',
1106
+ rows: [{
1107
+ header: '',
1108
+ title: '💭 Secret Ingredient',
1109
+ description: '',
1110
+ id: '#SecretIngredient'
1111
+ }]
1112
+ }],
1113
+ icon: 'default' // --- Optional
1114
+ }],
1115
+ interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
1116
+ }, {
1117
+ quoted: message
1118
+ })
1119
+
1120
+ // --- Carousel & Native Flow
1121
+ sock.sendMessage(jid, {
1122
+ text: '🗂️ Interactive with Carousel!',
1123
+ footer: '@dhilzzkz/baileys',
1124
+ cards: [{
1125
+ image: {
1126
+ url: './path/to/image.jpg'
1127
+ },
1128
+ caption: '🖼️ Image 1',
1129
+ footer: '🏷️️ Pinterest',
1130
+ nativeFlow: [{
1131
+ text: '🌐 Source',
1132
+ url: 'https://www.npmjs.com/package/@dhilzzkz/baileys',
1133
+ useWebview: true
1134
+ }]
1135
+ }, {
1136
+ image: {
1137
+ url: './path/to/image.jpg'
1138
+ },
1139
+ caption: '🖼️ Image 2',
1140
+ footer: '🏷️ Pinterest',
1141
+ offerText: '🏷️ New Coupon!',
1142
+ offerCode: '@dhilzzkz/baileys',
1143
+ offerUrl: 'https://www.npmjs.com/package/@dhilzzkz/baileys',
1144
+ offerExpiration: Date.now() + 3_600_000,
1145
+ nativeFlow: [{
1146
+ text: '🌐 Source',
1147
+ url: 'https://www.npmjs.com/package/@dhilzzkz/baileys'
1148
+ }]
1149
+ }, {
1150
+ image: {
1151
+ url: './path/to/image.jpg'
1152
+ },
1153
+ caption: '🖼️ Image 3',
1154
+ footer: '🏷️ Pinterest',
1155
+ optionText: '👉🏻 Select Options',
1156
+ optionTitle: '👉🏻 Select Options',
1157
+ offerText: '🏷️ New Coupon!',
1158
+ offerCode: '@dhilzzkz/baileys',
1159
+ offerUrl: 'https://www.npmjs.com/package/@dhilzzkz/baileys',
1160
+ offerExpiration: Date.now() + 3_600_000,
1161
+ nativeFlow: [{
1162
+ text: '🛒 Product',
1163
+ id: '#Product',
1164
+ icon: 'default'
1165
+ }, {
1166
+ text: '🌐 Source',
1167
+ url: 'https://www.npmjs.com/package/@dhilzzkz/baileys'
1168
+ }]
1169
+ }]
1170
+ }, {
1171
+ quoted: message
1172
+ })
1173
+
1174
+ // --- Native Flow with Audio in the Footer
1175
+ sock.sendMessage(jid, {
1176
+ text: '🔈 Music in the footer!',
1177
+ audioFooter: {
1178
+ url: './path/to/audio.mp3'
1179
+ }, // --- Like other media upload methods, buffers and streams are supported
1180
+ nativeFlow: [{
1181
+ text: '👍🏻 Good, next',
1182
+ id: '#Next',
1183
+ icon: 'review'
1184
+ }, {
1185
+ text: '👎🏻 Skip',
1186
+ id: '#Skip',
1187
+ icon: 'default'
1188
+ }]
1189
+ }, {
1190
+ quoted: message
1191
+ })
1192
+ ```
1193
+
1194
+ #### 🫙 Hydrated Template
1195
+
1196
+ ```javascript
1197
+ sock.sendMessage(jid, {
1198
+ title: '👋🏻 Hello',
1199
+ image: {
1200
+ url: './path/to/image.jpg'
1201
+ },
1202
+ caption: '🫙 Template!',
1203
+ footer: '@dhilzzkz/baileys',
1204
+ templateButtons: [{
1205
+ text: '👉🏻 Tap Here',
1206
+ id: '#Order'
1207
+ }, {
1208
+ text: '🌐 Source',
1209
+ url: 'https://www.npmjs.com/package/@dhilzzkz/baileys'
1210
+ }, {
1211
+ text: '📞 Call',
1212
+ call: '628123456789'
1213
+ }]
1214
+ }, {
1215
+ quoted: message
1216
+ })
1217
+ ```
1218
+
1219
+ ### 💳 Sending Payment Messages
1220
+
1221
+ #### ➕ Invite Payment
1222
+
1223
+ ```javascript
1224
+ sock.sendMessage(jid, {
1225
+ paymentInviteServiceType: 3 // 1, 2, or 3
1226
+ })
1227
+ ```
1228
+
1229
+ #### 🧾 Invoice
1230
+
1231
+ > [!NOTE]
1232
+ > Invoice message are not supported yet.
1233
+
1234
+ ```javascript
1235
+ sock.sendMessage(jid, {
1236
+ image: {
1237
+ url: './path/to/image.jpg'
1238
+ },
1239
+ invoiceNote: '🏷️ Invoice'
1240
+ })
1241
+ ```
1242
+
1243
+ #### 🛍️ Order
1244
+
1245
+ ```javascript
1246
+ sock.sendMessage(chat, {
1247
+ orderText: '🛍️ Order',
1248
+ thumbnail: fs.readFileSync('./path/to/image.jpg') // --- Must in buffer format
1249
+ }, {
1250
+ quoted: message
1251
+ })
1252
+ ```
1253
+
1254
+ #### 💳 Request Payment
1255
+
1256
+ ```javascript
1257
+ sock.sendMessage(jid, {
1258
+ text: '💳 Request Payment',
1259
+ requestPaymentFrom: '0@s.whatsapp.net'
1260
+ })
1261
+ ```
1262
+
1263
+ ### 👁️ Other Message Options
1264
+
1265
+ #### 🤖 AI Icon
1266
+
1267
+ > [!NOTE]
1268
+ > It only works in private chat (`@s.whatsapp.net`).
1269
+
1270
+ ```javascript
1271
+ sock.sendMessage(jid, {
1272
+ image: {
1273
+ url: './path/to/image.jpg'
1274
+ },
1275
+ caption: '🤖 With AI icon!',
1276
+ ai: true
1277
+ }, {
1278
+ quoted: message
1279
+ })
1280
+ ```
1281
+
1282
+ #### 🕒 Ephemeral
1283
+
1284
+ > [!NOTE]
1285
+ > Wrap message into `ephemeralMessage`
1286
+
1287
+ ```javascript
1288
+ sock.sendMessage(jid, {
1289
+ image: {
1290
+ url: './path/to/image.jpg'
1291
+ },
1292
+ caption: '👁️ Ephemeral',
1293
+ ephemeral: true
1294
+ })
1295
+ ```
1296
+
1297
+ #### 📰 External Ad Reply
1298
+
1299
+ > [!NOTE]
1300
+ > Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
1301
+
1302
+ ```javascript
1303
+ sock.sendMessage(jid, {
1304
+ text: '📰 External Ad Reply',
1305
+ externalAdReply: {
1306
+ title: '📝 Did you know?',
1307
+ body: '❓ I dont know',
1308
+ thumbnail: fs.readFileSync('./path/to/image.jpg'), // --- Must in buffer format
1309
+ largeThumbnail: false, // --- Or true for bigger thumbnail
1310
+ url: 'https://www.npmjs.com/package/@dhilzzkz/baileys' // --- Optional, used for WhatsApp internal thumbnail caching and direct URL
1311
+ }
1312
+ }, {
1313
+ quoted: message
1314
+ })
1315
+ ```
1316
+
1317
+ #### 🧑‍🧑‍🧒 Group Status
1318
+
1319
+ > [!NOTE]
1320
+ > It only works in group chat (`@g.us`)
1321
+
1322
+ ```javascript
1323
+ sock.sendMessage(jid, {
1324
+ image: {
1325
+ url: './path/to/image.jpg'
1326
+ },
1327
+ caption: '👥 Group Status!',
1328
+ groupStatus: true
1329
+ })
1330
+ ```
1331
+
1332
+ #### 🐱 Lottie Sticker
1333
+
1334
+ > [!NOTE]
1335
+ > Wrap message into `lottieStickerMessage`
1336
+
1337
+ ```javascript
1338
+ sock.sendMessage(jid, {
1339
+ sticker: {
1340
+ url: './path/to/sticker.webp'
1341
+ },
1342
+ isLottie: true
1343
+ })
1344
+ ```
1345
+
1346
+ #### 🧩 Raw
1347
+
1348
+ ```javascript
1349
+ sock.sendMessage(jid, {
1350
+ extendedTextMessage: {
1351
+ text: '📃 Built manually from scratch using the raw WhatsApp proto structure',
1352
+ contextInfo: {
1353
+ externalAdReply: {
1354
+ title: '@dhilzzkz/baileys',
1355
+ thumbnail: fs.readFileSync('./path/to/image.jpg'),
1356
+ sourceApp: 'whatsapp',
1357
+ showAdAttribution: true,
1358
+ mediaType: 1
1359
+ }
1360
+ }
1361
+ },
1362
+ raw: true
1363
+ }, {
1364
+ quoted: message
1365
+ })
1366
+ ```
1367
+
1368
+ #### 🏷️ Secure Meta Service Label
1369
+
1370
+ ```javascript
1371
+ sock.sendMessage(jid, {
1372
+ text: '🏷️ Just a label!',
1373
+ secureMetaServiceLabel: true
1374
+ })
1375
+ ```
1376
+
1377
+ #### 📑 Spoiler
1378
+
1379
+ > [!NOTE]
1380
+ > Wrap message into `spoilerMessage`
1381
+
1382
+ ```javascript
1383
+ sock.sendMessage(jid, {
1384
+ image: {
1385
+ url: './path/to/image.jpg'
1386
+ },
1387
+ caption: '❔ Spoiler',
1388
+ spoiler: true
1389
+ })
1390
+ ```
1391
+
1392
+ #### 👁️ View Once
1393
+
1394
+ > [!NOTE]
1395
+ > Wrap message into `viewOnceMessage`
1396
+
1397
+ ```javascript
1398
+ sock.sendMessage(jid, {
1399
+ image: {
1400
+ url: './path/to/image.jpg'
1401
+ },
1402
+ caption: '👁️ View Once',
1403
+ viewOnce: true
1404
+ })
1405
+ ```
1406
+
1407
+ #### 👁️ View Once V2
1408
+
1409
+ > [!NOTE]
1410
+ > Wrap message into `viewOnceMessageV2`
1411
+
1412
+ ```javascript
1413
+ sock.sendMessage(jid, {
1414
+ image: {
1415
+ url: './path/to/image.jpg'
1416
+ },
1417
+ caption: '👁️ View Once V2',
1418
+ viewOnceV2: true
1419
+ })
1420
+ ```
1421
+
1422
+ #### 👁️ View Once V2 Extension
1423
+
1424
+ > [!NOTE]
1425
+ > Wrap message into `viewOnceMessageV2Extension`
1426
+
1427
+ ```javascript
1428
+ sock.sendMessage(jid, {
1429
+ image: {
1430
+ url: './path/to/image.jpg'
1431
+ },
1432
+ caption: '👁️ View Once V2 Extension',
1433
+ viewOnceV2Extension: true
1434
+ })
1435
+ ```
1436
+
1437
+ ### ♻️ Modify Messages
1438
+
1439
+ #### 🗑️ Delete Messages
1440
+
1441
+ ```javascript
1442
+ sock.sendMessage(jid, {
1443
+ delete: message.key
1444
+ })
1445
+ ```
1446
+
1447
+ #### ✏️ Edit Messages
1448
+
1449
+ ```javascript
1450
+ // --- Edit plain text
1451
+ sock.sendMessage(jid, {
1452
+ text: '✨ I mean, nice!',
1453
+ edit: message.key
1454
+ })
1455
+
1456
+ // --- Edit media messages caption
1457
+ sock.sendMessage(jid, {
1458
+ caption: '✨ I mean, here is the image!',
1459
+ edit: message.key
1460
+ })
1461
+ ```
1462
+
1463
+ ### 🧰 Additional Contents
1464
+
1465
+ #### 🏷️ Find User ID (JID|PN/LID)
1466
+
1467
+ > [!NOTE]
1468
+ > The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
1469
+
1470
+ ```javascript
1471
+ // --- PN (Phone Number)
1472
+ const phoneNumber = '6281111111111@s.whatsapp.net'
1473
+
1474
+ const ids = await sock.findUserId(phoneNumber)
1475
+
1476
+ console.log('🏷️ Got user ID', ':', ids)
1477
+
1478
+ // --- LID (Local Identifier)
1479
+ const lid = '43411111111111@lid'
1480
+
1481
+ const ids = await sock.findUserId(lid)
1482
+
1483
+ console.log('🏷️ Got user ID', ':', ids)
1484
+
1485
+ // --- Output
1486
+ // {
1487
+ // phoneNumber: '6281111111111@s.whatsapp.net',
1488
+ // lid: '43411111111111@lid'
1489
+ // }
1490
+ // --- Output when failed
1491
+ // {
1492
+ // phoneNumber: '6281111111111@s.whatsapp.net',
1493
+ // lid: undefined
1494
+ // }
1495
+ // --- Same output shape regardless of input type
1496
+ ```
1497
+
1498
+ #### 🔑 Request Custom Pairing Code
1499
+
1500
+ > [!NOTE]
1501
+ > The phone number must contain numbers only (no +, (), or -) and must include the country code.
1502
+
1503
+ ```javascript
1504
+ const phoneNumber = '6281111111111'
1505
+ const customPairingCode = 'STARFALL'
1506
+
1507
+ await sock.requestPairingCode(phoneNumber, customPairingCode)
1508
+
1509
+ console.log('🔗 Pairing code', ':', customPairingCode)
1510
+ ```
1511
+
1512
+ #### 🖼️ Image Processing
1513
+
1514
+ > [!NOTE]
1515
+ > Automatically use available image processing library: `sharp`, `@napi-rs/image`, or `jimp`
1516
+
1517
+ ```javascript
1518
+ import { getImageProcessingLibrary } from '@dhilzzkz/baileys'
1519
+ import { readFile } from 'fs/promises'
1520
+
1521
+ const lib = await getImageProcessingLibrary()
1522
+
1523
+ const bufferOrFilePath = './path/to/image.jpg'
1524
+ const width = 512
1525
+
1526
+ let output
1527
+
1528
+ // --- If sharp installed
1529
+ if (lib.sharp?.default) {
1530
+ const img = lib.sharp.default(bufferOrFilePath)
1531
+
1532
+ output = await img.resize(width)
1533
+ .jpeg({ quality: 80 })
1534
+ .toBuffer()
1535
+ }
1536
+
1537
+ // --- If @napi-rs/image installed
1538
+ else if (lib.image?.Transformer) {
1539
+ // --- Must in buffer format
1540
+ const inputBuffer = Buffer.isBuffer(bufferOrFilePath)
1541
+ ? bufferOrFilePath
1542
+ : await readFile(bufferOrFilePath)
1543
+
1544
+ const img = new lib.image.Transformer(inputBuffer)
1545
+
1546
+ output = await img.resize(width, undefined, 0)
1547
+ .jpeg(50)
1548
+ }
1549
+
1550
+ // --- If jimp installed
1551
+ else if (lib.jimp?.Jimp) {
1552
+ const img = await lib.jimp.Jimp.read(bufferOrFilePath)
1553
+
1554
+ output = await img
1555
+ .resize({ w: width, mode: lib.jimp.ResizeStrategy.BILINEAR })
1556
+ .getBuffer('image/jpeg', { quality: 50 })
1557
+ }
1558
+
1559
+ // --- Fallback
1560
+ else {
1561
+ throw new Error('No image processing available')
1562
+ }
1563
+
1564
+ console.log('✅ Process completed!')
1565
+ console.dir(output, { depth: null })
1566
+ ```
1567
+
1568
+ #### 📣 Newsletter Management
1569
+
1570
+ ```javascript
1571
+ // --- Create a new one
1572
+ sock.newsletterCreate('@dhilzzkz/baileys', '📣 Fresh updates weekly')
1573
+
1574
+ // --- Get info
1575
+ const metadata = sock.newsletterMetadata('1231111111111@newsletter')
1576
+ console.dir(metadata, { depth: null })
1577
+
1578
+ // --- Get subscribers count
1579
+ const subscribers = await sock.newsletterSubscribers('1231111111111@newsletter')
1580
+ console.dir(subscribers, { depth: null })
1581
+
1582
+ // --- Follow and Unfollow
1583
+ sock.newsletterFollow('1231111111111@newsletter')
1584
+ sock.newsletterUnfollow('1231111111111@newsletter')
1585
+
1586
+ // --- Mute and Unmute
1587
+ sock.newsletterMute('1231111111111@newsletter')
1588
+ sock.newsletterUnmute('1231111111111@newsletter')
1589
+
1590
+ // --- Demote admin
1591
+ sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
1592
+
1593
+ // --- Change owner
1594
+ sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
1595
+
1596
+ // --- Update newsletter
1597
+ sock.newsletterUpdate('1231111111111@newsletter', { name: '@dhilzzkz/baileys' })
1598
+
1599
+ // --- Change name
1600
+ sock.newsletterUpdateName('1231111111111@newsletter', '📦 @dhilzzkz/baileys')
1601
+
1602
+ // --- Change description
1603
+ sock.newsletterUpdateDescription('1231111111111@newsletter', '📣 Fresh updates weekly')
1604
+
1605
+ // --- Change photo
1606
+ sock.newsletterUpdatePicture('1231111111111@newsletter', {
1607
+ url: 'path/to/image.jpg'
1608
+ })
1609
+
1610
+ // --- Remove photo
1611
+ sock.newsletterRemovePicture('1231111111111@newsletter')
1612
+
1613
+ // --- React to a message
1614
+ sock.newsletterReactMessage('1231111111111@newsletter', '100', '💛')
1615
+
1616
+ // --- Get admin count
1617
+ const count = await sock.newsletterAdminCount('1231111111111@newsletter')
1618
+
1619
+ // --- Get all subscribed newsletters
1620
+ const newsletters = await sock.newsletterSubscribed()
1621
+ console.dir(newsletters, { depth: null })
1622
+
1623
+ // --- Fetch newsletter messages
1624
+ const messages = sock.newsletterFetchMessages('jid', '1231111111111@newsletter', 50, 0, 0)
1625
+ console.dir(messages, { depth: null })
1626
+
1627
+ // --- Delete newsletter
1628
+ sock.newsletterDelete('1231111111111@newsletter')
1629
+ ```
1630
+
1631
+ #### 👥 Group Management
1632
+
1633
+ ```javascript
1634
+ // --- Create a new one and add participants using their JIDs
1635
+ const group = sock.groupCreate('@dhilzzkz/baileys', ['628123456789@s.whatsapp.net'])
1636
+ console.dir(group, { depth: null })
1637
+
1638
+ // --- Get info
1639
+ const metadata = await sock.groupMetadata(jid)
1640
+ console.dir(metadata, { depth: null })
1641
+
1642
+ // --- Get group invite code
1643
+ const inviteCode = await sock.groupInviteCode(jid)
1644
+ console.dir(inviteCode, { depth: null })
1645
+
1646
+
1647
+ // --- Revoke invite link
1648
+ sock.groupRevokeInvite(jid)
1649
+
1650
+ // --- Accept group invite
1651
+ sock.groupAcceptInvite(inviteCode)
1652
+
1653
+ // --- Leave group
1654
+ sock.groupLeave(jid)
1655
+
1656
+ // --- Add participants
1657
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'add')
1658
+
1659
+ // --- Remove participants
1660
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'remove')
1661
+
1662
+ // --- Promote to admin
1663
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'promote')
1664
+
1665
+ // --- Demote from admin
1666
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
1667
+
1668
+ // --- Accept join requests
1669
+ sock.groupRequestParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'approve')
1670
+
1671
+ // --- Change name
1672
+ sock.groupUpdateSubject(jid, '📦 @dhilzzkz/baileys')
1673
+
1674
+ // --- Change description
1675
+ sock.groupUpdateDescription(jid, 'Updated description')
1676
+
1677
+ // --- Change photo
1678
+ sock.updateProfilePicture(jid, {
1679
+ url: 'path/to/image.jpg'
1680
+ })
1681
+
1682
+ // --- Remove photo
1683
+ sock.removeProfilePicture(jid)
1684
+
1685
+ // --- Set group as admin only for chatting
1686
+ sock.groupSettingUpdate(jid, 'announcement')
1687
+
1688
+ // --- Set group as open to all for chatting
1689
+ sock.groupSettingUpdate(jid, 'not_announcement')
1690
+
1691
+ // --- Set admin only can edit group info
1692
+ sock.groupSettingUpdate(jid, 'locked')
1693
+
1694
+ // --- Set all participants can edit group info
1695
+ sock.groupSettingUpdate(jid, 'unlocked')
1696
+
1697
+ // --- Set admin only can add participants
1698
+ sock.groupMemberAddMode(jid, 'admin_add')
1699
+
1700
+ // --- Set all participants can add participants
1701
+ sock.groupMemberAddMode(jid, 'all_member_add')
1702
+
1703
+ // --- Enable or disable temporary messages with seconds format
1704
+ sock.groupToggleEphemeral(jid, 86400)
1705
+
1706
+ // --- Disable temporary messages
1707
+ sock.groupToggleEphemeral(jid, 0)
1708
+
1709
+ // --- Enable or disable membership approval mode
1710
+ sock.groupJoinApprovalMode(jid, 'on')
1711
+ sock.groupJoinApprovalMode(jid, 'off')
1712
+
1713
+ // --- Get all groups metadata
1714
+ const groups = await sock.groupFetchAllParticipating()
1715
+ console.dir(groups, { depth: null })
1716
+
1717
+ // --- Get pending join requests
1718
+ const requests = await sock.groupRequestParticipantsList(jid)
1719
+ console.dir(requests, { depth: null })
1720
+
1721
+ // --- Get group info from link
1722
+ const group = await sock.groupGetInviteInfo('ABC123456789')
1723
+ console.log('👥 Got group info from invite code', ':', group)
1724
+
1725
+ // --- Update bot member label
1726
+ sock.updateMemberLabel(jid, '@dhilzzkz/baileys')
1727
+ ```
1728
+
1729
+ #### 👥 Community Management
1730
+
1731
+ ```javascript
1732
+ // --- Create a new one and add description
1733
+ const community = await sock.communityCreate('@dhilzzkz/baileys', '📣 Fresh updates weekly')
1734
+ console.dir(community, { depth: null })
1735
+
1736
+ // --- Create a subgroup for community and add participants using their JIDs
1737
+ const group = await sock.communityCreateGroup('📢 Announcements', ['628123456789@s.whatsapp.net'], communityJid)
1738
+
1739
+ // --- Link an existing group
1740
+ sock.communityLinkGroup(groupJid, communityJid)
1741
+
1742
+ // --- Unlink an existing group
1743
+ sock.communityUnlinkGroup(groupJid, communityJid)
1744
+
1745
+ // --- Get info
1746
+ const metadata = await sock.communityMetadata(jid)
1747
+ console.dir(metadata, { depth: null })
1748
+
1749
+ // --- Get community invite code
1750
+ const inviteCode = await sock.communityInviteCode(jid)
1751
+ console.dir(inviteCode, { depth: null })
1752
+
1753
+ // --- Revoke invite link
1754
+ sock.communityRevokeInvite(jid)
1755
+
1756
+ // --- Accept community invite
1757
+ sock.communityAcceptInvite(inviteCode)
1758
+
1759
+ // --- Leave community
1760
+ sock.communityLeave(jid)
1761
+
1762
+ // --- Accept join requests
1763
+ sock.communityRequestParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'approve')
1764
+
1765
+ // --- Change name
1766
+ sock.communityUpdateSubject(jid, '📦 @dhilzzkz/baileys')
1767
+
1768
+ // --- Change description
1769
+ sock.communityUpdateDescription(jid, 'Updated description')
1770
+
1771
+ // --- Set community as admin only for chatting
1772
+ sock.communitySettingUpdate(jid, 'announcement')
1773
+
1774
+ // --- Set community as open to all for chatting
1775
+ sock.communitySettingUpdate(jid, 'not_announcement')
1776
+
1777
+ // --- Set admin only can edit community info
1778
+ sock.communitySettingUpdate(jid, 'locked')
1779
+
1780
+ // --- Set all participants can edit community info
1781
+ sock.communitySettingUpdate(jid, 'unlocked')
1782
+
1783
+ // --- Set admin only can add participants
1784
+ sock.communityMemberAddMode(jid, 'admin_add')
1785
+
1786
+ // --- Set all participants can add participants
1787
+ sock.communityMemberAddMode(jid, 'all_member_add')
1788
+
1789
+ // --- Enable or disable temporary messages with seconds format
1790
+ sock.communityToggleEphemeral(jid, 86400)
1791
+
1792
+ // --- Disable temporary messages
1793
+ sock.communityToggleEphemeral(jid, 0)
1794
+
1795
+ // --- Enable or disable membership approval mode
1796
+ sock.communityJoinApprovalMode(jid, 'on')
1797
+ sock.communityJoinApprovalMode(jid, 'off')
1798
+
1799
+ // --- Get all communities metadata
1800
+ const communities = await sock.communityFetchAllParticipating()
1801
+ console.dir(communities, { depth: null })
1802
+
1803
+ // --- Get all community linked groups
1804
+ const linked = await sock.communityFetchLinkedGroups(jid)
1805
+ console.dir(linked, { depth: null })
1806
+
1807
+ // --- Get pending join requests
1808
+ const requests = await sock.communityRequestParticipantsList(jid)
1809
+ console.dir(requests, { depth: null })
1810
+
1811
+ // --- Get community info from link
1812
+ const community = await sock.communityGetInviteInfo('ABC123456789')
1813
+ console.log('👥 Got community info from invite code', ':', community)
1814
+ ```
1815
+
1816
+ #### 👤 Profile Management
1817
+
1818
+ ```javascript
1819
+ // --- Get user profile picture
1820
+ const url = await sock.profilePictureUrl(jid, 'image')
1821
+ console.log('🖼️ Got user profile url', url)
1822
+
1823
+ // --- Update profile picture
1824
+ sock.updateProfilePicture(jid, buffer)
1825
+ sock.updateProfilePicture(jid, { url })
1826
+
1827
+ // --- Remove profile picture
1828
+ sock.removeProfilePicture(jid)
1829
+
1830
+ // --- Update profile name
1831
+ sock.updateProfileName('My Name')
1832
+
1833
+ // --- Update profile status
1834
+ sock.updateProfileStatus('Available')
1835
+
1836
+ // --- Presence
1837
+ sock.sendPresenceUpdate('available', jid)
1838
+ sock.presenceSubscribe(jid)
1839
+
1840
+ // --- Read receipts
1841
+ sock.readMessages([message.key])
1842
+ sock.sendReceipt(jid, participant, [messageId], 'read')
1843
+
1844
+ // --- Block user
1845
+ sock.updateBlockStatus(jid, 'block')
1846
+
1847
+ // --- Unblock user
1848
+ sock.updateBlockStatus(jid, 'unblock')
1849
+
1850
+ // --- Fetch blocklist
1851
+ const blocked = await sock.fetchBlocklist()
1852
+ console.dir(blocked, { depth: null })
1853
+
1854
+ // --- Modify chats
1855
+ sock.chatModify({
1856
+ archive: true,
1857
+ lastMessageOrig: message,
1858
+ lastMessage: message
1859
+ }, jid)
1860
+
1861
+ // --- Star messages
1862
+ sock.star(jid, [{ id: messageId, fromMe: true }], true)
1863
+
1864
+ // --- Contact
1865
+ sock.addOrEditContact(jid, { displayName: 'Starseed' })
1866
+ sock.removeContact(jid)
1867
+
1868
+ // --- Label
1869
+ sock.addChatLabel(jid, labelId)
1870
+ sock.removeChatLabel(jid, labelId)
1871
+ sock.addMessageLabel(jid, messageId, labelId)
1872
+
1873
+ // --- App state sync
1874
+ sock.resyncAppState(['regular', 'critical_block'], true)
1875
+
1876
+ // --- Get business profile
1877
+ const profile = await sock.getBusinessProfile(jid)
1878
+ console.dir(profile, { depth: null })
1879
+ ```
1880
+
1881
+ #### 🛒 Business Management
1882
+
1883
+ ```javascript
1884
+ // --- Create a new product
1885
+ const product = await sock.productCreate({
1886
+ name: '🧩 Starseed (Premium)',
1887
+ description: 'Get a full version of Starseed!',
1888
+ price: 100000,
1889
+ currency: 'IDR',
1890
+ originCountryCode: 'ID',
1891
+ images: [
1892
+ bufferImage,
1893
+ {
1894
+ url: './path/to/image.jpg'
1895
+ }
1896
+ ]
1897
+ })
1898
+ console.dir(product, { depth: null })
1899
+
1900
+ // --- Update product
1901
+ await sock.productUpdate(productId, {
1902
+ name: '🧩 Starseed (Premium)',
1903
+ description: 'Get a full version of Starseed with more features!',
1904
+ price: 75000,
1905
+ currency: 'IDR',
1906
+ images: [
1907
+ {
1908
+ url: './path/to/image.jpg'
1909
+ }
1910
+ ]
1911
+ })
1912
+
1913
+ // --- Delete product
1914
+ sock.productDelete([productId])
1915
+
1916
+ // --- Get catalog info
1917
+ const { products, nextPageCursor } = await sock.getCatalog({
1918
+ jid: '628123456789@s.whatsapp.net',
1919
+ limit: 10
1920
+ })
1921
+
1922
+ // --- Get collections
1923
+ const collections = await sock.getCollections('628123456789@s.whatsapp.net', 10)
1924
+ console.dir(collections, { depth: null })
1925
+
1926
+ // --- Get order info
1927
+ const order = await sock.getOrderDetails(orderId, tokenBase64)
1928
+ console.dir(order, { depth: null })
1929
+
1930
+ // --- Update business profile
1931
+ await sock.updateBusinessProfile({
1932
+ address: 'Jakarta, Indonesia',
1933
+ description: '🛒 Official Starseed Store',
1934
+ websites: ['https://www.npmjs.com/package/@dhilzzkz/baileys'],
1935
+ email: 'more-more@gmail.com',
1936
+ hours: {
1937
+ timezone: 'Asia/Jakarta',
1938
+ days: [{ day: 'mon', mode: 'open_24h' }]
1939
+ }
1940
+ })
1941
+
1942
+ // --- Update cover
1943
+ sock.updateCoverPhoto({
1944
+ url: './path/to/image.jpg'
1945
+ })
1946
+
1947
+ // --- Remove cover
1948
+ sock.removeCoverPhoto(coverId)
1949
+
1950
+ // --- Update quick replies
1951
+ sock.addOrEditQuickReply({
1952
+ shortcut: 'hello',
1953
+ message: 'Hello from business account',
1954
+ })
1955
+
1956
+ // --- Remove quick reply
1957
+ sock.removeQuickReply(timestamp)
1958
+ ```
1959
+
1960
+ #### 🔐 Privacy Management
1961
+
1962
+ ```javascript
1963
+ // --- Update last seen privacy
1964
+ sock.updateLastSeenPrivacy('all')
1965
+ sock.updateLastSeenPrivacy('contacts')
1966
+ sock.updateLastSeenPrivacy('contact_blacklist')
1967
+ sock.updateLastSeenPrivacy('nobody')
1968
+
1969
+ // --- Update online privacy
1970
+ sock.updateOnlinePrivacy('all')
1971
+ sock.updateOnlinePrivacy('match_last_seen')
1972
+
1973
+ // --- Update profile picture privacy
1974
+ sock.updateProfilePicturePrivacy('contacts')
1975
+
1976
+ // --- Update status privacy
1977
+ sock.updateStatusPrivacy('contacts')
1978
+
1979
+ // --- Update read receipts privacy
1980
+ sock.updateReadReceiptsPrivacy('all')
1981
+ sock.updateReadReceiptsPrivacy('none')
1982
+
1983
+ // --- Update groups add privacy
1984
+ sock.updateGroupsAddPrivacy('all')
1985
+ sock.updateGroupsAddPrivacy('contacts')
1986
+
1987
+ // --- Update messages privacy
1988
+ sock.updateMessagesPrivacy('all')
1989
+ sock.updateMessagesPrivacy('contacts')
1990
+ sock.updateMessagesPrivacy('nobody')
1991
+
1992
+ // --- Update call privacy
1993
+ sock.updateCallPrivacy('everyone')
1994
+
1995
+ // --- Update default disappearing mode
1996
+ sock.updateDefaultDisappearingMode(86400)
1997
+
1998
+ // --- Update link previews privacy
1999
+ sock.updateDisableLinkPreviewsPrivacy(true)
2000
+ ```
2001
+
2002
+ #### 📡 Events
2003
+
2004
+ ```javascript
2005
+ sock.ev.on('connection.update', (update) => {})
2006
+ sock.ev.on('creds.update', (update) => {})
2007
+ sock.ev.on('messaging-history.set', (update) => {})
2008
+ sock.ev.on('messaging-history.status', (update) => {})
2009
+ sock.ev.on('chats.upsert', (update) => {})
2010
+ sock.ev.on('chats.update', (update) => {})
2011
+ sock.ev.on('chats.delete', (update) => {})
2012
+ sock.ev.on('chats.lock', (update) => {})
2013
+ sock.ev.on('lid-mapping.update', (update) => {})
2014
+ sock.ev.on('presence.update', (update) => {})
2015
+ sock.ev.on('contacts.upsert', (update) => {})
2016
+ sock.ev.on('contacts.update', (update) => {})
2017
+ sock.ev.on('messages.delete', (update) => {})
2018
+ sock.ev.on('messages.update', (update) => {})
2019
+ sock.ev.on('messages.media-update', (update) => {})
2020
+ sock.ev.on('messages.upsert', (update) => {})
2021
+ sock.ev.on('messages.reaction', (update) => {})
2022
+ sock.ev.on('message-receipt.update', (update) => {})
2023
+ sock.ev.on('groups.upsert', (update) => {})
2024
+ sock.ev.on('groups.update', (update) => {})
2025
+ sock.ev.on('group-participants.update', (update) => {})
2026
+ sock.ev.on('group.join-request', (update) => {})
2027
+ sock.ev.on('group.member-tag.update', (update) => {})
2028
+ sock.ev.on('blocklist.set', (update) => {})
2029
+ sock.ev.on('blocklist.update', (update) => {})
2030
+ sock.ev.on('call', (update) => {})
2031
+ sock.ev.on('labels.edit', (update) => {})
2032
+ sock.ev.on('labels.association', (update) => {})
2033
+ sock.ev.on('newsletter.reaction', (update) => {})
2034
+ sock.ev.on('newsletter.view', (update) => {})
2035
+ sock.ev.on('newsletter-participants.update', (update) => {})
2036
+ sock.ev.on('newsletter-settings.update', (update) => {})
2037
+ sock.ev.on('settings.update', (update) => {})
2038
+ ```
2039
+
2040
+ ### 🗂️ Project Structure
2041
+
2042
+ ```
2043
+ baileys/
2044
+ ├── lib/
2045
+ │ ├── Addon/ HTTP error, keyed DB, link preview, starforge re-exports
2046
+ │ ├── Defaults/ Constants, default socket config, WhatsApp version
2047
+ │ ├── Signal/
2048
+ │ │ ├── Group/ Group (sender key) cipher and session builder
2049
+ │ │ ├── Protocol/ Signal session protocol: curve, cipher, builder, record
2050
+ │ │ ├── libsignal.js
2051
+ │ │ └── lid-mapping.js
2052
+ │ ├── Socket/ Socket layers: socket, chats, groups, communities,
2053
+ │ │ │ business, newsletter, messages-send, messages-recv
2054
+ │ │ └── Client/ WebSocket client
2055
+ │ ├── Store/ In-memory store and ordered dictionary
2056
+ │ ├── Types/ Type declarations
2057
+ │ ├── Utils/
2058
+ │ │ ├── Auth/ Auth state, pre-keys, connection validation
2059
+ │ │ ├── Common/ Generic helpers, logger, mutex, browser presets
2060
+ │ │ ├── Crypto/ AES / HKDF helpers, LT-hash, Noise handler, Signal helpers
2061
+ │ │ ├── Message/ Message building, media, decoding, processing, history
2062
+ │ │ └── State/ App state sync, event buffer, TC tokens, identity changes
2063
+ │ ├── WABinary/ WhatsApp binary node encoder / decoder and JID utils
2064
+ │ ├── WAM/ WhatsApp analytics (WAM) encoder
2065
+ │ └── WAUSync/ USync queries and protocols
2066
+ ├── WAProto/ Protocol Buffer definitions
2067
+ ├── scripts/ Engine check and import verification
2068
+ └── README.md
2069
+ ```
2070
+
2071
+ Run `npm run verify` to check that every relative import resolves and every module ships a type declaration.
2072
+
2073
+ ### 📦 Fork Base
2074
+
2075
+ This fork is based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baileys)
2076
+
2077
+ ### 📣 Credits
2078
+
2079
+ 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)
2080
+
2081
+ Full credit is attributed to the original maintainers and contributors of Baileys:
2082
+ - [purpshell](https://github.com/purpshell)
2083
+ - [jlucaso1](https://github.com/jlucaso1)
2084
+ - [adiwajshing](https://github.com/adiwajshing)