@lifeomic/abac
Advanced tools
Comparing version 1.2.2 to 1.3.0
@@ -347,2 +347,48 @@ 'use strict'; | ||
/** | ||
* Check whether the given policy allows one of a list of operations | ||
* with the given attributes. | ||
* @param {string[]} operations - the requested operations | ||
* @param {object} policy - the policy to use to check access | ||
* @param {object} attributes - the attributes to use to check access | ||
* @returns {boolean|string} - the first allowed operation or false | ||
* @throws {Error} Error if the policy is invalid | ||
*/ | ||
const enforceAny = (() => { | ||
var _ref5 = (0, _asyncToGenerator3.default)(function* (operations, policy, attributes) { | ||
var _iteratorNormalCompletion5 = true; | ||
var _didIteratorError5 = false; | ||
var _iteratorError5 = undefined; | ||
try { | ||
for (var _iterator5 = (0, _getIterator3.default)(operations), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { | ||
const operation = _step5.value; | ||
if (yield enforce(operation, policy, attributes)) { | ||
return operation; | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError5 = true; | ||
_iteratorError5 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion5 && _iterator5.return) { | ||
_iterator5.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError5) { | ||
throw _iteratorError5; | ||
} | ||
} | ||
} | ||
return false; | ||
}); | ||
return function enforceAny(_x6, _x7, _x8) { | ||
return _ref5.apply(this, arguments); | ||
}; | ||
})(); | ||
module.exports = { | ||
@@ -353,3 +399,4 @@ validate, | ||
enforce, | ||
enforceSync | ||
enforceSync, | ||
enforceAny | ||
}; |
{ | ||
"name": "@lifeomic/abac", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "Lifeomic Attribute Based Access Control Support Module", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231969
459