mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-25 15:07:07 +00:00
Fileprivate -> private (#91)
This commit is contained in:
parent
bc0a45366a
commit
b234100aa5
@ -23,7 +23,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
let path = (NSHomeDirectory() as NSString).appendingPathComponent("socket.ssh") as String
|
let path = (NSHomeDirectory() as NSString).appendingPathComponent("socket.ssh") as String
|
||||||
return SocketController(path: path)
|
return SocketController(path: path)
|
||||||
}()
|
}()
|
||||||
fileprivate var updateSink: AnyCancellable?
|
private var updateSink: AnyCancellable?
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
os_log(.debug, "SecretAgent finished launching")
|
os_log(.debug, "SecretAgent finished launching")
|
||||||
|
@ -7,7 +7,7 @@ import Brief
|
|||||||
|
|
||||||
class Notifier {
|
class Notifier {
|
||||||
|
|
||||||
fileprivate let notificationDelegate = NotificationDelegate()
|
private let notificationDelegate = NotificationDelegate()
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
let updateAction = UNNotificationAction(identifier: Constants.updateActionIdentitifier, title: "Update", options: [])
|
let updateAction = UNNotificationAction(identifier: Constants.updateActionIdentitifier, title: "Update", options: [])
|
||||||
|
@ -6,10 +6,10 @@ import AppKit
|
|||||||
|
|
||||||
public class Agent {
|
public class Agent {
|
||||||
|
|
||||||
fileprivate let storeList: SecretStoreList
|
private let storeList: SecretStoreList
|
||||||
fileprivate let witness: SigningWitness?
|
private let witness: SigningWitness?
|
||||||
fileprivate let writer = OpenSSHKeyWriter()
|
private let writer = OpenSSHKeyWriter()
|
||||||
fileprivate let requestTracer = SigningRequestTracer()
|
private let requestTracer = SigningRequestTracer()
|
||||||
|
|
||||||
public init(storeList: SecretStoreList, witness: SigningWitness? = nil) {
|
public init(storeList: SecretStoreList, witness: SigningWitness? = nil) {
|
||||||
os_log(.debug, "Agent is running")
|
os_log(.debug, "Agent is running")
|
||||||
|
@ -3,8 +3,8 @@ import OSLog
|
|||||||
|
|
||||||
public class SocketController {
|
public class SocketController {
|
||||||
|
|
||||||
fileprivate var fileHandle: FileHandle?
|
private var fileHandle: FileHandle?
|
||||||
fileprivate var port: SocketPort?
|
private var port: SocketPort?
|
||||||
public var handler: ((FileHandleReader, FileHandleWriter) -> Void)?
|
public var handler: ((FileHandleReader, FileHandleWriter) -> Void)?
|
||||||
|
|
||||||
public init(path: String) {
|
public init(path: String) {
|
||||||
|
@ -3,12 +3,12 @@ import Foundation
|
|||||||
public struct AnySecret: Secret {
|
public struct AnySecret: Secret {
|
||||||
|
|
||||||
let base: Any
|
let base: Any
|
||||||
fileprivate let hashable: AnyHashable
|
private let hashable: AnyHashable
|
||||||
fileprivate let _id: () -> AnyHashable
|
private let _id: () -> AnyHashable
|
||||||
fileprivate let _name: () -> String
|
private let _name: () -> String
|
||||||
fileprivate let _algorithm: () -> Algorithm
|
private let _algorithm: () -> Algorithm
|
||||||
fileprivate let _keySize: () -> Int
|
private let _keySize: () -> Int
|
||||||
fileprivate let _publicKey: () -> Data
|
private let _publicKey: () -> Data
|
||||||
|
|
||||||
public init<T>(_ secret: T) where T: Secret {
|
public init<T>(_ secret: T) where T: Secret {
|
||||||
if let secret = secret as? AnySecret {
|
if let secret = secret as? AnySecret {
|
||||||
|
@ -4,12 +4,12 @@ import Combine
|
|||||||
public class AnySecretStore: SecretStore {
|
public class AnySecretStore: SecretStore {
|
||||||
|
|
||||||
let base: Any
|
let base: Any
|
||||||
fileprivate let _isAvailable: () -> Bool
|
private let _isAvailable: () -> Bool
|
||||||
fileprivate let _id: () -> UUID
|
private let _id: () -> UUID
|
||||||
fileprivate let _name: () -> String
|
private let _name: () -> String
|
||||||
fileprivate let _secrets: () -> [AnySecret]
|
private let _secrets: () -> [AnySecret]
|
||||||
fileprivate let _sign: (Data, AnySecret) throws -> Data
|
private let _sign: (Data, AnySecret) throws -> Data
|
||||||
fileprivate var sink: AnyCancellable?
|
private var sink: AnyCancellable?
|
||||||
|
|
||||||
public init<SecretStoreType>(_ secretStore: SecretStoreType) where SecretStoreType: SecretStore {
|
public init<SecretStoreType>(_ secretStore: SecretStoreType) where SecretStoreType: SecretStore {
|
||||||
base = secretStore
|
base = secretStore
|
||||||
@ -47,8 +47,8 @@ public class AnySecretStore: SecretStore {
|
|||||||
|
|
||||||
public class AnySecretStoreModifiable: AnySecretStore, SecretStoreModifiable {
|
public class AnySecretStoreModifiable: AnySecretStore, SecretStoreModifiable {
|
||||||
|
|
||||||
fileprivate let _create: (String, Bool) throws -> Void
|
private let _create: (String, Bool) throws -> Void
|
||||||
fileprivate let _delete: (AnySecret) throws -> Void
|
private let _delete: (AnySecret) throws -> Void
|
||||||
|
|
||||||
public init<SecretStoreType>(modifiable secretStore: SecretStoreType) where SecretStoreType: SecretStoreModifiable {
|
public init<SecretStoreType>(modifiable secretStore: SecretStoreType) where SecretStoreType: SecretStoreModifiable {
|
||||||
_create = { try secretStore.create(name: $0, requiresAuthentication: $1) }
|
_create = { try secretStore.create(name: $0, requiresAuthentication: $1) }
|
||||||
|
@ -5,7 +5,7 @@ public class SecretStoreList: ObservableObject {
|
|||||||
|
|
||||||
@Published public var stores: [AnySecretStore] = []
|
@Published public var stores: [AnySecretStore] = []
|
||||||
@Published public var modifiableStore: AnySecretStoreModifiable?
|
@Published public var modifiableStore: AnySecretStoreModifiable?
|
||||||
fileprivate var sinks: [AnyCancellable] = []
|
private var sinks: [AnyCancellable] = []
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ public class SecretStoreList: ObservableObject {
|
|||||||
|
|
||||||
extension SecretStoreList {
|
extension SecretStoreList {
|
||||||
|
|
||||||
fileprivate func addInternal(store: AnySecretStore) {
|
private func addInternal(store: AnySecretStore) {
|
||||||
stores.append(store)
|
stores.append(store)
|
||||||
let sink = store.objectWillChange.sink {
|
let sink = store.objectWillChange.sink {
|
||||||
self.objectWillChange.send()
|
self.objectWillChange.send()
|
||||||
|
@ -14,7 +14,7 @@ extension SecureEnclave {
|
|||||||
}
|
}
|
||||||
public let id = UUID()
|
public let id = UUID()
|
||||||
public let name = NSLocalizedString("Secure Enclave", comment: "Secure Enclave")
|
public let name = NSLocalizedString("Secure Enclave", comment: "Secure Enclave")
|
||||||
@Published public fileprivate(set) var secrets: [Secret] = []
|
@Published public private(set) var secrets: [Secret] = []
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
DistributedNotificationCenter.default().addObserver(forName: .secretStoreUpdated, object: nil, queue: .main) { _ in
|
DistributedNotificationCenter.default().addObserver(forName: .secretStoreUpdated, object: nil, queue: .main) { _ in
|
||||||
@ -107,7 +107,7 @@ extension SecureEnclave {
|
|||||||
|
|
||||||
extension SecureEnclave.Store {
|
extension SecureEnclave.Store {
|
||||||
|
|
||||||
fileprivate func reloadSecrets(notify: Bool = true) {
|
private func reloadSecrets(notify: Bool = true) {
|
||||||
secrets.removeAll()
|
secrets.removeAll()
|
||||||
loadSecrets()
|
loadSecrets()
|
||||||
if notify {
|
if notify {
|
||||||
@ -115,7 +115,7 @@ extension SecureEnclave.Store {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func loadSecrets() {
|
private func loadSecrets() {
|
||||||
let attributes = [
|
let attributes = [
|
||||||
kSecClass: kSecClassKey,
|
kSecClass: kSecClassKey,
|
||||||
kSecAttrKeyType: SecureEnclave.Constants.keyType,
|
kSecAttrKeyType: SecureEnclave.Constants.keyType,
|
||||||
@ -139,7 +139,7 @@ extension SecureEnclave.Store {
|
|||||||
secrets.append(contentsOf: wrapped)
|
secrets.append(contentsOf: wrapped)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func savePublicKey(_ publicKey: SecKey, name: String) throws {
|
private func savePublicKey(_ publicKey: SecKey, name: String) throws {
|
||||||
let attributes = [
|
let attributes = [
|
||||||
kSecClass: kSecClassKey,
|
kSecClass: kSecClassKey,
|
||||||
kSecAttrKeyType: SecureEnclave.Constants.keyType,
|
kSecAttrKeyType: SecureEnclave.Constants.keyType,
|
||||||
@ -178,8 +178,8 @@ extension SecureEnclave {
|
|||||||
extension SecureEnclave {
|
extension SecureEnclave {
|
||||||
|
|
||||||
enum Constants {
|
enum Constants {
|
||||||
fileprivate static let keyTag = "com.maxgoedjen.secretive.secureenclave.key".data(using: .utf8)! as CFData
|
static let keyTag = "com.maxgoedjen.secretive.secureenclave.key".data(using: .utf8)! as CFData
|
||||||
fileprivate static let keyType = kSecAttrKeyTypeECSECPrimeRandom
|
static let keyType = kSecAttrKeyTypeECSECPrimeRandom
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,10 @@ extension SmartCard {
|
|||||||
// TODO: Read actual smart card name, eg "YubiKey 5c"
|
// TODO: Read actual smart card name, eg "YubiKey 5c"
|
||||||
@Published public var isAvailable: Bool = false
|
@Published public var isAvailable: Bool = false
|
||||||
public let id = UUID()
|
public let id = UUID()
|
||||||
public fileprivate(set) var name = NSLocalizedString("Smart Card", comment: "Smart Card")
|
public private(set) var name = NSLocalizedString("Smart Card", comment: "Smart Card")
|
||||||
@Published public fileprivate(set) var secrets: [Secret] = []
|
@Published public private(set) var secrets: [Secret] = []
|
||||||
fileprivate let watcher = TKTokenWatcher()
|
private let watcher = TKTokenWatcher()
|
||||||
fileprivate var tokenID: String?
|
private var tokenID: String?
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
tokenID = watcher.nonSecureEnclaveTokens.first
|
tokenID = watcher.nonSecureEnclaveTokens.first
|
||||||
@ -83,12 +83,12 @@ extension SmartCard {
|
|||||||
|
|
||||||
extension SmartCard.Store {
|
extension SmartCard.Store {
|
||||||
|
|
||||||
fileprivate func smartcardRemoved(for tokenID: String? = nil) {
|
private func smartcardRemoved(for tokenID: String? = nil) {
|
||||||
self.tokenID = nil
|
self.tokenID = nil
|
||||||
reloadSecrets()
|
reloadSecrets()
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func reloadSecrets() {
|
private func reloadSecrets() {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.isAvailable = self.tokenID != nil
|
self.isAvailable = self.tokenID != nil
|
||||||
self.secrets.removeAll()
|
self.secrets.removeAll()
|
||||||
@ -96,7 +96,7 @@ extension SmartCard.Store {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func loadSecrets() {
|
private func loadSecrets() {
|
||||||
guard let tokenID = tokenID else { return }
|
guard let tokenID = tokenID else { return }
|
||||||
// Hack to read name if there's only one smart card
|
// Hack to read name if there's only one smart card
|
||||||
let slotNames = TKSmartCardSlotManager().slotNames
|
let slotNames = TKSmartCardSlotManager().slotNames
|
||||||
|
@ -9,9 +9,9 @@ struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentSt
|
|||||||
@ObservedObject var agentStatusChecker: AgentStatusCheckerType
|
@ObservedObject var agentStatusChecker: AgentStatusCheckerType
|
||||||
var runSetupBlock: (() -> Void)?
|
var runSetupBlock: (() -> Void)?
|
||||||
|
|
||||||
@State fileprivate var active: AnySecret.ID?
|
@State private var active: AnySecret.ID?
|
||||||
@State fileprivate var showingDeletion = false
|
@State private var showingDeletion = false
|
||||||
@State fileprivate var deletingSecret: AnySecret?
|
@State private var deletingSecret: AnySecret?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
@ -115,7 +115,7 @@ struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentSt
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate enum Constants {
|
private enum Constants {
|
||||||
static let emptyStoreModifiableTag: AnyHashable = "emptyStoreModifiableTag"
|
static let emptyStoreModifiableTag: AnyHashable = "emptyStoreModifiableTag"
|
||||||
static let emptyStoreTag: AnyHashable = "emptyStoreModifiableTag"
|
static let emptyStoreTag: AnyHashable = "emptyStoreModifiableTag"
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ struct DeleteSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
|
|
||||||
@State var confirm = ""
|
@State var confirm = ""
|
||||||
|
|
||||||
fileprivate var dismissalBlock: (Bool) -> ()
|
private var dismissalBlock: (Bool) -> ()
|
||||||
|
|
||||||
init(secret: StoreType.SecretType, store: StoreType, dismissalBlock: @escaping (Bool) -> ()) {
|
init(secret: StoreType.SecretType, store: StoreType, dismissalBlock: @escaping (Bool) -> ()) {
|
||||||
self.secret = secret
|
self.secret = secret
|
||||||
|
Loading…
Reference in New Issue
Block a user