diff --git a/web/account/account-hooks.js b/web/account/account-hooks.js --- a/web/account/account-hooks.js +++ b/web/account/account-hooks.js @@ -229,11 +229,13 @@ ); const persistEncryptionKeyPromise = (async () => { - let cryptoKeyPersistentForm = encryptionKey; + let cryptoKeyPersistentForm; if (isDesktopSafari) { // Safari doesn't support structured clone algorithm in service // worker context so we have to store CryptoKey as JSON cryptoKeyPersistentForm = await exportKeyToJWK(encryptionKey); + } else { + cryptoKeyPersistentForm = encryptionKey; } await localforage.setItem( diff --git a/web/push-notif/notif-crypto-utils.js b/web/push-notif/notif-crypto-utils.js --- a/web/push-notif/notif-crypto-utils.js +++ b/web/push-notif/notif-crypto-utils.js @@ -52,15 +52,21 @@ const { id, encryptedPayload } = encryptedNotification; const retrieveEncryptionKeyPromise: Promise = (async () => { - const persistedCryptoKey = await localforage.getItem( - NOTIFICATIONS_OLM_DATA_ENCRYPTION_KEY, - ); - if (isDesktopSafari && persistedCryptoKey) { - // Safari doesn't support structured clone algorithm in service - // worker context so we have to store CryptoKey as JSON - return await importJWKKey(persistedCryptoKey); + if (!isDesktopSafari) { + return await localforage.getItem( + NOTIFICATIONS_OLM_DATA_ENCRYPTION_KEY, + ); + } + // Safari doesn't support structured clone algorithm in service + // worker context so we have to store CryptoKey as JSON + const persistedCryptoKey = + await localforage.getItem( + NOTIFICATIONS_OLM_DATA_ENCRYPTION_KEY, + ); + if (!persistedCryptoKey) { + return null; } - return persistedCryptoKey; + return await importJWKKey(persistedCryptoKey); })(); const [encryptedOlmData, encryptionKey, utilsData] = await Promise.all([