Add getObjectKeys.
This commit is contained in:
parent
fa9f25027c
commit
be0a597dfb
|
@ -1,5 +1,5 @@
|
|||
import { DoesNotExistError } from "./types/internalErrors.js";
|
||||
import { getAPIURL, getToken, removeDoubleSlash } from "./utils.js";
|
||||
import { getAPIURL, getObjectKeys, getToken, removeDoubleSlash } from "./utils.js";
|
||||
|
||||
export async function lookupSelf() {
|
||||
const request = new Request(getAPIURL() + "/v1/auth/token/lookup-self", {
|
||||
|
@ -181,8 +181,8 @@ export async function undeleteSecret(baseMount, secretPath, name, version = null
|
|||
pageState.currentSecretPath,
|
||||
pageState.currentSecret
|
||||
);
|
||||
let versions = Array.from(new Map(Object.entries(meta.versions)).keys())
|
||||
version = String(versions[versions.length-1])
|
||||
let versions = getObjectKeys(meta.versions);
|
||||
version = String(versions[versions.length-1]);
|
||||
}
|
||||
|
||||
let request = new Request(getAPIURL() + secretURL, {
|
||||
|
|
|
@ -2,8 +2,10 @@ export function removeDoubleSlash(str) {
|
|||
return str.replace(/\/\/+/g, "/");
|
||||
}
|
||||
|
||||
export const getObjectKeys = (obj) => Object.getOwnPropertyNames(obj);
|
||||
|
||||
export function getKeyByObjectPropertyValue(map, searchValue) {
|
||||
for (let key of Object.getOwnPropertyNames(map)) {
|
||||
for (let key of getObjectKeys(map)) {
|
||||
if (map[key] === searchValue)
|
||||
return key;
|
||||
}
|
||||
|
@ -23,5 +25,5 @@ export function getToken() {
|
|||
}
|
||||
|
||||
export function getAPIURL() {
|
||||
return pageState.apiURL.length > 0 ? pageState.apiURL : null
|
||||
return pageState.apiURL.length > 0 ? pageState.apiURL : null;
|
||||
}
|
Loading…
Reference in a new issue