mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 01:52:44 +02:00
Update WellKnown & HomeserverConfiguration for mandatory backup
This commit is contained in:
@@ -22,14 +22,14 @@ final class HomeserverConfiguration: NSObject {
|
||||
|
||||
// Note: Use an object per configuration subject when there is multiple properties related
|
||||
let jitsi: HomeserverJitsiConfiguration
|
||||
let isE2EEByDefaultEnabled: Bool
|
||||
let encryption: HomeserverEncryptionConfiguration
|
||||
let tileServer: HomeserverTileServerConfiguration
|
||||
|
||||
init(jitsi: HomeserverJitsiConfiguration,
|
||||
isE2EEByDefaultEnabled: Bool,
|
||||
encryption: HomeserverEncryptionConfiguration,
|
||||
tileServer: HomeserverTileServerConfiguration) {
|
||||
self.jitsi = jitsi
|
||||
self.isE2EEByDefaultEnabled = isE2EEByDefaultEnabled
|
||||
self.encryption = encryption
|
||||
self.tileServer = tileServer
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,6 @@ final class HomeserverConfigurationBuilder: NSObject {
|
||||
|
||||
/// Create an `HomeserverConfiguration` from an HS Well-Known when possible otherwise it takes hardcoded values from BuildSettings by default.
|
||||
func build(from wellKnown: MXWellKnown?) -> HomeserverConfiguration {
|
||||
|
||||
let isE2EEByDefaultEnabled: Bool
|
||||
let jitsiPreferredDomain: String
|
||||
|
||||
var vectorWellKnownEncryptionConfiguration: VectorWellKnownEncryptionConfiguration?
|
||||
var vectorWellKnownJitsiConfiguration: VectorWellKnownJitsiConfiguration?
|
||||
|
||||
@@ -39,12 +35,29 @@ final class HomeserverConfigurationBuilder: NSObject {
|
||||
vectorWellKnownEncryptionConfiguration = self.getEncryptionConfiguration(from: vectorWellKnown)
|
||||
vectorWellKnownJitsiConfiguration = self.getJitsiConfiguration(from: vectorWellKnown)
|
||||
}
|
||||
|
||||
|
||||
// Encryption configuration
|
||||
// Enable E2EE by default when there is no value
|
||||
isE2EEByDefaultEnabled = vectorWellKnownEncryptionConfiguration?.isE2EEByDefaultEnabled ?? true
|
||||
let isE2EEByDefaultEnabled = vectorWellKnownEncryptionConfiguration?.isE2EEByDefaultEnabled ?? true
|
||||
// Disable mandatory secure backup when there is no value
|
||||
let isSecureBackupRequired = vectorWellKnownEncryptionConfiguration?.isSecureBackupRequired ?? false
|
||||
// Default to `MXKKeyPreSharingWhenTyping` when there is no value
|
||||
let outboundKeysPreSharingMode = vectorWellKnownEncryptionConfiguration?.outboundKeysPreSharingMode ?? .whenTyping
|
||||
// Defaults to all secure backup methods available when there is no value
|
||||
let secureBackupSetupMethods: [VectorWellKnownBackupSetupMethod]
|
||||
if let backupSetupMethods = vectorWellKnownEncryptionConfiguration?.secureBackupSetupMethods {
|
||||
secureBackupSetupMethods = backupSetupMethods.isEmpty ? VectorWellKnownBackupSetupMethod.allCases : backupSetupMethods
|
||||
} else {
|
||||
secureBackupSetupMethods = VectorWellKnownBackupSetupMethod.allCases
|
||||
}
|
||||
|
||||
let encryptionConfiguration = HomeserverEncryptionConfiguration(isE2EEByDefaultEnabled: isE2EEByDefaultEnabled,
|
||||
isSecureBackupRequired: isSecureBackupRequired,
|
||||
secureBackupSetupMethods: secureBackupSetupMethods,
|
||||
outboundKeysPreSharingMode: outboundKeysPreSharingMode)
|
||||
|
||||
// Jitsi configuration
|
||||
let jitsiPreferredDomain: String
|
||||
let jitsiServerURL: URL
|
||||
let hardcodedJitsiServerURL: URL = BuildSettings.jitsiServerUrl
|
||||
|
||||
@@ -77,7 +90,7 @@ final class HomeserverConfigurationBuilder: NSObject {
|
||||
serverURL: jitsiServerURL)
|
||||
|
||||
return HomeserverConfiguration(jitsi: jitsiConfiguration,
|
||||
isE2EEByDefaultEnabled: isE2EEByDefaultEnabled,
|
||||
encryption: encryptionConfiguration,
|
||||
tileServer: tileServerConfiguration)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// `HomeserverEncryptionConfiguration` gives encryption configuration used by homeserver
|
||||
@objcMembers
|
||||
final class HomeserverEncryptionConfiguration: NSObject {
|
||||
let isE2EEByDefaultEnabled: Bool
|
||||
let isSecureBackupRequired: Bool
|
||||
let secureBackupSetupMethods: [VectorWellKnownBackupSetupMethod]
|
||||
let outboundKeysPreSharingMode: MXKKeyPreSharingStrategy
|
||||
|
||||
init(isE2EEByDefaultEnabled: Bool,
|
||||
isSecureBackupRequired: Bool,
|
||||
secureBackupSetupMethods: [VectorWellKnownBackupSetupMethod],
|
||||
outboundKeysPreSharingMode: MXKKeyPreSharingStrategy) {
|
||||
self.isE2EEByDefaultEnabled = isE2EEByDefaultEnabled
|
||||
self.isSecureBackupRequired = isSecureBackupRequired
|
||||
self.outboundKeysPreSharingMode = outboundKeysPreSharingMode
|
||||
self.secureBackupSetupMethods = secureBackupSetupMethods
|
||||
|
||||
super.init()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user