@periskope/baileys 7.0.0-rc5-3 → 7.0.0-rc9-alpha-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +49 -55
  2. package/WAProto/WAProto.proto +1067 -221
  3. package/WAProto/fix-imports.js +1 -1
  4. package/WAProto/index.d.ts +5011 -37518
  5. package/WAProto/index.js +113270 -54458
  6. package/lib/Defaults/index.d.ts +1 -1
  7. package/lib/Defaults/index.d.ts.map +1 -1
  8. package/lib/Defaults/index.js +8 -7
  9. package/lib/Defaults/index.js.map +1 -1
  10. package/lib/Signal/Group/sender-key-state.d.ts.map +1 -1
  11. package/lib/Signal/Group/sender-key-state.js.map +1 -1
  12. package/lib/Signal/libsignal.d.ts +1 -5
  13. package/lib/Signal/libsignal.d.ts.map +1 -1
  14. package/lib/Signal/libsignal.js +16 -14
  15. package/lib/Signal/libsignal.js.map +1 -1
  16. package/lib/Signal/lid-mapping.js +6 -6
  17. package/lib/Signal/lid-mapping.js.map +1 -1
  18. package/lib/Socket/Client/types.d.ts +2 -2
  19. package/lib/Socket/Client/types.d.ts.map +1 -1
  20. package/lib/Socket/Client/websocket.d.ts +2 -2
  21. package/lib/Socket/Client/websocket.d.ts.map +1 -1
  22. package/lib/Socket/Client/websocket.js +2 -2
  23. package/lib/Socket/Client/websocket.js.map +1 -1
  24. package/lib/Socket/business.d.ts +14 -4
  25. package/lib/Socket/business.d.ts.map +1 -1
  26. package/lib/Socket/chats.d.ts +14 -3
  27. package/lib/Socket/chats.d.ts.map +1 -1
  28. package/lib/Socket/chats.js +21 -8
  29. package/lib/Socket/chats.js.map +1 -1
  30. package/lib/Socket/communities.d.ts +14 -4
  31. package/lib/Socket/communities.d.ts.map +1 -1
  32. package/lib/Socket/communities.js +1 -1
  33. package/lib/Socket/communities.js.map +1 -1
  34. package/lib/Socket/groups.d.ts +14 -3
  35. package/lib/Socket/groups.d.ts.map +1 -1
  36. package/lib/Socket/index.d.ts +14 -4
  37. package/lib/Socket/index.d.ts.map +1 -1
  38. package/lib/Socket/messages-recv.d.ts +14 -4
  39. package/lib/Socket/messages-recv.d.ts.map +1 -1
  40. package/lib/Socket/messages-recv.js +158 -127
  41. package/lib/Socket/messages-recv.js.map +1 -1
  42. package/lib/Socket/messages-send.d.ts +14 -4
  43. package/lib/Socket/messages-send.d.ts.map +1 -1
  44. package/lib/Socket/messages-send.js +95 -75
  45. package/lib/Socket/messages-send.js.map +1 -1
  46. package/lib/Socket/newsletter.d.ts +14 -3
  47. package/lib/Socket/newsletter.d.ts.map +1 -1
  48. package/lib/Socket/socket.d.ts +5 -2
  49. package/lib/Socket/socket.d.ts.map +1 -1
  50. package/lib/Socket/socket.js +79 -27
  51. package/lib/Socket/socket.js.map +1 -1
  52. package/lib/Types/Auth.d.ts +4 -0
  53. package/lib/Types/Auth.d.ts.map +1 -1
  54. package/lib/Types/Message.d.ts +2 -0
  55. package/lib/Types/Message.d.ts.map +1 -1
  56. package/lib/Types/Message.js.map +1 -1
  57. package/lib/Types/Socket.d.ts +1 -5
  58. package/lib/Types/Socket.d.ts.map +1 -1
  59. package/lib/Utils/auth-utils.d.ts.map +1 -1
  60. package/lib/Utils/auth-utils.js +53 -21
  61. package/lib/Utils/auth-utils.js.map +1 -1
  62. package/lib/Utils/decode-wa-message.d.ts +1 -0
  63. package/lib/Utils/decode-wa-message.d.ts.map +1 -1
  64. package/lib/Utils/decode-wa-message.js +13 -8
  65. package/lib/Utils/decode-wa-message.js.map +1 -1
  66. package/lib/Utils/event-buffer.js +2 -2
  67. package/lib/Utils/event-buffer.js.map +1 -1
  68. package/lib/Utils/generics.d.ts.map +1 -1
  69. package/lib/Utils/generics.js +1 -1
  70. package/lib/Utils/generics.js.map +1 -1
  71. package/lib/Utils/history.d.ts +2 -2
  72. package/lib/Utils/history.d.ts.map +1 -1
  73. package/lib/Utils/history.js +7 -1
  74. package/lib/Utils/history.js.map +1 -1
  75. package/lib/Utils/index.d.ts +0 -1
  76. package/lib/Utils/index.d.ts.map +1 -1
  77. package/lib/Utils/index.js +0 -1
  78. package/lib/Utils/index.js.map +1 -1
  79. package/lib/Utils/link-preview.d.ts.map +1 -1
  80. package/lib/Utils/link-preview.js +4 -1
  81. package/lib/Utils/link-preview.js.map +1 -1
  82. package/lib/Utils/logger.d.ts +1 -2
  83. package/lib/Utils/logger.d.ts.map +1 -1
  84. package/lib/Utils/make-mutex.d.ts +1 -0
  85. package/lib/Utils/make-mutex.d.ts.map +1 -1
  86. package/lib/Utils/make-mutex.js +20 -27
  87. package/lib/Utils/make-mutex.js.map +1 -1
  88. package/lib/Utils/message-retry-manager.d.ts +3 -3
  89. package/lib/Utils/message-retry-manager.d.ts.map +1 -1
  90. package/lib/Utils/message-retry-manager.js +25 -2
  91. package/lib/Utils/message-retry-manager.js.map +1 -1
  92. package/lib/Utils/messages-media.d.ts +16 -0
  93. package/lib/Utils/messages-media.d.ts.map +1 -1
  94. package/lib/Utils/messages-media.js +147 -36
  95. package/lib/Utils/messages-media.js.map +1 -1
  96. package/lib/Utils/messages.d.ts +13 -0
  97. package/lib/Utils/messages.d.ts.map +1 -1
  98. package/lib/Utils/messages.js +30 -0
  99. package/lib/Utils/messages.js.map +1 -1
  100. package/lib/Utils/noise-handler.js +2 -1
  101. package/lib/Utils/noise-handler.js.map +1 -1
  102. package/lib/Utils/process-message.d.ts +22 -3
  103. package/lib/Utils/process-message.d.ts.map +1 -1
  104. package/lib/Utils/process-message.js +85 -9
  105. package/lib/Utils/process-message.js.map +1 -1
  106. package/lib/Utils/signal.d.ts.map +1 -1
  107. package/lib/Utils/signal.js +20 -20
  108. package/lib/Utils/signal.js.map +1 -1
  109. package/lib/Utils/validate-connection.d.ts.map +1 -1
  110. package/lib/Utils/validate-connection.js +10 -3
  111. package/lib/Utils/validate-connection.js.map +1 -1
  112. package/lib/WABinary/jid-utils.d.ts +2 -2
  113. package/lib/WABinary/jid-utils.d.ts.map +1 -1
  114. package/lib/WABinary/jid-utils.js +2 -2
  115. package/lib/WABinary/jid-utils.js.map +1 -1
  116. package/package.json +3 -1
