@periskope/baileys 7.0.0-beta-2 → 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.
- package/README.md +71 -68
- package/WAProto/GenerateStatics.sh +2 -2
- package/WAProto/WAProto.proto +1339 -493
- package/WAProto/fix-imports.js +75 -19
- package/WAProto/index.d.ts +12357 -2079
- package/WAProto/index.js +81080 -20695
- package/lib/Defaults/index.d.ts +31 -8
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +48 -20
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Signal/Group/group_cipher.d.ts +1 -2
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -1
- package/lib/Signal/Group/group_cipher.js +29 -41
- package/lib/Signal/Group/group_cipher.js.map +1 -1
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -1
- package/lib/Signal/Group/keyhelper.js +0 -1
- package/lib/Signal/Group/keyhelper.js.map +1 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -1
- package/lib/Signal/Group/sender-chain-key.js +1 -7
- package/lib/Signal/Group/sender-chain-key.js.map +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -1
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-message.js +1 -2
- package/lib/Signal/Group/sender-key-message.js.map +1 -1
- package/lib/Signal/Group/sender-key-record.d.ts +1 -1
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-record.js +2 -11
- package/lib/Signal/Group/sender-key-record.js.map +1 -1
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-state.js +21 -36
- package/lib/Signal/Group/sender-key-state.js.map +1 -1
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -1
- package/lib/Signal/Group/sender-message-key.js +0 -1
- package/lib/Signal/Group/sender-message-key.js.map +1 -1
- package/lib/Signal/libsignal.d.ts +4 -3
- package/lib/Signal/libsignal.d.ts.map +1 -1
- package/lib/Signal/libsignal.js +336 -46
- package/lib/Signal/libsignal.js.map +1 -1
- package/lib/Signal/lid-mapping.d.ts +16 -11
- package/lib/Signal/lid-mapping.d.ts.map +1 -1
- package/lib/Signal/lid-mapping.js +259 -65
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/Client/types.d.ts +2 -2
- package/lib/Socket/Client/types.d.ts.map +1 -1
- package/lib/Socket/Client/websocket.d.ts +1 -1
- package/lib/Socket/Client/websocket.d.ts.map +1 -1
- package/lib/Socket/Client/websocket.js +5 -1
- package/lib/Socket/Client/websocket.js.map +1 -1
- package/lib/Socket/business.d.ts +72 -23
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/business.js +125 -1
- package/lib/Socket/business.js.map +1 -1
- package/lib/Socket/chats.d.ts +46 -12
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +360 -72
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +82 -20
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/communities.js +84 -4
- package/lib/Socket/communities.js.map +1 -1
- package/lib/Socket/groups.d.ts +47 -13
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +38 -14
- package/lib/Socket/groups.js.map +1 -1
- package/lib/Socket/index.d.ts +82 -20
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +0 -5
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/messages-recv.d.ts +69 -23
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +1191 -462
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +63 -20
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +630 -141
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/newsletter.d.ts +47 -15
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +5 -3
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +23 -4
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +456 -96
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Types/Auth.d.ts +14 -1
- package/lib/Types/Auth.d.ts.map +1 -1
- package/lib/Types/Call.d.ts +2 -1
- package/lib/Types/Call.d.ts.map +1 -1
- package/lib/Types/Chat.d.ts +5 -0
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Chat.js.map +1 -1
- package/lib/Types/Contact.d.ts +6 -4
- package/lib/Types/Contact.d.ts.map +1 -1
- package/lib/Types/Events.d.ts +66 -9
- package/lib/Types/Events.d.ts.map +1 -1
- package/lib/Types/GroupMetadata.d.ts +11 -4
- package/lib/Types/GroupMetadata.d.ts.map +1 -1
- package/lib/Types/Message.d.ts +75 -18
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js +5 -1
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/Mex.d.ts +141 -0
- package/lib/Types/Mex.d.ts.map +1 -0
- package/lib/Types/Mex.js +37 -0
- package/lib/Types/Mex.js.map +1 -0
- package/lib/Types/Newsletter.d.ts +4 -2
- package/lib/Types/Newsletter.d.ts.map +1 -1
- package/lib/Types/Newsletter.js +4 -2
- package/lib/Types/Newsletter.js.map +1 -1
- package/lib/Types/Signal.d.ts +30 -1
- package/lib/Types/Signal.d.ts.map +1 -1
- package/lib/Types/Socket.d.ts +27 -13
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Types/Socket.js.map +1 -1
- package/lib/Types/State.d.ts +58 -0
- package/lib/Types/State.d.ts.map +1 -1
- package/lib/Types/State.js +43 -0
- package/lib/Types/State.js.map +1 -1
- package/lib/Types/index.d.ts +1 -1
- package/lib/Types/index.d.ts.map +1 -1
- package/lib/Types/index.js +1 -1
- package/lib/Types/index.js.map +1 -1
- package/lib/Utils/auth-utils.d.ts +7 -2
- package/lib/Utils/auth-utils.d.ts.map +1 -1
- package/lib/Utils/auth-utils.js +218 -106
- package/lib/Utils/auth-utils.js.map +1 -1
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +37 -8
- package/lib/Utils/chat-utils.d.ts.map +1 -1
- package/lib/Utils/chat-utils.js +199 -73
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +35 -0
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +7 -11
- package/lib/Utils/crypto.d.ts.map +1 -1
- package/lib/Utils/crypto.js +11 -31
- package/lib/Utils/crypto.js.map +1 -1
- package/lib/Utils/decode-wa-message.d.ts +32 -2
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +140 -15
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.d.ts +2 -1
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js +140 -21
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +6 -7
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +69 -44
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/history.d.ts +14 -10
- package/lib/Utils/history.d.ts.map +1 -1
- package/lib/Utils/history.js +66 -17
- package/lib/Utils/history.js.map +1 -1
- package/lib/Utils/identity-change-handler.d.ts +44 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +55 -0
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +5 -1
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +5 -1
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview.d.ts +1 -2
- package/lib/Utils/link-preview.d.ts.map +1 -1
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/link-preview.js.map +1 -1
- package/lib/Utils/lt-hash.d.ts +7 -12
- package/lib/Utils/lt-hash.d.ts.map +1 -1
- package/lib/Utils/lt-hash.js +2 -42
- package/lib/Utils/lt-hash.js.map +1 -1
- package/lib/Utils/make-mutex.d.ts +1 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -1
- package/lib/Utils/make-mutex.js +20 -27
- package/lib/Utils/make-mutex.js.map +1 -1
- package/lib/Utils/message-retry-manager.d.ts +38 -5
- package/lib/Utils/message-retry-manager.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.js +123 -7
- package/lib/Utils/message-retry-manager.js.map +1 -1
- package/lib/Utils/messages-media.d.ts +32 -11
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +193 -46
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +19 -4
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +217 -49
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/noise-handler.d.ts +4 -4
- package/lib/Utils/noise-handler.d.ts.map +1 -1
- package/lib/Utils/noise-handler.js +139 -84
- package/lib/Utils/noise-handler.js.map +1 -1
- package/lib/Utils/offline-node-processor.d.ts +17 -0
- package/lib/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/Utils/offline-node-processor.js +40 -0
- package/lib/Utils/offline-node-processor.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +106 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +27 -8
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +329 -46
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/proto-utils.d.ts +7 -0
- package/lib/Utils/proto-utils.d.ts.map +1 -0
- package/lib/Utils/proto-utils.js +7 -0
- package/lib/Utils/proto-utils.js.map +1 -0
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +258 -0
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/signal.d.ts +17 -4
- package/lib/Utils/signal.d.ts.map +1 -1
- package/lib/Utils/signal.js +63 -12
- package/lib/Utils/signal.js.map +1 -1
- package/lib/Utils/stanza-ack.d.ts +11 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +49 -0
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +37 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +163 -0
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +1 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
- package/lib/Utils/validate-connection.d.ts.map +1 -1
- package/lib/Utils/validate-connection.js +55 -16
- package/lib/Utils/validate-connection.js.map +1 -1
- package/lib/WABinary/decode.d.ts.map +1 -1
- package/lib/WABinary/decode.js +36 -2
- package/lib/WABinary/decode.js.map +1 -1
- package/lib/WABinary/encode.js +5 -1
- package/lib/WABinary/encode.js.map +1 -1
- package/lib/WABinary/generic-utils.d.ts +1 -1
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +20 -9
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WABinary/jid-utils.d.ts +18 -6
- package/lib/WABinary/jid-utils.d.ts.map +1 -1
- package/lib/WABinary/jid-utils.js +52 -8
- package/lib/WABinary/jid-utils.js.map +1 -1
- package/lib/WAM/constants.d.ts +1 -1
- package/lib/WAM/constants.d.ts.map +1 -1
- package/lib/WAM/constants.js +18516 -10904
- package/lib/WAM/constants.js.map +1 -1
- package/lib/WAM/encode.d.ts.map +1 -1
- package/lib/WAM/encode.js +0 -1
- package/lib/WAM/encode.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +26 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +2 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +10 -2
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/index.d.ts +1 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/Protocols/index.js.map +1 -1
- package/lib/WAUSync/USyncQuery.d.ts +2 -1
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -1
- package/lib/WAUSync/USyncQuery.js +28 -21
- package/lib/WAUSync/USyncQuery.js.map +1 -1
- package/lib/WAUSync/USyncUser.d.ts +4 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -1
- package/lib/WAUSync/USyncUser.js +8 -0
- package/lib/WAUSync/USyncUser.js.map +1 -1
- package/package.json +53 -15
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
|
-
>
|
|
8
|
-
>
|
|
9
|
-
>
|
|
10
|
-
>
|
|
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://
|
|
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 [
|
|
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 [
|
|
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 [
|
|
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
|
-
- **[
|
|
463
|
-
- **[
|
|
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.
|
|
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.
|
|
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.
|
|
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 [
|
|
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.
|
|
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 [
|
|
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 [
|
|
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 [
|
|
1204
|
-
- You can add `backgroundColor` and other options in the message options, see [
|
|
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 --no-
|
|
2
|
-
yarn pbjs -t static-module --no-
|
|
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
|