Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/definitions/rest/v1/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { IUser } from '../../IUser';

export type E2eEndpoints = {
'e2e.setUserPublicAndPrivateKeys': {
POST: (params: { public_key: string; private_key: string }) => void;
};
'e2e.getUsersOfRoomWithoutKey': {
GET: (params: { rid: string }) => {
users: Pick<IUser, '_id' | 'e2e'>[];
};
};
};
4 changes: 2 additions & 2 deletions app/lib/encryption/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ export default class EncryptionRoom {
const result = await RocketChat.e2eGetUsersOfRoomWithoutKey(this.roomId);
if (result.success) {
const { users } = result;
await Promise.all(users.map((user: IUser) => this.encryptRoomKeyForUser(user)));
await Promise.all(users.map(user => this.encryptRoomKeyForUser(user)));
}
};

// Encrypt the room key to each user in
encryptRoomKeyForUser = async (user: IUser) => {
encryptRoomKeyForUser = async (user: Pick<IUser, '_id' | 'e2e'>) => {
if (user?.e2e?.public_key) {
const { public_key: publicKey } = user.e2e;
const userKey = await SimpleCrypto.RSA.importKey(EJSON.parse(publicKey));
Expand Down
4 changes: 1 addition & 3 deletions app/lib/rocketchat/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ export const e2eRequestSubscriptionKeys = (): any =>
// RC 0.72.0
sdk.methodCallWrapper('e2e.requestSubscriptionKeys');

export const e2eGetUsersOfRoomWithoutKey = (rid: string): any =>
export const e2eGetUsersOfRoomWithoutKey = (rid: string) =>
// RC 0.70.0
// TODO: missing definitions from server
// @ts-ignore
sdk.get('e2e.getUsersOfRoomWithoutKey', { rid });

export const e2eSetRoomKeyID = (rid: string, keyID: string): any =>
Expand Down