From 7900997a10ccebb3da0ad3a27c898367dbdf7461 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Tue, 1 Oct 2019 19:58:53 +0200 Subject: [PATCH] fix(core): update --- package-lock.json | 12 ++++++------ package.json | 2 +- ts/smartjwt.classes.smartjwt.ts | 25 ++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index bcd4463..8589db6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -139,9 +139,9 @@ } }, "@pushrocks/smartcrypto": { - "version": "1.0.5", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartcrypto/-/smartcrypto-1.0.5.tgz", - "integrity": "sha512-GkvR/3LE5X4BI/SALmHP5m4cgN4O5AwBtNSMESGiGGnWD9/JN3FL17ZtA2oXe09uuskeoUeStPPCEGi1VWIs4Q==", + "version": "1.0.7", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartcrypto/-/smartcrypto-1.0.7.tgz", + "integrity": "sha512-o82yK1AcZCSh4YKJAt2LD4qp2wPBC2UYBgloaNhwv6ixITiF1OtKkVMky6uMhlYzTc+YfGFocl1CC0uVlSAaTw==", "requires": { "@pushrocks/smartpromise": "^3.0.5", "@types/node-forge": "^0.8.6", @@ -149,9 +149,9 @@ }, "dependencies": { "@pushrocks/smartpromise": { - "version": "3.0.5", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.5.tgz", - "integrity": "sha512-9kHBWyDFjQ6cV1rseOfge02EH6huh/mrtqxlFoJoxnMaGWf5F8H3UEsskBBUGI6QKE1Bl8evr74AIKWwJ0r/bA==" + "version": "3.0.6", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz", + "integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg==" } } }, diff --git a/package.json b/package.json index 787a058..6968bb9 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "tslint-config-prettier": "^1.15.0" }, "dependencies": { - "@pushrocks/smartcrypto": "^1.0.5", + "@pushrocks/smartcrypto": "^1.0.7", "@types/jsonwebtoken": "^8.3.4", "jsonwebtoken": "^8.5.1" } diff --git a/ts/smartjwt.classes.smartjwt.ts b/ts/smartjwt.classes.smartjwt.ts index c238b5c..210881d 100644 --- a/ts/smartjwt.classes.smartjwt.ts +++ b/ts/smartjwt.classes.smartjwt.ts @@ -1,7 +1,12 @@ import * as plugins from './smartjwt.plugins'; +export interface ISmartJWTJSONKeypair { + privatePem: string; + publicPem: string; +} + /** - * + * A class to create and validate JWTs and their keys */ export class SmartJwt { public smartcryptoInstance = new plugins.smartcrypto.Smartcrypto(); @@ -42,6 +47,24 @@ export class SmartJwt { this.publicKey = publicKey; } + /** + * gets the currently set kaypair as json + */ + public getKeyPairAsJson(): ISmartJWTJSONKeypair { + return { + privatePem: this.privateKey.toPemString(), + publicPem: this.publicKey.toPemString() + }; + } + + /** + * sets the currently set keypair as json + */ + public setKeyPairAsJson(jsonKeyPair: ISmartJWTJSONKeypair) { + this.privateKey = plugins.smartcrypto.PrivateKey.fromPemString(jsonKeyPair.privatePem); + this.publicKey = plugins.smartcrypto.PublicKey.fromPemString(jsonKeyPair.publicPem); + } + /** * creates a new keypair