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

Merge remote-tracking branch 'upstream/develop' into fix/12652/screen-share

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2021-05-28 17:37:17 +02:00
13 changed files with 101 additions and 89 deletions

View File

@@ -2,7 +2,9 @@ module.exports = {
plugins: [ plugins: [
"matrix-org", "matrix-org",
], ],
extends: ["plugin:matrix-org/javascript"], extends: [
"plugin:matrix-org/babel",
],
env: { env: {
browser: true, browser: true,
node: true, node: true,
@@ -31,14 +33,26 @@ module.exports = {
"no-console": "error", "no-console": "error",
}, },
overrides: [{ overrides: [{
"files": ["src/**/*.ts"], files: [
"extends": ["plugin:matrix-org/typescript"], "**/*.ts",
"rules": { ],
extends: [
"plugin:matrix-org/typescript",
],
rules: {
// TypeScript has its own version of this
"@babel/no-invalid-this": "off",
// We're okay being explicit at the moment // We're okay being explicit at the moment
"@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-empty-interface": "off",
// While we're converting to ts we make heavy use of this // We disable this while we're transitioning
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
// We'd rather not do this but we do
"@typescript-eslint/ban-ts-comment": "off",
"quotes": "off", "quotes": "off",
// We use a `logger` intermediary module
"no-console": "error",
}, },
}], }],
}; };

View File

@@ -144,7 +144,6 @@ function expectAliClaimKeys() {
}); });
} }
function aliDownloadsKeys() { function aliDownloadsKeys() {
// can't query keys before bob has uploaded them // can't query keys before bob has uploaded them
expect(bobTestClient.getSigningKey()).toBeTruthy(); expect(bobTestClient.getSigningKey()).toBeTruthy();
@@ -357,7 +356,6 @@ function recvMessage(httpBackend, client, sender, message) {
}); });
} }
/** /**
* Send an initial sync response to the client (which just includes the member * Send an initial sync response to the client (which just includes the member
* list for our test room). * list for our test room).
@@ -395,7 +393,6 @@ function firstSync(testClient) {
return testClient.flushSync(); return testClient.flushSync();
} }
describe("MatrixClient crypto", function() { describe("MatrixClient crypto", function() {
if (!CRYPTO_ENABLED) { if (!CRYPTO_ENABLED) {
return; return;
@@ -533,7 +530,6 @@ describe("MatrixClient crypto", function() {
}); });
}); });
it("Bob starts his client and uploads device keys and one-time keys", function() { it("Bob starts his client and uploads device keys and one-time keys", function() {
return Promise.resolve() return Promise.resolve()
.then(() => bobTestClient.start()) .then(() => bobTestClient.start())

View File

@@ -16,6 +16,7 @@ limitations under the License.
import * as matrixcs from "./matrix"; import * as matrixcs from "./matrix";
import * as utils from "./utils"; import * as utils from "./utils";
import { logger } from './logger';
import request from "request"; import request from "request";
matrixcs.request(request); matrixcs.request(request);
@@ -25,7 +26,7 @@ try {
const crypto = require('crypto'); const crypto = require('crypto');
utils.setCrypto(crypto); utils.setCrypto(crypto);
} catch (err) { } catch (err) {
console.log('nodejs was compiled without crypto support'); logger.log('nodejs was compiled without crypto support');
} }
export * from "./matrix"; export * from "./matrix";

View File

@@ -36,11 +36,11 @@ const DEFAULT_NAMESPACE = "matrix";
// when logging so we always get the current value of console methods. // when logging so we always get the current value of console methods.
log.methodFactory = function(methodName, logLevel, loggerName) { log.methodFactory = function(methodName, logLevel, loggerName) {
return function(...args) { return function(...args) {
/* eslint-disable @babel/no-invalid-this */ /* eslint-disable @typescript-eslint/no-invalid-this */
if (this.prefix) { if (this.prefix) {
args.unshift(this.prefix); args.unshift(this.prefix);
} }
/* eslint-enable @babel/no-invalid-this */ /* eslint-enable @typescript-eslint/no-invalid-this */
const supportedByConsole = methodName === "error" || const supportedByConsole = methodName === "error" ||
methodName === "warn" || methodName === "warn" ||
methodName === "trace" || methodName === "trace" ||

