Skip to content
Snippets Groups Projects
Commit 0d00247d authored by Damyan Mitev's avatar Damyan Mitev :beach:
Browse files

add validateVCard

parent 5a06292a
No related branches found
No related tags found
1 merge request!75Implement validation of VCard
......@@ -1575,6 +1575,77 @@ const connection = Penpal.connectToParent({
messageUUID: messageUUID,
}, "vCard signed");
},
// vCardImageData = {
// contentType: "image/png",
// contentBase64: base 64 encoded image
// };
// text, html - the text and html part of the email
// related, attachments - array of objects, containing hashes of images/objects, related to the html in format:
// {
// headers: {
// "Content-Type": "application/hash; algorithm=SHA-256",
// "Original-Content-Type": "image/jpeg", //original content type
// "Content-Disposition": "inline" or "attachment",
// ... //other headers
// },
// body: "base64 encoded hash"
// }
validateVCard: async (vCardImageData, text, html, parts = null) => {
const authenticationPublicKey = localStorage.getItem(
"authenticatedIdentity"
);
if (
!authenticationPublicKey ||
!window.loadedIdentities[authenticationPublicKey] ||
!extendPinCodeTtl(authenticationPublicKey)
) {
return encodeResponse("400", "", "Identity not authenticated");
}
//vCardImageData = new ImageData(vCardImageData);
if (!parts) {
parts = [];
}
if (html) {
const htmlPart = {
headers: {
"Content-Type": "text/html"
},
body: stringToUtf8Base64(html)
};
parts.unshift(htmlPart);
}
if (text) {
const textPart = {
headers: {
"Content-Type": "text/plain"
},
body: stringToUtf8Base64(text)
};
parts.unshift(textPart);
}
const validateVCardResponse = await executeRestfulFunction(
"private",
window.viamApi,
window.viamApi.signValidateVCard,
null,
parts
);
if (validateVCardResponse.code !== "200") {
return encodeResponse("400", "", validateVCardResponse.status);
}
//TODO - what will be the response?
const signedVCardImageData = new ImageData(validateVCardResponse.data);
return encodeResponse("200", signedVCardImageData, "vCard signed");
},
generateQrCode,
documentCreateDocument: async (passportUUID, path, contentType, title) => {
const authenticationPublicKey = localStorage.getItem(
......
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