fix(readme): add
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
export * from './smartkey.classes.smartkey';
|
||||
export * from './smartkey.classes.keypair';
|
||||
export * from './smartkey.classes.keypair';
|
||||
|
@ -3,34 +3,38 @@ import * as plugins from './smartkey.plugins';
|
||||
/**
|
||||
* represents a keypair
|
||||
*/
|
||||
export class KeyPair {
|
||||
export class KeyPair {
|
||||
// static
|
||||
public static async createKeyPair (passphraseArg = ''): Promise<KeyPair> {
|
||||
public static async createKeyPair(passphraseArg = ''): Promise<KeyPair> {
|
||||
const done = plugins.smartpromise.defer<KeyPair>();
|
||||
plugins.crypto.generateKeyPair('rsa', {
|
||||
modulusLength: 4096,
|
||||
publicKeyEncoding: {
|
||||
type: 'spki',
|
||||
format: 'pem'
|
||||
plugins.crypto.generateKeyPair(
|
||||
'rsa',
|
||||
{
|
||||
modulusLength: 4096,
|
||||
publicKeyEncoding: {
|
||||
type: 'spki',
|
||||
format: 'pem'
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
type: 'pkcs8',
|
||||
format: 'pem',
|
||||
cipher: 'aes-256-cbc',
|
||||
passphrase: passphraseArg
|
||||
}
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
type: 'pkcs8',
|
||||
format: 'pem',
|
||||
cipher: 'aes-256-cbc',
|
||||
passphrase: passphraseArg
|
||||
(err, publicKeyArg, privateKeyArg) => {
|
||||
// convey error
|
||||
if (err) {
|
||||
done.reject(err);
|
||||
throw err;
|
||||
}
|
||||
const keyPairInstance = new KeyPair({
|
||||
privateKey: privateKeyArg,
|
||||
publicKey: publicKeyArg
|
||||
});
|
||||
done.resolve(keyPairInstance);
|
||||
}
|
||||
}, (err, publicKeyArg, privateKeyArg) => {
|
||||
// convey error
|
||||
if (err) {
|
||||
done.reject(err);
|
||||
throw (err);
|
||||
}
|
||||
const keyPairInstance = new KeyPair({
|
||||
privateKey: privateKeyArg,
|
||||
publicKey: publicKeyArg
|
||||
});
|
||||
done.resolve(keyPairInstance);
|
||||
});
|
||||
);
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
@ -38,11 +42,8 @@ export class KeyPair {
|
||||
public publicKey: string;
|
||||
public privateKey: string;
|
||||
|
||||
constructor(optionsArg: {
|
||||
privateKey: string;
|
||||
publicKey: string;
|
||||
}) {
|
||||
constructor(optionsArg: { privateKey: string; publicKey: string }) {
|
||||
this.privateKey = optionsArg.privateKey;
|
||||
this.publicKey = optionsArg.publicKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import * as plugins from './smartkey.plugins';
|
||||
import { KeyPair } from './smartkey.classes.keypair';
|
||||
|
||||
|
||||
export class SmartKey {
|
||||
// instance
|
||||
public async getKeypair(passohrase?: string): Promise<KeyPair> {
|
||||
|
@ -1,13 +1,9 @@
|
||||
// node native
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
export {
|
||||
crypto
|
||||
};
|
||||
export { crypto };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
export {
|
||||
smartpromise
|
||||
};
|
||||
export { smartpromise };
|
||||
|
Reference in New Issue
Block a user