@periskope/baileys 7.0.0-beta-3 → 7.0.0-rc10-alpha-2

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 (284) hide show
  1. package/README.md +71 -68
  2. package/WAProto/GenerateStatics.sh +2 -2
  3. package/WAProto/WAProto.proto +1339 -493
  4. package/WAProto/fix-imports.js +75 -19
  5. package/WAProto/index.d.ts +5011 -37518
  6. package/WAProto/index.js +70159 -137495
  7. package/lib/Defaults/index.d.ts +27 -9
  8. package/lib/Defaults/index.d.ts.map +1 -1
  9. package/lib/Defaults/index.js +41 -19
  10. package/lib/Defaults/index.js.map +1 -1
  11. package/lib/Signal/Group/group_cipher.d.ts +1 -2
  12. package/lib/Signal/Group/group_cipher.d.ts.map +1 -1
  13. package/lib/Signal/Group/group_cipher.js +29 -41
  14. package/lib/Signal/Group/group_cipher.js.map +1 -1
  15. package/lib/Signal/Group/keyhelper.d.ts.map +1 -1
  16. package/lib/Signal/Group/keyhelper.js +0 -1
  17. package/lib/Signal/Group/keyhelper.js.map +1 -1
  18. package/lib/Signal/Group/queue-job.d.ts +0 -1
  19. package/lib/Signal/Group/queue-job.d.ts.map +1 -1
  20. package/lib/Signal/Group/queue-job.js +0 -3
  21. package/lib/Signal/Group/queue-job.js.map +1 -1
  22. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  23. package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -1
  24. package/lib/Signal/Group/sender-chain-key.js +1 -7
  25. package/lib/Signal/Group/sender-chain-key.js.map +1 -1
  26. package/lib/Signal/Group/sender-key-distribution-message.js +2 -2
  27. package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -1
  28. package/lib/Signal/Group/sender-key-message.d.ts.map +1 -1
  29. package/lib/Signal/Group/sender-key-message.js +0 -1
  30. package/lib/Signal/Group/sender-key-message.js.map +1 -1
  31. package/lib/Signal/Group/sender-key-record.d.ts +1 -1
  32. package/lib/Signal/Group/sender-key-record.d.ts.map +1 -1
  33. package/lib/Signal/Group/sender-key-record.js +2 -11
  34. package/lib/Signal/Group/sender-key-record.js.map +1 -1
  35. package/lib/Signal/Group/sender-key-state.d.ts +4 -4
  36. package/lib/Signal/Group/sender-key-state.d.ts.map +1 -1
  37. package/lib/Signal/Group/sender-key-state.js +21 -41
  38. package/lib/Signal/Group/sender-key-state.js.map +1 -1
  39. package/lib/Signal/Group/sender-message-key.d.ts.map +1 -1
  40. package/lib/Signal/Group/sender-message-key.js +0 -1
  41. package/lib/Signal/Group/sender-message-key.js.map +1 -1
  42. package/lib/Signal/libsignal.d.ts +4 -3
  43. package/lib/Signal/libsignal.d.ts.map +1 -1
  44. package/lib/Signal/libsignal.js +294 -142
  45. package/lib/Signal/libsignal.js.map +1 -1
  46. package/lib/Signal/lid-mapping.d.ts +16 -11
  47. package/lib/Signal/lid-mapping.d.ts.map +1 -1
  48. package/lib/Signal/lid-mapping.js +259 -65
  49. package/lib/Signal/lid-mapping.js.map +1 -1
  50. package/lib/Socket/Client/types.d.ts +2 -2
  51. package/lib/Socket/Client/types.d.ts.map +1 -1
  52. package/lib/Socket/Client/websocket.d.ts +1 -1
  53. package/lib/Socket/Client/websocket.d.ts.map +1 -1
  54. package/lib/Socket/Client/websocket.js +5 -1
  55. package/lib/Socket/Client/websocket.js.map +1 -1
  56. package/lib/Socket/business.d.ts +58 -20
  57. package/lib/Socket/business.d.ts.map +1 -1
  58. package/lib/Socket/business.js +11 -8
  59. package/lib/Socket/business.js.map +1 -1
  60. package/lib/Socket/chats.d.ts +40 -12
  61. package/lib/Socket/chats.d.ts.map +1 -1
  62. package/lib/Socket/chats.js +322 -71
  63. package/lib/Socket/chats.js.map +1 -1
  64. package/lib/Socket/communities.d.ts +69 -20
  65. package/lib/Socket/communities.d.ts.map +1 -1
  66. package/lib/Socket/communities.js +39 -3
  67. package/lib/Socket/communities.js.map +1 -1
  68. package/lib/Socket/groups.d.ts +42 -13
  69. package/lib/Socket/groups.d.ts.map +1 -1
  70. package/lib/Socket/groups.js +37 -13
  71. package/lib/Socket/groups.js.map +1 -1
  72. package/lib/Socket/index.d.ts +69 -20
  73. package/lib/Socket/index.d.ts.map +1 -1
  74. package/lib/Socket/index.js +0 -5
  75. package/lib/Socket/index.js.map +1 -1
  76. package/lib/Socket/messages-recv.d.ts +63 -24
  77. package/lib/Socket/messages-recv.d.ts.map +1 -1
  78. package/lib/Socket/messages-recv.js +1181 -515
  79. package/lib/Socket/messages-recv.js.map +1 -1
  80. package/lib/Socket/messages-send.d.ts +56 -20
  81. package/lib/Socket/messages-send.d.ts.map +1 -1
  82. package/lib/Socket/messages-send.js +522 -421
  83. package/lib/Socket/messages-send.js.map +1 -1
  84. package/lib/Socket/newsletter.d.ts +42 -15
  85. package/lib/Socket/newsletter.d.ts.map +1 -1
  86. package/lib/Socket/newsletter.js +5 -3
  87. package/lib/Socket/newsletter.js.map +1 -1
  88. package/lib/Socket/socket.d.ts +23 -4
  89. package/lib/Socket/socket.d.ts.map +1 -1
  90. package/lib/Socket/socket.js +339 -101
  91. package/lib/Socket/socket.js.map +1 -1
  92. package/lib/Socket/usync.d.ts +2 -2
  93. package/lib/Types/Auth.d.ts +13 -1
  94. package/lib/Types/Auth.d.ts.map +1 -1
  95. package/lib/Types/Call.d.ts +2 -1
  96. package/lib/Types/Call.d.ts.map +1 -1
  97. package/lib/Types/Chat.d.ts +2 -0
  98. package/lib/Types/Chat.d.ts.map +1 -1
  99. package/lib/Types/Contact.d.ts +6 -4
  100. package/lib/Types/Contact.d.ts.map +1 -1
  101. package/lib/Types/Events.d.ts +66 -9
  102. package/lib/Types/Events.d.ts.map +1 -1
  103. package/lib/Types/GroupMetadata.d.ts +11 -4
  104. package/lib/Types/GroupMetadata.d.ts.map +1 -1
  105. package/lib/Types/Message.d.ts +55 -18
  106. package/lib/Types/Message.d.ts.map +1 -1
  107. package/lib/Types/Message.js +5 -1
  108. package/lib/Types/Message.js.map +1 -1
  109. package/lib/Types/Mex.d.ts +141 -0
  110. package/lib/Types/Mex.d.ts.map +1 -0
  111. package/lib/Types/Mex.js +37 -0
  112. package/lib/Types/Mex.js.map +1 -0
  113. package/lib/Types/Newsletter.d.ts +4 -2
  114. package/lib/Types/Newsletter.d.ts.map +1 -1
  115. package/lib/Types/Newsletter.js +4 -2
  116. package/lib/Types/Newsletter.js.map +1 -1
  117. package/lib/Types/Signal.d.ts +25 -16
  118. package/lib/Types/Signal.d.ts.map +1 -1
  119. package/lib/Types/Socket.d.ts +27 -13
  120. package/lib/Types/Socket.d.ts.map +1 -1
  121. package/lib/Types/Socket.js.map +1 -1
  122. package/lib/Types/State.d.ts +58 -0
  123. package/lib/Types/State.d.ts.map +1 -1
  124. package/lib/Types/State.js +43 -0
  125. package/lib/Types/State.js.map +1 -1
  126. package/lib/Types/index.d.ts +1 -1
  127. package/lib/Types/index.d.ts.map +1 -1
  128. package/lib/Types/index.js +1 -1
  129. package/lib/Types/index.js.map +1 -1
  130. package/lib/Utils/auth-utils.d.ts +7 -2
  131. package/lib/Utils/auth-utils.d.ts.map +1 -1
  132. package/lib/Utils/auth-utils.js +218 -106
  133. package/lib/Utils/auth-utils.js.map +1 -1
  134. package/lib/Utils/browser-utils.d.ts +4 -0
  135. package/lib/Utils/browser-utils.d.ts.map +1 -0
  136. package/lib/Utils/browser-utils.js +28 -0
  137. package/lib/Utils/browser-utils.js.map +1 -0
  138. package/lib/Utils/chat-utils.d.ts +37 -8
  139. package/lib/Utils/chat-utils.d.ts.map +1 -1
  140. package/lib/Utils/chat-utils.js +181 -72
  141. package/lib/Utils/chat-utils.js.map +1 -1
  142. package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
  143. package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
  144. package/lib/Utils/companion-reg-client-utils.js +35 -0
  145. package/lib/Utils/companion-reg-client-utils.js.map +1 -0
  146. package/lib/Utils/crypto.d.ts +7 -11
  147. package/lib/Utils/crypto.d.ts.map +1 -1
  148. package/lib/Utils/crypto.js +11 -31
  149. package/lib/Utils/crypto.js.map +1 -1
  150. package/lib/Utils/decode-wa-message.d.ts +27 -2
  151. package/lib/Utils/decode-wa-message.d.ts.map +1 -1
  152. package/lib/Utils/decode-wa-message.js +110 -33
  153. package/lib/Utils/decode-wa-message.js.map +1 -1
  154. package/lib/Utils/event-buffer.d.ts +2 -1
  155. package/lib/Utils/event-buffer.d.ts.map +1 -1
  156. package/lib/Utils/event-buffer.js +140 -21
  157. package/lib/Utils/event-buffer.js.map +1 -1
  158. package/lib/Utils/generics.d.ts +6 -7
  159. package/lib/Utils/generics.d.ts.map +1 -1
  160. package/lib/Utils/generics.js +69 -44
  161. package/lib/Utils/generics.js.map +1 -1
  162. package/lib/Utils/history.d.ts +14 -10
  163. package/lib/Utils/history.d.ts.map +1 -1
  164. package/lib/Utils/history.js +66 -17
  165. package/lib/Utils/history.js.map +1 -1
  166. package/lib/Utils/identity-change-handler.d.ts +44 -0
  167. package/lib/Utils/identity-change-handler.d.ts.map +1 -0
  168. package/lib/Utils/identity-change-handler.js +55 -0
  169. package/lib/Utils/identity-change-handler.js.map +1 -0
  170. package/lib/Utils/index.d.ts +5 -1
  171. package/lib/Utils/index.d.ts.map +1 -1
  172. package/lib/Utils/index.js +5 -1
  173. package/lib/Utils/index.js.map +1 -1
  174. package/lib/Utils/link-preview.d.ts +1 -2
  175. package/lib/Utils/link-preview.d.ts.map +1 -1
  176. package/lib/Utils/link-preview.js +2 -2
  177. package/lib/Utils/link-preview.js.map +1 -1
  178. package/lib/Utils/lt-hash.d.ts +7 -12
  179. package/lib/Utils/lt-hash.d.ts.map +1 -1
  180. package/lib/Utils/lt-hash.js +2 -42
  181. package/lib/Utils/lt-hash.js.map +1 -1
  182. package/lib/Utils/make-mutex.d.ts +1 -0
  183. package/lib/Utils/make-mutex.d.ts.map +1 -1
  184. package/lib/Utils/make-mutex.js +20 -27
  185. package/lib/Utils/make-mutex.js.map +1 -1
  186. package/lib/Utils/message-retry-manager.d.ts +38 -5
  187. package/lib/Utils/message-retry-manager.d.ts.map +1 -1
  188. package/lib/Utils/message-retry-manager.js +123 -7
  189. package/lib/Utils/message-retry-manager.js.map +1 -1
  190. package/lib/Utils/messages-media.d.ts +32 -11
  191. package/lib/Utils/messages-media.d.ts.map +1 -1
  192. package/lib/Utils/messages-media.js +189 -45
  193. package/lib/Utils/messages-media.js.map +1 -1
  194. package/lib/Utils/messages.d.ts +19 -4
  195. package/lib/Utils/messages.d.ts.map +1 -1
  196. package/lib/Utils/messages.js +189 -41
  197. package/lib/Utils/messages.js.map +1 -1
  198. package/lib/Utils/noise-handler.d.ts +4 -4
  199. package/lib/Utils/noise-handler.d.ts.map +1 -1
  200. package/lib/Utils/noise-handler.js +139 -84
  201. package/lib/Utils/noise-handler.js.map +1 -1
  202. package/lib/Utils/offline-node-processor.d.ts +17 -0
  203. package/lib/Utils/offline-node-processor.d.ts.map +1 -0
  204. package/lib/Utils/offline-node-processor.js +40 -0
  205. package/lib/Utils/offline-node-processor.js.map +1 -0
  206. package/lib/Utils/pre-key-manager.d.ts +28 -0
  207. package/lib/Utils/pre-key-manager.d.ts.map +1 -0
  208. package/lib/Utils/pre-key-manager.js +106 -0
  209. package/lib/Utils/pre-key-manager.js.map +1 -0
  210. package/lib/Utils/process-message.d.ts +27 -8
  211. package/lib/Utils/process-message.d.ts.map +1 -1
  212. package/lib/Utils/process-message.js +329 -46
  213. package/lib/Utils/process-message.js.map +1 -1
  214. package/lib/Utils/proto-utils.d.ts +7 -0
  215. package/lib/Utils/proto-utils.d.ts.map +1 -0
  216. package/lib/Utils/proto-utils.js +7 -0
  217. package/lib/Utils/proto-utils.js.map +1 -0
  218. package/lib/Utils/reporting-utils.d.ts +11 -0
  219. package/lib/Utils/reporting-utils.d.ts.map +1 -0
  220. package/lib/Utils/reporting-utils.js +258 -0
  221. package/lib/Utils/reporting-utils.js.map +1 -0
  222. package/lib/Utils/signal.d.ts +17 -4
  223. package/lib/Utils/signal.d.ts.map +1 -1
  224. package/lib/Utils/signal.js +63 -12
  225. package/lib/Utils/signal.js.map +1 -1
  226. package/lib/Utils/stanza-ack.d.ts +11 -0
  227. package/lib/Utils/stanza-ack.d.ts.map +1 -0
  228. package/lib/Utils/stanza-ack.js +38 -0
  229. package/lib/Utils/stanza-ack.js.map +1 -0
  230. package/lib/Utils/sync-action-utils.d.ts +19 -0
  231. package/lib/Utils/sync-action-utils.d.ts.map +1 -0
  232. package/lib/Utils/sync-action-utils.js +49 -0
  233. package/lib/Utils/sync-action-utils.js.map +1 -0
  234. package/lib/Utils/tc-token-utils.d.ts +37 -0
  235. package/lib/Utils/tc-token-utils.d.ts.map +1 -0
  236. package/lib/Utils/tc-token-utils.js +163 -0
  237. package/lib/Utils/tc-token-utils.js.map +1 -0
  238. package/lib/Utils/validate-connection.d.ts.map +1 -1
  239. package/lib/Utils/validate-connection.js +53 -14
  240. package/lib/Utils/validate-connection.js.map +1 -1
  241. package/lib/WABinary/decode.d.ts.map +1 -1
  242. package/lib/WABinary/decode.js +36 -2
  243. package/lib/WABinary/decode.js.map +1 -1
  244. package/lib/WABinary/encode.js +5 -1
  245. package/lib/WABinary/encode.js.map +1 -1
  246. package/lib/WABinary/generic-utils.d.ts +1 -1
  247. package/lib/WABinary/generic-utils.d.ts.map +1 -1
  248. package/lib/WABinary/generic-utils.js +20 -9
  249. package/lib/WABinary/generic-utils.js.map +1 -1
  250. package/lib/WABinary/jid-utils.d.ts +18 -6
  251. package/lib/WABinary/jid-utils.d.ts.map +1 -1
  252. package/lib/WABinary/jid-utils.js +52 -8
  253. package/lib/WABinary/jid-utils.js.map +1 -1
  254. package/lib/WAM/constants.d.ts +1 -1
  255. package/lib/WAM/constants.d.ts.map +1 -1
  256. package/lib/WAM/constants.js +18516 -10904
  257. package/lib/WAM/constants.js.map +1 -1
  258. package/lib/WAM/encode.d.ts.map +1 -1
  259. package/lib/WAM/encode.js +0 -1
  260. package/lib/WAM/encode.js.map +1 -1
  261. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -1
  262. package/lib/WAUSync/Protocols/USyncContactProtocol.js +26 -3
  263. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -1
  264. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  265. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
  266. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  267. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
  268. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +2 -1
  269. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -1
  270. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +10 -2
  271. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -1
  272. package/lib/WAUSync/Protocols/index.d.ts +1 -0
  273. package/lib/WAUSync/Protocols/index.d.ts.map +1 -1
  274. package/lib/WAUSync/Protocols/index.js +1 -0
  275. package/lib/WAUSync/Protocols/index.js.map +1 -1
  276. package/lib/WAUSync/USyncQuery.d.ts +2 -1
  277. package/lib/WAUSync/USyncQuery.d.ts.map +1 -1
  278. package/lib/WAUSync/USyncQuery.js +28 -21
  279. package/lib/WAUSync/USyncQuery.js.map +1 -1
  280. package/lib/WAUSync/USyncUser.d.ts +4 -0
  281. package/lib/WAUSync/USyncUser.d.ts.map +1 -1
  282. package/lib/WAUSync/USyncUser.js +8 -0
  283. package/lib/WAUSync/USyncUser.js.map +1 -1
  284. package/package.json +52 -16
