Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
666374d174 |
BIN
.github/readme/app-dark.png
vendored
|
Before Width: | Height: | Size: 520 KiB After Width: | Height: | Size: 572 KiB |
BIN
.github/readme/app-light.png
vendored
|
Before Width: | Height: | Size: 519 KiB After Width: | Height: | Size: 545 KiB |
BIN
.github/readme/localize_add.png
vendored
|
Before Width: | Height: | Size: 1.3 MiB |
BIN
.github/readme/localize_sidebar.png
vendored
|
Before Width: | Height: | Size: 162 KiB |
BIN
.github/readme/localize_translate.png
vendored
|
Before Width: | Height: | Size: 1.7 MiB |
BIN
.github/readme/notification.png
vendored
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.0 MiB |
2
.github/workflows/add-to-project.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
name: Add issue to project
|
name: Add issue to project
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/add-to-project@v1.0.1
|
- uses: actions/add-to-project@v0.0.3
|
||||||
with:
|
with:
|
||||||
project-url: https://github.com/users/maxgoedjen/projects/1
|
project-url: https://github.com/users/maxgoedjen/projects/1
|
||||||
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
|
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
|
||||||
|
|||||||
8
.github/workflows/nightly.yml
vendored
@@ -6,10 +6,10 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
# runs-on: macOS-latest
|
# runs-on: macOS-latest
|
||||||
runs-on: macos-15
|
runs-on: macos-13
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
- name: Setup Signing
|
- name: Setup Signing
|
||||||
env:
|
env:
|
||||||
SIGNING_DATA: ${{ secrets.SIGNING_DATA }}
|
SIGNING_DATA: ${{ secrets.SIGNING_DATA }}
|
||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
|
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
|
||||||
run: ./.github/scripts/signing.sh
|
run: ./.github/scripts/signing.sh
|
||||||
- name: Set Environment
|
- name: Set Environment
|
||||||
run: sudo xcrun xcode-select -s /Applications/Xcode_26_beta_5.app
|
run: sudo xcrun xcode-select -s /Applications/Xcode_14.3.app
|
||||||
- name: Update Build Number
|
- name: Update Build Number
|
||||||
env:
|
env:
|
||||||
RUN_ID: ${{ github.run_id }}
|
RUN_ID: ${{ github.run_id }}
|
||||||
@@ -48,7 +48,7 @@ jobs:
|
|||||||
shasum -a 256 Secretive.zip
|
shasum -a 256 Secretive.zip
|
||||||
shasum -a 256 Archive.zip
|
shasum -a 256 Archive.zip
|
||||||
- name: Upload App to Artifacts
|
- name: Upload App to Artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: Secretive.zip
|
name: Secretive.zip
|
||||||
path: Secretive.zip
|
path: Secretive.zip
|
||||||
|
|||||||
16
.github/workflows/release.yml
vendored
@@ -7,10 +7,10 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
# runs-on: macOS-latest
|
# runs-on: macOS-latest
|
||||||
runs-on: macos-15
|
runs-on: macos-13
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v1
|
||||||
- name: Setup Signing
|
- name: Setup Signing
|
||||||
env:
|
env:
|
||||||
SIGNING_DATA: ${{ secrets.SIGNING_DATA }}
|
SIGNING_DATA: ${{ secrets.SIGNING_DATA }}
|
||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
|
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
|
||||||
run: ./.github/scripts/signing.sh
|
run: ./.github/scripts/signing.sh
|
||||||
- name: Set Environment
|
- name: Set Environment
|
||||||
run: sudo xcrun xcode-select -s /Applications/Xcode_26_beta_5.app
|
run: sudo xcrun xcode-select -s /Applications/Xcode_14.3.app
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
pushd Sources/Packages
|
pushd Sources/Packages
|
||||||
@@ -29,10 +29,10 @@ jobs:
|
|||||||
popd
|
popd
|
||||||
build:
|
build:
|
||||||
# runs-on: macOS-latest
|
# runs-on: macOS-latest
|
||||||
runs-on: macos-15
|
runs-on: macos-13
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
- name: Setup Signing
|
- name: Setup Signing
|
||||||
env:
|
env:
|
||||||
SIGNING_DATA: ${{ secrets.SIGNING_DATA }}
|
SIGNING_DATA: ${{ secrets.SIGNING_DATA }}
|
||||||
@@ -43,7 +43,7 @@ jobs:
|
|||||||
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
|
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
|
||||||
run: ./.github/scripts/signing.sh
|
run: ./.github/scripts/signing.sh
|
||||||
- name: Set Environment
|
- name: Set Environment
|
||||||
run: sudo xcrun xcode-select -s /Applications/Xcode_26_beta_5.app
|
run: sudo xcrun xcode-select -s /Applications/Xcode_14.3.app
|
||||||
- name: Update Build Number
|
- name: Update Build Number
|
||||||
env:
|
env:
|
||||||
TAG_NAME: ${{ github.ref }}
|
TAG_NAME: ${{ github.ref }}
|
||||||
@@ -107,12 +107,12 @@ jobs:
|
|||||||
asset_name: Secretive.zip
|
asset_name: Secretive.zip
|
||||||
asset_content_type: application/zip
|
asset_content_type: application/zip
|
||||||
- name: Upload App to Artifacts
|
- name: Upload App to Artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: Secretive.zip
|
name: Secretive.zip
|
||||||
path: Secretive.zip
|
path: Secretive.zip
|
||||||
- name: Upload Archive to Artifacts
|
- name: Upload Archive to Artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: Xcode_Archive.zip
|
name: Xcode_Archive.zip
|
||||||
path: Archive.zip
|
path: Archive.zip
|
||||||
|
|||||||
6
.github/workflows/test.yml
vendored
@@ -4,12 +4,12 @@ on: [push, pull_request]
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
# runs-on: macOS-latest
|
# runs-on: macOS-latest
|
||||||
runs-on: macos-15
|
runs-on: macos-13
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
- name: Set Environment
|
- name: Set Environment
|
||||||
run: sudo xcrun xcode-select -s /Applications/Xcode_26_beta_5.app
|
run: sudo xcrun xcode-select -s /Applications/Xcode_14.3.app
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
pushd Sources/Packages
|
pushd Sources/Packages
|
||||||
|
|||||||
@@ -110,15 +110,6 @@ Add this to `~/Library/LaunchAgents/com.maxgoedjen.Secretive.SecretAgent.plist`
|
|||||||
|
|
||||||
Log out and log in again before launching Gitkraken. Then enable "Use local SSH agent in GitKraken Preferences (Located under Preferences -> SSH)
|
Log out and log in again before launching Gitkraken. Then enable "Use local SSH agent in GitKraken Preferences (Located under Preferences -> SSH)
|
||||||
|
|
||||||
## Retcon
|
|
||||||
|
|
||||||
Add this to your `~/.ssh/config` (the path should match the socket path from the setup flow).
|
|
||||||
|
|
||||||
```
|
|
||||||
Host *
|
|
||||||
IdentityAgent /Users/$YOUR_USERNAME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh
|
|
||||||
```
|
|
||||||
|
|
||||||
# The app I use isn't listed here!
|
# The app I use isn't listed here!
|
||||||
|
|
||||||
If you know how to get it set up, please open a PR for this page and add it! Contributions are very welcome.
|
If you know how to get it set up, please open a PR for this page and add it! Contributions are very welcome.
|
||||||
|
|||||||
@@ -14,13 +14,9 @@ Secretive is designed to be easily auditable by people who are considering using
|
|||||||
|
|
||||||
All contributors must abide by the [Code of Conduct](CODE_OF_CONDUCT.md)
|
All contributors must abide by the [Code of Conduct](CODE_OF_CONDUCT.md)
|
||||||
|
|
||||||
## Localization
|
|
||||||
|
|
||||||
If you'd like to contribute a translation, please see [Localizing](LOCALIZING.md) to get started.
|
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
If you make a material contribution to the app, please add yourself to the end of the [credits](https://github.com/maxgoedjen/secretive/blob/main/Sources/Secretive/Credits.rtf).
|
If you make a material contribution to the app, please add yourself to the end of the [credits](https://github.com/maxgoedjen/secretive/blob/main/Secretive/Credits.rtf).
|
||||||
|
|
||||||
## Collaborator Status
|
## Collaborator Status
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 69 KiB |
@@ -1,59 +0,0 @@
|
|||||||
{
|
|
||||||
"fill" : {
|
|
||||||
"solid" : "srgb:0.00000,0.53333,1.00000,0.00000"
|
|
||||||
},
|
|
||||||
"groups" : [
|
|
||||||
{
|
|
||||||
"blur-material" : 0.5,
|
|
||||||
"layers" : [
|
|
||||||
{
|
|
||||||
"image-name" : "Icon 7.png",
|
|
||||||
"name" : "Signature",
|
|
||||||
"position" : {
|
|
||||||
"scale" : 1,
|
|
||||||
"translation-in-points" : [
|
|
||||||
64.00083178971097,
|
|
||||||
-58.21801551632592
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"image-name" : "Rectangle Copy 10.png",
|
|
||||||
"name" : "Border"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fill-specializations" : [
|
|
||||||
{
|
|
||||||
"appearance" : "tinted",
|
|
||||||
"value" : {
|
|
||||||
"solid" : "display-p3:0.00000,0.00000,0.00000,0.50000"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"image-name" : "Rectangle 2 8.png",
|
|
||||||
"name" : "Backing",
|
|
||||||
"opacity-specializations" : [
|
|
||||||
{
|
|
||||||
"appearance" : "tinted",
|
|
||||||
"value" : 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"shadow" : {
|
|
||||||
"kind" : "layer-color",
|
|
||||||
"opacity" : 0.5
|
|
||||||
},
|
|
||||||
"specular" : true,
|
|
||||||
"translucency" : {
|
|
||||||
"enabled" : true,
|
|
||||||
"value" : 0.5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"supported-platforms" : {
|
|
||||||
"squares" : [
|
|
||||||
"macOS"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
# Localizing Secretive
|
|
||||||
|
|
||||||
If you speak another language, and would like to help translate Secretive to support that language, we'd love your help!
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
### Download Xcode
|
|
||||||
|
|
||||||
Download the latest version of Xcode (at minimum, Xcode 15) from [Apple](http://developer.apple.com/download/applications/).
|
|
||||||
|
|
||||||
### Clone Secretive
|
|
||||||
|
|
||||||
Clone Secretive using [these instructions from GitHub](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository).
|
|
||||||
|
|
||||||
### Open Secretive
|
|
||||||
|
|
||||||
Open [Sources/Secretive.xcodeproj](Sources/Secretive.xcodeproj) in Xcode.
|
|
||||||
|
|
||||||
### Translate
|
|
||||||
|
|
||||||
Navigate to [Secretive/Localizable](Sources/Secretive/Localizable.xcstrings).
|
|
||||||
|
|
||||||
<img src="/.github/readme/localize_sidebar.png" alt="Screenshot of Xcode navigating to the Localizable file" width="300">
|
|
||||||
|
|
||||||
If your language already has an in-progress localization, select it from the list. If it isn't there, hit the "+" button and choose your language from the list.
|
|
||||||
|
|
||||||
<img src="/.github/readme/localize_add.png" alt="Screenshot of Xcode adding a new language" width="600">
|
|
||||||
|
|
||||||
Start translating! You'll see a list of english phrases, and a space to add a translation of your language.
|
|
||||||
|
|
||||||
### Create a Pull Request
|
|
||||||
|
|
||||||
Push your changes and open a pull request.
|
|
||||||
|
|
||||||
### Questions
|
|
||||||
|
|
||||||
Please open an issue if you have a question about translating the app. I'm more than happy to clarify any terms that are ambiguous or confusing. Thanks for contributing!
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// swift-tools-version:6.2
|
// swift-tools-version:5.5
|
||||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||||
|
|
||||||
import PackageDescription
|
import PackageDescription
|
||||||
@@ -6,7 +6,7 @@ import PackageDescription
|
|||||||
let package = Package(
|
let package = Package(
|
||||||
name: "SecretivePackages",
|
name: "SecretivePackages",
|
||||||
platforms: [
|
platforms: [
|
||||||
.macOS(.v14)
|
.macOS(.v11)
|
||||||
],
|
],
|
||||||
products: [
|
products: [
|
||||||
.library(
|
.library(
|
||||||
@@ -33,28 +33,23 @@ let package = Package(
|
|||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
name: "SecretKit",
|
name: "SecretKit",
|
||||||
dependencies: [],
|
dependencies: []
|
||||||
swiftSettings: swiftSettings
|
|
||||||
),
|
),
|
||||||
.testTarget(
|
.testTarget(
|
||||||
name: "SecretKitTests",
|
name: "SecretKitTests",
|
||||||
dependencies: ["SecretKit", "SecureEnclaveSecretKit", "SmartCardSecretKit"],
|
dependencies: ["SecretKit", "SecureEnclaveSecretKit", "SmartCardSecretKit"]
|
||||||
swiftSettings: swiftSettings
|
|
||||||
),
|
),
|
||||||
.target(
|
.target(
|
||||||
name: "SecureEnclaveSecretKit",
|
name: "SecureEnclaveSecretKit",
|
||||||
dependencies: ["SecretKit"],
|
dependencies: ["SecretKit"]
|
||||||
swiftSettings: swiftSettings
|
|
||||||
),
|
),
|
||||||
.target(
|
.target(
|
||||||
name: "SmartCardSecretKit",
|
name: "SmartCardSecretKit",
|
||||||
dependencies: ["SecretKit"],
|
dependencies: ["SecretKit"]
|
||||||
swiftSettings: swiftSettings
|
|
||||||
),
|
),
|
||||||
.target(
|
.target(
|
||||||
name: "SecretAgentKit",
|
name: "SecretAgentKit",
|
||||||
dependencies: ["SecretKit", "SecretAgentKitHeaders"],
|
dependencies: ["SecretKit", "SecretAgentKitHeaders"]
|
||||||
swiftSettings: swiftSettings
|
|
||||||
),
|
),
|
||||||
.systemLibrary(
|
.systemLibrary(
|
||||||
name: "SecretAgentKitHeaders"
|
name: "SecretAgentKitHeaders"
|
||||||
@@ -65,8 +60,7 @@ let package = Package(
|
|||||||
,
|
,
|
||||||
.target(
|
.target(
|
||||||
name: "Brief",
|
name: "Brief",
|
||||||
dependencies: [],
|
dependencies: []
|
||||||
swiftSettings: swiftSettings
|
|
||||||
),
|
),
|
||||||
.testTarget(
|
.testTarget(
|
||||||
name: "BriefTests",
|
name: "BriefTests",
|
||||||
@@ -74,10 +68,3 @@ let package = Package(
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
var swiftSettings: [PackageDescription.SwiftSetting] {
|
|
||||||
[
|
|
||||||
.swiftLanguageMode(.v6),
|
|
||||||
.treatAllWarnings(as: .error),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// A release is a representation of a downloadable update.
|
/// A release is a representation of a downloadable update.
|
||||||
public struct Release: Codable, Sendable {
|
public struct Release: Codable {
|
||||||
|
|
||||||
/// The user-facing name of the release. Typically "Secretive 1.2.3"
|
/// The user-facing name of the release. Typically "Secretive 1.2.3"
|
||||||
public let name: String
|
public let name: String
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// A representation of a Semantic Version.
|
/// A representation of a Semantic Version.
|
||||||
public struct SemVer: Sendable {
|
public struct SemVer {
|
||||||
|
|
||||||
/// The SemVer broken into an array of integers.
|
/// The SemVer broken into an array of integers.
|
||||||
let versionNumbers: [Int]
|
let versionNumbers: [Int]
|
||||||
|
|||||||
@@ -1,18 +1,10 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Observation
|
import Combine
|
||||||
|
|
||||||
/// A concrete implementation of ``UpdaterProtocol`` which considers the current release and OS version.
|
/// A concrete implementation of ``UpdaterProtocol`` which considers the current release and OS version.
|
||||||
@Observable public final class Updater: UpdaterProtocol, Sendable {
|
public class Updater: ObservableObject, UpdaterProtocol {
|
||||||
|
|
||||||
private let state = State()
|
|
||||||
@MainActor @Observable public final class State {
|
|
||||||
var update: Release? = nil
|
|
||||||
nonisolated init() {}
|
|
||||||
}
|
|
||||||
public var update: Release? {
|
|
||||||
state.update
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Published public var update: Release?
|
||||||
public let testBuild: Bool
|
public let testBuild: Bool
|
||||||
|
|
||||||
/// The current OS version.
|
/// The current OS version.
|
||||||
@@ -26,43 +18,36 @@ import Observation
|
|||||||
/// - checkFrequency: The interval at which the Updater should check for updates. Subject to a tolerance of 1 hour.
|
/// - checkFrequency: The interval at which the Updater should check for updates. Subject to a tolerance of 1 hour.
|
||||||
/// - osVersion: The current OS version.
|
/// - osVersion: The current OS version.
|
||||||
/// - currentVersion: The current version of the app that is running.
|
/// - currentVersion: The current version of the app that is running.
|
||||||
public init(
|
public init(checkOnLaunch: Bool, checkFrequency: TimeInterval = Measurement(value: 24, unit: UnitDuration.hours).converted(to: .seconds).value, osVersion: SemVer = SemVer(ProcessInfo.processInfo.operatingSystemVersion), currentVersion: SemVer = SemVer(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0.0")) {
|
||||||
checkOnLaunch: Bool,
|
|
||||||
checkFrequency: TimeInterval = Measurement(value: 24, unit: UnitDuration.hours).converted(to: .seconds).value,
|
|
||||||
osVersion: SemVer = SemVer(ProcessInfo.processInfo.operatingSystemVersion),
|
|
||||||
currentVersion: SemVer = SemVer(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0.0")
|
|
||||||
) {
|
|
||||||
self.osVersion = osVersion
|
self.osVersion = osVersion
|
||||||
self.currentVersion = currentVersion
|
self.currentVersion = currentVersion
|
||||||
testBuild = currentVersion == SemVer("0.0.0")
|
testBuild = currentVersion == SemVer("0.0.0")
|
||||||
if checkOnLaunch {
|
if checkOnLaunch {
|
||||||
// Don't do a launch check if the user hasn't seen the setup prompt explaining updater yet.
|
// Don't do a launch check if the user hasn't seen the setup prompt explaining updater yet.
|
||||||
Task {
|
checkForUpdates()
|
||||||
await checkForUpdates()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Task {
|
let timer = Timer.scheduledTimer(withTimeInterval: checkFrequency, repeats: true) { _ in
|
||||||
while !Task.isCancelled {
|
self.checkForUpdates()
|
||||||
try? await Task.sleep(for: .seconds(Int(checkFrequency)))
|
|
||||||
await checkForUpdates()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
timer.tolerance = 60*60
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Manually trigger an update check.
|
/// Manually trigger an update check.
|
||||||
public func checkForUpdates() async {
|
public func checkForUpdates() {
|
||||||
guard let (data, _) = try? await URLSession.shared.data(from: Constants.updateURL) else { return }
|
URLSession.shared.dataTask(with: Constants.updateURL) { data, _, _ in
|
||||||
guard let releases = try? JSONDecoder().decode([Release].self, from: data) else { return }
|
guard let data = data else { return }
|
||||||
await evaluate(releases: releases)
|
guard let releases = try? JSONDecoder().decode([Release].self, from: data) else { return }
|
||||||
|
self.evaluate(releases: releases)
|
||||||
|
}.resume()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ignores a specified release. `update` will be nil if the user has ignored the latest available release.
|
/// Ignores a specified release. `update` will be nil if the user has ignored the latest available release.
|
||||||
/// - Parameter release: The release to ignore.
|
/// - Parameter release: The release to ignore.
|
||||||
public func ignore(release: Release) async {
|
public func ignore(release: Release) {
|
||||||
guard !release.critical else { return }
|
guard !release.critical else { return }
|
||||||
defaults.set(true, forKey: release.name)
|
defaults.set(true, forKey: release.name)
|
||||||
await MainActor.run {
|
DispatchQueue.main.async {
|
||||||
state.update = nil
|
self.update = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +57,7 @@ extension Updater {
|
|||||||
|
|
||||||
/// Evaluates the available downloadable releases, and selects the newest non-prerelease release that the user is able to run.
|
/// Evaluates the available downloadable releases, and selects the newest non-prerelease release that the user is able to run.
|
||||||
/// - Parameter releases: An array of ``Release`` objects.
|
/// - Parameter releases: An array of ``Release`` objects.
|
||||||
func evaluate(releases: [Release]) async {
|
func evaluate(releases: [Release]) {
|
||||||
guard let release = releases
|
guard let release = releases
|
||||||
.sorted()
|
.sorted()
|
||||||
.reversed()
|
.reversed()
|
||||||
@@ -82,8 +67,8 @@ extension Updater {
|
|||||||
guard !release.prerelease else { return }
|
guard !release.prerelease else { return }
|
||||||
let latestVersion = SemVer(release.name)
|
let latestVersion = SemVer(release.name)
|
||||||
if latestVersion > currentVersion {
|
if latestVersion > currentVersion {
|
||||||
await MainActor.run {
|
DispatchQueue.main.async {
|
||||||
state.update = release
|
self.update = release
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
import Combine
|
||||||
|
|
||||||
/// A protocol for retreiving the latest available version of an app.
|
/// A protocol for retreiving the latest available version of an app.
|
||||||
public protocol UpdaterProtocol: Observable, Sendable {
|
public protocol UpdaterProtocol: ObservableObject {
|
||||||
|
|
||||||
/// The latest update
|
/// The latest update
|
||||||
@MainActor var update: Release? { get }
|
var update: Release? { get }
|
||||||
/// A boolean describing whether or not the current build of the app is a "test" build (ie, a debug build or otherwise special build)
|
/// A boolean describing whether or not the current build of the app is a "test" build (ie, a debug build or otherwise special build)
|
||||||
var testBuild: Bool { get }
|
var testBuild: Bool { get }
|
||||||
|
|
||||||
func ignore(release: Release) async
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import SecretKit
|
|||||||
import AppKit
|
import AppKit
|
||||||
|
|
||||||
/// The `Agent` is an implementation of an SSH agent. It manages coordination and access between a socket, traces requests, notifies witnesses and passes requests to stores.
|
/// The `Agent` is an implementation of an SSH agent. It manages coordination and access between a socket, traces requests, notifies witnesses and passes requests to stores.
|
||||||
public final class Agent: Sendable {
|
public class Agent {
|
||||||
|
|
||||||
private let storeList: SecretStoreList
|
private let storeList: SecretStoreList
|
||||||
private let witness: SigningWitness?
|
private let witness: SigningWitness?
|
||||||
private let writer = OpenSSHKeyWriter()
|
private let writer = OpenSSHKeyWriter()
|
||||||
private let requestTracer = SigningRequestTracer()
|
private let requestTracer = SigningRequestTracer()
|
||||||
private let certificateHandler = OpenSSHCertificateHandler()
|
private let certificateHandler = OpenSSHCertificateHandler()
|
||||||
private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent", category: "Agent")
|
private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent.agent", category: "")
|
||||||
|
|
||||||
/// Initializes an agent with a store list and a witness.
|
/// Initializes an agent with a store list and a witness.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
@@ -22,9 +22,7 @@ public final class Agent: Sendable {
|
|||||||
logger.debug("Agent is running")
|
logger.debug("Agent is running")
|
||||||
self.storeList = storeList
|
self.storeList = storeList
|
||||||
self.witness = witness
|
self.witness = witness
|
||||||
Task { @MainActor in
|
certificateHandler.reloadCertificates(for: storeList.allSecrets)
|
||||||
await certificateHandler.reloadCertificates(for: storeList.allSecrets)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -37,7 +35,7 @@ extension Agent {
|
|||||||
/// - writer: A ``FileHandleWriter`` to write the response to.
|
/// - writer: A ``FileHandleWriter`` to write the response to.
|
||||||
/// - Return value:
|
/// - Return value:
|
||||||
/// - Boolean if data could be read
|
/// - Boolean if data could be read
|
||||||
@discardableResult public func handle(reader: FileHandleReader, writer: FileHandleWriter) async -> Bool {
|
@discardableResult public func handle(reader: FileHandleReader, writer: FileHandleWriter) -> Bool {
|
||||||
logger.debug("Agent handling new data")
|
logger.debug("Agent handling new data")
|
||||||
let data = Data(reader.availableData)
|
let data = Data(reader.availableData)
|
||||||
guard data.count > 4 else { return false}
|
guard data.count > 4 else { return false}
|
||||||
@@ -49,25 +47,25 @@ extension Agent {
|
|||||||
}
|
}
|
||||||
logger.debug("Agent handling request of type \(requestType.debugDescription)")
|
logger.debug("Agent handling request of type \(requestType.debugDescription)")
|
||||||
let subData = Data(data[5...])
|
let subData = Data(data[5...])
|
||||||
let response = await handle(requestType: requestType, data: subData, reader: reader)
|
let response = handle(requestType: requestType, data: subData, reader: reader)
|
||||||
writer.write(response)
|
writer.write(response)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func handle(requestType: SSHAgent.RequestType, data: Data, reader: FileHandleReader) async -> Data {
|
func handle(requestType: SSHAgent.RequestType, data: Data, reader: FileHandleReader) -> Data {
|
||||||
// Depending on the launch context (such as after macOS update), the agent may need to reload secrets before acting
|
// Depending on the launch context (such as after macOS update), the agent may need to reload secrets before acting
|
||||||
await reloadSecretsIfNeccessary()
|
reloadSecretsIfNeccessary()
|
||||||
var response = Data()
|
var response = Data()
|
||||||
do {
|
do {
|
||||||
switch requestType {
|
switch requestType {
|
||||||
case .requestIdentities:
|
case .requestIdentities:
|
||||||
response.append(SSHAgent.ResponseType.agentIdentitiesAnswer.data)
|
response.append(SSHAgent.ResponseType.agentIdentitiesAnswer.data)
|
||||||
response.append(await identities())
|
response.append(identities())
|
||||||
logger.debug("Agent returned \(SSHAgent.ResponseType.agentIdentitiesAnswer.debugDescription)")
|
logger.debug("Agent returned \(SSHAgent.ResponseType.agentIdentitiesAnswer.debugDescription)")
|
||||||
case .signRequest:
|
case .signRequest:
|
||||||
let provenance = requestTracer.provenance(from: reader)
|
let provenance = requestTracer.provenance(from: reader)
|
||||||
response.append(SSHAgent.ResponseType.agentSignResponse.data)
|
response.append(SSHAgent.ResponseType.agentSignResponse.data)
|
||||||
response.append(try await sign(data: data, provenance: provenance))
|
response.append(try sign(data: data, provenance: provenance))
|
||||||
logger.debug("Agent returned \(SSHAgent.ResponseType.agentSignResponse.debugDescription)")
|
logger.debug("Agent returned \(SSHAgent.ResponseType.agentSignResponse.debugDescription)")
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@@ -85,9 +83,9 @@ extension Agent {
|
|||||||
|
|
||||||
/// Lists the identities available for signing operations
|
/// Lists the identities available for signing operations
|
||||||
/// - Returns: An OpenSSH formatted Data payload listing the identities available for signing operations.
|
/// - Returns: An OpenSSH formatted Data payload listing the identities available for signing operations.
|
||||||
func identities() async -> Data {
|
func identities() -> Data {
|
||||||
let secrets = await storeList.allSecrets
|
let secrets = storeList.allSecrets
|
||||||
await certificateHandler.reloadCertificates(for: secrets)
|
certificateHandler.reloadCertificates(for: secrets)
|
||||||
var count = secrets.count
|
var count = secrets.count
|
||||||
var keyData = Data()
|
var keyData = Data()
|
||||||
|
|
||||||
@@ -97,7 +95,7 @@ extension Agent {
|
|||||||
keyData.append(writer.lengthAndData(of: keyBlob))
|
keyData.append(writer.lengthAndData(of: keyBlob))
|
||||||
keyData.append(writer.lengthAndData(of: curveData))
|
keyData.append(writer.lengthAndData(of: curveData))
|
||||||
|
|
||||||
if let (certificateData, name) = try? await certificateHandler.keyBlobAndName(for: secret) {
|
if let (certificateData, name) = try? certificateHandler.keyBlobAndName(for: secret) {
|
||||||
keyData.append(writer.lengthAndData(of: certificateData))
|
keyData.append(writer.lengthAndData(of: certificateData))
|
||||||
keyData.append(writer.lengthAndData(of: name))
|
keyData.append(writer.lengthAndData(of: name))
|
||||||
count += 1
|
count += 1
|
||||||
@@ -114,28 +112,28 @@ extension Agent {
|
|||||||
/// - data: The data to sign.
|
/// - data: The data to sign.
|
||||||
/// - provenance: A ``SecretKit.SigningRequestProvenance`` object describing the origin of the request.
|
/// - provenance: A ``SecretKit.SigningRequestProvenance`` object describing the origin of the request.
|
||||||
/// - Returns: An OpenSSH formatted Data payload containing the signed data response.
|
/// - Returns: An OpenSSH formatted Data payload containing the signed data response.
|
||||||
func sign(data: Data, provenance: SigningRequestProvenance) async throws -> Data {
|
func sign(data: Data, provenance: SigningRequestProvenance) throws -> Data {
|
||||||
let reader = OpenSSHReader(data: data)
|
let reader = OpenSSHReader(data: data)
|
||||||
let payloadHash = reader.readNextChunk()
|
let payloadHash = reader.readNextChunk()
|
||||||
let hash: Data
|
let hash: Data
|
||||||
// Check if hash is actually an openssh certificate and reconstruct the public key if it is
|
// Check if hash is actually an openssh certificate and reconstruct the public key if it is
|
||||||
if let certificatePublicKey = await certificateHandler.publicKeyHash(from: payloadHash) {
|
if let certificatePublicKey = certificateHandler.publicKeyHash(from: payloadHash) {
|
||||||
hash = certificatePublicKey
|
hash = certificatePublicKey
|
||||||
} else {
|
} else {
|
||||||
hash = payloadHash
|
hash = payloadHash
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let (store, secret) = await secret(matching: hash) else {
|
guard let (store, secret) = secret(matching: hash) else {
|
||||||
logger.debug("Agent did not have a key matching \(hash as NSData)")
|
logger.debug("Agent did not have a key matching \(hash as NSData)")
|
||||||
throw AgentError.noMatchingKey
|
throw AgentError.noMatchingKey
|
||||||
}
|
}
|
||||||
|
|
||||||
if let witness = witness {
|
if let witness = witness {
|
||||||
try await witness.speakNowOrForeverHoldYourPeace(forAccessTo: secret, from: store, by: provenance)
|
try witness.speakNowOrForeverHoldYourPeace(forAccessTo: secret, from: store, by: provenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
let dataToSign = reader.readNextChunk()
|
let dataToSign = reader.readNextChunk()
|
||||||
let signed = try await store.sign(data: dataToSign, with: secret, for: provenance)
|
let signed = try store.sign(data: dataToSign, with: secret, for: provenance)
|
||||||
let derSignature = signed
|
let derSignature = signed
|
||||||
|
|
||||||
let curveData = writer.curveType(for: secret.algorithm, length: secret.keySize).data(using: .utf8)!
|
let curveData = writer.curveType(for: secret.algorithm, length: secret.keySize).data(using: .utf8)!
|
||||||
@@ -177,7 +175,7 @@ extension Agent {
|
|||||||
signedData.append(writer.lengthAndData(of: sub))
|
signedData.append(writer.lengthAndData(of: sub))
|
||||||
|
|
||||||
if let witness = witness {
|
if let witness = witness {
|
||||||
try await witness.witness(accessTo: secret, from: store, by: provenance)
|
try witness.witness(accessTo: secret, from: store, by: provenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("Agent signed request")
|
logger.debug("Agent signed request")
|
||||||
@@ -190,12 +188,11 @@ extension Agent {
|
|||||||
extension Agent {
|
extension Agent {
|
||||||
|
|
||||||
/// Gives any store with no loaded secrets a chance to reload.
|
/// Gives any store with no loaded secrets a chance to reload.
|
||||||
func reloadSecretsIfNeccessary() async {
|
func reloadSecretsIfNeccessary() {
|
||||||
for store in await storeList.stores {
|
for store in storeList.stores {
|
||||||
if await store.secrets.isEmpty {
|
if store.secrets.isEmpty {
|
||||||
let name = await store.name
|
logger.debug("Store \(store.name, privacy: .public) has no loaded secrets. Reloading.")
|
||||||
logger.debug("Store \(name, privacy: .public) has no loaded secrets. Reloading.")
|
store.reloadSecrets()
|
||||||
await store.reloadSecrets()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -203,16 +200,16 @@ extension Agent {
|
|||||||
/// Finds a ``Secret`` matching a specified hash whos signature was requested.
|
/// Finds a ``Secret`` matching a specified hash whos signature was requested.
|
||||||
/// - Parameter hash: The hash to match against.
|
/// - Parameter hash: The hash to match against.
|
||||||
/// - Returns: A ``Secret`` and the ``SecretStore`` containing it, if a match is found.
|
/// - Returns: A ``Secret`` and the ``SecretStore`` containing it, if a match is found.
|
||||||
func secret(matching hash: Data) async -> (AnySecretStore, AnySecret)? {
|
func secret(matching hash: Data) -> (AnySecretStore, AnySecret)? {
|
||||||
for store in await storeList.stores {
|
storeList.stores.compactMap { store -> (AnySecretStore, AnySecret)? in
|
||||||
let allMatching = await store.secrets.filter { secret in
|
let allMatching = store.secrets.filter { secret in
|
||||||
hash == writer.data(secret: secret)
|
hash == writer.data(secret: secret)
|
||||||
}
|
}
|
||||||
if let matching = allMatching.first {
|
if let matching = allMatching.first {
|
||||||
return (store, matching)
|
return (store, matching)
|
||||||
}
|
}
|
||||||
}
|
return nil
|
||||||
return nil
|
}.first
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Protocol abstraction of the reading aspects of FileHandle.
|
/// Protocol abstraction of the reading aspects of FileHandle.
|
||||||
public protocol FileHandleReader: Sendable {
|
public protocol FileHandleReader {
|
||||||
|
|
||||||
/// Gets data that is available for reading.
|
/// Gets data that is available for reading.
|
||||||
var availableData: Data { get }
|
var availableData: Data { get }
|
||||||
@@ -13,7 +13,7 @@ public protocol FileHandleReader: Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Protocol abstraction of the writing aspects of FileHandle.
|
/// Protocol abstraction of the writing aspects of FileHandle.
|
||||||
public protocol FileHandleWriter: Sendable {
|
public protocol FileHandleWriter {
|
||||||
|
|
||||||
/// Writes data to the handle.
|
/// Writes data to the handle.
|
||||||
func write(_ data: Data)
|
func write(_ data: Data)
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import Foundation
|
|
||||||
|
|
||||||
struct UncheckedSendable<T>: @unchecked Sendable {
|
|
||||||
|
|
||||||
let value: T
|
|
||||||
|
|
||||||
init(_ value: T) {
|
|
||||||
self.value = value
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ import Foundation
|
|||||||
import SecretKit
|
import SecretKit
|
||||||
|
|
||||||
/// A protocol that allows conformers to be notified of access to secrets, and optionally prevent access.
|
/// A protocol that allows conformers to be notified of access to secrets, and optionally prevent access.
|
||||||
public protocol SigningWitness: Sendable {
|
public protocol SigningWitness {
|
||||||
|
|
||||||
/// A ridiculously named method that notifies the callee that a signing operation is about to be performed using a secret. The callee may `throw` an `Error` to prevent access from occurring.
|
/// A ridiculously named method that notifies the callee that a signing operation is about to be performed using a secret. The callee may `throw` an `Error` to prevent access from occurring.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
@@ -10,13 +10,13 @@ public protocol SigningWitness: Sendable {
|
|||||||
/// - store: The `Store` being asked to sign the request..
|
/// - store: The `Store` being asked to sign the request..
|
||||||
/// - provenance: A `SigningRequestProvenance` object describing the origin of the request.
|
/// - provenance: A `SigningRequestProvenance` object describing the origin of the request.
|
||||||
/// - Note: This method being called does not imply that the requst has been authorized. If a secret requires authentication, authentication will still need to be performed by the user before the request will be performed. If the user declines or fails to authenticate, the request will fail.
|
/// - Note: This method being called does not imply that the requst has been authorized. If a secret requires authentication, authentication will still need to be performed by the user before the request will be performed. If the user declines or fails to authenticate, the request will fail.
|
||||||
func speakNowOrForeverHoldYourPeace(forAccessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) async throws
|
func speakNowOrForeverHoldYourPeace(forAccessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) throws
|
||||||
|
|
||||||
/// Notifies the callee that a signing operation has been performed for a given secret.
|
/// Notifies the callee that a signing operation has been performed for a given secret.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - secret: The `Secret` that will was used to sign the request.
|
/// - secret: The `Secret` that will was used to sign the request.
|
||||||
/// - store: The `Store` that signed the request..
|
/// - store: The `Store` that signed the request..
|
||||||
/// - provenance: A `SigningRequestProvenance` object describing the origin of the request.
|
/// - provenance: A `SigningRequestProvenance` object describing the origin of the request.
|
||||||
func witness(accessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) async throws
|
func witness(accessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) throws
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Foundation
|
|||||||
import OSLog
|
import OSLog
|
||||||
|
|
||||||
/// A controller that manages socket configuration and request dispatching.
|
/// A controller that manages socket configuration and request dispatching.
|
||||||
public final class SocketController {
|
public class SocketController {
|
||||||
|
|
||||||
/// The active FileHandle.
|
/// The active FileHandle.
|
||||||
private var fileHandle: FileHandle?
|
private var fileHandle: FileHandle?
|
||||||
@@ -10,24 +10,22 @@ public final class SocketController {
|
|||||||
private var port: SocketPort?
|
private var port: SocketPort?
|
||||||
/// A handler that will be notified when a new read/write handle is available.
|
/// A handler that will be notified when a new read/write handle is available.
|
||||||
/// False if no data could be read
|
/// False if no data could be read
|
||||||
public var handler: (@Sendable (FileHandleReader, FileHandleWriter) async -> Bool)?
|
public var handler: ((FileHandleReader, FileHandleWriter) -> Bool)?
|
||||||
/// Logger.
|
|
||||||
private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent", category: "SocketController")
|
|
||||||
|
|
||||||
|
|
||||||
/// Initializes a socket controller with a specified path.
|
/// Initializes a socket controller with a specified path.
|
||||||
/// - Parameter path: The path to use as a socket.
|
/// - Parameter path: The path to use as a socket.
|
||||||
public init(path: String) {
|
public init(path: String) {
|
||||||
logger.debug("Socket controller setting up at \(path)")
|
Logger().debug("Socket controller setting up at \(path)")
|
||||||
if let _ = try? FileManager.default.removeItem(atPath: path) {
|
if let _ = try? FileManager.default.removeItem(atPath: path) {
|
||||||
logger.debug("Socket controller removed existing socket")
|
Logger().debug("Socket controller removed existing socket")
|
||||||
}
|
}
|
||||||
let exists = FileManager.default.fileExists(atPath: path)
|
let exists = FileManager.default.fileExists(atPath: path)
|
||||||
assert(!exists)
|
assert(!exists)
|
||||||
logger.debug("Socket controller path is clear")
|
Logger().debug("Socket controller path is clear")
|
||||||
port = socketPort(at: path)
|
port = socketPort(at: path)
|
||||||
configureSocket(at: path)
|
configureSocket(at: path)
|
||||||
logger.debug("Socket listening at \(path)")
|
Logger().debug("Socket listening at \(path)")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configures the socket and a corresponding FileHandle.
|
/// Configures the socket and a corresponding FileHandle.
|
||||||
@@ -37,7 +35,7 @@ public final class SocketController {
|
|||||||
fileHandle = FileHandle(fileDescriptor: port.socket, closeOnDealloc: true)
|
fileHandle = FileHandle(fileDescriptor: port.socket, closeOnDealloc: true)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(handleConnectionAccept(notification:)), name: .NSFileHandleConnectionAccepted, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(handleConnectionAccept(notification:)), name: .NSFileHandleConnectionAccepted, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(handleConnectionDataAvailable(notification:)), name: .NSFileHandleDataAvailable, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(handleConnectionDataAvailable(notification:)), name: .NSFileHandleDataAvailable, object: nil)
|
||||||
fileHandle?.acceptConnectionInBackgroundAndNotify(forModes: [RunLoop.Mode.common])
|
fileHandle?.acceptConnectionInBackgroundAndNotify(forModes: [RunLoop.current.currentMode!])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a SocketPort for a path.
|
/// Creates a SocketPort for a path.
|
||||||
@@ -67,45 +65,25 @@ public final class SocketController {
|
|||||||
/// Handles a new connection being accepted, invokes the handler, and prepares to accept new connections.
|
/// Handles a new connection being accepted, invokes the handler, and prepares to accept new connections.
|
||||||
/// - Parameter notification: A `Notification` that triggered the call.
|
/// - Parameter notification: A `Notification` that triggered the call.
|
||||||
@objc func handleConnectionAccept(notification: Notification) {
|
@objc func handleConnectionAccept(notification: Notification) {
|
||||||
logger.debug("Socket controller accepted connection")
|
Logger().debug("Socket controller accepted connection")
|
||||||
guard let new = notification.userInfo?[NSFileHandleNotificationFileHandleItem] as? FileHandle else { return }
|
guard let new = notification.userInfo?[NSFileHandleNotificationFileHandleItem] as? FileHandle else { return }
|
||||||
Task { [handler, fileHandle] in
|
_ = handler?(new, new)
|
||||||
_ = await handler?(new, new)
|
new.waitForDataInBackgroundAndNotify()
|
||||||
await new.waitForDataInBackgroundAndNotifyOnMainActor()
|
fileHandle?.acceptConnectionInBackgroundAndNotify(forModes: [RunLoop.current.currentMode!])
|
||||||
await fileHandle?.acceptConnectionInBackgroundAndNotifyOnMainActor()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a new connection providing data and invokes the handler callback.
|
/// Handles a new connection providing data and invokes the handler callback.
|
||||||
/// - Parameter notification: A `Notification` that triggered the call.
|
/// - Parameter notification: A `Notification` that triggered the call.
|
||||||
@objc func handleConnectionDataAvailable(notification: Notification) {
|
@objc func handleConnectionDataAvailable(notification: Notification) {
|
||||||
logger.debug("Socket controller has new data available")
|
Logger().debug("Socket controller has new data available")
|
||||||
guard let new = notification.object as? FileHandle else { return }
|
guard let new = notification.object as? FileHandle else { return }
|
||||||
logger.debug("Socket controller received new file handle")
|
Logger().debug("Socket controller received new file handle")
|
||||||
Task { [handler, logger = UncheckedSendable(logger)] in
|
if((handler?(new, new)) == true) {
|
||||||
if((await handler?(new, new)) == true) {
|
Logger().debug("Socket controller handled data, wait for more data")
|
||||||
logger.value.debug("Socket controller handled data, wait for more data")
|
new.waitForDataInBackgroundAndNotify()
|
||||||
await new.waitForDataInBackgroundAndNotifyOnMainActor()
|
} else {
|
||||||
} else {
|
Logger().debug("Socket controller called with empty data, socked closed")
|
||||||
logger.value.debug("Socket controller called with empty data, socked closed")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension FileHandle {
|
|
||||||
|
|
||||||
/// Ensures waitForDataInBackgroundAndNotify will be called on the main actor.
|
|
||||||
@MainActor func waitForDataInBackgroundAndNotifyOnMainActor() {
|
|
||||||
waitForDataInBackgroundAndNotify()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Ensures acceptConnectionInBackgroundAndNotify will be called on the main actor.
|
|
||||||
/// - Parameter modes: the runloop modes to use.
|
|
||||||
@MainActor func acceptConnectionInBackgroundAndNotifyOnMainActor(forModes modes: [RunLoop.Mode]? = [RunLoop.Mode.common]) {
|
|
||||||
acceptConnectionInBackgroundAndNotify(forModes: modes)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Type eraser for Secret.
|
/// Type eraser for Secret.
|
||||||
public struct AnySecret: Secret, @unchecked Sendable {
|
public struct AnySecret: Secret {
|
||||||
|
|
||||||
let base: Any
|
let base: Any
|
||||||
private let hashable: AnyHashable
|
private let hashable: AnyHashable
|
||||||
|
|||||||
@@ -2,18 +2,20 @@ import Foundation
|
|||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
/// Type eraser for SecretStore.
|
/// Type eraser for SecretStore.
|
||||||
public class AnySecretStore: SecretStore, @unchecked Sendable {
|
public class AnySecretStore: SecretStore {
|
||||||
|
|
||||||
let base: any Sendable
|
let base: Any
|
||||||
private let _isAvailable: @MainActor @Sendable () -> Bool
|
private let _isAvailable: () -> Bool
|
||||||
private let _id: @Sendable () -> UUID
|
private let _id: () -> UUID
|
||||||
private let _name: @MainActor @Sendable () -> String
|
private let _name: () -> String
|
||||||
private let _secrets: @MainActor @Sendable () -> [AnySecret]
|
private let _secrets: () -> [AnySecret]
|
||||||
private let _sign: @Sendable (Data, AnySecret, SigningRequestProvenance) async throws -> Data
|
private let _sign: (Data, AnySecret, SigningRequestProvenance) throws -> Data
|
||||||
private let _verify: @Sendable (Data, Data, AnySecret) async throws -> Bool
|
private let _verify: (Data, Data, AnySecret) throws -> Bool
|
||||||
private let _existingPersistedAuthenticationContext: @Sendable (AnySecret) async -> PersistedAuthenticationContext?
|
private let _existingPersistedAuthenticationContext: (AnySecret) -> PersistedAuthenticationContext?
|
||||||
private let _persistAuthentication: @Sendable (AnySecret, TimeInterval) async throws -> Void
|
private let _persistAuthentication: (AnySecret, TimeInterval) throws -> Void
|
||||||
private let _reloadSecrets: @Sendable () async -> Void
|
private let _reloadSecrets: () -> Void
|
||||||
|
|
||||||
|
private var sink: AnyCancellable?
|
||||||
|
|
||||||
public init<SecretStoreType>(_ secretStore: SecretStoreType) where SecretStoreType: SecretStore {
|
public init<SecretStoreType>(_ secretStore: SecretStoreType) where SecretStoreType: SecretStore {
|
||||||
base = secretStore
|
base = secretStore
|
||||||
@@ -21,14 +23,17 @@ public class AnySecretStore: SecretStore, @unchecked Sendable {
|
|||||||
_name = { secretStore.name }
|
_name = { secretStore.name }
|
||||||
_id = { secretStore.id }
|
_id = { secretStore.id }
|
||||||
_secrets = { secretStore.secrets.map { AnySecret($0) } }
|
_secrets = { secretStore.secrets.map { AnySecret($0) } }
|
||||||
_sign = { try await secretStore.sign(data: $0, with: $1.base as! SecretStoreType.SecretType, for: $2) }
|
_sign = { try secretStore.sign(data: $0, with: $1.base as! SecretStoreType.SecretType, for: $2) }
|
||||||
_verify = { try await secretStore.verify(signature: $0, for: $1, with: $2.base as! SecretStoreType.SecretType) }
|
_verify = { try secretStore.verify(signature: $0, for: $1, with: $2.base as! SecretStoreType.SecretType) }
|
||||||
_existingPersistedAuthenticationContext = { await secretStore.existingPersistedAuthenticationContext(secret: $0.base as! SecretStoreType.SecretType) }
|
_existingPersistedAuthenticationContext = { secretStore.existingPersistedAuthenticationContext(secret: $0.base as! SecretStoreType.SecretType) }
|
||||||
_persistAuthentication = { try await secretStore.persistAuthentication(secret: $0.base as! SecretStoreType.SecretType, forDuration: $1) }
|
_persistAuthentication = { try secretStore.persistAuthentication(secret: $0.base as! SecretStoreType.SecretType, forDuration: $1) }
|
||||||
_reloadSecrets = { await secretStore.reloadSecrets() }
|
_reloadSecrets = { secretStore.reloadSecrets() }
|
||||||
|
sink = secretStore.objectWillChange.sink { _ in
|
||||||
|
self.objectWillChange.send()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor public var isAvailable: Bool {
|
public var isAvailable: Bool {
|
||||||
return _isAvailable()
|
return _isAvailable()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,59 +41,59 @@ public class AnySecretStore: SecretStore, @unchecked Sendable {
|
|||||||
return _id()
|
return _id()
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor public var name: String {
|
public var name: String {
|
||||||
return _name()
|
return _name()
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor public var secrets: [AnySecret] {
|
public var secrets: [AnySecret] {
|
||||||
return _secrets()
|
return _secrets()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sign(data: Data, with secret: AnySecret, for provenance: SigningRequestProvenance) async throws -> Data {
|
public func sign(data: Data, with secret: AnySecret, for provenance: SigningRequestProvenance) throws -> Data {
|
||||||
try await _sign(data, secret, provenance)
|
try _sign(data, secret, provenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func verify(signature: Data, for data: Data, with secret: AnySecret) async throws -> Bool {
|
public func verify(signature: Data, for data: Data, with secret: AnySecret) throws -> Bool {
|
||||||
try await _verify(signature, data, secret)
|
try _verify(signature, data, secret)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func existingPersistedAuthenticationContext(secret: AnySecret) async -> PersistedAuthenticationContext? {
|
public func existingPersistedAuthenticationContext(secret: AnySecret) -> PersistedAuthenticationContext? {
|
||||||
await _existingPersistedAuthenticationContext(secret)
|
_existingPersistedAuthenticationContext(secret)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func persistAuthentication(secret: AnySecret, forDuration duration: TimeInterval) async throws {
|
public func persistAuthentication(secret: AnySecret, forDuration duration: TimeInterval) throws {
|
||||||
try await _persistAuthentication(secret, duration)
|
try _persistAuthentication(secret, duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reloadSecrets() async {
|
public func reloadSecrets() {
|
||||||
await _reloadSecrets()
|
_reloadSecrets()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class AnySecretStoreModifiable: AnySecretStore, SecretStoreModifiable, @unchecked Sendable {
|
public class AnySecretStoreModifiable: AnySecretStore, SecretStoreModifiable {
|
||||||
|
|
||||||
private let _create: @Sendable (String, Bool) async throws -> Void
|
private let _create: (String, Bool) throws -> Void
|
||||||
private let _delete: @Sendable (AnySecret) async throws -> Void
|
private let _delete: (AnySecret) throws -> Void
|
||||||
private let _update: @Sendable (AnySecret, String) async throws -> Void
|
private let _update: (AnySecret, String) throws -> Void
|
||||||
|
|
||||||
public init<SecretStoreType>(modifiable secretStore: SecretStoreType) where SecretStoreType: SecretStoreModifiable {
|
public init<SecretStoreType>(modifiable secretStore: SecretStoreType) where SecretStoreType: SecretStoreModifiable {
|
||||||
_create = { try await secretStore.create(name: $0, requiresAuthentication: $1) }
|
_create = { try secretStore.create(name: $0, requiresAuthentication: $1) }
|
||||||
_delete = { try await secretStore.delete(secret: $0.base as! SecretStoreType.SecretType) }
|
_delete = { try secretStore.delete(secret: $0.base as! SecretStoreType.SecretType) }
|
||||||
_update = { try await secretStore.update(secret: $0.base as! SecretStoreType.SecretType, name: $1) }
|
_update = { try secretStore.update(secret: $0.base as! SecretStoreType.SecretType, name: $1) }
|
||||||
super.init(secretStore)
|
super.init(secretStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func create(name: String, requiresAuthentication: Bool) async throws {
|
public func create(name: String, requiresAuthentication: Bool) throws {
|
||||||
try await _create(name, requiresAuthentication)
|
try _create(name, requiresAuthentication)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func delete(secret: AnySecret) async throws {
|
public func delete(secret: AnySecret) throws {
|
||||||
try await _delete(secret)
|
try _delete(secret)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func update(secret: AnySecret, name: String) async throws {
|
public func update(secret: AnySecret, name: String) throws {
|
||||||
try await _update(secret, name)
|
try _update(secret, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import Foundation
|
|||||||
import OSLog
|
import OSLog
|
||||||
|
|
||||||
/// Manages storage and lookup for OpenSSH certificates.
|
/// Manages storage and lookup for OpenSSH certificates.
|
||||||
public actor OpenSSHCertificateHandler: Sendable {
|
public class OpenSSHCertificateHandler {
|
||||||
|
|
||||||
private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: NSHomeDirectory())
|
private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: NSHomeDirectory())
|
||||||
private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent", category: "OpenSSHCertificateHandler")
|
private let logger = Logger()
|
||||||
private let writer = OpenSSHKeyWriter()
|
private let writer = OpenSSHKeyWriter()
|
||||||
private var keyBlobsAndNames: [AnySecret: (Data, Data)] = [:]
|
private var keyBlobsAndNames: [AnySecret: (Data, Data)] = [:]
|
||||||
|
|
||||||
@@ -25,6 +25,14 @@ public actor OpenSSHCertificateHandler: Sendable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether or not the certificate handler has a certifiicate associated with a given secret.
|
||||||
|
/// - Parameter secret: The secret to check for a certificate.
|
||||||
|
/// - Returns: A boolean describing whether or not the certificate handler has a certifiicate associated with a given secret
|
||||||
|
public func hasCertificate<SecretType: Secret>(for secret: SecretType) -> Bool {
|
||||||
|
keyBlobsAndNames[AnySecret(secret)] != nil
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Reconstructs a public key from a ``Data``, if that ``Data`` contains an OpenSSH certificate hash. Currently only ecdsa certificates are supported
|
/// Reconstructs a public key from a ``Data``, if that ``Data`` contains an OpenSSH certificate hash. Currently only ecdsa certificates are supported
|
||||||
/// - Parameter certBlock: The openssh certificate to extract the public key from
|
/// - Parameter certBlock: The openssh certificate to extract the public key from
|
||||||
/// - Returns: A ``Data`` object containing the public key in OpenSSH wire format if the ``Data`` is an OpenSSH certificate hash, otherwise nil.
|
/// - Returns: A ``Data`` object containing the public key in OpenSSH wire format if the ``Data`` is an OpenSSH certificate hash, otherwise nil.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Foundation
|
|||||||
import CryptoKit
|
import CryptoKit
|
||||||
|
|
||||||
/// Generates OpenSSH representations of Secrets.
|
/// Generates OpenSSH representations of Secrets.
|
||||||
public struct OpenSSHKeyWriter: Sendable {
|
public struct OpenSSHKeyWriter {
|
||||||
|
|
||||||
/// Initializes the writer.
|
/// Initializes the writer.
|
||||||
public init() {
|
public init() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Reads OpenSSH protocol data.
|
/// Reads OpenSSH protocol data.
|
||||||
public final class OpenSSHReader {
|
public class OpenSSHReader {
|
||||||
|
|
||||||
var remaining: Data
|
var remaining: Data
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import Foundation
|
|||||||
import OSLog
|
import OSLog
|
||||||
|
|
||||||
/// Controller responsible for writing public keys to disk, so that they're easily accessible by scripts.
|
/// Controller responsible for writing public keys to disk, so that they're easily accessible by scripts.
|
||||||
public final class PublicKeyFileStoreController: Sendable {
|
public class PublicKeyFileStoreController {
|
||||||
|
|
||||||
private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent", category: "PublicKeyFileStoreController")
|
private let logger = Logger()
|
||||||
private let directory: String
|
private let directory: String
|
||||||
private let keyWriter = OpenSSHKeyWriter()
|
private let keyWriter = OpenSSHKeyWriter()
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,34 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Observation
|
import Combine
|
||||||
|
|
||||||
/// A "Store Store," which holds a list of type-erased stores.
|
/// A "Store Store," which holds a list of type-erased stores.
|
||||||
@Observable @MainActor public final class SecretStoreList: Sendable {
|
public class SecretStoreList: ObservableObject {
|
||||||
|
|
||||||
/// The Stores managed by the SecretStoreList.
|
/// The Stores managed by the SecretStoreList.
|
||||||
public var stores: [AnySecretStore] = []
|
@Published public var stores: [AnySecretStore] = []
|
||||||
/// A modifiable store, if one is available.
|
/// A modifiable store, if one is available.
|
||||||
public var modifiableStore: AnySecretStoreModifiable? = nil
|
@Published public var modifiableStore: AnySecretStoreModifiable?
|
||||||
|
private var cancellables: Set<AnyCancellable> = []
|
||||||
|
|
||||||
/// Initializes a SecretStoreList.
|
/// Initializes a SecretStoreList.
|
||||||
public nonisolated init() {
|
public init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a non-type-erased SecretStore to the list.
|
/// Adds a non-type-erased SecretStore to the list.
|
||||||
public func add<SecretStoreType: SecretStore>(store: SecretStoreType) {
|
public func add<SecretStoreType: SecretStore>(store: SecretStoreType) {
|
||||||
stores.append(AnySecretStore(store))
|
addInternal(store: AnySecretStore(store))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a non-type-erased modifiable SecretStore.
|
/// Adds a non-type-erased modifiable SecretStore.
|
||||||
public func add<SecretStoreType: SecretStoreModifiable>(store: SecretStoreType) {
|
public func add<SecretStoreType: SecretStoreModifiable>(store: SecretStoreType) {
|
||||||
let modifiable = AnySecretStoreModifiable(modifiable: store)
|
let modifiable = AnySecretStoreModifiable(modifiable: store)
|
||||||
if modifiableStore == nil {
|
modifiableStore = modifiable
|
||||||
modifiableStore = modifiable
|
addInternal(store: modifiable)
|
||||||
}
|
|
||||||
stores.append(modifiable)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A boolean describing whether there are any Stores available.
|
/// A boolean describing whether there are any Stores available.
|
||||||
public var anyAvailable: Bool {
|
public var anyAvailable: Bool {
|
||||||
stores.contains(where: \.isAvailable)
|
stores.reduce(false, { $0 || $1.isAvailable })
|
||||||
}
|
}
|
||||||
|
|
||||||
public var allSecrets: [AnySecret] {
|
public var allSecrets: [AnySecret] {
|
||||||
@@ -37,3 +36,14 @@ import Observation
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension SecretStoreList {
|
||||||
|
|
||||||
|
private func addInternal(store: AnySecretStore) {
|
||||||
|
stores.append(store)
|
||||||
|
store.objectWillChange.sink {
|
||||||
|
self.objectWillChange.send()
|
||||||
|
}.store(in: &cancellables)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Protocol describing a persisted authentication context. This is an authorization that can be reused for multiple access to a secret that requires authentication for a specific period of time.
|
/// Protocol describing a persisted authentication context. This is an authorization that can be reused for multiple access to a secret that requires authentication for a specific period of time.
|
||||||
public protocol PersistedAuthenticationContext: Sendable {
|
public protocol PersistedAuthenticationContext {
|
||||||
/// Whether the context remains valid.
|
/// Whether the context remains valid.
|
||||||
var valid: Bool { get }
|
var valid: Bool { get }
|
||||||
/// The date at which the authorization expires and the context becomes invalid.
|
/// The date at which the authorization expires and the context becomes invalid.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// The base protocol for describing a Secret
|
/// The base protocol for describing a Secret
|
||||||
public protocol Secret: Identifiable, Hashable, Sendable {
|
public protocol Secret: Identifiable, Hashable {
|
||||||
|
|
||||||
/// A user-facing string identifying the Secret.
|
/// A user-facing string identifying the Secret.
|
||||||
var name: String { get }
|
var name: String { get }
|
||||||
@@ -17,7 +17,7 @@ public protocol Secret: Identifiable, Hashable, Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The type of algorithm the Secret uses. Currently, only elliptic curve algorithms are supported.
|
/// The type of algorithm the Secret uses. Currently, only elliptic curve algorithms are supported.
|
||||||
public enum Algorithm: Hashable, Sendable {
|
public enum Algorithm: Hashable {
|
||||||
|
|
||||||
case ellipticCurve
|
case ellipticCurve
|
||||||
case rsa
|
case rsa
|
||||||
|
|||||||
@@ -2,18 +2,18 @@ import Foundation
|
|||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
/// Manages access to Secrets, and performs signature operations on data using those Secrets.
|
/// Manages access to Secrets, and performs signature operations on data using those Secrets.
|
||||||
public protocol SecretStore: Identifiable, Sendable {
|
public protocol SecretStore: ObservableObject, Identifiable {
|
||||||
|
|
||||||
associatedtype SecretType: Secret
|
associatedtype SecretType: Secret
|
||||||
|
|
||||||
/// A boolean indicating whether or not the store is available.
|
/// A boolean indicating whether or not the store is available.
|
||||||
@MainActor var isAvailable: Bool { get }
|
var isAvailable: Bool { get }
|
||||||
/// A unique identifier for the store.
|
/// A unique identifier for the store.
|
||||||
var id: UUID { get }
|
var id: UUID { get }
|
||||||
/// A user-facing name for the store.
|
/// A user-facing name for the store.
|
||||||
@MainActor var name: String { get }
|
var name: String { get }
|
||||||
/// The secrets the store manages.
|
/// The secrets the store manages.
|
||||||
@MainActor var secrets: [SecretType] { get }
|
var secrets: [SecretType] { get }
|
||||||
|
|
||||||
/// Signs a data payload with a specified Secret.
|
/// Signs a data payload with a specified Secret.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
@@ -21,7 +21,7 @@ public protocol SecretStore: Identifiable, Sendable {
|
|||||||
/// - secret: The ``Secret`` to sign with.
|
/// - secret: The ``Secret`` to sign with.
|
||||||
/// - provenance: A ``SigningRequestProvenance`` describing where the request came from.
|
/// - provenance: A ``SigningRequestProvenance`` describing where the request came from.
|
||||||
/// - Returns: The signed data.
|
/// - Returns: The signed data.
|
||||||
func sign(data: Data, with secret: SecretType, for provenance: SigningRequestProvenance) async throws -> Data
|
func sign(data: Data, with secret: SecretType, for provenance: SigningRequestProvenance) throws -> Data
|
||||||
|
|
||||||
/// Verifies that a signature is valid over a specified payload.
|
/// Verifies that a signature is valid over a specified payload.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
@@ -29,23 +29,23 @@ public protocol SecretStore: Identifiable, Sendable {
|
|||||||
/// - data: The data to verify the signature of.
|
/// - data: The data to verify the signature of.
|
||||||
/// - secret: The secret whose signature to verify.
|
/// - secret: The secret whose signature to verify.
|
||||||
/// - Returns: Whether the signature was verified.
|
/// - Returns: Whether the signature was verified.
|
||||||
func verify(signature: Data, for data: Data, with secret: SecretType) async throws -> Bool
|
func verify(signature: Data, for data: Data, with secret: SecretType) throws -> Bool
|
||||||
|
|
||||||
/// Checks to see if there is currently a valid persisted authentication for a given secret.
|
/// Checks to see if there is currently a valid persisted authentication for a given secret.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - secret: The ``Secret`` to check if there is a persisted authentication for.
|
/// - secret: The ``Secret`` to check if there is a persisted authentication for.
|
||||||
/// - Returns: A persisted authentication context, if a valid one exists.
|
/// - Returns: A persisted authentication context, if a valid one exists.
|
||||||
func existingPersistedAuthenticationContext(secret: SecretType) async -> PersistedAuthenticationContext?
|
func existingPersistedAuthenticationContext(secret: SecretType) -> PersistedAuthenticationContext?
|
||||||
|
|
||||||
/// Persists user authorization for access to a secret.
|
/// Persists user authorization for access to a secret.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - secret: The ``Secret`` to persist the authorization for.
|
/// - secret: The ``Secret`` to persist the authorization for.
|
||||||
/// - duration: The duration that the authorization should persist for.
|
/// - duration: The duration that the authorization should persist for.
|
||||||
/// - Note: This is used for temporarily unlocking access to a secret which would otherwise require authentication every single use. This is useful for situations where the user anticipates several rapid accesses to a authorization-guarded secret.
|
/// - Note: This is used for temporarily unlocking access to a secret which would otherwise require authentication every single use. This is useful for situations where the user anticipates several rapid accesses to a authorization-guarded secret.
|
||||||
func persistAuthentication(secret: SecretType, forDuration duration: TimeInterval) async throws
|
func persistAuthentication(secret: SecretType, forDuration duration: TimeInterval) throws
|
||||||
|
|
||||||
/// Requests that the store reload secrets from any backing store, if neccessary.
|
/// Requests that the store reload secrets from any backing store, if neccessary.
|
||||||
func reloadSecrets() async
|
func reloadSecrets()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,18 +56,18 @@ public protocol SecretStoreModifiable: SecretStore {
|
|||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - name: The user-facing name for the ``Secret``.
|
/// - name: The user-facing name for the ``Secret``.
|
||||||
/// - requiresAuthentication: A boolean indicating whether or not the user will be required to authenticate before performing signature operations with the secret.
|
/// - requiresAuthentication: A boolean indicating whether or not the user will be required to authenticate before performing signature operations with the secret.
|
||||||
func create(name: String, requiresAuthentication: Bool) async throws
|
func create(name: String, requiresAuthentication: Bool) throws
|
||||||
|
|
||||||
/// Deletes a Secret in the store.
|
/// Deletes a Secret in the store.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - secret: The ``Secret`` to delete.
|
/// - secret: The ``Secret`` to delete.
|
||||||
func delete(secret: SecretType) async throws
|
func delete(secret: SecretType) throws
|
||||||
|
|
||||||
/// Updates the name of a Secret in the store.
|
/// Updates the name of a Secret in the store.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - secret: The ``Secret`` to update.
|
/// - secret: The ``Secret`` to update.
|
||||||
/// - name: The new name for the Secret.
|
/// - name: The new name for the Secret.
|
||||||
func update(secret: SecretType, name: String) async throws
|
func update(secret: SecretType, name: String) throws
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Foundation
|
|||||||
import AppKit
|
import AppKit
|
||||||
|
|
||||||
/// Describes the chain of applications that requested a signature operation.
|
/// Describes the chain of applications that requested a signature operation.
|
||||||
public struct SigningRequestProvenance: Equatable, Sendable {
|
public struct SigningRequestProvenance: Equatable {
|
||||||
|
|
||||||
/// A list of processes involved in the request.
|
/// A list of processes involved in the request.
|
||||||
/// - Note: A chain will typically consist of many elements even for a simple request. For example, running `git fetch` in Terminal.app would generate a request chain of `ssh` -> `git` -> `zsh` -> `login` -> `Terminal.app`
|
/// - Note: A chain will typically consist of many elements even for a simple request. For example, running `git fetch` in Terminal.app would generate a request chain of `ssh` -> `git` -> `zsh` -> `login` -> `Terminal.app`
|
||||||
@@ -30,7 +30,7 @@ extension SigningRequestProvenance {
|
|||||||
extension SigningRequestProvenance {
|
extension SigningRequestProvenance {
|
||||||
|
|
||||||
/// Describes a process in a `SigningRequestProvenance` chain.
|
/// Describes a process in a `SigningRequestProvenance` chain.
|
||||||
public struct Process: Equatable, Sendable {
|
public struct Process: Equatable {
|
||||||
|
|
||||||
/// The pid of the process.
|
/// The pid of the process.
|
||||||
public let pid: Int32
|
public let pid: Int32
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
import LocalAuthentication
|
|
||||||
import SecretKit
|
|
||||||
|
|
||||||
extension SecureEnclave {
|
|
||||||
|
|
||||||
/// A context describing a persisted authentication.
|
|
||||||
final class PersistentAuthenticationContext: PersistedAuthenticationContext {
|
|
||||||
|
|
||||||
/// The Secret to persist authentication for.
|
|
||||||
let secret: Secret
|
|
||||||
/// The LAContext used to authorize the persistent context.
|
|
||||||
nonisolated(unsafe) let context: LAContext
|
|
||||||
/// An expiration date for the context.
|
|
||||||
/// - Note - Monotonic time instead of Date() to prevent people setting the clock back.
|
|
||||||
let monotonicExpiration: UInt64
|
|
||||||
|
|
||||||
/// Initializes a context.
|
|
||||||
/// - Parameters:
|
|
||||||
/// - secret: The Secret to persist authentication for.
|
|
||||||
/// - context: The LAContext used to authorize the persistent context.
|
|
||||||
/// - duration: The duration of the authorization context, in seconds.
|
|
||||||
init(secret: Secret, context: LAContext, duration: TimeInterval) {
|
|
||||||
self.secret = secret
|
|
||||||
self.context = context
|
|
||||||
let durationInNanoSeconds = Measurement(value: duration, unit: UnitDuration.seconds).converted(to: .nanoseconds).value
|
|
||||||
self.monotonicExpiration = clock_gettime_nsec_np(CLOCK_MONOTONIC) + UInt64(durationInNanoSeconds)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A boolean describing whether or not the context is still valid.
|
|
||||||
var valid: Bool {
|
|
||||||
clock_gettime_nsec_np(CLOCK_MONOTONIC) < monotonicExpiration
|
|
||||||
}
|
|
||||||
|
|
||||||
var expiration: Date {
|
|
||||||
let remainingNanoseconds = monotonicExpiration - clock_gettime_nsec_np(CLOCK_MONOTONIC)
|
|
||||||
let remainingInSeconds = Measurement(value: Double(remainingNanoseconds), unit: UnitDuration.nanoseconds).converted(to: .seconds).value
|
|
||||||
return Date(timeIntervalSinceNow: remainingInSeconds)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
actor PersistentAuthenticationHandler: Sendable {
|
|
||||||
|
|
||||||
private var persistedAuthenticationContexts: [Secret: PersistentAuthenticationContext] = [:]
|
|
||||||
|
|
||||||
func existingPersistedAuthenticationContext(secret: Secret) -> PersistentAuthenticationContext? {
|
|
||||||
guard let persisted = persistedAuthenticationContexts[secret], persisted.valid else { return nil }
|
|
||||||
return persisted
|
|
||||||
}
|
|
||||||
|
|
||||||
func persistAuthentication(secret: Secret, forDuration duration: TimeInterval) async throws {
|
|
||||||
let newContext = LAContext()
|
|
||||||
newContext.touchIDAuthenticationAllowableReuseDuration = duration
|
|
||||||
newContext.localizedCancelTitle = String(localized: "auth_context_request_deny_button")
|
|
||||||
|
|
||||||
let formatter = DateComponentsFormatter()
|
|
||||||
formatter.unitsStyle = .spellOut
|
|
||||||
formatter.allowedUnits = [.hour, .minute, .day]
|
|
||||||
|
|
||||||
if let durationString = formatter.string(from: duration) {
|
|
||||||
newContext.localizedReason = String(localized: "auth_context_persist_for_duration_\(secret.name)_\(durationString)")
|
|
||||||
} else {
|
|
||||||
newContext.localizedReason = String(localized: "auth_context_persist_for_duration_unknown_\(secret.name)")
|
|
||||||
}
|
|
||||||
let success = try await newContext.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: newContext.localizedReason)
|
|
||||||
guard success else { return }
|
|
||||||
let context = PersistentAuthenticationContext(secret: secret, context: newContext, duration: duration)
|
|
||||||
persistedAuthenticationContexts[secret] = context
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,36 +1,38 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Observation
|
import Combine
|
||||||
import Security
|
import Security
|
||||||
import CryptoKit
|
import CryptoTokenKit
|
||||||
import LocalAuthentication
|
import LocalAuthentication
|
||||||
import SecretKit
|
import SecretKit
|
||||||
|
|
||||||
extension SecureEnclave {
|
extension SecureEnclave {
|
||||||
|
|
||||||
/// An implementation of Store backed by the Secure Enclave.
|
/// An implementation of Store backed by the Secure Enclave.
|
||||||
@Observable public final class Store: SecretStoreModifiable {
|
public class Store: SecretStoreModifiable {
|
||||||
|
|
||||||
@MainActor public var secrets: [Secret] = []
|
|
||||||
public var isAvailable: Bool {
|
public var isAvailable: Bool {
|
||||||
CryptoKit.SecureEnclave.isAvailable
|
// For some reason, as of build time, CryptoKit.SecureEnclave.isAvailable always returns false
|
||||||
|
// error msg "Received error sending GET UNIQUE DEVICE command"
|
||||||
|
// Verify it with TKTokenWatcher manually.
|
||||||
|
TKTokenWatcher().tokenIDs.contains("com.apple.setoken")
|
||||||
}
|
}
|
||||||
public let id = UUID()
|
public let id = UUID()
|
||||||
public let name = String(localized: "secure_enclave")
|
public let name = NSLocalizedString("Secure Enclave", comment: "Secure Enclave")
|
||||||
private let persistentAuthenticationHandler = PersistentAuthenticationHandler()
|
@Published public private(set) var secrets: [Secret] = []
|
||||||
|
|
||||||
|
private var persistedAuthenticationContexts: [Secret: PersistentAuthenticationContext] = [:]
|
||||||
|
|
||||||
/// Initializes a Store.
|
/// Initializes a Store.
|
||||||
@MainActor public init() {
|
public init() {
|
||||||
loadSecrets()
|
DistributedNotificationCenter.default().addObserver(forName: .secretStoreUpdated, object: nil, queue: .main) { _ in
|
||||||
Task {
|
self.reloadSecretsInternal(notifyAgent: false)
|
||||||
for await _ in DistributedNotificationCenter.default().notifications(named: .secretStoreUpdated) {
|
|
||||||
await reloadSecretsInternal(notifyAgent: false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
loadSecrets()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Public API
|
// MARK: Public API
|
||||||
|
|
||||||
public func create(name: String, requiresAuthentication: Bool) async throws {
|
public func create(name: String, requiresAuthentication: Bool) throws {
|
||||||
var accessError: SecurityError?
|
var accessError: SecurityError?
|
||||||
let flags: SecAccessControlCreateFlags
|
let flags: SecAccessControlCreateFlags
|
||||||
if requiresAuthentication {
|
if requiresAuthentication {
|
||||||
@@ -67,10 +69,10 @@ extension SecureEnclave {
|
|||||||
throw KeychainError(statusCode: nil)
|
throw KeychainError(statusCode: nil)
|
||||||
}
|
}
|
||||||
try savePublicKey(publicKey, name: name)
|
try savePublicKey(publicKey, name: name)
|
||||||
await reloadSecretsInternal()
|
reloadSecretsInternal()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func delete(secret: Secret) async throws {
|
public func delete(secret: Secret) throws {
|
||||||
let deleteAttributes = KeychainDictionary([
|
let deleteAttributes = KeychainDictionary([
|
||||||
kSecClass: kSecClassKey,
|
kSecClass: kSecClassKey,
|
||||||
kSecAttrApplicationLabel: secret.id as CFData
|
kSecAttrApplicationLabel: secret.id as CFData
|
||||||
@@ -79,10 +81,10 @@ extension SecureEnclave {
|
|||||||
if status != errSecSuccess {
|
if status != errSecSuccess {
|
||||||
throw KeychainError(statusCode: status)
|
throw KeychainError(statusCode: status)
|
||||||
}
|
}
|
||||||
await reloadSecretsInternal()
|
reloadSecretsInternal()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func update(secret: Secret, name: String) async throws {
|
public func update(secret: Secret, name: String) throws {
|
||||||
let updateQuery = KeychainDictionary([
|
let updateQuery = KeychainDictionary([
|
||||||
kSecClass: kSecClassKey,
|
kSecClass: kSecClassKey,
|
||||||
kSecAttrApplicationLabel: secret.id as CFData
|
kSecAttrApplicationLabel: secret.id as CFData
|
||||||
@@ -96,19 +98,19 @@ extension SecureEnclave {
|
|||||||
if status != errSecSuccess {
|
if status != errSecSuccess {
|
||||||
throw KeychainError(statusCode: status)
|
throw KeychainError(statusCode: status)
|
||||||
}
|
}
|
||||||
await reloadSecretsInternal()
|
reloadSecretsInternal()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sign(data: Data, with secret: Secret, for provenance: SigningRequestProvenance) async throws -> Data {
|
public func sign(data: Data, with secret: Secret, for provenance: SigningRequestProvenance) throws -> Data {
|
||||||
let context: LAContext
|
let context: LAContext
|
||||||
if let existing = await persistentAuthenticationHandler.existingPersistedAuthenticationContext(secret: secret) {
|
if let existing = persistedAuthenticationContexts[secret], existing.valid {
|
||||||
context = existing.context
|
context = existing.context
|
||||||
} else {
|
} else {
|
||||||
let newContext = LAContext()
|
let newContext = LAContext()
|
||||||
newContext.localizedCancelTitle = String(localized: "auth_context_request_deny_button")
|
newContext.localizedCancelTitle = "Deny"
|
||||||
context = newContext
|
context = newContext
|
||||||
}
|
}
|
||||||
context.localizedReason = String(localized: "auth_context_request_signature_description_\(provenance.origin.displayName)_\(secret.name)")
|
context.localizedReason = "sign a request from \"\(provenance.origin.displayName)\" using secret \"\(secret.name)\""
|
||||||
let attributes = KeychainDictionary([
|
let attributes = KeychainDictionary([
|
||||||
kSecClass: kSecClassKey,
|
kSecClass: kSecClassKey,
|
||||||
kSecAttrKeyClass: kSecAttrKeyClassPrivate,
|
kSecAttrKeyClass: kSecAttrKeyClassPrivate,
|
||||||
@@ -118,7 +120,7 @@ extension SecureEnclave {
|
|||||||
kSecAttrApplicationTag: Constants.keyTag,
|
kSecAttrApplicationTag: Constants.keyTag,
|
||||||
kSecUseAuthenticationContext: context,
|
kSecUseAuthenticationContext: context,
|
||||||
kSecReturnRef: true
|
kSecReturnRef: true
|
||||||
])
|
])
|
||||||
var untyped: CFTypeRef?
|
var untyped: CFTypeRef?
|
||||||
let status = SecItemCopyMatching(attributes, &untyped)
|
let status = SecItemCopyMatching(attributes, &untyped)
|
||||||
if status != errSecSuccess {
|
if status != errSecSuccess {
|
||||||
@@ -138,8 +140,8 @@ extension SecureEnclave {
|
|||||||
|
|
||||||
public func verify(signature: Data, for data: Data, with secret: Secret) throws -> Bool {
|
public func verify(signature: Data, for data: Data, with secret: Secret) throws -> Bool {
|
||||||
let context = LAContext()
|
let context = LAContext()
|
||||||
context.localizedReason = String(localized: "auth_context_request_verify_description_\(secret.name)")
|
context.localizedReason = "verify a signature using secret \"\(secret.name)\""
|
||||||
context.localizedCancelTitle = String(localized: "auth_context_request_deny_button")
|
context.localizedCancelTitle = "Deny"
|
||||||
let attributes = KeychainDictionary([
|
let attributes = KeychainDictionary([
|
||||||
kSecClass: kSecClassKey,
|
kSecClass: kSecClassKey,
|
||||||
kSecAttrKeyClass: kSecAttrKeyClassPrivate,
|
kSecAttrKeyClass: kSecAttrKeyClassPrivate,
|
||||||
@@ -171,16 +173,34 @@ extension SecureEnclave {
|
|||||||
return verified
|
return verified
|
||||||
}
|
}
|
||||||
|
|
||||||
public func existingPersistedAuthenticationContext(secret: Secret) async -> PersistedAuthenticationContext? {
|
public func existingPersistedAuthenticationContext(secret: Secret) -> PersistedAuthenticationContext? {
|
||||||
await persistentAuthenticationHandler.existingPersistedAuthenticationContext(secret: secret)
|
guard let persisted = persistedAuthenticationContexts[secret], persisted.valid else { return nil }
|
||||||
|
return persisted
|
||||||
}
|
}
|
||||||
|
|
||||||
public func persistAuthentication(secret: Secret, forDuration duration: TimeInterval) async throws {
|
public func persistAuthentication(secret: Secret, forDuration duration: TimeInterval) throws {
|
||||||
try await persistentAuthenticationHandler.persistAuthentication(secret: secret, forDuration: duration)
|
let newContext = LAContext()
|
||||||
|
newContext.touchIDAuthenticationAllowableReuseDuration = duration
|
||||||
|
newContext.localizedCancelTitle = "Deny"
|
||||||
|
|
||||||
|
let formatter = DateComponentsFormatter()
|
||||||
|
formatter.unitsStyle = .spellOut
|
||||||
|
formatter.allowedUnits = [.hour, .minute, .day]
|
||||||
|
|
||||||
|
if let durationString = formatter.string(from: duration) {
|
||||||
|
newContext.localizedReason = "unlock secret \"\(secret.name)\" for \(durationString)"
|
||||||
|
} else {
|
||||||
|
newContext.localizedReason = "unlock secret \"\(secret.name)\""
|
||||||
|
}
|
||||||
|
newContext.evaluatePolicy(LAPolicy.deviceOwnerAuthentication, localizedReason: newContext.localizedReason) { [weak self] success, _ in
|
||||||
|
guard success else { return }
|
||||||
|
let context = PersistentAuthenticationContext(secret: secret, context: newContext, duration: duration)
|
||||||
|
self?.persistedAuthenticationContexts[secret] = context
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reloadSecrets() async {
|
public func reloadSecrets() {
|
||||||
await reloadSecretsInternal(notifyAgent: false)
|
reloadSecretsInternal(notifyAgent: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -191,7 +211,7 @@ extension SecureEnclave.Store {
|
|||||||
|
|
||||||
/// Reloads all secrets from the store.
|
/// Reloads all secrets from the store.
|
||||||
/// - Parameter notifyAgent: A boolean indicating whether a distributed notification should be posted, notifying other processes (ie, the SecretAgent) to reload their stores as well.
|
/// - Parameter notifyAgent: A boolean indicating whether a distributed notification should be posted, notifying other processes (ie, the SecretAgent) to reload their stores as well.
|
||||||
@MainActor private func reloadSecretsInternal(notifyAgent: Bool = true) async {
|
private func reloadSecretsInternal(notifyAgent: Bool = true) {
|
||||||
let before = secrets
|
let before = secrets
|
||||||
secrets.removeAll()
|
secrets.removeAll()
|
||||||
loadSecrets()
|
loadSecrets()
|
||||||
@@ -204,7 +224,7 @@ extension SecureEnclave.Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Loads all secrets from the store.
|
/// Loads all secrets from the store.
|
||||||
@MainActor private func loadSecrets() {
|
private func loadSecrets() {
|
||||||
let publicAttributes = KeychainDictionary([
|
let publicAttributes = KeychainDictionary([
|
||||||
kSecClass: kSecClassKey,
|
kSecClass: kSecClassKey,
|
||||||
kSecAttrKeyType: SecureEnclave.Constants.keyType,
|
kSecAttrKeyType: SecureEnclave.Constants.keyType,
|
||||||
@@ -240,7 +260,7 @@ extension SecureEnclave.Store {
|
|||||||
nil)!
|
nil)!
|
||||||
|
|
||||||
let wrapped: [SecureEnclave.Secret] = publicTyped.map {
|
let wrapped: [SecureEnclave.Secret] = publicTyped.map {
|
||||||
let name = $0[kSecAttrLabel] as? String ?? String(localized: "unnamed_secret")
|
let name = $0[kSecAttrLabel] as? String ?? "Unnamed"
|
||||||
let id = $0[kSecAttrApplicationLabel] as! Data
|
let id = $0[kSecAttrApplicationLabel] as! Data
|
||||||
let publicKeyRef = $0[kSecValueRef] as! SecKey
|
let publicKeyRef = $0[kSecValueRef] as! SecKey
|
||||||
let publicKeyAttributes = SecKeyCopyAttributes(publicKeyRef) as! [CFString: Any]
|
let publicKeyAttributes = SecKeyCopyAttributes(publicKeyRef) as! [CFString: Any]
|
||||||
@@ -284,9 +304,48 @@ extension SecureEnclave.Store {
|
|||||||
extension SecureEnclave {
|
extension SecureEnclave {
|
||||||
|
|
||||||
enum Constants {
|
enum Constants {
|
||||||
static let keyTag = Data("com.maxgoedjen.secretive.secureenclave.key".utf8)
|
static let keyTag = "com.maxgoedjen.secretive.secureenclave.key".data(using: .utf8)! as CFData
|
||||||
static let keyType = kSecAttrKeyTypeECSECPrimeRandom as String
|
static let keyType = kSecAttrKeyTypeECSECPrimeRandom
|
||||||
static let unauthenticatedThreshold: TimeInterval = 0.05
|
static let unauthenticatedThreshold: TimeInterval = 0.05
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension SecureEnclave {
|
||||||
|
|
||||||
|
/// A context describing a persisted authentication.
|
||||||
|
private struct PersistentAuthenticationContext: PersistedAuthenticationContext {
|
||||||
|
|
||||||
|
/// The Secret to persist authentication for.
|
||||||
|
let secret: Secret
|
||||||
|
/// The LAContext used to authorize the persistent context.
|
||||||
|
let context: LAContext
|
||||||
|
/// An expiration date for the context.
|
||||||
|
/// - Note - Monotonic time instead of Date() to prevent people setting the clock back.
|
||||||
|
let monotonicExpiration: UInt64
|
||||||
|
|
||||||
|
/// Initializes a context.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - secret: The Secret to persist authentication for.
|
||||||
|
/// - context: The LAContext used to authorize the persistent context.
|
||||||
|
/// - duration: The duration of the authorization context, in seconds.
|
||||||
|
init(secret: Secret, context: LAContext, duration: TimeInterval) {
|
||||||
|
self.secret = secret
|
||||||
|
self.context = context
|
||||||
|
let durationInNanoSeconds = Measurement(value: duration, unit: UnitDuration.seconds).converted(to: .nanoseconds).value
|
||||||
|
self.monotonicExpiration = clock_gettime_nsec_np(CLOCK_MONOTONIC) + UInt64(durationInNanoSeconds)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A boolean describing whether or not the context is still valid.
|
||||||
|
var valid: Bool {
|
||||||
|
clock_gettime_nsec_np(CLOCK_MONOTONIC) < monotonicExpiration
|
||||||
|
}
|
||||||
|
|
||||||
|
var expiration: Date {
|
||||||
|
let remainingNanoseconds = monotonicExpiration - clock_gettime_nsec_np(CLOCK_MONOTONIC)
|
||||||
|
let remainingInSeconds = Measurement(value: Double(remainingNanoseconds), unit: UnitDuration.nanoseconds).converted(to: .seconds).value
|
||||||
|
return Date(timeIntervalSinceNow: remainingInSeconds)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,53 +1,38 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Observation
|
import Combine
|
||||||
import Security
|
import Security
|
||||||
import CryptoTokenKit
|
import CryptoTokenKit
|
||||||
import LocalAuthentication
|
import LocalAuthentication
|
||||||
import SecretKit
|
import SecretKit
|
||||||
|
|
||||||
extension SmartCard {
|
extension SmartCard {
|
||||||
|
|
||||||
@MainActor @Observable fileprivate final class State {
|
|
||||||
var isAvailable = false
|
|
||||||
var name = String(localized: "smart_card")
|
|
||||||
var secrets: [Secret] = []
|
|
||||||
let watcher = TKTokenWatcher()
|
|
||||||
var tokenID: String? = nil
|
|
||||||
nonisolated init() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An implementation of Store backed by a Smart Card.
|
/// An implementation of Store backed by a Smart Card.
|
||||||
@Observable public final class Store: SecretStore {
|
public class Store: SecretStore {
|
||||||
|
|
||||||
private let state = State()
|
|
||||||
public var isAvailable: Bool {
|
|
||||||
state.isAvailable
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Published public var isAvailable: Bool = false
|
||||||
public let id = UUID()
|
public let id = UUID()
|
||||||
@MainActor public var name: String {
|
public private(set) var name = NSLocalizedString("Smart Card", comment: "Smart Card")
|
||||||
state.name
|
@Published public private(set) var secrets: [Secret] = []
|
||||||
}
|
private let watcher = TKTokenWatcher()
|
||||||
public var secrets: [Secret] {
|
private var tokenID: String?
|
||||||
state.secrets
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initializes a Store.
|
/// Initializes a Store.
|
||||||
public init() {
|
public init() {
|
||||||
Task { @MainActor in
|
tokenID = watcher.nonSecureEnclaveTokens.first
|
||||||
if let tokenID = state.tokenID {
|
watcher.setInsertionHandler { string in
|
||||||
state.isAvailable = true
|
guard self.tokenID == nil else { return }
|
||||||
state.watcher.addRemovalHandler(self.smartcardRemoved, forTokenID: tokenID)
|
guard !string.contains("setoken") else { return }
|
||||||
}
|
|
||||||
loadSecrets()
|
self.tokenID = string
|
||||||
state.watcher.setInsertionHandler { id in
|
self.reloadSecrets()
|
||||||
// Setting insertion handler will cause it to be called immediately.
|
self.watcher.addRemovalHandler(self.smartcardRemoved, forTokenID: string)
|
||||||
// Make a thread jump so we don't hit a recursive lock attempt.
|
|
||||||
Task {
|
|
||||||
self.smartcardInserted(for: id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if let tokenID = tokenID {
|
||||||
|
self.isAvailable = true
|
||||||
|
self.watcher.addRemovalHandler(self.smartcardRemoved, forTokenID: tokenID)
|
||||||
|
}
|
||||||
|
loadSecrets()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Public API
|
// MARK: Public API
|
||||||
@@ -60,11 +45,11 @@ extension SmartCard {
|
|||||||
fatalError("Keys must be deleted on the smart card.")
|
fatalError("Keys must be deleted on the smart card.")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sign(data: Data, with secret: Secret, for provenance: SigningRequestProvenance) async throws -> Data {
|
public func sign(data: Data, with secret: Secret, for provenance: SigningRequestProvenance) throws -> Data {
|
||||||
guard let tokenID = await state.tokenID else { fatalError() }
|
guard let tokenID = tokenID else { fatalError() }
|
||||||
let context = LAContext()
|
let context = LAContext()
|
||||||
context.localizedReason = String(localized: "auth_context_request_signature_description_\(provenance.origin.displayName)_\(secret.name)")
|
context.localizedReason = "sign a request from \"\(provenance.origin.displayName)\" using secret \"\(secret.name)\""
|
||||||
context.localizedCancelTitle = String(localized: "auth_context_request_deny_button")
|
context.localizedCancelTitle = "Deny"
|
||||||
let attributes = KeychainDictionary([
|
let attributes = KeychainDictionary([
|
||||||
kSecClass: kSecClassKey,
|
kSecClass: kSecClassKey,
|
||||||
kSecAttrKeyClass: kSecAttrKeyClassPrivate,
|
kSecAttrKeyClass: kSecAttrKeyClassPrivate,
|
||||||
@@ -120,8 +105,16 @@ extension SmartCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Reloads all secrets from the store.
|
/// Reloads all secrets from the store.
|
||||||
@MainActor public func reloadSecrets() {
|
public func reloadSecrets() {
|
||||||
reloadSecretsInternal()
|
DispatchQueue.main.async {
|
||||||
|
self.isAvailable = self.tokenID != nil
|
||||||
|
let before = self.secrets
|
||||||
|
self.secrets.removeAll()
|
||||||
|
self.loadSecrets()
|
||||||
|
if self.secrets != before {
|
||||||
|
NotificationCenter.default.post(name: .secretStoreReloaded, object: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -130,43 +123,32 @@ extension SmartCard {
|
|||||||
|
|
||||||
extension SmartCard.Store {
|
extension SmartCard.Store {
|
||||||
|
|
||||||
@MainActor private func reloadSecretsInternal() {
|
|
||||||
let before = state.secrets
|
|
||||||
state.isAvailable = state.tokenID != nil
|
|
||||||
state.secrets.removeAll()
|
|
||||||
loadSecrets()
|
|
||||||
if self.secrets != before {
|
|
||||||
NotificationCenter.default.post(name: .secretStoreReloaded, object: self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Resets the token ID and reloads secrets.
|
|
||||||
/// - Parameter tokenID: The ID of the token that was inserted.
|
|
||||||
@MainActor private func smartcardInserted(for tokenID: String? = nil) {
|
|
||||||
guard let string = state.watcher.nonSecureEnclaveTokens.first else { return }
|
|
||||||
guard state.tokenID == nil else { return }
|
|
||||||
guard !string.contains("setoken") else { return }
|
|
||||||
state.tokenID = string
|
|
||||||
state.watcher.addRemovalHandler(self.smartcardRemoved, forTokenID: string)
|
|
||||||
state.tokenID = string
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Resets the token ID and reloads secrets.
|
/// Resets the token ID and reloads secrets.
|
||||||
/// - Parameter tokenID: The ID of the token that was removed.
|
/// - Parameter tokenID: The ID of the token that was removed.
|
||||||
@MainActor private func smartcardRemoved(for tokenID: String? = nil) {
|
private func smartcardRemoved(for tokenID: String? = nil) {
|
||||||
state.tokenID = nil
|
self.tokenID = nil
|
||||||
reloadSecrets()
|
reloadSecrets()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads all secrets from the store.
|
/// Loads all secrets from the store.
|
||||||
@MainActor private func loadSecrets() {
|
private func loadSecrets() {
|
||||||
guard let tokenID = state.tokenID else { return }
|
guard let tokenID = tokenID else { return }
|
||||||
|
|
||||||
let fallbackName = String(localized: "smart_card")
|
let fallbackName = NSLocalizedString("Smart Card", comment: "Smart Card")
|
||||||
if let driverName = state.watcher.tokenInfo(forTokenID: tokenID)?.driverName {
|
if #available(macOS 12.0, *) {
|
||||||
state.name = driverName
|
if let driverName = watcher.tokenInfo(forTokenID: tokenID)?.driverName {
|
||||||
|
name = driverName
|
||||||
|
} else {
|
||||||
|
name = fallbackName
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
state.name = fallbackName
|
// Hack to read name if there's only one smart card
|
||||||
|
let slotNames = TKSmartCardSlotManager().slotNames
|
||||||
|
if watcher.nonSecureEnclaveTokens.count == 1 && slotNames.count == 1 {
|
||||||
|
name = slotNames.first!
|
||||||
|
} else {
|
||||||
|
name = fallbackName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let attributes = KeychainDictionary([
|
let attributes = KeychainDictionary([
|
||||||
@@ -180,7 +162,7 @@ extension SmartCard.Store {
|
|||||||
SecItemCopyMatching(attributes, &untyped)
|
SecItemCopyMatching(attributes, &untyped)
|
||||||
guard let typed = untyped as? [[CFString: Any]] else { return }
|
guard let typed = untyped as? [[CFString: Any]] else { return }
|
||||||
let wrapped = typed.map {
|
let wrapped = typed.map {
|
||||||
let name = $0[kSecAttrLabel] as? String ?? String(localized: "unnamed_secret")
|
let name = $0[kSecAttrLabel] as? String ?? "Unnamed"
|
||||||
let tokenID = $0[kSecAttrApplicationLabel] as! Data
|
let tokenID = $0[kSecAttrApplicationLabel] as! Data
|
||||||
let algorithm = Algorithm(secAttr: $0[kSecAttrKeyType] as! NSNumber)
|
let algorithm = Algorithm(secAttr: $0[kSecAttrKeyType] as! NSNumber)
|
||||||
let keySize = $0[kSecAttrKeySizeInBits] as! Int
|
let keySize = $0[kSecAttrKeySizeInBits] as! Int
|
||||||
@@ -190,7 +172,89 @@ extension SmartCard.Store {
|
|||||||
let publicKey = publicKeyAttributes[kSecValueData] as! Data
|
let publicKey = publicKeyAttributes[kSecValueData] as! Data
|
||||||
return SmartCard.Secret(id: tokenID, name: name, algorithm: algorithm, keySize: keySize, publicKey: publicKey)
|
return SmartCard.Secret(id: tokenID, name: name, algorithm: algorithm, keySize: keySize, publicKey: publicKey)
|
||||||
}
|
}
|
||||||
state.secrets.append(contentsOf: wrapped)
|
secrets.append(contentsOf: wrapped)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Smart Card specific encryption/decryption/verification
|
||||||
|
extension SmartCard.Store {
|
||||||
|
|
||||||
|
/// Encrypts a payload with a specified key.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - data: The payload to encrypt.
|
||||||
|
/// - secret: The secret to encrypt with.
|
||||||
|
/// - Returns: The encrypted data.
|
||||||
|
/// - Warning: Encryption functions are deliberately only exposed on a library level, and are not exposed in Secretive itself to prevent users from data loss. Any pull requests which expose this functionality in the app will not be merged.
|
||||||
|
public func encrypt(data: Data, with secret: SecretType) throws -> Data {
|
||||||
|
let context = LAContext()
|
||||||
|
context.localizedReason = "encrypt data using secret \"\(secret.name)\""
|
||||||
|
context.localizedCancelTitle = "Deny"
|
||||||
|
let attributes = KeychainDictionary([
|
||||||
|
kSecAttrKeyType: secret.algorithm.secAttrKeyType,
|
||||||
|
kSecAttrKeySizeInBits: secret.keySize,
|
||||||
|
kSecAttrKeyClass: kSecAttrKeyClassPublic,
|
||||||
|
kSecUseAuthenticationContext: context
|
||||||
|
])
|
||||||
|
var encryptError: SecurityError?
|
||||||
|
let untyped: CFTypeRef? = SecKeyCreateWithData(secret.publicKey as CFData, attributes, &encryptError)
|
||||||
|
guard let untypedSafe = untyped else {
|
||||||
|
throw KeychainError(statusCode: errSecSuccess)
|
||||||
|
}
|
||||||
|
let key = untypedSafe as! SecKey
|
||||||
|
guard let signature = SecKeyCreateEncryptedData(key, encryptionAlgorithm(for: secret), data as CFData, &encryptError) else {
|
||||||
|
throw SigningError(error: encryptError)
|
||||||
|
}
|
||||||
|
return signature as Data
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decrypts a payload with a specified key.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - data: The payload to decrypt.
|
||||||
|
/// - secret: The secret to decrypt with.
|
||||||
|
/// - Returns: The decrypted data.
|
||||||
|
/// - Warning: Encryption functions are deliberately only exposed on a library level, and are not exposed in Secretive itself to prevent users from data loss. Any pull requests which expose this functionality in the app will not be merged.
|
||||||
|
public func decrypt(data: Data, with secret: SecretType) throws -> Data {
|
||||||
|
guard let tokenID = tokenID else { fatalError() }
|
||||||
|
let context = LAContext()
|
||||||
|
context.localizedReason = "decrypt data using secret \"\(secret.name)\""
|
||||||
|
context.localizedCancelTitle = "Deny"
|
||||||
|
let attributes = KeychainDictionary([
|
||||||
|
kSecClass: kSecClassKey,
|
||||||
|
kSecAttrKeyClass: kSecAttrKeyClassPrivate,
|
||||||
|
kSecAttrApplicationLabel: secret.id as CFData,
|
||||||
|
kSecAttrTokenID: tokenID,
|
||||||
|
kSecUseAuthenticationContext: context,
|
||||||
|
kSecReturnRef: true
|
||||||
|
])
|
||||||
|
var untyped: CFTypeRef?
|
||||||
|
let status = SecItemCopyMatching(attributes, &untyped)
|
||||||
|
if status != errSecSuccess {
|
||||||
|
throw KeychainError(statusCode: status)
|
||||||
|
}
|
||||||
|
guard let untypedSafe = untyped else {
|
||||||
|
throw KeychainError(statusCode: errSecSuccess)
|
||||||
|
}
|
||||||
|
let key = untypedSafe as! SecKey
|
||||||
|
var encryptError: SecurityError?
|
||||||
|
guard let signature = SecKeyCreateDecryptedData(key, encryptionAlgorithm(for: secret), data as CFData, &encryptError) else {
|
||||||
|
throw SigningError(error: encryptError)
|
||||||
|
}
|
||||||
|
return signature as Data
|
||||||
|
}
|
||||||
|
|
||||||
|
private func encryptionAlgorithm(for secret: SecretType) -> SecKeyAlgorithm {
|
||||||
|
switch (secret.algorithm, secret.keySize) {
|
||||||
|
case (.ellipticCurve, 256):
|
||||||
|
return .eciesEncryptionCofactorVariableIVX963SHA256AESGCM
|
||||||
|
case (.ellipticCurve, 384):
|
||||||
|
return .eciesEncryptionCofactorVariableIVX963SHA384AESGCM
|
||||||
|
case (.rsa, 1024), (.rsa, 2048):
|
||||||
|
return .rsaEncryptionOAEPSHA512AESGCM
|
||||||
|
default:
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,65 +1,54 @@
|
|||||||
import Testing
|
import XCTest
|
||||||
import Foundation
|
|
||||||
@testable import Brief
|
@testable import Brief
|
||||||
|
|
||||||
@Suite struct ReleaseParsingTests {
|
class ReleaseParsingTests: XCTestCase {
|
||||||
|
|
||||||
@Test
|
func testNonCritical() {
|
||||||
func nonCritical() {
|
|
||||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Initial release")
|
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Initial release")
|
||||||
#expect(release.critical == false)
|
XCTAssert(release.critical == false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testCritical() {
|
||||||
func critical() {
|
|
||||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
|
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
|
||||||
#expect(release.critical == true)
|
XCTAssert(release.critical == true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testOSMissing() {
|
||||||
func osMissing() {
|
|
||||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
|
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
|
||||||
#expect(release.minimumOSVersion == SemVer("11.0.0"))
|
XCTAssert(release.minimumOSVersion == SemVer("11.0.0"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testOSPresentWithContentBelow() {
|
||||||
func osPresentWithContentBelow() {
|
|
||||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update ##Minimum macOS Version\n1.2.3\nBuild info")
|
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update ##Minimum macOS Version\n1.2.3\nBuild info")
|
||||||
#expect(release.minimumOSVersion == SemVer("1.2.3"))
|
XCTAssert(release.minimumOSVersion == SemVer("1.2.3"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testOSPresentAtEnd() {
|
||||||
func osPresentAtEnd() {
|
|
||||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 1.2.3")
|
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 1.2.3")
|
||||||
#expect(release.minimumOSVersion == SemVer("1.2.3"))
|
XCTAssert(release.minimumOSVersion == SemVer("1.2.3"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testOSWithMacOSPrefix() {
|
||||||
func osWithMacOSPrefix() {
|
|
||||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: macOS 1.2.3")
|
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: macOS 1.2.3")
|
||||||
#expect(release.minimumOSVersion == SemVer("1.2.3"))
|
XCTAssert(release.minimumOSVersion == SemVer("1.2.3"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testOSGreaterThanMinimum() {
|
||||||
func osGreaterThanMinimum() {
|
|
||||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 1.2.3")
|
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 1.2.3")
|
||||||
#expect(release.minimumOSVersion < SemVer("11.0.0"))
|
XCTAssert(release.minimumOSVersion < SemVer("11.0.0"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testOSEqualToMinimum() {
|
||||||
func osEqualToMinimum() {
|
|
||||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 11.2.3")
|
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 11.2.3")
|
||||||
#expect(release.minimumOSVersion <= SemVer("11.2.3"))
|
XCTAssert(release.minimumOSVersion <= SemVer("11.2.3"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testOSLessThanMinimum() {
|
||||||
func osLessThanMinimum() {
|
|
||||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 1.2.3")
|
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 1.2.3")
|
||||||
#expect(release.minimumOSVersion > SemVer("1.0.0"))
|
XCTAssert(release.minimumOSVersion > SemVer("1.0.0"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testGreatestSelectedIfOldPatchIsPublishedLater() {
|
||||||
@MainActor func greatestSelectedIfOldPatchIsPublishedLater() async throws {
|
|
||||||
// If 2.x.x series has been published, and a patch for 1.x.x is issued
|
// If 2.x.x series has been published, and a patch for 1.x.x is issued
|
||||||
// 2.x.x should still be selected if user can run it.
|
// 2.x.x should still be selected if user can run it.
|
||||||
let updater = Updater(checkOnLaunch: false, osVersion: SemVer("2.2.3"), currentVersion: SemVer("1.0.0"))
|
let updater = Updater(checkOnLaunch: false, osVersion: SemVer("2.2.3"), currentVersion: SemVer("1.0.0"))
|
||||||
@@ -71,13 +60,16 @@ import Foundation
|
|||||||
Release(name: "1.0.2", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Emergency patch! Minimum macOS Version: 1.2.3"),
|
Release(name: "1.0.2", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Emergency patch! Minimum macOS Version: 1.2.3"),
|
||||||
]
|
]
|
||||||
|
|
||||||
await updater.evaluate(releases: releases)
|
let expectation = XCTestExpectation()
|
||||||
try await Task.sleep(nanoseconds: 1)
|
updater.evaluate(releases: releases)
|
||||||
#expect(updater.update == two)
|
DispatchQueue.main.async {
|
||||||
|
XCTAssert(updater.update == two)
|
||||||
|
expectation.fulfill()
|
||||||
|
}
|
||||||
|
wait(for: [expectation], timeout: 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testLatestVersionIsRunnable() {
|
||||||
@MainActor func latestVersionIsRunnable() async throws {
|
|
||||||
// If the 2.x.x series has been published but the user can't run it
|
// If the 2.x.x series has been published but the user can't run it
|
||||||
// the last version the user can run should be selected.
|
// the last version the user can run should be selected.
|
||||||
let updater = Updater(checkOnLaunch: false, osVersion: SemVer("1.2.3"), currentVersion: SemVer("1.0.0"))
|
let updater = Updater(checkOnLaunch: false, osVersion: SemVer("1.2.3"), currentVersion: SemVer("1.0.0"))
|
||||||
@@ -88,13 +80,16 @@ import Foundation
|
|||||||
Release(name: "2.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "2.0 available! Minimum macOS Version: 2.2.3"),
|
Release(name: "2.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "2.0 available! Minimum macOS Version: 2.2.3"),
|
||||||
Release(name: "1.0.2", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Emergency patch! Minimum macOS Version: 1.2.3"),
|
Release(name: "1.0.2", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Emergency patch! Minimum macOS Version: 1.2.3"),
|
||||||
]
|
]
|
||||||
await updater.evaluate(releases: releases)
|
let expectation = XCTestExpectation()
|
||||||
try await Task.sleep(nanoseconds: 1)
|
updater.evaluate(releases: releases)
|
||||||
#expect(updater.update == oneOhTwo)
|
DispatchQueue.main.async {
|
||||||
|
XCTAssert(updater.update == oneOhTwo)
|
||||||
|
expectation.fulfill()
|
||||||
|
}
|
||||||
|
wait(for: [expectation], timeout: 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
func testSorting() {
|
||||||
func sorting() {
|
|
||||||
let two = Release(name: "2.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "2.0 available!")
|
let two = Release(name: "2.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "2.0 available!")
|
||||||
let releases = [
|
let releases = [
|
||||||
Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Initial release"),
|
Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Initial release"),
|
||||||
@@ -103,7 +98,7 @@ import Foundation
|
|||||||
Release(name: "1.0.2", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Emergency patch!"),
|
Release(name: "1.0.2", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Emergency patch!"),
|
||||||
]
|
]
|
||||||
let sorted = releases.sorted().reversed().first
|
let sorted = releases.sorted().reversed().first
|
||||||
#expect(sorted == two)
|
XCTAssert(sorted == two)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +1,51 @@
|
|||||||
import Testing
|
import XCTest
|
||||||
import Foundation
|
|
||||||
@testable import Brief
|
@testable import Brief
|
||||||
|
|
||||||
@Suite struct SemVerTests {
|
class SemVerTests: XCTestCase {
|
||||||
|
|
||||||
@Test func equal() {
|
func testEqual() {
|
||||||
let current = SemVer("1.0.2")
|
let current = SemVer("1.0.2")
|
||||||
let old = SemVer("1.0.2")
|
let old = SemVer("1.0.2")
|
||||||
#expect(!(current > old))
|
XCTAssert(!(current > old))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func patchGreaterButMinorLess() {
|
func testPatchGreaterButMinorLess() {
|
||||||
let current = SemVer("1.1.0")
|
let current = SemVer("1.1.0")
|
||||||
let old = SemVer("1.0.2")
|
let old = SemVer("1.0.2")
|
||||||
#expect(current > old)
|
XCTAssert(current > old)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func majorSameMinorGreater() {
|
func testMajorSameMinorGreater() {
|
||||||
let current = SemVer("1.0.2")
|
let current = SemVer("1.0.2")
|
||||||
let new = SemVer("1.0.3")
|
let new = SemVer("1.0.3")
|
||||||
#expect(current < new)
|
XCTAssert(current < new)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func majorGreaterMinorLesser() {
|
func testMajorGreaterMinorLesser() {
|
||||||
let current = SemVer("1.0.2")
|
let current = SemVer("1.0.2")
|
||||||
let new = SemVer("2.0.0")
|
let new = SemVer("2.0.0")
|
||||||
#expect(current < new)
|
XCTAssert(current < new)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func regularParsing() {
|
func testRegularParsing() {
|
||||||
let current = SemVer("1.0.2")
|
let current = SemVer("1.0.2")
|
||||||
#expect(current.versionNumbers == [1, 0, 2])
|
XCTAssert(current.versionNumbers == [1, 0, 2])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func noPatch() {
|
func testNoPatch() {
|
||||||
let current = SemVer("1.1")
|
let current = SemVer("1.1")
|
||||||
#expect(current.versionNumbers == [1, 1, 0])
|
XCTAssert(current.versionNumbers == [1, 1, 0])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func garbage() {
|
func testGarbage() {
|
||||||
let current = SemVer("Test")
|
let current = SemVer("Test")
|
||||||
#expect(current.versionNumbers == [0, 0, 0])
|
XCTAssert(current.versionNumbers == [0, 0, 0])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func beta() {
|
func testBeta() {
|
||||||
let current = SemVer("1.0.2")
|
let current = SemVer("1.0.2")
|
||||||
let new = SemVer("1.1.0_beta1")
|
let new = SemVer("1.1.0_beta1")
|
||||||
#expect(current < new)
|
XCTAssert(current < new)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +1,48 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Testing
|
import XCTest
|
||||||
import CryptoKit
|
import CryptoKit
|
||||||
@testable import SecretKit
|
@testable import SecretKit
|
||||||
@testable import SecretAgentKit
|
@testable import SecretAgentKit
|
||||||
|
|
||||||
@Suite struct AgentTests {
|
class AgentTests: XCTestCase {
|
||||||
|
|
||||||
let stubWriter = StubFileHandleWriter()
|
let stubWriter = StubFileHandleWriter()
|
||||||
|
|
||||||
// MARK: Identity Listing
|
// MARK: Identity Listing
|
||||||
|
|
||||||
@Test func emptyStores() async {
|
func testEmptyStores() {
|
||||||
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestIdentities)
|
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestIdentities)
|
||||||
let agent = Agent(storeList: SecretStoreList())
|
let agent = Agent(storeList: SecretStoreList())
|
||||||
await agent.handle(reader: stubReader, writer: stubWriter)
|
agent.handle(reader: stubReader, writer: stubWriter)
|
||||||
#expect(stubWriter.data == Constants.Responses.requestIdentitiesEmpty)
|
XCTAssertEqual(stubWriter.data, Constants.Responses.requestIdentitiesEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func identitiesList() async {
|
func testIdentitiesList() {
|
||||||
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestIdentities)
|
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestIdentities)
|
||||||
let list = await storeList(with: [Constants.Secrets.ecdsa256Secret, Constants.Secrets.ecdsa384Secret])
|
let list = storeList(with: [Constants.Secrets.ecdsa256Secret, Constants.Secrets.ecdsa384Secret])
|
||||||
let agent = Agent(storeList: list)
|
let agent = Agent(storeList: list)
|
||||||
await agent.handle(reader: stubReader, writer: stubWriter)
|
agent.handle(reader: stubReader, writer: stubWriter)
|
||||||
#expect(stubWriter.data == Constants.Responses.requestIdentitiesMultiple)
|
XCTAssertEqual(stubWriter.data, Constants.Responses.requestIdentitiesMultiple)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Signatures
|
// MARK: Signatures
|
||||||
|
|
||||||
@Test func noMatchingIdentities() async {
|
func testNoMatchingIdentities() {
|
||||||
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignatureWithNoneMatching)
|
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignatureWithNoneMatching)
|
||||||
let list = await storeList(with: [Constants.Secrets.ecdsa256Secret, Constants.Secrets.ecdsa384Secret])
|
let list = storeList(with: [Constants.Secrets.ecdsa256Secret, Constants.Secrets.ecdsa384Secret])
|
||||||
let agent = Agent(storeList: list)
|
let agent = Agent(storeList: list)
|
||||||
await agent.handle(reader: stubReader, writer: stubWriter)
|
agent.handle(reader: stubReader, writer: stubWriter)
|
||||||
#expect(stubWriter.data == Constants.Responses.requestFailure)
|
// XCTAssertEqual(stubWriter.data, Constants.Responses.requestFailure)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func signature() async throws {
|
func testSignature() {
|
||||||
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
||||||
let requestReader = OpenSSHReader(data: Constants.Requests.requestSignature[5...])
|
let requestReader = OpenSSHReader(data: Constants.Requests.requestSignature[5...])
|
||||||
_ = requestReader.readNextChunk()
|
_ = requestReader.readNextChunk()
|
||||||
let dataToSign = requestReader.readNextChunk()
|
let dataToSign = requestReader.readNextChunk()
|
||||||
let list = await storeList(with: [Constants.Secrets.ecdsa256Secret, Constants.Secrets.ecdsa384Secret])
|
let list = storeList(with: [Constants.Secrets.ecdsa256Secret, Constants.Secrets.ecdsa384Secret])
|
||||||
let agent = Agent(storeList: list)
|
let agent = Agent(storeList: list)
|
||||||
await agent.handle(reader: stubReader, writer: stubWriter)
|
agent.handle(reader: stubReader, writer: stubWriter)
|
||||||
let outer = OpenSSHReader(data: stubWriter.data[5...])
|
let outer = OpenSSHReader(data: stubWriter.data[5...])
|
||||||
let payload = outer.readNextChunk()
|
let payload = outer.readNextChunk()
|
||||||
let inner = OpenSSHReader(data: payload)
|
let inner = OpenSSHReader(data: payload)
|
||||||
@@ -62,50 +62,50 @@ import CryptoKit
|
|||||||
rs.append(s)
|
rs.append(s)
|
||||||
let signature = try! P256.Signing.ECDSASignature(rawRepresentation: rs)
|
let signature = try! P256.Signing.ECDSASignature(rawRepresentation: rs)
|
||||||
let referenceValid = try! P256.Signing.PublicKey(x963Representation: Constants.Secrets.ecdsa256Secret.publicKey).isValidSignature(signature, for: dataToSign)
|
let referenceValid = try! P256.Signing.PublicKey(x963Representation: Constants.Secrets.ecdsa256Secret.publicKey).isValidSignature(signature, for: dataToSign)
|
||||||
let store = await list.stores.first!
|
let store = list.stores.first!
|
||||||
let derVerifies = try await store.verify(signature: signature.derRepresentation, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa256Secret))
|
let derVerifies = try! store.verify(signature: signature.derRepresentation, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa256Secret))
|
||||||
let invalidRandomSignature = try await store.verify(signature: "invalid".data(using: .utf8)!, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa256Secret))
|
let invalidRandomSignature = try? store.verify(signature: "invalid".data(using: .utf8)!, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa256Secret))
|
||||||
let invalidRandomData = try await store.verify(signature: signature.derRepresentation, for: "invalid".data(using: .utf8)!, with: AnySecret(Constants.Secrets.ecdsa256Secret))
|
let invalidRandomData = try? store.verify(signature: signature.derRepresentation, for: "invalid".data(using: .utf8)!, with: AnySecret(Constants.Secrets.ecdsa256Secret))
|
||||||
let invalidWrongKey = try await store.verify(signature: signature.derRepresentation, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa384Secret))
|
let invalidWrongKey = try? store.verify(signature: signature.derRepresentation, for: dataToSign, with: AnySecret(Constants.Secrets.ecdsa384Secret))
|
||||||
#expect(referenceValid)
|
XCTAssertTrue(referenceValid)
|
||||||
#expect(derVerifies)
|
XCTAssertTrue(derVerifies)
|
||||||
#expect(invalidRandomSignature == false)
|
XCTAssert(invalidRandomSignature == false)
|
||||||
#expect(invalidRandomData == false)
|
XCTAssert(invalidRandomData == false)
|
||||||
#expect(invalidWrongKey == false)
|
XCTAssert(invalidWrongKey == false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Witness protocol
|
// MARK: Witness protocol
|
||||||
|
|
||||||
@Test func witnessObjectionStopsRequest() async {
|
func testWitnessObjectionStopsRequest() {
|
||||||
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
||||||
let list = await storeList(with: [Constants.Secrets.ecdsa256Secret])
|
let list = storeList(with: [Constants.Secrets.ecdsa256Secret])
|
||||||
let witness = StubWitness(speakNow: { _,_ in
|
let witness = StubWitness(speakNow: { _,_ in
|
||||||
return true
|
return true
|
||||||
}, witness: { _, _ in })
|
}, witness: { _, _ in })
|
||||||
let agent = Agent(storeList: list, witness: witness)
|
let agent = Agent(storeList: list, witness: witness)
|
||||||
await agent.handle(reader: stubReader, writer: stubWriter)
|
agent.handle(reader: stubReader, writer: stubWriter)
|
||||||
#expect(stubWriter.data == Constants.Responses.requestFailure)
|
XCTAssertEqual(stubWriter.data, Constants.Responses.requestFailure)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func witnessSignature() async {
|
func testWitnessSignature() {
|
||||||
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
||||||
let list = await storeList(with: [Constants.Secrets.ecdsa256Secret])
|
let list = storeList(with: [Constants.Secrets.ecdsa256Secret])
|
||||||
nonisolated(unsafe) var witnessed = false
|
var witnessed = false
|
||||||
let witness = StubWitness(speakNow: { _, trace in
|
let witness = StubWitness(speakNow: { _, trace in
|
||||||
return false
|
return false
|
||||||
}, witness: { _, trace in
|
}, witness: { _, trace in
|
||||||
witnessed = true
|
witnessed = true
|
||||||
})
|
})
|
||||||
let agent = Agent(storeList: list, witness: witness)
|
let agent = Agent(storeList: list, witness: witness)
|
||||||
await agent.handle(reader: stubReader, writer: stubWriter)
|
agent.handle(reader: stubReader, writer: stubWriter)
|
||||||
#expect(witnessed)
|
XCTAssertTrue(witnessed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func requestTracing() async {
|
func testRequestTracing() {
|
||||||
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
||||||
let list = await storeList(with: [Constants.Secrets.ecdsa256Secret])
|
let list = storeList(with: [Constants.Secrets.ecdsa256Secret])
|
||||||
nonisolated(unsafe) var speakNowTrace: SigningRequestProvenance?
|
var speakNowTrace: SigningRequestProvenance! = nil
|
||||||
nonisolated(unsafe) var witnessTrace: SigningRequestProvenance?
|
var witnessTrace: SigningRequestProvenance! = nil
|
||||||
let witness = StubWitness(speakNow: { _, trace in
|
let witness = StubWitness(speakNow: { _, trace in
|
||||||
speakNowTrace = trace
|
speakNowTrace = trace
|
||||||
return false
|
return false
|
||||||
@@ -113,39 +113,39 @@ import CryptoKit
|
|||||||
witnessTrace = trace
|
witnessTrace = trace
|
||||||
})
|
})
|
||||||
let agent = Agent(storeList: list, witness: witness)
|
let agent = Agent(storeList: list, witness: witness)
|
||||||
await agent.handle(reader: stubReader, writer: stubWriter)
|
agent.handle(reader: stubReader, writer: stubWriter)
|
||||||
#expect(witnessTrace == speakNowTrace)
|
XCTAssertEqual(witnessTrace, speakNowTrace)
|
||||||
#expect(witnessTrace?.origin.displayName == "Finder")
|
XCTAssertEqual(witnessTrace.origin.displayName, "Finder")
|
||||||
#expect(witnessTrace?.origin.validSignature == true)
|
XCTAssertEqual(witnessTrace.origin.validSignature, true)
|
||||||
#expect(witnessTrace?.origin.parentPID == 1)
|
XCTAssertEqual(witnessTrace.origin.parentPID, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Exception Handling
|
// MARK: Exception Handling
|
||||||
|
|
||||||
@Test func signatureException() async {
|
func testSignatureException() {
|
||||||
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
|
||||||
let list = await storeList(with: [Constants.Secrets.ecdsa256Secret, Constants.Secrets.ecdsa384Secret])
|
let list = storeList(with: [Constants.Secrets.ecdsa256Secret, Constants.Secrets.ecdsa384Secret])
|
||||||
let store = await list.stores.first?.base as! Stub.Store
|
let store = list.stores.first?.base as! Stub.Store
|
||||||
store.shouldThrow = true
|
store.shouldThrow = true
|
||||||
let agent = Agent(storeList: list)
|
let agent = Agent(storeList: list)
|
||||||
await agent.handle(reader: stubReader, writer: stubWriter)
|
agent.handle(reader: stubReader, writer: stubWriter)
|
||||||
#expect(stubWriter.data == Constants.Responses.requestFailure)
|
XCTAssertEqual(stubWriter.data, Constants.Responses.requestFailure)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Unsupported
|
// MARK: Unsupported
|
||||||
|
|
||||||
@Test func unhandledAdd() async {
|
func testUnhandledAdd() {
|
||||||
let stubReader = StubFileHandleReader(availableData: Constants.Requests.addIdentity)
|
let stubReader = StubFileHandleReader(availableData: Constants.Requests.addIdentity)
|
||||||
let agent = Agent(storeList: SecretStoreList())
|
let agent = Agent(storeList: SecretStoreList())
|
||||||
await agent.handle(reader: stubReader, writer: stubWriter)
|
agent.handle(reader: stubReader, writer: stubWriter)
|
||||||
#expect(stubWriter.data == Constants.Responses.requestFailure)
|
XCTAssertEqual(stubWriter.data, Constants.Responses.requestFailure)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AgentTests {
|
extension AgentTests {
|
||||||
|
|
||||||
@MainActor func storeList(with secrets: [Stub.Secret]) async -> SecretStoreList {
|
func storeList(with secrets: [Stub.Secret]) -> SecretStoreList {
|
||||||
let store = Stub.Store()
|
let store = Stub.Store()
|
||||||
store.secrets.append(contentsOf: secrets)
|
store.secrets.append(contentsOf: secrets)
|
||||||
let storeList = SecretStoreList()
|
let storeList = SecretStoreList()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import SecretAgentKit
|
import SecretAgentKit
|
||||||
|
|
||||||
class StubFileHandleWriter: FileHandleWriter, @unchecked Sendable {
|
class StubFileHandleWriter: FileHandleWriter {
|
||||||
|
|
||||||
var data = Data()
|
var data = Data()
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ struct Stub {}
|
|||||||
|
|
||||||
extension Stub {
|
extension Stub {
|
||||||
|
|
||||||
public final class Store: SecretStore, @unchecked Sendable {
|
public class Store: SecretStore {
|
||||||
|
|
||||||
public let isAvailable = true
|
public let isAvailable = true
|
||||||
public let id = UUID()
|
public let id = UUID()
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import SecretAgentKit
|
|||||||
|
|
||||||
struct StubWitness {
|
struct StubWitness {
|
||||||
|
|
||||||
let speakNow: @Sendable (AnySecret, SigningRequestProvenance) -> Bool
|
let speakNow: (AnySecret, SigningRequestProvenance) -> Bool
|
||||||
let witness: @Sendable (AnySecret, SigningRequestProvenance) -> ()
|
let witness: (AnySecret, SigningRequestProvenance) -> ()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Testing
|
import XCTest
|
||||||
@testable import SecretKit
|
@testable import SecretKit
|
||||||
@testable import SecureEnclaveSecretKit
|
@testable import SecureEnclaveSecretKit
|
||||||
@testable import SmartCardSecretKit
|
@testable import SmartCardSecretKit
|
||||||
|
|
||||||
@Suite struct AnySecretTests {
|
class AnySecretTests: XCTestCase {
|
||||||
|
|
||||||
@Test func eraser() {
|
func testEraser() {
|
||||||
let secret = SmartCard.Secret(id: UUID().uuidString.data(using: .utf8)!, name: "Name", algorithm: .ellipticCurve, keySize: 256, publicKey: UUID().uuidString.data(using: .utf8)!)
|
let secret = SmartCard.Secret(id: UUID().uuidString.data(using: .utf8)!, name: "Name", algorithm: .ellipticCurve, keySize: 256, publicKey: UUID().uuidString.data(using: .utf8)!)
|
||||||
let erased = AnySecret(secret)
|
let erased = AnySecret(secret)
|
||||||
#expect(erased.id == secret.id as AnyHashable)
|
XCTAssert(erased.id == secret.id as AnyHashable)
|
||||||
#expect(erased.name == secret.name)
|
XCTAssert(erased.name == secret.name)
|
||||||
#expect(erased.algorithm == secret.algorithm)
|
XCTAssert(erased.algorithm == secret.algorithm)
|
||||||
#expect(erased.keySize == secret.keySize)
|
XCTAssert(erased.keySize == secret.keySize)
|
||||||
#expect(erased.publicKey == secret.publicKey)
|
XCTAssert(erased.publicKey == secret.publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Testing
|
import XCTest
|
||||||
@testable import SecretKit
|
@testable import SecretKit
|
||||||
@testable import SecureEnclaveSecretKit
|
@testable import SecureEnclaveSecretKit
|
||||||
@testable import SmartCardSecretKit
|
@testable import SmartCardSecretKit
|
||||||
|
|
||||||
@Suite struct OpenSSHReaderTests {
|
class OpenSSHReaderTests: XCTestCase {
|
||||||
|
|
||||||
@Test func signatureRequest() {
|
func testSignatureRequest() {
|
||||||
let reader = OpenSSHReader(data: Constants.signatureRequest)
|
let reader = OpenSSHReader(data: Constants.signatureRequest)
|
||||||
let hash = reader.readNextChunk()
|
let hash = reader.readNextChunk()
|
||||||
#expect(hash == Data(base64Encoded: "AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBEqCbkJbOHy5S1wVCaJoKPmpS0egM4frMqllgnlRRQ/Uvnn6EVS8oV03cPA2Bz0EdESyRKA/sbmn0aBtgjIwGELxu45UXEW1TEz6TxyS0u3vuIqR3Wo1CrQWRDnkrG/pBQ=="))
|
XCTAssert(hash == Data(base64Encoded: "AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBEqCbkJbOHy5S1wVCaJoKPmpS0egM4frMqllgnlRRQ/Uvnn6EVS8oV03cPA2Bz0EdESyRKA/sbmn0aBtgjIwGELxu45UXEW1TEz6TxyS0u3vuIqR3Wo1CrQWRDnkrG/pBQ=="))
|
||||||
let dataToSign = reader.readNextChunk()
|
let dataToSign = reader.readNextChunk()
|
||||||
#expect(dataToSign == Data(base64Encoded: "AAAAICi5xf1ixOestUlxdjvt/BDcM+rzhwy7Vo8cW5YcxA8+MgAAAANnaXQAAAAOc3NoLWNvbm5lY3Rpb24AAAAJcHVibGlja2V5AQAAABNlY2RzYS1zaGEyLW5pc3RwMzg0AAAAiAAAABNlY2RzYS1zaGEyLW5pc3RwMzg0AAAACG5pc3RwMzg0AAAAYQRKgm5CWzh8uUtcFQmiaCj5qUtHoDOH6zKpZYJ5UUUP1L55+hFUvKFdN3DwNgc9BHREskSgP7G5p9GgbYIyMBhC8buOVFxFtUxM+k8cktLt77iKkd1qNQq0FkQ55Kxv6QU="))
|
XCTAssert(dataToSign == Data(base64Encoded: "AAAAICi5xf1ixOestUlxdjvt/BDcM+rzhwy7Vo8cW5YcxA8+MgAAAANnaXQAAAAOc3NoLWNvbm5lY3Rpb24AAAAJcHVibGlja2V5AQAAABNlY2RzYS1zaGEyLW5pc3RwMzg0AAAAiAAAABNlY2RzYS1zaGEyLW5pc3RwMzg0AAAACG5pc3RwMzg0AAAAYQRKgm5CWzh8uUtcFQmiaCj5qUtHoDOH6zKpZYJ5UUUP1L55+hFUvKFdN3DwNgc9BHREskSgP7G5p9GgbYIyMBhC8buOVFxFtUxM+k8cktLt77iKkd1qNQq0FkQ55Kxv6QU="))
|
||||||
let empty = reader.readNextChunk()
|
let empty = reader.readNextChunk()
|
||||||
#expect(empty.isEmpty)
|
XCTAssert(empty.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +1,45 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Testing
|
import XCTest
|
||||||
@testable import SecretKit
|
@testable import SecretKit
|
||||||
@testable import SecureEnclaveSecretKit
|
@testable import SecureEnclaveSecretKit
|
||||||
@testable import SmartCardSecretKit
|
@testable import SmartCardSecretKit
|
||||||
|
|
||||||
@Suite struct OpenSSHWriterTests {
|
class OpenSSHWriterTests: XCTestCase {
|
||||||
|
|
||||||
let writer = OpenSSHKeyWriter()
|
let writer = OpenSSHKeyWriter()
|
||||||
|
|
||||||
@Test func ecdsa256MD5Fingerprint() {
|
func testECDSA256MD5Fingerprint() {
|
||||||
#expect(writer.openSSHMD5Fingerprint(secret: Constants.ecdsa256Secret) == "dc:60:4d:ff:c2:d9:18:8b:2f:24:40:b5:7f:43:47:e5")
|
XCTAssertEqual(writer.openSSHMD5Fingerprint(secret: Constants.ecdsa256Secret), "dc:60:4d:ff:c2:d9:18:8b:2f:24:40:b5:7f:43:47:e5")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func ecdsa256SHA256Fingerprint() {
|
func testECDSA256SHA256Fingerprint() {
|
||||||
#expect(writer.openSSHSHA256Fingerprint(secret: Constants.ecdsa256Secret) == "SHA256:/VQFeGyM8qKA8rB6WGMuZZxZLJln2UgXLk3F0uTF650")
|
XCTAssertEqual(writer.openSSHSHA256Fingerprint(secret: Constants.ecdsa256Secret), "SHA256:/VQFeGyM8qKA8rB6WGMuZZxZLJln2UgXLk3F0uTF650")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func ecdsa256PublicKey() {
|
func testECDSA256PublicKey() {
|
||||||
#expect(writer.openSSHString(secret: Constants.ecdsa256Secret) ==
|
XCTAssertEqual(writer.openSSHString(secret: Constants.ecdsa256Secret),
|
||||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOVEjgAA5PHqRgwykjN5qM21uWCHFSY/Sqo5gkHAkn+e1MMQKHOLga7ucB9b3mif33MBid59GRK9GEPVlMiSQwo=")
|
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOVEjgAA5PHqRgwykjN5qM21uWCHFSY/Sqo5gkHAkn+e1MMQKHOLga7ucB9b3mif33MBid59GRK9GEPVlMiSQwo=")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func ecdsa256Hash() {
|
func testECDSA256Hash() {
|
||||||
#expect(writer.data(secret: Constants.ecdsa256Secret) == Data(base64Encoded: "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOVEjgAA5PHqRgwykjN5qM21uWCHFSY/Sqo5gkHAkn+e1MMQKHOLga7ucB9b3mif33MBid59GRK9GEPVlMiSQwo="))
|
XCTAssertEqual(writer.data(secret: Constants.ecdsa256Secret), Data(base64Encoded: "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOVEjgAA5PHqRgwykjN5qM21uWCHFSY/Sqo5gkHAkn+e1MMQKHOLga7ucB9b3mif33MBid59GRK9GEPVlMiSQwo="))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func ecdsa384MD5Fingerprint() {
|
func testECDSA384MD5Fingerprint() {
|
||||||
#expect(writer.openSSHMD5Fingerprint(secret: Constants.ecdsa384Secret) == "66:e0:66:d7:41:ed:19:8e:e2:20:df:ce:ac:7e:2b:6e")
|
XCTAssertEqual(writer.openSSHMD5Fingerprint(secret: Constants.ecdsa384Secret), "66:e0:66:d7:41:ed:19:8e:e2:20:df:ce:ac:7e:2b:6e")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func ecdsa384SHA256Fingerprint() {
|
func testECDSA384SHA256Fingerprint() {
|
||||||
#expect(writer.openSSHSHA256Fingerprint(secret: Constants.ecdsa384Secret) == "SHA256:GJUEymQNL9ymaMRRJCMGY4rWIJHu/Lm8Yhao/PAiz1I")
|
XCTAssertEqual(writer.openSSHSHA256Fingerprint(secret: Constants.ecdsa384Secret), "SHA256:GJUEymQNL9ymaMRRJCMGY4rWIJHu/Lm8Yhao/PAiz1I")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func ecdsa384PublicKey() {
|
func testECDSA384PublicKey() {
|
||||||
#expect(writer.openSSHString(secret: Constants.ecdsa384Secret) ==
|
XCTAssertEqual(writer.openSSHString(secret: Constants.ecdsa384Secret),
|
||||||
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBG2MNc/C5OTHFE2tBvbZCVcpOGa8vBMquiTLkH4lwkeqOPxhi+PyYUfQZMTRJNPiTyWPoMBqNiCIFRVv60yPN/AHufHaOgbdTP42EgMlMMImkAjYUEv9DESHTVIs2PW1yQ==")
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBG2MNc/C5OTHFE2tBvbZCVcpOGa8vBMquiTLkH4lwkeqOPxhi+PyYUfQZMTRJNPiTyWPoMBqNiCIFRVv60yPN/AHufHaOgbdTP42EgMlMMImkAjYUEv9DESHTVIs2PW1yQ==")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func ecdsa384Hash() {
|
func testECDSA384Hash() {
|
||||||
#expect(writer.data(secret: Constants.ecdsa384Secret) == Data(base64Encoded: "AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBG2MNc/C5OTHFE2tBvbZCVcpOGa8vBMquiTLkH4lwkeqOPxhi+PyYUfQZMTRJNPiTyWPoMBqNiCIFRVv60yPN/AHufHaOgbdTP42EgMlMMImkAjYUEv9DESHTVIs2PW1yQ=="))
|
XCTAssertEqual(writer.data(secret: Constants.ecdsa384Secret), Data(base64Encoded: "AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBG2MNc/C5OTHFE2tBvbZCVcpOGa8vBMquiTLkH4lwkeqOPxhi+PyYUfQZMTRJNPiTyWPoMBqNiCIFRVv60yPN/AHufHaOgbdTP42EgMlMMImkAjYUEv9DESHTVIs2PW1yQ=="))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,52 +6,50 @@ import SecureEnclaveSecretKit
|
|||||||
import SmartCardSecretKit
|
import SmartCardSecretKit
|
||||||
import SecretAgentKit
|
import SecretAgentKit
|
||||||
import Brief
|
import Brief
|
||||||
import Observation
|
|
||||||
|
|
||||||
@main
|
@NSApplicationMain
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
|
|
||||||
@MainActor private let storeList: SecretStoreList = {
|
private let storeList: SecretStoreList = {
|
||||||
let list = SecretStoreList()
|
let list = SecretStoreList()
|
||||||
list.add(store: SecureEnclave.Store())
|
list.add(store: SecureEnclave.Store())
|
||||||
list.add(store: SmartCard.Store())
|
list.add(store: SmartCard.Store())
|
||||||
return list
|
return list
|
||||||
}()
|
}()
|
||||||
private let updater = Updater(checkOnLaunch: true)
|
private static var homeDirectory: String {
|
||||||
|
// if UserDefaults.standard.bool(forKey: "usehomedirectory") {
|
||||||
|
let folder = "/Users/max/.secretive"
|
||||||
|
try? FileManager.default.createDirectory(atPath: folder, withIntermediateDirectories: false)
|
||||||
|
return folder
|
||||||
|
// } else {
|
||||||
|
// return FileManager.default.homeDirectoryForCurrentUser.path
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
private let updater = Updater(checkOnLaunch: false)
|
||||||
private let notifier = Notifier()
|
private let notifier = Notifier()
|
||||||
private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: NSHomeDirectory())
|
private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: homeDirectory)
|
||||||
private lazy var agent: Agent = {
|
private lazy var agent: Agent = {
|
||||||
Agent(storeList: storeList, witness: notifier)
|
Agent(storeList: storeList, witness: notifier)
|
||||||
}()
|
}()
|
||||||
private lazy var socketController: SocketController = {
|
private lazy var socketController: SocketController = {
|
||||||
let path = (NSHomeDirectory() as NSString).appendingPathComponent("socket.ssh") as String
|
let path = (AppDelegate.homeDirectory as NSString).appendingPathComponent("socket.ssh") as String
|
||||||
return SocketController(path: path)
|
return SocketController(path: path)
|
||||||
}()
|
}()
|
||||||
private var updateSink: AnyCancellable?
|
private var updateSink: AnyCancellable?
|
||||||
private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent", category: "AppDelegate")
|
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
logger.debug("SecretAgent finished launching")
|
Logger().debug("SecretAgent finished launching")
|
||||||
Task { @MainActor in
|
DispatchQueue.main.async {
|
||||||
socketController.handler = { [agent] reader, writer in
|
self.socketController.handler = self.agent.handle(reader:writer:)
|
||||||
await agent.handle(reader: reader, writer: writer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Task {
|
NotificationCenter.default.addObserver(forName: .secretStoreReloaded, object: nil, queue: .main) { [self] _ in
|
||||||
for await _ in NotificationCenter.default.notifications(named: .secretStoreReloaded) {
|
try? publicKeyFileStoreController.generatePublicKeys(for: storeList.allSecrets, clear: true)
|
||||||
try? publicKeyFileStoreController.generatePublicKeys(for: storeList.allSecrets, clear: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
try? publicKeyFileStoreController.generatePublicKeys(for: storeList.allSecrets, clear: true)
|
try? publicKeyFileStoreController.generatePublicKeys(for: storeList.allSecrets, clear: true)
|
||||||
notifier.prompt()
|
notifier.prompt()
|
||||||
_ = withObservationTracking {
|
updateSink = updater.$update.sink { update in
|
||||||
updater.update
|
guard let update = update else { return }
|
||||||
} onChange: { [updater, notifier] in
|
self.notifier.notify(update: update, ignore: self.updater.ignore(release:))
|
||||||
Task {
|
|
||||||
await notifier.notify(update: updater.update!) { release in
|
|
||||||
await updater.ignore(release: release)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "1x",
|
||||||
|
"size" : "16x16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "2x",
|
||||||
|
"size" : "16x16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "1x",
|
||||||
|
"size" : "32x32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "2x",
|
||||||
|
"size" : "32x32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "1x",
|
||||||
|
"size" : "128x128"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "2x",
|
||||||
|
"size" : "128x128"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "Mac Icon.png",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "1x",
|
||||||
|
"size" : "256x256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "Mac Icon@0.25x.png",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "2x",
|
||||||
|
"size" : "256x256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "1x",
|
||||||
|
"size" : "512x512"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "mac",
|
||||||
|
"scale" : "2x",
|
||||||
|
"size" : "512x512"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 40 KiB |
6
Sources/SecretAgent/Assets.xcassets/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,13 +5,13 @@ import SecretKit
|
|||||||
import SecretAgentKit
|
import SecretAgentKit
|
||||||
import Brief
|
import Brief
|
||||||
|
|
||||||
final class Notifier: Sendable {
|
class Notifier {
|
||||||
|
|
||||||
private let notificationDelegate = NotificationDelegate()
|
private let notificationDelegate = NotificationDelegate()
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
let updateAction = UNNotificationAction(identifier: Constants.updateActionIdentitifier, title: String(localized: "update_notification_update_button"), options: [])
|
let updateAction = UNNotificationAction(identifier: Constants.updateActionIdentitifier, title: "Update", options: [])
|
||||||
let ignoreAction = UNNotificationAction(identifier: Constants.ignoreActionIdentitifier, title: String(localized: "update_notification_ignore_button"), options: [])
|
let ignoreAction = UNNotificationAction(identifier: Constants.ignoreActionIdentitifier, title: "Ignore", options: [])
|
||||||
let updateCategory = UNNotificationCategory(identifier: Constants.updateCategoryIdentitifier, actions: [updateAction, ignoreAction], intentIdentifiers: [], options: [])
|
let updateCategory = UNNotificationCategory(identifier: Constants.updateCategoryIdentitifier, actions: [updateAction, ignoreAction], intentIdentifiers: [], options: [])
|
||||||
let criticalUpdateCategory = UNNotificationCategory(identifier: Constants.criticalUpdateCategoryIdentitifier, actions: [updateAction], intentIdentifiers: [], options: [])
|
let criticalUpdateCategory = UNNotificationCategory(identifier: Constants.criticalUpdateCategoryIdentitifier, actions: [updateAction], intentIdentifiers: [], options: [])
|
||||||
|
|
||||||
@@ -22,35 +22,32 @@ final class Notifier: Sendable {
|
|||||||
Measurement(value: 24, unit: UnitDuration.hours)
|
Measurement(value: 24, unit: UnitDuration.hours)
|
||||||
]
|
]
|
||||||
|
|
||||||
let doNotPersistAction = UNNotificationAction(identifier: Constants.doNotPersistActionIdentitifier, title: String(localized: "persist_authentication_decline_button"), options: [])
|
let doNotPersistAction = UNNotificationAction(identifier: Constants.doNotPersistActionIdentitifier, title: "Do Not Unlock", options: [])
|
||||||
var allPersistenceActions = [doNotPersistAction]
|
var allPersistenceActions = [doNotPersistAction]
|
||||||
|
|
||||||
let formatter = DateComponentsFormatter()
|
let formatter = DateComponentsFormatter()
|
||||||
formatter.unitsStyle = .spellOut
|
formatter.unitsStyle = .spellOut
|
||||||
formatter.allowedUnits = [.hour, .minute, .day]
|
formatter.allowedUnits = [.hour, .minute, .day]
|
||||||
|
|
||||||
var identifiers: [String: TimeInterval] = [:]
|
|
||||||
for duration in rawDurations {
|
for duration in rawDurations {
|
||||||
let seconds = duration.converted(to: .seconds).value
|
let seconds = duration.converted(to: .seconds).value
|
||||||
guard let string = formatter.string(from: seconds)?.capitalized else { continue }
|
guard let string = formatter.string(from: seconds)?.capitalized else { continue }
|
||||||
let identifier = Constants.persistAuthenticationCategoryIdentitifier.appending("\(seconds)")
|
let identifier = Constants.persistAuthenticationCategoryIdentitifier.appending("\(seconds)")
|
||||||
let action = UNNotificationAction(identifier: identifier, title: string, options: [])
|
let action = UNNotificationAction(identifier: identifier, title: string, options: [])
|
||||||
identifiers[identifier] = seconds
|
notificationDelegate.persistOptions[identifier] = seconds
|
||||||
allPersistenceActions.append(action)
|
allPersistenceActions.append(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
let persistAuthenticationCategory = UNNotificationCategory(identifier: Constants.persistAuthenticationCategoryIdentitifier, actions: allPersistenceActions, intentIdentifiers: [], options: [])
|
let persistAuthenticationCategory = UNNotificationCategory(identifier: Constants.persistAuthenticationCategoryIdentitifier, actions: allPersistenceActions, intentIdentifiers: [], options: [])
|
||||||
if persistAuthenticationCategory.responds(to: Selector(("actionsMenuTitle"))) {
|
if persistAuthenticationCategory.responds(to: Selector(("actionsMenuTitle"))) {
|
||||||
persistAuthenticationCategory.setValue(String(localized: "persist_authentication_accept_button"), forKey: "_actionsMenuTitle")
|
persistAuthenticationCategory.setValue("Leave Unlocked", forKey: "_actionsMenuTitle")
|
||||||
}
|
}
|
||||||
UNUserNotificationCenter.current().setNotificationCategories([updateCategory, criticalUpdateCategory, persistAuthenticationCategory])
|
UNUserNotificationCenter.current().setNotificationCategories([updateCategory, criticalUpdateCategory, persistAuthenticationCategory])
|
||||||
UNUserNotificationCenter.current().delegate = notificationDelegate
|
UNUserNotificationCenter.current().delegate = notificationDelegate
|
||||||
|
|
||||||
Task {
|
notificationDelegate.persistAuthentication = { secret, store, duration in
|
||||||
await notificationDelegate.state.setPersistenceState(options: identifiers) { secret, store, duration in
|
guard let duration = duration else { return }
|
||||||
guard let duration = duration else { return }
|
try? store.persistAuthentication(secret: secret, forDuration: duration)
|
||||||
try? await store.persistAuthentication(secret: secret, forDuration: duration)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -60,51 +57,57 @@ final class Notifier: Sendable {
|
|||||||
notificationCenter.requestAuthorization(options: .alert) { _, _ in }
|
notificationCenter.requestAuthorization(options: .alert) { _, _ in }
|
||||||
}
|
}
|
||||||
|
|
||||||
func notify(accessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) async {
|
func notify(accessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) {
|
||||||
await notificationDelegate.state.setPending(secret: secret, store: store)
|
notificationDelegate.pendingPersistableSecrets[secret.id.description] = secret
|
||||||
|
notificationDelegate.pendingPersistableStores[store.id.description] = store
|
||||||
let notificationCenter = UNUserNotificationCenter.current()
|
let notificationCenter = UNUserNotificationCenter.current()
|
||||||
let notificationContent = UNMutableNotificationContent()
|
let notificationContent = UNMutableNotificationContent()
|
||||||
notificationContent.title = String(localized: "signed_notification_title_\(provenance.origin.displayName)")
|
notificationContent.title = "Signed Request from \(provenance.origin.displayName)"
|
||||||
notificationContent.subtitle = String(localized: "signed_notification_description_\(secret.name)")
|
notificationContent.subtitle = "Using secret \"\(secret.name)\""
|
||||||
notificationContent.userInfo[Constants.persistSecretIDKey] = secret.id.description
|
notificationContent.userInfo[Constants.persistSecretIDKey] = secret.id.description
|
||||||
notificationContent.userInfo[Constants.persistStoreIDKey] = store.id.description
|
notificationContent.userInfo[Constants.persistStoreIDKey] = store.id.description
|
||||||
notificationContent.interruptionLevel = .timeSensitive
|
if #available(macOS 12.0, *) {
|
||||||
if await store.existingPersistedAuthenticationContext(secret: secret) == nil && secret.requiresAuthentication {
|
notificationContent.interruptionLevel = .timeSensitive
|
||||||
|
}
|
||||||
|
if secret.requiresAuthentication && store.existingPersistedAuthenticationContext(secret: secret) == nil {
|
||||||
notificationContent.categoryIdentifier = Constants.persistAuthenticationCategoryIdentitifier
|
notificationContent.categoryIdentifier = Constants.persistAuthenticationCategoryIdentitifier
|
||||||
}
|
}
|
||||||
if let iconURL = provenance.origin.iconURL, let attachment = try? UNNotificationAttachment(identifier: "icon", url: iconURL, options: nil) {
|
if let iconURL = provenance.origin.iconURL, let attachment = try? UNNotificationAttachment(identifier: "icon", url: iconURL, options: nil) {
|
||||||
notificationContent.attachments = [attachment]
|
notificationContent.attachments = [attachment]
|
||||||
}
|
}
|
||||||
let request = UNNotificationRequest(identifier: UUID().uuidString, content: notificationContent, trigger: nil)
|
let request = UNNotificationRequest(identifier: UUID().uuidString, content: notificationContent, trigger: nil)
|
||||||
try? await notificationCenter.add(request)
|
notificationCenter.add(request, withCompletionHandler: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func notify(update: Release, ignore: (@Sendable (Release) async -> Void)?) async {
|
func notify(update: Release, ignore: ((Release) -> Void)?) {
|
||||||
await notificationDelegate.state.prepareForNotification(release: update, ignoreAction: ignore)
|
notificationDelegate.release = update
|
||||||
|
notificationDelegate.ignore = ignore
|
||||||
let notificationCenter = UNUserNotificationCenter.current()
|
let notificationCenter = UNUserNotificationCenter.current()
|
||||||
let notificationContent = UNMutableNotificationContent()
|
let notificationContent = UNMutableNotificationContent()
|
||||||
if update.critical {
|
if update.critical {
|
||||||
notificationContent.interruptionLevel = .critical
|
if #available(macOS 12.0, *) {
|
||||||
notificationContent.title = String(localized: "update_notification_update_critical_title_\(update.name)")
|
notificationContent.interruptionLevel = .critical
|
||||||
|
}
|
||||||
|
notificationContent.title = "Critical Security Update - \(update.name)"
|
||||||
} else {
|
} else {
|
||||||
notificationContent.title = String(localized: "update_notification_update_normal_title_\(update.name)")
|
notificationContent.title = "Update Available - \(update.name)"
|
||||||
}
|
}
|
||||||
notificationContent.subtitle = String(localized: "update_notification_update_description")
|
notificationContent.subtitle = "Click to Update"
|
||||||
notificationContent.body = update.body
|
notificationContent.body = update.body
|
||||||
notificationContent.categoryIdentifier = update.critical ? Constants.criticalUpdateCategoryIdentitifier : Constants.updateCategoryIdentitifier
|
notificationContent.categoryIdentifier = update.critical ? Constants.criticalUpdateCategoryIdentitifier : Constants.updateCategoryIdentitifier
|
||||||
let request = UNNotificationRequest(identifier: UUID().uuidString, content: notificationContent, trigger: nil)
|
let request = UNNotificationRequest(identifier: UUID().uuidString, content: notificationContent, trigger: nil)
|
||||||
try? await notificationCenter.add(request)
|
notificationCenter.add(request, withCompletionHandler: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Notifier: SigningWitness {
|
extension Notifier: SigningWitness {
|
||||||
|
|
||||||
func speakNowOrForeverHoldYourPeace(forAccessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) async throws {
|
func speakNowOrForeverHoldYourPeace(forAccessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) throws {
|
||||||
}
|
}
|
||||||
|
|
||||||
func witness(accessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) async throws {
|
func witness(accessTo secret: AnySecret, from store: AnySecretStore, by provenance: SigningRequestProvenance) throws {
|
||||||
await notify(accessTo: secret, from: store, by: provenance)
|
notify(accessTo: secret, from: store, by: provenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -130,91 +133,55 @@ extension Notifier {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate, Sendable {
|
class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate {
|
||||||
|
|
||||||
fileprivate actor State {
|
fileprivate var release: Release?
|
||||||
typealias PersistAction = (@Sendable (AnySecret, AnySecretStore, TimeInterval?) async -> Void)
|
fileprivate var ignore: ((Release) -> Void)?
|
||||||
typealias IgnoreAction = (@Sendable (Release) async -> Void)
|
fileprivate var persistAuthentication: ((AnySecret, AnySecretStore, TimeInterval?) -> Void)?
|
||||||
fileprivate var release: Release?
|
fileprivate var persistOptions: [String: TimeInterval] = [:]
|
||||||
fileprivate var ignoreAction: IgnoreAction?
|
fileprivate var pendingPersistableStores: [String: AnySecretStore] = [:]
|
||||||
fileprivate var persistAction: PersistAction?
|
fileprivate var pendingPersistableSecrets: [String: AnySecret] = [:]
|
||||||
fileprivate var persistOptions: [String: TimeInterval] = [:]
|
|
||||||
fileprivate var pendingPersistableStores: [String: AnySecretStore] = [:]
|
|
||||||
fileprivate var pendingPersistableSecrets: [String: AnySecret] = [:]
|
|
||||||
|
|
||||||
func setPending(secret: AnySecret, store: AnySecretStore) {
|
|
||||||
pendingPersistableSecrets[secret.id.description] = secret
|
|
||||||
pendingPersistableStores[store.id.description] = store
|
|
||||||
}
|
|
||||||
|
|
||||||
func retrievePending(secretID: String, storeID: String, optionID: String) -> (AnySecret, AnySecretStore, TimeInterval)? {
|
|
||||||
guard let secret = pendingPersistableSecrets[secretID],
|
|
||||||
let store = pendingPersistableStores[storeID],
|
|
||||||
let options = persistOptions[optionID] else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
pendingPersistableSecrets.removeValue(forKey: secretID)
|
|
||||||
return (secret, store, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setPersistenceState(options: [String: TimeInterval], action: @escaping PersistAction) {
|
|
||||||
self.persistOptions = options
|
|
||||||
self.persistAction = action
|
|
||||||
}
|
|
||||||
|
|
||||||
func prepareForNotification(release: Release, ignoreAction: IgnoreAction?) {
|
|
||||||
self.release = release
|
|
||||||
self.ignoreAction = ignoreAction
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fileprivate let state = State()
|
|
||||||
|
|
||||||
func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) {
|
func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
|
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||||
let category = response.notification.request.content.categoryIdentifier
|
let category = response.notification.request.content.categoryIdentifier
|
||||||
switch category {
|
switch category {
|
||||||
case Notifier.Constants.updateCategoryIdentitifier:
|
case Notifier.Constants.updateCategoryIdentitifier:
|
||||||
await handleUpdateResponse(response: response)
|
handleUpdateResponse(response: response)
|
||||||
case Notifier.Constants.persistAuthenticationCategoryIdentitifier:
|
case Notifier.Constants.persistAuthenticationCategoryIdentitifier:
|
||||||
await handlePersistAuthenticationResponse(response: response)
|
handlePersistAuthenticationResponse(response: response)
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
completionHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleUpdateResponse(response: UNNotificationResponse) async {
|
func handleUpdateResponse(response: UNNotificationResponse) {
|
||||||
let id = response.actionIdentifier
|
guard let update = release else { return }
|
||||||
guard let update = await state.release else { return }
|
switch response.actionIdentifier {
|
||||||
switch id {
|
|
||||||
case Notifier.Constants.updateActionIdentitifier, UNNotificationDefaultActionIdentifier:
|
case Notifier.Constants.updateActionIdentitifier, UNNotificationDefaultActionIdentifier:
|
||||||
NSWorkspace.shared.open(update.html_url)
|
NSWorkspace.shared.open(update.html_url)
|
||||||
case Notifier.Constants.ignoreActionIdentitifier:
|
case Notifier.Constants.ignoreActionIdentitifier:
|
||||||
await state.ignoreAction?(update)
|
ignore?(update)
|
||||||
default:
|
default:
|
||||||
fatalError()
|
fatalError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handlePersistAuthenticationResponse(response: UNNotificationResponse) async {
|
func handlePersistAuthenticationResponse(response: UNNotificationResponse) {
|
||||||
guard let secretID = response.notification.request.content.userInfo[Notifier.Constants.persistSecretIDKey] as? String,
|
guard let secretID = response.notification.request.content.userInfo[Notifier.Constants.persistSecretIDKey] as? String, let secret = pendingPersistableSecrets[secretID],
|
||||||
let storeID = response.notification.request.content.userInfo[Notifier.Constants.persistStoreIDKey] as? String else {
|
let storeID = response.notification.request.content.userInfo[Notifier.Constants.persistStoreIDKey] as? String, let store = pendingPersistableStores[storeID]
|
||||||
return
|
else { return }
|
||||||
}
|
pendingPersistableSecrets[secretID] = nil
|
||||||
let optionID = response.actionIdentifier
|
persistAuthentication?(secret, store, persistOptions[response.actionIdentifier])
|
||||||
guard let (secret, store, persistOptions) = await state.retrievePending(secretID: secretID, storeID: storeID, optionID: optionID) else { return }
|
|
||||||
await state.persistAction?(secret, store, persistOptions)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
||||||
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {
|
completionHandler([.list, .banner])
|
||||||
[.list, .banner]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,14 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>com.apple.security.app-sandbox</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.network.client</key>
|
||||||
|
<true/>
|
||||||
<key>com.apple.security.smartcard</key>
|
<key>com.apple.security.smartcard</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.temporary-exception.files.home-relative-path.read-write</key>
|
||||||
|
<array/>
|
||||||
<key>keychain-access-groups</key>
|
<key>keychain-access-groups</key>
|
||||||
<array>
|
<array>
|
||||||
<string>$(AppIdentifierPrefix)com.maxgoedjen.Secretive</string>
|
<string>$(AppIdentifierPrefix)com.maxgoedjen.Secretive</string>
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
5003EF612780081600DF2006 /* SmartCardSecretKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5003EF602780081600DF2006 /* SmartCardSecretKit */; };
|
5003EF612780081600DF2006 /* SmartCardSecretKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5003EF602780081600DF2006 /* SmartCardSecretKit */; };
|
||||||
5003EF632780081B00DF2006 /* SecureEnclaveSecretKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5003EF622780081B00DF2006 /* SecureEnclaveSecretKit */; };
|
5003EF632780081B00DF2006 /* SecureEnclaveSecretKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5003EF622780081B00DF2006 /* SecureEnclaveSecretKit */; };
|
||||||
5003EF652780081B00DF2006 /* SmartCardSecretKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5003EF642780081B00DF2006 /* SmartCardSecretKit */; };
|
5003EF652780081B00DF2006 /* SmartCardSecretKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5003EF642780081B00DF2006 /* SmartCardSecretKit */; };
|
||||||
5008C2402E52792400507AC2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50617D8623FCE48E0099B055 /* Assets.xcassets */; };
|
|
||||||
500B93C32B478D8400E157DE /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 500B93C22B478D8400E157DE /* Localizable.xcstrings */; };
|
|
||||||
501421622781262300BBAA70 /* Brief in Frameworks */ = {isa = PBXBuildFile; productRef = 501421612781262300BBAA70 /* Brief */; };
|
501421622781262300BBAA70 /* Brief in Frameworks */ = {isa = PBXBuildFile; productRef = 501421612781262300BBAA70 /* Brief */; };
|
||||||
501421652781268000BBAA70 /* SecretAgent.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 50A3B78A24026B7500D209EA /* SecretAgent.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
501421652781268000BBAA70 /* SecretAgent.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 50A3B78A24026B7500D209EA /* SecretAgent.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
50153E20250AFCB200525160 /* UpdateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50153E1F250AFCB200525160 /* UpdateView.swift */; };
|
50153E20250AFCB200525160 /* UpdateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50153E1F250AFCB200525160 /* UpdateView.swift */; };
|
||||||
@@ -31,6 +29,7 @@
|
|||||||
50617D8523FCE48E0099B055 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50617D8423FCE48E0099B055 /* ContentView.swift */; };
|
50617D8523FCE48E0099B055 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50617D8423FCE48E0099B055 /* ContentView.swift */; };
|
||||||
50617D8723FCE48E0099B055 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50617D8623FCE48E0099B055 /* Assets.xcassets */; };
|
50617D8723FCE48E0099B055 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50617D8623FCE48E0099B055 /* Assets.xcassets */; };
|
||||||
50617D8A23FCE48E0099B055 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50617D8923FCE48E0099B055 /* Preview Assets.xcassets */; };
|
50617D8A23FCE48E0099B055 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50617D8923FCE48E0099B055 /* Preview Assets.xcassets */; };
|
||||||
|
50617D9923FCE48E0099B055 /* SecretiveTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50617D9823FCE48E0099B055 /* SecretiveTests.swift */; };
|
||||||
50617DD223FCEFA90099B055 /* PreviewStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50617DD123FCEFA90099B055 /* PreviewStore.swift */; };
|
50617DD223FCEFA90099B055 /* PreviewStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50617DD123FCEFA90099B055 /* PreviewStore.swift */; };
|
||||||
5065E313295517C500E16645 /* ToolbarButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5065E312295517C500E16645 /* ToolbarButtonStyle.swift */; };
|
5065E313295517C500E16645 /* ToolbarButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5065E312295517C500E16645 /* ToolbarButtonStyle.swift */; };
|
||||||
5066A6C22516F303004B5A36 /* SetupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5066A6C12516F303004B5A36 /* SetupView.swift */; };
|
5066A6C22516F303004B5A36 /* SetupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5066A6C12516F303004B5A36 /* SetupView.swift */; };
|
||||||
@@ -46,12 +45,12 @@
|
|||||||
508BF2AA25B4F1CB009EFB7E /* InternetAccessPolicy.plist in Resources */ = {isa = PBXBuildFile; fileRef = 508BF29425B4F140009EFB7E /* InternetAccessPolicy.plist */; };
|
508BF2AA25B4F1CB009EFB7E /* InternetAccessPolicy.plist in Resources */ = {isa = PBXBuildFile; fileRef = 508BF29425B4F140009EFB7E /* InternetAccessPolicy.plist */; };
|
||||||
5091D2BC25183B830049FD9B /* ApplicationDirectoryController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5091D2BB25183B830049FD9B /* ApplicationDirectoryController.swift */; };
|
5091D2BC25183B830049FD9B /* ApplicationDirectoryController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5091D2BB25183B830049FD9B /* ApplicationDirectoryController.swift */; };
|
||||||
5099A02423FD2AAA0062B6F2 /* CreateSecretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099A02323FD2AAA0062B6F2 /* CreateSecretView.swift */; };
|
5099A02423FD2AAA0062B6F2 /* CreateSecretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099A02323FD2AAA0062B6F2 /* CreateSecretView.swift */; };
|
||||||
|
50A3B79124026B7600D209EA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50A3B79024026B7600D209EA /* Assets.xcassets */; };
|
||||||
50A3B79424026B7600D209EA /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50A3B79324026B7600D209EA /* Preview Assets.xcassets */; };
|
50A3B79424026B7600D209EA /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50A3B79324026B7600D209EA /* Preview Assets.xcassets */; };
|
||||||
50A3B79724026B7600D209EA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50A3B79524026B7600D209EA /* Main.storyboard */; };
|
50A3B79724026B7600D209EA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50A3B79524026B7600D209EA /* Main.storyboard */; };
|
||||||
50B8550D24138C4F009958AC /* DeleteSecretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B8550C24138C4F009958AC /* DeleteSecretView.swift */; };
|
50B8550D24138C4F009958AC /* DeleteSecretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B8550C24138C4F009958AC /* DeleteSecretView.swift */; };
|
||||||
50BB046B2418AAAE00D6E079 /* EmptyStoreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50BB046A2418AAAE00D6E079 /* EmptyStoreView.swift */; };
|
50BB046B2418AAAE00D6E079 /* EmptyStoreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50BB046A2418AAAE00D6E079 /* EmptyStoreView.swift */; };
|
||||||
50C385A52407A76D00AF2719 /* SecretDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50C385A42407A76D00AF2719 /* SecretDetailView.swift */; };
|
50C385A52407A76D00AF2719 /* SecretDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50C385A42407A76D00AF2719 /* SecretDetailView.swift */; };
|
||||||
50E9CF422B51D596004AB36D /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 500B93C22B478D8400E157DE /* Localizable.xcstrings */; };
|
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@@ -62,6 +61,13 @@
|
|||||||
remoteGlobalIDString = 50A3B78924026B7500D209EA;
|
remoteGlobalIDString = 50A3B78924026B7500D209EA;
|
||||||
remoteInfo = SecretAgent;
|
remoteInfo = SecretAgent;
|
||||||
};
|
};
|
||||||
|
50617D9523FCE48E0099B055 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 50617D7723FCE48D0099B055 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = 50617D7E23FCE48D0099B055;
|
||||||
|
remoteInfo = Secretive;
|
||||||
|
};
|
||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
@@ -102,7 +108,6 @@
|
|||||||
50020BAF24064869003D4025 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
50020BAF24064869003D4025 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
50033AC227813F1700253856 /* BundleIDs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleIDs.swift; sourceTree = "<group>"; };
|
50033AC227813F1700253856 /* BundleIDs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleIDs.swift; sourceTree = "<group>"; };
|
||||||
5003EF39278005C800DF2006 /* Packages */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Packages; sourceTree = "<group>"; };
|
5003EF39278005C800DF2006 /* Packages */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Packages; sourceTree = "<group>"; };
|
||||||
500B93C22B478D8400E157DE /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
|
|
||||||
50153E1F250AFCB200525160 /* UpdateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateView.swift; sourceTree = "<group>"; };
|
50153E1F250AFCB200525160 /* UpdateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateView.swift; sourceTree = "<group>"; };
|
||||||
50153E21250DECA300525160 /* SecretListItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretListItemView.swift; sourceTree = "<group>"; };
|
50153E21250DECA300525160 /* SecretListItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretListItemView.swift; sourceTree = "<group>"; };
|
||||||
5018F54E24064786002EB505 /* Notifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifier.swift; sourceTree = "<group>"; };
|
5018F54E24064786002EB505 /* Notifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifier.swift; sourceTree = "<group>"; };
|
||||||
@@ -115,6 +120,9 @@
|
|||||||
50617D8923FCE48E0099B055 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
50617D8923FCE48E0099B055 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||||
50617D8E23FCE48E0099B055 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
50617D8E23FCE48E0099B055 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
50617D8F23FCE48E0099B055 /* Secretive.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Secretive.entitlements; sourceTree = "<group>"; };
|
50617D8F23FCE48E0099B055 /* Secretive.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Secretive.entitlements; sourceTree = "<group>"; };
|
||||||
|
50617D9423FCE48E0099B055 /* SecretiveTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SecretiveTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
50617D9823FCE48E0099B055 /* SecretiveTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretiveTests.swift; sourceTree = "<group>"; };
|
||||||
|
50617D9A23FCE48E0099B055 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
50617DD123FCEFA90099B055 /* PreviewStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewStore.swift; sourceTree = "<group>"; };
|
50617DD123FCEFA90099B055 /* PreviewStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewStore.swift; sourceTree = "<group>"; };
|
||||||
5065E312295517C500E16645 /* ToolbarButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolbarButtonStyle.swift; sourceTree = "<group>"; };
|
5065E312295517C500E16645 /* ToolbarButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolbarButtonStyle.swift; sourceTree = "<group>"; };
|
||||||
5066A6C12516F303004B5A36 /* SetupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupView.swift; sourceTree = "<group>"; };
|
5066A6C12516F303004B5A36 /* SetupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupView.swift; sourceTree = "<group>"; };
|
||||||
@@ -133,6 +141,7 @@
|
|||||||
5091D2BB25183B830049FD9B /* ApplicationDirectoryController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationDirectoryController.swift; sourceTree = "<group>"; };
|
5091D2BB25183B830049FD9B /* ApplicationDirectoryController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationDirectoryController.swift; sourceTree = "<group>"; };
|
||||||
5099A02323FD2AAA0062B6F2 /* CreateSecretView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateSecretView.swift; sourceTree = "<group>"; };
|
5099A02323FD2AAA0062B6F2 /* CreateSecretView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateSecretView.swift; sourceTree = "<group>"; };
|
||||||
50A3B78A24026B7500D209EA /* SecretAgent.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SecretAgent.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
50A3B78A24026B7500D209EA /* SecretAgent.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SecretAgent.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
50A3B79024026B7600D209EA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
50A3B79324026B7600D209EA /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
50A3B79324026B7600D209EA /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||||
50A3B79624026B7600D209EA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
50A3B79624026B7600D209EA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||||
50A3B79824026B7600D209EA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
50A3B79824026B7600D209EA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
@@ -154,6 +163,13 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
50617D9123FCE48E0099B055 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
50A3B78724026B7500D209EA /* Frameworks */ = {
|
50A3B78724026B7500D209EA /* Frameworks */ = {
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -182,6 +198,7 @@
|
|||||||
children = (
|
children = (
|
||||||
5003EF39278005C800DF2006 /* Packages */,
|
5003EF39278005C800DF2006 /* Packages */,
|
||||||
50617D8123FCE48E0099B055 /* Secretive */,
|
50617D8123FCE48E0099B055 /* Secretive */,
|
||||||
|
50617D9723FCE48E0099B055 /* SecretiveTests */,
|
||||||
50A3B78B24026B7500D209EA /* SecretAgent */,
|
50A3B78B24026B7500D209EA /* SecretAgent */,
|
||||||
508A58AF241E144C0069DC07 /* Config */,
|
508A58AF241E144C0069DC07 /* Config */,
|
||||||
50617D8023FCE48E0099B055 /* Products */,
|
50617D8023FCE48E0099B055 /* Products */,
|
||||||
@@ -193,6 +210,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
50617D7F23FCE48E0099B055 /* Secretive.app */,
|
50617D7F23FCE48E0099B055 /* Secretive.app */,
|
||||||
|
50617D9423FCE48E0099B055 /* SecretiveTests.xctest */,
|
||||||
50A3B78A24026B7500D209EA /* SecretAgent.app */,
|
50A3B78A24026B7500D209EA /* SecretAgent.app */,
|
||||||
);
|
);
|
||||||
name = Products;
|
name = Products;
|
||||||
@@ -210,7 +228,6 @@
|
|||||||
508BF28D25B4F005009EFB7E /* InternetAccessPolicy.plist */,
|
508BF28D25B4F005009EFB7E /* InternetAccessPolicy.plist */,
|
||||||
50617D8F23FCE48E0099B055 /* Secretive.entitlements */,
|
50617D8F23FCE48E0099B055 /* Secretive.entitlements */,
|
||||||
506772C62424784600034DED /* Credits.rtf */,
|
506772C62424784600034DED /* Credits.rtf */,
|
||||||
500B93C22B478D8400E157DE /* Localizable.xcstrings */,
|
|
||||||
50617D8823FCE48E0099B055 /* Preview Content */,
|
50617D8823FCE48E0099B055 /* Preview Content */,
|
||||||
);
|
);
|
||||||
path = Secretive;
|
path = Secretive;
|
||||||
@@ -227,6 +244,15 @@
|
|||||||
path = "Preview Content";
|
path = "Preview Content";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
50617D9723FCE48E0099B055 /* SecretiveTests */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
50617D9823FCE48E0099B055 /* SecretiveTests.swift */,
|
||||||
|
50617D9A23FCE48E0099B055 /* Info.plist */,
|
||||||
|
);
|
||||||
|
path = SecretiveTests;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
508A58AF241E144C0069DC07 /* Config */ = {
|
508A58AF241E144C0069DC07 /* Config */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -280,6 +306,7 @@
|
|||||||
children = (
|
children = (
|
||||||
50020BAF24064869003D4025 /* AppDelegate.swift */,
|
50020BAF24064869003D4025 /* AppDelegate.swift */,
|
||||||
5018F54E24064786002EB505 /* Notifier.swift */,
|
5018F54E24064786002EB505 /* Notifier.swift */,
|
||||||
|
50A3B79024026B7600D209EA /* Assets.xcassets */,
|
||||||
50A3B79524026B7600D209EA /* Main.storyboard */,
|
50A3B79524026B7600D209EA /* Main.storyboard */,
|
||||||
50A3B79824026B7600D209EA /* Info.plist */,
|
50A3B79824026B7600D209EA /* Info.plist */,
|
||||||
508BF29425B4F140009EFB7E /* InternetAccessPolicy.plist */,
|
508BF29425B4F140009EFB7E /* InternetAccessPolicy.plist */,
|
||||||
@@ -326,6 +353,24 @@
|
|||||||
productReference = 50617D7F23FCE48E0099B055 /* Secretive.app */;
|
productReference = 50617D7F23FCE48E0099B055 /* Secretive.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
};
|
};
|
||||||
|
50617D9323FCE48E0099B055 /* SecretiveTests */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 50617DA023FCE48E0099B055 /* Build configuration list for PBXNativeTarget "SecretiveTests" */;
|
||||||
|
buildPhases = (
|
||||||
|
50617D9023FCE48E0099B055 /* Sources */,
|
||||||
|
50617D9123FCE48E0099B055 /* Frameworks */,
|
||||||
|
50617D9223FCE48E0099B055 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
50617D9623FCE48E0099B055 /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
name = SecretiveTests;
|
||||||
|
productName = SecretiveTests;
|
||||||
|
productReference = 50617D9423FCE48E0099B055 /* SecretiveTests.xctest */;
|
||||||
|
productType = "com.apple.product-type.bundle.unit-test";
|
||||||
|
};
|
||||||
50A3B78924026B7500D209EA /* SecretAgent */ = {
|
50A3B78924026B7500D209EA /* SecretAgent */ = {
|
||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 50A3B79A24026B7600D209EA /* Build configuration list for PBXNativeTarget "SecretAgent" */;
|
buildConfigurationList = 50A3B79A24026B7600D209EA /* Build configuration list for PBXNativeTarget "SecretAgent" */;
|
||||||
@@ -357,14 +402,17 @@
|
|||||||
50617D7723FCE48D0099B055 /* Project object */ = {
|
50617D7723FCE48D0099B055 /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
BuildIndependentTargetsInParallel = YES;
|
|
||||||
LastSwiftUpdateCheck = 1220;
|
LastSwiftUpdateCheck = 1220;
|
||||||
LastUpgradeCheck = 2600;
|
LastUpgradeCheck = 1320;
|
||||||
ORGANIZATIONNAME = "Max Goedjen";
|
ORGANIZATIONNAME = "Max Goedjen";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
50617D7E23FCE48D0099B055 = {
|
50617D7E23FCE48D0099B055 = {
|
||||||
CreatedOnToolsVersion = 11.3;
|
CreatedOnToolsVersion = 11.3;
|
||||||
};
|
};
|
||||||
|
50617D9323FCE48E0099B055 = {
|
||||||
|
CreatedOnToolsVersion = 11.3;
|
||||||
|
TestTargetID = 50617D7E23FCE48D0099B055;
|
||||||
|
};
|
||||||
50A3B78924026B7500D209EA = {
|
50A3B78924026B7500D209EA = {
|
||||||
CreatedOnToolsVersion = 11.4;
|
CreatedOnToolsVersion = 11.4;
|
||||||
};
|
};
|
||||||
@@ -377,15 +425,6 @@
|
|||||||
knownRegions = (
|
knownRegions = (
|
||||||
en,
|
en,
|
||||||
Base,
|
Base,
|
||||||
it,
|
|
||||||
fr,
|
|
||||||
de,
|
|
||||||
"pt-BR",
|
|
||||||
fi,
|
|
||||||
ko,
|
|
||||||
ca,
|
|
||||||
ru,
|
|
||||||
pl,
|
|
||||||
);
|
);
|
||||||
mainGroup = 50617D7623FCE48D0099B055;
|
mainGroup = 50617D7623FCE48D0099B055;
|
||||||
productRefGroup = 50617D8023FCE48E0099B055 /* Products */;
|
productRefGroup = 50617D8023FCE48E0099B055 /* Products */;
|
||||||
@@ -393,6 +432,7 @@
|
|||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
targets = (
|
targets = (
|
||||||
50617D7E23FCE48D0099B055 /* Secretive */,
|
50617D7E23FCE48D0099B055 /* Secretive */,
|
||||||
|
50617D9323FCE48E0099B055 /* SecretiveTests */,
|
||||||
50A3B78924026B7500D209EA /* SecretAgent */,
|
50A3B78924026B7500D209EA /* SecretAgent */,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -404,22 +444,27 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
50617D8A23FCE48E0099B055 /* Preview Assets.xcassets in Resources */,
|
50617D8A23FCE48E0099B055 /* Preview Assets.xcassets in Resources */,
|
||||||
500B93C32B478D8400E157DE /* Localizable.xcstrings in Resources */,
|
|
||||||
50617D8723FCE48E0099B055 /* Assets.xcassets in Resources */,
|
50617D8723FCE48E0099B055 /* Assets.xcassets in Resources */,
|
||||||
506772C72424784600034DED /* Credits.rtf in Resources */,
|
506772C72424784600034DED /* Credits.rtf in Resources */,
|
||||||
508BF28E25B4F005009EFB7E /* InternetAccessPolicy.plist in Resources */,
|
508BF28E25B4F005009EFB7E /* InternetAccessPolicy.plist in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
50617D9223FCE48E0099B055 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
50A3B78824026B7500D209EA /* Resources */ = {
|
50A3B78824026B7500D209EA /* Resources */ = {
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
50A3B79724026B7600D209EA /* Main.storyboard in Resources */,
|
50A3B79724026B7600D209EA /* Main.storyboard in Resources */,
|
||||||
50E9CF422B51D596004AB36D /* Localizable.xcstrings in Resources */,
|
|
||||||
50A3B79424026B7600D209EA /* Preview Assets.xcassets in Resources */,
|
50A3B79424026B7600D209EA /* Preview Assets.xcassets in Resources */,
|
||||||
|
50A3B79124026B7600D209EA /* Assets.xcassets in Resources */,
|
||||||
508BF2AA25B4F1CB009EFB7E /* InternetAccessPolicy.plist in Resources */,
|
508BF2AA25B4F1CB009EFB7E /* InternetAccessPolicy.plist in Resources */,
|
||||||
5008C2402E52792400507AC2 /* Assets.xcassets in Resources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -456,6 +501,14 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
50617D9023FCE48E0099B055 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
50617D9923FCE48E0099B055 /* SecretiveTests.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
50A3B78624026B7500D209EA /* Sources */ = {
|
50A3B78624026B7500D209EA /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -473,6 +526,11 @@
|
|||||||
target = 50A3B78924026B7500D209EA /* SecretAgent */;
|
target = 50A3B78924026B7500D209EA /* SecretAgent */;
|
||||||
targetProxy = 50142166278126B500BBAA70 /* PBXContainerItemProxy */;
|
targetProxy = 50142166278126B500BBAA70 /* PBXContainerItemProxy */;
|
||||||
};
|
};
|
||||||
|
50617D9623FCE48E0099B055 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = 50617D7E23FCE48D0099B055 /* Secretive */;
|
||||||
|
targetProxy = 50617D9523FCE48E0099B055 /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
/* End PBXTargetDependency section */
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
/* Begin PBXVariantGroup section */
|
/* Begin PBXVariantGroup section */
|
||||||
@@ -492,8 +550,6 @@
|
|||||||
baseConfigurationReference = 508A58AB241E121B0069DC07 /* Config.xcconfig */;
|
baseConfigurationReference = 508A58AB241E121B0069DC07 /* Config.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
|
||||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||||
@@ -524,11 +580,9 @@
|
|||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
@@ -543,19 +597,16 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
OTHER_SWIFT_FLAGS = "";
|
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-concurrency -Xfrontend -enable-actor-data-race-checks";
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
|
||||||
STRIP_INSTALLED_PRODUCT = NO;
|
STRIP_INSTALLED_PRODUCT = NO;
|
||||||
STRIP_SWIFT_SYMBOLS = NO;
|
STRIP_SWIFT_SYMBOLS = NO;
|
||||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 6.0;
|
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
@@ -564,8 +615,6 @@
|
|||||||
baseConfigurationReference = 508A58AB241E121B0069DC07 /* Config.xcconfig */;
|
baseConfigurationReference = 508A58AB241E121B0069DC07 /* Config.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
|
||||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||||
@@ -596,11 +645,9 @@
|
|||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
@@ -609,78 +656,111 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
OTHER_SWIFT_FLAGS = "";
|
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-concurrency -Xfrontend -enable-actor-data-race-checks";
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
|
||||||
STRIP_INSTALLED_PRODUCT = NO;
|
STRIP_INSTALLED_PRODUCT = NO;
|
||||||
STRIP_SWIFT_SYMBOLS = NO;
|
STRIP_SWIFT_SYMBOLS = NO;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
SWIFT_VERSION = 6.0;
|
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
50617D9E23FCE48E0099B055 /* Debug */ = {
|
50617D9E23FCE48E0099B055 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = Secretive/Secretive.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Secretive/Secretive.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Secretive/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Secretive/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
||||||
ENABLE_APP_SANDBOX = YES;
|
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
|
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
ENABLE_USER_SELECTED_FILES = readwrite;
|
|
||||||
INFOPLIST_FILE = Secretive/Info.plist;
|
INFOPLIST_FILE = Secretive/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 14.0;
|
|
||||||
MARKETING_VERSION = 1;
|
MARKETING_VERSION = 1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
50617D9F23FCE48E0099B055 /* Release */ = {
|
50617D9F23FCE48E0099B055 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = Secretive/Secretive.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Secretive/Secretive.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Developer ID Application";
|
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Secretive/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Secretive/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
||||||
ENABLE_APP_SANDBOX = YES;
|
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
|
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
ENABLE_USER_SELECTED_FILES = readwrite;
|
|
||||||
INFOPLIST_FILE = Secretive/Info.plist;
|
INFOPLIST_FILE = Secretive/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 14.0;
|
|
||||||
MARKETING_VERSION = 1;
|
MARKETING_VERSION = 1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "Secretive - Host";
|
PROVISIONING_PROFILE_SPECIFIER = "Secretive - Host";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
50617DA123FCE48E0099B055 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
||||||
|
INFOPLIST_FILE = SecretiveTests/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/../Frameworks",
|
||||||
|
"@loader_path/../Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.SecretiveTests;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Secretive.app/Contents/MacOS/Secretive";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
50617DA223FCE48E0099B055 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
||||||
|
INFOPLIST_FILE = SecretiveTests/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/../Frameworks",
|
||||||
|
"@loader_path/../Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.SecretiveTests;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Secretive.app/Contents/MacOS/Secretive";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
@@ -689,8 +769,6 @@
|
|||||||
baseConfigurationReference = 508A58AB241E121B0069DC07 /* Config.xcconfig */;
|
baseConfigurationReference = 508A58AB241E121B0069DC07 /* Config.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
|
||||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||||
@@ -721,11 +799,9 @@
|
|||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
@@ -740,45 +816,61 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
OTHER_SWIFT_FLAGS = "";
|
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-concurrency -Xfrontend -enable-actor-data-race-checks";
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
|
||||||
STRIP_INSTALLED_PRODUCT = NO;
|
STRIP_INSTALLED_PRODUCT = NO;
|
||||||
STRIP_SWIFT_SYMBOLS = NO;
|
STRIP_SWIFT_SYMBOLS = NO;
|
||||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 6.0;
|
|
||||||
};
|
};
|
||||||
name = Test;
|
name = Test;
|
||||||
};
|
};
|
||||||
508A5915241EF1A00069DC07 /* Test */ = {
|
508A5915241EF1A00069DC07 /* Test */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Secretive/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Secretive/Preview Content\"";
|
||||||
ENABLE_APP_SANDBOX = YES;
|
|
||||||
ENABLE_HARDENED_RUNTIME = NO;
|
ENABLE_HARDENED_RUNTIME = NO;
|
||||||
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
|
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
ENABLE_USER_SELECTED_FILES = readwrite;
|
|
||||||
INFOPLIST_FILE = Secretive/Info.plist;
|
INFOPLIST_FILE = Secretive/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 14.0;
|
|
||||||
MARKETING_VERSION = 1;
|
MARKETING_VERSION = 1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
};
|
||||||
|
name = Test;
|
||||||
|
};
|
||||||
|
508A5916241EF1A00069DC07 /* Test */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
|
CODE_SIGN_IDENTITY = "-";
|
||||||
|
CODE_SIGN_STYLE = Manual;
|
||||||
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
INFOPLIST_FILE = SecretiveTests/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/../Frameworks",
|
||||||
|
"@loader_path/../Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.SecretiveTests;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Secretive.app/Contents/MacOS/Secretive";
|
||||||
};
|
};
|
||||||
name = Test;
|
name = Test;
|
||||||
};
|
};
|
||||||
@@ -786,23 +878,21 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = SecretAgent/SecretAgent.entitlements;
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"SecretAgent/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"SecretAgent/Preview Content\"";
|
||||||
ENABLE_APP_SANDBOX = YES;
|
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
|
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
INFOPLIST_FILE = SecretAgent/Info.plist;
|
INFOPLIST_FILE = SecretAgent/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 14.0;
|
|
||||||
MARKETING_VERSION = 1;
|
MARKETING_VERSION = 1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.SecretAgent;
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.SecretAgent;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
};
|
};
|
||||||
name = Test;
|
name = Test;
|
||||||
};
|
};
|
||||||
@@ -813,22 +903,19 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = SecretAgent/SecretAgent.entitlements;
|
CODE_SIGN_ENTITLEMENTS = SecretAgent/SecretAgent.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"SecretAgent/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"SecretAgent/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
||||||
ENABLE_APP_SANDBOX = YES;
|
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
|
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
INFOPLIST_FILE = SecretAgent/Info.plist;
|
INFOPLIST_FILE = SecretAgent/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 14.0;
|
|
||||||
MARKETING_VERSION = 1;
|
MARKETING_VERSION = 1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.SecretAgent;
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.SecretAgent;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
@@ -840,23 +927,20 @@
|
|||||||
CODE_SIGN_IDENTITY = "Developer ID Application";
|
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"SecretAgent/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"SecretAgent/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
DEVELOPMENT_TEAM = Z72PRUAWF6;
|
||||||
ENABLE_APP_SANDBOX = YES;
|
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
|
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
INFOPLIST_FILE = SecretAgent/Info.plist;
|
INFOPLIST_FILE = SecretAgent/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 14.0;
|
|
||||||
MARKETING_VERSION = 1;
|
MARKETING_VERSION = 1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.SecretAgent;
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.SecretAgent;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "Secretive - Secret Agent";
|
PROVISIONING_PROFILE_SPECIFIER = "Secretive - Secret Agent";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
@@ -883,6 +967,16 @@
|
|||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
|
50617DA023FCE48E0099B055 /* Build configuration list for PBXNativeTarget "SecretiveTests" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
50617DA123FCE48E0099B055 /* Debug */,
|
||||||
|
508A5916241EF1A00069DC07 /* Test */,
|
||||||
|
50617DA223FCE48E0099B055 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
50A3B79A24026B7600D209EA /* Build configuration list for PBXNativeTarget "SecretAgent" */ = {
|
50A3B79A24026B7600D209EA /* Build configuration list for PBXNativeTarget "SecretAgent" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
buildConfigurations = (
|
buildConfigurations = (
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "2600"
|
LastUpgradeVersion = "1320"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "2600"
|
LastUpgradeVersion = "1320"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
</BuildableProductRunnable>
|
</BuildableProductRunnable>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Release"
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
savedToolIdentifier = ""
|
savedToolIdentifier = ""
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
|
|||||||
@@ -5,42 +5,28 @@ import SecureEnclaveSecretKit
|
|||||||
import SmartCardSecretKit
|
import SmartCardSecretKit
|
||||||
import Brief
|
import Brief
|
||||||
|
|
||||||
extension EnvironmentValues {
|
@main
|
||||||
|
struct Secretive: App {
|
||||||
|
|
||||||
// This is injected through .environment modifier below instead of @Entry for performance reasons (basially, restrictions around init/mainactor causing delay in loading secrets/"empty screen" blip).
|
private let storeList: SecretStoreList = {
|
||||||
@MainActor fileprivate static let _secretStoreList: SecretStoreList = {
|
|
||||||
let list = SecretStoreList()
|
let list = SecretStoreList()
|
||||||
list.add(store: SecureEnclave.Store())
|
list.add(store: SecureEnclave.Store())
|
||||||
list.add(store: SmartCard.Store())
|
list.add(store: SmartCard.Store())
|
||||||
return list
|
return list
|
||||||
}()
|
}()
|
||||||
|
private let agentStatusChecker = AgentStatusChecker()
|
||||||
private static let _agentStatusChecker = AgentStatusChecker()
|
|
||||||
@Entry var agentStatusChecker: any AgentStatusCheckerProtocol = _agentStatusChecker
|
|
||||||
private static let _updater: any UpdaterProtocol = {
|
|
||||||
@AppStorage("defaultsHasRunSetup") var hasRunSetup = false
|
|
||||||
return Updater(checkOnLaunch: hasRunSetup)
|
|
||||||
}()
|
|
||||||
@Entry var updater: any UpdaterProtocol = _updater
|
|
||||||
|
|
||||||
@MainActor var secretStoreList: SecretStoreList {
|
|
||||||
EnvironmentValues._secretStoreList
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@main
|
|
||||||
struct Secretive: App {
|
|
||||||
|
|
||||||
private let justUpdatedChecker = JustUpdatedChecker()
|
private let justUpdatedChecker = JustUpdatedChecker()
|
||||||
@Environment(\.agentStatusChecker) var agentStatusChecker
|
|
||||||
@AppStorage("defaultsHasRunSetup") var hasRunSetup = false
|
@AppStorage("defaultsHasRunSetup") var hasRunSetup = false
|
||||||
@State private var showingSetup = false
|
@State private var showingSetup = false
|
||||||
@State private var showingCreation = false
|
@State private var showingCreation = false
|
||||||
|
|
||||||
@SceneBuilder var body: some Scene {
|
@SceneBuilder var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
ContentView(showingCreation: $showingCreation, runningSetup: $showingSetup, hasRunSetup: $hasRunSetup)
|
ContentView<Updater, AgentStatusChecker>(showingCreation: $showingCreation, runningSetup: $showingSetup, hasRunSetup: $hasRunSetup)
|
||||||
.environment(EnvironmentValues._secretStoreList)
|
.environmentObject(storeList)
|
||||||
|
.environmentObject(Updater(checkOnLaunch: hasRunSetup))
|
||||||
|
.environmentObject(agentStatusChecker)
|
||||||
.onAppear {
|
.onAppear {
|
||||||
if !hasRunSetup {
|
if !hasRunSetup {
|
||||||
showingSetup = true
|
showingSetup = true
|
||||||
@@ -59,18 +45,18 @@ struct Secretive: App {
|
|||||||
}
|
}
|
||||||
.commands {
|
.commands {
|
||||||
CommandGroup(after: CommandGroupPlacement.newItem) {
|
CommandGroup(after: CommandGroupPlacement.newItem) {
|
||||||
Button("app_menu_new_secret_button") {
|
Button("New Secret") {
|
||||||
showingCreation = true
|
showingCreation = true
|
||||||
}
|
}
|
||||||
.keyboardShortcut(KeyboardShortcut(KeyEquivalent("N"), modifiers: [.command, .shift]))
|
.keyboardShortcut(KeyboardShortcut(KeyEquivalent("N"), modifiers: [.command, .shift]))
|
||||||
}
|
}
|
||||||
CommandGroup(replacing: .help) {
|
CommandGroup(replacing: .help) {
|
||||||
Button("app_menu_help_button") {
|
Button("Help") {
|
||||||
NSWorkspace.shared.open(Constants.helpURL)
|
NSWorkspace.shared.open(Constants.helpURL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommandGroup(after: .help) {
|
CommandGroup(after: .help) {
|
||||||
Button("app_menu_setup_button") {
|
Button("Setup Secretive") {
|
||||||
showingSetup = true
|
showingSetup = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,12 +70,13 @@ extension Secretive {
|
|||||||
|
|
||||||
private func reinstallAgent() {
|
private func reinstallAgent() {
|
||||||
justUpdatedChecker.check()
|
justUpdatedChecker.check()
|
||||||
Task {
|
LaunchAgentController().install {
|
||||||
await LaunchAgentController().install()
|
// Wait a second for launchd to kick in (next runloop isn't enough).
|
||||||
try? await Task.sleep(for: .seconds(1))
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||||
agentStatusChecker.check()
|
agentStatusChecker.check()
|
||||||
if !agentStatusChecker.running {
|
if !agentStatusChecker.running {
|
||||||
forceLaunchAgent()
|
forceLaunchAgent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,8 +84,7 @@ extension Secretive {
|
|||||||
private func forceLaunchAgent() {
|
private func forceLaunchAgent() {
|
||||||
// We've run setup, we didn't just update, launchd is just not doing it's thing.
|
// We've run setup, we didn't just update, launchd is just not doing it's thing.
|
||||||
// Force a launch directly.
|
// Force a launch directly.
|
||||||
Task {
|
LaunchAgentController().forceLaunch { _ in
|
||||||
_ = await LaunchAgentController().forceLaunch()
|
|
||||||
agentStatusChecker.check()
|
agentStatusChecker.check()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +1,53 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-16x16@1x.png",
|
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "16x16"
|
"size" : "16x16"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-16x16@2x.png",
|
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "16x16"
|
"size" : "16x16"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-32x32@1x.png",
|
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "32x32"
|
"size" : "32x32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-32x32@2x.png",
|
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "32x32"
|
"size" : "32x32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-128x128@1x.png",
|
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "128x128"
|
"size" : "128x128"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-128x128@2x.png",
|
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "128x128"
|
"size" : "128x128"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-256x256@1x.png",
|
"filename" : "Mac Icon.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "256x256"
|
"size" : "256x256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-256x256@2x.png",
|
"filename" : "Mac Icon@0.25x.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "256x256"
|
"size" : "256x256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-512x512@1x.png",
|
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "512x512"
|
"size" : "512x512"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-macOS-ClearDark-1024x1024@1x.png",
|
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "512x512"
|
"size" : "512x512"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 856 B |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 356 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 356 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 40 KiB |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"info" : {
|
"info" : {
|
||||||
"author" : "xcode",
|
"version" : 1,
|
||||||
"version" : 1
|
"author" : "xcode"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,22 +2,18 @@ import Foundation
|
|||||||
import Combine
|
import Combine
|
||||||
import AppKit
|
import AppKit
|
||||||
import SecretKit
|
import SecretKit
|
||||||
import Observation
|
|
||||||
|
|
||||||
@MainActor protocol AgentStatusCheckerProtocol: Observable, Sendable {
|
protocol AgentStatusCheckerProtocol: ObservableObject {
|
||||||
var running: Bool { get }
|
var running: Bool { get }
|
||||||
var developmentBuild: Bool { get }
|
var developmentBuild: Bool { get }
|
||||||
func check()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Observable @MainActor final class AgentStatusChecker: AgentStatusCheckerProtocol {
|
class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {
|
||||||
|
|
||||||
var running: Bool = false
|
@Published var running: Bool = false
|
||||||
|
|
||||||
nonisolated init() {
|
init() {
|
||||||
Task { @MainActor in
|
check()
|
||||||
check()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func check() {
|
func check() {
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import Foundation
|
|||||||
import Combine
|
import Combine
|
||||||
import AppKit
|
import AppKit
|
||||||
|
|
||||||
protocol JustUpdatedCheckerProtocol: Observable {
|
protocol JustUpdatedCheckerProtocol: ObservableObject {
|
||||||
var justUpdated: Bool { get }
|
var justUpdated: Bool { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Observable class JustUpdatedChecker: JustUpdatedCheckerProtocol {
|
class JustUpdatedChecker: ObservableObject, JustUpdatedCheckerProtocol {
|
||||||
|
|
||||||
var justUpdated: Bool = false
|
@Published var justUpdated: Bool = false
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
check()
|
check()
|
||||||
|
|||||||
@@ -6,47 +6,38 @@ import SecretKit
|
|||||||
|
|
||||||
struct LaunchAgentController {
|
struct LaunchAgentController {
|
||||||
|
|
||||||
private let logger = Logger(subsystem: "com.maxgoedjen.secretive", category: "LaunchAgentController")
|
func install(completion: (() -> Void)? = nil) {
|
||||||
|
Logger().debug("Installing agent")
|
||||||
func install() async {
|
|
||||||
logger.debug("Installing agent")
|
|
||||||
_ = setEnabled(false)
|
_ = setEnabled(false)
|
||||||
// This is definitely a bit of a "seems to work better" thing but:
|
// This is definitely a bit of a "seems to work better" thing but:
|
||||||
// Seems to more reliably hit if these are on separate runloops, otherwise it seems like it sometimes doesn't kill old
|
// Seems to more reliably hit if these are on separate runloops, otherwise it seems like it sometimes doesn't kill old
|
||||||
// and start new?
|
// and start new?
|
||||||
try? await Task.sleep(for: .seconds(1))
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||||
await MainActor.run {
|
|
||||||
_ = setEnabled(true)
|
_ = setEnabled(true)
|
||||||
|
completion?()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func forceLaunch() async -> Bool {
|
func forceLaunch(completion: ((Bool) -> Void)?) {
|
||||||
logger.debug("Agent is not running, attempting to force launch")
|
Logger().debug("Agent is not running, attempting to force launch")
|
||||||
let url = Bundle.main.bundleURL.appendingPathComponent("Contents/Library/LoginItems/SecretAgent.app")
|
let url = Bundle.main.bundleURL.appendingPathComponent("Contents/Library/LoginItems/SecretAgent.app")
|
||||||
let config = NSWorkspace.OpenConfiguration()
|
let config = NSWorkspace.OpenConfiguration()
|
||||||
config.activates = false
|
config.activates = false
|
||||||
do {
|
NSWorkspace.shared.openApplication(at: url, configuration: config) { app, error in
|
||||||
try await NSWorkspace.shared.openApplication(at: url, configuration: config)
|
DispatchQueue.main.async {
|
||||||
logger.debug("Agent force launched")
|
completion?(error == nil)
|
||||||
return true
|
}
|
||||||
} catch {
|
if let error = error {
|
||||||
logger.error("Error force launching \(error.localizedDescription)")
|
Logger().error("Error force launching \(error.localizedDescription)")
|
||||||
return false
|
} else {
|
||||||
|
Logger().debug("Agent force launched")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setEnabled(_ enabled: Bool) -> Bool {
|
private func setEnabled(_ enabled: Bool) -> Bool {
|
||||||
let service = SMAppService.loginItem(identifier: Bundle.main.agentBundleID)
|
SMLoginItemSetEnabled(Bundle.main.agentBundleID as CFString, enabled)
|
||||||
do {
|
|
||||||
if enabled {
|
|
||||||
try service.register()
|
|
||||||
} else {
|
|
||||||
try service.unregister()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
} catch {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,4 @@ class PreviewAgentStatusChecker: AgentStatusCheckerProtocol {
|
|||||||
self.running = running
|
self.running = running
|
||||||
}
|
}
|
||||||
|
|
||||||
func check() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,20 +20,20 @@ extension Preview {
|
|||||||
|
|
||||||
extension Preview {
|
extension Preview {
|
||||||
|
|
||||||
@Observable final class Store: SecretStore {
|
class Store: SecretStore, ObservableObject {
|
||||||
|
|
||||||
let isAvailable = true
|
let isAvailable = true
|
||||||
let id = UUID()
|
let id = UUID()
|
||||||
var name: String { "Preview Store" }
|
var name: String { "Preview Store" }
|
||||||
let secrets: [Secret]
|
@Published var secrets: [Secret] = []
|
||||||
|
|
||||||
init(secrets: [Secret]) {
|
init(secrets: [Secret]) {
|
||||||
self.secrets = secrets
|
self.secrets.append(contentsOf: secrets)
|
||||||
}
|
}
|
||||||
|
|
||||||
convenience init(numberOfRandomSecrets: Int = 5) {
|
init(numberOfRandomSecrets: Int = 5) {
|
||||||
let new = (0..<numberOfRandomSecrets).map { Secret(name: String(describing: $0)) }
|
let new = (0..<numberOfRandomSecrets).map { Secret(name: String(describing: $0)) }
|
||||||
self.init(secrets: new)
|
self.secrets.append(contentsOf: new)
|
||||||
}
|
}
|
||||||
|
|
||||||
func sign(data: Data, with secret: Preview.Secret, for provenance: SigningRequestProvenance) throws -> Data {
|
func sign(data: Data, with secret: Preview.Secret, for provenance: SigningRequestProvenance) throws -> Data {
|
||||||
@@ -56,40 +56,8 @@ extension Preview {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class StoreModifiable: SecretStoreModifiable {
|
class StoreModifiable: Store, SecretStoreModifiable {
|
||||||
|
override var name: String { "Modifiable Preview Store" }
|
||||||
let isAvailable = true
|
|
||||||
let id = UUID()
|
|
||||||
var name: String { "Modifiable Preview Store" }
|
|
||||||
let secrets: [Secret]
|
|
||||||
|
|
||||||
init(secrets: [Secret]) {
|
|
||||||
self.secrets = secrets
|
|
||||||
}
|
|
||||||
|
|
||||||
convenience init(numberOfRandomSecrets: Int = 5) {
|
|
||||||
let new = (0..<numberOfRandomSecrets).map { Secret(name: String(describing: $0)) }
|
|
||||||
self.init(secrets: new)
|
|
||||||
}
|
|
||||||
|
|
||||||
func sign(data: Data, with secret: Preview.Secret, for provenance: SigningRequestProvenance) throws -> Data {
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
func verify(signature data: Data, for signature: Data, with secret: Preview.Secret) throws -> Bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
func existingPersistedAuthenticationContext(secret: Preview.Secret) -> PersistedAuthenticationContext? {
|
|
||||||
nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func persistAuthentication(secret: Preview.Secret, forDuration duration: TimeInterval) throws {
|
|
||||||
}
|
|
||||||
|
|
||||||
func reloadSecrets() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func create(name: String, requiresAuthentication: Bool) throws {
|
func create(name: String, requiresAuthentication: Bool) throws {
|
||||||
}
|
}
|
||||||
@@ -104,7 +72,7 @@ extension Preview {
|
|||||||
|
|
||||||
extension Preview {
|
extension Preview {
|
||||||
|
|
||||||
@MainActor static func storeList(stores: [Store] = [], modifiableStores: [StoreModifiable] = []) -> SecretStoreList {
|
static func storeList(stores: [Store] = [], modifiableStores: [StoreModifiable] = []) -> SecretStoreList {
|
||||||
let list = SecretStoreList()
|
let list = SecretStoreList()
|
||||||
for store in stores {
|
for store in stores {
|
||||||
list.add(store: store)
|
list.add(store: store)
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Observation
|
import Combine
|
||||||
import Brief
|
import Brief
|
||||||
|
|
||||||
@Observable @MainActor final class PreviewUpdater: UpdaterProtocol {
|
class PreviewUpdater: UpdaterProtocol {
|
||||||
|
|
||||||
var update: Release? = nil
|
|
||||||
|
|
||||||
|
let update: Release?
|
||||||
let testBuild = false
|
let testBuild = false
|
||||||
|
|
||||||
init(update: Update = .none) {
|
init(update: Update = .none) {
|
||||||
@@ -19,9 +18,6 @@ import Brief
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ignore(release: Release) async {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension PreviewUpdater {
|
extension PreviewUpdater {
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>com.apple.security.app-sandbox</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.files.user-selected.read-write</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.network.client</key>
|
||||||
|
<true/>
|
||||||
<key>com.apple.security.smartcard</key>
|
<key>com.apple.security.smartcard</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>keychain-access-groups</key>
|
<key>keychain-access-groups</key>
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ import SecureEnclaveSecretKit
|
|||||||
import SmartCardSecretKit
|
import SmartCardSecretKit
|
||||||
import Brief
|
import Brief
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentStatusCheckerProtocol>: View {
|
||||||
|
|
||||||
@Binding var showingCreation: Bool
|
@Binding var showingCreation: Bool
|
||||||
@Binding var runningSetup: Bool
|
@Binding var runningSetup: Bool
|
||||||
@Binding var hasRunSetup: Bool
|
@Binding var hasRunSetup: Bool
|
||||||
@State var showingAgentInfo = false
|
@State var showingAgentInfo = false
|
||||||
@State var activeSecret: AnySecret?
|
@State var activeSecret: AnySecret.ID?
|
||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
|
|
||||||
@Environment(\.secretStoreList) private var storeList
|
@EnvironmentObject private var storeList: SecretStoreList
|
||||||
@Environment(\.updater) private var updater: any UpdaterProtocol
|
@EnvironmentObject private var updater: UpdaterType
|
||||||
@Environment(\.agentStatusChecker) private var agentStatusChecker: any AgentStatusCheckerProtocol
|
@EnvironmentObject private var agentStatusChecker: AgentStatusCheckerType
|
||||||
|
|
||||||
@State private var selectedUpdate: Release?
|
@State private var selectedUpdate: Release?
|
||||||
@State private var showingAppPathNotice = false
|
@State private var showingAppPathNotice = false
|
||||||
@@ -30,7 +30,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
.frame(minWidth: 640, minHeight: 320)
|
.frame(minWidth: 640, minHeight: 320)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
// toolbarItem(updateNoticeView, id: "update")
|
toolbarItem(updateNoticeView, id: "update")
|
||||||
toolbarItem(runningOrRunSetupView, id: "setup")
|
toolbarItem(runningOrRunSetupView, id: "setup")
|
||||||
toolbarItem(appPathNoticeView, id: "appPath")
|
toolbarItem(appPathNoticeView, id: "appPath")
|
||||||
toolbarItem(newItemView, id: "new")
|
toolbarItem(newItemView, id: "new")
|
||||||
@@ -45,16 +45,10 @@ struct ContentView: View {
|
|||||||
extension ContentView {
|
extension ContentView {
|
||||||
|
|
||||||
|
|
||||||
@ToolbarContentBuilder
|
func toolbarItem(_ view: some View, id: String) -> ToolbarItem<String, some View> {
|
||||||
func toolbarItem(_ view: some View, id: String) -> some ToolbarContent {
|
ToolbarItem(id: id) { view }
|
||||||
if #available(macOS 26.0, *) {
|
|
||||||
ToolbarItem(id: id) { view }
|
|
||||||
.sharedBackgroundVisibility(.hidden)
|
|
||||||
} else {
|
|
||||||
ToolbarItem(id: id) { view }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var needsSetup: Bool {
|
var needsSetup: Bool {
|
||||||
(runningSetup || !hasRunSetup || !agentStatusChecker.running) && !agentStatusChecker.developmentBuild
|
(runningSetup || !hasRunSetup || !agentStatusChecker.running) && !agentStatusChecker.developmentBuild
|
||||||
}
|
}
|
||||||
@@ -70,15 +64,15 @@ extension ContentView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var updateNoticeContent: (LocalizedStringKey, Color)? {
|
var updateNoticeContent: (String, Color)? {
|
||||||
guard let update = updater.update else { return nil }
|
guard let update = updater.update else { return nil }
|
||||||
if update.critical {
|
if update.critical {
|
||||||
return ("update_critical_notice_title", .red)
|
return ("Critical Security Update Required", .red)
|
||||||
} else {
|
} else {
|
||||||
if updater.testBuild {
|
if updater.testBuild {
|
||||||
return ("update_test_notice_title", .blue)
|
return ("Test Build", .blue)
|
||||||
} else {
|
} else {
|
||||||
return ("update_normal_notice_title", .orange)
|
return ("Update Available", .orange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +106,7 @@ extension ContentView {
|
|||||||
if let modifiable = storeList.modifiableStore {
|
if let modifiable = storeList.modifiableStore {
|
||||||
CreateSecretView(store: modifiable, showing: $showingCreation)
|
CreateSecretView(store: modifiable, showing: $showingCreation)
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
guard let newest = modifiable.secrets.last else { return }
|
guard let newest = modifiable.secrets.last?.id else { return }
|
||||||
activeSecret = newest
|
activeSecret = newest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,9 +121,9 @@ extension ContentView {
|
|||||||
}, label: {
|
}, label: {
|
||||||
Group {
|
Group {
|
||||||
if hasRunSetup && !agentStatusChecker.running {
|
if hasRunSetup && !agentStatusChecker.running {
|
||||||
Text("agent_not_running_notice_title")
|
Text("Secret Agent Is Not Running")
|
||||||
} else {
|
} else {
|
||||||
Text("agent_setup_notice_title")
|
Text("Setup Secretive")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
@@ -144,7 +138,7 @@ extension ContentView {
|
|||||||
showingAgentInfo = true
|
showingAgentInfo = true
|
||||||
}, label: {
|
}, label: {
|
||||||
HStack {
|
HStack {
|
||||||
Text("agent_running_notice_title")
|
Text("Agent is Running")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.foregroundColor(colorScheme == .light ? Color(white: 0.3) : .white)
|
.foregroundColor(colorScheme == .light ? Color(white: 0.3) : .white)
|
||||||
Circle()
|
Circle()
|
||||||
@@ -155,10 +149,10 @@ extension ContentView {
|
|||||||
.buttonStyle(ToolbarButtonStyle(lightColor: .black.opacity(0.05), darkColor: .white.opacity(0.05)))
|
.buttonStyle(ToolbarButtonStyle(lightColor: .black.opacity(0.05), darkColor: .white.opacity(0.05)))
|
||||||
.popover(isPresented: $showingAgentInfo, attachmentAnchor: attachmentAnchor, arrowEdge: .bottom) {
|
.popover(isPresented: $showingAgentInfo, attachmentAnchor: attachmentAnchor, arrowEdge: .bottom) {
|
||||||
VStack {
|
VStack {
|
||||||
Text("agent_running_notice_detail_title")
|
Text("SecretAgent is Running")
|
||||||
.font(.title)
|
.font(.title)
|
||||||
.padding(5)
|
.padding(5)
|
||||||
Text("agent_running_notice_detail_description")
|
Text("SecretAgent is a process that runs in the background to sign requests, so you don't need to keep Secretive open all the time.\n\n**You can close Secretive, and everything will still keep working.**")
|
||||||
.frame(width: 300)
|
.frame(width: 300)
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
@@ -172,7 +166,7 @@ extension ContentView {
|
|||||||
showingAppPathNotice = true
|
showingAppPathNotice = true
|
||||||
}, label: {
|
}, label: {
|
||||||
Group {
|
Group {
|
||||||
Text("app_not_in_applications_notice_title")
|
Text("Secretive Is Not in Applications Folder")
|
||||||
}
|
}
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
@@ -184,7 +178,7 @@ extension ContentView {
|
|||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fit)
|
.aspectRatio(contentMode: .fit)
|
||||||
.frame(width: 64)
|
.frame(width: 64)
|
||||||
Text("app_not_in_applications_notice_detail_description")
|
Text("Secretive needs to be in your Applications folder to work properly. Please move it and relaunch.")
|
||||||
.frame(maxWidth: 300)
|
.frame(maxWidth: 300)
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
@@ -203,18 +197,34 @@ extension ContentView {
|
|||||||
|
|
||||||
struct ContentView_Previews: PreviewProvider {
|
struct ContentView_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
private static let storeList: SecretStoreList = {
|
||||||
|
let list = SecretStoreList()
|
||||||
|
list.add(store: SecureEnclave.Store())
|
||||||
|
list.add(store: SmartCard.Store())
|
||||||
|
return list
|
||||||
|
}()
|
||||||
|
private static let agentStatusChecker = AgentStatusChecker()
|
||||||
|
private static let justUpdatedChecker = JustUpdatedChecker()
|
||||||
|
|
||||||
|
@State var hasRunSetup = false
|
||||||
|
@State private var showingSetup = false
|
||||||
|
@State private var showingCreation = false
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
// Empty on modifiable and nonmodifiable
|
// Empty on modifiable and nonmodifiable
|
||||||
ContentView(showingCreation: .constant(false), runningSetup: .constant(false), hasRunSetup: .constant(true))
|
ContentView<PreviewUpdater, AgentStatusChecker>(showingCreation: .constant(false), runningSetup: .constant(false), hasRunSetup: .constant(true))
|
||||||
.environment(Preview.storeList(stores: [Preview.Store(numberOfRandomSecrets: 0)], modifiableStores: [Preview.StoreModifiable(numberOfRandomSecrets: 0)]))
|
.environmentObject(Preview.storeList(stores: [Preview.Store(numberOfRandomSecrets: 0)], modifiableStores: [Preview.StoreModifiable(numberOfRandomSecrets: 0)]))
|
||||||
.environment(PreviewUpdater())
|
.environmentObject(PreviewUpdater())
|
||||||
|
.environmentObject(agentStatusChecker)
|
||||||
|
|
||||||
// 5 items on modifiable and nonmodifiable
|
// 5 items on modifiable and nonmodifiable
|
||||||
ContentView(showingCreation: .constant(false), runningSetup: .constant(false), hasRunSetup: .constant(true))
|
ContentView<PreviewUpdater, AgentStatusChecker>(showingCreation: .constant(false), runningSetup: .constant(false), hasRunSetup: .constant(true))
|
||||||
.environment(Preview.storeList(stores: [Preview.Store()], modifiableStores: [Preview.StoreModifiable()]))
|
.environmentObject(Preview.storeList(stores: [Preview.Store()], modifiableStores: [Preview.StoreModifiable()]))
|
||||||
.environment(PreviewUpdater())
|
.environmentObject(PreviewUpdater())
|
||||||
|
.environmentObject(agentStatusChecker)
|
||||||
}
|
}
|
||||||
|
.environmentObject(agentStatusChecker)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ import UniformTypeIdentifiers
|
|||||||
|
|
||||||
struct CopyableView: View {
|
struct CopyableView: View {
|
||||||
|
|
||||||
var title: LocalizedStringKey
|
var title: String
|
||||||
var image: Image
|
var image: Image
|
||||||
var text: String
|
var text: String
|
||||||
|
|
||||||
@State private var interactionState: InteractionState = .normal
|
@State private var interactionState: InteractionState = .normal
|
||||||
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
var content: some View {
|
|
||||||
|
var body: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
HStack {
|
HStack {
|
||||||
image
|
image
|
||||||
@@ -21,7 +22,7 @@ struct CopyableView: View {
|
|||||||
.foregroundColor(primaryTextColor)
|
.foregroundColor(primaryTextColor)
|
||||||
Spacer()
|
Spacer()
|
||||||
if interactionState != .normal {
|
if interactionState != .normal {
|
||||||
hoverIcon
|
Text(hoverText)
|
||||||
.bold()
|
.bold()
|
||||||
.textCase(.uppercase)
|
.textCase(.uppercase)
|
||||||
.foregroundColor(secondaryTextColor)
|
.foregroundColor(secondaryTextColor)
|
||||||
@@ -38,23 +39,17 @@ struct CopyableView: View {
|
|||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
.font(.system(.body, design: .monospaced))
|
.font(.system(.body, design: .monospaced))
|
||||||
}
|
}
|
||||||
._background(interactionState: interactionState)
|
.background(backgroundColor)
|
||||||
.frame(minWidth: 150, maxWidth: .infinity)
|
.frame(minWidth: 150, maxWidth: .infinity)
|
||||||
}
|
.cornerRadius(10)
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
content
|
|
||||||
.onHover { hovering in
|
.onHover { hovering in
|
||||||
withAnimation {
|
withAnimation {
|
||||||
interactionState = hovering ? .hovering : .normal
|
interactionState = hovering ? .hovering : .normal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onDrag({
|
.onDrag {
|
||||||
NSItemProvider(item: NSData(data: text.data(using: .utf8)!), typeIdentifier: UTType.utf8PlainText.identifier)
|
NSItemProvider(item: NSData(data: text.data(using: .utf8)!), typeIdentifier: UTType.utf8PlainText.identifier)
|
||||||
}, preview: {
|
}
|
||||||
content
|
|
||||||
._background(interactionState: .dragging)
|
|
||||||
})
|
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
copy()
|
copy()
|
||||||
withAnimation {
|
withAnimation {
|
||||||
@@ -71,23 +66,31 @@ struct CopyableView: View {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
var hoverText: String {
|
||||||
var hoverIcon: some View {
|
|
||||||
switch interactionState {
|
switch interactionState {
|
||||||
case .hovering:
|
case .hovering:
|
||||||
Image(systemName: "document.on.document")
|
return "Click to Copy"
|
||||||
.accessibilityLabel(String(localized: "copyable_click_to_copy_button"))
|
|
||||||
case .clicking:
|
case .clicking:
|
||||||
Image(systemName: "checkmark.circle.fill")
|
return "Copied"
|
||||||
.accessibilityLabel(String(localized: "copyable_copied"))
|
case .normal:
|
||||||
case .normal, .dragging:
|
fatalError()
|
||||||
EmptyView()
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var backgroundColor: Color {
|
||||||
|
switch interactionState {
|
||||||
|
case .normal:
|
||||||
|
return colorScheme == .dark ? Color(white: 0.2) : Color(white: 0.885)
|
||||||
|
case .hovering:
|
||||||
|
return colorScheme == .dark ? Color(white: 0.275) : Color(white: 0.82)
|
||||||
|
case .clicking:
|
||||||
|
return .accentColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var primaryTextColor: Color {
|
var primaryTextColor: Color {
|
||||||
switch interactionState {
|
switch interactionState {
|
||||||
case .normal, .hovering, .dragging:
|
case .normal, .hovering:
|
||||||
return Color(.textColor)
|
return Color(.textColor)
|
||||||
case .clicking:
|
case .clicking:
|
||||||
return .white
|
return .white
|
||||||
@@ -96,7 +99,7 @@ struct CopyableView: View {
|
|||||||
|
|
||||||
var secondaryTextColor: Color {
|
var secondaryTextColor: Color {
|
||||||
switch interactionState {
|
switch interactionState {
|
||||||
case .normal, .hovering, .dragging:
|
case .normal, .hovering:
|
||||||
return Color(.secondaryLabelColor)
|
return Color(.secondaryLabelColor)
|
||||||
case .clicking:
|
case .clicking:
|
||||||
return .white
|
return .white
|
||||||
@@ -108,57 +111,10 @@ struct CopyableView: View {
|
|||||||
NSPasteboard.general.setString(text, forType: .string)
|
NSPasteboard.general.setString(text, forType: .string)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private enum InteractionState {
|
||||||
|
case normal, hovering, clicking
|
||||||
fileprivate enum InteractionState {
|
|
||||||
case normal, hovering, clicking, dragging
|
|
||||||
}
|
|
||||||
|
|
||||||
extension View {
|
|
||||||
|
|
||||||
fileprivate func _background(interactionState: InteractionState) -> some View {
|
|
||||||
modifier(BackgroundViewModifier(interactionState: interactionState))
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fileprivate struct BackgroundViewModifier: ViewModifier {
|
|
||||||
|
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
|
||||||
|
|
||||||
let interactionState: InteractionState
|
|
||||||
|
|
||||||
func body(content: Content) -> some View {
|
|
||||||
if interactionState == .dragging {
|
|
||||||
content
|
|
||||||
.background(backgroundColor(interactionState: interactionState), in: RoundedRectangle(cornerRadius: 15))
|
|
||||||
} else {
|
|
||||||
if #available(macOS 26.0, *) {
|
|
||||||
content
|
|
||||||
// Very thin opacity lets user hover anywhere over the view, glassEffect doesn't allow.
|
|
||||||
.background(.white.opacity(0.01), in: RoundedRectangle(cornerRadius: 15))
|
|
||||||
.glassEffect(.regular.tint(backgroundColor(interactionState: interactionState)), in: RoundedRectangle(cornerRadius: 15))
|
|
||||||
|
|
||||||
} else {
|
|
||||||
content
|
|
||||||
.background(backgroundColor(interactionState: interactionState))
|
|
||||||
.cornerRadius(10)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func backgroundColor(interactionState: InteractionState) -> Color {
|
|
||||||
switch interactionState {
|
|
||||||
case .normal:
|
|
||||||
return colorScheme == .dark ? Color(white: 0.2) : Color(white: 0.885)
|
|
||||||
case .hovering, .dragging:
|
|
||||||
return colorScheme == .dark ? Color(white: 0.275) : Color(white: 0.82)
|
|
||||||
case .clicking:
|
|
||||||
return .accentColor
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -166,9 +122,9 @@ fileprivate struct BackgroundViewModifier: ViewModifier {
|
|||||||
struct CopyableView_Previews: PreviewProvider {
|
struct CopyableView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
CopyableView(title: "secret_detail_sha256_fingerprint_label", image: Image(systemName: "figure.wave"), text: "Hello world.")
|
CopyableView(title: "Title", image: Image(systemName: "figure.wave"), text: "Hello world.")
|
||||||
.padding()
|
.padding()
|
||||||
CopyableView(title: "secret_detail_sha256_fingerprint_label", image: Image(systemName: "figure.wave"), text: "Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. ")
|
CopyableView(title: "Title", image: Image(systemName: "figure.wave"), text: "Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. ")
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import SecretKit
|
|||||||
|
|
||||||
struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
||||||
|
|
||||||
@State var store: StoreType
|
@ObservedObject var store: StoreType
|
||||||
@Binding var showing: Bool
|
@Binding var showing: Bool
|
||||||
|
|
||||||
@State private var name = ""
|
@State private var name = ""
|
||||||
@@ -14,30 +14,43 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
HStack {
|
HStack {
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
Text("create_secret_title")
|
Text("Create a New Secret")
|
||||||
.font(.largeTitle)
|
.font(.largeTitle)
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
Text("create_secret_name_label")
|
Text("Name:")
|
||||||
TextField("create_secret_name_placeholder", text: $name)
|
TextField("Shhhhh", text: $name)
|
||||||
.focusable()
|
.focusable()
|
||||||
}
|
}
|
||||||
ThumbnailPickerView(items: [
|
if #available(macOS 12.0, *) {
|
||||||
ThumbnailPickerView.Item(value: true, name: "create_secret_require_authentication_title", description: "create_secret_require_authentication_description", thumbnail: AuthenticationView()),
|
ThumbnailPickerView(items: [
|
||||||
ThumbnailPickerView.Item(value: false, name: "create_secret_notify_title",
|
ThumbnailPickerView.Item(value: true, name: "Require Authentication", description: "You will be required to authenticate using Touch ID, Apple Watch, or password before each use.", thumbnail: AuthenticationView()),
|
||||||
description: "create_secret_notify_description",
|
ThumbnailPickerView.Item(value: false, name: "Notify",
|
||||||
thumbnail: NotificationView())
|
description: "No authentication is required while your Mac is unlocked, but you will be notified when a secret is used.",
|
||||||
], selection: $requiresAuthentication)
|
thumbnail: NotificationView())
|
||||||
|
], selection: $requiresAuthentication)
|
||||||
|
} else {
|
||||||
|
HStack {
|
||||||
|
VStack(spacing: 20) {
|
||||||
|
Picker("", selection: $requiresAuthentication) {
|
||||||
|
Text("Requires Authentication (Biometrics or Password) before each use").tag(true)
|
||||||
|
Text("Authentication not required when Mac is unlocked").tag(false)
|
||||||
|
}
|
||||||
|
.pickerStyle(RadioGroupPickerStyle())
|
||||||
|
Spacer(minLength: 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
Button("create_secret_cancel_button") {
|
Button("Cancel") {
|
||||||
showing = false
|
showing = false
|
||||||
}
|
}
|
||||||
.keyboardShortcut(.cancelAction)
|
.keyboardShortcut(.cancelAction)
|
||||||
Button("create_secret_create_button", action: save)
|
Button("Create", action: save)
|
||||||
.disabled(name.isEmpty)
|
.disabled(name.isEmpty)
|
||||||
.keyboardShortcut(.defaultAction)
|
.keyboardShortcut(.defaultAction)
|
||||||
}
|
}
|
||||||
@@ -45,10 +58,8 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func save() {
|
func save() {
|
||||||
Task {
|
try! store.create(name: name, requiresAuthentication: requiresAuthentication)
|
||||||
try! await store.create(name: name, requiresAuthentication: requiresAuthentication)
|
showing = false
|
||||||
showing = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -95,14 +106,14 @@ struct ThumbnailPickerView<ValueType: Hashable>: View {
|
|||||||
|
|
||||||
extension ThumbnailPickerView {
|
extension ThumbnailPickerView {
|
||||||
|
|
||||||
struct Item<InnerValueType: Hashable>: Identifiable {
|
struct Item<ValueType: Hashable>: Identifiable {
|
||||||
let id = UUID()
|
let id = UUID()
|
||||||
let value: InnerValueType
|
let value: ValueType
|
||||||
let name: LocalizedStringKey
|
let name: String
|
||||||
let description: LocalizedStringKey
|
let description: String
|
||||||
let thumbnail: AnyView
|
let thumbnail: AnyView
|
||||||
|
|
||||||
init<ViewType: View>(value: InnerValueType, name: LocalizedStringKey, description: LocalizedStringKey, thumbnail: ViewType) {
|
init<ViewType: View>(value: ValueType, name: String, description: String, thumbnail: ViewType) {
|
||||||
self.value = value
|
self.value = value
|
||||||
self.name = name
|
self.name = name
|
||||||
self.description = description
|
self.description = description
|
||||||
@@ -112,10 +123,10 @@ extension ThumbnailPickerView {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor @Observable class SystemBackground {
|
@MainActor class SystemBackground: ObservableObject {
|
||||||
|
|
||||||
static let shared = SystemBackground()
|
static let shared = SystemBackground()
|
||||||
var image: NSImage?
|
@Published var image: NSImage?
|
||||||
|
|
||||||
private init() {
|
private init() {
|
||||||
if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) {
|
if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) {
|
||||||
@@ -127,6 +138,7 @@ extension ThumbnailPickerView {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(macOS 12.0, *)
|
||||||
struct SystemBackgroundView: View {
|
struct SystemBackgroundView: View {
|
||||||
|
|
||||||
let anchor: UnitPoint
|
let anchor: UnitPoint
|
||||||
@@ -145,6 +157,7 @@ struct SystemBackgroundView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(macOS 12.0, *)
|
||||||
struct AuthenticationView: View {
|
struct AuthenticationView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -156,15 +169,15 @@ struct AuthenticationView: View {
|
|||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fit)
|
.aspectRatio(contentMode: .fit)
|
||||||
.foregroundColor(Color(.systemRed))
|
.foregroundColor(Color(.systemRed))
|
||||||
Text(verbatim: "Touch ID Prompt")
|
Text("Touch ID Prompt")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
.redacted(reason: .placeholder)
|
.redacted(reason: .placeholder)
|
||||||
VStack {
|
VStack {
|
||||||
Text(verbatim: "Touch ID Detail prompt.Detail two.")
|
Text("Touch ID Detail prompt.Detail two.")
|
||||||
.font(.caption2)
|
.font(.caption2)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
Text(verbatim: "Touch ID Detail prompt.Detail two.")
|
Text("Touch ID Detail prompt.Detail two.")
|
||||||
.font(.caption2)
|
.font(.caption2)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
}
|
}
|
||||||
@@ -190,6 +203,7 @@ struct AuthenticationView: View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(macOS 12.0, *)
|
||||||
struct NotificationView: View {
|
struct NotificationView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -209,10 +223,10 @@ struct NotificationView: View {
|
|||||||
.frame(width: 64, height: 64)
|
.frame(width: 64, height: 64)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Text(verbatim: "Secretive")
|
Text("Secretive")
|
||||||
.font(.title)
|
.font(.title)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
Text(verbatim: "Secretive wants to sign")
|
Text("Secretive wants to sign")
|
||||||
.font(.body)
|
.font(.body)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
}
|
}
|
||||||
@@ -239,10 +253,14 @@ struct CreateSecretView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
CreateSecretView(store: Preview.StoreModifiable(), showing: .constant(true))
|
CreateSecretView(store: Preview.StoreModifiable(), showing: .constant(true))
|
||||||
|
if #available(macOS 12.0, *) {
|
||||||
AuthenticationView().environment(\.colorScheme, .dark)
|
AuthenticationView().environment(\.colorScheme, .dark)
|
||||||
AuthenticationView().environment(\.colorScheme, .light)
|
AuthenticationView().environment(\.colorScheme, .light)
|
||||||
NotificationView().environment(\.colorScheme, .dark)
|
NotificationView().environment(\.colorScheme, .dark)
|
||||||
NotificationView().environment(\.colorScheme, .light)
|
NotificationView().environment(\.colorScheme, .light)
|
||||||
|
} else {
|
||||||
|
// Fallback on earlier versions
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import SecretKit
|
|||||||
|
|
||||||
struct DeleteSecretView<StoreType: SecretStoreModifiable>: View {
|
struct DeleteSecretView<StoreType: SecretStoreModifiable>: View {
|
||||||
|
|
||||||
@State var store: StoreType
|
@ObservedObject var store: StoreType
|
||||||
let secret: StoreType.SecretType
|
let secret: StoreType.SecretType
|
||||||
var dismissalBlock: (Bool) -> ()
|
var dismissalBlock: (Bool) -> ()
|
||||||
|
|
||||||
@@ -18,24 +18,24 @@ struct DeleteSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
.padding()
|
.padding()
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
Text("delete_confirmation_title_\(secret.name)").bold()
|
Text("Delete \(secret.name)?").bold()
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
Text("delete_confirmation_description_\(secret.name)_\(secret.name)")
|
Text("If you delete \(secret.name), you will not be able to recover it. Type \"\(secret.name)\" to confirm.")
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
Text("delete_confirmation_confirm_name_label")
|
Text("Confirm Name:")
|
||||||
TextField(secret.name, text: $confirm)
|
TextField(secret.name, text: $confirm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
Button("delete_confirmation_delete_button", action: delete)
|
Button("Delete", action: delete)
|
||||||
.disabled(confirm != secret.name)
|
.disabled(confirm != secret.name)
|
||||||
Button("delete_confirmation_cancel_button") {
|
Button("Don't Delete") {
|
||||||
dismissalBlock(false)
|
dismissalBlock(false)
|
||||||
}
|
}
|
||||||
.keyboardShortcut(.cancelAction)
|
.keyboardShortcut(.cancelAction)
|
||||||
@@ -49,10 +49,8 @@ struct DeleteSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func delete() {
|
func delete() {
|
||||||
Task {
|
try! store.delete(secret: secret)
|
||||||
try! await store.delete(secret: secret)
|
dismissalBlock(true)
|
||||||
dismissalBlock(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,24 +3,38 @@ import SecretKit
|
|||||||
|
|
||||||
struct EmptyStoreView: View {
|
struct EmptyStoreView: View {
|
||||||
|
|
||||||
@State var store: AnySecretStore?
|
@ObservedObject var store: AnySecretStore
|
||||||
|
@Binding var activeSecret: AnySecret.ID?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if store is AnySecretStoreModifiable {
|
if store is AnySecretStoreModifiable {
|
||||||
EmptyStoreModifiableView()
|
NavigationLink(destination: EmptyStoreModifiableView(), tag: Constants.emptyStoreModifiableTag, selection: $activeSecret) {
|
||||||
|
Text("No Secrets")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
EmptyStoreImmutableView()
|
NavigationLink(destination: EmptyStoreImmutableView(), tag: Constants.emptyStoreTag, selection: $activeSecret) {
|
||||||
|
Text("No Secrets")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension EmptyStoreView {
|
||||||
|
|
||||||
|
enum Constants {
|
||||||
|
static let emptyStoreModifiableTag: AnyHashable = "emptyStoreModifiableTag"
|
||||||
|
static let emptyStoreTag: AnyHashable = "emptyStoreModifiableTag"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
struct EmptyStoreImmutableView: View {
|
struct EmptyStoreImmutableView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
Text("empty_store_nonmodifiable_title").bold()
|
Text("No Secrets").bold()
|
||||||
Text("empty_store_nonmodifiable_description")
|
Text("Use your Smart Card's management tool to create a secret.")
|
||||||
Text("empty_store_nonmodifiable_supported_key_types")
|
Text("Secretive supports EC256, EC384, RSA1024, and RSA2048 keys.")
|
||||||
}.frame(maxWidth: .infinity, maxHeight: .infinity)
|
}.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,8 +63,8 @@ struct EmptyStoreModifiableView: View {
|
|||||||
path.addLine(to: CGPoint(x: g.size.width - 3, y: 0))
|
path.addLine(to: CGPoint(x: g.size.width - 3, y: 0))
|
||||||
}.fill()
|
}.fill()
|
||||||
}.frame(height: (windowGeometry.size.height/2) - 20).padding()
|
}.frame(height: (windowGeometry.size.height/2) - 20).padding()
|
||||||
Text("empty_store_modifiable_click_here_title").bold()
|
Text("No Secrets").bold()
|
||||||
Text("empty_store_modifiable_click_here_description")
|
Text("Create a new one by clicking here.")
|
||||||
Spacer()
|
Spacer()
|
||||||
}.frame(maxWidth: .infinity, maxHeight: .infinity)
|
}.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ struct NoStoresView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
Text("no_secure_storage_title")
|
Text("No Secure Storage Available").bold()
|
||||||
.bold()
|
Text("Your Mac doesn't have a Secure Enclave, and there's not a compatible Smart Card inserted.")
|
||||||
Text("no_secure_storage_description")
|
Link("If you're looking to add one to your Mac, the YubiKey 5 Series are great.", destination: URL(string: "https://www.yubico.com/products/compare-yubikey-5-series/")!)
|
||||||
Link("no_secure_storage_yubico_link", destination: URL(string: "https://www.yubico.com/products/compare-yubikey-5-series/")!)
|
|
||||||
}.padding()
|
}.padding()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import SecretKit
|
|||||||
|
|
||||||
struct RenameSecretView<StoreType: SecretStoreModifiable>: View {
|
struct RenameSecretView<StoreType: SecretStoreModifiable>: View {
|
||||||
|
|
||||||
@State var store: StoreType
|
@ObservedObject var store: StoreType
|
||||||
let secret: StoreType.SecretType
|
let secret: StoreType.SecretType
|
||||||
var dismissalBlock: (_ renamed: Bool) -> ()
|
var dismissalBlock: (_ renamed: Bool) -> ()
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ struct RenameSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
.padding()
|
.padding()
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
Text("rename_title_\(secret.name)")
|
Text("Type your new name for \"\(secret.name)\" below.")
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
@@ -28,10 +28,10 @@ struct RenameSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
Button("rename_rename_button", action: rename)
|
Button("Rename", action: rename)
|
||||||
.disabled(newName.count == 0)
|
.disabled(newName.count == 0)
|
||||||
.keyboardShortcut(.return)
|
.keyboardShortcut(.return)
|
||||||
Button("rename_cancel_button") {
|
Button("Cancel") {
|
||||||
dismissalBlock(false)
|
dismissalBlock(false)
|
||||||
}.keyboardShortcut(.cancelAction)
|
}.keyboardShortcut(.cancelAction)
|
||||||
}
|
}
|
||||||
@@ -44,9 +44,7 @@ struct RenameSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func rename() {
|
func rename() {
|
||||||
Task {
|
try? store.update(secret: secret, name: newName)
|
||||||
try? await store.update(secret: secret, name: newName)
|
dismissalBlock(true)
|
||||||
dismissalBlock(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import SecretKit
|
|||||||
|
|
||||||
struct SecretDetailView<SecretType: Secret>: View {
|
struct SecretDetailView<SecretType: Secret>: View {
|
||||||
|
|
||||||
let secret: SecretType
|
@State var secret: SecretType
|
||||||
|
|
||||||
private let keyWriter = OpenSSHKeyWriter()
|
private let keyWriter = OpenSSHKeyWriter()
|
||||||
private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: NSHomeDirectory().replacingOccurrences(of: Bundle.main.hostBundleID, with: Bundle.main.agentBundleID))
|
private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: NSHomeDirectory().replacingOccurrences(of: Bundle.main.hostBundleID, with: Bundle.main.agentBundleID))
|
||||||
@@ -12,16 +12,16 @@ struct SecretDetailView<SecretType: Secret>: View {
|
|||||||
ScrollView {
|
ScrollView {
|
||||||
Form {
|
Form {
|
||||||
Section {
|
Section {
|
||||||
CopyableView(title: "secret_detail_sha256_fingerprint_label", image: Image(systemName: "touchid"), text: keyWriter.openSSHSHA256Fingerprint(secret: secret))
|
CopyableView(title: "SHA256 Fingerprint", image: Image(systemName: "touchid"), text: keyWriter.openSSHSHA256Fingerprint(secret: secret))
|
||||||
Spacer()
|
Spacer()
|
||||||
.frame(height: 20)
|
.frame(height: 20)
|
||||||
CopyableView(title: "secret_detail_md5_fingerprint_label", image: Image(systemName: "touchid"), text: keyWriter.openSSHMD5Fingerprint(secret: secret))
|
CopyableView(title: "MD5 Fingerprint", image: Image(systemName: "touchid"), text: keyWriter.openSSHMD5Fingerprint(secret: secret))
|
||||||
Spacer()
|
Spacer()
|
||||||
.frame(height: 20)
|
.frame(height: 20)
|
||||||
CopyableView(title: "secret_detail_public_key_label", image: Image(systemName: "key"), text: keyString)
|
CopyableView(title: "Public Key", image: Image(systemName: "key"), text: keyString)
|
||||||
Spacer()
|
Spacer()
|
||||||
.frame(height: 20)
|
.frame(height: 20)
|
||||||
CopyableView(title: "secret_detail_public_key_path_label", image: Image(systemName: "lock.doc"), text: publicKeyFileStoreController.publicKeyPath(for: secret))
|
CopyableView(title: "Public Key Path", image: Image(systemName: "lock.doc"), text: publicKeyFileStoreController.publicKeyPath(for: secret))
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,30 +2,24 @@ import SwiftUI
|
|||||||
import SecretKit
|
import SecretKit
|
||||||
|
|
||||||
struct SecretListItemView: View {
|
struct SecretListItemView: View {
|
||||||
|
|
||||||
@State var store: AnySecretStore
|
@ObservedObject var store: AnySecretStore
|
||||||
var secret: AnySecret
|
var secret: AnySecret
|
||||||
|
@Binding var activeSecret: AnySecret.ID?
|
||||||
|
|
||||||
@State var isDeleting: Bool = false
|
@State var isDeleting: Bool = false
|
||||||
@State var isRenaming: Bool = false
|
@State var isRenaming: Bool = false
|
||||||
|
|
||||||
var deletedSecret: (AnySecret) -> Void
|
var deletedSecret: (AnySecret) -> Void
|
||||||
var renamedSecret: (AnySecret) -> Void
|
var renamedSecret: (AnySecret) -> Void
|
||||||
|
|
||||||
private var showingPopup: Binding<Bool> {
|
|
||||||
Binding(
|
|
||||||
get: { isDeleting || isRenaming },
|
|
||||||
set: {
|
|
||||||
if $0 == false {
|
|
||||||
isDeleting = false
|
|
||||||
isRenaming = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationLink(value: secret) {
|
let showingPopupWrapped = Binding(
|
||||||
|
get: { isDeleting || isRenaming },
|
||||||
|
set: { if $0 == false { isDeleting = false; isRenaming = false } }
|
||||||
|
)
|
||||||
|
|
||||||
|
return NavigationLink(destination: SecretDetailView(secret: secret), tag: secret.id, selection: $activeSecret) {
|
||||||
if secret.requiresAuthentication {
|
if secret.requiresAuthentication {
|
||||||
HStack {
|
HStack {
|
||||||
Text(secret.name)
|
Text(secret.name)
|
||||||
@@ -39,14 +33,14 @@ struct SecretListItemView: View {
|
|||||||
.contextMenu {
|
.contextMenu {
|
||||||
if store is AnySecretStoreModifiable {
|
if store is AnySecretStoreModifiable {
|
||||||
Button(action: { isRenaming = true }) {
|
Button(action: { isRenaming = true }) {
|
||||||
Text("secret_list_rename_button")
|
Text("Rename")
|
||||||
}
|
}
|
||||||
Button(action: { isDeleting = true }) {
|
Button(action: { isDeleting = true }) {
|
||||||
Text("secret_list_delete_button")
|
Text("Delete")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.popover(isPresented: showingPopup) {
|
.popover(isPresented: showingPopupWrapped) {
|
||||||
if let modifiable = store as? AnySecretStoreModifiable {
|
if let modifiable = store as? AnySecretStoreModifiable {
|
||||||
if isDeleting {
|
if isDeleting {
|
||||||
DeleteSecretView(store: modifiable, secret: secret) { deleted in
|
DeleteSecretView(store: modifiable, secret: secret) { deleted in
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ struct SetupView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(minWidth: 500, idealWidth: 500, minHeight: 500, idealHeight: 500)
|
.frame(idealWidth: 500, idealHeight: 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -55,13 +55,13 @@ struct StepView: View {
|
|||||||
.foregroundColor(.green)
|
.foregroundColor(.green)
|
||||||
.frame(width: max(0, ((width - (Constants.padding * 2)) / Double(numberOfSteps - 1)) * Double(currentStep) - (Constants.circleWidth / 2)), height: 5)
|
.frame(width: max(0, ((width - (Constants.padding * 2)) / Double(numberOfSteps - 1)) * Double(currentStep) - (Constants.circleWidth / 2)), height: 5)
|
||||||
HStack {
|
HStack {
|
||||||
ForEach(Array(0..<numberOfSteps), id: \.self) { index in
|
ForEach(0..<numberOfSteps) { index in
|
||||||
ZStack {
|
ZStack {
|
||||||
if currentStep > index {
|
if currentStep > index {
|
||||||
Circle()
|
Circle()
|
||||||
.foregroundColor(.green)
|
.foregroundColor(.green)
|
||||||
.frame(width: Constants.circleWidth, height: Constants.circleWidth)
|
.frame(width: Constants.circleWidth, height: Constants.circleWidth)
|
||||||
Text("setup_step_complete_symbol")
|
Text("✓")
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
.bold()
|
.bold()
|
||||||
} else {
|
} else {
|
||||||
@@ -101,14 +101,14 @@ extension StepView {
|
|||||||
|
|
||||||
struct SetupStepView<Content> : View where Content : View {
|
struct SetupStepView<Content> : View where Content : View {
|
||||||
|
|
||||||
let title: LocalizedStringKey
|
let title: String
|
||||||
let image: Image
|
let image: Image
|
||||||
let bodyText: LocalizedStringKey
|
let bodyText: String
|
||||||
let buttonTitle: LocalizedStringKey
|
let buttonTitle: String
|
||||||
let buttonAction: () -> Void
|
let buttonAction: () -> Void
|
||||||
let content: Content
|
let content: Content
|
||||||
|
|
||||||
init(title: LocalizedStringKey, image: Image, bodyText: LocalizedStringKey, buttonTitle: LocalizedStringKey, buttonAction: @escaping () -> Void = {}, @ViewBuilder content: () -> Content) {
|
init(title: String, image: Image, bodyText: String, buttonTitle: String, buttonAction: @escaping () -> Void = {}, @ViewBuilder content: () -> Content) {
|
||||||
self.title = title
|
self.title = title
|
||||||
self.image = image
|
self.image = image
|
||||||
self.bodyText = bodyText
|
self.bodyText = bodyText
|
||||||
@@ -145,21 +145,19 @@ struct SecretAgentSetupView: View {
|
|||||||
let buttonAction: () -> Void
|
let buttonAction: () -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
SetupStepView(title: "setup_agent_title",
|
SetupStepView(title: "Setup Secret Agent",
|
||||||
image: Image(nsImage: NSApplication.shared.applicationIconImage),
|
image: Image(nsImage: NSApplication.shared.applicationIconImage),
|
||||||
bodyText: "setup_agent_description",
|
bodyText: "Secretive needs to set up a helper app to work properly. It will sign requests from SSH clients in the background, so you don't need to keep the main Secretive app open.",
|
||||||
buttonTitle: "setup_agent_install_button",
|
buttonTitle: "Install",
|
||||||
buttonAction: install) {
|
buttonAction: install) {
|
||||||
Text("setup_agent_activity_monitor_description")
|
(Text("This helper app is called ") + Text("Secret Agent").bold().underline() + Text(" and you may see it in Activity Manager from time to time."))
|
||||||
.multilineTextAlignment(.center)
|
.multilineTextAlignment(.center)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func install() {
|
func install() {
|
||||||
Task {
|
LaunchAgentController().install()
|
||||||
await LaunchAgentController().install()
|
buttonAction()
|
||||||
buttonAction()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -172,12 +170,12 @@ struct SSHAgentSetupView: View {
|
|||||||
@State private var selectedShellInstruction: ShellConfigInstruction = controller.shellInstructions.first!
|
@State private var selectedShellInstruction: ShellConfigInstruction = controller.shellInstructions.first!
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
SetupStepView(title: "setup_ssh_title",
|
SetupStepView(title: "Configure your SSH Agent",
|
||||||
image: Image(systemName: "terminal"),
|
image: Image(systemName: "terminal"),
|
||||||
bodyText: "setup_ssh_description",
|
bodyText: "Add this line to your shell config telling SSH to talk to Secret Agent when it wants to authenticate. Secretive can either do this for you automatically, or you can copy and paste this into your config file.",
|
||||||
buttonTitle: "setup_ssh_added_manually_button",
|
buttonTitle: "I Added it Manually",
|
||||||
buttonAction: buttonAction) {
|
buttonAction: buttonAction) {
|
||||||
Link("setup_third_party_faq_link", destination: URL(string: "https://github.com/maxgoedjen/secretive/blob/main/APP_CONFIG.md")!)
|
Link("If you're trying to set up a third party app, check out the FAQ.", destination: URL(string: "https://github.com/maxgoedjen/secretive/blob/main/APP_CONFIG.md")!)
|
||||||
Picker(selection: $selectedShellInstruction, label: EmptyView()) {
|
Picker(selection: $selectedShellInstruction, label: EmptyView()) {
|
||||||
ForEach(SSHAgentSetupView.controller.shellInstructions) { instruction in
|
ForEach(SSHAgentSetupView.controller.shellInstructions) { instruction in
|
||||||
Text(instruction.shell)
|
Text(instruction.shell)
|
||||||
@@ -185,8 +183,8 @@ struct SSHAgentSetupView: View {
|
|||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
}.pickerStyle(SegmentedPickerStyle())
|
}.pickerStyle(SegmentedPickerStyle())
|
||||||
CopyableView(title: "setup_ssh_add_to_config_button_\(selectedShellInstruction.shellConfigPath)", image: Image(systemName: "greaterthan.square"), text: selectedShellInstruction.text)
|
CopyableView(title: "Add to \(selectedShellInstruction.shellConfigPath)", image: Image(systemName: "greaterthan.square"), text: selectedShellInstruction.text)
|
||||||
Button("setup_ssh_add_for_me_button") {
|
Button("Add it For Me") {
|
||||||
let controller = ShellConfigurationController()
|
let controller = ShellConfigurationController()
|
||||||
if controller.addToShell(shellInstructions: selectedShellInstruction) {
|
if controller.addToShell(shellInstructions: selectedShellInstruction) {
|
||||||
buttonAction()
|
buttonAction()
|
||||||
@@ -216,12 +214,12 @@ struct UpdaterExplainerView: View {
|
|||||||
let buttonAction: () -> Void
|
let buttonAction: () -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
SetupStepView(title: "setup_updates_title",
|
SetupStepView(title: "Updates",
|
||||||
image: Image(systemName: "dot.radiowaves.left.and.right"),
|
image: Image(systemName: "dot.radiowaves.left.and.right"),
|
||||||
bodyText: "setup_updates_description",
|
bodyText: "Secretive will periodically check with GitHub to see if there's a new release. If you see any network requests to GitHub, that's why.",
|
||||||
buttonTitle: "setup_updates_ok",
|
buttonTitle: "Okay",
|
||||||
buttonAction: buttonAction) {
|
buttonAction: buttonAction) {
|
||||||
Link("setup_updates_readmore", destination: SetupView.Constants.updaterFAQURL)
|
Link("Read more about this here.", destination: SetupView.Constants.updaterFAQURL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,60 +4,60 @@ import SecretKit
|
|||||||
|
|
||||||
struct StoreListView: View {
|
struct StoreListView: View {
|
||||||
|
|
||||||
@Binding var activeSecret: AnySecret?
|
@Binding var activeSecret: AnySecret.ID?
|
||||||
|
|
||||||
@Environment(\.secretStoreList) private var storeList
|
@EnvironmentObject private var storeList: SecretStoreList
|
||||||
|
|
||||||
private func secretDeleted(secret: AnySecret) {
|
private func secretDeleted(secret: AnySecret) {
|
||||||
activeSecret = nextDefaultSecret
|
activeSecret = nextDefaultSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
private func secretRenamed(secret: AnySecret) {
|
private func secretRenamed(secret: AnySecret) {
|
||||||
activeSecret = secret
|
activeSecret = secret.id
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationSplitView {
|
NavigationView {
|
||||||
List(selection: $activeSecret) {
|
List(selection: $activeSecret) {
|
||||||
ForEach(storeList.stores) { store in
|
ForEach(storeList.stores) { store in
|
||||||
if store.isAvailable {
|
if store.isAvailable {
|
||||||
Section(header: Text(store.name)) {
|
Section(header: Text(store.name)) {
|
||||||
ForEach(store.secrets) { secret in
|
if store.secrets.isEmpty {
|
||||||
SecretListItemView(
|
EmptyStoreView(store: store, activeSecret: $activeSecret)
|
||||||
store: store,
|
} else {
|
||||||
secret: secret,
|
ForEach(store.secrets) { secret in
|
||||||
deletedSecret: secretDeleted,
|
SecretListItemView(
|
||||||
renamedSecret: secretRenamed
|
store: store,
|
||||||
)
|
secret: secret,
|
||||||
|
activeSecret: $activeSecret,
|
||||||
|
deletedSecret: self.secretDeleted,
|
||||||
|
renamedSecret: self.secretRenamed
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} detail: {
|
.listStyle(SidebarListStyle())
|
||||||
if let activeSecret {
|
.onAppear {
|
||||||
SecretDetailView(secret: activeSecret)
|
activeSecret = nextDefaultSecret
|
||||||
} else if let nextDefaultSecret {
|
|
||||||
// This just means onAppear hasn't executed yet.
|
|
||||||
// Do this to avoid a blip.
|
|
||||||
SecretDetailView(secret: nextDefaultSecret)
|
|
||||||
} else {
|
|
||||||
EmptyStoreView(store: storeList.modifiableStore ?? storeList.stores.first)
|
|
||||||
}
|
}
|
||||||
|
.frame(minWidth: 100, idealWidth: 240)
|
||||||
}
|
}
|
||||||
.navigationSplitViewStyle(.balanced)
|
|
||||||
.onAppear {
|
|
||||||
activeSecret = nextDefaultSecret
|
|
||||||
}
|
|
||||||
.frame(minWidth: 100, idealWidth: 240)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension StoreListView {
|
extension StoreListView {
|
||||||
|
|
||||||
private var nextDefaultSecret: AnySecret? {
|
var nextDefaultSecret: AnyHashable? {
|
||||||
return storeList.stores.first(where: { !$0.secrets.isEmpty })?.secrets.first
|
let fallback: AnyHashable
|
||||||
|
if storeList.modifiableStore?.isAvailable ?? false {
|
||||||
|
fallback = EmptyStoreView.Constants.emptyStoreModifiableTag
|
||||||
|
} else {
|
||||||
|
fallback = EmptyStoreView.Constants.emptyStoreTag
|
||||||
|
}
|
||||||
|
return storeList.stores.compactMap(\.secrets.first).first?.id ?? fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,42 +16,22 @@ struct ToolbarButtonStyle: ButtonStyle {
|
|||||||
self.lightColor = lightColor
|
self.lightColor = lightColor
|
||||||
self.darkColor = darkColor
|
self.darkColor = darkColor
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(macOS 26.0, *)
|
|
||||||
private var glassTint: Color {
|
|
||||||
if !hovering {
|
|
||||||
colorScheme == .light ? lightColor : darkColor
|
|
||||||
} else {
|
|
||||||
colorScheme == .light ? lightColor.exposureAdjust(1) : darkColor.exposureAdjust(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeBody(configuration: Configuration) -> some View {
|
func makeBody(configuration: Configuration) -> some View {
|
||||||
if #available(macOS 26.0, *) {
|
configuration.label
|
||||||
configuration
|
.padding(EdgeInsets(top: 6, leading: 8, bottom: 6, trailing: 8))
|
||||||
.label
|
.background(colorScheme == .light ? lightColor : darkColor)
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
.padding(EdgeInsets(top: 6, leading: 8, bottom: 6, trailing: 8))
|
.clipShape(RoundedRectangle(cornerRadius: 5))
|
||||||
.glassEffect(.regular.tint(glassTint), in: .capsule)
|
.overlay(
|
||||||
.onHover { hovering in
|
RoundedRectangle(cornerRadius: 5)
|
||||||
|
.stroke(colorScheme == .light ? .black.opacity(0.15) : .white.opacity(0.15), lineWidth: 1)
|
||||||
|
.background(hovering ? (colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.05)) : Color.clear)
|
||||||
|
)
|
||||||
|
.onHover { hovering in
|
||||||
|
withAnimation {
|
||||||
self.hovering = hovering
|
self.hovering = hovering
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
configuration
|
|
||||||
.label
|
|
||||||
.background(colorScheme == .light ? lightColor : darkColor)
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 5))
|
|
||||||
.overlay(
|
|
||||||
RoundedRectangle(cornerRadius: 5)
|
|
||||||
.stroke(colorScheme == .light ? .black.opacity(0.15) : .white.opacity(0.15), lineWidth: 1)
|
|
||||||
.background(hovering ? (colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.05)) : Color.clear)
|
|
||||||
)
|
|
||||||
.onHover { hovering in
|
|
||||||
withAnimation {
|
|
||||||
self.hovering = hovering
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,28 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Brief
|
import Brief
|
||||||
|
|
||||||
struct UpdateDetailView: View {
|
struct UpdateDetailView<UpdaterType: Updater>: View {
|
||||||
|
|
||||||
@Environment(\.updater) var updater: any UpdaterProtocol
|
@EnvironmentObject var updater: UpdaterType
|
||||||
|
|
||||||
let update: Release
|
let update: Release
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
Text("update_version_name_\(update.name)").font(.title)
|
Text("Secretive \(update.name)").font(.title)
|
||||||
GroupBox(label: Text("update_release_notes_title")) {
|
GroupBox(label: Text("Release Notes")) {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
attributedBody
|
attributedBody
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
if !update.critical {
|
if !update.critical {
|
||||||
Button("update_ignore_button") {
|
Button("Ignore") {
|
||||||
Task {
|
updater.ignore(release: update)
|
||||||
await updater.ignore(release: update)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
Button("update_update_button") {
|
Button("Update") {
|
||||||
NSWorkspace.shared.open(update.html_url)
|
NSWorkspace.shared.open(update.html_url)
|
||||||
}
|
}
|
||||||
.keyboardShortcut(.defaultAction)
|
.keyboardShortcut(.defaultAction)
|
||||||
@@ -36,24 +34,24 @@ struct UpdateDetailView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var attributedBody: Text {
|
var attributedBody: Text {
|
||||||
var text = Text(verbatim: "")
|
var text = Text("")
|
||||||
for line in update.body.split(whereSeparator: \.isNewline) {
|
for line in update.body.split(whereSeparator: \.isNewline) {
|
||||||
let attributed: Text
|
let attributed: Text
|
||||||
let split = line.split(separator: " ")
|
let split = line.split(separator: " ")
|
||||||
let unprefixed = split.dropFirst().joined(separator: " ")
|
let unprefixed = split.dropFirst().joined()
|
||||||
if let prefix = split.first {
|
if let prefix = split.first {
|
||||||
switch prefix {
|
switch prefix {
|
||||||
case "#":
|
case "#":
|
||||||
attributed = Text(unprefixed).font(.title) + Text(verbatim: "\n")
|
attributed = Text(unprefixed).font(.title) + Text("\n")
|
||||||
case "##":
|
case "##":
|
||||||
attributed = Text(unprefixed).font(.title2) + Text(verbatim: "\n")
|
attributed = Text(unprefixed).font(.title2) + Text("\n")
|
||||||
case "###":
|
case "###":
|
||||||
attributed = Text(unprefixed).font(.title3) + Text(verbatim: "\n")
|
attributed = Text(unprefixed).font(.title3) + Text("\n")
|
||||||
default:
|
default:
|
||||||
attributed = Text(line) + Text(verbatim: "\n\n")
|
attributed = Text(line) + Text("\n\n")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
attributed = Text(line) + Text(verbatim: "\n\n")
|
attributed = Text(line) + Text("\n\n")
|
||||||
}
|
}
|
||||||
text = text + attributed
|
text = text + attributed
|
||||||
}
|
}
|
||||||
|
|||||||
22
Sources/SecretiveTests/Info.plist
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
20
Sources/SecretiveTests/SecretiveTests.swift
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import XCTest
|
||||||
|
@testable import Secretive
|
||||||
|
|
||||||
|
class SecretiveTests: XCTestCase {
|
||||||
|
|
||||||
|
override func setUp() {
|
||||||
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tearDown() {
|
||||||
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||||
|
}
|
||||||
|
|
||||||
|
func testExample() {
|
||||||
|
// This is an example of a functional test case.
|
||||||
|
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||