vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
676 stars 174 forks source link

[signpdf] export Signer and SignPdfError classes from utils #212

Closed dhensby closed 7 months ago

dhensby commented 7 months ago

Consumers of the library may want to implement their own Signer or even catch and make assertions of errors. Exposing the classes from utils through this library means that consumers don't have to manually require the sub-package themselves, which helps avoid dependency resolution issues that can sometimes happen in npm when root projects and dependencies have slightly mis-matched version requirements.

In my view it's best for a package to export classes/interfaces/types it depends on (where possible) rather than have consumers import them manually through an explicit dependency definition.

eg:


const { sign, Signer } = require('@pdfsign/pdfsign');

is better than:


const { sign } = require('@pdfsign/pdfsign');
const { Signer } = require('@pdfsign/utils');

I can give examples of npm's dependency issues that I've experienced when doing this kind of thing.

vbuch commented 7 months ago

Please add a note in the CHANGELOG under [next]

vbuch commented 7 months ago

I just noticed the constructor of SignPdf initializes byteRangePlaceholder which is never used. If it's not a problem for you, you can remove that in this same PR.