DEV: Fix build.

DEV: Fix build.

diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs
index 8b50791..ff0337b 100644
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs
+++ b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs
@@ -6,7 +6,7 @@
         {{#if isEncryptEnabled}}
           {{#if isEncryptActive}}
             <p>{{i18n 'encrypt.preferences.status_enabled'}}</p>
-            {{d-button icon="times" action=(action "deactivateEncrypt") label="encrypt.preferences.deactivate"}}
+            {{d-button icon="times" action=(action "deactivateEncrypt") label="encrypt.preferences.deactivate" id="deactivate"}}
             {{d-button icon="plus" action=(action "generatePaperKey" true) label="encrypt.generate_paperkey.title_device"}}
             {{d-button icon="ticket-alt" action=(action "generatePaperKey") label="encrypt.generate_paperkey.title"}}
             {{encrypt-preferences-dropdown export=(action "export")
diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6 b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
index 21776bd..52f181d 100644
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
+++ b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
@@ -10,7 +10,8 @@ import {
   canEnableEncrypt,
   ENCRYPT_ACTIVE,
   ENCRYPT_DISABLED,
-  getEncryptionStatus
+  getEncryptionStatus,
+  reload
 } from "discourse/plugins/discourse-encrypt/lib/discourse";
 import { unpackIdentity } from "discourse/plugins/discourse-encrypt/lib/pack";
 import {
@@ -102,7 +103,7 @@ export default {
         .then(identity => saveDbIdentity(identity))
         .then(() => {
           this.appEvents.trigger("encrypt:status-changed");
-          window.location.reload();
+          reload();
         })
         .finally(() => {
           this.setProperties({
@@ -126,7 +127,7 @@ export default {
         .then(() => {
           this.appEvents.trigger("encrypt:status-changed");
           this.set("passphrase", "");
-          window.location.reload();
+          reload();
         })
         .catch(() =>
           bootbox.alert(I18n.t("encrypt.preferences.passphrase_invalid"))
@@ -164,7 +165,7 @@ export default {
       deleteDb()
         .then(() => {
           this.appEvents.trigger("encrypt:status-changed");
-          window.location.reload();
+          reload();
         })
         .finally(() => this.set("inProgress", false));
     },
diff --git a/assets/javascripts/discourse/controllers/activate-encrypt.js.es6 b/assets/javascripts/discourse/controllers/activate-encrypt.js.es6
index 08265aa..05d2db9 100644
--- a/assets/javascripts/discourse/controllers/activate-encrypt.js.es6
+++ b/assets/javascripts/discourse/controllers/activate-encrypt.js.es6
@@ -1,3 +1,4 @@
+import { reload } from "discourse/plugins/discourse-encrypt/lib/discourse";
 import ModalFunctionality from "discourse/mixins/modal-functionality";
 import { activateEncrypt } from "discourse/plugins/discourse-encrypt/lib/discourse";
 
@@ -37,7 +38,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
           });
           this.set("models", null);
           this.send("closeModal");
-          window.location.reload();
+          reload();
         })
         .catch(() =>
           this.set("error", I18n.t("encrypt.preferences.passphrase_invalid"))
diff --git a/assets/javascripts/discourse/controllers/reset-keypair.js.es6 b/assets/javascripts/discourse/controllers/reset-keypair.js.es6
index ff413cd..e1784c6 100644
--- a/assets/javascripts/discourse/controllers/reset-keypair.js.es6
+++ b/assets/javascripts/discourse/controllers/reset-keypair.js.es6
@@ -1,6 +1,7 @@
 import { ajax } from "discourse/lib/ajax";
 import { popupAjaxError } from "discourse/lib/ajax-error";
 import ModalFunctionality from "discourse/mixins/modal-functionality";
+import { reload } from "discourse/plugins/discourse-encrypt/lib/discourse";
 
 export default Ember.Controller.extend(ModalFunctionality, {
   onShow() {
@@ -20,7 +21,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
           everything: this.everything
         }
       })
-        .then(() => window.location.reload())
+        .then(() => reload())
         .catch(popupAjaxError);
     }
   }
diff --git a/assets/javascripts/lib/discourse.js.es6 b/assets/javascripts/lib/discourse.js.es6
index f2c21bf..0d410ee 100644
--- a/assets/javascripts/lib/discourse.js.es6
+++ b/assets/javascripts/lib/discourse.js.es6
@@ -338,3 +338,7 @@ function upgradeIdentity(currentUser, passphrase, oldIdentity) {
 
   return oldIdentity;
 }
+
+export function reload() {
+  return window.location.reload();
+}
diff --git a/test/javascripts/acceptance/encrypt-test.js.es6 b/test/javascripts/acceptance/encrypt-test.js.es6
index d8a074f..7287df4 100644
--- a/test/javascripts/acceptance/encrypt-test.js.es6
+++ b/test/javascripts/acceptance/encrypt-test.js.es6
@@ -1,25 +1,20 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
-import {
-  exportPrivateKey,
-  exportPublicKey,
-  generateIdentity,
-  generatePassphraseKey,
-  generateSalt
-} from "discourse/plugins/discourse-encrypt/lib/discourse";
 import {
   deleteDb,
   loadDbIdentity,
   saveDbIdentity
 } from "discourse/plugins/discourse-encrypt/lib/database";
-import {
+import EncryptLibDiscourse, {
+  ENCRYPT_ACTIVE,
   ENCRYPT_DISABLED,
-  ENCRYPT_ENABLED,
-  ENCRYPT_ACTIVE
+  ENCRYPT_ENABLED
 } from "discourse/plugins/discourse-encrypt/lib/discourse";
-import * as DiscourseEncryptLib from "discourse/plugins/discourse-encrypt/lib/discourse";
+import {
+  exportIdentity,
+  generateIdentity
+} from "discourse/plugins/discourse-encrypt/lib/protocol";
 import { default as userFixtures } from "fixtures/user_fixtures";
-import { parsePostData } from "helpers/create-pretender";
+import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import selectKit from "helpers/select-kit-helper";
 
 /*
  * Checks if a string is not contained in a string.
@@ -58,22 +53,6 @@ const keys = {};
 let globalAssert;
 
 /**
- * Generates a key pair.
- *
- * @param passphrase
- *
- * @return Tuple consisting of public and private key, as CryptoKey and string.
- */
-async function getKeyPair(passsphrase) {
-  const salt = generateSalt();
-  const passphraseKey = await generatePassphraseKey(passsphrase, salt);
-  const [publicKey, privateKey] = await generateIdentity();
-  const publicStr = await exportPublicKey(publicKey);
-  const privateStr = await exportPrivateKey(privateKey, passphraseKey);
-  return [publicKey, privateKey, publicStr, privateStr, salt];
-}
-
-/**
  * Sets up encryption.
  */
 async function setEncryptionStatus(status) {
@@ -85,16 +64,18 @@ async function setEncryptionStatus(status) {
   } catch (e) {}
 
   // Generating a new key pair if enabling or creating a dummy one if disabling.
-  const keyPair =
-    status !== ENCRYPT_DISABLED
-      ? await getKeyPair(PASSPHRASE)
-      : [null, null, null, null, null];
+  let identity = {};
+  let exported = {};
+  let exportedPrivate;
+  if (status !== ENCRYPT_DISABLED) {
+    identity = await generateIdentity();
+    exported = await exportIdentity(identity, PASSPHRASE);
+    exportedPrivate = JSON.stringify({ passphrase: exported.private });
+  }
 
   // Overwriting server-side fields.
-  const [publicKey, privateKey, publicStr, privateStr, salt] = keyPair;
-  user.set("custom_fields.encrypt_public_key", publicStr);
-  user.set("custom_fields.encrypt_private_key", privateStr);
-  user.set("custom_fields.encrypt_salt", salt);
+  user.set("custom_fields.encrypt_public", exported.public);
+  user.set("custom_fields.encrypt_private", exportedPrivate);
 

[... diff too long, it was truncated ...]

GitHub sha: 4771df36