fix(core): update
This commit is contained in:
@ -1,3 +1,2 @@
|
||||
import * as plugins from './smartkey.plugins';
|
||||
|
||||
export let standardExport = 'Hi there! :) This is an exported string';
|
||||
export * from './smartkey.classes.smartkey';
|
||||
export * from './smartkey.classes.keypair';
|
48
ts/smartkey.classes.keypair.ts
Normal file
48
ts/smartkey.classes.keypair.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import * as plugins from './smartkey.plugins';
|
||||
|
||||
/**
|
||||
* represents a keypair
|
||||
*/
|
||||
export class KeyPair {
|
||||
// static
|
||||
public static async createKeyPair (passphraseArg = ''): Promise<KeyPair> {
|
||||
const done = plugins.smartpromise.defer<KeyPair>();
|
||||
plugins.crypto.generateKeyPair('rsa', {
|
||||
modulusLength: 4096,
|
||||
publicKeyEncoding: {
|
||||
type: 'spki',
|
||||
format: 'pem'
|
||||
},
|
||||
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);
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
// instance
|
||||
public publicKey: string;
|
||||
public privateKey: string;
|
||||
|
||||
constructor(optionsArg: {
|
||||
privateKey: string;
|
||||
publicKey: string;
|
||||
}) {
|
||||
this.privateKey = optionsArg.privateKey;
|
||||
this.publicKey = optionsArg.publicKey;
|
||||
}
|
||||
}
|
10
ts/smartkey.classes.smartkey.ts
Normal file
10
ts/smartkey.classes.smartkey.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import * as plugins from './smartkey.plugins';
|
||||
import { KeyPair } from './smartkey.classes.keypair';
|
||||
|
||||
|
||||
export class SmartKey {
|
||||
// instance
|
||||
public async getKeypair(passohrase?: string): Promise<KeyPair> {
|
||||
return KeyPair.createKeyPair();
|
||||
}
|
||||
}
|
@ -1,4 +1,13 @@
|
||||
const removeme = {};
|
||||
// node native
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
export {
|
||||
removeme
|
||||
}
|
||||
crypto
|
||||
};
|
||||
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
export {
|
||||
smartpromise
|
||||
};
|
||||
|
Reference in New Issue
Block a user