Skip to content

Commit

Permalink
Merge branch 'develop' into chore/status-bullet-colors
Browse files Browse the repository at this point in the history
  • Loading branch information
juliajforesti authored May 22, 2023
2 parents 5786b6d + 222c8ec commit 4ee9ee7
Show file tree
Hide file tree
Showing 129 changed files with 1,848 additions and 923 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-windows-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/web-ui-registration': minor
---

fix: Handle login services errors
5 changes: 5 additions & 0 deletions .changeset/cold-meals-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

feat: [ENTERPRISE] Add setting to control user merge on LDAP Background Sync
6 changes: 6 additions & 0 deletions .changeset/large-penguins-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/gazzodown': minor
'@rocket.chat/meteor': minor
---

fix: respect useEmoji preference for messages
5 changes: 5 additions & 0 deletions .changeset/mean-bottles-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixes the Livechat CSP validation, which was incorrectly blocking access to the widget for all non whitelisted domains
6 changes: 6 additions & 0 deletions .changeset/poor-pants-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/meteor': patch
---

fix: Rocket.Chat.Apps using wrong id parameter to emit settings

5 changes: 5 additions & 0 deletions .changeset/seven-rules-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/api-client': minor
---

Moved from patch monkey solution to official one
6 changes: 6 additions & 0 deletions .changeset/shy-maps-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/meteor': minor
'@rocket.chat/api-client': minor
---

ask for totp if the provided one is invalid
23 changes: 12 additions & 11 deletions apps/meteor/.meteor/packages
2 changes: 1 addition & 1 deletion apps/meteor/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
METEOR@2.11.0
METEOR@2.12
43 changes: 22 additions & 21 deletions apps/meteor/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[email protected].7
[email protected].8
[email protected]
[email protected]
[email protected]
Expand All @@ -8,30 +8,30 @@ [email protected]
[email protected]
[email protected]
[email protected]
[email protected].3
[email protected].4
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected].0
[email protected].1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
ddp-rate-limiter@1.1.1
[email protected].0
ddp-rate-limiter@1.2.0
[email protected].1
[email protected]
dispatch:[email protected]
[email protected].2
[email protected].6
[email protected].0
[email protected].3
[email protected].7
[email protected].1
[email protected]
[email protected]
[email protected]
[email protected].4
[email protected].5
[email protected]
[email protected]
[email protected]
Expand All @@ -47,21 +47,21 @@ [email protected]
kadira:[email protected]
[email protected]
[email protected]
[email protected].1
[email protected].2
[email protected]
[email protected]
meteorhacks:[email protected]
[email protected].2
[email protected].4
[email protected]
[email protected].2
[email protected].3
[email protected]
[email protected]
[email protected]
[email protected].5
[email protected].6
[email protected]
[email protected]
[email protected]
npm-mongo@4.14.0
npm-mongo@4.16.0
[email protected]
[email protected]
[email protected]
Expand All @@ -71,8 +71,8 @@ pauli:[email protected]
pauli:[email protected]
[email protected]
[email protected]
rate-limit@1.0.9
[email protected].6
rate-limit@1.1.1
[email protected].7
[email protected]
[email protected]
[email protected]
Expand All @@ -90,13 +90,14 @@ [email protected]
[email protected]
[email protected]
[email protected]
[email protected].0
[email protected].0
[email protected].1
[email protected].2
[email protected]
[email protected].1
[email protected].2
[email protected]
[email protected]
[email protected].12
[email protected].13
[email protected]
[email protected].4
[email protected].5
[email protected]
zodern:[email protected]
34 changes: 9 additions & 25 deletions apps/meteor/app/2fa/client/overrideMeteorCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Meteor } from 'meteor/meteor';
import { t } from '../../utils/lib/i18n';
import { process2faReturn, process2faAsyncReturn } from '../../../client/lib/2fa/process2faReturn';
import { isTotpInvalidError } from '../../../client/lib/2fa/utils';
import { dispatchToastMessage } from '../../../client/lib/toast';

const { call, callAsync } = Meteor;

Expand Down Expand Up @@ -35,35 +34,20 @@ const callWithoutTotp = (methodName: string, args: unknown[], callback: Callback
});
});

const callAsyncWithTotp =
(methodName: string, args: unknown[]) =>
async (twoFactorCode: string, twoFactorMethod: string): Promise<unknown> => {
try {
const result = await callAsync(methodName, ...args, { twoFactorCode, twoFactorMethod });

return result;
} catch (error: unknown) {
if (isTotpInvalidError(error)) {
dispatchToastMessage({ type: 'error', message: t('TOTP Invalid [totp-invalid]') });
throw new Error(twoFactorMethod === 'password' ? t('Invalid_password') : t('Invalid_two_factor_code'));
}

throw error;
}
};

Meteor.call = function (methodName: string, ...args: unknown[]): unknown {
const callback = args.length > 0 && typeof args[args.length - 1] === 'function' ? (args.pop() as Callback) : (): void => undefined;

return callWithoutTotp(methodName, args, callback)();
};