View File

@@ -59,7 +59,6 @@ function synthesizeReceipt(userId, event, receiptType) {
return new MatrixEvent(fakeReceipt); return new MatrixEvent(fakeReceipt);
} }
/** /**
* Construct a new Room. * Construct a new Room.
* *
@@ -234,7 +233,6 @@ function pendingEventsKey(roomId) {
utils.inherits(Room, EventEmitter); utils.inherits(Room, EventEmitter);
/** /**
* Bulk decrypt critical events in a room * Bulk decrypt critical events in a room
* *
@@ -495,7 +493,6 @@ Room.prototype.getLiveTimeline = function() {
return this.getUnfilteredTimelineSet().getLiveTimeline(); return this.getUnfilteredTimelineSet().getLiveTimeline();
}; };
/** /**
* Get the timestamp of the last message in the room * Get the timestamp of the last message in the room
* *
@@ -640,7 +637,6 @@ Room.prototype._loadMembersFromServer = async function() {
return response.chunk; return response.chunk;
}; };
Room.prototype._loadMembers = async function() { Room.prototype._loadMembers = async function() {
// were the members loaded from the server? // were the members loaded from the server?
let fromServer = false; let fromServer = false;
@@ -1125,7 +1121,6 @@ Room.prototype.getInvitedAndJoinedMemberCount = function() {
return calculateRoomName(this, userId, true); return calculateRoomName(this, userId, true);
}; };
/** /**
* Check if the given user_id has the given membership state. * Check if the given user_id has the given membership state.
* @param {string} userId The user ID to check. * @param {string} userId The user ID to check.
@@ -1282,7 +1277,6 @@ Room.prototype._addLiveEvent = function(event, duplicateStrategy, fromCache) {
} }
}; };
/** /**
* Add a pending outgoing event to this room. * Add a pending outgoing event to this room.
* *
@@ -1693,7 +1687,6 @@ Room.prototype.removeEvent = function(eventId) {
return removedAny; return removedAny;
}; };
/** /**
* Recalculate various aspects of the room, including the room name and * Recalculate various aspects of the room, including the room name and
* room summary. Call this any time the room's current state is modified. * room summary. Call this any time the room's current state is modified.
@@ -1918,7 +1911,6 @@ Room.prototype._buildReceiptCache = function(receipts) {
return receiptCacheByEventId; return receiptCacheByEventId;
}; };
/** /**
* Add a temporary local-echo receipt to the room to reflect in the * Add a temporary local-echo receipt to the room to reflect in the
* client the fact that we've sent one. * client the fact that we've sent one.
@@ -1976,7 +1968,6 @@ Room.prototype.getAccountData = function(type) {
return this.accountData[type]; return this.accountData[type];
}; };
/** /**
* Returns whether the syncing user has permission to send a message in the room * Returns whether the syncing user has permission to send a message in the room
* @return {boolean} true if the user should be permitted to send * @return {boolean} true if the user should be permitted to send

View File

@@ -190,6 +190,11 @@ export enum CallErrorCode {
* Signalling for the call could not be sent (other than the initial invite) * Signalling for the call could not be sent (other than the initial invite)
*/ */
SignallingFailed = 'signalling_timeout', SignallingFailed = 'signalling_timeout',
/**
* The remote party is busy
*/
UserBusy = 'user_busy'
} }
enum ConstraintsType { enum ConstraintsType {
@@ -732,7 +737,7 @@ export class MatrixCall extends EventEmitter {
// Continue to send no reason for user hangups temporarily, until // Continue to send no reason for user hangups temporarily, until
// clients understand the user_hangup reason (voip v1) // clients understand the user_hangup reason (voip v1)
if (reason !== CallErrorCode.UserHangup) content['reason'] = reason; if (reason !== CallErrorCode.UserHangup) content['reason'] = reason;
this.sendVoipEvent(EventType.CallHangup, {}); this.sendVoipEvent(EventType.CallHangup, content);
} }
/** /**
@@ -1599,7 +1604,7 @@ export class MatrixCall extends EventEmitter {
); );
if (shouldTerminate) { if (shouldTerminate) {
this.terminate(CallParty.Remote, CallErrorCode.UserHangup, true); this.terminate(CallParty.Remote, msg.reason || CallErrorCode.UserHangup, true);
} else { } else {
logger.debug(`Call is in state: ${this.state}: ignoring reject`); logger.debug(`Call is in state: ${this.state}: ignoring reject`);
} }

View File

@@ -92,11 +92,7 @@ export class CallEventHandler {
private onEvent = (event: MatrixEvent) => { private onEvent = (event: MatrixEvent) => {
this.client.decryptEventIfNeeded(event); this.client.decryptEventIfNeeded(event);
// any call events or ones that might be once they're decrypted // any call events or ones that might be once they're decrypted
if ( if (this.eventIsACall(event) || event.isBeingDecrypted()) {
event.getType().indexOf("m.call.") === 0 ||
event.getType().indexOf("org.matrix.call.") === 0
|| event.isBeingDecrypted()
) {
// queue up for processing once all events from this sync have been // queue up for processing once all events from this sync have been
// processed (see above). // processed (see above).
this.callEventBuffer.push(event); this.callEventBuffer.push(event);
@@ -105,7 +101,7 @@ export class CallEventHandler {
if (event.isBeingDecrypted() || event.isDecryptionFailure()) { if (event.isBeingDecrypted() || event.isDecryptionFailure()) {
// add an event listener for once the event is decrypted. // add an event listener for once the event is decrypted.
event.once("Event.decrypted", () => { event.once("Event.decrypted", () => {
if (event.getType().indexOf("m.call.") === -1) return; if (!this.eventIsACall(event)) return;
if (this.callEventBuffer.includes(event)) { if (this.callEventBuffer.includes(event)) {
// we were waiting for that event to decrypt, so recheck the buffer // we were waiting for that event to decrypt, so recheck the buffer
@@ -123,6 +119,15 @@ export class CallEventHandler {
} }
} }
private eventIsACall(event: MatrixEvent): boolean {
const type = event.getType();
/**
* Unstable prefixes:
* - org.matrix.call. : MSC3086 https://github.com/matrix-org/matrix-doc/pull/3086
*/
return type.startsWith("m.call.") || type.startsWith("org.matrix.call.");
}
private handleCallEvent(event: MatrixEvent) { private handleCallEvent(event: MatrixEvent) {
const content = event.getContent(); const content = event.getContent();
let call = content.call_id ? this.calls.get(content.call_id) : undefined; let call = content.call_id ? this.calls.get(content.call_id) : undefined;

View File

@@ -2034,15 +2034,15 @@ browserify@^17.0.0:
xtend "^4.0.0" xtend "^4.0.0"
browserslist@^4.14.5, browserslist@^4.16.1: browserslist@^4.14.5, browserslist@^4.16.1:
version "4.16.1" version "4.16.6"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.1.tgz#bf757a2da376b3447b800a16f0f1c96358138766" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.6.tgz#d7901277a5a88e554ed305b183ec9b0c08f66fa2"
integrity sha512-UXhDrwqsNcpTYJBTZsbGATDxZbiVDsx6UjpmRUmtnP10pr8wAYr5LgFoEFw9ixriQH2mv/NX2SfGzE/o8GndLA== integrity sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ==
dependencies: dependencies:
caniuse-lite "^1.0.30001173" caniuse-lite "^1.0.30001219"
colorette "^1.2.1" colorette "^1.2.2"
electron-to-chromium "^1.3.634" electron-to-chromium "^1.3.723"
escalade "^3.1.1" escalade "^3.1.1"
node-releases "^1.1.69" node-releases "^1.1.71"
bs58@^4.0.1: bs58@^4.0.1:
version "4.0.1" version "4.0.1"
@@ -2129,10 +2129,10 @@ camelcase@^6.0.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809"
integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==
caniuse-lite@^1.0.30001173: caniuse-lite@^1.0.30001219:
version "1.0.30001178" version "1.0.30001230"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001178.tgz#3ad813b2b2c7d585b0be0a2440e1e233c6eabdbc" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz#8135c57459854b2240b57a4a6786044bdc5a9f71"
integrity sha512-VtdZLC0vsXykKni8Uztx45xynytOi71Ufx9T8kHptSw9AL4dpqailUJJHavttuzUe1KYuBYtChiWv+BAb7mPmQ== integrity sha512-5yBd5nWCBS+jWKTcHOzXwo5xzcj4ePE/yjtkZyUV1BTUmrBaA9MRGC+e7mxnqXSA90CmCA8L3eKLaSUkt099IQ==
capture-exit@^2.0.0: capture-exit@^2.0.0:
version "2.0.0" version "2.0.0"
@@ -2300,10 +2300,10 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
colorette@^1.2.1: colorette@^1.2.2:
version "1.2.1" version "1.2.2"
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b" resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94"
integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw== integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==
combine-source-map@^0.8.0, combine-source-map@~0.8.0: combine-source-map@^0.8.0, combine-source-map@~0.8.0:
version "0.8.0" version "0.8.0"
@@ -2715,10 +2715,10 @@ ecc-jsbn@~0.1.1:
jsbn "~0.1.0" jsbn "~0.1.0"
safer-buffer "^2.1.0" safer-buffer "^2.1.0"
electron-to-chromium@^1.3.634: electron-to-chromium@^1.3.723:
version "1.3.642" version "1.3.738"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.642.tgz#8b884f50296c2ae2a9997f024d0e3e57facc2b94" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.738.tgz#aec24b091c82acbfabbdcce08076a703941d17ca"
integrity sha512-cev+jOrz/Zm1i+Yh334Hed6lQVOkkemk2wRozfMF4MtTR7pxf3r3L5Rbd7uX1zMcEqVJ7alJBnJL7+JffkC6FQ== integrity sha512-vCMf4gDOpEylPSLPLSwAEsz+R3ShP02Y3cAKMZvTqule3XcPp7tgc/0ESI7IS6ZeyBlGClE50N53fIOkcIVnpw==
elliptic@^6.5.3: elliptic@^6.5.3:
version "6.5.4" version "6.5.4"
@@ -2845,8 +2845,8 @@ eslint-config-google@^0.14.0:
integrity sha512-WsbX4WbjuMvTdeVL6+J3rK1RGhCTqjsFjX7UMSMgZiyxxaNLkoJENbrGExzERFeoTpGw3F3FypTiWAP9ZXzkEw== integrity sha512-WsbX4WbjuMvTdeVL6+J3rK1RGhCTqjsFjX7UMSMgZiyxxaNLkoJENbrGExzERFeoTpGw3F3FypTiWAP9ZXzkEw==
"eslint-plugin-matrix-org@github:matrix-org/eslint-plugin-matrix-org#main": "eslint-plugin-matrix-org@github:matrix-org/eslint-plugin-matrix-org#main":
version "0.2.0" version "0.3.1"
resolved "https://codeload.github.com/matrix-org/eslint-plugin-matrix-org/tar.gz/0ae103fe9af97655be6039fc1e7ad6ea95da310b" resolved "https://codeload.github.com/matrix-org/eslint-plugin-matrix-org/tar.gz/b55649a0f48ee27155c1968ed5050b6ddc5afdbe"
eslint-rule-composer@^0.3.0: eslint-rule-composer@^0.3.0:
version "0.3.0" version "0.3.0"
@@ -5037,10 +5037,10 @@ node-notifier@^8.0.0:
uuid "^8.3.0" uuid "^8.3.0"
which "^2.0.2" which "^2.0.2"
node-releases@^1.1.69: node-releases@^1.1.71:
version "1.1.70" version "1.1.72"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.70.tgz#66e0ed0273aa65666d7fe78febe7634875426a08" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.72.tgz#14802ab6b1039a79a0c7d662b610a5bbd76eacbe"
integrity sha512-Slf2s69+2/uAD79pVVQo8uSiC34+g8GWY8UH2Qtqv34ZfhYrxpYpfzs9Js9d6O0mbDmALuxaTlplnBTnSELcrw== integrity sha512-LLUo+PpH3dU6XizX3iVoubUNheF/owjXCZZ5yACDxNnPtgFuludV1ZL3ayK1kVep42Rmm0+R9/Y60NQbZ2bifw==
normalize-package-data@^2.5.0: normalize-package-data@^2.5.0:
version "2.5.0" version "2.5.0"