securenow 7.5.1 → 7.6.1

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 (50) 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 +205 -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 +68 -104
  12. package/cli/firewall.js +29 -14
  13. package/cli/init.js +211 -212
  14. package/cli/monitor.js +107 -43
  15. package/cli/security.js +24 -12
  16. package/cli/utils.js +2 -1
  17. package/cli.js +72 -40
  18. package/console-instrumentation.js +1 -1
  19. package/docs/ENVIRONMENT-VARIABLES.md +137 -863
  20. package/docs/ENVIRONMENTS.md +60 -0
  21. package/docs/EXPRESS-SETUP-GUIDE.md +3 -0
  22. package/docs/FIREWALL-GUIDE.md +3 -0
  23. package/docs/INDEX.md +6 -8
  24. package/docs/LOGGING-GUIDE.md +3 -0
  25. package/docs/MCP-GUIDE.md +8 -0
  26. package/docs/NEXTJS-GUIDE.md +3 -0
  27. package/docs/NEXTJS-QUICKSTART.md +22 -16
  28. package/docs/NUXT-GUIDE.md +3 -0
  29. package/docs/QUICKSTART-BODY-CAPTURE.md +3 -0
  30. package/docs/REQUEST-BODY-CAPTURE.md +3 -0
  31. package/firewall-cloud.js +10 -10
  32. package/firewall-only.js +25 -23
  33. package/firewall.js +47 -29
  34. package/free-trial-banner.js +1 -1
  35. package/mcp/catalog.js +104 -17
  36. package/nextjs-auto-capture.d.ts +7 -4
  37. package/nextjs-auto-capture.js +7 -7
  38. package/nextjs-middleware.js +4 -3
  39. package/nextjs-wrapper.js +6 -6
  40. package/nextjs.d.ts +36 -25
  41. package/nextjs.js +48 -55
  42. package/nuxt-server-plugin.mjs +35 -51
  43. package/nuxt.d.ts +29 -23
  44. package/package.json +1 -1
  45. package/postinstall.js +27 -61
  46. package/register.d.ts +19 -33
  47. package/register.js +8 -8
  48. package/resolve-ip.js +4 -5
  49. package/tracing.d.ts +21 -19
  50. package/tracing.js +34 -42
package/README.md CHANGED
@@ -41,15 +41,22 @@ That's it. No `.env` edits, no API keys to paste, no peer-dep warnings. Your tra
41
41
  {
42
42
  "token": "...",
43
43
  "email": "you@example.com",
44
+ "apiKey": "snk_live_...",
44
45
  "app": {
45
46
  "key": "<uuid>",
46
47
  "name": "my-backend",
47
48
  "instance": "https://freetrial.securenow.ai:4318"
49
+ },
50
+ "config": {
51
+ "runtime": { "deploymentEnvironment": "local" },
52
+ "logging": { "enabled": true },
53
+ "capture": { "body": true, "multipart": true, "maxBodySize": 10240 },
54
+ "firewall": { "enabled": true, "failMode": "open" }
48
55
  }
49
56
  }
50
57
  ```
51
58
 
52
- The SDK reads this file at boot and sends traces/logs directly to the right app bucket. The file is auto-added to `.gitignore` so it never lands in git.
59
+ The SDK reads this file at boot and sends traces/logs directly to the right app bucket. `npx securenow init` also fills the config block with secure defaults plus an `_securenow.explanations` section so users can see what every setting does. The file is auto-added to `.gitignore` so it never lands in git.
53
60
 
54
61
  ---
55
62
 
@@ -77,16 +84,31 @@ npx securenow init
77
84
 
78
85
  Creates `instrumentation.ts` and shows you how to wrap `next.config.js`:
79
86
 
87
+ ```typescript
88
+ // instrumentation.ts
89
+ import { createRequire } from 'node:module';
90
+
91
+ const require = createRequire(import.meta.url);
92
+
93
+ export async function register() {
94
+ if (process.env.NEXT_RUNTIME !== 'nodejs') return;
95
+ const { registerSecureNow } = require('securenow/nextjs');
96
+ registerSecureNow({ captureBody: true });
97
+ require('securenow/nextjs-auto-capture');
98
+ }
99
+ ```
100
+
101
+ For Next.js 15+, `init` adds `securenow` to `serverExternalPackages` when it can safely edit the file:
102
+
80
103
  ```javascript
