securenow 7.5.0 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CONSUMING-APPS-GUIDE.md +2 -0
  2. package/NPM_README.md +201 -237
  3. package/README.md +73 -26
  4. package/SKILL-API.md +209 -205
  5. package/SKILL-CLI.md +71 -64
  6. package/app-config.js +479 -83
  7. package/cli/apiKey.js +1 -1
  8. package/cli/apps.js +1 -1
  9. package/cli/config.js +31 -12
  10. package/cli/credentials.js +88 -0
  11. package/cli/diagnostics.js +81 -98
  12. package/cli/firewall.js +29 -14
  13. package/cli/init.js +246 -201
  14. package/cli/monitor.js +107 -43
  15. package/cli/security.js +24 -12
  16. package/cli/ui.js +22 -12
  17. package/cli/utils.js +2 -1
  18. package/cli.js +71 -39
  19. package/console-instrumentation.js +1 -1
  20. package/docs/ENVIRONMENT-VARIABLES.md +137 -863
  21. package/docs/ENVIRONMENTS.md +60 -0
  22. package/docs/EXPRESS-SETUP-GUIDE.md +3 -0
  23. package/docs/FIREWALL-GUIDE.md +3 -0
  24. package/docs/INDEX.md +6 -8
  25. package/docs/LOGGING-GUIDE.md +3 -0
  26. package/docs/MCP-GUIDE.md +8 -0
  27. package/docs/NEXTJS-GUIDE.md +3 -0
  28. package/docs/NEXTJS-QUICKSTART.md +24 -16
  29. package/docs/NUXT-GUIDE.md +3 -0
  30. package/docs/QUICKSTART-BODY-CAPTURE.md +3 -0
  31. package/docs/REQUEST-BODY-CAPTURE.md +3 -0
  32. package/firewall-cloud.js +10 -10
  33. package/firewall-only.js +25 -23
  34. package/firewall.js +47 -29
  35. package/free-trial-banner.js +1 -1
  36. package/mcp/catalog.js +104 -17
  37. package/nextjs-auto-capture.d.ts +7 -4
  38. package/nextjs-auto-capture.js +7 -7
  39. package/nextjs-middleware.js +4 -3
  40. package/nextjs-wrapper.js +6 -6
  41. package/nextjs.d.ts +36 -25
  42. package/nextjs.js +47 -55
  43. package/nuxt-server-plugin.mjs +35 -51
  44. package/nuxt.d.ts +29 -23
  45. package/package.json +1 -1
  46. package/postinstall.js +27 -61
  47. package/register.d.ts +19 -33
  48. package/register.js +8 -8
  49. package/resolve-ip.js +4 -5
  50. package/tracing.d.ts +21 -19
  51. package/tracing.js +34 -42
package/SKILL-CLI.md CHANGED
@@ -9,22 +9,22 @@ Use the `securenow` CLI to perform security DevOps from the terminal: manage app
9
9
  npm install -g securenow
10
10
 
11
11
  # Or install per-project and use via npx
12
- npm install securenow
12
+ npm install securenow@latest
13
13
  npx securenow <command>
14
14
  ```
15
15
 
16
- **Full parity with the SDK:** every capability the `securenow` Node SDK exposes has a CLI counterpart — redaction, CIDR matching, log/span emission, firewall preload, config inspection. If you can do it in code, you can do it from the terminal.
17
-
18
- **MCP parity (v7.5+):** the same package also ships a local stdio MCP server for Codex, Claude, and other MCP clients:
19
-
20
- ```bash
21
- npx securenow login
22
- codex mcp add securenow -- npx securenow mcp
23
- # or
24
- npx -p securenow securenow-mcp
25
- ```
26
-
27
- The MCP server reuses `.securenow/credentials.json` and exposes apps, traces, logs, firewall, IP intelligence, forensics, notifications, remediation tools, bundled docs resources, and setup prompts. Write tools require `confirm:true` plus a reason.
16
+ **Full parity with the SDK:** every capability the `securenow` Node SDK exposes has a CLI counterpart — redaction, CIDR matching, log/span emission, firewall preload, config inspection. If you can do it in code, you can do it from the terminal.
17
+
18
+ **MCP parity (v7.5+):** the same package also ships a local stdio MCP server for Codex, Claude, and other MCP clients:
19
+
20
+ ```bash
21
+ npx securenow login
22
+ codex mcp add securenow -- npx securenow mcp
23
+ # or
24
+ npx -p securenow securenow-mcp
25
+ ```
26
+
27
+ The MCP server reuses `.securenow/credentials.json` and exposes apps, traces, logs, firewall, IP intelligence, forensics, notifications, remediation tools, bundled docs resources, and setup prompts. Write tools require `confirm:true` plus a reason.
28
28
 
29
29
  ### Authenticate
30
30
 
@@ -35,15 +35,17 @@ securenow login --token <JWT> # headless / CI login (get token from dashboard
35
35
  securenow whoami # verify session (shows email, app, auth source)
36
36
  ```