package/README.md CHANGED
@@ -3,24 +3,24 @@
3
3
  <div align='center'>Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API.</div>
4
4
 
5
5
 
6
-
7
- > [!IMPORTANT]
8
- > I made a survey for users of the project to ask questions, and provide Baileys valuable insights regarding its users. I will be publishing the results of this form (after filtering) as well so we can study and understand where we need to work.
9
- >
10
- > The survey is anonymous and requires no personal info at all. You are required to sign-in with Google to keep responses to one person. You are able to edit your response after you submit. The deadline for this form is September 30, 2025.
11
- >
12
- > I encourage you to put the effort, all it takes is 5-10 minutes and you get to ask me any questions you have.
13
- >
14
- > \- Rajeh (purpshell)
15
- >
16
- > Fill in the survey via the link: https://whiskey.so/survey
17
-
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.
18
12
 
19
13
  # Important Note
20
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).
21
15
 
22
16
  New guide link: https://baileys.wiki
23
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
24
  # Sponsor
25
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
26
 
@@ -33,8 +33,8 @@ Use at your own discretion. Do not spam people with this. We discourage any stal
33
33
 
34
34
  ##
35
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 :/
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
38
  - Baileys supports interacting with the multi-device & web versions of WhatsApp.
39
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
40
 
@@ -42,7 +42,7 @@ Use at your own discretion. Do not spam people with this. We discourage any stal
42
42
  > The original repository had to be removed by the original author - we now continue development in this repository here.
