@queenanya/baileys 7.1.0 → 7.1.3
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 +2 -2
- package/lib/Defaults/index.js +4 -4
- package/lib/Socket/business.d.ts +4 -25
- package/lib/Socket/groups.d.ts +2 -2
- package/lib/Socket/index.d.ts +4 -25
- package/lib/Socket/messages-recv.d.ts +4 -25
- package/lib/Socket/messages-recv.js +1 -51
- package/lib/Socket/messages-send.d.ts +1 -22
- package/lib/Socket/messages-send.js +6 -13
- package/lib/Socket/registration.d.ts +4 -25
- package/lib/Types/Events.d.ts +0 -27
- package/lib/Types/Message.d.ts +1 -3
- package/lib/Types/index.d.ts +0 -1
- package/lib/Types/index.js +0 -1
- package/lib/Utils/decode-wa-message.js +6 -16
- package/lib/Utils/generics.d.ts +0 -10
- package/lib/Utils/generics.js +2 -14
- package/lib/Utils/logger.d.ts +1 -3
- package/lib/Utils/messages-media.d.ts +1 -1
- package/lib/Utils/messages-media.js +2 -10
- package/lib/Utils/messages.js +2 -5
- package/lib/WABinary/jid-utils.d.ts +1 -3
- package/lib/WABinary/jid-utils.js +1 -4
- package/package.json +30 -42
- package/lib/Socket/newsletter.d.ts +0 -133
- package/lib/Socket/newsletter.js +0 -249
- package/lib/Types/Newsletter.d.ts +0 -79
- package/lib/Types/Newsletter.js +0 -18
package/README.md
CHANGED
|
@@ -324,13 +324,13 @@ const sock = makeWASocket({ })
|
|
|
324
324
|
// the store can listen from a new socket once the current socket outlives its lifetime
|
|
325
325
|
store.bind(sock.ev)
|
|
326
326
|
|
|
327
|
-
sock.ev.on('chats.
|
|
327
|
+
sock.ev.on('chats.upsert', () => {
|
|
328
328
|
// can use "store.chats" however you want, even after the socket dies out
|
|
329
329
|
// "chats" => a KeyedDB instance
|
|
330
330
|
console.log('got chats', store.chats.all())
|
|
331
331
|
})
|
|
332
332
|
|
|
333
|
-
sock.ev.on('contacts.
|
|
333
|
+
sock.ev.on('contacts.upsert', () => {
|
|
334
334
|
console.log('got contacts', Object.values(store.contacts))
|
|
335
335
|
})
|
|
336
336
|
|
package/lib/Defaults/index.js
CHANGED
|
@@ -48,14 +48,14 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
48
48
|
];
|
|
49
49
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
50
50
|
version: baileys_version_json_1.version,
|
|
51
|
-
browser: Utils_1.Browsers.ubuntu('
|
|
51
|
+
browser: Utils_1.Browsers.ubuntu('Chrome'),
|
|
52
52
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
53
53
|
connectTimeoutMs: 20000,
|
|
54
54
|
keepAliveIntervalMs: 30000,
|
|
55
55
|
logger: logger_1.default.child({ class: 'baileys' }),
|
|
56
|
-
printQRInTerminal:
|
|
56
|
+
printQRInTerminal: false,
|
|
57
57
|
emitOwnEvents: true,
|
|
58
|
-
defaultQueryTimeoutMs:
|
|
58
|
+
defaultQueryTimeoutMs: 60000,
|
|
59
59
|
customUploadHosts: [],
|
|
60
60
|
retryRequestDelayMs: 250,
|
|
61
61
|
maxMsgRetryCount: 5,
|
|
@@ -68,7 +68,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
68
68
|
shouldIgnoreJid: () => false,
|
|
69
69
|
linkPreviewImageThumbnailWidth: 192,
|
|
70
70
|
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
71
|
-
generateHighQualityLinkPreview:
|
|
71
|
+
generateHighQualityLinkPreview: false,
|
|
72
72
|
options: {},
|
|
73
73
|
appStateMacVerification: {
|
|
74
74
|
patch: false,
|
package/lib/Socket/business.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
|
|
3
3
|
import { BinaryNode } from '../WABinary';
|
|
4
4
|
export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
5
|
-
logger: import("pino").Logger<
|
|
5
|
+
logger: import("pino").Logger<never>;
|
|
6
6
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
7
7
|
getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
|
|
8
8
|
products: import("../Types").Product[];
|
|
@@ -23,11 +23,11 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
23
23
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
24
24
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
25
25
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
26
|
-
sendReceipts: (keys: import("../Types").
|
|
26
|
+
sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
27
27
|
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
|
|
28
28
|
[key: string]: string;
|
|
29
29
|
};
|
|
30
|
-
readMessages: (keys: import("../Types").
|
|
30
|
+
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
|
|
31
31
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
32
32
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
33
33
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
@@ -35,27 +35,6 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
35
35
|
}>;
|
|
36
36
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
37
37
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
38
|
-
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
39
|
-
duration: string;
|
|
40
|
-
}>;
|
|
41
|
-
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
42
|
-
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
43
|
-
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
44
|
-
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
45
|
-
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
46
|
-
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
47
|
-
newsletterFollow: (jid: string) => Promise<void>;
|
|
48
|
-
newsletterUnmute: (jid: string) => Promise<void>;
|
|
49
|
-
newsletterMute: (jid: string) => Promise<void>;
|
|
50
|
-
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
51
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
52
|
-
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
53
|
-
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
54
|
-
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
55
|
-
newsletterDelete: (jid: string) => Promise<void>;
|
|
56
|
-
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
|
57
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
58
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
59
38
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
60
39
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
61
40
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -76,7 +55,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
76
55
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
77
56
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
78
57
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
79
|
-
groupAcceptInviteV4: (key: string | import("../Types").
|
|
58
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
80
59
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
81
60
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
82
61
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
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
|
|
3
|
+
import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
|
|
4
4
|
import { BinaryNode } from '../WABinary';
|
|
5
5
|
export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
6
6
|
groupMetadata: (jid: string) => Promise<GroupMetadata>;
|
|
@@ -28,7 +28,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
28
28
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
29
29
|
* @param inviteMessage the message to accept
|
|
30
30
|
*/
|
|
31
|
-
groupAcceptInviteV4: (key: string |
|
|
31
|
+
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
|
|
32
32
|
groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
|
|
33
33
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
34
34
|
groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { UserFacingSocketConfig } from '../Types';
|
|
|
3
3
|
declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
4
4
|
register: (code: string) => Promise<import("./registration").ExistsResponse>;
|
|
5
5
|
requestRegistrationCode: (registrationOptions?: import("./registration").RegistrationOptions | undefined) => Promise<import("./registration").ExistsResponse>;
|
|
6
|
-
logger: import("pino").Logger<
|
|
6
|
+
logger: import("pino").Logger<never>;
|
|
7
7
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
8
8
|
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
9
9
|
products: import("../Types").Product[];
|
|
@@ -24,11 +24,11 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
24
24
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
25
25
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
26
26
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
27
|
-
sendReceipts: (keys: import("../Types").
|
|
27
|
+
sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
28
28
|
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
|
|
29
29
|
[key: string]: string;
|
|
30
30
|
};
|
|
31
|
-
readMessages: (keys: import("../Types").
|
|
31
|
+
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
|
|
32
32
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
33
33
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
34
34
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
@@ -36,27 +36,6 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
36
36
|
}>;
|
|
37
37
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
38
38
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
39
|
-
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
40
|
-
duration: string;
|
|
41
|
-
}>;
|
|
42
|
-
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
43
|
-
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
44
|
-
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
45
|
-
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
46
|
-
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
47
|
-
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
48
|
-
newsletterFollow: (jid: string) => Promise<void>;
|
|
49
|
-
newsletterUnmute: (jid: string) => Promise<void>;
|
|
50
|
-
newsletterMute: (jid: string) => Promise<void>;
|
|
51
|
-
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
52
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
53
|
-
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
54
|
-
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
55
|
-
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
56
|
-
newsletterDelete: (jid: string) => Promise<void>;
|
|
57
|
-
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
|
58
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
59
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
60
39
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
61
40
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
62
41
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -77,7 +56,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
77
56
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
78
57
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
79
58
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
80
|
-
groupAcceptInviteV4: (key: string | import("../Types").
|
|
59
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
81
60
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
82
61
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
83
62
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Boom } from '@hapi/boom';
|
|
3
3
|
import { proto } from '../../WAProto';
|
|
4
|
-
import { MessageReceiptType, MessageRelayOptions, SocketConfig
|
|
4
|
+
import { MessageReceiptType, MessageRelayOptions, SocketConfig } from '../Types';
|
|
5
5
|
import { BinaryNode } from '../WABinary';
|
|
6
6
|
export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
7
7
|
sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
|
|
@@ -11,11 +11,11 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
11
11
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
12
12
|
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
13
13
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
14
|
-
sendReceipts: (keys:
|
|
14
|
+
sendReceipts: (keys: proto.IMessageKey[], type: MessageReceiptType) => Promise<void>;
|
|
15
15
|
getButtonArgs: (message: proto.IMessage) => {
|
|
16
16
|
[key: string]: string;
|
|
17
17
|
};
|
|
18
|
-
readMessages: (keys:
|
|
18
|
+
readMessages: (keys: proto.IMessageKey[]) => Promise<void>;
|
|
19
19
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
20
20
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
21
21
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
@@ -23,27 +23,6 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
23
23
|
}>;
|
|
24
24
|
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
25
25
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
|
|
26
|
-
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
27
|
-
duration: string;
|
|
28
|
-
}>;
|
|
29
|
-
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
30
|
-
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
31
|
-
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
32
|
-
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
33
|
-
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
34
|
-
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
35
|
-
newsletterFollow: (jid: string) => Promise<void>;
|
|
36
|
-
newsletterUnmute: (jid: string) => Promise<void>;
|
|
37
|
-
newsletterMute: (jid: string) => Promise<void>;
|
|
38
|
-
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
39
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
40
|
-
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
41
|
-
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
42
|
-
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
43
|
-
newsletterDelete: (jid: string) => Promise<void>;
|
|
44
|
-
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
|
45
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
46
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
47
26
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
48
27
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
49
28
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -64,7 +43,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
64
43
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
65
44
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
66
45
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
67
|
-
groupAcceptInviteV4: (key: string |
|
|
46
|
+
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
|
|
68
47
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
69
48
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
70
49
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
@@ -256,50 +256,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
256
256
|
break;
|
|
257
257
|
}
|
|
258
258
|
};
|
|
259
|
-
const handleNewsletterNotification = (id, node) => {
|
|
260
|
-
const messages = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
|
|
261
|
-
const message = (0, WABinary_1.getBinaryNodeChild)(messages, 'message');
|
|
262
|
-
const server_id = message.attrs.server_id;
|
|
263
|
-
const reactionsList = (0, WABinary_1.getBinaryNodeChild)(message, 'reactions');
|
|
264
|
-
const viewsList = (0, WABinary_1.getBinaryNodeChildren)(message, 'views_count');
|
|
265
|
-
if (reactionsList) {
|
|
266
|
-
const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionsList, 'reaction');
|
|
267
|
-
if (reactions.length === 0) {
|
|
268
|
-
ev.emit('newsletter.reaction', { id, server_id, reaction: { removed: true } });
|
|
269
|
-
}
|
|
270
|
-
reactions.forEach(item => {
|
|
271
|
-
var _a, _b;
|
|
272
|
-
ev.emit('newsletter.reaction', { id, server_id, reaction: { code: (_a = item.attrs) === null || _a === void 0 ? void 0 : _a.code, count: +((_b = item.attrs) === null || _b === void 0 ? void 0 : _b.count) } });
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
if (viewsList.length) {
|
|
276
|
-
viewsList.forEach(item => {
|
|
277
|
-
ev.emit('newsletter.view', { id, server_id, count: +item.attrs.count });
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
const handleMexNewsletterNotification = (id, node) => {
|
|
282
|
-
var _a;
|
|
283
|
-
const operation = node === null || node === void 0 ? void 0 : node.attrs.op_name;
|
|
284
|
-
const content = JSON.parse((_a = node === null || node === void 0 ? void 0 : node.content) === null || _a === void 0 ? void 0 : _a.toString());
|
|
285
|
-
let contentPath;
|
|
286
|
-
if (operation === Types_1.MexOperations.PROMOTE || operation === Types_1.MexOperations.DEMOTE) {
|
|
287
|
-
let action;
|
|
288
|
-
if (operation === Types_1.MexOperations.PROMOTE) {
|
|
289
|
-
action = 'promote';
|
|
290
|
-
contentPath = content.data[Types_1.XWAPaths.PROMOTE];
|
|
291
|
-
}
|
|
292
|
-
if (operation === Types_1.MexOperations.DEMOTE) {
|
|
293
|
-
action = 'demote';
|
|
294
|
-
contentPath = content.data[Types_1.XWAPaths.DEMOTE];
|
|
295
|
-
}
|
|
296
|
-
ev.emit('newsletter-participants.update', { id, author: contentPath.actor.pn, user: contentPath.user.pn, new_role: contentPath.user_new_role, action });
|
|
297
|
-
}
|
|
298
|
-
if (operation === Types_1.MexOperations.UPDATE) {
|
|
299
|
-
contentPath = content.data[Types_1.XWAPaths.METADATA_UPDATE];
|
|
300
|
-
ev.emit('newsletter-settings.update', { id, update: contentPath.thread_metadata.settings });
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
259
|
const processNotification = async (node) => {
|
|
304
260
|
var _a, _b, _c;
|
|
305
261
|
const result = {};
|
|
@@ -320,12 +276,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
320
276
|
logger.debug({ jid }, 'got privacy token update');
|
|
321
277
|
}
|
|
322
278
|
break;
|
|
323
|
-
case 'newsletter':
|
|
324
|
-
handleNewsletterNotification(node.attrs.from, child);
|
|
325
|
-
break;
|
|
326
|
-
case 'mex':
|
|
327
|
-
handleMexNewsletterNotification(node.attrs.from, child);
|
|
328
|
-
break;
|
|
329
279
|
case 'w:gp2':
|
|
330
280
|
handleGroupNotification(node.attrs.participant, child, result);
|
|
331
281
|
break;
|
|
@@ -717,7 +667,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
717
667
|
await sendMessageAck(node);
|
|
718
668
|
};
|
|
719
669
|
const handleBadAck = async ({ attrs }) => {
|
|
720
|
-
const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id
|
|
670
|
+
const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id };
|
|
721
671
|
// current hypothesis is that if pash is sent in the ack
|
|
722
672
|
// it means -- the message hasn't reached all devices yet
|
|
723
673
|
// we'll retry sending the message here
|
|
@@ -18,27 +18,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
18
18
|
}>;
|
|
19
19
|
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
20
20
|
sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
|
|
21
|
-
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
22
|
-
duration: string;
|
|
23
|
-
}>;
|
|
24
|
-
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
25
|
-
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
26
|
-
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
27
|
-
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
28
|
-
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
29
|
-
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
30
|
-
newsletterFollow: (jid: string) => Promise<void>;
|
|
31
|
-
newsletterUnmute: (jid: string) => Promise<void>;
|
|
32
|
-
newsletterMute: (jid: string) => Promise<void>;
|
|
33
|
-
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
34
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
35
|
-
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
36
|
-
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
37
|
-
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
38
|
-
newsletterDelete: (jid: string) => Promise<void>;
|
|
39
|
-
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
|
40
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
41
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
42
21
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
43
22
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
44
23
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -59,7 +38,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
59
38
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
60
39
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
61
40
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
62
|
-
groupAcceptInviteV4: (key: string |
|
|
41
|
+
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
|
|
63
42
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
64
43
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
65
44
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
@@ -11,11 +11,11 @@ const Defaults_1 = require("../Defaults");
|
|
|
11
11
|
const Utils_1 = require("../Utils");
|
|
12
12
|
const link_preview_1 = require("../Utils/link-preview");
|
|
13
13
|
const WABinary_1 = require("../WABinary");
|
|
14
|
-
const
|
|
14
|
+
const groups_1 = require("./groups");
|
|
15
15
|
var ListType = WAProto_1.proto.Message.ListMessage.ListType;
|
|
16
16
|
const makeMessagesSocket = (config) => {
|
|
17
17
|
const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, } = config;
|
|
18
|
-
const sock = (0,
|
|
18
|
+
const sock = (0, groups_1.makeGroupsSocket)(config);
|
|
19
19
|
const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, generateMessageTag, sendNode, groupMetadata, groupToggleEphemeral } = sock;
|
|
20
20
|
const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
|
|
21
21
|
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,
|
|
@@ -130,6 +130,9 @@ const makeMessagesSocket = (config) => {
|
|
|
130
130
|
users.push({ tag: 'user', attrs: { jid } });
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
+
if (!users.length) {
|
|
134
|
+
return deviceResults;
|
|
135
|
+
}
|
|
133
136
|
const iq = {
|
|
134
137
|
tag: 'iq',
|
|
135
138
|
attrs: {
|
|
@@ -253,13 +256,12 @@ const makeMessagesSocket = (config) => {
|
|
|
253
256
|
const { user, server } = (0, WABinary_1.jidDecode)(jid);
|
|
254
257
|
const statusJid = 'status@broadcast';
|
|
255
258
|
const isGroup = server === 'g.us';
|
|
256
|
-
const isNewsletter = server == 'newsletter';
|
|
257
259
|
const isStatus = jid === statusJid;
|
|
258
260
|
const isLid = server === 'lid';
|
|
259
261
|
msgId = msgId || (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id);
|
|
260
262
|
useUserDevicesCache = useUserDevicesCache !== false;
|
|
261
263
|
const participants = [];
|
|
262
|
-
const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' :
|
|
264
|
+
const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : 's.whatsapp.net') : statusJid;
|
|
263
265
|
const binaryNodeContent = [];
|
|
264
266
|
const devices = [];
|
|
265
267
|
const meMsg = {
|
|
@@ -348,15 +350,6 @@ const makeMessagesSocket = (config) => {
|
|
|
348
350
|
});
|
|
349
351
|
await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
|
|
350
352
|
}
|
|
351
|
-
else if (isNewsletter) {
|
|
352
|
-
const patched = await patchMessageBeforeSending(message, []);
|
|
353
|
-
const bytes = (0, Utils_1.encodeNewsletterMessage)(patched);
|
|
354
|
-
binaryNodeContent.push({
|
|
355
|
-
tag: 'plaintext',
|
|
356
|
-
attrs: {},
|
|
357
|
-
content: bytes
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
353
|
else {
|
|
361
354
|
const { user: meUser, device: meDevice } = (0, WABinary_1.jidDecode)(meId);
|
|
362
355
|
if (!participant) {
|
|
@@ -4,7 +4,7 @@ import { KeyPair, SignedKeyPair, SocketConfig } from '../Types';
|
|
|
4
4
|
export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
5
5
|
register: (code: string) => Promise<ExistsResponse>;
|
|
6
6
|
requestRegistrationCode: (registrationOptions?: RegistrationOptions) => Promise<ExistsResponse>;
|
|
7
|
-
logger: import("pino").Logger<
|
|
7
|
+
logger: import("pino").Logger<never>;
|
|
8
8
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
9
9
|
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
10
10
|
products: import("../Types").Product[];
|
|
@@ -25,11 +25,11 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
25
25
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
26
26
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
27
27
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
28
|
-
sendReceipts: (keys: import("../Types").
|
|
28
|
+
sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
29
29
|
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
|
|
30
30
|
[key: string]: string;
|
|
31
31
|
};
|
|
32
|
-
readMessages: (keys: import("../Types").
|
|
32
|
+
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
|
|
33
33
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
34
34
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
35
35
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
@@ -37,27 +37,6 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
37
37
|
}>;
|
|
38
38
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
39
39
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
40
|
-
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
41
|
-
duration: string;
|
|
42
|
-
}>;
|
|
43
|
-
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
44
|
-
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
45
|
-
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
46
|
-
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
47
|
-
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
48
|
-
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
49
|
-
newsletterFollow: (jid: string) => Promise<void>;
|
|
50
|
-
newsletterUnmute: (jid: string) => Promise<void>;
|
|
51
|
-
newsletterMute: (jid: string) => Promise<void>;
|
|
52
|
-
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
53
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
54
|
-
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
55
|
-
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
56
|
-
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
57
|
-
newsletterDelete: (jid: string) => Promise<void>;
|
|
58
|
-
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
|
59
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
60
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
61
40
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
62
41
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
63
42
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -78,7 +57,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
78
57
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
79
58
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
80
59
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
81
|
-
groupAcceptInviteV4: (key: string | import("../Types").
|
|
60
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
82
61
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
83
62
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
84
63
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
package/lib/Types/Events.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { Label } from './Label';
|
|
|
9
9
|
import { LabelAssociation } from './LabelAssociation';
|
|
10
10
|
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
|
|
11
11
|
import { ConnectionState } from './State';
|
|
12
|
-
import { NewsletterSettingsUpdate, SubscriberAction, NewsletterViewRole } from './Newsletter';
|
|
13
12
|
export type BaileysEventMap = {
|
|
14
13
|
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
|
15
14
|
'connection.update': Partial<ConnectionState>;
|
|
@@ -86,32 +85,6 @@ export type BaileysEventMap = {
|
|
|
86
85
|
action: RequestJoinAction;
|
|
87
86
|
method: RequestJoinMethod;
|
|
88
87
|
};
|
|
89
|
-
'newsletter.reaction': {
|
|
90
|
-
id: string;
|
|
91
|
-
server_id: string;
|
|
92
|
-
reaction: {
|
|
93
|
-
code?: string;
|
|
94
|
-
count?: number;
|
|
95
|
-
removed?: boolean;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
'newsletter.view': {
|
|
99
|
-
id: string;
|
|
100
|
-
server_id: string;
|
|
101
|
-
count: number;
|
|
102
|
-
};
|
|
103
|
-
/**don't handles subscribe/unsubscribe actions */
|
|
104
|
-
'newsletter-participants.update': {
|
|
105
|
-
id: string;
|
|
106
|
-
author: string;
|
|
107
|
-
user: string;
|
|
108
|
-
new_role: NewsletterViewRole;
|
|
109
|
-
action: SubscriberAction;
|
|
110
|
-
};
|
|
111
|
-
'newsletter-settings.update': {
|
|
112
|
-
id: string;
|
|
113
|
-
update: NewsletterSettingsUpdate;
|
|
114
|
-
};
|
|
115
88
|
'blocklist.set': {
|
|
116
89
|
blocklist: string[];
|
|
117
90
|
};
|
package/lib/Types/Message.d.ts
CHANGED
|
@@ -14,9 +14,7 @@ export type WAMessage = proto.IWebMessageInfo;
|
|
|
14
14
|
export type WAMessageContent = proto.IMessage;
|
|
15
15
|
export type WAContactMessage = proto.Message.IContactMessage;
|
|
16
16
|
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
|
|
17
|
-
export type WAMessageKey = proto.IMessageKey
|
|
18
|
-
server_id?: string;
|
|
19
|
-
};
|
|
17
|
+
export type WAMessageKey = proto.IMessageKey;
|
|
20
18
|
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
|
21
19
|
export type WAContextInfo = proto.IContextInfo;
|
|
22
20
|
export type WALocationMessage = proto.Message.ILocationMessage;
|
package/lib/Types/index.d.ts
CHANGED
package/lib/Types/index.js
CHANGED
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.DisconnectReason = void 0;
|
|
18
18
|
__exportStar(require("./Auth"), exports);
|
|
19
19
|
__exportStar(require("./GroupMetadata"), exports);
|
|
20
|
-
__exportStar(require("./Newsletter"), exports);
|
|
21
20
|
__exportStar(require("./Chat"), exports);
|
|
22
21
|
__exportStar(require("./Contact"), exports);
|
|
23
22
|
__exportStar(require("./State"), exports);
|
|
@@ -11,7 +11,6 @@ const NO_MESSAGE_FOUND_ERROR_TEXT = 'Message absent from node';
|
|
|
11
11
|
* @note this will only parse the message, not decrypt it
|
|
12
12
|
*/
|
|
13
13
|
function decodeMessageNode(stanza, meId, meLid) {
|
|
14
|
-
var _a, _b, _c;
|
|
15
14
|
let msgType;
|
|
16
15
|
let chatId;
|
|
17
16
|
let author;
|
|
@@ -55,11 +54,6 @@ function decodeMessageNode(stanza, meId, meLid) {
|
|
|
55
54
|
author = participant;
|
|
56
55
|
chatId = from;
|
|
57
56
|
}
|
|
58
|
-
else if ((0, WABinary_1.isJidNewsletter)(from)) {
|
|
59
|
-
msgType = 'newsletter';
|
|
60
|
-
author = from;
|
|
61
|
-
chatId = from;
|
|
62
|
-
}
|
|
63
57
|
else if ((0, WABinary_1.isJidBroadcast)(from)) {
|
|
64
58
|
if (!participant) {
|
|
65
59
|
throw new boom_1.Boom('No participant in group message');
|
|
@@ -77,14 +71,13 @@ function decodeMessageNode(stanza, meId, meLid) {
|
|
|
77
71
|
else {
|
|
78
72
|
throw new boom_1.Boom('Unknown message type', { data: stanza });
|
|
79
73
|
}
|
|
80
|
-
const fromMe = (
|
|
81
|
-
const pushname =
|
|
74
|
+
const fromMe = ((0, WABinary_1.isLidUser)(from) ? isMeLid : isMe)(stanza.attrs.participant || stanza.attrs.from);
|
|
75
|
+
const pushname = stanza.attrs.notify;
|
|
82
76
|
const key = {
|
|
83
77
|
remoteJid: chatId,
|
|
84
78
|
fromMe,
|
|
85
79
|
id: msgId,
|
|
86
|
-
participant
|
|
87
|
-
server_id: (_c = stanza.attrs) === null || _c === void 0 ? void 0 : _c.server_id
|
|
80
|
+
participant
|
|
88
81
|
};
|
|
89
82
|
const fullMessage = {
|
|
90
83
|
key,
|
|
@@ -118,7 +111,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
118
111
|
const details = WAProto_1.proto.VerifiedNameCertificate.Details.decode(cert.details);
|
|
119
112
|
fullMessage.verifiedBizName = details.verifiedName;
|
|
120
113
|
}
|
|
121
|
-
if (tag !== 'enc'
|
|
114
|
+
if (tag !== 'enc') {
|
|
122
115
|
continue;
|
|
123
116
|
}
|
|
124
117
|
if (!(content instanceof Uint8Array)) {
|
|
@@ -145,14 +138,11 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
145
138
|
ciphertext: content
|
|
146
139
|
});
|
|
147
140
|
break;
|
|
148
|
-
case undefined:
|
|
149
|
-
msgBuffer = content;
|
|
150
|
-
break;
|
|
151
141
|
default:
|
|
152
142
|
throw new Error(`Unknown e2e type: ${e2eType}`);
|
|
153
143
|
}
|
|
154
|
-
let msg = WAProto_1.proto.Message.decode(
|
|
155
|
-
msg = ((_a = msg
|
|
144
|
+
let msg = WAProto_1.proto.Message.decode((0, generics_1.unpadRandomMax16)(msgBuffer));
|
|
145
|
+
msg = ((_a = msg.deviceSentMessage) === null || _a === void 0 ? void 0 : _a.message) || msg;
|
|
156
146
|
if (msg.senderKeyDistributionMessage) {
|
|
157
147
|
try {
|
|
158
148
|
await repository.processSenderKeyDistributionMessage({
|
package/lib/Utils/generics.d.ts
CHANGED
|
@@ -4,15 +4,6 @@ import { Logger } from 'pino';
|
|
|
4
4
|
import { proto } from '../../WAProto';
|
|
5
5
|
import { BaileysEventEmitter, BaileysEventMap, BrowsersMap, WACallUpdateType, WAVersion } from '../Types';
|
|
6
6
|
import { BinaryNode } from '../WABinary';
|
|
7
|
-
/**
|
|
8
|
-
const COMPANION_PLATFORM_MAP = {
|
|
9
|
-
'Chrome': '49',
|
|
10
|
-
'Edge': '50',
|
|
11
|
-
'Firefox': '51',
|
|
12
|
-
'Opera': '53',
|
|
13
|
-
'Safari': '54'
|
|
14
|
-
}
|
|
15
|
-
*/
|
|
16
7
|
export declare const Browsers: BrowsersMap;
|
|
17
8
|
export declare const getPlatformId: (browser: string) => any;
|
|
18
9
|
export declare const BufferJSON: {
|
|
@@ -23,7 +14,6 @@ export declare const getKeyAuthor: (key: proto.IMessageKey | undefined | null, m
|
|
|
23
14
|
export declare const writeRandomPadMax16: (msg: Uint8Array) => Buffer;
|
|
24
15
|
export declare const unpadRandomMax16: (e: Uint8Array | Buffer) => Uint8Array;
|
|
25
16
|
export declare const encodeWAMessage: (message: proto.IMessage) => Buffer;
|
|
26
|
-
export declare const encodeNewsletterMessage: (message: proto.IMessage) => Uint8Array;
|
|
27
17
|
export declare const generateRegistrationId: () => number;
|
|
28
18
|
export declare const encodeBigEndian: (e: number, t?: number) => Uint8Array;
|
|
29
19
|
export declare const toNumber: (t: Long | number | null | undefined) => number;
|