securenow 6.0.2 → 6.1.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.
Files changed (87) hide show
  1. package/CONSUMING-APPS-GUIDE.md +455 -0
  2. package/NPM_README.md +2029 -0
  3. package/README.md +297 -40
  4. package/SKILL-API.md +634 -0
  5. package/SKILL-CLI.md +454 -0
  6. package/cidr.js +83 -0
  7. package/cli/apps.js +585 -0
  8. package/cli/auth.js +280 -0
  9. package/cli/client.js +115 -0
  10. package/cli/config.js +173 -0
  11. package/cli/diagnostics.js +387 -0
  12. package/cli/firewall.js +100 -0
  13. package/cli/fp.js +638 -0
  14. package/cli/init.js +201 -0
  15. package/cli/monitor.js +440 -0
  16. package/cli/run.js +148 -0
  17. package/cli/security.js +980 -0
  18. package/cli/ui.js +386 -0
  19. package/cli/utils.js +127 -0
  20. package/cli.js +466 -455
  21. package/console-instrumentation.js +147 -136
  22. package/docs/ALL-FRAMEWORKS-QUICKSTART.md +1377 -455
  23. package/docs/API-KEYS-GUIDE.md +233 -0
  24. package/docs/ARCHITECTURE.md +3 -3
  25. package/docs/AUTO-BODY-CAPTURE.md +1 -1
  26. package/docs/AUTO-SETUP-SUMMARY.md +331 -0
  27. package/docs/AUTO-SETUP.md +4 -4
  28. package/docs/AUTOMATIC-IP-CAPTURE.md +5 -5
  29. package/docs/BODY-CAPTURE-FIX.md +261 -0
  30. package/docs/BODY-CAPTURE-QUICKSTART.md +2 -2
  31. package/docs/CHANGELOG-NEXTJS.md +1 -35
  32. package/docs/COMPLETION-REPORT.md +408 -0
  33. package/docs/CUSTOMER-GUIDE.md +16 -16
  34. package/docs/EASIEST-SETUP.md +5 -5
  35. package/docs/ENVIRONMENT-VARIABLES.md +880 -652
  36. package/docs/EXPRESS-BODY-CAPTURE.md +13 -12
  37. package/docs/EXPRESS-SETUP-GUIDE.md +719 -720
  38. package/docs/FINAL-SOLUTION.md +335 -0
  39. package/docs/FIREWALL-GUIDE.md +426 -0
  40. package/docs/IMPLEMENTATION-SUMMARY.md +410 -0
  41. package/docs/INDEX.md +22 -4
  42. package/docs/LOGGING-GUIDE.md +701 -708
  43. package/docs/LOGGING-QUICKSTART.md +234 -255
  44. package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +323 -0
  45. package/docs/NEXTJS-BODY-CAPTURE.md +2 -2
  46. package/docs/NEXTJS-GUIDE.md +14 -14
  47. package/docs/NEXTJS-QUICKSTART.md +1 -1
  48. package/docs/NEXTJS-SETUP-COMPLETE.md +795 -0
  49. package/docs/NEXTJS-WRAPPER-APPROACH.md +1 -1
  50. package/docs/NUXT-GUIDE.md +166 -0
  51. package/docs/QUICKSTART-BODY-CAPTURE.md +2 -2
  52. package/docs/REDACTION-EXAMPLES.md +1 -1
  53. package/docs/REQUEST-BODY-CAPTURE.md +19 -10
  54. package/docs/SOLUTION-SUMMARY.md +312 -0
  55. package/docs/VERCEL-OTEL-MIGRATION.md +3 -3
  56. package/examples/README.md +6 -6
  57. package/examples/instrumentation-with-auto-capture.ts +1 -1
  58. package/examples/nextjs-env-example.txt +2 -2
  59. package/examples/nextjs-instrumentation.js +1 -1
  60. package/examples/nextjs-instrumentation.ts +1 -1
  61. package/examples/nextjs-with-logging-example.md +6 -6
  62. package/examples/nextjs-with-options.ts +1 -1
  63. package/examples/test-nextjs-setup.js +1 -1
  64. package/firewall-cloud.js +212 -0
  65. package/firewall-iptables.js +139 -0
  66. package/firewall-only.js +38 -0
  67. package/firewall-tcp.js +74 -0
  68. package/firewall.js +720 -0
  69. package/free-trial-banner.js +174 -0
  70. package/nextjs-auto-capture.js +199 -207
  71. package/nextjs-middleware.js +186 -181
  72. package/nextjs-webpack-config.js +88 -53
  73. package/nextjs-wrapper.js +158 -158
  74. package/nextjs.d.ts +1 -1
  75. package/nextjs.js +639 -647
  76. package/nuxt-server-plugin.mjs +423 -0
  77. package/nuxt.d.ts +60 -0
  78. package/nuxt.mjs +75 -0
  79. package/package.json +186 -164
  80. package/postinstall.js +6 -6
  81. package/register.d.ts +1 -1
  82. package/register.js +39 -4
  83. package/resolve-ip.js +77 -0
  84. package/tracing.d.ts +2 -1
  85. package/tracing.js +295 -34
  86. package/web-vite.mjs +239 -156
  87. package/LICENSE +0 -15
