From 03c54ea31a301f194ab6068f928337c443d9a0be Mon Sep 17 00:00:00 2001 From: Sasha Ilieva <sasha.ilieva@vereign.com> Date: Thu, 20 Feb 2020 12:07:21 +0200 Subject: [PATCH] Console log response --- javascript/src/iframe/viamapi-iframe.js | 74 ++++++++++--------------- 1 file changed, 29 insertions(+), 45 deletions(-) diff --git a/javascript/src/iframe/viamapi-iframe.js b/javascript/src/iframe/viamapi-iframe.js index f82a7e7..cc84af6 100644 --- a/javascript/src/iframe/viamapi-iframe.js +++ b/javascript/src/iframe/viamapi-iframe.js @@ -1,4 +1,4 @@ -import '../lib/textencoder.polyfill'; +import "../lib/textencoder.polyfill"; import { parseSMIME, prepareVCardParts } from "../utilities/emailUtilities"; import { stringToUtf8ByteArray, @@ -308,7 +308,7 @@ async function executeRestfulFunction(type, that, fn, config, ...args) { const identity = currentlyAuthenticatedIdentity || currentlyLoadedIdentity; const { code, status } = response.data; - + console.log({ response }); const deviceRevoked = type === "private" && code === "401" && status === STATUS_DEVICE_REVOKED; if (deviceRevoked) { @@ -339,13 +339,17 @@ async function executeRestfulFunction(type, that, fn, config, ...args) { identity && code === "400" && status === "Bad session"; - if (!badSession) { return response.data; } + if (!badSession) { + return response.data; + } const loginResponse = await viamApi.identityLogin( null, "previousaddeddevice" ); - if (loginResponse.data.code !== "200") { return loginResponse.data; } + if (loginResponse.data.code !== "200") { + return loginResponse.data; + } const uuid = loginResponse.data.data["Uuid"]; const token = loginResponse.data.data["Session"]; @@ -417,15 +421,13 @@ function loadIdentityInternal(identityKey, pinCode) { function getCertificateForPassport(passportUUID, internal) { return new Penpal.Promise(certificateResult => { if (window.currentlyAuthenticatedIdentity === null) { - return { data: "", - code: "400", - status: "Identity not authenticated" }; + return { data: "", code: "400", status: "Identity not authenticated" }; } const passportIdentity = window.currentlyAuthenticatedIdentity; const passport = passportIdentity.getPassport(passportUUID); if (passport === undefined || passport === null) { - createPassportCertificate(passportUUID).then(function (keys) { + createPassportCertificate(passportUUID).then(function(keys) { const cryptoData = new CryptoData(); cryptoData.setPublicKey(keys["publicKeyPEM"]); cryptoData.setPrivateKey(keys["privateKeyPEM"]); @@ -536,14 +538,14 @@ 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) { return new Penpal.Promise(result => { - createPassportCertificate(makeid()).then(function (keys) { + createPassportCertificate(makeid()).then(function(keys) { const newIdentity = new Identity(); const cryptoData = new CryptoData(); cryptoData.setPublicKey(keys["publicKeyPEM"]); @@ -578,9 +580,7 @@ const connection = Penpal.connectToParent({ listIdentities() { return new Penpal.Promise(result => { const identities = listIdentitiesFromLocalStorage(); - result({ data: identities, - code: "200", - status: "Identities listed" }); + result({ data: identities, code: "200", status: "Identities listed" }); }); }, loadIdentity(identityKey, pinCode) { @@ -627,9 +627,7 @@ 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), @@ -855,7 +853,7 @@ const connection = Penpal.connectToParent({ if (executeResult.code === "200") { const actionID = executeResult.data["ActionID"]; const QrCode = executeResult.data["QrCode"]; - QRCode.toDataURL(actionID + "," + QrCode, function (err, url) { + QRCode.toDataURL(actionID + "," + QrCode, function(err, url) { executeResult.data["image"] = url; result(executeResult); }); @@ -967,14 +965,10 @@ 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" }; } const success = extendPinCodeTtl(authenticationPublicKey); @@ -988,9 +982,7 @@ 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"), @@ -1005,14 +997,10 @@ 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" }; } const success = extendPinCodeTtl(authenticationPublicKey); @@ -1038,14 +1026,10 @@ 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" }; } const success = extendPinCodeTtl(authenticationPublicKey); @@ -1071,7 +1055,7 @@ const connection = Penpal.connectToParent({ emailArg, passportPrivateKey, passportCertificate - ).then(function (keys) { + ).then(function(keys) { const publicKeyOneTime = keys["publicKeyPEM"]; const privateKeyOneTime = keys["privateKeyPEM"]; const certificateOneTime = keys["certificatePEM"]; @@ -2173,7 +2157,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); @@ -2306,7 +2290,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); }); @@ -2379,7 +2363,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); }); @@ -2427,7 +2411,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); }); -- GitLab