securenow 7.6.6 → 7.6.8

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 (68) hide show
  1. package/NPM_README.md +13 -13
  2. package/README.md +21 -37
  3. package/app-config.js +5 -3
  4. package/cli/config.js +4 -3
  5. package/cli/diagnostics.js +54 -15
  6. package/cli/run.js +40 -11
  7. package/firewall-only.js +1 -1
  8. package/firewall.js +88 -57
  9. package/mcp/catalog.js +1 -1
  10. package/nextjs-webpack-config.js +3 -15
  11. package/nextjs.js +21 -23
  12. package/nuxt-server-plugin.mjs +20 -10
  13. package/package.json +33 -34
  14. package/register.js +1 -1
  15. package/tracing.js +17 -7
  16. package/web-vite.mjs +23 -13
  17. package/CONSUMING-APPS-GUIDE.md +0 -463
  18. package/docs/ALL-FRAMEWORKS-QUICKSTART.md +0 -1388
  19. package/docs/API-KEYS-GUIDE.md +0 -278
  20. package/docs/ARCHITECTURE.md +0 -408
  21. package/docs/AUTO-BODY-CAPTURE.md +0 -412
  22. package/docs/AUTO-SETUP-SUMMARY.md +0 -331
  23. package/docs/AUTO-SETUP.md +0 -419
  24. package/docs/AUTOMATIC-IP-CAPTURE.md +0 -359
  25. package/docs/BODY-CAPTURE-FIX.md +0 -261
  26. package/docs/BODY-CAPTURE-QUICKSTART.md +0 -147
  27. package/docs/CHANGELOG-NEXTJS.md +0 -235
  28. package/docs/COMPLETION-REPORT.md +0 -408
  29. package/docs/CUSTOMER-GUIDE.md +0 -364
  30. package/docs/EASIEST-SETUP.md +0 -342
  31. package/docs/ENVIRONMENT-VARIABLES.md +0 -166
  32. package/docs/ENVIRONMENTS.md +0 -60
  33. package/docs/EXPRESS-BODY-CAPTURE.md +0 -1028
  34. package/docs/EXPRESS-SETUP-GUIDE.md +0 -722
  35. package/docs/FINAL-SOLUTION.md +0 -335
  36. package/docs/FIREWALL-GUIDE.md +0 -440
  37. package/docs/IMPLEMENTATION-SUMMARY.md +0 -410
  38. package/docs/INDEX.md +0 -222
  39. package/docs/LOGGING-GUIDE.md +0 -704
  40. package/docs/LOGGING-QUICKSTART.md +0 -221
  41. package/docs/MCP-GUIDE.md +0 -58
  42. package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +0 -323
  43. package/docs/NEXTJS-BODY-CAPTURE.md +0 -368
  44. package/docs/NEXTJS-GUIDE.md +0 -392
  45. package/docs/NEXTJS-QUICKSTART.md +0 -83
  46. package/docs/NEXTJS-SETUP-COMPLETE.md +0 -795
  47. package/docs/NEXTJS-WEBPACK-WARNINGS.md +0 -267
  48. package/docs/NEXTJS-WRAPPER-APPROACH.md +0 -414
  49. package/docs/NUXT-GUIDE.md +0 -173
  50. package/docs/QUICKSTART-BODY-CAPTURE.md +0 -293
  51. package/docs/REDACTION-EXAMPLES.md +0 -484
  52. package/docs/REQUEST-BODY-CAPTURE.md +0 -587
  53. package/docs/SOLUTION-SUMMARY.md +0 -312
  54. package/docs/VERCEL-OTEL-MIGRATION.md +0 -255
  55. package/examples/README.md +0 -265
  56. package/examples/express-with-logging.js +0 -137
  57. package/examples/instrumentation-with-auto-capture.ts +0 -41
  58. package/examples/next.config.js +0 -37
  59. package/examples/nextjs-api-route-with-body-capture.ts +0 -54
  60. package/examples/nextjs-env-example.txt +0 -32
  61. package/examples/nextjs-instrumentation.js +0 -36
  62. package/examples/nextjs-instrumentation.ts +0 -36
  63. package/examples/nextjs-middleware.js +0 -37
  64. package/examples/nextjs-middleware.ts +0 -37
  65. package/examples/nextjs-with-logging-example.md +0 -301
  66. package/examples/nextjs-with-options.ts +0 -36
  67. package/examples/test-nextjs-setup.js +0 -70
  68. package/postinstall.js +0 -296
