securenow 5.17.1 → 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 -243
  3. package/cli.js +455 -425
  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 -1958
  51. package/SKILL-API.md +0 -600
  52. package/SKILL-CLI.md +0 -419
  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 -545
  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,137 +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, issues
121
- npx securenow traces
122
- npx securenow logs
123
- npx securenow issues
64
+ # 1. Install
65
+ npm install securenow
124
66
 
125
- # IP intelligence, forensic queries, blocklist
126
- npx securenow ip 1.2.3.4
127
- npx securenow forensics "show top attacking IPs in the last hour"
128
- 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
129
71
 
130
- # Firewall automatic IP blocking
131
- npx securenow firewall status
132
- 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
133
74
 
134
- # Full dashboard overview
135
- npx securenow status
75
+ # Now all console.log/info/warn/error automatically go to SigNoz!
136
76
  ```
137
77
 
138
- Run `npx securenow help` for all commands. See the [CLI Reference](#cli-reference) below.
139
-
140
- ---
141
-
142
78
  ---
143
79
 
144
80
  ## 📦 Installation
@@ -161,9 +97,9 @@ pnpm add securenow
161
97
  # Required: Your application identifier
162
98
  SECURENOW_APPID=my-app-name
163
99
 
164
- # Optional: Your OTLP collector endpoint
100
+ # Optional: Your SigNoz/OTLP collector endpoint
165
101
  # Default: https://freetrial.securenow.ai:4318
166
- SECURENOW_INSTANCE=http://your-otlp-collector:4318
102
+ SECURENOW_INSTANCE=http://your-signoz-server:4318
167
103
 
168
104
  # Optional: Enable Logging
169
105
  SECURENOW_LOGGING_ENABLED=1 # Enable automatic log collection
@@ -178,9 +114,6 @@ OTEL_EXPORTER_OTLP_HEADERS="x-api-key=..." # Authentication headers
178
114
  SECURENOW_CAPTURE_BODY=1 # Capture request bodies in traces
179
115
  SECURENOW_MAX_BODY_SIZE=10240 # Max body size in bytes
180
116
  SECURENOW_SENSITIVE_FIELDS="field1,field2" # Additional fields to redact
181
-
182
- # Optional: Multipart body capture (file upload metadata)
183
- SECURENOW_CAPTURE_MULTIPART=1 # Capture multipart field names, values & file metadata
184
117
  ```
185
118
 
186
119
  ### Legacy Environment Variables (still supported)
@@ -198,7 +131,6 @@ SecureNow automatically instruments:
198
131
 
199
132
  ### Web Frameworks
200
133
  - ✅ Next.js (App Router & Pages Router)
201
- - ✅ Nuxt 3 (Nitro server)
202
134
  - ✅ Express.js
203
135
  - ✅ Fastify
204
136
  - ✅ NestJS
@@ -229,14 +161,10 @@ SecureNow automatically instruments:
229
161
 
230
162
  ### Quick Starts
231
163
  - **[Next.js Quick Start](./docs/NEXTJS-QUICKSTART.md)** - Get started in 30 seconds
232
- - **[Nuxt 3 Guide](./docs/NUXT-GUIDE.md)** - One-line Nuxt module setup
233
164
  - **[Logging Quick Start](./docs/LOGGING-QUICKSTART.md)** - Add logging in 2 minutes
234
165
 
235
166
  ### Complete Guides
236
- - **[Firewall Guide](./docs/FIREWALL-GUIDE.md)** - Automatic multi-layer IP blocking
237
- - **[API Keys Guide](./docs/API-KEYS-GUIDE.md)** - API key management and scopes
238
167
  - **[Next.js Complete Guide](./docs/NEXTJS-GUIDE.md)** - Full Next.js integration guide
239
- - **[Nuxt 3 Complete Guide](./docs/NUXT-GUIDE.md)** - Full Nuxt 3 integration guide
240
168
  - **[Logging Complete Guide](./docs/LOGGING-GUIDE.md)** - Full logging setup for all frameworks
241
169
  - **[📚 Complete Documentation](./docs/INDEX.md)** - All guides and references
242
170
 
@@ -245,138 +173,7 @@ SecureNow automatically instruments:
245
173
 
246
174
  ---
247
175
 