package/README.md CHANGED
@@ -5,28 +5,22 @@
5
5
 
6
6
  > [!CAUTION]
7
7
  > NOTICE OF BREAKING CHANGE.
8
- >
8
+ >
9
9
  > As of 7.0.0, multiple breaking changes were introduced into the library.
10
- >
10
+ >
11
11
  > Please check out https://whiskey.so/migrate-latest for more information.
12
12
 
13
- > [!IMPORTANT]
14
- > I made a survey for users of the project to ask questions, and provide Baileys valuable insights regarding its users. I will be publishing the results of this form (after filtering) as well so we can study and understand where we need to work.
15
- >
16
- > The survey is anonymous and requires no personal info at all. You are required to sign-in with Google to keep responses to one person. You are able to edit your response after you submit. The deadline for this form is September 30, 2025.
17
- >
18
- > I encourage you to put the effort, all it takes is 5-10 minutes and you get to ask me any questions you have.
19
- >
20
- > \- Rajeh (purpshell)
21
- >
22
- > Fill in the survey via the link: https://whiskey.so/survey
23
-
24
-
25
13
  # Important Note
26
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).
27
15
 
28
16
  New guide link: https://baileys.wiki
29
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
+
30
24
  # Sponsor
31
25
  If you'd like to financially support this project, you can do so by supporting the current maintainer [here](https://purpshell.dev/sponsor).
32
26
 
@@ -39,8 +33,8 @@ Use at your own discretion. Do not spam people with this. We discourage any stal
39
33
 
40
34
  ##
41
35
 
42
- - Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
43
- - 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 :/
44
38
  - Baileys supports interacting with the multi-device & web versions of WhatsApp.
45
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.
46
40
 
