securenow 5.18.0 → 6.0.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 (85) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +40 -239
  3. package/cli.js +455 -415
  4. package/console-instrumentation.js +136 -147
  5. package/docs/ALL-FRAMEWORKS-QUICKSTART.md +455 -1339
  6. package/docs/ARCHITECTURE.md +3 -3
  7. package/docs/AUTO-BODY-CAPTURE.md +1 -1
  8. package/docs/AUTO-SETUP.md +4 -4
  9. package/docs/AUTOMATIC-IP-CAPTURE.md +5 -5
  10. package/docs/BODY-CAPTURE-QUICKSTART.md +2 -2
  11. package/docs/CHANGELOG-NEXTJS.md +1 -1
  12. package/docs/CUSTOMER-GUIDE.md +16 -16
  13. package/docs/EASIEST-SETUP.md +5 -5
  14. package/docs/ENVIRONMENT-VARIABLES.md +652 -880
  15. package/docs/EXPRESS-BODY-CAPTURE.md +12 -13
  16. package/docs/EXPRESS-SETUP-GUIDE.md +720 -719
  17. package/docs/INDEX.md +4 -22
  18. package/docs/LOGGING-GUIDE.md +708 -701
  19. package/docs/LOGGING-QUICKSTART.md +239 -234
  20. package/docs/NEXTJS-BODY-CAPTURE.md +2 -2
  21. package/docs/NEXTJS-GUIDE.md +14 -14
  22. package/docs/NEXTJS-QUICKSTART.md +1 -1
  23. package/docs/NEXTJS-WRAPPER-APPROACH.md +1 -1
  24. package/docs/QUICKSTART-BODY-CAPTURE.md +2 -2
  25. package/docs/REDACTION-EXAMPLES.md +1 -1
  26. package/docs/REQUEST-BODY-CAPTURE.md +10 -19
  27. package/docs/VERCEL-OTEL-MIGRATION.md +3 -3
  28. package/examples/README.md +6 -6
  29. package/examples/instrumentation-with-auto-capture.ts +1 -1
  30. package/examples/nextjs-env-example.txt +2 -2
  31. package/examples/nextjs-instrumentation.js +1 -1
  32. package/examples/nextjs-instrumentation.ts +1 -1
  33. package/examples/nextjs-with-logging-example.md +6 -6
  34. package/examples/nextjs-with-options.ts +1 -1
  35. package/examples/test-nextjs-setup.js +1 -1
  36. package/nextjs-auto-capture.js +207 -199
  37. package/nextjs-middleware.js +181 -186
  38. package/nextjs-webpack-config.js +53 -88
  39. package/nextjs-wrapper.js +158 -158
  40. package/nextjs.d.ts +1 -1
  41. package/nextjs.js +135 -190
  42. package/package.json +45 -67
  43. package/postinstall.js +6 -6
  44. package/register.d.ts +1 -1
  45. package/register.js +4 -39
  46. package/tracing.d.ts +1 -2
  47. package/tracing.js +22 -287
  48. package/web-vite.mjs +156 -239
  49. package/CONSUMING-APPS-GUIDE.md +0 -455
  50. package/NPM_README.md +0 -1933
  51. package/SKILL-API.md +0 -600
  52. package/SKILL-CLI.md +0 -409
  53. package/cidr.js +0 -83
  54. package/cli/apps.js +0 -585
  55. package/cli/auth.js +0 -280
  56. package/cli/client.js +0 -115
  57. package/cli/config.js +0 -173
  58. package/cli/firewall.js +0 -100
  59. package/cli/fp.js +0 -638
  60. package/cli/init.js +0 -201
  61. package/cli/monitor.js +0 -440
  62. package/cli/run.js +0 -133
  63. package/cli/security.js +0 -1064
  64. package/cli/ui.js +0 -386
  65. package/docs/API-KEYS-GUIDE.md +0 -233
  66. package/docs/AUTO-SETUP-SUMMARY.md +0 -331
  67. package/docs/BODY-CAPTURE-FIX.md +0 -261
  68. package/docs/COMPLETION-REPORT.md +0 -408
  69. package/docs/FINAL-SOLUTION.md +0 -335
  70. package/docs/FIREWALL-GUIDE.md +0 -426
  71. package/docs/IMPLEMENTATION-SUMMARY.md +0 -410
  72. package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +0 -323
  73. package/docs/NEXTJS-SETUP-COMPLETE.md +0 -795
  74. package/docs/NUXT-GUIDE.md +0 -166
  75. package/docs/SOLUTION-SUMMARY.md +0 -312
  76. package/firewall-cloud.js +0 -212
  77. package/firewall-iptables.js +0 -139
  78. package/firewall-only.js +0 -38
  79. package/firewall-tcp.js +0 -74
  80. package/firewall.js +0 -720
  81. package/free-trial-banner.js +0 -174
  82. package/nuxt-server-plugin.mjs +0 -423
  83. package/nuxt.d.ts +0 -60
  84. package/nuxt.mjs +0 -75
  85. package/resolve-ip.js +0 -77
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2025 SecureNow
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SecureNow
2
2
 
