1
0
Fork 0
VaultUI/src/api/getCapabilities.ts
2021-05-08 00:21:58 +01:00

32 lines
816 B
TypeScript

import { appendAPIURL, getHeaders } from "./apiUtils";
import { removeDoubleSlash } from "../utils";
export async function getCapabilitiesPath(path: string): Promise<string[]> {
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: string,
secretPath: string[],
name: string
): Promise<string[]> {
return await getCapabilitiesPath(removeDoubleSlash(baseMount + secretPath.join("/") + "/" + name));
}