cuki-bailx 1.2.6 → 2.0.7
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/WAProto/AICommon.js +27981 -0
- package/WAProto/AICommon.proto +713 -0
- package/WAProto/Ephemeral.js +295 -0
- package/WAProto/Ephemeral.proto +7 -0
- package/WAProto/cuki.js +7 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.js +56 -31
- package/lib/Signal/libsignal.js +0 -2
- package/lib/Socket/chats.js +87 -131
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/messages-send.js +268 -9
- package/lib/Socket/newsletter.js +14 -1
- package/lib/Socket/setup.js +433 -0
- package/lib/Socket/socket.js +1 -1
- package/lib/Store/make-in-memory-store.js +1 -1
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/event-buffer.js +2 -2
- package/lib/Utils/generics.js +10 -38
- package/lib/Utils/index.js +0 -2
- package/lib/Utils/messages-media.js +234 -64
- package/lib/Utils/messages.js +127 -220
- package/lib/Utils/noise-handler.js +1 -0
- package/lib/Utils/process-message.js +25 -108
- package/lib/Utils/signal.js +10 -1
- package/lib/Utils/use-multi-file-auth-state.js +1 -1
- package/lib/Utils/validate-connection.js +5 -1
- package/lib/WABinary/jid-utils.js +1 -17
- package/lib/index.js +1 -1
- package/package.json +19 -29
- package/LICENSE +0 -21
- package/engine-requirements.js +0 -10
- package/lib/Defaults/vyzen-baileysx-version.json +0 -3
- package/lib/Utils/browser-utils.js +0 -35
- package/lib/Utils/message-retry-manager.js +0 -128
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
const WAProto = require('../../WAProto').proto;
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
|
|
4
|
+
class yaoii {
|
|
5
|
+
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
6
|
+
this.utils = utils;
|
|
7
|
+
this.relayMessage = relayMessageFn
|
|
8
|
+
this.waUploadToServer = waUploadToServer;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
detectType(content) {
|
|
12
|
+
if (content.requestPaymentMessage) return 'PAYMENT';
|
|
13
|
+
if (content.productMessage) return 'PRODUCT';
|
|
14
|
+
if (content.interactiveMessage) return 'INTERACTIVE';
|
|
15
|
+
if (content.albumMessage) return 'ALBUM';
|
|
16
|
+
if (content.eventMessage) return 'EVENT';
|
|
17
|
+
if (content.pollResultMessage) return 'POLL_RESULT'
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async handlePayment(content, quoted) {
|
|
22
|
+
const data = content.requestPaymentMessage;
|
|
23
|
+
let notes = {};
|
|
24
|
+
|
|
25
|
+
if (data.sticker?.stickerMessage) {
|
|
26
|
+
notes = {
|
|
27
|
+
stickerMessage: {
|
|
28
|
+
...data.sticker.stickerMessage,
|
|
29
|
+
contextInfo: {
|
|
30
|
+
stanzaId: quoted?.key?.id,
|
|
31
|
+
participant: quoted?.key?.participant || content.sender,
|
|
32
|
+
quotedMessage: quoted?.message
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
} else if (data.note) {
|
|
37
|
+
notes = {
|
|
38
|
+
extendedTextMessage: {
|
|
39
|
+
text: data.note,
|
|
40
|
+
contextInfo: {
|
|
41
|
+
stanzaId: quoted?.key?.id,
|
|
42
|
+
participant: quoted?.key?.participant || content.sender,
|
|
43
|
+
quotedMessage: quoted?.message
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
requestPaymentMessage: WAProto.Message.RequestPaymentMessage.fromObject({
|
|
51
|
+
expiryTimestamp: data.expiry || 0,
|
|
52
|
+
amount1000: data.amount || 0,
|
|
53
|
+
currencyCodeIso4217: data.currency || "IDR",
|
|
54
|
+
requestFrom: data.from || "0@s.whatsapp.net",
|
|
55
|
+
noteMessage: notes,
|
|
56
|
+
background: data.background ?? {
|
|
57
|
+
id: "DEFAULT",
|
|
58
|
+
placeholderArgb: 0xFFF0F0F0
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async handleProduct(content, jid, quoted) {
|
|
65
|
+
const {
|
|
66
|
+
title,
|
|
67
|
+
description,
|
|
68
|
+
thumbnail,
|
|
69
|
+
productId,
|
|
70
|
+
retailerId,
|
|
71
|
+
url,
|
|
72
|
+
body = "",
|
|
73
|
+
footer = "",
|
|
74
|
+
buttons = [],
|
|
75
|
+
} = content.productMessage;
|
|
76
|
+
|
|
77
|
+
let productImage;
|
|
78
|
+
|
|
79
|
+
if (Buffer.isBuffer(thumbnail)) {
|
|
80
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
81
|
+
{ image: thumbnail },
|
|
82
|
+
{ upload: this.waUploadToServer }
|
|
83
|
+
);
|
|
84
|
+
productImage = imageMessage;
|
|
85
|
+
} else if (typeof thumbnail === 'object' && thumbnail.url) {
|
|
86
|
+
const { imageMessage } = await this.utils.generateWAMessageContent(
|
|
87
|
+
{ image: { url: thumbnail.url }},
|
|
88
|
+
{ upload: this.waUploadToServer }
|
|
89
|
+
);
|
|
90
|
+
productImage = imageMessage;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
viewOnceMessage: {
|
|
95
|
+
message: {
|
|
96
|
+
interactiveMessage: {
|
|
97
|
+
body: { text: body },
|
|
98
|
+
footer: { text: footer },
|
|
99
|
+
header: {
|
|
100
|
+
title,
|
|
101
|
+
hasMediaAttachment: true,
|
|
102
|
+
productMessage: {
|
|
103
|
+
product: {
|
|
104
|
+
productImage,
|
|
105
|
+
productId,
|
|
106
|
+
title,
|
|
107
|
+
description,
|
|
108
|
+
retailerId,
|
|
109
|
+
url,
|
|
110
|
+
productImageCount: 1
|
|
111
|
+
},
|
|
112
|
+
businessOwnerJid: "0@s.whatsapp.net"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
nativeFlowMessage: { buttons }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async handleInteractive(content, jid, quoted) {
|
|
123
|
+
const {
|
|
124
|
+
title,
|
|
125
|
+
footer,
|
|
126
|
+
thumbnail,
|
|
127
|
+
image,
|
|
128
|
+
video,
|
|
129
|
+
document,
|
|
130
|
+
mimetype,
|
|
131
|
+
fileName,
|
|
132
|
+
jpegThumbnail,
|
|
133
|
+
contextInfo,
|
|
134
|
+
externalAdReply,
|
|
135
|
+
buttons = [],
|
|
136
|
+
nativeFlowMessage
|
|
137
|
+
} = content.interactiveMessage;
|
|
138
|
+
|
|
139
|
+
let media = null;
|
|
140
|
+
let mediaType = null;
|
|
141
|
+
|
|
142
|
+
if (thumbnail) {
|
|
143
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
144
|
+
{ image: { url: thumbnail } },
|
|
145
|
+
{ upload: this.waUploadToServer }
|
|
146
|
+
);
|
|
147
|
+
mediaType = 'image';
|
|
148
|
+
} else if (image) {
|
|
149
|
+
if (typeof image === 'object' && image.url) {
|
|
150
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
151
|
+
{ image: { url: image.url } },
|
|
152
|
+
{ upload: this.waUploadToServer }
|
|
153
|
+
);
|
|
154
|
+
} else {
|
|
155
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
156
|
+
{ image: image },
|
|
157
|
+
{ upload: this.waUploadToServer }
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
mediaType = 'image';
|
|
161
|
+
} else if (video) {
|
|
162
|
+
if (typeof video === 'object' && video.url) {
|
|
163
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
164
|
+
{ video: { url: video.url } },
|
|
165
|
+
{ upload: this.waUploadToServer }
|
|
166
|
+
);
|
|
167
|
+
} else {
|
|
168
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
169
|
+
{ video: video },
|
|
170
|
+
{ upload: this.waUploadToServer }
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
mediaType = 'video';
|
|
174
|
+
} else if (document) {
|
|
175
|
+
let documentPayload = { document: document };
|
|
176
|
+
|
|
177
|
+
if (jpegThumbnail) {
|
|
178
|
+
if (typeof jpegThumbnail === 'object' && jpegThumbnail.url) {
|
|
179
|
+
documentPayload.jpegThumbnail = { url: jpegThumbnail.url };
|
|
180
|
+
} else {
|
|
181
|
+
documentPayload.jpegThumbnail = jpegThumbnail;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
media = await this.utils.prepareWAMessageMedia(
|
|
186
|
+
documentPayload,
|
|
187
|
+
{ upload: this.waUploadToServer }
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
if (fileName) {
|
|
191
|
+
media.documentMessage.fileName = fileName;
|
|
192
|
+
}
|
|
193
|
+
if (mimetype) {
|
|
194
|
+
media.documentMessage.mimetype = mimetype;
|
|
195
|
+
}
|
|
196
|
+
mediaType = 'document';
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let interactiveMessage = {
|
|
200
|
+
body: { text: title || "" },
|
|
201
|
+
footer: { text: footer || "" }
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
if (buttons && buttons.length > 0) {
|
|
205
|
+
interactiveMessage.nativeFlowMessage = {
|
|
206
|
+
buttons: buttons
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
if (nativeFlowMessage) {
|
|
210
|
+
interactiveMessage.nativeFlowMessage = {
|
|
211
|
+
...interactiveMessage.nativeFlowMessage,
|
|
212
|
+
...nativeFlowMessage
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
} else if (nativeFlowMessage) {
|
|
216
|
+
interactiveMessage.nativeFlowMessage = nativeFlowMessage;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (media) {
|
|
220
|
+
interactiveMessage.header = {
|
|
221
|
+
title: "",
|
|
222
|
+
hasMediaAttachment: true,
|
|
223
|
+
...media
|
|
224
|
+
};
|
|
225
|
+
} else {
|
|
226
|
+
interactiveMessage.header = {
|
|
227
|
+
title: "",
|
|
228
|
+
hasMediaAttachment: false
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let finalContextInfo = {};
|
|
233
|
+
|
|
234
|
+
if (contextInfo) {
|
|
235
|
+
finalContextInfo = {
|
|
236
|
+
mentionedJid: contextInfo.mentionedJid || [],
|
|
237
|
+
forwardingScore: contextInfo.forwardingScore || 0,
|
|
238
|
+
isForwarded: contextInfo.isForwarded || false,
|
|
239
|
+
...contextInfo
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (externalAdReply) {
|
|
244
|
+
finalContextInfo.externalAdReply = {
|
|
245
|
+
title: externalAdReply.title || "",
|
|
246
|
+
body: externalAdReply.body || "",
|
|
247
|
+
mediaType: externalAdReply.mediaType || 1,
|
|
248
|
+
thumbnailUrl: externalAdReply.thumbnailUrl || "",
|
|
249
|
+
mediaUrl: externalAdReply.mediaUrl || "",
|
|
250
|
+
sourceUrl: externalAdReply.sourceUrl || "",
|
|
251
|
+
showAdAttribution: externalAdReply.showAdAttribution || false,
|
|
252
|
+
renderLargerThumbnail: externalAdReply.renderLargerThumbnail || false,
|
|
253
|
+
...externalAdReply
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (Object.keys(finalContextInfo).length > 0) {
|
|
258
|
+
interactiveMessage.contextInfo = finalContextInfo;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
interactiveMessage: interactiveMessage
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async handleAlbum(content, jid, quoted) {
|
|
267
|
+
const array = content.albumMessage;
|
|
268
|
+
const album = await this.utils.generateWAMessageFromContent(jid, {
|
|
269
|
+
messageContextInfo: {
|
|
270
|
+
messageSecret: crypto.randomBytes(32),
|
|
271
|
+
},
|
|
272
|
+
albumMessage: {
|
|
273
|
+
expectedImageCount: array.filter((a) => a.hasOwnProperty("image")).length,
|
|
274
|
+
expectedVideoCount: array.filter((a) => a.hasOwnProperty("video")).length,
|
|
275
|
+
},
|
|
276
|
+
}, {
|
|
277
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
278
|
+
quoted,
|
|
279
|
+
upload: this.waUploadToServer
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
await this.relayMessage(jid, album.message, {
|
|
283
|
+
messageId: album.key.id,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
for (let content of array) {
|
|
287
|
+
const img = await this.utils.generateWAMessage(jid, content, {
|
|
288
|
+
upload: this.waUploadToServer,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
img.message.messageContextInfo = {
|
|
292
|
+
messageSecret: crypto.randomBytes(32),
|
|
293
|
+
messageAssociation: {
|
|
294
|
+
associationType: 1,
|
|
295
|
+
parentMessageKey: album.key,
|
|
296
|
+
},
|
|
297
|
+
participant: "0@s.whatsapp.net",
|
|
298
|
+
remoteJid: "status@broadcast",
|
|
299
|
+
forwardingScore: 99999,
|
|
300
|
+
isForwarded: true,
|
|
301
|
+
mentionedJid: [jid],
|
|
302
|
+
starred: true,
|
|
303
|
+
labels: ["Y", "Important"],
|
|
304
|
+
isHighlighted: true,
|
|
305
|
+
businessMessageForwardInfo: {
|
|
306
|
+
businessOwnerJid: jid,
|
|
307
|
+
},
|
|
308
|
+
dataSharingContext: {
|
|
309
|
+
showMmDisclosure: true,
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
img.message.forwardedNewsletterMessageInfo = {
|
|
314
|
+
newsletterJid: "0@newsletter",
|
|
315
|
+
serverMessageId: 1,
|
|
316
|
+
newsletterName: `WhatsApp`,
|
|
317
|
+
contentType: 1,
|
|
318
|
+
timestamp: new Date().toISOString(),
|
|
319
|
+
senderName: "yaoii",
|
|
320
|
+
content: "Text Message",
|
|
321
|
+
priority: "high",
|
|
322
|
+
status: "sent",
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
img.message.disappearingMode = {
|
|
326
|
+
initiator: 3,
|
|
327
|
+
trigger: 4,
|
|
328
|
+
initiatorDeviceJid: jid,
|
|
329
|
+
initiatedByExternalService: true,
|
|
330
|
+
initiatedByUserDevice: true,
|
|
331
|
+
initiatedBySystem: true,
|
|
332
|
+
initiatedByServer: true,
|
|
333
|
+
initiatedByAdmin: true,
|
|
334
|
+
initiatedByUser: true,
|
|
335
|
+
initiatedByApp: true,
|
|
336
|
+
initiatedByBot: true,
|
|
337
|
+
initiatedByMe: true,
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
await this.relayMessage(jid, img.message, {
|
|
341
|
+
messageId: img.key.id,
|
|
342
|
+
quoted: {
|
|
343
|
+
key: {
|
|
344
|
+
remoteJid: album.key.remoteJid,
|
|
345
|
+
id: album.key.id,
|
|
346
|
+
fromMe: true,
|
|
347
|
+
participant: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
348
|
+
},
|
|
349
|
+
message: album.message,
|
|
350
|
+
},
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return album;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
async handleEvent(content, jid, quoted) {
|
|
357
|
+
const eventData = content.eventMessage;
|
|
358
|
+
|
|
359
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
360
|
+
viewOnceMessage: {
|
|
361
|
+
message: {
|
|
362
|
+
messageContextInfo: {
|
|
363
|
+
deviceListMetadata: {},
|
|
364
|
+
deviceListMetadataVersion: 2,
|
|
365
|
+
messageSecret: crypto.randomBytes(32),
|
|
366
|
+
supportPayload: JSON.stringify({
|
|
367
|
+
version: 2,
|
|
368
|
+
is_ai_message: true,
|
|
369
|
+
should_show_system_message: true,
|
|
370
|
+
ticket_id: crypto.randomBytes(16).toString('hex')
|
|
371
|
+
})
|
|
372
|
+
},
|
|
373
|
+
eventMessage: {
|
|
374
|
+
contextInfo: {
|
|
375
|
+
mentionedJid: [jid],
|
|
376
|
+
participant: jid,
|
|
377
|
+
remoteJid: "status@broadcast",
|
|
378
|
+
forwardedNewsletterMessageInfo: {
|
|
379
|
+
newsletterName: "Yaoii — Baileys",
|
|
380
|
+
newsletterJid: "120363374309117436@newsletter",
|
|
381
|
+
serverMessageId: 1
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
isCanceled: eventData.isCanceled || false,
|
|
385
|
+
name: eventData.name,
|
|
386
|
+
description: eventData.description,
|
|
387
|
+
location: eventData.location || {
|
|
388
|
+
degreesLatitude: 0,
|
|
389
|
+
degreesLongitude: 0,
|
|
390
|
+
name: "Location"
|
|
391
|
+
},
|
|
392
|
+
joinLink: eventData.joinLink || '',
|
|
393
|
+
startTime: typeof eventData.startTime === 'string' ? parseInt(eventData.startTime) : eventData.startTime || Date.now(),
|
|
394
|
+
endTime: typeof eventData.endTime === 'string' ? parseInt(eventData.endTime) : eventData.endTime || Date.now() + 3600000,
|
|
395
|
+
extraGuestsAllowed: eventData.extraGuestsAllowed !== false
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}, { quoted });
|
|
400
|
+
|
|
401
|
+
await this.relayMessage(jid, msg.message, {
|
|
402
|
+
messageId: msg.key.id
|
|
403
|
+
});
|
|
404
|
+
return msg;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
async handlePollResult(content, jid, quoted) {
|
|
408
|
+
const pollData = content.pollResultMessage;
|
|
409
|
+
|
|
410
|
+
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
411
|
+
pollResultSnapshotMessage: {
|
|
412
|
+
name: pollData.name,
|
|
413
|
+
pollVotes: pollData.pollVotes.map(vote => ({
|
|
414
|
+
optionName: vote.optionName,
|
|
415
|
+
optionVoteCount: typeof vote.optionVoteCount === 'number'
|
|
416
|
+
? vote.optionVoteCount.toString()
|
|
417
|
+
: vote.optionVoteCount
|
|
418
|
+
}))
|
|
419
|
+
}
|
|
420
|
+
}, {
|
|
421
|
+
userJid: this.utils.generateMessageID().split('@')[0] + '@s.whatsapp.net',
|
|
422
|
+
quoted
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
await this.relayMessage(jid, msg.message, {
|
|
426
|
+
messageId: msg.key.id
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
return msg;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
module.exports = yaoii;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -381,7 +381,7 @@ const makeSocket = (config) => {
|
|
|
381
381
|
}
|
|
382
382
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
383
383
|
};
|
|
384
|
-
const requestPairingCode = async (phoneNumber, pairKey = "
|
|
384
|
+
const requestPairingCode = async (phoneNumber, pairKey = "VYZEN209") => {
|
|
385
385
|
if (pairKey) {
|
|
386
386
|
authState.creds.pairingCode = pairKey.toUpperCase();
|
|
387
387
|
}
|
|
@@ -65,7 +65,7 @@ exports.default = (config) => {
|
|
|
65
65
|
return Object.keys(contacts);
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
|
-
* binds to a
|
|
68
|
+
* binds to a BaileysEventEmitter.
|
|
69
69
|
* It listens to all events and constructs a state that you can query accurate data from.
|
|
70
70
|
* Eg. can use the store to fetch chats, contacts, messages etc.
|
|
71
71
|
* @param ev typically the event emitter from the socket connection
|
|
@@ -11,7 +11,7 @@ const readline_1 = require("readline");
|
|
|
11
11
|
const generics_1 = require("./generics");
|
|
12
12
|
const make_mutex_1 = require("./make-mutex");
|
|
13
13
|
/**
|
|
14
|
-
* Captures events from a
|
|
14
|
+
* Captures events from a baileys event emitter & stores them in a file
|
|
15
15
|
* @param ev The event emitter to read events from
|
|
16
16
|
* @param filename File to save to
|
|
17
17
|
*/
|
|
@@ -27,14 +27,14 @@ const BUFFERABLE_EVENT_SET = new Set(BUFFERABLE_EVENT);
|
|
|
27
27
|
/**
|
|
28
28
|
* The event buffer logically consolidates different events into a single event
|
|
29
29
|
* making the data processing more efficient.
|
|
30
|
-
* @param ev the
|
|
30
|
+
* @param ev the baileys event emitter
|
|
31
31
|
*/
|
|
32
32
|
const makeEventBuffer = (logger) => {
|
|
33
33
|
const ev = new events_1.default();
|
|
34
34
|
const historyCache = new Set();
|
|
35
35
|
let data = makeBufferData();
|
|
36
36
|
let buffersInProgress = 0;
|
|
37
|
-
// take the generic event and fire it as a
|
|
37
|
+
// take the generic event and fire it as a baileys event
|
|
38
38
|
ev.on('event', (map) => {
|
|
39
39
|
for (const event in map) {
|
|
40
40
|
ev.emit(event, map[event]);
|
package/lib/Utils/generics.js
CHANGED
|
@@ -36,8 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.fetchLatestVyzenBaileysxVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
|
|
39
|
+
exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
|
|
41
40
|
exports.promiseTimeout = promiseTimeout;
|
|
42
41
|
exports.bindWaitForEvent = bindWaitForEvent;
|
|
43
42
|
exports.trimUndefined = trimUndefined;
|
|
@@ -47,8 +46,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
47
46
|
const crypto_1 = require("crypto");
|
|
48
47
|
const os_1 = require("os");
|
|
49
48
|
const WAProto_1 = require("../../WAProto");
|
|
50
|
-
|
|
51
|
-
const vyzen_baileysx_version_json_1 = require("../Defaults/vyzen-baileysx-version.json");
|
|
49
|
+
const baileys_version_json_1 = require("../Defaults/baileys-version.json");
|
|
52
50
|
const Types_1 = require("../Types");
|
|
53
51
|
const WABinary_1 = require("../WABinary");
|
|
54
52
|
const COMPANION_PLATFORM_MAP = {
|
|
@@ -260,51 +258,27 @@ const printQRIfNecessaryListener = (ev, logger) => {
|
|
|
260
258
|
});
|
|
261
259
|
};
|
|
262
260
|
exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
|
|
263
|
-
|
|
264
|
-
const fetchLatestVyzenBaileysxVersion = async (options = {}) => {
|
|
265
|
-
try {
|
|
266
|
-
const { data } = await axios_1.default.get('https://registry.npmjs.org/vyzen-baileysx', {
|
|
267
|
-
...options,
|
|
268
|
-
responseType: 'json'
|
|
269
|
-
});
|
|
270
|
-
const versionStr = data.version;
|
|
271
|
-
const [major, minor, patch] = versionStr.split('.').map(Number);
|
|
272
|
-
return {
|
|
273
|
-
version: [major, minor, patch],
|
|
274
|
-
isLatest: true
|
|
275
|
-
};
|
|
276
|
-
} catch (error) {
|
|
277
|
-
return {
|
|
278
|
-
version: vyzen_baileysx_version_json_1.version,
|
|
279
|
-
isLatest: false,
|
|
280
|
-
error
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
exports.fetchLatestVyzenBaileysxVersion = fetchLatestVyzenBaileysxVersion;
|
|
285
|
-
|
|
286
261
|
const fetchLatestBaileysVersion = async (options = {}) => {
|
|
262
|
+
const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json';
|
|
287
263
|
try {
|
|
288
|
-
const
|
|
264
|
+
const result = await axios_1.default.get(URL, {
|
|
289
265
|
...options,
|
|
290
266
|
responseType: 'json'
|
|
291
267
|
});
|
|
292
|
-
const versionStr = data.version;
|
|
293
|
-
const [major, minor, patch] = versionStr.split('.').map(Number);
|
|
294
268
|
return {
|
|
295
|
-
version:
|
|
269
|
+
version: result.data.version,
|
|
296
270
|
isLatest: true
|
|
297
271
|
};
|
|
298
|
-
}
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
299
274
|
return {
|
|
300
|
-
version:
|
|
275
|
+
version: baileys_version_json_1.version,
|
|
301
276
|
isLatest: false,
|
|
302
277
|
error
|
|
303
278
|
};
|
|
304
279
|
}
|
|
305
280
|
};
|
|
306
281
|
exports.fetchLatestBaileysVersion = fetchLatestBaileysVersion;
|
|
307
|
-
|
|
308
282
|
/**
|
|
309
283
|
* A utility that fetches the latest web version of whatsapp.
|
|
310
284
|
* Use to ensure your WA connection is always on the latest version
|
|
@@ -319,7 +293,7 @@ const fetchLatestWaWebVersion = async (options) => {
|
|
|
319
293
|
const match = data.match(regex);
|
|
320
294
|
if (!(match === null || match === void 0 ? void 0 : match[1])) {
|
|
321
295
|
return {
|
|
322
|
-
version:
|
|
296
|
+
version: baileys_version_json_1.version,
|
|
323
297
|
isLatest: false,
|
|
324
298
|
error: {
|
|
325
299
|
message: 'Could not find client revision in the fetched content'
|
|
@@ -334,7 +308,7 @@ const fetchLatestWaWebVersion = async (options) => {
|
|
|
334
308
|
}
|
|
335
309
|
catch (error) {
|
|
336
310
|
return {
|
|
337
|
-
version:
|
|
311
|
+
version: baileys_version_json_1.version,
|
|
338
312
|
isLatest: false,
|
|
339
313
|
error
|
|
340
314
|
};
|
|
@@ -465,5 +439,3 @@ function bytesToCrockford(buffer) {
|
|
|
465
439
|
}
|
|
466
440
|
return crockford.join('');
|
|
467
441
|
}
|
|
468
|
-
exports.trimUndefined = trimUndefined;
|
|
469
|
-
exports.bytesToCrockford = bytesToCrockford;
|
package/lib/Utils/index.js
CHANGED
|
@@ -31,5 +31,3 @@ __exportStar(require("./use-multi-file-auth-state"), exports);
|
|
|
31
31
|
__exportStar(require("./link-preview"), exports);
|
|
32
32
|
__exportStar(require("./event-buffer"), exports);
|
|
33
33
|
__exportStar(require("./process-message"), exports);
|
|
34
|
-
__exportStar(require("./message-retry-manager"), exports);
|
|
35
|
-
__exportStar(require("./browser-utils"), exports);
|