@sgintokic/baileys 0.0.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.

Potentially problematic release.


This version of @sgintokic/baileys might be problematic. Click here for more details.

Files changed (106) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +1097 -0
  3. package/WAProto/index.js +2 -0
  4. package/engine-requirements.js +1 -0
  5. package/lib/Defaults/index.js +155 -0
  6. package/lib/Signal/Group/ciphertext-message.js +11 -0
  7. package/lib/Signal/Group/group-session-builder.js +41 -0
  8. package/lib/Signal/Group/group_cipher.js +108 -0
  9. package/lib/Signal/Group/index.js +11 -0
  10. package/lib/Signal/Group/keyhelper.js +14 -0
  11. package/lib/Signal/Group/sender-chain-key.js +31 -0
  12. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  13. package/lib/Signal/Group/sender-key-message.js +79 -0
  14. package/lib/Signal/Group/sender-key-name.js +49 -0
  15. package/lib/Signal/Group/sender-key-record.js +46 -0
  16. package/lib/Signal/Group/sender-key-state.js +104 -0
  17. package/lib/Signal/Group/sender-message-key.js +29 -0
  18. package/lib/Signal/libsignal.js +485 -0
  19. package/lib/Signal/lid-mapping.js +291 -0
  20. package/lib/Socket/Client/index.js +2 -0
  21. package/lib/Socket/Client/types.js +10 -0
  22. package/lib/Socket/Client/websocket.js +64 -0
  23. package/lib/Socket/business.js +293 -0
  24. package/lib/Socket/chats.js +1068 -0
  25. package/lib/Socket/communities.js +476 -0
  26. package/lib/Socket/groups.js +383 -0
  27. package/lib/Socket/index.js +8 -0
  28. package/lib/Socket/messages-recv.js +1830 -0
  29. package/lib/Socket/messages-send.js +1462 -0
  30. package/lib/Socket/mex.js +55 -0
  31. package/lib/Socket/newsletter.js +277 -0
  32. package/lib/Socket/socket.js +1087 -0
  33. package/lib/Store/index.js +3 -0
  34. package/lib/Store/make-in-memory-store.js +517 -0
  35. package/lib/Store/make-ordered-dictionary.js +75 -0
  36. package/lib/Store/object-repository.js +23 -0
  37. package/lib/Types/Auth.js +1 -0
  38. package/lib/Types/Bussines.js +1 -0
  39. package/lib/Types/Call.js +1 -0
  40. package/lib/Types/Chat.js +7 -0
  41. package/lib/Types/Contact.js +1 -0
  42. package/lib/Types/Events.js +1 -0
  43. package/lib/Types/GroupMetadata.js +1 -0
  44. package/lib/Types/Label.js +24 -0
  45. package/lib/Types/LabelAssociation.js +6 -0
  46. package/lib/Types/Message.js +18 -0
  47. package/lib/Types/Newsletter.js +33 -0
  48. package/lib/Types/Product.js +1 -0
  49. package/lib/Types/Signal.js +1 -0
  50. package/lib/Types/Socket.js +2 -0
  51. package/lib/Types/State.js +15 -0
  52. package/lib/Types/USync.js +1 -0
  53. package/lib/Types/index.js +31 -0
  54. package/lib/Utils/auth-utils.js +293 -0
  55. package/lib/Utils/browser-utils.js +32 -0
  56. package/lib/Utils/business.js +245 -0
  57. package/lib/Utils/chat-utils.js +959 -0
  58. package/lib/Utils/crypto.js +133 -0
  59. package/lib/Utils/decode-wa-message.js +376 -0
  60. package/lib/Utils/event-buffer.js +620 -0
  61. package/lib/Utils/generics.js +417 -0
  62. package/lib/Utils/history.js +150 -0
  63. package/lib/Utils/identity-change-handler.js +63 -0
  64. package/lib/Utils/index.js +21 -0
  65. package/lib/Utils/link-preview.js +91 -0
  66. package/lib/Utils/logger.js +2 -0
  67. package/lib/Utils/lt-hash.js +6 -0
  68. package/lib/Utils/make-mutex.js +31 -0
  69. package/lib/Utils/message-retry-manager.js +240 -0
  70. package/lib/Utils/messages-media.js +901 -0
  71. package/lib/Utils/messages.js +2052 -0
  72. package/lib/Utils/noise-handler.js +229 -0
  73. package/lib/Utils/offline-node-processor.js +50 -0
  74. package/lib/Utils/pre-key-manager.js +119 -0
  75. package/lib/Utils/process-message.js +641 -0
  76. package/lib/Utils/reporting-utils.js +346 -0
  77. package/lib/Utils/signal.js +188 -0
  78. package/lib/Utils/stanza-ack.js +33 -0
  79. package/lib/Utils/sync-action-utils.js +53 -0
  80. package/lib/Utils/tc-token-utils.js +15 -0
  81. package/lib/Utils/use-multi-file-auth-state.js +116 -0
  82. package/lib/Utils/use-single-file-auth-state.js +94 -0
  83. package/lib/Utils/validate-connection.js +235 -0
  84. package/lib/WABinary/constants.js +1300 -0
  85. package/lib/WABinary/decode.js +258 -0
  86. package/lib/WABinary/encode.js +219 -0
  87. package/lib/WABinary/generic-utils.js +203 -0
  88. package/lib/WABinary/index.js +5 -0
  89. package/lib/WABinary/jid-utils.js +93 -0
  90. package/lib/WABinary/types.js +1 -0
  91. package/lib/WAM/BinaryInfo.js +9 -0
  92. package/lib/WAM/constants.js +20669 -0
  93. package/lib/WAM/encode.js +151 -0
  94. package/lib/WAM/index.js +3 -0
  95. package/lib/WAUSync/Protocols/USyncContactProtocol.js +21 -0
  96. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +50 -0
  97. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -0
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +29 -0
  99. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +59 -0
  100. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +21 -0
  101. package/lib/WAUSync/Protocols/index.js +4 -0
  102. package/lib/WAUSync/USyncQuery.js +103 -0
  103. package/lib/WAUSync/USyncUser.js +22 -0
  104. package/lib/WAUSync/index.js +3 -0
  105. package/lib/index.js +11 -0
  106. package/package.json +58 -0