37
37
 
38
- **Zero-config flow (v7+):** the browser step lets the user pick (or create) an app. The CLI stores the app's **key (UUID)**, **name**, and **instance URL** in `.securenow/credentials.json`. The SDK reads this file at boot and sends traces/logs to the right app bucket — **no env vars required for local dev**.
39
-
40
- **Default-on security (v7.4+):** after picking or creating the app, `securenow login` turns on that app's firewall toggle, mints an API key with `firewall:read + blocklist:read + allowlist:read` scopes, and writes it into `.securenow/credentials.json`. Traces, logs, POST body capture, multipart metadata capture, and the firewall are enabled by default. No `SECURENOW_API_KEY` env var is needed. To add or rotate a key later without re-running login, use `securenow api-key set snk_live_...` (see [API Key Management](#api-key-management) below).
38
+ **Zero-config flow (v7+):** the browser step lets the user pick (or create) an app. The CLI stores the app's **key (UUID)**, **name**, and **instance URL** in `.securenow/credentials.json`. The SDK reads this file at boot and sends traces/logs to the right app bucket — **no env vars required for local dev or production**.
41
39
 
42
- Credentials resolve in order: `SECURENOW_TOKEN` env var project `.securenow/credentials.json` global `~/.securenow/credentials.json`.
40
+ **Default-on security (v7.5.1+):** after picking or creating the app, `securenow login` turns on that app's firewall toggle, mints an API key with `firewall:read + blocklist:read + allowlist:read` scopes, and writes it into `.securenow/credentials.json`. Traces, logs, POST body capture, multipart metadata capture, and the firewall are enabled by default. No `SECURENOW_API_KEY` env var is needed. To add or rotate a key later without re-running login, use `securenow api-key set snk_live_...` (see [API Key Management](#api-key-management) below).
43
41
 
44
- The **firewall API key** resolves in a slightly different order: `SECURENOW_API_KEY` env var (only if it starts with `snk_live_`) → project `.securenow/credentials.json` global `~/.securenow/credentials.json`. An env var that isn't the `snk_live_` format is ignored, so the file can still win.
42
+ Credentials resolve in order: project `.securenow/credentials.json` -> global `~/.securenow/credentials.json`. Legacy env vars are fallback-only for existing deployments.
45
43
 
46
- For CI / Docker / production, set env vars directly (always win over the file): `SECURENOW_APPID=<uuid>`, `SECURENOW_INSTANCE=<url>`, `SECURENOW_API_KEY=snk_live_<...>`.
44
+ The **firewall API key** should live in the same credentials file as `apiKey`. Legacy `SECURENOW_API_KEY` overrides are honored only when they start with `snk_live_`.
45
+
46
+ For CI / Docker / production, use `securenow credentials runtime --env production` to generate a tokenless runtime file, then mount/copy it as `.securenow/credentials.json`.
47
+
48
+ **Environment model:** use one SecureNow app key for local, preview, staging, and production. The credentials field `config.runtime.deploymentEnvironment` separates traces/logs/firewall/forensics by environment. CLI security commands default to `production`; pass `--env local`, `--env staging`, or `--env all` only when that scope is intentional.
47
49
 
48
50
  ### Integrate With Your App
49
51
 
@@ -60,10 +62,11 @@ node -r securenow/register src/index.js
60
62
  For Next.js, run the interactive scaffolding:
61
63
 
62
64
  ```bash
63
- securenow init --key snk_live_...
65
+ securenow login
66
+ securenow init
64
67
  ```
65
68
 
66
- This auto-detects your framework and creates the necessary `instrumentation.ts`, `next.config.js` changes, and writes your API key to `.env.local`.
69
+ This auto-detects your framework, creates the necessary `instrumentation.ts` and `next.config.js` changes, and reuses the app, instance, and firewall key written by login to `.securenow/credentials.json`.
67
70
 
68
71
  ### Install This Skill in Cursor
69
72
 
