@nifrajs/cli 5.10.0 → 5.11.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 (61) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +10 -13
  4. package/dist/cli.js.map +1 -1
  5. package/dist/doctor.js +2 -2
  6. package/dist/doctor.js.map +1 -1
  7. package/dist/load.d.ts +2 -2
  8. package/dist/load.d.ts.map +1 -1
  9. package/dist/load.js +1 -1
  10. package/dist/load.js.map +1 -1
  11. package/dist/mcp-delegate.d.ts +17 -3
  12. package/dist/mcp-delegate.d.ts.map +1 -1
  13. package/dist/mcp-delegate.js +24 -9
  14. package/dist/mcp-delegate.js.map +1 -1
  15. package/dist/mcp-http.js +1 -1
  16. package/dist/mcp-relay.d.ts +37 -0
  17. package/dist/mcp-relay.d.ts.map +1 -0
  18. package/dist/mcp-relay.js +129 -0
  19. package/dist/mcp-relay.js.map +1 -0
  20. package/dist/mcp.d.ts.map +1 -1
  21. package/dist/mcp.js +55 -1
  22. package/dist/mcp.js.map +1 -1
  23. package/dist/migrate-layout.d.ts.map +1 -1
  24. package/dist/migrate-layout.js +45 -33
  25. package/dist/migrate-layout.js.map +1 -1
  26. package/dist/recipes/5.10.0.d.ts +3 -2
  27. package/dist/recipes/5.10.0.d.ts.map +1 -1
  28. package/dist/recipes/5.10.0.js +5 -4
  29. package/dist/recipes/5.10.0.js.map +1 -1
  30. package/dist/recipes/5.11.0.d.ts +10 -0
  31. package/dist/recipes/5.11.0.d.ts.map +1 -0
  32. package/dist/recipes/5.11.0.js +50 -0
  33. package/dist/recipes/5.11.0.js.map +1 -0
  34. package/dist/recipes/index.d.ts.map +1 -1
  35. package/dist/recipes/index.js +2 -0
  36. package/dist/recipes/index.js.map +1 -1
  37. package/dist/source-rewrites.d.ts +0 -5
  38. package/dist/source-rewrites.d.ts.map +1 -1
  39. package/dist/source-rewrites.js +232 -7
  40. package/dist/source-rewrites.js.map +1 -1
  41. package/dist/upgrade.d.ts +19 -1
  42. package/dist/upgrade.d.ts.map +1 -1
  43. package/dist/upgrade.js +55 -2
  44. package/dist/upgrade.js.map +1 -1
  45. package/docs/examples.json +2 -2
  46. package/docs/llms-full.txt +246 -63
  47. package/docs/types.json +316 -21
  48. package/package.json +11 -11
  49. package/src/cli.ts +10 -13
  50. package/src/doctor.ts +2 -2
  51. package/src/load.ts +6 -3
  52. package/src/mcp-delegate.ts +37 -11
  53. package/src/mcp-http.ts +1 -1
  54. package/src/mcp-relay.ts +155 -0
  55. package/src/mcp.ts +51 -1
  56. package/src/migrate-layout.ts +61 -29
  57. package/src/recipes/5.10.0.ts +5 -4
  58. package/src/recipes/5.11.0.ts +51 -0
  59. package/src/recipes/index.ts +2 -0
  60. package/src/source-rewrites.ts +250 -8
  61. package/src/upgrade.ts +71 -3
@@ -294,14 +294,14 @@ to full-stack later without a rewrite.
294
294
  **Throughput - the realistic case.** Router micro-benchmarks flatter Hono (a single compiled
295
295
  regex), but a real request also pays for middleware and validation,
296
296
  context, and serialization. In the current matrix Nifra runs **level with Elysia on Bun** -
297
- 100% of Elysia on `GET /users/:id` and
298
- 102% on the validated `POST` - and
299
- **level with Fastify on Node** (102% of Fastify on GET,
300
- 99% on the validated `POST`), with Elysia, Hono,
301
- and Express behind. On **Deno** it runs at 98% of Elysia on
302
- GET and 118% on the validated `POST`. In the realistic shape (security headers + CORS +
303
- bearer auth + cookies + validated query/body + a ~2.4 KB JSON response, measured with
304
- `oha`) Nifra runs at **104% of Elysia on GET and 104% on POST**. Treat benchmark
297
+ 99% of Elysia on `GET /users/:id` and
298
+ 101% on the validated `POST` - and
299
+ **level with Fastify on Node** (106% of Fastify on GET,
300
+ 105% on the validated `POST`), with Elysia, Hono,
301
+ and Express behind. On **Deno** it runs at 105% of Elysia on
302
+ GET and 128% on the validated `POST`. In the realistic shape (security headers + CORS +
303
+ bearer auth + cookies + validated query/body + a ~2.4 KB JSON response, measured on
304
+ **Bun** with `oha`) Nifra runs at **111% of Elysia on GET and 114% on POST**. Treat benchmark
305
305
  rows as same-run evidence, not a permanent law of nature.
306
306
 
307
307
  -
@@ -472,8 +472,13 @@ the root one shows instead. A navigation that settles sooner (a prefetched link,
472
472
  loader) goes straight to the new page, as does one with no eligible
473
473
  `_loading`; a change of search on the same path and a form submit keep the
474
474
  page and report `pending`. The component receives `pending` and no
