@slynova/fence
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -0,1 +1,10 @@ | ||
<a name="1.0.4"></a> | ||
## 1.0.4 (2018-07-20) | ||
### Features | ||
* export Helpers to let us overwrite formatResourceName ([79ab280](https://github.com/Slynova-Org/fence/commit/79ab280)) | ||
<a name="1.0.3"></a> | ||
@@ -2,0 +11,0 @@ ## 1.0.3 (2018-07-19) |
@@ -20,3 +20,3 @@ "use strict"; | ||
static define(name, callback) { | ||
storage.storeGate(name, callback); | ||
Gate.$getStorage().storeGate(name, callback); | ||
} | ||
@@ -30,3 +30,3 @@ /** | ||
static policy(resource, policy) { | ||
const resourceName = Gate.$formatResourceName(resource); | ||
const resourceName = Helpers_1.formatResourceName(resource); | ||
if (typeof policy === 'function') { | ||
@@ -36,13 +36,13 @@ // @ts-ignore | ||
} | ||
storage.storePolicy(resourceName, policy); | ||
Gate.$getStorage().storePolicy(resourceName, policy); | ||
} | ||
/** | ||
* Returns the name of a resource. | ||
* Returns the storage. | ||
* | ||
* @param resource Resource to search the name for | ||
* @return Storage used | ||
*/ | ||
static $formatResourceName(resource) { | ||
return Helpers_1.formatResourceName(resource); | ||
static $getStorage() { | ||
return storage; | ||
} | ||
} | ||
exports.Gate = Gate; |
@@ -13,1 +13,3 @@ "use strict"; | ||
exports.Guard = Guard_1.Guard; | ||
const Helpers = require("./Helpers"); | ||
exports.Helpers = Helpers; |
{ | ||
"name": "@slynova/fence", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Flexible and Fluent way to manage ACL in Node.js.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -78,13 +78,11 @@ <p align="center"> | ||
### Testing a Gate | ||
### Public API | ||
You can test your gate with a short or a long syntax. | ||
```js | ||
// Long | ||
await Guard.can(user).goThroughGate('XXX').for(resource) // true or false | ||
// Short - will need to have an instance of Guard with the specific user | ||
await guard.allows('XXX', resource) // true or false | ||
await guard.denies('XXX', resource) // true or false | ||
guard.allows('gateName/Policy Method', resource) // It will use per default the defined user or return false if not defined | ||
guard.denies('gateName/Policy Method', resource) // It will use per default the defined user or return true if not defined | ||
guard.allows('gateName/Policy Method', resource, user) | ||
guard.denies('gateName/Policy Method', resource, user) | ||
guard.can(user).pass('gateName').for(resource) | ||
guard.can(user).callPolicy('Policy Method', resource) | ||
``` | ||
@@ -91,0 +89,0 @@ |
@@ -24,8 +24,8 @@ /** | ||
/** | ||
* Returns the name of a resource. | ||
* Returns the storage. | ||
* | ||
* @param resource Resource to search the name for | ||
* @return Storage used | ||
*/ | ||
private static $formatResourceName; | ||
private static $getStorage; | ||
} | ||
export { Gate }; |
@@ -9,2 +9,3 @@ /** | ||
import { Guard } from './Guard'; | ||
export { Gate, Guard }; | ||
import * as Helpers from './Helpers'; | ||
export { Gate, Guard, Helpers }; |
23892
571
95