Use the E2EE extension

This commit is contained in:
Kegan Dougal 2021-12-17 13:37:22 +00:00
parent b9af4a585c
commit 104363b1ef

View file

@ -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,
},