475
- `data`. It is a browser-only convention on every adapter - the first load of a
476
- URL is a server render, where `defer()` streams the slow part.
475
+ `data`. React's `NavLink` widens this to a per-link signal: its
476
+ `className`, `style` and `children` take functions over
477
+ `{ isActive, isPending }`, where `isPending` is
478
+ `true` while a navigation into that link's own target is in flight; the
479
+ other adapters expose the route-level `pending` described here only. It is a
480
+ browser-only convention on every adapter - the first load of a URL is a server render,
481
+ where `defer()` streams the slow part.
477
482
 
478
483
  -
479
484
  `_error.tsx` is the segment's **error boundary**. On the server - if a route's
@@ -976,6 +981,82 @@ The component renders the boundary itself: it reads `boundaries.<name>`
976
981
  from its props and calls the boundary's `render` with the data. Every
977
982
  adapter passes `boundaries` to the layouts and the page.
978
983
 
984
+ ### Independently navigable route slots
985
+
986
+ An intercepted route is useful for one modal over its owning page. A dashboard with several
987
+ panels that open, change route, and close independently uses route slots. The page declares
988
+ named slots and an allowlist of route patterns for each. A slot renders that target's full
989
+ layout and page chain in its own component tree; each slot has separate loading and error UI.
990
+
991
+ ```tsx
992
+ // routes/dashboard.tsx - name the only route identities this panel may display
993
+ import { href } from "@nifrajs/web"
994
+ import { RouteSlot, useRouteSlot } from "@nifrajs/web-react/router"
995
+
996
+ export const routeSlots = {
997
+ inspector: ["/users/:id"],
998
+ activity: ["/activity"],
999
+ } as const
1000
+
1001
+ export default function Dashboard() {
1002
+ const inspector = useRouteSlot("inspector")
1003
+ return (
1004
+ <>
1005
+ <button type="button" onClick={() => inspector.open(href({ to: "/users/:id", params: { id: "7" } }))}>
1006
+ Inspect user 7
1007
+ </button>
1008
+ <RouteSlot name="inspector" fallback={<p>Select a user.</p>} />
1009
+ <RouteSlot name="activity" fallback={<p>Activity is closed.</p>} />
1010
+ </>
1011
+ )
1012
+ }
1013
+
1014
+ // A shareable link can open more than one panel at once.
1015
+ const dashboard = href({
1016
+ to: "/dashboard",
1017
+ slots: {
1018
+ inspector: href({ to: "/users/:id", params: { id: "7" } }),
1019
+ activity: href({ to: "/activity" }),
1020
+ },
1021
+ })
1022
+ ```
1023
+
1024
+ -
1025
+ Generated route types constrain the slot name and target route passed to `href`.
1026
+ At runtime, the client checks slot-only navigation against the page's registration and
1027
+ route identity, and the server applies the same checks to direct requests. Malformed,
1028
+ duplicate, unknown, or oversized slot state is rejected before rendering; the server
1029
+ returns `400` for an invalid direct URL. The reserved flat query keys use the
1030
+ form `slot.<name>=<target>`, allow at most four targets, 1,024
1031
+ encoded characters per target, and 4,096 encoded characters total. They are removed before
1032
+ application search parsing, while unrelated query text stays intact.
1033
+
1034
+ -
1035
+ The server sends only the page shell. After hydration, each target loads through the normal
1036
+ same-origin route-data request, so its middleware, gates, and loader run with the current
1037
+ request's authorization. Target data is never embedded in the cached shell. Slot URLs
1038
+ are inputs, never authorization grants; keep sensitive values out because URLs can appear
1039
+ in `Referer` headers, logs, and analytics. Identity changes clear old data before
1040
+ reauthorization. Returning focus revalidates at most once per 30 seconds while keeping
1041
+ ready content visible, and navigation cancels stale work.
1042
+
1043
+ -
1044
+ Opening, changing, and closing a slot create history entries; Browser Back and Forward
1045
+ restore the previous slot URLs. Updating one slot retains sibling slots and the page's
1046
+ own loader data; changing slot state alone does not rerun that page loader. Up to four slot
1047
+ targets may be open at once, with bounded concurrent loading.
1048
+
1049
+ -
1050
+ Slot content is client-rendered in this first slice: server HTML contains the fallback,
1051
+ then hydration performs an authorized route-data fetch. This works well for overlays and
1052
+ modals; always-visible panels incur that post-hydration request.
1053
+
1054
+ -
1055
+ React, Preact, Solid, and Vue export `RouteSlot` and `useRouteSlot`
1056
+ from their `/router` entry. Svelte exports `useRouteSlot` from
1057
+ `@nifrajs/web-svelte/router` and the `RouteSlot` component from
1058
+ `@nifrajs/web-svelte/route-slot`.
1059
+
979
1060
  ### Guarding navigation
980
1061
 
981
1062
  A page with unsaved work shouldn't lose it to a stray click or the back button.
@@ -4455,26 +4536,26 @@ left that lane. If a route looks like production, the contract costs nothing: de
4455
4536
 
4456
4537
  ### Bounded request bodies
4457
4538
 
4458
- Nifra caps the body of any **schema-validated** route at `maxBodyBytes` - an over-cap
4459
- `Content-Length` is rejected before buffering, and a chunked body is aborted mid-stream.
4460
- But a route that reads the body _directly_ (raw bodies, file uploads, your own validation)
4461
- bypasses that read path. `c.boundedBody(maxBytes?)` and
4462
- `c.boundedJson<T>(maxBytes?)` extend the **same** cap to those routes.
4539
+ Every HTTP route has a body limit, defaulting to `maxBodyBytes` (1,000,000 bytes).
4540
+ Nifra enforces it when the body is read, including direct `c.req`/`c.request` reads
4541
+ such as `json()`, `arrayBuffer()`, `text()`, and the raw stream. A route
4542
+ can explicitly opt out with `bodyLimit: "unlimited"`. Framework helpers, including
4543
+ `verifyWebhook` and `c.boundedBody(maxBytes?)`, read through their own bounded-reader
4544
+ paths. `verifyWebhook` defaults to 1 MiB, and an explicit `c.boundedBody(maxBytes)`
4545
+ value can exceed the route's `bodyLimit`. Set helper limits explicitly when the route-wide
4546
+ cap must apply to those reads. `c.boundedJson<T>(maxBytes?)` reads under that cap and parses JSON.
4463
4547
 
