Move pageState into a js file instead of in global window.
This commit is contained in:
parent
aa9a58af7c
commit
5409d64409
|
@ -1,4 +1,5 @@
|
|||
import { Page } from "./types/Page.js";
|
||||
import { allPages } from "./allPages.js"
|
||||
import {
|
||||
getKeyByObjectPropertyValue,
|
||||
} from "./utils.js";
|
||||
|
@ -19,14 +20,16 @@ export class PageState extends Page {
|
|||
// the clunkyness of this approach, but for now, this works.
|
||||
|
||||
get apiURL() {
|
||||
return localStorage.getItem('apiURL') || "";
|
||||
let apiurl = localStorage.getItem('apiURL') || "";
|
||||
return apiurl.length > 0 ? apiurl : null;
|
||||
}
|
||||
set apiURL(value) {
|
||||
localStorage.setItem('apiURL', value);
|
||||
}
|
||||
|
||||
get token() {
|
||||
return localStorage.getItem('token') || "";
|
||||
let tok = localStorage.getItem('token') || "";
|
||||
return tok.length > 0 ? tok : null;
|
||||
}
|
||||
set token(value) {
|
||||
localStorage.setItem('token', value);
|
||||
|
@ -91,14 +94,18 @@ export class PageState extends Page {
|
|||
}
|
||||
get currentPage() {
|
||||
let curPage = localStorage.getItem('currentPage') || "HOME";
|
||||
return realPages[curPage];
|
||||
return allPages[curPage];
|
||||
}
|
||||
get currentPageString() {
|
||||
let key = getKeyByObjectPropertyValue(realPages, this.currentPage);
|
||||
let key = getKeyByObjectPropertyValue(allPages, this.currentPage);
|
||||
return key;
|
||||
}
|
||||
set currentPage(value) {
|
||||
let key = getKeyByObjectPropertyValue(realPages, value);
|
||||
localStorage.setItem('currentPage', key);
|
||||
if (typeof page == 'object') {
|
||||
let key = getKeyByObjectPropertyValue(allPages, value);
|
||||
localStorage.setItem('currentPage', key);
|
||||
} else {
|
||||
localStorage.setItem('currentPage', value);
|
||||
}
|
||||
}
|
||||
}
|
41
src/allPages.js
Normal file
41
src/allPages.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { HomePage } from "./pages/Home.js";
|
||||
import { KeyValueDeletePage } from "./pages/KeyValue/KeyValueDelete.js";
|
||||
import { KeyValueNewPage } from "./pages/KeyValue/KeyValueNew.js";
|
||||
import { KeyValueSecretEditPage } from "./pages/KeyValue/KeyValueSecretsEdit.js";
|
||||
import { KeyValueSecretPage } from "./pages/KeyValue/KeyValueSecret.js";
|
||||
import { KeyValueVersionsPage } from "./pages/KeyValue/KeyValueVersions.js";
|
||||
import { KeyValueViewPage } from "./pages/KeyValue/KeyValueView.js";
|
||||
import { LoginPage } from "./pages/Login.js";
|
||||
import { MePage } from "./pages/Me.js";
|
||||
import { NewTOTPPage } from "./pages/TOTP/NewTOTP.js";
|
||||
import { PwGenPage } from "./pages/PwGen.js";
|
||||
import { SetLanguagePage } from "./pages/SetLanguage.js";
|
||||
import { SetVaultURLPage } from "./pages/SetVaultURL.js";
|
||||
import { TOTPViewPage } from "./pages/TOTP/TOTPView.js";
|
||||
import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt.js";
|
||||
import { TransitEncryptPage } from "./pages/Transit/TransitEncrypt.js";
|
||||
import { TransitViewPage } from "./pages/Transit/TransitView.js";
|
||||
import { TransitViewSecretPage } from "./pages/Transit/TransitViewSecret.js";
|
||||
import { UnsealPage } from "./pages/Unseal.js";
|
||||
|
||||
export const allPages = {
|
||||
HOME: new HomePage(),
|
||||
ME: new MePage(),
|
||||
TOTP: new TOTPViewPage(),
|
||||
NEW_TOTP: new NewTOTPPage(),
|
||||
LOGIN: new LoginPage(),
|
||||
SET_VAULT_URL: new SetVaultURLPage(),
|
||||
UNSEAL: new UnsealPage(),
|
||||
SET_LANGUAGE: new SetLanguagePage(),
|
||||
TRANSIT_VIEW: new TransitViewPage(),
|
||||
TRANSIT_VIEW_SECRET: new TransitViewSecretPage(),
|
||||
TRANSIT_ENCRYPT: new TransitEncryptPage(),
|
||||
TRANSIT_DECRYPT: new TransitDecryptPage(),
|
||||
KEY_VALUE_VIEW: new KeyValueViewPage(),
|
||||
KEY_VALUE_SECRET: new KeyValueSecretPage(),
|
||||
KEY_VALUE_VERSIONS: new KeyValueVersionsPage(),
|
||||
KEY_VALUE_NEW_SECRET: new KeyValueNewPage(),
|
||||
KEY_VALUE_DELETE: new KeyValueDeletePage(),
|
||||
KEY_VALUE_SECRET_EDIT: new KeyValueSecretEditPage(),
|
||||
PW_GEN: new PwGenPage(),
|
||||
};
|
81
src/api.js
81
src/api.js
|
@ -1,10 +1,11 @@
|
|||
import { DoesNotExistError } from "./types/internalErrors.js";
|
||||
import { getAPIURL, getObjectKeys, getToken, removeDoubleSlash } from "./utils.js";
|
||||
import { getObjectKeys, removeDoubleSlash } from "./utils.js";
|
||||
import { pageState } from "./globalPageState.js";
|
||||
|
||||
export async function lookupSelf() {
|
||||
const request = new Request(getAPIURL() + "/v1/auth/token/lookup-self", {
|
||||
const request = new Request(pageState.apiURL + "/v1/auth/token/lookup-self", {
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
}
|
||||
});
|
||||
return fetch(request).then(response => {
|
||||
|
@ -19,10 +20,10 @@ export async function lookupSelf() {
|
|||
}
|
||||
|
||||
export async function renewSelf() {
|
||||
const request = new Request(getAPIURL() + "/v1/auth/token/renew-self", {
|
||||
const request = new Request(pageState.apiURL + "/v1/auth/token/renew-self", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({})
|
||||
|
@ -37,10 +38,10 @@ export async function renewSelf() {
|
|||
}
|
||||
|
||||
export async function sealVault() {
|
||||
const request = new Request(getAPIURL() + "/v1/sys/seal", {
|
||||
const request = new Request(pageState.apiURL + "/v1/sys/seal", {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
},
|
||||
});
|
||||
return fetch(request).then(response => {
|
||||
|
@ -53,7 +54,7 @@ export async function sealVault() {
|
|||
}
|
||||
|
||||
export async function usernameLogin(username, password) {
|
||||
const request = new Request(getAPIURL() + `/v1/auth/userpass/login/${username}`, {
|
||||
const request = new Request(pageState.apiURL + `/v1/auth/userpass/login/${username}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
@ -72,9 +73,9 @@ export async function usernameLogin(username, password) {
|
|||
}
|
||||
|
||||
export async function getMounts() {
|
||||
const request = new Request(getAPIURL() + "/v1/sys/internal/ui/mounts", {
|
||||
const request = new Request(pageState.apiURL + "/v1/sys/internal/ui/mounts", {
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
}
|
||||
});
|
||||
return fetch(request).then(response => {
|
||||
|
@ -85,7 +86,7 @@ export async function getMounts() {
|
|||
}
|
||||
|
||||
export async function getSealStatus() {
|
||||
const request = new Request(getAPIURL() + "/v1/sys/seal-status");
|
||||
const request = new Request(pageState.apiURL + "/v1/sys/seal-status");
|
||||
return fetch(request).then(response => {
|
||||
return response.json();
|
||||
}).then(data => {
|
||||
|
@ -94,7 +95,7 @@ export async function getSealStatus() {
|
|||
}
|
||||
|
||||
export async function submitUnsealKey(key) {
|
||||
const request = new Request(getAPIURL() + "/v1/sys/unseal", {
|
||||
const request = new Request(pageState.apiURL + "/v1/sys/unseal", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -115,11 +116,11 @@ export async function getCapabilities(baseMount, secretPath, name) {
|
|||
}
|
||||
|
||||
export async function getCapabilitiesPath(path) {
|
||||
const request = new Request(getAPIURL() + "/v1/sys/capabilities-self", {
|
||||
const request = new Request(pageState.apiURL + "/v1/sys/capabilities-self", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
},
|
||||
body: JSON.stringify(
|
||||
{
|
||||
|
@ -142,9 +143,9 @@ export async function getSecrets(baseMount, mountType, secretPath) {
|
|||
// cubbyhole and v1 are identical
|
||||
secretURL = `/v1/${baseMount}/${secretPath.join("")}?list=true`;
|
||||
}
|
||||
const request = new Request(getAPIURL() + secretURL, {
|
||||
const request = new Request(pageState.apiURL + secretURL, {
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
}
|
||||
});
|
||||
return fetch(request).then(response => {
|
||||
|
@ -159,9 +160,9 @@ export async function getSecrets(baseMount, mountType, secretPath) {
|
|||
}
|
||||
|
||||
export async function getSecretMetadata(baseMount, secretPath, name) {
|
||||
const request = new Request(getAPIURL() + `/v1/${baseMount}/metadata/${secretPath.join("")}/${name}`, {
|
||||
const request = new Request(pageState.apiURL + `/v1/${baseMount}/metadata/${secretPath.join("")}/${name}`, {
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -185,10 +186,10 @@ export async function undeleteSecret(baseMount, secretPath, name, version = null
|
|||
version = String(versions[versions.length-1]);
|
||||
}
|
||||
|
||||
let request = new Request(getAPIURL() + secretURL, {
|
||||
let request = new Request(pageState.apiURL + secretURL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'X-Vault-Token': getToken(),
|
||||
'X-Vault-Token': pageState.token,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ "versions": [version] })
|
||||
|
@ -209,9 +210,9 @@ export async function getSecret(baseMount, mountType, secretPath, name, version
|
|||
} else {
|
||||
secretURL = `/v1/${baseMount}/${secretPath.join("")}/${name}`;
|
||||
}
|
||||
const request = new Request(getAPIURL() + secretURL, {
|
||||
const request = new Request(pageState.apiURL + secretURL, {
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -230,10 +231,10 @@ export async function deleteSecret(baseMount, mountType, secretPath, name, versi
|
|||
if (mountType == "kv-v2" && version != null) {
|
||||
secretURL = `/v1/${baseMount}/delete/${secretPath.join("")}/${name}`;
|
||||
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
|
||||
request = new Request(getAPIURL() + secretURL, {
|
||||
request = new Request(pageState.apiURL + secretURL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'X-Vault-Token': getToken(),
|
||||
'X-Vault-Token': pageState.token,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: version != null ? JSON.stringify({ "versions": [version] }) : "{}"
|
||||
|
@ -245,10 +246,10 @@ export async function deleteSecret(baseMount, mountType, secretPath, name, versi
|
|||
secretURL = `/v1/${baseMount}/${secretPath.join("")}/${name}`;
|
||||
}
|
||||
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
|
||||
request = new Request(getAPIURL() + secretURL, {
|
||||
request = new Request(pageState.apiURL + secretURL, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
'X-Vault-Token': getToken()
|
||||
'X-Vault-Token': pageState.token
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -274,11 +275,11 @@ export async function createOrUpdateSecret(baseMount, mountType, secretPath, nam
|
|||
}
|
||||
|
||||
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
|
||||
const request = new Request(getAPIURL() + secretURL, {
|
||||
const request = new Request(pageState.apiURL + secretURL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Vault-Token': getToken()
|
||||
'X-Vault-Token': pageState.token
|
||||
},
|
||||
body: JSON.stringify(APIData, null, 0)
|
||||
});
|
||||
|
@ -290,9 +291,9 @@ export async function createOrUpdateSecret(baseMount, mountType, secretPath, nam
|
|||
}
|
||||
|
||||
export async function getTransitKeys(baseMount) {
|
||||
const request = new Request(getAPIURL() + `/v1/${baseMount}/keys?list=true`, {
|
||||
const request = new Request(pageState.apiURL + `/v1/${baseMount}/keys?list=true`, {
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
}
|
||||
});
|
||||
return fetch(request).then(response => {
|
||||
|
@ -306,11 +307,11 @@ export async function getTransitKeys(baseMount) {
|
|||
}
|
||||
|
||||
export async function transitEncrypt(baseMount, name, data) {
|
||||
const request = new Request(getAPIURL() + removeDoubleSlash(`/v1/${baseMount}/encrypt/${name}`), {
|
||||
const request = new Request(pageState.apiURL + removeDoubleSlash(`/v1/${baseMount}/encrypt/${name}`), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Vault-Token': getToken()
|
||||
'X-Vault-Token': pageState.token
|
||||
},
|
||||
body: JSON.stringify({plaintext: data})
|
||||
});
|
||||
|
@ -325,11 +326,11 @@ export async function transitEncrypt(baseMount, name, data) {
|
|||
}
|
||||
|
||||
export async function transitDecrypt(baseMount, name, data) {
|
||||
const request = new Request(getAPIURL() + removeDoubleSlash(`/v1/${baseMount}/decrypt/${name}`), {
|
||||
const request = new Request(pageState.apiURL + removeDoubleSlash(`/v1/${baseMount}/decrypt/${name}`), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Vault-Token': getToken()
|
||||
'X-Vault-Token': pageState.token
|
||||
},
|
||||
body: JSON.stringify({ciphertext: data})
|
||||
});
|
||||
|
@ -345,9 +346,9 @@ export async function transitDecrypt(baseMount, name, data) {
|
|||
|
||||
|
||||
export async function getTOTPKeys(baseMount) {
|
||||
const request = new Request(getAPIURL() + `/v1/${baseMount}/keys?list=true`, {
|
||||
const request = new Request(pageState.apiURL + `/v1/${baseMount}/keys?list=true`, {
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
}
|
||||
});
|
||||
return fetch(request).then(response => {
|
||||
|
@ -361,9 +362,9 @@ export async function getTOTPKeys(baseMount) {
|
|||
}
|
||||
|
||||
export async function getTOTPCode(baseMount, name) {
|
||||
const request = new Request(getAPIURL() + `/v1/${baseMount}/code/${name}`, {
|
||||
const request = new Request(pageState.apiURL + `/v1/${baseMount}/code/${name}`, {
|
||||
headers: {
|
||||
"X-Vault-Token": getToken(),
|
||||
"X-Vault-Token": pageState.token,
|
||||
}
|
||||
});
|
||||
return fetch(request).then(response => {
|
||||
|
@ -374,11 +375,11 @@ export async function getTOTPCode(baseMount, name) {
|
|||
}
|
||||
|
||||
export async function addNewTOTP(baseMount, parms) {
|
||||
const request = new Request(getAPIURL() + removeDoubleSlash(`/v1/${baseMount}/keys/${parms.name}`), {
|
||||
const request = new Request(pageState.apiURL + removeDoubleSlash(`/v1/${baseMount}/keys/${parms.name}`), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Vault-Token': getToken()
|
||||
'X-Vault-Token': pageState.token
|
||||
},
|
||||
body: JSON.stringify(parms)
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { de, enGB, fr, it, nl, ru } from 'date-fns/locale'
|
||||
import { formatDistance as formatDistanceReal} from 'date-fns';
|
||||
import { pageState } from "./globalPageState.js";
|
||||
|
||||
function getLocale() {
|
||||
return {
|
||||
|
|
3
src/globalPageState.js
Normal file
3
src/globalPageState.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { PageState } from "./PageState.js";
|
||||
|
||||
export const pageState = new PageState();
|
63
src/main.js
63
src/main.js
|
@ -13,80 +13,19 @@ import "prismjs/components/prism-json";
|
|||
Prism.highlightAll();
|
||||
/* eslint-enable */
|
||||
|
||||
import { PageState } from "./PageState.js";
|
||||
import {
|
||||
changePage,
|
||||
renderPage,
|
||||
} from "./pageUtils.js";
|
||||
import { getSealStatus } from './api.js';
|
||||
import { makeElement } from "./htmlUtils.js";
|
||||
|
||||
// Pages
|
||||
|
||||
import {
|
||||
HomePage,
|
||||
KeyValueDeletePage,
|
||||
KeyValueNewPage,
|
||||
KeyValueSecretEditPage,
|
||||
KeyValueSecretPage,
|
||||
KeyValueVersionsPage,
|
||||
KeyValueViewPage,
|
||||
LoginPage,
|
||||
MePage,
|
||||
NewTOTPPage,
|
||||
PwGenPage,
|
||||
SetLanguagePage,
|
||||
SetVaultURLPage,
|
||||
TOTPViewPage,
|
||||
TransitDecryptPage,
|
||||
TransitEncryptPage,
|
||||
TransitViewPage,
|
||||
TransitViewSecretPage,
|
||||
UnsealPage,
|
||||
} from "./pages";
|
||||
|
||||
const pages = {
|
||||
HOME: new HomePage(),
|
||||
ME: new MePage(),
|
||||
TOTP: new TOTPViewPage(),
|
||||
NEW_TOTP: new NewTOTPPage(),
|
||||
LOGIN: new LoginPage(),
|
||||
SET_VAULT_URL: new SetVaultURLPage(),
|
||||
UNSEAL: new UnsealPage(),
|
||||
SET_LANGUAGE: new SetLanguagePage(),
|
||||
TRANSIT_VIEW: new TransitViewPage(),
|
||||
TRANSIT_VIEW_SECRET: new TransitViewSecretPage(),
|
||||
TRANSIT_ENCRYPT: new TransitEncryptPage(),
|
||||
TRANSIT_DECRYPT: new TransitDecryptPage(),
|
||||
KEY_VALUE_VIEW: new KeyValueViewPage(),
|
||||
KEY_VALUE_SECRET: new KeyValueSecretPage(),
|
||||
KEY_VALUE_VERSIONS: new KeyValueVersionsPage(),
|
||||
KEY_VALUE_NEW_SECRET: new KeyValueNewPage(),
|
||||
KEY_VALUE_DELETE: new KeyValueDeletePage(),
|
||||
KEY_VALUE_SECRET_EDIT: new KeyValueSecretEditPage(),
|
||||
PW_GEN: new PwGenPage(),
|
||||
};
|
||||
import { pageState } from "./globalPageState.js";
|
||||
|
||||
// Translations
|
||||
import { formatDistance } from './formatDistance.js';
|
||||
import i18next from 'i18next';
|
||||
import translations from './translations/index.mjs'
|
||||
|
||||
/*import "en-GB" as date_locale_en from 'date-fns/locale'
|
||||
|
||||
function getDateLocale() {
|
||||
let locales = {
|
||||
en:
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// Globals
|
||||
|
||||
var pageState = new PageState();
|
||||
window.pageState = pageState;
|
||||
window.realPages = pages;
|
||||
|
||||
function ListItem(children) {
|
||||
return makeElement({
|
||||
tag: "li",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { getAPIURL } from "./utils.js";
|
||||
import { getSealStatus, lookupSelf } from './api.js';
|
||||
import { makeElement } from "./htmlUtils.js";
|
||||
|
||||
import { pageState } from "./globalPageState.js";
|
||||
import UIkit from 'uikit/dist/js/uikit.min.js';
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
@ -10,7 +9,7 @@ async function prePageChecksReal() {
|
|||
changePage("SET_LANGUAGE");
|
||||
throw new Error("Language Not Set");
|
||||
}
|
||||
if (!getAPIURL()) {
|
||||
if (!pageState.apiURL) {
|
||||
changePage("SET_VAULT_URL");
|
||||
throw new Error("Vault URL Not Set");
|
||||
}
|
||||
|
@ -75,11 +74,7 @@ export function changePage(page, shouldSwitch = true) {
|
|||
if (pageState.currentPage && shouldSwitch) {
|
||||
pageState.currentPage.cleanup();
|
||||
}
|
||||
if (typeof page == 'object') {
|
||||
pageState.currentPage = page;
|
||||
} else {
|
||||
pageState.currentPage = realPages[page];
|
||||
}
|
||||
pageState.currentPage = page;
|
||||
if (shouldSwitch) {
|
||||
renderPage();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Page } from "../types/Page.js";
|
||||
import { changePage, prePageChecks, setErrorText } from "../pageUtils.js";
|
||||
import { getAPIURL } from "../utils.js";
|
||||
import { getMounts, lookupSelf } from "../api.js";
|
||||
import { makeElement } from "../htmlUtils.js";
|
||||
import { pageState } from "../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
export class HomePage extends Page {
|
||||
|
@ -21,7 +21,7 @@ export class HomePage extends Page {
|
|||
tag: "li",
|
||||
children: makeElement({
|
||||
tag: "span",
|
||||
html: i18next.t("vaulturl_text", {"text": getAPIURL()})
|
||||
html: i18next.t("vaulturl_text", {"text": pageState.apiURL})
|
||||
})
|
||||
}),
|
||||
makeElement({
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Page } from "../../types/Page.js";
|
|||
import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { deleteSecret } from "../../api.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
export class KeyValueDeletePage extends Page {
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Page } from "../../types/Page.js";
|
|||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { createOrUpdateSecret } from "../../api.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
export class KeyValueNewPage extends Page {
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Page } from "../../types/Page.js";
|
|||
import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { getCapabilities, getSecret, undeleteSecret } from "../../api.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import Prism from "prismjs";
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Page } from "../../types/Page.js";
|
|||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { createOrUpdateSecret, getSecret } from "../../api.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import { verifyJSONString } from "../../utils.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Page } from "../../types/Page.js";
|
|||
import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { getSecretMetadata } from "../../api.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Page } from "../../types/Page.js";
|
|||
import { changePage, setErrorText, setTitleElement } from "../../pageUtils.js";
|
||||
import { getSecrets } from "../../api.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Page } from "../types/Page.js";
|
||||
import { addClipboardNotifications, changePage, prePageChecks, setErrorText, setPageContent } from "../pageUtils.js";
|
||||
import { getCapabilitiesPath, renewSelf, sealVault } from "../api.js";
|
||||
import { getToken } from "../utils.js";
|
||||
import { makeElement } from "../htmlUtils.js";
|
||||
import { pageState } from "../globalPageState.js";
|
||||
import ClipboardJS from "clipboard";
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
@ -35,7 +35,7 @@ export class MePage extends Page {
|
|||
tag: "a",
|
||||
text: i18next.t("copy_token_btn"),
|
||||
attributes: {
|
||||
"data-clipboard-text": getToken(),
|
||||
"data-clipboard-text": pageState.token,
|
||||
},
|
||||
thenRun: (e) => {
|
||||
let clipboard = new ClipboardJS(e);
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Margin } from "../elements/Margin.js";
|
|||
import { Page } from "../types/Page.js";
|
||||
import { changePage, setPageContent } from "../pageUtils.js";
|
||||
import { makeElement } from "../htmlUtils.js";
|
||||
import { pageState } from "../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
import translations from "../translations/index.mjs";
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import { Page } from "../../types/Page.js";
|
|||
import { addNewTOTP } from "../../api.js";
|
||||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
export class NewTOTPPage extends Page {
|
||||
|
|
|
@ -4,6 +4,7 @@ import { Page } from "../../types/Page.js";
|
|||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { getTOTPCode, getTOTPKeys } from "../../api.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
export class TOTPViewPage extends Page {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Page } from "../types/Page.js";
|
||||
import { changePage, setPageContent, setTitleElement } from "../pageUtils.js";
|
||||
import { makeElement } from "../htmlUtils.js";
|
||||
import { pageState } from "../globalPageState.js";
|
||||
|
||||
export class TemplatePage extends Page {
|
||||
constructor() {
|
||||
|
|
|
@ -3,11 +3,11 @@ import { Margin } from "../../elements/Margin.js";
|
|||
import { Page } from "../../types/Page.js";
|
||||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import { transitDecrypt } from "../../api.js";
|
||||
import UIkit from 'uikit/dist/js/uikit.min.js';
|
||||
import i18next from "i18next";
|
||||
|
||||
|
||||
export class TransitDecryptPage extends Page {
|
||||
constructor() {
|
||||
super();
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Margin } from "../../elements/Margin.js";
|
|||
import { Page } from "../../types/Page.js";
|
||||
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import { transitEncrypt } from "../../api.js";
|
||||
import UIkit from 'uikit/dist/js/uikit.min.js';
|
||||
import i18next from "i18next";
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Page } from "../../types/Page.js";
|
|||
import { changePage, setErrorText, setTitleElement } from "../../pageUtils.js";
|
||||
import { getTransitKeys } from "../../api.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
export class TransitViewPage extends Page {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Page } from "../../types/Page.js";
|
||||
import { changePage, setPageContent, setTitleElement } from "../../pageUtils.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
import { pageState } from "../../globalPageState.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
export class TransitViewSecretPage extends Page {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import i18next from 'i18next';
|
||||
|
||||
import { changePage, setErrorText, setPageContent } from "../pageUtils.js";
|
||||
import { getSealStatus, submitUnsealKey } from "../api.js";
|
||||
|
||||
import { MarginInline } from "../elements/MarginInline.js";
|
||||
import { Page } from "../types/Page.js";
|
||||
import { QRScanner } from "../elements/QRScanner.js";
|
||||
import { changePage, setErrorText, setPageContent } from "../pageUtils.js";
|
||||
import { getSealStatus, submitUnsealKey } from "../api.js";
|
||||
import { makeElement } from "../htmlUtils.js";
|
||||
import i18next from 'i18next';
|
||||
|
||||
|
||||
const UnsealInputModes = {
|
||||
FORM_INPUT: "FORM_INPUT",
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
export { HomePage } from "./Home.js";
|
||||
export { LoginPage } from "./Login.js";
|
||||
export { SetVaultURLPage } from "./SetVaultURL.js";
|
||||
export { MePage } from "./Me.js";
|
||||
export { UnsealPage } from "./Unseal.js";
|
||||
export { PwGenPage } from "./PwGen.js";
|
||||
export { SetLanguagePage } from "./SetLanguage.js";
|
||||
export { TOTPViewPage } from "./TOTP/TOTPView.js";
|
||||
export { NewTOTPPage } from "./TOTP/NewTOTP.js";
|
||||
export { KeyValueViewPage } from "./KeyValue/KeyValueView.js";
|
||||
export { KeyValueSecretPage } from "./KeyValue/KeyValueSecret.js";
|
||||
export { KeyValueVersionsPage } from "./KeyValue/KeyValueVersions.js";
|
||||
export { KeyValueNewPage } from "./KeyValue/KeyValueNew.js";
|
||||
export { KeyValueDeletePage } from "./KeyValue/KeyValueDelete.js";
|
||||
export { KeyValueSecretEditPage } from "./KeyValue/KeyValueSecretsEdit.js";
|
||||
export { TransitViewPage } from "./Transit/TransitView.js";
|
||||
export { TransitViewSecretPage } from "./Transit/TransitViewSecret.js";
|
||||
export { TransitEncryptPage } from "./Transit/TransitEncrypt.js";
|
||||
export { TransitDecryptPage } from "./Transit/TransitDecrypt.js";
|
|
@ -18,12 +18,4 @@ export function verifyJSONString(str) {
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function getToken() {
|
||||
return pageState.token.length > 0 ? pageState.token : null;
|
||||
}
|
||||
|
||||
export function getAPIURL() {
|
||||
return pageState.apiURL.length > 0 ? pageState.apiURL : null;
|
||||
}
|
Loading…
Reference in a new issue