Newer
Older
import {encodeResponse} from "../utilities/appUtility";
WopiAPI.prototype.getPassports = function (resourceID, contentType) {
const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers;
url: `${window.WOPI_URL}getPassports`,
publicKey,
uuid,
token,
deviceHash,
resourceID: encodeURI(resourceID),
contentType: encodeURI(contentType)
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;
return await this.getPassports(resourceID, contentType);
};
WopiAPI.prototype.putDocument = function (resourceID, accessToken, file) {
const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers;
resourceID = encodeURI(resourceID);
url: `${window.WOPI_URL}files/${resourceID}/contents`,
method: 'POST',
headers: {
publicKey,
uuid,
token,
deviceHash
},
params: {
access_token: accessToken
},
data: file
};
return axios(requestConfig);
};