@aserto/aserto-spa-js
Advanced tools
Comparing version 0.1.24 to 0.1.25
@@ -43,8 +43,2 @@ "use strict"; | ||
this.defaultMap = options && options.defaultMap || { | ||
visible: true, | ||
enabled: true, | ||
allowed: false | ||
}; | ||
if (!options || !options.accessToken) { | ||
@@ -123,8 +117,10 @@ throw new Error('AsertoClient: must provide access token'); | ||
key: "resourceMap", | ||
value: function resourceMap(path) { | ||
var map = this.__accessMap[path] && this.__accessMap[path].verb || {}; | ||
map.GET = map.GET || this.defaultMap; | ||
map.PUT = map.PUT || this.defaultMap; | ||
map.DELETE = map.DELETE || this.defaultMap; | ||
map.POST = map.POST || this.defaultMap; | ||
value: function resourceMap(method, path) { | ||
var key = path ? "".concat(method).concat(path) : method; | ||
var map = this.__accessMap[key]; | ||
if (!map) { | ||
throw new Error("AsertoClient: access map does not contain the key ".concat(key)); | ||
} | ||
return map; | ||
@@ -138,2 +134,2 @@ } | ||
exports["default"] = AsertoClient; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9Bc2VydG9DbGllbnQuanMiXSwibmFtZXMiOlsiVklTSUJMRSIsIkVOQUJMRUQiLCJBTExPV0VEIiwiQXNlcnRvQ2xpZW50Iiwib3B0aW9ucyIsImRlZmF1bHRNYXAiLCJ2aXNpYmxlIiwiZW5hYmxlZCIsImFsbG93ZWQiLCJhY2Nlc3NUb2tlbiIsIkVycm9yIiwidG9rZW4iLCJlbmRwb2ludCIsImFjY2Vzc01hcEVuZHBvaW50Iiwic2VydmljZSIsInNlcnZpY2VVcmwiLCJVUkwiLCJ3aW5kb3ciLCJsb2NhdGlvbiIsIm9yaWdpbiIsImhlYWRlcnMiLCJyZXNwb25zZSIsImVycm9yIiwibWVzc2FnZSIsImpzb24iLCJtYXAiLCJfX2FjY2Vzc01hcCIsInBhdGgiLCJ2ZXJiIiwiR0VUIiwiUFVUIiwiREVMRVRFIiwiUE9TVCJdLCJtYXBw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9yO1xuICAgIHRyeSB7XG4gICAgICBbcmVzcG9uc2UsIGVycm9yXSA9IGF3YWl0IGdldCh0aGlzLnNlcnZpY2UsIHRoaXMudG9rZW4sIHRoaXMuZW5kcG9pbnQsIGhlYWRlcnMpO1xuICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgdGhyb3cgZXJyO1xuICAgIH1cbiAgICBpZiAoZXJyb3IpIHtcbiAgICAgIHRocm93IG5ldyBFcnJvcihgQXNlcnRvQ2xpZW50OiAke2Vycm9yLm1lc3NhZ2UgfHwgZXJyb3J9YCk7XG4gICAgfSBlbHNlIHtcbiAgICAgIGNvbnN0IG1hcCA9IGF3YWl0IHJlc3BvbnNlLmpzb24oKTtcbiAgICAgIHRoaXMuX19hY2Nlc3NNYXAgPSBtYXA7XG4gICAgfSAgXG4gIH1cblxuICBhY2Nlc3NNYXAoKSB7XG4gICAgcmV0dXJuIHRoaXMuX19hY2Nlc3NNYXA7XG4gIH1cblxuICByZXNvdXJjZU1hcChtZXRob2QsIHBhdGgpIHtcbiAgICBjb25zdCBrZXkgPSBwYXRoID8gYCR7bWV0aG9kfSR7cGF0aH1gIDogbWV0aG9kO1xuICAgIGNvbnN0IG1hcCA9IHRoaXMuX19hY2Nlc3NNYXBba2V5XTtcbiAgICBpZiAoIW1hcCkge1xuICAgICAgdGhyb3cgbmV3IEVycm9yKGBBc2VydG9DbGllbnQ6IGFjY2VzcyBtYXAgZG9lcyBub3QgY29udGFpbiB0aGUga2V5ICR7a2V5fWApO1xuICAgIH1cbiAgICByZXR1cm4gbWFwO1xuICB9XG59XG4iXX0= |
{ | ||
"name": "@aserto/aserto-spa-js", | ||
"version": "0.1.24", | ||
"version": "0.1.25", | ||
"description": "Aserto single-page application javascript SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -50,8 +50,3 @@ # Aserto single-page application javascript SDK | ||
serviceUrl: 'https://service-url', // defaults to window.location.origin | ||
endpoint: '/__accessmap', // access map endpoint, defaults to /__accessmap | ||
defaultMap: { // pass a default map for endpoints that don't expose a map | ||
visible: true, // visible defaults to true | ||
enabled: true, // enabled defaults to true | ||
allowed: false // allowed defaults to false | ||
} | ||
endpoint: '/__accessmap' // access map endpoint, defaults to /__accessmap | ||
}); | ||
@@ -82,27 +77,15 @@ | ||
### resourceMap('path') | ||
### resourceMap('method, 'path') | ||
Retrieves a map associated with a specific resource. | ||
The `path` argument is in the form `/path/to/resource`. It may contain a `__id` component to indicate an parameter - for example, `/mycars/__id`. | ||
By convention, the `method` argument is an HTTP method (GET, POST, PUT, DELETE), and the `path` argument is in the form `/path/to/resource`. It may contain a `__id` component to indicate an parameter - for example, `/mycars/__id`. | ||
If only the `method` argument is passed in, it is assumed to be a key into the `accessmap` (typically in the form of `METHOD/path/to/resource`). | ||
The returned map will be in the following format: | ||
```js | ||
{ | ||
GET: { | ||
visible: true, | ||
enabled: false, | ||
allowed: false | ||
}, | ||
POST: { | ||
visible: true, | ||
enabled: false, | ||
allowed: false | ||
}, | ||
PUT: { | ||
//... | ||
}, | ||
DELETE: { | ||
//... | ||
} | ||
visible: true, | ||
enabled: false, | ||
} | ||
@@ -113,6 +96,7 @@ ``` | ||
```js | ||
const method = 'GET'; | ||
const path = '/api/path'; | ||
const resource = aserto.resourceMap(path)); | ||
const isVisible = resource.GET.visible; | ||
const isEnabled = resource.GET.enabled; | ||
const resource = aserto.resourceMap(method, path)); | ||
const isVisible = resource.visible; | ||
const isEnabled = resource.enabled; | ||
``` | ||
@@ -123,5 +107,5 @@ | ||
const path = '/api/path'; | ||
const resource = aserto.resourceMap(path)); | ||
for (const verb of ['GET', 'POST', 'PUT', 'DELETE']) { | ||
for (const access of ['visible', 'enabled', 'allowed']) { | ||
const resource = aserto.resourceMap(verb, path)); | ||
for (const access of ['visible', 'enabled']) { | ||
console.log(`${verb} ${path} ${access} is ${resource[verb][access]}`); | ||
@@ -128,0 +112,0 @@ } |
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
25485
267
112