fix(core): update
This commit is contained in:
@ -1,5 +1 @@
|
||||
import * as plugins from './smartjwt.plugins';
|
||||
|
||||
export class SmartJwt {
|
||||
|
||||
}
|
||||
export * from './smartjwt.classes.smartjwt';
|
||||
|
50
ts/smartjwt.classes.smartjwt.ts
Normal file
50
ts/smartjwt.classes.smartjwt.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import * as plugins from './smartjwt.plugins';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export class SmartJwt {
|
||||
public smartcryptoInstance = new plugins.smartcrypto.Smartcrypto();
|
||||
public publicKey: plugins.smartcrypto.PublicKey;
|
||||
public privateKey: plugins.smartcrypto.PrivateKey;
|
||||
|
||||
constructor() {};
|
||||
|
||||
/**
|
||||
* creates a JWT
|
||||
*/
|
||||
public async createJWT(payloadArg: any) {
|
||||
return plugins.jsonwebtoken.sign(payloadArg, this.privateKey.toPemString());
|
||||
}
|
||||
|
||||
/**
|
||||
* checks a JWT
|
||||
*/
|
||||
public async verifyJWTAndGetData(jwtArg: string) {
|
||||
return plugins.jsonwebtoken.verify(jwtArg, this.publicKey.toPemString());
|
||||
};
|
||||
|
||||
/**
|
||||
* sets a private key to create jwts with
|
||||
*/
|
||||
public async setPrivateKey(privateKey: plugins.smartcrypto.PrivateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets a public key
|
||||
*/
|
||||
public async setPublicKey(publicKey: plugins.smartcrypto.PublicKey) {
|
||||
this.publicKey = publicKey;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* creates a new keypair
|
||||
*/
|
||||
public async createNewKeyPair() {
|
||||
const keypair = await this.smartcryptoInstance.createKeyPair();
|
||||
this.setPrivateKey(keypair.privateKey);
|
||||
this.setPublicKey(keypair.publicKey);
|
||||
}
|
||||
}
|
@ -1,3 +1,11 @@
|
||||
// @pushrocks scope
|
||||
import * as smartcrypto from '@pushrocks/smartcrypto';
|
||||
|
||||
export {
|
||||
smartcrypto
|
||||
};
|
||||
|
||||
// thirdparty scope
|
||||
import * as jsonwebtoken from 'jsonwebtoken';
|
||||
export {
|
||||
jsonwebtoken
|
||||
|
Reference in New Issue
Block a user