diff --git a/javascript/src/iframe/viamapi-iframe.js b/javascript/src/iframe/viamapi-iframe.js index 49aa87d2c1d7dacf24616ba5dd3ac64c7de14f71..efd6fe262831e165c52e6723ba09232701b48b6a 100644 --- a/javascript/src/iframe/viamapi-iframe.js +++ b/javascript/src/iframe/viamapi-iframe.js @@ -1280,7 +1280,8 @@ const connection = Penpal.connectToParent({ passportUUID, resourceid, contentType, - file + file, + upload ) => { const authenticationPublicKey = localStorage.getItem( "authenticatedIdentity" @@ -1301,7 +1302,8 @@ const connection = Penpal.connectToParent({ "Content-Type": "multipart/form-data", passportuuid: passportUUID, resourceid, - contentType + contentType, + upload } }; @@ -1468,7 +1470,27 @@ const connection = Penpal.connectToParent({ }, // WOPI - getPassports: async (resourceID, contentType) => { + getPassportsNewProtocol: async (resourceID, contentType) => { + const authenticationPublicKey = localStorage.getItem( + "authenticatedIdentity" + ); + + if ( + !authenticationPublicKey || + !window.loadedIdentities[authenticationPublicKey] || + !extendPinCodeTtl(authenticationPublicKey) + ) { + return encodeResponse("400", "", "Identity not authenticated"); + } + + const response = await wopiAPI.getPassportsNewProtocol( + resourceID, + contentType + ); + return response.data; + }, + + getPassports: async fileId => { const authenticationPublicKey = localStorage.getItem( "authenticatedIdentity" ); @@ -1481,7 +1503,7 @@ const connection = Penpal.connectToParent({ return encodeResponse("400", "", "Identity not authenticated"); } - const response = await wopiAPI.getPassports(resourceID, contentType); + const response = await wopiAPI.getPassports(fileId); return response.data; }, diff --git a/javascript/src/iframe/wopiapi-iframe.js b/javascript/src/iframe/wopiapi-iframe.js index b56e4a6d459e36fcd3d097336b2b26c0da7ccc8f..9de61de7ce47792039a5944cd2e76ae4c68aa7f1 100644 --- a/javascript/src/iframe/wopiapi-iframe.js +++ b/javascript/src/iframe/wopiapi-iframe.js @@ -2,7 +2,7 @@ const axios = require("axios"); function WopiAPI() {} -WopiAPI.prototype.getPassports = function(resourceID, contentType) { +WopiAPI.prototype.getPassportsNewProtocol = function(resourceID, contentType) { const { publicKey, uuid, @@ -10,7 +10,7 @@ WopiAPI.prototype.getPassports = function(resourceID, contentType) { deviceHash } = window.viamApi.getConfig().headers; const requestConfig = { - url: `${window.WOPI_URL}getPassports`, + url: `${window.WOPI_URL}getPassportsNewProtocol`, method: "POST", headers: { publicKey, @@ -25,6 +25,28 @@ WopiAPI.prototype.getPassports = function(resourceID, contentType) { return axios(requestConfig); }; +WopiAPI.prototype.getPassports = function(fileID) { + const { + publicKey, + uuid, + token, + deviceHash + } = window.viamApi.getConfig().headers; + const requestConfig = { + url: `${window.WOPI_URL}getPassports`, + method: "POST", + headers: { + publicKey, + uuid, + token, + deviceHash, + fileID: encodeURI(fileID) + } + }; + + return axios(requestConfig); +}; + WopiAPI.prototype.putDocument = function(resourceID, accessToken, file) { const { publicKey,