Commit 490d96fd authored by JC Brand's avatar JC Brand

Don't load the Crypto libraries if the browser doesn't have CSRNG

parent 5da32a59
Changelog
=========
0.7.1 (Unreleased)
------------------
* Don't load OTR crypto if the browser doesn't have a CSRNG [jcbrand]
0.7.0 (2013-11-13)
------------------
......
......@@ -12,7 +12,7 @@
console = { log: function () {}, error: function () {} };
}
if (typeof define === 'function' && define.amd) {
define("converse", [
var dependencies = [
"crypto",
"otr",
"locales",
......@@ -23,13 +23,27 @@
"strophe.roster",
"strophe.vcard",
"strophe.disco"
], function(CryptoJS, otr) {
];
if ((typeof crypto === 'undefined') ||
( (typeof crypto.randomBytes !== 'function') &&
(typeof crypto.getRandomValues !== 'function')
)) {
// Don't load crypto stuff if the browser doesn't have a CSRNG
dependencies.splice(0, 2);
}
define("converse", dependencies, function(CryptoJS, otr) {
// Use Mustache style syntax for variable interpolation
_.templateSettings = {
evaluate : /\{\[([\s\S]+?)\]\}/g,
interpolate : /\{\{([\s\S]+?)\}\}/g
};
if (typeof otr !== "undefined") {
return factory(jQuery, _, CryptoJS, otr.OTR, otr.DSA, console);
} else {
return factory(jQuery, _, undefined, undefined, undefined, console);
}
}
);
} else {
......@@ -54,6 +68,11 @@
var KEY = {
ENTER: 13
};
var HAS_CRYPTO = (
(typeof CryptoJS !== "undefined") &&
(typeof OTR !== "undefined") &&
(typeof DSA !== "undefined")
);
// Default configuration values
// ----------------------------
......@@ -105,6 +124,9 @@
'xhr_user_search_url'
]));
// Only allow OTR if we have the capability
this.allow_otr = this.allow_otr && HAS_CRYPTO;
// Translation machinery
// ---------------------
var __ = $.proxy(function (str) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment