@areumtecnologia/wasockets 2.0.0-alpha.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +1929 -1649
  2. package/lib/Defaults/baileys-version.json +1 -1
  3. package/lib/Defaults/connection.js +14 -1
  4. package/lib/Socket/index.js +51 -48
  5. package/lib/Socket/messages-recv.js +74 -13
  6. package/lib/Socket/messages-send.js +50 -25
  7. package/lib/Socket/socket.js +13 -0
  8. package/lib/Socket/voip.js +123 -0
  9. package/lib/Store/make-cache-manager-store.js +14 -5
  10. package/lib/Types/index.d.ts +4 -0
  11. package/lib/Utils/auth-utils.js +16 -1
  12. package/lib/Utils/browser-utils.js +6 -2
  13. package/lib/Utils/generics.js +47 -8
  14. package/lib/Utils/index.d.ts +1 -0
  15. package/lib/Utils/messages-media.js +44 -21
  16. package/lib/Utils/pre-key-manager.js +16 -1
  17. package/lib/Utils/validate-connection.js +10 -11
  18. package/lib/VoIP/VoIPCrypto.js +150 -0
  19. package/lib/VoIP/VoIPManager.js +469 -0
  20. package/lib/VoIP/VoIPMediaEngine.js +224 -0
  21. package/lib/VoIP/VoIPProtocol.js +354 -0
  22. package/lib/VoIP/VoIPRelayTransport.js +173 -0
  23. package/lib/VoIP/VoIPSession.js +314 -0
  24. package/lib/VoIP/assets/wasm/loader.js +5 -0
  25. package/lib/VoIP/assets/wasm/whatsapp.wasm +0 -0
  26. package/lib/VoIP/assets/wasm/worker-modules.js +305 -0
  27. package/lib/VoIP/engine/audio-feeder.d.mts +15 -0
  28. package/lib/VoIP/engine/audio-feeder.mjs +243 -0
  29. package/lib/VoIP/engine/index.d.mts +91 -0
  30. package/lib/VoIP/engine/index.mjs +1683 -0
  31. package/lib/VoIP/engine/relay-transport.d.mts +43 -0
  32. package/lib/VoIP/engine/relay-transport.mjs +607 -0
  33. package/lib/VoIP/engine/signaling.d.mts +44 -0
  34. package/lib/VoIP/engine/signaling.mjs +893 -0
  35. package/lib/VoIP/engine/types.d.mts +183 -0
  36. package/lib/VoIP/engine/types.mjs +17 -0
  37. package/lib/VoIP/engine/wasm-engine.d.mts +103 -0
  38. package/lib/VoIP/engine/wasm-engine.mjs +1397 -0
  39. package/lib/VoIP/engine/worker-bootstrap.mjs +1049 -0
  40. package/lib/VoIP/index.js +51 -0
  41. package/lib/VoIP/utils/audio.d.ts +28 -0
  42. package/lib/VoIP/utils/audio.js +148 -0
  43. package/lib/WABinary/generic-utils.js +22 -6
  44. package/lib/index.d.ts +382 -274
  45. package/lib/index.js +5 -0
  46. package/package.json +28 -32
