Socket
Socket
Sign inDemoInstall

@neoxr/baileys

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neoxr/baileys - npm Package Compare versions

Comparing version 6.7.4 to 6.7.5

56

lib/Socket/messages-recv.js

@@ -20,3 +20,3 @@ "use strict";

const makeMessagesRecvSocket = (config) => {
const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
const { logger, retryRequestDelayMs, getMessage, shouldIgnoreJid } = config;
const sock = (0, messages_send_1.makeMessagesSocket)(config);

@@ -35,3 +35,3 @@ const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, } = sock;

let sendActiveReceipts = false;
const sendMessageAck = async ({ tag, attrs, content }) => {
const sendMessageAck = async ({ tag, attrs }) => {
const stanza = {

@@ -51,8 +51,5 @@ tag: 'ack',

}
if (!!attrs.type && (tag !== 'message' || (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable'))) {
if (tag !== 'message' && attrs.type) {
stanza.attrs.type = attrs.type;
}
if (tag === 'message' && (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable')) {
stanza.attrs.from = authState.creds.me.id;
}
logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack');

@@ -83,3 +80,3 @@ await sendNode(stanza);

let retryCount = msgRetryCache.get(msgId) || 0;
if (retryCount >= maxMsgRetryCount) {
if (retryCount >= 5) {
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing');

@@ -230,20 +227,5 @@ msgRetryCache.del(msgId);

break;
case 'member_add_mode':
const addMode = child.content;
if (addMode) {
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE;
msg.messageStubParameters = [addMode.toString()];
}
break;
case 'membership_approval_mode':
const approvalMode = (0, WABinary_1.getBinaryNodeChild)(child, 'group_join');
if (approvalMode) {
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE;
msg.messageStubParameters = [approvalMode.attrs.state];
}
break;
}
};
const processNotification = async (node) => {
var _a, _b, _c;
const result = {};

@@ -295,4 +277,4 @@ const [child] = (0, WABinary_1.getAllBinaryNodeChildren)(node);

ev.emit('contacts.update', [{
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) || '',
imgUrl: setPicture ? 'changed' : 'removed'
id: from,
imgUrl: setPicture ? 'changed' : null
}]);

@@ -327,10 +309,2 @@ if ((0, WABinary_1.isJidGroup)(from)) {

}
else if (child.tag === 'blocklist') {
const blocklists = (0, WABinary_1.getBinaryNodeChildren)(child, 'item');
for (const { attrs } of blocklists) {
const blocklist = [attrs.jid];
const type = (attrs.action === 'block') ? 'add' : 'remove';
ev.emit('blocklist.update', { blocklist, type });
}
}
break;

@@ -416,3 +390,3 @@ case 'link_code_companion_reg':

const retryCount = msgRetryCache.get(key) || 0;
return retryCount < maxMsgRetryCount;
return retryCount < 5;
};

@@ -460,6 +434,5 @@ const updateSendMessageAgainCount = (id, participant) => {

const handleReceipt = async (node) => {
var _a, _b;
var _a;
const { attrs, content } = node;
const isLid = attrs.from.includes('lid');
const isNodeFromMe = (0, WABinary_1.areJidsSameUser)(attrs.participant || attrs.from, isLid ? (_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.lid : (_b = authState.creds.me) === null || _b === void 0 ? void 0 : _b.id);
const isNodeFromMe = (0, WABinary_1.areJidsSameUser)(attrs.participant || attrs.from, (_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
const remoteJid = !isNodeFromMe || (0, WABinary_1.isJidGroup)(attrs.from) ? attrs.from : attrs.recipient;

@@ -567,9 +540,3 @@ const fromMe = !attrs.recipient || (attrs.type === 'retry' && isNodeFromMe);

const handleMessage = async (node) => {
var _a, _b;
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
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) {
if (node.attrs.sender_pn) {
ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
}
}
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, signalRepository, logger);
if (shouldIgnoreJid(msg.key.remoteJid)) {

@@ -645,4 +612,3 @@ logger.debug({ key: msg.key }, 'ignored message');

call.isVideo = !!(0, WABinary_1.getBinaryNodeChild)(infoChild, 'video');
call.isGroup = infoChild.attrs.type === 'group' || !!infoChild.attrs['group-jid'];
call.groupJid = infoChild.attrs['group-jid'];
call.isGroup = infoChild.attrs.type === 'group';
callOfferCache.set(call.id, call);

@@ -649,0 +615,0 @@ }

37

lib/Utils/decode-wa-message.js

@@ -13,3 +13,3 @@ "use strict";

*/
function decodeMessageNode(stanza, meId, meLid) {
function decodeMessageNode(stanza, meId) {
let msgType;

@@ -23,3 +23,2 @@ let chatId;

const isMe = (jid) => (0, WABinary_1.areJidsSameUser)(jid, meId);
const isMeLid = (jid) => (0, WABinary_1.areJidsSameUser)(jid, meLid);
if ((0, WABinary_1.isJidUser)(from)) {

@@ -38,15 +37,2 @@ if (recipient) {

}
else if ((0, WABinary_1.isLidUser)(from)) {
if (recipient) {
if (!isMeLid(from)) {
throw new boom_1.Boom('receipient present, but msg not from me', { data: stanza });
}
chatId = recipient;
}
else {
chatId = from;
}
msgType = 'chat';
author = from;
}
else if ((0, WABinary_1.isJidGroup)(from)) {

@@ -77,3 +63,3 @@ if (!participant) {

}
const fromMe = ((0, WABinary_1.isLidUser)(from) ? isMeLid : isMe)(stanza.attrs.participant || stanza.attrs.from);
const fromMe = isMe(stanza.attrs.participant || stanza.attrs.from);
const pushname = stanza.attrs.notify;

@@ -102,4 +88,4 @@ const key = {

exports.decodeMessageNode = decodeMessageNode;
const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
const { fullMessage, author, sender } = decodeMessageNode(stanza, meId, meLid);
const decryptMessageNode = (stanza, meId, repository, logger) => {
const { fullMessage, author, sender } = decodeMessageNode(stanza, meId);
return {

@@ -152,11 +138,6 @@ fullMessage,

if (msg.senderKeyDistributionMessage) {
try {
await repository.processSenderKeyDistributionMessage({
authorJid: author,
item: msg.senderKeyDistributionMessage
});
}
catch (err) {
logger.error({ key: fullMessage.key, err }, 'failed to decrypt message');
}
await repository.processSenderKeyDistributionMessage({
authorJid: author,
item: msg.senderKeyDistributionMessage
});
}

@@ -180,3 +161,3 @@ if (fullMessage.message) {

fullMessage.messageStubType = WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT;
fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT, JSON.stringify(stanza, generics_1.BufferJSON.replacer)];
fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT];
}

@@ -183,0 +164,0 @@ }

@@ -106,3 +106,3 @@ "use strict";

const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, keyStore, logger, options, getMessage }) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
var _a, _b, _c, _d, _e, _f, _g, _h;
const meId = creds.me.id;

@@ -188,17 +188,2 @@ const { accountSettings } = creds;

break;
case WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
const response = protocolMsg.peerDataOperationRequestResponseMessage;
if (response) {
const { peerDataOperationResult } = response;
for (const result of peerDataOperationResult) {
const { placeholderMessageResendResponse: retryResponse } = result;
if (retryResponse) {
const webMessageInfo = WAProto_1.proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes);
ev.emit('messages.update', [
{ key: webMessageInfo.key, update: { message: webMessageInfo.message } }
]);
}
}
}
break;
}

@@ -220,6 +205,5 @@ }

let participants;
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, author: message.participant, participants, action }));
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, participants, action }));
const emitGroupUpdate = (update) => {
var _a;
ev.emit('groups.update', [{ id: jid, ...update, author: (_a = message.participant) !== null && _a !== void 0 ? _a : undefined }]);
ev.emit('groups.update', [{ id: jid, ...update }]);
};

@@ -271,10 +255,2 @@ const participantsIncludesMe = () => participants.find(jid => (0, WABinary_1.areJidsSameUser)(meId, jid));

break;
case Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE:
const memberAddValue = (_h = message.messageStubParameters) === null || _h === void 0 ? void 0 : _h[0];
emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' });
break;
case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
const approvalMode = (_j = message.messageStubParameters) === null || _j === void 0 ? void 0 : _j[0];
emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' });
break;
}

@@ -290,3 +266,3 @@ }

const voterJid = (0, generics_1.getKeyAuthor)(message.key, meIdNormalised);
const pollEncKey = (_k = pollMsg.messageContextInfo) === null || _k === void 0 ? void 0 : _k.messageSecret;
const pollEncKey = (_h = pollMsg.messageContextInfo) === null || _h === void 0 ? void 0 : _h.messageSecret;
try {

@@ -307,3 +283,3 @@ const voteMsg = decryptPollVote(content.pollUpdateMessage.vote, {

vote: voteMsg,
senderTimestampMs: content.pollUpdateMessage.senderTimestampMs.toNumber(),
senderTimestampMs: message.messageTimestamp,
}

@@ -310,0 +286,0 @@ ]

{
"name": "@neoxr/baileys",
"version": "6.7.4",
"version": "6.7.5",
"description": "WhatsApp API",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc