/** * Telegram MTProto API Configuration * * ============================================================ * IMPORTANT: This configuration is for BACKEND USE ONLY * ============================================================ * * The React Native SDK extracts data from Telegram Web's cache. * For full API access, implement MTProto on your backend using * these credentials with Telethon (Python) or GramJS (Node.js). * * Registration: https://my.telegram.org/apps * Documentation: https://core.telegram.org/api * * ============================================================ * SECURITY NOTICE * ============================================================ * - NEVER expose api_hash in client-side code in production * - Store credentials in environment variables on backend * - api_id can be public, api_hash must be kept secret * * ============================================================ */ /** * Telegram API Credentials * * @see https://my.telegram.org/apps */ export declare const TELEGRAM_API_CONFIG: { /** * Application ID (can be public) * From: https://my.telegram.org/apps */ API_ID: number; /** * Application Hash (KEEP SECRET - backend only) * From: https://my.telegram.org/apps * * ⚠️ In production, use environment variable: * process.env.TELEGRAM_API_HASH */ API_HASH: string; /** * Application Name */ APP_TITLE: string; SHORT_NAME: string; }; /** * MTProto Server Configuration */ export declare const TELEGRAM_SERVERS: { /** * Production Data Center 2 * Use this for production deployments */ production: { host: string; port: number; dc: number; }; /** * Test Data Center 2 * Use this for development/testing */ test: { host: string; port: number; dc: number; }; }; /** * Production RSA Public Key * Used for MTProto encryption handshake */ export declare const TELEGRAM_PUBLIC_KEY_PRODUCTION = "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEA6LszBcC1LGzyr992NzE0ieY+BSaOW622Aa9Bd4ZHLl+TuFQ4lo4g\n5nKaMBwK/BIb9xUfg0Q29/2mgIR6Zr9krM7HjuIcCzFvDtr+L0GQjae9H0pRB2OO\n62cECs5HKhT5DZ98K33vmWiLowc621dQuwKWSQKjWf50XYFw42h21P2KXUGyp2y/\n+aEyZ+uVgLLQbRA1dEjSDZ2iGRy12Mk5gpYc397aYp438fsJoHIgJ2lgMv5h7WY9\nt6N/byY9Nw9p21Og3AoXSL2q/2IJ1WRUhebgAdGVMlV1fkuOQoEzR7EdpqtQD9Cs\n5+bfo3Nhmcyvk5ftB0WkJ9z6bNZ7yxrP8wIDAQAB\n-----END RSA PUBLIC KEY-----"; /** * Test RSA Public Key * Used for MTProto encryption handshake in test environment */ export declare const TELEGRAM_PUBLIC_KEY_TEST = "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAyMEdY1aR+sCR3ZSJrtztKTKqigvO/vBfqACJLZtS7QMgCGXJ6XIR\nyy7mx66W0/sOFa7/1mAZtEoIokDP3ShoqF4fVNb6XeqgQfaUHd8wJpDWHcR2OFwv\nplUUI1PLTktZ9uW2WE23b+ixNwJjJGwBDJPQEQFBE+vfmH0JP503wr5INS1poWg/\nj25sIWeYPHYeOrFp/eXaqhISP6G+q2IeTaWTXpwZj4LzXq5YOpk4bYEQ6mvRq7D1\naHWfYmlEGepfaYR8Q0YqvvhYtMte3ITnuSJs171+GDqpdKcSwHnd6FudwGO4pcCO\nj4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB\n-----END RSA PUBLIC KEY-----"; /** * Telegram API Access Model * * Unlike OAuth platforms (Google, Facebook, etc.), Telegram uses: * * 1. FULL ACCESS MODEL * - Once user authenticates, you have access to everything * - No granular scope selection * - User trusts the app completely * * 2. AUTHENTICATION FLOW * - Phone number → Verification code → Optional 2FA * - Session is persisted (no need to re-login) * - Sessions can be managed in Telegram settings * * 3. DATA ACCESS * - All dialogs (chats, groups, channels) * - All messages (sent and received) * - All media (photos, videos, files) * - User profile information * - Contacts (if synced) * * 4. RATE LIMITS * - ~1 request per second recommended * - FLOOD_WAIT errors require sleeping * - Telethon handles this automatically with flood_sleep_threshold * * PRIVACY BEST PRACTICES: * - Only extract user's OWN messages (out=true) * - Don't store other users' private data * - Inform users what data you're collecting * - Allow users to revoke sessions via Telegram app */ export declare const TELEGRAM_ACCESS_INFO: { hasOAuthScopes: boolean; accessModel: string; dataExtracted: { dialogs: boolean; userMessages: boolean; otherMessages: boolean; secretChats: boolean; media: boolean; contacts: boolean; }; apiMethods: string[]; }; /** * Example: Python Backend with Telethon * * ```python * # requirements.txt * telethon==1.34.0 * * # telegram_service.py * from telethon import TelegramClient * from telethon.sessions import StringSession * import asyncio * import os * * API_ID = 33259558 * API_HASH = os.environ.get('TELEGRAM_API_HASH', '4b76b3a34aa0f56d8a8971db097a2ae3') * * async def authenticate_user(phone_number: str): * """Step 1: Send verification code""" * client = TelegramClient(StringSession(), API_ID, API_HASH) * await client.connect() * * result = await client.send_code_request(phone_number) * return { * 'phone_code_hash': result.phone_code_hash, * 'session_string': client.session.save() * } * * async def verify_code(session_string: str, phone: str, code: str, phone_code_hash: str): * """Step 2: Verify code and complete auth""" * client = TelegramClient(StringSession(session_string), API_ID, API_HASH) * await client.connect() * * await client.sign_in(phone, code, phone_code_hash=phone_code_hash) * * # Save session for future use (no re-login needed) * return client.session.save() * * async def get_user_data(session_string: str, limit: int = 50): * """Fetch user's dialogs and messages""" * client = TelegramClient(StringSession(session_string), API_ID, API_HASH) * await client.connect() * * # Get dialogs * dialogs = await client.get_dialogs(limit=limit) * * result = { * 'dialogs': [], * 'messages': [] * } * * for dialog in dialogs: * result['dialogs'].append({ * 'id': dialog.id, * 'title': dialog.title, * 'unread_count': dialog.unread_count, * 'type': type(dialog.entity).__name__ * }) * * # Get user's messages from this dialog * messages = await client.get_messages(dialog.entity, limit=20) * for msg in messages: * if msg.out: # Only user's outgoing messages * result['messages'].append({ * 'id': msg.id, * 'chat_id': dialog.id, * 'text': msg.text, * 'date': msg.date.isoformat(), * 'out': True * }) * * await client.disconnect() * return result * ``` */ export declare const PYTHON_EXAMPLE = "See comment above"; /** * Example: Node.js Backend with GramJS * * ```javascript * // package.json: "telegram": "^2.19.0" * * const { TelegramClient } = require('telegram'); * const { StringSession } = require('telegram/sessions'); * * const API_ID = 33259558; * const API_HASH = process.env.TELEGRAM_API_HASH || '4b76b3a34aa0f56d8a8971db097a2ae3'; * * async function authenticateUser(phoneNumber) { * const client = new TelegramClient(new StringSession(''), API_ID, API_HASH, { * connectionRetries: 5, * }); * * await client.connect(); * * const result = await client.sendCode({ * apiId: API_ID, * apiHash: API_HASH, * }, phoneNumber); * * return { * phoneCodeHash: result.phoneCodeHash, * sessionString: client.session.save(), * }; * } * * async function verifyCode(sessionString, phone, code, phoneCodeHash) { * const client = new TelegramClient(new StringSession(sessionString), API_ID, API_HASH, {}); * await client.connect(); * * await client.invoke({ * _: 'auth.signIn', * phone_number: phone, * phone_code_hash: phoneCodeHash, * phone_code: code, * }); * * return client.session.save(); * } * * async function getUserData(sessionString, limit = 50) { * const client = new TelegramClient(new StringSession(sessionString), API_ID, API_HASH, {}); * await client.connect(); * * const dialogs = await client.getDialogs({ limit }); * * const result = { dialogs: [], messages: [] }; * * for (const dialog of dialogs) { * result.dialogs.push({ * id: dialog.id.toString(), * title: dialog.title, * unreadCount: dialog.unreadCount, * }); * * const messages = await client.getMessages(dialog.entity, { limit: 20 }); * for (const msg of messages) { * if (msg.out) { * result.messages.push({ * id: msg.id.toString(), * chatId: dialog.id.toString(), * text: msg.text, * date: msg.date, * out: true, * }); * } * } * } * * await client.disconnect(); * return result; * } * * module.exports = { authenticateUser, verifyCode, getUserData }; * ``` */ export declare const NODEJS_EXAMPLE = "See comment above"; //# sourceMappingURL=telegramConfig.d.ts.map