securenow 5.2.1 → 5.2.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/nextjs.js +48 -6
- package/package.json +1 -1
package/nextjs.js
CHANGED
|
@@ -548,8 +548,48 @@ function registerSecureNow(options = {}) {
|
|
|
548
548
|
|
|
549
549
|
console.log('[securenow] 📋 Logging: ENABLED → %s', logsUrl);
|
|
550
550
|
|
|
551
|
+
// Auto-log every incoming HTTP request/response
|
|
552
|
+
try {
|
|
553
|
+
const http = require('http');
|
|
554
|
+
const originalEmit = http.Server.prototype.emit;
|
|
555
|
+
http.Server.prototype.emit = function (event, req, res) {
|
|
556
|
+
if (event === 'request' && req && res) {
|
|
557
|
+
const start = Date.now();
|
|
558
|
+
const method = req.method;
|
|
559
|
+
const url = req.url;
|
|
560
|
+
|
|
561
|
+
res.on('finish', () => {
|
|
562
|
+
const duration = Date.now() - start;
|
|
563
|
+
const status = res.statusCode;
|
|
564
|
+
const ip = req.headers['x-forwarded-for'] || req.headers['x-real-ip'] || req.socket?.remoteAddress || '-';
|
|
565
|
+
const ua = req.headers['user-agent'] || '-';
|
|
566
|
+
const body = `${method} ${url} ${status} ${duration}ms ip=${ip} ua=${ua}`;
|
|
567
|
+
const severity = status >= 500 ? SeverityNumber.ERROR : status >= 400 ? SeverityNumber.WARN : SeverityNumber.INFO;
|
|
568
|
+
const severityText = status >= 500 ? 'ERROR' : status >= 400 ? 'WARN' : 'INFO';
|
|
569
|
+
origLog.call(console, '[securenow] %s %s %d %dms', method, url, status, duration);
|
|
570
|
+
try {
|
|
571
|
+
logger.emit({
|
|
572
|
+
severityNumber: severity,
|
|
573
|
+
severityText,
|
|
574
|
+
body,
|
|
575
|
+
attributes: {
|
|
576
|
+
'http.method': method,
|
|
577
|
+
'http.url': url,
|
|
578
|
+
'http.status_code': status,
|
|
579
|
+
'http.duration_ms': duration,
|
|
580
|
+
'http.client_ip': String(ip).split(',')[0].trim(),
|
|
581
|
+
'http.user_agent': ua,
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
} catch (_) {}
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return originalEmit.apply(this, arguments);
|
|
588
|
+
};
|
|
589
|
+
console.log('[securenow] 📋 HTTP request logging: ENABLED');
|
|
590
|
+
} catch (_) {}
|
|
591
|
+
|
|
551
592
|
// Graceful shutdown for logs
|
|
552
|
-
const origShutdown = sdk.shutdown?.bind(sdk);
|
|
553
593
|
process.on('SIGTERM', async () => { try { await loggerProvider.shutdown(); } catch (_) {} });
|
|
554
594
|
process.on('SIGINT', async () => { try { await loggerProvider.shutdown(); } catch (_) {} });
|
|
555
595
|
} catch (e) {
|
|
@@ -562,11 +602,13 @@ function registerSecureNow(options = {}) {
|
|
|
562
602
|
|
|
563
603
|
isRegistered = true;
|
|
564
604
|
|
|
565
|
-
// Free trial banner
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
605
|
+
// Free trial banner (optional — may not be bundled in standalone builds)
|
|
606
|
+
try {
|
|
607
|
+
const { isFreeTrial, patchHttpForBanner } = require('./free-trial-banner');
|
|
608
|
+
if (isFreeTrial(endpointBase) && String(env('SECURENOW_HIDE_BANNER')) !== '1') {
|
|
609
|
+
patchHttpForBanner();
|
|
610
|
+
}
|
|
611
|
+
} catch (_) {}
|
|
570
612
|
|
|
571
613
|
console.log('[securenow] ✅ OpenTelemetry started for Next.js → %s', tracesUrl);
|
|
572
614
|
console.log('[securenow] 📊 Auto-capturing comprehensive request metadata:');
|
package/package.json
CHANGED