Socket
Socket
Sign inDemoInstall

@yard-team/baileys-mobile

Package Overview
Dependencies
245
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.0 to 5.1.2

1

lib/Defaults/index.d.ts

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

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

@@ -127,0 +128,0 @@ "52": number;

2

lib/index.d.ts

@@ -8,3 +8,3 @@ import makeWASocket from './Socket';

export * from './WABinary';
export type WASocket = ReturnType<typeof makeWASocket>;
export declare type WASocket = ReturnType<typeof makeWASocket>;
export default makeWASocket;

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

}>;
getCollections: (jid?: string, limit?: number) => Promise<{
getCollections: (jid?: string | undefined, limit?: number) => Promise<{
collections: import("../Types").CatalogCollection[];

@@ -79,3 +79,3 @@ }>;

type: "md";
ws: import("./mobile-socket").MobileSocket | import("./web-socket").WebSocket;
ws: import("./mobile-socket").MobileSocket;
ev: import("../Types").BaileysEventEmitter & {

@@ -82,0 +82,0 @@ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;

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

appPatch: (patchCreate: WAPatchCreate) => Promise<void>;
sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
profilePictureUrl: (jid: string, type?: 'preview' | 'image', timeoutMs?: number) => Promise<string | undefined>;
sendPresenceUpdate: (type: WAPresence, toJid?: string | undefined) => Promise<void>;
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
profilePictureUrl: (jid: string, type?: 'preview' | 'image', timeoutMs?: number | undefined) => Promise<string | undefined>;
onWhatsApp: (...jids: string[]) => Promise<{

@@ -36,3 +36,3 @@ exists: boolean;

type: "md";
ws: import("./mobile-socket").MobileSocket | import("./web-socket").WebSocket;
ws: import("./mobile-socket").MobileSocket;
ev: import("../Types").BaileysEventEmitter & {

@@ -39,0 +39,0 @@ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;

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

// the key and can sync the messages
if (!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId) && !config.mobile) {
if (!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
ev.buffer();

@@ -690,0 +690,0 @@ needToFlushWithAppStateSync = true;

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

}[]>;
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
groupInviteCode: (jid: string) => Promise<string | undefined>;

@@ -59,3 +59,3 @@ groupRevokeInvite: (jid: string) => Promise<string | undefined>;

type: "md";
ws: import("./mobile-socket").MobileSocket | import("./web-socket").WebSocket;
ws: import("./mobile-socket").MobileSocket;
ev: import("../Types").BaileysEventEmitter & {

@@ -62,0 +62,0 @@ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;

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

register: (code: string) => Promise<import("./registration").ExistsResponse>;
requestRegistrationCode: (registrationOptions: import("./registration").RegistrationOptions) => Promise<import("./registration").ExistsResponse>;
requestRegistrationCode: (registrationOptions?: import("./registration").RegistrationOptions | undefined) => Promise<import("./registration").ExistsResponse>;
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;

@@ -80,3 +80,3 @@ getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{

type: "md";
ws: import("./mobile-socket").MobileSocket | import("./web-socket").WebSocket;
ws: import("./mobile-socket").MobileSocket;
ev: import("../Types").BaileysEventEmitter & {

@@ -83,0 +83,0 @@ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;

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

type: "md";
ws: import("./mobile-socket").MobileSocket | import("./web-socket").WebSocket;
ws: import("./mobile-socket").MobileSocket;
ev: import("../Types").BaileysEventEmitter & {

@@ -69,0 +69,0 @@ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;

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

type: "md";
ws: import("./mobile-socket").MobileSocket | import("./web-socket").WebSocket;
ws: import("./mobile-socket").MobileSocket;
ev: import("../Types").BaileysEventEmitter & {

@@ -67,0 +67,0 @@ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;

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

if (!type) {
throw new boom_1.Boom("Expected list type inside message");
throw new boom_1.Boom('Expected list type inside message');
}

@@ -507,0 +507,0 @@ return { v: '2', type: ListType[type].toLowerCase() };

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

this.config = config;
if (config.auth.creds.registered) {
this.connect();
}
this.on('data', (d) => {

@@ -15,0 +12,0 @@ this.emit('message', d);

/// <reference types="node" />
/// <reference types="node" />
import { KeyPair, SignedKeyPair, SocketConfig } from '../Types';
import { MobileSocket } from './mobile-socket';
import type { Agent } from 'https';
export declare const makeRegistrationSocket: (config: SocketConfig) => {
register: (code: string) => Promise<ExistsResponse>;
requestRegistrationCode: (registrationOptions: RegistrationOptions) => Promise<ExistsResponse>;
requestRegistrationCode: (registrationOptions?: RegistrationOptions | undefined) => Promise<ExistsResponse>;
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
/**
* Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
*/
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{

@@ -82,3 +83,3 @@ products: import("../Types").Product[];

type: "md";
ws: MobileSocket | import("./web-socket").WebSocket;
ws: MobileSocket;
ev: import("../Types").BaileysEventEmitter & {

@@ -140,3 +141,3 @@ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;

}
export type RegistrationParams = RegistrationData & RegistrationOptions;
export declare type RegistrationParams = RegistrationData & RegistrationOptions;
export declare function registrationParams(params: RegistrationParams): {

@@ -169,3 +170,3 @@ cc: string;

*/
export declare function mobileRegisterCode(params: RegistrationParams, agent?: Agent): Promise<ExistsResponse>;
export declare function mobileRegisterCode(params: RegistrationParams): Promise<ExistsResponse>;
export declare function mobileRegisterExists(params: RegistrationParams): Promise<ExistsResponse>;

@@ -185,3 +186,2 @@ /**

headers?: Record<string, string>;
agent?: Agent;
}): Promise<ExistsResponse>;

@@ -188,0 +188,0 @@ export interface ExistsResponse {

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -13,10 +10,8 @@ exports.mobileRegisterFetch = exports.mobileRegisterEncrypt = exports.mobileRegister = exports.mobileRegisterExists = exports.mobileRegisterCode = exports.registrationParams = exports.makeRegistrationSocket = void 0;

const mobile_socket_1 = require("./mobile-socket");
const node_fetch_1 = __importDefault(require("node-fetch"));
function urlencode(str) {
return str.replace(/-/g, '%2d').replace(/_/g, '%5f').replace(/~/g, '%7e');
}
const validRegistrationOptions = (config) => !(config === null || config === void 0 ? void 0 : config.phoneNumberCountryCode) ||
!config.phoneNumberNationalNumber ||
!config.phoneNumberMobileCountryCode ||
!config.phoneNumberMobileNetworkCode;
const validRegistrationOptions = (config) => (config === null || config === void 0 ? void 0 : config.phoneNumberCountryCode) &&
config.phoneNumberNationalNumber &&
config.phoneNumberMobileCountryCode;
const makeRegistrationSocket = (config) => {

@@ -41,13 +36,9 @@ const sock = (0, business_1.makeBusinessSocket)(config);

const requestRegistrationCode = async (registrationOptions) => {
registrationOptions = registrationOptions || config.auth.creds.registration;
if (!validRegistrationOptions(registrationOptions)) {
throw new Error('Invalid registration options');
}
sock.authState.creds.registration = {
phoneNumberCountryCode: registrationOptions.phoneNumberCountryCode,
phoneNumberMobileCountryCode: registrationOptions.phoneNumberMobileCountryCode,
phoneNumberNationalNumber: registrationOptions.phoneNumberNationalNumber,
phoneNumberMobileNetworkCode: registrationOptions.phoneNumberMobileNetworkCode
};
sock.authState.creds.registration = registrationOptions;
sock.ev.emit('creds.update', sock.authState.creds);
return mobileRegisterCode({ ...config.auth.creds, ...registrationOptions }, sock.ws.config.agent);
return mobileRegisterCode({ ...config.auth.creds, ...registrationOptions });
};

@@ -106,3 +97,3 @@ return {

*/
function mobileRegisterCode(params, agent) {
function mobileRegisterCode(params) {
return mobileRegisterFetch('/code', {

@@ -117,5 +108,4 @@ params: {

reason: '',
hasav: '1',
hasav: '1'
},
agent: agent
});

@@ -166,3 +156,3 @@ }

opts.headers['User-Agent'] = Defaults_1.MOBILE_USERAGENT;
const response = await (0, node_fetch_1.default)(url, opts);
const response = await fetch(url, opts);
const text = await response.text();

@@ -169,0 +159,0 @@ try {

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

import { MobileSocket } from './mobile-socket';
import { WebSocket } from './web-socket';
/**

@@ -16,3 +15,3 @@ * Connects to WA servers and performs:

type: "md";
ws: MobileSocket | WebSocket;
ws: MobileSocket;
ev: import("../Types").BaileysEventEmitter & {

@@ -32,3 +31,3 @@ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;

generateMessageTag: () => string;
query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<T_1>;

@@ -38,3 +37,3 @@ waitForSocketOpen: () => Promise<void>;

sendNode: (frame: BinaryNode) => Promise<void>;
logout: (msg?: string) => Promise<void>;
logout: (msg?: string | undefined) => Promise<void>;
end: (error: Error | undefined) => void;

@@ -47,2 +46,2 @@ onUnexpectedError: (err: Error | Boom, msg: string) => void;

};
export type Socket = ReturnType<typeof makeSocket>;
export declare type Socket = ReturnType<typeof makeSocket>;

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

const mobile_socket_1 = require("./mobile-socket");
const web_socket_1 = require("./web-socket");
/**

@@ -25,4 +24,8 @@ * Connects to WA servers and performs:

config.mobile = config.mobile || config.auth.creds.registered;
const ws = config.mobile ? new mobile_socket_1.MobileSocket(config) : new web_socket_1.WebSocket(config);
const ws = new mobile_socket_1.MobileSocket(config);
ws.setMaxListeners(0);
// if not mobile or already registered -> auto connect
if (!config.mobile || config.auth.creds.registered) {
ws.connect();
}
const ev = (0, event_buffer_1.makeEventBuffer)(logger);

@@ -81,3 +84,5 @@ /** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */

if (!ws.isOpen) {
throw new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed });
throw new boom_1.Boom('Connection Closed', {
statusCode: Types_1.DisconnectReason.connectionClosed
});
}

@@ -84,0 +89,0 @@ let onOpen;

@@ -7,3 +7,3 @@ import type KeyedDB from '@adiwajshing/keyed-db';

import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
type WASocket = ReturnType<typeof makeMDSocket>;
declare type WASocket = ReturnType<typeof makeMDSocket>;
export declare const waChatKey: (pin: boolean) => {

@@ -14,3 +14,3 @@ key: (c: Chat) => string;

export declare const waMessageID: (m: WAMessage) => string;
export type BaileysInMemoryStoreConfig = {
export declare type BaileysInMemoryStoreConfig = {
chatKey?: Comparable<Chat, string>;

@@ -17,0 +17,0 @@ logger?: Logger;

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

import type { MinimalMessage } from './Message';
export type KeyPair = {
export declare type KeyPair = {
public: Uint8Array;
private: Uint8Array;
};
export type SignedKeyPair = {
export declare type SignedKeyPair = {
keyPair: KeyPair;

@@ -17,11 +17,11 @@ signature: Uint8Array;

};
export type ProtocolAddress = {
export declare type ProtocolAddress = {
name: string;
deviceId: number;
};
export type SignalIdentity = {
export declare type SignalIdentity = {
identifier: ProtocolAddress;
identifierKey: Uint8Array;
};
export type LTHashState = {
export declare type LTHashState = {
version: number;

@@ -35,3 +35,3 @@ hash: Buffer;

};
export type SignalCreds = {
export declare type SignalCreds = {
readonly signedIdentityKey: KeyPair;

@@ -41,3 +41,3 @@ readonly signedPreKey: SignedKeyPair;

};
export type AccountSettings = {
export declare type AccountSettings = {
/** unarchive chats when a new message is received */

@@ -48,3 +48,3 @@ unarchiveChats: boolean;

};
export type AuthenticationCreds = SignalCreds & {
export declare type AuthenticationCreds = SignalCreds & {
readonly noiseKey: KeyPair;

@@ -71,3 +71,3 @@ readonly advSecretKey: string;

};
export type SignalDataTypeMap = {
export declare type SignalDataTypeMap = {
'pre-key': KeyPair;

@@ -82,3 +82,3 @@ 'session': Uint8Array;

};
export type SignalDataSet = {
export declare type SignalDataSet = {
[T in keyof SignalDataTypeMap]?: {

@@ -88,4 +88,4 @@ [id: string]: SignalDataTypeMap[T] | null;

};
type Awaitable<T> = T | Promise<T>;
export type SignalKeyStore = {
declare type Awaitable<T> = T | Promise<T>;
export declare type SignalKeyStore = {
get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{

@@ -98,15 +98,15 @@ [id: string]: SignalDataTypeMap[T];

};
export type SignalKeyStoreWithTransaction = SignalKeyStore & {
export declare type SignalKeyStoreWithTransaction = SignalKeyStore & {
isInTransaction: () => boolean;
transaction<T>(exec: () => Promise<T>): Promise<T>;
};
export type TransactionCapabilityOptions = {
export declare type TransactionCapabilityOptions = {
maxCommitRetries: number;
delayBetweenTriesMs: number;
};
export type SignalAuthState = {
export declare type SignalAuthState = {
creds: SignalCreds;
keys: SignalKeyStore | SignalKeyStoreWithTransaction;
};
export type AuthenticationState = {
export declare type AuthenticationState = {
creds: AuthenticationCreds;

@@ -113,0 +113,0 @@ keys: SignalKeyStore;

@@ -1,3 +0,3 @@

export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
export type WACallEvent = {
export declare type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
export declare type WACallEvent = {
chatId: string;

@@ -4,0 +4,0 @@ from: string;

@@ -6,5 +6,5 @@ import type { proto } from '../../WAProto';

/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
export declare type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
export declare type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
export interface PresenceData {

@@ -14,7 +14,7 @@ lastKnownPresence: WAPresence;

}
export type ChatMutation = {
export declare type ChatMutation = {
syncAction: proto.ISyncActionData;
index: string[];
};
export type WAPatchCreate = {
export declare type WAPatchCreate = {
syncAction: proto.ISyncActionValue;

@@ -26,7 +26,7 @@ index: string[];

};
export type Chat = proto.IConversation & {
export declare type Chat = proto.IConversation & {
/** unix timestamp of when the last message was received in the chat */
lastMessageRecvTimestamp?: number;
};
export type ChatUpdate = Partial<Chat & {
export declare type ChatUpdate = Partial<Chat & {
/**

@@ -47,4 +47,4 @@ * if specified in the update,

* */
export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange;
export type ChatModification = {
export declare type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange;
export declare type ChatModification = {
archive: boolean;

@@ -82,3 +82,3 @@ lastMessages: LastMessageList;

};
export type InitialReceivedChatsState = {
export declare type InitialReceivedChatsState = {
[jid: string]: {

@@ -91,4 +91,4 @@ /** the last message received from the other party */

};
export type InitialAppStateSyncOptions = {
export declare type InitialAppStateSyncOptions = {
accountSettings: AccountSettings;
};

@@ -10,3 +10,3 @@ import type { Boom } from '@hapi/boom';

import { ConnectionState } from './State';
export type BaileysEventMap = {
export declare type BaileysEventMap = {
/** connection state has been updated -- WS closed, opened, connecting etc. */

@@ -86,3 +86,3 @@ 'connection.update': Partial<ConnectionState>;

};
export type BufferedEventData = {
export declare type BufferedEventData = {
historySets: {

@@ -142,3 +142,3 @@ chats: {

};
export type BaileysEvent = keyof BaileysEventMap;
export declare type BaileysEvent = keyof BaileysEventMap;
export interface BaileysEventEmitter {

@@ -145,0 +145,0 @@ on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void;

import { Contact } from './Contact';
export type GroupParticipant = (Contact & {
export declare type GroupParticipant = (Contact & {
isAdmin?: boolean;

@@ -7,3 +7,3 @@ isSuperAdmin?: boolean;

});
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
export declare type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
export interface GroupMetadata {

@@ -10,0 +10,0 @@ id: string;

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

import { SocketConfig } from './Socket';
export type UserFacingSocketConfig = Partial<SocketConfig> & {
export declare type UserFacingSocketConfig = Partial<SocketConfig> & {
auth: AuthenticationState;

@@ -28,3 +28,3 @@ };

}
export type WAInitResponse = {
export declare type WAInitResponse = {
ref: string;

@@ -34,3 +34,3 @@ ttl: number;

};
export type WABusinessHoursConfig = {
export declare type WABusinessHoursConfig = {
day_of_week: string;

@@ -41,3 +41,3 @@ mode: string;

};
export type WABusinessProfile = {
export declare type WABusinessProfile = {
description: string;

@@ -55,5 +55,5 @@ email: string | undefined;

};
export type CurveKeyPair = {
export declare type CurveKeyPair = {
private: Uint8Array;
public: Uint8Array;
};
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { AxiosRequestConfig } from 'axios';

@@ -13,14 +11,14 @@ import type { Logger } from 'pino';

export { proto as WAProto };
export type WAMessage = proto.IWebMessageInfo;
export type WAMessageContent = proto.IMessage;
export type WAContactMessage = proto.Message.IContactMessage;
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
export type WAMessageKey = proto.IMessageKey;
export type WATextMessage = proto.Message.IExtendedTextMessage;
export type WAContextInfo = proto.IContextInfo;
export type WALocationMessage = proto.Message.ILocationMessage;
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
export declare type WAMessage = proto.IWebMessageInfo;
export declare type WAMessageContent = proto.IMessage;
export declare type WAContactMessage = proto.Message.IContactMessage;
export declare type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
export declare type WAMessageKey = proto.IMessageKey;
export declare type WATextMessage = proto.Message.IExtendedTextMessage;
export declare type WAContextInfo = proto.IContextInfo;
export declare type WALocationMessage = proto.Message.ILocationMessage;
export declare type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
export import WAMessageStubType = proto.WebMessageInfo.StubType;
export import WAMessageStatus = proto.WebMessageInfo.Status;
export type WAMediaUpload = Buffer | {
export declare type WAMediaUpload = Buffer | {
url: URL | string;

@@ -31,4 +29,4 @@ } | {

/** Set of message types that are supported by the library */
export type MessageType = keyof proto.Message;
export type DownloadableMessage = {
export declare type MessageType = keyof proto.Message;
export declare type DownloadableMessage = {
mediaKey?: Uint8Array | null;

@@ -38,4 +36,4 @@ directPath?: string | null;

};
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
export type MediaConnInfo = {
export declare type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
export declare type MediaConnInfo = {
auth: string;

@@ -58,14 +56,14 @@ ttl: number;

}
type Mentionable = {
declare type Mentionable = {
/** list of jids that are mentioned in the accompanying text */
mentions?: string[];
};
type ViewOnce = {
declare type ViewOnce = {
viewOnce?: boolean;
};
type Buttonable = {
declare type Buttonable = {
/** add buttons to the message */
buttons?: proto.Message.ButtonsMessage.IButton[];
};
type Templatable = {
declare type Templatable = {
/** add buttons to the message (conflicts with normal buttons)*/

@@ -75,3 +73,3 @@ templateButtons?: proto.IHydratedTemplateButton[];

};
type Listable = {
declare type Listable = {
/** Sections of the List */

@@ -84,7 +82,7 @@ sections?: proto.Message.ListMessage.ISection[];

};
type WithDimensions = {
declare type WithDimensions = {
width?: number;
height?: number;
};
export type PollMessageOptions = {
export declare type PollMessageOptions = {
name: string;

@@ -96,4 +94,4 @@ selectableCount?: number;

};
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
export type AnyMediaMessageContent = (({
export declare type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
export declare type AnyMediaMessageContent = (({
image: WAMediaUpload;

@@ -124,3 +122,3 @@ caption?: string;

};
export type ButtonReplyInfo = {
export declare type ButtonReplyInfo = {
displayText: string;

@@ -130,6 +128,6 @@ id: string;

};
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
export declare type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
productImage: WAMediaUpload;
};
export type AnyRegularMessageContent = (({
export declare type AnyRegularMessageContent = (({
text: string;

@@ -159,3 +157,3 @@ linkPreview?: WAUrlInfo | null;

}) & ViewOnce;
export type AnyMessageContent = AnyRegularMessageContent | {
export declare type AnyMessageContent = AnyRegularMessageContent | {
forward: WAMessage;

@@ -169,4 +167,4 @@ force?: boolean;

};
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
type MinimalRelayOptions = {
export declare type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
declare type MinimalRelayOptions = {
/** override the message ID with a custom provided string */

@@ -177,3 +175,3 @@ messageId?: string;

};
export type MessageRelayOptions = MinimalRelayOptions & {
export declare type MessageRelayOptions = MinimalRelayOptions & {
/** only send to a specific participant; used when a message decryption fails for a single user */

@@ -191,3 +189,3 @@ participant?: {

};
export type MiscMessageGenerationOptions = MinimalRelayOptions & {
export declare type MiscMessageGenerationOptions = MinimalRelayOptions & {
/** optional, if you want to manually set the timestamp of the message */

@@ -202,6 +200,6 @@ timestamp?: Date;

};
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
export declare type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
userJid: string;
};
export type WAMediaUploadFunction = (readStream: Readable, opts: {
export declare type WAMediaUploadFunction = (readStream: Readable, opts: {
fileEncSha256B64: string;

@@ -214,3 +212,3 @@ mediaType: MediaType;

}>;
export type MediaGenerationOptions = {
export declare type MediaGenerationOptions = {
logger?: Logger;

@@ -224,6 +222,6 @@ mediaTypeOverride?: MediaType;

};
export type MessageContentGenerationOptions = MediaGenerationOptions & {
export declare type MessageContentGenerationOptions = MediaGenerationOptions & {
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
};
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
export declare type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
/**

@@ -234,9 +232,9 @@ * Type of message upsert

*/
export type MessageUpsertType = 'append' | 'notify';
export type MessageUserReceipt = proto.IUserReceipt;
export type WAMessageUpdate = {
export declare type MessageUpsertType = 'append' | 'notify';
export declare type MessageUserReceipt = proto.IUserReceipt;
export declare type WAMessageUpdate = {
update: Partial<WAMessage>;
key: proto.IMessageKey;
};
export type WAMessageCursor = {
export declare type WAMessageCursor = {
before: WAMessageKey | undefined;

@@ -246,7 +244,7 @@ } | {

};
export type MessageUserReceiptUpdate = {
export declare type MessageUserReceiptUpdate = {
key: proto.IMessageKey;
receipt: MessageUserReceipt;
};
export type MediaDecryptionKeyInfo = {
export declare type MediaDecryptionKeyInfo = {
iv: Buffer;

@@ -256,2 +254,2 @@ cipherKey: Buffer;

};
export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;
export declare type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;
import { WAMediaUpload } from './Message';
export type CatalogResult = {
export declare type CatalogResult = {
data: {

@@ -13,3 +13,3 @@ paging: {

};
export type ProductCreateResult = {
export declare type ProductCreateResult = {
data: {

@@ -19,7 +19,7 @@ product: {};

};
export type CatalogStatus = {
export declare type CatalogStatus = {
status: string;
canAppeal: boolean;
};
export type CatalogCollection = {
export declare type CatalogCollection = {
id: string;

@@ -30,4 +30,4 @@ name: string;

};
export type ProductAvailability = 'in stock';
export type ProductBase = {
export declare type ProductAvailability = 'in stock';
export declare type ProductBase = {
name: string;

@@ -41,3 +41,3 @@ retailerId?: string;

};
export type ProductCreate = ProductBase & {
export declare type ProductCreate = ProductBase & {
/** ISO country code for product origin. Set to undefined for no country */

@@ -48,4 +48,4 @@ originCountryCode: string | undefined;

};
export type ProductUpdate = Omit<ProductCreate, 'originCountryCode'>;
export type Product = ProductBase & {
export declare type ProductUpdate = Omit<ProductCreate, 'originCountryCode'>;
export declare type Product = ProductBase & {
id: string;

@@ -60,7 +60,7 @@ imageUrls: {

};
export type OrderPrice = {
export declare type OrderPrice = {
currency: string;
total: number;
};
export type OrderProduct = {
export declare type OrderProduct = {
id: string;

@@ -73,8 +73,8 @@ imageUrl: string;

};
export type OrderDetails = {
export declare type OrderDetails = {
price: OrderPrice;
products: OrderProduct[];
};
export type CatalogCursor = string;
export type GetCatalogOptions = {
export declare type CatalogCursor = string;
export declare type GetCatalogOptions = {
/** cursor to start from */

@@ -81,0 +81,0 @@ cursor?: CatalogCursor;

import { proto } from '../../WAProto';
type DecryptGroupSignalOpts = {
declare type DecryptGroupSignalOpts = {
group: string;

@@ -7,7 +7,7 @@ authorJid: string;

};
type ProcessSenderKeyDistributionMessageOpts = {
declare type ProcessSenderKeyDistributionMessageOpts = {
item: proto.Message.ISenderKeyDistributionMessage;
authorJid: string;
};
type DecryptSignalProtoOpts = {
declare type DecryptSignalProtoOpts = {
jid: string;

@@ -17,7 +17,7 @@ type: 'pkmsg' | 'msg';

};
type EncryptMessageOpts = {
declare type EncryptMessageOpts = {
jid: string;
data: Uint8Array;
};
type EncryptGroupMessageOpts = {
declare type EncryptGroupMessageOpts = {
group: string;

@@ -27,10 +27,10 @@ data: Uint8Array;

};
type PreKey = {
declare type PreKey = {
keyId: number;
publicKey: Uint8Array;
};
type SignedPreKey = PreKey & {
declare type SignedPreKey = PreKey & {
signature: Uint8Array;
};
type E2ESession = {
declare type E2ESession = {
registrationId: number;

@@ -41,7 +41,7 @@ identityKey: Uint8Array;

};
type E2ESessionOpts = {
declare type E2ESessionOpts = {
jid: string;
session: E2ESession;
};
export type SignalRepository = {
export declare type SignalRepository = {
decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>;

@@ -48,0 +48,0 @@ processSenderKeyDistributionMessage(opts: ProcessSenderKeyDistributionMessageOpts): Promise<void>;

/// <reference types="node" />
/// <reference types="node" />
import { AxiosRequestConfig } from 'axios';

@@ -11,5 +10,5 @@ import type { Agent } from 'https';

import { SignalRepository } from './Signal';
export type WAVersion = [number, number, number];
export type WABrowserDescription = [string, string, string];
export type CacheStore = {
export declare type WAVersion = [number, number, number];
export declare type WABrowserDescription = [string, string, string];
export declare type CacheStore = {
/** get a cached key and change the stats */

@@ -24,7 +23,5 @@ get<T>(key: string): T | undefined;

};
export type SocketConfig = {
export declare type SocketConfig = {
/** the WS url to connect to WA */
waWebSocketUrl: string | URL;
/** should baileys use the mobile api instead of the multi device api */
mobile?: boolean;
/** Fails the connection if the socket times out in this interval */

@@ -36,2 +33,4 @@ connectTimeoutMs: number;

keepAliveIntervalMs: number;
/** should baileys use the mobile api instead of the multi device api */
mobile?: boolean;
/** proxy agent */

@@ -38,0 +37,0 @@ agent?: Agent;

import { Contact } from './Contact';
export type WAConnectionState = 'open' | 'connecting' | 'close';
export type ConnectionState = {
export declare type WAConnectionState = 'open' | 'connecting' | 'close';
export declare type ConnectionState = {
/** connection is now open, connecting or closed */

@@ -5,0 +5,0 @@ connection: WAConnectionState;

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

const node_cache_1 = __importDefault(require("node-cache"));
const uuid_1 = require("uuid");
const Defaults_1 = require("../Defaults");
const crypto_2 = require("./crypto");
const generics_1 = require("./generics");
const uuid_1 = require("uuid");
/**

@@ -15,0 +15,0 @@ * Adds caching capability to a SignalKeyStore

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

import { BinaryNode } from '../WABinary';
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
export type ChatMutationMap = {
declare type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
export declare type ChatMutationMap = {
[index: string]: ChatMutation;

@@ -66,3 +66,3 @@ };

}>;
export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number | undefined, logger?: Logger<import("pino").LoggerOptions> | undefined, validateMacs?: boolean) => Promise<{
state: LTHashState;

@@ -72,3 +72,3 @@ mutationMap: ChatMutationMap;

export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: Logger) => void;
export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions | undefined, logger?: Logger<import("pino").LoggerOptions> | undefined) => void;
export {};

@@ -10,4 +10,4 @@ import { Logger } from 'pino';

*/
type BaileysEventData = Partial<BaileysEventMap>;
type BaileysBufferableEventEmitter = BaileysEventEmitter & {
declare type BaileysEventData = Partial<BaileysEventMap>;
declare type BaileysBufferableEventEmitter = BaileysEventEmitter & {
/** Use to process events in a batch */

@@ -14,0 +14,0 @@ process(handler: (events: BaileysEventData) => void | Promise<void>): (() => void);

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

export declare const unixTimestampSeconds: (date?: Date) => number;
export type DebouncedTimeout = ReturnType<typeof debouncedTimeout>;
export declare const debouncedTimeout: (intervalMs?: number, task?: () => void) => {
start: (newIntervalMs?: number, newTask?: () => void) => void;
export declare type DebouncedTimeout = ReturnType<typeof debouncedTimeout>;
export declare const debouncedTimeout: (intervalMs?: number, task?: (() => void) | undefined) => {
start: (newIntervalMs?: number | undefined, newTask?: (() => void) | undefined) => void;
cancel: () => void;

@@ -42,4 +42,4 @@ setTask: (newTask: () => void) => () => void;

export declare const generateMessageID: () => string;
export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => boolean | undefined, timeoutMs?: number) => Promise<void>;
export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
export declare const printQRIfNecessaryListener: (ev: BaileysEventEmitter, logger: Logger) => void;

@@ -46,0 +46,0 @@ /**

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

const fetchLatestBaileysVersion = async (options = {}) => {
const URL = 'https://raw.githubusercontent.com/Yard-Team/Baileys/master/src/Defaults/baileys-version.json';
const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json';
try {

@@ -222,0 +222,0 @@ const result = await axios_1.default.get(URL, {

import { AxiosRequestConfig } from 'axios';
import { Logger } from 'pino';
import { WAMediaUploadFunction, WAUrlInfo } from '../Types';
export type URLGenerationOptions = {
export declare type URLGenerationOptions = {
thumbnailWidth: number;

@@ -6,0 +6,0 @@ fetchOpts: {

export declare const makeMutex: () => {
mutex<T>(code: () => T | Promise<T>): Promise<T>;
};
export type Mutex = ReturnType<typeof makeMutex>;
export declare type Mutex = ReturnType<typeof makeMutex>;
export declare const makeKeyedMutex: () => {
mutex<T>(key: string, task: () => T | Promise<T>): Promise<T>;
};
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { Boom } from '@hapi/boom';

@@ -31,3 +29,3 @@ import { AxiosRequestConfig } from 'axios';

export declare const toBuffer: (stream: Readable) => Promise<Buffer>;
export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig<any> | undefined) => Promise<{
readonly stream: Readable;

@@ -58,3 +56,3 @@ readonly type: "buffer";

}) => Promise<Readable>;
type EncryptedStreamOptions = {
declare type EncryptedStreamOptions = {
saveOriginalFileIfRequired?: boolean;

@@ -74,3 +72,3 @@ logger?: Logger;

}>;
export type MediaDownloadOptions = {
export declare type MediaDownloadOptions = {
startByte?: number;

@@ -77,0 +75,0 @@ endByte?: number;

/// <reference types="node" />
/// <reference types="node" />
import { Logger } from 'pino';

@@ -15,3 +14,3 @@ import { proto } from '../../WAProto';

export declare const prepareWAMessageMedia: (message: AnyMediaMessageContent, options: MediaGenerationOptions) => Promise<proto.Message>;
export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number) => proto.Message;
export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number | undefined) => proto.Message;
/**

@@ -22,3 +21,3 @@ * Generate forwarded message content like WA does

*/
export declare const generateForwardMessageContent: (message: WAMessage, forceForward?: boolean) => proto.IMessage;
export declare const generateForwardMessageContent: (message: WAMessage, forceForward?: boolean | undefined) => proto.IMessage;
export declare const generateWAMessageContent: (message: AnyMessageContent, options: MessageContentGenerationOptions) => Promise<proto.Message>;

@@ -51,3 +50,3 @@ export declare const generateWAMessageFromContent: (jid: string, message: WAMessageContent, options: MessageGenerationOptionsFromContent) => proto.WebMessageInfo;

export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage, 'pollUpdates'>, update: proto.IPollUpdate) => void;
type VoteAggregation = {
declare type VoteAggregation = {
name: string;

@@ -69,3 +68,3 @@ voters: string[];

}[];
type DownloadMediaMessageContext = {
declare type DownloadMediaMessageContext = {
reuploadRequest: (msg: WAMessage) => Promise<WAMessage>;

@@ -77,5 +76,5 @@ logger: Logger;

*/
export declare const downloadMediaMessage: (message: WAMessage, type: 'buffer' | 'stream', options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Buffer | import("stream").Transform>;
export declare const downloadMediaMessage: (message: WAMessage, type: 'buffer' | 'stream', options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext | undefined) => Promise<Buffer | import("stream").Transform>;
/** Checks whether the given message is a media message; if it is returns the inner content */
export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
export {};

@@ -5,3 +5,3 @@ import { AxiosRequestConfig } from 'axios';

import { AuthenticationCreds, BaileysEventEmitter, SignalKeyStoreWithTransaction, SocketConfig } from '../Types';
type ProcessMessageContext = {
declare type ProcessMessageContext = {
shouldProcessHistoryMsg: boolean;

@@ -24,3 +24,3 @@ creds: AuthenticationCreds;

export declare const getChatId: ({ remoteJid, participant, fromMe }: proto.IMessageKey) => string;
type PollContext = {
declare type PollContext = {
/** normalised jid of the person that created the poll */

@@ -27,0 +27,0 @@ pollCreatorJid: string;

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

const manufacturer = config.mobile ? 'Apple' : '';
const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB;
const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.MACOS;
const phoneId = config.mobile ? { phoneId: config.auth.creds.phoneId } : {};

@@ -40,13 +40,2 @@ return {

};
const PLATFORM_MAP = {
'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
};
const getWebInfo = (config) => {
let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
webSubPlatform = PLATFORM_MAP[config.browser[0]];
}
return { webSubPlatform };
};
const getClientPayload = (config) => {

@@ -58,5 +47,2 @@ const payload = {

};
if (!config.mobile) {
payload.webInfo = getWebInfo(config);
}
return payload;

@@ -63,0 +49,0 @@ };

@@ -6,12 +6,12 @@ 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 JidWithDevice = {
export declare type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call';
export declare type JidWithDevice = {
user: string;
device?: number;
};
export type FullJid = JidWithDevice & {
export declare type FullJid = JidWithDevice & {
server: JidServer | string;
agent?: number;
};
export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number | undefined, agent?: number | undefined) => string;
export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;

@@ -18,0 +18,0 @@ /** is the jid a user */

@@ -9,3 +9,3 @@ import * as constants from './constants';

* */
export type BinaryNode = {
export declare type BinaryNode = {
tag: string;

@@ -17,4 +17,4 @@ attrs: {

};
export type BinaryNodeAttributes = BinaryNode['attrs'];
export type BinaryNodeData = BinaryNode['content'];
export type BinaryNodeCodingOptions = typeof constants;
export declare type BinaryNodeAttributes = BinaryNode['attrs'];
export declare type BinaryNodeData = BinaryNode['content'];
export declare type BinaryNodeCodingOptions = typeof constants;
{
"name": "@yard-team/baileys-mobile",
"version": "5.1.0",
"version": "5.1.2",
"description": "WhatsApp API",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/Yard-Team/Baileys",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc