natureco-cli 1.0.39 → 1.0.41
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/package.json
CHANGED
|
@@ -45,6 +45,12 @@ function log(module, message, color = 'white') {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// Number matching helper - compare last 10 digits only
|
|
49
|
+
function numberMatches(incoming, allowed) {
|
|
50
|
+
const clean = (n) => n.replace(/\D/g, '').slice(-10);
|
|
51
|
+
return clean(incoming) === clean(allowed);
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
async function gatewayServer(action) {
|
|
49
55
|
// Check if running as background worker
|
|
50
56
|
if (process.argv.includes('--gateway-worker')) {
|
|
@@ -239,8 +245,8 @@ async function startWhatsAppProvider(sessionDir, config) {
|
|
|
239
245
|
// Log incoming number before access control
|
|
240
246
|
log('whatsapp', `Incoming from: +${sender}, allowed: ${JSON.stringify(allowedNumbers)}`, 'gray');
|
|
241
247
|
|
|
242
|
-
// Access control
|
|
243
|
-
if (allowedNumbers.length > 0 && !allowedNumbers.
|
|
248
|
+
// Access control - compare last 10 digits
|
|
249
|
+
if (allowedNumbers.length > 0 && !allowedNumbers.some(n => numberMatches(n, sender))) {
|
|
244
250
|
log('whatsapp', `blocked message from +${sender} (not in allowed list)`, 'yellow');
|
|
245
251
|
continue;
|
|
246
252
|
}
|
package/src/commands/whatsapp.js
CHANGED
|
@@ -108,10 +108,10 @@ async function connectWhatsApp() {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
// Start connection (only for QR code)
|
|
111
|
-
await startWhatsAppConnection(sessionDir, botId, selectedBot, config
|
|
111
|
+
await startWhatsAppConnection(sessionDir, botId, selectedBot, config);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
async function startWhatsAppConnection(sessionDir, botId, selectedBot, config
|
|
114
|
+
async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
|
|
115
115
|
try {
|
|
116
116
|
// Create auth state
|
|
117
117
|
const { state, saveCreds } = await useMultiFileAuthState(sessionDir);
|
|
@@ -162,7 +162,7 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config, a
|
|
|
162
162
|
if (statusCode === 515 || statusCode === 408) {
|
|
163
163
|
// Normal — yeniden bağlan, logout değil
|
|
164
164
|
console.log(chalk.yellow('🔄 Yeniden bağlanıyor...'));
|
|
165
|
-
setTimeout(() => startWhatsAppConnection(sessionDir, botId, selectedBot, config
|
|
165
|
+
setTimeout(() => startWhatsAppConnection(sessionDir, botId, selectedBot, config), 2000);
|
|
166
166
|
return;
|
|
167
167
|
} else if (statusCode === 401) {
|
|
168
168
|
console.log(chalk.red('❌ Oturum sonlandı, tekrar bağlanın.'));
|
|
@@ -185,15 +185,19 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config, a
|
|
|
185
185
|
console.log(chalk.cyan('Telefon:'), chalk.white(sock.user?.id || 'Unknown'));
|
|
186
186
|
console.log(chalk.gray('\nSession kaydedildi: ~/.natureco/whatsapp-sessions/'));
|
|
187
187
|
|
|
188
|
-
//
|
|
188
|
+
// Extract own number and add to allowed list
|
|
189
|
+
const ownNumber = sock.user?.id?.split(':')[0].replace('@s.whatsapp.net', '') || '';
|
|
190
|
+
const allowedNumbers = ownNumber ? [ownNumber] : [];
|
|
191
|
+
|
|
192
|
+
// Save to config with own number in allowed list
|
|
189
193
|
config.whatsappConnected = true;
|
|
190
194
|
config.whatsappBotId = botId;
|
|
191
195
|
config.whatsappPhone = sock.user?.id;
|
|
192
|
-
config.whatsappAllowedNumbers =
|
|
196
|
+
config.whatsappAllowedNumbers = allowedNumbers;
|
|
193
197
|
saveConfig(config);
|
|
194
198
|
|
|
195
|
-
console.log(chalk.cyan('\nİzin
|
|
196
|
-
console.log(chalk.gray('
|
|
199
|
+
console.log(chalk.cyan('\nİzin verilen numara:'), chalk.white(`+${ownNumber} (kendi numaranız)`));
|
|
200
|
+
console.log(chalk.gray('Başka numara eklemek için: natureco whatsapp allow <numara>'));
|
|
197
201
|
|
|
198
202
|
console.log(chalk.green('\n✅ Kurulum tamamlandı!\n'));
|
|
199
203
|
console.log(chalk.yellow('Gateway ile başlatmak için:'), chalk.cyan('natureco gateway start'));
|