1
0
Fork 0

Make changePage async.

This commit is contained in:
Kitteh 2021-05-12 17:37:09 +01:00
parent 9c50ca2432
commit b3470be6f1
26 changed files with 119 additions and 127 deletions

View file

@ -28,12 +28,8 @@
"argsIgnorePattern": "^_" "argsIgnorePattern": "^_"
} }
], ],
"@typescript-eslint/no-empty-function": [ "@typescript-eslint/require-await": ["off"],
"error", "@typescript-eslint/no-empty-function": ["off"],
{
"allow": ["arrowFunctions"]
}
],
"@typescript-eslint/ban-ts-comment": ["off"], "@typescript-eslint/ban-ts-comment": ["off"],
"sort-imports-es6-autofix/sort-imports-es6": [2], "sort-imports-es6-autofix/sort-imports-es6": [2],
"@typescript-eslint/no-explicit-any": [2], "@typescript-eslint/no-explicit-any": [2],

View file

@ -22,8 +22,8 @@ export function NavBar(): HTMLElement {
makeElement({ makeElement({
tag: "a", tag: "a",
text: i18next.t("home_btn"), text: i18next.t("home_btn"),
onclick: () => { onclick: async () => {
changePage("HOME"); await changePage("HOME");
}, },
}), }),
), ),
@ -31,8 +31,8 @@ export function NavBar(): HTMLElement {
makeElement({ makeElement({
tag: "a", tag: "a",
text: i18next.t("back_btn"), text: i18next.t("back_btn"),
onclick: () => { onclick: async () => {
(pageState.currentPage as Page).goBack(); await (pageState.currentPage as Page).goBack();
}, },
}), }),
), ),
@ -40,8 +40,8 @@ export function NavBar(): HTMLElement {
makeElement({ makeElement({
tag: "a", tag: "a",
text: i18next.t("refresh_btn"), text: i18next.t("refresh_btn"),
onclick: () => { onclick: async () => {
changePage(pageState.currentPageString); await changePage(pageState.currentPageString);
}, },
}), }),
), ),
@ -59,8 +59,8 @@ export function NavBar(): HTMLElement {
makeElement({ makeElement({
tag: "a", tag: "a",
text: i18next.t("me_btn"), text: i18next.t("me_btn"),
onclick: () => { onclick: async () => {
changePage("ME"); await changePage("ME");
}, },
}), }),
), ),

View file