248
- ## CLI Reference
249
-
250
- After installing the package, the `securenow` CLI is available via `npx securenow` or globally after `npm install -g securenow`.
251
-
252
- ### Run (convenience wrapper)
253
-
254
- | Command | Description |
255
- |---------|-------------|
256
- | `securenow run <script>` | Run a Node.js app with `-r securenow/register` injected |
257
- | `securenow run --watch <script>` | Same, with Node.js watch mode |
258
-
259
- Most users won't need this — just add `-r securenow/register` to your existing start script.
260
-
261
- ### Authentication
262
-
263
- | Command | Description |
264
- |---------|-------------|
265
- | `securenow login` | Log in via browser (opens OAuth flow) |
266
- | `securenow login --token <TOKEN>` | Log in with a token (for CI/headless) |
267
- | `securenow login --local` | Log in and save credentials to the current project only |
268
- | `securenow logout` | Clear stored credentials |
269
- | `securenow logout --local` | Clear project-local credentials only |
270
- | `securenow whoami` | Show current session info (including auth source) |
271
-
272
- ### Applications
273
-
274
- | Command | Description |
275
- |---------|-------------|
276
- | `securenow apps` | List all applications |
277
- | `securenow apps create <name>` | Create app and get the app key |
278
- | `securenow apps info <id>` | Show application details |
279
- | `securenow apps delete <id>` | Delete an application |
280
- | `securenow apps default <key>` | Set default app for all commands |
281
-
282
- ### Observability
283
-
284
- | Command | Description |
285
- |---------|-------------|
286
- | `securenow traces --app <key>` | List recent traces |
287
- | `securenow traces show <traceId>` | Show trace spans |
288
- | `securenow traces analyze <traceId>` | AI security analysis of a trace |
289
- | `securenow logs --app <key>` | View logs (with `--minutes`, `--level`) |
290
- | `securenow logs trace <traceId>` | View logs for a specific trace |
291
- | `securenow analytics` | Response code analytics overview |
292
- | `securenow status` | Full dashboard summary |
293
-
294
- ### Detect & Respond
295
-
296
- | Command | Description |
297
- |---------|-------------|
298
- | `securenow issues` | List security issues |
299
- | `securenow issues show <id>` | Show issue details and AI analysis |
300
- | `securenow issues resolve <id>` | Mark an issue as resolved |
301
- | `securenow notifications` | List notifications |
302
- | `securenow notifications unread` | Show unread count |
303
- | `securenow notifications read <id>` | Mark notification as read |
304
- | `securenow notifications read-all` | Mark all as read |
305
- | `securenow alerts rules` | List alert rules (status, applications, schedule) |
306
- | `securenow alerts rules show <id>` | Show one rule (includes all-apps vs explicit apps) |
307
- | `securenow alerts rules update <id> --applications-all` | Set rule to all current & future apps |
308
- | `securenow alerts rules update <id> --apps k1,k2` | Scope rule to specific app keys |
309
- | `securenow alerts channels` | List alert channels |
310
- | `securenow alerts history` | View alert history |
311
-
312
- ### Investigate
313
-
314
- | Command | Description |
315
- |---------|-------------|
316
- | `securenow ip <address>` | IP intelligence lookup (geo, abuse score, verdict) |
317
- | `securenow ip traces <address>` | Show traces originating from an IP |
318
- | `securenow forensics "<query>"` | Natural language forensic query (NL to SQL) |
319
- | `securenow forensics library` | View saved query library |
320
- | `securenow api-map` | View discovered API endpoints |
321
- | `securenow api-map stats` | API map statistics |
322
-
323
- ### Firewall
324
-
325
- | Command | Description |
326
- |---------|-------------|
327
- | `securenow firewall status` | Show firewall status, active layers, and API key info |
328
- | `securenow firewall test-ip <ip>` | Check if an IP would be blocked by the current blocklist |
329
-
330
- ### Remediation
331
-
332
- | Command | Description |
333
- |---------|-------------|
334
- | `securenow blocklist` | List blocked IPs |
335
- | `securenow blocklist add <ip>` | Block an IP (`--reason <reason>`) |
336
- | `securenow blocklist remove <id>` | Remove from blocklist |
337
- | `securenow blocklist stats` | Blocklist statistics |
338
- | `securenow trusted` | List trusted IPs |
339
- | `securenow trusted add <ip>` | Add trusted IP (`--label <label>`) |
340
- | `securenow trusted remove <id>` | Remove trusted IP |
341
-
342
- ### Settings
343
-
344
- | Command | Description |
345
- |---------|-------------|
346
- | `securenow instances` | List ClickHouse instances |
347
- | `securenow instances test <id>` | Test instance connection |
348
- | `securenow config get` | Show all config values |
349
- | `securenow config set <key> <value>` | Set a config value |
350
- | `securenow config path` | Show config file locations |
351
- | `securenow init [--key <KEY>]` | Auto-scaffold instrumentation for your framework |
352
- | `securenow version` | Show CLI version |
353
-
354
- ### Global Flags
355
-
356
- | Flag | Description |
357
- |------|-------------|
358
- | `--json` | Output as JSON (works on every command) |
359
- | `--help` | Show help for any command |
360
- | `--app <key>` | Specify app key (or set default with `config set defaultApp`) |
361
- | `--local` | Save/clear credentials per-project (login/logout only) |
362
-
363
- ### Configuration
364
-
365
- Credentials and settings are stored in `~/.securenow/` (global) or `.securenow/` (per-project):
366
-
367
- | File | Purpose |
368
- |------|---------|
369
- | `~/.securenow/config.json` | API URL, default app, preferences |
370
- | `~/.securenow/credentials.json` | Auth token — global (restricted permissions) |
371
- | `.securenow/credentials.json` | Auth token — project-local (use `login --local`) |
372
-
373
- **Credential resolution order:** `SECURENOW_TOKEN` env var → project `.securenow/credentials.json` → global `~/.securenow/credentials.json`.
374
-
375
- Override the API URL with `securenow config set apiUrl <url>` or the `SECURENOW_API_URL` environment variable.
376
-
377
- ---
378
-
379
- ## Support
176
+ ## 🆘 Support
380
177
 
381
178
  - **Website:** [securenow.ai](http://securenow.ai/)
382
179
  - **Issues:** Report bugs and request features
@@ -384,6 +181,6 @@ Override the API URL with `securenow config set apiUrl <url>` or the `SECURENOW_
384
181
 
385
182
  ---
386
183
 
387
- ## License
184
+ ## 📄 License
388
185
 
389
186
  ISC