feat: add TIKeychainUtils playground with SingleValueStorage examples
This commit is contained in:
parent
5ca564476a
commit
43a12e322f
|
|
@ -66,9 +66,16 @@ let package = Package(
|
|||
.target(name: "TISwiftUICore", dependencies: ["TIUIKitCore", "TISwiftUtils"], path: "TISwiftUICore/Sources"),
|
||||
|
||||
// MARK: - Utils
|
||||
|
||||
.target(name: "TISwiftUtils", path: "TISwiftUtils/Sources"),
|
||||
.target(name: "TIFoundationUtils", dependencies: ["TISwiftUtils"], path: "TIFoundationUtils", exclude: ["TIFoundationUtils.app"]),
|
||||
.target(name: "TIKeychainUtils", dependencies: ["TIFoundationUtils", "KeychainAccess"], path: "TIKeychainUtils/Sources"),
|
||||
|
||||
.target(name: "TIKeychainUtils",
|
||||
dependencies: ["TIFoundationUtils", "KeychainAccess"],
|
||||
path: "TIKeychainUtils/Sources",
|
||||
exclude: ["../TIKeychainUtils.app"],
|
||||
plugins: [.plugin(name: "TISwiftLintPlugin")]),
|
||||
|
||||
.target(name: "TITableKitUtils", dependencies: ["TIUIElements", "TableKit"], path: "TITableKitUtils/Sources"),
|
||||
.target(name: "TIDeeplink", dependencies: ["TIFoundationUtils"], path: "TIDeeplink", exclude: ["TIDeeplink.app"]),
|
||||
.target(name: "TIDeveloperUtils", dependencies: ["TISwiftUtils", "TIUIKitCore", "TIUIElements"], path: "TIDeveloperUtils/Sources"),
|
||||
|
|
@ -80,7 +87,11 @@ let package = Package(
|
|||
path: "TINetworking/Sources",
|
||||
plugins: [.plugin(name: "TISwiftLintPlugin")]),
|
||||
|
||||
.target(name: "TIMoyaNetworking", dependencies: ["TINetworking", "TIFoundationUtils", "Moya"], path: "TIMoyaNetworking"),
|
||||
.target(name: "TIMoyaNetworking",
|
||||
dependencies: ["TINetworking", "TIFoundationUtils", "Moya"],
|
||||
path: "TIMoyaNetworking",
|
||||
plugins: [.plugin(name: "TISwiftLintPlugin")]),
|
||||
|
||||
.target(name: "TINetworkingCache", dependencies: ["TIFoundationUtils", "TINetworking", "Cache"], path: "TINetworkingCache/Sources"),
|
||||
|
||||
// MARK: - Maps
|
||||
|
|
@ -96,7 +107,7 @@ let package = Package(
|
|||
.target(name: "TITextProcessing",
|
||||
dependencies: [.product(name: "Antlr4", package: "antlr4")],
|
||||
path: "TITextProcessing/Sources",
|
||||
exclude: ["TITextProcessing.app"]),
|
||||
exclude: ["../TITextProcessing.app"]),
|
||||
|
||||
.binaryTarget(name: "SwiftLintBinary",
|
||||
url: "https://github.com/realm/SwiftLint/releases/download/0.52.2/SwiftLintBinary-macos.artifactbundle.zip",
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ LICENSE
|
|||
|
||||
- [TIFoundationUtils](docs/tifoundationutils)
|
||||
* [AsyncOperation](docs/tifoundationutils/asyncoperation.md)
|
||||
- [TIKeychainUtils](docs/tikeychainutils)
|
||||
* [SingleValueStorage](docs/tikeychainutils/singlevaluestorage.md)
|
||||
- [TIUIElements](docs/tiuielements)
|
||||
* [Skeletons](docs/tiuielements/skeletons.md)
|
||||
* [Placeholders](docs/tiuielements/placeholder.md)
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ import Foundation
|
|||
|
||||
open class DefaultAuthSettingsStorage: AuthSettingsStorage {
|
||||
public enum Defaults {
|
||||
public static var shouldResetAuthDataKey: String {
|
||||
"shouldResetAuthData"
|
||||
public static var shouldResetAuthDataKey: StorageKey<Bool> {
|
||||
.init(rawValue: "shouldResetAuthData")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ open class DefaultAuthSettingsStorage: AuthSettingsStorage {
|
|||
}
|
||||
|
||||
public init(defaultsStorage: UserDefaults = .standard,
|
||||
storageKey: String = Defaults.shouldResetAuthDataKey) {
|
||||
storageKey: StorageKey<Bool> = Defaults.shouldResetAuthDataKey) {
|
||||
|
||||
self.reinstallChecker = AppReinstallChecker(defaultsStorage: defaultsStorage,
|
||||
storageKey: storageKey)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
ENV["DEVELOPMENT_INSTALL"] = "true"
|
||||
|
||||
target 'TIModuleName' do
|
||||
platform :ios, 11
|
||||
use_frameworks!
|
||||
|
||||
pod 'TIFoundationUtils', :path => '../../../../TIFoundationUtils/TIFoundationUtils.podspec'
|
||||
pod 'TISwiftUtils', :path => '../../../../TISwiftUtils/TISwiftUtils.podspec'
|
||||
pod 'TIKeychainUtils', :path => '../../../../TIKeychainUtils/TIKeychainUtils.podspec'
|
||||
pod 'KeychainAccess'
|
||||
end
|
||||
|
|
@ -22,7 +22,9 @@
|
|||
|
||||
import TIFoundationUtils
|
||||
|
||||
open class AppInstallLifetimeSingleValueStorage<Storage: SingleValueStorage>: SingleValueStorage where Storage.ErrorType == StorageError {
|
||||
open class AppInstallLifetimeSingleValueStorage<Storage: SingleValueStorage>: SingleValueStorage
|
||||
where Storage.ErrorType == StorageError {
|
||||
|
||||
public let appReinstallChecker: AppReinstallChecker
|
||||
public let wrappedStorage: Storage
|
||||
|
||||
|
|
@ -77,6 +79,6 @@ public extension SingleValueStorage {
|
|||
where Self.ErrorType == ErrorType {
|
||||
|
||||
AppInstallLifetimeSingleValueStorage(storage: self,
|
||||
appReinstallChecker: reinstallChecker)
|
||||
appReinstallChecker: reinstallChecker)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ open class BaseSingleValueKeychainStorage<ValueType>: BaseSingleValueStorage<Val
|
|||
Result { try keychain.contains(storageKey.rawValue) }
|
||||
.mapError { StorageError.unableToExtractData(underlyingError: $0) }
|
||||
}
|
||||
|
||||
|
||||
let deleteValueClosure: DeleteValueClosure = { keychain, storageKey in
|
||||
Result { try keychain.remove(storageKey.rawValue) }
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import TIFoundationUtils
|
|||
|
||||
public final class StringValueKeychainStorage: BaseSingleValueKeychainStorage<String> {
|
||||
public init(keychain: Keychain, storageKey: StorageKey<String>) {
|
||||
let getValueClosure: BaseSingleValueKeychainStorage<String>.GetValueClosure = { keychain, storageKey in
|
||||
let getValueClosure: GetValueClosure = { keychain, storageKey in
|
||||
do {
|
||||
guard let value = try keychain.get(storageKey.rawValue) else {
|
||||
return .failure(.valueNotFound)
|
||||
|
|
@ -37,7 +37,7 @@ public final class StringValueKeychainStorage: BaseSingleValueKeychainStorage<St
|
|||
}
|
||||
}
|
||||
|
||||
let setValueClosure: BaseSingleValueKeychainStorage<String>.SetValueClosure = { keychain, value, storageKey in
|
||||
let setValueClosure: SetValueClosure = { keychain, value, storageKey in
|
||||
do {
|
||||
return .success(try keychain.set(value, key: storageKey.rawValue))
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
# gitignore nef files
|
||||
**/build/
|
||||
**/nef/
|
||||
LICENSE
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>launcher</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>AppIcon</string>
|
||||
<key>CFBundleIconName</key>
|
||||
<string>AppIcon</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.fortysevendeg.nef</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.14</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2019 The nef Authors. All rights reserved.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
## gitignore nef files
|
||||
**/build/
|
||||
**/nef/
|
||||
LICENSE
|
||||
|
||||
## User data
|
||||
**/xcuserdata/
|
||||
podfile.lock
|
||||
**.DS_Store
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
## CocoaPods
|
||||
**Pods**
|
||||
|
||||
## Carthage
|
||||
**Carthage**
|
||||
|
||||
## SPM
|
||||
.build
|
||||
.swiftpm
|
||||
swiftpm
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
ENV["DEVELOPMENT_INSTALL"] = "true"
|
||||
|
||||
target 'TIKeychainUtils' do
|
||||
platform :ios, 11
|
||||
use_frameworks!
|
||||
|
||||
pod 'TIFoundationUtils', :path => '../../../../TIFoundationUtils/TIFoundationUtils.podspec'
|
||||
pod 'TISwiftUtils', :path => '../../../../TISwiftUtils/TISwiftUtils.podspec'
|
||||
pod 'TIKeychainUtils', :path => '../../../../TIKeychainUtils/TIKeychainUtils.podspec'
|
||||
pod 'KeychainAccess'
|
||||
end
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*:
|
||||
# `SingleValueStorage` - протокол для доступа к значению которое может храниться в Keychain, UserDefaults или ещё где-то.
|
||||
|
||||
Позволяет:
|
||||
|
||||
- инкапсулировать внутри себя логику получения, записи и удаления значения
|
||||
- добавлять дополнительную логику для получения или изменения значений через композицию или наследование
|
||||
- ограничить доступ к данным в UserDefaults или Keychain в разных частях приложения
|
||||
|
||||
*/
|
||||
|
||||
/*:
|
||||
### `StringValueKeychainStorage`
|
||||
|
||||
Класс для работы со строковым значением нахоящимся в keychain (самый частый кейс)
|
||||
*/
|
||||
|
||||
import TIKeychainUtils
|
||||
import TIFoundationUtils
|
||||
import KeychainAccess
|
||||
|
||||
extension StorageKey {
|
||||
static var apiToken: StorageKey<String> {
|
||||
.init(rawValue: "apiToken")
|
||||
}
|
||||
|
||||
static var deleteApiToken: StorageKey<Bool> {
|
||||
.init(rawValue: "deleteApiToken")
|
||||
}
|
||||
}
|
||||
|
||||
let apiTokenKeychainStorage = StringValueKeychainStorage(keychain: keychain, storageKey: .apiToken)
|
||||
|
||||
if apiTokenKeychainStorage.hasStoredValue() {
|
||||
// app wasn't reinstalled, open auth user flow, perform requests
|
||||
} else {
|
||||
// show login screen
|
||||
// ...
|
||||
|
||||
// login
|
||||
|
||||
// switch await userService.login() {
|
||||
// case .success:
|
||||
// // open auth user flow, perform requests
|
||||
// case .failure:
|
||||
// // show login screen
|
||||
// }
|
||||
}
|
||||
|
||||
/*:
|
||||
### `AppInstallLifetimeSingleValueStorage<SingleValueStorage>`
|
||||
|
||||
Класс позволяющий добавить дополнительную функциональность очистки значения по конкретному ключу в keychain
|
||||
после переустановки приложения
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
let defaults = UserDefaults.standard // or AppGroup defaults
|
||||
|
||||
let appReinstallChecker = AppReinstallChecker(defaultsStorage: defaults,
|
||||
storageKey: .deleteApiToken)
|
||||
|
||||
let appInstallAwareTokenStorage = apiTokenKeychainStorage.appInstallLifetimeStorage(reinstallChecker: appReinstallChecker)
|
||||
|
||||
if appInstallAwareTokenStorage.hasStoredValue() {
|
||||
// app wasn't reinstalled, token is exist
|
||||
} else {
|
||||
// app was reinstalled or token is empty
|
||||
// ...
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import UIKit
|
||||
|
||||
public protocol NefPlaygroundLiveViewable {}
|
||||
extension UIView: NefPlaygroundLiveViewable {}
|
||||
extension UIViewController: NefPlaygroundLiveViewable {}
|
||||
|
||||
#if NOT_IN_PLAYGROUND
|
||||
public enum Nef {
|
||||
public enum Playground {
|
||||
public static func liveView(_ view: NefPlaygroundLiveViewable) {}
|
||||
public static func needsIndefiniteExecution(_ state: Bool) {}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
import PlaygroundSupport
|
||||
|
||||
public enum Nef {
|
||||
public enum Playground {
|
||||
public static func liveView(_ view: NefPlaygroundLiveViewable) {
|
||||
PlaygroundPage.current.liveView = (view as! PlaygroundLiveViewable)
|
||||
}
|
||||
|
||||
public static func needsIndefiniteExecution(_ state: Bool) {
|
||||
PlaygroundPage.current.needsIndefiniteExecution = state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='6.0' target-platform='ios' display-mode='raw' buildActiveScheme='true'/>
|
||||
|
|
@ -0,0 +1,396 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
419F8E81EC23E596305C14C1 /* Pods_TIKeychainUtils.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9558DC3B75CF88D5A98670 /* Pods_TIKeychainUtils.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
02F7E6D0F4B151F4585D0961 /* Pods-TIKeychainUtils.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TIKeychainUtils.debug.xcconfig"; path = "Target Support Files/Pods-TIKeychainUtils/Pods-TIKeychainUtils.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
1A9558DC3B75CF88D5A98670 /* Pods_TIKeychainUtils.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TIKeychainUtils.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
7D43492919D876D7B5F60316 /* Pods-TIKeychainUtils.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TIKeychainUtils.release.xcconfig"; path = "Target Support Files/Pods-TIKeychainUtils/Pods-TIKeychainUtils.release.xcconfig"; sourceTree = "<group>"; };
|
||||
8BACBE8322576CAD00266845 /* TIKeychainUtils.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TIKeychainUtils.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8BACBE8622576CAD00266845 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
8BACBE8022576CAD00266845 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
419F8E81EC23E596305C14C1 /* Pods_TIKeychainUtils.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
75FB9D9E19767EA711BCA3E2 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
02F7E6D0F4B151F4585D0961 /* Pods-TIKeychainUtils.debug.xcconfig */,
|
||||
7D43492919D876D7B5F60316 /* Pods-TIKeychainUtils.release.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8B39A26221D40F8700DE2643 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8BACBE8422576CAD00266845 /* TIKeychainUtils */,
|
||||
8B39A26C21D40F8700DE2643 /* Products */,
|
||||
75FB9D9E19767EA711BCA3E2 /* Pods */,
|
||||
B96CA711C514498357DF4109 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8B39A26C21D40F8700DE2643 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8BACBE8322576CAD00266845 /* TIKeychainUtils.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8BACBE8422576CAD00266845 /* TIKeychainUtils */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8BACBE8622576CAD00266845 /* Info.plist */,
|
||||
);
|
||||
path = TIKeychainUtils;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B96CA711C514498357DF4109 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1A9558DC3B75CF88D5A98670 /* Pods_TIKeychainUtils.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
8BACBE7E22576CAD00266845 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
8BACBE8222576CAD00266845 /* TIKeychainUtils */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 8BACBE8A22576CAD00266845 /* Build configuration list for PBXNativeTarget "TIKeychainUtils" */;
|
||||
buildPhases = (
|
||||
FB020BFF1242B09050D0D379 /* [CP] Check Pods Manifest.lock */,
|
||||
8BACBE7E22576CAD00266845 /* Headers */,
|
||||
8BACBE7F22576CAD00266845 /* Sources */,
|
||||
8BACBE8022576CAD00266845 /* Frameworks */,
|
||||
8BACBE8122576CAD00266845 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = TIKeychainUtils;
|
||||
productName = TIKeychainUtils2;
|
||||
productReference = 8BACBE8322576CAD00266845 /* TIKeychainUtils.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
8B39A26321D40F8700DE2643 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1010;
|
||||
LastUpgradeCheck = 1200;
|
||||
ORGANIZATIONNAME = "47 Degrees";
|
||||
TargetAttributes = {
|
||||
8BACBE8222576CAD00266845 = {
|
||||
CreatedOnToolsVersion = 10.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 8B39A26621D40F8700DE2643 /* Build configuration list for PBXProject "TIKeychainUtils" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 8B39A26221D40F8700DE2643;
|
||||
productRefGroup = 8B39A26C21D40F8700DE2643 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
8BACBE8222576CAD00266845 /* TIKeychainUtils */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
8BACBE8122576CAD00266845 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
FB020BFF1242B09050D0D379 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-TIKeychainUtils-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
8BACBE7F22576CAD00266845 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
8B39A27721D40F8800DE2643 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_TESTING_SEARCH_PATHS = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
8B39A27821D40F8800DE2643 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTING_SEARCH_PATHS = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
8BACBE8822576CAD00266845 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 02F7E6D0F4B151F4585D0961 /* Pods-TIKeychainUtils.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_TIKeychainUtils_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/TIKeychainUtils/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.47deg.ios.TIKeychainUtils;
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 5;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
8BACBE8922576CAD00266845 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7D43492919D876D7B5F60316 /* Pods-TIKeychainUtils.release.xcconfig */;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_TIKeychainUtils_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/TIKeychainUtils/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.47deg.ios.TIKeychainUtils;
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 5;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
8B39A26621D40F8700DE2643 /* Build configuration list for PBXProject "TIKeychainUtils" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
8B39A27721D40F8800DE2643 /* Debug */,
|
||||
8B39A27821D40F8800DE2643 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
8BACBE8A22576CAD00266845 /* Build configuration list for PBXNativeTarget "TIKeychainUtils" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
8BACBE8822576CAD00266845 /* Debug */,
|
||||
8BACBE8922576CAD00266845 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 8B39A26321D40F8700DE2643 /* Project object */;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:TIKeychainUtils.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1200"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BACBE8222576CAD00266845"
|
||||
BuildableName = "TIKeychainUtils.framework"
|
||||
BlueprintName = "TIKeychainUtils"
|
||||
ReferencedContainer = "container:TIKeychainUtils.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BACBE8222576CAD00266845"
|
||||
BuildableName = "TIKeychainUtils.framework"
|
||||
BlueprintName = "TIKeychainUtils"
|
||||
ReferencedContainer = "container:TIKeychainUtils.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BACBE8222576CAD00266845"
|
||||
BuildableName = "TIKeychainUtils.framework"
|
||||
BlueprintName = "TIKeychainUtils"
|
||||
ReferencedContainer = "container:TIKeychainUtils.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef location = "group:TIKeychainUtils.playground"></FileRef>
|
||||
<FileRef
|
||||
location = "group:TIKeychainUtils.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2019. The nef authors.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
workspace="TIKeychainUtils.xcworkspace"
|
||||
workspacePath=$(echo "$0" | rev | cut -f2- -d '/' | rev)
|
||||
|
||||
open "`pwd`/$workspacePath/$workspace"
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
TIKeychainUtils.app/Contents/MacOS/TIKeychainUtils.playground
|
||||
|
|
@ -69,10 +69,10 @@ open class DefaultJsonNetworkService: ApiInteractor {
|
|||
}
|
||||
|
||||
open func process<B: Encodable, S: Decodable, AE: Decodable, R>(request: EndpointRequest<B, S>,
|
||||
mapSuccess: @escaping Closure<S, R>,
|
||||
mapFailure: @escaping Closure<FailureMappingInput<AE>, R>,
|
||||
mapNetworkError: @escaping Closure<MoyaError, R>,
|
||||
completion: @escaping ParameterClosure<R>) -> TIFoundationUtils.Cancellable {
|
||||
mapSuccess: @escaping Closure<S, R>,
|
||||
mapFailure: @escaping Closure<FailureMappingInput<AE>, R>,
|
||||
mapNetworkError: @escaping Closure<MoyaError, R>,
|
||||
completion: @escaping ParameterClosure<R>) -> TIFoundationUtils.Cancellable {
|
||||
|
||||
let cancellableBag = BaseCancellableBag()
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ open class DefaultJsonNetworkService: ApiInteractor {
|
|||
mapFailure: mapFailure,
|
||||
mapNetworkError: mapNetworkError,
|
||||
completion: completion)
|
||||
.add(to: cancellableBag)
|
||||
.add(to: cancellableBag)
|
||||
} catch {
|
||||
callbackQueue.async {
|
||||
completion(mapNetworkError(.encodableMapping(error)))
|
||||
|
|
@ -116,10 +116,10 @@ open class DefaultJsonNetworkService: ApiInteractor {
|
|||
}
|
||||
|
||||
open func process<S: Decodable, AE: Decodable, R>(request: SerializedRequest,
|
||||
mapSuccess: @escaping Closure<S, R>,
|
||||
mapFailure: @escaping Closure<FailureMappingInput<AE>, R>,
|
||||
mapNetworkError: @escaping Closure<MoyaError, R>,
|
||||
completion: @escaping ParameterClosure<R>) -> TIFoundationUtils.Cancellable {
|
||||
mapSuccess: @escaping Closure<S, R>,
|
||||
mapFailure: @escaping Closure<FailureMappingInput<AE>, R>,
|
||||
mapNetworkError: @escaping Closure<MoyaError, R>,
|
||||
completion: @escaping ParameterClosure<R>) -> TIFoundationUtils.Cancellable {
|
||||
|
||||
createProvider().request(request) { [jsonDecoder,
|
||||
callbackQueue,
|
||||
|
|
@ -195,12 +195,12 @@ open class DefaultJsonNetworkService: ApiInteractor {
|
|||
}
|
||||
|
||||
private static func preprocess<B, S, P: Collection>(request: EndpointRequest<B, S>,
|
||||
preprocessors: P,
|
||||
cancellableBag: BaseCancellableBag,
|
||||
completion: @escaping (Result<EndpointRequest<B, S>, Error>) -> Void)
|
||||
preprocessors: P,
|
||||
cancellableBag: BaseCancellableBag,
|
||||
completion: @escaping (Result<EndpointRequest<B, S>, Error>) -> Void)
|
||||
where P.Element == EndpointRequestPreprocessor {
|
||||
|
||||
guard let preprocessor = preprocessors.first else {
|
||||
guard let preprocessor = preprocessors.first, !cancellableBag.isCancelled else {
|
||||
completion(.success(request))
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
import TINetworking
|
||||
import TISwiftUtils
|
||||
import TIFoundationUtils
|
||||
import Alamofire
|
||||
|
||||
open class DefaultRecoverableJsonNetworkService<ApiError: Decodable & Error>: DefaultJsonNetworkService {
|
||||
public typealias EndpointResponse<S: Decodable> = EndpointRecoverableRequestResult<S, ApiError, NetworkError>
|
||||
|
|
@ -61,13 +62,19 @@ open class DefaultRecoverableJsonNetworkService<ApiError: Decodable & Error>: De
|
|||
completion: @escaping ParameterClosure<EndpointResponse<S>>) -> Cancellable {
|
||||
|
||||
Cancellables.scoped { cancellableBag in
|
||||
process(request: recoverableRequest) { (result: RequestResult<S, ApiError>) in
|
||||
process(request: recoverableRequest) { [weak self] (result: RequestResult<S, ApiError>) in
|
||||
if case let .failure(errorResponse) = result {
|
||||
Self.validateAndRepair(recoverableRequest: recoverableRequest,
|
||||
errors: [errorResponse],
|
||||
retriers: errorHandlers,
|
||||
cancellableBag: cancellableBag,
|
||||
completion: completion)
|
||||
guard let self, !cancellableBag.isCancelled else {
|
||||
completion(result.mapError { .init(failures: [$0]) })
|
||||
return
|
||||
}
|
||||
|
||||
self.recover(request: recoverableRequest,
|
||||
errorHandlers: errorHandlers,
|
||||
errorResponse: errorResponse,
|
||||
originalResult: result,
|
||||
cancellableBag: cancellableBag,
|
||||
completion: completion)
|
||||
} else {
|
||||
completion(result.mapError { .init(failures: [$0]) })
|
||||
}
|
||||
|
|
@ -86,44 +93,27 @@ open class DefaultRecoverableJsonNetworkService<ApiError: Decodable & Error>: De
|
|||
}
|
||||
}
|
||||
|
||||
private static func validateAndRepair<B, S, R: Collection>(recoverableRequest: EndpointRequest<B, S>,
|
||||
errors: [ErrorType],
|
||||
retriers: R,
|
||||
cancellableBag: BaseCancellableBag,
|
||||
completion: @escaping ParameterClosure<EndpointResponse<S>>)
|
||||
where R.Element == RequestRetrier {
|
||||
open func recover<B: Encodable, S>(request: EndpointRequest<B, S>,
|
||||
errorHandlers: [RequestRetrier],
|
||||
errorResponse: ErrorType,
|
||||
originalResult: RequestResult<S, ApiError>,
|
||||
cancellableBag: BaseCancellableBag,
|
||||
completion: @escaping ParameterClosure<EndpointResponse<S>>) {
|
||||
|
||||
guard let retrier = retriers.first, !cancellableBag.isCancelled else {
|
||||
completion(.failure(.init(failures: errors)))
|
||||
return
|
||||
}
|
||||
|
||||
retrier.validateAndRepair(errorResults: errors) { handlerResult in
|
||||
switch handlerResult {
|
||||
case let .success(retryResult):
|
||||
switch retryResult {
|
||||
case .retry, .retryWithDelay:
|
||||
validateAndRepair(recoverableRequest: recoverableRequest,
|
||||
errors: errors,
|
||||
retriers: retriers,
|
||||
cancellableBag: cancellableBag,
|
||||
completion: completion)
|
||||
case .doNotRetry, .doNotRetryWithError:
|
||||
validateAndRepair(recoverableRequest: recoverableRequest,
|
||||
errors: errors,
|
||||
retriers: retriers.dropFirst(),
|
||||
cancellableBag: cancellableBag,
|
||||
completion: completion)
|
||||
Self.validateAndRepair(request: request,
|
||||
errors: [errorResponse],
|
||||
retriers: errorHandlers,
|
||||
cancellableBag: cancellableBag) {
|
||||
switch $0 {
|
||||
case .retry, .retryWithDelay:
|
||||
self.process(request: request) {
|
||||
completion($0.mapError { .init(failures: [$0]) })
|
||||
}
|
||||
case let .failure(error):
|
||||
validateAndRepair(recoverableRequest: recoverableRequest,
|
||||
errors: errors + [error],
|
||||
retriers: retriers.dropFirst(),
|
||||
cancellableBag: cancellableBag,
|
||||
completion: completion)
|
||||
.add(to: cancellableBag)
|
||||
case .doNotRetry, .doNotRetryWithError:
|
||||
completion(originalResult.mapError { .init(failures: [$0]) })
|
||||
}
|
||||
}
|
||||
.add(to: cancellableBag)
|
||||
}
|
||||
|
||||
public func register<RequestRetrier: EndpointRequestRetrier>(defaultRequestRetrier: RequestRetrier)
|
||||
|
|
@ -137,4 +127,40 @@ open class DefaultRecoverableJsonNetworkService<ApiError: Decodable & Error>: De
|
|||
|
||||
self.defaultRequestRetriers = defaultRequestRetriers.map { $0.asAnyEndpointRequestRetrier() }
|
||||
}
|
||||
|
||||
private static func validateAndRepair<B, S, R: Collection>(request: EndpointRequest<B, S>,
|
||||
errors: [ErrorType],
|
||||
retriers: R,
|
||||
cancellableBag: BaseCancellableBag,
|
||||
completion: @escaping ParameterClosure<RetryResult>)
|
||||
where R.Element == RequestRetrier {
|
||||
|
||||
guard let retrier = retriers.first, !cancellableBag.isCancelled else {
|
||||
completion(.doNotRetry)
|
||||
return
|
||||
}
|
||||
|
||||
retrier.validateAndRepair(errorResults: errors) { handlerResult in
|
||||
switch handlerResult {
|
||||
case let .success(retryResult):
|
||||
switch retryResult {
|
||||
case .retry, .retryWithDelay:
|
||||
completion(.retry)
|
||||
case .doNotRetry, .doNotRetryWithError:
|
||||
validateAndRepair(request: request,
|
||||
errors: errors,
|
||||
retriers: retriers.dropFirst(),
|
||||
cancellableBag: cancellableBag,
|
||||
completion: completion)
|
||||
}
|
||||
case let .failure(error):
|
||||
validateAndRepair(request: request,
|
||||
errors: errors + [error],
|
||||
retriers: retriers.dropFirst(),
|
||||
cancellableBag: cancellableBag,
|
||||
completion: completion)
|
||||
}
|
||||
}
|
||||
.add(to: cancellableBag)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ import Foundation
|
|||
|
||||
open class DefaultFingerprintsSettingsStorage: FingerprintsSettingsStorage {
|
||||
public enum Defaults {
|
||||
public static var shouldResetFingerprintsKey: String {
|
||||
"shouldResetFingerprints"
|
||||
public static var shouldResetFingerprintsKey: StorageKey<Bool> {
|
||||
.init(rawValue: "shouldResetFingerprints")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ open class DefaultFingerprintsSettingsStorage: FingerprintsSettingsStorage {
|
|||
}
|
||||
|
||||
public init(defaultsStorage: UserDefaults = .standard,
|
||||
storageKey: String = Defaults.shouldResetFingerprintsKey) {
|
||||
storageKey: StorageKey<Bool> = Defaults.shouldResetFingerprintsKey) {
|
||||
|
||||
self.reinstallChecker = AppReinstallChecker(defaultsStorage: defaultsStorage, storageKey: storageKey)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ public extension ApiInteractor {
|
|||
process(request: request,
|
||||
mapSuccess: mapSuccess,
|
||||
mapFailure: mapFailure,
|
||||
mapNetworkError: mapNetworkError, completion: $0)
|
||||
mapNetworkError: mapNetworkError,
|
||||
completion: $0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ open class DefaultSecuritySchemePreprocessor: SecuritySchemePreprocessor {
|
|||
completion(.failure(ValueNotProvidedError()))
|
||||
return
|
||||
}
|
||||
|
||||
completion(.success(value))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 39109c6e6032b2a59f4cdd7b80ac06c4dc8b33c0
|
||||
Subproject commit 318e0ce0215da8c790f9a4ea945d1773cb35687f
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
# `SingleValueStorage` - протокол для доступа к значению которое может храниться в Keychain, UserDefaults или ещё где-то.
|
||||
|
||||
Позволяет:
|
||||
|
||||
- инкапсулировать внутри себя логику получения, записи и удаления значения
|
||||
- добавлять дополнительную логику для получения или изменения значений через композицию или наследование
|
||||
- ограничить доступ к данным в UserDefaults или Keychain в разных частях приложения
|
||||
|
||||
|
||||
### `StringValueKeychainStorage`
|
||||
|
||||
Класс для работы со строковым значением нахоящимся в keychain (самый частый кейс)
|
||||
|
||||
```swift
|
||||
import TIKeychainUtils
|
||||
import TIFoundationUtils
|
||||
import KeychainAccess
|
||||
|
||||
extension StorageKey {
|
||||
static var apiToken: StorageKey<String> {
|
||||
.init(rawValue: "apiToken")
|
||||
}
|
||||
|
||||
static var deleteApiToken: StorageKey<Bool> {
|
||||
.init(rawValue: "deleteApiToken")
|
||||
}
|
||||
}
|
||||
|
||||
let apiTokenKeychainStorage = StringValueKeychainStorage(keychain: keychain, storageKey: .apiToken)
|
||||
|
||||
if apiTokenKeychainStorage.hasStoredValue() {
|
||||
// app wasn't reinstalled, open auth user flow, perform requests
|
||||
} else {
|
||||
// show login screen
|
||||
// ...
|
||||
|
||||
// login
|
||||
|
||||
// switch await userService.login() {
|
||||
// case .success:
|
||||
// // open auth user flow, perform requests
|
||||
// case .failure:
|
||||
// // show login screen
|
||||
// }
|
||||
}
|
||||
```
|
||||
|
||||
### `AppInstallLifetimeSingleValueStorage<SingleValueStorage>`
|
||||
|
||||
Класс позволяющий добавить дополнительную функциональность очистки значения по конкретному ключу в keychain
|
||||
после переустановки приложения
|
||||
|
||||
```swift
|
||||
import Foundation
|
||||
|
||||
let defaults = UserDefaults.standard // or AppGroup defaults
|
||||
|
||||
let appReinstallChecker = AppReinstallChecker(defaultsStorage: defaults,
|
||||
storageKey: .deleteApiToken)
|
||||
|
||||
let appInstallAwareTokenStorage = apiTokenKeychainStorage.appInstallLifetimeStorage(reinstallChecker: appReinstallChecker)
|
||||
|
||||
if appInstallAwareTokenStorage.hasStoredValue() {
|
||||
// app wasn't reinstalled, token is exist
|
||||
} else {
|
||||
// app was reinstalled or token is empty
|
||||
// ...
|
||||
}
|
||||
```
|
||||
Loading…
Reference in New Issue