Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Valeri Buchinski committed Feb 23, 2024
2 parents 320442f + 8e24e2c commit 15bdf9a
Show file tree
Hide file tree
Showing 30 changed files with 288 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/monorepo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
on: push
on: [push, pull_request]

name: monorepo

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CHANGELOG

## [3.2.3]

* [examples] Run linting on examples;
* [placeholder-plain] Fix ability to add a placeholder to a file that contains the "trailer" keyword in plain text;
* Bumped version of ip, punycode and sshpk.

## [3.2.2]

* Zero-change version. Lerna versioning was messed up with `lerna publish from-package`.

## [3.2.1]

* [signer-p12] Fixed JSDoc on the sign() method.
Expand Down
10 changes: 8 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "3.2.2",
"npmClient": "yarn"
"version": "3.2.3",
"npmClient": "yarn",
"ignoreChanges": [
"*.md",
"**/*.md",
"**/CHANGELOG.md",
"**/node_modules/**"
]
}
6 changes: 0 additions & 6 deletions packages/eslint-config/eslint.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
module.exports = {
env: {
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
},
extends: [
"airbnb-base",
"plugin:jest/recommended"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@signpdf/eslint-config",
"version": "3.1.0",
"version": "3.2.3",
"description": "",
"main": "eslint.js",
"repository": {
Expand Down
10 changes: 10 additions & 0 deletions packages/examples/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": [
"eslint:recommended"
],
"env": {
"node": true,
"browser": false,
"es2019": true
}
}
11 changes: 6 additions & 5 deletions packages/examples/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"private": true,
"name": "@signpdf/examples",
"version": "3.2.2",
"version": "3.2.3",
"description": "",
"scripts": {
"js": "node src/javascript.js",
"ts": "ts-node src/typescript.ts"
"ts": "ts-node src/typescript.ts",
"lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./"
},
"engines": {
"node": ">=12"
Expand All @@ -15,9 +16,9 @@
"url": "git+https://github.com/vbuch/node-signpdf.git"
},
"dependencies": {
"@signpdf/placeholder-plain": "^3.2.0",
"@signpdf/signer-p12": "^3.2.2",
"@signpdf/signpdf": "^3.2.2",
"@signpdf/placeholder-plain": "^3.2.3",
"@signpdf/signer-p12": "^3.2.3",
"@signpdf/signpdf": "^3.2.3",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
Expand Down
70 changes: 35 additions & 35 deletions packages/examples/src/javascript.js
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: 'signpdf@example.com',
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: 'signpdf@example.com',
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();
91 changes: 91 additions & 0 deletions packages/examples/src/multiple-signatures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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 buyerSign(pdfBuffer, targetPath) {
// Add a placeholder for John Doe - the customer
var pdfWithPlaceholder = plainAddPlaceholder({
pdfBuffer: pdfBuffer,
reason: 'Agrees to buy the truck trailer.',
contactInfo: 'john@example.com',
name: 'John Doe',
location: 'Free Text Str., Free World',
});

// John signs the PDF
// certificate.p12 is the certificate that is going to be used to sign
var certificateBuffer = fs.readFileSync(path.join(__dirname, '/../../../resources/certificate.p12'));
var signer = new P12Signer(certificateBuffer);
return signpdf
.sign(pdfWithPlaceholder, signer)
.then(function (signedPdf) {
// signedPdf is a Buffer of an electronically signed PDF. Store it.
fs.writeFileSync(targetPath, signedPdf);

return signedPdf;
})
}

function sellerSign(pdfBuffer, targetPath) {
// Add a placeholder for John Doe - the customer
var pdfWithPlaceholder = plainAddPlaceholder({
pdfBuffer: pdfBuffer,
reason: 'Agrees to sell a truck trailer to John Doe.',
contactInfo: 'dealer@example.com',
name: 'Thug Dealer',
location: 'Automotive Str., Free World',
});

// The seller signs the PDF
// bundle.p12 is the certificate bundle that is going to be used to sign
var certificateBuffer = fs.readFileSync(path.join(__dirname, '/../../../resources/bundle.p12'));
var signer = new P12Signer(certificateBuffer);
return signpdf
.sign(pdfWithPlaceholder, signer)
.then(function (signedPdf) {
// signedPdf is a Buffer of an electronically signed PDF. Store it.
fs.writeFileSync(targetPath, signedPdf);

return signedPdf;
})
}

/**
* John Doe is buying a truck trailer from Thug Dealer.
* The PDF is signed by both parties in two copies.
* The first copy is signed by John Doe and then by Thug Dealer.
* The second copy is signed by Thug Dealer and then by John Doe.
* 4 PDFs are created in the output folder.
*/
function work() {
// contributing.pdf is the "contract" they are going to sign.
var pdfBuffer = fs.readFileSync(path.join(__dirname, '/../../../resources/contributing.pdf'));

// A copy of the PDF is signed by the buyer and then by the seller.
buyerSign(
pdfBuffer,
path.join(__dirname, '/../output/multiple-signatures-buyer-seller-1.pdf'
))
.then(function (signedByCustomer) {
return sellerSign(
signedByCustomer,
path.join(__dirname, '/../output/multiple-signatures-buyer-seller-2.pdf')
);
});

// A copy of the PDF is signed by the seller and then by the buyer.
sellerSign(
pdfBuffer,
path.join(__dirname, '/../output/multiple-signatures-seller-buyer-1.pdf'
))
.then(function (signedBySeller) {
return buyerSign(
signedBySeller,
path.join(__dirname, '/../output/multiple-signatures-seller-buyer-2.pdf')
);
});
}

work();
4 changes: 2 additions & 2 deletions packages/examples/src/pdfkit010-with-visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function work() {
size: 'A4',
layout: 'portrait',
bufferPages: true,
});;
});
pdf.info.CreationDate = '';

