@itznomo/baileys 0.0.0-stage → 0.0.1

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 (124) hide show
  1. package/BUTTONS.md +153 -0
  2. package/Example/call-bot.mjs +38 -0
  3. package/Example/example.mjs +36 -0
  4. package/Example/full-bot-commands.mjs +319 -0
  5. package/Example/full-bot.mjs +77 -0
  6. package/LICENSE +21 -0
  7. package/README.md +543 -2
  8. package/WAProto/@dnuzi +1 -0
  9. package/WAProto/index.d.ts +15932 -0
  10. package/WAProto/index.js +113300 -0
  11. package/assets/banner.svg +17 -0
  12. package/assets/devider.svg +1 -0
  13. package/assets/features.svg +21 -0
  14. package/docs/CALLS.md +106 -0
  15. package/docs/FEATURES.md +1152 -0
  16. package/engine-requirements.js +19 -0
  17. package/index.d.ts +815 -0
  18. package/package.json +51 -4
  19. package/src/binary/wa-binary-constants.js +1300 -0
  20. package/src/binary/wa-binary.js +627 -0
  21. package/src/constants.js +147 -0
  22. package/src/defaults.js +106 -0
  23. package/src/foundation/ai-rich.js +654 -0
  24. package/src/foundation/audio-duration.js +470 -0
  25. package/src/foundation/audio-samples.js +250 -0
  26. package/src/foundation/boom.js +39 -0
  27. package/src/foundation/builders.js +851 -0
  28. package/src/foundation/cache.js +134 -0
  29. package/src/foundation/concurrency.js +69 -0
  30. package/src/foundation/curve25519.js +189 -0
  31. package/src/foundation/image-thumb.js +65 -0
  32. package/src/foundation/link-preview.js +278 -0
  33. package/src/foundation/logger.js +78 -0
  34. package/src/foundation/long.js +130 -0
  35. package/src/foundation/performance.js +385 -0
  36. package/src/foundation/protobuf-minimal.js +587 -0
  37. package/src/foundation/qrcode-terminal.js +273 -0
  38. package/src/foundation/sql-database.js +716 -0
  39. package/src/foundation/wa-crypto.js +47 -0
  40. package/src/foundation/zip.js +108 -0
  41. package/src/index.js +67 -0
  42. package/src/signal/libsignal.js +996 -0
  43. package/src/signal/signal-group.js +455 -0
  44. package/src/signal/signal-repository.js +635 -0
  45. package/src/socket/business-communities.js +811 -0
  46. package/src/socket/chats.js +702 -0
  47. package/src/socket/groups-newsletter.js +524 -0
  48. package/src/socket/messages-recv.js +1815 -0
  49. package/src/socket/messages-send.js +1526 -0
  50. package/src/socket/socket-builder.js +131 -0
  51. package/src/socket/socket-core.js +913 -0
  52. package/src/socket/usync.js +287 -0
  53. package/src/socket-client/native-websocket.js +344 -0
  54. package/src/socket-client/websocket-client.js +170 -0
  55. package/src/utils/auth-state-core.js +731 -0
  56. package/src/utils/auth-state-storage.js +594 -0
  57. package/src/utils/chat-sync.js +1046 -0
  58. package/src/utils/check-status.js +159 -0
  59. package/src/utils/cstoken.js +17 -0
  60. package/src/utils/media.js +807 -0
  61. package/src/utils/message-compose.js +1747 -0
  62. package/src/utils/message-processing.js +912 -0
  63. package/src/utils/modern-messages.js +435 -0
  64. package/src/utils/nomo-buttons.js +138 -0
  65. package/src/utils/nomo-commands.js +168 -0
  66. package/src/utils/spam-report-utils.js +136 -0
  67. package/src/utils/use-keyv-auth-state.js +307 -0
  68. package/src/utils/username.js +19 -0
  69. package/src/utils/wa-protocol-core.js +1227 -0
  70. package/src/voip/WaVoipCoordinator.js +158 -0
  71. package/src/voip/app-data/WaAppDataStream.js +193 -0
  72. package/src/voip/app-data/protocol.js +172 -0
  73. package/src/voip/auto.js +139 -0
  74. package/src/voip/bytes.js +63 -0
  75. package/src/voip/call/WaCallManager.js +442 -0
  76. package/src/voip/call/WaCallMediaSession.js +1727 -0
  77. package/src/voip/call/call-state.js +203 -0
  78. package/src/voip/crypto/encryption.js +13 -0
  79. package/src/voip/crypto/primitives.js +21 -0
  80. package/src/voip/crypto/rtcp.js +66 -0
  81. package/src/voip/crypto/srtp.js +180 -0
  82. package/src/voip/crypto/ssrc.js +15 -0
  83. package/src/voip/index.js +730 -0
  84. package/src/voip/media/WaAudioEngine.js +486 -0
  85. package/src/voip/media/WaVideoEngine.js +275 -0
  86. package/src/voip/media/audio-codec.js +0 -0
  87. package/src/voip/media/audio-reorder.js +107 -0
  88. package/src/voip/media/h264.js +246 -0
  89. package/src/voip/media/mlow-codec.js +465 -0
  90. package/src/voip/media/rtcp.js +68 -0
  91. package/src/voip/media/rtp.js +242 -0
  92. package/src/voip/protobuf.js +30 -0
  93. package/src/voip/relay/WaManualRelay.js +609 -0
  94. package/src/voip/relay/datachannel/pre-negotiated.js +25 -0
  95. package/src/voip/relay/dtls/aead.js +46 -0
  96. package/src/voip/relay/dtls/cert-builder.js +102 -0
  97. package/src/voip/relay/dtls/der.js +98 -0
  98. package/src/voip/relay/dtls/ecdhe.js +37 -0
  99. package/src/voip/relay/dtls/handshake-framing.js +100 -0
  100. package/src/voip/relay/dtls/handshake-messages.js +158 -0
  101. package/src/voip/relay/dtls/handshake.js +582 -0
  102. package/src/voip/relay/dtls/prf.js +39 -0
  103. package/src/voip/relay/dtls/record.js +56 -0
  104. package/src/voip/relay/relay-ack.js +141 -0
  105. package/src/voip/relay/sctp/association.js +434 -0
  106. package/src/voip/relay/sctp/crc32c.js +21 -0
  107. package/src/voip/relay/sctp/wire.js +226 -0
  108. package/src/voip/relay/stun.js +463 -0
  109. package/src/voip/shim/baileys-resolve.js +7 -0
  110. package/src/voip/shim/core.js +66 -0
  111. package/src/voip/shim/crypto.js +6 -0
  112. package/src/voip/shim/proto.js +10 -0
  113. package/src/voip/shim/protocol.js +130 -0
  114. package/src/voip/shim/transport.js +82 -0
  115. package/src/voip/shim/util.js +207 -0
  116. package/src/voip/signaling/bridge.js +102 -0
  117. package/src/voip/signaling/screen-share.js +60 -0
  118. package/src/voip/signaling/signaling.js +491 -0
  119. package/src/voip/types.js +69 -0
  120. package/src/voip/voip-deps.js +243 -0
  121. package/src/voip/voipClient.js +314 -0
  122. package/src/wam/wam-constants.js +22852 -0
  123. package/src/wam/wam.js +146 -0
  124. package/voip.d.ts +144 -0
