Merge branch 'develop' into chore.dehydrate-login-methods-from-rocketchatjs
This commit is contained in:
commit
c14a0614c9
|
@ -22,6 +22,16 @@ export interface IPersonalAccessToken extends ILoginToken {
|
||||||
bypassTwoFactor?: boolean;
|
bypassTwoFactor?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IUserRegistered {
|
||||||
|
_id: string;
|
||||||
|
type: string;
|
||||||
|
status: UserStatus;
|
||||||
|
active: boolean;
|
||||||
|
name: string;
|
||||||
|
username: string;
|
||||||
|
__rooms: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface IUserEmailVerificationToken {
|
export interface IUserEmailVerificationToken {
|
||||||
token: string;
|
token: string;
|
||||||
address: string;
|
address: string;
|
||||||
|
|
|
@ -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'>[];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
import { IRoom } from '../../IRoom';
|
import { IRoom } from '../../IRoom';
|
||||||
|
import { ITeam, TEAM_TYPE } from '../../ITeam';
|
||||||
|
|
||||||
export type TeamsEndpoints = {
|
export type TeamsEndpoints = {
|
||||||
'teams.removeRoom': {
|
'teams.removeRoom': {
|
||||||
POST: (params: { roomId: string; teamId: string }) => { room: IRoom };
|
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 };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { IUser } from '../../IUser';
|
import { IUser, IUserRegistered } from '../../IUser';
|
||||||
|
|
||||||
export type UserEndpoints = {
|
export type UserEndpoints = {
|
||||||
'users.info': {
|
'users.info': {
|
||||||
|
@ -11,4 +11,7 @@ export type UserEndpoints = {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
'users.register': {
|
||||||
|
POST: (params: { name: string; email: string; username: string; pass: string }) => { user: IUserRegistered };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -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 =>
|
||||||
|
@ -69,10 +67,8 @@ export const updateJitsiTimeout = (roomId: string): any =>
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
sdk.post('video-conference/jitsi.update-timeout', { roomId });
|
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
|
// RC 0.50.0
|
||||||
// TODO: missing definitions from server
|
|
||||||
// @ts-ignore
|
|
||||||
sdk.post('users.register', credentials);
|
sdk.post('users.register', credentials);
|
||||||
|
|
||||||
export const forgotPassword = (email: string): any =>
|
export const forgotPassword = (email: string): any =>
|
||||||
|
@ -152,7 +148,7 @@ export const createTeam = ({
|
||||||
readOnly: boolean;
|
readOnly: boolean;
|
||||||
broadcast: boolean;
|
broadcast: boolean;
|
||||||
encrypted: boolean;
|
encrypted: boolean;
|
||||||
}): any => {
|
}) => {
|
||||||
const params = {
|
const params = {
|
||||||
name,
|
name,
|
||||||
users,
|
users,
|
||||||
|
@ -166,8 +162,6 @@ export const createTeam = ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// RC 3.13.0
|
// RC 3.13.0
|
||||||
// TODO: missing definitions from server
|
|
||||||
// @ts-ignore
|
|
||||||
return sdk.post('teams.create', params);
|
return sdk.post('teams.create', params);
|
||||||
};
|
};
|
||||||
export const addRoomsToTeam = ({ teamId, rooms }: { teamId: string; rooms: string[] }): any =>
|
export const addRoomsToTeam = ({ teamId, rooms }: { teamId: string; rooms: string[] }): any =>
|
||||||
|
|
Loading…
Reference in New Issue