From 298951f1684995096b0ea7563435882749878138 Mon Sep 17 00:00:00 2001
From: Zdravko Iliev <zdravko.iliev61@gmail.com>
Date: Tue, 8 Nov 2022 18:00:39 +0200
Subject: [PATCH] fix subfilter return

---
 dist/lib/generalUtils.js | 3 ++-
 dist/lib/index.js        | 3 +--
 src/lib/generalUtils.ts  | 3 ++-
 src/lib/index.ts         | 3 +--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/dist/lib/generalUtils.js b/dist/lib/generalUtils.js
index 64ce8f2..6a35758 100644
--- a/dist/lib/generalUtils.js
+++ b/dist/lib/generalUtils.js
@@ -7,7 +7,8 @@ const checkForSubFilter = (pdfBuffer) => {
     const matches = pdfBuffer.toString().match(/\/SubFilter\s*\/([\w.]*)/);
     const subFilter = Array.isArray(matches) && matches[1];
     if (!subFilter) {
-        throw new errors_1.AppError("Can not find subfilter");
+        //SubFilter is only available if there is a sig in the pdf
+        return;
     }
     const supportedTypes = [
         "adbe.pkcs7.detached",
diff --git a/dist/lib/index.js b/dist/lib/index.js
index 6b0086a..7ed6264 100644
--- a/dist/lib/index.js
+++ b/dist/lib/index.js
@@ -10,8 +10,7 @@ const verifyPDF = (pdf) => {
         (0, generalUtils_1.checkForSubFilter)(pdfBuffer);
     }
     catch (error) {
-        //SubFilter is only available if there is a sig in the pdf
-        return null;
+        throw new Error(error.message);
     }
     try {
         const { signatureStr, signedData, signatureMeta } = (0, signatureUtils_1.extractSignature)(pdfBuffer);
diff --git a/src/lib/generalUtils.ts b/src/lib/generalUtils.ts
index 48509ab..6ba8aa2 100644
--- a/src/lib/generalUtils.ts
+++ b/src/lib/generalUtils.ts
@@ -7,7 +7,8 @@ export const checkForSubFilter = (pdfBuffer: Buffer) => {
   const subFilter = Array.isArray(matches) && matches[1];
 
   if (!subFilter) {
-    throw new AppError("Can not find subfilter");
+    //SubFilter is only available if there is a sig in the pdf
+    return;
   }
 
   const supportedTypes = [
diff --git a/src/lib/index.ts b/src/lib/index.ts
index f603cfd..81156ab 100644
--- a/src/lib/index.ts
+++ b/src/lib/index.ts
@@ -7,8 +7,7 @@ export const verifyPDF = (pdf: Buffer) => {
   try {
     checkForSubFilter(pdfBuffer);
   } catch (error) {
-    //SubFilter is only available if there is a sig in the pdf
-    return null;
+    throw new Error(error.message);
   }
 
   try {
-- 
GitLab