mtcute/packages/core
2024-06-15 08:35:35 +03:00
..
scripts feat: support business connections 2024-05-06 03:12:33 +03:00
src feat(core): more customization in updates handling 2024-06-15 08:35:35 +03:00
.gitignore tests(core): added e2e and fuzzing tests 2021-06-15 03:12:22 +03:00
build.config.cjs build: initial support for jsr building 2024-04-21 04:53:09 +03:00
package.json v0.13.2 2024-06-12 18:00:21 +00:00
README.md docs: updated readmes 2024-03-07 05:35:37 +03:00
tsconfig.json test(client): test coverage for client utils 2023-11-16 02:42:02 +03:00
typedoc.cjs docs: fixed typedoc configs 2024-03-15 23:38:39 +03:00
utils.ts ESM + end-to-end tests (#11) 2023-10-16 19:23:53 +03:00

@mtcute/core

📖 API Reference

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

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

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

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

tg.run({
    phone: '+1234567890',
    code: () => prompt('Enter the code:'),
    password: 'my-password',
}, async (user) => {
    console.log(`✨ logged in as ${user.displayName}`)
})