@ -37,7 +37,7 @@ declare global {
} }
} }
function onLoad(): void { async function onLoad(): Promise<void> {
document.body.innerHTML = ""; document.body.innerHTML = "";
document.body.appendChild(NavBar()); document.body.appendChild(NavBar());
document.body.appendChild( document.body.appendChild(
@ -66,10 +66,10 @@ function onLoad(): void {
window.pageContent = document.querySelector("#pageContent"); window.pageContent = document.querySelector("#pageContent");
if (process.env.NODE_ENV == "development") { if (process.env.NODE_ENV == "development") {
playground(); await playground();
} }
renderPage(); await renderPage();
setInterval(() => { setInterval(() => {
if (pageState.currentPageString != "UNSEAL") { if (pageState.currentPageString != "UNSEAL") {
@ -78,7 +78,7 @@ function onLoad(): void {
} }
void getSealStatus().then((sealStatus) => { void getSealStatus().then((sealStatus) => {
if (sealStatus.sealed) { if (sealStatus.sealed) {
changePage("UNSEAL"); void changePage("UNSEAL");
return; return;
} }
}); });
@ -110,7 +110,7 @@ document.addEventListener(
}, },
}) })
.then(function (_) { .then(function (_) {
onLoad(); void onLoad();
}); });
}, },
false, false,

View file

@ -10,24 +10,24 @@ import i18next from "i18next";
async function prePageChecksReal() { async function prePageChecksReal() {
if (pageState.language.length == 0) { if (pageState.language.length == 0) {
changePage("SET_LANGUAGE"); await changePage("SET_LANGUAGE");
throw new Error("Language Not Set"); throw new Error("Language Not Set");
} }
if (!pageState.apiURL) { if (!pageState.apiURL) {
changePage("SET_VAULT_URL"); await changePage("SET_VAULT_URL");
throw new Error("Vault URL Not Set"); throw new Error("Vault URL Not Set");
} }
const sealStatus = await getSealStatus(); const sealStatus = await getSealStatus();
if (sealStatus.sealed) { if (sealStatus.sealed) {
changePage("UNSEAL"); await changePage("UNSEAL");
throw new Error("Vault Sealed"); throw new Error("Vault Sealed");
} }
try { try {
await lookupSelf(); await lookupSelf();
} catch (e) { } catch (e) {
changePage("LOGIN"); await changePage("LOGIN");
throw e; throw e;
} }
} }
@ -78,22 +78,20 @@ export function setErrorText(text: string): void {
}); });
} }
export function changePage(page: string, shouldSwitch = true): void { export async function changePage(page: string): Promise<void> {
if (pageState.currentPage && shouldSwitch) { if (pageState.currentPage) {
(pageState.currentPage as Page).cleanup(); await (pageState.currentPage as Page).cleanup();
} }
pageState.currentPage = page; pageState.currentPage = page;
if (shouldSwitch) { await renderPage();
renderPage();
}
} }
export function renderPage(): void { export async function renderPage(): Promise<void> {
document.documentElement.dir = pageState.pageDirection; document.documentElement.dir = pageState.pageDirection;
console.log("Rendering Page: ", (pageState.currentPage as Page).name); console.log("Rendering Page: ", (pageState.currentPage as Page).name);
document.querySelector("#pageContent").innerHTML = ""; document.querySelector("#pageContent").innerHTML = "";
setPageTitle((pageState.currentPage as Page).name); setPageTitle((pageState.currentPage as Page).name);
(pageState.currentPage as Page).render(); await (pageState.currentPage as Page).render();
} }
export function setPageTitle(title: string | HTMLElement): void { export function setPageTitle(title: string | HTMLElement): void {
@ -121,7 +119,7 @@ export function setTitleElement(pageState: PageState): void {
makeElement({ makeElement({
tag: "a", tag: "a",
text: pageState.currentBaseMount + " ", text: pageState.currentBaseMount + " ",
onclick: () => { onclick: async () => {
pageState.currentSecretPath = []; pageState.currentSecretPath = [];
pageState.currentSecret = ""; pageState.currentSecret = "";
pageState.currentSecretVersion = null; pageState.currentSecretVersion = null;
@ -130,11 +128,11 @@ export function setTitleElement(pageState: PageState): void {
pageState.currentMountType.startsWith("kv") || pageState.currentMountType.startsWith("kv") ||
pageState.currentMountType == "cubbyhole" pageState.currentMountType == "cubbyhole"
) { ) {
changePage("KEY_VALUE_VIEW"); await changePage("KEY_VALUE_VIEW");
} else if (pageState.currentMountType == "totp") { } else if (pageState.currentMountType == "totp") {
changePage("TOTP"); await changePage("TOTP");
} else if (pageState.currentMountType == "transit") { } else if (pageState.currentMountType == "transit") {
changePage("TRANSIT_VIEW"); await changePage("TRANSIT_VIEW");
} }
}, },
}), }),
@ -142,11 +140,11 @@ export function setTitleElement(pageState: PageState): void {
return makeElement({ return makeElement({
tag: "a", tag: "a",
text: secretPath + " ", text: secretPath + " ",
onclick: () => { onclick: async () => {
pageState.currentSecretVersion = null; pageState.currentSecretVersion = null;
if (pageState.currentMountType.startsWith("kv")) { if (pageState.currentMountType.startsWith("kv")) {
pageState.currentSecretPath = secretPaths.slice(0, index + 1); pageState.currentSecretPath = secretPaths.slice(0, index + 1);
changePage("KEY_VALUE_VIEW"); await changePage("KEY_VALUE_VIEW");
} }
}, },
}); });

View file

@ -33,8 +33,8 @@ export class HomePage extends Page {
children: makeElement({ children: makeElement({
tag: "a", tag: "a",
text: i18next.t("password_generator_btn"), text: i18next.t("password_generator_btn"),
onclick: () => { onclick: async () => {
changePage("PW_GEN"); await changePage("PW_GEN");
}, },
}), }),
}), }),
@ -57,7 +57,7 @@ export class HomePage extends Page {
setErrorText(error.message); setErrorText(error.message);
if (error.message == "permission denied") { if (error.message == "permission denied") {
pageState.token = ""; pageState.token = "";
changePage("LOGIN"); await changePage("LOGIN");
} }
} }
@ -85,7 +85,7 @@ export class HomePage extends Page {
const mountType = mount.type == "kv" ? "kv-v" + String(mount.options.version) : mount.type; const mountType = mount.type == "kv" ? "kv-v" + String(mount.options.version) : mount.type;
let linkText = ""; let linkText = "";
let linkPage; let linkPage: string;
if (mount.type == "kv") { if (mount.type == "kv") {
linkText = `K/V (v${mount.options.version}) - ${baseMount}`; linkText = `K/V (v${mount.options.version}) - ${baseMount}`;
linkPage = "KEY_VALUE_VIEW"; linkPage = "KEY_VALUE_VIEW";
@ -106,10 +106,10 @@ export class HomePage extends Page {
children: makeElement({ children: makeElement({
tag: "a", tag: "a",
text: linkText, text: linkText,
onclick: () => { onclick: async () => {
pageState.currentBaseMount = baseMount; pageState.currentBaseMount = baseMount;
pageState.currentMountType = mountType; pageState.currentMountType = mountType;
changePage(linkPage); await changePage(linkPage);
}, },
}), }),
}), }),

