whalibmob 3.3.1 → 5.0.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.
- package/README.md +1247 -175
- package/cli.js +918 -400
- package/lib/Client.js +731 -0
- package/lib/messages/MessageSender.js +65 -7
- package/lib/proto/MessageProto.js +36 -9
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,297 +1,1369 @@
|
|
|
1
|
-
|
|
1
|
+
<div align='center'>whalibmob is a pure JavaScript Node.js library for interacting with the WhatsApp Mobile API.</div>
|
|
2
|
+
<div align='center'>v5.0.0</div>
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
##
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
> [!CAUTION]
|
|
7
|
+
> Use a dedicated phone number with this library. Connecting with a number that is already active on a real device will cause WhatsApp to log that device out.
|
|
6
8
|
|
|
7
|
-
>
|
|
9
|
+
> [!IMPORTANT]
|
|
10
|
+
> This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or affiliates. "WhatsApp" and related names are registered trademarks of their respective owners. Use at your own discretion.
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
- whalibmob does not require a browser, Selenium, or any other external runtime — it communicates directly with WhatsApp using a **TCP socket** and the **Noise Protocol** handshake.
|
|
13
|
+
- The library operates as a real **iOS mobile device**, not as WhatsApp Web. It uses the Mobile API endpoint, which behaves differently from the Web API.
|
|
14
|
+
- Signal Protocol encryption is **fully inlined** in pure JavaScript — no native binaries, no node-gyp, runs anywhere Node.js runs.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm install whalibmob
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Install the CLI globally:
|
|
10
23
|
|
|
11
|
-
|
|
24
|
+
```sh
|
|
25
|
+
npm install -g whalibmob
|
|
26
|
+
```
|
|
12
27
|
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
## Index
|
|
29
|
+
|
|
30
|
+
- [CLI — Getting Started](#cli--getting-started)
|
|
31
|
+
- [Install the CLI](#install-the-cli)
|
|
32
|
+
- [First-Time Setup: Register a Number](#first-time-setup-register-a-number)
|
|
33
|
+
- [Connect](#cli-connect)
|
|
34
|
+
- [Listen Mode](#listen-mode)
|
|
35
|
+
- [CLI — Interactive Shell Commands](#cli--interactive-shell-commands)
|
|
36
|
+
- [Messaging Commands](#messaging-commands)
|
|
37
|
+
- [Send Text](#send-text)
|
|
38
|
+
- [Send Image](#send-image)
|
|
39
|
+
- [Send Video](#send-video)
|
|
40
|
+
- [Send Audio](#send-audio)
|
|
41
|
+
- [Send Voice Note](#send-voice-note)
|
|
42
|
+
- [Send Document](#send-document)
|
|
43
|
+
- [Send Sticker](#send-sticker)
|
|
44
|
+
- [React to a Message](#react-to-a-message)
|
|
45
|
+
- [Edit a Message](#edit-a-message)
|
|
46
|
+
- [Delete a Message](#delete-a-message)
|
|
47
|
+
- [Post a Status / Story](#post-a-status--story)
|
|
48
|
+
- [Forward a Message](#forward-a-message)
|
|
49
|
+
- [Presence Commands](#presence-commands)
|
|
50
|
+
- [Set Online / Offline](#set-online--offline)
|
|
51
|
+
- [Typing and Recording Indicators](#typing-and-recording-indicators)
|
|
52
|
+
- [Subscribe to a Contact's Presence](#subscribe-to-a-contacts-presence)
|
|
53
|
+
- [Profile Commands](#profile-commands)
|
|
54
|
+
- [Change Display Name](#cli-change-display-name)
|
|
55
|
+
- [Change About Text](#cli-change-about-text)
|
|
56
|
+
- [Change Privacy Settings](#cli-change-privacy-settings)
|
|
57
|
+
- [Chat Management Commands](#chat-management-commands)
|
|
58
|
+
- [Mark Read / Unread](#mark-read--unread)
|
|
59
|
+
- [Mute / Unmute](#mute--unmute)
|
|
60
|
+
- [Pin / Unpin](#pin--unpin)
|
|
61
|
+
- [Archive / Unarchive](#archive--unarchive)
|
|
62
|
+
- [Star / Unstar a Message](#star--unstar-a-message-cli)
|
|
63
|
+
- [Disappearing Messages](#cli-disappearing-messages)
|
|
64
|
+
- [Block / Unblock](#block--unblock)
|
|
65
|
+
- [Show Block List](#show-block-list)
|
|
66
|
+
- [Group Commands](#group-commands)
|
|
67
|
+
- [Create a Group](#cli-create-a-group)
|
|
68
|
+
- [Leave a Group](#cli-leave-a-group)
|
|
69
|
+
- [Add / Remove Participants](#add--remove-participants)
|
|
70
|
+
- [Promote / Demote Admins](#promote--demote-admins)
|
|
71
|
+
- [Change Group Name](#change-group-name)
|
|
72
|
+
- [Change Group Description](#change-group-description)
|
|
73
|
+
- [Get Invite Link](#get-invite-link)
|
|
74
|
+
- [Revoke Invite Link](#revoke-invite-link)
|
|
75
|
+
- [Join a Group by Invite Code](#join-a-group-by-invite-code)
|
|
76
|
+
- [Query Group Metadata](#query-group-metadata)
|
|
77
|
+
- [Group Settings](#group-settings)
|
|
78
|
+
- [Registration Commands (in-shell)](#registration-commands-in-shell)
|
|
79
|
+
- [Connection Commands (in-shell)](#connection-commands-in-shell)
|
|
80
|
+
- [Full Command Reference Table](#full-command-reference-table)
|
|
81
|
+
- [Library API](#library-api)
|
|
82
|
+
- [Connecting Account](#connecting-account)
|
|
83
|
+
- [Register a New Number](#register-a-new-number)
|
|
84
|
+
- [Connect](#connect)
|
|
85
|
+
- [Saving & Restoring Sessions](#saving--restoring-sessions)
|
|
86
|
+
- [Handling Events](#handling-events)
|
|
87
|
+
- [Example to Start](#example-to-start)
|
|
88
|
+
- [All Events](#all-events)
|
|
89
|
+
- [Sending Messages](#sending-messages)
|
|
90
|
+
- [Text Message](#text-message)
|
|
91
|
+
- [Quote Message](#quote-message)
|
|
92
|
+
- [Mention User](#mention-user)
|
|
93
|
+
- [Reaction Message](#reaction-message)
|
|
94
|
+
- [Edit Message](#edit-message)
|
|
95
|
+
- [Delete Message](#delete-message)
|
|
96
|
+
- [Forward Message](#forward-message)
|
|
97
|
+
- [Media Messages](#media-messages)
|
|
98
|
+
- [Image Message](#image-message)
|
|
99
|
+
- [Video Message](#video-message)
|
|
100
|
+
- [Audio Message](#audio-message)
|
|
101
|
+
- [Voice Note](#voice-note)
|
|
102
|
+
- [Document Message](#document-message)
|
|
103
|
+
- [Sticker Message](#sticker-message)
|
|
104
|
+
- [Status / Stories](#status--stories)
|
|
105
|
+
- [Send States in Chat](#send-states-in-chat)
|
|
106
|
+
- [Reading Messages](#reading-messages)
|
|
107
|
+
- [Update Presence](#update-presence)
|
|
108
|
+
- [Modifying Chats](#modifying-chats)
|
|
109
|
+
- [Archive / Unarchive a Chat](#archive--unarchive-a-chat)
|
|
110
|
+
- [Mute / Unmute a Chat](#mute--unmute-a-chat)
|
|
111
|
+
- [Mark a Chat Read / Unread](#mark-a-chat-read--unread)
|
|
112
|
+
- [Pin / Unpin a Chat](#pin--unpin-a-chat)
|
|
113
|
+
- [Star / Unstar a Message](#star--unstar-a-message)
|
|
114
|
+
- [Disappearing Messages](#disappearing-messages)
|
|
115
|
+
- [User Queries](#user-queries)
|
|
116
|
+
- [Check If a Number Has WhatsApp](#check-if-a-number-has-whatsapp)
|
|
117
|
+
- [Fetch Profile About](#fetch-profile-about)
|
|
118
|
+
- [Fetch Profile Picture](#fetch-profile-picture)
|
|
119
|
+
- [Subscribe to Presence](#subscribe-to-presence)
|
|
120
|
+
- [Change Profile](#change-profile)
|
|
121
|
+
- [Change Display Name](#change-display-name)
|
|
122
|
+
- [Change About Text](#change-about-text)
|
|
123
|
+
- [Change Profile Picture](#change-profile-picture)
|
|
124
|
+
- [Privacy](#privacy)
|
|
125
|
+
- [Block / Unblock User](#block--unblock-user)
|
|
126
|
+
- [Get Block List](#get-block-list)
|
|
127
|
+
- [Update Privacy Settings](#update-privacy-settings)
|
|
128
|
+
- [Update Default Disappearing Mode](#update-default-disappearing-mode)
|
|
129
|
+
- [Groups](#groups)
|
|
130
|
+
- [Create a Group](#create-a-group)
|
|
131
|
+
- [Add / Remove or Demote / Promote](#add--remove-or-demote--promote)
|
|
132
|
+
- [Change Subject](#change-subject)
|
|
133
|
+
- [Change Description](#change-description)
|
|
134
|
+
- [Change Settings](#change-settings)
|
|
135
|
+
- [Leave a Group](#leave-a-group)
|
|
136
|
+
- [Get Invite Code](#get-invite-code)
|
|
137
|
+
- [Revoke Invite Code](#revoke-invite-code)
|
|
138
|
+
- [Join Using Invitation Code](#join-using-invitation-code)
|
|
139
|
+
- [Query Metadata](#query-metadata)
|
|
140
|
+
- [Get Request Join List](#get-request-join-list)
|
|
141
|
+
- [Approve / Reject Request Join](#approve--reject-request-join)
|
|
142
|
+
- [Toggle Ephemeral in Group](#toggle-ephemeral-in-group)
|
|
143
|
+
- [WhatsApp IDs](#whatsapp-ids)
|
|
144
|
+
- [Transport](#transport)
|
|
145
|
+
- [Media Encryption](#media-encryption)
|
|
15
146
|
|
|
16
147
|
---
|
|
17
148
|
|
|
18
|
-
##
|
|
149
|
+
## Library API
|
|
19
150
|
|
|
20
|
-
|
|
151
|
+
## Connecting Account
|
|
21
152
|
|
|
22
|
-
|
|
23
|
-
|
|
153
|
+
### Register a New Number
|
|
154
|
+
|
|
155
|
+
Registration is a one-time process. You need a phone number that can receive an SMS or voice call.
|
|
156
|
+
|
|
157
|
+
**Step 1 — request a verification code**
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
const {
|
|
161
|
+
createNewStore, saveStore, requestSmsCode
|
|
162
|
+
} = require('whalibmob')
|
|
163
|
+
const path = require('path')
|
|
164
|
+
const fs = require('fs')
|
|
165
|
+
|
|
166
|
+
const phone = '919634847671' // country code + number, no '+'
|
|
167
|
+
const sessDir = path.join(process.env.HOME, '.waSession')
|
|
168
|
+
const sessFile = path.join(sessDir, phone + '.json')
|
|
169
|
+
|
|
170
|
+
fs.mkdirSync(sessDir, { recursive: true })
|
|
171
|
+
|
|
172
|
+
const store = createNewStore(phone)
|
|
173
|
+
saveStore(store, sessFile)
|
|
174
|
+
|
|
175
|
+
await requestSmsCode(store, 'sms') // 'sms' | 'voice' | 'wa_old'
|
|
24
176
|
```
|
|
25
177
|
|
|
26
|
-
|
|
178
|
+
**Step 2 — verify the code**
|
|
27
179
|
|
|
28
|
-
```
|
|
29
|
-
|
|
180
|
+
```js
|
|
181
|
+
const { loadStore, saveStore, verifyCode } = require('whalibmob')
|
|
182
|
+
|
|
183
|
+
const store = loadStore(sessFile)
|
|
184
|
+
const result = await verifyCode(store, '123456')
|
|
185
|
+
|
|
186
|
+
if (result.status === 'ok') {
|
|
187
|
+
saveStore(result.store, sessFile)
|
|
188
|
+
console.log('registered')
|
|
189
|
+
}
|
|
30
190
|
```
|
|
31
191
|
|
|
32
|
-
|
|
192
|
+
### Connect
|
|
193
|
+
|
|
194
|
+
```js
|
|
195
|
+
const { WhalibmobClient } = require('whalibmob')
|
|
196
|
+
const path = require('path')
|
|
33
197
|
|
|
34
|
-
|
|
198
|
+
const client = new WhalibmobClient({
|
|
199
|
+
sessionDir: path.join(process.env.HOME, '.waSession')
|
|
200
|
+
})
|
|
35
201
|
|
|
36
|
-
|
|
202
|
+
client.on('connected', () => {
|
|
203
|
+
console.log('connected')
|
|
204
|
+
})
|
|
37
205
|
|
|
38
|
-
|
|
39
|
-
|
|
206
|
+
await client.init('919634847671')
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Saving & Restoring Sessions
|
|
210
|
+
|
|
211
|
+
Sessions are automatically persisted to disk as JSON files under the `sessionDir` you provide. The file is named `<phone>.json`. On the next `client.init()` call the session is restored and no re-registration is needed.
|
|
212
|
+
|
|
213
|
+
```js
|
|
214
|
+
const client = new WhalibmobClient({
|
|
215
|
+
sessionDir: path.join(process.env.HOME, '.waSession')
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
// no need to register again — just connect
|
|
219
|
+
await client.init('919634847671')
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
> [!NOTE]
|
|
223
|
+
> Each phone number uses its own session file. The library handles Signal Protocol key persistence automatically.
|
|
224
|
+
|
|
225
|
+
## Handling Events
|
|
226
|
+
|
|
227
|
+
whalibmob uses the EventEmitter syntax for events.
|
|
228
|
+
|
|
229
|
+
### Example to Start
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
const { WhalibmobClient } = require('whalibmob')
|
|
233
|
+
const path = require('path')
|
|
234
|
+
|
|
235
|
+
async function connect() {
|
|
236
|
+
const client = new WhalibmobClient({
|
|
237
|
+
sessionDir: path.join(process.env.HOME, '.waSession')
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
client.on('connected', async () => {
|
|
241
|
+
console.log('connected')
|
|
242
|
+
await client.sendText('919634847671@s.whatsapp.net', 'Hello!')
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
client.on('disconnected', () => {
|
|
246
|
+
console.log('disconnected — reconnecting...')
|
|
247
|
+
setTimeout(() => connect(), 3000)
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
client.on('message', msg => {
|
|
251
|
+
console.log('message from', msg.from, msg.text)
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
client.on('auth_failure', ({ reason }) => {
|
|
255
|
+
console.error('session revoked:', reason)
|
|
256
|
+
// re-register the number
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
await client.init('919634847671')
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
connect()
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### All Events
|
|
266
|
+
|
|
267
|
+
| Event | Payload | Description |
|
|
268
|
+
|---|---|---|
|
|
269
|
+
| `connected` | — | Session authenticated and ready |
|
|
270
|
+
| `disconnected` | — | Connection closed |
|
|
271
|
+
| `reconnecting` | `{ attempt, delay }` | Lost connection, will retry |
|
|
272
|
+
| `reconnected` | — | Connection restored |
|
|
273
|
+
| `auth_failure` | `{ reason }` | Session revoked or banned |
|
|
274
|
+
| `message` | message object | Incoming message received |
|
|
275
|
+
| `receipt` | `{ type, id, from }` | Delivery / read / played receipt |
|
|
276
|
+
| `presence` | `{ from, available, lastSeen }` | Contact came online or went offline |
|
|
277
|
+
| `notification` | node object | Group or contact update notification |
|
|
278
|
+
| `call` | `{ from }` | Incoming call event |
|
|
279
|
+
| `error` | Error | Unhandled transport error |
|
|
280
|
+
|
|
281
|
+
The message object contains:
|
|
282
|
+
|
|
283
|
+
```js
|
|
284
|
+
{
|
|
285
|
+
id: string, // message ID
|
|
286
|
+
from: string, // sender JID
|
|
287
|
+
participant: string, // group sender JID (groups only)
|
|
288
|
+
ts: number, // Unix timestamp
|
|
289
|
+
text: string, // text body (plain text messages)
|
|
290
|
+
plaintext: Buffer, // decrypted raw payload
|
|
291
|
+
mediaType: string // 'image' | 'video' | 'audio' | 'document' | 'sticker'
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Sending Messages
|
|
296
|
+
|
|
297
|
+
### Text Message
|
|
298
|
+
|
|
299
|
+
```js
|
|
300
|
+
await client.sendText('919634847671@s.whatsapp.net', 'Hello!')
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Quote Message
|
|
304
|
+
|
|
305
|
+
```js
|
|
306
|
+
// pass { quotedMsgId, quotedParticipant } in options
|
|
307
|
+
await client.sendText(
|
|
308
|
+
'919634847671@s.whatsapp.net',
|
|
309
|
+
'This is a reply',
|
|
310
|
+
{ quotedMsgId: 'ABCDEF123456', quotedParticipant: '919634847671@s.whatsapp.net' }
|
|
311
|
+
)
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Mention User
|
|
315
|
+
|
|
316
|
+
```js
|
|
317
|
+
await client.sendText(
|
|
318
|
+
'120363000000000000@g.us',
|
|
319
|
+
'@919634847671 hello!',
|
|
320
|
+
{ mentions: ['919634847671@s.whatsapp.net'] }
|
|
321
|
+
)
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Reaction Message
|
|
325
|
+
|
|
326
|
+
```js
|
|
327
|
+
// react to a message
|
|
328
|
+
await client.sendReaction('919634847671@s.whatsapp.net', 'MSGID123', '👍')
|
|
329
|
+
|
|
330
|
+
// remove a reaction — pass empty string
|
|
331
|
+
await client.sendReaction('919634847671@s.whatsapp.net', 'MSGID123', '')
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Edit Message
|
|
335
|
+
|
|
336
|
+
> [!NOTE]
|
|
337
|
+
> Editing is only possible within 15 minutes of the original send.
|
|
338
|
+
|
|
339
|
+
```js
|
|
340
|
+
await client.editMessage(
|
|
341
|
+
'MSGID123', // original message ID
|
|
342
|
+
'919634847671@s.whatsapp.net',
|
|
343
|
+
'Corrected text here'
|
|
344
|
+
)
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Delete Message
|
|
348
|
+
|
|
349
|
+
```js
|
|
350
|
+
// delete for yourself only
|
|
351
|
+
await client.deleteMessage('MSGID123', '919634847671@s.whatsapp.net', true, false)
|
|
352
|
+
|
|
353
|
+
// delete for everyone (revoke)
|
|
354
|
+
await client.deleteMessage('MSGID123', '919634847671@s.whatsapp.net', true, true)
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Forward Message
|
|
358
|
+
|
|
359
|
+
```js
|
|
360
|
+
await client.forwardMessage('919634847671@s.whatsapp.net', 'text to forward')
|
|
40
361
|
```
|
|
41
362
|
|
|
42
|
-
|
|
363
|
+
## Media Messages
|
|
364
|
+
|
|
365
|
+
### Image Message
|
|
366
|
+
|
|
367
|
+
```js
|
|
368
|
+
// from file path
|
|
369
|
+
await client.sendImage('919634847671@s.whatsapp.net', './photo.jpg', { caption: 'Look at this' })
|
|
370
|
+
|
|
371
|
+
// from Buffer
|
|
372
|
+
await client.sendImage('919634847671@s.whatsapp.net', buffer, {
|
|
373
|
+
caption: 'Photo',
|
|
374
|
+
mimetype: 'image/jpeg'
|
|
375
|
+
})
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Video Message
|
|
379
|
+
|
|
380
|
+
```js
|
|
381
|
+
await client.sendVideo('919634847671@s.whatsapp.net', './clip.mp4', { caption: 'Watch this' })
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Audio Message
|
|
385
|
+
|
|
386
|
+
```js
|
|
387
|
+
await client.sendAudio('919634847671@s.whatsapp.net', './song.mp3')
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Voice Note
|
|
391
|
+
|
|
392
|
+
```js
|
|
393
|
+
// ptt: true renders the audio as a push-to-talk voice note with waveform
|
|
394
|
+
await client.sendAudio('919634847671@s.whatsapp.net', './voice.ogg', { ptt: true })
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Document Message
|
|
398
|
+
|
|
399
|
+
```js
|
|
400
|
+
await client.sendDocument('919634847671@s.whatsapp.net', './report.pdf', {
|
|
401
|
+
fileName: 'Q1 Report.pdf'
|
|
402
|
+
})
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Sticker Message
|
|
406
|
+
|
|
407
|
+
```js
|
|
408
|
+
await client.sendSticker('919634847671@s.whatsapp.net', './sticker.webp')
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
## Status / Stories
|
|
412
|
+
|
|
413
|
+
```js
|
|
414
|
+
// post a text Status to status@broadcast
|
|
415
|
+
await client.sendStatus('Good morning!')
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
## Send States in Chat
|
|
419
|
+
|
|
420
|
+
### Reading Messages
|
|
421
|
+
|
|
422
|
+
```js
|
|
423
|
+
// mark the last message in a chat as read
|
|
424
|
+
client.markChatRead('919634847671@s.whatsapp.net')
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Update Presence
|
|
428
|
+
|
|
429
|
+
```js
|
|
430
|
+
// set yourself as online / offline globally
|
|
431
|
+
client.setOnline(true)
|
|
432
|
+
client.setOnline(false)
|
|
433
|
+
|
|
434
|
+
// show typing or recording in a specific chat
|
|
435
|
+
client.setChatPresence('919634847671@s.whatsapp.net', 'composing') // typing
|
|
436
|
+
client.setChatPresence('919634847671@s.whatsapp.net', 'recording') // recording audio
|
|
437
|
+
client.setChatPresence('919634847671@s.whatsapp.net', 'paused') // stopped
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## Modifying Chats
|
|
441
|
+
|
|
442
|
+
### Archive / Unarchive a Chat
|
|
443
|
+
|
|
444
|
+
```js
|
|
445
|
+
client.archiveChat('919634847671@s.whatsapp.net')
|
|
446
|
+
client.unarchiveChat('919634847671@s.whatsapp.net')
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### Mute / Unmute a Chat
|
|
450
|
+
|
|
451
|
+
```js
|
|
452
|
+
client.muteChat('919634847671@s.whatsapp.net', 8 * 60 * 60 * 1000) // mute for 8 hours (ms)
|
|
453
|
+
client.muteChat('919634847671@s.whatsapp.net', 0) // mute indefinitely
|
|
454
|
+
client.unmuteChat('919634847671@s.whatsapp.net')
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Mark a Chat Read / Unread
|
|
458
|
+
|
|
459
|
+
```js
|
|
460
|
+
client.markChatRead('919634847671@s.whatsapp.net')
|
|
461
|
+
client.markChatUnread('919634847671@s.whatsapp.net')
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Pin / Unpin a Chat
|
|
465
|
+
|
|
466
|
+
```js
|
|
467
|
+
client.pinChat('919634847671@s.whatsapp.net')
|
|
468
|
+
client.unpinChat('919634847671@s.whatsapp.net')
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Star / Unstar a Message
|
|
472
|
+
|
|
473
|
+
```js
|
|
474
|
+
client.starMessage('MSGID123', '919634847671@s.whatsapp.net')
|
|
475
|
+
client.unstarMessage('MSGID123', '919634847671@s.whatsapp.net')
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Disappearing Messages
|
|
479
|
+
|
|
480
|
+
| Duration | Seconds |
|
|
481
|
+
|---|---|
|
|
482
|
+
| Off | 0 |
|
|
483
|
+
| 24 hours | 86 400 |
|
|
484
|
+
| 7 days | 604 800 |
|
|
485
|
+
| 90 days | 7 776 000 |
|
|
486
|
+
|
|
487
|
+
```js
|
|
488
|
+
// set disappearing timer for a specific chat (DM or group)
|
|
489
|
+
await client.changeEphemeralTimer('919634847671@s.whatsapp.net', 86400)
|
|
490
|
+
await client.changeEphemeralTimer('120363000000000000@g.us', 604800)
|
|
491
|
+
|
|
492
|
+
// remove disappearing messages
|
|
493
|
+
await client.changeEphemeralTimer('919634847671@s.whatsapp.net', 0)
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
## User Queries
|
|
497
|
+
|
|
498
|
+
### Check If a Number Has WhatsApp
|
|
499
|
+
|
|
500
|
+
```js
|
|
501
|
+
const { checkNumberStatus } = require('whalibmob')
|
|
502
|
+
|
|
503
|
+
const result = await checkNumberStatus('919634847671')
|
|
504
|
+
// result.status: 'registered' | 'registered_blocked' | 'not_registered' | 'cooldown' | 'unknown'
|
|
505
|
+
console.log(result.status)
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
Check multiple numbers at once while connected:
|
|
509
|
+
|
|
510
|
+
```js
|
|
511
|
+
const results = await client.hasWhatsapp(['919634847671', '12345678901'])
|
|
512
|
+
// returns array of JIDs that have WhatsApp
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### Fetch Profile About
|
|
516
|
+
|
|
517
|
+
```js
|
|
518
|
+
const about = await client.queryAbout('919634847671@s.whatsapp.net')
|
|
519
|
+
console.log(about)
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Fetch Profile Picture
|
|
523
|
+
|
|
524
|
+
```js
|
|
525
|
+
const url = await client.queryPicture('919634847671@s.whatsapp.net')
|
|
526
|
+
// also works for groups
|
|
527
|
+
const groupUrl = await client.queryPicture('120363000000000000@g.us')
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
### Subscribe to Presence
|
|
531
|
+
|
|
532
|
+
```js
|
|
533
|
+
// triggers 'presence' events when the contact comes online or goes offline
|
|
534
|
+
client.subscribeToPresence('919634847671@s.whatsapp.net')
|
|
535
|
+
|
|
536
|
+
client.on('presence', ({ from, available, lastSeen }) => {
|
|
537
|
+
console.log(from, available ? 'online' : 'offline')
|
|
538
|
+
})
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
## Change Profile
|
|
542
|
+
|
|
543
|
+
### Change Display Name
|
|
544
|
+
|
|
545
|
+
```js
|
|
546
|
+
client.changeName('My Bot')
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
### Change About Text
|
|
550
|
+
|
|
551
|
+
```js
|
|
552
|
+
await client.changeAbout('Available 24/7')
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### Change Profile Picture
|
|
556
|
+
|
|
557
|
+
```js
|
|
558
|
+
// groups are also supported
|
|
559
|
+
await client.changeProfilePicture('./avatar.jpg')
|
|
560
|
+
await client.changeGroupPicture('120363000000000000@g.us', './group.jpg')
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
## Privacy
|
|
564
|
+
|
|
565
|
+
### Block / Unblock User
|
|
566
|
+
|
|
567
|
+
```js
|
|
568
|
+
await client.blockContact('919634847671@s.whatsapp.net')
|
|
569
|
+
await client.unblockContact('919634847671@s.whatsapp.net')
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
### Get Block List
|
|
573
|
+
|
|
574
|
+
```js
|
|
575
|
+
const list = await client.queryBlockList()
|
|
576
|
+
console.log(list) // [ '919634847671@s.whatsapp.net', ... ]
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### Update Privacy Settings
|
|
580
|
+
|
|
581
|
+
```js
|
|
582
|
+
// type: 'last_seen' | 'profile_picture' | 'status' | 'online' | 'read_receipts' | 'groups_add'
|
|
583
|
+
// value: 'all' | 'contacts' | 'contact_blacklist' | 'none' | 'match_last_seen'
|
|
584
|
+
|
|
585
|
+
await client.changePrivacySetting('last_seen', 'contacts')
|
|
586
|
+
await client.changePrivacySetting('profile_picture', 'contacts')
|
|
587
|
+
await client.changePrivacySetting('status', 'contacts')
|
|
588
|
+
await client.changePrivacySetting('online', 'match_last_seen')
|
|
589
|
+
await client.changePrivacySetting('read_receipts', 'none')
|
|
590
|
+
await client.changePrivacySetting('groups_add', 'contacts')
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### Update Default Disappearing Mode
|
|
594
|
+
|
|
595
|
+
```js
|
|
596
|
+
// sets the default ephemeral timer for all new chats
|
|
597
|
+
await client.changeNewChatsEphemeralTimer(86400) // 1 day
|
|
598
|
+
await client.changeNewChatsEphemeralTimer(0) // off
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
## Groups
|
|
602
|
+
|
|
603
|
+
### Create a Group
|
|
604
|
+
|
|
605
|
+
```js
|
|
606
|
+
const group = await client.createGroup('My Group', [
|
|
607
|
+
'919634847671@s.whatsapp.net',
|
|
608
|
+
'12345678901@s.whatsapp.net'
|
|
609
|
+
])
|
|
610
|
+
console.log('created group', group)
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### Add / Remove or Demote / Promote
|
|
614
|
+
|
|
615
|
+
```js
|
|
616
|
+
const groupJid = '120363000000000000@g.us'
|
|
617
|
+
|
|
618
|
+
await client.addGroupParticipants(groupJid, ['919634847671@s.whatsapp.net'])
|
|
619
|
+
await client.removeGroupParticipants(groupJid, ['919634847671@s.whatsapp.net'])
|
|
620
|
+
await client.promoteGroupParticipants(groupJid, ['919634847671@s.whatsapp.net'])
|
|
621
|
+
await client.demoteGroupParticipants(groupJid, ['919634847671@s.whatsapp.net'])
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
### Change Subject
|
|
625
|
+
|
|
626
|
+
```js
|
|
627
|
+
await client.changeGroupSubject('120363000000000000@g.us', 'New Group Name')
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
### Change Description
|
|
631
|
+
|
|
632
|
+
```js
|
|
633
|
+
await client.changeGroupDescription('120363000000000000@g.us', 'This is the group description')
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
### Change Settings
|
|
637
|
+
|
|
638
|
+
```js
|
|
639
|
+
// setting: 'edit_group_info' | 'send_messages' | 'add_participants' | 'approve_participants'
|
|
640
|
+
// policy: 'admins' | 'all'
|
|
641
|
+
|
|
642
|
+
await client.changeGroupSetting('120363000000000000@g.us', 'send_messages', 'admins')
|
|
643
|
+
await client.changeGroupSetting('120363000000000000@g.us', 'edit_group_info', 'admins')
|
|
644
|
+
await client.changeGroupSetting('120363000000000000@g.us', 'add_participants', 'all')
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
### Leave a Group
|
|
648
|
+
|
|
649
|
+
```js
|
|
650
|
+
await client.leaveGroup('120363000000000000@g.us')
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### Get Invite Code
|
|
654
|
+
|
|
655
|
+
```js
|
|
656
|
+
const link = await client.queryGroupInviteLink('120363000000000000@g.us')
|
|
657
|
+
// e.g. 'https://chat.whatsapp.com/AbCdEfGhIjK'
|
|
658
|
+
console.log(link)
|
|
659
|
+
```
|
|
43
660
|
|
|
44
|
-
|
|
45
|
-
|
|
661
|
+
### Revoke Invite Code
|
|
662
|
+
|
|
663
|
+
```js
|
|
664
|
+
await client.revokeGroupInvite('120363000000000000@g.us')
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
### Join Using Invitation Code
|
|
668
|
+
|
|
669
|
+
> [!NOTE]
|
|
670
|
+
> Pass only the code portion — do not include `https://chat.whatsapp.com/`
|
|
671
|
+
|
|
672
|
+
```js
|
|
673
|
+
const jid = await client.acceptGroupInvite('AbCdEfGhIjK')
|
|
674
|
+
console.log('joined', jid)
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
### Query Metadata
|
|
678
|
+
|
|
679
|
+
```js
|
|
680
|
+
const meta = await client.getGroupMetadata('120363000000000000@g.us')
|
|
681
|
+
console.log(meta)
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
### Get Request Join List
|
|
685
|
+
|
|
686
|
+
```js
|
|
687
|
+
const pending = await client.queryGroupPendingParticipants('120363000000000000@g.us')
|
|
688
|
+
console.log(pending)
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
### Approve / Reject Request Join
|
|
692
|
+
|
|
693
|
+
```js
|
|
694
|
+
await client.approveGroupParticipants('120363000000000000@g.us', [
|
|
695
|
+
'919634847671@s.whatsapp.net'
|
|
696
|
+
])
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
### Toggle Ephemeral in Group
|
|
700
|
+
|
|
701
|
+
```js
|
|
702
|
+
await client.changeEphemeralTimer('120363000000000000@g.us', 86400) // 1 day
|
|
703
|
+
await client.changeEphemeralTimer('120363000000000000@g.us', 0) // off
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
## CLI — Getting Started
|
|
707
|
+
|
|
708
|
+
### Install the CLI
|
|
709
|
+
|
|
710
|
+
Install whalibmob globally to get the `wa` command available from anywhere on your system:
|
|
711
|
+
|
|
712
|
+
```sh
|
|
713
|
+
npm install -g whalibmob
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
Verify the installation:
|
|
717
|
+
|
|
718
|
+
```sh
|
|
719
|
+
wa version
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
### First-Time Setup: Register a Number
|
|
723
|
+
|
|
724
|
+
Registration is a one-time process. You need a phone number that can receive an SMS or voice call. **Use a dedicated number** — do not use a number already active on a real WhatsApp device.
|
|
725
|
+
|
|
726
|
+
**Step 1 — request a verification code**
|
|
727
|
+
|
|
728
|
+
```sh
|
|
729
|
+
# via SMS (default)
|
|
46
730
|
wa registration --request-code 919634847671
|
|
47
731
|
|
|
48
|
-
#
|
|
732
|
+
# via voice call
|
|
49
733
|
wa registration --request-code 919634847671 --method voice
|
|
50
734
|
|
|
51
|
-
#
|
|
735
|
+
# via an old WhatsApp account
|
|
52
736
|
wa registration --request-code 919634847671 --method wa_old
|
|
53
737
|
```
|
|
54
738
|
|
|
55
|
-
|
|
739
|
+
The CLI sends the code request, prints the result, and then **stays open** in the interactive shell. You will see:
|
|
56
740
|
|
|
57
|
-
```
|
|
741
|
+
```
|
|
742
|
+
requesting sms code for +919634847671...
|
|
743
|
+
status sent
|
|
744
|
+
now run: wa registration --register 919634847671 --code <code>
|
|
745
|
+
|
|
746
|
+
staying in shell — use /reg confirm 919634847671 <code> to complete
|
|
747
|
+
wa>
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
**Step 2 — confirm the code you received**
|
|
751
|
+
|
|
752
|
+
Either run the one-shot command:
|
|
753
|
+
|
|
754
|
+
```sh
|
|
58
755
|
wa registration --register 919634847671 --code 123456
|
|
59
756
|
```
|
|
60
757
|
|
|
61
|
-
|
|
758
|
+
Or type it directly in the shell that stayed open:
|
|
759
|
+
|
|
760
|
+
```sh
|
|
761
|
+
wa> /reg confirm 919634847671 123456
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
On success you will see:
|
|
765
|
+
|
|
766
|
+
```
|
|
767
|
+
registered session saved to /home/user/.waSession/919634847671.json
|
|
768
|
+
now run: /connect 919634847671
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
**Check if a number already has WhatsApp**
|
|
772
|
+
|
|
773
|
+
```sh
|
|
774
|
+
wa registration --check 919634847671
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
Output:
|
|
778
|
+
|
|
779
|
+
```
|
|
780
|
+
checking +919634847671...
|
|
781
|
+
status registered
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
Possible statuses: `registered` · `registered_blocked` · `not_registered` · `cooldown` · `unknown`
|
|
785
|
+
|
|
786
|
+
### CLI Connect
|
|
62
787
|
|
|
63
|
-
|
|
788
|
+
After registering, connect with:
|
|
789
|
+
|
|
790
|
+
```sh
|
|
64
791
|
wa connect 919634847671
|
|
65
792
|
```
|
|
66
793
|
|
|
67
|
-
|
|
794
|
+
The shell opens with a persistent prompt:
|
|
68
795
|
|
|
69
796
|
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
wa>
|
|
73
|
-
|
|
797
|
+
connecting to +919634847671...
|
|
798
|
+
connected as +919634847671
|
|
799
|
+
wa +919634847671>
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
> [!TIP]
|
|
803
|
+
> **The shell never exits on its own.** It stays open until you type `/quit` or press Ctrl+C. This is true for every command — registration, connection, sending messages — everything.
|
|
804
|
+
|
|
805
|
+
Use a custom session directory with `--session`:
|
|
806
|
+
|
|
807
|
+
```sh
|
|
808
|
+
wa connect 919634847671 --session /data/my-sessions
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
### Listen Mode
|
|
812
|
+
|
|
813
|
+
Connect and print all incoming events to the terminal. The process stays alive indefinitely until you press Ctrl+C:
|
|
814
|
+
|
|
815
|
+
```sh
|
|
816
|
+
wa listen 919634847671
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
Output as messages arrive:
|
|
820
|
+
|
|
821
|
+
```
|
|
822
|
+
connected listening on +919634847671 (Ctrl+C to stop)
|
|
823
|
+
────────────────────────────────────────────────────────
|
|
824
|
+
time 2025-03-13 10:00:05
|
|
825
|
+
from 919634847671@s.whatsapp.net
|
|
826
|
+
id 3EB0ABCDEF123456
|
|
827
|
+
text Hello there!
|
|
74
828
|
```
|
|
75
829
|
|
|
76
830
|
---
|
|
77
831
|
|
|
78
|
-
## CLI
|
|
832
|
+
## CLI — Interactive Shell Commands
|
|
79
833
|
|
|
80
|
-
|
|
834
|
+
After running `wa connect <phone>`, every feature of the library is available as a `/command`. Type `/help` at any time to see all commands.
|
|
81
835
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
| `wa registration --check <phone>` | Check if a number has WhatsApp |
|
|
85
|
-
| `wa registration --request-code <phone>` | Request SMS verification code |
|
|
86
|
-
| `wa registration --request-code <phone> --method voice` | Request code via voice call |
|
|
87
|
-
| `wa registration --request-code <phone> --method wa_old` | Request code via old WA account |
|
|
88
|
-
| `wa registration --register <phone> --code <code>` | Complete registration |
|
|
836
|
+
> [!NOTE]
|
|
837
|
+
> JIDs can be written as plain phone numbers (e.g. `919634847671`) — the shell automatically appends `@s.whatsapp.net`. For groups, use the full `@g.us` JID.
|
|
89
838
|
|
|
90
|
-
###
|
|
839
|
+
### Messaging Commands
|
|
91
840
|
|
|
92
|
-
|
|
93
|
-
|---|---|
|
|
94
|
-
| `wa connect <phone>` | Connect and open interactive shell |
|
|
95
|
-
| `wa listen <phone>` | Connect and print all incoming messages |
|
|
841
|
+
#### Send Text
|
|
96
842
|
|
|
97
|
-
|
|
843
|
+
```sh
|
|
844
|
+
wa> /send 919634847671@s.whatsapp.net Hello, how are you?
|
|
845
|
+
sent 3EB0ABCDEF123456
|
|
98
846
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
847
|
+
# to a group
|
|
848
|
+
wa> /send 120363000000000000@g.us Hello everyone!
|
|
849
|
+
```
|
|
102
850
|
|
|
103
|
-
|
|
104
|
-
wa send <phone> --to <jid> --image ./photo.jpg --caption "Check this out"
|
|
851
|
+
#### Send Image
|
|
105
852
|
|
|
106
|
-
|
|
107
|
-
wa
|
|
853
|
+
```sh
|
|
854
|
+
wa> /image 919634847671@s.whatsapp.net ./photo.jpg
|
|
855
|
+
wa> /image 919634847671@s.whatsapp.net ./photo.jpg Look at this!
|
|
856
|
+
```
|
|
108
857
|
|
|
109
|
-
|
|
110
|
-
wa send <phone> --to <jid> --ptt ./voice.ogg
|
|
858
|
+
The second argument is the file path. The optional third argument is the caption.
|
|
111
859
|
|
|
112
|
-
|
|
113
|
-
wa send <phone> --to <jid> --audio ./song.mp3
|
|
860
|
+
#### Send Video
|
|
114
861
|
|
|
115
|
-
|
|
116
|
-
wa
|
|
862
|
+
```sh
|
|
863
|
+
wa> /video 919634847671@s.whatsapp.net ./clip.mp4
|
|
864
|
+
wa> /video 919634847671@s.whatsapp.net ./clip.mp4 Watch this
|
|
865
|
+
```
|
|
117
866
|
|
|
118
|
-
|
|
119
|
-
wa send <phone> --to <jid> --sticker ./sticker.webp
|
|
867
|
+
#### Send Audio
|
|
120
868
|
|
|
121
|
-
|
|
122
|
-
wa send <phone> --to <jid> --reaction 👍 --msg-id 3EB0ABCDEF123456
|
|
869
|
+
Sends the file as a regular audio attachment:
|
|
123
870
|
|
|
124
|
-
|
|
125
|
-
wa
|
|
871
|
+
```sh
|
|
872
|
+
wa> /audio 919634847671@s.whatsapp.net ./song.mp3
|
|
126
873
|
```
|
|
127
874
|
|
|
128
|
-
|
|
875
|
+
#### Send Voice Note
|
|
129
876
|
|
|
130
|
-
|
|
131
|
-
|---|---|
|
|
132
|
-
| Individual | `919634847671@s.whatsapp.net` |
|
|
133
|
-
| Group | `120363000000000000@g.us` |
|
|
877
|
+
Sends the file as a push-to-talk voice note with waveform:
|
|
134
878
|
|
|
135
|
-
|
|
879
|
+
```sh
|
|
880
|
+
wa> /ptt 919634847671@s.whatsapp.net ./voice.ogg
|
|
881
|
+
```
|
|
136
882
|
|
|
137
|
-
|
|
883
|
+
#### Send Document
|
|
138
884
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
885
|
+
```sh
|
|
886
|
+
wa> /doc 919634847671@s.whatsapp.net ./report.pdf
|
|
887
|
+
wa> /doc 919634847671@s.whatsapp.net ./report.pdf "Q1 Report.pdf"
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
The optional third argument overrides the displayed filename.
|
|
891
|
+
|
|
892
|
+
#### Send Sticker
|
|
893
|
+
|
|
894
|
+
The file must be in WebP format:
|
|
895
|
+
|
|
896
|
+
```sh
|
|
897
|
+
wa> /sticker 919634847671@s.whatsapp.net ./sticker.webp
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
#### React to a Message
|
|
901
|
+
|
|
902
|
+
```sh
|
|
903
|
+
wa> /react 919634847671@s.whatsapp.net 3EB0ABCDEF123456 👍
|
|
904
|
+
|
|
905
|
+
# remove a reaction — pass a space or empty string
|
|
906
|
+
wa> /react 919634847671@s.whatsapp.net 3EB0ABCDEF123456 " "
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
The message ID is shown in the incoming message display as `id`.
|
|
910
|
+
|
|
911
|
+
#### Edit a Message
|
|
912
|
+
|
|
913
|
+
> [!NOTE]
|
|
914
|
+
> Editing is only possible within 15 minutes of the original send.
|
|
915
|
+
|
|
916
|
+
```sh
|
|
917
|
+
wa> /edit 919634847671@s.whatsapp.net 3EB0ABCDEF123456 Corrected text here
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
#### Delete a Message
|
|
921
|
+
|
|
922
|
+
```sh
|
|
923
|
+
# delete for yourself only
|
|
924
|
+
wa> /delete 919634847671@s.whatsapp.net 3EB0ABCDEF123456
|
|
925
|
+
|
|
926
|
+
# delete for everyone (revoke)
|
|
927
|
+
wa> /delete 919634847671@s.whatsapp.net 3EB0ABCDEF123456 all
|
|
928
|
+
```
|
|
929
|
+
|
|
930
|
+
#### Post a Status / Story
|
|
931
|
+
|
|
932
|
+
Posts a text Status visible to your contacts:
|
|
933
|
+
|
|
934
|
+
```sh
|
|
935
|
+
wa> /status Good morning everyone!
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
#### Forward a Message
|
|
939
|
+
|
|
940
|
+
Sends a message with the forwarded flag set:
|
|
941
|
+
|
|
942
|
+
```sh
|
|
943
|
+
wa> /forward 919634847671@s.whatsapp.net This message was forwarded
|
|
944
|
+
```
|
|
149
945
|
|
|
150
946
|
---
|
|
151
947
|
|
|
152
|
-
|
|
948
|
+
### Presence Commands
|
|
153
949
|
|
|
154
|
-
|
|
155
|
-
Each phone number gets its own file: `~/.waSession/<phone>.json`.
|
|
950
|
+
#### Set Online / Offline
|
|
156
951
|
|
|
157
|
-
|
|
952
|
+
```sh
|
|
953
|
+
wa> /online
|
|
954
|
+
wa> /offline
|
|
955
|
+
```
|
|
158
956
|
|
|
159
|
-
|
|
160
|
-
|
|
957
|
+
#### Typing and Recording Indicators
|
|
958
|
+
|
|
959
|
+
```sh
|
|
960
|
+
# show "typing…" in a chat
|
|
961
|
+
wa> /typing 919634847671@s.whatsapp.net
|
|
962
|
+
|
|
963
|
+
# show "recording audio…" in a chat
|
|
964
|
+
wa> /recording 919634847671@s.whatsapp.net
|
|
965
|
+
|
|
966
|
+
# stop the indicator
|
|
967
|
+
wa> /stop 919634847671@s.whatsapp.net
|
|
161
968
|
```
|
|
162
969
|
|
|
163
|
-
|
|
970
|
+
#### Subscribe to a Contact's Presence
|
|
164
971
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
972
|
+
Subscribes to online/offline events for a contact. The shell will print presence updates as they arrive:
|
|
973
|
+
|
|
974
|
+
```sh
|
|
975
|
+
wa> /subscribe 919634847671@s.whatsapp.net
|
|
976
|
+
subscribed to 919634847671@s.whatsapp.net
|
|
977
|
+
|
|
978
|
+
# when they come online:
|
|
979
|
+
presence 919634847671@s.whatsapp.net online
|
|
168
980
|
```
|
|
169
981
|
|
|
170
982
|
---
|
|
171
983
|
|
|
172
|
-
|
|
984
|
+
### Profile Commands
|
|
173
985
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
makeJid,
|
|
180
|
-
generateMessageId
|
|
181
|
-
} = require('whalibmob');
|
|
986
|
+
#### CLI Change Display Name
|
|
987
|
+
|
|
988
|
+
```sh
|
|
989
|
+
wa> /name My Bot Name
|
|
990
|
+
name updated
|
|
182
991
|
```
|
|
183
992
|
|
|
184
|
-
|
|
993
|
+
#### CLI Change About Text
|
|
185
994
|
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
|
|
995
|
+
```sh
|
|
996
|
+
wa> /about Available 24/7 for support
|
|
997
|
+
about updated
|
|
998
|
+
```
|
|
189
999
|
|
|
190
|
-
|
|
191
|
-
const store = loadStore('919634847671', sessionDir);
|
|
1000
|
+
#### CLI Change Privacy Settings
|
|
192
1001
|
|
|
193
|
-
|
|
1002
|
+
```sh
|
|
1003
|
+
wa> /privacy last_seen contacts
|
|
1004
|
+
wa> /privacy profile_picture contacts
|
|
1005
|
+
wa> /privacy status contacts
|
|
1006
|
+
wa> /privacy online match_last_seen
|
|
1007
|
+
wa> /privacy read_receipts none
|
|
1008
|
+
wa> /privacy groups_add contacts
|
|
1009
|
+
```
|
|
194
1010
|
|
|
195
|
-
|
|
196
|
-
await client.sendText('911234567890@s.whatsapp.net', 'Hello from whalibmob!');
|
|
197
|
-
});
|
|
1011
|
+
Available types: `last_seen` · `profile_picture` · `status` · `online` · `read_receipts` · `groups_add`
|
|
198
1012
|
|
|
199
|
-
|
|
200
|
-
console.log('Received:', msg);
|
|
201
|
-
});
|
|
1013
|
+
Available values: `all` · `contacts` · `contact_blacklist` · `none` · `match_last_seen`
|
|
202
1014
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
1015
|
+
---
|
|
1016
|
+
|
|
1017
|
+
### Chat Management Commands
|
|
206
1018
|
|
|
207
|
-
|
|
1019
|
+
#### Mark Read / Unread
|
|
1020
|
+
|
|
1021
|
+
```sh
|
|
1022
|
+
wa> /read 919634847671@s.whatsapp.net
|
|
1023
|
+
wa> /unread 919634847671@s.whatsapp.net
|
|
208
1024
|
```
|
|
209
1025
|
|
|
210
|
-
|
|
1026
|
+
#### Mute / Unmute
|
|
211
1027
|
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
1028
|
+
```sh
|
|
1029
|
+
# mute for 60 minutes
|
|
1030
|
+
wa> /mute 919634847671@s.whatsapp.net 60
|
|
1031
|
+
|
|
1032
|
+
# mute indefinitely
|
|
1033
|
+
wa> /mute 919634847671@s.whatsapp.net
|
|
1034
|
+
|
|
1035
|
+
# unmute
|
|
1036
|
+
wa> /unmute 919634847671@s.whatsapp.net
|
|
219
1037
|
```
|
|
220
1038
|
|
|
221
|
-
|
|
1039
|
+
#### Pin / Unpin
|
|
222
1040
|
|
|
223
|
-
```
|
|
224
|
-
|
|
1041
|
+
```sh
|
|
1042
|
+
wa> /pin 919634847671@s.whatsapp.net
|
|
1043
|
+
wa> /unpin 919634847671@s.whatsapp.net
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
#### Archive / Unarchive
|
|
225
1047
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
1048
|
+
```sh
|
|
1049
|
+
wa> /archive 919634847671@s.whatsapp.net
|
|
1050
|
+
wa> /unarchive 919634847671@s.whatsapp.net
|
|
229
1051
|
```
|
|
230
1052
|
|
|
231
|
-
|
|
1053
|
+
#### Star / Unstar a Message (CLI)
|
|
232
1054
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
|
1055
|
+
```sh
|
|
1056
|
+
wa> /star 919634847671@s.whatsapp.net 3EB0ABCDEF123456
|
|
1057
|
+
wa> /unstar 919634847671@s.whatsapp.net 3EB0ABCDEF123456
|
|
1058
|
+
```
|
|
1059
|
+
|
|
1060
|
+
#### CLI Disappearing Messages
|
|
1061
|
+
|
|
1062
|
+
| Duration | Seconds |
|
|
1063
|
+
|---|---|
|
|
1064
|
+
| Off | 0 |
|
|
1065
|
+
| 24 hours | 86400 |
|
|
1066
|
+
| 7 days | 604800 |
|
|
1067
|
+
| 90 days | 7776000 |
|
|
1068
|
+
|
|
1069
|
+
```sh
|
|
1070
|
+
# set 1-day timer on a DM
|
|
1071
|
+
wa> /ephemeral 919634847671@s.whatsapp.net 86400
|
|
1072
|
+
|
|
1073
|
+
# set 1-week timer on a group
|
|
1074
|
+
wa> /ephemeral 120363000000000000@g.us 604800
|
|
1075
|
+
|
|
1076
|
+
# turn off
|
|
1077
|
+
wa> /ephemeral 919634847671@s.whatsapp.net 0
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
#### Block / Unblock
|
|
1081
|
+
|
|
1082
|
+
```sh
|
|
1083
|
+
wa> /block 919634847671@s.whatsapp.net
|
|
1084
|
+
blocked 919634847671@s.whatsapp.net
|
|
1085
|
+
|
|
1086
|
+
wa> /unblock 919634847671@s.whatsapp.net
|
|
1087
|
+
unblocked 919634847671@s.whatsapp.net
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
#### Show Block List
|
|
1091
|
+
|
|
1092
|
+
```sh
|
|
1093
|
+
wa> /blocklist
|
|
1094
|
+
blocked (2)
|
|
1095
|
+
919634847671@s.whatsapp.net
|
|
1096
|
+
12345678901@s.whatsapp.net
|
|
1097
|
+
```
|
|
241
1098
|
|
|
242
1099
|
---
|
|
243
1100
|
|
|
244
|
-
|
|
1101
|
+
### Group Commands
|
|
1102
|
+
|
|
1103
|
+
#### CLI Create a Group
|
|
1104
|
+
|
|
1105
|
+
```sh
|
|
1106
|
+
wa> /group create MyGroup 919634847671@s.whatsapp.net 12345678901@s.whatsapp.net
|
|
1107
|
+
creating group...
|
|
1108
|
+
created
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
#### CLI Leave a Group
|
|
1112
|
+
|
|
1113
|
+
```sh
|
|
1114
|
+
wa> /group leave 120363000000000000@g.us
|
|
1115
|
+
left 120363000000000000@g.us
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
#### Add / Remove Participants
|
|
1119
|
+
|
|
1120
|
+
```sh
|
|
1121
|
+
# add participants
|
|
1122
|
+
wa> /group add 120363000000000000@g.us 919634847671@s.whatsapp.net
|
|
245
1123
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
1124
|
+
# remove participants
|
|
1125
|
+
wa> /group remove 120363000000000000@g.us 919634847671@s.whatsapp.net
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
Multiple participants can be listed, separated by spaces.
|
|
1129
|
+
|
|
1130
|
+
#### Promote / Demote Admins
|
|
1131
|
+
|
|
1132
|
+
```sh
|
|
1133
|
+
# promote to admin
|
|
1134
|
+
wa> /group promote 120363000000000000@g.us 919634847671@s.whatsapp.net
|
|
1135
|
+
|
|
1136
|
+
# demote from admin
|
|
1137
|
+
wa> /group demote 120363000000000000@g.us 919634847671@s.whatsapp.net
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
#### Change Group Name
|
|
1141
|
+
|
|
1142
|
+
```sh
|
|
1143
|
+
wa> /group subject 120363000000000000@g.us New Group Name
|
|
1144
|
+
subject updated
|
|
1145
|
+
```
|
|
1146
|
+
|
|
1147
|
+
#### Change Group Description
|
|
1148
|
+
|
|
1149
|
+
```sh
|
|
1150
|
+
wa> /group desc 120363000000000000@g.us This is the group for project updates
|
|
1151
|
+
description updated
|
|
1152
|
+
```
|
|
1153
|
+
|
|
1154
|
+
#### Get Invite Link
|
|
1155
|
+
|
|
1156
|
+
```sh
|
|
1157
|
+
wa> /group invite 120363000000000000@g.us
|
|
1158
|
+
https://chat.whatsapp.com/AbCdEfGhIjKlMnOpQrStUv
|
|
1159
|
+
```
|
|
1160
|
+
|
|
1161
|
+
#### Revoke Invite Link
|
|
1162
|
+
|
|
1163
|
+
Invalidates the current invite link and generates a new one:
|
|
1164
|
+
|
|
1165
|
+
```sh
|
|
1166
|
+
wa> /group revoke 120363000000000000@g.us
|
|
1167
|
+
invite link revoked
|
|
1168
|
+
```
|
|
1169
|
+
|
|
1170
|
+
#### Join a Group by Invite Code
|
|
1171
|
+
|
|
1172
|
+
Pass only the code part — do not include `https://chat.whatsapp.com/`:
|
|
1173
|
+
|
|
1174
|
+
```sh
|
|
1175
|
+
wa> /group join AbCdEfGhIjKlMnOpQrStUv
|
|
1176
|
+
joined 120363000000000000@g.us
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
#### Query Group Metadata
|
|
1180
|
+
|
|
1181
|
+
```sh
|
|
1182
|
+
wa> /group meta 120363000000000000@g.us
|
|
1183
|
+
{
|
|
1184
|
+
"id": "120363000000000000@g.us",
|
|
1185
|
+
"subject": "My Group",
|
|
1186
|
+
"desc": "Group description",
|
|
1187
|
+
...
|
|
1188
|
+
}
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
#### Group Settings
|
|
1192
|
+
|
|
1193
|
+
Controls who can send messages, edit group info, add participants, or requires approval to join:
|
|
1194
|
+
|
|
1195
|
+
```sh
|
|
1196
|
+
# only admins can send messages
|
|
1197
|
+
wa> /group settings 120363000000000000@g.us send_messages admins
|
|
1198
|
+
|
|
1199
|
+
# everyone can send messages
|
|
1200
|
+
wa> /group settings 120363000000000000@g.us send_messages all
|
|
1201
|
+
|
|
1202
|
+
# only admins can edit group info
|
|
1203
|
+
wa> /group settings 120363000000000000@g.us edit_group_info admins
|
|
1204
|
+
|
|
1205
|
+
# only admins can add participants
|
|
1206
|
+
wa> /group settings 120363000000000000@g.us add_participants admins
|
|
1207
|
+
|
|
1208
|
+
# require admin approval for join requests
|
|
1209
|
+
wa> /group settings 120363000000000000@g.us approve_participants admins
|
|
1210
|
+
```
|
|
257
1211
|
|
|
258
1212
|
---
|
|
259
1213
|
|
|
260
|
-
|
|
1214
|
+
### Registration Commands (in-shell)
|
|
261
1215
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
1216
|
+
These commands work from within the shell — useful when you need to register a second number without closing the current session:
|
|
1217
|
+
|
|
1218
|
+
```sh
|
|
1219
|
+
# check if a phone number has WhatsApp
|
|
1220
|
+
wa> /reg check 919634847671
|
|
1221
|
+
|
|
1222
|
+
# request a verification code
|
|
1223
|
+
wa> /reg code 919634847671
|
|
1224
|
+
wa> /reg code 919634847671 voice
|
|
1225
|
+
wa> /reg code 919634847671 wa_old
|
|
1226
|
+
|
|
1227
|
+
# confirm the code received
|
|
1228
|
+
wa> /reg confirm 919634847671 123456
|
|
1229
|
+
registered session saved to /home/user/.waSession/919634847671.json
|
|
1230
|
+
now run: /connect 919634847671
|
|
1231
|
+
```
|
|
270
1232
|
|
|
271
1233
|
---
|
|
272
1234
|
|
|
273
|
-
|
|
1235
|
+
### Connection Commands (in-shell)
|
|
1236
|
+
|
|
1237
|
+
```sh
|
|
1238
|
+
# connect to a number (while already in the shell)
|
|
1239
|
+
wa> /connect 919634847671
|
|
1240
|
+
|
|
1241
|
+
# disconnect
|
|
1242
|
+
wa> /disconnect
|
|
1243
|
+
|
|
1244
|
+
# force a reconnection
|
|
1245
|
+
wa> /reconnect
|
|
274
1246
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
1247
|
+
# show current session info
|
|
1248
|
+
wa> /session
|
|
1249
|
+
phone 919634847671
|
|
1250
|
+
name My Bot
|
|
1251
|
+
session /home/user/.waSession
|
|
1252
|
+
|
|
1253
|
+
# show all available commands
|
|
1254
|
+
wa> /help
|
|
1255
|
+
|
|
1256
|
+
# disconnect and exit the shell
|
|
1257
|
+
wa> /quit
|
|
1258
|
+
```
|
|
281
1259
|
|
|
282
1260
|
---
|
|
283
1261
|
|
|
1262
|
+
### Full Command Reference Table
|
|
1263
|
+
|
|
1264
|
+
| Command | Description |
|
|
1265
|
+
|---|---|
|
|
1266
|
+
| `/send <jid> <text>` | Send a text message |
|
|
1267
|
+
| `/image <jid> <file> [caption]` | Send an image |
|
|
1268
|
+
| `/video <jid> <file> [caption]` | Send a video |
|
|
1269
|
+
| `/audio <jid> <file>` | Send an audio file |
|
|
1270
|
+
| `/ptt <jid> <file>` | Send a voice note (push-to-talk) |
|
|
1271
|
+
| `/doc <jid> <file> [name]` | Send a document |
|
|
1272
|
+
| `/sticker <jid> <file>` | Send a sticker (.webp) |
|
|
1273
|
+
| `/react <jid> <msgId> <emoji>` | React to a message |
|
|
1274
|
+
| `/edit <jid> <msgId> <text>` | Edit a sent message |
|
|
1275
|
+
| `/delete <jid> <msgId> [all]` | Delete a message (add `all` for everyone) |
|
|
1276
|
+
| `/status <text>` | Post a Status / Story |
|
|
1277
|
+
| `/forward <jid> <text>` | Send with forwarded flag |
|
|
1278
|
+
| `/online` | Set yourself as online |
|
|
1279
|
+
| `/offline` | Set yourself as offline |
|
|
1280
|
+
| `/typing <jid>` | Show typing indicator in a chat |
|
|
1281
|
+
| `/recording <jid>` | Show recording audio indicator |
|
|
1282
|
+
| `/stop <jid>` | Stop typing / recording |
|
|
1283
|
+
| `/subscribe <jid>` | Subscribe to a contact's presence |
|
|
1284
|
+
| `/name <text>` | Change your display name |
|
|
1285
|
+
| `/about <text>` | Change your bio / about text |
|
|
1286
|
+
| `/privacy <type> <value>` | Change a privacy setting |
|
|
1287
|
+
| `/read <jid>` | Mark chat as read |
|
|
1288
|
+
| `/unread <jid>` | Mark chat as unread |
|
|
1289
|
+
| `/mute <jid> [minutes]` | Mute a chat |
|
|
1290
|
+
| `/unmute <jid>` | Unmute a chat |
|
|
1291
|
+
| `/pin <jid>` | Pin a chat |
|
|
1292
|
+
| `/unpin <jid>` | Unpin a chat |
|
|
1293
|
+
| `/archive <jid>` | Archive a chat |
|
|
1294
|
+
| `/unarchive <jid>` | Unarchive a chat |
|
|
1295
|
+
| `/star <jid> <msgId>` | Star a message |
|
|
1296
|
+
| `/unstar <jid> <msgId>` | Unstar a message |
|
|
1297
|
+
| `/ephemeral <jid> <seconds>` | Set disappearing messages timer |
|
|
1298
|
+
| `/block <jid>` | Block a contact |
|
|
1299
|
+
| `/unblock <jid>` | Unblock a contact |
|
|
1300
|
+
| `/blocklist` | Show all blocked contacts |
|
|
1301
|
+
| `/group create <name> <jid...>` | Create a group |
|
|
1302
|
+
| `/group leave <jid>` | Leave a group |
|
|
1303
|
+
| `/group add <jid> <member...>` | Add participants |
|
|
1304
|
+
| `/group remove <jid> <member...>` | Remove participants |
|
|
1305
|
+
| `/group promote <jid> <member...>` | Promote to admin |
|
|
1306
|
+
| `/group demote <jid> <member...>` | Demote from admin |
|
|
1307
|
+
| `/group subject <jid> <name>` | Rename group |
|
|
1308
|
+
| `/group desc <jid> <text>` | Change group description |
|
|
1309
|
+
| `/group invite <jid>` | Get invite link |
|
|
1310
|
+
| `/group revoke <jid>` | Revoke invite link |
|
|
1311
|
+
| `/group join <code>` | Join group by invite code |
|
|
1312
|
+
| `/group meta <jid>` | Query group metadata |
|
|
1313
|
+
| `/group settings <jid> <setting> <policy>` | Change group setting |
|
|
1314
|
+
| `/reg check <phone>` | Check if number has WhatsApp |
|
|
1315
|
+
| `/reg code <phone> [method]` | Request verification code |
|
|
1316
|
+
| `/reg confirm <phone> <code>` | Complete registration |
|
|
1317
|
+
| `/connect <phone>` | Connect to WhatsApp |
|
|
1318
|
+
| `/disconnect` | Disconnect current session |
|
|
1319
|
+
| `/reconnect` | Force reconnection |
|
|
1320
|
+
| `/session` | Show session info |
|
|
1321
|
+
| `/help` | Show all commands |
|
|
1322
|
+
| `/quit` | Disconnect and exit |
|
|
1323
|
+
|
|
1324
|
+
---
|
|
1325
|
+
|
|
1326
|
+
## WhatsApp IDs
|
|
1327
|
+
|
|
1328
|
+
- Individual contacts: `[countrycode][number]@s.whatsapp.net`
|
|
1329
|
+
- Example: `919634847671@s.whatsapp.net`
|
|
1330
|
+
- Groups: `[groupid]@g.us`
|
|
1331
|
+
- Example: `120363000000000000@g.us`
|
|
1332
|
+
- Status broadcast: `status@broadcast`
|
|
1333
|
+
- Broadcast lists: `[timestamp]@broadcast`
|
|
1334
|
+
|
|
1335
|
+
> [!NOTE]
|
|
1336
|
+
> Phone numbers must include the country code without the `+` prefix.
|
|
1337
|
+
|
|
284
1338
|
## Transport
|
|
285
1339
|
|
|
286
|
-
|
|
1340
|
+
whalibmob uses **Noise_XX_25519_AESGCM_SHA256** over TCP to `g.whatsapp.net:443`:
|
|
287
1341
|
|
|
288
1342
|
1. Client sends `ClientHello` with an ephemeral X25519 public key.
|
|
289
1343
|
2. Server replies `ServerHello` (ephemeral + encrypted static + payload).
|
|
290
1344
|
3. Three DH steps (EE, SE, SS) derive the final session keys.
|
|
291
1345
|
4. Client sends `ClientFinish` (encrypted static + encrypted payload).
|
|
292
|
-
5.
|
|
1346
|
+
5. The library waits for a `<success>` stanza before emitting `connected`, or `<failure>` for `auth_failure`.
|
|
293
1347
|
|
|
294
|
-
|
|
1348
|
+
Automatic reconnection uses exponential backoff:
|
|
1349
|
+
|
|
1350
|
+
| Attempt | Delay |
|
|
1351
|
+
|---|---|
|
|
1352
|
+
| 1 | 1 s |
|
|
1353
|
+
| 2 | 2 s |
|
|
1354
|
+
| 3 | 4 s |
|
|
1355
|
+
| 4 | 8 s |
|
|
1356
|
+
| 5 | 15 s |
|
|
1357
|
+
| 6+ | 30 s |
|
|
1358
|
+
|
|
1359
|
+
## Media Encryption
|
|
1360
|
+
|
|
1361
|
+
1. A random 32-byte **media key** is generated.
|
|
1362
|
+
2. HKDF-SHA256 expands it into IV, cipher key, and MAC key.
|
|
1363
|
+
3. The file is encrypted with **AES-256-CBC**.
|
|
1364
|
+
4. A 10-byte **HMAC-SHA256** MAC is appended.
|
|
1365
|
+
5. The ciphertext is uploaded to the WhatsApp CDN.
|
|
1366
|
+
6. The media key and CDN URL are embedded in the encrypted message envelope sent to the recipient.
|
|
295
1367
|
|
|
296
1368
|
## License
|
|
297
1369
|
|