fix(core): initial, support creation of rsa keypairs

This commit is contained in:
Philipp Kunz 2019-10-01 14:22:21 +02:00
parent 70d7404b90
commit 44c2adf45d
6 changed files with 54 additions and 15 deletions

19
package-lock.json generated
View File

@ -259,8 +259,7 @@
"@pushrocks/smartpromise": {
"version": "3.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.5.tgz",
"integrity": "sha512-9kHBWyDFjQ6cV1rseOfge02EH6huh/mrtqxlFoJoxnMaGWf5F8H3UEsskBBUGI6QKE1Bl8evr74AIKWwJ0r/bA==",
"dev": true
"integrity": "sha512-9kHBWyDFjQ6cV1rseOfge02EH6huh/mrtqxlFoJoxnMaGWf5F8H3UEsskBBUGI6QKE1Bl8evr74AIKWwJ0r/bA=="
},
"@pushrocks/smartrequest": {
"version": "1.1.36",
@ -406,8 +405,15 @@
"@types/node": {
"version": "12.7.8",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.8.tgz",
"integrity": "sha512-FMdVn84tJJdV+xe+53sYiZS4R5yn1mAIxfj+DVoNiQjTYz1+OYmjwEZr1ev9nU0axXwda0QDbYl06QHanRVH3A==",
"dev": true
"integrity": "sha512-FMdVn84tJJdV+xe+53sYiZS4R5yn1mAIxfj+DVoNiQjTYz1+OYmjwEZr1ev9nU0axXwda0QDbYl06QHanRVH3A=="
},
"@types/node-forge": {
"version": "0.8.6",
"resolved": "https://verdaccio.lossless.one/@types%2fnode-forge/-/node-forge-0.8.6.tgz",
"integrity": "sha512-m2G+ipvx+1+BU4LrwrHcEGDk1MnioEVxTnCrkFsKT+BdDl/8OD3WbtspPFj3osnix9fzDIfy2O9p/AFyH3fTzg==",
"requires": {
"@types/node": "*"
}
},
"@types/through2": {
"version": "2.0.34",
@ -1075,6 +1081,11 @@
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
"dev": true
},
"node-forge": {
"version": "0.9.1",
"resolved": "https://verdaccio.lossless.one/node-forge/-/node-forge-0.9.1.tgz",
"integrity": "sha512-G6RlQt5Sb4GMBzXvhfkeFmbqR6MzhtnT7VTHuLadjkii3rdYHNdw0m8zA4BTxVIh68FicCQ2NSUANpsqkr9jvQ=="
},
"npm-run-path": {
"version": "2.0.2",
"resolved": "https://verdaccio.lossless.one/npm-run-path/-/npm-run-path-2.0.2.tgz",

View File

@ -20,5 +20,9 @@
"tslint": "^5.20.0",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {}
"dependencies": {
"@pushrocks/smartpromise": "^3.0.5",
"@types/node-forge": "^0.8.6",
"node-forge": "^0.9.1"
}
}

View File

@ -1,8 +1,8 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartcrypto from '../ts/index'
import * as smartcrypto from '../ts/index';
tap.test('first test', async () => {
console.log(smartcrypto.standardExport)
})
console.log('hi');
});
tap.start()
tap.start();

View File

@ -1,3 +1 @@
import * as plugins from './smartcrypto.plugins';
export let standardExport = 'Hi there! :) This is an exported string';
export * from './smartcrypto.classes.smartcrypto';

View 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;
}
}

View File

@ -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
};