Skip to content

Commit

Permalink
Release version 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Team Mobile Schorsch committed May 6, 2022
1 parent 91a41ad commit 9ad10de
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let package = Package(
// .package(url: /* package url */, from: "1.0.0"),

.package(name: "TrustKit", url: "https://github.com/datatheorem/TrustKit.git", from: "2.0.0"),
.package(name: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("1.2.1")),
.package(name: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("1.3.0")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="./GiniBank_Logo.png" width="250">
<img src="./GiniBank_Logo" width="250">
</p>

# Gini Bank API Library Pinning for iOS
Expand Down
46 changes: 41 additions & 5 deletions Sources/GiniBankAPILibraryPinning/GiniBankAPI+Pinning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,48 @@ import TrustKit
import GiniBankAPILibrary

public extension GiniBankAPI.Builder {

/**
* Creates a Gini Bank API Library with certificate pinning configuration.
*
* - Parameter client: The Gini Bank API client credentials
* - Parameter api: The Gini Bank API that the library interacts with. `APIDomain.default` by default
* - Parameter userApi: The Gini User API that the library interacts with. `UserDomain.default` by default
* - Parameter pinningConfig: Configuration for certificate pinning.
* - Parameter logLevel: The log level. `LogLevel.none` by default.
*/
init(client: Client,
api: APIDomain = .default,
pinningConfig: [String: Any],
logLevel: LogLevel = .none) {
self.init(client: client, api: api, logLevel: logLevel)

api: APIDomain = .default,
userApi: UserDomain = .default,
pinningConfig: [String: Any],
logLevel: LogLevel = .none) {
self.init(client: client, api: api, userApi: userApi, logLevel: logLevel, sessionDelegate: SessionDelegate())
TrustKit.initSharedInstance(withConfiguration: pinningConfig)
}

/**
* Creates a Gini Bank API Library to be used with a transparent proxy and a custom api access token source and certificate pinning configuration.
*
* - Parameter customApiDomain: A custom api domain string.
* - Parameter alternativeTokenSource: A protocol for using custom api access token
* - Parameter pinningConfig: Configuration for certificate pinning.
* - Parameter logLevel: The log level. `LogLevel.none` by default.
*/
init(customApiDomain: String,
alternativeTokenSource: AlternativeTokenSource,
pinningConfig: [String: Any],
logLevel: LogLevel = .none) {
self.init(customApiDomain: customApiDomain, alternativeTokenSource: alternativeTokenSource, logLevel: logLevel, sessionDelegate: SessionDelegate())
TrustKit.initSharedInstance(withConfiguration: pinningConfig)
}
}

class SessionDelegate: NSObject, URLSessionDelegate {
public func urlSession(_ session: URLSession,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
if TrustKit.sharedInstance().pinningValidator.handle(challenge, completionHandler: completionHandler) == false {
completionHandler(.performDefaultHandling, nil)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// Created by Nadya Karaban on 15.10.21.
//

public let GiniBankAPILibraryPinningVersion = "1.2.0"
public let GiniBankAPILibraryPinningVersion = "1.3.0"

0 comments on commit 9ad10de

Please sign in to comment.