npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mtcute/tl

v0.18.0-rc.5

Published

TL schema used for mtcute

Downloads

2,233

Readme

@mtcute/tl

TL schema and related utils used for mtcute.

Generated from TL layer 194 (last updated on 20.11.2024).

About

This package contains JSON schema, type declarations, binary (de-)serialization, errors, RSA keys and helper functions.

Package's major version is always TL schema layer number, so version 42.0.0 means that this version was generated from TL layer 42.

  • JSON schema, types, binary (de-)serialization and helper functions are generated directly from .tl files that are automatically fetched from multiple sources and are merged together.
  • Errors are generated from errors.csv and official Telegram errors JSON file.
  • RSA keys info is generated based on manually extracted PEMs from Telegram for Android source code.

Exports

Root

TypeScript typings and type helpers generated from the schema.

By default, all types are immutable (have their fields marked as readonly). That is because most of the time you don't really need to modify the objects, and modifying them will only lead to confusion. However, there are still valid use-cases for mutable TL objects, so you can use exported tl.Mutable helper type to make a given object type mutable.

tl is exported as a namespace to allow better code insights, as well as to avoid cluttering global namespace and very long import statements.

MTProto schema is available in namespace mtp, also exported by this package.

import { tl } from '@mtcute/tl'
const obj: tl.RawInputPeerChat = { _: 'inputPeerChat', chatId: 42 }
console.log(tl.isAnyInputPeer(obj)) // true

RPC errors are also exposed in this package in tl.errors namespace:

import { tl } from '@mtcute/tl'
try {
    await client.call(...)
} catch (e) {
    if (e instanceof tl.errors.ChatInvalidError) {
        console.log('invalid chat')
    } else throw e
}

/api-schema.json

Documentation

JSON file describing all available TL classes, methods and unions. Can be used to write custom code generators

This very file is used to generate binary serialization and TypeScript typings for @mtcute/tl.

import * as tlSchema from '@mtcute/tl/raw-schema.json'

console.log(`Current layer: ${tlSchema.apiLayer}`)
// Current layer: 124

/binary/reader.js

Contains mapping used to read TL objects from binary streams.

import { __tlReaderMap } from '@mtcute/tl/binary/reader.js'
import { TlBinaryReader } from '@mtcute/tl-runtime'

const reader = TlBinaryReader.manual(new Uint8Array([...]))
console.log(readerMap[0x5bb8e511 /* mt_message */](reader))
// { _: 'mt_message', ... }

/binary/writer.js

Contains mapping used to write TL objects to binary streams.

import { __tlWriterMap } from '@mtcute/tl/binary/writer'
import { TlBinaryWriter } from '@mtcute/tl-runtime'

const writer = TlBinaryWriter.manual(100)
writerMap[0x5bb8e511 /* mt_message */](writer, { ... })
console.log(writer.result())
// Uint8Array <11 e5 b8 5b ...>

/binary/rsa-keys.js

Contains RSA keys used when authorizing with Telegram.

old flag also determines if the client should use the old RSA padding scheme.