@queenanya/baileys 7.4.14 → 7.5.3-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 +26 -26
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +1 -231
- package/lib/Defaults/index.js +11 -23
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
- package/lib/Socket/business.d.ts +31 -28
- package/lib/Socket/chats.d.ts +17 -9
- package/lib/Socket/chats.js +115 -116
- package/lib/Socket/{registration.d.ts → communities.d.ts} +94 -145
- package/lib/Socket/communities.js +354 -0
- package/lib/Socket/groups.d.ts +23 -10
- package/lib/Socket/groups.js +12 -1
- package/lib/Socket/index.d.ts +69 -38
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +30 -28
- package/lib/Socket/messages-recv.js +291 -180
- package/lib/Socket/messages-send.d.ts +25 -19
- package/lib/Socket/messages-send.js +110 -76
- package/lib/Socket/newsletter.d.ts +19 -13
- package/lib/Socket/newsletter.js +67 -54
- package/lib/Socket/socket.d.ts +3 -1
- package/lib/Socket/socket.js +15 -17
- package/lib/Socket/usync.d.ts +38 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/make-cache-manager-store.d.ts +2 -1
- package/lib/Store/make-in-memory-store.js +13 -11
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +1 -6
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +15 -7
- package/lib/Types/Contact.d.ts +6 -1
- package/lib/Types/Events.d.ts +44 -2
- package/lib/Types/GroupMetadata.d.ts +3 -1
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Message.d.ts +37 -30
- package/lib/Types/Newsletter.d.ts +0 -13
- package/lib/Types/Newsletter.js +1 -15
- package/lib/Types/Socket.d.ts +10 -3
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +8 -0
- package/lib/Utils/auth-utils.js +1 -7
- package/lib/Utils/chat-utils.d.ts +5 -4
- package/lib/Utils/chat-utils.js +52 -20
- package/lib/Utils/crypto.d.ts +2 -1
- package/lib/Utils/crypto.js +4 -2
- package/lib/Utils/decode-wa-message.d.ts +1 -0
- package/lib/Utils/decode-wa-message.js +34 -14
- package/lib/Utils/event-buffer.js +14 -8
- package/lib/Utils/generics.d.ts +37 -13
- package/lib/Utils/generics.js +103 -18
- package/lib/Utils/history.d.ts +6 -2
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/index.d.ts +1 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/link-preview.js +24 -1
- package/lib/Utils/logger.d.ts +1 -3
- package/lib/Utils/make-mutex.js +1 -0
- package/lib/Utils/messages-media.d.ts +3 -2
- package/lib/Utils/messages-media.js +17 -32
- package/lib/Utils/messages.d.ts +1 -0
- package/lib/Utils/messages.js +67 -72
- package/lib/Utils/noise-handler.d.ts +3 -3
- package/lib/Utils/noise-handler.js +7 -12
- package/lib/Utils/process-message.d.ts +3 -2
- package/lib/Utils/process-message.js +55 -21
- package/lib/Utils/signal.js +23 -16
- package/lib/Utils/use-multi-file-auth-state.js +17 -3
- package/lib/Utils/validate-connection.d.ts +0 -1
- package/lib/Utils/validate-connection.js +10 -44
- package/lib/WABinary/constants.js +5 -5
- package/lib/WABinary/decode.d.ts +3 -2
- package/lib/WABinary/decode.js +6 -4
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +8 -6
- package/lib/WABinary/generic-utils.d.ts +1 -0
- package/lib/WABinary/jid-utils.d.ts +3 -3
- package/lib/WABinary/jid-utils.js +5 -5
- package/lib/WAM/BinaryInfo.d.ts +3 -2
- package/lib/WAM/constants.d.ts +3 -2
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -0
- package/lib/WAUSync/USyncQuery.js +79 -0
- package/lib/WAUSync/USyncUser.d.ts +10 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +36 -34
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/registration.js +0 -166
- /package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +0 -0
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
package/README.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
#
|
|
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
|
|
2
8
|
|
|
3
9
|
### Important Note
|
|
4
10
|
|
|
5
11
|
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.
|
|
6
12
|
|
|
7
13
|
#### Liability and License Notice
|
|
8
|
-
Baileys and its maintainers cannot be held liable for misuse of this application, as stated in the [MIT license](https://github.com/
|
|
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).
|
|
9
15
|
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.
|
|
10
16
|
##
|
|
11
17
|
|
|
@@ -33,17 +39,17 @@ To run the example script, download or clone the repo and then type the followin
|
|
|
33
39
|
|
|
34
40
|
Use the stable version:
|
|
35
41
|
```
|
|
36
|
-
yarn add @
|
|
42
|
+
yarn add @queenanya/baileys
|
|
37
43
|
```
|
|
38
44
|
|
|
39
45
|
Use the edge version (no guarantee of stability, but latest fixes + features)
|
|
40
46
|
```
|
|
41
|
-
yarn add github:
|
|
47
|
+
yarn add github:QueenAnya/Baileys
|
|
42
48
|
```
|
|
43
49
|
|
|
44
50
|
Then import your code using:
|
|
45
51
|
``` ts
|
|
46
|
-
import makeWASocket from '@
|
|
52
|
+
import makeWASocket from '@queenanya/baileys'
|
|
47
53
|
```
|
|
48
54
|
|
|
49
55
|
## Unit Tests
|
|
@@ -55,7 +61,7 @@ TODO
|
|
|
55
61
|
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.
|
|
56
62
|
|
|
57
63
|
``` ts
|
|
58
|
-
import makeWASocket, { DisconnectReason } from '@
|
|
64
|
+
import makeWASocket, { DisconnectReason } from '@queenanya/baileys'
|
|
59
65
|
import { Boom } from '@hapi/boom'
|
|
60
66
|
|
|
61
67
|
async function connectToWhatsApp () {
|
|
@@ -89,16 +95,6 @@ connectToWhatsApp()
|
|
|
89
95
|
|
|
90
96
|
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!
|
|
91
97
|
|
|
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
|
-
|
|
102
98
|
## Configuring the Connection
|
|
103
99
|
|
|
104
100
|
You can configure the connection by passing a `SocketConfig` object.
|
|
@@ -193,7 +189,7 @@ You obviously don't want to keep scanning the QR code every time you want to con
|
|
|
193
189
|
|
|
194
190
|
So, you can load the credentials to log back in:
|
|
195
191
|
``` ts
|
|
196
|
-
import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@
|
|
192
|
+
import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@queenanya/baileys'
|
|
197
193
|
import * as fs from 'fs'
|
|
198
194
|
|
|
199
195
|
// utility function to help save the auth state in a single folder
|
|
@@ -308,7 +304,7 @@ Baileys does not come with a defacto storage for chats, contacts, or messages. H
|
|
|
308
304
|
It can be used as follows:
|
|
309
305
|
|
|
310
306
|
``` ts
|
|
311
|
-
import makeWASocket, { makeInMemoryStore } from '@
|
|
307
|
+
import makeWASocket, { makeInMemoryStore } from '@queenanya/baileys'
|
|
312
308
|
// the store maintains the data of the WA connection in memory
|
|
313
309
|
// can be written out to a file & read from it
|
|
314
310
|
const store = makeInMemoryStore({ })
|
|
@@ -324,7 +320,7 @@ const sock = makeWASocket({ })
|
|
|
324
320
|
// the store can listen from a new socket once the current socket outlives its lifetime
|
|
325
321
|
store.bind(sock.ev)
|
|
326
322
|
|
|
327
|
-
sock.ev.on('chats.
|
|
323
|
+
sock.ev.on('chats.upsert', () => {
|
|
328
324
|
// can use "store.chats" however you want, even after the socket dies out
|
|
329
325
|
// "chats" => a KeyedDB instance
|
|
330
326
|
console.log('got chats', store.chats.all())
|
|
@@ -347,7 +343,7 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
347
343
|
### Non-Media Messages
|
|
348
344
|
|
|
349
345
|
``` ts
|
|
350
|
-
import { MessageType, MessageOptions, Mimetype } from '@
|
|
346
|
+
import { MessageType, MessageOptions, Mimetype } from '@queenanya/baileys'
|
|
351
347
|
|
|
352
348
|
const id = 'abcd@s.whatsapp.net' // the WhatsApp ID
|
|
353
349
|
// send a simple text!
|
|
@@ -406,7 +402,7 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
|
|
|
406
402
|
- When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
|
|
407
403
|
|
|
408
404
|
``` ts
|
|
409
|
-
import { MessageType, MessageOptions, Mimetype } from '@
|
|
405
|
+
import { MessageType, MessageOptions, Mimetype } from '@queenanya/baileys'
|
|
410
406
|
// Sending gifs
|
|
411
407
|
await sock.sendMessage(
|
|
412
408
|
id,
|
|
@@ -422,7 +418,8 @@ await sock.sendMessage(
|
|
|
422
418
|
{
|
|
423
419
|
video: "./Media/ma_gif.mp4",
|
|
424
420
|
caption: "hello!",
|
|
425
|
-
gifPlayback: true
|
|
421
|
+
gifPlayback: true,
|
|
422
|
+
ptv: false // if set to true, will send as a `video note`
|
|
426
423
|
}
|
|
427
424
|
)
|
|
428
425
|
|
|
@@ -455,7 +452,7 @@ await sock.sendMessage(
|
|
|
455
452
|
Do not enter this field if you want to automatically generate a thumb
|
|
456
453
|
*/
|
|
457
454
|
mimetype: Mimetype.pdf, /* (for media messages) specify the type of media (optional for all media types except documents),
|
|
458
|
-
import {Mimetype} from '@
|
|
455
|
+
import {Mimetype} from '@queenanya/baileys'
|
|
459
456
|
*/
|
|
460
457
|
fileName: 'somefile.pdf', // (for media messages) file name for the media
|
|
461
458
|
/* will send audio messages as voice notes, if set to true */
|
|
@@ -514,7 +511,7 @@ The presence expires after about 10 seconds.
|
|
|
514
511
|
If you want to save the media you received
|
|
515
512
|
``` ts
|
|
516
513
|
import { writeFile } from 'fs/promises'
|
|
517
|
-
import { downloadMediaMessage } from '@
|
|
514
|
+
import { downloadMediaMessage } from '@queenanya/baileys'
|
|
518
515
|
|
|
519
516
|
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
520
517
|
const m = messages[0]
|
|
@@ -801,6 +798,7 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|
|
801
798
|
console.log(response)
|
|
802
799
|
```
|
|
803
800
|
|
|
801
|
+
|
|
804
802
|
## Channel
|
|
805
803
|
- To get newsletter info from code
|
|
806
804
|
```ts
|
|
@@ -816,7 +814,8 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|
|
816
814
|
```
|
|
817
815
|
- To get subscribed newsletters
|
|
818
816
|
```ts
|
|
819
|
-
|
|
817
|
+
|
|
818
|
+
const result = await sock.getSubscribedNewsletters()
|
|
820
819
|
console.log(result)
|
|
821
820
|
```
|
|
822
821
|
- To toggle mute newsletters
|
|
@@ -834,6 +833,7 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|
|
834
833
|
const result = await sock.unFollowNewsletter(jid)
|
|
835
834
|
console.log(result)
|
|
836
835
|
```
|
|
836
|
+
|
|
837
837
|
## Privacy
|
|
838
838
|
- To get the privacy settings
|
|
839
839
|
``` ts
|
|
@@ -867,7 +867,7 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|
|
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'
|
|
871
871
|
await sock.updateGroupsAddPrivacy(value)
|
|
872
872
|
```
|
|
873
873
|
- To update the Default Disappearing Mode
|
package/lib/Defaults/index.d.ts
CHANGED
|
@@ -1,247 +1,17 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { proto } from '../../WAProto';
|
|
3
4
|
import type { MediaType, SocketConfig } from '../Types';
|
|
4
5
|
export declare const UNAUTHORIZED_CODES: number[];
|
|
5
|
-
export declare const PHONENUMBER_MCC: {
|
|
6
|
-
"93": number;
|
|
7
|
-
"355": number;
|
|
8
|
-
"213": number;
|
|
9
|
-
"1-684": number;
|
|
10
|
-
"376": number;
|
|
11
|
-
"244": number;
|
|
12
|
-
"1-264": number;
|
|
13
|
-
"1-268": number;
|
|
14
|
-
"54": number;
|
|
15
|
-
"374": number;
|
|
16
|
-
"297": number;
|
|
17
|
-
"61": number;
|
|
18
|
-
"43": number;
|
|
19
|
-
"994": number;
|
|
20
|
-
"1-242": number;
|
|
21
|
-
"973": number;
|
|
22
|
-
"880": number;
|
|
23
|
-
"1-246": number;
|
|
24
|
-
"375": number;
|
|
25
|
-
"32": number;
|
|
26
|
-
"501": number;
|
|
27
|
-
"229": number;
|
|
28
|
-
"1-441": number;
|
|
29
|
-
"975": number;
|
|
30
|
-
"591": number;
|
|
31
|
-
"387": number;
|
|
32
|
-
"267": number;
|
|
33
|
-
"55": number;
|
|
34
|
-
"1-284": number;
|
|
35
|
-
"673": number;
|
|
36
|
-
"359": number;
|
|
37
|
-
"226": number;
|
|
38
|
-
"257": number;
|
|
39
|
-
"855": number;
|
|
40
|
-
"237": number;
|
|
41
|
-
"238": number;
|
|
42
|
-
"1-345": number;
|
|
43
|
-
"236": number;
|
|
44
|
-
"235": number;
|
|
45
|
-
"56": number;
|
|
46
|
-
"86": number;
|
|
47
|
-
"57": number;
|
|
48
|
-
"269": number;
|
|
49
|
-
"682": number;
|
|
50
|
-
"506": number;
|
|
51
|
-
"385": number;
|
|
52
|
-
"53": number;
|
|
53
|
-
"357": number;
|
|
54
|
-
"420": number;
|
|
55
|
-
"243": number;
|
|
56
|
-
"45": number;
|
|
57
|
-
"253": number;
|
|
58
|
-
"1-767": number;
|
|
59
|
-
"1-809": number;
|
|
60
|
-
"1-849": number;
|
|
61
|
-
"1-829": number;
|
|
62
|
-
"593": number;
|
|
63
|
-
"20": number;
|
|
64
|
-
"503": number;
|
|
65
|
-
"240": number;
|
|
66
|
-
"291": number;
|
|
67
|
-
"372": number;
|
|
68
|
-
"251": number;
|
|
69
|
-
"500": number;
|
|
70
|
-
"298": number;
|
|
71
|
-
"679": number;
|
|
72
|
-
"358": number;
|
|
73
|
-
"33": number;
|
|
74
|
-
"689": number;
|
|
75
|
-
"241": number;
|
|
76
|
-
"220": number;
|
|
77
|
-
"995": number;
|
|
78
|
-
"49": number;
|
|
79
|
-
"233": number;
|
|
80
|
-
"350": number;
|
|
81
|
-
"30": number;
|
|
82
|
-
"299": number;
|
|
83
|
-
"1-473": number;
|
|
84
|
-
"1-671": number;
|
|
85
|
-
"502": number;
|
|
86
|
-
"224": number;
|
|
87
|
-
"592": number;
|
|
88
|
-
"509": number;
|
|
89
|
-
"504": number;
|
|
90
|
-
"852": number;
|
|
91
|
-
"36": number;
|
|
92
|
-
"354": number;
|
|
93
|
-
"91": number;
|
|
94
|
-
"62": number;
|
|
95
|
-
"98": number;
|
|
96
|
-
"964": number;
|
|
97
|
-
"353": number;
|
|
98
|
-
"972": number;
|
|
99
|
-
"39": number;
|
|
100
|
-
"225": number;
|
|
101
|
-
"1-876": number;
|
|
102
|
-
"81": number;
|
|
103
|
-
"962": number;
|
|
104
|
-
"254": number;
|
|
105
|
-
"686": number;
|
|
106
|
-
"383": number;
|
|
107
|
-
"965": number;
|
|
108
|
-
"371": number;
|
|
109
|
-
"961": number;
|
|
110
|
-
"266": number;
|
|
111
|
-
"231": number;
|
|
112
|
-
"218": number;
|
|
113
|
-
"423": number;
|
|
114
|
-
"370": number;
|
|
115
|
-
"352": number;
|
|
116
|
-
"389": number;
|
|
117
|
-
"261": number;
|
|
118
|
-
"265": number;
|
|
119
|
-
"60": number;
|
|
120
|
-
"960": number;
|
|
121
|
-
"223": number;
|
|
122
|
-
"356": number;
|
|
123
|
-
"692": number;
|
|
124
|
-
"222": number;
|
|
125
|
-
"230": number;
|
|
126
|
-
"52": number;
|
|
127
|
-
"691": number;
|
|
128
|
-
"373": number;
|
|
129
|
-
"377": number;
|
|
130
|
-
"976": number;
|
|
131
|
-
"382": number;
|
|
132
|
-
"1-664": number;
|
|
133
|
-
"212": number;
|
|
134
|
-
"258": number;
|
|
135
|
-
"95": number;
|
|
136
|
-
"264": number;
|
|
137
|
-
"674": number;
|
|
138
|
-
"977": number;
|
|
139
|
-
"31": number;
|
|
140
|
-
"687": number;
|
|
141
|
-
"64": number;
|
|
142
|
-
"505": number;
|
|
143
|
-
"227": number;
|
|
144
|
-
"234": number;
|
|
145
|
-
"683": number;
|
|
146
|
-
"1-670": number;
|
|
147
|
-
"47": number;
|
|
148
|
-
"968": number;
|
|
149
|
-
"92": number;
|
|
150
|
-
"680": number;
|
|
151
|
-
"970": number;
|
|
152
|
-
"507": number;
|
|
153
|
-
"675": number;
|
|
154
|
-
"595": number;
|
|
155
|
-
"51": number;
|
|
156
|
-
"63": number;
|
|
157
|
-
"48": number;
|
|
158
|
-
"351": number;
|
|
159
|
-
"1-787, 1-939": number;
|
|
160
|
-
"974": number;
|
|
161
|
-
"242": number;
|
|
162
|
-
"40": number;
|
|
163
|
-
"7": number;
|
|
164
|
-
"250": number;
|
|
165
|
-
"290": number;
|
|
166
|
-
"1-869": number;
|
|
167
|
-
"1-758": number;
|
|
168
|
-
"508": number;
|
|
169
|
-
"1-784": number;
|
|
170
|
-
"685": number;
|
|
171
|
-
"378": number;
|
|
172
|
-
"239": number;
|
|
173
|
-
"966": number;
|
|
174
|
-
"221": number;
|
|
175
|
-
"381": number;
|
|
176
|
-
"248": number;
|
|
177
|
-
"232": number;
|
|
178
|
-
"65": number;
|
|
179
|
-
"386": number;
|
|
180
|
-
"677": number;
|
|
181
|
-
"27": number;
|
|
182
|
-
"211": number;
|
|
183
|
-
"34": number;
|
|
184
|
-
"94": number;
|
|
185
|
-
"249": number;
|
|
186
|
-
"597": number;
|
|
187
|
-
"268": number;
|
|
188
|
-
"46": number;
|
|
189
|
-
"41": number;
|
|
190
|
-
"963": number;
|
|
191
|
-
"886": number;
|
|
192
|
-
"992": number;
|
|
193
|
-
"255": number;
|
|
194
|
-
"66": number;
|
|
195
|
-
"228": number;
|
|
196
|
-
"690": number;
|
|
197
|
-
"676": number;
|
|
198
|
-
"1-868": number;
|
|
199
|
-
"216": number;
|
|
200
|
-
"90": number;
|
|
201
|
-
"993": number;
|
|
202
|
-
"1-649": number;
|
|
203
|
-
"688": number;
|
|
204
|
-
"1-340": number;
|
|
205
|
-
"256": number;
|
|
206
|
-
"380": number;
|
|
207
|
-
"971": number;
|
|
208
|
-
"44": number;
|
|
209
|
-
"1": number;
|
|
210
|
-
"598": number;
|
|
211
|
-
"998": number;
|
|
212
|
-
"678": number;
|
|
213
|
-
"379": number;
|
|
214
|
-
"58": number;
|
|
215
|
-
"681": number;
|
|
216
|
-
"967": number;
|
|
217
|
-
"260": number;
|
|
218
|
-
"263": number;
|
|
219
|
-
"670": number;
|
|
220
|
-
"245": number;
|
|
221
|
-
"856": number;
|
|
222
|
-
"599": number;
|
|
223
|
-
"850": number;
|
|
224
|
-
"262": number;
|
|
225
|
-
"82": number;
|
|
226
|
-
"84": number;
|
|
227
|
-
};
|
|
228
6
|
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
229
|
-
export declare const MOBILE_ENDPOINT = "g.whatsapp.net";
|
|
230
|
-
export declare const MOBILE_PORT = 443;
|
|
231
7
|
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
|
232
8
|
export declare const DEF_TAG_PREFIX = "TAG:";
|
|
233
9
|
export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
234
10
|
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
235
|
-
export declare const MOBILE_TOKEN: Buffer;
|
|
236
|
-
export declare const MOBILE_REGISTRATION_ENDPOINT = "https://v.whatsapp.net/v2";
|
|
237
|
-
export declare const MOBILE_USERAGENT: string;
|
|
238
|
-
export declare const REGISTRATION_PUBLIC_KEY: Buffer;
|
|
239
11
|
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
240
12
|
export declare const DICT_VERSION = 2;
|
|
241
13
|
export declare const KEY_BUNDLE_TYPE: Buffer;
|
|
242
14
|
export declare const NOISE_WA_HEADER: Buffer;
|
|
243
|
-
export declare const PROTOCOL_VERSION: number[];
|
|
244
|
-
export declare const MOBILE_NOISE_HEADER: Buffer;
|
|
245
15
|
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
246
16
|
export declare const URL_REGEX: RegExp;
|
|
247
17
|
export declare const WA_CERT_DETAILS: {
|
package/lib/Defaults/index.js
CHANGED
|
@@ -3,38 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_CACHE_TTLS = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.
|
|
7
|
-
const crypto_1 = require("crypto");
|
|
6
|
+
exports.DEFAULT_CACHE_TTLS = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = void 0;
|
|
8
7
|
const WAProto_1 = require("../../WAProto");
|
|
9
8
|
const libsignal_1 = require("../Signal/libsignal");
|
|
10
9
|
const Utils_1 = require("../Utils");
|
|
11
10
|
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
12
11
|
const baileys_version_json_1 = require("./baileys-version.json");
|
|
13
|
-
const phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"));
|
|
14
12
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
15
|
-
exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default;
|
|
16
13
|
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
17
|
-
exports.MOBILE_ENDPOINT = 'g.whatsapp.net';
|
|
18
|
-
exports.MOBILE_PORT = 443;
|
|
19
14
|
exports.DEF_CALLBACK_PREFIX = 'CB:';
|
|
20
15
|
exports.DEF_TAG_PREFIX = 'TAG:';
|
|
21
16
|
exports.PHONE_CONNECTION_CB = 'CB:Pong';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const WA_VERSION_HASH = (0, crypto_1.createHash)('md5').update(WA_VERSION).digest('hex');
|
|
25
|
-
exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' + WA_VERSION_HASH);
|
|
26
|
-
exports.MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
|
|
27
|
-
exports.MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/15.3.1 Device/Apple-iPhone_7`;
|
|
28
|
-
exports.REGISTRATION_PUBLIC_KEY = Buffer.from([
|
|
29
|
-
5, 142, 140, 15, 116, 195, 235, 197, 215, 166, 134, 92, 108, 60, 132, 56, 86, 176, 97, 33, 204, 232, 234, 119, 77,
|
|
30
|
-
34, 251, 111, 18, 37, 18, 48, 45,
|
|
31
|
-
]);
|
|
17
|
+
// export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60
|
|
18
|
+
exports.WA_DEFAULT_EPHEMERAL = 24 * 60 * 60;
|
|
32
19
|
exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
|
|
33
20
|
exports.DICT_VERSION = 2;
|
|
34
21
|
exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
35
22
|
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]); // last is "DICT_VERSION"
|
|
36
|
-
exports.PROTOCOL_VERSION = [5, 2];
|
|
37
|
-
exports.MOBILE_NOISE_HEADER = Buffer.concat([Buffer.from('WA'), Buffer.from(exports.PROTOCOL_VERSION)]);
|
|
38
23
|
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
39
24
|
exports.URL_REGEX = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/;
|
|
40
25
|
exports.WA_CERT_DETAILS = {
|
|
@@ -44,22 +29,24 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
44
29
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
45
30
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
|
|
46
31
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
|
|
47
|
-
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL
|
|
32
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL,
|
|
33
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
|
|
48
34
|
];
|
|
49
35
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
50
36
|
version: baileys_version_json_1.version,
|
|
51
|
-
browser: Utils_1.Browsers.ubuntu('
|
|
37
|
+
browser: Utils_1.Browsers.ubuntu('Firefox'),
|
|
52
38
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
53
39
|
connectTimeoutMs: 20000,
|
|
54
40
|
keepAliveIntervalMs: 30000,
|
|
55
41
|
logger: logger_1.default.child({ class: 'baileys' }),
|
|
56
|
-
printQRInTerminal:
|
|
42
|
+
printQRInTerminal: true,
|
|
57
43
|
emitOwnEvents: true,
|
|
58
|
-
defaultQueryTimeoutMs:
|
|
44
|
+
defaultQueryTimeoutMs: undefined,
|
|
59
45
|
customUploadHosts: [],
|
|
60
46
|
retryRequestDelayMs: 250,
|
|
61
47
|
maxMsgRetryCount: 5,
|
|
62
48
|
fireInitQueries: true,
|
|
49
|
+
ignoreMsgLoading: false,
|
|
63
50
|
auth: undefined,
|
|
64
51
|
markOnlineOnConnect: true,
|
|
65
52
|
syncFullHistory: false,
|
|
@@ -68,13 +55,14 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
68
55
|
shouldIgnoreJid: () => false,
|
|
69
56
|
linkPreviewImageThumbnailWidth: 192,
|
|
70
57
|
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
71
|
-
generateHighQualityLinkPreview:
|
|
58
|
+
generateHighQualityLinkPreview: true,
|
|
72
59
|
options: {},
|
|
73
60
|
appStateMacVerification: {
|
|
74
61
|
patch: false,
|
|
75
62
|
snapshot: false,
|
|
76
63
|
},
|
|
77
64
|
getMessage: async () => undefined,
|
|
65
|
+
cachedGroupMetadata: async () => undefined,
|
|
78
66
|
makeSignalRepository: libsignal_1.makeLibSignalRepository
|
|
79
67
|
};
|
|
80
68
|
exports.MEDIA_PATH_MAP = {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './web-socket-client';
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './websocket';
|
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./web-socket-client"), exports);
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./websocket"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WebSocket from 'ws';
|
|
2
|
-
import { AbstractSocketClient } from './
|
|
2
|
+
import { AbstractSocketClient } from './types';
|
|
3
3
|
export declare class WebSocketClient extends AbstractSocketClient {
|
|
4
4
|
protected socket: WebSocket | null;
|
|
5
5
|
get isOpen(): boolean;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.WebSocketClient = void 0;
|
|
7
7
|
const ws_1 = __importDefault(require("ws"));
|
|
8
8
|
const Defaults_1 = require("../../Defaults");
|
|
9
|
-
const
|
|
10
|
-
class WebSocketClient extends
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
class WebSocketClient extends types_1.AbstractSocketClient {
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.socket = null;
|