From f162e225677051c184ba612141dbb83eaf962755 Mon Sep 17 00:00:00 2001 From: Kyle Hammond Date: Sun, 11 Feb 2024 11:58:23 -0600 Subject: [PATCH 1/5] Issue #5: Added support for visionOS. --- CHANGELOG.md | 4 ++++ LICENSE | 2 +- Package.resolved | 4 ++-- Package.swift | 9 +++++---- README.md | 9 +++++---- Sources/Haversack/Documentation.docc/Haversack.md | 2 +- Sources/Haversack/Haversack+AsyncAwait.swift | 4 ++-- Sources/Haversack/Haversack.swift | 10 +++++----- .../GenericPasswordConvertible+CryptoKit.swift | 12 ++++++------ Sources/HaversackCryptoKit/SecKeyConvertible.swift | 14 +++++++------- .../HaversackTests/HaversackAsyncAwaitTests.swift | 10 +++------- 11 files changed, 41 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 987743e..55dce3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.3.0] - 2024-02-11 +### Added +- Added support for visionOS. + ## [1.1.1] - 2024-01-05 ### Changed - System keychain is located using Security framework API. diff --git a/LICENSE b/LICENSE index fb2aef2..0826045 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright 2023, Jamf +Copyright 2024, Jamf Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Package.resolved b/Package.resolved index 8816dca..ad0205c 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-collections", "state" : { - "revision" : "d029d9d39c87bed85b1c50adee7c41795261a192", - "version" : "1.0.6" + "revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb", + "version" : "1.1.0" } }, { diff --git a/Package.swift b/Package.swift index c17956b..73644ab 100644 --- a/Package.swift +++ b/Package.swift @@ -1,6 +1,6 @@ -// swift-tools-version:5.6 +// swift-tools-version:5.9 // SPDX-License-Identifier: MIT -// Copyright 2023, Jamf +// Copyright 2024, Jamf import PackageDescription @@ -10,6 +10,7 @@ let package = Package( .macOS(.v10_13), .iOS(.v12), .tvOS(.v12), + .visionOS(.v1), .watchOS(.v5) ], products: [ @@ -18,8 +19,8 @@ let package = Package( .library(name: "HaversackMock", targets: ["HaversackMock"]) ], dependencies: [ - .package(url: "https://github.com/apple/swift-collections", from: "1.0.4"), - .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.2.0") + .package(url: "https://github.com/apple/swift-collections", from: "1.1.0"), + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0") ], targets: [ .target(name: "Haversack", dependencies: [ diff --git a/README.md b/README.md index 37528de..732209a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # Haversack: Swift library for keychain access -A Swift library for interacting with the Keychain on all Apple devices. Supports macOS, iOS/iPadOS, tvOS, and watchOS. +A Swift library for interacting with the Keychain on all Apple devices. Supports macOS, iOS/iPadOS, tvOS, visionOS, and watchOS. ## Goal @@ -130,12 +130,13 @@ Before submitting your pull request, please do the following: - If you are adding new commands or features, they should include unit tests. If you are changing functionality, update the tests or add new tests as needed. - Verify all unit tests pass on all four supported operating systems. There are two ways to do this: - 1. In Xcode you can switch destinations to each of the following: "My Mac", any iOS Simulator, any tvOS Simulator, and any watchOS Simulator. Run the unit tests for each of the destinations. - 2. Four command line invocations: + 1. In Xcode you can switch destinations to each of the following: "My Mac", any iOS Simulator, any tvOS Simulator, any visionOS Simulator, and any watchOS Simulator. Run the unit tests for each of the destinations. + 2. Five command line invocations: - `swift test` to verify macOS functionality. - `xcodebuild test -scheme Haversack-Package -destination 'platform=iOS Simulator,name=iPhone 14'` to verify iOS functionality. - `xcodebuild test -scheme Haversack-Package -destination 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)'` to verify tvOS functionality. - - `xcodebuild test -scheme Haversack-Package -destination 'platform=watchOS Simulator,name=Apple Watch Series 8 (41mm)` to verify watchOS functionality. + - `xcodebuild test -scheme Haversack-Package -destination 'platform=watchOS Simulator,name=Apple Watch Series 9 (41mm)'` to verify watchOS functionality. + - `xcodebuild test -scheme Haversack-Package -destination 'platform=visionOS Simulator,name=Apple Vision Pro'` to verify visionOS functionality. - Run [SwiftLint](https://github.com/realm/SwiftLint) on the code. Fix any warnings or errors that appear. - Add a note to the CHANGELOG describing what you changed. - If your pull request is related to an issue, add a link to the issue in the description. diff --git a/Sources/Haversack/Documentation.docc/Haversack.md b/Sources/Haversack/Documentation.docc/Haversack.md index 14fcf5e..87d5a2a 100644 --- a/Sources/Haversack/Documentation.docc/Haversack.md +++ b/Sources/Haversack/Documentation.docc/Haversack.md @@ -1,6 +1,6 @@ # ``Haversack`` -A type-safe fluent interface for the keychain on macOS, iOS/iPadOS, tvOS, and watchOS. +A type-safe fluent interface for the keychain on macOS, iOS/iPadOS, tvOS, visionOS, and watchOS. ## Overview diff --git a/Sources/Haversack/Haversack+AsyncAwait.swift b/Sources/Haversack/Haversack+AsyncAwait.swift index e675478..28dfba3 100644 --- a/Sources/Haversack/Haversack+AsyncAwait.swift +++ b/Sources/Haversack/Haversack+AsyncAwait.swift @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -// Copyright 2023, Jamf +// Copyright 2024, Jamf import Foundation -@available(macOS 10.15.0, iOS 13.0.0, tvOS 13.0.0, watchOS 6.0, *) +@available(macOS 10.15.0, iOS 13.0.0, tvOS 13.0.0, watchOS 6.0, visionOS 1.0, *) extension Haversack { /// This is equivalent to calling ``first(where:completionQueue:completion:)`` but using async-await syntax. public func first(where query: T) async throws -> T.Entity { diff --git a/Sources/Haversack/Haversack.swift b/Sources/Haversack/Haversack.swift index ffbe602..1c6586b 100644 --- a/Sources/Haversack/Haversack.swift +++ b/Sources/Haversack/Haversack.swift @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright 2023, Jamf +// Copyright 2024, Jamf import Foundation @@ -371,8 +371,8 @@ public struct Haversack { /// Synchronously delete an item from the keychain that was previously retrieved from the keychain. /// - /// If the item does not include a `reference` previously retrieved from the keychain: on iOS/tvOS/watchOS all items - /// matching the item metadata will be deleted, while on macOS only the first matching item will be deleted. + /// If the item does not include a `reference` previously retrieved from the keychain: on iOS/tvOS/visionOS/watchOS + /// all items matching the item metadata will be deleted, while on macOS only the first matching item will be deleted. /// - Parameter item: The item retrieved from the keychain. /// - Parameter treatNotFoundAsSuccess: If true, no error is thrown when the query does not /// find an item to delete; default is true. @@ -385,8 +385,8 @@ public struct Haversack { /// Aynchronously delete an item from the keychain that was previously retrieved from the keychain. /// - /// If the item does not include a `reference` previously retrieved from the keychain: on iOS/tvOS/watchOS all items - /// matching the item metadata will be deleted, while on macOS only the first matching item will be deleted. + /// If the item does not include a `reference` previously retrieved from the keychain: on iOS/tvOS/visionOS/watchOS + /// all items matching the item metadata will be deleted, while on macOS only the first matching item will be deleted. /// - Parameters: /// - item: The item retrieved from the keychain. /// - treatNotFoundAsSuccess: If true, no error is thrown when the query does not find an diff --git a/Sources/HaversackCryptoKit/GenericPasswordConvertible+CryptoKit.swift b/Sources/HaversackCryptoKit/GenericPasswordConvertible+CryptoKit.swift index 54a6f45..d82f557 100644 --- a/Sources/HaversackCryptoKit/GenericPasswordConvertible+CryptoKit.swift +++ b/Sources/HaversackCryptoKit/GenericPasswordConvertible+CryptoKit.swift @@ -1,25 +1,25 @@ // SPDX-License-Identifier: MIT -// Copyright 2023, Jamf +// Copyright 2024, Jamf import CryptoKit import Foundation import Haversack -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension Curve25519.KeyAgreement.PrivateKey: GenericPasswordConvertible { public static func make(fromRaw data: Data) throws -> Self { return try Self.init(rawRepresentation: data) } } -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension Curve25519.Signing.PrivateKey: GenericPasswordConvertible { public static func make(fromRaw data: Data) throws -> Self { return try Self.init(rawRepresentation: data) } } -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension SymmetricKey: GenericPasswordConvertible { public static func make(fromRaw data: Data) throws -> Self { return Self.init(data: data) @@ -32,7 +32,7 @@ extension SymmetricKey: GenericPasswordConvertible { } } -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension SecureEnclave.P256.KeyAgreement.PrivateKey: GenericPasswordConvertible { public static func make(fromRaw data: Data) throws -> Self { return try Self.init(dataRepresentation: data) @@ -43,7 +43,7 @@ extension SecureEnclave.P256.KeyAgreement.PrivateKey: GenericPasswordConvertible } } -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension SecureEnclave.P256.Signing.PrivateKey: GenericPasswordConvertible { public static func make(fromRaw data: Data) throws -> Self { return try Self.init(dataRepresentation: data) diff --git a/Sources/HaversackCryptoKit/SecKeyConvertible.swift b/Sources/HaversackCryptoKit/SecKeyConvertible.swift index a1032b3..192c760 100644 --- a/Sources/HaversackCryptoKit/SecKeyConvertible.swift +++ b/Sources/HaversackCryptoKit/SecKeyConvertible.swift @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright 2023, Jamf +// Copyright 2024, Jamf import CryptoKit import Foundation @@ -17,17 +17,17 @@ public protocol SecKeyConvertible { var x963Representation: Data { get } } -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension P256.Signing.PrivateKey: SecKeyConvertible {} -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension P256.KeyAgreement.PrivateKey: SecKeyConvertible {} -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension P384.Signing.PrivateKey: SecKeyConvertible {} -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension P384.KeyAgreement.PrivateKey: SecKeyConvertible {} -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension P521.Signing.PrivateKey: SecKeyConvertible {} -@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) +@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, visionOS 1.0, *) extension P521.KeyAgreement.PrivateKey: SecKeyConvertible {} // MARK: - storage diff --git a/Tests/HaversackTests/HaversackAsyncAwaitTests.swift b/Tests/HaversackTests/HaversackAsyncAwaitTests.swift index 334d20f..f16e4f7 100644 --- a/Tests/HaversackTests/HaversackAsyncAwaitTests.swift +++ b/Tests/HaversackTests/HaversackAsyncAwaitTests.swift @@ -1,16 +1,12 @@ -// -// HaversackAsyncAwaitTests.swift -// -// -// Created by Jacob Hearst on 9/30/22. -// +// SPDX-License-Identifier: MIT +// Copyright 2024, Jamf import Foundation import Haversack import HaversackMock import XCTest -@available(macOS 10.15.0, iOS 13.0.0, tvOS 13.0.0, watchOS 6.0, *) +@available(macOS 10.15.0, iOS 13.0.0, tvOS 13.0.0, watchOS 6.0, visionOS 1.0, *) final class HaversackAsyncAwaitTests: XCTestCase { var haversack: Haversack! var strategy: HaversackEphemeralStrategy! From ce69f58b11827795c2f7258fa95f46eab9a15cf8 Mon Sep 17 00:00:00 2001 From: Kyle Hammond Date: Sun, 11 Feb 2024 12:18:08 -0600 Subject: [PATCH 2/5] Moved xcprivacy file into correct place in Resources folder. --- Package.swift | 10 +++++++--- .../Haversack/Resources/PrivacyInfo.xcprivacy | 0 2 files changed, 7 insertions(+), 3 deletions(-) rename PrivacyInfo.xcprivacy => Sources/Haversack/Resources/PrivacyInfo.xcprivacy (100%) diff --git a/Package.swift b/Package.swift index 73644ab..7257705 100644 --- a/Package.swift +++ b/Package.swift @@ -23,11 +23,15 @@ let package = Package( .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0") ], targets: [ - .target(name: "Haversack", dependencies: [ - .product(name: "OrderedCollections", package: "swift-collections")]), + .target(name: "Haversack", + dependencies: [ + .product(name: "OrderedCollections", package: "swift-collections") + ], + resources: [.process("Resources/")]), .target(name: "HaversackCryptoKit", dependencies: ["Haversack"]), .target(name: "HaversackMock", dependencies: ["Haversack"]), - .testTarget(name: "HaversackTests", dependencies: ["HaversackMock"], + .testTarget(name: "HaversackTests", + dependencies: ["HaversackMock"], resources: [.copy("TestResources/")]) ] ) diff --git a/PrivacyInfo.xcprivacy b/Sources/Haversack/Resources/PrivacyInfo.xcprivacy similarity index 100% rename from PrivacyInfo.xcprivacy rename to Sources/Haversack/Resources/PrivacyInfo.xcprivacy From aad8565b000052590c1234a6b89c161f909e2e46 Mon Sep 17 00:00:00 2001 From: Kyle Hammond Date: Sun, 11 Feb 2024 12:18:30 -0600 Subject: [PATCH 3/5] Updated our GitHub action workflows to use the latest checkout version. --- .github/workflows/swift.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 409d384..844848d 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -# Copyright 2023, Jamf +# Copyright 2024, Jamf name: UnitTests @@ -14,7 +14,7 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run macOS tests (including integration) run: swift test @@ -22,7 +22,7 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run iOS tests run: xcodebuild test -scheme Haversack-Package -destination 'platform=iOS Simulator,name=iPhone 14' - name: Run tvOS tests @@ -34,6 +34,6 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: GitHub Action for SwiftLint uses: norio-nomura/action-swiftlint@3.2.1 From 6b5266bef8905fd3465926c9f0a70a4eb20eaf60 Mon Sep 17 00:00:00 2001 From: Kyle Hammond Date: Sun, 11 Feb 2024 12:24:55 -0600 Subject: [PATCH 4/5] Reset copyright year to comply with SwiftLint requirements. --- Package.swift | 2 +- Sources/Haversack/Haversack+AsyncAwait.swift | 2 +- Sources/Haversack/Haversack.swift | 2 +- .../GenericPasswordConvertible+CryptoKit.swift | 2 +- Sources/HaversackCryptoKit/SecKeyConvertible.swift | 2 +- Tests/HaversackTests/HaversackAsyncAwaitTests.swift | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Package.swift b/Package.swift index 7257705..2f0c125 100644 --- a/Package.swift +++ b/Package.swift @@ -1,6 +1,6 @@ // swift-tools-version:5.9 // SPDX-License-Identifier: MIT -// Copyright 2024, Jamf +// Copyright 2023, Jamf import PackageDescription diff --git a/Sources/Haversack/Haversack+AsyncAwait.swift b/Sources/Haversack/Haversack+AsyncAwait.swift index 28dfba3..e59059a 100644 --- a/Sources/Haversack/Haversack+AsyncAwait.swift +++ b/Sources/Haversack/Haversack+AsyncAwait.swift @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright 2024, Jamf +// Copyright 2023, Jamf import Foundation diff --git a/Sources/Haversack/Haversack.swift b/Sources/Haversack/Haversack.swift index 1c6586b..c2d5063 100644 --- a/Sources/Haversack/Haversack.swift +++ b/Sources/Haversack/Haversack.swift @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright 2024, Jamf +// Copyright 2023, Jamf import Foundation diff --git a/Sources/HaversackCryptoKit/GenericPasswordConvertible+CryptoKit.swift b/Sources/HaversackCryptoKit/GenericPasswordConvertible+CryptoKit.swift index d82f557..5e41fac 100644 --- a/Sources/HaversackCryptoKit/GenericPasswordConvertible+CryptoKit.swift +++ b/Sources/HaversackCryptoKit/GenericPasswordConvertible+CryptoKit.swift @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright 2024, Jamf +// Copyright 2023, Jamf import CryptoKit import Foundation diff --git a/Sources/HaversackCryptoKit/SecKeyConvertible.swift b/Sources/HaversackCryptoKit/SecKeyConvertible.swift index 192c760..023c429 100644 --- a/Sources/HaversackCryptoKit/SecKeyConvertible.swift +++ b/Sources/HaversackCryptoKit/SecKeyConvertible.swift @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright 2024, Jamf +// Copyright 2023, Jamf import CryptoKit import Foundation diff --git a/Tests/HaversackTests/HaversackAsyncAwaitTests.swift b/Tests/HaversackTests/HaversackAsyncAwaitTests.swift index f16e4f7..ab5c2f1 100644 --- a/Tests/HaversackTests/HaversackAsyncAwaitTests.swift +++ b/Tests/HaversackTests/HaversackAsyncAwaitTests.swift @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright 2024, Jamf +// Copyright 2023, Jamf import Foundation import Haversack From 5a3288db3549475b5b79e7897610c4857ce38958 Mon Sep 17 00:00:00 2001 From: Kyle Hammond Date: Sun, 11 Feb 2024 12:25:10 -0600 Subject: [PATCH 5/5] Using macos-14 runner on GitHub. --- .github/workflows/swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 844848d..51279f1 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -11,7 +11,7 @@ on: jobs: Test-on-macOS: - runs-on: macos-latest + runs-on: macos-14 steps: - uses: actions/checkout@v4 @@ -19,7 +19,7 @@ jobs: run: swift test Test-on-all-others: - runs-on: macos-latest + runs-on: macos-14 steps: - uses: actions/checkout@v4