diff --git a/javascript/src/iframe/viamapi-iframe.js b/javascript/src/iframe/viamapi-iframe.js index 981fa97de178948ebd5174d6d4792b7de911955a..14ddb014b89ddd943bdde075edc97114f457962b 100644 --- a/javascript/src/iframe/viamapi-iframe.js +++ b/javascript/src/iframe/viamapi-iframe.js @@ -1589,9 +1589,10 @@ function getCertificateForPassport(passportUUID, internal) { const connection = Penpal.connectToParent({ // Methods child is exposing to parent methods: { - initialize: (apiUrl, wopiUrl) => { + initialize: (apiUrl, wopiUrl, collaboraUrl) => { window.API_HOST = apiUrl.charAt(apiUrl.length - 1) === "/" ? apiUrl : apiUrl + "/"; - window.WOPI_URL = `${wopiUrl.charAt(wopiUrl.length - 1) === "/" ? wopiUrl : wopiUrl + "/"}getPassports`; + window.WOPI_URL = wopiUrl.charAt(wopiUrl.length - 1) === "/" ? wopiUrl : wopiUrl + "/"; + window.COLLABORA_URL = collaboraUrl.charAt(collaboraUrl.length - 1) === "/" ? collaboraUrl : collaboraUrl + "/"; }, createIdentity(pinCode) { return new Penpal.Promise(result => { diff --git a/javascript/src/iframe/wopiapi-iframe.js b/javascript/src/iframe/wopiapi-iframe.js index 6fcbaac2c0120feab67a894a811f4ed4066706a6..8d5b72aaab4722fc51f4167f93859253fa2901d1 100644 --- a/javascript/src/iframe/wopiapi-iframe.js +++ b/javascript/src/iframe/wopiapi-iframe.js @@ -3,14 +3,15 @@ const axios = require('axios'); function WopiAPI() {} WopiAPI.prototype.getPassports = function (fileID) { + const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers; const requestConfig = { - url: window.WOPI_URL, + url: `${window.WOPI_URL}getPassports`, method: 'POST', headers: { - publicKey: window.viamApi.getConfig().headers.publicKey, - uuid: window.viamApi.getConfig().headers.uuid, - token: window.viamApi.getConfig().headers.token, - deviceHash: window.viamApi.getConfig().headers.deviceHash, + publicKey, + uuid, + token, + deviceHash, fileID } }; diff --git a/javascript/src/viamapi-client.js b/javascript/src/viamapi-client.js index 7cea9b187c3b4c31fee36445255d35a66ea807bc..7c9fea399d2ebac265435027bc6426c127ab1c38 100644 --- a/javascript/src/viamapi-client.js +++ b/javascript/src/viamapi-client.js @@ -9,7 +9,7 @@ const Penpal = require('penpal').default; * @param wopiUrl - WOPI URL used to acces WopiAPI * @returns {*} */ -function setupViamAPI(divId, methods, iframeUrl, apiUrl, wopiUrl) { +function setupViamAPI(divId, methods, iframeUrl, apiUrl, wopiUrl, collaboraUrl) { if (!apiUrl) { apiUrl = `${window.location.origin}/api/`; console.warn(`API host URL not specified. Fall back to ${apiUrl}`); // eslint-disable-line no-console @@ -25,6 +25,11 @@ function setupViamAPI(divId, methods, iframeUrl, apiUrl, wopiUrl) { console.warn(`Iframe URL not specified. Fall back to ${iframeUrl}`); // eslint-disable-line no-console } + if (!collaboraUrl) { + collaboraUrl = window.location.origin; + console.warn(`Collabora host URL not specified. Fall back to ${collaboraUrl}`); // eslint-disable-line no-console + } + const connection = Penpal.connectToChild({ // URL of page to load into iframe. url: iframeUrl, @@ -35,7 +40,7 @@ function setupViamAPI(divId, methods, iframeUrl, apiUrl, wopiUrl) { }); return connection.promise - .then((child) => child.initialize(apiUrl, wopiUrl).then(() => child)); + .then((child) => child.initialize(apiUrl, wopiUrl, collaboraUrl).then(() => child)); } window.setupViamAPI = setupViamAPI;