diff --git a/lib/client.js b/lib/client.js index efb4317c4..682262368 100644 --- a/lib/client.js +++ b/lib/client.js @@ -20,8 +20,11 @@ var utils = require("./utils"); var CRYPTO_ENABLED = false; -if (CRYPTO_ENABLED) { +try { var Olm = require("olm"); + CRYPTO_ENABLED = true; +} catch (e) { + // Olm not installed. } // TODO: @@ -1799,7 +1802,7 @@ MatrixClient.prototype.startClient = function(historyLen) { return; } - if (this.sessionStore !== null) { + if (CRYPTO_ENABLED && this.sessionStore !== null) { this.uploadKeys(5); } diff --git a/lib/matrix.js b/lib/matrix.js index bf50d2e8e..17b9018ec 100644 --- a/lib/matrix.js +++ b/lib/matrix.js @@ -28,7 +28,7 @@ module.exports.MatrixScheduler = require("./scheduler"); * ebStorageSessionStore} class */ module.exports.WebStorageSessionStore = require("./store/session/webstorage"); /** */ -module.exports.CRYPTO_ENABLED = require("./client").ENABLE_CRYPTO; +module.exports.CRYPTO_ENABLED = require("./client").CRYPTO_ENABLED; /** * Create a new Matrix Call.