1
0
Fork 0
VaultUI/src/api/getCapabilities.js

28 lines
741 B
JavaScript
Raw Normal View History

2021-05-07 11:53:26 +01:00
import { appendAPIURL, getHeaders } from "./apiUtils.js";
2021-05-07 11:54:44 +01:00
import { removeDoubleSlash } from "../utils.js";
2021-05-07 11:53:26 +01:00
export async function getCapabilitiesPath(path) {
const request = new Request(appendAPIURL("/v1/sys/capabilities-self"), {
method: "POST",
headers: {
'Content-Type': 'application/json',
...getHeaders(),
},
body: JSON.stringify(
{
"paths": [removeDoubleSlash(path)]
}
)
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
return data.capabilities;
});
}
export async function getCapabilities(baseMount, secretPath, name) {
return await getCapabilitiesPath(removeDoubleSlash(baseMount + secretPath.join("/") + "/" + name));
}