package/index.d.ts ADDED
@@ -0,0 +1,815 @@
1
+ // Hand-written TypeScript declarations for @nomo/ballieys.
2
+ // The most used API is typed. Everything else the package exports is declared as `any` at the bottom of this file
3
+ // (generated by scripts/gen-types.mjs), so imports never fail to compile.
4
+ import { proto } from './WAProto/index.js'
5
+ export { proto }
6
+
7
+ /* ------------------------------------------------------------------ basic types */
8
+
9
+ export type WAMessage = proto.IWebMessageInfo
10
+ export type WAMessageKey = proto.IMessageKey
11
+ export type WAProtoMessage = proto.IMessage
12
+ export type MediaInput = { url: string } | Buffer | { stream: NodeJS.ReadableStream }
13
+
14
+ export interface NativeFlowButton {
15
+ name: string
16
+ buttonParamsJson: string
17
+ }
18
+
19
+ export interface ListRow {
20
+ id: string
21
+ title: string
22
+ header?: string
23
+ description?: string
24
+ }
25
+ export interface ListSection {
26
+ title?: string
27
+ highlightLabel?: string
28
+ rows: ListRow[]
29
+ }
30
+
31
+ export interface ButtonReply {
32
+ kind: 'buttons' | 'template' | 'list' | 'native_flow'
33
+ id: string
34
+ displayText?: string
35
+ name?: string
36
+ }
37
+
38
+ /** Content for `sock.sendMessage(jid, content, options)`. Common fields are typed, any other field is allowed. */
39
+ export interface AnyMessageContent {
40
+ text?: string
41
+ caption?: string
42
+ title?: string
43
+ subtitle?: string
44
+ footer?: string
45
+ image?: MediaInput
46
+ video?: MediaInput
47
+ audio?: MediaInput
48
+ document?: MediaInput
49
+ sticker?: MediaInput
50
+ mimetype?: string
51
+ fileName?: string
52
+ ptt?: boolean
53
+ gifPlayback?: boolean
54
+ viewOnce?: boolean
55
+ spoiler?: boolean
56
+ ptv?: boolean
57
+ mentions?: string[]
58
+ react?: { text: string; key: WAMessageKey }
59
+ delete?: WAMessageKey
60
+ edit?: WAMessageKey
61
+ forward?: WAMessage
62
+ location?: { degreesLatitude: number; degreesLongitude: number; name?: string; address?: string }
63
+ contacts?: { displayName?: string; contacts: { displayName: string; vcard: string }[] }
64
+ poll?: { name: string; values: string[]; selectableCount?: number; [key: string]: any }
65
+ event?: { name: string; description?: string; startDate: Date; [key: string]: any }
66
+ interactiveButtons?: NativeFlowButton[]
67
+ nativeFlow?: { text?: string; id?: string; url?: string; copy?: string; call?: string; sections?: ListSection[] }[]
68
+ buttons?: { buttonId: string; buttonText: { displayText: string }; type?: number }[]
69
+ templateButtons?: { text: string; id?: string; url?: string; call?: string }[]
70
+ sections?: { title: string; rows: { title: string; rowId: string; description?: string }[] }[]
71
+ buttonText?: string
72
+ cards?: { image?: MediaInput; video?: MediaInput; title?: string; body?: string; caption?: string; footer?: string; buttons?: NativeFlowButton[]; nativeFlow?: any[]; [key: string]: any }[]
73
+ widget?: { align?: string; fallback?: string; items: Record<string, any>[] }
74
+ aiRich?: Record<string, any>
75
+ album?: ({ image: MediaInput; caption?: string } | { video: MediaInput; caption?: string })[]
76
+ [key: string]: any
77
+ }
78
+
79
+ export interface MiscMessageGenerationOptions {
80
+ quoted?: WAMessage
81
+ ephemeralExpiration?: number
82
+ messageId?: string
83
+ statusJidList?: string[]
84
+ [key: string]: any
85
+ }
86
+
87
+ /* ------------------------------------------------------------------ auth */
88
+
89
+ export interface AuthenticationState {
90
+ creds: any
91
+ keys: any
92
+ }
93
+ export interface AuthStateResult {
94
+ state: AuthenticationState
95
+ saveCreds: () => Promise<void>
96
+ }
97
+ export function useMultiFileAuthState(folder: string): Promise<AuthStateResult>
98
+ export function useSingleFileAuthState(file: string): Promise<AuthStateResult>
99
+ export function useSqliteAuthState(options: { dbPath?: string; database?: any }): Promise<AuthStateResult>
100
+ export function useMongoDBAuthState(
101
+ optionsOrCollection: { url?: string; uri?: string; collection?: any; db?: any; client?: any; dbName?: string; collectionName?: string; sessionId?: string; mongoOptions?: any } | any,
102
+ sessionId?: string
103
+ ): Promise<AuthStateResult>
104
+ export function useKeyvAuthState(sessionId: string, stores: string | Record<string, string | any>): Promise<AuthStateResult>
105
+
106
+ /* ------------------------------------------------------------------ socket */
107
+
108
+ export type PerformanceMode = 'balanced' | 'high' | 'low-memory'
109
+
110
+ export interface Logger {
111
+ level: string
112
+ info(...args: any[]): void
113
+ warn(...args: any[]): void
114
+ error(...args: any[]): void
115
+ debug(...args: any[]): void
116
+ trace(...args: any[]): void
117
+ child?(bindings: Record<string, any>): Logger
118
+ [key: string]: any
119
+ }
120
+
121
+ export interface SocketConfig {
122
+ auth: AuthenticationState
123
+ printQRInTerminal?: boolean
124
+ performanceMode?: PerformanceMode
125
+ browser?: [string, string, string]
126
+ syncFullHistory?: boolean
127
+ markOnlineOnConnect?: boolean
128
+ logger?: Logger
129
+ getMessage?: (key: WAMessageKey) => Promise<WAProtoMessage | undefined>
130
+ connectTimeoutMs?: number
131
+ keepAliveIntervalMs?: number
132
+ defaultQueryTimeoutMs?: number
133
+ qrTimeout?: number
134
+ dedupTTL?: number
135
+ dedupMax?: number
136
+ groupMetadataCacheTTL?: number
137
+ [key: string]: any
138
+ }
139
+
140
+ export interface ConnectionState {
141
+ connection?: 'open' | 'connecting' | 'close'
142
+ lastDisconnect?: { error?: Error & { output?: { statusCode?: number }; data?: any }; date: Date }
143
+ qr?: string
144
+ isNewLogin?: boolean
145
+ receivedPendingNotifications?: boolean
146
+ [key: string]: any
147
+ }
148
+
149
+ export interface BaileysEventMap {
150
+ 'connection.update': Partial<ConnectionState>
151
+ 'creds.update': Partial<any>
152
+ 'messages.upsert': { messages: WAMessage[]; type: 'notify' | 'append' | string; requestId?: string }
153
+ 'messages.update': { key: WAMessageKey; update: Partial<WAMessage> }[]
154
+ 'messages.delete': any
155
+ 'messages.reaction': { key: WAMessageKey; reaction: proto.IReaction }[]
156
+ 'groups.update': Partial<GroupMetadata>[]
157
+ 'group-participants.update': { id: string; author: string; participants: any[]; action: 'add' | 'remove' | 'promote' | 'demote' | 'modify' | string }
158
+ 'presence.update': any
159
+ 'call': any[]
160
+ [event: string]: any
161
+ }
162
+
163
+ export interface BaileysEventEmitter {
164
+ on<K extends keyof BaileysEventMap>(event: K, listener: (arg: BaileysEventMap[K]) => void | Promise<void>): void
165
+ off<K extends keyof BaileysEventMap>(event: K, listener: (arg: BaileysEventMap[K]) => void | Promise<void>): void
166
+ removeAllListeners<K extends keyof BaileysEventMap>(event: K): void
167
+ [key: string]: any
168
+ }
169
+
170
+ export interface GroupParticipant {
171
+ id: string
172
+ lid?: string
173
+ phoneNumber?: string
174
+ admin?: 'admin' | 'superadmin' | null
175
+ [key: string]: any
176
+ }
177
+ export interface GroupMetadata {
178
+ id: string
179
+ subject: string
180
+ owner?: string
181
+ desc?: string
182
+ creation?: number
183
+ size?: number
184
+ announce?: boolean
185
+ restrict?: boolean
186
+ participants: GroupParticipant[]
187
+ [key: string]: any
188
+ }
189
+
190
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote'
191
+ export type GroupSetting = 'announcement' | 'not_announcement' | 'locked' | 'unlocked'
192
+ export type PrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none'
193
+
194
+ export interface WASocket {
195
+ ev: BaileysEventEmitter
196
+ user?: { id: string; lid?: string; name?: string; [key: string]: any }
197
+ authState: AuthenticationState
198
+ ws: any
199
+ logger: Logger
200
+
201
+ sendMessage(jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions): Promise<WAMessage | undefined>
202
+ relayMessage(jid: string, message: WAProtoMessage, options?: Record<string, any>): Promise<string>
203
+ readMessages(keys: WAMessageKey[]): Promise<void>
204
+ sendPresenceUpdate(type: 'unavailable' | 'available' | 'composing' | 'recording' | 'paused', toJid?: string): Promise<void>
205
+ presenceSubscribe(jid: string): Promise<void>
206
+ requestPairingCode(phoneNumber: string, customCode?: string): Promise<string>
207
+ logout(msg?: string): Promise<void>
208
+ end(error?: Error): void
209
+ onWhatsApp(...jids: string[]): Promise<{ jid: string; exists: boolean; lid?: string }[] | undefined>
210
+ profilePictureUrl(jid: string, type?: 'preview' | 'image'): Promise<string | undefined>
211
+ updateBlockStatus(jid: string, action: 'block' | 'unblock'): Promise<void>
212
+ fetchBlocklist(): Promise<string[]>
213
+ fetchStatus(...jids: string[]): Promise<any>
214
+
215
+ groupMetadata(jid: string): Promise<GroupMetadata>
216
+ groupFetchAllParticipating(): Promise<Record<string, GroupMetadata>>
217
+ groupCreate(subject: string, participants: string[]): Promise<GroupMetadata>
218
+ groupLeave(jid: string): Promise<void>
219
+ groupUpdateSubject(jid: string, subject: string): Promise<void>
220
+ groupUpdateDescription(jid: string, description?: string): Promise<void>
221
+ groupParticipantsUpdate(jid: string, participants: string[], action: ParticipantAction): Promise<{ status: string; jid: string; content?: any }[]>
222
+ groupSettingUpdate(jid: string, setting: GroupSetting): Promise<void>
223
+ groupInviteCode(jid: string): Promise<string | undefined>
224
+ groupRevokeInvite(jid: string): Promise<string | undefined>
225
+ groupAcceptInvite(code: string): Promise<string | undefined>
226
+ groupToggleEphemeral(jid: string, expiration: number): Promise<void>
227
+
228
+ updateLastSeenPrivacy(value: PrivacyValue): Promise<void>
229
+ updateOnlinePrivacy(value: 'all' | 'match_last_seen'): Promise<void>
230
+ updateProfilePicturePrivacy(value: PrivacyValue): Promise<void>
231
+ updateStatusPrivacy(value: PrivacyValue): Promise<void>
232
+ updateReadReceiptsPrivacy(value: 'all' | 'none'): Promise<void>
233
+ updateGroupsAddPrivacy(value: PrivacyValue): Promise<void>
234
+ updateDefaultDisappearingMode(duration: number): Promise<void>
235
+ updateProfileName(name: string): Promise<void>
236
+ updateProfileStatus(status: string): Promise<void>
237
+ reportSpam(jid: string, options?: { reason?: 'spam' | 'inappropriate' | 'offensive'; block?: boolean; deleteChat?: boolean }): Promise<any>
238
+ setChatTheme(jid: string, themeId: string): Promise<any>
239
+ setChatThemeColor(jid: string, options: { backgroundLightArgb: number; backgroundDarkArgb: number; isDoodleEnabled?: boolean }): Promise<any>
240
+
241
+ sendStatus(content: AnyMessageContent, options?: { statusJidList?: string[]; [key: string]: any }): Promise<any>
242
+ sendStatusMentions(jid: string, content: AnyMessageContent): Promise<any>
243
+
244
+ newsletterCreate(name: string, description?: string): Promise<any>
245
+ newsletterMetadata(type: 'jid' | 'invite', key: string): Promise<any>
246
+ newsletterReactMessage(jid: string, serverId: string, reaction?: string): Promise<void>
247
+
248
+ poll(): PollBuilder
249
+ event(): EventBuilder
250
+ album(): AlbumBuilder
251
+ aiRich(): AIRichBuilder
252
+
253
+ groupMetadataCache: any
254
+ [key: string]: any
255
+ }
256
+
257
+ export function makeWASocket(config: SocketConfig): WASocket
258
+ export default makeWASocket
259
+
260
+ /* ------------------------------------------------------------------ builders */
261
+
262
+ export class Button {
263
+ constructor(sock: WASocket)
264
+ setBody(text: string): this
265
+ setFooter(text: string): this
266
+ reply(text: string, id: string): this
267
+ url(text: string, url: string): this
268
+ call(text: string, phone: string): this
269
+ copy(text: string, code: string): this
270
+ send(jid: string, options?: MiscMessageGenerationOptions): Promise<WAMessage | undefined>
271
+ [key: string]: any
272
+ }
273
+ export interface PollBuilder {
274
+ name(name: string): this
275
+ options(values: string[]): this
276
+ multiSelect(count?: number): this
277
+ send(jid: string, options?: MiscMessageGenerationOptions): Promise<any>
278
+ [key: string]: any
279
+ }
280
+ export interface EventBuilder {
281
+ setName(name: string): this
282
+ setDescription(text: string): this
283
+ setStartTime(date: Date): this
284
+ setLocation(location: { name: string; degreesLatitude: number; degreesLongitude: number }): this
285
+ send(jid: string, options?: MiscMessageGenerationOptions): Promise<any>
286
+ [key: string]: any
287
+ }
288
+ export interface AlbumBuilder {
289
+ image(source: string | Buffer, caption?: string): this
290
+ video(source: string | Buffer, caption?: string): this
291
+ send(jid: string, options?: MiscMessageGenerationOptions): Promise<any>
292
+ [key: string]: any
293
+ }
294
+ export class AIRichBuilder {
295
+ setTitle(title: string): this
296
+ setFooter(footer: string): this
297
+ addText(text: string, options?: Record<string, any>): this
298
+ addCode(language: string, code: string): this
299
+ addTable(rows: string[][], options?: Record<string, any>): this
300
+ addImage(image: string | Buffer | (string | Buffer)[]): this
301
+ addVideo(video: any): this
302
+ addSource(sources: [string, string, string][]): this
303
+ addTip(text: string): this
304
+ addSuggest(suggestion: string | string[], options?: Record<string, any>): this
305
+ addProcess(title: string): this
306
+ addHtml(...blocks: (string | [string, string])[]): this
307
+ build(options?: Record<string, any>): any
308
+ send(jid: string, options?: (MiscMessageGenerationOptions & { bypassDownload?: boolean }) | undefined): Promise<any>
309
+ [key: string]: any
310
+ }
311
+
312
+ /* ------------------------------------------------------------------ nomo buttons */
313
+
314
+ export function quickReplyButton(displayText: string, id: string): NativeFlowButton
315
+ export function urlButton(displayText: string, url: string, merchantUrl?: string): NativeFlowButton
316
+ export function copyButton(displayText: string, code: string, id?: string): NativeFlowButton
317
+ export function callButton(displayText: string, phoneNumber: string): NativeFlowButton
318
+ export function singleSelectButton(title: string, sections: ListSection[]): NativeFlowButton
319
+ export function listSection(title: string, rows: { title: string; rowId: string; description?: string }[]): { title: string; rows: any[] }
320
+ export function getButtonReply(message: WAMessage | WAProtoMessage | undefined): ButtonReply | undefined
321
+ export function withNomoAliases<T = any>(message: T): T
322
+
323
+ /* ------------------------------------------------------------------ command router */
324
+
325
+ export interface CommandMeta {
326
+ description?: string
327
+ category?: string
328
+ title?: string
329
+ ownerOnly?: boolean
330
+ groupOnly?: boolean
331
+ privateOnly?: boolean
332
+ cooldownMs?: number
333
+ hidden?: boolean
334
+ }
335
+
336
+ export interface CommandContext {
337
+ sock: WASocket
338
+ msg: WAMessage
339
+ jid: string
340
+ sender: string
341
+ text: string
342
+ args: string[]
343
+ command: string
344
+ isGroup: boolean
345
+ isOwner: boolean
346
+ buttonReply?: ButtonReply
347
+ reply(content: string | AnyMessageContent): Promise<WAMessage | undefined>
348
+ }
349
+
350
+ export type DeniedReason = 'owner_only' | 'group_only' | 'private_only' | 'cooldown'
351
+
352
+ export interface CommandRouterOptions {
353
+ prefix?: string
354
+ owners?: string[]
355
+ cooldownMs?: number
356
+ logger?: Logger
357
+ onUnknown?: (ctx: CommandContext) => void | Promise<void>
358
+ onDenied?: (ctx: CommandContext, reason: DeniedReason, waitMs?: number) => void | Promise<void>
359
+ onError?: (error: unknown, ctx: CommandContext) => void | Promise<void>
360
+ }
361
+
362
+ export interface CommandRouter {
363
+ prefix: string
364
+ commands: { names: string[]; handler: (ctx: CommandContext) => any; meta: CommandMeta }[]
365
+ command(names: string | string[], handler: (ctx: CommandContext) => any, meta?: CommandMeta): CommandRouter
366
+ parse(text: string): { name: string; args: string[] } | undefined
367
+ handle(msg: WAMessage): Promise<boolean>
368
+ attach(): () => void
369
+ sendMenu(jid: string, menu?: { text?: string; title?: string; footer?: string; buttonText?: string; style?: 'list' | 'buttons' }): Promise<WAMessage | undefined>
370
+ }
371
+
372
+ export function createCommandRouter(sock: WASocket, options?: CommandRouterOptions): CommandRouter
373
+ export function getMessageText(msg: WAMessage | undefined): string
374
+
375
+ /* ------------------------------------------------------------------ helpers */
376
+
377
+ export const DisconnectReason: {
378
+ connectionClosed: number
379
+ connectionLost: number
380
+ connectionReplaced: number
381
+ timedOut: number
382
+ loggedOut: number
383
+ badSession: number
384
+ restartRequired: number
385
+ multideviceMismatch: number
386
+ forbidden: number
387
+ unavailableService: number
388
+ [key: string]: number | string
389
+ }
390
+ export const Browsers: {
391
+ macOS(browser: string): [string, string, string]
392
+ ubuntu(browser: string): [string, string, string]
393
+ windows(browser: string): [string, string, string]
394
+ appropriate(browser: string): [string, string, string]
395
+ baileys(browser: string): [string, string, string]
396
+ android(browser: string): [string, string, string]
397
+ [key: string]: any
398
+ }
399
+ export const CHAT_THEMES: Record<string, any>
400
+
401
+ export function jidDecode(jid: string | undefined): { user: string; server: string; device?: number; domainType?: number } | undefined
402
+ export function jidEncode(user: string | number | null, server: string, device?: number, agent?: number): string
403
+ export function jidNormalizedUser(jid: string | undefined): string
404
+ export function areJidsSameUser(a?: string, b?: string): boolean
405
+ export function isJidGroup(jid: string | undefined): boolean
406
+ export function isLidUser(jid: string | undefined): boolean
407
+ export function isPnUser(jid: string | undefined): boolean
408
+ export function isJidNewsletter(jid: string | undefined): boolean
409
+ export function isJidStatusBroadcast(jid: string | undefined): boolean
410
+ export function extractMessageContent(message: WAProtoMessage | undefined | null): WAProtoMessage | undefined
411
+ export function getContentType(content: WAProtoMessage | undefined): string | undefined
412
+ export function normalizeMessageContent(content: WAProtoMessage | undefined | null): WAProtoMessage | undefined
413
+ export function downloadMediaMessage(message: WAMessage, type: 'buffer' | 'stream', options?: Record<string, any>, ctx?: Record<string, any>): Promise<Buffer | NodeJS.ReadableStream>
414
+ export function generateMessageID(): string
415
+ export function delay(ms: number): Promise<void>
416
+ export function fetchLatestBaileysVersion(options?: Record<string, any>): Promise<{ version: [number, number, number]; isLatest: boolean; error?: unknown }>
417
+ export function checkStatusWA(number: string): Promise<{ number: string; status: string; isBanned?: boolean; isNeedOfficialWa?: boolean; banInfo?: any; [key: string]: any }>
418
+ export function createFakeQuoted(text: string, options?: { participant?: string; pushName?: string; [key: string]: any }): WAMessage
419
+ export function makeCacheableSignalKeyStore(store: any, logger?: Logger): any
420
+ export function initAuthCreds(): any
421
+
422
+ /* ------------------------------------------------------------------ untyped exports (generated) */
423
+ // 392 exports, see scripts/gen-types.mjs
424
+ export const A2UI: any
425
+ export const ACCOUNT_RESTRICTED_TEXT: any
426
+ export const AIRich: any
427
+ export const ALL_WA_PATCH_NAMES: any
428
+ export const Album: any
429
+ export const AssociationType: any
430
+ export const BIZ_BOT_SUPPORT_PAYLOAD: any
431
+ export const BOT_RENDERING_CONFIG_METADATA: any
432
+ export const BaseBuilder: any
433
+ export const BinaryInfo: any
434
+ export const BufferJSON: any
435
+ export const ButtonHeaderType: any
436
+ export const ButtonType: any
437
+ export const CALL_AUDIO_PREFIX: any
438
+ export const CALL_VIDEO_PREFIX: any
439
+ export const CLEANUP_INTERVAL_MS: any
440
+ export const Carousel: any
441
+ export const CarouselCardType: any
442
+ export const CodeHighlightType: any
443
+ export const CompanionWebClientType: any
444
+ export const Curve: any
445
+ export const DECRYPTION_RETRY_CONFIG: any
446
+ export const DEFAULT_CACHE_TTLS: any
447
+ export const DEFAULT_CLEANUP_THRESHOLD: any
448
+ export const DEFAULT_COLLECTION_NAME: any
449
+ export const DEFAULT_CONNECTION_CONFIG: any
450
+ export const DEFAULT_ORIGIN: any
451
+ export const DEFAULT_PREKEY_RETENTION: any
452
+ export const DEF_CALLBACK_PREFIX: any
453
+ export const DEF_MEDIA_HOST: any
454
+ export const DEF_TAG_PREFIX: any
455
+ export const DICT_VERSION: any
456
+ export const Event: any
457
+ export const FLAG_BYTE: any
458
+ export const FLAG_EVENT: any
459
+ export const FLAG_EXTENDED: any
460
+ export const FLAG_FIELD: any
461
+ export const FLAG_GLOBAL: any
462
+ export const GridImage: any
463
+ export const HANDLER_SHORTCUTS: any
464
+ export const HISTORY_SYNC_PAUSED_TIMEOUT_MS: any
465
+ export const INITIAL_PREKEY_COUNT: any
466
+ export const Interactive: any
467
+ export const KEY_BUNDLE_TYPE: any
468
+ export const LIBRARY_NAME: any
469
+ export const LT_HASH_ANTI_TAMPERING: any
470
+ export const LabelAssociationType: any
471
+ export const LabelColor: any
472
+ export const ListType: any
473
+ export const MAX_SYNC_ATTEMPTS: any
474
+ export const MEDIA_HKDF_KEY_MAPPING: any
475
+ export const MEDIA_KEYS: any
476
+ export const MEDIA_PATH_MAP: any
477
+ export const META_AI_JID: any
478
+ export const MIN_PREKEY_COUNT: any
479
+ export const MISSING_KEYS_ERROR_TEXT: any
480
+ export const MessageDeduplicator: any
481
+ export const MessageRetryManager: any
482
+ export const NACK_REASONS: any
483
+ export const NOISE_MODE: any
484
+ export const NOISE_WA_HEADER: any
485
+ export const NO_MESSAGE_FOUND_ERROR_TEXT: any
486
+ export const NewChatMessageCappingMVStatusType: any
487
+ export const NewChatMessageCappingOTEStatusType: any
488
+ export const NewChatMessageCappingStatusType: any
489
+ export const OFFICIAL_BIZ_JID: any
490
+ export const Order: any
491
+ export const PERFORMANCE_MODE_DEFAULTS: any
492
+ export const PHONE_CONNECTION_CB: any
493
+ export const PLACEHOLDER_MAX_AGE_SECONDS: any
494
+ export const PRIMITIVE_SHORTCUTS: any
495
+ export const PROCESSABLE_HISTORY_TYPES: any
496
+ export const PROTOCOL_ADAPTERS: any
497
+ export const PSA_WID: any
498
+ export const Payment: any
499
+ export const Poll: any
500
+ export const PreKeyManager: any
501
+ export const ProtocolType: any
502
+ export const QueryIds: any
503
+ export const REPORT_REASON_CODES: any
504
+ export const ReachoutTimelockEnforcementType: any
505
+ export const RequestCoalescer: any
506
+ export const RetryReason: any
507
+ export const RichSubMessageType: any
508
+ export const SERVER_ERROR_CODES: any
509
+ export const SERVER_JID: any
510
+ export const SPAM_FLOWS: any
511
+ export const STATUS_AUDIENCE_DEFAULT_EMOJI: any
512
+ export const STATUS_AUDIENCE_DEFAULT_LIST_NAME: any
513
+ export const STATUS_EXPIRY_SECONDS: any
514
+ export const STATUS_NOTIFICATION_TYPES: any
515
+ export const STORIES_JID: any
516
+ export const S_WHATSAPP_NET: any
517
+ export const StickerPack: any
518
+ export const SyncState: any
519
+ export const TC_TOKEN_INDEX_KEY: any
520
+ export const TimeMs: any
521
+ export const UNAUTHORIZED_CODES: any
522
+ export const UPLOAD_TIMEOUT: any
523
+ export const URL_REGEX: any
524
+ export const USyncBotProfileProtocol: any
525
+ export const USyncContactProtocol: any
526
+ export const USyncDeviceProtocol: any
527
+ export const USyncDisappearingModeProtocol: any
528
+ export const USyncLIDProtocol: any
529
+ export const USyncQuery: any
530
+ export const USyncStatusProtocol: any
531
+ export const USyncUser: any
532
+ export const USyncUsernameProtocol: any
533
+ export const VerticalAlbum: any
534
+ export const VideoGrid: any
535
+ export const WAJIDDomains: any
536
+ export const WAMessageAddressingMode: any
537
+ export const WAMessageStatus: any
538
+ export const WAMessageStubType: any
539
+ export const WAProto: any
540
+ export const WA_ADV_ACCOUNT_SIG_PREFIX: any
541
+ export const WA_ADV_DEVICE_SIG_PREFIX: any
542
+ export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: any
543
+ export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: any
544
+ export const WA_BINARY_CONSTANTS: any
545
+ export const WA_CERT_DETAILS: any
546
+ export const WA_DEFAULT_EPHEMERAL: any
547
+ export const WEB_EVENTS: any
548
+ export const WEB_GLOBALS: any
549
+ export const XWAPaths: any
550
+ export const addTransactionCapability: any
551
+ export const aesDecrypt: any
552
+ export const aesDecryptCTR: any
553
+ export const aesDecryptGCM: any
554
+ export const aesDecryptWithIV: any
555
+ export const aesEncrypWithIV: any
556
+ export const aesEncrypt: any
557
+ export const aesEncryptCTR: any
558
+ export const aesEncryptGCM: any
559
+ export const aggregateMessageKeysNotFromMe: any
560
+ export const aiRichBuilderFromSpec: any
561
+ export const aiRichFromObject: any
562
+ export const applyPerformanceMode: any
563
+ export const assertMeId: any
564
+ export const assertMediaContent: any
565
+ export const assertNodeErrorFree: any
566
+ export const attachAIRich: any
567
+ export const binaryNodeToString: any
568
+ export const bindWaitForConnectionUpdate: any
569
+ export const bindWaitForEvent: any
570
+ export const bootstrapCreds: any
571
+ export const botMetadataCertificate: any
572
+ export const botMetadataSignature: any
573
+ export const buildAckStanza: any
574
+ export const buildAutoBuilders: any
575
+ export const buildDispatch: any
576
+ export const buildMergedTcTokenIndexWrite: any
577
+ export const buildPairingQRData: any
578
+ export const buildPlugins: any
579
+ export const buildSimpleReportNode: any
580
+ export const buildSpamReportIq: any
581
+ export const buildSpamReportMessageNodes: any
582
+ export const buildTcTokenFromJid: any
583
+ export const bytesToCrockford: any
584
+ export const chatModificationToAppPatch: any
585
+ export const cleanMessage: any
586
+ export const clearAdapterCache: any
587
+ export const configureSuccessfulPairing: any
588
+ export const createConcurrencyLimit: any
589
+ export const createSignalIdentity: any
590
+ export const debouncedTimeout: any
591
+ export const decodeBinaryNode: any
592
+ export const decodeDecompressedBinaryNode: any
593
+ export const decodeMediaRetryNode: any
594
+ export const decodeMessageNode: any
595
+ export const decodePatches: any
596
+ export const decodeSyncdMutations: any
597
+ export const decodeSyncdPatch: any
598
+ export const decodeSyncdSnapshot: any
599
+ export const decompressingIfRequired: any
600
+ export const decryptEventResponse: any
601
+ export const decryptMediaRetryData: any
602
+ export const decryptMessageEdit: any
603
+ export const decryptMessageNode: any
604
+ export const decryptPollVote: any
605
+ export const delayCancellable: any
606
+ export const derivePairingCodeKey: any
607
+ export const deser: any
608
+ export const downloadAndProcessHistorySyncNotification: any
609
+ export const downloadContentFromMessage: any
610
+ export const downloadEncryptedContent: any
611
+ export const downloadExternalBlob: any
612
+ export const downloadExternalPatch: any
613
+ export const downloadHistory: any
614
+ export const emitSyncActionResults: any
615
+ export const encodeBase64EncodedStringForUpload: any
616
+ export const encodeBigEndian: any
617
+ export const encodeBinaryNode: any
618
+ export const encodeNewsletterMessage: any
619
+ export const encodeSignedDeviceIdentity: any
620
+ export const encodeSyncdPatch: any
621
+ export const encodeWAM: any
622
+ export const encodeWAMessage: any
623
+ export const encryptMediaRetryRequest: any
624
+ export const encryptedStream: any
625
+ export const ensureLTHashStateVersion: any
626
+ export const extensionForMediaMessage: any
627
+ export const extractAddressingContext: any
628
+ export const extractDeviceJids: any
629
+ export const extractE2ESessionFromRetryReceipt: any
630
+ export const extractImageThumb: any
631
+ export const extractMessageText: any
632
+ export const extractSyncdPatches: any
633
+ export const extractUrlFromText: any
634
+ export const extractVideoThumb: any
635
+ export const fetchLatestWaWebVersion: any
636
+ export const generateCsToken: any
637
+ export const generateForwardMessageContent: any
638
+ export const generateLinkPreviewIfRequired: any
639
+ export const generateLoginNode: any
640
+ export const generateMdTagPrefix: any
641
+ export const generateMessageIDV2: any
642
+ export const generateOrGetPreKeys: any
643
+ export const generateParticipantHashV2: any
644
+ export const generateProfilePicture: any
645
+ export const generateQR: any
646
+ export const generateRegistrationId: any
647
+ export const generateRegistrationNode: any
648
+ export const generateSignalPubKey: any
649
+ export const generateThumbnail: any
650
+ export const generateWAMessage: any
651
+ export const generateWAMessageContent: any
652
+ export const generateWAMessageFromContent: any
653
+ export const getAggregateResponsesInEventMessage: any
654
+ export const getAggregateVotesInPollMessage: any
655
+ export const getAllBinaryNodeChildren: any
656
+ export const getAudioDuration: any
657
+ export const getAudioWaveform: any
658
+ export const getAutoBuilders: any
659
+ export const getBanDetails: any
660
+ export const getBinaryNodeChild: any
661
+ export const getBinaryNodeChildBuffer: any
662
+ export const getBinaryNodeChildString: any
663
+ export const getBinaryNodeChildUInt: any
664
+ export const getBinaryNodeChildren: any
665
+ export const getBinaryNodeMessages: any
666
+ export const getBizBinaryNode: any
667
+ export const getCallStatusFromNode: any
668
+ export const getChatId: any
669
+ export const getCodeFromWSError: any
670
+ export const getCompanionPlatformId: any
671
+ export const getCompanionWebClientType: any
672
+ export const getDecryptionJid: any
673
+ export const getDevice: any
674
+ export const getErrorCodeFromStreamError: any
675
+ export const getHistoryMsg: any
676
+ export const getHttpStream: any
677
+ export const getImageProcessingLibrary: any
678
+ export const getKeyAuthor: any
679
+ export const getMediaKeys: any
680
+ export const getMessageReportingToken: any
681
+ export const getNextPreKeys: any
682
+ export const getNextPreKeysNode: any
683
+ export const getPerformanceModeDefaults: any
684
+ export const getPlatformId: any
685
+ export const getPreKeys: any
686
+ export const getRandomHex: any
687
+ export const getRawMediaUploadData: any
688
+ export const getServerFromDomainType: any
689
+ export const getStatusCodeForMediaRetry: any
690
+ export const getStatusFromReceiptType: any
691
+ export const getStream: any
692
+ export const getUrlFromDirectPath: any
693
+ export const getUrlInfo: any
694
+ export const getWAUploadToServer: any
695
+ export const handleGroupStatus: any
696
+ export const handleIdentityChange: any
697
+ export const handleNativeFlow: any
698
+ export const handlePollResult: any
699
+ export const handleStatusMention: any
700
+ export const hasKeyvAuth: any
701
+ export const hasNonNullishProperty: any
702
+ export const hasOptionalProperty: any
703
+ export const hasValidAlbumMedia: any
704
+ export const hasValidCarouselHeader: any
705
+ export const hasValidInteractiveHeader: any
706
+ export const hkdf: any
707
+ export const hkdfInfoKey: any
708
+ export const hmacSign: any
709
+ export const isAppStateSyncIrrecoverable: any
710
+ export const isHostedLidUser: any
711
+ export const isHostedPnUser: any
712
+ export const isJidBot: any
713
+ export const isJidBroadcast: any
714
+ export const isJidMetaAI: any
715
+ export const isLogEnabled: any
716
+ export const isMissingKeyError: any
717
+ export const isRealMessage: any
718
+ export const isStringNullOrEmpty: any
719
+ export const isTcTokenExpired: any
720
+ export const isWABusinessPlatform: any
721
+ export const lazyLog: any
722
+ export const makeCommentMessage: any
723
+ export const makeEventBuffer: any
724
+ export const makeEventInviteMessage: any
725
+ export const makeGroupStatusAttribution: any
726
+ export const makeGroupStatusReactionMessage: any
727
+ export const makeLtHashGenerator: any
728
+ export const makeMessageAssociation: any
729
+ export const makeMessageBuilderSocket: any
730
+ export const makeNewsletterAdminInviteMessage: any
731
+ export const makeNewsletterFollowerInviteMessage: any
732
+ export const makeNewsletterStatusAttribution: any
733
+ export const makeNoiseHandler: any
734
+ export const makeOfflineNodeProcessor: any
735
+ export const makePollAddOptionMessage: any
736
+ export const makeQuestionMessage: any
737
+ export const makeQuestionReplyMessage: any
738
+ export const makeQuestionResponseMessage: any
739
+ export const makeScheduledCallCreationMessage: any
740
+ export const makeScheduledCallEditMessage: any
741
+ export const makeStatusAddYoursAssociation: any
742
+ export const makeStatusAudienceMetadata: any
743
+ export const makeStatusMentionMessage: any
744
+ export const makeStatusNotificationMessage: any
745
+ export const makeStatusQuestionAnswerMessage: any
746
+ export const makeStatusQuotedMessage: any
747
+ export const makeStatusStickerInteractionMessage: any
748
+ export const makeWhatsAppFlowButton: any
749
+ export const md5: any
750
+ export const mediaMessageSHA256B64: any
751
+ export const memoizeAsync: any
752
+ export const mobileRegisterExists: any
753
+ export const newLTHashState: any
754
+ export const norm: any
755
+ export const normalizeReportingTag: any
756
+ export const parseAndInjectE2ESessions: any
757
+ export const parseCatalogNode: any
758
+ export const parseCollectionsNode: any
759
+ export const parseOrderDetailsNode: any
760
+ export const parseProductNode: any
761
+ export const parseSpamReportResponse: any
762
+ export const patchAppStateKey: any
763
+ export const prepareDisappearingMessageSettingContent: any
764
+ export const prepareModernMessageContent: any
765
+ export const prepareRichResponseMessage: any
766
+ export const prepareStickerPackMessage: any
767
+ export const prepareWAMessageMedia: any
768
+ export const processContactAction: any
769
+ export const processHistoryMessage: any
770
+ export const processSyncAction: any
771
+ export const promiseTimeout: any
772
+ export const q: any
773
+ export const readTcTokenIndex: any
774
+ export const reduceBinaryNodeToDictionary: any
775
+ export const registrationParams: any
776
+ export const resolveIssuanceJid: any
777
+ export const resolveNativeFlowButtons: any
778
+ export const resolveReportContext: any
779
+ export const resolveReportJid: any
780
+ export const resolveTcTokenJid: any
781
+ export const runBackground: any
782
+ export const safeAsync: any
783
+ export const ser: any
784
+ export const sha256: any
785
+ export const shouldIncludeBizBinaryNode: any
786
+ export const shouldIncludeReportingToken: any
787
+ export const shouldIncrementChatUnread: any
788
+ export const shouldSendCsToken: any
789
+ export const shouldSendNewTcToken: any
790
+ export const signedKeyPair: any
791
+ export const storeTcTokensFromIqResult: any
792
+ export const toBuffer: any
793
+ export const toNumber: any
794
+ export const toProductNode: any
795
+ export const toReadable: any
796
+ export const toUnified: any
797
+ export const tokenizeAIRichCode: any
798
+ export const tokenizeCode: any
799
+ export const transferDevice: any
800
+ export const trimUndefined: any
801
+ export const unixTimestampSeconds: any
802
+ export const unpadRandomMax16: any
803
+ export const updateMessageWithEventResponse: any
804
+ export const updateMessageWithPollUpdate: any
805
+ export const updateMessageWithReaction: any
806
+ export const updateMessageWithReceipt: any
807
+ export const uploadWithNodeHttp: any
808
+ export const uploadingNecessaryImages: any
809
+ export const uploadingNecessaryImagesOfProduct: any
810
+ export const useMongoAuthState: any
811
+ export const useMongoDbAuthState: any
812
+ export const wrapToBotForwardedMessage: any
813
+ export const writeRandomPadMax16: any
814
+ export const xmppPreKey: any
815
+ export const xmppSignedPreKey: any