Chore: Migrate REST API - e2eGetUsersOfRoomWithoutKey to Typescript (#3793)

* Chore: Migrate REST API - e2eGetUsersOfRoomWithoutKey to Typescript

* Update app/definitions/rest/v1/e2e.ts

Co-authored-by: Gleidson Daniel Silva <gleidson10daniel@hotmail.com>

Co-authored-by: Gleidson Daniel Silva <gleidson10daniel@hotmail.com>
This commit is contained in:
Reinaldo Neto 2022-03-02 16:53:41 -03:00 committed by GitHub
parent 79f585a361
commit d506de9f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -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'>[];
};
};
};

View File

@ -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));

View File

@ -41,10 +41,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 =>