1
0
Fork 0

Move API unctions to their own iles.

This commit is contained in:
Kitteh 2021-05-07 11:53:26 +01:00
parent 01519b1878
commit 13ea95a552
40 changed files with 475 additions and 396 deletions

View file

@ -1,379 +0,0 @@
import { DoesNotExistError } from "./types/internalErrors.js";
import { getObjectKeys, removeDoubleSlash } from "./utils.js";
import { pageState } from "./globalPageState.js";
function getHeaders() {
return {
"X-Vault-Token": pageState.token,
}
}
const appendAPIURL = (url) => pageState.apiURL + url;
export async function lookupSelf() {
const request = new Request(appendAPIURL("/v1/auth/token/lookup-self"), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
if ("data" in data) {
return data.data;
} else if ("errors" in data) {
throw new Error(data.errors[0]);
}
});
}
export async function renewSelf() {
const request = new Request(appendAPIURL("/v1/auth/token/renew-self"), {
method: 'POST',
headers: {
...getHeaders(),
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
if ("errors" in data) {
throw new Error(data.errors[0]);
}
});
}
export async function sealVault() {
const request = new Request(appendAPIURL("/v1/sys/seal"), {
method: 'PUT',
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
if ("errors" in data) {
throw new Error(data.errors[0]);
}
});
}
export async function usernameLogin(username, password) {
const request = new Request(appendAPIURL(`/v1/auth/userpass/login/${username}`), {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ "username": username, "password": password })
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
if ("auth" in data) {
return data.auth.client_token;
} else if ("errors" in data) {
throw new Error(data.errors[0]);
}
});
}
export async function getMounts() {
const request = new Request(appendAPIURL("/v1/sys/internal/ui/mounts"), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
return data.data.secret;
});
}
export async function getSealStatus() {
const request = new Request(appendAPIURL("/v1/sys/seal-status"));
return fetch(request).then(response => {
return response.json();
}).then(data => {
return data;
});
}
export async function submitUnsealKey(key) {
const request = new Request(appendAPIURL("/v1/sys/unseal"), {
method: "POST",
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"key": key
})
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}
export async function getCapabilities(baseMount, secretPath, name) {
return await getCapabilitiesPath(removeDoubleSlash(baseMount + secretPath.join("/") + "/" + name))
}
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 getSecrets(baseMount, mountType, secretPath) {
let secretURL = "";
if (mountType == "kv-v2") {
secretURL = `/v1/${baseMount}/metadata/${secretPath.join("")}?list=true`;
} else {
// cubbyhole and v1 are identical
secretURL = `/v1/${baseMount}/${secretPath.join("")}?list=true`;
}
const request = new Request(appendAPIURL(secretURL), {
headers: getHeaders(),
});
return fetch(request).then(response => {
if (response.status == 404) {
throw DoesNotExistError;
}
return response.json();
}).then(data => {
return data.data.keys;
});
}
export async function getSecretMetadata(baseMount, secretPath, name) {
const request = new Request(appendAPIURL(`/v1/${baseMount}/metadata/${secretPath.join("")}/${name}`), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
return data.data;
});
}
export async function undeleteSecret(baseMount, secretPath, name, version = null) {
let secretURL = `/v1/${baseMount}/undelete/${secretPath.join("/")}/${name}`;
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
if (version == null) {
let meta = await getSecretMetadata(
baseMount,
secretPath,
name
);
let versions = getObjectKeys(meta.versions);
version = String(versions[versions.length-1]);
}
let request = new Request(appendAPIURL(secretURL), {
method: "POST",
headers: {
...getHeaders(),
'Content-Type': 'application/json',
},
body: JSON.stringify({ "versions": [version] })
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}
export async function getSecret(baseMount, mountType, secretPath, name, version = null) {
let secretURL = "";
if (mountType == "kv-v2") {
secretURL = `/v1/${baseMount}/data/${secretPath.join("")}/${name}`;
if (version != null) secretURL += `?version=${version}`;
} else {
secretURL = `/v1/${baseMount}/${secretPath.join("")}/${name}`;
}
const request = new Request(appendAPIURL(secretURL), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
return mountType == "kv-v2" ? data.data.data : data.data;
});
}
export async function deleteSecret(baseMount, mountType, secretPath, name, version = null) {
let secretURL = "";
let request;
if (mountType == "kv-v2" && version != null) {
secretURL = `/v1/${baseMount}/delete/${secretPath.join("")}/${name}`;
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
request = new Request(appendAPIURL(secretURL), {
method: "POST",
headers: {
...getHeaders(),
'Content-Type': 'application/json',
},
body: version != null ? JSON.stringify({ "versions": [version] }) : "{}"
});
} else {
if (mountType == "kv-v2") {
secretURL = `/v1/${baseMount}/metadata/${secretPath.join("")}/${name}`;
} else {
secretURL = `/v1/${baseMount}/${secretPath.join("")}/${name}`;
}
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
request = new Request(appendAPIURL(secretURL), {
method: "DELETE",
headers: getHeaders(),
});
}
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}
export async function createOrUpdateSecret(baseMount, mountType, secretPath, name, data) {
let secretURL = "";
let APIData = {};
if (mountType == "kv-v2") {
secretURL = `/v1/${baseMount}/data/${secretPath.join("/")}/${name}`;
APIData = { "data": data };
} else {
secretURL = `/v1/${baseMount}/${secretPath.join("/")}/${name}`;
APIData = data;
}
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
const request = new Request(appendAPIURL(secretURL), {
method: "POST",
headers: {
'Content-Type': 'application/json',
...getHeaders(),
},
body: JSON.stringify(APIData, null, 0)
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}
export async function getTransitKeys(baseMount) {
const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), {
headers: getHeaders(),
});
return fetch(request).then(response => {
if (response.status == 404) {
throw DoesNotExistError;
}
return response.json();
}).then(data => {
return data.data.keys;
});
}
export async function transitEncrypt(baseMount, name, data) {
const request = new Request(appendAPIURL(removeDoubleSlash(`/v1/${baseMount}/encrypt/${name}`)), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...getHeaders(),
},
body: JSON.stringify({plaintext: data})
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
} else {
let json = await response.json();
return json.data;
}
}
export async function transitDecrypt(baseMount, name, data) {
const request = new Request(appendAPIURL(removeDoubleSlash(`/v1/${baseMount}/decrypt/${name}`)), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...getHeaders(),
},
body: JSON.stringify({ciphertext: data})
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
} else {
let json = await response.json();
return json.data;
}
}
export async function getTOTPKeys(baseMount) {
const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), {
headers: getHeaders(),
});
return fetch(request).then(response => {
if (response.status == 404) {
throw DoesNotExistError;
}
return response.json();
}).then(data => {
return data.data.keys;
});
}
export async function getTOTPCode(baseMount, name) {
const request = new Request(appendAPIURL(`/v1/${baseMount}/code/${name}`), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
return data.data.code;
});
}
export async function addNewTOTP(baseMount, parms) {
const request = new Request(appendAPIURL(removeDoubleSlash(`/v1/${baseMount}/keys/${parms.name}`)), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...getHeaders(),
},
body: JSON.stringify(parms)
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}

