From 104363b1ef3a8fc14318e74567f31b8e9e3a57d1 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 17 Dec 2021 13:37:22 +0000 Subject: [PATCH] Use the E2EE extension --- src/matrix/Sync3.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/matrix/Sync3.ts b/src/matrix/Sync3.ts index 85c74db6..63f2365d 100644 --- a/src/matrix/Sync3.ts +++ b/src/matrix/Sync3.ts @@ -82,6 +82,7 @@ type RoomSubscriptionsRequest = { type ExtensionsRequest = { to_device?: ToDeviceExtensionRequest; + e2ee?: E2EEExtensionRequest; }; type ToDeviceExtensionRequest = { @@ -90,6 +91,10 @@ type ToDeviceExtensionRequest = { limit?: number; }; +type E2EEExtensionRequest = { + enabled: boolean; +}; + interface Sync3RequestBody { session_id: string; lists: Sync3List[]; @@ -133,6 +138,7 @@ interface RoomResponse { type ExtensionsResponse = { to_device?: ToDeviceExtensionResponse; + e2ee?: E2EEExtensionResponse; }; type ToDeviceExtensionResponse = { @@ -140,6 +146,11 @@ type ToDeviceExtensionResponse = { events: any[]; }; +type E2EEExtensionResponse = { + device_lists: any; + device_one_time_keys_count: any; +}; + // Some internal data structure types type IndexToRoomId = { @@ -366,6 +377,9 @@ export class Sync3 { limit: 100, since: toDeviceSince, }, + e2ee: { + enabled: true, + }, }, }; if (this.nextRoomSubscriptions.length > 0) { @@ -443,6 +457,8 @@ export class Sync3 { try { // E2EE decrypts room keys const v2DeviceResponse = { + device_one_time_keys_count: resp.extensions?.e2ee?.device_one_time_keys_count, + device_lists: resp.extensions?.e2ee?.device_lists, to_device: { events: resp.extensions?.to_device?.events, },