Meteor.callAsync = async function _callAsyncWithTotp(methodName: string, ...args: unknown[]): Promise<unknown> {
const promise = callAsync(methodName, ...args);

return process2faAsyncReturn({
promise,
onCode: callAsyncWithTotp(methodName, args),
emailOrUsername: undefined,
});
try {
return await callAsync(methodName, ...args);
} catch (error: unknown) {
return process2faAsyncReturn({
error,
onCode: (twoFactorCode, twoFactorMethod) => Meteor.callAsync(methodName, ...args, { twoFactorCode, twoFactorMethod }),
emailOrUsername: undefined,
});
}
};
2 changes: 1 addition & 1 deletion apps/meteor/app/2fa/server/code/PasswordCheckFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class PasswordCheckFallback implements ICodeCheck {
return false;
}

const passCheck = Accounts._checkPassword(user as Meteor.User, {
const passCheck = await Accounts._checkPasswordAsync(user as Meteor.User, {
digest: code.toLowerCase(),
algorithm: 'sha-256',
});
Expand Down
7 changes: 4 additions & 3 deletions apps/meteor/app/2fa/server/code/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function getMethodByNameOrFirstActiveForUser(user: IUser, name?: string): ICodeC
return Array.from(checkMethods.values()).find((method) => method.isEnabled(user));
}

function getAvailableMethodNames(user: IUser): string[] | [] {
function getAvailableMethodNames(user: IUser): string[] {
return (
Array.from(checkMethods)
.filter(([, method]) => method.isEnabled(user))
Expand Down Expand Up @@ -205,9 +205,9 @@ export async function checkCodeForUser({ user, code, method, options = {}, conne

const data = await selectedMethod.processInvalidCode(existingUser);

if (!code) {
const availableMethods = getAvailableMethodNames(existingUser);
const availableMethods = getAvailableMethodNames(existingUser);

if (!code) {
throw new Meteor.Error('totp-required', 'TOTP Required', {
method: selectedMethod.name,
...data,
Expand All @@ -220,6 +220,7 @@ export async function checkCodeForUser({ user, code, method, options = {}, conne
throw new Meteor.Error('totp-invalid', 'TOTP Invalid', {
method: selectedMethod.name,
...data,
availableMethods,
});
}

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/v1/oauthapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ API.v1.addRoute(

const { appId } = this.bodyParams;

const result = Meteor.call('updateOAuthApp', appId, this.bodyParams);
const result = await Meteor.callAsync('updateOAuthApp', appId, this.bodyParams);

return API.v1.success(result);
},
Expand All @@ -84,7 +84,7 @@ API.v1.addRoute(

const { appId } = this.bodyParams;

const result = Meteor.call('deleteOAuthApp', appId);
const result = await Meteor.callAsync('deleteOAuthApp', appId);

return API.v1.success(result);
},
Expand Down
23 changes: 14 additions & 9 deletions apps/meteor/app/apps/server/bridges/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@ import { Settings, Subscriptions } from '@rocket.chat/models';

import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';
import { isTruthy } from '../../../../lib/isTruthy';
import { deasyncPromise } from '../../../../server/deasync/deasync';

export class AppInternalBridge extends InternalBridge {
// eslint-disable-next-line no-empty-function
constructor(private readonly orch: AppServerOrchestrator) {
super();
}

protected getUsernamesOfRoomById(roomId: string): Array<string> {
protected getUsernamesOfRoomByIdSync(roomId: string): Array<string> {
return deasyncPromise(this.getUsernamesOfRoomById(roomId));
}

protected async getUsernamesOfRoomById(roomId: string): Promise<Array<string>> {
// This function will be converted to sync inside the apps-engine code
// TODO: Track Deprecation

if (!roomId) {
return [];
}

// Depends on apps engine separation to microservices
const records = Promise.await(
Subscriptions.findByRoomIdWhenUsernameExists(roomId, {
projection: {
'u.username': 1,
},
}).toArray(),
);
const records = await Subscriptions.findByRoomIdWhenUsernameExists(roomId, {
projection: {
'u.username': 1,
},
}).toArray();

if (!records || records.length === 0) {
return [];
Expand Down
6 changes: 4 additions & 2 deletions apps/meteor/app/apps/server/bridges/livechat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getRoom } from '../../../livechat/server/api/lib/livechat';
import { Livechat } from '../../../livechat/server/lib/Livechat';
import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';
import { Livechat as LivechatTyped } from '../../../livechat/server/lib/LivechatTyped';
import { deasyncPromise } from '../../../../server/deasync/deasync';

export class AppLivechatBridge extends LivechatBridge {
// eslint-disable-next-line no-empty-function
Expand All @@ -25,8 +26,9 @@ export class AppLivechatBridge extends LivechatBridge {
}

protected isOnline(departmentId?: string): boolean {
// Depends on apps engine separation to microservices
return Promise.await(Livechat.online(departmentId));
// This function will be converted to sync inside the apps-engine code
// TODO: Track Deprecation
return deasyncPromise(Livechat.online(departmentId));
}

protected async isOnlineAsync(departmentId?: string): Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/apps/server/bridges/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class AppMessageBridge extends MessageBridge {
protected async typing({ scope, id, username, isTyping }: ITypingDescriptor): Promise<void> {
switch (scope) {
case 'room':
notifications.notifyRoom(id, 'typing', username, isTyping);
notifications.notifyRoom(id, 'typing', username!, isTyping);
return;
default:
throw new Error('Unrecognized typing scope provided');
Expand Down
Loading

0 comments on commit 4ee9ee7

Please sign in to comment.