Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3351642
D10065.id33936.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D10065.id33936.diff
View Options
diff --git a/lib/flow-typed/web-crypto-common.js b/lib/flow-typed/web-crypto-common.js
--- a/lib/flow-typed/web-crypto-common.js
+++ b/lib/flow-typed/web-crypto-common.js
@@ -20,7 +20,16 @@
| 'wrapKey'
| 'unwrapKey';
-declare type CryptoKey = SubtleCrypto$JsonWebKey;
+declare type CryptoKey = {
+ +algorithm:
+ | SubtleCrypto$AesKeyGenParams
+ | SubtleCrypto$RsaHashedKeyGenParams
+ | SubtleCrypto$EcKeyGenParams
+ | SubtleCrypto$HmacKeyGenParams,
+ +extractable: boolean,
+ +type: CryptoKey$Type,
+ +usages: $ReadOnlyArray<CryptoKey$Usages>,
+};
type SubtleCrypto$KeyFormatWithoutJwk = 'pkcs8' | 'raw' | 'spki';
type SubtleCrypto$KeyFormat = 'jwk' | SubtleCrypto$KeyFormatWithoutJwk;
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<?CryptoKey> = (async () => {
- const persistedCryptoKey = await localforage.getItem<CryptoKey>(
- 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<CryptoKey>(
+ 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<SubtleCrypto$JsonWebKey>(
+ NOTIFICATIONS_OLM_DATA_ENCRYPTION_KEY,
+ );
+ if (!persistedCryptoKey) {
+ return null;
}
- return persistedCryptoKey;
+ return await importJWKKey(persistedCryptoKey);
})();
const [encryptedOlmData, encryptionKey, utilsData] = await Promise.all([
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 2:57 AM (18 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2573575
Default Alt Text
D10065.id33936.diff (2 KB)
Attached To
Mode
D10065: [Flow202] Fix rebasing mistakes in D9984
Attached
Detach File
Event Timeline
Log In to Comment