diff --git a/javascript/src/iframe/viamapi-iframe.js b/javascript/src/iframe/viamapi-iframe.js index 4f2b83f4370ec8717479e42fc1e24691f3253b5c..7ad243400d972b5a1e4b18cde88d149b4b694dd7 100644 --- a/javascript/src/iframe/viamapi-iframe.js +++ b/javascript/src/iframe/viamapi-iframe.js @@ -1212,7 +1212,7 @@ const connection = Penpal.connectToParent({ }, // WOPI - getPassports: async (resourceID, contentType) => { + getPassportsNewProtocol: async (resourceID, contentType) => { const authenticationPublicKey = localStorage.getItem("authenticatedIdentity"); if ( @@ -1223,7 +1223,22 @@ const connection = Penpal.connectToParent({ return encodeResponse("400", "", "Identity not authenticated"); } - const response = await wopiAPI.getPassports(resourceID, contentType); + const response = await wopiAPI.getPassportsNewProtocol(resourceID, contentType); + return response.data; + }, + + getPassports: async fileId => { + const authenticationPublicKey = localStorage.getItem("authenticatedIdentity"); + + if ( + !authenticationPublicKey || + !window.loadedIdentities[authenticationPublicKey] || + !extendPinCodeTtl(authenticationPublicKey) + ) { + return encodeResponse("400", "", "Identity not authenticated"); + } + + 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 6e7794e5312f04a8716b0571ec0a99a057e75432..a7106a486dc8a6ec9515197ad52e9d1bf770e9a1 100644 --- a/javascript/src/iframe/wopiapi-iframe.js +++ b/javascript/src/iframe/wopiapi-iframe.js @@ -2,10 +2,10 @@ const axios = require('axios'); function WopiAPI() {} -WopiAPI.prototype.getPassports = function (resourceID, contentType) { +WopiAPI.prototype.getPassportsNewProtocol = function (resourceID, contentType) { const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers; const requestConfig = { - url: `${window.WOPI_URL}getPassports`, + url: `${window.WOPI_URL}getPassportsNewProtocol`, method: 'POST', headers: { publicKey, @@ -20,6 +20,23 @@ 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, uuid, token, deviceHash } = window.viamApi.getConfig().headers;