@d0v3riz/baileys 6.7.17 → 6.7.18
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/lib/Socket/business.d.ts +5 -5
- package/lib/Socket/chats.d.ts +3 -3
- package/lib/Socket/groups.d.ts +4 -4
- package/lib/Socket/groups.js +3 -2
- package/lib/Socket/index.d.ts +5 -5
- package/lib/Socket/messages-recv.d.ts +5 -5
- package/lib/Socket/messages-send.d.ts +5 -5
- package/lib/Socket/messages-send.js +7 -1
- package/lib/Socket/socket.d.ts +3 -3
- package/lib/Socket/socket.js +6 -4
- package/lib/Socket/usync.d.ts +3 -3
- package/lib/Types/GroupMetadata.d.ts +2 -0
- package/lib/Utils/decode-wa-message.js +3 -16
- package/lib/Utils/generics.js +1 -1
- package/lib/Utils/messages-media.js +2 -2
- package/lib/Utils/messages.js +1 -1
- package/lib/WABinary/decode.js +3 -2
- package/lib/WABinary/jid-utils.d.ts +2 -0
- package/lib/WABinary/jid-utils.js +4 -1
- package/package.json +1 -1
package/lib/Socket/business.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
20
20
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
21
21
|
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").default) => Promise<string>;
|
|
22
22
|
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
23
|
-
getPrivacyTokens: (jids: string[]) => Promise<
|
|
23
|
+
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
24
24
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
25
25
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
26
26
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
@@ -60,7 +60,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
60
60
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
61
61
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
62
62
|
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
63
|
-
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<
|
|
63
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
|
|
64
64
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
65
65
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
66
66
|
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
@@ -130,8 +130,8 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
130
130
|
signalRepository: import("../Types").SignalRepository;
|
|
131
131
|
user: import("../Types").Contact | undefined;
|
|
132
132
|
generateMessageTag: () => string;
|
|
133
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
134
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
133
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
134
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
135
135
|
waitForSocketOpen: () => Promise<void>;
|
|
136
136
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
137
137
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -142,5 +142,5 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
142
142
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
143
143
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
144
144
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
145
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
145
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
146
146
|
};
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -69,8 +69,8 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
69
69
|
signalRepository: import("../Types").SignalRepository;
|
|
70
70
|
user: import("../Types").Contact | undefined;
|
|
71
71
|
generateMessageTag: () => string;
|
|
72
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
73
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
72
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
73
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
74
74
|
waitForSocketOpen: () => Promise<void>;
|
|
75
75
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
76
76
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -81,5 +81,5 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
81
81
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
82
82
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
83
83
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
84
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
84
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
85
85
|
};
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
34
34
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
35
35
|
* @param inviteMessage the message to accept
|
|
36
36
|
*/
|
|
37
|
-
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<
|
|
37
|
+
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
|
|
38
38
|
groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
|
|
39
39
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
40
40
|
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
@@ -107,8 +107,8 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
107
107
|
signalRepository: import("../Types").SignalRepository;
|
|
108
108
|
user: import("../Types").Contact | undefined;
|
|
109
109
|
generateMessageTag: () => string;
|
|
110
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
111
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
110
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
111
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
112
112
|
waitForSocketOpen: () => Promise<void>;
|
|
113
113
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
114
114
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -119,6 +119,6 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
119
119
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
120
120
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
121
121
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
122
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
122
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
123
123
|
};
|
|
124
124
|
export declare const extractGroupMetadata: (result: BinaryNode) => GroupMetadata;
|
package/lib/Socket/groups.js
CHANGED
|
@@ -69,7 +69,7 @@ const makeGroupsSocket = (config) => {
|
|
|
69
69
|
...sock,
|
|
70
70
|
groupMetadata,
|
|
71
71
|
groupCreate: async (subject, participants) => {
|
|
72
|
-
const key = (0, Utils_1.
|
|
72
|
+
const key = (0, Utils_1.generateMessageIDV2)();
|
|
73
73
|
const result = await groupQuery('@g.us', 'set', [
|
|
74
74
|
{
|
|
75
75
|
tag: 'create',
|
|
@@ -163,7 +163,7 @@ const makeGroupsSocket = (config) => {
|
|
|
163
163
|
{
|
|
164
164
|
tag: 'description',
|
|
165
165
|
attrs: {
|
|
166
|
-
...(description ? { id: (0, Utils_1.
|
|
166
|
+
...(description ? { id: (0, Utils_1.generateMessageIDV2)() } : { delete: 'true' }),
|
|
167
167
|
...(prev ? { prev } : {})
|
|
168
168
|
},
|
|
169
169
|
content: description ? [
|
|
@@ -286,6 +286,7 @@ const extractGroupMetadata = (result) => {
|
|
|
286
286
|
const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
|
|
287
287
|
const metadata = {
|
|
288
288
|
id: groupId,
|
|
289
|
+
addressingMode: group.attrs.addressing_mode,
|
|
289
290
|
subject: group.attrs.subject,
|
|
290
291
|
subjectOwner: group.attrs.s_o,
|
|
291
292
|
subjectTime: +group.attrs.s_t,
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
19
19
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
20
20
|
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").default) => Promise<string>;
|
|
21
21
|
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
22
|
-
getPrivacyTokens: (jids: string[]) => Promise<
|
|
22
|
+
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
23
23
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
24
24
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
25
25
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
@@ -59,7 +59,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
59
59
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
60
60
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
61
61
|
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
62
|
-
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<
|
|
62
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
|
|
63
63
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
64
64
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
65
65
|
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
@@ -129,8 +129,8 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
129
129
|
signalRepository: import("../Types").SignalRepository;
|
|
130
130
|
user: import("../Types").Contact | undefined;
|
|
131
131
|
generateMessageTag: () => string;
|
|
132
|
-
query: (node: import("..").BinaryNode, timeoutMs?: number) => Promise<
|
|
133
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
132
|
+
query: (node: import("..").BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
133
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
134
134
|
waitForSocketOpen: () => Promise<void>;
|
|
135
135
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
136
136
|
sendNode: (frame: import("..").BinaryNode) => Promise<void>;
|
|
@@ -141,6 +141,6 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
141
141
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
142
142
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
143
143
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
144
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
144
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
145
145
|
};
|
|
146
146
|
export default makeWASocket;
|
|
@@ -9,7 +9,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
9
9
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
10
10
|
fetchMessageHistory: (count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
11
11
|
requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<string | undefined>;
|
|
12
|
-
getPrivacyTokens: (jids: string[]) => Promise<
|
|
12
|
+
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
13
13
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
14
14
|
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
15
15
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
@@ -49,7 +49,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
49
49
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
50
50
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
51
51
|
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
52
|
-
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<
|
|
52
|
+
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
|
|
53
53
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
54
54
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
55
55
|
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
@@ -119,8 +119,8 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
119
119
|
signalRepository: import("../Types").SignalRepository;
|
|
120
120
|
user: import("../Types").Contact | undefined;
|
|
121
121
|
generateMessageTag: () => string;
|
|
122
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
123
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
122
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
123
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
124
124
|
waitForSocketOpen: () => Promise<void>;
|
|
125
125
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
126
126
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -131,5 +131,5 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
131
131
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
132
132
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
133
133
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
134
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
134
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
135
135
|
};
|
|
@@ -4,7 +4,7 @@ import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptio
|
|
|
4
4
|
import { BinaryNode, JidWithDevice } from '../WABinary';
|
|
5
5
|
import { USyncQuery } from '../WAUSync';
|
|
6
6
|
export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
7
|
-
getPrivacyTokens: (jids: string[]) => Promise<
|
|
7
|
+
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
8
8
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
9
9
|
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
10
10
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
@@ -44,7 +44,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
44
44
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
45
45
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
46
46
|
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
47
|
-
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<
|
|
47
|
+
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
|
|
48
48
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
49
49
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
50
50
|
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
@@ -114,8 +114,8 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
114
114
|
signalRepository: import("../Types").SignalRepository;
|
|
115
115
|
user: import("../Types").Contact | undefined;
|
|
116
116
|
generateMessageTag: () => string;
|
|
117
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
118
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
117
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
118
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
119
119
|
waitForSocketOpen: () => Promise<void>;
|
|
120
120
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
121
121
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -126,5 +126,5 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
126
126
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
127
127
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
128
128
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
129
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
129
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
130
130
|
};
|
|
@@ -325,6 +325,12 @@ const makeMessagesSocket = (config) => {
|
|
|
325
325
|
if (isStatus && statusJidList) {
|
|
326
326
|
participantsList.push(...statusJidList);
|
|
327
327
|
}
|
|
328
|
+
if (!isStatus) {
|
|
329
|
+
additionalAttributes = {
|
|
330
|
+
...additionalAttributes,
|
|
331
|
+
addressing_mode: (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) || 'pn'
|
|
332
|
+
};
|
|
333
|
+
}
|
|
328
334
|
const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false);
|
|
329
335
|
devices.push(...additionalDevices);
|
|
330
336
|
}
|
|
@@ -341,7 +347,7 @@ const makeMessagesSocket = (config) => {
|
|
|
341
347
|
const senderKeyJids = [];
|
|
342
348
|
// ensure a connection is established with every device
|
|
343
349
|
for (const { user, device } of devices) {
|
|
344
|
-
const jid = (0, WABinary_1.jidEncode)(user,
|
|
350
|
+
const jid = (0, WABinary_1.jidEncode)(user, (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) === 'lid' ? 'lid' : 's.whatsapp.net', device);
|
|
345
351
|
if (!senderKeyMap[jid] || !!participant) {
|
|
346
352
|
senderKeyJids.push(jid);
|
|
347
353
|
// store that this person has had the sender keys sent to them
|
package/lib/Socket/socket.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ export declare const makeSocket: (config: SocketConfig) => {
|
|
|
25
25
|
signalRepository: import("../Types").SignalRepository;
|
|
26
26
|
readonly user: import("../Types").Contact | undefined;
|
|
27
27
|
generateMessageTag: () => string;
|
|
28
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
29
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
28
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
29
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
30
30
|
waitForSocketOpen: () => Promise<void>;
|
|
31
31
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
32
32
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -38,5 +38,5 @@ export declare const makeSocket: (config: SocketConfig) => {
|
|
|
38
38
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
39
39
|
/** Waits for the connection to WA to reach a state */
|
|
40
40
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
41
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
41
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
42
42
|
};
|
package/lib/Socket/socket.js
CHANGED
|
@@ -117,7 +117,7 @@ const makeSocket = (config) => {
|
|
|
117
117
|
let onRecv;
|
|
118
118
|
let onErr;
|
|
119
119
|
try {
|
|
120
|
-
|
|
120
|
+
const result = await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
|
|
121
121
|
onRecv = resolve;
|
|
122
122
|
onErr = err => {
|
|
123
123
|
reject(err || new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
|
|
@@ -126,6 +126,7 @@ const makeSocket = (config) => {
|
|
|
126
126
|
ws.on('close', onErr); // if the socket closes, you'll never receive the message
|
|
127
127
|
ws.off('error', onErr);
|
|
128
128
|
});
|
|
129
|
+
return result;
|
|
129
130
|
}
|
|
130
131
|
finally {
|
|
131
132
|
ws.off(`TAG:${msgId}`, onRecv);
|
|
@@ -139,9 +140,10 @@ const makeSocket = (config) => {
|
|
|
139
140
|
node.attrs.id = generateMessageTag();
|
|
140
141
|
}
|
|
141
142
|
const msgId = node.attrs.id;
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
const [result] = await Promise.all([
|
|
144
|
+
waitForMessage(msgId, timeoutMs),
|
|
145
|
+
sendNode(node)
|
|
146
|
+
]);
|
|
145
147
|
if ('tag' in result) {
|
|
146
148
|
(0, WABinary_1.assertNodeErrorFree)(result);
|
|
147
149
|
}
|
package/lib/Socket/usync.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
|
20
20
|
signalRepository: import("../Types").SignalRepository;
|
|
21
21
|
user: import("../Types").Contact | undefined;
|
|
22
22
|
generateMessageTag: () => string;
|
|
23
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
24
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
23
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
24
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
25
25
|
waitForSocketOpen: () => Promise<void>;
|
|
26
26
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
27
27
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -32,5 +32,5 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
|
32
32
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
33
33
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
34
34
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
35
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
35
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
36
36
|
};
|
|
@@ -9,6 +9,8 @@ export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
|
|
|
9
9
|
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
|
|
10
10
|
export interface GroupMetadata {
|
|
11
11
|
id: string;
|
|
12
|
+
/** group uses 'lid' or 'pn' to send messages */
|
|
13
|
+
addressingMode: "pn" | "lid";
|
|
12
14
|
owner: string | undefined;
|
|
13
15
|
subject: string;
|
|
14
16
|
/** group subject owner */
|
|
@@ -38,22 +38,9 @@ function decodeMessageNode(stanza, meId, meLid) {
|
|
|
38
38
|
const recipient = stanza.attrs.recipient;
|
|
39
39
|
const isMe = (jid) => (0, WABinary_1.areJidsSameUser)(jid, meId);
|
|
40
40
|
const isMeLid = (jid) => (0, WABinary_1.areJidsSameUser)(jid, meLid);
|
|
41
|
-
if ((0, WABinary_1.isJidUser)(from)) {
|
|
42
|
-
if (recipient) {
|
|
43
|
-
if (!isMe(from)) {
|
|
44
|
-
throw new boom_1.Boom('receipient present, but msg not from me', { data: stanza });
|
|
45
|
-
}
|
|
46
|
-
chatId = recipient;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
chatId = from;
|
|
50
|
-
}
|
|
51
|
-
msgType = 'chat';
|
|
52
|
-
author = from;
|
|
53
|
-
}
|
|
54
|
-
else if ((0, WABinary_1.isLidUser)(from)) {
|
|
55
|
-
if (recipient) {
|
|
56
|
-
if (!isMeLid(from)) {
|
|
41
|
+
if ((0, WABinary_1.isJidUser)(from) || (0, WABinary_1.isLidUser)(from)) {
|
|
42
|
+
if (recipient && !(0, WABinary_1.isJidMetaIa)(recipient)) {
|
|
43
|
+
if (!isMe(from) && !isMeLid(from)) {
|
|
57
44
|
throw new boom_1.Boom('receipient present, but msg not from me', { data: stanza });
|
|
58
45
|
}
|
|
59
46
|
chatId = recipient;
|
package/lib/Utils/generics.js
CHANGED
|
@@ -35,7 +35,7 @@ exports.Browsers = {
|
|
|
35
35
|
};
|
|
36
36
|
const getPlatformId = (browser) => {
|
|
37
37
|
const platformType = WAProto_1.proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
38
|
-
return platformType ? platformType.toString()
|
|
38
|
+
return platformType ? platformType.toString() : '1'; //chrome
|
|
39
39
|
};
|
|
40
40
|
exports.getPlatformId = getPlatformId;
|
|
41
41
|
exports.BufferJSON = {
|
|
@@ -309,7 +309,7 @@ async function generateThumbnail(file, mediaType, options) {
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
else if (mediaType === 'video') {
|
|
312
|
-
const imgFilename = (0, path_1.join)(getTmpFilesDirectory(), (0, generics_1.
|
|
312
|
+
const imgFilename = (0, path_1.join)(getTmpFilesDirectory(), (0, generics_1.generateMessageIDV2)() + '.jpg');
|
|
313
313
|
try {
|
|
314
314
|
await extractVideoThumb(file, imgFilename, '00:00:00', { width: 32, height: 32 });
|
|
315
315
|
const buff = await fs_1.promises.readFile(imgFilename);
|
|
@@ -343,7 +343,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
343
343
|
bodyPath = media.url.toString();
|
|
344
344
|
}
|
|
345
345
|
else if (saveOriginalFileIfRequired) {
|
|
346
|
-
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.
|
|
346
|
+
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.generateMessageIDV2)());
|
|
347
347
|
writeStream = (0, fs_1.createWriteStream)(bodyPath);
|
|
348
348
|
didSaveToTmpPath = true;
|
|
349
349
|
}
|
package/lib/Utils/messages.js
CHANGED
|
@@ -497,7 +497,7 @@ const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
497
497
|
key: {
|
|
498
498
|
remoteJid: jid,
|
|
499
499
|
fromMe: true,
|
|
500
|
-
id: (options === null || options === void 0 ? void 0 : options.messageId) || (0, generics_1.
|
|
500
|
+
id: (options === null || options === void 0 ? void 0 : options.messageId) || (0, generics_1.generateMessageIDV2)(),
|
|
501
501
|
},
|
|
502
502
|
message: message,
|
|
503
503
|
messageTimestamp: timestamp,
|
package/lib/WABinary/decode.js
CHANGED
|
@@ -156,10 +156,11 @@ const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) =>
|
|
|
156
156
|
throw new Error('invalid jid pair: ' + i + ', ' + j);
|
|
157
157
|
};
|
|
158
158
|
const readAdJid = () => {
|
|
159
|
-
const
|
|
159
|
+
const rawDomainType = readByte();
|
|
160
|
+
const domainType = Number(rawDomainType);
|
|
160
161
|
const device = readByte();
|
|
161
162
|
const user = readString(readByte());
|
|
162
|
-
return (0, jid_utils_1.jidEncode)(user,
|
|
163
|
+
return (0, jid_utils_1.jidEncode)(user, domainType === 0 || domainType === 128 ? 's.whatsapp.net' : 'lid', device);
|
|
163
164
|
};
|
|
164
165
|
const readString = (tag) => {
|
|
165
166
|
if (tag >= 1 && tag < SINGLE_BYTE_TOKENS.length) {
|
|
@@ -17,6 +17,8 @@ export declare const jidEncode: (user: string | number | null, server: JidServer
|
|
|
17
17
|
export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;
|
|
18
18
|
/** is the jid a user */
|
|
19
19
|
export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean;
|
|
20
|
+
/** is the jid Meta IA */
|
|
21
|
+
export declare const isJidMetaIa: (jid: string | undefined) => boolean | undefined;
|
|
20
22
|
/** is the jid a user */
|
|
21
23
|
export declare const isJidUser: (jid: string | undefined) => boolean | undefined;
|
|
22
24
|
/** is the jid a group */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jidNormalizedUser = exports.isJidBot = exports.isJidNewsletter = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.META_AI_JID = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
|
|
3
|
+
exports.jidNormalizedUser = exports.isJidBot = exports.isJidNewsletter = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.isJidMetaIa = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.META_AI_JID = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
|
|
4
4
|
exports.S_WHATSAPP_NET = '@s.whatsapp.net';
|
|
5
5
|
exports.OFFICIAL_BIZ_JID = '16505361212@c.us';
|
|
6
6
|
exports.SERVER_JID = 'server@c.us';
|
|
@@ -34,6 +34,9 @@ const areJidsSameUser = (jid1, jid2) => {
|
|
|
34
34
|
return (((_a = (0, exports.jidDecode)(jid1)) === null || _a === void 0 ? void 0 : _a.user) === ((_b = (0, exports.jidDecode)(jid2)) === null || _b === void 0 ? void 0 : _b.user));
|
|
35
35
|
};
|
|
36
36
|
exports.areJidsSameUser = areJidsSameUser;
|
|
37
|
+
/** is the jid Meta IA */
|
|
38
|
+
const isJidMetaIa = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@bot'));
|
|
39
|
+
exports.isJidMetaIa = isJidMetaIa;
|
|
37
40
|
/** is the jid a user */
|
|
38
41
|
const isJidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net'));
|
|
39
42
|
exports.isJidUser = isJidUser;
|