{"id":13461892,"url":"https://github.com/zerobias/telegram-mtproto","last_synced_at":"2025-03-24T23:31:59.912Z","repository":{"id":62921050,"uuid":"79104109","full_name":"zerobias/telegram-mtproto","owner":"zerobias","description":"Telegram client api (MTProto) library","archived":true,"fork":false,"pushed_at":"2020-03-31T18:56:53.000Z","size":2943,"stargazers_count":625,"open_issues_count":1,"forks_count":137,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-03-11T05:47:56.698Z","etag":null,"topics":["mtproto","telegram","telegram-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zerobias.png","metadata":{"files":{"readme":"README-RU.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-16T09:44:01.000Z","updated_at":"2025-02-17T18:29:47.000Z","dependencies_parsed_at":"2022-11-09T06:36:27.838Z","dependency_job_id":null,"html_url":"https://github.com/zerobias/telegram-mtproto","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerobias%2Ftelegram-mtproto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerobias%2Ftelegram-mtproto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerobias%2Ftelegram-mtproto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerobias%2Ftelegram-mtproto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zerobias","download_url":"https://codeload.github.com/zerobias/telegram-mtproto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245372193,"owners_count":20604487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mtproto","telegram","telegram-api"],"created_at":"2024-07-31T12:00:26.643Z","updated_at":"2025-03-24T23:31:59.450Z","avatar_url":"https://github.com/zerobias.png","language":"JavaScript","funding_links":[],"categories":["MTProto implementations","JavaScript","Libraries"],"sub_categories":["Community","Node.js"],"readme":"# telegram-mtproto\n\n[![npm version][npm-image]][npm-url]\n\n**Mobile Telegram Protocol** [(MTProto)](https://core.telegram.org/mtproto) пакет написан на **ES6**\n\n## Про MTProto...\n\n**MTProto** - это протокол сервиса [Telegram](http://www.telegram.org) _\"придуман для работы с серверами API из мобильных приложений\"_.\n\nMobile Protocol подразделятся на 3 части ([с официального сайта](https://core.telegram.org/mtproto#general-description)):\n\n - **Компонент высшего уровня (API query language):** определяет методы через которые запросы и ответы преобразуются в двоичные сообщения.\n - **Криптографический слой (для авторизаций):** определяет методы через которые сообщения шифруются перед передачей.\n - **Транспортный компонент:** определяет протоколы по которым будут общаться клиент и сервер (такие как, `http`, `https`, `tcp`, `udp`).\n\n\n## Про telegram-mtproto в двух словах...\n\nНикакие другие пакеты не нужны.\nПакет **telegram-mtproto** позволяет реализовать все возможности работы с **Mobile Protocol**:\n\n - Выший уровень API для подключения к серверу\n\n - API которая работает через промисы\n\n - **HTTP подключения** которые выполняют перенос данных\n\n - **Web worker** - сверх быстрые криптографическеские работы в фоновом режиме\n\n - Реализация **AES и RSA-шифрования** шифрования, для безопасности\n\n - Оба метода **plain-text** и **encrypted message** для передачи данных на сервер\n\n - Обмен **ключами Диффи-Хеллмана**, поддерживающими функцию **prime factorization**, для безопасности\n\n - **MTProto TL-Schema** сборник **JavaScript классов и функций**\n\n - **async storage** для сохранения данных между сессиями\n\n\n## Установка\n\n```bash\n$ npm install --save telegram-mtproto@beta\n```\n\n## Использование\n\n```javascript\nimport MTProto from 'telegram-mtproto'\n\nconst phone = {\n  num : '+79123456789',\n  code: '22222'\n}\n\nconst api = {\n  layer          : 57,\n  initConnection : 0x69796de9,\n  api_id         : 49631\n}\n\nconst server = {\n  dev: true // Подключаемся к тестовому серверу.\n}           // Пустые поля конфигураций можно не указывать\n\nconst client = MTProto({ server, api })\n\nasync function connect(){\n  const { phone_code_hash } = await client('auth.sendCode', {\n    phone_number  : phone.num,\n    current_number: false,\n    api_id        : 49631,\n    api_hash      : 'fb050b8f6771e15bfda5df2409931569'\n  })\n  const { user } = await client('auth.signIn', {\n    phone_number   : phone.num,\n    phone_code_hash: phone_code_hash,\n    phone_code     : phone.code\n  })\n\n  console.log('Вы вошли как ', user)\n}\n\nconnect()\n```\n\nВыше мы использовали две функции из API.\n\n```typescript\ntype auth.sendCode = (\n  phone_number: string,\n  sms_type: int,\n  api_id: int,\n  api_hash: string,\n  lang_code: string\n) =\u003e {\n  phone_registered: boolean,\n  phone_code_hash: string,\n  send_call_timeout: int,\n  is_password: boolean\n}\n\ntype auth.signIn = (\n  phone_number: string,\n  phone_code_hash: string,\n  phone_code: string\n) =\u003e {\n  expires: int,\n  user: User\n}\n```\n[Больше][send-code] про [авторизацию][sign-in], а также о многих других методах, вы можете прочитать в [документации][docs].\n\nДополнительные примеры можно посмотреть в [папке с примерами][examples].\n\n## Хранение\n\nВы можете использовать наши основные хранилища [localForage][localForage] для хранения данных.\nМодуль имеет следующие интерфейсы:\n\n```typescript\ninterface AsyncStorage {\n  get(key: string): Promise\u003cany\u003e;\n  set(key: string, value: any): Promise\u003cvoid\u003e;\n  remove(...keys: string[]): Promise\u003cvoid\u003e;\n  clear(): Promise\u003cvoid\u003e;\n}\n```\n\n```javascript\nimport { MTProto } from 'telegram-mtproto'\nimport { api } from './config'\nimport CustomStorage from './storage'\n\nconst client = MTProto({\n  api,\n  app: {\n    storage: CustomStorage\n  }\n})\n\n```\n\n## Лицензия\n\nПроект запущен под лицензией [MIT](./LICENSE)\n\n[examples]: https://github.com/zerobias/telegram-mtproto/tree/develop/examples\n[localForage]: https://github.com/localForage/localForage\n[docs]: https://core.telegram.org/\n[send-code]: https://core.telegram.org/method/auth.sendCode\n[sign-in]: https://core.telegram.org/method/auth.signIn\n[npm-url]: https://www.npmjs.org/package/telegram-mtproto\n[npm-image]: https://badge.fury.io/js/telegram-mtproto.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerobias%2Ftelegram-mtproto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerobias%2Ftelegram-mtproto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerobias%2Ftelegram-mtproto/lists"}