From 9f2f3ac510140477c85348e2f9a0495ed0b5228f Mon Sep 17 00:00:00 2001 From: josedario87 Date: Tue, 2 Dec 2025 20:49:59 -0600 Subject: [PATCH] Docs: Script para scrapear documentacion de Baileys API - Script en scripts/scrape-baileys-docs.ts - Genera docs/baileys-api-reference.md con 6433 lineas - 79 secciones: interfaces, types, functions, variables, enums - Referencia completa para desarrollo de mensajes --- app/components/debug/BlocklistSection.vue | 94 + app/components/debug/ChatSection.vue | 131 + app/components/debug/GroupsSection.vue | 291 + app/components/debug/HistorySection.vue | 87 + app/components/debug/MediaSection.vue | 95 + app/components/debug/PrivacySection.vue | 124 + app/layouts/dashboard.vue | 1 + app/pages/debug/index.vue | 141 + docs/baileys-api-reference.md | 6433 ++++++++++++++++++ scripts/scrape-baileys-docs.ts | 300 + server/api/debug/chat/modify.post.ts | 76 + server/api/debug/groups/create.post.ts | 42 + server/api/debug/groups/description.post.ts | 42 + server/api/debug/groups/invite-code.post.ts | 44 + server/api/debug/groups/metadata.post.ts | 38 + server/api/debug/groups/participants.post.ts | 57 + server/api/debug/groups/subject.post.ts | 42 + server/api/debug/history/fetch.post.ts | 41 + server/api/debug/media/update.post.ts | 38 + 19 files changed, 8117 insertions(+) create mode 100644 app/components/debug/BlocklistSection.vue create mode 100644 app/components/debug/ChatSection.vue create mode 100644 app/components/debug/GroupsSection.vue create mode 100644 app/components/debug/HistorySection.vue create mode 100644 app/components/debug/MediaSection.vue create mode 100644 app/components/debug/PrivacySection.vue create mode 100644 app/pages/debug/index.vue create mode 100644 docs/baileys-api-reference.md create mode 100644 scripts/scrape-baileys-docs.ts create mode 100644 server/api/debug/chat/modify.post.ts create mode 100644 server/api/debug/groups/create.post.ts create mode 100644 server/api/debug/groups/description.post.ts create mode 100644 server/api/debug/groups/invite-code.post.ts create mode 100644 server/api/debug/groups/metadata.post.ts create mode 100644 server/api/debug/groups/participants.post.ts create mode 100644 server/api/debug/groups/subject.post.ts create mode 100644 server/api/debug/history/fetch.post.ts create mode 100644 server/api/debug/media/update.post.ts diff --git a/app/components/debug/BlocklistSection.vue b/app/components/debug/BlocklistSection.vue new file mode 100644 index 0000000..560c861 --- /dev/null +++ b/app/components/debug/BlocklistSection.vue @@ -0,0 +1,94 @@ + + + diff --git a/app/components/debug/ChatSection.vue b/app/components/debug/ChatSection.vue new file mode 100644 index 0000000..0097860 --- /dev/null +++ b/app/components/debug/ChatSection.vue @@ -0,0 +1,131 @@ + + + diff --git a/app/components/debug/GroupsSection.vue b/app/components/debug/GroupsSection.vue new file mode 100644 index 0000000..dd72265 --- /dev/null +++ b/app/components/debug/GroupsSection.vue @@ -0,0 +1,291 @@ + + + diff --git a/app/components/debug/HistorySection.vue b/app/components/debug/HistorySection.vue new file mode 100644 index 0000000..2f52d4a --- /dev/null +++ b/app/components/debug/HistorySection.vue @@ -0,0 +1,87 @@ + + + diff --git a/app/components/debug/MediaSection.vue b/app/components/debug/MediaSection.vue new file mode 100644 index 0000000..025b8ec --- /dev/null +++ b/app/components/debug/MediaSection.vue @@ -0,0 +1,95 @@ + + + diff --git a/app/components/debug/PrivacySection.vue b/app/components/debug/PrivacySection.vue new file mode 100644 index 0000000..b97bdf0 --- /dev/null +++ b/app/components/debug/PrivacySection.vue @@ -0,0 +1,124 @@ + + + diff --git a/app/layouts/dashboard.vue b/app/layouts/dashboard.vue index 7167d27..c55b46c 100644 --- a/app/layouts/dashboard.vue +++ b/app/layouts/dashboard.vue @@ -85,6 +85,7 @@ const menuItems = [ { to: '/', label: 'Instancias', icon: 'i-lucide-smartphone' }, { to: '/messages', label: 'Mensajes', icon: 'i-lucide-message-square' }, { to: '/webhooks', label: 'Webhooks', icon: 'i-lucide-webhook' }, + { to: '/debug', label: 'Debug', icon: 'i-lucide-bug' }, ] // Close sidebar on route change (mobile) diff --git a/app/pages/debug/index.vue b/app/pages/debug/index.vue new file mode 100644 index 0000000..5beda17 --- /dev/null +++ b/app/pages/debug/index.vue @@ -0,0 +1,141 @@ + + + diff --git a/docs/baileys-api-reference.md b/docs/baileys-api-reference.md new file mode 100644 index 0000000..48af81b --- /dev/null +++ b/docs/baileys-api-reference.md @@ -0,0 +1,6433 @@ +# Baileys API Documentation Reference + +> Auto-generated documentation for WhatsApp Nucleo development +> Source: https://baileys.wiki +> Generated: 2025-12-03T02:48:39.883Z + +This document contains the relevant Baileys API documentation for developing the WhatsApp Nucleo messaging features. + +## Table of Contents + +### Interfaces +- [Contact](#interface-contact) +- [GroupMetadata](#interface-groupmetadata) +- [GroupModificationResponse](#interface-groupmodificationresponse) +- [PresenceData](#interface-presencedata) +- [BaileysEventEmitter](#interface-baileyseventemitter) +- [WAUrlInfo](#interface-waurlinfo) +- [RecentMessage](#interface-recentmessage) + +### Type Aliases +- [Chat](#type-chat) +- [ChatModification](#type-chatmodification) +- [ChatUpdate](#type-chatupdate) +- [ChatMutation](#type-chatmutation) +- [WAMessage](#type-wamessage) +- [WAMessageContent](#type-wamessagecontent) +- [WAMessageKey](#type-wamessagekey) +- [WAMessageUpdate](#type-wamessageupdate) +- [MessageType](#type-messagetype) +- [MessageUpsertType](#type-messageupserttype) +- [AnyMessageContent](#type-anymessagecontent) +- [AnyMediaMessageContent](#type-anymediamessagecontent) +- [AnyRegularMessageContent](#type-anyregularmessagecontent) +- [MessageGenerationOptions](#type-messagegenerationoptions) +- [MessageContentGenerationOptions](#type-messagecontentgenerationoptions) +- [MinimalMessage](#type-minimalmessage) +- [MediaType](#type-mediatype) +- [MediaDownloadOptions](#type-mediadownloadoptions) +- [WAMediaUpload](#type-wamediaupload) +- [DownloadableMessage](#type-downloadablemessage) +- [MediaGenerationOptions](#type-mediagenerationoptions) +- [GroupParticipant](#type-groupparticipant) +- [GroupInviteInfo](#type-groupinviteinfo) +- [ParticipantAction](#type-participantaction) +- [WAPresence](#type-wapresence) +- [ConnectionState](#type-connectionstate) +- [BaileysEventMap](#type-baileyseventmap) +- [BaileysEvent](#type-baileysevent) +- [AuthenticationCreds](#type-authenticationcreds) +- [AuthenticationState](#type-authenticationstate) +- [WASocket](#type-wasocket) +- [SocketConfig](#type-socketconfig) +- [UserFacingSocketConfig](#type-userfacingsocketconfig) + +### Functions +- [generateWAMessage](#function-generatewamessage) +- [generateWAMessageContent](#function-generatewamessagecontent) +- [generateWAMessageFromContent](#function-generatewamessagefromcontent) +- [extractMessageContent](#function-extractmessagecontent) +- [getContentType](#function-getcontenttype) +- [normalizeMessageContent](#function-normalizemessagecontent) +- [downloadMediaMessage](#function-downloadmediamessage) +- [downloadContentFromMessage](#function-downloadcontentfrommessage) +- [prepareWAMessageMedia](#function-preparewamessagemedia) +- [extractImageThumb](#function-extractimagethumb) +- [generateThumbnail](#function-generatethumbnail) +- [generateProfilePicture](#function-generateprofilepicture) +- [getMediaKeys](#function-getmediakeys) +- [encryptedStream](#function-encryptedstream) +- [jidDecode](#function-jiddecode) +- [jidEncode](#function-jidencode) +- [jidNormalizedUser](#function-jidnormalizeduser) +- [isJidGroup](#function-isjidgroup) +- [isJidBroadcast](#function-isjidbroadcast) +- [isJidStatusBroadcast](#function-isjidstatusbroadcast) +- [areJidsSameUser](#function-arejidssameuser) +- [isLidUser](#function-isliduser) +- [downloadAndProcessHistorySyncNotification](#function-downloadandprocesshistorysyncnotification) +- [processHistoryMessage](#function-processhistorymessage) +- [getHistoryMsg](#function-gethistorymsg) +- [makeWASocket](#function-makewasocket) +- [makeCacheableSignalKeyStore](#function-makecacheablesignalkeystore) +- [useMultiFileAuthState](#function-usemultifileauthstate) +- [delay](#function-delay) +- [toNumber](#function-tonumber) +- [toBuffer](#function-tobuffer) +- [unixTimestampSeconds](#function-unixtimestampseconds) + +### Variables +- [WAMessageStatus](#variable-wamessagestatus) +- [WAMessageStubType](#variable-wamessagestubtype) +- [S_WHATSAPP_NET](#variable-s_whatsapp_net) +- [Browsers](#variable-browsers) +- [MEDIA_KEYS](#variable-media_keys) +- [DEFAULT_CONNECTION_CONFIG](#variable-default_connection_config) + +### Enumerations +- [DisconnectReason](#enum-disconnectreason) + + + +# Interfaces + + +--- + +## Interface: Contact + +**Source:** https://baileys.wiki/docs/api/interfaces/Contact + +On this page + +Defined in: src/Types/Contact.ts:1 + +## Properties​ + +### id​ + +**id**: `string` + +Defined in: src/Types/Contact.ts:3 + +ID either in lid or jid format (preferred) * + +### imgUrl?​ + +`optional` **imgUrl**: `null` | `string` + +Defined in: src/Types/Contact.ts:22 + +Url of the profile picture of the contact + +'changed' => if the profile picture has changed +null => if the profile picture has not been set (default profile picture) +any other string => url of the profile picture + +### lid?​ + +`optional` **lid**: `string` + +Defined in: src/Types/Contact.ts:5 + +ID in LID format (@lid) * + +### name?​ + +`optional` **name**: `string` + +Defined in: src/Types/Contact.ts:9 + +name of the contact, you have saved on your WA + +### notify?​ + +`optional` **notify**: `string` + +Defined in: src/Types/Contact.ts:11 + +name of the contact, the contact has set on their own on WA + +### phoneNumber?​ + +`optional` **phoneNumber**: `string` + +Defined in: src/Types/Contact.ts:7 + +ID in PN format (@s.whatsapp.net) * + +### status?​ + +`optional` **status**: `string` + +Defined in: src/Types/Contact.ts:23 + +### verifiedName?​ + +`optional` **verifiedName**: `string` + +Defined in: src/Types/Contact.ts:13 + +I have no idea + +- Properties +id +- imgUrl? +- lid? +- name? +- notify? +- phoneNumber? +- status? +- verifiedName? + + +--- + +## Interface: GroupMetadata + +**Source:** https://baileys.wiki/docs/api/interfaces/GroupMetadata + +On this page + +Defined in: src/Types/GroupMetadata.ts:16 + +## Properties​ + +### addressingMode?​ + +`optional` **addressingMode**: `WAMessageAddressingMode` + +Defined in: src/Types/GroupMetadata.ts:20 + +group uses 'lid' or 'pn' to send messages + +### announce?​ + +`optional` **announce**: `boolean` + +Defined in: src/Types/GroupMetadata.ts:41 + +is set when the group only allows admins to write messages + +### author?​ + +`optional` **author**: `string` + +Defined in: src/Types/GroupMetadata.ts:57 + +the person who added you to group or changed some setting in group + +### authorPn?​ + +`optional` **authorPn**: `string` + +Defined in: src/Types/GroupMetadata.ts:58 + +### creation?​ + +`optional` **creation**: `number` + +Defined in: src/Types/GroupMetadata.ts:30 + +### desc?​ + +`optional` **desc**: `string` + +Defined in: src/Types/GroupMetadata.ts:31 + +### descId?​ + +`optional` **descId**: `string` + +Defined in: src/Types/GroupMetadata.ts:34 + +### descOwner?​ + +`optional` **descOwner**: `string` + +Defined in: src/Types/GroupMetadata.ts:32 + +### descOwnerPn?​ + +`optional` **descOwnerPn**: `string` + +Defined in: src/Types/GroupMetadata.ts:33 + +### descTime?​ + +`optional` **descTime**: `number` + +Defined in: src/Types/GroupMetadata.ts:35 + +### ephemeralDuration?​ + +`optional` **ephemeralDuration**: `number` + +Defined in: src/Types/GroupMetadata.ts:54 + +### id​ + +**id**: `string` + +Defined in: src/Types/GroupMetadata.ts:17 + +### inviteCode?​ + +`optional` **inviteCode**: `string` + +Defined in: src/Types/GroupMetadata.ts:55 + +### isCommunity?​ + +`optional` **isCommunity**: `boolean` + +Defined in: src/Types/GroupMetadata.ts:47 + +is this a community + +### isCommunityAnnounce?​ + +`optional` **isCommunityAnnounce**: `boolean` + +Defined in: src/Types/GroupMetadata.ts:49 + +is this the announce of a community + +### joinApprovalMode?​ + +`optional` **joinApprovalMode**: `boolean` + +Defined in: src/Types/GroupMetadata.ts:45 + +Request approval to join the group + +### linkedParent?​ + +`optional` **linkedParent**: `string` + +Defined in: src/Types/GroupMetadata.ts:37 + +if this group is part of a community, it returns the jid of the community to which it belongs + +### memberAddMode?​ + +`optional` **memberAddMode**: `boolean` + +Defined in: src/Types/GroupMetadata.ts:43 + +is set when the group also allows members to add participants + +### notify?​ + +`optional` **notify**: `string` + +Defined in: src/Types/GroupMetadata.ts:18 + +### owner​ + +**owner**: `undefined` | `string` + +Defined in: src/Types/GroupMetadata.ts:21 + +### owner_country_code?​ + +`optional` **owner_country_code**: `string` + +Defined in: src/Types/GroupMetadata.ts:23 + +### ownerPn?​ + +`optional` **ownerPn**: `string` + +Defined in: src/Types/GroupMetadata.ts:22 + +### participants​ + +**participants**: `GroupParticipant`[] + +Defined in: src/Types/GroupMetadata.ts:53 + +### restrict?​ + +`optional` **restrict**: `boolean` + +Defined in: src/Types/GroupMetadata.ts:39 + +is set when the group only allows admins to change group settings + +### size?​ + +`optional` **size**: `number` + +Defined in: src/Types/GroupMetadata.ts:51 + +number of group participants + +### subject​ + +**subject**: `string` + +Defined in: src/Types/GroupMetadata.ts:24 + +### subjectOwner?​ + +`optional` **subjectOwner**: `string` + +Defined in: src/Types/GroupMetadata.ts:26 + +group subject owner + +### subjectOwnerPn?​ + +`optional` **subjectOwnerPn**: `string` + +Defined in: src/Types/GroupMetadata.ts:27 + +### subjectTime?​ + +`optional` **subjectTime**: `number` + +Defined in: src/Types/GroupMetadata.ts:29 + +group subject modification date + +- Properties +addressingMode? +- announce? +- author? +- authorPn? +- creation? +- desc? +- descId? +- descOwner? +- descOwnerPn? +- descTime? +- ephemeralDuration? +- id +- inviteCode? +- isCommunity? +- isCommunityAnnounce? +- joinApprovalMode? +- linkedParent? +- memberAddMode? +- notify? +- owner +- owner_country_code? +- ownerPn? +- participants +- restrict? +- size? +- subject +- subjectOwner? +- subjectOwnerPn? +- subjectTime? + + +--- + +## Interface: GroupModificationResponse + +**Source:** https://baileys.wiki/docs/api/interfaces/GroupModificationResponse + +On this page + +Defined in: src/Types/GroupMetadata.ts:67 + +## Properties​ + +### participants?​ + +`optional` **participants**: `object` + +Defined in: src/Types/GroupMetadata.ts:69 + +#### Index Signature​ + +[`key`: `string`]: `object` + +### status​ + +**status**: `number` + +Defined in: src/Types/GroupMetadata.ts:68 + +- Properties +participants? +- status + + +--- + +## Interface: PresenceData + +**Source:** https://baileys.wiki/docs/api/interfaces/PresenceData + +On this page + +Defined in: src/Types/Chat.ts:36 + +## Properties​ + +### lastKnownPresence​ + +**lastKnownPresence**: `WAPresence` + +Defined in: src/Types/Chat.ts:37 + +### lastSeen?​ + +`optional` **lastSeen**: `number` + +Defined in: src/Types/Chat.ts:38 + +- Properties +lastKnownPresence +- lastSeen? + + +--- + +## Interface: BaileysEventEmitter + +**Source:** https://baileys.wiki/docs/api/interfaces/BaileysEventEmitter + +On this page + +Defined in: src/Types/Events.ts:127 + +## Methods​ + +### emit()​ + +**emit**<`T`>(`event`, `arg`): `boolean` + +Defined in: src/Types/Events.ts:131 + +#### Type Parameters​ + +• **T** *extends* keyof `BaileysEventMap` + +#### Parameters​ + +event​ + +`T` + +arg​ + +`BaileysEventMap`[`T`] + +#### Returns​ + +`boolean` + +### off()​ + +**off**<`T`>(`event`, `listener`): `void` + +Defined in: src/Types/Events.ts:129 + +#### Type Parameters​ + +• **T** *extends* keyof `BaileysEventMap` + +#### Parameters​ + +event​ + +`T` + +listener​ + +(`arg`) => `void` + +#### Returns​ + +`void` + +### on()​ + +**on**<`T`>(`event`, `listener`): `void` + +Defined in: src/Types/Events.ts:128 + +#### Type Parameters​ + +• **T** *extends* keyof `BaileysEventMap` + +#### Parameters​ + +event​ + +`T` + +listener​ + +(`arg`) => `void` + +#### Returns​ + +`void` + +### removeAllListeners()​ + +**removeAllListeners**<`T`>(`event`): `void` + +Defined in: src/Types/Events.ts:130 + +#### Type Parameters​ + +• **T** *extends* keyof `BaileysEventMap` + +#### Parameters​ + +event​ + +`T` + +#### Returns​ + +`void` + +- Methods +emit() +- off() +- on() +- removeAllListeners() + + +--- + +## Interface: WAUrlInfo + +**Source:** https://baileys.wiki/docs/api/interfaces/WAUrlInfo + +On this page + +Defined in: src/Types/Message.ts:102 + +## Properties​ + +### canonical-url​ + +**canonical-url**: `string` + +Defined in: src/Types/Message.ts:103 + +### description?​ + +`optional` **description**: `string` + +Defined in: src/Types/Message.ts:106 + +### highQualityThumbnail?​ + +`optional` **highQualityThumbnail**: `IImageMessage` + +Defined in: src/Types/Message.ts:108 + +### jpegThumbnail?​ + +`optional` **jpegThumbnail**: `Buffer`<`ArrayBufferLike`> + +Defined in: src/Types/Message.ts:107 + +### matched-text​ + +**matched-text**: `string` + +Defined in: src/Types/Message.ts:104 + +### originalThumbnailUrl?​ + +`optional` **originalThumbnailUrl**: `string` + +Defined in: src/Types/Message.ts:109 + +### title​ + +**title**: `string` + +Defined in: src/Types/Message.ts:105 + +- Properties +canonical-url +- description? +- highQualityThumbnail? +- jpegThumbnail? +- matched-text +- originalThumbnailUrl? +- title + + +--- + +## Interface: RecentMessage + +**Source:** https://baileys.wiki/docs/api/interfaces/RecentMessage + +On this page + +Defined in: src/Utils/message-retry-manager.ts:18 + +## Properties​ + +### message​ + +**message**: `IMessage` + +Defined in: src/Utils/message-retry-manager.ts:19 + +### timestamp​ + +**timestamp**: `number` + +Defined in: src/Utils/message-retry-manager.ts:20 + +- Properties +message +- timestamp + + +# Types + + +--- + +## Type: Chat + +**Source:** https://baileys.wiki/docs/api/type-aliases/Chat + +On this page + +**Chat**: `IConversation` & `object` + +Defined in: src/Types/Chat.ts:59 + +## Type declaration​ + +### lastMessageRecvTimestamp?​ + +`optional` **lastMessageRecvTimestamp**: `number` + +unix timestamp of when the last message was received in the chat + +- Type declaration +lastMessageRecvTimestamp? + + +--- + +## Type: ChatModification + +**Source:** https://baileys.wiki/docs/api/type-aliases/ChatModification + +On this page + +**ChatModification**: { `archive`: `boolean`; `lastMessages`: `LastMessageList`; } | { `pushNameSetting`: `string`; } | { `pin`: `boolean`; } | { `mute`: `number` | `null`; } | { `clear`: `boolean`; `lastMessages`: `LastMessageList`; } | { `deleteForMe`: { `deleteMedia`: `boolean`; `key`: `WAMessageKey`; `timestamp`: `number`; }; } | { `star`: { `messages`: `object`[]; `star`: `boolean`; }; } | { `lastMessages`: `LastMessageList`; `markRead`: `boolean`; } | { `delete`: `true`; `lastMessages`: `LastMessageList`; } | { `contact`: `IContactAction` | `null`; } | { `disableLinkPreviews`: `IPrivacySettingDisableLinkPreviewsAction`; } | { `addLabel`: `LabelActionBody`; } | { `addChatLabel`: `ChatLabelAssociationActionBody`; } | { `removeChatLabel`: `ChatLabelAssociationActionBody`; } | { `addMessageLabel`: `MessageLabelAssociationActionBody`; } | { `removeMessageLabel`: `MessageLabelAssociationActionBody`; } | { `quickReply`: `QuickReplyAction`; } + +Defined in: src/Types/Chat.ts:87 + +## Type declaration​ + +{ `archive`: `boolean`; `lastMessages`: `LastMessageList`; } + +### archive​ + +**archive**: `boolean` + +### lastMessages​ + +**lastMessages**: `LastMessageList` + +{ `pushNameSetting`: `string`; } + +### pushNameSetting​ + +**pushNameSetting**: `string` + +{ `pin`: `boolean`; } + +### pin​ + +**pin**: `boolean` + +{ `mute`: `number` | `null`; } + +### mute​ + +**mute**: `number` | `null` + +mute for duration, or provide timestamp of mute to remove + +{ `clear`: `boolean`; `lastMessages`: `LastMessageList`; } + +### clear​ + +**clear**: `boolean` + +### lastMessages​ + +**lastMessages**: `LastMessageList` + +{ `deleteForMe`: { `deleteMedia`: `boolean`; `key`: `WAMessageKey`; `timestamp`: `number`; }; } + +### deleteForMe​ + +**deleteForMe**: `object` + +#### deleteForMe.deleteMedia​ + +**deleteMedia**: `boolean` + +#### deleteForMe.key​ + +**key**: `WAMessageKey` + +#### deleteForMe.timestamp​ + +**timestamp**: `number` + +{ `star`: { `messages`: `object`[]; `star`: `boolean`; }; } + +### star​ + +**star**: `object` + +#### star.messages​ + +**messages**: `object`[] + +#### star.star​ + +**star**: `boolean` + +{ `lastMessages`: `LastMessageList`; `markRead`: `boolean`; } + +### lastMessages​ + +**lastMessages**: `LastMessageList` + +### markRead​ + +**markRead**: `boolean` + +{ `delete`: `true`; `lastMessages`: `LastMessageList`; } + +### delete​ + +**delete**: `true` + +### lastMessages​ + +**lastMessages**: `LastMessageList` + +{ `contact`: `IContactAction` | `null`; } + +### contact​ + +**contact**: `IContactAction` | `null` + +{ `disableLinkPreviews`: `IPrivacySettingDisableLinkPreviewsAction`; } + +### disableLinkPreviews​ + +**disableLinkPreviews**: `IPrivacySettingDisableLinkPreviewsAction` + +{ `addLabel`: `LabelActionBody`; } + +### addLabel​ + +**addLabel**: `LabelActionBody` + +{ `addChatLabel`: `ChatLabelAssociationActionBody`; } + +### addChatLabel​ + +**addChatLabel**: `ChatLabelAssociationActionBody` + +{ `removeChatLabel`: `ChatLabelAssociationActionBody`; } + +### removeChatLabel​ + +**removeChatLabel**: `ChatLabelAssociationActionBody` + +{ `addMessageLabel`: `MessageLabelAssociationActionBody`; } + +### addMessageLabel​ + +**addMessageLabel**: `MessageLabelAssociationActionBody` + +{ `removeMessageLabel`: `MessageLabelAssociationActionBody`; } + +### removeMessageLabel​ + +**removeMessageLabel**: `MessageLabelAssociationActionBody` + +{ `quickReply`: `QuickReplyAction`; } + +### quickReply​ + +**quickReply**: `QuickReplyAction` + +- Type declaration +archive +- lastMessages +- pushNameSetting +- pin +- mute +- clear +- lastMessages +- deleteForMe +- star +- lastMessages +- markRead +- delete +- lastMessages +- contact +- disableLinkPreviews +- addLabel +- addChatLabel +- removeChatLabel +- addMessageLabel +- removeMessageLabel +- quickReply + + +--- + +## Type: ChatUpdate + +**Source:** https://baileys.wiki/docs/api/type-aliases/ChatUpdate + +**ChatUpdate**: `Partial`<`Chat` & `object`> + +Defined in: src/Types/Chat.ts:64 + + +--- + +## Type: ChatMutation + +**Source:** https://baileys.wiki/docs/api/type-aliases/ChatMutation + +On this page + +**ChatMutation**: `object` + +Defined in: src/Types/Chat.ts:46 + +## Type declaration​ + +### index​ + +**index**: `string`[] + +### syncAction​ + +**syncAction**: `ISyncActionData` + +- Type declaration +index +- syncAction + + +--- + +## Type: WAMessage + +**Source:** https://baileys.wiki/docs/api/type-aliases/WAMessage + +On this page + +**WAMessage**: `IWebMessageInfo` & `object` + +Defined in: src/Types/Message.ts:11 + +## Type declaration​ + +### category?​ + +`optional` **category**: `string` + +### key​ + +**key**: `WAMessageKey` + +### messageStubParameters?​ + +`optional` **messageStubParameters**: `any` + +### retryCount?​ + +`optional` **retryCount**: `number` + +- Type declaration +category? +- key +- messageStubParameters? +- retryCount? + + +--- + +## Type: WAMessageContent + +**Source:** https://baileys.wiki/docs/api/type-aliases/WAMessageContent + +**WAMessageContent**: `IMessage` + +Defined in: src/Types/Message.ts:17 + + +--- + +## Type: WAMessageKey + +**Source:** https://baileys.wiki/docs/api/type-aliases/WAMessageKey + +On this page + +**WAMessageKey**: `IMessageKey` & `object` + +Defined in: src/Types/Message.ts:20 + +## Type declaration​ + +### addressingMode?​ + +`optional` **addressingMode**: `string` + +### isViewOnce?​ + +`optional` **isViewOnce**: `boolean` + +### participantAlt?​ + +`optional` **participantAlt**: `string` + +### remoteJidAlt?​ + +`optional` **remoteJidAlt**: `string` + +### server_id?​ + +`optional` **server_id**: `string` + +- Type declaration +addressingMode? +- isViewOnce? +- participantAlt? +- remoteJidAlt? +- server_id? + + +--- + +## Type: WAMessageUpdate + +**Source:** https://baileys.wiki/docs/api/type-aliases/WAMessageUpdate + +On this page + +**WAMessageUpdate**: `object` + +Defined in: src/Types/Message.ts:368 + +## Type declaration​ + +### key​ + +**key**: `WAMessageKey` + +### update​ + +**update**: `Partial`<`WAMessage`> + +- Type declaration +key +- update + + +--- + +## Type: MessageType + +**Source:** https://baileys.wiki/docs/api/type-aliases/MessageType + +**MessageType**: keyof `Message` + +Defined in: src/Types/Message.ts:43 + +Set of message types that are supported by the library + + +--- + +## Type: MessageUpsertType + +**Source:** https://baileys.wiki/docs/api/type-aliases/MessageUpsertType + +**MessageUpsertType**: `"append"` | `"notify"` + +Defined in: src/Types/Message.ts:364 + +Type of message upsert + +- notify => notify the user, this message was just received + +- append => append the message to the chat history, no notification required + + +--- + +## Type: AnyMessageContent + +**Source:** https://baileys.wiki/docs/api/type-aliases/AnyMessageContent + +On this page + +**AnyMessageContent**: `AnyRegularMessageContent` | { `force`: `boolean`; `forward`: `WAMessage`; } | { `delete`: `WAMessageKey`; } | { `disappearingMessagesInChat`: `boolean` | `number`; } | { `limitSharing`: `boolean`; } + +Defined in: src/Types/Message.ts:271 + +## Type declaration​ + +`AnyRegularMessageContent` + +{ `force`: `boolean`; `forward`: `WAMessage`; } + +### force?​ + +`optional` **force**: `boolean` + +### forward​ + +**forward**: `WAMessage` + +{ `delete`: `WAMessageKey`; } + +### delete​ + +**delete**: `WAMessageKey` + +Delete your message or anyone's message in a group (admin required) + +{ `disappearingMessagesInChat`: `boolean` | `number`; } + +### disappearingMessagesInChat​ + +**disappearingMessagesInChat**: `boolean` | `number` + +{ `limitSharing`: `boolean`; } + +### limitSharing​ + +**limitSharing**: `boolean` + +- Type declaration +force? +- forward +- delete +- disappearingMessagesInChat +- limitSharing + + +--- + +## Type: AnyMediaMessageContent + +**Source:** https://baileys.wiki/docs/api/type-aliases/AnyMediaMessageContent + +On this page + +**AnyMediaMessageContent**: `object` & `Mentionable` & `Contextable` & `WithDimensions` | `object` & `Mentionable` & `Contextable` & `WithDimensions` | { `audio`: `WAMediaUpload`; `ptt`: `boolean`; `seconds`: `number`; } | `object` & `WithDimensions` | `object` & `Contextable` & `object` & `Editable` + +Defined in: src/Types/Message.ts:163 + +## Type declaration​ + +### mimetype?​ + +`optional` **mimetype**: `string` + +- Type declaration +mimetype? + + +--- + +## Type: AnyRegularMessageContent + +**Source:** https://baileys.wiki/docs/api/type-aliases/AnyRegularMessageContent + +**AnyRegularMessageContent**: `object` & `Mentionable` & `Contextable` & `Editable` | `AnyMediaMessageContent` | { `event`: `EventMessageOptions`; } | `object` & `Mentionable` & `Contextable` & `Editable` | { `contacts`: { `contacts`: `IContactMessage`[]; `displayName`: `string`; }; } | { `location`: `WALocationMessage`; } | { `react`: `IReactionMessage`; } | { `buttonReply`: `ButtonReplyInfo`; `type`: `"template"` | `"plain"`; } | { `groupInvite`: `GroupInviteInfo`; } | { `listReply`: `Omit`<`IListResponseMessage`, `"contextInfo"`>; } | { `pin`: `WAMessageKey`; `time`: `86400` | `604800` | `2592000`; `type`: `Type`; } | { `body`: `string`; `businessOwnerJid`: `string`; `footer`: `string`; `product`: `WASendableProduct`; } | `SharePhoneNumber` | `RequestPhoneNumber` & `ViewOnce` + +Defined in: src/Types/Message.ts:218 + + +--- + +## Type: MessageGenerationOptions + +**Source:** https://baileys.wiki/docs/api/type-aliases/MessageGenerationOptions + +**MessageGenerationOptions**: `MessageContentGenerationOptions` & `MessageGenerationOptionsFromContent` + +Defined in: src/Types/Message.ts:357 + + +--- + +## Type: MessageContentGenerationOptions + +**Source:** https://baileys.wiki/docs/api/type-aliases/MessageContentGenerationOptions + +On this page + +**MessageContentGenerationOptions**: `MediaGenerationOptions` & `object` + +Defined in: src/Types/Message.ts:351 + +## Type declaration​ + +### getCallLink()?​ + +`optional` **getCallLink**: (`type`, `event`?) => `Promise`<`string` | `undefined`> + +#### Parameters​ + +type​ + +`"audio"` | `"video"` + +event?​ +startTime​ + +`number` + +#### Returns​ + +`Promise`<`string` | `undefined`> + +### getProfilePicUrl()?​ + +`optional` **getProfilePicUrl**: (`jid`, `type`) => `Promise`<`string` | `undefined`> + +#### Parameters​ + +jid​ + +`string` + +type​ + +`"image"` | `"preview"` + +#### Returns​ + +`Promise`<`string` | `undefined`> + +### getUrlInfo()?​ + +`optional` **getUrlInfo**: (`text`) => `Promise`<`WAUrlInfo` | `undefined`> + +#### Parameters​ + +text​ + +`string` + +#### Returns​ + +`Promise`<`WAUrlInfo` | `undefined`> + +### jid?​ + +`optional` **jid**: `string` + +- Type declaration +getCallLink()? +- getProfilePicUrl()? +- getUrlInfo()? +- jid? + + +--- + +## Type: MinimalMessage + +**Source:** https://baileys.wiki/docs/api/type-aliases/MinimalMessage + +**MinimalMessage**: `Pick`<`WAMessage`, `"key"` | `"messageTimestamp"`> + +Defined in: src/Types/Message.ts:380 + + +--- + +## Type: MediaType + +**Source:** https://baileys.wiki/docs/api/type-aliases/MediaType + +**MediaType**: keyof *typeof* `MEDIA_HKDF_KEY_MAPPING` + +Defined in: src/Defaults/index.ts:117 + + +--- + +## Type: MediaDownloadOptions + +**Source:** https://baileys.wiki/docs/api/type-aliases/MediaDownloadOptions + +On this page + +**MediaDownloadOptions**: `object` + +Defined in: src/Utils/messages-media.ts:498 + +## Type declaration​ + +### endByte?​ + +`optional` **endByte**: `number` + +### options?​ + +`optional` **options**: `RequestInit` + +### startByte?​ + +`optional` **startByte**: `number` + +- Type declaration +endByte? +- options? +- startByte? + + +--- + +## Type: WAMediaUpload + +**Source:** https://baileys.wiki/docs/api/type-aliases/WAMediaUpload + +**WAMediaUpload**: `Buffer` | `WAMediaPayloadStream` | `WAMediaPayloadURL` + +Defined in: src/Types/Message.ts:41 + + +--- + +## Type: DownloadableMessage + +**Source:** https://baileys.wiki/docs/api/type-aliases/DownloadableMessage + +On this page + +**DownloadableMessage**: `object` + +Defined in: src/Types/Message.ts:83 + +## Type declaration​ + +### directPath?​ + +`optional` **directPath**: `string` | `null` + +### mediaKey?​ + +`optional` **mediaKey**: `Uint8Array` | `null` + +### url?​ + +`optional` **url**: `string` | `null` + +- Type declaration +directPath? +- mediaKey? +- url? + + +--- + +## Type: MediaGenerationOptions + +**Source:** https://baileys.wiki/docs/api/type-aliases/MediaGenerationOptions + +On this page + +**MediaGenerationOptions**: `object` + +Defined in: src/Types/Message.ts:336 + +## Type declaration​ + +### backgroundColor?​ + +`optional` **backgroundColor**: `string` + +### font?​ + +`optional` **font**: `number` + +### logger?​ + +`optional` **logger**: `ILogger` + +### mediaCache?​ + +`optional` **mediaCache**: `CacheStore` + +cache media so it does not have to be uploaded again + +### mediaTypeOverride?​ + +`optional` **mediaTypeOverride**: `MediaType` + +### mediaUploadTimeoutMs?​ + +`optional` **mediaUploadTimeoutMs**: `number` + +### options?​ + +`optional` **options**: `RequestInit` + +### upload​ + +**upload**: `WAMediaUploadFunction` + +- Type declaration +backgroundColor? +- font? +- logger? +- mediaCache? +- mediaTypeOverride? +- mediaUploadTimeoutMs? +- options? +- upload + + +--- + +## Type: GroupParticipant + +**Source:** https://baileys.wiki/docs/api/type-aliases/GroupParticipant + +On this page + +**GroupParticipant**: `Contact` & `object` + +Defined in: src/Types/GroupMetadata.ts:4 + +## Type declaration​ + +### admin?​ + +`optional` **admin**: `"admin"` | `"superadmin"` | `null` + +### isAdmin?​ + +`optional` **isAdmin**: `boolean` + +### isSuperAdmin?​ + +`optional` **isSuperAdmin**: `boolean` + +- Type declaration +admin? +- isAdmin? +- isSuperAdmin? + + +--- + +## Type: GroupInviteInfo + +**Source:** https://baileys.wiki/docs/api/type-aliases/GroupInviteInfo + +On this page + +**GroupInviteInfo**: `object` + +Defined in: src/Types/Message.ts:206 + +## Type declaration​ + +### inviteCode​ + +**inviteCode**: `string` + +### inviteExpiration​ + +**inviteExpiration**: `number` + +### jid​ + +**jid**: `string` + +### subject​ + +**subject**: `string` + +### text​ + +**text**: `string` + +- Type declaration +inviteCode +- inviteExpiration +- jid +- subject +- text + + +--- + +## Type: ParticipantAction + +**Source:** https://baileys.wiki/docs/api/type-aliases/ParticipantAction + +**ParticipantAction**: `"add"` | `"remove"` | `"promote"` | `"demote"` | `"modify"` + +Defined in: src/Types/GroupMetadata.ts:10 + + +--- + +## Type: WAPresence + +**Source:** https://baileys.wiki/docs/api/type-aliases/WAPresence + +**WAPresence**: `"unavailable"` | `"available"` | `"composing"` | `"recording"` | `"paused"` + +Defined in: src/Types/Chat.ts:24 + +set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send + + +--- + +## Type: ConnectionState + +**Source:** https://baileys.wiki/docs/api/type-aliases/ConnectionState + +On this page + +**ConnectionState**: `object` + +Defined in: src/Types/State.ts:17 + +## Type declaration​ + +### connection​ + +**connection**: `WAConnectionState` + +connection is now open, connecting or closed + +### isNewLogin?​ + +`optional` **isNewLogin**: `boolean` + +is this a new login + +### isOnline?​ + +`optional` **isOnline**: `boolean` + +if the client is shown as an active, online client. +If this is false, the primary phone and other devices will receive notifs + +### lastDisconnect?​ + +`optional` **lastDisconnect**: `object` + +the error that caused the connection to close + +#### lastDisconnect.date​ + +**date**: `Date` + +#### lastDisconnect.error​ + +**error**: `Boom` | `Error` | `undefined` + +### legacy?​ + +`optional` **legacy**: `object` + +legacy connection options + +#### legacy.phoneConnected​ + +**phoneConnected**: `boolean` + +#### legacy.user?​ + +`optional` **user**: `Contact` + +### qr?​ + +`optional` **qr**: `string` + +the current QR code + +### receivedPendingNotifications?​ + +`optional` **receivedPendingNotifications**: `boolean` + +has the device received all pending notifications while it was offline + +- Type declaration +connection +- isNewLogin? +- isOnline? +- lastDisconnect? +- legacy? +- qr? +- receivedPendingNotifications? + + +--- + +## Type: BaileysEventMap + +**Source:** https://baileys.wiki/docs/api/type-aliases/BaileysEventMap + +On this page + +**BaileysEventMap**: `object` + +Defined in: src/Types/Events.ts:20 + +## Type declaration​ + +#### blocklist.set​ + +**set**: `object` + +#### blocklist.set.blocklist​ + +**blocklist**: `string`[] + +#### blocklist.update​ + +**update**: `object` + +#### blocklist.update.blocklist​ + +**blocklist**: `string`[] + +#### blocklist.update.type​ + +**type**: `"add"` | `"remove"` + +### call​ + +**call**: `WACallEvent`[] + +Receive an update on a call, including when the call was received, rejected, accepted + +#### chats.delete​ + +**delete**: `string`[] + +delete chats with given ID + +#### chats.update​ + +**update**: `ChatUpdate`[] + +update the given chats + +#### chats.upsert​ + +**upsert**: `Chat`[] + +upsert chats + +#### connection.update​ + +**update**: `Partial`<`ConnectionState`> + +connection state has been updated -- WS closed, opened, connecting etc. + +#### contacts.update​ + +**update**: `Partial`<`Contact`>[] + +#### contacts.upsert​ + +**upsert**: `Contact`[] + +#### creds.update​ + +**update**: `Partial`<`AuthenticationCreds`> + +credentials updated -- some metadata, keys or something + +#### group-participants.update​ + +**update**: `object` + +apply an action to participants in a group + +#### group-participants.update.action​ + +**action**: `ParticipantAction` + +#### group-participants.update.author​ + +**author**: `string` + +#### group-participants.update.authorPn?​ + +`optional` **authorPn**: `string` + +#### group-participants.update.id​ + +**id**: `string` + +#### group-participants.update.participants​ + +**participants**: `GroupParticipant`[] + +#### group.join-request​ + +**join-request**: `object` + +#### group.join-request.action​ + +**action**: `RequestJoinAction` + +#### group.join-request.author​ + +**author**: `string` + +#### group.join-request.authorPn?​ + +`optional` **authorPn**: `string` + +#### group.join-request.id​ + +**id**: `string` + +#### group.join-request.method​ + +**method**: `RequestJoinMethod` + +#### group.join-request.participant​ + +**participant**: `string` + +#### group.join-request.participantPn?​ + +`optional` **participantPn**: `string` + +#### groups.update​ + +**update**: `Partial`<`GroupMetadata`>[] + +#### groups.upsert​ + +**upsert**: `GroupMetadata`[] + +#### labels.association​ + +**association**: `object` + +#### labels.association.association​ + +**association**: `LabelAssociation` + +#### labels.association.type​ + +**type**: `"add"` | `"remove"` + +#### labels.edit​ + +**edit**: `Label` + +#### lid-mapping.update​ + +**update**: `object` + +#### lid-mapping.update.lid​ + +**lid**: `string` + +#### lid-mapping.update.pn​ + +**pn**: `string` + +#### message-receipt.update​ + +**update**: `MessageUserReceiptUpdate`[] + +#### messages.delete​ + +**delete**: { `keys`: `WAMessageKey`[]; } | { `all`: `true`; `jid`: `string`; } + +#### messages.media-update​ + +**media-update**: `object`[] + +#### messages.reaction​ + +**reaction**: `object`[] + +message was reacted to. If reaction was removed -- then "reaction.text" will be falsey + +#### messages.update​ + +**update**: `WAMessageUpdate`[] + +#### messages.upsert​ + +**upsert**: `object` + +add/update the given messages. If they were received while the connection was online, +the update will have type: "notify" +if requestId is provided, then the messages was received from the phone due to it being unavailable + +#### messages.upsert.messages​ + +**messages**: `WAMessage`[] + +#### messages.upsert.requestId?​ + +`optional` **requestId**: `string` + +#### messages.upsert.type​ + +**type**: `MessageUpsertType` + +#### messaging-history.set​ + +**set**: `object` + +set chats (history sync), everything is reverse chronologically sorted + +#### messaging-history.set.chats​ + +**chats**: `Chat`[] + +#### messaging-history.set.contacts​ + +**contacts**: `Contact`[] + +#### messaging-history.set.isLatest?​ + +`optional` **isLatest**: `boolean` + +#### messaging-history.set.messages​ + +**messages**: `WAMessage`[] + +#### messaging-history.set.peerDataRequestSessionId?​ + +`optional` **peerDataRequestSessionId**: `string` | `null` + +#### messaging-history.set.progress?​ + +`optional` **progress**: `number` | `null` + +#### messaging-history.set.syncType?​ + +`optional` **syncType**: `HistorySyncType` | `null` + +#### newsletter-participants.update​ + +**update**: `object` + +#### newsletter-participants.update.action​ + +**action**: `string` + +#### newsletter-participants.update.author​ + +**author**: `string` + +#### newsletter-participants.update.id​ + +**id**: `string` + +#### newsletter-participants.update.new_role​ + +**new_role**: `string` + +#### newsletter-participants.update.user​ + +**user**: `string` + +#### newsletter-settings.update​ + +**update**: `object` + +#### newsletter-settings.update.id​ + +**id**: `string` + +#### newsletter-settings.update.update​ + +**update**: `any` + +#### newsletter.reaction​ + +**reaction**: `object` + +Newsletter-related events + +#### newsletter.reaction.id​ + +**id**: `string` + +#### newsletter.reaction.reaction​ + +**reaction**: `object` + +#### newsletter.reaction.reaction.code?​ + +`optional` **code**: `string` + +#### newsletter.reaction.reaction.count?​ + +`optional` **count**: `number` + +#### newsletter.reaction.reaction.removed?​ + +`optional` **removed**: `boolean` + +#### newsletter.reaction.server_id​ + +**server_id**: `string` + +#### newsletter.view​ + +**view**: `object` + +#### newsletter.view.count​ + +**count**: `number` + +#### newsletter.view.id​ + +**id**: `string` + +#### newsletter.view.server_id​ + +**server_id**: `string` + +#### presence.update​ + +**update**: `object` + +presence of contact in a chat updated + +#### presence.update.id​ + +**id**: `string` + +#### presence.update.presences​ + +**presences**: `object` + +Index Signature​ + +[`participant`: `string`]: `PresenceData` + +- Type declaration +call + + +--- + +## Type: BaileysEvent + +**Source:** https://baileys.wiki/docs/api/type-aliases/BaileysEvent + +**BaileysEvent**: keyof `BaileysEventMap` + +Defined in: src/Types/Events.ts:125 + + +--- + +## Type: AuthenticationCreds + +**Source:** https://baileys.wiki/docs/api/type-aliases/AuthenticationCreds + +On this page + +**AuthenticationCreds**: `SignalCreds` & `object` + +Defined in: src/Types/Auth.ts:48 + +## Type declaration​ + +### account?​ + +`optional` **account**: `IADVSignedDeviceIdentity` + +### accountSettings​ + +**accountSettings**: `AccountSettings` + +### accountSyncCounter​ + +**accountSyncCounter**: `number` + +number of times history & app state has been synced + +### additionalData?​ + +`optional` **additionalData**: `any` + +### advSecretKey​ + +**advSecretKey**: `string` + +### firstUnuploadedPreKeyId​ + +**firstUnuploadedPreKeyId**: `number` + +### lastAccountSyncTimestamp?​ + +`optional` **lastAccountSyncTimestamp**: `number` + +### lastPropHash​ + +**lastPropHash**: `string` | `undefined` + +### me?​ + +`optional` **me**: `Contact` + +### myAppStateKeyId?​ + +`optional` **myAppStateKeyId**: `string` + +### nextPreKeyId​ + +**nextPreKeyId**: `number` + +### noiseKey​ + +`readonly` **noiseKey**: `KeyPair` + +### pairingCode​ + +**pairingCode**: `string` | `undefined` + +### pairingEphemeralKeyPair​ + +`readonly` **pairingEphemeralKeyPair**: `KeyPair` + +### platform?​ + +`optional` **platform**: `string` + +### processedHistoryMessages​ + +**processedHistoryMessages**: `MinimalMessage`[] + +### registered​ + +**registered**: `boolean` + +### routingInfo​ + +**routingInfo**: `Buffer` | `undefined` + +### signalIdentities?​ + +`optional` **signalIdentities**: `SignalIdentity`[] + +- Type declaration +account? +- accountSettings +- accountSyncCounter +- additionalData? +- advSecretKey +- firstUnuploadedPreKeyId +- lastAccountSyncTimestamp? +- lastPropHash +- me? +- myAppStateKeyId? +- nextPreKeyId +- noiseKey +- pairingCode +- pairingEphemeralKeyPair +- platform? +- processedHistoryMessages +- registered +- routingInfo +- signalIdentities? + + +--- + +## Type: AuthenticationState + +**Source:** https://baileys.wiki/docs/api/type-aliases/AuthenticationState + +On this page + +**AuthenticationState**: `object` + +Defined in: src/Types/Auth.ts:112 + +## Type declaration​ + +### creds​ + +**creds**: `AuthenticationCreds` + +### keys​ + +**keys**: `SignalKeyStore` + +- Type declaration +creds +- keys + + +--- + +## Type: WASocket + +**Source:** https://baileys.wiki/docs/api/type-aliases/WASocket + +**WASocket**: `ReturnType`<*typeof* `makeWASocket`> + +Defined in: src/index.ts:11 + + +--- + +## Type: SocketConfig + +**Source:** https://baileys.wiki/docs/api/type-aliases/SocketConfig + +On this page + +**SocketConfig**: `object` + +Defined in: src/Types/Socket.ts:32 + +## Type declaration​ + +### agent?​ + +`optional` **agent**: `Agent` + +proxy agent + +### appStateMacVerification​ + +**appStateMacVerification**: `object` + +verify app state MACs + +#### appStateMacVerification.patch​ + +**patch**: `boolean` + +#### appStateMacVerification.snapshot​ + +**snapshot**: `boolean` + +### auth​ + +**auth**: `AuthenticationState` + +provide an auth state object to maintain the auth state + +### browser​ + +**browser**: `WABrowserDescription` + +override browser config + +### cachedGroupMetadata()​ + +**cachedGroupMetadata**: (`jid`) => `Promise`<`GroupMetadata` | `undefined`> + +cached group metadata, use to prevent redundant requests to WA & speed up msg sending + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`GroupMetadata` | `undefined`> + +### callOfferCache?​ + +`optional` **callOfferCache**: `CacheStore` + +cache to store call offers + +### connectTimeoutMs​ + +**connectTimeoutMs**: `number` + +Fails the connection if the socket times out in this interval + +### countryCode​ + +**countryCode**: `string` + +alphanumeric country code (USA -> US) for the number used + +### customUploadHosts​ + +**customUploadHosts**: `MediaConnInfo`[`"hosts"`] + +custom upload hosts to upload media to + +### defaultQueryTimeoutMs​ + +**defaultQueryTimeoutMs**: `number` | `undefined` + +Default timeout for queries, undefined for no timeout + +### emitOwnEvents​ + +**emitOwnEvents**: `boolean` + +should events be emitted for actions done by this socket connection + +### enableAutoSessionRecreation​ + +**enableAutoSessionRecreation**: `boolean` + +Enable automatic session recreation for failed messages + +### enableRecentMessageCache​ + +**enableRecentMessageCache**: `boolean` + +Enable recent message caching for retry handling + +### fetchAgent?​ + +`optional` **fetchAgent**: `Agent` + +agent used for fetch requests -- uploading/downloading media + +### fireInitQueries​ + +**fireInitQueries**: `boolean` + +Should baileys fire init queries automatically, default true + +### generateHighQualityLinkPreview​ + +**generateHighQualityLinkPreview**: `boolean` + +generate a high quality link preview, +entails uploading the jpegThumbnail to WA + +### getMessage()​ + +**getMessage**: (`key`) => `Promise`<`IMessage` | `undefined`> + +fetch a message from your store +implement this so that messages failed to send +(solves the "this message can take a while" issue) can be retried + +#### Parameters​ + +key​ + +`WAMessageKey` + +#### Returns​ + +`Promise`<`IMessage` | `undefined`> + +### keepAliveIntervalMs​ + +**keepAliveIntervalMs**: `number` + +ping-pong interval for WS connection + +### linkPreviewImageThumbnailWidth​ + +**linkPreviewImageThumbnailWidth**: `number` + +width for link preview images + +### logger​ + +**logger**: `ILogger` + +logger + +### makeSignalRepository()​ + +**makeSignalRepository**: (`auth`, `logger`, `pnToLIDFunc`?) => `SignalRepositoryWithLIDStore` + +#### Parameters​ + +auth​ + +`SignalAuthState` + +logger​ + +`ILogger` + +pnToLIDFunc?​ + +(`jids`) => `Promise`<`LIDMapping`[] | `undefined`> + +#### Returns​ + +`SignalRepositoryWithLIDStore` + +### markOnlineOnConnect​ + +**markOnlineOnConnect**: `boolean` + +marks the client as online whenever the socket successfully connects + +### maxMsgRetryCount​ + +**maxMsgRetryCount**: `number` + +max retry count + +### mediaCache?​ + +`optional` **mediaCache**: `CacheStore` + +provide a cache to store media, so does not have to be re-uploaded + +### mobile?​ + +`optional` **mobile**: `boolean` + +should baileys use the mobile api instead of the multi device api + +#### Deprecated​ + +This feature has been removed + +### msgRetryCounterCache?​ + +`optional` **msgRetryCounterCache**: `CacheStore` + +map to store the retry counts for failed messages; +used to determine whether to retry a message or not + +### options​ + +**options**: `RequestInit` + +options for HTTP fetch requests + +### patchMessageBeforeSending()​ + +**patchMessageBeforeSending**: (`msg`, `recipientJids`?) => `Promise`<`PatchedMessageWithRecipientJID`[] | `PatchedMessageWithRecipientJID`> | `PatchedMessageWithRecipientJID`[] | `PatchedMessageWithRecipientJID` + +Optionally patch the message before sending out + +#### Parameters​ + +msg​ + +`IMessage` + +recipientJids?​ + +`string`[] + +#### Returns​ + +`Promise`<`PatchedMessageWithRecipientJID`[] | `PatchedMessageWithRecipientJID`> | `PatchedMessageWithRecipientJID`[] | `PatchedMessageWithRecipientJID` + +### placeholderResendCache?​ + +`optional` **placeholderResendCache**: `CacheStore` + +cache to track placeholder resends + +### printQRInTerminal?​ + +`optional` **printQRInTerminal**: `boolean` + +should the QR be printed in the terminal + +#### Deprecated​ + +This feature has been removed + +### qrTimeout?​ + +`optional` **qrTimeout**: `number` + +time to wait for the generation of the next QR in ms + +### retryRequestDelayMs​ + +**retryRequestDelayMs**: `number` + +time to wait between sending new retry requests + +### shouldIgnoreJid()​ + +**shouldIgnoreJid**: (`jid`) => `boolean` | `undefined` + +Returns if a jid should be ignored, +no event for that jid will be triggered. +Messages from that jid will also not be decrypted + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`boolean` | `undefined` + +### shouldSyncHistoryMessage()​ + +**shouldSyncHistoryMessage**: (`msg`) => `boolean` + +manage history processing with this control; by default will sync up everything + +#### Parameters​ + +msg​ + +`IHistorySyncNotification` + +#### Returns​ + +`boolean` + +### syncFullHistory​ + +**syncFullHistory**: `boolean` + +Should Baileys ask the phone for full history, will be received async + +### transactionOpts​ + +**transactionOpts**: `TransactionCapabilityOptions` + +transaction capability options for SignalKeyStore + +### userDevicesCache?​ + +`optional` **userDevicesCache**: `PossiblyExtendedCacheStore` + +provide a cache to store a user's device list + +### version​ + +**version**: `WAVersion` + +version to connect with + +### waWebSocketUrl​ + +**waWebSocketUrl**: `string` | `URL` + +the WS url to connect to WA + +- Type declaration +agent? +- appStateMacVerification +- auth +- browser +- cachedGroupMetadata() +- callOfferCache? +- connectTimeoutMs +- countryCode +- customUploadHosts +- defaultQueryTimeoutMs +- emitOwnEvents +- enableAutoSessionRecreation +- enableRecentMessageCache +- fetchAgent? +- fireInitQueries +- generateHighQualityLinkPreview +- getMessage() +- keepAliveIntervalMs +- linkPreviewImageThumbnailWidth +- logger +- makeSignalRepository() +- markOnlineOnConnect +- maxMsgRetryCount +- mediaCache? +- mobile? +- msgRetryCounterCache? +- options +- patchMessageBeforeSending() +- placeholderResendCache? +- printQRInTerminal? +- qrTimeout? +- retryRequestDelayMs +- shouldIgnoreJid() +- shouldSyncHistoryMessage() +- syncFullHistory +- transactionOpts +- userDevicesCache? +- version +- waWebSocketUrl + + +--- + +## Type: UserFacingSocketConfig + +**Source:** https://baileys.wiki/docs/api/type-aliases/UserFacingSocketConfig + +On this page + +**UserFacingSocketConfig**: `Partial`<`SocketConfig`> & `object` + +Defined in: src/Types/index.ts:17 + +## Type declaration​ + +### auth​ + +**auth**: `AuthenticationState` + +- Type declaration +auth + + +# Functions + + +--- + +## Function: generateWAMessage + +**Source:** https://baileys.wiki/docs/api/functions/generateWAMessage + +On this page + +**generateWAMessage**(`jid`, `content`, `options`): `Promise`<`WAMessage`> + +Defined in: src/Utils/messages.ts:707 + +## Parameters​ + +### jid​ + +`string` + +### content​ + +`AnyMessageContent` + +### options​ + +`MessageGenerationOptions` + +## Returns​ + +`Promise`<`WAMessage`> + +- Parameters +jid +- content +- options + +- Returns + + +--- + +## Function: generateWAMessageContent + +**Source:** https://baileys.wiki/docs/api/functions/generateWAMessageContent + +On this page + +**generateWAMessageContent**(`message`, `options`): `Promise`<`Message`> + +Defined in: src/Utils/messages.ts:369 + +## Parameters​ + +### message​ + +`AnyMessageContent` + +### options​ + +`MessageContentGenerationOptions` + +## Returns​ + +`Promise`<`Message`> + +- Parameters +message +- options + +- Returns + + +--- + +## Function: generateWAMessageFromContent + +**Source:** https://baileys.wiki/docs/api/functions/generateWAMessageFromContent + +On this page + +**generateWAMessageFromContent**(`jid`, `message`, `options`): `WAMessage` + +Defined in: src/Utils/messages.ts:623 + +## Parameters​ + +### jid​ + +`string` + +### message​ + +`IMessage` + +### options​ + +`MessageGenerationOptionsFromContent` + +## Returns​ + +`WAMessage` + +- Parameters +jid +- message +- options + +- Returns + + +--- + +## Function: extractMessageContent + +**Source:** https://baileys.wiki/docs/api/functions/extractMessageContent + +On this page + +**extractMessageContent**(`content`): `undefined` | `IMessage` + +Defined in: src/Utils/messages.ts:762 + +Extract the true message content from a message +Eg. extracts the inner message from a disappearing message/view once message + +## Parameters​ + +### content​ + +`undefined` | `null` | `IMessage` + +## Returns​ + +`undefined` | `IMessage` + +- Parameters +content + +- Returns + + +--- + +## Function: getContentType + +**Source:** https://baileys.wiki/docs/api/functions/getContentType + +On this page + +**getContentType**(`content`): `undefined` | keyof IMessage + +Defined in: src/Utils/messages.ts:715 + +Get the key to access the true type of content + +## Parameters​ + +### content​ + +`undefined` | `IMessage` + +## Returns​ + +`undefined` | keyof IMessage + +- Parameters +content + +- Returns + + +--- + +## Function: normalizeMessageContent + +**Source:** https://baileys.wiki/docs/api/functions/normalizeMessageContent + +On this page + +**normalizeMessageContent**(`content`): `undefined` | `IMessage` + +Defined in: src/Utils/messages.ts:729 + +Normalizes ephemeral, view once messages to regular message content +Eg. image messages in ephemeral messages, in view once messages etc. + +## Parameters​ + +### content​ + +`undefined` | `null` | `IMessage` + +## Returns​ + +`undefined` | `IMessage` + +- Parameters +content + +- Returns + + +--- + +## Function: downloadMediaMessage + +**Source:** https://baileys.wiki/docs/api/functions/downloadMediaMessage + +On this page + +**downloadMediaMessage**<`Type`>(`message`, `type`, `options`, `ctx`?): `Promise`<`Type` *extends* `"buffer"` ? `Buffer`<`ArrayBufferLike`> : `Transform`> + +Defined in: src/Utils/messages.ts:985 + +Downloads the given message. Throws an error if it's not a media message + +## Type Parameters​ + +• **Type** *extends* `"buffer"` | `"stream"` + +## Parameters​ + +### message​ + +`WAMessage` + +### type​ + +`Type` + +### options​ + +`MediaDownloadOptions` + +### ctx?​ + +`DownloadMediaMessageContext` + +## Returns​ + +`Promise`<`Type` *extends* `"buffer"` ? `Buffer`<`ArrayBufferLike`> : `Transform`> + +- Type Parameters +- Parameters +message +- type +- options +- ctx? + +- Returns + + +--- + +## Function: downloadContentFromMessage + +**Source:** https://baileys.wiki/docs/api/functions/downloadContentFromMessage + +On this page + +**downloadContentFromMessage**(`__namedParameters`, `type`, `opts`): `Promise`<`Transform`> + +Defined in: src/Utils/messages-media.ts:506 + +## Parameters​ + +### __namedParameters​ + +`DownloadableMessage` + +### type​ + +`"ppic"` | `"product"` | `"image"` | `"video"` | `"sticker"` | `"thumbnail-document"` | `"audio"` | `"thumbnail-image"` | `"biz-cover-photo"` | `"thumbnail-video"` | `"thumbnail-link"` | `"gif"` | `"md-app-state"` | `"md-msg-hist"` | `"document"` | `"ptt"` | `"product-catalog-image"` | `"payment-bg-image"` | `"ptv"` + +### opts​ + +`MediaDownloadOptions` = `{}` + +## Returns​ + +`Promise`<`Transform`> + +- Parameters +__namedParameters +- type +- opts + +- Returns + + +--- + +## Function: prepareWAMessageMedia + +**Source:** https://baileys.wiki/docs/api/functions/prepareWAMessageMedia + +On this page + +**prepareWAMessageMedia**(`message`, `options`): `Promise`<`Message`> + +Defined in: src/Utils/messages.ts:116 + +## Parameters​ + +### message​ + +`AnyMediaMessageContent` + +### options​ + +`MessageContentGenerationOptions` + +## Returns​ + +`Promise`<`Message`> + +- Parameters +message +- options + +- Returns + + +--- + +## Function: extractImageThumb + +**Source:** https://baileys.wiki/docs/api/functions/extractImageThumb + +On this page + +**extractImageThumb**(`bufferOrFilePath`, `width`): `Promise`<{ `buffer`: `any`; `original`: { `height`: `any`; `width`: `any`; }; }> + +Defined in: src/Utils/messages-media.ts:134 + +## Parameters​ + +### bufferOrFilePath​ + +`string` | `Buffer`<`ArrayBufferLike`> | `Readable` + +### width​ + +`number` = `32` + +## Returns​ + +`Promise`<{ `buffer`: `any`; `original`: { `height`: `any`; `width`: `any`; }; }> + +- Parameters +bufferOrFilePath +- width + +- Returns + + +--- + +## Function: generateThumbnail + +**Source:** https://baileys.wiki/docs/api/functions/generateThumbnail + +On this page + +**generateThumbnail**(`file`, `mediaType`, `options`): `Promise`<{ `originalImageDimensions`: `undefined` | { `height`: `number`; `width`: `number`; }; `thumbnail`: `undefined` | `string`; }> + +Defined in: src/Utils/messages-media.ts:327 + +generates a thumbnail for a given media, if required + +## Parameters​ + +### file​ + +`string` + +### mediaType​ + +`"image"` | `"video"` + +### options​ + +#### logger?​ + +`ILogger` + +## Returns​ + +`Promise`<{ `originalImageDimensions`: `undefined` | { `height`: `number`; `width`: `number`; }; `thumbnail`: `undefined` | `string`; }> + +- Parameters +file +- mediaType +- options + +- Returns + + +--- + +## Function: generateProfilePicture + +**Source:** https://baileys.wiki/docs/api/functions/generateProfilePicture + +On this page + +**generateProfilePicture**(`mediaUpload`, `dimensions`?): `Promise`<{ `img`: `Buffer`<`ArrayBufferLike`>; }> + +Defined in: src/Utils/messages-media.ts:175 + +## Parameters​ + +### mediaUpload​ + +`WAMediaUpload` + +### dimensions?​ + +#### height​ + +`number` + +#### width​ + +`number` + +## Returns​ + +`Promise`<{ `img`: `Buffer`<`ArrayBufferLike`>; }> + +- Parameters +mediaUpload +- dimensions? + +- Returns + + +--- + +## Function: getMediaKeys + +**Source:** https://baileys.wiki/docs/api/functions/getMediaKeys + +On this page + +**getMediaKeys**(`buffer`, `mediaType`): `Promise`<`MediaDecryptionKeyInfo`> + +Defined in: src/Utils/messages-media.ts:95 + +generates all the keys required to encrypt/decrypt & sign a media message + +## Parameters​ + +### buffer​ + +`undefined` | `null` | `string` | `Uint8Array`<`ArrayBufferLike`> + +### mediaType​ + +`"ppic"` | `"product"` | `"image"` | `"video"` | `"sticker"` | `"thumbnail-document"` | `"audio"` | `"thumbnail-image"` | `"biz-cover-photo"` | `"thumbnail-video"` | `"thumbnail-link"` | `"gif"` | `"md-app-state"` | `"md-msg-hist"` | `"document"` | `"ptt"` | `"product-catalog-image"` | `"payment-bg-image"` | `"ptv"` + +## Returns​ + +`Promise`<`MediaDecryptionKeyInfo`> + +- Parameters +buffer +- mediaType + +- Returns + + +--- + +## Function: encryptedStream + +**Source:** https://baileys.wiki/docs/api/functions/encryptedStream + +On this page + +**encryptedStream**(`media`, `mediaType`, `__namedParameters`): `Promise`<{ `encFilePath`: `string`; `fileEncSha256`: `Buffer`<`ArrayBufferLike`>; `fileLength`: `number`; `fileSha256`: `Buffer`<`ArrayBufferLike`>; `mac`: `Buffer`<`ArrayBuffer`>; `mediaKey`: `Buffer`<`ArrayBufferLike`>; `originalFilePath`: `undefined` | `string`; }> + +Defined in: src/Utils/messages-media.ts:384 + +## Parameters​ + +### media​ + +`WAMediaUpload` + +### mediaType​ + +`"ppic"` | `"product"` | `"image"` | `"video"` | `"sticker"` | `"thumbnail-document"` | `"audio"` | `"thumbnail-image"` | `"biz-cover-photo"` | `"thumbnail-video"` | `"thumbnail-link"` | `"gif"` | `"md-app-state"` | `"md-msg-hist"` | `"document"` | `"ptt"` | `"product-catalog-image"` | `"payment-bg-image"` | `"ptv"` + +### __namedParameters​ + +`EncryptedStreamOptions` = `{}` + +## Returns​ + +`Promise`<{ `encFilePath`: `string`; `fileEncSha256`: `Buffer`<`ArrayBufferLike`>; `fileLength`: `number`; `fileSha256`: `Buffer`<`ArrayBufferLike`>; `mac`: `Buffer`<`ArrayBuffer`>; `mediaKey`: `Buffer`<`ArrayBufferLike`>; `originalFilePath`: `undefined` | `string`; }> + +- Parameters +media +- mediaType +- __namedParameters + +- Returns + + +--- + +## Function: jidDecode + +**Source:** https://baileys.wiki/docs/api/functions/jidDecode + +On this page + +**jidDecode**(`jid`): `undefined` | `FullJid` + +Defined in: src/WABinary/jid-utils.ts:55 + +## Parameters​ + +### jid​ + +`undefined` | `string` + +## Returns​ + +`undefined` | `FullJid` + +- Parameters +jid + +- Returns + + +--- + +## Function: jidEncode + +**Source:** https://baileys.wiki/docs/api/functions/jidEncode + +On this page + +**jidEncode**(`user`, `server`, `device`?, `agent`?): `string` + +Defined in: src/WABinary/jid-utils.ts:51 + +## Parameters​ + +### user​ + +`null` | `string` | `number` + +### server​ + +`JidServer` + +### device?​ + +`number` + +### agent?​ + +`number` + +## Returns​ + +`string` + +- Parameters +user +- server +- device? +- agent? + +- Returns + + +--- + +## Function: jidNormalizedUser + +**Source:** https://baileys.wiki/docs/api/functions/jidNormalizedUser + +On this page + +**jidNormalizedUser**(`jid`): `string` + +Defined in: src/WABinary/jid-utils.ts:113 + +## Parameters​ + +### jid​ + +`undefined` | `string` + +## Returns​ + +`string` + +- Parameters +jid + +- Returns + + +--- + +## Function: isJidGroup + +**Source:** https://baileys.wiki/docs/api/functions/isJidGroup + +On this page + +**isJidGroup**(`jid`): `undefined` | `boolean` + +Defined in: src/WABinary/jid-utils.ts:99 + +is the jid a group + +## Parameters​ + +### jid​ + +`undefined` | `string` + +## Returns​ + +`undefined` | `boolean` + +- Parameters +jid + +- Returns + + +--- + +## Function: isJidBroadcast + +**Source:** https://baileys.wiki/docs/api/functions/isJidBroadcast + +On this page + +**isJidBroadcast**(`jid`): `undefined` | `boolean` + +Defined in: src/WABinary/jid-utils.ts:97 + +is the jid a broadcast + +## Parameters​ + +### jid​ + +`undefined` | `string` + +## Returns​ + +`undefined` | `boolean` + +- Parameters +jid + +- Returns + + +--- + +## Function: isJidStatusBroadcast + +**Source:** https://baileys.wiki/docs/api/functions/isJidStatusBroadcast + +On this page + +**isJidStatusBroadcast**(`jid`): `jid is "status@broadcast"` + +Defined in: src/WABinary/jid-utils.ts:101 + +is the jid the status broadcast + +## Parameters​ + +### jid​ + +`string` + +## Returns​ + +`jid is "status@broadcast"` + +- Parameters +jid + +- Returns + + +--- + +## Function: areJidsSameUser + +**Source:** https://baileys.wiki/docs/api/functions/areJidsSameUser + +On this page + +**areJidsSameUser**(`jid1`, `jid2`): `boolean` + +Defined in: src/WABinary/jid-utils.ts:88 + +is the jid a user + +## Parameters​ + +### jid1​ + +`undefined` | `string` + +### jid2​ + +`undefined` | `string` + +## Returns​ + +`boolean` + +- Parameters +jid1 +- jid2 + +- Returns + + +--- + +## Function: isLidUser + +**Source:** https://baileys.wiki/docs/api/functions/isLidUser + +On this page + +**isLidUser**(`jid`): `undefined` | `boolean` + +Defined in: src/WABinary/jid-utils.ts:95 + +is the jid a LID + +## Parameters​ + +### jid​ + +`undefined` | `string` + +## Returns​ + +`undefined` | `boolean` + +- Parameters +jid + +- Returns + + +--- + +## Function: downloadAndProcessHistorySyncNotification + +**Source:** https://baileys.wiki/docs/api/functions/downloadAndProcessHistorySyncNotification + +On this page + +**downloadAndProcessHistorySyncNotification**(`msg`, `options`): `Promise`<{ `chats`: `Chat`[]; `contacts`: `Contact`[]; `messages`: `WAMessage`[]; `progress`: `undefined` | `null` | `number`; `syncType`: `undefined` | `null` | `HistorySyncType`; }> + +Defined in: src/Utils/history.ts:95 + +## Parameters​ + +### msg​ + +`IHistorySyncNotification` + +### options​ + +`RequestInit` + +## Returns​ + +`Promise`<{ `chats`: `Chat`[]; `contacts`: `Contact`[]; `messages`: `WAMessage`[]; `progress`: `undefined` | `null` | `number`; `syncType`: `undefined` | `null` | `HistorySyncType`; }> + +- Parameters +msg +- options + +- Returns + + +--- + +## Function: processHistoryMessage + +**Source:** https://baileys.wiki/docs/api/functions/processHistoryMessage + +On this page + +**processHistoryMessage**(`item`): `object` + +Defined in: src/Utils/history.ts:28 + +## Parameters​ + +### item​ + +`IHistorySync` + +## Returns​ + +`object` + +### chats​ + +**chats**: `Chat`[] + +### contacts​ + +**contacts**: `Contact`[] + +### messages​ + +**messages**: `WAMessage`[] + +### progress​ + +**progress**: `undefined` | `null` | `number` = `item.progress` + +### syncType​ + +**syncType**: `undefined` | `null` | `HistorySyncType` = `item.syncType` + +- Parameters +item + +- Returns +chats +- contacts +- messages +- progress +- syncType + + +--- + +## Function: getHistoryMsg + +**Source:** https://baileys.wiki/docs/api/functions/getHistoryMsg + +On this page + +**getHistoryMsg**(`message`): `IHistorySyncNotification` + +Defined in: src/Utils/history.ts:109 + +## Parameters​ + +### message​ + +`IMessage` + +## Returns​ + +`IHistorySyncNotification` + +- Parameters +message + +- Returns + + +--- + +## Function: makeWASocket + +**Source:** https://baileys.wiki/docs/api/functions/makeWASocket + +On this page + +**makeWASocket**(`config`): `object` + +Defined in: src/Socket/index.ts:6 + +## Parameters​ + +### config​ + +`UserFacingSocketConfig` + +## Returns​ + +`object` + +### addChatLabel()​ + +**addChatLabel**: (`jid`, `labelId`) => `Promise`<`void`> + +Adds label for the chats + +#### Parameters​ + +jid​ + +`string` + +labelId​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### addLabel()​ + +**addLabel**: (`jid`, `labels`) => `Promise`<`void`> + +Adds label + +#### Parameters​ + +jid​ + +`string` + +labels​ + +`LabelActionBody` + +#### Returns​ + +`Promise`<`void`> + +### addMessageLabel()​ + +**addMessageLabel**: (`jid`, `messageId`, `labelId`) => `Promise`<`void`> + +Adds label for the message + +#### Parameters​ + +jid​ + +`string` + +messageId​ + +`string` + +labelId​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### addOrEditContact()​ + +**addOrEditContact**: (`jid`, `contact`) => `Promise`<`void`> + +Add or Edit Contact + +#### Parameters​ + +jid​ + +`string` + +contact​ + +`IContactAction` + +#### Returns​ + +`Promise`<`void`> + +### addOrEditQuickReply()​ + +**addOrEditQuickReply**: (`quickReply`) => `Promise`<`void`> + +Add or Edit Quick Reply + +#### Parameters​ + +quickReply​ + +`QuickReplyAction` + +#### Returns​ + +`Promise`<`void`> + +### appPatch()​ + +**appPatch**: (`patchCreate`) => `Promise`<`void`> + +#### Parameters​ + +patchCreate​ + +`WAPatchCreate` + +#### Returns​ + +`Promise`<`void`> + +### assertSessions()​ + +**assertSessions**: (`jids`, `force`?) => `Promise`<`boolean`> + +#### Parameters​ + +jids​ + +`string`[] + +force?​ + +`boolean` + +#### Returns​ + +`Promise`<`boolean`> + +### authState​ + +**authState**: `object` + +#### authState.creds​ + +**creds**: `AuthenticationCreds` + +#### authState.keys​ + +**keys**: `SignalKeyStoreWithTransaction` + +### chatModify()​ + +**chatModify**: (`mod`, `jid`) => `Promise`<`void`> + +modify a chat -- mark unread, read etc. +lastMessages must be sorted in reverse chronologically +requires the last messages till the last message received; required for archive & unread + +#### Parameters​ + +mod​ + +`ChatModification` + +jid​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### cleanDirtyBits()​ + +**cleanDirtyBits**: (`type`, `fromTimestamp`?) => `Promise`<`void`> + +#### Parameters​ + +type​ + +`"account_sync"` | `"groups"` + +fromTimestamp?​ + +`string` | `number` + +#### Returns​ + +`Promise`<`void`> + +### communityAcceptInvite()​ + +**communityAcceptInvite**: (`code`) => `Promise`<`undefined` | `string`> + +#### Parameters​ + +code​ + +`string` + +#### Returns​ + +`Promise`<`undefined` | `string`> + +### communityAcceptInviteV4()​ + +**communityAcceptInviteV4**: (...`args`) => `Promise`<`any`> + +accept a CommunityInviteMessage + +#### Parameters​ + +args​ + +...[`string` | `WAMessageKey`, `IGroupInviteMessage`] + +#### Returns​ + +`Promise`<`any`> + +### communityCreate()​ + +**communityCreate**: (`subject`, `body`) => `Promise`<`null` | `GroupMetadata`> + +#### Parameters​ + +subject​ + +`string` + +body​ + +`string` + +#### Returns​ + +`Promise`<`null` | `GroupMetadata`> + +### communityCreateGroup()​ + +**communityCreateGroup**: (`subject`, `participants`, `parentCommunityJid`) => `Promise`<`null` | `GroupMetadata`> + +#### Parameters​ + +subject​ + +`string` + +participants​ + +`string`[] + +parentCommunityJid​ + +`string` + +#### Returns​ + +`Promise`<`null` | `GroupMetadata`> + +### communityFetchAllParticipating()​ + +**communityFetchAllParticipating**: () => `Promise`<{}> + +#### Returns​ + +`Promise`<{}> + +### communityFetchLinkedGroups()​ + +**communityFetchLinkedGroups**: (`jid`) => `Promise`<{ `communityJid`: `string`; `isCommunity`: `boolean`; `linkedGroups`: `object`[]; }> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<{ `communityJid`: `string`; `isCommunity`: `boolean`; `linkedGroups`: `object`[]; }> + +### communityGetInviteInfo()​ + +**communityGetInviteInfo**: (`code`) => `Promise`<`GroupMetadata`> + +#### Parameters​ + +code​ + +`string` + +#### Returns​ + +`Promise`<`GroupMetadata`> + +### communityInviteCode()​ + +**communityInviteCode**: (`jid`) => `Promise`<`undefined` | `string`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`undefined` | `string`> + +### communityJoinApprovalMode()​ + +**communityJoinApprovalMode**: (`jid`, `mode`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +mode​ + +`"on"` | `"off"` + +#### Returns​ + +`Promise`<`void`> + +### communityLeave()​ + +**communityLeave**: (`id`) => `Promise`<`void`> + +#### Parameters​ + +id​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### communityLinkGroup()​ + +**communityLinkGroup**: (`groupJid`, `parentCommunityJid`) => `Promise`<`void`> + +#### Parameters​ + +groupJid​ + +`string` + +parentCommunityJid​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### communityMemberAddMode()​ + +**communityMemberAddMode**: (`jid`, `mode`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +mode​ + +`"all_member_add"` | `"admin_add"` + +#### Returns​ + +`Promise`<`void`> + +### communityMetadata()​ + +**communityMetadata**: (`jid`) => `Promise`<`GroupMetadata`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`GroupMetadata`> + +### communityParticipantsUpdate()​ + +**communityParticipantsUpdate**: (`jid`, `participants`, `action`) => `Promise`<`object`[]> + +#### Parameters​ + +jid​ + +`string` + +participants​ + +`string`[] + +action​ + +`ParticipantAction` + +#### Returns​ + +`Promise`<`object`[]> + +### communityRequestParticipantsList()​ + +**communityRequestParticipantsList**: (`jid`) => `Promise`<`object`[]> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`object`[]> + +### communityRequestParticipantsUpdate()​ + +**communityRequestParticipantsUpdate**: (`jid`, `participants`, `action`) => `Promise`<`object`[]> + +#### Parameters​ + +jid​ + +`string` + +participants​ + +`string`[] + +action​ + +`"reject"` | `"approve"` + +#### Returns​ + +`Promise`<`object`[]> + +### communityRevokeInvite()​ + +**communityRevokeInvite**: (`jid`) => `Promise`<`undefined` | `string`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`undefined` | `string`> + +### communityRevokeInviteV4()​ + +**communityRevokeInviteV4**: (`communityJid`, `invitedJid`) => `Promise`<`boolean`> + +revoke a v4 invite for someone + +#### Parameters​ + +communityJid​ + +`string` + +community jid + +invitedJid​ + +`string` + +jid of person you invited + +#### Returns​ + +`Promise`<`boolean`> + +true if successful + +### communitySettingUpdate()​ + +**communitySettingUpdate**: (`jid`, `setting`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +setting​ + +`"announcement"` | `"locked"` | `"not_announcement"` | `"unlocked"` + +#### Returns​ + +`Promise`<`void`> + +### communityToggleEphemeral()​ + +**communityToggleEphemeral**: (`jid`, `ephemeralExpiration`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +ephemeralExpiration​ + +`number` + +#### Returns​ + +`Promise`<`void`> + +### communityUnlinkGroup()​ + +**communityUnlinkGroup**: (`groupJid`, `parentCommunityJid`) => `Promise`<`void`> + +#### Parameters​ + +groupJid​ + +`string` + +parentCommunityJid​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### communityUpdateDescription()​ + +**communityUpdateDescription**: (`jid`, `description`?) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +description?​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### communityUpdateSubject()​ + +**communityUpdateSubject**: (`jid`, `subject`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +subject​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### createCallLink()​ + +**createCallLink**: (`type`, `event`?, `timeoutMs`?) => `Promise`<`undefined` | `string`> + +#### Parameters​ + +type​ + +`"video"` | `"audio"` + +event?​ +startTime​ + +`number` + +timeoutMs?​ + +`number` + +#### Returns​ + +`Promise`<`undefined` | `string`> + +### createParticipantNodes()​ + +**createParticipantNodes**: (`recipientJids`, `message`, `extraAttrs`?, `dsmMessage`?) => `Promise`<{ `nodes`: `BinaryNode`[]; `shouldIncludeDeviceIdentity`: `boolean`; }> + +#### Parameters​ + +recipientJids​ + +`string`[] + +message​ + +`IMessage` + +extraAttrs?​ +dsmMessage?​ + +`IMessage` + +#### Returns​ + +`Promise`<{ `nodes`: `BinaryNode`[]; `shouldIncludeDeviceIdentity`: `boolean`; }> + +### digestKeyBundle()​ + +**digestKeyBundle**: () => `Promise`<`void`> + +#### Returns​ + +`Promise`<`void`> + +### end()​ + +**end**: (`error`) => `void` + +#### Parameters​ + +error​ + +`undefined` | `Error` + +#### Returns​ + +`void` + +### ev​ + +**ev**: `BaileysBufferableEventEmitter` + +### executeUSyncQuery()​ + +**executeUSyncQuery**: (`usyncQuery`) => `Promise`<`undefined` | `USyncQueryResult`> + +#### Parameters​ + +usyncQuery​ + +`USyncQuery` + +#### Returns​ + +`Promise`<`undefined` | `USyncQueryResult`> + +### fetchBlocklist()​ + +**fetchBlocklist**: () => `Promise`<(`undefined` | `string`)[]> + +#### Returns​ + +`Promise`<(`undefined` | `string`)[]> + +### fetchDisappearingDuration()​ + +**fetchDisappearingDuration**: (...`jids`) => `Promise`<`undefined` | `USyncQueryResultList`[]> + +#### Parameters​ + +jids​ + +...`string`[] + +#### Returns​ + +`Promise`<`undefined` | `USyncQueryResultList`[]> + +### fetchMessageHistory()​ + +**fetchMessageHistory**: (`count`, `oldestMsgKey`, `oldestMsgTimestamp`) => `Promise`<`string`> + +#### Parameters​ + +count​ + +`number` + +oldestMsgKey​ + +`WAMessageKey` + +oldestMsgTimestamp​ + +`number` | `Long` + +#### Returns​ + +`Promise`<`string`> + +### fetchPrivacySettings()​ + +**fetchPrivacySettings**: (`force`) => `Promise`<{}> + +#### Parameters​ + +force​ + +`boolean` = `false` + +#### Returns​ + +`Promise`<{}> + +### fetchStatus()​ + +**fetchStatus**: (...`jids`) => `Promise`<`undefined` | `USyncQueryResultList`[]> + +#### Parameters​ + +jids​ + +...`string`[] + +#### Returns​ + +`Promise`<`undefined` | `USyncQueryResultList`[]> + +### generateMessageTag()​ + +**generateMessageTag**: () => `string` + +#### Returns​ + +`string` + +### getBotListV2()​ + +**getBotListV2**: () => `Promise`<`BotListInfo`[]> + +#### Returns​ + +`Promise`<`BotListInfo`[]> + +### getBusinessProfile()​ + +**getBusinessProfile**: (`jid`) => `Promise`<`void` | `WABusinessProfile`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`void` | `WABusinessProfile`> + +### getCatalog()​ + +**getCatalog**: (`__namedParameters`) => `Promise`<{ `nextPageCursor`: `undefined` | `string`; `products`: `Product`[]; }> + +#### Parameters​ + +__namedParameters​ + +`GetCatalogOptions` + +#### Returns​ + +`Promise`<{ `nextPageCursor`: `undefined` | `string`; `products`: `Product`[]; }> + +### getCollections()​ + +**getCollections**: (`jid`?, `limit`) => `Promise`<{ `collections`: `CatalogCollection`[]; }> + +#### Parameters​ + +jid?​ + +`string` + +limit?​ + +`number` = `51` + +#### Returns​ + +`Promise`<{ `collections`: `CatalogCollection`[]; }> + +### getOrderDetails()​ + +**getOrderDetails**: (`orderId`, `tokenBase64`) => `Promise`<`OrderDetails`> + +#### Parameters​ + +orderId​ + +`string` + +tokenBase64​ + +`string` + +#### Returns​ + +`Promise`<`OrderDetails`> + +### getPrivacyTokens()​ + +**getPrivacyTokens**: (`jids`) => `Promise`<`any`> + +#### Parameters​ + +jids​ + +`string`[] + +#### Returns​ + +`Promise`<`any`> + +### getUSyncDevices()​ + +**getUSyncDevices**: (`jids`, `useCache`, `ignoreZeroDevices`) => `Promise`<`DeviceWithJid`[]> + +Fetch all the devices we've to send a message to + +#### Parameters​ + +jids​ + +`string`[] + +useCache​ + +`boolean` + +ignoreZeroDevices​ + +`boolean` + +#### Returns​ + +`Promise`<`DeviceWithJid`[]> + +### groupAcceptInvite()​ + +**groupAcceptInvite**: (`code`) => `Promise`<`undefined` | `string`> + +#### Parameters​ + +code​ + +`string` + +#### Returns​ + +`Promise`<`undefined` | `string`> + +### groupAcceptInviteV4()​ + +**groupAcceptInviteV4**: (...`args`) => `Promise`<`any`> + +accept a GroupInviteMessage + +#### Parameters​ + +args​ + +...[`string` | `WAMessageKey`, `IGroupInviteMessage`] + +#### Returns​ + +`Promise`<`any`> + +### groupCreate()​ + +**groupCreate**: (`subject`, `participants`) => `Promise`<`GroupMetadata`> + +#### Parameters​ + +subject​ + +`string` + +participants​ + +`string`[] + +#### Returns​ + +`Promise`<`GroupMetadata`> + +### groupFetchAllParticipating()​ + +**groupFetchAllParticipating**: () => `Promise`<{}> + +#### Returns​ + +`Promise`<{}> + +### groupGetInviteInfo()​ + +**groupGetInviteInfo**: (`code`) => `Promise`<`GroupMetadata`> + +#### Parameters​ + +code​ + +`string` + +#### Returns​ + +`Promise`<`GroupMetadata`> + +### groupInviteCode()​ + +**groupInviteCode**: (`jid`) => `Promise`<`undefined` | `string`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`undefined` | `string`> + +### groupJoinApprovalMode()​ + +**groupJoinApprovalMode**: (`jid`, `mode`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +mode​ + +`"on"` | `"off"` + +#### Returns​ + +`Promise`<`void`> + +### groupLeave()​ + +**groupLeave**: (`id`) => `Promise`<`void`> + +#### Parameters​ + +id​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### groupMemberAddMode()​ + +**groupMemberAddMode**: (`jid`, `mode`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +mode​ + +`"all_member_add"` | `"admin_add"` + +#### Returns​ + +`Promise`<`void`> + +### groupMetadata()​ + +**groupMetadata**: (`jid`) => `Promise`<`GroupMetadata`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`GroupMetadata`> + +### groupParticipantsUpdate()​ + +**groupParticipantsUpdate**: (`jid`, `participants`, `action`) => `Promise`<`object`[]> + +#### Parameters​ + +jid​ + +`string` + +participants​ + +`string`[] + +action​ + +`ParticipantAction` + +#### Returns​ + +`Promise`<`object`[]> + +### groupRequestParticipantsList()​ + +**groupRequestParticipantsList**: (`jid`) => `Promise`<`object`[]> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`object`[]> + +### groupRequestParticipantsUpdate()​ + +**groupRequestParticipantsUpdate**: (`jid`, `participants`, `action`) => `Promise`<`object`[]> + +#### Parameters​ + +jid​ + +`string` + +participants​ + +`string`[] + +action​ + +`"reject"` | `"approve"` + +#### Returns​ + +`Promise`<`object`[]> + +### groupRevokeInvite()​ + +**groupRevokeInvite**: (`jid`) => `Promise`<`undefined` | `string`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`undefined` | `string`> + +### groupRevokeInviteV4()​ + +**groupRevokeInviteV4**: (`groupJid`, `invitedJid`) => `Promise`<`boolean`> + +revoke a v4 invite for someone + +#### Parameters​ + +groupJid​ + +`string` + +group jid + +invitedJid​ + +`string` + +jid of person you invited + +#### Returns​ + +`Promise`<`boolean`> + +true if successful + +### groupSettingUpdate()​ + +**groupSettingUpdate**: (`jid`, `setting`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +setting​ + +`"announcement"` | `"locked"` | `"not_announcement"` | `"unlocked"` + +#### Returns​ + +`Promise`<`void`> + +### groupToggleEphemeral()​ + +**groupToggleEphemeral**: (`jid`, `ephemeralExpiration`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +ephemeralExpiration​ + +`number` + +#### Returns​ + +`Promise`<`void`> + +### groupUpdateDescription()​ + +**groupUpdateDescription**: (`jid`, `description`?) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +description?​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### groupUpdateSubject()​ + +**groupUpdateSubject**: (`jid`, `subject`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +subject​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### logger​ + +**logger**: `ILogger` = `config.logger` + +### logout()​ + +**logout**: (`msg`?) => `Promise`<`void`> + +logout & invalidate connection + +#### Parameters​ + +msg?​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### messageRetryManager​ + +**messageRetryManager**: `null` | `MessageRetryManager` + +### newsletterAdminCount()​ + +**newsletterAdminCount**: (`jid`) => `Promise`<`number`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`number`> + +### newsletterChangeOwner()​ + +**newsletterChangeOwner**: (`jid`, `newOwnerJid`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +newOwnerJid​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### newsletterCreate()​ + +**newsletterCreate**: (`name`, `description`?) => `Promise`<`NewsletterMetadata`> + +#### Parameters​ + +name​ + +`string` + +description?​ + +`string` + +#### Returns​ + +`Promise`<`NewsletterMetadata`> + +### newsletterDelete()​ + +**newsletterDelete**: (`jid`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### newsletterDemote()​ + +**newsletterDemote**: (`jid`, `userJid`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +userJid​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### newsletterFetchMessages()​ + +**newsletterFetchMessages**: (`jid`, `count`, `since`, `after`) => `Promise`<`any`> + +#### Parameters​ + +jid​ + +`string` + +count​ + +`number` + +since​ + +`number` + +after​ + +`number` + +#### Returns​ + +`Promise`<`any`> + +### newsletterFollow()​ + +**newsletterFollow**: (`jid`) => `Promise`<`unknown`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`unknown`> + +### newsletterMetadata()​ + +**newsletterMetadata**: (`type`, `key`) => `Promise`<`null` | `NewsletterMetadata`> + +#### Parameters​ + +type​ + +`"invite"` | `"jid"` + +key​ + +`string` + +#### Returns​ + +`Promise`<`null` | `NewsletterMetadata`> + +### newsletterMute()​ + +**newsletterMute**: (`jid`) => `Promise`<`unknown`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`unknown`> + +### newsletterReactMessage()​ + +**newsletterReactMessage**: (`jid`, `serverId`, `reaction`?) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +serverId​ + +`string` + +reaction?​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### newsletterRemovePicture()​ + +**newsletterRemovePicture**: (`jid`) => `Promise`<`unknown`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`unknown`> + +### newsletterSubscribers()​ + +**newsletterSubscribers**: (`jid`) => `Promise`<{ `subscribers`: `number`; }> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<{ `subscribers`: `number`; }> + +### newsletterUnfollow()​ + +**newsletterUnfollow**: (`jid`) => `Promise`<`unknown`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`unknown`> + +### newsletterUnmute()​ + +**newsletterUnmute**: (`jid`) => `Promise`<`unknown`> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`unknown`> + +### newsletterUpdate()​ + +**newsletterUpdate**: (`jid`, `updates`) => `Promise`<`unknown`> + +#### Parameters​ + +jid​ + +`string` + +updates​ + +`NewsletterUpdate` + +#### Returns​ + +`Promise`<`unknown`> + +### newsletterUpdateDescription()​ + +**newsletterUpdateDescription**: (`jid`, `description`) => `Promise`<`unknown`> + +#### Parameters​ + +jid​ + +`string` + +description​ + +`string` + +#### Returns​ + +`Promise`<`unknown`> + +### newsletterUpdateName()​ + +**newsletterUpdateName**: (`jid`, `name`) => `Promise`<`unknown`> + +#### Parameters​ + +jid​ + +`string` + +name​ + +`string` + +#### Returns​ + +`Promise`<`unknown`> + +### newsletterUpdatePicture()​ + +**newsletterUpdatePicture**: (`jid`, `content`) => `Promise`<`unknown`> + +#### Parameters​ + +jid​ + +`string` + +content​ + +`WAMediaUpload` + +#### Returns​ + +`Promise`<`unknown`> + +### onUnexpectedError()​ + +**onUnexpectedError**: (`err`, `msg`) => `void` + +log & process any unexpected errors + +#### Parameters​ + +err​ + +`Error` | `Boom`<`any`> + +msg​ + +`string` + +#### Returns​ + +`void` + +### onWhatsApp()​ + +**onWhatsApp**: (...`phoneNumber`) => `Promise`<`undefined` | `object`[]> + +#### Parameters​ + +phoneNumber​ + +...`string`[] + +#### Returns​ + +`Promise`<`undefined` | `object`[]> + +### presenceSubscribe()​ + +**presenceSubscribe**: (`toJid`, `tcToken`?) => `Promise`<`void`> + +#### Parameters​ + +toJid​ + +`string` + +the jid to subscribe to + +tcToken?​ + +`Buffer`<`ArrayBufferLike`> + +token for subscription, use if present + +#### Returns​ + +`Promise`<`void`> + +### processingMutex​ + +**processingMutex**: `object` + +#### processingMutex.mutex()​ + +Type Parameters​ + +• **T** + +Parameters​ +code​ + +() => `T` | `Promise`<`T`> + +Returns​ + +`Promise`<`T`> + +### productCreate()​ + +**productCreate**: (`create`) => `Promise`<`Product`> + +#### Parameters​ + +create​ + +`ProductCreate` + +#### Returns​ + +`Promise`<`Product`> + +### productDelete()​ + +**productDelete**: (`productIds`) => `Promise`<{ `deleted`: `number`; }> + +#### Parameters​ + +productIds​ + +`string`[] + +#### Returns​ + +`Promise`<{ `deleted`: `number`; }> + +### productUpdate()​ + +**productUpdate**: (`productId`, `update`) => `Promise`<`Product`> + +#### Parameters​ + +productId​ + +`string` + +update​ + +`ProductUpdate` + +#### Returns​ + +`Promise`<`Product`> + +### profilePictureUrl()​ + +**profilePictureUrl**: (`jid`, `type`, `timeoutMs`?) => `Promise`<`undefined` | `string`> + +fetch the profile picture of a user/group +type = "preview" for a low res picture +type = "image for the high res picture" + +#### Parameters​ + +jid​ + +`string` + +type​ + +`"image"` | `"preview"` + +timeoutMs?​ + +`number` + +#### Returns​ + +`Promise`<`undefined` | `string`> + +### query()​ + +**query**: (`node`, `timeoutMs`?) => `Promise`<`any`> + +send a query, and wait for its response. auto-generates message ID if not provided + +#### Parameters​ + +node​ + +`BinaryNode` + +timeoutMs?​ + +`number` + +#### Returns​ + +`Promise`<`any`> + +### readMessages()​ + +**readMessages**: (`keys`) => `Promise`<`void`> + +Bulk read messages. Keys can be from different chats & participants + +#### Parameters​ + +keys​ + +`WAMessageKey`[] + +#### Returns​ + +`Promise`<`void`> + +### refreshMediaConn()​ + +**refreshMediaConn**: (`forceGet`) => `Promise`<`MediaConnInfo`> + +#### Parameters​ + +forceGet​ + +`boolean` = `false` + +#### Returns​ + +`Promise`<`MediaConnInfo`> + +### rejectCall()​ + +**rejectCall**: (`callId`, `callFrom`) => `Promise`<`void`> + +#### Parameters​ + +callId​ + +`string` + +callFrom​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### relayMessage()​ + +**relayMessage**: (`jid`, `message`, `__namedParameters`) => `Promise`<`string`> + +#### Parameters​ + +jid​ + +`string` + +message​ + +`IMessage` + +__namedParameters​ + +`MessageRelayOptions` + +#### Returns​ + +`Promise`<`string`> + +### removeChatLabel()​ + +**removeChatLabel**: (`jid`, `labelId`) => `Promise`<`void`> + +Removes label for the chat + +#### Parameters​ + +jid​ + +`string` + +labelId​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### removeContact()​ + +**removeContact**: (`jid`) => `Promise`<`void`> + +Remove Contact + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### removeCoverPhoto()​ + +**removeCoverPhoto**: (`id`) => `Promise`<`any`> + +#### Parameters​ + +id​ + +`string` + +#### Returns​ + +`Promise`<`any`> + +### removeMessageLabel()​ + +**removeMessageLabel**: (`jid`, `messageId`, `labelId`) => `Promise`<`void`> + +Removes label for the message + +#### Parameters​ + +jid​ + +`string` + +messageId​ + +`string` + +labelId​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### removeProfilePicture()​ + +**removeProfilePicture**: (`jid`) => `Promise`<`void`> + +remove the profile picture for yourself or a group + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### removeQuickReply()​ + +**removeQuickReply**: (`timestamp`) => `Promise`<`void`> + +Remove Quick Reply + +#### Parameters​ + +timestamp​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### requestPairingCode()​ + +**requestPairingCode**: (`phoneNumber`, `customPairingCode`?) => `Promise`<`string`> + +#### Parameters​ + +phoneNumber​ + +`string` + +customPairingCode?​ + +`string` + +#### Returns​ + +`Promise`<`string`> + +### requestPlaceholderResend()​ + +**requestPlaceholderResend**: (`messageKey`) => `Promise`<`undefined` | `string`> + +#### Parameters​ + +messageKey​ + +`WAMessageKey` + +#### Returns​ + +`Promise`<`undefined` | `string`> + +### resyncAppState()​ + +**resyncAppState**: (...`args`) => `Promise`<`void`> + +#### Parameters​ + +args​ + +...[readonly (`"critical_unblock_low"` | `"regular_high"` | `"regular_low"` | `"critical_block"` | `"regular"`)[], `boolean`] + +#### Returns​ + +`Promise`<`void`> + +### rotateSignedPreKey()​ + +**rotateSignedPreKey**: () => `Promise`<`void`> + +#### Returns​ + +`Promise`<`void`> + +### sendMessage()​ + +**sendMessage**: (`jid`, `content`, `options`) => `Promise`<`undefined` | `WAMessage`> + +#### Parameters​ + +jid​ + +`string` + +content​ + +`AnyMessageContent` + +options​ + +`MiscMessageGenerationOptions` = `{}` + +#### Returns​ + +`Promise`<`undefined` | `WAMessage`> + +### sendMessageAck()​ + +**sendMessageAck**: (`__namedParameters`, `errorCode`?) => `Promise`<`void`> + +#### Parameters​ + +__namedParameters​ + +`BinaryNode` + +errorCode?​ + +`number` + +#### Returns​ + +`Promise`<`void`> + +### sendNode()​ + +**sendNode**: (`frame`) => `Promise`<`void`> + +send a binary node + +#### Parameters​ + +frame​ + +`BinaryNode` + +#### Returns​ + +`Promise`<`void`> + +### sendPeerDataOperationMessage()​ + +**sendPeerDataOperationMessage**: (`pdoMessage`) => `Promise`<`string`> + +#### Parameters​ + +pdoMessage​ + +`IPeerDataOperationRequestMessage` + +#### Returns​ + +`Promise`<`string`> + +### sendPresenceUpdate()​ + +**sendPresenceUpdate**: (`type`, `toJid`?) => `Promise`<`void`> + +#### Parameters​ + +type​ + +`WAPresence` + +toJid?​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### sendRawMessage()​ + +**sendRawMessage**: (`data`) => `Promise`<`void`> + +send a raw buffer + +#### Parameters​ + +data​ + +`Uint8Array`<`ArrayBufferLike`> | `Buffer`<`ArrayBufferLike`> + +#### Returns​ + +`Promise`<`void`> + +### sendReceipt()​ + +**sendReceipt**: (`jid`, `participant`, `messageIds`, `type`) => `Promise`<`void`> + +generic send receipt function +used for receipts of phone call, read, delivery etc. + +#### Parameters​ + +jid​ + +`string` + +participant​ + +`undefined` | `string` + +messageIds​ + +`string`[] + +type​ + +`MessageReceiptType` + +#### Returns​ + +`Promise`<`void`> + +### sendReceipts()​ + +**sendReceipts**: (`keys`, `type`) => `Promise`<`void`> + +Correctly bulk send receipts to multiple chats, participants + +#### Parameters​ + +keys​ + +`WAMessageKey`[] + +type​ + +`MessageReceiptType` + +#### Returns​ + +`Promise`<`void`> + +### sendRetryRequest()​ + +**sendRetryRequest**: (`node`, `forceIncludeKeys`) => `Promise`<`void`> + +#### Parameters​ + +node​ + +`BinaryNode` + +forceIncludeKeys​ + +`boolean` = `false` + +#### Returns​ + +`Promise`<`void`> + +### sendWAMBuffer()​ + +**sendWAMBuffer**: (`wamBuffer`) => `Promise`<`any`> + +#### Parameters​ + +wamBuffer​ + +`Buffer` + +#### Returns​ + +`Promise`<`any`> + +### signalRepository​ + +**signalRepository**: `SignalRepositoryWithLIDStore` + +### star()​ + +**star**: (`jid`, `messages`, `star`) => `Promise`<`void`> + +Star or Unstar a message + +#### Parameters​ + +jid​ + +`string` + +messages​ + +`object`[] + +star​ + +`boolean` + +#### Returns​ + +`Promise`<`void`> + +### subscribeNewsletterUpdates()​ + +**subscribeNewsletterUpdates**: (`jid`) => `Promise`<`null` | { `duration`: `string`; }> + +#### Parameters​ + +jid​ + +`string` + +#### Returns​ + +`Promise`<`null` | { `duration`: `string`; }> + +### type​ + +**type**: `"md"` + +### updateBlockStatus()​ + +**updateBlockStatus**: (`jid`, `action`) => `Promise`<`void`> + +#### Parameters​ + +jid​ + +`string` + +action​ + +`"block"` | `"unblock"` + +#### Returns​ + +`Promise`<`void`> + +### updateBussinesProfile()​ + +**updateBussinesProfile**: (`args`) => `Promise`<`any`> + +#### Parameters​ + +args​ + +`UpdateBussinesProfileProps` + +#### Returns​ + +`Promise`<`any`> + +### updateCallPrivacy()​ + +**updateCallPrivacy**: (`value`) => `Promise`<`void`> + +#### Parameters​ + +value​ + +`WAPrivacyCallValue` + +#### Returns​ + +`Promise`<`void`> + +### updateCoverPhoto()​ + +**updateCoverPhoto**: (`photo`) => `Promise`<`number`> + +#### Parameters​ + +photo​ + +`WAMediaUpload` + +#### Returns​ + +`Promise`<`number`> + +### updateDefaultDisappearingMode()​ + +**updateDefaultDisappearingMode**: (`duration`) => `Promise`<`void`> + +#### Parameters​ + +duration​ + +`number` + +#### Returns​ + +`Promise`<`void`> + +### updateDisableLinkPreviewsPrivacy()​ + +**updateDisableLinkPreviewsPrivacy**: (`isPreviewsDisabled`) => `Promise`<`void`> + +Enable/Disable link preview privacy, not related to baileys link preview generation + +#### Parameters​ + +isPreviewsDisabled​ + +`boolean` + +#### Returns​ + +`Promise`<`void`> + +### updateGroupsAddPrivacy()​ + +**updateGroupsAddPrivacy**: (`value`) => `Promise`<`void`> + +#### Parameters​ + +value​ + +`WAPrivacyGroupAddValue` + +#### Returns​ + +`Promise`<`void`> + +### updateLastSeenPrivacy()​ + +**updateLastSeenPrivacy**: (`value`) => `Promise`<`void`> + +#### Parameters​ + +value​ + +`WAPrivacyValue` + +#### Returns​ + +`Promise`<`void`> + +### updateMediaMessage()​ + +**updateMediaMessage**: (`message`) => `Promise`<`WAMessage`> + +#### Parameters​ + +message​ + +`WAMessage` + +#### Returns​ + +`Promise`<`WAMessage`> + +### updateMessagesPrivacy()​ + +**updateMessagesPrivacy**: (`value`) => `Promise`<`void`> + +#### Parameters​ + +value​ + +`WAPrivacyMessagesValue` + +#### Returns​ + +`Promise`<`void`> + +### updateOnlinePrivacy()​ + +**updateOnlinePrivacy**: (`value`) => `Promise`<`void`> + +#### Parameters​ + +value​ + +`WAPrivacyOnlineValue` + +#### Returns​ + +`Promise`<`void`> + +### updateProfileName()​ + +**updateProfileName**: (`name`) => `Promise`<`void`> + +#### Parameters​ + +name​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### updateProfilePicture()​ + +**updateProfilePicture**: (`jid`, `content`, `dimensions`?) => `Promise`<`void`> + +update the profile picture for yourself or a group + +#### Parameters​ + +jid​ + +`string` + +content​ + +`WAMediaUpload` + +dimensions?​ +height​ + +`number` + +width​ + +`number` + +#### Returns​ + +`Promise`<`void`> + +### updateProfilePicturePrivacy()​ + +**updateProfilePicturePrivacy**: (`value`) => `Promise`<`void`> + +#### Parameters​ + +value​ + +`WAPrivacyValue` + +#### Returns​ + +`Promise`<`void`> + +### updateProfileStatus()​ + +**updateProfileStatus**: (`status`) => `Promise`<`void`> + +update the profile status for yourself + +#### Parameters​ + +status​ + +`string` + +#### Returns​ + +`Promise`<`void`> + +### updateReadReceiptsPrivacy()​ + +**updateReadReceiptsPrivacy**: (`value`) => `Promise`<`void`> + +#### Parameters​ + +value​ + +`WAReadReceiptsValue` + +#### Returns​ + +`Promise`<`void`> + +### updateStatusPrivacy()​ + +**updateStatusPrivacy**: (`value`) => `Promise`<`void`> + +#### Parameters​ + +value​ + +`WAPrivacyValue` + +#### Returns​ + +`Promise`<`void`> + +### uploadPreKeys()​ + +**uploadPreKeys**: (`count`, `retryCount`) => `Promise`<`void`> + +generates and uploads a set of pre-keys to the server + +#### Parameters​ + +count​ + +`number` = `MIN_PREKEY_COUNT` + +retryCount​ + +`number` = `0` + +#### Returns​ + +`Promise`<`void`> + +### uploadPreKeysToServerIfRequired()​ + +**uploadPreKeysToServerIfRequired**: () => `Promise`<`void`> + +#### Returns​ + +`Promise`<`void`> + +### upsertMessage()​ + +**upsertMessage**: (...`args`) => `Promise`<`void`> + +#### Parameters​ + +args​ + +...[`WAMessage`, `MessageUpsertType`] + +#### Returns​ + +`Promise`<`void`> + +### user​ + +**user**: `undefined` | `Contact` + +### waitForConnectionUpdate()​ + +**waitForConnectionUpdate**: (`check`, `timeoutMs`?) => `Promise`<`void`> + +Waits for the connection to WA to reach a state + +#### Parameters​ + +check​ + +(`u`) => `Promise`<`undefined` | `boolean`> + +timeoutMs?​ + +`number` + +#### Returns​ + +`Promise`<`void`> + +### waitForMessage()​ + +**waitForMessage**: <`T`>(`msgId`, `timeoutMs`) => `Promise`<`undefined` | `T`> + +Wait for a message with a certain tag to be received + +#### Type Parameters​ + +• **T** + +#### Parameters​ + +msgId​ + +`string` + +the message tag to await + +timeoutMs​ + +timeout after which the promise will reject + +`undefined` | `number` + +#### Returns​ + +`Promise`<`undefined` | `T`> + +### waitForSocketOpen()​ + +**waitForSocketOpen**: () => `Promise`<`void`> + +#### Returns​ + +`Promise`<`void`> + +### wamBuffer​ + +**wamBuffer**: `BinaryInfo` = `publicWAMBuffer` + +### waUploadToServer​ + +**waUploadToServer**: `WAMediaUploadFunction` + +### ws​ + +**ws**: `WebSocketClient` + +- Parameters +config + +- Returns +addChatLabel() +- addLabel() +- addMessageLabel() +- addOrEditContact() +- addOrEditQuickReply() +- appPatch() +- assertSessions() +- authState +- chatModify() +- cleanDirtyBits() +- communityAcceptInvite() +- communityAcceptInviteV4() +- communityCreate() +- communityCreateGroup() +- communityFetchAllParticipating() +- communityFetchLinkedGroups() +- communityGetInviteInfo() +- communityInviteCode() +- communityJoinApprovalMode() +- communityLeave() +- communityLinkGroup() +- communityMemberAddMode() +- communityMetadata() +- communityParticipantsUpdate() +- communityRequestParticipantsList() +- communityRequestParticipantsUpdate() +- communityRevokeInvite() +- communityRevokeInviteV4() +- communitySettingUpdate() +- communityToggleEphemeral() +- communityUnlinkGroup() +- communityUpdateDescription() +- communityUpdateSubject() +- createCallLink() +- createParticipantNodes() +- digestKeyBundle() +- end() +- ev +- executeUSyncQuery() +- fetchBlocklist() +- fetchDisappearingDuration() +- fetchMessageHistory() +- fetchPrivacySettings() +- fetchStatus() +- generateMessageTag() +- getBotListV2() +- getBusinessProfile() +- getCatalog() +- getCollections() +- getOrderDetails() +- getPrivacyTokens() +- getUSyncDevices() +- groupAcceptInvite() +- groupAcceptInviteV4() +- groupCreate() +- groupFetchAllParticipating() +- groupGetInviteInfo() +- groupInviteCode() +- groupJoinApprovalMode() +- groupLeave() +- groupMemberAddMode() +- groupMetadata() +- groupParticipantsUpdate() +- groupRequestParticipantsList() +- groupRequestParticipantsUpdate() +- groupRevokeInvite() +- groupRevokeInviteV4() +- groupSettingUpdate() +- groupToggleEphemeral() +- groupUpdateDescription() +- groupUpdateSubject() +- logger +- logout() +- messageRetryManager +- newsletterAdminCount() +- newsletterChangeOwner() +- newsletterCreate() +- newsletterDelete() +- newsletterDemote() +- newsletterFetchMessages() +- newsletterFollow() +- newsletterMetadata() +- newsletterMute() +- newsletterReactMessage() +- newsletterRemovePicture() +- newsletterSubscribers() +- newsletterUnfollow() +- newsletterUnmute() +- newsletterUpdate() +- newsletterUpdateDescription() +- newsletterUpdateName() +- newsletterUpdatePicture() +- onUnexpectedError() +- onWhatsApp() +- presenceSubscribe() +- processingMutex +- productCreate() +- productDelete() +- productUpdate() +- profilePictureUrl() +- query() +- readMessages() +- refreshMediaConn() +- rejectCall() +- relayMessage() +- removeChatLabel() +- removeContact() +- removeCoverPhoto() +- removeMessageLabel() +- removeProfilePicture() +- removeQuickReply() +- requestPairingCode() +- requestPlaceholderResend() +- resyncAppState() +- rotateSignedPreKey() +- sendMessage() +- sendMessageAck() +- sendNode() +- sendPeerDataOperationMessage() +- sendPresenceUpdate() +- sendRawMessage() +- sendReceipt() +- sendReceipts() +- sendRetryRequest() +- sendWAMBuffer() +- signalRepository +- star() +- subscribeNewsletterUpdates() +- type +- updateBlockStatus() +- updateBussinesProfile() +- updateCallPrivacy() +- updateCoverPhoto() +- updateDefaultDisappearingMode() +- updateDisableLinkPreviewsPrivacy() +- updateGroupsAddPrivacy() +- updateLastSeenPrivacy() +- updateMediaMessage() +- updateMessagesPrivacy() +- updateOnlinePrivacy() +- updateProfileName() +- updateProfilePicture() +- updateProfilePicturePrivacy() +- updateProfileStatus() +- updateReadReceiptsPrivacy() +- updateStatusPrivacy() +- uploadPreKeys() +- uploadPreKeysToServerIfRequired() +- upsertMessage() +- user +- waitForConnectionUpdate() +- waitForMessage() +- waitForSocketOpen() +- wamBuffer +- waUploadToServer +- ws + + +--- + +## Function: makeCacheableSignalKeyStore + +**Source:** https://baileys.wiki/docs/api/functions/makeCacheableSignalKeyStore + +On this page + +**makeCacheableSignalKeyStore**(`store`, `logger`?, `_cache`?): `SignalKeyStore` + +Defined in: src/Utils/auth-utils.ts:36 + +Adds caching capability to a SignalKeyStore + +## Parameters​ + +### store​ + +`SignalKeyStore` + +the store to add caching to + +### logger?​ + +`ILogger` + +to log trace events + +### _cache?​ + +`CacheStore` + +cache store to use + +## Returns​ + +`SignalKeyStore` + +- Parameters +store +- logger? +- _cache? + +- Returns + + +--- + +## Function: useMultiFileAuthState + +**Source:** https://baileys.wiki/docs/api/functions/useMultiFileAuthState + +On this page + +**useMultiFileAuthState**(`folder`): `Promise`<{ `saveCreds`: () => `Promise`<`void`>; `state`: `AuthenticationState`; }> + +Defined in: src/Utils/use-multi-file-auth-state.ts:33 + +stores the full authentication state in a single folder. +Far more efficient than singlefileauthstate + +Again, I wouldn't endorse this for any production level use other than perhaps a bot. +Would recommend writing an auth state for use with a proper SQL or No-SQL DB + +## Parameters​ + +### folder​ + +`string` + +## Returns​ + +`Promise`<{ `saveCreds`: () => `Promise`<`void`>; `state`: `AuthenticationState`; }> + +- Parameters +folder + +- Returns + + +--- + +## Function: delay + +**Source:** https://baileys.wiki/docs/api/functions/delay + +On this page + +**delay**(`ms`): `Promise`<`void`> + +Defined in: src/Utils/generics.ts:121 + +## Parameters​ + +### ms​ + +`number` + +## Returns​ + +`Promise`<`void`> + +- Parameters +ms + +- Returns + + +--- + +## Function: toNumber + +**Source:** https://baileys.wiki/docs/api/functions/toNumber + +On this page + +**toNumber**(`t`): `number` + +Defined in: src/Utils/generics.ts:95 + +## Parameters​ + +### t​ + +`undefined` | `null` | `number` | `Long` + +## Returns​ + +`number` + +- Parameters +t + +- Returns + + +--- + +## Function: toBuffer + +**Source:** https://baileys.wiki/docs/api/functions/toBuffer + +On this page + +**toBuffer**(`stream`): `Promise`<`Buffer`<`ArrayBuffer`>> + +Defined in: src/Utils/messages-media.ts:293 + +## Parameters​ + +### stream​ + +`Readable` + +## Returns​ + +`Promise`<`Buffer`<`ArrayBuffer`>> + +- Parameters +stream + +- Returns + + +--- + +## Function: unixTimestampSeconds + +**Source:** https://baileys.wiki/docs/api/functions/unixTimestampSeconds + +On this page + +**unixTimestampSeconds**(`date`): `number` + +Defined in: src/Utils/generics.ts:99 + +unix timestamp of a date in seconds + +## Parameters​ + +### date​ + +`Date` = `...` + +## Returns​ + +`number` + +- Parameters +date + +- Returns + + +# Variables + + +--- + +## Variable: WAMessageStatus + +**Source:** https://baileys.wiki/docs/api/variables/WAMessageStatus + +`const` **WAMessageStatus**: *typeof* `Status` = `proto.WebMessageInfo.Status` + +Defined in: src/Types/Message.ts:37 + + +--- + +## Variable: WAMessageStubType + +**Source:** https://baileys.wiki/docs/api/variables/WAMessageStubType + +`const` **WAMessageStubType**: *typeof* `StubType` = `proto.WebMessageInfo.StubType` + +Defined in: src/Types/Message.ts:36 + + +--- + +## Variable: S_WHATSAPP_NET + +**Source:** https://baileys.wiki/docs/api/variables/S_WHATSAPP_NET + +`const` **S_WHATSAPP_NET**: `"@s.whatsapp.net"` = `'@s.whatsapp.net'` + +Defined in: src/WABinary/jid-utils.ts:1 + + +--- + +## Variable: Browsers + +**Source:** https://baileys.wiki/docs/api/variables/Browsers + +`const` **Browsers**: `BrowsersMap` + +Defined in: src/Utils/browser-utils.ts:19 + + +--- + +## Variable: MEDIA_KEYS + +**Source:** https://baileys.wiki/docs/api/variables/MEDIA_KEYS + +`const` **MEDIA_KEYS**: (`"ppic"` | `"product"` | `"image"` | `"video"` | `"sticker"` | `"thumbnail-document"` | `"audio"` | `"thumbnail-image"` | `"biz-cover-photo"` | `"thumbnail-video"` | `"thumbnail-link"` | `"gif"` | `"md-app-state"` | `"md-msg-hist"` | `"document"` | `"ptt"` | `"product-catalog-image"` | `"payment-bg-image"` | `"ptv"`)[] + +Defined in: src/Defaults/index.ts:119 + + +--- + +## Variable: DEFAULT_CONNECTION_CONFIG + +**Source:** https://baileys.wiki/docs/api/variables/DEFAULT_CONNECTION_CONFIG + +`const` **DEFAULT_CONNECTION_CONFIG**: `SocketConfig` + +Defined in: src/Defaults/index.ts:47 + + +# Enums + + +--- + +## Enum: DisconnectReason + +**Source:** https://baileys.wiki/docs/api/enumerations/DisconnectReason + +On this page + +Defined in: src/Types/index.ts:27 + +## Enumeration Members​ + +### badSession​ + +**badSession**: `500` + +Defined in: src/Types/index.ts:33 + +### connectionClosed​ + +**connectionClosed**: `428` + +Defined in: src/Types/index.ts:28 + +### connectionLost​ + +**connectionLost**: `408` + +Defined in: src/Types/index.ts:29 + +### connectionReplaced​ + +**connectionReplaced**: `440` + +Defined in: src/Types/index.ts:30 + +### forbidden​ + +**forbidden**: `403` + +Defined in: src/Types/index.ts:36 + +### loggedOut​ + +**loggedOut**: `401` + +Defined in: src/Types/index.ts:32 + +### multideviceMismatch​ + +**multideviceMismatch**: `411` + +Defined in: src/Types/index.ts:35 + +### restartRequired​ + +**restartRequired**: `515` + +Defined in: src/Types/index.ts:34 + +### timedOut​ + +**timedOut**: `408` + +Defined in: src/Types/index.ts:31 + +### unavailableService​ + +**unavailableService**: `503` + +Defined in: src/Types/index.ts:37 + +- Enumeration Members +badSession +- connectionClosed +- connectionLost +- connectionReplaced +- forbidden +- loggedOut +- multideviceMismatch +- restartRequired +- timedOut +- unavailableService diff --git a/scripts/scrape-baileys-docs.ts b/scripts/scrape-baileys-docs.ts new file mode 100644 index 0000000..3a12b12 --- /dev/null +++ b/scripts/scrape-baileys-docs.ts @@ -0,0 +1,300 @@ +/** + * Script to scrape Baileys documentation from baileys.wiki + * Creates a comprehensive markdown file for Claude Code reference + */ + +import * as fs from 'fs' + +const BASE_URL = 'https://baileys.wiki/docs/api' + +interface DocSection { + name: string + path: string + type: 'interface' | 'type' | 'function' | 'variable' | 'class' | 'enum' +} + +// Relevant documentation sections to scrape +const SECTIONS: DocSection[] = [ + // Interfaces + { name: 'Contact', path: '/interfaces/Contact', type: 'interface' }, + { name: 'GroupMetadata', path: '/interfaces/GroupMetadata', type: 'interface' }, + { name: 'GroupModificationResponse', path: '/interfaces/GroupModificationResponse', type: 'interface' }, + { name: 'PresenceData', path: '/interfaces/PresenceData', type: 'interface' }, + { name: 'BaileysEventEmitter', path: '/interfaces/BaileysEventEmitter', type: 'interface' }, + { name: 'WAUrlInfo', path: '/interfaces/WAUrlInfo', type: 'interface' }, + { name: 'RecentMessage', path: '/interfaces/RecentMessage', type: 'interface' }, + + // Type Aliases - Chat + { name: 'Chat', path: '/type-aliases/Chat', type: 'type' }, + { name: 'ChatModification', path: '/type-aliases/ChatModification', type: 'type' }, + { name: 'ChatUpdate', path: '/type-aliases/ChatUpdate', type: 'type' }, + { name: 'ChatMutation', path: '/type-aliases/ChatMutation', type: 'type' }, + + // Type Aliases - Messages + { name: 'WAMessage', path: '/type-aliases/WAMessage', type: 'type' }, + { name: 'WAMessageContent', path: '/type-aliases/WAMessageContent', type: 'type' }, + { name: 'WAMessageKey', path: '/type-aliases/WAMessageKey', type: 'type' }, + { name: 'WAMessageUpdate', path: '/type-aliases/WAMessageUpdate', type: 'type' }, + { name: 'MessageType', path: '/type-aliases/MessageType', type: 'type' }, + { name: 'MessageUpsertType', path: '/type-aliases/MessageUpsertType', type: 'type' }, + { name: 'AnyMessageContent', path: '/type-aliases/AnyMessageContent', type: 'type' }, + { name: 'AnyMediaMessageContent', path: '/type-aliases/AnyMediaMessageContent', type: 'type' }, + { name: 'AnyRegularMessageContent', path: '/type-aliases/AnyRegularMessageContent', type: 'type' }, + { name: 'MessageGenerationOptions', path: '/type-aliases/MessageGenerationOptions', type: 'type' }, + { name: 'MessageContentGenerationOptions', path: '/type-aliases/MessageContentGenerationOptions', type: 'type' }, + { name: 'MinimalMessage', path: '/type-aliases/MinimalMessage', type: 'type' }, + + // Type Aliases - Media + { name: 'MediaType', path: '/type-aliases/MediaType', type: 'type' }, + { name: 'MediaDownloadOptions', path: '/type-aliases/MediaDownloadOptions', type: 'type' }, + { name: 'WAMediaUpload', path: '/type-aliases/WAMediaUpload', type: 'type' }, + { name: 'DownloadableMessage', path: '/type-aliases/DownloadableMessage', type: 'type' }, + { name: 'MediaGenerationOptions', path: '/type-aliases/MediaGenerationOptions', type: 'type' }, + + // Type Aliases - Groups + { name: 'GroupParticipant', path: '/type-aliases/GroupParticipant', type: 'type' }, + { name: 'GroupInviteInfo', path: '/type-aliases/GroupInviteInfo', type: 'type' }, + { name: 'ParticipantAction', path: '/type-aliases/ParticipantAction', type: 'type' }, + + // Type Aliases - Presence & Status + { name: 'WAPresence', path: '/type-aliases/WAPresence', type: 'type' }, + { name: 'ConnectionState', path: '/type-aliases/ConnectionState', type: 'type' }, + + // Type Aliases - Events + { name: 'BaileysEventMap', path: '/type-aliases/BaileysEventMap', type: 'type' }, + { name: 'BaileysEvent', path: '/type-aliases/BaileysEvent', type: 'type' }, + + // Type Aliases - Auth + { name: 'AuthenticationCreds', path: '/type-aliases/AuthenticationCreds', type: 'type' }, + { name: 'AuthenticationState', path: '/type-aliases/AuthenticationState', type: 'type' }, + + // Type Aliases - Socket + { name: 'WASocket', path: '/type-aliases/WASocket', type: 'type' }, + { name: 'SocketConfig', path: '/type-aliases/SocketConfig', type: 'type' }, + { name: 'UserFacingSocketConfig', path: '/type-aliases/UserFacingSocketConfig', type: 'type' }, + + // Functions - Messages + { name: 'generateWAMessage', path: '/functions/generateWAMessage', type: 'function' }, + { name: 'generateWAMessageContent', path: '/functions/generateWAMessageContent', type: 'function' }, + { name: 'generateWAMessageFromContent', path: '/functions/generateWAMessageFromContent', type: 'function' }, + { name: 'extractMessageContent', path: '/functions/extractMessageContent', type: 'function' }, + { name: 'getContentType', path: '/functions/getContentType', type: 'function' }, + { name: 'normalizeMessageContent', path: '/functions/normalizeMessageContent', type: 'function' }, + + // Functions - Media + { name: 'downloadMediaMessage', path: '/functions/downloadMediaMessage', type: 'function' }, + { name: 'downloadContentFromMessage', path: '/functions/downloadContentFromMessage', type: 'function' }, + { name: 'prepareWAMessageMedia', path: '/functions/prepareWAMessageMedia', type: 'function' }, + { name: 'extractImageThumb', path: '/functions/extractImageThumb', type: 'function' }, + { name: 'generateThumbnail', path: '/functions/generateThumbnail', type: 'function' }, + { name: 'generateProfilePicture', path: '/functions/generateProfilePicture', type: 'function' }, + { name: 'getMediaKeys', path: '/functions/getMediaKeys', type: 'function' }, + { name: 'encryptedStream', path: '/functions/encryptedStream', type: 'function' }, + + // Functions - JID + { name: 'jidDecode', path: '/functions/jidDecode', type: 'function' }, + { name: 'jidEncode', path: '/functions/jidEncode', type: 'function' }, + { name: 'jidNormalizedUser', path: '/functions/jidNormalizedUser', type: 'function' }, + { name: 'isJidGroup', path: '/functions/isJidGroup', type: 'function' }, + { name: 'isJidBroadcast', path: '/functions/isJidBroadcast', type: 'function' }, + { name: 'isJidStatusBroadcast', path: '/functions/isJidStatusBroadcast', type: 'function' }, + { name: 'areJidsSameUser', path: '/functions/areJidsSameUser', type: 'function' }, + { name: 'isLidUser', path: '/functions/isLidUser', type: 'function' }, + + // Functions - History + { name: 'downloadAndProcessHistorySyncNotification', path: '/functions/downloadAndProcessHistorySyncNotification', type: 'function' }, + { name: 'processHistoryMessage', path: '/functions/processHistoryMessage', type: 'function' }, + { name: 'getHistoryMsg', path: '/functions/getHistoryMsg', type: 'function' }, + + // Functions - Socket + { name: 'makeWASocket', path: '/functions/makeWASocket', type: 'function' }, + { name: 'makeCacheableSignalKeyStore', path: '/functions/makeCacheableSignalKeyStore', type: 'function' }, + { name: 'useMultiFileAuthState', path: '/functions/useMultiFileAuthState', type: 'function' }, + + // Functions - Utility + { name: 'delay', path: '/functions/delay', type: 'function' }, + { name: 'toNumber', path: '/functions/toNumber', type: 'function' }, + { name: 'toBuffer', path: '/functions/toBuffer', type: 'function' }, + { name: 'unixTimestampSeconds', path: '/functions/unixTimestampSeconds', type: 'function' }, + + // Variables + { name: 'WAMessageStatus', path: '/variables/WAMessageStatus', type: 'variable' }, + { name: 'WAMessageStubType', path: '/variables/WAMessageStubType', type: 'variable' }, + { name: 'S_WHATSAPP_NET', path: '/variables/S_WHATSAPP_NET', type: 'variable' }, + { name: 'Browsers', path: '/variables/Browsers', type: 'variable' }, + { name: 'MEDIA_KEYS', path: '/variables/MEDIA_KEYS', type: 'variable' }, + { name: 'DEFAULT_CONNECTION_CONFIG', path: '/variables/DEFAULT_CONNECTION_CONFIG', type: 'variable' }, + + // Enums + { name: 'DisconnectReason', path: '/enumerations/DisconnectReason', type: 'enum' }, +] + +async function fetchPage(url: string): Promise { + const response = await fetch(url) + if (!response.ok) { + throw new Error(`Failed to fetch ${url}: ${response.status}`) + } + return response.text() +} + +function extractContent(html: string, name: string, type: string): string { + // Remove script tags and style tags + html = html.replace(/]*>[\s\S]*?<\/script>/gi, '') + html = html.replace(/]*>[\s\S]*?<\/style>/gi, '') + html = html.replace(/]*>[\s\S]*?<\/nav>/gi, '') + html = html.replace(/]*>[\s\S]*?<\/footer>/gi, '') + html = html.replace(/]*>[\s\S]*?<\/header>/gi, '') + html = html.replace(/]*>[\s\S]*?<\/aside>/gi, '') + + // Extract main/article content + let mainMatch = html.match(/]*>([\s\S]*?)<\/main>/i) + if (!mainMatch) { + mainMatch = html.match(/]*>([\s\S]*?)<\/article>/i) + } + const content = mainMatch ? mainMatch[1] : html + + // Convert HTML to markdown-like text + let text = content + // Headers + .replace(/]*>([\s\S]*?)<\/h1>/gi, '\n# $1\n') + .replace(/]*>([\s\S]*?)<\/h2>/gi, '\n## $1\n') + .replace(/]*>([\s\S]*?)<\/h3>/gi, '\n### $1\n') + .replace(/]*>([\s\S]*?)<\/h4>/gi, '\n#### $1\n') + // Code blocks + .replace(/]*>]*>([\s\S]*?)<\/code><\/pre>/gi, '\n```typescript\n$1\n```\n') + .replace(/]*>([\s\S]*?)<\/code>/gi, '`$1`') + // Lists + .replace(/]*>([\s\S]*?)<\/li>/gi, '- $1\n') + .replace(/]*>/gi, '\n') + .replace(/<\/ul>/gi, '\n') + // Paragraphs + .replace(/]*>([\s\S]*?)<\/p>/gi, '\n$1\n') + // Links - keep only text for cleaner output + .replace(/]*>([\s\S]*?)<\/a>/gi, '$1') + // Bold/Italic + .replace(/]*>([\s\S]*?)<\/strong>/gi, '**$1**') + .replace(/]*>([\s\S]*?)<\/em>/gi, '*$1*') + // Line breaks + .replace(//gi, '\n') + // Divs and spans + .replace(/]*>/gi, '\n') + .replace(/<\/div>/gi, '\n') + .replace(/]*>/gi, '') + .replace(/<\/span>/gi, '') + // Tables (simplified) + .replace(/]*>/gi, '\n') + .replace(/<\/table>/gi, '\n') + .replace(/]*>/gi, '') + .replace(/<\/tr>/gi, '\n') + .replace(/]*>([\s\S]*?)<\/td>/gi, '| $1 ') + .replace(/]*>([\s\S]*?)<\/th>/gi, '| **$1** ') + // Remove remaining tags + .replace(/<[^>]+>/g, '') + // Decode HTML entities + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/&/g, '&') + .replace(/"/g, '"') + .replace(/'/g, "'") + .replace(/ /g, ' ') + // Clean up whitespace + .replace(/\n\s*\n\s*\n/g, '\n\n') + .replace(/^\s+|\s+$/g, '') + + return text +} + +async function scrapeSection(section: DocSection): Promise { + const url = `${BASE_URL}${section.path}` + console.log(`Fetching ${section.name}...`) + + try { + const html = await fetchPage(url) + const content = extractContent(html, section.name, section.type) + + return ` +--- + +## ${section.type.charAt(0).toUpperCase() + section.type.slice(1)}: ${section.name} + +**Source:** ${url} + +${content} +` + } catch (error) { + console.error(`Error fetching ${section.name}:`, (error as Error).message) + return ` +--- + +## ${section.type.charAt(0).toUpperCase() + section.type.slice(1)}: ${section.name} + +**Source:** ${url} + +*Error: Could not fetch documentation* +` + } +} + +async function main() { + console.log('Starting Baileys documentation scrape...\n') + + const markdown: string[] = [ + `# Baileys API Documentation Reference + +> Auto-generated documentation for WhatsApp Nucleo development +> Source: https://baileys.wiki +> Generated: ${new Date().toISOString()} + +This document contains the relevant Baileys API documentation for developing the WhatsApp Nucleo messaging features. + +## Table of Contents + +### Interfaces +${SECTIONS.filter(s => s.type === 'interface').map(s => `- [${s.name}](#interface-${s.name.toLowerCase()})`).join('\n')} + +### Type Aliases +${SECTIONS.filter(s => s.type === 'type').map(s => `- [${s.name}](#type-${s.name.toLowerCase()})`).join('\n')} + +### Functions +${SECTIONS.filter(s => s.type === 'function').map(s => `- [${s.name}](#function-${s.name.toLowerCase()})`).join('\n')} + +### Variables +${SECTIONS.filter(s => s.type === 'variable').map(s => `- [${s.name}](#variable-${s.name.toLowerCase()})`).join('\n')} + +### Enumerations +${SECTIONS.filter(s => s.type === 'enum').map(s => `- [${s.name}](#enum-${s.name.toLowerCase()})`).join('\n')} + +` + ] + + // Group sections by type + const groupedSections = { + interface: SECTIONS.filter(s => s.type === 'interface'), + type: SECTIONS.filter(s => s.type === 'type'), + function: SECTIONS.filter(s => s.type === 'function'), + variable: SECTIONS.filter(s => s.type === 'variable'), + enum: SECTIONS.filter(s => s.type === 'enum'), + } + + // Process each group + for (const [type, sections] of Object.entries(groupedSections)) { + markdown.push(`\n# ${type.charAt(0).toUpperCase() + type.slice(1)}s\n`) + + for (const section of sections) { + const content = await scrapeSection(section) + markdown.push(content) + + // Small delay to be nice to the server + await new Promise(r => setTimeout(r, 300)) + } + } + + // Write to file + const outputPath = './docs/baileys-api-reference.md' + fs.writeFileSync(outputPath, markdown.join('\n')) + + console.log(`\nDocumentation saved to ${outputPath}`) + console.log(`Total sections: ${SECTIONS.length}`) +} + +main().catch(console.error) diff --git a/server/api/debug/chat/modify.post.ts b/server/api/debug/chat/modify.post.ts new file mode 100644 index 0000000..575a6c7 --- /dev/null +++ b/server/api/debug/chat/modify.post.ts @@ -0,0 +1,76 @@ +/** + * POST /api/debug/chat/modify + * Modify chat state (archive, mute, mark read, pin) + */ +import { baileysManager } from '../../../services/baileys/manager' + +type ModificationType = 'archive' | 'mute' | 'markRead' | 'pin' + +export default defineEventHandler(async (event) => { + const username = getHeader(event, 'x-authentik-username') + if (!username) { + throw createError({ statusCode: 401, message: 'Unauthorized' }) + } + + const body = await readBody(event) + const { instanceId, jid, type, value, lastMessages } = body as { + instanceId: string + jid: string + type: ModificationType + value: boolean | number | null + lastMessages?: any[] + } + + if (!instanceId) { + throw createError({ statusCode: 400, message: 'instanceId is required' }) + } + + if (!jid) { + throw createError({ statusCode: 400, message: 'jid is required' }) + } + + const validTypes: ModificationType[] = ['archive', 'mute', 'markRead', 'pin'] + if (!type || !validTypes.includes(type)) { + throw createError({ + statusCode: 400, + message: `type must be one of: ${validTypes.join(', ')}` + }) + } + + if (value === undefined) { + throw createError({ statusCode: 400, message: 'value is required' }) + } + + const socket = baileysManager.getSocket(instanceId) + if (!socket) { + throw createError({ statusCode: 400, message: 'Instance not connected' }) + } + + try { + let modification: any + + switch (type) { + case 'archive': + modification = { archive: value, lastMessages: lastMessages || [] } + break + case 'mute': + // value should be timestamp for mute duration, null to unmute + modification = { mute: value } + break + case 'markRead': + modification = { markRead: value, lastMessages: lastMessages || [] } + break + case 'pin': + modification = { pin: value } + break + } + + await socket.chatModify(modification, jid) + return { success: true, message: `Chat ${type} modified successfully` } + } catch (error) { + throw createError({ + statusCode: 500, + message: `Failed to modify chat: ${(error as Error).message}` + }) + } +}) diff --git a/server/api/debug/groups/create.post.ts b/server/api/debug/groups/create.post.ts new file mode 100644 index 0000000..f04de50 --- /dev/null +++ b/server/api/debug/groups/create.post.ts @@ -0,0 +1,42 @@ +/** + * POST /api/debug/groups/create + * Create a new group + */ +import { baileysManager } from '../../../services/baileys/manager' + +export default defineEventHandler(async (event) => { + const username = getHeader(event, 'x-authentik-username') + if (!username) { + throw createError({ statusCode: 401, message: 'Unauthorized' }) + } + + const body = await readBody(event) + const { instanceId, name, participants } = body + + if (!instanceId) { + throw createError({ statusCode: 400, message: 'instanceId is required' }) + } + + if (!name) { + throw createError({ statusCode: 400, message: 'name is required' }) + } + + if (!participants || !Array.isArray(participants) || participants.length === 0) { + throw createError({ statusCode: 400, message: 'participants array is required' }) + } + + const socket = baileysManager.getSocket(instanceId) + if (!socket) { + throw createError({ statusCode: 400, message: 'Instance not connected' }) + } + + try { + const result = await socket.groupCreate(name, participants) + return { success: true, data: result } + } catch (error) { + throw createError({ + statusCode: 500, + message: `Failed to create group: ${(error as Error).message}` + }) + } +}) diff --git a/server/api/debug/groups/description.post.ts b/server/api/debug/groups/description.post.ts new file mode 100644 index 0000000..ff6258d --- /dev/null +++ b/server/api/debug/groups/description.post.ts @@ -0,0 +1,42 @@ +/** + * POST /api/debug/groups/description + * Update group description + */ +import { baileysManager } from '../../../services/baileys/manager' + +export default defineEventHandler(async (event) => { + const username = getHeader(event, 'x-authentik-username') + if (!username) { + throw createError({ statusCode: 401, message: 'Unauthorized' }) + } + + const body = await readBody(event) + const { instanceId, jid, description } = body + + if (!instanceId) { + throw createError({ statusCode: 400, message: 'instanceId is required' }) + } + + if (!jid) { + throw createError({ statusCode: 400, message: 'jid is required' }) + } + + if (description === undefined) { + throw createError({ statusCode: 400, message: 'description is required' }) + } + + const socket = baileysManager.getSocket(instanceId) + if (!socket) { + throw createError({ statusCode: 400, message: 'Instance not connected' }) + } + + try { + await socket.groupUpdateDescription(jid, description) + return { success: true, message: 'Group description updated successfully' } + } catch (error) { + throw createError({ + statusCode: 500, + message: `Failed to update group description: ${(error as Error).message}` + }) + } +}) diff --git a/server/api/debug/groups/invite-code.post.ts b/server/api/debug/groups/invite-code.post.ts new file mode 100644 index 0000000..ca1bb73 --- /dev/null +++ b/server/api/debug/groups/invite-code.post.ts @@ -0,0 +1,44 @@ +/** + * POST /api/debug/groups/invite-code + * Get group invite code + */ +import { baileysManager } from '../../../services/baileys/manager' + +export default defineEventHandler(async (event) => { + const username = getHeader(event, 'x-authentik-username') + if (!username) { + throw createError({ statusCode: 401, message: 'Unauthorized' }) + } + + const body = await readBody(event) + const { instanceId, jid } = body + + if (!instanceId) { + throw createError({ statusCode: 400, message: 'instanceId is required' }) + } + + if (!jid) { + throw createError({ statusCode: 400, message: 'jid is required' }) + } + + const socket = baileysManager.getSocket(instanceId) + if (!socket) { + throw createError({ statusCode: 400, message: 'Instance not connected' }) + } + + try { + const code = await socket.groupInviteCode(jid) + return { + success: true, + data: { + code, + link: `https://chat.whatsapp.com/${code}` + } + } + } catch (error) { + throw createError({ + statusCode: 500, + message: `Failed to get invite code: ${(error as Error).message}` + }) + } +}) diff --git a/server/api/debug/groups/metadata.post.ts b/server/api/debug/groups/metadata.post.ts new file mode 100644 index 0000000..f285453 --- /dev/null +++ b/server/api/debug/groups/metadata.post.ts @@ -0,0 +1,38 @@ +/** + * POST /api/debug/groups/metadata + * Get group metadata + */ +import { baileysManager } from '../../../services/baileys/manager' + +export default defineEventHandler(async (event) => { + const username = getHeader(event, 'x-authentik-username') + if (!username) { + throw createError({ statusCode: 401, message: 'Unauthorized' }) + } + + const body = await readBody(event) + const { instanceId, jid } = body + + if (!instanceId) { + throw createError({ statusCode: 400, message: 'instanceId is required' }) + } + + if (!jid) { + throw createError({ statusCode: 400, message: 'jid is required' }) + } + + const socket = baileysManager.getSocket(instanceId) + if (!socket) { + throw createError({ statusCode: 400, message: 'Instance not connected' }) + } + + try { + const result = await socket.groupMetadata(jid) + return { success: true, data: result } + } catch (error) { + throw createError({ + statusCode: 500, + message: `Failed to get group metadata: ${(error as Error).message}` + }) + } +}) diff --git a/server/api/debug/groups/participants.post.ts b/server/api/debug/groups/participants.post.ts new file mode 100644 index 0000000..837f0a1 --- /dev/null +++ b/server/api/debug/groups/participants.post.ts @@ -0,0 +1,57 @@ +/** + * POST /api/debug/groups/participants + * Update group participants (add, remove, promote, demote) + */ +import { baileysManager } from '../../../services/baileys/manager' + +type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' + +export default defineEventHandler(async (event) => { + const username = getHeader(event, 'x-authentik-username') + if (!username) { + throw createError({ statusCode: 401, message: 'Unauthorized' }) + } + + const body = await readBody(event) + const { instanceId, jid, participants, action } = body as { + instanceId: string + jid: string + participants: string[] + action: ParticipantAction + } + + if (!instanceId) { + throw createError({ statusCode: 400, message: 'instanceId is required' }) + } + + if (!jid) { + throw createError({ statusCode: 400, message: 'jid is required' }) + } + + if (!participants || !Array.isArray(participants) || participants.length === 0) { + throw createError({ statusCode: 400, message: 'participants array is required' }) + } + + const validActions: ParticipantAction[] = ['add', 'remove', 'promote', 'demote'] + if (!action || !validActions.includes(action)) { + throw createError({ + statusCode: 400, + message: `action must be one of: ${validActions.join(', ')}` + }) + } + + const socket = baileysManager.getSocket(instanceId) + if (!socket) { + throw createError({ statusCode: 400, message: 'Instance not connected' }) + } + + try { + const result = await socket.groupParticipantsUpdate(jid, participants, action) + return { success: true, data: result } + } catch (error) { + throw createError({ + statusCode: 500, + message: `Failed to update participants: ${(error as Error).message}` + }) + } +}) diff --git a/server/api/debug/groups/subject.post.ts b/server/api/debug/groups/subject.post.ts new file mode 100644 index 0000000..d7e829d --- /dev/null +++ b/server/api/debug/groups/subject.post.ts @@ -0,0 +1,42 @@ +/** + * POST /api/debug/groups/subject + * Update group subject (name) + */ +import { baileysManager } from '../../../services/baileys/manager' + +export default defineEventHandler(async (event) => { + const username = getHeader(event, 'x-authentik-username') + if (!username) { + throw createError({ statusCode: 401, message: 'Unauthorized' }) + } + + const body = await readBody(event) + const { instanceId, jid, subject } = body + + if (!instanceId) { + throw createError({ statusCode: 400, message: 'instanceId is required' }) + } + + if (!jid) { + throw createError({ statusCode: 400, message: 'jid is required' }) + } + + if (!subject) { + throw createError({ statusCode: 400, message: 'subject is required' }) + } + + const socket = baileysManager.getSocket(instanceId) + if (!socket) { + throw createError({ statusCode: 400, message: 'Instance not connected' }) + } + + try { + await socket.groupUpdateSubject(jid, subject) + return { success: true, message: 'Group subject updated successfully' } + } catch (error) { + throw createError({ + statusCode: 500, + message: `Failed to update group subject: ${(error as Error).message}` + }) + } +}) diff --git a/server/api/debug/history/fetch.post.ts b/server/api/debug/history/fetch.post.ts new file mode 100644 index 0000000..c15bcfc --- /dev/null +++ b/server/api/debug/history/fetch.post.ts @@ -0,0 +1,41 @@ +/** + * POST /api/debug/history/fetch + * Request message history on-demand + */ +import { baileysManager } from '../../../services/baileys/manager' + +export default defineEventHandler(async (event) => { + const username = getHeader(event, 'x-authentik-username') + if (!username) { + throw createError({ statusCode: 401, message: 'Unauthorized' }) + } + + const body = await readBody(event) + const { instanceId, count, oldestMsgKey, oldestMsgTimestamp } = body + + if (!instanceId) { + throw createError({ statusCode: 400, message: 'instanceId is required' }) + } + + if (!count || typeof count !== 'number') { + throw createError({ statusCode: 400, message: 'count (number) is required' }) + } + + const socket = baileysManager.getSocket(instanceId) + if (!socket) { + throw createError({ statusCode: 400, message: 'Instance not connected' }) + } + + try { + await socket.fetchMessageHistory(count, oldestMsgKey, oldestMsgTimestamp) + return { + success: true, + message: `Requested ${count} messages from history. Check messaging-history.set event for results.` + } + } catch (error) { + throw createError({ + statusCode: 500, + message: `Failed to fetch message history: ${(error as Error).message}` + }) + } +}) diff --git a/server/api/debug/media/update.post.ts b/server/api/debug/media/update.post.ts new file mode 100644 index 0000000..282b010 --- /dev/null +++ b/server/api/debug/media/update.post.ts @@ -0,0 +1,38 @@ +/** + * POST /api/debug/media/update + * Update expired media message + */ +import { baileysManager } from '../../../services/baileys/manager' + +export default defineEventHandler(async (event) => { + const username = getHeader(event, 'x-authentik-username') + if (!username) { + throw createError({ statusCode: 401, message: 'Unauthorized' }) + } + + const body = await readBody(event) + const { instanceId, message } = body + + if (!instanceId) { + throw createError({ statusCode: 400, message: 'instanceId is required' }) + } + + if (!message) { + throw createError({ statusCode: 400, message: 'message (proto.IWebMessageInfo) is required' }) + } + + const socket = baileysManager.getSocket(instanceId) + if (!socket) { + throw createError({ statusCode: 400, message: 'Instance not connected' }) + } + + try { + const result = await socket.updateMediaMessage(message) + return { success: true, data: result } + } catch (error) { + throw createError({ + statusCode: 500, + message: `Failed to update media message: ${(error as Error).message}` + }) + } +})