wwebjs-electron
Advanced tools
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Read(//home/targino/Documentos/GitHub/UniExpress/src/views/**)", | ||
| "Read(//home/targino/Documentos/GitHub/UniExpress/**)", | ||
| "Bash(git rebase:*)", | ||
| "Bash(git commit:*)", | ||
| "Bash(npm version:*)", | ||
| "Bash(npm publish:*)" | ||
| ], | ||
| "deny": [], | ||
| "ask": [] | ||
| } | ||
| } |
+1
-1
| { | ||
| "name": "wwebjs-electron", | ||
| "version": "1.33.2", | ||
| "version": "1.33.3", | ||
| "description": "Library for interacting with the WhatsApp Web API through electron", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
+134
-8
@@ -8,3 +8,3 @@ <div align="center"> | ||
| <p> | ||
| <a href="https://www.npmjs.com/package/whatsapp-web.js"><img src="https://img.shields.io/npm/v/whatsapp-web.js.svg" alt="npm" /></a> | ||
| <a href="https://www.npmjs.com/package/wwebjs-electron"><img src="https://img.shields.io/npm/v/wwebjs-electron.svg" alt="npm" /></a> | ||
| <a href="https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765"><img src="https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg" alt="Depfu" /></a> | ||
@@ -18,5 +18,5 @@ <img src="https://img.shields.io/badge/WhatsApp_Web-2.3000.1017054665-brightgreen.svg" alt="WhatsApp_Web 2.2346.52" /> | ||
| ## About | ||
| **A WhatsApp API client that connects through the WhatsApp Web browser app** | ||
| **A WhatsApp API client optimized for Electron applications** | ||
| The library works by launching the WhatsApp Web browser application and managing it using Puppeteer to create an instance of WhatsApp Web, thereby mitigating the risk of being blocked. The WhatsApp API client connects through the WhatsApp Web browser app, accessing its internal functions. This grants you access to nearly all the features available on WhatsApp Web, enabling dynamic handling similar to any other Node.js application. | ||
| wwebjs-electron is a fork of whatsapp-web.js specifically optimized for use with Electron applications. It works seamlessly with puppeteer-in-electron to provide a native desktop WhatsApp experience. The library connects through WhatsApp Web using Puppeteer within Electron's BrowserView, providing access to all WhatsApp Web features while maintaining the security and performance benefits of Electron. | ||
@@ -37,4 +37,12 @@ > [!IMPORTANT] | ||
| The module is now available on npm! `npm i whatsapp-web.js` | ||
| The module is now available on npm! `npm i wwebjs-electron` | ||
| ### Required Dependencies for Electron Integration | ||
| For proper Electron integration, you also need to install these dependencies: | ||
| ```bash | ||
| npm i wwebjs-electron puppeteer-core puppeteer-in-electron | ||
| ``` | ||
| > [!NOTE] | ||
@@ -74,9 +82,88 @@ > **Node ``v18+`` is required.** | ||
| ### Basic Electron Implementation | ||
| ```js | ||
| const { Client } = require('whatsapp-web.js'); | ||
| const { app, BrowserWindow, BrowserView } = require('electron'); | ||
| const { Client, LocalAuth } = require('wwebjs-electron'); | ||
| const pie = require('puppeteer-in-electron'); | ||
| const puppeteer = require('puppeteer-core'); | ||
| const client = new Client(); | ||
| // Initialize puppeteer-in-electron | ||
| pie.initialize(app); | ||
| app.whenReady().then(async () => { | ||
| // Create main window | ||
| const mainWindow = new BrowserWindow({ | ||
| width: 1200, | ||
| height: 800, | ||
| webPreferences: { | ||
| nodeIntegration: false, | ||
| contextIsolation: true | ||
| } | ||
| }); | ||
| // Connect browser | ||
| const browser = await pie.connect(app, puppeteer); | ||
| // Create BrowserView for WhatsApp | ||
| const whatsappView = new BrowserView({ | ||
| webPreferences: { | ||
| nodeIntegration: false, | ||
| contextIsolation: true, | ||
| webSecurity: false | ||
| } | ||
| }); | ||
| // Get Puppeteer page from BrowserView | ||
| const page = await pie.getPage(browser, whatsappView); | ||
| // Set user agent | ||
| await page.setUserAgent( | ||
| 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' | ||
| ); | ||
| // Create WhatsApp client using the Puppeteer page | ||
| const client = new Client({ | ||
| authStrategy: new LocalAuth(), | ||
| page: page | ||
| }); | ||
| client.on('qr', (qr) => { | ||
| console.log('QR RECEIVED', qr); | ||
| // Display QR code to user | ||
| }); | ||
| client.on('ready', () => { | ||
| console.log('WhatsApp Client is ready!'); | ||
| }); | ||
| client.on('message', async (msg) => { | ||
| if (msg.body === '!ping') { | ||
| await msg.reply('π€ Pong!'); | ||
| } | ||
| }); | ||
| // Add BrowserView to window | ||
| mainWindow.addBrowserView(whatsappView); | ||
| mainWindow.setBrowserView(whatsappView); | ||
| // Set BrowserView bounds | ||
| const { width, height } = mainWindow.getContentBounds(); | ||
| whatsappView.setBounds({ x: 0, y: 0, width, height }); | ||
| // Initialize client | ||
| await client.initialize(); | ||
| }); | ||
| ``` | ||
| ### Standalone Usage (Compatible with original whatsapp-web.js) | ||
| ```js | ||
| const { Client, LocalAuth } = require('wwebjs-electron'); | ||
| const client = new Client({ | ||
| authStrategy: new LocalAuth() | ||
| }); | ||
| client.on('qr', (qr) => { | ||
| // Generate and scan this code with your phone | ||
| console.log('QR RECEIVED', qr); | ||
@@ -101,3 +188,42 @@ }); | ||
| ## Key Differences from whatsapp-web.js | ||
| wwebjs-electron provides several enhancements specifically designed for Electron applications: | ||
| - **Native Electron Integration**: Works seamlessly with Electron's BrowserView and BrowserWindow | ||
| - **puppeteer-in-electron Support**: Optimized to work with puppeteer-in-electron for better performance | ||
| - **Enhanced Security**: Maintains Electron's security model while providing full WhatsApp functionality | ||
| - **Desktop-First Design**: Built specifically for desktop applications rather than web browsers | ||
| - **Improved Resource Management**: Better memory and CPU usage in Electron environments | ||
| - **Custom User Agent Support**: Easy configuration for desktop-specific user agents | ||
| ### Installation with Electron | ||
| 1. Install the required packages: | ||
| ```bash | ||
| npm install wwebjs-electron puppeteer-core puppeteer-in-electron | ||
| ``` | ||
| 2. Initialize puppeteer-in-electron in your main process: | ||
| ```js | ||
| const pie = require('puppeteer-in-electron'); | ||
| pie.initialize(app); | ||
| ``` | ||
| 3. Use the provided Electron integration pattern as shown in the examples above. | ||
| ### Recommended Versions | ||
| For optimal compatibility, use these specific versions: | ||
| ```json | ||
| { | ||
| "wwebjs-electron": "^1.33.2", | ||
| "puppeteer-core": "^24.19.0", | ||
| "puppeteer-in-electron": "^3.0.5" | ||
| } | ||
| ``` | ||
| These versions have been tested together and provide the most stable experience. | ||
| ## Supported features | ||
@@ -180,3 +306,3 @@ | ||
| [gitHub]: https://github.com/pedroslopez/whatsapp-web.js | ||
| [npm]: https://npmjs.org/package/whatsapp-web.js | ||
| [npm]: https://npmjs.org/package/wwebjs-electron | ||
| [nodejs]: https://nodejs.org/en/download/ | ||
@@ -183,0 +309,0 @@ [examples]: https://github.com/pedroslopez/whatsapp-web.js/blob/master/example.js |
+1
-0
| # Release sync for v1.33.2 | ||
| # Release sync for v1.33.2 | ||
| # Release sync for v1.33.2 | ||
| # Release sync for v1.33.2 |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
456199
0.88%58
1.75%9913
0.13%312
67.74%38
5.56%