@realvare/based 2.5.7 → 2.5.8
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.
- package/README.MD +1288 -1544
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Socket/messages-recv.js +0 -29
- package/lib/Socket/messages-send.js +1406 -1410
- package/lib/Socket/socket.js +1 -1
- package/lib/Types/Message.d.ts +413 -413
- package/lib/Utils/cache-manager.js +1 -16
- package/lib/Utils/messages.js +1338 -1373
- package/lib/Utils/performance-config.d.ts +0 -4
- package/lib/Utils/performance-config.js +4 -8
- package/package.json +6 -3
- package/lib/Utils/rate-limiter.js +0 -95
package/lib/Types/Message.d.ts
CHANGED
|
@@ -1,414 +1,414 @@
|
|
|
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
|
-
server_id?: string;
|
|
22
|
-
isViewOnce?: boolean;
|
|
23
|
-
};
|
|
24
|
-
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
|
25
|
-
export type WAContextInfo = proto.IContextInfo;
|
|
26
|
-
export type WALocationMessage = proto.Message.ILocationMessage;
|
|
27
|
-
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
28
|
-
export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
|
|
29
|
-
export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
|
|
30
|
-
export type WAMediaPayloadURL = {
|
|
31
|
-
url: URL | string;
|
|
32
|
-
};
|
|
33
|
-
export type WAMediaPayloadStream = {
|
|
34
|
-
stream: Readable;
|
|
35
|
-
};
|
|
36
|
-
export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
|
|
37
|
-
/** Set of message types that are supported by the library */
|
|
38
|
-
export type MessageType = keyof proto.Message;
|
|
39
|
-
export type DownloadableMessage = {
|
|
40
|
-
mediaKey?: Uint8Array | null;
|
|
41
|
-
directPath?: string | null;
|
|
42
|
-
url?: string | null;
|
|
43
|
-
};
|
|
44
|
-
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
|
|
45
|
-
export type MediaConnInfo = {
|
|
46
|
-
auth: string;
|
|
47
|
-
ttl: number;
|
|
48
|
-
hosts: {
|
|
49
|
-
hostname: string;
|
|
50
|
-
maxContentLengthBytes: number;
|
|
51
|
-
}[];
|
|
52
|
-
fetchDate: Date;
|
|
53
|
-
};
|
|
54
|
-
export interface WAUrlInfo {
|
|
55
|
-
'canonical-url': string;
|
|
56
|
-
'matched-text': string;
|
|
57
|
-
title: string;
|
|
58
|
-
description?: string;
|
|
59
|
-
jpegThumbnail?: Buffer;
|
|
60
|
-
highQualityThumbnail?: proto.Message.IImageMessage;
|
|
61
|
-
originalThumbnailUrl?: string;
|
|
62
|
-
}
|
|
63
|
-
type Mentionable = {
|
|
64
|
-
/** list of jids that are mentioned in the accompanying text */
|
|
65
|
-
mentions?: string[];
|
|
66
|
-
};
|
|
67
|
-
type Contextable = {
|
|
68
|
-
/** add contextInfo to the message */
|
|
69
|
-
contextInfo?: proto.IContextInfo;
|
|
70
|
-
};
|
|
71
|
-
type ViewOnce = {
|
|
72
|
-
viewOnce?: boolean;
|
|
73
|
-
};
|
|
74
|
-
type Buttonable = {
|
|
75
|
-
/** add buttons to the message */
|
|
76
|
-
buttons?: proto.Message.ButtonsMessage.IButton[];
|
|
77
|
-
};
|
|
78
|
-
type Templatable = {
|
|
79
|
-
/** add buttons to the message (conflicts with normal buttons)*/
|
|
80
|
-
templateButtons?: proto.IHydratedTemplateButton[];
|
|
81
|
-
footer?: string;
|
|
82
|
-
};
|
|
83
|
-
type Interactiveable = {
|
|
84
|
-
/** add buttons to the message */
|
|
85
|
-
interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
|
|
86
|
-
title?: string;
|
|
87
|
-
subtitle?: string;
|
|
88
|
-
media?: boolean;
|
|
89
|
-
};
|
|
90
|
-
type Shopable = {
|
|
91
|
-
shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
|
|
92
|
-
id?: string;
|
|
93
|
-
title?: string;
|
|
94
|
-
subtitle?: string;
|
|
95
|
-
media?: boolean;
|
|
96
|
-
};
|
|
97
|
-
type Cardsable = {
|
|
98
|
-
cards?: CarouselCard[];
|
|
99
|
-
subtitle?: string;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
type CarouselCard = {
|
|
103
|
-
title?: string;
|
|
104
|
-
body?: string;
|
|
105
|
-
footer?: string;
|
|
106
|
-
image?: WAMediaUpload;
|
|
107
|
-
video?: WAMediaUpload;
|
|
108
|
-
buttons?: CarouselButton[];
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
type CarouselButton = {
|
|
112
|
-
name: 'quick_reply' | 'cta_url';
|
|
113
|
-
buttonParamsJson: string;
|
|
114
|
-
};
|
|
115
|
-
type Editable = {
|
|
116
|
-
edit?: WAMessageKey;
|
|
117
|
-
};
|
|
118
|
-
type Listable = {
|
|
119
|
-
/** Sections of the List */
|
|
120
|
-
sections?: proto.Message.ListMessage.ISection[];
|
|
121
|
-
/** Title of a List Message only */
|
|
122
|
-
title?: string;
|
|
123
|
-
/** Text of the button on the list (required) */
|
|
124
|
-
buttonText?: string;
|
|
125
|
-
/** ListType of a List Message only */
|
|
126
|
-
listType?: proto.Message.ListMessage.ListType;
|
|
127
|
-
};
|
|
128
|
-
type WithDimensions = {
|
|
129
|
-
width?: number;
|
|
130
|
-
height?: number;
|
|
131
|
-
};
|
|
132
|
-
export type PollMessageOptions = {
|
|
133
|
-
name: string;
|
|
134
|
-
selectableCount?: number;
|
|
135
|
-
values: string[];
|
|
136
|
-
/** 32 byte message secret to encrypt poll selections */
|
|
137
|
-
messageSecret?: Uint8Array;
|
|
138
|
-
toAnnouncementGroup?: boolean;
|
|
139
|
-
};
|
|
140
|
-
type SharePhoneNumber = {
|
|
141
|
-
sharePhoneNumber: boolean;
|
|
142
|
-
};
|
|
143
|
-
type RequestPhoneNumber = {
|
|
144
|
-
requestPhoneNumber: boolean;
|
|
145
|
-
};
|
|
146
|
-
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
|
|
147
|
-
export type AnyMediaMessageContent = (({
|
|
148
|
-
image: WAMediaUpload;
|
|
149
|
-
caption?: string;
|
|
150
|
-
jpegThumbnail?: string;
|
|
151
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | ({
|
|
152
|
-
video: WAMediaUpload;
|
|
153
|
-
caption?: string;
|
|
154
|
-
gifPlayback?: boolean;
|
|
155
|
-
jpegThumbnail?: string;
|
|
156
|
-
/** if set to true, will send as a `video note` */
|
|
157
|
-
ptv?: boolean;
|
|
158
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | {
|
|
159
|
-
audio: WAMediaUpload;
|
|
160
|
-
/** if set to true, will send as a `voice note` */
|
|
161
|
-
ptt?: boolean;
|
|
162
|
-
/** optionally tell the duration of the audio */
|
|
163
|
-
seconds?: number;
|
|
164
|
-
} | ({
|
|
165
|
-
sticker: WAMediaUpload;
|
|
166
|
-
isAnimated?: boolean;
|
|
167
|
-
} & WithDimensions) | ({
|
|
168
|
-
document: WAMediaUpload;
|
|
169
|
-
mimetype: string;
|
|
170
|
-
fileName?: string;
|
|
171
|
-
caption?: string;
|
|
172
|
-
} & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable)) & {
|
|
173
|
-
mimetype?: string;
|
|
174
|
-
} & Editable;
|
|
175
|
-
export type ButtonReplyInfo = {
|
|
176
|
-
displayText: string;
|
|
177
|
-
id: string;
|
|
178
|
-
index: number;
|
|
179
|
-
};
|
|
180
|
-
export type GroupInviteInfo = {
|
|
181
|
-
inviteCode: string;
|
|
182
|
-
inviteExpiration: number;
|
|
183
|
-
text: string;
|
|
184
|
-
jid: string;
|
|
185
|
-
subject: string;
|
|
186
|
-
};
|
|
187
|
-
export type CallCreationInfo = {
|
|
188
|
-
time?: number;
|
|
189
|
-
title?: string;
|
|
190
|
-
type?: number;
|
|
191
|
-
};
|
|
192
|
-
export type AdminInviteInfo = {
|
|
193
|
-
inviteExpiration: number;
|
|
194
|
-
text: string;
|
|
195
|
-
jid: string;
|
|
196
|
-
subject: string;
|
|
197
|
-
thumbnail: Buffer;
|
|
198
|
-
};
|
|
199
|
-
export type PaymentInviteInfo = {
|
|
200
|
-
type?: number;
|
|
201
|
-
expiry?: number;
|
|
202
|
-
};
|
|
203
|
-
export type RequestPaymentInfo = {
|
|
204
|
-
expiry: number;
|
|
205
|
-
amount: number;
|
|
206
|
-
currency: string;
|
|
207
|
-
from: string;
|
|
208
|
-
note?: string;
|
|
209
|
-
sticker?: WAMediaUpload;
|
|
210
|
-
background: string;
|
|
211
|
-
/** add contextInfo to the message */
|
|
212
|
-
contextInfo?: proto.IContextInfo;
|
|
213
|
-
};
|
|
214
|
-
export type EventsInfo = {
|
|
215
|
-
isCanceled?: boolean;
|
|
216
|
-
name: string;
|
|
217
|
-
description: string;
|
|
218
|
-
joinLink?: string;
|
|
219
|
-
startTime?: number;
|
|
220
|
-
messageSecret?: Uint8Array;
|
|
221
|
-
};
|
|
222
|
-
export type OrderInfo = {
|
|
223
|
-
id: number;
|
|
224
|
-
thumbnail: string;
|
|
225
|
-
itemCount: number;
|
|
226
|
-
status: number;
|
|
227
|
-
surface: number;
|
|
228
|
-
title: string;
|
|
229
|
-
text: string;
|
|
230
|
-
seller: string;
|
|
231
|
-
token: string;
|
|
232
|
-
amount: number;
|
|
233
|
-
currency: string;
|
|
234
|
-
};
|
|
235
|
-
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
|
236
|
-
productImage: WAMediaUpload;
|
|
237
|
-
};
|
|
238
|
-
export type AlbumMedia = {
|
|
239
|
-
image: WAMediaUpload;
|
|
240
|
-
caption?: string;
|
|
241
|
-
} | {
|
|
242
|
-
video: WAMediaUpload;
|
|
243
|
-
caption?: string;
|
|
244
|
-
gifPlayback?: boolean;
|
|
245
|
-
};
|
|
246
|
-
export type AnyRegularMessageContent = (({
|
|
247
|
-
text: string;
|
|
248
|
-
linkPreview?: WAUrlInfo | null;
|
|
249
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
|
|
250
|
-
poll: PollMessageOptions;
|
|
251
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
|
|
252
|
-
contacts: {
|
|
253
|
-
displayName?: string;
|
|
254
|
-
contacts: proto.Message.IContactMessage[];
|
|
255
|
-
};
|
|
256
|
-
} | {
|
|
257
|
-
location: WALocationMessage;
|
|
258
|
-
} | {
|
|
259
|
-
react: proto.Message.IReactionMessage;
|
|
260
|
-
} | {
|
|
261
|
-
buttonReply: ButtonReplyInfo;
|
|
262
|
-
type: 'template' | 'plain';
|
|
263
|
-
} | {
|
|
264
|
-
groupInvite: GroupInviteInfo;
|
|
265
|
-
} | {
|
|
266
|
-
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
267
|
-
} | {
|
|
268
|
-
pin: WAMessageKey;
|
|
269
|
-
type: proto.PinInChat.Type;
|
|
270
|
-
/**
|
|
271
|
-
* 24 hours, 7 days, 30 days
|
|
272
|
-
*/
|
|
273
|
-
time?: 86400 | 604800 | 2592000;
|
|
274
|
-
} | {
|
|
275
|
-
keep: WAMessageKey;
|
|
276
|
-
type: number;
|
|
277
|
-
/**
|
|
278
|
-
* 24 hours, 7 days, 90 days
|
|
279
|
-
*/
|
|
280
|
-
time?: 86400 | 604800 | 7776000;
|
|
281
|
-
} | {
|
|
282
|
-
paymentInvite: PaymentInviteInfo;
|
|
283
|
-
} | {
|
|
284
|
-
requestPayment: RequestPaymentInfo;
|
|
285
|
-
} | {
|
|
286
|
-
event: EventsInfo;
|
|
287
|
-
} | {
|
|
288
|
-
order: OrderInfo;
|
|
289
|
-
} | {
|
|
290
|
-
call: CallCreationInfo;
|
|
291
|
-
} | {
|
|
292
|
-
inviteAdmin: AdminInviteInfo;
|
|
293
|
-
} | {
|
|
294
|
-
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
295
|
-
} | ({
|
|
296
|
-
product: WASendableProduct;
|
|
297
|
-
businessOwnerJid?: string;
|
|
298
|
-
body?: string;
|
|
299
|
-
footer?: string;
|
|
300
|
-
} & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber | ({
|
|
301
|
-
album: AlbumMedia[];
|
|
302
|
-
caption?: string;
|
|
303
|
-
} & Mentionable & Contextable & Editable)) & ViewOnce;
|
|
304
|
-
export type AnyMessageContent = AnyRegularMessageContent | {
|
|
305
|
-
forward: WAMessage;
|
|
306
|
-
force?: boolean;
|
|
307
|
-
} | {
|
|
308
|
-
/** Delete your message or anyone's message in a group (admin required) */
|
|
309
|
-
delete: WAMessageKey;
|
|
310
|
-
} | {
|
|
311
|
-
disappearingMessagesInChat: boolean | number;
|
|
312
|
-
};
|
|
313
|
-
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
|
|
314
|
-
type MinimalRelayOptions = {
|
|
315
|
-
/** override the message ID with a custom provided string */
|
|
316
|
-
messageId?: string;
|
|
317
|
-
/** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
|
|
318
|
-
useCachedGroupMetadata?: boolean;
|
|
319
|
-
};
|
|
320
|
-
export type MessageRelayOptions = MinimalRelayOptions & {
|
|
321
|
-
/** only send to a specific participant; used when a message decryption fails for a single user */
|
|
322
|
-
participant?: {
|
|
323
|
-
jid: string;
|
|
324
|
-
count: number;
|
|
325
|
-
};
|
|
326
|
-
/** additional attributes to add to the WA binary node */
|
|
327
|
-
additionalAttributes?: {
|
|
328
|
-
[_: string]: string;
|
|
329
|
-
};
|
|
330
|
-
additionalNodes?: BinaryNode[];
|
|
331
|
-
/** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
|
|
332
|
-
useUserDevicesCache?: boolean;
|
|
333
|
-
/** jid list of participants for status@broadcast */
|
|
334
|
-
statusJidList?: string[];
|
|
335
|
-
newsletter?: boolean;
|
|
336
|
-
};
|
|
337
|
-
export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
|
338
|
-
/** optional, if you want to manually set the timestamp of the message */
|
|
339
|
-
timestamp?: Date;
|
|
340
|
-
/** the message you want to quote */
|
|
341
|
-
quoted?: WAMessage;
|
|
342
|
-
/** disappearing messages settings */
|
|
343
|
-
ephemeralExpiration?: number | string;
|
|
344
|
-
/** timeout for media upload to WA server */
|
|
345
|
-
mediaUploadTimeoutMs?: number;
|
|
346
|
-
/** jid list of participants for status@broadcast */
|
|
347
|
-
statusJidList?: string[];
|
|
348
|
-
/** backgroundcolor for status */
|
|
349
|
-
backgroundColor?: string;
|
|
350
|
-
/** font type for status */
|
|
351
|
-
font?: number;
|
|
352
|
-
/** if it is broadcast */
|
|
353
|
-
broadcast?: boolean;
|
|
354
|
-
newsletter?: boolean;
|
|
355
|
-
additionalNodes?: BinaryNode[];
|
|
356
|
-
};
|
|
357
|
-
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
|
358
|
-
userJid: string;
|
|
359
|
-
};
|
|
360
|
-
export type WAMediaUploadFunctionOpts = {
|
|
361
|
-
fileEncSha256B64: string;
|
|
362
|
-
mediaType: MediaType;
|
|
363
|
-
newsletter?: boolean;
|
|
364
|
-
timeoutMs?: number;
|
|
365
|
-
};
|
|
366
|
-
export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
|
|
367
|
-
mediaUrl: string;
|
|
368
|
-
directPath: string;
|
|
369
|
-
handle?: string;
|
|
370
|
-
}>;
|
|
371
|
-
export type MediaGenerationOptions = {
|
|
372
|
-
logger?: ILogger;
|
|
373
|
-
mediaTypeOverride?: MediaType;
|
|
374
|
-
upload: WAMediaUploadFunction;
|
|
375
|
-
/** cache media so it does not have to be uploaded again */
|
|
376
|
-
mediaCache?: CacheStore;
|
|
377
|
-
mediaUploadTimeoutMs?: number;
|
|
378
|
-
options?: AxiosRequestConfig;
|
|
379
|
-
backgroundColor?: string;
|
|
380
|
-
font?: number;
|
|
381
|
-
/** The message is for newsletter? */
|
|
382
|
-
newsletter?: boolean;
|
|
383
|
-
};
|
|
384
|
-
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
|
385
|
-
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
|
|
386
|
-
getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
|
|
387
|
-
};
|
|
388
|
-
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
|
|
389
|
-
/**
|
|
390
|
-
* Type of message upsert
|
|
391
|
-
* 1. notify => notify the user, this message was just received
|
|
392
|
-
* 2. append => append the message to the chat history, no notification required
|
|
393
|
-
*/
|
|
394
|
-
export type MessageUpsertType = 'append' | 'notify';
|
|
395
|
-
export type MessageUserReceipt = proto.IUserReceipt;
|
|
396
|
-
export type WAMessageUpdate = {
|
|
397
|
-
update: Partial<WAMessage>;
|
|
398
|
-
key: proto.IMessageKey;
|
|
399
|
-
};
|
|
400
|
-
export type WAMessageCursor = {
|
|
401
|
-
before: WAMessageKey | undefined;
|
|
402
|
-
} | {
|
|
403
|
-
after: WAMessageKey | undefined;
|
|
404
|
-
};
|
|
405
|
-
export type MessageUserReceiptUpdate = {
|
|
406
|
-
key: proto.IMessageKey;
|
|
407
|
-
receipt: MessageUserReceipt;
|
|
408
|
-
};
|
|
409
|
-
export type MediaDecryptionKeyInfo = {
|
|
410
|
-
iv: Buffer;
|
|
411
|
-
cipherKey: Buffer;
|
|
412
|
-
macKey?: Buffer;
|
|
413
|
-
};
|
|
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
|
+
server_id?: string;
|
|
22
|
+
isViewOnce?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
|
25
|
+
export type WAContextInfo = proto.IContextInfo;
|
|
26
|
+
export type WALocationMessage = proto.Message.ILocationMessage;
|
|
27
|
+
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
28
|
+
export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
|
|
29
|
+
export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
|
|
30
|
+
export type WAMediaPayloadURL = {
|
|
31
|
+
url: URL | string;
|
|
32
|
+
};
|
|
33
|
+
export type WAMediaPayloadStream = {
|
|
34
|
+
stream: Readable;
|
|
35
|
+
};
|
|
36
|
+
export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
|
|
37
|
+
/** Set of message types that are supported by the library */
|
|
38
|
+
export type MessageType = keyof proto.Message;
|
|
39
|
+
export type DownloadableMessage = {
|
|
40
|
+
mediaKey?: Uint8Array | null;
|
|
41
|
+
directPath?: string | null;
|
|
42
|
+
url?: string | null;
|
|
43
|
+
};
|
|
44
|
+
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
|
|
45
|
+
export type MediaConnInfo = {
|
|
46
|
+
auth: string;
|
|
47
|
+
ttl: number;
|
|
48
|
+
hosts: {
|
|
49
|
+
hostname: string;
|
|
50
|
+
maxContentLengthBytes: number;
|
|
51
|
+
}[];
|
|
52
|
+
fetchDate: Date;
|
|
53
|
+
};
|
|
54
|
+
export interface WAUrlInfo {
|
|
55
|
+
'canonical-url': string;
|
|
56
|
+
'matched-text': string;
|
|
57
|
+
title: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
jpegThumbnail?: Buffer;
|
|
60
|
+
highQualityThumbnail?: proto.Message.IImageMessage;
|
|
61
|
+
originalThumbnailUrl?: string;
|
|
62
|
+
}
|
|
63
|
+
type Mentionable = {
|
|
64
|
+
/** list of jids that are mentioned in the accompanying text */
|
|
65
|
+
mentions?: string[];
|
|
66
|
+
};
|
|
67
|
+
type Contextable = {
|
|
68
|
+
/** add contextInfo to the message */
|
|
69
|
+
contextInfo?: proto.IContextInfo;
|
|
70
|
+
};
|
|
71
|
+
type ViewOnce = {
|
|
72
|
+
viewOnce?: boolean;
|
|
73
|
+
};
|
|
74
|
+
type Buttonable = {
|
|
75
|
+
/** add buttons to the message */
|
|
76
|
+
buttons?: proto.Message.ButtonsMessage.IButton[];
|
|
77
|
+
};
|
|
78
|
+
type Templatable = {
|
|
79
|
+
/** add buttons to the message (conflicts with normal buttons)*/
|
|
80
|
+
templateButtons?: proto.IHydratedTemplateButton[];
|
|
81
|
+
footer?: string;
|
|
82
|
+
};
|
|
83
|
+
type Interactiveable = {
|
|
84
|
+
/** add buttons to the message */
|
|
85
|
+
interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
|
|
86
|
+
title?: string;
|
|
87
|
+
subtitle?: string;
|
|
88
|
+
media?: boolean;
|
|
89
|
+
};
|
|
90
|
+
type Shopable = {
|
|
91
|
+
shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
|
|
92
|
+
id?: string;
|
|
93
|
+
title?: string;
|
|
94
|
+
subtitle?: string;
|
|
95
|
+
media?: boolean;
|
|
96
|
+
};
|
|
97
|
+
type Cardsable = {
|
|
98
|
+
cards?: CarouselCard[];
|
|
99
|
+
subtitle?: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type CarouselCard = {
|
|
103
|
+
title?: string;
|
|
104
|
+
body?: string;
|
|
105
|
+
footer?: string;
|
|
106
|
+
image?: WAMediaUpload;
|
|
107
|
+
video?: WAMediaUpload;
|
|
108
|
+
buttons?: CarouselButton[];
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type CarouselButton = {
|
|
112
|
+
name: 'quick_reply' | 'cta_url';
|
|
113
|
+
buttonParamsJson: string;
|
|
114
|
+
};
|
|
115
|
+
type Editable = {
|
|
116
|
+
edit?: WAMessageKey;
|
|
117
|
+
};
|
|
118
|
+
type Listable = {
|
|
119
|
+
/** Sections of the List */
|
|
120
|
+
sections?: proto.Message.ListMessage.ISection[];
|
|
121
|
+
/** Title of a List Message only */
|
|
122
|
+
title?: string;
|
|
123
|
+
/** Text of the button on the list (required) */
|
|
124
|
+
buttonText?: string;
|
|
125
|
+
/** ListType of a List Message only */
|
|
126
|
+
listType?: proto.Message.ListMessage.ListType;
|
|
127
|
+
};
|
|
128
|
+
type WithDimensions = {
|
|
129
|
+
width?: number;
|
|
130
|
+
height?: number;
|
|
131
|
+
};
|
|
132
|
+
export type PollMessageOptions = {
|
|
133
|
+
name: string;
|
|
134
|
+
selectableCount?: number;
|
|
135
|
+
values: string[];
|
|
136
|
+
/** 32 byte message secret to encrypt poll selections */
|
|
137
|
+
messageSecret?: Uint8Array;
|
|
138
|
+
toAnnouncementGroup?: boolean;
|
|
139
|
+
};
|
|
140
|
+
type SharePhoneNumber = {
|
|
141
|
+
sharePhoneNumber: boolean;
|
|
142
|
+
};
|
|
143
|
+
type RequestPhoneNumber = {
|
|
144
|
+
requestPhoneNumber: boolean;
|
|
145
|
+
};
|
|
146
|
+
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
|
|
147
|
+
export type AnyMediaMessageContent = (({
|
|
148
|
+
image: WAMediaUpload;
|
|
149
|
+
caption?: string;
|
|
150
|
+
jpegThumbnail?: string;
|
|
151
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | ({
|
|
152
|
+
video: WAMediaUpload;
|
|
153
|
+
caption?: string;
|
|
154
|
+
gifPlayback?: boolean;
|
|
155
|
+
jpegThumbnail?: string;
|
|
156
|
+
/** if set to true, will send as a `video note` */
|
|
157
|
+
ptv?: boolean;
|
|
158
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | {
|
|
159
|
+
audio: WAMediaUpload;
|
|
160
|
+
/** if set to true, will send as a `voice note` */
|
|
161
|
+
ptt?: boolean;
|
|
162
|
+
/** optionally tell the duration of the audio */
|
|
163
|
+
seconds?: number;
|
|
164
|
+
} | ({
|
|
165
|
+
sticker: WAMediaUpload;
|
|
166
|
+
isAnimated?: boolean;
|
|
167
|
+
} & WithDimensions) | ({
|
|
168
|
+
document: WAMediaUpload;
|
|
169
|
+
mimetype: string;
|
|
170
|
+
fileName?: string;
|
|
171
|
+
caption?: string;
|
|
172
|
+
} & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable)) & {
|
|
173
|
+
mimetype?: string;
|
|
174
|
+
} & Editable;
|
|
175
|
+
export type ButtonReplyInfo = {
|
|
176
|
+
displayText: string;
|
|
177
|
+
id: string;
|
|
178
|
+
index: number;
|
|
179
|
+
};
|
|
180
|
+
export type GroupInviteInfo = {
|
|
181
|
+
inviteCode: string;
|
|
182
|
+
inviteExpiration: number;
|
|
183
|
+
text: string;
|
|
184
|
+
jid: string;
|
|
185
|
+
subject: string;
|
|
186
|
+
};
|
|
187
|
+
export type CallCreationInfo = {
|
|
188
|
+
time?: number;
|
|
189
|
+
title?: string;
|
|
190
|
+
type?: number;
|
|
191
|
+
};
|
|
192
|
+
export type AdminInviteInfo = {
|
|
193
|
+
inviteExpiration: number;
|
|
194
|
+
text: string;
|
|
195
|
+
jid: string;
|
|
196
|
+
subject: string;
|
|
197
|
+
thumbnail: Buffer;
|
|
198
|
+
};
|
|
199
|
+
export type PaymentInviteInfo = {
|
|
200
|
+
type?: number;
|
|
201
|
+
expiry?: number;
|
|
202
|
+
};
|
|
203
|
+
export type RequestPaymentInfo = {
|
|
204
|
+
expiry: number;
|
|
205
|
+
amount: number;
|
|
206
|
+
currency: string;
|
|
207
|
+
from: string;
|
|
208
|
+
note?: string;
|
|
209
|
+
sticker?: WAMediaUpload;
|
|
210
|
+
background: string;
|
|
211
|
+
/** add contextInfo to the message */
|
|
212
|
+
contextInfo?: proto.IContextInfo;
|
|
213
|
+
};
|
|
214
|
+
export type EventsInfo = {
|
|
215
|
+
isCanceled?: boolean;
|
|
216
|
+
name: string;
|
|
217
|
+
description: string;
|
|
218
|
+
joinLink?: string;
|
|
219
|
+
startTime?: number;
|
|
220
|
+
messageSecret?: Uint8Array;
|
|
221
|
+
};
|
|
222
|
+
export type OrderInfo = {
|
|
223
|
+
id: number;
|
|
224
|
+
thumbnail: string;
|
|
225
|
+
itemCount: number;
|
|
226
|
+
status: number;
|
|
227
|
+
surface: number;
|
|
228
|
+
title: string;
|
|
229
|
+
text: string;
|
|
230
|
+
seller: string;
|
|
231
|
+
token: string;
|
|
232
|
+
amount: number;
|
|
233
|
+
currency: string;
|
|
234
|
+
};
|
|
235
|
+
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
|
236
|
+
productImage: WAMediaUpload;
|
|
237
|
+
};
|
|
238
|
+
export type AlbumMedia = {
|
|
239
|
+
image: WAMediaUpload;
|
|
240
|
+
caption?: string;
|
|
241
|
+
} | {
|
|
242
|
+
video: WAMediaUpload;
|
|
243
|
+
caption?: string;
|
|
244
|
+
gifPlayback?: boolean;
|
|
245
|
+
};
|
|
246
|
+
export type AnyRegularMessageContent = (({
|
|
247
|
+
text: string;
|
|
248
|
+
linkPreview?: WAUrlInfo | null;
|
|
249
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
|
|
250
|
+
poll: PollMessageOptions;
|
|
251
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
|
|
252
|
+
contacts: {
|
|
253
|
+
displayName?: string;
|
|
254
|
+
contacts: proto.Message.IContactMessage[];
|
|
255
|
+
};
|
|
256
|
+
} | {
|
|
257
|
+
location: WALocationMessage;
|
|
258
|
+
} | {
|
|
259
|
+
react: proto.Message.IReactionMessage;
|
|
260
|
+
} | {
|
|
261
|
+
buttonReply: ButtonReplyInfo;
|
|
262
|
+
type: 'template' | 'plain';
|
|
263
|
+
} | {
|
|
264
|
+
groupInvite: GroupInviteInfo;
|
|
265
|
+
} | {
|
|
266
|
+
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
267
|
+
} | {
|
|
268
|
+
pin: WAMessageKey;
|
|
269
|
+
type: proto.PinInChat.Type;
|
|
270
|
+
/**
|
|
271
|
+
* 24 hours, 7 days, 30 days
|
|
272
|
+
*/
|
|
273
|
+
time?: 86400 | 604800 | 2592000;
|
|
274
|
+
} | {
|
|
275
|
+
keep: WAMessageKey;
|
|
276
|
+
type: number;
|
|
277
|
+
/**
|
|
278
|
+
* 24 hours, 7 days, 90 days
|
|
279
|
+
*/
|
|
280
|
+
time?: 86400 | 604800 | 7776000;
|
|
281
|
+
} | {
|
|
282
|
+
paymentInvite: PaymentInviteInfo;
|
|
283
|
+
} | {
|
|
284
|
+
requestPayment: RequestPaymentInfo;
|
|
285
|
+
} | {
|
|
286
|
+
event: EventsInfo;
|
|
287
|
+
} | {
|
|
288
|
+
order: OrderInfo;
|
|
289
|
+
} | {
|
|
290
|
+
call: CallCreationInfo;
|
|
291
|
+
} | {
|
|
292
|
+
inviteAdmin: AdminInviteInfo;
|
|
293
|
+
} | {
|
|
294
|
+
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
295
|
+
} | ({
|
|
296
|
+
product: WASendableProduct;
|
|
297
|
+
businessOwnerJid?: string;
|
|
298
|
+
body?: string;
|
|
299
|
+
footer?: string;
|
|
300
|
+
} & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber | ({
|
|
301
|
+
album: AlbumMedia[];
|
|
302
|
+
caption?: string;
|
|
303
|
+
} & Mentionable & Contextable & Editable)) & ViewOnce;
|
|
304
|
+
export type AnyMessageContent = AnyRegularMessageContent | {
|
|
305
|
+
forward: WAMessage;
|
|
306
|
+
force?: boolean;
|
|
307
|
+
} | {
|
|
308
|
+
/** Delete your message or anyone's message in a group (admin required) */
|
|
309
|
+
delete: WAMessageKey;
|
|
310
|
+
} | {
|
|
311
|
+
disappearingMessagesInChat: boolean | number;
|
|
312
|
+
};
|
|
313
|
+
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
|
|
314
|
+
type MinimalRelayOptions = {
|
|
315
|
+
/** override the message ID with a custom provided string */
|
|
316
|
+
messageId?: string;
|
|
317
|
+
/** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
|
|
318
|
+
useCachedGroupMetadata?: boolean;
|
|
319
|
+
};
|
|
320
|
+
export type MessageRelayOptions = MinimalRelayOptions & {
|
|
321
|
+
/** only send to a specific participant; used when a message decryption fails for a single user */
|
|
322
|
+
participant?: {
|
|
323
|
+
jid: string;
|
|
324
|
+
count: number;
|
|
325
|
+
};
|
|
326
|
+
/** additional attributes to add to the WA binary node */
|
|
327
|
+
additionalAttributes?: {
|
|
328
|
+
[_: string]: string;
|
|
329
|
+
};
|
|
330
|
+
additionalNodes?: BinaryNode[];
|
|
331
|
+
/** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
|
|
332
|
+
useUserDevicesCache?: boolean;
|
|
333
|
+
/** jid list of participants for status@broadcast */
|
|
334
|
+
statusJidList?: string[];
|
|
335
|
+
newsletter?: boolean;
|
|
336
|
+
};
|
|
337
|
+
export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
|
338
|
+
/** optional, if you want to manually set the timestamp of the message */
|
|
339
|
+
timestamp?: Date;
|
|
340
|
+
/** the message you want to quote */
|
|
341
|
+
quoted?: WAMessage;
|
|
342
|
+
/** disappearing messages settings */
|
|
343
|
+
ephemeralExpiration?: number | string;
|
|
344
|
+
/** timeout for media upload to WA server */
|
|
345
|
+
mediaUploadTimeoutMs?: number;
|
|
346
|
+
/** jid list of participants for status@broadcast */
|
|
347
|
+
statusJidList?: string[];
|
|
348
|
+
/** backgroundcolor for status */
|
|
349
|
+
backgroundColor?: string;
|
|
350
|
+
/** font type for status */
|
|
351
|
+
font?: number;
|
|
352
|
+
/** if it is broadcast */
|
|
353
|
+
broadcast?: boolean;
|
|
354
|
+
newsletter?: boolean;
|
|
355
|
+
additionalNodes?: BinaryNode[];
|
|
356
|
+
};
|
|
357
|
+
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
|
358
|
+
userJid: string;
|
|
359
|
+
};
|
|
360
|
+
export type WAMediaUploadFunctionOpts = {
|
|
361
|
+
fileEncSha256B64: string;
|
|
362
|
+
mediaType: MediaType;
|
|
363
|
+
newsletter?: boolean;
|
|
364
|
+
timeoutMs?: number;
|
|
365
|
+
};
|
|
366
|
+
export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMediaUploadFunctionOpts) => Promise<{
|
|
367
|
+
mediaUrl: string;
|
|
368
|
+
directPath: string;
|
|
369
|
+
handle?: string;
|
|
370
|
+
}>;
|
|
371
|
+
export type MediaGenerationOptions = {
|
|
372
|
+
logger?: ILogger;
|
|
373
|
+
mediaTypeOverride?: MediaType;
|
|
374
|
+
upload: WAMediaUploadFunction;
|
|
375
|
+
/** cache media so it does not have to be uploaded again */
|
|
376
|
+
mediaCache?: CacheStore;
|
|
377
|
+
mediaUploadTimeoutMs?: number;
|
|
378
|
+
options?: AxiosRequestConfig;
|
|
379
|
+
backgroundColor?: string;
|
|
380
|
+
font?: number;
|
|
381
|
+
/** The message is for newsletter? */
|
|
382
|
+
newsletter?: boolean;
|
|
383
|
+
};
|
|
384
|
+
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
|
385
|
+
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
|
|
386
|
+
getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
|
|
387
|
+
};
|
|
388
|
+
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
|
|
389
|
+
/**
|
|
390
|
+
* Type of message upsert
|
|
391
|
+
* 1. notify => notify the user, this message was just received
|
|
392
|
+
* 2. append => append the message to the chat history, no notification required
|
|
393
|
+
*/
|
|
394
|
+
export type MessageUpsertType = 'append' | 'notify';
|
|
395
|
+
export type MessageUserReceipt = proto.IUserReceipt;
|
|
396
|
+
export type WAMessageUpdate = {
|
|
397
|
+
update: Partial<WAMessage>;
|
|
398
|
+
key: proto.IMessageKey;
|
|
399
|
+
};
|
|
400
|
+
export type WAMessageCursor = {
|
|
401
|
+
before: WAMessageKey | undefined;
|
|
402
|
+
} | {
|
|
403
|
+
after: WAMessageKey | undefined;
|
|
404
|
+
};
|
|
405
|
+
export type MessageUserReceiptUpdate = {
|
|
406
|
+
key: proto.IMessageKey;
|
|
407
|
+
receipt: MessageUserReceipt;
|
|
408
|
+
};
|
|
409
|
+
export type MediaDecryptionKeyInfo = {
|
|
410
|
+
iv: Buffer;
|
|
411
|
+
cipherKey: Buffer;
|
|
412
|
+
macKey?: Buffer;
|
|
413
|
+
};
|
|
414
414
|
export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;
|