Merge branch 'release/v5.1.2'

This commit is contained in:
Zbigniew Cisiński 2023-11-27 22:10:50 +01:00
commit 45f0f9664e
6 changed files with 38 additions and 27 deletions

View File

@ -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

View File

@ -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)";

View File

@ -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,

View File

@ -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) {

View File

@ -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"

View File

@ -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 }