19
src/api/addNewTOTP.js Normal file
View file

@ -0,0 +1,19 @@
import { removeDoubleSlash } from "../utils.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function addNewTOTP(baseMount, parms) {
const request = new Request(appendAPIURL(removeDoubleSlash(`/v1/${baseMount}/keys/${parms.name}`)), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...getHeaders(),
},
body: JSON.stringify(parms)
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}

9
src/api/apiUtils.js Normal file
View file

@ -0,0 +1,9 @@
import { pageState } from "../globalPageState.js";
export function getHeaders() {
return {
"X-Vault-Token": pageState.token,
}
}
export const appendAPIURL = (url) => pageState.apiURL + url;

View file

@ -0,0 +1,31 @@
import { removeDoubleSlash } from "../utils.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function createOrUpdateSecret(baseMount, mountType, secretPath, name, data) {
let secretURL = "";
let APIData = {};
if (mountType == "kv-v2") {
secretURL = `/v1/${baseMount}/data/${secretPath.join("/")}/${name}`;
APIData = { "data": data };
} else {
secretURL = `/v1/${baseMount}/${secretPath.join("/")}/${name}`;
APIData = data;
}
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
const request = new Request(appendAPIURL(secretURL), {
method: "POST",
headers: {
'Content-Type': 'application/json',
...getHeaders(),
},
body: JSON.stringify(APIData, null, 0)
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}

38
src/api/deleteSecret.js Normal file
View file

@ -0,0 +1,38 @@
import { removeDoubleSlash } from "../utils.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function deleteSecret(baseMount, mountType, secretPath, name, version = null) {
let secretURL = "";
let request;
if (mountType == "kv-v2" && version != null) {
secretURL = `/v1/${baseMount}/delete/${secretPath.join("")}/${name}`;
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
request = new Request(appendAPIURL(secretURL), {
method: "POST",
headers: {
...getHeaders(),
'Content-Type': 'application/json',
},
body: version != null ? JSON.stringify({ "versions": [version] }) : "{}"
});
} else {
if (mountType == "kv-v2") {
secretURL = `/v1/${baseMount}/metadata/${secretPath.join("")}/${name}`;
} else {
secretURL = `/v1/${baseMount}/${secretPath.join("")}/${name}`;
}
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
request = new Request(appendAPIURL(secretURL), {
method: "DELETE",
headers: getHeaders(),
});
}
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}

