Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Sources/Clavis/State/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ public class AppState: ObservableObject {
algorithm: String = "ECDSA P-256",
storageType: KeyStorageType = .secureEnclave,
biometricPolicy: BiometricPolicy? = nil,
keyPurpose: KeyPurpose = .general
keyPurpose: KeyPurpose = .general,
accessProfile: KeyAccessProfile? = nil
) throws -> SSHKeyInfo {
defer {
self.keys = keyManagementViewModel.keys
Expand All @@ -490,7 +491,8 @@ public class AppState: ObservableObject {
algorithm: algorithm,
storageType: storageType,
biometricPolicy: biometricPolicy,
keyPurpose: keyPurpose
keyPurpose: keyPurpose,
accessProfile: accessProfile
)
// Generating a key already authenticates the user; transition the panel out
// of its initial locked state so leaving empty-vault bypass does not lock the window.
Expand Down Expand Up @@ -529,6 +531,16 @@ public class AppState: ObservableObject {
try changeKeyKind(label: label, to: newPurpose)
}

public func changeAccessProfile(label: String, type: KeyType? = nil, capabilities: KeyCapabilities? = nil) throws {
defer {
self.keys = keyManagementViewModel.keys
self.errorMessage = keyManagementViewModel.errorMessage
refreshAgentSessions()
updateGitGraceState()
}
try keyManagementViewModel.changeAccessProfile(label: label, type: type, capabilities: capabilities)
}

public func lockKey(label: String) throws {
defer {
self.keys = keyManagementViewModel.keys
Expand Down
11 changes: 9 additions & 2 deletions Sources/Clavis/State/KeyManagementViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ public class KeyManagementViewModel: ObservableObject {
algorithm: String = "ECDSA P-256",
storageType: KeyStorageType = .secureEnclave,
biometricPolicy: BiometricPolicy? = nil,
keyPurpose: KeyPurpose = .general
keyPurpose: KeyPurpose = .general,
accessProfile: KeyAccessProfile? = nil
) throws -> SSHKeyInfo {
let info = try keyManager.generateKey(
label: label,
algorithm: algorithm,
storageType: storageType,
biometricPolicy: biometricPolicy,
keyPurpose: keyPurpose
keyPurpose: keyPurpose,
accessProfile: accessProfile
)
refresh()
return info
Expand All @@ -70,6 +72,11 @@ public class KeyManagementViewModel: ObservableObject {
try changeKeyKind(label: label, to: newPurpose)
}

public func changeAccessProfile(label: String, type: KeyType? = nil, capabilities: KeyCapabilities? = nil) throws {
defer { refresh() }
try keyManager.changeAccessProfile(label: label, type: type, capabilities: capabilities)
}

public func lockKey(label: String) throws {
try keyManager.lockKey(label: label)
refresh()
Expand Down
Loading
Loading