fix: update fetchLatestWaWebVersion to retrieve client revision from new endpoint (#1234)

This commit is contained in:
Wender Teixeira
2025-03-01 13:17:34 -03:00
committed by GitHub
parent cfbfcd8e14
commit 36690fc462

View File

@@ -288,16 +288,31 @@ export const fetchLatestBaileysVersion = async(options: AxiosRequestConfig<{}> =
*/ */
export const fetchLatestWaWebVersion = async(options: AxiosRequestConfig<{}>) => { export const fetchLatestWaWebVersion = async(options: AxiosRequestConfig<{}>) => {
try { try {
const result = await axios.get( const { data } = await axios.get(
'https://web.whatsapp.com/check-update?version=1&platform=web', 'https://web.whatsapp.com/sw.js',
{ {
...options, ...options,
responseType: 'json' responseType: 'json'
} }
) )
const version = result.data.currentVersion.split('.')
const regex = /\\?"client_revision\\?":\s*(\d+)/
const match = data.match(regex)
if(!match?.[1]) {
return {
version: baileysVersion as WAVersion,
isLatest: false,
error: {
message: 'Could not find client revision in the fetched content'
}
}
}
const clientRevision = match[1]
return { return {
version: [+version[0], +version[1], +version[2]] as WAVersion, version: [2, 3000, +clientRevision] as WAVersion,
isLatest: true isLatest: true
} }
} catch(error) { } catch(error) {