Skip to content

Commit

Permalink
Merge branch 'release/v5.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
adocyn committed Nov 27, 2023
2 parents 20040b2 + 93df63c commit 45f0f96
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
2 changes: 2 additions & 0 deletions TwoFAS/Common/GlobalTypes/TokenType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions TwoFAS/TwoFAS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)";
Expand All @@ -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;
Expand Down Expand Up @@ -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)";
Expand Down
17 changes: 12 additions & 5 deletions TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor+Parsers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }

Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions TwoFAS/TwoFAS/Interactors/ImportFromFileInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeConsts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 11 additions & 11 deletions TwoFAS/TwoFAS/MainRepository/DataTypes/ExchangeDataFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ 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 {
var schemaVersion: Int {
switch self {
case .twoFAS(let exchangeData):
return exchangeData.schemaVersion
case .twoFASV3(let exchangeData):
case .twoFASV34(let exchangeData):
return exchangeData.schemaVersion
}
}
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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)
}
}

Expand All @@ -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)
}
}

Expand All @@ -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 }
Expand Down

0 comments on commit 45f0f96

Please sign in to comment.