nest-access-control 2.0.4 → 2.1.1
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/decorators/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* You can pass an optional property key to the decorator to get it from the user object
|
|
5
5
|
* e.g `@UserRoles('permissions')` will return the `req.user.permissions` instead.
|
|
6
|
+
* In case that the request is missing User object the function will return null
|
|
6
7
|
*/
|
|
7
8
|
export declare const UserRoles: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
@@ -17,7 +17,7 @@ function userFactory(ctx) {
|
|
|
17
17
|
// do something that is only important in the context of Websockets requests
|
|
18
18
|
throw new Error('Websockets context is not implemented yet');
|
|
19
19
|
}
|
|
20
|
-
else if (
|
|
20
|
+
else if (contextType === 'graphql') {
|
|
21
21
|
// inline require here, since we don't want to require the graphql module in the pacakge.
|
|
22
22
|
const { GqlExecutionContext } = require('@nestjs/graphql');
|
|
23
23
|
// do something that is only important in the context of GraphQL requests
|
|
@@ -31,8 +31,11 @@ function userFactory(ctx) {
|
|
|
31
31
|
*
|
|
32
32
|
* You can pass an optional property key to the decorator to get it from the user object
|
|
33
33
|
* e.g `@UserRoles('permissions')` will return the `req.user.permissions` instead.
|
|
34
|
+
* In case that the request is missing User object the function will return null
|
|
34
35
|
*/
|
|
35
|
-
exports.UserRoles = (0, common_1.createParamDecorator)((
|
|
36
|
+
exports.UserRoles = (0, common_1.createParamDecorator)((propertyKey, ctx) => {
|
|
36
37
|
const user = userFactory(ctx);
|
|
37
|
-
|
|
38
|
+
if (!user)
|
|
39
|
+
return null;
|
|
40
|
+
return propertyKey ? user[propertyKey] : user.roles;
|
|
38
41
|
});
|
package/index.js
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
*-------------------------------------------------------------*/
|
|
7
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
8
|
if (k2 === undefined) k2 = k;
|
|
9
|
-
Object.
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
10
14
|
}) : (function(o, m, k, k2) {
|
|
11
15
|
if (k2 === undefined) k2 = k;
|
|
12
16
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nest-access-control",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Access Control Module For Nestjs Framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,19 +29,19 @@
|
|
|
29
29
|
"@nestjs/common": "^7.6.18",
|
|
30
30
|
"@nestjs/core": "^7.6.18",
|
|
31
31
|
"@nestjs/testing": "^7.6.18",
|
|
32
|
-
"@types/jest": "^27.
|
|
32
|
+
"@types/jest": "^27.4.1",
|
|
33
33
|
"@types/node": "^10.1.2",
|
|
34
34
|
"coveralls": "^3.0.1",
|
|
35
35
|
"gulp": "^4.0.0",
|
|
36
36
|
"gulp-sequence": "^1.0.0",
|
|
37
37
|
"gulp-typescript": "^5.0.1",
|
|
38
|
-
"jest": "^27.
|
|
39
|
-
"node-notifier": "^10.0.
|
|
38
|
+
"jest": "^27.5.1",
|
|
39
|
+
"node-notifier": "^10.0.1",
|
|
40
40
|
"reflect-metadata": "^0.1.12",
|
|
41
41
|
"rxjs": "^6.0.0",
|
|
42
|
-
"ts-jest": "^27.1.
|
|
43
|
-
"ts-node": "^10.
|
|
44
|
-
"typescript": "^4.
|
|
42
|
+
"ts-jest": "^27.1.3",
|
|
43
|
+
"ts-node": "^10.6.0",
|
|
44
|
+
"typescript": "^4.6.2"
|
|
45
45
|
},
|
|
46
46
|
"bugs": {
|
|
47
47
|
"url": "https://github.com/nestjsx/nest-access-control/issues"
|
|
@@ -51,10 +51,11 @@
|
|
|
51
51
|
"accesscontrol": "^2.2.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"graphql":
|
|
58
|
-
|
|
54
|
+
"@nestjs/graphql": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@nestjs/graphql": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
59
60
|
}
|
|
60
61
|
}
|