@jkt48connect-corp/baileys 7.3.0 → 7.3.2

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