View file

@ -0,0 +1,27 @@
import { removeDoubleSlash } from "../utils.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
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));
}

13
src/api/getMounts.js Normal file
View file

@ -0,0 +1,13 @@
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function getMounts() {
const request = new Request(appendAPIURL("/v1/sys/internal/ui/mounts"), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
return data.data.secret;
});
}

11
src/api/getSealStatus.js Normal file
View file

@ -0,0 +1,11 @@
import { appendAPIURL } from "./apiUtils.js";
export async function getSealStatus() {
const request = new Request(appendAPIURL("/v1/sys/seal-status"));
return fetch(request).then(response => {
return response.json();
}).then(data => {
return data;
});
}

22
src/api/getSecret.js Normal file
View file

@ -0,0 +1,22 @@
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function getSecret(baseMount, mountType, secretPath, name, version = null) {
let secretURL = "";
if (mountType == "kv-v2") {
secretURL = `/v1/${baseMount}/data/${secretPath.join("")}/${name}`;
if (version != null)
secretURL += `?version=${version}`;
} else {
secretURL = `/v1/${baseMount}/${secretPath.join("")}/${name}`;
}
const request = new Request(appendAPIURL(secretURL), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
return mountType == "kv-v2" ? data.data.data : data.data;
});
}

View file

@ -0,0 +1,14 @@
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function getSecretMetadata(baseMount, secretPath, name) {
const request = new Request(appendAPIURL(`/v1/${baseMount}/metadata/${secretPath.join("")}/${name}`), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
return data.data;
});
}

24
src/api/getSecrets.js Normal file
View file

@ -0,0 +1,24 @@
import { DoesNotExistError } from "../types/internalErrors.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function getSecrets(baseMount, mountType, secretPath) {
let secretURL = "";
if (mountType == "kv-v2") {
secretURL = `/v1/${baseMount}/metadata/${secretPath.join("")}?list=true`;
} else {
// cubbyhole and v1 are identical
secretURL = `/v1/${baseMount}/${secretPath.join("")}?list=true`;
}
const request = new Request(appendAPIURL(secretURL), {
headers: getHeaders(),
});
return fetch(request).then(response => {
if (response.status == 404) {
throw DoesNotExistError;
}
return response.json();
}).then(data => {
return data.data.keys;
});
}

13
src/api/getTOTPCode.js Normal file
View file

@ -0,0 +1,13 @@
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function getTOTPCode(baseMount, name) {
const request = new Request(appendAPIURL(`/v1/${baseMount}/code/${name}`), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
return data.data.code;
});
}

17
src/api/getTOTPKeys.js Normal file
View file

@ -0,0 +1,17 @@
import { DoesNotExistError } from "../types/internalErrors.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function getTOTPKeys(baseMount) {
const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), {
headers: getHeaders(),
});
return fetch(request).then(response => {
if (response.status == 404) {
throw DoesNotExistError;
}
return response.json();
}).then(data => {
return data.data.keys;
});
}

17
src/api/getTransitKeys.js Normal file
View file

@ -0,0 +1,17 @@
import { DoesNotExistError } from "../types/internalErrors.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function getTransitKeys(baseMount) {
const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), {
headers: getHeaders(),
});
return fetch(request).then(response => {
if (response.status == 404) {
throw DoesNotExistError;
}
return response.json();
}).then(data => {
return data.data.keys;
});
}

23
src/api/index.js Normal file
View file

