@depup/nestjs__common 12.0.4-depup.0 → 12.1.1-depup.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.
Files changed (39) hide show
  1. package/README.md +2 -2
  2. package/changes.json +1 -1
  3. package/decorators/http/route-params.decorator.d.ts +48 -0
  4. package/decorators/http/route-params.decorator.js +58 -0
  5. package/enums/route-paramtypes.enum.d.ts +3 -1
  6. package/enums/route-paramtypes.enum.js +2 -0
  7. package/index.d.ts +1 -1
  8. package/interfaces/http/cookie-options.interface.d.ts +79 -0
  9. package/interfaces/http/cookie-options.interface.js +1 -0
  10. package/interfaces/http/csrf-protection-options.interface.d.ts +47 -0
  11. package/interfaces/http/csrf-protection-options.interface.js +1 -0
  12. package/interfaces/http/http-server.interface.d.ts +51 -0
  13. package/interfaces/http/index.d.ts +3 -0
  14. package/interfaces/http/index.js +3 -0
  15. package/interfaces/http/security-headers-options.interface.d.ts +142 -0
  16. package/interfaces/http/security-headers-options.interface.js +1 -0
  17. package/interfaces/nest-application-options.interface.d.ts +7 -0
  18. package/interfaces/nest-application.interface.d.ts +43 -0
  19. package/internal.d.ts +1 -1
  20. package/package.json +4 -4
  21. package/pipes/parse-array.pipe.d.ts +1 -0
  22. package/pipes/parse-array.pipe.js +18 -3
  23. package/pipes/parse-date.pipe.d.ts +2 -1
  24. package/pipes/parse-date.pipe.js +8 -2
  25. package/pipes/parse-enum.pipe.js +3 -1
  26. package/services/console-logger.service.d.ts +71 -4
  27. package/services/console-logger.service.js +182 -14
  28. package/services/log-levels.constant.d.ts +5 -0
  29. package/services/log-levels.constant.js +8 -0
  30. package/services/logger.service.d.ts +6 -6
  31. package/services/logger.service.js +25 -9
  32. package/services/utils/filter-log-levels.util.d.ts +1 -1
  33. package/services/utils/filter-log-levels.util.js +1 -1
  34. package/services/utils/get-env-log-levels.util.d.ts +14 -0
  35. package/services/utils/get-env-log-levels.util.js +25 -0
  36. package/services/utils/is-log-level.util.d.ts +1 -1
  37. package/services/utils/is-log-level.util.js +1 -1
  38. package/services/utils/redact.util.d.ts +27 -0
  39. package/services/utils/redact.util.js +225 -0
