summaryrefslogtreecommitdiff
path: root/keys.js
diff options
context:
space:
mode:
Diffstat (limited to 'keys.js')
-rw-r--r--keys.js49
1 files changed, 27 insertions, 22 deletions
diff --git a/keys.js b/keys.js
index 72ad6f9..1b64df2 100644
--- a/keys.js
+++ b/keys.js
@@ -13,7 +13,7 @@ window.rcmail && window.rcmail.addEventListener('init', function() {
.focus();
}
- rcmail.register_command('plugin.inbox_keys_generate', () => rcmail.inbox_keys_generate(), false);
+ rcmail.register_command('plugin.inbox_keys_generate', () => rcmail.inbox_keys_generate(), true);
rcmail.register_command('plugin.inbox_keys_import', () => rcmail.inbox_keys_import(), true);
rcmail.register_command('plugin.inbox_keys_delete', () => rcmail.inbox_keys_delete(), false);
}
@@ -24,8 +24,31 @@ rcube_webmail.prototype.inbox_keys_select = function(list) {
};
rcube_webmail.prototype.inbox_keys_generate = function() {
- // TODO: generate the key client-side and post it to the import endpoint,
- // TODO: then redirect the client to download the generated private key
+ var userIDs = [], passphrase;
+ var comment = 'Generated ' + (new Date()).toLocaleDateString();
+ var generating_message = this.display_message(
+ this.get_label('inbox_settings.generating_key'), 'loading');
+ openpgp.generateKey(
+ {
+ type: 'ecc',
+ curve: 'curve25519',
+ userIDs,
+ passphrase,
+ format: 'armored'
+ }).then(generated => {
+ this.hide_message(generating_message);
+ var lock = this.display_message(
+ this.get_label('inbox_settings.importing_key'), 'loading');
+ this.addEventListener('responseafter', () => {
+ location.href =
+ 'data:application/pgp-keys;base64,' + btoa(generated.privateKey);
+ this.reload(2000);
+ });
+ this.http_post(
+ 'plugin.inbox_keys_import',
+ {import: true, key_data: generated.publicKey, comment},
+ lock);
+ });
};
rcube_webmail.prototype.inbox_keys_import = function() {
@@ -42,25 +65,7 @@ rcube_webmail.prototype.inbox_keys_delete = function() {
function(_evt, ref) {
var lock = ref.display_message(
ref.get_label('inbox_settings.deleting_key', 'loading'));
- ref.addEventListener('responseafter', () => ref.reload(3000));
+ ref.addEventListener('responseafter', () => ref.reload(2000));
ref.http_post('plugin.inbox_keys_delete', {keys}, lock);
});
};
-
-rcube_webmail.prototype.inbox_keys_loadframe = function(url) {
- var win;
- if (win = this.get_frame_window(this.env.contentframe)) {
- if (!url) {
- if (win.location && win.location.href.indexOf(this.env.blankpage) < 0) {
- win.location.href = this.env.blankpage;
- }
- if (this.env.frame_lock) {
- this.set_busy(false, null, this.env.frame_lock);
- }
- return;
- }
-
- this.env.frame_lock = this.set_busy(true, 'loading');
- win.location.href = this.env.comm_path + '&_framed=1' + url;
- }
-};