Fingerprints
Checks of the fields a client sends in initConnection, the tz_offset Telegram Desktop adds,
the TL layer and msg ids. The messages are character for character those of the Python package.
validate.mjs
import { generate, issuesMessage, validateInitParams } from 'opentele2'
const device = generate('TelegramDesktop', 'account-42', 'windows')
const issues = validateInitParams(device, null, 'strict')
console.log(issues.length === 0 ? 'clean' : issuesMessage(issues))Validation
index.d.ts
function validateInitParams(profile: ApiProfile, versions?: Versions | null,
mode?: 'off' | 'warn' | 'strict'): Array<Issue>
function checkVersions(profile: ApiProfile, versions?: Versions | null): Array<Issue>
function issuesMessage(issues: Array<Issue>): string
interface Issue {
kind: 'UnknownLangPack' | 'ShortLangCode' | 'MissingRegion' | 'EmptyDeviceModel'
| 'EmptySystemVersion' | 'EmptyAppVersion' | 'ApiIdMismatch' | 'AppVersionMajor'
| 'AndroidSdkRange'
severity: 'note' | 'warning' | 'error'
message: string
}| Function | Description |
|---|---|
validate | The findings of validate_ for profile, strict exactly when mode is 'strict' (default 'warn'); each finding has the severity of mode. versions overrides the offline versions the strict check compares with. |
check | The version findings alone, each an 'error': the app version major of Android, iOS, Telegram Desktop and macOS profiles, and the Android SDK range. |
issuesMessage(issues) | The message validate_params warns or raises with: a header line, then one - line per issue. |
Severity 'note' is returned only (mode 'off'), 'warning' is warned about ('warn') and
'error' is raised ('strict').
FingerprintConfig
index.d.ts
function fingerprintConfig(options?: FingerprintConfigOptions | null): FingerprintConfig
function validateFingerprint(config: FingerprintConfig, profile: ApiProfile, versions?: Versions | null): Array<Issue>
function effectiveLayer(config: FingerprintConfig): number
interface FingerprintConfig {
strictMode: 'off' | 'warn' | 'strict'
autoValidate: boolean
preferredTransport: string
warnOnLayerMismatch: boolean
layerOverride?: number
randomizeMsgIdOffset: boolean
msgIdOffset: number
}
interface FingerprintConfigOptions {
strictMode?: 'off' | 'warn' | 'strict'
autoValidate?: boolean
preferredTransport?: string
warnOnLayerMismatch?: boolean
layerOverride?: number
randomizeMsgIdOffset?: boolean
msgIdOffset?: number
}| Function | Description |
|---|---|
fingerprint | A config with the defaults ('warn', auto validation, 'obfuscated', layer mismatch warnings, no layer override, a randomized offset), each replaced by the option given; without msgIdOffset the offset is drawn from the OS random source. |
validate | The issues validate_params would surface: none with autoValidate off or mode 'off', else validateInitParams under the configured mode. |
effectiveLayer(config) | layerOverride when set, else LAYER. Pass the MTProto library’s layer as the override to match the Python package, which answers with Telethon’s layer. |
Layer, time zone and msg ids
index.d.ts
const LAYER: number // 230
const LAYER_TOLERANCE: number // 15
const MSG_ID_OFFSET_MAX: number
function tzOffset(offsetSeconds: number): number
function msgIdOffset(): number
function isValidMsgId(msgId: bigint | number, fromClient: boolean, nowUnix: number): boolean| Name | Description |
|---|---|
LAYER | The TL schema layer opentele2 advertises: the layer of the api.tl shipped by Telegram Desktop 7.3.1. |
LAYER_TOLERANCE | The largest distance from LAYER the layer_match check passes. |
tz | The tz_offset for a local UTC offset: wrapped by whole days into -12 h..+14 h, then rounded to a multiple of 900 seconds, halves away from zero. Pass -new Date( for the local offset. |
msgIdOffset() | A random msg id offset in 0..=0xFFFF from the OS CSPRNG. |
MSG_ID_OFFSET_MAX | The largest offset msgIdOffset draws. |
is | Whether msgId is plausible at nowUnix: positive, odd from the client and even otherwise, its upper 32 bits within 300 seconds of nowUnix. |
initConnectionOptions in opentele2/mtcute turns a profile into the
options mtcute sends, with tz_offset for the tdesktop lang pack.
Last updated on