|
|
@@ -54,13 +54,13 @@ final class KeychainTokenStore {
|
|
|
let status = SecItemCopyMatching(query as CFDictionary, &result)
|
|
|
if status == errSecItemNotFound { return nil }
|
|
|
guard status == errSecSuccess else {
|
|
|
- throw makeKeychainError(status: status, message: "Failed to read OAuth tokens from Keychain.")
|
|
|
+ throw makeKeychainError(status: status, message: "Failed to read OAuth tokens from Keychain.".localized)
|
|
|
}
|
|
|
guard let data = result as? Data else {
|
|
|
throw NSError(
|
|
|
domain: NSOSStatusErrorDomain,
|
|
|
code: Int(errSecDecode),
|
|
|
- userInfo: [NSLocalizedDescriptionKey: "Keychain returned an invalid token payload."]
|
|
|
+ userInfo: [NSLocalizedDescriptionKey: "Keychain returned an invalid token payload.".localized]
|
|
|
)
|
|
|
}
|
|
|
return try JSONDecoder().decode(GoogleOAuthTokens.self, from: data)
|
|
|
@@ -96,7 +96,7 @@ final class KeychainTokenStore {
|
|
|
let updateStatus = SecItemUpdate(baseQuery as CFDictionary, attributesToUpdate as CFDictionary)
|
|
|
if updateStatus == errSecSuccess { return }
|
|
|
if updateStatus != errSecItemNotFound {
|
|
|
- throw makeKeychainError(status: updateStatus, message: "Failed to update OAuth tokens in Keychain.")
|
|
|
+ throw makeKeychainError(status: updateStatus, message: "Failed to update OAuth tokens in Keychain.".localized)
|
|
|
}
|
|
|
|
|
|
var addQuery = baseQuery
|
|
|
@@ -104,14 +104,14 @@ final class KeychainTokenStore {
|
|
|
addQuery[kSecAttrAccessible as String] = kSecAttrAccessibleAfterFirstUnlock
|
|
|
let addStatus = SecItemAdd(addQuery as CFDictionary, nil)
|
|
|
guard addStatus == errSecSuccess else {
|
|
|
- throw makeKeychainError(status: addStatus, message: "Failed to save OAuth tokens to Keychain.")
|
|
|
+ throw makeKeychainError(status: addStatus, message: "Failed to save OAuth tokens to Keychain.".localized)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func deleteTokens() throws {
|
|
|
let status = SecItemDelete(baseQuery() as CFDictionary)
|
|
|
guard status == errSecSuccess || status == errSecItemNotFound else {
|
|
|
- throw makeKeychainError(status: status, message: "Failed to delete OAuth tokens from Keychain.")
|
|
|
+ throw makeKeychainError(status: status, message: "Failed to delete OAuth tokens from Keychain.".localized)
|
|
|
}
|
|
|
}
|
|
|
|