@lenne.tech/nest-server 11.46.6 → 11.46.8
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/.claude/rules/package-management.md +1 -1
- package/.claude/rules/testing.md +4 -4
- package/FRAMEWORK-API.md +1 -1
- package/dist/core/modules/better-auth/better-auth-cookie-prefix.helper.d.ts +2 -0
- package/dist/core/modules/better-auth/better-auth-cookie-prefix.helper.js +7 -0
- package/dist/core/modules/better-auth/better-auth-cookie-prefix.helper.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.middleware.js +4 -2
- package/dist/core/modules/better-auth/core-better-auth.middleware.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/migration-guides/11.46.6-to-11.46.7.md +70 -0
- package/migration-guides/11.46.7-to-11.46.8.md +86 -0
- package/package.json +2 -2
- package/src/core/modules/better-auth/better-auth-cookie-prefix.helper.ts +17 -0
- package/src/core/modules/better-auth/core-better-auth.middleware.ts +9 -4
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Migration Guide: 11.46.6 → 11.46.7
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
| Category | Details |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **Breaking Changes** | None |
|
|
8
|
+
| **New Features** | None. `resolveJwtCookieName()` and `DEFAULT_JWT_COOKIE_NAME` name the JWT cookie |
|
|
9
|
+
| **Bugfixes** | With `COOKIE_PREFIX`, the API reads a JWT-mode frontend's JWT cookie under `<prefix>-jwt-token`, the name `@lenne.tech/nuxt-extensions` writes (§1) |
|
|
10
|
+
| **Security** | None |
|
|
11
|
+
| **Migration Effort** | Package update. Only projects that set `COOKIE_PREFIX` and run in JWT mode (`cookies: false`) notice a difference |
|
|
12
|
+
|
|
13
|
+
## Quick Migration
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @lenne.tech/nest-server@11.46.7
|
|
17
|
+
pnpm run update # nest-server-starter based projects
|
|
18
|
+
pnpm run build
|
|
19
|
+
pnpm test
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Vendor mode**: run `/lt-dev:backend:update-nest-server-core` as usual.
|
|
23
|
+
|
|
24
|
+
## 1. Bugfix: the JWT cookie follows `COOKIE_PREFIX`
|
|
25
|
+
|
|
26
|
+
**No action needed.** Keep `COOKIE_PREFIX` (API) and `NUXT_PUBLIC_COOKIE_PREFIX` (app) equal, as before.
|
|
27
|
+
|
|
28
|
+
In JWT mode the frontend keeps the Better-Auth JWT in a cookie as well as sending it as a bearer token. A request that
|
|
29
|
+
carries the cookie but no `Authorization` header is authenticated by `CoreBetterAuthMiddleware` from that cookie: a
|
|
30
|
+
server-side rendered page that forwards the browser's cookies, and a passkey request from the app.
|
|
31
|
+
|
|
32
|
+
`@lenne.tech/nuxt-extensions` names that cookie `<NUXT_PUBLIC_COOKIE_PREFIX>-jwt-token` when a prefix is set. Up to
|
|
33
|
+
11.46.6 the API read `lt-jwt-token` only. With a prefix such a request was anonymous, and Better-Auth's plugin routes
|
|
34
|
+
(passkey registration, two-factor) answered `401`.
|
|
35
|
+
|
|
36
|
+
| `COOKIE_PREFIX` | JWT cookie read since 11.46.7 | Before |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| not set | `lt-jwt-token` | `lt-jwt-token` |
|
|
39
|
+
| `acme` | `acme-jwt-token` | `lt-jwt-token` |
|
|
40
|
+
|
|
41
|
+
The prefix is sanitised by the same rule as on the frontend (`[A-Za-z0-9._-]`). The base path does not enter the name,
|
|
42
|
+
unlike the session cookie (`<prefix>.session_token`, else `iam.session_token`). There is no fallback to `lt-jwt-token`
|
|
43
|
+
while `COOKIE_PREFIX` is set: the prefix keeps the apps on one host apart, and the session cookie does not fall back
|
|
44
|
+
either.
|
|
45
|
+
|
|
46
|
+
## 2. Dependencies
|
|
47
|
+
|
|
48
|
+
A pnpm override lifts `i18next` to 26.4.4 under `@compodoc/compodoc` (GHSA-6jcc-5g8w-32mx, GHSA-5jr9-983r-c8x4). It is dev tooling of this repository (`pnpm run docs`) and does not reach consumers; nothing to do in a project.
|
|
49
|
+
|
|
50
|
+
## Compatibility Notes
|
|
51
|
+
|
|
52
|
+
| Pattern | Status |
|
|
53
|
+
|---|---|
|
|
54
|
+
| No `COOKIE_PREFIX` | Unchanged |
|
|
55
|
+
| `COOKIE_PREFIX` with cookies (the default `cookies: true`) | Unchanged; the session cookie already followed the prefix |
|
|
56
|
+
| `COOKIE_PREFIX` with `cookies: false` and a matching `NUXT_PUBLIC_COOKIE_PREFIX` | Fixed: the JWT cookie is read |
|
|
57
|
+
| A frontend that sets `COOKIE_PREFIX` on the API but writes `lt-jwt-token` | No longer authenticated through the cookie. Set the same prefix on both sides |
|
|
58
|
+
|
|
59
|
+
## Troubleshooting
|
|
60
|
+
|
|
61
|
+
| Symptom | Cause | Fix |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| Passkey or 2FA routes answer `401` in JWT mode with a cookie prefix | 11.46.6 or older read only `lt-jwt-token` | Update to 11.46.7 |
|
|
64
|
+
| Still `401` after the update | The API and the app use different prefixes | Set `COOKIE_PREFIX` and `NUXT_PUBLIC_COOKIE_PREFIX` to the same value |
|
|
65
|
+
|
|
66
|
+
## Module Documentation
|
|
67
|
+
|
|
68
|
+
- `src/core/modules/better-auth/better-auth-cookie-prefix.helper.ts`: `resolveJwtCookieName()`, `resolveBetterAuthCookiePrefix()`
|
|
69
|
+
- Same fix on the current line: 12.11.2
|
|
70
|
+
- `migration-guides/11.26.1-to-11.26.2.md`, §1: `COOKIE_PREFIX` and the frontend pairing
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Migration Guide: 11.46.7 → 11.46.8
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
| Category | Details |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **Breaking Changes** | None |
|
|
8
|
+
| **New Features** | None |
|
|
9
|
+
| **Bugfixes** | None |
|
|
10
|
+
| **Security** | The Node.js runtime of a deployed API must be at least 24.22.3 (22.23.5, 26.13.1): a Brotli decoder flaw in older versions is reachable through every request body (§1). `cross-spawn` 7.1.2 and `rimraf` 6.1.4 clear GHSA-ghv9-86vm-4v8m (critical) and GHSA-qxr8-q827-836c (moderate) in the framework's own tree (§2) |
|
|
11
|
+
| **Migration Effort** | Raise the Node.js base image of the project's `Dockerfile` and rebuild; re-resolve `cross-spawn` in the project's lockfile |
|
|
12
|
+
|
|
13
|
+
## Quick Migration
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @lenne.tech/nest-server@11.46.8
|
|
17
|
+
pnpm run update # nest-server-starter based projects
|
|
18
|
+
pnpm update cross-spawn # the project's lockfile keeps its own copy (§2)
|
|
19
|
+
pnpm audit
|
|
20
|
+
pnpm run build
|
|
21
|
+
pnpm test
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Vendor mode**: run `/lt-dev:backend:update-nest-server-core` as usual.
|
|
25
|
+
|
|
26
|
+
Then raise the Node.js image of the deployment (§1). The package update alone does not change the runtime.
|
|
27
|
+
|
|
28
|
+
## 1. Security: Node.js runtime at least 24.22.3
|
|
29
|
+
|
|
30
|
+
**Action needed** for every deployed API, in npm and in vendor mode.
|
|
31
|
+
|
|
32
|
+
Node.js versions before 22.23.4, 24.22.1 and 26.12.1 contain CVE-2026-111497 (high): malformed Brotli input makes the
|
|
33
|
+
bundled decoder write past the end of an internal buffer, which permits remote code execution. CISA lists it as
|
|
34
|
+
actively exploited. An API built on nest-server reaches the decoder without authentication: Express's body parser
|
|
35
|
+
decompresses a request body sent with `Content-Encoding: br`, before any guard runs, and a reverse proxy passes such a
|
|
36
|
+
body through. The November security releases (22.23.5, 24.22.3, 26.13.1) fix further CVEs in the TLS server, HTTP/2
|
|
37
|
+
and the HTTP client, so take those versions as the minimum.
|
|
38
|
+
|
|
39
|
+
The `Dockerfile` of nest-server-starter pinned `node:24-alpine` at a digest that is Node.js 24.18.0. Replace the base
|
|
40
|
+
image in every stage:
|
|
41
|
+
|
|
42
|
+
```dockerfile
|
|
43
|
+
# Before
|
|
44
|
+
FROM node:24-alpine@sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432d679c54fbfd AS deps
|
|
45
|
+
# After
|
|
46
|
+
FROM node:24.22.3-alpine@sha256:116b800c3754b440ee0aa3ed2f20f5bf3d99a554bfd9adeea09ea8017f6e85f5 AS deps
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The version tag in front of the digest only documents the version; Docker uses the digest. Check the running image
|
|
50
|
+
after the deploy:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
docker run --rm --entrypoint node <image> -p process.version # v24.22.3 or later on the 24.x line
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
A project on another runtime (a CI image, a PaaS Node.js version, a 22.x or 26.x image) raises it to 22.23.5, 24.22.3
|
|
57
|
+
or 26.13.1 at least. `engines.node` of `@lenne.tech/nest-server` stays `>= 22.15`: the package itself has no fix to
|
|
58
|
+
ship, the runtime does.
|
|
59
|
+
|
|
60
|
+
## 2. Security: `cross-spawn` and `glob`
|
|
61
|
+
|
|
62
|
+
**Action needed** in the project's lockfile; nest-server's own lockfile does not reach a consumer.
|
|
63
|
+
|
|
64
|
+
- **GHSA-ghv9-86vm-4v8m** (critical, `cross-spawn` >= 7.0.0 < 7.1.0): command injection on Windows when a `.bat` or
|
|
65
|
+
`.cmd` file is started. `cross-spawn` reaches a project through `@modelcontextprotocol/sdk` (a dependency of the
|
|
66
|
+
framework), `cross-env` and `@swc/cli` (the SWC builder of `@nestjs/cli`). Every path accepts 7.1.x, so
|
|
67
|
+
`pnpm update cross-spawn` lifts all of them; `pnpm why cross-spawn` then lists 7.1.2 only.
|
|
68
|
+
- **GHSA-qxr8-q827-836c** (moderate, `glob` >= 13.0.5 <= 14.0.5): fixed only in glob 14.0.6. `rimraf` 6.1.4 moved to
|
|
69
|
+
glob 14 and is clean; `@nestjs/cli` 11.0.24, the newest 11.x, pins glob 13.0.6 exactly and cannot take the fix. Its
|
|
70
|
+
glob matches the developer's own build patterns, never request input. The framework lists the advisory in
|
|
71
|
+
`auditConfig.ignoreGhsas` with an `unusableFixConsumers` entry (`'@nestjs/cli@11.0.24 cannot use 14.0.6'`), which
|
|
72
|
+
`check:overrides` re-tests on every run; a project with the same tree can do the same. Do not override glob across
|
|
73
|
+
the major for `@nestjs/cli`.
|
|
74
|
+
|
|
75
|
+
## Troubleshooting
|
|
76
|
+
|
|
77
|
+
| Symptom | Cause | Fix |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `process.version` in the running container is below 24.22.3 | the image was built from a cached or still pinned base layer | Raise the digest in every `FROM` line and build with `--pull` |
|
|
80
|
+
| `pnpm audit` still reports GHSA-ghv9-86vm-4v8m | the project's lockfile keeps `cross-spawn` 7.0.6 | `pnpm update cross-spawn` |
|
|
81
|
+
| `pnpm audit` reports GHSA-qxr8-q827-836c via `@nestjs/cli>glob` | `@nestjs/cli` 11 pins glob 13.0.6 | Declare it as a residual (§2) |
|
|
82
|
+
|
|
83
|
+
## Module Documentation
|
|
84
|
+
|
|
85
|
+
- [Node.js October 2026 security releases](https://nodejs.org/en/blog/vulnerability/october-2026-security-releases)
|
|
86
|
+
- [Node.js November 2026 security releases](https://nodejs.org/en/blog/vulnerability/november-2026-security-releases)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "11.46.
|
|
3
|
+
"version": "11.46.8",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
"otpauth": "9.5.2",
|
|
220
220
|
"oxfmt": "0.73.0",
|
|
221
221
|
"oxlint": "1.88.0",
|
|
222
|
-
"rimraf": "6.1.
|
|
222
|
+
"rimraf": "6.1.4",
|
|
223
223
|
"smtp-server": "3.21.1",
|
|
224
224
|
"ts-node": "10.9.2",
|
|
225
225
|
"tsconfig-paths": "4.2.0",
|
|
@@ -58,6 +58,23 @@ export function resolveBetterAuthSessionCookieName(basePath: string, env: NodeJS
|
|
|
58
58
|
return `${resolveBetterAuthCookiePrefix(basePath, env)}.session_token`;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/** The name of the JWT cookie without `COOKIE_PREFIX`, the one `@lenne.tech/nuxt-extensions` writes by default. */
|
|
62
|
+
export const DEFAULT_JWT_COOKIE_NAME = 'lt-jwt-token';
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The cookie a JWT-mode frontend keeps the Better-Auth JWT in (11.46.7): `<COOKIE_PREFIX>-jwt-token` when `COOKIE_PREFIX`
|
|
66
|
+
* is set, otherwise `lt-jwt-token`. `@lenne.tech/nuxt-extensions` names it the same way from `NUXT_PUBLIC_COOKIE_PREFIX`,
|
|
67
|
+
* sanitised by the same rule. Unlike the session cookie, the basePath never enters the name.
|
|
68
|
+
*
|
|
69
|
+
* There is no fallback to `lt-jwt-token` while `COOKIE_PREFIX` is set: the prefix isolates the apps on one host, and
|
|
70
|
+
* the session cookie does not fall back either. Before 11.46.7 the API read `lt-jwt-token` only, so with a prefix
|
|
71
|
+
* every request without an `Authorization` header (SSR with forwarded cookies, a passkey request) was anonymous.
|
|
72
|
+
*/
|
|
73
|
+
export function resolveJwtCookieName(env: NodeJS.ProcessEnv = process.env): string {
|
|
74
|
+
const explicit = sanitizeCookiePrefix(typeof env.COOKIE_PREFIX === 'string' ? env.COOKIE_PREFIX : '');
|
|
75
|
+
return explicit ? `${explicit}-jwt-token` : DEFAULT_JWT_COOKIE_NAME;
|
|
76
|
+
}
|
|
77
|
+
|
|
61
78
|
/**
|
|
62
79
|
* Detect a Better-Auth cookie-prefix drift between the value the NestJS layer
|
|
63
80
|
* resolves (via {@link resolveBetterAuthCookiePrefix}) and a programmatic
|
|
@@ -2,6 +2,7 @@ import { Injectable, Logger, NestMiddleware } from '@nestjs/common';
|
|
|
2
2
|
import { NextFunction, Request, Response } from 'express';
|
|
3
3
|
|
|
4
4
|
import { hasApiTokenCredential } from '../api-token/core-api-token.helpers';
|
|
5
|
+
import { resolveJwtCookieName } from './better-auth-cookie-prefix.helper';
|
|
5
6
|
import { isLegacyJwt } from './core-better-auth-token.helper';
|
|
6
7
|
import { BetterAuthSessionUser, CoreBetterAuthUserMapper, MappedUser } from './core-better-auth-user.mapper';
|
|
7
8
|
import { convertExpressHeaders, extractSessionToken } from './core-better-auth-web.helper';
|
|
@@ -142,14 +143,18 @@ export class CoreBetterAuthMiddleware implements NestMiddleware {
|
|
|
142
143
|
|
|
143
144
|
// Strategy 2: Try JWT from cookie (for JWT mode when frontend stores JWT as cookie)
|
|
144
145
|
// In JWT mode (cookies=false), the frontend may store the JWT in a cookie
|
|
145
|
-
// (
|
|
146
|
+
// (`lt-jwt-token`, `<COOKIE_PREFIX>-jwt-token` with a prefix) instead of sending it as an Authorization header.
|
|
146
147
|
// This bridges the gap between cookie-based frontend storage and JWT verification.
|
|
147
148
|
if (!req.user && !req.headers.authorization && this.betterAuthService.isJwtEnabled()) {
|
|
148
149
|
try {
|
|
149
|
-
// Try parsed cookies first, then raw header (cookie-parser may not have run yet)
|
|
150
|
-
|
|
150
|
+
// Try parsed cookies first, then raw header (cookie-parser may not have run yet). The name follows
|
|
151
|
+
// COOKIE_PREFIX like the frontend's (`<prefix>-jwt-token`, else `lt-jwt-token`; 11.46.7).
|
|
152
|
+
const jwtCookieName = resolveJwtCookieName();
|
|
153
|
+
let jwtFromCookie = req.cookies?.[jwtCookieName];
|
|
151
154
|
if (!jwtFromCookie && req.headers.cookie) {
|
|
152
|
-
const match = req.headers.cookie.match(
|
|
155
|
+
const match = req.headers.cookie.match(
|
|
156
|
+
new RegExp(`(?:^|;\\s*)${jwtCookieName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}=([^;]+)`),
|
|
157
|
+
);
|
|
153
158
|
if (match) {
|
|
154
159
|
jwtFromCookie = decodeURIComponent(match[1]);
|
|
155
160
|
}
|