diff --git a/javascript/src/CryptoData.js b/javascript/src/CryptoData.js new file mode 100644 index 0000000000000000000000000000000000000000..9261a2d92c9f12334b2388a9224f90b2e2653b19 --- /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 0000000000000000000000000000000000000000..43a52eafc057f67cf2feb961db87e5392f015f4d --- /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 199a75ea0f0f04745b12ab38e79aca729bb7462a..f93f0e5e74ddcb781d479d0b6d6fbb9855a24aa8 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() {