beast-agent 0.26.1 → 0.26.2

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "beast-agent",
3
3
  "productName": "Beast Agent",
4
- "version": "0.26.1",
4
+ "version": "0.26.2",
5
5
  "description": "Ultra-fast local agent shell for Windows.",
6
6
  "author": "algokodcom (AlgoKod)",
7
7
  "license": "MIT",
@@ -20,6 +20,19 @@ const SEND_CHUNK = 1900; // Discord mesaj sınırı 2000 — güvenli pay
20
20
  /* GUILDS(1) | GUILD_MESSAGES(512) | DIRECT_MESSAGES(4096) | MESSAGE_CONTENT(32768) */
21
21
  const INTENTS = 1 | 512 | 4096 | 32768;
22
22
 
23
+ /* AĞ ARA YAZILIMI (antivirüs SSL taraması / proxy / ağ filtresi) Discord
24
+ trafiğine araya girip SELF-SIGNED sertifika sunarsa Node varsayılan olarak
25
+ bağlantıyı reddeder ("self signed certificate") ve bot hiç bağlanamaz.
26
+ Çözüm: hata tespit edilince bu köprü için TLS doğrulaması esnetilir ve
27
+ uyarı loglanır — YALNIZ Discord bağlantıları etkilenir, app'in geri kalanı
28
+ normal doğrulama kullanmaya devam eder. */
29
+ let tlsRelaxed = false;
30
+ const CERT_ERR_RE = /self[ -]?signed|unable to verify the first certificate|depth zero|err_tls|certificate has expired|cert_has_expired|unable_to_get_issuer|self signed certificate/i;
31
+
32
+ function isCertError(e) {
33
+ return CERT_ERR_RE.test(String((e && (e.message || e.code)) || e || ''));
34
+ }
35
+
23
36
  class DiscordBridge {
24
37
  constructor({ token, emit, onIncoming }) {
25
38
  this.token = String(token || '').trim();
@@ -41,8 +54,9 @@ class DiscordBridge {
41
54
  this.emit({ type: 'status', status, user: user || null });
42
55
  }
43
56
 
44
- /* REST çağrısı — JSON (token: "Bot <token>") */
45
- api(method, path, body) {
57
+ /* REST çağrısı — JSON (token: "Bot <token>"). Cert engeli tespit edilirse
58
+ TLS esnetilip TEK seferlik yeniden denenir. */
59
+ api(method, path, body, attempt = 0) {
46
60
  return new Promise((resolve, reject) => {
47
61
  const payload = body ? JSON.stringify(body) : null;
48
62
  const req = https.request(
@@ -55,6 +69,7 @@ class DiscordBridge {
55
69
  ...(payload ? { 'Content-Length': Buffer.byteLength(payload) } : {}),
56
70
  },
57
71
  timeout: 15000,
72
+ rejectUnauthorized: !tlsRelaxed,
58
73
  },
59
74
  (res) => {
60
75
  let data = '';
@@ -75,6 +90,17 @@ class DiscordBridge {
75
90
  req.on('error', reject);
76
91
  if (payload) req.write(payload);
77
92
  req.end();
93
+ }).catch((e) => {
94
+ /* ara yazılım sertifikası tespit: esnet ve aynı isteği bir kez daha dene */
95
+ if (isCertError(e) && !tlsRelaxed) {
96
+ tlsRelaxed = true;
97
+ this.emit({
98
+ type: 'warn',
99
+ text: 'ağ ara yazılımı (antivirüs/proxy) self-signed sertifikası tespit edildi — Discord bağlantısı esnek TLS ile devam ediyor',
100
+ });
101
+ if (attempt < 1) return this.api(method, path, body, attempt + 1);
102
+ }
103
+ throw e;
78
104
  });
79
105
  }
80
106
 
@@ -102,7 +128,7 @@ class DiscordBridge {
102
128
  clearInterval(this._hbTimer);
103
129
  this._hbTimer = null;
104
130
  let identified = false;
105
- const ws = new WebSocket(GATEWAY_URL);
131
+ const ws = new WebSocket(GATEWAY_URL, { rejectUnauthorized: !tlsRelaxed });
106
132
  this._ws = ws;
107
133
 
108
134
  ws.on('message', (raw) => {
@@ -193,8 +219,16 @@ class DiscordBridge {
193
219
  setTimeout(() => this._connect(), wait);
194
220
  });
195
221
 
196
- ws.on('error', () => {
197
- /* close tetikleniryeniden bağlanma orada */
222
+ ws.on('error', (e) => {
223
+ /* gateway TLS'i de ara yazılımdan etkilenebilir esnet ve close sonrası
224
+ yeniden bağlanma zaten relaxed ile kurar */
225
+ if (isCertError(e) && !tlsRelaxed) {
226
+ tlsRelaxed = true;
227
+ this.emit({
228
+ type: 'warn',
229
+ text: 'ağ ara yazılımı (antivirüs/proxy) self-signed sertifikası tespit edildi — Discord bağlantısı esnek TLS ile devam ediyor',
230
+ });
231
+ }
198
232
  });
199
233
  }
200
234
 
package/src/main.js CHANGED
@@ -2240,6 +2240,7 @@ function ensureDc() {
2240
2240
  token: settings.dcToken || '',
2241
2241
  emit: (ev) => {
2242
2242
  if (ev.type === 'status') dcLog(`status=${ev.status}${ev.user ? ' user=' + ev.user : ''}`);
2243
+ if (ev.type === 'warn') dcLog('⚠ ' + String(ev.text || ''));
2243
2244
  if (win && !win.isDestroyed()) win.webContents.send('dc:event', ev);
2244
2245
  },
2245
2246
  onIncoming: handleDcIncoming,