diff --git a/src/index.html b/src/index.html
index be72874..26ca981 100644
--- a/src/index.html
+++ b/src/index.html
@@ -135,7 +135,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -145,7 +145,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
Remote Signature Pad Connection
+
Remote Signature Pad Connection
@@ -158,12 +158,12 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
+
@@ -271,7 +271,22 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/js/crypto.js b/src/js/crypto.js
index d300263..75cf834 100644
--- a/src/js/crypto.js
+++ b/src/js/crypto.js
@@ -20,27 +20,29 @@ function loadKeyFromLocalStorage(callback) {
}
$("#lockstatus").css("display", "none");
if (!inStorage("signingkey") || getStorage("signingkey") == "undefined") {
- var pass = prompt("Generating a new signing key (might take a while, be patient). Enter a password to protect it. You'll need to save this password somewhere safe; it cannot be recovered.");
- generatePrivateKey(getStorage("notary_name") + " ", pass, function (key) {
- if (typeof key == "undefined") {
- callback("Could not generate key.", false);
- return;
- }
- keymgr = key;
- keyring.add_key_manager(keymgr);
- setStorage("signingkey", keymgr.armored_pgp_private);
- callback("Signing key generated.", true);
+ showPasswordPrompt("Generating a new signing key (might take a while, be patient). Enter a password to protect it. You'll need to save this password somewhere safe; it cannot be recovered.", function (pass) {
+ generatePrivateKey(getStorage("notary_name") + " ", pass, function (key) {
+ if (typeof key == "undefined") {
+ callback("Could not generate key.", false);
+ return;
+ }
+ keymgr = key;
+ keyring.add_key_manager(keymgr);
+ setStorage("signingkey", keymgr.armored_pgp_private);
+ callback("Signing key generated.", true);
+ });
});
} else {
- var pass = prompt("Enter password to unlock signing key:");
- loadPrivateKey(getStorage("signingkey"), pass, function (key) {
- if (typeof key == "undefined") {
- callback("Could not unlock key. Password is probably incorrect.", false);
- return;
- }
- keymgr = key;
- keyring.add_key_manager(keymgr);
- callback("Signing key unlocked.", true);
+ showPasswordPrompt("Enter password to unlock signing key:", function (pass) {
+ loadPrivateKey(getStorage("signingkey"), pass, function (key) {
+ if (typeof key == "undefined") {
+ callback("Could not unlock key. Password is probably incorrect.", false);
+ return;
+ }
+ keymgr = key;
+ keyring.add_key_manager(keymgr);
+ callback("Signing key unlocked.", true);
+ });
});
}
}
@@ -201,42 +203,44 @@ function exportPublicKey() {
}
function exportPrivateKey() {
- var pass = prompt("Enter password for private key:");
- const savepriv = function (key) {
- var pass2 = prompt("Enter a password to protect the key backup:");
- openSaveFileDialog(function (path) {
- key.export_pgp_private({
- passphrase: pass2
- }, function (err, pgp_private) {
- if (err) {
- showAlert("Something went wrong.");
- } else {
- writeToFile(path, pgp_private);
- }
+ showPasswordPrompt("Enter password for private key:", function (pass) {
+ const savepriv = function (key) {
+ showPasswordPrompt("Enter a password to protect the key backup:", function (pass2) {
+ openSaveFileDialog(function (path) {
+ key.export_pgp_private({
+ passphrase: pass2
+ }, function (err, pgp_private) {
+ if (err) {
+ showAlert("Something went wrong.");
+ } else {
+ writeToFile(path, pgp_private);
+ }
+ });
+ }, "private-key.asc", ".asc");
});
- }, "private-key.asc", ".asc");
- }
- kbpgp.KeyManager.import_from_armored_pgp({
- armored: getStorage("signingkey")
- }, function (err, key) {
- if (!err) {
- if (key.is_pgp_locked()) {
- key.unlock_pgp({
- passphrase: pass
- }, function (err) {
- if (!err) {
- savepriv(key);
- } else {
- showAlert("Could not unlock key. Password is probably incorrect.");
- }
- });
- } else {
- console.log("Loaded private key w/o passphrase");
- savepriv(key);
- }
- } else {
- showAlert("Could not unlock key: " + err);
}
+ kbpgp.KeyManager.import_from_armored_pgp({
+ armored: getStorage("signingkey")
+ }, function (err, key) {
+ if (!err) {
+ if (key.is_pgp_locked()) {
+ key.unlock_pgp({
+ passphrase: pass
+ }, function (err) {
+ if (!err) {
+ savepriv(key);
+ } else {
+ showAlert("Could not unlock key. Password is probably incorrect.");
+ }
+ });
+ } else {
+ console.log("Loaded private key w/o passphrase");
+ savepriv(key);
+ }
+ } else {
+ showAlert("Could not unlock key: " + err);
+ }
+ });
});
}
@@ -249,15 +253,16 @@ function importPrivateKey() {
keymgr = null;
openFileDialog(function (path) {
var keyfile = getFileAsString(path);
- var pass = prompt("Enter password for imported key (password was set when exported):");
- loadPrivateKey(keyfile, pass, function (key) {
- if (typeof key == "undefined") {
- showAlert("Could not import key. Password is probably incorrect.");
- return;
- }
- keymgr = key;
- setStorage("signingkey", keymgr.armored_pgp_private);
- showAlert("Private key imported.");
+ showPasswordPrompt("Enter password for imported key (password was set when exported):", function (pass) {
+ loadPrivateKey(keyfile, pass, function (key) {
+ if (typeof key == "undefined") {
+ showAlert("Could not import key. Password is probably incorrect.");
+ return;
+ }
+ keymgr = key;
+ setStorage("signingkey", keymgr.armored_pgp_private);
+ showAlert("Private key imported.");
+ });
});
}, ".asc");
}
diff --git a/src/js/main.js b/src/js/main.js
index 33015d0..6ee868a 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -242,6 +242,25 @@ function showAlert(message) {
new bootstrap.Modal(document.getElementById('alertModal')).show();
}
+var passwordModalCallback = function (pass) {};
+
+function showPasswordPrompt(message, callback) {
+ $("#passwordModalText").html(message);
+ $("#passwordModalInput").val("");
+ passwordModalCallback = callback;
+ new bootstrap.Modal(document.getElementById('passwordModal')).show();
+}
+
+$("#passwordModal").on("shown.bs.modal", function () {
+ $("#passwordModalInput").focus();
+});
+
+$(".modal").on("keydown", function (e) {
+ if (e.keyCode == 13) {
+ $(this).find(".btn-default").first().click();
+ }
+});
+
$(document).ready(function () {
setButtonSize(getStorage("button_size"));
setAppTheme(getStorage("color_theme"));