View file

@ -9,16 +9,16 @@ export class KeyValueDeletePage extends Page {
constructor() { constructor() {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
if (pageState.currentSecretVersion != null) { if (pageState.currentSecretVersion != null) {
pageState.currentSecretVersion = null; pageState.currentSecretVersion = null;
changePage("KEY_VALUE_SECRET"); await changePage("KEY_VALUE_SECRET");
} else { } else {
pageState.currentSecret = ""; pageState.currentSecret = "";
changePage("KEY_VALUE_VIEW"); await changePage("KEY_VALUE_VIEW");
} }
} }
render(): void { async render(): Promise<void> {
setTitleElement(pageState); setTitleElement(pageState);
setPageContent( setPageContent(
makeElement({ makeElement({
@ -40,7 +40,7 @@ export class KeyValueDeletePage extends Page {
pageState.currentSecret, pageState.currentSecret,
pageState.currentSecretVersion, pageState.currentSecretVersion,
).then(() => { ).then(() => {
this.goBack(); void this.goBack();
}); });
}, },
}), }),

View file

@ -10,13 +10,13 @@ export class KeyValueNewPage extends Page {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
changePage("KEY_VALUE_VIEW"); await changePage("KEY_VALUE_VIEW");
} }
addKVNewForm: HTMLFormElement; addKVNewForm: HTMLFormElement;
render(): void { async render(): Promise<void> {
setTitleElement(pageState); setTitleElement(pageState);
this.addKVNewForm = makeElement({ this.addKVNewForm = makeElement({
tag: "form", tag: "form",
@ -76,7 +76,7 @@ export class KeyValueNewPage extends Page {
path, path,
keyData, keyData,
); );
changePage("KEY_VALUE_VIEW"); await changePage("KEY_VALUE_VIEW");
} catch (e: unknown) { } catch (e: unknown) {
const error = e as Error; const error = e as Error;
setErrorText(error.message); setErrorText(error.message);

View file

@ -14,13 +14,13 @@ export class KeyValueSecretPage extends Page {
constructor() { constructor() {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
if (pageState.currentSecretVersion != null) { if (pageState.currentSecretVersion != null) {
pageState.currentSecretVersion = null; pageState.currentSecretVersion = null;
changePage("KEY_VALUE_VERSIONS"); await changePage("KEY_VALUE_VERSIONS");
} else { } else {
pageState.currentSecret = ""; pageState.currentSecret = "";
changePage("KEY_VALUE_VIEW"); await changePage("KEY_VALUE_VIEW");
} }
} }
async render(): Promise<void> { async render(): Promise<void> {
@ -68,8 +68,8 @@ export class KeyValueSecretPage extends Page {
tag: "button", tag: "button",
id: "deleteButton", id: "deleteButton",
class: ["uk-button", "uk-button-danger"], class: ["uk-button", "uk-button-danger"],
onclick: () => { onclick: async () => {
changePage("KEY_VALUE_DELETE"); await changePage("KEY_VALUE_DELETE");
}, },
text: deleteButtonText, text: deleteButtonText,
}), }),
@ -82,8 +82,8 @@ export class KeyValueSecretPage extends Page {
tag: "button", tag: "button",
id: "editButton", id: "editButton",
class: ["uk-button", "uk-margin", "uk-button-primary"], class: ["uk-button", "uk-margin", "uk-button-primary"],
onclick: () => { onclick: async () => {
changePage("KEY_VALUE_SECRET_EDIT"); await changePage("KEY_VALUE_SECRET_EDIT");
}, },
text: i18next.t("kv_secret_edit_btn"), text: i18next.t("kv_secret_edit_btn"),
}), }),
@ -96,8 +96,8 @@ export class KeyValueSecretPage extends Page {
tag: "button", tag: "button",
id: "versionsButton", id: "versionsButton",
class: ["uk-button", "uk-button-secondary"], class: ["uk-button", "uk-button-secondary"],
onclick: () => { onclick: async () => {
changePage("KEY_VALUE_VERSIONS"); await changePage("KEY_VALUE_VERSIONS");
}, },
text: i18next.t("kv_secret_versions_btn"), text: i18next.t("kv_secret_versions_btn"),
}), }),
@ -135,7 +135,7 @@ export class KeyValueSecretPage extends Page {
pageState.currentSecret, pageState.currentSecret,
pageState.currentSecretVersion, pageState.currentSecretVersion,
).then((_) => { ).then((_) => {
changePage(pageState.currentPageString); void changePage(pageState.currentPageString);
}); });
}, },
}), }),

