Skip to content

Commit

Permalink
Revert "Backport mutex"
Browse files Browse the repository at this point in the history
This reverts commit 9b02afb.
  • Loading branch information
maxgoedjen committed Jan 6, 2025
1 parent 9b02afb commit bab76da
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 60 deletions.
18 changes: 5 additions & 13 deletions Sources/Packages/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,18 @@ let package = Package(
.library(
name: "Brief",
targets: ["Brief"]),
.library(
name: "Backports",
targets: ["Backports"]),
],
dependencies: [
],
targets: [
.target(
name: "Backports",
dependencies: [],
swiftSettings: swiftSettings
),
.target(
name: "SecretKit",
dependencies: ["Backports"],
dependencies: [],
swiftSettings: swiftSettings
),
.testTarget(
name: "SecretKitTests",
dependencies: ["Backports", "SecretKit", "SecureEnclaveSecretKit", "SmartCardSecretKit"],
dependencies: ["SecretKit", "SecureEnclaveSecretKit", "SmartCardSecretKit"],
swiftSettings: swiftSettings
),
.target(
Expand All @@ -56,12 +48,12 @@ let package = Package(
),
.target(
name: "SmartCardSecretKit",
dependencies: ["Backports", "SecretKit"],
dependencies: ["SecretKit"],
swiftSettings: swiftSettings
),
.target(
name: "SecretAgentKit",
dependencies: ["Backports", "SecretKit", "SecretAgentKitHeaders"],
dependencies: ["SecretKit", "SecretAgentKitHeaders"],
swiftSettings: swiftSettings
),
.systemLibrary(
Expand All @@ -73,7 +65,7 @@ let package = Package(
,
.target(
name: "Brief",
dependencies: ["Backports"]
dependencies: []
),
.testTarget(
name: "BriefTests",
Expand Down
30 changes: 0 additions & 30 deletions Sources/Packages/Sources/Backports/_Mutex.swift

This file was deleted.

3 changes: 1 addition & 2 deletions Sources/Packages/Sources/Brief/Updater.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import Foundation
import Observation
import Synchronization
import Backports

/// A concrete implementation of ``UpdaterProtocol`` which considers the current release and OS version.
@Observable public final class Updater: UpdaterProtocol, ObservableObject, Sendable {

public var update: Release? {
_update.withLock { $0 }
}
private let _update: _Mutex<Release?> = .init(nil)
private let _update: Mutex<Release?> = .init(nil)
public let testBuild: Bool

/// The current OS version.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import Foundation
import OSLog
import Synchronization
import Backports

/// Manages storage and lookup for OpenSSH certificates.
public final class OpenSSHCertificateHandler: Sendable {

private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: NSHomeDirectory())
private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent", category: "OpenSSHCertificateHandler")
private let writer = OpenSSHKeyWriter()
private let keyBlobsAndNames: _Mutex<[AnySecret: (Data, Data)]> = .init([:])
private let keyBlobsAndNames: Mutex<[AnySecret: (Data, Data)]> = .init([:])

/// Initializes an OpenSSHCertificateHandler.
public init() {
Expand Down
5 changes: 2 additions & 3 deletions Sources/Packages/Sources/SecretKit/SecretStoreList.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import Observation
import Synchronization
import Backports

/// A "Store Store," which holds a list of type-erased stores.
@Observable public final class SecretStoreList: Sendable {
Expand All @@ -10,13 +9,13 @@ import Backports
public var stores: [AnySecretStore] {
__stores.withLock { $0 }
}
private let __stores: _Mutex<[AnySecretStore]> = .init([])
private let __stores: Mutex<[AnySecretStore]> = .init([])

/// A modifiable store, if one is available.
public var modifiableStore: AnySecretStoreModifiable? {
__modifiableStore.withLock { $0 }
}
private let __modifiableStore: _Mutex<AnySecretStoreModifiable?> = .init(nil)
private let __modifiableStore: Mutex<AnySecretStoreModifiable?> = .init(nil)

/// Initializes a SecretStoreList.
public init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import CryptoKit
import LocalAuthentication
import SecretKit
import Synchronization
import Backports

extension SecureEnclave {

Expand All @@ -20,9 +19,9 @@ extension SecureEnclave {
public var secrets: [Secret] {
_secrets.withLock { $0 }
}
private let _secrets: _Mutex<[Secret]> = .init([])
private let _secrets: Mutex<[Secret]> = .init([])

private let persistedAuthenticationContexts: _Mutex<[Secret: PersistentAuthenticationContext]> = .init([:])
private let persistedAuthenticationContexts: Mutex<[Secret: PersistentAuthenticationContext]> = .init([:])

/// Initializes a Store.
public init() {
Expand Down Expand Up @@ -106,7 +105,7 @@ extension SecureEnclave {
}

public func sign(data: Data, with secret: Secret, for provenance: SigningRequestProvenance) throws -> Data {
let context: _Mutex<LAContext>
let context: Mutex<LAContext>
// if let existing = persistedAuthenticationContexts.withLock({ $0 })[secret], existing.valid {
// context = existing.context
// } else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Security
import CryptoTokenKit
import LocalAuthentication
import SecretKit
import Backports

extension SmartCard {

Expand All @@ -20,7 +19,7 @@ extension SmartCard {
/// An implementation of Store backed by a Smart Card.
@Observable public final class Store: SecretStore {

private let state: _Mutex<State> = .init(.init())
private let state: Mutex<State> = .init(.init())
public var isAvailable: Bool {
state.withLock { $0.isAvailable }
}
Expand Down
3 changes: 1 addition & 2 deletions Sources/SecretAgent/Notifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import SecretKit
import SecretAgentKit
import Brief
import Synchronization
import Backports

final class Notifier: Sendable {

Expand Down Expand Up @@ -152,7 +151,7 @@ final class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate, Se
fileprivate var pendingPersistableSecrets: [String: AnySecret] = [:]
}

fileprivate let state: _Mutex<State> = .init(.init())
fileprivate let state: Mutex<State> = .init(.init())

func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) {

Expand Down
3 changes: 1 addition & 2 deletions Sources/Secretive/Preview Content/PreviewUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import Foundation
import Synchronization
import Observation
import Brief
import Backports

@Observable class PreviewUpdater: UpdaterProtocol {

var update: Release? {
_update.withLock { $0 }
}
let _update: _Mutex<Release?> = .init(nil)
let _update: Mutex<Release?> = .init(nil)

let testBuild = false

Expand Down

0 comments on commit bab76da

Please sign in to comment.