index : matrix-js-sdk

My fork of matrix-js-sdk

diff options
context:
space:
mode:
authorHubert Chathi <[email protected]>2020-06-16 11:38:36 -0400
committerHubert Chathi <[email protected]>2020-06-16 11:38:36 -0400
commit2d73564eba62f0840241f1ebf4991f9acdefa5df (patch)
tree7c6ae5616b1e037d43daefb8594f85c1045a5001
parentfd126b8563cd85878cda458fa8fe0507dc29d942 (diff)
downloadmatrix-js-sdk-2d73564eba62f0840241f1ebf4991f9acdefa5df.tar.gz
apply feedback from review, and improve js docs
-rw-r--r--src/crypto/OlmDevice.js5
-rw-r--r--src/crypto/algorithms/megolm.js9
-rw-r--r--src/crypto/index.js2
-rw-r--r--src/models/event.js8
4 files changed, 14 insertions, 10 deletions
diff --git a/src/crypto/OlmDevice.js b/src/crypto/OlmDevice.js
index 38e2783e..774d696b 100644
--- a/src/crypto/OlmDevice.js
+++ b/src/crypto/OlmDevice.js
@@ -992,14 +992,13 @@ OlmDevice.prototype._getInboundGroupSession = function(
* @param {Object<string, string>} keysClaimed Other keys the sender claims.
* @param {boolean} exportFormat true if the megolm keys are in export format
* (ie, they lack an ed25519 signature)
- * @param {Object} extraSessionData any other data to be include with the session
+ * @param {Object} [extraSessionData={}] any other data to be include with the session
*/
OlmDevice.prototype.addInboundGroupSession = async function(
roomId, senderKey, forwardingCurve25519KeyChain,
sessionId, sessionKey, keysClaimed,
- exportFormat, extraSessionData,
+ exportFormat, extraSessionData = {},
) {
- extraSessionData = extraSessionData || {};
await this._cryptoStore.doTxn(
'readwrite', [
IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,
diff --git a/src/crypto/algorithms/megolm.js b/src/crypto/algorithms/megolm.js
index b8d0572d..a7c3d717 100644
--- a/src/crypto/algorithms/megolm.js
+++ b/src/crypto/algorithms/megolm.js
@@ -1549,12 +1549,11 @@ MegolmDecryption.prototype._buildKeyForwardingMessage = async function(
* @inheritdoc
*
* @param {module:crypto/OlmDevice.MegolmSessionData} session
- * @param {object} opts options for the import
- * @param {boolean} opts.untrusted whether the key should be considered as untrusted
- * @param {string} opts.source where the key came from
+ * @param {object} [opts={}] options for the import
+ * @param {boolean} [opts.untrusted] whether the key should be considered as untrusted
+ * @param {string} [opts.source where] the key came from
*/
-MegolmDecryption.prototype.importRoomKey = function(session, opts) {
- opts = opts || {};
+MegolmDecryption.prototype.importRoomKey = function(session, opts = {}) {
return this._olmDevice.addInboundGroupSession(
session.room_id,
session.sender_key,
diff --git a/src/crypto/index.js b/src/crypto/index.js
index a0d943ae..238f1a3e 100644
--- a/src/crypto/index.js
+++ b/src/crypto/index.js
@@ -2243,7 +2243,7 @@ Crypto.prototype.getEventSenderDeviceInfo = function(event) {
return null;
}
- if (event.isUntrusted()) {
+ if (event.isKeySourceUntrusted()) {
// we got the key for this event from a source that we consider untrusted
return null;
}
diff --git a/src/models/event.js b/src/models/event.js
index 915b3fe8..73ea735d 100644
--- a/src/models/event.js
+++ b/src/models/event.js
@@ -694,7 +694,13 @@ utils.extend(MatrixEvent.prototype, {
return this._forwardingCurve25519KeyChain;
},
- isUntrusted: function() {
+ /**
+ * Whether the decryption key was obtained from an untrusted source. If so,
+ * we cannot verify the authenticity of the message.
+ *
+ * @return {boolean}
+ */
+ isKeySourceUntrusted: function() {
return this._untrusted;
},