Skip to content

Commit 5ff81fa

Browse files
committed
Widen platform support for iOS 12 and tvOS 12
1 parent aeb4a40 commit 5ff81fa

16 files changed

+27
-4
lines changed

Package.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import PackageDescription
66
let package = Package(
77
name: "UID2",
88
defaultLocalization: "en",
9+
// NB: The UID2 framework code only runs on iOS 13 & tvOS 13, however this allows
10+
// integration in apps supporting iOS 12.
911
platforms: [
10-
.iOS(.v13),
11-
.tvOS(.v13)
12+
.iOS(.v12),
13+
.tvOS(.v12)
1214
],
1315
products: [
1416
.library(

Sources/UID2/CryptoUtil.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import CryptoKit
99
import Foundation
1010
import SwiftASN1
1111

12+
@available(iOS 13, tvOS 13, *)
1213
struct CryptoUtil: Sendable {
1314
// Parses a server's public key and returns a newly generated public key and symmetric key.
1415
var parseKey: @Sendable (_ string: String) throws -> (SymmetricKey, P256.KeyAgreement.PublicKey)
@@ -17,6 +18,7 @@ struct CryptoUtil: Sendable {
1718
var encrypt: @Sendable (_ data: Data, _ key: SymmetricKey, _ authenticatedData: Data) throws -> AES.GCM.SealedBox
1819
}
1920

21+
@available(iOS 13, tvOS 13, *)
2022
extension CryptoUtil {
2123
private static let serverPublicKeyPrefixLength = 9
2224

Sources/UID2/Extensions/PublicKey+Extensions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import CryptoKit
99
import Foundation
1010
import SwiftASN1
1111

12+
@available(iOS 13, tvOS 13, *)
1213
extension P256.KeyAgreement.PublicKey {
1314
// CryptoKit's implementation is only available in iOS 14
1415
var derRepresentation: Data {

Sources/UID2/Extensions/URLSession+Extensions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import Foundation
99

10+
@available(iOS 13, tvOS 13, *)
1011
extension URLSession: NetworkSession {
1112

1213
func loadData(for request: URLRequest) async throws -> (Data, HTTPURLResponse) {

Sources/UID2/Internal/Broadcaster.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22

33
/// Send a value to multiple observers
4+
@available(iOS 13, tvOS 13, *)
45
actor Broadcaster<Element: Sendable> {
56
typealias Identifier = UUID
67
private var continuations: [Identifier: AsyncStream<Element>.Continuation] = [:]

Sources/UID2/Internal/Queue.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Foundation
33
/// When bridging from a sync to async context using multiple `Task`s, order of execution is not guaranteed.
44
/// Using an `AsyncStream` we can bridge enqueued work to an async context within a single `Task`.
55
/// https://forums.swift.org/t/a-pitfall-when-using-didset-and-task-together-order-cant-be-guaranteed/71311/6
6+
@available(iOS 13, tvOS 13, *)
67
final class Queue {
78
typealias Operation = @Sendable () async -> Void
89
private let continuation: AsyncStream<Operation>.Continuation

Sources/UID2/KeychainManager.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import Foundation
66
import Security
77

8+
@available(iOS 13, tvOS 13, *)
89
extension Storage {
910
static func keychainStorage() -> Storage {
1011
let storage = KeychainManager()
@@ -17,6 +18,7 @@ extension Storage {
1718
}
1819

1920
/// Securely manages data in the Keychain
21+
@available(iOS 13, tvOS 13, *)
2022
actor KeychainManager {
2123

2224
private let attrAccount = "uid2"

Sources/UID2/Networking/ClientGenerate.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import CryptoKit
99
import Foundation
1010

1111
extension Request {
12+
13+
@available(iOS 13, tvOS 13, *)
1214
static func clientGenerate(
1315
payload: Data,
1416
initializationVector: Data,
@@ -54,6 +56,7 @@ struct ClientGeneratePayload: Encodable {
5456
}
5557
}
5658

59+
@available(iOS 13, tvOS 13, *)
5760
extension ClientGeneratePayload {
5861
init(_ identity: IdentityType) {
5962
switch identity {
@@ -87,6 +90,7 @@ struct ClientGenerateRequestBody: Encodable {
8790
}
8891
}
8992

93+
@available(iOS 13, tvOS 13, *)
9094
fileprivate extension String {
9195
func sha256hash() -> Data {
9296
let digest = SHA256.hash(data: Data(self.utf8))

Sources/UID2/Networking/DataEnvelope.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import CryptoKit
99
import Foundation
1010

11+
@available(iOS 13, tvOS 13, *)
1112
internal enum DataEnvelope {
1213

1314
/// Decrypts raw response envelope data, which is expected to be a base64 encoded string.

Sources/UID2/Networking/NetworkSession.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import Foundation
99

1010
/// Common interface for networking and unit testing
11+
@available(iOS 13, tvOS 13, *)
1112
protocol NetworkSession: Sendable {
1213

1314
func loadData(for request: URLRequest) async throws -> (Data, HTTPURLResponse)

0 commit comments

Comments
 (0)