package/README.md CHANGED
@@ -13,8 +13,8 @@ npm install @depup/nestjs__common
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@nestjs/common](https://www.npmjs.com/package/@nestjs/common) @ 12.0.4 |
17
- | Processed | 2026-09-21 |
16
+ | Original | [@nestjs/common](https://www.npmjs.com/package/@nestjs/common) @ 12.1.1 |
17
+ | Processed | 2026-09-28 |
18
18
  | Smoke test | passed |
19
19
  | Deps updated | 0 |
20
20
 
package/changes.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "bumped": {},
3
- "timestamp": "2026-09-21T08:13:01.677Z",
3
+ "timestamp": "2026-09-28T16:10:42.807Z",
4
4
  "totalUpdated": 0
5
5
  }
@@ -591,6 +591,54 @@ export declare function HostParam(): ParameterDecorator;
591
591
  * @publicApi
592
592
  */
593
593
  export declare function HostParam(property: string): ParameterDecorator;
594
+ /**
595
+ * Route handler parameter decorator. Extracts the cookies sent with the
596
+ * request (all of them, or a single one by name) and populates the decorated
597
+ * parameter with that value. May also apply pipes to the bound parameter.
598
+ *
599
+ * Works the same on every HTTP adapter, with no extra package: the `Cookie`
600
+ * header is parsed once per request. When a cookie middleware (such as
601
+ * `cookie-parser` or `@fastify/cookie`) already populated `req.cookies`, that
602
+ * object is used instead. Signatures are not verified here; read signed
603
+ * cookies with `@SignedCookies()`.
604
+ *
605
+ * For example:
606
+ * ```typescript
607
+ * findAll(@Cookies('theme') theme?: string)
608
+ * ```
609
+ *
610
+ * @param property name of a single cookie to extract
611
+ * @param pipes one or more pipes to apply to the bound parameter
612
+ *
613
+ * @see [Cookies](https://docs.nestjs.com/techniques/cookies)
614
+ *
615
+ * @publicApi
616
+ */
617
+ export declare function Cookies(property?: string | (Type<PipeTransform> | PipeTransform), ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
618
+ /**
619
+ * Route handler parameter decorator. Extracts the signed cookies sent with
620
+ * the request (all of them, or a single one by name), verified against the
621
+ * `cookies.secret` application option, and populates the decorated parameter
622
+ * with the unsigned value. A cookie whose signature does not verify resolves
623
+ * to `undefined` (and is left out when reading all signed cookies).
624
+ *
625
+ * Without a `cookies.secret`, falls back to `req.signedCookies` as populated
626
+ * by `cookie-parser`; when neither is available, resolving the parameter
627
+ * throws.
628
+ *
629
+ * For example:
630
+ * ```typescript
631
+ * profile(@SignedCookies('uid') userId?: string)
632
+ * ```
633
+ *
634
+ * @param property name of a single signed cookie to extract
635
+ * @param pipes one or more pipes to apply to the bound parameter
636
+ *
637
+ * @see [Cookies](https://docs.nestjs.com/techniques/cookies)
638
+ *
639
+ * @publicApi
640
+ */
641
+ export declare function SignedCookies(property?: string | (Type<PipeTransform> | PipeTransform), ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
594
642
  /**
595
643
  * Route handler parameter decorator. Extracts the `Request`
596
644
  * object from the underlying platform and populates the decorated
@@ -334,6 +334,64 @@ export function Param(property, optionsOrPipe, ...pipes) {
334
334
  export function HostParam(property) {
335
335
  return createRouteParamDecorator(RouteParamtypes.HOST)(property);
336
336
  }
337
+ /**
338
+ * Route handler parameter decorator. Extracts the cookies sent with the
339
+ * request (all of them, or a single one by name) and populates the decorated
340
+ * parameter with that value. May also apply pipes to the bound parameter.
341
+ *
342
+ * Works the same on every HTTP adapter, with no extra package: the `Cookie`
343
+ * header is parsed once per request. When a cookie middleware (such as
344
+ * `cookie-parser` or `@fastify/cookie`) already populated `req.cookies`, that
345
+ * object is used instead. Signatures are not verified here; read signed
346
+ * cookies with `@SignedCookies()`.
347
+ *
348
+ * For example:
349
+ * ```typescript
350
+ * findAll(@Cookies('theme') theme?: string)
351
+ * ```
352
+ *
353
+ * @param property name of a single cookie to extract
354
+ * @param pipes one or more pipes to apply to the bound parameter
355
+ *
356
+ * @see [Cookies](https://docs.nestjs.com/techniques/cookies)
357
+ *
358
+ * @publicApi
359
+ */
360
+ export function Cookies(property, ...pipes) {
361
+ return createPipesRouteParamDecorator(RouteParamtypes.COOKIES)({
362
+ data: property,
363
+ pipes,
364
+ });
365
+ }
366
+ /**
367
+ * Route handler parameter decorator. Extracts the signed cookies sent with
368
+ * the request (all of them, or a single one by name), verified against the
369
+ * `cookies.secret` application option, and populates the decorated parameter
370
+ * with the unsigned value. A cookie whose signature does not verify resolves
371
+ * to `undefined` (and is left out when reading all signed cookies).
372
+ *
373
+ * Without a `cookies.secret`, falls back to `req.signedCookies` as populated
374
+ * by `cookie-parser`; when neither is available, resolving the parameter
375
+ * throws.
376
+ *
377
+ * For example:
378
+ * ```typescript
379
+ * profile(@SignedCookies('uid') userId?: string)
380
+ * ```
381
+ *
382
+ * @param property name of a single signed cookie to extract
383
+ * @param pipes one or more pipes to apply to the bound parameter
384
+ *
385
+ * @see [Cookies](https://docs.nestjs.com/techniques/cookies)
386
+ *
387
+ * @publicApi
388
+ */
389
+ export function SignedCookies(property, ...pipes) {
390
+ return createPipesRouteParamDecorator(RouteParamtypes.SIGNED_COOKIES)({
391
+ data: property,
392
+ pipes,
393
+ });
394
+ }
337
395
  /**
338
396
  * Route handler parameter decorator. Extracts the `Request`
339
397
  * object from the underlying platform and populates the decorated
@@ -12,5 +12,7 @@ export declare enum RouteParamtypes {
12
12
  HOST = 10,
13
13
  IP = 11,
14
14
  RAW_BODY = 12,
15
- ACK = 13
15
+ ACK = 13,
16
+ COOKIES = 14,
17
+ SIGNED_COOKIES = 15
16
18
  }
@@ -14,4 +14,6 @@ export var RouteParamtypes;
14
14
  RouteParamtypes[RouteParamtypes["IP"] = 11] = "IP";
15
15
  RouteParamtypes[RouteParamtypes["RAW_BODY"] = 12] = "RAW_BODY";
16
16
  RouteParamtypes[RouteParamtypes["ACK"] = 13] = "ACK";
17
+ RouteParamtypes[RouteParamtypes["COOKIES"] = 14] = "COOKIES";
18
+ RouteParamtypes[RouteParamtypes["SIGNED_COOKIES"] = 15] = "SIGNED_COOKIES";
17
19
  })(RouteParamtypes || (RouteParamtypes = {}));
package/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from './decorators/index.js';
3
3
  export * from './enums/index.js';
4
4
  export * from './exceptions/index.js';
5
5
  export * from './file-stream/index.js';
6
- export { Abstract, ArgumentMetadata, ArgumentsHost, BeforeApplicationShutdown, CallHandler, CanActivate, ClassProvider, ContextType, DynamicModule, ExceptionFilter, ExecutionContext, ExistingProvider, FactoryProvider, ForwardReference, HttpServer, HttpExceptionBody, HttpExceptionBodyMessage, HttpRedirectResponse, INestApplication, INestApplicationContext, INestMicroservice, ITransportServer, InjectionToken, IntrospectionResult, MessageEvent, MiddlewareConsumer, ModuleMetadata, NestApplicationOptions, NestHybridApplicationOptions, NestInterceptor, NestMiddleware, PreRequestHook, NestModule, OnApplicationBootstrap, OnApplicationShutdown, OnModuleDestroy, OnModuleInit, OptionalFactoryDependency, Paramtype, PipeTransform, Provider, RawBodyRequest, RouteConflictPolicy, RouteConflictPolicyLevel, RouteResolutionStrategy, RpcExceptionFilter, Scope, ScopeOptions, Type, ValidationError, ValueProvider, VersioningOptions, VERSION_NEUTRAL, WebSocketAdapter, WsExceptionFilter, WsMessageHandler, } from './interfaces/index.js';
6
+ export { Abstract, ArgumentMetadata, ArgumentsHost, BeforeApplicationShutdown, CallHandler, CanActivate, ClassProvider, ContentSecurityPolicyDirectiveValue, ContentSecurityPolicyOptions, ContextType, CookieSerializeOptions, CookiesOptions, CsrfProtectionOptions, DynamicModule, ExceptionFilter, ExecutionContext, ExistingProvider, FactoryProvider, ForwardReference, HttpServer, HttpExceptionBody, HttpExceptionBodyMessage, HttpRedirectResponse, INestApplication, INestApplicationContext, INestMicroservice, ITransportServer, InjectionToken, IntrospectionResult, MessageEvent, MiddlewareConsumer, ModuleMetadata, NestApplicationOptions, NestHybridApplicationOptions, NestInterceptor, NestMiddleware, PreRequestHook, NestModule, OnApplicationBootstrap, OnApplicationShutdown, OnModuleDestroy, OnModuleInit, OptionalFactoryDependency, Paramtype, PipeTransform, Provider, RawBodyRequest, ReferrerPolicyToken, RouteConflictPolicy, RouteConflictPolicyLevel, RouteResolutionStrategy, RpcExceptionFilter, Scope, ScopeOptions, SecurityHeadersOptions, Type, ValidationError, ValueProvider, VersioningOptions, VERSION_NEUTRAL, WebSocketAdapter, WsExceptionFilter, WsMessageHandler, } from './interfaces/index.js';
7
7
  export * from './module-utils/index.js';
8
8
  export * from './pipes/index.js';
9
9
  export * from './serializer/index.js';
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Attributes of a `Set-Cookie` header written by `HttpServer.setCookie()` and
3
+ * `HttpServer.clearCookie()`.
4
+ *
5
+ * @see [RFC 6265, section 4.1](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1)
6
+ *
7
+ * @publicApi
8
+ */
9
+ export interface CookieSerializeOptions {
10
+ /**
11
+ * `Path` attribute.
12
+ *
13
+ * @default '/'
14
+ */
15
+ path?: string;
16
+ /**
17
+ * `Domain` attribute. Omitted by default, which makes the cookie host-only.
18
+ */
19
+ domain?: string;
20
+ /**
21
+ * `Max-Age` attribute, in **seconds**, as in RFC 6265 and `@fastify/cookie`.
22
+ * Must be an integer.
23
+ *
24
+ * **Not milliseconds**: Express' `res.cookie()` takes `maxAge` in
25
+ * milliseconds, so a value carried over from it would make the cookie live
26
+ * 1000 times longer. For one day, pass `60 * 60 * 24`.
27
+ */
28
+ maxAge?: number;
29
+ /**
30
+ * `Expires` attribute. Browsers give precedence to `maxAge` when both are
31
+ * set.
32
+ */
33
+ expires?: Date;
34
+ /**
35
+ * `HttpOnly` attribute.
36
+ */
37
+ httpOnly?: boolean;
38
+ /**
39
+ * `Secure` attribute.
40
+ */
41
+ secure?: boolean;
42
+ /**
43
+ * `SameSite` attribute. `'none'` requires `secure: true`, since browsers
44
+ * reject `SameSite=None` cookies that are not `Secure`.
45
+ */
46
+ sameSite?: 'strict' | 'lax' | 'none';
47
+ /**
48
+ * `Partitioned` attribute (CHIPS). Requires `secure: true`, since browsers
49
+ * reject partitioned cookies that are not `Secure`.
50
+ */
51
+ partitioned?: boolean;
52
+ /**
53
+ * `Priority` attribute (non-standard, honored by Chromium).
54
+ */
55
+ priority?: 'low' | 'medium' | 'high';
56
+ /**
57
+ * Whether to sign the value with the first secret configured through the
58
+ * `cookies.secret` application option. Signed cookies are read with the
59
+ * `@SignedCookies()` decorator.
60
+ *
61
+ * @default false
62
+ */
63
+ signed?: boolean;
64
+ }
65
+ /**
66
+ * The `cookies` option of `NestFactory.create()`.
67
+ *
68
+ * @publicApi
69
+ */
70
+ export interface CookiesOptions {
71
+ /**
72
+ * Secret (or secrets) used to sign and verify cookies. When an array is
73
+ * given, cookies are signed with the first secret and verified against all
74
+ * of them, which allows rotating secrets without invalidating cookies
75
+ * signed with a previous one. An empty string, an empty array or an empty
76
+ * entry throws when the application is created.
77
+ */
78
+ secret?: string | string[];
79
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
1
+ import type { RouteInfo } from '../middleware/middleware-configuration.interface.js';
2
+ /**
3
+ * Options for `app.enableCsrfProtection()`.
4
+ *
5
+ * The protection is based on Fetch Metadata (`Sec-Fetch-Site`) with an
6
+ * `Origin`/`Host` fallback, following the algorithm of Go's
7
+ * `net/http.CrossOriginProtection`. It is not a token scheme: it relies on the
8
+ * browser telling the server where a request comes from, which every
9
+ * evergreen browser does since 2023.
10
+ *
11
+ * Browsers only send `Sec-Fetch-Site` to secure origins (HTTPS or
12
+ * `localhost`). Otherwise the `Origin` header is compared with the `Host`
13
+ * header the server receives (`X-Forwarded-Host` is ignored). Behind a proxy
14
+ * that rewrites `Host`, preserve it, or list the public origin in
15
+ * `trustedOrigins`.
16
+ *
17
+ * @publicApi
18
+ */
19
+ export interface CsrfProtectionOptions<TRequest = any> {
20
+ /**
21
+ * Origins that may send cross-origin, state-changing requests, e.g.
22
+ * `https://admin.example.com`. Each entry must be a serialized origin:
23
+ * `scheme://host[:port]`, without a path, query string, fragment or
24
+ * wildcard. Entries are normalized the way browsers serialize `Origin`
25
+ * (lower-case, without the default port), and a request is exempt when its
26
+ * `Origin` header equals one of them.
27
+ *
28
+ * Origins allowed by CORS are not trusted implicitly: list them here too.
29
+ */
30
+ trustedOrigins?: string[];
31
+ /**
32
+ * Requests that skip the protection altogether (for example webhook
33
+ * endpoints called by third-party servers that send a foreign `Origin`).
34
+ *
35
+ * Either a list of routes, or a predicate receiving the platform request
36
+ * object. Only consulted for requests that would otherwise be rejected.
37
+ *
38
+ * Routes are declared like `MiddlewareConsumer.exclude()`: a path, or
39
+ * `{ path, method, version? }` to narrow by method (and URI version),
40
+ * without the global prefix, which is added unless the route is excluded
41
+ * from it. Unlike `exclude()`, the match is exact: case-sensitive, without
42
+ * an optional trailing slash, and never for non-canonical request paths
43
+ * (`//`, dot segments, `;`, encoded `/` or `.`), which a router could
44
+ * resolve to a route that is not excluded.
45
+ */
46
+ exclude?: (string | RouteInfo)[] | ((request: TRequest) => boolean);
47
+ }
@@ -1,6 +1,7 @@
1
1
  import { RequestMethod } from '../../enums/index.js';
2
2
  import { NestApplicationOptions } from '../../interfaces/nest-application-options.interface.js';
3
3
  import { VersionValue, VersioningOptions } from '../version-options.interface.js';
4
+ import { CookieSerializeOptions } from './cookie-options.interface.js';
4
5
  /**
5
6
  * Shape of the error-layer callback that Nest hands to
6
7
  * {@link HttpServer.setErrorHandler}.
@@ -37,6 +38,19 @@ export type ErrorHandler<TRequest = any, TResponse = any> = (error: any, req: TR
37
38
  * @publicApi
38
39
  */
39
40
  export type RequestHandler<TRequest = any, TResponse = any> = (req: TRequest, res: TResponse, next?: Function) => any;
41
+ /**
42
+ * Request hook of the built-in HTTP security features, handed to
43
+ * {@link HttpServer.registerSecurityHook}. It receives the request and the
44
+ * Node.js `ServerResponse` (of which it only uses `setHeader()` and
45
+ * `removeHeader()`), and returns the error to hand to the exception layer
46
+ * when the request must be rejected.
47
+ *
48
+ * @publicApi
49
+ */
50
+ export type SecurityRequestHook<TRequest = any> = (request: TRequest, response: {
51
+ setHeader(name: string, value: string): unknown;
52
+ removeHeader(name: string): unknown;
53
+ }) => Error | undefined;
40
54
  /**
41
55
  * Contract between the Nest core (`NestApplication`, the router, the
42
56
  * middleware module and the exception layer) and an HTTP platform such as
@@ -356,6 +370,20 @@ export interface HttpServer<TRequest = any, TResponse = any, ServerInstance = an
356
370
  * right after {@link HttpServer.status}. Not awaited.
357
371
  */
358
372
  setHeader(response: any, name: string, value: string): any;
373
+ /**
374
+ * Appends a `Set-Cookie` header to the response, so several cookies set
375
+ * during the same request accumulate. Not called by the core;
376
+ * `AbstractHttpAdapter` implements it on top of its `appendHeader()`.
377
+ * Throws a `TypeError` when the name, the value or an attribute is not
378
+ * valid per RFC 6265. Note that `options.maxAge` is in seconds.
379
+ */
380
+ setCookie?(response: TResponse, name: string, value: string, options?: CookieSerializeOptions): any;
381
+ /**
382
+ * Appends a `Set-Cookie` header that expires the cookie. `path` and
383
+ * `domain` must match the ones the cookie was set with. Not called by the
384
+ * core; `AbstractHttpAdapter` implements it.
385
+ */
386
+ clearCookie?(response: TResponse, name: string, options?: CookieSerializeOptions): any;
359
387
  /**
360
388
  * Installs the global exception layer: an {@link ErrorHandler} that
361
389
  * forwards errors to the registered exception filters. The core calls it
@@ -479,6 +507,29 @@ export interface HttpServer<TRequest = any, TResponse = any, ServerInstance = an
479
507
  * for `cors: true`.
480
508
  */
481
509
  enableCors(options: any): any;
510
+ /**
511
+ * Installs the request hook of the built-in HTTP security features
512
+ * (`app.enableCsrfProtection()`, `app.useSecurityHeaders()`). The core
513
+ * composes the features into this one hook and owns their logic; the
514
+ * adapter only decides where the hook runs.
515
+ *
516
+ * Called at most once, before `app.init()`, the first time one of the
517
+ * features is enabled. The hook must run for every request (matched routes,
518
+ * unmatched requests, routes outside the global prefix) before Nest
519
+ * middleware, guards and route handlers, and before body parsing when the
520
+ * platform allows it; registering a framework-level middleware or request
521
+ * hook at call time satisfies that on Express and Fastify. It receives the
522
+ * request and the Node.js `ServerResponse` (`reply.raw` on Fastify), on
523
+ * which it may set headers that route handlers, `@Header()` and exception
524
+ * filters can still override.
525
+ *
526
+ * When the hook returns an error, the adapter must not continue to the
527
+ * route: it hands the error to the exception layer installed through
528
+ * {@link HttpServer.setErrorHandler} (`next(error)` on Express,
529
+ * `done(error)` in a Fastify hook), so exception filters shape the
530
+ * response. Optional: when absent, enabling a feature throws.
531
+ */
532
+ registerSecurityHook?(hook: SecurityRequestHook<TRequest>): any;
482
533
  /**
483
534
  * Returns the native HTTP server created by
484
535
  * {@link HttpServer.initHttpServer}. It must behave like a Node.js
@@ -1,5 +1,8 @@
1
+ export * from './cookie-options.interface.js';
2
+ export * from './csrf-protection-options.interface.js';
1
3
  export * from './http-exception-body.interface.js';
2
4
  export * from './http-redirect-response.interface.js';
3
5
  export * from './http-server.interface.js';
4
6
  export * from './message-event.interface.js';
5
7
  export * from './raw-body-request.interface.js';
8
+ export * from './security-headers-options.interface.js';
@@ -1,5 +1,8 @@
1
+ export * from './cookie-options.interface.js';
2
+ export * from './csrf-protection-options.interface.js';
1
3
  export * from './http-exception-body.interface.js';
2
4
  export * from './http-redirect-response.interface.js';
3
5
  export * from './http-server.interface.js';
4
6
  export * from './message-event.interface.js';
5
7
  export * from './raw-body-request.interface.js';
8
+ export * from './security-headers-options.interface.js';
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Value of a Content-Security-Policy directive:
3
+ *
4
+ * - a string or a list of strings: the directive's source expressions
5
+ * (keywords must be quoted, e.g. `"'self'"`);
6
+ * - `true` or an empty list: a directive without value (e.g.
7
+ * `upgrade-insecure-requests`);
8
+ * - `null` or `false`: removes the directive, including a default one.
9
+ *
10
+ * @publicApi
11
+ */
12
+ export type ContentSecurityPolicyDirectiveValue = string | readonly string[] | boolean | null;
13
+ /**
14
+ * @publicApi
15
+ */
16
+ export interface ContentSecurityPolicyOptions {
17
+ /**
18
+ * Whether `directives` are merged into the default directives. When
19
+ * `false`, only `directives` are sent, and they must include `default-src`
20
+ * (or remove it explicitly with `defaultSrc: null`).
21
+ *
22
+ * @default true
23
+ */
24
+ useDefaults?: boolean;
25
+ /**
26
+ * Directives keyed by name, in camelCase (`scriptSrc`) or kebab-case
27
+ * (`'script-src'`). A directive given here replaces the default directive
28
+ * of the same name.
29
+ */
30
+ directives?: Record<string, ContentSecurityPolicyDirectiveValue>;
31
+ /**
32
+ * Sends `Content-Security-Policy-Report-Only` instead, so violations are
33
+ * reported (see the `report-to` directive) but not blocked.
34
+ *
35
+ * @default false
36
+ */
37
+ reportOnly?: boolean;
38
+ }
39
+ /**
40
+ * Options for `app.useSecurityHeaders()`.
41
+ *
42
+ * Each key controls one header and accepts `false` to leave that header out,
43
+ * `true` for its default value (the same defaults as helmet 8), or an object
44
+ * to configure it. Option names match helmet's, so existing helmet
45
+ * configurations carry over, except for helmet's legacy aliases (`hsts`,
46
+ * `frameguard`, ...). Unknown options are rejected.
47
+ *
48
+ * @publicApi
49
+ */
50
+ export interface SecurityHeadersOptions {
51
+ /**
52
+ * `Content-Security-Policy`. Default: `default-src 'self'; base-uri 'self';
53
+ * font-src 'self' https: data:; form-action 'self'; frame-ancestors 'self';
54
+ * img-src 'self' data:; object-src 'none'; script-src 'self';
55
+ * script-src-attr 'none'; style-src 'self' https: 'unsafe-inline';
56
+ * upgrade-insecure-requests` (serialized without spaces after `;`).
57
+ */
58
+ contentSecurityPolicy?: boolean | ContentSecurityPolicyOptions;
59
+ /**
60
+ * `Cross-Origin-Embedder-Policy`. Not sent by default; `true` sends
61
+ * `require-corp`.
62
+ */
63
+ crossOriginEmbedderPolicy?: boolean | {
64
+ policy?: 'require-corp' | 'credentialless' | 'unsafe-none';
65
+ };
66
+ /**
67
+ * `Cross-Origin-Opener-Policy`. Default: `same-origin`.
68
+ */
69
+ crossOriginOpenerPolicy?: boolean | {
70
+ policy?: 'same-origin' | 'same-origin-allow-popups' | 'noopener-allow-popups' | 'unsafe-none';
71
+ };
72
+ /**
73
+ * `Cross-Origin-Resource-Policy`. Default: `same-origin`.
74
+ */
75
+ crossOriginResourcePolicy?: boolean | {
76
+ policy?: 'same-origin' | 'same-site' | 'cross-origin';
77
+ };
78
+ /**
79
+ * `Origin-Agent-Cluster: ?1`.
80
+ */
81
+ originAgentCluster?: boolean;
82
+ /**
83
+ * `Referrer-Policy`. Default: `no-referrer`. A list is sent as a fallback
84
+ * chain (the browser uses the last one it supports).
85
+ */
86
+ referrerPolicy?: boolean | {
87
+ policy?: ReferrerPolicyToken | readonly ReferrerPolicyToken[];
88
+ };
89
+ /**
90
+ * `Strict-Transport-Security`. Default: `max-age=31536000;
91
+ * includeSubDomains`. Browsers ignore it over plain HTTP.
92
+ */
93
+ strictTransportSecurity?: boolean | {
94
+ /** In seconds. @default 31536000 (365 days) */
95
+ maxAge?: number;
96
+ /** @default true */
97
+ includeSubDomains?: boolean;
98
+ /** @default false */
99
+ preload?: boolean;
100
+ };
101
+ /**
102
+ * `X-Content-Type-Options: nosniff`.
103
+ */
104
+ xContentTypeOptions?: boolean;
105
+ /**
106
+ * `X-DNS-Prefetch-Control`. Default: `off`; `{ allow: true }` sends `on`.
107
+ */
108
+ xDnsPrefetchControl?: boolean | {
109
+ allow?: boolean;
110
+ };
111
+ /**
112
+ * `X-Download-Options: noopen`.
113
+ */
114
+ xDownloadOptions?: boolean;
115
+ /**
116
+ * `X-Frame-Options`. Default: `SAMEORIGIN`. Superseded by the CSP
117
+ * `frame-ancestors` directive, kept for older browsers.
118
+ */
119
+ xFrameOptions?: boolean | {
120
+ action?: 'deny' | 'sameorigin';
121
+ };
122
+ /**
123
+ * `X-Permitted-Cross-Domain-Policies`. Default: `none`.
124
+ */
125
+ xPermittedCrossDomainPolicies?: boolean | {
126
+ permittedPolicies?: 'none' | 'master-only' | 'by-content-type' | 'all';
127
+ };
128
+ /**
129
+ * Removes the `X-Powered-By` header (on Express, also disables the
130
+ * `x-powered-by` setting). `false` leaves it untouched.
131
+ */
132
+ xPoweredBy?: boolean;
133
+ /**
134
+ * `X-XSS-Protection: 0`, which disables the legacy XSS auditor of old
135
+ * browsers (a source of vulnerabilities itself).
136
+ */
137
+ xXssProtection?: boolean;
138
+ }
139
+ /**
140
+ * @publicApi
141
+ */
142
+ export type ReferrerPolicyToken = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
@@ -1,5 +1,6 @@
1
1
  import { CorsOptions, CorsOptionsDelegate } from './external/cors-options.interface.js';
2
2
  import { HttpsOptions } from './external/https-options.interface.js';
3
+ import { CookiesOptions } from './http/cookie-options.interface.js';
3
4
  import { NestApplicationContextOptions } from './nest-application-context-options.interface.js';
4
5
  import { RouteConflictPolicy, RouteResolutionStrategy } from './router-options.interface.js';
5
6
  /**
@@ -47,4 +48,10 @@ export interface NestApplicationOptions extends NestApplicationContextOptions {
47
48
  * to `'declaration'`.
48
49
  */
49
50
  routeResolutionStrategy?: RouteResolutionStrategy;
51
+ /**
52
+ * Built-in cookie support. `secret` enables signing cookies with
53
+ * `setCookie(..., { signed: true })` and reading them with
54
+ * `@SignedCookies()`.
55
+ */
56
+ cookies?: CookiesOptions;
50
57
  }
@@ -1,7 +1,9 @@
1
1
  import { CanActivate } from './features/can-activate.interface.js';
2
2
  import { NestInterceptor } from './features/nest-interceptor.interface.js';
3
3
  import { GlobalPrefixOptions } from './global-prefix-options.interface.js';
4
+ import { CsrfProtectionOptions } from './http/csrf-protection-options.interface.js';
4
5
  import { HttpServer } from './http/http-server.interface.js';
6
+ import { SecurityHeadersOptions } from './http/security-headers-options.interface.js';
5
7
  import { ExceptionFilter, INestMicroservice, NestHybridApplicationOptions, PipeTransform } from './index.js';
6
8
  import { INestApplicationContext } from './nest-application-context.interface.js';
7
9
  import { VersioningOptions } from './version-options.interface.js';
@@ -25,6 +27,47 @@ export interface INestApplication<TServer = any> extends INestApplicationContext
25
27
  * @returns {void}
26
28
  */
27
29
  enableCors(options?: any): void;
30
+ /**
31
+ * Enables protection against cross-site request forgery (CSRF) for every
32
+ * route, based on Fetch Metadata (`Sec-Fetch-Site`) with an `Origin`/`Host`
33
+ * fallback (the algorithm of Go's `net/http.CrossOriginProtection`).
34
+ *
35
+ * `GET`, `HEAD` and `OPTIONS` requests are always allowed. Other requests
36
+ * are rejected with a `ForbiddenException`, which goes through the
37
+ * exception filters, when the browser reports them as cross-origin.
38
+ * Requests carrying neither `Sec-Fetch-Site` nor `Origin` (non-browser
39
+ * clients) are allowed.
40
+ *
41
+ * Must be called once, before `app.init()` / `app.listen()`. The check runs
42
+ * before Nest middleware, body parsing, guards and handlers. It shares one
43
+ * request hook with `app.useSecurityHeaders()`, registered where the first
44
+ * of the two is called: middleware registered with `app.use()` before that
45
+ * runs before the check.
46
+ *
47
+ * @param {CsrfProtectionOptions} options
48
+ * @returns {this}
49
+ */
50
+ enableCsrfProtection(options?: CsrfProtectionOptions): this;
51
+ /**
52
+ * Sets security-related response headers on every response (routes,
53
+ * `404`s and errors, including rejections of `enableCsrfProtection()`):
54
+ * the same headers and defaults as helmet 8, including a default
55
+ * Content-Security-Policy, and removes `X-Powered-By`.
56
+ *
57
+ * Pass `false` for a header to leave it out, `true` for its default, or an
58
+ * object to configure it. Options are validated when this method is
59
+ * called. Route handlers and `@Header()` can still override a header per
60
+ * route.
61
+ *
62
+ * Must be called once, before `app.init()` / `app.listen()`. It shares one
63
+ * request hook with `app.enableCsrfProtection()`, registered where the
64
+ * first of the two is called: middleware registered with `app.use()` before
65
+ * that runs first, so responses it ends itself do not carry the headers.
66
+ *
67
+ * @param {SecurityHeadersOptions} options
68
+ * @returns {this}
69
+ */
70
+ useSecurityHeaders(options?: SecurityHeadersOptions): this;
28
71
  /**
29
72
  * Enables Versioning for the application.
30
73
  * By default, URI-based versioning is used.
package/internal.d.ts CHANGED
@@ -25,7 +25,7 @@ export type { MiddlewareConfiguration, RouteInfo, } from './interfaces/middlewar
25
25
  export type { MiddlewareConfigProxy } from './interfaces/middleware/middleware-config-proxy.interface.js';
26
26
  export type { ModuleMetadata } from './interfaces/modules/module-metadata.interface.js';
27
27
  export type { HttpArgumentsHost, RpcArgumentsHost, WsArgumentsHost, } from './interfaces/features/arguments-host.interface.js';
28
- export type { RequestHandler } from './interfaces/http/http-server.interface.js';
28
+ export type { RequestHandler, SecurityRequestHook, } from './interfaces/http/http-server.interface.js';
29
29
  export type { GetOrResolveOptions, SelectOptions, } from './interfaces/nest-application-context.interface.js';
30
30
  export type { ShutdownHooksOptions } from './interfaces/shutdown-hooks-options.interface.js';
31
31
  export { assignMetadata } from './decorators/http/route-params.decorator.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depup/nestjs__common",
3
- "version": "12.0.4-depup.0",
3
+ "version": "12.1.1-depup.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@common) (with updated dependencies)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "homepage": "https://nestjs.com",
@@ -44,7 +44,7 @@
44
44
  "optional": true
45
45
  }
46
46
  },
47
- "gitHead": "899dbe3a0c1e59d1d0fb7e0c7ad0b2d2aa4ae771",
47
+ "gitHead": "9feedffde8ef8c86f0cd521153740575dc579d88",
48
48
  "keywords": [
49
49
  "@nestjs/common",
50
50
  "depup",
@@ -57,8 +57,8 @@
57
57
  "changes": {},
58
58
  "depsUpdated": 0,
59
59
  "originalPackage": "@nestjs/common",
60
- "originalVersion": "12.0.4",
61
- "processedAt": "2026-09-21T08:13:04.687Z",
60
+ "originalVersion": "12.1.1",
61
+ "processedAt": "2026-09-28T16:10:47.564Z",
62
62
  "smokeTest": "passed"
63
63
  }
64
64
  }