@@ -1,255 +1,234 @@
1
- # SecureNow Logging - Quick Start
2
-
3
- Get logging set up in your Node.js app in under 2 minutes!
4
-
5
- ---
6
-
7
- ## 1. Install
8
-
9
- ```bash
10
- npm install securenow
11
- ```
12
-
13
- ---
14
-
15
- ## 2. Configure Environment
16
-
17
- Create `.env` file or export variables:
18
-
19
- ```bash
20
- SECURENOW_LOGGING_ENABLED=1
21
- SECURENOW_APPID=my-app
22
- SECURENOW_INSTANCE=http://your-signoz-server:4318
23
-
24
- # For SigNoz Cloud:
25
- # SECURENOW_INSTANCE=https://ingest.<region>.signoz.cloud:443
26
- # OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-key>"
27
- ```
28
-
29
- ---
30
-
31
- ## 3. Add to Your App
32
-
33
- **Option A: Automatic Console Logging (Easiest)**
34
-
35
- Add these two lines at the top of your main file:
36
-
37
- ```javascript
38
- // app.js, index.js, server.js, or main.ts
39
- require('securenow/register');
40
- require('securenow/console-instrumentation');
41
-
42
- // That's it! Now use console normally
43
- console.log('App started');
44
- console.error('An error occurred', { userId: 123 });
45
- ```
46
-
47
- **Option B: Use NODE_OPTIONS (No code changes)**
48
-
49
- ```bash
50
- NODE_OPTIONS="-r securenow/register -r securenow/console-instrumentation" node app.js
51
- ```
52
-
53
- ---
54
-
55
- ## 4. Run Your App
56
-
57
- ```bash
58
- node app.js
59
- # or
60
- npm start
61
- ```
62
-
63
- You should see:
64
-
65
- ```
66
- [securenow] OTel SDK started → http://your-signoz-server:4318/v1/traces
67
- [securenow] 📋 Logging: ENABLED → http://your-signoz-server:4318/v1/logs
68
- [securenow] Console instrumentation installed
69
- ```
70
-
71
- ---
72
-
73
- ## 5. View Logs in SigNoz
74
-
75
- 1. Open your SigNoz dashboard
76
- 2. Go to **Logs** section
77
- 3. Filter by `service.name = my-app`
78
- 4. See all your logs with automatic trace correlation!
79
-
80
- ---
81
-
82
- ## Framework-Specific Examples
83
-
84
- ### Express.js
85
-
86
- ```javascript
87
- // app.js
88
- require('securenow/register');
89
- require('securenow/console-instrumentation');
90
-
91
- const express = require('express');
92
- const app = express();
93
-
94
- app.get('/', (req, res) => {
95
- console.log('Request received');
96
- res.send('Hello World');
97
- });
98
-
99
- app.listen(3000);
100
- ```
101
-
102
- ### Next.js
103
-
104
- Next.js apps must use `securenow/nextjs` (not `securenow/register`, which
105
- boots a full NodeSDK and conflicts with Next.js / `@vercel/otel`). Since
106
- **6.0.1**, `registerSecureNow()` sets up the OTLP logs pipeline and auto-
107
- patches `console.*` whenever `SECURENOW_LOGGING_ENABLED=1` is set — on both
108
- Vercel and self-hosted (EC2, PM2, Docker) environments.
109
-
110
- ```typescript
111
- // instrumentation.ts (in project root)
112
- export async function register() {
113
- if (process.env.NEXT_RUNTIME === 'nodejs') {
114
- // Must be set BEFORE loading securenow/nextjs
115
- process.env.SECURENOW_LOGGING_ENABLED = '1';
116
-
117
- const { registerSecureNow } = await import('securenow/nextjs');
118
- registerSecureNow({ captureBody: true });
119
- }
120
- }
121
- ```
122
-
123
- ```bash
124
- # .env.local
125
- SECURENOW_LOGGING_ENABLED=1
126
- SECURENOW_APPID=my-nextjs-app
127
- SECURENOW_INSTANCE=http://localhost:4318
128
- ```
129
-
130
- Enable the instrumentation hook in `next.config.js`:
131
-
132
- ```javascript
133
- module.exports = {
134
- experimental: { instrumentationHook: true },
135
- };
136
- ```
137
-
138
- ### Fastify
139
-
140
- ```javascript
141
- // server.js
142
- require('securenow/register');
143
- require('securenow/console-instrumentation');
144
-
145
- const fastify = require('fastify')();
146
-
147
- fastify.get('/', async () => {
148
- console.log('Route called');
149
- return { hello: 'world' };
150
- });
151
-
152
- fastify.listen({ port: 3000 });
153
- ```
154
-
155
- ### NestJS
156
-
157
- ```typescript
158
- // main.ts
159
- require('securenow/register');
160
- require('securenow/console-instrumentation');
161
-
162
- import { NestFactory } from '@nestjs/core';
163
- import { AppModule } from './app.module';
164
-
165
- async function bootstrap() {
166
- const app = await NestFactory.create(AppModule);
167
- console.log('App starting');
168
- await app.listen(3000);
169
- }
170
-
171
- bootstrap();
172
- ```
173
-
174
- ---
175
-
176
- ## Troubleshooting
177
-
178
- **Logs not appearing?**
179
-
180
- 1. Check `SECURENOW_LOGGING_ENABLED=1` is set
181
- 2. Verify SigNoz endpoint is correct
182
- 3. Enable debug: `OTEL_LOG_LEVEL=debug`
183
-
184
- **Console instrumentation not working?**
185
-
186
- Make sure require order is correct:
187
-
188
- ```javascript
189
- // Correct
190
- require('securenow/register'); // First
191
- require('securenow/console-instrumentation'); // Second
192
-
193
- // ❌ Wrong
194
- require('express');
195
- require('securenow/register'); // Too late!
196
- ```
197
-
198
- ---
199
-
200
- ## What Gets Logged?
201
-
202
- All standard console methods:
203
-
204
- - `console.log()` → INFO
205
- - `console.info()` → INFO
206
- - `console.warn()` → WARN
207
- - `console.error()` → ERROR
208
- - `console.debug()` → DEBUG
209
-
210
- **Structured logging example:**
211
-
212
- ```javascript
213
- console.log('User logged in', {
214
- userId: 123,
215
- email: 'user@example.com',
216
- ip: '192.168.1.1'
217
- });
218
- ```
219
-
220
- This creates a log with attributes you can filter/search in SigNoz!
221
-
222
- ---
223
-
224
- ## Advanced Usage
225
-
226
- **Direct Logger API:**
227
-
228
- ```javascript
229
- const { getLogger } = require('securenow/tracing');
230
- const logger = getLogger('my-module', '1.0.0');
231
-
232
- logger.emit({
233
- severityNumber: 9,
234
- severityText: 'INFO',
235
- body: 'Custom log message',
236
- attributes: {
237
- customField: 'value',
238
- },
239
- });
240
- ```
241
-
242
- ---
243
-
244
- ## Next Steps
245
-
246
- - [Complete Logging Guide](./LOGGING-GUIDE.md) - All features and options
247
- - [View Logs in SigNoz](https://signoz.io/docs/logs-management/overview/)
248
- - [Set Up Log Alerts](https://signoz.io/docs/alerts-management/log-based-alerts/)
249
- - [Combine with Tracing](../README.md) - Full observability
250
-
251
- ---
252
-
253
- **That's it!** 🎉 Your app is now sending logs to SigNoz.
254
-
255
- Need help? Check the [full documentation](./LOGGING-GUIDE.md) or open an issue.
1
+ # SecureNow Logging - Quick Start
2
+
3
+ Get logging set up in your Node.js app in under 2 minutes!
4
+
5
+ **Since v5.6.0:** When `SECURENOW_LOGGING_ENABLED=1` is set, all `console.log` / `warn` / `error` / `info` / `debug` calls are automatically forwarded as OTLP log records. You only need `require('securenow/register')`—a separate `console-instrumentation` preload is no longer required.
6
+
7
+ ---
8
+
9
+ ## 1. Install
10
+
11
+ ```bash
12
+ npm install securenow
13
+ ```
14
+
15
+ ---
16
+
17
+ ## 2. Configure Environment
18
+
19
+ Create `.env` file or export variables:
20
+
21
+ ```bash
22
+ SECURENOW_LOGGING_ENABLED=1
23
+ SECURENOW_APPID=my-app
24
+ SECURENOW_INSTANCE=http://your-otlp-backend:4318
25
+
26
+ # For SecureNow / hosted OTLP (example):
27
+ # SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
28
+ # OTEL_EXPORTER_OTLP_HEADERS="x-api-key=<your-key>"
29
+ ```
30
+
31
+ ---
32
+
33
+ ## 3. Add to Your App
34
+
35
+ **Option A: Automatic Console Logging (Easiest)**
36
+
37
+ Add this line at the top of your main file:
38
+
39
+ ```javascript
40
+ // app.js, index.js, server.js, or main.ts
41
+ require('securenow/register');
42
+
43
+ // That's it! Now use console normally
44
+ console.log('App started');
45
+ console.error('An error occurred', { userId: 123 });
46
+ ```
47
+
48
+ **Option B: Use NODE_OPTIONS (No code changes)**
49
+
50
+ ```bash
51
+ NODE_OPTIONS="-r securenow/register" node app.js
52
+ ```
53
+
54
+ ---
55
+
56
+ ## 4. Run Your App
57
+
58
+ ```bash
59
+ node app.js
60
+ # or
61
+ npm start
62
+ ```
63
+
64
+ You should see:
65
+
66
+ ```
67
+ [securenow] OTel SDK started → http://your-otlp-backend:4318/v1/traces
68
+ [securenow] 📋 Logging: ENABLED → http://your-otlp-backend:4318/v1/logs
69
+ ```
70
+
71
+ ---
72
+
73
+ ## 5. View Logs in SecureNow
74
+
75
+ 1. Open your SecureNow dashboard
76
+ 2. Go to **Logs** section
77
+ 3. Filter by `service.name = my-app`
78
+ 4. See all your logs with automatic trace correlation!
79
+
80
+ ---
81
+
82
+ ## Framework-Specific Examples
83
+
84
+ ### Express.js
85
+
86
+ ```javascript
87
+ // app.js
88
+ require('securenow/register');
89
+
90
+ const express = require('express');
91
+ const app = express();
92
+
93
+ app.get('/', (req, res) => {
94
+ console.log('Request received');
95
+ res.send('Hello World');
96
+ });
97
+
98
+ app.listen(3000);
99
+ ```
100
+
101
+ ### Next.js
102
+
103
+ ```typescript
104
+ // instrumentation.ts (in project root)
105
+ export async function register() {
106
+ if (process.env.NEXT_RUNTIME === 'nodejs') {
107
+ process.env.SECURENOW_LOGGING_ENABLED = '1';
108
+ await import('securenow/register');
109
+ }
110
+ }
111
+ ```
112
+
113
+ ```bash
114
+ # .env.local
115
+ SECURENOW_LOGGING_ENABLED=1
116
+ SECURENOW_APPID=my-nextjs-app
117
+ SECURENOW_INSTANCE=http://localhost:4318
118
+ ```
119
+
120
+ ### Fastify
121
+
122
+ ```javascript
123
+ // server.js
124
+ require('securenow/register');
125
+
126
+ const fastify = require('fastify')();
127
+
128
+ fastify.get('/', async () => {
129
+ console.log('Route called');
130
+ return { hello: 'world' };
131
+ });
132
+
133
+ fastify.listen({ port: 3000 });
134
+ ```
135
+
136
+ ### NestJS
137
+
138
+ ```typescript
139
+ // main.ts
140
+ require('securenow/register');
141
+
142
+ import { NestFactory } from '@nestjs/core';
143
+ import { AppModule } from './app.module';
144
+
145
+ async function bootstrap() {
146
+ const app = await NestFactory.create(AppModule);
147
+ console.log('App starting');
148
+ await app.listen(3000);
149
+ }
150
+
151
+ bootstrap();
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Troubleshooting
157
+
158
+ **Logs not appearing?**
159
+
160
+ 1. Check `SECURENOW_LOGGING_ENABLED=1` is set
161
+ 2. Verify your OTLP / SecureNow endpoint is correct
162
+ 3. Enable debug: `OTEL_LOG_LEVEL=debug`
163
+
164
+ **Console logs not forwarding?**
165
+
166
+ Load `securenow/register` before other app code so logging hooks run first:
167
+
168
+ ```javascript
169
+ // ✅ Correct
170
+ require('securenow/register'); // First
171
+
172
+ // ❌ Wrong
173
+ require('express');
174
+ require('securenow/register'); // Too late!
175
+ ```
176
+
177
+ ---
178
+
179
+ ## What Gets Logged?
180
+
181
+ All standard console methods:
182
+
183
+ - `console.log()` → INFO
184
+ - `console.info()` INFO
185
+ - `console.warn()` → WARN
186
+ - `console.error()` ERROR
187
+ - `console.debug()` → DEBUG
188
+
189
+ **Structured logging example:**
190
+
191
+ ```javascript
192
+ console.log('User logged in', {
193
+ userId: 123,
194
+ email: 'user@example.com',
195
+ ip: '192.168.1.1'
196
+ });
197
+ ```
198
+
199
+ This creates a log with attributes you can filter/search in SecureNow!
200
+
201
+ ---
202
+
203
+ ## Advanced Usage
204
+
205
+ **Direct Logger API:**
206
+
207
+ ```javascript
208
+ const { getLogger } = require('securenow/tracing');
209
+ const logger = getLogger('my-module', '1.0.0');
210
+
211
+ logger.emit({
212
+ severityNumber: 9,
213
+ severityText: 'INFO',
214
+ body: 'Custom log message',
215
+ attributes: {
216
+ customField: 'value',
217
+ },
218
+ });
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Next Steps
224
+
225
+ - [Complete Logging Guide](./LOGGING-GUIDE.md) - All features and options
226
+ - [SecureNow](https://securenow.ai/)
227
+ - [Documentation](./INDEX.md)
228
+ - [Combine with Tracing](../README.md) - Full observability
229
+
230
+ ---
231
+
232
+ **That's it!** 🎉 Your app is now sending logs to SecureNow.
233
+
234
+ Need help? Check the [full documentation](./LOGGING-GUIDE.md) or open an issue.