initial commit

This commit is contained in:
nxglabs
2023-10-22 01:37:25 +05:30
parent 80327652c3
commit 97fd28697a
182 changed files with 55033 additions and 122 deletions
@@ -0,0 +1,31 @@
const signer = require("node-signpdf").default;
class SignPDF {
constructor(pdfBuffer, certBuffer) {
this.pdfDoc = pdfBuffer;
this.certificate = certBuffer;
}
/**
* @return Promise<Buffer>
*/
async signPDF() {
let newPDF = signer.sign(this.pdfDoc, this.certificate, {
passphrase: "emudhra",
});
return newPDF;
}
/**
* @param {Uint8Array} unit8
*/
static unit8ToBuffer(unit8) {
let buf = Buffer.alloc(unit8.byteLength);
const view = new Uint8Array(unit8);
for (let i = 0; i < buf.length; ++i) {
buf[i] = view[i];
}
return buf;
}
}
module.exports = SignPDF;