From 2a3ca79f437e6f9f2255846041ac8e469ec60e3c Mon Sep 17 00:00:00 2001 From: Zdravko Iliev <zdravko.iliev@vereign.com> Date: Mon, 23 May 2022 21:46:03 +0300 Subject: [PATCH] fix params --- dist/utils.d.ts | 2 +- dist/utils.js | 10 +++++----- src/utils.ts | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dist/utils.d.ts b/dist/utils.d.ts index 5bb1449..ce9bafb 100644 --- a/dist/utils.d.ts +++ b/dist/utils.d.ts @@ -1 +1 @@ -export declare const TimestampAndEnableLTV: (in_docpath: any, tsa_url: any, in_trusted_cert_path: any, in_appearance_img_path: any, coords: any) => Promise<any>; +export declare const TimestampAndEnableLTV: (docBuffer: ArrayBuffer, certPath: string, certTSAUrl: string, imgBytes: ArrayBuffer, coords: any) => Promise<ArrayBuffer>; diff --git a/dist/utils.js b/dist/utils.js index 2d78ea6..3fc0eaa 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -11,13 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", { value: true }); exports.TimestampAndEnableLTV = void 0; const pdfnet_node_1 = require("@pdftron/pdfnet-node"); -const TimestampAndEnableLTV = (in_docpath, tsa_url, in_trusted_cert_path, in_appearance_img_path, coords) => __awaiter(void 0, void 0, void 0, function* () { - const doc = yield pdfnet_node_1.PDFNet.PDFDoc.createFromBuffer(in_docpath); +const TimestampAndEnableLTV = (docBuffer, certPath, certTSAUrl, imgBytes, coords) => __awaiter(void 0, void 0, void 0, function* () { + const doc = yield pdfnet_node_1.PDFNet.PDFDoc.createFromBuffer(docBuffer); doc.initSecurityHandler(); - const tst_config = yield pdfnet_node_1.PDFNet.TimestampingConfiguration.createFromURL(tsa_url); + const tst_config = yield pdfnet_node_1.PDFNet.TimestampingConfiguration.createFromURL(certTSAUrl); const opts = yield pdfnet_node_1.PDFNet.VerificationOptions.create(pdfnet_node_1.PDFNet.VerificationOptions.SecurityLevel.e_compatibility_and_archiving); - yield opts.addTrustedCertificateUString(in_trusted_cert_path); - const img = yield pdfnet_node_1.PDFNet.Image.createFromMemory2(doc, in_appearance_img_path); + yield opts.addTrustedCertificateUString(certPath); + const img = yield pdfnet_node_1.PDFNet.Image.createFromMemory2(doc, imgBytes); //make this dynamic with canvas lib const imgWidth = 300; const imgHeight = 300; diff --git a/src/utils.ts b/src/utils.ts index b9459ff..829a241 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,24 +1,24 @@ import { PDFNet } from "@pdftron/pdfnet-node"; export const TimestampAndEnableLTV = async ( - in_docpath, - tsa_url, - in_trusted_cert_path, - in_appearance_img_path, - coords -) => { - const doc = await PDFNet.PDFDoc.createFromBuffer(in_docpath); + docBuffer: ArrayBuffer, + certPath: string, + certTSAUrl: string, + imgBytes: ArrayBuffer, + coords: any +): Promise<ArrayBuffer> => { + const doc = await PDFNet.PDFDoc.createFromBuffer(docBuffer); doc.initSecurityHandler(); const tst_config = await PDFNet.TimestampingConfiguration.createFromURL( - tsa_url + certTSAUrl ); const opts = await PDFNet.VerificationOptions.create( PDFNet.VerificationOptions.SecurityLevel.e_compatibility_and_archiving ); - await opts.addTrustedCertificateUString(in_trusted_cert_path); + await opts.addTrustedCertificateUString(certPath); - const img = await PDFNet.Image.createFromMemory2(doc, in_appearance_img_path); + const img = await PDFNet.Image.createFromMemory2(doc, imgBytes); //make this dynamic with canvas lib const imgWidth = 300; -- GitLab