From 13b071e7640f15c69f5aee9a3c4af417d15cccba Mon Sep 17 00:00:00 2001 From: Valery Buchinsky Date: Fri, 1 Mar 2024 11:18:48 +0200 Subject: [PATCH 1/6] Remove annoying buy-me-a-coffee links Use github and npm's official ways to do that. --- .github/FUNDING.yml | 1 + README.md | 1 - package.json | 6 ++++++ packages/placeholder-pdf-lib/README.md | 1 - packages/placeholder-pdf-lib/package.json | 6 ++++++ packages/placeholder-pdfkit/README.md | 1 - packages/placeholder-pdfkit/package.json | 6 ++++++ packages/placeholder-pdfkit010/README.md | 1 - packages/placeholder-pdfkit010/package.json | 6 ++++++ packages/placeholder-plain/README.md | 1 - packages/placeholder-plain/package.json | 6 ++++++ packages/signer-p12/README.md | 1 - packages/signer-p12/package.json | 6 ++++++ packages/signpdf/README.md | 1 - packages/signpdf/package.json | 6 ++++++ packages/utils/README.md | 1 - packages/utils/package.json | 6 ++++++ 17 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..c72f249e --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: ['https://buymeacoffee.com/vbuch?utm_source=github-sponsor-signpdf'] diff --git a/README.md b/README.md index 25b2aec7..50fb8405 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![Known Vulnerabilities](https://snyk.io/test/npm/node-signpdf/badge.svg)](https://snyk.io/test/npm/node-signpdf) ![Coverage as reported by Coveralls](https://img.shields.io/coverallsCoverage/github/vbuch/node-signpdf) ![GitHub last commit](https://img.shields.io/github/last-commit/vbuch/node-signpdf?color=red) -[![Donate to this project using Buy Me A Coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://buymeacoffee.com/vbuch) Formerly known as [`node-signpdf`](https://www.npmjs.com/package/node-signpdf) `@signpdf` is a family of packages trying to make signing of PDFs simple in Node.js. diff --git a/package.json b/package.json index b29b2d90..0fe952c3 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,12 @@ "type": "git", "url": "https://github.com/vbuch/node-signpdf" }, + "funding": [ + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } + ], "license": "MIT", "engines": { "node": ">=12" diff --git a/packages/placeholder-pdf-lib/README.md b/packages/placeholder-pdf-lib/README.md index 073fc509..a8e156ef 100644 --- a/packages/placeholder-pdf-lib/README.md +++ b/packages/placeholder-pdf-lib/README.md @@ -3,7 +3,6 @@ for [![@signpdf](https://raw.githubusercontent.com/vbuch/node-signpdf/master/resources/logo-horizontal.svg?sanitize=true)](https://github.com/vbuch/node-signpdf/) [![npm version](https://badge.fury.io/js/@signpdf%2Fplaceholder-pdf-lib.svg)](https://badge.fury.io/js/@signpdf%2Fplaceholder-pdf-lib) -[![Donate to this project using Buy Me A Coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://buymeacoffee.com/vbuch) Works with `PDF-LIB` and given a PDFDocument that is in the works, adds an e-signature placeholder. When the PDF is ready you can convert it to Buffer and pass it to `@signpdf/signpdf` to complete the process. diff --git a/packages/placeholder-pdf-lib/package.json b/packages/placeholder-pdf-lib/package.json index 70ed7db0..eabd8f47 100644 --- a/packages/placeholder-pdf-lib/package.json +++ b/packages/placeholder-pdf-lib/package.json @@ -21,6 +21,12 @@ "pades", "digital signature" ], + "funding": [ + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } + ], "main": "dist/pdflibAddPlaceholder.js", "types": "dist/pdflibAddPlaceholder.d.ts", "files": [ diff --git a/packages/placeholder-pdfkit/README.md b/packages/placeholder-pdfkit/README.md index 1d5b2dcf..95fd022f 100644 --- a/packages/placeholder-pdfkit/README.md +++ b/packages/placeholder-pdfkit/README.md @@ -3,7 +3,6 @@ for [![@signpdf](https://raw.githubusercontent.com/vbuch/node-signpdf/master/resources/logo-horizontal.svg?sanitize=true)](https://github.com/vbuch/node-signpdf/) [![npm version](https://badge.fury.io/js/@signpdf%2Fplaceholder-pdfkit.svg)](https://badge.fury.io/js/@signpdf%2Fplaceholder-pdfkit) -[![Donate to this project using Buy Me A Coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://buymeacoffee.com/vbuch) Works on top of `PDFKit 0.11+` and given a PDFDocument that is in the works, adds an e-signature placeholder. When the PDF is ready you can pass it to `@signpdf/signpdf` to complete the process. diff --git a/packages/placeholder-pdfkit/package.json b/packages/placeholder-pdfkit/package.json index 4611f165..2966b66e 100644 --- a/packages/placeholder-pdfkit/package.json +++ b/packages/placeholder-pdfkit/package.json @@ -21,6 +21,12 @@ "pades", "digital signature" ], + "funding": [ + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } + ], "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ diff --git a/packages/placeholder-pdfkit010/README.md b/packages/placeholder-pdfkit010/README.md index 37b4d679..a33f9892 100644 --- a/packages/placeholder-pdfkit010/README.md +++ b/packages/placeholder-pdfkit010/README.md @@ -3,7 +3,6 @@ for [![@signpdf](https://raw.githubusercontent.com/vbuch/node-signpdf/master/resources/logo-horizontal.svg?sanitize=true)](https://github.com/vbuch/node-signpdf/) [![npm version](https://badge.fury.io/js/@signpdf%2Fplaceholder-pdfkit010.svg)](https://badge.fury.io/js/@signpdf%2Fplaceholder-pdfkit010) -[![Donate to this project using Buy Me A Coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://buymeacoffee.com/vbuch) Works on top of `PDFKit 0.10.0` and given a PDFDocument that is in the works, adds an e-signature placeholder. When the PDF is ready you can pass it to `@signpdf/signpdf` to complete the process. diff --git a/packages/placeholder-pdfkit010/package.json b/packages/placeholder-pdfkit010/package.json index d263a133..15273cd3 100644 --- a/packages/placeholder-pdfkit010/package.json +++ b/packages/placeholder-pdfkit010/package.json @@ -21,6 +21,12 @@ "pades", "digital signature" ], + "funding": [ + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } + ], "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ diff --git a/packages/placeholder-plain/README.md b/packages/placeholder-plain/README.md index fd27edcd..dc89dbd0 100644 --- a/packages/placeholder-plain/README.md +++ b/packages/placeholder-plain/README.md @@ -3,7 +3,6 @@ for [![@signpdf](https://raw.githubusercontent.com/vbuch/node-signpdf/master/resources/logo-horizontal.svg?sanitize=true)](https://github.com/vbuch/node-signpdf/) [![npm version](https://badge.fury.io/js/@signpdf%2Fplaceholder-plain.svg)](https://badge.fury.io/js/@signpdf%2Fplaceholder-plain) -[![Donate to this project using Buy Me A Coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://buymeacoffee.com/vbuch) Implements adding e-signature placeholder with plain string operations (.indexOf(), .replace(), .match(), etc.). Because of the lack of semantics it is rather *fragile*. Additionally it doesn't support streams and only works on PDF version <= 1.3. Regardless of those disadvantages this flow seems to be **the most popular among the users of @signpdf**. diff --git a/packages/placeholder-plain/package.json b/packages/placeholder-plain/package.json index dad847f7..e095b19d 100644 --- a/packages/placeholder-plain/package.json +++ b/packages/placeholder-plain/package.json @@ -21,6 +21,12 @@ "pades", "digital signature" ], + "funding": [ + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } + ], "main": "dist/plainAddPlaceholder.js", "files": [ "dist", diff --git a/packages/signer-p12/README.md b/packages/signer-p12/README.md index f44690d7..91d92f27 100644 --- a/packages/signer-p12/README.md +++ b/packages/signer-p12/README.md @@ -3,7 +3,6 @@ for [![@signpdf](https://raw.githubusercontent.com/vbuch/node-signpdf/master/resources/logo-horizontal.svg?sanitize=true)](https://github.com/vbuch/node-signpdf/) [![npm version](https://badge.fury.io/js/@signpdf%2Fsigner-p12.svg)](https://badge.fury.io/js/@signpdf%2Fsigner-p12) -[![Donate to this project using Buy Me A Coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://buymeacoffee.com/vbuch) Uses `node-forge` to create a detached signature of a given `Buffer` using a PKCS#12 certificate bundle. diff --git a/packages/signer-p12/package.json b/packages/signer-p12/package.json index 36177055..c64f7488 100644 --- a/packages/signer-p12/package.json +++ b/packages/signer-p12/package.json @@ -22,6 +22,12 @@ "P12", "digital signature" ], + "funding": [ + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } + ], "main": "dist/P12Signer.js", "types": "dist/P12Signer.d.ts", "files": [ diff --git a/packages/signpdf/README.md b/packages/signpdf/README.md index 598b195a..dd9a4bc4 100644 --- a/packages/signpdf/README.md +++ b/packages/signpdf/README.md @@ -1,7 +1,6 @@ # [![@signpdf](https://raw.githubusercontent.com/vbuch/node-signpdf/master/resources/logo-horizontal.svg?sanitize=true)](/) [![npm version](https://badge.fury.io/js/@signpdf%2Fsignpdf.svg)](https://badge.fury.io/js/@signpdf%2Fsignpdf) -[![Donate to this project using Buy Me A Coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://buymeacoffee.com/vbuch) The main package from the [@signpdf family](/) that tries to make signing of PDFs simple in Node.js. diff --git a/packages/signpdf/package.json b/packages/signpdf/package.json index 589c3f4b..ec0cbcc0 100644 --- a/packages/signpdf/package.json +++ b/packages/signpdf/package.json @@ -21,6 +21,12 @@ "pades", "digital signature" ], + "funding": [ + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } + ], "main": "dist/signpdf.js", "files": [ "dist", diff --git a/packages/utils/README.md b/packages/utils/README.md index 118aaaa4..634ef0fc 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -3,7 +3,6 @@ for [![@signpdf](https://raw.githubusercontent.com/vbuch/node-signpdf/master/resources/logo-horizontal.svg?sanitize=true)](https://github.com/vbuch/node-signpdf/) [![npm version](https://badge.fury.io/js/@signpdf%2Futils.svg)](https://badge.fury.io/js/@signpdf%2Futils) -[![Donate to this project using Buy Me A Coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://buymeacoffee.com/vbuch) ## Usage diff --git a/packages/utils/package.json b/packages/utils/package.json index 1b709f9e..c7aa084a 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -21,6 +21,12 @@ "pades", "digital signature" ], + "funding": [ + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } + ], "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ From 7dafaec26a9e3c4e4a952209d4b185f3acd18bac Mon Sep 17 00:00:00 2001 From: Valery Buchinsky Date: Fri, 15 Mar 2024 12:08:13 +0200 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=91=B7=20=F0=9F=A7=AA=20Add=20types?= =?UTF-8?q?=20checking=20(tsd)=20after=20generating=20the=20.d.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/placeholder-pdf-lib/index.test-d.ts | 1 + packages/placeholder-pdf-lib/package.json | 19 ++-- packages/placeholder-pdfkit/index.test-d.ts | 1 + packages/placeholder-pdfkit/package.json | 19 ++-- .../placeholder-pdfkit010/index.test-d.ts | 1 + packages/placeholder-pdfkit010/package.json | 19 ++-- packages/placeholder-plain/index.test-d.ts | 1 + packages/placeholder-plain/package.json | 20 ++-- packages/signer-p12/index.test-d.ts | 1 + packages/signer-p12/package.json | 19 ++-- packages/signpdf/index.test-d.ts | 1 + packages/signpdf/package.json | 20 ++-- yarn.lock | 95 ++++++++++++++++++- 13 files changed, 176 insertions(+), 41 deletions(-) create mode 100644 packages/placeholder-pdf-lib/index.test-d.ts create mode 100644 packages/placeholder-pdfkit/index.test-d.ts create mode 100644 packages/placeholder-pdfkit010/index.test-d.ts create mode 100644 packages/placeholder-plain/index.test-d.ts create mode 100644 packages/signer-p12/index.test-d.ts create mode 100644 packages/signpdf/index.test-d.ts diff --git a/packages/placeholder-pdf-lib/index.test-d.ts b/packages/placeholder-pdf-lib/index.test-d.ts new file mode 100644 index 00000000..ec061b2d --- /dev/null +++ b/packages/placeholder-pdf-lib/index.test-d.ts @@ -0,0 +1 @@ +import './dist/pdflibAddPlaceholder' \ No newline at end of file diff --git a/packages/placeholder-pdf-lib/package.json b/packages/placeholder-pdf-lib/package.json index eabd8f47..e918db99 100644 --- a/packages/placeholder-pdf-lib/package.json +++ b/packages/placeholder-pdf-lib/package.json @@ -22,10 +22,10 @@ "digital signature" ], "funding": [ - { - "type": "individual", - "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" - } + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } ], "main": "dist/pdflibAddPlaceholder.js", "types": "dist/pdflibAddPlaceholder.d.ts", @@ -40,8 +40,14 @@ }, "scripts": { "test": "jest", - "build": "rm -rf ./dist/* & babel ./src -d ./dist --ignore \"**/*.test.js\" & tsc", - "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./" + "build": "yarn build:clean && yarn build:compile && yarn build:types", + "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", + + "build:clean": "rm -rf ./dist/*", + "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", + "build:types": "yarn build:types:compile && yarn build:types:verify", + "build:types:compile": "tsc", + "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { "@signpdf/utils": "^3.2.3" @@ -73,6 +79,7 @@ "jest": "^27.3.1", "node-forge": "^1.2.1", "pdf-lib": "^1.17.1", + "tsd": "^0.30.7", "typescript": "^5.2.2" }, "gitHead": "56f621c5b6b240f363927cdab47ec8e0bb9fa180" diff --git a/packages/placeholder-pdfkit/index.test-d.ts b/packages/placeholder-pdfkit/index.test-d.ts new file mode 100644 index 00000000..20b3c3eb --- /dev/null +++ b/packages/placeholder-pdfkit/index.test-d.ts @@ -0,0 +1 @@ +import './dist' \ No newline at end of file diff --git a/packages/placeholder-pdfkit/package.json b/packages/placeholder-pdfkit/package.json index 2966b66e..8411f31d 100644 --- a/packages/placeholder-pdfkit/package.json +++ b/packages/placeholder-pdfkit/package.json @@ -22,10 +22,10 @@ "digital signature" ], "funding": [ - { - "type": "individual", - "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" - } + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } ], "main": "dist/index.js", "types": "dist/index.d.ts", @@ -40,8 +40,14 @@ }, "scripts": { "test": "jest", - "build": "rm -rf ./dist/* & babel ./src -d ./dist --ignore \"**/*.test.js\" & tsc", - "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./" + "build": "yarn build:clean && yarn build:compile && yarn build:types", + "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", + + "build:clean": "rm -rf ./dist/*", + "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", + "build:types": "yarn build:types:compile && yarn build:types:verify", + "build:types:compile": "tsc", + "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { "@signpdf/utils": "^3.2.3" @@ -73,6 +79,7 @@ "jest": "^27.3.1", "node-forge": "^1.2.1", "pdfkit": "^0.11.0", + "tsd": "^0.30.7", "typescript": "^5.2.2" } } diff --git a/packages/placeholder-pdfkit010/index.test-d.ts b/packages/placeholder-pdfkit010/index.test-d.ts new file mode 100644 index 00000000..20b3c3eb --- /dev/null +++ b/packages/placeholder-pdfkit010/index.test-d.ts @@ -0,0 +1 @@ +import './dist' \ No newline at end of file diff --git a/packages/placeholder-pdfkit010/package.json b/packages/placeholder-pdfkit010/package.json index 15273cd3..9e8aa519 100644 --- a/packages/placeholder-pdfkit010/package.json +++ b/packages/placeholder-pdfkit010/package.json @@ -22,10 +22,10 @@ "digital signature" ], "funding": [ - { - "type": "individual", - "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" - } + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } ], "main": "dist/index.js", "types": "dist/index.d.ts", @@ -40,8 +40,14 @@ }, "scripts": { "test": "jest", - "build": "rm -rf ./dist/* & babel ./src -d ./dist --ignore \"**/*.test.js\" & tsc", - "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./" + "build": "yarn build:clean && yarn build:compile && yarn build:types", + "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", + + "build:clean": "rm -rf ./dist/*", + "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", + "build:types": "yarn build:types:compile && yarn build:types:verify", + "build:types:compile": "tsc", + "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { "@signpdf/utils": "^3.2.3" @@ -73,6 +79,7 @@ "jest": "^27.3.1", "node-forge": "^1.2.1", "pdfkit": "~0.10.0", + "tsd": "^0.30.7", "typescript": "^5.2.2" }, "gitHead": "5d5ec00c21e072613acb9776c7c6ac7697314955" diff --git a/packages/placeholder-plain/index.test-d.ts b/packages/placeholder-plain/index.test-d.ts new file mode 100644 index 00000000..58cbf8cb --- /dev/null +++ b/packages/placeholder-plain/index.test-d.ts @@ -0,0 +1 @@ +import './dist/plainAddPlaceholder' \ No newline at end of file diff --git a/packages/placeholder-plain/package.json b/packages/placeholder-plain/package.json index e095b19d..80228ada 100644 --- a/packages/placeholder-plain/package.json +++ b/packages/placeholder-plain/package.json @@ -22,12 +22,13 @@ "digital signature" ], "funding": [ - { - "type": "individual", - "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" - } + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } ], "main": "dist/plainAddPlaceholder.js", + "types": "dist/plainAddPlaceholder.d.ts", "files": [ "dist", "LICENSE", @@ -38,8 +39,14 @@ }, "scripts": { "test": "./node_modules/.bin/jest", - "build": "rm -rf ./dist/* & ./node_modules/.bin/babel ./src -d ./dist --ignore \"**/*.test.js\" & tsc", - "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./" + "build": "yarn build:clean && yarn build:compile && yarn build:types", + "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", + + "build:clean": "rm -rf ./dist/*", + "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", + "build:types": "yarn build:types:compile && yarn build:types:verify", + "build:types:compile": "tsc", + "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { "@signpdf/placeholder-pdfkit010": "^3.2.3", @@ -68,6 +75,7 @@ "jest": "^27.3.1", "node-forge": "^1.2.1", "pdfkit": "~0.10.0", + "tsd": "^0.30.7", "typescript": "^5.2.2" }, "gitHead": "5d5ec00c21e072613acb9776c7c6ac7697314955" diff --git a/packages/signer-p12/index.test-d.ts b/packages/signer-p12/index.test-d.ts new file mode 100644 index 00000000..f8800b46 --- /dev/null +++ b/packages/signer-p12/index.test-d.ts @@ -0,0 +1 @@ +import './dist/P12Signer' \ No newline at end of file diff --git a/packages/signer-p12/package.json b/packages/signer-p12/package.json index c64f7488..27c22514 100644 --- a/packages/signer-p12/package.json +++ b/packages/signer-p12/package.json @@ -23,10 +23,10 @@ "digital signature" ], "funding": [ - { - "type": "individual", - "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" - } + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } ], "main": "dist/P12Signer.js", "types": "dist/P12Signer.d.ts", @@ -41,8 +41,14 @@ }, "scripts": { "test": "jest", - "build": "rm -rf ./dist/* & babel ./src -d ./dist --ignore \"**/*.test.js\" & tsc", - "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./" + "build": "yarn build:clean && yarn build:compile && yarn build:types", + "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", + + "build:clean": "rm -rf ./dist/*", + "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", + "build:types": "yarn build:types:compile && yarn build:types:verify", + "build:types:compile": "tsc", + "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { "@signpdf/utils": "^3.2.3" @@ -74,6 +80,7 @@ "jest": "^27.3.1", "node-forge": "^1.2.1", "pdfkit": "~0.10.0", + "tsd": "^0.30.7", "typescript": "^5.2.2" }, "gitHead": "5d5ec00c21e072613acb9776c7c6ac7697314955" diff --git a/packages/signpdf/index.test-d.ts b/packages/signpdf/index.test-d.ts new file mode 100644 index 00000000..4a71812a --- /dev/null +++ b/packages/signpdf/index.test-d.ts @@ -0,0 +1 @@ +import './dist/signpdf' \ No newline at end of file diff --git a/packages/signpdf/package.json b/packages/signpdf/package.json index ec0cbcc0..2eda413e 100644 --- a/packages/signpdf/package.json +++ b/packages/signpdf/package.json @@ -22,12 +22,13 @@ "digital signature" ], "funding": [ - { - "type": "individual", - "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" - } + { + "type": "individual", + "url": "https://buymeacoffee.com/vbuch?utm_source=npm-funding-signpdf" + } ], "main": "dist/signpdf.js", + "types": "dist/signpdf.d.ts", "files": [ "dist", "LICENSE", @@ -38,8 +39,14 @@ }, "scripts": { "test": "./node_modules/.bin/jest", - "build": "rm -rf ./dist/* & ./node_modules/.bin/babel ./src -d ./dist --ignore \"**/*.test.js\" & tsc", - "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./" + "build": "yarn build:clean && yarn build:compile && yarn build:types", + "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", + + "build:clean": "rm -rf ./dist/*", + "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", + "build:types": "yarn build:types:compile && yarn build:types:verify", + "build:types:compile": "tsc", + "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { "@signpdf/utils": "^3.2.3" @@ -71,6 +78,7 @@ "jest": "^27.3.1", "node-forge": "^1.2.1", "pdfkit": "~0.10.0", + "tsd": "^0.30.7", "typescript": "^5.2.2" }, "gitHead": "5d5ec00c21e072613acb9776c7c6ac7697314955" diff --git a/yarn.lock b/yarn.lock index 8a600b8a..8ba0b5c4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1784,6 +1784,11 @@ resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== +"@tsd/typescript@~5.3.3": + version "5.3.3" + resolved "https://registry.yarnpkg.com/@tsd/typescript/-/typescript-5.3.3.tgz#bc01854b6e0e746b5f70a6b48c30c7b95b81a74e" + integrity sha512-CQlfzol0ldaU+ftWuG52vH29uRoKboLinLy84wS8TQOu+m+tWoaUfk4svL4ij2V8M5284KymJBlHUusKj6k34w== + "@tufjs/canonical-json@1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@tufjs/canonical-json/-/canonical-json-1.0.0.tgz#eade9fd1f537993bc1f0949f3aea276ecc4fab31" @@ -1830,6 +1835,19 @@ dependencies: "@babel/types" "^7.20.7" +"@types/eslint@^7.2.13": + version "7.29.0" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.29.0.tgz#e56ddc8e542815272720bb0b4ccc2aff9c3e1c78" + integrity sha512-VNcvioYDH8/FxaeTKkM4/TiTwt6pBV9E3OfGmvaw8tPl0rrHCJ4Ll15HRT+pMiFAf/MLQvAzC+6RzUMEL9Ceng== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" + integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== + "@types/graceful-fs@^4.1.2": version "4.1.7" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.7.tgz#30443a2e64fd51113bc3e2ba0914d47109695e2a" @@ -1856,6 +1874,11 @@ dependencies: "@types/istanbul-lib-report" "*" +"@types/json-schema@*": + version "7.0.15" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" + integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== + "@types/json-schema@^7.0.9": version "7.0.13" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.13.tgz#02c24f4363176d2d18fc8b70b9f3c54aba178a85" @@ -3061,7 +3084,7 @@ decamelize-keys@^1.1.0: decamelize "^1.1.0" map-obj "^1.0.0" -decamelize@^1.1.0: +decamelize@^1.1.0, decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA== @@ -3480,6 +3503,20 @@ eslint-config-airbnb-base@^15.0.0: object.entries "^1.1.5" semver "^6.3.0" +eslint-formatter-pretty@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/eslint-formatter-pretty/-/eslint-formatter-pretty-4.1.0.tgz#7a6877c14ffe2672066c853587d89603e97c7708" + integrity sha512-IsUTtGxF1hrH6lMWiSl1WbGaiP01eT6kzywdY1U+zLc0MP+nwEnUiS9UI8IaOTUhTeQJLlCEWIbXINBH4YJbBQ== + dependencies: + "@types/eslint" "^7.2.13" + ansi-escapes "^4.2.1" + chalk "^4.1.0" + eslint-rule-docs "^1.1.5" + log-symbols "^4.0.0" + plur "^4.0.0" + string-width "^4.2.0" + supports-hyperlinks "^2.0.0" + eslint-import-resolver-babel-module@^5.3.1: version "5.3.2" resolved "https://registry.yarnpkg.com/eslint-import-resolver-babel-module/-/eslint-import-resolver-babel-module-5.3.2.tgz#67ed1cd2689d97e9566a8dbc2c6483671a6bde33" @@ -3534,6 +3571,11 @@ eslint-plugin-jest@^25.2.4: dependencies: "@typescript-eslint/experimental-utils" "^5.0.0" +eslint-rule-docs@^1.1.5: + version "1.1.235" + resolved "https://registry.yarnpkg.com/eslint-rule-docs/-/eslint-rule-docs-1.1.235.tgz#be6ef1fc3525f17b3c859ae2997fedadc89bfb9b" + integrity sha512-+TQ+x4JdTnDoFEXXb3fDvfGOwnyNV7duH8fXWTPD1ieaBmB8omj7Gw/pMBBu4uI2uJCCU8APDaQJzWuXnTsH4A== + eslint-scope@5.1.1, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" @@ -4217,7 +4259,7 @@ globalthis@^1.0.3: dependencies: define-properties "^1.1.3" -globby@11.1.0, globby@^11.1.0: +globby@11.1.0, globby@^11.0.1, globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== @@ -4559,6 +4601,11 @@ ip@^2.0.0: resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.1.tgz#e8f3595d33a3ea66490204234b77636965307105" integrity sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ== +irregular-plurals@^3.2.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-3.5.0.tgz#0835e6639aa8425bdc8b0d33d0dc4e89d9c01d2b" + integrity sha512-1ANGLZ+Nkv1ptFb2pa8oG8Lem4krflKuX/gINiHJHjJUKaJHk/SXk5x6K3J+39/p0h1RQ2saROclJJ+QLvETCQ== + is-arguments@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" @@ -4990,7 +5037,7 @@ jest-config@^27.5.1: slash "^3.0.0" strip-json-comments "^3.1.1" -"jest-diff@>=29.4.3 < 30", jest-diff@^29.4.1: +"jest-diff@>=29.4.3 < 30", jest-diff@^29.0.3, jest-diff@^29.4.1: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.7.0.tgz#017934a66ebb7ecf6f205e84699be10afd70458a" integrity sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw== @@ -5730,7 +5777,7 @@ log-driver@^1.2.7: resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.7.tgz#63b95021f0702fedfa2c9bb0a24e7797d71871d8" integrity sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg== -log-symbols@^4.1.0: +log-symbols@^4.0.0, log-symbols@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== @@ -5844,6 +5891,24 @@ meow@^8.1.2: type-fest "^0.18.0" yargs-parser "^20.2.3" +meow@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-9.0.0.tgz#cd9510bc5cac9dee7d03c73ee1f9ad959f4ea364" + integrity sha512-+obSblOQmRhcyBt62furQqRAQpNyWXo8BuQ5bN7dG8wmwQ+vwHKp/rCFD4CrTP8CsDQD1sjoZ94K417XEUk8IQ== + dependencies: + "@types/minimist" "^1.2.0" + camelcase-keys "^6.2.2" + decamelize "^1.2.0" + decamelize-keys "^1.1.0" + hard-rejection "^2.1.0" + minimist-options "4.1.0" + normalize-package-data "^3.0.0" + read-pkg-up "^7.0.1" + redent "^3.0.0" + trim-newlines "^3.0.0" + type-fest "^0.18.0" + yargs-parser "^20.2.3" + merge-source-map@1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.0.4.tgz#a5de46538dae84d4114cc5ea02b4772a6346701f" @@ -6836,6 +6901,13 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" +plur@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/plur/-/plur-4.0.0.tgz#729aedb08f452645fe8c58ef115bf16b0a73ef84" + integrity sha512-4UGewrYgqDFw9vV6zNV+ADmPAUAfJPKtGvb/VdpQAx25X5f3xXdGdyOEVFwkl8Hl/tl7+xbeHqSEM+D5/TirUg== + dependencies: + irregular-plurals "^3.2.0" + png-js@>=0.1.0, png-js@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/png-js/-/png-js-1.0.0.tgz#e5484f1e8156996e383aceebb3789fd75df1874d" @@ -6997,7 +7069,7 @@ read-pkg-up@^3.0.0: find-up "^2.0.0" read-pkg "^3.0.0" -read-pkg-up@^7.0.1: +read-pkg-up@^7.0.0, read-pkg-up@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507" integrity sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg== @@ -7914,6 +7986,19 @@ tsconfig-paths@^4.1.2: minimist "^1.2.6" strip-bom "^3.0.0" +tsd@^0.30.7: + version "0.30.7" + resolved "https://registry.yarnpkg.com/tsd/-/tsd-0.30.7.tgz#319a0403073df6d3f572c4089378901662554ae5" + integrity sha512-oTiJ28D6B/KXoU3ww/Eji+xqHJojiuPVMwA12g4KYX1O72N93Nb6P3P3h2OAhhf92Xl8NIhb/xFmBZd5zw/xUw== + dependencies: + "@tsd/typescript" "~5.3.3" + eslint-formatter-pretty "^4.1.0" + globby "^11.0.1" + jest-diff "^29.0.3" + meow "^9.0.0" + path-exists "^4.0.0" + read-pkg-up "^7.0.0" + tslib@^1.11.1, tslib@^1.8.1: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" From f884e3a87f6199181c157e55540ae9ccdb39e022 Mon Sep 17 00:00:00 2001 From: Valery Buchinsky Date: Fri, 15 Mar 2024 12:42:04 +0200 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20=F0=9F=90=9B[placeh?= =?UTF-8?q?older-pdf-lib]=20Fix=20types:=20Import=20PDFPage=20from=20pdf-l?= =?UTF-8?q?ib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #234 --- .../dist/pdflibAddPlaceholder.d.ts | 1 + .../dist/pdflibAddPlaceholder.d.ts.map | 2 +- .../dist/pdflibAddPlaceholder.js | 32 +++++++++++-------- .../src/pdflibAddPlaceholder.js | 32 +++++++++++-------- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts index f8fe6593..b2603c60 100644 --- a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts +++ b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts @@ -1,5 +1,6 @@ export function pdflibAddPlaceholder({ pdfDoc, pdfPage, reason, contactInfo, name, location, signingTime, signatureLength, byteRangePlaceholder, subFilter, widgetRect, appName, }: InputType): void; export type PDFDocument = import('pdf-lib').PDFDocument; +export type PDFPage = import('pdf-lib').PDFPage; export type InputType = { pdfDoc: PDFDocument; pdfPage: PDFPage; diff --git a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map index bc86ec5a..6ceaf8c6 100644 --- a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map +++ b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"pdflibAddPlaceholder.d.ts","sourceRoot":"","sources":["../src/pdflibAddPlaceholder.js"],"names":[],"mappings":"AAwCO,oLAHI,SAAS,GACP,IAAI,CAmHhB;0BA5IY,OAAO,SAAS,EAAE,WAAW;;YAK7B,WAAW;;YAEX,MAAM;iBACN,MAAM;UACN,MAAM;cACN,MAAM;kBACN,IAAI;sBACJ,MAAM;2BACN,MAAM;;;;gBACN,MAAM;;;;iBACN,MAAM,EAAE;;;;cACR,MAAM"} \ No newline at end of file +{"version":3,"file":"pdflibAddPlaceholder.d.ts","sourceRoot":"","sources":["../src/pdflibAddPlaceholder.js"],"names":[],"mappings":"AA4CO,oLAHI,SAAS,GACP,IAAI,CAmHhB;0BAhJY,OAAO,SAAS,EAAE,WAAW;sBAI7B,OAAO,SAAS,EAAE,OAAO;;YAKxB,WAAW;aACX,OAAO;YACP,MAAM;iBACN,MAAM;UACN,MAAM;cACN,MAAM;kBACN,IAAI;sBACJ,MAAM;2BACN,MAAM;;;;gBACN,MAAM;;;;iBACN,MAAM,EAAE;;;;cACR,MAAM"} \ No newline at end of file diff --git a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js index e2c86a08..45a683a0 100644 --- a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js +++ b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js @@ -11,20 +11,24 @@ var _pdfLib = require("pdf-lib"); */ /** -* @typedef {object} InputType -* @property {PDFDocument} pdfDoc -* @property {PDFPage} pdfPage -* @property {string} reason -* @property {string} contactInfo -* @property {string} name -* @property {string} location -* @property {Date} [signingTime] -* @property {number} [signatureLength] -* @property {string} [byteRangePlaceholder] -* @property {string} [subFilter] One of SUBFILTER_* from \@signpdf/utils -* @property {number[]} [widgetRect] [x1, y1, x2, y2] widget rectangle -* @property {string} [appName] Name of the application generating the signature -*/ + * @typedef {import('pdf-lib').PDFPage} PDFPage + */ + +/** + * @typedef {object} InputType + * @property {PDFDocument} pdfDoc + * @property {PDFPage} pdfPage + * @property {string} reason + * @property {string} contactInfo + * @property {string} name + * @property {string} location + * @property {Date} [signingTime] + * @property {number} [signatureLength] + * @property {string} [byteRangePlaceholder] + * @property {string} [subFilter] One of SUBFILTER_* from \@signpdf/utils + * @property {number[]} [widgetRect] [x1, y1, x2, y2] widget rectangle + * @property {string} [appName] Name of the application generating the signature + */ /** * Adds a signature placeholder to a PDF-LIB PDFDocument. diff --git a/packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.js b/packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.js index 8d5efd2c..b2139365 100644 --- a/packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.js +++ b/packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.js @@ -15,20 +15,24 @@ import { */ /** -* @typedef {object} InputType -* @property {PDFDocument} pdfDoc -* @property {PDFPage} pdfPage -* @property {string} reason -* @property {string} contactInfo -* @property {string} name -* @property {string} location -* @property {Date} [signingTime] -* @property {number} [signatureLength] -* @property {string} [byteRangePlaceholder] -* @property {string} [subFilter] One of SUBFILTER_* from \@signpdf/utils -* @property {number[]} [widgetRect] [x1, y1, x2, y2] widget rectangle -* @property {string} [appName] Name of the application generating the signature -*/ + * @typedef {import('pdf-lib').PDFPage} PDFPage + */ + +/** + * @typedef {object} InputType + * @property {PDFDocument} pdfDoc + * @property {PDFPage} pdfPage + * @property {string} reason + * @property {string} contactInfo + * @property {string} name + * @property {string} location + * @property {Date} [signingTime] + * @property {number} [signatureLength] + * @property {string} [byteRangePlaceholder] + * @property {string} [subFilter] One of SUBFILTER_* from \@signpdf/utils + * @property {number[]} [widgetRect] [x1, y1, x2, y2] widget rectangle + * @property {string} [appName] Name of the application generating the signature + */ /** * Adds a signature placeholder to a PDF-LIB PDFDocument. From 1c79a47cf7901030b17db47e9a029f256559c816 Mon Sep 17 00:00:00 2001 From: Valery Buchinsky Date: Fri, 15 Mar 2024 12:46:07 +0200 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20[placeholder-pdf-li?= =?UTF-8?q?b]=20Either=20pdfDoc=20or=20pdfPage=20is=20required,=20not=20bo?= =?UTF-8?q?th?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dist/pdflibAddPlaceholder.d.ts | 13 +++++++++--- .../dist/pdflibAddPlaceholder.d.ts.map | 2 +- .../dist/pdflibAddPlaceholder.js | 20 ++++++++++++++++--- .../src/pdflibAddPlaceholder.js | 20 ++++++++++++++++--- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts index b2603c60..5737c7a9 100644 --- a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts +++ b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts @@ -1,9 +1,9 @@ export function pdflibAddPlaceholder({ pdfDoc, pdfPage, reason, contactInfo, name, location, signingTime, signatureLength, byteRangePlaceholder, subFilter, widgetRect, appName, }: InputType): void; export type PDFDocument = import('pdf-lib').PDFDocument; export type PDFPage = import('pdf-lib').PDFPage; -export type InputType = { - pdfDoc: PDFDocument; - pdfPage: PDFPage; +export type CommonInputType = { + pdfDoc?: PDFDocument; + pdfPage?: PDFPage; reason: string; contactInfo: string; name: string; @@ -24,4 +24,11 @@ export type InputType = { */ appName?: string; }; +export type DocInputType = { + pdfDoc: PDFDocument; +}; +export type PageInputType = { + pdfPage: PDFPage; +}; +export type InputType = CommonInputType & (DocInputType | PageInputType); //# sourceMappingURL=pdflibAddPlaceholder.d.ts.map \ No newline at end of file diff --git a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map index 6ceaf8c6..a675bad3 100644 --- a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map +++ b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"pdflibAddPlaceholder.d.ts","sourceRoot":"","sources":["../src/pdflibAddPlaceholder.js"],"names":[],"mappings":"AA4CO,oLAHI,SAAS,GACP,IAAI,CAmHhB;0BAhJY,OAAO,SAAS,EAAE,WAAW;sBAI7B,OAAO,SAAS,EAAE,OAAO;;YAKxB,WAAW;aACX,OAAO;YACP,MAAM;iBACN,MAAM;UACN,MAAM;cACN,MAAM;kBACN,IAAI;sBACJ,MAAM;2BACN,MAAM;;;;gBACN,MAAM;;;;iBACN,MAAM,EAAE;;;;cACR,MAAM"} \ No newline at end of file +{"version":3,"file":"pdflibAddPlaceholder.d.ts","sourceRoot":"","sources":["../src/pdflibAddPlaceholder.js"],"names":[],"mappings":"AA0DO,oLAHI,SAAS,GACP,IAAI,CAmHhB;0BA9JY,OAAO,SAAS,EAAE,WAAW;sBAI7B,OAAO,SAAS,EAAE,OAAO;;aAKxB,WAAW;cACX,OAAO;YACP,MAAM;iBACN,MAAM;UACN,MAAM;cACN,MAAM;kBACN,IAAI;sBACJ,MAAM;2BACN,MAAM;;;;gBACN,MAAM;;;;iBACN,MAAM,EAAE;;;;cACR,MAAM;;;YAKP,WAAW;;;aAKX,OAAO;;wBAIR,eAAe,GAAG,CAAC,YAAY,GAAG,aAAa,CAAC"} \ No newline at end of file diff --git a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js index 45a683a0..9c87b66b 100644 --- a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js +++ b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js @@ -15,9 +15,9 @@ var _pdfLib = require("pdf-lib"); */ /** - * @typedef {object} InputType - * @property {PDFDocument} pdfDoc - * @property {PDFPage} pdfPage + * @typedef {object} CommonInputType + * @property {PDFDocument} [pdfDoc] + * @property {PDFPage} [pdfPage] * @property {string} reason * @property {string} contactInfo * @property {string} name @@ -30,6 +30,20 @@ var _pdfLib = require("pdf-lib"); * @property {string} [appName] Name of the application generating the signature */ +/** +* @typedef {object} DocInputType +* @property {PDFDocument} pdfDoc +*/ + +/** +* @typedef {object} PageInputType +* @property {PDFPage} pdfPage +*/ + +/** +* @typedef {CommonInputType & (DocInputType | PageInputType)} InputType +*/ + /** * Adds a signature placeholder to a PDF-LIB PDFDocument. * diff --git a/packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.js b/packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.js index b2139365..7758c9fd 100644 --- a/packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.js +++ b/packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.js @@ -19,9 +19,9 @@ import { */ /** - * @typedef {object} InputType - * @property {PDFDocument} pdfDoc - * @property {PDFPage} pdfPage + * @typedef {object} CommonInputType + * @property {PDFDocument} [pdfDoc] + * @property {PDFPage} [pdfPage] * @property {string} reason * @property {string} contactInfo * @property {string} name @@ -34,6 +34,20 @@ import { * @property {string} [appName] Name of the application generating the signature */ +/** +* @typedef {object} DocInputType +* @property {PDFDocument} pdfDoc +*/ + +/** +* @typedef {object} PageInputType +* @property {PDFPage} pdfPage +*/ + +/** +* @typedef {CommonInputType & (DocInputType | PageInputType)} InputType +*/ + /** * Adds a signature placeholder to a PDF-LIB PDFDocument. * From 9dc8fe3b732c831b31cc4cd6693c83b57309cd6b Mon Sep 17 00:00:00 2001 From: Valery Buchinsky Date: Mon, 18 Mar 2024 11:00:50 +0200 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=93=9D=20CHANGELOG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0631b39b..f8d5c1dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## [3.2.4] + +* [placeholder-pdf-lib] Fix typing for `pdf-lib`'s `PDFPage`. +* [placeholder-pdf-lib] Correctly noted that either `pdfDoc` or `pdfPage` is required, not both. +* Introduced `tsd` to verify the types that we generate. + ## [3.2.3] * [examples] Run linting on examples; From 402c4a229b392aa08c290de1bf0b92d398326415 Mon Sep 17 00:00:00 2001 From: Valery Buchinsky Date: Mon, 18 Mar 2024 11:03:18 +0200 Subject: [PATCH 6/6] v3.2.4 --- lerna.json | 2 +- packages/examples/package.json | 8 ++++---- packages/placeholder-pdf-lib/package.json | 5 ++--- packages/placeholder-pdfkit/package.json | 5 ++--- packages/placeholder-pdfkit010/package.json | 5 ++--- packages/placeholder-plain/package.json | 7 +++---- packages/signer-p12/package.json | 5 ++--- packages/signpdf/package.json | 11 +++++------ packages/utils/package.json | 2 +- 9 files changed, 22 insertions(+), 28 deletions(-) diff --git a/lerna.json b/lerna.json index b1912474..646b0d35 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "3.2.3", + "version": "3.2.4", "npmClient": "yarn", "ignoreChanges": [ "*.md", diff --git a/packages/examples/package.json b/packages/examples/package.json index 07ab870e..43b3b26d 100644 --- a/packages/examples/package.json +++ b/packages/examples/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@signpdf/examples", - "version": "3.2.3", + "version": "3.2.4", "description": "", "scripts": { "js": "node src/javascript.js", @@ -16,9 +16,9 @@ "url": "git+https://github.com/vbuch/node-signpdf.git" }, "dependencies": { - "@signpdf/placeholder-plain": "^3.2.3", - "@signpdf/signer-p12": "^3.2.3", - "@signpdf/signpdf": "^3.2.3", + "@signpdf/placeholder-plain": "^3.2.4", + "@signpdf/signer-p12": "^3.2.4", + "@signpdf/signpdf": "^3.2.4", "ts-node": "^10.9.1", "typescript": "^5.2.2" }, diff --git a/packages/placeholder-pdf-lib/package.json b/packages/placeholder-pdf-lib/package.json index e918db99..bff5550b 100644 --- a/packages/placeholder-pdf-lib/package.json +++ b/packages/placeholder-pdf-lib/package.json @@ -1,6 +1,6 @@ { "name": "@signpdf/placeholder-pdf-lib", - "version": "3.2.3", + "version": "3.2.4", "description": "Use PDF-LIB to insert a signature placeholder.", "repository": { "type": "git", @@ -42,7 +42,6 @@ "test": "jest", "build": "yarn build:clean && yarn build:compile && yarn build:types", "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", - "build:clean": "rm -rf ./dist/*", "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", "build:types": "yarn build:types:compile && yarn build:types:verify", @@ -50,7 +49,7 @@ "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { - "@signpdf/utils": "^3.2.3" + "@signpdf/utils": "^3.2.4" }, "peerDependencies": { "pdf-lib": "^1.17.1" diff --git a/packages/placeholder-pdfkit/package.json b/packages/placeholder-pdfkit/package.json index 8411f31d..1fccf56c 100644 --- a/packages/placeholder-pdfkit/package.json +++ b/packages/placeholder-pdfkit/package.json @@ -1,6 +1,6 @@ { "name": "@signpdf/placeholder-pdfkit", - "version": "3.2.3", + "version": "3.2.4", "description": "Use foliojs/PDFKit 0.11+ to insert a signature placeholder.", "repository": { "type": "git", @@ -42,7 +42,6 @@ "test": "jest", "build": "yarn build:clean && yarn build:compile && yarn build:types", "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", - "build:clean": "rm -rf ./dist/*", "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", "build:types": "yarn build:types:compile && yarn build:types:verify", @@ -50,7 +49,7 @@ "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { - "@signpdf/utils": "^3.2.3" + "@signpdf/utils": "^3.2.4" }, "peerDependencies": { "pdfkit": "^0.11.0" diff --git a/packages/placeholder-pdfkit010/package.json b/packages/placeholder-pdfkit010/package.json index 9e8aa519..44c069be 100644 --- a/packages/placeholder-pdfkit010/package.json +++ b/packages/placeholder-pdfkit010/package.json @@ -1,6 +1,6 @@ { "name": "@signpdf/placeholder-pdfkit010", - "version": "3.2.3", + "version": "3.2.4", "description": "Use foliojs/PDFKit 0.10 to insert a signature placeholder.", "repository": { "type": "git", @@ -42,7 +42,6 @@ "test": "jest", "build": "yarn build:clean && yarn build:compile && yarn build:types", "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", - "build:clean": "rm -rf ./dist/*", "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", "build:types": "yarn build:types:compile && yarn build:types:verify", @@ -50,7 +49,7 @@ "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { - "@signpdf/utils": "^3.2.3" + "@signpdf/utils": "^3.2.4" }, "peerDependencies": { "pdfkit": "~0.10.0" diff --git a/packages/placeholder-plain/package.json b/packages/placeholder-plain/package.json index 80228ada..d59e7a89 100644 --- a/packages/placeholder-plain/package.json +++ b/packages/placeholder-plain/package.json @@ -1,6 +1,6 @@ { "name": "@signpdf/placeholder-plain", - "version": "3.2.3", + "version": "3.2.4", "description": "Try to add a signature placeholder to a PDF using plain string modifications.", "repository": { "type": "git", @@ -41,7 +41,6 @@ "test": "./node_modules/.bin/jest", "build": "yarn build:clean && yarn build:compile && yarn build:types", "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", - "build:clean": "rm -rf ./dist/*", "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", "build:types": "yarn build:types:compile && yarn build:types:verify", @@ -49,8 +48,8 @@ "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { - "@signpdf/placeholder-pdfkit010": "^3.2.3", - "@signpdf/utils": "^3.2.3" + "@signpdf/placeholder-pdfkit010": "^3.2.4", + "@signpdf/utils": "^3.2.4" }, "devDependencies": { "@babel/cli": "^7.0.0", diff --git a/packages/signer-p12/package.json b/packages/signer-p12/package.json index 27c22514..ae66a04c 100644 --- a/packages/signer-p12/package.json +++ b/packages/signer-p12/package.json @@ -1,6 +1,6 @@ { "name": "@signpdf/signer-p12", - "version": "3.2.3", + "version": "3.2.4", "description": "Sign using a P12 certificate.", "repository": { "type": "git", @@ -43,7 +43,6 @@ "test": "jest", "build": "yarn build:clean && yarn build:compile && yarn build:types", "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", - "build:clean": "rm -rf ./dist/*", "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", "build:types": "yarn build:types:compile && yarn build:types:verify", @@ -51,7 +50,7 @@ "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { - "@signpdf/utils": "^3.2.3" + "@signpdf/utils": "^3.2.4" }, "peerDependencies": { "node-forge": "^1.2.1" diff --git a/packages/signpdf/package.json b/packages/signpdf/package.json index 2eda413e..a47b750c 100644 --- a/packages/signpdf/package.json +++ b/packages/signpdf/package.json @@ -1,6 +1,6 @@ { "name": "@signpdf/signpdf", - "version": "3.2.3", + "version": "3.2.4", "description": "Simple signing of PDFs in node.", "repository": { "type": "git", @@ -41,7 +41,6 @@ "test": "./node_modules/.bin/jest", "build": "yarn build:clean && yarn build:compile && yarn build:types", "lint": "eslint -c .eslintrc --ignore-path ../../.eslintignore ./", - "build:clean": "rm -rf ./dist/*", "build:compile": "babel ./src -d ./dist --ignore \"**/*.test.js\"", "build:types": "yarn build:types:compile && yarn build:types:verify", @@ -49,7 +48,7 @@ "build:types:verify": "tsd --files=index.test-d.ts" }, "dependencies": { - "@signpdf/utils": "^3.2.3" + "@signpdf/utils": "^3.2.4" }, "devDependencies": { "@babel/cli": "^7.0.0", @@ -60,9 +59,9 @@ "@babel/preset-env": "^7.4.2", "@signpdf/eslint-config": "^3.2.3", "@signpdf/internal-utils": "^3.2.0", - "@signpdf/placeholder-pdfkit010": "^3.2.3", - "@signpdf/placeholder-plain": "^3.2.3", - "@signpdf/signer-p12": "^3.2.3", + "@signpdf/placeholder-pdfkit010": "^3.2.4", + "@signpdf/placeholder-plain": "^3.2.4", + "@signpdf/signer-p12": "^3.2.4", "@types/node": ">=12.0.0", "@types/node-forge": "^1.2.1", "assertion-error": "^1.1.0", diff --git a/packages/utils/package.json b/packages/utils/package.json index c7aa084a..d13327c9 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@signpdf/utils", - "version": "3.2.3", + "version": "3.2.4", "description": "Utilities for the @signpdf packages.", "repository": { "type": "git",