@another-trial/whatsapp-web.js 1.34.1 → 1.34.5-alpha.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 (56) hide show
  1. package/.env.example +2 -2
  2. package/CODE_OF_CONDUCT.md +133 -133
  3. package/LICENSE +201 -201
  4. package/README.md +155 -185
  5. package/example.js +706 -690
  6. package/index.d.ts +2259 -2202
  7. package/index.js +35 -35
  8. package/package.json +59 -59
  9. package/shell.js +36 -36
  10. package/src/Client.js +2533 -2361
  11. package/src/authStrategies/BaseAuthStrategy.js +26 -26
  12. package/src/authStrategies/LocalAuth.js +58 -58
  13. package/src/authStrategies/NoAuth.js +11 -11
  14. package/src/authStrategies/RemoteAuth.js +210 -210
  15. package/src/factories/ChatFactory.js +21 -21
  16. package/src/factories/ContactFactory.js +15 -15
  17. package/src/structures/Base.js +21 -21
  18. package/src/structures/Broadcast.js +69 -69
  19. package/src/structures/BusinessContact.js +20 -20
  20. package/src/structures/Buttons.js +81 -81
  21. package/src/structures/Call.js +75 -75
  22. package/src/structures/Channel.js +382 -382
  23. package/src/structures/Chat.js +329 -299
  24. package/src/structures/ClientInfo.js +70 -70
  25. package/src/structures/Contact.js +215 -208
  26. package/src/structures/GroupChat.js +485 -485
  27. package/src/structures/GroupNotification.js +104 -104
  28. package/src/structures/Label.js +49 -49
  29. package/src/structures/List.js +79 -79
  30. package/src/structures/Location.js +61 -61
  31. package/src/structures/Message.js +787 -747
  32. package/src/structures/MessageMedia.js +111 -111
  33. package/src/structures/Order.js +51 -51
  34. package/src/structures/Payment.js +79 -79
  35. package/src/structures/Poll.js +44 -44
  36. package/src/structures/PollVote.js +75 -75
  37. package/src/structures/PrivateChat.js +12 -12
  38. package/src/structures/PrivateContact.js +12 -12
  39. package/src/structures/Product.js +67 -67
  40. package/src/structures/ProductMetadata.js +24 -24
  41. package/src/structures/Reaction.js +68 -68
  42. package/src/structures/ScheduledEvent.js +71 -71
  43. package/src/structures/index.js +27 -27
  44. package/src/util/Constants.js +186 -183
  45. package/src/util/Injected/AuthStore/AuthStore.js +16 -16
  46. package/src/util/Injected/AuthStore/LegacyAuthStore.js +21 -21
  47. package/src/util/Injected/LegacyStore.js +145 -145
  48. package/src/util/Injected/Store.js +263 -233
  49. package/src/util/Injected/Utils.js +1221 -1169
  50. package/src/util/InterfaceController.js +126 -126
  51. package/src/util/Puppeteer.js +23 -23
  52. package/src/util/Util.js +186 -186
  53. package/src/webCache/LocalWebCache.js +40 -40
  54. package/src/webCache/RemoteWebCache.js +39 -39
  55. package/src/webCache/WebCache.js +13 -13
  56. package/src/webCache/WebCacheFactory.js +19 -19
