diff --git a/TwoFAS/Common/GlobalTypes/TokenType.swift b/TwoFAS/Common/GlobalTypes/TokenType.swift index a741831f..5eebdc3e 100644 --- a/TwoFAS/Common/GlobalTypes/TokenType.swift +++ b/TwoFAS/Common/GlobalTypes/TokenType.swift @@ -22,6 +22,8 @@ import Foundation public enum TokenType: String, CaseIterable, Equatable { case totp = "TOTP" case hotp = "HOTP" + // TODO: Add support for Steam + // case steam = "STEAM" public static var defaultValue: Self { .totp diff --git a/TwoFAS/TwoFAS.xcodeproj/project.pbxproj b/TwoFAS/TwoFAS.xcodeproj/project.pbxproj index 17a8a4bf..6fccd5bf 100644 --- a/TwoFAS/TwoFAS.xcodeproj/project.pbxproj +++ b/TwoFAS/TwoFAS.xcodeproj/project.pbxproj @@ -9374,7 +9374,7 @@ "@executable_path/Frameworks", ); MACH_O_TYPE = mh_execute; - MARKETING_VERSION = 5.1.1; + MARKETING_VERSION = 5.1.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; OTHER_LDFLAGS = ( "$(OTHER_LDFLAGS)", @@ -9416,7 +9416,7 @@ "@executable_path/Frameworks", ); MACH_O_TYPE = mh_execute; - MARKETING_VERSION = 5.1.1; + MARKETING_VERSION = 5.1.2; OTHER_LDFLAGS = ( "$(OTHER_LDFLAGS)", "-ObjC", @@ -9702,7 +9702,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 5.1.1; + MARKETING_VERSION = 5.1.2; PRODUCT_BUNDLE_IDENTIFIER = com.twofas.org.TwoFASAuth; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -9730,7 +9730,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 5.1.1; + MARKETING_VERSION = 5.1.2; PRODUCT_BUNDLE_IDENTIFIER = com.twofas.org.TwoFASAuth; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -10048,7 +10048,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 5.1.1; + MARKETING_VERSION = 5.1.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.twofas.org.TwoFASWidget; @@ -10078,7 +10078,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 5.1.1; + MARKETING_VERSION = 5.1.2; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.twofas.org.TwoFASWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -10105,7 +10105,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 5.1.1; + MARKETING_VERSION = 5.1.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.twofas.org.TwoFASServiceIntent; @@ -10133,7 +10133,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 5.1.1; + MARKETING_VERSION = 5.1.2; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.twofas.org.TwoFASServiceIntent; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor+Parsers.swift b/TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor+Parsers.swift index 8c481362..0034da73 100644 --- a/TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor+Parsers.swift +++ b/TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor+Parsers.swift @@ -70,8 +70,8 @@ extension ImportFromFileInteractor { switch services { case .twoFAS(let servicesList): return parseTwoFASServicesV12(with: servicesList, sections: sections) - case .twoFASV3(let servicesList): - return parseTwoFASServicesV3(with: servicesList, sections: sections) + case .twoFASV34(let servicesList): + return parseTwoFASServicesV34(with: servicesList, sections: sections) } } @@ -151,8 +151,8 @@ extension ImportFromFileInteractor { } } - func parseTwoFASServicesV3(with services: [ExchangeData2.Service], sections: [CommonSectionData]) -> [ServiceData] { - Log("Parsing 2FAS Backup File V3", module: .interactor) + func parseTwoFASServicesV34(with services: [ExchangeData2.Service], sections: [CommonSectionData]) -> [ServiceData] { + Log("Parsing 2FAS Backup File V3/V4", module: .interactor) let date = Date() return services .sorted { $0.order.position < $1.order.position } @@ -203,6 +203,13 @@ extension ImportFromFileInteractor { return secID }() + if item.otp.tokenType?.uppercased() == "STEAM" { + // TODO: Add support for Steam + return nil + } + + let tokenType = TokenType.create(item.otp.tokenType) + let secret = item.secret.sanitazeSecret() guard secret.isValidSecret() else { return nil } @@ -225,7 +232,7 @@ extension ImportFromFileInteractor { isTrashed: false, trashingDate: nil, counter: item.otp.counter, - tokenType: TokenType.create(item.otp.tokenType), + tokenType: tokenType, source: .link, otpAuth: otpAuth, order: item.order.position, diff --git a/TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor.swift b/TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor.swift index c46c77b0..8340ae3b 100644 --- a/TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor.swift +++ b/TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor.swift @@ -121,8 +121,9 @@ extension ImportFromFileInteractor: ImportFromFileInteracting { func parseContent(_ data: Data) -> ImportFromFileParsing? { Log("ImportFromFileInteractor - parseContent", module: .interactor) if let services = try? jsonDecoder.decode(ExchangeData2.self, from: data), - services.schemaVersion == ExchangeConsts.schemaVersionV3 { - return .twoFAS(.twoFASV3(services)) + services.schemaVersion == ExchangeConsts.schemaVersionV3 || + services.schemaVersion == ExchangeConsts.schemaVersionV4 { + return .twoFAS(.twoFASV34(services)) } if let services = try? jsonDecoder.decode(ExchangeData.self, from: data) { diff --git a/TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeConsts.swift b/TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeConsts.swift index 2b671366..557e2bbd 100644 --- a/TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeConsts.swift +++ b/TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeConsts.swift @@ -21,7 +21,8 @@ import Foundation enum ExchangeConsts { static let schemaVersionV3: Int = 3 - static let schemaVersion: Int = 3 + static let schemaVersionV4: Int = 4 + static let schemaVersion: Int = 4 static let fileNameStart = "Backup_" static let fileNameEnd = ".2fas" static let `extension` = "bak" diff --git a/TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeDataFormat.swift b/TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeDataFormat.swift index a29c0be2..7682fa15 100644 --- a/TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeDataFormat.swift +++ b/TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeDataFormat.swift @@ -22,12 +22,12 @@ import Common enum ExchangeDataFormat { case twoFAS(ExchangeData) - case twoFASV3(ExchangeData2) + case twoFASV34(ExchangeData2) } enum ExchangeDataServices { case twoFAS([ExchangeData.Service]) - case twoFASV3([ExchangeData2.Service]) + case twoFASV34([ExchangeData2.Service]) } extension ExchangeDataFormat { @@ -35,7 +35,7 @@ extension ExchangeDataFormat { switch self { case .twoFAS(let exchangeData): return exchangeData.schemaVersion - case .twoFASV3(let exchangeData): + case .twoFASV34(let exchangeData): return exchangeData.schemaVersion } } @@ -44,7 +44,7 @@ extension ExchangeDataFormat { switch self { case .twoFAS(let exchangeData): return exchangeData.servicesEncrypted != nil && exchangeData.reference != nil - case .twoFASV3(let exchangeData): + case .twoFASV34(let exchangeData): return exchangeData.servicesEncrypted != nil && exchangeData.reference != nil } } @@ -53,7 +53,7 @@ extension ExchangeDataFormat { switch self { case .twoFAS(let exchangeData): return exchangeData.reference - case .twoFASV3(let exchangeData): + case .twoFASV34(let exchangeData): return exchangeData.reference } } @@ -62,7 +62,7 @@ extension ExchangeDataFormat { switch self { case .twoFAS(let exchangeData): return exchangeData.servicesEncrypted - case .twoFASV3(let exchangeData): + case .twoFASV34(let exchangeData): return exchangeData.servicesEncrypted } } @@ -71,8 +71,8 @@ extension ExchangeDataFormat { switch self { case .twoFAS(let exchangeData): return .twoFAS(exchangeData.services) - case .twoFASV3(let exchangeData2): - return .twoFASV3(exchangeData2.services) + case .twoFASV34(let exchangeData2): + return .twoFASV34(exchangeData2.services) } } @@ -83,11 +83,11 @@ extension ExchangeDataFormat { return nil } return .twoFAS(services) - case .twoFASV3: + case .twoFASV34: guard let services = try? jsonDecoder.decode([ExchangeData2.Service].self, from: data) else { return nil } - return .twoFASV3(services) + return .twoFASV34(services) } } @@ -105,7 +105,7 @@ extension ExchangeDataFormat { isCollapsed: !item.isExpanded ) }) ?? [] - case .twoFASV3(let exchangeData): + case .twoFASV34(let exchangeData): return exchangeData.groups? .compactMap({ item in guard let id = UUID(uuidString: item.id) else { return nil }