Skip to content

Commit f2c78a2

Browse files
authored
Merge pull request #141 from twofas/release/5.3.9
Merge 5.3.9
2 parents 9d09b5e + 1f20e02 commit f2c78a2

File tree

84 files changed

+1142
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1142
-230
lines changed

TwoFAS/Common/Assets/ThemeColor.xcassets/ColorDecoratedContainerButtonInverted.colorset/Contents.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
"color-space" : "srgb",
2424
"components" : {
2525
"alpha" : "1.000",
26-
"blue" : "0.137",
27-
"green" : "0.110",
28-
"red" : "0.929"
26+
"blue" : "0x22",
27+
"green" : "0x1C",
28+
"red" : "0xEC"
2929
}
3030
},
3131
"idiom" : "universal"

TwoFAS/Common/Assets/ThemeColor.xcassets/ColorHighlighed.colorset/Contents.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"color-space" : "srgb",
66
"components" : {
77
"alpha" : "1.000",
8-
"blue" : "0.480",
9-
"green" : "0.450",
10-
"red" : "1.000"
8+
"blue" : "0x7A",
9+
"green" : "0x72",
10+
"red" : "0xFF"
1111
}
1212
},
1313
"idiom" : "universal"
@@ -23,9 +23,9 @@
2323
"color-space" : "srgb",
2424
"components" : {
2525
"alpha" : "1.000",
26-
"blue" : "0.140",
27-
"green" : "0.110",
28-
"red" : "0.744"
26+
"blue" : "0x23",
27+
"green" : "0x1C",
28+
"red" : "0xBD"
2929
}
3030
},
3131
"idiom" : "universal"

TwoFAS/Common/Assets/ThemeColor.xcassets/ColorTheme.colorset/Contents.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"color-space" : "srgb",
66
"components" : {
77
"alpha" : "1.000",
8-
"blue" : "0.137",
9-
"green" : "0.110",
10-
"red" : "0.929"
8+
"blue" : "0x22",
9+
"green" : "0x1C",
10+
"red" : "0xEC"
1111
}
1212
},
1313
"idiom" : "universal"