@@ -1,173 +0,0 @@
1
- # SecureNow — Nuxt 3 Setup Guide
2
-
3
- ## Quick Start (1 minute)
4
-
5
- ### 1. Install + login
6
-
7
- ```bash
8
- npm install securenow
9
- npx securenow login # pick/create your app in the browser
10
- ```
11
-
12
- `login` writes `.securenow/credentials.json` locally. No `.env` needed for local dev.
13
-
14
- ### 2. Add the module to `nuxt.config.ts`
15
-
16
- ```ts
17
- export default defineNuxtConfig({
18
- modules: ['securenow/nuxt'],
19
- });
20
- ```
21
-
22
- ### 3. Start your app
23
-
24
- ```bash
25
- nuxt dev
26
- ```
27
-
28
- You should see in the console:
29
-
30
- ```
31
- [securenow] Nuxt module loaded — server plugin registered
32
- [securenow] 🚀 Nuxt OTel SDK started → https://freetrial.securenow.ai:4318/v1/traces
33
- ```
34
-
35
- That's it — all server-side requests are now traced, logs forwarded, and bodies captured. The app you picked during `login` is where they land.
36
-
37
- ### 4. (Optional) Override for CI / Docker / prod
38
-
39
- `.securenow/credentials.json` is for local dev. For environments where you can't run `npx securenow login`, set env vars:
40
-
41
- ```env
42
- SECURENOW_APPID=<app-key-uuid>
43
- SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
44
- ```
45
-
46
- Env vars always take precedence.
47
-
48
- ---
49
-
50
- ## Configuration
51
-
52
- ### Module options in `nuxt.config.ts`
53
-
54
- ```ts
55
- export default defineNuxtConfig({
56
- modules: ['securenow/nuxt'],
57
- securenow: {
58
- serviceName: 'my-nuxt-app', // overrides SECURENOW_APPID
59
- endpoint: 'http://host:4318', // overrides SECURENOW_INSTANCE
60
- noUuid: true, // single service.name (no UUID suffix)
61
- captureBody: true, // capture POST/PUT/PATCH bodies
62
- logging: true, // forward console.* as OTLP logs
63
- },
64
- });
65
- ```
66
-
67
- ### Environment variables
68
-
69
- All standard SecureNow env vars are supported:
70
-
71
- | Variable | Description | Default |
72
- |----------|-------------|---------|
73
- | `SECURENOW_APPID` | Service name | `nuxt-app-<uuid>` |
74
- | `SECURENOW_INSTANCE` | OTLP base URL | `https://freetrial.securenow.ai:4318` |
75
- | `SECURENOW_NO_UUID` | Don't append UUID to service name | `false` |
76
- | `SECURENOW_LOGGING_ENABLED` | Forward console logs as OTLP | `false` |
77
- | `SECURENOW_CAPTURE_BODY` | Capture request bodies | `false` |
78
- | `SECURENOW_MAX_BODY_SIZE` | Max body size to capture (bytes) | `10240` |
79
- | `SECURENOW_SENSITIVE_FIELDS` | Extra fields to redact (CSV) | _(built-in list)_ |
80
- | `OTEL_EXPORTER_OTLP_ENDPOINT` | Alternative OTLP base URL | — |
81
- | `OTEL_EXPORTER_OTLP_HEADERS` | OTLP headers (k=v,k2=v2) | — |
82
-
83
- ---
84
-
85
- ## What gets traced
86
-
87
- ### Automatic (out of the box)
88
-
89
- - All Nitro server handler requests (API routes, SSR pages, middleware)
90
- - HTTP method, path, status code, duration
91
- - Client IP address (with proxy-aware resolution)
92
- - User-Agent, Referer, Origin, Host
93
- - Security header presence (auth, cookies, CSRF)
94
- - Request IDs and correlation headers
95
-
96
- ### With `captureBody: true`
97
-
98
- - POST/PUT/PATCH request bodies (JSON, form-urlencoded, GraphQL)
99
- - Sensitive fields auto-redacted (passwords, tokens, etc.)
100
- - Bodies larger than `SECURENOW_MAX_BODY_SIZE` are skipped
101
-
102
- ### With `logging: true`
103
-
104
- - All `console.log/info/warn/error/debug` calls forwarded as OTLP log records
105
- - Logs correlated with active trace spans
106
-
107
- ---
108
-
109
- ## Comparison with Next.js integration
110
-
111
- | Feature | Nuxt (`securenow/nuxt`) | Next.js (`securenow/nextjs`) |
112
- |---------|-------------------------|------------------------------|
113
- | Setup | Add to `modules` array | Create `instrumentation.ts` |
114
- | Config | `nuxt.config.ts` | `.env.local` + `next.config.js` |
115
- | Server tracing | Nitro hooks | HTTP instrumentation |
116
- | Edge runtime | Not supported | Skipped gracefully |
117
- | Vercel support | Via env vars | `@vercel/otel` integration |
118
- | Body capture | HTTP instrumentation | Middleware + `Request.clone()` |
119
- | Logging | Console patching | Console patching |
120
-
121
- ---
122
-
123
- ## Deployment
124
-
125
- ### Node.js server (PM2, Docker, etc.)
126
-
127
- Works out of the box with `nuxt build && node .output/server/index.mjs`.
128
-
129
- ### Vercel / Netlify / Cloudflare
130
-
131
- Set env vars in the platform dashboard:
132
-
133
- ```
134
- SECURENOW_APPID=my-nuxt-app
135
- SECURENOW_INSTANCE=https://your-otlp-backend:4318
136
- ```
137
-
138
- > Note: On edge runtimes (Cloudflare Workers, Vercel Edge), some Node.js-specific
139
- > instrumentations may not be available. Server-handler tracing via Nitro hooks
140
- > still works.
141
-
142
- ---
143
-
144
- ## Troubleshooting
145
-
146
- ### No traces appearing
147
-
148
- 1. Check that `SECURENOW_APPID` and `SECURENOW_INSTANCE` are set
149
- 2. Look for `[securenow] 🚀 Nuxt OTel SDK started` in the console
150
- 3. Verify the OTLP endpoint is reachable from your server
151
-
152
- ### Module not loading
153
-
154
- Make sure you're using Nuxt 3 (`nuxt: ">=3.0.0"`) and the module is listed
155
- in the `modules` array (not `buildModules`).
156
-
157
- ### OpenTelemetry packages bundled by Nitro
158
-
159
- The module automatically externalizes OTel packages. If you see bundling errors,
160
- manually add to `nuxt.config.ts`:
161
-
162
- ```ts
163
- export default defineNuxtConfig({
164
- nitro: {
165
- externals: {
166
- external: ['securenow', '@opentelemetry/api', '@opentelemetry/sdk-node'],
167
- },
168
- },
169
- });
170
- ```
171
- # Current setup note
172
-
173
- Use `.securenow/credentials.json` for local and production. Run `npx securenow login`, `npx securenow init`, and for production generate `npx securenow credentials runtime --env production`; mount/copy that file as `.securenow/credentials.json`. Env-var examples in this older guide are legacy fallback snippets.
@@ -1,293 +0,0 @@
1
- # 🚀 Quick Start: Body Capture in Next.js
2
-
3
- ## ✅ Recommended: Wrapper Approach (No Conflicts!)
4
-
5
- This approach **never interferes** with your middleware or routing.
6
-
7
- ### Step 1: Enable in .env.local
8
-
9
- ```bash
10
- SECURENOW_APPID=my-app
11
- SECURENOW_INSTANCE=http://otel-collector:4318
12
- SECURENOW_CAPTURE_BODY=1
13
- ```
14
-
15
- ### Step 2: Wrap Your API Routes
16
-
17
- ```typescript
18
- // app/api/login/route.ts
19
- import { withSecureNow } from 'securenow/nextjs-wrapper';
20
-
21
- export const POST = withSecureNow(async (request: Request) => {
22
- const body = await request.json();
23
-
24
- // Your logic here...
25
-
26
- return Response.json({ success: true });
27
- });
28
- ```
29
-
30
- ### Step 3: Keep Your Middleware Clean
31
-
32
- ```typescript
33
- // middleware.ts - NO securenow imports!
34
- import { getToken } from 'next-auth/jwt';
35
-
36
- export async function middleware(request) {
37
- // Just your auth logic - securenow doesn't interfere!
38
- const token = await getToken({ req: request });
39
- if (!token) {
40
- return NextResponse.redirect('/login');
41
- }
42
- return NextResponse.next();
43
- }
44
- ```
45
-
46
- **That's it!** 🎉
47
-
48
- ---
49
-
50
- ## What Gets Captured
51
-
52
- ### ✅ Automatically Captured & Redacted
53
-
54
- ```typescript
55
- // Request:
56
- {
57
- "username": "john",
58
- "password": "secret123",
59
- "email": "john@example.com"
60
- }
61
-
62
- // In your traces (sensitive fields redacted):
63
- {
64
- "username": "john",
65
- "password": "[REDACTED]",
66
- "email": "john@example.com"
67
- }
68
- ```
69
-
70
- ### 🔒 Auto-Redacted Fields (20+)
71
-
72
- ```
73
- password, passwd, pwd, secret, token, api_key, access_token,
74
- auth, credentials, card, cardnumber, cvv, cvc, ssn, pin, etc.
75
- ```
76
-
77
- ### 📝 Supported Content Types
78
-
79
- - ✅ JSON (`application/json`)
80
- - ✅ GraphQL (`application/graphql`)
81
- - ✅ Form data (`application/x-www-form-urlencoded`)
82
- - ℹ️ Multipart (marked as `[MULTIPART - NOT CAPTURED]`)
83
-
84
- ---
85
-
86
- ## ✨ Benefits
87
-
88
- ### Zero Conflicts
89
- - ✅ Works perfectly with NextAuth
90
- - ✅ Works with any middleware
91
- - ✅ Never blocks requests
92
- - ✅ Runs inside your handler (not before)
93
-
94
- ### Safe & Secure
95
- - ✅ Automatic sensitive data redaction
96
- - ✅ Size limits (configurable)
97
- - ✅ Non-blocking (background capture)
98
- - ✅ Fails silently (never breaks your app)
99
-
100
- ### Flexible
101
- - ✅ Per-route control (wrap only what you need)
102
- - ✅ Easy to add/remove
103
- - ✅ Works with App Router & Pages Router
104
-
105
- ---
106
-
107
- ## 📊 Example: Full API Route
108
-
109
- ```typescript
110
- import { withSecureNow } from 'securenow/nextjs-wrapper';
111
- import { db } from '@/lib/db';
112
-
113
- export const POST = withSecureNow(async (request: Request) => {
114
- try {
115
- // Parse body (securenow captures this automatically)
116
- const { email, password } = await request.json();
117
-
118
- // Your business logic
119
- const user = await db.user.create({
120
- data: { email, passwordHash: hash(password) }
121
- });
122
-
123
- return Response.json({
124
- success: true,
125
- userId: user.id
126
- });
127
- } catch (error) {
128
- return Response.json({
129
- success: false,
130
- error: error.message
131
- }, { status: 400 });
132
- }
133
- });
134
-
135
- // Optional: Other methods without capture
136
- export async function GET() {
137
- const users = await db.user.findMany();
138
- return Response.json({ users });
139
- }
140
- ```
141
-
142
- **Trace will show:**
143
- - ✅ HTTP method, path, status
144
- - ✅ Request body: `{"email":"john@example.com","password":"[REDACTED]"}`
145
- - ✅ Response time
146
- - ✅ IP address, user agent
147
- - ✅ All without blocking or interfering!
148
-
149
- ---
150
-
151
- ## ⚙️ Configuration
152
-
153
- ### Environment Variables
154
-
155
- ```bash
156
- # Required
157
- SECURENOW_APPID=my-nextjs-app
158
- SECURENOW_INSTANCE=http://your-otlp-backend:4318
159
-
160
- # Body capture
161
- SECURENOW_CAPTURE_BODY=1 # Enable body capture
162
- SECURENOW_MAX_BODY_SIZE=10240 # Max size in bytes (10KB default)
163
- SECURENOW_SENSITIVE_FIELDS=email,phone # Additional fields to redact
164
-
165
- # Optional
166
- OTEL_LOG_LEVEL=info # Logging level
167
- ```
168
-
169
- ### Custom Sensitive Fields
170
-
171
- Add your own fields to redact:
172
-
173
- ```bash
174
- SECURENOW_SENSITIVE_FIELDS=credit_card_number,ssn,bank_account
175
- ```
176
-
177
- Now these will also show as `[REDACTED]` in traces!
178
-
179
- ---
180
-
181
- ## 🎓 More Examples
182
-
183
- ### Selective Wrapping
184
-
185
- ```typescript
186
- // Capture body for login
187
- export const POST = withSecureNow(async (request: Request) => {
188
- const body = await request.json();
189
- return Response.json({ success: true });
190
- });
191
-
192
- // No capture for public endpoint
193
- export async function GET() {
194
- return Response.json({ status: 'ok' });
195
- }
196
- ```
197
-
198
- ### With Dynamic Routes
199
-
200
- ```typescript
201
- // app/api/users/[id]/route.ts
202
- import { withSecureNow } from 'securenow/nextjs-wrapper';
203
-
204
- export const PUT = withSecureNow(async (
205
- request: Request,
206
- { params }: { params: { id: string } }
207
- ) => {
208
- const body = await request.json();
209
- const userId = params.id;
210
-
211
- await updateUser(userId, body);
212
-
213
- return Response.json({ updated: true });
214
- });
215
- ```
216
-
217
- ### Pages Router
218
-
219
- ```typescript
220
- // pages/api/login.ts
221
- import { withSecureNow } from 'securenow/nextjs-wrapper';
222
-
223
- async function handler(req, res) {
224
- if (req.method === 'POST') {
225
- const { email, password } = req.body;
226
- // Your logic...
227
- res.json({ success: true });
228
- } else {
229
- res.status(405).end();
230
- }
231
- }
232
-
233
- export default withSecureNow(handler);
234
- ```
235
-
236
- ---
237
-
238
- ## 🐛 Troubleshooting
239
-
240
- ### Q: I'm getting "Response body disturbed or locked" errors
241
-
242
- **A:** Don't use the middleware approach! Use the wrapper approach shown above. The wrapper runs inside your handler and never locks the request.
243
-
244
- ### Q: Bodies aren't being captured
245
-
246
- **Check:**
247
- 1. Is `SECURENOW_CAPTURE_BODY=1` set in `.env.local`?
248
- 2. Did you wrap the route with `withSecureNow()`?
249
- 3. Is the request POST/PUT/PATCH?
250
- 4. Is content-type `application/json` or similar?
251
-
252
- ### Q: Can I use this with NextAuth?
253
-
254
- **A:** Yes! That's exactly what it's designed for. Your middleware stays clean:
255
-
256
- ```typescript
257
- // middleware.ts - Just NextAuth, no securenow!
258
- export async function middleware(request) {
259
- const token = await getToken({ req: request });
260
- // ...
261
- }
262
-
263
- // API routes - Add securenow wrapper
264
- export const POST = withSecureNow(handler);
265
- ```
266
-
267
- ---
268
-
269
- ## ✅ Summary
270
-
271
- **Setup (2 steps):**
272
- 1. Set `SECURENOW_CAPTURE_BODY=1` in `.env.local`
273
- 2. Wrap routes: `withSecureNow(handler)`
274
-
275
- **Result:**
276
- - ✅ Request bodies captured
277
- - ✅ Sensitive fields redacted
278
- - ✅ Zero middleware conflicts
279
- - ✅ Non-blocking & safe
280
- - ✅ Works with NextAuth
281
-
282
- **That's it!** 🎊
283
-
284
- 📚 **More info:**
285
- - `NEXTJS-WRAPPER-APPROACH.md` - Full guide
286
- - `NEXTJS-BODY-CAPTURE-COMPARISON.md` - Comparison with middleware approach
287
-
288
-
289
-
290
-
291
- # Current setup note
292
-
293
- Use `.securenow/credentials.json` for local and production. Body capture defaults live under `config.capture.*`; run `npx securenow init` to create secure defaults. Env-var examples in this older guide are legacy fallback snippets.