From a6da750f40d8bf8f2fc2e00f4f0655a3b8cd19fd Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 18:18:37 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 16 ++++-- package.json | 14 ++++- readme.hints.md | 1 + readme.md | 136 ++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 139 insertions(+), 28 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index 3d0e257..8ebd1d2 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,17 +5,27 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartsign", - "description": "sign documents", + "description": "A library for signing PDF documents.", "npmPackagename": "@push.rocks/smartsign", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "keywords": [ + "PDF signing", + "document signing", + "smartpdf", + "signpdf", + "typescript", + "node.js", + "certificate", + "P12 cert" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "tsdocs": { + "tsdoc": { "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" } } \ No newline at end of file diff --git a/package.json b/package.json index 330cf46..d88723b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartsign", "version": "1.0.5", "private": false, - "description": "sign documents", + "description": "A library for signing PDF documents.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "type": "module", @@ -50,5 +50,15 @@ "cli.js", "npmextra.json", "readme.md" + ], + "keywords": [ + "PDF signing", + "document signing", + "smartpdf", + "signpdf", + "typescript", + "node.js", + "certificate", + "P12 cert" ] -} +} \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index ec94ada..33d6516 100644 --- a/readme.md +++ b/readme.md @@ -1,31 +1,121 @@ # @push.rocks/smartsign + sign documents -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartsign) -* [gitlab.com (source)](https://gitlab.com/push.rocks/smartsign) -* [github.com (source mirror)](https://github.com/push.rocks/smartsign) -* [docs (typedoc)](https://push.rocks.gitlab.io/smartsign/) +## Install -## Status for master +To install @push.rocks/smartsign, run the following command in your terminal: -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartsign/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartsign/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartsign)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartsign)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartsign)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartsign)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartsign)](https://lossless.cloud) +```bash +npm install @push.rocks/smartsign --save +``` + +This will add @push.rocks/smartsign to your project's dependencies and enable you to start using its functionality to sign PDF documents. ## Usage -Use TypeScript for best in class intellisense -For further information read the linked docs at the top of this readme. -## Legal -> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +@push.rocks/smartsign provides a powerful yet simple API designed for signing documents, especially PDFs, in Node.js applications. The package seamlessly integrates with TypeScript, offering comprehensive type support for better development experience. Let's dive into how to use @push.rocks/smartsign in your TypeScript projects. + +### Prerequisites + +Make sure you have a PDF document prepared for signing and a P12 certificate. In a real-world scenario, the P12 certificate should be obtained from a certified authority and securely stored. + +### Setting Up + +First, you'll need to import the `SmartSign` class from the package: + +```typescript +import { SmartSign } from '@push.rocks/smartsign'; +import * as fs from 'fs'; +``` + +Prepare the P12 certificate and the PDF document you intend to sign: + +```typescript +// Load your P12 certificate as a Buffer +const p12CertificatePath = './path/to/your/certificate.p12'; +const p12CertificateBuffer = fs.readFileSync(p12CertificatePath); + +// Specify the path to the PDF you want to sign +const pdfFilePath = './path/to/your/document.pdf'; +``` + +### Initialize and Use SmartSign + +Create an instance of `SmartSign` by passing the P12 certificate buffer to its constructor. Then, start the SmartSign service to prepare it for signing operations: + +```typescript +const smartSignInstance = new SmartSign(p12CertificateBuffer); + +// Start the smartsign instance +await smartSignInstance.start(); +``` + +Once the service is started, you can create a signing envelope for your document. The envelope wraps the document and prepares it for the signing process: + +```typescript +import { SmartPdf, IPdf } from '@push.rocks/smartpdf'; + +// Assume you have loaded your PDF into a SmartPdf instance +const mySmartPdf: SmartPdf = new SmartPdf(); +await mySmartPdf.loadPdf(pdfFilePath); +// Create an envelope for the document +const signingEnvelope = await smartSignInstance.createEnvelopeFromPdf(mySmartPdf); +``` + +At this point, the `signingEnvelope` object can be used to apply various signing operations defined by your business logic. + +### Signing the Document + +With the signing envelope prepared, you can add a signature to the document. Here is a simplified example of how to apply an invisible signature: + +```typescript +// The detailed implementation of applying a signature will depend on the document's requirements +// and the level of customization provided by the @push.rocks/smartsign API. + +await signingEnvelope.signPdf({ /* signature options */ }); +``` + +After signing the document, you can export the signed PDF: + +```typescript +const signedPdfBuffer = await signingEnvelope.exportSignedPdf(); + +// Save the signed PDF to a file +fs.writeFileSync('./path/to/signed_document.pdf', signedPdfBuffer); +``` + +### Finalizing + +Don't forget to stop the SmartSign instance once all operations are completed to release any resources: + +```typescript +await smartSignInstance.stop(); +``` + +### Conclusion + +The @push.rocks/smartsign package offers a streamlined, TypeScript-friendly way to sign PDF documents in your Node.js applications. By leveraging TypeScript, it provides a rich development experience with autocomplete and type checking, ensuring that you can integrate document signing capabilities into your projects efficiently and reliably. + +This introduction covered the basic usage of @push.rocks/smartsign. Depending on your specific use case, you might explore more advanced features and customization options provided by the library, such as signing with visible signatures, timestamping, and handling multiple signatures. + +For further information, consult the [official documentation](https://gitlab.com/push.rocks/smartsign). + +## License and Legal Information + +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. + +**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. + +### Trademarks + +This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH. + +### Company Information + +Task Venture Capital GmbH +Registered at District court Bremen HRB 35230 HB, Germany + +For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. + +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.