@d0v3riz/baileys 6.7.12 → 6.7.17

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 (161) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +35 -1267
  3. package/WAProto/index.d.ts +16106 -2739
  4. package/WAProto/index.js +128593 -73944
  5. package/engine-requirements.js +10 -0
  6. package/lib/Defaults/baileys-version.json +3 -3
  7. package/lib/Defaults/index.d.ts +51 -53
  8. package/lib/Defaults/index.js +105 -106
  9. package/lib/Signal/libsignal.d.ts +3 -3
  10. package/lib/Signal/libsignal.js +161 -152
  11. package/lib/Socket/Client/index.d.ts +2 -2
  12. package/lib/Socket/Client/index.js +18 -18
  13. package/lib/Socket/Client/types.d.ts +15 -17
  14. package/lib/Socket/Client/types.js +13 -13
  15. package/lib/Socket/Client/websocket.d.ts +12 -12
  16. package/lib/Socket/Client/websocket.js +62 -62
  17. package/lib/Socket/business.d.ts +146 -148
  18. package/lib/Socket/business.js +260 -260
  19. package/lib/Socket/chats.d.ts +85 -84
  20. package/lib/Socket/chats.js +880 -846
  21. package/lib/Socket/groups.d.ts +124 -123
  22. package/lib/Socket/groups.js +314 -314
  23. package/lib/Socket/index.d.ts +146 -148
  24. package/lib/Socket/index.js +10 -10
  25. package/lib/Socket/messages-recv.d.ts +135 -135
  26. package/lib/Socket/messages-recv.js +920 -913
  27. package/lib/Socket/messages-send.d.ts +130 -129
  28. package/lib/Socket/messages-send.js +683 -673
  29. package/lib/Socket/socket.d.ts +42 -45
  30. package/lib/Socket/socket.js +622 -622
  31. package/lib/Socket/usync.d.ts +36 -38
  32. package/lib/Socket/usync.js +70 -70
  33. package/lib/Types/Auth.d.ts +103 -105
  34. package/lib/Types/Auth.js +2 -2
  35. package/lib/Types/Call.d.ts +13 -13
  36. package/lib/Types/Call.js +2 -2
  37. package/lib/Types/Chat.d.ts +112 -107
  38. package/lib/Types/Chat.js +4 -4
  39. package/lib/Types/Contact.d.ts +19 -19
  40. package/lib/Types/Contact.js +2 -2
  41. package/lib/Types/Events.d.ts +172 -172
  42. package/lib/Types/Events.js +2 -2
  43. package/lib/Types/GroupMetadata.d.ts +56 -56
  44. package/lib/Types/GroupMetadata.js +2 -2
  45. package/lib/Types/Label.d.ts +46 -46
  46. package/lib/Types/Label.js +27 -27
  47. package/lib/Types/LabelAssociation.d.ts +29 -29
  48. package/lib/Types/LabelAssociation.js +9 -9
  49. package/lib/Types/Message.d.ts +269 -273
  50. package/lib/Types/Message.js +7 -9
  51. package/lib/Types/Product.d.ts +78 -78
  52. package/lib/Types/Product.js +2 -2
  53. package/lib/Types/Signal.d.ts +57 -57
  54. package/lib/Types/Signal.js +2 -2
  55. package/lib/Types/Socket.d.ts +121 -118
  56. package/lib/Types/Socket.js +2 -2
  57. package/lib/Types/State.d.ts +27 -27
  58. package/lib/Types/State.js +2 -2
  59. package/lib/Types/USync.d.ts +25 -25
  60. package/lib/Types/USync.js +2 -2
  61. package/lib/Types/index.d.ts +63 -63
  62. package/lib/Types/index.js +41 -41
  63. package/lib/Utils/auth-utils.d.ts +18 -18
  64. package/lib/Utils/auth-utils.js +200 -200
  65. package/lib/Utils/baileys-event-stream.d.ts +16 -16
  66. package/lib/Utils/baileys-event-stream.js +63 -63
  67. package/lib/Utils/business.d.ts +22 -22
  68. package/lib/Utils/business.js +234 -234
  69. package/lib/Utils/chat-utils.d.ts +70 -72
  70. package/lib/Utils/chat-utils.js +745 -745
  71. package/lib/Utils/crypto.d.ts +40 -42
  72. package/lib/Utils/crypto.js +193 -153
  73. package/lib/Utils/decode-wa-message.d.ts +36 -36
  74. package/lib/Utils/decode-wa-message.js +205 -205
  75. package/lib/Utils/event-buffer.d.ts +35 -35
  76. package/lib/Utils/event-buffer.js +520 -520
  77. package/lib/Utils/generics.d.ts +90 -94
  78. package/lib/Utils/generics.js +398 -421
  79. package/lib/Utils/history.d.ts +19 -19
  80. package/lib/Utils/history.js +94 -94
  81. package/lib/Utils/index.d.ts +17 -17
  82. package/lib/Utils/index.js +33 -33
  83. package/lib/Utils/link-preview.d.ts +21 -21
  84. package/lib/Utils/link-preview.js +126 -116
  85. package/lib/Utils/logger.d.ts +11 -4
  86. package/lib/Utils/logger.js +7 -7
  87. package/lib/Utils/lt-hash.d.ts +12 -12
  88. package/lib/Utils/lt-hash.js +51 -51
  89. package/lib/Utils/make-mutex.d.ts +7 -7
  90. package/lib/Utils/make-mutex.js +44 -44
  91. package/lib/Utils/messages-media.d.ts +104 -108
  92. package/lib/Utils/messages-media.js +677 -667
  93. package/lib/Utils/messages.d.ts +75 -78
  94. package/lib/Utils/messages.js +765 -762
  95. package/lib/Utils/noise-handler.d.ts +19 -21
  96. package/lib/Utils/noise-handler.js +150 -150
  97. package/lib/Utils/process-message.d.ts +41 -42
  98. package/lib/Utils/process-message.js +382 -371
  99. package/lib/Utils/signal.d.ts +33 -33
  100. package/lib/Utils/signal.js +153 -153
  101. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -12
  102. package/lib/Utils/use-multi-file-auth-state.js +125 -94
  103. package/lib/Utils/validate-connection.d.ts +10 -10
  104. package/lib/Utils/validate-connection.js +175 -175
  105. package/lib/WABinary/constants.d.ts +27 -27
  106. package/lib/WABinary/constants.js +40 -40
  107. package/lib/WABinary/decode.d.ts +6 -8
  108. package/lib/WABinary/decode.js +264 -254
  109. package/lib/WABinary/encode.d.ts +2 -4
  110. package/lib/WABinary/encode.js +252 -234
  111. package/lib/WABinary/generic-utils.d.ts +14 -16
  112. package/lib/WABinary/generic-utils.js +110 -110
  113. package/lib/WABinary/index.d.ts +5 -5
  114. package/lib/WABinary/index.js +21 -21
  115. package/lib/WABinary/jid-utils.d.ts +33 -31
  116. package/lib/WABinary/jid-utils.js +66 -62
  117. package/lib/WABinary/types.d.ts +18 -18
  118. package/lib/WABinary/types.js +2 -2
  119. package/lib/WAM/BinaryInfo.d.ts +8 -18
  120. package/lib/WAM/BinaryInfo.js +13 -13
  121. package/lib/WAM/constants.d.ts +39 -39
  122. package/lib/WAM/constants.js +15350 -15350
  123. package/lib/WAM/encode.d.ts +2 -4
  124. package/lib/WAM/encode.js +155 -155
  125. package/lib/WAM/index.d.ts +3 -3
  126. package/lib/WAM/index.js +19 -19
  127. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
  128. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -32
  129. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -22
  130. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -57
  131. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -12
  132. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -30
  133. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -12
  134. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -42
  135. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  136. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  137. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  138. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  139. package/lib/WAUSync/Protocols/index.d.ts +4 -4
  140. package/lib/WAUSync/Protocols/index.js +20 -20
  141. package/lib/WAUSync/USyncQuery.d.ts +28 -26
  142. package/lib/WAUSync/USyncQuery.js +89 -79
  143. package/lib/WAUSync/USyncUser.d.ts +12 -10
  144. package/lib/WAUSync/USyncUser.js +26 -22
  145. package/lib/WAUSync/index.d.ts +3 -3
  146. package/lib/WAUSync/index.js +19 -19
  147. package/lib/index.d.ts +11 -12
  148. package/lib/index.js +30 -31
  149. package/package.json +27 -35
  150. package/WAProto/GenerateStatics.sh +0 -4
  151. package/WAProto/WAProto.proto +0 -3344
  152. package/lib/Store/index.d.ts +0 -3
  153. package/lib/Store/index.js +0 -10
  154. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  155. package/lib/Store/make-cache-manager-store.js +0 -83
  156. package/lib/Store/make-in-memory-store.d.ts +0 -118
  157. package/lib/Store/make-in-memory-store.js +0 -420
  158. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  159. package/lib/Store/make-ordered-dictionary.js +0 -81
  160. package/lib/Store/object-repository.d.ts +0 -10
  161. package/lib/Store/object-repository.js +0 -27