81
- // next.config.js
82
- const { withSecureNow } = require('securenow/nextjs-webpack-config');
104
+ const nextConfig = {
105
+ serverExternalPackages: ['securenow'],
106
+ };
83
107
 
84
- module.exports = withSecureNow({
85
- // your existing config
86
- });
108
+ export default nextConfig;
87
109
  ```
88
110
 
89
- `withSecureNow()` auto-detects Next.js 14 vs 15 vs 16. See [Next.js Complete Guide](./docs/NEXTJS-GUIDE.md).
111
+ If a custom config or existing instrumentation file needs human judgment, `init` prints a Codex/Claude-ready prompt with the exact edits to merge. See [Next.js Complete Guide](./docs/NEXTJS-GUIDE.md).
90
112
 
91
113
  ### Nuxt 3
92
114
 
@@ -110,26 +132,33 @@ See [Nuxt 3 Guide](./docs/NUXT-GUIDE.md).
110
132
  - ✅ Multipart upload metadata (field names, file names, sizes, content-types — never file content)
111
133
  - ✅ Firewall (500k+ known-bad IPs, refreshed hourly) — activates as soon as you've logged in
112
134
 
113
- All of these are **on by default**. Each can be disabled individually with an env var if needed (e.g. `SECURENOW_CAPTURE_BODY=0`).
135
+ All of these are **on by default**. Tune them in `.securenow/credentials.json` under the `config` block.
114
136
 
115
137
  ---
116
138
 
117
- ## Overriding via environment variables (CI, Docker, prod)
139
+ ## Production Without Env Vars
118
140
 
119
- `.securenow/credentials.json` is the zero-config path for local dev. For CI, containers, or prod servers where you can't run `npx securenow login`, set env vars they always take precedence:
141
+ Production uses the same file structure. Do not commit `.securenow/`; instead deploy a tokenless runtime credentials file as a secret file and mount/copy it to:
142
+
143
+ ```text
144
+ <app-root>/.securenow/credentials.json
145
+ ```
146
+
147
+ Create that runtime file from a logged-in project:
120
148
 
121
149
  ```bash
122
- SECURENOW_APPID=<app-key-uuid> # routing key (from dashboard or `npx securenow apps`)
123
- SECURENOW_INSTANCE=https://your-collector # defaults to freetrial
124
- SECURENOW_API_KEY=<same uuid> # enables the firewall
150
+ npx securenow credentials runtime --env production
125
151
  ```
126
152
 
127
- Resolution order (first non-empty wins):
153
+ It writes `.securenow/credentials.production.json`, with the same `app`, `apiKey`, `config`, and `_securenow.explanations` shape, but without the CLI OAuth `token`, `email`, or `expiresAt`. Store that JSON in your deployment secret manager and materialize it as `.securenow/credentials.json` at runtime.
154
+
155
+ Resolution order:
128
156
 
129
- 1. Environment variable
130
- 2. Project-local `.securenow/credentials.json`
131
- 3. Global `~/.securenow/credentials.json`
132
- 4. `package.json#name` (label only — won't route telemetry)
157
+ 1. Project-local `.securenow/credentials.json`
158
+ 2. Global `~/.securenow/credentials.json`
159
+ 3. `package.json#name` (label only)
160
+
161
+ Legacy environment variables are fallback-only for existing installs. New local, CI, Docker, and production setups should use the credentials file.
133
162
 
134
163
  ---
135
164
 
@@ -140,7 +169,8 @@ Resolution order (first non-empty wins):
140
169
  npx securenow login # browser auth + app picker + firewall enabled by default
141
170
  npx securenow login --global # save to ~/.securenow/ instead
142
171
  npx securenow login --token <TOKEN> # headless (CI)
143
- npx securenow init # scaffold Next.js instrumentation files
172
+ npx securenow init --env local # scaffold framework files + local env scope
173
+ npx securenow credentials runtime --env production # write tokenless production credentials file
144
174
  npx securenow api-key set snk_live_... # store firewall key in .securenow/credentials.json
145
175
 
146
176
  # Apps
