mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-24 08:32:34 +02:00
initial commit
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user