Fix fetchLatestWaWebVersion to bypass WhatsApp anti-bot detection with minimal headers (#1883)
* fix: fetchLatestWaWebVersion to curl * fix: lint * fix: fetchLatestWaWebVersion to bypass WhatsApp anti-bot detection with minimal headers --------- Co-authored-by: João Lucas <jlucaso@hotmail.com>
This commit is contained in:
+12
-2
@@ -274,11 +274,21 @@ export const fetchLatestBaileysVersion = async (options: RequestInit = {}) => {
|
||||
*/
|
||||
export const fetchLatestWaWebVersion = async (options: RequestInit = {}) => {
|
||||
try {
|
||||
// Absolute minimal headers required to bypass anti-bot detection
|
||||
const defaultHeaders = {
|
||||
'sec-fetch-site': 'none',
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
|
||||
}
|
||||
|
||||
const headers = { ...defaultHeaders, ...options.headers }
|
||||
|
||||
const response = await fetch('https://web.whatsapp.com/sw.js', {
|
||||
dispatcher: options.dispatcher,
|
||||
...options,
|
||||
method: 'GET',
|
||||
headers: options.headers
|
||||
headers
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Boom(`Failed to fetch sw.js: ${response.statusText}`, { statusCode: response.status })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user