4464
4548
  ```ts
4465
4549
  import { server } from "@nifrajs/core/server"
4466
4550
 
4467
4551
  const app = server()
4468
4552
 
4469
- // A schema route is ALREADY bounded - the validated read enforces `maxBodyBytes`.
4470
- // But a raw-body / file / BYO-validation route reads the body directly, which
4471
- // `maxBodyBytes` does not cover. `c.boundedBody` caps that read:
4472
- app.post("/import", async (c) => {
4473
- const bytes = await c.boundedBody(5 * 1024 * 1024) // cap THIS route at 5 MiB
4474
- // Over-cap throws a flat 413; a malformed Content-Length a 400 - as control-flow
4475
- // Responses (caught by the lifecycle like `throw redirect()`), so a handler can't
4476
- // accidentally ignore the cap. The over-cap length is rejected BEFORE buffering;
4477
- // a chunked / length-less body is aborted mid-stream once it crosses the cap.
4553
+ // Every route is bounded, including raw-body / file / BYO-validation routes that
4554
+ // read c.req directly. Raise the route cap when this endpoint needs more than the default:
4555
+ app.post("/import", { bodyLimit: 5 * 1024 * 1024 }, async (c) => {
4556
+ const bytes = await c.req.arrayBuffer() // the direct read is capped at 5 MiB
4557
+ // An over-cap Content-Length is rejected BEFORE buffering; chunked bodies are
4558
+ // aborted mid-stream. Both answer a flat 413 through the request lifecycle.
4478
4559
  return { received: bytes.byteLength } // a returned object is serialized as JSON 200
4479
4560
  })
4480
4561
 
@@ -4485,10 +4566,10 @@ app.post("/rpc", async (c) => {
4485
4566
  })
4486
4567
  ```
4487
4568
 
4488
- Over-cap throws a flat `413`, a malformed `Content-Length` a `400`,
4489
- bad JSON a `400` - thrown as control-flow `Response`s the lifecycle catches,
4490
- so the cap can't be silently skipped. Pass a larger `maxBytes` for an upload route, a
4491
- smaller one to tighten an endpoint.
4569
+ An over-cap read is rejected with a flat `413`; a malformed
4570
+ `Content-Length` gets a `400`. `c.boundedJson` also returns
4571
+ `400` for malformed or rejected JSON. Set a larger finite route
4572
+ `bodyLimit` for an upload, or a smaller `maxBytes` to tighten an individual read.
4492
4573
 
4493
4574
  The cap is enforced on the bytes actually **delivered**, never on the number the caller wrote in
4494
4575
  `Content-Length`. That distinction is the whole defense: an adapter that rebuilds a
@@ -4511,12 +4592,16 @@ through the streaming guard.
4511
4592
 
4512
4593
  ### Prototype-poisoning defense
4513
4594
 
4514
- Every JSON body nifra parses - the schema-validated route and `c.boundedJson`
4515
- alike - is screened for the prototype-pollution shape: an own `__proto__` key, or
4516
- a `constructor` whose value carries a `prototype`. `JSON.parse`
4595
+ The schema body reader and `c.boundedJson` screen parsed JSON for the prototype-pollution
4596
+ shape: an own `__proto__` key, or a `constructor` whose value carries a
4597
+ `prototype`. `JSON.parse`
4517
4598
  creates these as ordinary data properties, and the damage lands later, when innocent code does
4518
4599
  `{ ...body }`, `Object.assign(target, body)`, or a deep merge and
4519
- walks that key onto a real prototype. The screen is on by default.
4600
+ walks that key onto a real prototype. This screen is on by default for those guarded readers.
4601
+
4602
+ Direct `c.req.json()` reads are still subject to the body-size cap, but do not apply the
4603
+ `protoPoisoning` policy. Treat their parsed object keys as untrusted before merging; use
4604
+ `c.boundedJson` when you want Nifra to apply that policy.
4520
4605
 