43
43
  This is the only official repository and is maintained by the community.
44
44
  > **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
45
-
45
+
46
46
  ## Example
47
47
 
48
48
  Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
@@ -65,14 +65,14 @@ yarn add github:WhiskeySockets/Baileys
65
65
  ```
66
66
 
67
67
  Then import your code using:
68
- ```ts
68
+ ```ts
69
69
  import makeWASocket from '@whiskeysockets/baileys'
70
70
  ```
71
71
 
72
72
  # Links
73
73
 
74
74
  - [Discord](https://discord.gg/WeJM5FP9GG)
75
- - [Docs](https://guide.whiskeysockets.io/)
75
+ - [Docs](https://baileys.wiki/docs/intro/)
76
76
 
77
77
  # Index
78
78
 
@@ -187,12 +187,12 @@ WhatsApp provides a multi-device API that allows Baileys to be authenticated as
187
187
  > **[Here](#example-to-start) is a simple example of event handling**
188
188
 
189
189
  > [!TIP]
190
- > **You can see all supported socket configs [here](https://baileys.whiskeysockets.io/types/SocketConfig.html) (Recommended)**
190
+ > **You can see all supported socket configs in the [SocketConfig type alias](https://baileys.wiki/docs/api/type-aliases/SocketConfig/) (Recommended)**
191
191
 
192
192
  ### Starting socket with **QR-CODE**
193
193
 
194
194
  > [!TIP]
195
- > You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://baileys.whiskeysockets.io/types/BrowsersMap.html)**
195
+ > 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/)**
196
196
 
197
197
  ```ts
198
198
  import makeWASocket from '@whiskeysockets/baileys'
@@ -284,7 +284,7 @@ const sock = makeWASocket({
284
284
  ```
285
285
  ## Saving & Restoring Sessions
286
286
 
287
- You obviously don't want to keep scanning the QR code every time you want to connect.
287
+ You obviously don't want to keep scanning the QR code every time you want to connect.
288
288
 
289
289
  So, you can load the credentials to log back in:
290
290
  ```ts
@@ -308,11 +308,11 @@ sock.ev.on('creds.update', saveCreds)
308
308
 
309
309
  ## Handling Events
310
310
 
311
- - Baileys uses the EventEmitter syntax for events.
311
+ - Baileys uses the EventEmitter syntax for events.
312
312
  They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
313
313
 
314
314
  > [!IMPORTANT]
315
- > **The events are [these](https://baileys.whiskeysockets.io/types/BaileysEventMap.html)**, it's important you see all events
315
+ > **The events are in the [BaileysEventMap type alias](https://baileys.wiki/docs/api/type-aliases/BaileysEventMap/)**, it's important you see all events
316
316
 
317
317
  You can listen to these events like this:
318
318
  ```ts
@@ -327,6 +327,9 @@ sock.ev.on('messages.upsert', ({ messages }) => {
327
327
  > [!NOTE]
328
328
  > This example includes basic auth storage too
329
329
 
330
+ > [!NOTE]
331
+ > For reliable serialization of the authentication state, especially when storing as JSON, always use the BufferJSON utility.
332
+
330
333
  ```ts
331
334
  import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@whiskeysockets/baileys'
332
335
  import { Boom } from '@hapi/boom'
@@ -442,10 +445,10 @@ The store also provides some simple functions such as `loadMessages` that utiliz
442
445
 
443
446
  ## Whatsapp IDs Explain
444
447
 
445
- - `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
448
+ - `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
446
449
  - It must be in the format ```[country code][phone number]@s.whatsapp.net```
447
- - Example for people: ```+19999999999@s.whatsapp.net```.
448
- - For groups, it must be in the format ``` 123456789-123345@g.us ```.
450
+ - Example for people: ```+19999999999@s.whatsapp.net```.
451
+ - For groups, it must be in the format ``` 123456789-123345@g.us ```.
449
452
  - For broadcast lists, it's `[timestamp of creation]@broadcast`.
450
453
  - For stories, the ID is `status@broadcast`.
451
454
 
@@ -459,8 +462,8 @@ The store also provides some simple functions such as `loadMessages` that utiliz
459
462
  ## Sending Messages
460
463
 
461
464
  - Send all types of messages with a single function
462
- - **[Here](https://baileys.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**
463
- - **[Here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html) you can see all options supported, like quote message**
465
+ - **In the [AnyMessageContent type alias](https://baileys.wiki/docs/api/type-aliases/AnyMessageContent/) you can see all message contents supported, like text message**
466
+ - **In the [MiscMessageGenerationOptions type alias](https://baileys.wiki/docs/api/type-aliases/MiscMessageGenerationOptions/) you can see all options supported, like quote message**
464
467
 
465
468
  ```ts
466
469
  const jid: string
@@ -495,7 +498,7 @@ await sock.sendMessage(
495
498
  ```
496
499
 
497
500
  #### Forward Messages
498
- - You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://baileys.whiskeysockets.io/types/WAMessage.html) object
501
+ - 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
499
502
  ```ts
500
503
  const msg = getMessageFromStore() // implement this on your end
501
504
  await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
@@ -504,7 +507,7 @@ await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
504
507
  #### Location Message
505
508
  ```ts
506
509
  await sock.sendMessage(
507
- jid,
510
+ jid,
508
511
  {
509
512
  location: {
510
513
  degreesLatitude: 24.121231,
@@ -516,7 +519,7 @@ await sock.sendMessage(
516
519
  #### Contact Message
517
520
  ```ts
518
521
  const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
519
- + 'VERSION:3.0\n'
522
+ + 'VERSION:3.0\n'
520
523
  + 'FN:Jeff Singh\n' // full name
521
524
  + 'ORG:Ashoka Uni;\n' // the organization of the contact
522
525
  + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
@@ -524,17 +527,17 @@ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
524
527
 
525
528
  await sock.sendMessage(
526
529
  id,
527
- {
528
- contacts: {
529
- displayName: 'Jeff',
530
- contacts: [{ vcard }]
530
+ {
531
+ contacts: {
532
+ displayName: 'Jeff',
533
+ contacts: [{ vcard }]
531
534
  }
532
535
  }
533
536
  )
534
537
  ```
535
538
 
536
539
  #### Reaction Message
537
- - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object
540
+ - 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
538
541
  ```ts
539
542
  await sock.sendMessage(
540
543
  jid,
@@ -548,7 +551,7 @@ await sock.sendMessage(
548
551
  ```
549
552
 
550
553
  #### Pin 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.whiskeysockets.io/types/WAMessageKey.html) object
554
+ - 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
555
 
553
556
  - Time can be:
554
557
 
@@ -606,7 +609,7 @@ await sock.sendMessage(
606
609
  Sending media (video, stickers, images) is easier & more efficient than ever.
607
610
 
608
611
  > [!NOTE]
609
- > In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
612
+ > 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/)
610
613
 
611
614
  - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
612
615
 
@@ -617,8 +620,8 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
617
620
  - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
618
621
  ```ts
619
622
  await sock.sendMessage(
620
- jid,
621
- {
623
+ jid,
624
+ {
622
625
  video: fs.readFileSync('Media/ma_gif.mp4'),
623
626
  caption: 'hello word',
624
627
  gifPlayback: true
@@ -629,8 +632,8 @@ await sock.sendMessage(
629
632
  #### Video Message
630
633
  ```ts
631
634
  await sock.sendMessage(
632
- id,
633
- {
635
+ id,
636
+ {
634
637
  video: {
635
638
  url: './Media/ma_gif.mp4'
636
639
  },
@@ -654,7 +657,7 @@ await sock.sendMessage(
654
657
  ```
655
658
  ```ts
656
659
  await sock.sendMessage(
657
- jid,
660
+ jid,
658
661
  {
659
662
  audio: {
660
663
  url: './Media/audio.mp3'
@@ -667,8 +670,8 @@ await sock.sendMessage(
667
670
  #### Image Message
668
671
  ```ts
669
672
  await sock.sendMessage(
670
- id,
671
- {
673
+ id,
674
+ {
672
675
  image: {
673
676
  url: './Media/ma_img.png'
674
677
  },
@@ -683,8 +686,8 @@ await sock.sendMessage(
683
686
 
684
687
  ```ts
685
688
  await sock.sendMessage(
686
- id,
687
- {
689
+ id,
690
+ {
688
691
  image: {
689
692
  url: './Media/ma_img.png'
690
693
  },
@@ -739,7 +742,7 @@ sock.ev.on('messages.upsert', async ({ [m] }) => {
739
742
  m,
740
743
  'stream', // can be 'buffer' too
741
744
  { },
742
- {
745
+ {
743
746
  logger,
744
747
  // pass this so that baileys can request a reupload of media
745
748
  // that has been deleted
@@ -755,7 +758,7 @@ sock.ev.on('messages.upsert', async ({ [m] }) => {
755
758
 
756
759
  ### Re-upload Media Message to Whatsapp
757
760
 
758
- - 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:
761
+ - 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:
759
762
  ```ts
760
763
  await sock.updateMediaMessage(msg)
761
764
  ```
@@ -771,7 +774,7 @@ await sock.rejectCall(callId, callFrom)
771
774
  ## Send States in Chat
772
775
 
773
776
  ### Reading Messages
774
- - A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
777
+ - A set of message [keys](https://baileys.wiki/docs/api/type-aliases/WAMessageKey/) must be explicitly marked read now.
775
778
  - You cannot mark an entire 'chat' read as it were with Baileys Web.
776
779
  This means you have to keep track of unread messages.
777
780
 
@@ -781,17 +784,17 @@ const key: WAMessageKey
781
784
  await sock.readMessages([key])
782
785
  ```
783
786
 
784
- The message ID is the unique identifier of the message that you are marking as read.
787
+ The message ID is the unique identifier of the message that you are marking as read.
785
788
  On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
786
789
 
787
790
  ### Update Presence
788
791
 
789
- - ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
792
+ - ``` presence ``` can be one of the values in the [WAPresence type alias](https://baileys.wiki/docs/api/type-aliases/WAPresence/)
790
793
  - The presence expires after about 10 seconds.
791
- - This lets the person/group with `jid` know whether you're online, offline, typing etc.
794
+ - This lets the person/group with `jid` know whether you're online, offline, typing etc.
792
795
 
793
796
  ```ts
794
- await sock.sendPresenceUpdate('available', jid)
797
+ await sock.sendPresenceUpdate('available', jid)
795
798
  ```
796
799
 
797
800
  > [!NOTE]
@@ -840,12 +843,12 @@ await sock.chatModify(
840
843
  messages: [
841
844
  {
842
845
  id: 'ATWYHDNNWU81732J',
843
- fromMe: true,
846
+ fromMe: true,
844
847
  timestamp: '1654823909'
845
848
  }
846
849
  ]
847
850
  }
848
- },
851
+ },
849
852
  jid
850
853
  )
851
854
 
@@ -906,7 +909,7 @@ await sock.chatModify({
906
909
  ```ts
907
910
  // turn on disappearing messages
908
911
  await sock.sendMessage(
909
- jid,
912
+ jid,
910
913
  // this is 1 week in seconds -- how long you want messages to appear for
911
914
  { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
912
915
  )
@@ -916,7 +919,7 @@ await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT
916
919
 
917
920
  // turn off disappearing messages
918
921
  await sock.sendMessage(
919
- jid,
922
+ jid,
920
923
  { disappearingMessagesInChat: false }
921
924
  )
922
925
  ```
@@ -971,7 +974,7 @@ console.log('business description: ' + profile.description + ', category: ' + pr
971
974
  sock.ev.on('presence.update', console.log)
972
975
 
973
976
  // request updates for a chat
974
- await sock.presenceSubscribe(jid)
977
+ await sock.presenceSubscribe(jid)
975
978
  ```
976
979
 
977
980
  ## Change Profile
@@ -988,7 +991,7 @@ await sock.updateProfileName('My name')
988
991
  - To change your display picture or a group's
989
992
 
990
993
  > [!NOTE]
991
- > Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
994
+ > 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/)
992
995
 
993
996
  ```ts
994
997
  await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
@@ -1013,7 +1016,7 @@ await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyo
1013
1016
  ```ts
1014
1017
  // id & people to add to the group (will throw error if it fails)
1015
1018
  await sock.groupParticipantsUpdate(
1016
- jid,
1019
+ jid,
1017
1020
  ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1018
1021
  'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1019
1022
  )
@@ -1066,7 +1069,7 @@ console.log('group information: ' + response)
1066
1069
  ```
1067
1070
  ### Query Metadata (participants, name, description...)
1068
1071
  ```ts
1069
- const metadata = await sock.groupMetadata(jid)
1072
+ const metadata = await sock.groupMetadata(jid)
1070
1073
  console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1071
1074
  ```
1072
1075
  ### Join using `groupInviteMessage`
@@ -1084,7 +1087,7 @@ console.log(response)
1084
1087
  const response = await sock.groupRequestParticipantsUpdate(
1085
1088
  jid, // group id
1086
1089
  ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1087
- 'approve' // or 'reject'
1090
+ 'approve' // or 'reject'
1088
1091
  )
1089
1092
  console.log(response)
1090
1093
  ```
@@ -1175,7 +1178,7 @@ await sock.updateGroupsAddPrivacy(value)
1175
1178
  | 90d | 7.776.000 |
1176
1179
 
1177
1180
  ```ts
1178
- const ephemeral = 86400
1181
+ const ephemeral = 86400
1179
1182
  await sock.updateDefaultDisappearingMode(ephemeral)
1180
1183
  ```
1181
1184
 
@@ -1200,8 +1203,8 @@ await sock.sendMessage(
1200
1203
  }
1201
1204
  )
1202
1205
  ```
1203
- - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://baileys.whiskeysockets.io/types/AnyRegularMessageContent.html)
1204
- - You can add `backgroundColor` and other options in the message options, see [here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html)
1206
+ - 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/)
1207
+ - You can add `backgroundColor` and other options in the message options, see the [MiscMessageGenerationOptions type alias](https://baileys.wiki/docs/api/type-aliases/MiscMessageGenerationOptions/)
1205
1208
  - `broadcast: true` enables broadcast mode
1206
1209
  - `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.
1207
1210
 
@@ -1224,14 +1227,14 @@ const sock = makeWASocket({
1224
1227
  logger: P({ level: 'debug' }),
1225
1228
  })
1226
1229
  ```
1227
- This will enable you to see all sorts of messages WhatsApp sends in the console.
1230
+ This will enable you to see all sorts of messages WhatsApp sends in the console.
1228
1231
 
1229
1232
  ### How Whatsapp Communicate With Us
1230
1233
 
1231
1234
  > [!TIP]
1232
1235
  > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1233
1236
 
1234
- - **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:
1237
+ - **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:
1235
1238
  ```
1236
1239
  {
1237
1240
  "level": 10,
@@ -1260,7 +1263,7 @@ This will enable you to see all sorts of messages WhatsApp sends in the console.
1260
1263
  },
1261
1264
  "msg":"communication"
1262
1265
  }
1263
- ```
1266
+ ```
1264
1267
 
1265
1268
  The `'frame'` is what the message received is, it has three components:
1266
1269
  - `tag` -- what this frame is about (eg. message will have 'message')
@@ -1,3 +1,3 @@
1
- yarn pbjs -t static-module -w es6 --no-bundle -o ./index.js ./WAProto.proto;
2
- yarn pbts -o ./index.d.ts ./index.js;
1
+ yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify --no-comments -o ./index.js ./WAProto.proto;
2
+ yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify ./WAProto.proto | yarn pbts --no-comments -o ./index.d.ts -;
3
3
  node ./fix-imports.js