Skip to content

Commit 9cde874

Browse files
committed
feat: add option to force encryption
1 parent 5959271 commit 9cde874

4 files changed

Lines changed: 46 additions & 2 deletions

File tree

_locales/_untranslated_en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"prevent_dialog_spam_checkbox": {
5454
"message": "Don't allow the app to open this dialog again"
5555
},
56-
"react_more_emojis" : {
56+
"react_more_emojis": {
5757
"message": "More emojis..."
5858
},
5959
"edit_channel": {
@@ -64,5 +64,8 @@
6464
},
6565
"paste_in_qr_scanner": {
6666
"message": "Click to paste it in QR scanner"
67+
},
68+
"enforce_e2ee": {
69+
"message": "Enforce Encryption"
6770
}
6871
}

packages/frontend/scss/login/_login.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,22 @@ div.delta-form-group {
152152
}
153153
}
154154

155+
&.delta-switch {
156+
> label {
157+
display: flex;
158+
flex-direction: row;
159+
align-items: center;
160+
justify-content: space-between;
161+
width: 100%;
162+
height: auto;
163+
font-size: 15px;
164+
line-height: normal;
165+
cursor: pointer;
166+
color: var(--deltaChatPrimaryFgLight);
167+
padding-inline-end: 5px;
168+
}
169+
}
170+
155171
&.delta-input {
156172
input {
157173
appearance: none;

packages/frontend/src/components/LoginForm.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { I18nContext } from '../contexts/I18nContext'
1212
const log = getLogger('renderer/loginForm')
1313

1414
import type { Credentials } from './Settings/DefaultCredentials'
15+
import SettingsStoreInstance, { useSettingsStore } from '../stores/settings'
16+
import Switch from './Switch'
1517

1618
const Socket = {
1719
automatic: 'automatic',
@@ -42,6 +44,8 @@ export default function LoginForm({
4244
const [providerInfo, setProviderInfo] = useState<
4345
Type.ProviderInfo | undefined
4446
>()
47+
const settingsStore = useSettingsStore()[0]
48+
const forceEncryption = settingsStore?.settings['force_encryption'] !== '0'
4549

4650
const handleCredentialsChange = (
4751
event: React.ChangeEvent<HTMLInputElement>
@@ -260,7 +264,22 @@ export default function LoginForm({
260264
<option value={Socket.starttls}>STARTTLS</option>
261265
<option value={Socket.plain}>{tx('off')}</option>
262266
</DeltaSelect>
263-
267+
<div className='delta-form-group delta-switch'>
268+
<label>
269+
<span>{tx('enforce_e2ee')}</span>
270+
{/** be aware that this setting applies to all relays! */}
271+
<Switch
272+
checked={forceEncryption}
273+
disabled={settingsStore == null}
274+
onChange={() =>
275+
SettingsStoreInstance.effect.setCoreSetting(
276+
'force_encryption',
277+
forceEncryption ? '0' : '1'
278+
)
279+
}
280+
/>
281+
</label>
282+
</div>
264283
<DeltaSelect
265284
id='certificateChecks'
266285
label={tx('login_certificate_checks')}

packages/frontend/src/stores/settings.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface SettingsStoreState {
1818
bcc_self: string
1919
delete_device_after: string
2020
download_limit: string
21+
force_encryption: '0' | '1'
2122
media_quality: string
2223
is_chatmail: '0' | '1'
2324
who_can_call_me: WhoCanCallMe
@@ -36,6 +37,7 @@ const settingsKeys = [
3637
'bcc_self',
3738
'delete_device_after',
3839
'download_limit',
40+
'force_encryption',
3941
'media_quality',
4042
'is_chatmail',
4143
'who_can_call_me',
@@ -132,6 +134,10 @@ class SettingsStore extends Store<SettingsStoreState | null> {
132134
settings['ui.mentions_enabled'] = mentionsEnabledDefaultVal
133135
}
134136

137+
if (settings['force_encryption'] == null) {
138+
settings['force_encryption'] = '1'
139+
}
140+
135141
const rc = runtime.getRC_Config()
136142
this.reducer.setState({
137143
settings,

0 commit comments

Comments
 (0)