Skip to content
Snippets Groups Projects

Exchange 2016 support

Merged Alexey Lunin requested to merge exchange-2016-support into master
3 files
+ 70
48
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -43,6 +43,7 @@ const penpalMethods = require("../../temp/penpal-methods").default;
const WopiAPI = require("./wopiapi-iframe");
const CollaboraAPI = require("./collaboraapi-iframe");
const ViamAPI = require("../../temp/viamapi");
const asmCrypto = require('asmcrypto.js');
let identityColors = ["#994392", "#cb0767", "#e51d31", "#ec671b", "#fab610"];
@@ -411,7 +412,7 @@ function getCertificateForPassport(passportUUID, internal) {
let cryptoData = new CryptoData();
cryptoData.setPublicKey(keys["publicKeyPEM"]);
cryptoData.setPrivateKey(keys["privateKeyPEM"]);
let certificate = keys["certificatePEM"];
const certificate = keys["certificatePEM"];
//download("passportCertificateBeforeSigning.crt", "text/plain", certificate)
//cryptoData.setx509Certificate(keys["certificate"])
executeRestfulFunction(
@@ -423,15 +424,15 @@ function getCertificateForPassport(passportUUID, internal) {
passportUUID
).then(executeResult => {
if (executeResult.code === "200") {
let signedCertificate = atob(
const signedCertificate = atob(
executeResult.data["SignedCertificate"]
);
//download("passportCertificateAfterSigning.crt", "text/plain", signedCertificate)
let keyUUID = executeResult.data["CertificateUUID"];
let encodedChain = executeResult.data["Chain"];
const keyUUID = executeResult.data["CertificateUUID"];
const encodedChain = executeResult.data["Chain"];
//download("rootCertificate.crt", "text/plain", atob(encodedChain[0]))
let chain = [];
const chain = [];
for (let i = 0; i < encodedChain.length; i++) {
chain.push(atob(encodedChain[i]));
@@ -477,7 +478,7 @@ function getCertificateForPassport(passportUUID, internal) {
});
});
} else {
let copyOfCryptoData = JSON.parse(JSON.stringify(passport));
const copyOfCryptoData = JSON.parse(JSON.stringify(passport));
if (internal === false) {
copyOfCryptoData["privateKey"] = "";
@@ -518,16 +519,17 @@ const connection = Penpal.connectToParent({
window.WOPI_URL =
wopiUrl.charAt(wopiUrl.length - 1) === "/" ? wopiUrl : wopiUrl + "/";
window.COLLABORA_URL =
collaboraUrl.charAt(collaboraUrl.length - 1) === "/"
? collaboraUrl
: collaboraUrl + "/";
collaboraUrl.charAt(collaboraUrl.length - 1) === "/" ?
collaboraUrl :
collaboraUrl + "/";
},
...penpalMethods,
createIdentity(pinCode) {
console.log(asmCrypto.Sha1());
return new Penpal.Promise(result => {
createPassportCertificate(makeid()).then(function(keys) {
let newIdentity = new Identity();
let cryptoData = new CryptoData();
createPassportCertificate(makeid()).then(function (keys) {
const newIdentity = new Identity();
const cryptoData = new CryptoData();
cryptoData.setPublicKey(keys["publicKeyPEM"]);
cryptoData.setPrivateKey(keys["privateKeyPEM"]);
cryptoData.setx509Certificate(keys["certificatePEM"]);
@@ -564,8 +566,10 @@ const connection = Penpal.connectToParent({
},
listIdentities() {
return new Penpal.Promise(result => {
let identities = listIdentitiesFromLocalStorage();
result({ data: identities, code: "200", status: "Identities listed" });
const identities = listIdentitiesFromLocalStorage();
result({ data: identities,
code: "200",
status: "Identities listed" });
});
},
loadIdentity(identityKey, pinCode) {
@@ -612,7 +616,9 @@ const connection = Penpal.connectToParent({
"profiles/" + identityKey
);
if (serializedProfile === null || serializedProfile === "") {
result({ data: "", code: "400", status: "Profile is empty" });
result({ data: "",
code: "400",
status: "Profile is empty" });
} else {
result({
data: JSON.parse(serializedProfile),
@@ -819,7 +825,7 @@ const connection = Penpal.connectToParent({
});
}
let success = extendPinCodeTtl(authenticationPublicKey);
const success = extendPinCodeTtl(authenticationPublicKey);
if (success === false) {
result({
@@ -836,9 +842,9 @@ const connection = Penpal.connectToParent({
null
).then(executeResult => {
if (executeResult.code === "200") {
let actionID = executeResult.data["ActionID"];
let QrCode = executeResult.data["QrCode"];
QRCode.toDataURL(actionID + "," + QrCode, function(err, url) {
const actionID = executeResult.data["ActionID"];
const QrCode = executeResult.data["QrCode"];
QRCode.toDataURL(actionID + "," + QrCode, function (err, url) {
executeResult.data["image"] = url;
result(executeResult);
});
@@ -868,7 +874,7 @@ const connection = Penpal.connectToParent({
});
}
let success = extendPinCodeTtl(authenticationPublicKey);
const success = extendPinCodeTtl(authenticationPublicKey);
if (success === false) {
result({
@@ -950,13 +956,17 @@ const connection = Penpal.connectToParent({
"authenticatedIdentity"
);
if (authenticationPublicKey === null) {
return { data: "", code: "400", status: "Identity not loaded" };
return { data: "",
code: "400",
status: "Identity not loaded" };
}
if (window.loadedIdentities[authenticationPublicKey] === null) {
return { data: "", code: "400", status: "Identity not loaded" };
return { data: "",
code: "400",
status: "Identity not loaded" };
}
let success = extendPinCodeTtl(authenticationPublicKey);
const success = extendPinCodeTtl(authenticationPublicKey);
if (success === false) {
result({
@@ -967,7 +977,9 @@ const connection = Penpal.connectToParent({
}
if (localStorage.getItem("uuid") === null) {
result({ data: "", code: "400", status: "Not logged in UUID" });
result({ data: "",
code: "400",
status: "Not logged in UUID" });
}
result({
data: localStorage.getItem("uuid"),
@@ -982,13 +994,17 @@ const connection = Penpal.connectToParent({
"authenticatedIdentity"
);
if (authenticationPublicKey === null) {
return { data: "", code: "400", status: "Identity not loaded" };
return { data: "",
code: "400",
status: "Identity not loaded" };
}
if (window.loadedIdentities[authenticationPublicKey] === null) {
return { data: "", code: "400", status: "Identity not loaded" };
return { data: "",
code: "400",
status: "Identity not loaded" };
}
let success = extendPinCodeTtl(authenticationPublicKey);
const success = extendPinCodeTtl(authenticationPublicKey);
if (success === false) {
result({
@@ -1011,13 +1027,17 @@ const connection = Penpal.connectToParent({
"authenticatedIdentity"
);
if (authenticationPublicKey === null) {
return { data: "", code: "400", status: "Identity not loaded" };
return { data: "",
code: "400",
status: "Identity not loaded" };
}
if (window.loadedIdentities[authenticationPublicKey] === null) {
return { data: "", code: "400", status: "Identity not loaded" };
return { data: "",
code: "400",
status: "Identity not loaded" };
}
let success = extendPinCodeTtl(authenticationPublicKey);
const success = extendPinCodeTtl(authenticationPublicKey);
if (success === false) {
result({
@@ -1030,23 +1050,23 @@ const connection = Penpal.connectToParent({
getCertificateForPassport(passportUUID, true).then(
certificateResult => {
if (certificateResult.code === "200") {
let passportCertificate =
const passportCertificate =
certificateResult.data["x509Certificate"];
let passportPrivateKey = certificateResult.data["privateKey"];
let passportChain = certificateResult.data["chain"];
const passportPrivateKey = certificateResult.data["privateKey"];
const passportChain = certificateResult.data["chain"];
createOneTimePassportCertificate(
makeid() + "-" + passportUUID,
emailArg,
passportPrivateKey,
passportCertificate
).then(function(keys) {
let publicKeyOneTime = keys["publicKeyPEM"];
let privateKeyOneTime = keys["privateKeyPEM"];
let certificateOneTime = keys["certificatePEM"];
).then(function (keys) {
const publicKeyOneTime = keys["publicKeyPEM"];
const privateKeyOneTime = keys["privateKeyPEM"];
const certificateOneTime = keys["certificatePEM"];
passportChain.push(passportCertificate);
let oneTimeCryptoData = new CryptoData();
const oneTimeCryptoData = new CryptoData();
oneTimeCryptoData.setx509Certificate(certificateOneTime);
oneTimeCryptoData.setPrivateKey(privateKeyOneTime);
oneTimeCryptoData.setPublicKey(publicKeyOneTime);
@@ -1469,7 +1489,10 @@ const connection = Penpal.connectToParent({
}
let qrCodeImageData;
let qrCodeCoordinates = {fromL: -1, fromR:-1, toL: -1, toR: -1};
let qrCodeCoordinates = {fromL: -1,
fromR: -1,
toL: -1,
toR: -1};
if (vCardImageClaimValue && "state" in vCardImageClaimValue && vCardImageClaimValue.state === "disabled") {
vCardImageData = new ImageData({
@@ -1601,7 +1624,7 @@ const connection = Penpal.connectToParent({
const signedVCardImageData = new ImageData(signVCardResponse.data);
return encodeResponse("200", {
image: signedVCardImageData,
messageUUID: messageUUID
messageUUID
}, "vCard signed");
},
// mime - String - the MIME of the email message
@@ -1753,7 +1776,7 @@ const connection = Penpal.connectToParent({
});
}
let success = extendPinCodeTtl(authenticationPublicKey);
const success = extendPinCodeTtl(authenticationPublicKey);
if (success === false) {
result({
@@ -2092,7 +2115,7 @@ connection.promise.then(parent => {
let previousLocalStorageToken;
let previousLocalStorageIdentity;
setInterval(async function() {
setInterval(async function () {
if (window.currentlyAuthenticatedIdentity) {
const { authentication } = window.currentlyAuthenticatedIdentity;
const pinCode = getPincode(authentication.publicKey);
@@ -2225,7 +2248,7 @@ connection.promise.then(parent => {
const eventCopy = JSON.parse(JSON.stringify(event));
QRCode.toDataURL(actionID + "," + QrCode, function(err, url) {
QRCode.toDataURL(actionID + "," + QrCode, function (err, url) {
eventCopy["payloads"].push(url);
parent.onEvent(eventCopy);
});
@@ -2298,7 +2321,7 @@ connection.promise.then(parent => {
const eventCopy = JSON.parse(JSON.stringify(event));
QRCode.toDataURL(actionID + "," + QrCode, function(err, url) {
QRCode.toDataURL(actionID + "," + QrCode, function (err, url) {
eventCopy["payloads"].push(url);
parent.onEvent(eventCopy);
});
@@ -2346,7 +2369,7 @@ connection.promise.then(parent => {
const eventCopy = JSON.parse(JSON.stringify(event));
QRCode.toDataURL(actionID + "," + QrCode, function(err, url) {
QRCode.toDataURL(actionID + "," + QrCode, function (err, url) {
eventCopy["payloads"].push(url);
parent.onEvent(eventCopy);
});
Loading