package/lib/index.d.ts CHANGED
@@ -1,274 +1,382 @@
1
- /// <reference types="node" />
2
-
3
- import { proto } from '../WAProto'
4
- import { AuthenticationState, BaileysEventEmitter, ConnectionState, Contact, GroupMetadata, WACallEvent, WAMessage, WAMessageKey, WAMessageContent, AnyMessageContent, MiscMessageGenerationOptions } from './Types'
5
- import { PluginManager } from './Plugins'
6
-
7
- export * from './Types'
8
- export * from './Utils'
9
- export * from './Defaults'
10
- export * from './Store'
11
- export * from './WABinary'
12
- export * from './Plugins'
13
- export { proto }
14
-
15
- export interface GroupPermissionsPolicies {
16
- announce?: boolean
17
- restrict?: boolean
18
- memberAddMode?: 'admin_add' | 'all_member_add'
19
- approvalMode?: boolean | 'on' | 'off'
20
- ephemeral?: number | false
21
- }
22
-
23
- export interface GroupSubGroupsResult {
24
- communityJid: string
25
- isCommunity: boolean
26
- defaultSubGroup: any | null
27
- subGroups: any[]
28
- linkedGroups: any[]
29
- }
30
-
31
- export interface SendAlbumMediaItem {
32
- image?: any
33
- video?: any
34
- caption?: string
35
- [key: string]: any
36
- }
37
-
38
- export interface UserFacingSocketConfig {
39
- version?: [number, number, number]
40
- browser?: [string, string, string]
41
- waWebSocketUrl?: string
42
- connectTimeoutMs?: number
43
- keepAliveIntervalMs?: number
44
- logger?: any
45
- printQRInTerminal?: boolean
46
- emitOwnEvents?: boolean
47
- defaultQueryTimeoutMs?: number
48
- customUploadHosts?: string[]
49
- retryRequestDelayMs?: number
50
- maxMsgRetryCount?: number
51
- fireInitQueries?: boolean
52
- auth?: AuthenticationState
53
- markOnlineOnConnect?: boolean
54
- syncFullHistory?: boolean
55
- patchMessageBeforeSending?: (msg: proto.IMessage) => proto.IMessage | Promise<proto.IMessage>
56
- shouldSyncHistoryMessage?: (msg: proto.IHistorySyncNotification) => boolean
57
- shouldIgnoreJid?: (jid: string) => boolean
58
- linkPreviewImageThumbnailWidth?: number
59
- transactionOpts?: { maxCommitRetries: number; delayBetweenTriesMs: number }
60
- generateHighQualityLinkPreview?: boolean
61
- enableAutoSessionRecreation?: boolean
62
- enableRecentMessageCache?: boolean
63
- enableMessageQueue?: boolean
64
- messageQueueTtlMs?: number
65
- maxReconnectAttempts?: number
66
- enableGroupCache?: boolean
67
- cachedGroupMetadata?: (jid: string) => Promise<GroupMetadata | undefined>
68
- plugins?: any[]
69
- [key: string]: any
70
- }
71
-
72
- export interface WASocket {
73
- type: 'md'
74
- ws: any
75
- ev: BaileysEventEmitter
76
- authState: AuthenticationState
77
- user: Contact | undefined
78
- plugins: PluginManager
79
-
80
- // Plugin & Middleware system
81
- use(plugin: any, options?: any): WASocket
82
- registerMiddleware(hook: 'beforeSendMessage' | 'afterSendMessage' | 'beforeRecvMessage' | 'afterRecvMessage' | 'connectionUpdate', fn: Function): () => void
83
- hasPlugin(name: string): boolean
84
- listPlugins(): Array<{ name: string; registeredAt: number; version: string; description: string }>
85
-
86
- // Connection & Auth
87
- waitForConnectionUpdate(check: (u: Partial<ConnectionState>) => boolean | undefined, timeoutMs?: number): Promise<void>
88
- end(error: Error | undefined): void
89
- logout(msg?: string): Promise<void>
90
- requestPairingCode(phoneNumber: string): Promise<string>
91
- repairSession(jid: string): Promise<void>
92
- onWhatsApp(...phoneNumber: string[]): Promise<{ jid: string; exists: boolean }[] | undefined>
93
-
94
- // Presence & Status
95
- sendPresenceUpdate(type: 'available' | 'unavailable' | 'composing' | 'recording' | 'paused', toJid?: string): Promise<void>
96
- presenceSubscribe(toJid: string): Promise<void>
97
-
98
- // Profile & User
99
- profilePictureUrl(jid: string, type?: 'image' | 'preview', timeoutMs?: number): Promise<string | undefined>
100
- updateProfilePicture(jid: string, content: any): Promise<void>
101
- removeProfilePicture(jid: string): Promise<void>
102
- fetchStatus(jid: string): Promise<{ status: string | undefined; setAt: Date } | undefined>
103
- updateProfileStatus(status: string): Promise<void>
104
- updateProfileName(name: string): Promise<void>
105
-
106
- // Cross-JID / LID Architecture
107
- toPn(jid: string, fetchIfMissing?: boolean): Promise<string | null>
108
- toLid(jid: string, fetchIfMissing?: boolean): Promise<string | null>
109
- resolveJid(jid: string, fetchIfMissing?: boolean): Promise<{ pn: string | null; lid: string | null; jid: string | null }>
110
- storeLidPnMapping(pn: string, lid: string): Promise<boolean>
111
-
112
- // Messaging
113
- sendMessage(jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions & { mentionAll?: boolean; adminsOnly?: boolean; excludeMe?: boolean }): Promise<WAMessage | undefined>
114
- sendAlbumMessage(jid: string, medias: SendAlbumMediaItem[], options?: MiscMessageGenerationOptions): Promise<WAMessage[]>
115
- groupSendMentionAll(jid: string, content: string | AnyMessageContent, options?: { adminsOnly?: boolean; excludeMe?: boolean }): Promise<WAMessage | undefined>
116
- relayMessage(jid: string, message: proto.IMessage, options: any): Promise<string>
117
- readMessages(keys: WAMessageKey[]): Promise<void>
118
- star(jid: string, messages: { id: string; fromMe?: boolean }[], star: boolean): Promise<void>
119
- sendStatusMentions(content: any, jids?: string[]): Promise<WAMessage>
120
- reactToStatus(key: WAMessageKey, reaction?: string): Promise<string>
121
- sendEventResponse(jid: string, eventCreationMessageKey: WAMessageKey, response: string | number, extraGuestCount?: number): Promise<WAMessage | undefined>
122
- cancelEvent(jid: string, eventKey: WAMessageKey): Promise<WAMessage | undefined>
123
-
124
- // Calls (Web Calling)
125
- offerCall(toJid: string, isVideo?: boolean): Promise<any>
126
- acceptCall(callId: string, callFrom: string): Promise<void>
127
- rejectCall(callId: string, callFrom: string): Promise<void>
128
- terminateCall(callId: string, callFrom: string): Promise<void>
129
-
130
- // Chats & Contacts
131
- chatModify(mod: any, jid: string): Promise<void>
132
- updateFavorite(jid: string, favorite: boolean): Promise<void>
133
- updateChatNote(jid: string, note: string): Promise<void>
134
- removeChatNote(jid: string): Promise<void>
135
- addOrEditContact(contact: any): Promise<void>
136
- removeContact(jid: string): Promise<void>
137
-
138
- // Groups
139
- groupMetadata(jid: string): Promise<GroupMetadata>
140
- groupCreate(subject: string, participants: string[]): Promise<GroupMetadata>
141
- groupLeave(id: string): Promise<void>
142
- groupUpdateSubject(jid: string, subject: string): Promise<void>
143
- groupUpdateDescription(jid: string, description: string): Promise<void>
144
- groupInviteCode(jid: string): Promise<string | undefined>
145
- groupRevokeInvite(jid: string): Promise<string | undefined>
146
- groupAcceptInvite(code: string): Promise<string | undefined>
147
- groupGetInviteInfo(code: string): Promise<GroupMetadata>
148
- groupParticipantsUpdate(jid: string, participants: string[], action: 'add' | 'remove' | 'demote' | 'promote'): Promise<any[]>
149
- groupSettingUpdate(jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked'): Promise<void>
150
- groupMemberAddMode(jid: string, mode: 'admin_add' | 'all_member_add'): Promise<void>
151
- groupJoinApprovalMode(jid: string, mode: 'on' | 'off' | boolean): Promise<void>
152
- groupMembershipApprovalMode(jid: string, mode: 'on' | 'off' | boolean): Promise<void>
153
- groupRequestParticipantsList(jid: string): Promise<any[]>
154
- groupRequestParticipantsUpdate(jid: string, participants: string[], action: 'approve' | 'reject'): Promise<any[]>
155
- groupApprovePendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
156
- groupRejectPendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
157
- groupUpdatePermissions(jid: string, policies: GroupPermissionsPolicies): Promise<Record<string, any>>
158
- groupGetAdminJids(jid: string): Promise<string[]>
159
- groupGetParticipants(jid: string): Promise<any[]>
160
- groupToggleEphemeral(jid: string, ephemeralExpiration: number): Promise<void>
161
-
162
- // Communities v2
163
- communityCreate(subject: string, body?: string): Promise<GroupMetadata | null>
164
- communityCreateGroup(subject: string, participants: string[], parentCommunityJid: string): Promise<GroupMetadata | null>
165
- communityLinkGroup(groupJid: string, parentCommunityJid: string): Promise<void>
166
- communityUnlinkGroup(groupJid: string, parentCommunityJid: string): Promise<void>
167
- communityFetchLinkedGroups(jid: string): Promise<any>
168
- communityFetchSubGroups(jid: string): Promise<GroupSubGroupsResult>
169
- communityMembershipApprovalMode(jid: string, mode: 'on' | 'off' | boolean): Promise<void>
170
- communityApprovePendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
171
- communityRejectPendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
172
- communityUpdatePermissions(jid: string, policies: GroupPermissionsPolicies): Promise<Record<string, any>>
173
-
174
- // Newsletters v2
175
- newsletterCreate(name: string, description?: string, picture?: Buffer): Promise<any>
176
- newsletterMetadata(type: 'invite' | 'jid', key: string): Promise<any>
177
- newsletterFetchMessages(jid: string, count: number, since?: number): Promise<any[]>
178
- newsletterFetchMessage(jid: string, messageServerId: string | number): Promise<any>
179
- newsletterFetchReactions(jid: string, messageServerId: string | number): Promise<any[]>
180
- newsletterToggleMute(jid: string, mute: boolean): Promise<void>
181
- newsletterFollow(jid: string): Promise<void>
182
- newsletterUnfollow(jid: string): Promise<void>
183
- newsletterSubscribers(jid: string): Promise<any>
184
- newsletterSubscribed(): Promise<any[]>
185
- newsletterUpdate(jid: string, updates: any): Promise<any>
186
- newsletterUpdateName(jid: string, name: string): Promise<any>
187
- newsletterUpdateDescription(jid: string, description: string): Promise<any>
188
- newsletterUpdatePicture(jid: string, content: any): Promise<any>
189
- newsletterRemovePicture(jid: string): Promise<any>
190
- newsletterReactMessage(jid: string, serverId: string | number, reaction?: string): Promise<void>
191
- newsletterAdminCount(jid: string): Promise<number>
192
- newsletterChangeOwner(jid: string, newOwnerJid: string): Promise<void>
193
- newsletterDelete(jid: string): Promise<void>
194
-
195
- // Labels & Quick Replies
196
- createLabel(name: string, color?: number): Promise<any>
197
- updateLabel(labelId: string, name: string, color?: number): Promise<any>
198
- deleteLabel(labelId: string): Promise<any>
199
- addChatLabel(jid: string, labelId: string): Promise<void>
200
- removeChatLabel(jid: string, labelId: string): Promise<void>
201
- addMessageLabel(jid: string, messageId: string, labelId: string): Promise<void>
202
- removeMessageLabel(jid: string, messageId: string, labelId: string): Promise<void>
203
- addOrEditQuickReply(quickReply: any): Promise<void>
204
- removeQuickReply(id: string): Promise<void>
205
-
206
- // Privacy
207
- fetchBlocklist(): Promise<string[]>
208
- updateBlockStatus(jid: string, action: 'block' | 'unblock'): Promise<void>
209
- fetchPrivacySettings(force?: boolean): Promise<any>
210
- updateLastSeenPrivacy(value: 'all' | 'contacts' | 'contact_blacklist' | 'none'): Promise<void>
211
- updateOnlinePrivacy(value: 'all' | 'match_last_seen'): Promise<void>
212
- updateReadReceiptsPrivacy(value: 'all' | 'none'): Promise<void>
213
- updateProfilePicturePrivacy(value: 'all' | 'contacts' | 'contact_blacklist' | 'none'): Promise<void>
214
- updateStatusPrivacy(value: 'all' | 'contacts' | 'contact_blacklist' | 'none'): Promise<void>
215
- updateGroupsAddPrivacy(value: 'all' | 'contacts' | 'contact_blacklist'): Promise<void>
216
- updateCallPrivacy(value: 'all' | 'known'): Promise<void>
217
-
218
- // Business
219
- getCatalog(opts: { jid?: string; limit?: number; cursor?: string }): Promise<any>
220
- getCollections(jid?: string, limit?: number): Promise<any>
221
- getOrderDetails(orderId: string, tokenBase64: string): Promise<any>
222
- getProduct(jid: string, productId: string): Promise<any>
223
- productCreate(create: any): Promise<any>
224
- productUpdate(productId: string, update: any): Promise<any>
225
- productDelete(productIds: string[]): Promise<{ deleted: number }>
226
- updateBussinesProfile(args: any): Promise<void>
227
- updateCoverPhoto(file: any): Promise<string>
228
- removeCoverPhoto(id: string): Promise<void>
229
-
230
- [key: string]: any
231
- }
232
-
233
- export interface InMemoryStoreConfig {
234
- logger?: any
235
- chatKey?: any
236
- labelAssociationKey?: any
237
- maxMessagesPerChat?: number
238
- [key: string]: any
239
- }
240
-
241
- export interface InMemoryStore {
242
- chats: any
243
- messages: Record<string, any>
244
- contacts: Record<string, Contact>
245
- groupMetadata: Record<string, GroupMetadata>
246
- presences: Record<string, any>
247
- state: Partial<ConnectionState>
248
- labels: any
249
- labelAssociations: any
250
- bind(ev: BaileysEventEmitter): void
251
- loadMessage(jid: string, id: string): Promise<WAMessage | undefined>
252
- loadMessages(jid: string, count: number, cursor?: any): Promise<WAMessage[]>
253
- mostRecentMessage(jid: string): Promise<WAMessage | undefined>
254
- getContact(jid: string): Contact | undefined
255
- getChat(jid: string): any | undefined
256
- pruneMessages(jid?: string, keepLastN?: number): number
257
- clear(chatId?: string): void
258
- getMessageCount(jid?: string): number
259
- writeToFile(path: string): void
260
- readFromFile(path: string): void
261
- toJSON(): any
262
- fromJSON(json: any): void
263
- }
264
-
265
- export declare function makeInMemoryStore(config?: InMemoryStoreConfig): InMemoryStore
266
- export declare function createGroupMetadataCache(ttlMs?: number, maxSize?: number): {
267
- (jid: string): Promise<GroupMetadata | undefined>
268
- set(jid: string, metadata: GroupMetadata): void
269
- delete(jid: string): boolean
270
- clear(): void
271
- }
272
-
273
- export declare function makeWASocket(config?: UserFacingSocketConfig): WASocket
274
- export default makeWASocket
1
+ /// <reference types="node" />
2
+
3
+ import { proto } from '../WAProto'
4
+ import { AuthenticationState, BaileysEventEmitter, ConnectionState, Contact, GroupMetadata, WACallEvent, WAMessage, WAMessageKey, WAMessageContent, AnyMessageContent, MiscMessageGenerationOptions } from './Types'
5
+ import { PluginManager } from './Plugins'
6
+
7
+ export * from './Types'
8
+ export * from './Utils'
9
+ export * from './Defaults'
10
+ export * from './Store'
11
+ export * from './WABinary'
12
+ export * from './Plugins'
13
+ export { proto }
14
+ export * from './Client'
15
+
16
+ export interface GroupPermissionsPolicies {
17
+ announce?: boolean
18
+ restrict?: boolean
19
+ memberAddMode?: 'admin_add' | 'all_member_add'
20
+ approvalMode?: boolean | 'on' | 'off'
21
+ ephemeral?: number | false
22
+ }
23
+
24
+ export interface GroupSubGroupsResult {
25
+ communityJid: string
26
+ isCommunity: boolean
27
+ defaultSubGroup: any | null
28
+ subGroups: any[]
29
+ linkedGroups: any[]
30
+ }
31
+
32
+ export interface SendAlbumMediaItem {
33
+ image?: any
34
+ video?: any
35
+ caption?: string
36
+ [key: string]: any
37
+ }
38
+
39
+
40
+ export interface VoipConfig {
41
+ autoInit?: boolean
42
+ [key: string]: any
43
+ }
44
+
45
+ export interface CallOptions {
46
+ durationMs?: number
47
+ audioSource?: string
48
+ isVideo?: boolean
49
+ }
50
+
51
+ export interface CallPeerInfo {
52
+ phoneNumber?: string
53
+ pnJid?: string
54
+ lidJid?: string
55
+ displayName?: string
56
+ }
57
+
58
+ export interface CallTelemetryStats {
59
+ rttMs?: number
60
+ packetLossPct?: number
61
+ jitterMs?: number
62
+ rxAudioPackets?: number
63
+ txAudioPackets?: number
64
+ rxVideoFrames?: number
65
+ txVideoFrames?: number
66
+ [key: string]: any
67
+ }
68
+
69
+ export interface VideoFrameEvent {
70
+ frameBuffer: Buffer | Uint8Array
71
+ width: number
72
+ height: number
73
+ format?: number
74
+ }
75
+
76
+ export interface VADSpeakingEvent {
77
+ volumeDbfs: number
78
+ rms: number
79
+ }
80
+
81
+ export interface VADSilenceEvent {
82
+ durationMs: number
83
+ }
84
+
85
+ export interface IncomingCall {
86
+ readonly id: string
87
+ readonly callId: string
88
+ readonly from: string
89
+ readonly chatId?: string
90
+ readonly isVideo: boolean
91
+ readonly isGroup: boolean
92
+ readonly date: Date
93
+ accept(options?: CallOptions): Promise<ActiveCall>
94
+ reject(reason?: string | number): Promise<void>
95
+ }
96
+
97
+ export interface ActiveCall {
98
+ readonly callId: string
99
+ readonly isVideo: boolean
100
+ readonly state: number
101
+ readonly direction?: 'outbound' | 'inbound'
102
+ readonly peer?: CallPeerInfo
103
+ readonly caller?: CallPeerInfo
104
+ end(): void
105
+ mute(muted: boolean): void
106
+ waitForEnd(): Promise<string>
107
+ pushAudio(pcm: Float32Array): void
108
+ pushVideo(frameBuffer: ArrayBuffer | Uint8Array | Buffer, width: number, height: number): void
109
+ pushVideoRgba(rgbaBuffer: ArrayBuffer | Uint8Array | Buffer, width: number, height: number): void
110
+ readonly isSharingScreen?: boolean
111
+ startScreenShare(options?: { fps?: number; width?: number; height?: number; screen?: string }): any
112
+ stopScreenShare(): void
113
+ getRxStream(options?: { format?: 'float32' | 'pcm_s16le' }): import('stream').Readable
114
+ getTxStream(options?: { format?: 'float32' | 'pcm_s16le' }): import('stream').Readable
115
+ recordToFile(filePath: string, options?: { source?: 'rx' | 'tx' | 'both', channels?: number }): Promise<void>
116
+ stopRecording(): void
117
+ on(event: 'ringing' | 'connected', listener: () => void): this
118
+ on(event: 'ended', listener: (reason: string) => void): this
119
+ on(event: 'audio' | 'audio_out' | 'audio:out', listener: (pcm: Float32Array) => void): this
120
+ on(event: 'video', listener: (frame: VideoFrameEvent) => void): this
121
+ on(event: 'video_out' | 'video:out', listener: (frame: Omit<VideoFrameEvent, 'format'>) => void): this
122
+ on(event: 'speaking', listener: (data: VADSpeakingEvent) => void): this
123
+ on(event: 'silence', listener: (data: VADSilenceEvent) => void): this
124
+ on(event: 'stats' | 'telemetry', listener: (stats: CallTelemetryStats) => void): this
125
+ on(event: string, listener: (...args: any[]) => void): this
126
+ }
127
+
128
+ export type CallSession = ActiveCall
129
+
130
+ export interface UserFacingSocketConfig {
131
+ version?: [number, number, number]
132
+ browser?: [string, string, string]
133
+ waWebSocketUrl?: string
134
+ connectTimeoutMs?: number
135
+ keepAliveIntervalMs?: number
136
+ logger?: any
137
+ printQRInTerminal?: boolean
138
+ emitOwnEvents?: boolean
139
+ defaultQueryTimeoutMs?: number
140
+ customUploadHosts?: string[]
141
+ retryRequestDelayMs?: number
142
+ maxMsgRetryCount?: number
143
+ fireInitQueries?: boolean
144
+ auth?: AuthenticationState
145
+ markOnlineOnConnect?: boolean
146
+ syncFullHistory?: boolean
147
+ patchMessageBeforeSending?: (msg: proto.IMessage) => proto.IMessage | Promise<proto.IMessage>
148
+ shouldSyncHistoryMessage?: (msg: proto.IHistorySyncNotification) => boolean
149
+ shouldIgnoreJid?: (jid: string) => boolean
150
+ linkPreviewImageThumbnailWidth?: number
151
+ transactionOpts?: { maxCommitRetries: number; delayBetweenTriesMs: number }
152
+ generateHighQualityLinkPreview?: boolean
153
+ enableAutoSessionRecreation?: boolean
154
+ enableRecentMessageCache?: boolean
155
+ enableMessageQueue?: boolean
156
+ messageQueueTtlMs?: number
157
+ maxReconnectAttempts?: number
158
+ enableGroupCache?: boolean
159
+ cachedGroupMetadata?: (jid: string) => Promise<GroupMetadata | undefined>
160
+ plugins?: any[]
161
+ voip?: boolean | VoipConfig
162
+ [key: string]: any
163
+ }
164
+
165
+ export interface WASocket {
166
+ type: 'md'
167
+ // VoIP Calling (Direct WebAssembly Multi-Device)
168
+ call(phoneNumber: string, options?: CallOptions): Promise<ActiveCall>
169
+ callVideo(phoneNumber: string, options?: Omit<CallOptions, 'isVideo'>): Promise<ActiveCall>
170
+ acceptCall(callId: string, from?: string, options?: CallOptions): Promise<ActiveCall>
171
+ answerCall(callId: string, from?: string, options?: CallOptions): Promise<ActiveCall>
172
+ activeCall: ActiveCall | null
173
+ clearActiveCall(): void
174
+ rejectCall(callId: string, from?: string, reason?: string | number): Promise<void>
175
+ voip: {
176
+ getEngine(): Promise<any>
177
+ destroy(): void
178
+ }
179
+
180
+ ws: any
181
+ ev: BaileysEventEmitter
182
+ authState: AuthenticationState
183
+ user: Contact | undefined
184
+ plugins: PluginManager
185
+
186
+ // Plugin & Middleware system
187
+ use(plugin: any, options?: any): WASocket
188
+ registerMiddleware(hook: 'beforeSendMessage' | 'afterSendMessage' | 'beforeRecvMessage' | 'afterRecvMessage' | 'connectionUpdate', fn: Function): () => void
189
+ hasPlugin(name: string): boolean
190
+ listPlugins(): Array<{ name: string; registeredAt: number; version: string; description: string }>
191
+
192
+ // Connection & Auth
193
+ waitForConnectionUpdate(check: (u: Partial<ConnectionState>) => boolean | undefined, timeoutMs?: number): Promise<void>
194
+ end(error: Error | undefined): void
195
+ logout(msg?: string): Promise<void>
196
+ requestPairingCode(phoneNumber: string): Promise<string>
197
+ repairSession(jid: string): Promise<void>
198
+ onWhatsApp(...phoneNumber: string[]): Promise<{ jid: string; exists: boolean }[] | undefined>
199
+
200
+ // Presence & Status
201
+ sendPresenceUpdate(type: 'available' | 'unavailable' | 'composing' | 'recording' | 'paused', toJid?: string): Promise<void>
202
+ presenceSubscribe(toJid: string): Promise<void>
203
+
204
+ // Profile & User
205
+ profilePictureUrl(jid: string, type?: 'image' | 'preview', timeoutMs?: number): Promise<string | undefined>
206
+ updateProfilePicture(jid: string, content: any): Promise<void>
207
+ removeProfilePicture(jid: string): Promise<void>
208
+ fetchStatus(jid: string): Promise<{ status: string | undefined; setAt: Date } | undefined>
209
+ updateProfileStatus(status: string): Promise<void>
210
+ updateProfileName(name: string): Promise<void>
211
+
212
+ // Cross-JID / LID Architecture
213
+ toPn(jid: string, fetchIfMissing?: boolean): Promise<string | null>
214
+ toLid(jid: string, fetchIfMissing?: boolean): Promise<string | null>
215
+ resolveJid(jid: string, fetchIfMissing?: boolean): Promise<{ pn: string | null; lid: string | null; jid: string | null }>
216
+ storeLidPnMapping(pn: string, lid: string): Promise<boolean>
217
+
218
+ // Messaging
219
+ sendMessage(jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions & { mentionAll?: boolean; adminsOnly?: boolean; excludeMe?: boolean }): Promise<WAMessage | undefined>
220
+ sendAlbumMessage(jid: string, medias: SendAlbumMediaItem[], options?: MiscMessageGenerationOptions): Promise<WAMessage[]>
221
+ groupSendMentionAll(jid: string, content: string | AnyMessageContent, options?: { adminsOnly?: boolean; excludeMe?: boolean }): Promise<WAMessage | undefined>
222
+ relayMessage(jid: string, message: proto.IMessage, options: any): Promise<string>
223
+ readMessages(keys: WAMessageKey[]): Promise<void>
224
+ star(jid: string, messages: { id: string; fromMe?: boolean }[], star: boolean): Promise<void>
225
+ sendStatusMentions(content: any, jids?: string[]): Promise<WAMessage>
226
+ reactToStatus(key: WAMessageKey, reaction?: string): Promise<string>
227
+ sendEventResponse(jid: string, eventCreationMessageKey: WAMessageKey, response: string | number, extraGuestCount?: number): Promise<WAMessage | undefined>
228
+ cancelEvent(jid: string, eventKey: WAMessageKey): Promise<WAMessage | undefined>
229
+
230
+ // Calls (VoIP & Web Calling)
231
+ voip: any
232
+ getVoIPRelayTokens(): Promise<any>
233
+ offerCall(toJid: string, isVideo?: boolean): Promise<{ id: string, to: string, callKey: Buffer }>
234
+ acceptCall(callId: string, callFrom: string, options?: { isVideo?: boolean, audioRate?: string }): Promise<void>
235
+ rejectCall(callId: string, callFrom: string, reason?: string | number): Promise<void>
236
+ terminateCall(callId: string, callFrom: string, reason?: string): Promise<void>
237
+
238
+ // Chats & Contacts
239
+ chatModify(mod: any, jid: string): Promise<void>
240
+ updateFavorite(jid: string, favorite: boolean): Promise<void>
241
+ updateChatNote(jid: string, note: string): Promise<void>
242
+ removeChatNote(jid: string): Promise<void>
243
+ addOrEditContact(contact: any): Promise<void>
244
+ removeContact(jid: string): Promise<void>
245
+
246
+ // Groups
247
+ groupMetadata(jid: string): Promise<GroupMetadata>
248
+ groupCreate(subject: string, participants: string[]): Promise<GroupMetadata>
249
+ groupLeave(id: string): Promise<void>
250
+ groupUpdateSubject(jid: string, subject: string): Promise<void>
251
+ groupUpdateDescription(jid: string, description: string): Promise<void>
252
+ groupInviteCode(jid: string): Promise<string | undefined>
253
+ groupRevokeInvite(jid: string): Promise<string | undefined>
254
+ groupAcceptInvite(code: string): Promise<string | undefined>
255
+ groupGetInviteInfo(code: string): Promise<GroupMetadata>
256
+ groupParticipantsUpdate(jid: string, participants: string[], action: 'add' | 'remove' | 'demote' | 'promote'): Promise<any[]>
257
+ groupSettingUpdate(jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked'): Promise<void>
258
+ groupMemberAddMode(jid: string, mode: 'admin_add' | 'all_member_add'): Promise<void>
259
+ groupJoinApprovalMode(jid: string, mode: 'on' | 'off' | boolean): Promise<void>
260
+ groupMembershipApprovalMode(jid: string, mode: 'on' | 'off' | boolean): Promise<void>
261
+ groupRequestParticipantsList(jid: string): Promise<any[]>
262
+ groupRequestParticipantsUpdate(jid: string, participants: string[], action: 'approve' | 'reject'): Promise<any[]>
263
+ groupApprovePendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
264
+ groupRejectPendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
265
+ groupUpdatePermissions(jid: string, policies: GroupPermissionsPolicies): Promise<Record<string, any>>
266
+ groupGetAdminJids(jid: string): Promise<string[]>
267
+ groupGetParticipants(jid: string): Promise<any[]>
268
+ groupToggleEphemeral(jid: string, ephemeralExpiration: number): Promise<void>
269
+
270
+ // Communities v2
271
+ communityCreate(subject: string, body?: string): Promise<GroupMetadata | null>
272
+ communityCreateGroup(subject: string, participants: string[], parentCommunityJid: string): Promise<GroupMetadata | null>
273
+ communityLinkGroup(groupJid: string, parentCommunityJid: string): Promise<void>
274
+ communityUnlinkGroup(groupJid: string, parentCommunityJid: string): Promise<void>
275
+ communityFetchLinkedGroups(jid: string): Promise<any>
276
+ communityFetchSubGroups(jid: string): Promise<GroupSubGroupsResult>
277
+ communityMembershipApprovalMode(jid: string, mode: 'on' | 'off' | boolean): Promise<void>
278
+ communityApprovePendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
279
+ communityRejectPendingParticipants(jid: string, participants: string | string[]): Promise<any[]>
280
+ communityUpdatePermissions(jid: string, policies: GroupPermissionsPolicies): Promise<Record<string, any>>
281
+
282
+ // Newsletters v2
283
+ newsletterCreate(name: string, description?: string, picture?: Buffer): Promise<any>
284
+ newsletterMetadata(type: 'invite' | 'jid', key: string): Promise<any>
285
+ newsletterFetchMessages(jid: string, count: number, since?: number): Promise<any[]>
286
+ newsletterFetchMessage(jid: string, messageServerId: string | number): Promise<any>
287
+ newsletterFetchReactions(jid: string, messageServerId: string | number): Promise<any[]>
288
+ newsletterToggleMute(jid: string, mute: boolean): Promise<void>
289
+ newsletterFollow(jid: string): Promise<void>
290
+ newsletterUnfollow(jid: string): Promise<void>
291
+ newsletterSubscribers(jid: string): Promise<any>
292
+ newsletterSubscribed(): Promise<any[]>
293
+ newsletterUpdate(jid: string, updates: any): Promise<any>
294
+ newsletterUpdateName(jid: string, name: string): Promise<any>
295
+ newsletterUpdateDescription(jid: string, description: string): Promise<any>
296
+ newsletterUpdatePicture(jid: string, content: any): Promise<any>
297
+ newsletterRemovePicture(jid: string): Promise<any>
298
+ newsletterReactMessage(jid: string, serverId: string | number, reaction?: string): Promise<void>
299
+ newsletterAdminCount(jid: string): Promise<number>
300
+ newsletterChangeOwner(jid: string, newOwnerJid: string): Promise<void>
301
+ newsletterDelete(jid: string): Promise<void>
302
+
303
+ // Labels & Quick Replies
304
+ createLabel(name: string, color?: number): Promise<any>
305
+ updateLabel(labelId: string, name: string, color?: number): Promise<any>
306
+ deleteLabel(labelId: string): Promise<any>
307
+ addChatLabel(jid: string, labelId: string): Promise<void>
308
+ removeChatLabel(jid: string, labelId: string): Promise<void>
309
+ addMessageLabel(jid: string, messageId: string, labelId: string): Promise<void>
310
+ removeMessageLabel(jid: string, messageId: string, labelId: string): Promise<void>
311
+ addOrEditQuickReply(quickReply: any): Promise<void>
312
+ removeQuickReply(id: string): Promise<void>
313
+
314
+ // Privacy
315
+ fetchBlocklist(): Promise<string[]>
316
+ updateBlockStatus(jid: string, action: 'block' | 'unblock'): Promise<void>
317
+ fetchPrivacySettings(force?: boolean): Promise<any>
318
+ updateLastSeenPrivacy(value: 'all' | 'contacts' | 'contact_blacklist' | 'none'): Promise<void>
319
+ updateOnlinePrivacy(value: 'all' | 'match_last_seen'): Promise<void>
320
+ updateReadReceiptsPrivacy(value: 'all' | 'none'): Promise<void>
321
+ updateProfilePicturePrivacy(value: 'all' | 'contacts' | 'contact_blacklist' | 'none'): Promise<void>
322
+ updateStatusPrivacy(value: 'all' | 'contacts' | 'contact_blacklist' | 'none'): Promise<void>
323
+ updateGroupsAddPrivacy(value: 'all' | 'contacts' | 'contact_blacklist'): Promise<void>
324
+ updateCallPrivacy(value: 'all' | 'known'): Promise<void>
325
+
326
+ // Business
327
+ getCatalog(opts: { jid?: string; limit?: number; cursor?: string }): Promise<any>
328
+ getCollections(jid?: string, limit?: number): Promise<any>
329
+ getOrderDetails(orderId: string, tokenBase64: string): Promise<any>
330
+ getProduct(jid: string, productId: string): Promise<any>
331
+ productCreate(create: any): Promise<any>
332
+ productUpdate(productId: string, update: any): Promise<any>
333
+ productDelete(productIds: string[]): Promise<{ deleted: number }>
334
+ updateBussinesProfile(args: any): Promise<void>
335
+ updateCoverPhoto(file: any): Promise<string>
336
+ removeCoverPhoto(id: string): Promise<void>
337
+
338
+ [key: string]: any
339
+ }
340
+
341
+ export interface InMemoryStoreConfig {
342
+ logger?: any
343
+ chatKey?: any
344
+ labelAssociationKey?: any
345
+ maxMessagesPerChat?: number
346
+ [key: string]: any
347
+ }
348
+
349
+ export interface InMemoryStore {
350
+ chats: any
351
+ messages: Record<string, any>
352
+ contacts: Record<string, Contact>
353
+ groupMetadata: Record<string, GroupMetadata>
354
+ presences: Record<string, any>
355
+ state: Partial<ConnectionState>
356
+ labels: any
357
+ labelAssociations: any
358
+ bind(ev: BaileysEventEmitter): void
359
+ loadMessage(jid: string, id: string): Promise<WAMessage | undefined>
360
+ loadMessages(jid: string, count: number, cursor?: any): Promise<WAMessage[]>
361
+ mostRecentMessage(jid: string): Promise<WAMessage | undefined>
362
+ getContact(jid: string): Contact | undefined
363
+ getChat(jid: string): any | undefined
364
+ pruneMessages(jid?: string, keepLastN?: number): number
365
+ clear(chatId?: string): void
366
+ getMessageCount(jid?: string): number
367
+ writeToFile(path: string): void
368
+ readFromFile(path: string): void
369
+ toJSON(): any
370
+ fromJSON(json: any): void
371
+ }
372
+
373
+ export declare function makeInMemoryStore(config?: InMemoryStoreConfig): InMemoryStore
374
+ export declare function createGroupMetadataCache(ttlMs?: number, maxSize?: number): {
375
+ (jid: string): Promise<GroupMetadata | undefined>
376
+ set(jid: string, metadata: GroupMetadata): void
377
+ delete(jid: string): boolean
378
+ clear(): void
379
+ }
380
+
381
+ export declare function makeWASocket(config?: UserFacingSocketConfig): WASocket
382
+ export default makeWASocket