npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

n8n-nodes-whatsapp-media-decrypt

v1.2.0

Published

Custom n8n node for decrypting WhatsApp encrypted media files (.enc)

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

  1. Copy the WhatsAppDecrypt folder to the nodes folder in your n8n project:

    n8n/packages/nodes-base/nodes/WhatsAppDecrypt/
  2. Add the required libraries to package.json:

    {
      "dependencies": {
        "axios": "^1.6.0",
        "@whiskeysockets/baileys": "^6.0.0",
        "hkdf": "^0.0.2"
      }
    }
  3. Build the project:

    npm run build

Installing as Standalone Package

  1. Clone this project:

    git clone <repository-url>
    cd n8n-nodes-whatsapp-media-decrypt
  2. Install libraries:

    npm install
  3. Build the project:

    npm run build
  4. Link the package with n8n:

    npm link
    cd /path/to/your/n8n
    npm link n8n-nodes-whatsapp-media-decrypt

🛠️ How to Use

Required Inputs:

  1. Media URL (Required): URL of the encrypted WhatsApp media file (.enc)
  2. Media Key (Required): Media key for decryption (base64 encoded)
  3. Media Type (Required): Message type (audioMessage, videoMessage, etc.)
  4. Output Format (Optional): Output format (Binary Data or Base64 String)
  5. File Extension (Optional): Required file extension
  6. 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:fix

Adding New Features:

  1. Edit the file src/nodes/WhatsAppDecrypt/WhatsAppDecrypt.node.ts
  2. Add new parameters to the properties array
  3. Modify execution logic in the execute method
  4. Build the project and test changes

🐛 Troubleshooting

Common Issues:

  1. "MAC verification failed"

    • Verify the mediaKey is correct
    • Try different decryption methods
    • Check media type matches the file
  2. "Failed to download file"

    • Verify the file URL is correct
    • Check internet connection
  3. "Decryption failed"

    • Verify mediaKey correctness
    • Ensure correct message type
  4. "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:

  1. Fork the project
  2. Create a branch for the new feature
  3. Implement changes with tests
  4. Submit a Pull Request

📝 License

MIT License

📞 Support

If you encounter issues or have questions, please:

  1. Open an issue on GitHub
  2. Check the documentation
  3. 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.