feat(server): run the WhatsApp channel on whatsapp-web.js (P1.7)
Baileys depends on libsignal (GPL-3.0), which the sidecar bundled. The WhatsApp adapter now drives WhatsApp Web through whatsapp-web.js and keeps its public shape: start, stop, status with the pairing QR, send and inbound text. LocalAuth stores the session as a browser profile in <dataDir>/channels/whatsapp; the old Baileys state is left untouched. The browser comes from whatsapp-browser.ts: CHROME_PATH or PUPPETEER_EXECUTABLE_PATH, then an installed Chrome, Edge or Chromium (Windows, macOS, Linux), then a Chrome for Testing build downloaded on the first start into <dataDir>/browsers, with progress in the status. The root .puppeteerrc.cjs stops npm install from downloading a browser. The sidecar build keeps whatsapp-web.js external: bundled, it fails on __dirname and would inline LGPL node-webpmux. Text only, so ffmpeg is never needed. New dependencies, pinned: whatsapp-web.js 1.34.7 (Apache-2.0) and @puppeteer/browsers 2.13.0 (Apache-2.0). Transitive: puppeteer, puppeteer-core, chromium-bidi, webdriver-bidi-protocol (Apache-2.0), devtools-protocol (BSD-3-Clause), extract-zip (BSD-2-Clause), fluent-ffmpeg and the rest (MIT or ISC), and node-webpmux (LGPL-3.0-or-later, shipped as a separate package; needs the license review). Removed: @whiskeysockets/baileys and libsignal. UF-020 is now Fixed; ADR-0005 records the consequences.
This commit is contained in:
@@ -37,7 +37,7 @@ export const CHANNEL_VAULT_KEYS: Record<ChannelPlatform, string[]> = {
|
||||
telegram: ['telegram_bot_token'],
|
||||
discord: ['discord_bot_token'],
|
||||
slack: ['slack_app_token', 'slack_bot_token'],
|
||||
whatsapp: [], // No user-entered token; Baileys state uses an encrypted Vault entry.
|
||||
whatsapp: [], // No user-entered token; the WhatsApp Web session is a local browser profile.
|
||||
};
|
||||
|
||||
interface ChannelVault {
|
||||
@@ -169,11 +169,10 @@ export class ChannelManager {
|
||||
return new SlackAdapter({ appToken, botToken, onMessage, log: this.opts.log });
|
||||
}
|
||||
if (platform === 'whatsapp') {
|
||||
// No user-entered credential: Baileys pairs via QR and persists all
|
||||
// resulting session state through the encrypted Vault adapter.
|
||||
// No user-entered credential: whatsapp-web.js pairs via QR and keeps
|
||||
// the session under <dataDir>/channels/whatsapp.
|
||||
return new WhatsAppAdapter({
|
||||
dataDir: this.opts.dataDir,
|
||||
vault: this.opts.vault,
|
||||
onMessage,
|
||||
log: this.opts.log,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user