@@ -76,12 +79,12 @@ Config lives in `~/.securenow/` (global) and optionally `.securenow/` (per-proje
76
79
  | File | Content |
77
80
  |------|---------|
78
81
  | `~/.securenow/config.json` | `apiUrl`, `appUrl`, `defaultApp`, `output` |
79
- | `~/.securenow/credentials.json` | `token`, `email`, `expiresAt` (global) |
80
- | `.securenow/credentials.json` | `token`, `email`, `expiresAt` (project-local, use `login --local`) |
82
+ | `~/.securenow/credentials.json` | `token`, `email`, `expiresAt`, `apiKey`, `app`, `config` (global, use `login --global`) |
83
+ | `.securenow/credentials.json` | `token`, `email`, `expiresAt`, `apiKey`, `app`, `config`, `_securenow.explanations` (project-local default) |
81
84
 
82
- **Credential resolution order:** `SECURENOW_TOKEN` env var → `.securenow/credentials.json` (project) `~/.securenow/credentials.json` (global).
85
+ **Credential resolution order:** `.securenow/credentials.json` (project) -> `~/.securenow/credentials.json` (global). Legacy env vars are fallback-only for existing deployments.
83
86
 
84
- **Firewall API key resolution (v7.1+):** `SECURENOW_API_KEY` env var (only honored if it starts with `snk_live_`) → project `.securenow/credentials.json` global `~/.securenow/credentials.json`. Use `securenow api-key set` to write the key to the credentials file without touching env vars.
87
+ **Firewall API key resolution (v7.5.1+):** project `.securenow/credentials.json` -> global `~/.securenow/credentials.json`. Use `securenow login` for default setup or `securenow api-key set` to rotate a key without touching env vars.
85
88
 
86
89
  ```bash
87
90
  securenow config set apiUrl https://api.securenow.ai
@@ -91,7 +94,7 @@ securenow config get defaultApp # show one
91
94
  securenow config path # print file paths + active auth source
92
95
  ```
93
96
 
94
- Environment overrides: `SECURENOW_TOKEN` (JWT), `SECURENOW_API_URL`, `SECURENOW_APP_URL`, `SECURENOW_APP` (default app key).
97
+ Legacy CLI overrides still exist for existing automation (`SECURENOW_TOKEN`, `SECURENOW_API_URL`, `SECURENOW_APP_URL`, `SECURENOW_APP`), but file credentials are the default path.
95
98
 
96
99
  ## Global Flags
97
100
 
@@ -124,13 +127,13 @@ Spawns `node --require securenow/register [--import otel/hook.mjs] <script>`. ES
124
127
  ### Authentication
125
128
 
126
129
  ```bash
127
- securenow login # browser-based OAuth (stores in global ~/.securenow/)
128
- securenow login --token <JWT> # headless / CI login
129
- securenow login --local # save credentials to project .securenow/ (per-project session)
130
- securenow logout # clear active credentials (local if present, else global)
131
- securenow logout --local # clear project-local credentials only
132
- securenow whoami # show email, user ID, API URL, auth source, expiry, default app
133
- ```
130
+ securenow login # browser-based OAuth (stores in project ./.securenow/)
131
+ securenow login --token <JWT> # headless / CI login
132
+ securenow login --global # save credentials to ~/.securenow/ instead
133
+ securenow logout # clear active credentials (local if present, else global)
134
+ securenow logout --global # clear global credentials only
135
+ securenow whoami # show email, user ID, API URL, auth source, expiry, default app
136
+ ```
134
137
 
135
138
  ### Applications
136
139
 
@@ -147,14 +150,15 @@ securenow apps scan [--yes] # scan all app domains for new subd
147
150
 
148
151
  ### API Key Management
149
152
 
150
- Manage the firewall API key stored in the credentials file. Since v7.1.0 the firewall reads `snk_live_...` keys from `.securenow/credentials.json` so no env var is required.
153
+ Manage the firewall API key stored in the credentials file. Since v7.5.1 the login flow writes `snk_live_...` keys to `.securenow/credentials.json` by default, so no env var is required for local dev.
151
154
 
152
155
  ```bash
153
156
  securenow api-key set snk_live_xxxxxxxxxx # save to project ./.securenow/ (default)
154
157
  securenow api-key set snk_live_xxx --global # save to ~/.securenow/ instead
155
- securenow api-key show # print the masked current key + its source
156
- securenow api-key clear # remove just the API key (keeps session/app)
157
- securenow api-key clear --global # same, but from the global file
158
+ securenow api-key show # print the masked current key + its source
159
+ securenow api-key clear # remove just the API key (keeps session/app)
160
+ securenow api-key clear --global # same, but from the global file
161
+ securenow credentials runtime --env production # write .securenow/credentials.production.json for production secret-file deploys
158
162
  ```
159
163
 
160
164
  The key must start with `snk_live_`. `securenow login` with firewall enabled writes the key automatically; use `api-key set` when you already have a key from the dashboard, or to rotate it later.
@@ -162,19 +166,21 @@ The key must start with `snk_live_`. `securenow login` with firewall enabled wri
162
166
  ### Init — Project Setup
163
167
 
164
168
  ```bash
165
- securenow init [--key <API_KEY>]
169
+ securenow init [--env local] [--key <API_KEY>]
166
170
  ```
167
171
 
168
- Auto-detects framework (Next.js, Nuxt, Express, Fastify, Koa, Hapi, Node) from `package.json`. Then:
169
- - **Next.js**: creates `instrumentation.ts/js`, suggests `withSecureNow()` in `next.config`
170
- - **Nuxt**: tells you to add `securenow/nuxt` to modules
171
- - **Node/Express/etc.**: suggests adding `-r securenow/register` to start script
172
- - Writes `SECURENOW_API_KEY` to `.env.local` or `.env` if `--key` provided
172
+ Auto-detects framework (Next.js, Nuxt, Express, Fastify, Koa, Hapi, Node) from `package.json`. Then:
173
+ - **Credentials**: ensures `.securenow/credentials.json` exists, has secure defaults/explanations, and `.securenow/` is gitignored
174
+ - **Next.js**: creates `instrumentation.ts/js` with `securenow/nextjs` + `securenow/nextjs-auto-capture`, and adds `serverExternalPackages: ['securenow']` when the config can be patched safely
175
+ - **Existing Next.js files**: prints a Codex/Claude-ready merge prompt when instrumentation or config already exists or is too custom to safely patch
176
+ - **Nuxt**: tells you to add `securenow/nuxt` to modules
177
+ - **Node/Express/etc.**: suggests adding `-r securenow/register` to start script
178
+ - Reuses `.securenow/credentials.json` written by login; production should mount/copy the tokenless runtime file generated by `securenow credentials runtime --env production`
173
179
 
174
180
  ### Dashboard & Status
175
181
 
176
182
  ```bash
177
- securenow status [--app <key>] # dashboard overview
183
+ securenow status [--app <key>] [--env local|production|all] # dashboard overview
178
184
  securenow analytics [--app <key>] # response analytics
179
185
  ```
180
186
 
@@ -183,18 +189,18 @@ securenow analytics [--app <key>] # response analytics
183
189
  ### Traces
184
190
 
185
191
  ```bash
186
- securenow traces [--app <key>] [--limit N] [--start ISO] [--end ISO]
187
- securenow traces list --app my-app --limit 50
188
- securenow traces show <traceId> # full trace detail with spans
189
- securenow traces analyze <traceId> # AI-powered trace analysis
192
+ securenow traces [--app <key>] [--env production] [--limit N] [--start ISO] [--end ISO]
193
+ securenow traces list --app my-app --env production --limit 50
194
+ securenow traces show <traceId> --env production # full trace detail with spans
195
+ securenow traces analyze <traceId> --env production # AI-powered trace analysis
190
196
  ```
191
197
 
192
198
  ### Logs
193
199
 
194
200
  ```bash
195
- securenow logs [--app <key>] [--limit N] [--minutes M] [--level error|warn|info]
196
- securenow logs list --app my-app --minutes 30 --level error
197
- securenow logs trace <traceId> # logs correlated to a specific trace
201
+ securenow logs [--app <key>] [--env production] [--limit N] [--minutes M] [--level error|warn|info]
202
+ securenow logs list --app my-app --env production --minutes 30 --level error
203
+ securenow logs trace <traceId> --env production # logs correlated to a specific trace
198
204
  ```
199
205
 
200
206
  ### Notifications
@@ -226,15 +232,15 @@ securenow alerts history [--limit N] # past triggered alerts
226
232
  ```bash
227
233
  securenow ip <ip-address> # lookup (geo, ASN, threat score, reputation)
228
234
  securenow ip lookup <ip-address> # same as above
229
- securenow ip traces <ip-address> # traces originating from this IP
235
+ securenow ip traces <ip-address> --env production # traces originating from this IP
230
236
  ```
231
237
 
232
238
  ### Forensics — Natural Language Security Queries
233
239
 
234
240
  ```bash
235
- securenow forensics "show me all SQL injection attempts in the last 24h"
236
- securenow forensics query "top 10 IPs by blocked requests" --app my-app
237
- securenow forensics chat --app my-app # interactive forensics chat session
241
+ securenow forensics "show me all SQL injection attempts in the last 24h" --env production
242
+ securenow forensics query "top 10 IPs by blocked requests" --app my-app --env production
243
+ securenow forensics chat --app my-app --env production # interactive forensics chat session
238
244
  securenow forensics library # view saved/template queries
239
245
  ```
240
246
 
@@ -252,11 +258,11 @@ securenow api-map stats # endpoint statistics
252
258
 
253
259
  ```bash
254
260
  securenow firewall # show status (default)
255
- securenow firewall status # layers, sync time, blocked count, API key info
261
+ securenow firewall status --env production # layers, sync time, blocked count, API key info
256
262
  securenow firewall test-ip <ip> # check if IP would be blocked
257
263
  ```
258
264
 
259
- **Zero-config setup (v7.4+):** running `securenow login` enables the selected app's firewall toggle, auto-mints an API key (scoped `firewall:read + blocklist:read + allowlist:read`), and writes it to the credentials file after the app is selected. No `SECURENOW_API_KEY` env var needed. If the user already has a key, `securenow api-key set snk_live_...` achieves the same thing. See [the landing firewall page](https://securenow.ai/firewall) for an overview.
265
+ **Zero-config setup (v7.5.1+):** running `securenow login` enables the selected app's firewall toggle, auto-mints an API key (scoped `firewall:read + blocklist:read + allowlist:read`), and writes it to the credentials file after the app is selected. No `SECURENOW_API_KEY` env var needed. If the user already has a key, `securenow api-key set snk_live_...` achieves the same thing. See [the landing firewall page](https://securenow.ai/firewall) for an overview.
260
266
 
261
267
  ### Blocklist — Block Malicious IPs
262
268
 
@@ -375,7 +381,7 @@ securenow test-span
375
381
  securenow test-span "ci.smoke-test" # custom span name
376
382
  ```
377
383
 
378
- Both commands use the resolved `SECURENOW_INSTANCE` / `OTEL_EXPORTER_OTLP_*` endpoints. Honors `OTEL_EXPORTER_OTLP_HEADERS` for API-key auth. Returns non-zero on HTTP errors so CI/cron can detect failures.
384
+ Both commands use the resolved collector settings from `.securenow/credentials.json` (`app.instance`, `config.otel.*`) and return non-zero on HTTP errors so CI/cron can detect failures.
379
385
 
380
386
  ### Utilities — Redaction, CIDR, Diagnostics
381
387
 
@@ -390,7 +396,7 @@ securenow redact @request.json --fields internal_id,sessionHash
390
396
  securenow cidr match 10.0.0.5 10.0.0.0/24,192.168.0.0/16
391
397
  securenow cidr parse 10.0.0.0/24 # network, broadcast, mask, size
392
398
 
393
- # Show resolved config (service name, endpoints, env vars, firewall layers)
399
+ # Show resolved config (service name, endpoints, credentials, firewall layers)
394
400
  securenow env # human-readable
395
401
  securenow env --json # pipe to jq
396
402
 
@@ -448,7 +454,8 @@ securenow fp mark <notification-id> <ip> --rule-scope this_rule --reason "Known
448
454
  ```bash
449
455
  securenow apps create my-new-app --hosts api.example.com,app.example.com
450
456
  securenow apps default my-new-app
451
- securenow init --key snk_live_abc123...
457
+ securenow login
458
+ securenow init
452
459
  securenow run src/index.js
453
460
  securenow status --json
454
461
  ```
@@ -482,10 +489,10 @@ All commands support `--json` for structured output. When piping to other tools
482
489
 
483
490
  | Exit code / Error | Meaning | Recovery |
484
491
  |------------------|---------|----------|
485
- | `Session expired` | JWT expired | `securenow login` (or `login --local`) |
486
- | `Not logged in` | No token found | `securenow login` or set `SECURENOW_TOKEN` env var |
487
- | `Access denied (403)` | Insufficient plan or permissions | Upgrade plan or check user role |
488
- | `Cannot connect` | API unreachable | Check `SECURENOW_API_URL` or network |
492
+ | `Session expired` | JWT expired | `securenow login` (or `login --global` for shared credentials) |
493
+ | `Not logged in` | No token found | `securenow login` or mount/copy the right `.securenow/credentials.json` |
494
+ | `Access denied (403)` | Insufficient plan or permissions | Upgrade plan or check user role |
495
+ | `Cannot connect` | API unreachable | Check `securenow config get apiUrl` or network |
489
496
  | `Unknown command` | Typo or unrecognized command | `securenow help` |
490
497
 
491
498
  Set `SECURENOW_DEBUG=1` for full stack traces on any error.