@ -0,0 +1,23 @@
export * from "addNewTOTP.js";
export * from "api.js";
export * from "apiUtils.js";
export * from "createOrUpdateSecret.js";
export * from "deleteSecret.js";
export * from "getCapabilities.js";
export * from "getCapabilitiesPath.js";
export * from "getMounts.js";
export * from "getSealStatus.js";
export * from "getSecret.js";
export * from "getSecretMetadata.js";
export * from "getSecrets.js";
export * from "getTOTPCode.js";
export * from "getTOTPKeys.js";
export * from "getTransitKeys.js";
export * from "lookupSelf.js";
export * from "renewSelf.js";
export * from "sealVault.js";
export * from "submitUnsealKey.js";
export * from "transitDecrypt.js";
export * from "transitEncrypt.js";
export * from "undeleteSecret.js";
export * from "usernameLogin.js";

17
src/api/lookupSelf.js Normal file
View file

@ -0,0 +1,17 @@
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function lookupSelf() {
const request = new Request(appendAPIURL("/v1/auth/token/lookup-self"), {
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
if ("data" in data) {
return data.data;
} else if ("errors" in data) {
throw new Error(data.errors[0]);
}
});
}

20
src/api/renewSelf.js Normal file
View file

@ -0,0 +1,20 @@
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function renewSelf() {
const request = new Request(appendAPIURL("/v1/auth/token/renew-self"), {
method: 'POST',
headers: {
...getHeaders(),
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
if ("errors" in data) {
throw new Error(data.errors[0]);
}
});
}

16
src/api/sealVault.js Normal file
View file

@ -0,0 +1,16 @@
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function sealVault() {
const request = new Request(appendAPIURL("/v1/sys/seal"), {
method: 'PUT',
headers: getHeaders(),
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
if ("errors" in data) {
throw new Error(data.errors[0]);
}
});
}

View file

@ -0,0 +1,19 @@
import { appendAPIURL } from "./apiUtils.js";
export async function submitUnsealKey(key) {
const request = new Request(appendAPIURL("/v1/sys/unseal"), {
method: "POST",
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"key": key
})
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}

22
src/api/transitDecrypt.js Normal file
View file

@ -0,0 +1,22 @@
import { removeDoubleSlash } from "../utils.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function transitDecrypt(baseMount, name, data) {
const request = new Request(appendAPIURL(removeDoubleSlash(`/v1/${baseMount}/decrypt/${name}`)), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...getHeaders(),
},
body: JSON.stringify({ ciphertext: data })
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
} else {
let json = await response.json();
return json.data;
}
}

22
src/api/transitEncrypt.js Normal file
View file

@ -0,0 +1,22 @@
import { removeDoubleSlash } from "../utils.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
export async function transitEncrypt(baseMount, name, data) {
const request = new Request(appendAPIURL(removeDoubleSlash(`/v1/${baseMount}/encrypt/${name}`)), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...getHeaders(),
},
body: JSON.stringify({ plaintext: data })
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
} else {
let json = await response.json();
return json.data;
}
}

32
src/api/undeleteSecret.js Normal file
View file

@ -0,0 +1,32 @@
import { getObjectKeys, removeDoubleSlash } from "../utils.js";
import { appendAPIURL, getHeaders } from "./apiUtils.js";
import { getSecretMetadata } from "./getSecretMetadata";
export async function undeleteSecret(baseMount, secretPath, name, version = null) {
let secretURL = `/v1/${baseMount}/undelete/${secretPath.join("/")}/${name}`;
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
if (version == null) {
let meta = await getSecretMetadata(
baseMount,
secretPath,
name
);
let versions = getObjectKeys(meta.versions);
version = String(versions[versions.length - 1]);
}
let request = new Request(appendAPIURL(secretURL), {
method: "POST",
headers: {
...getHeaders(),
'Content-Type': 'application/json',
},
body: JSON.stringify({ "versions": [version] })
});
let response = await fetch(request);
if (!response.ok) {
let json = await response.json();
throw new Error(json.errors[0]);
}
}

21
src/api/usernameLogin.js Normal file
View file

@ -0,0 +1,21 @@
import { appendAPIURL } from "./apiUtils.js";
export async function usernameLogin(username, password) {
const request = new Request(appendAPIURL(`/v1/auth/userpass/login/${username}`), {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ "username": username, "password": password })
});
return fetch(request).then(response => {
return response.json();
}).then(data => {
if ("auth" in data) {
return data.auth.client_token;
} else if ("errors" in data) {
throw new Error(data.errors[0]);
}
});
}

View file

