Files
bundesmessenger-ios/Config/BWIBuildSettings.swift
2022-11-16 10:28:50 +00:00

501 lines
18 KiB
Swift

//
/*
* Copyright (c) 2022 BWI GmbH
*
* 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
import KeychainAccess
@objcMembers
class BWIBuildSettings: NSObject {
static let shared = BWIBuildSettings()
private let vault: KeyValueVault
override init() {
vault = KeychainVault(Keychain(service: BwiSettingsConstants.bwiSettingsKeychainService,
accessGroup: BuildSettings.keychainAccessGroup))
super.init()
overrideTargetSpecificSettings()
}
// MARK: -
private enum UserDefaultsKeys {
static let additionalBwiHeaderKey = "bwiHeader"
}
private struct BwiSettingsConstants {
static let bwiSettingsKeychainService: String = BuildSettings.baseBundleIdentifier + ".bwi-settings-service"
}
func reset() {
additionalBwiHeader = UserAgentService().bwiUserAgentDict
let sdkOptions = MXSDKOptions.sharedInstance()
sdkOptions.httpAdditionalHeaders = UserAgentService().bwiUserAgentDict
}
// MARK: Servers
var additionalBwiHeader: Dictionary<String, String> {
get {
do {
guard let data = try vault.data(forKey: UserDefaultsKeys.additionalBwiHeaderKey) else {
return UserAgentService().bwiUserAgentDict
}
var dict = try JSONDecoder().decode(Dictionary<String,String>.self, from: data)
dict["User-Agent"] = UserAgentService().bwiUserAgent
return dict
} catch {
return UserAgentService().bwiUserAgentDict
}
} set {
do {
let data = try JSONEncoder().encode(newValue)
try vault.set(data, forKey: UserDefaultsKeys.additionalBwiHeaderKey)
} catch let error {
NSLog("[PinCodePreferences] Error when storing addional header to the vault: \(error)")
}
}
}
// MARK: -
// Integration check
var forcedPinProtection = true
// Jailbreak check
var forcedNoneJailbroken = true
/// Default number of iterations for secure storage. Do not change this value after going live.
var iterationsForSecureStorage: UInt = 100000
/// Allow split view detail view stacking
var allowSplitViewDetailsScreenStacking = true
// direct rooms are for two persons only in bwi context
var allowInviteOnDirectRooms = false
// test setup for downtime: should be false for all builds
var useTestDataForDowntime = false
var flavor = ""
var showBwiSplashScreen = false
var bwiShowRoomSearch = false
var bwiAllowRoomPermalink = false
var bwiAllowUserPermalink = false
var bwiCheckAppVersion = true
var bwiNotificationTimes = true
var bwiUserLabelsAdminSettingsVisible = true
var bwiUserLabelsMemberDetailsVisible = true
var bwiUserLabelsParticipantsVisible = true
var bwiUserLabelsTimelineDisplayNameVisible = true
var bwiUserLabelsTimelineEventVisible = true
var bwiUserLabelEventTypeString = "de.bwi.room.user_function_labels"
var bwiUserLabelParticipantSorting = true
var bwiShowClosedPolls = true
var bwiShowThreads = false
var bwiShowRoomCreationSectionFooter = false
var bwiAutoCreateAliasOnRoomCreation = true
var bwiLocationShareButtonVisible = true
var bwiUseCustomPersonalNotesAvatar = true
var bwiBetterIgnoredUsers = true
var bwiSettingsShowInAppNotifications = false
var bwiFilteredContextMenu = true
var bwiShowPinnedNotificationSettings = false
var bwiShowSessionSettingsFooter = false
var bwiEnablePersonalState = false
// In onboarding splash screen dis/enable register button
var bwiOnboardingSplashScreenEnableRegister = false
// make sure that the NSE extention always resets message body and title
var bwiHideNotificationMessageBody = true
// in Auth screen dis/enable register button even with onboarding splash screen enabled
var bwiAuthentificationScreenEnableRegister = false
// enable BuM style authentication UI (more Info text and a logo)
var bwiEnableBuMAuthentificationUI = true
// voicemessages should resignplaying when the app enters the background
var bwiResignPlayingVoiceMessageInBackground = true
// enable BUM style UI in pincode and maybe other places
var bwiEnableBuMUI = true
// clear media cache every time when leaving a room vc: no media should be saved on device for security purposes
var bwiClearMediaCacheOnRoomExit = true
var bwiEnableLoginProtection = true
var bwiHashes = [ "a3f65e35a7476799afe8d80282fb3c45b39dab06d1d8c70dc98e45ab7d8e93a9",
"2fda1a831655c22a5e6096d7cfbff4429fbf27891141e191b46adbf168142a11",
"4f8cbb3fef885f7284d0477d797d7007f0e1ba76221834132752f4d645796e28",
"24c2ec541e61e8e68944b96dc45ed5df12f6bdbda283cb0b3a522742aa970256",
"1be0b314a6c915d4475290522baef5b642db1b6d68937792b8e0eb5b7b0d6666",
"3deb73db8cafcd1d5a59e25e251c35816162e1f6ee67b5d7d011da0e8d6ef931",
"42e57985d61202c2c7dd87d898cef9bdce020877a4c7a8c7cd699f6a28f58c0c",
"e1c3c7cac12bd65bd48de79a2677187d2e768d2769377627534023588b8d7a33"]
// use a different badge color if the user was mentioned in a room
var showMentionsInRoom = true
// replace feature history link variable with the appropiate build setting
var bwiFeatureHistoryLink = "https://messenger.bwi.de/#c4783"
var bwiReplaceFeatureLink = true
// login with matrix id should only be enabled in some configurations
var bwiEnableLoginWithMatrixID = true
// show app specific loading icons instead of the rotating element logo
var showBUMLottieAnimation = true
// DMs don't need all roomsettings (like changing avatar, name, topic)
var showUnrelatedRoomSettingsForDirectMessages = false
// create rooms without shared history
var enableSharedHistoryOnRoomCreation = false
// explicitly set sdk option for key sharing => We don't want to share even if the room setting allows it
var allowKeySharingOnRoomInvite = true
// DMs don't need all roomsettings (like changing avatar, name, topic)
var allowDoubleTapOnImageAttachmentsForZoom = true
// ------ End of BwiBuildSettings ---------
// Element-Web instance for the app
var applicationWebAppUrlString = ""
// Default servers proposed on the authentication screen
var serverConfigDefaultHomeserverUrlString = ""
var serverConfigDefaultIdentityServerUrlString = ""
var serverConfigPreSelections = ["":""]
var serverConfigSygnalAPIUrlString = "https://push-local/_matrix/push/v1/notify"
// Note: Set empty strings to hide the related entry in application settings
var applicationCopyrightUrlString = "https://messenger.bwi.de/copyright"
var applicationPrivacyPolicyUrlString = ""
// MARk: - Matrix permalinks
// Paths for URLs that will considered as Matrix permalinks. Those permalinks are opened within the app
var permalinkSupportedHosts: [String: [String]] = [:]
// MARK: - VoIP
var allowVoIPUsage = false
var stunServerFallbackUrlString: String? = ""
// MARK: - Public rooms Directory
// List of homeservers for the public rooms directory
var publicRoomsDirectoryServers = ["matrix.org"]
// MARK: - Analytics
/// BWI: set host and key to nil to disable PostHog tracking
var analyticsHost: String? = nil
var analyticsKey: String? = nil
var bwiAnalyticsServerUrlString = ""
var bwiAnalyticsAppId = "1"
/// The configuration to use for analytics during development. Set `isEnabled` to false to disable analytics in debug builds.
var analyticsConfiguration = BuildSettings.AnalyticsConfiguration(isEnabled: false,
host: "",
apiKey: "",
termsURL: URL(string: "https://element.io/cookie-policy")!)
// MARK: - Bug report
var bugReportEndpointUrlString = ""
// MARK: - Integrations
// Widgets in those paths require a scalar token
var integrationsScalarWidgetsPaths = [""]
// Jitsi server used outside integrations to create conference calls from the call button in the timeline
var jitsiServerUrl = URL(string: "https://enter.jitsi.url")!
var enableJSInWebView = false
// MARK: - Features
/// Setting to force protection by pin code
var forcePinProtection = true
/// Max allowed time to continue using the app without prompting PIN
var pinCodeGraceTimeInSeconds: TimeInterval = 180
var allowLocalContactsAccess = false
var allowInviteExernalUsers = false
var enableSideMenu = false
var sideMenuShowInviteFriends = false
// MARK: - Feature Specifics
/// Not allowed pin codes. User won't be able to select one of the pin in the list.
var notAllowedPINs: [String] = [
"1234",
"1111",
"0000",
"1212",
"7777",
"1004",
"2000",
"4444",
"2222",
"6969",
"9999",
"3333",
"5555",
"6666",
"1122",
"1313",
"8888",
"4321",
"2001",
"1010",
"2580",
"4711",
"0815",
"0852"
]
var allowLocalContactPresence = false
/// Indicates should the app log out the user when number of PIN failures reaches `maxAllowedNumberOfPinFailures`. Defaults to `false`
var logOutUserWhenPINFailuresExceeded = true
/// Indicates should the app log out the user when number of biometrics failures reaches `maxAllowedNumberOfBiometricsFailures`. Defaults to `false`
var logOutUserWhenBiometricsFailuresExceeded = true
/// If force is enabled the dialog for asking if reseting the key backup is not shown.. already asked before in mandatory verfication
var forceResetBackupIfLost = true
/// if skip is enabled the key backup dialogs are passed through
var skipKeyBackupStep = true
// MARK: - Main Tabs
var homeScreenShowHomeTab = false
// MARK: - General Settings Screen
var settingsScreenAllowAddingLinkedEmails = false
var settingsScreenAllowAddingPhoneNumbers = false
var settingsScreenAllowAddingEmailThreepids = false
var settingsScreenAllowAddingPhoneThreepids = false
var settingsScreenShowThreepidExplanatory = false
var settingsScreenShowDiscoverySettings = false
var settingsScreenAllowIdentityServerConfig = false
var settingsScreenShowConfirmMediaSize = false
var settingsScreenShowAdvancedSettings = false
var settingsScreenShowLabSettings = false
var settingsScreenAllowChangingRageshakeSettings = false
var settingsScreenAllowChangingCrashUsageDataSettings = false
var settingsScreenAllowBugReportingManually = false
var settingsScreenAllowDeactivatingAccount = false
var settingsScreenShowLinkPreviews = false
var settingsScreenShowInviteFriends = false
var settingsScreenShowSettings = true
var settingsScreenShowFeedback = false
var settingsScreenShowHelp = false
var settingsScreenShowNotificationDecodedContentOption = false
var settingsScreenShowSystemSettingsOption = false
var settingsScreenShowNsfwRoomsOption = false
var settingsScreenShowSupportSetting = true
var settingsScreenSupportSettingHTML = "support"
var settingsSecurityScreenShowCryptographyInfo:Bool = false
var settingsSecurityScreenShowCryptographyExport:Bool = false
var settingsSecurityScreenShowAdvancedUnverifiedDevices:Bool = false
// MARK: - Notification Settings
var settingsNotificationsBWIDefaultSet = true
var settingsNotificationsShowDefault = true
var settingsNotificationsShowMentions = false
var settingsNotificationsShowAdvanced = false
// MARK: - Timeline settings
var roomInputToolbarCompressionMode: BuildSettings.MediaCompressionMode = .none
// MARK: - Room Creation Screen
var roomCreationScreenAllowEncryptionConfiguration = false
// MARK: - Room Screen
var roomScreenAllowStickerAction = false
// MARK: - Room Info Screen
var roomInfoScreenShowIntegrations = false
// MARK: - Room Settings Screen
var roomSettingsScreenShowLowPriorityOption = false
var roomSettingsScreenShowDirectChatOption = false
var roomSettingsScreenAllowChangingAccessSettings = false
var roomSettingsScreenAllowChangingHistorySettings = false
var roomSettingsScreenShowAddressSettings = false
var roomSettingsScreenShowAdvancedSettings = false
var roomSettingsScreenShowAccessSettingsBW = true
var roomSettingsScreenRemoveLeave = true
var roomSettingsScreenShowNotificationsV2 = false
// MARK: - Message
var messageDetailsAllowShare = false
var messageDetailsAllowPermalink = false
var messageDetailsAllowViewSource = false
var messageDetailsAllowSave = false
var messageDetailsAllowCopyMedia = false
var messageDetailsAllowPasteMedia = false
// MARK: - Authentication Screen
var authScreenShowRegister = false
var authScreenShowPhoneNumber = false
var authScreenShowForgotPassword = false
var authScreenShowCustomServerOptions = true
var authScreenShowTestServerOptions = true
var authScreenShowSocialLoginSection = false
// MARK: - Cross-signing (bwi=true)
var disableSelfUserVerification = true
// MARK: - Antivirus scan (bwi=true)
var enableAntivirusScan = false
// MARK: Verification screen (bwi=false)
var showRecoverWithKey = false
// MARK: Unified search screen (bwi=false)
var showUnifiedSearchViewMessagesTab = false
var showUnifiedSearchViewFilesTab = false
// MARK: - Onboarding
var onboardingShowAccountPersonalization = false
var onboardingEnableNewAuthenticationFlow = false
// ---
// MARK: Last message timestamp support (bwi=false)
var enableLastMessageTimestamp = false
// MARK: Invite friends in Direct Chat (bwi=false)
var directChatShowInviteFriends = false
// MARK: Last admin is not allowed to leave the room (bwi=true)
var lastAdminIsNotAllowedToLeaveRoom = true
// MARK: Room Member Details Screen (bwi=true)
var roomMemberDetailsHideLeaveButton = true
// MARK: Room create options (bwi=false)
var enableShowInRoomDirectory = false
// Mark: Unified Search (bwi=true)
var unifiedSearchScreenShowPublicDirectory = true
// MARK: Allows removal of uploaded avatar photos (bwi=true)
var enableRemoveAvatarImage = true
// MARK: Add a toggle button to the login screen to make the password visible
var passwordIndicatorOnLogin = true
// MARK: Displays the element base version on the settings screen
var elementBaseVersion = "1.9.10"
var showElementBaseVersion = true
// MARK: Bypasses the normal forgot password process by presenting the user an information alert
// (requires authScreenShowForgotPassword set to true)
var forgotPasswordInformationAlert = true
// MARK: Promote new feature within a banner below the navigation view
var showTopBanner = true
var showCustomServerDisplayName = true
var customServerDisplayName = ""
// MARK BWI show/hide developer menu
var bwiShowDeveloperSettings = false
// MARK BWI personal notes room
var bwiPersonalNotesRoom = false
var bwiPersonalNotesRoomLeavable = false
var bwiResetPersonalNotesAccountData = false
var bwiShowTimelineSettings = false
// MARK BWI personal state
var bwiPersonalState = false
// MARK BWI personal notes room
var bwiRollsAndRights = true
// MARK: Timeline
var settingsScreenShowSimpleTimeLineOptions = false
var settingsScreenShowTimeStampOption = true
var settingsScreenShowDeletedMessagesOption = false
var settingsScreenShowNameChangeOption = false
var settingsScreenShowChatEffectsOption = false
var settingsScreenShowRoomAvatarChangeOption = false
var settingsScreenShowUserAvatarChangeOption = true
var settingsScreenShowEnterRoomOption = true
var bwiLastAdminCanDowngradeHimself = false
var bwiEnableErrorTracking = false
var bwiEnableRegisterInfo = false
var bwiShowHappyBirthdayCampaign = false
var bwiHappyBirthdayCampaignIdentifier: String = "one_year_anniversary"
var bwiDisableSecuritySettingsUntrustedDevices = true
var bwiMatomoTrackingDefaultState = false
var bwiShowNewFeatures = true
// MARK: - Location Sharing
/// Overwritten by the home server's .well-known configuration (if any exists)
var defaultTileServerMapStyleURL = URL(string: "https://msgpriv.example.com/")!
// MARK: - Message Bubbles bwi show in our menu and only for beta builds
var bwiShowMessageBubbles = false
// bwi disable encrypted option in message context menu
var roomContextualMenuShowEncryptionOption = false
}