
Research
/Security News
npm Author Qix Compromised in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
simple-permissions
Advanced tools
Trivial permissions implementation - takes an array and stores permissions from multiple targets for sources. 100% tested.
Trivial permissions implementation with following features
Dependencies
License
bower install simple-permissions
npm install simple-permissions
To launch tests you have to run npm install
then npm test
.
If you want to contribute make sure to run grunt githooks
first thing after clone.
It will create pre-commit hook and run tests and jshint before you commit.
Please use git flow - create a feature branch for your feature and send a pull request to dev.
Please don't include dist folder in your commit.
/**
* @typedef {{target: String, source: String, permissions: Array}} SimplePermissions
*/
/**
* Create/append permissions in a storage
* @param {SimplePermissions[]} storage
* @param {String|Array} to
* @param {Object} permissionsMap
*/
function grant(storage, to, permissionsMap) {}
/**
* Reduce/Remove permissions in a storage
* @param {SimplePermissions[]} storage
* @param {String|Array} from
* @param {Object} permissionsMap
*/
function revoke(storage, from, permissionsMap) {}
//one to many
var app = (function () {
var permissions = [];
return {
permissions: permissions,
grant: _.partial(grant, permissions, 'App'),
revoke: _.partial(revoke, permissions, 'App')
};
})();
app.grant({Admin: ['Read', 'Write', 'Email', 'Users'], User: ['Write', 'Read']});
console.log(_.map(app.permissions, function (entry) {
return entry.source + ' - ' + entry.permissions.join(',')
}));
//["Admin - Read,Write,Email,Users", "User - Write,Read"]
app.revoke({User: ['Write']});
console.log(_.map(app.permissions, function (entry) {
return entry.source + ' - ' + entry.permissions.join(',')
}));
//["Admin - Read,Write,Email,Users", "User - Read"]
//starting code
var Foo = {
name: 'Foo',
storage: []
},
s = Foo.storage;
///////////////////
// grant example //
///////////////////
//basic case
var str = 'whatever';
grant(s, Foo.name, {Bar: [str]});
var entry = _(s).find({target: Foo.name, source: 'Bar'});
//s.length === 1;
//entry.permissions[0] === str;
//works with multiple targets
var str = 'whatever';
grant(s, ['Bar', 'Baz', 'Qux'], {Foo: [str]});
var results = [
_(s).find({target: 'Bar', source: Foo.name}),
_(s).find({target: 'Baz', source: Foo.name}),
_(s).find({target: 'Qux', source: Foo.name})
];
//s.length === 4;
//_.each(results, function (result) {
// result.permissions[0] === str;
//});
//works with multiple permission rules
var str1 = 'anything';
var str2 = 'something else';
grant(s, 'Bar', {Foo: [str1], Baz: [str2]});
var result1 = _(s).find({target: 'Bar', source: Foo.name});
var result2 = _(s).find({target: 'Bar', source: 'Baz'});
//s.length === 5;
//result1.permissions[1] === str1;
//result2.permissions[0] === str2;
////////////////////
// revoke example //
////////////////////
//basic case
revoke(s, 'Foo', {Bar: ['whatever']});
//s.length === 4;
//_(s).find({target: Foo.name, source: 'Bar'}) === undefined;
//works with multiple permission rules
revoke(s, 'Bar', {Foo: ['anything'], Baz: ['something else']});
//s.length === 3
//_(s).find({target: 'Bar', source: Foo.name}).permissions[0] === 'whatever';
//_(s).find({target: 'Bar', source: 'Baz'}) === undefined;
// works with multiple targets
revoke(s, ['Bar', 'Baz', 'Qux'], {Foo: ['whatever']});
//s.length === 0
FAQs
Trivial permissions implementation - takes an array and stores permissions from multiple targets for sources. 100% tested.
The npm package simple-permissions receives a total of 1 weekly downloads. As such, simple-permissions popularity was classified as not popular.
We found that simple-permissions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.