diff --git a/src/main.js b/src/main.js index 78a28f7..b2ee597 100644 --- a/src/main.js +++ b/src/main.js @@ -125,6 +125,7 @@ document.addEventListener('DOMContentLoaded', function () { setInterval(async () => { if (pageState.currentPage != "UNSEAL") { + if (!localStorage.getItem('apiurl')) { return; } let sealStatus = await getSealStatus(); if (sealStatus.sealed) { changePage("UNSEAL"); diff --git a/src/pages/Transit/TransitDecrypt.js b/src/pages/Transit/TransitDecrypt.js index 8220603..f373c59 100644 --- a/src/pages/Transit/TransitDecrypt.js +++ b/src/pages/Transit/TransitDecrypt.js @@ -30,6 +30,24 @@ export class TransitDecryptPage extends Page { name: "ciphertext", } })), + Margin([ + makeElement({ + tag: "div", + class: "uk-form-label", + text: "Should the plaintext be base64 decoded?", + }), + makeElement({ + tag: "div", + class: ["uk-form-controls", "uk-form-controls-text"], + children: makeElement({ + tag: "input", + attributes: { + type: "checkbox", + name: "decodeBase64Checkbox", + } + }), + }), + ]), makeElement({ tag: "p", id: "errorText", @@ -56,7 +74,11 @@ export class TransitDecryptPage extends Page { let formData = new FormData(this.transitDecryptForm); transitDecrypt(pageState.currentBaseMount, pageState.currentSecret, formData.get("ciphertext")).then(res => { - let modal = CopyableModal("Decryption Result", res.plaintext); + let plaintext = res.plaintext; + if (formData.get("decodeBase64Checkbox") == "on") { + plaintext = atob(plaintext); + } + let modal = CopyableModal("Decryption Result", plaintext); pageContent.appendChild(modal); UIkit.modal(modal).show(); }).catch(e => { diff --git a/src/pages/Transit/TransitEncrypt.js b/src/pages/Transit/TransitEncrypt.js index 131f689..2cf2d71 100644 --- a/src/pages/Transit/TransitEncrypt.js +++ b/src/pages/Transit/TransitEncrypt.js @@ -41,7 +41,6 @@ export class TransitEncryptPage extends Page { class: ["uk-form-controls", "uk-form-controls-text"], children: makeElement({ tag: "input", - class: ["uk-checkbox"], attributes: { type: "checkbox", name: "base64Checkbox", @@ -74,7 +73,8 @@ export class TransitEncryptPage extends Page { transitEncryptFormHandler() { let formData = new FormData(this.transitEncryptForm); - let encodedData = formData.get("base64Checkbox") ? formData.get("plaintext") : btoa(formData.get("plaintext")); + let encodedData = + formData.get("base64Checkbox") == "on" ? formData.get("plaintext") : btoa(formData.get("plaintext")); transitEncrypt(pageState.currentBaseMount, pageState.currentSecret, encodedData).then(res => { console.log(res); let modal = CopyableModal("Encryption Result", res.ciphertext);