@nestjs-kitchen/authz 2.0.6 → 2.0.7
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/dist/jwt/jwt-authz-als.middleware.d.ts +2 -1
- package/dist/jwt/jwt-authz.guard.d.ts +5 -4
- package/dist/jwt/jwt-authz.interface.d.ts +9 -8
- package/dist/jwt/jwt-authz.module.d.ts +15 -14
- package/dist/jwt/jwt-authz.service.d.ts +4 -3
- package/dist/jwt/jwt-authz.strategy.d.ts +3 -2
- package/dist/session/session-authz-als.middleware.d.ts +2 -1
- package/dist/session/session-authz.guard.d.ts +2 -2
- package/dist/session/session-authz.module.d.ts +14 -13
- package/dist/session/session-authz.service.d.ts +4 -3
- package/dist/session/session-authz.strategy.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { type Type } from '@nestjs/common';
|
|
2
3
|
import type { NextFunction, Request, Response } from 'express';
|
|
3
4
|
import { JwtValidationType } from '../constants';
|
|
4
5
|
import { type CookieOptionsWithSecret } from '../utils';
|
|
@@ -11,7 +12,7 @@ export interface JwtAlsType<U> {
|
|
|
11
12
|
authOptions: JwtAuthzOptions;
|
|
12
13
|
setCookie: (name: string, value: string, options?: CookieOptionsWithSecret) => void;
|
|
13
14
|
}
|
|
14
|
-
export declare const createJwtAuthzAlsMiddleware: ([ALS_PROVIDER, JWT_AUTHZ_OPTIONS]: [any, any]) =>
|
|
15
|
+
export declare const createJwtAuthzAlsMiddleware: ([ALS_PROVIDER, JWT_AUTHZ_OPTIONS]: [any, any]) => Type<Omit<{
|
|
15
16
|
readonly als: AsyncLocalStorage<JwtAlsType<unknown>>;
|
|
16
17
|
readonly jwtAuthzOptions: JwtAuthzOptions;
|
|
17
18
|
use(req: Request, res: Response, next: NextFunction): void;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { ExecutionContext, type Type } from '@nestjs/common';
|
|
3
3
|
import { Reflector } from '@nestjs/core';
|
|
4
|
+
import type { Observable } from 'rxjs';
|
|
4
5
|
import { AuthzProviderClass } from '../authz.provider';
|
|
5
6
|
import { type AuthzError } from '../errors';
|
|
6
7
|
import type { JwtAlsType } from './jwt-authz-als.middleware';
|
|
7
8
|
import type { JwtAuthzOptions } from './jwt-authz.interface';
|
|
8
|
-
export declare const createJwtAuthzGuard: ([JWT_STRATEGY, AUTHZ_PROVIDER, JWT_AUTHZ_OPTIONS, ALS_PROVIDER, JWT_META_KEY, JWT_REFRESH_META_KEY]: [string, any, any, any, any, any]) =>
|
|
9
|
+
export declare const createJwtAuthzGuard: ([JWT_STRATEGY, AUTHZ_PROVIDER, JWT_AUTHZ_OPTIONS, ALS_PROVIDER, JWT_META_KEY, JWT_REFRESH_META_KEY]: [string, any, any, any, any, any]) => Type<Omit<{
|
|
9
10
|
readonly reflector: Reflector;
|
|
10
11
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
11
12
|
readonly jwtAuthzOptions: JwtAuthzOptions;
|
|
@@ -32,14 +33,14 @@ export declare const createJwtAuthzGuard: ([JWT_STRATEGY, AUTHZ_PROVIDER, JWT_AU
|
|
|
32
33
|
} = any>(request: TRequest): Promise<void>;
|
|
33
34
|
getRequest(context: ExecutionContext): any;
|
|
34
35
|
}, "als" | "jwtAuthzOptions" | "reflector" | "authzProvider">>;
|
|
35
|
-
export declare const createJwtRefreshAuthzGuard: ([JWT_REFRESH_STRATEGY, JWT_AUTHZ_OPTIONS]: [string, any]) =>
|
|
36
|
+
export declare const createJwtRefreshAuthzGuard: ([JWT_REFRESH_STRATEGY, JWT_AUTHZ_OPTIONS]: [string, any]) => Type<Omit<{
|
|
36
37
|
readonly jwtAuthzOptions: JwtAuthzOptions;
|
|
37
38
|
getAuthenticateOptions(): {
|
|
38
39
|
property: string;
|
|
39
40
|
session: boolean;
|
|
40
41
|
};
|
|
41
42
|
handleRequest<T>(_err: unknown, user: T, info?: AuthzError): T;
|
|
42
|
-
canActivate(context: ExecutionContext): boolean | Promise<boolean> |
|
|
43
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean>;
|
|
43
44
|
logIn<TRequest extends {
|
|
44
45
|
logIn: Function;
|
|
45
46
|
} = any>(request: TRequest): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JsonWebKeyInput, KeyObject, PrivateKeyInput, PublicKeyInput } from 'node:crypto';
|
|
1
2
|
import { type PrivateKey, type PublicKey, type Secret, type SignOptions, type VerifyOptions } from 'jsonwebtoken';
|
|
2
3
|
import { type AuthzModuleBaseOptions } from '../utils';
|
|
3
4
|
import type { JwtFromRequestFunction } from './extract-jwt';
|
|
@@ -43,27 +44,27 @@ export declare const normalizedJwtAuthzModuleOptions: (options: JwtAuthzModuleOp
|
|
|
43
44
|
skipFalsyMetadata: boolean;
|
|
44
45
|
defaultAllowAnonymous: boolean;
|
|
45
46
|
jwt: {
|
|
46
|
-
secretOrPrivateKey: string | Buffer<ArrayBufferLike> |
|
|
47
|
+
secretOrPrivateKey: string | Buffer<ArrayBufferLike> | KeyObject | {
|
|
47
48
|
key: string | Buffer;
|
|
48
49
|
passphrase: string;
|
|
49
|
-
} |
|
|
50
|
-
secretOrPublicKey: string | Buffer<ArrayBufferLike> |
|
|
50
|
+
} | PrivateKeyInput | JsonWebKeyInput | null;
|
|
51
|
+
secretOrPublicKey: string | Buffer<ArrayBufferLike> | KeyObject | {
|
|
51
52
|
key: string | Buffer;
|
|
52
53
|
passphrase: string;
|
|
53
|
-
} |
|
|
54
|
+
} | JsonWebKeyInput | PublicKeyInput | null;
|
|
54
55
|
jwtFromRequest: JwtFromRequestFunction<any>[];
|
|
55
56
|
sign: SignOptions;
|
|
56
57
|
verify: VerifyOptions;
|
|
57
58
|
};
|
|
58
59
|
refresh: {
|
|
59
|
-
secretOrPrivateKey: string | Buffer<ArrayBufferLike> |
|
|
60
|
+
secretOrPrivateKey: string | Buffer<ArrayBufferLike> | KeyObject | {
|
|
60
61
|
key: string | Buffer;
|
|
61
62
|
passphrase: string;
|
|
62
|
-
} |
|
|
63
|
-
secretOrPublicKey: string | Buffer<ArrayBufferLike> |
|
|
63
|
+
} | PrivateKeyInput | JsonWebKeyInput | null;
|
|
64
|
+
secretOrPublicKey: string | Buffer<ArrayBufferLike> | KeyObject | {
|
|
64
65
|
key: string | Buffer;
|
|
65
66
|
passphrase: string;
|
|
66
|
-
} |
|
|
67
|
+
} | JsonWebKeyInput | PublicKeyInput | null;
|
|
67
68
|
jwtFromRequest: JwtFromRequestFunction<any>[];
|
|
68
69
|
sign: SignOptions;
|
|
69
70
|
verify: VerifyOptions;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import { DynamicModule, MiddlewareConsumer, type Type } from '@nestjs/common';
|
|
2
|
+
import { type ConfigurableModuleAsyncOptions, DynamicModule, type ExecutionContext, MiddlewareConsumer, type Type } from '@nestjs/common';
|
|
3
|
+
import type { Reflector } from '@nestjs/core';
|
|
3
4
|
import { AuthzProviderClass } from '../authz.provider';
|
|
4
5
|
import { AuthzError } from '../errors';
|
|
5
|
-
import { type AbstractConstructor, type ApplyDecorators, type AuthzModuleRoutesOptions, type RoutesOptions } from '../utils';
|
|
6
|
+
import { type AbstractConstructor, type ApplyDecorators, type AuthzDecoParams, type AuthzModuleBaseOptions, type AuthzModuleRoutesOptions, type CookieOptionsWithSecret, type DeepReadonly, type MethodParameters, type RoutesOptions } from '../utils';
|
|
6
7
|
import { type JwtAlsType } from './jwt-authz-als.middleware';
|
|
7
|
-
import { type JwtAuthzModuleOptions, type JwtAuthzOptions } from './jwt-authz.interface';
|
|
8
|
-
declare const ASYNC_OPTIONS_TYPE:
|
|
8
|
+
import { type JwtAuthzModuleOptions, type JwtAuthzOptions, type JwtOptions } from './jwt-authz.interface';
|
|
9
|
+
declare const ASYNC_OPTIONS_TYPE: ConfigurableModuleAsyncOptions<JwtAuthzModuleOptions, "createJwtAuthzModuleOptions"> & Partial<{
|
|
9
10
|
authzProvider?: Type<AuthzProviderClass<unknown, unknown>>;
|
|
10
|
-
} & AuthzModuleRoutesOptions>, OPTIONS_TYPE: Partial<
|
|
11
|
-
jwt:
|
|
12
|
-
refresh?:
|
|
11
|
+
} & AuthzModuleRoutesOptions>, OPTIONS_TYPE: Partial<AuthzModuleBaseOptions> & {
|
|
12
|
+
jwt: JwtOptions;
|
|
13
|
+
refresh?: JwtOptions;
|
|
13
14
|
} & Partial<{
|
|
14
15
|
authzProvider?: Type<AuthzProviderClass<unknown, unknown>>;
|
|
15
16
|
} & AuthzModuleRoutesOptions>;
|
|
@@ -92,7 +93,7 @@ export declare const createJwtAuthzModule: <P, U, T extends AuthzProviderClass<P
|
|
|
92
93
|
* ```
|
|
93
94
|
*/
|
|
94
95
|
AuthzGuard: Type<Omit<{
|
|
95
|
-
readonly reflector:
|
|
96
|
+
readonly reflector: Reflector;
|
|
96
97
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
97
98
|
readonly jwtAuthzOptions: JwtAuthzOptions;
|
|
98
99
|
readonly als: AsyncLocalStorage<JwtAlsType<unknown>>;
|
|
@@ -101,11 +102,11 @@ export declare const createJwtAuthzModule: <P, U, T extends AuthzProviderClass<P
|
|
|
101
102
|
session: boolean;
|
|
102
103
|
};
|
|
103
104
|
handleRequest<T_1>(_err: unknown, user: T_1, info?: AuthzError): T_1;
|
|
104
|
-
canActivate(context:
|
|
105
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
105
106
|
logIn<TRequest extends {
|
|
106
107
|
logIn: Function;
|
|
107
108
|
} = any>(request: TRequest): Promise<void>;
|
|
108
|
-
getRequest(context:
|
|
109
|
+
getRequest(context: ExecutionContext): any;
|
|
109
110
|
}, "als" | "jwtAuthzOptions" | "reflector" | "authzProvider">> & {
|
|
110
111
|
/**
|
|
111
112
|
* Verifies the user's authorization for specific meta data.
|
|
@@ -124,7 +125,7 @@ export declare const createJwtAuthzModule: <P, U, T extends AuthzProviderClass<P
|
|
|
124
125
|
* }
|
|
125
126
|
* ```
|
|
126
127
|
*/
|
|
127
|
-
Verify: (...args:
|
|
128
|
+
Verify: (...args: AuthzDecoParams<MethodParameters<T, "authorize">[1]>) => ApplyDecorators;
|
|
128
129
|
/**
|
|
129
130
|
* Skips authentication & authorization checks for specific routes.
|
|
130
131
|
*
|
|
@@ -177,7 +178,7 @@ export declare const createJwtAuthzModule: <P, U, T extends AuthzProviderClass<P
|
|
|
177
178
|
* }
|
|
178
179
|
* ```
|
|
179
180
|
*/
|
|
180
|
-
Apply: (...rest: Parameters<(...args:
|
|
181
|
+
Apply: (...rest: Parameters<(...args: AuthzDecoParams<MethodParameters<T, "authorize">[1]>) => ApplyDecorators>) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
181
182
|
};
|
|
182
183
|
/**
|
|
183
184
|
* A custom servcie to provide methods to handle authentication and authorization.
|
|
@@ -196,8 +197,8 @@ export declare const createJwtAuthzModule: <P, U, T extends AuthzProviderClass<P
|
|
|
196
197
|
refresh(user?: U | undefined): Promise<{
|
|
197
198
|
token: string;
|
|
198
199
|
} | undefined>;
|
|
199
|
-
setCookie(name: string, value: string, options?:
|
|
200
|
-
getUser():
|
|
200
|
+
setCookie(name: string, value: string, options?: CookieOptionsWithSecret | undefined): void;
|
|
201
|
+
getUser(): DeepReadonly<U> | undefined;
|
|
201
202
|
}, "als" | "jwtAuthzOptions" | "authzProvider">>;
|
|
202
203
|
};
|
|
203
204
|
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { type Type } from '@nestjs/common';
|
|
2
3
|
import { AuthzProviderClass } from '../authz.provider';
|
|
3
|
-
import { type DeepReadonly } from '../utils';
|
|
4
|
+
import { type CookieOptionsWithSecret, type DeepReadonly } from '../utils';
|
|
4
5
|
import type { JwtAlsType } from './jwt-authz-als.middleware';
|
|
5
6
|
import type { JwtAuthzOptions } from './jwt-authz.interface';
|
|
6
|
-
export declare const createJwtAuthzService: <P = unknown, U = unknown>([AUTHZ_PROVIDER, JWT_AUTHZ_OPTIONS, ALS_PROVIDER]: [any, any, any]) =>
|
|
7
|
+
export declare const createJwtAuthzService: <P = unknown, U = unknown>([AUTHZ_PROVIDER, JWT_AUTHZ_OPTIONS, ALS_PROVIDER]: [any, any, any]) => Type<Omit<{
|
|
7
8
|
readonly authzProvider: AuthzProviderClass<P, U>;
|
|
8
9
|
readonly jwtAuthzOptions: JwtAuthzOptions;
|
|
9
10
|
readonly als: AsyncLocalStorage<JwtAlsType<U>>;
|
|
@@ -35,7 +36,7 @@ export declare const createJwtAuthzService: <P = unknown, U = unknown>([AUTHZ_PR
|
|
|
35
36
|
/**
|
|
36
37
|
* Sets a secure HTTP cookie with the given name, value, and optional cookie options.
|
|
37
38
|
*/
|
|
38
|
-
setCookie(name: string, value: string, options?:
|
|
39
|
+
setCookie(name: string, value: string, options?: CookieOptionsWithSecret | undefined): void;
|
|
39
40
|
/**
|
|
40
41
|
* Retrieves the current user associated with the request, if available.
|
|
41
42
|
*/
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { type Type } from '@nestjs/common';
|
|
2
3
|
import type { Request } from 'express';
|
|
3
4
|
import { AuthzProviderClass } from '../authz.provider';
|
|
4
5
|
import type { JwtAlsType } from './jwt-authz-als.middleware';
|
|
5
|
-
export declare const createJwtStrategy: ([JWT_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]: [string, any, any]) =>
|
|
6
|
+
export declare const createJwtStrategy: ([JWT_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]: [string, any, any]) => Type<Omit<{
|
|
6
7
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
7
8
|
readonly als: AsyncLocalStorage<JwtAlsType<unknown>>;
|
|
8
9
|
validate(req: Request): Promise<{}>;
|
|
9
10
|
authenticate(req: Request, options?: any): any;
|
|
10
11
|
}, "als" | "authzProvider">>;
|
|
11
|
-
export declare const createRefreshStrategy: ([JWT_REFRESH_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]: [string, any, any]) =>
|
|
12
|
+
export declare const createRefreshStrategy: ([JWT_REFRESH_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]: [string, any, any]) => Type<Omit<{
|
|
12
13
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
13
14
|
readonly als: AsyncLocalStorage<JwtAlsType<unknown>>;
|
|
14
15
|
validate(req: Request): Promise<{}>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { type Type } from '@nestjs/common';
|
|
2
3
|
import type { NextFunction, Request, Response } from 'express';
|
|
3
4
|
import { type CookieOptionsWithSecret } from '../utils';
|
|
4
5
|
import type { SessionAuthzOptions } from './session-authz.interface';
|
|
@@ -11,7 +12,7 @@ export interface SessionAlsType<P, U> {
|
|
|
11
12
|
logOut: () => Promise<void>;
|
|
12
13
|
setCookie: (name: string, value: string, options?: CookieOptionsWithSecret) => void;
|
|
13
14
|
}
|
|
14
|
-
export declare const createSessionAuthzAlsMiddleware: ([ALS_PROVIDER, SESSION_AUTHZ_OPTIONS]: [any, any]) =>
|
|
15
|
+
export declare const createSessionAuthzAlsMiddleware: ([ALS_PROVIDER, SESSION_AUTHZ_OPTIONS]: [any, any]) => Type<Omit<{
|
|
15
16
|
readonly als: AsyncLocalStorage<SessionAlsType<unknown, unknown>>;
|
|
16
17
|
readonly sessionAuthzOptions: SessionAuthzOptions;
|
|
17
18
|
use(req: Request, res: Response, next: NextFunction): void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ExecutionContext } from '@nestjs/common';
|
|
1
|
+
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
5
|
import { type AuthzError } from '../errors';
|
|
6
6
|
import type { SessionAlsType } from './session-authz-als.middleware';
|
|
7
7
|
import type { SessionAuthzOptions } from './session-authz.interface';
|
|
8
|
-
export declare const createSessionAuthzGuard: ([SESSION_STRATEGY, AUTHZ_PROVIDER, SESSION_AUTHZ_OPTIONS, ALS_PROVIDER, SESSION_META_KEY]: [string, any, any, any, any]) =>
|
|
8
|
+
export declare const createSessionAuthzGuard: ([SESSION_STRATEGY, AUTHZ_PROVIDER, SESSION_AUTHZ_OPTIONS, ALS_PROVIDER, SESSION_META_KEY]: [string, any, any, any, any]) => Type<Omit<{
|
|
9
9
|
readonly reflector: Reflector;
|
|
10
10
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
11
11
|
readonly sessionAuthzOptions: SessionAuthzOptions;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import { DynamicModule, MiddlewareConsumer, type Type } from '@nestjs/common';
|
|
2
|
+
import { type ConfigurableModuleAsyncOptions, DynamicModule, type ExecutionContext, MiddlewareConsumer, type Type } from '@nestjs/common';
|
|
3
|
+
import type { Reflector } from '@nestjs/core';
|
|
3
4
|
import { AuthzProviderClass } from '../authz.provider';
|
|
4
5
|
import { AuthzError } from '../errors';
|
|
5
|
-
import { type AbstractConstructor, type AuthzModuleRoutesOptions, type RoutesOptions } from '../utils';
|
|
6
|
+
import { type AbstractConstructor, type ApplyDecorators, type AuthzDecoParams, type AuthzModuleBaseOptions, type AuthzModuleRoutesOptions, type CookieOptionsWithSecret, type DeepReadonly, type MethodParameters, type RoutesOptions } from '../utils';
|
|
6
7
|
import { type SessionAlsType } from './session-authz-als.middleware';
|
|
7
|
-
import { type SessionAuthzModuleOptions, type SessionAuthzOptions } from './session-authz.interface';
|
|
8
|
-
declare const ASYNC_OPTIONS_TYPE:
|
|
8
|
+
import { type SessionAuthzModuleOptions, type SessionAuthzOptions, type SessionOptions } from './session-authz.interface';
|
|
9
|
+
declare const ASYNC_OPTIONS_TYPE: ConfigurableModuleAsyncOptions<SessionAuthzModuleOptions, "createSessionAuthzModuleOptions"> & Partial<{
|
|
9
10
|
authzProvider?: Type<AuthzProviderClass<unknown, unknown>>;
|
|
10
|
-
} & AuthzModuleRoutesOptions>, OPTIONS_TYPE: Partial<
|
|
11
|
-
session:
|
|
11
|
+
} & AuthzModuleRoutesOptions>, OPTIONS_TYPE: Partial<AuthzModuleBaseOptions> & {
|
|
12
|
+
session: SessionOptions & {
|
|
12
13
|
keepSessionInfo?: boolean;
|
|
13
14
|
};
|
|
14
15
|
} & Partial<{
|
|
@@ -90,7 +91,7 @@ export declare const cereateSessionAuthzModule: <P, U, T extends AuthzProviderCl
|
|
|
90
91
|
* ```
|
|
91
92
|
*/
|
|
92
93
|
AuthzGuard: Type<Omit<{
|
|
93
|
-
readonly reflector:
|
|
94
|
+
readonly reflector: Reflector;
|
|
94
95
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
95
96
|
readonly sessionAuthzOptions: SessionAuthzOptions;
|
|
96
97
|
readonly als: AsyncLocalStorage<SessionAlsType<unknown, unknown>>;
|
|
@@ -99,11 +100,11 @@ export declare const cereateSessionAuthzModule: <P, U, T extends AuthzProviderCl
|
|
|
99
100
|
session: boolean;
|
|
100
101
|
};
|
|
101
102
|
handleRequest<T_1>(_err: unknown, user: T_1, info?: AuthzError): T_1;
|
|
102
|
-
canActivate(context:
|
|
103
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
103
104
|
logIn<TRequest extends {
|
|
104
105
|
logIn: Function;
|
|
105
106
|
} = any>(request: TRequest): Promise<void>;
|
|
106
|
-
getRequest(context:
|
|
107
|
+
getRequest(context: ExecutionContext): any;
|
|
107
108
|
}, "als" | "reflector" | "authzProvider" | "sessionAuthzOptions">> & {
|
|
108
109
|
/**
|
|
109
110
|
* Verifies the user's authorization for specific meta data.
|
|
@@ -122,7 +123,7 @@ export declare const cereateSessionAuthzModule: <P, U, T extends AuthzProviderCl
|
|
|
122
123
|
* }
|
|
123
124
|
* ```
|
|
124
125
|
*/
|
|
125
|
-
Verify: (...args:
|
|
126
|
+
Verify: (...args: AuthzDecoParams<MethodParameters<T, "authorize">[1]>) => ApplyDecorators;
|
|
126
127
|
/**
|
|
127
128
|
* Skips authentication & authorization checks for specific routes.
|
|
128
129
|
*
|
|
@@ -157,7 +158,7 @@ export declare const cereateSessionAuthzModule: <P, U, T extends AuthzProviderCl
|
|
|
157
158
|
* }
|
|
158
159
|
* ```
|
|
159
160
|
*/
|
|
160
|
-
Apply: (...rest: Parameters<(...args:
|
|
161
|
+
Apply: (...rest: Parameters<(...args: AuthzDecoParams<MethodParameters<T, "authorize">[1]>) => ApplyDecorators>) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
161
162
|
};
|
|
162
163
|
/**
|
|
163
164
|
* A custom servcie to provide methods to handle authentication and authorization.
|
|
@@ -167,8 +168,8 @@ export declare const cereateSessionAuthzModule: <P, U, T extends AuthzProviderCl
|
|
|
167
168
|
readonly als: AsyncLocalStorage<SessionAlsType<P, U>>;
|
|
168
169
|
logIn(user: U): Promise<void>;
|
|
169
170
|
logOut(): Promise<void>;
|
|
170
|
-
setCookie(name: string, value: string, options?:
|
|
171
|
-
getUser():
|
|
171
|
+
setCookie(name: string, value: string, options?: CookieOptionsWithSecret | undefined): void;
|
|
172
|
+
getUser(): DeepReadonly<U> | undefined;
|
|
172
173
|
}, "als" | "authzProvider">>;
|
|
173
174
|
};
|
|
174
175
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { type Type } from '@nestjs/common';
|
|
2
3
|
import { AuthzProviderClass } from '../authz.provider';
|
|
3
|
-
import { type DeepReadonly } from '../utils';
|
|
4
|
+
import { type CookieOptionsWithSecret, type DeepReadonly } from '../utils';
|
|
4
5
|
import type { SessionAlsType } from './session-authz-als.middleware';
|
|
5
|
-
export declare const createSessionAuthzService: <P = unknown, U = unknown>([AUTHZ_PROVIDER, ALS_PROVIDER]: [any, any]) =>
|
|
6
|
+
export declare const createSessionAuthzService: <P = unknown, U = unknown>([AUTHZ_PROVIDER, ALS_PROVIDER]: [any, any]) => Type<Omit<{
|
|
6
7
|
readonly authzProvider: AuthzProviderClass<P, U>;
|
|
7
8
|
readonly als: AsyncLocalStorage<SessionAlsType<P, U>>;
|
|
8
9
|
/**
|
|
@@ -18,7 +19,7 @@ export declare const createSessionAuthzService: <P = unknown, U = unknown>([AUTH
|
|
|
18
19
|
/**
|
|
19
20
|
* Sets a secure HTTP cookie with the given name, value, and optional cookie options.
|
|
20
21
|
*/
|
|
21
|
-
setCookie(name: string, value: string, options?:
|
|
22
|
+
setCookie(name: string, value: string, options?: CookieOptionsWithSecret | undefined): void;
|
|
22
23
|
/**
|
|
23
24
|
* Retrieves the current user associated with the request, if available.
|
|
24
25
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { type Type } from '@nestjs/common';
|
|
2
3
|
import type { Request } from 'express';
|
|
3
4
|
import { AuthzProviderClass } from '../authz.provider';
|
|
4
5
|
import type { SessionAlsType } from './session-authz-als.middleware';
|
|
5
|
-
export declare const createSessionAuthzStrategy: ([SESSION_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]: [string, any, any]) =>
|
|
6
|
+
export declare const createSessionAuthzStrategy: ([SESSION_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]: [string, any, any]) => Type<Omit<{
|
|
6
7
|
readonly authzProvider: AuthzProviderClass<unknown, unknown>;
|
|
7
8
|
readonly als: AsyncLocalStorage<SessionAlsType<unknown, unknown>>;
|
|
8
9
|
validate(req: Request): Promise<{}>;
|
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": "2.0.
|
|
5
|
+
"version": "2.0.7",
|
|
6
6
|
"homepage": "https://github.com/yikenman/nestjs-kitchen",
|
|
7
7
|
"repository": "https://github.com/yikenman/nestjs-kitchen",
|
|
8
8
|
"author": "yikenman",
|