securenow 8.23.0 → 8.25.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.
package/README.md CHANGED
@@ -10,6 +10,8 @@ Your agent already sees the repository, the dependencies, the auth implementatio
10
10
 
11
11
  **Find it in code. Watch it in production.**
12
12
 
13
+ The full guides ship in this package: [`SKILL-API.md`](./SKILL-API.md) (wiring every framework, every setting and feature, deployment, verification, troubleshooting) and [`SKILL-CLI.md`](./SKILL-CLI.md) (every CLI command, by task).
14
+
13
15
  ---
14
16
 
15
17
  ## What it looks like
@@ -45,16 +47,21 @@ Paste this into Claude Code, Codex, or Cursor:
45
47
  Set up SecureNow (npm package "securenow") in this project:
46
48
 
47
49
  1. Install it: npm install securenow@latest
48
- 2. Run npx securenow login from the project root and wait while I complete
50
+ 2. Read node_modules/securenow/SKILL-API.md and follow it for this
51
+ project's framework and deployment.
52
+ 3. Run npx securenow login from the project root and wait while I complete
49
53
  the browser flow. It writes .securenow/runtime.json (SDK runtime config +
50
54
  runtime API key) and .securenow/admin.json (CLI/MCP auth).
51
- 3. Wire the runtime: run npx securenow init for Next.js or Nuxt; for plain
52
- Node servers (Express, Fastify, NestJS, Koa, Hapi) add
53
- -r securenow/register to the start script instead.
54
- 4. Make sure the .securenow/*.json credential files are gitignored without
55
+ 4. Run npx securenow init, then wire the runtime as SKILL-API.md says:
56
+ Next.js and Nuxt through init and the module; plain Node servers
57
+ (Express, Fastify, NestJS, Koa, Hapi, Hono, Polka, Feathers, h3) with
58
+ -r securenow/register on the command that starts the server, including
59
+ Docker CMD, PM2 node_args or systemd ExecStart.
60
+ 5. Make sure the .securenow/*.json credential files are gitignored without
55
61
  ignoring the whole .securenow/ directory. Never print their contents.
56
- 5. Verify: npx securenow whoami, npx securenow doctor,
57
- npx securenow test-span, then npx securenow status.
62
+ 6. Verify: npx securenow whoami, npx securenow doctor,
63
+ npx securenow test-span, start the app and check its [securenow] lines,
64
+ then npx securenow status.
58
65
 
59
66
  Do not block traffic or modify security policy without asking me first.
60
67
  ```
@@ -65,17 +72,20 @@ Do not block traffic or modify security policy without asking me first.
65
72
 
66
73
  ```bash
67
74
  # 1. Install
68
- npm install securenow
75
+ npm install securenow@latest
69
76
 
70
77
  # 2. Pick (or create) your app in the browser — writes .securenow/runtime.json
71
78
  # and refreshes CLI/MCP auth in .securenow/admin.json
72
79
  npx securenow login
73
80
 
74
- # 3. Start your app — one flag is all it takes
81
+ # 3. Fill the runtime config and detect the framework
82
+ npx securenow init
83
+
84
+ # 4. Start your app — one flag is all it takes
75
85
  node -r securenow/register src/index.js
76
86
  ```
77
87
 
78
- No `.env` edits, no API keys to paste. Runtime config lives in `.securenow/runtime.json`; it is never read from environment variables.
88
+ No `.env` edits, no API keys to paste. Runtime config lives in `.securenow/runtime.json`. The only environment variables the SDK reads are `SECURENOW_CREDENTIALS`, for hosts that cannot mount a file (see Production), and the `SECURENOW_DISABLED` test switch; any other `SECURENOW_*` variable is ignored.
79
89
 
80
90
  ```json
81
91
  "scripts": {
@@ -84,11 +94,15 @@ No `.env` edits, no API keys to paste. Runtime config lives in `.securenow/runti
84
94
  }
85
95
  ```
86
96
 
87
- Can't change the script? Use `NODE_OPTIONS="-r securenow/register" npm start`, or the wrapper: `npx securenow run src/index.js`.
97
+ The same flag works for CommonJS, ESM (`"type": "module"`, `.mjs`) and TypeScript (`node -r securenow/register --import tsx src/index.ts`). Can't change the script? Use `NODE_OPTIONS="-r securenow/register" npm start`, or the wrapper: `npx securenow run src/index.js`.
98
+
99
+ **Express, Fastify, NestJS, Koa, Hapi, Hono (`@hono/node-server`), Polka, Feathers, h3, raw `http`/`https`** — the preload above, no code changes.
100
+
101
+ **Next.js 15 and 16** — `npx securenow init` creates `instrumentation.ts` and patches `next.config.*` when it can do so safely (`serverExternalPackages: ['securenow']` plus `outputFileTracingIncludes` for standalone output). If your config needs human judgment, `init` prints an agent-ready prompt with the exact edits to merge. `next start` and `output: 'standalone'` (Docker) both work. If `init` wrote your instrumentation file before 8.24.0, run it again: it replaces that file, whose `webpackIgnore` imports left SecureNow's dependencies out of standalone builds. With a `src/` layout `init` writes `src/instrumentation.ts` (8.25.0+), where Next.js loads it. The Edge runtime is not instrumented.
88
102
 
89
- **Next.js** — `npx securenow init` creates `instrumentation.ts` and patches `next.config.*` when it can do so safely (adds `securenow` to `serverExternalPackages` on Next.js 15+). If your config needs human judgment, `init` prints an agent-ready prompt with the exact edits to merge.
103
+ **Next.js 14 (8.25.0+)** — `init` writes the `experimental` version of the config (`instrumentationHook`, `serverComponentsExternalPackages`, `outputFileTracingIncludes`), or prints the exact edits for an existing config. Tested on 14.2 (`next start` and standalone).
90
104
 
91
- **Nuxt 3** — add the module, then run `npx securenow init`:
105
+ **Nuxt 3 and 4** — add the module, then run `npx securenow init`. The `nuxt build` output is fully covered (tested on Nuxt 3.21 and 4.6, with `.output` running on its own like a Docker image), and `nuxt dev` is traced too. In `nuxt dev` the client IP is known from 8.25.0; before, it was unknown behind Nuxt's dev proxy, so IP blocking only applied to the built server.
92
106
 
93
107
  ```ts
94
108
  export default defineNuxtConfig({
@@ -96,24 +110,65 @@ export default defineNuxtConfig({
96
110
  });
97
111
  ```
98
112
 
99
- **What's captured automatically:** HTTP spans (Express, Fastify, NestJS, Koa, Hapi, Next.js, Nuxt, raw `http`), database spans (Postgres, MySQL, MongoDB, Redis), `console.*` as logs with trace correlation, crashes (uncaught exceptions and unhandled rejections) as `FATAL` logs with their stack, request bodies with auto-redaction, multipart metadata (never file content), plus the firewall. Tune everything in `.securenow/runtime.json` under `config`.
113
+ Settings come from `.securenow/runtime.json` like every other integration; `securenow: { ... }` options in `nuxt.config` are ignored.
114
+
115
+ **PM2** — in `ecosystem.config.cjs`, pass the preload as an absolute path: `node_args: ['-r', require.resolve('securenow/register')]`. That works in fork and cluster mode (`instances: 'max'`) wherever the PM2 daemon was started. (In cluster mode Node resolves a bare `-r securenow/register` from the daemon's folder, so after `pm2 resurrect` at boot the workers crash-loop with `Cannot find module 'securenow/register'`.) Each process reads the `.securenow/` folder of the app PM2 started.
116
+
117
+ **Vite** — browser telemetry is not sent to SecureNow. Instrument the Node process that serves the app: `node -r securenow/register-vite node_modules/vite/bin/vite.js preview`, or `-r securenow/register` for a Vite SSR server.
118
+
119
+ **Bun** — `bun --preload securenow/register app.js` works for apps served through `node:http` (tested with Express 5 on Bun 1.3). `Bun.serve` is not traced or protected. Deno and edge runtimes (Cloudflare Workers, Vercel Edge) are not supported: SecureNow runs inside a Node.js process.
100
120
 
101
- **Production** — same file structure, no env vars. Generate a tokenless runtime credentials file and mount it as a deployment secret:
121
+ **What's captured automatically:** HTTP spans with the client IP, database spans (Postgres, MySQL, MongoDB, Redis), outgoing HTTP, `console.*` as logs with trace correlation, crashes (uncaught exceptions and unhandled rejections) as `FATAL` logs with their stack, plus the spans that ended just before the crash, request headers and bodies with auto-redaction, multipart metadata (never file content), plus the firewall. `http.route` is recorded for Express, Fastify, NestJS, Koa with `@koa/router`, Hapi and Nuxt; from 8.25.0 also for Hono, h3, Feathers and Polka, and for Next.js 15 and 16 on the HTTP span (before 8.25.0 those four showed the raw path, Next.js 16 put the route on Next.js's own span and Next.js 15 recorded `next.route`). Tune everything in `.securenow/runtime.json` under `config`.
122
+
123
+ **Behind a proxy** — forwarding headers (`X-Forwarded-For`, `CF-Connecting-IP`...) count only when the connection comes from a trusted proxy: private and loopback addresses, the host itself, and from 8.25.0 Unix-socket and named-pipe connections (nginx `proxy_pass http://unix:...`). Add public load balancers or CDNs to `config.networking.trustedProxies` (IPv4/IPv6 addresses or ranges, or `"cloudflare"`).
124
+
125
+ **Production** — same file structure. Generate a tokenless runtime credentials file and mount it as a deployment secret (Docker, Kubernetes, VMs):
102
126
 
103
127
  ```bash
104
128
  npx securenow credentials runtime --env production
105
129
  # store the output, mount it at <app-root>/.securenow/credentials.json
106
130
  ```
107
131
 
132
+ **Hosts without file mounts** (Vercel, Railway, Render, Heroku, Fly) — print the same credentials as one environment variable and store it as a secret there:
133
+
134
+ ```bash
135
+ npx securenow credentials runtime --env production --format env
136
+ # SECURENOW_CREDENTIALS=eyJ... -> add as a secret environment variable
137
+ ```
138
+
139
+ `SECURENOW_CREDENTIALS` (raw JSON or base64) takes precedence over credential files. The startup line says where credentials came from (`credentials=env:SECURENOW_CREDENTIALS` or the file path). Next.js on Vercel goes through `@vercel/otel` and is not tested end to end; the firewall is not verified on Vercel serverless functions. Docker, Kubernetes, PM2 and systemd recipes: SKILL-API.md, section 6.
140
+
108
141
  **Verify** any environment with:
109
142
 
110
143
  ```bash
111
- npx securenow test-span # send a test span
112
- npx securenow doctor # diagnose config + connectivity
144
+ npx securenow doctor # diagnose config + connectivity ("All checks passed.")
145
+ npx securenow test-span # send a test span ("Span accepted (HTTP 200)")
113
146
  npx securenow status # dashboard summary
147
+ npx securenow today # what happened, what SecureNow did, what needs you
148
+ ```
149
+
150
+ **Tests** — test runs otherwise report to your real app with the project's `.securenow` credentials. `SECURENOW_DISABLED=1 npm test` turns the SDK off for that process: no traces, logs, events, firewall or session sync, and `guard()` just calls `next()`. Apart from `SECURENOW_CREDENTIALS`, this is the only setting read from the environment.
151
+
152
+ ---
153
+
154
+ ## Custom events and session revocation
155
+
156
+ Report what only your app knows, so SecureNow can catch brute force, credential stuffing and account takeover:
157
+
158
+ ```js
159
+ const { track } = require('securenow/events');
160
+ track('auth.login.failure', { userId, ip, userAgent, severity: 'warn', attributes: { reason: 'bad_password' } });
114
161
  ```
115
162
 
116
- **Tests** — test runs otherwise report to your real app with the project's `.securenow` credentials. `SECURENOW_DISABLED=1 npm test` turns the SDK off for that process: no traces, logs, events, firewall or session sync, and `guard()` just calls `next()`. This is the only setting read from the environment.
163
+ Fire-and-forget, batched, never throws. Recommended events: `auth.login.failure`, `auth.login.success`, `auth.otp.send.requested`, `auth.otp.send.result`, `auth.otp.verify.failure`, `auth.otp.verify.success`, `auth.password_reset.requested`, `auth.password_reset.completed`, `auth.mfa.challenge.failure`, `auth.mfa.challenge.success`, `auth.session.revoked`. From scripts or non-JS services: `npx securenow event send <type> --user <id> --ip <ip>`.
164
+
165
+ Kill a stolen session with `npx securenow revoke session <id>` (or `revoke user <id>`); the SDK enforces it within 30 seconds:
166
+
167
+ - **Zero code, any framework (8.25.0+):** `"sessions": { "guard": true, "capture": true }` under `config` in `.securenow/runtime.json`. Revoked sessions get 401 and their cookies cleared; `capture` sends `session.seen` for session-theft detection.
168
+ - **Express-style middleware:** `app.use(require('securenow/sessions').guard())` (Express, Connect, Polka, NestJS with Express, Feathers-Express).
169
+ - **Anything else (8.25.0+):** `const { revoked } = require('securenow/sessions').check(req)` in a Fastify hook, Koa or Hono middleware, a Next.js route handler or an h3 handler; `req` can be a Node request or a Web `Request`, and you return the 401.
170
+
171
+ Examples for each framework: SKILL-API.md, sections 5.9 and 5.10.
117
172
 
118
173
  ---
119
174
 
@@ -146,20 +201,24 @@ codex mcp add securenow -- npx securenow mcp
146
201
  }
147
202
  ```
148
203
 
149
- The server resolves credentials by operation type: admin/control-plane tools use `.securenow/admin.json`, app-scoped runtime reads can use `.securenow/runtime.json` or an explicit app key. Refresh one lane with `npx securenow admin login` or `npx securenow app connect`.
204
+ **Hosted** — `https://api.securenow.ai/mcp`, with OAuth sign-in (no install), for Claude Code (`claude mcp add --transport http securenow https://api.securenow.ai/mcp`), claude.ai, Claude Desktop, ChatGPT or any MCP client.
205
+
206
+ The local server resolves credentials by operation type: admin/control-plane tools use `.securenow/admin.json`, app-scoped runtime reads can use `.securenow/runtime.json` or an explicit app key. Refresh one lane with `npx securenow admin login` or `npx securenow app connect`.
150
207
 
151
- It exposes tools for apps, traces, logs, firewall, IP intelligence, forensics, blocklist/allowlist/trusted IPs, session revocation, rate limits, and the human approval queue — plus bundled docs as MCP resources and ready-made prompts (`investigate_ip`, `work_human_actions`, `work_alert_review`, `soc_patrol`, `secure_project_setup`). Read tools are annotated read-only; every write tool refuses to run without `confirm: true` and a non-empty `reason`.
208
+ It exposes tools for apps, traces, logs, the firewall, IP intelligence, forensics, blocklist/allowlist/trusted IPs, rate limits, challenges, alert rules, starter protection, and both review queues — plus bundled docs as MCP resources and ready-made prompts (`investigate_ip`, `work_human_actions`, `work_alert_review`, `soc_patrol`, `secure_project_setup`). `npx securenow mcp --profile investigator|detection|responder` serves a smaller set. Read tools are annotated read-only; every write tool refuses to run without `confirm: true` and a non-empty `reason`. Session revocation is a CLI command (`securenow revoke`).
152
209
 
153
210
  ---
154
211
 
155
212
  ## CLI
156
213
 
157
- Everything the MCP server can do is also a command. Run `npx securenow help` for the full reference; most read commands take `--json` for machine-readable output and `--app <key>` to target another app.
214
+ Everything the MCP server can do is also a command. Run `npx securenow help` for the list and `npx securenow help <command>` for flags; most read commands take `--json` for machine-readable output and `--app <key>` to target another app. SKILL-CLI.md organizes them by task.
158
215
 
159
216
  ### Investigate
160
217
 
161
218
  | Command | Description |
162
219
  |---|---|
220
+ | `securenow today` | The Overview: what happened, what SecureNow did, what needs you |
221
+ | `securenow attacker <address>` | Why an address was flagged: verdict, signals, traffic, detections, timeline |
163
222
  | `securenow ip <address>` | IP intelligence (geo, abuse, verdict) |
164
223
  | `securenow ip traces <address>` | Traces from an IP |
165
224
  | `securenow forensics "<query>"` | Natural-language forensic query |
@@ -168,6 +227,7 @@ Everything the MCP server can do is also a command. Run `npx securenow help` for
168
227
  | `securenow traces` / `traces show <traceId>` | Recent traces / trace spans |
169
228
  | `securenow traces analyze <traceId>` | AI security analysis of a trace |
170
229
  | `securenow logs [--since 6h] [--level error]` | View logs |
230
+ | `securenow logs errors [--since 1h]` | Failures grouped by message |
171
231
  | `securenow analytics` | Response-code analytics |
172
232
 
173
233
  ### Respond
@@ -185,8 +245,9 @@ Everything the MCP server can do is also a command. Run `npx securenow help` for
185
245
  | `securenow ratelimit add --route /api/ --limit 100 --window 1m --header x-api-key` | Per-API-key (or `--cookie session` per-session) limit |
186
246
  | `securenow firewall hits --since 1h` | Who your blocks, rate limits and challenges actually stopped |
187
247
  | `securenow challenge add <ip> --route /login` | Proof-of-work challenge instead of a hard block |
188
- | `securenow revoke session <id>` / `revoke user <id>` | Kill stolen sessions (enforced via `securenow/sessions`) |
248
+ | `securenow revoke session <id>` / `revoke user <id>` | Kill stolen sessions (the SDK's session guard enforces it) |
189
249
  | `securenow trusted add <ip>` | Mark an IP as trusted |
250
+ | `securenow agent` / `agent mode <action> <mode>` | The autonomous agent that works both queues: status, what it may do |
190
251
 
191
252
  ### Rate limits, outside your code
192
253
 
@@ -198,13 +259,15 @@ Counters live in each process by default. To share one counter across workers an
198
259
  { "config": { "firewall": { "rateLimitStore": "redis://your-redis:6379" } } }
199
260
  ```
200
261
 
201
- The firewall never waits on Redis: it decides from what it already knows and reports each hit in the background (at most about one extra request per process can get through while a reply is in flight). If Redis is unreachable, counting falls back to in-process.
262
+ The firewall never waits on Redis: it decides from what it already knows and reports each hit in the background (at most a request or two per process can get through while a reply is in flight). If Redis is unreachable, counting falls back to in-process.
202
263
 
203
264
  ### Rules & detections
204
265
 
205
266
  | Command | Description |
206
267
  |---|---|
207
- | `securenow alerts rules` | List alert rules (`create`, `update`, `test`, `delete`, ...) |
268
+ | `securenow protect` | Starter protection (about 20 rules every app gets, monitor or block mode) |
269
+ | `securenow alerts rules from-text "<what to catch>" --app <key>` | Describe a detection in English; checked draft, created in test mode |
270
+ | `securenow alerts rules` | List alert rules (`create`, `update`, `test`, `runs`, `why`, `promote`, `delete`, ...) |
208
271
  | `securenow alerts rules validate --sql @rule.sql --app <key>` | Compile and dry-run candidate detection SQL |
209
272
  | `securenow alerts history` | Alert history |
210
273
  | `securenow fp` / `fp ai-fill --description "..."` | False-positive exclusions, AI-drafted |
@@ -243,18 +306,18 @@ npx securenow run --firewall-only src/index.js
243
306
  node -r securenow/firewall-only src/index.js
244
307
  ```
245
308
 
246
- It syncs your app's blocklist plus SecureNow's known-bad IP feed, refreshed hourly, and blocks in-process with HTTP 403. No proxies, no DNS changes, no network configuration — and it fails open.
309
+ It syncs your app's blocklist plus SecureNow's known-bad IP feed, refreshed hourly, and blocks in-process with HTTP 403. No proxies, no DNS changes, no network configuration — and it fails open. Rate limits (429) and proof-of-work challenges run in the same place.
247
310
 
248
311
  ---
249
312
 
250
313
  ## Security & trust
251
314
 
252
315
  - **SecureNow never needs your source code.** It sees runtime telemetry — requests, spans, logs — not your repository.
253
- - **Redacted at capture.** `password`, `token`, `api_key`, `authorization`, `cookie`, and friends are auto-redacted before leaving your process; multipart file content is never captured. Preview with `securenow redact '<json>'`.
316
+ - **Redacted at capture.** `password`, `token`, `api_key`, `authorization`, `cookie`, emails, card numbers and friends are auto-redacted before leaving your process; multipart file content is never captured. Preview with `securenow redact '<json>'`. Log lines are redacted too (8.25.0+, `config.logging.redact`): credential fields and secret shapes become `[REDACTED]`, but a secret in free text still goes out, so don't log secrets.
254
317
 
255
318
  SecureNow 8.11.2 redacts sign-in credentials named `code`, `otpCode`, `oneTimeCode`, `verificationCode`, and `passcode` by default, including case and separator variants. JSON, form, GraphQL, and multipart text capture use the same rule; URL query parameters and captured headers are also protected. Credential names match exactly after normalization, so `status_code` and `error_code` remain available for investigation. Redaction changes exported telemetry only.
256
319
  - **Fails open.** If SecureNow is unreachable, your app serves traffic normally (`config.firewall.failMode: "open"` is the default).
257
- - **Read/write split.** MCP read tools are read-only; write tools require explicit `confirm: true` plus a reason, so your agent asks you before it blocks, rate-limits or revokes anything; every write is recorded and reversible.
320
+ - **Read/write split.** MCP read tools are read-only; write tools require explicit `confirm: true` plus a reason, so your agent asks you before it blocks, rate-limits or changes a rule; every write is recorded and reversible.
258
321
 
259
322
  More at [securenow.ai/security](https://securenow.ai/security).
260
323
 
@@ -268,7 +331,7 @@ One plan: **$99 per app per month**, every feature included — detection, MCP,
268
331
  - **14-day free trial** for the whole account, every feature, no credit card.
269
332
  - **No free tier.** After the trial, everything pauses until you subscribe, including the firewall (the known-bad IP feed and blocklist sync stop being served).
270
333
 
271
- Details at [securenow.ai](https://securenow.ai/). Full CLI/SDK reference: `npx securenow help` plus the `SKILL-CLI.md` and `SKILL-API.md` files shipped in this package.
334
+ Details at [securenow.ai](https://securenow.ai/). Full CLI/SDK reference: `npx securenow help` plus the [`SKILL-CLI.md`](./SKILL-CLI.md) and [`SKILL-API.md`](./SKILL-API.md) files shipped in this package.
272
335
 
273
336
  ## License
274
337