From 2a280afa8811e6ae6a4f159c8bb44920f6ac5349 Mon Sep 17 00:00:00 2001 From: Christian Paul Date: Fri, 13 Aug 2021 15:58:44 +0200 Subject: [PATCH 1/7] Make SSSSCryptoCallbacks.delegateCryptoCallbacks optional --- src/crypto/EncryptionSetup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/EncryptionSetup.ts b/src/crypto/EncryptionSetup.ts index 1a36efb70..cb208b9cc 100644 --- a/src/crypto/EncryptionSetup.ts +++ b/src/crypto/EncryptionSetup.ts @@ -351,7 +351,7 @@ class CrossSigningCallbacks implements ICryptoCallbacks, ICacheCallbacks { class SSSSCryptoCallbacks { private readonly privateKeys = new Map(); - constructor(private readonly delegateCryptoCallbacks: ICryptoCallbacks) {} + constructor(private readonly delegateCryptoCallbacks?: ICryptoCallbacks) {} public async getSecretStorageKey( { keys }: { keys: Record }, From c6009b1056e7afb96af23461704a144b7d50d899 Mon Sep 17 00:00:00 2001 From: Christian Paul Date: Fri, 13 Aug 2021 16:04:47 +0200 Subject: [PATCH 2/7] Make delegateCryptoCallbacks parameter optional on EncryptionSetupBuilder --- src/crypto/EncryptionSetup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/EncryptionSetup.ts b/src/crypto/EncryptionSetup.ts index cb208b9cc..442149b90 100644 --- a/src/crypto/EncryptionSetup.ts +++ b/src/crypto/EncryptionSetup.ts @@ -59,7 +59,7 @@ export class EncryptionSetupBuilder { * @param {Object.} accountData pre-existing account data, will only be read, not written. * @param {CryptoCallbacks} delegateCryptoCallbacks crypto callbacks to delegate to if the key isn't in cache yet */ - constructor(accountData: Record, delegateCryptoCallbacks: ICryptoCallbacks) { + constructor(accountData: Record, delegateCryptoCallbacks?: ICryptoCallbacks) { this.accountDataClientAdapter = new AccountDataClientAdapter(accountData); this.crossSigningCallbacks = new CrossSigningCallbacks(); this.ssssCryptoCallbacks = new SSSSCryptoCallbacks(delegateCryptoCallbacks); From 768c0e7f778b375c382fd4bba83206a06524b05e Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 13 Aug 2021 09:25:19 -0600 Subject: [PATCH 3/7] Add method for including extra fields when uploading to a tree space We ultimately need this to include things like `info` and other metadata in a specific environment. --- src/models/MSC3089TreeSpace.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/models/MSC3089TreeSpace.ts b/src/models/MSC3089TreeSpace.ts index 80ea2b365..27bfe113e 100644 --- a/src/models/MSC3089TreeSpace.ts +++ b/src/models/MSC3089TreeSpace.ts @@ -18,7 +18,7 @@ import { MatrixClient } from "../client"; import { EventType, IEncryptedFile, MsgType, UNSTABLE_MSC3089_BRANCH, UNSTABLE_MSC3089_LEAF } from "../@types/event"; import { Room } from "./room"; import { logger } from "../logger"; -import { MatrixEvent } from "./event"; +import { IContent, MatrixEvent } from "./event"; import { averageBetweenStrings, DEFAULT_ALPHABET, @@ -451,11 +451,14 @@ export class MSC3089TreeSpace { * @param {string} name The name of the file. * @param {ArrayBuffer} encryptedContents The encrypted contents. * @param {Partial} info The encrypted file information. + * @param {IContent} additionalContent Optional event content fields to include in the message. * @returns {Promise} Resolves when uploaded. */ public async createFile( name: string, - encryptedContents: ArrayBuffer, info: Partial, + encryptedContents: ArrayBuffer, + info: Partial, + additionalContent?: IContent, ): Promise { const mxc = await this.client.uploadContent(new Blob([encryptedContents]), { includeFilename: false, @@ -464,6 +467,7 @@ export class MSC3089TreeSpace { info.url = mxc; const res = await this.client.sendMessage(this.roomId, { + ...(additionalContent ?? {}), msgtype: MsgType.File, body: name, url: mxc, From dd80e744ff6bc9bd3a586c56c23f14d32a138186 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Mon, 16 Aug 2021 09:06:52 +0100 Subject: [PATCH 4/7] Expose IMyDevice interface --- src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 058f22250..2460cffa2 100644 --- a/src/client.ts +++ b/src/client.ts @@ -600,7 +600,7 @@ interface IUserDirectoryResponse { limited: boolean; } -interface IMyDevice { +export interface IMyDevice { device_id: string; display_name?: string; last_seen_ip?: string; From c0e15b206a806fd1e12c7e1716ffc77f474890c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 17 Aug 2021 10:03:46 +0200 Subject: [PATCH 5/7] Revert "Fix regressions" This reverts commit bd8690de57ceae28a2ef78cfe0fce14411923445. --- src/webrtc/callEventHandler.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/webrtc/callEventHandler.ts b/src/webrtc/callEventHandler.ts index 68aaffd0a..0ce247263 100644 --- a/src/webrtc/callEventHandler.ts +++ b/src/webrtc/callEventHandler.ts @@ -80,7 +80,7 @@ export class CallEventHandler { continue; } try { - this.handleCallEvent(e); + await this.handleCallEvent(e); } catch (e) { logger.error("Caught exception handling call event", e); } @@ -100,7 +100,7 @@ export class CallEventHandler { if (event.isBeingDecrypted() || event.isDecryptionFailure()) { // add an event listener for once the event is decrypted. - event.once("Event.decrypted", () => { + event.once("Event.decrypted", async () => { if (!this.eventIsACall(event)) return; if (this.callEventBuffer.includes(event)) { @@ -110,7 +110,7 @@ export class CallEventHandler { // This one wasn't buffered so just run the event handler for it // straight away try { - this.handleCallEvent(event); + await this.handleCallEvent(event); } catch (e) { logger.error("Caught exception handling call event", e); } @@ -169,7 +169,7 @@ export class CallEventHandler { } call.callId = content.call_id; - const initWithInvitePromise = call.initWithInvite(event); + await call.initWithInvite(event); this.calls.set(call.callId, call); // if we stashed candidate events for that call ID, play them back now @@ -210,8 +210,6 @@ export class CallEventHandler { "Glare detected: answering incoming call " + call.callId + " and canceling outgoing call " + existingCall.callId, ); - // Await init with invite as we need a peerConn for the following methods - await initWithInvitePromise; existingCall.replacedBy(call); call.answer(); } else { From 0a10fa12ef69959960cc52526160b98a20eab268 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Thu, 19 Aug 2021 08:59:55 +0200 Subject: [PATCH 6/7] Add necessary changes for PasswordReset migration --- src/client.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client.ts b/src/client.ts index 2460cffa2..a50a25e27 100644 --- a/src/client.ts +++ b/src/client.ts @@ -521,7 +521,7 @@ interface IMessagesResponse { state: IStateEvent[]; } -interface IRequestTokenResponse { +export interface IRequestTokenResponse { sid: string; submit_url?: string; } @@ -5078,7 +5078,7 @@ export class MatrixClient extends EventEmitter { email: string, clientSecret: string, sendAttempt: number, - nextLink: string, + nextLink?: string, ): Promise { return this.requestTokenFromEndpoint( "/account/password/email/requestToken", @@ -7992,9 +7992,9 @@ export class MatrixClient extends EventEmitter { limit?: number, batch?: string, ): Promise<{ - rooms: ISpaceSummaryRoom[]; - events: ISpaceSummaryEvent[]; - }> { + rooms: ISpaceSummaryRoom[]; + events: ISpaceSummaryEvent[]; + }> { const path = utils.encodeUri("/rooms/$roomId/spaces", { $roomId: roomId, }); From 8fb036ba2d01fab66dc4373802ccf19b5cac8541 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Thu, 19 Aug 2021 09:46:54 +0200 Subject: [PATCH 7/7] Make eslint happy --- src/client.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/client.ts b/src/client.ts index a50a25e27..abf92b6eb 100644 --- a/src/client.ts +++ b/src/client.ts @@ -7991,10 +7991,7 @@ export class MatrixClient extends EventEmitter { autoJoinOnly?: boolean, limit?: number, batch?: string, - ): Promise<{ - rooms: ISpaceSummaryRoom[]; - events: ISpaceSummaryEvent[]; - }> { + ): Promise<{rooms: ISpaceSummaryRoom[], events: ISpaceSummaryEvent[]}> { const path = utils.encodeUri("/rooms/$roomId/spaces", { $roomId: roomId, });