open-index/open-npm huggingface dataset:
npm package: @mtcute/bun
Description: Meta-package for Bun
Author: alina sireneva
Latest version: 0.29.6

# @mtcute/bun

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_node.html)

‼️ **Experimental** Bun support package for mtcute. Includes:
- SQLite storage (based on `bun:sqlite`)
- TCP transport (based on Bun-native APIs)
- `TelegramClient` implementation using the above
- HTML and Markdown parsers

## Usage

```typescript
import { TelegramClient } from '@mtcute/bun'

const tg = new TelegramClient({
    apiId: 12345,
    apiHash: 'abcdef',
    storage: 'my-account'
})

const self = await tg.start()
console.log(`✨ logged in as ${self.displayName}`)
```
npm package: @mtcute/client
Description: High-level API over @mtcute/core
Author: Alina Sireneva
Latest version: 0.6.0
Deprecated: This package was merged into @mtcute/core

# @mtcute/client

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_client.html)

High-level Telegram client implementation over the `@mtcute/core` base library.

## Features
- **Updates handling**: Implements proper updates handling, including ordering and gap recovery ([learn more](https://core.telegram.org/api/updates))
- **Wrapper classes**: Easy-to-use classes that wrap the complex TL objects and provide a clean interface
- **High-level methods**: Methods that wrap the low-level API calls and provide a clean interface
- **Tree-shaking**: Only import the methods you need, and the rest will not be included into the bundle
- **Web support**: Works in the browser with no additional configuration

## Usage

```ts
import { TelegramClient } from '@mtcute/client'

const tg = new TelegramClient({
    apiId: 12345,
    apiHash: '0123456789abcdef0123456789abcdef',
    // ... + supports all options from @mtcute/core ...
})

tg.start({
    phone: '+1234567890',
    password: () => prompt('Enter password'),
    code: () => prompt('Enter code'),
}, (user) => {
    console.log(`Logged in as ${user.displayName}`)
})
```

> **Note**: for web, prefer BaseTelegramClient over TelegramClient, 
> as it is tree-shakeable – [learn more](https://mtcute.dev/guide/topics/treeshaking.html)
npm package: @mtcute/convert
Description: Cross-library session conversion utilities
Author: alina sireneva
Latest version: 0.29.6

# @mtcute/convert

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_convert.html)

This package can be used to convert other libraries sessions to/from mtcute sessions

Currently only the libraries that support exporting sessions to strings are supported, namely:

## [Telethon](https://github.com/LonamiWebs/Telethon)

> Telethon v2 seems to have removed the ability to export sessions,
> so it's currently not supported

```ts
import { convertFromTelethonSession } from '@mtcute/convert'

const client = new TelegramClient({ ... })
await client.importSession(convertFromTelethonSession("..."))
```

## [Pyrogram](https://github.com/pyrogram/pyrogram)

```ts
import { convertFromPyrogramSession } from '@mtcute/convert'

const client = new TelegramClient({ ... })
await client.importSession(convertFromPyrogramSession("..."))
```

## [GramJS](https://github.com/gram-js/gramjs)

```ts
import { convertFromGramjsSession } from '@mtcute/convert'

const client = new TelegramClient({ ... })
await client.importSession(convertFromGramjsSession("..."))
```

## [MTKruto](https://github.com/MTKruto/MTKruto)

```ts
import { convertFromMtkrutoSession } from '@mtcute/convert'

const client = new TelegramClient({ ... })
await client.importSession(convertFromMtkrutoSession("..."))
```
npm package: @mtcute/core
Description: Type-safe library for MTProto (Telegram API)
Author: alina sireneva
Latest version: 0.29.6

# @mtcute/core

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_core.html)

Platform-agnostic MTProto implementation and auxiliary utilities.

## Features
- **MTProto 2.0**: Implements the full MTProto protocol, including all the encryption and serialization
- **2FA support**: Provides utilities for 2-step verification
- **Hackable**: Bring your own storage, transport, and other components to customize the library to your needs
- **Magical**: Handles reconnections, connection pooling, DC redirections and other stuff for you
- **Updates handling**: Implements proper updates handling, including ordering and gap recovery (learn more)
- **High-level**: Includes a high-level API that wrap the MTProto APIs and provide a clean interface
- **Tree-shaking**: You can import just the methods you need, and the rest will not be included into the bundle

## Usage

```ts
import { BaseTelegramClient } from '@mtcute/core/client.js'

const tg = new BaseTelegramClient({
    apiId: 12345,
    apiHash: '0123456789abcdef0123456789abcdef',
    crypto: new MyCryptoProvider(),
    storage: new MyStorage(),
    transport: () => new MyTransport(),
})

tg.call({ _: 'help.getConfig' })
    .then(console.log)
```

## Usage with high-level API

```ts
import { TelegramClient } from '@mtcute/core/client.js'

const tg = new TelegramClient({
    // ... same options as above
})

const self = await tg.start({
    phone: '+1234567890',
    code: () => prompt('Enter the code:'),
    password: 'my-password',
})
console.log(`✨ logged in as ${self.displayName}`)
```
npm package: @mtcute/create-bot
Description: Bot starter kit for mtcute
Author: alina sireneva
Latest version: 0.29.0

# @mtcute/create-bot

Starter kit for creating bots using `@mtcute/node` or `@mtcute/bun`.

[Learn more](https://mtcute.dev/guide/)

## Features
- **Linters**: can set up linters using [@antfu/eslint-config](https://github.com/antfu/eslint-config)
- **TypeScript**: can generate a TypeScript project
- **Docker**: can generate a Dockerfile for easy deployment

## Usage

Depending on your preferred package manager and runtime, run one of the following commands:
```bash
pnpm create @mtcute/bot my-awesome-bot
# or
yarn create @mtcute/bot my-awesome-bot
# or
npm create @mtcute/bot my-awesome-bot
# or
bun create @mtcute/bot my-awesome-bot
# or
deno run -A npm:@mtcute/create-bot my-awesome-bot
```

and follow the instructions
npm package: @mtcute/crypto-node
Description: Native crypto implementation for NodeJS
Author: alina sireneva
Latest version: 0.19.0
Deprecated: built-in wasm-based crypto is now the preferred way, this package is no longer updated

# @mtcute/crypto-node

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_crypto_node.html)

Native extension for NodeJS that improves performance of the most used
cryptographic mode in Telegram (IGE), which is not implemented directly by OpenSSL.

Uses OpenSSL under the hood to provide maximum performance

## Installation
You will need all the pre-requisites for [node-gyp](https://github.com/nodejs/node-gyp#installation).
Pre-built packages are currently not available.

Then, install the package as usual. The native library will be built automatically.

## Usage

```typescript
import { TelegramClient } from '@mtcute/core'
import { NodeNativeCryptoProvider } from '@mtcute/crypto-node'

const tg = new TelegramClient({
    ...,
    crypto: () => new NodeNativeCryptoProvider()
})
```

> **Tip**: When using `@mtcute/node`, this will be done automatically for you.

## Benchmarks

See https://github.com/mtcute/benchmarks
npm package: @mtcute/dispatcher
Description: Updates dispatcher and bot framework for @mtcute/client
Author: alina sireneva
Latest version: 0.29.6

# @mtcute/dispatcher

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_dispatcher.html)
🧐 [Guide](https://mtcute.dev/guide/dispatcher/intro.html)

Dispatcher and bot framework based on @mtcute/core.

## Features
- **Straightforward**: Simple and expressive API
- **State**: Supports storing state for each chat
- **Filters**: Powerful and easy-to-use filtering system
- **Middleware**: Basic middleware support for updates
- **Scenes**: Built-in support for scenes

## Usage

```ts
import { Dispatcher } from '@mtcute/dispatcher'

const tg = new TelegramClient({ ... })
const dp = Dispatcher.for(tg)

dp.onNewMessage(async (msg) => {
    await msg.replyText('Hello world!')
})
```
npm package: @mtcute/file-id
Description: Support for TDLib and Bot API file ID for mtcute
Author: alina sireneva
Latest version: 0.29.0

# @mtcute/file-id

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_file-id.html)

This package is used internally by `@mtcute/core` to parse, serialize
and manipulate TDLib and Bot API compatible File IDs, but can also be used
for any other purposes.

## Acknowledgements
This is basically a port of a portion of TDLib APIs, but greatly
simplified in usage and made to work seamlessly with the rest of the
mtcute APIs.

This is a list of files from TDLib repository, from which most of the code was taken:
 - [td/telegram/files/FileManager.cpp](https://github.com/tdlib/td/blob/master/td/telegram/files/FileManager.cpp)
 - [td/telegram/files/FileLocation.hpp](https://github.com/tdlib/td/blob/master/td/telegram/files/FileLocation.hpp)
 - [td/telegram/PhotoSizeSource.h](https://github.com/tdlib/td/blob/master/td/telegram/PhotoSizeSource.h)
 - [td/telegram/PhotoSizeSource.hpp](https://github.com/tdlib/td/blob/master/td/telegram/PhotoSizeSource.hpp)
 - [td/telegram/Version.h](https://github.com/tdlib/td/blob/master/td/telegram/Version.h)

Additionally, some of the test cases were taken from a similar Python
library, [luckydonald/telegram_file_id](https://github.com/luckydonald/telegram_file_id)
npm package: @mtcute/http-proxy
Description: HTTP(S) proxy support for mtcute
Author: alina sireneva
Latest version: 0.17.0

# @mtcute/http-proxy

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_http_proxy.html)

HTTP(s) proxy transport for mtcute.

## Usage

```typescript
import { HttpProxyTcpTransport } from '@mtcute/socks-proxy'

const tg = new TelegramClient({
    // ...
    transport: () => new HttpProxyTcpTransport({
        host: 'localhost',
        port: 1080,
    })
})
```
npm package: @mtcute/i18n
Description: I18n for mtcute
Author: alina sireneva
Latest version: 0.27.0
Deprecated: this package is no longer supported, use a proper i18n library

# @mtcute/i18n

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_i18n.html)

Internationalization library built with TypeScript and mtcute in mind.

## Features
- **Type-safe**: All string keys and parameters are type-checked
- **Plurals**: Supports pluralization
- **Customizable**: Supports custom locales and customizing existing ones
- **Pluggable**: Can be used with any library, not just mtcute. Can also be used with other i18n libraries.

## Usage

```ts
// i18n/en.ts
export const en = {
    hello: (name: string) => `Hello, ${name}!`,
}

// i18n/ru.ts
export const ru: OtherLanguageWrap<typeof en> = {
    hello: (name: string) => `Привет, ${name}!`,
}

// i18n/index.ts
export const tr = createMtcuteI18n({
    primaryLanguage: {
        name: 'en',
        strings: en,
    },
    otherLanguages: { ru },
})

// main.ts
dp.onNewMessage(async (upd) => {
    await upd.replyText(tr(upd, 'hello', upd.sender.displayName))
})
```
npm package: @mtcute/mtproxy
Description: MTProto proxy (MTProxy) support for mtcute
Author: alina sireneva
Latest version: 0.17.0

# @mtcute/mtproxy

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_mtproxy.html)

MTProto proxy (MTProxy) transport for mtcute.

Supports all kinds of MTProto proxies, including obfuscated and fake TLS.

## Usage

```typescript
import { MtProxyTcpTransport } from '@mtcute/mtproxy'

const tg = new TelegramClient({
    // ...
    transport: () => new MtProxyTcpTransport({
        host: 'localhost',
        port: 443,
        secret: 'secret'
    })
})
```
npm package: @mtcute/node
Description: Meta-package for Node.js
Author: alina sireneva
Latest version: 0.29.6

# @mtcute/node

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_node.html)

Node.js support package for mtcute. Includes:
- Terminal I/O via `readline`
- SQLite storage (via `better-sqlite3`)
- TCP transport (via `node:net`)
- `TelegramClient` implementation using the above
- HTML and Markdown parsers

## Usage

```typescript
import { TelegramClient } from '@mtcute/node'

const tg = new TelegramClient({
    apiId: 12345,
    apiHash: 'abcdef',
    storage: 'my-account'
})

const self = await tg.start()
console.log(`✨ logged in as ${self.displayName}`)
```
npm package: @mtcute/socks-proxy
Description: SOCKS4/5 proxy support for mtcute
Author: alina sireneva
Latest version: 0.17.0

# @mtcute/socks-proxy

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_socks_proxy.html)

Socks4/5 proxy transport for mtcute.

## Usage

```typescript
import { SocksTcpTransport } from '@mtcute/socks-proxy'

const tg = new TelegramClient({
    // ...
    transport: () => new SocksTcpTransport({
        host: 'localhost',
        port: 1080,
    })
})
```
npm package: @mtcute/sqlite
Description: SQLite-based storage for mtcute
Author: Alina Sireneva
Latest version: 0.8.0
Deprecated: Use platform-specific packages instead (e.g. @mtcute/node)

# @mtcute/sqlite

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_sqlite.html)

SQLite backed storage for mtcute, built with `better-sqlite3`

## Usage

```typescript
import { SqliteStorage } from '@mtcute/sqlite'

const tg = new TelegramClient({
    // ...
    storage: new SqliteStorage('client.session')
})
```
npm package: @mtcute/tl-runtime
Description: Runtime for TL
Author: alina sireneva
Latest version: 0.29.0

# @mtcute/tl-runtime

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_tl-runtime.html)

This package contains runtime for TL (de-)serialization.
It only contains binary reader and writer implementations,
as well as some `Uint8Array` utilities, and is used by `@mtcute/core`.

`@mtcute/tl-utils` on the other hand has utilities like codegen
and schema manipulation, which is only needed at runtime if you
are patching the schema (which is a rare case anyways).

## Features
- Supports all TL features used by the public schema
- Supports browsers out of the box
npm package: @mtcute/tl-utils
Description: Utils for working with TL schema
Author: alina sireneva
Latest version: 0.29.3

# @mtcute/tl-utils

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_tl-utils.html)

