Describe the bug
Calling downloadMediaMessage on a message with an audio file sent as a "document" causes a decryption error.
The same situation described on #420.
The returned stream throws an error event during the execution of the pipe call on downloadEncryptedContent.
Error: error:1C800064:Provider routines::bad decrypt
at Decipheriv.final (node:internal/crypto/cipher:193:29)
at Transform.final [as _final] (/app/node_modules/@whiskeysockets/baileys/lib/Utils/messages-media.js:498:31)
at callFinal (node:internal/streams/writable:698:12)
at prefinish (node:internal/streams/writable:710:7)
at finishMaybe (node:internal/streams/writable:720:5)
at Writable.end (node:internal/streams/writable:634:5)
at IncomingMessage.onend (node:internal/streams/readable:705:10)
at Object.onceWrapper (node:events:627:28)
at IncomingMessage.emit (node:events:525:35)
at IncomingMessage.emit (node:domain:552:15) {
library: 'Provider routines',
reason: 'bad decrypt',
code: 'ERR_OSSL_BAD_DECRYPT'
}
From what I could understand, the wrong "literal string" is chosen by Baileys for the HKDF function.
In the reveng docs, it seems that the text WhatsApp Audio Keys should be used, and not WhatsApp Document Keys.
However, the mediaType sent to the downloadContentFromMessage method is based on the message object key.
So, if it is a "documentMessage", the type will be document, even if the "documentMessage" contains an "audio file", leading to the error.
To Reproduce
Send an audio file to the phone connected to Baileys as a document:
On Baileys, call downloadMediaMessage
// Received message example, it's an "audio/ogg" MIME, but in a "documentMessage"
// {
// "key": {"id": "ABCD", "remoteJid": "123@s.whatsapp.net"},
// "messageTimestamp": 1710167093,
// "message": {
// "documentMessage": {
// "url": "https://mmg.whatsapp.net...",
// "mimetype": "audio/ogg",
// "mediaKey": "xxxx"
// },
// "messageContextInfo": {}
// }
// }
Describe the bug Calling
downloadMediaMessage
on a message with an audio file sent as a "document" causes a decryption error. The same situation described on #420.The returned stream throws an error event during the execution of the pipe call on
downloadEncryptedContent
.From what I could understand, the wrong "literal string" is chosen by Baileys for the HKDF function. In the reveng docs, it seems that the text
WhatsApp Audio Keys
should be used, and notWhatsApp Document Keys
.However, the
mediaType
sent to thedownloadContentFromMessage
method is based on the message object key. So, if it is a "documentMessage", the type will bedocument
, even if the "documentMessage" contains an "audio file", leading to the error.To Reproduce
Send an audio file to the phone connected to Baileys as a document:
On Baileys, call
downloadMediaMessage
import { downloadMediaMessage } from '@whiskeysockets/baileys' await downloadMediaMessage(m, 'stream', {}, { logger, reuploadRequest: sock.updateMediaMessage })