@queenanya/baileys 6.9.2 → 7.0.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 +56 -13
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +5 -2
- package/lib/Socket/business.d.ts +46 -8
- package/lib/Socket/business.js +1 -0
- package/lib/Socket/chats.d.ts +10 -2
- package/lib/Socket/chats.js +42 -3
- package/lib/Socket/groups.d.ts +17 -3
- package/lib/Socket/groups.js +12 -1
- package/lib/Socket/index.d.ts +46 -8
- package/lib/Socket/messages-recv.d.ts +45 -9
- package/lib/Socket/messages-recv.js +184 -22
- package/lib/Socket/messages-send.d.ts +40 -6
- package/lib/Socket/messages-send.js +153 -37
- package/lib/Socket/newsletter.d.ts +140 -0
- package/lib/Socket/newsletter.js +249 -0
- package/lib/Socket/registration.d.ts +46 -11
- package/lib/Socket/socket.js +18 -4
- package/lib/Store/make-in-memory-store.d.ts +2 -2
- package/lib/Store/make-in-memory-store.js +11 -44
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Chat.d.ts +5 -0
- package/lib/Types/Events.d.ts +40 -2
- package/lib/Types/GroupMetadata.d.ts +3 -1
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Message.d.ts +39 -27
- package/lib/Types/Newsletter.d.ts +79 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Socket.d.ts +7 -0
- package/lib/Types/index.d.ts +9 -0
- package/lib/Types/index.js +1 -0
- package/lib/Utils/auth-utils.js +1 -0
- package/lib/Utils/chat-utils.js +16 -0
- package/lib/Utils/crypto.d.ts +1 -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 +50 -22
- package/lib/Utils/generics.d.ts +30 -10
- package/lib/Utils/generics.js +82 -10
- package/lib/Utils/history.d.ts +4 -0
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/logger.d.ts +1 -3
- package/lib/Utils/messages-media.d.ts +10 -1
- package/lib/Utils/messages-media.js +61 -18
- package/lib/Utils/messages.d.ts +2 -1
- package/lib/Utils/messages.js +77 -76
- package/lib/Utils/noise-handler.d.ts +3 -2
- package/lib/Utils/noise-handler.js +18 -5
- package/lib/Utils/process-message.d.ts +3 -2
- package/lib/Utils/process-message.js +53 -21
- package/lib/Utils/signal.js +21 -16
- package/lib/Utils/use-multi-file-auth-state.js +16 -3
- package/lib/WABinary/decode.d.ts +2 -2
- package/lib/WABinary/decode.js +6 -4
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +1 -1
- package/lib/WABinary/jid-utils.d.ts +3 -1
- package/lib/WABinary/jid-utils.js +4 -1
- package/package.json +32 -27
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 () {
|
|
@@ -193,7 +199,7 @@ You obviously don't want to keep scanning the QR code every time you want to con
|
|
|
193
199
|
|
|
194
200
|
So, you can load the credentials to log back in:
|
|
195
201
|
``` ts
|
|
196
|
-
import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@
|
|
202
|
+
import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@queenanya/baileys'
|
|
197
203
|
import * as fs from 'fs'
|
|
198
204
|
|
|
199
205
|
// utility function to help save the auth state in a single folder
|
|
@@ -308,7 +314,7 @@ Baileys does not come with a defacto storage for chats, contacts, or messages. H
|
|
|
308
314
|
It can be used as follows:
|
|
309
315
|
|
|
310
316
|
``` ts
|
|
311
|
-
import makeWASocket, { makeInMemoryStore } from '@
|
|
317
|
+
import makeWASocket, { makeInMemoryStore } from '@queenanya/baileys'
|
|
312
318
|
// the store maintains the data of the WA connection in memory
|
|
313
319
|
// can be written out to a file & read from it
|
|
314
320
|
const store = makeInMemoryStore({ })
|
|
@@ -347,7 +353,7 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
347
353
|
### Non-Media Messages
|
|
348
354
|
|
|
349
355
|
``` ts
|
|
350
|
-
import { MessageType, MessageOptions, Mimetype } from '@
|
|
356
|
+
import { MessageType, MessageOptions, Mimetype } from '@queenanya/baileys'
|
|
351
357
|
|
|
352
358
|
const id = 'abcd@s.whatsapp.net' // the WhatsApp ID
|
|
353
359
|
// send a simple text!
|
|
@@ -406,7 +412,7 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
|
|
|
406
412
|
- When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
|
|
407
413
|
|
|
408
414
|
``` ts
|
|
409
|
-
import { MessageType, MessageOptions, Mimetype } from '@
|
|
415
|
+
import { MessageType, MessageOptions, Mimetype } from '@queenanya/baileys'
|
|
410
416
|
// Sending gifs
|
|
411
417
|
await sock.sendMessage(
|
|
412
418
|
id,
|
|
@@ -422,7 +428,8 @@ await sock.sendMessage(
|
|
|
422
428
|
{
|
|
423
429
|
video: "./Media/ma_gif.mp4",
|
|
424
430
|
caption: "hello!",
|
|
425
|
-
gifPlayback: true
|
|
431
|
+
gifPlayback: true,
|
|
432
|
+
ptv: false // if set to true, will send as a `video note`
|
|
426
433
|
}
|
|
427
434
|
)
|
|
428
435
|
|
|
@@ -455,7 +462,7 @@ await sock.sendMessage(
|
|
|
455
462
|
Do not enter this field if you want to automatically generate a thumb
|
|
456
463
|
*/
|
|
457
464
|
mimetype: Mimetype.pdf, /* (for media messages) specify the type of media (optional for all media types except documents),
|
|
458
|
-
import {Mimetype} from '@
|
|
465
|
+
import {Mimetype} from '@queenanya/baileys'
|
|
459
466
|
*/
|
|
460
467
|
fileName: 'somefile.pdf', // (for media messages) file name for the media
|
|
461
468
|
/* will send audio messages as voice notes, if set to true */
|
|
@@ -514,7 +521,7 @@ The presence expires after about 10 seconds.
|
|
|
514
521
|
If you want to save the media you received
|
|
515
522
|
``` ts
|
|
516
523
|
import { writeFile } from 'fs/promises'
|
|
517
|
-
import { downloadMediaMessage } from '@
|
|
524
|
+
import { downloadMediaMessage } from '@queenanya/baileys'
|
|
518
525
|
|
|
519
526
|
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
520
527
|
const m = messages[0]
|
|
@@ -801,6 +808,42 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|
|
801
808
|
console.log(response)
|
|
802
809
|
```
|
|
803
810
|
|
|
811
|
+
|
|
812
|
+
## Channel
|
|
813
|
+
- To get newsletter info from code
|
|
814
|
+
```ts
|
|
815
|
+
// https://whatsapp.com/channel/key
|
|
816
|
+
const key = '123wedss972279'
|
|
817
|
+
const result = await sock.getNewsletterInfo(key)
|
|
818
|
+
console.log(result)
|
|
819
|
+
```
|
|
820
|
+
- To create newsletter
|
|
821
|
+
```ts
|
|
822
|
+
const result = await sock.createNewsLetter('Name newsletter', 'Description news letter', { url: 'url profile pictur' })
|
|
823
|
+
console.log(result)
|
|
824
|
+
```
|
|
825
|
+
- To get subscribed newsletters
|
|
826
|
+
```ts
|
|
827
|
+
|
|
828
|
+
const result = await sock.getSubscribedNewsletters()
|
|
829
|
+
console.log(result)
|
|
830
|
+
```
|
|
831
|
+
- To toggle mute newsletters
|
|
832
|
+
```ts
|
|
833
|
+
const result = await sock.toggleMuteNewsletter(jid, true) // true to mute, false to unmute
|
|
834
|
+
console.log(result)
|
|
835
|
+
```
|
|
836
|
+
- To follow newsletter
|
|
837
|
+
```ts
|
|
838
|
+
const result = await sock.followNewsletter(jid)
|
|
839
|
+
console.log(result)
|
|
840
|
+
```
|
|
841
|
+
- To unfollow newsletter
|
|
842
|
+
```ts
|
|
843
|
+
const result = await sock.unFollowNewsletter(jid)
|
|
844
|
+
console.log(result)
|
|
845
|
+
```
|
|
846
|
+
|
|
804
847
|
## Privacy
|
|
805
848
|
- To get the privacy settings
|
|
806
849
|
``` ts
|
package/lib/Defaults/index.js
CHANGED
|
@@ -44,11 +44,12 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
44
44
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
45
45
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
|
|
46
46
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
|
|
47
|
-
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL
|
|
47
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL,
|
|
48
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
|
|
48
49
|
];
|
|
49
50
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
50
51
|
version: baileys_version_json_1.version,
|
|
51
|
-
browser: Utils_1.Browsers.ubuntu(
|
|
52
|
+
browser: Utils_1.Browsers.ubuntu('Firefox'),
|
|
52
53
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
53
54
|
connectTimeoutMs: 20000,
|
|
54
55
|
keepAliveIntervalMs: 30000,
|
|
@@ -60,6 +61,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
60
61
|
retryRequestDelayMs: 250,
|
|
61
62
|
maxMsgRetryCount: 5,
|
|
62
63
|
fireInitQueries: true,
|
|
64
|
+
ignoreMsgLoading: false,
|
|
63
65
|
auth: undefined,
|
|
64
66
|
markOnlineOnConnect: true,
|
|
65
67
|
syncFullHistory: false,
|
|
@@ -75,6 +77,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
75
77
|
snapshot: false,
|
|
76
78
|
},
|
|
77
79
|
getMessage: async () => undefined,
|
|
80
|
+
cachedGroupMetadata: async () => undefined,
|
|
78
81
|
makeSignalRepository: libsignal_1.makeLibSignalRepository
|
|
79
82
|
};
|
|
80
83
|
exports.MEDIA_PATH_MAP = {
|
package/lib/Socket/business.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/// <reference types="long" />
|
|
1
2
|
/// <reference types="node" />
|
|
2
3
|
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
|
|
3
4
|
import { BinaryNode } from '../WABinary';
|
|
4
5
|
export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
6
|
+
logger: import("pino").Logger<never>;
|
|
5
7
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
6
8
|
getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
|
|
7
9
|
products: import("../Types").Product[];
|
|
@@ -18,22 +20,50 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
18
20
|
sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
|
|
19
21
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
20
22
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
23
|
+
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
|
|
24
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
21
25
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
22
26
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
23
|
-
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache,
|
|
27
|
+
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
24
28
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
25
|
-
sendReceipts: (keys: import("../Types").
|
|
26
|
-
|
|
27
|
-
[key: string]: string;
|
|
28
|
-
};
|
|
29
|
-
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
|
|
29
|
+
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
30
|
+
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
|
30
31
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
31
32
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
32
33
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
33
34
|
[_: string]: string;
|
|
34
35
|
}>;
|
|
36
|
+
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
37
|
+
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
|
|
38
|
+
[key: string]: string;
|
|
39
|
+
} | undefined) => Promise<{
|
|
40
|
+
nodes: BinaryNode[];
|
|
41
|
+
shouldIncludeDeviceIdentity: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
|
35
44
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
36
45
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
46
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
47
|
+
duration: string;
|
|
48
|
+
}>;
|
|
49
|
+
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
50
|
+
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
51
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
52
|
+
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
53
|
+
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
54
|
+
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
55
|
+
newsletterFollow: (jid: string) => Promise<void>;
|
|
56
|
+
newsletterUnmute: (jid: string) => Promise<void>;
|
|
57
|
+
newsletterMute: (jid: string) => Promise<void>;
|
|
58
|
+
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
59
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
60
|
+
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
61
|
+
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
62
|
+
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
63
|
+
newsletterDelete: (jid: string) => Promise<void>;
|
|
64
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
|
65
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
66
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
37
67
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
38
68
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
39
69
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -54,7 +84,8 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
54
84
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
55
85
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
56
86
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
57
|
-
|
|
87
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
88
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
58
89
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
59
90
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
60
91
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
@@ -76,6 +107,11 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
76
107
|
jid: string;
|
|
77
108
|
}[]>;
|
|
78
109
|
fetchBlocklist: () => Promise<string[]>;
|
|
110
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<{
|
|
111
|
+
user: string;
|
|
112
|
+
duration: number;
|
|
113
|
+
setAt: Date;
|
|
114
|
+
}[]>;
|
|
79
115
|
fetchStatus: (jid: string) => Promise<{
|
|
80
116
|
status: string | undefined;
|
|
81
117
|
setAt: Date;
|
|
@@ -85,17 +121,19 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
85
121
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
86
122
|
updateProfileName: (name: string) => Promise<void>;
|
|
87
123
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
124
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
88
125
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
89
126
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
90
127
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
91
128
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
92
129
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
93
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
130
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
94
131
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
95
132
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
96
133
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
97
134
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
98
135
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
136
|
+
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
99
137
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
100
138
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
101
139
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
package/lib/Socket/business.js
CHANGED
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Boom } from '@hapi/boom';
|
|
3
3
|
import { proto } from '../../WAProto';
|
|
4
|
-
import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
|
4
|
+
import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
|
5
5
|
import { BinaryNode } from '../WABinary';
|
|
6
|
+
import { LabelActionBody } from '../Types/Label';
|
|
6
7
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
7
8
|
processingMutex: {
|
|
8
9
|
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
|
@@ -20,6 +21,11 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
20
21
|
jid: string;
|
|
21
22
|
}[]>;
|
|
22
23
|
fetchBlocklist: () => Promise<string[]>;
|
|
24
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<{
|
|
25
|
+
user: string;
|
|
26
|
+
duration: number;
|
|
27
|
+
setAt: Date;
|
|
28
|
+
}[]>;
|
|
23
29
|
fetchStatus: (jid: string) => Promise<{
|
|
24
30
|
status: string | undefined;
|
|
25
31
|
setAt: Date;
|
|
@@ -29,17 +35,19 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
29
35
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
30
36
|
updateProfileName: (name: string) => Promise<void>;
|
|
31
37
|
updateBlockStatus: (jid: string, action: 'block' | 'unblock') => Promise<void>;
|
|
38
|
+
updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>;
|
|
32
39
|
updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
33
40
|
updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>;
|
|
34
41
|
updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
35
42
|
updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
36
43
|
updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>;
|
|
37
|
-
updateGroupsAddPrivacy: (value:
|
|
44
|
+
updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
|
|
38
45
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
39
46
|
getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
|
|
40
47
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
41
48
|
chatModify: (mod: ChatModification, jid: string) => Promise<void>;
|
|
42
49
|
cleanDirtyBits: (type: 'account_sync' | 'groups', fromTimestamp?: number | string) => Promise<void>;
|
|
50
|
+
addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
|
|
43
51
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
44
52
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
45
53
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
package/lib/Socket/chats.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeChatsSocket = void 0;
|
|
7
7
|
const boom_1 = require("@hapi/boom");
|
|
8
|
+
const node_cache_1 = __importDefault(require("node-cache"));
|
|
8
9
|
const WAProto_1 = require("../../WAProto");
|
|
9
10
|
const Defaults_1 = require("../Defaults");
|
|
10
11
|
const Types_1 = require("../Types");
|
|
@@ -23,6 +24,13 @@ const makeChatsSocket = (config) => {
|
|
|
23
24
|
let pendingAppStateSync = false;
|
|
24
25
|
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
|
|
25
26
|
const processingMutex = (0, make_mutex_1.makeMutex)();
|
|
27
|
+
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
28
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
29
|
+
useClones: false
|
|
30
|
+
});
|
|
31
|
+
if (!config.placeholderResendCache) {
|
|
32
|
+
config.placeholderResendCache = placeholderResendCache;
|
|
33
|
+
}
|
|
26
34
|
/** helper function to fetch the given app state sync key */
|
|
27
35
|
const getAppStateSyncKey = async (keyId) => {
|
|
28
36
|
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
|
|
@@ -66,6 +74,9 @@ const makeChatsSocket = (config) => {
|
|
|
66
74
|
}]
|
|
67
75
|
});
|
|
68
76
|
};
|
|
77
|
+
const updateCallPrivacy = async (value) => {
|
|
78
|
+
await privacyQuery('calladd', value);
|
|
79
|
+
};
|
|
69
80
|
const updateLastSeenPrivacy = async (value) => {
|
|
70
81
|
await privacyQuery('last', value);
|
|
71
82
|
};
|
|
@@ -170,6 +181,19 @@ const makeChatsSocket = (config) => {
|
|
|
170
181
|
};
|
|
171
182
|
}
|
|
172
183
|
};
|
|
184
|
+
/** Fetching The Disappearing Duration of a specific chats by their jids*/
|
|
185
|
+
const fetchDisappearingDuration = async (...jids) => {
|
|
186
|
+
const list = jids.map((jid) => ({ tag: 'user', attrs: { jid } }));
|
|
187
|
+
const results = await interactiveQuery(list, { tag: 'disappearing_mode', attrs: {} });
|
|
188
|
+
return results.map(item => {
|
|
189
|
+
const result = (0, WABinary_1.getBinaryNodeChild)(item, 'disappearing_mode');
|
|
190
|
+
return {
|
|
191
|
+
user: item.attrs.jid,
|
|
192
|
+
duration: parseInt(result === null || result === void 0 ? void 0 : result.attrs.duration),
|
|
193
|
+
setAt: new Date(+((result === null || result === void 0 ? void 0 : result.attrs.t) || 0) * 1000)
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
};
|
|
173
197
|
/** update the profile picture for yourself or a group */
|
|
174
198
|
const updateProfilePicture = async (jid, content) => {
|
|
175
199
|
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
@@ -442,7 +466,8 @@ const makeChatsSocket = (config) => {
|
|
|
442
466
|
const result = await query({
|
|
443
467
|
tag: 'iq',
|
|
444
468
|
attrs: {
|
|
445
|
-
|
|
469
|
+
target: jid,
|
|
470
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
446
471
|
type: 'get',
|
|
447
472
|
xmlns: 'w:profile:picture'
|
|
448
473
|
},
|
|
@@ -511,7 +536,7 @@ const makeChatsSocket = (config) => {
|
|
|
511
536
|
let presence;
|
|
512
537
|
const jid = attrs.from;
|
|
513
538
|
const participant = attrs.participant || attrs.from;
|
|
514
|
-
if (shouldIgnoreJid(jid)) {
|
|
539
|
+
if (shouldIgnoreJid(jid) && jid !== '@s.whatsapp.net') {
|
|
515
540
|
return;
|
|
516
541
|
}
|
|
517
542
|
if (tag === 'presence') {
|
|
@@ -610,7 +635,7 @@ const makeChatsSocket = (config) => {
|
|
|
610
635
|
content: [
|
|
611
636
|
{ tag: 'props', attrs: {
|
|
612
637
|
protocol: '2',
|
|
613
|
-
hash: ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.lastPropHash) ||
|
|
638
|
+
hash: ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.lastPropHash) || ''
|
|
614
639
|
} }
|
|
615
640
|
]
|
|
616
641
|
});
|
|
@@ -644,6 +669,16 @@ const makeChatsSocket = (config) => {
|
|
|
644
669
|
}
|
|
645
670
|
}, jid);
|
|
646
671
|
};
|
|
672
|
+
/**
|
|
673
|
+
* Adds label
|
|
674
|
+
*/
|
|
675
|
+
const addLabel = (jid, labels) => {
|
|
676
|
+
return chatModify({
|
|
677
|
+
addLabel: {
|
|
678
|
+
...labels
|
|
679
|
+
}
|
|
680
|
+
}, jid);
|
|
681
|
+
};
|
|
647
682
|
/**
|
|
648
683
|
* Adds label for the chats
|
|
649
684
|
*/
|
|
@@ -730,6 +765,7 @@ const makeChatsSocket = (config) => {
|
|
|
730
765
|
})(),
|
|
731
766
|
(0, process_message_1.default)(msg, {
|
|
732
767
|
shouldProcessHistoryMsg,
|
|
768
|
+
placeholderResendCache,
|
|
733
769
|
ev,
|
|
734
770
|
creds: authState.creds,
|
|
735
771
|
keyStore: authState.keys,
|
|
@@ -811,12 +847,14 @@ const makeChatsSocket = (config) => {
|
|
|
811
847
|
profilePictureUrl,
|
|
812
848
|
onWhatsApp,
|
|
813
849
|
fetchBlocklist,
|
|
850
|
+
fetchDisappearingDuration,
|
|
814
851
|
fetchStatus,
|
|
815
852
|
updateProfilePicture,
|
|
816
853
|
removeProfilePicture,
|
|
817
854
|
updateProfileStatus,
|
|
818
855
|
updateProfileName,
|
|
819
856
|
updateBlockStatus,
|
|
857
|
+
updateCallPrivacy,
|
|
820
858
|
updateLastSeenPrivacy,
|
|
821
859
|
updateOnlinePrivacy,
|
|
822
860
|
updateProfilePicturePrivacy,
|
|
@@ -828,6 +866,7 @@ const makeChatsSocket = (config) => {
|
|
|
828
866
|
resyncAppState,
|
|
829
867
|
chatModify,
|
|
830
868
|
cleanDirtyBits,
|
|
869
|
+
addLabel,
|
|
831
870
|
addChatLabel,
|
|
832
871
|
removeChatLabel,
|
|
833
872
|
addMessageLabel,
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { proto } from '../../WAProto';
|
|
3
|
-
import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
|
|
3
|
+
import { GroupMetadata, ParticipantAction, SocketConfig, WAMessageKey } from '../Types';
|
|
4
4
|
import { BinaryNode } from '../WABinary';
|
|
5
5
|
export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
6
6
|
groupMetadata: (jid: string) => Promise<GroupMetadata>;
|
|
@@ -23,12 +23,19 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
23
23
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
24
24
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
25
25
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* revoke a v4 invite for someone
|
|
28
|
+
* @param groupJid group jid
|
|
29
|
+
* @param invitedJid jid of person you invited
|
|
30
|
+
* @returns true if successful
|
|
31
|
+
*/
|
|
32
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
26
33
|
/**
|
|
27
34
|
* accept a GroupInviteMessage
|
|
28
35
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
29
36
|
* @param inviteMessage the message to accept
|
|
30
37
|
*/
|
|
31
|
-
groupAcceptInviteV4: (key: string |
|
|
38
|
+
groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
|
|
32
39
|
groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
|
|
33
40
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
34
41
|
groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
|
|
@@ -53,6 +60,11 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
53
60
|
jid: string;
|
|
54
61
|
}[]>;
|
|
55
62
|
fetchBlocklist: () => Promise<string[]>;
|
|
63
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<{
|
|
64
|
+
user: string;
|
|
65
|
+
duration: number;
|
|
66
|
+
setAt: Date;
|
|
67
|
+
}[]>;
|
|
56
68
|
fetchStatus: (jid: string) => Promise<{
|
|
57
69
|
status: string | undefined;
|
|
58
70
|
setAt: Date;
|
|
@@ -62,17 +74,19 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
62
74
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
63
75
|
updateProfileName: (name: string) => Promise<void>;
|
|
64
76
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
77
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
65
78
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
66
79
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
67
80
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
68
81
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
69
82
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
70
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
83
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
71
84
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
72
85
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
73
86
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
74
87
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
75
88
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
89
|
+
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
76
90
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
77
91
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
78
92
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
package/lib/Socket/groups.js
CHANGED
|
@@ -187,12 +187,23 @@ const makeGroupsSocket = (config) => {
|
|
|
187
187
|
const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
|
|
188
188
|
return result === null || result === void 0 ? void 0 : result.attrs.jid;
|
|
189
189
|
},
|
|
190
|
+
/**
|
|
191
|
+
* revoke a v4 invite for someone
|
|
192
|
+
* @param groupJid group jid
|
|
193
|
+
* @param invitedJid jid of person you invited
|
|
194
|
+
* @returns true if successful
|
|
195
|
+
*/
|
|
196
|
+
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
197
|
+
const result = await groupQuery(groupJid, 'set', [{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }]);
|
|
198
|
+
return !!result;
|
|
199
|
+
},
|
|
190
200
|
/**
|
|
191
201
|
* accept a GroupInviteMessage
|
|
192
202
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
193
203
|
* @param inviteMessage the message to accept
|
|
194
204
|
*/
|
|
195
205
|
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
206
|
+
var _a;
|
|
196
207
|
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
197
208
|
const results = await groupQuery(inviteMessage.groupJid, 'set', [{
|
|
198
209
|
tag: 'accept',
|
|
@@ -224,7 +235,7 @@ const makeGroupsSocket = (config) => {
|
|
|
224
235
|
await upsertMessage({
|
|
225
236
|
key: {
|
|
226
237
|
remoteJid: inviteMessage.groupJid,
|
|
227
|
-
id: (0, Utils_1.
|
|
238
|
+
id: (0, Utils_1.generateMessageIDV3)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
|
|
228
239
|
fromMe: false,
|
|
229
240
|
participant: key.remoteJid,
|
|
230
241
|
},
|