@d0v3riz/baileys 6.7.5 → 6.7.7

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 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' | 'none'
838
+ const value = 'all' // 'contacts' | 'contact_blacklist'
839
839
  await sock.updateGroupsAddPrivacy(value)
840
840
  ```
841
841
  - To update the Default Disappearing Mode
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": [2, 2413, 1]
2
+ "version": [2, 3000, 1015901307]
3
3
  }
@@ -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 = {
@@ -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,27 @@ 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, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
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>;
37
+ createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
38
+ [key: string]: string;
39
+ } | undefined) => Promise<{
40
+ nodes: BinaryNode[];
41
+ shouldIncludeDeviceIdentity: boolean;
42
+ }>;
43
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
36
44
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
37
45
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
38
46
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
@@ -55,6 +63,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
55
63
  groupInviteCode: (jid: string) => Promise<string | undefined>;
56
64
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
57
65
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
66
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
58
67
  groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
59
68
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
60
69
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
@@ -92,7 +101,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
92
101
  updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
93
102
  updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
94
103
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
95
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
104
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
96
105
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
97
106
  getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
98
107
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { Boom } from '@hapi/boom';
3
3
  import { proto } from '../../WAProto';
4
- import { 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: WAPrivacyValue) => Promise<void>;
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>;
@@ -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,
@@ -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").WAPrivacyValue) => Promise<void>;
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>;
@@ -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
@@ -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,27 @@ 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, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
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>;
38
+ createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
39
+ [key: string]: string;
40
+ } | undefined) => Promise<{
41
+ nodes: import("../index").BinaryNode[];
42
+ shouldIncludeDeviceIdentity: boolean;
43
+ }>;
44
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../index").JidWithDevice[]>;
37
45
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
38
46
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
39
47
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
@@ -56,6 +64,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
56
64
  groupInviteCode: (jid: string) => Promise<string | undefined>;
57
65
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
58
66
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
67
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
59
68
  groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
60
69
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
61
70
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
@@ -93,7 +102,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
93
102
  updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
94
103
  updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
95
104
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
96
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
105
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
97
106
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
98
107
  getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
99
108
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
@@ -1,26 +1,33 @@
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, cachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
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
+ createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: {
25
+ [key: string]: string;
26
+ } | undefined) => Promise<{
27
+ nodes: BinaryNode[];
28
+ shouldIncludeDeviceIdentity: boolean;
29
+ }>;
30
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
24
31
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
25
32
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
26
33
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
@@ -43,6 +50,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
43
50
  groupInviteCode: (jid: string) => Promise<string | undefined>;
44
51
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
45
52
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
53
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
46
54
  groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
47
55
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
48
56
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
@@ -80,7 +88,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
80
88
  updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
81
89
  updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
82
90
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
83
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
91
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
84
92
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
85
93
  getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
86
94
  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 { id: msgId, participant } = node.attrs;
79
- const key = `${msgId}:${participant}`;
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;
@@ -304,7 +320,7 @@ const makeMessagesRecvSocket = (config) => {
304
320
  const setPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'set');
305
321
  const delPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'delete');
306
322
  ev.emit('contacts.update', [{
307
- id: (0, WABinary_1.jidNormalizedUser)((_a = node === null || node === void 0 ? void 0 : node.attrs) === null || _a === void 0 ? void 0 : _a.jid) || ((_c = (_b = (setPicture || delPicture)) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c.hash) || '',
323
+ id: (0, WABinary_1.jidNormalizedUser)((_a = node === null || node === void 0 ? void 0 : node.attrs) === null || _a === void 0 ? void 0 : _a.from) || ((_c = (_b = (setPicture || delPicture)) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c.hash) || '',
308
324
  imgUrl: setPicture ? 'changed' : 'removed'
309
325
  }]);
310
326
  if ((0, WABinary_1.isJidGroup)(from)) {
@@ -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 (((_b = (_a = msg.message) === null || _a === void 0 ? void 0 : _a.protocolMessage) === null || _b === void 0 ? void 0 : _b.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER) {
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;
@@ -2,20 +2,25 @@
2
2
  import { Boom } from '@hapi/boom';
3
3
  import { proto } from '../../WAProto';
4
4
  import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, SocketConfig, WAMessageKey } from '../Types';
5
- import { BinaryNode } from '../WABinary';
5
+ import { BinaryNode, JidWithDevice } 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, cachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
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
+ createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode['attrs']) => Promise<{
20
+ nodes: BinaryNode[];
21
+ shouldIncludeDeviceIdentity: boolean;
22
+ }>;
23
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<JidWithDevice[]>;
19
24
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
20
25
  sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
21
26
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
@@ -38,6 +43,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
38
43
  groupInviteCode: (jid: string) => Promise<string | undefined>;
39
44
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
40
45
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
46
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
41
47
  groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
42
48
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
43
49
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
@@ -75,7 +81,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
75
81
  updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
76
82
  updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
77
83
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
78
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
84
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
79
85
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
80
86
  getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
81
87
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;