package/index.d.ts CHANGED
@@ -1,2202 +1,2259 @@
1
-
2
- import { EventEmitter } from 'events'
3
- import { RequestInit } from 'node-fetch'
4
- import * as puppeteer from 'puppeteer'
5
- import InterfaceController from './src/util/InterfaceController'
6
-
7
- declare namespace WAWebJS {
8
-
9
- export class Client extends EventEmitter {
10
- constructor(options: ClientOptions)
11
-
12
- /** Current connection information */
13
- public info: ClientInfo
14
-
15
- /** Puppeteer page running WhatsApp Web */
16
- pupPage?: puppeteer.Page
17
-
18
- /** Puppeteer browser running WhatsApp Web */
19
- pupBrowser?: puppeteer.Browser
20
-
21
- /** Client interactivity interface */
22
- interface?: InterfaceController
23
-
24
- /**Accepts an invitation to join a group */
25
- acceptInvite(inviteCode: string): Promise<string>
26
-
27
- /** Accepts a channel admin invitation and promotes the current user to a channel admin */
28
- acceptChannelAdminInvite(channelId: string): Promise<boolean>
29
-
30
- /** Revokes a channel admin invitation sent to a user by a channel owner */
31
- revokeChannelAdminInvite(channelId: string, userId: string): Promise<boolean>
32
-
33
- /** Demotes a channel admin to a regular subscriber (can be used also for self-demotion) */
34
- demoteChannelAdmin(channelId: string, userId: string): Promise<boolean>
35
-
36
- /** Accepts a private invitation to join a group (v4 invite) */
37
- acceptGroupV4Invite: (inviteV4: InviteV4Data) => Promise<{status: number}>
38
-
39
- /**Returns an object with information about the invite code's group */
40
- getInviteInfo(inviteCode: string): Promise<object>
41
-
42
- /** Enables and returns the archive state of the Chat */
43
- archiveChat(chatId: string): Promise<boolean>
44
-
45
- /** Pins the Chat and returns its new Pin state */
46
- pinChat(chatId: string): Promise<boolean>
47
-
48
- /** Unpins the Chat and returns its new Pin state */
49
- unpinChat(chatId: string): Promise<boolean>
50
-
51
- /** Creates a new group */
52
- createGroup(title: string, participants?: string | Contact | Contact[] | string[], options?: CreateGroupOptions): Promise<CreateGroupResult|string>
53
-
54
- /** Creates a new channel */
55
- createChannel(title: string, options?: CreateChannelOptions): Promise<CreateChannelResult | string>
56
-
57
- /** Deletes the channel you created */
58
- deleteChannel(channelId: string): Promise<boolean>;
59
-
60
- /** Subscribe to channel */
61
- subscribeToChannel(channelId: string): Promise<boolean>
62
-
63
- /** Unsubscribe from channel */
64
- unsubscribeFromChannel(channelId: string, options?: UnsubscribeOptions): Promise<boolean>
65
-
66
- /**
67
- * Searches for channels based on search criteria, there are some notes:
68
- * 1. The method finds only channels you are not subscribed to currently
69
- * 2. If you have never been subscribed to a found channel
70
- * or you have unsubscribed from it with {@link UnsubscribeOptions.deleteLocalModels} set to 'true',
71
- * the lastMessage property of a found channel will be 'null'
72
- */
73
- searchChannels(searchOptions: SearchChannelsOptions): Promise<Array<Channel> | []>
74
-
75
- /** Closes the client */
76
- destroy(): Promise<void>
77
-
78
- /** Logs out the client, closing the current session */
79
- logout(): Promise<void>
80
-
81
- /** Get all blocked contacts by host account */
82
- getBlockedContacts(): Promise<Contact[]>
83
-
84
- /** Gets chat or channel instance by ID */
85
- getChatById(chatId: string): Promise<Chat>
86
-
87
- /** Gets a {@link Channel} instance by invite code */
88
- getChannelByInviteCode(inviteCode: string): Promise<Channel>
89
-
90
- /** Get all current chat instances */
91
- getChats(): Promise<Chat[]>
92
-
93
- /** Gets all cached {@link Channel} instances */
94
- getChannels(): Promise<Channel[]>
95
-
96
- /** Get contact instance by ID */
97
- getContactById(contactId: string): Promise<Contact>
98
-
99
- /** Get message by ID */
100
- getMessageById(messageId: string): Promise<Message>
101
-
102
- /** Gets instances of all pinned messages in a chat */
103
- getPinnedMessages(chatId: string): Promise<[Message]|[]>
104
-
105
- /** Get all current contact instances */
106
- getContacts(): Promise<Contact[]>
107
-
108
- /** Get the country code of a WhatsApp ID. (154185968@c.us) => (1) */
109
- getCountryCode(number: string): Promise<string>
110
-
111
- /** Get the formatted number of a WhatsApp ID. (12345678901@c.us) => (+1 (234) 5678-901) */
112
- getFormattedNumber(number: string): Promise<string>
113
-
114
- /** Get all current Labels */
115
- getLabels(): Promise<Label[]>
116
-
117
- /** Get all current Broadcasts */
118
- getBroadcasts(): Promise<Broadcast[]>
119
-
120
- /** Change labels in chats */
121
- addOrRemoveLabels(labelIds: Array<number|string>, chatIds: Array<string>): Promise<void>
122
-
123
- /** Get Label instance by ID */
124
- getLabelById(labelId: string): Promise<Label>
125
-
126
- /** Get all Labels assigned to a Chat */
127
- getChatLabels(chatId: string): Promise<Label[]>
128
-
129
- /** Get all Chats for a specific Label */
130
- getChatsByLabelId(labelId: string): Promise<Chat[]>
131
-
132
- /** Returns the contact ID's profile picture URL, if privacy settings allow it */
133
- getProfilePicUrl(contactId: string): Promise<string>
134
-
135
- /** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
136
- getCommonGroups(contactId: string): Promise<ChatId[]>
137
-
138
- /** Gets the current connection state for the client */
139
- getState(): Promise<WAState>
140
-
141
- /** Returns the version of WhatsApp Web currently being run */
142
- getWWebVersion(): Promise<string>
143
-
144
- /** Sets up events and requirements, kicks off authentication request */
145
- initialize(): Promise<void>
146
-
147
- /** Check if a given ID is registered in whatsapp */
148
- isRegisteredUser(contactId: string): Promise<boolean>
149
-
150
- /** Get the registered WhatsApp ID for a number. Returns null if the number is not registered on WhatsApp. */
151
- getNumberId(number: string): Promise<ContactId | null>
152
-
153
- /**
154
- * Mutes this chat forever, unless a date is specified
155
- * @param chatId ID of the chat that will be muted
156
- * @param unmuteDate Date when the chat will be unmuted, leave as is to mute forever
157
- */
158
- muteChat(chatId: string, unmuteDate?: Date): Promise<{ isMuted: boolean, muteExpiration: number }>
159
-
160
- /**
161
- * Request authentication via pairing code instead of QR code
162
- * @param phoneNumber - Phone number in international, symbol-free format (e.g. 12025550108 for US, 551155501234 for Brazil)
163
- * @param showNotification - Show notification to pair on phone number. Defaults to `true`
164
- * @param intervalMs - The interval in milliseconds on how frequent to generate pairing code (WhatsApp default to 3 minutes). Defaults to `180000`
165
- * @returns {Promise<string>} - Returns a pairing code in format "ABCDEFGH"
166
- */
167
- requestPairingCode(phoneNumber: string, showNotification?: boolean, intervalMs?: number): Promise<string>
168
-
169
- /** Force reset of connection state for the client */
170
- resetState(): Promise<void>
171
-
172
- /** Send a message to a specific chatId */
173
- sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>
174
-
175
- /** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
176
- sendChannelAdminInvite(chatId: string, channelId: string, options?: { comment?: string }): Promise<boolean>
177
-
178
- /** Searches for messages */
179
- searchMessages(query: string, options?: { chatId?: string, page?: number, limit?: number }): Promise<Message[]>
180
-
181
- /** Marks the client as online */
182
- sendPresenceAvailable(): Promise<void>
183
-
184
- /** Marks the client as offline */
185
- sendPresenceUnavailable(): Promise<void>
186
-
187
- /** Mark as seen for the Chat */
188
- sendSeen(chatId: string): Promise<boolean>
189
-
190
- /** Mark the Chat as unread */
191
- markChatUnread(chatId: string): Promise<void>
192
-
193
- /**
194
- * Sets the current user's status message
195
- * @param status New status message
196
- */
197
- setStatus(status: string): Promise<void>
198
-
199
- /**
200
- * Sets the current user's display name
201
- * @param displayName New display name
202
- */
203
- setDisplayName(displayName: string): Promise<boolean>
204
-
205
- /**
206
- * Changes the autoload Audio
207
- * @param flag true/false on or off
208
- */
209
- setAutoDownloadAudio(flag: boolean): Promise<void>
210
- /**
211
- * Changes the autoload Documents
212
- * @param flag true/false on or off
213
- */
214
- setAutoDownloadDocuments(flag: boolean): Promise<void>
215
- /**
216
- * Changes the autoload Photos
217
- * @param flag true/false on or off
218
- */
219
- setAutoDownloadPhotos(flag: boolean): Promise<void>
220
- /**
221
- * Changes the autoload Videos
222
- * @param flag true/false on or off
223
- */
224
- setAutoDownloadVideos(flag: boolean): Promise<void>
225
-
226
- /**
227
- * Changing the background synchronization setting.
228
- * NOTE: this action will take effect after you restart the client.
229
- * @param flag true/false on or off
230
- */
231
- setBackgroundSync(flag: boolean): Promise<void>
232
-
233
- /**
234
- * Get user device count by ID
235
- * Each WaWeb Connection counts as one device, and the phone (if exists) counts as one
236
- * So for a non-enterprise user with one WaWeb connection it should return "2"
237
- * @param {string} contactId
238
- */
239
- getContactDeviceCount(userId: string): Promise<number>
240
-
241
- /** Sync history conversation of the Chat */
242
- syncHistory(chatId: string): Promise<boolean>
243
-
244
- /** Save new contact to user's addressbook or edit the existing one */
245
- saveOrEditAddressbookContact(phoneNumber: string, firstName: string, lastName: string, syncToAddressbook?: boolean): Promise<ChatId>
246
-
247
- /** Deletes the contact from user's addressbook */
248
- deleteAddressbookContact(honeNumber: string): Promise<void>
249
-
250
- /** Get Contact lid and phone */
251
- getContactLidAndPhone(userIds: string[]): Promise<{ lid: string; pn: string }[]>
252
-
253
- /** Changes and returns the archive state of the Chat */
254
- unarchiveChat(chatId: string): Promise<boolean>
255
-
256
- /** Unmutes the Chat */
257
- unmuteChat(chatId: string): Promise<{ isMuted: boolean, muteExpiration: number }>
258
-
259
- /** Sets the current user's profile picture */
260
- setProfilePicture(media: MessageMedia): Promise<boolean>
261
-
262
- /** Deletes the current user's profile picture */
263
- deleteProfilePicture(): Promise<boolean>
264
-
265
- /** Generates a WhatsApp call link (video call or voice call) */
266
- createCallLink(startTime: Date, callType: string): Promise<string>
267
-
268
- /**
269
- * Sends a response to the scheduled event message, indicating whether a user is going to attend the event or not
270
- * @param response The response code to the event message. Valid values are: `0` for NONE response (removes a previous response) | `1` for GOING | `2` for NOT GOING | `3` for MAYBE going
271
- * @param eventMessageId The event message ID
272
- */
273
- sendResponseToScheduledEvent(response: number, eventMessageId: string): Promise<boolean>
274
-
275
- /** Gets an array of membership requests */
276
- getGroupMembershipRequests(groupId: string): Promise<Array<GroupMembershipRequest>>
277
-
278
- /** Approves membership requests if any */
279
- approveGroupMembershipRequests(groupId: string, options: MembershipRequestActionOptions): Promise<Array<MembershipRequestActionResult>>;
280
-
281
- /** Rejects membership requests if any */
282
- rejectGroupMembershipRequests(groupId: string, options: MembershipRequestActionOptions): Promise<Array<MembershipRequestActionResult>>;
283
-
284
- /**
285
- * Transfers a channel ownership to another user.
286
- * Note: the user you are transferring the channel ownership to must be a channel admin.
287
- */
288
- transferChannelOwnership(channelId: string, newOwnerId: string, options?: TransferChannelOwnershipOptions): Promise<boolean>;
289
-
290
- /** Generic event */
291
- on(event: string, listener: (...args: any) => void): this
292
-
293
- /** Emitted when there has been an error while trying to restore an existing session */
294
- on(event: 'auth_failure', listener: (message: string) => void): this
295
-
296
- /** Emitted when authentication is successful */
297
- on(event: 'authenticated', listener: (
298
- /**
299
- * Object containing session information, when using LegacySessionAuth. Can be used to restore the session
300
- */
301
- session?: ClientSession
302
- ) => void): this
303
-
304
- /**
305
- * Emitted when the battery percentage for the attached device changes
306
- * @deprecated
307
- */
308
- on(event: 'change_battery', listener: (batteryInfo: BatteryInfo) => void): this
309
-
310
- /** Emitted when the connection state changes */
311
- on(event: 'change_state', listener: (
312
- /** the new connection state */
313
- state: WAState
314
- ) => void): this
315
-
316
- /** Emitted when the client has been disconnected */
317
- on(event: 'disconnected', listener: (
318
- /** reason that caused the disconnect */
319
- reason: WAState | "LOGOUT"
320
- ) => void): this
321
-
322
- /** Emitted when a user joins the chat via invite link or is added by an admin */
323
- on(event: 'group_join', listener: (
324
- /** GroupNotification with more information about the action */
325
- notification: GroupNotification
326
- ) => void): this
327
-
328
- /** Emitted when a user leaves the chat or is removed by an admin */
329
- on(event: 'group_leave', listener: (
330
- /** GroupNotification with more information about the action */
331
- notification: GroupNotification
332
- ) => void): this
333
-
334
- /** Emitted when a current user is promoted to an admin or demoted to a regular user */
335
- on(event: 'group_admin_changed', listener: (
336
- /** GroupNotification with more information about the action */
337
- notification: GroupNotification
338
- ) => void): this
339
-
340
- /**
341
- * Emitted when some user requested to join the group
342
- * that has the membership approval mode turned on
343
- */
344
- on(event: 'group_membership_request', listener: (
345
- /** GroupNotification with more information about the action */
346
- notification: GroupNotification
347
- ) => void): this
348
-
349
- /** Emitted when group settings are updated, such as subject, description or picture */
350
- on(event: 'group_update', listener: (
351
- /** GroupNotification with more information about the action */
352
- notification: GroupNotification
353
- ) => void): this
354
-
355
- /** Emitted when a contact or a group participant changed their phone number. */
356
- on(event: 'contact_changed', listener: (
357
- /** Message with more information about the event. */
358
- message: Message,
359
- /** Old user's id. */
360
- oldId : String,
361
- /** New user's id. */
362
- newId : String,
363
- /** Indicates if a contact or a group participant changed their phone number. */
364
- isContact : Boolean
365
- ) => void): this
366
-
367
- /** Emitted when media has been uploaded for a message sent by the client */
368
- on(event: 'media_uploaded', listener: (
369
- /** The message with media that was uploaded */
370
- message: Message
371
- ) => void): this
372
-
373
- /** Emitted when a new message is received */
374
- on(event: 'message', listener: (
375
- /** The message that was received */
376
- message: Message
377
- ) => void): this
378
-
379
- /** Emitted when an ack event occurrs on message type */
380
- on(event: 'message_ack', listener: (
381
- /** The message that was affected */
382
- message: Message,
383
- /** The new ACK value */
384
- ack: MessageAck
385
- ) => void): this
386
-
387
- /** Emitted when an edit event occurrs on message type */
388
- on(event: 'message_edit', listener: (
389
- /** The message that was affected */
390
- message: Message,
391
- /** New text message */
392
- newBody: String,
393
- /** Prev text message */
394
- prevBody: String
395
- ) => void): this
396
-
397
- /** Emitted when a chat unread count changes */
398
- on(event: 'unread_count', listener: (
399
- /** The chat that was affected */
400
- chat: Chat
401
- ) => void): this
402
-
403
- /** Emitted when a new message is created, which may include the current user's own messages */
404
- on(event: 'message_create', listener: (
405
- /** The message that was created */
406
- message: Message
407
- ) => void): this
408
-
409
- /** Emitted when a new message ciphertext is received */
410
- on(event: 'message_ciphertext', listener: (
411
- /** The message that was ciphertext */
412
- message: Message
413
- ) => void): this
414
-
415
- /** Emitted when a message is deleted for everyone in the chat */
416
- on(event: 'message_revoke_everyone', listener: (
417
- /** The message that was revoked, in its current state. It will not contain the original message's data */
418
- message: Message,
419
- /**The message that was revoked, before it was revoked.
420
- * It will contain the message's original data.
421
- * Note that due to the way this data is captured,
422
- * it may be possible that this param will be undefined. */
423
- revoked_msg?: Message | null
424
- ) => void): this
425
-
426
- /** Emitted when a message is deleted by the current user */
427
- on(event: 'message_revoke_me', listener: (
428
- /** The message that was revoked */
429
- message: Message
430
- ) => void): this
431
-
432
- /** Emitted when a reaction is sent, received, updated or removed */
433
- on(event: 'message_reaction', listener: (
434
- /** The reaction object */
435
- reaction: Reaction
436
- ) => void): this
437
-
438
- /** Emitted when a chat is removed */
439
- on(event: 'chat_removed', listener: (
440
- /** The chat that was removed */
441
- chat: Chat
442
- ) => void): this
443
-
444
- /** Emitted when a chat is archived/unarchived */
445
- on(event: 'chat_archived', listener: (
446
- /** The chat that was archived/unarchived */
447
- chat: Chat,
448
- /** State the chat is currently in */
449
- currState: boolean,
450
- /** State the chat was previously in */
451
- prevState: boolean
452
- ) => void): this
453
-
454
- /** Emitted when loading screen is appearing */
455
- on(event: 'loading_screen', listener: (percent: string, message: string) => void): this
456
-
457
- /** Emitted when the QR code is received */
458
- on(event: 'qr', listener: (
459
- /** qr code string
460
- * @example ```1@9Q8tWf6bnezr8uVGwVCluyRuBOJ3tIglimzI5dHB0vQW2m4DQ0GMlCGf,f1/vGcW4Z3vBa1eDNl3tOjWqLL5DpYTI84DMVkYnQE8=,ZL7YnK2qdPN8vKo2ESxhOQ==``` */
461
- qr: string
462
- ) => void): this
463
-
464
- /** Emitted when the phone number pairing code is received */
465
- on(event: 'code', listener: (
466
- /** pairing code string
467
- * @example `8W2WZ3TS` */
468
- code: string
469
- ) => void): this
470
-
471
- /** Emitted when a call is received */
472
- on(event: 'call', listener: (
473
- /** The call that started */
474
- call: Call
475
- ) => void): this
476
-
477
- /** Emitted when the client has initialized and is ready to receive messages */
478
- on(event: 'ready', listener: () => void): this
479
-
480
- /** Emitted when the RemoteAuth session is saved successfully on the external Database */
481
- on(event: 'remote_session_saved', listener: () => void): this
482
-
483
- /**
484
- * Emitted when some poll option is selected or deselected,
485
- * shows a user's current selected option(s) on the poll
486
- */
487
- on(event: 'vote_update', listener: (
488
- vote: PollVote
489
- ) => void): this
490
- }
491
-
492
- /** Current connection information */
493
- export interface ClientInfo {
494
- /**
495
- * Current user ID
496
- * @deprecated Use .wid instead
497
- */
498
- me: ContactId
499
- /** Current user ID */
500
- wid: ContactId
501
- /**
502
- * Information about the phone this client is connected to. Not available in multi-device.
503
- * @deprecated
504
- */
505
- phone: ClientInfoPhone
506
- /** Platform the phone is running on */
507
- platform: string
508
- /** Name configured to be shown in push notifications */
509
- pushname: string
510
-
511
- /** Get current battery percentage and charging status for the attached device */
512
- getBatteryStatus: () => Promise<BatteryInfo>
513
- }
514
-
515
- /**
516
- * Information about the phone this client is connected to
517
- * @deprecated
518
- */
519
- export interface ClientInfoPhone {
520
- /** WhatsApp Version running on the phone */
521
- wa_version: string
522
- /** OS Version running on the phone (iOS or Android version) */
523
- os_version: string
524
- /** Device manufacturer */
525
- device_manufacturer: string
526
- /** Device model */
527
- device_model: string
528
- /** OS build number */
529
- os_build_number: string
530
- }
531
-
532
- /** Options for initializing the whatsapp client */
533
- export interface ClientOptions {
534
- /** Timeout for authentication selector in puppeteer
535
- * @default 0 */
536
- authTimeoutMs?: number,
537
- /** Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/ */
538
- puppeteer?: puppeteer.PuppeteerNodeLaunchOptions & puppeteer.ConnectOptions
539
- /** Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used. */
540
- authStrategy?: AuthStrategy,
541
- /** The version of WhatsApp Web to use. Use options.webVersionCache to configure how the version is retrieved. */
542
- webVersion?: string,
543
- /** Determines how to retrieve the WhatsApp Web version specified in options.webVersion. */
544
- webVersionCache?: WebCacheOptions,
545
- /** How many times should the qrcode be refreshed before giving up
546
- * @default 0 (disabled) */
547
- qrMaxRetries?: number,
548
- /**
549
- * @deprecated This option should be set directly on the LegacySessionAuth
550
- */
551
- restartOnAuthFail?: boolean
552
- /**
553
- * @deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.
554
- */
555
- session?: ClientSession
556
- /** If another whatsapp web session is detected (another browser), take over the session in the current browser
557
- * @default false */
558
- takeoverOnConflict?: boolean,
559
- /** How much time to wait before taking over the session
560
- * @default 0 */
561
- takeoverTimeoutMs?: number,
562
- /** User agent to use in puppeteer.
563
- * @default 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36' */
564
- userAgent?: string
565
- /** Ffmpeg path to use when formatting videos to webp while sending stickers
566
- * @default 'ffmpeg' */
567
- ffmpegPath?: string,
568
- /** Sets bypassing of page's Content-Security-Policy
569
- * @default false */
570
- bypassCSP?: boolean,
571
- /** Sets the device name of a current linked device., i.e.: 'TEST' */
572
- deviceName?: string,
573
- /**
574
- * Sets the browser name of a current linked device, i.e.: 'Firefox'.
575
- * Valid value are: 'Chrome' | 'Firefox' | 'IE' | 'Opera' | 'Safari' | 'Edge'
576
- */
577
- browserName?: string,
578
- /** Object with proxy autentication requirements @default: undefined */
579
- proxyAuthentication?: {username: string, password: string} | undefined
580
- /** Phone number pairing configuration. Refer the requestPairingCode function of Client.
581
- * @default
582
- * {
583
- * phoneNumber: "",
584
- * showNotification: true,
585
- * intervalMs: 180000,
586
- * }
587
- */
588
- pairWithPhoneNumber?: {phoneNumber: string, showNotification?: boolean, intervalMs?: number}
589
- }
590
-
591
- export interface LocalWebCacheOptions {
592
- type: 'local',
593
- path?: string,
594
- strict?: boolean
595
- }
596
-
597
- export interface RemoteWebCacheOptions {
598
- type: 'remote',
599
- remotePath: string,
600
- strict?: boolean
601
- }
602
-
603
- export interface NoWebCacheOptions {
604
- type: 'none'
605
- }
606
-
607
- export type WebCacheOptions = NoWebCacheOptions | LocalWebCacheOptions | RemoteWebCacheOptions;
608
-
609
- /**
610
- * Base class which all authentication strategies extend
611
- */
612
- export abstract class AuthStrategy {
613
- setup: (client: Client) => void;
614
- beforeBrowserInitialized: () => Promise<void>;
615
- afterBrowserInitialized: () => Promise<void>;
616
- onAuthenticationNeeded: () => Promise<{
617
- failed?: boolean;
618
- restart?: boolean;
619
- failureEventPayload?: any
620
- }>;
621
- getAuthEventPayload: () => Promise<any>;
622
- afterAuthReady: () => Promise<void>;
623
- disconnect: () => Promise<void>;
624
- destroy: () => Promise<void>;
625
- logout: () => Promise<void>;
626
- }
627
-
628
- /**
629
- * No session restoring functionality
630
- * Will need to authenticate via QR code every time
631
- */
632
- export class NoAuth extends AuthStrategy {}
633
-
634
- /**
635
- * Local directory-based authentication
636
- */
637
- export class LocalAuth extends AuthStrategy {
638
- public clientId?: string;
639
- public dataPath?: string;
640
- constructor(options?: {
641
- clientId?: string,
642
- dataPath?: string,
643
- rmMaxRetries?: number
644
- })
645
- }
646
-
647
- /**
648
- * Remote-based authentication
649
- */
650
- export class RemoteAuth extends AuthStrategy {
651
- public clientId?: string;
652
- public dataPath?: string;
653
- constructor(options?: {
654
- store: Store,
655
- clientId?: string,
656
- dataPath?: string,
657
- backupSyncIntervalMs: number,
658
- rmMaxRetries?: number
659
- })
660
- }
661
-
662
- /**
663
- * Remote store interface
664
- */
665
- export interface Store {
666
- sessionExists: (options: { session: string }) => Promise<boolean> | boolean,
667
- delete: (options: { session: string }) => Promise<any> | any,
668
- save: (options: { session: string }) => Promise<any> | any,
669
- extract: (options: { session: string, path: string }) => Promise<any> | any,
670
- }
671
-
672
- /**
673
- * Legacy session auth strategy
674
- * Not compatible with multi-device accounts.
675
- */
676
- export class LegacySessionAuth extends AuthStrategy {
677
- constructor(options?: {
678
- session?: ClientSession,
679
- restartOnAuthFail?: boolean,
680
- })
681
- }
682
-
683
- /**
684
- * Represents a WhatsApp client session
685
- */
686
- export interface ClientSession {
687
- WABrowserId: string,
688
- WASecretBundle: string,
689
- WAToken1: string,
690
- WAToken2: string,
691
- }
692
-
693
- /**
694
- * @deprecated
695
- */
696
- export interface BatteryInfo {
697
- /** The current battery percentage */
698
- battery: number,
699
- /** Indicates if the phone is plugged in (true) or not (false) */
700
- plugged: boolean,
701
- }
702
-
703
- /** An object that handles options for group creation */
704
- export interface CreateGroupOptions {
705
- /**
706
- * The number of seconds for the messages to disappear in the group,
707
- * won't take an effect if the group is been creating with myself only
708
- * @default 0
709
- */
710
- messageTimer?: number
711
- /**
712
- * The ID of a parent community group to link the newly created group with,
713
- * won't take an effect if the group is been creating with myself only
714
- */
715
- parentGroupId?: string
716
- /** If true, the inviteV4 will be sent to those participants
717
- * who have restricted others from being automatically added to groups,
718
- * otherwise the inviteV4 won't be sent
719
- * @default true
720
- */
721
- autoSendInviteV4?: boolean,
722
- /**
723
- * The comment to be added to an inviteV4 (empty string by default)
724
- * @default ''
725
- */
726
- comment?: string
727
- /** If true, only admins can add members to the group (false by default)
728
- * @default false
729
- */
730
- memberAddMode?: boolean,
731
- /** If true, group admins will be required to approve anyone who wishes to join the group (false by default)
732
- * @default false
733
- */
734
- membershipApprovalMode?: boolean,
735
- /** If true, only admins can change group group info (true by default)
736
- * @default true
737
- */
738
- isRestrict?: boolean,
739
- /** If true, only admins can send messages (false by default)
740
- * @default false
741
- */
742
- isAnnounce?: boolean,
743
- }
744
-
745
- /** An object that handles the result for createGroup method */
746
- export interface CreateGroupResult {
747
- /** A group title */
748
- title: string;
749
- /** An object that handles the newly created group ID */
750
- gid: ChatId;
751
- /** An object that handles the result value for each added to the group participant */
752
- participants: {
753
- [participantId: string]: {
754
- statusCode: number,
755
- message: string,
756
- isGroupCreator: boolean,
757
- isInviteV4Sent: boolean
758
- };
759
- };
760
- }
761
-
762
- /** An object that handles options for channel creation */
763
- export interface CreateChannelOptions {
764
- /** The channel description */
765
- description?: string,
766
- /** The channel profile picture */
767
- picture?: MessageMedia
768
- }
769
-
770
- /** An object that handles the result for createGroup method */
771
- export interface CreateChannelResult {
772
- /** A channel title */
773
- title: string,
774
- /** An object that handles the newly created channel ID */
775
- nid: ChatId,
776
- /** The channel invite link, starts with 'https://whatsapp.com/channel/' */
777
- inviteLink: string,
778
- /** The timestamp the channel was created at */
779
- createdAtTs: number
780
- }
781
-
782
- /** Options for unsubscribe from a channel */
783
- export interface UnsubscribeOptions {
784
- /**
785
- * If true, after an unsubscription, it will completely remove a channel from the channel collection
786
- * making it seem like the current user have never interacted with it.
787
- * Otherwise it will only remove a channel from the list of channels the current user is subscribed to
788
- * and will set the membership type for that channel to GUEST
789
- */
790
- deleteLocalModels?: boolean
791
- }
792
-
793
- /** Options for searching for channels */
794
- export interface SearchChannelsOptions {
795
- searchText?: string;
796
- countryCodes?: string[];
797
- skipSubscribedNewsletters?: boolean;
798
- view?: number;
799
- limit?: number;
800
- }
801
-
802
- export interface GroupNotification {
803
- /** ContactId for the user that produced the GroupNotification */
804
- author: string,
805
- /** Extra content */
806
- body: string,
807
- /** ID for the Chat that this groupNotification was sent for */
808
- chatId: string,
809
- /** ID that represents the groupNotification
810
- * @todo create a more specific type for the id object */
811
- id: object,
812
- /** Contact IDs for the users that were affected by this GroupNotification */
813
- recipientIds: string[],
814
- /** Unix timestamp for when the groupNotification was created */
815
- timestamp: number,
816
- /** GroupNotification type */
817
- type: GroupNotificationTypes,
818
-
819
- /** Returns the Chat this GroupNotification was sent in */
820
- getChat: () => Promise<Chat>,
821
- /** Returns the Contact this GroupNotification was produced by */
822
- getContact: () => Promise<Contact>,
823
- /** Returns the Contacts affected by this GroupNotification */
824
- getRecipients: () => Promise<Contact[]>,
825
- /** Sends a message to the same chat this GroupNotification was produced in */
826
- reply: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
827
-
828
- }
829
-
830
- /** whatsapp web url */
831
- export const WhatsWebURL: string
832
-
833
- /** default client options */
834
- export const DefaultOptions: ClientOptions
835
-
836
- /** Chat types */
837
- export enum ChatTypes {
838
- SOLO = 'solo',
839
- GROUP = 'group',
840
- UNKNOWN = 'unknown',
841
- }
842
-
843
- /** Events that can be emitted by the client */
844
- export enum Events {
845
- AUTHENTICATED = 'authenticated',
846
- AUTHENTICATION_FAILURE = 'auth_failure',
847
- READY = 'ready',
848
- MESSAGE_RECEIVED = 'message',
849
- MESSAGE_CIPHERTEXT = 'message_ciphertext',
850
- MESSAGE_CREATE = 'message_create',
851
- MESSAGE_REVOKED_EVERYONE = 'message_revoke_everyone',
852
- MESSAGE_REVOKED_ME = 'message_revoke_me',
853
- MESSAGE_ACK = 'message_ack',
854
- MESSAGE_EDIT = 'message_edit',
855
- MEDIA_UPLOADED = 'media_uploaded',
856
- CONTACT_CHANGED = 'contact_changed',
857
- GROUP_JOIN = 'group_join',
858
- GROUP_LEAVE = 'group_leave',
859
- GROUP_ADMIN_CHANGED = 'group_admin_changed',
860
- GROUP_MEMBERSHIP_REQUEST = 'group_membership_request',
861
- GROUP_UPDATE = 'group_update',
862
- QR_RECEIVED = 'qr',
863
- LOADING_SCREEN = 'loading_screen',
864
- DISCONNECTED = 'disconnected',
865
- STATE_CHANGED = 'change_state',
866
- BATTERY_CHANGED = 'change_battery',
867
- REMOTE_SESSION_SAVED = 'remote_session_saved',
868
- CALL = 'call'
869
- }
870
-
871
- /** Group notification types */
872
- export enum GroupNotificationTypes {
873
- ADD = 'add',
874
- INVITE = 'invite',
875
- REMOVE = 'remove',
876
- LEAVE = 'leave',
877
- SUBJECT = 'subject',
878
- DESCRIPTION = 'description',
879
- PICTURE = 'picture',
880
- ANNOUNCE = 'announce',
881
- RESTRICT = 'restrict',
882
- }
883
-
884
- /** Message ACK */
885
- export enum MessageAck {
886
- ACK_ERROR = -1,
887
- ACK_PENDING = 0,
888
- ACK_SERVER = 1,
889
- ACK_DEVICE = 2,
890
- ACK_READ = 3,
891
- ACK_PLAYED = 4,
892
- }
893
-
894
- /** Message types */
895
- export enum MessageTypes {
896
- TEXT = 'chat',
897
- AUDIO = 'audio',
898
- VOICE = 'ptt',
899
- IMAGE = 'image',
900
- VIDEO = 'video',
901
- DOCUMENT = 'document',
902
- STICKER = 'sticker',
903
- LOCATION = 'location',
904
- CONTACT_CARD = 'vcard',
905
- CONTACT_CARD_MULTI = 'multi_vcard',
906
- REVOKED = 'revoked',
907
- ORDER = 'order',
908
- PRODUCT = 'product',
909
- PAYMENT = 'payment',
910
- UNKNOWN = 'unknown',
911
- GROUP_INVITE = 'groups_v4_invite',
912
- LIST = 'list',
913
- LIST_RESPONSE = 'list_response',
914
- BUTTONS_RESPONSE = 'buttons_response',
915
- BROADCAST_NOTIFICATION = 'broadcast_notification',
916
- CALL_LOG = 'call_log',
917
- CIPHERTEXT = 'ciphertext',
918
- DEBUG = 'debug',
919
- E2E_NOTIFICATION = 'e2e_notification',
920
- GP2 = 'gp2',
921
- GROUP_NOTIFICATION = 'group_notification',
922
- HSM = 'hsm',
923
- INTERACTIVE = 'interactive',
924
- NATIVE_FLOW = 'native_flow',
925
- NOTIFICATION = 'notification',
926
- NOTIFICATION_TEMPLATE = 'notification_template',
927
- OVERSIZED = 'oversized',
928
- PROTOCOL = 'protocol',
929
- REACTION = 'reaction',
930
- TEMPLATE_BUTTON_REPLY = 'template_button_reply',
931
- POLL_CREATION = 'poll_creation',
932
- SCHEDULED_EVENT_CREATION = 'scheduled_event_creation',
933
- }
934
-
935
- /** Client status */
936
- export enum Status {
937
- INITIALIZING = 0,
938
- AUTHENTICATING = 1,
939
- READY = 3,
940
- }
941
-
942
- /** WhatsApp state */
943
- export enum WAState {
944
- CONFLICT = 'CONFLICT',
945
- CONNECTED = 'CONNECTED',
946
- DEPRECATED_VERSION = 'DEPRECATED_VERSION',
947
- OPENING = 'OPENING',
948
- PAIRING = 'PAIRING',
949
- PROXYBLOCK = 'PROXYBLOCK',
950
- SMB_TOS_BLOCK = 'SMB_TOS_BLOCK',
951
- TIMEOUT = 'TIMEOUT',
952
- TOS_BLOCK = 'TOS_BLOCK',
953
- UNLAUNCHED = 'UNLAUNCHED',
954
- UNPAIRED = 'UNPAIRED',
955
- UNPAIRED_IDLE = 'UNPAIRED_IDLE',
956
- }
957
-
958
- export type MessageInfo = {
959
- delivery: Array<{id: ContactId, t: number}>,
960
- deliveryRemaining: number,
961
- played: Array<{id: ContactId, t: number}>,
962
- playedRemaining: number,
963
- read: Array<{id: ContactId, t: number}>,
964
- readRemaining: number
965
- }
966
-
967
- export type InviteV4Data = {
968
- inviteCode: string,
969
- inviteCodeExp: number,
970
- groupId: string,
971
- groupName?: string,
972
- fromId: string,
973
- toId: string
974
- }
975
-
976
- /**
977
- * Represents a Message on WhatsApp
978
- *
979
- * @example
980
- * {
981
- * mediaKey: undefined,
982
- * id: {
983
- * fromMe: false,
984
- * remote: `554199999999@c.us`,
985
- * id: '1234567890ABCDEFGHIJ',
986
- * _serialized: `false_554199999999@c.us_1234567890ABCDEFGHIJ`
987
- * },
988
- * ack: -1,
989
- * hasMedia: false,
990
- * body: 'Hello!',
991
- * type: 'chat',
992
- * timestamp: 1591482682,
993
- * from: `554199999999@c.us`,
994
- * to: `554188888888@c.us`,
995
- * author: undefined,
996
- * isForwarded: false,
997
- * broadcast: false,
998
- * fromMe: false,
999
- * hasQuotedMsg: false,
1000
- * hasReaction: false,
1001
- * location: undefined,
1002
- * mentionedIds: []
1003
- * }
1004
- */
1005
- export interface Message {
1006
- /** ACK status for the message */
1007
- ack: MessageAck,
1008
- /** If the message was sent to a group, this field will contain the user that sent the message. */
1009
- author?: string,
1010
- /** String that represents from which device type the message was sent */
1011
- deviceType: string,
1012
- /** Message content */
1013
- body: string,
1014
- /** Indicates if the message was a broadcast */
1015
- broadcast: boolean,
1016
- /** Indicates if the message was a status update */
1017
- isStatus: boolean,
1018
- /** Indicates if the message is a Gif */
1019
- isGif: boolean,
1020
- /** Indicates if the message will disappear after it expires */
1021
- isEphemeral: boolean,
1022
- /** ID for the Chat that this message was sent to, except if the message was sent by the current user */
1023
- from: string,
1024
- /** Indicates if the message was sent by the current user */
1025
- fromMe: boolean,
1026
- /** Indicates if the message has media available for download */
1027
- hasMedia: boolean,
1028
- /** Indicates if the message was sent as a reply to another message */
1029
- hasQuotedMsg: boolean,
1030
- /** Indicates whether there are reactions to the message */
1031
- hasReaction: boolean,
1032
- /** Indicates the duration of the message in seconds */
1033
- duration: string,
1034
- /** ID that represents the message */
1035
- id: MessageId,
1036
- /** Indicates if the message was forwarded */
1037
- isForwarded: boolean,
1038
- /**
1039
- * Indicates how many times the message was forwarded.
1040
- * The maximum value is 127.
1041
- */
1042
- forwardingScore: number,
1043
- /** Indicates if the message was starred */
1044
- isStarred: boolean,
1045
- /** Location information contained in the message, if the message is type "location" */
1046
- location: Location,
1047
- /** List of vCards contained in the message */
1048
- vCards: string[],
1049
- /** Invite v4 info */
1050
- inviteV4?: InviteV4Data,
1051
- /** MediaKey that represents the sticker 'ID' */
1052
- mediaKey?: string,
1053
- /** Indicates the mentions in the message body. */
1054
- mentionedIds: string[],
1055
- /** Indicates whether there are group mentions in the message body */
1056
- groupMentions: {
1057
- groupSubject: string;
1058
- groupJid: string;
1059
- }[],
1060
- /** Unix timestamp for when the message was created */
1061
- timestamp: number,
1062
- /**
1063
- * ID for who this message is for.
1064
- * If the message is sent by the current user, it will be the Chat to which the message is being sent.
1065
- * If the message is sent by another user, it will be the ID for the current user.
1066
- */
1067
- to: string,
1068
- /** Message type */
1069
- type: MessageTypes,
1070
- /** Links included in the message. */
1071
- links: Array<{
1072
- link: string,
1073
- isSuspicious: boolean
1074
- }>,
1075
- /** Order ID */
1076
- orderId: string,
1077
- /** title */
1078
- title?: string,
1079
- /** description*/
1080
- description?: string,
1081
- /** Business Owner JID */
1082
- businessOwnerJid?: string,
1083
- /** Product JID */
1084
- productId?: string,
1085
- /** Last edit time */
1086
- latestEditSenderTimestampMs?: number,
1087
- /** Last edit message author */
1088
- latestEditMsgKey?: MessageId,
1089
- /**
1090
- * Protocol message key.
1091
- * Can be used to retrieve the ID of an original message that was revoked.
1092
- */
1093
- protocolMessageKey?: MessageId,
1094
- /** Message buttons */
1095
- dynamicReplyButtons?: object,
1096
- /** Selected button ID */
1097
- selectedButtonId?: string,
1098
- /** Selected list row ID */
1099
- selectedRowId?: string,
1100
- /** Returns message in a raw format */
1101
- rawData: object,
1102
- pollName: string,
1103
- /** Avaiaible poll voting options */
1104
- pollOptions: string[],
1105
- /** False for a single choice poll, true for a multiple choice poll */
1106
- allowMultipleAnswers: boolean,
1107
- /** The start time of the event in timestamp (10 digits) */
1108
- eventStartTime: number,
1109
- /** The end time of the event in timestamp (10 digits) */
1110
- eventEndTime?: number,
1111
- /** The event description */
1112
- eventDescription?: string,
1113
- /** The location of the event */
1114
- eventLocation?: {
1115
- degreesLatitude: number;
1116
- degreesLongitude: number;
1117
- name: string;
1118
- },
1119
- /** WhatsApp call link (video call or voice call) */
1120
- eventJoinLink?: string,
1121
- /** Indicates if an event should be sent as an already canceled */
1122
- isEventCaneled: boolean,
1123
- /** The custom message secret, can be used as an event ID */
1124
- messageSecret?: Array<number>,
1125
- /*
1126
- * Reloads this Message object's data in-place with the latest values from WhatsApp Web.
1127
- * Note that the Message must still be in the web app cache for this to work, otherwise will return null.
1128
- */
1129
- reload: () => Promise<Message>,
1130
- /** Accept the Group V4 Invite in message */
1131
- acceptGroupV4Invite: () => Promise<{status: number}>,
1132
- /** Deletes the message from the chat */
1133
- delete: (everyone?: boolean, clearMedia?: boolean) => Promise<void>,
1134
- /** Downloads and returns the attached message media */
1135
- downloadMedia: () => Promise<MessageMedia>,
1136
- /** Returns the Chat this message was sent in */
1137
- getChat: () => Promise<Chat>,
1138
- /** Returns the Contact this message was sent from */
1139
- getContact: () => Promise<Contact>,
1140
- /** Returns the Contacts mentioned in this message */
1141
- getMentions: () => Promise<Contact[]>,
1142
- /** Returns groups mentioned in this message */
1143
- getGroupMentions: () => Promise<GroupChat[]|[]>,
1144
- /** Returns the quoted message, if any */
1145
- getQuotedMessage: () => Promise<Message>,
1146
- /**
1147
- * Sends a message as a reply to this message.
1148
- * If chatId is specified, it will be sent through the specified Chat.
1149
- * If not, it will send the message in the same Chat as the original message was sent.
1150
- */
1151
- reply: (content: MessageContent, chatId?: string, options?: MessageSendOptions) => Promise<Message>,
1152
- /** React to this message with an emoji*/
1153
- react: (reaction: string) => Promise<void>,
1154
- /**
1155
- * Forwards this message to another chat (that you chatted before, otherwise it will fail)
1156
- */
1157
- forward: (chat: Chat | string) => Promise<void>,
1158
- /** Star this message */
1159
- star: () => Promise<void>,
1160
- /** Unstar this message */
1161
- unstar: () => Promise<void>,
1162
- /** Pins the message (group admins can pin messages of all group members) */
1163
- pin: (duration: number) => Promise<boolean>,
1164
- /** Unpins the message (group admins can unpin messages of all group members) */
1165
- unpin: () => Promise<boolean>,
1166
- /** Get information about message delivery status */
1167
- getInfo: () => Promise<MessageInfo | null>,
1168
- /**
1169
- * Gets the order associated with a given message
1170
- */
1171
- getOrder: () => Promise<Order>,
1172
- /**
1173
- * Gets the payment details associated with a given message
1174
- */
1175
- getPayment: () => Promise<Payment>,
1176
- /**
1177
- * Gets the reactions associated with the given message
1178
- */
1179
- getReactions: () => Promise<ReactionList[]>,
1180
- /** Edits the current message */
1181
- edit: (content: MessageContent, options?: MessageEditOptions) => Promise<Message | null>,
1182
- /**
1183
- * Edits the current ScheduledEvent message.
1184
- * Once the event is canceled, it can not be edited.
1185
- */
1186
- editScheduledEvent: (editedEventObject: Event) => Promise<Message | null>,
1187
- }
1188
-
1189
- /** ID that represents a message */
1190
- export interface MessageId {
1191
- fromMe: boolean,
1192
- remote: string,
1193
- id: string,
1194
- _serialized: string,
1195
- }
1196
-
1197
- /** Options for sending a location */
1198
- export interface LocationSendOptions {
1199
- /** Location name */
1200
- name?: string;
1201
- /** Location address */
1202
- address?: string;
1203
- /** URL address to be shown within a location message */
1204
- url?: string;
1205
- }
1206
-
1207
- /** Location information */
1208
- export class Location {
1209
- latitude: string;
1210
- longitude: string;
1211
- name?: string;
1212
- address?: string;
1213
- url?: string;
1214
- description?: string;
1215
-
1216
- constructor(latitude: number, longitude: number, options?: LocationSendOptions)
1217
- }
1218
-
1219
- /** Poll send options */
1220
- export interface PollSendOptions {
1221
- /** False for a single choice poll, true for a multiple choice poll (false by default) */
1222
- allowMultipleAnswers?: boolean,
1223
- /**
1224
- * The custom message secret, can be used as a poll ID
1225
- * @note It has to be a unique vector with a length of 32
1226
- */
1227
- messageSecret: Array<number>|undefined
1228
- }
1229
-
1230
- /** Represents a Poll on WhatsApp */
1231
- export class Poll {
1232
- pollName: string
1233
- pollOptions: Array<{
1234
- name: string,
1235
- localId: number
1236
- }>
1237
- options: PollSendOptions
1238
-
1239
- constructor(pollName: string, pollOptions: Array<string>, options?: PollSendOptions)
1240
- }
1241
-
1242
- /** ScheduledEvent send options */
1243
- export interface ScheduledEventSendOptions {
1244
- /** The scheduled event description */
1245
- description?: string,
1246
- /** The end time of the event */
1247
- endTime?: Date,
1248
- /** The location of the event */
1249
- location?: string,
1250
- /** The type of a WhatsApp call link to generate, valid values are: `video` | `voice` */
1251
- callType?: string,
1252
- /**
1253
- * Indicates if a scheduled event should be sent as an already canceled
1254
- * @default false
1255
- */
1256
- isEventCanceled?: boolean
1257
- /**
1258
- * The custom message secret, can be used as an event ID
1259
- * @note It has to be a unique vector with a length of 32
1260
- */
1261
- messageSecret: Array<number>|undefined
1262
- }
1263
-
1264
- /** Represents a ScheduledEvent on WhatsApp */
1265
- export class ScheduledEvent {
1266
- name: string
1267
- startTimeTs: number
1268
- eventSendOptions: {
1269
- description?: string;
1270
- endTimeTs?: number;
1271
- location?: string;
1272
- callType?: string;
1273
- isEventCanceled?: boolean;
1274
- messageSecret?: string;
1275
- };
1276
-
1277
- constructor(name: string, startTime: Date, options?: EventSendOptions)
1278
- }
1279
-
1280
- /** Represents a Poll Vote on WhatsApp */
1281
- export interface PollVote {
1282
- /** The person who voted */
1283
- voter: string;
1284
-
1285
- /**
1286
- * The selected poll option(s)
1287
- * If it's an empty array, the user hasn't selected any options on the poll,
1288
- * may occur when they deselected all poll options
1289
- */
1290
- selectedOptions: SelectedPollOption[];
1291
-
1292
- /** Timestamp the option was selected or deselected at */
1293
- interractedAtTs: number;
1294
-
1295
- /** The poll creation message associated with the poll vote */
1296
- parentMessage: Message;
1297
- }
1298
-
1299
- /** Selected poll option structure */
1300
- export interface SelectedPollOption {
1301
- /** The local selected option ID */
1302
- id: number;
1303
-
1304
- /** The option name */
1305
- name: string;
1306
- }
1307
-
1308
- export interface Label {
1309
- /** Label name */
1310
- name: string,
1311
- /** Label ID */
1312
- id: string,
1313
- /** Color assigned to the label */
1314
- hexColor: string,
1315
-
1316
- /** Get all chats that have been assigned this Label */
1317
- getChats: () => Promise<Chat[]>
1318
- }
1319
-
1320
- export interface Broadcast {
1321
- /** Chat Object ID */
1322
- id: {
1323
- server: string,
1324
- user: string,
1325
- _serialized: string
1326
- },
1327
- /** Unix timestamp of last story */
1328
- timestamp: number,
1329
- /** Number of available statuses */
1330
- totalCount: number,
1331
- /** Number of not viewed */
1332
- unreadCount: number,
1333
- /** Unix timestamp of last story */
1334
- msgs: Message[],
1335
-
1336
- /** Returns the Chat of the owner of the story */
1337
- getChat: () => Promise<Chat>,
1338
- /** Returns the Contact of the owner of the story */
1339
- getContact: () => Promise<Contact>,
1340
- }
1341
-
1342
- /** Options for sending a message */
1343
- export interface MessageSendOptions {
1344
- /** Show links preview. Has no effect on multi-device accounts. */
1345
- linkPreview?: boolean
1346
- /** Send audio as voice message with a generated waveform */
1347
- sendAudioAsVoice?: boolean
1348
- /** Send video as gif */
1349
- sendVideoAsGif?: boolean
1350
- /** Send media as sticker */
1351
- sendMediaAsSticker?: boolean
1352
- /** Send media as document */
1353
- sendMediaAsDocument?: boolean
1354
- /** Send media as quality HD */
1355
- sendMediaAsHd?: boolean
1356
- /** Send photo/video as a view once message */
1357
- isViewOnce?: boolean
1358
- /** Automatically parse vCards and send them as contacts */
1359
- parseVCards?: boolean
1360
- /** Image or videos caption */
1361
- caption?: string
1362
- /** Id of the message that is being quoted (or replied to) */
1363
- quotedMessageId?: string
1364
- /** User IDs to mention in the message */
1365
- mentions?: string[]
1366
- /** An array of object that handle group mentions */
1367
- groupMentions?: {
1368
- /** The name of a group to mention (can be custom) */
1369
- subject: string,
1370
- /** The group ID, e.g.: 'XXXXXXXXXX@g.us' */
1371
- id: string
1372
- }[]
1373
- /** Send 'seen' status */
1374
- sendSeen?: boolean
1375
- /** Bot Wid when doing a bot mention like @Meta AI */
1376
- invokedBotWid?: string
1377
- /** Media to be sent */
1378
- media?: MessageMedia
1379
- /** Extra options */
1380
- extra?: any
1381
- /** Sticker name, if sendMediaAsSticker is true */
1382
- stickerName?: string
1383
- /** Sticker author, if sendMediaAsSticker is true */
1384
- stickerAuthor?: string
1385
- /** Sticker categories, if sendMediaAsSticker is true */
1386
- stickerCategories?: string[],
1387
- /** Should the bot send a quoted message without the quoted message if it fails to get the quote?
1388
- * @default true (enabled) */
1389
- ignoreQuoteErrors?: boolean
1390
- /**
1391
- * Should the bot wait for the message send result?
1392
- * @default false
1393
- */
1394
- waitUntilMsgSent?: boolean
1395
- }
1396
-
1397
- /** Options for editing a message */
1398
- export interface MessageEditOptions {
1399
- /** Show links preview. Has no effect on multi-device accounts. */
1400
- linkPreview?: boolean
1401
- /** User IDs of users that being mentioned in the message */
1402
- mentions?: string[]
1403
- /** Extra options */
1404
- extra?: any
1405
- }
1406
-
1407
- export interface MediaFromURLOptions {
1408
- client?: Client
1409
- filename?: string
1410
- unsafeMime?: boolean
1411
- reqOptions?: RequestInit
1412
- }
1413
-
1414
- /** Media attached to a message */
1415
- export class MessageMedia {
1416
- /** MIME type of the attachment */
1417
- mimetype: string
1418
- /** Base64-encoded data of the file */
1419
- data: string
1420
- /** Document file name. Value can be null */
1421
- filename?: string | null
1422
- /** Document file size in bytes. Value can be null. */
1423
- filesize?: number | null
1424
-
1425
- /**
1426
- * @param {string} mimetype MIME type of the attachment
1427
- * @param {string} data Base64-encoded data of the file
1428
- * @param {?string} filename Document file name. Value can be null
1429
- * @param {?number} filesize Document file size in bytes. Value can be null.
1430
- */
1431
- constructor(mimetype: string, data: string, filename?: string | null, filesize?: number | null)
1432
-
1433
- /** Creates a MessageMedia instance from a local file path */
1434
- static fromFilePath: (filePath: string) => MessageMedia
1435
-
1436
- /** Creates a MessageMedia instance from a URL */
1437
- static fromUrl: (url: string, options?: MediaFromURLOptions) => Promise<MessageMedia>
1438
- }
1439
-
1440
- export type MessageContent = string | MessageMedia | Location | Poll | Contact | Contact[] | List | Buttons | ScheduledEvent
1441
-
1442
- /**
1443
- * Represents a Contact on WhatsApp
1444
- *
1445
- * @example
1446
- * {
1447
- * id: {
1448
- * server: 'c.us',
1449
- * user: '554199999999',
1450
- * _serialized: `554199999999@c.us`
1451
- * },
1452
- * number: '554199999999',
1453
- * isBusiness: false,
1454
- * isEnterprise: false,
1455
- * labels: [],
1456
- * name: undefined,
1457
- * pushname: 'John',
1458
- * sectionHeader: undefined,
1459
- * shortName: undefined,
1460
- * statusMute: false,
1461
- * type: 'in',
1462
- * verifiedLevel: undefined,
1463
- * verifiedName: undefined,
1464
- * isMe: false,
1465
- * isUser: true,
1466
- * isGroup: false,
1467
- * isWAContact: true,
1468
- * isMyContact: false
1469
- * }
1470
- */
1471
- export interface Contact {
1472
- /** Contact's phone number */
1473
- number: string,
1474
- /** Indicates if the contact is a business contact */
1475
- isBusiness: boolean,
1476
- /** ID that represents the contact */
1477
- id: ContactId,
1478
- /** Indicates if the contact is an enterprise contact */
1479
- isEnterprise: boolean,
1480
- /** Indicates if the contact is a group contact */
1481
- isGroup: boolean,
1482
- /** Indicates if the contact is the current user's contact */
1483
- isMe: boolean,
1484
- /** Indicates if the number is saved in the current phone's contacts */
1485
- isMyContact: boolean
1486
- /** Indicates if the contact is a user contact */
1487
- isUser: boolean,
1488
- /** Indicates if the number is registered on WhatsApp */
1489
- isWAContact: boolean,
1490
- /** Indicates if you have blocked this contact */
1491
- isBlocked: boolean,
1492
- /** @todo verify labels type. didn't have any documentation */
1493
- labels?: string[],
1494
- /** The contact's name, as saved by the current user */
1495
- name?: string,
1496
- /** The name that the contact has configured to be shown publically */
1497
- pushname: string,
1498
- /** @todo missing documentation */
1499
- sectionHeader: string,
1500
- /** A shortened version of name */
1501
- shortName?: string,
1502
- /** Indicates if the status from the contact is muted */
1503
- statusMute: boolean,
1504
- /** @todo missing documentation */
1505
- type: string,
1506
- /** @todo missing documentation */
1507
- verifiedLevel?: undefined,
1508
- /** @todo missing documentation */
1509
- verifiedName?: undefined,
1510
-
1511
- /** Returns the contact's profile picture URL, if privacy settings allow it */
1512
- getProfilePicUrl: () => Promise<string>,
1513
-
1514
- /** Returns the Chat that corresponds to this Contact.
1515
- * Will return null when getting chat for currently logged in user.
1516
- */
1517
- getChat: () => Promise<Chat>,
1518
-
1519
- /** Returns the contact's countrycode, (1541859685@c.us) => (1) */
1520
- getCountryCode(): Promise<string>,
1521
-
1522
- /** Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901) */
1523
- getFormattedNumber(): Promise<string>,
1524
-
1525
- /** Blocks this contact from WhatsApp */
1526
- block: () => Promise<boolean>,
1527
-
1528
- /** Unlocks this contact from WhatsApp */
1529
- unblock: () => Promise<boolean>,
1530
-
1531
- /** Gets the Contact's current "about" info. Returns null if you don't have permission to read their status. */
1532
- getAbout: () => Promise<string | null>,
1533
-
1534
- /** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
1535
- getCommonGroups: () => Promise<ChatId[]>
1536
-
1537
- }
1538
-
1539
- export interface ContactId {
1540
- server: string,
1541
- user: string,
1542
- _serialized: string,
1543
- }
1544
-
1545
- export interface BusinessCategory {
1546
- id: string,
1547
- localized_display_name: string,
1548
- }
1549
-
1550
- export interface BusinessHoursOfDay {
1551
- mode: string,
1552
- hours: number[]
1553
- }
1554
-
1555
- export interface BusinessHours {
1556
- config: {
1557
- sun: BusinessHoursOfDay,
1558
- mon: BusinessHoursOfDay,
1559
- tue: BusinessHoursOfDay,
1560
- wed: BusinessHoursOfDay,
1561
- thu: BusinessHoursOfDay,
1562
- fri: BusinessHoursOfDay,
1563
- }
1564
- timezone: string,
1565
- }
1566
-
1567
-
1568
-
1569
- export interface BusinessContact extends Contact {
1570
- /**
1571
- * The contact's business profile
1572
- */
1573
- businessProfile: {
1574
- /** The contact's business profile id */
1575
- id: ContactId,
1576
-
1577
- /** The contact's business profile tag */
1578
- tag: string,
1579
-
1580
- /** The contact's business profile description */
1581
- description: string,
1582
-
1583
- /** The contact's business profile categories */
1584
- categories: BusinessCategory[],
1585
-
1586
- /** The contact's business profile options */
1587
- profileOptions: {
1588
- /** The contact's business profile commerce experience*/
1589
- commerceExperience: string,
1590
-
1591
- /** The contact's business profile cart options */
1592
- cartEnabled: boolean,
1593
- }
1594
-
1595
- /** The contact's business profile email */
1596
- email: string,
1597
-
1598
- /** The contact's business profile websites */
1599
- website: string[],
1600
-
1601
- /** The contact's business profile latitude */
1602
- latitude: number,
1603
-
1604
- /** The contact's business profile longitude */
1605
- longitude: number,
1606
-
1607
- /** The contact's business profile work hours*/
1608
- businessHours: BusinessHours
1609
-
1610
- /** The contact's business profile address */
1611
- address: string,
1612
-
1613
- /** The contact's business profile facebook page */
1614
- fbPage: object,
1615
-
1616
- /** Indicate if the contact's business profile linked */
1617
- ifProfileLinked: boolean
1618
-
1619
- /** The contact's business profile coverPhoto */
1620
- coverPhoto: null | any,
1621
- }
1622
- }
1623
-
1624
- export interface PrivateContact extends Contact {
1625
-
1626
- }
1627
-
1628
- /**
1629
- * Represents a Chat on WhatsApp
1630
- *
1631
- * @example
1632
- * {
1633
- * id: {
1634
- * server: 'c.us',
1635
- * user: '554199999999',
1636
- * _serialized: `554199999999@c.us`
1637
- * },
1638
- * name: '+55 41 9999-9999',
1639
- * isGroup: false,
1640
- * isReadOnly: false,
1641
- * unreadCount: 6,
1642
- * timestamp: 1591484087,
1643
- * archived: false
1644
- * }
1645
- */
1646
- export interface Chat {
1647
- /** Indicates if the Chat is archived */
1648
- archived: boolean,
1649
- /** ID that represents the chat */
1650
- id: ChatId,
1651
- /** Indicates if the Chat is a Group Chat */
1652
- isGroup: boolean,
1653
- /** Indicates if the Chat is readonly */
1654
- isReadOnly: boolean,
1655
- /** Indicates if the Chat is muted */
1656
- isMuted: boolean,
1657
- /** Unix timestamp for when the mute expires */
1658
- muteExpiration: number,
1659
- /** Title of the chat */
1660
- name: string,
1661
- /** Unix timestamp for when the last activity occurred */
1662
- timestamp: number,
1663
- /** Amount of messages unread */
1664
- unreadCount: number,
1665
- /** Last message of chat */
1666
- lastMessage: Message,
1667
- /** Indicates if the Chat is pinned */
1668
- pinned: boolean,
1669
-
1670
- /** Archives this chat */
1671
- archive: () => Promise<void>,
1672
- /** Pins this chat and returns its new Pin state */
1673
- pin: () => Promise<boolean>,
1674
- /** Unpins this chat and returns its new Pin state */
1675
- unpin: () => Promise<boolean>,
1676
- /** Clears all messages from the chat */
1677
- clearMessages: () => Promise<boolean>,
1678
- /** Stops typing or recording in chat immediately. */
1679
- clearState: () => Promise<boolean>,
1680
- /** Deletes the chat */
1681
- delete: () => Promise<boolean>,
1682
- /** Loads chat messages, sorted from earliest to latest. */
1683
- fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
1684
- /** Mutes this chat forever, unless a date is specified */
1685
- mute: (unmuteDate?: Date) => Promise<{ isMuted: boolean, muteExpiration: number }>,
1686
- /** Send a message to this chat */
1687
- sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
1688
- /** Sets the chat as seen */
1689
- sendSeen: () => Promise<boolean>,
1690
- /** Simulate recording audio in chat. This will last for 25 seconds */
1691
- sendStateRecording: () => Promise<void>,
1692
- /** Simulate typing in chat. This will last for 25 seconds. */
1693
- sendStateTyping: () => Promise<void>,
1694
- /** un-archives this chat */
1695
- unarchive: () => Promise<void>,
1696
- /** Unmutes this chat */
1697
- unmute: () => Promise<{ isMuted: boolean, muteExpiration: number }>,
1698
- /** Returns the Contact that corresponds to this Chat. */
1699
- getContact: () => Promise<Contact>,
1700
- /** Marks this Chat as unread */
1701
- markUnread: () => Promise<void>,
1702
- /** Returns array of all Labels assigned to this Chat */
1703
- getLabels: () => Promise<Label[]>,
1704
- /** Add or remove labels to this Chat */
1705
- changeLabels: (labelIds: Array<string | number>) => Promise<void>
1706
- /** Gets instances of all pinned messages in a chat */
1707
- getPinnedMessages: () => Promise<[Message]|[]>
1708
- /** Sync history conversation of the Chat */
1709
- syncHistory: () => Promise<boolean>
1710
- }
1711
-
1712
- export interface Channel {
1713
- /** ID that represents the channel */
1714
- id: {
1715
- server: string;
1716
- user: string;
1717
- _serialized: string;
1718
- };
1719
- /** Title of the channel */
1720
- name: string;
1721
- /** The channel description */
1722
- description: string;
1723
- /** Indicates if it is a Channel */
1724
- isChannel: boolean;
1725
- /** Indicates if it is a Group */
1726
- isGroup: boolean;
1727
- /** Indicates if the channel is readonly */
1728
- isReadOnly: boolean;
1729
- /** Amount of messages unread */
1730
- unreadCount: number;
1731
- /** Unix timestamp for when the last activity occurred */
1732
- timestamp: number;
1733
- /** Indicates if the channel is muted or not */
1734
- isMuted: boolean;
1735
- /** Unix timestamp for when the mute expires */
1736
- muteExpiration: number;
1737
- /** Last message in the channel */
1738
- lastMessage: Message | undefined;
1739
-
1740
- /** Gets the subscribers of the channel (only those who are in your contact list) */
1741
- getSubscribers(limit?: number): Promise<{contact: Contact, role: string}[]>;
1742
- /** Updates the channel subject */
1743
- setSubject(newSubject: string): Promise<boolean>;
1744
- /** Updates the channel description */
1745
- setDescription(newDescription: string): Promise<boolean>;
1746
- /** Updates the channel profile picture */
1747
- setProfilePicture(newProfilePicture: MessageMedia): Promise<boolean>;
1748
- /**
1749
- * Updates available reactions to use in the channel
1750
- *
1751
- * Valid values for passing to the method are:
1752
- * 0 for NONE reactions to be avaliable
1753
- * 1 for BASIC reactions to be available: 👍, ❤️, 😂, 😮, 😢, 🙏
1754
- * 2 for ALL reactions to be available
1755
- */
1756
- setReactionSetting(reactionCode: number): Promise<boolean>;
1757
- /** Mutes the channel */
1758
- mute(): Promise<boolean>;
1759
- /** Unmutes the channel */
1760
- unmute(): Promise<boolean>;
1761
- /** Sends a message to this channel */
1762
- sendMessage(content: string|MessageMedia, options?: MessageSendChannelOptions): Promise<Message>;
1763
- /** Sets the channel as seen */
1764
- sendSeen(): Promise<boolean>;
1765
- /** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
1766
- sendChannelAdminInvite(chatId: string, options?: { comment?: string }): Promise<boolean>;
1767
- /** Accepts a channel admin invitation and promotes the current user to a channel admin */
1768
- acceptChannelAdminInvite(): Promise<boolean>;
1769
- /** Revokes a channel admin invitation sent to a user by a channel owner */
1770
- revokeChannelAdminInvite(userId: string): Promise<boolean>;
1771
- /** Demotes a channel admin to a regular subscriber (can be used also for self-demotion) */
1772
- demoteChannelAdmin(userId: string): Promise<boolean>;
1773
- /** Loads channel messages, sorted from earliest to latest */
1774
- fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>;
1775
- /**
1776
- * Transfers a channel ownership to another user.
1777
- * Note: the user you are transferring the channel ownership to must be a channel admin.
1778
- */
1779
- transferChannelOwnership(newOwnerId: string, options?: TransferChannelOwnershipOptions): Promise<boolean>;
1780
- /** Deletes the channel you created */
1781
- deleteChannel(): Promise<boolean>;
1782
- }
1783
-
1784
- /** Options for transferring a channel ownership to another user */
1785
- export interface TransferChannelOwnershipOptions {
1786
- /**
1787
- * If true, after the channel ownership is being transferred to another user,
1788
- * the current user will be dismissed as a channel admin and will become to a channel subscriber.
1789
- */
1790
- shouldDismissSelfAsAdmin?: boolean
1791
- }
1792
-
1793
- /** Options for sending a message */
1794
- export interface MessageSendChannelOptions {
1795
- /** Image or videos caption */
1796
- caption?: string
1797
- /** User IDs of user that will be mentioned in the message */
1798
- mentions?: string[]
1799
- /** Image or video to be sent */
1800
- media?: MessageMedia
1801
- /** Extra options */
1802
- extra?: any
1803
- }
1804
-
1805
- export interface MessageSearchOptions {
1806
- /**
1807
- * The amount of messages to return. If no limit is specified, the available messages will be returned.
1808
- * Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation.
1809
- * Set this to Infinity to load all messages.
1810
- */
1811
- limit?: number
1812
- /**
1813
- * Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
1814
- */
1815
- fromMe?: boolean
1816
- }
1817
-
1818
- /**
1819
- * Id that represents the chat
1820
- *
1821
- * @example
1822
- * id: {
1823
- * server: 'c.us',
1824
- * user: '554199999999',
1825
- * _serialized: `554199999999@c.us`
1826
- * },
1827
- */
1828
- export interface ChatId {
1829
- /**
1830
- * Whatsapp server domain
1831
- * @example `c.us`
1832
- */
1833
- server: string,
1834
- /**
1835
- * User whatsapp number
1836
- * @example `554199999999`
1837
- */
1838
- user: string,
1839
- /**
1840
- * Serialized id
1841
- * @example `554199999999@c.us`
1842
- */
1843
- _serialized: string,
1844
- }
1845
-
1846
- export interface PrivateChat extends Chat {
1847
-
1848
- }
1849
-
1850
- export type GroupParticipant = {
1851
- id: ContactId,
1852
- isAdmin: boolean
1853
- isSuperAdmin: boolean
1854
- }
1855
-
1856
- /** Promotes or demotes participants by IDs to regular users or admins */
1857
- export type ChangeParticipantsPermissions =
1858
- (participantIds: Array<string>) => Promise<{ status: number }>
1859
-
1860
- /** An object that handles the result for addParticipants method */
1861
- export interface AddParticipantsResult {
1862
- [participantId: string]: {
1863
- code: number;
1864
- message: string;
1865
- isInviteV4Sent: boolean,
1866
- }
1867
- }
1868
-
1869
- /** An object that handles options for adding participants */
1870
- export interface AddParticipantsOptions {
1871
- /**
1872
- * The number of milliseconds to wait before adding the next participant.
1873
- * If it is an array, a random sleep time between the sleep[0] and sleep[1] values will be added
1874
- * (the difference must be >=100 ms, otherwise, a random sleep time between sleep[1] and sleep[1] + 100
1875
- * will be added). If sleep is a number, a sleep time equal to its value will be added
1876
- * @default [250,500]
1877
- */
1878
- sleep?: Array<number>|number,
1879
- /**
1880
- * If true, the inviteV4 will be sent to those participants
1881
- * who have restricted others from being automatically added to groups,
1882
- * otherwise the inviteV4 won't be sent
1883
- * @default true
1884
- */
1885
- autoSendInviteV4?: boolean,
1886
- /**
1887
- * The comment to be added to an inviteV4 (empty string by default)
1888
- * @default ''
1889
- */
1890
- comment?: string
1891
- }
1892
-
1893
- /** An object that handles the information about the group membership request */
1894
- export interface GroupMembershipRequest {
1895
- /** The wid of a user who requests to enter the group */
1896
- id: Object;
1897
- /** The wid of a user who created that request */
1898
- addedBy: Object;
1899
- /** The wid of a community parent group to which the current group is linked */
1900
- parentGroupId: Object | null;
1901
- /** The method used to create the request: NonAdminAdd/InviteLink/LinkedGroupJoin */
1902
- requestMethod: string,
1903
- /** The timestamp the request was created at */
1904
- t: number
1905
- }
1906
-
1907
- /** An object that handles the result for membership request action */
1908
- export interface MembershipRequestActionResult {
1909
- /** User ID whos membership request was approved/rejected */
1910
- requesterId: Array<string> | string | null;
1911
- /** An error code that occurred during the operation for the participant */
1912
- error?: number;
1913
- /** A message with a result of membership request action */
1914
- message: string;
1915
- }
1916
-
1917
- /** Options for performing a membership request action */
1918
- export interface MembershipRequestActionOptions {
1919
- /** User ID/s who requested to join the group, if no value is provided, the method will search for all membership requests for that group */
1920
- requesterIds: Array<string> | string | null;
1921
- /** The number of milliseconds to wait before performing an operation for the next requester. If it is an array, a random sleep time between the sleep[0] and sleep[1] values will be added (the difference must be >=100 ms, otherwise, a random sleep time between sleep[1] and sleep[1] + 100 will be added). If sleep is a number, a sleep time equal to its value will be added. By default, sleep is an array with a value of [250, 500] */
1922
- sleep: Array<number> | number | null;
1923
- }
1924
-
1925
- export interface GroupChat extends Chat {
1926
- /** Group owner */
1927
- owner: ContactId;
1928
- /** Date at which the group was created */
1929
- createdAt: Date;
1930
- /** Group description */
1931
- description: string;
1932
- /** Group participants */
1933
- participants: Array<GroupParticipant>;
1934
- /** Adds a list of participants by ID to the group */
1935
- addParticipants: (participantIds: string | string[], options?: AddParticipantsOptions) => Promise<{ [key: string]: AddParticipantsResult } | string>;
1936
- /** Removes a list of participants by ID to the group */
1937
- removeParticipants: (participantIds: string[]) => Promise<{ status: number }>;
1938
- /** Promotes participants by IDs to admins */
1939
- promoteParticipants: ChangeParticipantsPermissions;
1940
- /** Demotes participants by IDs to regular users */
1941
- demoteParticipants: ChangeParticipantsPermissions;
1942
- /** Updates the group subject */
1943
- setSubject: (subject: string) => Promise<boolean>;
1944
- /** Updates the group description */
1945
- setDescription: (description: string) => Promise<boolean>;
1946
- /**
1947
- * Updates the group setting to allow only admins to add members to the group.
1948
- * @param {boolean} [adminsOnly=true] Enable or disable this option
1949
- * @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
1950
- */
1951
- setAddMembersAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
1952
- /** Updates the group settings to only allow admins to send messages
1953
- * @param {boolean} [adminsOnly=true] Enable or disable this option
1954
- * @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
1955
- */
1956
- setMessagesAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
1957
- /**
1958
- * Updates the group settings to only allow admins to edit group info (title, description, photo).
1959
- * @param {boolean} [adminsOnly=true] Enable or disable this option
1960
- * @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
1961
- */
1962
- setInfoAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
1963
- /**
1964
- * Gets an array of membership requests
1965
- * @returns {Promise<Array<GroupMembershipRequest>>} An array of membership requests
1966
- */
1967
- getGroupMembershipRequests: () => Promise<Array<GroupMembershipRequest>>;
1968
- /**
1969
- * Approves membership requests if any
1970
- * @param {MembershipRequestActionOptions} options Options for performing a membership request action
1971
- * @returns {Promise<Array<MembershipRequestActionResult>>} Returns an array of requester IDs whose membership requests were approved and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
1972
- */
1973
- approveGroupMembershipRequests: (options: MembershipRequestActionOptions) => Promise<Array<MembershipRequestActionResult>>;
1974
- /**
1975
- * Rejects membership requests if any
1976
- * @param {MembershipRequestActionOptions} options Options for performing a membership request action
1977
- * @returns {Promise<Array<MembershipRequestActionResult>>} Returns an array of requester IDs whose membership requests were rejected and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
1978
- */
1979
- rejectGroupMembershipRequests: (options: MembershipRequestActionOptions) => Promise<Array<MembershipRequestActionResult>>;
1980
- /** Gets the invite code for a specific group */
1981
- getInviteCode: () => Promise<string>;
1982
- /** Invalidates the current group invite code and generates a new one */
1983
- revokeInvite: () => Promise<void>;
1984
- /** Makes the bot leave the group */
1985
- leave: () => Promise<void>;
1986
- /** Sets the group's picture.*/
1987
- setPicture: (media: MessageMedia) => Promise<boolean>;
1988
- /** Deletes the group's picture */
1989
- deletePicture: () => Promise<boolean>;
1990
- }
1991
-
1992
- /**
1993
- * Represents the metadata associated with a given product
1994
- *
1995
- */
1996
- export interface ProductMetadata {
1997
- /** Product Id */
1998
- id: string,
1999
- /** Product Name */
2000
- name: string,
2001
- /** Product Description */
2002
- description: string,
2003
- /** Retailer ID */
2004
- retailer_id?: string
2005
- }
2006
-
2007
- /**
2008
- * Represents a Product on Whatsapp
2009
- * @example
2010
- * {
2011
- * "id": "123456789",
2012
- * "price": "150000",
2013
- * "thumbnailId": "123456789",
2014
- * "thumbnailUrl": "https://mmg.whatsapp.net",
2015
- * "currency": "GTQ",
2016
- * "name": "Store Name",
2017
- * "quantity": 1
2018
- * }
2019
- */
2020
- export interface Product {
2021
- /** Product Id */
2022
- id: string,
2023
- /** Price */
2024
- price?: string,
2025
- /** Product Thumbnail*/
2026
- thumbnailUrl: string,
2027
- /** Currency */
2028
- currency: string,
2029
- /** Product Name */
2030
- name: string,
2031
- /** Product Quantity*/
2032
- quantity: number,
2033
- /** Gets the Product metadata */
2034
- getData: () => Promise<ProductMetadata>
2035
- }
2036
-
2037
- /**
2038
- * Represents a Order on WhatsApp
2039
- *
2040
- * @example
2041
- * {
2042
- * "products": [
2043
- * {
2044
- * "id": "123456789",
2045
- * "price": "150000",
2046
- * "thumbnailId": "123456789",
2047
- * "thumbnailUrl": "https://mmg.whatsapp.net",
2048
- * "currency": "GTQ",
2049
- * "name": "Store Name",
2050
- * "quantity": 1
2051
- * }
2052
- * ],
2053
- * "subtotal": "150000",
2054
- * "total": "150000",
2055
- * "currency": "GTQ",
2056
- * "createdAt": 1610136796,
2057
- * "sellerJid": "55555555@s.whatsapp.net"
2058
- * }
2059
- */
2060
- export interface Order {
2061
- /** List of products*/
2062
- products: Array<Product>,
2063
- /** Order Subtotal */
2064
- subtotal: string,
2065
- /** Order Total */
2066
- total: string,
2067
- /** Order Currency */
2068
- currency: string,
2069
- /** Order Created At*/
2070
- createdAt: number;
2071
- }
2072
-
2073
- /**
2074
- * Represents a Payment on WhatsApp
2075
- *
2076
- * @example
2077
- * {
2078
- * id: {
2079
- * fromMe: true,
2080
- * remote: {
2081
- * server: 'c.us',
2082
- * user: '5511999999999',
2083
- * _serialized: '5511999999999@c.us'
2084
- * },
2085
- * id: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
2086
- * _serialized: 'true_5511999999999@c.us_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
2087
- * },
2088
- * paymentCurrency: 'BRL',
2089
- * paymentAmount1000: 1000,
2090
- * paymentMessageReceiverJid: {
2091
- * server: 'c.us',
2092
- * user: '5511999999999',
2093
- * _serialized: '5511999999999@c.us'
2094
- * },
2095
- * paymentTransactionTimestamp: 1623463058,
2096
- * paymentStatus: 4,
2097
- * paymentTxnStatus: 4,
2098
- * paymentNote: 'note'
2099
- * }
2100
- */
2101
- export interface Payment {
2102
- /** Payment Id*/
2103
- id: object,
2104
- /** Payment currency */
2105
- paymentCurrency: string,
2106
- /** Payment ammount */
2107
- paymentAmount1000 : number,
2108
- /** Payment receiver */
2109
- paymentMessageReceiverJid : object,
2110
- /** Payment transaction timestamp */
2111
- paymentTransactionTimestamp : number,
2112
- /** Payment paymentStatus */
2113
- paymentStatus : number,
2114
- /** Integer that represents the payment Text */
2115
- paymentTxnStatus : number,
2116
- /** The note sent with the payment */
2117
- paymentNote : string;
2118
- }
2119
-
2120
- /**
2121
- * Represents a Call on WhatsApp
2122
- *
2123
- * @example
2124
- * Call {
2125
- * id: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
2126
- * from: '5511999999@c.us',
2127
- * timestamp: 1625003709,
2128
- * isVideo: false,
2129
- * isGroup: false,
2130
- * fromMe: false,
2131
- * canHandleLocally: false,
2132
- * webClientShouldHandle: false,
2133
- * participants: []
2134
- * }
2135
- */
2136
- export interface Call {
2137
- /** Call Id */
2138
- id: string,
2139
- /** from */
2140
- from?: string,
2141
- /** Unix timestamp for when the call was created*/
2142
- timestamp: number,
2143
- /** Is video */
2144
- isVideo: boolean,
2145
- /** Is Group */
2146
- isGroup: boolean,
2147
- /** Indicates if the call was sent by the current user */
2148
- fromMe: boolean,
2149
- /** indicates if the call can be handled in waweb */
2150
- canHandleLocally: boolean,
2151
- /** indicates if the call should be handled in waweb */
2152
- webClientShouldHandle: boolean,
2153
- /** Object with participants */
2154
- participants: object
2155
-
2156
- /** Reject the call */
2157
- reject: () => Promise<void>
2158
- }
2159
-
2160
- /** Message type List */
2161
- export class List {
2162
- body: string
2163
- buttonText: string
2164
- sections: Array<any>
2165
- title?: string | null
2166
- footer?: string | null
2167
-
2168
- constructor(body: string, buttonText: string, sections: Array<any>, title?: string | null, footer?: string | null)
2169
- }
2170
-
2171
- /** Message type Buttons */
2172
- export class Buttons {
2173
- body: string | MessageMedia
2174
- buttons: Array<{ buttonId: string; buttonText: {displayText: string}; type: number }>
2175
- title?: string | null
2176
- footer?: string | null
2177
-
2178
- constructor(body: string, buttons: Array<{ id?: string; body: string }>, title?: string | null, footer?: string | null)
2179
- }
2180
-
2181
- /** Message type Reaction */
2182
- export class Reaction {
2183
- id: MessageId
2184
- orphan: number
2185
- orphanReason?: string
2186
- timestamp: number
2187
- reaction: string
2188
- read: boolean
2189
- msgId: MessageId
2190
- senderId: string
2191
- ack?: number
2192
- }
2193
-
2194
- export type ReactionList = {
2195
- id: string,
2196
- aggregateEmoji: string,
2197
- hasReactionByMe: boolean,
2198
- senders: Array<Reaction>
2199
- }
2200
- }
2201
-
2202
- export = WAWebJS
1
+
2
+ import { EventEmitter } from 'events'
3
+ import { RequestInit } from 'node-fetch'
4
+ import * as puppeteer from 'puppeteer'
5
+ import InterfaceController from './src/util/InterfaceController'
6
+
7
+ declare namespace WAWebJS {
8
+
9
+ export class Client extends EventEmitter {
10
+ constructor(options: ClientOptions)
11
+
12
+ /** Current connection information */
13
+ public info: ClientInfo
14
+
15
+ /** Puppeteer page running WhatsApp Web */
16
+ pupPage?: puppeteer.Page
17
+
18
+ /** Puppeteer browser running WhatsApp Web */
19
+ pupBrowser?: puppeteer.Browser
20
+
21
+ /** Client interactivity interface */
22
+ interface?: InterfaceController
23
+
24
+ /**Accepts an invitation to join a group */
25
+ acceptInvite(inviteCode: string): Promise<string>
26
+
27
+ /** Accepts a channel admin invitation and promotes the current user to a channel admin */
28
+ acceptChannelAdminInvite(channelId: string): Promise<boolean>
29
+
30
+ /** Revokes a channel admin invitation sent to a user by a channel owner */
31
+ revokeChannelAdminInvite(channelId: string, userId: string): Promise<boolean>
32
+
33
+ /** Demotes a channel admin to a regular subscriber (can be used also for self-demotion) */
34
+ demoteChannelAdmin(channelId: string, userId: string): Promise<boolean>
35
+
36
+ /** Accepts a private invitation to join a group (v4 invite) */
37
+ acceptGroupV4Invite: (inviteV4: InviteV4Data) => Promise<{status: number}>
38
+
39
+ /**Returns an object with information about the invite code's group */
40
+ getInviteInfo(inviteCode: string): Promise<object>
41
+
42
+ /** Enables and returns the archive state of the Chat */
43
+ archiveChat(chatId: string): Promise<boolean>
44
+
45
+ /** Pins the Chat and returns its new Pin state */
46
+ pinChat(chatId: string): Promise<boolean>
47
+
48
+ /** Unpins the Chat and returns its new Pin state */
49
+ unpinChat(chatId: string): Promise<boolean>
50
+
51
+ /** Creates a new group */
52
+ createGroup(title: string, participants?: string | Contact | Contact[] | string[], options?: CreateGroupOptions): Promise<CreateGroupResult|string>
53
+
54
+ /** Creates a new channel */
55
+ createChannel(title: string, options?: CreateChannelOptions): Promise<CreateChannelResult | string>
56
+
57
+ /** Deletes the channel you created */
58
+ deleteChannel(channelId: string): Promise<boolean>;
59
+
60
+ /** Subscribe to channel */
61
+ subscribeToChannel(channelId: string): Promise<boolean>
62
+
63
+ /** Unsubscribe from channel */
64
+ unsubscribeFromChannel(channelId: string, options?: UnsubscribeOptions): Promise<boolean>
65
+
66
+ /**
67
+ * Searches for channels based on search criteria, there are some notes:
68
+ * 1. The method finds only channels you are not subscribed to currently
69
+ * 2. If you have never been subscribed to a found channel
70
+ * or you have unsubscribed from it with {@link UnsubscribeOptions.deleteLocalModels} set to 'true',
71
+ * the lastMessage property of a found channel will be 'null'
72
+ */
73
+ searchChannels(searchOptions: SearchChannelsOptions): Promise<Array<Channel> | []>
74
+
75
+ /** Closes the client */
76
+ destroy(): Promise<void>
77
+
78
+ /** Logs out the client, closing the current session */
79
+ logout(): Promise<void>
80
+
81
+ /** Get all blocked contacts by host account */
82
+ getBlockedContacts(): Promise<Contact[]>
83
+
84
+ /** Gets chat or channel instance by ID */
85
+ getChatById(chatId: string): Promise<Chat>
86
+
87
+ /** Gets a {@link Channel} instance by invite code */
88
+ getChannelByInviteCode(inviteCode: string): Promise<Channel>
89
+
90
+ /** Get all current chat instances */
91
+ getChats(): Promise<Chat[]>
92
+
93
+ /** Gets all cached {@link Channel} instances */
94
+ getChannels(): Promise<Channel[]>
95
+
96
+ /** Get contact instance by ID */
97
+ getContactById(contactId: string): Promise<Contact>
98
+
99
+ /** Get message by ID */
100
+ getMessageById(messageId: string): Promise<Message>
101
+
102
+ /** Gets instances of all pinned messages in a chat */
103
+ getPinnedMessages(chatId: string): Promise<[Message]|[]>
104
+
105
+ /** Get all current contact instances */
106
+ getContacts(): Promise<Contact[]>
107
+
108
+ /** Get the country code of a WhatsApp ID. (154185968@c.us) => (1) */
109
+ getCountryCode(number: string): Promise<string>
110
+
111
+ /** Get the formatted number of a WhatsApp ID. (12345678901@c.us) => (+1 (234) 5678-901) */
112
+ getFormattedNumber(number: string): Promise<string>
113
+
114
+ /** Get all current Labels */
115
+ getLabels(): Promise<Label[]>
116
+
117
+ /** Get all current Broadcasts */
118
+ getBroadcasts(): Promise<Broadcast[]>
119
+
120
+ /** Get broadcast instance by current user ID */
121
+ getBroadcastById(contactId: string): Promise<Broadcast>
122
+
123
+ /** Revoke current own status messages */
124
+ revokeStatusMessage(messageId: string): Promise<void>
125
+
126
+ /** Change labels in chats */
127
+ addOrRemoveLabels(labelIds: Array<number|string>, chatIds: Array<string>): Promise<void>
128
+
129
+ /** Get Label instance by ID */
130
+ getLabelById(labelId: string): Promise<Label>
131
+
132
+ /** Get all Labels assigned to a Chat */
133
+ getChatLabels(chatId: string): Promise<Label[]>
134
+
135
+ /** Get all Chats for a specific Label */
136
+ getChatsByLabelId(labelId: string): Promise<Chat[]>
137
+
138
+ /** Returns the contact ID's profile picture URL, if privacy settings allow it */
139
+ getProfilePicUrl(contactId: string): Promise<string>
140
+
141
+ /** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
142
+ getCommonGroups(contactId: string): Promise<ChatId[]>
143
+
144
+ /** Gets the current connection state for the client */
145
+ getState(): Promise<WAState>
146
+
147
+ /** Returns the version of WhatsApp Web currently being run */
148
+ getWWebVersion(): Promise<string>
149
+
150
+ /** Sets up events and requirements, kicks off authentication request */
151
+ initialize(): Promise<void>
152
+
153
+ /** Check if a given ID is registered in whatsapp */
154
+ isRegisteredUser(contactId: string): Promise<boolean>
155
+
156
+ /** Get the registered WhatsApp ID for a number. Returns null if the number is not registered on WhatsApp. */
157
+ getNumberId(number: string): Promise<ContactId | null>
158
+
159
+ /**
160
+ * Mutes this chat forever, unless a date is specified
161
+ * @param chatId ID of the chat that will be muted
162
+ * @param unmuteDate Date when the chat will be unmuted, leave as is to mute forever
163
+ */
164
+ muteChat(chatId: string, unmuteDate?: Date): Promise<{ isMuted: boolean, muteExpiration: number }>
165
+
166
+ /**
167
+ * Request authentication via pairing code instead of QR code
168
+ * @param phoneNumber - Phone number in international, symbol-free format (e.g. 12025550108 for US, 551155501234 for Brazil)
169
+ * @param showNotification - Show notification to pair on phone number. Defaults to `true`
170
+ * @param intervalMs - The interval in milliseconds on how frequent to generate pairing code (WhatsApp default to 3 minutes). Defaults to `180000`
171
+ * @returns {Promise<string>} - Returns a pairing code in format "ABCDEFGH"
172
+ */
173
+ requestPairingCode(phoneNumber: string, showNotification?: boolean, intervalMs?: number): Promise<string>
174
+
175
+ /** Force reset of connection state for the client */
176
+ resetState(): Promise<void>
177
+
178
+ /** Send a message to a specific chatId */
179
+ sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>
180
+
181
+ /** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
182
+ sendChannelAdminInvite(chatId: string, channelId: string, options?: { comment?: string }): Promise<boolean>
183
+
184
+ /** Searches for messages */
185
+ searchMessages(query: string, options?: { chatId?: string, page?: number, limit?: number }): Promise<Message[]>
186
+
187
+ /** Marks the client as online */
188
+ sendPresenceAvailable(): Promise<void>
189
+
190
+ /** Marks the client as offline */
191
+ sendPresenceUnavailable(): Promise<void>
192
+
193
+ /** Mark as seen for the Chat */
194
+ sendSeen(chatId: string): Promise<boolean>
195
+
196
+ /** Mark the Chat as unread */
197
+ markChatUnread(chatId: string): Promise<void>
198
+
199
+ /**
200
+ * Sets the current user's status message
201
+ * @param status New status message
202
+ */
203
+ setStatus(status: string): Promise<void>
204
+
205
+ /**
206
+ * Sets the current user's display name
207
+ * @param displayName New display name
208
+ */
209
+ setDisplayName(displayName: string): Promise<boolean>
210
+
211
+ /**
212
+ * Changes the autoload Audio
213
+ * @param flag true/false on or off
214
+ */
215
+ setAutoDownloadAudio(flag: boolean): Promise<void>
216
+ /**
217
+ * Changes the autoload Documents
218
+ * @param flag true/false on or off
219
+ */
220
+ setAutoDownloadDocuments(flag: boolean): Promise<void>
221
+ /**
222
+ * Changes the autoload Photos
223
+ * @param flag true/false on or off
224
+ */
225
+ setAutoDownloadPhotos(flag: boolean): Promise<void>
226
+ /**
227
+ * Changes the autoload Videos
228
+ * @param flag true/false on or off
229
+ */
230
+ setAutoDownloadVideos(flag: boolean): Promise<void>
231
+
232
+ /**
233
+ * Changing the background synchronization setting.
234
+ * NOTE: this action will take effect after you restart the client.
235
+ * @param flag true/false on or off
236
+ */
237
+ setBackgroundSync(flag: boolean): Promise<void>
238
+
239
+ /**
240
+ * Get user device count by ID
241
+ * Each WaWeb Connection counts as one device, and the phone (if exists) counts as one
242
+ * So for a non-enterprise user with one WaWeb connection it should return "2"
243
+ * @param {string} contactId
244
+ */
245
+ getContactDeviceCount(userId: string): Promise<number>
246
+
247
+ /** Sync history conversation of the Chat */
248
+ syncHistory(chatId: string): Promise<boolean>
249
+
250
+ /** Save new contact to user's addressbook or edit the existing one */
251
+ saveOrEditAddressbookContact(phoneNumber: string, firstName: string, lastName: string, syncToAddressbook?: boolean): Promise<void>
252
+
253
+ /**
254
+ * Add or edit a customer note
255
+ * @see https://faq.whatsapp.com/1433099287594476
256
+ */
257
+ addOrEditCustomerNote(userId: string, note: string): Promise<void>
258
+
259
+ /**
260
+ * Get a customer note
261
+ * @see https://faq.whatsapp.com/1433099287594476
262
+ */
263
+ getCustomerNote(userId: string): Promise<{
264
+ chatId: string;
265
+ content: string;
266
+ createdAt: number;
267
+ id: string;
268
+ modifiedAt: number;
269
+ type: string;
270
+ }>
271
+
272
+ /** Deletes the contact from user's addressbook */
273
+ deleteAddressbookContact(honeNumber: string): Promise<void>
274
+
275
+ /** Get Contact lid and phone */
276
+ getContactLidAndPhone(userIds: string[]): Promise<{ lid: string; pn: string }[]>
277
+
278
+ /** Changes and returns the archive state of the Chat */
279
+ unarchiveChat(chatId: string): Promise<boolean>
280
+
281
+ /** Unmutes the Chat */
282
+ unmuteChat(chatId: string): Promise<{ isMuted: boolean, muteExpiration: number }>
283
+
284
+ /** Sets the current user's profile picture */
285
+ setProfilePicture(media: MessageMedia): Promise<boolean>
286
+
287
+ /** Deletes the current user's profile picture */
288
+ deleteProfilePicture(): Promise<boolean>
289
+
290
+ /** Generates a WhatsApp call link (video call or voice call) */
291
+ createCallLink(startTime: Date, callType: string): Promise<string>
292
+
293
+ /**
294
+ * Sends a response to the scheduled event message, indicating whether a user is going to attend the event or not
295
+ * @param response The response code to the event message. Valid values are: `0` for NONE response (removes a previous response) | `1` for GOING | `2` for NOT GOING | `3` for MAYBE going
296
+ * @param eventMessageId The event message ID
297
+ */
298
+ sendResponseToScheduledEvent(response: number, eventMessageId: string): Promise<boolean>
299
+
300
+ /** Gets an array of membership requests */
301
+ getGroupMembershipRequests(groupId: string): Promise<Array<GroupMembershipRequest>>
302
+
303
+ /** Approves membership requests if any */
304
+ approveGroupMembershipRequests(groupId: string, options: MembershipRequestActionOptions): Promise<Array<MembershipRequestActionResult>>;
305
+
306
+ /** Rejects membership requests if any */
307
+ rejectGroupMembershipRequests(groupId: string, options: MembershipRequestActionOptions): Promise<Array<MembershipRequestActionResult>>;
308
+
309
+ /**
310
+ * Transfers a channel ownership to another user.
311
+ * Note: the user you are transferring the channel ownership to must be a channel admin.
312
+ */
313
+ transferChannelOwnership(channelId: string, newOwnerId: string, options?: TransferChannelOwnershipOptions): Promise<boolean>;
314
+
315
+ /** Get Poll Votes */
316
+ getPollVotes(messageId: string): Promise<PollVote[]>
317
+
318
+ /** Generic event */
319
+ on(event: string, listener: (...args: any) => void): this
320
+
321
+ /** Emitted when there has been an error while trying to restore an existing session */
322
+ on(event: 'auth_failure', listener: (message: string) => void): this
323
+
324
+ /** Emitted when authentication is successful */
325
+ on(event: 'authenticated', listener: (
326
+ /**
327
+ * Object containing session information, when using LegacySessionAuth. Can be used to restore the session
328
+ */
329
+ session?: ClientSession
330
+ ) => void): this
331
+
332
+ /**
333
+ * Emitted when the battery percentage for the attached device changes
334
+ * @deprecated
335
+ */
336
+ on(event: 'change_battery', listener: (batteryInfo: BatteryInfo) => void): this
337
+
338
+ /** Emitted when the connection state changes */
339
+ on(event: 'change_state', listener: (
340
+ /** the new connection state */
341
+ state: WAState
342
+ ) => void): this
343
+
344
+ /** Emitted when the client has been disconnected */
345
+ on(event: 'disconnected', listener: (
346
+ /** reason that caused the disconnect */
347
+ reason: WAState | "LOGOUT"
348
+ ) => void): this
349
+
350
+ /** Emitted when a user joins the chat via invite link or is added by an admin */
351
+ on(event: 'group_join', listener: (
352
+ /** GroupNotification with more information about the action */
353
+ notification: GroupNotification
354
+ ) => void): this
355
+
356
+ /** Emitted when a user leaves the chat or is removed by an admin */
357
+ on(event: 'group_leave', listener: (
358
+ /** GroupNotification with more information about the action */
359
+ notification: GroupNotification
360
+ ) => void): this
361
+
362
+ /** Emitted when a current user is promoted to an admin or demoted to a regular user */
363
+ on(event: 'group_admin_changed', listener: (
364
+ /** GroupNotification with more information about the action */
365
+ notification: GroupNotification
366
+ ) => void): this
367
+
368
+ /**
369
+ * Emitted when some user requested to join the group
370
+ * that has the membership approval mode turned on
371
+ */
372
+ on(event: 'group_membership_request', listener: (
373
+ /** GroupNotification with more information about the action */
374
+ notification: GroupNotification
375
+ ) => void): this
376
+
377
+ /** Emitted when group settings are updated, such as subject, description or picture */
378
+ on(event: 'group_update', listener: (
379
+ /** GroupNotification with more information about the action */
380
+ notification: GroupNotification
381
+ ) => void): this
382
+
383
+ /** Emitted when a contact or a group participant changed their phone number. */
384
+ on(event: 'contact_changed', listener: (
385
+ /** Message with more information about the event. */
386
+ message: Message,
387
+ /** Old user's id. */
388
+ oldId : String,
389
+ /** New user's id. */
390
+ newId : String,
391
+ /** Indicates if a contact or a group participant changed their phone number. */
392
+ isContact : Boolean
393
+ ) => void): this
394
+
395
+ /** Emitted when media has been uploaded for a message sent by the client */
396
+ on(event: 'media_uploaded', listener: (
397
+ /** The message with media that was uploaded */
398
+ message: Message
399
+ ) => void): this
400
+
401
+ /** Emitted when a new message is received */
402
+ on(event: 'message', listener: (
403
+ /** The message that was received */
404
+ message: Message
405
+ ) => void): this
406
+
407
+ /** Emitted when an ack event occurrs on message type */
408
+ on(event: 'message_ack', listener: (
409
+ /** The message that was affected */
410
+ message: Message,
411
+ /** The new ACK value */
412
+ ack: MessageAck
413
+ ) => void): this
414
+
415
+ /** Emitted when an edit event occurrs on message type */
416
+ on(event: 'message_edit', listener: (
417
+ /** The message that was affected */
418
+ message: Message,
419
+ /** New text message */
420
+ newBody: String,
421
+ /** Prev text message */
422
+ prevBody: String
423
+ ) => void): this
424
+
425
+ /** Emitted when a chat unread count changes */
426
+ on(event: 'unread_count', listener: (
427
+ /** The chat that was affected */
428
+ chat: Chat
429
+ ) => void): this
430
+
431
+ /** Emitted when a new message is created, which may include the current user's own messages */
432
+ on(event: 'message_create', listener: (
433
+ /** The message that was created */
434
+ message: Message
435
+ ) => void): this
436
+
437
+ /** Emitted when a new message ciphertext is received */
438
+ on(event: 'message_ciphertext', listener: (
439
+ /** The message that was ciphertext */
440
+ message: Message
441
+ ) => void): this
442
+
443
+ /** Emitted when a message is deleted for everyone in the chat */
444
+ on(event: 'message_revoke_everyone', listener: (
445
+ /** The message that was revoked, in its current state. It will not contain the original message's data */
446
+ message: Message,
447
+ /**The message that was revoked, before it was revoked.
448
+ * It will contain the message's original data.
449
+ * Note that due to the way this data is captured,
450
+ * it may be possible that this param will be undefined. */
451
+ revoked_msg?: Message | null
452
+ ) => void): this
453
+
454
+ /** Emitted when a message is deleted by the current user */
455
+ on(event: 'message_revoke_me', listener: (
456
+ /** The message that was revoked */
457
+ message: Message
458
+ ) => void): this
459
+
460
+ /** Emitted when a reaction is sent, received, updated or removed */
461
+ on(event: 'message_reaction', listener: (
462
+ /** The reaction object */
463
+ reaction: Reaction
464
+ ) => void): this
465
+
466
+ /** Emitted when a chat is removed */
467
+ on(event: 'chat_removed', listener: (
468
+ /** The chat that was removed */
469
+ chat: Chat
470
+ ) => void): this
471
+
472
+ /** Emitted when a chat is archived/unarchived */
473
+ on(event: 'chat_archived', listener: (
474
+ /** The chat that was archived/unarchived */
475
+ chat: Chat,
476
+ /** State the chat is currently in */
477
+ currState: boolean,
478
+ /** State the chat was previously in */
479
+ prevState: boolean
480
+ ) => void): this
481
+
482
+ /** Emitted when loading screen is appearing */
483
+ on(event: 'loading_screen', listener: (percent: string, message: string) => void): this
484
+
485
+ /** Emitted when the QR code is received */
486
+ on(event: 'qr', listener: (
487
+ /** qr code string
488
+ * @example ```1@9Q8tWf6bnezr8uVGwVCluyRuBOJ3tIglimzI5dHB0vQW2m4DQ0GMlCGf,f1/vGcW4Z3vBa1eDNl3tOjWqLL5DpYTI84DMVkYnQE8=,ZL7YnK2qdPN8vKo2ESxhOQ==``` */
489
+ qr: string
490
+ ) => void): this
491
+
492
+ /** Emitted when the phone number pairing code is received */
493
+ on(event: 'code', listener: (
494
+ /** pairing code string
495
+ * @example `8W2WZ3TS` */
496
+ code: string
497
+ ) => void): this
498
+
499
+ /** Emitted when a call is received */
500
+ on(event: 'call', listener: (
501
+ /** The call that started */
502
+ call: Call
503
+ ) => void): this
504
+
505
+ /** Emitted when the client has initialized and is ready to receive messages */
506
+ on(event: 'ready', listener: () => void): this
507
+
508
+ /** Emitted when the RemoteAuth session is saved successfully on the external Database */
509
+ on(event: 'remote_session_saved', listener: () => void): this
510
+
511
+ /**
512
+ * Emitted when some poll option is selected or deselected,
513
+ * shows a user's current selected option(s) on the poll
514
+ */
515
+ on(event: 'vote_update', listener: (
516
+ vote: PollVote
517
+ ) => void): this
518
+ }
519
+
520
+ /** Current connection information */
521
+ export interface ClientInfo {
522
+ /**
523
+ * Current user ID
524
+ * @deprecated Use .wid instead
525
+ */
526
+ me: ContactId
527
+ /** Current user ID */
528
+ wid: ContactId
529
+ /**
530
+ * Information about the phone this client is connected to. Not available in multi-device.
531
+ * @deprecated
532
+ */
533
+ phone: ClientInfoPhone
534
+ /** Platform the phone is running on */
535
+ platform: string
536
+ /** Name configured to be shown in push notifications */
537
+ pushname: string
538
+
539
+ /** Get current battery percentage and charging status for the attached device */
540
+ getBatteryStatus: () => Promise<BatteryInfo>
541
+ }
542
+
543
+ /**
544
+ * Information about the phone this client is connected to
545
+ * @deprecated
546
+ */
547
+ export interface ClientInfoPhone {
548
+ /** WhatsApp Version running on the phone */
549
+ wa_version: string
550
+ /** OS Version running on the phone (iOS or Android version) */
551
+ os_version: string
552
+ /** Device manufacturer */
553
+ device_manufacturer: string
554
+ /** Device model */
555
+ device_model: string
556
+ /** OS build number */
557
+ os_build_number: string
558
+ }
559
+
560
+ /** Options for initializing the whatsapp client */
561
+ export interface ClientOptions {
562
+ /** Timeout for authentication selector in puppeteer
563
+ * @default 0 */
564
+ authTimeoutMs?: number,
565
+ /** function to be evaluated On New Document
566
+ * @default undefined */
567
+ evalOnNewDoc?: Function,
568
+ /** Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/ */
569
+ puppeteer?: puppeteer.PuppeteerNodeLaunchOptions & puppeteer.ConnectOptions
570
+ /** Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used. */
571
+ authStrategy?: AuthStrategy,
572
+ /** The version of WhatsApp Web to use. Use options.webVersionCache to configure how the version is retrieved. */
573
+ webVersion?: string,
574
+ /** Determines how to retrieve the WhatsApp Web version specified in options.webVersion. */
575
+ webVersionCache?: WebCacheOptions,
576
+ /** How many times should the qrcode be refreshed before giving up
577
+ * @default 0 (disabled) */
578
+ qrMaxRetries?: number,
579
+ /**
580
+ * @deprecated This option should be set directly on the LegacySessionAuth
581
+ */
582
+ restartOnAuthFail?: boolean
583
+ /**
584
+ * @deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.
585
+ */
586
+ session?: ClientSession
587
+ /** If another whatsapp web session is detected (another browser), take over the session in the current browser
588
+ * @default false */
589
+ takeoverOnConflict?: boolean,
590
+ /** How much time to wait before taking over the session
591
+ * @default 0 */
592
+ takeoverTimeoutMs?: number,
593
+ /** User agent to use in puppeteer.
594
+ * @default 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36' */
595
+ userAgent?: string
596
+ /** Ffmpeg path to use when formatting videos to webp while sending stickers
597
+ * @default 'ffmpeg' */
598
+ ffmpegPath?: string,
599
+ /** Sets bypassing of page's Content-Security-Policy
600
+ * @default false */
601
+ bypassCSP?: boolean,
602
+ /** Sets the device name of a current linked device., i.e.: 'TEST' */
603
+ deviceName?: string,
604
+ /**
605
+ * Sets the browser name of a current linked device, i.e.: 'Firefox'.
606
+ * Valid value are: 'Chrome' | 'Firefox' | 'IE' | 'Opera' | 'Safari' | 'Edge'
607
+ */
608
+ browserName?: string,
609
+ /** Object with proxy autentication requirements @default: undefined */
610
+ proxyAuthentication?: {username: string, password: string} | undefined
611
+ /** Phone number pairing configuration. Refer the requestPairingCode function of Client.
612
+ * @default
613
+ * {
614
+ * phoneNumber: "",
615
+ * showNotification: true,
616
+ * intervalMs: 180000,
617
+ * }
618
+ */
619
+ pairWithPhoneNumber?: {phoneNumber: string, showNotification?: boolean, intervalMs?: number}
620
+ }
621
+
622
+ export interface LocalWebCacheOptions {
623
+ type: 'local',
624
+ path?: string,
625
+ strict?: boolean
626
+ }
627
+
628
+ export interface RemoteWebCacheOptions {
629
+ type: 'remote',
630
+ remotePath: string,
631
+ strict?: boolean
632
+ }
633
+
634
+ export interface NoWebCacheOptions {
635
+ type: 'none'
636
+ }
637
+
638
+ export type WebCacheOptions = NoWebCacheOptions | LocalWebCacheOptions | RemoteWebCacheOptions;
639
+
640
+ /**
641
+ * Base class which all authentication strategies extend
642
+ */
643
+ export abstract class AuthStrategy {
644
+ setup: (client: Client) => void;
645
+ beforeBrowserInitialized: () => Promise<void>;
646
+ afterBrowserInitialized: () => Promise<void>;
647
+ onAuthenticationNeeded: () => Promise<{
648
+ failed?: boolean;
649
+ restart?: boolean;
650
+ failureEventPayload?: any
651
+ }>;
652
+ getAuthEventPayload: () => Promise<any>;
653
+ afterAuthReady: () => Promise<void>;
654
+ disconnect: () => Promise<void>;
655
+ destroy: () => Promise<void>;
656
+ logout: () => Promise<void>;
657
+ }
658
+
659
+ /**
660
+ * No session restoring functionality
661
+ * Will need to authenticate via QR code every time
662
+ */
663
+ export class NoAuth extends AuthStrategy {}
664
+
665
+ /**
666
+ * Local directory-based authentication
667
+ */
668
+ export class LocalAuth extends AuthStrategy {
669
+ public clientId?: string;
670
+ public dataPath?: string;
671
+ constructor(options?: {
672
+ clientId?: string,
673
+ dataPath?: string,
674
+ rmMaxRetries?: number
675
+ })
676
+ }
677
+
678
+ /**
679
+ * Remote-based authentication
680
+ */
681
+ export class RemoteAuth extends AuthStrategy {
682
+ public clientId?: string;
683
+ public dataPath?: string;
684
+ constructor(options?: {
685
+ store: Store,
686
+ clientId?: string,
687
+ dataPath?: string,
688
+ backupSyncIntervalMs: number,
689
+ rmMaxRetries?: number
690
+ })
691
+ }
692
+
693
+ /**
694
+ * Remote store interface
695
+ */
696
+ export interface Store {
697
+ sessionExists: (options: { session: string }) => Promise<boolean> | boolean,
698
+ delete: (options: { session: string }) => Promise<any> | any,
699
+ save: (options: { session: string }) => Promise<any> | any,
700
+ extract: (options: { session: string, path: string }) => Promise<any> | any,
701
+ }
702
+
703
+ /**
704
+ * Legacy session auth strategy
705
+ * Not compatible with multi-device accounts.
706
+ */
707
+ export class LegacySessionAuth extends AuthStrategy {
708
+ constructor(options?: {
709
+ session?: ClientSession,
710
+ restartOnAuthFail?: boolean,
711
+ })
712
+ }
713
+
714
+ /**
715
+ * Represents a WhatsApp client session
716
+ */
717
+ export interface ClientSession {
718
+ WABrowserId: string,
719
+ WASecretBundle: string,
720
+ WAToken1: string,
721
+ WAToken2: string,
722
+ }
723
+
724
+ /**
725
+ * @deprecated
726
+ */
727
+ export interface BatteryInfo {
728
+ /** The current battery percentage */
729
+ battery: number,
730
+ /** Indicates if the phone is plugged in (true) or not (false) */
731
+ plugged: boolean,
732
+ }
733
+
734
+ /** An object that handles options for group creation */
735
+ export interface CreateGroupOptions {
736
+ /**
737
+ * The number of seconds for the messages to disappear in the group,
738
+ * won't take an effect if the group is been creating with myself only
739
+ * @default 0
740
+ */
741
+ messageTimer?: number
742
+ /**
743
+ * The ID of a parent community group to link the newly created group with,
744
+ * won't take an effect if the group is been creating with myself only
745
+ */
746
+ parentGroupId?: string
747
+ /** If true, the inviteV4 will be sent to those participants
748
+ * who have restricted others from being automatically added to groups,
749
+ * otherwise the inviteV4 won't be sent
750
+ * @default true
751
+ */
752
+ autoSendInviteV4?: boolean,
753
+ /**
754
+ * The comment to be added to an inviteV4 (empty string by default)
755
+ * @default ''
756
+ */
757
+ comment?: string
758
+ /** If true, only admins can add members to the group (false by default)
759
+ * @default false
760
+ */
761
+ memberAddMode?: boolean,
762
+ /** If true, group admins will be required to approve anyone who wishes to join the group (false by default)
763
+ * @default false
764
+ */
765
+ membershipApprovalMode?: boolean,
766
+ /** If true, only admins can change group group info (true by default)
767
+ * @default true
768
+ */
769
+ isRestrict?: boolean,
770
+ /** If true, only admins can send messages (false by default)
771
+ * @default false
772
+ */
773
+ isAnnounce?: boolean,
774
+ }
775
+
776
+ /** An object that handles the result for createGroup method */
777
+ export interface CreateGroupResult {
778
+ /** A group title */
779
+ title: string;
780
+ /** An object that handles the newly created group ID */
781
+ gid: ChatId;
782
+ /** An object that handles the result value for each added to the group participant */
783
+ participants: {
784
+ [participantId: string]: {
785
+ statusCode: number,
786
+ message: string,
787
+ isGroupCreator: boolean,
788
+ isInviteV4Sent: boolean
789
+ };
790
+ };
791
+ }
792
+
793
+ /** An object that handles options for channel creation */
794
+ export interface CreateChannelOptions {
795
+ /** The channel description */
796
+ description?: string,
797
+ /** The channel profile picture */
798
+ picture?: MessageMedia
799
+ }
800
+
801
+ /** An object that handles the result for createGroup method */
802
+ export interface CreateChannelResult {
803
+ /** A channel title */
804
+ title: string,
805
+ /** An object that handles the newly created channel ID */
806
+ nid: ChatId,
807
+ /** The channel invite link, starts with 'https://whatsapp.com/channel/' */
808
+ inviteLink: string,
809
+ /** The timestamp the channel was created at */
810
+ createdAtTs: number
811
+ }
812
+
813
+ /** Options for unsubscribe from a channel */
814
+ export interface UnsubscribeOptions {
815
+ /**
816
+ * If true, after an unsubscription, it will completely remove a channel from the channel collection
817
+ * making it seem like the current user have never interacted with it.
818
+ * Otherwise it will only remove a channel from the list of channels the current user is subscribed to
819
+ * and will set the membership type for that channel to GUEST
820
+ */
821
+ deleteLocalModels?: boolean
822
+ }
823
+
824
+ /** Options for searching for channels */
825
+ export interface SearchChannelsOptions {
826
+ searchText?: string;
827
+ countryCodes?: string[];
828
+ skipSubscribedNewsletters?: boolean;
829
+ view?: number;
830
+ limit?: number;
831
+ }
832
+
833
+ export interface GroupNotification {
834
+ /** ContactId for the user that produced the GroupNotification */
835
+ author: string,
836
+ /** Extra content */
837
+ body: string,
838
+ /** ID for the Chat that this groupNotification was sent for */
839
+ chatId: string,
840
+ /** ID that represents the groupNotification
841
+ * @todo create a more specific type for the id object */
842
+ id: object,
843
+ /** Contact IDs for the users that were affected by this GroupNotification */
844
+ recipientIds: string[],
845
+ /** Unix timestamp for when the groupNotification was created */
846
+ timestamp: number,
847
+ /** GroupNotification type */
848
+ type: GroupNotificationTypes,
849
+
850
+ /** Returns the Chat this GroupNotification was sent in */
851
+ getChat: () => Promise<Chat>,
852
+ /** Returns the Contact this GroupNotification was produced by */
853
+ getContact: () => Promise<Contact>,
854
+ /** Returns the Contacts affected by this GroupNotification */
855
+ getRecipients: () => Promise<Contact[]>,
856
+ /** Sends a message to the same chat this GroupNotification was produced in */
857
+ reply: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
858
+
859
+ }
860
+
861
+ /** whatsapp web url */
862
+ export const WhatsWebURL: string
863
+
864
+ /** default client options */
865
+ export const DefaultOptions: ClientOptions
866
+
867
+ /** Chat types */
868
+ export enum ChatTypes {
869
+ SOLO = 'solo',
870
+ GROUP = 'group',
871
+ UNKNOWN = 'unknown',
872
+ }
873
+
874
+ /** Events that can be emitted by the client */
875
+ export enum Events {
876
+ AUTHENTICATED = 'authenticated',
877
+ AUTHENTICATION_FAILURE = 'auth_failure',
878
+ READY = 'ready',
879
+ MESSAGE_RECEIVED = 'message',
880
+ MESSAGE_CIPHERTEXT = 'message_ciphertext',
881
+ MESSAGE_CREATE = 'message_create',
882
+ MESSAGE_REVOKED_EVERYONE = 'message_revoke_everyone',
883
+ MESSAGE_REVOKED_ME = 'message_revoke_me',
884
+ MESSAGE_ACK = 'message_ack',
885
+ MESSAGE_EDIT = 'message_edit',
886
+ MEDIA_UPLOADED = 'media_uploaded',
887
+ CONTACT_CHANGED = 'contact_changed',
888
+ GROUP_JOIN = 'group_join',
889
+ GROUP_LEAVE = 'group_leave',
890
+ GROUP_ADMIN_CHANGED = 'group_admin_changed',
891
+ GROUP_MEMBERSHIP_REQUEST = 'group_membership_request',
892
+ GROUP_UPDATE = 'group_update',
893
+ QR_RECEIVED = 'qr',
894
+ CODE_RECEIVED = 'code',
895
+ LOADING_SCREEN = 'loading_screen',
896
+ DISCONNECTED = 'disconnected',
897
+ STATE_CHANGED = 'change_state',
898
+ BATTERY_CHANGED = 'change_battery',
899
+ REMOTE_SESSION_SAVED = 'remote_session_saved',
900
+ INCOMING_CALL = 'call',
901
+ VOTE_UPDATE = 'vote_update',
902
+ }
903
+
904
+ /** Group notification types */
905
+ export enum GroupNotificationTypes {
906
+ ADD = 'add',
907
+ INVITE = 'invite',
908
+ REMOVE = 'remove',
909
+ LEAVE = 'leave',
910
+ PROMOTE = 'promote',
911
+ DEMOTE = 'demote',
912
+ SUBJECT = 'subject',
913
+ DESCRIPTION = 'description',
914
+ PICTURE = 'picture',
915
+ ANNOUNCE = 'announce',
916
+ RESTRICT = 'restrict',
917
+ }
918
+
919
+ /** Message ACK */
920
+ export enum MessageAck {
921
+ ACK_ERROR = -1,
922
+ ACK_PENDING = 0,
923
+ ACK_SERVER = 1,
924
+ ACK_DEVICE = 2,
925
+ ACK_READ = 3,
926
+ ACK_PLAYED = 4,
927
+ }
928
+
929
+ /** Message types */
930
+ export enum MessageTypes {
931
+ TEXT = 'chat',
932
+ AUDIO = 'audio',
933
+ VOICE = 'ptt',
934
+ IMAGE = 'image',
935
+ ALBUM = 'album',
936
+ VIDEO = 'video',
937
+ DOCUMENT = 'document',
938
+ STICKER = 'sticker',
939
+ LOCATION = 'location',
940
+ CONTACT_CARD = 'vcard',
941
+ CONTACT_CARD_MULTI = 'multi_vcard',
942
+ REVOKED = 'revoked',
943
+ ORDER = 'order',
944
+ PRODUCT = 'product',
945
+ PAYMENT = 'payment',
946
+ UNKNOWN = 'unknown',
947
+ GROUP_INVITE = 'groups_v4_invite',
948
+ LIST = 'list',
949
+ LIST_RESPONSE = 'list_response',
950
+ BUTTONS_RESPONSE = 'buttons_response',
951
+ BROADCAST_NOTIFICATION = 'broadcast_notification',
952
+ CALL_LOG = 'call_log',
953
+ CIPHERTEXT = 'ciphertext',
954
+ DEBUG = 'debug',
955
+ E2E_NOTIFICATION = 'e2e_notification',
956
+ GP2 = 'gp2',
957
+ GROUP_NOTIFICATION = 'group_notification',
958
+ HSM = 'hsm',
959
+ INTERACTIVE = 'interactive',
960
+ NATIVE_FLOW = 'native_flow',
961
+ NOTIFICATION = 'notification',
962
+ NOTIFICATION_TEMPLATE = 'notification_template',
963
+ OVERSIZED = 'oversized',
964
+ PROTOCOL = 'protocol',
965
+ REACTION = 'reaction',
966
+ TEMPLATE_BUTTON_REPLY = 'template_button_reply',
967
+ POLL_CREATION = 'poll_creation',
968
+ SCHEDULED_EVENT_CREATION = 'scheduled_event_creation',
969
+ }
970
+
971
+ /** Client status */
972
+ export enum Status {
973
+ INITIALIZING = 0,
974
+ AUTHENTICATING = 1,
975
+ READY = 3,
976
+ }
977
+
978
+ /** WhatsApp state */
979
+ export enum WAState {
980
+ CONFLICT = 'CONFLICT',
981
+ CONNECTED = 'CONNECTED',
982
+ DEPRECATED_VERSION = 'DEPRECATED_VERSION',
983
+ OPENING = 'OPENING',
984
+ PAIRING = 'PAIRING',
985
+ PROXYBLOCK = 'PROXYBLOCK',
986
+ SMB_TOS_BLOCK = 'SMB_TOS_BLOCK',
987
+ TIMEOUT = 'TIMEOUT',
988
+ TOS_BLOCK = 'TOS_BLOCK',
989
+ UNLAUNCHED = 'UNLAUNCHED',
990
+ UNPAIRED = 'UNPAIRED',
991
+ UNPAIRED_IDLE = 'UNPAIRED_IDLE',
992
+ }
993
+
994
+ export type MessageInfo = {
995
+ delivery: Array<{id: ContactId, t: number}>,
996
+ deliveryRemaining: number,
997
+ played: Array<{id: ContactId, t: number}>,
998
+ playedRemaining: number,
999
+ read: Array<{id: ContactId, t: number}>,
1000
+ readRemaining: number
1001
+ }
1002
+
1003
+ export type InviteV4Data = {
1004
+ inviteCode: string,
1005
+ inviteCodeExp: number,
1006
+ groupId: string,
1007
+ groupName?: string,
1008
+ fromId: string,
1009
+ toId: string
1010
+ }
1011
+
1012
+ /**
1013
+ * Represents a Message on WhatsApp
1014
+ *
1015
+ * @example
1016
+ * {
1017
+ * mediaKey: undefined,
1018
+ * id: {
1019
+ * fromMe: false,
1020
+ * remote: `554199999999@c.us`,
1021
+ * id: '1234567890ABCDEFGHIJ',
1022
+ * _serialized: `false_554199999999@c.us_1234567890ABCDEFGHIJ`
1023
+ * },
1024
+ * ack: -1,
1025
+ * hasMedia: false,
1026
+ * body: 'Hello!',
1027
+ * type: 'chat',
1028
+ * timestamp: 1591482682,
1029
+ * from: `554199999999@c.us`,
1030
+ * to: `554188888888@c.us`,
1031
+ * author: undefined,
1032
+ * isForwarded: false,
1033
+ * broadcast: false,
1034
+ * fromMe: false,
1035
+ * hasQuotedMsg: false,
1036
+ * hasReaction: false,
1037
+ * location: undefined,
1038
+ * mentionedIds: []
1039
+ * }
1040
+ */
1041
+ export interface Message {
1042
+ /** ACK status for the message */
1043
+ ack: MessageAck,
1044
+ /** If the message was sent to a group, this field will contain the user that sent the message. */
1045
+ author?: string,
1046
+ /** String that represents from which device type the message was sent */
1047
+ deviceType: string,
1048
+ /** Message content */
1049
+ body: string,
1050
+ /** Indicates if the message was a broadcast */
1051
+ broadcast: boolean,
1052
+ /** Indicates if the message was a status update */
1053
+ isStatus: boolean,
1054
+ /** Indicates if the message is a Gif */
1055
+ isGif: boolean,
1056
+ /** Indicates if the message will disappear after it expires */
1057
+ isEphemeral: boolean,
1058
+ /** ID for the Chat that this message was sent to, except if the message was sent by the current user */
1059
+ from: string,
1060
+ /** Indicates if the message was sent by the current user */
1061
+ fromMe: boolean,
1062
+ /** Indicates if the message has media available for download */
1063
+ hasMedia: boolean,
1064
+ /** Indicates if the message was sent as a reply to another message */
1065
+ hasQuotedMsg: boolean,
1066
+ /** Indicates whether there are reactions to the message */
1067
+ hasReaction: boolean,
1068
+ /** Indicates the duration of the message in seconds */
1069
+ duration: string,
1070
+ /** ID that represents the message */
1071
+ id: MessageId,
1072
+ /** Indicates if the message was forwarded */
1073
+ isForwarded: boolean,
1074
+ /**
1075
+ * Indicates how many times the message was forwarded.
1076
+ * The maximum value is 127.
1077
+ */
1078
+ forwardingScore: number,
1079
+ /** Indicates if the message was starred */
1080
+ isStarred: boolean,
1081
+ /** Location information contained in the message, if the message is type "location" */
1082
+ location: Location,
1083
+ /** List of vCards contained in the message */
1084
+ vCards: string[],
1085
+ /** Invite v4 info */
1086
+ inviteV4?: InviteV4Data,
1087
+ /** MediaKey that represents the sticker 'ID' */
1088
+ mediaKey?: string,
1089
+ /** Indicates the mentions in the message body. */
1090
+ mentionedIds: string[],
1091
+ /** Indicates whether there are group mentions in the message body */
1092
+ groupMentions: {
1093
+ groupSubject: string;
1094
+ groupJid: string;
1095
+ }[],
1096
+ /** Unix timestamp for when the message was created */
1097
+ timestamp: number,
1098
+ /**
1099
+ * ID for who this message is for.
1100
+ * If the message is sent by the current user, it will be the Chat to which the message is being sent.
1101
+ * If the message is sent by another user, it will be the ID for the current user.
1102
+ */
1103
+ to: string,
1104
+ /** Message type */
1105
+ type: MessageTypes,
1106
+ /** Links included in the message. */
1107
+ links: Array<{
1108
+ link: string,
1109
+ isSuspicious: boolean
1110
+ }>,
1111
+ /** Order ID */
1112
+ orderId: string,
1113
+ /** title */
1114
+ title?: string,
1115
+ /** description*/
1116
+ description?: string,
1117
+ /** Business Owner JID */
1118
+ businessOwnerJid?: string,
1119
+ /** Product JID */
1120
+ productId?: string,
1121
+ /** Last edit time */
1122
+ latestEditSenderTimestampMs?: number,
1123
+ /** Last edit message author */
1124
+ latestEditMsgKey?: MessageId,
1125
+ /**
1126
+ * Protocol message key.
1127
+ * Can be used to retrieve the ID of an original message that was revoked.
1128
+ */
1129
+ protocolMessageKey?: MessageId,
1130
+ /** Message buttons */
1131
+ dynamicReplyButtons?: object,
1132
+ /** Selected button ID */
1133
+ selectedButtonId?: string,
1134
+ /** Selected list row ID */
1135
+ selectedRowId?: string,
1136
+ /** Returns message in a raw format */
1137
+ rawData: object,
1138
+ pollName: string,
1139
+ /** Avaiaible poll voting options */
1140
+ pollOptions: string[],
1141
+ /** False for a single choice poll, true for a multiple choice poll */
1142
+ allowMultipleAnswers: boolean,
1143
+ /** The start time of the event in timestamp (10 digits) */
1144
+ eventStartTime: number,
1145
+ /** The end time of the event in timestamp (10 digits) */
1146
+ eventEndTime?: number,
1147
+ /** The event description */
1148
+ eventDescription?: string,
1149
+ /** The location of the event */
1150
+ eventLocation?: {
1151
+ degreesLatitude: number;
1152
+ degreesLongitude: number;
1153
+ name: string;
1154
+ },
1155
+ /** WhatsApp call link (video call or voice call) */
1156
+ eventJoinLink?: string,
1157
+ /** Indicates if an event should be sent as an already canceled */
1158
+ isEventCaneled: boolean,
1159
+ /** The custom message secret, can be used as an event ID */
1160
+ messageSecret?: Array<number>,
1161
+ /*
1162
+ * Reloads this Message object's data in-place with the latest values from WhatsApp Web.
1163
+ * Note that the Message must still be in the web app cache for this to work, otherwise will return null.
1164
+ */
1165
+ reload: () => Promise<Message>,
1166
+ /** Accept the Group V4 Invite in message */
1167
+ acceptGroupV4Invite: () => Promise<{status: number}>,
1168
+ /** Deletes the message from the chat */
1169
+ delete: (everyone?: boolean, clearMedia?: boolean) => Promise<void>,
1170
+ /** Downloads and returns the attached message media */
1171
+ downloadMedia: () => Promise<MessageMedia>,
1172
+ /** Returns the Chat this message was sent in */
1173
+ getChat: () => Promise<Chat>,
1174
+ /** Returns the Contact this message was sent from */
1175
+ getContact: () => Promise<Contact>,
1176
+ /** Returns the Contacts mentioned in this message */
1177
+ getMentions: () => Promise<Contact[]>,
1178
+ /** Returns groups mentioned in this message */
1179
+ getGroupMentions: () => Promise<GroupChat[]|[]>,
1180
+ /** Returns the quoted message, if any */
1181
+ getQuotedMessage: () => Promise<Message>,
1182
+ /**
1183
+ * Sends a message as a reply to this message.
1184
+ * If chatId is specified, it will be sent through the specified Chat.
1185
+ * If not, it will send the message in the same Chat as the original message was sent.
1186
+ */
1187
+ reply: (content: MessageContent, chatId?: string, options?: MessageSendOptions) => Promise<Message>,
1188
+ /** React to this message with an emoji*/
1189
+ react: (reaction: string) => Promise<void>,
1190
+ /**
1191
+ * Forwards this message to another chat (that you chatted before, otherwise it will fail)
1192
+ */
1193
+ forward: (chat: Chat | string) => Promise<void>,
1194
+ /** Star this message */
1195
+ star: () => Promise<void>,
1196
+ /** Unstar this message */
1197
+ unstar: () => Promise<void>,
1198
+ /** Pins the message (group admins can pin messages of all group members) */
1199
+ pin: (duration: number) => Promise<boolean>,
1200
+ /** Unpins the message (group admins can unpin messages of all group members) */
1201
+ unpin: () => Promise<boolean>,
1202
+ /** Get information about message delivery status */
1203
+ getInfo: () => Promise<MessageInfo | null>,
1204
+ /**
1205
+ * Gets the order associated with a given message
1206
+ */
1207
+ getOrder: () => Promise<Order>,
1208
+ /**
1209
+ * Gets the payment details associated with a given message
1210
+ */
1211
+ getPayment: () => Promise<Payment>,
1212
+ /**
1213
+ * Get Poll Votes associated with the given message
1214
+ */
1215
+ getPollVotes: () => Promise<PollVote[]>,
1216
+ /**
1217
+ * Gets the reactions associated with the given message
1218
+ */
1219
+ getReactions: () => Promise<ReactionList[]>,
1220
+ /** Edits the current message */
1221
+ edit: (content: MessageContent, options?: MessageEditOptions) => Promise<Message | null>,
1222
+ /**
1223
+ * Edits the current ScheduledEvent message.
1224
+ * Once the event is canceled, it can not be edited.
1225
+ */
1226
+ editScheduledEvent: (editedEventObject: Event) => Promise<Message | null>,
1227
+ /**
1228
+ * Send votes to the poll message
1229
+ */
1230
+ vote: (selectedOptions: Array<string>) => Promise<void>,
1231
+ }
1232
+
1233
+ /** ID that represents a message */
1234
+ export interface MessageId {
1235
+ fromMe: boolean,
1236
+ remote: string,
1237
+ id: string,
1238
+ _serialized: string,
1239
+ }
1240
+
1241
+ /** Options for sending a location */
1242
+ export interface LocationSendOptions {
1243
+ /** Location name */
1244
+ name?: string;
1245
+ /** Location address */
1246
+ address?: string;
1247
+ /** URL address to be shown within a location message */
1248
+ url?: string;
1249
+ }
1250
+
1251
+ /** Location information */
1252
+ export class Location {
1253
+ latitude: string;
1254
+ longitude: string;
1255
+ name?: string;
1256
+ address?: string;
1257
+ url?: string;
1258
+ description?: string;
1259
+
1260
+ constructor(latitude: number, longitude: number, options?: LocationSendOptions)
1261
+ }
1262
+
1263
+ /** Poll send options */
1264
+ export interface PollSendOptions {
1265
+ /** False for a single choice poll, true for a multiple choice poll (false by default) */
1266
+ allowMultipleAnswers?: boolean,
1267
+ /**
1268
+ * The custom message secret, can be used as a poll ID
1269
+ * @note It has to be a unique vector with a length of 32
1270
+ */
1271
+ messageSecret: Array<number>|undefined
1272
+ }
1273
+
1274
+ /** Represents a Poll on WhatsApp */
1275
+ export class Poll {
1276
+ pollName: string
1277
+ pollOptions: Array<{
1278
+ name: string,
1279
+ localId: number
1280
+ }>
1281
+ options: PollSendOptions
1282
+
1283
+ constructor(pollName: string, pollOptions: Array<string>, options?: PollSendOptions)
1284
+ }
1285
+
1286
+ /** ScheduledEvent send options */
1287
+ export interface ScheduledEventSendOptions {
1288
+ /** The scheduled event description */
1289
+ description?: string,
1290
+ /** The end time of the event */
1291
+ endTime?: Date,
1292
+ /** The location of the event */
1293
+ location?: string,
1294
+ /** The type of a WhatsApp call link to generate, valid values are: `video` | `voice` | `none` */
1295
+ callType?: string,
1296
+ /**
1297
+ * Indicates if a scheduled event should be sent as an already canceled
1298
+ * @default false
1299
+ */
1300
+ isEventCanceled?: boolean
1301
+ /**
1302
+ * The custom message secret, can be used as an event ID
1303
+ * @note It has to be a unique vector with a length of 32
1304
+ */
1305
+ messageSecret: Array<number>|undefined
1306
+ }
1307
+
1308
+ /** Represents a ScheduledEvent on WhatsApp */
1309
+ export class ScheduledEvent {
1310
+ name: string
1311
+ startTimeTs: number
1312
+ eventSendOptions: {
1313
+ description?: string;
1314
+ endTimeTs?: number;
1315
+ location?: string;
1316
+ callType?: string;
1317
+ isEventCanceled?: boolean;
1318
+ messageSecret?: string;
1319
+ };
1320
+
1321
+ constructor(name: string, startTime: Date, options?: ScheduledEventSendOptions)
1322
+ }
1323
+
1324
+ /** Represents a Poll Vote on WhatsApp */
1325
+ export interface PollVote {
1326
+ /** The person who voted */
1327
+ voter: string;
1328
+
1329
+ /**
1330
+ * The selected poll option(s)
1331
+ * If it's an empty array, the user hasn't selected any options on the poll,
1332
+ * may occur when they deselected all poll options
1333
+ */
1334
+ selectedOptions: SelectedPollOption[];
1335
+
1336
+ /** Timestamp the option was selected or deselected at */
1337
+ interractedAtTs: number;
1338
+
1339
+ /** The poll creation message associated with the poll vote */
1340
+ parentMessage: Message;
1341
+ }
1342
+
1343
+ /** Selected poll option structure */
1344
+ export interface SelectedPollOption {
1345
+ /** The local selected option ID */
1346
+ id: number;
1347
+
1348
+ /** The option name */
1349
+ name: string;
1350
+ }
1351
+
1352
+ export interface Label {
1353
+ /** Label name */
1354
+ name: string,
1355
+ /** Label ID */
1356
+ id: string,
1357
+ /** Color assigned to the label */
1358
+ hexColor: string,
1359
+
1360
+ /** Get all chats that have been assigned this Label */
1361
+ getChats: () => Promise<Chat[]>
1362
+ }
1363
+
1364
+ export interface Broadcast {
1365
+ /** Chat Object ID */
1366
+ id: {
1367
+ server: string,
1368
+ user: string,
1369
+ _serialized: string
1370
+ },
1371
+ /** Unix timestamp of last story */
1372
+ timestamp: number,
1373
+ /** Number of available statuses */
1374
+ totalCount: number,
1375
+ /** Number of not viewed */
1376
+ unreadCount: number,
1377
+ /** Unix timestamp of last story */
1378
+ msgs: Message[],
1379
+
1380
+ /** Returns the Chat of the owner of the story */
1381
+ getChat: () => Promise<Chat>,
1382
+ /** Returns the Contact of the owner of the story */
1383
+ getContact: () => Promise<Contact>,
1384
+ }
1385
+
1386
+ /** Options for sending a message */
1387
+ export interface MessageSendOptions {
1388
+ /** Show links preview. Has no effect on multi-device accounts. */
1389
+ linkPreview?: boolean
1390
+ /** Send audio as voice message with a generated waveform */
1391
+ sendAudioAsVoice?: boolean
1392
+ /** Send video as gif */
1393
+ sendVideoAsGif?: boolean
1394
+ /** Send media as sticker */
1395
+ sendMediaAsSticker?: boolean
1396
+ /** Send media as document */
1397
+ sendMediaAsDocument?: boolean
1398
+ /** Send media as quality HD */
1399
+ sendMediaAsHd?: boolean
1400
+ /** Send photo/video as a view once message */
1401
+ isViewOnce?: boolean
1402
+ /** Automatically parse vCards and send them as contacts */
1403
+ parseVCards?: boolean
1404
+ /** Image or videos caption */
1405
+ caption?: string
1406
+ /** Id of the message that is being quoted (or replied to) */
1407
+ quotedMessageId?: string
1408
+ /** User IDs to mention in the message */
1409
+ mentions?: string[]
1410
+ /** An array of object that handle group mentions */
1411
+ groupMentions?: {
1412
+ /** The name of a group to mention (can be custom) */
1413
+ subject: string,
1414
+ /** The group ID, e.g.: 'XXXXXXXXXX@g.us' */
1415
+ id: string
1416
+ }[]
1417
+ /** Send 'seen' status */
1418
+ sendSeen?: boolean
1419
+ /** Bot Wid when doing a bot mention like @Meta AI */
1420
+ invokedBotWid?: string
1421
+ /** Media to be sent */
1422
+ media?: MessageMedia
1423
+ /** Extra options */
1424
+ extra?: any
1425
+ /** Sticker name, if sendMediaAsSticker is true */
1426
+ stickerName?: string
1427
+ /** Sticker author, if sendMediaAsSticker is true */
1428
+ stickerAuthor?: string
1429
+ /** Sticker categories, if sendMediaAsSticker is true */
1430
+ stickerCategories?: string[],
1431
+ /** Should the bot send a quoted message without the quoted message if it fails to get the quote?
1432
+ * @default true (enabled) */
1433
+ ignoreQuoteErrors?: boolean
1434
+ /**
1435
+ * Should the bot wait for the message send result?
1436
+ * @default false
1437
+ */
1438
+ waitUntilMsgSent?: boolean
1439
+ }
1440
+
1441
+ /** Options for editing a message */
1442
+ export interface MessageEditOptions {
1443
+ /** Show links preview. Has no effect on multi-device accounts. */
1444
+ linkPreview?: boolean
1445
+ /** User IDs of users that being mentioned in the message */
1446
+ mentions?: string[]
1447
+ /** Extra options */
1448
+ extra?: any
1449
+ }
1450
+
1451
+ export interface MediaFromURLOptions {
1452
+ client?: Client
1453
+ filename?: string
1454
+ unsafeMime?: boolean
1455
+ reqOptions?: RequestInit
1456
+ }
1457
+
1458
+ /** Media attached to a message */
1459
+ export class MessageMedia {
1460
+ /** MIME type of the attachment */
1461
+ mimetype: string
1462
+ /** Base64-encoded data of the file */
1463
+ data: string
1464
+ /** Document file name. Value can be null */
1465
+ filename?: string | null
1466
+ /** Document file size in bytes. Value can be null. */
1467
+ filesize?: number | null
1468
+
1469
+ /**
1470
+ * @param {string} mimetype MIME type of the attachment
1471
+ * @param {string} data Base64-encoded data of the file
1472
+ * @param {?string} filename Document file name. Value can be null
1473
+ * @param {?number} filesize Document file size in bytes. Value can be null.
1474
+ */
1475
+ constructor(mimetype: string, data: string, filename?: string | null, filesize?: number | null)
1476
+
1477
+ /** Creates a MessageMedia instance from a local file path */
1478
+ static fromFilePath: (filePath: string) => MessageMedia
1479
+
1480
+ /** Creates a MessageMedia instance from a URL */
1481
+ static fromUrl: (url: string, options?: MediaFromURLOptions) => Promise<MessageMedia>
1482
+ }
1483
+
1484
+ export type MessageContent = string | MessageMedia | Location | Poll | Contact | Contact[] | List | Buttons | ScheduledEvent
1485
+
1486
+ /**
1487
+ * Represents a Contact on WhatsApp
1488
+ *
1489
+ * @example
1490
+ * {
1491
+ * id: {
1492
+ * server: 'c.us',
1493
+ * user: '554199999999',
1494
+ * _serialized: `554199999999@c.us`
1495
+ * },
1496
+ * number: '554199999999',
1497
+ * isBusiness: false,
1498
+ * isEnterprise: false,
1499
+ * labels: [],
1500
+ * name: undefined,
1501
+ * pushname: 'John',
1502
+ * sectionHeader: undefined,
1503
+ * shortName: undefined,
1504
+ * statusMute: false,
1505
+ * type: 'in',
1506
+ * verifiedLevel: undefined,
1507
+ * verifiedName: undefined,
1508
+ * isMe: false,
1509
+ * isUser: true,
1510
+ * isGroup: false,
1511
+ * isWAContact: true,
1512
+ * isMyContact: false
1513
+ * }
1514
+ */
1515
+ export interface Contact {
1516
+ /** Contact's phone number */
1517
+ number: string,
1518
+ /** Indicates if the contact is a business contact */
1519
+ isBusiness: boolean,
1520
+ /** ID that represents the contact */
1521
+ id: ContactId,
1522
+ /** Indicates if the contact is an enterprise contact */
1523
+ isEnterprise: boolean,
1524
+ /** Indicates if the contact is a group contact */
1525
+ isGroup: boolean,
1526
+ /** Indicates if the contact is the current user's contact */
1527
+ isMe: boolean,
1528
+ /** Indicates if the number is saved in the current phone's contacts */
1529
+ isMyContact: boolean
1530
+ /** Indicates if the contact is a user contact */
1531
+ isUser: boolean,
1532
+ /** Indicates if the number is registered on WhatsApp */
1533
+ isWAContact: boolean,
1534
+ /** Indicates if you have blocked this contact */
1535
+ isBlocked: boolean,
1536
+ /** @todo verify labels type. didn't have any documentation */
1537
+ labels?: string[],
1538
+ /** The contact's name, as saved by the current user */
1539
+ name?: string,
1540
+ /** The name that the contact has configured to be shown publically */
1541
+ pushname: string,
1542
+ /** @todo missing documentation */
1543
+ sectionHeader: string,
1544
+ /** A shortened version of name */
1545
+ shortName?: string,
1546
+ /** Indicates if the status from the contact is muted */
1547
+ statusMute: boolean,
1548
+ /** @todo missing documentation */
1549
+ type: string,
1550
+ /** @todo missing documentation */
1551
+ verifiedLevel?: undefined,
1552
+ /** @todo missing documentation */
1553
+ verifiedName?: undefined,
1554
+
1555
+ /** Returns the contact's profile picture URL, if privacy settings allow it */
1556
+ getProfilePicUrl: () => Promise<string>,
1557
+
1558
+ /** Returns the Chat that corresponds to this Contact.
1559
+ * Will return null when getting chat for currently logged in user.
1560
+ */
1561
+ getChat: () => Promise<Chat>,
1562
+
1563
+ /** Returns the contact's countrycode, (1541859685@c.us) => (1) */
1564
+ getCountryCode(): Promise<string>,
1565
+
1566
+ /** Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901) */
1567
+ getFormattedNumber(): Promise<string>,
1568
+
1569
+ /** Blocks this contact from WhatsApp */
1570
+ block: () => Promise<boolean>,
1571
+
1572
+ /** Unlocks this contact from WhatsApp */
1573
+ unblock: () => Promise<boolean>,
1574
+
1575
+ /** Gets the Contact's current "about" info. Returns null if you don't have permission to read their status. */
1576
+ getAbout: () => Promise<string | null>,
1577
+
1578
+ /** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
1579
+ getCommonGroups: () => Promise<ChatId[]>
1580
+
1581
+ /** Gets the Contact's current status broadcast. */
1582
+ getBroadcast: () => Promise<Broadcast>
1583
+ }
1584
+
1585
+ export interface ContactId {
1586
+ server: string,
1587
+ user: string,
1588
+ _serialized: string,
1589
+ }
1590
+
1591
+ export interface BusinessCategory {
1592
+ id: string,
1593
+ localized_display_name: string,
1594
+ }
1595
+
1596
+ export interface BusinessHoursOfDay {
1597
+ mode: string,
1598
+ hours: number[]
1599
+ }
1600
+
1601
+ export interface BusinessHours {
1602
+ config: {
1603
+ sun: BusinessHoursOfDay,
1604
+ mon: BusinessHoursOfDay,
1605
+ tue: BusinessHoursOfDay,
1606
+ wed: BusinessHoursOfDay,
1607
+ thu: BusinessHoursOfDay,
1608
+ fri: BusinessHoursOfDay,
1609
+ }
1610
+ timezone: string,
1611
+ }
1612
+
1613
+
1614
+
1615
+ export interface BusinessContact extends Contact {
1616
+ /**
1617
+ * The contact's business profile
1618
+ */
1619
+ businessProfile: {
1620
+ /** The contact's business profile id */
1621
+ id: ContactId,
1622
+
1623
+ /** The contact's business profile tag */
1624
+ tag: string,
1625
+
1626
+ /** The contact's business profile description */
1627
+ description: string,
1628
+
1629
+ /** The contact's business profile categories */
1630
+ categories: BusinessCategory[],
1631
+
1632
+ /** The contact's business profile options */
1633
+ profileOptions: {
1634
+ /** The contact's business profile commerce experience*/
1635
+ commerceExperience: string,
1636
+
1637
+ /** The contact's business profile cart options */
1638
+ cartEnabled: boolean,
1639
+ }
1640
+
1641
+ /** The contact's business profile email */
1642
+ email: string,
1643
+
1644
+ /** The contact's business profile websites */
1645
+ website: string[],
1646
+
1647
+ /** The contact's business profile latitude */
1648
+ latitude: number,
1649
+
1650
+ /** The contact's business profile longitude */
1651
+ longitude: number,
1652
+
1653
+ /** The contact's business profile work hours*/
1654
+ businessHours: BusinessHours
1655
+
1656
+ /** The contact's business profile address */
1657
+ address: string,
1658
+
1659
+ /** The contact's business profile facebook page */
1660
+ fbPage: object,
1661
+
1662
+ /** Indicate if the contact's business profile linked */
1663
+ ifProfileLinked: boolean
1664
+
1665
+ /** The contact's business profile coverPhoto */
1666
+ coverPhoto: null | any,
1667
+ }
1668
+ }
1669
+
1670
+ export interface PrivateContact extends Contact {
1671
+
1672
+ }
1673
+
1674
+ /**
1675
+ * Represents a Chat on WhatsApp
1676
+ *
1677
+ * @example
1678
+ * {
1679
+ * id: {
1680
+ * server: 'c.us',
1681
+ * user: '554199999999',
1682
+ * _serialized: `554199999999@c.us`
1683
+ * },
1684
+ * name: '+55 41 9999-9999',
1685
+ * isGroup: false,
1686
+ * isReadOnly: false,
1687
+ * unreadCount: 6,
1688
+ * timestamp: 1591484087,
1689
+ * archived: false
1690
+ * }
1691
+ */
1692
+ export interface Chat {
1693
+ /** Indicates if the Chat is archived */
1694
+ archived: boolean,
1695
+ /** ID that represents the chat */
1696
+ id: ChatId,
1697
+ /** Indicates if the Chat is a Group Chat */
1698
+ isGroup: boolean,
1699
+ /** Indicates if the Chat is readonly */
1700
+ isReadOnly: boolean,
1701
+ /** Indicates if the Chat is muted */
1702
+ isMuted: boolean,
1703
+ /** Unix timestamp for when the mute expires */
1704
+ muteExpiration: number,
1705
+ /** Title of the chat */
1706
+ name: string,
1707
+ /** Unix timestamp for when the last activity occurred */
1708
+ timestamp: number,
1709
+ /** Amount of messages unread */
1710
+ unreadCount: number,
1711
+ /** Last message of chat */
1712
+ lastMessage: Message,
1713
+ /** Indicates if the Chat is pinned */
1714
+ pinned: boolean,
1715
+
1716
+ /** Archives this chat */
1717
+ archive: () => Promise<void>,
1718
+ /** Pins this chat and returns its new Pin state */
1719
+ pin: () => Promise<boolean>,
1720
+ /** Unpins this chat and returns its new Pin state */
1721
+ unpin: () => Promise<boolean>,
1722
+ /** Clears all messages from the chat */
1723
+ clearMessages: () => Promise<boolean>,
1724
+ /** Stops typing or recording in chat immediately. */
1725
+ clearState: () => Promise<boolean>,
1726
+ /** Deletes the chat */
1727
+ delete: () => Promise<boolean>,
1728
+ /** Loads chat messages, sorted from earliest to latest. */
1729
+ fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
1730
+ /** Mutes this chat forever, unless a date is specified */
1731
+ mute: (unmuteDate?: Date) => Promise<{ isMuted: boolean, muteExpiration: number }>,
1732
+ /** Send a message to this chat */
1733
+ sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
1734
+ /** Sets the chat as seen */
1735
+ sendSeen: () => Promise<boolean>,
1736
+ /** Simulate recording audio in chat. This will last for 25 seconds */
1737
+ sendStateRecording: () => Promise<void>,
1738
+ /** Simulate typing in chat. This will last for 25 seconds. */
1739
+ sendStateTyping: () => Promise<void>,
1740
+ /** un-archives this chat */
1741
+ unarchive: () => Promise<void>,
1742
+ /** Unmutes this chat */
1743
+ unmute: () => Promise<{ isMuted: boolean, muteExpiration: number }>,
1744
+ /** Returns the Contact that corresponds to this Chat. */
1745
+ getContact: () => Promise<Contact>,
1746
+ /** Marks this Chat as unread */
1747
+ markUnread: () => Promise<void>,
1748
+ /** Returns array of all Labels assigned to this Chat */
1749
+ getLabels: () => Promise<Label[]>,
1750
+ /** Add or remove labels to this Chat */
1751
+ changeLabels: (labelIds: Array<string | number>) => Promise<void>
1752
+ /** Gets instances of all pinned messages in a chat */
1753
+ getPinnedMessages: () => Promise<[Message]|[]>
1754
+ /** Sync history conversation of the Chat */
1755
+ syncHistory: () => Promise<boolean>
1756
+ /** Add or edit a customer note */
1757
+ addOrEditCustomerNote: (note: string) => Promise<void>
1758
+ /** Get a customer note */
1759
+ getCustomerNote: () => Promise<{
1760
+ chatId: string;
1761
+ content: string;
1762
+ createdAt: number;
1763
+ id: string;
1764
+ modifiedAt: number;
1765
+ type: string;
1766
+ }>
1767
+ }
1768
+
1769
+ export interface Channel {
1770
+ /** ID that represents the channel */
1771
+ id: {
1772
+ server: string;
1773
+ user: string;
1774
+ _serialized: string;
1775
+ };
1776
+ /** Title of the channel */
1777
+ name: string;
1778
+ /** The channel description */
1779
+ description: string;
1780
+ /** Indicates if it is a Channel */
1781
+ isChannel: boolean;
1782
+ /** Indicates if it is a Group */
1783
+ isGroup: boolean;
1784
+ /** Indicates if the channel is readonly */
1785
+ isReadOnly: boolean;
1786
+ /** Amount of messages unread */
1787
+ unreadCount: number;
1788
+ /** Unix timestamp for when the last activity occurred */
1789
+ timestamp: number;
1790
+ /** Indicates if the channel is muted or not */
1791
+ isMuted: boolean;
1792
+ /** Unix timestamp for when the mute expires */
1793
+ muteExpiration: number;
1794
+ /** Last message in the channel */
1795
+ lastMessage: Message | undefined;
1796
+
1797
+ /** Gets the subscribers of the channel (only those who are in your contact list) */
1798
+ getSubscribers(limit?: number): Promise<{contact: Contact, role: string}[]>;
1799
+ /** Updates the channel subject */
1800
+ setSubject(newSubject: string): Promise<boolean>;
1801
+ /** Updates the channel description */
1802
+ setDescription(newDescription: string): Promise<boolean>;
1803
+ /** Updates the channel profile picture */
1804
+ setProfilePicture(newProfilePicture: MessageMedia): Promise<boolean>;
1805
+ /**
1806
+ * Updates available reactions to use in the channel
1807
+ *
1808
+ * Valid values for passing to the method are:
1809
+ * 0 for NONE reactions to be avaliable
1810
+ * 1 for BASIC reactions to be available: 👍, ❤️, 😂, 😮, 😢, 🙏
1811
+ * 2 for ALL reactions to be available
1812
+ */
1813
+ setReactionSetting(reactionCode: number): Promise<boolean>;
1814
+ /** Mutes the channel */
1815
+ mute(): Promise<boolean>;
1816
+ /** Unmutes the channel */
1817
+ unmute(): Promise<boolean>;
1818
+ /** Sends a message to this channel */
1819
+ sendMessage(content: string|MessageMedia, options?: MessageSendChannelOptions): Promise<Message>;
1820
+ /** Sets the channel as seen */
1821
+ sendSeen(): Promise<boolean>;
1822
+ /** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
1823
+ sendChannelAdminInvite(chatId: string, options?: { comment?: string }): Promise<boolean>;
1824
+ /** Accepts a channel admin invitation and promotes the current user to a channel admin */
1825
+ acceptChannelAdminInvite(): Promise<boolean>;
1826
+ /** Revokes a channel admin invitation sent to a user by a channel owner */
1827
+ revokeChannelAdminInvite(userId: string): Promise<boolean>;
1828
+ /** Demotes a channel admin to a regular subscriber (can be used also for self-demotion) */
1829
+ demoteChannelAdmin(userId: string): Promise<boolean>;
1830
+ /** Loads channel messages, sorted from earliest to latest */
1831
+ fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>;
1832
+ /**
1833
+ * Transfers a channel ownership to another user.
1834
+ * Note: the user you are transferring the channel ownership to must be a channel admin.
1835
+ */
1836
+ transferChannelOwnership(newOwnerId: string, options?: TransferChannelOwnershipOptions): Promise<boolean>;
1837
+ /** Deletes the channel you created */
1838
+ deleteChannel(): Promise<boolean>;
1839
+ }
1840
+
1841
+ /** Options for transferring a channel ownership to another user */
1842
+ export interface TransferChannelOwnershipOptions {
1843
+ /**
1844
+ * If true, after the channel ownership is being transferred to another user,
1845
+ * the current user will be dismissed as a channel admin and will become to a channel subscriber.
1846
+ */
1847
+ shouldDismissSelfAsAdmin?: boolean
1848
+ }
1849
+
1850
+ /** Options for sending a message */
1851
+ export interface MessageSendChannelOptions {
1852
+ /** Image or videos caption */
1853
+ caption?: string
1854
+ /** User IDs of user that will be mentioned in the message */
1855
+ mentions?: string[]
1856
+ /** Image or video to be sent */
1857
+ media?: MessageMedia
1858
+ /** Extra options */
1859
+ extra?: any
1860
+ }
1861
+
1862
+ export interface MessageSearchOptions {
1863
+ /**
1864
+ * The amount of messages to return. If no limit is specified, the available messages will be returned.
1865
+ * Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation.
1866
+ * Set this to Infinity to load all messages.
1867
+ */
1868
+ limit?: number
1869
+ /**
1870
+ * Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
1871
+ */
1872
+ fromMe?: boolean
1873
+ }
1874
+
1875
+ /**
1876
+ * Id that represents the chat
1877
+ *
1878
+ * @example
1879
+ * id: {
1880
+ * server: 'c.us',
1881
+ * user: '554199999999',
1882
+ * _serialized: `554199999999@c.us`
1883
+ * },
1884
+ */
1885
+ export interface ChatId {
1886
+ /**
1887
+ * Whatsapp server domain
1888
+ * @example `c.us`
1889
+ */
1890
+ server: string,
1891
+ /**
1892
+ * User whatsapp number
1893
+ * @example `554199999999`
1894
+ */
1895
+ user: string,
1896
+ /**
1897
+ * Serialized id
1898
+ * @example `554199999999@c.us`
1899
+ */
1900
+ _serialized: string,
1901
+ }
1902
+
1903
+ export interface PrivateChat extends Chat {
1904
+
1905
+ }
1906
+
1907
+ export type GroupParticipant = {
1908
+ id: ContactId,
1909
+ isAdmin: boolean
1910
+ isSuperAdmin: boolean
1911
+ }
1912
+
1913
+ /** Promotes or demotes participants by IDs to regular users or admins */
1914
+ export type ChangeParticipantsPermissions =
1915
+ (participantIds: Array<string>) => Promise<{ status: number }>
1916
+
1917
+ /** An object that handles the result for addParticipants method */
1918
+ export interface AddParticipantsResult {
1919
+ [participantId: string]: {
1920
+ code: number;
1921
+ message: string;
1922
+ isInviteV4Sent: boolean,
1923
+ }
1924
+ }
1925
+
1926
+ /** An object that handles options for adding participants */
1927
+ export interface AddParticipantsOptions {
1928
+ /**
1929
+ * The number of milliseconds to wait before adding the next participant.
1930
+ * If it is an array, a random sleep time between the sleep[0] and sleep[1] values will be added
1931
+ * (the difference must be >=100 ms, otherwise, a random sleep time between sleep[1] and sleep[1] + 100
1932
+ * will be added). If sleep is a number, a sleep time equal to its value will be added
1933
+ * @default [250,500]
1934
+ */
1935
+ sleep?: Array<number>|number,
1936
+ /**
1937
+ * If true, the inviteV4 will be sent to those participants
1938
+ * who have restricted others from being automatically added to groups,
1939
+ * otherwise the inviteV4 won't be sent
1940
+ * @default true
1941
+ */
1942
+ autoSendInviteV4?: boolean,
1943
+ /**
1944
+ * The comment to be added to an inviteV4 (empty string by default)
1945
+ * @default ''
1946
+ */
1947
+ comment?: string
1948
+ }
1949
+
1950
+ /** An object that handles the information about the group membership request */
1951
+ export interface GroupMembershipRequest {
1952
+ /** The wid of a user who requests to enter the group */
1953
+ id: Object;
1954
+ /** The wid of a user who created that request */
1955
+ addedBy: Object;
1956
+ /** The wid of a community parent group to which the current group is linked */
1957
+ parentGroupId: Object | null;
1958
+ /** The method used to create the request: NonAdminAdd/InviteLink/LinkedGroupJoin */
1959
+ requestMethod: string,
1960
+ /** The timestamp the request was created at */
1961
+ t: number
1962
+ }
1963
+
1964
+ /** An object that handles the result for membership request action */
1965
+ export interface MembershipRequestActionResult {
1966
+ /** User ID whos membership request was approved/rejected */
1967
+ requesterId: Array<string> | string | null;
1968
+ /** An error code that occurred during the operation for the participant */
1969
+ error?: number;
1970
+ /** A message with a result of membership request action */
1971
+ message: string;
1972
+ }
1973
+
1974
+ /** Options for performing a membership request action */
1975
+ export interface MembershipRequestActionOptions {
1976
+ /** User ID/s who requested to join the group, if no value is provided, the method will search for all membership requests for that group */
1977
+ requesterIds: Array<string> | string | null;
1978
+ /** The number of milliseconds to wait before performing an operation for the next requester. If it is an array, a random sleep time between the sleep[0] and sleep[1] values will be added (the difference must be >=100 ms, otherwise, a random sleep time between sleep[1] and sleep[1] + 100 will be added). If sleep is a number, a sleep time equal to its value will be added. By default, sleep is an array with a value of [250, 500] */
1979
+ sleep: Array<number> | number | null;
1980
+ }
1981
+
1982
+ export interface GroupChat extends Chat {
1983
+ /** Group owner */
1984
+ owner: ContactId;
1985
+ /** Date at which the group was created */
1986
+ createdAt: Date;
1987
+ /** Group description */
1988
+ description: string;
1989
+ /** Group participants */
1990
+ participants: Array<GroupParticipant>;
1991
+ /** Adds a list of participants by ID to the group */
1992
+ addParticipants: (participantIds: string | string[], options?: AddParticipantsOptions) => Promise<{ [key: string]: AddParticipantsResult } | string>;
1993
+ /** Removes a list of participants by ID to the group */
1994
+ removeParticipants: (participantIds: string[]) => Promise<{ status: number }>;
1995
+ /** Promotes participants by IDs to admins */
1996
+ promoteParticipants: ChangeParticipantsPermissions;
1997
+ /** Demotes participants by IDs to regular users */
1998
+ demoteParticipants: ChangeParticipantsPermissions;
1999
+ /** Updates the group subject */
2000
+ setSubject: (subject: string) => Promise<boolean>;
2001
+ /** Updates the group description */
2002
+ setDescription: (description: string) => Promise<boolean>;
2003
+ /**
2004
+ * Updates the group setting to allow only admins to add members to the group.
2005
+ * @param {boolean} [adminsOnly=true] Enable or disable this option
2006
+ * @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
2007
+ */
2008
+ setAddMembersAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
2009
+ /** Updates the group settings to only allow admins to send messages
2010
+ * @param {boolean} [adminsOnly=true] Enable or disable this option
2011
+ * @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
2012
+ */
2013
+ setMessagesAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
2014
+ /**
2015
+ * Updates the group settings to only allow admins to edit group info (title, description, photo).
2016
+ * @param {boolean} [adminsOnly=true] Enable or disable this option
2017
+ * @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
2018
+ */
2019
+ setInfoAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
2020
+ /**
2021
+ * Gets an array of membership requests
2022
+ * @returns {Promise<Array<GroupMembershipRequest>>} An array of membership requests
2023
+ */
2024
+ getGroupMembershipRequests: () => Promise<Array<GroupMembershipRequest>>;
2025
+ /**
2026
+ * Approves membership requests if any
2027
+ * @param {MembershipRequestActionOptions} options Options for performing a membership request action
2028
+ * @returns {Promise<Array<MembershipRequestActionResult>>} Returns an array of requester IDs whose membership requests were approved and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
2029
+ */
2030
+ approveGroupMembershipRequests: (options: MembershipRequestActionOptions) => Promise<Array<MembershipRequestActionResult>>;
2031
+ /**
2032
+ * Rejects membership requests if any
2033
+ * @param {MembershipRequestActionOptions} options Options for performing a membership request action
2034
+ * @returns {Promise<Array<MembershipRequestActionResult>>} Returns an array of requester IDs whose membership requests were rejected and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
2035
+ */
2036
+ rejectGroupMembershipRequests: (options: MembershipRequestActionOptions) => Promise<Array<MembershipRequestActionResult>>;
2037
+ /** Gets the invite code for a specific group */
2038
+ getInviteCode: () => Promise<string>;
2039
+ /** Invalidates the current group invite code and generates a new one */
2040
+ revokeInvite: () => Promise<void>;
2041
+ /** Makes the bot leave the group */
2042
+ leave: () => Promise<void>;
2043
+ /** Sets the group's picture.*/
2044
+ setPicture: (media: MessageMedia) => Promise<boolean>;
2045
+ /** Deletes the group's picture */
2046
+ deletePicture: () => Promise<boolean>;
2047
+ }
2048
+
2049
+ /**
2050
+ * Represents the metadata associated with a given product
2051
+ *
2052
+ */
2053
+ export interface ProductMetadata {
2054
+ /** Product Id */
2055
+ id: string,
2056
+ /** Product Name */
2057
+ name: string,
2058
+ /** Product Description */
2059
+ description: string,
2060
+ /** Retailer ID */
2061
+ retailer_id?: string
2062
+ }
2063
+
2064
+ /**
2065
+ * Represents a Product on Whatsapp
2066
+ * @example
2067
+ * {
2068
+ * "id": "123456789",
2069
+ * "price": "150000",
2070
+ * "thumbnailId": "123456789",
2071
+ * "thumbnailUrl": "https://mmg.whatsapp.net",
2072
+ * "currency": "GTQ",
2073
+ * "name": "Store Name",
2074
+ * "quantity": 1
2075
+ * }
2076
+ */
2077
+ export interface Product {
2078
+ /** Product Id */
2079
+ id: string,
2080
+ /** Price */
2081
+ price?: string,
2082
+ /** Product Thumbnail*/
2083
+ thumbnailUrl: string,
2084
+ /** Currency */
2085
+ currency: string,
2086
+ /** Product Name */
2087
+ name: string,
2088
+ /** Product Quantity*/
2089
+ quantity: number,
2090
+ /** Gets the Product metadata */
2091
+ getData: () => Promise<ProductMetadata>
2092
+ }
2093
+
2094
+ /**
2095
+ * Represents a Order on WhatsApp
2096
+ *
2097
+ * @example
2098
+ * {
2099
+ * "products": [
2100
+ * {
2101
+ * "id": "123456789",
2102
+ * "price": "150000",
2103
+ * "thumbnailId": "123456789",
2104
+ * "thumbnailUrl": "https://mmg.whatsapp.net",
2105
+ * "currency": "GTQ",
2106
+ * "name": "Store Name",
2107
+ * "quantity": 1
2108
+ * }
2109
+ * ],
2110
+ * "subtotal": "150000",
2111
+ * "total": "150000",
2112
+ * "currency": "GTQ",
2113
+ * "createdAt": 1610136796,
2114
+ * "sellerJid": "55555555@s.whatsapp.net"
2115
+ * }
2116
+ */
2117
+ export interface Order {
2118
+ /** List of products*/
2119
+ products: Array<Product>,
2120
+ /** Order Subtotal */
2121
+ subtotal: string,
2122
+ /** Order Total */
2123
+ total: string,
2124
+ /** Order Currency */
2125
+ currency: string,
2126
+ /** Order Created At*/
2127
+ createdAt: number;
2128
+ }
2129
+
2130
+ /**
2131
+ * Represents a Payment on WhatsApp
2132
+ *
2133
+ * @example
2134
+ * {
2135
+ * id: {
2136
+ * fromMe: true,
2137
+ * remote: {
2138
+ * server: 'c.us',
2139
+ * user: '5511999999999',
2140
+ * _serialized: '5511999999999@c.us'
2141
+ * },
2142
+ * id: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
2143
+ * _serialized: 'true_5511999999999@c.us_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
2144
+ * },
2145
+ * paymentCurrency: 'BRL',
2146
+ * paymentAmount1000: 1000,
2147
+ * paymentMessageReceiverJid: {
2148
+ * server: 'c.us',
2149
+ * user: '5511999999999',
2150
+ * _serialized: '5511999999999@c.us'
2151
+ * },
2152
+ * paymentTransactionTimestamp: 1623463058,
2153
+ * paymentStatus: 4,
2154
+ * paymentTxnStatus: 4,
2155
+ * paymentNote: 'note'
2156
+ * }
2157
+ */
2158
+ export interface Payment {
2159
+ /** Payment Id*/
2160
+ id: object,
2161
+ /** Payment currency */
2162
+ paymentCurrency: string,
2163
+ /** Payment ammount */
2164
+ paymentAmount1000 : number,
2165
+ /** Payment receiver */
2166
+ paymentMessageReceiverJid : object,
2167
+ /** Payment transaction timestamp */
2168
+ paymentTransactionTimestamp : number,
2169
+ /** Payment paymentStatus */
2170
+ paymentStatus : number,
2171
+ /** Integer that represents the payment Text */
2172
+ paymentTxnStatus : number,
2173
+ /** The note sent with the payment */
2174
+ paymentNote : string;
2175
+ }
2176
+
2177
+ /**
2178
+ * Represents a Call on WhatsApp
2179
+ *
2180
+ * @example
2181
+ * Call {
2182
+ * id: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
2183
+ * from: '5511999999@c.us',
2184
+ * timestamp: 1625003709,
2185
+ * isVideo: false,
2186
+ * isGroup: false,
2187
+ * fromMe: false,
2188
+ * canHandleLocally: false,
2189
+ * webClientShouldHandle: false,
2190
+ * participants: []
2191
+ * }
2192
+ */
2193
+ export interface Call {
2194
+ /** Call Id */
2195
+ id: string,
2196
+ /** from */
2197
+ from?: string,
2198
+ /** Unix timestamp for when the call was created*/
2199
+ timestamp: number,
2200
+ /** Is video */
2201
+ isVideo: boolean,
2202
+ /** Is Group */
2203
+ isGroup: boolean,
2204
+ /** Indicates if the call was sent by the current user */
2205
+ fromMe: boolean,
2206
+ /** indicates if the call can be handled in waweb */
2207
+ canHandleLocally: boolean,
2208
+ /** indicates if the call should be handled in waweb */
2209
+ webClientShouldHandle: boolean,
2210
+ /** Object with participants */
2211
+ participants: object
2212
+
2213
+ /** Reject the call */
2214
+ reject: () => Promise<void>
2215
+ }
2216
+
2217
+ /** Message type List */
2218
+ export class List {
2219
+ body: string
2220
+ buttonText: string
2221
+ sections: Array<any>
2222
+ title?: string | null
2223
+ footer?: string | null
2224
+
2225
+ constructor(body: string, buttonText: string, sections: Array<any>, title?: string | null, footer?: string | null)
2226
+ }
2227
+
2228
+ /** Message type Buttons */
2229
+ export class Buttons {
2230
+ body: string | MessageMedia
2231
+ buttons: Array<{ buttonId: string; buttonText: {displayText: string}; type: number }>
2232
+ title?: string | null
2233
+ footer?: string | null
2234
+
2235
+ constructor(body: string, buttons: Array<{ id?: string; body: string }>, title?: string | null, footer?: string | null)
2236
+ }
2237
+
2238
+ /** Message type Reaction */
2239
+ export class Reaction {
2240
+ id: MessageId
2241
+ orphan: number
2242
+ orphanReason?: string
2243
+ timestamp: number
2244
+ reaction: string
2245
+ read: boolean
2246
+ msgId: MessageId
2247
+ senderId: string
2248
+ ack?: number
2249
+ }
2250
+
2251
+ export type ReactionList = {
2252
+ id: string,
2253
+ aggregateEmoji: string,
2254
+ hasReactionByMe: boolean,
2255
+ senders: Array<Reaction>
2256
+ }
2257
+ }
2258
+
2259
+ export = WAWebJS