From 11988888b5effacf6e6fde5c41c57eca1bdbf63c Mon Sep 17 00:00:00 2001
From: Markin Igor <markin.io210@gmail.com>
Date: Wed, 20 Feb 2019 16:35:53 +0300
Subject: [PATCH] Move Identity and CryptoData declarations into separate
 files.

---
 javascript/src/CryptoData.js            |  58 +++++++++++++
 javascript/src/Identity.js              |  51 +++++++++++
 javascript/src/iframe/viamapi-iframe.js | 111 +-----------------------
 3 files changed, 111 insertions(+), 109 deletions(-)
 create mode 100644 javascript/src/CryptoData.js
 create mode 100644 javascript/src/Identity.js

diff --git a/javascript/src/CryptoData.js b/javascript/src/CryptoData.js
new file mode 100644
index 0000000..9261a2d
--- /dev/null
+++ b/javascript/src/CryptoData.js
@@ -0,0 +1,58 @@
+function CryptoData() {}
+
+CryptoData.prototype.set = function(obj) {
+  for(var member in obj) {
+    this[member] = JSON.parse(JSON.stringify(obj[member]))
+  }
+};
+
+CryptoData.prototype.serialize = function() {
+  return JSON.stringify(this)
+};
+
+CryptoData.prototype.deserialize = function(serialized) {
+  var obj = JSON.parse(serialized);
+  this.set(obj)
+};
+
+CryptoData.prototype.setPublicKey = function(publicKey) {
+  this["publicKey"] = publicKey
+};
+
+CryptoData.prototype.getPublicKey = function() {
+  return this["publicKey"]
+};
+
+CryptoData.prototype.setPrivateKey = function(privateKey) {
+  this["privateKey"] = privateKey
+};
+
+CryptoData.prototype.getPrivateKey = function() {
+  return this["privateKey"]
+};
+
+CryptoData.prototype.setx509Certificate = function(x509Certificate) {
+  this["x509Certificate"] = x509Certificate
+};
+
+CryptoData.prototype.getx509Certificate = function() {
+  return this["x509Certificate"]
+};
+
+CryptoData.prototype.setKeyUUID = function(keyUUID) {
+  this["keyUUID"] = keyUUID
+};
+
+CryptoData.prototype.getKeyUUID = function() {
+  return this["keyUUID"]
+};
+
+CryptoData.prototype.setChain = function(chain) {
+  this["chain"] = chain
+};
+
+CryptoData.prototype.getChain = function() {
+  return this["chain"]
+};
+
+export default CryptoData;
\ No newline at end of file
diff --git a/javascript/src/Identity.js b/javascript/src/Identity.js
new file mode 100644
index 0000000..43a52ea
--- /dev/null
+++ b/javascript/src/Identity.js
@@ -0,0 +1,51 @@
+function Identity() {
+}
+
+Identity.prototype.set = function(obj) {
+  for(var member in obj) {
+    this[member] = JSON.parse(JSON.stringify(obj[member]))
+  }
+};
+
+Identity.prototype.serialize = function() {
+  return JSON.stringify(this)
+};
+
+Identity.prototype.deserialize = function(serialized) {
+  var obj = JSON.parse(serialized);
+  this.set(obj)
+};
+
+Identity.prototype.setAuthentication = function(cryptoData) {
+  this["authentication"] = cryptoData
+};
+
+Identity.prototype.getAuthentication = function() {
+  return this["authentication"]
+};
+
+Identity.prototype.setPinCode = function(pinCode) {
+  this["pinCode"] = pinCode
+};
+
+Identity.prototype.getPinCode = function() {
+  return this["pinCode"]
+};
+
+Identity.prototype.setPassport = function(passportUUID, cryptoData) {
+  if(this["passports"] === undefined || this["passports"] === null) {
+    this["passports"] = {}
+  }
+
+  this["passports"][passportUUID] = cryptoData
+};
+
+Identity.prototype.getPassport = function(passportUUID) {
+  if(this["passports"] === undefined || this["passports"] === null) {
+    this["passports"] = {}
+  }
+
+  return this["passports"][passportUUID]
+};
+
+export default Identity;
\ No newline at end of file
diff --git a/javascript/src/iframe/viamapi-iframe.js b/javascript/src/iframe/viamapi-iframe.js
index 199a75e..f93f0e5 100644
--- a/javascript/src/iframe/viamapi-iframe.js
+++ b/javascript/src/iframe/viamapi-iframe.js
@@ -11,6 +11,8 @@ import {
   decryptMessage,
   encryptMessage, signEmail
 } from '../utilities/signingUtilities';
