diff --git a/npmextra.json b/npmextra.json index 728d3a0..9e436bb 100644 --- a/npmextra.json +++ b/npmextra.json @@ -14,4 +14,4 @@ "npmGlobalTools": [], "npmAccessLevel": "public" } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 985b95d..a908917 100644 --- a/package.json +++ b/package.json @@ -24,5 +24,16 @@ "@pushrocks/smartpromise": "^3.0.5", "@types/node-forge": "^0.8.6", "node-forge": "^0.9.1" - } -} + }, + "files": [ + "ts/*", + "ts_web/*", + "dist/*", + "dist_web/*", + "dist_ts_web/*", + "assets/*", + "cli.js", + "npmextra.json", + "readme.md" + ] +} \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..ab4ca84 --- /dev/null +++ b/readme.md @@ -0,0 +1,26 @@ +# @pushrocks/smartcrypto +easy crypto methods + +## Availabililty and Links +* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartcrypto) +* [gitlab.com (source)](https://gitlab.com/pushrocks/smartcrypto) +* [github.com (source mirror)](https://github.com/pushrocks/smartcrypto) +* [docs (typedoc)](https://pushrocks.gitlab.io/smartcrypto/) + +## Status for master +[![build status](https://gitlab.com/pushrocks/smartcrypto/badges/master/build.svg)](https://gitlab.com/pushrocks/smartcrypto/commits/master) +[![coverage report](https://gitlab.com/pushrocks/smartcrypto/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartcrypto/commits/master) +[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartcrypto.svg)](https://www.npmjs.com/package/@pushrocks/smartcrypto) +[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartcrypto/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartcrypto) +[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) +[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) +[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) + +## Usage + +For further information read the linked docs at the top of this readme. + +> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) +| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) + +[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) diff --git a/ts/smartcrypto.classes.keypair.ts b/ts/smartcrypto.classes.keypair.ts index cfcf786..5f5c758 100644 --- a/ts/smartcrypto.classes.keypair.ts +++ b/ts/smartcrypto.classes.keypair.ts @@ -7,18 +7,19 @@ export class KeyPair { public static async createNewKeyPair(): Promise { const done = plugins.smartpromise.defer(); const rsa = plugins.nodeForge.pki.rsa; - rsa.generateKeyPair({bits: 2048, workers: 2}, async (err, keypair) => { + rsa.generateKeyPair({ bits: 2048, workers: 2 }, async (err, keypair) => { if (err) { console.log(err); throw err; } - done.resolve(new KeyPair({ - privateKey: new PrivateKey(keypair.privateKey), - publicKey: new PublicKey(keypair.publicKey), - })); - - }); + done.resolve( + new KeyPair({ + privateKey: new PrivateKey(keypair.privateKey), + publicKey: new PublicKey(keypair.publicKey) + }) + ); + }); return done.promise; } @@ -26,11 +27,8 @@ export class KeyPair { public publicKey: PublicKey; public privateKey: PrivateKey; - constructor(optionsArg: { - privateKey: PrivateKey; - publicKey: PublicKey; - }) { + constructor(optionsArg: { privateKey: PrivateKey; publicKey: PublicKey }) { this.privateKey = optionsArg.privateKey; this.publicKey = optionsArg.publicKey; } -} \ No newline at end of file +} diff --git a/ts/smartcrypto.classes.publickey.ts b/ts/smartcrypto.classes.publickey.ts index 46d04d2..606a1c9 100644 --- a/ts/smartcrypto.classes.publickey.ts +++ b/ts/smartcrypto.classes.publickey.ts @@ -7,15 +7,14 @@ export class PublicKey { return new PublicKey(privateKey); } - // INSTANCE public forgePublicKey: plugins.nodeForge.pki.PublicKey; - constructor (publicKeyArg: plugins.nodeForge.pki.PublicKey) { + constructor(publicKeyArg: plugins.nodeForge.pki.PublicKey) { this.forgePublicKey = publicKeyArg; } public toPemString(): string { return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey); } -} \ No newline at end of file +} diff --git a/ts/smartcrypto.classes.smartcrypto.ts b/ts/smartcrypto.classes.smartcrypto.ts index 7eedaf4..41cab3d 100644 --- a/ts/smartcrypto.classes.smartcrypto.ts +++ b/ts/smartcrypto.classes.smartcrypto.ts @@ -2,7 +2,7 @@ import * as plugins from './smartcrypto.plugins'; import { KeyPair } from './smartcrypto.classes.keypair'; export class Smartcrypto { - public async createKeyPair (): Promise { + public async createKeyPair(): Promise { return KeyPair.createNewKeyPair(); - }; -} \ No newline at end of file + } +} diff --git a/ts/smartcrypto.plugins.ts b/ts/smartcrypto.plugins.ts index 6286702..4aa87b4 100644 --- a/ts/smartcrypto.plugins.ts +++ b/ts/smartcrypto.plugins.ts @@ -1,13 +1,9 @@ // @pushrocks scope import * as smartpromise from '@pushrocks/smartpromise'; -export { - smartpromise -}; +export { smartpromise }; // third party scope import * as nodeForge from 'node-forge'; -export { - nodeForge -}; +export { nodeForge };