From f77e1760ad990d38c1df2a7fa05e5a65761ed7e1 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 24 Sep 2024 10:00:16 -0300 Subject: [PATCH 1/6] feat: E2EE messages mentions (#5744) --- app/lib/constants/defaultSettings.ts | 6 ++++++ app/lib/encryption/room.ts | 2 ++ app/lib/encryption/utils.ts | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/app/lib/constants/defaultSettings.ts b/app/lib/constants/defaultSettings.ts index ab1b4ea150..290d447ff7 100644 --- a/app/lib/constants/defaultSettings.ts +++ b/app/lib/constants/defaultSettings.ts @@ -258,5 +258,11 @@ export const defaultSettings = { Accounts_ConfirmPasswordPlaceholder: { type: 'valueAsString' }, + E2E_Enabled_Mentions: { + type: 'valueAsBoolean' + }, + UTF8_User_Names_Validation: { + type: 'valueAsString' + }, ...deprecatedSettings } as const; diff --git a/app/lib/encryption/room.ts b/app/lib/encryption/room.ts index 10cd50fda0..247d6f9f87 100644 --- a/app/lib/encryption/room.ts +++ b/app/lib/encryption/room.ts @@ -16,6 +16,7 @@ import { bufferToB64, bufferToB64URI, bufferToUtf8, + getE2EEMentions, encryptAESCTR, exportAESCTR, generateAESCTRKey, @@ -245,6 +246,7 @@ export default class EncryptionRoom { t: E2E_MESSAGE_TYPE, e2e: E2E_STATUS.PENDING, msg, + e2eMentions: getE2EEMentions(message.msg), content: { algorithm: 'rc.v1.aes-sha2' as const, ciphertext: await this.encryptText( diff --git a/app/lib/encryption/utils.ts b/app/lib/encryption/utils.ts index a79a55a6cd..71787799f1 100644 --- a/app/lib/encryption/utils.ts +++ b/app/lib/encryption/utils.ts @@ -59,6 +59,24 @@ export const toString = (thing: string | ByteBuffer | Buffer | ArrayBuffer | Uin // @ts-ignore return new ByteBuffer.wrap(thing).toString('binary'); }; + +// https://github.com/RocketChat/Rocket.Chat/blob/b94db45cab297a3bcbafca4d135d83c898222380/apps/meteor/app/mentions/lib/MentionsParser.ts#L50 +const userMentionRegex = (pattern: string) => new RegExp(`(^|\\s|>)@(${pattern}(@(${pattern}))?(:([0-9a-zA-Z-_.]+))?)`, 'gm'); +const channelMentionRegex = (pattern: string) => new RegExp(`(^|\\s|>)#(${pattern}(@(${pattern}))?)`, 'gm'); + +export const getE2EEMentions = (message?: string) => { + const e2eEnabledMentions = store.getState().settings.E2E_Enabled_Mentions; + if (!e2eEnabledMentions || !message) { + return undefined; + } + const utf8UserNamesValidation = store.getState().settings.UTF8_User_Names_Validation as string; + + return { + e2eUserMentions: (message.match(userMentionRegex(utf8UserNamesValidation)) || []).map(match => match.trim()), + e2eChannelMentions: (message.match(channelMentionRegex(utf8UserNamesValidation)) || []).map(match => match.trim()) + }; +}; + export const randomPassword = async (): Promise => { const random = await Promise.all(Array.from({ length: 4 }, () => SimpleCrypto.utils.getRandomValues(3))); return `${random[0]}-${random[1]}-${random[2]}-${random[3]}`; From e1f58bc79b1e9a40028569d21c80c5ae6e49cf8c Mon Sep 17 00:00:00 2001 From: Yash Rajpal <58601732+yash-rajpal@users.noreply.github.com> Date: Tue, 24 Sep 2024 22:06:35 +0530 Subject: [PATCH 2/6] feat(a11y): Color and contrast improvements (#5869) --- app/containers/Button/Button.stories.tsx | 2 +- app/containers/Button/Button.test.tsx | 4 ++-- app/containers/Button/index.tsx | 2 +- app/containers/CallHeader.tsx | 2 +- app/containers/Check.tsx | 2 +- app/containers/TwoFactor/index.tsx | 13 +++---------- app/containers/markdown/Hashtag.tsx | 4 ++-- app/lib/constants/colors.ts | 4 ++-- .../hooks/useVideoConf/StartACallActionSheet.tsx | 8 +++----- app/lib/methods/helpers/navigation/index.ts | 6 ++++-- app/views/RoomsListView/ServersList.tsx | 4 ++-- 11 files changed, 22 insertions(+), 29 deletions(-) diff --git a/app/containers/Button/Button.stories.tsx b/app/containers/Button/Button.stories.tsx index d58fcdbe14..2ecf791037 100644 --- a/app/containers/Button/Button.stories.tsx +++ b/app/containers/Button/Button.stories.tsx @@ -4,7 +4,7 @@ import Button from '.'; const buttonProps = { title: 'Press me!', - type: 'primary', + type: 'primary' as const, onPress: () => {}, testID: 'testButton' }; diff --git a/app/containers/Button/Button.test.tsx b/app/containers/Button/Button.test.tsx index 6d89faa452..9fd76940fa 100644 --- a/app/containers/Button/Button.test.tsx +++ b/app/containers/Button/Button.test.tsx @@ -8,7 +8,7 @@ const onPressMock = jest.fn(); const testProps = { title: 'Press me!', - type: 'primary', + type: 'primary' as const, onPress: onPressMock, testID: 'testButton', initialText: 'Initial text', @@ -19,7 +19,7 @@ const TestButton = ({ loading = false, disabled = false }) => (