mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-09-19 14:48:01 +02:00
WIP
This commit is contained in:
@@ -365,16 +365,6 @@
|
||||
},
|
||||
"shouldTranslate" : false
|
||||
},
|
||||
"%@ - %@" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "new",
|
||||
"value" : "%1$@ - %2$@"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"about_build_log_button" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
@@ -6130,6 +6120,19 @@
|
||||
},
|
||||
"Certificates" : {
|
||||
|
||||
},
|
||||
"Connecting to %@@%@" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "new",
|
||||
"value" : "Connecting to %1$@@%2$@"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Connecting to unknown host" : {
|
||||
|
||||
},
|
||||
"copyable_click_to_copy_button" : {
|
||||
"extractionState" : "manual",
|
||||
@@ -20463,7 +20466,7 @@
|
||||
"Review" : {
|
||||
|
||||
},
|
||||
"Review All" : {
|
||||
"Review as Batch" : {
|
||||
|
||||
},
|
||||
"secret_detail_certificate_path_label" : {
|
||||
@@ -24920,6 +24923,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Signing for %@" : {
|
||||
|
||||
},
|
||||
"smart_card" : {
|
||||
"extractionState" : "manual",
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import SwiftUI
|
||||
|
||||
public struct PrimaryButtonModifier: ViewModifier {
|
||||
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
@Environment(\.isEnabled) var isEnabled
|
||||
|
||||
public func body(content: Content) -> some View {
|
||||
// Tinted glass prominent is really hard to read on 26.0.
|
||||
if #available(macOS 26.0, *), colorScheme == .dark, isEnabled {
|
||||
content.buttonStyle(.glassProminent)
|
||||
} else {
|
||||
content.buttonStyle(.borderedProminent)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension View {
|
||||
|
||||
public func primaryButton() -> some View {
|
||||
modifier(PrimaryButtonModifier())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct ToolbarCircleButtonModifier: ViewModifier {
|
||||
|
||||
public func body(content: Content) -> some View {
|
||||
if #available(macOS 26.0, *) {
|
||||
content
|
||||
.glassEffect(.regular.tint(.white.opacity(0.1)), in: .circle)
|
||||
} else {
|
||||
content
|
||||
.buttonStyle(.borderless)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension View {
|
||||
|
||||
public func toolbarCircleButton() -> some View {
|
||||
modifier(ToolbarCircleButtonModifier())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct NormalButtonModifier: ViewModifier {
|
||||
|
||||
public func body(content: Content) -> some View {
|
||||
if #available(macOS 26.0, *) {
|
||||
content.buttonStyle(.glass)
|
||||
} else {
|
||||
content.buttonStyle(.bordered)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension View {
|
||||
|
||||
public func normalButton() -> some View {
|
||||
modifier(NormalButtonModifier())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct DangerButtonModifier: ViewModifier {
|
||||
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
public func body(content: Content) -> some View {
|
||||
// Tinted glass prominent is really hard to read on 26.0.
|
||||
if #available(macOS 26.0, *), colorScheme == .dark {
|
||||
content.buttonStyle(.glassProminent)
|
||||
.tint(.red)
|
||||
.foregroundStyle(.white)
|
||||
} else {
|
||||
content.buttonStyle(.borderedProminent)
|
||||
.tint(.red)
|
||||
.foregroundStyle(.white)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension View {
|
||||
|
||||
public func danger() -> some View {
|
||||
modifier(DangerButtonModifier())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,6 +97,12 @@ public struct FixedTitleView: View {
|
||||
let subtitle: LocalizedStringResource?
|
||||
let image: Image
|
||||
|
||||
public init(title: LocalizedStringResource, subtitle: LocalizedStringResource?, image: Image) {
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
self.image = image
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
HStack {
|
||||
image
|
||||
|
||||
@@ -185,7 +185,7 @@ extension Agent {
|
||||
}
|
||||
|
||||
func signWithRequiredAuthentication(data: Data, store: AnySecretStore, secret: AnySecret, provenance: SigningRequestProvenance, target: SigningRequestTarget?) async throws -> Data {
|
||||
let context = try await authenticationHandler.waitForAuthentication(for: SignatureRequest(secret: secret, provenance: provenance))
|
||||
let context = try await authenticationHandler.waitForAuthentication(for: SignatureRequest(secret: secret, provenance: provenance, target: target))
|
||||
let result = try await store.sign(data: data, with: secret, for: provenance, target: target, context: context.laContext)
|
||||
let signedData = signatureWriter.data(secret: secret, signature: result)
|
||||
try await witness?.witness(accessTo: secret, from: store, by: provenance, target: target, offerPersistence: false) // FIXME: THIS
|
||||
|
||||
@@ -69,7 +69,7 @@ public final class AuthenticationContext: AuthenticationContextProtocol {
|
||||
|
||||
private var persistedContexts: [AnySecret: AuthenticationContext] = [:]
|
||||
private var holdingRequests: Set<SignatureRequest> = []
|
||||
private var activeTask: Task<Void, any Error>?
|
||||
private var activeTask: Task<Bool, any Error>?
|
||||
|
||||
private var lastBatchAuthPresentation: Set<SignatureRequest>?
|
||||
private var presentBatchAuth: (() async throws -> Void)?
|
||||
@@ -118,10 +118,15 @@ public final class AuthenticationContext: AuthenticationContextProtocol {
|
||||
|
||||
activeTask = Task {
|
||||
logger.log("Beginning individual auth prompt")
|
||||
_ = try? await laContext.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: laContext.localizedReason)
|
||||
let result = (try? await laContext.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: laContext.localizedReason)) ?? false
|
||||
logger.log("Ended individual auth prompt")
|
||||
return result
|
||||
}
|
||||
let result = try? await activeTask?.value
|
||||
if result == false {
|
||||
holdingRequests.remove(request)
|
||||
return context
|
||||
}
|
||||
_ = try? await activeTask?.value
|
||||
// TODO: Check something beyond cancellation? id?
|
||||
// Is this okay? Do we always assume that a cancelled task will be the proceeded on?
|
||||
if activeTask?.isCancelled ?? false {
|
||||
|
||||
@@ -19,17 +19,22 @@ public struct SignatureRequest: Identifiable, Hashable, Sendable, Comparable {
|
||||
public let date: Date
|
||||
public let secret: AnySecret
|
||||
public let provenance: SigningRequestProvenance
|
||||
public let target: SigningRequestTarget?
|
||||
|
||||
public init(secret: AnySecret, provenance: SigningRequestProvenance) {
|
||||
public init(secret: AnySecret, provenance: SigningRequestProvenance, target: SigningRequestTarget?) {
|
||||
self.id = UUID()
|
||||
self.date = Date()
|
||||
self.secret = secret
|
||||
self.provenance = provenance
|
||||
self.target = target
|
||||
}
|
||||
|
||||
public var batchID: Int {
|
||||
var hasher = Hasher()
|
||||
provenance.batchID.hash(into: &hasher)
|
||||
if let target {
|
||||
target.batchID.hash(into: &hasher)
|
||||
}
|
||||
secret.id.hash(into: &hasher)
|
||||
return hasher.finalize()
|
||||
}
|
||||
|
||||
@@ -2,12 +2,17 @@ import Foundation
|
||||
import AppKit
|
||||
|
||||
/// Describes the target of the signature operation.
|
||||
public enum SigningRequestTarget: Sendable {
|
||||
public enum SigningRequestTarget: Sendable, Hashable {
|
||||
|
||||
case connection(ConnectionPayload)
|
||||
case signature(SignaturePayload)
|
||||
|
||||
public struct ConnectionPayload: Sendable, Codable{
|
||||
public var batchID: Int {
|
||||
hashValue
|
||||
}
|
||||
|
||||
|
||||
public struct ConnectionPayload: Sendable, Codable, Hashable {
|
||||
|
||||
public let username: String
|
||||
public let hasSignature: Bool
|
||||
@@ -34,7 +39,7 @@ public enum SigningRequestTarget: Sendable {
|
||||
|
||||
}
|
||||
|
||||
public struct SignaturePayload: Sendable, Codable {
|
||||
public struct SignaturePayload: Sendable, Codable, Hashable {
|
||||
|
||||
public let namespace: String
|
||||
public let hashAlgorithm: String
|
||||
|
||||
Reference in New Issue
Block a user