{"_id":"@astralibx/telegram-account-manager","_rev":"5-e4026f7586c0f22e3251968afc0b7fa2","name":"@astralibx/telegram-account-manager","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@astralibx/telegram-account-manager","version":"0.1.0","keywords":["telegram","account-manager","tdlib","gramjs","warmup","health-tracking","quarantine"],"license":"MIT","_id":"@astralibx/telegram-account-manager@0.1.0","maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"homepage":"https://github.com/Hariprakash1997/astralib#readme","bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"dist":{"shasum":"70068410590f9820aa9571717ceaecb2b2b5d376","tarball":"https://registry.npmjs.org/@astralibx/telegram-account-manager/-/telegram-account-manager-0.1.0.tgz","fileCount":2,"integrity":"sha512-qIfmuCcW3ZX1+QmvRYMwvF1521QOGPPNbKlKDLZzXcQEIPOj9n1HmZjKo+DTp8WbuKHmE4Eu2SuYv0Na9RkLKg==","signatures":[{"sig":"MEQCIFudbYWE9jwN1KzL8PpU7KEwgUL4a3tUbKtpwc56Qcv7AiAFiwPUP0tHDB8+QvBFywcQ1Wh1wQOW9l1syYnNnbQKKg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5789},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"7b31566b4e1292e820e38c3c891a8e38c6ad13d4","scripts":{"lint":"eslint src/","test":"vitest run","build":"tsc","clean":"rm -rf dist","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"astralib","email":"1997hariprakash@gmail.com"},"repository":{"url":"git+https://github.com/Hariprakash1997/astralib.git","type":"git","directory":"packages/telegram-account-manager"},"_npmVersion":"10.9.4","description":"Telegram account lifecycle management with TDLib sessions, health tracking, warmup, quarantine, and daily stats","directories":{},"_nodeVersion":"22.22.1","dependencies":{"zod":"^3.23.0","@astralibx/core":"*"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","express":"^5.0.0","mongoose":"^8.12.1","telegram":"^2.26.22","typescript":"^5.8.2","@types/express":"^5.0.0","@vitest/coverage-v8":"^3.0.0","mongodb-memory-server":"^10.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0","mongoose":"^7.0.0 || ^8.0.0","telegram":"^2.20.0"},"_npmOperationalInternal":{"tmp":"tmp/telegram-account-manager_0.1.0_1773719531249_0.98166493490109","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@astralibx/telegram-account-manager","version":"0.1.1","keywords":["telegram","account-manager","tdlib","gramjs","warmup","health-tracking","quarantine"],"license":"MIT","_id":"@astralibx/telegram-account-manager@0.1.1","maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"homepage":"https://github.com/Hariprakash1997/astralib#readme","bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"dist":{"shasum":"8d96d0d4f3c3f4b181aa76ff39cf6f86074db82a","tarball":"https://registry.npmjs.org/@astralibx/telegram-account-manager/-/telegram-account-manager-0.1.1.tgz","fileCount":94,"integrity":"sha512-4qF5hPYERK7KDeBjt8MZYHd/1jyPsUbSSOKUqgu51ctGxWzhmNrspx6xe5RV59jc6ozEkIlpMJbRua1JNlTS4w==","signatures":[{"sig":"MEYCIQDe6CtnGWf8IE+VnQXRiougA2IFMP/F9Bbo5mdfccdsmwIhAJ+gJTmaLd1kvZZFuvwsx1V8ePh+pGZxU5jCF60JDnEf","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":197917},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"df956e4b9f30b71fc0ee0eba6b811eee2092bf52","scripts":{"lint":"eslint src/","test":"vitest run","build":"tsc","clean":"rm -rf dist","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"astralib","email":"1997hariprakash@gmail.com"},"repository":{"url":"git+https://github.com/Hariprakash1997/astralib.git","type":"git","directory":"packages/telegram/account-manager"},"_npmVersion":"10.9.4","description":"Telegram account lifecycle management with TDLib sessions, health tracking, warmup, quarantine, and daily stats","directories":{},"_nodeVersion":"22.22.1","dependencies":{"zod":"^3.23.0","@astralibx/core":"*"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","express":"^5.0.0","mongoose":"^8.12.1","telegram":"^2.26.22","typescript":"^5.8.2","@types/express":"^5.0.0","@vitest/coverage-v8":"^3.0.0","mongodb-memory-server":"^10.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0","mongoose":"^7.0.0 || ^8.0.0","telegram":"^2.20.0"},"_npmOperationalInternal":{"tmp":"tmp/telegram-account-manager_0.1.1_1773730924334_0.17707082794117945","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@astralibx/telegram-account-manager","version":"0.1.2","keywords":["telegram","account-manager","tdlib","gramjs","warmup","health-tracking","quarantine"],"license":"MIT","_id":"@astralibx/telegram-account-manager@0.1.2","maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"homepage":"https://github.com/Hariprakash1997/astralib#readme","bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"dist":{"shasum":"061f53b253e59880788ac97721631f9704dd1cb8","tarball":"https://registry.npmjs.org/@astralibx/telegram-account-manager/-/telegram-account-manager-0.1.2.tgz","fileCount":94,"integrity":"sha512-tupaCG3pOvE4tjbE8m/3kSHqnFBoioqqvNQ8rKUCjthAcQWYo57ydGEXoWtl3fRlxIYsMqCvPcLh0ZyHVZ/saQ==","signatures":[{"sig":"MEUCIQDrdZg2kSFLAjeSLim4aJ21RmnXrapdJXhMBT7+3tocygIgVC+d2SgdCEDusxEBi1lqDMQR074APVuJuPghj7S2WLQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":197917},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"fd42f0db8c9fd08982aee61f94304819cd425d54","scripts":{"lint":"eslint src/","test":"vitest run","build":"tsc","clean":"rm -rf dist","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"astralib","email":"1997hariprakash@gmail.com"},"repository":{"url":"git+https://github.com/Hariprakash1997/astralib.git","type":"git","directory":"packages/telegram/account-manager"},"_npmVersion":"10.9.4","description":"Telegram account lifecycle management with TDLib sessions, health tracking, warmup, quarantine, and daily stats","directories":{},"_nodeVersion":"22.22.1","dependencies":{"zod":"^3.23.0","@astralibx/core":"*"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","express":"^5.0.0","mongoose":"^8.12.1","telegram":"^2.26.22","typescript":"^5.8.2","@types/express":"^5.0.0","@vitest/coverage-v8":"^3.0.0","mongodb-memory-server":"^10.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0","mongoose":"^7.0.0 || ^8.0.0","telegram":"^2.20.0"},"_npmOperationalInternal":{"tmp":"tmp/telegram-account-manager_0.1.2_1773733708278_0.27655331782611947","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@astralibx/telegram-account-manager","version":"0.2.0","keywords":["telegram","account-manager","tdlib","gramjs","warmup","health-tracking","quarantine"],"license":"MIT","_id":"@astralibx/telegram-account-manager@0.2.0","maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"homepage":"https://github.com/Hariprakash1997/astralib#readme","bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"dist":{"shasum":"51f59a98ce563acd1b075f0d973ddfa7991c27d3","tarball":"https://registry.npmjs.org/@astralibx/telegram-account-manager/-/telegram-account-manager-0.2.0.tgz","fileCount":110,"integrity":"sha512-wGSEFzJaTWYi/mha0ieFQAb3ie/mio9i322g2sKXV5FfOVERXKcwK0EXKjqFLm19d6tY1/0/p5JyUnYFknCWcQ==","signatures":[{"sig":"MEUCIEzgVdGwTFsBq8OCD1q3p1D5Nh5AsRC1N+ZqJEnSbf5ZAiEAmUon6RSE+G/Ew6MX6I7cROZ/7rXdNVww1bx8RiMNQEk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":258225},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"b96fb6e63feccf19591d627ddda0c3d04f165ad2","scripts":{"lint":"eslint src/","test":"vitest run","build":"tsc","clean":"rm -rf dist","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"astralib","email":"1997hariprakash@gmail.com"},"repository":{"url":"git+https://github.com/Hariprakash1997/astralib.git","type":"git","directory":"packages/telegram/account-manager"},"_npmVersion":"10.9.4","description":"Telegram account lifecycle management with TDLib sessions, health tracking, warmup, quarantine, and daily stats","directories":{},"_nodeVersion":"22.22.1","dependencies":{"zod":"^3.23.0","@astralibx/core":"*"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","express":"^5.0.0","mongoose":"^8.12.1","telegram":"^2.26.22","typescript":"^5.8.2","@types/express":"^5.0.0","@vitest/coverage-v8":"^3.0.0","mongodb-memory-server":"^10.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0","mongoose":"^7.0.0 || ^8.0.0","telegram":"^2.20.0"},"_npmOperationalInternal":{"tmp":"tmp/telegram-account-manager_0.2.0_1773814059726_0.032251881413082106","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@astralibx/telegram-account-manager","version":"0.2.1","description":"Telegram account lifecycle management with TDLib sessions, health tracking, warmup, quarantine, and daily stats","repository":{"type":"git","url":"git+https://github.com/Hariprakash1997/astralib.git","directory":"packages/telegram/account-manager"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","lint":"eslint src/","clean":"rm -rf dist"},"keywords":["telegram","account-manager","tdlib","gramjs","warmup","health-tracking","quarantine"],"license":"MIT","dependencies":{"@astralibx/core":"*","zod":"^3.23.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0","mongoose":"^7.0.0 || ^8.0.0","telegram":"^2.20.0"},"devDependencies":{"@types/express":"^5.0.0","@vitest/coverage-v8":"^3.0.0","express":"^5.0.0","mongodb-memory-server":"^10.0.0","mongoose":"^8.12.1","telegram":"^2.26.22","typescript":"^5.8.2","vitest":"^3.0.0"},"_id":"@astralibx/telegram-account-manager@0.2.1","gitHead":"4d2a55b3968e55f083d4a957eb2319acb1fa5ba3","bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"homepage":"https://github.com/Hariprakash1997/astralib#readme","_nodeVersion":"22.22.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-9OWNZpVSC9a3B2rzTlLPVbpSO+e0Xc0/VsnV90Mb7+lBYSHXe4gzrT4uWRscZjK2P7wrQpFHoveuWq7PISmD7w==","shasum":"928e29786a10a9b9c8b45a689c13b06eeb311cd9","tarball":"https://registry.npmjs.org/@astralibx/telegram-account-manager/-/telegram-account-manager-0.2.1.tgz","fileCount":110,"unpackedSize":257934,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCID15R+PmOdercaMmRI5IRFlFLhnnTdcjxaxXj2MbMTb5AiEAkwC+W96PJWnj/xSb7M0klwUp2cUZBVPqBD9chN1geRg="}]},"_npmUser":{"name":"astralib","email":"1997hariprakash@gmail.com"},"directories":{},"maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/telegram-account-manager_0.2.1_1773998151123_0.5918021283398491"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-17T03:52:11.183Z","modified":"2026-03-20T09:15:51.396Z","0.1.0":"2026-03-17T03:52:11.392Z","0.1.1":"2026-03-17T07:02:04.478Z","0.1.2":"2026-03-17T07:48:28.406Z","0.2.0":"2026-03-18T06:07:39.925Z","0.2.1":"2026-03-20T09:15:51.260Z"},"bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"license":"MIT","homepage":"https://github.com/Hariprakash1997/astralib#readme","keywords":["telegram","account-manager","tdlib","gramjs","warmup","health-tracking","quarantine"],"repository":{"type":"git","url":"git+https://github.com/Hariprakash1997/astralib.git","directory":"packages/telegram/account-manager"},"description":"Telegram account lifecycle management with TDLib sessions, health tracking, warmup, quarantine, and daily stats","maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"readme":"# @astralibx/telegram-account-manager\n\nA production-ready, multi-account Telegram infrastructure library for Node.js. Manages multiple TDLib client sessions with automatic health tracking, account warmup, quarantine management, capacity-based rotation, daily stats, and Telegram identifier tracking. Plug it into any Express app with a single factory call.\n\n> **Getting started?** See the [Quick Start Tutorial](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/docs/quick-start-tutorial.md) for a step-by-step walkthrough, [Integration Guide](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/docs/integration-guide.md) for multi-package setup, or the [Glossary](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/docs/glossary.md) for ID terminology.\n\n## Install\n\n```bash\nnpm install @astralibx/telegram-account-manager\n```\n\n### Peer Dependencies\n\n| Package | Required |\n|---------|----------|\n| `express` | Yes |\n| `mongoose` | Yes |\n| `telegram` | Yes (GramJS) |\n\n```bash\nnpm install express mongoose telegram\n```\n\n## Quick Start\n\n```ts\nimport express from 'express';\nimport mongoose from 'mongoose';\nimport { createTelegramAccountManager } from '@astralibx/telegram-account-manager';\n\nconst app = express();\napp.use(express.json());\n\nconst db = await mongoose.createConnection('mongodb://localhost:27017/myapp');\n\nconst tam = createTelegramAccountManager({\n  db: { connection: db },\n  credentials: {\n    apiId: 12345678,\n    apiHash: 'your-api-hash',\n  },\n});\n\n// Admin API (protect with your own auth middleware)\napp.use('/api/telegram', tam.routes);\n\n// 1. Generate session (or use existing one)\nconst { phoneCodeHash } = await tam.sessions.requestCode('+919876543210');\nconst { session } = await tam.sessions.verifyCode('+919876543210', '12345', phoneCodeHash);\n\n// 2. Create account\nconst account = await tam.models.TelegramAccount.create({\n  phone: '+919876543210', name: 'Main Account', session, tags: ['outreach'],\n  // ... other required fields\n});\n\n// 3. Connect\nawait tam.connection.connect(account._id.toString());\n\n// Get connected clients\nconst clients = tam.getConnectedAccounts();\nconsole.log(clients); // [{ accountId, phone, name, isConnected }]\n\n// Graceful shutdown\nprocess.on('SIGTERM', () => tam.destroy());\n\napp.listen(3000);\n```\n\n## Features\n\n- **Multi-account management** -- TDLib session management with credential storage, status tracking, and connection lifecycle. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/configuration.md)\n- **Health tracking** -- Automatic scoring with flood wait detection and consecutive error tracking. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/types.md)\n- **Auto-quarantine** -- Accounts triggering PEER_FLOOD or USER_RESTRICTED are quarantined with configurable duration and automatic release. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/configuration.md#optionsquarantine)\n- **Account warmup** -- Phased volume ramp-up with configurable schedules (4-phase default). [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/configuration.md#optionswarmup)\n- **Daily capacity tracking** -- Per-account daily limit enforcement with usage percentage tracking. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/api-routes.md)\n- **Telegram identifier management** -- Track Telegram user IDs, usernames, and contact mappings with status lifecycle. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/api-routes.md#identifier-routes)\n- **Session generation** -- Two-step phone auth flow (request code, verify OTP, handle 2FA) to produce session strings for new accounts. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/api-routes.md#session-routes)\n- **Account rotation** -- Rotate between accounts using round-robin, least-used, or highest-health strategies via `AccountRotator`. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/types.md#exported-service-classes)\n- **Idle timeout** -- Automatically disconnect accounts that have been idle (no sends) for a configurable duration. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/configuration.md#optionsidletimeoutms)\n- **Account tags** -- Tag accounts for categorization and filtering (e.g., by purpose, region, or priority). Filter accounts by tag via the REST API.\n- **Direct message sending** -- Low-level `sendMessage()` on connected accounts, usable by inbox and other consumers. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/api-routes.md#send-message)\n- **Express routes out of the box** -- 25 REST endpoints for accounts, identifiers, and sessions. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/api-routes.md)\n- **Adapter-based DI** -- Database-agnostic via Mongoose connection injection, logger adapter, lifecycle hooks.\n- **Error classification** -- Critical errors (ban), quarantine errors (flood), skip errors (privacy), and recoverable errors (network) are handled automatically.\n\n## Architecture\n\nThe library exposes a single Express router from a factory call:\n\n| Router | Purpose | Access |\n|--------|---------|--------|\n| `tam.routes` | Admin API -- accounts, identifiers, capacity, health | Protected (add your auth middleware) |\n\nAll services are also available programmatically via the returned `tam` object.\n\n## Getting Started Guide\n\n1. [Configuration](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/configuration.md) -- Set up database, credentials, options, and hooks\n2. [API Routes](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/api-routes.md) -- 25 REST endpoints for accounts, identifiers, and sessions\n3. [Types](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/account-manager/docs/types.md) -- All importable types, constants, errors, and service classes\n\n> **Important:** When `autoAdvance: true` (the default), the library automatically calls `advanceAllAccounts()` every 24 hours via an internal `setInterval` -- no cron job needed. When `autoAdvance: false`, you must call `warmup.advanceDay(accountId)` manually for each account.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}