Utilities for TL schema parsing and manipulation

## Features
- Parsing & generating TL schema definitions
- Computing constructor IDs
- Parsing & generating TDLib style comments
- Code generation for readers and writers maps, errors, type definitions
- Merging and diffing entries, schemas
npm package: @mtcute/wasm
Description: WASM implementation of common algorithms used in Telegram
Author: alina sireneva
Latest version: 0.29.0

# @mtcute/wasm

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_wasm.html)

Highly optimized for size & speed WASM implementation of common algorithms used in Telegram.

## Features
- **Super lightweight**: Only 47 KB raw, 24 KB gzipped
- **Blazingly fast**: Up to 10x faster than pure JS implementations
- **Ready to use**: Implements almost all algos used in MTProto:
  - AES IGE
  - Deflate (zlib compression + gunzip)
  - SHA-1, SHA-256

## Acknowledgements
- Deflate is implemented through a modified version of [libdeflate](https://github.com/ebiggers/libdeflate), MIT license.
  - Modified by [kamillaova](https://github.com/kamillaova) to support WASM and improve bundle size
- AES IGE code is mostly based on [tgcrypto](https://github.com/pyrogram/tgcrypto), LGPL-3.0 license.
  - To comply with LGPL-3.0, the source code of the modified tgcrypto is available [here](./lib/crypto/) under LGPL-3.0 license.
- SHA1 is based on [teeny-sha1](https://github.com/CTrabant/teeny-sha1)
- SHA256 is based on [lekkit/sha256](https://github.com/LekKit/sha256)

## Benchmarks
See https://github.com/mtcute/benchmarks
npm package: @mtcute/web
Description: Meta-package for the web platform
Author: alina sireneva
Latest version: 0.29.6

# @mtcute/web

📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_web.html)

Web support package for mtcute. Includes:
- WASM crypto provider
- Websocket transport
- IndexedDB storage
- `TelegramClient` implementation using the above

## Usage

```typescript
import { TelegramClient } from '@mtcute/web'

const tg = new TelegramClient({
    apiId: 12345,
    apiHash: 'abcdef',
    storage: 'my-account'
})

const self = await tg.start()
console.log(`✨ logged in as ${self.displayName}`)
```

## Usage with workers

You can also use this package with web workers to offload most of the heavy lifting to a separate thread:

```typescript
// worker.ts
import { BaseTelegramClient, TelegramWorker } from '@mtcute/web'

const client = new BaseTelegramClient({
    apiId: 12345,
    apiHash: 'abcdef',
    storage: 'my-account'
})

new TelegramWorker({ client }).mount()

// main.ts
import { TelegramClient, TelegramWorkerPort } from '@mtcute/web'

const worker = new Worker(new URL('./worker.ts', import.meta.url), { type: 'module' }) // or SharedWorker
const port = new TelegramWorkerPort({ worker })
const tg = new TelegramClient({ client: port })

const self = await tg.start()
console.log(`✨ logged in as ${user.displayName}`)
```

`port.destroy()` only releases that port. Use `port.unsafeForceDestroy()` if you need to tear down the shared worker-side client.