Compare commits

..

3 Commits

Author SHA1 Message Date
1947b326a4 Scheudle timer on mian 2024-01-20 19:47:55 -08:00
3df4bcef3c . 2024-01-20 19:08:20 -08:00
18ba03bf03 . 2024-01-20 19:07:00 -08:00
6 changed files with 24 additions and 272 deletions

View File

@ -44,7 +44,7 @@ let package = Package(
.target(
name: "SecureEnclaveSecretKit",
dependencies: ["SecretKit"],
swiftSettings: [.enableExperimentalFeature("StrictConcurrency"), .unsafeFlags(["-warnings-as-errors"])]
swiftSettings: [.unsafeFlags(["-warnings-as-errors"])]
),
.target(
name: "SmartCardSecretKit",

View File

@ -17,7 +17,7 @@ public protocol Secret: Identifiable, Hashable {
}
/// The type of algorithm the Secret uses. Currently, only elliptic curve algorithms are supported.
public enum Algorithm: Hashable {
public enum Algorithm: Hashable, Sendable {
case ellipticCurve
case rsa

View File

@ -5,7 +5,7 @@ import SecretKit
extension SecureEnclave {
/// An implementation of Secret backed by the Secure Enclave.
public struct Secret: SecretKit.Secret {
public struct Secret: SecretKit.Secret, Sendable {
public let id: Data
public let name: String

View File

@ -180,7 +180,7 @@ extension SecureEnclave {
public func persistAuthentication(secret: Secret, forDuration duration: TimeInterval) throws {
let newContext = LAContext()
newContext.touchIDAuthenticationAllowableReuseDuration = duration
newContext.touchIDAuthenticationAllowableReuseDuration = max(duration, LATouchIDAuthenticationMaximumAllowableReuseDuration)
newContext.localizedCancelTitle = String(localized: "auth_context_request_deny_button")
let formatter = DateComponentsFormatter()
@ -196,6 +196,23 @@ extension SecureEnclave {
guard success else { return }
let context = PersistentAuthenticationContext(secret: secret, context: newContext, duration: duration)
self?.persistedAuthenticationContexts[secret] = context
// Contexts will expire within LATouchIDAuthenticationMaximumAllowableReuseDuration unless we periodically refresh them
if duration > LATouchIDAuthenticationMaximumAllowableReuseDuration {
DispatchQueue.main.async {
Timer.scheduledTimer(withTimeInterval: LATouchIDAuthenticationMaximumAllowableReuseDuration - 10, repeats: true) { [weak self] timer in
print("Refreshing context")
guard let refreshContext = self?.persistedAuthenticationContexts[secret] else { return }
guard refreshContext.valid else {
timer.invalidate()
return
}
refreshContext.context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Refresh") { success, _ in
guard success else { return }
print("Refreshed")
}
}
}
}
}
}

View File

@ -433,7 +433,6 @@
fr,
de,
"pt-BR",
fi,
);
mainGroup = 50617D7623FCE48D0099B055;
productRefGroup = 50617D8023FCE48E0099B055 /* Products */;

View File

@ -15,12 +15,6 @@
"value" : "Agent Is Not Running"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Agentti ei ole käynnissä"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -61,28 +55,22 @@
"value" : "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.**"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "SecretAgent on taustaprosessi joka allekirjoittaa pyyntöjä, joten Secretiveä ei tarvitse pitää käynnissä koko aikaa.**Voit sulkea Secretiven, ja kaikki toimii yhä.**"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "SecretAgent est un processus qui s'exécute en arrière-plan pour signer les demandes, de sorte que vous n'ayez pas besoin de garder Secretive ouvert en permanence.\n\n**Vous pouvez fermer Secretive, et tout continuera à fonctionner.**"
"value" : "SecretAgent est un processus qui s'exécute en arrière-plan pour signer les demandes, de sorte que vous n'ayez pas besoin de garder Secretive ouvert en permanence.\n\n**Vous pouvez fermer Secretive, et tout continuera à fonctionner."
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "SecretAgent è un processo che viene eseguito in background per firmare le richieste, così che non devi tenere aperto Secretive tutto il tempo.\n\n**Puoi chiudere Secretive, e continuerà a funzionare.**"
"value" : "SecretAgent è un processo che viene eseguito in background per firmare le richieste, così che non devi tenere aperto Secretive tutto il tempo.\\n\\n**Puoi chiudere Secretive, e continuerà a funzionare.**"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"value" : "SecretAgent é um processo que roda em background para assinar requisições para que você não precise manter o Secretive aberto a todo momento.\n\n**Você pode fechar o Secretive e tudo continuará funcionando.**"
"value" : "SecretAgent é um processo que roda em background para assinar requisições para que você não precise manter o Secretive aberto a todo momento.\n\n**Você pode fechar o Secretive e tudo continuará funcionando."
}
},
"zh-Hans" : {
@ -107,12 +95,6 @@
"value" : "Secret Agent is Running"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "SecretAgent on käynnissä"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -153,12 +135,6 @@
"value" : "Agent is Running"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Agentti on käynnissä"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -199,12 +175,6 @@
"value" : "Setup Secretive"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Asenna Secretive"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -245,12 +215,6 @@
"value" : "Help"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Apua"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -291,12 +255,6 @@
"value" : "New Secret"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Uusi salaisuus"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -337,12 +295,6 @@
"value" : "Setup Secretive"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Asenna Secretive"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -383,12 +335,6 @@
"value" : "Secretive needs to be in your Applications folder to work properly. Please move it and relaunch."
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secretiven tulee olla Ohjelmat-kansiossa toimiakseen oikein. Ole hyvä ja käynnistä se uudelleen siirrettyäsi sen."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -429,12 +375,6 @@
"value" : "Secretive Is Not in Applications Folder"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secretive ei ole Ohjelmat-kansiossa"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -477,12 +417,6 @@
"value" : "unlock secret \"%1$@\" for %2$@"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "avaa salaisuuden \"%1$@\" lukitus ajaksi %2$@"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -525,12 +459,6 @@
"value" : "unlock secret \"%1$@\""
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "avaa salaisuuden \"%1$@\" lukitus"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -573,12 +501,6 @@
"value" : "decrypt data using secret \"%1$@\""
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "pura salaus käyttäen salaisuutta \"%1$@\""
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -621,12 +543,6 @@
"value" : "Deny"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Kiellä"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -669,12 +585,6 @@
"value" : "encrypt data using secret \"%1$@\""
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "salaa käyttäen salaisuutta \"%1$@\""
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -717,12 +627,6 @@
"value" : "sign a request from \"%1$@\" using secret \"%2$@\""
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "allekirjoita pyyntö lähteestä \"%1$@\" käyttäen salaisuutta \"%2$@\""
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -765,12 +669,6 @@
"value" : "verify a signature using secret \"%1$@\""
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "varmista allekirjoitus käyttäen salaisuutta \"%1$@\""
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -811,12 +709,6 @@
"value" : "Click to Copy"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Klikkaa kopioidaksesi"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -857,12 +749,6 @@
"value" : "Copied"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Kopioitu"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -903,12 +789,6 @@
"value" : "Cancel"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Peru"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -949,12 +829,6 @@
"value" : "Create"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Luo"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -995,12 +869,6 @@
"value" : "Name:"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Nimi:"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1041,12 +909,6 @@
"value" : "Shhhhh"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Hysssss"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1087,12 +949,6 @@
"value" : "No authentication is required while your Mac is unlocked, but you will be notified when a secret is used."
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Todennusta ei vaadita Macisi ollessa lukitsematta, mutta saat ilmoituksen kun salaisuutta käytetään."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1133,12 +989,6 @@
"value" : "Notify"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ilmoita"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1179,12 +1029,6 @@
"value" : "You will be required to authenticate using Touch ID, Apple Watch, or password before each use."
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Touch ID-, Apple Watch- tai salasanatodennus vaaditaan joka käytöllä."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1225,12 +1069,6 @@
"value" : "Require Authentication"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Vaadi todennus"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1271,12 +1109,6 @@
"value" : "Create a New Secret"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Luo uusi salaisuus"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1317,12 +1149,6 @@
"value" : "Don't Delete"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Älä poista"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1363,12 +1189,6 @@
"value" : "Confirm Name:"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Vahvista nimi:"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1409,12 +1229,6 @@
"value" : "Delete"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Poista"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1455,12 +1269,6 @@
"value" : "If you delete %1$@, you will not be able to recover it. Type \"%2$@\" to confirm."
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Jos poistat kohteen %1$@, sitä ei pysty palauttamaan. Kirjoita \"%2$@\" vahvistaaksesi poiston."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1501,12 +1309,6 @@
"value" : "Delete %1$@?"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Poista %1$@?"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1547,12 +1349,6 @@
"value" : "Create a new one by clicking here."
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Luo uusi klikkaamalla tästä."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1593,12 +1389,6 @@
"value" : "No Secrets"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ei salaisuuksia"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1639,12 +1429,6 @@
"value" : "No Secrets"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ei salaisuuksia"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1685,12 +1469,6 @@
"value" : "Use your Smart Card's management tool to create a secret."
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Käytä älykorttisi hallintatyökalua luodaksesi salaisuuden."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1731,12 +1509,6 @@
"value" : "Secretive supports EC256, EC384, RSA1024, and RSA2048 keys."
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secretive tukee EC256-, EC384-, RSA1024- ja RSA2048-avaimia."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1777,12 +1549,6 @@
"value" : "No Secrets"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ei salaisuuksia"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1823,12 +1589,6 @@
"value" : "Your Mac doesn't have a Secure Enclave, and there's not a compatible Smart Card inserted."
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Macissasi ei ole Secure Enclavea, eikä tuettu älykortti ole syötettynä."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1869,12 +1629,6 @@
"value" : "No Secure Storage Available"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Turvasäilö ei saatavilla"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1915,12 +1669,6 @@
"value" : "If you're looking to add one to your Mac, the YubiKey 5 Series are great."
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Jos haluat lisätä Maciisi sellaisen, YubiKey 5 -sarja on mainio."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -1963,12 +1711,6 @@
"value" : "Leave Unlocked"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Jätä lukitsematta"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
@ -2011,12 +1753,6 @@
"value" : "Do Not Unlock"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Älä avaa lukitusta"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",