@gqb333/based 2.7.71

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 (201) hide show
  1. package/LICENSE +58 -0
  2. package/README.MD +611 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +5604 -0
  5. package/WAProto/index.d.ts +63156 -0
  6. package/WAProto/index.js +195638 -0
  7. package/WAProto/p.html +1 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/baileys-version.json +3 -0
  10. package/lib/Defaults/index.d.ts +53 -0
  11. package/lib/Defaults/index.js +108 -0
  12. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  13. package/lib/Signal/Group/ciphertext-message.js +15 -0
  14. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  15. package/lib/Signal/Group/group-session-builder.js +64 -0
  16. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  17. package/lib/Signal/Group/group_cipher.js +96 -0
  18. package/lib/Signal/Group/index.d.ts +11 -0
  19. package/lib/Signal/Group/index.js +57 -0
  20. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  21. package/lib/Signal/Group/keyhelper.js +55 -0
  22. package/lib/Signal/Group/queue-job.d.ts +1 -0
  23. package/lib/Signal/Group/queue-job.js +57 -0
  24. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  25. package/lib/Signal/Group/sender-chain-key.js +34 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  27. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  28. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  29. package/lib/Signal/Group/sender-key-message.js +69 -0
  30. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  31. package/lib/Signal/Group/sender-key-name.js +51 -0
  32. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  33. package/lib/Signal/Group/sender-key-record.js +53 -0
  34. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  35. package/lib/Signal/Group/sender-key-state.js +99 -0
  36. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  37. package/lib/Signal/Group/sender-message-key.js +29 -0
  38. package/lib/Signal/libsignal.d.ts +3 -0
  39. package/lib/Signal/libsignal.js +174 -0
  40. package/lib/Socket/Client/index.d.ts +2 -0
  41. package/lib/Socket/Client/index.js +18 -0
  42. package/lib/Socket/Client/types.d.ts +16 -0
  43. package/lib/Socket/Client/types.js +13 -0
  44. package/lib/Socket/Client/websocket.d.ts +13 -0
  45. package/lib/Socket/Client/websocket.js +111 -0
  46. package/lib/Socket/business.d.ts +172 -0
  47. package/lib/Socket/business.js +260 -0
  48. package/lib/Socket/chats.d.ts +85 -0
  49. package/lib/Socket/chats.js +1094 -0
  50. package/lib/Socket/groups.d.ts +124 -0
  51. package/lib/Socket/groups.js +423 -0
  52. package/lib/Socket/index.d.ts +172 -0
  53. package/lib/Socket/index.js +32 -0
  54. package/lib/Socket/messages-interactive.js +259 -0
  55. package/lib/Socket/messages-recv.d.ts +161 -0
  56. package/lib/Socket/messages-recv.js +1474 -0
  57. package/lib/Socket/messages-send.d.ts +151 -0
  58. package/lib/Socket/messages-send.js +1085 -0
  59. package/lib/Socket/newsletter.d.ts +136 -0
  60. package/lib/Socket/newsletter.js +250 -0
  61. package/lib/Socket/socket.d.ts +43 -0
  62. package/lib/Socket/socket.js +1241 -0
  63. package/lib/Socket/usync.d.ts +36 -0
  64. package/lib/Socket/usync.js +123 -0
  65. package/lib/Store/index.d.ts +2 -0
  66. package/lib/Store/index.js +8 -0
  67. package/lib/Store/make-in-memory-store.d.ts +118 -0
  68. package/lib/Store/make-in-memory-store.js +452 -0
  69. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  70. package/lib/Store/make-ordered-dictionary.js +81 -0
  71. package/lib/Store/object-repository.d.ts +10 -0
  72. package/lib/Store/object-repository.js +27 -0
  73. package/lib/Types/Auth.d.ts +114 -0
  74. package/lib/Types/Auth.js +2 -0
  75. package/lib/Types/Call.d.ts +13 -0
  76. package/lib/Types/Call.js +2 -0
  77. package/lib/Types/Chat.d.ts +109 -0
  78. package/lib/Types/Chat.js +4 -0
  79. package/lib/Types/Contact.d.ts +29 -0
  80. package/lib/Types/Contact.js +2 -0
  81. package/lib/Types/Events.d.ts +199 -0
  82. package/lib/Types/Events.js +2 -0
  83. package/lib/Types/GroupMetadata.d.ts +64 -0
  84. package/lib/Types/GroupMetadata.js +2 -0
  85. package/lib/Types/Label.d.ts +35 -0
  86. package/lib/Types/Label.js +27 -0
  87. package/lib/Types/LabelAssociation.d.ts +29 -0
  88. package/lib/Types/LabelAssociation.js +9 -0
  89. package/lib/Types/Message.d.ts +740 -0
  90. package/lib/Types/Message.js +7 -0
  91. package/lib/Types/Newsletter.d.ts +22 -0
  92. package/lib/Types/Newsletter.js +18 -0
  93. package/lib/Types/Product.d.ts +78 -0
  94. package/lib/Types/Product.js +2 -0
  95. package/lib/Types/Signal.d.ts +63 -0
  96. package/lib/Types/Signal.js +2 -0
  97. package/lib/Types/Socket.d.ts +134 -0
  98. package/lib/Types/Socket.js +2 -0
  99. package/lib/Types/State.d.ts +27 -0
  100. package/lib/Types/State.js +2 -0
  101. package/lib/Types/USync.d.ts +25 -0
  102. package/lib/Types/USync.js +2 -0
  103. package/lib/Types/index.d.ts +65 -0
  104. package/lib/Types/index.js +43 -0
  105. package/lib/Utils/auth-utils.d.ts +18 -0
  106. package/lib/Utils/auth-utils.js +209 -0
  107. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  108. package/lib/Utils/baileys-event-stream.js +63 -0
  109. package/lib/Utils/business.d.ts +22 -0
  110. package/lib/Utils/business.js +234 -0
  111. package/lib/Utils/cache-manager.d.ts +16 -0
  112. package/lib/Utils/cache-manager.js +114 -0
  113. package/lib/Utils/chat-utils.d.ts +70 -0
  114. package/lib/Utils/chat-utils.js +734 -0
  115. package/lib/Utils/crypto.d.ts +40 -0
  116. package/lib/Utils/crypto.js +193 -0
  117. package/lib/Utils/decode-wa-message.d.ts +35 -0
  118. package/lib/Utils/decode-wa-message.js +207 -0
  119. package/lib/Utils/event-buffer.d.ts +35 -0
  120. package/lib/Utils/event-buffer.js +619 -0
  121. package/lib/Utils/generics.d.ts +89 -0
  122. package/lib/Utils/generics.js +440 -0
  123. package/lib/Utils/history.d.ts +19 -0
  124. package/lib/Utils/history.js +94 -0
  125. package/lib/Utils/index.d.ts +22 -0
  126. package/lib/Utils/index.js +38 -0
  127. package/lib/Utils/jid-validation.d.ts +2 -0
  128. package/lib/Utils/jid-validation.js +186 -0
  129. package/lib/Utils/link-preview.d.ts +21 -0
  130. package/lib/Utils/link-preview.js +152 -0
  131. package/lib/Utils/logger.d.ts +11 -0
  132. package/lib/Utils/logger.js +59 -0
  133. package/lib/Utils/lt-hash.d.ts +12 -0
  134. package/lib/Utils/lt-hash.js +51 -0
  135. package/lib/Utils/make-mutex.d.ts +7 -0
  136. package/lib/Utils/make-mutex.js +43 -0
  137. package/lib/Utils/messages-media.d.ts +120 -0
  138. package/lib/Utils/messages-media.js +848 -0
  139. package/lib/Utils/messages.d.ts +131 -0
  140. package/lib/Utils/messages.js +1793 -0
  141. package/lib/Utils/newsletter-utils.d.ts +2 -0
  142. package/lib/Utils/newsletter-utils.js +48 -0
  143. package/lib/Utils/noise-handler.d.ts +19 -0
  144. package/lib/Utils/noise-handler.js +150 -0
  145. package/lib/Utils/performance-config.d.ts +70 -0
  146. package/lib/Utils/performance-config.js +183 -0
  147. package/lib/Utils/process-message.d.ts +42 -0
  148. package/lib/Utils/process-message.js +498 -0
  149. package/lib/Utils/rate-limiter.js +90 -0
  150. package/lib/Utils/retry.js +66 -0
  151. package/lib/Utils/signal.d.ts +33 -0
  152. package/lib/Utils/signal.js +153 -0
  153. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
  154. package/lib/Utils/use-multi-file-auth-state.js +129 -0
  155. package/lib/Utils/validate-connection.d.ts +10 -0
  156. package/lib/Utils/validate-connection.js +233 -0
  157. package/lib/WABinary/constants.d.ts +27 -0
  158. package/lib/WABinary/constants.js +1303 -0
  159. package/lib/WABinary/decode.d.ts +6 -0
  160. package/lib/WABinary/decode.js +279 -0
  161. package/lib/WABinary/encode.d.ts +2 -0
  162. package/lib/WABinary/encode.js +264 -0
  163. package/lib/WABinary/generic-utils.d.ts +14 -0
  164. package/lib/WABinary/generic-utils.js +114 -0
  165. package/lib/WABinary/index.d.ts +5 -0
  166. package/lib/WABinary/index.js +21 -0
  167. package/lib/WABinary/jid-utils.d.ts +38 -0
  168. package/lib/WABinary/jid-utils.js +485 -0
  169. package/lib/WABinary/types.d.ts +18 -0
  170. package/lib/WABinary/types.js +2 -0
  171. package/lib/WAM/BinaryInfo.d.ts +8 -0
  172. package/lib/WAM/BinaryInfo.js +13 -0
  173. package/lib/WAM/constants.d.ts +38 -0
  174. package/lib/WAM/constants.js +15350 -0
  175. package/lib/WAM/encode.d.ts +2 -0
  176. package/lib/WAM/encode.js +155 -0
  177. package/lib/WAM/index.d.ts +3 -0
  178. package/lib/WAM/index.js +19 -0
  179. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  180. package/lib/WAUSync/Protocols/USyncContactProtocol.js +102 -0
  181. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  182. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +110 -0
  183. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  184. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  185. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  186. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  187. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  188. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  189. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  190. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  191. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  192. package/lib/WAUSync/Protocols/index.js +20 -0
  193. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  194. package/lib/WAUSync/USyncQuery.js +147 -0
  195. package/lib/WAUSync/USyncUser.d.ts +12 -0
  196. package/lib/WAUSync/USyncUser.js +26 -0
  197. package/lib/WAUSync/index.d.ts +3 -0
  198. package/lib/WAUSync/index.js +19 -0
  199. package/lib/index.d.ts +17 -0
  200. package/lib/index.js +53 -0
  201. package/package.json +104 -0
