Skip to content
Snippets Groups Projects
Commit 3019a9ba authored by Zdravko Iliev's avatar Zdravko Iliev
Browse files

add new method for getting Vcard with QR

parent fd80ad2d
Branches
Tags
1 merge request!90ability to attach visual signature on pdf document
This commit is part of merge request !90. Comments created here will be created in the context of that merge request.
...@@ -1758,6 +1758,76 @@ const connection = Penpal.connectToParent({ ...@@ -1758,6 +1758,76 @@ const connection = Penpal.connectToParent({
return encodeResponse("200", response.data, "Document created"); return encodeResponse("200", response.data, "Document created");
}, },
getVcardWithQrCode: async (passportUUID, QRCodeContent = null) =>{
//TODO: IMPLEMENT QR CODE backend method needed
const authenticationPublicKey = localStorage.getItem(
"authenticatedIdentity"
);
if (
!authenticationPublicKey ||
!window.loadedIdentities[authenticationPublicKey] ||
!extendPinCodeTtl(authenticationPublicKey)
) {
return encodeResponse("400", "", "Identity not authenticated");
}
let vCardImageData;
let vCardImageClaimValue;
const vCardImageClaimName = "vCardImage";
const defaultTagName = "notag";
const vCardClaimResponse = await executeRestfulFunction(
"private",
window.viamApi,
window.viamApi.entityGetClaim,
null,
vCardImageClaimName,
defaultTagName,
passportUUID
);
if (vCardClaimResponse.code === "200") {
vCardImageClaimValue = vCardClaimResponse.data;
}
if (
vCardImageClaimValue &&
"state" in vCardImageClaimValue &&
vCardImageClaimValue.state === "disabled"
) {
//No image data if the user have disabled vCard for this profile.
vCardImageData = null;
// vCardImageData = new ImageData({
// contentType: "image/png",
// contentBase64:
// "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" //1x1px transparent pixel
// });
} else {
const vCardImageResponse = await executeRestfulFunction(
"private",
window.viamApi,
window.viamApi.passportGetVCardImage,
null,
passportUUID
);
if (vCardImageResponse.code !== "200") {
return encodeResponse("400", "", vCardImageResponse.status);
}
vCardImageData = new ImageData(vCardImageResponse.data.Image);
if (vCardImageData.contentType !== "image/png") {
return encodeResponse(
"400",
"",
"Content type of vCard mmust be 'image/png'"
);
}
}
return encodeResponse("200",vCardImageData, 'vCard got');
},
documentPutDocument: async ( documentPutDocument: async (
passportUUID, passportUUID,
resourceid, resourceid,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment