@signpdf/utils
Advanced tools
Comparing version 3.1.0 to 3.2.0
export * from "./const"; | ||
export * from "./convertBuffer"; | ||
export * from "./extractSignature"; | ||
@@ -3,0 +4,0 @@ export * from "./findByteRange"; |
@@ -17,2 +17,13 @@ "use strict"; | ||
}); | ||
var _convertBuffer = require("./convertBuffer"); | ||
Object.keys(_convertBuffer).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _convertBuffer[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _convertBuffer[key]; | ||
} | ||
}); | ||
}); | ||
var _extractSignature = require("./extractSignature"); | ||
@@ -19,0 +30,0 @@ Object.keys(_extractSignature).forEach(function (key) { |
@@ -8,6 +8,12 @@ "use strict"; | ||
var _SignPdfError = require("./SignPdfError"); | ||
/** | ||
* Removes a trailing character if it is the one passed as the second parameter. | ||
* @param {Buffer} pdf | ||
* @param {string} character | ||
* @returns {Buffer} | ||
*/ | ||
const sliceLastChar = (pdf, character) => { | ||
const lastChar = pdf.slice(pdf.length - 1).toString(); | ||
const lastChar = pdf.subarray(pdf.length - 1).toString(); | ||
if (lastChar === character) { | ||
return pdf.slice(0, pdf.length - 1); | ||
return pdf.subarray(0, pdf.length - 1); | ||
} | ||
@@ -31,4 +37,4 @@ return pdf; | ||
output = sliceLastChar(output, '\r'); | ||
const lastLine = output.slice(output.length - 6).toString(); | ||
if (lastLine !== '\n%%EOF') { | ||
const lastLine = output.subarray(output.length - 6).toString(); | ||
if (lastLine !== '\n%%EOF' && lastLine !== '\r%%EOF') { | ||
throw new _SignPdfError.SignPdfError('A PDF file must end with an EOF line.', _SignPdfError.SignPdfError.TYPE_PARSE); | ||
@@ -35,0 +41,0 @@ } |
export class Signer { | ||
/** | ||
* @param {Buffer} pdfBuffer | ||
* @returns {Promise<Buffer> | Buffer} | ||
* @param {Date | undefined} signingTime | ||
* @returns {Promise<Buffer>} | ||
*/ | ||
sign(pdfBuffer: Buffer): Promise<Buffer> | Buffer; | ||
sign(pdfBuffer: Buffer, signingTime?: Date | undefined): Promise<Buffer>; | ||
} | ||
//# sourceMappingURL=Signer.d.ts.map |
@@ -13,5 +13,6 @@ "use strict"; | ||
* @param {Buffer} pdfBuffer | ||
* @returns {Promise<Buffer> | Buffer} | ||
* @param {Date | undefined} signingTime | ||
* @returns {Promise<Buffer>} | ||
*/ | ||
sign(pdfBuffer) { | ||
async sign(pdfBuffer, signingTime = undefined) { | ||
throw new _SignPdfError.SignPdfError(`sign() is not implemented on ${this.constructor.name}`, _SignPdfError.SignPdfError.TYPE_INPUT); | ||
@@ -18,0 +19,0 @@ } |
{ | ||
"name": "@signpdf/utils", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Utilities for the @signpdf packages.", | ||
@@ -48,3 +48,3 @@ "repository": { | ||
"@signpdf/eslint-config": "^3.1.0", | ||
"@signpdf/internal-utils": "^3.0.0", | ||
"@signpdf/internal-utils": "^3.2.0", | ||
"@types/node": ">=12.0.0", | ||
@@ -67,3 +67,3 @@ "@types/node-forge": "^1.2.1", | ||
}, | ||
"gitHead": "5d5ec00c21e072613acb9776c7c6ac7697314955" | ||
"gitHead": "17a9e6ba4133e75af2916340683d7b4189ad47f0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21086
27
430