fix(readme): add
This commit is contained in:
parent
b75758882c
commit
503275a6a2
26
readme.md
Normal file
26
readme.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# @pushrocks/smartkey
|
||||||
|
handle private/public key creation
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartkey)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartkey)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartkey)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartkey/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[![build status](https://gitlab.com/pushrocks/smartkey/badges/master/build.svg)](https://gitlab.com/pushrocks/smartkey/commits/master)
|
||||||
|
[![coverage report](https://gitlab.com/pushrocks/smartkey/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartkey/commits/master)
|
||||||
|
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartkey.svg)](https://www.npmjs.com/package/@pushrocks/smartkey)
|
||||||
|
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartkey/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartkey)
|
||||||
|
[![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.html)
|
||||||
|
|
||||||
|
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)
|
@ -7,7 +7,9 @@ export class KeyPair {
|
|||||||
// static
|
// static
|
||||||
public static async createKeyPair(passphraseArg = ''): Promise<KeyPair> {
|
public static async createKeyPair(passphraseArg = ''): Promise<KeyPair> {
|
||||||
const done = plugins.smartpromise.defer<KeyPair>();
|
const done = plugins.smartpromise.defer<KeyPair>();
|
||||||
plugins.crypto.generateKeyPair('rsa', {
|
plugins.crypto.generateKeyPair(
|
||||||
|
'rsa',
|
||||||
|
{
|
||||||
modulusLength: 4096,
|
modulusLength: 4096,
|
||||||
publicKeyEncoding: {
|
publicKeyEncoding: {
|
||||||
type: 'spki',
|
type: 'spki',
|
||||||
@ -19,18 +21,20 @@ export class KeyPair {
|
|||||||
cipher: 'aes-256-cbc',
|
cipher: 'aes-256-cbc',
|
||||||
passphrase: passphraseArg
|
passphrase: passphraseArg
|
||||||
}
|
}
|
||||||
}, (err, publicKeyArg, privateKeyArg) => {
|
},
|
||||||
|
(err, publicKeyArg, privateKeyArg) => {
|
||||||
// convey error
|
// convey error
|
||||||
if (err) {
|
if (err) {
|
||||||
done.reject(err);
|
done.reject(err);
|
||||||
throw (err);
|
throw err;
|
||||||
}
|
}
|
||||||
const keyPairInstance = new KeyPair({
|
const keyPairInstance = new KeyPair({
|
||||||
privateKey: privateKeyArg,
|
privateKey: privateKeyArg,
|
||||||
publicKey: publicKeyArg
|
publicKey: publicKeyArg
|
||||||
});
|
});
|
||||||
done.resolve(keyPairInstance);
|
done.resolve(keyPairInstance);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,10 +42,7 @@ export class KeyPair {
|
|||||||
public publicKey: string;
|
public publicKey: string;
|
||||||
public privateKey: string;
|
public privateKey: string;
|
||||||
|
|
||||||
constructor(optionsArg: {
|
constructor(optionsArg: { privateKey: string; publicKey: string }) {
|
||||||
privateKey: string;
|
|
||||||
publicKey: string;
|
|
||||||
}) {
|
|
||||||
this.privateKey = optionsArg.privateKey;
|
this.privateKey = optionsArg.privateKey;
|
||||||
this.publicKey = optionsArg.publicKey;
|
this.publicKey = optionsArg.publicKey;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import * as plugins from './smartkey.plugins';
|
import * as plugins from './smartkey.plugins';
|
||||||
import { KeyPair } from './smartkey.classes.keypair';
|
import { KeyPair } from './smartkey.classes.keypair';
|
||||||
|
|
||||||
|
|
||||||
export class SmartKey {
|
export class SmartKey {
|
||||||
// instance
|
// instance
|
||||||
public async getKeypair(passohrase?: string): Promise<KeyPair> {
|
public async getKeypair(passohrase?: string): Promise<KeyPair> {
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
// node native
|
// node native
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
||||||
export {
|
export { crypto };
|
||||||
crypto
|
|
||||||
};
|
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
export {
|
export { smartpromise };
|
||||||
smartpromise
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user