@solongate/proxy 0.2.4 → 0.2.6

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.
Files changed (3) hide show
  1. package/dist/index.js +18 -14
  2. package/dist/init.js +18 -14
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -529,22 +529,26 @@ process.stdin.on('end', async () => {
529
529
  const ms = Date.now() - start;
530
530
 
531
531
  if (threat) {
532
- // Send DENY audit log
532
+ // Send DENY audit log \u2014 MUST await before exit or fetch dies
533
533
  if (API_KEY && API_KEY.startsWith('sg_live_')) {
534
- fetch(API_URL + '/api/v1/audit-logs', {
535
- method: 'POST',
536
- headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' },
537
- body: JSON.stringify({
538
- tool, arguments: Object.fromEntries(Object.entries(args).map(([k,v]) =>
539
- [k, typeof v === 'string' && v.length > 200 ? v.slice(0,200)+'...' : v])),
540
- decision: 'DENY', reason: threat, source: 'claude-code-guard',
541
- evaluationTimeMs: ms,
542
- }),
543
- signal: AbortSignal.timeout(5000),
544
- }).catch(() => {});
534
+ try {
535
+ await fetch(API_URL + '/api/v1/audit-logs', {
536
+ method: 'POST',
537
+ headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' },
538
+ body: JSON.stringify({
539
+ tool, arguments: Object.fromEntries(Object.entries(args).map(([k,v]) =>
540
+ [k, typeof v === 'string' && v.length > 200 ? v.slice(0,200)+'...' : v])),
541
+ decision: 'DENY', reason: threat, source: 'claude-code-guard',
542
+ evaluationTimeMs: ms,
543
+ }),
544
+ signal: AbortSignal.timeout(3000),
545
+ });
546
+ } catch {}
545
547
  }
546
- // Exit 2 = BLOCK. Message printed to stdout is shown to user.
547
- process.stdout.write('SolonGate BLOCKED: ' + threat);
548
+ // Exit 2 = BLOCK. Write to both stdout and stderr for visibility.
549
+ const msg = 'SOLONGATE BLOCKED: ' + threat;
550
+ process.stdout.write(msg);
551
+ process.stderr.write(msg);
548
552
  process.exit(2);
549
553
  }
550
554
  } catch {
package/dist/init.js CHANGED
@@ -248,22 +248,26 @@ process.stdin.on('end', async () => {
248
248
  const ms = Date.now() - start;
249
249
 
250
250
  if (threat) {
251
- // Send DENY audit log
251
+ // Send DENY audit log \u2014 MUST await before exit or fetch dies
252
252
  if (API_KEY && API_KEY.startsWith('sg_live_')) {
253
- fetch(API_URL + '/api/v1/audit-logs', {
254
- method: 'POST',
255
- headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' },
256
- body: JSON.stringify({
257
- tool, arguments: Object.fromEntries(Object.entries(args).map(([k,v]) =>
258
- [k, typeof v === 'string' && v.length > 200 ? v.slice(0,200)+'...' : v])),
259
- decision: 'DENY', reason: threat, source: 'claude-code-guard',
260
- evaluationTimeMs: ms,
261
- }),
262
- signal: AbortSignal.timeout(5000),
263
- }).catch(() => {});
253
+ try {
254
+ await fetch(API_URL + '/api/v1/audit-logs', {
255
+ method: 'POST',
256
+ headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' },
257
+ body: JSON.stringify({
258
+ tool, arguments: Object.fromEntries(Object.entries(args).map(([k,v]) =>
259
+ [k, typeof v === 'string' && v.length > 200 ? v.slice(0,200)+'...' : v])),
260
+ decision: 'DENY', reason: threat, source: 'claude-code-guard',
261
+ evaluationTimeMs: ms,
262
+ }),
263
+ signal: AbortSignal.timeout(3000),
264
+ });
265
+ } catch {}
264
266
  }
265
- // Exit 2 = BLOCK. Message printed to stdout is shown to user.
266
- process.stdout.write('SolonGate BLOCKED: ' + threat);
267
+ // Exit 2 = BLOCK. Write to both stdout and stderr for visibility.
268
+ const msg = 'SOLONGATE BLOCKED: ' + threat;
269
+ process.stdout.write(msg);
270
+ process.stderr.write(msg);
267
271
  process.exit(2);
268
272
  }
269
273
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "MCP security proxy \u00e2\u20ac\u201d protect any MCP server with policies, input validation, rate limiting, and audit logging. Zero code changes required.",
5
5
  "type": "module",
6
6
  "bin": {