From f34a50b76f2ddf3dd35f5eba2fa2001852142005 Mon Sep 17 00:00:00 2001 From: Sasha Ilieva <sasha.ilieva@vereign.com> Date: Tue, 28 May 2019 17:29:20 +0300 Subject: [PATCH] Move wopiCreateDocument to viamapi-iframe --- javascript/src/iframe/viamapi-iframe.js | 26 +++++++++++++++++++++++++ javascript/src/iframe/wopiapi-iframe.js | 26 ------------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/javascript/src/iframe/viamapi-iframe.js b/javascript/src/iframe/viamapi-iframe.js index 4fb851d..6de3366 100644 --- a/javascript/src/iframe/viamapi-iframe.js +++ b/javascript/src/iframe/viamapi-iframe.js @@ -1205,6 +1205,32 @@ const connection = Penpal.connectToParent({ return response.data; }, + wopiCreateDocument: async (passportUUID, path, contentType, title) => { + const authenticationPublicKey = localStorage.getItem("authenticatedIdentity"); + if ( + !authenticationPublicKey || + !window.loadedIdentities[authenticationPublicKey] || + !extendPinCodeTtl(authenticationPublicKey) + ) { + return encodeResponse("400", "", "Identity not authenticated"); + } + + const config = { + headers: { + path, + passportuuid: passportUUID, + contentType, + title + } + }; + const executeResult = await executeRestfulFunction("private", window.viamApi, window.viamApi.documentCreateDocument, + config); + if (executeResult.code !== "200") return executeResult; + const resourceID = executeResult.data; + const passports = await wopiAPI.getPassports(resourceID, contentType); + return passports; + }, + wopiPutFile: async (path, accessToken, file) => { const authenticationPublicKey = localStorage.getItem("authenticatedIdentity"); diff --git a/javascript/src/iframe/wopiapi-iframe.js b/javascript/src/iframe/wopiapi-iframe.js index d50acc2..e4556f2 100644 --- a/javascript/src/iframe/wopiapi-iframe.js +++ b/javascript/src/iframe/wopiapi-iframe.js @@ -22,32 +22,6 @@ WopiAPI.prototype.getPassports = function (resourceID, contentType) { return axios(requestConfig); }; -// WopiAPI.prototype.createDocument = async (passportUUID, path, contentType, title) => { -// const authenticationPublicKey = localStorage.getItem("authenticatedIdentity"); -// if ( -// !authenticationPublicKey || -// !window.loadedIdentities[authenticationPublicKey] || -// !extendPinCodeTtl(authenticationPublicKey) -// ) { -// return encodeResponse("400", "", "Identity not authenticated"); -// } - -// const config = { -// headers: { -// path, -// passportuuid: passportUUID, -// contentType, -// title -// } -// }; -// const response = await executeRestfulFunction("private", window.viamApi, window.viamApi.documentCreateDocument, -// config); - -// const resourceID = response.data; -// const passports = await this.getPassports(resourceID, contentType); -// return axios(config); -// }; - WopiAPI.prototype.putDocument = function (resourceID, accessToken, file) { const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers; -- GitLab