@queenanya/baileys 7.4.7 → 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.
- package/README.md +26 -26
- package/WAProto/index.js +97194 -67957
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +231 -1
- package/lib/Defaults/index.js +23 -11
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
- package/lib/Socket/Client/{websocket.js → web-socket-client.js} +2 -2
- package/lib/Socket/business.d.ts +22 -29
- package/lib/Socket/chats.d.ts +3 -14
- package/lib/Socket/chats.js +48 -76
- package/lib/Socket/groups.d.ts +4 -21
- package/lib/Socket/groups.js +1 -12
- package/lib/Socket/index.d.ts +32 -37
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +22 -28
- package/lib/Socket/messages-recv.js +180 -291
- package/lib/Socket/messages-send.d.ts +13 -23
- package/lib/Socket/messages-send.js +76 -110
- package/lib/Socket/newsletter.d.ts +7 -17
- package/lib/Socket/newsletter.js +54 -67
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +1 -3
- package/lib/Socket/socket.js +17 -15
- package/lib/Store/make-cache-manager-store.d.ts +1 -2
- package/lib/Store/make-in-memory-store.js +11 -13
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +6 -1
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +7 -12
- package/lib/Types/Contact.d.ts +1 -1
- package/lib/Types/Events.d.ts +2 -44
- package/lib/Types/GroupMetadata.d.ts +1 -3
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +30 -37
- package/lib/Types/Newsletter.d.ts +13 -0
- package/lib/Types/Newsletter.js +15 -1
- package/lib/Types/Socket.d.ts +3 -10
- package/lib/Types/index.d.ts +0 -8
- package/lib/Utils/auth-utils.js +7 -1
- package/lib/Utils/chat-utils.d.ts +4 -5
- package/lib/Utils/chat-utils.js +20 -41
- package/lib/Utils/crypto.d.ts +1 -2
- package/lib/Utils/crypto.js +2 -4
- package/lib/Utils/decode-wa-message.d.ts +0 -1
- package/lib/Utils/decode-wa-message.js +14 -34
- package/lib/Utils/event-buffer.js +8 -14
- package/lib/Utils/generics.d.ts +13 -37
- package/lib/Utils/generics.js +18 -102
- package/lib/Utils/history.d.ts +2 -6
- package/lib/Utils/history.js +0 -3
- package/lib/Utils/index.d.ts +0 -1
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/link-preview.js +1 -24
- package/lib/Utils/logger.d.ts +3 -1
- package/lib/Utils/make-mutex.js +0 -1
- package/lib/Utils/messages-media.d.ts +2 -3
- package/lib/Utils/messages-media.js +32 -17
- package/lib/Utils/messages.d.ts +0 -1
- package/lib/Utils/messages.js +72 -67
- package/lib/Utils/noise-handler.d.ts +3 -3
- package/lib/Utils/noise-handler.js +12 -7
- package/lib/Utils/process-message.d.ts +2 -3
- package/lib/Utils/process-message.js +21 -55
- package/lib/Utils/signal.js +16 -23
- package/lib/Utils/use-multi-file-auth-state.js +3 -17
- package/lib/Utils/validate-connection.d.ts +1 -0
- package/lib/Utils/validate-connection.js +44 -10
- package/lib/WABinary/constants.js +5 -5
- package/lib/WABinary/decode.d.ts +2 -3
- package/lib/WABinary/decode.js +4 -6
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +6 -8
- package/lib/WABinary/generic-utils.d.ts +0 -1
- package/lib/WABinary/jid-utils.d.ts +3 -3
- package/lib/WABinary/jid-utils.js +5 -5
- package/lib/WAM/BinaryInfo.d.ts +2 -3
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/encode.d.ts +0 -1
- package/lib/WAM/encode.js +2 -2
- package/package.json +37 -39
- /package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +0 -0
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
package/README.md
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
#
|
|
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/
|
|
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 @
|
|
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:
|
|
41
|
+
yarn add github:WhiskeySockets/Baileys
|
|
48
42
|
```
|
|
49
43
|
|
|
50
44
|
Then import your code using:
|
|
51
45
|
``` ts
|
|
52
|
-
import makeWASocket from '@
|
|
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 '@
|
|
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 '@
|
|
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 '@
|
|
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.
|
|
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 '@
|
|
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 '@
|
|
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 '@
|
|
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 '@
|
|
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
|