Skip to content

Commit

Permalink
🐛 Signer.sign() is an async method so the typing should indicate it c…
Browse files Browse the repository at this point in the history
…an be a promise

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`. The sign method
can also return a Buffer (sync) as is done in the P12Signer. Therefore the typings should be
`sign(pdfBuffer: Buffer) => Promise<Buffer> | Buffer`.
  • Loading branch information
dhensby authored and vbuch committed Nov 23, 2023
1 parent 5855e24 commit d1e930e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions packages/signer-p12/dist/P12Signer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export class P12Signer extends Signer {
asn1StrictParsing: boolean;
};
cert: any;
/**
* @param {Buffer} pdfBuffer
* @returns {Buffer}
*/
sign(pdfBuffer: Buffer): Buffer;
}
export type SignerOptions = {
passphrase?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/signer-p12/dist/P12Signer.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/utils/dist/Signer.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export class Signer {
/**
* @param {Buffer} pdfBuffer
* @returns {Buffer}
* @returns {Promise<Buffer> | Buffer}
*/
sign(pdfBuffer: Buffer): Buffer;
sign(pdfBuffer: Buffer): Promise<Buffer> | Buffer;
}
//# sourceMappingURL=Signer.d.ts.map
2 changes: 1 addition & 1 deletion packages/utils/dist/Signer.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/utils/dist/Signer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var _SignPdfError = require("./SignPdfError");
class Signer {
/**
* @param {Buffer} pdfBuffer
* @returns {Buffer}
* @returns {Promise<Buffer> | Buffer}
*/
async sign(pdfBuffer) {
sign(pdfBuffer) {
throw new _SignPdfError.SignPdfError(`sign() is not implemented on ${this.constructor.name}`, _SignPdfError.SignPdfError.TYPE_INPUT);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/Signer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {SignPdfError} from './SignPdfError';
export class Signer {
/**
* @param {Buffer} pdfBuffer
* @returns {Buffer}
* @returns {Promise<Buffer> | Buffer}
*/
async sign(pdfBuffer) {
sign(pdfBuffer) {
throw new SignPdfError(
`sign() is not implemented on ${this.constructor.name}`,
SignPdfError.TYPE_INPUT,
Expand Down

0 comments on commit d1e930e

Please sign in to comment.