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 () => {
|
setInterval(async () => {
|
||||||
if (pageState.currentPage != "UNSEAL") {
|
if (pageState.currentPage != "UNSEAL") {
|
||||||
|
if (!localStorage.getItem('apiurl')) { return; }
|
||||||
let sealStatus = await getSealStatus();
|
let sealStatus = await getSealStatus();
|
||||||
if (sealStatus.sealed) {
|
if (sealStatus.sealed) {
|
||||||
changePage("UNSEAL");
|
changePage("UNSEAL");
|
||||||
|
|
|
@ -30,6 +30,24 @@ export class TransitDecryptPage extends Page {
|
||||||
name: "ciphertext",
|
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({
|
makeElement({
|
||||||
tag: "p",
|
tag: "p",
|
||||||
id: "errorText",
|
id: "errorText",
|
||||||
|
@ -56,7 +74,11 @@ export class TransitDecryptPage extends Page {
|
||||||
let formData = new FormData(this.transitDecryptForm);
|
let formData = new FormData(this.transitDecryptForm);
|
||||||
|
|
||||||
transitDecrypt(pageState.currentBaseMount, pageState.currentSecret, formData.get("ciphertext")).then(res => {
|
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);
|
pageContent.appendChild(modal);
|
||||||
UIkit.modal(modal).show();
|
UIkit.modal(modal).show();
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
|
|
|
@ -41,7 +41,6 @@ export class TransitEncryptPage extends Page {
|
||||||
class: ["uk-form-controls", "uk-form-controls-text"],
|
class: ["uk-form-controls", "uk-form-controls-text"],
|
||||||
children: makeElement({
|
children: makeElement({
|
||||||
tag: "input",
|
tag: "input",
|
||||||
class: ["uk-checkbox"],
|
|
||||||
attributes: {
|
attributes: {
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
name: "base64Checkbox",
|
name: "base64Checkbox",
|
||||||
|
@ -74,7 +73,8 @@ export class TransitEncryptPage extends Page {
|
||||||
|
|
||||||
transitEncryptFormHandler() {
|
transitEncryptFormHandler() {
|
||||||
let formData = new FormData(this.transitEncryptForm);
|
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 => {
|
transitEncrypt(pageState.currentBaseMount, pageState.currentSecret, encodedData).then(res => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
let modal = CopyableModal("Encryption Result", res.ciphertext);
|
let modal = CopyableModal("Encryption Result", res.ciphertext);
|
||||||
|
|
Loading…
Reference in a new issue