Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@allchats/baileys

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@allchats/baileys - npm Package Compare versions

Comparing version 23.44.7 to 24.1.1

2

lib/Defaults/baileys-version.json
{
"version": [2, 2329, 9]
"version": [2, 2403, 2]
}

@@ -141,3 +141,3 @@ /// <reference types="node" />

"687": number;
"64": number;
"64": number; /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
"505": number;

@@ -238,3 +238,3 @@ "227": number;

export declare const MOBILE_REGISTRATION_ENDPOINT = "https://v.whatsapp.net/v2";
export declare const MOBILE_USERAGENT = "WhatsApp/2.23.13.82 iOS/15.3.1 Device/Apple-iPhone_7";
export declare const MOBILE_USERAGENT: string;
export declare const REGISTRATION_PUBLIC_KEY: Buffer;

@@ -241,0 +241,0 @@ export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";

@@ -7,2 +7,3 @@ "use strict";

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;
const crypto_1 = require("crypto");
const WAProto_1 = require("../../WAProto");

@@ -23,5 +24,7 @@ const libsignal_1 = require("../Signal/libsignal");

exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM3d3683e76445591c0591bc3c034c3bca');
const WA_VERSION = '2.23.14.82';
const WA_VERSION_HASH = (0, crypto_1.createHash)('md5').update(WA_VERSION).digest('hex');
exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' + WA_VERSION_HASH);
exports.MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
exports.MOBILE_USERAGENT = 'WhatsApp/2.23.13.82 iOS/15.3.1 Device/Apple-iPhone_7';
exports.MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/15.3.1 Device/Apple-iPhone_7`;
exports.REGISTRATION_PUBLIC_KEY = Buffer.from([

@@ -61,2 +64,3 @@ 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,

retryRequestDelayMs: 250,
maxMsgRetryCount: 5,
fireInitQueries: true,

@@ -63,0 +67,0 @@ auth: undefined,

@@ -26,2 +26,5 @@ /// <reference types="node" />

sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
[key: string]: string;
};
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;

@@ -59,2 +62,4 @@ refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;

groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
groupFetchAllParticipating: () => Promise<{

@@ -100,2 +105,6 @@ [_: string]: import("../Types").GroupMetadata;

removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
star: (jid: string, messages: {
id: string;
fromMe?: boolean | undefined;
}[], star: boolean) => Promise<void>;
type: "md";

@@ -102,0 +111,0 @@ ws: any;

@@ -47,2 +47,6 @@ /// <reference types="node" />

removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
star: (jid: string, messages: {
id: string;
fromMe?: boolean;
}[], star: boolean) => Promise<void>;
type: "md";

@@ -70,3 +74,3 @@ ws: any;

logout: (msg?: string | undefined) => Promise<void>;
end: (error: Error | undefined) => void;
end: (error: Error | undefined) => void; /** sending non-abt props may fix QR scan fail if server expects */
onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;

@@ -73,0 +77,0 @@ uploadPreKeys: (count?: number) => Promise<void>;

@@ -652,2 +652,13 @@ "use strict";

/**
* Star or Unstar a message
*/
const star = (jid, messages, star) => {
return chatModify({
star: {
messages,
star
}
}, jid);
};
/**
* Adds label for the chats

@@ -840,5 +851,6 @@ */

addMessageLabel,
removeMessageLabel
removeMessageLabel,
star
};
};
exports.makeChatsSocket = makeChatsSocket;

@@ -35,2 +35,4 @@ /// <reference types="node" />

groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
groupMemberAddMode: (jid: string, mode: 'admin_add' | 'all_member_add') => Promise<void>;
groupJoinApprovalMode: (jid: string, mode: 'on' | 'off') => Promise<void>;
groupFetchAllParticipating: () => Promise<{

@@ -79,2 +81,6 @@ [_: string]: GroupMetadata;

removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
star: (jid: string, messages: {
id: string;
fromMe?: boolean | undefined;
}[], star: boolean) => Promise<void>;
type: "md";

@@ -81,0 +87,0 @@ ws: any;

@@ -253,2 +253,8 @@ "use strict";

},
groupMemberAddMode: async (jid, mode) => {
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
},
groupJoinApprovalMode: async (jid, mode) => {
await groupQuery(jid, 'set', [{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }]);
},
groupFetchAllParticipating

@@ -270,3 +276,3 @@ };

const eph = (_a = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral')) === null || _a === void 0 ? void 0 : _a.attrs.expiration;
const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') == "all_member_add";
const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
const metadata = {

@@ -277,3 +283,3 @@ id: groupId,

subjectTime: +group.attrs.s_t,
size: +group.attrs.size,
size: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
creation: +group.attrs.creation,

@@ -287,2 +293,3 @@ owner: group.attrs.creator ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) : undefined,

isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'default_sub_group'),
joinApprovalMode: !!(0, WABinary_1.getBinaryNodeChild)(group, 'membership_approval_mode'),
memberAddMode,

@@ -289,0 +296,0 @@ participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {

@@ -27,2 +27,5 @@ /// <reference types="node" />

sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
[key: string]: string;
};
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;

@@ -60,2 +63,4 @@ refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;

groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
groupFetchAllParticipating: () => Promise<{

@@ -101,2 +106,6 @@ [_: string]: import("../Types").GroupMetadata;

removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
star: (jid: string, messages: {
id: string;
fromMe?: boolean | undefined;
}[], star: boolean) => Promise<void>;
type: "md";

@@ -103,0 +112,0 @@ ws: any;

@@ -15,2 +15,5 @@ /// <reference types="node" />

sendReceipts: (keys: proto.IMessageKey[], type: MessageReceiptType) => Promise<void>;
getButtonArgs: (message: proto.IMessage) => {
[key: string]: string;
};
readMessages: (keys: proto.IMessageKey[]) => Promise<void>;

@@ -48,2 +51,4 @@ refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;

groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
groupFetchAllParticipating: () => Promise<{

@@ -89,2 +94,6 @@ [_: string]: import("../Types").GroupMetadata;

removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
star: (jid: string, messages: {
id: string;
fromMe?: boolean | undefined;
}[], star: boolean) => Promise<void>;
type: "md";

@@ -91,0 +100,0 @@ ws: any;

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

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

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

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

@@ -225,2 +225,16 @@ 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;
}

@@ -394,3 +408,3 @@ };

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

@@ -543,3 +557,9 @@ const updateSendMessageAgainCount = (id, participant) => {

const handleMessage = async (node) => {
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, signalRepository, logger);
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 });
}
}
if (shouldIgnoreJid(msg.key.remoteJid)) {

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

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

@@ -618,0 +639,0 @@ }

@@ -12,2 +12,3 @@ /// <reference types="node" />

sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
getButtonArgs: (message: proto.IMessage) => BinaryNode['attrs'];
readMessages: (keys: WAMessageKey[]) => Promise<void>;

@@ -45,2 +46,4 @@ refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;

groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
groupFetchAllParticipating: () => Promise<{

@@ -86,2 +89,6 @@ [_: string]: import("../Types").GroupMetadata;

removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
star: (jid: string, messages: {
id: string;
fromMe?: boolean | undefined;
}[], star: boolean) => Promise<void>;
type: "md";

@@ -88,0 +95,0 @@ ws: any;

@@ -256,6 +256,7 @@ "use strict";

const isStatus = jid === statusJid;
const isLid = server === 'lid';
msgId = msgId || (0, Utils_1.generateMessageID)();
useUserDevicesCache = useUserDevicesCache !== false;
const participants = [];
const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isGroup ? 'g.us' : 's.whatsapp.net') : statusJid;
const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : 's.whatsapp.net') : statusJid;
const binaryNodeContent = [];

@@ -280,2 +281,3 @@ const devices = [];

await authState.keys.transaction(async () => {
var _a, _b;
const mediaType = getMediaType(message);

@@ -310,3 +312,3 @@ if (isGroup || isStatus) {

}
const patched = await patchMessageBeforeSending(message, devices.map(d => (0, WABinary_1.jidEncode)(d.user, 's.whatsapp.net', d.device)));
const patched = await patchMessageBeforeSending(message, devices.map(d => (0, WABinary_1.jidEncode)(d.user, isLid ? 'lid' : 's.whatsapp.net', d.device)));
const bytes = (0, Utils_1.encodeWAMessage)(patched);

@@ -321,3 +323,3 @@ const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({

for (const { user, device } of devices) {
const jid = (0, WABinary_1.jidEncode)(user, 's.whatsapp.net', device);
const jid = (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : 's.whatsapp.net', device);
if (!senderKeyMap[jid] || !!participant) {

@@ -366,4 +368,4 @@ senderKeyJids.push(jid);

for (const { user, device } of devices) {
const jid = (0, WABinary_1.jidEncode)(user, 's.whatsapp.net', device);
const isMe = user === meUser;
const jid = (0, WABinary_1.jidEncode)(isMe && isLid ? ((_b = (_a = authState.creds) === null || _a === void 0 ? void 0 : _a.me) === null || _b === void 0 ? void 0 : _b.lid.split(':')[0]) || user : user, isLid ? 'lid' : 's.whatsapp.net', device);
if (isMe) {

@@ -560,2 +562,3 @@ meJids.push(jid);

sendReceipts,
getButtonArgs,
readMessages,

@@ -562,0 +565,0 @@ refreshMediaConn,

@@ -28,2 +28,5 @@ /// <reference types="node" />

sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
[key: string]: string;
};
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;

@@ -64,2 +67,4 @@ refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;

groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
groupFetchAllParticipating: () => Promise<{

@@ -105,2 +110,6 @@ [_: string]: import("../Types").GroupMetadata;

removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
star: (jid: string, messages: {
id: string;
fromMe?: boolean | undefined;
}[], star: boolean) => Promise<void>;
type: "md";

@@ -107,0 +116,0 @@ ws: any;

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

attrs: {},
content: config.browser[0]
content: `${browser[1]} (${browser[0]})`
},

@@ -495,3 +495,3 @@ {

// login complete
ws.on('CB:success', async () => {
ws.on('CB:success', async (node) => {
await uploadPreKeysToServerIfRequired();

@@ -501,2 +501,3 @@ await sendPassiveIq('active');

clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
ev.emit('connection.update', { connection: 'open' });

@@ -503,0 +504,0 @@ });

@@ -1,2 +0,1 @@

import { Store } from 'cache-manager';
import { AuthenticationCreds } from '../Types';

@@ -3,0 +2,0 @@ declare const makeCacheManagerAuthState: (store: Store, sessionKey: string) => Promise<{

@@ -6,2 +6,3 @@ export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';

isGroup?: boolean;
groupJid?: string;
id: string;

@@ -8,0 +9,0 @@ date: Date;

export interface Contact {
id: string;
lid?: string;
/** name of the contact, you have saved on your WA */

@@ -4,0 +5,0 @@ name?: string;

@@ -28,2 +28,6 @@ import type { Boom } from '@hapi/boom';

'chats.update': ChatUpdate[];
'chats.phoneNumberShare': {
lid: string;
jid: string;
};
/** delete chats with given ID */

@@ -74,2 +78,3 @@ 'chats.delete': string[];

id: string;
author: string;
participants: string[];

@@ -76,0 +81,0 @@ action: ParticipantAction;

@@ -26,2 +26,4 @@ import { Contact } from './Contact';

memberAddMode?: boolean;
/** Request approval to join the group */
joinApprovalMode?: boolean;
/** is this a community */

@@ -28,0 +30,0 @@ isCommunity?: boolean;

@@ -25,3 +25,5 @@ export * from './Auth';

restartRequired = 515,
multideviceMismatch = 411
multideviceMismatch = 411,
forbidden = 403,
unavailableService = 503
}

@@ -28,0 +30,0 @@ export type WAInitResponse = {

@@ -39,2 +39,4 @@ "use strict";

DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
})(DisconnectReason = exports.DisconnectReason || (exports.DisconnectReason = {}));

@@ -97,2 +97,8 @@ /// <reference types="node" />

};
type SharePhoneNumber = {
sharePhoneNumber: boolean;
};
type RequestPhoneNumber = {
requestPhoneNumber: boolean;
};
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;

@@ -157,3 +163,3 @@ export type AnyMediaMessageContent = (({

footer?: string;
}) & ViewOnce;
} | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
export type AnyMessageContent = AnyRegularMessageContent | {

@@ -160,0 +166,0 @@ forward: WAMessage;

@@ -52,2 +52,4 @@ /// <reference types="node" />

retryRequestDelayMs: number;
/** max retry count */
maxMsgRetryCount: number;
/** time to wait for the generation of the next QR in ms */

@@ -54,0 +56,0 @@ qrTimeout?: number;

@@ -454,2 +454,16 @@ "use strict";

}
else if ('star' in mod) {
const key = mod.star.messages[0];
patch = {
syncAction: {
starAction: {
starred: !!mod.star.star
}
},
index: ['star', jid, key.id, key.fromMe ? '1' : '0', '0'],
type: 'regular_low',
apiVersion: 2,
operation: OP.SET
};
}
else if ('delete' in mod) {

@@ -456,0 +470,0 @@ patch = {

@@ -9,3 +9,3 @@ import { Logger } from 'pino';

*/
export declare function decodeMessageNode(stanza: BinaryNode, meId: string): {
export declare function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: string): {
fullMessage: proto.IWebMessageInfo;

@@ -15,3 +15,3 @@ author: string;

};
export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, repository: SignalRepository, logger: Logger) => {
export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, meLid: string, repository: SignalRepository, logger: Logger) => {
fullMessage: proto.IWebMessageInfo;

@@ -18,0 +18,0 @@ category: string;

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

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

@@ -23,2 +23,3 @@ 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)) {

@@ -37,2 +38,15 @@ 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)) {

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

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

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

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

@@ -92,0 +106,0 @@ fullMessage,

@@ -11,2 +11,3 @@ /// <reference types="node" />

baileys: (browser: any) => [string, string, string];
windows: (browser: any) => [string, string, string];
/** The appropriate browser based on your OS & release */

@@ -13,0 +14,0 @@ appropriate: (browser: any) => [string, string, string];

@@ -25,2 +25,3 @@ "use strict";

baileys: browser => ['Baileys', browser, '4.0.0'],
windows: browser => ['Windows', browser, '10.0.22621'],
/** The appropriate browser based on your OS & release */

@@ -27,0 +28,0 @@ appropriate: browser => [PLATFORM_MAP[(0, os_1.platform)()] || 'Ubuntu', browser, (0, os_1.release)()]

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

try {
const audioDecode = (...args) => import('audio-decode').then(({ default: audioDecode }) => audioDecode(...args));
const audioDecode = (buffer) => import('audio-decode').then(({ default: audioDecode }) => audioDecode(buffer));
let audioData;

@@ -219,0 +219,0 @@ if (Buffer.isBuffer(buffer)) {

@@ -42,3 +42,3 @@ /// <reference types="node" />

*/
export declare const getDevice: (id: string) => "android" | "web" | "ios";
export declare const getDevice: (id: string) => "android" | "unknown" | "web" | "ios" | "desktop";
/** Upserts a receipt in the message */

@@ -45,0 +45,0 @@ export declare const updateMessageWithReceipt: (msg: Pick<WAMessage, 'userReceipt'>, receipt: MessageUserReceipt) => void;

@@ -360,2 +360,10 @@ "use strict";

}
else if ('sharePhoneNumber' in message) {
m.protocolMessage = {
type: WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER
};
}
else if ('requestPhoneNumber' in message) {
m.requestPhoneNumberMessage = {};
}
else {

@@ -515,3 +523,3 @@ m = await (0, exports.prepareWAMessageMedia)(message, options);

const keys = Object.keys(content);
const key = keys.find(k => (k === 'conversation' || k.endsWith('Message')) && k !== 'senderKeyDistributionMessage');
const key = keys.find(k => (k === 'conversation' || k.includes('Message')) && k !== 'senderKeyDistributionMessage');
return key;

@@ -545,2 +553,3 @@ }

|| (message === null || message === void 0 ? void 0 : message.viewOnceMessageV2)
|| (message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension)
|| (message === null || message === void 0 ? void 0 : message.editedMessage));

@@ -596,6 +605,3 @@ }

*/
const getDevice = (id) => {
const deviceType = id.length > 21 ? 'android' : id.substring(0, 2) === '3A' ? 'ios' : 'web';
return deviceType;
};
const getDevice = (id) => /^3A.{18}$/.test(id) ? 'ios' : /^3E.{20}$/.test(id) ? 'web' : /^(.{21}|.{32})$/.test(id) ? 'android' : /^.{18}$/.test(id) ? 'desktop' : 'unknown';
exports.getDevice = getDevice;

@@ -602,0 +608,0 @@ /** Upserts a receipt in the message */

@@ -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;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
const meId = creds.me.id;

@@ -188,2 +188,17 @@ 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;
}

@@ -205,3 +220,3 @@ }

let participants;
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, participants, action }));
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, author: message.participant, participants, action }));
const emitGroupUpdate = (update) => {

@@ -255,2 +270,10 @@ ev.emit('groups.update', [{ id: jid, ...update }]);

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;
}

@@ -266,3 +289,3 @@ }

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

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

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

@@ -286,0 +309,0 @@ ]

@@ -79,2 +79,6 @@ "use strict";

exports.generateLoginNode = generateLoginNode;
const getPlatformType = (platform) => {
const platformType = platform.toUpperCase();
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.DESKTOP;
};
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {

@@ -88,3 +92,3 @@ // the app version needs to be md5 hashed

os: config.browser[0],
platformType: WAProto_1.proto.DeviceProps.PlatformType.DESKTOP,
platformType: getPlatformType(config.browser[1]),
requireFullSync: config.syncFullHistory,

@@ -91,0 +95,0 @@ };

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

const user = readString(readByte());
return (0, jid_utils_1.jidEncode)(user, 's.whatsapp.net', device, agent);
return (0, jid_utils_1.jidEncode)(user, agent === 0 ? 's.whatsapp.net' : 'lid', device);
};

@@ -153,0 +153,0 @@ const readString = (tag) => {

@@ -65,6 +65,6 @@ "use strict";

};
const writeJid = ({ agent, device, user, server }) => {
if (typeof agent !== 'undefined' || typeof device !== 'undefined') {
const writeJid = ({ domainType, device, user, server }) => {
if (typeof device !== 'undefined') {
pushByte(TAGS.AD_JID);
pushByte(agent || 0);
pushByte(domainType || 0);
pushByte(device || 0);

@@ -71,0 +71,0 @@ writeString(user);

@@ -6,3 +6,3 @@ export declare const S_WHATSAPP_NET = "@s.whatsapp.net";

export declare const STORIES_JID = "status@broadcast";
export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call';
export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid';
export type JidWithDevice = {

@@ -14,3 +14,3 @@ user: string;

server: JidServer | string;
agent?: number;
domainType?: number;
};

@@ -23,2 +23,4 @@ export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;

export declare const isJidUser: (jid: string | undefined) => boolean | undefined;
/** is the jid a group */
export declare const isLidUser: (jid: string | undefined) => boolean | undefined;
/** is the jid a broadcast */

@@ -25,0 +27,0 @@ export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.jidNormalizedUser = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isJidUser = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
exports.jidNormalizedUser = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
exports.S_WHATSAPP_NET = '@s.whatsapp.net';

@@ -21,7 +21,7 @@ exports.OFFICIAL_BIZ_JID = '16505361212@c.us';

const [userAgent, device] = userCombined.split(':');
const [user, agent] = userAgent.split('_');
const user = userAgent.split('_')[0];
return {
server,
user,
agent: agent ? +agent : undefined,
domainType: server === 'lid' ? 1 : 0,
device: device ? +device : undefined

@@ -40,2 +40,5 @@ };

exports.isJidUser = isJidUser;
/** is the jid a group */
const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid'));
exports.isLidUser = isLidUser;
/** is the jid a broadcast */

@@ -42,0 +45,0 @@ const isJidBroadcast = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast'));

{
"name": "@allchats/baileys",
"version": "23.44.7",
"version": "24.1.1",
"description": "WhatsApp API",

@@ -51,3 +51,3 @@ "homepage": "https://github.com/jeferssonlemes/Baileys",

"axios": "^1.3.3",
"cache-manager": "^5.2.2",
"cache-manager": "4.0.1",
"futoin-hkdf": "^1.5.1",

@@ -59,3 +59,3 @@ "libphonenumber-js": "^1.10.20",

"pino": "^7.0.0",
"protobufjs": "^6.11.3",
"protobufjs": "^7.2.4",
"uuid": "^9.0.0",

@@ -89,3 +89,3 @@ "ws": "^8.13.0"

"qrcode-terminal": "^0.12.0",
"sharp": "^0.30.5"
"sharp": "^0.32.2"
},

@@ -92,0 +92,0 @@ "peerDependenciesMeta": {

@@ -137,2 +137,4 @@ # Baileys - Typescript/Javascript WhatsApp Web API

retryRequestDelayMs: number
/** max msg retry count */
maxMsgRetryCount: number
/** time to wait for the generation of the next QR in ms */

@@ -380,61 +382,2 @@ qrTimeout?: number;

// send a buttons message!
const buttons = [
{buttonId: 'id1', buttonText: {displayText: 'Button 1'}, type: 1},
{buttonId: 'id2', buttonText: {displayText: 'Button 2'}, type: 1},
{buttonId: 'id3', buttonText: {displayText: 'Button 3'}, type: 1}
]
const buttonMessage = {
text: "Hi it's button message",
footer: 'Hello World',
buttons: buttons,
headerType: 1
}
const sendMsg = await sock.sendMessage(id, buttonMessage)
//send a template message!
const templateButtons = [
{index: 1, urlButton: {displayText: '⭐ Star Baileys on GitHub!', url: 'https://github.com/adiwajshing/Baileys'}},
{index: 2, callButton: {displayText: 'Call me!', phoneNumber: '+1 (234) 5678-901'}},
{index: 3, quickReplyButton: {displayText: 'This is a reply, just like normal buttons!', id: 'id-like-buttons-message'}},
]
const templateMessage = {
text: "Hi it's a template message",
footer: 'Hello World',
templateButtons: templateButtons
}
const sendMsg = await sock.sendMessage(id, templateMessage)
// send a list message!
const sections = [
{
title: "Section 1",
rows: [
{title: "Option 1", rowId: "option1"},
{title: "Option 2", rowId: "option2", description: "This is a description"}
]
},
{
title: "Section 2",
rows: [
{title: "Option 3", rowId: "option3"},
{title: "Option 4", rowId: "option4", description: "This is a description V2"}
]
},
]
const listMessage = {
text: "This is a list",
footer: "nice footer, link: https://google.com",
title: "Amazing boldfaced list title",
buttonText: "Required, text on the button to view the list",
sections
}
const sendMsg = await sock.sendMessage(id, listMessage)
const reactionMessage = {

@@ -494,35 +437,2 @@ react: {

)
// send a buttons message with image header!
const buttons = [
{buttonId: 'id1', buttonText: {displayText: 'Button 1'}, type: 1},
{buttonId: 'id2', buttonText: {displayText: 'Button 2'}, type: 1},
{buttonId: 'id3', buttonText: {displayText: 'Button 3'}, type: 1}
]
const buttonMessage = {
image: {url: 'https://example.com/image.jpeg'},
caption: "Hi it's button message",
footer: 'Hello World',
buttons: buttons,
headerType: 4
}
const sendMsg = await sock.sendMessage(id, buttonMessage)
//send a template message with an image **attached**!
const templateButtons = [
{index: 1, urlButton: {displayText: '⭐ Star Baileys on GitHub!', url: 'https://github.com/adiwajshing/Baileys'}},
{index: 2, callButton: {displayText: 'Call me!', phoneNumber: '+1 (234) 5678-901'}},
{index: 3, quickReplyButton: {displayText: 'This is a reply, just like normal buttons!', id: 'id-like-buttons-message'}},
]
const buttonMessage = {
text: "Hi it's a template message",
footer: 'Hello World',
templateButtons: templateButtons,
image: {url: 'https://example.com/image.jpeg'}
}
const sendMsg = await sock.sendMessage(id, templateMessage)
```

