You've already forked matrix-js-sdk
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:
23
CHANGELOG.md
23
CHANGELOG.md
@@ -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)
|
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)
|
[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v11.0.0-rc.1...v11.0.0)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "matrix-js-sdk",
|
"name": "matrix-js-sdk",
|
||||||
"version": "11.0.0",
|
"version": "11.1.0",
|
||||||
"description": "Matrix Client-Server SDK for Javascript",
|
"description": "Matrix Client-Server SDK for Javascript",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "yarn build",
|
"prepublishOnly": "yarn build",
|
||||||
@@ -72,6 +72,7 @@
|
|||||||
"@babel/preset-env": "^7.12.11",
|
"@babel/preset-env": "^7.12.11",
|
||||||
"@babel/preset-typescript": "^7.12.7",
|
"@babel/preset-typescript": "^7.12.7",
|
||||||
"@babel/register": "^7.12.10",
|
"@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/jest": "^26.0.20",
|
||||||
"@types/node": "12",
|
"@types/node": "12",
|
||||||
"@types/request": "^2.48.5",
|
"@types/request": "^2.48.5",
|
||||||
@@ -91,7 +92,6 @@
|
|||||||
"jest-localstorage-mock": "^2.4.6",
|
"jest-localstorage-mock": "^2.4.6",
|
||||||
"jsdoc": "^3.6.6",
|
"jsdoc": "^3.6.6",
|
||||||
"matrix-mock-request": "^1.2.3",
|
"matrix-mock-request": "^1.2.3",
|
||||||
"olm": "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz",
|
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"terser": "^5.5.1",
|
"terser": "^5.5.1",
|
||||||
"tsify": "^5.0.2",
|
"tsify": "^5.0.2",
|
||||||
|
@@ -20,12 +20,12 @@ limitations under the License.
|
|||||||
import './olm-loader';
|
import './olm-loader';
|
||||||
|
|
||||||
import MockHttpBackend from 'matrix-mock-request';
|
import MockHttpBackend from 'matrix-mock-request';
|
||||||
import {LocalStorageCryptoStore} from '../src/crypto/store/localStorage-crypto-store';
|
import { LocalStorageCryptoStore } from '../src/crypto/store/localStorage-crypto-store';
|
||||||
import {logger} from '../src/logger';
|
import { logger } from '../src/logger';
|
||||||
import {WebStorageSessionStore} from "../src/store/session/webstorage";
|
import { WebStorageSessionStore } from "../src/store/session/webstorage";
|
||||||
import {syncPromise} from "./test-utils";
|
import { syncPromise } from "./test-utils";
|
||||||
import {createClient} from "../src/matrix";
|
import { createClient } from "../src/matrix";
|
||||||
import {MockStorageApi} from "./MockStorageApi";
|
import { MockStorageApi } from "./MockStorageApi";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for a MockStorageApi, MockHttpBackend and MatrixClient
|
* Wrapper for a MockStorageApi, MockHttpBackend and MatrixClient
|
||||||
@@ -129,11 +129,10 @@ TestClient.prototype.expectDeviceKeyUpload = function() {
|
|||||||
expect(Object.keys(self.oneTimeKeys).length).toEqual(0);
|
expect(Object.keys(self.oneTimeKeys).length).toEqual(0);
|
||||||
|
|
||||||
self.deviceKeys = content.device_keys;
|
self.deviceKeys = content.device_keys;
|
||||||
return {one_time_key_counts: {signed_curve25519: 0}};
|
return { one_time_key_counts: { signed_curve25519: 0 } };
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If one-time keys have already been uploaded, return them. Otherwise,
|
* If one-time keys have already been uploaded, return them. Otherwise,
|
||||||
* set up an expectation that the keys will be uploaded, and wait for
|
* set up an expectation that the keys will be uploaded, and wait for
|
||||||
@@ -151,9 +150,9 @@ TestClient.prototype.awaitOneTimeKeyUpload = function() {
|
|||||||
.respond(200, (path, content) => {
|
.respond(200, (path, content) => {
|
||||||
expect(content.device_keys).toBe(undefined);
|
expect(content.device_keys).toBe(undefined);
|
||||||
expect(content.one_time_keys).toBe(undefined);
|
expect(content.one_time_keys).toBe(undefined);
|
||||||
return {one_time_key_counts: {
|
return { one_time_key_counts: {
|
||||||
signed_curve25519: Object.keys(this.oneTimeKeys).length,
|
signed_curve25519: Object.keys(this.oneTimeKeys).length,
|
||||||
}};
|
} };
|
||||||
});
|
});
|
||||||
|
|
||||||
this.httpBackend.when("POST", "/keys/upload")
|
this.httpBackend.when("POST", "/keys/upload")
|
||||||
@@ -164,9 +163,9 @@ TestClient.prototype.awaitOneTimeKeyUpload = function() {
|
|||||||
logger.log('%s: received %i one-time keys', this,
|
logger.log('%s: received %i one-time keys', this,
|
||||||
Object.keys(content.one_time_keys).length);
|
Object.keys(content.one_time_keys).length);
|
||||||
this.oneTimeKeys = content.one_time_keys;
|
this.oneTimeKeys = content.one_time_keys;
|
||||||
return {one_time_key_counts: {
|
return { one_time_key_counts: {
|
||||||
signed_curve25519: Object.keys(this.oneTimeKeys).length,
|
signed_curve25519: Object.keys(this.oneTimeKeys).length,
|
||||||
}};
|
} };
|
||||||
});
|
});
|
||||||
|
|
||||||
// this can take ages
|
// this can take ages
|
||||||
@@ -197,7 +196,6 @@ TestClient.prototype.expectKeyQuery = function(response) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the uploaded curve25519 device key
|
* get the uploaded curve25519 device key
|
||||||
*
|
*
|
||||||
@@ -208,7 +206,6 @@ TestClient.prototype.getDeviceKey = function() {
|
|||||||
return this.deviceKeys.keys[keyId];
|
return this.deviceKeys.keys[keyId];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the uploaded ed25519 device key
|
* get the uploaded ed25519 device key
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,10 @@ limitations under the License.
|
|||||||
// load XmlHttpRequest mock
|
// load XmlHttpRequest mock
|
||||||
import "./setupTests";
|
import "./setupTests";
|
||||||
import "../../dist/browser-matrix"; // uses browser-matrix instead of the src
|
import "../../dist/browser-matrix"; // uses browser-matrix instead of the src
|
||||||
import {MockStorageApi} from "../MockStorageApi";
|
import { MockStorageApi } from "../MockStorageApi";
|
||||||
import {WebStorageSessionStore} from "../../src/store/session/webstorage";
|
import { WebStorageSessionStore } from "../../src/store/session/webstorage";
|
||||||
import MockHttpBackend from "matrix-mock-request";
|
import MockHttpBackend from "matrix-mock-request";
|
||||||
import {LocalStorageCryptoStore} from "../../src/crypto/store/localStorage-crypto-store";
|
import { LocalStorageCryptoStore } from "../../src/crypto/store/localStorage-crypto-store";
|
||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
|
|
||||||
const USER_ID = "@user:test.server";
|
const USER_ID = "@user:test.server";
|
||||||
@@ -58,7 +58,7 @@ describe("Browserify Test", function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
({client, httpBackend} = await createTestClient());
|
({ client, httpBackend } = await createTestClient());
|
||||||
await client.startClient();
|
await client.startClient();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -16,9 +16,9 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {TestClient} from '../TestClient';
|
import { TestClient } from '../TestClient';
|
||||||
import * as testUtils from '../test-utils';
|
import * as testUtils from '../test-utils';
|
||||||
import {logger} from '../../src/logger';
|
import { logger } from '../../src/logger';
|
||||||
|
|
||||||
const ROOM_ID = "!room:id";
|
const ROOM_ID = "!room:id";
|
||||||
|
|
||||||
@@ -67,7 +67,6 @@ function getSyncResponse(roomMembers) {
|
|||||||
return syncResponse;
|
return syncResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
describe("DeviceList management:", function() {
|
describe("DeviceList management:", function() {
|
||||||
if (!global.Olm) {
|
if (!global.Olm) {
|
||||||
logger.warn('not running deviceList tests: Olm not present');
|
logger.warn('not running deviceList tests: Olm not present');
|
||||||
@@ -98,7 +97,7 @@ describe("DeviceList management:", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Alice shouldn't do a second /query for non-e2e-capable devices", function() {
|
it("Alice shouldn't do a second /query for non-e2e-capable devices", function() {
|
||||||
aliceTestClient.expectKeyQuery({device_keys: {'@alice:localhost': {}}});
|
aliceTestClient.expectKeyQuery({ device_keys: { '@alice:localhost': {} } });
|
||||||
return aliceTestClient.start().then(function() {
|
return aliceTestClient.start().then(function() {
|
||||||
const syncResponse = getSyncResponse(['@bob:xyz']);
|
const syncResponse = getSyncResponse(['@bob:xyz']);
|
||||||
aliceTestClient.httpBackend.when('GET', '/sync').respond(200, syncResponse);
|
aliceTestClient.httpBackend.when('GET', '/sync').respond(200, syncResponse);
|
||||||
@@ -137,11 +136,10 @@ describe("DeviceList management:", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("We should not get confused by out-of-order device query responses",
|
it("We should not get confused by out-of-order device query responses",
|
||||||
() => {
|
() => {
|
||||||
// https://github.com/vector-im/element-web/issues/3126
|
// https://github.com/vector-im/element-web/issues/3126
|
||||||
aliceTestClient.expectKeyQuery({device_keys: {'@alice:localhost': {}}});
|
aliceTestClient.expectKeyQuery({ device_keys: { '@alice:localhost': {} } });
|
||||||
return aliceTestClient.start().then(() => {
|
return aliceTestClient.start().then(() => {
|
||||||
aliceTestClient.httpBackend.when('GET', '/sync').respond(
|
aliceTestClient.httpBackend.when('GET', '/sync').respond(
|
||||||
200, getSyncResponse(['@bob:xyz', '@chris:abc']));
|
200, getSyncResponse(['@bob:xyz', '@chris:abc']));
|
||||||
@@ -160,7 +158,7 @@ describe("DeviceList management:", function() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
aliceTestClient.httpBackend.when('PUT', '/send/').respond(
|
aliceTestClient.httpBackend.when('PUT', '/send/').respond(
|
||||||
200, {event_id: '$event1'});
|
200, { event_id: '$event1' });
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
aliceTestClient.client.sendTextMessage(ROOM_ID, 'test'),
|
aliceTestClient.client.sendTextMessage(ROOM_ID, 'test'),
|
||||||
@@ -199,7 +197,7 @@ describe("DeviceList management:", function() {
|
|||||||
},
|
},
|
||||||
token: '3',
|
token: '3',
|
||||||
}).respond(200, {
|
}).respond(200, {
|
||||||
device_keys: {'@chris:abc': {}},
|
device_keys: { '@chris:abc': {} },
|
||||||
});
|
});
|
||||||
return aliceTestClient.httpBackend.flush('/keys/query', 1);
|
return aliceTestClient.httpBackend.flush('/keys/query', 1);
|
||||||
}).then((flushed) => {
|
}).then((flushed) => {
|
||||||
@@ -228,7 +226,7 @@ describe("DeviceList management:", function() {
|
|||||||
},
|
},
|
||||||
token: '2',
|
token: '2',
|
||||||
}).respond(200, {
|
}).respond(200, {
|
||||||
device_keys: {'@bob:xyz': {}},
|
device_keys: { '@bob:xyz': {} },
|
||||||
});
|
});
|
||||||
return aliceTestClient.httpBackend.flush('/keys/query', 1);
|
return aliceTestClient.httpBackend.flush('/keys/query', 1);
|
||||||
}).then((flushed) => {
|
}).then((flushed) => {
|
||||||
@@ -323,7 +321,6 @@ describe("DeviceList management:", function() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
await aliceTestClient.flushSync();
|
await aliceTestClient.flushSync();
|
||||||
await aliceTestClient.client._crypto._deviceList.saveIfDirty();
|
await aliceTestClient.client._crypto._deviceList.saveIfDirty();
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {TestClient} from "../TestClient";
|
import { TestClient } from "../TestClient";
|
||||||
|
|
||||||
describe("MatrixClient events", function() {
|
describe("MatrixClient events", function() {
|
||||||
let client;
|
let client;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {EventTimeline} from "../../src/matrix";
|
import { EventTimeline } from "../../src/matrix";
|
||||||
import {logger} from "../../src/logger";
|
import { logger } from "../../src/logger";
|
||||||
import {TestClient} from "../TestClient";
|
import { TestClient } from "../TestClient";
|
||||||
|
|
||||||
const userId = "@alice:localhost";
|
const userId = "@alice:localhost";
|
||||||
const userName = "Alice";
|
const userName = "Alice";
|
||||||
@@ -127,7 +127,7 @@ describe("getEventTimeline support", function() {
|
|||||||
"DEVICE",
|
"DEVICE",
|
||||||
accessToken,
|
accessToken,
|
||||||
undefined,
|
undefined,
|
||||||
{timelineSupport: true},
|
{ timelineSupport: true },
|
||||||
);
|
);
|
||||||
client = testClient.client;
|
client = testClient.client;
|
||||||
httpBackend = testClient.httpBackend;
|
httpBackend = testClient.httpBackend;
|
||||||
@@ -141,7 +141,6 @@ describe("getEventTimeline support", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("scrollback should be able to scroll back to before a gappy /sync",
|
it("scrollback should be able to scroll back to before a gappy /sync",
|
||||||
function() {
|
function() {
|
||||||
// need a client with timelineSupport disabled to make this work
|
// need a client with timelineSupport disabled to make this work
|
||||||
@@ -218,7 +217,7 @@ describe("MatrixClient event timelines", function() {
|
|||||||
"DEVICE",
|
"DEVICE",
|
||||||
accessToken,
|
accessToken,
|
||||||
undefined,
|
undefined,
|
||||||
{timelineSupport: true},
|
{ timelineSupport: true },
|
||||||
);
|
);
|
||||||
client = testClient.client;
|
client = testClient.client;
|
||||||
httpBackend = testClient.httpBackend;
|
httpBackend = testClient.httpBackend;
|
||||||
@@ -516,7 +515,7 @@ describe("MatrixClient event timelines", function() {
|
|||||||
client.getEventTimeline(timelineSet, EVENTS[0].event_id,
|
client.getEventTimeline(timelineSet, EVENTS[0].event_id,
|
||||||
).then(function(tl0) {
|
).then(function(tl0) {
|
||||||
tl = tl0;
|
tl = tl0;
|
||||||
return client.paginateEventTimeline(tl, {backwards: true});
|
return client.paginateEventTimeline(tl, { backwards: true });
|
||||||
}).then(function(success) {
|
}).then(function(success) {
|
||||||
expect(success).toBeTruthy();
|
expect(success).toBeTruthy();
|
||||||
expect(tl.getEvents().length).toEqual(3);
|
expect(tl.getEvents().length).toEqual(3);
|
||||||
@@ -532,7 +531,6 @@ describe("MatrixClient event timelines", function() {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("should allow you to paginate forwards", function() {
|
it("should allow you to paginate forwards", function() {
|
||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
const timelineSet = room.getTimelineSets()[0];
|
const timelineSet = room.getTimelineSets()[0];
|
||||||
@@ -569,7 +567,7 @@ describe("MatrixClient event timelines", function() {
|
|||||||
).then(function(tl0) {
|
).then(function(tl0) {
|
||||||
tl = tl0;
|
tl = tl0;
|
||||||
return client.paginateEventTimeline(
|
return client.paginateEventTimeline(
|
||||||
tl, {backwards: false, limit: 20});
|
tl, { backwards: false, limit: 20 });
|
||||||
}).then(function(success) {
|
}).then(function(success) {
|
||||||
expect(success).toBeTruthy();
|
expect(success).toBeTruthy();
|
||||||
expect(tl.getEvents().length).toEqual(3);
|
expect(tl.getEvents().length).toEqual(3);
|
||||||
@@ -591,7 +589,7 @@ describe("MatrixClient event timelines", function() {
|
|||||||
const event = utils.mkMessage({
|
const event = utils.mkMessage({
|
||||||
room: roomId, user: userId, msg: "a body",
|
room: roomId, user: userId, msg: "a body",
|
||||||
});
|
});
|
||||||
event.unsigned = {transaction_id: TXN_ID};
|
event.unsigned = { transaction_id: TXN_ID };
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
// set up handlers for both the message send, and the
|
// set up handlers for both the message send, and the
|
||||||
@@ -680,7 +678,6 @@ describe("MatrixClient event timelines", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("should handle gappy syncs after redactions", function() {
|
it("should handle gappy syncs after redactions", function() {
|
||||||
// https://github.com/vector-im/vector-web/issues/1389
|
// https://github.com/vector-im/vector-web/issues/1389
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {CRYPTO_ENABLED} from "../../src/client";
|
import { CRYPTO_ENABLED } from "../../src/client";
|
||||||
import {Filter, MemoryStore, Room} from "../../src/matrix";
|
import { Filter, MemoryStore, Room } from "../../src/matrix";
|
||||||
import {TestClient} from "../TestClient";
|
import { TestClient } from "../TestClient";
|
||||||
|
|
||||||
describe("MatrixClient", function() {
|
describe("MatrixClient", function() {
|
||||||
let client = null;
|
let client = null;
|
||||||
@@ -285,7 +285,6 @@ describe("MatrixClient", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("downloadKeys", function() {
|
describe("downloadKeys", function() {
|
||||||
if (!CRYPTO_ENABLED) {
|
if (!CRYPTO_ENABLED) {
|
||||||
return;
|
return;
|
||||||
@@ -346,10 +345,10 @@ describe("MatrixClient", function() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
httpBackend.when("POST", "/keys/query").check(function(req) {
|
httpBackend.when("POST", "/keys/query").check(function(req) {
|
||||||
expect(req.data).toEqual({device_keys: {
|
expect(req.data).toEqual({ device_keys: {
|
||||||
'boris': [],
|
'boris': [],
|
||||||
'chaz': [],
|
'chaz': [],
|
||||||
}});
|
} });
|
||||||
}).respond(200, {
|
}).respond(200, {
|
||||||
device_keys: {
|
device_keys: {
|
||||||
boris: borisKeys,
|
boris: borisKeys,
|
||||||
@@ -379,12 +378,12 @@ describe("MatrixClient", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("deleteDevice", function() {
|
describe("deleteDevice", function() {
|
||||||
const auth = {a: 1};
|
const auth = { a: 1 };
|
||||||
it("should pass through an auth dict", function() {
|
it("should pass through an auth dict", function() {
|
||||||
httpBackend.when(
|
httpBackend.when(
|
||||||
"DELETE", "/_matrix/client/r0/devices/my_device",
|
"DELETE", "/_matrix/client/r0/devices/my_device",
|
||||||
).check(function(req) {
|
).check(function(req) {
|
||||||
expect(req.data).toEqual({auth: auth});
|
expect(req.data).toEqual({ auth: auth });
|
||||||
}).respond(200);
|
}).respond(200);
|
||||||
|
|
||||||
const prom = client.deleteDevice("my_device", auth);
|
const prom = client.deleteDevice("my_device", auth);
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import HttpBackend from "matrix-mock-request";
|
import HttpBackend from "matrix-mock-request";
|
||||||
import {MatrixClient} from "../../src/matrix";
|
import { MatrixClient } from "../../src/matrix";
|
||||||
import {MatrixScheduler} from "../../src/scheduler";
|
import { MatrixScheduler } from "../../src/scheduler";
|
||||||
import {MemoryStore} from "../../src/store/memory";
|
import { MemoryStore } from "../../src/store/memory";
|
||||||
import {MatrixError} from "../../src/http-api";
|
import { MatrixError } from "../../src/http-api";
|
||||||
|
|
||||||
describe("MatrixClient opts", function() {
|
describe("MatrixClient opts", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
const baseUrl = "http://localhost.or.something";
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import {EventStatus} from "../../src/matrix";
|
import { EventStatus } from "../../src/matrix";
|
||||||
import {MatrixScheduler} from "../../src/scheduler";
|
import { MatrixScheduler } from "../../src/scheduler";
|
||||||
import {Room} from "../../src/models/room";
|
import { Room } from "../../src/models/room";
|
||||||
import {TestClient} from "../TestClient";
|
import { TestClient } from "../TestClient";
|
||||||
|
|
||||||
describe("MatrixClient retrying", function() {
|
describe("MatrixClient retrying", function() {
|
||||||
let client = null;
|
let client = null;
|
||||||
@@ -19,7 +19,7 @@ describe("MatrixClient retrying", function() {
|
|||||||
"DEVICE",
|
"DEVICE",
|
||||||
accessToken,
|
accessToken,
|
||||||
undefined,
|
undefined,
|
||||||
{scheduler},
|
{ scheduler },
|
||||||
);
|
);
|
||||||
httpBackend = testClient.httpBackend;
|
httpBackend = testClient.httpBackend;
|
||||||
client = testClient.client;
|
client = testClient.client;
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {EventStatus} from "../../src/models/event";
|
import { EventStatus } from "../../src/models/event";
|
||||||
import {TestClient} from "../TestClient";
|
import { TestClient } from "../TestClient";
|
||||||
|
|
||||||
|
|
||||||
describe("MatrixClient room timelines", function() {
|
describe("MatrixClient room timelines", function() {
|
||||||
let client = null;
|
let client = null;
|
||||||
@@ -104,7 +103,7 @@ describe("MatrixClient room timelines", function() {
|
|||||||
"DEVICE",
|
"DEVICE",
|
||||||
accessToken,
|
accessToken,
|
||||||
undefined,
|
undefined,
|
||||||
{timelineSupport: true},
|
{ timelineSupport: true },
|
||||||
);
|
);
|
||||||
httpBackend = testClient.httpBackend;
|
httpBackend = testClient.httpBackend;
|
||||||
client = testClient.client;
|
client = testClient.client;
|
||||||
@@ -166,7 +165,7 @@ describe("MatrixClient room timelines", function() {
|
|||||||
body: "I am a fish", user: userId, room: roomId,
|
body: "I am a fish", user: userId, room: roomId,
|
||||||
});
|
});
|
||||||
ev.event_id = eventId;
|
ev.event_id = eventId;
|
||||||
ev.unsigned = {transaction_id: "txn1"};
|
ev.unsigned = { transaction_id: "txn1" };
|
||||||
setNextSyncData([ev]);
|
setNextSyncData([ev]);
|
||||||
|
|
||||||
client.on("sync", function(state) {
|
client.on("sync", function(state) {
|
||||||
@@ -198,7 +197,7 @@ describe("MatrixClient room timelines", function() {
|
|||||||
body: "I am a fish", user: userId, room: roomId,
|
body: "I am a fish", user: userId, room: roomId,
|
||||||
});
|
});
|
||||||
ev.event_id = eventId;
|
ev.event_id = eventId;
|
||||||
ev.unsigned = {transaction_id: "txn1"};
|
ev.unsigned = { transaction_id: "txn1" };
|
||||||
setNextSyncData([ev]);
|
setNextSyncData([ev]);
|
||||||
|
|
||||||
client.on("sync", function(state) {
|
client.on("sync", function(state) {
|
||||||
@@ -396,8 +395,8 @@ describe("MatrixClient room timelines", function() {
|
|||||||
describe("new events", function() {
|
describe("new events", function() {
|
||||||
it("should be added to the right place in the timeline", function() {
|
it("should be added to the right place in the timeline", function() {
|
||||||
const eventData = [
|
const eventData = [
|
||||||
utils.mkMessage({user: userId, room: roomId}),
|
utils.mkMessage({ user: userId, room: roomId }),
|
||||||
utils.mkMessage({user: userId, room: roomId}),
|
utils.mkMessage({ user: userId, room: roomId }),
|
||||||
];
|
];
|
||||||
setNextSyncData(eventData);
|
setNextSyncData(eventData);
|
||||||
|
|
||||||
@@ -434,11 +433,11 @@ describe("MatrixClient room timelines", function() {
|
|||||||
|
|
||||||
it("should set the right event.sender values", function() {
|
it("should set the right event.sender values", function() {
|
||||||
const eventData = [
|
const eventData = [
|
||||||
utils.mkMessage({user: userId, room: roomId}),
|
utils.mkMessage({ user: userId, room: roomId }),
|
||||||
utils.mkMembership({
|
utils.mkMembership({
|
||||||
user: userId, room: roomId, mship: "join", name: "New Name",
|
user: userId, room: roomId, mship: "join", name: "New Name",
|
||||||
}),
|
}),
|
||||||
utils.mkMessage({user: userId, room: roomId}),
|
utils.mkMessage({ user: userId, room: roomId }),
|
||||||
];
|
];
|
||||||
eventData[1].__prev_event = USER_MEMBERSHIP_EVENT;
|
eventData[1].__prev_event = USER_MEMBERSHIP_EVENT;
|
||||||
setNextSyncData(eventData);
|
setNextSyncData(eventData);
|
||||||
@@ -546,7 +545,7 @@ describe("MatrixClient room timelines", function() {
|
|||||||
describe("gappy sync", function() {
|
describe("gappy sync", function() {
|
||||||
it("should copy the last known state to the new timeline", function() {
|
it("should copy the last known state to the new timeline", function() {
|
||||||
const eventData = [
|
const eventData = [
|
||||||
utils.mkMessage({user: userId, room: roomId}),
|
utils.mkMessage({ user: userId, room: roomId }),
|
||||||
];
|
];
|
||||||
setNextSyncData(eventData);
|
setNextSyncData(eventData);
|
||||||
NEXT_SYNC_DATA.rooms.join[roomId].timeline.limited = true;
|
NEXT_SYNC_DATA.rooms.join[roomId].timeline.limited = true;
|
||||||
@@ -579,7 +578,7 @@ describe("MatrixClient room timelines", function() {
|
|||||||
|
|
||||||
it("should emit a 'Room.timelineReset' event", function() {
|
it("should emit a 'Room.timelineReset' event", function() {
|
||||||
const eventData = [
|
const eventData = [
|
||||||
utils.mkMessage({user: userId, room: roomId}),
|
utils.mkMessage({ user: userId, room: roomId }),
|
||||||
];
|
];
|
||||||
setNextSyncData(eventData);
|
setNextSyncData(eventData);
|
||||||
NEXT_SYNC_DATA.rooms.join[roomId].timeline.limited = true;
|
NEXT_SYNC_DATA.rooms.join[roomId].timeline.limited = true;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import {MatrixEvent} from "../../src/models/event";
|
import { MatrixEvent } from "../../src/models/event";
|
||||||
import {EventTimeline} from "../../src/models/event-timeline";
|
import { EventTimeline } from "../../src/models/event-timeline";
|
||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {TestClient} from "../TestClient";
|
import { TestClient } from "../TestClient";
|
||||||
|
|
||||||
describe("MatrixClient syncing", function() {
|
describe("MatrixClient syncing", function() {
|
||||||
let client = null;
|
let client = null;
|
||||||
@@ -122,7 +122,6 @@ describe("MatrixClient syncing", function() {
|
|||||||
resolveInvitesToProfiles: true,
|
resolveInvitesToProfiles: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
httpBackend.flushAllExpected(),
|
httpBackend.flushAllExpected(),
|
||||||
awaitSyncEvent(),
|
awaitSyncEvent(),
|
||||||
@@ -677,8 +676,8 @@ describe("MatrixClient syncing", function() {
|
|||||||
it("should create and use an appropriate filter", function() {
|
it("should create and use an appropriate filter", function() {
|
||||||
httpBackend.when("POST", "/filter").check(function(req) {
|
httpBackend.when("POST", "/filter").check(function(req) {
|
||||||
expect(req.data).toEqual({
|
expect(req.data).toEqual({
|
||||||
room: { timeline: {limit: 1},
|
room: { timeline: { limit: 1 },
|
||||||
include_leave: true }});
|
include_leave: true } });
|
||||||
}).respond(200, { filter_id: "another_id" });
|
}).respond(200, { filter_id: "another_id" });
|
||||||
|
|
||||||
const prom = new Promise((resolve) => {
|
const prom = new Promise((resolve) => {
|
||||||
|
@@ -17,8 +17,8 @@ limitations under the License.
|
|||||||
|
|
||||||
import anotherjson from "another-json";
|
import anotherjson from "another-json";
|
||||||
import * as testUtils from "../test-utils";
|
import * as testUtils from "../test-utils";
|
||||||
import {TestClient} from "../TestClient";
|
import { TestClient } from "../TestClient";
|
||||||
import {logger} from "../../src/logger";
|
import { logger } from "../../src/logger";
|
||||||
|
|
||||||
const ROOM_ID = "!room:id";
|
const ROOM_ID = "!room:id";
|
||||||
|
|
||||||
@@ -196,7 +196,6 @@ function getSyncResponse(roomMembers) {
|
|||||||
return syncResponse;
|
return syncResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
describe("megolm", function() {
|
describe("megolm", function() {
|
||||||
if (!global.Olm) {
|
if (!global.Olm) {
|
||||||
logger.warn('not running megolm tests: Olm not present');
|
logger.warn('not running megolm tests: Olm not present');
|
||||||
@@ -268,7 +267,7 @@ describe("megolm", function() {
|
|||||||
'ed25519:DEVICE_ID': sig,
|
'ed25519:DEVICE_ID': sig,
|
||||||
};
|
};
|
||||||
|
|
||||||
const claimResponse = {one_time_keys: {}};
|
const claimResponse = { one_time_keys: {} };
|
||||||
claimResponse.one_time_keys[userId] = {
|
claimResponse.one_time_keys[userId] = {
|
||||||
'DEVICE_ID': {},
|
'DEVICE_ID': {},
|
||||||
};
|
};
|
||||||
@@ -494,7 +493,7 @@ describe("megolm", function() {
|
|||||||
it('Alice sends a megolm message', function() {
|
it('Alice sends a megolm message', function() {
|
||||||
let p2pSession;
|
let p2pSession;
|
||||||
|
|
||||||
aliceTestClient.expectKeyQuery({device_keys: {'@alice:localhost': {}}});
|
aliceTestClient.expectKeyQuery({ device_keys: { '@alice:localhost': {} } });
|
||||||
return aliceTestClient.start().then(() => {
|
return aliceTestClient.start().then(() => {
|
||||||
// establish an olm session with alice
|
// establish an olm session with alice
|
||||||
return createOlmSession(testOlmAccount, aliceTestClient);
|
return createOlmSession(testOlmAccount, aliceTestClient);
|
||||||
@@ -577,7 +576,7 @@ describe("megolm", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("We shouldn't attempt to send to blocked devices", function() {
|
it("We shouldn't attempt to send to blocked devices", function() {
|
||||||
aliceTestClient.expectKeyQuery({device_keys: {'@alice:localhost': {}}});
|
aliceTestClient.expectKeyQuery({ device_keys: { '@alice:localhost': {} } });
|
||||||
return aliceTestClient.start().then(() => {
|
return aliceTestClient.start().then(() => {
|
||||||
// establish an olm session with alice
|
// establish an olm session with alice
|
||||||
return createOlmSession(testOlmAccount, aliceTestClient);
|
return createOlmSession(testOlmAccount, aliceTestClient);
|
||||||
@@ -634,7 +633,7 @@ describe("megolm", function() {
|
|||||||
let p2pSession;
|
let p2pSession;
|
||||||
let megolmSessionId;
|
let megolmSessionId;
|
||||||
|
|
||||||
aliceTestClient.expectKeyQuery({device_keys: {'@alice:localhost': {}}});
|
aliceTestClient.expectKeyQuery({ device_keys: { '@alice:localhost': {} } });
|
||||||
return aliceTestClient.start().then(() => {
|
return aliceTestClient.start().then(() => {
|
||||||
// establish an olm session with alice
|
// establish an olm session with alice
|
||||||
return createOlmSession(testOlmAccount, aliceTestClient);
|
return createOlmSession(testOlmAccount, aliceTestClient);
|
||||||
@@ -841,13 +840,12 @@ describe("megolm", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Alice should wait for device list to complete when sending a megolm message',
|
it('Alice should wait for device list to complete when sending a megolm message',
|
||||||
function() {
|
function() {
|
||||||
let downloadPromise;
|
let downloadPromise;
|
||||||
let sendPromise;
|
let sendPromise;
|
||||||
|
|
||||||
aliceTestClient.expectKeyQuery({device_keys: {'@alice:localhost': {}}});
|
aliceTestClient.expectKeyQuery({ device_keys: { '@alice:localhost': {} } });
|
||||||
return aliceTestClient.start().then(() => {
|
return aliceTestClient.start().then(() => {
|
||||||
// establish an olm session with alice
|
// establish an olm session with alice
|
||||||
return createOlmSession(testOlmAccount, aliceTestClient);
|
return createOlmSession(testOlmAccount, aliceTestClient);
|
||||||
@@ -887,11 +885,10 @@ describe("megolm", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("Alice exports megolm keys and imports them to a new device", function() {
|
it("Alice exports megolm keys and imports them to a new device", function() {
|
||||||
let messageEncrypted;
|
let messageEncrypted;
|
||||||
|
|
||||||
aliceTestClient.expectKeyQuery({device_keys: {'@alice:localhost': {}}});
|
aliceTestClient.expectKeyQuery({ device_keys: { '@alice:localhost': {} } });
|
||||||
return aliceTestClient.start().then(() => {
|
return aliceTestClient.start().then(() => {
|
||||||
// establish an olm session with alice
|
// establish an olm session with alice
|
||||||
return createOlmSession(testOlmAccount, aliceTestClient);
|
return createOlmSession(testOlmAccount, aliceTestClient);
|
||||||
|
@@ -15,12 +15,12 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../src/logger';
|
import { logger } from '../src/logger';
|
||||||
import * as utils from "../src/utils";
|
import * as utils from "../src/utils";
|
||||||
|
|
||||||
// try to load the olm library.
|
// try to load the olm library.
|
||||||
try {
|
try {
|
||||||
global.Olm = require('olm');
|
global.Olm = require('@matrix-org/olm');
|
||||||
logger.log('loaded libolm');
|
logger.log('loaded libolm');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn("unable to run crypto tests: libolm not available");
|
logger.warn("unable to run crypto tests: libolm not available");
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
// load olm before the sdk if possible
|
// load olm before the sdk if possible
|
||||||
import './olm-loader';
|
import './olm-loader';
|
||||||
|
|
||||||
import {logger} from '../src/logger';
|
import { logger } from '../src/logger';
|
||||||
import {MatrixEvent} from "../src/models/event";
|
import { MatrixEvent } from "../src/models/event";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a promise that is resolved when the client next emits a
|
* Return a promise that is resolved when the client next emits a
|
||||||
@@ -177,7 +177,6 @@ export function mkMessage(opts) {
|
|||||||
return mkEvent(opts);
|
return mkEvent(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mock implementation of webstorage
|
* A mock implementation of webstorage
|
||||||
*
|
*
|
||||||
@@ -204,7 +203,6 @@ MockStorageApi.prototype = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If an event is being decrypted, wait for it to finish being decrypted.
|
* If an event is being decrypted, wait for it to finish being decrypted.
|
||||||
*
|
*
|
||||||
@@ -229,7 +227,6 @@ export function awaitDecryption(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function HttpResponse(
|
export function HttpResponse(
|
||||||
httpLookups, acceptKeepalives, ignoreUnhandledSync,
|
httpLookups, acceptKeepalives, ignoreUnhandledSync,
|
||||||
) {
|
) {
|
||||||
|
@@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
|
|
||||||
import MockHttpBackend from "matrix-mock-request";
|
import MockHttpBackend from "matrix-mock-request";
|
||||||
import * as sdk from "../../src";
|
import * as sdk from "../../src";
|
||||||
import {AutoDiscovery} from "../../src/autodiscovery";
|
import { AutoDiscovery } from "../../src/autodiscovery";
|
||||||
|
|
||||||
describe("AutoDiscovery", function() {
|
describe("AutoDiscovery", function() {
|
||||||
let httpBackend = null;
|
let httpBackend = null;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import {getHttpUriForMxc} from "../../src/content-repo";
|
import { getHttpUriForMxc } from "../../src/content-repo";
|
||||||
|
|
||||||
describe("ContentRepo", function() {
|
describe("ContentRepo", function() {
|
||||||
const baseUrl = "https://my.home.server";
|
const baseUrl = "https://my.home.server";
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
import '../olm-loader';
|
import '../olm-loader';
|
||||||
import {Crypto} from "../../src/crypto";
|
import { Crypto } from "../../src/crypto";
|
||||||
import {WebStorageSessionStore} from "../../src/store/session/webstorage";
|
import { WebStorageSessionStore } from "../../src/store/session/webstorage";
|
||||||
import {MemoryCryptoStore} from "../../src/crypto/store/memory-crypto-store";
|
import { MemoryCryptoStore } from "../../src/crypto/store/memory-crypto-store";
|
||||||
import {MockStorageApi} from "../MockStorageApi";
|
import { MockStorageApi } from "../MockStorageApi";
|
||||||
import {TestClient} from "../TestClient";
|
import { TestClient } from "../TestClient";
|
||||||
import {MatrixEvent} from "../../src/models/event";
|
import { MatrixEvent } from "../../src/models/event";
|
||||||
import {Room} from "../../src/models/room";
|
import { Room } from "../../src/models/room";
|
||||||
import * as olmlib from "../../src/crypto/olmlib";
|
import * as olmlib from "../../src/crypto/olmlib";
|
||||||
import {sleep} from "../../src/utils";
|
import { sleep } from "../../src/utils";
|
||||||
import {EventEmitter} from "events";
|
import { EventEmitter } from "events";
|
||||||
import {CRYPTO_ENABLED} from "../../src/client";
|
import { CRYPTO_ENABLED } from "../../src/client";
|
||||||
import {DeviceInfo} from "../../src/crypto/deviceinfo";
|
import { DeviceInfo } from "../../src/crypto/deviceinfo";
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ describe("Crypto", function() {
|
|||||||
|
|
||||||
// unknown sender (e.g. deleted device), forwarded megolm key (untrusted)
|
// unknown sender (e.g. deleted device), forwarded megolm key (untrusted)
|
||||||
event.getSenderKey = () => 'YmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmI';
|
event.getSenderKey = () => 'YmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmI';
|
||||||
event.getWireContent = () => {return {algorithm: olmlib.MEGOLM_ALGORITHM};};
|
event.getWireContent = () => {return { algorithm: olmlib.MEGOLM_ALGORITHM };};
|
||||||
event.getForwardingCurve25519KeyChain = () => ["not empty"];
|
event.getForwardingCurve25519KeyChain = () => ["not empty"];
|
||||||
event.isKeySourceUntrusted = () => false;
|
event.isKeySourceUntrusted = () => false;
|
||||||
event.getClaimedEd25519Key =
|
event.getClaimedEd25519Key =
|
||||||
|
@@ -22,11 +22,11 @@ import {
|
|||||||
import {
|
import {
|
||||||
IndexedDBCryptoStore,
|
IndexedDBCryptoStore,
|
||||||
} from '../../../src/crypto/store/indexeddb-crypto-store';
|
} from '../../../src/crypto/store/indexeddb-crypto-store';
|
||||||
import {MemoryCryptoStore} from '../../../src/crypto/store/memory-crypto-store';
|
import { MemoryCryptoStore } from '../../../src/crypto/store/memory-crypto-store';
|
||||||
import 'fake-indexeddb/auto';
|
import 'fake-indexeddb/auto';
|
||||||
import 'jest-localstorage-mock';
|
import 'jest-localstorage-mock';
|
||||||
import {OlmDevice} from "../../../src/crypto/OlmDevice";
|
import { OlmDevice } from "../../../src/crypto/OlmDevice";
|
||||||
import {logger} from '../../../src/logger';
|
import { logger } from '../../../src/logger';
|
||||||
|
|
||||||
const userId = "@alice:example.com";
|
const userId = "@alice:example.com";
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ describe("CrossSigningInfo.getCrossSigningKey", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each(types)("should throw if the callback returns falsey",
|
it.each(types)("should throw if the callback returns falsey",
|
||||||
async ({type, shouldCache}) => {
|
async ({ type, shouldCache }) => {
|
||||||
const info = new CrossSigningInfo(userId, {
|
const info = new CrossSigningInfo(userId, {
|
||||||
getCrossSigningKey: () => false,
|
getCrossSigningKey: () => false,
|
||||||
});
|
});
|
||||||
|
@@ -16,10 +16,10 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from "../../../src/logger";
|
import { logger } from "../../../src/logger";
|
||||||
import * as utils from "../../../src/utils";
|
import * as utils from "../../../src/utils";
|
||||||
import {MemoryCryptoStore} from "../../../src/crypto/store/memory-crypto-store";
|
import { MemoryCryptoStore } from "../../../src/crypto/store/memory-crypto-store";
|
||||||
import {DeviceList} from "../../../src/crypto/DeviceList";
|
import { DeviceList } from "../../../src/crypto/DeviceList";
|
||||||
|
|
||||||
const signedDeviceList = {
|
const signedDeviceList = {
|
||||||
"failures": {},
|
"failures": {},
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
import '../../../olm-loader';
|
import '../../../olm-loader';
|
||||||
import * as algorithms from "../../../../src/crypto/algorithms";
|
import * as algorithms from "../../../../src/crypto/algorithms";
|
||||||
import {MemoryCryptoStore} from "../../../../src/crypto/store/memory-crypto-store";
|
import { MemoryCryptoStore } from "../../../../src/crypto/store/memory-crypto-store";
|
||||||
import {MockStorageApi} from "../../../MockStorageApi";
|
import { MockStorageApi } from "../../../MockStorageApi";
|
||||||
import * as testUtils from "../../../test-utils";
|
import * as testUtils from "../../../test-utils";
|
||||||
import {OlmDevice} from "../../../../src/crypto/OlmDevice";
|
import { OlmDevice } from "../../../../src/crypto/OlmDevice";
|
||||||
import {Crypto} from "../../../../src/crypto";
|
import { Crypto } from "../../../../src/crypto";
|
||||||
import {logger} from "../../../../src/logger";
|
import { logger } from "../../../../src/logger";
|
||||||
import {MatrixEvent} from "../../../../src/models/event";
|
import { MatrixEvent } from "../../../../src/models/event";
|
||||||
import {TestClient} from "../../../TestClient";
|
import { TestClient } from "../../../TestClient";
|
||||||
import {Room} from "../../../../src/models/room";
|
import { Room } from "../../../../src/models/room";
|
||||||
import * as olmlib from "../../../../src/crypto/olmlib";
|
import * as olmlib from "../../../../src/crypto/olmlib";
|
||||||
|
|
||||||
const MegolmDecryption = algorithms.DECRYPTION_CLASSES['m.megolm.v1.aes-sha2'];
|
const MegolmDecryption = algorithms.DECRYPTION_CLASSES['m.megolm.v1.aes-sha2'];
|
||||||
@@ -50,7 +50,6 @@ describe("MegolmDecryption", function() {
|
|||||||
roomId: ROOM_ID,
|
roomId: ROOM_ID,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// we stub out the olm encryption bits
|
// we stub out the olm encryption bits
|
||||||
mockOlmLib = {};
|
mockOlmLib = {};
|
||||||
mockOlmLib.ensureOlmSessionsForDevices = jest.fn();
|
mockOlmLib.ensureOlmSessionsForDevices = jest.fn();
|
||||||
@@ -136,9 +135,9 @@ describe("MegolmDecryption", function() {
|
|||||||
mockCrypto.getStoredDevice.mockReturnValue(deviceInfo);
|
mockCrypto.getStoredDevice.mockReturnValue(deviceInfo);
|
||||||
|
|
||||||
mockOlmLib.ensureOlmSessionsForDevices.mockResolvedValue({
|
mockOlmLib.ensureOlmSessionsForDevices.mockResolvedValue({
|
||||||
'@alice:foo': {'alidevice': {
|
'@alice:foo': { 'alidevice': {
|
||||||
sessionId: 'alisession',
|
sessionId: 'alisession',
|
||||||
}},
|
} },
|
||||||
});
|
});
|
||||||
|
|
||||||
const awaitEncryptForDevice = new Promise((res, rej) => {
|
const awaitEncryptForDevice = new Promise((res, rej) => {
|
||||||
@@ -313,7 +312,7 @@ describe("MegolmDecryption", function() {
|
|||||||
});
|
});
|
||||||
const mockRoom = {
|
const mockRoom = {
|
||||||
getEncryptionTargetMembers: jest.fn().mockReturnValue(
|
getEncryptionTargetMembers: jest.fn().mockReturnValue(
|
||||||
[{userId: "@alice:home.server"}],
|
[{ userId: "@alice:home.server" }],
|
||||||
),
|
),
|
||||||
getBlacklistUnverifiedDevices: jest.fn().mockReturnValue(false),
|
getBlacklistUnverifiedDevices: jest.fn().mockReturnValue(false),
|
||||||
};
|
};
|
||||||
@@ -373,7 +372,7 @@ describe("MegolmDecryption", function() {
|
|||||||
const roomId = "!someroom";
|
const roomId = "!someroom";
|
||||||
const room = new Room(roomId, aliceClient, "@alice:example.com", {});
|
const room = new Room(roomId, aliceClient, "@alice:example.com", {});
|
||||||
room.getEncryptionTargetMembers = async function() {
|
room.getEncryptionTargetMembers = async function() {
|
||||||
return [{userId: "@bob:example.com"}];
|
return [{ userId: "@bob:example.com" }];
|
||||||
};
|
};
|
||||||
room.setBlacklistUnverifiedDevices(true);
|
room.setBlacklistUnverifiedDevices(true);
|
||||||
aliceClient.store.storeRoom(room);
|
aliceClient.store.storeRoom(room);
|
||||||
|
@@ -16,12 +16,12 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import '../../../olm-loader';
|
import '../../../olm-loader';
|
||||||
import {MemoryCryptoStore} from "../../../../src/crypto/store/memory-crypto-store";
|
import { MemoryCryptoStore } from "../../../../src/crypto/store/memory-crypto-store";
|
||||||
import {MockStorageApi} from "../../../MockStorageApi";
|
import { MockStorageApi } from "../../../MockStorageApi";
|
||||||
import {logger} from "../../../../src/logger";
|
import { logger } from "../../../../src/logger";
|
||||||
import {OlmDevice} from "../../../../src/crypto/OlmDevice";
|
import { OlmDevice } from "../../../../src/crypto/OlmDevice";
|
||||||
import * as olmlib from "../../../../src/crypto/olmlib";
|
import * as olmlib from "../../../../src/crypto/olmlib";
|
||||||
import {DeviceInfo} from "../../../../src/crypto/deviceinfo";
|
import { DeviceInfo } from "../../../../src/crypto/deviceinfo";
|
||||||
|
|
||||||
function makeOlmDevice() {
|
function makeOlmDevice() {
|
||||||
const mockStorage = new MockStorageApi();
|
const mockStorage = new MockStorageApi();
|
||||||
|
@@ -16,18 +16,18 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import '../../olm-loader';
|
import '../../olm-loader';
|
||||||
import {logger} from "../../../src/logger";
|
import { logger } from "../../../src/logger";
|
||||||
import * as olmlib from "../../../src/crypto/olmlib";
|
import * as olmlib from "../../../src/crypto/olmlib";
|
||||||
import {MatrixClient} from "../../../src/client";
|
import { MatrixClient } from "../../../src/client";
|
||||||
import {MatrixEvent} from "../../../src/models/event";
|
import { MatrixEvent } from "../../../src/models/event";
|
||||||
import * as algorithms from "../../../src/crypto/algorithms";
|
import * as algorithms from "../../../src/crypto/algorithms";
|
||||||
import {WebStorageSessionStore} from "../../../src/store/session/webstorage";
|
import { WebStorageSessionStore } from "../../../src/store/session/webstorage";
|
||||||
import {MemoryCryptoStore} from "../../../src/crypto/store/memory-crypto-store";
|
import { MemoryCryptoStore } from "../../../src/crypto/store/memory-crypto-store";
|
||||||
import {MockStorageApi} from "../../MockStorageApi";
|
import { MockStorageApi } from "../../MockStorageApi";
|
||||||
import * as testUtils from "../../test-utils";
|
import * as testUtils from "../../test-utils";
|
||||||
import {OlmDevice} from "../../../src/crypto/OlmDevice";
|
import { OlmDevice } from "../../../src/crypto/OlmDevice";
|
||||||
import {Crypto} from "../../../src/crypto";
|
import { Crypto } from "../../../src/crypto";
|
||||||
import {resetCrossSigningKeys} from "./crypto-utils";
|
import { resetCrossSigningKeys } from "./crypto-utils";
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
|
@@ -18,11 +18,11 @@ limitations under the License.
|
|||||||
import '../../olm-loader';
|
import '../../olm-loader';
|
||||||
import anotherjson from 'another-json';
|
import anotherjson from 'another-json';
|
||||||
import * as olmlib from "../../../src/crypto/olmlib";
|
import * as olmlib from "../../../src/crypto/olmlib";
|
||||||
import {TestClient} from '../../TestClient';
|
import { TestClient } from '../../TestClient';
|
||||||
import {HttpResponse, setHttpResponses} from '../../test-utils';
|
import { HttpResponse, setHttpResponses } from '../../test-utils';
|
||||||
import { resetCrossSigningKeys } from "./crypto-utils";
|
import { resetCrossSigningKeys } from "./crypto-utils";
|
||||||
import { MatrixError } from '../../../src/http-api';
|
import { MatrixError } from '../../../src/http-api';
|
||||||
import {logger} from '../../../src/logger';
|
import { logger } from '../../../src/logger';
|
||||||
|
|
||||||
async function makeTestClient(userInfo, options, keys) {
|
async function makeTestClient(userInfo, options, keys) {
|
||||||
if (!keys) keys = {};
|
if (!keys) keys = {};
|
||||||
@@ -60,7 +60,7 @@ describe("Cross Signing", function() {
|
|||||||
|
|
||||||
it("should sign the master key with the device key", async function() {
|
it("should sign the master key with the device key", async function() {
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
);
|
);
|
||||||
alice.uploadDeviceSigningKeys = jest.fn(async (auth, keys) => {
|
alice.uploadDeviceSigningKeys = jest.fn(async (auth, keys) => {
|
||||||
await olmlib.verifySignature(
|
await olmlib.verifySignature(
|
||||||
@@ -80,7 +80,7 @@ describe("Cross Signing", function() {
|
|||||||
|
|
||||||
it("should abort bootstrap if device signing auth fails", async function() {
|
it("should abort bootstrap if device signing auth fails", async function() {
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
);
|
);
|
||||||
alice.uploadDeviceSigningKeys = async (auth, keys) => {
|
alice.uploadDeviceSigningKeys = async (auth, keys) => {
|
||||||
const errorResponse = {
|
const errorResponse = {
|
||||||
@@ -131,7 +131,7 @@ describe("Cross Signing", function() {
|
|||||||
|
|
||||||
it("should upload a signature when a user is verified", async function() {
|
it("should upload a signature when a user is verified", async function() {
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
);
|
);
|
||||||
alice.uploadDeviceSigningKeys = async () => {};
|
alice.uploadDeviceSigningKeys = async () => {};
|
||||||
alice.uploadKeySignatures = async () => {};
|
alice.uploadKeySignatures = async () => {};
|
||||||
@@ -175,7 +175,7 @@ describe("Cross Signing", function() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{
|
{
|
||||||
cryptoCallbacks: {
|
cryptoCallbacks: {
|
||||||
// will be called to sign our own device
|
// will be called to sign our own device
|
||||||
@@ -328,7 +328,7 @@ describe("Cross Signing", function() {
|
|||||||
|
|
||||||
it("should use trust chain to determine device verification", async function() {
|
it("should use trust chain to determine device verification", async function() {
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
);
|
);
|
||||||
alice.uploadDeviceSigningKeys = async () => {};
|
alice.uploadDeviceSigningKeys = async () => {};
|
||||||
alice.uploadKeySignatures = async () => {};
|
alice.uploadKeySignatures = async () => {};
|
||||||
@@ -413,7 +413,7 @@ describe("Cross Signing", function() {
|
|||||||
it("should trust signatures received from other devices", async function() {
|
it("should trust signatures received from other devices", async function() {
|
||||||
const aliceKeys = {};
|
const aliceKeys = {};
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
null,
|
null,
|
||||||
aliceKeys,
|
aliceKeys,
|
||||||
);
|
);
|
||||||
@@ -575,7 +575,7 @@ describe("Cross Signing", function() {
|
|||||||
|
|
||||||
it("should dis-trust an unsigned device", async function() {
|
it("should dis-trust an unsigned device", async function() {
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
);
|
);
|
||||||
alice.uploadDeviceSigningKeys = async () => {};
|
alice.uploadDeviceSigningKeys = async () => {};
|
||||||
alice.uploadKeySignatures = async () => {};
|
alice.uploadKeySignatures = async () => {};
|
||||||
@@ -644,7 +644,7 @@ describe("Cross Signing", function() {
|
|||||||
|
|
||||||
it("should dis-trust a user when their ssk changes", async function() {
|
it("should dis-trust a user when their ssk changes", async function() {
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
);
|
);
|
||||||
alice.uploadDeviceSigningKeys = async () => {};
|
alice.uploadDeviceSigningKeys = async () => {};
|
||||||
alice.uploadKeySignatures = async () => {};
|
alice.uploadKeySignatures = async () => {};
|
||||||
@@ -782,7 +782,7 @@ describe("Cross Signing", function() {
|
|||||||
let upgradeResolveFunc;
|
let upgradeResolveFunc;
|
||||||
|
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{
|
{
|
||||||
cryptoCallbacks: {
|
cryptoCallbacks: {
|
||||||
shouldUpgradeDeviceVerifications: (verifs) => {
|
shouldUpgradeDeviceVerifications: (verifs) => {
|
||||||
@@ -794,7 +794,7 @@ describe("Cross Signing", function() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
const bob = await makeTestClient(
|
const bob = await makeTestClient(
|
||||||
{userId: "@bob:example.com", deviceId: "Dynabook"},
|
{ userId: "@bob:example.com", deviceId: "Dynabook" },
|
||||||
);
|
);
|
||||||
|
|
||||||
bob.uploadDeviceSigningKeys = async () => {};
|
bob.uploadDeviceSigningKeys = async () => {};
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import {IndexedDBCryptoStore} from '../../../src/crypto/store/indexeddb-crypto-store';
|
import { IndexedDBCryptoStore } from '../../../src/crypto/store/indexeddb-crypto-store';
|
||||||
|
|
||||||
|
|
||||||
// needs to be phased out and replaced with bootstrapSecretStorage,
|
// needs to be phased out and replaced with bootstrapSecretStorage,
|
||||||
// but that is doing too much extra stuff for it to be an easy transition.
|
// but that is doing too much extra stuff for it to be an easy transition.
|
||||||
|
@@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
import {
|
import {
|
||||||
IndexedDBCryptoStore,
|
IndexedDBCryptoStore,
|
||||||
} from '../../../src/crypto/store/indexeddb-crypto-store';
|
} from '../../../src/crypto/store/indexeddb-crypto-store';
|
||||||
import {MemoryCryptoStore} from '../../../src/crypto/store/memory-crypto-store';
|
import { MemoryCryptoStore } from '../../../src/crypto/store/memory-crypto-store';
|
||||||
import 'fake-indexeddb/auto';
|
import 'fake-indexeddb/auto';
|
||||||
import 'jest-localstorage-mock';
|
import 'jest-localstorage-mock';
|
||||||
|
|
||||||
|
@@ -16,13 +16,13 @@ limitations under the License.
|
|||||||
|
|
||||||
import '../../olm-loader';
|
import '../../olm-loader';
|
||||||
import * as olmlib from "../../../src/crypto/olmlib";
|
import * as olmlib from "../../../src/crypto/olmlib";
|
||||||
import {SECRET_STORAGE_ALGORITHM_V1_AES} from "../../../src/crypto/SecretStorage";
|
import { SECRET_STORAGE_ALGORITHM_V1_AES } from "../../../src/crypto/SecretStorage";
|
||||||
import {MatrixEvent} from "../../../src/models/event";
|
import { MatrixEvent } from "../../../src/models/event";
|
||||||
import {TestClient} from '../../TestClient';
|
import { TestClient } from '../../TestClient';
|
||||||
import {makeTestClients} from './verification/util';
|
import { makeTestClients } from './verification/util';
|
||||||
import {encryptAES} from "../../../src/crypto/aes";
|
import { encryptAES } from "../../../src/crypto/aes";
|
||||||
import {resetCrossSigningKeys, createSecretStorageKey} from "./crypto-utils";
|
import { resetCrossSigningKeys, createSecretStorageKey } from "./crypto-utils";
|
||||||
import {logger} from '../../../src/logger';
|
import { logger } from '../../../src/logger';
|
||||||
|
|
||||||
import * as utils from "../../../src/utils";
|
import * as utils from "../../../src/utils";
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ describe("Secrets", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{
|
{
|
||||||
cryptoCallbacks: {
|
cryptoCallbacks: {
|
||||||
getCrossSigningKey: t => signingKey,
|
getCrossSigningKey: t => signingKey,
|
||||||
@@ -141,7 +141,7 @@ describe("Secrets", function() {
|
|||||||
|
|
||||||
it("should throw if given a key that doesn't exist", async function() {
|
it("should throw if given a key that doesn't exist", async function() {
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -155,7 +155,7 @@ describe("Secrets", function() {
|
|||||||
|
|
||||||
it("should refuse to encrypt with zero keys", async function() {
|
it("should refuse to encrypt with zero keys", async function() {
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -175,7 +175,7 @@ describe("Secrets", function() {
|
|||||||
|
|
||||||
let keys = {};
|
let keys = {};
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{
|
{
|
||||||
cryptoCallbacks: {
|
cryptoCallbacks: {
|
||||||
getCrossSigningKey: t => keys[t],
|
getCrossSigningKey: t => keys[t],
|
||||||
@@ -208,7 +208,7 @@ describe("Secrets", function() {
|
|||||||
|
|
||||||
it("should refuse to encrypt if no keys given and no default key", async function() {
|
it("should refuse to encrypt if no keys given and no default key", async function() {
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -221,8 +221,8 @@ describe("Secrets", function() {
|
|||||||
it("should request secrets from other clients", async function() {
|
it("should request secrets from other clients", async function() {
|
||||||
const [osborne2, vax] = await makeTestClients(
|
const [osborne2, vax] = await makeTestClients(
|
||||||
[
|
[
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{userId: "@alice:example.com", deviceId: "VAX"},
|
{ userId: "@alice:example.com", deviceId: "VAX" },
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
cryptoCallbacks: {
|
cryptoCallbacks: {
|
||||||
@@ -419,12 +419,12 @@ describe("Secrets", function() {
|
|||||||
key_id: SSSSKey,
|
key_id: SSSSKey,
|
||||||
};
|
};
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{
|
{
|
||||||
cryptoCallbacks: {
|
cryptoCallbacks: {
|
||||||
getCrossSigningKey: t => crossSigningKeys[t],
|
getCrossSigningKey: t => crossSigningKeys[t],
|
||||||
saveCrossSigningKeys: k => crossSigningKeys = k,
|
saveCrossSigningKeys: k => crossSigningKeys = k,
|
||||||
getSecretStorageKey: ({keys}, name) => {
|
getSecretStorageKey: ({ keys }, name) => {
|
||||||
for (const keyId of Object.keys(keys)) {
|
for (const keyId of Object.keys(keys)) {
|
||||||
if (secretStorageKeys[keyId]) {
|
if (secretStorageKeys[keyId]) {
|
||||||
return [keyId, secretStorageKeys[keyId]];
|
return [keyId, secretStorageKeys[keyId]];
|
||||||
@@ -458,7 +458,7 @@ describe("Secrets", function() {
|
|||||||
type: "m.cross_signing.master",
|
type: "m.cross_signing.master",
|
||||||
content: {
|
content: {
|
||||||
encrypted: {
|
encrypted: {
|
||||||
key_id: {ciphertext: "bla", mac: "bla", iv: "bla"},
|
key_id: { ciphertext: "bla", mac: "bla", iv: "bla" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -466,7 +466,7 @@ describe("Secrets", function() {
|
|||||||
type: "m.cross_signing.self_signing",
|
type: "m.cross_signing.self_signing",
|
||||||
content: {
|
content: {
|
||||||
encrypted: {
|
encrypted: {
|
||||||
key_id: {ciphertext: "bla", mac: "bla", iv: "bla"},
|
key_id: { ciphertext: "bla", mac: "bla", iv: "bla" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -474,7 +474,7 @@ describe("Secrets", function() {
|
|||||||
type: "m.cross_signing.user_signing",
|
type: "m.cross_signing.user_signing",
|
||||||
content: {
|
content: {
|
||||||
encrypted: {
|
encrypted: {
|
||||||
key_id: {ciphertext: "bla", mac: "bla", iv: "bla"},
|
key_id: { ciphertext: "bla", mac: "bla", iv: "bla" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -525,7 +525,7 @@ describe("Secrets", function() {
|
|||||||
await alice.bootstrapSecretStorage();
|
await alice.bootstrapSecretStorage();
|
||||||
|
|
||||||
expect(alice.getAccountData("m.secret_storage.default_key").getContent())
|
expect(alice.getAccountData("m.secret_storage.default_key").getContent())
|
||||||
.toEqual({key: "key_id"});
|
.toEqual({ key: "key_id" });
|
||||||
const keyInfo = alice.getAccountData("m.secret_storage.key.key_id")
|
const keyInfo = alice.getAccountData("m.secret_storage.key.key_id")
|
||||||
.getContent();
|
.getContent();
|
||||||
expect(keyInfo.algorithm)
|
expect(keyInfo.algorithm)
|
||||||
@@ -550,12 +550,12 @@ describe("Secrets", function() {
|
|||||||
key_id: SSSSKey,
|
key_id: SSSSKey,
|
||||||
};
|
};
|
||||||
const alice = await makeTestClient(
|
const alice = await makeTestClient(
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{
|
{
|
||||||
cryptoCallbacks: {
|
cryptoCallbacks: {
|
||||||
getCrossSigningKey: t => crossSigningKeys[t],
|
getCrossSigningKey: t => crossSigningKeys[t],
|
||||||
saveCrossSigningKeys: k => crossSigningKeys = k,
|
saveCrossSigningKeys: k => crossSigningKeys = k,
|
||||||
getSecretStorageKey: ({keys}, name) => {
|
getSecretStorageKey: ({ keys }, name) => {
|
||||||
for (const keyId of Object.keys(keys)) {
|
for (const keyId of Object.keys(keys)) {
|
||||||
if (secretStorageKeys[keyId]) {
|
if (secretStorageKeys[keyId]) {
|
||||||
return [keyId, secretStorageKeys[keyId]];
|
return [keyId, secretStorageKeys[keyId]];
|
||||||
@@ -587,7 +587,7 @@ describe("Secrets", function() {
|
|||||||
type: "m.cross_signing.master",
|
type: "m.cross_signing.master",
|
||||||
content: {
|
content: {
|
||||||
encrypted: {
|
encrypted: {
|
||||||
key_id: {ciphertext: "bla", mac: "bla", iv: "bla"},
|
key_id: { ciphertext: "bla", mac: "bla", iv: "bla" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -595,7 +595,7 @@ describe("Secrets", function() {
|
|||||||
type: "m.cross_signing.self_signing",
|
type: "m.cross_signing.self_signing",
|
||||||
content: {
|
content: {
|
||||||
encrypted: {
|
encrypted: {
|
||||||
key_id: {ciphertext: "bla", mac: "bla", iv: "bla"},
|
key_id: { ciphertext: "bla", mac: "bla", iv: "bla" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -603,7 +603,7 @@ describe("Secrets", function() {
|
|||||||
type: "m.cross_signing.user_signing",
|
type: "m.cross_signing.user_signing",
|
||||||
content: {
|
content: {
|
||||||
encrypted: {
|
encrypted: {
|
||||||
key_id: {ciphertext: "bla", mac: "bla", iv: "bla"},
|
key_id: { ciphertext: "bla", mac: "bla", iv: "bla" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
@@ -13,9 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import {InRoomChannel} from "../../../../src/crypto/verification/request/InRoomChannel";
|
import { InRoomChannel } from "../../../../src/crypto/verification/request/InRoomChannel";
|
||||||
"../../../../src/crypto/verification/request/ToDeviceChannel";
|
"../../../../src/crypto/verification/request/ToDeviceChannel";
|
||||||
import {MatrixEvent} from "../../../../src/models/event";
|
import { MatrixEvent } from "../../../../src/models/event";
|
||||||
|
|
||||||
describe("InRoomChannel tests", function() {
|
describe("InRoomChannel tests", function() {
|
||||||
const ALICE = "@alice:hs.tld";
|
const ALICE = "@alice:hs.tld";
|
||||||
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import "../../../olm-loader";
|
import "../../../olm-loader";
|
||||||
import {logger} from "../../../../src/logger";
|
import { logger } from "../../../../src/logger";
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
|
@@ -15,10 +15,10 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import "../../../olm-loader";
|
import "../../../olm-loader";
|
||||||
import {verificationMethods} from "../../../../src/crypto";
|
import { verificationMethods } from "../../../../src/crypto";
|
||||||
import {logger} from "../../../../src/logger";
|
import { logger } from "../../../../src/logger";
|
||||||
import {SAS} from "../../../../src/crypto/verification/SAS";
|
import { SAS } from "../../../../src/crypto/verification/SAS";
|
||||||
import {makeTestClients, setupWebcrypto, teardownWebcrypto} from './util';
|
import { makeTestClients, setupWebcrypto, teardownWebcrypto } from './util';
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@ describe("verification request integration tests with crypto layer", function()
|
|||||||
it("should request and accept a verification", async function() {
|
it("should request and accept a verification", async function() {
|
||||||
const [alice, bob] = await makeTestClients(
|
const [alice, bob] = await makeTestClients(
|
||||||
[
|
[
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{userId: "@bob:example.com", deviceId: "Dynabook"},
|
{ userId: "@bob:example.com", deviceId: "Dynabook" },
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
verificationMethods: [verificationMethods.SAS],
|
verificationMethods: [verificationMethods.SAS],
|
||||||
|
@@ -15,14 +15,14 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import "../../../olm-loader";
|
import "../../../olm-loader";
|
||||||
import {makeTestClients, setupWebcrypto, teardownWebcrypto} from './util';
|
import { makeTestClients, setupWebcrypto, teardownWebcrypto } from './util';
|
||||||
import {MatrixEvent} from "../../../../src/models/event";
|
import { MatrixEvent } from "../../../../src/models/event";
|
||||||
import {SAS} from "../../../../src/crypto/verification/SAS";
|
import { SAS } from "../../../../src/crypto/verification/SAS";
|
||||||
import {DeviceInfo} from "../../../../src/crypto/deviceinfo";
|
import { DeviceInfo } from "../../../../src/crypto/deviceinfo";
|
||||||
import {verificationMethods} from "../../../../src/crypto";
|
import { verificationMethods } from "../../../../src/crypto";
|
||||||
import * as olmlib from "../../../../src/crypto/olmlib";
|
import * as olmlib from "../../../../src/crypto/olmlib";
|
||||||
import {logger} from "../../../../src/logger";
|
import { logger } from "../../../../src/logger";
|
||||||
import {resetCrossSigningKeys} from "../crypto-utils";
|
import { resetCrossSigningKeys } from "../crypto-utils";
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
@@ -79,8 +79,8 @@ describe("SAS verification", function() {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
[alice, bob] = await makeTestClients(
|
[alice, bob] = await makeTestClients(
|
||||||
[
|
[
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{userId: "@bob:example.com", deviceId: "Dynabook"},
|
{ userId: "@bob:example.com", deviceId: "Dynabook" },
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
verificationMethods: [verificationMethods.SAS],
|
verificationMethods: [verificationMethods.SAS],
|
||||||
@@ -336,8 +336,8 @@ describe("SAS verification", function() {
|
|||||||
it("should send a cancellation message on error", async function() {
|
it("should send a cancellation message on error", async function() {
|
||||||
const [alice, bob] = await makeTestClients(
|
const [alice, bob] = await makeTestClients(
|
||||||
[
|
[
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{userId: "@bob:example.com", deviceId: "Dynabook"},
|
{ userId: "@bob:example.com", deviceId: "Dynabook" },
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
verificationMethods: [verificationMethods.SAS],
|
verificationMethods: [verificationMethods.SAS],
|
||||||
@@ -390,8 +390,8 @@ describe("SAS verification", function() {
|
|||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
[alice, bob] = await makeTestClients(
|
[alice, bob] = await makeTestClients(
|
||||||
[
|
[
|
||||||
{userId: "@alice:example.com", deviceId: "Osborne2"},
|
{ userId: "@alice:example.com", deviceId: "Osborne2" },
|
||||||
{userId: "@bob:example.com", deviceId: "Dynabook"},
|
{ userId: "@bob:example.com", deviceId: "Dynabook" },
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
verificationMethods: [verificationMethods.SAS],
|
verificationMethods: [verificationMethods.SAS],
|
||||||
|
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {VerificationBase} from '../../../../src/crypto/verification/Base';
|
import { VerificationBase } from '../../../../src/crypto/verification/Base';
|
||||||
import {CrossSigningInfo} from '../../../../src/crypto/CrossSigning';
|
import { CrossSigningInfo } from '../../../../src/crypto/CrossSigning';
|
||||||
import {encodeBase64} from "../../../../src/crypto/olmlib";
|
import { encodeBase64 } from "../../../../src/crypto/olmlib";
|
||||||
import {setupWebcrypto, teardownWebcrypto} from './util';
|
import { setupWebcrypto, teardownWebcrypto } from './util';
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
|
@@ -15,10 +15,10 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {TestClient} from '../../../TestClient';
|
import { TestClient } from '../../../TestClient';
|
||||||
import {MatrixEvent} from "../../../../src/models/event";
|
import { MatrixEvent } from "../../../../src/models/event";
|
||||||
import nodeCrypto from "crypto";
|
import nodeCrypto from "crypto";
|
||||||
import {logger} from '../../../../src/logger';
|
import { logger } from '../../../../src/logger';
|
||||||
|
|
||||||
export async function makeTestClients(userInfos, options) {
|
export async function makeTestClients(userInfos, options) {
|
||||||
const clients = [];
|
const clients = [];
|
||||||
@@ -76,7 +76,7 @@ export async function makeTestClients(userInfos, options) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.resolve({event_id: eventId});
|
return Promise.resolve({ event_id: eventId });
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const userInfo of userInfos) {
|
for (const userInfo of userInfos) {
|
||||||
|
@@ -13,13 +13,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import {VerificationRequest, READY_TYPE, START_TYPE, DONE_TYPE} from
|
import { VerificationRequest, READY_TYPE, START_TYPE, DONE_TYPE } from
|
||||||
"../../../../src/crypto/verification/request/VerificationRequest";
|
"../../../../src/crypto/verification/request/VerificationRequest";
|
||||||
import {InRoomChannel} from "../../../../src/crypto/verification/request/InRoomChannel";
|
import { InRoomChannel } from "../../../../src/crypto/verification/request/InRoomChannel";
|
||||||
import {ToDeviceChannel} from
|
import { ToDeviceChannel } from
|
||||||
"../../../../src/crypto/verification/request/ToDeviceChannel";
|
"../../../../src/crypto/verification/request/ToDeviceChannel";
|
||||||
import {MatrixEvent} from "../../../../src/models/event";
|
import { MatrixEvent } from "../../../../src/models/event";
|
||||||
import {setupWebcrypto, teardownWebcrypto} from "./util";
|
import { setupWebcrypto, teardownWebcrypto } from "./util";
|
||||||
|
|
||||||
function makeMockClient(userId, deviceId) {
|
function makeMockClient(userId, deviceId) {
|
||||||
let counter = 1;
|
let counter = 1;
|
||||||
@@ -40,7 +40,7 @@ function makeMockClient(userId, deviceId) {
|
|||||||
content,
|
content,
|
||||||
origin_server_ts: Date.now(),
|
origin_server_ts: Date.now(),
|
||||||
}));
|
}));
|
||||||
return Promise.resolve({event_id: eventId});
|
return Promise.resolve({ event_id: eventId });
|
||||||
},
|
},
|
||||||
|
|
||||||
sendToDevice(type, msgMap) {
|
sendToDevice(type, msgMap) {
|
||||||
@@ -48,7 +48,7 @@ function makeMockClient(userId, deviceId) {
|
|||||||
const deviceMap = msgMap[userId];
|
const deviceMap = msgMap[userId];
|
||||||
for (const deviceId of Object.keys(deviceMap)) {
|
for (const deviceId of Object.keys(deviceMap)) {
|
||||||
const content = deviceMap[deviceId];
|
const content = deviceMap[deviceId];
|
||||||
const event = new MatrixEvent({content, type});
|
const event = new MatrixEvent({ content, type });
|
||||||
deviceEvents[userId] = deviceEvents[userId] || {};
|
deviceEvents[userId] = deviceEvents[userId] || {};
|
||||||
deviceEvents[userId][deviceId] = deviceEvents[userId][deviceId] || [];
|
deviceEvents[userId][deviceId] = deviceEvents[userId][deviceId] || [];
|
||||||
deviceEvents[userId][deviceId].push(event);
|
deviceEvents[userId][deviceId].push(event);
|
||||||
@@ -90,7 +90,7 @@ class MockVerifier {
|
|||||||
if (this._startEvent) {
|
if (this._startEvent) {
|
||||||
await this._channel.send(DONE_TYPE, {});
|
await this._channel.send(DONE_TYPE, {});
|
||||||
} else {
|
} else {
|
||||||
await this._channel.send(START_TYPE, {method: MOCK_METHOD});
|
await this._channel.send(START_TYPE, { method: MOCK_METHOD });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ describe("verification request unit tests", function() {
|
|||||||
new ToDeviceChannel(bob1, bob1.getUserId(), ["device1", "device2"],
|
new ToDeviceChannel(bob1, bob1.getUserId(), ["device1", "device2"],
|
||||||
ToDeviceChannel.makeTransactionId(), "device2"),
|
ToDeviceChannel.makeTransactionId(), "device2"),
|
||||||
new Map([[MOCK_METHOD, MockVerifier]]), bob1);
|
new Map([[MOCK_METHOD, MockVerifier]]), bob1);
|
||||||
const to = {userId: "@bob:matrix.tld", deviceId: "device2"};
|
const to = { userId: "@bob:matrix.tld", deviceId: "device2" };
|
||||||
const verifier = bob1Request.beginKeyVerification(MOCK_METHOD, to);
|
const verifier = bob1Request.beginKeyVerification(MOCK_METHOD, to);
|
||||||
expect(verifier).toBeInstanceOf(MockVerifier);
|
expect(verifier).toBeInstanceOf(MockVerifier);
|
||||||
await verifier.start();
|
await verifier.start();
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {EventTimeline} from "../../src/models/event-timeline";
|
import { EventTimeline } from "../../src/models/event-timeline";
|
||||||
import {RoomState} from "../../src/models/room-state";
|
import { RoomState } from "../../src/models/room-state";
|
||||||
|
|
||||||
function mockRoomStates(timeline) {
|
function mockRoomStates(timeline) {
|
||||||
timeline._startState = utils.mock(RoomState, "startState");
|
timeline._startState = utils.mock(RoomState, "startState");
|
||||||
@@ -15,7 +15,7 @@ describe("EventTimeline", function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
// XXX: this is a horrid hack; should use sinon or something instead to mock
|
// XXX: this is a horrid hack; should use sinon or something instead to mock
|
||||||
const timelineSet = { room: { roomId: roomId }};
|
const timelineSet = { room: { roomId: roomId } };
|
||||||
timelineSet.room.getUnfilteredTimelineSet = function() {
|
timelineSet.room.getUnfilteredTimelineSet = function() {
|
||||||
return timelineSet;
|
return timelineSet;
|
||||||
};
|
};
|
||||||
@@ -94,7 +94,6 @@ describe("EventTimeline", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("neighbouringTimelines", function() {
|
describe("neighbouringTimelines", function() {
|
||||||
it("neighbouring timelines should start null", function() {
|
it("neighbouring timelines should start null", function() {
|
||||||
expect(timeline.getNeighbouringTimeline(EventTimeline.BACKWARDS)).toBe(null);
|
expect(timeline.getNeighbouringTimeline(EventTimeline.BACKWARDS)).toBe(null);
|
||||||
@@ -102,8 +101,8 @@ describe("EventTimeline", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("setNeighbouringTimeline should set neighbour", function() {
|
it("setNeighbouringTimeline should set neighbour", function() {
|
||||||
const prev = {a: "a"};
|
const prev = { a: "a" };
|
||||||
const next = {b: "b"};
|
const next = { b: "b" };
|
||||||
timeline.setNeighbouringTimeline(prev, EventTimeline.BACKWARDS);
|
timeline.setNeighbouringTimeline(prev, EventTimeline.BACKWARDS);
|
||||||
timeline.setNeighbouringTimeline(next, EventTimeline.FORWARDS);
|
timeline.setNeighbouringTimeline(next, EventTimeline.FORWARDS);
|
||||||
expect(timeline.getNeighbouringTimeline(EventTimeline.BACKWARDS)).toBe(prev);
|
expect(timeline.getNeighbouringTimeline(EventTimeline.BACKWARDS)).toBe(prev);
|
||||||
@@ -111,8 +110,8 @@ describe("EventTimeline", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("setNeighbouringTimeline should throw if called twice", function() {
|
it("setNeighbouringTimeline should throw if called twice", function() {
|
||||||
const prev = {a: "a"};
|
const prev = { a: "a" };
|
||||||
const next = {b: "b"};
|
const next = { b: "b" };
|
||||||
expect(function() {
|
expect(function() {
|
||||||
timeline.setNeighbouringTimeline(prev, EventTimeline.BACKWARDS);
|
timeline.setNeighbouringTimeline(prev, EventTimeline.BACKWARDS);
|
||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
@@ -278,7 +277,6 @@ describe("EventTimeline", function() {
|
|||||||
not.toHaveBeenCalled();
|
not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("should call setStateEvents on the right RoomState with the right " +
|
it("should call setStateEvents on the right RoomState with the right " +
|
||||||
"forwardLooking value for old events", function() {
|
"forwardLooking value for old events", function() {
|
||||||
const events = [
|
const events = [
|
||||||
|
@@ -15,8 +15,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from "../../src/logger";
|
import { logger } from "../../src/logger";
|
||||||
import {MatrixEvent} from "../../src/models/event";
|
import { MatrixEvent } from "../../src/models/event";
|
||||||
|
|
||||||
describe("MatrixEvent", () => {
|
describe("MatrixEvent", () => {
|
||||||
describe(".attemptDecryption", () => {
|
describe(".attemptDecryption", () => {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import {FilterComponent} from "../../src/filter-component";
|
import { FilterComponent } from "../../src/filter-component";
|
||||||
import {mkEvent} from '../test-utils';
|
import { mkEvent } from '../test-utils';
|
||||||
|
|
||||||
describe("Filter Component", function() {
|
describe("Filter Component", function() {
|
||||||
describe("types", function() {
|
describe("types", function() {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import {Filter} from "../../src/filter";
|
import { Filter } from "../../src/filter";
|
||||||
|
|
||||||
describe("Filter", function() {
|
describe("Filter", function() {
|
||||||
const filterId = "f1lt3ring15g00d4ursoul";
|
const filterId = "f1lt3ring15g00d4ursoul";
|
||||||
|
@@ -15,9 +15,9 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from "../../src/logger";
|
import { logger } from "../../src/logger";
|
||||||
import {InteractiveAuth} from "../../src/interactive-auth";
|
import { InteractiveAuth } from "../../src/interactive-auth";
|
||||||
import {MatrixError} from "../../src/http-api";
|
import { MatrixError } from "../../src/http-api";
|
||||||
|
|
||||||
// Trivial client object to test interactive auth
|
// Trivial client object to test interactive auth
|
||||||
// (we do not need TestClient here)
|
// (we do not need TestClient here)
|
||||||
@@ -63,7 +63,7 @@ describe("InteractiveAuth", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// .. which should trigger a call here
|
// .. which should trigger a call here
|
||||||
const requestRes = {"a": "b"};
|
const requestRes = { "a": "b" };
|
||||||
doRequest.mockImplementation(function(authData) {
|
doRequest.mockImplementation(function(authData) {
|
||||||
logger.log('cccc');
|
logger.log('cccc');
|
||||||
expect(authData).toEqual({
|
expect(authData).toEqual({
|
||||||
@@ -112,7 +112,7 @@ describe("InteractiveAuth", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// .. which should be followed by a call to stateUpdated
|
// .. which should be followed by a call to stateUpdated
|
||||||
const requestRes = {"a": "b"};
|
const requestRes = { "a": "b" };
|
||||||
stateUpdated.mockImplementation(function(stage) {
|
stateUpdated.mockImplementation(function(stage) {
|
||||||
expect(stage).toEqual("logintype");
|
expect(stage).toEqual("logintype");
|
||||||
expect(ia.getSessionId()).toEqual("sessionId");
|
expect(ia.getSessionId()).toEqual("sessionId");
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import {TestClient} from '../TestClient';
|
import { TestClient } from '../TestClient';
|
||||||
|
|
||||||
describe('Login request', function() {
|
describe('Login request', function() {
|
||||||
let client;
|
let client;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import {logger} from "../../src/logger";
|
import { logger } from "../../src/logger";
|
||||||
import {MatrixClient} from "../../src/client";
|
import { MatrixClient } from "../../src/client";
|
||||||
import {Filter} from "../../src/filter";
|
import { Filter } from "../../src/filter";
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ describe("MatrixClient", function() {
|
|||||||
const filterId = "ehfewf";
|
const filterId = "ehfewf";
|
||||||
store.getFilterIdByName.mockReturnValue(filterId);
|
store.getFilterIdByName.mockReturnValue(filterId);
|
||||||
const filter = new Filter(0, filterId);
|
const filter = new Filter(0, filterId);
|
||||||
filter.setDefinition({"room": {"timeline": {"limit": 8}}});
|
filter.setDefinition({ "room": { "timeline": { "limit": 8 } } });
|
||||||
store.getFilter.mockReturnValue(filter);
|
store.getFilter.mockReturnValue(filter);
|
||||||
const syncPromise = new Promise((resolve, reject) => {
|
const syncPromise = new Promise((resolve, reject) => {
|
||||||
client.on("sync", function syncListener(state) {
|
client.on("sync", function syncListener(state) {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {PushProcessor} from "../../src/pushprocessor";
|
import { PushProcessor } from "../../src/pushprocessor";
|
||||||
|
|
||||||
describe('NotificationService', function() {
|
describe('NotificationService', function() {
|
||||||
const testUserId = "@ali:matrix.org";
|
const testUserId = "@ali:matrix.org";
|
||||||
|
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { EventTimelineSet } from "../../src/models/event-timeline-set";
|
||||||
import { MatrixEvent } from "../../src/models/event";
|
import { MatrixEvent } from "../../src/models/event";
|
||||||
import { Relations } from "../../src/models/relations";
|
import { Relations } from "../../src/models/relations";
|
||||||
|
|
||||||
@@ -70,4 +71,63 @@ describe("Relations", function() {
|
|||||||
expect(events.size).toEqual(1);
|
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;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {RoomMember} from "../../src/models/room-member";
|
import { RoomMember } from "../../src/models/room-member";
|
||||||
|
|
||||||
describe("RoomMember", function() {
|
describe("RoomMember", function() {
|
||||||
const roomId = "!foo:bar";
|
const roomId = "!foo:bar";
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {RoomState} from "../../src/models/room-state";
|
import { RoomState } from "../../src/models/room-state";
|
||||||
import {RoomMember} from "../../src/models/room-member";
|
import { RoomMember } from "../../src/models/room-member";
|
||||||
|
|
||||||
describe("RoomState", function() {
|
describe("RoomState", function() {
|
||||||
const roomId = "!foo:bar";
|
const roomId = "!foo:bar";
|
||||||
@@ -471,13 +471,13 @@ describe("RoomState", function() {
|
|||||||
|
|
||||||
it("should update after adding joined member", function() {
|
it("should update after adding joined member", function() {
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "join",
|
utils.mkMembership({ event: true, mship: "join",
|
||||||
user: userA, room: roomId}),
|
user: userA, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getJoinedMemberCount()).toEqual(1);
|
expect(state.getJoinedMemberCount()).toEqual(1);
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "join",
|
utils.mkMembership({ event: true, mship: "join",
|
||||||
user: userC, room: roomId}),
|
user: userC, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getJoinedMemberCount()).toEqual(2);
|
expect(state.getJoinedMemberCount()).toEqual(2);
|
||||||
});
|
});
|
||||||
@@ -490,13 +490,13 @@ describe("RoomState", function() {
|
|||||||
|
|
||||||
it("should update after adding invited member", function() {
|
it("should update after adding invited member", function() {
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "invite",
|
utils.mkMembership({ event: true, mship: "invite",
|
||||||
user: userA, room: roomId}),
|
user: userA, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getInvitedMemberCount()).toEqual(1);
|
expect(state.getInvitedMemberCount()).toEqual(1);
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "invite",
|
utils.mkMembership({ event: true, mship: "invite",
|
||||||
user: userC, room: roomId}),
|
user: userC, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getInvitedMemberCount()).toEqual(2);
|
expect(state.getInvitedMemberCount()).toEqual(2);
|
||||||
});
|
});
|
||||||
@@ -509,15 +509,15 @@ describe("RoomState", function() {
|
|||||||
|
|
||||||
it("should, once used, override counting members from state", function() {
|
it("should, once used, override counting members from state", function() {
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "join",
|
utils.mkMembership({ event: true, mship: "join",
|
||||||
user: userA, room: roomId}),
|
user: userA, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getJoinedMemberCount()).toEqual(1);
|
expect(state.getJoinedMemberCount()).toEqual(1);
|
||||||
state.setJoinedMemberCount(100);
|
state.setJoinedMemberCount(100);
|
||||||
expect(state.getJoinedMemberCount()).toEqual(100);
|
expect(state.getJoinedMemberCount()).toEqual(100);
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "join",
|
utils.mkMembership({ event: true, mship: "join",
|
||||||
user: userC, room: roomId}),
|
user: userC, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getJoinedMemberCount()).toEqual(100);
|
expect(state.getJoinedMemberCount()).toEqual(100);
|
||||||
});
|
});
|
||||||
@@ -525,14 +525,14 @@ describe("RoomState", function() {
|
|||||||
it("should, once used, override counting members from state, " +
|
it("should, once used, override counting members from state, " +
|
||||||
"also after clone", function() {
|
"also after clone", function() {
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "join",
|
utils.mkMembership({ event: true, mship: "join",
|
||||||
user: userA, room: roomId}),
|
user: userA, room: roomId }),
|
||||||
]);
|
]);
|
||||||
state.setJoinedMemberCount(100);
|
state.setJoinedMemberCount(100);
|
||||||
const copy = state.clone();
|
const copy = state.clone();
|
||||||
copy.setStateEvents([
|
copy.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "join",
|
utils.mkMembership({ event: true, mship: "join",
|
||||||
user: userC, room: roomId}),
|
user: userC, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getJoinedMemberCount()).toEqual(100);
|
expect(state.getJoinedMemberCount()).toEqual(100);
|
||||||
});
|
});
|
||||||
@@ -545,15 +545,15 @@ describe("RoomState", function() {
|
|||||||
|
|
||||||
it("should, once used, override counting members from state", function() {
|
it("should, once used, override counting members from state", function() {
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "invite",
|
utils.mkMembership({ event: true, mship: "invite",
|
||||||
user: userB, room: roomId}),
|
user: userB, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getInvitedMemberCount()).toEqual(1);
|
expect(state.getInvitedMemberCount()).toEqual(1);
|
||||||
state.setInvitedMemberCount(100);
|
state.setInvitedMemberCount(100);
|
||||||
expect(state.getInvitedMemberCount()).toEqual(100);
|
expect(state.getInvitedMemberCount()).toEqual(100);
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "invite",
|
utils.mkMembership({ event: true, mship: "invite",
|
||||||
user: userC, room: roomId}),
|
user: userC, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getInvitedMemberCount()).toEqual(100);
|
expect(state.getInvitedMemberCount()).toEqual(100);
|
||||||
});
|
});
|
||||||
@@ -561,14 +561,14 @@ describe("RoomState", function() {
|
|||||||
it("should, once used, override counting members from state, " +
|
it("should, once used, override counting members from state, " +
|
||||||
"also after clone", function() {
|
"also after clone", function() {
|
||||||
state.setStateEvents([
|
state.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "invite",
|
utils.mkMembership({ event: true, mship: "invite",
|
||||||
user: userB, room: roomId}),
|
user: userB, room: roomId }),
|
||||||
]);
|
]);
|
||||||
state.setInvitedMemberCount(100);
|
state.setInvitedMemberCount(100);
|
||||||
const copy = state.clone();
|
const copy = state.clone();
|
||||||
copy.setStateEvents([
|
copy.setStateEvents([
|
||||||
utils.mkMembership({event: true, mship: "invite",
|
utils.mkMembership({ event: true, mship: "invite",
|
||||||
user: userC, room: roomId}),
|
user: userC, room: roomId }),
|
||||||
]);
|
]);
|
||||||
expect(state.getInvitedMemberCount()).toEqual(100);
|
expect(state.getInvitedMemberCount()).toEqual(100);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
import {EventStatus, MatrixEvent} from "../../src/models/event";
|
import { EventStatus, MatrixEvent } from "../../src/models/event";
|
||||||
import {EventTimeline} from "../../src/models/event-timeline";
|
import { EventTimeline } from "../../src/models/event-timeline";
|
||||||
import {RoomState} from "../../src/models/room-state";
|
import { RoomState } from "../../src/models/room-state";
|
||||||
import {Room} from "../../src/models/room";
|
import { Room } from "../../src/models/room";
|
||||||
import {TestClient} from "../TestClient";
|
import { TestClient } from "../TestClient";
|
||||||
|
|
||||||
describe("Room", function() {
|
describe("Room", function() {
|
||||||
const roomId = "!foo:bar";
|
const roomId = "!foo:bar";
|
||||||
@@ -191,7 +191,7 @@ describe("Room", function() {
|
|||||||
const remoteEvent = utils.mkMessage({
|
const remoteEvent = utils.mkMessage({
|
||||||
room: roomId, user: userA, event: true,
|
room: roomId, user: userA, event: true,
|
||||||
});
|
});
|
||||||
remoteEvent.event.unsigned = {transaction_id: "TXN_ID"};
|
remoteEvent.event.unsigned = { transaction_id: "TXN_ID" };
|
||||||
const remoteEventId = remoteEvent.getId();
|
const remoteEventId = remoteEvent.getId();
|
||||||
|
|
||||||
let callCount = 0;
|
let callCount = 0;
|
||||||
@@ -375,7 +375,7 @@ describe("Room", function() {
|
|||||||
let events = null;
|
let events = null;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
room = new Room(roomId, null, null, {timelineSupport: timelineSupport});
|
room = new Room(roomId, null, null, { timelineSupport: timelineSupport });
|
||||||
// set events each time to avoid resusing Event objects (which
|
// set events each time to avoid resusing Event objects (which
|
||||||
// doesn't work because they get frozen)
|
// doesn't work because they get frozen)
|
||||||
events = [
|
events = [
|
||||||
@@ -457,7 +457,7 @@ describe("Room", function() {
|
|||||||
|
|
||||||
describe("compareEventOrdering", function() {
|
describe("compareEventOrdering", function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
room = new Room(roomId, null, null, {timelineSupport: true});
|
room = new Room(roomId, null, null, { timelineSupport: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
const events = [
|
const events = [
|
||||||
@@ -713,7 +713,7 @@ describe("Room", function() {
|
|||||||
it("uses hero name from state", function() {
|
it("uses hero name from state", function() {
|
||||||
const name = "Mr B";
|
const name = "Mr B";
|
||||||
addMember(userA, "invite");
|
addMember(userA, "invite");
|
||||||
addMember(userB, "join", {name});
|
addMember(userB, "join", { name });
|
||||||
room.setSummary({
|
room.setSummary({
|
||||||
"m.heroes": [userB],
|
"m.heroes": [userB],
|
||||||
});
|
});
|
||||||
@@ -724,7 +724,7 @@ describe("Room", function() {
|
|||||||
|
|
||||||
it("uses counts from summary", function() {
|
it("uses counts from summary", function() {
|
||||||
const name = "Mr B";
|
const name = "Mr B";
|
||||||
addMember(userB, "join", {name});
|
addMember(userB, "join", { name });
|
||||||
room.setSummary({
|
room.setSummary({
|
||||||
"m.heroes": [userB],
|
"m.heroes": [userB],
|
||||||
"m.joined_member_count": 50,
|
"m.joined_member_count": 50,
|
||||||
@@ -737,8 +737,8 @@ describe("Room", function() {
|
|||||||
it("relies on heroes in case of absent counts", function() {
|
it("relies on heroes in case of absent counts", function() {
|
||||||
const nameB = "Mr Bean";
|
const nameB = "Mr Bean";
|
||||||
const nameC = "Mel C";
|
const nameC = "Mel C";
|
||||||
addMember(userB, "join", {name: nameB});
|
addMember(userB, "join", { name: nameB });
|
||||||
addMember(userC, "join", {name: nameC});
|
addMember(userC, "join", { name: nameC });
|
||||||
room.setSummary({
|
room.setSummary({
|
||||||
"m.heroes": [userB, userC],
|
"m.heroes": [userB, userC],
|
||||||
});
|
});
|
||||||
@@ -748,7 +748,7 @@ describe("Room", function() {
|
|||||||
|
|
||||||
it("uses only heroes", function() {
|
it("uses only heroes", function() {
|
||||||
const nameB = "Mr Bean";
|
const nameB = "Mr Bean";
|
||||||
addMember(userB, "join", {name: nameB});
|
addMember(userB, "join", { name: nameB });
|
||||||
addMember(userC, "join");
|
addMember(userC, "join");
|
||||||
room.setSummary({
|
room.setSummary({
|
||||||
"m.heroes": [userB],
|
"m.heroes": [userB],
|
||||||
@@ -841,7 +841,7 @@ describe("Room", function() {
|
|||||||
it("should show the other user's name for private" +
|
it("should show the other user's name for private" +
|
||||||
" (invite join_rules) rooms if you are invited to it.", function() {
|
" (invite join_rules) rooms if you are invited to it.", function() {
|
||||||
setJoinRule("invite");
|
setJoinRule("invite");
|
||||||
addMember(userA, "invite", {user: userB});
|
addMember(userA, "invite", { user: userB });
|
||||||
addMember(userB);
|
addMember(userB);
|
||||||
room.recalculate();
|
room.recalculate();
|
||||||
const name = room.name;
|
const name = room.name;
|
||||||
@@ -916,8 +916,8 @@ describe("Room", function() {
|
|||||||
"available",
|
"available",
|
||||||
function() {
|
function() {
|
||||||
setJoinRule("invite");
|
setJoinRule("invite");
|
||||||
addMember(userB, 'join', {name: "Alice"});
|
addMember(userB, 'join', { name: "Alice" });
|
||||||
addMember(userA, "invite", {user: userA});
|
addMember(userA, "invite", { user: userA });
|
||||||
room.recalculate();
|
room.recalculate();
|
||||||
const name = room.name;
|
const name = room.name;
|
||||||
expect(name).toEqual("Alice");
|
expect(name).toEqual("Alice");
|
||||||
@@ -927,7 +927,7 @@ describe("Room", function() {
|
|||||||
function() {
|
function() {
|
||||||
setJoinRule("invite");
|
setJoinRule("invite");
|
||||||
addMember(userB);
|
addMember(userB);
|
||||||
addMember(userA, "invite", {user: userA});
|
addMember(userA, "invite", { user: userA });
|
||||||
room.recalculate();
|
room.recalculate();
|
||||||
const name = room.name;
|
const name = room.name;
|
||||||
expect(name).toEqual(userB);
|
expect(name).toEqual(userB);
|
||||||
@@ -1267,7 +1267,6 @@ describe("Room", function() {
|
|||||||
expect(callCount).toEqual(1);
|
expect(callCount).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("should remove cancelled events from the timeline", function() {
|
it("should remove cancelled events from the timeline", function() {
|
||||||
const room = new Room(roomId, null, userA);
|
const room = new Room(roomId, null, userA);
|
||||||
const eventA = utils.mkMessage({
|
const eventA = utils.mkMessage({
|
||||||
@@ -1321,7 +1320,7 @@ describe("Room", function() {
|
|||||||
if (this.serverResponse instanceof Error) {
|
if (this.serverResponse instanceof Error) {
|
||||||
return Promise.reject(this.serverResponse);
|
return Promise.reject(this.serverResponse);
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve({chunk: this.serverResponse});
|
return Promise.resolve({ chunk: this.serverResponse });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1351,7 +1350,7 @@ describe("Room", function() {
|
|||||||
|
|
||||||
it("should load members from server on first call", async function() {
|
it("should load members from server on first call", async function() {
|
||||||
const client = createClientMock([memberEvent]);
|
const client = createClientMock([memberEvent]);
|
||||||
const room = new Room(roomId, client, null, {lazyLoadMembers: true});
|
const room = new Room(roomId, client, null, { lazyLoadMembers: true });
|
||||||
await room.loadMembersIfNeeded();
|
await room.loadMembersIfNeeded();
|
||||||
const memberA = room.getMember("@user_a:bar");
|
const memberA = room.getMember("@user_a:bar");
|
||||||
expect(memberA.name).toEqual("User A");
|
expect(memberA.name).toEqual("User A");
|
||||||
@@ -1366,7 +1365,7 @@ describe("Room", function() {
|
|||||||
room: roomId, event: true, name: "Ms A",
|
room: roomId, event: true, name: "Ms A",
|
||||||
});
|
});
|
||||||
const client = createClientMock([memberEvent2], [memberEvent]);
|
const client = createClientMock([memberEvent2], [memberEvent]);
|
||||||
const room = new Room(roomId, client, null, {lazyLoadMembers: true});
|
const room = new Room(roomId, client, null, { lazyLoadMembers: true });
|
||||||
|
|
||||||
await room.loadMembersIfNeeded();
|
await room.loadMembersIfNeeded();
|
||||||
|
|
||||||
@@ -1376,7 +1375,7 @@ describe("Room", function() {
|
|||||||
|
|
||||||
it("should allow retry on error", async function() {
|
it("should allow retry on error", async function() {
|
||||||
const client = createClientMock(new Error("server says no"));
|
const client = createClientMock(new Error("server says no"));
|
||||||
const room = new Room(roomId, client, null, {lazyLoadMembers: true});
|
const room = new Room(roomId, client, null, { lazyLoadMembers: true });
|
||||||
let hasThrown = false;
|
let hasThrown = false;
|
||||||
try {
|
try {
|
||||||
await room.loadMembersIfNeeded();
|
await room.loadMembersIfNeeded();
|
||||||
@@ -1404,17 +1403,17 @@ describe("Room", function() {
|
|||||||
const room = new Room(roomId, null, userA);
|
const room = new Room(roomId, null, userA);
|
||||||
const events = [];
|
const events = [];
|
||||||
room.on("Room.myMembership", (_room, membership, oldMembership) => {
|
room.on("Room.myMembership", (_room, membership, oldMembership) => {
|
||||||
events.push({membership, oldMembership});
|
events.push({ membership, oldMembership });
|
||||||
});
|
});
|
||||||
room.updateMyMembership("invite");
|
room.updateMyMembership("invite");
|
||||||
expect(room.getMyMembership()).toEqual("invite");
|
expect(room.getMyMembership()).toEqual("invite");
|
||||||
expect(events[0]).toEqual({membership: "invite", oldMembership: null});
|
expect(events[0]).toEqual({ membership: "invite", oldMembership: null });
|
||||||
events.splice(0); //clear
|
events.splice(0); //clear
|
||||||
room.updateMyMembership("invite");
|
room.updateMyMembership("invite");
|
||||||
expect(events.length).toEqual(0);
|
expect(events.length).toEqual(0);
|
||||||
room.updateMyMembership("join");
|
room.updateMyMembership("join");
|
||||||
expect(room.getMyMembership()).toEqual("join");
|
expect(room.getMyMembership()).toEqual("join");
|
||||||
expect(events[0]).toEqual({membership: "join", oldMembership: "invite"});
|
expect(events[0]).toEqual({ membership: "join", oldMembership: "invite" });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1422,7 +1421,7 @@ describe("Room", function() {
|
|||||||
it("should return first hero id",
|
it("should return first hero id",
|
||||||
function() {
|
function() {
|
||||||
const room = new Room(roomId, null, userA);
|
const room = new Room(roomId, null, userA);
|
||||||
room.setSummary({'m.heroes': [userB]});
|
room.setSummary({ 'm.heroes': [userB] });
|
||||||
expect(room.guessDMUserId()).toEqual(userB);
|
expect(room.guessDMUserId()).toEqual(userB);
|
||||||
});
|
});
|
||||||
it("should return first member that isn't self",
|
it("should return first member that isn't self",
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
// This file had a function whose name is all caps, which displeases eslint
|
// This file had a function whose name is all caps, which displeases eslint
|
||||||
/* eslint new-cap: "off" */
|
/* eslint new-cap: "off" */
|
||||||
|
|
||||||
import {defer} from '../../src/utils';
|
import { defer } from '../../src/utils';
|
||||||
import {MatrixError} from "../../src/http-api";
|
import { MatrixError } from "../../src/http-api";
|
||||||
import {MatrixScheduler} from "../../src/scheduler";
|
import { MatrixScheduler } from "../../src/scheduler";
|
||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
@@ -62,8 +62,8 @@ describe("MatrixScheduler", function() {
|
|||||||
scheduler.queueEvent(eventA),
|
scheduler.queueEvent(eventA),
|
||||||
scheduler.queueEvent(eventB),
|
scheduler.queueEvent(eventB),
|
||||||
]);
|
]);
|
||||||
deferB.resolve({b: true});
|
deferB.resolve({ b: true });
|
||||||
deferA.resolve({a: true});
|
deferA.resolve({ a: true });
|
||||||
const [a, b] = await abPromise;
|
const [a, b] = await abPromise;
|
||||||
expect(a.a).toEqual(true);
|
expect(a.a).toEqual(true);
|
||||||
expect(b.b).toEqual(true);
|
expect(b.b).toEqual(true);
|
||||||
@@ -156,8 +156,8 @@ describe("MatrixScheduler", function() {
|
|||||||
// Expect to have processFn invoked for A&B.
|
// Expect to have processFn invoked for A&B.
|
||||||
// Resolve A.
|
// Resolve A.
|
||||||
// Expect to have processFn invoked for D.
|
// Expect to have processFn invoked for D.
|
||||||
const eventC = utils.mkMessage({user: "@a:bar", room: roomId, event: true});
|
const eventC = utils.mkMessage({ user: "@a:bar", room: roomId, event: true });
|
||||||
const eventD = utils.mkMessage({user: "@b:bar", room: roomId, event: true});
|
const eventD = utils.mkMessage({ user: "@b:bar", room: roomId, event: true });
|
||||||
|
|
||||||
const buckets = {};
|
const buckets = {};
|
||||||
buckets[eventA.getId()] = "queue_A";
|
buckets[eventA.getId()] = "queue_A";
|
||||||
@@ -241,7 +241,7 @@ describe("MatrixScheduler", function() {
|
|||||||
expect(queue).toEqual([eventA, eventB]);
|
expect(queue).toEqual([eventA, eventB]);
|
||||||
// modify the queue
|
// modify the queue
|
||||||
const eventC = utils.mkMessage(
|
const eventC = utils.mkMessage(
|
||||||
{user: "@a:bar", room: roomId, event: true},
|
{ user: "@a:bar", room: roomId, event: true },
|
||||||
);
|
);
|
||||||
queue.push(eventC);
|
queue.push(eventC);
|
||||||
const queueAgain = scheduler.getQueueForEvent(eventA);
|
const queueAgain = scheduler.getQueueForEvent(eventA);
|
||||||
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {SyncAccumulator} from "../../src/sync-accumulator";
|
import { SyncAccumulator } from "../../src/sync-accumulator";
|
||||||
|
|
||||||
// The event body & unsigned object get frozen to assert that they don't get altered
|
// The event body & unsigned object get frozen to assert that they don't get altered
|
||||||
// by the impl
|
// by the impl
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import {EventTimeline} from "../../src/models/event-timeline";
|
import { EventTimeline } from "../../src/models/event-timeline";
|
||||||
import {TimelineIndex, TimelineWindow} from "../../src/timeline-window";
|
import { TimelineIndex, TimelineWindow } from "../../src/timeline-window";
|
||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
|
|
||||||
const ROOM_ID = "roomId";
|
const ROOM_ID = "roomId";
|
||||||
@@ -18,7 +18,7 @@ function createTimeline(numEvents, baseIndex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XXX: this is a horrid hack
|
// XXX: this is a horrid hack
|
||||||
const timelineSet = { room: { roomId: ROOM_ID }};
|
const timelineSet = { room: { roomId: ROOM_ID } };
|
||||||
timelineSet.room.getUnfilteredTimelineSet = function() {
|
timelineSet.room.getUnfilteredTimelineSet = function() {
|
||||||
return timelineSet;
|
return timelineSet;
|
||||||
};
|
};
|
||||||
@@ -46,7 +46,6 @@ function addEventsToTimeline(timeline, numEvents, atStart) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create a pair of linked timelines
|
* create a pair of linked timelines
|
||||||
*/
|
*/
|
||||||
@@ -58,7 +57,6 @@ function createLinkedTimelines() {
|
|||||||
return [tl1, tl2];
|
return [tl1, tl2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
describe("TimelineIndex", function() {
|
describe("TimelineIndex", function() {
|
||||||
describe("minIndex", function() {
|
describe("minIndex", function() {
|
||||||
it("should return the min index relative to BaseIndex", function() {
|
it("should return the min index relative to BaseIndex", function() {
|
||||||
@@ -133,7 +131,6 @@ describe("TimelineIndex", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("TimelineWindow", function() {
|
describe("TimelineWindow", function() {
|
||||||
/**
|
/**
|
||||||
* create a dummy eventTimelineSet and client, and a TimelineWindow
|
* create a dummy eventTimelineSet and client, and a TimelineWindow
|
||||||
@@ -142,7 +139,7 @@ describe("TimelineWindow", function() {
|
|||||||
let timelineSet;
|
let timelineSet;
|
||||||
let client;
|
let client;
|
||||||
function createWindow(timeline, opts) {
|
function createWindow(timeline, opts) {
|
||||||
timelineSet = {getTimelineForEvent: () => null};
|
timelineSet = { getTimelineForEvent: () => null };
|
||||||
client = {};
|
client = {};
|
||||||
client.getEventTimeline = function(timelineSet0, eventId0) {
|
client.getEventTimeline = function(timelineSet0, eventId0) {
|
||||||
expect(timelineSet0).toBe(timelineSet);
|
expect(timelineSet0).toBe(timelineSet);
|
||||||
@@ -171,7 +168,7 @@ describe("TimelineWindow", function() {
|
|||||||
const timeline = createTimeline();
|
const timeline = createTimeline();
|
||||||
const eventId = timeline.getEvents()[1].getId();
|
const eventId = timeline.getEvents()[1].getId();
|
||||||
|
|
||||||
const timelineSet = {getTimelineForEvent: () => null};
|
const timelineSet = { getTimelineForEvent: () => null };
|
||||||
const client = {};
|
const client = {};
|
||||||
client.getEventTimeline = function(timelineSet0, eventId0) {
|
client.getEventTimeline = function(timelineSet0, eventId0) {
|
||||||
expect(timelineSet0).toBe(timelineSet);
|
expect(timelineSet0).toBe(timelineSet);
|
||||||
@@ -193,7 +190,7 @@ describe("TimelineWindow", function() {
|
|||||||
|
|
||||||
const eventId = timeline.getEvents()[1].getId();
|
const eventId = timeline.getEvents()[1].getId();
|
||||||
|
|
||||||
const timelineSet = {getTimelineForEvent: () => null};
|
const timelineSet = { getTimelineForEvent: () => null };
|
||||||
const client = {};
|
const client = {};
|
||||||
|
|
||||||
const timelineWindow = new TimelineWindow(client, timelineSet);
|
const timelineWindow = new TimelineWindow(client, timelineSet);
|
||||||
@@ -266,7 +263,7 @@ describe("TimelineWindow", function() {
|
|||||||
it("should advance into next timeline", function() {
|
it("should advance into next timeline", function() {
|
||||||
const tls = createLinkedTimelines();
|
const tls = createLinkedTimelines();
|
||||||
const eventId = tls[0].getEvents()[1].getId();
|
const eventId = tls[0].getEvents()[1].getId();
|
||||||
const timelineWindow = createWindow(tls[0], {windowLimit: 5});
|
const timelineWindow = createWindow(tls[0], { windowLimit: 5 });
|
||||||
|
|
||||||
return timelineWindow.load(eventId, 3).then(function() {
|
return timelineWindow.load(eventId, 3).then(function() {
|
||||||
const expectedEvents = tls[0].getEvents();
|
const expectedEvents = tls[0].getEvents();
|
||||||
@@ -311,7 +308,7 @@ describe("TimelineWindow", function() {
|
|||||||
it("should retreat into previous timeline", function() {
|
it("should retreat into previous timeline", function() {
|
||||||
const tls = createLinkedTimelines();
|
const tls = createLinkedTimelines();
|
||||||
const eventId = tls[1].getEvents()[1].getId();
|
const eventId = tls[1].getEvents()[1].getId();
|
||||||
const timelineWindow = createWindow(tls[1], {windowLimit: 5});
|
const timelineWindow = createWindow(tls[1], { windowLimit: 5 });
|
||||||
|
|
||||||
return timelineWindow.load(eventId, 3).then(function() {
|
return timelineWindow.load(eventId, 3).then(function() {
|
||||||
const expectedEvents = tls[1].getEvents();
|
const expectedEvents = tls[1].getEvents();
|
||||||
@@ -357,7 +354,7 @@ describe("TimelineWindow", function() {
|
|||||||
const timeline = createTimeline();
|
const timeline = createTimeline();
|
||||||
timeline.setPaginationToken("toktok", EventTimeline.FORWARDS);
|
timeline.setPaginationToken("toktok", EventTimeline.FORWARDS);
|
||||||
|
|
||||||
const timelineWindow = createWindow(timeline, {windowLimit: 5});
|
const timelineWindow = createWindow(timeline, { windowLimit: 5 });
|
||||||
const eventId = timeline.getEvents()[1].getId();
|
const eventId = timeline.getEvents()[1].getId();
|
||||||
|
|
||||||
client.paginateEventTimeline = function(timeline0, opts) {
|
client.paginateEventTimeline = function(timeline0, opts) {
|
||||||
@@ -385,12 +382,11 @@ describe("TimelineWindow", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("should make backward pagination requests", function() {
|
it("should make backward pagination requests", function() {
|
||||||
const timeline = createTimeline();
|
const timeline = createTimeline();
|
||||||
timeline.setPaginationToken("toktok", EventTimeline.BACKWARDS);
|
timeline.setPaginationToken("toktok", EventTimeline.BACKWARDS);
|
||||||
|
|
||||||
const timelineWindow = createWindow(timeline, {windowLimit: 5});
|
const timelineWindow = createWindow(timeline, { windowLimit: 5 });
|
||||||
const eventId = timeline.getEvents()[1].getId();
|
const eventId = timeline.getEvents()[1].getId();
|
||||||
|
|
||||||
client.paginateEventTimeline = function(timeline0, opts) {
|
client.paginateEventTimeline = function(timeline0, opts) {
|
||||||
@@ -422,7 +418,7 @@ describe("TimelineWindow", function() {
|
|||||||
const timeline = createTimeline();
|
const timeline = createTimeline();
|
||||||
timeline.setPaginationToken("toktok", EventTimeline.FORWARDS);
|
timeline.setPaginationToken("toktok", EventTimeline.FORWARDS);
|
||||||
|
|
||||||
const timelineWindow = createWindow(timeline, {windowLimit: 5});
|
const timelineWindow = createWindow(timeline, { windowLimit: 5 });
|
||||||
const eventId = timeline.getEvents()[1].getId();
|
const eventId = timeline.getEvents()[1].getId();
|
||||||
|
|
||||||
let paginateCount = 0;
|
let paginateCount = 0;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import {User} from "../../src/models/user";
|
import { User } from "../../src/models/user";
|
||||||
import * as utils from "../test-utils";
|
import * as utils from "../test-utils";
|
||||||
|
|
||||||
describe("User", function() {
|
describe("User", function() {
|
||||||
|
@@ -140,19 +140,19 @@ describe("utils", function() {
|
|||||||
|
|
||||||
it("should handle simple objects", function() {
|
it("should handle simple objects", function() {
|
||||||
assert.isTrue(utils.deepCompare({}, {}));
|
assert.isTrue(utils.deepCompare({}, {}));
|
||||||
assert.isTrue(utils.deepCompare({a: 1, b: 2}, {a: 1, b: 2}));
|
assert.isTrue(utils.deepCompare({ a: 1, b: 2 }, { a: 1, b: 2 }));
|
||||||
assert.isTrue(utils.deepCompare({a: 1, b: 2}, {b: 2, a: 1}));
|
assert.isTrue(utils.deepCompare({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
||||||
assert.isFalse(utils.deepCompare({a: 1, b: 2}, {a: 1, b: 3}));
|
assert.isFalse(utils.deepCompare({ a: 1, b: 2 }, { a: 1, b: 3 }));
|
||||||
|
|
||||||
assert.isTrue(utils.deepCompare({1: {name: "mhc", age: 28},
|
assert.isTrue(utils.deepCompare({ 1: { name: "mhc", age: 28 },
|
||||||
2: {name: "arb", age: 26}},
|
2: { name: "arb", age: 26 } },
|
||||||
{1: {name: "mhc", age: 28},
|
{ 1: { name: "mhc", age: 28 },
|
||||||
2: {name: "arb", age: 26}}));
|
2: { name: "arb", age: 26 } }));
|
||||||
|
|
||||||
assert.isFalse(utils.deepCompare({1: {name: "mhc", age: 28},
|
assert.isFalse(utils.deepCompare({ 1: { name: "mhc", age: 28 },
|
||||||
2: {name: "arb", age: 26}},
|
2: { name: "arb", age: 26 } },
|
||||||
{1: {name: "mhc", age: 28},
|
{ 1: { name: "mhc", age: 28 },
|
||||||
2: {name: "arb", age: 27}}));
|
2: { name: "arb", age: 27 } }));
|
||||||
|
|
||||||
assert.isFalse(utils.deepCompare({}, null));
|
assert.isFalse(utils.deepCompare({}, null));
|
||||||
assert.isFalse(utils.deepCompare({}, undefined));
|
assert.isFalse(utils.deepCompare({}, undefined));
|
||||||
@@ -175,7 +175,6 @@ describe("utils", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("extend", function() {
|
describe("extend", function() {
|
||||||
const SOURCE = { "prop2": 1, "string2": "x", "newprop": "new" };
|
const SOURCE = { "prop2": 1, "string2": "x", "newprop": "new" };
|
||||||
|
|
||||||
|
2
src/@types/global.d.ts
vendored
2
src/@types/global.d.ts
vendored
@@ -15,7 +15,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// this is needed to tell TS about global.Olm
|
// 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 {};
|
export {};
|
||||||
|
|
||||||
|
@@ -17,8 +17,8 @@ limitations under the License.
|
|||||||
|
|
||||||
/** @module auto-discovery */
|
/** @module auto-discovery */
|
||||||
|
|
||||||
import {logger} from './logger';
|
import { logger } from './logger';
|
||||||
import {URL as NodeURL} from "url";
|
import { URL as NodeURL } from "url";
|
||||||
|
|
||||||
// Dev note: Auto discovery is part of the spec.
|
// Dev note: Auto discovery is part of the spec.
|
||||||
// See: https://matrix.org/docs/spec/client_server/r0.4.0.html#server-discovery
|
// See: https://matrix.org/docs/spec/client_server/r0.4.0.html#server-discovery
|
||||||
@@ -511,12 +511,12 @@ export class AutoDiscovery {
|
|||||||
action = "IGNORE";
|
action = "IGNORE";
|
||||||
reason = AutoDiscovery.ERROR_MISSING_WELLKNOWN;
|
reason = AutoDiscovery.ERROR_MISSING_WELLKNOWN;
|
||||||
}
|
}
|
||||||
resolve({raw: {}, action: action, reason: reason, error: err});
|
resolve({ raw: {}, action: action, reason: reason, error: err });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resolve({raw: JSON.parse(body), action: "SUCCESS"});
|
resolve({ raw: JSON.parse(body), action: "SUCCESS" });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let reason = AutoDiscovery.ERROR_INVALID;
|
let reason = AutoDiscovery.ERROR_INVALID;
|
||||||
if (e.name === "SyntaxError") {
|
if (e.name === "SyntaxError") {
|
||||||
|
@@ -24,11 +24,11 @@ limitations under the License.
|
|||||||
* @module base-apis
|
* @module base-apis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {SERVICE_TYPES} from './service-types';
|
import { SERVICE_TYPES } from './service-types';
|
||||||
import {logger} from './logger';
|
import { logger } from './logger';
|
||||||
import {PushProcessor} from "./pushprocessor";
|
import { PushProcessor } from "./pushprocessor";
|
||||||
import * as utils from "./utils";
|
import * as utils from "./utils";
|
||||||
import {MatrixHttpApi, PREFIX_IDENTITY_V2, PREFIX_R0, PREFIX_UNSTABLE} from "./http-api";
|
import { MatrixHttpApi, PREFIX_IDENTITY_V2, PREFIX_R0, PREFIX_UNSTABLE } from "./http-api";
|
||||||
|
|
||||||
function termsUrlForService(serviceType, baseUrl) {
|
function termsUrlForService(serviceType, baseUrl) {
|
||||||
switch (serviceType) {
|
switch (serviceType) {
|
||||||
@@ -158,7 +158,6 @@ MatrixBaseApis.prototype.makeTxnId = function() {
|
|||||||
return "m" + new Date().getTime() + "." + (this._txnCtr++);
|
return "m" + new Date().getTime() + "." + (this._txnCtr++);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Registration/Login operations
|
// Registration/Login operations
|
||||||
// =============================
|
// =============================
|
||||||
|
|
||||||
@@ -197,7 +196,7 @@ MatrixBaseApis.prototype.register = function(
|
|||||||
) {
|
) {
|
||||||
// backwards compat
|
// backwards compat
|
||||||
if (bindThreepids === true) {
|
if (bindThreepids === true) {
|
||||||
bindThreepids = {email: true};
|
bindThreepids = { email: true };
|
||||||
} else if (bindThreepids === null || bindThreepids === undefined) {
|
} else if (bindThreepids === null || bindThreepids === undefined) {
|
||||||
bindThreepids = {};
|
bindThreepids = {};
|
||||||
}
|
}
|
||||||
@@ -401,7 +400,6 @@ MatrixBaseApis.prototype.loginWithToken = function(token, callback) {
|
|||||||
}, callback);
|
}, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out the current session.
|
* Logs out the current session.
|
||||||
* Obviously, further calls that require authorisation should fail after this
|
* Obviously, further calls that require authorisation should fail after this
|
||||||
@@ -547,7 +545,7 @@ MatrixBaseApis.prototype.fetchRelations =
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.roomState = function(roomId, callback) {
|
MatrixBaseApis.prototype.roomState = function(roomId, callback) {
|
||||||
const path = utils.encodeUri("/rooms/$roomId/state", {$roomId: roomId});
|
const path = utils.encodeUri("/rooms/$roomId/state", { $roomId: roomId });
|
||||||
return this._http.authedRequest(callback, "GET", path);
|
return this._http.authedRequest(callback, "GET", path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -595,7 +593,7 @@ function(roomId, includeMembership, excludeMembership, atEventId, callback) {
|
|||||||
const queryString = utils.encodeParams(queryParams);
|
const queryString = utils.encodeParams(queryParams);
|
||||||
|
|
||||||
const path = utils.encodeUri("/rooms/$roomId/members?" + queryString,
|
const path = utils.encodeUri("/rooms/$roomId/members?" + queryString,
|
||||||
{$roomId: roomId});
|
{ $roomId: roomId });
|
||||||
return this._http.authedRequest(callback, "GET", path);
|
return this._http.authedRequest(callback, "GET", path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -607,20 +605,19 @@ function(roomId, includeMembership, excludeMembership, atEventId, callback) {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.upgradeRoom = function(roomId, newVersion) {
|
MatrixBaseApis.prototype.upgradeRoom = function(roomId, newVersion) {
|
||||||
const path = utils.encodeUri("/rooms/$roomId/upgrade", {$roomId: roomId});
|
const path = utils.encodeUri("/rooms/$roomId/upgrade", { $roomId: roomId });
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, "POST", path, undefined, {new_version: newVersion},
|
undefined, "POST", path, undefined, { new_version: newVersion },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} groupId
|
* @param {string} groupId
|
||||||
* @return {Promise} Resolves: Group summary object
|
* @return {Promise} Resolves: Group summary object
|
||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.getGroupSummary = function(groupId) {
|
MatrixBaseApis.prototype.getGroupSummary = function(groupId) {
|
||||||
const path = utils.encodeUri("/groups/$groupId/summary", {$groupId: groupId});
|
const path = utils.encodeUri("/groups/$groupId/summary", { $groupId: groupId });
|
||||||
return this._http.authedRequest(undefined, "GET", path);
|
return this._http.authedRequest(undefined, "GET", path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -630,7 +627,7 @@ MatrixBaseApis.prototype.getGroupSummary = function(groupId) {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.getGroupProfile = function(groupId) {
|
MatrixBaseApis.prototype.getGroupProfile = function(groupId) {
|
||||||
const path = utils.encodeUri("/groups/$groupId/profile", {$groupId: groupId});
|
const path = utils.encodeUri("/groups/$groupId/profile", { $groupId: groupId });
|
||||||
return this._http.authedRequest(undefined, "GET", path);
|
return this._http.authedRequest(undefined, "GET", path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -645,7 +642,7 @@ MatrixBaseApis.prototype.getGroupProfile = function(groupId) {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.setGroupProfile = function(groupId, profile) {
|
MatrixBaseApis.prototype.setGroupProfile = function(groupId, profile) {
|
||||||
const path = utils.encodeUri("/groups/$groupId/profile", {$groupId: groupId});
|
const path = utils.encodeUri("/groups/$groupId/profile", { $groupId: groupId });
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, "POST", path, undefined, profile,
|
undefined, "POST", path, undefined, profile,
|
||||||
);
|
);
|
||||||
@@ -663,7 +660,7 @@ MatrixBaseApis.prototype.setGroupProfile = function(groupId, profile) {
|
|||||||
MatrixBaseApis.prototype.setGroupJoinPolicy = function(groupId, policy) {
|
MatrixBaseApis.prototype.setGroupJoinPolicy = function(groupId, policy) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/settings/m.join_policy",
|
"/groups/$groupId/settings/m.join_policy",
|
||||||
{$groupId: groupId},
|
{ $groupId: groupId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, "PUT", path, undefined, {
|
undefined, "PUT", path, undefined, {
|
||||||
@@ -678,7 +675,7 @@ MatrixBaseApis.prototype.setGroupJoinPolicy = function(groupId, policy) {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.getGroupUsers = function(groupId) {
|
MatrixBaseApis.prototype.getGroupUsers = function(groupId) {
|
||||||
const path = utils.encodeUri("/groups/$groupId/users", {$groupId: groupId});
|
const path = utils.encodeUri("/groups/$groupId/users", { $groupId: groupId });
|
||||||
return this._http.authedRequest(undefined, "GET", path);
|
return this._http.authedRequest(undefined, "GET", path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -688,7 +685,7 @@ MatrixBaseApis.prototype.getGroupUsers = function(groupId) {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.getGroupInvitedUsers = function(groupId) {
|
MatrixBaseApis.prototype.getGroupInvitedUsers = function(groupId) {
|
||||||
const path = utils.encodeUri("/groups/$groupId/invited_users", {$groupId: groupId});
|
const path = utils.encodeUri("/groups/$groupId/invited_users", { $groupId: groupId });
|
||||||
return this._http.authedRequest(undefined, "GET", path);
|
return this._http.authedRequest(undefined, "GET", path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -698,7 +695,7 @@ MatrixBaseApis.prototype.getGroupInvitedUsers = function(groupId) {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.getGroupRooms = function(groupId) {
|
MatrixBaseApis.prototype.getGroupRooms = function(groupId) {
|
||||||
const path = utils.encodeUri("/groups/$groupId/rooms", {$groupId: groupId});
|
const path = utils.encodeUri("/groups/$groupId/rooms", { $groupId: groupId });
|
||||||
return this._http.authedRequest(undefined, "GET", path);
|
return this._http.authedRequest(undefined, "GET", path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -711,7 +708,7 @@ MatrixBaseApis.prototype.getGroupRooms = function(groupId) {
|
|||||||
MatrixBaseApis.prototype.inviteUserToGroup = function(groupId, userId) {
|
MatrixBaseApis.prototype.inviteUserToGroup = function(groupId, userId) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/admin/users/invite/$userId",
|
"/groups/$groupId/admin/users/invite/$userId",
|
||||||
{$groupId: groupId, $userId: userId},
|
{ $groupId: groupId, $userId: userId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
||||||
};
|
};
|
||||||
@@ -725,7 +722,7 @@ MatrixBaseApis.prototype.inviteUserToGroup = function(groupId, userId) {
|
|||||||
MatrixBaseApis.prototype.removeUserFromGroup = function(groupId, userId) {
|
MatrixBaseApis.prototype.removeUserFromGroup = function(groupId, userId) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/admin/users/remove/$userId",
|
"/groups/$groupId/admin/users/remove/$userId",
|
||||||
{$groupId: groupId, $userId: userId},
|
{ $groupId: groupId, $userId: userId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
||||||
};
|
};
|
||||||
@@ -742,7 +739,7 @@ MatrixBaseApis.prototype.addUserToGroupSummary = function(groupId, userId, roleI
|
|||||||
roleId ?
|
roleId ?
|
||||||
"/groups/$groupId/summary/$roleId/users/$userId" :
|
"/groups/$groupId/summary/$roleId/users/$userId" :
|
||||||
"/groups/$groupId/summary/users/$userId",
|
"/groups/$groupId/summary/users/$userId",
|
||||||
{$groupId: groupId, $roleId: roleId, $userId: userId},
|
{ $groupId: groupId, $roleId: roleId, $userId: userId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
||||||
};
|
};
|
||||||
@@ -756,7 +753,7 @@ MatrixBaseApis.prototype.addUserToGroupSummary = function(groupId, userId, roleI
|
|||||||
MatrixBaseApis.prototype.removeUserFromGroupSummary = function(groupId, userId) {
|
MatrixBaseApis.prototype.removeUserFromGroupSummary = function(groupId, userId) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/summary/users/$userId",
|
"/groups/$groupId/summary/users/$userId",
|
||||||
{$groupId: groupId, $userId: userId},
|
{ $groupId: groupId, $userId: userId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "DELETE", path, undefined, {});
|
return this._http.authedRequest(undefined, "DELETE", path, undefined, {});
|
||||||
};
|
};
|
||||||
@@ -773,7 +770,7 @@ MatrixBaseApis.prototype.addRoomToGroupSummary = function(groupId, roomId, categ
|
|||||||
categoryId ?
|
categoryId ?
|
||||||
"/groups/$groupId/summary/$categoryId/rooms/$roomId" :
|
"/groups/$groupId/summary/$categoryId/rooms/$roomId" :
|
||||||
"/groups/$groupId/summary/rooms/$roomId",
|
"/groups/$groupId/summary/rooms/$roomId",
|
||||||
{$groupId: groupId, $categoryId: categoryId, $roomId: roomId},
|
{ $groupId: groupId, $categoryId: categoryId, $roomId: roomId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
||||||
};
|
};
|
||||||
@@ -787,7 +784,7 @@ MatrixBaseApis.prototype.addRoomToGroupSummary = function(groupId, roomId, categ
|
|||||||
MatrixBaseApis.prototype.removeRoomFromGroupSummary = function(groupId, roomId) {
|
MatrixBaseApis.prototype.removeRoomFromGroupSummary = function(groupId, roomId) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/summary/rooms/$roomId",
|
"/groups/$groupId/summary/rooms/$roomId",
|
||||||
{$groupId: groupId, $roomId: roomId},
|
{ $groupId: groupId, $roomId: roomId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "DELETE", path, undefined, {});
|
return this._http.authedRequest(undefined, "DELETE", path, undefined, {});
|
||||||
};
|
};
|
||||||
@@ -805,7 +802,7 @@ MatrixBaseApis.prototype.addRoomToGroup = function(groupId, roomId, isPublic) {
|
|||||||
}
|
}
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/admin/rooms/$roomId",
|
"/groups/$groupId/admin/rooms/$roomId",
|
||||||
{$groupId: groupId, $roomId: roomId},
|
{ $groupId: groupId, $roomId: roomId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined,
|
return this._http.authedRequest(undefined, "PUT", path, undefined,
|
||||||
{ "m.visibility": { type: isPublic ? "public" : "private" } },
|
{ "m.visibility": { type: isPublic ? "public" : "private" } },
|
||||||
@@ -827,7 +824,7 @@ MatrixBaseApis.prototype.updateGroupRoomVisibility = function(groupId, roomId, i
|
|||||||
|
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/admin/rooms/$roomId/config/m.visibility",
|
"/groups/$groupId/admin/rooms/$roomId/config/m.visibility",
|
||||||
{$groupId: groupId, $roomId: roomId},
|
{ $groupId: groupId, $roomId: roomId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined,
|
return this._http.authedRequest(undefined, "PUT", path, undefined,
|
||||||
{ type: isPublic ? "public" : "private" },
|
{ type: isPublic ? "public" : "private" },
|
||||||
@@ -843,7 +840,7 @@ MatrixBaseApis.prototype.updateGroupRoomVisibility = function(groupId, roomId, i
|
|||||||
MatrixBaseApis.prototype.removeRoomFromGroup = function(groupId, roomId) {
|
MatrixBaseApis.prototype.removeRoomFromGroup = function(groupId, roomId) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/admin/rooms/$roomId",
|
"/groups/$groupId/admin/rooms/$roomId",
|
||||||
{$groupId: groupId, $roomId: roomId},
|
{ $groupId: groupId, $roomId: roomId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "DELETE", path, undefined, {});
|
return this._http.authedRequest(undefined, "DELETE", path, undefined, {});
|
||||||
};
|
};
|
||||||
@@ -857,7 +854,7 @@ MatrixBaseApis.prototype.removeRoomFromGroup = function(groupId, roomId) {
|
|||||||
MatrixBaseApis.prototype.acceptGroupInvite = function(groupId, opts = null) {
|
MatrixBaseApis.prototype.acceptGroupInvite = function(groupId, opts = null) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/self/accept_invite",
|
"/groups/$groupId/self/accept_invite",
|
||||||
{$groupId: groupId},
|
{ $groupId: groupId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined, opts || {});
|
return this._http.authedRequest(undefined, "PUT", path, undefined, opts || {});
|
||||||
};
|
};
|
||||||
@@ -870,7 +867,7 @@ MatrixBaseApis.prototype.acceptGroupInvite = function(groupId, opts = null) {
|
|||||||
MatrixBaseApis.prototype.joinGroup = function(groupId) {
|
MatrixBaseApis.prototype.joinGroup = function(groupId) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/self/join",
|
"/groups/$groupId/self/join",
|
||||||
{$groupId: groupId},
|
{ $groupId: groupId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
||||||
};
|
};
|
||||||
@@ -883,7 +880,7 @@ MatrixBaseApis.prototype.joinGroup = function(groupId) {
|
|||||||
MatrixBaseApis.prototype.leaveGroup = function(groupId) {
|
MatrixBaseApis.prototype.leaveGroup = function(groupId) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/self/leave",
|
"/groups/$groupId/self/leave",
|
||||||
{$groupId: groupId},
|
{ $groupId: groupId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
return this._http.authedRequest(undefined, "PUT", path, undefined, {});
|
||||||
};
|
};
|
||||||
@@ -940,7 +937,7 @@ MatrixBaseApis.prototype.getPublicisedGroups = function(userIds) {
|
|||||||
MatrixBaseApis.prototype.setGroupPublicity = function(groupId, isPublic) {
|
MatrixBaseApis.prototype.setGroupPublicity = function(groupId, isPublic) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/groups/$groupId/self/update_publicity",
|
"/groups/$groupId/self/update_publicity",
|
||||||
{$groupId: groupId},
|
{ $groupId: groupId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(undefined, "PUT", path, undefined, {
|
return this._http.authedRequest(undefined, "PUT", path, undefined, {
|
||||||
publicise: isPublic,
|
publicise: isPublic,
|
||||||
@@ -1008,7 +1005,7 @@ MatrixBaseApis.prototype.roomInitialSync = function(roomId, limit, callback) {
|
|||||||
callback = limit; limit = undefined;
|
callback = limit; limit = undefined;
|
||||||
}
|
}
|
||||||
const path = utils.encodeUri("/rooms/$roomId/initialSync",
|
const path = utils.encodeUri("/rooms/$roomId/initialSync",
|
||||||
{$roomId: roomId},
|
{ $roomId: roomId },
|
||||||
);
|
);
|
||||||
if (!limit) {
|
if (!limit) {
|
||||||
limit = 30;
|
limit = 30;
|
||||||
@@ -1159,7 +1156,7 @@ MatrixBaseApis.prototype.deleteAlias = function(alias, callback) {
|
|||||||
MatrixBaseApis.prototype.unstableGetLocalAliases =
|
MatrixBaseApis.prototype.unstableGetLocalAliases =
|
||||||
function(roomId, callback) {
|
function(roomId, callback) {
|
||||||
const path = utils.encodeUri("/rooms/$roomId/aliases",
|
const path = utils.encodeUri("/rooms/$roomId/aliases",
|
||||||
{$roomId: roomId});
|
{ $roomId: roomId });
|
||||||
const prefix = PREFIX_UNSTABLE + "/org.matrix.msc2432";
|
const prefix = PREFIX_UNSTABLE + "/org.matrix.msc2432";
|
||||||
return this._http.authedRequest(callback, "GET", path,
|
return this._http.authedRequest(callback, "GET", path,
|
||||||
null, null, { prefix });
|
null, null, { prefix });
|
||||||
@@ -1190,7 +1187,7 @@ MatrixBaseApis.prototype.getRoomIdForAlias = function(alias, callback) {
|
|||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.resolveRoomAlias = function(roomAlias, callback) {
|
MatrixBaseApis.prototype.resolveRoomAlias = function(roomAlias, callback) {
|
||||||
// TODO: deprecate this or getRoomIdForAlias
|
// TODO: deprecate this or getRoomIdForAlias
|
||||||
const path = utils.encodeUri("/directory/room/$alias", {$alias: roomAlias});
|
const path = utils.encodeUri("/directory/room/$alias", { $alias: roomAlias });
|
||||||
return this._http.request(callback, "GET", path);
|
return this._http.request(callback, "GET", path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1278,7 +1275,6 @@ MatrixBaseApis.prototype.searchUserDirectory = function(opts) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Media operations
|
// Media operations
|
||||||
// ================
|
// ================
|
||||||
|
|
||||||
@@ -1347,7 +1343,6 @@ MatrixBaseApis.prototype.getCurrentUploads = function() {
|
|||||||
return this._http.getCurrentUploads();
|
return this._http.getCurrentUploads();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Profile operations
|
// Profile operations
|
||||||
// ==================
|
// ==================
|
||||||
|
|
||||||
@@ -1372,7 +1367,6 @@ MatrixBaseApis.prototype.getProfileInfo = function(userId, info, callback) {
|
|||||||
return this._http.authedRequest(callback, "GET", path);
|
return this._http.authedRequest(callback, "GET", path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Account operations
|
// Account operations
|
||||||
// ==================
|
// ==================
|
||||||
|
|
||||||
@@ -1518,7 +1512,6 @@ MatrixBaseApis.prototype.setPassword = function(authDict, newPassword, callback)
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Device operations
|
// Device operations
|
||||||
// =================
|
// =================
|
||||||
|
|
||||||
@@ -1595,7 +1588,7 @@ MatrixBaseApis.prototype.deleteDevice = function(device_id, auth) {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixBaseApis.prototype.deleteMultipleDevices = function(devices, auth) {
|
MatrixBaseApis.prototype.deleteMultipleDevices = function(devices, auth) {
|
||||||
const body = {devices};
|
const body = { devices };
|
||||||
|
|
||||||
if (auth) {
|
if (auth) {
|
||||||
body.auth = auth;
|
body.auth = auth;
|
||||||
@@ -1605,7 +1598,6 @@ MatrixBaseApis.prototype.deleteMultipleDevices = function(devices, auth) {
|
|||||||
return this._http.authedRequest(undefined, "POST", path, undefined, body);
|
return this._http.authedRequest(undefined, "POST", path, undefined, body);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Push operations
|
// Push operations
|
||||||
// ===============
|
// ===============
|
||||||
|
|
||||||
@@ -1703,7 +1695,7 @@ MatrixBaseApis.prototype.setPushRuleEnabled = function(scope, kind,
|
|||||||
$ruleId: ruleId,
|
$ruleId: ruleId,
|
||||||
});
|
});
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
callback, "PUT", path, undefined, {"enabled": enabled},
|
callback, "PUT", path, undefined, { "enabled": enabled },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1724,11 +1716,10 @@ MatrixBaseApis.prototype.setPushRuleActions = function(scope, kind,
|
|||||||
$ruleId: ruleId,
|
$ruleId: ruleId,
|
||||||
});
|
});
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
callback, "PUT", path, undefined, {"actions": actions},
|
callback, "PUT", path, undefined, { "actions": actions },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
// ======
|
// ======
|
||||||
|
|
||||||
@@ -1842,7 +1833,7 @@ MatrixBaseApis.prototype.claimOneTimeKeys = function(devices, key_algorithm, tim
|
|||||||
queries[userId] = query;
|
queries[userId] = query;
|
||||||
query[deviceId] = key_algorithm;
|
query[deviceId] = key_algorithm;
|
||||||
}
|
}
|
||||||
const content = {one_time_keys: queries};
|
const content = { one_time_keys: queries };
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
content.timeout = timeout;
|
content.timeout = timeout;
|
||||||
}
|
}
|
||||||
@@ -1872,7 +1863,7 @@ MatrixBaseApis.prototype.getKeyChanges = function(oldToken, newToken) {
|
|||||||
|
|
||||||
MatrixBaseApis.prototype.uploadDeviceSigningKeys = function(auth, keys) {
|
MatrixBaseApis.prototype.uploadDeviceSigningKeys = function(auth, keys) {
|
||||||
const data = Object.assign({}, keys);
|
const data = Object.assign({}, keys);
|
||||||
if (auth) Object.assign(data, {auth});
|
if (auth) Object.assign(data, { auth });
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, "POST", "/keys/device_signing/upload", undefined, data, {
|
undefined, "POST", "/keys/device_signing/upload", undefined, data, {
|
||||||
prefix: PREFIX_UNSTABLE,
|
prefix: PREFIX_UNSTABLE,
|
||||||
@@ -2166,7 +2157,7 @@ MatrixBaseApis.prototype.identityHashedLookup = async function(
|
|||||||
throw new Error("Identity server returned more results than expected");
|
throw new Error("Identity server returned more results than expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
foundAddresses.push({address: plainAddress, mxid});
|
foundAddresses.push({ address: plainAddress, mxid });
|
||||||
}
|
}
|
||||||
return foundAddresses;
|
return foundAddresses;
|
||||||
};
|
};
|
||||||
@@ -2257,7 +2248,7 @@ MatrixBaseApis.prototype.bulkLookupThreePids = async function(
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {threepids: v1results};
|
return { threepids: v1results };
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2401,7 +2392,7 @@ MatrixBaseApis.prototype.reportEvent = function(roomId, eventId, score, reason)
|
|||||||
$eventId: eventId,
|
$eventId: eventId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return this._http.authedRequest(undefined, "POST", path, null, {score, reason});
|
return this._http.authedRequest(undefined, "POST", path, null, { score, reason });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -17,46 +17,45 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an internal module. See {@link MatrixClient} for the public class.
|
* This is an internal module. See {@link MatrixClient} for the public class.
|
||||||
* @module client
|
* @module client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import url from "url";
|
import url from "url";
|
||||||
import {EventEmitter} from "events";
|
import { EventEmitter } from "events";
|
||||||
import {MatrixBaseApis} from "./base-apis";
|
import { MatrixBaseApis } from "./base-apis";
|
||||||
import {Filter} from "./filter";
|
import { Filter } from "./filter";
|
||||||
import {SyncApi} from "./sync";
|
import { SyncApi } from "./sync";
|
||||||
import {EventStatus, MatrixEvent} from "./models/event";
|
import { EventStatus, MatrixEvent } from "./models/event";
|
||||||
import {EventTimeline} from "./models/event-timeline";
|
import { EventTimeline } from "./models/event-timeline";
|
||||||
import {SearchResult} from "./models/search-result";
|
import { SearchResult } from "./models/search-result";
|
||||||
import {StubStore} from "./store/stub";
|
import { StubStore } from "./store/stub";
|
||||||
import {createNewMatrixCall} from "./webrtc/call";
|
import { createNewMatrixCall } from "./webrtc/call";
|
||||||
import {CallEventHandler} from './webrtc/callEventHandler';
|
import { CallEventHandler } from './webrtc/callEventHandler';
|
||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
import {sleep} from './utils';
|
import { sleep } from './utils';
|
||||||
import {
|
import {
|
||||||
MatrixError,
|
MatrixError,
|
||||||
PREFIX_MEDIA_R0,
|
PREFIX_MEDIA_R0,
|
||||||
PREFIX_UNSTABLE,
|
PREFIX_UNSTABLE,
|
||||||
retryNetworkOperation,
|
retryNetworkOperation,
|
||||||
} from "./http-api";
|
} from "./http-api";
|
||||||
import {getHttpUriForMxc} from "./content-repo";
|
import { getHttpUriForMxc } from "./content-repo";
|
||||||
import * as ContentHelpers from "./content-helpers";
|
import * as ContentHelpers from "./content-helpers";
|
||||||
import * as olmlib from "./crypto/olmlib";
|
import * as olmlib from "./crypto/olmlib";
|
||||||
import {ReEmitter} from './ReEmitter';
|
import { ReEmitter } from './ReEmitter';
|
||||||
import {RoomList} from './crypto/RoomList';
|
import { RoomList } from './crypto/RoomList';
|
||||||
import {logger} from './logger';
|
import { logger } from './logger';
|
||||||
import {Crypto, isCryptoAvailable, fixBackupKey} from './crypto';
|
import { Crypto, isCryptoAvailable, fixBackupKey } from './crypto';
|
||||||
import {decodeRecoveryKey} from './crypto/recoverykey';
|
import { decodeRecoveryKey } from './crypto/recoverykey';
|
||||||
import {keyFromAuthData} from './crypto/key_passphrase';
|
import { keyFromAuthData } from './crypto/key_passphrase';
|
||||||
import {randomString} from './randomstring';
|
import { randomString } from './randomstring';
|
||||||
import {PushProcessor} from "./pushprocessor";
|
import { PushProcessor } from "./pushprocessor";
|
||||||
import {encodeBase64, decodeBase64} from "./crypto/olmlib";
|
import { encodeBase64, decodeBase64 } from "./crypto/olmlib";
|
||||||
import { User } from "./models/user";
|
import { User } from "./models/user";
|
||||||
import {AutoDiscovery} from "./autodiscovery";
|
import { AutoDiscovery } from "./autodiscovery";
|
||||||
import {DEHYDRATION_ALGORITHM} from "./crypto/dehydration";
|
import { DEHYDRATION_ALGORITHM } from "./crypto/dehydration";
|
||||||
|
|
||||||
const SCROLLBACK_DELAY_MS = 3000;
|
const SCROLLBACK_DELAY_MS = 3000;
|
||||||
export const CRYPTO_ENABLED = isCryptoAvailable();
|
export const CRYPTO_ENABLED = isCryptoAvailable();
|
||||||
@@ -706,7 +705,6 @@ MatrixClient.prototype.getDeviceId = function() {
|
|||||||
return this.deviceId;
|
return this.deviceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the runtime environment supports VoIP calling.
|
* Check if the runtime environment supports VoIP calling.
|
||||||
* @return {boolean} True if VoIP is supported.
|
* @return {boolean} True if VoIP is supported.
|
||||||
@@ -969,14 +967,12 @@ MatrixClient.prototype.initCrypto = async function() {
|
|||||||
|
|
||||||
this.olmVersion = Crypto.getOlmVersion();
|
this.olmVersion = Crypto.getOlmVersion();
|
||||||
|
|
||||||
|
|
||||||
// if crypto initialisation was successful, tell it to attach its event
|
// if crypto initialisation was successful, tell it to attach its event
|
||||||
// handlers.
|
// handlers.
|
||||||
crypto.registerEventHandlers(this);
|
crypto.registerEventHandlers(this);
|
||||||
this._crypto = crypto;
|
this._crypto = crypto;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is end-to-end crypto enabled for this client.
|
* Is end-to-end crypto enabled for this client.
|
||||||
* @return {boolean} True if end-to-end is enabled.
|
* @return {boolean} True if end-to-end is enabled.
|
||||||
@@ -1790,7 +1786,7 @@ MatrixClient.prototype.checkKeyBackup = function() {
|
|||||||
MatrixClient.prototype.getKeyBackupVersion = function() {
|
MatrixClient.prototype.getKeyBackupVersion = function() {
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, "GET", "/room_keys/version", undefined, undefined,
|
undefined, "GET", "/room_keys/version", undefined, undefined,
|
||||||
{prefix: PREFIX_UNSTABLE},
|
{ prefix: PREFIX_UNSTABLE },
|
||||||
).then((res) => {
|
).then((res) => {
|
||||||
if (res.algorithm !== olmlib.MEGOLM_BACKUP_ALGORITHM) {
|
if (res.algorithm !== olmlib.MEGOLM_BACKUP_ALGORITHM) {
|
||||||
const err = "Unknown backup algorithm: " + res.algorithm;
|
const err = "Unknown backup algorithm: " + res.algorithm;
|
||||||
@@ -1968,7 +1964,7 @@ MatrixClient.prototype.createKeyBackupVersion = async function(info) {
|
|||||||
|
|
||||||
const res = await this._http.authedRequest(
|
const res = await this._http.authedRequest(
|
||||||
undefined, "POST", "/room_keys/version", undefined, data,
|
undefined, "POST", "/room_keys/version", undefined, data,
|
||||||
{prefix: PREFIX_UNSTABLE},
|
{ prefix: PREFIX_UNSTABLE },
|
||||||
);
|
);
|
||||||
|
|
||||||
// We could assume everything's okay and enable directly, but this ensures
|
// We could assume everything's okay and enable directly, but this ensures
|
||||||
@@ -2000,7 +1996,7 @@ MatrixClient.prototype.deleteKeyBackupVersion = function(version) {
|
|||||||
|
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, "DELETE", path, undefined, undefined,
|
undefined, "DELETE", path, undefined, undefined,
|
||||||
{prefix: PREFIX_UNSTABLE},
|
{ prefix: PREFIX_UNSTABLE },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2042,7 +2038,7 @@ MatrixClient.prototype.sendKeyBackup = function(roomId, sessionId, version, data
|
|||||||
const path = this._makeKeyBackupPath(roomId, sessionId, version);
|
const path = this._makeKeyBackupPath(roomId, sessionId, version);
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, "PUT", path.path, path.queryData, data,
|
undefined, "PUT", path.path, path.queryData, data,
|
||||||
{prefix: PREFIX_UNSTABLE},
|
{ prefix: PREFIX_UNSTABLE },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2242,7 +2238,7 @@ MatrixClient.prototype._restoreKeyBackup = function(
|
|||||||
// doesn't match the one in the auth_data, the user has enetered
|
// doesn't match the one in the auth_data, the user has enetered
|
||||||
// a different recovery key / the wrong passphrase.
|
// a different recovery key / the wrong passphrase.
|
||||||
if (backupPubKey !== backupInfo.auth_data.public_key) {
|
if (backupPubKey !== backupInfo.auth_data.public_key) {
|
||||||
return Promise.reject({errcode: MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY});
|
return Promise.reject({ errcode: MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the key, if possible.
|
// Cache the key, if possible.
|
||||||
@@ -2260,7 +2256,7 @@ MatrixClient.prototype._restoreKeyBackup = function(
|
|||||||
|
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, "GET", path.path, path.queryData, undefined,
|
undefined, "GET", path.path, path.queryData, undefined,
|
||||||
{prefix: PREFIX_UNSTABLE},
|
{ prefix: PREFIX_UNSTABLE },
|
||||||
).then((res) => {
|
).then((res) => {
|
||||||
if (res.rooms) {
|
if (res.rooms) {
|
||||||
for (const [roomId, roomData] of Object.entries(res.rooms)) {
|
for (const [roomId, roomData] of Object.entries(res.rooms)) {
|
||||||
@@ -2300,7 +2296,7 @@ MatrixClient.prototype._restoreKeyBackup = function(
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this._crypto.setTrustedBackupPubKey(backupPubKey);
|
return this._crypto.setTrustedBackupPubKey(backupPubKey);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return {total: totalKeyCount, imported: keys.length};
|
return { total: totalKeyCount, imported: keys.length };
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
decryption.free();
|
decryption.free();
|
||||||
});
|
});
|
||||||
@@ -2314,7 +2310,7 @@ MatrixClient.prototype.deleteKeysFromBackup = function(roomId, sessionId, versio
|
|||||||
const path = this._makeKeyBackupPath(roomId, sessionId, version);
|
const path = this._makeKeyBackupPath(roomId, sessionId, version);
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, "DELETE", path.path, path.queryData, undefined,
|
undefined, "DELETE", path.path, path.queryData, undefined,
|
||||||
{prefix: PREFIX_UNSTABLE},
|
{ prefix: PREFIX_UNSTABLE },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2549,7 +2545,7 @@ MatrixClient.prototype.getIgnoredUsers = function() {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixClient.prototype.setIgnoredUsers = function(userIds, callback) {
|
MatrixClient.prototype.setIgnoredUsers = function(userIds, callback) {
|
||||||
const content = {ignored_users: {}};
|
const content = { ignored_users: {} };
|
||||||
userIds.map((u) => content.ignored_users[u] = {});
|
userIds.map((u) => content.ignored_users[u] = {});
|
||||||
return this.setAccountData("m.ignored_user_list", content, callback);
|
return this.setAccountData("m.ignored_user_list", content, callback);
|
||||||
};
|
};
|
||||||
@@ -2610,7 +2606,7 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) {
|
|||||||
queryString["server_name"] = opts.viaServers;
|
queryString["server_name"] = opts.viaServers;
|
||||||
}
|
}
|
||||||
|
|
||||||
const reqOpts = {qsStringifyOptions: {arrayFormat: 'repeat'}};
|
const reqOpts = { qsStringifyOptions: { arrayFormat: 'repeat' } };
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
const prom = new Promise((resolve, reject) => {
|
const prom = new Promise((resolve, reject) => {
|
||||||
@@ -2620,7 +2616,7 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) {
|
|||||||
data.third_party_signed = signed_invite_object;
|
data.third_party_signed = signed_invite_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = utils.encodeUri("/join/$roomid", { $roomid: roomIdOrAlias});
|
const path = utils.encodeUri("/join/$roomid", { $roomid: roomIdOrAlias });
|
||||||
return self._http.authedRequest(
|
return self._http.authedRequest(
|
||||||
undefined, "POST", path, queryString, data, reqOpts);
|
undefined, "POST", path, queryString, data, reqOpts);
|
||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
@@ -2684,7 +2680,7 @@ MatrixClient.prototype.cancelPendingEvent = function(event) {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixClient.prototype.setRoomName = function(roomId, name, callback) {
|
MatrixClient.prototype.setRoomName = function(roomId, name, callback) {
|
||||||
return this.sendStateEvent(roomId, "m.room.name", {name: name},
|
return this.sendStateEvent(roomId, "m.room.name", { name: name },
|
||||||
undefined, callback);
|
undefined, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2696,7 +2692,7 @@ MatrixClient.prototype.setRoomName = function(roomId, name, callback) {
|
|||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
*/
|
*/
|
||||||
MatrixClient.prototype.setRoomTopic = function(roomId, topic, callback) {
|
MatrixClient.prototype.setRoomTopic = function(roomId, topic, callback) {
|
||||||
return this.sendStateEvent(roomId, "m.room.topic", {topic: topic},
|
return this.sendStateEvent(roomId, "m.room.topic", { topic: topic },
|
||||||
undefined, callback);
|
undefined, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2882,7 +2878,6 @@ MatrixClient.prototype._sendCompleteEvent = function(roomId, eventObject, txnId,
|
|||||||
return _sendEvent(this, room, localEvent, callback);
|
return _sendEvent(this, room, localEvent, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// encrypts the event if necessary
|
// encrypts the event if necessary
|
||||||
// adds the event to the queue, or sends it
|
// adds the event to the queue, or sends it
|
||||||
// marks the event as sent/unsent
|
// marks the event as sent/unsent
|
||||||
@@ -3730,7 +3725,7 @@ function _setMembershipState(client, roomId, userId, membershipValue, reason,
|
|||||||
|
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/rooms/$roomId/state/m.room.member/$userId",
|
"/rooms/$roomId/state/m.room.member/$userId",
|
||||||
{ $roomId: roomId, $userId: userId},
|
{ $roomId: roomId, $userId: userId },
|
||||||
);
|
);
|
||||||
|
|
||||||
return client._http.authedRequest(callback, "PUT", path, undefined, {
|
return client._http.authedRequest(callback, "PUT", path, undefined, {
|
||||||
@@ -4045,7 +4040,7 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) {
|
|||||||
|
|
||||||
let params = undefined;
|
let params = undefined;
|
||||||
if (this._clientOpts.lazyLoadMembers) {
|
if (this._clientOpts.lazyLoadMembers) {
|
||||||
params = {filter: JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER)};
|
params = { filter: JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER) };
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: we should implement a backoff (as per scrollback()) to deal more
|
// TODO: we should implement a backoff (as per scrollback()) to deal more
|
||||||
@@ -4111,7 +4106,7 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) {
|
|||||||
MatrixClient.prototype._createMessagesRequest =
|
MatrixClient.prototype._createMessagesRequest =
|
||||||
function(roomId, fromToken, limit, dir, timelineFilter = undefined) {
|
function(roomId, fromToken, limit, dir, timelineFilter = undefined) {
|
||||||
const path = utils.encodeUri(
|
const path = utils.encodeUri(
|
||||||
"/rooms/$roomId/messages", {$roomId: roomId},
|
"/rooms/$roomId/messages", { $roomId: roomId },
|
||||||
);
|
);
|
||||||
if (limit === undefined) {
|
if (limit === undefined) {
|
||||||
limit = 30;
|
limit = 30;
|
||||||
@@ -4566,7 +4561,6 @@ MatrixClient.prototype._requestTokenFromEndpoint = async function(endpoint, para
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Push operations
|
// Push operations
|
||||||
// ===============
|
// ===============
|
||||||
|
|
||||||
@@ -4745,7 +4739,7 @@ MatrixClient.prototype.searchRoomEvents = function(opts) {
|
|||||||
highlights: [],
|
highlights: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.search({body: body}).then(
|
return this.search({ body: body }).then(
|
||||||
this._processRoomEventsSearch.bind(this, searchResults),
|
this._processRoomEventsSearch.bind(this, searchResults),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -4822,7 +4816,6 @@ MatrixClient.prototype._processRoomEventsSearch = function(searchResults, respon
|
|||||||
return searchResults;
|
return searchResults;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the store with rooms the user has left.
|
* Populate the store with rooms the user has left.
|
||||||
* @return {Promise} Resolves: TODO - Resolved when the rooms have
|
* @return {Promise} Resolves: TODO - Resolved when the rooms have
|
||||||
@@ -4968,7 +4961,6 @@ MatrixClient.prototype.getOrCreateFilter = async function(filterName, filter) {
|
|||||||
return createdFilter.filterId;
|
return createdFilter.filterId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a bearer token from the Home Server that the user can
|
* Gets a bearer token from the Home Server that the user can
|
||||||
* present to a third party in order to prove their ownership
|
* present to a third party in order to prove their ownership
|
||||||
@@ -4986,7 +4978,6 @@ MatrixClient.prototype.getOpenIdToken = function() {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// VoIP operations
|
// VoIP operations
|
||||||
// ===============
|
// ===============
|
||||||
|
|
||||||
@@ -5103,7 +5094,7 @@ MatrixClient.prototype.isSynapseAdministrator = function() {
|
|||||||
{ $userId: this.getUserId() },
|
{ $userId: this.getUserId() },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, 'GET', path, undefined, undefined, {prefix: ''},
|
undefined, 'GET', path, undefined, undefined, { prefix: '' },
|
||||||
).then(r => r['admin']); // pull out the specific boolean we want
|
).then(r => r['admin']); // pull out the specific boolean we want
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -5120,7 +5111,7 @@ MatrixClient.prototype.whoisSynapseUser = function(userId) {
|
|||||||
{ $userId: userId },
|
{ $userId: userId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, 'GET', path, undefined, undefined, {prefix: ''},
|
undefined, 'GET', path, undefined, undefined, { prefix: '' },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -5136,7 +5127,7 @@ MatrixClient.prototype.deactivateSynapseUser = function(userId) {
|
|||||||
{ $userId: userId },
|
{ $userId: userId },
|
||||||
);
|
);
|
||||||
return this._http.authedRequest(
|
return this._http.authedRequest(
|
||||||
undefined, 'POST', path, undefined, undefined, {prefix: ''},
|
undefined, 'POST', path, undefined, undefined, { prefix: '' },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -5154,7 +5145,6 @@ MatrixClient.prototype.deactivateSynapseUser = function(userId) {
|
|||||||
// due to ambiguity (or should this be on a chat-specific layer)?
|
// due to ambiguity (or should this be on a chat-specific layer)?
|
||||||
// reconnect after connectivity outages
|
// reconnect after connectivity outages
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* High level helper method to begin syncing and poll for new events. To listen for these
|
* 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"}
|
* events, add a listener for {@link module:client~MatrixClient#event:"event"}
|
||||||
@@ -5305,7 +5295,7 @@ MatrixClient.prototype._unstable_getSharedRooms = async function(userId) {
|
|||||||
});
|
});
|
||||||
const res = await this._http.authedRequest(
|
const res = await this._http.authedRequest(
|
||||||
undefined, "GET", path, undefined, undefined,
|
undefined, "GET", path, undefined, undefined,
|
||||||
{prefix: PREFIX_UNSTABLE},
|
{ prefix: PREFIX_UNSTABLE },
|
||||||
);
|
);
|
||||||
return res.joined;
|
return res.joined;
|
||||||
};
|
};
|
||||||
|
@@ -20,11 +20,11 @@ limitations under the License.
|
|||||||
* @module crypto/CrossSigning
|
* @module crypto/CrossSigning
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {decodeBase64, encodeBase64, pkSign, pkVerify} from './olmlib';
|
import { decodeBase64, encodeBase64, pkSign, pkVerify } from './olmlib';
|
||||||
import {EventEmitter} from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
import {IndexedDBCryptoStore} from '../crypto/store/indexeddb-crypto-store';
|
import { IndexedDBCryptoStore } from '../crypto/store/indexeddb-crypto-store';
|
||||||
import {decryptAES, encryptAES} from './aes';
|
import { decryptAES, encryptAES } from './aes';
|
||||||
|
|
||||||
const KEY_REQUEST_TIMEOUT_MS = 1000 * 60;
|
const KEY_REQUEST_TIMEOUT_MS = 1000 * 60;
|
||||||
|
|
||||||
|
@@ -22,14 +22,13 @@ limitations under the License.
|
|||||||
* Manages the list of other users' devices
|
* Manages the list of other users' devices
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EventEmitter} from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
import {DeviceInfo} from './deviceinfo';
|
import { DeviceInfo } from './deviceinfo';
|
||||||
import {CrossSigningInfo} from './CrossSigning';
|
import { CrossSigningInfo } from './CrossSigning';
|
||||||
import * as olmlib from './olmlib';
|
import * as olmlib from './olmlib';
|
||||||
import {IndexedDBCryptoStore} from './store/indexeddb-crypto-store';
|
import { IndexedDBCryptoStore } from './store/indexeddb-crypto-store';
|
||||||
import {chunkPromises, defer, sleep} from '../utils';
|
import { chunkPromises, defer, sleep } from '../utils';
|
||||||
|
|
||||||
|
|
||||||
/* State transition diagram for DeviceList._deviceTrackingStatus
|
/* State transition diagram for DeviceList._deviceTrackingStatus
|
||||||
*
|
*
|
||||||
@@ -51,7 +50,6 @@ import {chunkPromises, defer, sleep} from '../utils';
|
|||||||
* +----------------------- UP_TO_DATE ------------------------+
|
* +----------------------- UP_TO_DATE ------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// constants for DeviceList._deviceTrackingStatus
|
// constants for DeviceList._deviceTrackingStatus
|
||||||
const TRACKING_STATUS_NOT_TRACKED = 0;
|
const TRACKING_STATUS_NOT_TRACKED = 0;
|
||||||
const TRACKING_STATUS_PENDING_DOWNLOAD = 1;
|
const TRACKING_STATUS_PENDING_DOWNLOAD = 1;
|
||||||
@@ -892,7 +890,6 @@ class DeviceListUpdateSerialiser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function _updateStoredDeviceKeysForUser(
|
async function _updateStoredDeviceKeysForUser(
|
||||||
_olmDevice, userId, userStore, userResult, localUserId, localDeviceId,
|
_olmDevice, userId, userStore, userResult, localUserId, localDeviceId,
|
||||||
) {
|
) {
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { logger } from "../logger";
|
import { logger } from "../logger";
|
||||||
import {MatrixEvent} from "../models/event";
|
import { MatrixEvent } from "../models/event";
|
||||||
import {EventEmitter} from "events";
|
import { EventEmitter } from "events";
|
||||||
import {createCryptoStoreCacheCallbacks} from "./CrossSigning";
|
import { createCryptoStoreCacheCallbacks } from "./CrossSigning";
|
||||||
import {IndexedDBCryptoStore} from './store/indexeddb-crypto-store';
|
import { IndexedDBCryptoStore } from './store/indexeddb-crypto-store';
|
||||||
import {
|
import {
|
||||||
PREFIX_UNSTABLE,
|
PREFIX_UNSTABLE,
|
||||||
} from "../http-api";
|
} from "../http-api";
|
||||||
@@ -43,7 +43,7 @@ export class EncryptionSetupBuilder {
|
|||||||
* @param {Object} keys the new keys
|
* @param {Object} keys the new keys
|
||||||
*/
|
*/
|
||||||
addCrossSigningKeys(authUpload, keys) {
|
addCrossSigningKeys(authUpload, keys) {
|
||||||
this._crossSigningKeys = {authUpload, keys};
|
this._crossSigningKeys = { authUpload, keys };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +86,6 @@ export class EncryptionSetupBuilder {
|
|||||||
userSignatures[deviceId] = signature;
|
userSignatures[deviceId] = signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} type
|
* @param {String} type
|
||||||
* @param {Object} content
|
* @param {Object} content
|
||||||
@@ -211,21 +210,20 @@ export class EncryptionSetupOperation {
|
|||||||
algorithm: this._keyBackupInfo.algorithm,
|
algorithm: this._keyBackupInfo.algorithm,
|
||||||
auth_data: this._keyBackupInfo.auth_data,
|
auth_data: this._keyBackupInfo.auth_data,
|
||||||
},
|
},
|
||||||
{prefix: PREFIX_UNSTABLE},
|
{ prefix: PREFIX_UNSTABLE },
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// add new key backup
|
// add new key backup
|
||||||
await baseApis._http.authedRequest(
|
await baseApis._http.authedRequest(
|
||||||
undefined, "POST", "/room_keys/version",
|
undefined, "POST", "/room_keys/version",
|
||||||
undefined, this._keyBackupInfo,
|
undefined, this._keyBackupInfo,
|
||||||
{prefix: PREFIX_UNSTABLE},
|
{ prefix: PREFIX_UNSTABLE },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Catches account data set by SecretStorage during bootstrapping by
|
* Catches account data set by SecretStorage during bootstrapping by
|
||||||
* implementing the methods related to account data in MatrixClient
|
* implementing the methods related to account data in MatrixClient
|
||||||
@@ -276,7 +274,7 @@ class AccountDataClientAdapter extends EventEmitter {
|
|||||||
// as SecretStorage listens for it while calling this method
|
// as SecretStorage listens for it while calling this method
|
||||||
// and it seems to rely on this.
|
// and it seems to rely on this.
|
||||||
return Promise.resolve().then(() => {
|
return Promise.resolve().then(() => {
|
||||||
const event = new MatrixEvent({type, content});
|
const event = new MatrixEvent({ type, content });
|
||||||
this.emit("accountData", event, lastEvent);
|
this.emit("accountData", event, lastEvent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -335,7 +333,7 @@ class SSSSCryptoCallbacks {
|
|||||||
// for it to the general crypto callbacks and cache it
|
// for it to the general crypto callbacks and cache it
|
||||||
if (this._delegateCryptoCallbacks) {
|
if (this._delegateCryptoCallbacks) {
|
||||||
const result = await this._delegateCryptoCallbacks.
|
const result = await this._delegateCryptoCallbacks.
|
||||||
getSecretStorageKey({keys}, name);
|
getSecretStorageKey({ keys }, name);
|
||||||
if (result) {
|
if (result) {
|
||||||
const [keyId, privateKey] = result;
|
const [keyId, privateKey] = result;
|
||||||
this._privateKeys.set(keyId, privateKey);
|
this._privateKeys.set(keyId, privateKey);
|
||||||
|
@@ -16,8 +16,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
import {IndexedDBCryptoStore} from './store/indexeddb-crypto-store';
|
import { IndexedDBCryptoStore } from './store/indexeddb-crypto-store';
|
||||||
import * as algorithms from './algorithms';
|
import * as algorithms from './algorithms';
|
||||||
|
|
||||||
// The maximum size of an event is 65K, and we base64 the content, so this is a
|
// The maximum size of an event is 65K, and we base64 the content, so this is a
|
||||||
@@ -48,7 +48,6 @@ function checkPayloadLength(payloadString) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of object we use for importing and exporting megolm session data.
|
* 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
|
* @property {String} session_key Base64'ed key data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages the olm cryptography functions. Each OlmDevice has a single
|
* Manages the olm cryptography functions. Each OlmDevice has a single
|
||||||
* OlmAccount and a number of OlmSessions.
|
* OlmAccount and a number of OlmSessions.
|
||||||
@@ -350,7 +348,7 @@ OlmDevice.prototype._unpickleSession = function(sessionInfo, func) {
|
|||||||
const session = new global.Olm.Session();
|
const session = new global.Olm.Session();
|
||||||
try {
|
try {
|
||||||
session.unpickle(this._pickleKey, sessionInfo.session);
|
session.unpickle(this._pickleKey, sessionInfo.session);
|
||||||
const unpickledSessInfo = Object.assign({}, sessionInfo, {session});
|
const unpickledSessInfo = Object.assign({}, sessionInfo, { session });
|
||||||
|
|
||||||
func(unpickledSessInfo);
|
func(unpickledSessInfo);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -376,7 +374,6 @@ OlmDevice.prototype._saveSession = function(deviceKey, sessionInfo, txn) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get an OlmUtility and call the given function
|
* 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.
|
* Signs a message with the ed25519 key for this account.
|
||||||
*
|
*
|
||||||
@@ -434,7 +430,6 @@ OlmDevice.prototype.getOneTimeKeys = async function() {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum number of one-time keys we can store.
|
* Get the maximum number of one-time keys we can store.
|
||||||
*
|
*
|
||||||
@@ -550,7 +545,6 @@ OlmDevice.prototype.createOutboundSession = async function(
|
|||||||
return newSessionId;
|
return newSessionId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a new inbound session, given an incoming message
|
* Generate a new inbound session, given an incoming message
|
||||||
*
|
*
|
||||||
@@ -612,7 +606,6 @@ OlmDevice.prototype.createInboundSession = async function(
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of known session IDs for the given device
|
* 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);
|
return await this._cryptoStore.filterOutNotifiedErrorDevices(devices);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Outbound group session
|
// Outbound group session
|
||||||
// ======================
|
// ======================
|
||||||
|
|
||||||
@@ -871,7 +863,6 @@ OlmDevice.prototype._saveOutboundGroupSession = function(session) {
|
|||||||
this._outboundGroupSessionStore[session.session_id()] = pickledSession;
|
this._outboundGroupSessionStore[session.session_id()] = pickledSession;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extract an OutboundGroupSession from _outboundGroupSessionStore and call the
|
* extract an OutboundGroupSession from _outboundGroupSessionStore and call the
|
||||||
* given function
|
* given function
|
||||||
@@ -896,7 +887,6 @@ OlmDevice.prototype._getOutboundGroupSession = function(sessionId, func) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a new outbound group session
|
* Generate a new outbound group session
|
||||||
*
|
*
|
||||||
@@ -913,7 +903,6 @@ OlmDevice.prototype.createOutboundGroupSession = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt an outgoing message with an outbound group session
|
* Encrypt an outgoing message with an outbound group session
|
||||||
*
|
*
|
||||||
@@ -953,7 +942,6 @@ OlmDevice.prototype.getOutboundGroupSessionKey = function(sessionId) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Inbound group session
|
// Inbound group session
|
||||||
// =====================
|
// =====================
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ limitations under the License.
|
|||||||
* Manages the list of encrypted rooms
|
* Manages the list of encrypted rooms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {IndexedDBCryptoStore} from './store/indexeddb-crypto-store';
|
import { IndexedDBCryptoStore } from './store/indexeddb-crypto-store';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @alias module:crypto/RoomList
|
* @alias module:crypto/RoomList
|
||||||
|
@@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EventEmitter} from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
import * as olmlib from './olmlib';
|
import * as olmlib from './olmlib';
|
||||||
import {randomString} from '../randomstring';
|
import { randomString } from '../randomstring';
|
||||||
import {encryptAES, decryptAES} from './aes';
|
import { encryptAES, decryptAES } from './aes';
|
||||||
import {encodeBase64} from "./olmlib";
|
import { encodeBase64 } from "./olmlib";
|
||||||
|
|
||||||
export const SECRET_STORAGE_ALGORITHM_V1_AES
|
export const SECRET_STORAGE_ALGORITHM_V1_AES
|
||||||
= "m.secret_storage.v1.aes-hmac-sha2";
|
= "m.secret_storage.v1.aes-hmac-sha2";
|
||||||
@@ -86,7 +86,7 @@ export class SecretStorage extends EventEmitter {
|
|||||||
* keyInfo: {object} details about the key (iv, mac, passphrase)
|
* keyInfo: {object} details about the key (iv, mac, passphrase)
|
||||||
*/
|
*/
|
||||||
async addKey(algorithm, opts, keyId) {
|
async addKey(algorithm, opts, keyId) {
|
||||||
const keyInfo = {algorithm};
|
const keyInfo = { algorithm };
|
||||||
|
|
||||||
if (!opts) opts = {};
|
if (!opts) opts = {};
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ export class SecretStorage extends EventEmitter {
|
|||||||
keyInfo.passphrase = opts.passphrase;
|
keyInfo.passphrase = opts.passphrase;
|
||||||
}
|
}
|
||||||
if (opts.key) {
|
if (opts.key) {
|
||||||
const {iv, mac} = await SecretStorage._calculateKeyCheck(opts.key);
|
const { iv, mac } = await SecretStorage._calculateKeyCheck(opts.key);
|
||||||
keyInfo.iv = iv;
|
keyInfo.iv = iv;
|
||||||
keyInfo.mac = mac;
|
keyInfo.mac = mac;
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ export class SecretStorage extends EventEmitter {
|
|||||||
async checkKey(key, info) {
|
async checkKey(key, info) {
|
||||||
if (info.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {
|
if (info.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {
|
||||||
if (info.mac) {
|
if (info.mac) {
|
||||||
const {mac} = await SecretStorage._calculateKeyCheck(key, info.iv);
|
const { mac } = await SecretStorage._calculateKeyCheck(key, info.iv);
|
||||||
return info.mac.replace(/=+$/g, '') === mac.replace(/=+$/g, '');
|
return info.mac.replace(/=+$/g, '') === mac.replace(/=+$/g, '');
|
||||||
} else {
|
} else {
|
||||||
// if we have no information, we have to assume the key is right
|
// if we have no information, we have to assume the key is right
|
||||||
@@ -220,7 +220,7 @@ export class SecretStorage extends EventEmitter {
|
|||||||
|
|
||||||
// encrypt secret, based on the algorithm
|
// encrypt secret, based on the algorithm
|
||||||
if (keyInfo.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {
|
if (keyInfo.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {
|
||||||
const keys = {[keyId]: keyInfo};
|
const keys = { [keyId]: keyInfo };
|
||||||
const [, encryption] = await this._getSecretStorageKey(keys, name);
|
const [, encryption] = await this._getSecretStorageKey(keys, name);
|
||||||
encrypted[keyId] = await encryption.encrypt(secret);
|
encrypted[keyId] = await encryption.encrypt(secret);
|
||||||
} else {
|
} else {
|
||||||
@@ -231,7 +231,7 @@ export class SecretStorage extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save encrypted secret
|
// save encrypted secret
|
||||||
await this._baseApis.setAccountData(name, {encrypted});
|
await this._baseApis.setAccountData(name, { encrypted });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {getCrypto} from '../utils';
|
import { getCrypto } from '../utils';
|
||||||
import {decodeBase64, encodeBase64} from './olmlib';
|
import { decodeBase64, encodeBase64 } from './olmlib';
|
||||||
|
|
||||||
const subtleCrypto = (typeof window !== "undefined" && window.crypto) ?
|
const subtleCrypto = (typeof window !== "undefined" && window.crypto) ?
|
||||||
(window.crypto.subtle || window.crypto.webkitSubtle) : null;
|
(window.crypto.subtle || window.crypto.webkitSubtle) : null;
|
||||||
@@ -148,7 +148,7 @@ async function encryptBrowser(data, key, name, ivStr) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const hmac = await subtleCrypto.sign(
|
const hmac = await subtleCrypto.sign(
|
||||||
{name: 'HMAC'},
|
{ name: 'HMAC' },
|
||||||
hmacKey,
|
hmacKey,
|
||||||
ciphertext,
|
ciphertext,
|
||||||
);
|
);
|
||||||
@@ -176,7 +176,7 @@ async function decryptBrowser(data, key, name) {
|
|||||||
const ciphertext = decodeBase64(data.ciphertext);
|
const ciphertext = decodeBase64(data.ciphertext);
|
||||||
|
|
||||||
if (!await subtleCrypto.verify(
|
if (!await subtleCrypto.verify(
|
||||||
{name: "HMAC"},
|
{ name: "HMAC" },
|
||||||
hmacKey,
|
hmacKey,
|
||||||
decodeBase64(data.mac),
|
decodeBase64(data.mac),
|
||||||
ciphertext,
|
ciphertext,
|
||||||
@@ -201,7 +201,7 @@ async function deriveKeysBrowser(key, name) {
|
|||||||
const hkdfkey = await subtleCrypto.importKey(
|
const hkdfkey = await subtleCrypto.importKey(
|
||||||
'raw',
|
'raw',
|
||||||
key,
|
key,
|
||||||
{name: "HKDF"},
|
{ name: "HKDF" },
|
||||||
false,
|
false,
|
||||||
["deriveBits"],
|
["deriveBits"],
|
||||||
);
|
);
|
||||||
@@ -222,7 +222,7 @@ async function deriveKeysBrowser(key, name) {
|
|||||||
const aesProm = subtleCrypto.importKey(
|
const aesProm = subtleCrypto.importKey(
|
||||||
'raw',
|
'raw',
|
||||||
aesKey,
|
aesKey,
|
||||||
{name: 'AES-CTR'},
|
{ name: 'AES-CTR' },
|
||||||
false,
|
false,
|
||||||
['encrypt', 'decrypt'],
|
['encrypt', 'decrypt'],
|
||||||
);
|
);
|
||||||
@@ -232,7 +232,7 @@ async function deriveKeysBrowser(key, name) {
|
|||||||
hmacKey,
|
hmacKey,
|
||||||
{
|
{
|
||||||
name: 'HMAC',
|
name: 'HMAC',
|
||||||
hash: {name: 'SHA-256'},
|
hash: { name: 'SHA-256' },
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
['sign', 'verify'],
|
['sign', 'verify'],
|
||||||
|
@@ -22,9 +22,9 @@ limitations under the License.
|
|||||||
* @module crypto/algorithms/megolm
|
* @module crypto/algorithms/megolm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import * as utils from "../../utils";
|
import * as utils from "../../utils";
|
||||||
import {polyfillSuper} from "../../utils";
|
import { polyfillSuper } from "../../utils";
|
||||||
import * as olmlib from "../olmlib";
|
import * as olmlib from "../olmlib";
|
||||||
import {
|
import {
|
||||||
DecryptionAlgorithm,
|
DecryptionAlgorithm,
|
||||||
@@ -34,7 +34,7 @@ import {
|
|||||||
UnknownDeviceError,
|
UnknownDeviceError,
|
||||||
} from "./base";
|
} from "./base";
|
||||||
|
|
||||||
import {WITHHELD_MESSAGES} from '../OlmDevice';
|
import { WITHHELD_MESSAGES } from '../OlmDevice';
|
||||||
|
|
||||||
// determine whether the key can be shared with invitees
|
// determine whether the key can be shared with invitees
|
||||||
function isRoomSharedHistory(room) {
|
function isRoomSharedHistory(room) {
|
||||||
@@ -75,7 +75,6 @@ function OutboundSessionInfo(sessionId, sharedHistory = false) {
|
|||||||
this.sharedHistory = sharedHistory;
|
this.sharedHistory = sharedHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if it's time to rotate the session
|
* Check if it's time to rotate the session
|
||||||
*
|
*
|
||||||
@@ -158,7 +157,6 @@ OutboundSessionInfo.prototype.sharedWithTooManyDevices = function(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Megolm encryption implementation
|
* Megolm encryption implementation
|
||||||
*
|
*
|
||||||
@@ -328,7 +326,7 @@ MegolmEncryption.prototype._ensureOutboundSession = async function(
|
|||||||
failedServerMap.add(server);
|
failedServerMap.add(server);
|
||||||
}
|
}
|
||||||
const failedDevices = [];
|
const failedDevices = [];
|
||||||
for (const {userId, deviceInfo} of errorDevices) {
|
for (const { userId, deviceInfo } of errorDevices) {
|
||||||
const userHS = userId.slice(userId.indexOf(":") + 1);
|
const userHS = userId.slice(userId.indexOf(":") + 1);
|
||||||
if (failedServerMap.has(userHS)) {
|
if (failedServerMap.has(userHS)) {
|
||||||
retryDevices[userId] = retryDevices[userId] || [];
|
retryDevices[userId] = retryDevices[userId] || [];
|
||||||
@@ -336,7 +334,7 @@ MegolmEncryption.prototype._ensureOutboundSession = async function(
|
|||||||
} else {
|
} else {
|
||||||
// if we aren't going to retry, then handle it
|
// if we aren't going to retry, then handle it
|
||||||
// as a failed device
|
// as a failed device
|
||||||
failedDevices.push({userId, deviceInfo});
|
failedDevices.push({ userId, deviceInfo });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,8 +408,8 @@ MegolmEncryption.prototype._prepareNewSession = async function(sharedHistory) {
|
|||||||
|
|
||||||
await this._olmDevice.addInboundGroupSession(
|
await this._olmDevice.addInboundGroupSession(
|
||||||
this._roomId, this._olmDevice.deviceCurve25519Key, [], sessionId,
|
this._roomId, this._olmDevice.deviceCurve25519Key, [], sessionId,
|
||||||
key.key, {ed25519: this._olmDevice.deviceEd25519Key}, false,
|
key.key, { ed25519: this._olmDevice.deviceEd25519Key }, false,
|
||||||
{sharedHistory: sharedHistory},
|
{ sharedHistory: sharedHistory },
|
||||||
);
|
);
|
||||||
|
|
||||||
// don't wait for it to complete
|
// don't wait for it to complete
|
||||||
@@ -454,7 +452,7 @@ MegolmEncryption.prototype._getDevicesWithoutSessions = function(
|
|||||||
// no session with this device, probably because there
|
// no session with this device, probably because there
|
||||||
// were no one-time keys.
|
// were no one-time keys.
|
||||||
|
|
||||||
noOlmDevices.push({userId, deviceInfo});
|
noOlmDevices.push({ userId, deviceInfo });
|
||||||
delete sessionResults[deviceId];
|
delete sessionResults[deviceId];
|
||||||
|
|
||||||
// ensureOlmSessionsForUsers has already done the logging,
|
// ensureOlmSessionsForUsers has already done the logging,
|
||||||
@@ -819,7 +817,7 @@ MegolmEncryption.prototype._notifyFailedOlmDevices = async function(
|
|||||||
|
|
||||||
// mark the devices that failed as "handled" because we don't want to try
|
// mark the devices that failed as "handled" because we don't want to try
|
||||||
// to claim a one-time-key for dead devices on every message.
|
// to claim a one-time-key for dead devices on every message.
|
||||||
for (const {userId, deviceInfo} of failedDevices) {
|
for (const { userId, deviceInfo } of failedDevices) {
|
||||||
const deviceId = deviceInfo.deviceId;
|
const deviceId = deviceInfo.deviceId;
|
||||||
|
|
||||||
session.markSharedWithDevice(
|
session.markSharedWithDevice(
|
||||||
@@ -836,7 +834,7 @@ MegolmEncryption.prototype._notifyFailedOlmDevices = async function(
|
|||||||
`in ${this._roomId}`,
|
`in ${this._roomId}`,
|
||||||
);
|
);
|
||||||
const blockedMap = {};
|
const blockedMap = {};
|
||||||
for (const {userId, deviceInfo} of filteredFailedDevices) {
|
for (const { userId, deviceInfo } of filteredFailedDevices) {
|
||||||
blockedMap[userId] = blockedMap[userId] || {};
|
blockedMap[userId] = blockedMap[userId] || {};
|
||||||
// we use a similar format to what
|
// we use a similar format to what
|
||||||
// olmlib.ensureOlmSessionsForDevices returns, so that
|
// olmlib.ensureOlmSessionsForDevices returns, so that
|
||||||
@@ -1341,7 +1339,6 @@ MegolmDecryption.prototype._removeEventFromPendingList = function(event) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*
|
*
|
||||||
@@ -1489,7 +1486,7 @@ MegolmDecryption.prototype.onRoomKeyWithheldEvent = async function(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await olmlib.ensureOlmSessionsForDevices(
|
await olmlib.ensureOlmSessionsForDevices(
|
||||||
this._olmDevice, this._baseApis, {[sender]: [device]}, false,
|
this._olmDevice, this._baseApis, { [sender]: [device] }, false,
|
||||||
);
|
);
|
||||||
const encryptedContent = {
|
const encryptedContent = {
|
||||||
algorithm: olmlib.OLM_ALGORITHM,
|
algorithm: olmlib.OLM_ALGORITHM,
|
||||||
@@ -1503,7 +1500,7 @@ MegolmDecryption.prototype.onRoomKeyWithheldEvent = async function(event) {
|
|||||||
this._olmDevice,
|
this._olmDevice,
|
||||||
sender,
|
sender,
|
||||||
device,
|
device,
|
||||||
{type: "m.dummy"},
|
{ type: "m.dummy" },
|
||||||
);
|
);
|
||||||
|
|
||||||
await this._olmDevice.recordSessionProblem(senderKey, "no_olm", true);
|
await this._olmDevice.recordSessionProblem(senderKey, "no_olm", true);
|
||||||
|
@@ -20,11 +20,11 @@ limitations under the License.
|
|||||||
* @module crypto/algorithms/olm
|
* @module crypto/algorithms/olm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import * as utils from "../../utils";
|
import * as utils from "../../utils";
|
||||||
import {polyfillSuper} from "../../utils";
|
import { polyfillSuper } from "../../utils";
|
||||||
import * as olmlib from "../olmlib";
|
import * as olmlib from "../olmlib";
|
||||||
import {DeviceInfo} from "../deviceinfo";
|
import { DeviceInfo } from "../deviceinfo";
|
||||||
import {
|
import {
|
||||||
DecryptionAlgorithm,
|
DecryptionAlgorithm,
|
||||||
DecryptionError,
|
DecryptionError,
|
||||||
@@ -358,5 +358,4 @@ OlmDecryption.prototype._reallyDecryptMessage = async function(
|
|||||||
return res.payload;
|
return res.payload;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
registerAlgorithm(olmlib.OLM_ALGORITHM, OlmEncryption, OlmDecryption);
|
registerAlgorithm(olmlib.OLM_ALGORITHM, OlmEncryption, OlmDecryption);
|
||||||
|
@@ -14,11 +14,11 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {decodeBase64, encodeBase64} from './olmlib';
|
import { decodeBase64, encodeBase64 } from './olmlib';
|
||||||
import {IndexedDBCryptoStore} from '../crypto/store/indexeddb-crypto-store';
|
import { IndexedDBCryptoStore } from '../crypto/store/indexeddb-crypto-store';
|
||||||
import {decryptAES, encryptAES} from './aes';
|
import { decryptAES, encryptAES } from './aes';
|
||||||
import anotherjson from "another-json";
|
import anotherjson from "another-json";
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
|
|
||||||
// FIXME: these types should eventually go in a different file
|
// FIXME: these types should eventually go in a different file
|
||||||
type Signatures = Record<string, Record<string, string>>;
|
type Signatures = Record<string, Record<string, string>>;
|
||||||
@@ -59,7 +59,7 @@ export class DehydrationManager {
|
|||||||
txn,
|
txn,
|
||||||
async (result) => {
|
async (result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
const {key, keyInfo, deviceDisplayName, time} = result;
|
const { key, keyInfo, deviceDisplayName, time } = result;
|
||||||
const pickleKey = Buffer.from(this.crypto._olmDevice._pickleKey);
|
const pickleKey = Buffer.from(this.crypto._olmDevice._pickleKey);
|
||||||
const decrypted = await decryptAES(key, pickleKey, DEHYDRATION_ALGORITHM);
|
const decrypted = await decryptAES(key, pickleKey, DEHYDRATION_ALGORITHM);
|
||||||
this.key = decodeBase64(decrypted);
|
this.key = decodeBase64(decrypted);
|
||||||
@@ -231,7 +231,7 @@ export class DehydrationManager {
|
|||||||
logger.log("Preparing one-time keys");
|
logger.log("Preparing one-time keys");
|
||||||
const oneTimeKeys = {};
|
const oneTimeKeys = {};
|
||||||
for (const [keyId, key] of Object.entries(otks.curve25519)) {
|
for (const [keyId, key] of Object.entries(otks.curve25519)) {
|
||||||
const k: OneTimeKey = {key};
|
const k: OneTimeKey = { key };
|
||||||
const signature = account.sign(anotherjson.stringify(k));
|
const signature = account.sign(anotherjson.stringify(k));
|
||||||
k.signatures = {
|
k.signatures = {
|
||||||
[this.crypto._userId]: {
|
[this.crypto._userId]: {
|
||||||
@@ -244,7 +244,7 @@ export class DehydrationManager {
|
|||||||
logger.log("Preparing fallback keys");
|
logger.log("Preparing fallback keys");
|
||||||
const fallbackKeys = {};
|
const fallbackKeys = {};
|
||||||
for (const [keyId, key] of Object.entries(fallbacks.curve25519)) {
|
for (const [keyId, key] of Object.entries(fallbacks.curve25519)) {
|
||||||
const k: OneTimeKey = {key, fallback: true};
|
const k: OneTimeKey = { key, fallback: true };
|
||||||
const signature = account.sign(anotherjson.stringify(k));
|
const signature = account.sign(anotherjson.stringify(k));
|
||||||
k.signatures = {
|
k.signatures = {
|
||||||
[this.crypto._userId]: {
|
[this.crypto._userId]: {
|
||||||
|
@@ -22,15 +22,15 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import anotherjson from "another-json";
|
import anotherjson from "another-json";
|
||||||
import {EventEmitter} from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import {ReEmitter} from '../ReEmitter';
|
import { ReEmitter } from '../ReEmitter';
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
import * as utils from "../utils";
|
import * as utils from "../utils";
|
||||||
import {sleep} from "../utils";
|
import { sleep } from "../utils";
|
||||||
import {OlmDevice} from "./OlmDevice";
|
import { OlmDevice } from "./OlmDevice";
|
||||||
import * as olmlib from "./olmlib";
|
import * as olmlib from "./olmlib";
|
||||||
import {DeviceList} from "./DeviceList";
|
import { DeviceList } from "./DeviceList";
|
||||||
import {DeviceInfo} from "./deviceinfo";
|
import { DeviceInfo } from "./deviceinfo";
|
||||||
import * as algorithms from "./algorithms";
|
import * as algorithms from "./algorithms";
|
||||||
import {
|
import {
|
||||||
CrossSigningInfo,
|
CrossSigningInfo,
|
||||||
@@ -38,25 +38,25 @@ import {
|
|||||||
UserTrustLevel,
|
UserTrustLevel,
|
||||||
createCryptoStoreCacheCallbacks,
|
createCryptoStoreCacheCallbacks,
|
||||||
} from './CrossSigning';
|
} from './CrossSigning';
|
||||||
import {EncryptionSetupBuilder} from "./EncryptionSetup";
|
import { EncryptionSetupBuilder } from "./EncryptionSetup";
|
||||||
import {SECRET_STORAGE_ALGORITHM_V1_AES, SecretStorage} from './SecretStorage';
|
import { SECRET_STORAGE_ALGORITHM_V1_AES, SecretStorage } from './SecretStorage';
|
||||||
import {OutgoingRoomKeyRequestManager} from './OutgoingRoomKeyRequestManager';
|
import { OutgoingRoomKeyRequestManager } from './OutgoingRoomKeyRequestManager';
|
||||||
import {IndexedDBCryptoStore} from './store/indexeddb-crypto-store';
|
import { IndexedDBCryptoStore } from './store/indexeddb-crypto-store';
|
||||||
import {
|
import {
|
||||||
ReciprocateQRCode,
|
ReciprocateQRCode,
|
||||||
SCAN_QR_CODE_METHOD,
|
SCAN_QR_CODE_METHOD,
|
||||||
SHOW_QR_CODE_METHOD,
|
SHOW_QR_CODE_METHOD,
|
||||||
} from './verification/QRCode';
|
} from './verification/QRCode';
|
||||||
import {SAS} from './verification/SAS';
|
import { SAS } from './verification/SAS';
|
||||||
import {keyFromPassphrase} from './key_passphrase';
|
import { keyFromPassphrase } from './key_passphrase';
|
||||||
import {encodeRecoveryKey, decodeRecoveryKey} from './recoverykey';
|
import { encodeRecoveryKey, decodeRecoveryKey } from './recoverykey';
|
||||||
import {VerificationRequest} from "./verification/request/VerificationRequest";
|
import { VerificationRequest } from "./verification/request/VerificationRequest";
|
||||||
import {InRoomChannel, InRoomRequests} from "./verification/request/InRoomChannel";
|
import { InRoomChannel, InRoomRequests } from "./verification/request/InRoomChannel";
|
||||||
import {ToDeviceChannel, ToDeviceRequests} from "./verification/request/ToDeviceChannel";
|
import { ToDeviceChannel, ToDeviceRequests } from "./verification/request/ToDeviceChannel";
|
||||||
import {IllegalMethod} from "./verification/IllegalMethod";
|
import { IllegalMethod } from "./verification/IllegalMethod";
|
||||||
import {KeySignatureUploadError} from "../errors";
|
import { KeySignatureUploadError } from "../errors";
|
||||||
import {decryptAES, encryptAES} from './aes';
|
import { decryptAES, encryptAES } from './aes';
|
||||||
import {DehydrationManager} from './dehydration';
|
import { DehydrationManager } from './dehydration';
|
||||||
import { MatrixEvent } from "../models/event";
|
import { MatrixEvent } from "../models/event";
|
||||||
|
|
||||||
const DeviceVerification = DeviceInfo.DeviceVerification;
|
const DeviceVerification = DeviceInfo.DeviceVerification;
|
||||||
@@ -682,12 +682,12 @@ Crypto.prototype.bootstrapSecretStorage = async function({
|
|||||||
const ensureCanCheckPassphrase = async (keyId, keyInfo) => {
|
const ensureCanCheckPassphrase = async (keyId, keyInfo) => {
|
||||||
if (!keyInfo.mac) {
|
if (!keyInfo.mac) {
|
||||||
const key = await this._baseApis._cryptoCallbacks.getSecretStorageKey(
|
const key = await this._baseApis._cryptoCallbacks.getSecretStorageKey(
|
||||||
{keys: {[keyId]: keyInfo}}, "",
|
{ keys: { [keyId]: keyInfo } }, "",
|
||||||
);
|
);
|
||||||
if (key) {
|
if (key) {
|
||||||
const privateKey = key[1];
|
const privateKey = key[1];
|
||||||
builder.ssssCryptoCallbacks.addPrivateKey(keyId, keyInfo, privateKey);
|
builder.ssssCryptoCallbacks.addPrivateKey(keyId, keyInfo, privateKey);
|
||||||
const {iv, mac} = await SecretStorage._calculateKeyCheck(privateKey);
|
const { iv, mac } = await SecretStorage._calculateKeyCheck(privateKey);
|
||||||
keyInfo.iv = iv;
|
keyInfo.iv = iv;
|
||||||
keyInfo.mac = mac;
|
keyInfo.mac = mac;
|
||||||
|
|
||||||
@@ -1599,7 +1599,7 @@ Crypto.prototype._checkAndStartKeyBackup = async function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {backupInfo, trustInfo};
|
return { backupInfo, trustInfo };
|
||||||
};
|
};
|
||||||
|
|
||||||
Crypto.prototype.setTrustedBackupPubKey = async function(trustedPubKey) {
|
Crypto.prototype.setTrustedBackupPubKey = async function(trustedPubKey) {
|
||||||
@@ -1774,7 +1774,6 @@ Crypto.prototype.registerEventHandlers = function(eventEmitter) {
|
|||||||
eventEmitter.on("Event.decrypted", timelineHandler);
|
eventEmitter.on("Event.decrypted", timelineHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Start background processes related to crypto */
|
/** Start background processes related to crypto */
|
||||||
Crypto.prototype.start = function() {
|
Crypto.prototype.start = function() {
|
||||||
this._outgoingRoomKeyRequestManager.start();
|
this._outgoingRoomKeyRequestManager.start();
|
||||||
@@ -2231,7 +2230,7 @@ Crypto.prototype.setDeviceVerification = async function(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (device) {
|
if (device) {
|
||||||
const upload = async ({shouldEmit}) => {
|
const upload = async ({ shouldEmit }) => {
|
||||||
logger.info("Uploading signature for " + deviceId);
|
logger.info("Uploading signature for " + deviceId);
|
||||||
const response = await this._baseApis.uploadKeySignatures({
|
const response = await this._baseApis.uploadKeySignatures({
|
||||||
[userId]: {
|
[userId]: {
|
||||||
@@ -2251,7 +2250,7 @@ Crypto.prototype.setDeviceVerification = async function(
|
|||||||
throw new KeySignatureUploadError("Key upload failed", { failures });
|
throw new KeySignatureUploadError("Key upload failed", { failures });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await upload({shouldEmit: true});
|
await upload({ shouldEmit: true });
|
||||||
// XXX: we'll need to wait for the device list to be updated
|
// XXX: we'll need to wait for the device list to be updated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2344,7 +2343,7 @@ Crypto.prototype.beginKeyVerification = function(
|
|||||||
this._toDeviceVerificationRequests.setRequestBySenderAndTxnId(
|
this._toDeviceVerificationRequests.setRequestBySenderAndTxnId(
|
||||||
userId, transactionId, request);
|
userId, transactionId, request);
|
||||||
}
|
}
|
||||||
return request.beginKeyVerification(method, {userId, deviceId});
|
return request.beginKeyVerification(method, { userId, deviceId });
|
||||||
};
|
};
|
||||||
|
|
||||||
Crypto.prototype.legacyDeviceVerification = async function(
|
Crypto.prototype.legacyDeviceVerification = async function(
|
||||||
@@ -2357,7 +2356,7 @@ Crypto.prototype.legacyDeviceVerification = async function(
|
|||||||
channel, this._verificationMethods, this._baseApis);
|
channel, this._verificationMethods, this._baseApis);
|
||||||
this._toDeviceVerificationRequests.setRequestBySenderAndTxnId(
|
this._toDeviceVerificationRequests.setRequestBySenderAndTxnId(
|
||||||
userId, transactionId, request);
|
userId, transactionId, request);
|
||||||
const verifier = request.beginKeyVerification(method, {userId, deviceId});
|
const verifier = request.beginKeyVerification(method, { userId, deviceId });
|
||||||
// either reject by an error from verify() while sending .start
|
// either reject by an error from verify() while sending .start
|
||||||
// or resolve when the request receives the
|
// or resolve when the request receives the
|
||||||
// local (fake remote) echo for sending the .start event
|
// local (fake remote) echo for sending the .start event
|
||||||
@@ -2368,7 +2367,6 @@ Crypto.prototype.legacyDeviceVerification = async function(
|
|||||||
return request;
|
return request;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information on the active olm sessions with a user
|
* Get information on the active olm sessions with a user
|
||||||
* <p>
|
* <p>
|
||||||
@@ -2399,7 +2397,6 @@ Crypto.prototype.getOlmSessionsForUser = async function(userId) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the device which sent an event
|
* 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.
|
* Make sure we are tracking the device lists for all users in this room.
|
||||||
*
|
*
|
||||||
@@ -2867,7 +2863,7 @@ Crypto.prototype._backupPendingKeys = async function(limit) {
|
|||||||
for (const session of sessions) {
|
for (const session of sessions) {
|
||||||
const roomId = session.sessionData.room_id;
|
const roomId = session.sessionData.room_id;
|
||||||
if (data[roomId] === undefined) {
|
if (data[roomId] === undefined) {
|
||||||
data[roomId] = {sessions: {}};
|
data[roomId] = { sessions: {} };
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionData = await this._olmDevice.exportInboundGroupSession(
|
const sessionData = await this._olmDevice.exportInboundGroupSession(
|
||||||
@@ -2901,7 +2897,7 @@ Crypto.prototype._backupPendingKeys = async function(limit) {
|
|||||||
|
|
||||||
await this._baseApis.sendKeyBackup(
|
await this._baseApis.sendKeyBackup(
|
||||||
undefined, undefined, this.backupInfo.version,
|
undefined, undefined, this.backupInfo.version,
|
||||||
{rooms: data},
|
{ rooms: data },
|
||||||
);
|
);
|
||||||
|
|
||||||
await this._cryptoStore.unmarkSessionsNeedingBackup(sessions);
|
await this._cryptoStore.unmarkSessionsNeedingBackup(sessions);
|
||||||
@@ -3301,7 +3297,6 @@ Crypto.prototype._getTrackedE2eRooms = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Crypto.prototype._onToDeviceEvent = function(event) {
|
Crypto.prototype._onToDeviceEvent = function(event) {
|
||||||
try {
|
try {
|
||||||
logger.log(`received to_device ${event.getType()} from: ` +
|
logger.log(`received to_device ${event.getType()} from: ` +
|
||||||
@@ -3442,7 +3437,7 @@ Crypto.prototype._onKeyVerificationMessage = function(event) {
|
|||||||
* @param {bool} data.liveEvent whether this is a live event
|
* @param {bool} data.liveEvent whether this is a live event
|
||||||
*/
|
*/
|
||||||
Crypto.prototype._onTimelineEvent = function(
|
Crypto.prototype._onTimelineEvent = function(
|
||||||
event, room, atStart, removed, {liveEvent} = {},
|
event, room, atStart, removed, { liveEvent } = {},
|
||||||
) {
|
) {
|
||||||
if (!InRoomChannel.validateEvent(event, this._baseApis)) {
|
if (!InRoomChannel.validateEvent(event, this._baseApis)) {
|
||||||
return;
|
return;
|
||||||
@@ -3580,7 +3575,7 @@ Crypto.prototype._onToDeviceBadEncrypted = async function(event) {
|
|||||||
this._olmDevice,
|
this._olmDevice,
|
||||||
sender,
|
sender,
|
||||||
device,
|
device,
|
||||||
{type: "m.dummy"},
|
{ type: "m.dummy" },
|
||||||
);
|
);
|
||||||
|
|
||||||
await this._olmDevice.recordSessionProblem(deviceKey, "wedged", true);
|
await this._olmDevice.recordSessionProblem(deviceKey, "wedged", true);
|
||||||
@@ -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
|
// 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
|
// 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
|
// 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);
|
alg.onRoomMembership(event, member, oldMembership);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when we get an m.room_key_request event.
|
* 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);
|
this.emit("crypto.roomKeyRequest", req);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for processReceivedRoomKeyRequests
|
* Helper for processReceivedRoomKeyRequests
|
||||||
*
|
*
|
||||||
@@ -3878,7 +3870,6 @@ Crypto.prototype._getRoomDecryptor = function(roomId, algorithm) {
|
|||||||
return alg;
|
return alg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the room decryptors for a given encryption algorithm.
|
* Get all the room decryptors for a given encryption algorithm.
|
||||||
*
|
*
|
||||||
@@ -3896,7 +3887,6 @@ Crypto.prototype._getRoomDecryptors = function(algorithm) {
|
|||||||
return decryptors;
|
return decryptors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sign the given object with our ed25519 key
|
* sign the given object with our ed25519 key
|
||||||
*
|
*
|
||||||
@@ -3916,7 +3906,6 @@ Crypto.prototype._signObject = async function(obj) {
|
|||||||
if (unsigned !== undefined) obj.unsigned = unsigned;
|
if (unsigned !== undefined) obj.unsigned = unsigned;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parameters of a room key request. The details of the request may
|
* 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
|
* vary with the crypto algorithm, but the management and storage layers for
|
||||||
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {randomString} from '../randomstring';
|
import { randomString } from '../randomstring';
|
||||||
|
|
||||||
const DEFAULT_ITERATIONS = 500000;
|
const DEFAULT_ITERATIONS = 500000;
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ export async function deriveKey(password, salt, iterations, numBits = DEFAULT_BI
|
|||||||
const key = await subtleCrypto.importKey(
|
const key = await subtleCrypto.importKey(
|
||||||
'raw',
|
'raw',
|
||||||
new TextEncoder().encode(password),
|
new TextEncoder().encode(password),
|
||||||
{name: 'PBKDF2'},
|
{ name: 'PBKDF2' },
|
||||||
false,
|
false,
|
||||||
['deriveBits'],
|
['deriveBits'],
|
||||||
);
|
);
|
||||||
|
@@ -22,7 +22,7 @@ limitations under the License.
|
|||||||
* Utilities common to olm encryption algorithms
|
* Utilities common to olm encryption algorithms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
import * as utils from "../utils";
|
import * as utils from "../utils";
|
||||||
import anotherjson from "another-json";
|
import anotherjson from "another-json";
|
||||||
|
|
||||||
@@ -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";
|
export const MEGOLM_BACKUP_ALGORITHM = "m.megolm_backup.v1.curve25519-aes-sha2";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt an event payload for an Olm device
|
* Encrypt an event payload for an Olm device
|
||||||
*
|
*
|
||||||
@@ -408,7 +407,6 @@ async function _verifyKeyAndStartSession(olmDevice, oneTimeKey, userId, deviceIn
|
|||||||
return sid;
|
return sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify the signature on an object
|
* Verify the signature on an object
|
||||||
*
|
*
|
||||||
|
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import * as utils from "../../utils";
|
import * as utils from "../../utils";
|
||||||
|
|
||||||
export const VERSION = 10;
|
export const VERSION = 10;
|
||||||
@@ -230,7 +230,7 @@ export class Backend {
|
|||||||
const cursor = ev.target.result;
|
const cursor = ev.target.result;
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
const keyReq = cursor.value;
|
const keyReq = cursor.value;
|
||||||
if (keyReq.recipients.includes({userId, deviceId})) {
|
if (keyReq.recipients.includes({ userId, deviceId })) {
|
||||||
results.push(keyReq);
|
results.push(keyReq);
|
||||||
}
|
}
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
@@ -496,7 +496,7 @@ export class Backend {
|
|||||||
const lastProblem = problems[problems.length - 1];
|
const lastProblem = problems[problems.length - 1];
|
||||||
for (const problem of problems) {
|
for (const problem of problems) {
|
||||||
if (problem.time > timestamp) {
|
if (problem.time > timestamp) {
|
||||||
result = Object.assign({}, problem, {fixed: lastProblem.fixed});
|
result = Object.assign({}, problem, { fixed: lastProblem.fixed });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,11 +519,11 @@ export class Backend {
|
|||||||
|
|
||||||
await Promise.all(devices.map((device) => {
|
await Promise.all(devices.map((device) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const {userId, deviceInfo} = device;
|
const { userId, deviceInfo } = device;
|
||||||
const getReq = objectStore.get([userId, deviceInfo.deviceId]);
|
const getReq = objectStore.get([userId, deviceInfo.deviceId]);
|
||||||
getReq.onsuccess = function() {
|
getReq.onsuccess = function() {
|
||||||
if (!getReq.result) {
|
if (!getReq.result) {
|
||||||
objectStore.put({userId, deviceId: deviceInfo.deviceId});
|
objectStore.put({ userId, deviceId: deviceInfo.deviceId });
|
||||||
ret.push(device);
|
ret.push(device);
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
@@ -768,9 +768,9 @@ export class Backend {
|
|||||||
const objectStore = txn.objectStore("shared_history_inbound_group_sessions");
|
const objectStore = txn.objectStore("shared_history_inbound_group_sessions");
|
||||||
const req = objectStore.get([roomId]);
|
const req = objectStore.get([roomId]);
|
||||||
req.onsuccess = () => {
|
req.onsuccess = () => {
|
||||||
const {sessions} = req.result || {sessions: []};
|
const { sessions } = req.result || { sessions: [] };
|
||||||
sessions.push([senderKey, sessionId]);
|
sessions.push([senderKey, sessionId]);
|
||||||
objectStore.put({roomId, sessions});
|
objectStore.put({ roomId, sessions });
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,7 +784,7 @@ export class Backend {
|
|||||||
const req = objectStore.get([roomId]);
|
const req = objectStore.get([roomId]);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
req.onsuccess = () => {
|
req.onsuccess = () => {
|
||||||
const {sessions} = req.result || {sessions: []};
|
const { sessions } = req.result || { sessions: [] };
|
||||||
resolve(sessions);
|
resolve(sessions);
|
||||||
};
|
};
|
||||||
req.onerror = reject;
|
req.onerror = reject;
|
||||||
|
@@ -16,11 +16,11 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import {LocalStorageCryptoStore} from './localStorage-crypto-store';
|
import { LocalStorageCryptoStore } from './localStorage-crypto-store';
|
||||||
import {MemoryCryptoStore} from './memory-crypto-store';
|
import { MemoryCryptoStore } from './memory-crypto-store';
|
||||||
import * as IndexedDBCryptoStoreBackend from './indexeddb-crypto-store-backend';
|
import * as IndexedDBCryptoStoreBackend from './indexeddb-crypto-store-backend';
|
||||||
import {InvalidCryptoStoreError} from '../../errors';
|
import { InvalidCryptoStoreError } from '../../errors';
|
||||||
import * as IndexedDBHelpers from "../../indexeddb-helpers";
|
import * as IndexedDBHelpers from "../../indexeddb-helpers";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -15,8 +15,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import {MemoryCryptoStore} from './memory-crypto-store';
|
import { MemoryCryptoStore } from './memory-crypto-store';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal module. Partial localStorage backed storage for e2e.
|
* Internal module. Partial localStorage backed storage for e2e.
|
||||||
@@ -136,7 +136,7 @@ export class LocalStorageCryptoStore extends MemoryCryptoStore {
|
|||||||
async storeEndToEndSessionProblem(deviceKey, type, fixed) {
|
async storeEndToEndSessionProblem(deviceKey, type, fixed) {
|
||||||
const key = keyEndToEndSessionProblems(deviceKey);
|
const key = keyEndToEndSessionProblems(deviceKey);
|
||||||
const problems = getJsonItem(this.store, key) || [];
|
const problems = getJsonItem(this.store, key) || [];
|
||||||
problems.push({type, fixed, time: Date.now()});
|
problems.push({ type, fixed, time: Date.now() });
|
||||||
problems.sort((a, b) => {
|
problems.sort((a, b) => {
|
||||||
return a.time - b.time;
|
return a.time - b.time;
|
||||||
});
|
});
|
||||||
@@ -152,7 +152,7 @@ export class LocalStorageCryptoStore extends MemoryCryptoStore {
|
|||||||
const lastProblem = problems[problems.length - 1];
|
const lastProblem = problems[problems.length - 1];
|
||||||
for (const problem of problems) {
|
for (const problem of problems) {
|
||||||
if (problem.time > timestamp) {
|
if (problem.time > timestamp) {
|
||||||
return Object.assign({}, problem, {fixed: lastProblem.fixed});
|
return Object.assign({}, problem, { fixed: lastProblem.fixed });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lastProblem.fixed) {
|
if (lastProblem.fixed) {
|
||||||
@@ -168,7 +168,7 @@ export class LocalStorageCryptoStore extends MemoryCryptoStore {
|
|||||||
const ret = [];
|
const ret = [];
|
||||||
|
|
||||||
for (const device of devices) {
|
for (const device of devices) {
|
||||||
const {userId, deviceInfo} = device;
|
const { userId, deviceInfo } = device;
|
||||||
if (userId in notifiedErrorDevices) {
|
if (userId in notifiedErrorDevices) {
|
||||||
if (!(deviceInfo.deviceId in notifiedErrorDevices[userId])) {
|
if (!(deviceInfo.deviceId in notifiedErrorDevices[userId])) {
|
||||||
ret.push(device);
|
ret.push(device);
|
||||||
@@ -176,7 +176,7 @@ export class LocalStorageCryptoStore extends MemoryCryptoStore {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret.push(device);
|
ret.push(device);
|
||||||
notifiedErrorDevices[userId] = {[deviceInfo.deviceId]: true };
|
notifiedErrorDevices[userId] = { [deviceInfo.deviceId]: true };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import * as utils from "../../utils";
|
import * as utils from "../../utils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -186,7 +186,7 @@ export class MemoryCryptoStore {
|
|||||||
|
|
||||||
for (const req of this._outgoingRoomKeyRequests) {
|
for (const req of this._outgoingRoomKeyRequests) {
|
||||||
for (const state of wantedStates) {
|
for (const state of wantedStates) {
|
||||||
if (req.state === state && req.recipients.includes({userId, deviceId})) {
|
if (req.state === state && req.recipients.includes({ userId, deviceId })) {
|
||||||
results.push(req);
|
results.push(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,7 +324,7 @@ export class MemoryCryptoStore {
|
|||||||
async storeEndToEndSessionProblem(deviceKey, type, fixed) {
|
async storeEndToEndSessionProblem(deviceKey, type, fixed) {
|
||||||
const problems = this._sessionProblems[deviceKey]
|
const problems = this._sessionProblems[deviceKey]
|
||||||
= this._sessionProblems[deviceKey] || [];
|
= this._sessionProblems[deviceKey] || [];
|
||||||
problems.push({type, fixed, time: Date.now()});
|
problems.push({ type, fixed, time: Date.now() });
|
||||||
problems.sort((a, b) => {
|
problems.sort((a, b) => {
|
||||||
return a.time - b.time;
|
return a.time - b.time;
|
||||||
});
|
});
|
||||||
@@ -338,7 +338,7 @@ export class MemoryCryptoStore {
|
|||||||
const lastProblem = problems[problems.length - 1];
|
const lastProblem = problems[problems.length - 1];
|
||||||
for (const problem of problems) {
|
for (const problem of problems) {
|
||||||
if (problem.time > timestamp) {
|
if (problem.time > timestamp) {
|
||||||
return Object.assign({}, problem, {fixed: lastProblem.fixed});
|
return Object.assign({}, problem, { fixed: lastProblem.fixed });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lastProblem.fixed) {
|
if (lastProblem.fixed) {
|
||||||
@@ -353,7 +353,7 @@ export class MemoryCryptoStore {
|
|||||||
const ret = [];
|
const ret = [];
|
||||||
|
|
||||||
for (const device of devices) {
|
for (const device of devices) {
|
||||||
const {userId, deviceInfo} = device;
|
const { userId, deviceInfo } = device;
|
||||||
if (userId in notifiedErrorDevices) {
|
if (userId in notifiedErrorDevices) {
|
||||||
if (!(deviceInfo.deviceId in notifiedErrorDevices[userId])) {
|
if (!(deviceInfo.deviceId in notifiedErrorDevices[userId])) {
|
||||||
ret.push(device);
|
ret.push(device);
|
||||||
@@ -361,7 +361,7 @@ export class MemoryCryptoStore {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret.push(device);
|
ret.push(device);
|
||||||
notifiedErrorDevices[userId] = {[deviceInfo.deviceId]: true };
|
notifiedErrorDevices[userId] = { [deviceInfo.deviceId]: true };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,12 +20,12 @@ limitations under the License.
|
|||||||
* @module crypto/verification/Base
|
* @module crypto/verification/Base
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {MatrixEvent} from '../../models/event';
|
import { MatrixEvent } from '../../models/event';
|
||||||
import {EventEmitter} from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import {logger} from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import {DeviceInfo} from '../deviceinfo';
|
import { DeviceInfo } from '../deviceinfo';
|
||||||
import {newTimeoutError} from "./Error";
|
import { newTimeoutError } from "./Error";
|
||||||
import {requestKeysDuringVerification} from "../CrossSigning";
|
import { requestKeysDuringVerification } from "../CrossSigning";
|
||||||
|
|
||||||
const timeoutException = new Error("Verification timed out");
|
const timeoutException = new Error("Verification timed out");
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ export class VerificationBase extends EventEmitter {
|
|||||||
switchStartEvent(event) {
|
switchStartEvent(event) {
|
||||||
if (this.canSwitchStartEvent(event)) {
|
if (this.canSwitchStartEvent(event)) {
|
||||||
logger.log("Verification Base: switching verification start event",
|
logger.log("Verification Base: switching verification start event",
|
||||||
{restartingFlow: !!this._rejectEvent});
|
{ restartingFlow: !!this._rejectEvent });
|
||||||
if (this._rejectEvent) {
|
if (this._rejectEvent) {
|
||||||
const reject = this._rejectEvent;
|
const reject = this._rejectEvent;
|
||||||
this._rejectEvent = undefined;
|
this._rejectEvent = undefined;
|
||||||
@@ -167,7 +167,7 @@ export class VerificationBase extends EventEmitter {
|
|||||||
// there is only promise to reject if verify has been called
|
// there is only promise to reject if verify has been called
|
||||||
if (reject) {
|
if (reject) {
|
||||||
const content = e.getContent();
|
const content = e.getContent();
|
||||||
const {reason, code} = content;
|
const { reason, code } = content;
|
||||||
reject(new Error(`Other side cancelled verification ` +
|
reject(new Error(`Other side cancelled verification ` +
|
||||||
`because ${reason} (${code})`));
|
`because ${reason} (${code})`));
|
||||||
}
|
}
|
||||||
|
@@ -20,10 +20,10 @@ limitations under the License.
|
|||||||
* @module crypto/verification/Error
|
* @module crypto/verification/Error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {MatrixEvent} from "../../models/event";
|
import { MatrixEvent } from "../../models/event";
|
||||||
|
|
||||||
export function newVerificationError(code, reason, extradata) {
|
export function newVerificationError(code, reason, extradata) {
|
||||||
const content = Object.assign({}, {code, reason}, extradata);
|
const content = Object.assign({}, { code, reason }, extradata);
|
||||||
return new MatrixEvent({
|
return new MatrixEvent({
|
||||||
type: "m.key.verification.cancel",
|
type: "m.key.verification.cancel",
|
||||||
content,
|
content,
|
||||||
@@ -87,9 +87,9 @@ export const newInvalidMessageError = errorFactory(
|
|||||||
export function errorFromEvent(event) {
|
export function errorFromEvent(event) {
|
||||||
const content = event.getContent();
|
const content = event.getContent();
|
||||||
if (content) {
|
if (content) {
|
||||||
const {code, reason} = content;
|
const { code, reason } = content;
|
||||||
return {code, reason};
|
return { code, reason };
|
||||||
} else {
|
} else {
|
||||||
return {code: "Unknown error", reason: "m.unknown"};
|
return { code: "Unknown error", reason: "m.unknown" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ limitations under the License.
|
|||||||
* @module crypto/verification/IllegalMethod
|
* @module crypto/verification/IllegalMethod
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {VerificationBase as Base} from "./Base";
|
import { VerificationBase as Base } from "./Base";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class crypto/verification/IllegalMethod/IllegalMethod
|
* @class crypto/verification/IllegalMethod/IllegalMethod
|
||||||
|
@@ -20,13 +20,13 @@ limitations under the License.
|
|||||||
* @module crypto/verification/QRCode
|
* @module crypto/verification/QRCode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {VerificationBase as Base} from "./Base";
|
import { VerificationBase as Base } from "./Base";
|
||||||
import {
|
import {
|
||||||
newKeyMismatchError,
|
newKeyMismatchError,
|
||||||
newUserCancelledError,
|
newUserCancelledError,
|
||||||
} from './Error';
|
} from './Error';
|
||||||
import {encodeUnpaddedBase64, decodeBase64} from "../olmlib";
|
import { encodeUnpaddedBase64, decodeBase64 } from "../olmlib";
|
||||||
import {logger} from '../../logger';
|
import { logger } from '../../logger';
|
||||||
|
|
||||||
export const SHOW_QR_CODE_METHOD = "m.qr_code.show.v1";
|
export const SHOW_QR_CODE_METHOD = "m.qr_code.show.v1";
|
||||||
export const SCAN_QR_CODE_METHOD = "m.qr_code.scan.v1";
|
export const SCAN_QR_CODE_METHOD = "m.qr_code.scan.v1";
|
||||||
@@ -51,7 +51,7 @@ export class ReciprocateQRCode extends Base {
|
|||||||
"with this method yet.");
|
"with this method yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const {qrCodeData} = this.request;
|
const { qrCodeData } = this.request;
|
||||||
// 1. check the secret
|
// 1. check the secret
|
||||||
if (this.startEvent.getContent()['secret'] !== qrCodeData.encodedSharedSecret) {
|
if (this.startEvent.getContent()['secret'] !== qrCodeData.encodedSharedSecret) {
|
||||||
throw newKeyMismatchError();
|
throw newKeyMismatchError();
|
||||||
|
@@ -19,7 +19,7 @@ limitations under the License.
|
|||||||
* @module crypto/verification/SAS
|
* @module crypto/verification/SAS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {VerificationBase as Base, SwitchStartEventError} from "./Base";
|
import { VerificationBase as Base, SwitchStartEventError } from "./Base";
|
||||||
import anotherjson from 'another-json';
|
import anotherjson from 'another-json';
|
||||||
import {
|
import {
|
||||||
errorFactory,
|
errorFactory,
|
||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
newUnknownMethodError,
|
newUnknownMethodError,
|
||||||
newUserCancelledError,
|
newUserCancelledError,
|
||||||
} from './Error';
|
} from './Error';
|
||||||
import {logger} from '../../logger';
|
import { logger } from '../../logger';
|
||||||
|
|
||||||
const START_TYPE = "m.key.verification.start";
|
const START_TYPE = "m.key.verification.start";
|
||||||
|
|
||||||
@@ -323,7 +323,6 @@ export class SAS extends Base {
|
|||||||
key: this.ourSASPubKey,
|
key: this.ourSASPubKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
e = await this._waitForEvent("m.key.verification.key");
|
e = await this._waitForEvent("m.key.verification.key");
|
||||||
// FIXME: make sure event is properly formed
|
// FIXME: make sure event is properly formed
|
||||||
content = e.getContent();
|
content = e.getContent();
|
||||||
@@ -353,7 +352,6 @@ export class SAS extends Base {
|
|||||||
this.emit("show_sas", this.sasEvent);
|
this.emit("show_sas", this.sasEvent);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
[e] = await Promise.all([
|
[e] = await Promise.all([
|
||||||
this._waitForEvent("m.key.verification.mac")
|
this._waitForEvent("m.key.verification.mac")
|
||||||
.then((e) => {
|
.then((e) => {
|
||||||
@@ -411,7 +409,6 @@ export class SAS extends Base {
|
|||||||
commitment: olmutil.sha256(commitmentStr),
|
commitment: olmutil.sha256(commitmentStr),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let e = await this._waitForEvent("m.key.verification.key");
|
let e = await this._waitForEvent("m.key.verification.key");
|
||||||
// FIXME: make sure event is properly formed
|
// FIXME: make sure event is properly formed
|
||||||
content = e.getContent();
|
content = e.getContent();
|
||||||
@@ -440,7 +437,6 @@ export class SAS extends Base {
|
|||||||
this.emit("show_sas", this.sasEvent);
|
this.emit("show_sas", this.sasEvent);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
[e] = await Promise.all([
|
[e] = await Promise.all([
|
||||||
this._waitForEvent("m.key.verification.mac")
|
this._waitForEvent("m.key.verification.mac")
|
||||||
.then((e) => {
|
.then((e) => {
|
||||||
|
@@ -21,7 +21,7 @@ import {
|
|||||||
READY_TYPE,
|
READY_TYPE,
|
||||||
START_TYPE,
|
START_TYPE,
|
||||||
} from "./VerificationRequest";
|
} from "./VerificationRequest";
|
||||||
import {logger} from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
|
|
||||||
const MESSAGE_TYPE = "m.room.message";
|
const MESSAGE_TYPE = "m.room.message";
|
||||||
const M_REFERENCE = "m.reference";
|
const M_REFERENCE = "m.reference";
|
||||||
@@ -157,7 +157,7 @@ export class InRoomChannel {
|
|||||||
if (type === MESSAGE_TYPE) {
|
if (type === MESSAGE_TYPE) {
|
||||||
const content = event.getContent();
|
const content = event.getContent();
|
||||||
if (content) {
|
if (content) {
|
||||||
const {msgtype} = content;
|
const { msgtype } = content;
|
||||||
if (msgtype === REQUEST_TYPE) {
|
if (msgtype === REQUEST_TYPE) {
|
||||||
return REQUEST_TYPE;
|
return REQUEST_TYPE;
|
||||||
}
|
}
|
||||||
|
@@ -15,8 +15,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {randomString} from '../../../randomstring';
|
import { randomString } from '../../../randomstring';
|
||||||
import {logger} from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
import {
|
import {
|
||||||
CANCEL_TYPE,
|
CANCEL_TYPE,
|
||||||
PHASE_STARTED,
|
PHASE_STARTED,
|
||||||
@@ -26,8 +26,8 @@ import {
|
|||||||
START_TYPE,
|
START_TYPE,
|
||||||
VerificationRequest,
|
VerificationRequest,
|
||||||
} from "./VerificationRequest";
|
} from "./VerificationRequest";
|
||||||
import {errorFromEvent, newUnexpectedMessageError} from "../Error";
|
import { errorFromEvent, newUnexpectedMessageError } from "../Error";
|
||||||
import {MatrixEvent} from "../../../models/event";
|
import { MatrixEvent } from "../../../models/event";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A key verification channel that sends verification events over to_device messages.
|
* A key verification channel that sends verification events over to_device messages.
|
||||||
@@ -277,7 +277,7 @@ export class ToDeviceChannel {
|
|||||||
msgMap[deviceId] = content;
|
msgMap[deviceId] = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._client.sendToDevice(type, {[this.userId]: msgMap});
|
return this._client.sendToDevice(type, { [this.userId]: msgMap });
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,6 @@ export class ToDeviceChannel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class ToDeviceRequests {
|
export class ToDeviceRequests {
|
||||||
constructor() {
|
constructor() {
|
||||||
this._requestsByUserId = new Map();
|
this._requestsByUserId = new Map();
|
||||||
|
@@ -15,15 +15,15 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
import {EventEmitter} from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import {
|
import {
|
||||||
errorFactory,
|
errorFactory,
|
||||||
errorFromEvent,
|
errorFromEvent,
|
||||||
newUnexpectedMessageError,
|
newUnexpectedMessageError,
|
||||||
newUnknownMethodError,
|
newUnknownMethodError,
|
||||||
} from "../Error";
|
} from "../Error";
|
||||||
import {QRCodeData, SCAN_QR_CODE_METHOD} from "../QRCode";
|
import { QRCodeData, SCAN_QR_CODE_METHOD } from "../QRCode";
|
||||||
|
|
||||||
// How long after the event's timestamp that the request times out
|
// How long after the event's timestamp that the request times out
|
||||||
const TIMEOUT_FROM_EVENT_TS = 10 * 60 * 1000; // 10 minutes
|
const TIMEOUT_FROM_EVENT_TS = 10 * 60 * 1000; // 10 minutes
|
||||||
@@ -37,7 +37,6 @@ const TIMEOUT_FROM_EVENT_RECEIPT = 2 * 60 * 1000; // 2 minutes
|
|||||||
// are this amount of time away from expiring.
|
// are this amount of time away from expiring.
|
||||||
const VERIFICATION_REQUEST_MARGIN = 3 * 1000; // 3 seconds
|
const VERIFICATION_REQUEST_MARGIN = 3 * 1000; // 3 seconds
|
||||||
|
|
||||||
|
|
||||||
export const EVENT_PREFIX = "m.key.verification.";
|
export const EVENT_PREFIX = "m.key.verification.";
|
||||||
export const REQUEST_TYPE = EVENT_PREFIX + "request";
|
export const REQUEST_TYPE = EVENT_PREFIX + "request";
|
||||||
export const START_TYPE = EVENT_PREFIX + "start";
|
export const START_TYPE = EVENT_PREFIX + "start";
|
||||||
@@ -52,7 +51,6 @@ export const PHASE_STARTED = 4;
|
|||||||
export const PHASE_CANCELLED = 5;
|
export const PHASE_CANCELLED = 5;
|
||||||
export const PHASE_DONE = 6;
|
export const PHASE_DONE = 6;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State machine for verification requests.
|
* State machine for verification requests.
|
||||||
* Things that differ based on what channel is used to
|
* Things that differ based on what channel is used to
|
||||||
@@ -98,7 +96,6 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
static validateEvent(type, event, client) {
|
static validateEvent(type, event, client) {
|
||||||
const content = event.getContent();
|
const content = event.getContent();
|
||||||
|
|
||||||
|
|
||||||
if (!type || !type.startsWith(EVENT_PREFIX)) {
|
if (!type || !type.startsWith(EVENT_PREFIX)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -265,7 +262,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
if (!content) {
|
if (!content) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const {methods} = content;
|
const { methods } = content;
|
||||||
if (!Array.isArray(methods)) {
|
if (!Array.isArray(methods)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -355,7 +352,6 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
return this._observeOnly;
|
return this._observeOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets which device the verification should be started with
|
* Gets which device the verification should be started with
|
||||||
* given the events sent so far in the verification. This is the
|
* given the events sent so far in the verification. This is the
|
||||||
@@ -414,7 +410,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
async sendRequest() {
|
async sendRequest() {
|
||||||
if (!this.observeOnly && this._phase === PHASE_UNSENT) {
|
if (!this.observeOnly && this._phase === PHASE_UNSENT) {
|
||||||
const methods = [...this._verificationMethods.keys()];
|
const methods = [...this._verificationMethods.keys()];
|
||||||
await this.channel.send(REQUEST_TYPE, {methods});
|
await this.channel.send(REQUEST_TYPE, { methods });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,7 +420,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
* @param {string?} error.code the error code to send the cancellation with
|
* @param {string?} error.code the error code to send the cancellation with
|
||||||
* @returns {Promise} resolves when the event has been sent.
|
* @returns {Promise} resolves when the event has been sent.
|
||||||
*/
|
*/
|
||||||
async cancel({reason = "User declined", code = "m.user"} = {}) {
|
async cancel({ reason = "User declined", code = "m.user" } = {}) {
|
||||||
if (!this.observeOnly && this._phase !== PHASE_CANCELLED) {
|
if (!this.observeOnly && this._phase !== PHASE_CANCELLED) {
|
||||||
this._declining = true;
|
this._declining = true;
|
||||||
this.emit("change");
|
this.emit("change");
|
||||||
@@ -432,7 +428,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
return this._verifier.cancel(errorFactory(code, reason)());
|
return this._verifier.cancel(errorFactory(code, reason)());
|
||||||
} else {
|
} else {
|
||||||
this._cancellingUserId = this._client.getUserId();
|
this._cancellingUserId = this._client.getUserId();
|
||||||
await this.channel.send(CANCEL_TYPE, {code, reason});
|
await this.channel.send(CANCEL_TYPE, { code, reason });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -446,7 +442,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
const methods = [...this._verificationMethods.keys()];
|
const methods = [...this._verificationMethods.keys()];
|
||||||
this._accepting = true;
|
this._accepting = true;
|
||||||
this.emit("change");
|
this.emit("change");
|
||||||
await this.channel.send(READY_TYPE, {methods});
|
await this.channel.send(READY_TYPE, { methods });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,20 +495,20 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_calculatePhaseTransitions() {
|
_calculatePhaseTransitions() {
|
||||||
const transitions = [{phase: PHASE_UNSENT}];
|
const transitions = [{ phase: PHASE_UNSENT }];
|
||||||
const phase = () => transitions[transitions.length - 1].phase;
|
const phase = () => transitions[transitions.length - 1].phase;
|
||||||
|
|
||||||
// always pass by .request first to be sure channel.userId has been set
|
// always pass by .request first to be sure channel.userId has been set
|
||||||
const hasRequestByThem = this._eventsByThem.has(REQUEST_TYPE);
|
const hasRequestByThem = this._eventsByThem.has(REQUEST_TYPE);
|
||||||
const requestEvent = this._getEventBy(REQUEST_TYPE, hasRequestByThem);
|
const requestEvent = this._getEventBy(REQUEST_TYPE, hasRequestByThem);
|
||||||
if (requestEvent) {
|
if (requestEvent) {
|
||||||
transitions.push({phase: PHASE_REQUESTED, event: requestEvent});
|
transitions.push({ phase: PHASE_REQUESTED, event: requestEvent });
|
||||||
}
|
}
|
||||||
|
|
||||||
const readyEvent =
|
const readyEvent =
|
||||||
requestEvent && this._getEventBy(READY_TYPE, !hasRequestByThem);
|
requestEvent && this._getEventBy(READY_TYPE, !hasRequestByThem);
|
||||||
if (readyEvent && phase() === PHASE_REQUESTED) {
|
if (readyEvent && phase() === PHASE_REQUESTED) {
|
||||||
transitions.push({phase: PHASE_READY, event: readyEvent});
|
transitions.push({ phase: PHASE_READY, event: readyEvent });
|
||||||
}
|
}
|
||||||
|
|
||||||
let startEvent;
|
let startEvent;
|
||||||
@@ -535,18 +531,18 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
const fromUnsentPhase = phase() === PHASE_UNSENT &&
|
const fromUnsentPhase = phase() === PHASE_UNSENT &&
|
||||||
this.channel.constructor.canCreateRequest(START_TYPE);
|
this.channel.constructor.canCreateRequest(START_TYPE);
|
||||||
if (fromRequestPhase || phase() === PHASE_READY || fromUnsentPhase) {
|
if (fromRequestPhase || phase() === PHASE_READY || fromUnsentPhase) {
|
||||||
transitions.push({phase: PHASE_STARTED, event: startEvent});
|
transitions.push({ phase: PHASE_STARTED, event: startEvent });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ourDoneEvent = this._eventsByUs.get(DONE_TYPE);
|
const ourDoneEvent = this._eventsByUs.get(DONE_TYPE);
|
||||||
if (this._verifierHasFinished || (ourDoneEvent && phase() === PHASE_STARTED)) {
|
if (this._verifierHasFinished || (ourDoneEvent && phase() === PHASE_STARTED)) {
|
||||||
transitions.push({phase: PHASE_DONE});
|
transitions.push({ phase: PHASE_DONE });
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancelEvent = this._getEventByEither(CANCEL_TYPE);
|
const cancelEvent = this._getEventByEither(CANCEL_TYPE);
|
||||||
if ((this._cancelled || cancelEvent) && phase() !== PHASE_DONE) {
|
if ((this._cancelled || cancelEvent) && phase() !== PHASE_DONE) {
|
||||||
transitions.push({phase: PHASE_CANCELLED, event: cancelEvent});
|
transitions.push({ phase: PHASE_CANCELLED, event: cancelEvent });
|
||||||
return transitions;
|
return transitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -554,7 +550,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_transitionToPhase(transition) {
|
_transitionToPhase(transition) {
|
||||||
const {phase, event} = transition;
|
const { phase, event } = transition;
|
||||||
// get common methods
|
// get common methods
|
||||||
if (phase === PHASE_REQUESTED || phase === PHASE_READY) {
|
if (phase === PHASE_REQUESTED || phase === PHASE_READY) {
|
||||||
if (!this._wasSentByOwnDevice(event)) {
|
if (!this._wasSentByOwnDevice(event)) {
|
||||||
@@ -581,7 +577,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
}
|
}
|
||||||
// create verifier
|
// create verifier
|
||||||
if (phase === PHASE_STARTED) {
|
if (phase === PHASE_STARTED) {
|
||||||
const {method} = event.getContent();
|
const { method } = event.getContent();
|
||||||
if (!this._verifier && !this.observeOnly) {
|
if (!this._verifier && !this.observeOnly) {
|
||||||
this._verifier = this._createVerifier(method, event);
|
this._verifier = this._createVerifier(method, event);
|
||||||
if (!this._verifier) {
|
if (!this._verifier) {
|
||||||
@@ -731,7 +727,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const lastTransition = newTransitions[newTransitions.length - 1];
|
const lastTransition = newTransitions[newTransitions.length - 1];
|
||||||
const {phase} = lastTransition;
|
const { phase } = lastTransition;
|
||||||
|
|
||||||
this._setupTimeout(phase);
|
this._setupTimeout(phase);
|
||||||
// set phase as last thing as this emits the "change" event
|
// set phase as last thing as this emits the "change" event
|
||||||
@@ -809,7 +805,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
logger.warn(`Cancelling, unexpected ${type} verification ` +
|
logger.warn(`Cancelling, unexpected ${type} verification ` +
|
||||||
`event from ${event.getSender()}`);
|
`event from ${event.getSender()}`);
|
||||||
const reason = `Unexpected ${type} event in phase ${this.phase}`;
|
const reason = `Unexpected ${type} event in phase ${this.phase}`;
|
||||||
await this.cancel(errorFromEvent(newUnexpectedMessageError({reason})));
|
await this.cancel(errorFromEvent(newUnexpectedMessageError({ reason })));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -849,7 +845,7 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
if (!targetDevice) {
|
if (!targetDevice) {
|
||||||
targetDevice = this.targetDevice;
|
targetDevice = this.targetDevice;
|
||||||
}
|
}
|
||||||
const {userId, deviceId} = targetDevice;
|
const { userId, deviceId } = targetDevice;
|
||||||
|
|
||||||
const VerifierCtor = this._verificationMethods.get(method);
|
const VerifierCtor = this._verificationMethods.get(method);
|
||||||
if (!VerifierCtor) {
|
if (!VerifierCtor) {
|
||||||
|
@@ -22,7 +22,6 @@ InvalidStoreError.prototype = Object.create(Error.prototype, {
|
|||||||
});
|
});
|
||||||
Reflect.setPrototypeOf(InvalidStoreError, Error);
|
Reflect.setPrototypeOf(InvalidStoreError, Error);
|
||||||
|
|
||||||
|
|
||||||
export function InvalidCryptoStoreError(reason) {
|
export function InvalidCryptoStoreError(reason) {
|
||||||
const message = `Crypto store is invalid because ${reason}, ` +
|
const message = `Crypto store is invalid because ${reason}, ` +
|
||||||
`please stop the client, delete all data and start the client again`;
|
`please stop the client, delete all data and start the client again`;
|
||||||
|
@@ -19,7 +19,7 @@ limitations under the License.
|
|||||||
* @module filter
|
* @module filter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {FilterComponent} from "./filter-component";
|
import { FilterComponent } from "./filter-component";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
|
@@ -20,9 +20,9 @@ limitations under the License.
|
|||||||
* @module http-api
|
* @module http-api
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {parse as parseContentType} from "content-type";
|
import { parse as parseContentType } from "content-type";
|
||||||
import * as utils from "./utils";
|
import * as utils from "./utils";
|
||||||
import {logger} from './logger';
|
import { logger } from './logger';
|
||||||
|
|
||||||
// we use our own implementation of setTimeout, so that if we get suspended in
|
// we use our own implementation of setTimeout, so that if we get suspended in
|
||||||
// the middle of a /sync, we cancel the sync as soon as we awake, rather than
|
// the middle of a /sync, we cancel the sync as soon as we awake, rather than
|
||||||
@@ -344,7 +344,7 @@ MatrixHttpApi.prototype = {
|
|||||||
promise = this.authedRequest(
|
promise = this.authedRequest(
|
||||||
opts.callback, "POST", "/upload", queryParams, body, {
|
opts.callback, "POST", "/upload", queryParams, body, {
|
||||||
prefix: "/_matrix/media/r0",
|
prefix: "/_matrix/media/r0",
|
||||||
headers: {"Content-Type": contentType},
|
headers: { "Content-Type": contentType },
|
||||||
json: false,
|
json: false,
|
||||||
bodyParser: bodyParser,
|
bodyParser: bodyParser,
|
||||||
},
|
},
|
||||||
@@ -803,7 +803,8 @@ const requestCallback = function(
|
|||||||
}
|
}
|
||||||
if (!err) {
|
if (!err) {
|
||||||
try {
|
try {
|
||||||
if (response.statusCode >= 400) {
|
const httpStatus = response.status || response.statusCode; // XMLHttpRequest vs http.IncomingMessage
|
||||||
|
if (httpStatus >= 400) {
|
||||||
err = parseErrorResponse(response, body);
|
err = parseErrorResponse(response, body);
|
||||||
} else if (bodyParser) {
|
} else if (bodyParser) {
|
||||||
body = bodyParser(body);
|
body = bodyParser(body);
|
||||||
@@ -818,7 +819,7 @@ const requestCallback = function(
|
|||||||
userDefinedCallback(err);
|
userDefinedCallback(err);
|
||||||
} else {
|
} else {
|
||||||
const res = {
|
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
|
// XXX: why do we bother with this? it doesn't work for
|
||||||
// XMLHttpRequest, so clearly we don't use it.
|
// XMLHttpRequest, so clearly we don't use it.
|
||||||
@@ -842,7 +843,7 @@ const requestCallback = function(
|
|||||||
* @returns {Error}
|
* @returns {Error}
|
||||||
*/
|
*/
|
||||||
function parseErrorResponse(response, body) {
|
function parseErrorResponse(response, body) {
|
||||||
const httpStatus = response.statusCode;
|
const httpStatus = response.status || response.statusCode; // XMLHttpRequest vs http.IncomingMessage
|
||||||
const contentType = getResponseContentType(response);
|
const contentType = getResponseContentType(response);
|
||||||
|
|
||||||
let err;
|
let err;
|
||||||
@@ -862,7 +863,6 @@ function parseErrorResponse(response, body) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extract the Content-Type header from the response object, and
|
* extract the Content-Type header from the response object, and
|
||||||
* parse it to a `{type, parameters}` object.
|
* parse it to a `{type, parameters}` object.
|
||||||
|
@@ -21,5 +21,5 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** The {@link module:indexeddb-store-worker~IndexedDBStoreWorker} class. */
|
/** The {@link module:indexeddb-store-worker~IndexedDBStoreWorker} class. */
|
||||||
export {IndexedDBStoreWorker} from "./store/indexeddb-store-worker";
|
export { IndexedDBStoreWorker } from "./store/indexeddb-store-worker";
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ limitations under the License.
|
|||||||
|
|
||||||
import url from "url";
|
import url from "url";
|
||||||
import * as utils from "./utils";
|
import * as utils from "./utils";
|
||||||
import {logger} from './logger';
|
import { logger } from './logger';
|
||||||
|
|
||||||
const EMAIL_STAGE_TYPE = "m.login.email.identity";
|
const EMAIL_STAGE_TYPE = "m.login.email.identity";
|
||||||
const MSISDN_STAGE_TYPE = "m.login.msisdn";
|
const MSISDN_STAGE_TYPE = "m.login.msisdn";
|
||||||
|
@@ -18,15 +18,15 @@ limitations under the License.
|
|||||||
|
|
||||||
import type Request from "request";
|
import type Request from "request";
|
||||||
|
|
||||||
import {MemoryCryptoStore} from "./crypto/store/memory-crypto-store";
|
import { MemoryCryptoStore } from "./crypto/store/memory-crypto-store";
|
||||||
import {LocalStorageCryptoStore} from "./crypto/store/localStorage-crypto-store";
|
import { LocalStorageCryptoStore } from "./crypto/store/localStorage-crypto-store";
|
||||||
import {IndexedDBCryptoStore} from "./crypto/store/indexeddb-crypto-store";
|
import { IndexedDBCryptoStore } from "./crypto/store/indexeddb-crypto-store";
|
||||||
import {MemoryStore} from "./store/memory";
|
import { MemoryStore } from "./store/memory";
|
||||||
import {StubStore} from "./store/stub";
|
import { StubStore } from "./store/stub";
|
||||||
import {LocalIndexedDBStoreBackend} from "./store/indexeddb-local-backend";
|
import { LocalIndexedDBStoreBackend } from "./store/indexeddb-local-backend";
|
||||||
import {RemoteIndexedDBStoreBackend} from "./store/indexeddb-remote-backend";
|
import { RemoteIndexedDBStoreBackend } from "./store/indexeddb-remote-backend";
|
||||||
import {MatrixScheduler} from "./scheduler";
|
import { MatrixScheduler } from "./scheduler";
|
||||||
import {MatrixClient} from "./client";
|
import { MatrixClient } from "./client";
|
||||||
|
|
||||||
export * from "./client";
|
export * from "./client";
|
||||||
export * from "./http-api";
|
export * from "./http-api";
|
||||||
@@ -59,7 +59,6 @@ export {
|
|||||||
setVideoInput as setMatrixCallVideoInput,
|
setVideoInput as setMatrixCallVideoInput,
|
||||||
} from "./webrtc/call";
|
} from "./webrtc/call";
|
||||||
|
|
||||||
|
|
||||||
// expose the underlying request object so different environments can use
|
// expose the underlying request object so different environments can use
|
||||||
// different request libs (e.g. request or browser-request)
|
// different request libs (e.g. request or browser-request)
|
||||||
let requestInstance;
|
let requestInstance;
|
||||||
|
@@ -36,10 +36,10 @@ limitations under the License.
|
|||||||
export function EventContext(ourEvent) {
|
export function EventContext(ourEvent) {
|
||||||
this._timeline = [ourEvent];
|
this._timeline = [ourEvent];
|
||||||
this._ourEventIndex = 0;
|
this._ourEventIndex = 0;
|
||||||
this._paginateTokens = {b: null, f: null};
|
this._paginateTokens = { b: null, f: null };
|
||||||
|
|
||||||
// this is used by MatrixClient to keep track of active requests
|
// this is used by MatrixClient to keep track of active requests
|
||||||
this._paginateRequests = {b: null, f: null};
|
this._paginateRequests = { b: null, f: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -19,12 +19,12 @@ limitations under the License.
|
|||||||
* @module models/event-timeline-set
|
* @module models/event-timeline-set
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EventEmitter} from "events";
|
import { EventEmitter } from "events";
|
||||||
import {EventTimeline} from "./event-timeline";
|
import { EventTimeline } from "./event-timeline";
|
||||||
import {EventStatus} from "./event";
|
import { EventStatus } from "./event";
|
||||||
import * as utils from "../utils";
|
import * as utils from "../utils";
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
import {Relations} from './relations';
|
import { Relations } from './relations';
|
||||||
|
|
||||||
// var DEBUG = false;
|
// var DEBUG = false;
|
||||||
const DEBUG = true;
|
const DEBUG = true;
|
||||||
@@ -271,7 +271,6 @@ EventTimelineSet.prototype.addTimeline = function() {
|
|||||||
return timeline;
|
return timeline;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add events to a timeline
|
* Add events to a timeline
|
||||||
*
|
*
|
||||||
@@ -474,7 +473,7 @@ EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimel
|
|||||||
// timeline we ended up on.
|
// timeline we ended up on.
|
||||||
if (lastEventWasNew || !didUpdate) {
|
if (lastEventWasNew || !didUpdate) {
|
||||||
if (direction === EventTimeline.FORWARDS && timeline === this._liveTimeline) {
|
if (direction === EventTimeline.FORWARDS && timeline === this._liveTimeline) {
|
||||||
logger.warn({lastEventWasNew, didUpdate}); // for debugging
|
logger.warn({ lastEventWasNew, didUpdate }); // for debugging
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Refusing to set forwards pagination token of live timeline ` +
|
`Refusing to set forwards pagination token of live timeline ` +
|
||||||
`${timeline} to ${paginationToken}`,
|
`${timeline} to ${paginationToken}`,
|
||||||
@@ -740,16 +739,11 @@ EventTimelineSet.prototype.setRelationsTarget = function(event) {
|
|||||||
if (!relationsForEvent) {
|
if (!relationsForEvent) {
|
||||||
return;
|
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)) {
|
||||||
relationsWithEventType.setTargetEvent(event);
|
for (const relationsWithEventType of Object.values(relationsWithRelType)) {
|
||||||
|
relationsWithEventType.setTargetEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -797,7 +791,6 @@ EventTimelineSet.prototype.aggregateRelations = function(event) {
|
|||||||
}
|
}
|
||||||
let relationsWithEventType = relationsWithRelType[eventType];
|
let relationsWithEventType = relationsWithRelType[eventType];
|
||||||
|
|
||||||
let isNewRelations = false;
|
|
||||||
let relatesToEvent;
|
let relatesToEvent;
|
||||||
if (!relationsWithEventType) {
|
if (!relationsWithEventType) {
|
||||||
relationsWithEventType = relationsWithRelType[eventType] = new Relations(
|
relationsWithEventType = relationsWithRelType[eventType] = new Relations(
|
||||||
@@ -805,7 +798,6 @@ EventTimelineSet.prototype.aggregateRelations = function(event) {
|
|||||||
eventType,
|
eventType,
|
||||||
this.room,
|
this.room,
|
||||||
);
|
);
|
||||||
isNewRelations = true;
|
|
||||||
relatesToEvent = this.findEventById(relatesToEventId) || this.room.getPendingEvent(relatesToEventId);
|
relatesToEvent = this.findEventById(relatesToEventId) || this.room.getPendingEvent(relatesToEventId);
|
||||||
if (relatesToEvent) {
|
if (relatesToEvent) {
|
||||||
relationsWithEventType.setTargetEvent(relatesToEvent);
|
relationsWithEventType.setTargetEvent(relatesToEvent);
|
||||||
@@ -813,11 +805,6 @@ EventTimelineSet.prototype.aggregateRelations = function(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
relationsWithEventType.addEvent(event);
|
relationsWithEventType.addEvent(event);
|
||||||
|
|
||||||
// only emit once event has been added to relations
|
|
||||||
if (isNewRelations && relatesToEvent) {
|
|
||||||
relatesToEvent.emit("Event.relationsCreated", relationType, eventType);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -19,7 +19,7 @@ limitations under the License.
|
|||||||
* @module models/event-timeline
|
* @module models/event-timeline
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {RoomState} from "./room-state";
|
import { RoomState } from "./room-state";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new EventTimeline
|
* Construct a new EventTimeline
|
||||||
@@ -55,7 +55,7 @@ export function EventTimeline(eventTimelineSet) {
|
|||||||
this._nextTimeline = null;
|
this._nextTimeline = null;
|
||||||
|
|
||||||
// this is used by client.js
|
// this is used by client.js
|
||||||
this._paginationRequests = {'b': null, 'f': null};
|
this._paginationRequests = { 'b': null, 'f': null };
|
||||||
|
|
||||||
this._name = this._roomId + ":" + new Date().toISOString();
|
this._name = this._roomId + ":" + new Date().toISOString();
|
||||||
}
|
}
|
||||||
|
@@ -21,9 +21,9 @@ limitations under the License.
|
|||||||
* @module models/event
|
* @module models/event
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EventEmitter} from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import * as utils from '../utils';
|
import * as utils from '../utils';
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum for event statuses.
|
* Enum for event statuses.
|
||||||
@@ -180,7 +180,6 @@ export const MatrixEvent = function(
|
|||||||
};
|
};
|
||||||
utils.inherits(MatrixEvent, EventEmitter);
|
utils.inherits(MatrixEvent, EventEmitter);
|
||||||
|
|
||||||
|
|
||||||
utils.extend(MatrixEvent.prototype, {
|
utils.extend(MatrixEvent.prototype, {
|
||||||
/**
|
/**
|
||||||
* Get the event_id for this event.
|
* 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
|
/* _REDACT_KEEP_KEY_MAP gives the keys we keep when an event is redacted
|
||||||
*
|
*
|
||||||
* This is specified here:
|
* This is specified here:
|
||||||
@@ -1165,17 +1163,16 @@ const _REDACT_KEEP_KEY_MAP = [
|
|||||||
|
|
||||||
// a map from event type to the .content keys we keep when an event is redacted
|
// a map from event type to the .content keys we keep when an event is redacted
|
||||||
const _REDACT_KEEP_CONTENT_MAP = {
|
const _REDACT_KEEP_CONTENT_MAP = {
|
||||||
'm.room.member': {'membership': 1},
|
'm.room.member': { 'membership': 1 },
|
||||||
'm.room.create': {'creator': 1},
|
'm.room.create': { 'creator': 1 },
|
||||||
'm.room.join_rules': {'join_rule': 1},
|
'm.room.join_rules': { 'join_rule': 1 },
|
||||||
'm.room.power_levels': {'ban': 1, 'events': 1, 'events_default': 1,
|
'm.room.power_levels': { 'ban': 1, 'events': 1, 'events_default': 1,
|
||||||
'kick': 1, 'redact': 1, 'state_default': 1,
|
'kick': 1, 'redact': 1, 'state_default': 1,
|
||||||
'users': 1, 'users_default': 1,
|
'users': 1, 'users_default': 1,
|
||||||
},
|
},
|
||||||
'm.room.aliases': {'aliases': 1},
|
'm.room.aliases': { 'aliases': 1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires when an event is decrypted
|
* Fires when an event is decrypted
|
||||||
*
|
*
|
||||||
|
@@ -20,7 +20,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as utils from "../utils";
|
import * as utils from "../utils";
|
||||||
import {EventEmitter} from "events";
|
import { EventEmitter } from "events";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Group.
|
* Construct a new Group.
|
||||||
|
@@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EventEmitter} from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import {EventStatus} from '../models/event';
|
import { EventStatus } from '../models/event';
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A container for relation events that supports easy access to common ways of
|
* A container for relation events that supports easy access to common ways of
|
||||||
@@ -48,6 +48,7 @@ export class Relations extends EventEmitter {
|
|||||||
this._sortedAnnotationsByKey = [];
|
this._sortedAnnotationsByKey = [];
|
||||||
this._targetEvent = null;
|
this._targetEvent = null;
|
||||||
this._room = room;
|
this._room = room;
|
||||||
|
this._creationEmitted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,6 +95,8 @@ export class Relations extends EventEmitter {
|
|||||||
event.on("Event.beforeRedaction", this._onBeforeRedaction);
|
event.on("Event.beforeRedaction", this._onBeforeRedaction);
|
||||||
|
|
||||||
this.emit("Relations.add", event);
|
this.emit("Relations.add", event);
|
||||||
|
|
||||||
|
this._maybeEmitCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -345,6 +348,7 @@ export class Relations extends EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._targetEvent = event;
|
this._targetEvent = event;
|
||||||
|
|
||||||
if (this.relationType === "m.replace") {
|
if (this.relationType === "m.replace") {
|
||||||
const replacement = await this.getLastReplacement();
|
const replacement = await this.getLastReplacement();
|
||||||
// this is the initial update, so only call it if we already have something
|
// 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._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,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,8 +19,8 @@ limitations under the License.
|
|||||||
* @module models/room-member
|
* @module models/room-member
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EventEmitter} from "events";
|
import { EventEmitter } from "events";
|
||||||
import {getHttpUriForMxc} from "../content-repo";
|
import { getHttpUriForMxc } from "../content-repo";
|
||||||
import * as utils from "../utils";
|
import * as utils from "../utils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,7 +203,6 @@ RoomMember.prototype.getLastModifiedTime = function() {
|
|||||||
return this._modified;
|
return this._modified;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
RoomMember.prototype.isKicked = function() {
|
RoomMember.prototype.isKicked = function() {
|
||||||
return this.membership === "leave" &&
|
return this.membership === "leave" &&
|
||||||
this.events.member.getSender() !== this.events.member.getStateKey();
|
this.events.member.getSender() !== this.events.member.getStateKey();
|
||||||
@@ -240,7 +239,6 @@ RoomMember.prototype.getDMInviter = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the avatar URL for a room member.
|
* Get the avatar URL for a room member.
|
||||||
* @param {string} baseUrl The base homeserver URL See
|
* @param {string} baseUrl The base homeserver URL See
|
||||||
|
@@ -19,11 +19,11 @@ limitations under the License.
|
|||||||
* @module models/room-state
|
* @module models/room-state
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EventEmitter} from "events";
|
import { EventEmitter } from "events";
|
||||||
import {RoomMember} from "./room-member";
|
import { RoomMember } from "./room-member";
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
import * as utils from "../utils";
|
import * as utils from "../utils";
|
||||||
import {EventType} from "../@types/event";
|
import { EventType } from "../@types/event";
|
||||||
|
|
||||||
// possible statuses for out-of-band member loading
|
// possible statuses for out-of-band member loading
|
||||||
const OOB_STATUS_NOTSTARTED = 1;
|
const OOB_STATUS_NOTSTARTED = 1;
|
||||||
@@ -735,7 +735,6 @@ RoomState.prototype.getJoinRule = function() {
|
|||||||
return joinRuleContent["join_rule"] || "invite";
|
return joinRuleContent["join_rule"] || "invite";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function _updateThirdPartyTokenCache(roomState, memberEvent) {
|
function _updateThirdPartyTokenCache(roomState, memberEvent) {
|
||||||
if (!memberEvent.getContent().third_party_invite) {
|
if (!memberEvent.getContent().third_party_invite) {
|
||||||
return;
|
return;
|
||||||
|
@@ -20,7 +20,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as utils from "../utils";
|
import * as utils from "../utils";
|
||||||
import {EventEmitter} from "events";
|
import { EventEmitter } from "events";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new User. A User must have an ID and can optionally have extra
|
* Construct a new User. A User must have an ID and can optionally have extra
|
||||||
@@ -139,7 +139,6 @@ User.prototype.setDisplayName = function(name) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manually set this user's non-disambiguated display name. No event is emitted
|
* 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.
|
* 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
|
* Manually set this user's avatar URL. No event is emitted in response to this
|
||||||
* as there is no underlying MatrixEvent to emit with.
|
* as there is no underlying MatrixEvent to emit with.
|
||||||
|
@@ -15,8 +15,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {escapeRegExp, globToRegexp, isNullOrUndefined} from "./utils";
|
import { escapeRegExp, globToRegexp, isNullOrUndefined } from "./utils";
|
||||||
import {logger} from './logger';
|
import { logger } from './logger';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module pushprocessor
|
* @module pushprocessor
|
||||||
@@ -360,7 +360,6 @@ export function PushProcessor(client) {
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user's push actions for the given event
|
* Get the user's push actions for the given event
|
||||||
*
|
*
|
||||||
@@ -468,4 +467,3 @@ PushProcessor.rewriteDefaultRules = function(incomingRules) {
|
|||||||
* noise.
|
* noise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ limitations under the License.
|
|||||||
* it will instead fire as soon as possible after resume.
|
* it will instead fire as soon as possible after resume.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from './logger';
|
import { logger } from './logger';
|
||||||
|
|
||||||
// we schedule a callback at least this often, to check if we've missed out on
|
// we schedule a callback at least this often, to check if we've missed out on
|
||||||
// some wall-clock time due to being suspended.
|
// some wall-clock time due to being suspended.
|
||||||
@@ -177,7 +177,6 @@ function _runCallbacks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* search in a sorted array.
|
/* search in a sorted array.
|
||||||
*
|
*
|
||||||
* returns the index of the last element for which func returns
|
* returns the index of the last element for which func returns
|
||||||
|
@@ -21,7 +21,7 @@ limitations under the License.
|
|||||||
* @module scheduler
|
* @module scheduler
|
||||||
*/
|
*/
|
||||||
import * as utils from "./utils";
|
import * as utils from "./utils";
|
||||||
import {logger} from './logger';
|
import { logger } from './logger';
|
||||||
|
|
||||||
const DEBUG = false; // set true to enable console logging.
|
const DEBUG = false; // set true to enable console logging.
|
||||||
|
|
||||||
@@ -93,7 +93,6 @@ MatrixScheduler.prototype.removeEventFromQueue = function(event) {
|
|||||||
return removed;
|
return removed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the process function. Required for events in the queue to be processed.
|
* 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
|
* If set after events have been added to the queue, this will immediately start
|
||||||
|
@@ -16,10 +16,10 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {SyncAccumulator} from "../sync-accumulator";
|
import { SyncAccumulator } from "../sync-accumulator";
|
||||||
import * as utils from "../utils";
|
import * as utils from "../utils";
|
||||||
import * as IndexedDBHelpers from "../indexeddb-helpers";
|
import * as IndexedDBHelpers from "../indexeddb-helpers";
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
|
|
||||||
const VERSION = 3;
|
const VERSION = 3;
|
||||||
|
|
||||||
@@ -45,10 +45,9 @@ function upgradeSchemaV2(db) {
|
|||||||
|
|
||||||
function upgradeSchemaV3(db) {
|
function upgradeSchemaV3(db) {
|
||||||
db.createObjectStore("client_options",
|
db.createObjectStore("client_options",
|
||||||
{ keyPath: ["clobber"]});
|
{ keyPath: ["clobber"] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to collect results from a Cursor and promiseify it.
|
* Helper method to collect results from a Cursor and promiseify it.
|
||||||
* @param {ObjectStore|Index} store The store to perform openCursor on.
|
* @param {ObjectStore|Index} store The store to perform openCursor on.
|
||||||
|
@@ -16,8 +16,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../logger';
|
import { logger } from '../logger';
|
||||||
import {defer} from '../utils';
|
import { defer } from '../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An IndexedDB store backend where the actual backend sits in a web
|
* An IndexedDB store backend where the actual backend sits in a web
|
||||||
@@ -48,7 +48,6 @@ export function RemoteIndexedDBStoreBackend(
|
|||||||
this._startPromise = null;
|
this._startPromise = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RemoteIndexedDBStoreBackend.prototype = {
|
RemoteIndexedDBStoreBackend.prototype = {
|
||||||
/**
|
/**
|
||||||
* Attempt to connect to the database. This can fail if the user does not
|
* Attempt to connect to the database. This can fail if the user does not
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user