Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support visionOS #6

Merged
merged 5 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
# Copyright 2023, Jamf
# Copyright 2024, Jamf

name: UnitTests

Expand All @@ -11,18 +11,18 @@ on:

jobs:
Test-on-macOS:
runs-on: macos-latest
runs-on: macos-14

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run macOS tests (including integration)
run: swift test

Test-on-all-others:
runs-on: macos-latest
runs-on: macos-14

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
Expand All @@ -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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
17 changes: 11 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.6
// swift-tools-version:5.9
// SPDX-License-Identifier: MIT
// Copyright 2023, Jamf

Expand All @@ -10,6 +10,7 @@ let package = Package(
.macOS(.v10_13),
.iOS(.v12),
.tvOS(.v12),
.visionOS(.v1),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is indented too far. Maybe it's just a case of spaces not tabs or vice-versa though. Not a big deal, just looks weird on the PR.

.watchOS(.v5)
],
products: [
Expand All @@ -18,15 +19,19 @@ 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: [
.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/")])
]
)
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another spot where the indentation is different.

- 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.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Haversack/Documentation.docc/Haversack.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion Sources/Haversack/Haversack+AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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<T: KeychainQuerying>(where query: T) async throws -> T.Entity {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Haversack/Haversack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is indented too far

/// - 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.
Expand All @@ -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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears like this is indented too far

/// - Parameters:
/// - item: The item retrieved from the keychain.
/// - treatNotFoundAsSuccess: If true, no error is thrown when the query does not find an
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ 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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions Sources/HaversackCryptoKit/SecKeyConvertible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions Tests/HaversackTests/HaversackAsyncAwaitTests.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
//
// HaversackAsyncAwaitTests.swift
//
//
// Created by Jacob Hearst on 9/30/22.
//
// SPDX-License-Identifier: MIT
// Copyright 2023, 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!
Expand Down