-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚨 Lint examples with eslint:recommended
Since we're targetting Node 12 (should we go up?), the target ES spec is 2019.
- Loading branch information
Valeri Buchinski
committed
Feb 9, 2024
1 parent
1ef1957
commit 6c8c95a
Showing
7 changed files
with
68 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": [ | ||
"eslint:recommended" | ||
], | ||
"env": { | ||
"node": true, | ||
"browser": false, | ||
"es2019": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var plainAddPlaceholder = require('@signpdf/placeholder-plain').plainAddPlaceholder | ||
var signpdf = require('@signpdf/signpdf').default; | ||
var P12Signer = require('@signpdf/signer-p12').P12Signer; | ||
|
||
function work() { | ||
// contributing.pdf is the file that is going to be signed | ||
var sourcePath = path.join(__dirname, '/../../../resources/contributing.pdf'); | ||
var pdfBuffer = fs.readFileSync(sourcePath); | ||
|
||
// certificate.p12 is the certificate that is going to be used to sign | ||
var certificatePath = path.join(__dirname, '/../../../resources/certificate.p12'); | ||
var certificateBuffer = fs.readFileSync(certificatePath); | ||
var signer = new P12Signer(certificateBuffer); | ||
|
||
// The PDF needs to have a placeholder for a signature to be signed. | ||
var pdfWithPlaceholder = plainAddPlaceholder({ | ||
pdfBuffer: pdfBuffer, | ||
reason: 'The user is decalaring consent through JavaScript.', | ||
contactInfo: '[email protected]', | ||
name: 'John Doe', | ||
location: 'Free Text Str., Free World', | ||
}); | ||
|
||
// pdfWithPlaceholder is now a modified buffer that is ready to be signed. | ||
signpdf | ||
.sign(pdfWithPlaceholder, signer) | ||
.then(function (signedPdf) { | ||
// signedPdf is a Buffer of an electronically signed PDF. Store it. | ||
var targetPath = path.join(__dirname, '/../output/javascript.pdf'); | ||
fs.writeFileSync(targetPath, signedPdf); | ||
}) | ||
} | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var plainAddPlaceholder = require('@signpdf/placeholder-plain').plainAddPlaceholder; | ||
var signpdf = require('@signpdf/signpdf').default; | ||
var P12Signer = require('@signpdf/signer-p12').P12Signer; | ||
|
||
function work() { | ||
// contributing.pdf is the file that is going to be signed | ||
var sourcePath = path.join(__dirname, '/../../../resources/contributing.pdf'); | ||
var pdfBuffer = fs.readFileSync(sourcePath); | ||
|
||
// certificate.p12 is the certificate that is going to be used to sign | ||
var certificatePath = path.join(__dirname, '/../../../resources/certificate.p12'); | ||
var certificateBuffer = fs.readFileSync(certificatePath); | ||
var signer = new P12Signer(certificateBuffer); | ||
|
||
// The PDF needs to have a placeholder for a signature to be signed. | ||
var pdfWithPlaceholder = plainAddPlaceholder({ | ||
pdfBuffer: pdfBuffer, | ||
reason: 'The user is decalaring consent through JavaScript.', | ||
contactInfo: '[email protected]', | ||
name: 'John Doe', | ||
location: 'Free Text Str., Free World', | ||
}); | ||
|
||
// pdfWithPlaceholder is now a modified buffer that is ready to be signed. | ||
signpdf | ||
.sign(pdfWithPlaceholder, signer) | ||
.then(function (signedPdf) { | ||
// signedPdf is a Buffer of an electronically signed PDF. Store it. | ||
var targetPath = path.join(__dirname, '/../output/javascript.pdf'); | ||
fs.writeFileSync(targetPath, signedPdf); | ||
}) | ||
} | ||
|
||
work(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters