@aserto/aserto-spa-js
Advanced tools
Comparing version 0.1.25 to 0.1.26
@@ -48,3 +48,3 @@ "use strict"; | ||
this.token = options.accessToken; | ||
this.endpoint = options.accessMapEndpoint || '/__accessmap'; | ||
this.endpoint = options.displayStateMapEndpoint || '/__displaystatemap'; | ||
this.service = options.serviceUrl || new URL(window.location.origin); | ||
@@ -94,3 +94,3 @@ } | ||
map = _context.sent; | ||
this.__accessMap = map; | ||
this.__displayStateMap = map; | ||
@@ -112,11 +112,11 @@ case 20: | ||
}, { | ||
key: "accessMap", | ||
value: function accessMap() { | ||
return this.__accessMap; | ||
key: "displayStateMap", | ||
value: function displayStateMap() { | ||
return this.__displayStateMap; | ||
} | ||
}, { | ||
key: "resourceMap", | ||
value: function resourceMap(method, path) { | ||
key: "getDisplayState", | ||
value: function getDisplayState(method, path) { | ||
var key = path ? "".concat(method).concat(path) : method; | ||
var map = this.__accessMap[key]; | ||
var map = this.__displayStateMap[key]; | ||
@@ -135,2 +135,2 @@ if (!map) { | ||
exports["default"] = AsertoClient; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9Bc2VydG9DbGllbnQuanMiXSwibmFtZXMiOlsiVklTSUJMRSIsIkVOQUJMRUQiLCJBTExPV0VEIiwiQXNlcnRvQ2xpZW50Iiwib3B0aW9ucyIsImFjY2Vzc1Rva2VuIiwiRXJyb3IiLCJ0b2tlbiIsImVuZHBvaW50IiwiYWNjZXNzTWFwRW5kcG9pbnQiLCJzZXJ2aWNlIiwic2VydmljZVVybCIsIlVSTCIsIndpbmRvdyIsImxvY2F0aW9uIiwib3JpZ2luIiwiaGVhZGVycyIsInJlc3BvbnNlIiwiZXJyb3IiLCJtZXNzYWdlIiwianNvbiIsIm1hcCIsIl9fYWNjZXNzTWFwIiwibWV0aG9kIiwicGF0aCIsImtleSJdLCJtYXBwaW5ncyI6Ijs7Ozs7OztBQUFBOzs7Ozs7Ozs7Oz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GVNYXBba2V5XTtcbiAgICBpZiAoIW1hcCkge1xuICAgICAgdGhyb3cgbmV3IEVycm9yKGBBc2VydG9DbGllbnQ6IGFjY2VzcyBtYXAgZG9lcyBub3QgY29udGFpbiB0aGUga2V5ICR7a2V5fWApO1xuICAgIH1cbiAgICByZXR1cm4gbWFwO1xuICB9XG59XG4iXX0= |
{ | ||
"name": "@aserto/aserto-spa-js", | ||
"version": "0.1.25", | ||
"version": "0.1.26", | ||
"description": "Aserto single-page application javascript SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -50,3 +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 | ||
endpoint: '/__displaystatemap' // access map endpoint, defaults to /__displaystatemap | ||
}); | ||
@@ -60,3 +60,3 @@ | ||
serviceUrl: 'https://service-url', // defaults to window.location.origin | ||
endpoint: '/__accessmap' // access map endpoint, defaults to /__accessmap | ||
endpoint: '/__displaystatemap' // access map endpoint, defaults to /__displaystatemap | ||
}); | ||
@@ -70,17 +70,17 @@ | ||
### accessMap() | ||
### displayStateMap() | ||
Retrieves a javascript object that holds the access map | ||
Retrieves a javascript object that holds the display state map | ||
```js | ||
console.log(aserto.accessMap()); | ||
console.log(aserto.displayStateMap()); | ||
``` | ||
### resourceMap('method, 'path') | ||
### getDisplayState('method, 'path') | ||
Retrieves a map associated with a specific resource. | ||
Retrieves the display state associated with a specific resource. | ||
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`). | ||
If only the `method` argument is passed in, it is assumed to be a key into the `displayStateMap` (typically in the form of `METHOD/path/to/resource`). | ||
@@ -99,14 +99,14 @@ The returned map will be in the following format: | ||
const path = '/api/path'; | ||
const resource = aserto.resourceMap(method, path)); | ||
const isVisible = resource.visible; | ||
const isEnabled = resource.enabled; | ||
const displayState = aserto.getDisplayState(method, path)); | ||
const isVisible = displayState.visible; | ||
const isEnabled = displayState.enabled; | ||
``` | ||
Display the values for all access levels on each verb for the path: | ||
Log the display state values for each verb for the path: | ||
```js | ||
const path = '/api/path'; | ||
for (const verb of ['GET', 'POST', 'PUT', 'DELETE']) { | ||
const resource = aserto.resourceMap(verb, path)); | ||
for (const access of ['visible', 'enabled']) { | ||
console.log(`${verb} ${path} ${access} is ${resource[verb][access]}`); | ||
const resource = aserto.getDisplayState(verb, path)); | ||
for (const value of ['visible', 'enabled']) { | ||
console.log(`${verb} ${path} ${value} is ${resource[verb][value]}`); | ||
} | ||
@@ -113,0 +113,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
25682