@@ -654,2 +564,13 @@

## Updating Messages
``` ts
const jid = '1234@s.whatsapp.net'
await sock.sendMessage(jid, {
text: 'updated text goes here',
edit: response.key,
});
```
## Modifying Chats

@@ -705,2 +626,11 @@

```
- Star/unstar a message
``` ts
await sock.chatModify({
star: {
messages: [{ id: 'messageID', fromMe: true // or `false` }],
star: true // - true: Star Message; false: Unstar Message
}},'123456@s.whatsapp.net');
```

@@ -922,3 +852,11 @@ **Note:** if you mess up one of your updates, WA can log you out of all your devices and you'll have to log in again.

**Note:** messages currently cannot be sent to broadcast lists from the MD version.
Messages can be sent to broadcasts & stories.
you need to add the following message options in sendMessage, like this:
```ts
sock.sendMessage(jid, {image: {url: url}, caption: caption}, {backgroundColor : backgroundColor, font : font, statusJidList: statusJidList, broadcast : true})
```
- the message body can be a extendedTextMessage or imageMessage or videoMessage or voiceMessage
- You can add backgroundColor and other options in the message options
- broadcast: true enables broadcast mode
- statusJidList: a list of people that you can get which you need to provide, which are the people who will get this status message.

@@ -925,0 +863,0 @@ - You can send messages to broadcast lists the same way you send messages to groups & individual chats.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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