fyoutoo 1.0.0 → 1.0.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.
@@ -228,12 +228,18 @@ export const toReadable = (buffer) => {
228
228
  return readable;
229
229
  };
230
230
 
231
+ const safeDestroyStream = (stream) => {
232
+ if (!stream) return;
233
+ if (typeof stream.destroy === 'function') return stream.destroy();
234
+ if (typeof stream.cancel === 'function') return stream.cancel();
235
+ };
236
+
231
237
  export const toBuffer = async (stream) => {
232
238
  const chunks = [];
233
239
  for await (const chunk of stream) {
234
240
  chunks.push(chunk);
235
241
  }
236
- stream.destroy();
242
+ safeDestroyStream(stream);
237
243
  return Buffer.concat(chunks);
238
244
  };
239
245
 
@@ -341,7 +347,7 @@ export const encryptedStream = async (media, mediaType, { logger, saveOriginalFi
341
347
  const originalFinishPromise = originalFileStream ? once(originalFileStream, 'finish') : Promise.resolve();
342
348
  encFileWriteStream.end();
343
349
  originalFileStream?.end?.();
344
- stream.destroy();
350
+ safeDestroyStream(stream);
345
351
 
346
352
  await encFinishPromise;
347
353
  await originalFinishPromise;
@@ -363,7 +369,7 @@ export const encryptedStream = async (media, mediaType, { logger, saveOriginalFi
363
369
  hmac.destroy();
364
370
  sha256Plain.destroy();
365
371
  sha256Enc.destroy();
366
- stream.destroy();
372
+ safeDestroyStream(stream);
367
373
  try {
368
374
  await fs.unlink(encFilePath);
369
375
  if (originalFilePath) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fyoutoo",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "description": "A WebSockets library for interacting with WhatsApp Web",
6
6
  "keywords": [
7
7
  "whatsapp",