@queenanya/baileys 7.4.10 → 7.4.13

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 (111) hide show
  1. package/README.md +26 -26
  2. package/WAProto/index.js +97194 -67957
  3. package/lib/Defaults/baileys-version.json +1 -1
  4. package/lib/Defaults/index.d.ts +231 -1
  5. package/lib/Defaults/index.js +23 -11
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Socket/Client/index.d.ts +3 -2
  8. package/lib/Socket/Client/index.js +3 -2
  9. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  10. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  11. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
  12. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +2 -2
  13. package/lib/Socket/business.d.ts +28 -31
  14. package/lib/Socket/chats.d.ts +9 -17
  15. package/lib/Socket/chats.js +116 -115
  16. package/lib/Socket/groups.d.ts +10 -23
  17. package/lib/Socket/groups.js +1 -12
  18. package/lib/Socket/index.d.ts +38 -69
  19. package/lib/Socket/index.js +2 -2
  20. package/lib/Socket/messages-recv.d.ts +28 -30
  21. package/lib/Socket/messages-recv.js +180 -291
  22. package/lib/Socket/messages-send.d.ts +19 -25
  23. package/lib/Socket/messages-send.js +76 -110
  24. package/lib/Socket/newsletter.d.ts +13 -19
  25. package/lib/Socket/newsletter.js +54 -67
  26. package/lib/Socket/{communities.d.ts → registration.d.ts} +145 -94
  27. package/lib/Socket/registration.js +166 -0
  28. package/lib/Socket/socket.d.ts +1 -3
  29. package/lib/Socket/socket.js +17 -15
  30. package/lib/Store/make-cache-manager-store.d.ts +1 -2
  31. package/lib/Store/make-in-memory-store.js +11 -13
  32. package/lib/Store/make-ordered-dictionary.js +2 -2
  33. package/lib/Types/Auth.d.ts +6 -1
  34. package/lib/Types/Call.d.ts +1 -1
  35. package/lib/Types/Chat.d.ts +7 -15
  36. package/lib/Types/Contact.d.ts +1 -6
  37. package/lib/Types/Events.d.ts +2 -44
  38. package/lib/Types/GroupMetadata.d.ts +1 -3
  39. package/lib/Types/Label.d.ts +0 -11
  40. package/lib/Types/Message.d.ts +30 -37
  41. package/lib/Types/Newsletter.d.ts +13 -0
  42. package/lib/Types/Newsletter.js +15 -1
  43. package/lib/Types/Socket.d.ts +3 -10
  44. package/lib/Types/index.d.ts +0 -8
  45. package/lib/Utils/auth-utils.js +7 -1
  46. package/lib/Utils/chat-utils.d.ts +4 -5
  47. package/lib/Utils/chat-utils.js +20 -52
  48. package/lib/Utils/crypto.d.ts +1 -2
  49. package/lib/Utils/crypto.js +2 -4
  50. package/lib/Utils/decode-wa-message.d.ts +0 -1
  51. package/lib/Utils/decode-wa-message.js +14 -34
  52. package/lib/Utils/event-buffer.js +8 -14
  53. package/lib/Utils/generics.d.ts +13 -37
  54. package/lib/Utils/generics.js +18 -103
  55. package/lib/Utils/history.d.ts +2 -6
  56. package/lib/Utils/history.js +0 -3
  57. package/lib/Utils/index.d.ts +0 -1
  58. package/lib/Utils/index.js +0 -1
  59. package/lib/Utils/link-preview.js +1 -24
  60. package/lib/Utils/logger.d.ts +3 -1
  61. package/lib/Utils/make-mutex.js +0 -1
  62. package/lib/Utils/messages-media.d.ts +2 -3
  63. package/lib/Utils/messages-media.js +32 -17
  64. package/lib/Utils/messages.d.ts +0 -1
  65. package/lib/Utils/messages.js +72 -67
  66. package/lib/Utils/noise-handler.d.ts +3 -3
  67. package/lib/Utils/noise-handler.js +12 -7
  68. package/lib/Utils/process-message.d.ts +2 -3
  69. package/lib/Utils/process-message.js +21 -55
  70. package/lib/Utils/signal.js +16 -23
  71. package/lib/Utils/use-multi-file-auth-state.js +3 -17
  72. package/lib/Utils/validate-connection.d.ts +1 -0
  73. package/lib/Utils/validate-connection.js +44 -10
  74. package/lib/WABinary/constants.js +5 -5
  75. package/lib/WABinary/decode.d.ts +2 -3
  76. package/lib/WABinary/decode.js +4 -6
  77. package/lib/WABinary/encode.d.ts +2 -1
  78. package/lib/WABinary/encode.js +6 -8
  79. package/lib/WABinary/generic-utils.d.ts +0 -1
  80. package/lib/WABinary/jid-utils.d.ts +3 -3
  81. package/lib/WABinary/jid-utils.js +5 -5
  82. package/lib/WAM/BinaryInfo.d.ts +2 -3
  83. package/lib/WAM/constants.d.ts +2 -3
  84. package/lib/WAM/encode.d.ts +0 -1
  85. package/lib/WAM/encode.js +2 -2
  86. package/lib/index.d.ts +0 -1
  87. package/lib/index.js +0 -1
  88. package/package.json +37 -39
  89. package/lib/Socket/communities.js +0 -354
  90. package/lib/Socket/usync.d.ts +0 -38
  91. package/lib/Socket/usync.js +0 -70
  92. package/lib/Types/USync.d.ts +0 -25
  93. package/lib/Types/USync.js +0 -2
  94. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  95. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -32
  96. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  97. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -57
  98. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  99. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -30
  100. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  101. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
  102. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  103. package/lib/WAUSync/Protocols/index.js +0 -20
  104. package/lib/WAUSync/USyncQuery.d.ts +0 -26
  105. package/lib/WAUSync/USyncQuery.js +0 -79
  106. package/lib/WAUSync/USyncUser.d.ts +0 -10
  107. package/lib/WAUSync/USyncUser.js +0 -22
  108. package/lib/WAUSync/index.d.ts +0 -3
  109. package/lib/WAUSync/index.js +0 -19
  110. /package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +0 -0
  111. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
