@lifeomic/abac
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -6,4 +6,8 @@ 'use strict'; | ||
}); | ||
exports.privilegesSync = exports.privilegesLenient = exports.privileges = exports.enforceAny = exports.enforceSync = exports.enforceLenient = exports.enforce = exports.reduceSync = exports.reduce = exports.merge = exports.validate = undefined; | ||
exports.policyRequiresAttribute = exports.privilegesSync = exports.privilegesLenient = exports.privileges = exports.enforceAny = exports.enforceSync = exports.enforceLenient = exports.enforce = exports.reduceSync = exports.reduce = exports.merge = exports.validate = undefined; | ||
var _values = require('babel-runtime/core-js/object/values'); | ||
var _values2 = _interopRequireDefault(_values); | ||
var _keys = require('babel-runtime/core-js/object/keys'); | ||
@@ -339,2 +343,16 @@ | ||
/** | ||
* Synchronously determines if a given attribute path is in the list of rules | ||
* for a given policy. This may be useful for determining if additional metadata | ||
* should be fetched before enforcing a policy. | ||
* | ||
* @param {object} policy - the policy to check | ||
* @param {string} attribute - the attribute path, e.g. 'user.patients' | ||
* @returns {Boolean} True if the attribute is in the rules list | ||
*/ | ||
const policyRequiresAttribute = (policy, attribute) => { | ||
const rules = (0, _values2.default)(policy.rules).filter(rule => Array.isArray(rule)).reduce((left, right) => left.concat(right), []); | ||
return rules.some(rule => rule.hasOwnProperty(attribute)); | ||
}; | ||
exports.validate = validate; | ||
@@ -351,2 +369,3 @@ exports.merge = merge; | ||
exports.privilegesSync = privilegesSync; | ||
exports.policyRequiresAttribute = policyRequiresAttribute; | ||
//# sourceMappingURL=index.js.map |
'use strict'; | ||
import _Object$values from 'babel-runtime/core-js/object/values'; | ||
import _Object$keys from 'babel-runtime/core-js/object/keys'; | ||
@@ -463,6 +464,26 @@ import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray'; | ||
/** | ||
* Synchronously determines if a given attribute path is in the list of rules | ||
* for a given policy. This may be useful for determining if additional metadata | ||
* should be fetched before enforcing a policy. | ||
* | ||
* @param {object} policy - the policy to check | ||
* @param {string} attribute - the attribute path, e.g. 'user.patients' | ||
* @returns {Boolean} True if the attribute is in the rules list | ||
*/ | ||
var policyRequiresAttribute = function policyRequiresAttribute(policy, attribute) { | ||
var rules = _Object$values(policy.rules).filter(function (rule) { | ||
return Array.isArray(rule); | ||
}).reduce(function (left, right) { | ||
return left.concat(right); | ||
}, []); | ||
return rules.some(function (rule) { | ||
return rule.hasOwnProperty(attribute); | ||
}); | ||
}; | ||
export { validate, merge, reduce, reduceSync /* deprecated */ | ||
, enforce, enforceLenient, enforceSync /* deprecated */ | ||
, enforceAny, privileges, privilegesLenient, privilegesSync /* deprecated */ | ||
}; | ||
, policyRequiresAttribute }; | ||
//# sourceMappingURL=index.js.map |
'use strict'; | ||
import _Object$values from 'babel-runtime/core-js/object/values'; | ||
import _Object$keys from 'babel-runtime/core-js/object/keys'; | ||
@@ -317,6 +318,20 @@ import _Object$entries from 'babel-runtime/core-js/object/entries'; | ||
/** | ||
* Synchronously determines if a given attribute path is in the list of rules | ||
* for a given policy. This may be useful for determining if additional metadata | ||
* should be fetched before enforcing a policy. | ||
* | ||
* @param {object} policy - the policy to check | ||
* @param {string} attribute - the attribute path, e.g. 'user.patients' | ||
* @returns {Boolean} True if the attribute is in the rules list | ||
*/ | ||
const policyRequiresAttribute = (policy, attribute) => { | ||
const rules = _Object$values(policy.rules).filter(rule => Array.isArray(rule)).reduce((left, right) => left.concat(right), []); | ||
return rules.some(rule => rule.hasOwnProperty(attribute)); | ||
}; | ||
export { validate, merge, reduce, reduceSync /* deprecated */ | ||
, enforce, enforceLenient, enforceSync /* deprecated */ | ||
, enforceAny, privileges, privilegesLenient, privilegesSync /* deprecated */ | ||
}; | ||
, policyRequiresAttribute }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@lifeomic/abac", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Lifeomic Attribute Based Access Control Support Module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
129586
1709