@@ -48,7 +42,7 @@ Use at your own discretion. Do not spam people with this. We discourage any stal
48
42
  > The original repository had to be removed by the original author - we now continue development in this repository here.
49
43
  This is the only official repository and is maintained by the community.
50
44
  > **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
51
-
45
+
52
46
  ## Example
53
47
 
54
48
  Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
@@ -71,7 +65,7 @@ yarn add github:WhiskeySockets/Baileys
71
65
  ```
72
66
 
73
67
  Then import your code using:
74
- ```ts
68
+ ```ts
75
69
  import makeWASocket from '@whiskeysockets/baileys'
76
70
  ```
77
71
 
@@ -290,7 +284,7 @@ const sock = makeWASocket({
290
284
  ```
291
285
  ## Saving & Restoring Sessions
292
286
 
293
- 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.
294
288
 
295
289
  So, you can load the credentials to log back in:
296
290
  ```ts
@@ -314,7 +308,7 @@ sock.ev.on('creds.update', saveCreds)
314
308
 
315
309
  ## Handling Events
316
310
 
317
- - Baileys uses the EventEmitter syntax for events.
311
+ - Baileys uses the EventEmitter syntax for events.
318
312
  They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
319
313
 
320
314
  > [!IMPORTANT]
@@ -451,10 +445,10 @@ The store also provides some simple functions such as `loadMessages` that utiliz
451
445
 
452
446
  ## Whatsapp IDs Explain
453
447
 
454
- - `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.
455
449
  - It must be in the format ```[country code][phone number]@s.whatsapp.net```
456
- - Example for people: ```+19999999999@s.whatsapp.net```.
457
- - 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 ```.
458
452
  - For broadcast lists, it's `[timestamp of creation]@broadcast`.
459
453
  - For stories, the ID is `status@broadcast`.
460
454
 
@@ -513,7 +507,7 @@ await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
513
507
  #### Location Message
514
508
  ```ts
515
509
  await sock.sendMessage(
516
- jid,
510
+ jid,
517
511
  {
518
512
  location: {
519
513
  degreesLatitude: 24.121231,
@@ -525,7 +519,7 @@ await sock.sendMessage(
525
519
  #### Contact Message
526
520
  ```ts
527
521
  const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
528
- + 'VERSION:3.0\n'
522
+ + 'VERSION:3.0\n'
529
523
  + 'FN:Jeff Singh\n' // full name
530
524
  + 'ORG:Ashoka Uni;\n' // the organization of the contact
531
525
  + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
@@ -533,10 +527,10 @@ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
533
527
 
534
528
  await sock.sendMessage(
535
529
  id,
536
- {
537
- contacts: {
538
- displayName: 'Jeff',
539
- contacts: [{ vcard }]
530
+ {
531
+ contacts: {
532
+ displayName: 'Jeff',
533
+ contacts: [{ vcard }]
540
534
  }
541
535
  }
542
536
  )
@@ -626,8 +620,8 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
626
620
  - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
627
621
  ```ts
628
622
  await sock.sendMessage(
629
- jid,
630
- {
623
+ jid,
624
+ {
631
625
  video: fs.readFileSync('Media/ma_gif.mp4'),
632
626
  caption: 'hello word',
633
627
  gifPlayback: true
@@ -638,8 +632,8 @@ await sock.sendMessage(
638
632
  #### Video Message
639
633
  ```ts
640
634
  await sock.sendMessage(
641
- id,
642
- {
635
+ id,
636
+ {
643
637
  video: {
644
638
  url: './Media/ma_gif.mp4'
645
639
  },
@@ -663,7 +657,7 @@ await sock.sendMessage(
663
657
  ```
664
658
  ```ts
665
659
  await sock.sendMessage(
666
- jid,
660
+ jid,
667
661
  {
668
662
  audio: {
669
663
  url: './Media/audio.mp3'
@@ -676,8 +670,8 @@ await sock.sendMessage(
676
670
  #### Image Message
677
671
  ```ts
678
672
  await sock.sendMessage(
679
- id,
680
- {
673
+ id,
674
+ {
681
675
  image: {
682
676
  url: './Media/ma_img.png'
683
677
  },
@@ -692,8 +686,8 @@ await sock.sendMessage(
692
686
 
693
687
  ```ts
694
688
  await sock.sendMessage(
695
- id,
696
- {
689
+ id,
690
+ {
697
691
  image: {
698
692
  url: './Media/ma_img.png'
699
693
  },
@@ -748,7 +742,7 @@ sock.ev.on('messages.upsert', async ({ [m] }) => {
748
742
  m,
749
743
  'stream', // can be 'buffer' too
750
744
  { },
751
- {
745
+ {
752
746
  logger,
753
747
  // pass this so that baileys can request a reupload of media
754
748
  // that has been deleted
@@ -764,7 +758,7 @@ sock.ev.on('messages.upsert', async ({ [m] }) => {
764
758
 
765
759
  ### Re-upload Media Message to Whatsapp
766
760
 
767
- - 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:
768
762
  ```ts
769
763
  await sock.updateMediaMessage(msg)
770
764
  ```
@@ -790,17 +784,17 @@ const key: WAMessageKey
790
784
  await sock.readMessages([key])
791
785
  ```
792
786
 
793
- 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.
794
788
  On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
795
789
 
796
790
  ### Update Presence
797
791
 
798
792
  - ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
799
793
  - The presence expires after about 10 seconds.
800
- - 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.
801
795
 
802
796
  ```ts
803
- await sock.sendPresenceUpdate('available', jid)
797
+ await sock.sendPresenceUpdate('available', jid)
804
798
  ```
805
799
 
806
800
  > [!NOTE]
@@ -849,12 +843,12 @@ await sock.chatModify(
849
843
  messages: [
850
844
  {
851
845
  id: 'ATWYHDNNWU81732J',
852
- fromMe: true,
846
+ fromMe: true,
853
847
  timestamp: '1654823909'
854
848
  }
855
849
  ]
856
850
  }
857
- },
851
+ },
858
852
  jid
859
853
  )
860
854
 
@@ -915,7 +909,7 @@ await sock.chatModify({
915
909
  ```ts
916
910
  // turn on disappearing messages
917
911
  await sock.sendMessage(
918
- jid,
912
+ jid,
919
913
  // this is 1 week in seconds -- how long you want messages to appear for
920
914
  { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
921
915
  )
@@ -925,7 +919,7 @@ await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT
925
919
 
926
920
  // turn off disappearing messages
927
921
  await sock.sendMessage(
928
- jid,
922
+ jid,
929
923
  { disappearingMessagesInChat: false }
930
924
  )
931
925
  ```
@@ -980,7 +974,7 @@ console.log('business description: ' + profile.description + ', category: ' + pr
980
974
  sock.ev.on('presence.update', console.log)
981
975
 
982
976
  // request updates for a chat
983
- await sock.presenceSubscribe(jid)
977
+ await sock.presenceSubscribe(jid)
984
978
  ```
985
979
 
986
980
  ## Change Profile
@@ -1022,7 +1016,7 @@ await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyo
1022
1016
  ```ts
1023
1017
  // id & people to add to the group (will throw error if it fails)
1024
1018
  await sock.groupParticipantsUpdate(
1025
- jid,
1019
+ jid,
1026
1020
  ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1027
1021
  'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1028
1022
  )
@@ -1075,7 +1069,7 @@ console.log('group information: ' + response)
1075
1069
  ```
1076
1070
  ### Query Metadata (participants, name, description...)
1077
1071
  ```ts
1078
- const metadata = await sock.groupMetadata(jid)
1072
+ const metadata = await sock.groupMetadata(jid)
1079
1073
  console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1080
1074
  ```
1081
1075
  ### Join using `groupInviteMessage`
@@ -1093,7 +1087,7 @@ console.log(response)
1093
1087
  const response = await sock.groupRequestParticipantsUpdate(
1094
1088
  jid, // group id
1095
1089
  ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1096
- 'approve' // or 'reject'
1090
+ 'approve' // or 'reject'
1097
1091
  )
1098
1092
  console.log(response)
1099
1093
  ```
@@ -1184,7 +1178,7 @@ await sock.updateGroupsAddPrivacy(value)
1184
1178
  | 90d | 7.776.000 |
1185
1179
 
1186
1180
  ```ts
1187
- const ephemeral = 86400
1181
+ const ephemeral = 86400
1188
1182
  await sock.updateDefaultDisappearingMode(ephemeral)
1189
1183
  ```
1190
1184
 
@@ -1233,14 +1227,14 @@ const sock = makeWASocket({
1233
1227
  logger: P({ level: 'debug' }),
1234
1228
  })
1235
1229
  ```
1236
- 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.
1237
1231
 
1238
1232
  ### How Whatsapp Communicate With Us
1239
1233
 
1240
1234
  > [!TIP]
1241
1235
  > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1242
1236
 
1243
- - **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:
1244
1238
  ```
1245
1239
  {
1246
1240
  "level": 10,
@@ -1269,7 +1263,7 @@ This will enable you to see all sorts of messages WhatsApp sends in the console.
1269
1263
  },
1270
1264
  "msg":"communication"
1271
1265
  }
1272
- ```
1266
+ ```
1273
1267
 
1274
1268
  The `'frame'` is what the message received is, it has three components:
1275
1269
  - `tag` -- what this frame is about (eg. message will have 'message')