Socket
Socket
Sign inDemoInstall

@mtcute/core

Package Overview
Dependencies
6
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mtcute/core

Type-safe library for MTProto (Telegram API)


Version published
Weekly downloads
318
increased by48.6%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@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}`)
})

FAQs

Last updated on 24 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc