Add support for reading accounts from Element Classic.

This commit is contained in:
Mauro Romito
2025-10-10 16:44:26 +02:00
committed by Doug
parent ac56a0ba43
commit 95b3a8fbb1
18 changed files with 775 additions and 3 deletions
@@ -23,6 +23,10 @@ struct InfoPlistReader {
static let bundleURLTypes = "CFBundleURLTypes"
static let bundleURLName = "CFBundleURLName"
static let bundleURLSchemes = "CFBundleURLSchemes"
static let classicAppGroupIdentifier = "classicAppGroupIdentifier"
static let classicAppKeychainServiceIdentifier = "classicAppKeychainServiceIdentifier"
static let classicAppKeychainAccessGroupIdentifier = "classicAppKeychainAccessGroupIdentifier"
}
private enum Values {
@@ -115,8 +119,23 @@ struct InfoPlistReader {
return utType.lowercased()
}
// MARK: - Sign in with Classic app
var classicAppGroupIdentifier: String? {
infoPlistValue(forKey: Keys.classicAppGroupIdentifier)
}
var classicAppKeychainServiceIdentifier: String? {
infoPlistValue(forKey: Keys.classicAppKeychainServiceIdentifier)
}
var classicAppKeychainAccessGroupIdentifier: String? {
infoPlistValue(forKey: Keys.classicAppKeychainAccessGroupIdentifier)
}
// MARK: - Private
@_disfavoredOverload // Make sure optional types default to the optional version below.
private func infoPlistValue<T>(forKey key: String) -> T {
guard let result = bundle.object(forInfoDictionaryKey: key) as? T else {
fatalError("Add \(key) into your target's Info.plst")
@@ -124,6 +143,10 @@ struct InfoPlistReader {
return result
}
private func infoPlistValue<T>(forKey key: String) -> T? {
bundle.object(forInfoDictionaryKey: key) as? T
}
private func customSchemeForName(_ name: String) -> String {
let urlTypes: [[String: Any]] = infoPlistValue(forKey: Keys.bundleURLTypes)