@ -17,7 +17,7 @@ import {
changePage, changePage,
renderPage, renderPage,
} from "./pageUtils.js"; } from "./pageUtils.js";
import { getSealStatus } from './api.js'; import { getSealStatus } from "./api/getSealStatus";
import { makeElement } from "./htmlUtils.js"; import { makeElement } from "./htmlUtils.js";
import { pageState } from "./globalPageState.js"; import { pageState } from "./globalPageState.js";

View file

@ -1,4 +1,5 @@
import { getSealStatus, lookupSelf } from './api.js'; import { getSealStatus } from "./api/getSealStatus";
import { lookupSelf } from "./api/lookupSelf";
import { makeElement } from "./htmlUtils.js"; import { makeElement } from "./htmlUtils.js";
import { pageState } from "./globalPageState.js"; import { pageState } from "./globalPageState.js";
import UIkit from 'uikit/dist/js/uikit.min.js'; import UIkit from 'uikit/dist/js/uikit.min.js';

View file

@ -1,6 +1,7 @@
import { Page } from "../types/Page.js"; import { Page } from "../types/Page.js";
import { changePage, prePageChecks, setErrorText } from "../pageUtils.js"; import { changePage, prePageChecks, setErrorText } from "../pageUtils.js";
import { getMounts, lookupSelf } from "../api.js"; import { getMounts } from "../api/getMounts";
import { lookupSelf } from "../api/lookupSelf";
import { makeElement } from "../htmlUtils.js"; import { makeElement } from "../htmlUtils.js";
import { pageState } from "../globalPageState.js"; import { pageState } from "../globalPageState.js";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,6 +1,6 @@
import { Page } from "../../types/Page.js"; import { Page } from "../../types/Page.js";
import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js"; import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js";
import { deleteSecret } from "../../api.js"; import { deleteSecret } from "../../api/deleteSecret";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,6 +1,6 @@
import { Page } from "../../types/Page.js"; import { Page } from "../../types/Page.js";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
import { createOrUpdateSecret } from "../../api.js"; import { createOrUpdateSecret } from "../../api/createOrUpdateSecret";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,7 +1,9 @@
import { CopyableInputBox } from "../../elements/CopyableInputBox.js"; import { CopyableInputBox } from "../../elements/CopyableInputBox.js";
import { Page } from "../../types/Page.js"; import { Page } from "../../types/Page.js";
import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js"; import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js";
import { getCapabilities, getSecret, undeleteSecret } from "../../api.js"; import { getSecret } from "../../api/getSecret";
import { undeleteSecret } from "../../api/undeleteSecret";
import { getCapabilities } from "../../api/getCapabilities";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import Prism from "prismjs"; import Prism from "prismjs";

View file

@ -1,7 +1,8 @@
import { CodeJar } from "codejar"; import { CodeJar } from "codejar";
import { Page } from "../../types/Page.js"; import { Page } from "../../types/Page.js";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
import { createOrUpdateSecret, getSecret } from "../../api.js"; import { createOrUpdateSecret } from "../../api/createOrUpdateSecret.js";
import { getSecret } from "../../api/getSecret.js";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import { verifyJSONString } from "../../utils.js"; import { verifyJSONString } from "../../utils.js";

View file

