From ee449cfb6d3f32b1aa075be060a8e51dd562dc74 Mon Sep 17 00:00:00 2001
From: Gospodin Bodurov <gospodin@bodurov.net>
Date: Tue, 4 Jun 2019 15:39:51 +0300
Subject: [PATCH] Add old GetPassport api

---
 javascript/src/iframe/viamapi-iframe.js | 15 +++++++++++++++
 javascript/src/iframe/wopiapi-iframe.js | 17 +++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/javascript/src/iframe/viamapi-iframe.js b/javascript/src/iframe/viamapi-iframe.js
index 575d4b0..7ad2434 100644
--- a/javascript/src/iframe/viamapi-iframe.js
+++ b/javascript/src/iframe/viamapi-iframe.js
@@ -1227,6 +1227,21 @@ const connection = Penpal.connectToParent({
       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;
+    },
+
     wopiCreateDocument: async (passportUUID, path, contentType, title) => {
       const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
       if (
diff --git a/javascript/src/iframe/wopiapi-iframe.js b/javascript/src/iframe/wopiapi-iframe.js
index 8c5c2fc..a7106a4 100644
--- a/javascript/src/iframe/wopiapi-iframe.js
+++ b/javascript/src/iframe/wopiapi-iframe.js
@@ -20,6 +20,23 @@ WopiAPI.prototype.getPassportsNewProtocol = 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;
 
-- 
GitLab