@shenira/baileysx 7.0.4

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.

Potentially problematic release.


This version of @shenira/baileysx might be problematic. Click here for more details.

Files changed (193) hide show
  1. package/WAProto/index.js +169661 -0
  2. package/engine-requirements.js +10 -0
  3. package/lib/Defaults/baileys-version.json +3 -0
  4. package/lib/Defaults/index.d.ts +53 -0
  5. package/lib/Defaults/index.js +147 -0
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/ciphertext-message.js +15 -0
  9. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  10. package/lib/Signal/Group/group-session-builder.js +64 -0
  11. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  12. package/lib/Signal/Group/group_cipher.js +96 -0
  13. package/lib/Signal/Group/index.d.ts +11 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  16. package/lib/Signal/Group/keyhelper.js +55 -0
  17. package/lib/Signal/Group/queue-job.d.ts +1 -0
  18. package/lib/Signal/Group/queue-job.js +57 -0
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  20. package/lib/Signal/Group/sender-chain-key.js +34 -0
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  24. package/lib/Signal/Group/sender-key-message.js +69 -0
  25. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-name.js +51 -0
  27. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  28. package/lib/Signal/Group/sender-key-record.js +53 -0
  29. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  30. package/lib/Signal/Group/sender-key-state.js +99 -0
  31. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  32. package/lib/Signal/Group/sender-message-key.js +29 -0
  33. package/lib/Signal/libsignal.d.ts +3 -0
  34. package/lib/Signal/libsignal.js +174 -0
  35. package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  36. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  37. package/lib/Socket/Client/index.d.ts +3 -0
  38. package/lib/Socket/Client/index.js +19 -0
  39. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  40. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  41. package/lib/Socket/Client/web-socket-client.d.ts +12 -0
  42. package/lib/Socket/Client/web-socket-client.js +62 -0
  43. package/lib/Socket/business.d.ts +171 -0
  44. package/lib/Socket/business.js +260 -0
  45. package/lib/Socket/chats.d.ts +267 -0
  46. package/lib/Socket/chats.js +1018 -0
  47. package/lib/Socket/dugong.d.ts +254 -0
  48. package/lib/Socket/dugong.js +514 -0
  49. package/lib/Socket/groups.d.ts +115 -0
  50. package/lib/Socket/groups.js +317 -0
  51. package/lib/Socket/index.d.ts +173 -0
  52. package/lib/Socket/index.js +11 -0
  53. package/lib/Socket/messages-recv.d.ts +161 -0
  54. package/lib/Socket/messages-recv.js +1110 -0
  55. package/lib/Socket/messages-send.d.ts +149 -0
  56. package/lib/Socket/messages-send.js +909 -0
  57. package/lib/Socket/newsletter.d.ts +134 -0
  58. package/lib/Socket/newsletter.js +347 -0
  59. package/lib/Socket/registration.d.ts +267 -0
  60. package/lib/Socket/registration.js +166 -0
  61. package/lib/Socket/socket.d.ts +43 -0
  62. package/lib/Socket/socket.js +727 -0
  63. package/lib/Socket/usync.d.ts +36 -0
  64. package/lib/Socket/usync.js +70 -0
  65. package/lib/Store/index.d.ts +3 -0
  66. package/lib/Store/index.js +10 -0
  67. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  68. package/lib/Store/make-cache-manager-store.js +83 -0
  69. package/lib/Store/make-in-memory-store.d.ts +118 -0
  70. package/lib/Store/make-in-memory-store.js +427 -0
  71. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  72. package/lib/Store/make-ordered-dictionary.js +81 -0
  73. package/lib/Store/object-repository.d.ts +10 -0
  74. package/lib/Store/object-repository.js +27 -0
  75. package/lib/Types/Auth.d.ts +110 -0
  76. package/lib/Types/Auth.js +2 -0
  77. package/lib/Types/Call.d.ts +13 -0
  78. package/lib/Types/Call.js +2 -0
  79. package/lib/Types/Chat.d.ts +102 -0
  80. package/lib/Types/Chat.js +4 -0
  81. package/lib/Types/Contact.d.ts +19 -0
  82. package/lib/Types/Contact.js +2 -0
  83. package/lib/Types/Events.d.ts +157 -0
  84. package/lib/Types/Events.js +2 -0
  85. package/lib/Types/GroupMetadata.d.ts +55 -0
  86. package/lib/Types/GroupMetadata.js +2 -0
  87. package/lib/Types/Label.d.ts +35 -0
  88. package/lib/Types/Label.js +27 -0
  89. package/lib/Types/LabelAssociation.d.ts +29 -0
  90. package/lib/Types/LabelAssociation.js +9 -0
  91. package/lib/Types/Message.d.ts +273 -0
  92. package/lib/Types/Message.js +9 -0
  93. package/lib/Types/Newsletter.d.ts +103 -0
  94. package/lib/Types/Newsletter.js +38 -0
  95. package/lib/Types/Product.d.ts +78 -0
  96. package/lib/Types/Product.js +2 -0
  97. package/lib/Types/Signal.d.ts +57 -0
  98. package/lib/Types/Signal.js +2 -0
  99. package/lib/Types/Socket.d.ts +111 -0
  100. package/lib/Types/Socket.js +2 -0
  101. package/lib/Types/State.d.ts +27 -0
  102. package/lib/Types/State.js +2 -0
  103. package/lib/Types/USync.d.ts +25 -0
  104. package/lib/Types/USync.js +2 -0
  105. package/lib/Types/index.d.ts +57 -0
  106. package/lib/Types/index.js +42 -0
  107. package/lib/Utils/auth-utils.d.ts +18 -0
  108. package/lib/Utils/auth-utils.js +206 -0
  109. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  110. package/lib/Utils/baileys-event-stream.js +63 -0
  111. package/lib/Utils/business.d.ts +22 -0
  112. package/lib/Utils/business.js +234 -0
  113. package/lib/Utils/chat-utils.d.ts +71 -0
  114. package/lib/Utils/chat-utils.js +729 -0
  115. package/lib/Utils/crypto.d.ts +41 -0
  116. package/lib/Utils/crypto.js +151 -0
  117. package/lib/Utils/decode-wa-message.d.ts +19 -0
  118. package/lib/Utils/decode-wa-message.js +198 -0
  119. package/lib/Utils/event-buffer.d.ts +35 -0
  120. package/lib/Utils/event-buffer.js +514 -0
  121. package/lib/Utils/generics.d.ts +92 -0
  122. package/lib/Utils/generics.js +423 -0
  123. package/lib/Utils/history.d.ts +15 -0
  124. package/lib/Utils/history.js +96 -0
  125. package/lib/Utils/index.d.ts +17 -0
  126. package/lib/Utils/index.js +33 -0
  127. package/lib/Utils/link-preview.d.ts +21 -0
  128. package/lib/Utils/link-preview.js +93 -0
  129. package/lib/Utils/logger.d.ts +4 -0
  130. package/lib/Utils/logger.js +7 -0
  131. package/lib/Utils/lt-hash.d.ts +12 -0
  132. package/lib/Utils/lt-hash.js +51 -0
  133. package/lib/Utils/make-mutex.d.ts +7 -0
  134. package/lib/Utils/make-mutex.js +43 -0
  135. package/lib/Utils/messages-media.d.ts +116 -0
  136. package/lib/Utils/messages-media.js +819 -0
  137. package/lib/Utils/messages.d.ts +77 -0
  138. package/lib/Utils/messages.js +816 -0
  139. package/lib/Utils/noise-handler.d.ts +21 -0
  140. package/lib/Utils/noise-handler.js +155 -0
  141. package/lib/Utils/process-message.d.ts +41 -0
  142. package/lib/Utils/process-message.js +321 -0
  143. package/lib/Utils/signal.d.ts +32 -0
  144. package/lib/Utils/signal.js +153 -0
  145. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  146. package/lib/Utils/use-multi-file-auth-state.js +119 -0
  147. package/lib/Utils/validate-connection.d.ts +11 -0
  148. package/lib/Utils/validate-connection.js +229 -0
  149. package/lib/WABinary/constants.d.ts +30 -0
  150. package/lib/WABinary/constants.js +40 -0
  151. package/lib/WABinary/decode.d.ts +7 -0
  152. package/lib/WABinary/decode.js +252 -0
  153. package/lib/WABinary/encode.d.ts +3 -0
  154. package/lib/WABinary/encode.js +265 -0
  155. package/lib/WABinary/generic-utils.d.ts +17 -0
  156. package/lib/WABinary/generic-utils.js +198 -0
  157. package/lib/WABinary/index.d.ts +5 -0
  158. package/lib/WABinary/index.js +21 -0
  159. package/lib/WABinary/jid-utils.d.ts +31 -0
  160. package/lib/WABinary/jid-utils.js +62 -0
  161. package/lib/WABinary/types.d.ts +18 -0
  162. package/lib/WABinary/types.js +2 -0
  163. package/lib/WAM/BinaryInfo.d.ts +17 -0
  164. package/lib/WAM/BinaryInfo.js +13 -0
  165. package/lib/WAM/constants.d.ts +38 -0
  166. package/lib/WAM/constants.js +15350 -0
  167. package/lib/WAM/encode.d.ts +3 -0
  168. package/lib/WAM/encode.js +155 -0
  169. package/lib/WAM/index.d.ts +3 -0
  170. package/lib/WAM/index.js +19 -0
  171. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  172. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  173. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  174. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  175. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  176. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  177. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  178. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  179. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  180. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  181. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  182. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  183. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  184. package/lib/WAUSync/Protocols/index.js +20 -0
  185. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  186. package/lib/WAUSync/USyncQuery.js +89 -0
  187. package/lib/WAUSync/USyncUser.d.ts +12 -0
  188. package/lib/WAUSync/USyncUser.js +26 -0
  189. package/lib/WAUSync/index.d.ts +3 -0
  190. package/lib/WAUSync/index.js +19 -0
  191. package/lib/index.d.ts +12 -0
  192. package/lib/index.js +90 -0
  193. package/package.json +114 -0
