Skip to content
Snippets Groups Projects
Commit 5effa606 authored by Alexey Lunin's avatar Alexey Lunin
Browse files

merge master

parents b4824ae5 86e86f50
No related branches found
No related tags found
1 merge request!49Applied prettier to the VCL project
...@@ -1280,7 +1280,8 @@ const connection = Penpal.connectToParent({ ...@@ -1280,7 +1280,8 @@ const connection = Penpal.connectToParent({
passportUUID, passportUUID,
resourceid, resourceid,
contentType, contentType,
file file,
upload
) => { ) => {
const authenticationPublicKey = localStorage.getItem( const authenticationPublicKey = localStorage.getItem(
"authenticatedIdentity" "authenticatedIdentity"
...@@ -1301,7 +1302,8 @@ const connection = Penpal.connectToParent({ ...@@ -1301,7 +1302,8 @@ const connection = Penpal.connectToParent({
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
passportuuid: passportUUID, passportuuid: passportUUID,
resourceid, resourceid,
contentType contentType,
upload
} }
}; };
...@@ -1468,7 +1470,27 @@ const connection = Penpal.connectToParent({ ...@@ -1468,7 +1470,27 @@ const connection = Penpal.connectToParent({
}, },
// WOPI // 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( const authenticationPublicKey = localStorage.getItem(
"authenticatedIdentity" "authenticatedIdentity"
); );
...@@ -1481,7 +1503,7 @@ const connection = Penpal.connectToParent({ ...@@ -1481,7 +1503,7 @@ const connection = Penpal.connectToParent({
return encodeResponse("400", "", "Identity not authenticated"); return encodeResponse("400", "", "Identity not authenticated");
} }
const response = await wopiAPI.getPassports(resourceID, contentType); const response = await wopiAPI.getPassports(fileId);
return response.data; return response.data;
}, },
......
...@@ -2,7 +2,7 @@ const axios = require("axios"); ...@@ -2,7 +2,7 @@ const axios = require("axios");
function WopiAPI() {} function WopiAPI() {}
WopiAPI.prototype.getPassports = function(resourceID, contentType) { WopiAPI.prototype.getPassportsNewProtocol = function(resourceID, contentType) {
const { const {
publicKey, publicKey,
uuid, uuid,
...@@ -10,7 +10,7 @@ WopiAPI.prototype.getPassports = function(resourceID, contentType) { ...@@ -10,7 +10,7 @@ WopiAPI.prototype.getPassports = function(resourceID, contentType) {
deviceHash deviceHash
} = window.viamApi.getConfig().headers; } = window.viamApi.getConfig().headers;
const requestConfig = { const requestConfig = {
url: `${window.WOPI_URL}getPassports`, url: `${window.WOPI_URL}getPassportsNewProtocol`,
method: "POST", method: "POST",
headers: { headers: {
publicKey, publicKey,
...@@ -25,6 +25,28 @@ WopiAPI.prototype.getPassports = function(resourceID, contentType) { ...@@ -25,6 +25,28 @@ WopiAPI.prototype.getPassports = function(resourceID, contentType) {
return axios(requestConfig); 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) { WopiAPI.prototype.putDocument = function(resourceID, accessToken, file) {
const { const {
publicKey, publicKey,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment