@nestjs-kitchen/authz 2.0.4 → 2.0.6
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/authz.provider.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
1
2
|
/**
|
|
2
3
|
* Abstract base class for implementing custom authorization logic.
|
|
3
4
|
*
|
|
@@ -25,7 +26,7 @@ export declare abstract class AuthzProviderClass<Payload, User> {
|
|
|
25
26
|
* @param {Payload} payload - The payload to authenticate.
|
|
26
27
|
* @returns {User | Promise<User>} The authenticated user, or a promise resolving to the user.
|
|
27
28
|
*/
|
|
28
|
-
abstract authenticate(payload: Payload): User | Promise<User>;
|
|
29
|
+
abstract authenticate(payload: Payload, req?: Request): User | Promise<User>;
|
|
29
30
|
/**
|
|
30
31
|
* (**Optional**: Implement this method only if authorization is required.)
|
|
31
32
|
*
|
|
@@ -44,10 +44,10 @@ const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, ASYNC_OPTIONS_TYPE, OPTIO
|
|
|
44
44
|
if (!global && !routes.length) {
|
|
45
45
|
throw new errors_1.AuthzError(`InternalError: Missing parameter 'global' or 'routes' in configuration.`);
|
|
46
46
|
}
|
|
47
|
-
if (store.globalInited) {
|
|
48
|
-
throw new errors_1.AuthzError(`InternalError: Cannot initialize mutiple global modules. Only one global module is allowed.`);
|
|
49
|
-
}
|
|
50
47
|
if (global) {
|
|
48
|
+
if (store.globalInited) {
|
|
49
|
+
throw new errors_1.AuthzError(`InternalError: Cannot initialize mutiple global modules. Only one global module is allowed.`);
|
|
50
|
+
}
|
|
51
51
|
store.globalInited += 1;
|
|
52
52
|
}
|
|
53
53
|
return (0, utils_1.mergeDynamicModuleConfigs)(definition, {
|
|
@@ -51,7 +51,7 @@ const createJwtStrategy = ([JWT_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]) => {
|
|
|
51
51
|
let user = undefined;
|
|
52
52
|
try {
|
|
53
53
|
const payload = jsonwebtoken_1.default.verify(token, authOptions.jwt.secretOrPublicKey, authOptions.jwt.verify);
|
|
54
|
-
user = await this.authzProvider.authenticate(payload);
|
|
54
|
+
user = await this.authzProvider.authenticate(payload, req);
|
|
55
55
|
}
|
|
56
56
|
catch (error) {
|
|
57
57
|
return [
|
|
@@ -104,7 +104,7 @@ const createRefreshStrategy = ([JWT_REFRESH_STRATEGY, AUTHZ_PROVIDER, ALS_PROVID
|
|
|
104
104
|
try {
|
|
105
105
|
const payload = jsonwebtoken_1.default.verify(token, authOptions.refresh.secretOrPublicKey, authOptions.refresh.verify);
|
|
106
106
|
const decodePayload = (0, utils_1.decodeMsgpackrString)(payload.data);
|
|
107
|
-
user = await this.authzProvider.authenticate(decodePayload);
|
|
107
|
+
user = await this.authzProvider.authenticate(decodePayload, req);
|
|
108
108
|
}
|
|
109
109
|
catch (error) {
|
|
110
110
|
return [
|
|
@@ -48,10 +48,10 @@ const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, ASYNC_OPTIONS_TYPE, OPTIO
|
|
|
48
48
|
if (!global && !routes.length) {
|
|
49
49
|
throw new errors_1.AuthzError(`InternalError: Missing parameter 'global' or 'routes' in configuration.`);
|
|
50
50
|
}
|
|
51
|
-
if (store.globalInited) {
|
|
52
|
-
throw new errors_1.AuthzError(`InternalError: Cannot initialize mutiple global modules. Only one global module is allowed.`);
|
|
53
|
-
}
|
|
54
51
|
if (global) {
|
|
52
|
+
if (store.globalInited) {
|
|
53
|
+
throw new errors_1.AuthzError(`InternalError: Cannot initialize mutiple global modules. Only one global module is allowed.`);
|
|
54
|
+
}
|
|
55
55
|
store.globalInited += 1;
|
|
56
56
|
}
|
|
57
57
|
return (0, utils_1.mergeDynamicModuleConfigs)(definition, {
|
|
@@ -42,7 +42,7 @@ const createSessionAuthzStrategy = ([SESSION_STRATEGY, AUTHZ_PROVIDER, ALS_PROVI
|
|
|
42
42
|
}
|
|
43
43
|
let user = undefined;
|
|
44
44
|
try {
|
|
45
|
-
user = await this.authzProvider.authenticate(payload);
|
|
45
|
+
user = await this.authzProvider.authenticate(payload, req);
|
|
46
46
|
}
|
|
47
47
|
catch (error) {
|
|
48
48
|
return [
|
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.6",
|
|
6
6
|
"homepage": "https://github.com/yikenman/nestjs-kitchen",
|
|
7
7
|
"repository": "https://github.com/yikenman/nestjs-kitchen",
|
|
8
8
|
"author": "yikenman",
|