From 874ea309ac0492d0c611d497fb7dc69b450eb7b2 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sun, 8 Jan 2023 11:22:44 +0100 Subject: [PATCH] Fix keys --- Packages/Env/Sources/Env/PushNotifications.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Packages/Env/Sources/Env/PushNotifications.swift b/Packages/Env/Sources/Env/PushNotifications.swift index ce9af371..34a2a67d 100644 --- a/Packages/Env/Sources/Env/PushNotifications.swift +++ b/Packages/Env/Sources/Env/PushNotifications.swift @@ -133,12 +133,16 @@ public class PushNotifications: ObservableObject { return try P256.KeyAgreement.PrivateKey(rawRepresentation: data) } catch { let key = P256.KeyAgreement.PrivateKey() - keychain.set(key.rawRepresentation.base64EncodedString(), forKey: Constants.keychainPrivateKey) + keychain.set(key.rawRepresentation.base64EncodedString(), + forKey: Constants.keychainPrivateKey, + withAccess: .accessibleAfterFirstUnlock) return key } } else { let key = P256.KeyAgreement.PrivateKey() - keychain.set(key.rawRepresentation.base64EncodedString(), forKey: Constants.keychainPrivateKey) + keychain.set(key.rawRepresentation.base64EncodedString(), + forKey: Constants.keychainPrivateKey, + withAccess: .accessibleAfterFirstUnlock) return key } } @@ -149,7 +153,9 @@ public class PushNotifications: ObservableObject { return data } else { let key = Self.makeRandomeNotificationsAuthKey() - keychain.set(key.base64EncodedString(), forKey: Constants.keychainAuthKey) + keychain.set(key.base64EncodedString(), + forKey: Constants.keychainAuthKey, + withAccess: .accessibleAfterFirstUnlock) return key } }