Skip to content

Commit 1a311c3

Browse files
authored
Merge pull request #250 from DP-3T/develop
Release 2.3.0
2 parents 68dc79c + 357f7a1 commit 1a311c3

15 files changed

+49
-10
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog for DP3T-SDK iOS
22

3+
## Version 2.3.0 (30.04.2021)
4+
- expose oldest shared keydate when calling iWasExposed
5+
36
## Version 2.2.0 (25.03.2021)
47
- Add support for international key exchange with parameter 'federationGateway'
58

DP3TSDK.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Pod::Spec.new do |spec|
33

44
spec.name = "DP3TSDK"
5-
spec.version = ENV['LIB_VERSION'] || '2.2.0'
5+
spec.version = ENV['LIB_VERSION'] || '2.3.0'
66
spec.summary = "Open protocol for COVID-19 proximity tracing using Bluetooth Low Energy on mobile devices"
77

88
spec.description = <<-DESC

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ DP3T-SDK is available through [Cocoapods](https://cocoapods.org/)
8181

8282
```ruby
8383

84-
pod 'DP3TSDK', => '2.2.0'
84+
pod 'DP3TSDK', => '2.3.0'
8585

8686
```
8787

Sources/DP3TSDK/DP3TSDK.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class DP3TSDK {
246246
func iWasExposed(onset: Date,
247247
authentication: ExposeeAuthMethod,
248248
isFakeRequest: Bool = false,
249-
callback: @escaping (Result<Void, DP3TTracingError>) -> Void) {
249+
callback: @escaping (Result<DP3TTracing.IWasExposedResult, DP3TTracingError>) -> Void) {
250250
log.trace()
251251
if !isFakeRequest,
252252
case .infected = state.infectionStatus {
@@ -299,6 +299,11 @@ class DP3TSDK {
299299
withFederationGateway = nil
300300
}
301301

302+
var oldestNonFakeKeyDate: Date? = nil
303+
if !isFakeRequest {
304+
oldestNonFakeKeyDate = Date(timeIntervalSince1970: Double(oldestRollingStartNumber) * 10 * .minute)
305+
}
306+
302307
let model = ExposeeListModel(gaenKeys: mutableKeys,
303308
withFederationGateway: withFederationGateway,
304309
fake: isFakeRequest)
@@ -313,7 +318,7 @@ class DP3TSDK {
313318
self.tracer.setEnabled(false, completionHandler: nil)
314319
}
315320

316-
callback(.success(()))
321+
callback(.success(.init(oldestKeyDate: oldestNonFakeKeyDate)))
317322
case let .failure(error):
318323
callback(.failure(.networkingError(error: error)))
319324
}

Sources/DP3TSDK/DP3TTracing.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private var instance: DP3TSDK!
2929
/// DP3TTracing
3030
public enum DP3TTracing {
3131
/// The current version of the SDK
32-
public static let frameworkVersion: String = "2.2.0"
32+
public static let frameworkVersion: String = "2.3.0"
3333

3434
/// sets global parameter values which are used throughout the sdk
3535
public static var parameters: DP3TParameters {
@@ -135,6 +135,11 @@ public enum DP3TTracing {
135135
return instance.status
136136
}
137137

138+
139+
public struct IWasExposedResult {
140+
public let oldestKeyDate: Date?
141+
}
142+
138143
/// tell the SDK that the user was exposed
139144
/// - Parameters:
140145
/// - onset: Start date of the exposure
@@ -145,7 +150,7 @@ public enum DP3TTracing {
145150
public static func iWasExposed(onset: Date,
146151
authentication: ExposeeAuthMethod,
147152
isFakeRequest: Bool = false,
148-
callback: @escaping (Result<Void, DP3TTracingError>) -> Void) {
153+
callback: @escaping (Result<IWasExposedResult, DP3TTracingError>) -> Void) {
149154
instancePrecondition()
150155
instance.iWasExposed(onset: onset,
151156
authentication: authentication,

Sources/DP3TSDK/Models/ExposeeListModel.swift

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ struct CodableDiagnosisKey: Codable, Equatable {
1818
let fake: UInt8
1919
}
2020

21+
extension CodableDiagnosisKey {
22+
var date: Date {
23+
Date(timeIntervalSince1970: TimeInterval(rollingStartNumber) * TimeInterval.minute * 10)
24+
}
25+
}
26+
2127
/// Model of the exposed person
2228
struct ExposeeListModel: Encodable {
2329
/// Diagnosis keys

Sources/DP3TSDK/Networking/ExposeeServiceClient.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ExposeeServiceClient: ExposeeServiceClientProtocol {
5454

5555
private let jwtVerifier: DP3TJWTVerifier?
5656

57-
var federationGateway: FederationGateway
57+
internal var federationGateway: FederationGateway
5858

5959
private let log = Logger(ExposeeServiceClient.self, category: "exposeeServiceClient")
6060

Tests/DP3TSDKTests/DP3TSDKTests.swift

+14-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private class MockKeyProvider: DiagnosisKeysProvider {
2626
}
2727

2828

29+
@available(iOS 12.5, *)
2930
class DP3TSDKTests: XCTestCase {
3031

3132
fileprivate var keychain: MockKeychain!
@@ -95,8 +96,18 @@ class DP3TSDKTests: XCTestCase {
9596
XCTAssertEqual(sdk.status.infectionStatus, .healthy)
9697

9798
let exp = expectation(description: "infected")
98-
keyProvider.keys = [ .init(keyData: Data(count: 16), rollingPeriod: 144, rollingStartNumber: DayDate().period, transmissionRiskLevel: 0, fake: 0) ]
99+
let oldestDate = Date(timeIntervalSinceNow: -.day * 5)
100+
keyProvider.keys = [
101+
.init(keyData: Data(count: 16), rollingPeriod: 144, rollingStartNumber: DayDate(date: oldestDate.addingTimeInterval(.day)).period, transmissionRiskLevel: 0, fake: 0),
102+
.init(keyData: Data(count: 16), rollingPeriod: 144, rollingStartNumber: DayDate(date: oldestDate).period, transmissionRiskLevel: 0, fake: 0),
103+
.init(keyData: Data(count: 16), rollingPeriod: 144, rollingStartNumber: DayDate(date: oldestDate.addingTimeInterval(.day * 2)).period, transmissionRiskLevel: 0, fake: 0),
104+
]
99105
sdk.iWasExposed(onset: .init(timeIntervalSinceNow: -.day), authentication: .none) { (result) in
106+
if case let Result.success(wrapper) = result {
107+
XCTAssertEqual(wrapper.oldestKeyDate, DayDate(date: oldestDate).dayMin)
108+
} else {
109+
XCTFail()
110+
}
100111
exp.fulfill()
101112
}
102113
wait(for: [exp], timeout: 0.1)
@@ -107,8 +118,8 @@ class DP3TSDKTests: XCTestCase {
107118
let rollingStartNumbers = Set(model!.gaenKeys.map(\.rollingStartNumber))
108119
XCTAssertEqual(rollingStartNumbers.count, model!.gaenKeys.count)
109120
var runningDate: Date?
110-
for key in model!.gaenKeys {
111-
let date = Date(timeIntervalSince1970: Double(key.rollingStartNumber) * 10 * .minute)
121+
for key in model!.gaenKeys.sorted(by: { $0.date > $1.date }) {
122+
let date = key.date
112123
guard runningDate != nil else {
113124
runningDate = date
114125
continue

Tests/DP3TSDKTests/DiagnosisKeysProviderTests.swift

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Foundation
1313
import XCTest
1414
import ExposureNotification
1515

16+
@available(iOS 12.5, *)
1617
class DiagnosisKeysProviderTests: XCTestCase {
1718

1819
var manager: MockENManager!
@@ -81,6 +82,7 @@ class DiagnosisKeysProviderTests: XCTestCase {
8182

8283
}
8384

85+
@available(iOS 12.5, *)
8486
extension ENTemporaryExposureKey {
8587
static func initialize(data: Data = Data(capacity: 16),
8688
rollingPeriod: ENIntervalNumber = UInt32(TimeInterval.day / (.minute * 10)),

Tests/DP3TSDKTests/ExposureNotificationMatcherTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Foundation
1515
import XCTest
1616
import ZIPFoundation
1717

18+
@available(iOS 12.5, *)
1819
final class ExposureNotificationMatcherTests: XCTestCase {
1920
var keychain = MockKeychain()
2021

Tests/DP3TSDKTests/ExposureNotificationTracerTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@testable import DP3TSDK
1212
import XCTest
1313

14+
@available(iOS 12.5, *)
1415
class ExposureNotificationTracerTests: XCTestCase {
1516

1617
var manager: MockENManager!

Tests/DP3TSDKTests/ExposureWindowTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import XCTest
1313
import ExposureNotification
1414

1515

16+
@available(iOS 12.5, *)
1617
class ExposureWindowTests: XCTestCase {
1718
func testDayGroupingSingle(){
1819
var windows: [MockWindow] = []

Tests/DP3TSDKTests/Mocks/MockENManager.swift

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import Foundation
1313
import ExposureNotification
1414

15+
@available(iOS 12.5, *)
1516
class MockENManager: ENManager {
1617
var activateCallbacks: [ENErrorHandler] = []
1718

@@ -108,6 +109,7 @@ class MockENManager: ENManager {
108109
}
109110
}
110111

112+
@available(iOS 12.5, *)
111113
class MockSummary: ENExposureDetectionSummary {
112114
override var attenuationDurations: [NSNumber] {
113115
get {

Tests/DP3TSDKTests/Mocks/MockScanInstance.swift

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import Foundation
1212
import ExposureNotification
1313

14+
@available(iOS 12.5, *)
1415
class MockScanInstance: ENScanInstance {
1516

1617
private var internalTypicalAttenuation: ENAttenuation

Tests/DP3TSDKTests/Mocks/MockWindow.swift

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import Foundation
1212
import ExposureNotification
1313

14+
@available(iOS 12.5, *)
1415
class MockWindow: ENExposureWindow {
1516
private var internalDate: Date
1617
private var internalScanInstances: [ENScanInstance]

0 commit comments

Comments
 (0)