@@ -155,7 +185,7 @@ npx securenow status # dashboard summary
155
185
  npx securenow doctor # diagnose config + connectivity
156
186
 
157
187
  # Security
158
- npx securenow firewall status
188
+ npx securenow firewall status --env production
159
189
  npx securenow blocklist add 1.2.3.4 --reason "scanner"
160
190
  npx securenow fp ai-fill --description "Stripe webhook POST /api/stripe/webhook"
161
191
 
@@ -183,15 +213,31 @@ The MCP server reuses the same project-local `.securenow/credentials.json` as th
183
213
 
184
214
  ---
185
215
 
186
- ## Environment variables (optional)
216
+ ## Credentials Config
217
+
218
+ Use `.securenow/credentials.json` fields for new local, CI, Docker, and production setups. The credentials file is the product path.
187
219
 
188
- Only set these if you want to override the zero-config defaults.
220
+ | Field | Default | Purpose |
221
+ |---|---|---|
222
+ | `app.key` | selected during login | App routing UUID, sent as OTel `service.name` |
223
+ | `app.instance` | `https://freetrial.securenow.ai:4318` | OTLP collector endpoint |
224
+ | `apiKey` | minted during login | Scoped firewall key (`snk_live_...`) |
225
+ | `config.runtime.deploymentEnvironment` | `local` from `init`, `production` from runtime credentials | Sent as OTel `deployment.environment` |
226
+ | `config.logging.enabled` | `true` | Forward `console.*` as OTLP logs |
227
+ | `config.capture.body` | `true` | Capture JSON / form request bodies with redaction |
228
+ | `config.capture.multipart` | `true` | Capture multipart metadata, never file content |
229
+ | `config.capture.maxBodySize` | `10240` | Max bytes captured per body |
230
+ | `config.capture.sensitiveFields` | `[]` | Extra field-name fragments to redact |
231
+ | `config.firewall.enabled` | `true` | Local SDK firewall switch; dashboard firewall toggle is scoped per environment |
232
+ | `config.otel.*` | empty | Optional custom OTLP endpoints, headers, and log level |
233
+
234
+ Legacy env fallback aliases:
189
235
 
190
236
  | Variable | Default | Purpose |
191
237
  |---|---|---|
192
238
  | `SECURENOW_APPID` | from credentials file | App routing key (UUID) — sent as OTel `service.name` |
193
239
  | `SECURENOW_INSTANCE` | `https://freetrial.securenow.ai:4318` | OTLP collector endpoint |
194
- | `SECURENOW_API_KEY` | from credentials file | Enables firewall + collector routing |
240
+ | `SECURENOW_API_KEY` | from credentials file | Scoped firewall API key (`snk_live_...`) |
195
241
  | `SECURENOW_LOGGING_ENABLED` | `1` (on) | Forward `console.*` as OTLP logs. Set to `0` to disable. |
196
242
  | `SECURENOW_CAPTURE_BODY` | `1` (on) | Capture JSON / form request bodies. Set to `0` only for a local stream conflict. |
197
243
  | `SECURENOW_CAPTURE_MULTIPART` | `1` (on) | Capture multipart metadata (not content). |
@@ -364,13 +410,14 @@ After install, the `securenow` CLI is available via `npx securenow` or globally
364
410
 
365
411
  | File | Purpose |
366
412
  |---|---|
367
- | `./.securenow/credentials.json` | Project-local token + app (default) |
413
+ | `./.securenow/credentials.json` | Project-local or production runtime credentials |
414
+ | `./.securenow/credentials.production.json` | Tokenless production file generated by `securenow credentials runtime --env production` |
368
415
  | `~/.securenow/credentials.json` | Global (with `login --global`) |
369
416
  | `~/.securenow/config.json` | API URL, default app, preferences |
370
417
 
371
- Resolution order: `SECURENOW_TOKEN` env → project `.securenow/` global `~/.securenow/`.
418
+ Resolution order: project `.securenow/` -> global `~/.securenow/` -> package name fallback. Legacy env vars are fallback-only for older installs.
372
419
 
373
- Override the API with `securenow config set apiUrl <url>` or `SECURENOW_API_URL`.
420
+ Override the dashboard API with `securenow config set apiUrl <url>`.
374
421
 
375
422
  ---
376
423