@@ -0,0 +1,740 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import type { Readable } from 'stream';
3
+ import type { URL } from 'url';
4
+ import { proto } from '../../WAProto';
5
+ import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
6
+ import { BinaryNode } from '../WABinary';
7
+ import type { GroupMetadata } from './GroupMetadata';
8
+ import { CacheStore } from './Socket';
9
+ import { ILogger } from '../Utils/logger';
10
+ export { proto as WAProto };
11
+ export type WAMessage = proto.IWebMessageInfo & {
12
+ key: WAMessageKey;
13
+ };
14
+ export type WAMessageContent = proto.IMessage;
15
+ export type WAContactMessage = proto.Message.IContactMessage;
16
+ export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
17
+ export type WAMessageKey = proto.IMessageKey & {
18
+ senderPn?: string;
19
+ senderLid?: string;
20
+ participantLid?: string;
21
+ remoteLid?: string;
22
+ remoteJidNormalized?: string;
23
+ server_id?: string;
24
+ isViewOnce?: boolean;
25
+ };
26
+ export type WATextMessage = proto.Message.IExtendedTextMessage;
27
+ export type WAContextInfo = proto.IContextInfo;
28
+ export type WALocationMessage = proto.Message.ILocationMessage;
29
+ export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
30
+ export interface StickerPackMessage {
31
+ name: string;
32
+ publisher: string;
33
+ description?: string;
34
+ cover?: WAMediaUpload;
35
+ stickers: Sticker[];
36
+ stickerPackId?: string;
37
+ origin?: 0 | 1 | 2; // FIRST_PARTY = 0, THIRD_PARTY = 1, USER_CREATED = 2
38
+ caption?: string;
39
+ }
40
+ export interface Sticker {
41
+ sticker: WAMediaUpload;
42
+ emojis?: string[];
43
+ isAnimated?: boolean;
44
+ isLottie?: boolean;
45
+ fileName?: string;
46
+ accessibilityLabel?: string;
47
+ mimetype?: string;
48
+ }
49
+ export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
50
+ export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
51
+ export type WAMediaPayloadURL = {
52
+ url: URL | string;
53
+ };
54
+ export type WAMediaPayloadStream = {
55
+ stream: Readable;
56
+ };
57
+ export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
58
+ /** Set of message types that are supported by the library */
59
+ export type MessageType = keyof proto.Message;
60
+ export type DownloadableMessage = {
61
+ mediaKey?: Uint8Array | null;
62
+ directPath?: string | null;
63
+ url?: string | null;
64
+ };
65
+ export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
66
+ export type MediaConnInfo = {
67
+ auth: string;
68
+ ttl: number;
69
+ hosts: {
70
+ hostname: string;
71
+ maxContentLengthBytes: number;
72
+ }[];
73
+ fetchDate: Date;
74
+ };
75
+ export interface WAUrlInfo {
76
+ 'canonical-url': string;
77
+ 'matched-text': string;
78
+ title: string;
79
+ description?: string;
80
+ jpegThumbnail?: Buffer;
81
+ highQualityThumbnail?: proto.Message.IImageMessage;
82
+ originalThumbnailUrl?: string;
83
+ }
84
+ type Mentionable = {
85
+ /** list of jids that are mentioned in the accompanying text */
86
+ mentions?: string[];
87
+ };
88
+ type Contextable = {
89
+ /** add contextInfo to the message */
90
+ contextInfo?: proto.IContextInfo;
91
+ };
92
+ type ViewOnce = {
93
+ viewOnce?: boolean;
94
+ };
95
+ type Buttonable = {
96
+ /** add buttons to the message */
97
+ buttons?: proto.Message.ButtonsMessage.IButton[];
98
+ };
99
+ type Templatable = {
100
+ /** add buttons to the message (conflicts with normal buttons)*/
101
+ templateButtons?: proto.IHydratedTemplateButton[];
102
+ footer?: string;
103
+ };
104
+ type Interactiveable = {
105
+ /** add buttons to the message */
106
+ interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
107
+ title?: string;
108
+ subtitle?: string;
109
+ media?: boolean;
110
+ /** Footer with optional audio attachment */
111
+ footer?: string | {
112
+ text: string;
113
+ audio?: WAMediaUpload;
114
+ };
115
+ /** Product message in header */
116
+ headerProduct?: WASendableProduct;
117
+ };
118
+ type Shopable = {
119
+ shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
120
+ id?: string;
121
+ title?: string;
122
+ subtitle?: string;
123
+ media?: boolean;
124
+ };
125
+ type Collectionable = {
126
+ collection?: {
127
+ bizJid: string;
128
+ id: string;
129
+ messageVersion?: number;
130
+ };
131
+ };
132
+ type Invoiceable = {
133
+ invoice?: {
134
+ note: string;
135
+ token: string;
136
+ attachmentType?: 0 | 1; // 0 = IMAGE, 1 = PDF
137
+ attachment?: WAMediaUpload;
138
+ };
139
+ };
140
+ type Cardsable = {
141
+ cards?: CarouselCard[];
142
+ subtitle?: string;
143
+ /** Carousel card type: 1 = HSCROLL_CARDS, 2 = ALBUM_IMAGE */
144
+ carouselCardType?: 1 | 2;
145
+ };
146
+
147
+ type CarouselCard = {
148
+ title?: string;
149
+ body?: string;
150
+ footer?: string;
151
+ image?: WAMediaUpload;
152
+ video?: WAMediaUpload;
153
+ buttons?: CarouselButton[];
154
+ };
155
+
156
+ type CarouselButton = {
157
+ name: 'quick_reply' | 'cta_url';
158
+ buttonParamsJson: string;
159
+ };
160
+ type Editable = {
161
+ edit?: WAMessageKey;
162
+ };
163
+ type Listable = {
164
+ /** Sections of the List */
165
+ sections?: proto.Message.ListMessage.ISection[];
166
+ /** Title of a List Message only */
167
+ title?: string;
168
+ /** Text of the button on the list (required) */
169
+ buttonText?: string;
170
+ /** ListType of a List Message only */
171
+ listType?: proto.Message.ListMessage.ListType;
172
+ };
173
+ type WithDimensions = {
174
+ width?: number;
175
+ height?: number;
176
+ };
177
+ export type PollMessageOptions = {
178
+ name: string;
179
+ selectableCount?: number;
180
+ values: string[];
181
+ /** 32 byte message secret to encrypt poll selections */
182
+ messageSecret?: Uint8Array;
183
+ toAnnouncementGroup?: boolean;
184
+ };
185
+ type SharePhoneNumber = {
186
+ sharePhoneNumber: boolean;
187
+ };
188
+ type RequestPhoneNumber = {
189
+ requestPhoneNumber: boolean;
190
+ };
191
+ export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
192
+ export type AnyMediaMessageContent = (({
193
+ image: WAMediaUpload;
194
+ caption?: string;
195
+ jpegThumbnail?: string;
196
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Invoiceable & Cardsable & WithDimensions) | ({
197
+ video: WAMediaUpload;
198
+ caption?: string;
199
+ gifPlayback?: boolean;
200
+ jpegThumbnail?: string;
201
+ /** if set to true, will send as a `video note` */
202
+ ptv?: boolean;
203
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | {
204
+ audio: WAMediaUpload;
205
+ /** if set to true, will send as a `voice note` */
206
+ ptt?: boolean;
207
+ /** optionally tell the duration of the audio */
208
+ seconds?: number;
209
+ } | ({
210
+ sticker: WAMediaUpload;
211
+ isAnimated?: boolean;
212
+ } & WithDimensions) | ({
213
+ document: WAMediaUpload;
214
+ mimetype: string;
215
+ fileName?: string;
216
+ caption?: string;
217
+ } & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable)) & {
218
+ mimetype?: string;
219
+ } & Editable;
220
+ export type ButtonReplyInfo = {
221
+ displayText: string;
222
+ id: string;
223
+ index: number;
224
+ carouselCardIndex?: number; // For carousel button replies
225
+ };
226
+ export type GroupInviteInfo = {
227
+ inviteCode: string;
228
+ inviteExpiration: number;
229
+ text: string;
230
+ jid: string;
231
+ subject: string;
232
+ };
233
+ export type CallCreationInfo = {
234
+ time?: number;
235
+ title?: string;
236
+ type?: number;
237
+ };
238
+ export type AdminInviteInfo = {
239
+ inviteExpiration: number;
240
+ text: string;
241
+ jid: string;
242
+ subject: string;
243
+ thumbnail: Buffer;
244
+ };
245
+ export type PaymentInviteInfo = {
246
+ type?: number;
247
+ expiry?: number;
248
+ };
249
+ export type RequestPaymentInfo = {
250
+ expiry: number;
251
+ amount: number;
252
+ currency: string;
253
+ from: string;
254
+ note?: string;
255
+ sticker?: WAMediaUpload;
256
+ background: string;
257
+ /** add contextInfo to the message */
258
+ contextInfo?: proto.IContextInfo;
259
+ };
260
+ export type EventsInfo = {
261
+ isCanceled?: boolean;
262
+ name: string;
263
+ description: string;
264
+ joinLink?: string;
265
+ startTime?: number;
266
+ messageSecret?: Uint8Array;
267
+ };
268
+ export type CommentInfo = {
269
+ message: proto.IMessage;
270
+ targetMessageKey: WAMessageKey;
271
+ };
272
+ export type QuestionInfo = {
273
+ text: string;
274
+ contextInfo?: proto.IContextInfo;
275
+ };
276
+ export type QuestionResponseInfo = {
277
+ key: WAMessageKey;
278
+ text: string;
279
+ };
280
+ export type StatusQuestionAnswerInfo = {
281
+ key: WAMessageKey;
282
+ text: string;
283
+ };
284
+ export type StatusQuotedInfo = {
285
+ type: proto.Message.StatusQuotedMessage.StatusQuotedMessageType;
286
+ text: string;
287
+ thumbnail?: Buffer;
288
+ originalStatusId?: WAMessageKey;
289
+ };
290
+ export type StatusStickerInteractionInfo = {
291
+ key: WAMessageKey;
292
+ stickerKey: string;
293
+ type: proto.Message.StatusStickerInteractionMessage.StatusStickerType;
294
+ };
295
+ export type PollMessageOptionsV4 = PollMessageOptions & { pollType: proto.Message.PollType; };
296
+ export type PollMessageOptionsV5 = PollMessageOptions & { pollType: proto.Message.PollType; };
297
+ export type PollResultSnapshotMessageV3 = {
298
+ pollCreationMessageKey: WAMessageKey;
299
+ pollResult?: {
300
+ vote: {
301
+ selectedOptions: Uint8Array[];
302
+ };
303
+ senderTimestampMs: number;
304
+ };
305
+ selectedOptions?: Uint8Array[];
306
+ contextInfo?: proto.IContextInfo;
307
+ pollType?: proto.Message.PollType;
308
+ };
309
+
310
+ export type TemplateButton = proto.TemplateButton;
311
+
312
+ export type HydratedFourRowTemplateInfo = {
313
+ text?: string;
314
+ footer?: string;
315
+ header?: InteractiveMessageHeader;
316
+ buttons: TemplateButton[];
317
+ };
318
+
319
+ export type FourRowTemplateInfo = {
320
+ text?: string;
321
+ footer?: string;
322
+ header?: InteractiveMessageHeader;
323
+ buttons: TemplateButton[];
324
+ };
325
+
326
+ export type RichResponseInfo = {
327
+ messageType?: proto.AIRichResponseMessageType;
328
+ submessages?: proto.Message.AIRichResponseSubMessage[];
329
+ unifiedResponse?: proto.Message.AIRichResponseUnifiedResponse;
330
+ contextInfo?: proto.IContextInfo;
331
+ };
332
+ export type EventResponseInfo = {
333
+ response: proto.Message.EventResponseMessage.EventResponseType; // GOING = 1, NOT_GOING = 2, MAYBE = 3
334
+ timestampMs?: number;
335
+ extraGuestCount?: number;
336
+ };
337
+ export type StatusMentionInfo = {
338
+ quotedStatus: proto.IMessage;
339
+ };
340
+ export type GroupStatusInfo = {
341
+ message: proto.IMessage;
342
+ };
343
+ export type BotTaskInfo = {
344
+ message: proto.IMessage;
345
+ };
346
+ export type LimitSharingInfo = {
347
+ message: proto.IMessage;
348
+ };
349
+ export type StatusAddYoursInfo = {
350
+ message: proto.IMessage;
351
+ };
352
+ export type BotForwardedInfo = {
353
+ message: proto.IMessage;
354
+ };
355
+ export type EventCoverImageInfo = {
356
+ message: proto.IMessage;
357
+ };
358
+ export type OrderInfo = {
359
+ id: number;
360
+ thumbnail: string;
361
+ itemCount: number;
362
+ status: number;
363
+ surface: number;
364
+ title: string;
365
+ text: string;
366
+ seller: string;
367
+ token: string;
368
+ amount: number;
369
+ currency: string;
370
+ };
371
+ export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
372
+ productImage: WAMediaUpload;
373
+ };
374
+ export type AlbumMedia = {
375
+ image: WAMediaUpload;
376
+ caption?: string;
377
+ } | {
378
+ video: WAMediaUpload;
379
+ caption?: string;
380
+ gifPlayback?: boolean;
381
+ };
382
+ export type AnyRegularMessageContent = (({
383
+ text: string;
384
+ linkPreview?: WAUrlInfo | null;
385
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
386
+ template: FourRowTemplateInfo | HydratedFourRowTemplateInfo;
387
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | ({
388
+ poll: PollMessageOptions;
389
+ } & Mentionable & Contextable & Buttonable & Templatable & Editable) | ({
390
+ pollV4: PollMessageOptionsV4;
391
+ } & Mentionable & Contextable & Buttonable & Templatable & Editable) | ({
392
+ pollV5: PollMessageOptionsV5;
393
+ } & Mentionable & Contextable & Buttonable & Templatable & Editable) | ({
394
+ pollResultSnapshotV3: PollResultSnapshotMessageV3;
395
+ } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
396
+ contacts: {
397
+ displayName?: string;
398
+ contacts: proto.Message.IContactMessage[];
399
+ };
400
+ } | {
401
+ location: WALocationMessage;
402
+ } | {
403
+ react: proto.Message.IReactionMessage;
404
+ } | {
405
+ buttonReply: ButtonReplyInfo;
406
+ type: 'template' | 'plain';
407
+ } | {
408
+ groupInvite: GroupInviteInfo;
409
+ } | {
410
+ listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
411
+ } | {
412
+ pin: WAMessageKey | {
413
+ key: WAMessageKey;
414
+ type?: 1 | 2; // 1 = PIN_FOR_ALL, 2 = UNPIN_FOR_ALL
415
+ time?: number; // Duration in seconds (24 hours = 86400, 7 days = 604800, 30 days = 2592000)
416
+ };
417
+ type?: 1 | 2; // 1 = PIN_FOR_ALL, 2 = UNPIN_FOR_ALL (only used if pin is WAMessageKey)
418
+ /**
419
+ * Duration in seconds for pin (24 hours = 86400, 7 days = 604800, 30 days = 2592000)
420
+ * Only used when type = 1 (PIN_FOR_ALL)
421
+ */
422
+ time?: number;
423
+ } | {
424
+ keep: WAMessageKey;
425
+ type: number;
426
+ /**
427
+ * 24 hours, 7 days, 90 days
428
+ */
429
+ time?: 86400 | 604800 | 7776000;
430
+ } | {
431
+ paymentInvite: PaymentInviteInfo;
432
+ } | {
433
+ requestPayment: RequestPaymentInfo;
434
+ } | {
435
+ event: EventsInfo;
436
+ } | {
437
+ comment: CommentInfo;
438
+ } | {
439
+ question: QuestionInfo;
440
+ } | {
441
+ questionResponse: QuestionResponseInfo;
442
+ } | {
443
+ statusQuestionAnswer: StatusQuestionAnswerInfo;
444
+ } | {
445
+ statusQuoted: StatusQuotedInfo;
446
+ } | {
447
+ statusStickerInteraction: StatusStickerInteractionInfo;
448
+ } | {
449
+ richResponse: RichResponseInfo;
450
+ } | {
451
+ eventResponse: EventResponseInfo;
452
+ } | {
453
+ statusMention: StatusMentionInfo;
454
+ } | {
455
+ groupStatus: GroupStatusInfo;
456
+ } | {
457
+ botTask: BotTaskInfo;
458
+ } | {
459
+ limitSharing: LimitSharingInfo;
460
+ } | {
461
+ statusAddYours: StatusAddYoursInfo;
462
+ } | {
463
+ botForwarded: BotForwardedInfo;
464
+ } | {
465
+ eventCoverImage: EventCoverImageInfo;
466
+ } | {
467
+ bCall: {
468
+ sessionId: string;
469
+ mediaType?: 0 | 1 | 2; // UNKNOWN = 0, AUDIO = 1, VIDEO = 2
470
+ masterKey?: Uint8Array;
471
+ caption?: string;
472
+ };
473
+ } | {
474
+ callLog: {
475
+ isVideo?: boolean;
476
+ callOutcome?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; // CONNECTED, MISSED, FAILED, etc.
477
+ durationSecs?: number;
478
+ callType?: 0 | 1 | 2; // REGULAR = 0, SCHEDULED_CALL = 1, VOICE_CHAT = 2
479
+ participants?: Array<{
480
+ jid: string;
481
+ callOutcome?: number;
482
+ }>;
483
+ };
484
+ } | {
485
+ encComment: {
486
+ targetMessageKey: WAMessageKey;
487
+ encPayload: Uint8Array;
488
+ encIv: Uint8Array;
489
+ };
490
+ } | {
491
+ encEventResponse: {
492
+ eventCreationMessageKey: WAMessageKey;
493
+ encPayload: Uint8Array;
494
+ encIv: Uint8Array;
495
+ };
496
+ } | {
497
+ messageHistoryBundle: {
498
+ mimetype?: string;
499
+ media?: WAMediaUpload;
500
+ contextInfo?: proto.IContextInfo;
501
+ messageHistoryMetadata?: {
502
+ historyReceivers?: string[];
503
+ oldestMessageTimestamp?: number;
504
+ messageCount?: number;
505
+ };
506
+ };
507
+ } | {
508
+ messageHistoryNotice: {
509
+ contextInfo?: proto.IContextInfo;
510
+ messageHistoryMetadata?: {
511
+ historyReceivers?: string[];
512
+ oldestMessageTimestamp?: number;
513
+ messageCount?: number;
514
+ };
515
+ };
516
+ } | {
517
+ inviteFollower: {
518
+ newsletterJid: string;
519
+ newsletterName: string;
520
+ thumbnail?: Buffer;
521
+ caption?: string;
522
+ contextInfo?: proto.IContextInfo;
523
+ };
524
+ } | {
525
+ placeholder: {
526
+ type?: 0; // MASK_LINKED_DEVICES = 0
527
+ };
528
+ } | {
529
+ secretEncrypted: {
530
+ targetMessageKey: WAMessageKey;
531
+ encPayload: Uint8Array;
532
+ encIv: Uint8Array;
533
+ secretEncType?: 0 | 1 | 2; // UNKNOWN = 0, EVENT_EDIT = 1, MESSAGE_EDIT = 2
534
+ };
535
+ } | {
536
+ statusNotification: {
537
+ responseMessageKey?: WAMessageKey;
538
+ originalMessageKey?: WAMessageKey;
539
+ type?: 0 | 1 | 2 | 3; // UNKNOWN = 0, STATUS_ADD_YOURS = 1, STATUS_RESHARE = 2, STATUS_QUESTION_ANSWER_RESHARE = 3
540
+ };
541
+ } | {
542
+ stickerSyncRMR: {
543
+ filehash?: string[];
544
+ rmrSource?: string;
545
+ requestTimestamp?: number;
546
+ };
547
+ } | {
548
+ sendPayment: {
549
+ requestMessageKey: WAMessageKey;
550
+ noteMessage?: proto.IMessage;
551
+ background?: proto.IPaymentBackground;
552
+ transactionData?: string;
553
+ };
554
+ } | {
555
+ declinePayment: {
556
+ key: WAMessageKey;
557
+ };
558
+ } | {
559
+ cancelPayment: {
560
+ key: WAMessageKey;
561
+ };
562
+ } | {
563
+ scheduledCallEdit: {
564
+ key: WAMessageKey;
565
+ editType?: 0 | 1; // UNKNOWN = 0, CANCEL = 1
566
+ };
567
+ } | {
568
+ pollResultSnapshot: {
569
+ name: string;
570
+ pollVotes?: Array<{
571
+ optionName: string;
572
+ optionVoteCount: number;
573
+ }>;
574
+ contextInfo?: proto.IContextInfo;
575
+ pollType?: 0 | 1; // POLL = 0, QUIZ = 1
576
+ };
577
+ } | {
578
+ pollUpdate: {
579
+ pollCreationMessageKey: WAMessageKey;
580
+ vote?: {
581
+ encPayload: Uint8Array;
582
+ encIv: Uint8Array;
583
+ };
584
+ metadata?: {};
585
+ senderTimestampMs?: number;
586
+ };
587
+ } | {
588
+ deviceSent: {
589
+ destinationJid: string;
590
+ message: AnyRegularMessageContent;
591
+ phash?: string;
592
+ };
593
+ } | {
594
+ chat: {
595
+ displayName: string;
596
+ id: string;
597
+ };
598
+ } | {
599
+ order: OrderInfo;
600
+ } | {
601
+ call: CallCreationInfo;
602
+ } | {
603
+ inviteAdmin: AdminInviteInfo;
604
+ } | {
605
+ listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
606
+ } | ({
607
+ product: WASendableProduct;
608
+ businessOwnerJid?: string;
609
+ body?: string;
610
+ footer?: string;
611
+ } & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber | ({
612
+ album: AlbumMedia[];
613
+ caption?: string;
614
+ } & Mentionable & Contextable & Editable) | {
615
+ stickerPack: StickerPackMessage;
616
+ } | {
617
+ interactiveResponse: {
618
+ body?: {
619
+ text: string;
620
+ format?: 0 | 1; // DEFAULT = 0, EXTENSIONS_1 = 1
621
+ };
622
+ nativeFlowResponse?: {
623
+ name: string;
624
+ paramsJson: string;
625
+ version?: number;
626
+ };
627
+ contextInfo?: proto.IContextInfo;
628
+ };
629
+ }) & ViewOnce;
630
+ export type AnyMessageContent = AnyRegularMessageContent | {
631
+ forward: WAMessage;
632
+ force?: boolean;
633
+ } | {
634
+ /** Delete your message or anyone's message in a group (admin required) */
635
+ delete: WAMessageKey;
636
+ } | {
637
+ disappearingMessagesInChat: boolean | number;
638
+ };
639
+ export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
640
+ type MinimalRelayOptions = {
641
+ /** override the message ID with a custom provided string */
642
+ messageId?: string;
643
+ /** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
644
+ useCachedGroupMetadata?: boolean;
645
+ };
646
+ export type MessageRelayOptions = MinimalRelayOptions & {
647
+ /** only send to a specific participant; used when a message decryption fails for a single user */
648
+ participant?: {
649
+ jid: string;
650
+ count: number;
651
+ };
652
+ /** additional attributes to add to the WA binary node */
653
+ additionalAttributes?: {
654
+ [_: string]: string;
655
+ };
656
+ additionalNodes?: BinaryNode[];
657
+ /** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
658
+ useUserDevicesCache?: boolean;
659
+ /** jid list of participants for status@broadcast */
660
+ statusJidList?: string[];
661
+ newsletter?: boolean;
662
+ };
663
+ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
664
+ /** optional, if you want to manually set the timestamp of the message */
665
+ timestamp?: Date;
666
+ /** the message you want to quote */
667
+ quoted?: WAMessage;
668
+ /** disappearing messages settings */
669
+ ephemeralExpiration?: number | string;
670
+ /** timeout for media upload to WA server */
671
+ mediaUploadTimeoutMs?: number;
672
+ /** jid list of participants for status@broadcast */
673
+ statusJidList?: string[];
674
+ /** backgroundcolor for status */
675
+ backgroundColor?: string;
676
+ /** font type for status */
677
+ font?: number;
678
+ /** if it is broadcast */
679
+ broadcast?: boolean;
680
+ newsletter?: boolean;
681
+ additionalNodes?: BinaryNode[];
682
+ };
683
+ export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
684
+ userJid: string;
685
+ };
686
+ export type WAMediaUploadFunctionOpts = {
687
+ fileEncSha256B64: string;
688
+ mediaType: MediaType;
689
+ newsletter?: boolean;
690
+ timeoutMs?: number;
691
+ };
692
+ export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
693
+ mediaUrl: string;
694
+ directPath: string;
695
+ handle?: string;
696
+ }>;
697
+ export type MediaGenerationOptions = {
698
+ logger?: ILogger;
699
+ mediaTypeOverride?: MediaType;
700
+ upload: WAMediaUploadFunction;
701
+ /** cache media so it does not have to be uploaded again */
702
+ mediaCache?: CacheStore;
703
+ mediaUploadTimeoutMs?: number;
704
+ options?: AxiosRequestConfig;
705
+ backgroundColor?: string;
706
+ font?: number;
707
+ /** The message is for newsletter? */
708
+ newsletter?: boolean;
709
+ };
710
+ export type MessageContentGenerationOptions = MediaGenerationOptions & {
711
+ getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
712
+ getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
713
+ };
714
+ export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
715
+ /**
716
+ * Type of message upsert
717
+ * 1. notify => notify the user, this message was just received
718
+ * 2. append => append the message to the chat history, no notification required
719
+ */
720
+ export type MessageUpsertType = 'append' | 'notify';
721
+ export type MessageUserReceipt = proto.IUserReceipt;
722
+ export type WAMessageUpdate = {
723
+ update: Partial<WAMessage>;
724
+ key: proto.IMessageKey;
725
+ };
726
+ export type WAMessageCursor = {
727
+ before: WAMessageKey | undefined;
728
+ } | {
729
+ after: WAMessageKey | undefined;
730
+ };
731
+ export type MessageUserReceiptUpdate = {
732
+ key: proto.IMessageKey;
733
+ receipt: MessageUserReceipt;
734
+ };
735
+ export type MediaDecryptionKeyInfo = {
736
+ iv: Buffer;
737
+ cipherKey: Buffer;
738
+ macKey?: Buffer;
739
+ };
740
+ export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;