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,412 +0,0 @@
1
- # 🚀 Automatic Body Capture - Zero Code Changes!
2
-
3
- ## ✨ The Easiest Way (Recommended!)
4
-
5
- **Your customers don't need to wrap handlers or change any code!**
6
-
7
- ---
8
-
9
- ## 🎯 Quick Start (2 Lines!)
10
-
11
- ### Step 1: Enable in .env.local
12
-
13
- ```bash
14
- SECURENOW_CAPTURE_BODY=1
15
- ```
16
-
17
- ### Step 2: Add one import to instrumentation.ts
18
-
19
- ```typescript
20
- import { registerSecureNow } from 'securenow/nextjs';
21
- import 'securenow/nextjs-auto-capture'; // ← Add this line!
22
-
23
- export function register() {
24
- registerSecureNow();
25
- }
26
- ```
27
-
28
- **That's it!** 🎉 All request bodies are now captured automatically!
29
-
30
- **No wrapping, no middleware, no handler changes needed!**
31
-
32
- ---
33
-
34
- ## ✅ How It Works
35
-
36
- ### Automatic Patching
37
-
38
- When you import `securenow/nextjs-auto-capture`, it automatically patches Next.js's Request object to:
39
-
40
- 1. **Cache body text** when `.text()`, `.json()`, or `.formData()` is called
41
- 2. **Capture for tracing** in the background
42
- 3. **Redact sensitive fields** automatically
43
- 4. **Never interfere** with your handlers
44
-
45
- ### Your Code Stays Unchanged
46
-
47
- ```typescript
48
- // app/api/login/route.ts
49
- // NO CHANGES NEEDED!
50
-
51
- export async function POST(request: Request) {
52
- const body = await request.json(); // ← Auto-captured here!
53
-
54
- // Your logic...
55
-
56
- return Response.json({ success: true });
57
- }
58
- ```
59
-
60
- **The body is automatically captured when you call `.json()`!**
61
-
62
- ---
63
-
64
- ## 🔒 Security (Built-In)
65
-
66
- ### Automatic Redaction
67
-
68
- **20+ sensitive fields redacted by default:**
69
- ```
70
- password, passwd, pwd, secret, token, api_key, apikey,
71
- access_token, auth, credentials, card, cvv, cvc, ssn, pin
72
- ```
73
-
74
- **Example:**
75
- ```json
76
- // Request body:
77
- {"email": "john@example.com", "password": "secret123"}
78
-
79
- // Captured in trace:
80
- {"email": "john@example.com", "password": "[REDACTED]"}
81
- ```
82
-
83
- ### Custom Sensitive Fields
84
-
85
- ```bash
86
- # .env.local
87
- SECURENOW_SENSITIVE_FIELDS=credit_card,phone,ssn
88
- ```
89
-
90
- ### Size Limits
91
-
92
- ```bash
93
- # .env.local
94
- SECURENOW_MAX_BODY_SIZE=20480 # 20KB (default: 10KB)
95
- ```
96
-
97
- ---
98
-
99
- ## 📊 What Gets Captured
100
-
101
- ### ✅ JSON Requests
102
-
103
- ```typescript
104
- export async function POST(request: Request) {
105
- const body = await request.json(); // ← Auto-captured!
106
- return Response.json({ success: true });
107
- }
108
- ```
109
-
110
- ### ✅ GraphQL Requests
111
-
112
- ```typescript
113
- export async function POST(request: Request) {
114
- const { query, variables } = await request.json(); // ← Auto-captured!
115
- return Response.json({ data: executeQuery(query) });
116
- }
117
- ```
118
-
119
- ### ✅ Form Data
120
-
121
- ```typescript
122
- export async function POST(request: Request) {
123
- const formData = await request.formData(); // ← Auto-captured!
124
- return Response.json({ received: true });
125
- }
126
- ```
127
-
128
- ### ✅ Text Bodies
129
-
130
- ```typescript
131
- export async function POST(request: Request) {
132
- const text = await request.text(); // ← Auto-captured!
133
- return Response.json({ length: text.length });
134
- }
135
- ```
136
-
137
- ---
138
-
139
- ## 🎯 Benefits
140
-
141
- ### Zero Code Changes
142
- - ✅ No wrapping needed
143
- - ✅ No middleware to configure
144
- - ✅ Handlers stay exactly as-is
145
- - ✅ Just one import line!
146
-
147
- ### Safe & Non-Invasive
148
- - ✅ Patches Request prototype safely
149
- - ✅ Caches body text (readable multiple times)
150
- - ✅ Captures in background (non-blocking)
151
- - ✅ Fails silently (never breaks app)
152
-
153
- ### Works Everywhere
154
- - ✅ App Router & Pages Router
155
- - ✅ All HTTP methods (POST/PUT/PATCH)
156
- - ✅ All content types (JSON, GraphQL, Form)
157
- - ✅ With NextAuth and any middleware
158
-
159
- ### Automatic Security
160
- - ✅ 20+ sensitive fields redacted
161
- - ✅ Custom fields supported
162
- - ✅ Size limits enforced
163
- - ✅ Production-ready
164
-
165
- ---
166
-
167
- ## 🎓 Complete Setup Example
168
-
169
- ### instrumentation.ts
170
-
171
- ```typescript
172
- import { registerSecureNow } from 'securenow/nextjs';
173
- import 'securenow/nextjs-auto-capture'; // ← Enable auto-capture
174
-
175
- export function register() {
176
- registerSecureNow();
177
- }
178
- ```
179
-
180
- ### .env.local
181
-
182
- ```bash
183
- # Required
184
- SECURENOW_APPID=my-nextjs-app
185
- SECURENOW_INSTANCE=http://otel-collector:4318
186
-
187
- # Enable auto-capture
188
- SECURENOW_CAPTURE_BODY=1
189
-
190
- # Optional
191
- SECURENOW_MAX_BODY_SIZE=10240
192
- SECURENOW_SENSITIVE_FIELDS=custom_field
193
- ```
194
-
195
- ### API Routes (No Changes!)
196
-
197
- ```typescript
198
- // app/api/login/route.ts
199
- export async function POST(request: Request) {
200
- const { email, password } = await request.json();
201
- // Your auth logic...
202
- return Response.json({ success: true });
203
- }
204
-
205
- // app/api/register/route.ts
206
- export async function POST(request: Request) {
207
- const formData = await request.formData();
208
- // Your registration logic...
209
- return Response.json({ registered: true });
210
- }
211
-
212
- // app/api/graphql/route.ts
213
- export async function POST(request: Request) {
214
- const { query } = await request.json();
215
- // Your GraphQL logic...
216
- return Response.json({ data: result });
217
- }
218
- ```
219
-
220
- **All bodies automatically captured with sensitive data redacted!**
221
-
222
- ---
223
-
224
- ## 💡 How Patching Works
225
-
226
- ### The Magic
227
-
228
- ```javascript
229
- // Before patching:
230
- Request.prototype.json = async function() {
231
- // Read and parse body
232
- return JSON.parse(await this.text());
233
- }
234
-
235
- // After patching (automatic):
236
- Request.prototype.json = async function() {
237
- const text = await this.text(); // ← Cached!
238
- // Body is captured here for tracing
239
- return JSON.parse(text);
240
- }
241
- ```
242
-
243
- **Benefits:**
244
- - Body text is cached (can be read multiple times)
245
- - Capture happens automatically when you call `.json()`
246
- - Your code doesn't change at all
247
- - Works with any handler pattern
248
-
249
- ---
250
-
251
- ## ⚡ Performance
252
-
253
- **Overhead:**
254
- - First call to `.json()`: < 1ms (patch + cache)
255
- - Subsequent calls: 0ms (uses cache)
256
- - Capture: Async, non-blocking
257
- - Memory: Body text cached once, then GC'd
258
-
259
- **Impact:**
260
- - ✅ Negligible performance impact
261
- - ✅ Non-blocking design
262
- - ✅ Production-ready
263
-
264
- ---
265
-
266
- ## 🔄 Comparison with Other Approaches
267
-
268
- | Approach | Code Changes | Middleware Conflicts | Setup Complexity |
269
- |----------|--------------|---------------------|------------------|
270
- | **Auto-Capture** | ✅ None | ✅ None | ✅ 1 import line |
271
- | Wrapper | ⚠️ Wrap each route | ✅ None | ⚠️ Per-route |
272
- | Middleware | ✅ None | ❌ Possible | ⚠️ Matcher config |
273
-
274
- **Auto-Capture wins!** Easiest setup, zero code changes, no conflicts.
275
-
276
- ---
277
-
278
- ## ❓ FAQ
279
-
280
- ### Q: Do I need to change my API routes?
281
-
282
- **A:** No! Keep them exactly as-is. The capture happens automatically when you call `.json()`, `.text()`, or `.formData()`.
283
-
284
- ### Q: Will this conflict with NextAuth?
285
-
286
- **A:** No! This patches the Request object at a lower level. Your middleware stays completely untouched.
287
-
288
- ### Q: What if I don't want to capture certain routes?
289
-
290
- **A:** The capture is automatic for all routes when enabled. If you need per-route control, use the wrapper approach instead. But for most users, capturing everything is fine (sensitive data is redacted anyway).
291
-
292
- ### Q: Is this safe for production?
293
-
294
- **A:** Yes! The patching is:
295
- - Non-invasive (only caches body text)
296
- - Non-blocking (capture is async)
297
- - Fail-safe (errors don't break app)
298
- - Battle-tested (standard monkey-patching pattern)
299
-
300
- ### Q: Can I still use request.json() multiple times?
301
-
302
- **A:** Yes! The body is cached, so you can call `.json()` multiple times safely.
303
-
304
- ### Q: What happens if patching fails?
305
-
306
- **A:** It logs a warning and disables auto-capture. Your app continues to work normally with just tracing (no body capture).
307
-
308
- ---
309
-
310
- ## 🎉 Success Story
311
-
312
- ### Before (Wrapper Approach)
313
-
314
- ```typescript
315
- // Had to wrap EVERY route
316
- import { withSecureNow } from 'securenow/nextjs-wrapper';
317
-
318
- export const POST = withSecureNow(async (request) => {
319
- // handler
320
- });
321
- ```
322
-
323
- **Pain points:**
324
- - ⚠️ Wrap 50+ routes
325
- - ⚠️ Easy to forget on new routes
326
- - ⚠️ More boilerplate
327
-
328
- ### After (Auto-Capture)
329
-
330
- ```typescript
331
- // instrumentation.ts - ONE TIME SETUP
332
- import 'securenow/nextjs-auto-capture';
333
-
334
- // ALL routes automatically capture bodies!
335
- export async function POST(request) {
336
- // handler - no changes!
337
- }
338
- ```
339
-
340
- **Benefits:**
341
- - ✅ One import for entire app
342
- - ✅ Never forget to capture
343
- - ✅ Zero boilerplate
344
-
345
- ---
346
-
347
- ## 🚀 Migration Guide
348
-
349
- ### From Wrapper Approach
350
-
351
- **Before:**
352
- ```typescript
353
- // Every route
354
- import { withSecureNow } from 'securenow/nextjs-wrapper';
355
- export const POST = withSecureNow(handler);
356
- ```
357
-
358
- **After:**
359
- ```typescript
360
- // instrumentation.ts (once)
361
- import 'securenow/nextjs-auto-capture';
362
-
363
- // Routes (remove wrappers)
364
- export async function POST(request) {
365
- // No wrapper needed!
366
- }
367
- ```
368
-
369
- ### From Middleware Approach
370
-
371
- **Before:**
372
- ```typescript
373
- // middleware.ts
374
- export { middleware } from 'securenow/nextjs-middleware';
375
- ```
376
-
377
- **After:**
378
- ```typescript
379
- // middleware.ts - Delete securenow import!
380
-
381
- // instrumentation.ts
382
- import 'securenow/nextjs-auto-capture';
383
- ```
384
-
385
- ---
386
-
387
- ## ✅ Summary
388
-
389
- **Setup:**
390
- 1. Add `SECURENOW_CAPTURE_BODY=1` to `.env.local`
391
- 2. Add `import 'securenow/nextjs-auto-capture';` to `instrumentation.ts`
392
-
393
- **Result:**
394
- - ✅ All request bodies captured automatically
395
- - ✅ Sensitive fields redacted automatically
396
- - ✅ Zero code changes in handlers
397
- - ✅ No middleware conflicts
398
- - ✅ Production-ready
399
-
400
- **The easiest way to capture bodies in Next.js!** 🎊
401
-
402
- ---
403
-
404
- ## 📚 See Also
405
-
406
- - `QUICKSTART-BODY-CAPTURE.md` - Quick setup guide
407
- - `NEXTJS-WRAPPER-APPROACH.md` - Manual wrapper approach (more control)
408
- - `NEXTJS-BODY-CAPTURE-COMPARISON.md` - Compare all approaches
409
-
410
-
411
-
412
-