securenow 7.6.7 → 7.6.9

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 +23 -33
  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,1388 +0,0 @@
1
- # SecureNow — Complete Guide for Every Node.js Framework
2
-
3
- Protect any Node.js app in minutes. This guide covers **installation, CLI commands, the forensics chat, and IP blocking** for all 11 supported frameworks.
4
-
5
- > **v7+ — zero-config shortcut.** For local dev, the short version is:
6
- > ```bash
7
- > npm install securenow
8
- > npx securenow login # pick/create app in the browser
9
- > node -r securenow/register app.js
10
- > ```
11
- > No `.env` setup. Credentials live in `.securenow/credentials.json` (gitignored automatically). Skip "Step 2 — Set Environment Variables" below unless you're configuring CI / Docker / prod.
12
-
13
- ---
14
-
15
- ## Table of Contents
16
-
17
- 1. [Prerequisites](#prerequisites)
18
- 2. [Install & Create Your App](#step-1--install--create-your-app)
19
- 3. [Set Environment Variables](#step-2--set-environment-variables)
20
- 4. [Plug SecureNow into Your Framework](#step-3--plug-securenow-into-your-framework)
21
- - [Express.js](#expressjs)
22
- - [Fastify](#fastify)
23
- - [Koa](#koa)
24
- - [NestJS](#nestjs)
25
- - [Hapi](#hapi)
26
- - [h3 (UnJS / Nitro)](#h3-unjs--nitro)
27
- - [Polka](#polka)
28
- - [Micro / Raw HTTP](#micro--raw-http)
29
- - [Hono](#hono)
30
- - [Feathers](#feathers)
31
- - [Next.js](#nextjs)
32
- 5. [Verify It Works](#step-4--verify-it-works)
33
- 6. [CLI Command Reference](#step-5--cli-command-reference)
34
- 7. [Forensics Chat — Ask Questions in Plain English](#step-6--forensics-chat--ask-questions-in-plain-english)
35
- 8. [Block & Manage IPs + Firewall](#step-7--block--manage-ips)
36
- 9. [Monitor, Detect & Respond](#step-8--monitor-detect--respond)
37
- 10. [PM2 / Docker Deployment](#deployment)
38
- 11. [Compatibility Matrix](#compatibility-matrix)
39
- 12. [Troubleshooting](#troubleshooting)
40
-
41
- ---
42
-
43
- ## Prerequisites
44
-
45
- | Requirement | Details |
46
- |-------------|---------|
47
- | **Node.js** | v16 or later |
48
- | **npm** | v7 or later |
49
- | **Account** | Free trial at [app.securenow.ai](https://app.securenow.ai) (no credit card) |
50
-
51
- ---
52
-
53
- ## Step 1 — Install & Create Your App
54
-
55
- ### 1a. Install the package
56
-
57
- ```bash
58
- npm install securenow
59
- ```
60
-
61
- ### 1b. Authenticate the CLI
62
-
63
- ```bash
64
- npx securenow login
65
- ```
66
-
67
- This opens your browser. Log in with your SecureNow account and the CLI receives a session token automatically.
68
-
69
- **Alternative — token-based login (CI / headless servers):**
70
-
71
- ```bash
72
- npx securenow login --token <YOUR_TOKEN>
73
- ```
74
-
75
- Get your CLI token from [app.securenow.ai/dashboard/settings](https://app.securenow.ai/dashboard/settings).
76
-
77
- ### 1c. Create an application
78
-
79
- ```bash
80
- npx securenow apps create my-app
81
- ```
82
-
83
- The CLI returns your **app key** and **instance URL**. Copy them — you need both in the next step.
84
-
85
- ```
86
- Name my-app
87
- Key my-app
88
- Instance Free Trial (https://freetrial.securenow.ai:4318)
89
-
90
- Add to your .env.local:
91
- SECURENOW_APPID=my-app
92
- SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
93
- ```
94
-
95
- ### 1d. Set it as the default app (optional)
96
-
97
- ```bash
98
- npx securenow config set defaultApp my-app
99
- ```
100
-
101
- This lets you run CLI commands like `securenow traces` without passing `--app` every time.
102
-
103
- ---
104
-
105
- ## Step 2 — Set Environment Variables
106
-
107
- Create a `.env` file in your project root:
108
-
109
- ```env
110
- SECURENOW_APPID=my-app
111
- SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
112
- SECURENOW_LOGGING_ENABLED=1
113
- SECURENOW_NO_UUID=1
114
- ```
115
-
116
- ### All Environment Variables
117
-
118
- | Variable | Purpose | Default |
119
- |----------|---------|---------|
120
- | `SECURENOW_APPID` | Your app key (from `securenow apps create`) | **Required** |
121
- | `SECURENOW_INSTANCE` | OTLP collector endpoint | `https://freetrial.securenow.ai:4318` |
122
- | `SECURENOW_LOGGING_ENABLED` | Auto-forward all `console.*` calls as OTLP logs | `1` |
123
- | `SECURENOW_NO_UUID` | Keep `service.name` equal to your app key (no UUID suffix) | `0` |
124
- | `SECURENOW_CAPTURE_BODY` | Capture request/response bodies in traces | `1` |
125
- | `SECURENOW_CAPTURE_MULTIPART` | Capture multipart field/file metadata | `1` |
126
- | `SECURENOW_MAX_BODY_SIZE` | Max captured body size in bytes | `10240` |
127
- | `SECURENOW_SENSITIVE_FIELDS` | Extra field names to auto-redact (comma-separated) | — |
128
- | `SECURENOW_TRUSTED_PROXIES` | Comma-separated proxy IPs for X-Forwarded-For | — |
129
- | `SECURENOW_DISABLE_INSTRUMENTATIONS` | OTel instrumentation packages to skip (comma-separated) | — |
130
- | `SECURENOW_HIDE_BANNER` | Hide the free-trial testing banner | `0` |
131
- | `SECURENOW_STRICT` | Exit if `APPID` is missing in PM2 cluster mode | `0` |
132
- | `OTEL_LOG_LEVEL` | OTel diagnostic level (`debug`, `info`, `warn`, `error`, `none`) | `none` |
133
-
134
- ### Production Example
135
-
136
- ```env
137
- SECURENOW_APPID=my-app-prod
138
- SECURENOW_INSTANCE=https://collector.yourcompany.com:4318
139
- SECURENOW_LOGGING_ENABLED=1
140
- SECURENOW_NO_UUID=1
141
- SECURENOW_CAPTURE_BODY=1
142
- SECURENOW_CAPTURE_MULTIPART=1
143
- SECURENOW_TRUSTED_PROXIES=10.0.0.1,10.0.0.2
144
- NODE_ENV=production
145
- ```
146
-
147
- ---
148
-
149
- ## Step 3 — Plug SecureNow into Your Framework
150
-
151
- There are two ways to initialize SecureNow. Both work with every framework.
152
-
153
- **Option A — Zero code changes (recommended)**
154
-
155
- ```bash
156
- node -r securenow/register app.js
157
- ```
158
-
159
- **Option B — Add one line to your entry file**
160
-
161
- ```javascript
162
- require('securenow/register'); // Must be the very first line
163
- ```
164
-
165
- Pick **one** method. Both do the same thing. Below are complete, copy-paste examples for each framework.
166
-
167
- ---
168
-
169
- ### Express.js
170
-
171
- ```bash
172
- npm install securenow express
173
- ```
174
-
175
- ```javascript
176
- // app.js
177
- 'use strict';
178
- require('securenow/register');
179
- const express = require('express');
180
-
181
- const app = express();
182
- app.use(express.json());
183
-
184
- app.get('/health', (req, res) => {
185
- res.json({ status: 'ok' });
186
- });
187
-
188
- app.post('/tasks', (req, res) => {
189
- const { title } = req.body;
190
- if (!title) return res.status(400).json({ error: 'title is required' });
191
- console.log('Created task:', title);
192
- res.status(201).json({ id: '1', title });
193
- });
194
-
195
- app.listen(3000, () => {
196
- console.log('Express app running on port 3000');
197
- });
198
- ```
199
-
200
- ```bash
201
- node app.js
202
- ```
203
-
204
- | Feature | Supported |
205
- |---------|-----------|
206
- | Traces | Yes |
207
- | Logs | Yes |
208
- | Body Capture | Yes - default on |
209
-
210
- ---
211
-
212
- ### Fastify
213
-
214
- ```bash
215
- npm install securenow fastify
216
- ```
217
-
218
- ```javascript
219
- // app.js
220
- 'use strict';
221
- require('securenow/register');
222
- const Fastify = require('fastify');
223
-
224
- const fastify = Fastify({ logger: true });
225
-
226
- fastify.get('/health', async () => {
227
- return { status: 'ok' };
228
- });
229
-
230
- fastify.post('/tasks', {
231
- schema: {
232
- body: { type: 'object', required: ['title'], properties: { title: { type: 'string' } } }
233
- }
234
- }, async (request) => {
235
- const { title } = request.body;
236
- console.log('Created task:', title);
237
- return { id: '1', title };
238
- });
239
-
240
- fastify.listen({ port: 3000 }, (err) => {
241
- if (err) { fastify.log.error(err); process.exit(1); }
242
- console.log('Fastify app running on port 3000');
243
- });
244
- ```
245
-
246
- ```bash
247
- node app.js
248
- ```
249
-
250
- | Feature | Supported |
251
- |---------|-----------|
252
- | Traces | Yes |
253
- | Logs | Yes |
254
- | Body Capture | Yes - default on; set `SECURENOW_CAPTURE_BODY=0` only for a local stream conflict |
255
-
256
- ---
257
-
258
- ### Koa
259
-
260
- ```bash
261
- npm install securenow koa @koa/router koa-bodyparser
262
- ```
263
-
264
- ```javascript
265
- // app.js
266
- 'use strict';
267
- require('securenow/register');
268
- const Koa = require('koa');
269
- const Router = require('@koa/router');
270
- const bodyParser = require('koa-bodyparser');
271
-
272
- const app = new Koa();
273
- const router = new Router();
274
-
275
- router.get('/health', (ctx) => {
276
- ctx.body = { status: 'ok' };
277
- });
278
-
279
- router.post('/tasks', (ctx) => {
280
- const { title } = ctx.request.body;
281
- if (!title) { ctx.status = 400; ctx.body = { error: 'title is required' }; return; }
282
- console.log('Created task:', title);
283
- ctx.status = 201;
284
- ctx.body = { id: '1', title };
285
- });
286
-
287
- app.use(bodyParser());
288
- app.use(router.routes());
289
- app.use(router.allowedMethods());
290
-
291
- app.listen(3000, () => {
292
- console.log('Koa app running on port 3000');
293
- });
294
- ```
295
-
296
- ```bash
297
- node app.js
298
- ```
299
-
300
- | Feature | Supported |
301
- |---------|-----------|
302
- | Traces | Yes |
303
- | Logs | Yes |
304
- | Body Capture | Yes - default on |
305
-
306
- ---
307
-
308
- ### NestJS
309
-
310
- ```bash
311
- npm install securenow
312
- ```
313
-
314
- NestJS uses TypeScript. Create an `instrument.js` file in your project root to load SecureNow before anything else:
315
-
316
- ```javascript
317
- // instrument.js
318
- require('securenow/register');
319
- ```
320
-
321
- Your NestJS entry file stays unchanged:
322
-
323
- ```typescript
324
- // src/main.ts
325
- import 'reflect-metadata';
326
- import { NestFactory } from '@nestjs/core';
327
- import { Module, Controller, Get, Post, Body } from '@nestjs/common';
328
-
329
- @Controller()
330
- class AppController {
331
- @Get('health')
332
- health() {
333
- return { status: 'ok' };
334
- }
335
-
336
- @Post('tasks')
337
- create(@Body() body: { title: string }) {
338
- console.log('Created task:', body.title);
339
- return { id: '1', title: body.title };
340
- }
341
- }
342
-
343
- @Module({ controllers: [AppController] })
344
- class AppModule {}
345
-
346
- async function bootstrap() {
347
- const app = await NestFactory.create(AppModule);
348
- await app.listen(3000);
349
- console.log('NestJS app running on port 3000');
350
- }
351
- bootstrap();
352
- ```
353
-
354
- **Development (ts-node):**
355
-
356
- ```bash
357
- node -r ./instrument.js -r ts-node/register src/main.ts
358
- ```
359
-
360
- **Production (compiled):**
361
-
362
- ```bash
363
- node -r ./instrument.js dist/main.js
364
- ```
365
-
366
- Add both to your `package.json`:
367
-
368
- ```json
369
- {
370
- "scripts": {
371
- "start:dev": "node -r ./instrument.js -r ts-node/register src/main.ts",
372
- "start": "node -r ./instrument.js dist/main.js"
373
- }
374
- }
375
- ```
376
-
377
- | Feature | Supported |
378
- |---------|-----------|
379
- | Traces | Yes |
380
- | Logs | Yes |
381
- | Body Capture | Yes - default on |
382
-
383
- ---
384
-
385
- ### Hapi
386
-
387
- ```bash
388
- npm install securenow @hapi/hapi
389
- ```
390
-
391
- ```javascript
392
- // app.js
393
- 'use strict';
394
- require('securenow/register');
395
- const Hapi = require('@hapi/hapi');
396
-
397
- const init = async () => {
398
- const server = Hapi.server({ port: 3000, host: '0.0.0.0' });
399
-
400
- server.route({
401
- method: 'GET', path: '/health',
402
- handler: () => ({ status: 'ok' })
403
- });
404
-
405
- server.route({
406
- method: 'POST', path: '/tasks',
407
- options: { payload: { parse: true, allow: 'application/json' } },
408
- handler: (request, h) => {
409
- const { title } = request.payload || {};
410
- if (!title) return h.response({ error: 'title is required' }).code(400);
411
- console.log('Created task:', title);
412
- return h.response({ id: '1', title }).code(201);
413
- }
414
- });
415
-
416
- await server.start();
417
- console.log('Hapi app running on port 3000');
418
- };
419
-
420
- init().catch((err) => { console.error(err); process.exit(1); });
421
- ```
422
-
423
- ```bash
424
- node app.js
425
- ```
426
-
427
- | Feature | Supported |
428
- |---------|-----------|
429
- | Traces | Yes |
430
- | Logs | Yes |
431
- | Body Capture | Yes - default on; set `SECURENOW_CAPTURE_BODY=0` only for a local stream conflict |
432
-
433
- ---
434
-
435
- ### h3 (UnJS / Nitro)
436
-
437
- ```bash
438
- npm install securenow h3
439
- ```
440
-
441
- ```javascript
442
- // app.js
443
- 'use strict';
444
- require('securenow/register');
445
- const { createApp, createRouter, defineEventHandler, readBody, setResponseStatus, toNodeListener } = require('h3');
446
- const http = require('http');
447
-
448
- const app = createApp();
449
- const router = createRouter();
450
-
451
- router.get('/health', defineEventHandler(() => {
452
- return { status: 'ok' };
453
- }));
454
-
455
- router.post('/tasks', defineEventHandler(async (event) => {
456
- const body = await readBody(event);
457
- if (!body?.title) { setResponseStatus(event, 400); return { error: 'title is required' }; }
458
- console.log('Created task:', body.title);
459
- setResponseStatus(event, 201);
460
- return { id: '1', title: body.title };
461
- }));
462
-
463
- app.use(router);
464
-
465
- http.createServer(toNodeListener(app)).listen(3000, () => {
466
- console.log('h3 app running on port 3000');
467
- });
468
- ```
469
-
470
- ```bash
471
- node app.js
472
- ```
473
-
474
- | Feature | Supported |
475
- |---------|-----------|
476
- | Traces | Yes |
477
- | Logs | Yes |
478
- | Body Capture | Yes - default on |
479
-
480
- ---
481
-
482
- ### Polka
483
-
484
- ```bash
485
- npm install securenow polka
486
- ```
487
-
488
- Polka has no built-in body parser, so add a simple middleware:
489
-
490
- ```javascript
491
- // app.js
492
- 'use strict';
493
- require('securenow/register');
494
- const polka = require('polka');
495
-
496
- function jsonBody(req, res, next) {
497
- if (req.method === 'GET' || req.method === 'DELETE') return next();
498
- let data = '';
499
- req.on('data', chunk => { data += chunk; });
500
- req.on('end', () => {
501
- try { req.body = JSON.parse(data); } catch { req.body = {}; }
502
- next();
503
- });
504
- }
505
-
506
- function sendJson(res, status, body) {
507
- res.writeHead(status, { 'Content-Type': 'application/json' });
508
- res.end(JSON.stringify(body));
509
- }
510
-
511
- polka()
512
- .use(jsonBody)
513
- .get('/health', (req, res) => sendJson(res, 200, { status: 'ok' }))
514
- .post('/tasks', (req, res) => {
515
- const { title } = req.body;
516
- if (!title) return sendJson(res, 400, { error: 'title is required' });
517
- console.log('Created task:', title);
518
- sendJson(res, 201, { id: '1', title });
519
- })
520
- .listen(3000, () => {
521
- console.log('Polka app running on port 3000');
522
- });
523
- ```
524
-
525
- ```bash
526
- node app.js
527
- ```
528
-
529
- | Feature | Supported |
530
- |---------|-----------|
531
- | Traces | Yes |
532
- | Logs | Yes |
533
- | Body Capture | Yes - default on |
534
-
535
- ---
536
-
537
- ### Micro / Raw HTTP
538
-
539
- For apps using the bare `http` module:
540
-
541
- ```bash
542
- npm install securenow
543
- ```
544
-
545
- ```javascript
546
- // app.js
547
- 'use strict';
548
- require('securenow/register');
549
- const http = require('http');
550
-
551
- function sendJson(res, status, body) {
552
- res.writeHead(status, { 'Content-Type': 'application/json' });
553
- res.end(JSON.stringify(body));
554
- }
555
-
556
- function readBody(req) {
557
- return new Promise((resolve) => {
558
- let data = '';
559
- req.on('data', chunk => { data += chunk; });
560
- req.on('end', () => {
561
- try { resolve(JSON.parse(data)); } catch { resolve({}); }
562
- });
563
- });
564
- }
565
-
566
- async function handler(req, res) {
567
- const url = new URL(req.url, `http://${req.headers.host}`);
568
-
569
- if (url.pathname === '/health' && req.method === 'GET') {
570
- return sendJson(res, 200, { status: 'ok' });
571
- }
572
-
573
- if (url.pathname === '/tasks' && req.method === 'POST') {
574
- const body = await readBody(req);
575
- if (!body.title) return sendJson(res, 400, { error: 'title is required' });
576
- console.log('Created task:', body.title);
577
- return sendJson(res, 201, { id: '1', title: body.title });
578
- }
579
-
580
- sendJson(res, 404, { error: 'Not found' });
581
- }
582
-
583
- http.createServer(handler).listen(3000, () => {
584
- console.log('HTTP app running on port 3000');
585
- });
586
- ```
587
-
588
- ```bash
589
- node app.js
590
- ```
591
-
592
- | Feature | Supported |
593
- |---------|-----------|
594
- | Traces | Yes |
595
- | Logs | Yes |
596
- | Body Capture | Yes - default on |
597
-
598
- ---
599
-
600
- ### Hono
601
-
602
- ```bash
603
- npm install securenow hono @hono/node-server
604
- ```
605
-
606
- Hono uses ESM, so load SecureNow via the `-r` flag (do **not** use `require()` in `.mjs` files):
607
-
608
- ```javascript
609
- // app.mjs
610
- import { serve } from '@hono/node-server';
611
- import { Hono } from 'hono';
612
-
613
- const app = new Hono();
614
-
615
- app.get('/health', (c) => c.json({ status: 'ok' }));
616
-
617
- app.post('/tasks', async (c) => {
618
- const body = await c.req.json();
619
- if (!body.title) return c.json({ error: 'title is required' }, 400);
620
- console.log('Created task:', body.title);
621
- return c.json({ id: '1', title: body.title }, 201);
622
- });
623
-
624
- serve({ fetch: app.fetch, port: 3000 }, () => {
625
- console.log('Hono app running on port 3000');
626
- });
627
- ```
628
-
629
- ```bash
630
- node -r securenow/register app.mjs
631
- ```
632
-
633
- | Feature | Supported |
634
- |---------|-----------|
635
- | Traces | Yes |
636
- | Logs | Yes |
637
- | Body Capture | Yes - default on; set `SECURENOW_CAPTURE_BODY=0` only for a local stream conflict |
638
-
639
- ---
640
-
641
- ### Feathers
642
-
643
- ```bash
644
- npm install securenow @feathersjs/feathers @feathersjs/express @feathersjs/errors
645
- ```
646
-
647
- Feathers uses Express as its transport, so the setup is identical:
648
-
649
- ```javascript
650
- // app.js
651
- 'use strict';
652
- require('securenow/register');
653
- const feathers = require('@feathersjs/feathers');
654
- const express = require('@feathersjs/express');
655
- const errors = require('@feathersjs/errors');
656
-
657
- class TaskService {
658
- constructor() { this.tasks = []; this.nextId = 1; }
659
-
660
- async find() { return this.tasks; }
661
-
662
- async create(data) {
663
- if (!data.title) throw new errors.BadRequest('title is required');
664
- const task = { id: String(this.nextId++), title: data.title };
665
- this.tasks.push(task);
666
- console.log('Created task:', task.id);
667
- return task;
668
- }
669
- }
670
-
671
- const app = express(feathers());
672
- app.use(express.json());
673
- app.configure(express.rest());
674
-
675
- app.get('/health', (req, res) => res.json({ status: 'ok' }));
676
- app.use('/tasks', new TaskService());
677
- app.use(express.errorHandler());
678
-
679
- app.listen(3000, () => {
680
- console.log('Feathers app running on port 3000');
681
- });
682
- ```
683
-
684
- ```bash
685
- node app.js
686
- ```
687
-
688
- | Feature | Supported |
689
- |---------|-----------|
690
- | Traces | Yes |
691
- | Logs | Yes |
692
- | Body Capture | Yes - default on |
693
-
694
- ---
695
-
696
- ### Next.js
697
-
698
- ```bash
699
- npm install securenow
700
- ```
701
-
702
- Create `instrumentation.ts` (or `.js`) in your project root (or `src/` if you use that layout):
703
-
704
- ```typescript
705
- // instrumentation.ts
706
- export async function register() {
707
- if (process.env.NEXT_RUNTIME === 'nodejs') {
708
- await import('securenow/register');
709
- }
710
- }
711
- ```
712
-
713
- Add to `.env.local`:
714
-
715
- ```env
716
- SECURENOW_APPID=my-nextjs-app
717
- SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
718
- SECURENOW_LOGGING_ENABLED=1
719
- SECURENOW_NO_UUID=1
720
- ```
721
-
722
- **Or scaffold it automatically:**
723
-
724
- ```bash
725
- npx securenow init
726
- ```
727
-
728
- This creates both `instrumentation.ts` and `.env.local` for you.
729
-
730
- ```bash
731
- npm run dev
732
- ```
733
-
734
- | Feature | Supported |
735
- |---------|-----------|
736
- | Traces | Yes |
737
- | Logs | Yes |
738
- | Body Capture | Yes |
739
-
740
- See the [full Next.js guide](./NEXTJS-SETUP-COMPLETE.md) for App Router, middleware, and server actions.
741
-
742
- ---
743
-
744
- ## Step 4 — Verify It Works
745
-
746
- After starting your app, you should see this in the console:
747
-
748
- ```
749
- [securenow] OTel SDK started → https://freetrial.securenow.ai:4318/v1/traces
750
- [securenow] 📋 Logging: ENABLED → https://freetrial.securenow.ai:4318/v1/logs
751
- ```
752
-
753
- Send a test request:
754
-
755
- ```bash
756
- curl http://localhost:3000/health
757
- ```
758
-
759
- Then check traces from the CLI:
760
-
761
- ```bash
762
- npx securenow traces --app my-app
763
- ```
764
-
765
- Traces and logs should appear within seconds.
766
-
767
- ---
768
-
769
- ## Step 5 — CLI Command Reference
770
-
771
- The SecureNow CLI is your terminal command center. Below is every command organized by workflow.
772
-
773
- ### Authentication
774
-
775
- | Command | What It Does |
776
- |---------|-------------|
777
- | `securenow login` | Opens browser to authenticate (global session) |
778
- | `securenow login --token <T>` | Authenticate with a token (for CI/CD or headless servers) |
779
- | `securenow login --local` | Save credentials to this project only (per-project session) |
780
- | `securenow logout` | Clear stored credentials |
781
- | `securenow logout --local` | Clear project-local credentials only |
782
- | `securenow whoami` | Show current session (email, API URL, auth source, expiry, default app) |
783
-
784
- **Per-project credentials:** Use `--local` to maintain separate logins for different projects on the same machine. The CLI resolves credentials in order: `SECURENOW_TOKEN` env var → project `.securenow/credentials.json` → global `~/.securenow/credentials.json`.
785
-
786
- ### App Management
787
-
788
- | Command | What It Does |
789
- |---------|-------------|
790
- | `securenow apps list` | List all your applications |
791
- | `securenow apps create <name>` | Create a new app (interactive instance picker) |
792
- | `securenow apps create <name> --hosts api.example.com` | Create with host binding |
793
- | `securenow apps info <id>` | Show app details + env variables |
794
- | `securenow apps delete <id>` | Delete an app |
795
- | `securenow apps default <key>` | Set default app for CLI commands |
796
- | `securenow apps discover --domain example.com` | Discover subdomains and add as apps |
797
- | `securenow apps scan --yes` | Scan all app domains for new subdomains |
798
-
799
- ### Observe — Traces & Logs
800
-
801
- | Command | What It Does |
802
- |---------|-------------|
803
- | `securenow traces` | List recent traces |
804
- | `securenow traces --app my-app --limit 50` | Filtered trace list |
805
- | `securenow traces show <traceId>` | Show all spans in a trace |
806
- | `securenow traces analyze <traceId>` | AI-powered security analysis of a trace |
807
- | `securenow logs` | List recent logs |
808
- | `securenow logs --app my-app --minutes 30 --level ERROR` | Filtered logs |
809
- | `securenow logs trace <traceId>` | Show all logs for a specific trace |
810
- | `securenow analytics --app my-app` | Response code breakdown (2xx/3xx/4xx/5xx) |
811
- | `securenow status` | Dashboard overview (apps, alerts, protection status) |
812
-
813
- ### Detect & Respond — Alerts, Notifications, False Positives
814
-
815
- | Command | What It Does |
816
- |---------|-------------|
817
- | `securenow alerts rules` | List alert rules |
818
- | `securenow alerts rules show <id>` | One rule (all-apps vs explicit keys) |
819
- | `securenow alerts rules update <id> --applications-all` | All current & future apps |
820
- | `securenow alerts rules update <id> --apps k1,k2` | Explicit app keys only |
821
- | `securenow alerts channels` | List alert channels (email, webhook, Slack) |
822
- | `securenow alerts history --limit 50` | View past triggered alerts |
823
- | `securenow notifications` | List notifications |
824
- | `securenow notifications unread` | Show unread count |
825
- | `securenow notifications read <id>` | Mark one as read |
826
- | `securenow notifications read-all` | Mark all as read |
827
- | `securenow fp` / `fp list` | List FP exclusion rules |
828
- | `securenow fp show <id>` | Rule detail (conditions, scope, match mode) |
829
- | `securenow fp create --conditions '[...]'` | Create raw exclusion rule |
830
- | `securenow fp create --path /api/events --method POST --path-safe standard` | Safe-value preset helper |
831
- | `securenow fp edit <id> [--active true\|false] [--conditions '[...]']` | Edit existing rule |
832
- | `securenow fp delete <id> [--yes]` | Delete rule |
833
- | `securenow fp test-body '<json>' --conditions '[...]'` | Test conditions against a payload |
834
- | `securenow fp dry-run --conditions '[...]'` | Dry-run against last 3 days of live traces |
835
- | `securenow fp ai-fill --description "..."` | AI-generate exclusion conditions |
836
- | `securenow fp mark <notification-id> <ip>` | Mark an IP as FP on a notification in one shot |
837
-
838
- ### Investigate — IP Intelligence & Forensics
839
-
840
- | Command | What It Does |
841
- |---------|-------------|
842
- | `securenow ip <ip-address>` | Full IP intelligence report (country, ISP, abuse score, risk factors) |
843
- | `securenow ip traces <ip-address>` | Show all traces from a specific IP |
844
- | `securenow forensics "<query>"` | **Chat with your data** — natural language to SQL (see below) |
845
- | `securenow forensics library` | View saved forensic queries |
846
- | `securenow api-map` | List all discovered API endpoints |
847
- | `securenow api-map stats` | API map statistics |
848
-
849
- ### Remediation — Blocklist, Allowlist & Trusted IPs
850
-
851
- | Command | What It Does |
852
- |---------|-------------|
853
- | `securenow blocklist` | List all blocked IPs |
854
- | `securenow blocklist add <ip>` | Block an IP address |
855
- | `securenow blocklist add <cidr> --reason "brute force"` | Block a CIDR range with reason |
856
- | `securenow blocklist remove <id>` | Unblock an IP |
857
- | `securenow blocklist stats` | Blocklist statistics |
858
- | `securenow allowlist` | List allowed IPs (restrict mode) |
859
- | `securenow allowlist add <ip> --label "office" --reason "corporate VPN"` | Allow an IP |
860
- | `securenow allowlist remove <id>` | Remove from allowlist |
861
- | `securenow trusted` | List trusted IPs |
862
- | `securenow trusted add <ip> --label "office"` | Add a trusted IP |
863
- | `securenow trusted remove <id>` | Remove a trusted IP |
864
-
865
- ### Firewall Runtime
866
-
867
- | Command | What It Does |
868
- |---------|-------------|
869
- | `securenow firewall status` | Active layers, sync time, blocked count |
870
- | `securenow firewall test-ip <ip>` | Check if an IP would be blocked |
871
- | `securenow run --firewall-only <script>` | Preload firewall **without** OTel tracing (zero overhead) |
872
-
873
- ### Telemetry from the Shell
874
-
875
- Mirrors the SDK's `getLogger()` and tracing APIs for scripts, cron, and CI.
876
-
877
- | Command | What It Does |
878
- |---------|-------------|
879
- | `securenow log send "<msg>" [--level info\|warn\|error] [--attrs k=v]` | Emit an OTLP log record |
880
- | `securenow test-span [<name>]` | Emit a test span to verify collector connectivity |
881
-
882
- ### Utilities
883
-
884
- SDK helpers surfaced as CLI commands.
885
-
886
- | Command | What It Does |
887
- |---------|-------------|
888
- | `securenow redact '<json>' [--fields f1,f2]` | Redact sensitive fields (accepts `@file.json`) |
889
- | `securenow cidr match <ip> <cidrs>` | IP vs. CIDR list (exit 0 hit / 2 miss) |
890
- | `securenow cidr parse <cidr>` | Parse CIDR — network, broadcast, mask, size |
891
- | `securenow env [--json]` | Show resolved config (service name, endpoints, env vars) |
892
- | `securenow doctor [--json]` | Probe OTLP + API endpoints, check config sanity |
893
-
894
- ### Settings & Config
895
-
896
- | Command | What It Does |
897
- |---------|-------------|
898
- | `securenow config set <key> <value>` | Set a config value |
899
- | `securenow config get [key]` | Get a config value (or show all) |
900
- | `securenow config path` | Show config + credentials file paths |
901
- | `securenow instances` | List ClickHouse instances |
902
- | `securenow instances test <id>` | Test an instance connection |
903
- | `securenow version` | Show CLI version |
904
-
905
- ### Global Flags
906
-
907
- Every command supports:
908
-
909
- | Flag | Effect |
910
- |------|--------|
911
- | `--json` | Output raw JSON (pipe to `jq`, scripts, etc.) |
912
- | `--help` | Show help for any command |
913
- | `--app <key>` | Override the default app for this command |
914
-
915
- ---
916
-
917
- ## Step 6 — Forensics Chat — Ask Questions in Plain English
918
-
919
- The `securenow forensics` command lets you **ask security questions in plain English**. SecureNow translates your question to SQL, runs it against your ClickHouse traces database, and returns the results.
920
-
921
- ### How to Use
922
-
923
- ```bash
924
- npx securenow forensics "your question here"
925
- ```
926
-
927
- ### Example Queries
928
-
929
- **Find suspicious activity:**
930
-
931
- ```bash
932
- npx securenow forensics "show me all 401 responses in the last hour"
933
- ```
934
-
935
- **Hunt for attackers:**
936
-
937
- ```bash
938
- npx securenow forensics "which IPs sent the most requests in the last 24 hours"
939
- ```
940
-
941
- **Find slow endpoints:**
942
-
943
- ```bash
944
- npx securenow forensics "show the slowest API endpoints this week"
945
- ```
946
-
947
- **Investigate a specific IP:**
948
-
949
- ```bash
950
- npx securenow forensics "show all requests from 185.220.101.1 in the last 7 days"
951
- ```
952
-
953
- **Error analysis:**
954
-
955
- ```bash
956
- npx securenow forensics "count 500 errors per endpoint in the last 24 hours"
957
- ```
958
-
959
- **Brute force detection:**
960
-
961
- ```bash
962
- npx securenow forensics "find IPs that sent more than 100 POST requests to /login today"
963
- ```
964
-
965
- **Data exfiltration patterns:**
966
-
967
- ```bash
968
- npx securenow forensics "show requests with response bodies larger than 1MB"
969
- ```
970
-
971
- ### How It Works
972
-
973
- 1. You type a question in English
974
- 2. SecureNow's AI converts it to a SQL query
975
- 3. The query runs against your ClickHouse traces database
976
- 4. Results are displayed as a table in your terminal
977
-
978
- The CLI shows you both the generated SQL and the results:
979
-
980
- ```
981
- Generated SQL
982
-
983
- SELECT ClientIP, count() as cnt FROM traces
984
- WHERE Timestamp > now() - INTERVAL 1 HOUR AND ResponseStatusCode = 401
985
- GROUP BY ClientIP ORDER BY cnt DESC LIMIT 20
986
-
987
- Results (5 rows)
988
-
989
- ClientIP cnt
990
- 185.220.101.1 342
991
- 45.134.26.8 128
992
- ...
993
- ```
994
-
995
- ### Save & Reuse Queries
996
-
997
- View your saved query library:
998
-
999
- ```bash
1000
- npx securenow forensics library
1001
- ```
1002
-
1003
- ### Output as JSON
1004
-
1005
- Pipe forensic results to scripts or other tools:
1006
-
1007
- ```bash
1008
- npx securenow forensics "top 10 IPs by request count today" --json | jq '.result'
1009
- ```
1010
-
1011
- ---
1012
-
1013
- ## Step 7 — Block & Manage IPs
1014
-
1015
- SecureNow gives you full IP lifecycle management — investigate, block, trust, and audit.
1016
-
1017
- ### Investigate an IP
1018
-
1019
- Before blocking, look up the IP's intelligence:
1020
-
1021
- ```bash
1022
- npx securenow ip 185.220.101.1
1023
- ```
1024
-
1025
- Output:
1026
-
1027
- ```
1028
- IP Intelligence: 185.220.101.1
1029
-
1030
- Country Germany (DE)
1031
- ISP Tor Exit Node
1032
- Usage Type Hosting
1033
- Abuse Score 100/100
1034
- Malicious Yes
1035
- Bot Yes
1036
- Total Reports 4,521
1037
-
1038
- Risk Factors
1039
- • Known Tor exit node
1040
- • High abuse confidence score
1041
- • Associated with brute force attacks
1042
-
1043
- Attack Types
1044
- • SSH Brute Force
1045
- • Web Application Attack
1046
- • Port Scanning
1047
- ```
1048
-
1049
- ### See What That IP Did
1050
-
1051
- ```bash
1052
- npx securenow ip traces 185.220.101.1
1053
- ```
1054
-
1055
- Shows all traced requests from that IP — method, status code, URL, duration, and time.
1056
-
1057
- ### Block an IP
1058
-
1059
- ```bash
1060
- npx securenow blocklist add 185.220.101.1 --reason "tor exit node, brute force"
1061
- ```
1062
-
1063
- Block a CIDR range:
1064
-
1065
- ```bash
1066
- npx securenow blocklist add 185.220.101.0/24 --reason "malicious subnet"
1067
- ```
1068
-
1069
- Block with an expiration:
1070
-
1071
- ```bash
1072
- npx securenow blocklist add 45.134.26.8 --reason "rate limiting" --duration 24h
1073
- ```
1074
-
1075
- ### View All Blocked IPs
1076
-
1077
- ```bash
1078
- npx securenow blocklist
1079
- ```
1080
-
1081
- Output:
1082
-
1083
- ```
1084
- ID IP/CIDR Reason Source Added Expires
1085
- abc123... 185.220.101.1 tor exit node manual 2 hours ago permanent
1086
- def456... 185.220.101.0/24 malicious subnet manual 1 hour ago permanent
1087
- ghi789... 45.134.26.8 rate limiting manual 30 min ago 2024-01-16
1088
- ```
1089
-
1090
- ### Unblock an IP
1091
-
1092
- ```bash
1093
- npx securenow blocklist remove abc123
1094
- ```
1095
-
1096
- ### Blocklist Statistics
1097
-
1098
- ```bash
1099
- npx securenow blocklist stats
1100
- ```
1101
-
1102
- Shows total active blocks, removed blocks, manual vs automated counts, and active automation rules.
1103
-
1104
- ### Trust an IP (Whitelist)
1105
-
1106
- Trusted IPs bypass security detections:
1107
-
1108
- ```bash
1109
- npx securenow trusted add 203.0.113.50 --label "office VPN"
1110
- ```
1111
-
1112
- List trusted IPs:
1113
-
1114
- ```bash
1115
- npx securenow trusted
1116
- ```
1117
-
1118
- Remove a trusted IP:
1119
-
1120
- ```bash
1121
- npx securenow trusted remove <id>
1122
- ```
1123
-
1124
- ### Full Investigation → Block Workflow
1125
-
1126
- Here is the typical workflow for handling a suspicious IP:
1127
-
1128
- ```bash
1129
- # 1. Check forensics for anomalies
1130
- npx securenow forensics "IPs with more than 50 failed login attempts today"
1131
-
1132
- # 2. Pick a suspicious IP and investigate
1133
- npx securenow ip 185.220.101.1
1134
-
1135
- # 3. See exactly what it did
1136
- npx securenow ip traces 185.220.101.1
1137
-
1138
- # 4. Block it
1139
- npx securenow blocklist add 185.220.101.1 --reason "brute force login attempts"
1140
-
1141
- # 5. Verify it's blocked
1142
- npx securenow blocklist
1143
- ```
1144
-
1145
- ### Enforce the Blocklist on Your App (Firewall)
1146
-
1147
- Once you've built a blocklist, enforce it at your application layer — automatically, with zero code changes:
1148
-
1149
- ```bash
1150
- # Add your API key to .env
1151
- SECURENOW_API_KEY=snk_live_abc123...
1152
- ```
1153
-
1154
- Restart your app. The firewall syncs the blocklist every 60 seconds and blocks matching IPs with a 403 response:
1155
-
1156
- ```
1157
- [securenow] Firewall: ENABLED
1158
- [securenow] Firewall: Layer 1 (HTTP 403) active
1159
- [securenow] Firewall: synced 142 blocked IPs
1160
- ```
1161
-
1162
- Enable additional layers for defense in depth:
1163
-
1164
- ```bash
1165
- # TCP-level blocking (zero bytes sent back)
1166
- SECURENOW_FIREWALL_TCP=1
1167
-
1168
- # OS-level blocking (iptables/nftables, Linux only)
1169
- SECURENOW_FIREWALL_IPTABLES=1
1170
-
1171
- # Cloud WAF blocking (Cloudflare, AWS WAF, GCP Cloud Armor)
1172
- SECURENOW_FIREWALL_CLOUD=cloudflare
1173
- ```
1174
-
1175
- Check firewall status:
1176
-
1177
- ```bash
1178
- npx securenow firewall status
1179
- npx securenow firewall test-ip 185.220.101.1
1180
- ```
1181
-
1182
- See the [Firewall Guide](FIREWALL-GUIDE.md) for the full reference.
1183
-
1184
- ---
1185
-
1186
- ## Step 8 — Monitor, Detect & Respond
1187
-
1188
- ### Daily Monitoring
1189
-
1190
- ```bash
1191
- # Quick overview of all your apps
1192
- npx securenow status
1193
-
1194
- # Check for unread alerts
1195
- npx securenow notifications unread
1196
-
1197
- # List open security issues
1198
- npx securenow issues --status open
1199
- ```
1200
-
1201
- ### Respond to an Issue
1202
-
1203
- ```bash
1204
- # Read the full issue detail (includes AI analysis)
1205
- npx securenow issues show <id>
1206
-
1207
- # If it's resolved, mark it
1208
- npx securenow issues resolve <id>
1209
- ```
1210
-
1211
- ### AI Trace Analysis
1212
-
1213
- Let SecureNow's AI analyze a suspicious trace for security issues:
1214
-
1215
- ```bash
1216
- npx securenow traces analyze <traceId>
1217
- ```
1218
-
1219
- Returns a summary, risk level, specific security issues found, and recommended actions.
1220
-
1221
- ### Set Up Alerts
1222
-
1223
- Configure alert rules and channels from the [dashboard](https://app.securenow.ai/dashboard), then monitor from the CLI:
1224
-
1225
- ```bash
1226
- # List your alert rules
1227
- npx securenow alerts rules
1228
-
1229
- # Show one rule / set application scope (all apps vs explicit keys)
1230
- npx securenow alerts rules show <rule-id>
1231
- npx securenow alerts rules update <rule-id> --applications-all
1232
- npx securenow alerts rules update <rule-id> --apps key1,key2
1233
-
1234
- # List alert channels (email, Slack, webhook)
1235
- npx securenow alerts channels
1236
-
1237
- # View alert history
1238
- npx securenow alerts history --limit 20
1239
- ```
1240
-
1241
- ---
1242
-
1243
- ## Deployment
1244
-
1245
- ### PM2 Setup (All Frameworks)
1246
-
1247
- ```javascript
1248
- // ecosystem.config.cjs
1249
- module.exports = {
1250
- apps: [{
1251
- name: 'my-app',
1252
- script: './app.js',
1253
- node_args: '-r securenow/register',
1254
- env: {
1255
- SECURENOW_APPID: 'my-app',
1256
- SECURENOW_INSTANCE: 'https://freetrial.securenow.ai:4318',
1257
- SECURENOW_LOGGING_ENABLED: '1',
1258
- SECURENOW_NO_UUID: '1',
1259
- SECURENOW_CAPTURE_BODY: '1',
1260
- PORT: 3000,
1261
- }
1262
- }]
1263
- };
1264
- ```
1265
-
1266
- ```bash
1267
- pm2 start ecosystem.config.cjs
1268
- ```
1269
-
1270
- **NestJS (TypeScript):**
1271
-
1272
- ```javascript
1273
- {
1274
- name: 'my-nestjs-app',
1275
- script: 'dist/main.js',
1276
- node_args: '-r ./instrument.js',
1277
- env: { /* same as above */ }
1278
- }
1279
- ```
1280
-
1281
- **Hono (ESM `.mjs`):**
1282
-
1283
- ```javascript
1284
- {
1285
- name: 'my-hono-app',
1286
- script: 'app.mjs',
1287
- node_args: '-r securenow/register',
1288
- env: {
1289
- SECURENOW_CAPTURE_BODY: '1',
1290
- SECURENOW_CAPTURE_MULTIPART: '1',
1291
- /* ... other vars ... */
1292
- }
1293
- }
1294
- ```
1295
-
1296
- ### Docker
1297
-
1298
- ```dockerfile
1299
- FROM node:20-alpine
1300
- WORKDIR /app
1301
- COPY package*.json ./
1302
- RUN npm install
1303
- COPY . .
1304
-
1305
- ENV SECURENOW_APPID=my-app
1306
- ENV SECURENOW_INSTANCE=https://collector:4318
1307
- ENV SECURENOW_LOGGING_ENABLED=1
1308
- ENV SECURENOW_NO_UUID=1
1309
-
1310
- EXPOSE 3000
1311
- CMD ["node", "-r", "securenow/register", "app.js"]
1312
- ```
1313
-
1314
- ---
1315
-
1316
- ## Compatibility Matrix
1317
-
1318
- | Framework | Traces | Logs | Body Capture | Init Method | Notes |
1319
- |-----------|--------|------|--------------|-------------|-------|
1320
- | Express | Yes | Yes | Yes | `require()` or `-r` | Fully compatible |
1321
- | Fastify | Yes | Yes | Yes | `require()` or `-r` | Default on; set `SECURENOW_CAPTURE_BODY=0` only for a local stream conflict |
1322
- | Koa | Yes | Yes | Yes | `require()` or `-r` | Needs `koa-bodyparser` |
1323
- | NestJS | Yes | Yes | Yes | `instrument.js` + `-r ./instrument.js` | Create `instrument.js` with `require('securenow/register')` |
1324
- | Hapi | Yes | Yes | Yes | `require()` or `-r` | Default on; set `SECURENOW_CAPTURE_BODY=0` only for a local stream conflict |
1325
- | h3 | Yes | Yes | Yes | `require()` or `-r` | Uses `toNodeListener()` |
1326
- | Polka | Yes | Yes | Yes | `require()` or `-r` | Needs manual body parser |
1327
- | Micro/HTTP | Yes | Yes | Yes | `require()` or `-r` | Raw `http.createServer` |
1328
- | Hono | Yes | Yes | Yes | `-r` flag only (ESM) | Default on; set `SECURENOW_CAPTURE_BODY=0` only for a local stream conflict |
1329
- | Feathers | Yes | Yes | Yes | `require()` or `-r` | Express transport |
1330
- | Next.js | Yes | Yes | Yes | `instrumentation.ts` | Use `securenow init` |
1331
-
1332
- ---
1333
-
1334
- ## Troubleshooting
1335
-
1336
- ### Traces not appearing
1337
-
1338
- 1. Verify `SECURENOW_APPID` and `SECURENOW_INSTANCE` are set
1339
- 2. Set `SECURENOW_NO_UUID=1` so the dashboard matches your app key exactly
1340
- 3. Enable debug logging: `OTEL_LOG_LEVEL=debug node -r securenow/register app.js`
1341
-
1342
- ### Logs not appearing
1343
-
1344
- 1. Confirm `SECURENOW_LOGGING_ENABLED=1` is set
1345
- 2. Check that startup output shows `📋 Logging: ENABLED`
1346
- 3. Any `console.log` / `console.error` in your app automatically becomes an OTLP log record
1347
-
1348
- ### ESM apps (.mjs / "type": "module")
1349
-
1350
- Use `NODE_OPTIONS="-r securenow/register"` or `node -r securenow/register app.mjs`.
1351
- Do **not** add `require('securenow/register')` inside `.mjs` files.
1352
-
1353
- ### Body capture crashes / empty payloads
1354
-
1355
- Body capture is on by default. If a specific framework version or plugin stack reports request-stream conflicts, set `SECURENOW_CAPTURE_BODY=0` as a local override for that app.
1356
-
1357
- ### CLI says "Not logged in"
1358
-
1359
- ```bash
1360
- npx securenow login
1361
- ```
1362
-
1363
- Or re-authenticate with a token:
1364
-
1365
- ```bash
1366
- npx securenow login --token <YOUR_TOKEN>
1367
- ```
1368
-
1369
- Or set the env var directly:
1370
-
1371
- ```bash
1372
- SECURENOW_TOKEN=<YOUR_JWT> npx securenow whoami
1373
- ```
1374
-
1375
- ### CLI says "Session expired"
1376
-
1377
- Tokens expire after a set period. Re-run `securenow login` to get a fresh session. Use `securenow whoami` to check which credential source is active.
1378
-
1379
- ---
1380
-
1381
- ## Complete Documentation
1382
-
1383
- - [Express Guide](./EXPRESS-SETUP-GUIDE.md)
1384
- - [Next.js Guide](./NEXTJS-SETUP-COMPLETE.md)
1385
- - [Logging Guide](./LOGGING-GUIDE.md)
1386
- - [Environment Variables](./ENVIRONMENT-VARIABLES.md)
1387
- - [Body Capture](./REQUEST-BODY-CAPTURE.md)
1388
- - [NPM README](../NPM_README.md)