4521
4606
  ```ts
4522
4607
  import { server } from "@nifrajs/core/server"
@@ -4766,31 +4851,36 @@ size cap and sniffs the **real** type from magic bytes - never the client-set
4766
4851
  // doc-check: skip - fragment: `app`, `save`, `id`, and `env` are your application's.
4767
4852
  import { validateUpload, signDownloadUrl } from "@nifrajs/uploads"
4768
4853
 
4769
- app.post("/avatar", async (c) => {
4770
- const form = await c.req.formData()
4771
- const file = form.get("file")
4772
- if (!(file instanceof Blob)) { c.set.status = 400; return { ok: false, error: "no_file" } }
4773
-
4774
- // Size cap + REAL type by magic bytes - a .exe renamed .png (or a spoofed
4775
- // Content-Type) is caught, because the bytes win. An oversized Blob is rejected
4776
- // by its .size BEFORE it's buffered into memory.
4777
- const result = await validateUpload(file, {
4778
- maxBytes: 2_000_000,
4779
- accept: ["image/png", "image/jpeg"], // exact, or "image/*"
4780
- })
4781
- if (!result.ok) { c.set.status = 400; return { ok: false, error: result.reason } }
4782
- // reason: "too_large" | "empty" | "unrecognized" | "type_not_allowed"
4854
+ app.post(
4855
+ "/avatar",
4856
+ { bodyLimit: 2_100_000 }, // request cap includes multipart framing around a 2 MB file
4857
+ async (c) => {
4858
+ const form = await c.req.formData()
4859
+ const file = form.get("file")
4860
+ if (!(file instanceof Blob)) { c.set.status = 400; return { ok: false, error: "no_file" } }
4861
+
4862
+ // Size cap + REAL type by magic bytes - a .exe renamed .png (or a spoofed
4863
+ // Content-Type) is caught, because the bytes win. An oversized Blob is rejected
4864
+ // by its .size BEFORE it's buffered into memory.
4865
+ const result = await validateUpload(file, {
4866
+ maxBytes: 2_000_000,
4867
+ accept: ["image/png", "image/jpeg"], // exact, or "image/*"
4868
+ })
4869
+ if (!result.ok) { c.set.status = 400; return { ok: false, error: result.reason } }
4870
+ // reason: "too_large" | "empty" | "unrecognized" | "type_not_allowed"
4783
4871
 
4784
- await save(result.bytes, `${id}.${result.ext}`) // result.mime / .ext are trustworthy
4872
+ await save(result.bytes, `${id}.${result.ext}`) // result.mime / .ext are trustworthy
4785
4873
 
4786
- // Hand back a short-TTL, tamper-evident URL (HMAC over path + expiry):
4787
- const url = await signDownloadUrl(`/files/${id}`, env.FILE_SECRET, { expiresInSeconds: 300 })
4788
- return { ok: true, url } // a returned object is serialized as JSON 200
4789
- })
4874
+ // Hand back a short-TTL, tamper-evident URL (HMAC over path + expiry):
4875
+ const url = await signDownloadUrl(`/files/${id}`, env.FILE_SECRET, { expiresInSeconds: 300 })
4876
+ return { ok: true, url } // a returned object is serialized as JSON 200
4877
+ },
4878
+ )
4790
4879
  ```
4791
4880
 
4792
- Pair it with `c.boundedBody` to also bound the _read_: cap the read, then validate
4793
- the buffered bytes. The detection alone is `detectFileType(bytes)` from
4881
+ Direct request reads already follow the route's body limit. Use `c.boundedBody` to
4882
+ set an explicit cap for the bytes you pass to `validateUpload`. The detection alone is
4883
+ `detectFileType(bytes)` from
4794
4884
  `@nifrajs/core/file-type` (returns `{ mime, ext }` or `null`),
4795
4885
  covering common image / A-V / archive types.
4796
4886
 
@@ -4943,7 +5033,8 @@ const app = server()
4943
5033
  // X-Forwarded-For is never believed.
4944
5034
  .use(ipRestriction({ allow: ["10.0.0.0/8", "::1"] }))
4945
5035
  // Reject oversized bodies at the EDGE by Content-Length, before routing - fails closed (411) on a
4946
- // length-less body. (The schema / c.boundedBody cap is the read-time guard; this is the cheap pre-filter.)
5036
+ // length-less body. This is the cheap pre-filter; the route's cap on direct and
5037
+ // framework reads is the read-time guard.
4947
5038
  .use(bodyLimit({ maxBytes: 1_000_000 }))
4948
5039
  ```
4949
5040
 
@@ -4964,8 +5055,8 @@ trustworthy client IP can be derived, and never trusts `X-Forwarded-For` unless
4964
5055
 
4965
5056
  -
4966
5057
  `bodyLimit` - a cheap `Content-Length` pre-filter that rejects oversized
4967
- bodies before routing (fails closed with `411` on a length-less body). The read-time
4968
- guard above (`c.boundedBody` / schema cap) remains the source of truth.
5058
+ bodies before routing (fails closed with `411` on a length-less body). The route's
5059
+ read-time body limit applies to direct reads, schema validation, and bounded readers.
4969
5060
 
4970
5061
  ### Security response headers - `securityHeaders`
4971
5062
 
@@ -5195,6 +5286,91 @@ const app = server({
5195
5286
  // Add your own: { valuePatterns: [...commonSecretPatterns, /\bord_[a-z0-9]+/g] }
5196
5287
  ```
5197
5288
 