@ -1,6 +1,6 @@
import { Page } from "../../types/Page.js"; import { Page } from "../../types/Page.js";
import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js"; import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js";
import { getSecretMetadata } from "../../api.js"; import { getSecretMetadata } from "../../api/getSecretMetadata.js";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,7 +1,7 @@
import { DoesNotExistError } from "../../types/internalErrors.js"; import { DoesNotExistError } from "../../types/internalErrors.js";
import { Page } from "../../types/Page.js"; import { Page } from "../../types/Page.js";
import { changePage, setErrorText, setTitleElement } from "../../pageUtils.js"; import { changePage, setErrorText, setTitleElement } from "../../pageUtils.js";
import { getSecrets } from "../../api.js"; import { getSecrets } from "../../api/getSecrets";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -2,7 +2,8 @@ import { Margin } from "../elements/Margin.js";
import { MarginInline } from "../elements/MarginInline.js"; import { MarginInline } from "../elements/MarginInline.js";
import { Page } from "../types/Page.js"; import { Page } from "../types/Page.js";
import { changePage, setErrorText, setPageContent } from "../pageUtils.js"; import { changePage, setErrorText, setPageContent } from "../pageUtils.js";
import { lookupSelf, usernameLogin } from "../api.js"; import { usernameLogin } from "../api/usernameLogin";
import { lookupSelf } from "../api/lookupSelf";
import { makeElement } from "../htmlUtils.js"; import { makeElement } from "../htmlUtils.js";
import { pageState } from "../globalPageState.js"; import { pageState } from "../globalPageState.js";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -1,6 +1,8 @@
import { Page } from "../types/Page.js"; import { Page } from "../types/Page.js";
import { addClipboardNotifications, changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils.js"; import { addClipboardNotifications, changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils.js";
import { getCapabilitiesPath, renewSelf, sealVault } from "../api.js"; import { getCapabilitiesPath } from "../api/getCapabilities.js";
import { renewSelf } from "../api/renewSelf.js";
import { sealVault } from "../api/sealVault.js";
import { makeElement } from "../htmlUtils.js"; import { makeElement } from "../htmlUtils.js";
import { pageState } from "../globalPageState.js"; import { pageState } from "../globalPageState.js";
import ClipboardJS from "clipboard"; import ClipboardJS from "clipboard";

View file

@ -1,12 +1,13 @@
import { Margin } from "../../elements/Margin.js"; import { Margin } from "../../elements/Margin.js";
import { MarginInline } from "../../elements/MarginInline.js"; import { MarginInline } from "../../elements/MarginInline.js";
import { Page } from "../../types/Page.js"; import { Page } from "../../types/Page.js";
import { addNewTOTP } from "../../api.js"; import { addNewTOTP } from "../../api/addNewTOTP";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import i18next from 'i18next'; import i18next from 'i18next';
export class NewTOTPPage extends Page { export class NewTOTPPage extends Page {
constructor() { constructor() {
super(); super();

View file

@ -2,7 +2,8 @@ import { CopyableInputBox } from "../../elements/CopyableInputBox.js";
import { DoesNotExistError } from "../../types/internalErrors.js"; import { DoesNotExistError } from "../../types/internalErrors.js";
import { Page } from "../../types/Page.js"; import { Page } from "../../types/Page.js";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
import { getTOTPCode, getTOTPKeys } from "../../api.js"; import { getTOTPCode } from "../../api/getTOTPCode";
import { getTOTPKeys } from "../../api/getTOTPKeys";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -4,7 +4,7 @@ import { Page } from "../../types/Page.js";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import { transitDecrypt } from "../../api.js"; import { transitDecrypt } from "../../api/transitDecrypt";
import UIkit from 'uikit/dist/js/uikit.min.js'; import UIkit from 'uikit/dist/js/uikit.min.js';
import i18next from "i18next"; import i18next from "i18next";

View file

@ -4,7 +4,7 @@ import { Page } from "../../types/Page.js";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import { transitEncrypt } from "../../api.js"; import { transitEncrypt } from "../../api/transitEncrypt";
import UIkit from 'uikit/dist/js/uikit.min.js'; import UIkit from 'uikit/dist/js/uikit.min.js';
import i18next from "i18next"; import i18next from "i18next";

View file

@ -1,7 +1,7 @@
import { DoesNotExistError } from "../../types/internalErrors.js"; import { DoesNotExistError } from "../../types/internalErrors.js";
import { Page } from "../../types/Page.js"; import { Page } from "../../types/Page.js";
import { changePage, setErrorText, setTitleElement } from "../../pageUtils.js"; import { changePage, setErrorText, setTitleElement } from "../../pageUtils.js";
import { getTransitKeys } from "../../api.js"; import { getTransitKeys } from "../../api/getTransitKeys";
import { makeElement } from "../../htmlUtils.js"; import { makeElement } from "../../htmlUtils.js";
import { pageState } from "../../globalPageState.js"; import { pageState } from "../../globalPageState.js";
import i18next from 'i18next'; import i18next from 'i18next';

View file

@ -2,7 +2,8 @@ import { MarginInline } from "../elements/MarginInline.js";
import { Page } from "../types/Page.js"; import { Page } from "../types/Page.js";
import { QRScanner } from "../elements/QRScanner.js"; import { QRScanner } from "../elements/QRScanner.js";
import { changePage, setErrorText, setPageContent } from "../pageUtils.js"; import { changePage, setErrorText, setPageContent } from "../pageUtils.js";
import { getSealStatus, submitUnsealKey } from "../api.js"; import { getSealStatus } from "../api/getSealStatus.js";
import { submitUnsealKey } from "../api/submitUnsealKey.js";
import { makeElement } from "../htmlUtils.js"; import { makeElement } from "../htmlUtils.js";
import i18next from 'i18next'; import i18next from 'i18next';