@telperion/nest-pack 1.2.0 → 1.3.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.
@@ -132,5 +132,5 @@
132
132
  }
133
133
  }
134
134
  ],
135
- "generatedAt": "2026-12-01T16:45:38.292Z"
135
+ "generatedAt": "2026-12-02T11:03:41.174Z"
136
136
  }
package/README.md CHANGED
@@ -64,6 +64,8 @@ export class HuddlesController {
64
64
  | expired token | **401** `expiredMessage` (`'TokenExpired'`), so clients can renew the token and retry |
65
65
  | valid token | passes; the payload is on `request.user`, `@AuthGuard.user()` and `AuthGuard.userOf(request)` |
66
66
 
67
+ Markers are per guard: `AuthGuard.isPublic()` reads only the `public()` markers of `AuthGuard`.
68
+
67
69
  **Options** (all optional):
68
70
 
69
71
  - `extract(request)` — reads the token; default: `Authorization: Bearer <token>` (scheme case-insensitive)
@@ -71,6 +73,17 @@ export class HuddlesController {
71
73
  - `expiredMessage`, `unauthorizedMessage` — messages of the 401 answers
72
74
  - `property` — the request property the payload is written to (default `'user'`, where Passport and most code expect it)
73
75
 
76
+ **Public routes in other guards and interceptors**: `AuthGuard.isPublic(context)` tells whether the route is marked with `@AuthGuard.public()` (a method's setting replaces its controller's), so throttling, auditing or user-resolving code can skip public routes without knowing the metadata key. Pass the injected `Reflector` as the second argument, or leave it out to use one of the guard's own.
77
+
78
+ ```typescript
79
+ @Injectable()
80
+ export class CurrentUserInterceptor implements NestInterceptor {
81
+ intercept(context: ExecutionContext, next: CallHandler) {
82
+ return AuthGuard.isPublic(context) ? next.handle() : this.users.resolve(context).pipe(switchMap(() => next.handle()));
83
+ }
84
+ }
85
+ ```
86
+
74
87
  With `@telperion/ng-pack/http`, detect the expired answer in `ApiAuth.expired`: `error => error.status === 401 && error.error?.message === 'TokenExpired'`.
75
88
 
76
89
  ## Access
@@ -46,9 +46,11 @@ var jwt = require('@nestjs/jwt');
46
46
  * ```
47
47
  *
48
48
  * To give the guard a class name of its own, extend it: `@Injectable() export class AuthGuard extends createJwtAuthGuard<TokenPayload>() {}`.
49
+ *
50
+ * Other guards and interceptors can skip public routes with `AuthGuard.isPublic(context)`.
49
51
  * * * *
50
52
  * @param options Messages, where the token comes from, verification options and where the payload goes
51
- * @returns An injectable guard class with `public()`, `user()` and `userOf()`
53
+ * @returns An injectable guard class with `public()`, `isPublic()`, `user()` and `userOf()`
52
54
  */
53
55
  function createJwtAuthGuard(options = {}) {
54
56
  var JwtAuthGuard_1;
@@ -67,9 +69,14 @@ function createJwtAuthGuard(options = {}) {
67
69
  this.reflector = reflector;
68
70
  this.jwt = jwt;
69
71
  }
72
+ /** Reads `public()` markers when `isPublic()` gets no reflector; `Reflector` needs no dependencies */
73
+ static defaultReflector = new core.Reflector();
70
74
  static public() {
71
75
  return common.SetMetadata(publicKey, true);
72
76
  }
77
+ static isPublic(context, reflector = JwtAuthGuard_1.defaultReflector) {
78
+ return !!reflector.getAllAndOverride(publicKey, [context.getHandler(), context.getClass()]);
79
+ }
73
80
  static userOf(request) {
74
81
  return request[property];
75
82
  }
@@ -81,7 +88,7 @@ function createJwtAuthGuard(options = {}) {
81
88
  return (typeof header === 'string' ? /^Bearer +(\S+)$/i.exec(header) : null)?.[1];
82
89
  }
83
90
  canActivate(context) {
84
- if (this.reflector.getAllAndOverride(publicKey, [context.getHandler(), context.getClass()])) {
91
+ if (JwtAuthGuard_1.isPublic(context, this.reflector)) {
85
92
  return true;
86
93
  }
87
94
  const request = context.switchToHttp().getRequest();
@@ -1 +1 @@
1
- {"version":3,"file":"create-jwt-auth-guard.cjs","sources":["../../../../libs/nest-pack/src/auth/create-jwt-auth-guard.ts"],"sourcesContent":[null],"names":["createParamDecorator","SetMetadata","UnauthorizedException","TokenExpiredError","__decorate","Injectable","Reflector","JwtService","Inject"],"mappings":";;;;;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CG;AACG,SAAU,kBAAkB,CAChC,OAAA,GAAwC,EAAE,E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YAAY,EAAE,CAAC,UAAU,EAAW;AAC5D,YAAA,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,cAAY,CAAC,WAAW,CAAC,OAAyC,CAAC;AAE9G,YAAA,OAAO;AACL,kBAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAU,KAAK,EAAE,aAAa,CAAC,CAAC,IAAI,CACtD,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,GAAG,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,EAClE,CAAC,KAAc,KAAK,OAAO,CAAC,MAAM,CAAC,IAAIC,4BAAqB,CAAC,KAAK,YAAYC,qBAAiB,GAAG,cAAc,GAAG,mBAAmB,CAAC,CAAC;kBAE1I,OAAO,CAAC,MAAM,CAAC,IAAID,4BAAqB,CAAC,mBAAmB,CAAC,CAAC;QACpE;;IA7CI,YAAY,GAAA,cAAA,GAAAE,gBAAA,CAAA;AADjB,QAAAC,iBAAU,EAAE;+CAWmBC,cAAS;YACfC,cAAU,CAAA;AAX9B,KAAA,EAAA,YAAY,CA8CjB;IAED,CAACD,cAAS,EAAEC,cAAU,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAKC,aAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AAEhG,IAAA,OAAO,YAAY;AACrB;;;;"}
1
+ {"version":3,"file":"create-jwt-auth-guard.cjs","sources":["../../../../libs/nest-pack/src/auth/create-jwt-auth-guard.ts"],"sourcesContent":[null],"names":["createParamDecorator","Reflector","SetMetadata","UnauthorizedException","TokenExpiredError","__decorate","Injectable","JwtService","Inject"],"mappings":";;;;;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CG;AACG,SAAU,kBAAkB,CAChC,OAAA,GAAwC,EAAE,EAAA;;AAE1C,IAAA,MAAM,EACJ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nestjs/jwt';
4
5
 
5
6
  /**
@@ -43,9 +44,11 @@ import '@nestjs/jwt';
43
44
  * ```
44
45
  *
45
46
  * To give the guard a class name of its own, extend it: `@Injectable() export class AuthGuard extends createJwtAuthGuard<TokenPayload>() {}`.
47
+ *
48
+ * Other guards and interceptors can skip public routes with `AuthGuard.isPublic(context)`.
46
49
  * * * *
47
50
  * @param options Messages, where the token comes from, verification options and where the payload goes
48
- * @returns An injectable guard class with `public()`, `user()` and `userOf()`
51
+ * @returns An injectable guard class with `public()`, `isPublic()`, `user()` and `userOf()`
49
52
  */
50
53
  declare function createJwtAuthGuard<Payload extends object, Request extends object = JwtAuthGuardRequest>(options?: JwtAuthGuardOptions<Request>): JwtAuthGuardType<Payload>;
51
54
 
@@ -1,5 +1,6 @@
1
1
  import { JwtAuthGuardRequest, JwtAuthGuardOptions, JwtAuthGuardType } from './jwt-auth-guard-options.js';
2
2
  import '@nestjs/common';
3
+ import '@nestjs/core';
3
4
  import '@nestjs/jwt';
4
5
 
5
6
  /**
@@ -43,9 +44,11 @@ import '@nestjs/jwt';
43
44
  * ```
44
45
  *
45
46
  * To give the guard a class name of its own, extend it: `@Injectable() export class AuthGuard extends createJwtAuthGuard<TokenPayload>() {}`.
47
+ *
48
+ * Other guards and interceptors can skip public routes with `AuthGuard.isPublic(context)`.
46
49
  * * * *
47
50
  * @param options Messages, where the token comes from, verification options and where the payload goes
48
- * @returns An injectable guard class with `public()`, `user()` and `userOf()`
51
+ * @returns An injectable guard class with `public()`, `isPublic()`, `user()` and `userOf()`
49
52
  */
50
53
  declare function createJwtAuthGuard<Payload extends object, Request extends object = JwtAuthGuardRequest>(options?: JwtAuthGuardOptions<Request>): JwtAuthGuardType<Payload>;
51
54
 
@@ -44,9 +44,11 @@ import { TokenExpiredError, JwtService } from '@nestjs/jwt';
44
44
  * ```
45
45
  *
46
46
  * To give the guard a class name of its own, extend it: `@Injectable() export class AuthGuard extends createJwtAuthGuard<TokenPayload>() {}`.
47
+ *
48
+ * Other guards and interceptors can skip public routes with `AuthGuard.isPublic(context)`.
47
49
  * * * *
48
50
  * @param options Messages, where the token comes from, verification options and where the payload goes
49
- * @returns An injectable guard class with `public()`, `user()` and `userOf()`
51
+ * @returns An injectable guard class with `public()`, `isPublic()`, `user()` and `userOf()`
50
52
  */
51
53
  function createJwtAuthGuard(options = {}) {
52
54
  var JwtAuthGuard_1;
@@ -65,9 +67,14 @@ function createJwtAuthGuard(options = {}) {
65
67
  this.reflector = reflector;
66
68
  this.jwt = jwt;
67
69
  }
70
+ /** Reads `public()` markers when `isPublic()` gets no reflector; `Reflector` needs no dependencies */
71
+ static defaultReflector = new Reflector();
68
72
  static public() {
69
73
  return SetMetadata(publicKey, true);
70
74
  }
75
+ static isPublic(context, reflector = JwtAuthGuard_1.defaultReflector) {
76
+ return !!reflector.getAllAndOverride(publicKey, [context.getHandler(), context.getClass()]);
77
+ }
71
78
  static userOf(request) {
72
79
  return request[property];
73
80
  }
@@ -79,7 +86,7 @@ function createJwtAuthGuard(options = {}) {
79
86
  return (typeof header === 'string' ? /^Bearer +(\S+)$/i.exec(header) : null)?.[1];
80
87
  }
81
88
  canActivate(context) {
82
- if (this.reflector.getAllAndOverride(publicKey, [context.getHandler(), context.getClass()])) {
89
+ if (JwtAuthGuard_1.isPublic(context, this.reflector)) {
83
90
  return true;
84
91
  }
85
92
  const request = context.switchToHttp().getRequest();
@@ -1 +1 @@
1
- {"version":3,"file":"create-jwt-auth-guard.js","sources":["../../../../libs/nest-pack/src/auth/create-jwt-auth-guard.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CG;AACG,SAAU,kBAAkB,CAChC,OAAA,GAAwC,EAAE,EAAA;;AAE1C,IAAA,MAAM,EACJ,cAAc,GAAG,cAAc,EAC/B,mBAAmB,GAAG,cAAc,EACpC,OAAO,EACP,aAAa,EACb,QAAQ,GAAG,MAAM,GAClB,GAAG,OA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M,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,cAAY,CAAC,WAAW,CAAC,OAAyC,CAAC;AAE9G,YAAA,OAAO;AACL,kBAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAU,KAAK,EAAE,aAAa,CAAC,CAAC,IAAI,CACtD,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,GAAG,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,EAClE,CAAC,KAAc,KAAK,OAAO,CAAC,MAAM,CAAC,IAAI,qBAAqB,CAAC,KAAK,YAAY,iBAAiB,GAAG,cAAc,GAAG,mBAAmB,CAAC,CAAC;kBAE1I,OAAO,CAAC,MAAM,CAAC,IAAI,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;QACpE;;IApDI,YAAY,GAAA,cAAA,GAAA,UAAA,CAAA;AADjB,QAAA,UAAU,EAAE;yCAWmB,SAAS;YACf,UAAU,CAAA;AAX9B,KAAA,EAAA,YAAY,CAqDjB;IAED,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AAEhG,IAAA,OAAO,YAAY;AACrB;;;;"}
package/auth/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { JwtAuthGuardOptions, JwtAuthGuardRequest, JwtAuthGuardType } from './jwt-auth-guard-options.cjs';
2
2
  export { createJwtAuthGuard } from './create-jwt-auth-guard.cjs';
3
3
  import '@nestjs/common';
4
+ import '@nestjs/core';
4
5
  import '@nestjs/jwt';
package/auth/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { JwtAuthGuardOptions, JwtAuthGuardRequest, JwtAuthGuardType } from './jwt-auth-guard-options.js';
2
2
  export { createJwtAuthGuard } from './create-jwt-auth-guard.js';
3
3
  import '@nestjs/common';
4
+ import '@nestjs/core';
4
5
  import '@nestjs/jwt';
@@ -1,4 +1,5 @@
1
- import { Type, CanActivate } from '@nestjs/common';
1
+ import { Type, CanActivate, ExecutionContext } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
2
3
  import { JwtVerifyOptions } from '@nestjs/jwt';
3
4
 
4
5
  /**
@@ -49,6 +50,14 @@ interface JwtAuthGuardType<Payload extends object> extends Type<CanActivate> {
49
50
  * Route or controller decorator: the route needs no token. A method's setting replaces its controller's.
50
51
  */
51
52
  public(): MethodDecorator & ClassDecorator;
53
+ /**
54
+ * Whether the route of a context is marked with `public()`, for other guards and interceptors that skip public
55
+ * routes (throttling, auditing, resolving the user, …). A method's setting replaces its controller's.
56
+ *
57
+ * @param context The context of the route, e.g. of `canActivate` or `intercept`
58
+ * @param reflector Reads the markers; a `Reflector` of its own by default
59
+ */
60
+ isPublic(context: ExecutionContext, reflector?: Reflector): boolean;
52
61
  /**
53
62
  * Parameter decorator: the verified token payload, `undefined` on public routes
54
63
  */
@@ -1,4 +1,5 @@
1
- import { Type, CanActivate } from '@nestjs/common';
1
+ import { Type, CanActivate, ExecutionContext } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
2
3
  import { JwtVerifyOptions } from '@nestjs/jwt';
3
4
 
4
5
  /**
@@ -49,6 +50,14 @@ interface JwtAuthGuardType<Payload extends object> extends Type<CanActivate> {
49
50
  * Route or controller decorator: the route needs no token. A method's setting replaces its controller's.
50
51
  */
51
52
  public(): MethodDecorator & ClassDecorator;
53
+ /**
54
+ * Whether the route of a context is marked with `public()`, for other guards and interceptors that skip public
55
+ * routes (throttling, auditing, resolving the user, …). A method's setting replaces its controller's.
56
+ *
57
+ * @param context The context of the route, e.g. of `canActivate` or `intercept`
58
+ * @param reflector Reads the markers; a `Reflector` of its own by default
59
+ */
60
+ isPublic(context: ExecutionContext, reflector?: Reflector): boolean;
52
61
  /**
53
62
  * Parameter decorator: the verified token payload, `undefined` on public routes
54
63
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telperion/nest-pack",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "NestJS utilities: JWT auth and access guards, validation helpers and pagination",
5
5
  "keywords": [
6
6
  "nestjs",