@lenne.tech/nest-server 11.43.9 → 11.44.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/.claude/rules/better-auth.md +11 -0
- package/.claude/rules/configurable-features.md +3 -0
- package/.claude/rules/testing.md +4 -4
- package/FRAMEWORK-API.md +2 -2
- package/dist/core/common/interfaces/server-options.interface.d.ts +2 -0
- package/dist/core/common/middlewares/string-cookies.middleware.d.ts +12 -0
- package/dist/core/common/middlewares/string-cookies.middleware.js +54 -0
- package/dist/core/common/middlewares/string-cookies.middleware.js.map +1 -0
- package/dist/core/common/pipes/map-and-validate.pipe.d.ts +2 -0
- package/dist/core/common/pipes/map-and-validate.pipe.js +16 -0
- package/dist/core/common/pipes/map-and-validate.pipe.js.map +1 -1
- package/dist/core/modules/better-auth/better-auth-token.service.d.ts +1 -1
- package/dist/core/modules/better-auth/better-auth-token.service.js +2 -1
- package/dist/core/modules/better-auth/better-auth-token.service.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth-email-verification.service.d.ts +7 -1
- package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js +19 -4
- package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js.map +1 -1
- package/dist/core/modules/better-auth/core-better-auth.service.js +2 -1
- package/dist/core/modules/better-auth/core-better-auth.service.js.map +1 -1
- package/dist/core/modules/error-code/error-codes.d.ts +9 -0
- package/dist/core/modules/error-code/error-codes.js +8 -0
- package/dist/core/modules/error-code/error-codes.js.map +1 -1
- package/dist/core.module.js +2 -0
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server/modules/error-code/error-codes.d.ts +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/docs/REQUEST-LIFECYCLE.md +25 -0
- package/migration-guides/11.13.x-to-11.14.0.md +5 -5
- package/migration-guides/11.43.9-to-11.43.10.md +48 -0
- package/migration-guides/11.43.x-to-11.44.x.md +147 -0
- package/package.json +2 -2
- package/src/core/common/interfaces/server-options.interface.ts +50 -9
- package/src/core/common/middlewares/string-cookies.middleware.ts +57 -0
- package/src/core/common/pipes/map-and-validate.pipe.ts +38 -0
- package/src/core/modules/better-auth/better-auth-token.service.ts +7 -3
- package/src/core/modules/better-auth/core-better-auth-email-verification.service.ts +45 -9
- package/src/core/modules/better-auth/core-better-auth.service.ts +7 -1
- package/src/core/modules/error-code/error-codes.ts +13 -0
- package/src/core/modules/system-setup/INTEGRATION-CHECKLIST.md +10 -4
- package/src/core/modules/system-setup/README.md +5 -5
- package/src/core.module.ts +5 -0
- package/src/index.ts +1 -0
|
@@ -493,6 +493,19 @@ export const LtnsErrors = {
|
|
|
493
493
|
},
|
|
494
494
|
},
|
|
495
495
|
|
|
496
|
+
/**
|
|
497
|
+
* An object arrived where the route declares a string, number or boolean (`@Body('token') token: string`) — the
|
|
498
|
+
* shape a MongoDB operator takes (`{ "$ne": null }`). Answered by `MapAndValidatePipe` (11.44.0 / 12.8.0, DEV-4144).
|
|
499
|
+
*/
|
|
500
|
+
INVALID_PARAMETER_TYPE: {
|
|
501
|
+
code: 'LTNS_0306',
|
|
502
|
+
message: 'Invalid parameter type',
|
|
503
|
+
translations: {
|
|
504
|
+
de: 'Ein Parameter hat einen ungültigen Typ.',
|
|
505
|
+
en: 'A parameter has an invalid type.',
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
|
|
496
509
|
// =====================================================
|
|
497
510
|
// Resource Errors (LTNS_0400-LTNS_0499)
|
|
498
511
|
// =====================================================
|
|
@@ -35,12 +35,17 @@ https://github.com/lenneTech/nest-server/tree/develop/src/core/modules/system-se
|
|
|
35
35
|
For automated deployments where no manual REST call is possible:
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
# .env or Docker environment
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
# .env or Docker environment — every segment in SCREAMING_SNAKE_CASE
|
|
39
|
+
NSC__SYSTEM_SETUP__INITIAL_ADMIN__EMAIL=admin@example.com
|
|
40
|
+
NSC__SYSTEM_SETUP__INITIAL_ADMIN__PASSWORD=YourSecurePassword123!
|
|
41
|
+
NSC__SYSTEM_SETUP__INITIAL_ADMIN__NAME=Admin # optional
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
**WHY SCREAMING_SNAKE_CASE?** The environment reader lowercases every segment it does not split at `_`. The camelCase
|
|
45
|
+
form `NSC__systemSetup__initialAdmin__email`, which this checklist showed before, is therefore read as
|
|
46
|
+
`systemsetup.initialadmin.email` and never reaches `systemSetup.initialAdmin`: no admin is created, and nothing reports
|
|
47
|
+
it.
|
|
48
|
+
|
|
44
49
|
Or in `config.env.ts`:
|
|
45
50
|
|
|
46
51
|
```typescript
|
|
@@ -99,6 +104,7 @@ export class SystemSetupController extends CoreSystemSetupController {
|
|
|
99
104
|
| Re-running init after a successful setup | 403, even with an empty `users` | The claim marker in `system-setup-locks` outlives a SUCCESSFUL setup (it is released only on failure) — drop that collection too, or wait 5 min for it to go stale |
|
|
100
105
|
| Password too short | 400 validation error | Password must be at least 8 characters |
|
|
101
106
|
| Missing ENV password | Auto-creation silently skipped | Set both `email` and `password` ENV vars |
|
|
107
|
+
| camelCase ENV names (`NSC__systemSetup__…`) | Auto-creation silently skipped | Write every segment in SCREAMING_SNAKE_CASE: `NSC__SYSTEM_SETUP__INITIAL_ADMIN__EMAIL` |
|
|
102
108
|
| `systemSetup: { enabled: false }` in config | 404 on endpoints | Remove the explicit disable |
|
|
103
109
|
|
|
104
110
|
---
|
|
@@ -9,8 +9,8 @@ System setup is **enabled by default** when BetterAuth is active. No configurati
|
|
|
9
9
|
For automated deployments (Docker, CI/CD), set initial admin credentials via ENV:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
NSC__SYSTEM_SETUP__INITIAL_ADMIN__EMAIL=admin@example.com
|
|
13
|
+
NSC__SYSTEM_SETUP__INITIAL_ADMIN__PASSWORD=YourSecurePassword123!
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
**Quick Links:** [Integration Checklist](./INTEGRATION-CHECKLIST.md) | [Endpoints](#endpoints) | [Configuration](#configuration) | [Security](#security)
|
|
@@ -136,9 +136,9 @@ For automated deployments where no manual REST call is possible (Docker, CI/CD,
|
|
|
136
136
|
### Via NSC Environment Variables
|
|
137
137
|
|
|
138
138
|
```bash
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
NSC__SYSTEM_SETUP__INITIAL_ADMIN__EMAIL=admin@example.com
|
|
140
|
+
NSC__SYSTEM_SETUP__INITIAL_ADMIN__PASSWORD=YourSecurePassword123!
|
|
141
|
+
NSC__SYSTEM_SETUP__INITIAL_ADMIN__NAME=Admin # optional
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
### Via config.env.ts
|
package/src/core.module.ts
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
} from './core/common/interfaces/server-options.interface';
|
|
41
41
|
import { RequestContextMiddleware } from './core/common/middleware/request-context.middleware';
|
|
42
42
|
import { SecurityHeadersMiddleware } from './core/common/middlewares/security-headers.middleware';
|
|
43
|
+
import { StringCookiesMiddleware } from './core/common/middlewares/string-cookies.middleware';
|
|
43
44
|
import { MapAndValidatePipe } from './core/common/pipes/map-and-validate.pipe';
|
|
44
45
|
import { ComplexityPlugin } from './core/common/plugins/complexity.plugin';
|
|
45
46
|
import { mongooseIdPlugin } from './core/common/plugins/mongoose-id.plugin';
|
|
@@ -99,6 +100,10 @@ export class CoreModule implements NestModule {
|
|
|
99
100
|
// RequestContext middleware must run for all routes to provide AsyncLocalStorage context
|
|
100
101
|
consumer.apply(RequestContextMiddleware).forRoutes('*');
|
|
101
102
|
|
|
103
|
+
// No non-string values in the parsed cookies (cookie-parser turns `j:{...}` into an object, the shape of a MongoDB
|
|
104
|
+
// operator — DEV-4138 / DEV-4144). Before every other middleware and every guard, so none of them sees one.
|
|
105
|
+
consumer.apply(StringCookiesMiddleware).forRoutes('*');
|
|
106
|
+
|
|
102
107
|
// Security headers on EVERY response, guards' rejections included. Middleware rather than an
|
|
103
108
|
// interceptor for exactly that reason: an interceptor never runs for a request a guard turns
|
|
104
109
|
// away, and those are the ones an attacker generates most of. The middleware itself decides
|
package/src/index.ts
CHANGED
|
@@ -80,6 +80,7 @@ export * from './core/common/interfaces/swagger-setup-options.interface';
|
|
|
80
80
|
export * from './core/common/middleware/request-context.middleware';
|
|
81
81
|
export * from './core/common/middlewares/to-lower-case.middleware';
|
|
82
82
|
export * from './core/common/middlewares/security-headers.middleware';
|
|
83
|
+
export * from './core/common/middlewares/string-cookies.middleware';
|
|
83
84
|
export * from './core/common/models/core-model.model';
|
|
84
85
|
export * from './core/common/models/core-persistence.model';
|
|
85
86
|
export * from './core/common/models/pagination-info.model';
|