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:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user