diff --git a/app/definitions/IUser.ts b/app/definitions/IUser.ts index 474a2105e..e1746554d 100644 --- a/app/definitions/IUser.ts +++ b/app/definitions/IUser.ts @@ -22,6 +22,16 @@ export interface IPersonalAccessToken extends ILoginToken { bypassTwoFactor?: boolean; } +export interface IUserRegistered { + _id: string; + type: string; + status: UserStatus; + active: boolean; + name: string; + username: string; + __rooms: string[]; +} + export interface IUserEmailVerificationToken { token: string; address: string; diff --git a/app/definitions/rest/v1/e2e.ts b/app/definitions/rest/v1/e2e.ts index 4e41ef562..b62f312f5 100644 --- a/app/definitions/rest/v1/e2e.ts +++ b/app/definitions/rest/v1/e2e.ts @@ -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[]; + }; + }; }; diff --git a/app/definitions/rest/v1/teams.ts b/app/definitions/rest/v1/teams.ts index 29047149d..cc6bfd620 100644 --- a/app/definitions/rest/v1/teams.ts +++ b/app/definitions/rest/v1/teams.ts @@ -1,7 +1,16 @@ import { IRoom } from '../../IRoom'; +import { ITeam, TEAM_TYPE } from '../../ITeam'; export type TeamsEndpoints = { 'teams.removeRoom': { POST: (params: { roomId: string; teamId: string }) => { room: IRoom }; }; + 'teams.create': { + POST: (params: { + name: string; + users: string[]; + type: TEAM_TYPE; + room: { readOnly: boolean; extraData: { broadcast: boolean; encrypted: boolean } }; + }) => { team: ITeam }; + }; }; diff --git a/app/definitions/rest/v1/user.ts b/app/definitions/rest/v1/user.ts index 7de12aabf..b8c37cc17 100644 --- a/app/definitions/rest/v1/user.ts +++ b/app/definitions/rest/v1/user.ts @@ -1,4 +1,4 @@ -import { IUser } from '../../IUser'; +import { IUser, IUserRegistered } from '../../IUser'; export type UserEndpoints = { 'users.info': { @@ -11,4 +11,7 @@ export type UserEndpoints = { success: boolean; }; }; + 'users.register': { + POST: (params: { name: string; email: string; username: string; pass: string }) => { user: IUserRegistered }; + }; }; diff --git a/app/lib/encryption/room.ts b/app/lib/encryption/room.ts index a68ccc49f..ee3519207 100644 --- a/app/lib/encryption/room.ts +++ b/app/lib/encryption/room.ts @@ -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) => { if (user?.e2e?.public_key) { const { public_key: publicKey } = user.e2e; const userKey = await SimpleCrypto.RSA.importKey(EJSON.parse(publicKey)); diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index a3f148f0a..b5947efae 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -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 => @@ -69,10 +67,8 @@ export const updateJitsiTimeout = (roomId: string): any => // @ts-ignore sdk.post('video-conference/jitsi.update-timeout', { roomId }); -export const register = (credentials: any): any => +export const register = (credentials: { name: string; email: string; pass: string; username: string }) => // RC 0.50.0 - // TODO: missing definitions from server - // @ts-ignore sdk.post('users.register', credentials); export const forgotPassword = (email: string): any => @@ -152,7 +148,7 @@ export const createTeam = ({ readOnly: boolean; broadcast: boolean; encrypted: boolean; -}): any => { +}) => { const params = { name, users, @@ -166,8 +162,6 @@ export const createTeam = ({ } }; // RC 3.13.0 - // TODO: missing definitions from server - // @ts-ignore return sdk.post('teams.create', params); }; export const addRoomsToTeam = ({ teamId, rooms }: { teamId: string; rooms: string[] }): any =>