3
- OpenTelemetry instrumentation for Node.js, Next.js, and Nuxt applications - send **traces and logs** to any OTLP-compatible backend (including SecureNow).
3
+ OpenTelemetry instrumentation for Node.js and Next.js applications - send **traces and logs** to SigNoz or any OTLP-compatible backend.
4
4
 
5
5
  **Official npm package:** [securenow](http://securenow.ai/)
6
6
 
@@ -8,136 +8,73 @@ OpenTelemetry instrumentation for Node.js, Next.js, and Nuxt applications - send
8
8
 
9
9
  ## 🚀 Quick Start
10
10
 
11
- ### For Any Node.js App (Express, Fastify, NestJS, Koa, Hapi, etc.)
12
-
13
- ```bash
14
- # 1. Install
15
- npm install securenow
16
-
17
- # 2. Set env vars
18
- export SECURENOW_APPID=my-app
19
- export SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
20
-
21
- # 3. Add -r securenow/register to your start command
22
- node -r securenow/register src/app.js
23
- ```
24
-
25
- That's it. One `-r` flag is all you need — ESM and CJS apps are handled automatically (Node >=20.6 auto-registers the ESM loader hook).
11
+ ### For Next.js Applications
26
12
 
27
- > **package.json** example:
28
- > ```json
29
- > "scripts": {
30
- > "start": "node -r securenow/register src/index.js",
31
- > "dev": "node -r securenow/register --watch src/index.js"
32
- > }
33
- > ```
13
+ **The easiest way to add observability to Next.js!**
34
14
 
35
- You can also use `NODE_OPTIONS` so your existing scripts stay unchanged:
36
15
  ```bash
37
- NODE_OPTIONS="-r securenow/register" npm start
16
+ # Just install - setup is automatic!
17
+ npm install securenow
38
18
  ```
39
19
 
40
- See the [All Frameworks Quick Start](./docs/ALL-FRAMEWORKS-QUICKSTART.md) for tested setup guides.
20
+ **🎉 The installer will automatically:**
21
+ - Detect your Next.js project
22
+ - Create `instrumentation.ts` (or `.js`)
23
+ - Create `.env.local` template
41
24
 
42
- ---
25
+ **Just answer "Y" when prompted!**
43
26
 
44
- ### For Next.js Applications
27
+ Then configure your `.env.local`:
45
28
 
46
29
  ```bash
47
- # 1. Install
48
- npm install securenow
49
-
50
- # 2. Auto-scaffold instrumentation files
51
- npx securenow init --key snk_live_abc123...
52
- ```
53
-
54
- This creates `instrumentation.ts` and tells you to wrap your `next.config.js`:
55
-
56
- ```javascript
57
- // next.config.js
58
- const { withSecureNow } = require('securenow/nextjs-webpack-config');
59
-
60
- module.exports = withSecureNow({
61
- // your existing config
62
- });
30
+ SECURENOW_APPID=my-nextjs-app
31
+ SECURENOW_INSTANCE=http://your-signoz-server:4318
63
32
  ```
64
33
 
65
- `withSecureNow()` auto-detects Next.js 14 vs 15 and sets the correct externalization config. No manual `serverExternalPackages` list needed.
66
-
67
- Configure `.env.local`:
68
-
34
+ **Alternative:** Use the CLI command
69
35
  ```bash
70
- SECURENOW_APPID=my-nextjs-app
71
- SECURENOW_INSTANCE=http://your-otlp-collector:4318
72
- SECURENOW_API_KEY=snk_live_abc123...
36
+ npx securenow init
73
37
  ```
74
38
 
75
- **Done!** See [Next.js Complete Guide](./docs/NEXTJS-GUIDE.md) for details.
39
+ **Done!** 🎉 See [Next.js Complete Guide](./docs/NEXTJS-GUIDE.md) for details.
76
40
 
77
41
  ---
78
42
 
79
- ### For Nuxt 3 Applications
43
+ ### For Node.js Applications (Express, Fastify, NestJS, etc.)
44
+
45
+ #### Tracing Only
80
46
 
81
47
  ```bash
82
48
  # 1. Install
83
49
  npm install securenow
84
- ```
85
-
86
- Add the module to your `nuxt.config.ts`:
87
-
88
- ```ts
89
- export default defineNuxtConfig({
90
- modules: ['securenow/nuxt'],
91
- });
92
- ```
93
50
 
94
- Set environment variables in `.env`:
51
+ # 2. Set environment variables
52
+ export SECURENOW_APPID=my-app
53
+ export SECURENOW_INSTANCE=http://your-signoz-server:4318
95
54
 
96
- ```bash
97
- SECURENOW_APPID=my-nuxt-app
98
- SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
55
+ # 3. Run with preload
56
+ NODE_OPTIONS="-r securenow/register" node app.js
57
+ # or
58
+ NODE_OPTIONS="-r securenow/register" npm start
99
59
  ```
100
60
 
101
- **Done!** All server-side requests are now traced automatically. The firewall also activates automatically when `SECURENOW_API_KEY` is set. See the [Nuxt 3 Complete Guide](./docs/NUXT-GUIDE.md) for details.
102
-
103
- ---
104
-
105
- ### CLI -- Manage Everything from the Terminal
61
+ #### Tracing + Logging (Recommended)
106
62
 
107
63
  ```bash
108
- # Set up your project (auto-detects framework, creates instrumentation files)
109
- npx securenow init --key snk_live_abc123...
110
-
111
- # Authenticate
112
- npx securenow login
113
-
114
- # Create an app and get the key
115
- npx securenow apps create my-app
116
-
117
- # Set it as default so you don't need --app every time
118
- npx securenow config set defaultApp <key>
119
-
120
- # View traces, logs
121
- npx securenow traces
122
- npx securenow logs
64
+ # 1. Install
65
+ npm install securenow
123
66
 
124
- # IP intelligence, forensic queries, blocklist
125
- npx securenow ip 1.2.3.4
126
- npx securenow forensics "show top attacking IPs in the last hour"
127
- npx securenow blocklist add 1.2.3.4 --reason "scanner"
67
+ # 2. Set environment variables
68
+ export SECURENOW_APPID=my-app
69
+ export SECURENOW_INSTANCE=http://your-signoz-server:4318
70
+ export SECURENOW_LOGGING_ENABLED=1
128
71
 
129
- # Firewall automatic IP blocking
130
- npx securenow firewall status
131
- npx securenow firewall test-ip 1.2.3.4
72
+ # 3. Run with preload (adds logging)
73
+ NODE_OPTIONS="-r securenow/register -r securenow/console-instrumentation" node app.js
132
74
 
133
- # Full dashboard overview
134
- npx securenow status
75
+ # Now all console.log/info/warn/error automatically go to SigNoz!
135
76
  ```
136
77
 
137
- Run `npx securenow help` for all commands. See the [CLI Reference](#cli-reference) below.
138
-
139
- ---
140
-
141
78
  ---
142
79
 
143
80
  ## 📦 Installation
@@ -160,9 +97,9 @@ pnpm add securenow
160
97
  # Required: Your application identifier
161
98
  SECURENOW_APPID=my-app-name
162
99
 
163
- # Optional: Your OTLP collector endpoint
100
+ # Optional: Your SigNoz/OTLP collector endpoint
164
101
  # Default: https://freetrial.securenow.ai:4318
165
- SECURENOW_INSTANCE=http://your-otlp-collector:4318
102
+ SECURENOW_INSTANCE=http://your-signoz-server:4318
166
103
 
167
104
  # Optional: Enable Logging
168
105
  SECURENOW_LOGGING_ENABLED=1 # Enable automatic log collection
@@ -177,9 +114,6 @@ OTEL_EXPORTER_OTLP_HEADERS="x-api-key=..." # Authentication headers
177
114
  SECURENOW_CAPTURE_BODY=1 # Capture request bodies in traces
178
115
  SECURENOW_MAX_BODY_SIZE=10240 # Max body size in bytes
179
116
  SECURENOW_SENSITIVE_FIELDS="field1,field2" # Additional fields to redact
180
-
181
- # Optional: Multipart body capture (file upload metadata)
182
- SECURENOW_CAPTURE_MULTIPART=1 # Capture multipart field names, values & file metadata
183
117
  ```
184
118
 
185
119
  ### Legacy Environment Variables (still supported)
@@ -197,7 +131,6 @@ SecureNow automatically instruments:
197
131
 
198
132
  ### Web Frameworks
199
133
  - ✅ Next.js (App Router & Pages Router)
200
- - ✅ Nuxt 3 (Nitro server)
201
134
  - ✅ Express.js
202
135
  - ✅ Fastify
203
136
  - ✅ NestJS
@@ -228,14 +161,10 @@ SecureNow automatically instruments:
228
161
 
229
162
  ### Quick Starts
230
163
  - **[Next.js Quick Start](./docs/NEXTJS-QUICKSTART.md)** - Get started in 30 seconds
231
- - **[Nuxt 3 Guide](./docs/NUXT-GUIDE.md)** - One-line Nuxt module setup
232
164
  - **[Logging Quick Start](./docs/LOGGING-QUICKSTART.md)** - Add logging in 2 minutes
233
165
 
234
166
  ### Complete Guides
235
- - **[Firewall Guide](./docs/FIREWALL-GUIDE.md)** - Automatic multi-layer IP blocking
236
- - **[API Keys Guide](./docs/API-KEYS-GUIDE.md)** - API key management and scopes
237
167
  - **[Next.js Complete Guide](./docs/NEXTJS-GUIDE.md)** - Full Next.js integration guide
238
- - **[Nuxt 3 Complete Guide](./docs/NUXT-GUIDE.md)** - Full Nuxt 3 integration guide
239
168
  - **[Logging Complete Guide](./docs/LOGGING-GUIDE.md)** - Full logging setup for all frameworks
240
169
  - **[📚 Complete Documentation](./docs/INDEX.md)** - All guides and references
241
170
 
@@ -244,135 +173,7 @@ SecureNow automatically instruments:
244
173
 
245
174
  ---
246
175
 
247
- ## CLI Reference
248
-
249
- After installing the package, the `securenow` CLI is available via `npx securenow` or globally after `npm install -g securenow`.
250
-
251
- ### Run (convenience wrapper)
252
-
253
- | Command | Description |
254
- |---------|-------------|
255
- | `securenow run <script>` | Run a Node.js app with `-r securenow/register` injected |
256
- | `securenow run --watch <script>` | Same, with Node.js watch mode |
257
-
258
- Most users won't need this — just add `-r securenow/register` to your existing start script.
259
-
260
- ### Authentication
261
-
262
- | Command | Description |
263
- |---------|-------------|
264
- | `securenow login` | Log in via browser (opens OAuth flow) |
265
- | `securenow login --token <TOKEN>` | Log in with a token (for CI/headless) |
266
- | `securenow login --local` | Log in and save credentials to the current project only |
267
- | `securenow logout` | Clear stored credentials |
268
- | `securenow logout --local` | Clear project-local credentials only |
269
- | `securenow whoami` | Show current session info (including auth source) |
270
-
271
- ### Applications
272
-
273
- | Command | Description |
274
- |---------|-------------|
275
- | `securenow apps` | List all applications |
276
- | `securenow apps create <name>` | Create app and get the app key |
277
- | `securenow apps info <id>` | Show application details |
278
- | `securenow apps delete <id>` | Delete an application |
279
- | `securenow apps default <key>` | Set default app for all commands |
280
-
281
- ### Observability
282
-
283
- | Command | Description |
284
- |---------|-------------|
285
- | `securenow traces --app <key>` | List recent traces |
286
- | `securenow traces show <traceId>` | Show trace spans |
287
- | `securenow traces analyze <traceId>` | AI security analysis of a trace |
288
- | `securenow logs --app <key>` | View logs (with `--minutes`, `--level`) |
289
- | `securenow logs trace <traceId>` | View logs for a specific trace |
290
- | `securenow analytics` | Response code analytics overview |
291
- | `securenow status` | Full dashboard summary |
292
-
293
- ### Detect & Respond
294
-
295
- | Command | Description |
296
- |---------|-------------|
297
- | `securenow notifications` | List notifications |
298
- | `securenow notifications unread` | Show unread count |
299
- | `securenow notifications read <id>` | Mark notification as read |
300
- | `securenow notifications read-all` | Mark all as read |
301
- | `securenow alerts rules` | List alert rules (status, applications, schedule) |
302
- | `securenow alerts rules show <id>` | Show one rule (includes all-apps vs explicit apps) |
303
- | `securenow alerts rules update <id> --applications-all` | Set rule to all current & future apps |
304
- | `securenow alerts rules update <id> --apps k1,k2` | Scope rule to specific app keys |
305
- | `securenow alerts channels` | List alert channels |
306
- | `securenow alerts history` | View alert history |
307
-
308
- ### Investigate
309
-
310
- | Command | Description |
311
- |---------|-------------|
312
- | `securenow ip <address>` | IP intelligence lookup (geo, abuse score, verdict) |
313
- | `securenow ip traces <address>` | Show traces originating from an IP |
314
- | `securenow forensics "<query>"` | Natural language forensic query (NL to SQL) |
315
- | `securenow forensics library` | View saved query library |
316
- | `securenow api-map` | View discovered API endpoints |
317
- | `securenow api-map stats` | API map statistics |
318
-
319
- ### Firewall
320
-
321
- | Command | Description |
322
- |---------|-------------|
323
- | `securenow firewall status` | Show firewall status, active layers, and API key info |
324
- | `securenow firewall test-ip <ip>` | Check if an IP would be blocked by the current blocklist |
325
-
326
- ### Remediation
327
-
328
- | Command | Description |
329
- |---------|-------------|
330
- | `securenow blocklist` | List blocked IPs |
331
- | `securenow blocklist add <ip>` | Block an IP (`--reason <reason>`) |
332
- | `securenow blocklist remove <id>` | Remove from blocklist |
333
- | `securenow blocklist stats` | Blocklist statistics |
334
- | `securenow trusted` | List trusted IPs |
335
- | `securenow trusted add <ip>` | Add trusted IP (`--label <label>`) |
336
- | `securenow trusted remove <id>` | Remove trusted IP |
337
-
338
- ### Settings
339
-
340
- | Command | Description |
341
- |---------|-------------|
342
- | `securenow instances` | List ClickHouse instances |
343
- | `securenow instances test <id>` | Test instance connection |
344
- | `securenow config get` | Show all config values |
345
- | `securenow config set <key> <value>` | Set a config value |
346
- | `securenow config path` | Show config file locations |
347
- | `securenow init [--key <KEY>]` | Auto-scaffold instrumentation for your framework |
348
- | `securenow version` | Show CLI version |
349
-
350
- ### Global Flags
351
-
352
- | Flag | Description |
353
- |------|-------------|
354
- | `--json` | Output as JSON (works on every command) |
355
- | `--help` | Show help for any command |
356
- | `--app <key>` | Specify app key (or set default with `config set defaultApp`) |
357
- | `--local` | Save/clear credentials per-project (login/logout only) |
358
-
359
- ### Configuration
360
-
361
- Credentials and settings are stored in `~/.securenow/` (global) or `.securenow/` (per-project):
362
-
363
- | File | Purpose |
364
- |------|---------|
365
- | `~/.securenow/config.json` | API URL, default app, preferences |
366
- | `~/.securenow/credentials.json` | Auth token — global (restricted permissions) |
367
- | `.securenow/credentials.json` | Auth token — project-local (use `login --local`) |
368
-
369
- **Credential resolution order:** `SECURENOW_TOKEN` env var → project `.securenow/credentials.json` → global `~/.securenow/credentials.json`.
370
-
371
- Override the API URL with `securenow config set apiUrl <url>` or the `SECURENOW_API_URL` environment variable.
372
-
373
- ---
374
-
375
- ## Support
176
+ ## 🆘 Support
376
177
 
377
178
  - **Website:** [securenow.ai](http://securenow.ai/)
378
179
  - **Issues:** Report bugs and request features
@@ -380,6 +181,6 @@ Override the API URL with `securenow config set apiUrl <url>` or the `SECURENOW_
380
181
 
381
182
  ---
382
183
 
383
- ## License
184
+ ## 📄 License
384
185
 
385
186
  ISC