package/README.md ADDED
@@ -0,0 +1,1097 @@
1
+ # 🌱 @itsliaaa/baileys
2
+
3
+ ![Logo](https://files.catbox.moe/c5s9g0.jpg)
4
+
5
+ A lightweight fork of Baileys with a few fixes and a small adjustment.
6
+
7
+ ### ⚙️ Changes
8
+
9
+ #### 🛠️ Internal Adjustments
10
+ - 🖼️ Fixed an issue where media could not be sent to newsletters due to an upstream issue.
11
+ - 📁 Reintroduced [`makeInMemoryStore`](#%EF%B8%8F-implementing-a-data-store) with a minimal ESM adaptation and small adjustments for Baileys v7.
12
+ - 📦 Switched FFmpeg execution from `exec` to `spawn` for safer process handling.
13
+ - 🗃️ Added `@napi-rs/image` as a supported image processing backend in `getImageProcessingLibrary()`, offering a balance between performance and compatibility.
14
+
15
+ #### 📨 Message Handling & Compatibility
16
+ - 👉🏻 Added support for sending [interactive message](#-sending-interactive-messages) types (button, list, interactive, template, carousel).
17
+ - 📩 Added support for [album messages](#%EF%B8%8F-album-image--video), [group status messages](#4%EF%B8%8F⃣-group-status), [status mention messages](#%EF%B8%8F-status-mention), [sticker pack messages](#-sticker-pack), and several [payment-related messages](#-sending-payment-messages) (request payment, payment invite, order, invoice).
18
+ - 📰 Simplified sending messages with ad thumbnails via [`externalAdReply`](#3%EF%B8%8F⃣-external-ad-reply) without requiring manual `contextInfo`.
19
+
20
+ #### 🧩 Additional Message Options
21
+ - 👁️ Added optional boolean flags for message handling:
22
+ - [`ai`](#1%EF%B8%8F⃣-ai-label) - AI label on message
23
+ - [`mentionAll`](#-mention) - Mentions all group participants without requiring their JIDs in `mentions` or `mentionedJid`
24
+ - [`ephemeral`](#2%EF%B8%8F⃣-ephemeral), [`groupStatus`](#4%EF%B8%8F⃣-group-status), [`viewOnceV2`](#8%EF%B8%8F⃣-view-once-v2), [`viewOnceV2Extension`](#9%EF%B8%8F⃣-view-once-v2-extension), [`interactiveAsTemplate`](#3%EF%B8%8F⃣-interactive) - Message wrappers
25
+ - [`secureMetaServiceLabel`](#6%EF%B8%8F⃣-secure-meta-service-label) - Secure meta service label on message
26
+ - [`raw`](#5%EF%B8%8F⃣-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
27
+
28
+ > [!NOTE]
29
+ 📄 This project is maintained with limited scope and is not intended to replace upstream Baileys.
30
+ >
31
+ > 😞 And, really sorry for my bad english.
32
+
33
+ ### 📥 Installation
34
+
35
+ - 📄 Via `package.json`
36
+
37
+ ```json
38
+ # NPM
39
+ "dependencies": {
40
+ "@itsliaaa/baileys": "latest"
41
+ }
42
+
43
+ # GitHub
44
+ "dependencies": {
45
+ "@itsliaaa/baileys": "github:itsliaaa/baileys"
46
+ }
47
+ ```
48
+
49
+ - ⌨️ Via terminal
50
+
51
+ ```bash
52
+ # NPM
53
+ npm i @itsliaaa/baileys@latest
54
+
55
+ # GitHub
56
+ npm i github:itsliaaa/baileys
57
+ ```
58
+
59
+ #### 🧩 Import (ESM & CJS)
60
+
61
+ ```javascript
62
+ // --- ESM
63
+ import { makeWASocket } from '@itsliaaa/baileys'
64
+
65
+ // --- CJS (tested and working on Node.js 24 ✅)
66
+ const { makeWASocket } = require('@itsliaaa/baileys')
67
+ ```
68
+
69
+ ### 🔧 Usage
70
+
71
+ #### 🌐 Connect to WhatsApp (Quick Step)
72
+
73
+ ```javascript
74
+ import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@itsliaaa/baileys'
75
+ import { Boom } from '@hapi/boom'
76
+ import pino from 'pino'
77
+
78
+ // --- Connect with pairing code
79
+ const myPhoneNumber = '6288888888888'
80
+
81
+ const logger = pino({ level: 'silent' })
82
+
83
+ const connectToWhatsApp = async () => {
84
+ const { state, saveCreds } = await useMultiFileAuthState('session')
85
+
86
+ const sock = makeWASocket({
87
+ logger,
88
+ auth: state
89
+ })
90
+
91
+ sock.ev.on('creds.update', saveCreds)
92
+
93
+ sock.ev.on('connection.update', (update) => {
94
+ const { connection, lastDisconnect } = update
95
+ if (connection === 'connecting' && !sock.authState.creds.registered) {
96
+ await delay(1500)
97
+ const code = await sock.requestPairingCode(myPhoneNumber)
98
+ console.log('🔗 Pairing code', ':', code)
99
+ }
100
+ else if (connection === 'close') {
101
+ const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
102
+ console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
103
+ if (shouldReconnect) {
104
+ connectToWhatsApp()
105
+ }
106
+ }
107
+ else if (connection === 'open') {
108
+ console.log('✅ Successfully connected to WhatsApp')
109
+ }
110
+ })
111
+
112
+ sock.ev.on('messages.upsert', async ({ messages }) => {
113
+ for (const message of messages) {
114
+ if (!message.message) continue
115
+
116
+ console.log('🔔 Got new message', ':', message)
117
+ await sock.sendMessage(message.key.remoteJid, {
118
+ text: '👋🏻 Hello world'
119
+ })
120
+ }
121
+ })
122
+ }
123
+
124
+ connectToWhatsApp()
125
+ ```
126
+
127
+ #### 🗄️ Implementing a Data Store
128
+
129
+ > [!CAUTION]
130
+ I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
131
+
132
+ ```javascript
133
+ import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from '@itsliaaa/baileys'
134
+ import { Boom } from '@hapi/boom'
135
+ import pino from 'pino'
136
+
137
+ const myPhoneNumber = '6288888888888'
138
+
139
+ // --- Create your store path
140
+ const storePath = './store.json'
141
+
142
+ const logger = pino({ level: 'silent' })
143
+
144
+ const connectToWhatsApp = async () => {
145
+ const { state, saveCreds } = await useMultiFileAuthState('session')
146
+
147
+ const sock = makeWASocket({
148
+ logger,
149
+ auth: state
150
+ })
151
+
152
+ const store = makeInMemoryStore({
153
+ logger,
154
+ socket: sock
155
+ })
156
+
157
+ store.bind(sock.ev)
158
+
159
+ sock.ev.on('creds.update', saveCreds)
160
+
161
+ sock.ev.on('connection.update', (update) => {
162
+ const { connection, lastDisconnect } = update
163
+ if (connection === 'connecting' && !sock.authState.creds.registered) {
164
+ await delay(1500)
165
+ const code = await sock.requestPairingCode(myPhoneNumber)
166
+ console.log('🔗 Pairing code', ':', code)
167
+ }
168
+ else if (connection === 'close') {
169
+ const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
170
+ console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
171
+ if (shouldReconnect) {
172
+ connectToWhatsApp()
173
+ }
174
+ }
175
+ else if (connection === 'open') {
176
+ console.log('✅ Successfully connected to WhatsApp')
177
+ }
178
+ })
179
+
180
+ sock.ev.on('chats.upsert', () => {
181
+ console.log('✉️ Got chats', store.chats.all())
182
+ })
183
+
184
+ sock.ev.on('contacts.upsert', () => {
185
+ console.log('👥 Got contacts', Object.values(store.contacts))
186
+ })
187
+
188
+ // --- Read store from file
189
+ store.readFromFile(storePath)
190
+
191
+ // --- Save store every 3 minutes
192
+ setInterval(() => {
193
+ store.writeToFile(storePath)
194
+ }, 180000)
195
+ }
196
+
197
+ connectToWhatsApp()
198
+ ```
199
+
200
+ #### 🪪 WhatsApp IDs Explain
201
+
202
+ `id` is the WhatsApp ID, called `jid` and `lid` too, of the person or group you're sending the message to.
203
+ - It must be in the format `[country code][phone number]@s.whatsapp.net`
204
+ - Example for people: `19999999999@s.whatsapp.net` and `12699999999@lid`.
205
+ - For groups, it must be in the format `123456789-123345@g.us`.
206
+ - For Meta AI, it's `11111111111@bot`.
207
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
208
+ - For stories, the ID is `status@broadcast`.
209
+
210
+ #### ✉️ Sending Messages
211
+
212
+ > [!NOTE]
213
+ You can get the `jid` from `message.key.remoteJid` in the first example.
214
+
215
+ ##### 🔠 Text
216
+
217
+ ```javascript
218
+ sock.sendMessage(jid, {
219
+ text: '👋🏻 Hello'
220
+ }, {
221
+ quoted: message
222
+ })
223
+ ```
224
+
225
+ ##### 🔔 Mention
226
+
227
+ ```javascript
228
+ // --- Regular mention
229
+ sock.sendMessage(jid, {
230
+ text: '👋🏻 Hello @628123456789',
231
+ mentions: ['628123456789@s.whatsapp.net']
232
+ }, {
233
+ quoted: message
234
+ })
235
+
236
+ // --- Mention all
237
+ sock.sendMessage(jid, {
238
+ text: '👋🏻 Hello @all',
239
+ mentionAll: true
240
+ }, {
241
+ quoted: message
242
+ })
243
+ ```
244
+
245
+ ##### 😁 Reaction
246
+
247
+ ```javascript
248
+ sock.sendMessage(jid, {
249
+ react: {
250
+ key: message.key,
251
+ text: '✨'
252
+ }
253
+ }, {
254
+ quoted: message
255
+ })
256
+ ```
257
+
258
+ ##### 📌 Pin Message
259
+
260
+ ```javascript
261
+ sock.sendMessage(jid, {
262
+ pin: message.key,
263
+ time: 86400, // --- Set the value in seconds: 86400 (1d), 604800 (7d), or 2592000 (30d)
264
+ type: 1 // --- Or 0 to remove
265
+ }, {
266
+ quoted: message
267
+ })
268
+ ```
269
+
270
+ ##### 👤 Contact
271
+
272
+ ```javascript
273
+ const vcard = 'BEGIN:VCARD\n'
274
+ + 'VERSION:3.0\n'
275
+ + 'FN:Lia Wynn\n'
276
+ + 'ORG:Waitress;\n'
277
+ + 'TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n'
278
+ + 'END:VCARD'
279
+
280
+ sock.sendMessage(jid, {
281
+ contacts: {
282
+ displayName: 'Lia',
283
+ contacts: [
284
+ { vcard }
285
+ ]
286
+ }
287
+ }, {
288
+ quoted: message
289
+ })
290
+ ```
291
+
292
+ ##### 📍 Location
293
+
294
+ ```javascript
295
+ sock.sendMessage(jid, {
296
+ location: {
297
+ degreesLatitude: 24.121231,
298
+ degreesLongitude: 55.1121221,
299
+ name: '👋🏻 I am here'
300
+ }
301
+ }, {
302
+ quoted: message
303
+ })
304
+ ```
305
+
306
+ ##### 📊 Poll
307
+
308
+ ```javascript
309
+ // --- Regular poll message
310
+ sock.sendMessage(jid, {
311
+ poll: {
312
+ name: '🔥 Voting time',
313
+ values: ['Yes', 'No'],
314
+ selectableCount: 1,
315
+ toAnnouncementGroup: false
316
+ }
317
+ }, {
318
+ quoted: message
319
+ })
320
+
321
+ // --- Quiz (only for newsletter)
322
+ sock.sendMessage('1211111111111@newsletter', {
323
+ poll: {
324
+ name: '🔥 Quiz',
325
+ values: ['Yes', 'No'],
326
+ correctAnswer: 'Yes',
327
+ pollType: 1
328
+ }
329
+ }, {
330
+ quoted: message
331
+ })
332
+
333
+ // --- Poll result
334
+ sock.sendMessage(jid, {
335
+ pollResult: {
336
+ name: '📝 Poll Result',
337
+ votes: [{
338
+ name: 'Nice',
339
+ voteCount: 10
340
+ }, {
341
+ name: 'Nah',
342
+ voteCount: 2
343
+ }],
344
+ pollType: 0 // Or 1 for quiz
345
+ }
346
+ }, {
347
+ quoted: message
348
+ })
349
+
350
+ // --- Poll update
351
+ sock.sendMessage(jid, {
352
+ pollUpdate: {
353
+ metadata: {},
354
+ key: message.key,
355
+ vote: {
356
+ enclv: /* <Buffer> */,
357
+ encPayload: /* <Buffer> */
358
+ }
359
+ }
360
+ }, {
361
+ quoted: message
362
+ })
363
+ ```
364
+
365
+ ##### 🎞️ Status Mention
366
+
367
+ ```javascript
368
+ sock.sendMessage([jidA, jidB, jidC], {
369
+ text: 'Hello! 👋🏻'
370
+ })
371
+ ```
372
+
373
+ #### 📁 Sending Media Messages
374
+
375
+ > [!NOTE]
376
+ For media messages, you can pass a `Buffer` directly, or an object with either `{ stream: Readable }` or `{ url: string }` (local file path or HTTP/HTTPS URL).
377
+
378
+ ##### 🖼️ Image
379
+
380
+ ```javascript
381
+ sock.sendMessage(jid, {
382
+ image: {
383
+ url: './path/to/image.jpg'
384
+ },
385
+ caption: '🔥 Superb'
386
+ }, {
387
+ quoted: message
388
+ })
389
+ ```
390
+
391
+ ##### 🎥 Video
392
+
393
+ ```javascript
394
+ sock.sendMessage(jid, {
395
+ video: {
396
+ url: './path/to/video.mp4'
397
+ },
398
+ gifPlayback: false, // --- Set true if you want to send video as GIF
399
+ ptv: false, // --- Set true if you want to send video as PTV
400
+ caption: '🔥 Superb'
401
+ }, {
402
+ quoted: message
403
+ })
404
+ ```
405
+
406
+ ##### 📃 Sticker
407
+
408
+ ```javascript
409
+ sock.sendMessage(jid, {
410
+ sticker: {
411
+ url: './path/to/sticker.webp'
412
+ }
413
+ }, {
414
+ quoted: message
415
+ })
416
+ ```
417
+
418
+ ##### 💽 Audio
419
+
420
+ ```javascript
421
+ sock.sendMessage(jid, {
422
+ audio: {
423
+ url: './path/to/audio.mp3'
424
+ },
425
+ ptt: false, // --- Set true if you want to send audio as Voice Note
426
+ }, {
427
+ quoted: message
428
+ })
429
+ ```
430
+
431
+ ##### 🖼️ Album (Image & Video)
432
+
433
+ ```javascript
434
+ sock.sendMessage(jid, {
435
+ album: [{
436
+ image: {
437
+ url: './path/to/image.jpg'
438
+ },
439
+ caption: '1st image'
440
+ }, {
441
+ video: {
442
+ url: './path/to/video.mp4'
443
+ },
444
+ caption: '1st video'
445
+ }, {
446
+ image: {
447
+ url: './path/to/image.jpg'
448
+ },
449
+ caption: '2nd image'
450
+ }, {
451
+ video: {
452
+ url: './path/to/video.mp4'
453
+ },
454
+ caption: '2nd video'
455
+ }]
456
+ }, {
457
+ quoted: message
458
+ })
459
+ ```
460
+
461
+ ##### 📦 Sticker Pack
462
+
463
+ > [!IMPORTANT]
464
+ If `sharp` or `@napi-rs/image` is not installed, the `cover` and `stickers` must already be in WebP format.
465
+
466
+ ```javascript
467
+ sock.sendMessage(jid, {
468
+ cover: {
469
+ url: './path/to/image.webp'
470
+ },
471
+ stickers: [{
472
+ data: {
473
+ url: './path/to/image.webp'
474
+ }
475
+ }, {
476
+ data: {
477
+ url: './path/to/image.webp'
478
+ }
479
+ }, {
480
+ data: {
481
+ url: './path/to/image.webp'
482
+ }
483
+ }],
484
+ name: '📦 My Sticker Pack',
485
+ publisher: '🌟 Lia Wynn',
486
+ description: '@itsliaaa/baileys'
487
+ }, {
488
+ quoted: message
489
+ })
490
+ ```
491
+
492
+ #### 👉🏻 Sending Interactive Messages
493
+
494
+ ##### 1️⃣ Buttons
495
+
496
+ ```javascript
497
+ // --- Regular buttons message
498
+ sock.sendMessage(jid, {
499
+ text: '👆🏻 Buttons!',
500
+ footer: '@itsliaaa/baileys',
501
+ buttons: [{
502
+ text: '👋🏻 SignUp',
503
+ id: '#SignUp'
504
+ }]
505
+ }, {
506
+ quoted: message
507
+ })
508
+
509
+ // --- Buttons with Media & Native Flow
510
+ sock.sendMessage(jid, {
511
+ image: {
512
+ url: './path/to/image.jpg'
513
+ },
514
+ caption: '👆🏻 Buttons and Native Flow!',
515
+ footer: '@itsliaaa/baileys',
516
+ buttons: [{
517
+ text: '👋🏻 Rating',
518
+ id: '#Rating'
519
+ }, {
520
+ text: '📋 Select',
521
+ sections: [{
522
+ title: '✨ Section 1',
523
+ rows: [{
524
+ header: '',
525
+ title: '💭 Secret Ingredient',
526
+ description: '',
527
+ id: '#SecretIngredient'
528
+ }]
529
+ }, {
530
+ title: '✨ Section 2',
531
+ highlight_label: '🔥 Popular',
532
+ rows: [{
533
+ header: '',
534
+ title: '🏷️ Coupon',
535
+ description: '',
536
+ id: '#CouponCode'
537
+ }]
538
+ }]
539
+ }]
540
+ }, {
541
+ quoted: message
542
+ })
543
+ ```
544
+
545
+ ##### 2️⃣ List
546
+
547
+ > [!NOTE]
548
+ It only works in private chat (`@s.whatsapp.net`).
549
+
550
+ ```javascript
551
+ sock.sendMessage(jid, {
552
+ text: '📋 List!',
553
+ footer: '@itsliaaa/baileys',
554
+ buttonText: '📋 Select',
555
+ title: '👋🏻 Hello',
556
+ sections: [{
557
+ title: '🚀 Menu 1',
558
+ rows: [{
559
+ title: '✨ AI',
560
+ description: '',
561
+ rowId: '#AI'
562
+ }]
563
+ }, {
564
+ title: '🌱 Menu 2',
565
+ rows: [{
566
+ title: '🔍 Search',
567
+ description: '',
568
+ rowId: '#Search'
569
+ }]
570
+ }]
571
+ }, {
572
+ quoted: message
573
+ })
574
+ ```
575
+
576
+ ##### 3️⃣ Interactive
577
+
578
+ ```javascript
579
+ // --- Native Flow
580
+ sock.sendMessage(jid, {
581
+ image: {
582
+ url: './path/to/image.jpg'
583
+ },
584
+ caption: '🗄️ Interactive!',
585
+ footer: '@itsliaaa/baileys',
586
+ optionText: '👉🏻 Select Options', // --- Optional, wrap all native flow into a single list
587
+ optionTitle: '📄 Select Options', // --- Optional
588
+ couponText: '🏷️ Newest Coupon!', // --- Optional, add coupon into message
589
+ couponCode: '@itsliaaa/baileys', // --- Optional
590
+ nativeFlow: [{
591
+ text: '👋🏻 Greeting',
592
+ id: '#Greeting'
593
+ }, {
594
+ text: '📞 Call',
595
+ call: '628123456789'
596
+ }, {
597
+ text: '📋 Copy',
598
+ copy: '@itsliaaa/baileys'
599
+ }, {
600
+ text: '🌐 Source',
601
+ url: 'https://www.npmjs.com/package/baileys'
602
+ }, {
603
+ text: '📋 Select',
604
+ sections: [{
605
+ title: '✨ Section 1',
606
+ rows: [{
607
+ header: '',
608
+ title: '🏷️ Coupon',
609
+ description: '',
610
+ id: '#CouponCode'
611
+ }]
612
+ }, {
613
+ title: '✨ Section 2',
614
+ highlight_label: '🔥 Popular',
615
+ rows: [{
616
+ header: '',
617
+ title: '💭 Secret Ingredient',
618
+ description: '',
619
+ id: '#SecretIngredient'
620
+ }]
621
+ }]
622
+ }],
623
+ interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
624
+ }, {
625
+ quoted: message
626
+ })
627
+
628
+ // --- Carousel & Native Flow
629
+ sock.sendMessage(jid, {
630
+ text: '🗂️ Interactive with Carousel!',
631
+ footer: '@itsliaaa/baileys',
632
+ cards: [{
633
+ image: {
634
+ url: './path/to/image.jpg'
635
+ },
636
+ caption: '🖼️ Image 1',
637
+ footer: '🏷️️ Pinterest',
638
+ nativeFlow: [{
639
+ text: '🌐 Source',
640
+ url: 'https://www.npmjs.com/package/baileys'
641
+ }]
642
+ }, {
643
+ image: {
644
+ url: './path/to/image.jpg'
645
+ },
646
+ caption: '🖼️ Image 2',
647
+ footer: '🏷️ Pinterest',
648
+ couponText: '🏷️ New Coupon!',
649
+ couponCode: '@itsliaaa/baileys',
650
+ nativeFlow: [{
651
+ text: '🌐 Source',
652
+ url: 'https://www.npmjs.com/package/baileys'
653
+ }]
654
+ }, {
655
+ image: {
656
+ url: './path/to/image.jpg'
657
+ },
658
+ caption: '🖼️ Image 3',
659
+ footer: '🏷️ Pinterest',
660
+ optionText: '👉🏻 Select Options',
661
+ optionTitle: '📄 Select Options',
662
+ couponText: '🏷️ New Coupon!',
663
+ couponCode: '@itsliaaa/baileys',
664
+ nativeFlow: [{
665
+ text: '🛒 Product',
666
+ id: '#Product'
667
+ }, {
668
+ text: '🌐 Source',
669
+ url: 'https://www.npmjs.com/package/baileys'
670
+ }]
671
+ }]
672
+ }, {
673
+ quoted: message
674
+ })
675
+ ```
676
+
677
+ ##### 4️⃣ Hydrated Template
678
+
679
+ ```javascript
680
+ sock.sendMessage(jid, {
681
+ title: '👋🏻 Hello',
682
+ image: {
683
+ url: './path/to/image.jpg'
684
+ },
685
+ caption: '🫙 Template!',
686
+ footer: '@itsliaaa/baileys',
687
+ templateButtons: [{
688
+ text: '👉🏻 Tap Here',
689
+ id: '#Order'
690
+ }, {
691
+ text: '🌐 Source',
692
+ url: 'https://www.npmjs.com/package/baileys'
693
+ }, {
694
+ text: '📞 Call',
695
+ call: '628123456789'
696
+ }]
697
+ }, {
698
+ quoted: message
699
+ })
700
+ ```
701
+
702
+ #### 💳 Sending Payment Messages
703
+
704
+ ##### 1️⃣ Invite Payment
705
+
706
+ ```javascript
707
+ sock.sendMessage(jid, {
708
+ paymentInviteServiceType: 3 // 1, 2, or 3
709
+ })
710
+ ```
711
+
712
+ ##### 2️⃣ Invoice
713
+
714
+ > [!NOTE]
715
+ Invoice message are not supported yet.
716
+
717
+ ```javascript
718
+ sock.sendMessage(jid, {
719
+ image: {
720
+ url: './path/to/image.jpg'
721
+ },
722
+ invoiceNote: '🏷️ Invoice'
723
+ })
724
+ ```
725
+
726
+ ##### 3️⃣ Order
727
+
728
+ ```javascript
729
+ sock.sendMessage(chat, {
730
+ orderText: '🛍️ Order',
731
+ thumbnail: fs.readFileSync('./path/to/image.jpg') // --- Must in buffer format
732
+ }, {
733
+ quoted: message
734
+ })
735
+ ```
736
+
737
+ ##### 4️⃣ Product
738
+
739
+ ```javascript
740
+ sock.sendMessage(jid, {
741
+ image: {
742
+ url: './path/to/image.jpg'
743
+ },
744
+ product: {
745
+ title: '🛒 My Product'
746
+ },
747
+ businessOwnerJid: '0@s.whatsapp.net' // --- Must included
748
+ }, {
749
+ quoted: message
750
+ })
751
+ ```
752
+
753
+ ##### 5️⃣ Request Payment
754
+
755
+ ```javascript
756
+ sock.sendMessage(jid, {
757
+ text: '💳 Request Payment',
758
+ requestPaymentFrom: '0@s.whatsapp.net'
759
+ })
760
+ ```
761
+
762
+ #### 👁️ Other Message Options
763
+
764
+ ##### 1️⃣ AI Label
765
+
766
+ > [!NOTE]
767
+ It only works in private chat (`@s.whatsapp.net`).
768
+
769
+ ```javascript
770
+ sock.sendMessage(jid, {
771
+ image: {
772
+ url: './path/to/image.jpg'
773
+ },
774
+ caption: '🤖 AI Labeled!',
775
+ ai: true
776
+ }, {
777
+ quoted: message
778
+ })
779
+ ```
780
+
781
+ ##### 2️⃣ Ephemeral
782
+
783
+ > [!NOTE]
784
+ Wrap message into `ephemeralMessage`
785
+
786
+ ```javascript
787
+ sock.sendMessage(jid, {
788
+ image: {
789
+ url: './path/to/image.jpg'
790
+ },
791
+ caption: '👁️ Ephemeral',
792
+ ephemeral: true
793
+ })
794
+ ```
795
+
796
+ ##### 3️⃣ External Ad Reply
797
+
798
+ > [!NOTE]
799
+ Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
800
+
801
+ ```javascript
802
+ sock.sendMessage(jid, {
803
+ text: '📰 External Ad Reply',
804
+ externalAdReply: {
805
+ title: '📝 Did you know?',
806
+ body: '❓ I dont know',
807
+ thumbnail: fs.readFileSync('./path/to/image.jpg'), // --- Must in buffer format
808
+ largeThumbnail: false, // --- Or true for bigger thumbnail
809
+ url: 'https://www.npmjs.com/package/baileys' // --- Optional, used for WhatsApp internal thumbnail caching and direct URL
810
+ }
811
+ }, {
812
+ quoted: message
813
+ })
814
+ ```
815
+
816
+ ##### 4️⃣ Group Status
817
+
818
+ > [!NOTE]
819
+ It only works in group chat (`@g.us`)
820
+
821
+ ```javascript
822
+ sock.sendMessage(jid, {
823
+ image: {
824
+ url: './path/to/image.jpg'
825
+ },
826
+ caption: '👥 Group Status!',
827
+ groupStatus: true
828
+ })
829
+ ```
830
+
831
+ ##### 5️⃣ Raw
832
+
833
+ ```javascript
834
+ sock.sendMessage(jid, {
835
+ extendedTextMessage: {
836
+ text: '📃 Built manually from scratch using the raw WhatsApp proto structure',
837
+ contextInfo: {
838
+ externalAdReply: {
839
+ title: '@itsliaaa/baileys',
840
+ thumbnail: fs.readFileSync('./path/to/image.jpg'),
841
+ sourceApp: 'whatsapp',
842
+ showAdAttribution: true,
843
+ mediaType: 1
844
+ }
845
+ }
846
+ },
847
+ raw: true
848
+ }, {
849
+ quoted: message
850
+ })
851
+ ```
852
+
853
+ ##### 6️⃣ Secure Meta Service Label
854
+
855
+ ```javascript
856
+ sock.sendMessage(jid, {
857
+ text: 'Just a label!',
858
+ secureMetaServiceLabel: true
859
+ })
860
+ ```
861
+
862
+ ##### 7️⃣ View Once
863
+
864
+ > [!NOTE]
865
+ Wrap message into `viewOnceMessage`
866
+
867
+ ```javascript
868
+ sock.sendMessage(jid, {
869
+ image: {
870
+ url: './path/to/image.jpg'
871
+ },
872
+ caption: '👁️ View Once',
873
+ viewOnce: true
874
+ })
875
+ ```
876
+
877
+ ##### 8️⃣ View Once V2
878
+
879
+ > [!NOTE]
880
+ Wrap message into `viewOnceMessageV2`
881
+
882
+ ```javascript
883
+ sock.sendMessage(jid, {
884
+ image: {
885
+ url: './path/to/image.jpg'
886
+ },
887
+ caption: '👁️ View Once V2',
888
+ viewOnceV2: true
889
+ })
890
+ ```
891
+
892
+ ##### 9️⃣ View Once V2 Extension
893
+
894
+ > [!NOTE]
895
+ Wrap message into `viewOnceMessageV2Extension`
896
+
897
+ ```javascript
898
+ sock.sendMessage(jid, {
899
+ image: {
900
+ url: './path/to/image.jpg'
901
+ },
902
+ caption: '👁️ View Once V2 Extension',
903
+ viewOnceV2Extension: true
904
+ })
905
+ ```
906
+
907
+ #### 🧰 Additional Contents
908
+
909
+ ##### 🏷️ Find User ID (JID|PN/LID)
910
+
911
+ > [!NOTE]
912
+ The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
913
+
914
+ ```javascript
915
+ // --- PN (Phone Number)
916
+ const phoneNumber = '6281111111111@s.whatsapp.net'
917
+
918
+ const ids = await sock.findUserId(phoneNumber)
919
+
920
+ console.log('🏷️ Got user ID', ':', ids)
921
+
922
+ // --- LID (Local Identifier)
923
+ const lid = '43411111111111@lid'
924
+
925
+ const ids = await sock.findUserId(lid)
926
+
927
+ console.log('🏷️ Got user ID', ':', ids)
928
+
929
+ // --- Output
930
+ // {
931
+ // phoneNumber: '6281111111111@s.whatsapp.net',
932
+ // lid: '43411111111111@lid'
933
+ // }
934
+ // --- Output when failed
935
+ // {
936
+ // phoneNumber: '6281111111111@s.whatsapp.net',
937
+ // lid: 'id-not-found'
938
+ // }
939
+ // --- Same output shape regardless of input type
940
+ ```
941
+
942
+ ##### 🔑 Request Custom Pairing Code
943
+
944
+ > [!NOTE]
945
+ The phone number must contain numbers only (no +, (), or -) and must include the country code.
946
+
947
+ ```javascript
948
+ const phoneNumber = '6281111111111'
949
+ const customPairingCode = 'STARFALL'
950
+
951
+ await sock.requestPairingCode(phoneNumber, customPairingCode)
952
+
953
+ console.log('🔗 Pairing code', ':', customPairingCode)
954
+ ```
955
+
956
+ ##### 📣 Newsletter Management
957
+
958
+ ```javascript
959
+ // --- Create a new one
960
+ sock.newsletterCreate('@itsliaaa/baileys')
961
+
962
+ // --- Get info
963
+ sock.newsletterMetadata('1231111111111@newsletter')
964
+
965
+ // --- Demote admin
966
+ sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
967
+
968
+ // --- Change owner
969
+ sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
970
+
971
+ // --- Change name
972
+ sock.newsletterUpdateName('1231111111111@newsletter', '📦 @itsliaaa/baileys')
973
+
974
+ // --- Change description
975
+ sock.newsletterUpdateDescription('1231111111111@newsletter', '📣 Fresh updates weekly')
976
+
977
+ // --- Change photo
978
+ sock.newsletterUpdatePicture('1231111111111@newsletter', {
979
+ url: 'path/to/image.jpg'
980
+ })
981
+
982
+ // --- Remove photo
983
+ sock.newsletterRemovePicture('1231111111111@newsletter')
984
+
985
+ // --- React to a message
986
+ sock.newsletterReactMessage('1231111111111@newsletter', '100', '💛')
987
+
988
+ // --- Get all subscribed newsletters
989
+ const newsletters = await sock.newsletterSubscribed()
990
+
991
+ console.dir(newsletters, { depth: null })
992
+ ```
993
+
994
+ ##### 👥 Group Management
995
+
996
+ ```javascript
997
+ // --- Create a new one and add participants using their JIDs
998
+ sock.groupCreate('@itsliaaa/baileys', ['628123456789@s.whatsapp.net'])
999
+
1000
+ // --- Get info
1001
+ sock.groupMetadata(jid)
1002
+
1003
+ // --- Get invite code
1004
+ sock.groupInviteCode(jid)
1005
+
1006
+ // --- Revoke invite link
1007
+ sock.groupRevokeInvite(jid)
1008
+
1009
+ // --- Leave group
1010
+ sock.groupLeave(jid)
1011
+
1012
+ // --- Add participants
1013
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'add')
1014
+
1015
+ // --- Remove participants
1016
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'remove')
1017
+
1018
+ // --- Promote to admin
1019
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'promote')
1020
+
1021
+ // --- Demote from admin
1022
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
1023
+
1024
+ // --- Change name
1025
+ sock.groupUpdateSubject(jid, '📦 @itsliaaa/baileys')
1026
+
1027
+ // --- Change description
1028
+ sock.groupUpdateDescription(jid, 'Updated description')
1029
+
1030
+ // --- Change photo
1031
+ sock.updateProfilePicture(jid, {
1032
+ url: 'path/to/image.jpg'
1033
+ })
1034
+
1035
+ // --- Remove photo
1036
+ sock.removeProfilePicture(jid)
1037
+
1038
+ // --- Set group as admin only for chatting
1039
+ sock.groupSettingUpdate(jid, 'announcement')
1040
+
1041
+ // --- Set group as open to all for chatting
1042
+ sock.groupSettingUpdate(jid, 'not_announcement')
1043
+
1044
+ // --- Set admin only can edit group info
1045
+ sock.groupSettingUpdate(jid, 'locked')
1046
+
1047
+ // --- Set all participants can edit group info
1048
+ sock.groupSettingUpdate(jid, 'unlocked')
1049
+
1050
+ // --- Set admin only can add participants
1051
+ sock.groupMemberAddMode(jid, 'admin_add')
1052
+
1053
+ // --- Set all participants can add participants
1054
+ sock.groupMemberAddMode(jid, 'all_member_add')
1055
+
1056
+ // --- Enable or disable temporary messages with seconds format
1057
+ sock.groupToggleEphemeral(jid, 86400)
1058
+
1059
+ // --- Disable temporary messages
1060
+ sock.groupToggleEphemeral(jid, 0)
1061
+
1062
+ // --- Enable or disable membership approval mode
1063
+ sock.groupJoinApprovalMode(jid, 'on')
1064
+ sock.groupJoinApprovalMode(jid, 'off')
1065
+
1066
+ // --- Get all groups metadata
1067
+ const groups = await sock.groupFetchAllParticipating()
1068
+
1069
+ console.dir(groups, { depth: null })
1070
+
1071
+ // --- Get pending invites
1072
+ const invites = await sock.groupGetInviteInfo(code)
1073
+
1074
+ console.dir(invites, { depth: null })
1075
+
1076
+ // --- Accept group invite
1077
+ sock.groupAcceptInvite(code)
1078
+
1079
+ // --- Get group info from link
1080
+ const group = await sock.groupGetInviteInfo('https://chat.whatsapp.com/ABC123')
1081
+
1082
+ console.log('👥 Got group info from link', ':', group)
1083
+ ```
1084
+
1085
+ ## 📦 Fork Base
1086
+ > [!NOTE]
1087
+ This fork is based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baileys)
1088
+
1089
+ ## 📣 Credits
1090
+ > [!IMPORTANT]
1091
+ This fork uses Protocol Buffer definitions maintained by [WPP Connect](https://github.com/wppconnect-team) via [`wa-proto`](https://github.com/wppconnect-team/wa-proto)
1092
+ >
1093
+ > All rights belong to the original Baileys maintainers and contributors:
1094
+ > - [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)
1095
+ > - [purpshell](https://github.com/purpshell)
1096
+ > - [jlucaso1](https://github.com/jlucaso1)
1097
+ > - [adiwajshing](https://github.com/adiwajshing)