angularsockets 1.0.3 → 1.4.1
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/LICENSE +21 -0
- package/README.MD +170 -0
- package/README.md +163 -1813
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.d.ts +4798 -124
- package/WAProto/index.js +14270 -302
- package/WAProto/index.ts.ts +53473 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +4 -6
- package/lib/Defaults/index.js +4 -6
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
- package/lib/Signal/libsignal.js +51 -29
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -2
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +2 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +54 -5
- package/lib/Socket/RHandler.d.ts +416 -0
- package/lib/Socket/RHandler.js +530 -0
- package/lib/Socket/business.d.ts +39 -37
- package/lib/Socket/chats.d.ts +36 -23
- package/lib/Socket/chats.js +74 -116
- package/lib/Socket/groups.d.ts +42 -33
- package/lib/Socket/groups.js +26 -9
- package/lib/Socket/index.d.ts +39 -39
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +37 -34
- package/lib/Socket/messages-recv.js +111 -29
- package/lib/Socket/messages-send.d.ts +50 -53
- package/lib/Socket/messages-send.js +213 -397
- package/lib/Socket/newsletter.d.ts +25 -21
- package/lib/Socket/newsletter.js +92 -25
- package/lib/Socket/socket.d.ts +10 -11
- package/lib/Socket/socket.js +34 -23
- package/lib/Socket/usync.d.ts +11 -12
- package/lib/Store/index.d.ts +1 -2
- package/lib/Store/index.js +1 -3
- package/lib/Store/make-in-memory-store.d.ts +22 -22
- package/lib/Store/make-in-memory-store.js +21 -13
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Auth.d.ts +0 -6
- package/lib/Types/Chat.d.ts +6 -4
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +27 -0
- package/lib/Types/GroupMetadata.d.ts +8 -0
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +59 -90
- package/lib/Types/Message.js +0 -2
- package/lib/Types/Newsletter.d.ts +97 -86
- package/lib/Types/Newsletter.js +38 -32
- package/lib/Types/Socket.d.ts +10 -7
- package/lib/Types/index.d.ts +1 -3
- package/lib/Types/index.js +1 -1
- package/lib/Utils/audioToBuffer.js +29 -0
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +13 -41
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/chat-utils.d.ts +12 -12
- package/lib/Utils/chat-utils.js +4 -19
- package/lib/Utils/crypto.d.ts +15 -15
- package/lib/Utils/crypto.js +6 -12
- package/lib/Utils/decode-wa-message.d.ts +5 -6
- package/lib/Utils/decode-wa-message.js +28 -55
- package/lib/Utils/event-buffer.d.ts +2 -2
- package/lib/Utils/event-buffer.js +2 -1
- package/lib/Utils/generics.d.ts +12 -11
- package/lib/Utils/generics.js +64 -38
- package/lib/Utils/history.d.ts +2 -2
- package/lib/Utils/history.js +1 -1
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +34 -1
- package/lib/Utils/logger.d.ts +10 -1
- package/lib/Utils/lt-hash.d.ts +2 -2
- package/lib/Utils/lt-hash.js +6 -6
- package/lib/Utils/messages-media.d.ts +40 -29
- package/lib/Utils/messages-media.js +276 -110
- package/lib/Utils/messages.d.ts +8 -10
- package/lib/Utils/messages.js +126 -317
- package/lib/Utils/noise-handler.d.ts +10 -11
- package/lib/Utils/noise-handler.js +3 -13
- package/lib/Utils/process-message.d.ts +3 -2
- package/lib/Utils/process-message.js +17 -5
- package/lib/Utils/signal.js +2 -8
- package/lib/Utils/streamToBuffer.js +15 -0
- package/lib/Utils/use-multi-file-auth-state.js +72 -242
- package/lib/Utils/validate-connection.d.ts +2 -3
- package/lib/Utils/validate-connection.js +19 -51
- package/lib/WABinary/constants.d.ts +4 -4
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +2 -2
- package/lib/WABinary/decode.js +3 -2
- package/lib/WABinary/encode.js +5 -7
- package/lib/WABinary/generic-utils.d.ts +2 -2
- package/lib/WABinary/jid-utils.d.ts +9 -4
- package/lib/WABinary/jid-utils.js +26 -5
- package/lib/WABinary/jid-utils.js.bak +83 -0
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +48 -4
- package/lib/index.js.bak +56 -0
- package/package.json +43 -35
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/registration.d.ts +0 -264
- package/lib/Socket/registration.js +0 -166
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-state.js +0 -75
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
|
@@ -32,37 +32,45 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getStatusCodeForMediaRetry = exports.decryptMediaRetryData = exports.decodeMediaRetryNode = exports.encryptMediaRetryRequest = exports.getWAUploadToServer = exports.downloadEncryptedContent = exports.downloadContentFromMessage = exports.getUrlFromDirectPath = exports.encryptedStream = exports.prepareStream = exports.getHttpStream = exports.getStream = exports.toBuffer = exports.toReadable = exports.mediaMessageSHA256B64 = exports.generateProfilePicture = exports.encodeBase64EncodedStringForUpload = exports.extractImageThumb = exports.hkdfInfoKey = void 0;
|
|
39
|
+
exports.getStatusCodeForMediaRetry = exports.decryptMediaRetryData = exports.decodeMediaRetryNode = exports.encryptMediaRetryRequest = exports.getWAUploadToServer = exports.downloadEncryptedContent = exports.downloadContentFromMessage = exports.getUrlFromDirectPath = exports.encryptedStream = exports.prepareStream = exports.getHttpStream = exports.getStream = exports.toBuffer = exports.toReadable = exports.mediaMessageSHA256B64 = exports.generateProfilePicture = exports.encodeBase64EncodedStringForUpload = exports.extractImageThumb = exports.extractVideoThumb = exports.hkdfInfoKey = void 0;
|
|
37
40
|
exports.getMediaKeys = getMediaKeys;
|
|
41
|
+
exports.uploadFile = uploadFile;
|
|
42
|
+
exports.vid2jpg = vid2jpg;
|
|
38
43
|
exports.getAudioDuration = getAudioDuration;
|
|
39
44
|
exports.getAudioWaveform = getAudioWaveform;
|
|
40
45
|
exports.generateThumbnail = generateThumbnail;
|
|
41
46
|
exports.extensionForMediaMessage = extensionForMediaMessage;
|
|
42
47
|
const boom_1 = require("@hapi/boom");
|
|
43
|
-
const
|
|
48
|
+
const axios_1 = __importDefault(require("axios"));
|
|
49
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
50
|
+
const cheerio = __importStar(require("cheerio"));
|
|
44
51
|
const Crypto = __importStar(require("crypto"));
|
|
45
52
|
const events_1 = require("events");
|
|
46
53
|
const fs_1 = require("fs");
|
|
47
54
|
const os_1 = require("os");
|
|
48
55
|
const path_1 = require("path");
|
|
56
|
+
const jimp_1 = __importDefault(require("jimp"));
|
|
49
57
|
const stream_1 = require("stream");
|
|
58
|
+
const child_process_1 = require("child_process");
|
|
50
59
|
const WAProto_1 = require("../../WAProto");
|
|
51
60
|
const Defaults_1 = require("../Defaults");
|
|
52
61
|
const WABinary_1 = require("../WABinary");
|
|
53
62
|
const crypto_1 = require("./crypto");
|
|
63
|
+
const streamToBuffer = require("./streamToBuffer")
|
|
54
64
|
const generics_1 = require("./generics");
|
|
55
65
|
const getTmpFilesDirectory = () => (0, os_1.tmpdir)();
|
|
56
66
|
const getImageProcessingLibrary = async () => {
|
|
57
67
|
const [_jimp, sharp] = await Promise.all([
|
|
58
68
|
(async () => {
|
|
59
|
-
const jimp = await (
|
|
60
|
-
.catch(() => { }));
|
|
69
|
+
const jimp = await (Promise.resolve().then(() => __importStar(require('jimp'))).catch(() => { }));
|
|
61
70
|
return jimp;
|
|
62
71
|
})(),
|
|
63
72
|
(async () => {
|
|
64
|
-
const sharp = await (
|
|
65
|
-
.catch(() => { }));
|
|
73
|
+
const sharp = await (Promise.resolve().then(() => __importStar(require('sharp'))).catch(() => { }));
|
|
66
74
|
return sharp;
|
|
67
75
|
})()
|
|
68
76
|
]);
|
|
@@ -96,18 +104,176 @@ async function getMediaKeys(buffer, mediaType) {
|
|
|
96
104
|
macKey: expandedMediaKey.slice(48, 80),
|
|
97
105
|
};
|
|
98
106
|
}
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
async function uploadFile(buffer, logger) {
|
|
108
|
+
const { fromBuffer } = await Promise.resolve().then(() => __importStar(require('file-type')));
|
|
109
|
+
const fileType = await fromBuffer(buffer);
|
|
110
|
+
if (!fileType)
|
|
111
|
+
throw new Error("Failed to detect file type.");
|
|
112
|
+
const { ext, mime } = fileType;
|
|
113
|
+
const services = [
|
|
114
|
+
{
|
|
115
|
+
name: "catbox",
|
|
116
|
+
url: "https://catbox.moe/user/api.php",
|
|
117
|
+
buildForm: () => {
|
|
118
|
+
const form = new form_data_1.default();
|
|
119
|
+
form.append("fileToUpload", buffer, {
|
|
120
|
+
filename: `file.${ext}`,
|
|
121
|
+
contentType: mime || "application/octet-stream"
|
|
122
|
+
});
|
|
123
|
+
form.append("reqtype", "fileupload");
|
|
124
|
+
return form;
|
|
125
|
+
},
|
|
126
|
+
parseResponse: res => res.data
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "pdi.moe",
|
|
130
|
+
url: "https://scdn.pdi.moe/upload",
|
|
131
|
+
buildForm: () => {
|
|
132
|
+
const form = new form_data_1.default();
|
|
133
|
+
form.append("file", buffer, {
|
|
134
|
+
filename: `file.${ext}`,
|
|
135
|
+
contentType: mime
|
|
136
|
+
});
|
|
137
|
+
return form;
|
|
138
|
+
},
|
|
139
|
+
parseResponse: res => res.data.result.url
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "qu.ax",
|
|
143
|
+
url: "https://qu.ax/upload.php",
|
|
144
|
+
buildForm: () => {
|
|
145
|
+
const form = new form_data_1.default();
|
|
146
|
+
form.append("files[]", buffer, {
|
|
147
|
+
filename: `file.${ext}`,
|
|
148
|
+
contentType: mime || "application/octet-stream"
|
|
149
|
+
});
|
|
150
|
+
return form;
|
|
151
|
+
},
|
|
152
|
+
parseResponse: res => {
|
|
153
|
+
var _a, _b, _c;
|
|
154
|
+
if (!((_c = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url))
|
|
155
|
+
throw new Error("Failed to get URL from qu.ax");
|
|
156
|
+
return res.data.files[0].url;
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "uguu.se",
|
|
161
|
+
url: "https://uguu.se/upload.php",
|
|
162
|
+
buildForm: () => {
|
|
163
|
+
const form = new form_data_1.default();
|
|
164
|
+
form.append("files[]", buffer, {
|
|
165
|
+
filename: `file.${ext}`,
|
|
166
|
+
contentType: mime || "application/octet-stream"
|
|
167
|
+
});
|
|
168
|
+
return form;
|
|
169
|
+
},
|
|
170
|
+
parseResponse: res => {
|
|
171
|
+
var _a, _b, _c;
|
|
172
|
+
if (!((_c = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url))
|
|
173
|
+
throw new Error("Failed to get URL from uguu.se");
|
|
174
|
+
return res.data.files[0].url;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "tmpfiles",
|
|
179
|
+
url: "https://tmpfiles.org/api/v1/upload",
|
|
180
|
+
buildForm: () => {
|
|
181
|
+
const form = new form_data_1.default();
|
|
182
|
+
form.append("file", buffer, {
|
|
183
|
+
filename: `file.${ext}`,
|
|
184
|
+
contentType: mime
|
|
185
|
+
});
|
|
186
|
+
return form;
|
|
187
|
+
},
|
|
188
|
+
parseResponse: res => {
|
|
189
|
+
const match = res.data.data.url.match(/https:\/\/tmpfiles\.org\/(.*)/);
|
|
190
|
+
if (!match)
|
|
191
|
+
throw new Error("Failed to parse tmpfiles URL.");
|
|
192
|
+
return `https://tmpfiles.org/dl/${match[1]}`;
|
|
193
|
+
}
|
|
105
194
|
}
|
|
106
|
-
|
|
107
|
-
|
|
195
|
+
];
|
|
196
|
+
for (const service of services) {
|
|
197
|
+
try {
|
|
198
|
+
const form = service.buildForm();
|
|
199
|
+
const res = await axios_1.default.post(service.url, form, {
|
|
200
|
+
headers: form.getHeaders()
|
|
201
|
+
});
|
|
202
|
+
const url = service.parseResponse(res);
|
|
203
|
+
return url;
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
logger === null || logger === void 0 ? void 0 : logger.debug(`[${service.name}] eror:`, (error === null || error === void 0 ? void 0 : error.message) || error);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
throw new Error("All upload services failed.");
|
|
210
|
+
}
|
|
211
|
+
async function vid2jpg(videoUrl) {
|
|
212
|
+
try {
|
|
213
|
+
const { data } = await axios_1.default.get(`https://ezgif.com/video-to-jpg?url=${encodeURIComponent(videoUrl)}`);
|
|
214
|
+
const $ = cheerio.load(data);
|
|
215
|
+
const fileToken = $('input[name="file"]').attr("value");
|
|
216
|
+
if (!fileToken) {
|
|
217
|
+
throw new Error("Failed to retrieve file token. The video URL may be invalid or inaccessible.");
|
|
218
|
+
}
|
|
219
|
+
const formData = new URLSearchParams();
|
|
220
|
+
formData.append("file", fileToken);
|
|
221
|
+
formData.append("end", "1");
|
|
222
|
+
formData.append("video-to-jpg", "Convert to JPG!");
|
|
223
|
+
const convert = await axios_1.default.post(`https://ezgif.com/video-to-jpg/${fileToken}`, formData);
|
|
224
|
+
const $2 = cheerio.load(convert.data);
|
|
225
|
+
let imageUrl = $2("#output img").first().attr("src");
|
|
226
|
+
if (!imageUrl) {
|
|
227
|
+
throw new Error("Could not locate the converted image output.");
|
|
228
|
+
}
|
|
229
|
+
if (imageUrl.startsWith("//")) {
|
|
230
|
+
imageUrl = "https:" + imageUrl;
|
|
231
|
+
}
|
|
232
|
+
else if (imageUrl.startsWith("/")) {
|
|
233
|
+
const cdnMatch = imageUrl.match(/\/(s\d+\..+?)\/.*/);
|
|
234
|
+
if (cdnMatch) {
|
|
235
|
+
imageUrl = "https://" + imageUrl.slice(2);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
imageUrl = "https://ezgif.com" + imageUrl;
|
|
239
|
+
}
|
|
108
240
|
}
|
|
241
|
+
return imageUrl;
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
throw new Error("Failed to convert video to JPG: " + error.message);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Extracts video thumbnail using FFmpeg
|
|
249
|
+
*/
|
|
250
|
+
const extractVideoThumb = async (videoPath, time = '00:00:00', size = { width: 256 }) => {
|
|
251
|
+
return new Promise((resolve, reject) => {
|
|
252
|
+
const args = [
|
|
253
|
+
'-ss', time,
|
|
254
|
+
'-i', videoPath,
|
|
255
|
+
'-y',
|
|
256
|
+
'-vf', `scale=${size.width}:-1`,
|
|
257
|
+
'-vframes', '1',
|
|
258
|
+
'-f', 'image2',
|
|
259
|
+
'-vcodec', 'mjpeg',
|
|
260
|
+
'pipe:1'
|
|
261
|
+
];
|
|
262
|
+
const ffmpeg = (0, child_process_1.spawn)('ffmpeg', args);
|
|
263
|
+
const chunks = [];
|
|
264
|
+
let errorOutput = '';
|
|
265
|
+
ffmpeg.stdout.on('data', chunk => chunks.push(chunk));
|
|
266
|
+
ffmpeg.stderr.on('data', data => {
|
|
267
|
+
errorOutput += data.toString();
|
|
268
|
+
});
|
|
269
|
+
ffmpeg.on('error', reject);
|
|
270
|
+
ffmpeg.on('close', code => {
|
|
271
|
+
if (code === 0) return resolve(Buffer.concat(chunks));
|
|
272
|
+
reject(new Error(`ffmpeg exited with code ${code}\n${errorOutput}`));
|
|
273
|
+
});
|
|
109
274
|
});
|
|
110
|
-
}
|
|
275
|
+
};
|
|
276
|
+
exports.extractVideoThumb = extractVideoThumb;
|
|
111
277
|
const extractImageThumb = async (bufferOrFilePath, width = 32) => {
|
|
112
278
|
var _a, _b;
|
|
113
279
|
if (bufferOrFilePath instanceof stream_1.Readable) {
|
|
@@ -156,23 +322,24 @@ const encodeBase64EncodedStringForUpload = (b64) => (encodeURIComponent(b64
|
|
|
156
322
|
.replace(/\=+$/, '')));
|
|
157
323
|
exports.encodeBase64EncodedStringForUpload = encodeBase64EncodedStringForUpload;
|
|
158
324
|
const generateProfilePicture = async (mediaUpload) => {
|
|
159
|
-
|
|
160
|
-
? mediaUpload
|
|
161
|
-
: typeof mediaUpload === 'object' && 'url' in mediaUpload
|
|
162
|
-
? mediaUpload.url.toString()
|
|
163
|
-
: await (0, exports.toBuffer)(mediaUpload.stream);
|
|
325
|
+
let bufferOrFilePath;
|
|
164
326
|
let img;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
327
|
+
if (Buffer.isBuffer(mediaUpload)) {
|
|
328
|
+
bufferOrFilePath = mediaUpload;
|
|
329
|
+
}
|
|
330
|
+
else if ('url' in mediaUpload) {
|
|
331
|
+
bufferOrFilePath = mediaUpload.url.toString();
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
bufferOrFilePath = await (0, exports.toBuffer)(mediaUpload.stream);
|
|
335
|
+
}
|
|
336
|
+
const jimp = await jimp_1.default.read(bufferOrFilePath);
|
|
337
|
+
const cropped = jimp.getWidth() > jimp.getHeight() ? jimp.resize(550, -1) : jimp.resize(-1, 650);
|
|
170
338
|
img = cropped
|
|
171
339
|
.quality(100)
|
|
172
|
-
.
|
|
173
|
-
.getBufferAsync(MIME_JPEG);
|
|
340
|
+
.getBufferAsync(jimp_1.default.MIME_JPEG);
|
|
174
341
|
return {
|
|
175
|
-
img: await img
|
|
342
|
+
img: await img,
|
|
176
343
|
};
|
|
177
344
|
};
|
|
178
345
|
exports.generateProfilePicture = generateProfilePicture;
|
|
@@ -183,66 +350,74 @@ const mediaMessageSHA256B64 = (message) => {
|
|
|
183
350
|
};
|
|
184
351
|
exports.mediaMessageSHA256B64 = mediaMessageSHA256B64;
|
|
185
352
|
async function getAudioDuration(buffer) {
|
|
186
|
-
const musicMetadata = await
|
|
353
|
+
const musicMetadata = await Promise.resolve().then(() => __importStar(require('music-metadata')));
|
|
187
354
|
let metadata;
|
|
355
|
+
const options = {
|
|
356
|
+
duration: true
|
|
357
|
+
};
|
|
188
358
|
if (Buffer.isBuffer(buffer)) {
|
|
189
|
-
metadata = await musicMetadata.parseBuffer(buffer, undefined,
|
|
359
|
+
metadata = await musicMetadata.parseBuffer(buffer, undefined, options);
|
|
190
360
|
}
|
|
191
361
|
else if (typeof buffer === 'string') {
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
metadata = await musicMetadata.parseStream(rStream, undefined, { duration: true });
|
|
195
|
-
}
|
|
196
|
-
finally {
|
|
197
|
-
rStream.destroy();
|
|
198
|
-
}
|
|
362
|
+
metadata = await musicMetadata.parseFile(buffer, options);
|
|
199
363
|
}
|
|
200
364
|
else {
|
|
201
|
-
metadata = await musicMetadata.parseStream(buffer, undefined,
|
|
365
|
+
metadata = await musicMetadata.parseStream(buffer, undefined, options);
|
|
202
366
|
}
|
|
203
367
|
return metadata.format.duration;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
368
|
+
}
|
|
369
|
+
const toBuffer = async (stream) => {
|
|
370
|
+
const chunks = [];
|
|
371
|
+
for await (const chunk of stream) {
|
|
372
|
+
chunks.push(chunk);
|
|
373
|
+
}
|
|
374
|
+
stream.destroy();
|
|
375
|
+
return Buffer.concat(chunks);
|
|
376
|
+
};
|
|
377
|
+
exports.toBuffer = toBuffer;
|
|
378
|
+
|
|
208
379
|
async function getAudioWaveform(buffer, logger) {
|
|
209
380
|
try {
|
|
210
|
-
const
|
|
211
|
-
let audioData
|
|
381
|
+
const { default: decoder } = await eval('import("audio-decode")')
|
|
382
|
+
let audioData
|
|
383
|
+
|
|
212
384
|
if (Buffer.isBuffer(buffer)) {
|
|
213
|
-
audioData = buffer
|
|
385
|
+
audioData = buffer
|
|
386
|
+
} else if (typeof buffer === 'string') {
|
|
387
|
+
const rStream = fs_1.createReadStream(buffer)
|
|
388
|
+
audioData = await streamToBuffer(rStream)
|
|
389
|
+
} else {
|
|
390
|
+
audioData = await streamToBuffer(buffer)
|
|
214
391
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const rawData = audioBuffer.getChannelData(0); // We only need to work with one channel of data
|
|
224
|
-
const samples = 64; // Number of samples we want to have in our final data set
|
|
225
|
-
const blockSize = Math.floor(rawData.length / samples); // the number of samples in each subdivision
|
|
226
|
-
const filteredData = [];
|
|
392
|
+
|
|
393
|
+
const audioBuffer = await decoder(audioData)
|
|
394
|
+
const rawData = audioBuffer.getChannelData(0)
|
|
395
|
+
const samples = 64
|
|
396
|
+
const blockSize = Math.floor(rawData.length / samples)
|
|
397
|
+
const filteredData = []
|
|
398
|
+
|
|
399
|
+
// === Versi TS style: ambil RATA-RATA amplitudo biar halus ===
|
|
227
400
|
for (let i = 0; i < samples; i++) {
|
|
228
|
-
|
|
229
|
-
|
|
401
|
+
let sum = 0
|
|
402
|
+
const blockStart = blockSize * i
|
|
230
403
|
for (let j = 0; j < blockSize; j++) {
|
|
231
|
-
sum
|
|
404
|
+
sum += Math.abs(rawData[blockStart + j] || 0)
|
|
232
405
|
}
|
|
233
|
-
filteredData.push(sum / blockSize)
|
|
406
|
+
filteredData.push(sum / blockSize)
|
|
234
407
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
catch (e) {
|
|
243
|
-
logger
|
|
408
|
+
|
|
409
|
+
// Normalisasi
|
|
410
|
+
const multiplier = Math.pow(Math.max(...filteredData) || 1, -1)
|
|
411
|
+
const normalizedData = filteredData.map((n) => n * multiplier)
|
|
412
|
+
|
|
413
|
+
// Hasil akhir: Uint8Array rentang 0–100
|
|
414
|
+
return new Uint8Array(normalizedData.map((n) => Math.floor(100 * n)))
|
|
415
|
+
} catch (e) {
|
|
416
|
+
logger?.debug?.('⚠️ Failed to generate waveform: ' + e)
|
|
417
|
+
return new Uint8Array(64).fill(0)
|
|
244
418
|
}
|
|
245
419
|
}
|
|
420
|
+
|
|
246
421
|
const toReadable = (buffer) => {
|
|
247
422
|
const readable = new stream_1.Readable({ read: () => { } });
|
|
248
423
|
readable.push(buffer);
|
|
@@ -250,15 +425,6 @@ const toReadable = (buffer) => {
|
|
|
250
425
|
return readable;
|
|
251
426
|
};
|
|
252
427
|
exports.toReadable = toReadable;
|
|
253
|
-
const toBuffer = async (stream) => {
|
|
254
|
-
const chunks = [];
|
|
255
|
-
for await (const chunk of stream) {
|
|
256
|
-
chunks.push(chunk);
|
|
257
|
-
}
|
|
258
|
-
stream.destroy();
|
|
259
|
-
return Buffer.concat(chunks);
|
|
260
|
-
};
|
|
261
|
-
exports.toBuffer = toBuffer;
|
|
262
428
|
const getStream = async (item, opts) => {
|
|
263
429
|
if (Buffer.isBuffer(item)) {
|
|
264
430
|
return { stream: (0, exports.toReadable)(item), type: 'buffer' };
|
|
@@ -288,12 +454,28 @@ async function generateThumbnail(file, mediaType, options) {
|
|
|
288
454
|
}
|
|
289
455
|
}
|
|
290
456
|
else if (mediaType === 'video') {
|
|
291
|
-
const imgFilename = (0, path_1.join)(getTmpFilesDirectory(), (0, generics_1.generateMessageID)() + '.jpg');
|
|
292
457
|
try {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
458
|
+
let videoPath = file;
|
|
459
|
+
if (Buffer.isBuffer(file) || file instanceof stream_1.Readable) {
|
|
460
|
+
videoPath = (0, path_1.join)(getTmpFilesDirectory(), (0, generics_1.generateMessageIDV2)() + '.mp4');
|
|
461
|
+
const buffer = Buffer.isBuffer(file) ? file : await (0, exports.toBuffer)(file);
|
|
462
|
+
await fs_1.promises.writeFile(videoPath, buffer);
|
|
463
|
+
}
|
|
464
|
+
const thumbnailBuffer = await (0, exports.extractVideoThumb)(videoPath);
|
|
465
|
+
const imgFilename = (0, path_1.join)(getTmpFilesDirectory(), (0, generics_1.generateMessageIDV2)() + '.jpg');
|
|
466
|
+
await fs_1.promises.writeFile(imgFilename, thumbnailBuffer);
|
|
467
|
+
const { buffer: processedThumbnailBuffer, original } = await (0, exports.extractImageThumb)(imgFilename);
|
|
468
|
+
thumbnail = processedThumbnailBuffer.toString('base64');
|
|
469
|
+
if (original.width && original.height) {
|
|
470
|
+
originalImageDimensions = {
|
|
471
|
+
width: original.width,
|
|
472
|
+
height: original.height,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
296
475
|
await fs_1.promises.unlink(imgFilename);
|
|
476
|
+
if (videoPath !== file) {
|
|
477
|
+
await fs_1.promises.unlink(videoPath);
|
|
478
|
+
}
|
|
297
479
|
}
|
|
298
480
|
catch (err) {
|
|
299
481
|
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.debug('could not generate video thumb: ' + err);
|
|
@@ -305,8 +487,7 @@ async function generateThumbnail(file, mediaType, options) {
|
|
|
305
487
|
};
|
|
306
488
|
}
|
|
307
489
|
const getHttpStream = async (url, options = {}) => {
|
|
308
|
-
const
|
|
309
|
-
const fetched = await axios.get(url.toString(), { ...options, responseType: 'stream' });
|
|
490
|
+
const fetched = await axios_1.default.get(url.toString(), { ...options, responseType: 'stream' });
|
|
310
491
|
return fetched.data;
|
|
311
492
|
};
|
|
312
493
|
exports.getHttpStream = getHttpStream;
|
|
@@ -321,7 +502,7 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
|
|
|
321
502
|
bodyPath = media.url;
|
|
322
503
|
}
|
|
323
504
|
else if (saveOriginalFileIfRequired) {
|
|
324
|
-
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.
|
|
505
|
+
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.generateMessageIDV2)());
|
|
325
506
|
(0, fs_1.writeFileSync)(bodyPath, buffer);
|
|
326
507
|
didSaveToTmpPath = true;
|
|
327
508
|
}
|
|
@@ -340,7 +521,6 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
|
|
|
340
521
|
};
|
|
341
522
|
}
|
|
342
523
|
catch (error) {
|
|
343
|
-
// destroy all streams with error
|
|
344
524
|
stream.destroy();
|
|
345
525
|
if (didSaveToTmpPath) {
|
|
346
526
|
try {
|
|
@@ -367,7 +547,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
367
547
|
bodyPath = media.url;
|
|
368
548
|
}
|
|
369
549
|
else if (saveOriginalFileIfRequired) {
|
|
370
|
-
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.
|
|
550
|
+
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.generateMessageIDV2)());
|
|
371
551
|
writeStream = (0, fs_1.createWriteStream)(bodyPath);
|
|
372
552
|
didSaveToTmpPath = true;
|
|
373
553
|
}
|
|
@@ -416,7 +596,6 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
416
596
|
};
|
|
417
597
|
}
|
|
418
598
|
catch (error) {
|
|
419
|
-
// destroy all streams with error
|
|
420
599
|
encWriteStream.destroy();
|
|
421
600
|
writeStream === null || writeStream === void 0 ? void 0 : writeStream.destroy();
|
|
422
601
|
aes.destroy();
|
|
@@ -449,20 +628,19 @@ const toSmallestChunkSize = (num) => {
|
|
|
449
628
|
const getUrlFromDirectPath = (directPath) => `https://${DEF_HOST}${directPath}`;
|
|
450
629
|
exports.getUrlFromDirectPath = getUrlFromDirectPath;
|
|
451
630
|
const downloadContentFromMessage = async ({ mediaKey, directPath, url }, type, opts = {}) => {
|
|
452
|
-
const
|
|
631
|
+
const isValidMediaUrl = url === null || url === void 0 ? void 0 : url.startsWith('https://mmg.whatsapp.net/');
|
|
632
|
+
const downloadUrl = isValidMediaUrl ? url : (0, exports.getUrlFromDirectPath)(directPath);
|
|
633
|
+
if (!downloadUrl) {
|
|
634
|
+
throw new boom_1.Boom('No valid media URL or directPath present in message', { statusCode: 400 });
|
|
635
|
+
}
|
|
453
636
|
const keys = await getMediaKeys(mediaKey, type);
|
|
454
637
|
return (0, exports.downloadEncryptedContent)(downloadUrl, keys, opts);
|
|
455
638
|
};
|
|
456
639
|
exports.downloadContentFromMessage = downloadContentFromMessage;
|
|
457
|
-
/**
|
|
458
|
-
* Decrypts and downloads an AES256-CBC encrypted file given the keys.
|
|
459
|
-
* Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
|
|
460
|
-
* */
|
|
461
640
|
const downloadEncryptedContent = async (downloadUrl, { cipherKey, iv }, { startByte, endByte, options } = {}) => {
|
|
462
641
|
let bytesFetched = 0;
|
|
463
642
|
let startChunk = 0;
|
|
464
643
|
let firstBlockIsIV = false;
|
|
465
|
-
// if a start byte is specified -- then we need to fetch the previous chunk as that will form the IV
|
|
466
644
|
if (startByte) {
|
|
467
645
|
const chunk = toSmallestChunkSize(startByte || 0);
|
|
468
646
|
if (chunk) {
|
|
@@ -482,7 +660,6 @@ const downloadEncryptedContent = async (downloadUrl, { cipherKey, iv }, { startB
|
|
|
482
660
|
headers.Range += endChunk;
|
|
483
661
|
}
|
|
484
662
|
}
|
|
485
|
-
// download the message
|
|
486
663
|
const fetched = await (0, exports.getHttpStream)(downloadUrl, {
|
|
487
664
|
...options || {},
|
|
488
665
|
headers,
|
|
@@ -515,8 +692,6 @@ const downloadEncryptedContent = async (downloadUrl, { cipherKey, iv }, { startB
|
|
|
515
692
|
data = data.slice(AES_CHUNK_SIZE);
|
|
516
693
|
}
|
|
517
694
|
aes = Crypto.createDecipheriv('aes-256-cbc', cipherKey, ivValue);
|
|
518
|
-
// if an end byte that is not EOF is specified
|
|
519
|
-
// stop auto padding (PKCS7) -- otherwise throws an error for decryption
|
|
520
695
|
if (endByte) {
|
|
521
696
|
aes.setAutoPadding(false);
|
|
522
697
|
}
|
|
@@ -560,8 +735,6 @@ function extensionForMediaMessage(message) {
|
|
|
560
735
|
const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options }, refreshMediaConn) => {
|
|
561
736
|
return async (stream, { mediaType, fileEncSha256B64, newsletter, timeoutMs }) => {
|
|
562
737
|
var _a, _b;
|
|
563
|
-
const { default: axios } = await import('axios');
|
|
564
|
-
// send a query JSON to obtain the url & auth token to upload our media
|
|
565
738
|
let uploadInfo = await refreshMediaConn(false);
|
|
566
739
|
let urls;
|
|
567
740
|
const hosts = [...customUploadHosts, ...uploadInfo.hosts];
|
|
@@ -579,14 +752,14 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
|
579
752
|
}
|
|
580
753
|
for (const { hostname, maxContentLengthBytes } of hosts) {
|
|
581
754
|
logger.debug(`uploading to "${hostname}"`);
|
|
582
|
-
const auth = encodeURIComponent(uploadInfo.auth);
|
|
755
|
+
const auth = encodeURIComponent(uploadInfo.auth);
|
|
583
756
|
const url = `https://${hostname}${media}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
|
|
584
757
|
let result;
|
|
585
758
|
try {
|
|
586
759
|
if (maxContentLengthBytes && reqBody.length > maxContentLengthBytes) {
|
|
587
760
|
throw new boom_1.Boom(`Body too large for "${hostname}"`, { statusCode: 413 });
|
|
588
761
|
}
|
|
589
|
-
const body = await
|
|
762
|
+
const body = await axios_1.default.post(url, reqBody, {
|
|
590
763
|
...options,
|
|
591
764
|
headers: {
|
|
592
765
|
...options.headers || {},
|
|
@@ -614,7 +787,7 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
|
614
787
|
}
|
|
615
788
|
}
|
|
616
789
|
catch (error) {
|
|
617
|
-
if (
|
|
790
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
618
791
|
result = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
619
792
|
}
|
|
620
793
|
const isLast = hostname === ((_b = hosts[uploadInfo.hosts.length - 1]) === null || _b === void 0 ? void 0 : _b.hostname);
|
|
@@ -631,9 +804,6 @@ exports.getWAUploadToServer = getWAUploadToServer;
|
|
|
631
804
|
const getMediaRetryKey = (mediaKey) => {
|
|
632
805
|
return (0, crypto_1.hkdf)(mediaKey, 32, { info: 'WhatsApp Media Retry Notification' });
|
|
633
806
|
};
|
|
634
|
-
/**
|
|
635
|
-
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
|
|
636
|
-
*/
|
|
637
807
|
const encryptMediaRetryRequest = async (key, mediaKey, meId) => {
|
|
638
808
|
const recp = { stanzaId: key.id };
|
|
639
809
|
const recpBuffer = WAProto_1.proto.ServerErrorReceipt.encode(recp).finish();
|
|
@@ -648,9 +818,6 @@ const encryptMediaRetryRequest = async (key, mediaKey, meId) => {
|
|
|
648
818
|
type: 'server-error'
|
|
649
819
|
},
|
|
650
820
|
content: [
|
|
651
|
-
// this encrypt node is actually pretty useless
|
|
652
|
-
// the media is returned even without this node
|
|
653
|
-
// keeping it here to maintain parity with WA Web
|
|
654
821
|
{
|
|
655
822
|
tag: 'encrypt',
|
|
656
823
|
attrs: {},
|
|
@@ -664,7 +831,6 @@ const encryptMediaRetryRequest = async (key, mediaKey, meId) => {
|
|
|
664
831
|
attrs: {
|
|
665
832
|
jid: key.remoteJid,
|
|
666
833
|
'from_me': (!!key.fromMe).toString(),
|
|
667
|
-
// @ts-ignore
|
|
668
834
|
participant: key.participant || undefined
|
|
669
835
|
}
|
|
670
836
|
}
|
package/lib/Utils/messages.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Logger } from 'pino';
|
|
4
1
|
import { type Transform } from 'stream';
|
|
5
2
|
import { proto } from '../../WAProto';
|
|
3
|
+
import { ILogger } from './logger';
|
|
6
4
|
import { AnyMediaMessageContent, AnyMessageContent, MediaGenerationOptions, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, MessageUserReceipt, WAMessage, WAMessageContent, WAProto } from '../Types';
|
|
7
5
|
import { MediaDownloadOptions } from './messages-media';
|
|
8
6
|
/**
|
|
@@ -11,7 +9,7 @@ import { MediaDownloadOptions } from './messages-media';
|
|
|
11
9
|
* @returns the URL, eg. https://google.com
|
|
12
10
|
*/
|
|
13
11
|
export declare const extractUrlFromText: (text: string) => string | undefined;
|
|
14
|
-
export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions[
|
|
12
|
+
export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions["getUrlInfo"], logger: MessageGenerationOptions["logger"]) => Promise<import("../Types").WAUrlInfo | undefined>;
|
|
15
13
|
export declare const prepareWAMessageMedia: (message: AnyMediaMessageContent, options: MediaGenerationOptions) => Promise<proto.Message>;
|
|
16
14
|
export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number) => proto.Message;
|
|
17
15
|
/**
|
|
@@ -40,13 +38,13 @@ export declare const extractMessageContent: (content: WAMessageContent | undefin
|
|
|
40
38
|
/**
|
|
41
39
|
* Returns the device predicted by message ID
|
|
42
40
|
*/
|
|
43
|
-
export declare const getDevice: (id: string) => "
|
|
41
|
+
export declare const getDevice: (id: string) => "web" | "unknown" | "android" | "ios" | "desktop";
|
|
44
42
|
/** Upserts a receipt in the message */
|
|
45
|
-
export declare const updateMessageWithReceipt: (msg: Pick<WAMessage,
|
|
43
|
+
export declare const updateMessageWithReceipt: (msg: Pick<WAMessage, "userReceipt">, receipt: MessageUserReceipt) => void;
|
|
46
44
|
/** Update the message with a new reaction */
|
|
47
|
-
export declare const updateMessageWithReaction: (msg: Pick<WAMessage,
|
|
45
|
+
export declare const updateMessageWithReaction: (msg: Pick<WAMessage, "reactions">, reaction: proto.IReaction) => void;
|
|
48
46
|
/** Update the message with a new poll update */
|
|
49
|
-
export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage,
|
|
47
|
+
export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage, "pollUpdates">, update: proto.IPollUpdate) => void;
|
|
50
48
|
type VoteAggregation = {
|
|
51
49
|
name: string;
|
|
52
50
|
voters: string[];
|
|
@@ -66,12 +64,12 @@ export declare const aggregateMessageKeysNotFromMe: (keys: proto.IMessageKey[])
|
|
|
66
64
|
}[];
|
|
67
65
|
type DownloadMediaMessageContext = {
|
|
68
66
|
reuploadRequest: (msg: WAMessage) => Promise<WAMessage>;
|
|
69
|
-
logger:
|
|
67
|
+
logger: ILogger;
|
|
70
68
|
};
|
|
71
69
|
/**
|
|
72
70
|
* Downloads the given message. Throws an error if it's not a media message
|
|
73
71
|
*/
|
|
74
|
-
export declare const downloadMediaMessage: <Type extends "
|
|
72
|
+
export declare const downloadMediaMessage: <Type extends "buffer" | "stream">(message: WAMessage, type: Type, options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Type extends "buffer" ? Buffer<ArrayBufferLike> : Transform>;
|
|
75
73
|
/** Checks whether the given message is a media message; if it is returns the inner content */
|
|
76
74
|
export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
77
75
|
export {};
|