FIX: Fix key saving on Safari.

FIX: Fix key saving on Safari.

Follow-up to dc937dbf.

From 937c9a441b9f936e6fa43e3a7e8f938e161561e7 Mon Sep 17 00:00:00 2001
From: Dan Ungureanu <dan@ungureanu.me>
Date: Sun, 9 Dec 2018 13:22:34 +0200
Subject: [PATCH] FIX: Fix key saving on Safari.

Follow-up to dc937dbf.

diff --git a/assets/javascripts/lib/keys_db.js.es6 b/assets/javascripts/lib/keys_db.js.es6
index 389e121..884901a 100644
--- a/assets/javascripts/lib/keys_db.js.es6
+++ b/assets/javascripts/lib/keys_db.js.es6
@@ -35,7 +35,7 @@ function exportKey(key) {
  *
  * @return CryptoKey
  */
-function importKey(key, op) {
+function importKey(key, ops) {
   return window.crypto.subtle.importKey(
     "jwk",
     JSON.parse(key),
@@ -44,7 +44,7 @@ function importKey(key, op) {
       hash: { name: "SHA-256" }
     },
     true,
-    [op]
+    ops
   );
 }
 
@@ -140,8 +140,8 @@ export function loadKeyPairFromIndexedDb() {
 
     if (isSafari) {
       return Ember.RSVP.Promise.all([
-        importKey(keyPair.publicKey, "encrypt"),
-        importKey(keyPair.privateKey, "decrypt")
+        importKey(keyPair.publicKey, ["encrypt", "wrapKey"]),
+        importKey(keyPair.privateKey, ["decrypt", "unwrapKey"])
       ]);
     }

GitHub

1 Like