@d0v3riz/baileys 6.7.5 → 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 +1 -1
- package/lib/Defaults/index.js +3 -1
- package/lib/Socket/business.d.ts +7 -5
- package/lib/Socket/chats.d.ts +2 -5
- package/lib/Socket/chats.js +9 -0
- package/lib/Socket/groups.d.ts +8 -1
- package/lib/Socket/groups.js +10 -0
- package/lib/Socket/index.d.ts +7 -5
- package/lib/Socket/messages-recv.d.ts +7 -6
- package/lib/Socket/messages-recv.js +94 -7
- package/lib/Socket/messages-send.d.ts +4 -3
- package/lib/Socket/messages-send.js +75 -68
- package/lib/Socket/registration.d.ts +7 -5
- package/lib/Store/make-in-memory-store.js +5 -1
- package/lib/Types/Chat.d.ts +1 -0
- package/lib/Types/Events.d.ts +5 -1
- package/lib/Types/Message.d.ts +27 -24
- package/lib/Types/Socket.d.ts +5 -0
- package/lib/Utils/decode-wa-message.d.ts +1 -0
- package/lib/Utils/decode-wa-message.js +16 -7
- package/lib/Utils/history.d.ts +4 -0
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/messages-media.d.ts +0 -1
- package/lib/Utils/messages.js +44 -58
- package/lib/Utils/process-message.d.ts +3 -2
- package/lib/Utils/process-message.js +43 -24
- package/lib/WABinary/jid-utils.d.ts +2 -0
- package/lib/WABinary/jid-utils.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -835,7 +835,7 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|
|
835
835
|
```
|
|
836
836
|
- To update the Groups Add privacy
|
|
837
837
|
``` ts
|
|
838
|
-
const value = 'all' // 'contacts' | 'contact_blacklist'
|
|
838
|
+
const value = 'all' // 'contacts' | 'contact_blacklist'
|
|
839
839
|
await sock.updateGroupsAddPrivacy(value)
|
|
840
840
|
```
|
|
841
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>;
|
|
@@ -92,7 +94,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
92
94
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
93
95
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
94
96
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
95
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
97
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
96
98
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
97
99
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
98
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, WAPrivacyCallValue, 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: {
|
|
@@ -35,7 +35,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
35
35
|
updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
36
36
|
updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
37
37
|
updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>;
|
|
38
|
-
updateGroupsAddPrivacy: (value:
|
|
38
|
+
updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
|
|
39
39
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
40
40
|
getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
|
|
41
41
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
@@ -67,9 +67,6 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
67
67
|
generateMessageTag: () => string;
|
|
68
68
|
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
|
|
69
69
|
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
|
|
70
|
-
/**
|
|
71
|
-
* Star or Unstar a message
|
|
72
|
-
*/
|
|
73
70
|
waitForSocketOpen: () => Promise<void>;
|
|
74
71
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
75
72
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
package/lib/Socket/chats.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeChatsSocket = void 0;
|
|
7
7
|
const boom_1 = require("@hapi/boom");
|
|
8
|
+
const node_cache_1 = __importDefault(require("node-cache"));
|
|
8
9
|
const WAProto_1 = require("../../WAProto");
|
|
9
10
|
const Defaults_1 = require("../Defaults");
|
|
10
11
|
const Types_1 = require("../Types");
|
|
@@ -23,6 +24,13 @@ const makeChatsSocket = (config) => {
|
|
|
23
24
|
let pendingAppStateSync = false;
|
|
24
25
|
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
|
|
25
26
|
const processingMutex = (0, make_mutex_1.makeMutex)();
|
|
27
|
+
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
28
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
29
|
+
useClones: false
|
|
30
|
+
});
|
|
31
|
+
if (!config.placeholderResendCache) {
|
|
32
|
+
config.placeholderResendCache = placeholderResendCache;
|
|
33
|
+
}
|
|
26
34
|
/** helper function to fetch the given app state sync key */
|
|
27
35
|
const getAppStateSyncKey = async (keyId) => {
|
|
28
36
|
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
|
|
@@ -734,6 +742,7 @@ const makeChatsSocket = (config) => {
|
|
|
734
742
|
})(),
|
|
735
743
|
(0, process_message_1.default)(msg, {
|
|
736
744
|
shouldProcessHistoryMsg,
|
|
745
|
+
placeholderResendCache,
|
|
737
746
|
ev,
|
|
738
747
|
creds: authState.creds,
|
|
739
748
|
keyStore: authState.keys,
|
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
|
|
@@ -68,7 +75,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
68
75
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
69
76
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
70
77
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
71
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
78
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
72
79
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
73
80
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
74
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,6 +187,16 @@ 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
|
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>;
|
|
@@ -93,7 +95,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
93
95
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
94
96
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
95
97
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
96
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
98
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
97
99
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
98
100
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
99
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>;
|
|
@@ -80,7 +81,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
80
81
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
81
82
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
82
83
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
83
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
84
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
84
85
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
85
86
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
86
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,8 +79,10 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
75
79
|
await query(stanza);
|
|
76
80
|
};
|
|
77
81
|
const sendRetryRequest = async (node, forceIncludeKeys = false) => {
|
|
78
|
-
const {
|
|
79
|
-
const key =
|
|
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}`;
|
|
80
86
|
let retryCount = msgRetryCache.get(key) || 0;
|
|
81
87
|
if (retryCount >= maxMsgRetryCount) {
|
|
82
88
|
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing');
|
|
@@ -86,6 +92,11 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
86
92
|
retryCount += 1;
|
|
87
93
|
msgRetryCache.set(key, retryCount);
|
|
88
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
|
+
}
|
|
89
100
|
const deviceIdentity = (0, Utils_1.encodeSignedDeviceIdentity)(account, true);
|
|
90
101
|
await authState.keys.transaction(async () => {
|
|
91
102
|
const receipt = {
|
|
@@ -164,7 +175,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
164
175
|
}
|
|
165
176
|
};
|
|
166
177
|
const handleGroupNotification = (participant, child, msg) => {
|
|
167
|
-
var _a, _b;
|
|
178
|
+
var _a, _b, _c, _d;
|
|
168
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;
|
|
169
180
|
switch (child === null || child === void 0 ? void 0 : child.tag) {
|
|
170
181
|
case 'create':
|
|
@@ -217,6 +228,11 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
217
228
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT;
|
|
218
229
|
msg.messageStubParameters = [child.attrs.subject];
|
|
219
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;
|
|
220
236
|
case 'announcement':
|
|
221
237
|
case 'not_announcement':
|
|
222
238
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE;
|
|
@@ -572,14 +588,32 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
572
588
|
]);
|
|
573
589
|
};
|
|
574
590
|
const handleMessage = async (node) => {
|
|
575
|
-
var _a, _b;
|
|
591
|
+
var _a, _b, _c;
|
|
576
592
|
if (shouldIgnoreJid(node.attrs.from) && node.attrs.from !== '@s.whatsapp.net') {
|
|
577
593
|
logger.debug({ key: node.attrs.key }, 'ignored message');
|
|
578
594
|
await sendMessageAck(node);
|
|
579
595
|
return;
|
|
580
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
|
+
}
|
|
581
612
|
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
|
|
582
|
-
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) {
|
|
583
617
|
if (node.attrs.sender_pn) {
|
|
584
618
|
ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
|
|
585
619
|
}
|
|
@@ -591,6 +625,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
591
625
|
if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
|
|
592
626
|
retryMutex.mutex(async () => {
|
|
593
627
|
if (ws.isOpen) {
|
|
628
|
+
if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable')) {
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
594
631
|
const encNode = (0, WABinary_1.getBinaryNodeChild)(node, 'enc');
|
|
595
632
|
await sendRetryRequest(node, !encNode);
|
|
596
633
|
if (retryRequestDelayMs) {
|
|
@@ -633,6 +670,54 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
633
670
|
sendMessageAck(node)
|
|
634
671
|
]);
|
|
635
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
|
+
};
|
|
636
721
|
const handleCall = async (node) => {
|
|
637
722
|
const { attrs } = node;
|
|
638
723
|
const [infoChild] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
|
|
@@ -762,7 +847,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
762
847
|
...sock,
|
|
763
848
|
sendMessageAck,
|
|
764
849
|
sendRetryRequest,
|
|
765
|
-
rejectCall
|
|
850
|
+
rejectCall,
|
|
851
|
+
fetchMessageHistory,
|
|
852
|
+
requestPlaceholderResend,
|
|
766
853
|
};
|
|
767
854
|
};
|
|
768
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>;
|
|
@@ -75,7 +76,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
75
76
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
76
77
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
77
78
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
78
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
79
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
79
80
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
80
81
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
81
82
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|