@nestjs-kitchen/authz 3.0.1 → 3.1.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/README.md +23 -6
- package/dist/authz.provider.d.ts +1 -2
- package/dist/jwt/jwt-authz-als.middleware.d.ts +3 -4
- package/dist/jwt/jwt-authz-als.middleware.js +3 -2
- package/dist/jwt/jwt-authz.module.d.ts +3 -3
- package/dist/jwt/jwt-authz.module.js +1 -0
- package/dist/jwt/jwt-authz.service.d.ts +2 -2
- package/dist/jwt/jwt-authz.strategy.d.ts +4 -5
- package/dist/session/session-authz-als.middleware.d.ts +3 -4
- package/dist/session/session-authz-als.middleware.js +29 -49
- package/dist/session/session-authz.guard.d.ts +1 -1
- package/dist/session/session-authz.module.d.ts +3 -3
- package/dist/session/session-authz.module.js +1 -0
- package/dist/session/session-authz.service.d.ts +2 -2
- package/dist/session/session-authz.strategy.d.ts +2 -3
- package/dist/utils/adapter-shim.d.ts +28 -0
- package/dist/utils/adapter-shim.js +174 -0
- package/dist/utils/cookie-parsers.d.ts +6 -7
- package/dist/utils/cookie-parsers.js +10 -0
- package/dist/utils/create-set-cookie-fn.d.ts +2 -3
- package/dist/utils/create-set-cookie-fn.js +2 -1
- package/dist/utils/generics.d.ts +0 -1
- package/dist/utils/generics.js +1 -12
- package/dist/utils/get-passport-property.d.ts +1 -1
- package/dist/utils/get-passport-property.js +0 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/safe-clone.d.ts +1 -0
- package/dist/utils/safe-clone.js +15 -0
- package/dist/utils/types.d.ts +0 -7
- package/package.json +27 -7
package/README.md
CHANGED
|
@@ -16,12 +16,15 @@ Simplest authentication & authorization module in NextJS.
|
|
|
16
16
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
|
-
- JWT based authentication
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
19
|
+
- ✅ JWT based authentication
|
|
20
|
+
|
|
21
|
+
- ✅ Session based authentication
|
|
22
|
+
|
|
23
|
+
- ✅ Flexible authorization
|
|
24
|
+
|
|
25
|
+
- ✅ Support Anonymous access
|
|
26
|
+
|
|
27
|
+
- ✅ Compatible with both `@nestjs/platform-express` and `@nestjs/platform-fastify`
|
|
25
28
|
|
|
26
29
|
## Install
|
|
27
30
|
|
|
@@ -31,6 +34,20 @@ Once completed NestJS project setup, install this package and its dependencies:
|
|
|
31
34
|
$ npm install --save @nestjs/passport passport @nestjs-kitchen/authz
|
|
32
35
|
```
|
|
33
36
|
|
|
37
|
+
## Platform prerequisite
|
|
38
|
+
|
|
39
|
+
Different platforms require different dependencies:
|
|
40
|
+
|
|
41
|
+
- For `@nestjs/platform-express`:
|
|
42
|
+
|
|
43
|
+
It requires [`express-session`](https://www.npmjs.com/package/express-session).
|
|
44
|
+
|
|
45
|
+
- For `@nestjs/platform-fastify`:
|
|
46
|
+
|
|
47
|
+
It requires [`@fastify/cookie`](https://www.npmjs.com/package/@fastify/cookie) and [`@fastify/session`](https://www.npmjs.com/package/@fastify/session).
|
|
48
|
+
|
|
49
|
+
Or [`@fastify/secure-session`](https://www.npmjs.com/package/@fastify/secure-session) instead.
|
|
50
|
+
|
|
34
51
|
## Beark change
|
|
35
52
|
|
|
36
53
|
- From `@nestjs-kitchen/authz` **v3**, [`express-session`](https://www.npmjs.com/package/express-session) had been removed from dependency. Please setup session manually:
|
package/dist/authz.provider.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Request } from 'express';
|
|
2
1
|
/**
|
|
3
2
|
* Abstract base class for implementing custom authorization logic.
|
|
4
3
|
*
|
|
@@ -26,7 +25,7 @@ export declare abstract class AuthzProviderClass<Payload, User> {
|
|
|
26
25
|
* @param {Payload} payload - The payload to authenticate.
|
|
27
26
|
* @returns {User | Promise<User>} The authenticated user, or a promise resolving to the user.
|
|
28
27
|
*/
|
|
29
|
-
abstract authenticate(payload: Payload, req?:
|
|
28
|
+
abstract authenticate(payload: Payload, req?: any): User | Promise<User>;
|
|
30
29
|
/**
|
|
31
30
|
* (**Optional**: Implement this method only if authorization is required.)
|
|
32
31
|
*
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { type Type } from '@nestjs/common';
|
|
3
|
-
import type { NextFunction, Request, Response } from 'express';
|
|
4
3
|
import { JwtValidationType } from '../constants';
|
|
5
|
-
import { type
|
|
4
|
+
import { type RawRequestWithShims, type RawResponseWithShims } from '../utils';
|
|
6
5
|
import type { JwtAuthzOptions } from './jwt-authz.interface';
|
|
7
6
|
export interface JwtAlsType<U> {
|
|
8
7
|
user?: U;
|
|
@@ -10,10 +9,10 @@ export interface JwtAlsType<U> {
|
|
|
10
9
|
allowAnonymous?: boolean;
|
|
11
10
|
guardResult?: boolean;
|
|
12
11
|
authOptions: JwtAuthzOptions;
|
|
13
|
-
setCookie: (name: string, value: string, options?:
|
|
12
|
+
setCookie: (name: string, value: string, options?: Record<string, any>) => void;
|
|
14
13
|
}
|
|
15
14
|
export declare const createJwtAuthzAlsMiddleware: ([ALS_PROVIDER, JWT_AUTHZ_OPTIONS]: [any, any]) => Type<Omit<{
|
|
16
15
|
readonly als: AsyncLocalStorage<JwtAlsType<unknown>>;
|
|
17
16
|
readonly jwtAuthzOptions: JwtAuthzOptions;
|
|
18
|
-
use(req:
|
|
17
|
+
use(req: RawRequestWithShims, res: RawResponseWithShims, next: Function): void;
|
|
19
18
|
}, "als" | "jwtAuthzOptions">>;
|
|
@@ -23,7 +23,7 @@ const createJwtAuthzAlsMiddleware = ([ALS_PROVIDER, JWT_AUTHZ_OPTIONS]) => {
|
|
|
23
23
|
this.jwtAuthzOptions = jwtAuthzOptions;
|
|
24
24
|
}
|
|
25
25
|
use(req, res, next) {
|
|
26
|
-
|
|
26
|
+
const store = {
|
|
27
27
|
user: undefined,
|
|
28
28
|
jwtVerifiedBy: undefined,
|
|
29
29
|
allowAnonymous: undefined,
|
|
@@ -31,7 +31,8 @@ const createJwtAuthzAlsMiddleware = ([ALS_PROVIDER, JWT_AUTHZ_OPTIONS]) => {
|
|
|
31
31
|
// a workaround to pass jwtAuthzOptions to passport strategy.
|
|
32
32
|
authOptions: this.jwtAuthzOptions,
|
|
33
33
|
setCookie: (0, utils_1.createSetCookieFn)(req, res)
|
|
34
|
-
}
|
|
34
|
+
};
|
|
35
|
+
this.als.run(store, () => {
|
|
35
36
|
next();
|
|
36
37
|
});
|
|
37
38
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { type ConfigurableModuleAsyncOptions, DynamicModule, type ExecutionContext, MiddlewareConsumer, type Type } from '@nestjs/common';
|
|
3
|
-
import type
|
|
3
|
+
import { type Reflector } from '@nestjs/core';
|
|
4
4
|
import { AuthzProviderClass } from '../authz.provider';
|
|
5
5
|
import { AuthzError } from '../errors';
|
|
6
|
-
import { type AbstractConstructor, type ApplyDecorators, type AuthzDecoParams, type AuthzModuleBaseOptions, type AuthzModuleRoutesOptions, type
|
|
6
|
+
import { type AbstractConstructor, type ApplyDecorators, type AuthzDecoParams, type AuthzModuleBaseOptions, type AuthzModuleRoutesOptions, type DeepReadonly, type MethodParameters, type RoutesOptions } from '../utils';
|
|
7
7
|
import { type JwtAuthzModuleOptions, type JwtAuthzOptions, type JwtOptions } from './jwt-authz.interface';
|
|
8
8
|
import { type JwtAlsType } from './jwt-authz-als.middleware';
|
|
9
9
|
declare const ASYNC_OPTIONS_TYPE: ConfigurableModuleAsyncOptions<JwtAuthzModuleOptions, "createJwtAuthzModuleOptions"> & Partial<{
|
|
@@ -197,7 +197,7 @@ export declare const createJwtAuthzModule: <P, U, T extends AuthzProviderClass<P
|
|
|
197
197
|
refresh(user?: U | undefined): Promise<{
|
|
198
198
|
token: string;
|
|
199
199
|
} | undefined>;
|
|
200
|
-
setCookie(name: string, value: string, options?:
|
|
200
|
+
setCookie(name: string, value: string, options?: Record<string, any> | undefined): void;
|
|
201
201
|
getUser(): DeepReadonly<U> | undefined;
|
|
202
202
|
}, "als" | "jwtAuthzOptions" | "authzProvider">>;
|
|
203
203
|
};
|
|
@@ -53,6 +53,7 @@ const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, ASYNC_OPTIONS_TYPE, OPTIO
|
|
|
53
53
|
return (0, utils_1.mergeDynamicModuleConfigs)(definition, {
|
|
54
54
|
global,
|
|
55
55
|
providers: [
|
|
56
|
+
...(0, utils_1.createOnceAdapterShimProvider)(),
|
|
56
57
|
{
|
|
57
58
|
provide: constants_1.ROUTES_OPTIONS,
|
|
58
59
|
useValue: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { type Type } from '@nestjs/common';
|
|
3
3
|
import { AuthzProviderClass } from '../authz.provider';
|
|
4
|
-
import { type
|
|
4
|
+
import { type DeepReadonly } from '../utils';
|
|
5
5
|
import type { JwtAuthzOptions } from './jwt-authz.interface';
|
|
6
6
|
import type { JwtAlsType } from './jwt-authz-als.middleware';
|
|
7
7
|
export declare const createJwtAuthzService: <P = unknown, U = unknown>([AUTHZ_PROVIDER, JWT_AUTHZ_OPTIONS, ALS_PROVIDER]: [any, any, any]) => Type<Omit<{
|
|
@@ -36,7 +36,7 @@ export declare const createJwtAuthzService: <P = unknown, U = unknown>([AUTHZ_PR
|
|
|
36
36
|
/**
|
|
37
37
|
* Sets a secure HTTP cookie with the given name, value, and optional cookie options.
|
|
38
38
|
*/
|
|
39
|
-
setCookie(name: string, value: string, options?:
|
|
39
|
+
setCookie(name: string, value: string, options?: Record<string, any> | undefined): void;
|
|
40
40
|
/**
|
|
41
41
|
* Retrieves the current user associated with the request, if available.
|
|
42
42
|
*/
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { type Type } from '@nestjs/common';
|
|
3
|
-
import type { Request } from 'express';
|
|
4
3
|
import { AuthzProviderClass } from '../authz.provider';
|
|
5
4
|
import type { JwtAlsType } from './jwt-authz-als.middleware';
|
|
6
5
|
export declare const createJwtStrategy: ([JWT_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]: [string, any, any]) => Type<Omit<{
|
|
7
6
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
8
7
|
readonly als: AsyncLocalStorage<JwtAlsType<unknown>>;
|
|
9
|
-
validate(req:
|
|
10
|
-
authenticate(req: Request, options?: any): any;
|
|
8
|
+
validate(req: any): Promise<{}>;
|
|
9
|
+
authenticate(req: import("express").Request, options?: any): any;
|
|
11
10
|
}, "als" | "authzProvider">>;
|
|
12
11
|
export declare const createRefreshStrategy: ([JWT_REFRESH_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]: [string, any, any]) => Type<Omit<{
|
|
13
12
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
14
13
|
readonly als: AsyncLocalStorage<JwtAlsType<unknown>>;
|
|
15
|
-
validate(req:
|
|
16
|
-
authenticate(req: Request, options?: any): any;
|
|
14
|
+
validate(req: any): Promise<{}>;
|
|
15
|
+
authenticate(req: import("express").Request, options?: any): any;
|
|
17
16
|
}, "als" | "authzProvider">>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { type Type } from '@nestjs/common';
|
|
3
|
-
import
|
|
4
|
-
import { type CookieOptionsWithSecret } from '../utils';
|
|
3
|
+
import { type RawRequestWithShims, type RawResponseWithShims } from '../utils';
|
|
5
4
|
import type { SessionAuthzOptions } from './session-authz.interface';
|
|
6
5
|
export interface SessionAlsType<P, U> {
|
|
7
6
|
user?: U;
|
|
@@ -10,10 +9,10 @@ export interface SessionAlsType<P, U> {
|
|
|
10
9
|
authOptions: SessionAuthzOptions;
|
|
11
10
|
logIn: (user: P) => Promise<void>;
|
|
12
11
|
logOut: () => Promise<void>;
|
|
13
|
-
setCookie: (name: string, value: string, options?:
|
|
12
|
+
setCookie: (name: string, value: string, options?: Record<string, any>) => void;
|
|
14
13
|
}
|
|
15
14
|
export declare const createSessionAuthzAlsMiddleware: ([ALS_PROVIDER, SESSION_AUTHZ_OPTIONS]: [any, any]) => Type<Omit<{
|
|
16
15
|
readonly als: AsyncLocalStorage<SessionAlsType<unknown, unknown>>;
|
|
17
16
|
readonly sessionAuthzOptions: SessionAuthzOptions;
|
|
18
|
-
use(req:
|
|
17
|
+
use(req: RawRequestWithShims, res: RawResponseWithShims, next: Function): void;
|
|
19
18
|
}, "als" | "sessionAuthzOptions">>;
|
|
@@ -16,7 +16,6 @@ exports.createSessionAuthzAlsMiddleware = void 0;
|
|
|
16
16
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const constants_1 = require("../constants");
|
|
19
|
-
const errors_1 = require("../errors");
|
|
20
19
|
const utils_1 = require("../utils");
|
|
21
20
|
const createSessionAuthzAlsMiddleware = ([ALS_PROVIDER, SESSION_AUTHZ_OPTIONS]) => {
|
|
22
21
|
let SessionAuthzAlsMiddleware = class SessionAuthzAlsMiddleware {
|
|
@@ -26,64 +25,45 @@ const createSessionAuthzAlsMiddleware = ([ALS_PROVIDER, SESSION_AUTHZ_OPTIONS])
|
|
|
26
25
|
}
|
|
27
26
|
use(req, res, next) {
|
|
28
27
|
const keepSessionInfo = Boolean(this.sessionAuthzOptions.keepSessionInfo);
|
|
29
|
-
if (!req.session) {
|
|
30
|
-
return next(new errors_1.AuthzError('Login sessions require session support. Did you forget to use `express-session` middleware?'));
|
|
31
|
-
}
|
|
32
|
-
const prevSession = req.session;
|
|
33
28
|
const store = {
|
|
34
29
|
user: undefined,
|
|
35
30
|
allowAnonymous: undefined,
|
|
36
31
|
guardResult: undefined,
|
|
37
32
|
authOptions: this.sessionAuthzOptions,
|
|
38
33
|
// ref: https://github.com/jaredhanson/passport/blob/217018dbc46dcd4118dd6f2c60c8d97010c587f8/lib/sessionmanager.js#L14
|
|
39
|
-
logIn: (user) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
logIn: async (user) => {
|
|
35
|
+
const prevSession = req.shims.getAllSession();
|
|
36
|
+
await req.shims.regenerateSession();
|
|
37
|
+
if (keepSessionInfo) {
|
|
38
|
+
for (const key in prevSession) {
|
|
39
|
+
if (req.shims.sessionContains(key)) {
|
|
40
|
+
req.shims.setSession(key, prevSession[key]);
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
req.session[constants_1.SESSION_PASSPORT_KEY].user = user;
|
|
55
|
-
req.session.save(function (err) {
|
|
56
|
-
if (err) {
|
|
57
|
-
return reject(err);
|
|
58
|
-
}
|
|
59
|
-
resolve();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const passportSession = req.shims.getSession(constants_1.SESSION_PASSPORT_KEY) ?? {};
|
|
45
|
+
passportSession.user = user;
|
|
46
|
+
req.shims.setSession(constants_1.SESSION_PASSPORT_KEY, passportSession);
|
|
47
|
+
await req.shims.saveSession();
|
|
48
|
+
return;
|
|
63
49
|
},
|
|
64
50
|
// ref: https://github.com/jaredhanson/passport/blob/217018dbc46dcd4118dd6f2c60c8d97010c587f8/lib/sessionmanager.js#L57
|
|
65
|
-
logOut: () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
51
|
+
logOut: async () => {
|
|
52
|
+
if (req.shims.sessionContains(constants_1.SESSION_PASSPORT_KEY)) {
|
|
53
|
+
const passportSession = req.shims.getSession(constants_1.SESSION_PASSPORT_KEY);
|
|
54
|
+
delete passportSession.user;
|
|
55
|
+
req.shims.setSession(constants_1.SESSION_PASSPORT_KEY, passportSession);
|
|
56
|
+
}
|
|
57
|
+
const prevSession = req.shims.getAllSession();
|
|
58
|
+
await req.shims.saveSession();
|
|
59
|
+
await req.shims.regenerateSession();
|
|
60
|
+
if (keepSessionInfo) {
|
|
61
|
+
for (const key in prevSession) {
|
|
62
|
+
if (req.shims.sessionContains(key)) {
|
|
63
|
+
req.shims.setSession(key, prevSession[key]);
|
|
75
64
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return reject(err);
|
|
79
|
-
}
|
|
80
|
-
if (keepSessionInfo) {
|
|
81
|
-
(0, utils_1.merge)(req.session, prevSession);
|
|
82
|
-
}
|
|
83
|
-
resolve();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
87
67
|
},
|
|
88
68
|
setCookie: (0, utils_1.createSetCookieFn)(req, res)
|
|
89
69
|
};
|
|
@@ -2,7 +2,7 @@ import { ExecutionContext, type Type } from '@nestjs/common';
|
|
|
2
2
|
import { Reflector } from '@nestjs/core';
|
|
3
3
|
import type { AsyncLocalStorage } from 'async_hooks';
|
|
4
4
|
import { AuthzProviderClass } from '../authz.provider';
|
|
5
|
-
import {
|
|
5
|
+
import { AuthzError } from '../errors';
|
|
6
6
|
import type { SessionAuthzOptions } from './session-authz.interface';
|
|
7
7
|
import type { SessionAlsType } from './session-authz-als.middleware';
|
|
8
8
|
export declare const createSessionAuthzGuard: ([SESSION_STRATEGY, AUTHZ_PROVIDER, SESSION_AUTHZ_OPTIONS, ALS_PROVIDER, SESSION_META_KEY]: [string, any, any, any, any]) => Type<Omit<{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { type ConfigurableModuleAsyncOptions, DynamicModule, type ExecutionContext, MiddlewareConsumer, type Type } from '@nestjs/common';
|
|
3
|
-
import type
|
|
3
|
+
import { type Reflector } from '@nestjs/core';
|
|
4
4
|
import { AuthzProviderClass } from '../authz.provider';
|
|
5
5
|
import { AuthzError } from '../errors';
|
|
6
|
-
import { type AbstractConstructor, type ApplyDecorators, type AuthzDecoParams, type AuthzModuleBaseOptions, type AuthzModuleRoutesOptions, type
|
|
6
|
+
import { type AbstractConstructor, type ApplyDecorators, type AuthzDecoParams, type AuthzModuleBaseOptions, type AuthzModuleRoutesOptions, type DeepReadonly, type MethodParameters, type RoutesOptions } from '../utils';
|
|
7
7
|
import { type SessionAuthzModuleOptions, type SessionAuthzOptions } from './session-authz.interface';
|
|
8
8
|
import { type SessionAlsType } from './session-authz-als.middleware';
|
|
9
9
|
declare const ASYNC_OPTIONS_TYPE: ConfigurableModuleAsyncOptions<SessionAuthzModuleOptions, "createSessionAuthzModuleOptions"> & Partial<{
|
|
@@ -166,7 +166,7 @@ export declare const cereateSessionAuthzModule: <P, U, T extends AuthzProviderCl
|
|
|
166
166
|
readonly als: AsyncLocalStorage<SessionAlsType<P, U>>;
|
|
167
167
|
logIn(user: U): Promise<void>;
|
|
168
168
|
logOut(): Promise<void>;
|
|
169
|
-
setCookie(name: string, value: string, options?:
|
|
169
|
+
setCookie(name: string, value: string, options?: Record<string, any> | undefined): void;
|
|
170
170
|
getUser(): DeepReadonly<U> | undefined;
|
|
171
171
|
}, "als" | "authzProvider">>;
|
|
172
172
|
};
|
|
@@ -53,6 +53,7 @@ const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, ASYNC_OPTIONS_TYPE, OPTIO
|
|
|
53
53
|
return (0, utils_1.mergeDynamicModuleConfigs)(definition, {
|
|
54
54
|
global,
|
|
55
55
|
providers: [
|
|
56
|
+
...(0, utils_1.createOnceAdapterShimProvider)(),
|
|
56
57
|
{
|
|
57
58
|
provide: constants_1.ROUTES_OPTIONS,
|
|
58
59
|
useValue: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { type Type } from '@nestjs/common';
|
|
3
3
|
import { AuthzProviderClass } from '../authz.provider';
|
|
4
|
-
import { type
|
|
4
|
+
import { type DeepReadonly } from '../utils';
|
|
5
5
|
import type { SessionAlsType } from './session-authz-als.middleware';
|
|
6
6
|
export declare const createSessionAuthzService: <P = unknown, U = unknown>([AUTHZ_PROVIDER, ALS_PROVIDER]: [any, any]) => Type<Omit<{
|
|
7
7
|
readonly authzProvider: AuthzProviderClass<P, U>;
|
|
@@ -19,7 +19,7 @@ export declare const createSessionAuthzService: <P = unknown, U = unknown>([AUTH
|
|
|
19
19
|
/**
|
|
20
20
|
* Sets a secure HTTP cookie with the given name, value, and optional cookie options.
|
|
21
21
|
*/
|
|
22
|
-
setCookie(name: string, value: string, options?:
|
|
22
|
+
setCookie(name: string, value: string, options?: Record<string, any> | undefined): void;
|
|
23
23
|
/**
|
|
24
24
|
* Retrieves the current user associated with the request, if available.
|
|
25
25
|
*/
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { type Type } from '@nestjs/common';
|
|
3
|
-
import type { Request } from 'express';
|
|
4
3
|
import { AuthzProviderClass } from '../authz.provider';
|
|
5
4
|
import type { SessionAlsType } from './session-authz-als.middleware';
|
|
6
5
|
export declare const createSessionAuthzStrategy: ([SESSION_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]: [string, any, any]) => Type<Omit<{
|
|
7
6
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
8
7
|
readonly als: AsyncLocalStorage<SessionAlsType<unknown, unknown>>;
|
|
9
|
-
validate(req:
|
|
10
|
-
authenticate(req: Request, options?: any): any;
|
|
8
|
+
validate(req: any): Promise<{}>;
|
|
9
|
+
authenticate(req: import("express").Request, options?: any): any;
|
|
11
10
|
}, "als" | "authzProvider">>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type CanActivate, ExecutionContext, type OnModuleInit, type Provider } from '@nestjs/common';
|
|
2
|
+
import { HttpAdapterHost } from '@nestjs/core';
|
|
3
|
+
export type RawRequestWithShims = {
|
|
4
|
+
shims: {
|
|
5
|
+
getSession(key?: string): any;
|
|
6
|
+
getAllSession(): any;
|
|
7
|
+
setSession(key: string, value: any): void;
|
|
8
|
+
deleteSession(key: string): void;
|
|
9
|
+
sessionContains(key: string): boolean;
|
|
10
|
+
regenerateSession(): Promise<void>;
|
|
11
|
+
saveSession(): Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
export type RawResponseWithShims = {
|
|
16
|
+
shims: {
|
|
17
|
+
setCookie(key: string, value: string, options?: Record<string, any>): void;
|
|
18
|
+
};
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
export declare class AdapterShim implements CanActivate, OnModuleInit {
|
|
22
|
+
private httpAdapterHost;
|
|
23
|
+
private addShims;
|
|
24
|
+
constructor(httpAdapterHost: HttpAdapterHost);
|
|
25
|
+
onModuleInit(): void;
|
|
26
|
+
canActivate(context: ExecutionContext): boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare const createOnceAdapterShimProvider: () => Provider[];
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createOnceAdapterShimProvider = exports.AdapterShim = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
const errors_1 = require("../errors");
|
|
16
|
+
const safe_clone_1 = require("./safe-clone");
|
|
17
|
+
const addExpressShims = (req, res) => {
|
|
18
|
+
const reqShims = {
|
|
19
|
+
getSession(key) {
|
|
20
|
+
return req.session?.[key];
|
|
21
|
+
},
|
|
22
|
+
getAllSession() {
|
|
23
|
+
return (0, safe_clone_1.safeClone)(req.session);
|
|
24
|
+
},
|
|
25
|
+
setSession(key, value) {
|
|
26
|
+
req.session[key] = value;
|
|
27
|
+
},
|
|
28
|
+
deleteSession(key) {
|
|
29
|
+
delete req.session?.[key];
|
|
30
|
+
},
|
|
31
|
+
sessionContains(key) {
|
|
32
|
+
if (!req.session) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return key in req.session;
|
|
36
|
+
},
|
|
37
|
+
async regenerateSession() {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
req.session.regenerate((err) => {
|
|
40
|
+
if (err)
|
|
41
|
+
return reject(err);
|
|
42
|
+
resolve();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
async saveSession() {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
req.session.save((err) => {
|
|
49
|
+
if (err)
|
|
50
|
+
return reject(err);
|
|
51
|
+
resolve();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const resShims = {
|
|
57
|
+
setCookie(key, value, options) {
|
|
58
|
+
res.cookie(key, value, options);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
req.shims = reqShims;
|
|
62
|
+
res.shims = resShims;
|
|
63
|
+
};
|
|
64
|
+
const addFastifyShims = (req, res) => {
|
|
65
|
+
const reqShims = {
|
|
66
|
+
getSession(key) {
|
|
67
|
+
return req.session.get(key);
|
|
68
|
+
},
|
|
69
|
+
getAllSession() {
|
|
70
|
+
const cloned = (0, safe_clone_1.safeClone)(req.session);
|
|
71
|
+
// exclude cookie in @fastify/session
|
|
72
|
+
if (req.session?.cookie?.constructor?.name === 'Cookie') {
|
|
73
|
+
delete cloned.cookie;
|
|
74
|
+
}
|
|
75
|
+
// exclude built-in props in @fastify/secure-session
|
|
76
|
+
if (req.session?.constructor?.name === 'Session') {
|
|
77
|
+
delete cloned.changed;
|
|
78
|
+
delete cloned.deleted;
|
|
79
|
+
}
|
|
80
|
+
return cloned;
|
|
81
|
+
},
|
|
82
|
+
setSession(key, value) {
|
|
83
|
+
req.session.set(key, value);
|
|
84
|
+
},
|
|
85
|
+
deleteSession(key) {
|
|
86
|
+
req.session[key] = undefined;
|
|
87
|
+
},
|
|
88
|
+
sessionContains(key) {
|
|
89
|
+
if (!req.session) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
// fastify-session
|
|
93
|
+
if (key in req.session) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
// fastify-secure-session
|
|
97
|
+
return req.session.get(key) !== undefined;
|
|
98
|
+
},
|
|
99
|
+
async regenerateSession() {
|
|
100
|
+
if (typeof req.session.save === 'function') {
|
|
101
|
+
// fastify-session
|
|
102
|
+
return req.session.regenerate();
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// fastify-secure-session
|
|
106
|
+
try {
|
|
107
|
+
req.session.regenerate();
|
|
108
|
+
return Promise.resolve();
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
return Promise.reject(err);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
async saveSession() {
|
|
116
|
+
if (typeof req.session.save === 'function') {
|
|
117
|
+
// fastify-session
|
|
118
|
+
return req.session.save();
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// fastify-secure-session does not have save method
|
|
122
|
+
return Promise.resolve();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const resShims = {
|
|
127
|
+
setCookie(key, value, options) {
|
|
128
|
+
res.setCookie(key, value, options);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
req.raw.shims = reqShims;
|
|
132
|
+
res.raw.shims = resShims;
|
|
133
|
+
};
|
|
134
|
+
const getShimsFactory = (adapter) => {
|
|
135
|
+
switch (adapter) {
|
|
136
|
+
case 'ExpressAdapter':
|
|
137
|
+
return addExpressShims;
|
|
138
|
+
case 'FastifyAdapter':
|
|
139
|
+
return addFastifyShims;
|
|
140
|
+
}
|
|
141
|
+
throw new errors_1.AuthzError(`Cannot find shims factory for adapter "${adapter}".`);
|
|
142
|
+
};
|
|
143
|
+
let AdapterShim = class AdapterShim {
|
|
144
|
+
constructor(httpAdapterHost) {
|
|
145
|
+
this.httpAdapterHost = httpAdapterHost;
|
|
146
|
+
}
|
|
147
|
+
onModuleInit() {
|
|
148
|
+
const adapter = this.httpAdapterHost?.httpAdapter?.constructor?.name;
|
|
149
|
+
this.addShims = getShimsFactory(adapter);
|
|
150
|
+
}
|
|
151
|
+
canActivate(context) {
|
|
152
|
+
this.addShims(context.switchToHttp().getRequest(), context.switchToHttp().getResponse());
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
exports.AdapterShim = AdapterShim;
|
|
157
|
+
exports.AdapterShim = AdapterShim = __decorate([
|
|
158
|
+
(0, common_1.Injectable)(),
|
|
159
|
+
__metadata("design:paramtypes", [core_1.HttpAdapterHost])
|
|
160
|
+
], AdapterShim);
|
|
161
|
+
let guardRegistered = false;
|
|
162
|
+
const createOnceAdapterShimProvider = () => {
|
|
163
|
+
if (guardRegistered) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
guardRegistered = true;
|
|
167
|
+
return [
|
|
168
|
+
{
|
|
169
|
+
provide: core_1.APP_GUARD,
|
|
170
|
+
useClass: AdapterShim
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
};
|
|
174
|
+
exports.createOnceAdapterShimProvider = createOnceAdapterShimProvider;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
signedCookies: Record<string, any>;
|
|
1
|
+
export declare const normalCookieParser: (req: any, _secrets?: string[], decode?: (str: string) => string | undefined) => {
|
|
2
|
+
cookies: any;
|
|
3
|
+
signedCookies: any;
|
|
5
4
|
};
|
|
6
|
-
export declare const customCookieParser: (req:
|
|
7
|
-
cookies:
|
|
8
|
-
signedCookies:
|
|
5
|
+
export declare const customCookieParser: (req: any, secrets?: string[], decode?: (str: string) => string | undefined) => {
|
|
6
|
+
cookies: {};
|
|
7
|
+
signedCookies: {};
|
|
9
8
|
};
|
|
@@ -42,8 +42,18 @@ const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
|
42
42
|
const normalCookieParser = (req, _secrets = [], decode) => {
|
|
43
43
|
let cookies = req.cookies || {};
|
|
44
44
|
let signedCookies = req.signedCookies || {};
|
|
45
|
+
// compatible to @fastify/cookie
|
|
46
|
+
if (typeof req.unsignCookie === 'function') {
|
|
47
|
+
for (const [key, value] of Object.entries(cookies)) {
|
|
48
|
+
const unsigned = req.unsignCookie(value);
|
|
49
|
+
if (unsigned.valid) {
|
|
50
|
+
signedCookies[key] = unsigned.value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
45
54
|
if (!req.cookies && req.headers.cookie) {
|
|
46
55
|
const parsedCookies = cookie.parse(req.headers.cookie, { decode });
|
|
56
|
+
// cookie-parser uses req.secret to decrypt cookies
|
|
47
57
|
if (req.secret) {
|
|
48
58
|
signedCookies = cookie_parser_1.default.JSONCookies(cookie_parser_1.default.signedCookies(parsedCookies, [req.secret]));
|
|
49
59
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare const createSetCookieFn: (req: Request, res: Response) => (name: string, value: string, options?: CookieOptionsWithSecret) => void;
|
|
1
|
+
import type { RawRequestWithShims, RawResponseWithShims } from './adapter-shim';
|
|
2
|
+
export declare const createSetCookieFn: (req: RawRequestWithShims, res: RawResponseWithShims) => (name: string, value: string, options?: Record<string, any>) => void;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSetCookieFn = void 0;
|
|
4
4
|
const generics_1 = require("./generics");
|
|
5
|
+
// @fastify/cookie does not use req.secret to encrypted.
|
|
5
6
|
const createSetCookieFn = (req, res) => (name, value, options = {}) => {
|
|
6
7
|
const { secret, signed: optSigned, ...restOpts } = options;
|
|
7
8
|
const secrets = (0, generics_1.normalizedArray)(secret) ?? [];
|
|
@@ -15,7 +16,7 @@ const createSetCookieFn = (req, res) => (name, value, options = {}) => {
|
|
|
15
16
|
else {
|
|
16
17
|
req.secret = undefined;
|
|
17
18
|
}
|
|
18
|
-
res.
|
|
19
|
+
res.shims.setCookie(name, value, {
|
|
19
20
|
signed,
|
|
20
21
|
...restOpts
|
|
21
22
|
});
|
package/dist/utils/generics.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const isNotFalsy: <T>(val: T) => val is T;
|
|
2
2
|
export declare const normalizedArray: <T>(val?: T | T[]) => undefined extends T ? T[] | undefined : NonNullable<T>[];
|
|
3
3
|
export declare const normalizedObject: <T extends Record<string, any>>(obj?: T) => T | undefined;
|
|
4
|
-
export declare const merge: <T extends Record<string, any>, U extends Record<string, any>>(obj1: T, obj2?: U) => T & U;
|
package/dist/utils/generics.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.normalizedObject = exports.normalizedArray = exports.isNotFalsy = void 0;
|
|
4
4
|
const isNotFalsy = (val) => {
|
|
5
5
|
return val !== undefined && val !== null && !Number.isNaN(val);
|
|
6
6
|
};
|
|
@@ -27,14 +27,3 @@ const normalizedObject = (obj) => {
|
|
|
27
27
|
return Object.fromEntries(filtered);
|
|
28
28
|
};
|
|
29
29
|
exports.normalizedObject = normalizedObject;
|
|
30
|
-
// ref: https://github.com/jaredhanson/utils-merge/blob/master/index.js
|
|
31
|
-
const merge = (obj1, obj2) => {
|
|
32
|
-
if (obj1 && obj2) {
|
|
33
|
-
for (var key in obj2) {
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
obj1[key] = obj2[key];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return obj1;
|
|
39
|
-
};
|
|
40
|
-
exports.merge = merge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getPassportProperty: <T>(request:
|
|
1
|
+
export declare const getPassportProperty: <T>(request: any) => T;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getPassportProperty = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const getPassportProperty = (request) => {
|
|
6
|
-
// @ts-ignore
|
|
7
6
|
return request[request[constants_1.PASSPORT_PROPERTY]];
|
|
8
7
|
};
|
|
9
8
|
exports.getPassportProperty = getPassportProperty;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './adapter-shim';
|
|
1
2
|
export * from './cookie-parsers';
|
|
2
3
|
export * from './create-authz-decorator-factory';
|
|
3
4
|
export * from './create-set-cookie-fn';
|
|
@@ -8,4 +9,5 @@ export * from './get-context-authz-meta-params-list';
|
|
|
8
9
|
export * from './get-passport-property';
|
|
9
10
|
export * from './merge-dynamic-module-configs';
|
|
10
11
|
export * from './msgpackrs';
|
|
12
|
+
export * from './safe-clone';
|
|
11
13
|
export * from './types';
|
package/dist/utils/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./adapter-shim"), exports);
|
|
17
18
|
__exportStar(require("./cookie-parsers"), exports);
|
|
18
19
|
__exportStar(require("./create-authz-decorator-factory"), exports);
|
|
19
20
|
__exportStar(require("./create-set-cookie-fn"), exports);
|
|
@@ -24,4 +25,5 @@ __exportStar(require("./get-context-authz-meta-params-list"), exports);
|
|
|
24
25
|
__exportStar(require("./get-passport-property"), exports);
|
|
25
26
|
__exportStar(require("./merge-dynamic-module-configs"), exports);
|
|
26
27
|
__exportStar(require("./msgpackrs"), exports);
|
|
28
|
+
__exportStar(require("./safe-clone"), exports);
|
|
27
29
|
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const safeClone: (obj: any) => any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safeClone = void 0;
|
|
4
|
+
const safeClone = (obj) => {
|
|
5
|
+
if (!obj) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(JSON.stringify(obj));
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
exports.safeClone = safeClone;
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { applyDecorators } from '@nestjs/common';
|
|
2
2
|
import type { RouteInfo, Type } from '@nestjs/common/interfaces';
|
|
3
|
-
import type { CookieOptions } from 'express';
|
|
4
3
|
import type { AuthzProviderClass } from '../authz.provider';
|
|
5
4
|
export type OmitClassInstance<T extends abstract new (...args: any) => any, K extends keyof any> = Type<Omit<InstanceType<T>, K>>;
|
|
6
5
|
export type SetRequired<T, K extends keyof T> = T & {
|
|
@@ -12,12 +11,6 @@ export type IsUnknown<T> = unknown extends T ? IsNull<T> extends false ? true :
|
|
|
12
11
|
export type DeepReadonly<T> = {
|
|
13
12
|
readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];
|
|
14
13
|
};
|
|
15
|
-
export type CookieOptionsWithSecret = CookieOptions & {
|
|
16
|
-
/**
|
|
17
|
-
* a string or array used to sign cookies.
|
|
18
|
-
*/
|
|
19
|
-
secret?: string | string[];
|
|
20
|
-
};
|
|
21
14
|
export interface AuthzDecoBaseOptions {
|
|
22
15
|
/**
|
|
23
16
|
* When set, overrides the previous metadatas during the authorization, instead of inheriting.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nestjs-kitchen/authz",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "Simplest authentication & authorization module in NextJS",
|
|
5
|
-
"version": "3.0
|
|
5
|
+
"version": "3.1.0",
|
|
6
6
|
"homepage": "https://github.com/yikenman/nestjs-kitchen",
|
|
7
7
|
"repository": "https://github.com/yikenman/nestjs-kitchen",
|
|
8
8
|
"author": "yikenman",
|
|
@@ -26,16 +26,22 @@
|
|
|
26
26
|
"uid": "^2.0.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
+
"@fastify/cookie": "^11.0.2",
|
|
30
|
+
"@fastify/secure-session": "^8.2.0",
|
|
31
|
+
"@fastify/session": "^11.1.0",
|
|
32
|
+
"@nestjs/platform-express": "^11.0.0",
|
|
33
|
+
"@nestjs/platform-fastify": "^11.0.0",
|
|
29
34
|
"@nestjs/testing": "^11.0.0",
|
|
30
35
|
"@types/cookie-parser": "^1.4.8",
|
|
31
36
|
"@types/express": "^5.0.1",
|
|
32
|
-
"@types/express-session": "^1.18.
|
|
37
|
+
"@types/express-session": "^1.18.2",
|
|
33
38
|
"@types/jest": "^30.0.0",
|
|
34
39
|
"@types/jsonwebtoken": "^9.0.9",
|
|
35
40
|
"@types/node": "^22.13.9",
|
|
36
41
|
"@types/passport": "^1.0.17",
|
|
37
42
|
"@types/supertest": "^6.0.2",
|
|
38
|
-
"express-session": "^1.18.
|
|
43
|
+
"express-session": "^1.18.2",
|
|
44
|
+
"fastify": "^5.5.0",
|
|
39
45
|
"jest": "^30.0.5",
|
|
40
46
|
"rimraf": "^6.0.1",
|
|
41
47
|
"supertest": "^7.1.0",
|
|
@@ -52,16 +58,30 @@
|
|
|
52
58
|
"authentication",
|
|
53
59
|
"authorization",
|
|
54
60
|
"authz",
|
|
61
|
+
"express",
|
|
62
|
+
"Express",
|
|
63
|
+
"fastify",
|
|
64
|
+
"Fastify",
|
|
55
65
|
"JWT",
|
|
56
66
|
"NextJS",
|
|
57
67
|
"NodeJS",
|
|
68
|
+
"passport",
|
|
69
|
+
"Passport",
|
|
58
70
|
"Session"
|
|
59
71
|
],
|
|
72
|
+
"optionalDependencies": {
|
|
73
|
+
"@fastify/cookie": "^11.0.2",
|
|
74
|
+
"@fastify/secure-session": "^8.2.0",
|
|
75
|
+
"@fastify/session": "^11.1.0",
|
|
76
|
+
"@nestjs/platform-express": "^11.0.0",
|
|
77
|
+
"@nestjs/platform-fastify": "^11.0.0",
|
|
78
|
+
"@types/express-session": "^1.18.2",
|
|
79
|
+
"express-session": "^1.18.2"
|
|
80
|
+
},
|
|
60
81
|
"peerDependencies": {
|
|
61
|
-
"@nestjs/common": "^
|
|
62
|
-
"@nestjs/core": "^
|
|
63
|
-
"@nestjs/passport": "^
|
|
64
|
-
"@nestjs/platform-express": "^10.0.0 || ^11.0.0",
|
|
82
|
+
"@nestjs/common": "^11.0.0",
|
|
83
|
+
"@nestjs/core": "^11.0.0",
|
|
84
|
+
"@nestjs/passport": "^11.0.0",
|
|
65
85
|
"passport": "^0.7.0",
|
|
66
86
|
"reflect-metadata": "^0.2.2",
|
|
67
87
|
"rxjs": "^7.8.2"
|