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:
parent
79f585a361
commit
d506de9f23
|
@ -1,5 +1,12 @@
|
||||||
|
import { IUser } from '../../IUser';
|
||||||
|
|
||||||
export type E2eEndpoints = {
|
export type E2eEndpoints = {
|
||||||
'e2e.setUserPublicAndPrivateKeys': {
|
'e2e.setUserPublicAndPrivateKeys': {
|
||||||
POST: (params: { public_key: string; private_key: string }) => void;
|
POST: (params: { public_key: string; private_key: string }) => void;
|
||||||
};
|
};
|
||||||
|
'e2e.getUsersOfRoomWithoutKey': {
|
||||||
|
GET: (params: { rid: string }) => {
|
||||||
|
users: Pick<IUser, '_id' | 'e2e'>[];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -158,12 +158,12 @@ export default class EncryptionRoom {
|
||||||
const result = await RocketChat.e2eGetUsersOfRoomWithoutKey(this.roomId);
|
const result = await RocketChat.e2eGetUsersOfRoomWithoutKey(this.roomId);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const { users } = result;
|
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
|
// Encrypt the room key to each user in
|
||||||
encryptRoomKeyForUser = async (user: IUser) => {
|
encryptRoomKeyForUser = async (user: Pick<IUser, '_id' | 'e2e'>) => {
|
||||||
if (user?.e2e?.public_key) {
|
if (user?.e2e?.public_key) {
|
||||||
const { public_key: publicKey } = user.e2e;
|
const { public_key: publicKey } = user.e2e;
|
||||||
const userKey = await SimpleCrypto.RSA.importKey(EJSON.parse(publicKey));
|
const userKey = await SimpleCrypto.RSA.importKey(EJSON.parse(publicKey));
|
||||||
|
|
|
@ -41,10 +41,8 @@ export const e2eRequestSubscriptionKeys = (): any =>
|
||||||
// RC 0.72.0
|
// RC 0.72.0
|
||||||
sdk.methodCallWrapper('e2e.requestSubscriptionKeys');
|
sdk.methodCallWrapper('e2e.requestSubscriptionKeys');
|
||||||
|
|
||||||
export const e2eGetUsersOfRoomWithoutKey = (rid: string): any =>
|
export const e2eGetUsersOfRoomWithoutKey = (rid: string) =>
|
||||||
// RC 0.70.0
|
// RC 0.70.0
|
||||||
// TODO: missing definitions from server
|
|
||||||
// @ts-ignore
|
|
||||||
sdk.get('e2e.getUsersOfRoomWithoutKey', { rid });
|
sdk.get('e2e.getUsersOfRoomWithoutKey', { rid });
|
||||||
|
|
||||||
export const e2eSetRoomKeyID = (rid: string, keyID: string): any =>
|
export const e2eSetRoomKeyID = (rid: string, keyID: string): any =>
|
||||||
|
|
Loading…
Reference in New Issue