From ca9c215cac6cb6ee57233b03e66bccb79de7a0a0 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Wed, 12 Feb 2014 00:41:51 +0200 Subject: [PATCH] Use a random passphrase to encrypt the private key. Updates #111 --- converse.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/converse.js b/converse.js index b9e1b0eb7..ce0b6b34b 100644 --- a/converse.js +++ b/converse.js @@ -244,13 +244,6 @@ // Module-level functions // ---------------------- - // TODO: REMOVE - this.createLinks = function (text) { - // Convert URLs into hyperlinks - var re = /((http|https|ftp):\/\/[\w?=&.\/\-;#~%\-]+(?![\w\s?&.\/;#~%"=\-]*>))/g; - return text.replace(re, '$1'); - }; - this.giveFeedback = function (message, klass) { $('.conn-feedback').text(message); $('.conn-feedback').attr('class', 'conn-feedback'); @@ -319,7 +312,6 @@ this.reconnect = function () { converse.giveFeedback(__('Reconnecting'), 'error'); - // XXX: Couldn't get the prebind case to work here. if (!converse.prebind) { this.connection.connect( this.connection.jid, @@ -576,7 +568,17 @@ }, getSessionPassphrase: function () { - return converse.prebind ? converse.connection.jid : converse.connection.pass; + if (converse.prebind) { + var key = hex_sha1(converse.connection.jid), + pass = window.sessionStorage[key]; + if (typeof pass === 'undefined') { + pass = Math.floor(Math.random()*4294967295); + window.sessionStorage[key] = pass; + } + return pass; + } else { + return converse.connection.pass; + } }, generatePrivateKey: function (callback, instance_tag) { @@ -2930,8 +2932,7 @@ }, this), $.proxy(function (jid, fullname, img, img_type, url) { converse.log("Error while retrieving vcard"); - // XXX: Should vcard_updated be set here as - // well? + // XXX: Should vcard_updated be set here as well? this.add({ jid: bare_jid, subscription: 'none', @@ -2954,8 +2955,6 @@ var $presence = $(presence), presence_type = $presence.attr('type'); if (presence_type === 'error') { - // TODO - // error presence stanzas don't necessarily have a 'from' attr. return true; } var jid = $presence.attr('from'), @@ -3303,7 +3302,7 @@ } else if (stat === 'away') { pretty_status = __('away'); } else { - pretty_status = __(stat) || __('online'); // XXX: Is 'online' the right default choice here? + pretty_status = __(stat) || __('online'); } return pretty_status; },