@cslug/http 0.9.0 → 0.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.
package/docs/api.md CHANGED
@@ -25,7 +25,7 @@ on another domain is absolute; `signed` adds an HMAC (APP_KEY) checked by the `s
25
25
  ## `HttpContext`
26
26
 
27
27
  `request`, `params`, `response` (`header()`, `cookie()`, `status`), `app`, `scope`, `requestId`, `signal`, `log`,
28
- `locale`, `routeName`, `resolve(token)`. Packages augment it (`declare module '@cslug/http' { interface HttpContext { … } }`).
28
+ `locale`, `routeName`, `nonce` (set by a CSP middleware such as `csp()` from `@cslug/security`), `resolve(token)`. Packages augment it (`declare module '@cslug/http' { interface HttpContext { … } }`).
29
29
 
30
30
  `HttpRequest`: `method`, `path`, `url`, `headers`, `header()`, `ip()` (X-Forwarded-For only from
31
31
  `http.trustedProxies`, `'loopback'` allowed), `query()`, `queryAll()`, `body()` (JSON; forms with `a[b]`/`a[]`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cslug/http",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Router, middleware, HttpContext, sessions, CSRF, error rendering on Bun.serve.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "bun": ">=1.3.14"
30
30
  },
31
31
  "peerDependencies": {
32
- "@cslug/core": "0.9.0",
33
- "@cslug/validation": "0.9.0"
32
+ "@cslug/core": "0.11.0",
33
+ "@cslug/validation": "0.11.0"
34
34
  }
35
35
  }
package/src/context.ts CHANGED
@@ -227,6 +227,8 @@ export interface HttpContext {
227
227
  session: Session
228
228
  /** Name of the matched route. */
229
229
  readonly routeName?: string
230
+ /** This request's Content-Security-Policy nonce, when a CSP middleware set one (`csp()` from @cslug/security). */
231
+ nonce?: string
230
232
  /** Resolve from the request scope. */
231
233
  resolve<K extends Token>(token: K): Resolved<K>
232
234
  }