// At the end we want to convert the PDFKit to a string/Buffer and store it in a file.
Expand Down Expand Up @@ -125,6 +125,6 @@ function work() {
// Finally end the PDFDocument stream.
pdf.end();
// This has just triggered the `pdfReady` Promise to be resolved.
};
}

work();
4 changes: 2 additions & 2 deletions packages/examples/src/pdfkit010.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function work() {
size: 'A4',
layout: 'portrait',
bufferPages: true,
});;
});
pdf.info.CreationDate = '';

// At the end we want to convert the PDFKit to a string/Buffer and store it in a file.
Expand Down Expand Up @@ -74,6 +74,6 @@ function work() {
// Finally end the PDFDocument stream.
pdf.end();
// This has just triggered the `pdfReady` Promise to be resolved.
};
}

work();
6 changes: 3 additions & 3 deletions packages/placeholder-pdf-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signpdf/placeholder-pdf-lib",
"version": "3.2.0",
"version": "3.2.3",
"description": "Use PDF-LIB to insert a signature placeholder.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -38,7 +38,7 @@
"lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./"
},
"dependencies": {
"@signpdf/utils": "^3.2.0"
"@signpdf/utils": "^3.2.3"
},
"peerDependencies": {
"pdf-lib": "^1.17.1"
Expand All @@ -50,7 +50,7 @@
"@babel/node": "^7.0.0",
"@babel/plugin-syntax-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.4.2",
"@signpdf/eslint-config": "^3.1.0",
"@signpdf/eslint-config": "^3.2.3",
"@signpdf/internal-utils": "^3.2.0",
"@types/node": ">=12.0.0",
"@types/node-forge": "^1.2.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/placeholder-pdfkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signpdf/placeholder-pdfkit",
"version": "3.2.0",
"version": "3.2.3",
"description": "Use foliojs/PDFKit 0.11+ to insert a signature placeholder.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -38,7 +38,7 @@
"lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./"
},
"dependencies": {
"@signpdf/utils": "^3.2.0"
"@signpdf/utils": "^3.2.3"
},
"peerDependencies": {
"pdfkit": "^0.11.0"
Expand All @@ -50,7 +50,7 @@
"@babel/node": "^7.0.0",
"@babel/plugin-syntax-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.4.2",
"@signpdf/eslint-config": "^3.0.0",
"@signpdf/eslint-config": "^3.2.3",
"@signpdf/internal-utils": "^3.2.0",
"@types/node": ">=12.0.0",
"@types/node-forge": "^1.2.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/placeholder-pdfkit010/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signpdf/placeholder-pdfkit010",
"version": "3.2.0",
"version": "3.2.3",
"description": "Use foliojs/PDFKit 0.10 to insert a signature placeholder.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -38,7 +38,7 @@
"lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./"
},
"dependencies": {
"@signpdf/utils": "^3.2.0"
"@signpdf/utils": "^3.2.3"
},
"peerDependencies": {
"pdfkit": "~0.10.0"
Expand All @@ -50,7 +50,7 @@
"@babel/node": "^7.0.0",
"@babel/plugin-syntax-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.4.2",
"@signpdf/eslint-config": "^3.1.0",
"@signpdf/eslint-config": "^3.2.3",
"@signpdf/internal-utils": "^3.2.0",
"@types/node": ">=12.0.0",
"@types/node-forge": "^1.2.1",
Expand Down
Loading

0 comments on commit 15bdf9a

Please sign in to comment.