@d0v3riz/baileys 6.7.4 → 6.7.6
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 +5 -4
- package/lib/Defaults/index.js +3 -1
- package/lib/Socket/business.d.ts +8 -5
- package/lib/Socket/chats.d.ts +3 -8
- package/lib/Socket/chats.js +15 -1
- package/lib/Socket/groups.d.ts +9 -1
- package/lib/Socket/groups.js +12 -1
- package/lib/Socket/index.d.ts +8 -5
- package/lib/Socket/messages-recv.d.ts +8 -6
- package/lib/Socket/messages-recv.js +105 -12
- package/lib/Socket/messages-send.d.ts +5 -3
- package/lib/Socket/messages-send.js +83 -71
- package/lib/Socket/registration.d.ts +8 -5
- package/lib/Socket/socket.js +2 -2
- package/lib/Store/make-in-memory-store.js +5 -1
- package/lib/Types/Chat.d.ts +2 -0
- package/lib/Types/Events.d.ts +5 -1
- package/lib/Types/GroupMetadata.d.ts +1 -1
- package/lib/Types/Message.d.ts +27 -24
- package/lib/Types/Socket.d.ts +5 -0
- package/lib/Types/index.d.ts +7 -0
- package/lib/Utils/crypto.d.ts +1 -1
- package/lib/Utils/crypto.js +4 -2
- package/lib/Utils/decode-wa-message.d.ts +1 -0
- package/lib/Utils/decode-wa-message.js +16 -7
- package/lib/Utils/generics.d.ts +4 -9
- package/lib/Utils/generics.js +34 -8
- package/lib/Utils/history.d.ts +4 -0
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/messages-media.js +8 -14
- package/lib/Utils/messages.js +48 -58
- package/lib/Utils/noise-handler.d.ts +1 -1
- package/lib/Utils/noise-handler.js +2 -2
- package/lib/Utils/process-message.d.ts +3 -2
- package/lib/Utils/process-message.js +47 -24
- package/lib/Utils/signal.js +26 -16
- package/lib/WABinary/decode.d.ts +2 -2
- package/lib/WABinary/decode.js +6 -4
- package/lib/WABinary/encode.d.ts +1 -1
- package/lib/WABinary/encode.js +8 -4
- package/lib/WABinary/jid-utils.d.ts +2 -0
- package/lib/WABinary/jid-utils.js +4 -1
- package/package.json +6 -5
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
|
|
|
@@ -422,7 +422,8 @@ await sock.sendMessage(
|
|
|
422
422
|
{
|
|
423
423
|
video: "./Media/ma_gif.mp4",
|
|
424
424
|
caption: "hello!",
|
|
425
|
-
gifPlayback: true
|
|
425
|
+
gifPlayback: true,
|
|
426
|
+
ptv: false // if set to true, will send as a `video note`
|
|
426
427
|
}
|
|
427
428
|
)
|
|
428
429
|
|
|
@@ -834,7 +835,7 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|
|
834
835
|
```
|
|
835
836
|
- To update the Groups Add privacy
|
|
836
837
|
``` ts
|
|
837
|
-
const value = 'all' // 'contacts' | 'contact_blacklist'
|
|
838
|
+
const value = 'all' // 'contacts' | 'contact_blacklist'
|
|
838
839
|
await sock.updateGroupsAddPrivacy(value)
|
|
839
840
|
```
|
|
840
841
|
- To update the Default Disappearing Mode
|
package/lib/Defaults/index.js
CHANGED
|
@@ -44,7 +44,8 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
44
44
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
45
45
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
|
|
46
46
|
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
|
|
47
|
-
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL
|
|
47
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL,
|
|
48
|
+
WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
|
|
48
49
|
];
|
|
49
50
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
50
51
|
version: baileys_version_json_1.version,
|
|
@@ -75,6 +76,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
75
76
|
snapshot: false,
|
|
76
77
|
},
|
|
77
78
|
getMessage: async () => undefined,
|
|
79
|
+
cachedGroupMetadata: async () => undefined,
|
|
78
80
|
makeSignalRepository: libsignal_1.makeLibSignalRepository
|
|
79
81
|
};
|
|
80
82
|
exports.MEDIA_PATH_MAP = {
|
package/lib/Socket/business.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="long" />
|
|
1
2
|
/// <reference types="node" />
|
|
2
3
|
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
|
|
3
4
|
import { BinaryNode } from '../WABinary';
|
|
@@ -19,20 +20,20 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
19
20
|
sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
|
|
20
21
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
21
22
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
23
|
+
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAProto.IMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
|
|
24
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAProto.IMessageKey) => Promise<string | undefined>;
|
|
22
25
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
23
26
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
24
|
-
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache,
|
|
27
|
+
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
25
28
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
26
29
|
sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
27
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
|
|
28
|
-
[key: string]: string;
|
|
29
|
-
};
|
|
30
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<{
|
|
34
34
|
[_: string]: string;
|
|
35
35
|
}>;
|
|
36
|
+
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
36
37
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
37
38
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
38
39
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
@@ -55,6 +56,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
55
56
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
56
57
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
57
58
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
59
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
58
60
|
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
59
61
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
60
62
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
@@ -86,12 +88,13 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
86
88
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
87
89
|
updateProfileName: (name: string) => Promise<void>;
|
|
88
90
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
91
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
89
92
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
90
93
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
91
94
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
92
95
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
93
96
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
94
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
97
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
95
98
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
96
99
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
97
100
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Boom } from '@hapi/boom';
|
|
3
3
|
import { proto } from '../../WAProto';
|
|
4
|
-
import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
|
4
|
+
import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
|
5
5
|
import { BinaryNode } from '../WABinary';
|
|
6
6
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
7
7
|
processingMutex: {
|
|
@@ -29,12 +29,13 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
29
29
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
30
30
|
updateProfileName: (name: string) => Promise<void>;
|
|
31
31
|
updateBlockStatus: (jid: string, action: 'block' | 'unblock') => Promise<void>;
|
|
32
|
+
updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>;
|
|
32
33
|
updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
33
34
|
updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>;
|
|
34
35
|
updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
35
36
|
updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
36
37
|
updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>;
|
|
37
|
-
updateGroupsAddPrivacy: (value:
|
|
38
|
+
updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
|
|
38
39
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
39
40
|
getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
|
|
40
41
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
@@ -61,9 +62,6 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
61
62
|
creds: import("../Types").AuthenticationCreds;
|
|
62
63
|
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
63
64
|
};
|
|
64
|
-
/**
|
|
65
|
-
* Star or Unstar a message
|
|
66
|
-
*/
|
|
67
65
|
signalRepository: import("../Types").SignalRepository;
|
|
68
66
|
user: import("../Types").Contact | undefined;
|
|
69
67
|
generateMessageTag: () => string;
|
|
@@ -75,9 +73,6 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
75
73
|
logout: (msg?: string | undefined) => Promise<void>;
|
|
76
74
|
end: (error: Error | undefined) => void;
|
|
77
75
|
onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
|
|
78
|
-
/**
|
|
79
|
-
* Adds label for the chats
|
|
80
|
-
*/
|
|
81
76
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
82
77
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
83
78
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
package/lib/Socket/chats.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeChatsSocket = void 0;
|
|
7
7
|
const boom_1 = require("@hapi/boom");
|
|
8
|
+
const node_cache_1 = __importDefault(require("node-cache"));
|
|
8
9
|
const WAProto_1 = require("../../WAProto");
|
|
9
10
|
const Defaults_1 = require("../Defaults");
|
|
10
11
|
const Types_1 = require("../Types");
|
|
@@ -23,6 +24,13 @@ const makeChatsSocket = (config) => {
|
|
|
23
24
|
let pendingAppStateSync = false;
|
|
24
25
|
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
|
|
25
26
|
const processingMutex = (0, make_mutex_1.makeMutex)();
|
|
27
|
+
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
28
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
29
|
+
useClones: false
|
|
30
|
+
});
|
|
31
|
+
if (!config.placeholderResendCache) {
|
|
32
|
+
config.placeholderResendCache = placeholderResendCache;
|
|
33
|
+
}
|
|
26
34
|
/** helper function to fetch the given app state sync key */
|
|
27
35
|
const getAppStateSyncKey = async (keyId) => {
|
|
28
36
|
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
|
|
@@ -66,6 +74,9 @@ const makeChatsSocket = (config) => {
|
|
|
66
74
|
}]
|
|
67
75
|
});
|
|
68
76
|
};
|
|
77
|
+
const updateCallPrivacy = async (value) => {
|
|
78
|
+
await privacyQuery('calladd', value);
|
|
79
|
+
};
|
|
69
80
|
const updateLastSeenPrivacy = async (value) => {
|
|
70
81
|
await privacyQuery('last', value);
|
|
71
82
|
};
|
|
@@ -442,7 +453,8 @@ const makeChatsSocket = (config) => {
|
|
|
442
453
|
const result = await query({
|
|
443
454
|
tag: 'iq',
|
|
444
455
|
attrs: {
|
|
445
|
-
|
|
456
|
+
target: jid,
|
|
457
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
446
458
|
type: 'get',
|
|
447
459
|
xmlns: 'w:profile:picture'
|
|
448
460
|
},
|
|
@@ -730,6 +742,7 @@ const makeChatsSocket = (config) => {
|
|
|
730
742
|
})(),
|
|
731
743
|
(0, process_message_1.default)(msg, {
|
|
732
744
|
shouldProcessHistoryMsg,
|
|
745
|
+
placeholderResendCache,
|
|
733
746
|
ev,
|
|
734
747
|
creds: authState.creds,
|
|
735
748
|
keyStore: authState.keys,
|
|
@@ -817,6 +830,7 @@ const makeChatsSocket = (config) => {
|
|
|
817
830
|
updateProfileStatus,
|
|
818
831
|
updateProfileName,
|
|
819
832
|
updateBlockStatus,
|
|
833
|
+
updateCallPrivacy,
|
|
820
834
|
updateLastSeenPrivacy,
|
|
821
835
|
updateOnlinePrivacy,
|
|
822
836
|
updateProfilePicturePrivacy,
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -23,6 +23,13 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
23
23
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
24
24
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
25
25
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* revoke a v4 invite for someone
|
|
28
|
+
* @param groupJid group jid
|
|
29
|
+
* @param invitedJid jid of person you invited
|
|
30
|
+
* @returns true if successful
|
|
31
|
+
*/
|
|
32
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
26
33
|
/**
|
|
27
34
|
* accept a GroupInviteMessage
|
|
28
35
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
@@ -62,12 +69,13 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
62
69
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
63
70
|
updateProfileName: (name: string) => Promise<void>;
|
|
64
71
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
72
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
65
73
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
66
74
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
67
75
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
68
76
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
69
77
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
70
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
78
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
71
79
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
72
80
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
73
81
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
package/lib/Socket/groups.js
CHANGED
|
@@ -187,12 +187,23 @@ const makeGroupsSocket = (config) => {
|
|
|
187
187
|
const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
|
|
188
188
|
return result === null || result === void 0 ? void 0 : result.attrs.jid;
|
|
189
189
|
},
|
|
190
|
+
/**
|
|
191
|
+
* revoke a v4 invite for someone
|
|
192
|
+
* @param groupJid group jid
|
|
193
|
+
* @param invitedJid jid of person you invited
|
|
194
|
+
* @returns true if successful
|
|
195
|
+
*/
|
|
196
|
+
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
197
|
+
const result = await groupQuery(groupJid, 'set', [{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }]);
|
|
198
|
+
return !!result;
|
|
199
|
+
},
|
|
190
200
|
/**
|
|
191
201
|
* accept a GroupInviteMessage
|
|
192
202
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
193
203
|
* @param inviteMessage the message to accept
|
|
194
204
|
*/
|
|
195
205
|
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
206
|
+
var _a;
|
|
196
207
|
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
197
208
|
const results = await groupQuery(inviteMessage.groupJid, 'set', [{
|
|
198
209
|
tag: 'accept',
|
|
@@ -224,7 +235,7 @@ const makeGroupsSocket = (config) => {
|
|
|
224
235
|
await upsertMessage({
|
|
225
236
|
key: {
|
|
226
237
|
remoteJid: inviteMessage.groupJid,
|
|
227
|
-
id: (0, Utils_1.
|
|
238
|
+
id: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
|
|
228
239
|
fromMe: false,
|
|
229
240
|
participant: key.remoteJid,
|
|
230
241
|
},
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="long" />
|
|
1
2
|
/// <reference types="node" />
|
|
2
3
|
import { UserFacingSocketConfig } from '../Types';
|
|
3
4
|
declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
@@ -20,20 +21,20 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
20
21
|
sendMessageAck: ({ tag, attrs, content }: import("../index").BinaryNode) => Promise<void>;
|
|
21
22
|
sendRetryRequest: (node: import("../index").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
22
23
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
24
|
+
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAProto.IMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
|
|
25
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAProto.IMessageKey) => Promise<string | undefined>;
|
|
23
26
|
getPrivacyTokens: (jids: string[]) => Promise<import("../index").BinaryNode>;
|
|
24
27
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
25
|
-
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache,
|
|
28
|
+
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
26
29
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
27
30
|
sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
28
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
|
|
29
|
-
[key: string]: string;
|
|
30
|
-
};
|
|
31
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<{
|
|
35
35
|
[_: string]: string;
|
|
36
36
|
}>;
|
|
37
|
+
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
37
38
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
38
39
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
39
40
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
@@ -56,6 +57,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
56
57
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
57
58
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
58
59
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
60
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
59
61
|
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
60
62
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
61
63
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
@@ -87,12 +89,13 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
87
89
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
88
90
|
updateProfileName: (name: string) => Promise<void>;
|
|
89
91
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
92
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
90
93
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
91
94
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
92
95
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
93
96
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
94
97
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
95
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
98
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
96
99
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
97
100
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
98
101
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Boom } from '@hapi/boom';
|
|
3
3
|
import { proto } from '../../WAProto';
|
|
4
|
-
import { MessageReceiptType, MessageRelayOptions, SocketConfig } from '../Types';
|
|
4
|
+
import { MessageReceiptType, MessageRelayOptions, SocketConfig, WAMessageKey } 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>;
|
|
8
8
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
9
9
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
10
|
+
fetchMessageHistory: (count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
11
|
+
requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<'RESOLVED' | string | undefined>;
|
|
10
12
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
11
13
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
12
|
-
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache,
|
|
14
|
+
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
13
15
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
14
16
|
sendReceipts: (keys: proto.IMessageKey[], type: MessageReceiptType) => Promise<void>;
|
|
15
|
-
getButtonArgs: (message: proto.IMessage) => {
|
|
16
|
-
[key: string]: string;
|
|
17
|
-
};
|
|
18
17
|
readMessages: (keys: proto.IMessageKey[]) => Promise<void>;
|
|
19
18
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
20
19
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
21
20
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
22
21
|
[_: string]: string;
|
|
23
22
|
}>;
|
|
23
|
+
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
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
26
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
@@ -43,6 +43,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
43
43
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
44
44
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
45
45
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
46
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
46
47
|
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
|
|
47
48
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
48
49
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
@@ -74,12 +75,13 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
74
75
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
75
76
|
updateProfileName: (name: string) => Promise<void>;
|
|
76
77
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
78
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
77
79
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
78
80
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
79
81
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
80
82
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
81
83
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
82
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
84
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
83
85
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
84
86
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
85
87
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
@@ -19,7 +19,7 @@ const messages_send_1 = require("./messages-send");
|
|
|
19
19
|
const makeMessagesRecvSocket = (config) => {
|
|
20
20
|
const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
|
|
21
21
|
const sock = (0, messages_send_1.makeMessagesSocket)(config);
|
|
22
|
-
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, } = sock;
|
|
22
|
+
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, sendPeerDataOperationMessage, } = sock;
|
|
23
23
|
/** this mutex ensures that each retryRequest will wait for the previous one to finish */
|
|
24
24
|
const retryMutex = (0, make_mutex_1.makeMutex)();
|
|
25
25
|
const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
|
|
@@ -30,6 +30,10 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
30
30
|
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.CALL_OFFER,
|
|
31
31
|
useClones: false
|
|
32
32
|
});
|
|
33
|
+
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
34
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
35
|
+
useClones: false
|
|
36
|
+
});
|
|
33
37
|
let sendActiveReceipts = false;
|
|
34
38
|
const sendMessageAck = async ({ tag, attrs, content }) => {
|
|
35
39
|
const stanza = {
|
|
@@ -75,16 +79,24 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
75
79
|
await query(stanza);
|
|
76
80
|
};
|
|
77
81
|
const sendRetryRequest = async (node, forceIncludeKeys = false) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
82
|
+
const { fullMessage } = (0, Utils_1.decodeMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '');
|
|
83
|
+
const { key: msgKey } = fullMessage;
|
|
84
|
+
const msgId = msgKey.id;
|
|
85
|
+
const key = `${msgId}:${msgKey === null || msgKey === void 0 ? void 0 : msgKey.participant}`;
|
|
86
|
+
let retryCount = msgRetryCache.get(key) || 0;
|
|
80
87
|
if (retryCount >= maxMsgRetryCount) {
|
|
81
88
|
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing');
|
|
82
|
-
msgRetryCache.del(
|
|
89
|
+
msgRetryCache.del(key);
|
|
83
90
|
return;
|
|
84
91
|
}
|
|
85
92
|
retryCount += 1;
|
|
86
|
-
msgRetryCache.set(
|
|
93
|
+
msgRetryCache.set(key, retryCount);
|
|
87
94
|
const { account, signedPreKey, signedIdentityKey: identityKey } = authState.creds;
|
|
95
|
+
if (retryCount === 1) {
|
|
96
|
+
//request a resend via phone
|
|
97
|
+
const msgId = await requestPlaceholderResend(msgKey);
|
|
98
|
+
logger.debug(`sendRetryRequest: requested placeholder resend for message ${msgId}`);
|
|
99
|
+
}
|
|
88
100
|
const deviceIdentity = (0, Utils_1.encodeSignedDeviceIdentity)(account, true);
|
|
89
101
|
await authState.keys.transaction(async () => {
|
|
90
102
|
const receipt = {
|
|
@@ -163,7 +175,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
163
175
|
}
|
|
164
176
|
};
|
|
165
177
|
const handleGroupNotification = (participant, child, msg) => {
|
|
166
|
-
var _a, _b;
|
|
178
|
+
var _a, _b, _c, _d;
|
|
167
179
|
const participantJid = ((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(child, 'participant')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.jid) || participant;
|
|
168
180
|
switch (child === null || child === void 0 ? void 0 : child.tag) {
|
|
169
181
|
case 'create':
|
|
@@ -190,6 +202,11 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
190
202
|
}
|
|
191
203
|
};
|
|
192
204
|
break;
|
|
205
|
+
case 'modify':
|
|
206
|
+
const oldNumber = (0, WABinary_1.getBinaryNodeChildren)(child, 'participant').map(p => p.attrs.jid);
|
|
207
|
+
msg.messageStubParameters = oldNumber || [];
|
|
208
|
+
msg.messageStubType = Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER;
|
|
209
|
+
break;
|
|
193
210
|
case 'promote':
|
|
194
211
|
case 'demote':
|
|
195
212
|
case 'remove':
|
|
@@ -211,6 +228,11 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
211
228
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT;
|
|
212
229
|
msg.messageStubParameters = [child.attrs.subject];
|
|
213
230
|
break;
|
|
231
|
+
case 'description':
|
|
232
|
+
const description = (_d = (_c = (0, WABinary_1.getBinaryNodeChild)(child, 'body')) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.toString();
|
|
233
|
+
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION;
|
|
234
|
+
msg.messageStubParameters = description ? [description] : undefined;
|
|
235
|
+
break;
|
|
214
236
|
case 'announcement':
|
|
215
237
|
case 'not_announcement':
|
|
216
238
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE;
|
|
@@ -343,7 +365,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
343
365
|
const ref = toRequiredBuffer((0, WABinary_1.getBinaryNodeChildBuffer)(linkCodeCompanionReg, 'link_code_pairing_ref'));
|
|
344
366
|
const primaryIdentityPublicKey = toRequiredBuffer((0, WABinary_1.getBinaryNodeChildBuffer)(linkCodeCompanionReg, 'primary_identity_pub'));
|
|
345
367
|
const primaryEphemeralPublicKeyWrapped = toRequiredBuffer((0, WABinary_1.getBinaryNodeChildBuffer)(linkCodeCompanionReg, 'link_code_pairing_wrapped_primary_ephemeral_pub'));
|
|
346
|
-
const codePairingPublicKey = decipherLinkPublicKey(primaryEphemeralPublicKeyWrapped);
|
|
368
|
+
const codePairingPublicKey = await decipherLinkPublicKey(primaryEphemeralPublicKeyWrapped);
|
|
347
369
|
const companionSharedKey = Utils_1.Curve.sharedKey(authState.creds.pairingEphemeralKeyPair.private, codePairingPublicKey);
|
|
348
370
|
const random = (0, crypto_1.randomBytes)(32);
|
|
349
371
|
const linkCodeSalt = (0, crypto_1.randomBytes)(32);
|
|
@@ -400,10 +422,10 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
400
422
|
return result;
|
|
401
423
|
}
|
|
402
424
|
};
|
|
403
|
-
function decipherLinkPublicKey(data) {
|
|
425
|
+
async function decipherLinkPublicKey(data) {
|
|
404
426
|
const buffer = toRequiredBuffer(data);
|
|
405
427
|
const salt = buffer.slice(0, 32);
|
|
406
|
-
const secretKey = (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
428
|
+
const secretKey = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
407
429
|
const iv = buffer.slice(32, 48);
|
|
408
430
|
const payload = buffer.slice(48, 80);
|
|
409
431
|
return (0, Utils_1.aesDecryptCTR)(payload, secretKey, iv);
|
|
@@ -566,14 +588,32 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
566
588
|
]);
|
|
567
589
|
};
|
|
568
590
|
const handleMessage = async (node) => {
|
|
569
|
-
var _a, _b;
|
|
591
|
+
var _a, _b, _c;
|
|
570
592
|
if (shouldIgnoreJid(node.attrs.from) && node.attrs.from !== '@s.whatsapp.net') {
|
|
571
593
|
logger.debug({ key: node.attrs.key }, 'ignored message');
|
|
572
594
|
await sendMessageAck(node);
|
|
573
595
|
return;
|
|
574
596
|
}
|
|
597
|
+
let response;
|
|
598
|
+
if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable') && !(0, WABinary_1.getBinaryNodeChild)(node, 'enc')) {
|
|
599
|
+
await sendMessageAck(node);
|
|
600
|
+
const { key } = (0, Utils_1.decodeMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '').fullMessage;
|
|
601
|
+
response = await requestPlaceholderResend(key);
|
|
602
|
+
if (response === 'RESOLVED') {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
logger.debug('received unavailable message, acked and requested resend from phone');
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
if (placeholderResendCache.get(node.attrs.id)) {
|
|
609
|
+
placeholderResendCache.del(node.attrs.id);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
575
612
|
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
|
|
576
|
-
if (
|
|
613
|
+
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) {
|
|
614
|
+
msg.messageStubParameters = [Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT, response];
|
|
615
|
+
}
|
|
616
|
+
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) {
|
|
577
617
|
if (node.attrs.sender_pn) {
|
|
578
618
|
ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
|
|
579
619
|
}
|
|
@@ -585,6 +625,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
585
625
|
if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
|
|
586
626
|
retryMutex.mutex(async () => {
|
|
587
627
|
if (ws.isOpen) {
|
|
628
|
+
if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable')) {
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
588
631
|
const encNode = (0, WABinary_1.getBinaryNodeChild)(node, 'enc');
|
|
589
632
|
await sendRetryRequest(node, !encNode);
|
|
590
633
|
if (retryRequestDelayMs) {
|
|
@@ -627,6 +670,54 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
627
670
|
sendMessageAck(node)
|
|
628
671
|
]);
|
|
629
672
|
};
|
|
673
|
+
const fetchMessageHistory = async (count, oldestMsgKey, oldestMsgTimestamp) => {
|
|
674
|
+
var _a;
|
|
675
|
+
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
676
|
+
throw new boom_1.Boom('Not authenticated');
|
|
677
|
+
}
|
|
678
|
+
const pdoMessage = {
|
|
679
|
+
historySyncOnDemandRequest: {
|
|
680
|
+
chatJid: oldestMsgKey.remoteJid,
|
|
681
|
+
oldestMsgFromMe: oldestMsgKey.fromMe,
|
|
682
|
+
oldestMsgId: oldestMsgKey.id,
|
|
683
|
+
oldestMsgTimestampMs: oldestMsgTimestamp,
|
|
684
|
+
onDemandMsgCount: count
|
|
685
|
+
},
|
|
686
|
+
peerDataOperationRequestType: WAProto_1.proto.Message.PeerDataOperationRequestType.HISTORY_SYNC_ON_DEMAND
|
|
687
|
+
};
|
|
688
|
+
return sendPeerDataOperationMessage(pdoMessage);
|
|
689
|
+
};
|
|
690
|
+
const requestPlaceholderResend = async (messageKey) => {
|
|
691
|
+
var _a;
|
|
692
|
+
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
693
|
+
throw new boom_1.Boom('Not authenticated');
|
|
694
|
+
}
|
|
695
|
+
if (placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
|
|
696
|
+
logger.debug('already requested resend', { messageKey });
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
placeholderResendCache.set(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id, true);
|
|
701
|
+
}
|
|
702
|
+
await (0, Utils_1.delay)(5000);
|
|
703
|
+
if (!placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
|
|
704
|
+
logger.debug('message received while resend requested', { messageKey });
|
|
705
|
+
return 'RESOLVED';
|
|
706
|
+
}
|
|
707
|
+
const pdoMessage = {
|
|
708
|
+
placeholderMessageResendRequest: [{
|
|
709
|
+
messageKey
|
|
710
|
+
}],
|
|
711
|
+
peerDataOperationRequestType: WAProto_1.proto.Message.PeerDataOperationRequestType.PLACEHOLDER_MESSAGE_RESEND
|
|
712
|
+
};
|
|
713
|
+
setTimeout(() => {
|
|
714
|
+
if (placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
|
|
715
|
+
logger.debug('PDO message without response after 15 seconds. Phone possibly offline', { messageKey });
|
|
716
|
+
placeholderResendCache.del(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id);
|
|
717
|
+
}
|
|
718
|
+
}, 15000);
|
|
719
|
+
return sendPeerDataOperationMessage(pdoMessage);
|
|
720
|
+
};
|
|
630
721
|
const handleCall = async (node) => {
|
|
631
722
|
const { attrs } = node;
|
|
632
723
|
const [infoChild] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
|
|
@@ -756,7 +847,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
756
847
|
...sock,
|
|
757
848
|
sendMessageAck,
|
|
758
849
|
sendRetryRequest,
|
|
759
|
-
rejectCall
|
|
850
|
+
rejectCall,
|
|
851
|
+
fetchMessageHistory,
|
|
852
|
+
requestPlaceholderResend,
|
|
760
853
|
};
|
|
761
854
|
};
|
|
762
855
|
exports.makeMessagesRecvSocket = makeMessagesRecvSocket;
|
|
@@ -6,16 +6,16 @@ import { BinaryNode } from '../WABinary';
|
|
|
6
6
|
export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
7
7
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
8
8
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
9
|
-
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache,
|
|
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;
|
|
16
15
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
17
16
|
[_: string]: string;
|
|
18
17
|
}>;
|
|
18
|
+
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
19
19
|
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
20
20
|
sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
|
|
21
21
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
@@ -38,6 +38,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
38
38
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
39
39
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
40
40
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
41
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
41
42
|
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
|
|
42
43
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
43
44
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
@@ -69,12 +70,13 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
69
70
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
70
71
|
updateProfileName: (name: string) => Promise<void>;
|
|
71
72
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
73
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
72
74
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
73
75
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
74
76
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
75
77
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
76
78
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
77
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
79
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
78
80
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
79
81
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
80
82
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|