From 3215e86ce99cd73c4b2e852cc9acf599e0d39c4b Mon Sep 17 00:00:00 2001
From: Zdravko Iliev <zdravko.iliev@vereign.com>
Date: Mon, 11 Jul 2022 17:24:35 +0300
Subject: [PATCH] add build

---
 dist/lib/verify.js | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/dist/lib/verify.js b/dist/lib/verify.js
index 3e21602..2870e52 100644
--- a/dist/lib/verify.js
+++ b/dist/lib/verify.js
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
 exports.verify = void 0;
 const forge = __importStar(require("@vereign/node-forge"));
 const certUtils_1 = require("./certUtils");
-const errors_1 = require("./errors");
 const signatureUtils_1 = require("./signatureUtils");
 const verify = (signature, signatureMeta) => {
     const message = (0, signatureUtils_1.getMessageFromSignature)(signature);
@@ -40,11 +39,21 @@ const verify = (signature, signatureMeta) => {
         .update(forge.asn1.toDer(set).data)
         .digest()
         .getBytes();
-    const validAuthenticatedAttributes = clientCertificate["publicKey"].verify(digest, sig);
-    if (!validAuthenticatedAttributes) {
-        throw new errors_1.AppError("Wrong authenticated attributes");
-    }
-    // WIP: fix integrity check
+    //FIXME: verification for some of the pdf documents is failing
+    // Encryption block is invalid.
+    // Check if the code is wrong or the PDF is not valid
+    // try {
+    //   const validAuthenticatedAttributes = clientCertificate["publicKey"].verify(
+    //     digest,
+    //     sig
+    //   );
+    // } catch (error) {
+    //   console.log(error);
+    // }
+    // if (!validAuthenticatedAttributes) {
+    //   throw new AppError("Wrong authenticated attributes");
+    // }
+    // FIXME: fix integrity check
     //   const messageDigestAttr = forge.pki.oids.messageDigest;
     //   const fullAttrDigest = attrs.find(
     //     (attr) => forge.asn1.derToOid(attr.value[0].value) === messageDigestAttr
@@ -58,7 +67,7 @@ const verify = (signature, signatureMeta) => {
     //   const integrity = dataDigest === attrDigest;
     const sortedCerts = (0, certUtils_1.sortCertificateChain)(certificates);
     const parsedCerts = (0, certUtils_1.extractCertificatesDetails)(sortedCerts);
-    //WIP: fix authenticity check after you have the root cert
+    //FIXME: fix authenticity check after you have the root cert
     //   const authenticity = authenticateSignature(sortedCerts);
     const isExpired = (0, certUtils_1.isCertsExpired)(sortedCerts);
     return {
-- 
GitLab