vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
711 stars 178 forks source link

[utils] Signer.sign() types don't indicate it is async method #211

Closed dhensby closed 10 months ago

dhensby commented 10 months ago

At the moment the typings are wrong because the sign function is reported to be sign(pdfBuffer: Buffer) => Buffer. However, this is not a correct typing as the method is expected to return a promise as it is async. Therefore the typings should be sign(pdfBuffer: Buffer) => Promise<Buffer>.

Question - should we actually allow non async methods (as having it sometimes return a Promise and sometimes not is a bit of a confusing API to consume). I've changed the base implementation so it is no longer async, as this will be a bit more predictable for anyone that may be intercepting the sign method, but happy to revert that change.