@zenofolio/hyper-decor 1.0.55 → 1.0.56
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FULL_ACCESS = exports.METADATA_STATE_KEYS = exports.METADATA_PARAMS_KEYS = exports.METADATA_METHOD_KEYS = exports.METADATA_STORE_KEYS = exports.METADATA_KEYS = exports.METADATA_HYPER_TYPE = exports.DESIGN_TYPE = exports.DESIGN_RETURNTYPE = exports.DESIGN_PARAMTYPES = exports.KEY_STATE_BY_PASS = exports.KEY_STATE_PREPARED = exports.KEY_STATE_CREATED = exports.KEY_STATE_UPDATED = exports.KEY_PARAMS_PASS = exports.KEY_PARAMS_ROLE = exports.KEY_PARAMS_SCOPE = exports.KEY_PARAMS_MIDDLEWARES = exports.KEY_PARAMS_PARAM = exports.KEY_PARAMS_ROUTE = exports.KEY_PARAMS_MODULE = exports.KEY_PARAMS_CONTROLLER = exports.KEY_PARAMS_APP = exports.KEY_TYPE_GUARD = exports.KEY_TYPE_SERVICE = exports.KEY_TYPE_ROUTE = exports.KEY_TYPE_MODULE = exports.KEY_TYPE_CONTROLLER = exports.KEY_TYPE_APP = void 0;
|
|
4
4
|
//////////////////////////////
|
|
5
5
|
/// Types constants
|
|
6
6
|
//////////////////////////////
|
|
@@ -71,4 +71,4 @@ exports.METADATA_STATE_KEYS = {
|
|
|
71
71
|
CREATED: "hyper:created",
|
|
72
72
|
PREPARED: "hyper:prepared",
|
|
73
73
|
};
|
|
74
|
-
exports.
|
|
74
|
+
exports.FULL_ACCESS = "*";
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = roleTransform;
|
|
4
4
|
const exeptions_1 = require("../../exeptions");
|
|
5
5
|
const helpers_1 = require("../../common/helpers");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
6
7
|
function roleTransform(list, callback) {
|
|
7
8
|
const { roles, names, isEmtpy } = resolveRoles(list);
|
|
8
9
|
const middleware = (req, res, next) => {
|
|
@@ -11,6 +12,8 @@ function roleTransform(list, callback) {
|
|
|
11
12
|
return next();
|
|
12
13
|
// get the user scopes
|
|
13
14
|
const requestRoles = (0, helpers_1.getRoles)(req);
|
|
15
|
+
if (requestRoles === null || requestRoles === void 0 ? void 0 : requestRoles.includes(constants_1.FULL_ACCESS))
|
|
16
|
+
return next();
|
|
14
17
|
// find the first scope that is not in the userScopes
|
|
15
18
|
const role = roles.find((scope) => requestRoles === null || requestRoles === void 0 ? void 0 : requestRoles.includes(scope.role));
|
|
16
19
|
if (role) {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = scopeTransfrom;
|
|
4
4
|
const exeptions_1 = require("../../exeptions");
|
|
5
5
|
const helpers_1 = require("../../common/helpers");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
6
7
|
function scopeTransfrom(listScopes, ...callback) {
|
|
7
8
|
const { scopes, scopeNames, isEmtpy } = resolveScopes(listScopes);
|
|
8
9
|
const middleware = (req, res, next) => {
|
|
@@ -13,7 +14,7 @@ function scopeTransfrom(listScopes, ...callback) {
|
|
|
13
14
|
// get the user scopes
|
|
14
15
|
const userScopes = (0, helpers_1.getScopes)(req);
|
|
15
16
|
// hek if has global scope
|
|
16
|
-
if (userScopes === null || userScopes === void 0 ? void 0 : userScopes.includes(
|
|
17
|
+
if (userScopes === null || userScopes === void 0 ? void 0 : userScopes.includes(constants_1.FULL_ACCESS))
|
|
17
18
|
return next();
|
|
18
19
|
// find the first scope that is not in the userScopes
|
|
19
20
|
const error = scopes.find((scope) => !(userScopes === null || userScopes === void 0 ? void 0 : userScopes.includes(scope.scope)));
|