@@ -1,273 +1,269 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- import { AxiosRequestConfig } from 'axios';
6
- import type { Logger } from 'pino';
7
- import type { Readable } from 'stream';
8
- import type { URL } from 'url';
9
- import { proto } from '../../WAProto';
10
- import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
11
- import { BinaryNode } from '../WABinary';
12
- import type { GroupMetadata } from './GroupMetadata';
13
- import { CacheStore } from './Socket';
14
- export { proto as WAProto };
15
- export type WAMessage = proto.IWebMessageInfo;
16
- export type WAMessageContent = proto.IMessage;
17
- export type WAContactMessage = proto.Message.IContactMessage;
18
- export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
19
- export type WAMessageKey = proto.IMessageKey;
20
- export type WATextMessage = proto.Message.IExtendedTextMessage;
21
- export type WAContextInfo = proto.IContextInfo;
22
- export type WALocationMessage = proto.Message.ILocationMessage;
23
- export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
24
- export import WAMessageStubType = proto.WebMessageInfo.StubType;
25
- export import WAMessageStatus = proto.WebMessageInfo.Status;
26
- export type WAMediaPayloadURL = {
27
- url: URL | string;
28
- };
29
- export type WAMediaPayloadStream = {
30
- stream: Readable;
31
- };
32
- export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
33
- /** Set of message types that are supported by the library */
34
- export type MessageType = keyof proto.Message;
35
- export type DownloadableMessage = {
36
- mediaKey?: Uint8Array | null;
37
- directPath?: string | null;
38
- url?: string | null;
39
- };
40
- export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined;
41
- export type MediaConnInfo = {
42
- auth: string;
43
- ttl: number;
44
- hosts: {
45
- hostname: string;
46
- maxContentLengthBytes: number;
47
- }[];
48
- fetchDate: Date;
49
- };
50
- export interface WAUrlInfo {
51
- 'canonical-url': string;
52
- 'matched-text': string;
53
- title: string;
54
- description?: string;
55
- jpegThumbnail?: Buffer;
56
- highQualityThumbnail?: proto.Message.IImageMessage;
57
- originalThumbnailUrl?: string;
58
- }
59
- type Mentionable = {
60
- /** list of jids that are mentioned in the accompanying text */
61
- mentions?: string[];
62
- };
63
- type Contextable = {
64
- /** add contextInfo to the message */
65
- contextInfo?: proto.IContextInfo;
66
- };
67
- type ViewOnce = {
68
- viewOnce?: boolean;
69
- };
70
- type Editable = {
71
- edit?: WAMessageKey;
72
- };
73
- type WithDimensions = {
74
- width?: number;
75
- height?: number;
76
- };
77
- export type PollMessageOptions = {
78
- name: string;
79
- selectableCount?: number;
80
- values: string[];
81
- /** 32 byte message secret to encrypt poll selections */
82
- messageSecret?: Uint8Array;
83
- toAnnouncementGroup?: boolean;
84
- };
85
- type SharePhoneNumber = {
86
- sharePhoneNumber: boolean;
87
- };
88
- type RequestPhoneNumber = {
89
- requestPhoneNumber: boolean;
90
- };
91
- export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
92
- export type AnyMediaMessageContent = (({
93
- image: WAMediaUpload;
94
- caption?: string;
95
- jpegThumbnail?: string;
96
- } & Mentionable & Contextable & WithDimensions) | ({
97
- video: WAMediaUpload;
98
- caption?: string;
99
- gifPlayback?: boolean;
100
- jpegThumbnail?: string;
101
- /** if set to true, will send as a `video note` */
102
- ptv?: boolean;
103
- } & Mentionable & Contextable & WithDimensions) | {
104
- audio: WAMediaUpload;
105
- /** if set to true, will send as a `voice note` */
106
- ptt?: boolean;
107
- /** optionally tell the duration of the audio */
108
- seconds?: number;
109
- } | ({
110
- sticker: WAMediaUpload;
111
- isAnimated?: boolean;
112
- } & WithDimensions) | ({
113
- document: WAMediaUpload;
114
- mimetype: string;
115
- fileName?: string;
116
- caption?: string;
117
- } & Contextable)) & {
118
- mimetype?: string;
119
- } & Editable;
120
- export type ButtonReplyInfo = {
121
- displayText: string;
122
- id: string;
123
- index: number;
124
- };
125
- export type GroupInviteInfo = {
126
- inviteCode: string;
127
- inviteExpiration: number;
128
- text: string;
129
- jid: string;
130
- subject: string;
131
- };
132
- export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
133
- productImage: WAMediaUpload;
134
- };
135
- export type AnyRegularMessageContent = (({
136
- text: string;
137
- linkPreview?: WAUrlInfo | null;
138
- } & Mentionable & Contextable & Editable) | AnyMediaMessageContent | ({
139
- poll: PollMessageOptions;
140
- } & Mentionable & Contextable & Editable) | {
141
- contacts: {
142
- displayName?: string;
143
- contacts: proto.Message.IContactMessage[];
144
- };
145
- } | {
146
- location: WALocationMessage;
147
- } | {
148
- react: proto.Message.IReactionMessage;
149
- } | {
150
- buttonReply: ButtonReplyInfo;
151
- type: 'template' | 'plain';
152
- } | {
153
- groupInvite: GroupInviteInfo;
154
- } | {
155
- listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
156
- } | {
157
- pin: WAMessageKey;
158
- type: proto.PinInChat.Type;
159
- /**
160
- * 24 hours, 7 days, 30 days
161
- */
162
- time?: 86400 | 604800 | 2592000;
163
- } | {
164
- product: WASendableProduct;
165
- businessOwnerJid?: string;
166
- body?: string;
167
- footer?: string;
168
- } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
169
- export type AnyMessageContent = AnyRegularMessageContent | {
170
- forward: WAMessage;
171
- force?: boolean;
172
- } | {
173
- /** Delete your message or anyone's message in a group (admin required) */
174
- delete: WAMessageKey;
175
- } | {
176
- disappearingMessagesInChat: boolean | number;
177
- };
178
- export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
179
- type MinimalRelayOptions = {
180
- /** override the message ID with a custom provided string */
181
- messageId?: string;
182
- /** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
183
- useCachedGroupMetadata?: boolean;
184
- };
185
- export type MessageRelayOptions = MinimalRelayOptions & {
186
- /** only send to a specific participant; used when a message decryption fails for a single user */
187
- participant?: {
188
- jid: string;
189
- count: number;
190
- };
191
- /** additional attributes to add to the WA binary node */
192
- additionalAttributes?: {
193
- [_: string]: string;
194
- };
195
- additionalNodes?: BinaryNode[];
196
- /** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
197
- useUserDevicesCache?: boolean;
198
- /** jid list of participants for status@broadcast */
199
- statusJidList?: string[];
200
- };
201
- export type MiscMessageGenerationOptions = MinimalRelayOptions & {
202
- /** optional, if you want to manually set the timestamp of the message */
203
- timestamp?: Date;
204
- /** the message you want to quote */
205
- quoted?: WAMessage;
206
- /** additional contextInfo */
207
- contextInfo?: proto.IMessageContextInfo;
208
- /** disappearing messages settings */
209
- ephemeralExpiration?: number | string;
210
- /** timeout for media upload to WA server */
211
- mediaUploadTimeoutMs?: number;
212
- /** jid list of participants for status@broadcast */
213
- statusJidList?: string[];
214
- /** backgroundcolor for status */
215
- backgroundColor?: string;
216
- /** font type for status */
217
- font?: number;
218
- /** if it is broadcast */
219
- broadcast?: boolean;
220
- };
221
- export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
222
- userJid: string;
223
- };
224
- export type WAMediaUploadFunction = (readStream: Readable, opts: {
225
- fileEncSha256B64: string;
226
- mediaType: MediaType;
227
- timeoutMs?: number;
228
- }) => Promise<{
229
- mediaUrl: string;
230
- directPath: string;
231
- }>;
232
- export type MediaGenerationOptions = {
233
- logger?: Logger;
234
- mediaTypeOverride?: MediaType;
235
- upload: WAMediaUploadFunction;
236
- /** cache media so it does not have to be uploaded again */
237
- mediaCache?: CacheStore;
238
- mediaUploadTimeoutMs?: number;
239
- options?: AxiosRequestConfig;
240
- backgroundColor?: string;
241
- font?: number;
242
- };
243
- export type MessageContentGenerationOptions = MediaGenerationOptions & {
244
- getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
245
- getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
246
- };
247
- export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
248
- /**
249
- * Type of message upsert
250
- * 1. notify => notify the user, this message was just received
251
- * 2. append => append the message to the chat history, no notification required
252
- */
253
- export type MessageUpsertType = 'append' | 'notify';
254
- export type MessageUserReceipt = proto.IUserReceipt;
255
- export type WAMessageUpdate = {
256
- update: Partial<WAMessage>;
257
- key: proto.IMessageKey;
258
- };
259
- export type WAMessageCursor = {
260
- before: WAMessageKey | undefined;
261
- } | {
262
- after: WAMessageKey | undefined;
263
- };
264
- export type MessageUserReceiptUpdate = {
265
- key: proto.IMessageKey;
266
- receipt: MessageUserReceipt;
267
- };
268
- export type MediaDecryptionKeyInfo = {
269
- iv: Buffer;
270
- cipherKey: Buffer;
271
- macKey?: Buffer;
272
- };
273
- export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;
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
+ export { proto as WAProto };
10
+ export type WAMessage = proto.IWebMessageInfo;
11
+ export type WAMessageContent = proto.IMessage;
12
+ export type WAContactMessage = proto.Message.IContactMessage;
13
+ export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
14
+ export type WAMessageKey = proto.IMessageKey;
15
+ export type WATextMessage = proto.Message.IExtendedTextMessage;
16
+ export type WAContextInfo = proto.IContextInfo;
17
+ export type WALocationMessage = proto.Message.ILocationMessage;
18
+ export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
19
+ export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
20
+ export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
21
+ import { ILogger } from '../Utils/logger';
22
+ export type WAMediaPayloadURL = {
23
+ url: URL | string;
24
+ };
25
+ export type WAMediaPayloadStream = {
26
+ stream: Readable;
27
+ };
28
+ export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
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 Editable = {
67
+ edit?: WAMessageKey;
68
+ };
69
+ type WithDimensions = {
70
+ width?: number;
71
+ height?: number;
72
+ };
73
+ export type PollMessageOptions = {
74
+ name: string;
75
+ selectableCount?: number;
76
+ values: string[];
77
+ /** 32 byte message secret to encrypt poll selections */
78
+ messageSecret?: Uint8Array;
79
+ toAnnouncementGroup?: boolean;
80
+ };
81
+ type SharePhoneNumber = {
82
+ sharePhoneNumber: boolean;
83
+ };
84
+ type RequestPhoneNumber = {
85
+ requestPhoneNumber: boolean;
86
+ };
87
+ export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
88
+ export type AnyMediaMessageContent = (({
89
+ image: WAMediaUpload;
90
+ caption?: string;
91
+ jpegThumbnail?: string;
92
+ } & Mentionable & Contextable & WithDimensions) | ({
93
+ video: WAMediaUpload;
94
+ caption?: string;
95
+ gifPlayback?: boolean;
96
+ jpegThumbnail?: string;
97
+ /** if set to true, will send as a `video note` */
98
+ ptv?: boolean;
99
+ } & Mentionable & Contextable & WithDimensions) | {
100
+ audio: WAMediaUpload;
101
+ /** if set to true, will send as a `voice note` */
102
+ ptt?: boolean;
103
+ /** optionally tell the duration of the audio */
104
+ seconds?: number;
105
+ } | ({
106
+ sticker: WAMediaUpload;
107
+ isAnimated?: boolean;
108
+ } & WithDimensions) | ({
109
+ document: WAMediaUpload;
110
+ mimetype: string;
111
+ fileName?: string;
112
+ caption?: string;
113
+ } & Contextable)) & {
114
+ mimetype?: string;
115
+ } & Editable;
116
+ export type ButtonReplyInfo = {
117
+ displayText: string;
118
+ id: string;
119
+ index: number;
120
+ };
121
+ export type GroupInviteInfo = {
122
+ inviteCode: string;
123
+ inviteExpiration: number;
124
+ text: string;
125
+ jid: string;
126
+ subject: string;
127
+ };
128
+ export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
129
+ productImage: WAMediaUpload;
130
+ };
131
+ export type AnyRegularMessageContent = (({
132
+ text: string;
133
+ linkPreview?: WAUrlInfo | null;
134
+ } & Mentionable & Contextable & Editable) | AnyMediaMessageContent | ({
135
+ poll: PollMessageOptions;
136
+ } & Mentionable & Contextable & Editable) | {
137
+ contacts: {
138
+ displayName?: string;
139
+ contacts: proto.Message.IContactMessage[];
140
+ };
141
+ } | {
142
+ location: WALocationMessage;
143
+ } | {
144
+ react: proto.Message.IReactionMessage;
145
+ } | {
146
+ buttonReply: ButtonReplyInfo;
147
+ type: 'template' | 'plain';
148
+ } | {
149
+ groupInvite: GroupInviteInfo;
150
+ } | {
151
+ listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
152
+ } | {
153
+ pin: WAMessageKey;
154
+ type: proto.PinInChat.Type;
155
+ /**
156
+ * 24 hours, 7 days, 30 days
157
+ */
158
+ time?: 86400 | 604800 | 2592000;
159
+ } | {
160
+ product: WASendableProduct;
161
+ businessOwnerJid?: string;
162
+ body?: string;
163
+ footer?: string;
164
+ } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
165
+ export type AnyMessageContent = AnyRegularMessageContent | {
166
+ forward: WAMessage;
167
+ force?: boolean;
168
+ } | {
169
+ /** Delete your message or anyone's message in a group (admin required) */
170
+ delete: WAMessageKey;
171
+ } | {
172
+ disappearingMessagesInChat: boolean | number;
173
+ };
174
+ export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
175
+ type MinimalRelayOptions = {
176
+ /** override the message ID with a custom provided string */
177
+ messageId?: string;
178
+ /** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
179
+ useCachedGroupMetadata?: boolean;
180
+ };
181
+ export type MessageRelayOptions = MinimalRelayOptions & {
182
+ /** only send to a specific participant; used when a message decryption fails for a single user */
183
+ participant?: {
184
+ jid: string;
185
+ count: number;
186
+ };
187
+ /** additional attributes to add to the WA binary node */
188
+ additionalAttributes?: {
189
+ [_: string]: string;
190
+ };
191
+ additionalNodes?: BinaryNode[];
192
+ /** should we use the devices cache, or fetch afresh from the server; default assumed to be "true" */
193
+ useUserDevicesCache?: boolean;
194
+ /** jid list of participants for status@broadcast */
195
+ statusJidList?: string[];
196
+ };
197
+ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
198
+ /** optional, if you want to manually set the timestamp of the message */
199
+ timestamp?: Date;
200
+ /** the message you want to quote */
201
+ quoted?: WAMessage;
202
+ /** additional contextInfo */
203
+ contextInfo?: proto.IMessageContextInfo;
204
+ /** disappearing messages settings */
205
+ ephemeralExpiration?: number | string;
206
+ /** timeout for media upload to WA server */
207
+ mediaUploadTimeoutMs?: number;
208
+ /** jid list of participants for status@broadcast */
209
+ statusJidList?: string[];
210
+ /** backgroundcolor for status */
211
+ backgroundColor?: string;
212
+ /** font type for status */
213
+ font?: number;
214
+ /** if it is broadcast */
215
+ broadcast?: boolean;
216
+ };
217
+ export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
218
+ userJid: string;
219
+ };
220
+ export type WAMediaUploadFunction = (readStream: Readable, opts: {
221
+ fileEncSha256B64: string;
222
+ mediaType: MediaType;
223
+ timeoutMs?: number;
224
+ }) => Promise<{
225
+ mediaUrl: string;
226
+ directPath: string;
227
+ }>;
228
+ export type MediaGenerationOptions = {
229
+ logger?: ILogger;
230
+ mediaTypeOverride?: MediaType;
231
+ upload: WAMediaUploadFunction;
232
+ /** cache media so it does not have to be uploaded again */
233
+ mediaCache?: CacheStore;
234
+ mediaUploadTimeoutMs?: number;
235
+ options?: AxiosRequestConfig;
236
+ backgroundColor?: string;
237
+ font?: number;
238
+ };
239
+ export type MessageContentGenerationOptions = MediaGenerationOptions & {
240
+ getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
241
+ getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
242
+ };
243
+ export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
244
+ /**
245
+ * Type of message upsert
246
+ * 1. notify => notify the user, this message was just received
247
+ * 2. append => append the message to the chat history, no notification required
248
+ */
249
+ export type MessageUpsertType = 'append' | 'notify';
250
+ export type MessageUserReceipt = proto.IUserReceipt;
251
+ export type WAMessageUpdate = {
252
+ update: Partial<WAMessage>;
253
+ key: proto.IMessageKey;
254
+ };
255
+ export type WAMessageCursor = {
256
+ before: WAMessageKey | undefined;
257
+ } | {
258
+ after: WAMessageKey | undefined;
259
+ };
260
+ export type MessageUserReceiptUpdate = {
261
+ key: proto.IMessageKey;
262
+ receipt: MessageUserReceipt;
263
+ };
264
+ export type MediaDecryptionKeyInfo = {
265
+ iv: Buffer;
266
+ cipherKey: Buffer;
267
+ macKey?: Buffer;
268
+ };
269
+ export type MinimalMessage = Pick<proto.IWebMessageInfo, 'key' | 'messageTimestamp'>;
@@ -1,9 +1,7 @@
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
+ exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
7
+ exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;