Newer
Older
import {
createDeviceHash,
destroyIdentityFromLocalStorage,
encodeResponse,
listIdentitiesFromLocalStorage, makeid
} from '../utilities/appUtility';
import {
createOneTimePassportCertificate,
createPassportCertificate,
decryptMessage,
encryptMessage, signEmail
} from '../utilities/signingUtilities';
const QRCode = require('qrcode');
const Penpal = require('penpal').default;
Markin Igor
committed
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) {
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) {
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() {
var colorIndex = localStorage.getItem("colorIndex");
return color
}
function setKeyForUUID(uuid, key) {
var storedIdentityForUuid = localStorage.getItem("keyperuuid/" + uuid);
if(storedIdentityForUuid !== key && storedIdentityForUuid != null && storedIdentityForUuid !== "") {
destroyIdentityFromLocalStorage(storedIdentityForUuid)
}
localStorage.setItem("keyperuuid/" + uuid, key)
}
function getColorForIdentity(key) {
var storedColor = localStorage.getItem("colors/" + key);
localStorage.setItem("colors/" + key, storedColor)
}
return storedColor
}
function setIdentityInLocalStorage(identityToStore, extendKey = true) {
var pinCode = identityToStore.pinCode;
const serializedIdentity = JSON.stringify(identityToStore);
const key = identityToStore.authentication.publicKey;
return null;
}
return encryptMessage(serializedIdentity, pinCode, "identity").then((encryptedIdentity) => {
if(extendKey === true) {
success = extendPinCodeTtl(key, pinCode)
}
localStorage.setItem(key, encryptedIdentity);
let serializedIdentitiesList = localStorage.getItem("identities");
let identities = JSON.parse(serializedIdentitiesList);
identities[key] = true;
localStorage.setItem("identities", JSON.stringify(identities))
} else {
Loading
Loading full blame...