1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-07 23:02:56 +03:00

Merge branch 'develop' into fix/12652/screen-share

This commit is contained in:
Šimon Brandner
2021-05-27 18:23:22 +02:00
111 changed files with 770 additions and 790 deletions

View File

@@ -1,3 +1,26 @@
Changes in [11.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v11.1.0) (2021-05-24)
==================================================================================================
[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v11.1.0-rc.1...v11.1.0)
* [Release] Bump libolm version and update package name
[\#1707](https://github.com/matrix-org/matrix-js-sdk/pull/1707)
* [Release] Change call event handlers to adapt to undecrypted events
[\#1699](https://github.com/matrix-org/matrix-js-sdk/pull/1699)
Changes in [11.1.0-rc.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v11.1.0-rc.1) (2021-05-19)
============================================================================================================
[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v11.0.0...v11.1.0-rc.1)
* Fix regressed glare
[\#1690](https://github.com/matrix-org/matrix-js-sdk/pull/1690)
* Add m.reaction to EventType enum
[\#1692](https://github.com/matrix-org/matrix-js-sdk/pull/1692)
* Prioritise and reduce the amount of events decrypted on application startup
[\#1684](https://github.com/matrix-org/matrix-js-sdk/pull/1684)
* Decrypt relations before applying them to target event
[\#1696](https://github.com/matrix-org/matrix-js-sdk/pull/1696)
* Guard against duplicates in `Relations` model
Changes in [11.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v11.0.0) (2021-05-17)
==================================================================================================
[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v11.0.0-rc.1...v11.0.0)

View File

@@ -1,6 +1,6 @@
{
"name": "matrix-js-sdk",
"version": "11.0.0",
"version": "11.1.0",
"description": "Matrix Client-Server SDK for Javascript",
"scripts": {
"prepublishOnly": "yarn build",
@@ -72,6 +72,7 @@
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"@babel/register": "^7.12.10",
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz",
"@types/jest": "^26.0.20",
"@types/node": "12",
"@types/request": "^2.48.5",
@@ -91,7 +92,6 @@
"jest-localstorage-mock": "^2.4.6",
"jsdoc": "^3.6.6",
"matrix-mock-request": "^1.2.3",
"olm": "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz",
"rimraf": "^3.0.2",
"terser": "^5.5.1",
"tsify": "^5.0.2",

View File

@@ -133,7 +133,6 @@ TestClient.prototype.expectDeviceKeyUpload = function() {
});
};
/**
* If one-time keys have already been uploaded, return them. Otherwise,
* set up an expectation that the keys will be uploaded, and wait for
@@ -197,7 +196,6 @@ TestClient.prototype.expectKeyQuery = function(response) {
});
};
/**
* get the uploaded curve25519 device key
*
@@ -208,7 +206,6 @@ TestClient.prototype.getDeviceKey = function() {
return this.deviceKeys.keys[keyId];
};
/**
* get the uploaded ed25519 device key
*

View File

@@ -67,7 +67,6 @@ function getSyncResponse(roomMembers) {
return syncResponse;
}
describe("DeviceList management:", function() {
if (!global.Olm) {
logger.warn('not running deviceList tests: Olm not present');
@@ -137,7 +136,6 @@ describe("DeviceList management:", function() {
});
});
it("We should not get confused by out-of-order device query responses",
() => {
// https://github.com/vector-im/element-web/issues/3126
@@ -323,7 +321,6 @@ describe("DeviceList management:", function() {
},
);
await aliceTestClient.flushSync();
await aliceTestClient.client._crypto._deviceList.saveIfDirty();

View File

@@ -141,7 +141,6 @@ describe("getEventTimeline support", function() {
});
});
it("scrollback should be able to scroll back to before a gappy /sync",
function() {
// need a client with timelineSupport disabled to make this work
@@ -532,7 +531,6 @@ describe("MatrixClient event timelines", function() {
]);
});
it("should allow you to paginate forwards", function() {
const room = client.getRoom(roomId);
const timelineSet = room.getTimelineSets()[0];
@@ -680,7 +678,6 @@ describe("MatrixClient event timelines", function() {
});
});
it("should handle gappy syncs after redactions", function() {
// https://github.com/vector-im/vector-web/issues/1389

View File

@@ -285,7 +285,6 @@ describe("MatrixClient", function() {
});
});
describe("downloadKeys", function() {
if (!CRYPTO_ENABLED) {
return;

View File

@@ -2,7 +2,6 @@ import * as utils from "../test-utils";
import { EventStatus } from "../../src/models/event";
import { TestClient } from "../TestClient";
describe("MatrixClient room timelines", function() {
let client = null;
let httpBackend = null;

View File

@@ -122,7 +122,6 @@ describe("MatrixClient syncing", function() {
resolveInvitesToProfiles: true,
});
return Promise.all([
httpBackend.flushAllExpected(),
awaitSyncEvent(),

View File

@@ -196,7 +196,6 @@ function getSyncResponse(roomMembers) {
return syncResponse;
}
describe("megolm", function() {
if (!global.Olm) {
logger.warn('not running megolm tests: Olm not present');
@@ -841,7 +840,6 @@ describe("megolm", function() {
});
});
it('Alice should wait for device list to complete when sending a megolm message',
function() {
let downloadPromise;
@@ -887,7 +885,6 @@ describe("megolm", function() {
});
});
it("Alice exports megolm keys and imports them to a new device", function() {
let messageEncrypted;

View File

@@ -20,7 +20,7 @@ import * as utils from "../src/utils";
// try to load the olm library.
try {
global.Olm = require('olm');
global.Olm = require('@matrix-org/olm');
logger.log('loaded libolm');
} catch (e) {
logger.warn("unable to run crypto tests: libolm not available");

View File

@@ -177,7 +177,6 @@ export function mkMessage(opts) {
return mkEvent(opts);
}
/**
* A mock implementation of webstorage
*
@@ -204,7 +203,6 @@ MockStorageApi.prototype = {
},
};
/**
* If an event is being decrypted, wait for it to finish being decrypted.
*
@@ -229,7 +227,6 @@ export function awaitDecryption(event) {
}
}
export function HttpResponse(
httpLookups, acceptKeepalives, ignoreUnhandledSync,
) {

View File

@@ -50,7 +50,6 @@ describe("MegolmDecryption", function() {
roomId: ROOM_ID,
});
// we stub out the olm encryption bits
mockOlmLib = {};
mockOlmLib.ensureOlmSessionsForDevices = jest.fn();

View File

@@ -1,6 +1,5 @@
import { IndexedDBCryptoStore } from '../../../src/crypto/store/indexeddb-crypto-store';
// needs to be phased out and replaced with bootstrapSecretStorage,
// but that is doing too much extra stuff for it to be an easy transition.
export async function resetCrossSigningKeys(client, {

View File

@@ -94,7 +94,6 @@ describe("EventTimeline", function() {
});
});
describe("neighbouringTimelines", function() {
it("neighbouring timelines should start null", function() {
expect(timeline.getNeighbouringTimeline(EventTimeline.BACKWARDS)).toBe(null);
@@ -278,7 +277,6 @@ describe("EventTimeline", function() {
not.toHaveBeenCalled();
});
it("should call setStateEvents on the right RoomState with the right " +
"forwardLooking value for old events", function() {
const events = [

View File

@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { EventTimelineSet } from "../../src/models/event-timeline-set";
import { MatrixEvent } from "../../src/models/event";
import { Relations } from "../../src/models/relations";
@@ -70,4 +71,63 @@ describe("Relations", function() {
expect(events.size).toEqual(1);
}
});
it("should emit created regardless of ordering", async function () {
const targetEvent = new MatrixEvent({
"sender": "@bob:example.com",
"type": "m.room.message",
"event_id": "$2s4yYpEkVQrPglSCSqB_m6E8vDhWsg0yFNyOJdVIb_o",
"room_id": "!pzVjCQSoQPpXQeHpmK:example.com",
"content": {},
});
const relationEvent = new MatrixEvent({
"sender": "@bob:example.com",
"type": "m.reaction",
"event_id": "$cZ1biX33ENJqIm00ks0W_hgiO_6CHrsAc3ZQrnLeNTw",
"room_id": "!pzVjCQSoQPpXQeHpmK:example.com",
"content": {
"m.relates_to": {
"event_id": "$2s4yYpEkVQrPglSCSqB_m6E8vDhWsg0yFNyOJdVIb_o",
"key": "👍️",
"rel_type": "m.annotation",
},
},
});
// Stub the room
const room = {
getPendingEvent() { return null; },
getUnfilteredTimelineSet() { return null; },
};
// Add the target event first, then the relation event
{
const relationsCreated = new Promise(resolve => {
targetEvent.once("Event.relationsCreated", resolve);
})
const timelineSet = new EventTimelineSet(room, {
unstableClientRelationAggregation: true,
});
timelineSet.addLiveEvent(targetEvent);
timelineSet.addLiveEvent(relationEvent);
await relationsCreated;
}
// Add the relation event first, then the target event
{
const relationsCreated = new Promise(resolve => {
targetEvent.once("Event.relationsCreated", resolve);
})
const timelineSet = new EventTimelineSet(room, {
unstableClientRelationAggregation: true,
});
timelineSet.addLiveEvent(relationEvent);
timelineSet.addLiveEvent(targetEvent);
await relationsCreated;
}
});
});

View File

@@ -1267,7 +1267,6 @@ describe("Room", function() {
expect(callCount).toEqual(1);
});
it("should remove cancelled events from the timeline", function() {
const room = new Room(roomId, null, userA);
const eventA = utils.mkMessage({

View File

@@ -46,7 +46,6 @@ function addEventsToTimeline(timeline, numEvents, atStart) {
}
}
/*
* create a pair of linked timelines
*/
@@ -58,7 +57,6 @@ function createLinkedTimelines() {
return [tl1, tl2];
}
describe("TimelineIndex", function() {
describe("minIndex", function() {
it("should return the min index relative to BaseIndex", function() {
@@ -133,7 +131,6 @@ describe("TimelineIndex", function() {
});
});
describe("TimelineWindow", function() {
/**
* create a dummy eventTimelineSet and client, and a TimelineWindow
@@ -385,7 +382,6 @@ describe("TimelineWindow", function() {
});
});
it("should make backward pagination requests", function() {
const timeline = createTimeline();
timeline.setPaginationToken("toktok", EventTimeline.BACKWARDS);

View File

@@ -175,7 +175,6 @@ describe("utils", function() {
});
});
describe("extend", function() {
const SOURCE = { "prop2": 1, "string2": "x", "newprop": "new" };

View File

@@ -15,7 +15,7 @@ limitations under the License.
*/
// this is needed to tell TS about global.Olm
import * as Olm from "olm"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as Olm from "@matrix-org/olm"; // eslint-disable-line @typescript-eslint/no-unused-vars
export {};

View File

@@ -158,7 +158,6 @@ MatrixBaseApis.prototype.makeTxnId = function() {
return "m" + new Date().getTime() + "." + (this._txnCtr++);
};
// Registration/Login operations
// =============================
@@ -401,7 +400,6 @@ MatrixBaseApis.prototype.loginWithToken = function(token, callback) {
}, callback);
};
/**
* Logs out the current session.
* Obviously, further calls that require authorisation should fail after this
@@ -613,7 +611,6 @@ MatrixBaseApis.prototype.upgradeRoom = function(roomId, newVersion) {
);
};
/**
* @param {string} groupId
* @return {Promise} Resolves: Group summary object
@@ -1278,7 +1275,6 @@ MatrixBaseApis.prototype.searchUserDirectory = function(opts) {
);
};
// Media operations
// ================
@@ -1347,7 +1343,6 @@ MatrixBaseApis.prototype.getCurrentUploads = function() {
return this._http.getCurrentUploads();
};
// Profile operations
// ==================
@@ -1372,7 +1367,6 @@ MatrixBaseApis.prototype.getProfileInfo = function(userId, info, callback) {
return this._http.authedRequest(callback, "GET", path);
};
// Account operations
// ==================
@@ -1518,7 +1512,6 @@ MatrixBaseApis.prototype.setPassword = function(authDict, newPassword, callback)
);
};
// Device operations
// =================
@@ -1605,7 +1598,6 @@ MatrixBaseApis.prototype.deleteMultipleDevices = function(devices, auth) {
return this._http.authedRequest(undefined, "POST", path, undefined, body);
};
// Push operations
// ===============
@@ -1728,7 +1720,6 @@ MatrixBaseApis.prototype.setPushRuleActions = function(scope, kind,
);
};
// Search
// ======

View File

@@ -17,7 +17,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* This is an internal module. See {@link MatrixClient} for the public class.
* @module client
@@ -706,7 +705,6 @@ MatrixClient.prototype.getDeviceId = function() {
return this.deviceId;
};
/**
* Check if the runtime environment supports VoIP calling.
* @return {boolean} True if VoIP is supported.
@@ -969,14 +967,12 @@ MatrixClient.prototype.initCrypto = async function() {
this.olmVersion = Crypto.getOlmVersion();
// if crypto initialisation was successful, tell it to attach its event
// handlers.
crypto.registerEventHandlers(this);
this._crypto = crypto;
};
/**
* Is end-to-end crypto enabled for this client.
* @return {boolean} True if end-to-end is enabled.
@@ -2882,7 +2878,6 @@ MatrixClient.prototype._sendCompleteEvent = function(roomId, eventObject, txnId,
return _sendEvent(this, room, localEvent, callback);
};
// encrypts the event if necessary
// adds the event to the queue, or sends it
// marks the event as sent/unsent
@@ -4566,7 +4561,6 @@ MatrixClient.prototype._requestTokenFromEndpoint = async function(endpoint, para
);
};
// Push operations
// ===============
@@ -4822,7 +4816,6 @@ MatrixClient.prototype._processRoomEventsSearch = function(searchResults, respon
return searchResults;
};
/**
* Populate the store with rooms the user has left.
* @return {Promise} Resolves: TODO - Resolved when the rooms have
@@ -4968,7 +4961,6 @@ MatrixClient.prototype.getOrCreateFilter = async function(filterName, filter) {
return createdFilter.filterId;
};
/**
* Gets a bearer token from the Home Server that the user can
* present to a third party in order to prove their ownership
@@ -4986,7 +4978,6 @@ MatrixClient.prototype.getOpenIdToken = function() {
);
};
// VoIP operations
// ===============
@@ -5154,7 +5145,6 @@ MatrixClient.prototype.deactivateSynapseUser = function(userId) {
// due to ambiguity (or should this be on a chat-specific layer)?
// reconnect after connectivity outages
/**
* High level helper method to begin syncing and poll for new events. To listen for these
* events, add a listener for {@link module:client~MatrixClient#event:"event"}

View File

@@ -30,7 +30,6 @@ import * as olmlib from './olmlib';
import { IndexedDBCryptoStore } from './store/indexeddb-crypto-store';
import { chunkPromises, defer, sleep } from '../utils';
/* State transition diagram for DeviceList._deviceTrackingStatus
*
* |
@@ -51,7 +50,6 @@ import {chunkPromises, defer, sleep} from '../utils';
* +----------------------- UP_TO_DATE ------------------------+
*/
// constants for DeviceList._deviceTrackingStatus
const TRACKING_STATUS_NOT_TRACKED = 0;
const TRACKING_STATUS_PENDING_DOWNLOAD = 1;
@@ -892,7 +890,6 @@ class DeviceListUpdateSerialiser {
}
}
async function _updateStoredDeviceKeysForUser(
_olmDevice, userId, userStore, userResult, localUserId, localDeviceId,
) {

View File

@@ -86,7 +86,6 @@ export class EncryptionSetupBuilder {
userSignatures[deviceId] = signature;
}
/**
* @param {String} type
* @param {Object} content
@@ -225,7 +224,6 @@ export class EncryptionSetupOperation {
}
}
/**
* Catches account data set by SecretStorage during bootstrapping by
* implementing the methods related to account data in MatrixClient

View File

@@ -48,7 +48,6 @@ function checkPayloadLength(payloadString) {
}
}
/**
* The type of object we use for importing and exporting megolm session data.
*
@@ -62,7 +61,6 @@ function checkPayloadLength(payloadString) {
* @property {String} session_key Base64'ed key data
*/
/**
* Manages the olm cryptography functions. Each OlmDevice has a single
* OlmAccount and a number of OlmSessions.
@@ -376,7 +374,6 @@ OlmDevice.prototype._saveSession = function(deviceKey, sessionInfo, txn) {
);
};
/**
* get an OlmUtility and call the given function
*
@@ -393,7 +390,6 @@ OlmDevice.prototype._getUtility = function(func) {
}
};
/**
* Signs a message with the ed25519 key for this account.
*
@@ -434,7 +430,6 @@ OlmDevice.prototype.getOneTimeKeys = async function() {
return result;
};
/**
* Get the maximum number of one-time keys we can store.
*
@@ -550,7 +545,6 @@ OlmDevice.prototype.createOutboundSession = async function(
return newSessionId;
};
/**
* Generate a new inbound session, given an incoming message
*
@@ -612,7 +606,6 @@ OlmDevice.prototype.createInboundSession = async function(
return result;
};
/**
* Get a list of known session IDs for the given device
*
@@ -856,7 +849,6 @@ OlmDevice.prototype.filterOutNotifiedErrorDevices = async function(devices) {
return await this._cryptoStore.filterOutNotifiedErrorDevices(devices);
};
// Outbound group session
// ======================
@@ -871,7 +863,6 @@ OlmDevice.prototype._saveOutboundGroupSession = function(session) {
this._outboundGroupSessionStore[session.session_id()] = pickledSession;
};
/**
* extract an OutboundGroupSession from _outboundGroupSessionStore and call the
* given function
@@ -896,7 +887,6 @@ OlmDevice.prototype._getOutboundGroupSession = function(sessionId, func) {
}
};
/**
* Generate a new outbound group session
*
@@ -913,7 +903,6 @@ OlmDevice.prototype.createOutboundGroupSession = function() {
}
};
/**
* Encrypt an outgoing message with an outbound group session
*
@@ -953,7 +942,6 @@ OlmDevice.prototype.getOutboundGroupSessionKey = function(sessionId) {
});
};
// Inbound group session
// =====================

View File

@@ -75,7 +75,6 @@ function OutboundSessionInfo(sessionId, sharedHistory = false) {
this.sharedHistory = sharedHistory;
}
/**
* Check if it's time to rotate the session
*
@@ -158,7 +157,6 @@ OutboundSessionInfo.prototype.sharedWithTooManyDevices = function(
}
};
/**
* Megolm encryption implementation
*
@@ -1341,7 +1339,6 @@ MegolmDecryption.prototype._removeEventFromPendingList = function(event) {
}
};
/**
* @inheritdoc
*

View File

@@ -358,5 +358,4 @@ OlmDecryption.prototype._reallyDecryptMessage = async function(
return res.payload;
};
registerAlgorithm(olmlib.OLM_ALGORITHM, OlmEncryption, OlmDecryption);

View File

@@ -1774,7 +1774,6 @@ Crypto.prototype.registerEventHandlers = function(eventEmitter) {
eventEmitter.on("Event.decrypted", timelineHandler);
};
/** Start background processes related to crypto */
Crypto.prototype.start = function() {
this._outgoingRoomKeyRequestManager.start();
@@ -2368,7 +2367,6 @@ Crypto.prototype.legacyDeviceVerification = async function(
return request;
};
/**
* Get information on the active olm sessions with a user
* <p>
@@ -2399,7 +2397,6 @@ Crypto.prototype.getOlmSessionsForUser = async function(userId) {
return result;
};
/**
* Get the device which sent an event
*
@@ -2644,7 +2641,6 @@ Crypto.prototype.setRoomEncryption = async function(roomId, config, inhibitDevic
}
};
/**
* Make sure we are tracking the device lists for all users in this room.
*
@@ -3301,7 +3297,6 @@ Crypto.prototype._getTrackedE2eRooms = function() {
});
};
Crypto.prototype._onToDeviceEvent = function(event) {
try {
logger.log(`received to_device ${event.getType()} from: ` +
@@ -3592,7 +3587,6 @@ Crypto.prototype._onToDeviceBadEncrypted = async function(event) {
},
});
// Most of the time this probably won't be necessary since we'll have queued up a key request when
// we failed to decrypt the message and will be waiting a bit for the key to arrive before sending
// it. This won't always be the case though so we need to re-send any that have already been sent
@@ -3649,7 +3643,6 @@ Crypto.prototype._onRoomMembership = function(event, member, oldMembership) {
alg.onRoomMembership(event, member, oldMembership);
};
/**
* Called when we get an m.room_key_request event.
*
@@ -3802,7 +3795,6 @@ Crypto.prototype._processReceivedRoomKeyRequest = async function(req) {
this.emit("crypto.roomKeyRequest", req);
};
/**
* Helper for processReceivedRoomKeyRequests
*
@@ -3878,7 +3870,6 @@ Crypto.prototype._getRoomDecryptor = function(roomId, algorithm) {
return alg;
};
/**
* Get all the room decryptors for a given encryption algorithm.
*
@@ -3896,7 +3887,6 @@ Crypto.prototype._getRoomDecryptors = function(algorithm) {
return decryptors;
};
/**
* sign the given object with our ed25519 key
*
@@ -3916,7 +3906,6 @@ Crypto.prototype._signObject = async function(obj) {
if (unsigned !== undefined) obj.unsigned = unsigned;
};
/**
* The parameters of a room key request. The details of the request may
* vary with the crypto algorithm, but the management and storage layers for

View File

@@ -41,7 +41,6 @@ export const MEGOLM_ALGORITHM = "m.megolm.v1.aes-sha2";
*/
export const MEGOLM_BACKUP_ALGORITHM = "m.megolm_backup.v1.curve25519-aes-sha2";
/**
* Encrypt an event payload for an Olm device
*
@@ -408,7 +407,6 @@ async function _verifyKeyAndStartSession(olmDevice, oneTimeKey, userId, deviceIn
return sid;
}
/**
* Verify the signature on an object
*

View File

@@ -323,7 +323,6 @@ export class SAS extends Base {
key: this.ourSASPubKey,
});
e = await this._waitForEvent("m.key.verification.key");
// FIXME: make sure event is properly formed
content = e.getContent();
@@ -353,7 +352,6 @@ export class SAS extends Base {
this.emit("show_sas", this.sasEvent);
});
[e] = await Promise.all([
this._waitForEvent("m.key.verification.mac")
.then((e) => {
@@ -411,7 +409,6 @@ export class SAS extends Base {
commitment: olmutil.sha256(commitmentStr),
});
let e = await this._waitForEvent("m.key.verification.key");
// FIXME: make sure event is properly formed
content = e.getContent();
@@ -440,7 +437,6 @@ export class SAS extends Base {
this.emit("show_sas", this.sasEvent);
});
[e] = await Promise.all([
this._waitForEvent("m.key.verification.mac")
.then((e) => {

View File

@@ -292,7 +292,6 @@ export class ToDeviceChannel {
}
}
export class ToDeviceRequests {
constructor() {
this._requestsByUserId = new Map();

View File

@@ -37,7 +37,6 @@ const TIMEOUT_FROM_EVENT_RECEIPT = 2 * 60 * 1000; // 2 minutes
// are this amount of time away from expiring.
const VERIFICATION_REQUEST_MARGIN = 3 * 1000; // 3 seconds
export const EVENT_PREFIX = "m.key.verification.";
export const REQUEST_TYPE = EVENT_PREFIX + "request";
export const START_TYPE = EVENT_PREFIX + "start";
@@ -52,7 +51,6 @@ export const PHASE_STARTED = 4;
export const PHASE_CANCELLED = 5;
export const PHASE_DONE = 6;
/**
* State machine for verification requests.
* Things that differ based on what channel is used to
@@ -98,7 +96,6 @@ export class VerificationRequest extends EventEmitter {
static validateEvent(type, event, client) {
const content = event.getContent();
if (!type || !type.startsWith(EVENT_PREFIX)) {
return false;
}
@@ -355,7 +352,6 @@ export class VerificationRequest extends EventEmitter {
return this._observeOnly;
}
/**
* Gets which device the verification should be started with
* given the events sent so far in the verification. This is the

View File

@@ -22,7 +22,6 @@ InvalidStoreError.prototype = Object.create(Error.prototype, {
});
Reflect.setPrototypeOf(InvalidStoreError, Error);
export function InvalidCryptoStoreError(reason) {
const message = `Crypto store is invalid because ${reason}, ` +
`please stop the client, delete all data and start the client again`;

View File

@@ -803,7 +803,8 @@ const requestCallback = function(
}
if (!err) {
try {
if (response.statusCode >= 400) {
const httpStatus = response.status || response.statusCode; // XMLHttpRequest vs http.IncomingMessage
if (httpStatus >= 400) {
err = parseErrorResponse(response, body);
} else if (bodyParser) {
body = bodyParser(body);
@@ -818,7 +819,7 @@ const requestCallback = function(
userDefinedCallback(err);
} else {
const res = {
code: response.statusCode,
code: response.status || response.statusCode, // XMLHttpRequest vs http.IncomingMessage
// XXX: why do we bother with this? it doesn't work for
// XMLHttpRequest, so clearly we don't use it.
@@ -842,7 +843,7 @@ const requestCallback = function(
* @returns {Error}
*/
function parseErrorResponse(response, body) {
const httpStatus = response.statusCode;
const httpStatus = response.status || response.statusCode; // XMLHttpRequest vs http.IncomingMessage
const contentType = getResponseContentType(response);
let err;
@@ -862,7 +863,6 @@ function parseErrorResponse(response, body) {
return err;
}
/**
* extract the Content-Type header from the response object, and
* parse it to a `{type, parameters}` object.

View File

@@ -59,7 +59,6 @@ export {
setVideoInput as setMatrixCallVideoInput,
} from "./webrtc/call";
// expose the underlying request object so different environments can use
// different request libs (e.g. request or browser-request)
let requestInstance;

View File

@@ -271,7 +271,6 @@ EventTimelineSet.prototype.addTimeline = function() {
return timeline;
};
/**
* Add events to a timeline
*
@@ -740,17 +739,12 @@ EventTimelineSet.prototype.setRelationsTarget = function(event) {
if (!relationsForEvent) {
return;
}
// don't need it for non m.replace relations for now
const relationsWithRelType = relationsForEvent["m.replace"];
if (!relationsWithRelType) {
return;
}
// only doing replacements for messages for now (e.g. edits)
const relationsWithEventType = relationsWithRelType["m.room.message"];
if (relationsWithEventType) {
for (const relationsWithRelType of Object.values(relationsForEvent)) {
for (const relationsWithEventType of Object.values(relationsWithRelType)) {
relationsWithEventType.setTargetEvent(event);
}
}
};
/**
@@ -797,7 +791,6 @@ EventTimelineSet.prototype.aggregateRelations = function(event) {
}
let relationsWithEventType = relationsWithRelType[eventType];
let isNewRelations = false;
let relatesToEvent;
if (!relationsWithEventType) {
relationsWithEventType = relationsWithRelType[eventType] = new Relations(
@@ -805,7 +798,6 @@ EventTimelineSet.prototype.aggregateRelations = function(event) {
eventType,
this.room,
);
isNewRelations = true;
relatesToEvent = this.findEventById(relatesToEventId) || this.room.getPendingEvent(relatesToEventId);
if (relatesToEvent) {
relationsWithEventType.setTargetEvent(relatesToEvent);
@@ -813,11 +805,6 @@ EventTimelineSet.prototype.aggregateRelations = function(event) {
}
relationsWithEventType.addEvent(event);
// only emit once event has been added to relations
if (isNewRelations && relatesToEvent) {
relatesToEvent.emit("Event.relationsCreated", relationType, eventType);
}
};
/**

View File

@@ -180,7 +180,6 @@ export const MatrixEvent = function(
};
utils.inherits(MatrixEvent, EventEmitter);
utils.extend(MatrixEvent.prototype, {
/**
* Get the event_id for this event.
@@ -1146,7 +1145,6 @@ utils.extend(MatrixEvent.prototype, {
},
});
/* _REDACT_KEEP_KEY_MAP gives the keys we keep when an event is redacted
*
* This is specified here:
@@ -1175,7 +1173,6 @@ const _REDACT_KEEP_CONTENT_MAP = {
'm.room.aliases': { 'aliases': 1 },
};
/**
* Fires when an event is decrypted
*

View File

@@ -48,6 +48,7 @@ export class Relations extends EventEmitter {
this._sortedAnnotationsByKey = [];
this._targetEvent = null;
this._room = room;
this._creationEmitted = false;
}
/**
@@ -94,6 +95,8 @@ export class Relations extends EventEmitter {
event.on("Event.beforeRedaction", this._onBeforeRedaction);
this.emit("Relations.add", event);
this._maybeEmitCreated();
}
/**
@@ -345,6 +348,7 @@ export class Relations extends EventEmitter {
return;
}
this._targetEvent = event;
if (this.relationType === "m.replace") {
const replacement = await this.getLastReplacement();
// this is the initial update, so only call it if we already have something
@@ -353,5 +357,24 @@ export class Relations extends EventEmitter {
this._targetEvent.makeReplaced(replacement);
}
}
this._maybeEmitCreated();
}
_maybeEmitCreated() {
if (this._creationEmitted) {
return;
}
// Only emit we're "created" once we have a target event instance _and_
// at least one related event.
if (!this._targetEvent || !this._relations.size) {
return;
}
this._creationEmitted = true;
this._targetEvent.emit(
"Event.relationsCreated",
this.relationType,
this.eventType,
);
}
}

View File

@@ -203,7 +203,6 @@ RoomMember.prototype.getLastModifiedTime = function() {
return this._modified;
};
RoomMember.prototype.isKicked = function() {
return this.membership === "leave" &&
this.events.member.getSender() !== this.events.member.getStateKey();
@@ -240,7 +239,6 @@ RoomMember.prototype.getDMInviter = function() {
}
};
/**
* Get the avatar URL for a room member.
* @param {string} baseUrl The base homeserver URL See

View File

@@ -735,7 +735,6 @@ RoomState.prototype.getJoinRule = function() {
return joinRuleContent["join_rule"] || "invite";
};
function _updateThirdPartyTokenCache(roomState, memberEvent) {
if (!memberEvent.getContent().third_party_invite) {
return;

View File

@@ -139,7 +139,6 @@ User.prototype.setDisplayName = function(name) {
}
};
/**
* Manually set this user's non-disambiguated display name. No event is emitted
* in response to this as there is no underlying MatrixEvent to emit with.
@@ -153,7 +152,6 @@ User.prototype.setRawDisplayName = function(name) {
}
};
/**
* Manually set this user's avatar URL. No event is emitted in response to this
* as there is no underlying MatrixEvent to emit with.

View File

@@ -360,7 +360,6 @@ export function PushProcessor(client) {
return ret;
};
/**
* Get the user's push actions for the given event
*
@@ -468,4 +467,3 @@ PushProcessor.rewriteDefaultRules = function(incomingRules) {
* noise.
*/

View File

@@ -177,7 +177,6 @@ function _runCallbacks() {
}
}
/* search in a sorted array.
*
* returns the index of the last element for which func returns

View File

@@ -93,7 +93,6 @@ MatrixScheduler.prototype.removeEventFromQueue = function(event) {
return removed;
};
/**
* Set the process function. Required for events in the queue to be processed.
* If set after events have been added to the queue, this will immediately start

View File

@@ -48,7 +48,6 @@ function upgradeSchemaV3(db) {
{ keyPath: ["clobber"] });
}
/**
* Helper method to collect results from a Cursor and promiseify it.
* @param {ObjectStore|Index} store The store to perform openCursor on.

View File

@@ -48,7 +48,6 @@ export function RemoteIndexedDBStoreBackend(
this._startPromise = null;
}
RemoteIndexedDBStoreBackend.prototype = {
/**
* Attempt to connect to the database. This can fail if the user does not

View File

@@ -39,7 +39,6 @@ import {logger} from '../logger';
// response is persisted each time.
const WRITE_DELAY_MS = 1000 * 60 * 5; // once every 5 minutes
/**
* Construct a new Indexed Database store, which extends MemoryStore.
*

View File

@@ -62,7 +62,6 @@ function debuglog(...params) {
logger.log(...params);
}
/**
* <b>Internal class - unstable.</b>
* Construct an entity which is able to sync with a homeserver.
@@ -188,7 +187,6 @@ SyncApi.prototype._deregisterStateListeners = function(room) {
room.currentState.removeAllListeners("RoomState.newMember");
};
/**
* Sync rooms the user has left.
* @return {Promise} Resolved when they've been added to the store.

View File

@@ -335,7 +335,6 @@ TimelineWindow.prototype.paginate = function(direction, size, makeRequest,
return prom;
};
/**
* Remove `delta` events from the start or end of the timeline.
*
@@ -368,7 +367,6 @@ TimelineWindow.prototype.unpaginate = function(delta, startOfTimeline) {
}
};
/**
* Get a list of the events currently in the window
*
@@ -420,7 +418,6 @@ TimelineWindow.prototype.getEvents = function() {
return result;
};
/**
* a thing which contains a timeline reference, and an index into it.
*

View File

@@ -39,7 +39,6 @@ import {
} from './callEventTypes';
import { CallFeed } from './callFeed';
// events: hangup, error(err), replaced(call), state(state, oldState)
/**

View File

@@ -1130,6 +1130,10 @@
"@types/yargs" "^15.0.0"
chalk "^4.0.0"
"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz":
version "3.2.3"
resolved "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz#cc332fdd25c08ef0e40f4d33fc3f822a0f98b6f4"
"@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents":
version "2.1.8-no-fsevents"
resolved "https://registry.yarnpkg.com/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.tgz#da7c3996b8e6e19ebd14d82eaced2313e7769f9b"
@@ -5142,10 +5146,6 @@ object.pick@^1.3.0:
dependencies:
isobject "^3.0.1"
"olm@https://packages.matrix.org/npm/olm/olm-3.2.1.tgz":
version "3.2.1"
resolved "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz#d623d76f99c3518dde68be8c86618d68bc7b004a"
once@^1.3.0, once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"