telegram-ssh-bot 2.2.0 → 2.4.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/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +27 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/schema.js +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/core/ConnectionPool.d.ts.map +1 -1
- package/dist/core/ConnectionPool.js +28 -22
- package/dist/core/ConnectionPool.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/services/BackupService.d.ts +1 -1
- package/dist/services/BackupService.d.ts.map +1 -1
- package/dist/services/BackupService.js +3 -9
- package/dist/services/BackupService.js.map +1 -1
- package/dist/services/ValidationService.d.ts.map +1 -1
- package/dist/services/ValidationService.js +2 -2
- package/dist/services/ValidationService.js.map +1 -1
- package/dist/utils/pathUtils.d.ts +5 -0
- package/dist/utils/pathUtils.d.ts.map +1 -1
- package/dist/utils/pathUtils.js +35 -0
- package/dist/utils/pathUtils.js.map +1 -1
- package/dist/wizard/InstallationWizard.d.ts +32 -0
- package/dist/wizard/InstallationWizard.d.ts.map +1 -0
- package/dist/wizard/InstallationWizard.js +96 -0
- package/dist/wizard/InstallationWizard.js.map +1 -0
- package/dist/wizard/index.d.ts +10 -0
- package/dist/wizard/index.d.ts.map +1 -0
- package/dist/wizard/index.js +8 -0
- package/dist/wizard/index.js.map +1 -0
- package/dist/wizard/prompts.d.ts +45 -0
- package/dist/wizard/prompts.d.ts.map +1 -0
- package/dist/wizard/prompts.js +194 -0
- package/dist/wizard/prompts.js.map +1 -0
- package/dist/wizard/validators.d.ts +50 -0
- package/dist/wizard/validators.d.ts.map +1 -0
- package/dist/wizard/validators.js +107 -0
- package/dist/wizard/validators.js.map +1 -0
- package/package.json +3 -1
- package/scripts/setup-env.d.ts +28 -0
- package/scripts/setup-env.js +61 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "telegram-ssh-bot",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "A Telegram bot for secure SSH server management and remote command execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -64,11 +64,13 @@
|
|
|
64
64
|
"dotenv": "^16.3.1",
|
|
65
65
|
"joi": "^17.11.0",
|
|
66
66
|
"node-telegram-bot-api": "^0.61.0",
|
|
67
|
+
"prompts": "^2.4.2",
|
|
67
68
|
"ssh2": "^1.14.0"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@types/node": "^20.10.0",
|
|
71
72
|
"@types/node-telegram-bot-api": "^0.61.0",
|
|
73
|
+
"@types/prompts": "^2.4.9",
|
|
72
74
|
"@types/ssh2": "^1.15.0",
|
|
73
75
|
"@yao-pkg/pkg": "^5.11.0",
|
|
74
76
|
"nodemon": "^3.0.1",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for setup-env.js
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export function getConfigDir(): string;
|
|
6
|
+
export function getEnvFilePath(): string;
|
|
7
|
+
export function getEnvExamplePath(): string | null;
|
|
8
|
+
export function ensureConfigDir(): string;
|
|
9
|
+
export function generateEncryptionKey(): string;
|
|
10
|
+
export function envFileExists(): boolean;
|
|
11
|
+
export function createEnvFile(options?: { generateKey?: boolean }): boolean;
|
|
12
|
+
export function writeEnvFile(values: {
|
|
13
|
+
botToken: string;
|
|
14
|
+
botChatId: string;
|
|
15
|
+
botOwnerIds: string[];
|
|
16
|
+
encryptionKey: string;
|
|
17
|
+
}): boolean;
|
|
18
|
+
export function main(options?: {
|
|
19
|
+
force?: boolean;
|
|
20
|
+
generateKey?: boolean;
|
|
21
|
+
silent?: boolean;
|
|
22
|
+
}): {
|
|
23
|
+
success: boolean;
|
|
24
|
+
created: boolean;
|
|
25
|
+
envPath: string;
|
|
26
|
+
configDir: string;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
package/scripts/setup-env.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
import { randomBytes } from "crypto";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
copyFileSync,
|
|
10
|
+
existsSync,
|
|
11
|
+
mkdirSync,
|
|
12
|
+
readFileSync,
|
|
13
|
+
writeFileSync,
|
|
14
14
|
} from "fs";
|
|
15
15
|
import { homedir } from "os";
|
|
16
16
|
import { join } from "path";
|
|
@@ -164,6 +164,62 @@ MONITORING_INTERVAL_MS=300000
|
|
|
164
164
|
return true;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Write a .env file with specific values
|
|
169
|
+
* Used by the installation wizard
|
|
170
|
+
* @param {Object} values - Configuration values
|
|
171
|
+
* @param {string} values.botToken - Telegram bot token
|
|
172
|
+
* @param {string} values.botChatId - Telegram chat ID
|
|
173
|
+
* @param {string[]} values.botOwnerIds - Array of owner IDs
|
|
174
|
+
* @param {string} values.encryptionKey - Encryption key (64 hex chars)
|
|
175
|
+
* @returns {boolean} True if the file was written successfully
|
|
176
|
+
*/
|
|
177
|
+
export function writeEnvFile(values) {
|
|
178
|
+
const { botToken, botChatId, botOwnerIds, encryptionKey } = values;
|
|
179
|
+
|
|
180
|
+
// Ensure config directory exists
|
|
181
|
+
ensureConfigDir();
|
|
182
|
+
|
|
183
|
+
const envPath = getEnvFilePath();
|
|
184
|
+
|
|
185
|
+
// Build .env content
|
|
186
|
+
const envContent = `# Telegram Bot Configuration
|
|
187
|
+
BOT_TOKEN=${botToken}
|
|
188
|
+
BOT_CHAT_ID=${botChatId}
|
|
189
|
+
BOT_OWNER_IDS=${botOwnerIds.join(",")}
|
|
190
|
+
|
|
191
|
+
# Security
|
|
192
|
+
ENCRYPTION_KEY=${encryptionKey}
|
|
193
|
+
|
|
194
|
+
# SSH Configuration
|
|
195
|
+
SSH_DEFAULT_PORT=22
|
|
196
|
+
SSH_CONNECTION_TIMEOUT=30000
|
|
197
|
+
SSH_COMMAND_TIMEOUT=30000
|
|
198
|
+
SSH_DEFAULT_PRIVATE_KEY_PATH=
|
|
199
|
+
|
|
200
|
+
# Rate Limiting
|
|
201
|
+
RATE_LIMIT_ENABLED=true
|
|
202
|
+
RATE_LIMIT_WINDOW_MS=60000
|
|
203
|
+
RATE_LIMIT_MAX_REQUESTS=100
|
|
204
|
+
|
|
205
|
+
# Backup
|
|
206
|
+
BACKUP_ENABLED=true
|
|
207
|
+
BACKUP_INTERVAL_MS=3600000
|
|
208
|
+
BACKUP_MAX_COUNT=10
|
|
209
|
+
|
|
210
|
+
# Monitoring
|
|
211
|
+
MONITORING_ENABLED=true
|
|
212
|
+
MONITORING_INTERVAL_MS=300000
|
|
213
|
+
|
|
214
|
+
# Logging
|
|
215
|
+
LOG_LEVEL=info
|
|
216
|
+
LOG_FORMAT=json
|
|
217
|
+
`;
|
|
218
|
+
|
|
219
|
+
writeFileSync(envPath, envContent);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
|
|
167
223
|
/**
|
|
168
224
|
* Main function to set up the environment
|
|
169
225
|
* @param {Object} options - Setup options
|