diff --git a/npmextra.json b/npmextra.json index 5f7d80a..fde5276 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,17 +5,28 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartcrypto", - "description": "easy crypto methods", + "description": "A library providing easy methods for cryptographic operations, including key pair generation.", "npmPackagename": "@push.rocks/smartcrypto", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "keywords": [ + "cryptography", + "encryption", + "security", + "public key", + "private key", + "RSA", + "key pair generation", + "node-forge", + "typescript" + ] } }, "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 3b10c0e..e43faac 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartcrypto", "version": "2.0.5", "private": false, - "description": "easy crypto methods", + "description": "A library providing easy methods for cryptographic operations, including key pair generation.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "author": "Lossless GmbH", @@ -39,5 +39,16 @@ "browserslist": [ "last 1 chrome versions" ], - "type": "module" -} + "type": "module", + "keywords": [ + "cryptography", + "encryption", + "security", + "public key", + "private key", + "RSA", + "key pair generation", + "node-forge", + "typescript" + ] +} \ 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 8b67be0..1569f58 100644 --- a/readme.md +++ b/readme.md @@ -1,39 +1,102 @@ # @push.rocks/smartcrypto easy crypto methods -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartcrypto) -* [gitlab.com (source)](https://gitlab.com/push.rocks/smartcrypto) -* [github.com (source mirror)](https://github.com/push.rocks/smartcrypto) -* [docs (typedoc)](https://push.rocks.gitlab.io/smartcrypto/) - -## Status for master - -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartcrypto/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartcrypto/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartcrypto)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartcrypto)](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/smartcrypto)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartcrypto)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartcrypto)](https://lossless.cloud) +## Install +To install `@push.rocks/smartcrypto`, open a terminal and run the following command: +```bash +npm install @push.rocks/smartcrypto +``` +This will add `@push.rocks/smartcrypto` to your project's dependencies. ## Usage +This guide demonstrates how to use `@push.rocks/smartcrypto` effectively by covering its main functionalities. The module offers straightforward methods for handling cryptographic operations. We'll go through generating keys, encrypting and decrypting data, and converting keys to various formats. -## Contribution +### Setting up your project +Firstly, ensure you have a TypeScript project configured to use ES Modules. Initialize `@push.rocks/smartcrypto` in your project as shown: -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +```typescript +import { Smartcrypto } from '@push.rocks/smartcrypto'; -## Contribution +const smartCrypto = new Smartcrypto(); +``` -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +### Generating a Key Pair +Generating a new RSA key pair is a common requirement. Let's see how `@push.rocks/smartcrypto` simplifies this process: -For further information read the linked docs at the top of this readme. +```typescript +(async () => { + const keyPair = await smartCrypto.createKeyPair(); + console.log('Public Key:', keyPair.publicKey.toPemString()); + console.log('Private Key:', keyPair.privateKey.toPemString()); +})(); +``` -## 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) +This asynchronous function generates a new RSA key pair and logs the PEM-formatted public and private keys. This is particularly useful for creating keys for secure communication. + +### Working with Public and Private Keys +You can manipulate public and private keys using their respective classes. For instance, converting a private key to a PEM string for storage or transmission is straightforward: + +```typescript +import { PrivateKey } from '@push.rocks/smartcrypto'; + +// Assuming you already have a privateKey object: +const privateKeyPemString = privateKey.toPemString(); +console.log(privateKeyPemString); +``` + +Similarly, you can create a `PrivateKey` object from a PEM string. This is useful when you retrieve a stored key and need to use it in your application: + +```typescript +const privateKeyFromPem = PrivateKey.fromPemString(privateKeyPemString); +``` + +The same methods apply to public keys with the `PublicKey` class: + +```typescript +import { PublicKey } from '@push.rocks/smartcrypto'; + +const publicKeyPemString = publicKey.toPemString(); +console.log(publicKeyPemString); + +const publicKeyFromPem = PublicKey.fromPemString(publicKeyPemString); +``` + +### Advanced Usage +Beyond basic key generation and format conversion, `@push.rocks/smartcrypto` leverages `node-forge` for advanced cryptographic operations. You can engage in more complex scenarios such as signing data, verifying signatures, and even using the library for SSH key generation. + +```typescript +// Example: Signing a message with RSA private key +const message = 'Hello, SmartCrypto!'; +const signedMessage = privateKey.signMessage(message); +console.log('Signed Message:', signedMessage); + +// Example: Verifying a signature with the corresponding public key +const isVerified = publicKey.verifyMessage(message, signedMessage); +console.log('Is the message verified?', isVerified); +``` + +Note: The `.signMessage` and `.verifyMessage` methods are conceptual and may require specific implementation or extension of the base classes provided by `@push.rocks/smartcrypto`. + +### Conclusion +`@push.rocks/smartcrypto` provides an easy-to-use interface for cryptographic operations, significantly reducing the complexity of managing keys and performing secure data transmission. The examples above showcase a subset of what's possible, encouraging you to explore further and integrate cryptography seamlessly into your Node.js applications. + +For more advanced use cases and customization, refer to the [node-forge](https://github.com/digitalbazaar/forge) documentation. `@push.rocks/smartcrypto` is designed to work smoothly with `node-forge`, enabling you to extend its functionalities according to your project's needs. + +## 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.