Spaces:
Runtime error
Runtime error
Download src/utils/fetchLatestWaWebVersion.ts from oex2003/evolution-api: direct link, hf CLI and curl.
- Browser
- Download file 978 Bytes
-
https://huggingface.co/spaces/oex2003/evolution-api/resolve/refs%2Fpr%2F1/src/utils/fetchLatestWaWebVersion.ts
- Command line
-
hf download hf://spaces/oex2003/evolution-api@refs/pr/1/src/utils/fetchLatestWaWebVersion.ts
-
curl -L -o fetchLatestWaWebVersion.ts https://huggingface.co/spaces/oex2003/evolution-api/resolve/refs%2Fpr%2F1/src/utils/fetchLatestWaWebVersion.ts
978 Bytes
| import axios, { AxiosRequestConfig } from 'axios'; | |
| import { fetchLatestBaileysVersion, WAVersion } from 'baileys'; | |
| export const fetchLatestWaWebVersion = async (options: AxiosRequestConfig<{}>) => { | |
| try { | |
| const { data } = await axios.get('https://web.whatsapp.com/sw.js', { | |
| ...options, | |
| responseType: 'json', | |
| }); | |
| const regex = /\\?"client_revision\\?":\s*(\d+)/; | |
| const match = data.match(regex); | |
| if (!match?.[1]) { | |
| return { | |
| version: (await fetchLatestBaileysVersion()).version as WAVersion, | |
| isLatest: false, | |
| error: { | |
| message: 'Could not find client revision in the fetched content', | |
| }, | |
| }; | |
| } | |
| const clientRevision = match[1]; | |
| return { | |
| version: [2, 3000, +clientRevision] as WAVersion, | |
| isLatest: true, | |
| }; | |
| } catch (error) { | |
| return { | |
| version: (await fetchLatestBaileysVersion()).version as WAVersion, | |
| isLatest: false, | |
| error, | |
| }; | |
| } | |
| }; | |