Skip to content

Commit d93b1db

Browse files
committed
review
1 parent 5c01a2d commit d93b1db

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

src/client.ts

+8
Original file line numberDiff line numberDiff line change
@@ -7942,6 +7942,14 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
79427942
return this.http.authedRequest(Method.Put, path, undefined, body);
79437943
}
79447944

7945+
/**
7946+
* This will encrypt the payload for all devices in the list and will queue it.
7947+
* The type of the sent to-device message will be `m.room.encrypted`.
7948+
* @param eventType - The type of event to send
7949+
* @param devices - The list of devices to send the event to. Each device is
7950+
* @param payload - The payload to send. This will be encrypted.
7951+
* @returns Promise which resolves once queued.
7952+
*/
79457953
public async encryptAndSendToDevice(
79467954
eventType: string,
79477955
devices: { userId: string; deviceId: string }[],

src/embedded.ts

+3-23
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,6 @@ interface IStateEventRequest {
6262
stateKey?: string;
6363
}
6464

65-
export interface OlmDevice {
66-
/**
67-
* The user ID of the device owner.
68-
*/
69-
userId: string;
70-
/**
71-
* The device ID of the device.
72-
*/
73-
deviceId: string;
74-
}
75-
7665
export interface ICapabilities {
7766
/**
7867
* Event types that this client expects to send.
@@ -464,6 +453,9 @@ export class RoomWidgetClient extends MatrixClient {
464453
return {};
465454
}
466455

456+
/**
457+
* by {@link MatrixClient.encryptAndSendToDevice}.
458+
*/
467459
public async encryptAndSendToDevice(
468460
eventType: string,
469461
devices: { userId: string; deviceId: string }[],
@@ -511,18 +503,6 @@ export class RoomWidgetClient extends MatrixClient {
511503
.catch(timeoutToConnectionError);
512504
}
513505

514-
public async encryptAndSendToDevices(userDeviceInfoArr: OlmDevice[], payload: object): Promise<void> {
515-
// map: user Id → device Id → payload
516-
const contentMap: MapWithDefault<string, Map<string, object>> = new MapWithDefault(() => new Map());
517-
for (const { userId, deviceId } of userDeviceInfoArr) {
518-
contentMap.getOrCreate(userId).set(deviceId, payload);
519-
}
520-
521-
await this.widgetApi
522-
.sendToDevice((payload as { type: string }).type, true, recursiveMapToObject(contentMap))
523-
.catch(timeoutToConnectionError);
524-
}
525-
526506
/**
527507
* Send an event to a specific list of devices via the widget API. Optionally encrypts the event.
528508
*

src/matrixrtc/IKeyTransport.ts

+8
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,17 @@ export interface IKeyTransport {
4545
*/
4646
sendKey(keyBase64Encoded: string, index: number, members: CallMembership[]): Promise<void>;
4747

48+
/** Subscribe to keys from this transport. */
4849
on(event: KeyTransportEvents.ReceivedKeys, listener: KeyTransportEventListener): this;
50+
/** Unsubscribe to keys from this transport. */
4951
off(event: KeyTransportEvents.ReceivedKeys, listener: KeyTransportEventListener): this;
5052

53+
/** Once start is called the underlying transport will subscribe to its transport system.
54+
* Before start is called this transport will not emit any events.
55+
*/
5156
start(): void;
57+
/** Once stop is called the underlying transport will unsubscribe from its transport system.
58+
* After stop is called this transport will not emit any events.
59+
*/
5260
stop(): void;
5361
}

src/matrixrtc/MatrixRTCSession.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
380380
}
381381
// Create Encryption manager
382382
let transport;
383-
if (joinConfig?.useExperimentalToDeviceTransport == true) {
383+
if (joinConfig?.useExperimentalToDeviceTransport) {
384384
logger.info("Using experimental to-device transport for encryption keys");
385385
transport = new ToDeviceKeyTransport(
386386
this.client.getUserId()!,

0 commit comments

Comments
 (0)