5289
+ ### Credentials that reach the browser - NF-C032
5290
+
5291
+ The zone rules keep `backend/` halves and server-only imports out of the browser
5292
+ bundle; the credential scan is the net under them - for a credential typed straight into
5293
+ browser code, one a dependency carries, and a server-only environment value that reached the
5294
+ output some other way (a `define`, a prerendered page, a copied
5295
+ `public/` file). `nifra check` (NF-C032, an error) scans each app's
5296
+ browser-zone modules and every file in `public/`; the build runs the same net on
5297
+ what it publishes - every emitted file with its inline source maps decoded, every
5298
+ `public/` copy, every prerendered page - and matches the values of the build
5299
+ environment's non-public variables there, raw and URL-, base64-, JSON- and
5300
+ HTML-encoded. A `PUBLIC_`-prefixed variable is public by declaration.
5301
+
5302
+ Five rules:
5303
+
5304
+ -
5305
+ **Known token formats** - AWS access keys, Stripe secret keys and webhook secrets,
5306
+ GitHub, Slack (tokens and webhook URLs), OpenAI, Anthropic, SendGrid, Twilio, Mailgun, npm,
5307
+ and a Supabase service-role JWT.
5308
+
5309
+ -
5310
+ **PEM private keys** - a block with a body present, not a parser's bare
5311
+ `-----BEGIN PRIVATE KEY-----` constant.
5312
+
5313
+ -
5314
+ **URLs with a password** - `postgres://user:password@host`, unless the
5315
+ password is a placeholder.
5316
+
5317
+ -
5318
+ **Assigned secrets** - a random literal given to a secret-like name, in first-party
5319
+ source only: `apiKey: "..."`, a quoted header name including its hyphens (
5320
+ `"x-api-key": "..."`), a header set by call (
5321
+ `headers.set("x-api-key", ...)`), a pair in
5322
+ `new Headers([...])`, and `Authorization` read into its
5323
+ `Bearer` token or `Basic` credentials.
5324
+
5325
+ -
5326
+ **Private env values** - the value of a build variable whose name says secret (
5327
+ `TOKEN`, `API_KEY`, `DATABASE_URL`, …) or that looks
5328
+ random, in any encoding above. A defined set of recognized ambient shell, OS and CI names
5329
+ is skipped unless the name itself looks secret-like. Other names are scanned when they
5330
+ look secret-like, contain a credential URL, or hold a random-looking value.
5331
+
5332
+ Deliberate skips: keys public by design (Stripe `pk_`, Google `AIza`,
5333
+ reCAPTCHA `6L`, `G-` and `UA-` ids), placeholders (
5334
+ `changeme`, `<your-key-here>`, a whole-value stand-in such as
5335
+ `your_signing_secret` or an interpolated shell value), low-entropy and word-shaped
5336
+ values, and labels inside a message catalog (`password: "Lykilorð"`). A
5337
+ finding never prints the value: the rule, the location, and a preview of the first few
5338
+ characters plus the length. When a match sits in a content-hashed output file, the build
5339
+ names the module it came from.
5340
+
5341
+ A reviewed false positive can be exempted in `nifra.config.ts`. A `file`
5342
+ exemption suppresses that rule throughout the named file, so the same credential in another
5343
+ file still fails. For `private-env-value`, an `env` exemption suppresses
5344
+ every finding from that variable anywhere in scanned output; use it only when publishing that
5345
+ value everywhere it appears is intended. Every exemption needs its rule and reason, or the
5346
+ build refuses:
5347
+
5348
+ ```ts
5349
+ // nifra.config.ts
5350
+ // doc-check: skip - exemptions name your own findings; there is nothing to run
5351
+ export const secretExemptions = [
5352
+ {
5353
+ rule: "key-format",
5354
+ file: "routes/docs.tsx",
5355
+ reason: "the sample literally spells an AWS access key id",
5356
+ },
5357
+ // A file exemption covers this rule throughout the named file. An env exemption covers every
5358
+ // finding from that variable anywhere in scanned output; use it only when that is intended.
5359
+ {
5360
+ rule: "private-env-value",
5361
+ env: "SIGNING_SALT",
5362
+ reason: "this value is intentionally published wherever it appears; it shapes a public nonce",
5363
+ },
5364
+ ]
5365
+ ```
5366
+
5367
+ The net is a heuristic, not a guarantee. A credential spelled inside a longer string - a
5368
+ URL's query (`https://api.example.com/v1?key=...`) or a cookie header's
5369
+ value - is seen by the known-format rules alone, and a random value given to a name the scan
5370
+ does not judge secret-like is not the `assigned-secret` rule's target. Keep
5371
+ credentials in a route's backend half or under `backend/`, and rotate any
5372
+ that were ever committed.
5373
+
5198
5374
  ## Nifra - Effect provenance
5199
5375
 
5200
5376
  > A route declares the effects it performs, and `nifra check` fails it for being able to reach further than it declared. How reach is computed, why that shapes your modules, and how the declaration turns into an enforced policy.
@@ -8060,12 +8236,16 @@ starts from unless nothing else, installed or declared, names one.
8060
8236
  nifra upgrade --list # the release targets this CLI knows
8061
8237
  nifra upgrade 5.6.0 # dry-run: every planned edit, nothing written
8062
8238
  nifra upgrade 5.6.0 --write # apply; it verifies with nifra check once the target is installed
8239
+ nifra upgrade 5.6.0 --from 5.4.0 --write # pins already bumped by hand: apply the recipes they skipped
8063
8240
  bun install # install the new pins
8064
8241
  nifra check # verify against them
8065
8242
  nifra doctor # afterwards: no "mixed nifra versions" advisory left
