securenow 7.6.7 → 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 (67) 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/mcp/catalog.js +1 -1
  9. package/nextjs-webpack-config.js +3 -15
  10. package/nextjs.js +21 -23
  11. package/nuxt-server-plugin.mjs +20 -10
  12. package/package.json +33 -34
  13. package/register.js +1 -1
  14. package/tracing.js +17 -7
  15. package/web-vite.mjs +23 -13
  16. package/CONSUMING-APPS-GUIDE.md +0 -463
  17. package/docs/ALL-FRAMEWORKS-QUICKSTART.md +0 -1388
  18. package/docs/API-KEYS-GUIDE.md +0 -278
  19. package/docs/ARCHITECTURE.md +0 -408
  20. package/docs/AUTO-BODY-CAPTURE.md +0 -412
  21. package/docs/AUTO-SETUP-SUMMARY.md +0 -331
  22. package/docs/AUTO-SETUP.md +0 -419
  23. package/docs/AUTOMATIC-IP-CAPTURE.md +0 -359
  24. package/docs/BODY-CAPTURE-FIX.md +0 -261
  25. package/docs/BODY-CAPTURE-QUICKSTART.md +0 -147
  26. package/docs/CHANGELOG-NEXTJS.md +0 -235
  27. package/docs/COMPLETION-REPORT.md +0 -408
  28. package/docs/CUSTOMER-GUIDE.md +0 -364
  29. package/docs/EASIEST-SETUP.md +0 -342
  30. package/docs/ENVIRONMENT-VARIABLES.md +0 -166
  31. package/docs/ENVIRONMENTS.md +0 -60
  32. package/docs/EXPRESS-BODY-CAPTURE.md +0 -1028
  33. package/docs/EXPRESS-SETUP-GUIDE.md +0 -722
  34. package/docs/FINAL-SOLUTION.md +0 -335
  35. package/docs/FIREWALL-GUIDE.md +0 -440
  36. package/docs/IMPLEMENTATION-SUMMARY.md +0 -410
  37. package/docs/INDEX.md +0 -222
  38. package/docs/LOGGING-GUIDE.md +0 -704
  39. package/docs/LOGGING-QUICKSTART.md +0 -221
  40. package/docs/MCP-GUIDE.md +0 -58
  41. package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +0 -323
  42. package/docs/NEXTJS-BODY-CAPTURE.md +0 -368
  43. package/docs/NEXTJS-GUIDE.md +0 -392
  44. package/docs/NEXTJS-QUICKSTART.md +0 -83
  45. package/docs/NEXTJS-SETUP-COMPLETE.md +0 -795
  46. package/docs/NEXTJS-WEBPACK-WARNINGS.md +0 -267
  47. package/docs/NEXTJS-WRAPPER-APPROACH.md +0 -414
  48. package/docs/NUXT-GUIDE.md +0 -173
  49. package/docs/QUICKSTART-BODY-CAPTURE.md +0 -293
  50. package/docs/REDACTION-EXAMPLES.md +0 -484
  51. package/docs/REQUEST-BODY-CAPTURE.md +0 -587
  52. package/docs/SOLUTION-SUMMARY.md +0 -312
  53. package/docs/VERCEL-OTEL-MIGRATION.md +0 -255
  54. package/examples/README.md +0 -265
  55. package/examples/express-with-logging.js +0 -137
  56. package/examples/instrumentation-with-auto-capture.ts +0 -41
  57. package/examples/next.config.js +0 -37
  58. package/examples/nextjs-api-route-with-body-capture.ts +0 -54
  59. package/examples/nextjs-env-example.txt +0 -32
  60. package/examples/nextjs-instrumentation.js +0 -36
  61. package/examples/nextjs-instrumentation.ts +0 -36
  62. package/examples/nextjs-middleware.js +0 -37
  63. package/examples/nextjs-middleware.ts +0 -37
  64. package/examples/nextjs-with-logging-example.md +0 -301
  65. package/examples/nextjs-with-options.ts +0 -36
  66. package/examples/test-nextjs-setup.js +0 -70
  67. package/postinstall.js +0 -296
