Versions
The client and browser versions the profiles and checks use: the built-in offline set, overrides of it, and the current versions from the release feeds.
versions.mjs
import { applyVersionsPatch, fetchVersions, platformVersions, profile } from 'opentele2'
const patch = await fetchVersions(5000) // {} with no network
const versions = applyVersionsPatch(platformVersions(), patch)
console.log(versions.androidAppVersion, profile('TelegramAndroid', versions).appVersion)Functions
index.d.ts
function platformVersions(overrides?: Versions | null): PlatformVersions
function fetchVersions(timeoutMs?: number | null): Promise<VersionsPatch>
function applyVersionsPatch(versions: Versions | null | undefined, patch: VersionsPatch): PlatformVersions| Function | Description |
|---|---|
platform | The offline PlatformVersions (the set Python uses with OPENTELE_NO_FETCH), with the fields of overrides replaced. |
fetch | Fetches the current versions from the nine sources (Telegram Desktop, Android, Telegram X, iOS, macOS, Web K, Web A, Chrome, Firefox) in parallel. timeoutMs bounds each request, 10000 by default, and must be a positive number (else OT_INVALID_INPUT). Never rejects for the network: a source that fails leaves its fields absent. |
apply | versions with every field patch sets written onto it, except desktopAppVersion, which stays bound to the tdata version; chromeVersion rebuilds userAgent too. A wrongly typed value throws ERR_INVALID_ARG_VALUE. |
Every function that takes versions (profile, generate, validateInitParams, …) reads the
offline set when it is null or absent, with the given fields overriding it.
Types
index.d.ts
interface PlatformVersions {
androidAppVersion: string
androidAppVersionCode: number
androidSdkRange: [number, number]
androidLatestSdk: number
iosAppVersion: string
iosBuildNumber: number
iosVersionRange: [string, string]
iosSystemVersion: string
macosSystemVersion: string
desktopAppVersion: string
desktopAppVersionSuffix: string
macosAppVersion: string
macosBuildNumber: number
androidXAppVersion: string
webAVersion: string
webKVersion: string
chromeVersion: string
userAgent: string
firefoxVersion: string
}
interface VersionsPatch {
desktopAppVersion?: string
androidAppVersion?: string
androidAppVersionCode?: number
androidXAppVersion?: string
iosAppVersion?: string
iosBuildNumber?: number
macosAppVersion?: string
macosBuildNumber?: number
webKVersion?: string
webAVersion?: string
chromeVersion?: string
firefoxVersion?: string
}Versions has the fields of PlatformVersions, each optional; a full PlatformVersions is one.
In a VersionsPatch, desktopAppVersion is reported but never applied, webKVersion and
webAVersion carry their K and A suffixes, chromeVersion is <major>.0.0.0 and
firefoxVersion <major>.0.
Last updated on