@slynova/fence
Advanced tools
Comparing version 1.0.0-alpha to 1.0.0-alpha-1
{ | ||
"name": "@slynova/fence", | ||
"version": "1.0.0-alpha", | ||
"version": "1.0.0-alpha-1", | ||
"description": "Flexible and Fluent way to manage ACL in Node.js.", | ||
@@ -18,3 +18,3 @@ "keywords": [ | ||
"scripts": { | ||
"test": "node --harmony-async-await tests/test.js", | ||
"test": "node tests/test.js", | ||
"test:coverage": "./node_modules/.bin/istanbul cover -x tests/test.js tests/test.js && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage" | ||
@@ -30,11 +30,10 @@ }, | ||
"devDependencies": { | ||
"co": "^4.6.0", | ||
"coveralls": "^2.12.0", | ||
"coveralls": "^2.13.1", | ||
"istanbul": "^0.4.5", | ||
"japa": "^1.0.1", | ||
"japa": "^1.0.3", | ||
"require-all": "^2.2.0" | ||
}, | ||
"dependencies": { | ||
"node-exceptions": "^2.0.0" | ||
"node-exceptions": "^2.0.2" | ||
} | ||
} |
@@ -68,3 +68,3 @@ 'use strict' | ||
*/ | ||
* for (resource) { | ||
async for (resource) { | ||
const gate = Storage.retrieveGate(this.$gate) | ||
@@ -76,3 +76,3 @@ | ||
return yield gate(this.$user, resource) | ||
return gate(this.$user, resource) | ||
} | ||
@@ -88,3 +88,3 @@ | ||
*/ | ||
* callPolicy (ability, resource) { | ||
async callPolicy (ability, resource) { | ||
const resourceName = Helpers.formatResourceName(resource) | ||
@@ -97,3 +97,3 @@ const policy = Storage.retrievePolicy(resourceName) | ||
return yield policy[ability](this.$user, resource) | ||
return policy[ability](this.$user, resource) | ||
} | ||
@@ -100,0 +100,0 @@ |
@@ -48,9 +48,9 @@ 'use strict' | ||
*/ | ||
static * allows (ability, resource) { | ||
static async allows (ability, resource) { | ||
try { | ||
if (Guard.$correspondsToPolicy(resource)) { | ||
return yield (new Bouncer()).callPolicy(ability, resource) | ||
return await (new Bouncer()).callPolicy(ability, resource) | ||
} | ||
return yield (new Bouncer()).goThroughGate(ability).for(resource) | ||
return await (new Bouncer()).goThroughGate(ability).for(resource) | ||
} catch (e) { | ||
@@ -69,9 +69,9 @@ return false | ||
*/ | ||
static * denies (ability, resource) { | ||
static async denies (ability, resource) { | ||
try { | ||
if (Guard.$correspondsToPolicy(resource)) { | ||
return !(yield (new Bouncer()).callPolicy(ability, resource)) | ||
return !(await (new Bouncer()).callPolicy(ability, resource)) | ||
} | ||
return !(yield (new Bouncer()).goThroughGate(ability).for(resource)) | ||
return !(await (new Bouncer()).goThroughGate(ability).for(resource)) | ||
} catch (e) { | ||
@@ -78,0 +78,0 @@ return true |
'use strict' | ||
const co = require('co') | ||
class Helpers { | ||
@@ -6,0 +4,0 @@ |
@@ -12,4 +12,2 @@ 'use strict' | ||
module.exports = { | ||
Gate, Guard | ||
} | ||
module.exports = { Gate, Guard } |
4
11956
348
Updatednode-exceptions@^2.0.2