@telperion/nest-pack 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build-manifest.json +31 -1
- package/README.md +48 -1
- package/auth/create-jwt-auth-guard.cjs +104 -0
- package/auth/create-jwt-auth-guard.cjs.map +1 -0
- package/auth/create-jwt-auth-guard.d.cts +52 -0
- package/auth/create-jwt-auth-guard.d.ts +52 -0
- package/auth/create-jwt-auth-guard.js +102 -0
- package/auth/create-jwt-auth-guard.js.map +1 -0
- package/auth/index.cjs +8 -0
- package/auth/index.cjs.map +1 -0
- package/auth/index.d.cts +4 -0
- package/auth/index.d.ts +4 -0
- package/auth/index.js +2 -0
- package/auth/index.js.map +1 -0
- package/auth/jwt-auth-guard-options.cjs +3 -0
- package/auth/jwt-auth-guard-options.cjs.map +1 -0
- package/auth/jwt-auth-guard-options.d.cts +62 -0
- package/auth/jwt-auth-guard-options.d.ts +62 -0
- package/auth/jwt-auth-guard-options.js +2 -0
- package/auth/jwt-auth-guard-options.js.map +1 -0
- package/package.json +53 -4
package/.build-manifest.json
CHANGED
|
@@ -40,6 +40,36 @@
|
|
|
40
40
|
"dcts": "access/index.d.cts"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
+
{
|
|
44
|
+
"name": "auth/create-jwt-auth-guard",
|
|
45
|
+
"sourcePath": "src/auth/create-jwt-auth-guard.ts",
|
|
46
|
+
"outputs": {
|
|
47
|
+
"esm": "auth/create-jwt-auth-guard.js",
|
|
48
|
+
"cjs": "auth/create-jwt-auth-guard.cjs",
|
|
49
|
+
"dts": "auth/create-jwt-auth-guard.d.ts",
|
|
50
|
+
"dcts": "auth/create-jwt-auth-guard.d.cts"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "auth/index",
|
|
55
|
+
"sourcePath": "src/auth/index.ts",
|
|
56
|
+
"outputs": {
|
|
57
|
+
"esm": "auth/index.js",
|
|
58
|
+
"cjs": "auth/index.cjs",
|
|
59
|
+
"dts": "auth/index.d.ts",
|
|
60
|
+
"dcts": "auth/index.d.cts"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "auth/jwt-auth-guard-options",
|
|
65
|
+
"sourcePath": "src/auth/jwt-auth-guard-options.ts",
|
|
66
|
+
"outputs": {
|
|
67
|
+
"esm": "auth/jwt-auth-guard-options.js",
|
|
68
|
+
"cjs": "auth/jwt-auth-guard-options.cjs",
|
|
69
|
+
"dts": "auth/jwt-auth-guard-options.d.ts",
|
|
70
|
+
"dcts": "auth/jwt-auth-guard-options.d.cts"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
43
73
|
{
|
|
44
74
|
"name": "index",
|
|
45
75
|
"sourcePath": "src/index.ts",
|
|
@@ -102,5 +132,5 @@
|
|
|
102
132
|
}
|
|
103
133
|
}
|
|
104
134
|
],
|
|
105
|
-
"generatedAt": "2026-12-
|
|
135
|
+
"generatedAt": "2026-12-01T16:45:38.292Z"
|
|
106
136
|
}
|
package/README.md
CHANGED
|
@@ -21,10 +21,57 @@ Requires `@nestjs/common` and `@nestjs/core` (11 or 12).
|
|
|
21
21
|
| --- | --- | --- |
|
|
22
22
|
| `@telperion/nest-pack` | `createAccessGuard` | |
|
|
23
23
|
| `@telperion/nest-pack/access` | `createAccessGuard` | |
|
|
24
|
+
| `@telperion/nest-pack/auth` | `createJwtAuthGuard` | `@nestjs/jwt` 11 or 12 (optional peer dependency) |
|
|
24
25
|
| `@telperion/nest-pack/validation` | `Trim` | `class-transformer` (optional peer dependency); usually with `class-validator` |
|
|
25
26
|
| `@telperion/nest-pack/pagination` | `PageQuery`, `Page` | `class-transformer` and `class-validator` (optional peer dependencies) |
|
|
26
27
|
|
|
27
|
-
The root entry point does not include `validation` or `pagination`, so projects without class-transformer or class-validator are not affected.
|
|
28
|
+
The root entry point does not include `auth`, `validation` or `pagination`, so projects without `@nestjs/jwt`, class-transformer or class-validator are not affected.
|
|
29
|
+
|
|
30
|
+
## Auth
|
|
31
|
+
|
|
32
|
+
### Create JWT Auth Guard
|
|
33
|
+
|
|
34
|
+
Creates a guard that requires a valid JWT on every route, for use as the global `APP_GUARD`. Tokens are verified with the `JwtService` of `@nestjs/jwt`, so register `JwtModule` next to the guard.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { createJwtAuthGuard } from '@telperion/nest-pack/auth';
|
|
38
|
+
import { APP_GUARD } from '@nestjs/core';
|
|
39
|
+
import { JwtModule } from '@nestjs/jwt';
|
|
40
|
+
|
|
41
|
+
export const AuthGuard = createJwtAuthGuard<TokenPayload>();
|
|
42
|
+
|
|
43
|
+
@Module({
|
|
44
|
+
imports: [JwtModule.register({ secret: process.env.JWT_SECRET })],
|
|
45
|
+
providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
|
|
46
|
+
})
|
|
47
|
+
export class AppModule {}
|
|
48
|
+
|
|
49
|
+
@Controller('huddles')
|
|
50
|
+
export class HuddlesController {
|
|
51
|
+
@Get()
|
|
52
|
+
list(@AuthGuard.user() user: TokenPayload) {}
|
|
53
|
+
|
|
54
|
+
@Get('health')
|
|
55
|
+
@AuthGuard.public() // no token needed; also works on a controller
|
|
56
|
+
health() {}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
| Request | Answer |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| route or controller with `@AuthGuard.public()` | passes, without verifying any token |
|
|
63
|
+
| no token, another scheme, invalid signature or claims | **401** `unauthorizedMessage` (`'Unauthorized'`) |
|
|
64
|
+
| expired token | **401** `expiredMessage` (`'TokenExpired'`), so clients can renew the token and retry |
|
|
65
|
+
| valid token | passes; the payload is on `request.user`, `@AuthGuard.user()` and `AuthGuard.userOf(request)` |
|
|
66
|
+
|
|
67
|
+
**Options** (all optional):
|
|
68
|
+
|
|
69
|
+
- `extract(request)` — reads the token; default: `Authorization: Bearer <token>` (scheme case-insensitive)
|
|
70
|
+
- `verifyOptions` — options of `JwtService.verifyAsync`, e.g. `audience`, `issuer`
|
|
71
|
+
- `expiredMessage`, `unauthorizedMessage` — messages of the 401 answers
|
|
72
|
+
- `property` — the request property the payload is written to (default `'user'`, where Passport and most code expect it)
|
|
73
|
+
|
|
74
|
+
With `@telperion/ng-pack/http`, detect the expired answer in `ApiAuth.expired`: `error => error.status === 401 && error.error?.message === 'TokenExpired'`.
|
|
28
75
|
|
|
29
76
|
## Access
|
|
30
77
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var common = require('@nestjs/common');
|
|
5
|
+
var core = require('@nestjs/core');
|
|
6
|
+
var jwt = require('@nestjs/jwt');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* #### Create JWT Auth Guard
|
|
10
|
+
*
|
|
11
|
+
* Creates a guard that requires a valid JWT on every route, for use as the global `APP_GUARD`:
|
|
12
|
+
*
|
|
13
|
+
* - routes and controllers marked with `@Guard.public()` pass without a token
|
|
14
|
+
* - a missing, malformed or invalid token (bad signature, wrong audience, …): **401** `unauthorizedMessage`
|
|
15
|
+
* - an expired token: **401** `expiredMessage` (`'TokenExpired'`), so clients can tell "renew and retry" from "sign in"
|
|
16
|
+
* - otherwise the payload is written to `request.user` (see `property`) and is available through `@Guard.user()`
|
|
17
|
+
*
|
|
18
|
+
* Tokens are verified with the `JwtService` of `@nestjs/jwt`: register `JwtModule` (with the secret or keys) in
|
|
19
|
+
* the module that provides the guard. The token comes from the `Authorization: Bearer` header unless `extract`
|
|
20
|
+
* reads it from elsewhere. HTTP only.
|
|
21
|
+
*
|
|
22
|
+
* * * *
|
|
23
|
+
* Example:
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { createJwtAuthGuard } from '@telperion/nest-pack/auth';
|
|
26
|
+
* import { APP_GUARD } from '@nestjs/core';
|
|
27
|
+
* import { JwtModule } from '@nestjs/jwt';
|
|
28
|
+
*
|
|
29
|
+
* export const AuthGuard = createJwtAuthGuard<TokenPayload>();
|
|
30
|
+
*
|
|
31
|
+
* @Module({
|
|
32
|
+
* imports: [JwtModule.register({ secret: process.env.JWT_SECRET })],
|
|
33
|
+
* providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
|
|
34
|
+
* })
|
|
35
|
+
* export class AppModule {}
|
|
36
|
+
*
|
|
37
|
+
* @Controller('huddles')
|
|
38
|
+
* export class HuddlesController {
|
|
39
|
+
* @Get()
|
|
40
|
+
* list(@AuthGuard.user() user: TokenPayload) {}
|
|
41
|
+
*
|
|
42
|
+
* @Get('health')
|
|
43
|
+
* @AuthGuard.public()
|
|
44
|
+
* health() {}
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* To give the guard a class name of its own, extend it: `@Injectable() export class AuthGuard extends createJwtAuthGuard<TokenPayload>() {}`.
|
|
49
|
+
* * * *
|
|
50
|
+
* @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()`
|
|
52
|
+
*/
|
|
53
|
+
function createJwtAuthGuard(options = {}) {
|
|
54
|
+
var JwtAuthGuard_1;
|
|
55
|
+
const { expiredMessage = 'TokenExpired', unauthorizedMessage = 'Unauthorized', extract, verifyOptions, property = 'user', } = options;
|
|
56
|
+
const publicKey = Symbol('jwt-auth-guard:public');
|
|
57
|
+
let JwtAuthGuard = class JwtAuthGuard {
|
|
58
|
+
static { JwtAuthGuard_1 = this; }
|
|
59
|
+
reflector;
|
|
60
|
+
jwt;
|
|
61
|
+
static user = common.createParamDecorator((_data, context) => JwtAuthGuard_1.userOf(context.switchToHttp().getRequest()));
|
|
62
|
+
/**
|
|
63
|
+
* @param reflector Reads `public()` markers
|
|
64
|
+
* @param jwt Verifies tokens
|
|
65
|
+
*/
|
|
66
|
+
constructor(reflector, jwt) {
|
|
67
|
+
this.reflector = reflector;
|
|
68
|
+
this.jwt = jwt;
|
|
69
|
+
}
|
|
70
|
+
static public() {
|
|
71
|
+
return common.SetMetadata(publicKey, true);
|
|
72
|
+
}
|
|
73
|
+
static userOf(request) {
|
|
74
|
+
return request[property];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The token of an `Authorization: Bearer <token>` header (the scheme is case-insensitive)
|
|
78
|
+
*/
|
|
79
|
+
static bearerToken({ headers }) {
|
|
80
|
+
const header = headers['authorization'];
|
|
81
|
+
return (typeof header === 'string' ? /^Bearer +(\S+)$/i.exec(header) : null)?.[1];
|
|
82
|
+
}
|
|
83
|
+
canActivate(context) {
|
|
84
|
+
if (this.reflector.getAllAndOverride(publicKey, [context.getHandler(), context.getClass()])) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
const request = context.switchToHttp().getRequest();
|
|
88
|
+
const token = extract ? extract(request) : JwtAuthGuard_1.bearerToken(request);
|
|
89
|
+
return token
|
|
90
|
+
? this.jwt.verifyAsync(token, verifyOptions).then(payload => (Object.assign(request, { [property]: payload }), true), (error) => Promise.reject(new common.UnauthorizedException(error instanceof jwt.TokenExpiredError ? expiredMessage : unauthorizedMessage)))
|
|
91
|
+
: Promise.reject(new common.UnauthorizedException(unauthorizedMessage));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
JwtAuthGuard = JwtAuthGuard_1 = tslib.__decorate([
|
|
95
|
+
common.Injectable(),
|
|
96
|
+
tslib.__metadata("design:paramtypes", [core.Reflector,
|
|
97
|
+
jwt.JwtService])
|
|
98
|
+
], JwtAuthGuard);
|
|
99
|
+
[core.Reflector, jwt.JwtService].forEach((token, index) => common.Inject(token)(JwtAuthGuard, undefined, index));
|
|
100
|
+
return JwtAuthGuard;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
exports.createJwtAuthGuard = createJwtAuthGuard;
|
|
104
|
+
//# sourceMappingURL=create-jwt-auth-guard.cjs.map
|
|
@@ -0,0 +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,EAAA;;AAE1C,IAAA,MAAM,EACJ,cAAc,GAAG,cAAc,EAC/B,mBAAmB,GAAG,cAAc,EACpC,OAAO,EACP,aAAa,EACb,QAAQ,GAAG,MAAM,GAClB,GAAG,OAAO;AACX,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,uBAAuB,CAAC;IAEjD,IACM,YAAY,GADlB,MACM,YAAY,CAAA;;AAUG,QAAA,SAAA;AACA,QAAA,GAAA;QAVnB,OAAgB,IAAI,GAAGA,2BAAoB,CACzC,CAAC,KAAc,EAAE,OAAyB,KAA0B,cAAY,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAU,CAAC,CACrI;AAED;;;AAGG;QACH,WAAA,CACmB,SAAoB,EACpB,GAAe,EAAA;YADf,IAAA,CAAA,SAAS,GAAT,SAAS;YACT,IAAA,CAAA,GAAG,GAAH,GAAG;QACnB;AAEH,QAAA,OAAO,MAAM,GAAA;AACX,YAAA,OAAOC,kBAAW,CAAC,SAAS,EAAE,IAAI,CAAC;QACrC;QAEA,OAAO,MAAM,CAAC,OAAe,EAAA;AAC3B,YAAA,OAAQ,OAA4C,CAAC,QAAQ,CAAC;QAChE;AAEA;;AAEG;AACK,QAAA,OAAO,WAAW,CAAC,EAAE,OAAO,EAAuB,EAAA;AACzD,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;YAEvC,OAAO,CAAC,OAAO,MAAM,KAAK,QAAQ,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QACnF;AAEA,QAAA,WAAW,CAAC,OAAyB,EAAA;YACnC,IAAI,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAsB,SAAS,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE;AAChH,gBAAA,OAAO,IAAI;YACb;YAEA,MAAM,OAAO,GAAG,OAAO,CAAC,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;;;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { JwtAuthGuardRequest, JwtAuthGuardOptions, JwtAuthGuardType } from './jwt-auth-guard-options.cjs';
|
|
2
|
+
import '@nestjs/common';
|
|
3
|
+
import '@nestjs/jwt';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* #### Create JWT Auth Guard
|
|
7
|
+
*
|
|
8
|
+
* Creates a guard that requires a valid JWT on every route, for use as the global `APP_GUARD`:
|
|
9
|
+
*
|
|
10
|
+
* - routes and controllers marked with `@Guard.public()` pass without a token
|
|
11
|
+
* - a missing, malformed or invalid token (bad signature, wrong audience, …): **401** `unauthorizedMessage`
|
|
12
|
+
* - an expired token: **401** `expiredMessage` (`'TokenExpired'`), so clients can tell "renew and retry" from "sign in"
|
|
13
|
+
* - otherwise the payload is written to `request.user` (see `property`) and is available through `@Guard.user()`
|
|
14
|
+
*
|
|
15
|
+
* Tokens are verified with the `JwtService` of `@nestjs/jwt`: register `JwtModule` (with the secret or keys) in
|
|
16
|
+
* the module that provides the guard. The token comes from the `Authorization: Bearer` header unless `extract`
|
|
17
|
+
* reads it from elsewhere. HTTP only.
|
|
18
|
+
*
|
|
19
|
+
* * * *
|
|
20
|
+
* Example:
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { createJwtAuthGuard } from '@telperion/nest-pack/auth';
|
|
23
|
+
* import { APP_GUARD } from '@nestjs/core';
|
|
24
|
+
* import { JwtModule } from '@nestjs/jwt';
|
|
25
|
+
*
|
|
26
|
+
* export const AuthGuard = createJwtAuthGuard<TokenPayload>();
|
|
27
|
+
*
|
|
28
|
+
* @Module({
|
|
29
|
+
* imports: [JwtModule.register({ secret: process.env.JWT_SECRET })],
|
|
30
|
+
* providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
|
|
31
|
+
* })
|
|
32
|
+
* export class AppModule {}
|
|
33
|
+
*
|
|
34
|
+
* @Controller('huddles')
|
|
35
|
+
* export class HuddlesController {
|
|
36
|
+
* @Get()
|
|
37
|
+
* list(@AuthGuard.user() user: TokenPayload) {}
|
|
38
|
+
*
|
|
39
|
+
* @Get('health')
|
|
40
|
+
* @AuthGuard.public()
|
|
41
|
+
* health() {}
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* To give the guard a class name of its own, extend it: `@Injectable() export class AuthGuard extends createJwtAuthGuard<TokenPayload>() {}`.
|
|
46
|
+
* * * *
|
|
47
|
+
* @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()`
|
|
49
|
+
*/
|
|
50
|
+
declare function createJwtAuthGuard<Payload extends object, Request extends object = JwtAuthGuardRequest>(options?: JwtAuthGuardOptions<Request>): JwtAuthGuardType<Payload>;
|
|
51
|
+
|
|
52
|
+
export { createJwtAuthGuard };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { JwtAuthGuardRequest, JwtAuthGuardOptions, JwtAuthGuardType } from './jwt-auth-guard-options.js';
|
|
2
|
+
import '@nestjs/common';
|
|
3
|
+
import '@nestjs/jwt';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* #### Create JWT Auth Guard
|
|
7
|
+
*
|
|
8
|
+
* Creates a guard that requires a valid JWT on every route, for use as the global `APP_GUARD`:
|
|
9
|
+
*
|
|
10
|
+
* - routes and controllers marked with `@Guard.public()` pass without a token
|
|
11
|
+
* - a missing, malformed or invalid token (bad signature, wrong audience, …): **401** `unauthorizedMessage`
|
|
12
|
+
* - an expired token: **401** `expiredMessage` (`'TokenExpired'`), so clients can tell "renew and retry" from "sign in"
|
|
13
|
+
* - otherwise the payload is written to `request.user` (see `property`) and is available through `@Guard.user()`
|
|
14
|
+
*
|
|
15
|
+
* Tokens are verified with the `JwtService` of `@nestjs/jwt`: register `JwtModule` (with the secret or keys) in
|
|
16
|
+
* the module that provides the guard. The token comes from the `Authorization: Bearer` header unless `extract`
|
|
17
|
+
* reads it from elsewhere. HTTP only.
|
|
18
|
+
*
|
|
19
|
+
* * * *
|
|
20
|
+
* Example:
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { createJwtAuthGuard } from '@telperion/nest-pack/auth';
|
|
23
|
+
* import { APP_GUARD } from '@nestjs/core';
|
|
24
|
+
* import { JwtModule } from '@nestjs/jwt';
|
|
25
|
+
*
|
|
26
|
+
* export const AuthGuard = createJwtAuthGuard<TokenPayload>();
|
|
27
|
+
*
|
|
28
|
+
* @Module({
|
|
29
|
+
* imports: [JwtModule.register({ secret: process.env.JWT_SECRET })],
|
|
30
|
+
* providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
|
|
31
|
+
* })
|
|
32
|
+
* export class AppModule {}
|
|
33
|
+
*
|
|
34
|
+
* @Controller('huddles')
|
|
35
|
+
* export class HuddlesController {
|
|
36
|
+
* @Get()
|
|
37
|
+
* list(@AuthGuard.user() user: TokenPayload) {}
|
|
38
|
+
*
|
|
39
|
+
* @Get('health')
|
|
40
|
+
* @AuthGuard.public()
|
|
41
|
+
* health() {}
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* To give the guard a class name of its own, extend it: `@Injectable() export class AuthGuard extends createJwtAuthGuard<TokenPayload>() {}`.
|
|
46
|
+
* * * *
|
|
47
|
+
* @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()`
|
|
49
|
+
*/
|
|
50
|
+
declare function createJwtAuthGuard<Payload extends object, Request extends object = JwtAuthGuardRequest>(options?: JwtAuthGuardOptions<Request>): JwtAuthGuardType<Payload>;
|
|
51
|
+
|
|
52
|
+
export { createJwtAuthGuard };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { createParamDecorator, SetMetadata, UnauthorizedException, Injectable, Inject } from '@nestjs/common';
|
|
3
|
+
import { Reflector } from '@nestjs/core';
|
|
4
|
+
import { TokenExpiredError, JwtService } from '@nestjs/jwt';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* #### Create JWT Auth Guard
|
|
8
|
+
*
|
|
9
|
+
* Creates a guard that requires a valid JWT on every route, for use as the global `APP_GUARD`:
|
|
10
|
+
*
|
|
11
|
+
* - routes and controllers marked with `@Guard.public()` pass without a token
|
|
12
|
+
* - a missing, malformed or invalid token (bad signature, wrong audience, …): **401** `unauthorizedMessage`
|
|
13
|
+
* - an expired token: **401** `expiredMessage` (`'TokenExpired'`), so clients can tell "renew and retry" from "sign in"
|
|
14
|
+
* - otherwise the payload is written to `request.user` (see `property`) and is available through `@Guard.user()`
|
|
15
|
+
*
|
|
16
|
+
* Tokens are verified with the `JwtService` of `@nestjs/jwt`: register `JwtModule` (with the secret or keys) in
|
|
17
|
+
* the module that provides the guard. The token comes from the `Authorization: Bearer` header unless `extract`
|
|
18
|
+
* reads it from elsewhere. HTTP only.
|
|
19
|
+
*
|
|
20
|
+
* * * *
|
|
21
|
+
* Example:
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { createJwtAuthGuard } from '@telperion/nest-pack/auth';
|
|
24
|
+
* import { APP_GUARD } from '@nestjs/core';
|
|
25
|
+
* import { JwtModule } from '@nestjs/jwt';
|
|
26
|
+
*
|
|
27
|
+
* export const AuthGuard = createJwtAuthGuard<TokenPayload>();
|
|
28
|
+
*
|
|
29
|
+
* @Module({
|
|
30
|
+
* imports: [JwtModule.register({ secret: process.env.JWT_SECRET })],
|
|
31
|
+
* providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
|
|
32
|
+
* })
|
|
33
|
+
* export class AppModule {}
|
|
34
|
+
*
|
|
35
|
+
* @Controller('huddles')
|
|
36
|
+
* export class HuddlesController {
|
|
37
|
+
* @Get()
|
|
38
|
+
* list(@AuthGuard.user() user: TokenPayload) {}
|
|
39
|
+
*
|
|
40
|
+
* @Get('health')
|
|
41
|
+
* @AuthGuard.public()
|
|
42
|
+
* health() {}
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* To give the guard a class name of its own, extend it: `@Injectable() export class AuthGuard extends createJwtAuthGuard<TokenPayload>() {}`.
|
|
47
|
+
* * * *
|
|
48
|
+
* @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()`
|
|
50
|
+
*/
|
|
51
|
+
function createJwtAuthGuard(options = {}) {
|
|
52
|
+
var JwtAuthGuard_1;
|
|
53
|
+
const { expiredMessage = 'TokenExpired', unauthorizedMessage = 'Unauthorized', extract, verifyOptions, property = 'user', } = options;
|
|
54
|
+
const publicKey = Symbol('jwt-auth-guard:public');
|
|
55
|
+
let JwtAuthGuard = class JwtAuthGuard {
|
|
56
|
+
static { JwtAuthGuard_1 = this; }
|
|
57
|
+
reflector;
|
|
58
|
+
jwt;
|
|
59
|
+
static user = createParamDecorator((_data, context) => JwtAuthGuard_1.userOf(context.switchToHttp().getRequest()));
|
|
60
|
+
/**
|
|
61
|
+
* @param reflector Reads `public()` markers
|
|
62
|
+
* @param jwt Verifies tokens
|
|
63
|
+
*/
|
|
64
|
+
constructor(reflector, jwt) {
|
|
65
|
+
this.reflector = reflector;
|
|
66
|
+
this.jwt = jwt;
|
|
67
|
+
}
|
|
68
|
+
static public() {
|
|
69
|
+
return SetMetadata(publicKey, true);
|
|
70
|
+
}
|
|
71
|
+
static userOf(request) {
|
|
72
|
+
return request[property];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The token of an `Authorization: Bearer <token>` header (the scheme is case-insensitive)
|
|
76
|
+
*/
|
|
77
|
+
static bearerToken({ headers }) {
|
|
78
|
+
const header = headers['authorization'];
|
|
79
|
+
return (typeof header === 'string' ? /^Bearer +(\S+)$/i.exec(header) : null)?.[1];
|
|
80
|
+
}
|
|
81
|
+
canActivate(context) {
|
|
82
|
+
if (this.reflector.getAllAndOverride(publicKey, [context.getHandler(), context.getClass()])) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
const request = context.switchToHttp().getRequest();
|
|
86
|
+
const token = extract ? extract(request) : JwtAuthGuard_1.bearerToken(request);
|
|
87
|
+
return token
|
|
88
|
+
? this.jwt.verifyAsync(token, verifyOptions).then(payload => (Object.assign(request, { [property]: payload }), true), (error) => Promise.reject(new UnauthorizedException(error instanceof TokenExpiredError ? expiredMessage : unauthorizedMessage)))
|
|
89
|
+
: Promise.reject(new UnauthorizedException(unauthorizedMessage));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
JwtAuthGuard = JwtAuthGuard_1 = __decorate([
|
|
93
|
+
Injectable(),
|
|
94
|
+
__metadata("design:paramtypes", [Reflector,
|
|
95
|
+
JwtService])
|
|
96
|
+
], JwtAuthGuard);
|
|
97
|
+
[Reflector, JwtService].forEach((token, index) => Inject(token)(JwtAuthGuard, undefined, index));
|
|
98
|
+
return JwtAuthGuard;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { createJwtAuthGuard };
|
|
102
|
+
//# sourceMappingURL=create-jwt-auth-guard.js.map
|
|
@@ -0,0 +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,OAAO;AACX,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,uBAAuB,CAAC;IAEjD,IACM,YAAY,GADlB,MACM,YAAY,CAAA;;AAUG,QAAA,SAAA;AACA,QAAA,GAAA;QAVnB,OAAgB,IAAI,GAAG,oBAAoB,CACzC,CAAC,KAAc,EAAE,OAAyB,KAA0B,cAAY,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAU,CAAC,CACrI;AAED;;;AAGG;QACH,WAAA,CACmB,SAAoB,EACpB,GAAe,EAAA;YADf,IAAA,CAAA,SAAS,GAAT,SAAS;YACT,IAAA,CAAA,GAAG,GAAH,GAAG;QACnB;AAEH,QAAA,OAAO,MAAM,GAAA;AACX,YAAA,OAAO,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC;QACrC;QAEA,OAAO,MAAM,CAAC,OAAe,EAAA;AAC3B,YAAA,OAAQ,OAA4C,CAAC,QAAQ,CAAC;QAChE;AAEA;;AAEG;AACK,QAAA,OAAO,WAAW,CAAC,EAAE,OAAO,EAAuB,EAAA;AACzD,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;YAEvC,OAAO,CAAC,OAAO,MAAM,KAAK,QAAQ,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QACnF;AAEA,QAAA,WAAW,CAAC,OAAyB,EAAA;YACnC,IAAI,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAsB,SAAS,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE;AAChH,gBAAA,OAAO,IAAI;YACb;YAEA,MAAM,OAAO,GAAG,OAAO,CAAC,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,IAAI,qBAAqB,CAAC,KAAK,YAAY,iBAAiB,GAAG,cAAc,GAAG,mBAAmB,CAAC,CAAC;kBAE1I,OAAO,CAAC,MAAM,CAAC,IAAI,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;QACpE;;IA7CI,YAAY,GAAA,cAAA,GAAA,UAAA,CAAA;AADjB,QAAA,UAAU,EAAE;yCAWmB,SAAS;YACf,UAAU,CAAA;AAX9B,KAAA,EAAA,YAAY,CA8CjB;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.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/auth/index.d.cts
ADDED
package/auth/index.d.ts
ADDED
package/auth/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-auth-guard-options.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Type, CanActivate } from '@nestjs/common';
|
|
2
|
+
import { JwtVerifyOptions } from '@nestjs/jwt';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a {@link createJwtAuthGuard} reads from a request
|
|
6
|
+
*/
|
|
7
|
+
interface JwtAuthGuardRequest {
|
|
8
|
+
headers: Record<string, string | string[] | undefined>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Options of {@link createJwtAuthGuard}
|
|
12
|
+
*/
|
|
13
|
+
interface JwtAuthGuardOptions<Request extends object = JwtAuthGuardRequest> {
|
|
14
|
+
/**
|
|
15
|
+
* The message of the 401 answer for an expired token, so clients can renew the token and retry
|
|
16
|
+
* (e.g. `ApiAuth.expired` of `@telperion/ng-pack/http`)
|
|
17
|
+
*
|
|
18
|
+
* @default 'TokenExpired'
|
|
19
|
+
*/
|
|
20
|
+
expiredMessage?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The message of the 401 answer for a missing or invalid token
|
|
23
|
+
*
|
|
24
|
+
* @default 'Unauthorized'
|
|
25
|
+
*/
|
|
26
|
+
unauthorizedMessage?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Reads the token from a request
|
|
29
|
+
*
|
|
30
|
+
* @default the token of an `Authorization: Bearer <token>` header
|
|
31
|
+
*/
|
|
32
|
+
extract?: (request: Request) => string | null | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Options of `JwtService.verifyAsync`, e.g. the `audience`, `issuer` or a `secret` other than the `JwtModule`'s
|
|
35
|
+
*/
|
|
36
|
+
verifyOptions?: JwtVerifyOptions;
|
|
37
|
+
/**
|
|
38
|
+
* The request property the verified payload is written to
|
|
39
|
+
*
|
|
40
|
+
* @default 'user'
|
|
41
|
+
*/
|
|
42
|
+
property?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The guard class {@link createJwtAuthGuard} returns, with its decorators
|
|
46
|
+
*/
|
|
47
|
+
interface JwtAuthGuardType<Payload extends object> extends Type<CanActivate> {
|
|
48
|
+
/**
|
|
49
|
+
* Route or controller decorator: the route needs no token. A method's setting replaces its controller's.
|
|
50
|
+
*/
|
|
51
|
+
public(): MethodDecorator & ClassDecorator;
|
|
52
|
+
/**
|
|
53
|
+
* Parameter decorator: the verified token payload, `undefined` on public routes
|
|
54
|
+
*/
|
|
55
|
+
user(...pipes: unknown[]): ParameterDecorator;
|
|
56
|
+
/**
|
|
57
|
+
* The verified payload of a request, `undefined` before the guard ran or on public routes
|
|
58
|
+
*/
|
|
59
|
+
userOf(request: object): Payload | undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type { JwtAuthGuardOptions, JwtAuthGuardRequest, JwtAuthGuardType };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Type, CanActivate } from '@nestjs/common';
|
|
2
|
+
import { JwtVerifyOptions } from '@nestjs/jwt';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a {@link createJwtAuthGuard} reads from a request
|
|
6
|
+
*/
|
|
7
|
+
interface JwtAuthGuardRequest {
|
|
8
|
+
headers: Record<string, string | string[] | undefined>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Options of {@link createJwtAuthGuard}
|
|
12
|
+
*/
|
|
13
|
+
interface JwtAuthGuardOptions<Request extends object = JwtAuthGuardRequest> {
|
|
14
|
+
/**
|
|
15
|
+
* The message of the 401 answer for an expired token, so clients can renew the token and retry
|
|
16
|
+
* (e.g. `ApiAuth.expired` of `@telperion/ng-pack/http`)
|
|
17
|
+
*
|
|
18
|
+
* @default 'TokenExpired'
|
|
19
|
+
*/
|
|
20
|
+
expiredMessage?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The message of the 401 answer for a missing or invalid token
|
|
23
|
+
*
|
|
24
|
+
* @default 'Unauthorized'
|
|
25
|
+
*/
|
|
26
|
+
unauthorizedMessage?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Reads the token from a request
|
|
29
|
+
*
|
|
30
|
+
* @default the token of an `Authorization: Bearer <token>` header
|
|
31
|
+
*/
|
|
32
|
+
extract?: (request: Request) => string | null | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Options of `JwtService.verifyAsync`, e.g. the `audience`, `issuer` or a `secret` other than the `JwtModule`'s
|
|
35
|
+
*/
|
|
36
|
+
verifyOptions?: JwtVerifyOptions;
|
|
37
|
+
/**
|
|
38
|
+
* The request property the verified payload is written to
|
|
39
|
+
*
|
|
40
|
+
* @default 'user'
|
|
41
|
+
*/
|
|
42
|
+
property?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The guard class {@link createJwtAuthGuard} returns, with its decorators
|
|
46
|
+
*/
|
|
47
|
+
interface JwtAuthGuardType<Payload extends object> extends Type<CanActivate> {
|
|
48
|
+
/**
|
|
49
|
+
* Route or controller decorator: the route needs no token. A method's setting replaces its controller's.
|
|
50
|
+
*/
|
|
51
|
+
public(): MethodDecorator & ClassDecorator;
|
|
52
|
+
/**
|
|
53
|
+
* Parameter decorator: the verified token payload, `undefined` on public routes
|
|
54
|
+
*/
|
|
55
|
+
user(...pipes: unknown[]): ParameterDecorator;
|
|
56
|
+
/**
|
|
57
|
+
* The verified payload of a request, `undefined` before the guard ran or on public routes
|
|
58
|
+
*/
|
|
59
|
+
userOf(request: object): Payload | undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type { JwtAuthGuardOptions, JwtAuthGuardRequest, JwtAuthGuardType };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-auth-guard-options.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telperion/nest-pack",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "NestJS utilities: access guards, validation helpers and pagination",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "NestJS utilities: JWT auth and access guards, validation helpers and pagination",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nestjs",
|
|
7
7
|
"nest",
|
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
"trim",
|
|
17
17
|
"pagination",
|
|
18
18
|
"paging",
|
|
19
|
-
"dto"
|
|
19
|
+
"dto",
|
|
20
|
+
"jwt",
|
|
21
|
+
"authentication",
|
|
22
|
+
"auth guard",
|
|
23
|
+
"bearer token",
|
|
24
|
+
"public route"
|
|
20
25
|
],
|
|
21
26
|
"homepage": "https://github.com/telperiontech/telperion/tree/main/libs/nest-pack#readme",
|
|
22
27
|
"repository": {
|
|
@@ -35,9 +40,13 @@
|
|
|
35
40
|
"@nestjs/common": "^11.0.0 || ^12.0.0",
|
|
36
41
|
"@nestjs/core": "^11.0.0 || ^12.0.0",
|
|
37
42
|
"class-transformer": "^0.5.0",
|
|
38
|
-
"class-validator": "^0.14.0 || ^0.15.0"
|
|
43
|
+
"class-validator": "^0.14.0 || ^0.15.0",
|
|
44
|
+
"@nestjs/jwt": "^11.0.0 || ^12.0.0"
|
|
39
45
|
},
|
|
40
46
|
"peerDependenciesMeta": {
|
|
47
|
+
"@nestjs/jwt": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
41
50
|
"class-transformer": {
|
|
42
51
|
"optional": true
|
|
43
52
|
},
|
|
@@ -108,6 +117,46 @@
|
|
|
108
117
|
"node": "./access/index.cjs",
|
|
109
118
|
"default": "./access/index.js"
|
|
110
119
|
},
|
|
120
|
+
"./auth/create-jwt-auth-guard": {
|
|
121
|
+
"types": {
|
|
122
|
+
"import": "./auth/create-jwt-auth-guard.d.ts",
|
|
123
|
+
"require": "./auth/create-jwt-auth-guard.d.cts"
|
|
124
|
+
},
|
|
125
|
+
"import": "./auth/create-jwt-auth-guard.js",
|
|
126
|
+
"require": "./auth/create-jwt-auth-guard.cjs",
|
|
127
|
+
"node": "./auth/create-jwt-auth-guard.cjs",
|
|
128
|
+
"default": "./auth/create-jwt-auth-guard.js"
|
|
129
|
+
},
|
|
130
|
+
"./auth/index": {
|
|
131
|
+
"types": {
|
|
132
|
+
"import": "./auth/index.d.ts",
|
|
133
|
+
"require": "./auth/index.d.cts"
|
|
134
|
+
},
|
|
135
|
+
"import": "./auth/index.js",
|
|
136
|
+
"require": "./auth/index.cjs",
|
|
137
|
+
"node": "./auth/index.cjs",
|
|
138
|
+
"default": "./auth/index.js"
|
|
139
|
+
},
|
|
140
|
+
"./auth": {
|
|
141
|
+
"types": {
|
|
142
|
+
"import": "./auth/index.d.ts",
|
|
143
|
+
"require": "./auth/index.d.cts"
|
|
144
|
+
},
|
|
145
|
+
"import": "./auth/index.js",
|
|
146
|
+
"require": "./auth/index.cjs",
|
|
147
|
+
"node": "./auth/index.cjs",
|
|
148
|
+
"default": "./auth/index.js"
|
|
149
|
+
},
|
|
150
|
+
"./auth/jwt-auth-guard-options": {
|
|
151
|
+
"types": {
|
|
152
|
+
"import": "./auth/jwt-auth-guard-options.d.ts",
|
|
153
|
+
"require": "./auth/jwt-auth-guard-options.d.cts"
|
|
154
|
+
},
|
|
155
|
+
"import": "./auth/jwt-auth-guard-options.js",
|
|
156
|
+
"require": "./auth/jwt-auth-guard-options.cjs",
|
|
157
|
+
"node": "./auth/jwt-auth-guard-options.cjs",
|
|
158
|
+
"default": "./auth/jwt-auth-guard-options.js"
|
|
159
|
+
},
|
|
111
160
|
"./pagination/index": {
|
|
112
161
|
"types": {
|
|
113
162
|
"import": "./pagination/index.d.ts",
|