@ebowwa/mcp-telegram 0.1.4 ā 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +300 -0
- package/package.json +4 -2
- package/src/index.ts +355 -0
- package/auth-signin.js +0 -182
- package/auth-verify.js +0 -234
- package/auth.js +0 -154
- package/bun.lock +0 -302
- package/dist/index.d.ts +0 -18
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/src/index.js +0 -918
package/auth-verify.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
"use strict";
|
|
3
|
-
/**
|
|
4
|
-
* Telegram Authentication Script (Non-interactive)
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* Step 1 - Request code:
|
|
8
|
-
* doppler run --project seed --config prd -- bun run auth-verify.ts +1234567890
|
|
9
|
-
*
|
|
10
|
-
* Step 2 - Verify with code:
|
|
11
|
-
* doppler run --project seed --config prd -- bun run auth-verify.ts +1234567890 12345
|
|
12
|
-
*
|
|
13
|
-
* Step 3 - With 2FA password:
|
|
14
|
-
* doppler run --project seed --config prd -- bun run auth-verify.ts +1234567890 12345 "mypassword"
|
|
15
|
-
*/
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
27
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var telegram_1 = require("telegram");
|
|
54
|
-
var sessions_1 = require("telegram/sessions");
|
|
55
|
-
var os_1 = require("os");
|
|
56
|
-
var path_1 = require("path");
|
|
57
|
-
var fs_1 = require("fs");
|
|
58
|
-
var SESSION_DIR = (0, path_1.join)((0, os_1.homedir)(), ".telegram-mcp");
|
|
59
|
-
var SESSION_FILE = (0, path_1.join)(SESSION_DIR, "session.txt");
|
|
60
|
-
var PHONE_CODE_HASH_FILE = (0, path_1.join)(SESSION_DIR, "phone_code_hash.txt");
|
|
61
|
-
// Ensure session directory exists
|
|
62
|
-
if (!(0, fs_1.existsSync)(SESSION_DIR)) {
|
|
63
|
-
(0, fs_1.mkdirSync)(SESSION_DIR, { recursive: true });
|
|
64
|
-
}
|
|
65
|
-
function main() {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var apiId, apiHash, phoneNumber, code, password, existingSession, session_1, client_1, me, e_1, session, client, result, e_2, phoneCodeHash, result, e_3, passwordInfo, _a, _b, _c, _d, sessionString, me, e_4;
|
|
68
|
-
var _e;
|
|
69
|
-
var _f;
|
|
70
|
-
return __generator(this, function (_g) {
|
|
71
|
-
switch (_g.label) {
|
|
72
|
-
case 0:
|
|
73
|
-
apiId = parseInt(process.env.TELEGRAM_API_ID || "0");
|
|
74
|
-
apiHash = process.env.TELEGRAM_API_HASH;
|
|
75
|
-
if (!apiId || !apiHash) {
|
|
76
|
-
console.error("ERROR: TELEGRAM_API_ID and TELEGRAM_API_HASH must be set");
|
|
77
|
-
console.error("Run with: doppler run --project seed --config prd -- bun run auth-verify.ts ...");
|
|
78
|
-
process.exit(1);
|
|
79
|
-
}
|
|
80
|
-
phoneNumber = process.argv[2];
|
|
81
|
-
code = process.argv[3];
|
|
82
|
-
password = process.argv[4] || "";
|
|
83
|
-
if (!phoneNumber) {
|
|
84
|
-
console.error("Usage: bun run auth-verify.ts <phone> [code] [password]");
|
|
85
|
-
console.error(" phone: Phone number with country code (e.g., +1234567890)");
|
|
86
|
-
console.error(" code: Verification code (optional, for step 2)");
|
|
87
|
-
console.error(" password: 2FA password (optional)");
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
if (!(0, fs_1.existsSync)(SESSION_FILE)) return [3 /*break*/, 8];
|
|
91
|
-
existingSession = (0, fs_1.readFileSync)(SESSION_FILE, "utf-8").trim();
|
|
92
|
-
if (!(existingSession && !code)) return [3 /*break*/, 8];
|
|
93
|
-
console.log("Found existing session, testing connection...");
|
|
94
|
-
session_1 = new sessions_1.StringSession(existingSession);
|
|
95
|
-
client_1 = new telegram_1.TelegramClient(session_1, apiId, apiHash, {
|
|
96
|
-
connectionRetries: 5,
|
|
97
|
-
});
|
|
98
|
-
_g.label = 1;
|
|
99
|
-
case 1:
|
|
100
|
-
_g.trys.push([1, 7, , 8]);
|
|
101
|
-
return [4 /*yield*/, client_1.connect()];
|
|
102
|
-
case 2:
|
|
103
|
-
_g.sent();
|
|
104
|
-
return [4 /*yield*/, client_1.checkAuthorization()];
|
|
105
|
-
case 3:
|
|
106
|
-
if (!_g.sent()) return [3 /*break*/, 6];
|
|
107
|
-
return [4 /*yield*/, client_1.getMe()];
|
|
108
|
-
case 4:
|
|
109
|
-
me = _g.sent();
|
|
110
|
-
console.log("\nā
Already authenticated as:", me.firstName, me.lastName || "");
|
|
111
|
-
console.log("š Phone:", me.phone);
|
|
112
|
-
return [4 /*yield*/, client_1.disconnect()];
|
|
113
|
-
case 5:
|
|
114
|
-
_g.sent();
|
|
115
|
-
process.exit(0);
|
|
116
|
-
_g.label = 6;
|
|
117
|
-
case 6: return [3 /*break*/, 8];
|
|
118
|
-
case 7:
|
|
119
|
-
e_1 = _g.sent();
|
|
120
|
-
console.log("Existing session invalid, re-authenticating...");
|
|
121
|
-
return [3 /*break*/, 8];
|
|
122
|
-
case 8:
|
|
123
|
-
session = new sessions_1.StringSession("");
|
|
124
|
-
client = new telegram_1.TelegramClient(session, apiId, apiHash, {
|
|
125
|
-
connectionRetries: 5,
|
|
126
|
-
});
|
|
127
|
-
return [4 /*yield*/, client.connect()];
|
|
128
|
-
case 9:
|
|
129
|
-
_g.sent();
|
|
130
|
-
if (!!code) return [3 /*break*/, 14];
|
|
131
|
-
// Step 1: Send verification code
|
|
132
|
-
console.log("\n\uD83D\uDCF1 Sending verification code to ".concat(phoneNumber, "..."));
|
|
133
|
-
_g.label = 10;
|
|
134
|
-
case 10:
|
|
135
|
-
_g.trys.push([10, 12, , 13]);
|
|
136
|
-
return [4 /*yield*/, client.invoke(new telegram_1.Api.auth.SendCode({
|
|
137
|
-
phoneNumber: phoneNumber,
|
|
138
|
-
apiId: apiId,
|
|
139
|
-
apiHash: apiHash,
|
|
140
|
-
settings: new telegram_1.Api.CodeSettings({}),
|
|
141
|
-
}))];
|
|
142
|
-
case 11:
|
|
143
|
-
result = _g.sent();
|
|
144
|
-
// Save phone_code_hash for step 2
|
|
145
|
-
(0, fs_1.writeFileSync)(PHONE_CODE_HASH_FILE, result.phoneCodeHash, "utf-8");
|
|
146
|
-
console.log("\nā
Verification code sent!");
|
|
147
|
-
console.log("Check your Telegram app for the code.");
|
|
148
|
-
console.log("\nNext step: Run this command with the code:");
|
|
149
|
-
console.log(" doppler run --project seed --config prd -- bun run auth-verify.ts ".concat(phoneNumber, " <CODE>"));
|
|
150
|
-
return [3 /*break*/, 13];
|
|
151
|
-
case 12:
|
|
152
|
-
e_2 = _g.sent();
|
|
153
|
-
console.error("\nā Error sending code:", e_2.message);
|
|
154
|
-
return [3 /*break*/, 13];
|
|
155
|
-
case 13: return [3 /*break*/, 27];
|
|
156
|
-
case 14:
|
|
157
|
-
// Step 2: Sign in with code
|
|
158
|
-
console.log("\n\uD83D\uDD10 Signing in with code: ".concat(code, "..."));
|
|
159
|
-
phoneCodeHash = "";
|
|
160
|
-
if ((0, fs_1.existsSync)(PHONE_CODE_HASH_FILE)) {
|
|
161
|
-
phoneCodeHash = (0, fs_1.readFileSync)(PHONE_CODE_HASH_FILE, "utf-8").trim();
|
|
162
|
-
}
|
|
163
|
-
if (!phoneCodeHash) {
|
|
164
|
-
console.error("ā No phone_code_hash found. Run step 1 first (without code).");
|
|
165
|
-
process.exit(1);
|
|
166
|
-
}
|
|
167
|
-
_g.label = 15;
|
|
168
|
-
case 15:
|
|
169
|
-
_g.trys.push([15, 26, , 27]);
|
|
170
|
-
result = void 0;
|
|
171
|
-
_g.label = 16;
|
|
172
|
-
case 16:
|
|
173
|
-
_g.trys.push([16, 18, , 24]);
|
|
174
|
-
return [4 /*yield*/, client.invoke(new telegram_1.Api.auth.SignIn({
|
|
175
|
-
phoneNumber: phoneNumber,
|
|
176
|
-
phoneCodeHash: phoneCodeHash,
|
|
177
|
-
phoneCode: code,
|
|
178
|
-
}))];
|
|
179
|
-
case 17:
|
|
180
|
-
result = _g.sent();
|
|
181
|
-
return [3 /*break*/, 24];
|
|
182
|
-
case 18:
|
|
183
|
-
e_3 = _g.sent();
|
|
184
|
-
if (!(((_f = e_3.message) === null || _f === void 0 ? void 0 : _f.includes("SESSION_PASSWORD_NEEDED")) || password)) return [3 /*break*/, 22];
|
|
185
|
-
// 2FA required
|
|
186
|
-
if (!password) {
|
|
187
|
-
console.log("\nā ļø 2FA is enabled on this account.");
|
|
188
|
-
console.log("Please provide your 2FA password:");
|
|
189
|
-
console.log(" doppler run --project seed --config prd -- bun run auth-verify.ts ".concat(phoneNumber, " ").concat(code, " \"YOUR_PASSWORD\""));
|
|
190
|
-
process.exit(1);
|
|
191
|
-
}
|
|
192
|
-
return [4 /*yield*/, client.invoke(new telegram_1.Api.account.GetPassword({}))];
|
|
193
|
-
case 19:
|
|
194
|
-
passwordInfo = _g.sent();
|
|
195
|
-
_b = (_a = client).invoke;
|
|
196
|
-
_d = (_c = telegram_1.Api.auth.CheckPassword).bind;
|
|
197
|
-
_e = {};
|
|
198
|
-
return [4 /*yield*/, client.computeCheck(passwordInfo, password)];
|
|
199
|
-
case 20: return [4 /*yield*/, _b.apply(_a, [new (_d.apply(_c, [void 0, (_e.password = _g.sent(),
|
|
200
|
-
_e)]))()])];
|
|
201
|
-
case 21:
|
|
202
|
-
result = _g.sent();
|
|
203
|
-
return [3 /*break*/, 23];
|
|
204
|
-
case 22: throw e_3;
|
|
205
|
-
case 23: return [3 /*break*/, 24];
|
|
206
|
-
case 24:
|
|
207
|
-
sessionString = client.session.save();
|
|
208
|
-
(0, fs_1.writeFileSync)(SESSION_FILE, sessionString, "utf-8");
|
|
209
|
-
console.log("\nā
Successfully authenticated!");
|
|
210
|
-
console.log("\uD83D\uDCC1 Session saved to: ".concat(SESSION_FILE));
|
|
211
|
-
return [4 /*yield*/, client.getMe()];
|
|
212
|
-
case 25:
|
|
213
|
-
me = _g.sent();
|
|
214
|
-
console.log("\uD83D\uDC64 Logged in as: ".concat(me.firstName, " ").concat(me.lastName || ""));
|
|
215
|
-
console.log("\uD83D\uDCDE Phone: ".concat(me.phone));
|
|
216
|
-
console.log("\uD83D\uDC64 Username: @".concat(me.username || "N/A"));
|
|
217
|
-
return [3 /*break*/, 27];
|
|
218
|
-
case 26:
|
|
219
|
-
e_4 = _g.sent();
|
|
220
|
-
console.error("\nā Sign in error:", e_4.message);
|
|
221
|
-
return [3 /*break*/, 27];
|
|
222
|
-
case 27: return [4 /*yield*/, client.disconnect()];
|
|
223
|
-
case 28:
|
|
224
|
-
_g.sent();
|
|
225
|
-
process.exit(0);
|
|
226
|
-
return [2 /*return*/];
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
main().catch(function (err) {
|
|
232
|
-
console.error("Fatal error:", err);
|
|
233
|
-
process.exit(1);
|
|
234
|
-
});
|
package/auth.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
"use strict";
|
|
3
|
-
/**
|
|
4
|
-
* Telegram Authentication Script
|
|
5
|
-
*
|
|
6
|
-
* Run this once to authenticate and generate a session string.
|
|
7
|
-
* The session will be saved to ~/.telegram-mcp/session.txt
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* bun run auth.ts
|
|
11
|
-
*
|
|
12
|
-
* Environment variables (from Doppler):
|
|
13
|
-
* TELEGRAM_API_ID - Your Telegram API ID
|
|
14
|
-
* TELEGRAM_API_HASH - Your Telegram API Hash
|
|
15
|
-
*/
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
27
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var telegram_1 = require("telegram");
|
|
54
|
-
var sessions_1 = require("telegram/sessions");
|
|
55
|
-
var readline_1 = require("readline");
|
|
56
|
-
var os_1 = require("os");
|
|
57
|
-
var path_1 = require("path");
|
|
58
|
-
var fs_1 = require("fs");
|
|
59
|
-
var SESSION_DIR = (0, path_1.join)((0, os_1.homedir)(), ".telegram-mcp");
|
|
60
|
-
var SESSION_FILE = (0, path_1.join)(SESSION_DIR, "session.txt");
|
|
61
|
-
// Ensure session directory exists
|
|
62
|
-
if (!(0, fs_1.existsSync)(SESSION_DIR)) {
|
|
63
|
-
(0, fs_1.mkdirSync)(SESSION_DIR, { recursive: true });
|
|
64
|
-
}
|
|
65
|
-
var rl = readline_1.default.createInterface({
|
|
66
|
-
input: process.stdin,
|
|
67
|
-
output: process.stdout,
|
|
68
|
-
});
|
|
69
|
-
var question = function (prompt) {
|
|
70
|
-
return new Promise(function (resolve) {
|
|
71
|
-
rl.question(prompt, resolve);
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
function main() {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
-
var apiId, apiHash, session, client, sessionString;
|
|
77
|
-
var _this = this;
|
|
78
|
-
return __generator(this, function (_a) {
|
|
79
|
-
switch (_a.label) {
|
|
80
|
-
case 0:
|
|
81
|
-
apiId = parseInt(process.env.TELEGRAM_API_ID || "0");
|
|
82
|
-
apiHash = process.env.TELEGRAM_API_HASH;
|
|
83
|
-
if (!apiId || !apiHash) {
|
|
84
|
-
console.error("ERROR: TELEGRAM_API_ID and TELEGRAM_API_HASH must be set");
|
|
85
|
-
console.error("Run with: doppler run --project seed --config prd -- bun run auth.ts");
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
console.log("\nš± Telegram Authentication\n");
|
|
89
|
-
console.log("This will authenticate your Telegram account and save a session.");
|
|
90
|
-
console.log("You'll receive a verification code via Telegram.\n");
|
|
91
|
-
session = new sessions_1.StringSession("");
|
|
92
|
-
client = new telegram_1.TelegramClient(session, apiId, apiHash, {
|
|
93
|
-
connectionRetries: 5,
|
|
94
|
-
});
|
|
95
|
-
return [4 /*yield*/, client.start({
|
|
96
|
-
phoneNumber: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
97
|
-
var phone;
|
|
98
|
-
return __generator(this, function (_a) {
|
|
99
|
-
switch (_a.label) {
|
|
100
|
-
case 0: return [4 /*yield*/, question("Enter your phone number (with country code, e.g., +1234567890): ")];
|
|
101
|
-
case 1:
|
|
102
|
-
phone = _a.sent();
|
|
103
|
-
return [2 /*return*/, phone];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}); },
|
|
107
|
-
password: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
108
|
-
var password;
|
|
109
|
-
return __generator(this, function (_a) {
|
|
110
|
-
switch (_a.label) {
|
|
111
|
-
case 0: return [4 /*yield*/, question("Enter your 2FA password (if enabled, press Enter to skip): ")];
|
|
112
|
-
case 1:
|
|
113
|
-
password = _a.sent();
|
|
114
|
-
return [2 /*return*/, password || ""];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}); },
|
|
118
|
-
phoneCode: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
119
|
-
var code;
|
|
120
|
-
return __generator(this, function (_a) {
|
|
121
|
-
switch (_a.label) {
|
|
122
|
-
case 0: return [4 /*yield*/, question("Enter the verification code you received: ")];
|
|
123
|
-
case 1:
|
|
124
|
-
code = _a.sent();
|
|
125
|
-
return [2 /*return*/, code];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}); },
|
|
129
|
-
onError: function (err) {
|
|
130
|
-
console.error("Auth error:", err);
|
|
131
|
-
},
|
|
132
|
-
})];
|
|
133
|
-
case 1:
|
|
134
|
-
_a.sent();
|
|
135
|
-
rl.close();
|
|
136
|
-
sessionString = client.session.save();
|
|
137
|
-
(0, fs_1.writeFileSync)(SESSION_FILE, sessionString, "utf-8");
|
|
138
|
-
console.log("\nā
Successfully authenticated!");
|
|
139
|
-
console.log("\uD83D\uDCC1 Session saved to: ".concat(SESSION_FILE));
|
|
140
|
-
console.log("\uD83D\uDD11 Session string (backup): ".concat(sessionString.substring(0, 50), "..."));
|
|
141
|
-
console.log("\nYou can now use the Telegram MCP server.");
|
|
142
|
-
return [4 /*yield*/, client.disconnect()];
|
|
143
|
-
case 2:
|
|
144
|
-
_a.sent();
|
|
145
|
-
process.exit(0);
|
|
146
|
-
return [2 /*return*/];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
main().catch(function (err) {
|
|
152
|
-
console.error("Fatal error:", err);
|
|
153
|
-
process.exit(1);
|
|
154
|
-
});
|