Implement base64 decoding option on transit decrypt page.
This completes #14
This commit is contained in:
parent
b2c75cf1e6
commit
aa6ed9a3e2
|
@ -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");
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue