cuki-bailx 2.0.9 → 2.1.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.
- package/lib/Signal/Group/index/_internal.js +1 -0
- package/lib/Socket/messages-send.js +16 -11
- package/lib/Socket/newsletter.js +60 -211
- package/lib/Socket/setup.js +5 -5
- package/lib/Socket/socket.js +1 -1
- package/lib/Utils/crypto.js +17 -21
- package/lib/Utils/messages-media.js +1 -1
- package/lib/Utils/messages.js +43 -58
- package/lib/Utils/noise-handler.js +2 -2
- package/lib/Utils/validate-connection.js +3 -3
- package/package.json +1 -1
- package/lib/Signal/Group/index/_ceche.js +0 -100
package/lib/Utils/messages.js
CHANGED
|
@@ -22,7 +22,7 @@ exports.prepareWAMessageMedia =
|
|
|
22
22
|
exports.generateLinkPreviewIfRequired =
|
|
23
23
|
exports.extractUrlFromText = void 0;
|
|
24
24
|
exports.getAggregateVotesInPollMessage = getAggregateVotesInPollMessage;
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
const boom_1 = require("@hapi/boom");
|
|
27
27
|
const axios_1 = __importDefault(require("axios"));
|
|
28
28
|
const crypto_1 = require("crypto");
|
|
@@ -64,7 +64,7 @@ const generateLinkPreviewIfRequired = async (text, getUrlInfo, logger) => {
|
|
|
64
64
|
const urlInfo = await getUrlInfo(url);
|
|
65
65
|
return urlInfo;
|
|
66
66
|
}
|
|
67
|
-
catch (error) {
|
|
67
|
+
catch (error) {
|
|
68
68
|
logger === null || logger === void 0 ? void 0 : logger.warn({ trace: error.stack }, 'url generation failed');
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -96,42 +96,12 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
96
96
|
throw new boom_1.Boom('Invalid media type', { statusCode: 400 });
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
|
|
99
100
|
const uploadData = {
|
|
100
101
|
...message,
|
|
101
|
-
...(message.annotations ? {
|
|
102
|
-
annotations: message.annotations
|
|
103
|
-
} : {
|
|
104
|
-
annotations: [
|
|
105
|
-
{
|
|
106
|
-
polygonVertices: [
|
|
107
|
-
{
|
|
108
|
-
x: 60.71664810180664,
|
|
109
|
-
y: -36.39784622192383
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
x: -16.710189819335938,
|
|
113
|
-
y: 49.263675689697266
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
x: -56.585853576660156,
|
|
117
|
-
y: 37.85963439941406
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
x: 20.840980529785156,
|
|
121
|
-
y: -47.80188751220703
|
|
122
|
-
}
|
|
123
|
-
],
|
|
124
|
-
newsletter: {
|
|
125
|
-
newsletterJid: "120363423722136487@newsletter",
|
|
126
|
-
serverMessageId: 0,
|
|
127
|
-
newsletterName: "Baileys —",
|
|
128
|
-
contentType: "UPDATE",
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
]
|
|
132
|
-
}),
|
|
133
102
|
media: message[mediaType]
|
|
134
103
|
};
|
|
104
|
+
|
|
135
105
|
delete uploadData[mediaType];
|
|
136
106
|
|
|
137
107
|
const cacheableKey = typeof uploadData.media === 'object' &&
|
|
@@ -162,8 +132,12 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
162
132
|
const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined';
|
|
163
133
|
const requiresThumbnailComputation = (mediaType === 'image' || mediaType === 'video') &&
|
|
164
134
|
typeof uploadData['jpegThumbnail'] === 'undefined';
|
|
165
|
-
|
|
166
|
-
|
|
135
|
+
|
|
136
|
+
// MODIFIED BY VYZEN
|
|
137
|
+
const requiresWaveformProcessing = mediaType === 'audio' && (uploadData.ptt === true || !!options.backgroundColor);
|
|
138
|
+
// MODIFIED BY VYZEN
|
|
139
|
+
const requiresAudioBackground = options.backgroundColor && mediaType === 'audio';
|
|
140
|
+
|
|
167
141
|
const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation;
|
|
168
142
|
|
|
169
143
|
const { mediaKey, encWriteStream, bodyPath, fileEncSha256, fileSha256, fileLength, didSaveToTmpPath, opusConverted } =
|
|
@@ -208,10 +182,21 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
208
182
|
uploadData.seconds = await messages_media_1.getAudioDuration(bodyPath);
|
|
209
183
|
logger?.debug('computed audio duration');
|
|
210
184
|
}
|
|
185
|
+
|
|
186
|
+
// MODIFIED BY VYZEN
|
|
211
187
|
if (requiresWaveformProcessing) {
|
|
212
|
-
|
|
188
|
+
try {
|
|
189
|
+
uploadData.waveform = await messages_media_1.getAudioWaveform(bodyPath, logger);
|
|
190
|
+
} catch (err) {
|
|
191
|
+
logger?.warn('Failed to generate waveform, using fallback');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (!uploadData.waveform) {
|
|
195
|
+
uploadData.waveform = new Uint8Array([0,99,0,99,0,99,0,99,88,99,0,99,0,55,0,99,0,99,0,99,0,99,0,99,88,99,0,99,0,55,0,99]);
|
|
196
|
+
}
|
|
213
197
|
logger?.debug('processed waveform');
|
|
214
198
|
}
|
|
199
|
+
|
|
215
200
|
if (requiresAudioBackground) {
|
|
216
201
|
uploadData.backgroundArgb = await assertColor(options.backgroundColor);
|
|
217
202
|
logger?.debug('computed backgroundColor audio status');
|
|
@@ -290,7 +275,7 @@ const generateForwardMessageContent = (message, forceForward) => {
|
|
|
290
275
|
if (!content) {
|
|
291
276
|
throw new boom_1.Boom('no content in message', { statusCode: 400 });
|
|
292
277
|
}
|
|
293
|
-
|
|
278
|
+
|
|
294
279
|
content = (0, exports.normalizeMessageContent)(content);
|
|
295
280
|
content = WAProto_1.proto.Message.decode(WAProto_1.proto.Message.encode(content).finish());
|
|
296
281
|
let key = Object.keys(content)[0];
|
|
@@ -388,8 +373,8 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
388
373
|
m.groupInviteMessage.caption = message.groupInvite.text;
|
|
389
374
|
m.groupInviteMessage.groupJid = message.groupInvite.jid;
|
|
390
375
|
m.groupInviteMessage.groupName = message.groupInvite.subject;
|
|
391
|
-
|
|
392
|
-
|
|
376
|
+
|
|
377
|
+
|
|
393
378
|
if (options.getProfilePicUrl) {
|
|
394
379
|
const pfpUrl = await options.getProfilePicUrl(message.groupInvite.jid, 'preview');
|
|
395
380
|
if (pfpUrl) {
|
|
@@ -490,7 +475,7 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
490
475
|
throw new boom_1.Boom(`poll.selectableCount in poll should be >= 0 and <= ${message.poll.values.length}`, { statusCode: 400 });
|
|
491
476
|
}
|
|
492
477
|
m.messageContextInfo = {
|
|
493
|
-
|
|
478
|
+
|
|
494
479
|
messageSecret: message.poll.messageSecret || (0, crypto_1.randomBytes)(32),
|
|
495
480
|
};
|
|
496
481
|
const pollCreationMessage = {
|
|
@@ -499,16 +484,16 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
499
484
|
options: message.poll.values.map(optionName => ({ optionName })),
|
|
500
485
|
};
|
|
501
486
|
if (message.poll.toAnnouncementGroup) {
|
|
502
|
-
|
|
487
|
+
|
|
503
488
|
m.pollCreationMessageV2 = pollCreationMessage;
|
|
504
489
|
}
|
|
505
490
|
else {
|
|
506
491
|
if (message.poll.selectableCount === 1) {
|
|
507
|
-
|
|
492
|
+
|
|
508
493
|
m.pollCreationMessageV3 = pollCreationMessage;
|
|
509
494
|
}
|
|
510
495
|
else {
|
|
511
|
-
|
|
496
|
+
|
|
512
497
|
m.pollCreationMessage = pollCreationMessage;
|
|
513
498
|
}
|
|
514
499
|
}
|
|
@@ -758,8 +743,8 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
758
743
|
};
|
|
759
744
|
exports.generateWAMessageContent = generateWAMessageContent;
|
|
760
745
|
const generateWAMessageFromContent = (jid, message, options) => {
|
|
761
|
-
|
|
762
|
-
|
|
746
|
+
|
|
747
|
+
|
|
763
748
|
if (!options.timestamp) {
|
|
764
749
|
options.timestamp = new Date();
|
|
765
750
|
}
|
|
@@ -767,12 +752,12 @@ const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
767
752
|
const key = (0, exports.getContentType)(innerMessage);
|
|
768
753
|
const timestamp = (0, generics_1.unixTimestampSeconds)(options.timestamp);
|
|
769
754
|
const { quoted, userJid } = options;
|
|
770
|
-
|
|
755
|
+
|
|
771
756
|
if (quoted && !(0, WABinary_1.isJidNewsletter)(jid)) {
|
|
772
757
|
const participant = quoted.key.fromMe ? userJid : (quoted.participant || quoted.key.participant || quoted.key.remoteJid);
|
|
773
758
|
let quotedMsg = (0, exports.normalizeMessageContent)(quoted.message);
|
|
774
759
|
const msgType = (0, exports.getContentType)(quotedMsg);
|
|
775
|
-
|
|
760
|
+
|
|
776
761
|
if (quotedMsg) {
|
|
777
762
|
quotedMsg = WAProto_1.proto.Message.fromObject({ [msgType]: quotedMsg[msgType] });
|
|
778
763
|
const quotedContent = quotedMsg[msgType];
|
|
@@ -783,8 +768,8 @@ const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
783
768
|
contextInfo.participant = (0, WABinary_1.jidNormalizedUser)(participant);
|
|
784
769
|
contextInfo.stanzaId = quoted.key.id;
|
|
785
770
|
contextInfo.quotedMessage = quotedMsg;
|
|
786
|
-
|
|
787
|
-
|
|
771
|
+
|
|
772
|
+
|
|
788
773
|
if (jid !== quoted.key.remoteJid) {
|
|
789
774
|
contextInfo.remoteJid = quoted.key.remoteJid;
|
|
790
775
|
}
|
|
@@ -792,13 +777,13 @@ const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
792
777
|
}
|
|
793
778
|
}
|
|
794
779
|
if (
|
|
795
|
-
|
|
780
|
+
|
|
796
781
|
!!(options === null || options === void 0 ? void 0 : options.ephemeralExpiration) &&
|
|
797
|
-
|
|
782
|
+
|
|
798
783
|
key !== 'protocolMessage' &&
|
|
799
|
-
|
|
784
|
+
|
|
800
785
|
key !== 'ephemeralMessage' &&
|
|
801
|
-
|
|
786
|
+
|
|
802
787
|
!(0, WABinary_1.isJidNewsletter)(jid)) {
|
|
803
788
|
innerMessage[key].contextInfo = {
|
|
804
789
|
...(innerMessage[key].contextInfo || {}),
|
|
@@ -824,7 +809,7 @@ const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
824
809
|
exports.generateWAMessageFromContent = generateWAMessageFromContent;
|
|
825
810
|
const generateWAMessage = async (jid, content, options) => {
|
|
826
811
|
var _a;
|
|
827
|
-
|
|
812
|
+
|
|
828
813
|
options.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.child({ msgId: options.messageId });
|
|
829
814
|
return (0, exports.generateWAMessageFromContent)(jid, await (0, exports.generateWAMessageContent)(content, { newsletter: (0, WABinary_1.isJidNewsletter)(jid), ...options }), options);
|
|
830
815
|
};
|
|
@@ -848,7 +833,7 @@ const normalizeMessageContent = (content) => {
|
|
|
848
833
|
if (!content) {
|
|
849
834
|
return undefined;
|
|
850
835
|
}
|
|
851
|
-
|
|
836
|
+
|
|
852
837
|
for (let i = 0; i < 5; i++) {
|
|
853
838
|
const inner = getFutureProofMessage(content);
|
|
854
839
|
if (!inner) {
|
|
@@ -1036,10 +1021,10 @@ const downloadMediaMessage = async (message, type, options, ctx) => {
|
|
|
1036
1021
|
var _a;
|
|
1037
1022
|
if (ctx) {
|
|
1038
1023
|
if (axios_1.default.isAxiosError(error)) {
|
|
1039
|
-
|
|
1024
|
+
|
|
1040
1025
|
if (REUPLOAD_REQUIRED_STATUS.includes((_a = error.response) === null || _a === void 0 ? void 0 : _a.status)) {
|
|
1041
1026
|
ctx.logger.info({ key: message.key }, 'sending reupload media request...');
|
|
1042
|
-
|
|
1027
|
+
|
|
1043
1028
|
message = await ctx.reuploadRequest(message);
|
|
1044
1029
|
const result = await downloadMsg();
|
|
1045
1030
|
return result;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeNoiseHandler = void 0;
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
const boom_1 = require("@hapi/boom");
|
|
6
6
|
const WAProto_1 = require("../../WAProto");
|
|
7
7
|
const Defaults_1 = require("../Defaults");
|
|
@@ -87,7 +87,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
87
87
|
const { intermediate: certIntermediate } = WAProto_1.proto.CertChain.decode(certDecoded);
|
|
88
88
|
const { issuerSerial } = WAProto_1.proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details);
|
|
89
89
|
if (issuerSerial !== Defaults_1.WA_CERT_DETAILS.SERIAL) {
|
|
90
|
-
throw new boom_1.Boom('certification match failed', { statusCode: 400 });
|
|
90
|
+
throw new boom_1.Boom('certification match failed', { statusCode: 400 }); // 🅥🅨🅩🅔🅝
|
|
91
91
|
}
|
|
92
92
|
const keyEnc = encrypt(noiseKey.public);
|
|
93
93
|
await mixIntoKey(crypto_1.Curve.sharedKey(noiseKey.private, serverHello.ephemeral));
|
|
@@ -4,7 +4,7 @@ exports.encodeSignedDeviceIdentity =
|
|
|
4
4
|
exports.configureSuccessfulPairing =
|
|
5
5
|
exports.generateRegistrationNode =
|
|
6
6
|
exports.generateLoginNode = void 0;
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
const boom_1 = require("@hapi/boom");
|
|
9
9
|
const crypto_1 = require("crypto");
|
|
10
10
|
const WAProto_1 = require("../../WAProto");
|
|
@@ -76,7 +76,7 @@ const getPlatformType = (platform) => {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
79
|
-
const appVersionBuf = (0, crypto_1.createHash)('md5')
|
|
79
|
+
const appVersionBuf = (0, crypto_1.createHash)('md5') // 🅥🅨🅩🅔🅝
|
|
80
80
|
.update(config.version.join('.'))
|
|
81
81
|
.digest();
|
|
82
82
|
|
|
@@ -189,7 +189,7 @@ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, s
|
|
|
189
189
|
type: 'result',
|
|
190
190
|
id: msgId,
|
|
191
191
|
},
|
|
192
|
-
content: [
|
|
192
|
+
content: [ // 🆅🆈🆉🅴🅽
|
|
193
193
|
{
|
|
194
194
|
tag: 'pair-device-sign',
|
|
195
195
|
attrs: {},
|