@@ -1,392 +0,0 @@
1
- # SecureNow for Next.js - Complete Integration Guide
2
-
3
- Send traces and logs from your Next.js app to SecureNow or any OTLP-compatible backend in under 2 minutes.
4
-
5
- ## 🚀 Quick Start (2 Simple Steps!)
6
-
7
- ### Step 1: Install SecureNow
8
-
9
- ```bash
10
- npm install securenow
11
- # or
12
- yarn add securenow
13
- # or
14
- pnpm add securenow
15
- ```
16
-
17
- **🎉 The installer will automatically:**
18
- - Detect your Next.js project
19
- - Offer to create `instrumentation.ts` (or `.js`)
20
- - Create `.env.local` template
21
- - **Zero webpack warnings** (uses @vercel/otel under the hood)
22
-
23
- **Just answer "Y" when prompted!**
24
-
25
- ### Step 2: Configure Environment Variables
26
-
27
- Edit the `.env.local` file that was created:
28
-
29
- ```bash
30
- # Required: Your app name (shows up in SecureNow)
31
- SECURENOW_APPID=my-nextjs-app
32
-
33
- # Required: Your OTLP endpoint
34
- SECURENOW_INSTANCE=http://your-otlp-backend:4318
35
-
36
- # Optional: API key for authentication
37
- OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key-here"
38
- ```
39
-
40
- ### That's It! 🎉
41
-
42
- **No webpack warnings!** SecureNow uses `@vercel/otel` under the hood, which is specifically designed for Next.js and handles all the bundling correctly.
43
-
44
- ---
45
-
46
- ## 🔧 Alternative Setup Methods
47
-
48
- ### If You Skipped Auto-Setup
49
-
50
- **Option 1: Use the CLI (Recommended)**
51
-
52
- ```bash
53
- npx securenow init
54
- ```
55
-
56
- **Option 2: Create Manually**
57
-
58
- Create `instrumentation.ts` at the **root** of your Next.js project (or inside `src/`):
59
-
60
- ```typescript
61
- // instrumentation.ts
62
- import { registerSecureNow } from 'securenow/nextjs';
63
-
64
- export function register() {
65
- registerSecureNow();
66
- }
67
- ```
68
-
69
- **JavaScript version:**
70
- ```javascript
71
- // instrumentation.js
72
- const { registerSecureNow } = require('securenow/nextjs');
73
-
74
- export function register() {
75
- registerSecureNow();
76
- }
77
- ```
78
-
79
- See [AUTO-SETUP.md](./AUTO-SETUP.md) for detailed setup options.
80
-
81
- ---
82
-
83
- ## ▶️ Run Your App
84
-
85
- Run your Next.js app:
86
-
87
- ```bash
88
- npm run dev
89
- # or
90
- npm run build && npm start
91
- ```
92
-
93
- You should see:
94
- ```
95
- [securenow] Next.js integration loading
96
- [securenow] 🚀 Next.js App → service.name=my-nextjs-app-xxx
97
- [securenow] ✅ OpenTelemetry started for Next.js → http://...
98
- ```
99
-
100
- ---
101
-
102
- ## 📊 What Gets Automatically Captured?
103
-
104
- SecureNow automatically captures comprehensive request data:
105
-
106
- ### 🌐 User Information (Automatic!)
107
- - **IP Address** - From x-forwarded-for, x-real-ip, etc.
108
- - **User Agent** - Browser and device info
109
- - **Referer** - Where users came from
110
- - **Geographic Data** - Country, region, city (Vercel/Cloudflare)
111
- - **Request Metadata** - Headers, host, scheme
112
- - **Response Data** - Status codes, timing
113
-
114
- See [AUTOMATIC-IP-CAPTURE.md](./AUTOMATIC-IP-CAPTURE.md) for full details.
115
-
116
- ### 📝 Request Body Capture (Optional!)
117
- - **JSON Bodies** - API payloads with sensitive fields redacted
118
- - **GraphQL Queries** - Full query capture
119
- - **Form Data** - Form submissions
120
- - **Auto-Redaction** - Passwords, tokens, cards automatically hidden
121
-
122
- Enable with: `SECURENOW_CAPTURE_BODY=1`
123
-
124
- See [REQUEST-BODY-CAPTURE.md](./REQUEST-BODY-CAPTURE.md) for full details.
125
-
126
- ### Next.js Built-in Spans
127
- - ✅ HTTP requests (`[http.method] [next.route]`)
128
- - ✅ API routes execution
129
- - ✅ Page rendering (App Router & Pages Router)
130
- - ✅ `getServerSideProps` / `getStaticProps`
131
- - ✅ Metadata generation
132
- - ✅ Server component loading
133
- - ✅ TTFB (Time to First Byte)
134
-
135
- ### Backend Calls
136
- - ✅ HTTP/HTTPS requests (via `fetch`, `axios`, `node-fetch`, etc.)
137
- - ✅ Database queries:
138
- - PostgreSQL
139
- - MySQL / MySQL2
140
- - MongoDB
141
- - Redis
142
- - ✅ GraphQL queries
143
- - ✅ Other Node.js libraries
144
-
145
- ---
146
-
147
- ## ⚙️ Advanced Configuration
148
-
149
- ### Option 1: Environment Variables (Recommended)
150
-
151
- ```bash
152
- # .env.local
153
-
154
- # Required
155
- SECURENOW_APPID=my-nextjs-app
156
-
157
- # Optional Configuration
158
- SECURENOW_INSTANCE=http://your-otlp-backend:4318
159
- SECURENOW_NO_UUID=1 # Don't append UUID (useful for dev)
160
- OTEL_LOG_LEVEL=info # debug|info|warn|error
161
- SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns # Disable specific instrumentations
162
- SECURENOW_TEST_SPAN=1 # Create test span on startup
163
-
164
- # Authentication
165
- OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-key,authorization=Bearer token"
166
-
167
- # Alternative endpoint configuration
168
- OTEL_EXPORTER_OTLP_ENDPOINT=http://... # Base endpoint
169
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://... # Full traces URL
170
- ```
171
-
172
- ### Option 2: Programmatic Configuration
173
-
174
- ```typescript
175
- // instrumentation.ts
176
- import { registerSecureNow } from 'securenow/nextjs';
177
-
178
- export function register() {
179
- registerSecureNow({
180
- serviceName: 'my-nextjs-app',
181
- endpoint: 'http://your-otlp-backend:4318',
182
- noUuid: false,
183
- disableInstrumentations: ['fs', 'dns'],
184
- headers: {
185
- 'x-api-key': process.env.SECURENOW_API_KEY || '',
186
- },
187
- });
188
- }
189
- ```
190
-
191
- **Options:**
192
- - `serviceName` (string): Service name (overrides `SECURENOW_APPID`)
193
- - `endpoint` (string): Base URL for OTLP collector (overrides `SECURENOW_INSTANCE`)
194
- - `noUuid` (boolean): Don't append UUID to service name
195
- - `disableInstrumentations` (string[]): List of instrumentations to disable
196
- - `headers` (object): Additional headers for authentication
197
-
198
- ---
199
-
200
- ## 🔧 Next.js Version Compatibility
201
-
202
- ### Next.js 15+ (Recommended)
203
- ✅ Works out of the box. Just create `instrumentation.ts`.
204
-
205
- ### Next.js 14 and Below
206
- ⚠️ You need to enable the instrumentation hook in `next.config.js`:
207
-
208
- ```javascript
209
- // next.config.js
210
- const nextConfig = {
211
- experimental: {
212
- instrumentationHook: true, // Required for Next.js 14 and below
213
- },
214
- };
215
-
216
- module.exports = nextConfig;
217
- ```
218
-
219
- ---
220
-
221
- ## 🎯 Deployment
222
-
223
- ### Vercel
224
-
225
- SecureNow works seamlessly on Vercel:
226
-
227
- 1. Add environment variables in Vercel dashboard
228
- 2. Deploy normally
229
-
230
- The instrumentation runs during both build and runtime.
231
-
232
- ### Docker
233
-
234
- ```dockerfile
235
- FROM node:20-alpine
236
-
237
- WORKDIR /app
238
-
239
- COPY package*.json ./
240
- RUN npm ci --production
241
-
242
- COPY . .
243
- RUN npm run build
244
-
245
- ENV SECURENOW_APPID=my-nextjs-app
246
- ENV SECURENOW_INSTANCE=http://otel-collector:4318
247
-
248
- EXPOSE 3000
249
- CMD ["npm", "start"]
250
- ```
251
-
252
- ### Self-Hosted / VPS
253
-
254
- Just set environment variables and run:
255
-
256
- ```bash
257
- export SECURENOW_APPID=my-nextjs-app
258
- export SECURENOW_INSTANCE=http://your-otlp-backend:4318
259
- npm start
260
- ```
261
-
262
- ---
263
-
264
- ## 🐛 Troubleshooting
265
-
266
- ### Not seeing traces?
267
-
268
- **Check 1: Is instrumentation loading?**
269
- ```bash
270
- npm run dev
271
- # Look for: [securenow] Next.js integration loading
272
- ```
273
-
274
- **Check 2: Enable debug logging**
275
- ```bash
276
- OTEL_LOG_LEVEL=debug npm run dev
277
- ```
278
-
279
- **Check 3: Create a test span**
280
- ```bash
281
- SECURENOW_TEST_SPAN=1 npm run dev
282
- ```
283
-
284
- ### `Cannot find module 'securenow/nextjs'`
285
-
286
- Make sure you're on the latest version:
287
- ```bash
288
- npm install securenow@latest
289
- ```
290
-
291
- ### Traces not appearing in SecureNow
292
-
293
- 1. **Check endpoint:**
294
- ```bash
295
- curl http://your-otlp-backend:4318/v1/traces
296
- ```
297
-
298
- 2. **Verify connectivity:** Make sure your app can reach your OTLP backend (or SecureNow)
299
-
300
- 3. **Check authentication:** If using API keys, verify headers
301
-
302
- ### Too many spans / noisy logs
303
-
304
- Disable specific instrumentations:
305
- ```bash
306
- SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns,net
307
- ```
308
-
309
- ---
310
-
311
- ## 📖 Comparison with Other Solutions
312
-
313
- ### vs. `@vercel/otel`
314
- - ✅ **SecureNow**: Pre-configured for OTLP / SecureNow, includes auto-instrumentations
315
- - ⚠️ **@vercel/otel**: Requires manual instrumentation setup
316
-
317
- ### vs. Manual OpenTelemetry Setup
318
- - ✅ **SecureNow**: 3 lines of code, works immediately
319
- - ⚠️ **Manual**: 50+ lines, complex configuration
320
-
321
- ### vs. Other APM Solutions (DataDog, New Relic)
322
- - ✅ **SecureNow**: Open-source, self-hosted, vendor-neutral
323
- - ⚠️ **Commercial APM**: Expensive, vendor lock-in
324
-
325
- ---
326
-
327
- ## 🔥 Best Practices
328
-
329
- ### 1. Use Meaningful Service Names
330
- ```bash
331
- # Good ✅
332
- SECURENOW_APPID=checkout-service
333
- SECURENOW_APPID=user-dashboard
334
-
335
- # Bad ❌
336
- SECURENOW_APPID=app
337
- SECURENOW_APPID=test
338
- ```
339
-
340
- ### 2. Set Deployment Environment
341
- ```bash
342
- # Vercel automatically sets VERCEL_ENV
343
- # For other platforms:
344
- NODE_ENV=production
345
- ```
346
-
347
- ### 3. Use Service Instance IDs in Production
348
- ```bash
349
- # Default behavior (recommended for production)
350
- # Each worker gets a unique instance ID
351
-
352
- # For development (easier to filter)
353
- SECURENOW_NO_UUID=1
354
- ```
355
-
356
- ### 4. Disable Noisy Instrumentations
357
- ```bash
358
- # File system operations can be too verbose
359
- SECURENOW_DISABLE_INSTRUMENTATIONS=fs
360
- ```
361
-
362
- ---
363
-
364
- ## 🎓 Examples
365
-
366
- Check the `examples/` folder for:
367
- - `nextjs-instrumentation.ts` - Basic TypeScript setup
368
- - `nextjs-instrumentation.js` - Basic JavaScript setup
369
- - `nextjs-with-options.ts` - Advanced configuration
370
- - `nextjs-env-example.txt` - Complete environment variables reference
371
-
372
- ---
373
-
374
- ## 🆘 Support
375
-
376
- - **Issues:** [GitHub Issues](https://github.com/your-repo/securenow/issues)
377
- - **Documentation:** [Full Documentation](https://your-docs-site.com)
378
- - **SecureNow:** [securenow.ai](https://securenow.ai/)
379
-
380
- ---
381
-
382
- ## 📝 License
383
-
384
- ISC
385
-
386
- ---
387
-
388
- **Made with ❤️ for the Next.js and SecureNow community**
389
- # Current setup note
390
-
391
- 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.
392
-
@@ -1,83 +0,0 @@
1
- # Next.js + SecureNow — 30 seconds
2
-
3
- ## The whole setup
4
-
5
- ```bash
6
- # 1. Install
7
- npm install securenow
8
-
9
- # 2. Pick (or create) your app in the browser — writes .securenow/ locally
10
- npx securenow login
11
-
12
- # 3. Scaffold instrumentation.ts and update next.config.js
13
- npx securenow init
14
-
15
- # 4. Run
16
- npm run dev
17
- ```
18
-
19
- No `.env.local` edits. No API key copy-paste. The app you picked in step 2 is where your traces land.
20
-
21
- ---
22
-
23
- ## What `npx securenow init` generates
24
-
25
- **`instrumentation.ts`** (or `.js`, auto-detected):
26
-
27
- ```typescript
28
- export async function register() {
29
- if (process.env.NEXT_RUNTIME !== 'nodejs') return;
30
-
31
- const securenowNext = await import(/* webpackIgnore: true */ 'securenow/nextjs');
32
- const registerSecureNow = securenowNext.registerSecureNow || securenowNext.default?.registerSecureNow;
33
- registerSecureNow({ captureBody: true });
34
- await import(/* webpackIgnore: true */ 'securenow/nextjs-auto-capture');
35
- }
36
- ```
37
-
38
- For Next.js 15+, `init` adds `securenow` to `serverExternalPackages` when it can safely patch the file:
39
-
40
- ```javascript
41
- const nextConfig = {
42
- serverExternalPackages: ['securenow'],
43
- };
44
-
45
- export default nextConfig;
46
- ```
47
-
48
- For older Next.js, use `experimental.serverComponentsExternalPackages`. If you already have custom `instrumentation.*` or a complex `next.config.*`, `init` prints a Codex/Claude-ready prompt with the exact edits to merge instead of guessing.
49
-
50
- ---
51
-
52
- ## Verify
53
-
54
- Start your app. In the console you should see:
55
-
56
- ```
57
- [securenow] Next.js integration loading (pid=…)
58
- [securenow] ✅ OpenTelemetry started for Next.js → https://freetrial.securenow.ai:4318/v1/traces
59
- ```
60
-
61
- Then:
62
-
63
- ```bash
64
- npx securenow test-span # emits with config.runtime.deploymentEnvironment
65
- npx securenow traces --env local
66
- npx securenow status --env local
67
- ```
68
-
69
- If `traces` shows your span under the app name you picked, you're done.
70
-
71
- ---
72
-
73
- ## Production / Docker / Vercel
74
-
75
- Production uses the same credentials shape. Generate a tokenless runtime file:
76
-
77
- ```bash
78
- npx securenow credentials runtime --env production
79
- ```
80
-
81
- Deploy `.securenow/credentials.production.json` as a secret file and mount or copy it to `<app-root>/.securenow/credentials.json`. It contains `app`, `apiKey`, `config`, and explanations, but no CLI OAuth token.
82
-
83
- See [NEXTJS-GUIDE.md](./NEXTJS-GUIDE.md) for Vercel, standalone builds, and edge runtime details.