TwoFAS/Common/Sources/Config/Config.swift

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public enum Config {
2929

3030
public enum API {
3131
public static let baseURL = URL(string: "https://api2.2fas.com")!
32+
public static let notificationsURL = URL(string: "https://notifications.2fas.com")!
3233
}
3334

3435
public enum TokenConsts {

TwoFAS/Common/Sources/Models/SortType.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import Foundation
2121

2222
public enum SortType: String, CaseIterable, Equatable {
23+
case manual
2324
case az
2425
case za
25-
case manual
2626
}

TwoFAS/Data/CodeSupport/Code+LastPass.swift

+15-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Compression
2222
import Common
2323

2424
extension Code {
25-
static func checkLastPass(with str: String) -> [Code]? {
25+
static func checkLastPass(with str: String) -> (codes: [Code], totalCodesCount: Int)? {
2626
guard let components = NSURLComponents(string: str),
2727
let scheme = components.scheme, scheme == "lpaauth-migration",
2828
let host = components.host, host == "offline",
@@ -31,9 +31,9 @@ extension Code {
3131
let value = data.value?.removingPercentEncoding,
3232
let encodeData = Data(base64Encoded: value),
3333
let decompressedData = decompress(encodeData),
34-
let codes = parseAndDecompressMainStructure(for: decompressedData)
34+
let (codes, totalCodesCount) = parseAndDecompressMainStructure(for: decompressedData)
3535
else { return nil }
36-
return codes
36+
return (codes, totalCodesCount)
3737
}
3838
}
3939

@@ -77,7 +77,7 @@ private extension Code {
7777
return decompressedData
7878
}
7979

80-
static func parseAndDecompressMainStructure(for data: Data) -> [Code]? {
80+
static func parseAndDecompressMainStructure(for data: Data) -> (codes: [Code], totalCodesCount: Int)? {
8181
let supportedVersion: Int = 3
8282
struct MainStructure: Decodable {
8383
let content: String
@@ -112,16 +112,22 @@ private extension Code {
112112
return nil
113113
}
114114

115-
return content.a.map({ parseLastPassService($0) })
115+
return (content.a.compactMap({ parseLastPassService($0) }), totalCodesCount: content.a.count)
116116
}
117117

118-
static func parseLastPassService(_ service: LastPassService) -> Code {
119-
Code(
118+
static func parseLastPassService(_ service: LastPassService) -> Code? {
119+
guard let digits = Digits(rawValue: service.d),
120+
let periodValue = service.tS,
121+
let period = Period(rawValue: periodValue),
122+
service.s.sanitazeSecret().isValidSecret()
123+
else { return nil }
124+
125+
return Code(
120126
issuer: service.iN,
121127
label: service.uN?.sanitizeInfo(),
122128
secret: service.s.sanitazeSecret(),
123-
period: .create(service.tS),
124-
digits: .create(service.d),
129+
period: period,
130+
digits: digits,
125131
algorithm: .create(service.a),
126132
tokenType: .totp,
127133
counter: 0,

TwoFAS/Data/CodeSupport/Code.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public enum CodeType: Hashable {
2424
case appStore
2525
case service(code: Code)
2626
case googleAuth(codes: [Code])
27-
case lastPass(codes: [Code])
27+
case lastPass(codes: [Code], totalCodesCount: Int)
2828
case twoFASWebExtension(extensionID: String)
2929
case support(auditID: UUID)
3030
case unknown
@@ -86,8 +86,8 @@ public extension Code {
8686
return .googleAuth(codes: codes)
8787
} else if let extensionID = Code.checkTwoFASWebExtension(with: data) {
8888
return .twoFASWebExtension(extensionID: extensionID)
89-
} else if let codes = Code.checkLastPass(with: data) {
90-
return .lastPass(codes: codes)
89+
} else if let parsedData = Code.checkLastPass(with: data) {
90+
return .lastPass(codes: parsedData.codes, totalCodesCount: parsedData.totalCodesCount)
9191
} else if Code.isAppStore(with: data) {
9292
return .appStore
9393
} else if let auditID = Code.parseSupport(with: data) {

TwoFAS/Data/Interactors/TrashingServiceInteractor.swift

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extension TrashingServiceInteractor: TrashingServiceInteracting {
4343
func trashService(_ serviceData: ServiceData) {
4444
Log("TrashingServiceInteractor - trashService", module: .interactor)
4545
mainRepository.trashService(serviceData)
46+
removeAuthRequests(for: serviceData.secret)
4647
}
4748

4849
func untrashService(_ serviceData: ServiceData) {

TwoFAS/Data/Interactors/ViewPathInteractor.swift

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public enum ViewPath: Equatable, Codable {
2929
case trash
3030
case about
3131
case appearance
32+
case appleWatch
3233
}
3334

3435
case main

TwoFAS/Data/MainRepository/MainRepositoryImpl.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ final class MainRepositoryImpl: MainRepository {
4545
let userDefaultsRepository: UserDefaultsRepository
4646
let storageRepository: StorageRepository
4747
let logDataChange: LogDataChange
48-
let networkStack = NetworkStack(baseURL: Config.API.baseURL)
48+
let networkStack = NetworkStack(
49+
baseURL: Config.API.baseURL,
50+
notificationsBaseURL: Config.API.notificationsURL
51+
)
4952
let iconDatabase: IconDescriptionDatabase = IconDescriptionDatabaseImpl()
5053
let serviceDefinitionDatabase: ServiceDefinitionDatabase = ServiceDefinitionDatabaseImpl()
5154
let iconDescriptionDatabase: IconDescriptionDatabase = IconDescriptionDatabaseImpl()

TwoFAS/NetworkStack/NetworkCall.swift

+31-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ final class NetworkCall {
2525
var noError: (() -> Void)?
2626

2727
private let baseURL: URL
28+
private let notificationsBaseURL: URL
2829
private let jsonDecoder: JSONDecoder = {
2930
let decoder = JSONDecoder()
3031
decoder.keyDecodingStrategy = .convertFromSnakeCase
@@ -60,8 +61,9 @@ final class NetworkCall {
6061
}()
6162
private let session: URLSession
6263

63-
init(baseURL: URL) {
64+
init(baseURL: URL, notificationsBaseURL: URL) {
6465
self.baseURL = baseURL
66+
self.notificationsBaseURL = notificationsBaseURL
6567
self.session = URLSession(configuration: configuration)
6668
}
6769

@@ -79,7 +81,22 @@ final class NetworkCall {
7981
dataTask.resume()
8082
}
8183
}
82-
84+
85+
func handleNotificationsCall<T: Decodable>(
86+
with request: NetworkRequestFormat,
87+
completion: @escaping (Result<T, NetworkError>) -> Void
88+
) {
89+
queue.async { [weak self] in
90+
guard let self else { return }
91+
let dataTask = self.session.dataTask(
92+
with: self.notificationsUrlRequest(for: request)
93+
) { [weak self] data, response, error in
94+
self?.completionHandler(data, response as? HTTPURLResponse, error, completion: completion)
95+
}
96+
dataTask.resume()
97+
}
98+
}
99+
83100
func handleCall(with request: NetworkRequestFormat, completion: @escaping (Result<Void, NetworkError>) -> Void) {
84101
queue.async { [weak self] in
85102
guard let self else { return }
@@ -246,7 +263,18 @@ private extension NetworkCall {
246263

247264
return urlRequest
248265
}
249-
266+
267+
func notificationsUrlRequest(for request: NetworkRequestFormat) -> URLRequest {
268+
let path = notificationsBaseURL.absoluteString + "/" + request.path
269+
guard
270+
let url = URL(string: path)
271+
else { fatalError("Network Stack: Can't create path for url: \(request.path)") }
272+
var urlRequest = URLRequest(url: url)
273+
urlRequest.httpMethod = request.method.rawValue
274+
275+
return urlRequest
276+
}
277+
250278
func urlRequest<P: Encodable>(for request: NetworkRequestFormat, data: P) -> URLRequest {
251279
let path = baseURL.absoluteString + "/" + request.path
252280
guard

TwoFAS/NetworkStack/NetworkStack.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ public final class NetworkStack {
2828
private let appVersionHandler = AppVersionHandler()
2929
private let networkHandler: NetworkStackRepositoryImpl
3030

31-
public init(baseURL: URL) {
32-
networkHandler = NetworkStackRepositoryImpl(baseURL: baseURL)
31+
public init(baseURL: URL, notificationsBaseURL: URL) {
32+
networkHandler = NetworkStackRepositoryImpl(
33+
baseURL: baseURL,
34+
notificationsBaseURL: notificationsBaseURL
35+
)
3336
}
3437
}
3538

TwoFAS/NetworkStack/NetworkStackRepositoryImpl.swift

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ import Foundation
2222
public final class NetworkStackRepositoryImpl {
2323
private let platform = "ios"
2424
private let networkCall: NetworkCall
25-
init(baseURL: URL) {
26-
self.networkCall = NetworkCall(baseURL: baseURL)
25+
init(baseURL: URL, notificationsBaseURL: URL) {
26+
self.networkCall = NetworkCall(
27+
baseURL: baseURL,
28+
notificationsBaseURL: notificationsBaseURL
29+
)
2730
networkCall.sslError = {
2831
NotificationCenter.default.post(name: .SSLNetworkErrorNotificationKey, object: nil)
2932
}
@@ -128,13 +131,13 @@ extension NetworkStackRepositoryImpl: NetworkStackRepository {
128131
)
129132
networkCall.handleCall(with: req, data: reqData, completion: completion)
130133
}
131-
134+
132135
public func listAllNews(
133136
publishedAfter: String,
134137
completion: @escaping (Result<[ListNews.NewsEntry], NetworkError>) -> Void
135138
) {
136139
let req = ListNews.Request(platform: "ios", publishedAfter: publishedAfter)
137-
networkCall.handleCall(with: req, completion: completion)
140+
networkCall.handleNotificationsCall(with: req, completion: completion)
138141
}
139142

140143
public func uploadLogs(

TwoFAS/Protection/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>5.3.8</string>
18+
<string>5.3.9</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

TwoFAS/ProtectionTests/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>5.3.8</string>
18+
<string>5.3.9</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
</dict>

TwoFAS/PushNotifications/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>5.3.8</string>
18+
<string>5.3.9</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

TwoFAS/Storage/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>5.3.8</string>
18+
<string>5.3.9</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

TwoFAS/Sync/Other/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>5.3.8</string>
18+
<string>5.3.9</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
</dict>

TwoFAS/TimeVerification/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>5.3.8</string>
18+
<string>5.3.9</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
</dict>

0 commit comments

Comments
 (0)