@lenne.tech/nest-server 12.11.3 → 12.12.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/architecture.md +3 -0
- package/.claude/rules/configurable-features.md +6 -0
- package/.claude/rules/package-management.md +6 -4
- package/.claude/rules/testing.md +8 -7
- package/CLAUDE.md +2 -1
- package/FRAMEWORK-API.md +15 -1
- package/dist/core/common/decorators/common-error.decorator.d.ts +1 -1
- package/dist/core/common/interfaces/server-options.interface.d.ts +54 -0
- package/dist/core/common/persistence/audit-log.registry.d.ts +19 -0
- package/dist/core/common/persistence/audit-log.registry.js +84 -0
- package/dist/core/common/persistence/audit-log.registry.js.map +1 -0
- package/dist/core/common/services/core-trust-proxy.initializer.js +1 -1
- package/dist/core/common/services/core-trust-proxy.initializer.js.map +1 -1
- package/dist/core/common/services/crud.service.d.ts +10 -0
- package/dist/core/common/services/crud.service.js +79 -24
- package/dist/core/common/services/crud.service.js.map +1 -1
- package/dist/core/common/services/email.service.d.ts +5 -0
- package/dist/core/common/services/email.service.js +82 -6
- package/dist/core/common/services/email.service.js.map +1 -1
- package/dist/core/common/services/leased-interval.d.ts +22 -0
- package/dist/core/common/services/leased-interval.js +81 -0
- package/dist/core/common/services/leased-interval.js.map +1 -0
- package/dist/core/common/services/mail-outbox.registry.d.ts +26 -0
- package/dist/core/common/services/mail-outbox.registry.js +8 -0
- package/dist/core/common/services/mail-outbox.registry.js.map +1 -0
- package/dist/core/modules/audit-log/audited.decorator.d.ts +2 -0
- package/dist/core/modules/audit-log/audited.decorator.js +10 -0
- package/dist/core/modules/audit-log/audited.decorator.js.map +1 -0
- package/dist/core/modules/audit-log/core-audit-log.constants.d.ts +13 -0
- package/dist/core/modules/audit-log/core-audit-log.constants.js +11 -0
- package/dist/core/modules/audit-log/core-audit-log.constants.js.map +1 -0
- package/dist/core/modules/audit-log/core-audit-log.controller.d.ts +9 -0
- package/dist/core/modules/audit-log/core-audit-log.controller.js +87 -0
- package/dist/core/modules/audit-log/core-audit-log.controller.js.map +1 -0
- package/dist/core/modules/audit-log/core-audit-log.models.d.ts +10 -0
- package/dist/core/modules/audit-log/core-audit-log.models.js +11 -0
- package/dist/core/modules/audit-log/core-audit-log.models.js.map +1 -0
- package/dist/core/modules/audit-log/core-audit-log.module.d.ts +13 -0
- package/dist/core/modules/audit-log/core-audit-log.module.js +41 -0
- package/dist/core/modules/audit-log/core-audit-log.module.js.map +1 -0
- package/dist/core/modules/audit-log/core-audit-log.service.d.ts +49 -0
- package/dist/core/modules/audit-log/core-audit-log.service.js +169 -0
- package/dist/core/modules/audit-log/core-audit-log.service.js.map +1 -0
- package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js +4 -0
- package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js.map +1 -1
- package/dist/core/modules/mail-outbox/core-mail-outbox.constants.d.ts +22 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.constants.js +23 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.constants.js.map +1 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.controller.d.ts +10 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.controller.js +80 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.controller.js.map +1 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.models.d.ts +17 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.models.js +17 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.models.js.map +1 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.module.d.ts +12 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.module.js +42 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.module.js.map +1 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.service.d.ts +59 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.service.js +280 -0
- package/dist/core/modules/mail-outbox/core-mail-outbox.service.js.map +1 -0
- package/dist/core/modules/migrate/cli/migrate-cli.js +20 -2
- package/dist/core/modules/migrate/cli/migrate-cli.js.map +1 -1
- package/dist/core/modules/throttler/core-throttler.config.d.ts +16 -0
- package/dist/core/modules/throttler/core-throttler.config.js +107 -0
- package/dist/core/modules/throttler/core-throttler.config.js.map +1 -0
- package/dist/core/modules/throttler/core-throttler.constants.d.ts +10 -0
- package/dist/core/modules/throttler/core-throttler.constants.js +11 -0
- package/dist/core/modules/throttler/core-throttler.constants.js.map +1 -0
- package/dist/core/modules/throttler/core-throttler.decorators.d.ts +1 -0
- package/dist/core/modules/throttler/core-throttler.decorators.js +2 -0
- package/dist/core/modules/throttler/core-throttler.decorators.js.map +1 -0
- package/dist/core/modules/throttler/core-throttler.guard.d.ts +15 -0
- package/dist/core/modules/throttler/core-throttler.guard.js +65 -0
- package/dist/core/modules/throttler/core-throttler.guard.js.map +1 -0
- package/dist/core/modules/throttler/core-throttler.models.d.ts +1 -0
- package/dist/core/modules/throttler/core-throttler.models.js +11 -0
- package/dist/core/modules/throttler/core-throttler.models.js.map +1 -0
- package/dist/core/modules/throttler/core-throttler.module.d.ts +12 -0
- package/dist/core/modules/throttler/core-throttler.module.js +71 -0
- package/dist/core/modules/throttler/core-throttler.module.js.map +1 -0
- package/dist/core/modules/throttler/core-throttler.storages.d.ts +43 -0
- package/dist/core/modules/throttler/core-throttler.storages.js +174 -0
- package/dist/core/modules/throttler/core-throttler.storages.js.map +1 -0
- package/dist/core/modules/user/core-user.service.js +2 -2
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/core.module.js +26 -0
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/docs/REQUEST-LIFECYCLE.md +7 -0
- package/docs/security-overrides.md +20 -8
- package/migration-guides/12.11.x-to-12.12.x.md +182 -0
- package/package.json +24 -23
- package/src/core/common/interfaces/server-options.interface.ts +311 -1
- package/src/core/common/persistence/audit-log.registry.ts +150 -0
- package/src/core/common/services/core-trust-proxy.initializer.ts +5 -4
- package/src/core/common/services/crud.service.ts +128 -33
- package/src/core/common/services/email.service.ts +101 -9
- package/src/core/common/services/leased-interval.ts +123 -0
- package/src/core/common/services/mail-outbox.registry.ts +53 -0
- package/src/core/modules/audit-log/README.md +95 -0
- package/src/core/modules/audit-log/audited.decorator.ts +27 -0
- package/src/core/modules/audit-log/core-audit-log.constants.ts +28 -0
- package/src/core/modules/audit-log/core-audit-log.controller.ts +77 -0
- package/src/core/modules/audit-log/core-audit-log.models.ts +34 -0
- package/src/core/modules/audit-log/core-audit-log.module.ts +54 -0
- package/src/core/modules/audit-log/core-audit-log.service.ts +270 -0
- package/src/core/modules/better-auth/core-better-auth-email-verification.service.ts +4 -0
- package/src/core/modules/mail-outbox/README.md +88 -0
- package/src/core/modules/mail-outbox/core-mail-outbox.constants.ts +42 -0
- package/src/core/modules/mail-outbox/core-mail-outbox.controller.ts +60 -0
- package/src/core/modules/mail-outbox/core-mail-outbox.models.ts +46 -0
- package/src/core/modules/mail-outbox/core-mail-outbox.module.ts +52 -0
- package/src/core/modules/mail-outbox/core-mail-outbox.service.ts +390 -0
- package/src/core/modules/migrate/README.md +4 -1
- package/src/core/modules/migrate/cli/migrate-cli.ts +30 -2
- package/src/core/modules/throttler/README.md +107 -0
- package/src/core/modules/throttler/core-throttler.config.ts +162 -0
- package/src/core/modules/throttler/core-throttler.constants.ts +33 -0
- package/src/core/modules/throttler/core-throttler.decorators.ts +14 -0
- package/src/core/modules/throttler/core-throttler.guard.ts +109 -0
- package/src/core/modules/throttler/core-throttler.models.ts +23 -0
- package/src/core/modules/throttler/core-throttler.module.ts +95 -0
- package/src/core/modules/throttler/core-throttler.storages.ts +299 -0
- package/src/core/modules/user/core-user.service.ts +3 -2
- package/src/core.module.ts +46 -0
- package/src/index.ts +36 -0
|
@@ -61,6 +61,7 @@ proves the build loads and runs with them unresolvable. Rules: `.claude/rules/pe
|
|
|
61
61
|
|
|
62
62
|
| Module | Purpose |
|
|
63
63
|
|--------|---------|
|
|
64
|
+
| **AuditLog** | Opt-in (`auditLog`): who created, changed, deleted or restored which record of the models carrying `@Audited()` / named in `auditLog.models`, field names only, never values; `CrudService` reports through `common/persistence/audit-log.registry.ts`; `GET /audit-log` for admins, retention purge |
|
|
64
65
|
| **ApiToken** | Opt-in bearer tokens: USER tokens (act as their user, no global roles) and TENANT tokens (lowest tenant role, own tenant only); deny by default via `@ApiTokenScopes()`; signed short-lived assertions |
|
|
65
66
|
| **Auth** | JWT authentication, refresh tokens, role-based access |
|
|
66
67
|
| **BetterAuth** | Modern auth integration (2FA, Passkey, Social) |
|
|
@@ -68,10 +69,12 @@ proves the build loads and runs with them unresolvable. Rules: `.claude/rules/pe
|
|
|
68
69
|
| **File** | File upload/download with GridFS storage |
|
|
69
70
|
| **HealthCheck** | Application health monitoring |
|
|
70
71
|
| **Hub** | Build-free ADMIN-gated operator cockpit at `/hub` (config-gated per environment; 17 panels, runtime collectors, mailbox, admin actions) |
|
|
72
|
+
| **MailOutbox** | Opt-in (`mailOutbox`): every `EmailService` mail stored first, delivered by exactly one replica (atomic claim), retried with backoff, failed mails listed for admins |
|
|
71
73
|
| **Migrate** | Database migration utilities |
|
|
72
74
|
| **Permissions** | ADMIN-gated security-map report (routes + roles + `@Restricted` fields); also surfaced in the Hub's "Routes / Permissions" panel |
|
|
73
75
|
| **Sync** | Opt-in (`sync`) offline sync for models declared `@PersistedModel({ sync })`: pull by cursor, push with idempotency and conflict strategies, resync on access loss — through the model's CrudService; change hints over SSE and GraphQL, filtered per subscriber; hourly tombstone purge under a lease |
|
|
74
76
|
| **SystemSetup** | Initial admin creation for fresh deployments |
|
|
77
|
+
| **Throttler** | Opt-in (`throttler`): rate limit for a project's routes on top of `@nestjs/throttler` (`@Throttle()` / `@SkipThrottle()`), first global guard, counters in memory, Redis or the project's database |
|
|
75
78
|
| **Tus** | Resumable file uploads via tus.io protocol |
|
|
76
79
|
| **User** | Core user management functionality |
|
|
77
80
|
|
|
@@ -303,6 +303,9 @@ This pattern is currently applied to:
|
|
|
303
303
|
| SMTP TLS Mode | `email.smtp.secure` + `SMTP_REQUIRE_TLS` | Derived from the port | **`secure` follows `SMTP_PORT` unless set to `'true'`/`'false'`.** It is not an independent setting: 465 negotiates TLS immediately, everything else upgrades via STARTTLS. The production profile shipped 587 + `secure: true` — a pair that cannot connect — so a deployment configuring only host and credentials sent NO mail, invisibly, because authentication mail is not awaited. Only the two canonical values override; anything else defers to the port, which is the only rule under which no input produces an unconnectable pair. `requireTLS` defaults to **true**: `secure: false` alone means opportunistic STARTTLS, and an on-path attacker stripping the capability line gets credentials and a live reset link in plaintext. `EmailService` warns once when the resolved pair cannot connect — reported, not overruled. Implementation: `config.helper.ts` → `resolveSmtpSecure()` / `isImpossibleSmtpTlsCombination()` |
|
|
304
304
|
| Mail Reply-To | `email.defaultReplyTo` | Explicit Value — absent = no header | **Absent → no `Reply-To` header, exactly as before (12.3.2+).** A string (an address, or `"Name" <address>`) becomes the Reply-To of every mail `EmailService.sendMail()` sends; a call overrides it with `replyTo`, and `replyTo: false` (or `''`) sends that one mail without it. Env: `NSC__EMAIL__DEFAULT_REPLY_TO`. A value that is not a string is ignored with one warning — a misconfigured default must not stop password-reset or verification mail. SMTP path only (`email.smtp`, nodemailer, Hub capture unaffected): Brevo and Mailjet templates carry their own reply-to. Pinned by `tests/unit/email-smtp-roundtrip.spec.ts` (Reply-To block, real SMTP). Implementation: `common/services/email.service.ts` → `resolveReplyTo()` |
|
|
305
305
|
| Auth Mail App Name | `betterAuth.emailVerification.appName` | Explicit Value — absent = the `package.json` name | **Absent or empty → the formatted `name` of the working directory's `package.json` (`my-app` → `My App`, `'Nest Server'` without one), exactly as before (12.8.3+).** A string becomes the application name in the verification and password-reset mails: the subject (`<appName> - Verify your email address`, `<appName> - Reset your password`), the EJS variable `appName` and the Brevo parameter `appName`; trimmed. Env: `NSC__BETTER_AUTH__EMAIL_VERIFICATION__APP_NAME`. Exists because in a monorepo the working directory is the API package, whose name (`api`) became the subject of every auth mail; before, only an override of `getAppName()` changed it, which still works and wins. A value that is not a string is ignored with one warning — a misconfigured name must not stop an auth mail. Mails only: authenticator apps read `twoFactor.appName`, passkey prompts `passkey.rpName`. **With verification switched off it needs `enabled: false` beside it** (`{ enabled: false, appName }`, or `NSC__BETTER_AUTH__EMAIL_VERIFICATION__ENABLED=false` next to the variable): `emailVerification: false` keeps no settings, and an object without `enabled: false` — what the variable alone makes of `false` — switches verification on, so every unverified user's sign-in answers 401. The reset mail goes through this service with verification off too. Pinned by `tests/unit/better-auth-mail-app-name.spec.ts` (mutation `mail-app-name-config-ignored`). Implementation: `core-better-auth-email-verification.service.ts` → `resolveAppName()` |
|
|
306
|
+
| Rate Limit for Project Routes | `throttler` | Boolean Shorthand + Presence Implies Enabled — absent = off | **Absent → no guard, no storage, no table (12.12.0, DEV-4431).** `true` / `{}` registers `CoreThrottlerModule` FIRST in `CoreModule`'s imports, so `CoreThrottlerGuard` (`@nestjs/throttler`'s `ThrottlerGuard`, request resolved through `resolveGuardRequest()`) is the first global guard: an over-limit client gets 429, `Retry-After` and `#LTNS_0020` before the role guards authenticate it. Defaults: `limit: 10`, `ttl: 60000` (ms, `@nestjs/throttler`'s unit), `blockDuration: ttl`, `routes: 'decorated'` (only routes whose method or controller carries `@Throttle()`, by the throttlers it names — implemented as a per-throttler `skipIf`; `'all'` limits every route unless `@SkipThrottle()`), `setHeaders: true`, `ipv6SubnetPrefix: 64`; `throttlers: [{ name, limit, ttl, blockDuration }]` replaces the `default` throttler. An invalid number → its default with a warning (Family C: never "no limit", never `0`, which would refuse everything). `storage`: unset → `'redis'` with `redis`, else `'memory'` (`@nestjs/throttler`'s `ThrottlerStorageService`); `'database'` → the framework model `CoreThrottlerCounter` (table `throttler_counters`) through `CorePersistenceModule.forFeature()`, a fixed window per throttler and client counted with ONE atomic `updateOne` per step, exact across replicas without Redis; `'redis'` → one Lua script per hit. An explicit storage that cannot work (`'redis'` without `redis`, `'database'` with `database: false`, an unknown name) stops the boot; an unreachable Redis / database falls back to memory, logged once per transition — never 500, never "allowed". Counted per `request.ip`, so the trust-proxy boot warning lists `throttler` too; a request without an address (a GraphQL operation over the WebSocket, an HTTP request whose client already closed the connection) per signed-in user, else by the WebSocket's upgrade address, else in one shared bucket — never uncounted (mutation `throttler-skips-addressless-request`). `@Throttle` / `@SkipThrottle` are re-exported from `@lenne.tech/nest-server`; a project must not import `ThrottlerModule` itself. Guard override: `CoreModule.forRoot(env, { throttler: { guard } })`. Pinned by `tests/unit/throttler.spec.ts` and `tests/throttler.e2e-spec.ts` (mutations `throttler-*`). Implementation: `src/core/modules/throttler/` |
|
|
307
|
+
| Audit Log | `auditLog` | Boolean Shorthand + Presence Implies Enabled — absent = off | **Absent → no model, no route, no listener; a write costs one `undefined` check (12.12.0, DEV-4432).** `true` / `{}` registers `CoreAuditLogModule`; its service registers itself in `common/persistence/audit-log.registry.ts`, and `CrudService.create()` / `update()` / `delete()` (variants included, `CoreUserService.create()` too) report each successful write of a model whose class carries `@Audited()` or whose name is in `models` — action, model, record id, user (`serviceOptions.currentUser`, else the request's), time and the field NAMES (create: what the input set; update: what changed, compared before and after the merge, bookkeeping fields excluded; an update that changed nothing leaves no entry). Never a value — the model has no field for one. `CoreAuditLogService.record()` logs a project's own actions (restore); `importEntries()` takes entries of another system (keeps `at`, drops every other field). Model `CoreAuditLogEntry` (table `audit_log_entries`), not tenant-scoped. `retentionDays` (365; `false` keeps; invalid → 365): hourly purge on one replica (`LeasedInterval`, `frameworkJobLeaseStore()`: Redis → SQL lease table → `cron-locks`), 1000 per batch. `GET /audit-log` (`path`), `ADMIN` plus `roles` (global, `@SkipTenantCheck()`). Not logged: writes past `CrudService` (data store, Mongoose, `pushToArray`). Overrides: `{ auditLog: { controller, service } }`. Pinned by `tests/audit-log.e2e-spec.ts` (mutations `audit-log-*`). Implementation: `src/core/modules/audit-log/` |
|
|
308
|
+
| Mail Outbox | `mailOutbox` | Boolean Shorthand + Presence Implies Enabled — absent = off | **Absent → `EmailService` sends directly, as before (12.12.0, DEV-4433).** `true` / `{}` registers `CoreMailOutboxModule`; its service registers itself in `common/services/mail-outbox.registry.ts` and `EmailService.sendMail()` stores the rendered mail (after the templates, the production `jsonTransport` guard and the Hub capture) and answers `{ accepted, messageId, outboxId, queued: true, rejected }`; Better-Auth's SMTP auth mails take the same path. Delivery at once and every `pollIntervalSeconds` (10) on every replica; a mail is CLAIMED with one atomic `updateOne` (pending and due, or a claim older than `lockSeconds`, 900), so exactly one replica sends it, with the same Message-ID on every attempt. Failure → retry after `retryDelaySeconds` (30) doubled per attempt up to `maxRetryDelaySeconds` (3600); after `maxAttempts` (10) `failed`, logged as an error with the recipient masked. A delivered mail loses its content at once (`mail: null`); `retention.sentDays` (7) / `retention.failedDays` (30), `false` keeps, hourly purge under a lease. At least once: a replica dying between the server's accept and the record leaves a claim another replica takes over. Not through the outbox: a call with its own `smtp` (credentials are never stored), Brevo / Mailjet templates. Model `CoreMailOutboxEntry` (table `mail_outbox`). `GET /mail-outbox` (no content), `POST /mail-outbox/:id/retry`; `ADMIN` plus `roles`. Overrides: `{ mailOutbox: { controller, service } }`. Pinned by `tests/mail-outbox.e2e-spec.ts` and `tests/unit/audit-log-outbox.spec.ts` (mutations `mail-outbox-*`). Implementation: `src/core/modules/mail-outbox/` |
|
|
306
309
|
| Legacy Auth Rate Limiting | `auth.rateLimit` | Presence Implies Enabled | `max: 10`, `windowSeconds: 60`. Counters live in a `RateLimitStore`: `RedisRateLimitStore` when `redis` is configured (limit enforced EXACTLY across replicas instead of `max × replicas`), else `InMemoryRateLimitStore` (previous behavior). On a Redis outage it degrades to the in-memory counter and logs once per transition — never a 500, never "allowed". `check()` / `reset()` / `clear()` are ASYNC since 11.33.0; `getStats().activeEntries` is `-1` on the Redis store |
|
|
307
310
|
| BetterAuth Rate Limiting | `betterAuth.rateLimit` | Presence Implies Enabled | `max: 10`, `windowSeconds: 60`. Same `RateLimitStore` selection, degradation and async signatures as the Legacy Auth row (namespace `better-auth`) |
|
|
308
311
|
| BetterAuth JWT Plugin | `betterAuth.jwt` | Boolean Shorthand | `expiresIn: '15m'`. **Since 12.11.0 a JWT is bound to the session it was issued from** (claim `sid`, `definePayload` in `buildPlugins()`): `verifyJwtToken()` accepts it only while that session exists, belongs to the token's `sub` and has not expired — asked through Better-Auth's adapter by id (the user's session list where sessions live only in `secondaryStorage`), cached 10 s (`jwtSessionCacheTtlMs`, protected) in the import-free leaf `core-better-auth-jwt-session.cache.ts` (10,000 entries max), and forgotten at once when Better-Auth deletes the session (`wsSessionRevocationPlugin()` → `jwtSessionEnded()`), on every replica over the user mapper's Redis invalidation channel (`{ sessionId }`). A JWT without `sid` is refused; a failed lookup refuses and is not cached. The middleware hands Better-Auth's plugin routes the JWT's OWN session (`getJwtSession()`), and `POST /iam/sign-out` revokes it — before, the user's newest session, and a JWT client's sign-out read the cookie alone and ended nothing. After a session rotation (first `verify-totp` while enabling 2FA; since 12.11.1 also `two-factor/disable` and enabling with OTP / `skipVerificationOnEnable`, whose answers name no token, recognised by the request's session token that every forwarding hands `sendBetterAuthResponse()`) the answer's token is the JWT of the new session. Pinned by `tests/unit/better-auth-jwt-session-binding.spec.ts` and `tests/better-auth-jwt-session.e2e-spec.ts` (mutations `jwt-session-*`, `jwt-payload-without-session-id`, `jwt-middleware-newest-session`, `jwt-sign-out-reads-cookie-only`) |
|
|
@@ -393,6 +396,9 @@ CoreModule.forRoot(CoreAuthService, AuthModule.forRoot(envConfig.jwt), envConfig
|
|
|
393
396
|
|
|
394
397
|
| Module | Fields | Description |
|
|
395
398
|
|--------|--------|-------------|
|
|
399
|
+
| `auditLog` | `controller`, `service` | Custom audit log read endpoint and/or service (12.12.0) |
|
|
400
|
+
| `mailOutbox` | `controller`, `service` | Custom mail outbox admin endpoints and/or service (12.12.0) |
|
|
401
|
+
| `throttler` | `guard` | Custom rate limit guard extending `CoreThrottlerGuard` (12.12.0) |
|
|
396
402
|
| `ai` | `budgetService`, `connectionResolver`, `connectionService`, `controller`, `conversationService`, `interactionService`, `mcpClientService`, `mcpOAuthService`, `modeService`, `placeholderRegistry`, `preferenceService`, `promptBuilder`, `promptHintService`, `promptService`, `resolver`, `service`, `slotService`, `toolGrantService`, `toolPolicyService`, `userSettingService` | Custom AI orchestrator, connection-resolution chain, connection/preference/budget/conversation/interaction/MCP-client services, MCP OAuth service (the consent step), slot + user-prompt + learning-hint stores, mode service, placeholder registry, tool-grant + tool-policy services, personal-settings store, endpoints |
|
|
397
403
|
| `errorCode` | `controller`, `service` | Custom error code endpoint and/or service |
|
|
398
404
|
| `healthCheck` | `readinessController`, `service` | Custom health check service (project checks via `additionalHealthIndicators(kind)`) and/or readiness controller (12.11.0) |
|
|
@@ -174,12 +174,14 @@ load-bearing (it has since grown back to as many as 20, mostly as new advisories
|
|
|
174
174
|
and they were removed, leaving `@graphql-tools/utils` and `multer`, both on an upstream EXACT pin with
|
|
175
175
|
an open advisory. Those two left on 2026-10-29 (nest-server 12.1.0), once `@nestjs/graphql` 14.1.0 and
|
|
176
176
|
`@nestjs/platform-express` 12.3.2 moved their pins past the fixes: the set was empty (`overrides: {}`,
|
|
177
|
-
written explicitly so `check:overrides` reads it as a decision) from 12.1.0 to 12.9.3.
|
|
178
|
-
|
|
179
|
-
`@nestjs/graphql` 14.2.1 exact-
|
|
177
|
+
written explicitly so `check:overrides` reads it as a decision) from 12.1.0 to 12.9.3. From 12.9.4 to 12.11.3 it held
|
|
178
|
+
`ws`: GHSA-37g9-w4hg-h9qr (high, pre-auth memory-exhaustion DoS, patched 8.23.0) covered the 8.22.1 that
|
|
179
|
+
`@nestjs/graphql` 14.2.1 exact-pinned, and the GraphQL WebSocket server ran on that copy. The advisory was published
|
|
180
180
|
by the ws maintainers on 2026-11-12 and was not yet in GitHub's global database when the entry was added, so
|
|
181
181
|
`pnpm audit` did not report it — read the advisories of a package's own repository when a release announces a
|
|
182
|
-
security fix.
|
|
182
|
+
security fix. It left in 12.12.0, once `@nestjs/graphql` 14.2.2 pinned ws 8.23.0 itself (two fresh resolves with and
|
|
183
|
+
without the entry: identical package set, one `ws@8.23.0`). `check:overrides` could not report it as UNUSED: every
|
|
184
|
+
edge resolved to the override's target either way, so only the with/without resolve shows such an entry is inert. From 12.10.0 to 12.10.1 a second entry, `minimatch` 11 -> 11.0.9: `@nestjs/cli` 12.0.13 exact-pins 11.0.5, covered by three moderate advisories (dev tooling only; the target is the newest 11.x, because an older one held every other `^11` consumer back). It left in 12.11.0, once `@nestjs/cli` 12.0.15 pinned 11.0.9 itself. Since 12.10.0 the set holds `i18next` 26 -> 26.4.4 (its only entry since 12.12.0): `@compodoc/compodoc` 2.0.0 exact-pins 26.3.3, covered by two advisories (dev tooling only); GHSA-6jcc is in GitHub's global database since 2026-11-23, GHSA-5jr9 was still repository-only at 12.12.0. An override is only necessary if removing it lets the package resolve
|
|
183
185
|
back INTO its vulnerable range (verify with a with/without lockfile diff; `pnpm audit` is the arbiter).
|
|
184
186
|
"Cheap insurance against a parent re-pinning downwards" is not a reason to keep one: `pnpm audit` and
|
|
185
187
|
`check:overrides` run on every `check` and report such a regression the day it happens. Each surviving entry carries its CVE rationale as a comment. Remove an entry once its parent dependency ships a fixed version.
|
package/.claude/rules/testing.md
CHANGED
|
@@ -34,7 +34,7 @@ mis-named suite fails the build instead of silently passing. Type-only tests
|
|
|
34
34
|
|
|
35
35
|
## Infrastructure containers (Redis + S3 + PostgreSQL + MySQL + MariaDB + MongoDB replica set)
|
|
36
36
|
|
|
37
|
-
**Twenty-
|
|
37
|
+
**Twenty-three** e2e suites talk to a **real** Redis, a **real** S3-compatible store and/or a **real**
|
|
38
38
|
PostgreSQL, MySQL, MariaDB or MongoDB replica set rather than a mock, and they **fail loudly** when it is missing — a silently skipped
|
|
39
39
|
infrastructure test is how an untested driver ships:
|
|
40
40
|
|
|
@@ -62,13 +62,14 @@ infrastructure test is how an untested driver ships:
|
|
|
62
62
|
| `tests/persistence-mysql-wiring.e2e-spec.ts` | MySQL + MariaDB |
|
|
63
63
|
| `tests/sync-contract.e2e-spec.ts` | PostgreSQL + MySQL + MariaDB + MongoDB replica set (and MongoDB) |
|
|
64
64
|
| `tests/sync-clock-skew.e2e-spec.ts` | PostgreSQL + MySQL + MongoDB replica set (and MongoDB) |
|
|
65
|
+
| `tests/throttler.e2e-spec.ts` | Redis (its Redis describes; the memory and database describes need only the run's database) |
|
|
65
66
|
|
|
66
|
-
Beyond these twenty-
|
|
67
|
+
Beyond these twenty-three, the `postgres` vitest project runs the whole e2e suite once more on PostgreSQL (see "Behaviour
|
|
67
68
|
matrices" below), so without the PostgreSQL container that project fails as a whole while `e2e` runs.
|
|
68
69
|
|
|
69
70
|
`tests/global-setup.ts` starts all six containers automatically, so `pnpm test` works from a clean
|
|
70
71
|
machine with no manual docker command. It is idempotent (a running container is reused) and never
|
|
71
|
-
fatal: without Docker every other suite still runs, and the twenty-
|
|
72
|
+
fatal: without Docker every other suite still runs, and the twenty-three above report their own actionable
|
|
72
73
|
error.
|
|
73
74
|
|
|
74
75
|
```bash
|
|
@@ -412,7 +413,7 @@ pnpm run check:mutations -- --id=<id> # one mutation
|
|
|
412
413
|
pnpm run check:mutations -- --list # the registry, without running anything
|
|
413
414
|
pnpm run check:mutations -- --allow-dirty # when the fix and its evidence share a working tree
|
|
414
415
|
pnpm run check:mutations -- --jobs=4 # N mutations at a time (default: 2, or 4 on >=12 cores)
|
|
415
|
-
pnpm run check:mutations -- --no-infra # only the
|
|
416
|
+
pnpm run check:mutations -- --no-infra # only the 529 that need no MongoDB
|
|
416
417
|
pnpm run check:mutations -- --since=<ref> # only mutations touching files changed since <ref>
|
|
417
418
|
pnpm run check:mutations -- --shard=2/4 # this job's quarter of the selection (CI splits the full run)
|
|
418
419
|
```
|
|
@@ -432,7 +433,7 @@ when the registry, a vitest config or a setup file changed, since those can move
|
|
|
432
433
|
commit, and in CI alongside the publish without blocking it. The price of caching is a cache that
|
|
433
434
|
has to model each spec's full dependency closure correctly, and getting that wrong produces a stale
|
|
434
435
|
PASS for a test that has since gone vacuous — exactly what the gate is there to prevent. Bad trade
|
|
435
|
-
at
|
|
436
|
+
at 787 mutations.
|
|
436
437
|
|
|
437
438
|
**Decided 2026-10-03 (repo owner): keep the full run.** Measured at 128 mutations, the CI job for
|
|
438
439
|
11.41.6 took **14 minutes**. The trigger to revisit is that wall time, not the mutation count —
|
|
@@ -503,9 +504,9 @@ exactly the environment where the answer matters.
|
|
|
503
504
|
|
|
504
505
|
### The cost is vitest's cold start, not the tests
|
|
505
506
|
|
|
506
|
-
Worth knowing before optimising the wrong thing: the specs behind all
|
|
507
|
+
Worth knowing before optimising the wrong thing: the specs behind all 258 e2e mutations add up to
|
|
507
508
|
**~40 seconds**. The step takes ~740s. The remaining ~700s is paying vitest's startup — process
|
|
508
|
-
spawn, transform, module graph, mongod connect, DB create and drop — once per mutation,
|
|
509
|
+
spawn, transform, module graph, mongod connect, DB create and drop — once per mutation, 787 times.
|
|
509
510
|
That work is largely single-threaded I/O and barely scales with cores: the full registry measures
|
|
510
511
|
**744s on a 12-core laptop and 777s on a 4-vCPU CI runner**.
|
|
511
512
|
|
package/CLAUDE.md
CHANGED
|
@@ -214,10 +214,11 @@ contents into a tracked file, a commit message or a PR. Pinned by `tests/unit/pu
|
|
|
214
214
|
**Key Components:**
|
|
215
215
|
- `CoreModule` - Dynamic module with GraphQL (optional, disable via `graphQl: false`), MongoDB, security
|
|
216
216
|
- `src/core/common/` - Decorators, helpers, interceptors, services
|
|
217
|
-
- `src/core/modules/` - ApiToken, Auth, BetterAuth, ErrorCode, File, HealthCheck, Hub, Migrate, Permissions, Sync, SystemSetup, Tus, User
|
|
217
|
+
- `src/core/modules/` - ApiToken, AuditLog, Auth, BetterAuth, ErrorCode, File, HealthCheck, Hub, MailOutbox, Migrate, Permissions, Sync, SystemSetup, Throttler, Tus, User
|
|
218
218
|
- **ApiToken** - Opt-in (`apiTokens`) USER and TENANT tokens + signed assertions. Denied on every route without `@ApiTokenScopes()`; all three guards share `enforceApiTokenRoute()`. See `src/core/modules/api-token/README.md`.
|
|
219
219
|
- **Hub** - Build-free ADMIN-gated operator cockpit at `/hub` (config-gated per environment; 17 panels, runtime collectors, mailbox, admin actions). See `src/core/modules/hub/README.md`.
|
|
220
220
|
- **Permissions** - ADMIN-gated security-map report (routes + roles + `@Restricted` fields); also surfaced in the Hub's "Routes / Permissions" panel.
|
|
221
|
+
- **AuditLog / MailOutbox / Throttler** (12.12.0) - Opt-in (`auditLog`, `mailOutbox`, `throttler`): who changed which record (field names, never values, reported by `CrudService`); every mail stored first and delivered by exactly one replica with retries; a rate limit for a project's routes on `@nestjs/throttler` with counters in memory, Redis or the database. Absent config = nothing registered. See each module's README.
|
|
221
222
|
- **Sync** - Opt-in (`sync`) offline sync: `GET/POST /sync/{model}` for models declared `@PersistedModel({ sync })` whose CrudService carries `@SyncService()`, change hints over SSE (`GET /sync/hints`) and GraphQL (`syncHint`), hourly tombstone purge; protocol in `docs/offline-sync-protocol.md`, client duties in the module's `SECURITY.md`, reference test clients in `tests/clients/`. See `src/core/modules/sync/README.md`.
|
|
222
223
|
- **Optional central infrastructure** (11.33.0+) - `CoreRedisService` (`redis` config) and `CoreS3Service` (`s3` config) turn process-local state into shared state for multi-replica deployments: rate-limit counters, cron deduplication, GraphQL subscriptions, tenant-cache and IAM role-cache invalidation, Hub collectors, file storage (`file.storage: 's3'`; the driver is otherwise derived — S3 → GridFS → filesystem — and an unavailable one fails the boot rather than falling back) and TUS staging. Both are inert without their config, and their client libraries are **optional peer dependencies** (`ioredis`, `bullmq`, `@aws-sdk/client-s3`, `@aws-sdk/lib-storage`, `@aws-sdk/s3-request-presigner`, `@tus/s3-store`) — a project that uses neither installs nothing extra. When adding a distributed feature, always keep the non-configured fallback path.
|
|
223
224
|
|
package/FRAMEWORK-API.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @lenne.tech/nest-server — Framework API Reference
|
|
2
2
|
|
|
3
|
-
> Auto-generated from source code as of 2026-11-
|
|
3
|
+
> Auto-generated from source code as of 2026-11-26 (v12.12.0)
|
|
4
4
|
> File: `FRAMEWORK-API.md` — compact, machine-readable API surface for Claude Code
|
|
5
5
|
|
|
6
6
|
## CoreModule.forRoot()
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
- `ai?`: `boolean | IAi` — Configuration for the AI assistant module.
|
|
16
16
|
- `appUrl?`: `string` — Base URL of the frontend/app application.
|
|
17
17
|
- `apiTokens?`: `boolean | IApiTokens` (default: `undefined (disabled)`) — API tokens: bearer credentials for machine clients and embedded pages that cannot carry a session
|
|
18
|
+
- `auditLog?`: `boolean | IAuditLog` — Audit log (DEV-4432): who created, changed, deleted or restored which record of the models a project names, and
|
|
18
19
|
- `auth?`: `IAuth` — Authentication system configuration
|
|
19
20
|
- `automaticObjectIdFiltering?`: `boolean` — Automatically detect ObjectIds in string values in FilterQueries
|
|
20
21
|
- `baseUrl?`: `string` — Base URL of the API server.
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
- `jwt?`: `IJwt & JwtModuleOptions & { refresh?: IJwt & { renewal?: boolean; }; sameToke...` — Configuration of JavaScript Web Token (JWT) module
|
|
44
45
|
- `loadLocalConfig?`: `string | boolean` (default: `false`) — Load a local configuration file and merge it over this environment's configuration
|
|
45
46
|
- `logExceptions?`: `boolean` — Log exceptions (for better debugging)
|
|
47
|
+
- `mailOutbox?`: `boolean | IMailOutbox` — Mail outbox (DEV-4433): every mail of `EmailService` — the framework's auth mails included — is stored first and
|
|
46
48
|
- `mongoose?`: `{ collation?: CollationOptions; modelDocumentation?: boolean; options?: Mongo...` — Configuration for Mongoose
|
|
47
49
|
- `multiTenancy?`: `IMultiTenancy` (default: `undefined (disabled)`) — Multi-tenancy configuration for tenant-based data isolation.
|
|
48
50
|
- `permissions?`: `boolean | IPermissions` (default: `undefined (disabled)`) — Permissions report module (development tool).
|
|
@@ -57,6 +59,7 @@
|
|
|
57
59
|
- `swagger?`: `boolean` (default: `undefined (served only in `local`, `ci` and `e2e`)`) — Whether `setupSwagger()` serves the API documentation (12.7.0+), decided by `isSwaggerEnabled()`.
|
|
58
60
|
- `systemSetup?`: `ISystemSetup` — System setup configuration for initial admin creation.
|
|
59
61
|
- `templates?`: `{ engine?: string; path?: string; }` — Templates
|
|
62
|
+
- `throttler?`: `boolean | IThrottler` — Rate limit for a project's routes, on top of `@nestjs/throttler` (DEV-4431): `@Throttle()` on a route or a
|
|
60
63
|
- `trustProxy?`: `string | number | boolean | string[]` (default: `false (Express default — the forwarded chain is not trusted)`) — Express `trust proxy` setting — how far up the `X-Forwarded-For` chain this app believes.
|
|
61
64
|
- `tus?`: `boolean | ITusConfig` — TUS resumable upload configuration.
|
|
62
65
|
|
|
@@ -226,6 +229,9 @@ When `passkey` is enabled, `trustedOrigins` is required (compile-time enforcemen
|
|
|
226
229
|
### ICoreModuleOverrides
|
|
227
230
|
|
|
228
231
|
- `apiToken?`: `{ model?: Type<any>; service?: Type<any>; }` — Override API token collaborators with project-specific subclasses (`apiTokens` config).
|
|
232
|
+
- `auditLog?`: `{ controller?: Type<any>; service?: Type<any>; }` — Override the audit log's read endpoint and/or service (`auditLog` config).
|
|
233
|
+
- `mailOutbox?`: `{ controller?: Type<any>; service?: Type<any>; }` — Override the mail outbox's admin endpoints and/or service (`mailOutbox` config).
|
|
234
|
+
- `throttler?`: `{ guard?: Type<any>; }` — Override the rate limit guard (`throttler` config). `guard` must extend `CoreThrottlerGuard` (e.g. to count a
|
|
229
235
|
- `sync?`: `{ controller?: Type<any>; hintsController?: Type<any>; resolver?: Type<any>; ...` — Override the offline sync endpoints, the hint subscription and their service (`sync` config).
|
|
230
236
|
- `ai?`: `{ budgetService?: Type<any>; connectionResolver?: Type<any>; connectionServic...` — Override AI module collaborators with project-specific subclasses.
|
|
231
237
|
- `betterAuth?`: `{ controller?: Type<any>; resolver?: Type<any>; }` — Override BetterAuth controller and/or resolver.
|
|
@@ -326,6 +332,7 @@ Generic: `CrudService<Model, CreateInput, UpdateInput>`
|
|
|
326
332
|
- `async aggregateForce(pipeline: PipelineStage[], serviceOptions?: ServiceOptions)`: `Promise<T>` — Aggregate without checks or restrictions
|
|
327
333
|
- `async aggregateRaw(pipeline: PipelineStage[], serviceOptions?: ServiceOptions)`: `Promise<T>` — Aggregate without checks, restrictions or preparations
|
|
328
334
|
- `async create(input: PlainObject<CreateInput>, serviceOptions?: ServiceOptions)`: `Promise<Model>` — Create item
|
|
335
|
+
- `async createInProcess(data: { input?: any; }, serviceOptions?: ServiceOptions)`: `Promise<any>` — The write of `create()`, inside `process()`
|
|
329
336
|
- `async createForce(input: PlainObject<CreateInput>, serviceOptions?: ServiceOptions)`: `Promise<Model>` — Create item without checks or restrictions
|
|
330
337
|
- `async createRaw(input: PlainObject<CreateInput>, serviceOptions?: ServiceOptions)`: `Promise<Model>` — Create item without checks, restrictions or preparations
|
|
331
338
|
- `distinct(property: string, serviceOptions?: ServiceOptions)`: `Promise<string[]>` — Get distinct values of a property
|
|
@@ -355,6 +362,10 @@ Generic: `CrudService<Model, CreateInput, UpdateInput>`
|
|
|
355
362
|
- `async updateForce(id: string, input: PlainObject<UpdateInput>, serviceOptions?: ServiceOptions)`: `Promise<Model>` — Update item via ID without checks or restrictions
|
|
356
363
|
- `async updateRaw(id: string, input: PlainObject<UpdateInput>, serviceOptions?: ServiceOptions)`: `Promise<Model>` — Update item via ID without checks, restrictions or preparations
|
|
357
364
|
- `async delete(id: string, serviceOptions?: ServiceOptions)`: `Promise<Model>` — Delete item via ID
|
|
365
|
+
- `auditBefore(stored: Record<string, any>, input: unknown)`: `Map<string, string>` — The stored values of the fields an update names, compared after the write; `undefined` when nobody logs
|
|
366
|
+
- `async auditCreated(created: R, input: unknown, serviceOptions?: ServiceOptions)`: `Promise<R>` — Log a created record with the names of the fields its input set; answers the record
|
|
367
|
+
- `async auditUpdated(id: string, before: Map<string, string>, written: Record<string, any>, serviceOptions?: ServiceOptions)`: `Promise<void>` — Log an update with the names of the fields whose value changed; an update that changed nothing is not logged
|
|
368
|
+
- `async reportAudit(action: AuditAction, recordId: string, fields: string[], serviceOptions?: ServiceOptions)`: `Promise<void>` — Hand a successful write to the audit log — names only, never values. A no-op without the module or for a model it
|
|
358
369
|
- `withTombstones(query: Q, serviceOptions?: ServiceOptions)`: `Q` — A Mongoose query or aggregation that also sees tombstones when the caller asked (`includeTombstones`)
|
|
359
370
|
- `expectedVersionOf(serviceOptions?: ServiceOptions)`: `number` — `serviceOptions.expectedVersion`, checked; only a synchronized model has a version
|
|
360
371
|
- `assertVersion(id: string, stored: any, expectedVersion: number)`: `void` — The early answer to a conditional change on a record that already has another version
|
|
@@ -382,17 +393,20 @@ Generic: `CrudService<Model, CreateInput, UpdateInput>`
|
|
|
382
393
|
|--------|------|------|
|
|
383
394
|
| `ai` | README, CHECKLIST | `src/core/modules/ai/` |
|
|
384
395
|
| `api-token` | README, CHECKLIST | `src/core/modules/api-token/` |
|
|
396
|
+
| `audit-log` | README | `src/core/modules/audit-log/` |
|
|
385
397
|
| `auth` | README | `src/core/modules/auth/` |
|
|
386
398
|
| `better-auth` | README, CHECKLIST | `src/core/modules/better-auth/` |
|
|
387
399
|
| `error-code` | CHECKLIST | `src/core/modules/error-code/` |
|
|
388
400
|
| `file` | README, CHECKLIST | `src/core/modules/file/` |
|
|
389
401
|
| `health-check` | — | `src/core/modules/health-check/` |
|
|
390
402
|
| `hub` | README, CHECKLIST | `src/core/modules/hub/` |
|
|
403
|
+
| `mail-outbox` | README | `src/core/modules/mail-outbox/` |
|
|
391
404
|
| `migrate` | README | `src/core/modules/migrate/` |
|
|
392
405
|
| `permissions` | README, CHECKLIST | `src/core/modules/permissions/` |
|
|
393
406
|
| `sync` | README, CHECKLIST | `src/core/modules/sync/` |
|
|
394
407
|
| `system-setup` | README, CHECKLIST | `src/core/modules/system-setup/` |
|
|
395
408
|
| `tenant` | README, CHECKLIST | `src/core/modules/tenant/` |
|
|
409
|
+
| `throttler` | README | `src/core/modules/throttler/` |
|
|
396
410
|
| `tus` | README, CHECKLIST | `src/core/modules/tus/` |
|
|
397
411
|
| `user` | — | `src/core/modules/user/` |
|
|
398
412
|
|
|
@@ -56,4 +56,4 @@ export declare const badRequestSchema: {
|
|
|
56
56
|
};
|
|
57
57
|
type: string;
|
|
58
58
|
};
|
|
59
|
-
export declare function ApiCommonErrorResponses():
|
|
59
|
+
export declare function ApiCommonErrorResponses(): ClassDecorator & MethodDecorator & ParameterDecorator & ((target: object, propertyKey?: string | symbol, descriptor?: undefined) => void);
|
|
@@ -311,6 +311,7 @@ export interface IServerOptions {
|
|
|
311
311
|
ai?: boolean | IAi;
|
|
312
312
|
appUrl?: string;
|
|
313
313
|
apiTokens?: boolean | IApiTokens;
|
|
314
|
+
auditLog?: boolean | IAuditLog;
|
|
314
315
|
auth?: IAuth;
|
|
315
316
|
automaticObjectIdFiltering?: boolean;
|
|
316
317
|
baseUrl?: string;
|
|
@@ -403,6 +404,7 @@ export interface IServerOptions {
|
|
|
403
404
|
};
|
|
404
405
|
loadLocalConfig?: boolean | string;
|
|
405
406
|
logExceptions?: boolean;
|
|
407
|
+
mailOutbox?: boolean | IMailOutbox;
|
|
406
408
|
mongoose?: {
|
|
407
409
|
collation?: CollationOptions;
|
|
408
410
|
modelDocumentation?: boolean;
|
|
@@ -465,6 +467,7 @@ export interface IServerOptions {
|
|
|
465
467
|
engine?: string;
|
|
466
468
|
path?: string;
|
|
467
469
|
};
|
|
470
|
+
throttler?: boolean | IThrottler;
|
|
468
471
|
trustProxy?: boolean | number | string | string[];
|
|
469
472
|
tus?: boolean | ITusConfig;
|
|
470
473
|
}
|
|
@@ -498,6 +501,46 @@ export interface IS3Config {
|
|
|
498
501
|
socketTimeoutMs?: number;
|
|
499
502
|
stagingBucket?: string;
|
|
500
503
|
}
|
|
504
|
+
export interface IThrottlerLimit {
|
|
505
|
+
blockDuration?: number;
|
|
506
|
+
limit: number;
|
|
507
|
+
name?: string;
|
|
508
|
+
ttl: number;
|
|
509
|
+
}
|
|
510
|
+
export interface IThrottler {
|
|
511
|
+
blockDuration?: number;
|
|
512
|
+
enabled?: boolean;
|
|
513
|
+
errorMessage?: string;
|
|
514
|
+
ignoreUserAgents?: RegExp[];
|
|
515
|
+
ipv6SubnetPrefix?: number;
|
|
516
|
+
limit?: number;
|
|
517
|
+
routes?: 'all' | 'decorated';
|
|
518
|
+
setHeaders?: boolean;
|
|
519
|
+
storage?: 'database' | 'memory' | 'redis';
|
|
520
|
+
throttlers?: IThrottlerLimit[];
|
|
521
|
+
ttl?: number;
|
|
522
|
+
}
|
|
523
|
+
export interface IAuditLog {
|
|
524
|
+
enabled?: boolean;
|
|
525
|
+
models?: string[];
|
|
526
|
+
path?: string;
|
|
527
|
+
retentionDays?: false | number;
|
|
528
|
+
roles?: string[];
|
|
529
|
+
}
|
|
530
|
+
export interface IMailOutbox {
|
|
531
|
+
enabled?: boolean;
|
|
532
|
+
lockSeconds?: number;
|
|
533
|
+
maxAttempts?: number;
|
|
534
|
+
maxRetryDelaySeconds?: number;
|
|
535
|
+
path?: string;
|
|
536
|
+
pollIntervalSeconds?: number;
|
|
537
|
+
retention?: {
|
|
538
|
+
failedDays?: false | number;
|
|
539
|
+
sentDays?: false | number;
|
|
540
|
+
};
|
|
541
|
+
retryDelaySeconds?: number;
|
|
542
|
+
roles?: string[];
|
|
543
|
+
}
|
|
501
544
|
export interface ISync {
|
|
502
545
|
cursorSecret?: string;
|
|
503
546
|
enabled?: boolean;
|
|
@@ -622,6 +665,17 @@ export interface ICoreModuleOverrides {
|
|
|
622
665
|
model?: Type<any>;
|
|
623
666
|
service?: Type<any>;
|
|
624
667
|
};
|
|
668
|
+
auditLog?: {
|
|
669
|
+
controller?: Type<any>;
|
|
670
|
+
service?: Type<any>;
|
|
671
|
+
};
|
|
672
|
+
mailOutbox?: {
|
|
673
|
+
controller?: Type<any>;
|
|
674
|
+
service?: Type<any>;
|
|
675
|
+
};
|
|
676
|
+
throttler?: {
|
|
677
|
+
guard?: Type<any>;
|
|
678
|
+
};
|
|
625
679
|
sync?: {
|
|
626
680
|
controller?: Type<any>;
|
|
627
681
|
hintsController?: Type<any>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type AuditAction = 'create' | 'delete' | 'restore' | 'update' | (string & {});
|
|
2
|
+
export interface AuditWrite {
|
|
3
|
+
action: AuditAction;
|
|
4
|
+
fields: string[];
|
|
5
|
+
model: string;
|
|
6
|
+
recordId: string;
|
|
7
|
+
userId?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AuditLogListener {
|
|
10
|
+
isAudited(model: string, modelClass?: Function): boolean;
|
|
11
|
+
recordWrite(write: AuditWrite): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function setAuditLogListener(value: AuditLogListener | undefined): void;
|
|
14
|
+
export declare function getAuditLogListener(): AuditLogListener | undefined;
|
|
15
|
+
export declare const AUDIT_IGNORED_FIELDS: ReadonlySet<string>;
|
|
16
|
+
export declare function auditFingerprint(value: unknown): string;
|
|
17
|
+
export declare function auditInputFields(input: Record<string, any> | null | undefined): string[];
|
|
18
|
+
export declare function auditSnapshot(stored: Record<string, any> | null | undefined, input: Record<string, any> | null | undefined): Map<string, string>;
|
|
19
|
+
export declare function auditChangedFields(snapshot: Map<string, string>, written: Record<string, any>): string[];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
let listener;
|
|
2
|
+
export function setAuditLogListener(value) {
|
|
3
|
+
listener = value;
|
|
4
|
+
}
|
|
5
|
+
export function getAuditLogListener() {
|
|
6
|
+
return listener;
|
|
7
|
+
}
|
|
8
|
+
export const AUDIT_IGNORED_FIELDS = new Set([
|
|
9
|
+
'_id',
|
|
10
|
+
'createdAt',
|
|
11
|
+
'createdBy',
|
|
12
|
+
'id',
|
|
13
|
+
'syncAt',
|
|
14
|
+
'syncSeq',
|
|
15
|
+
'updatedAt',
|
|
16
|
+
'updatedBy',
|
|
17
|
+
'version',
|
|
18
|
+
]);
|
|
19
|
+
const MAX_DEPTH = 20;
|
|
20
|
+
function normalize(value, depth) {
|
|
21
|
+
if (value === undefined || value === null) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (depth > MAX_DEPTH) {
|
|
25
|
+
return { $deep: Math.random() };
|
|
26
|
+
}
|
|
27
|
+
if (value instanceof Date) {
|
|
28
|
+
return Number.isNaN(value.getTime()) ? 'Invalid Date' : value.toISOString();
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === 'bigint') {
|
|
31
|
+
return { $bigint: value.toString() };
|
|
32
|
+
}
|
|
33
|
+
if (typeof value !== 'object') {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
const object = value;
|
|
37
|
+
if (typeof object.toHexString === 'function') {
|
|
38
|
+
return object.toHexString();
|
|
39
|
+
}
|
|
40
|
+
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(object)) {
|
|
41
|
+
return object.toString('base64');
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(object)) {
|
|
44
|
+
return object.map((item) => normalize(item, depth + 1));
|
|
45
|
+
}
|
|
46
|
+
const plain = typeof object.toObject === 'function' ? object.toObject() : object;
|
|
47
|
+
return Object.fromEntries(Object.keys(plain)
|
|
48
|
+
.filter((key) => plain[key] !== undefined)
|
|
49
|
+
.sort()
|
|
50
|
+
.map((key) => [key, normalize(plain[key], depth + 1)]));
|
|
51
|
+
}
|
|
52
|
+
export function auditFingerprint(value) {
|
|
53
|
+
try {
|
|
54
|
+
return JSON.stringify(normalize(value, 0));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return `{"$uncomparable":${Math.random()}}`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function auditInputFields(input) {
|
|
61
|
+
if (!input || typeof input !== 'object') {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
return Object.keys(input)
|
|
65
|
+
.filter((key) => input[key] !== undefined && !AUDIT_IGNORED_FIELDS.has(key))
|
|
66
|
+
.sort();
|
|
67
|
+
}
|
|
68
|
+
export function auditSnapshot(stored, input) {
|
|
69
|
+
const snapshot = new Map();
|
|
70
|
+
for (const key of auditInputFields(input)) {
|
|
71
|
+
snapshot.set(key, auditFingerprint(stored?.[key]));
|
|
72
|
+
}
|
|
73
|
+
return snapshot;
|
|
74
|
+
}
|
|
75
|
+
export function auditChangedFields(snapshot, written) {
|
|
76
|
+
const changed = [];
|
|
77
|
+
for (const [key, before] of snapshot) {
|
|
78
|
+
if (auditFingerprint(written?.[key]) !== before) {
|
|
79
|
+
changed.push(key);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return changed.sort();
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=audit-log.registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log.registry.js","sourceRoot":"","sources":["../../../../src/core/common/persistence/audit-log.registry.ts"],"names":[],"mappings":"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"}
|
|
@@ -49,7 +49,7 @@ let CoreTrustProxyInitializer = CoreTrustProxyInitializer_1 = class CoreTrustPro
|
|
|
49
49
|
'(e.g. `trustProxy: 1`), or `trustProxy: false` if nothing proxies it — which also silences this warning.');
|
|
50
50
|
}
|
|
51
51
|
enabledIpRateLimiters() {
|
|
52
|
-
return ['auth.rateLimit', 'betterAuth.rateLimit'].filter((path) => {
|
|
52
|
+
return ['auth.rateLimit', 'betterAuth.rateLimit', 'throttler'].filter((path) => {
|
|
53
53
|
const config = ConfigService.getFastButReadOnly(path);
|
|
54
54
|
if (config === undefined || config === null || config === false) {
|
|
55
55
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-trust-proxy.initializer.js","sourceRoot":"","sources":["../../../../src/core/common/services/core-trust-proxy.initializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAwC,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,MAAM,WAAW,GAAG,aAAa,CAAC;AAe3B,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IAGO;IAFxB,MAAM,GAAG,IAAI,MAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;IAEvE,YAA2C,eAAiC;QAAjC,oBAAe,GAAf,eAAe,CAAkB;IAAG,CAAC;IAShF,YAAY;QACV,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACxC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACjC,IAAI,CAAC,GAAG,EAAE,CAAC;YAGT,OAAO;QACT,CAAC;QAED,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,gCAAgC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,mDAAmD,CAC9G,CAAC;IACJ,CAAC;IAaD,sBAAsB;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC9C,IAAI,IAAI,CAAC,aAAa,EAAE,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC3D,OAAO;QACT,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACjC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,6BAA6B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,0CAA0C;YACxF,6GAA6G;YAC7G,2GAA2G;YAC3G,iGAAiG;YACjG,0GAA0G,CAC7G,CAAC;IACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"core-trust-proxy.initializer.js","sourceRoot":"","sources":["../../../../src/core/common/services/core-trust-proxy.initializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAwC,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,MAAM,WAAW,GAAG,aAAa,CAAC;AAe3B,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IAGO;IAFxB,MAAM,GAAG,IAAI,MAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;IAEvE,YAA2C,eAAiC;QAAjC,oBAAe,GAAf,eAAe,CAAkB;IAAG,CAAC;IAShF,YAAY;QACV,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACxC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACjC,IAAI,CAAC,GAAG,EAAE,CAAC;YAGT,OAAO;QACT,CAAC;QAED,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,gCAAgC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,mDAAmD,CAC9G,CAAC;IACJ,CAAC;IAaD,sBAAsB;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC9C,IAAI,IAAI,CAAC,aAAa,EAAE,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC3D,OAAO;QACT,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACjC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,6BAA6B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,0CAA0C;YACxF,6GAA6G;YAC7G,2GAA2G;YAC3G,iGAAiG;YACjG,0GAA0G,CAC7G,CAAC;IACJ,CAAC;IAUS,qBAAqB;QAC7B,OAAQ,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,WAAW,CAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACxF,MAAM,MAAM,GAAG,aAAa,CAAC,kBAAkB,CAAkC,IAAI,CAAC,CAAC;YACvF,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;gBAChE,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC;IAGS,aAAa;QACrB,OAAO,aAAa,CAAC,kBAAkB,CAA+B,YAAY,CAAC,CAAC;IACtF,CAAC;IAGS,aAAa;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,CAAC;QACpE,OAAO,OAAO,QAAQ,EAAE,GAAG,KAAK,UAAU,IAAI,OAAO,QAAQ,EAAE,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3G,CAAC;CACF,CAAA;AA1FY,yBAAyB;IADrC,UAAU,EAAE;IAIE,WAAA,QAAQ,EAAE,CAAA;qCAAsC,eAAe;GAHjE,yBAAyB,CA0FrC"}
|
|
@@ -3,6 +3,7 @@ import type { Query } from 'mongoose';
|
|
|
3
3
|
import type { AggregateOptions, Connection, QueryOptions, Types } from 'mongoose';
|
|
4
4
|
import { FilterArgs } from '../args/filter.args.js';
|
|
5
5
|
import { ServiceOptions } from '../interfaces/service-options.interface.js';
|
|
6
|
+
import { type AuditAction } from '../persistence/audit-log.registry.js';
|
|
6
7
|
import type { SyncDescriptor } from '../persistence/model-descriptor.interface.js';
|
|
7
8
|
import { CoreModel } from '../models/core-model.model.js';
|
|
8
9
|
import { PaginationInfo } from '../models/pagination-info.model.js';
|
|
@@ -15,6 +16,9 @@ export declare abstract class CrudService<Model extends CoreModel = any, CreateI
|
|
|
15
16
|
aggregateForce<T = any>(pipeline: PipelineStage[], serviceOptions?: ServiceOptions): Promise<T>;
|
|
16
17
|
aggregateRaw<T = any>(pipeline: PipelineStage[], serviceOptions?: ServiceOptions): Promise<T>;
|
|
17
18
|
create(input: PlainObject<CreateInput>, serviceOptions?: ServiceOptions): Promise<Model>;
|
|
19
|
+
protected createInProcess(data: {
|
|
20
|
+
input?: any;
|
|
21
|
+
}, serviceOptions?: ServiceOptions): Promise<any>;
|
|
18
22
|
createForce(input: PlainObject<CreateInput>, serviceOptions?: ServiceOptions): Promise<Model>;
|
|
19
23
|
createRaw(input: PlainObject<CreateInput>, serviceOptions?: ServiceOptions): Promise<Model>;
|
|
20
24
|
distinct(property: string, serviceOptions?: ServiceOptions): Promise<string[]>;
|
|
@@ -115,6 +119,12 @@ export declare abstract class CrudService<Model extends CoreModel = any, CreateI
|
|
|
115
119
|
updateForce(id: string, input: PlainObject<UpdateInput>, serviceOptions?: ServiceOptions): Promise<Model>;
|
|
116
120
|
updateRaw(id: string, input: PlainObject<UpdateInput>, serviceOptions?: ServiceOptions): Promise<Model>;
|
|
117
121
|
delete(id: string, serviceOptions?: ServiceOptions): Promise<Model>;
|
|
122
|
+
protected get auditListener(): import("../persistence/audit-log.registry.js").AuditLogListener;
|
|
123
|
+
protected get auditModelName(): string;
|
|
124
|
+
protected auditBefore(stored: Record<string, any> | undefined, input: unknown): Map<string, string> | undefined;
|
|
125
|
+
protected auditCreated<R>(created: R, input: unknown, serviceOptions?: ServiceOptions): Promise<R>;
|
|
126
|
+
protected auditUpdated(id: string, before: Map<string, string> | undefined, written: Record<string, any>, serviceOptions?: ServiceOptions): Promise<void>;
|
|
127
|
+
protected reportAudit(action: AuditAction, recordId: string, fields: string[], serviceOptions?: ServiceOptions): Promise<void>;
|
|
118
128
|
protected get mongoSync(): SyncDescriptor | undefined;
|
|
119
129
|
protected get isSynchronized(): boolean;
|
|
120
130
|
protected withTombstones<Q extends object>(query: Q, serviceOptions?: ServiceOptions): Q;
|