+import CryptoData from '../CryptoData';
+import Identity from '../Identity';
 
 const QRCode = require('qrcode');
 const Penpal = require('penpal').default;
@@ -19,115 +21,6 @@ const penpalMethods = require('../../temp/penpal-methods').default;
 const WopiAPI = require('./wopiapi-iframe');
 const ViamAPI = require('../../temp/viamapi');
 
-
-function CryptoData() {
-}
-
-CryptoData.prototype.set = function(obj) {
-  for(var member in obj) {
-    this[member] = JSON.parse(JSON.stringify(obj[member]))
-  }
-};
-
-CryptoData.prototype.serialize = function() {
-  return JSON.stringify(this)
-};
-
-CryptoData.prototype.deserialize = function(serialized) {
-  var obj = JSON.parse(serialized);
-  this.set(obj)
-};
-
-CryptoData.prototype.setPublicKey = function(publicKey) {
-  this["publicKey"] = publicKey
-};
-
-CryptoData.prototype.getPublicKey = function() {
-  return this["publicKey"]
-};
-
-CryptoData.prototype.setPrivateKey = function(privateKey) {
-  this["privateKey"] = privateKey
-};
-
-CryptoData.prototype.getPrivateKey = function() {
-  return this["privateKey"]
-};
-
-CryptoData.prototype.setx509Certificate = function(x509Certificate) {
-  this["x509Certificate"] = x509Certificate
-};
-
-CryptoData.prototype.getx509Certificate = function() {
-  return this["x509Certificate"]
-};
-
-CryptoData.prototype.setKeyUUID = function(keyUUID) {
-  this["keyUUID"] = keyUUID
-};
-
-CryptoData.prototype.getKeyUUID = function() {
-  return this["keyUUID"]
-};
-
-CryptoData.prototype.setChain = function(chain) {
-  this["chain"] = chain
-};
-
-CryptoData.prototype.getChain = function() {
-  return this["chain"]
-};
-
-function Identity() {
-}
-
-Identity.prototype.set = function(obj) {
-  for(var member in obj) {
-    this[member] = JSON.parse(JSON.stringify(obj[member]))
-  }
-};
-
-Identity.prototype.serialize = function() {
-  return JSON.stringify(this)
-};
-
-Identity.prototype.deserialize = function(serialized) {
-  var obj = JSON.parse(serialized);
-  this.set(obj)
-};
-
-Identity.prototype.setAuthentication = function(cryptoData) {
-  this["authentication"] = cryptoData
-};
-
-Identity.prototype.getAuthentication = function() {
-  return this["authentication"]
-};
-
-Identity.prototype.setPinCode = function(pinCode) {
-  this["pinCode"] = pinCode
-};
-
-Identity.prototype.getPinCode = function() {
-  return this["pinCode"]
-};
-
-Identity.prototype.setPassport = function(passportUUID, cryptoData) {
-  if(this["passports"] === undefined || this["passports"] === null) {
-    this["passports"] = {}
-  }
-
-  this["passports"][passportUUID] = cryptoData
-};
-
-Identity.prototype.getPassport = function(passportUUID) {
-  if(this["passports"] === undefined || this["passports"] === null) {
-    this["passports"] = {}
-  }
-
-  return this["passports"][passportUUID]
-};
-
 var identityColors = ["#994392", "#cb0767", "#e51d31", "#ec671b", "#fab610"];
 
 function getNextColor() {
-- 
GitLab