feat: add makeWASocketAutoVersion for automatic version fetching

Adds a new async function that automatically fetches the latest
WhatsApp Web version from web.whatsapp.com before connecting.

Usage:
```typescript
// Option 1: Auto-fetch version (recommended)
const sock = await makeWASocketAutoVersion({ auth: state })

// Option 2: Manual version (existing behavior)
const sock = makeWASocket({ auth: state })
```

Benefits:
- No need to update library for version changes
- Automatic fallback to bundled version if fetch fails
- Logged warnings when using fallback
This commit is contained in:
Claude
2026-01-21 16:38:46 +00:00
parent b9a7c2cabc
commit 76e080daec
4 changed files with 55 additions and 2 deletions
+7
View File
@@ -49,6 +49,13 @@ export type SocketConfig = {
logger: ILogger
/** version to connect with */
version: WAVersion
/**
* Automatically fetch the latest WhatsApp Web version on connect.
* When enabled, fetches from web.whatsapp.com before connecting.
* Falls back to bundled version if fetch fails.
* @default false
*/
fetchLatestVersion: boolean
/** override browser config */
browser: WABrowserDescription
/** agent used for fetch requests -- uploading/downloading media */