View file

@ -12,10 +12,10 @@ export class KeyValueSecretEditPage extends Page {
constructor() { constructor() {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
changePage("KEY_VALUE_SECRET"); await changePage("KEY_VALUE_SECRET");
} }
render(): void { async render(): Promise<void> {
setTitleElement(pageState); setTitleElement(pageState);
const loadingText = makeElement({ const loadingText = makeElement({
tag: "p", tag: "p",
@ -71,7 +71,7 @@ export class KeyValueSecretEditPage extends Page {
JSON.parse(jar.toString()), JSON.parse(jar.toString()),
) )
.then((_) => { .then((_) => {
changePage("KEY_VALUE_SECRET"); void changePage("KEY_VALUE_SECRET");
return; return;
}) })
.catch((e: Error) => { .catch((e: Error) => {

View file

@ -10,11 +10,11 @@ export class KeyValueVersionsPage extends Page {
constructor() { constructor() {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
if (pageState.currentSecretVersion != null) { if (pageState.currentSecretVersion != null) {
pageState.currentSecretVersion = null; pageState.currentSecretVersion = null;
} }
changePage("KEY_VALUE_SECRET"); await changePage("KEY_VALUE_SECRET");
} }
async render(): Promise<void> { async render(): Promise<void> {
setTitleElement(pageState); setTitleElement(pageState);
@ -39,9 +39,9 @@ export class KeyValueVersionsPage extends Page {
children: makeElement({ children: makeElement({
tag: "a", tag: "a",
text: `v${ver}`, text: `v${ver}`,
onclick: () => { onclick: async () => {
pageState.currentSecretVersion = ver; pageState.currentSecretVersion = ver;
changePage("KEY_VALUE_SECRET"); await changePage("KEY_VALUE_SECRET");
}, },
}), }),
}), }),

View file

@ -10,12 +10,12 @@ export class KeyValueViewPage extends Page {
constructor() { constructor() {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
if (pageState.currentSecretPath.length != 0) { if (pageState.currentSecretPath.length != 0) {
pageState.popCurrentSecretPath(); pageState.popCurrentSecretPath();
changePage("KEY_VALUE_VIEW"); await changePage("KEY_VALUE_VIEW");
} else { } else {
changePage("HOME"); await changePage("HOME");
} }
} }
async render(): Promise<void> { async render(): Promise<void> {
@ -39,8 +39,8 @@ export class KeyValueViewPage extends Page {
tag: "button", tag: "button",
text: i18next.t("kv_view_new_btn"), text: i18next.t("kv_view_new_btn"),
class: ["uk-button", "uk-button-primary", "uk-margin-bottom"], class: ["uk-button", "uk-button-primary", "uk-margin-bottom"],
onclick: () => { onclick: async () => {
changePage("KEY_VALUE_NEW_SECRET"); await changePage("KEY_VALUE_NEW_SECRET");
}, },
}); });
kvViewPageContent.appendChild(newButton); kvViewPageContent.appendChild(newButton);
@ -63,13 +63,13 @@ export class KeyValueViewPage extends Page {
children: makeElement({ children: makeElement({
tag: "a", tag: "a",
text: secret, text: secret,
onclick: () => { onclick: async () => {
if (secret.endsWith("/")) { if (secret.endsWith("/")) {
pageState.pushCurrentSecretPath(secret); pageState.pushCurrentSecretPath(secret);
changePage("KEY_VALUE_VIEW"); await changePage("KEY_VALUE_VIEW");
} else { } else {
pageState.currentSecret = secret; pageState.currentSecret = secret;
changePage("KEY_VALUE_SECRET"); await changePage("KEY_VALUE_SECRET");
} }
}, },
}), }),

View file

@ -12,7 +12,7 @@ export class LoginPage extends Page {
constructor() { constructor() {
super(); super();
} }
render(): void { async render(): Promise<void> {
const tokenLoginForm = makeElement({ const tokenLoginForm = makeElement({
tag: "form", tag: "form",
children: [ children: [
@ -139,7 +139,7 @@ export class LoginPage extends Page {
pageState.token = token as string; pageState.token = token as string;
lookupSelf() lookupSelf()
.then((_) => { .then((_) => {
changePage("HOME"); void changePage("HOME");
}) })
.catch((e: Error) => { .catch((e: Error) => {
document.getElementById("tokenInput").classList.add("uk-form-danger"); document.getElementById("tokenInput").classList.add("uk-form-danger");
@ -156,7 +156,7 @@ export class LoginPage extends Page {
usernameLogin(formData.get("username") as string, formData.get("password") as string) usernameLogin(formData.get("username") as string, formData.get("password") as string)
.then((res) => { .then((res) => {
pageState.token = res; pageState.token = res;
changePage("HOME"); void changePage("HOME");
}) })
.catch((e: Error) => { .catch((e: Error) => {
document.getElementById("usernameInput").classList.add("uk-form-danger"); document.getElementById("usernameInput").classList.add("uk-form-danger");

View file

@ -31,9 +31,9 @@ export class MePage extends Page {
children: makeElement({ children: makeElement({
tag: "a", tag: "a",
text: i18next.t("log_out_btn"), text: i18next.t("log_out_btn"),
onclick: () => { onclick: async () => {
pageState.token = ""; pageState.token = "";
changePage("HOME"); await changePage("HOME");
}, },
}), }),
}), }),
@ -59,7 +59,7 @@ export class MePage extends Page {
onclick: () => { onclick: () => {
renewSelf() renewSelf()
.then(() => { .then(() => {
changePage("HOME"); void changePage("HOME");
}) })
.catch((e: Error) => { .catch((e: Error) => {
setErrorText(e.message); setErrorText(e.message);
@ -82,7 +82,7 @@ export class MePage extends Page {
text: i18next.t("seal_vault_btn"), text: i18next.t("seal_vault_btn"),
onclick: async () => { onclick: async () => {
await sealVault(); await sealVault();
changePage("UNSEAL_VAULT"); await changePage("UNSEAL_VAULT");
}, },
}), }),
}), }),
@ -91,8 +91,8 @@ export class MePage extends Page {
children: makeElement({ children: makeElement({
tag: "a", tag: "a",
text: i18next.t("change_language_btn"), text: i18next.t("change_language_btn"),
onclick: () => { onclick: async () => {
changePage("SET_LANGUAGE"); await changePage("SET_LANGUAGE");
}, },
}), }),
}), }),

View file

@ -58,7 +58,7 @@ export class PwGenPage extends Page {
passwordAlphabet: HTMLSelectElement; passwordAlphabet: HTMLSelectElement;
passwordForm: HTMLFormElement; passwordForm: HTMLFormElement;
render(): void { async render(): Promise<void> {
setPageContent(""); setPageContent("");
this.passwordBox = CopyableInputBox(genPassword(passwordOptionsDefault)); this.passwordBox = CopyableInputBox(genPassword(passwordOptionsDefault));
@ -135,7 +135,7 @@ export class PwGenPage extends Page {
); );
} }
cleanup(): void { async cleanup(): Promise<void> {
this.passwordBox = undefined; this.passwordBox = undefined;
this.passwordLengthTitle = undefined; this.passwordLengthTitle = undefined;
this.passwordLengthRange = undefined; this.passwordLengthRange = undefined;

View file

@ -15,7 +15,7 @@ export class SetLanguagePage extends Page {
constructor() { constructor() {
super(); super();
} }
render(): void { async render(): Promise<void> {
const setLanguageForm = makeElement({ const setLanguageForm = makeElement({
tag: "form", tag: "form",
id: "setLanguageForm", id: "setLanguageForm",
@ -61,7 +61,7 @@ export class SetLanguagePage extends Page {
void i18next.changeLanguage(language).then((t) => { void i18next.changeLanguage(language).then((t) => {
pageState.pageDirection = t("language_direction"); pageState.pageDirection = t("language_direction");
reloadNavBar(); reloadNavBar();
changePage("HOME"); void changePage("HOME");
}); });
}); });
} }

View file

@ -7,7 +7,7 @@ export class SetVaultURLPage extends Page {
constructor() { constructor() {
super(); super();
} }
render(): void { async render(): Promise<void> {
setPageContent( setPageContent(
makeElement({ makeElement({
tag: "form", tag: "form",
@ -47,7 +47,7 @@ export class SetVaultURLPage extends Page {
e.preventDefault(); e.preventDefault();
const formData = new FormData(document.querySelector("#setVaultURLForm")); const formData = new FormData(document.querySelector("#setVaultURLForm"));
pageState.apiURL = formData.get("vaultURL") as string; pageState.apiURL = formData.get("vaultURL") as string;
changePage("HOME"); void changePage("HOME");
}); });
} }
get name(): string { get name(): string {

View file

@ -20,10 +20,10 @@ export class NewTOTPPage extends Page {
constructor() { constructor() {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
changePage("TOTP"); await changePage("TOTP");
} }
render(): void { async render(): Promise<void> {
setTitleElement(pageState); setTitleElement(pageState);
const totpForm = makeElement({ const totpForm = makeElement({
@ -97,7 +97,7 @@ export class NewTOTPPage extends Page {
}; };
addNewTOTP(pageState.currentBaseMount, parms) addNewTOTP(pageState.currentBaseMount, parms)
.then((_) => { .then((_) => {
changePage("TOTP"); void changePage("TOTP");
}) })
.catch((e: Error) => { .catch((e: Error) => {
setErrorText(`API Error: ${e.message}`); setErrorText(`API Error: ${e.message}`);

View file

@ -34,7 +34,7 @@ export class TOTPViewPage extends Page {
tag: "a", tag: "a",
text: i18next.t("totp_view_new_btn"), text: i18next.t("totp_view_new_btn"),
onclick: () => { onclick: () => {
changePage("NEW_TOTP"); void changePage("NEW_TOTP");
}, },
}), }),
makeElement({ makeElement({
@ -51,7 +51,8 @@ export class TOTPViewPage extends Page {
try { try {
const res = await getTOTPKeys(pageState.currentBaseMount); const res = await getTOTPKeys(pageState.currentBaseMount);
for (const totpKeyName in res.entries()) { for (const totpKeyName of res) {
console.log(totpKeyName);
const totpListElement = this.makeTOTPListElement(totpKeyName); const totpListElement = this.makeTOTPListElement(totpKeyName);
totpList.appendChild(totpListElement); totpList.appendChild(totpListElement);
this.totpListElements[totpKeyName] = totpListElement; this.totpListElements[totpKeyName] = totpListElement;
@ -81,7 +82,7 @@ export class TOTPViewPage extends Page {
}, 3000) as unknown as number; }, 3000) as unknown as number;
} }
cleanup(): void { async cleanup(): Promise<void> {
clearInterval(this.refresher); clearInterval(this.refresher);
this.totpListElements = {}; this.totpListElements = {};
} }

View file

@ -13,13 +13,13 @@ export class TransitDecryptPage extends Page {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
changePage("TRANSIT_VIEW_SECRET"); await changePage("TRANSIT_VIEW_SECRET");
} }
transitDecryptForm: HTMLFormElement; transitDecryptForm: HTMLFormElement;
render(): void { async render(): Promise<void> {
setTitleElement(pageState); setTitleElement(pageState);
setPageContent( setPageContent(
makeElement({ makeElement({

View file

@ -13,13 +13,13 @@ export class TransitEncryptPage extends Page {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
changePage("TRANSIT_VIEW_SECRET"); await changePage("TRANSIT_VIEW_SECRET");
} }
transitEncryptForm: HTMLFormElement; transitEncryptForm: HTMLFormElement;
render(): void { async render(): Promise<void> {
setTitleElement(pageState); setTitleElement(pageState);
setPageContent( setPageContent(
makeElement({ makeElement({

View file

@ -17,8 +17,8 @@ export class TransitRewrapPage extends Page {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
changePage("TRANSIT_VIEW_SECRET"); await changePage("TRANSIT_VIEW_SECRET");
} }
transitRewrapForm: HTMLFormElement; transitRewrapForm: HTMLFormElement;

View file

@ -11,8 +11,8 @@ export class TransitViewPage extends Page {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
changePage("HOME"); await changePage("HOME");
} }
async render(): Promise<void> { async render(): Promise<void> {
@ -28,7 +28,7 @@ export class TransitViewPage extends Page {
text: "New", text: "New",
class: ["uk-button", "uk-button-primary", "uk-margin-bottom"], class: ["uk-button", "uk-button-primary", "uk-margin-bottom"],
onclick: () => { onclick: () => {
changePage("TRANSIT_NEW_KEY"); void changePage("TRANSIT_NEW_KEY");
}, },
}); });
transitViewContent.appendChild(newButton); transitViewContent.appendChild(newButton);
@ -49,7 +49,7 @@ export class TransitViewPage extends Page {
text: secret, text: secret,
onclick: () => { onclick: () => {
pageState.currentSecret = secret; pageState.currentSecret = secret;
changePage("TRANSIT_VIEW_SECRET"); void changePage("TRANSIT_VIEW_SECRET");
}, },
}), }),
}); });

View file

@ -11,8 +11,8 @@ export class TransitViewSecretPage extends Page {
super(); super();
} }
goBack(): void { async goBack(): Promise<void> {
changePage("TRANSIT_VIEW"); await changePage("TRANSIT_VIEW");
} }
async render(): Promise<void> { async render(): Promise<void> {
@ -33,7 +33,7 @@ export class TransitViewSecretPage extends Page {
icon: "lock", icon: "lock",
iconText: i18next.t("transit_view_encrypt_icon_text"), iconText: i18next.t("transit_view_encrypt_icon_text"),
onclick: () => { onclick: () => {
changePage("TRANSIT_ENCRYPT"); void changePage("TRANSIT_ENCRYPT");
}, },
}), }),
Tile({ Tile({
@ -43,7 +43,7 @@ export class TransitViewSecretPage extends Page {
icon: "mail", icon: "mail",
iconText: i18next.t("transit_view_decrypt_icon_text"), iconText: i18next.t("transit_view_decrypt_icon_text"),
onclick: () => { onclick: () => {
changePage("TRANSIT_DECRYPT"); void changePage("TRANSIT_DECRYPT");
}, },
}), }),
Tile({ Tile({
@ -53,7 +53,7 @@ export class TransitViewSecretPage extends Page {
icon: "code", icon: "code",
iconText: i18next.t("transit_view_rewrap_icon_text"), iconText: i18next.t("transit_view_rewrap_icon_text"),
onclick: () => { onclick: () => {
changePage("TRANSIT_REWRAP"); void changePage("TRANSIT_REWRAP");
}, },
}), }),
], ],

View file

@ -26,7 +26,7 @@ export class UnsealPage extends Page {
unsealInputContent: HTMLElement; unsealInputContent: HTMLElement;
unsealKeyForm: HTMLFormElement; unsealKeyForm: HTMLFormElement;
cleanup(): void { async cleanup(): Promise<void> {
this.deinitWebcam(); this.deinitWebcam();
clearInterval(this.refresher); clearInterval(this.refresher);
} }
@ -169,7 +169,7 @@ export class UnsealPage extends Page {
progressBar.max = keysNeeded; progressBar.max = keysNeeded;
if (!data.sealed) { if (!data.sealed) {
progressBar.value = keysNeeded; progressBar.value = keysNeeded;
changePage("HOME"); void changePage("HOME");
} }
} }

View file

@ -15,7 +15,7 @@ declare global {
} }
// Please empty this function before committing. // Please empty this function before committing.
export function playground(): void { export async function playground(): Promise<void> {
console.log("Welcome to Playground!"); console.log("Welcome to Playground!");
window.pageState = pageState; window.pageState = pageState;
window.i18next = i18next; window.i18next = i18next;

View file

@ -4,20 +4,17 @@ export class Page {
constructor() { constructor() {
// Do Nothing // Do Nothing
} }
render(): unknown { async render(): Promise<void> {}
// Do Nothing
return null;
}
get name(): string { get name(): string {
return "Page"; return "Page";
} }
get titleSuffix(): string { get titleSuffix(): string {
return ""; return "";
} }
goBack(): void { async goBack(): Promise<void> {
changePage("HOME"); await changePage("HOME");
} }
cleanup(): void { async cleanup(): Promise<void> {
// Do Nothing // Do Nothing
} }
} }