diff --git a/src/allPages.ts b/src/allPages.ts index 0654cd8..8b23b12 100644 --- a/src/allPages.ts +++ b/src/allPages.ts @@ -13,7 +13,7 @@ import { PwGenPage } from "./pages/PwGen"; import { SetLanguagePage } from "./pages/SetLanguage"; import { SetVaultURLPage } from "./pages/SetVaultURL"; import { TOTPViewPage } from "./pages/TOTP/TOTPView"; -import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt.js"; +import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt"; import { TransitEncryptPage } from "./pages/Transit/TransitEncrypt.js"; import { TransitViewPage } from "./pages/Transit/TransitView"; import { TransitViewSecretPage } from "./pages/Transit/TransitViewSecret"; diff --git a/src/elements/Margin.ts b/src/elements/Margin.ts index 7421d29..450ca99 100644 --- a/src/elements/Margin.ts +++ b/src/elements/Margin.ts @@ -1,6 +1,6 @@ import { makeElement } from "../htmlUtils"; -export function Margin(children: null | Element | (Element | null[])): Element { +export function Margin(children: Element | Element[]): Element { return makeElement({ tag: "div", class: "uk-margin", diff --git a/src/elements/MarginInline.ts b/src/elements/MarginInline.ts index 729262e..84e7b96 100644 --- a/src/elements/MarginInline.ts +++ b/src/elements/MarginInline.ts @@ -1,6 +1,6 @@ import { makeElement } from "../htmlUtils"; -export function MarginInline(children: null | Element | (Element | null[])): Element { +export function MarginInline(children: Element | Element[]): Element { return makeElement({ tag: "div", class: "uk-margin", diff --git a/src/pages/Transit/TransitDecrypt.js b/src/pages/Transit/TransitDecrypt.ts similarity index 79% rename from src/pages/Transit/TransitDecrypt.js rename to src/pages/Transit/TransitDecrypt.ts index 73bccf1..4f31cd5 100644 --- a/src/pages/Transit/TransitDecrypt.js +++ b/src/pages/Transit/TransitDecrypt.ts @@ -3,7 +3,7 @@ import { Margin } from "../../elements/Margin"; import { Page } from "../../types/Page"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { makeElement } from "../../htmlUtils"; -import { pageState } from "../../globalPageState.ts"; +import { pageState } from "../../globalPageState"; import { transitDecrypt } from "../../api/transitDecrypt"; import UIkit from 'uikit/dist/js/uikit.min.js'; import i18next from "i18next"; @@ -12,10 +12,14 @@ export class TransitDecryptPage extends Page { constructor() { super(); } - goBack() { + + goBack(): void { changePage("TRANSIT_VIEW_SECRET"); } - async render() { + + transitDecryptForm: HTMLFormElement; + + async render(): Promise { setTitleElement(pageState); setPageContent(makeElement({ tag: "div" @@ -64,35 +68,35 @@ export class TransitDecryptPage extends Page { } }) ] - }); + }) as HTMLFormElement; setPageContent(this.transitDecryptForm); - this.transitDecryptForm.addEventListener("submit", function (e) { + this.transitDecryptForm.addEventListener("submit", function (e: Event) { e.preventDefault(); this.transitEncryptFormHandler(); }.bind(this)); } - transitEncryptFormHandler() { - let formData = new FormData(this.transitDecryptForm); + transitEncryptFormHandler(): void { + const formData = new FormData(this.transitDecryptForm); - transitDecrypt(pageState.currentBaseMount, pageState.currentSecret, formData.get("ciphertext")).then(res => { + transitDecrypt(pageState.currentBaseMount, pageState.currentSecret, formData.get("ciphertext") as string).then(res => { let plaintext = res.plaintext; - if (formData.get("decodeBase64Checkbox") == "on") { + if (formData.get("decodeBase64Checkbox") as string == "on") { plaintext = atob(plaintext); } - let modal = CopyableModal(i18next.t("transit_decrypt_decryption_result_modal_title"), plaintext); - pageContent.appendChild(modal); + const modal = CopyableModal(i18next.t("transit_decrypt_decryption_result_modal_title"), plaintext); + document.body.querySelector("#pageContent").appendChild(modal); UIkit.modal(modal).show(); }).catch(e => { setErrorText(`API Error: ${e.message}`); }); } - get titleSuffix() { + get titleSuffix(): string { return i18next.t("transit_decrypt_suffix"); } - get name() { + get name(): string { return i18next.t("transit_decrypt_title"); } }