@queenanya/baileys 6.7.0 → 6.8.0
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/WASignalGroup/readme.md +6 -0
- package/lib/Defaults/baileys-version.json +3 -3
- package/lib/Defaults/index.d.ts +284 -284
- package/lib/Defaults/index.js +120 -120
- package/lib/Defaults/phonenumber-mcc.json +223 -223
- package/lib/Signal/libsignal.d.ts +3 -3
- package/lib/Signal/libsignal.js +152 -152
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -17
- package/lib/Socket/Client/abstract-socket-client.js +13 -13
- package/lib/Socket/Client/index.d.ts +3 -3
- package/lib/Socket/Client/index.js +19 -19
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -13
- package/lib/Socket/Client/mobile-socket-client.js +65 -65
- package/lib/Socket/Client/web-socket-client.d.ts +12 -12
- package/lib/Socket/Client/web-socket-client.js +62 -62
- package/lib/Socket/business.d.ts +135 -135
- package/lib/Socket/business.js +259 -259
- package/lib/Socket/chats.d.ts +79 -79
- package/lib/Socket/chats.js +854 -854
- package/lib/Socket/groups.d.ts +113 -113
- package/lib/Socket/groups.js +302 -302
- package/lib/Socket/index.d.ts +137 -137
- package/lib/Socket/index.js +10 -10
- package/lib/Socket/messages-recv.d.ts +124 -124
- package/lib/Socket/messages-recv.js +747 -747
- package/lib/Socket/messages-send.d.ts +119 -119
- package/lib/Socket/messages-send.js +663 -663
- package/lib/Socket/registration.d.ts +232 -232
- package/lib/Socket/registration.js +166 -166
- package/lib/Socket/socket.d.ts +42 -42
- package/lib/Socket/socket.js +588 -588
- package/lib/Store/index.d.ts +3 -3
- package/lib/Store/index.js +10 -10
- package/lib/Store/make-cache-manager-store.d.ts +13 -13
- package/lib/Store/make-cache-manager-store.js +83 -83
- package/lib/Store/make-in-memory-store.d.ts +117 -117
- package/lib/Store/make-in-memory-store.js +437 -437
- package/lib/Store/make-ordered-dictionary.d.ts +13 -13
- package/lib/Store/make-ordered-dictionary.js +81 -81
- package/lib/Store/object-repository.d.ts +10 -10
- package/lib/Store/object-repository.js +27 -27
- package/lib/Types/Auth.d.ts +108 -108
- package/lib/Types/Auth.js +2 -2
- package/lib/Types/Call.d.ts +13 -13
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.d.ts +102 -102
- package/lib/Types/Chat.js +4 -4
- package/lib/Types/Contact.d.ts +19 -19
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.d.ts +157 -157
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.d.ts +52 -52
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.d.ts +35 -35
- package/lib/Types/Label.js +27 -27
- package/lib/Types/LabelAssociation.d.ts +29 -29
- package/lib/Types/LabelAssociation.js +9 -9
- package/lib/Types/Message.d.ts +261 -261
- package/lib/Types/Message.js +9 -9
- package/lib/Types/Product.d.ts +78 -78
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.d.ts +57 -57
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.d.ts +111 -111
- package/lib/Types/Socket.js +2 -2
- package/lib/Types/State.d.ts +27 -27
- package/lib/Types/State.js +2 -2
- package/lib/Types/index.d.ts +56 -56
- package/lib/Types/index.js +41 -41
- package/lib/Utils/auth-utils.d.ts +18 -18
- package/lib/Utils/auth-utils.js +204 -204
- package/lib/Utils/baileys-event-stream.d.ts +16 -16
- package/lib/Utils/baileys-event-stream.js +63 -63
- package/lib/Utils/business.d.ts +22 -22
- package/lib/Utils/business.js +234 -234
- package/lib/Utils/chat-utils.d.ts +71 -71
- package/lib/Utils/chat-utils.js +724 -724
- package/lib/Utils/crypto.d.ts +41 -41
- package/lib/Utils/crypto.js +151 -151
- package/lib/Utils/decode-wa-message.d.ts +19 -19
- package/lib/Utils/decode-wa-message.js +174 -174
- package/lib/Utils/event-buffer.d.ts +35 -35
- package/lib/Utils/event-buffer.js +514 -514
- package/lib/Utils/generics.d.ts +94 -94
- package/lib/Utils/generics.js +367 -367
- package/lib/Utils/history.d.ts +15 -15
- package/lib/Utils/history.js +91 -91
- package/lib/Utils/index.d.ts +17 -17
- package/lib/Utils/index.js +33 -33
- package/lib/Utils/link-preview.d.ts +21 -21
- package/lib/Utils/link-preview.js +93 -93
- package/lib/Utils/logger.d.ts +4 -4
- package/lib/Utils/logger.js +7 -7
- package/lib/Utils/lt-hash.d.ts +12 -12
- package/lib/Utils/lt-hash.js +51 -51
- package/lib/Utils/make-mutex.d.ts +7 -7
- package/lib/Utils/make-mutex.js +43 -43
- package/lib/Utils/messages-media.d.ts +107 -107
- package/lib/Utils/messages-media.js +680 -680
- package/lib/Utils/messages.d.ts +76 -76
- package/lib/Utils/messages.js +768 -768
- package/lib/Utils/noise-handler.d.ts +20 -20
- package/lib/Utils/noise-handler.js +142 -142
- package/lib/Utils/process-message.d.ts +41 -41
- package/lib/Utils/process-message.js +320 -320
- package/lib/Utils/signal.d.ts +32 -32
- package/lib/Utils/signal.js +151 -151
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -12
- package/lib/Utils/use-multi-file-auth-state.js +80 -80
- package/lib/Utils/validate-connection.d.ts +11 -11
- package/lib/Utils/validate-connection.js +191 -222
- package/lib/WABinary/constants.d.ts +27 -27
- package/lib/WABinary/constants.js +40 -40
- package/lib/WABinary/decode.d.ts +7 -7
- package/lib/WABinary/decode.js +252 -252
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.js +228 -228
- package/lib/WABinary/generic-utils.d.ts +15 -15
- package/lib/WABinary/generic-utils.js +110 -110
- package/lib/WABinary/index.d.ts +5 -5
- package/lib/WABinary/index.js +21 -21
- package/lib/WABinary/jid-utils.d.ts +29 -29
- package/lib/WABinary/jid-utils.js +59 -59
- package/lib/WABinary/types.d.ts +18 -18
- package/lib/WABinary/types.js +2 -2
- package/lib/index.d.ts +10 -10
- package/lib/index.js +29 -29
- package/package.json +1 -1
- package/CHANGELOG.md +0 -4
package/lib/Types/Message.d.ts
CHANGED
|
@@ -1,261 +1,261 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
import { AxiosRequestConfig } from 'axios';
|
|
5
|
-
import type { Logger } from 'pino';
|
|
6
|
-
import type { Readable } from 'stream';
|
|
7
|
-
import type { URL } from 'url';
|
|
8
|
-
import { proto } from '../../WAProto';
|
|
9
|
-
import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
|
|
10
|
-
import type { GroupMetadata } from './GroupMetadata';
|
|
11
|
-
import { CacheStore } from './Socket';
|
|
12
|
-
export { proto as WAProto };
|
|
13
|
-
export type WAMessage = proto.IWebMessageInfo;
|
|
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
|
-
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
|
19
|
-
export type WAContextInfo = proto.IContextInfo;
|
|
20
|
-
export type WALocationMessage = proto.Message.ILocationMessage;
|
|
21
|
-
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
22
|
-
export import WAMessageStubType = proto.WebMessageInfo.StubType;
|
|
23
|
-
export import WAMessageStatus = proto.WebMessageInfo.Status;
|
|
24
|
-
export type WAMediaUpload = Buffer | {
|
|
25
|
-
url: URL | string;
|
|
26
|
-
} | {
|
|
27
|
-
stream: Readable;
|
|
28
|
-
};
|
|
29
|
-
/** Set of message types that are supported by the library */
|
|
30
|
-
export type MessageType = keyof proto.Message;
|
|
31
|
-
export type DownloadableMessage = {
|
|
32
|
-
mediaKey?: Uint8Array | null;
|
|
33
|
-
directPath?: string | null;
|
|
34
|
-
url?: string | null;
|
|
35
|
-
};
|
|
36
|
-
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
|
|
37
|
-
export type MediaConnInfo = {
|
|
38
|
-
auth: string;
|
|
39
|
-
ttl: number;
|
|
40
|
-
hosts: {
|
|
41
|
-
hostname: string;
|
|
42
|
-
maxContentLengthBytes: number;
|
|
43
|
-
}[];
|
|
44
|
-
fetchDate: Date;
|
|
45
|
-
};
|
|
46
|
-
export interface WAUrlInfo {
|
|
47
|
-
'canonical-url': string;
|
|
48
|
-
'matched-text': string;
|
|
49
|
-
title: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
jpegThumbnail?: Buffer;
|
|
52
|
-
highQualityThumbnail?: proto.Message.IImageMessage;
|
|
53
|
-
originalThumbnailUrl?: string;
|
|
54
|
-
}
|
|
55
|
-
type Mentionable = {
|
|
56
|
-
/** list of jids that are mentioned in the accompanying text */
|
|
57
|
-
mentions?: string[];
|
|
58
|
-
};
|
|
59
|
-
type Contextable = {
|
|
60
|
-
/** add contextInfo to the message */
|
|
61
|
-
contextInfo?: proto.IContextInfo;
|
|
62
|
-
};
|
|
63
|
-
type ViewOnce = {
|
|
64
|
-
viewOnce?: boolean;
|
|
65
|
-
};
|
|
66
|
-
type Buttonable = {
|
|
67
|
-
/** add buttons to the message */
|
|
68
|
-
buttons?: proto.Message.ButtonsMessage.IButton[];
|
|
69
|
-
};
|
|
70
|
-
type Templatable = {
|
|
71
|
-
/** add buttons to the message (conflicts with normal buttons)*/
|
|
72
|
-
templateButtons?: proto.IHydratedTemplateButton[];
|
|
73
|
-
footer?: string;
|
|
74
|
-
};
|
|
75
|
-
type Editable = {
|
|
76
|
-
edit?: WAMessageKey;
|
|
77
|
-
};
|
|
78
|
-
type Listable = {
|
|
79
|
-
/** Sections of the List */
|
|
80
|
-
sections?: proto.Message.ListMessage.ISection[];
|
|
81
|
-
/** Title of a List Message only */
|
|
82
|
-
title?: string;
|
|
83
|
-
/** Text of the bnutton on the list (required) */
|
|
84
|
-
buttonText?: string;
|
|
85
|
-
};
|
|
86
|
-
type WithDimensions = {
|
|
87
|
-
width?: number;
|
|
88
|
-
height?: number;
|
|
89
|
-
};
|
|
90
|
-
export type PollMessageOptions = {
|
|
91
|
-
name: string;
|
|
92
|
-
selectableCount?: number;
|
|
93
|
-
values: string[];
|
|
94
|
-
/** 32 byte message secret to encrypt poll selections */
|
|
95
|
-
messageSecret?: Uint8Array;
|
|
96
|
-
};
|
|
97
|
-
type SharePhoneNumber = {
|
|
98
|
-
sharePhoneNumber: boolean;
|
|
99
|
-
};
|
|
100
|
-
type RequestPhoneNumber = {
|
|
101
|
-
requestPhoneNumber: boolean;
|
|
102
|
-
};
|
|
103
|
-
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
|
|
104
|
-
export type AnyMediaMessageContent = (({
|
|
105
|
-
image: WAMediaUpload;
|
|
106
|
-
caption?: string;
|
|
107
|
-
jpegThumbnail?: string;
|
|
108
|
-
} & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
|
|
109
|
-
video: WAMediaUpload;
|
|
110
|
-
caption?: string;
|
|
111
|
-
gifPlayback?: boolean;
|
|
112
|
-
jpegThumbnail?: string;
|
|
113
|
-
} & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
|
|
114
|
-
audio: WAMediaUpload;
|
|
115
|
-
/** if set to true, will send as a `voice note` */
|
|
116
|
-
ptt?: boolean;
|
|
117
|
-
/** optionally tell the duration of the audio */
|
|
118
|
-
seconds?: number;
|
|
119
|
-
} | ({
|
|
120
|
-
sticker: WAMediaUpload;
|
|
121
|
-
isAnimated?: boolean;
|
|
122
|
-
} & WithDimensions) | ({
|
|
123
|
-
document: WAMediaUpload;
|
|
124
|
-
mimetype: string;
|
|
125
|
-
fileName?: string;
|
|
126
|
-
caption?: string;
|
|
127
|
-
} & Contextable & Buttonable & Templatable)) & {
|
|
128
|
-
mimetype?: string;
|
|
129
|
-
} & Editable;
|
|
130
|
-
export type ButtonReplyInfo = {
|
|
131
|
-
displayText: string;
|
|
132
|
-
id: string;
|
|
133
|
-
index: number;
|
|
134
|
-
};
|
|
135
|
-
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
|
136
|
-
productImage: WAMediaUpload;
|
|
137
|
-
};
|
|
138
|
-
export type AnyRegularMessageContent = (({
|
|
139
|
-
text: string;
|
|
140
|
-
linkPreview?: WAUrlInfo | null;
|
|
141
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
|
|
142
|
-
poll: PollMessageOptions;
|
|
143
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
|
|
144
|
-
contacts: {
|
|
145
|
-
displayName?: string;
|
|
146
|
-
contacts: proto.Message.IContactMessage[];
|
|
147
|
-
};
|
|
148
|
-
} | {
|
|
149
|
-
location: WALocationMessage;
|
|
150
|
-
} | {
|
|
151
|
-
react: proto.Message.IReactionMessage;
|
|
152
|
-
} | {
|
|
153
|
-
buttonReply: ButtonReplyInfo;
|
|
154
|
-
type: 'template' | 'plain';
|
|
155
|
-
} | {
|
|
156
|
-
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
157
|
-
} | {
|
|
158
|
-
product: WASendableProduct;
|
|
159
|
-
businessOwnerJid?: string;
|
|
160
|
-
body?: string;
|
|
161
|
-
footer?: string;
|
|
162
|
-
} | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
|
|
163
|
-
export type AnyMessageContent = AnyRegularMessageContent | {
|
|
164
|
-
forward: WAMessage;
|
|
165
|
-
force?: boolean;
|
|
166
|
-
} | {
|
|
167
|
-
/** Delete your message or anyone's message in a group (admin required) */
|
|
168
|
-
delete: WAMessageKey;
|
|
169
|
-
} | {
|
|
170
|
-
disappearingMessagesInChat: boolean | number;
|
|
171
|
-
};
|
|
172
|
-
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
|
|
173
|
-
type MinimalRelayOptions = {
|
|
174
|
-
/** override the message ID with a custom provided string */
|
|
175
|
-
messageId?: string;
|
|
176
|
-
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
|
177
|
-
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>;
|
|
178
|
-
};
|
|
179
|
-
export type MessageRelayOptions = MinimalRelayOptions & {
|
|
180
|
-
/** only send to a specific participant; used when a message decryption fails for a single user */
|
|
181
|
-
participant?: {
|
|
182
|
-
jid: string;
|
|
183
|
-
count: number;
|
|
184
|
-
};
|
|
185
|
-
/** additional attributes to add to the WA binary node */
|
|
186
|
-
additionalAttributes?: {
|
|
187
|
-
[_: string]: string;
|
|
188
|
-
};
|
|
189
|
-
/** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
|
|
190
|
-
useUserDevicesCache?: boolean;
|
|
191
|
-
/** jid list of participants for status@broadcast */
|
|
192
|
-
statusJidList?: string[];
|
|
193
|
-
};
|
|
194
|
-
export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
|
195
|
-
/** optional, if you want to manually set the timestamp of the message */
|
|
196
|
-
timestamp?: Date;
|
|
197
|
-
/** the message you want to quote */
|
|
198
|
-
quoted?: WAMessage;
|
|
199
|
-
/** disappearing messages settings */
|
|
200
|
-
ephemeralExpiration?: number | string;
|
|
201
|
-
/** timeout for media upload to WA server */
|
|
202
|
-
mediaUploadTimeoutMs?: number;
|
|
203
|
-
/** jid list of participants for status@broadcast */
|
|
204
|
-
statusJidList?: string[];
|
|
205
|
-
/** backgroundcolor for status */
|
|
206
|
-
backgroundColor?: string;
|
|
207
|
-
/** font type for status */
|
|
208
|
-
font?: number;
|
|
209
|
-
};
|
|
210
|
-
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
|
211
|
-
userJid: string;
|
|
212
|
-
};
|
|
213
|
-
export type WAMediaUploadFunction = (readStream: Readable, opts: {
|
|
214
|
-
fileEncSha256B64: string;
|
|
215
|
-
mediaType: MediaType;
|
|
216
|
-
timeoutMs?: number;
|
|
217
|
-
}) => Promise<{
|
|
218
|
-
mediaUrl: string;
|
|
219
|
-
directPath: string;
|
|
220
|
-
}>;
|
|
221
|
-
export type MediaGenerationOptions = {
|
|
222
|
-
logger?: Logger;
|
|
223
|
-
mediaTypeOverride?: MediaType;
|
|
224
|
-
upload: WAMediaUploadFunction;
|
|
225
|
-
/** cache media so it does not have to be uploaded again */
|
|
226
|
-
mediaCache?: CacheStore;
|
|
227
|
-
mediaUploadTimeoutMs?: number;
|
|
228
|
-
options?: AxiosRequestConfig;
|
|
229
|
-
backgroundColor?: string;
|
|
230
|
-
font?: number;
|
|
231
|
-
};
|
|
232
|
-
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
|
233
|
-
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
|
|
234
|
-
};
|
|
235
|
-
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
|
|
236
|
-
/**
|
|
237
|
-
* Type of message upsert
|
|
238
|
-
* 1. notify => notify the user, this message was just received
|
|
239
|
-
* 2. append => append the message to the chat history, no notification required
|
|
240
|
-
*/
|
|
241
|
-
export type MessageUpsertType = 'append' | 'notify';
|
|
242
|
-
export type MessageUserReceipt = proto.IUserReceipt;
|
|
243
|
-
export type WAMessageUpdate = {
|
|
244
|
-
update: Partial<WAMessage>;
|
|
245
|
-
key: proto.IMessageKey;
|
|
246
|
-
};
|
|
247
|
-
export type WAMessageCursor = {
|
|
248
|
-
before: WAMessageKey | undefined;
|
|
249
|
-
} | {
|
|
250
|
-
after: WAMessageKey | undefined;
|
|
251
|
-
};
|
|
252
|
-
export type MessageUserReceiptUpdate = {
|
|
253
|
-
key: proto.IMessageKey;
|
|
254
|
-
receipt: MessageUserReceipt;
|
|
255
|
-
};
|
|
256
|
-
export type MediaDecryptionKeyInfo = {
|
|
257
|
-
iv: Buffer;
|
|
258
|
-
cipherKey: Buffer;
|
|
259
|
-
macKey?: Buffer;
|
|
260
|
-
};
|
|
261
|
-
export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import { AxiosRequestConfig } from 'axios';
|
|
5
|
+
import type { Logger } from 'pino';
|
|
6
|
+
import type { Readable } from 'stream';
|
|
7
|
+
import type { URL } from 'url';
|
|
8
|
+
import { proto } from '../../WAProto';
|
|
9
|
+
import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
|
|
10
|
+
import type { GroupMetadata } from './GroupMetadata';
|
|
11
|
+
import { CacheStore } from './Socket';
|
|
12
|
+
export { proto as WAProto };
|
|
13
|
+
export type WAMessage = proto.IWebMessageInfo;
|
|
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
|
+
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
|
19
|
+
export type WAContextInfo = proto.IContextInfo;
|
|
20
|
+
export type WALocationMessage = proto.Message.ILocationMessage;
|
|
21
|
+
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
22
|
+
export import WAMessageStubType = proto.WebMessageInfo.StubType;
|
|
23
|
+
export import WAMessageStatus = proto.WebMessageInfo.Status;
|
|
24
|
+
export type WAMediaUpload = Buffer | {
|
|
25
|
+
url: URL | string;
|
|
26
|
+
} | {
|
|
27
|
+
stream: Readable;
|
|
28
|
+
};
|
|
29
|
+
/** Set of message types that are supported by the library */
|
|
30
|
+
export type MessageType = keyof proto.Message;
|
|
31
|
+
export type DownloadableMessage = {
|
|
32
|
+
mediaKey?: Uint8Array | null;
|
|
33
|
+
directPath?: string | null;
|
|
34
|
+
url?: string | null;
|
|
35
|
+
};
|
|
36
|
+
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
|
|
37
|
+
export type MediaConnInfo = {
|
|
38
|
+
auth: string;
|
|
39
|
+
ttl: number;
|
|
40
|
+
hosts: {
|
|
41
|
+
hostname: string;
|
|
42
|
+
maxContentLengthBytes: number;
|
|
43
|
+
}[];
|
|
44
|
+
fetchDate: Date;
|
|
45
|
+
};
|
|
46
|
+
export interface WAUrlInfo {
|
|
47
|
+
'canonical-url': string;
|
|
48
|
+
'matched-text': string;
|
|
49
|
+
title: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
jpegThumbnail?: Buffer;
|
|
52
|
+
highQualityThumbnail?: proto.Message.IImageMessage;
|
|
53
|
+
originalThumbnailUrl?: string;
|
|
54
|
+
}
|
|
55
|
+
type Mentionable = {
|
|
56
|
+
/** list of jids that are mentioned in the accompanying text */
|
|
57
|
+
mentions?: string[];
|
|
58
|
+
};
|
|
59
|
+
type Contextable = {
|
|
60
|
+
/** add contextInfo to the message */
|
|
61
|
+
contextInfo?: proto.IContextInfo;
|
|
62
|
+
};
|
|
63
|
+
type ViewOnce = {
|
|
64
|
+
viewOnce?: boolean;
|
|
65
|
+
};
|
|
66
|
+
type Buttonable = {
|
|
67
|
+
/** add buttons to the message */
|
|
68
|
+
buttons?: proto.Message.ButtonsMessage.IButton[];
|
|
69
|
+
};
|
|
70
|
+
type Templatable = {
|
|
71
|
+
/** add buttons to the message (conflicts with normal buttons)*/
|
|
72
|
+
templateButtons?: proto.IHydratedTemplateButton[];
|
|
73
|
+
footer?: string;
|
|
74
|
+
};
|
|
75
|
+
type Editable = {
|
|
76
|
+
edit?: WAMessageKey;
|
|
77
|
+
};
|
|
78
|
+
type Listable = {
|
|
79
|
+
/** Sections of the List */
|
|
80
|
+
sections?: proto.Message.ListMessage.ISection[];
|
|
81
|
+
/** Title of a List Message only */
|
|
82
|
+
title?: string;
|
|
83
|
+
/** Text of the bnutton on the list (required) */
|
|
84
|
+
buttonText?: string;
|
|
85
|
+
};
|
|
86
|
+
type WithDimensions = {
|
|
87
|
+
width?: number;
|
|
88
|
+
height?: number;
|
|
89
|
+
};
|
|
90
|
+
export type PollMessageOptions = {
|
|
91
|
+
name: string;
|
|
92
|
+
selectableCount?: number;
|
|
93
|
+
values: string[];
|
|
94
|
+
/** 32 byte message secret to encrypt poll selections */
|
|
95
|
+
messageSecret?: Uint8Array;
|
|
96
|
+
};
|
|
97
|
+
type SharePhoneNumber = {
|
|
98
|
+
sharePhoneNumber: boolean;
|
|
99
|
+
};
|
|
100
|
+
type RequestPhoneNumber = {
|
|
101
|
+
requestPhoneNumber: boolean;
|
|
102
|
+
};
|
|
103
|
+
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
|
|
104
|
+
export type AnyMediaMessageContent = (({
|
|
105
|
+
image: WAMediaUpload;
|
|
106
|
+
caption?: string;
|
|
107
|
+
jpegThumbnail?: string;
|
|
108
|
+
} & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
|
|
109
|
+
video: WAMediaUpload;
|
|
110
|
+
caption?: string;
|
|
111
|
+
gifPlayback?: boolean;
|
|
112
|
+
jpegThumbnail?: string;
|
|
113
|
+
} & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
|
|
114
|
+
audio: WAMediaUpload;
|
|
115
|
+
/** if set to true, will send as a `voice note` */
|
|
116
|
+
ptt?: boolean;
|
|
117
|
+
/** optionally tell the duration of the audio */
|
|
118
|
+
seconds?: number;
|
|
119
|
+
} | ({
|
|
120
|
+
sticker: WAMediaUpload;
|
|
121
|
+
isAnimated?: boolean;
|
|
122
|
+
} & WithDimensions) | ({
|
|
123
|
+
document: WAMediaUpload;
|
|
124
|
+
mimetype: string;
|
|
125
|
+
fileName?: string;
|
|
126
|
+
caption?: string;
|
|
127
|
+
} & Contextable & Buttonable & Templatable)) & {
|
|
128
|
+
mimetype?: string;
|
|
129
|
+
} & Editable;
|
|
130
|
+
export type ButtonReplyInfo = {
|
|
131
|
+
displayText: string;
|
|
132
|
+
id: string;
|
|
133
|
+
index: number;
|
|
134
|
+
};
|
|
135
|
+
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
|
136
|
+
productImage: WAMediaUpload;
|
|
137
|
+
};
|
|
138
|
+
export type AnyRegularMessageContent = (({
|
|
139
|
+
text: string;
|
|
140
|
+
linkPreview?: WAUrlInfo | null;
|
|
141
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
|
|
142
|
+
poll: PollMessageOptions;
|
|
143
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
|
|
144
|
+
contacts: {
|
|
145
|
+
displayName?: string;
|
|
146
|
+
contacts: proto.Message.IContactMessage[];
|
|
147
|
+
};
|
|
148
|
+
} | {
|
|
149
|
+
location: WALocationMessage;
|
|
150
|
+
} | {
|
|
151
|
+
react: proto.Message.IReactionMessage;
|
|
152
|
+
} | {
|
|
153
|
+
buttonReply: ButtonReplyInfo;
|
|
154
|
+
type: 'template' | 'plain';
|
|
155
|
+
} | {
|
|
156
|
+
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
157
|
+
} | {
|
|
158
|
+
product: WASendableProduct;
|
|
159
|
+
businessOwnerJid?: string;
|
|
160
|
+
body?: string;
|
|
161
|
+
footer?: string;
|
|
162
|
+
} | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
|
|
163
|
+
export type AnyMessageContent = AnyRegularMessageContent | {
|
|
164
|
+
forward: WAMessage;
|
|
165
|
+
force?: boolean;
|
|
166
|
+
} | {
|
|
167
|
+
/** Delete your message or anyone's message in a group (admin required) */
|
|
168
|
+
delete: WAMessageKey;
|
|
169
|
+
} | {
|
|
170
|
+
disappearingMessagesInChat: boolean | number;
|
|
171
|
+
};
|
|
172
|
+
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
|
|
173
|
+
type MinimalRelayOptions = {
|
|
174
|
+
/** override the message ID with a custom provided string */
|
|
175
|
+
messageId?: string;
|
|
176
|
+
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
|
177
|
+
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>;
|
|
178
|
+
};
|
|
179
|
+
export type MessageRelayOptions = MinimalRelayOptions & {
|
|
180
|
+
/** only send to a specific participant; used when a message decryption fails for a single user */
|
|
181
|
+
participant?: {
|
|
182
|
+
jid: string;
|
|
183
|
+
count: number;
|
|
184
|
+
};
|
|
185
|
+
/** additional attributes to add to the WA binary node */
|
|
186
|
+
additionalAttributes?: {
|
|
187
|
+
[_: string]: string;
|
|
188
|
+
};
|
|
189
|
+
/** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
|
|
190
|
+
useUserDevicesCache?: boolean;
|
|
191
|
+
/** jid list of participants for status@broadcast */
|
|
192
|
+
statusJidList?: string[];
|
|
193
|
+
};
|
|
194
|
+
export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
|
195
|
+
/** optional, if you want to manually set the timestamp of the message */
|
|
196
|
+
timestamp?: Date;
|
|
197
|
+
/** the message you want to quote */
|
|
198
|
+
quoted?: WAMessage;
|
|
199
|
+
/** disappearing messages settings */
|
|
200
|
+
ephemeralExpiration?: number | string;
|
|
201
|
+
/** timeout for media upload to WA server */
|
|
202
|
+
mediaUploadTimeoutMs?: number;
|
|
203
|
+
/** jid list of participants for status@broadcast */
|
|
204
|
+
statusJidList?: string[];
|
|
205
|
+
/** backgroundcolor for status */
|
|
206
|
+
backgroundColor?: string;
|
|
207
|
+
/** font type for status */
|
|
208
|
+
font?: number;
|
|
209
|
+
};
|
|
210
|
+
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
|
211
|
+
userJid: string;
|
|
212
|
+
};
|
|
213
|
+
export type WAMediaUploadFunction = (readStream: Readable, opts: {
|
|
214
|
+
fileEncSha256B64: string;
|
|
215
|
+
mediaType: MediaType;
|
|
216
|
+
timeoutMs?: number;
|
|
217
|
+
}) => Promise<{
|
|
218
|
+
mediaUrl: string;
|
|
219
|
+
directPath: string;
|
|
220
|
+
}>;
|
|
221
|
+
export type MediaGenerationOptions = {
|
|
222
|
+
logger?: Logger;
|
|
223
|
+
mediaTypeOverride?: MediaType;
|
|
224
|
+
upload: WAMediaUploadFunction;
|
|
225
|
+
/** cache media so it does not have to be uploaded again */
|
|
226
|
+
mediaCache?: CacheStore;
|
|
227
|
+
mediaUploadTimeoutMs?: number;
|
|
228
|
+
options?: AxiosRequestConfig;
|
|
229
|
+
backgroundColor?: string;
|
|
230
|
+
font?: number;
|
|
231
|
+
};
|
|
232
|
+
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
|
233
|
+
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
|
|
234
|
+
};
|
|
235
|
+
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
|
|
236
|
+
/**
|
|
237
|
+
* Type of message upsert
|
|
238
|
+
* 1. notify => notify the user, this message was just received
|
|
239
|
+
* 2. append => append the message to the chat history, no notification required
|
|
240
|
+
*/
|
|
241
|
+
export type MessageUpsertType = 'append' | 'notify';
|
|
242
|
+
export type MessageUserReceipt = proto.IUserReceipt;
|
|
243
|
+
export type WAMessageUpdate = {
|
|
244
|
+
update: Partial<WAMessage>;
|
|
245
|
+
key: proto.IMessageKey;
|
|
246
|
+
};
|
|
247
|
+
export type WAMessageCursor = {
|
|
248
|
+
before: WAMessageKey | undefined;
|
|
249
|
+
} | {
|
|
250
|
+
after: WAMessageKey | undefined;
|
|
251
|
+
};
|
|
252
|
+
export type MessageUserReceiptUpdate = {
|
|
253
|
+
key: proto.IMessageKey;
|
|
254
|
+
receipt: MessageUserReceipt;
|
|
255
|
+
};
|
|
256
|
+
export type MediaDecryptionKeyInfo = {
|
|
257
|
+
iv: Buffer;
|
|
258
|
+
cipherKey: Buffer;
|
|
259
|
+
macKey?: Buffer;
|
|
260
|
+
};
|
|
261
|
+
export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;
|
package/lib/Types/Message.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WAMessageStatus = exports.WAMessageStubType = exports.WAProto = void 0;
|
|
4
|
-
const WAProto_1 = require("../../WAProto");
|
|
5
|
-
Object.defineProperty(exports, "WAProto", { enumerable: true, get: function () { return WAProto_1.proto; } });
|
|
6
|
-
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
7
|
-
exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
|
|
8
|
-
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
9
|
-
exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WAMessageStatus = exports.WAMessageStubType = exports.WAProto = void 0;
|
|
4
|
+
const WAProto_1 = require("../../WAProto");
|
|
5
|
+
Object.defineProperty(exports, "WAProto", { enumerable: true, get: function () { return WAProto_1.proto; } });
|
|
6
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
7
|
+
exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
|
|
8
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
9
|
+
exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
|