fix(core): initial, support creation of rsa keypairs
This commit is contained in:
@ -1,3 +1 @@
|
||||
import * as plugins from './smartcrypto.plugins';
|
||||
|
||||
export let standardExport = 'Hi there! :) This is an exported string';
|
||||
export * from './smartcrypto.classes.smartcrypto';
|
||||
|
17
ts/smartcrypto.classes.smartcrypto.ts
Normal file
17
ts/smartcrypto.classes.smartcrypto.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import * as plugins from './smartcrypto.plugins';
|
||||
|
||||
export class Smartcrypto {
|
||||
public static async createRSAKeyPair(): Promise<plugins.nodeForge.pki.KeyPair> {
|
||||
const done = plugins.smartpromise.defer<plugins.nodeForge.pki.KeyPair>();
|
||||
const rsa = plugins.nodeForge.pki.rsa;
|
||||
rsa.generateKeyPair({bits: 2048, workers: 2}, (err, keypair) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
}
|
||||
done.resolve(keypair);
|
||||
// keypair.privateKey, keypair.publicKey
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
}
|
@ -1,4 +1,13 @@
|
||||
const removeme = {};
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
export {
|
||||
removeme
|
||||
}
|
||||
smartpromise
|
||||
};
|
||||
|
||||
// third party scope
|
||||
import * as nodeForge from 'node-forge';
|
||||
|
||||
export {
|
||||
nodeForge
|
||||
};
|
||||
|
Reference in New Issue
Block a user