@queenanya/baileys 8.2.7 → 8.3.1
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/WAProto/index.d.ts +1590 -6
- package/WAProto/index.js +4635 -3
- package/engine-requirements.js +1 -1
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +232 -1
- package/lib/Defaults/index.js +21 -6
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
- package/lib/Socket/Client/{websocket.js → web-socket-client.js} +3 -3
- package/lib/Socket/business.d.ts +4 -9
- package/lib/Socket/chats.d.ts +3 -9
- package/lib/Socket/chats.js +6 -89
- package/lib/Socket/groups.d.ts +3 -7
- package/lib/Socket/groups.js +13 -9
- package/lib/Socket/index.d.ts +6 -9
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +4 -9
- package/lib/Socket/messages-recv.js +14 -27
- package/lib/Socket/messages-send.d.ts +3 -8
- package/lib/Socket/messages-send.js +55 -86
- package/lib/Socket/newsletter.d.ts +3 -7
- package/lib/Socket/newsletter.js +2 -4
- package/lib/Socket/registration.d.ts +266 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +1 -2
- package/lib/Socket/socket.js +15 -10
- package/lib/Socket/usync.d.ts +1 -1
- package/lib/Socket/usync.js +15 -10
- package/lib/Store/make-in-memory-store.js +10 -8
- package/lib/Types/Auth.d.ts +6 -0
- package/lib/Types/Chat.d.ts +2 -8
- package/lib/Types/Contact.d.ts +4 -5
- package/lib/Types/GroupMetadata.d.ts +4 -3
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +5 -5
- package/lib/Types/Socket.d.ts +3 -5
- package/lib/Utils/auth-utils.js +7 -0
- package/lib/Utils/chat-utils.d.ts +8 -8
- package/lib/Utils/chat-utils.js +4 -30
- package/lib/Utils/crypto.d.ts +1 -1
- package/lib/Utils/crypto.js +1 -3
- package/lib/Utils/decode-wa-message.d.ts +2 -4
- package/lib/Utils/decode-wa-message.js +18 -161
- package/lib/Utils/event-buffer.js +6 -4
- package/lib/Utils/generics.d.ts +18 -8
- package/lib/Utils/generics.js +93 -7
- package/lib/Utils/history.js +1 -1
- package/lib/Utils/messages-media.d.ts +9 -16
- package/lib/Utils/messages-media.js +175 -88
- package/lib/Utils/messages.d.ts +1 -1
- package/lib/Utils/messages.js +17 -15
- package/lib/Utils/noise-handler.d.ts +2 -1
- package/lib/Utils/noise-handler.js +10 -5
- package/lib/Utils/validate-connection.d.ts +1 -0
- package/lib/Utils/validate-connection.js +50 -16
- package/lib/WABinary/constants.d.ts +4 -4
- package/lib/WABinary/constants.js +1271 -8
- package/lib/WABinary/encode.js +5 -7
- package/lib/WABinary/jid-utils.d.ts +4 -4
- package/lib/WABinary/jid-utils.js +19 -19
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/encode.js +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +3 -3
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -1
- package/lib/WAUSync/USyncQuery.js +13 -17
- package/package.json +9 -5
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
- /package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +0 -0
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
package/lib/Socket/business.d.ts
CHANGED
|
@@ -24,13 +24,12 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
24
24
|
isVideo: boolean;
|
|
25
25
|
}>;
|
|
26
26
|
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
27
|
-
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
27
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<"RESOLVED" | string | undefined>;
|
|
28
28
|
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
29
29
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
30
30
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
31
31
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
32
32
|
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
33
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) => BinaryNode["attrs"];
|
|
34
33
|
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
|
35
34
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
36
35
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
@@ -66,6 +65,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
66
65
|
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
67
66
|
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
68
67
|
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
68
|
+
groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
|
|
69
69
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
70
70
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
71
71
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -114,8 +114,6 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
114
114
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
115
115
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
116
116
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
117
|
-
updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
118
|
-
updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
119
117
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
120
118
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
121
119
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -130,12 +128,9 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
130
128
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
131
129
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
132
130
|
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
133
|
-
resyncAppState: (collections: readonly ("
|
|
131
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
134
132
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
135
133
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
136
|
-
addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
|
|
137
|
-
removeContact: (jid: string) => Promise<void>;
|
|
138
|
-
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
139
134
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
140
135
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
141
136
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -146,7 +141,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
146
141
|
}[], star: boolean) => Promise<void>;
|
|
147
142
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
148
143
|
type: "md";
|
|
149
|
-
ws:
|
|
144
|
+
ws: any;
|
|
150
145
|
ev: import("../Types").BaileysEventEmitter & {
|
|
151
146
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
152
147
|
buffer(): void;
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom';
|
|
2
2
|
import { proto } from '../../WAProto';
|
|
3
|
-
import { BotListInfo, ChatModification,
|
|
4
|
-
import { LabelActionBody } from '../Types/Label';
|
|
3
|
+
import { BotListInfo, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
|
5
4
|
import { BinaryNode } from '../WABinary';
|
|
6
5
|
import { USyncQuery } from '../WAUSync';
|
|
7
6
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
@@ -26,8 +25,6 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
26
25
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
27
26
|
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
28
27
|
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
29
|
-
updateProfilePictureFull: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
30
|
-
updateProfilePictureFull2: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
31
28
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
32
29
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
33
30
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -42,12 +39,9 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
42
39
|
updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
|
|
43
40
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
44
41
|
getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
|
|
45
|
-
resyncAppState: (collections: readonly ("
|
|
42
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
46
43
|
chatModify: (mod: ChatModification, jid: string) => Promise<void>;
|
|
47
44
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
48
|
-
addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>;
|
|
49
|
-
removeContact: (jid: string) => Promise<void>;
|
|
50
|
-
addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
|
|
51
45
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
52
46
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
53
47
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -58,7 +52,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
58
52
|
}[], star: boolean) => Promise<void>;
|
|
59
53
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
60
54
|
type: "md";
|
|
61
|
-
ws:
|
|
55
|
+
ws: any;
|
|
62
56
|
ev: import("../Types").BaileysEventEmitter & {
|
|
63
57
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
64
58
|
buffer(): void;
|
package/lib/Socket/chats.js
CHANGED
|
@@ -206,59 +206,6 @@ const makeChatsSocket = (config) => {
|
|
|
206
206
|
]
|
|
207
207
|
});
|
|
208
208
|
};
|
|
209
|
-
/** update the profile picture for yourself or a group as Full */
|
|
210
|
-
const updateProfilePictureFull = async (jid, content) => {
|
|
211
|
-
let targetJid;
|
|
212
|
-
if (!jid) {
|
|
213
|
-
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
214
|
-
}
|
|
215
|
-
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
216
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
217
|
-
}
|
|
218
|
-
const { img } = await (0, Utils_1.generateProfilePictureFull)(content);
|
|
219
|
-
await query({
|
|
220
|
-
tag: 'iq',
|
|
221
|
-
attrs: {
|
|
222
|
-
target: targetJid,
|
|
223
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
224
|
-
type: 'set',
|
|
225
|
-
xmlns: 'w:profile:picture'
|
|
226
|
-
},
|
|
227
|
-
content: [
|
|
228
|
-
{
|
|
229
|
-
tag: 'picture',
|
|
230
|
-
attrs: { type: 'image' },
|
|
231
|
-
content: img
|
|
232
|
-
}
|
|
233
|
-
]
|
|
234
|
-
});
|
|
235
|
-
};
|
|
236
|
-
const updateProfilePictureFull2 = async (jid, content) => {
|
|
237
|
-
let targetJid;
|
|
238
|
-
if (!jid) {
|
|
239
|
-
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
240
|
-
}
|
|
241
|
-
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
242
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
243
|
-
}
|
|
244
|
-
const { preview } = await (0, Utils_1.generateProfilePictureFP)(content);
|
|
245
|
-
await query({
|
|
246
|
-
tag: 'iq',
|
|
247
|
-
attrs: {
|
|
248
|
-
target: targetJid,
|
|
249
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
250
|
-
type: 'set',
|
|
251
|
-
xmlns: 'w:profile:picture'
|
|
252
|
-
},
|
|
253
|
-
content: [
|
|
254
|
-
{
|
|
255
|
-
tag: 'picture',
|
|
256
|
-
attrs: { type: 'image' },
|
|
257
|
-
content: preview
|
|
258
|
-
}
|
|
259
|
-
]
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
209
|
/** remove the profile picture for yourself or a group */
|
|
263
210
|
const removeProfilePicture = async (jid) => {
|
|
264
211
|
let targetJid;
|
|
@@ -725,32 +672,6 @@ const makeChatsSocket = (config) => {
|
|
|
725
672
|
}
|
|
726
673
|
}, jid);
|
|
727
674
|
};
|
|
728
|
-
/**
|
|
729
|
-
* Add or Edit Contact
|
|
730
|
-
*/
|
|
731
|
-
const addOrEditContact = (jid, contact) => {
|
|
732
|
-
return chatModify({
|
|
733
|
-
contact
|
|
734
|
-
}, jid);
|
|
735
|
-
};
|
|
736
|
-
/**
|
|
737
|
-
* Remove Contact
|
|
738
|
-
*/
|
|
739
|
-
const removeContact = (jid) => {
|
|
740
|
-
return chatModify({
|
|
741
|
-
contact: null
|
|
742
|
-
}, jid);
|
|
743
|
-
};
|
|
744
|
-
/**
|
|
745
|
-
* Adds label
|
|
746
|
-
*/
|
|
747
|
-
const addLabel = (jid, labels) => {
|
|
748
|
-
return chatModify({
|
|
749
|
-
addLabel: {
|
|
750
|
-
...labels
|
|
751
|
-
}
|
|
752
|
-
}, jid);
|
|
753
|
-
};
|
|
754
675
|
/**
|
|
755
676
|
* Adds label for the chats
|
|
756
677
|
*/
|
|
@@ -898,13 +819,14 @@ const makeChatsSocket = (config) => {
|
|
|
898
819
|
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
|
|
899
820
|
.catch(error => onUnexpectedError(error, 'presence update requests'));
|
|
900
821
|
}
|
|
901
|
-
if (receivedPendingNotifications
|
|
822
|
+
if (receivedPendingNotifications) {
|
|
823
|
+
// if we don't have the app state key
|
|
902
824
|
// we keep buffering events until we finally have
|
|
903
825
|
// the key and can sync the messages
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
826
|
+
if (!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId) && !config.mobile) {
|
|
827
|
+
ev.buffer();
|
|
828
|
+
needToFlushWithAppStateSync = true;
|
|
829
|
+
}
|
|
908
830
|
}
|
|
909
831
|
});
|
|
910
832
|
return {
|
|
@@ -922,8 +844,6 @@ const makeChatsSocket = (config) => {
|
|
|
922
844
|
fetchDisappearingDuration,
|
|
923
845
|
fetchStatus,
|
|
924
846
|
updateProfilePicture,
|
|
925
|
-
updateProfilePictureFull,
|
|
926
|
-
updateProfilePictureFull2,
|
|
927
847
|
removeProfilePicture,
|
|
928
848
|
updateProfileStatus,
|
|
929
849
|
updateProfileName,
|
|
@@ -941,9 +861,6 @@ const makeChatsSocket = (config) => {
|
|
|
941
861
|
resyncAppState,
|
|
942
862
|
chatModify,
|
|
943
863
|
cleanDirtyBits,
|
|
944
|
-
addOrEditContact,
|
|
945
|
-
removeContact,
|
|
946
|
-
addLabel,
|
|
947
864
|
addChatLabel,
|
|
948
865
|
removeChatLabel,
|
|
949
866
|
addMessageLabel,
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { proto } from '../../WAProto';
|
|
|
2
2
|
import { GroupMetadata, ParticipantAction, SocketConfig, WAMessageKey } from '../Types';
|
|
3
3
|
import { BinaryNode } from '../WABinary';
|
|
4
4
|
export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
5
|
+
groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
|
|
5
6
|
groupMetadata: (jid: string) => Promise<GroupMetadata>;
|
|
6
7
|
groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>;
|
|
7
8
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -64,8 +65,6 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
64
65
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
65
66
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
66
67
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
67
|
-
updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
68
|
-
updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
69
68
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
70
69
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
71
70
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -80,12 +79,9 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
80
79
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
81
80
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
82
81
|
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
83
|
-
resyncAppState: (collections: readonly ("
|
|
82
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
84
83
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
85
84
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
86
|
-
addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
|
|
87
|
-
removeContact: (jid: string) => Promise<void>;
|
|
88
|
-
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
89
85
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
90
86
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
91
87
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -96,7 +92,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
96
92
|
}[], star: boolean) => Promise<void>;
|
|
97
93
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
98
94
|
type: "md";
|
|
99
|
-
ws:
|
|
95
|
+
ws: any;
|
|
100
96
|
ev: import("../Types").BaileysEventEmitter & {
|
|
101
97
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
102
98
|
buffer(): void;
|
package/lib/Socket/groups.js
CHANGED
|
@@ -67,6 +67,7 @@ const makeGroupsSocket = (config) => {
|
|
|
67
67
|
});
|
|
68
68
|
return {
|
|
69
69
|
...sock,
|
|
70
|
+
groupQuery,
|
|
70
71
|
groupMetadata,
|
|
71
72
|
groupCreate: async (subject, participants) => {
|
|
72
73
|
const key = (0, Utils_1.generateMessageIDV2)();
|
|
@@ -278,12 +279,14 @@ const extractGroupMetadata = (result) => {
|
|
|
278
279
|
let desc;
|
|
279
280
|
let descId;
|
|
280
281
|
let descOwner;
|
|
281
|
-
let
|
|
282
|
+
let descOwnerLid;
|
|
282
283
|
let descTime;
|
|
283
284
|
if (descChild) {
|
|
284
285
|
desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
|
|
285
|
-
descOwner = descChild.attrs.participant;
|
|
286
|
-
|
|
286
|
+
descOwner = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant_pn || descChild.attrs.participant);
|
|
287
|
+
if (group.attrs.addressing_mode === 'lid') {
|
|
288
|
+
descOwnerLid = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant);
|
|
289
|
+
}
|
|
287
290
|
descId = descChild.attrs.id;
|
|
288
291
|
descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
|
|
289
292
|
}
|
|
@@ -295,17 +298,17 @@ const extractGroupMetadata = (result) => {
|
|
|
295
298
|
id: groupId,
|
|
296
299
|
addressingMode: group.attrs.addressing_mode,
|
|
297
300
|
subject: group.attrs.subject,
|
|
298
|
-
subjectOwner: group.attrs.s_o,
|
|
299
|
-
|
|
301
|
+
subjectOwner: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o_pn || group.attrs.s_o),
|
|
302
|
+
...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o) } : {}),
|
|
300
303
|
subjectTime: group.attrs.s_t ? +group.attrs.s_t : undefined,
|
|
301
304
|
size: groupSize || (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
|
|
302
305
|
creation: group.attrs.creation ? +group.attrs.creation : undefined,
|
|
303
|
-
owner:
|
|
304
|
-
|
|
306
|
+
owner: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator_pn || group.attrs.creator),
|
|
307
|
+
...(group.attrs.addressing_mode === 'lid' ? { ownerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) } : {}),
|
|
305
308
|
desc,
|
|
306
309
|
descId,
|
|
307
310
|
descOwner,
|
|
308
|
-
|
|
311
|
+
descOwnerLid,
|
|
309
312
|
descTime,
|
|
310
313
|
linkedParent: ((_b = (0, WABinary_1.getBinaryNodeChild)(group, 'linked_parent')) === null || _b === void 0 ? void 0 : _b.attrs.jid) || undefined,
|
|
311
314
|
restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
|
|
@@ -316,7 +319,8 @@ const extractGroupMetadata = (result) => {
|
|
|
316
319
|
memberAddMode,
|
|
317
320
|
participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
|
|
318
321
|
return {
|
|
319
|
-
id: attrs.
|
|
322
|
+
id: attrs.jid,
|
|
323
|
+
jid: attrs.phone_number || attrs.jid,
|
|
320
324
|
lid: attrs.lid || attrs.jid,
|
|
321
325
|
admin: (attrs.type || null),
|
|
322
326
|
};
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { UserFacingSocketConfig } from '../Types';
|
|
2
2
|
declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
3
|
+
register: (code: string) => Promise<import("./registration").ExistsResponse>;
|
|
4
|
+
requestRegistrationCode: (registrationOptions?: import("./registration").RegistrationOptions) => Promise<import("./registration").ExistsResponse>;
|
|
3
5
|
logger: import("../Utils/logger").ILogger;
|
|
4
6
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
5
7
|
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
@@ -23,13 +25,12 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
23
25
|
isVideo: boolean;
|
|
24
26
|
}>;
|
|
25
27
|
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
26
|
-
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
28
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<"RESOLVED" | string | undefined>;
|
|
27
29
|
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
28
30
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
29
31
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
30
32
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
31
33
|
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
32
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) => import("..").BinaryNode["attrs"];
|
|
33
34
|
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
|
34
35
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
35
36
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
@@ -65,6 +66,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
65
66
|
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
66
67
|
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
67
68
|
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
69
|
+
groupQuery: (jid: string, type: "get" | "set", content: import("..").BinaryNode[]) => Promise<any>;
|
|
68
70
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
69
71
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
70
72
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -113,8 +115,6 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
113
115
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
114
116
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
115
117
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
116
|
-
updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
117
|
-
updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
118
118
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
119
119
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
120
120
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -129,12 +129,9 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
129
129
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
130
130
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
131
131
|
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
132
|
-
resyncAppState: (collections: readonly ("
|
|
132
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
133
133
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
134
134
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
135
|
-
addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
|
|
136
|
-
removeContact: (jid: string) => Promise<void>;
|
|
137
|
-
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
138
135
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
139
136
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
140
137
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -145,7 +142,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
145
142
|
}[], star: boolean) => Promise<void>;
|
|
146
143
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
147
144
|
type: "md";
|
|
148
|
-
ws:
|
|
145
|
+
ws: any;
|
|
149
146
|
ev: import("../Types").BaileysEventEmitter & {
|
|
150
147
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
151
148
|
buffer(): void;
|
package/lib/Socket/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const Defaults_1 = require("../Defaults");
|
|
4
|
-
const
|
|
4
|
+
const registration_1 = require("./registration");
|
|
5
5
|
// export the last socket layer
|
|
6
|
-
const makeWASocket = (config) => ((0,
|
|
6
|
+
const makeWASocket = (config) => ((0, registration_1.makeRegistrationSocket)({
|
|
7
7
|
...Defaults_1.DEFAULT_CONNECTION_CONFIG,
|
|
8
8
|
...config
|
|
9
9
|
}));
|
|
@@ -13,13 +13,12 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
13
13
|
isVideo: boolean;
|
|
14
14
|
}>;
|
|
15
15
|
fetchMessageHistory: (count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
16
|
-
requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<string | undefined>;
|
|
16
|
+
requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<"RESOLVED" | string | undefined>;
|
|
17
17
|
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
18
18
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
19
19
|
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
20
20
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
21
21
|
sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
|
|
22
|
-
getButtonArgs: (message: proto.IMessage) => BinaryNode["attrs"];
|
|
23
22
|
readMessages: (keys: WAMessageKey[]) => Promise<void>;
|
|
24
23
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
25
24
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
@@ -55,6 +54,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
55
54
|
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
56
55
|
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
57
56
|
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
57
|
+
groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
|
|
58
58
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
59
59
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
60
60
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -103,8 +103,6 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
103
103
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
104
104
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
105
105
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
106
|
-
updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
107
|
-
updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
108
106
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
109
107
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
110
108
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -119,12 +117,9 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
119
117
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
120
118
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
121
119
|
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
122
|
-
resyncAppState: (collections: readonly ("
|
|
120
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
123
121
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
124
122
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
125
|
-
addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
|
|
126
|
-
removeContact: (jid: string) => Promise<void>;
|
|
127
|
-
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
128
123
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
129
124
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
130
125
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -135,7 +130,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
135
130
|
}[], star: boolean) => Promise<void>;
|
|
136
131
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
137
132
|
type: "md";
|
|
138
|
-
ws:
|
|
133
|
+
ws: any;
|
|
139
134
|
ev: import("../Types").BaileysEventEmitter & {
|
|
140
135
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
141
136
|
buffer(): void;
|
|
@@ -16,7 +16,7 @@ const WABinary_1 = require("../WABinary");
|
|
|
16
16
|
const groups_1 = require("./groups");
|
|
17
17
|
const messages_send_1 = require("./messages-send");
|
|
18
18
|
const makeMessagesRecvSocket = (config) => {
|
|
19
|
-
const { logger, retryRequestDelayMs, maxMsgRetryCount,
|
|
19
|
+
const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
|
|
20
20
|
const sock = (0, messages_send_1.makeMessagesSocket)(config);
|
|
21
21
|
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, createParticipantNodes, getUSyncDevices, sendPeerDataOperationMessage, } = sock;
|
|
22
22
|
/** this mutex ensures that each retryRequest will wait for the previous one to finish */
|
|
@@ -35,11 +35,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
35
35
|
});
|
|
36
36
|
let sendActiveReceipts = false;
|
|
37
37
|
const sendMessageAck = async ({ tag, attrs, content }, errorCode) => {
|
|
38
|
-
// If ws not connected - logs it and return
|
|
39
|
-
if (!ws.isOpen) {
|
|
40
|
-
logger.warn({ attrs: attrs }, 'Client not connected, cannot send ack');
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
38
|
const stanza = {
|
|
44
39
|
tag: 'ack',
|
|
45
40
|
attrs: {
|
|
@@ -67,7 +62,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
67
62
|
await sendNode(stanza);
|
|
68
63
|
};
|
|
69
64
|
const offerCall = async (toJid, isVideo = false) => {
|
|
70
|
-
const ToJidm = `${toJid}`;
|
|
71
65
|
const callId = (0, crypto_1.randomBytes)(16).toString('hex').toUpperCase().substring(0, 64);
|
|
72
66
|
const offerContent = [];
|
|
73
67
|
offerContent.push({ tag: 'audio', attrs: { enc: 'opus', rate: '16000' }, content: undefined });
|
|
@@ -89,9 +83,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
89
83
|
offerContent.push({ tag: 'capability', attrs: { ver: '1' }, content: new Uint8Array([1, 4, 255, 131, 207, 4]) });
|
|
90
84
|
offerContent.push({ tag: 'encopt', attrs: { keygen: '2' }, content: undefined });
|
|
91
85
|
const encKey = (0, crypto_1.randomBytes)(32);
|
|
92
|
-
const
|
|
93
|
-
const srvr = toJid.split('@')[1];
|
|
94
|
-
const devices = (await getUSyncDevices([toJid], true, false)).map(({ user, device }) => toJid);
|
|
86
|
+
const devices = (await getUSyncDevices([toJid], true, false)).map(({ user, device }) => (0, WABinary_1.jidEncode)(user, 's.whatsapp.net', device));
|
|
95
87
|
await assertSessions(devices, true);
|
|
96
88
|
const { nodes: destinations, shouldIncludeDeviceIdentity } = await createParticipantNodes(devices, {
|
|
97
89
|
call: {
|
|
@@ -192,7 +184,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
192
184
|
]
|
|
193
185
|
};
|
|
194
186
|
if (node.attrs.recipient) {
|
|
195
|
-
receipt.attrs.recipient =
|
|
187
|
+
receipt.attrs.recipient = node.attrs.recipient;
|
|
196
188
|
}
|
|
197
189
|
if (node.attrs.participant) {
|
|
198
190
|
receipt.attrs.participant = node.attrs.participant;
|
|
@@ -423,9 +415,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
423
415
|
case 'encrypt':
|
|
424
416
|
await handleEncryptNotification(node);
|
|
425
417
|
break;
|
|
426
|
-
case 'newsletter':
|
|
427
|
-
// TO DO
|
|
428
|
-
break;
|
|
429
418
|
case 'devices':
|
|
430
419
|
const devices = (0, WABinary_1.getBinaryNodeChildren)(child, 'device');
|
|
431
420
|
if ((0, WABinary_1.areJidsSameUser)(child.attrs.jid, authState.creds.me.id)) {
|
|
@@ -585,7 +574,8 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
585
574
|
await authState.keys.set({ 'sender-key-memory': { [remoteJid]: null } });
|
|
586
575
|
}
|
|
587
576
|
logger.debug({ participant, sendToAll }, 'forced new session for retry recp');
|
|
588
|
-
for (
|
|
577
|
+
for (let i = 0; i < msgs.length; i++) {
|
|
578
|
+
const msg = msgs[i];
|
|
589
579
|
if (msg) {
|
|
590
580
|
updateSendMessageAgainCount(ids[i], participant);
|
|
591
581
|
const msgRelayOpts = { messageId: ids[i] };
|
|
@@ -721,11 +711,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
721
711
|
};
|
|
722
712
|
const handleMessage = async (node) => {
|
|
723
713
|
var _a, _b, _c;
|
|
724
|
-
if (ignoreMsgLoading && node.attrs.offline) {
|
|
725
|
-
logger.debug({ key: node.attrs.key }, 'ignored offline message');
|
|
726
|
-
await sendMessageAck(node);
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
714
|
if (shouldIgnoreJid(node.attrs.from) && node.attrs.from !== '@s.whatsapp.net') {
|
|
730
715
|
logger.debug({ key: node.attrs.key }, 'ignored message');
|
|
731
716
|
await sendMessageAck(node);
|
|
@@ -753,17 +738,19 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
753
738
|
placeholderResendCache.del(node.attrs.id);
|
|
754
739
|
}
|
|
755
740
|
}
|
|
756
|
-
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger
|
|
741
|
+
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
|
|
757
742
|
if (response && ((_a = msg === null || msg === void 0 ? void 0 : msg.messageStubParameters) === null || _a === void 0 ? void 0 : _a[0]) === Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT) {
|
|
758
743
|
msg.messageStubParameters = [Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT, response];
|
|
759
744
|
}
|
|
760
|
-
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER
|
|
761
|
-
|
|
745
|
+
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER) {
|
|
746
|
+
if (node.attrs.sender_pn) {
|
|
747
|
+
ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
|
|
748
|
+
}
|
|
762
749
|
}
|
|
763
750
|
try {
|
|
764
751
|
await Promise.all([
|
|
765
752
|
processingMutex.mutex(async () => {
|
|
766
|
-
var _a, _b
|
|
753
|
+
var _a, _b;
|
|
767
754
|
await decrypt();
|
|
768
755
|
// message failed to decrypt
|
|
769
756
|
if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
|
|
@@ -789,6 +776,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
789
776
|
else {
|
|
790
777
|
// no type in the receipt => message delivered
|
|
791
778
|
let type = undefined;
|
|
779
|
+
if ((_b = msg.key.participant) === null || _b === void 0 ? void 0 : _b.endsWith('@lid')) {
|
|
780
|
+
msg.key.participant = node.attrs.participant_pn || authState.creds.me.id;
|
|
781
|
+
}
|
|
792
782
|
let participant = msg.key.participant;
|
|
793
783
|
if (category === 'peer') { // special peer message
|
|
794
784
|
type = 'peer_msg';
|
|
@@ -811,9 +801,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
811
801
|
await sendReceipt(jid, undefined, [msg.key.id], 'hist_sync');
|
|
812
802
|
}
|
|
813
803
|
}
|
|
814
|
-
if (((_b = node.attrs) === null || _b === void 0 ? void 0 : _b.addressing_mode) === 'lid' && ((_c = node.attrs) === null || _c === void 0 ? void 0 : _c.participant_pn)) {
|
|
815
|
-
msg.key.participant = (0, WABinary_1.jidNormalizedUser)(node.attrs.participant_pn);
|
|
816
|
-
}
|
|
817
804
|
(0, Utils_1.cleanMessage)(msg, authState.creds.me.id);
|
|
818
805
|
await sendMessageAck(node);
|
|
819
806
|
await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
|
|
@@ -9,7 +9,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
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>;
|
|
11
11
|
sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
|
|
12
|
-
getButtonArgs: (message: proto.IMessage) => BinaryNode["attrs"];
|
|
13
12
|
readMessages: (keys: WAMessageKey[]) => Promise<void>;
|
|
14
13
|
refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
|
|
15
14
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
@@ -45,6 +44,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
45
44
|
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
46
45
|
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
47
46
|
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
47
|
+
groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
|
|
48
48
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
49
49
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
50
50
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -93,8 +93,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
93
93
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
94
94
|
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
95
95
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
96
|
-
updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
97
|
-
updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
98
96
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
99
97
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
100
98
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -109,12 +107,9 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
109
107
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
110
108
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
111
109
|
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
112
|
-
resyncAppState: (collections: readonly ("
|
|
110
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
113
111
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
114
112
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
115
|
-
addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
|
|
116
|
-
removeContact: (jid: string) => Promise<void>;
|
|
117
|
-
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
118
113
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
119
114
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
120
115
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -125,7 +120,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
125
120
|
}[], star: boolean) => Promise<void>;
|
|
126
121
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
127
122
|
type: "md";
|
|
128
|
-
ws:
|
|
123
|
+
ws: any;
|
|
129
124
|
ev: import("../Types").BaileysEventEmitter & {
|
|
130
125
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
131
126
|
buffer(): void;
|