fix(core): update

This commit is contained in:
Philipp Kunz 2019-10-01 19:58:53 +02:00
parent 67bba6335c
commit 7900997a10
3 changed files with 31 additions and 8 deletions

12
package-lock.json generated
View File

@ -139,9 +139,9 @@
} }
}, },
"@pushrocks/smartcrypto": { "@pushrocks/smartcrypto": {
"version": "1.0.5", "version": "1.0.7",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartcrypto/-/smartcrypto-1.0.5.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartcrypto/-/smartcrypto-1.0.7.tgz",
"integrity": "sha512-GkvR/3LE5X4BI/SALmHP5m4cgN4O5AwBtNSMESGiGGnWD9/JN3FL17ZtA2oXe09uuskeoUeStPPCEGi1VWIs4Q==", "integrity": "sha512-o82yK1AcZCSh4YKJAt2LD4qp2wPBC2UYBgloaNhwv6ixITiF1OtKkVMky6uMhlYzTc+YfGFocl1CC0uVlSAaTw==",
"requires": { "requires": {
"@pushrocks/smartpromise": "^3.0.5", "@pushrocks/smartpromise": "^3.0.5",
"@types/node-forge": "^0.8.6", "@types/node-forge": "^0.8.6",
@ -149,9 +149,9 @@
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": { "@pushrocks/smartpromise": {
"version": "3.0.5", "version": "3.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.5.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
"integrity": "sha512-9kHBWyDFjQ6cV1rseOfge02EH6huh/mrtqxlFoJoxnMaGWf5F8H3UEsskBBUGI6QKE1Bl8evr74AIKWwJ0r/bA==" "integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
} }
} }
}, },

View File

@ -21,7 +21,7 @@
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartcrypto": "^1.0.5", "@pushrocks/smartcrypto": "^1.0.7",
"@types/jsonwebtoken": "^8.3.4", "@types/jsonwebtoken": "^8.3.4",
"jsonwebtoken": "^8.5.1" "jsonwebtoken": "^8.5.1"
} }

View File

@ -1,7 +1,12 @@
import * as plugins from './smartjwt.plugins'; 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 { export class SmartJwt {
public smartcryptoInstance = new plugins.smartcrypto.Smartcrypto(); public smartcryptoInstance = new plugins.smartcrypto.Smartcrypto();
@ -42,6 +47,24 @@ export class SmartJwt {
this.publicKey = publicKey; 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 * creates a new keypair