n8n-nodes-whatsapp-media-decrypt
v1.2.0
Published
Custom n8n node for decrypting WhatsApp encrypted media files (.enc)
Maintainers
Readme
WhatsApp Media Decrypt - n8n Custom Node
A custom n8n node for decrypting WhatsApp encrypted media files (.enc) using mediaKey.
Package Name: n8n-nodes-whatsapp-media-decrypt
🔧 Available Decryption Methods
1. Auto (Try All Methods) - Default
Automatically tries all available methods until one succeeds:
- HKDF Library (External HKDF library)
- Baileys Library (@whiskeysockets/baileys library)
- Standard Algorithm (Internal algorithm)
2. HKDF Library
Uses an external specialized HKDF library for more accurate results.
3. Baileys Library
Uses the popular @whiskeysockets/baileys library for WhatsApp bot development.
4. Standard Algorithm
The internal algorithm developed in-house.
🧱 What is this Extension?
This is a custom node for n8n that allows you to automatically decrypt WhatsApp encrypted media files using the media key (mediaKey). The extension works with all types of WhatsApp media files such as:
- Audio Messages
- Video Messages
- Image Messages
- Document Messages
- Sticker Messages
📋 Requirements
- Node.js 18+
- n8n framework
- Media key (mediaKey) for the encrypted file
- Encrypted file URL (.enc)
Important Note: This project requires the n8n framework. The n8n-workflow and n8n-core modules are available as peerDependencies and will be available when running the project within the n8n environment.
🚀 Installation
Installing as Custom Node in Existing n8n
Copy the
WhatsAppDecryptfolder to the nodes folder in your n8n project:n8n/packages/nodes-base/nodes/WhatsAppDecrypt/Add the required libraries to package.json:
{ "dependencies": { "axios": "^1.6.0", "@whiskeysockets/baileys": "^6.0.0", "hkdf": "^0.0.2" } }Build the project:
npm run build
Installing as Standalone Package
Clone this project:
git clone <repository-url> cd n8n-nodes-whatsapp-media-decryptInstall libraries:
npm installBuild the project:
npm run buildLink the package with n8n:
npm link cd /path/to/your/n8n npm link n8n-nodes-whatsapp-media-decrypt
🛠️ How to Use
Required Inputs:
- Media URL (Required): URL of the encrypted WhatsApp media file (.enc)
- Media Key (Required): Media key for decryption (base64 encoded)
- Media Type (Required): Message type (audioMessage, videoMessage, etc.)
- Output Format (Optional): Output format (Binary Data or Base64 String)
- File Extension (Optional): Required file extension
- Decryption Method (Optional): Choose decryption method (Auto, HKDF, Baileys, Standard)
Outputs:
- Binary Data: Decrypted file as binary data (default)
- Base64 String: Decrypted file as base64 string
- Metadata: Additional file information (size, timestamp, etc.)
Usage Example:
// In n8n workflow
{
"url": "https://example.com/encrypted-media.enc",
"mediaKey": "base64-encoded-media-key",
"mediaType": "audioMessage",
"outputFormat": "binary",
"fileExtension": ".ogg",
"decryptionMethod": "auto"
}📁 Project Structure
src/
├── nodes/
│ └── WhatsAppDecrypt/
│ ├── WhatsAppDecrypt.node.ts
│ ├── logo.svg
│ └── whatsapp.svg
├── utils/
│ ├── decrypt.ts
│ ├── decrypt-baileys.ts
│ └── decrypt-hkdf.ts
└── index.ts🔧 Development
Development Commands:
# Build project
npm run build
# Development with watch mode
npm run dev
# Code linting
npm run lint
# Fix code issues
npm run lint:fixAdding New Features:
- Edit the file
src/nodes/WhatsAppDecrypt/WhatsAppDecrypt.node.ts - Add new parameters to the
propertiesarray - Modify execution logic in the
executemethod - Build the project and test changes
🐛 Troubleshooting
Common Issues:
"MAC verification failed"
- Verify the mediaKey is correct
- Try different decryption methods
- Check media type matches the file
"Failed to download file"
- Verify the file URL is correct
- Check internet connection
"Decryption failed"
- Verify mediaKey correctness
- Ensure correct message type
"Invalid media type"
- Use supported types: audioMessage, videoMessage, imageMessage, documentMessage, stickerMessage
🔍 Debugging
Enable Debug Logging:
The node includes detailed logging for troubleshooting. Check n8n logs for:
[Auto Decrypt] Trying HKDF Library
[HKDF Decrypt] Starting decryption with external HKDF library
[Auto Decrypt] Success with HKDF Library🤝 Contributing
Contributions are welcome! Please:
- Fork the project
- Create a branch for the new feature
- Implement changes with tests
- Submit a Pull Request
📝 License
MIT License
📞 Support
If you encounter issues or have questions, please:
- Open an issue on GitHub
- Check the documentation
- Review common issues in the troubleshooting section
🔗 Links
- npm Package: https://www.npmjs.com/package/n8n-nodes-whatsapp-media-decrypt
- GitHub: [Repository URL]
- n8n Documentation: https://docs.n8n.io/
Important Note: This extension is for educational and development purposes. Make sure to comply with WhatsApp's terms of service and local privacy laws when using it.
