Skip to content
Snippets Groups Projects

268 convert odt file to pdf

Merged Damyan Mitev requested to merge 268-convert-odt-file-to-pdf into master
1 unresolved thread
Files
6
@@ -16,6 +16,9 @@ import {
@@ -16,6 +16,9 @@ import {
decryptMessage,
decryptMessage,
encryptMessage, signEmail
encryptMessage, signEmail
} from '../utilities/signingUtilities';
} from '../utilities/signingUtilities';
 
import {
 
signPdf
 
} from '../utilities/pdfUtilities';
import CryptoData from '../CryptoData';
import CryptoData from '../CryptoData';
import Identity from '../Identity';
import Identity from '../Identity';
import {STATUS_DEVICE_REVOKED} from '../constants/statuses';
import {STATUS_DEVICE_REVOKED} from '../constants/statuses';
@@ -935,6 +938,64 @@ const connection = Penpal.connectToParent({
@@ -935,6 +938,64 @@ const connection = Penpal.connectToParent({
return encodeResponse("200", response.data, "Email signed");
return encodeResponse("200", response.data, "Email signed");
},
},
 
signPdf: async (passportUUID, pdfRaw /*array buffer*/) => {
 
 
//TODO api is not finished
 
 
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
 
 
if (
 
!authenticationPublicKey ||
 
!window.loadedIdentities[authenticationPublicKey] ||
 
!extendPinCodeTtl(authenticationPublicKey)
 
) {
 
return encodeResponse("400", "", "Identity not authenticated");
 
}
 
 
let response = await getCertificateForPassport(passportUUID, true);
 
 
if (response.code !== "200") {
 
return encodeResponse("400", "", response.status);
 
}
 
 
const {
 
x509Certificate: passportCertificate,
 
privateKey: passportPrivateKey,
 
chain: passportChain
 
} = response.data;
 
 
const keys =
 
await createOneTimePassportCertificate(
 
makeid() + "-" + passportUUID, null, passportPrivateKey, passportCertificate);
 
 
const { privateKeyPEM: privateKeyOneTime, certificatePEM: certificateOneTime } = keys;
 
 
passportChain.push(passportCertificate);
 
 
const signedPdf = await signPdf(pdfRaw, certificateOneTime, passportChain, privateKeyOneTime);
 
 
//for test
 
response.data.signedPdf = signedPdf;
 
//for test
 
 
// response = await executeRestfulFunction(
 
// "private", window.viamApi, window.viamApi.passportGetEmailWithHeaderByPassport, null, passportUUID, emailMessage);
 
//
 
// if (response.code !== "200") {
 
// return encodeResponse("400", "", response.status);
 
// }
 
//
 
// const signedEmail = await signEmail(response.data, certificateOneTime, passportChain, privateKeyOneTime);
 
//
 
// response = await executeRestfulFunction(
 
// "private", window.viamApi, window.viamApi.signResignEmail, null, passportUUID, signedEmail);
 
//
 
// if (response.code !== "200") {
 
// return encodeResponse("400", "", response.status);
 
// }
 
 
return encodeResponse("200", response.data, "PDF signed");
 
},
documentCreateDocument: async (path, passportUUID, contenttype) => {
documentCreateDocument: async (path, passportUUID, contenttype) => {
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
if (
if (
Loading