@lenne.tech/nest-server 12.6.12 → 12.6.14
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/configurable-features.md +1 -1
- package/.claude/rules/package-management.md +7 -7
- package/.claude/rules/role-system.md +10 -0
- package/.claude/rules/testing.md +4 -4
- package/FRAMEWORK-API.md +1 -1
- package/dist/core/common/decorators/rest-user.decorator.js +4 -0
- package/dist/core/common/decorators/rest-user.decorator.js.map +1 -1
- package/dist/core/common/filters/http-exception-log.filter.js +4 -0
- package/dist/core/common/filters/http-exception-log.filter.js.map +1 -1
- package/dist/core/common/helpers/context.helper.js +9 -0
- package/dist/core/common/helpers/context.helper.js.map +1 -1
- package/dist/core/common/helpers/decorator.helper.js +4 -0
- package/dist/core/common/helpers/decorator.helper.js.map +1 -1
- package/dist/core/common/helpers/execution-context-request.helper.d.ts +9 -1
- package/dist/core/common/helpers/execution-context-request.helper.js +29 -0
- package/dist/core/common/helpers/execution-context-request.helper.js.map +1 -1
- package/dist/core/common/helpers/graphql-upload.helper.d.ts +10 -0
- package/dist/core/common/helpers/graphql-upload.helper.js +237 -0
- package/dist/core/common/helpers/graphql-upload.helper.js.map +1 -0
- package/dist/core/common/helpers/redact-secrets.helper.js +7 -2
- package/dist/core/common/helpers/redact-secrets.helper.js.map +1 -1
- package/dist/core/common/interceptors/translate-response.interceptor.js +4 -0
- package/dist/core/common/interceptors/translate-response.interceptor.js.map +1 -1
- package/dist/core/common/plugins/complexity.plugin.js +73 -9
- package/dist/core/common/plugins/complexity.plugin.js.map +1 -1
- package/dist/core/modules/auth/guards/auth.guard.js +10 -2
- package/dist/core/modules/auth/guards/auth.guard.js.map +1 -1
- package/dist/core/modules/auth/guards/legacy-auth-rate-limit.guard.js +4 -1
- package/dist/core/modules/auth/guards/legacy-auth-rate-limit.guard.js.map +1 -1
- package/dist/core/modules/auth/guards/roles.guard.js +11 -1
- package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
- package/dist/core/modules/better-auth/better-auth-roles.guard.js +15 -1
- package/dist/core/modules/better-auth/better-auth-roles.guard.js.map +1 -1
- package/dist/core/modules/tenant/core-tenant.guard.js +9 -1
- package/dist/core/modules/tenant/core-tenant.guard.js.map +1 -1
- package/dist/core.module.js +2 -1
- 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/types/graphql-upload.d.ts +34 -2
- package/docs/REQUEST-LIFECYCLE.md +33 -9
- package/docs/security-overrides.md +3 -2
- package/migration-guides/12.6.12-to-12.6.13.md +162 -0
- package/migration-guides/12.6.13-to-12.6.14.md +143 -0
- package/package.json +10 -3
- package/src/core/common/decorators/rest-user.decorator.ts +6 -0
- package/src/core/common/filters/http-exception-log.filter.ts +9 -0
- package/src/core/common/helpers/context.helper.ts +14 -0
- package/src/core/common/helpers/decorator.helper.ts +5 -0
- package/src/core/common/helpers/execution-context-request.helper.ts +78 -1
- package/src/core/common/helpers/graphql-upload.helper.ts +520 -0
- package/src/core/common/helpers/redact-secrets.helper.ts +22 -3
- package/src/core/common/interceptors/translate-response.interceptor.ts +8 -0
- package/src/core/common/plugins/complexity.plugin.ts +150 -9
- package/src/core/modules/auth/guards/auth.guard.ts +19 -2
- package/src/core/modules/auth/guards/legacy-auth-rate-limit.guard.ts +9 -2
- package/src/core/modules/auth/guards/roles.guard.ts +23 -1
- package/src/core/modules/better-auth/better-auth-roles.guard.ts +29 -1
- package/src/core/modules/tenant/core-tenant.guard.ts +13 -1
- package/src/core.module.ts +5 -1
- package/src/index.ts +1 -0
- package/src/types/graphql-upload.d.ts +34 -2
|
@@ -323,7 +323,7 @@ This pattern is currently applied to:
|
|
|
323
323
|
| Response Model Interceptor | `security.responseModelInterceptor` | Boolean Shorthand | `true` (enabled), `debug: false` |
|
|
324
324
|
| Translate Response Interceptor | `security.translateResponseInterceptor` | Boolean Shorthand | `true` (enabled) |
|
|
325
325
|
| Mongoose CastError Filter | `security.mongooseCastErrorFilter` | Explicit Boolean — **safe default** | **`true` since 11.42.16.** `MongooseCastErrorFilter`, registered by `CoreModule` as `APP_FILTER` (so `main.ts` and `Test.createTestingModule()` setups need nothing). A malformed id reached Mongoose and its `CastError` — not an `HttpException` — escaped every `@Catch(HttpException)` filter, so `GET /users/<malformed-id>` and every other `:id` route answered **500**. The filter decides by WHERE the failing value came from: a route parameter or a top-level GraphQL argument → **404** `ErrorCode.RESOURCE_NOT_FOUND` (answered like an unknown id); the query string, an update or filter body, or a nested GraphQL input → **400** `ErrorCode.INVALID_FIELD_FORMAT [<path>]`; a value the request does not contain (a broken stored id, a server-computed value) → **stays a 500**, with Nest's own body and log line (context `ExceptionsHandler`), because that is a data or code defect monitoring must keep seeing — relabelling it as a client error is the mistake the refusal tests pin (mutations `cast-error-server-value-relabelled-*`). Only primitives and arrays of primitives (`$in`) are matched: an object cast as a whole yields no candidates, so its inner strings cannot match the body by coincidence. Never sends the Mongoose message (it names the model). REST bodies use the `HttpExceptionLogFilter` shape (`{ ...exception }`). A project's own catch-all filter via `app.useGlobalFilters()` is consulted first and wins. Covers casts Mongoose raises while running a QUERY or an UPDATE (`findById`, filters, `findByIdAndUpdate` — `CrudService.update()`). NOT covered, both stay a 500: a malformed id in a document being CREATED (`save()` / `create()` / `insertMany()` — `CrudService.create()`), which Mongoose reports as a `ValidationError` wrapping the CastError (validate in the input: `validator: () => [IsMongoId()]`); and a `BSONError` from `new Types.ObjectId(bad)`, which carries no value (check the id in the service, `CoreFileService.isMalformedFileId()`). `false` restores the 500. Implementation: `common/filters/mongoose-cast-error.filter.ts` |
|
|
326
|
-
| Config Endpoint | `configEndpoint` | Explicit Boolean with DERIVED default | **Unset → a project's `GET /config` answers only in `local` / `ci` / `e2e` (`isLocalEnv()`), 404 everywhere else (12.5.0+)**; `true` answers everywhere, `false` nowhere; a non-boolean value counts as not set (`NSC__CONFIG_ENDPOINT=true`). The route lives in project code (the starter's `ServerController`) and returns `configEndpointResponse()`, which throws `NotFoundException` when closed (404, as if the route did not exist; the route's `@Roles(ADMIN)` still answers 401 first) and otherwise the REDACTED configuration (`ConfigService.getRedactedConfig()`). Before 12.5.0 the starter's endpoint returned the database URI, auth secrets and mail password to every administrator, and projects created before the starter redacted kept doing so. Redaction is the one framework masker `redactSecrets()` (`common/helpers/redact-secrets.helper.ts`, moved from the Hub where it remains as `maskConfigDeep`): key patterns (`secret`/`password`/`token`/`credential` anywhere in the name, names ending in `pass` or `key`, `encryption`, `dsn`, `salt`, … — a superset of the pattern the starter used before), the password of a connection URI and secret-named URI query parameters, scheme + host + port only for an address under a key ending in `url`/`uri`/`endpoint`/`webhook` (a webhook carries its secret in the path), nested values; below a secret-named key EVERYTHING is masked except booleans; plus `FRAMEWORK_SECRET_FIELDS` and `security.secretFields`. The Hub config panel and the `ConfigService` `warn: true` debug output use the same view. Implementation: `common/helpers/config-endpoint.helper.ts` |
|
|
326
|
+
| Config Endpoint | `configEndpoint` | Explicit Boolean with DERIVED default | **Unset → a project's `GET /config` answers only in `local` / `ci` / `e2e` (`isLocalEnv()`), 404 everywhere else (12.5.0+)**; `true` answers everywhere, `false` nowhere; a non-boolean value counts as not set (`NSC__CONFIG_ENDPOINT=true`). The route lives in project code (the starter's `ServerController`) and returns `configEndpointResponse()`, which throws `NotFoundException` when closed (404, as if the route did not exist; the route's `@Roles(ADMIN)` still answers 401 first) and otherwise the REDACTED configuration (`ConfigService.getRedactedConfig()`). Before 12.5.0 the starter's endpoint returned the database URI, auth secrets and mail password to every administrator, and projects created before the starter redacted kept doing so. Redaction is the one framework masker `redactSecrets()` (`common/helpers/redact-secrets.helper.ts`, moved from the Hub where it remains as `maskConfigDeep`): key patterns (`secret`/`password`/`token`/`credential` anywhere in the name, names ending in `pass` or `key`, `encryption`, `dsn`, `salt`, … — a superset of the pattern the starter used before; `pfx` / `pkcs12` since 12.6.14), every string or `Buffer` holding a PEM private key whatever its key is called (12.6.14 — a certificate login keeps certificate and key in one PEM under `certificate`, which reached `GET /config` in clear text before; a certificate alone stays readable), the password of a connection URI and secret-named URI query parameters, scheme + host + port only for an address under a key ending in `url`/`uri`/`endpoint`/`webhook` (a webhook carries its secret in the path), nested values; below a secret-named key EVERYTHING is masked except booleans; plus `FRAMEWORK_SECRET_FIELDS` and `security.secretFields`. The Hub config panel and the `ConfigService` `warn: true` debug output use the same view. Implementation: `common/helpers/config-endpoint.helper.ts` |
|
|
327
327
|
| Secret Fields Removal | `security.secretFields` | Array | `['password', 'verificationToken', ...]`. A project list is a UNION with the defaults (it can add, never remove). `CheckSecurityInterceptor` strips each field under its SQL column name too since 12.3.1 (`passwordResetToken` and `password_reset_token`): a row read through `store.native()` / `store.raw()` carries snake_case columns, and a route returning it unchanged used to hand every secret but `password` to the client. Pinned by `tests/unit/check-security-secret-columns.spec.ts` (mutation `secret-columns-not-stripped`) |
|
|
328
328
|
| Data Sources | `database` | Explicit Value — absent = today's `mongoose` config | **Absent → the `mongoose` configuration is the only data source, exactly as before; nothing SQL is loaded or installed.** A URL string (`'postgres://…'`) sets the default source (driver from the scheme, `sqlEngine` defaults to `typeorm`; `kysely` and `drizzle` are the alternatives — optional peers, each with `pg`); an object adds `ownerUrl` (default source), `sources` (name → URL or `{ url, ownerUrl, sqlEngine }`) and per-model exceptions (`models`); `false` means no database. Precedence for a model: `database.models` > the `dataSource` of a `CorePersistenceModule.forFeature()` definition > `@PersistedModel({ dataSource })` (read from the definition's `model:` class, otherwise from the decorated class named like the model; two such classes naming different sources refuse to guess) > default. When `database` sets a default and the project ALSO configures `mongoose` explicitly, that MongoDB becomes the source `mongoose` — only the project's own `mongoose` counts, because `CoreModule.forRoot()` always merges a fallback URI. **Since phase 1 (DEV-3829) PostgreSQL sources are wired**: only models registered with `CorePersistenceModule.forFeature()` are routed — **since phase 2 (DEV-3830) that includes the core's own models**: the user model (the reference `UserModule`), tenant memberships and API tokens, whose services switch to the routed store (a service that only received `@InjectModel()` follows its model's store; the Mongoose model of a model routed to SQL refuses every data access with a named error, so a direct `mainDbModel` call cannot split a model's data). **Since phase 3 (DEV-3831) Better-Auth follows the user model**: with the user model (table `users`) on a SQL source, Better-Auth runs its built-in Kysely adapter on that source's application pool — ONE `users` row per user shared with the user model (Better-Auth's own columns `name`, `email_verified`, `image` beside the framework's; its required ones are added nullable, so a row the user model writes alone stays valid), snake_case tables (`session`, `account`, `verification`, `jwks`, `two_factor`, `passkey`), ObjectId-hex ids. Its schema is applied as the OWNER at boot, under the same schema lock and grants as the framework's tables; without `ownerUrl` the application role only verifies and the boot stops while Better-Auth's migrations are pending. The framework's own reads and writes of Better-Auth's data follow it (session lookup by token, token service, JWKS, passkey challenge mappings — as Better-Auth verification values —, the e-mail-verified hook, user mapper, system setup, migration status — counted in SQL —, the MCP OAuth subject's roles); the MongoDB boot steps (indices, account-issuer backfill) are skipped there. Nothing is copied from MongoDB: a project that moves its users brings them over itself. **Since phase 4 (DEV-3832) the remaining core persistence follows too**: the AI module's eleven models and the three MCP OAuth stores (clients, codes, refresh tokens) are registered through `CorePersistenceModule.forFeature()` and run on their routed store (one code path; an upsert is update-then-insert with a retry on a duplicate, `sum()` replaces the budget aggregation, `find(…, { exclude })` the `-field` projection); the S3 and filesystem file metadata are two framework models (`CoreS3File`, `CoreFilesystemFile`, tables `s3_files` / `filesystem_files`) read and written through `fileMetadataCollection()` by the file service, the TUS hand-off and the Hub — GridFS stays MongoDB-only. A collection name with a hyphen becomes a table with an underscore. A TTL (`expires`, `index: { expireAfterSeconds }`) is a plain index on SQL; an **expiry sweep** (`scheduleExpirySweep()`, every 15 min, one replica per interval through a lease in the default SQL source's `lt_locks`, fail-open) deletes the expired rows of every routed TTL model, and — with Better-Auth on SQL — expired sessions and verification values. Nothing relies on it for correctness: every reader checks the expiry (an MCP authorization code older than ten minutes is refused on read on both databases). MongoDB keeps its TTL indexes and gets no sweep. The framework's leases (system-setup claim, cron, migrations) live in the default source: on MongoDB in the 12.0.0 documents (a rolling deploy with older replicas shares them), on SQL in `lt_locks`, namespaced, swept an hour after expiry. With `healthCheck.configs.database` every SQL source answers as `<key>:<source>`; `createMigrationStore(<owner URL>)` keeps the migration state in `lt_migrations` with an advisory run lock, on the first SQL engine installed (the CLI cannot read `database.sqlEngine`), and the Hub refuses to run migrations while that table is empty and the MongoDB collection is not (a `migrate.js` still writing MongoDB); the Hub's Persistence panel shows the routing. a SQL model's table is migrated as the OWNER (`ownerUrl`) when its store is created — without `ownerUrl` the application role only verifies and the boot stops while changes are pending; ONE owner connection per source, released once the application is bootstrapped — and the boot refuses an application role that is superuser, has `BYPASSRLS`, owns (or inherits the owner of) a framework table or may `TRUNCATE` it. Two roles in every environment (plan §3.9). Changes the framework never applies on its own (type change, new unique index, rename collision) stop the boot with the suggested statements; `migrate create <name> --sql` + `runSqlMigration()` apply them after review. **Since phase 5 (DEV-3833, 12.1.0) MongoDB is optional**: `mongoose`, `@nestjs/mongoose` and `mongodb` are optional peers, loaded through `common/persistence/mongo/mongo-packages.ts`; `CoreModule` connects MongoDB only when a source uses it (`usesMongoDb()` — `mongoose` configured explicitly, `database` naming MongoDB, or `database` absent), otherwise `@InjectConnection()` receives `null` and a model token without a connection is a stand-in that refuses data access. A configured MongoDB feature without the packages fails the boot with `MongoPackagesMissingError`. `database: false` runs a service without any database: a registered model's store refuses with the reason, Better-Auth is refused at boot. Proven by `pnpm run check:without-mongodb` (dist, packages hidden) and `check:without-mongodb:package` (the tarball installed without them, publish path). **Since phase 6 (DEV-3848) MySQL 8.4 and MariaDB 11.8 sources are wired** (`mysql://`, `mariadb://` — the scheme must name the server the URL reaches): `mysql2` is an optional peer beside the engine, all three engines run on one pool the framework creates (strict session with backslash escapes, UTC), `MysqlDataStore` writes the statements, the owner grants the application account `SELECT, INSERT, UPDATE, DELETE` on the database once and the boot refuses an application account that may alter, drop, index, trigger or grant; leases, migration state (`createMigrationStore()` / `runSqlMigration()` under `GET_LOCK`), the expiry sweep, health check and Hub work there. **Neither database has row-level security**: tenant isolation is the store's, the boot warns once per source, and native / raw access on a tenant table must filter by tenant itself. **Since 12.1.1 (DEV-3904) Better-Auth runs there too**: its Kysely adapter on the source's `mysql2` pool (the promise wrapper — Better-Auth builds `MysqlDialect` from it), its migrations as the owner under `GET_LOCK`, with the database's default collation switched to `utf8mb4_bin` while it creates a table and restored (`withFrameworkDefaultCollation()`; only on such a run and with a 5 s lock wait, because `ALTER DATABASE` locks every table) — Better-Auth names no collation, and MariaDB refuses a foreign key to `users.id` across collations; the database-level grant covers its tables. 12.1.0 refused it at boot. An indexed text field is `varchar(255)` (longer: 400); a DDL run is not transactional. Still refused with a named `DataSourceConfigError`: a second MongoDB source, and an `ownerUrl` without `url` — what `NSC__DATABASE__OWNER_URL` leaves of a `database` given as a URL string, because the environment merge replaces the string with an object (write `database: { url }`, or set `NSC__DATABASE__URL` too). An update path the model does not declare is dropped on SQL as by MongoDB's strict mode (`CrudService.update()` adds `updatedBy` to every update with a current user). URLs appear in errors and logs as scheme + host only. Implementation: `common/persistence/data-source.config.ts`, `data-source.runtime.ts`, `sql/` (db-agnostic plan §3.9) |
|
|
329
329
|
| Multi-Tenancy | `multiTenancy` | Presence Implies Enabled | **`excludeSchemas` is an OFF SWITCH for isolation, per model** — a listed schema gets no tenant filter at all; since 11.35.0 the plugin WARNS once per model when the excluded schema declares `tenantId` (i.e. was built for isolation). The framework's own docs recommended `['User', 'Session']` until then; that is withdrawn — it is only right for the global-user model. Since 11.35.0 GraphQL operations over the WEBSOCKET also run inside a `RequestContext` (`CoreModule` installs a context-aware `execute`/`subscribe` pair inside `subscriptions`, where `ApolloDriver` forwards it): the tenant comes from the handshake header validated against an active membership, else from the subscriber's memberships, and an unresolvable tenant leaves the safety net to refuse the read rather than returning everything. `headerName: 'x-tenant-id'`, `membershipModel: 'TenantMember'`, `adminBypass: true`, `excludeSchemas: []`, `roleHierarchy: { member: 1, manager: 2, owner: 3 }`, `cacheTtlMs: 30000` (0 disables, process-local). System roles (`S_EVERYONE`, `S_USER`, `S_VERIFIED`) are checked as OR alternatives before real roles; method-level system roles take precedence; membership validated for context when system role grants access + header present. Hierarchy roles use level comparison, normal roles use exact match. Use `DefaultHR` or `createHierarchyRoles()` for type-safe role constants. Bypass: `RequestContext.runWithBypassTenantGuard()`. Cache invalidation: `invalidateUser(userId)` / `invalidateAll()` are **instance** methods on the singleton `CoreTenantGuard` — inject it and call `this.tenantGuard?.invalidateUser(userId)`, never `CoreTenantGuard.invalidateUser(...)` (there is no static). With `redis` configured, both additionally BROADCAST the invalidation to every replica (`<keyPrefix>:tenant-cache:invalidate` pub/sub); without Redis they clear the local process only, so other replicas stay stale until `cacheTtlMs`. A received broadcast clears locally without re-publishing. **`isTenantActive` (11.42.0)**: optional hook `(tenantId, { connection, store }) => boolean \| Promise<boolean>`, absent = every tenant active (no change). `store(modelName)` (12.x, db-agnostic) is the data store of a model registered with `CorePersistenceModule.forFeature()`, wherever `database` routes it, and THROWS for any other model — an `undefined` would read as "active" in a hook written with `?.` and open every deactivated tenant. Asked AFTER the membership check on every path that establishes a tenant: 403 on header paths and for tenant API tokens, no enrichment on `S_EVERYONE`, dropped from the header-less tenant list, no tenant for a NEW WebSocket subscription, and since 11.42.3 an OPEN one is closed with 4403 on `invalidateTenant()` (or at its next event once `graphQl.subscriptionRevalidationMs` has passed — see the GraphQL Subscription Re-check row); an admin under `adminBypass` is exempt (someone must be able to switch it back on). Only `false` deactivates. Cached for `cacheTtlMs`; `invalidateTenant(tenantId)` clears and broadcasts (`{ scope: 'tenant' }`) — since 12.3.0 together with the tenant's cached memberships and every cached tenant list holding it, so memberships removed without `invalidateUser()` (a deleted tenant) stop counting at once rather than after `cacheTtlMs` (a tenant switched off through `isTenantActive` was already refused at once, its answer being cleared). **Removing a tenant (12.3.0)**: `CoreTenantService.purgeTenantData(tenantId, { dryRun?, exclude? })` first ends every way in — the memberships (`deleteAllMembers()`) and the tenant's API tokens, which need no member — then deletes, in batches of 1000 ids, every registered model with a `tenantId` path (MongoDB and SQL), the core references without one (the AI settings with `scope: 'tenant'`) and the AI connections — one only this tenant could use is deleted, from a shared one the tenant is removed (an empty `tenantIds` means every tenant). `excludeSchemas` and `exclude` are left out, so are users and files; the protected `purgeTenantRecords()` is where a project adds its own references. A function, so `config.env.ts` only — not reachable through `NSC__*`. **`adminBypass: false` (11.42.0)** additionally withholds two things that went around it: `CoreUserService.update()` refuses changing another account's e-mail or password (`assertCredentialChangeAllowed()`, administrator targets included — promote-then-change — system work without a current user exempt), and the AI tool registry grants no ADMIN bypass |
|
|
@@ -453,13 +453,13 @@ plus one for the opposite failure, a guard that rejects a declaration which is s
|
|
|
453
453
|
matters just as much: a check that cries wolf on correct entries is a check that gets switched off,
|
|
454
454
|
which is how the hole this feature closes came about in the first place.
|
|
455
455
|
|
|
456
|
-
**Current
|
|
457
|
-
`< 11.0.1
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
456
|
+
**Current entry (since 2026-10-31, owner decision, DEV-3899).** `GHSA-g3hv-75wg-m249` (minimatch
|
|
457
|
+
`< 11.0.1`, moderate), fixed only in a new major released 2026-10-27 that its remaining consumers cannot take yet
|
|
458
|
+
(`@nestjs/cli` 12.0.11 pins 10.2.6 exactly, `@swc/cli`, `@ts-morph/common`, nodemon). The justification is in the
|
|
459
|
+
comment above `ignoreGhsas`, the declaration in `unusableFixConsumers`. `tests/unit/audit-suppression-scope.spec.ts`
|
|
460
|
+
allows minimatch in the production tree only under `@ts-morph/common` (ts-morph, the Permissions module's scanner,
|
|
461
|
+
matching globs the developer writes) — its `prodVia` form. `GHSA-3g3m-2fjr-6pw4` (glob `<= 14.0.1`) was a second
|
|
462
|
+
entry until 2026-11-14 on this line (12.6.x), when rimraf 6.1.4 moved to glob 14 and no affected glob remained.
|
|
463
463
|
|
|
464
464
|
**Before that, no entry from 2026-10-24.** `GHSA-vfj7-8cjw-p6xm` (braces, via nodemon / npm-watch) was
|
|
465
465
|
listed from 2026-10-11 to 2026-10-24: a dev-tooling-only path of an advisory with no patched release
|
|
@@ -502,6 +502,16 @@ reserved for a socket whose rights changed while it was open (above). Pinned by
|
|
|
502
502
|
`tests/subscription-session-iam.e2e-spec.ts` / `tests/subscription-session-legacy.e2e-spec.ts` (mutations
|
|
503
503
|
`iam-ws-handshake-refusal-throws`, `legacy-ws-handshake-refusal-throws`).
|
|
504
504
|
|
|
505
|
+
## Agent function and MCP calls (12.6.x backport of 12.10.0)
|
|
506
|
+
|
|
507
|
+
`@nestjs/ai` (`@AgentFunction()`) and `@nestjs/mcp` (`@Tool()` …) run every global guard around their methods with the
|
|
508
|
+
context types `'ai'` / `'mcp'` and the arguments `[input, call]`. Index 0 is what the model or the MCP client wrote.
|
|
509
|
+
`resolveGuardRequest()` answers `call.request` there — never index 0, which the HTTP fallback returned before (tool
|
|
510
|
+
arguments `{ "user": { "roles": ["admin"] } }` were the caller). A REQUEST-LESS caller (`caller: { user }`, a durable
|
|
511
|
+
run, stdio) is anonymous: public methods run, everything else is 401 in every guard, `CoreTenantGuard` included.
|
|
512
|
+
Nothing changes for any other transport. Pinned by `tests/unit/agent-call-context.spec.ts`.
|
|
513
|
+
**When you add a guard, resolve the request through `resolveGuardRequest()`; never `switchToHttp()` on its own.**
|
|
514
|
+
|
|
505
515
|
## Role Check Implementation
|
|
506
516
|
|
|
507
517
|
The role system is evaluated in:
|
package/.claude/rules/testing.md
CHANGED
|
@@ -410,7 +410,7 @@ pnpm run check:mutations -- --id=<id> # one mutation
|
|
|
410
410
|
pnpm run check:mutations -- --list # the registry, without running anything
|
|
411
411
|
pnpm run check:mutations -- --allow-dirty # when the fix and its evidence share a working tree
|
|
412
412
|
pnpm run check:mutations -- --jobs=4 # N mutations at a time (default: 2, or 4 on >=12 cores)
|
|
413
|
-
pnpm run check:mutations -- --no-infra # only the
|
|
413
|
+
pnpm run check:mutations -- --no-infra # only the 437 that need no MongoDB
|
|
414
414
|
pnpm run check:mutations -- --since=<ref> # only mutations touching files changed since <ref>
|
|
415
415
|
pnpm run check:mutations -- --shard=2/4 # this job's quarter of the selection (CI splits the full run)
|
|
416
416
|
```
|
|
@@ -430,7 +430,7 @@ when the registry, a vitest config or a setup file changed, since those can move
|
|
|
430
430
|
commit, and in CI alongside the publish without blocking it. The price of caching is a cache that
|
|
431
431
|
has to model each spec's full dependency closure correctly, and getting that wrong produces a stale
|
|
432
432
|
PASS for a test that has since gone vacuous — exactly what the gate is there to prevent. Bad trade
|
|
433
|
-
at
|
|
433
|
+
at 676 mutations.
|
|
434
434
|
|
|
435
435
|
**Decided 2026-10-03 (repo owner): keep the full run.** Measured at 128 mutations, the CI job for
|
|
436
436
|
11.41.6 took **14 minutes**. The trigger to revisit is that wall time, not the mutation count —
|
|
@@ -501,9 +501,9 @@ exactly the environment where the answer matters.
|
|
|
501
501
|
|
|
502
502
|
### The cost is vitest's cold start, not the tests
|
|
503
503
|
|
|
504
|
-
Worth knowing before optimising the wrong thing: the specs behind all
|
|
504
|
+
Worth knowing before optimising the wrong thing: the specs behind all 239 e2e mutations add up to
|
|
505
505
|
**~40 seconds**. The step takes ~740s. The remaining ~700s is paying vitest's startup — process
|
|
506
|
-
spawn, transform, module graph, mongod connect, DB create and drop — once per mutation,
|
|
506
|
+
spawn, transform, module graph, mongod connect, DB create and drop — once per mutation, 676 times.
|
|
507
507
|
That work is largely single-threaded I/O and barely scales with cores: the full registry measures
|
|
508
508
|
**744s on a 12-core laptop and 777s on a 4-vCPU CI runner**.
|
|
509
509
|
|
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-19 (v12.6.14)
|
|
4
4
|
> File: `FRAMEWORK-API.md` — compact, machine-readable API surface for Claude Code
|
|
5
5
|
|
|
6
6
|
## CoreModule.forRoot()
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createParamDecorator } from '@nestjs/common';
|
|
2
|
+
import { isAgentCallContext, resolveAgentCallRequest } from '../helpers/execution-context-request.helper.js';
|
|
2
3
|
export const RESTUser = createParamDecorator((data, ctx) => {
|
|
4
|
+
if (isAgentCallContext(ctx)) {
|
|
5
|
+
return resolveAgentCallRequest(ctx)?.user;
|
|
6
|
+
}
|
|
3
7
|
const request = ctx.switchToHttp().getRequest();
|
|
4
8
|
return request.user;
|
|
5
9
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-user.decorator.js","sourceRoot":"","sources":["../../../../src/core/common/decorators/rest-user.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"rest-user.decorator.js","sourceRoot":"","sources":["../../../../src/core/common/decorators/rest-user.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AAK7G,MAAM,CAAC,MAAM,QAAQ,GAAG,oBAAoB,CAAC,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IAEpF,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,uBAAuB,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAC5C,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CAAC,CAAC"}
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Catch, HttpException, Logger, ServiceUnavailableException, } from '@nestjs/common';
|
|
8
|
+
import { isAgentCallContext } from '../helpers/execution-context-request.helper.js';
|
|
8
9
|
const exceptionLogger = new Logger('HttpExceptionLogFilter');
|
|
9
10
|
let HttpExceptionLogFilter = class HttpExceptionLogFilter {
|
|
10
11
|
catch(exception, host) {
|
|
@@ -13,6 +14,9 @@ let HttpExceptionLogFilter = class HttpExceptionLogFilter {
|
|
|
13
14
|
if (type === 'graphql') {
|
|
14
15
|
return exception;
|
|
15
16
|
}
|
|
17
|
+
if (isAgentCallContext(host)) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
16
20
|
const ctx = host.switchToHttp();
|
|
17
21
|
const res = ctx.getResponse();
|
|
18
22
|
const status = exception.getStatus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-exception-log.filter.js","sourceRoot":"","sources":["../../../../src/core/common/filters/http-exception-log.filter.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEL,KAAK,EAEL,aAAa,EACb,MAAM,EACN,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"http-exception-log.filter.js","sourceRoot":"","sources":["../../../../src/core/common/filters/http-exception-log.filter.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEL,KAAK,EAEL,aAAa,EACb,MAAM,EACN,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAOpF,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAGtD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAIjC,KAAK,CAAC,SAAwB,EAAE,IAAmB;QAEjD,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAGvC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAkB,CAAC;QAC5C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QAMD,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAC;QACnB,CAAC;QAGD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QACxC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QAIrC,MAAM,IAAI,GAA4B,EAAE,GAAG,SAAS,EAAE,CAAC;QACvD,OAAO,IAAI,CAAC,OAAO,CAAC;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;QAClB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,YAAY,2BAA2B,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACnG,CAAC;CACF,CAAA;AAlCY,sBAAsB;IADlC,KAAK,CAAC,aAAa,CAAC;GACR,sBAAsB,CAkClC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GqlExecutionContext } from '@nestjs/graphql';
|
|
2
|
+
import { isAgentCallContext, resolveAgentCallRequest } from './execution-context-request.helper.js';
|
|
2
3
|
export default class Context {
|
|
3
4
|
static getData(context) {
|
|
4
5
|
return getContextData(context);
|
|
@@ -8,6 +9,14 @@ export function getContextData(context) {
|
|
|
8
9
|
if (!context) {
|
|
9
10
|
return { args: null, currentUser: null, request: null };
|
|
10
11
|
}
|
|
12
|
+
if (isAgentCallContext(context)) {
|
|
13
|
+
const agentRequest = resolveAgentCallRequest(context);
|
|
14
|
+
return {
|
|
15
|
+
args: context.getArgByIndex(0),
|
|
16
|
+
currentUser: agentRequest?.user,
|
|
17
|
+
request: (agentRequest ?? null),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
11
20
|
let user;
|
|
12
21
|
let rawContext = null;
|
|
13
22
|
let ctx = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/context.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"context.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/context.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAMpG,MAAM,CAAC,OAAO,OAAO,OAAO;IAKnB,MAAM,CAAC,OAAO,CAAC,OAAyB;QAK7C,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACF;AAKD,MAAM,UAAU,cAAc,CAAC,OAAyB;IAMtD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IAKD,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,MAAM,YAAY,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACtD,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;YAC9B,WAAW,EAAE,YAAY,EAAE,IAAI;YAC/B,OAAO,EAAE,CAAC,YAAY,IAAI,IAAI,CAAgB;SAC/C,CAAC;IACJ,CAAC;IAGD,IAAI,IAA4B,CAAC;IACjC,IAAI,UAAU,GAAQ,IAAI,CAAC;IAC3B,IAAI,GAAG,GAAQ,IAAI,CAAC;IACpB,IAAI,OAAY,CAAC;IACjB,IAAI,CAAC;QACH,UAAU,GAAG,mBAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACjD,GAAG,GAAG,UAAU,EAAE,UAAU,EAAE,CAAC;QAC/B,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC;IACpB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;IAEb,CAAC;IAED,IAAI,IAAS,CAAC;IACd,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,CAAC;YACH,IAAI,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;QAEb,CAAC;IACH,CAAC;IAGD,IAAI,GAAG,EAAE,CAAC;QAER,IAAI,GAAG,GAAG,EAAE,IAAI,IAAI,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC;IACrC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC9E,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAGpB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;IAGD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { GqlExecutionContext } from '@nestjs/graphql';
|
|
2
2
|
import { getPopulateOptions } from './db.helper.js';
|
|
3
|
+
import { isAgentCallContext, resolveAgentCallRequest } from './execution-context-request.helper.js';
|
|
3
4
|
import { removePropertiesDeep } from './input.helper.js';
|
|
4
5
|
export function currentUserDec(data, ctx) {
|
|
6
|
+
if (isAgentCallContext(ctx)) {
|
|
7
|
+
return resolveAgentCallRequest(ctx)?.user;
|
|
8
|
+
}
|
|
5
9
|
if (ctx.getType() === 'graphql') {
|
|
6
10
|
const gqlContext = GqlExecutionContext.create(ctx);
|
|
7
11
|
return gqlContext.getContext().req.user;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/decorator.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,mBAAmB,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AE,GAAG;QACpC,OAAO,EAAE,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI;QACrC,gBAAgB,EAAE,IAAI;QACtB,GAAG,IAAI;KACR,CAAC;IAGF,MAAM,eAAe,GAAG,kBAAkB,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1E,IAAI,gBAAgB,EAAE,CAAC;QACrB,oBAAoB,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpD,CAAC;IAGD,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import type { ExecutionContext } from '@nestjs/common';
|
|
1
|
+
import type { ArgumentsHost, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
export declare const AGENT_CALL_CONTEXT_TYPES: ReadonlySet<string>;
|
|
3
|
+
export interface AgentCallLike {
|
|
4
|
+
name?: string;
|
|
5
|
+
request?: GuardRequestLike;
|
|
6
|
+
}
|
|
7
|
+
export declare function isAgentCallContext(context: ArgumentsHost | undefined): boolean;
|
|
8
|
+
export declare function agentCallOf(context: ArgumentsHost | undefined): AgentCallLike | undefined;
|
|
9
|
+
export declare function resolveAgentCallRequest(context: ArgumentsHost | undefined): GuardRequestLike | undefined;
|
|
2
10
|
export interface GuardRequestLike {
|
|
3
11
|
[key: string]: any;
|
|
4
12
|
headers?: Record<string, any>;
|
|
@@ -1,7 +1,36 @@
|
|
|
1
|
+
export const AGENT_CALL_CONTEXT_TYPES = new Set(['ai', 'mcp']);
|
|
2
|
+
export function isAgentCallContext(context) {
|
|
3
|
+
let type;
|
|
4
|
+
try {
|
|
5
|
+
type = context?.getType?.();
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return typeof type === 'string' && AGENT_CALL_CONTEXT_TYPES.has(type);
|
|
11
|
+
}
|
|
12
|
+
export function agentCallOf(context) {
|
|
13
|
+
if (!isAgentCallContext(context)) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const call = context.getArgByIndex(1);
|
|
17
|
+
return call && typeof call === 'object' ? call : undefined;
|
|
18
|
+
}
|
|
19
|
+
export function resolveAgentCallRequest(context) {
|
|
20
|
+
const call = agentCallOf(context);
|
|
21
|
+
const request = call?.request;
|
|
22
|
+
if (!request || typeof request !== 'object') {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return request;
|
|
26
|
+
}
|
|
1
27
|
function isSubscriptionContext(value) {
|
|
2
28
|
return (!!value && typeof value === 'object' && ('socket' in value || 'connectionParams' in value || 'request' in value));
|
|
3
29
|
}
|
|
4
30
|
export function resolveGuardRequest(context, gqlContextOf) {
|
|
31
|
+
if (isAgentCallContext(context)) {
|
|
32
|
+
return resolveAgentCallRequest(context);
|
|
33
|
+
}
|
|
5
34
|
let gqlContext;
|
|
6
35
|
try {
|
|
7
36
|
gqlContext = gqlContextOf(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-context-request.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/execution-context-request.helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execution-context-request.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/execution-context-request.helper.ts"],"names":[],"mappings":"AAkDA,MAAM,CAAC,MAAM,wBAAwB,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAcpF,MAAM,UAAU,kBAAkB,CAAC,OAAkC;IACnE,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACxE,CAAC;AAGD,MAA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C,UAAU,CAAC,EAAE,CAAC;QAItC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,gBAAgB,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;QACxF,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
export declare const GRAPHQL_UPLOAD_MAX_PATH_KEYS = 64;
|
|
3
|
+
export declare const GRAPHQL_UPLOAD_MAX_MAP_KEYS = 10000;
|
|
4
|
+
export interface GraphQlUploadProcessRequestOptions {
|
|
5
|
+
maxFieldSize?: number;
|
|
6
|
+
maxFileSize?: number;
|
|
7
|
+
maxFiles?: number;
|
|
8
|
+
}
|
|
9
|
+
export type GraphQlUploadOperations = Array<Record<string, unknown>> | Record<string, unknown>;
|
|
10
|
+
export declare function processGraphQlUploadRequest(request: IncomingMessage, response: ServerResponse, { maxFieldSize, maxFileSize, maxFiles }?: GraphQlUploadProcessRequestOptions): Promise<GraphQlUploadOperations>;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import busboy from 'busboy';
|
|
2
|
+
import { WriteStream } from 'fs-capacitor';
|
|
3
|
+
import Upload from 'graphql-upload/Upload.mjs';
|
|
4
|
+
import createError from 'http-errors';
|
|
5
|
+
import objectPath from 'object-path';
|
|
6
|
+
const GRAPHQL_MULTIPART_REQUEST_SPEC_URL = 'https://github.com/jaydenseric/graphql-multipart-request-spec';
|
|
7
|
+
export const GRAPHQL_UPLOAD_MAX_PATH_KEYS = 64;
|
|
8
|
+
export const GRAPHQL_UPLOAD_MAX_MAP_KEYS = 10_000;
|
|
9
|
+
function ignoreStream(stream) {
|
|
10
|
+
stream.on('error', () => { });
|
|
11
|
+
stream.resume();
|
|
12
|
+
}
|
|
13
|
+
function arrayGrowth(container, key) {
|
|
14
|
+
const index = Number.parseInt(key, 10);
|
|
15
|
+
if (index.toString() !== key || !Number.isInteger(index) || index < 0) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
if (container === undefined) {
|
|
19
|
+
return index + 1;
|
|
20
|
+
}
|
|
21
|
+
return Array.isArray(container) ? Math.max(0, index + 1 - container.length) : 0;
|
|
22
|
+
}
|
|
23
|
+
export function processGraphQlUploadRequest(request, response, { maxFieldSize = 1000000, maxFileSize = Infinity, maxFiles = Infinity } = {}) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
let released;
|
|
26
|
+
let exitError;
|
|
27
|
+
let operations;
|
|
28
|
+
let operationsPath;
|
|
29
|
+
let map;
|
|
30
|
+
const parser = busboy({
|
|
31
|
+
headers: request.headers,
|
|
32
|
+
defParamCharset: 'utf8',
|
|
33
|
+
limits: {
|
|
34
|
+
fieldSize: maxFieldSize,
|
|
35
|
+
fields: 2,
|
|
36
|
+
fileSize: maxFileSize,
|
|
37
|
+
files: maxFiles,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
function exit(error, isParserError = false) {
|
|
41
|
+
if (exitError) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
exitError = error;
|
|
45
|
+
if (map) {
|
|
46
|
+
for (const upload of map.values()) {
|
|
47
|
+
if (!upload.file) {
|
|
48
|
+
upload.reject(exitError);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (isParserError) {
|
|
53
|
+
parser.destroy();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
parser.destroy(exitError);
|
|
57
|
+
}
|
|
58
|
+
request.unpipe(parser);
|
|
59
|
+
setImmediate(() => {
|
|
60
|
+
request.resume();
|
|
61
|
+
});
|
|
62
|
+
reject(exitError);
|
|
63
|
+
}
|
|
64
|
+
parser.on('field', (fieldName, value, { valueTruncated }) => {
|
|
65
|
+
if (valueTruncated) {
|
|
66
|
+
return exit(createError(413, `The ‘${fieldName}’ multipart field value exceeds the ${maxFieldSize} byte size limit.`));
|
|
67
|
+
}
|
|
68
|
+
switch (fieldName) {
|
|
69
|
+
case 'operations':
|
|
70
|
+
try {
|
|
71
|
+
operations = JSON.parse(value);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return exit(createError(400, `Invalid JSON in the ‘operations’ multipart field (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
75
|
+
}
|
|
76
|
+
if (typeof operations !== 'object' || !operations) {
|
|
77
|
+
return exit(createError(400, `Invalid type for the ‘operations’ multipart field (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
78
|
+
}
|
|
79
|
+
operationsPath = objectPath(operations);
|
|
80
|
+
break;
|
|
81
|
+
case 'map': {
|
|
82
|
+
if (!operations) {
|
|
83
|
+
return exit(createError(400, `Misordered multipart fields; ‘map’ should follow ‘operations’ (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
84
|
+
}
|
|
85
|
+
let parsedMap;
|
|
86
|
+
try {
|
|
87
|
+
parsedMap = JSON.parse(value);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return exit(createError(400, `Invalid JSON in the ‘map’ multipart field (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
91
|
+
}
|
|
92
|
+
if (typeof parsedMap !== 'object' || !parsedMap || Array.isArray(parsedMap)) {
|
|
93
|
+
return exit(createError(400, `Invalid type for the ‘map’ multipart field (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
94
|
+
}
|
|
95
|
+
const mapEntries = Object.entries(parsedMap);
|
|
96
|
+
if (mapEntries.length > maxFiles) {
|
|
97
|
+
return exit(createError(413, `${maxFiles} max file uploads exceeded.`));
|
|
98
|
+
}
|
|
99
|
+
map = new Map();
|
|
100
|
+
let mapKeyCount = 0;
|
|
101
|
+
for (const [mapFieldName, paths] of mapEntries) {
|
|
102
|
+
if (!Array.isArray(paths)) {
|
|
103
|
+
return exit(createError(400, `Invalid type for the ‘map’ multipart field entry key ‘${mapFieldName}’ array (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
104
|
+
}
|
|
105
|
+
mapKeyCount += 1;
|
|
106
|
+
if (mapKeyCount > GRAPHQL_UPLOAD_MAX_MAP_KEYS) {
|
|
107
|
+
return exit(createError(400, `Invalid ‘map’ multipart field entry key ‘${mapFieldName}’: the map has more than ${GRAPHQL_UPLOAD_MAX_MAP_KEYS} entries and object path keys together (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
108
|
+
}
|
|
109
|
+
map.set(mapFieldName, new Upload());
|
|
110
|
+
for (const [index, path] of paths.entries()) {
|
|
111
|
+
if (typeof path !== 'string') {
|
|
112
|
+
return exit(createError(400, `Invalid type for the ‘map’ multipart field entry key ‘${mapFieldName}’ array index ‘${index}’ value (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const keys = path.split('.');
|
|
116
|
+
if (keys.length > GRAPHQL_UPLOAD_MAX_PATH_KEYS) {
|
|
117
|
+
throw new RangeError(`Object path has more than ${GRAPHQL_UPLOAD_MAX_PATH_KEYS} keys.`);
|
|
118
|
+
}
|
|
119
|
+
mapKeyCount += keys.length;
|
|
120
|
+
if (mapKeyCount > GRAPHQL_UPLOAD_MAX_MAP_KEYS) {
|
|
121
|
+
throw new RangeError(`The map has more than ${GRAPHQL_UPLOAD_MAX_MAP_KEYS} entries and object path keys.`);
|
|
122
|
+
}
|
|
123
|
+
let pathValue = operations;
|
|
124
|
+
for (const [keyIndex, key] of keys.entries()) {
|
|
125
|
+
if (key === '__proto__') {
|
|
126
|
+
throw new TypeError('Object path has a `__proto__` key.');
|
|
127
|
+
}
|
|
128
|
+
const growth = arrayGrowth(pathValue, key);
|
|
129
|
+
if (growth > 0) {
|
|
130
|
+
mapKeyCount += growth;
|
|
131
|
+
if (mapKeyCount > GRAPHQL_UPLOAD_MAX_MAP_KEYS) {
|
|
132
|
+
throw new RangeError(`The map's arrays have more than ${GRAPHQL_UPLOAD_MAX_MAP_KEYS} elements.`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (keyIndex < keys.length - 1) {
|
|
136
|
+
pathValue = objectPath.get(pathValue, [key]);
|
|
137
|
+
if (pathValue instanceof Upload) {
|
|
138
|
+
throw new TypeError('Object path traverses an upload.');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
operationsPath.set(path, map.get(mapFieldName));
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return exit(createError(400, `Invalid object path for the ‘map’ multipart field entry key ‘${mapFieldName}’ array index ‘${index}’ value ‘${path}’ (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
resolve(operations);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
parser.on('file', (fieldName, stream, { encoding, filename, mimeType: mimetype }) => {
|
|
154
|
+
if (!map) {
|
|
155
|
+
ignoreStream(stream);
|
|
156
|
+
return exit(createError(400, `Misordered multipart fields; files should follow ‘map’ (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
157
|
+
}
|
|
158
|
+
const upload = map.get(fieldName);
|
|
159
|
+
if (!upload || upload.file) {
|
|
160
|
+
ignoreStream(stream);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
let fileError;
|
|
164
|
+
const capacitor = new WriteStream();
|
|
165
|
+
capacitor.on('error', () => {
|
|
166
|
+
stream.unpipe();
|
|
167
|
+
stream.resume();
|
|
168
|
+
});
|
|
169
|
+
stream.on('limit', () => {
|
|
170
|
+
fileError = createError(413, `File truncated as it exceeds the ${maxFileSize} byte size limit.`);
|
|
171
|
+
stream.unpipe();
|
|
172
|
+
capacitor.destroy(fileError);
|
|
173
|
+
});
|
|
174
|
+
stream.on('error', (error) => {
|
|
175
|
+
fileError = error;
|
|
176
|
+
stream.unpipe();
|
|
177
|
+
capacitor.destroy(fileError);
|
|
178
|
+
});
|
|
179
|
+
const file = {
|
|
180
|
+
filename,
|
|
181
|
+
mimetype,
|
|
182
|
+
encoding,
|
|
183
|
+
createReadStream(options) {
|
|
184
|
+
const error = fileError || (released ? exitError : null);
|
|
185
|
+
if (error) {
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
return capacitor.createReadStream(options);
|
|
189
|
+
},
|
|
190
|
+
capacitor,
|
|
191
|
+
};
|
|
192
|
+
Object.defineProperty(file, 'capacitor', {
|
|
193
|
+
enumerable: false,
|
|
194
|
+
configurable: false,
|
|
195
|
+
writable: false,
|
|
196
|
+
});
|
|
197
|
+
stream.pipe(capacitor);
|
|
198
|
+
upload.resolve(file);
|
|
199
|
+
});
|
|
200
|
+
parser.once('filesLimit', () => exit(createError(413, `${maxFiles} max file uploads exceeded.`)));
|
|
201
|
+
parser.once('finish', () => {
|
|
202
|
+
request.unpipe(parser);
|
|
203
|
+
request.resume();
|
|
204
|
+
if (!operations) {
|
|
205
|
+
return exit(createError(400, `Missing multipart field ‘operations’ (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
206
|
+
}
|
|
207
|
+
if (!map) {
|
|
208
|
+
return exit(createError(400, `Missing multipart field ‘map’ (${GRAPHQL_MULTIPART_REQUEST_SPEC_URL}).`));
|
|
209
|
+
}
|
|
210
|
+
for (const upload of map.values()) {
|
|
211
|
+
if (!upload.file) {
|
|
212
|
+
upload.reject(createError(400, 'File missing in the request.'));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
parser.on('error', (error) => {
|
|
217
|
+
exit(error, true);
|
|
218
|
+
});
|
|
219
|
+
response.once('close', () => {
|
|
220
|
+
released = true;
|
|
221
|
+
if (map) {
|
|
222
|
+
for (const upload of map.values()) {
|
|
223
|
+
if (upload.file) {
|
|
224
|
+
upload.file.capacitor.release();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
request.once('close', () => {
|
|
230
|
+
if (!request.readableEnded) {
|
|
231
|
+
exit(createError(499, 'Request disconnected during file upload stream parsing.'));
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
request.pipe(parser);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=graphql-upload.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-upload.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/graphql-upload.helper.ts"],"names":[],"mappings":"AAiEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,UAAU,MAAM,aAAa,CAAC;AAMrC,MAAM,kCAAkC,GAAG,+DAA+D,CAAC;AAO3G,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAa/C,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAkClD,SAAS,YAAY,CAAC,MAAgB;IAEpC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAG7B,MAAM,CAAC,MAAM,EAAE,CAAC;AAClB,CAAC;AASD,SAAS,WAAW,CAAC,SAAkB,EAAE,GAAW;IAElD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACvC,IA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C;YAEhB,IAAI,GAAG,EAAE,CAAC;gBACR,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC;oBAClC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;wBAEf,MAAM,CAAC,IAA4B,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;oBAC3D,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;gBAC3B,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,yDAAyD,CAAC,CAAC,CAAC;YACpF,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const SECRET_KEY_PATTERN = /secret|passwd|password|passphrase|credential|api[-_]?key|access[-_]?key|private[-_]?key|encryption|token|\bpass\b|pass$|dsn|salt|key$|(^|[^a-z])key([^a-z]|$)/i;
|
|
1
|
+
const SECRET_KEY_PATTERN = /secret|passwd|password|passphrase|credential|api[-_]?key|access[-_]?key|private[-_]?key|encryption|token|\bpass\b|pass$|dsn|salt|key$|(^|[^a-z])key([^a-z]|$)|pfx|pkcs12/i;
|
|
2
|
+
const PRIVATE_KEY_PEM_PATTERN = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY[A-Z ]*-----/i;
|
|
2
3
|
const URL_KEY_PATTERN = /(url|uri|endpoint|webhook)$/i;
|
|
3
4
|
const URI_PARTS_PATTERN = /^([a-z][a-z0-9+.-]*:\/\/[^/?#]*)(.*)$/is;
|
|
4
5
|
const URI_USERINFO_PATTERN = /^([a-z][a-z0-9+.-]*:\/\/).*@/is;
|
|
@@ -55,10 +56,14 @@ function redactValue(value, underSecretKey, extra, key) {
|
|
|
55
56
|
if (typeof value !== 'string') {
|
|
56
57
|
return value;
|
|
57
58
|
}
|
|
59
|
+
if (PRIVATE_KEY_PEM_PATTERN.test(value)) {
|
|
60
|
+
return REDACTED_VALUE;
|
|
61
|
+
}
|
|
58
62
|
return URL_KEY_PATTERN.test(key) ? redactUrl(value) : redactString(value);
|
|
59
63
|
}
|
|
60
64
|
if (value instanceof Date || Buffer.isBuffer(value)) {
|
|
61
|
-
|
|
65
|
+
const holdsPrivateKey = Buffer.isBuffer(value) && PRIVATE_KEY_PEM_PATTERN.test(value.toString('latin1'));
|
|
66
|
+
return underSecretKey || holdsPrivateKey ? REDACTED_VALUE : value;
|
|
62
67
|
}
|
|
63
68
|
if (Array.isArray(value)) {
|
|
64
69
|
return value.map((item) => redactValue(item, underSecretKey, extra, key));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact-secrets.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/redact-secrets.helper.ts"],"names":[],"mappings":"AA8BA,MAAM,kBAAkB,GACtB,
|
|
1
|
+
{"version":3,"file":"redact-secrets.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/redact-secrets.helper.ts"],"names":[],"mappings":"AA8BA,MAAM,kBAAkB,GACtB,2KAA2K,CAAC;AAa9K,MAAM,uBAAuB,GAAG,+CAA+C,CAAC;AAOhF,MAAM,eAAe,GAAG,8BAA8B,CAAC;AAGvD,MAAM,iBAAiB,GAAG,yCAAyC,CAAC;AAMpE,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAc9D,MAAM,sBAAsB,GAAG,oEAAoE,CAAC;AAOpG,MAAM,uBAAuB,GAAG,+BAA+B,CAAC;AAGhE,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAQpC,MAAM,CAAC,MAAM,uBAAuB,GAAsB;IACxD,UAAU;IACV,mBAAmB;IACnB,oBAAoB;IACpB,6BAA6B;IAC7B,eAAe;IACf,YAAY;IACZ,iBAAiB;CAClB,CAAC;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C,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QACzG,OAAO,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;IACpE,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;QAChF,GAAG,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC,IAAI,EAAE,cAAc,IAAI,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { Injectable } from '@nestjs/common';
|
|
|
8
8
|
import { GqlExecutionContext } from '@nestjs/graphql';
|
|
9
9
|
import { map } from 'rxjs/operators';
|
|
10
10
|
import { applyTranslationsRecursively } from '../helpers/service.helper.js';
|
|
11
|
+
import { isAgentCallContext } from '../helpers/execution-context-request.helper.js';
|
|
11
12
|
let TranslateResponseInterceptor = class TranslateResponseInterceptor {
|
|
12
13
|
intercept(context, next) {
|
|
13
14
|
const language = this.getLanguage(context);
|
|
@@ -57,6 +58,9 @@ let TranslateResponseInterceptor = class TranslateResponseInterceptor {
|
|
|
57
58
|
return '_translations' in data;
|
|
58
59
|
}
|
|
59
60
|
getLanguage(context) {
|
|
61
|
+
if (isAgentCallContext(context)) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
60
64
|
try {
|
|
61
65
|
if (context.getType() === 'graphql') {
|
|
62
66
|
const gqlContext = GqlExecutionContext.create(context);
|