8066
8243
  ```
8067
8244
 
8068
- It is a dry-run until `--write`, and the same run twice makes no further edits. An
8245
+ It is a dry-run until `--write`, and the same run twice makes no further edits. Once
8246
+ the pins name the target, no recipe is left to apply: pass `--from <version>`
8247
+ with the version they were at to apply the ones they skipped. An option it does not know is
8248
+ refused rather than ignored. An
8069
8249
  unknown version or a target below what is installed is refused (`--allow-downgrade`
8070
8250
  when the rollback is intended); a target newer than the running CLI prints the command for
8071
8251
  that release's CLI. It edits files under the workspace root only: a symlinked package
@@ -13946,8 +14126,8 @@ app.
13946
14126
 
13947
14127
  -
13948
14128
  **Much faster SSR** - the current dynamic-page snapshot reports Nifra at
13949
- 15× the throughput of Next.js, 7.2× Nuxt, and
13950
- 3.9× SvelteKit / 2.2× SolidStart, with a fraction
14129
+ 15× the throughput of Next.js, 6.9× Nuxt, and
14130
+ 4.1× SvelteKit / 2.6× SolidStart, with a fraction
13951
14131
  of the client JavaScript. See benchmarks.
13952
14132
 
13953
14133
  -
@@ -19302,9 +19482,12 @@ const app = server()
19302
19482
  - **`rateLimit(options)`** - `429` + `Retry-After` + `RateLimit-*` headers, with a
19303
19483
  pluggable `RateLimitStore`. The default bucket key is the caller IP the server resolved (the
19304
19484
  socket peer, or the app's `clientIp` trust declaration behind a proxy); a custom `key`, trusted
19305
- single-IP `header`, or `trustedProxies` overrides it. With no caller IP it fails closed (`500`)
19306
- instead of silently sharing one bucket. The bundled `MemoryStore` **refuses to run in production** (a per-instance
19307
- limiter is unsafe across instances) - provide a shared store (Redis, etc.) there.
19485
+ single-IP `header`, or `trustedProxies` overrides it. A configured header must contain exactly one
19486
+ valid IP; comma-separated or malformed values fall through to configured `trustedProxies` or
19487
+ `allowGlobalKey` fallbacks. Without a usable key or explicit global fallback, requests fail closed
19488
+ (`500`) instead of silently sharing one bucket. The bundled `MemoryStore` **refuses to run in
19489
+ production** (a per-instance limiter is unsafe across instances) - provide a shared store (Redis,
19490
+ etc.) there.
19308
19491
  - **`cache({ store, ttlMs })` / `responseCache(...)`** - full response cache with a pluggable
19309
19492
  store, `Vary`-aware keys, `Age`, byte caps, and `Cache-Control` / `Set-Cookie` safety defaults.
19310
19493
  `MemoryResponseCache` is dev/single-instance only unless explicitly allowed in production.
@@ -21201,7 +21384,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
21201
21384
 
21202
21385
  ## @nifrajs/web
21203
21386
 
21204
- `ACTION_GLOBAL`, `Action`, `BOUNDARY_GLOBAL`, `BackendOnly`, `Blocker`, `BlockerController`, `BlockerFunction`, `BlockerLocation`, `BlockerState`, `Boundary`, `BoundaryDescriptor`, `BoundaryError`, `BoundaryLoaderEntry`, `BoundaryLoadersOf`, `BoundaryMode`, `BoundaryRegistration`, `BoundaryRequestCtx`, `BoundaryState`, `BoundaryStates`, `BoundaryStatus`, `BrowserNavigate`, `BuildAssetSet`, `CacheStore`, `CachedResponse`, `CdnPurgeOutcome`, `CdnPurgeTarget`, `ClientAction`, `ClientActionArgs`, `ClientActionResult`, `ClientLoader`, `ClientLoaderArgs`, `ClientRequestBody`, `ClientRouteHooks`, `ClientRouter`, `ClientRouterOptions`, `CreateCspPolicyOptions`, `CreateNonceResolverOptions`, `CreateWebAppOptions`, `CspHeaderContext`, `CspPolicy`, `CssLoadingMode`, `DATA_GLOBAL`, `DATA_HEADER`, `DEFAULT_CSS_LOADING`, `DEFAULT_DEV_PORT`, `DRAFT_COOKIE`, `DataText`, `Deferred`, `DehydrateOptions`, `DehydratedQueryInfo`, `DehydratedState`, `DocumentParts`, `DraftCookieControls`, `DynamicBoundary`, `DynamicBoundaryBatch`, `EnableDraftOptions`, `FetchRouteData`, `Fetcher`, `FetcherState`, `FontDisplay`, `FontFace`, `FontPreloadInput`, `FontSource`, `GenerateClientEntryOptions`, `GenerateServerManifestOptions`, `GetStaticPaths`, `HANDOVER_ID`, `HostPolicy`, `HostPolicyOptions`, `HostPolicyRule`, `Href`, `HrefOptions`, `HtmlSanitizer`, `IDLE_BLOCKER`, `ISRApp`, `ISROptions`, `ISRPlatform`, `ISRQuery`, `ISRStoreOp`, `ISR_REVALIDATE_HEADER`, `ISR_REVALIDATE_TAGS_HEADER`, `ISR_STATUS_HEADER`, `IdentityEpochContext`, `InertScriptType`, `InfiniteData`, `InfiniteQueryHandle`, `InfiniteQueryOptions`, `InterceptBoundary`, `Intercepted`, `KVCacheStore`, `KVCacheStoreOptions`, `KVNamespaceLike`, `KeepAliveOptions`, `KeepAliveServerOptions`, `KeptPage`, `LAYOUT_DATA_GLOBAL`, `LOCALES_GLOBAL`, `LayoutEntry`, `LinkDescriptor`, `LiveClientEntry`, `Loader`, `LoaderContext`, `LoaderResponseControls`, `LoadingEntry`, `Manifest`, `MatchChain`, `MemoryCacheStore`, `MemoryCacheStoreOptions`, `MemoryStaticBoundaryCache`, `Meta`, `MetaArgs`, `MetaDescriptor`, `MetaInput`, `MiddlewareOutcome`, `MountRouterOptions`, `MutationCallbacks`, `MutationCancelledError`, `MutationContext`, `MutationHandle`, `MutationState`, `MutationStatus`, `NAV_FROM_HEADER`, `NavigateFunction`, `NavigateOptions`, `NonceContext`, `NonceGenerator`, `NonceHeader`, `NonceHeaderContext`, `NonceResolver`, `NotFoundEntry`, `NotFoundScope`, `OpenGraphInput`, `PREFETCH_HEADER`, `PRE_HYDRATION_GUARD`, `PageLocale`, `PageLocales`, `PendingBoundary`, `PrefetchMode`, `PrerenderedPageReaderOptions`, `PrerenderedPages`, `PreviewEndpointOptions`, `QueryClient`, `QueryClientOptions`, `QueryHandle`, `QueryOptions`, `QueryState`, `QueryStatus`, `REDIRECT_HEADER`, `RETAIN_HEADER`, `REVALIDATE_HEADER`, `ROOT_ATTRIBUTE`, `ROUTE_GLOBAL`, `RedirectOptions`, `RenderAdapter`, `RenderAdapterConformanceError`, `RenderAdapterConformanceFixture`, `RenderAssemblyCache`, `RenderPageInput`, `RenderPageOptions`, `RenderProps`, `RenderStreamOptions`, `RenderedPage`, `RevalidateEndpointOptions`, `RevalidateOptions`, `RevalidateResult`, `RevalidateTags`, `RevalidateTagsInput`, `RouteEntry`, `RouteMatch`, `RouteMiddleware`, `RouteModule`, `RoutePattern`, `RouteTable`, `RouterState`, `SERVER_FN_MODULE`, `STATUS_HEADER`, `SanitizedHtml`, `ScriptDescriptor`, `SearchOf`, `SharedBoundary`, `SharedHoleCtx`, `ShellCtx`, `ShouldRevalidate`, `ShouldRevalidateArgs`, `SsrModuleLoader`, `StaticBoundary`, `StaticBoundaryCache`, `StaticBoundaryImportEdge`, `StaticBoundaryRoot`, `StaticCtx`, `StaticPath`, `StaticPaths`, `StaticRoutes`, `StatusPageOptions`, `Submission`, `SubmitOptions`, `TrustedHtml`, `UIMatch`, `UnsafeScriptDescriptor`, `WebAppI18n`, `assertCssLoadingCompatible`, `assertRenderAdapterConformance`, `assertStaticBoundaryImports`, `boundaryDescriptors`, `boundaryModeKey`, `buildManifest`, `canonical`, `closeBoundary`, `createClientRouter`, `createCspPolicy`, `createHostPolicy`, `createMatcher`, `createMutation`, `createNonceResolver`, `createQueryClient`, `createWebApp`, `defer`, `disableDraft`, `enableDraft`, `enumerateStaticRoutes`, `filePathToPattern`, `filePathToPatterns`, `fontFace`, `fontPreload`, `generateClientEntry`, `generateServerManifest`, `getBrowserNavigate`, `gone`, `hashQueryKey`, `href`, `isCacheablePage`, `isDraftEnabled`, `isHostPolicy`, `jsonLd`, `localeOfProps`, `mergeHeads`, `nifraScriptHashes`, `normalizeCssLoading`, `notFound`, `openGraph`, `pageLocaleIn`, `prerenderedPageReader`, `previewEndpoint`, `rawHref`, `redirect`, `registerBlocker`, `renderPage`, `renderPageResult`, `resolveChainMeta`, `resolveDynamicBoundaries`, `resolveMeta`, `resolvePublicPath`, `resolveStaticBoundaries`, `revalidate`, `revalidateEndpoint`, `rotateIdentityEpoch`, `sanitizeHtml`, `sanitizedHtml`, `searchOf`, `searchOfChain`, `serializeData`, `serializeSearch`, `setBlockerController`, `setBrowserNavigate`, `setSsrModuleLoader`, `ssrModuleLoader`, `startDynamicBoundaries`, `statusPage`, `trustHtml`, `unsafeInlineScript`, `webProjectEvidence`, `withISR`
21387
+ `ACTION_GLOBAL`, `Action`, `BOUNDARY_GLOBAL`, `BackendOnly`, `Blocker`, `BlockerController`, `BlockerFunction`, `BlockerLocation`, `BlockerState`, `Boundary`, `BoundaryDescriptor`, `BoundaryError`, `BoundaryLoaderEntry`, `BoundaryLoadersOf`, `BoundaryMode`, `BoundaryRegistration`, `BoundaryRequestCtx`, `BoundaryState`, `BoundaryStates`, `BoundaryStatus`, `BrowserNavigate`, `BuildAssetSet`, `CacheStore`, `CachedResponse`, `CdnPurgeOutcome`, `CdnPurgeTarget`, `ClientAction`, `ClientActionArgs`, `ClientActionResult`, `ClientLoader`, `ClientLoaderArgs`, `ClientRequestBody`, `ClientRouteHooks`, `ClientRouter`, `ClientRouterOptions`, `CreateCspPolicyOptions`, `CreateNonceResolverOptions`, `CreateWebAppOptions`, `CspHeaderContext`, `CspPolicy`, `CssLoadingMode`, `DATA_GLOBAL`, `DATA_HEADER`, `DEFAULT_CSS_LOADING`, `DEFAULT_DEV_PORT`, `DRAFT_COOKIE`, `DataText`, `Deferred`, `DehydrateOptions`, `DehydratedQueryInfo`, `DehydratedState`, `DocumentParts`, `DraftCookieControls`, `DynamicBoundary`, `DynamicBoundaryBatch`, `EnableDraftOptions`, `FetchRouteData`, `Fetcher`, `FetcherState`, `FontDisplay`, `FontFace`, `FontPreloadInput`, `FontSource`, `GenerateClientEntryOptions`, `GenerateServerManifestOptions`, `GetStaticPaths`, `HANDOVER_ID`, `HostPolicy`, `HostPolicyOptions`, `HostPolicyRule`, `Href`, `HrefOptions`, `HtmlSanitizer`, `IDLE_BLOCKER`, `ISRApp`, `ISROptions`, `ISRPlatform`, `ISRQuery`, `ISRStoreOp`, `ISR_REVALIDATE_HEADER`, `ISR_REVALIDATE_TAGS_HEADER`, `ISR_STATUS_HEADER`, `IdentityEpochContext`, `InertScriptType`, `InfiniteData`, `InfiniteQueryHandle`, `InfiniteQueryOptions`, `InterceptBoundary`, `Intercepted`, `KVCacheStore`, `KVCacheStoreOptions`, `KVNamespaceLike`, `KeepAliveOptions`, `KeepAliveServerOptions`, `KeptPage`, `LAYOUT_DATA_GLOBAL`, `LOCALES_GLOBAL`, `LayoutEntry`, `LinkDescriptor`, `LiveClientEntry`, `Loader`, `LoaderContext`, `LoaderResponseControls`, `LoadingEntry`, `Manifest`, `MatchChain`, `MemoryCacheStore`, `MemoryCacheStoreOptions`, `MemoryStaticBoundaryCache`, `Meta`, `MetaArgs`, `MetaDescriptor`, `MetaInput`, `MiddlewareOutcome`, `MountRouterOptions`, `MutationCallbacks`, `MutationCancelledError`, `MutationContext`, `MutationHandle`, `MutationState`, `MutationStatus`, `NAV_FROM_HEADER`, `NavigateFunction`, `NavigateOptions`, `NonceContext`, `NonceGenerator`, `NonceHeader`, `NonceHeaderContext`, `NonceResolver`, `NotFoundEntry`, `NotFoundScope`, `OpenGraphInput`, `PREFETCH_HEADER`, `PRE_HYDRATION_GUARD`, `PageLocale`, `PageLocales`, `PendingBoundary`, `PrefetchMode`, `PrerenderedPageReaderOptions`, `PrerenderedPages`, `PreviewEndpointOptions`, `QueryClient`, `QueryClientOptions`, `QueryHandle`, `QueryOptions`, `QueryState`, `QueryStatus`, `REDIRECT_HEADER`, `RETAIN_HEADER`, `REVALIDATE_HEADER`, `ROOT_ATTRIBUTE`, `ROUTE_GLOBAL`, `RedirectOptions`, `RenderAdapter`, `RenderAdapterConformanceError`, `RenderAdapterConformanceFixture`, `RenderAssemblyCache`, `RenderPageInput`, `RenderPageOptions`, `RenderProps`, `RenderStreamOptions`, `RenderedPage`, `RevalidateEndpointOptions`, `RevalidateOptions`, `RevalidateResult`, `RevalidateTags`, `RevalidateTagsInput`, `RouteEntry`, `RouteMatch`, `RouteMiddleware`, `RouteModule`, `RoutePattern`, `RouteSlotName`, `RouteSlotPatternsOf`, `RouteSlotRegistry`, `RouteSlotTarget`, `RouteTable`, `RouterState`, `SERVER_FN_MODULE`, `STATUS_HEADER`, `SanitizedHtml`, `ScriptDescriptor`, `SearchOf`, `SharedBoundary`, `SharedHoleCtx`, `ShellCtx`, `ShouldRevalidate`, `ShouldRevalidateArgs`, `SsrModuleLoader`, `StaticBoundary`, `StaticBoundaryCache`, `StaticBoundaryImportEdge`, `StaticBoundaryRoot`, `StaticCtx`, `StaticPath`, `StaticPaths`, `StaticRoutes`, `StatusPageOptions`, `Submission`, `SubmitOptions`, `TrustedHtml`, `UIMatch`, `UnsafeScriptDescriptor`, `WebAppI18n`, `assertCssLoadingCompatible`, `assertRenderAdapterConformance`, `assertStaticBoundaryImports`, `boundaryDescriptors`, `boundaryModeKey`, `buildManifest`, `canonical`, `closeBoundary`, `createClientRouter`, `createCspPolicy`, `createHostPolicy`, `createMatcher`, `createMutation`, `createNonceResolver`, `createQueryClient`, `createWebApp`, `defer`, `disableDraft`, `enableDraft`, `enumerateStaticRoutes`, `filePathToPattern`, `filePathToPatterns`, `fontFace`, `fontPreload`, `generateClientEntry`, `generateServerManifest`, `getBrowserNavigate`, `gone`, `hashQueryKey`, `href`, `isCacheablePage`, `isDraftEnabled`, `isHostPolicy`, `jsonLd`, `localeOfProps`, `mergeHeads`, `nifraScriptHashes`, `normalizeCssLoading`, `notFound`, `openGraph`, `pageLocaleIn`, `prerenderedPageReader`, `previewEndpoint`, `rawHref`, `redirect`, `registerBlocker`, `renderPage`, `renderPageResult`, `resolveChainMeta`, `resolveDynamicBoundaries`, `resolveMeta`, `resolvePublicPath`, `resolveStaticBoundaries`, `revalidate`, `revalidateEndpoint`, `rotateIdentityEpoch`, `sanitizeHtml`, `sanitizedHtml`, `searchOf`, `searchOfChain`, `serializeData`, `serializeSearch`, `setBlockerController`, `setBrowserNavigate`, `setSsrModuleLoader`, `ssrModuleLoader`, `startDynamicBoundaries`, `statusPage`, `trustHtml`, `unsafeInlineScript`, `webProjectEvidence`, `withISR`
21205
21388
 
21206
21389
  ## @nifrajs/web-preact
21207
21390