@d0v3riz/baileys 6.6.0 → 6.6.2
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 +11 -1
- package/WAProto/WAProto.proto +473 -8
- package/WAProto/index.d.ts +4793 -22
- package/WAProto/index.js +32548 -19335
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +1 -1
- package/lib/Defaults/index.js +7 -3
- package/lib/Socket/business.d.ts +3 -1
- package/lib/Socket/groups.d.ts +2 -0
- package/lib/Socket/groups.js +8 -1
- package/lib/Socket/index.d.ts +3 -1
- package/lib/Socket/messages-recv.d.ts +3 -1
- package/lib/Socket/messages-recv.js +28 -5
- package/lib/Socket/messages-send.d.ts +2 -0
- package/lib/Socket/registration.d.ts +3 -1
- package/lib/Store/make-cache-manager-store.d.ts +1 -2
- package/lib/Types/GroupMetadata.d.ts +2 -0
- package/lib/Types/Socket.d.ts +2 -0
- package/lib/Utils/generics.d.ts +1 -0
- package/lib/Utils/generics.js +1 -0
- package/lib/Utils/messages-media.js +1 -1
- package/lib/Utils/messages.js +2 -1
- package/lib/Utils/process-message.js +11 -3
- package/package.json +4 -4
package/lib/Defaults/index.d.ts
CHANGED
|
@@ -234,7 +234,7 @@ export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
|
234
234
|
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
235
235
|
export declare const MOBILE_TOKEN: Buffer;
|
|
236
236
|
export declare const MOBILE_REGISTRATION_ENDPOINT = "https://v.whatsapp.net/v2";
|
|
237
|
-
export declare const MOBILE_USERAGENT
|
|
237
|
+
export declare const MOBILE_USERAGENT: string;
|
|
238
238
|
export declare const REGISTRATION_PUBLIC_KEY: Buffer;
|
|
239
239
|
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
240
240
|
export declare const DICT_VERSION = 2;
|
package/lib/Defaults/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DEFAULT_CACHE_TTLS = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_EXCLUDE_REGEX = exports.URL_REGEX = exports.MOBILE_NOISE_HEADER = exports.PROTOCOL_VERSION = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.REGISTRATION_PUBLIC_KEY = exports.MOBILE_USERAGENT = exports.MOBILE_REGISTRATION_ENDPOINT = exports.MOBILE_TOKEN = exports.WA_DEFAULT_EPHEMERAL = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.MOBILE_PORT = exports.MOBILE_ENDPOINT = exports.DEFAULT_ORIGIN = exports.PHONENUMBER_MCC = exports.UNAUTHORIZED_CODES = void 0;
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
7
8
|
const WAProto_1 = require("../../WAProto");
|
|
8
9
|
const libsignal_1 = require("../Signal/libsignal");
|
|
9
10
|
const Utils_1 = require("../Utils");
|
|
@@ -19,9 +20,11 @@ exports.DEF_CALLBACK_PREFIX = 'CB:';
|
|
|
19
20
|
exports.DEF_TAG_PREFIX = 'TAG:';
|
|
20
21
|
exports.PHONE_CONNECTION_CB = 'CB:Pong';
|
|
21
22
|
exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
22
|
-
|
|
23
|
+
const WA_VERSION = '2.23.14.82';
|
|
24
|
+
const WA_VERSION_HASH = (0, crypto_1.createHash)('md5').update(WA_VERSION).digest('hex');
|
|
25
|
+
exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' + WA_VERSION_HASH);
|
|
23
26
|
exports.MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
|
|
24
|
-
exports.MOBILE_USERAGENT =
|
|
27
|
+
exports.MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/15.3.1 Device/Apple-iPhone_7`;
|
|
25
28
|
exports.REGISTRATION_PUBLIC_KEY = Buffer.from([
|
|
26
29
|
5, 142, 140, 15, 116, 195, 235, 197, 215, 166, 134, 92, 108, 60, 132, 56, 86, 176, 97, 33, 204, 232, 234, 119, 77,
|
|
27
30
|
34, 251, 111, 18, 37, 18, 48, 45,
|
|
@@ -46,7 +49,7 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
46
49
|
];
|
|
47
50
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
48
51
|
version: baileys_version_json_1.version,
|
|
49
|
-
browser: Utils_1.Browsers.
|
|
52
|
+
browser: Utils_1.Browsers.ubuntu('Chrome'),
|
|
50
53
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
51
54
|
connectTimeoutMs: 20000,
|
|
52
55
|
keepAliveIntervalMs: 30000,
|
|
@@ -56,6 +59,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
56
59
|
defaultQueryTimeoutMs: 60000,
|
|
57
60
|
customUploadHosts: [],
|
|
58
61
|
retryRequestDelayMs: 250,
|
|
62
|
+
maxMsgRetryCount: 5,
|
|
59
63
|
fireInitQueries: true,
|
|
60
64
|
auth: undefined,
|
|
61
65
|
markOnlineOnConnect: true,
|
package/lib/Socket/business.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
15
15
|
deleted: number;
|
|
16
16
|
}>;
|
|
17
17
|
productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
|
|
18
|
-
sendMessageAck: ({ tag, attrs }: BinaryNode) => Promise<void>;
|
|
18
|
+
sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
|
|
19
19
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
20
20
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
21
21
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
@@ -58,6 +58,8 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
58
58
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
59
59
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
60
60
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
61
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
|
62
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
61
63
|
groupFetchAllParticipating: () => Promise<{
|
|
62
64
|
[_: string]: import("../Types").GroupMetadata;
|
|
63
65
|
}>;
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
32
32
|
groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
|
|
33
33
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
34
34
|
groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
|
|
35
|
+
groupMemberAddMode: (jid: string, mode: 'admin_add' | 'all_member_add') => Promise<void>;
|
|
36
|
+
groupJoinApprovalMode: (jid: string, mode: 'on' | 'off') => Promise<void>;
|
|
35
37
|
groupFetchAllParticipating: () => Promise<{
|
|
36
38
|
[_: string]: GroupMetadata;
|
|
37
39
|
}>;
|
package/lib/Socket/groups.js
CHANGED
|
@@ -250,6 +250,12 @@ const makeGroupsSocket = (config) => {
|
|
|
250
250
|
groupSettingUpdate: async (jid, setting) => {
|
|
251
251
|
await groupQuery(jid, 'set', [{ tag: setting, attrs: {} }]);
|
|
252
252
|
},
|
|
253
|
+
groupMemberAddMode: async (jid, mode) => {
|
|
254
|
+
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
|
|
255
|
+
},
|
|
256
|
+
groupJoinApprovalMode: async (jid, mode) => {
|
|
257
|
+
await groupQuery(jid, 'set', [{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }]);
|
|
258
|
+
},
|
|
253
259
|
groupFetchAllParticipating
|
|
254
260
|
};
|
|
255
261
|
};
|
|
@@ -272,7 +278,7 @@ const extractGroupMetadata = (result) => {
|
|
|
272
278
|
subject: group.attrs.subject,
|
|
273
279
|
subjectOwner: group.attrs.s_o,
|
|
274
280
|
subjectTime: +group.attrs.s_t,
|
|
275
|
-
size:
|
|
281
|
+
size: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
|
|
276
282
|
creation: +group.attrs.creation,
|
|
277
283
|
owner: group.attrs.creator ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) : undefined,
|
|
278
284
|
desc,
|
|
@@ -281,6 +287,7 @@ const extractGroupMetadata = (result) => {
|
|
|
281
287
|
announce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'announcement'),
|
|
282
288
|
isCommunity: !!(0, WABinary_1.getBinaryNodeChild)(group, 'parent'),
|
|
283
289
|
isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'default_sub_group'),
|
|
290
|
+
joinApprovalMode: !!(0, WABinary_1.getBinaryNodeChild)(group, 'membership_approval_mode'),
|
|
284
291
|
memberAddMode,
|
|
285
292
|
participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
|
|
286
293
|
return {
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
16
16
|
deleted: number;
|
|
17
17
|
}>;
|
|
18
18
|
productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
|
|
19
|
-
sendMessageAck: ({ tag, attrs }: import("../index").BinaryNode) => Promise<void>;
|
|
19
|
+
sendMessageAck: ({ tag, attrs, content }: import("../index").BinaryNode) => Promise<void>;
|
|
20
20
|
sendRetryRequest: (node: import("../index").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
21
21
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
22
22
|
getPrivacyTokens: (jids: string[]) => Promise<import("../index").BinaryNode>;
|
|
@@ -59,6 +59,8 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
59
59
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
60
60
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
61
61
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
62
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
|
63
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
62
64
|
groupFetchAllParticipating: () => Promise<{
|
|
63
65
|
[_: string]: import("../Types").GroupMetadata;
|
|
64
66
|
}>;
|
|
@@ -4,7 +4,7 @@ import { proto } from '../../WAProto';
|
|
|
4
4
|
import { MessageReceiptType, MessageRelayOptions, SocketConfig } from '../Types';
|
|
5
5
|
import { BinaryNode } from '../WABinary';
|
|
6
6
|
export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
7
|
-
sendMessageAck: ({ tag, attrs }: BinaryNode) => Promise<void>;
|
|
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
10
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
@@ -47,6 +47,8 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
47
47
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
48
48
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
49
49
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
50
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
|
51
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
50
52
|
groupFetchAllParticipating: () => Promise<{
|
|
51
53
|
[_: string]: import("../Types").GroupMetadata;
|
|
52
54
|
}>;
|
|
@@ -17,7 +17,7 @@ const WABinary_1 = require("../WABinary");
|
|
|
17
17
|
const groups_1 = require("./groups");
|
|
18
18
|
const messages_send_1 = require("./messages-send");
|
|
19
19
|
const makeMessagesRecvSocket = (config) => {
|
|
20
|
-
const { logger, retryRequestDelayMs, getMessage, shouldIgnoreJid } = config;
|
|
20
|
+
const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
|
|
21
21
|
const sock = (0, messages_send_1.makeMessagesSocket)(config);
|
|
22
22
|
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, } = sock;
|
|
23
23
|
/** this mutex ensures that each retryRequest will wait for the previous one to finish */
|
|
@@ -31,7 +31,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
31
31
|
useClones: false
|
|
32
32
|
});
|
|
33
33
|
let sendActiveReceipts = false;
|
|
34
|
-
const sendMessageAck = async ({ tag, attrs }) => {
|
|
34
|
+
const sendMessageAck = async ({ tag, attrs, content }) => {
|
|
35
35
|
const stanza = {
|
|
36
36
|
tag: 'ack',
|
|
37
37
|
attrs: {
|
|
@@ -46,9 +46,12 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
46
46
|
if (!!attrs.recipient) {
|
|
47
47
|
stanza.attrs.recipient = attrs.recipient;
|
|
48
48
|
}
|
|
49
|
-
if (tag !== 'message'
|
|
49
|
+
if (!!attrs.type && (tag !== 'message' || (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable'))) {
|
|
50
50
|
stanza.attrs.type = attrs.type;
|
|
51
51
|
}
|
|
52
|
+
if (tag === 'message' && (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable')) {
|
|
53
|
+
stanza.attrs.from = authState.creds.me.id;
|
|
54
|
+
}
|
|
52
55
|
logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack');
|
|
53
56
|
await sendNode(stanza);
|
|
54
57
|
};
|
|
@@ -74,7 +77,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
74
77
|
const sendRetryRequest = async (node, forceIncludeKeys = false) => {
|
|
75
78
|
const msgId = node.attrs.id;
|
|
76
79
|
let retryCount = msgRetryCache.get(msgId) || 0;
|
|
77
|
-
if (retryCount >=
|
|
80
|
+
if (retryCount >= maxMsgRetryCount) {
|
|
78
81
|
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing');
|
|
79
82
|
msgRetryCache.del(msgId);
|
|
80
83
|
return;
|
|
@@ -220,6 +223,20 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
220
223
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_INVITE_LINK;
|
|
221
224
|
msg.messageStubParameters = [child.attrs.code];
|
|
222
225
|
break;
|
|
226
|
+
case 'member_add_mode':
|
|
227
|
+
const addMode = child.content;
|
|
228
|
+
if (addMode) {
|
|
229
|
+
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE;
|
|
230
|
+
msg.messageStubParameters = [addMode.toString()];
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case 'membership_approval_mode':
|
|
234
|
+
const approvalMode = (0, WABinary_1.getBinaryNodeChild)(child, 'group_join');
|
|
235
|
+
if (approvalMode) {
|
|
236
|
+
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE;
|
|
237
|
+
msg.messageStubParameters = [approvalMode.attrs.state];
|
|
238
|
+
}
|
|
239
|
+
break;
|
|
223
240
|
}
|
|
224
241
|
};
|
|
225
242
|
const processNotification = async (node) => {
|
|
@@ -388,7 +405,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
388
405
|
const willSendMessageAgain = (id, participant) => {
|
|
389
406
|
const key = `${id}:${participant}`;
|
|
390
407
|
const retryCount = msgRetryCache.get(key) || 0;
|
|
391
|
-
return retryCount <
|
|
408
|
+
return retryCount < maxMsgRetryCount;
|
|
392
409
|
};
|
|
393
410
|
const updateSendMessageAgainCount = (id, participant) => {
|
|
394
411
|
const key = `${id}:${participant}`;
|
|
@@ -538,6 +555,12 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
538
555
|
};
|
|
539
556
|
const handleMessage = async (node) => {
|
|
540
557
|
var _a, _b;
|
|
558
|
+
if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable') && !(0, WABinary_1.getBinaryNodeChild)(node, 'enc')) {
|
|
559
|
+
// "missing message from node" fix
|
|
560
|
+
logger.debug(node, 'missing body; sending ack then ignoring.');
|
|
561
|
+
await sendMessageAck(node);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
541
564
|
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
|
|
542
565
|
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) {
|
|
543
566
|
if (node.attrs.sender_pn) {
|
|
@@ -42,6 +42,8 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
42
42
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
43
43
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
44
44
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
45
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
|
46
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
45
47
|
groupFetchAllParticipating: () => Promise<{
|
|
46
48
|
[_: string]: import("../Types").GroupMetadata;
|
|
47
49
|
}>;
|
|
@@ -17,7 +17,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
17
17
|
deleted: number;
|
|
18
18
|
}>;
|
|
19
19
|
productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
|
|
20
|
-
sendMessageAck: ({ tag, attrs }: import("../WABinary").BinaryNode) => Promise<void>;
|
|
20
|
+
sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode) => Promise<void>;
|
|
21
21
|
sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
22
22
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
23
23
|
getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
|
|
@@ -60,6 +60,8 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
60
60
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
61
61
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
62
62
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
63
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
|
64
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
63
65
|
groupFetchAllParticipating: () => Promise<{
|
|
64
66
|
[_: string]: import("../Types").GroupMetadata;
|
|
65
67
|
}>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Store } from 'cache-manager';
|
|
2
1
|
import { AuthenticationCreds } from '../Types';
|
|
3
|
-
declare const makeCacheManagerAuthState: (store:
|
|
2
|
+
declare const makeCacheManagerAuthState: (store: Storage, sessionKey: string) => Promise<{
|
|
4
3
|
clearState: () => Promise<void>;
|
|
5
4
|
saveCreds: () => Promise<void>;
|
|
6
5
|
state: {
|
|
@@ -23,6 +23,8 @@ export interface GroupMetadata {
|
|
|
23
23
|
announce?: boolean;
|
|
24
24
|
/** is set when the group also allows members to add participants */
|
|
25
25
|
memberAddMode?: boolean;
|
|
26
|
+
/** Request approval to join the group */
|
|
27
|
+
joinApprovalMode?: boolean;
|
|
26
28
|
/** is this a community */
|
|
27
29
|
isCommunity?: boolean;
|
|
28
30
|
/** is this the announce of a community */
|
package/lib/Types/Socket.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export type SocketConfig = {
|
|
|
49
49
|
customUploadHosts: MediaConnInfo['hosts'];
|
|
50
50
|
/** time to wait between sending new retry requests */
|
|
51
51
|
retryRequestDelayMs: number;
|
|
52
|
+
/** max retry count */
|
|
53
|
+
maxMsgRetryCount: number;
|
|
52
54
|
/** time to wait for the generation of the next QR in ms */
|
|
53
55
|
qrTimeout?: number;
|
|
54
56
|
/** provide an auth state object to maintain the auth state */
|
package/lib/Utils/generics.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const Browsers: {
|
|
|
8
8
|
ubuntu: (browser: any) => [string, string, string];
|
|
9
9
|
macOS: (browser: any) => [string, string, string];
|
|
10
10
|
baileys: (browser: any) => [string, string, string];
|
|
11
|
+
windows: (browser: any) => [string, string, string];
|
|
11
12
|
/** The appropriate browser based on your OS & release */
|
|
12
13
|
appropriate: (browser: any) => [string, string, string];
|
|
13
14
|
};
|
package/lib/Utils/generics.js
CHANGED
|
@@ -22,6 +22,7 @@ exports.Browsers = {
|
|
|
22
22
|
ubuntu: browser => ['Ubuntu', browser, '20.0.04'],
|
|
23
23
|
macOS: browser => ['Mac OS', browser, '10.15.7'],
|
|
24
24
|
baileys: browser => ['Baileys', browser, '4.0.0'],
|
|
25
|
+
windows: browser => ['Windows', browser, '10.0.22621'],
|
|
25
26
|
/** The appropriate browser based on your OS & release */
|
|
26
27
|
appropriate: browser => [PLATFORM_MAP[(0, os_1.platform)()] || 'Ubuntu', browser, (0, os_1.release)()]
|
|
27
28
|
};
|
|
@@ -213,7 +213,7 @@ exports.getAudioDuration = getAudioDuration;
|
|
|
213
213
|
*/
|
|
214
214
|
async function getAudioWaveform(buffer, logger) {
|
|
215
215
|
try {
|
|
216
|
-
const audioDecode = (
|
|
216
|
+
const audioDecode = (buffer) => import('audio-decode').then(({ default: audioDecode }) => audioDecode(buffer));
|
|
217
217
|
let audioData;
|
|
218
218
|
if (Buffer.isBuffer(buffer)) {
|
|
219
219
|
audioData = buffer;
|
package/lib/Utils/messages.js
CHANGED
|
@@ -554,6 +554,7 @@ const normalizeMessageContent = (content) => {
|
|
|
554
554
|
|| (message === null || message === void 0 ? void 0 : message.viewOnceMessage)
|
|
555
555
|
|| (message === null || message === void 0 ? void 0 : message.documentWithCaptionMessage)
|
|
556
556
|
|| (message === null || message === void 0 ? void 0 : message.viewOnceMessageV2)
|
|
557
|
+
|| (message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension)
|
|
557
558
|
|| (message === null || message === void 0 ? void 0 : message.editedMessage));
|
|
558
559
|
}
|
|
559
560
|
};
|
|
@@ -604,7 +605,7 @@ exports.extractMessageContent = extractMessageContent;
|
|
|
604
605
|
/**
|
|
605
606
|
* Returns the device predicted by message ID
|
|
606
607
|
*/
|
|
607
|
-
const getDevice = (id) => /^3A
|
|
608
|
+
const getDevice = (id) => /^3A.{18}$/.test(id) ? 'ios' : /^3E.{20}$/.test(id) ? 'web' : /^(.{21}|.{32})$/.test(id) ? 'android' : /^.{18}$/.test(id) ? 'desktop' : 'unknown';
|
|
608
609
|
exports.getDevice = getDevice;
|
|
609
610
|
/** Upserts a receipt in the message */
|
|
610
611
|
const updateMessageWithReceipt = (msg, receipt) => {
|
|
@@ -103,7 +103,7 @@ function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pol
|
|
|
103
103
|
}
|
|
104
104
|
exports.decryptPollVote = decryptPollVote;
|
|
105
105
|
const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, keyStore, logger, options, getMessage }) => {
|
|
106
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
107
107
|
const meId = creds.me.id;
|
|
108
108
|
const { accountSettings } = creds;
|
|
109
109
|
const chat = { id: (0, WABinary_1.jidNormalizedUser)((0, exports.getChatId)(message.key)) };
|
|
@@ -264,6 +264,14 @@ const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, key
|
|
|
264
264
|
const code = (_g = message.messageStubParameters) === null || _g === void 0 ? void 0 : _g[0];
|
|
265
265
|
emitGroupUpdate({ inviteCode: code });
|
|
266
266
|
break;
|
|
267
|
+
case Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE:
|
|
268
|
+
const memberAddValue = (_h = message.messageStubParameters) === null || _h === void 0 ? void 0 : _h[0];
|
|
269
|
+
emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' });
|
|
270
|
+
break;
|
|
271
|
+
case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
|
|
272
|
+
const approvalMode = (_j = message.messageStubParameters) === null || _j === void 0 ? void 0 : _j[0];
|
|
273
|
+
emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' });
|
|
274
|
+
break;
|
|
267
275
|
}
|
|
268
276
|
}
|
|
269
277
|
else if (content === null || content === void 0 ? void 0 : content.pollUpdateMessage) {
|
|
@@ -274,7 +282,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, key
|
|
|
274
282
|
const meIdNormalised = (0, WABinary_1.jidNormalizedUser)(meId);
|
|
275
283
|
const pollCreatorJid = (0, generics_1.getKeyAuthor)(creationMsgKey, meIdNormalised);
|
|
276
284
|
const voterJid = (0, generics_1.getKeyAuthor)(message.key, meIdNormalised);
|
|
277
|
-
const pollEncKey = (
|
|
285
|
+
const pollEncKey = (_k = pollMsg.messageContextInfo) === null || _k === void 0 ? void 0 : _k.messageSecret;
|
|
278
286
|
try {
|
|
279
287
|
const voteMsg = decryptPollVote(content.pollUpdateMessage.vote, {
|
|
280
288
|
pollEncKey,
|
|
@@ -290,7 +298,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, key
|
|
|
290
298
|
{
|
|
291
299
|
pollUpdateMessageKey: message.key,
|
|
292
300
|
vote: voteMsg,
|
|
293
|
-
senderTimestampMs:
|
|
301
|
+
senderTimestampMs: content.pollUpdateMessage.senderTimestampMs.toNumber(),
|
|
294
302
|
}
|
|
295
303
|
]
|
|
296
304
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d0v3riz/baileys",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.2",
|
|
4
4
|
"description": "WhatsApp API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"@hapi/boom": "^9.1.3",
|
|
48
48
|
"audio-decode": "^2.1.3",
|
|
49
49
|
"axios": "^1.3.3",
|
|
50
|
-
"cache-manager": "
|
|
50
|
+
"cache-manager": "4.0.1",
|
|
51
51
|
"futoin-hkdf": "^1.5.1",
|
|
52
52
|
"libphonenumber-js": "^1.10.20",
|
|
53
53
|
"libsignal": "https://github.com/d0v3riz/libsignal-node.git",
|
|
54
54
|
"music-metadata": "^7.12.3",
|
|
55
55
|
"node-cache": "^5.1.2",
|
|
56
56
|
"pino": "^7.0.0",
|
|
57
|
-
"protobufjs": "^
|
|
57
|
+
"protobufjs": "^7.2.4",
|
|
58
58
|
"uuid": "^9.0.0",
|
|
59
59
|
"ws": "^8.13.0"
|
|
60
60
|
},
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"jimp": "^0.16.1",
|
|
84
84
|
"link-preview-js": "^3.0.0",
|
|
85
85
|
"qrcode-terminal": "^0.12.0",
|
|
86
|
-
"sharp": "^0.
|
|
86
|
+
"sharp": "^0.32.2"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"jimp": {
|