fix(core): update
This commit is contained in:
@ -7,18 +7,19 @@ export class KeyPair {
|
||||
public static async createNewKeyPair(): Promise<KeyPair> {
|
||||
const done = plugins.smartpromise.defer<KeyPair>();
|
||||
const rsa = plugins.nodeForge.pki.rsa;
|
||||
rsa.generateKeyPair({bits: 2048, workers: 2}, async (err, keypair) => {
|
||||
rsa.generateKeyPair({ bits: 2048, workers: 2 }, async (err, keypair) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
done.resolve(new KeyPair({
|
||||
privateKey: new PrivateKey(keypair.privateKey),
|
||||
publicKey: new PublicKey(keypair.publicKey),
|
||||
}));
|
||||
|
||||
});
|
||||
done.resolve(
|
||||
new KeyPair({
|
||||
privateKey: new PrivateKey(keypair.privateKey),
|
||||
publicKey: new PublicKey(keypair.publicKey)
|
||||
})
|
||||
);
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
@ -26,11 +27,8 @@ export class KeyPair {
|
||||
public publicKey: PublicKey;
|
||||
public privateKey: PrivateKey;
|
||||
|
||||
constructor(optionsArg: {
|
||||
privateKey: PrivateKey;
|
||||
publicKey: PublicKey;
|
||||
}) {
|
||||
constructor(optionsArg: { privateKey: PrivateKey; publicKey: PublicKey }) {
|
||||
this.privateKey = optionsArg.privateKey;
|
||||
this.publicKey = optionsArg.publicKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,15 +7,14 @@ export class PublicKey {
|
||||
return new PublicKey(privateKey);
|
||||
}
|
||||
|
||||
|
||||
// INSTANCE
|
||||
public forgePublicKey: plugins.nodeForge.pki.PublicKey;
|
||||
|
||||
constructor (publicKeyArg: plugins.nodeForge.pki.PublicKey) {
|
||||
constructor(publicKeyArg: plugins.nodeForge.pki.PublicKey) {
|
||||
this.forgePublicKey = publicKeyArg;
|
||||
}
|
||||
|
||||
public toPemString(): string {
|
||||
return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import * as plugins from './smartcrypto.plugins';
|
||||
import { KeyPair } from './smartcrypto.classes.keypair';
|
||||
|
||||
export class Smartcrypto {
|
||||
public async createKeyPair (): Promise<KeyPair> {
|
||||
public async createKeyPair(): Promise<KeyPair> {
|
||||
return KeyPair.createNewKeyPair();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,9 @@
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
export {
|
||||
smartpromise
|
||||
};
|
||||
export { smartpromise };
|
||||
|
||||
// third party scope
|
||||
import * as nodeForge from 'node-forge';
|
||||
|
||||
export {
|
||||
nodeForge
|
||||
};
|
||||
export { nodeForge };
|
||||
|
Reference in New Issue
Block a user