package/README.md CHANGED
@@ -1,17 +1,11 @@
1
- # Note:
2
- **@queenanya/baileys is another version of Baileys that was originally created by Adhiraj Singh. @queenanya/baileys is Maintained and Up-to-dated with all lestest feature [Thanks for Visiting Here If You Any Questions/Query Please Open A Issue In GitHub Repository]**
3
-
4
- ## Maintainer Of @queenanya/baileys
5
- ** •Team PikaBotz. **
6
-
7
- # QueenAnya/Baileys - Typescript/Javascript WhatsApp Web API
1
+ # Baileys - Typescript/Javascript WhatsApp Web API
8
2
 
9
3
  ### Important Note
10
4
 
11
5
  This library was originally a project for **CS-2362 at Ashoka University** and is in no way affiliated with or endorsed by WhatsApp. Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
12
6
 
13
7
  #### Liability and License Notice
14
- Baileys and its maintainers cannot be held liable for misuse of this application, as stated in the [MIT license](https://github.com/queenanya/Baileys/blob/master/LICENSE).
8
+ Baileys and its maintainers cannot be held liable for misuse of this application, as stated in the [MIT license](https://github.com/WhiskeySockets/Baileys/blob/master/LICENSE).
15
9
  The maintainers of Baileys do not in any way condone the use of this application in practices that violate the Terms of Service of WhatsApp. The maintainers of this application call upon the personal responsibility of its users to use this application in a fair way, as it is intended to be used.
16
10
  ##
17
11
 
@@ -39,17 +33,17 @@ To run the example script, download or clone the repo and then type the followin
39
33
 
40
34
  Use the stable version:
41
35
  ```
42
- yarn add @queenanya/baileys
36
+ yarn add @whiskeysockets/baileys
43
37
  ```
44
38
 
45
39
  Use the edge version (no guarantee of stability, but latest fixes + features)
46
40
  ```
47
- yarn add github:QueenAnya/Baileys
41
+ yarn add github:WhiskeySockets/Baileys
48
42
  ```
49
43
 
50
44
  Then import your code using:
51
45
  ``` ts
52
- import makeWASocket from '@queenanya/baileys'
46
+ import makeWASocket from '@whiskeysockets/baileys'
53
47
  ```
54
48
 
55
49
  ## Unit Tests
@@ -61,7 +55,7 @@ TODO
61
55
  WhatsApp provides a multi-device API that allows Baileys to be authenticated as a second WhatsApp client by scanning a QR code with WhatsApp on your phone.
62
56
 
63
57
  ``` ts
64
- import makeWASocket, { DisconnectReason } from '@queenanya/baileys'
58
+ import makeWASocket, { DisconnectReason } from '@whiskeysockets/baileys'
65
59
  import { Boom } from '@hapi/boom'
66
60
 
67
61
  async function connectToWhatsApp () {
@@ -95,6 +89,16 @@ connectToWhatsApp()
95
89
 
96
90
  If the connection is successful, you will see a QR code printed on your terminal screen, scan it with WhatsApp on your phone and you'll be logged in!
97
91
 
92
+ **Note:** install `qrcode-terminal` using `yarn add qrcode-terminal` to auto-print the QR to the terminal.
93
+
94
+ **Note:** the code to support the legacy version of WA Web (pre multi-device) has been removed in v5. Only the standard multi-device connection is now supported. This is done as WA seems to have completely dropped support for the legacy version.
95
+
96
+ ## Connecting native mobile api
97
+
98
+ Baileys also supports the native mobile API, which allows users to authenticate as a standalone WhatsApp client using their phone number.
99
+
100
+ Run the [example](Example/example.ts) file with ``--mobile`` cli flag to use the native mobile API.
101
+
98
102
  ## Configuring the Connection
99
103
 
100
104
  You can configure the connection by passing a `SocketConfig` object.
@@ -189,7 +193,7 @@ You obviously don't want to keep scanning the QR code every time you want to con
189
193
 
190
194
  So, you can load the credentials to log back in:
191
195
  ``` ts
192
- import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@queenanya/baileys'
196
+ import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@whiskeysockets/baileys'
193
197
  import * as fs from 'fs'
194
198
 
195
199
  // utility function to help save the auth state in a single folder
@@ -304,7 +308,7 @@ Baileys does not come with a defacto storage for chats, contacts, or messages. H
304
308
  It can be used as follows:
305
309
 
306
310
  ``` ts
307
- import makeWASocket, { makeInMemoryStore } from '@queenanya/baileys'
311
+ import makeWASocket, { makeInMemoryStore } from '@whiskeysockets/baileys'
308
312
  // the store maintains the data of the WA connection in memory
309
313
  // can be written out to a file & read from it
310
314
  const store = makeInMemoryStore({ })
@@ -320,7 +324,7 @@ const sock = makeWASocket({ })
320
324
  // the store can listen from a new socket once the current socket outlives its lifetime
321
325
  store.bind(sock.ev)
322
326
 
323
- sock.ev.on('chats.upsert', () => {
327
+ sock.ev.on('chats.set', () => {
324
328
  // can use "store.chats" however you want, even after the socket dies out
325
329
  // "chats" => a KeyedDB instance
326
330
  console.log('got chats', store.chats.all())
@@ -343,7 +347,7 @@ The store also provides some simple functions such as `loadMessages` that utiliz
343
347
  ### Non-Media Messages
344
348
 
345
349
  ``` ts
346
- import { MessageType, MessageOptions, Mimetype } from '@queenanya/baileys'
350
+ import { MessageType, MessageOptions, Mimetype } from '@whiskeysockets/baileys'
347
351
 
348
352
  const id = 'abcd@s.whatsapp.net' // the WhatsApp ID
349
353
  // send a simple text!
@@ -402,7 +406,7 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
402
406
  - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
403
407
 
404
408
  ``` ts
405
- import { MessageType, MessageOptions, Mimetype } from '@queenanya/baileys'
409
+ import { MessageType, MessageOptions, Mimetype } from '@whiskeysockets/baileys'
406
410
  // Sending gifs
407
411
  await sock.sendMessage(
408
412
  id,
@@ -418,8 +422,7 @@ await sock.sendMessage(
418
422
  {
419
423
  video: "./Media/ma_gif.mp4",
420
424
  caption: "hello!",
421
- gifPlayback: true,
422
- ptv: false // if set to true, will send as a `video note`
425
+ gifPlayback: true
423
426
  }
424
427
  )
425
428
 
@@ -452,7 +455,7 @@ await sock.sendMessage(
452
455
  Do not enter this field if you want to automatically generate a thumb
453
456
  */
454
457
  mimetype: Mimetype.pdf, /* (for media messages) specify the type of media (optional for all media types except documents),
455
- import {Mimetype} from '@queenanya/baileys'
458
+ import {Mimetype} from '@whiskeysockets/baileys'
456
459
  */
457
460
  fileName: 'somefile.pdf', // (for media messages) file name for the media
458
461
  /* will send audio messages as voice notes, if set to true */
@@ -511,7 +514,7 @@ The presence expires after about 10 seconds.
511
514
  If you want to save the media you received
512
515
  ``` ts
513
516
  import { writeFile } from 'fs/promises'
514
- import { downloadMediaMessage } from '@queenanya/baileys'
517
+ import { downloadMediaMessage } from '@whiskeysockets/baileys'
515
518
 
516
519
  sock.ev.on('messages.upsert', async ({ messages }) => {
517
520
  const m = messages[0]
@@ -798,7 +801,6 @@ Of course, replace ``` xyz ``` with an actual ID.
798
801
  console.log(response)
799
802
  ```
800
803
 
801
-
802
804
  ## Channel
803
805
  - To get newsletter info from code
804
806
  ```ts
@@ -814,8 +816,7 @@ Of course, replace ``` xyz ``` with an actual ID.
814
816
  ```
815
817
  - To get subscribed newsletters
816
818
  ```ts
817
-
818
- const result = await sock.getSubscribedNewsletters()
819
+ const result = await sock.getSubscribedNewsletters()
819
820
  console.log(result)
820
821
  ```
821
822
  - To toggle mute newsletters
@@ -833,7 +834,6 @@ const result = await sock.getSubscribedNewsletters()
833
834
  const result = await sock.unFollowNewsletter(jid)
834
835
  console.log(result)
835
836
  ```
836
-
837
837
  ## Privacy
838
838
  - To get the privacy settings
839
839
  ``` ts
@@ -867,7 +867,7 @@ const result = await sock.getSubscribedNewsletters()
867
867
  ```
868
868
  - To update the Groups Add privacy
869
869
  ``` ts
870
- const value = 'all' // 'contacts' | 'contact_blacklist'
870
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
871
871
  await sock.updateGroupsAddPrivacy(value)
872
872
  ```
873
873
  - To update the Default Disappearing Mode