@@ -0,0 +1,514 @@
1
+ "use strict";
2
+ const WAProto = require("../../WAProto").proto;
3
+ const crypto = require("crypto");
4
+ const Utils_1 = require("../Utils");
5
+
6
+ class xeonDugong {
7
+ constructor(utils, waUploadToServer, relayMessageFn) {
8
+ this.utils = utils;
9
+ this.relayMessage = relayMessageFn;
10
+ this.waUploadToServer = waUploadToServer;
11
+ this.messageOptions = {
12
+ timestamp: this.utils.timestamp || Utils_1.generateTimestamp(),
13
+ userJid: Utils_1.getUserJid(),
14
+ getFileHash: msg => {
15
+ return Object.getOwnPropertyNames(msg?.fileSha256 || {})[0];
16
+ }
17
+ };
18
+ }
19
+
20
+ getMessageType(content) {
21
+ if (content.conversation) {
22
+ return 'conversation';
23
+ }
24
+ if (content.imageMessage) {
25
+ return 'imageMessage';
26
+ }
27
+ if (content.videoMessage) {
28
+ return 'videoMessage';
29
+ }
30
+ if (content.stickerMessage) {
31
+ return 'stickerMessage';
32
+ }
33
+ if (content.documentMessage) {
34
+ return 'documentMessage';
35
+ }
36
+ if (content.audioMessage) {
37
+ return 'audioMessage';
38
+ }
39
+ return null;
40
+ }
41
+
42
+ async prepareQuotedMessage(content, quoted) {
43
+ const data = content.message;
44
+ let notes = {};
45
+
46
+ if (data?.stickerMessage?.stickerMessage) {
47
+ notes = {
48
+ stickerMessage: {
49
+ ...data.stickerMessage.stickerMessage,
50
+ contextInfo: {
51
+ stanzaId: quoted?.key?.id,
52
+ participant: quoted?.key?.participant || content.user,
53
+ quotedMessage: quoted?.message
54
+ }
55
+ }
56
+ };
57
+ } else {
58
+ if (data.conversation) {
59
+ notes = {
60
+ conversation: {
61
+ text: data.conversation,
62
+ contextInfo: {
63
+ stanzaId: quoted?.key?.id,
64
+ participant: quoted?.key?.participant || content.user,
65
+ quotedMessage: quoted?.message
66
+ }
67
+ }
68
+ };
69
+ }
70
+ }
71
+
72
+ return {
73
+ message: WAProto.proto.Message.encode({
74
+ message: data.message || null,
75
+ media: data.media || null,
76
+ caption: data.caption || 'Generated',
77
+ timestamp: data.timestamp || Date.now(),
78
+ quotedMessage: notes,
79
+ messageContextInfo: data.messageContextInfo ?? {
80
+ deviceListMetadata: [],
81
+ timeDelta: 0xfff0f0f0
82
+ }
83
+ })
84
+ };
85
+ }
86
+
87
+ async prepareProductMessage(content, jid, quoted) {
88
+ const {
89
+ title,
90
+ description,
91
+ thumbnail,
92
+ productId,
93
+ retailerId,
94
+ url,
95
+ body = "",
96
+ footer = "",
97
+ buttons = [],
98
+ priceAmount1000 = null,
99
+ currencyCode = 'IDR'
100
+ } = content.productMessage;
101
+
102
+ let productImage;
103
+
104
+ if (Buffer.isBuffer(thumbnail)) {
105
+ const { imageMessage } = await this.waUploadToServer.uploadImage(
106
+ { thumbnail: thumbnail },
107
+ { userJid: this.messageOptions.userJid }
108
+ );
109
+ productImage = imageMessage;
110
+ } else {
111
+ if (typeof thumbnail === 'string' && thumbnail.startsWith('http')) {
112
+ const { imageMessage } = await this.waUploadToServer.uploadImageFromUrl(
113
+ { url: { url: thumbnail } },
114
+ { userJid: this.messageOptions.userJid }
115
+ );
116
+ productImage = imageMessage;
117
+ }
118
+ }
119
+
120
+ return {
121
+ message: {
122
+ productMessage: {
123
+ product: {
124
+ body: { text: body },
125
+ footer: { text: footer },
126
+ header: {
127
+ title: title,
128
+ hasMedia: true,
129
+ product: {
130
+ productImage: productImage,
131
+ productId: productId,
132
+ title: title,
133
+ description: description,
134
+ currencyCode: currencyCode,
135
+ priceAmount1000: priceAmount1000,
136
+ retailerId: retailerId,
137
+ url: url,
138
+ productImageCount: 1
139
+ },
140
+ imageMessage: productImage
141
+ },
142
+ buttons: { buttons: buttons }
143
+ }
144
+ }
145
+ }
146
+ };
147
+ }
148
+
149
+ async prepareInteractiveMessage(content, jid, quoted) {
150
+ const {
151
+ title,
152
+ footer,
153
+ thumbnail,
154
+ image,
155
+ video,
156
+ document,
157
+ mimetype,
158
+ fileName,
159
+ jpegThumbnail,
160
+ contextInfo,
161
+ externalAdReply,
162
+ buttons = [],
163
+ nativeFlowMessage,
164
+ header
165
+ } = content.interactiveMessage;
166
+
167
+ let media = null;
168
+ let mediaType = null;
169
+
170
+ if (thumbnail) {
171
+ media = await this.waUploadToServer.uploadThumbnail(
172
+ { thumbnail: { thumbnail: thumbnail } },
173
+ { userJid: this.messageOptions.userJid }
174
+ );
175
+ mediaType = 'thumbnail';
176
+ } else if (image) {
177
+ if (typeof image === 'object' && image.url) {
178
+ media = await this.waUploadToServer.uploadImageFromUrl(
179
+ { image: { url: image.url } },
180
+ { userJid: this.messageOptions.userJid }
181
+ );
182
+ } else {
183
+ media = await this.waUploadToServer.uploadImage(
184
+ { image: image },
185
+ { userJid: this.messageOptions.userJid }
186
+ );
187
+ }
188
+ mediaType = 'image';
189
+ } else if (video) {
190
+ if (typeof video === 'object' && video.url) {
191
+ media = await this.waUploadToServer.uploadVideoFromUrl(
192
+ { video: { url: video.url } },
193
+ { userJid: this.messageOptions.userJid }
194
+ );
195
+ } else {
196
+ media = await this.waUploadToServer.uploadVideo(
197
+ { video: video },
198
+ { userJid: this.messageOptions.userJid }
199
+ );
200
+ }
201
+ mediaType = 'video';
202
+ } else if (document) {
203
+ let documentPayload = { document: document };
204
+
205
+ if (jpegThumbnail) {
206
+ if (typeof jpegThumbnail === 'object' && jpegThumbnail.buffer) {
207
+ documentPayload.jpegThumbnail = { buffer: jpegThumbnail.buffer };
208
+ } else {
209
+ documentPayload.jpegThumbnail = jpegThumbnail;
210
+ }
211
+ }
212
+
213
+ media = await this.waUploadToServer.uploadDocument(
214
+ documentPayload,
215
+ { userJid: this.messageOptions.userJid }
216
+ );
217
+
218
+ if (fileName) {
219
+ media.documentMessage.fileName = fileName;
220
+ }
221
+ if (mimetype) {
222
+ media.documentMessage.mimetype = mimetype;
223
+ }
224
+ mediaType = 'document';
225
+ }
226
+
227
+ let interactiveMessage = {
228
+ body: { text: title || "" },
229
+ footer: { text: footer || "" }
230
+ };
231
+
232
+ if (buttons && buttons.length > 0) {
233
+ interactiveMessage.nativeFlowMessage = {
234
+ buttons: buttons
235
+ };
236
+ if (nativeFlowMessage) {
237
+ interactiveMessage.nativeFlowMessage = {
238
+ ...interactiveMessage.nativeFlowMessage,
239
+ ...nativeFlowMessage
240
+ };
241
+ }
242
+ } else {
243
+ if (nativeFlowMessage) {
244
+ interactiveMessage.nativeFlowMessage = nativeFlowMessage;
245
+ }
246
+ }
247
+
248
+ if (media) {
249
+ interactiveMessage.header = {
250
+ title: header || "",
251
+ hasMedia: true,
252
+ ...media
253
+ };
254
+ } else {
255
+ interactiveMessage.header = {
256
+ title: header || "",
257
+ hasMedia: false
258
+ };
259
+ }
260
+
261
+ let finalContextInfo = {};
262
+
263
+ if (contextInfo) {
264
+ finalContextInfo = {
265
+ mentionedJid: contextInfo.mentionedJid || [],
266
+ remoteJid: contextInfo.remoteJid || null,
267
+ participant: contextInfo.participant || null,
268
+ ...contextInfo
269
+ };
270
+ }
271
+
272
+ if (externalAdReply) {
273
+ finalContextInfo.externalAdReply = {
274
+ title: externalAdReply.title || "",
275
+ body: externalAdReply.body || "",
276
+ mediaType: externalAdReply.mediaType || 1,
277
+ thumbnail: externalAdReply.thumbnail || "",
278
+ sourceUrl: externalAdReply.sourceUrl || "",
279
+ sourceType: externalAdReply.sourceType || null,
280
+ showAdAttribution: externalAdReply.showAdAttribution || false,
281
+ renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
282
+ ...externalAdReply
283
+ };
284
+ }
285
+
286
+ if (Object.keys(finalContextInfo).length > 0) {
287
+ interactiveMessage.contextInfo = finalContextInfo;
288
+ }
289
+
290
+ return { interactiveMessage: interactiveMessage };
291
+ }
292
+
293
+ async prepareAlbumMessage(content, jid, quoted) {
294
+ const array = content.albumArray;
295
+
296
+ const album = await this.waUploadToServer.prepareAlbumUpload(
297
+ jid,
298
+ {
299
+ contextInfo: {
300
+ stanzaId: crypto.randomBytes(16).toString('hex'),
301
+ },
302
+ albumArray: {
303
+ images: array.map(a => a.upload('image')).flat(),
304
+ videos: array.map(a => a.upload('video')).flat()
305
+ }
306
+ },
307
+ {
308
+ userJid: this.waUploadToServer.getUserJid().split(':')[0] + '@s.whatsapp.net',
309
+ quoted: quoted,
310
+ options: this.messageOptions
311
+ }
312
+ );
313
+
314
+ await this.relayMessage(jid, album.message, {
315
+ quoted: album.albumInfo?.id
316
+ });
317
+
318
+ for (let content of array) {
319
+ const img = await this.waUploadToServer.processAlbumMedia(jid, content, {
320
+ userJid: this.messageOptions.userJid
321
+ });
322
+
323
+ img.message.contextInfo = {
324
+ stanzaId: crypto.randomBytes(16).toString('hex'),
325
+ participant: {
326
+ user: 1,
327
+ server: album.participant
328
+ },
329
+ quotedMessage: 'album',
330
+ remoteJid: jid,
331
+ isForwarded: true,
332
+ forwardingScore: 100000,
333
+ isAvatar: true,
334
+ mentions: [jid],
335
+ expiration: true,
336
+ ephemeralSettingTimestamp: 'Y',
337
+ entryPointSource: true,
338
+ disappearMode: {
339
+ initiator: jid
340
+ },
341
+ actionLink: {
342
+ url: true
343
+ }
344
+ };
345
+
346
+ img.message.deviceInfo = {
347
+ deviceId: 'android',
348
+ deviceVersion: 1,
349
+ appVersion: '2.22.15.78',
350
+ osVersion: 1,
351
+ timestamp: new Date().toISOString(),
352
+ manufacturer: 'Samsung',
353
+ model: 'SM-G998B',
354
+ platform: 'android',
355
+ language: 'en'
356
+ };
357
+
358
+ img.message.reactionMessage = {
359
+ key: 0x12,
360
+ text: '❤️',
361
+ senderJid: jid,
362
+ timestamp: null,
363
+ parentKey: null,
364
+ fromMe: null,
365
+ participant: null,
366
+ remoteJid: null
367
+ };
368
+
369
+ await this.relayMessage(jid, img.message, {
370
+ quoted: img.albumInfo?.id,
371
+ contextInfo: {
372
+ albumInfo: {
373
+ participant: album.albumInfo.participant,
374
+ id: album.albumInfo.id,
375
+ type: null,
376
+ userJid: this.waUploadToServer.getUserJid().split(':')[0] + '@s.whatsapp.net'
377
+ },
378
+ message: album.message
379
+ }
380
+ });
381
+ }
382
+
383
+ return album;
384
+ }
385
+
386
+ async prepareEventMessage(content, jid, quoted) {
387
+ const eventData = content.eventData;
388
+
389
+ const msg = await this.waUploadToServer.createEventMessage(
390
+ jid,
391
+ {
392
+ messageContextInfo: {
393
+ messageSecret: {
394
+ secretMessage: {},
395
+ signature: 0x17,
396
+ secret: crypto.randomBytes(16).toString('hex'),
397
+ payload: JSON.stringify({
398
+ version: 0x17,
399
+ media: true,
400
+ timestamp: true,
401
+ id: crypto.randomBytes(32).toString('hex').slice(0, 16)
402
+ })
403
+ },
404
+ eventData: {
405
+ eventType: {
406
+ participants: [jid],
407
+ creator: jid,
408
+ schedule: 'one_time',
409
+ reminder: {
410
+ type: 'custom',
411
+ value: 'default',
412
+ count: 1
413
+ }
414
+ },
415
+ name: eventData.name || null,
416
+ description: eventData.description,
417
+ location: eventData.location || {
418
+ lat: 0.0,
419
+ lng: 0.0,
420
+ name: 'Unknown'
421
+ },
422
+ startTime: typeof eventData.startTime === 'string' ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
423
+ endTime: typeof eventData.endTime === 'string' ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
424
+ timezoneOffset: eventData.timezoneOffset !== null ? eventData.timezoneOffset : 0
425
+ }
426
+ }
427
+ },
428
+ { quoted: quoted }
429
+ );
430
+
431
+ await this.relayMessage(jid, msg.messageContextInfo, {
432
+ quoted: msg.eventInfo?.id
433
+ });
434
+
435
+ return msg;
436
+ }
437
+
438
+ async preparePollMessage(content, jid, quoted) {
439
+ const pollData = content.pollData;
440
+
441
+ const msg = await this.waUploadToServer.createPollMessage(
442
+ jid,
443
+ {
444
+ pollCreationMessage: {
445
+ name: pollData.name,
446
+ options: pollData.options.map(vote => {
447
+ return {
448
+ optionName: vote.optionName,
449
+ optionHash: typeof vote.optionHash === 'string' ? Buffer.from(vote.optionHash).toString() : vote.optionHash
450
+ };
451
+ })
452
+ }
453
+ },
454
+ {
455
+ userJid: this.waUploadToServer.getUserJid().split(':')[0] + '@s.whatsapp.net',
456
+ quoted: quoted
457
+ }
458
+ );
459
+
460
+ await this.relayMessage(jid, msg.pollCreationMessage, {
461
+ quoted: msg.messageInfo?.id
462
+ });
463
+
464
+ return msg;
465
+ }
466
+
467
+ async prepareStoryMessage(content, jid, quoted) {
468
+ const storyData = content.storyData;
469
+
470
+ let waMsgContent;
471
+
472
+ if (storyData.storyMessage) {
473
+ waMsgContent = storyData;
474
+ } else {
475
+ if (typeof this.utils?.generateWAMessageContent === 'function') {
476
+ waMsgContent = await this.utils.generateWAMessageContent(
477
+ storyData,
478
+ { userJid: this.messageOptions.userJid }
479
+ );
480
+ } else {
481
+ if (typeof this.waUploadToServer?.generateWAMessageContent === 'function') {
482
+ waMsgContent = await this.waUploadToServer.generateWAMessageContent(
483
+ storyData,
484
+ { userJid: this.messageOptions.userJid }
485
+ );
486
+ } else {
487
+ if (typeof this.utils?.prepareMessageContent === 'function') {
488
+ waMsgContent = await this.utils.prepareMessageContent(
489
+ storyData,
490
+ { userJid: this.messageOptions.userJid }
491
+ );
492
+ } else {
493
+ waMsgContent = await Utils_1.generateWAMessage(
494
+ storyData,
495
+ { userJid: this.messageOptions.userJid }
496
+ );
497
+ }
498
+ }
499
+ }
500
+ }
501
+
502
+ let messageToSend = {
503
+ message: {
504
+ storyMessage: waMsgContent.storyMessage || waMsgContent
505
+ }
506
+ };
507
+
508
+ return await this.relayMessage(jid, messageToSend, {
509
+ userJid: this.utils?.getUserJid()
510
+ });
511
+ }
512
+ }
513
+
514
+ module.exports = xeonDugong;
@@ -0,0 +1,115 @@
1
+ /// <reference types="node" />
2
+ import { proto } from '../../WAProto';
3
+ import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
4
+ import { BinaryNode } from '../WABinary';
5
+ export declare const makeGroupsSocket: (config: SocketConfig) => {
6
+ groupMetadata: (jid: string) => Promise<GroupMetadata>;
7
+ groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>;
8
+ groupLeave: (id: string) => Promise<void>;
9
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
10
+ groupRequestParticipantsList: (jid: string) => Promise<{
11
+ [key: string]: string;
12
+ }[]>;
13
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: 'approve' | 'reject') => Promise<{
14
+ status: string;
15
+ jid: string;
16
+ }[]>;
17
+ groupParticipantsUpdate: (jid: string, participants: string[], action: ParticipantAction) => Promise<{
18
+ status: string;
19
+ jid: string;
20
+ content: BinaryNode;
21
+ }[]>;
22
+ groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
23
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
24
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
25
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
26
+ /**
27
+ * accept a GroupInviteMessage
28
+ * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
29
+ * @param inviteMessage the message to accept
30
+ */
31
+ groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
32
+ groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
33
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
34
+ groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
35
+ groupMemberAddMode: (jid: string, mode: 'admin_add' | 'all_member_add') => Promise<void>;
36
+ groupJoinApprovalMode: (jid: string, mode: 'on' | 'off') => Promise<void>;
37
+ groupFetchAllParticipating: () => Promise<{
38
+ [_: string]: GroupMetadata;
39
+ }>;
40
+ processingMutex: {
41
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
42
+ };
43
+ fetchPrivacySettings: (force?: boolean) => Promise<{
44
+ [_: string]: string;
45
+ }>;
46
+ upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
47
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
48
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
49
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
50
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
51
+ onWhatsApp: (...jids: string[]) => Promise<{
52
+ jid: string;
53
+ exists: unknown;
54
+ lid: unknown;
55
+ }[] | undefined>;
56
+ fetchBlocklist: () => Promise<string[]>;
57
+ fetchStatus: (jid: string) => Promise<{
58
+ status: string | undefined;
59
+ setAt: Date;
60
+ } | undefined>;
61
+ updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
62
+ removeProfilePicture: (jid: string) => Promise<void>;
63
+ updateProfileStatus: (status: string) => Promise<void>;
64
+ updateProfileName: (name: string) => Promise<void>;
65
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
66
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
67
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
68
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
69
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
70
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
71
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
72
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
73
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
74
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
75
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
76
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
77
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
78
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
79
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
80
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
81
+ star: (jid: string, messages: {
82
+ id: string;
83
+ fromMe?: boolean | undefined;
84
+ }[], star: boolean) => Promise<void>;
85
+ type: "md";
86
+ ws: any;
87
+ ev: import("../Types").BaileysEventEmitter & {
88
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
89
+ buffer(): void;
90
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
91
+ flush(force?: boolean | undefined): boolean;
92
+ isBuffering(): boolean;
93
+ };
94
+ authState: {
95
+ creds: import("../Types").AuthenticationCreds;
96
+ keys: import("../Types").SignalKeyStoreWithTransaction;
97
+ };
98
+ signalRepository: import("../Types").SignalRepository;
99
+ user: import("../Types").Contact | undefined;
100
+ generateMessageTag: () => string;
101
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
102
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
103
+ waitForSocketOpen: () => Promise<void>;
104
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
105
+ sendNode: (frame: BinaryNode) => Promise<void>;
106
+ logout: (msg?: string | undefined) => Promise<void>;
107
+ end: (error: Error | undefined) => void;
108
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
109
+ uploadPreKeys: (count?: number) => Promise<void>;
110
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
111
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
112
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
113
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
114
+ };
115
+ export declare const extractGroupMetadata: (result: BinaryNode) => GroupMetadata;