Compare commits

...

6 Commits

Author SHA1 Message Date
6f9c644221 2.0.16 2019-01-12 19:11:39 +01:00
0b26054687 fix(core): update 2019-01-12 19:11:39 +01:00
e3323ed4ef 2.0.15 2019-01-12 13:52:21 +01:00
24f692636c fix(core): update 2019-01-12 13:52:21 +01:00
a9f709ee7b 2.0.14 2019-01-12 13:44:18 +01:00
1b11b637a5 fix(core): update 2019-01-12 13:44:18 +01:00
5 changed files with 41 additions and 13 deletions

8
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartacme",
"version": "2.0.13",
"version": "2.0.16",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1614,9 +1614,9 @@
"integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU="
},
"luxon": {
"version": "1.9.0",
"resolved": "https://verdaccio.lossless.one/luxon/-/luxon-1.9.0.tgz",
"integrity": "sha512-N1kSwtIEhM/gIRGASXPgi1CwfQZX5VTjndYFjOsZdEEtWij2uSoRrgDGWwViZCUNY9Rwh4UVG/TLcUinHM20cA=="
"version": "1.10.0",
"resolved": "https://verdaccio.lossless.one/luxon/-/luxon-1.10.0.tgz",
"integrity": "sha512-ry3GKh//v3isD6oJN5pFWmdh+3GiScwv9q8VgG6fZ2j1guGOol2vVVdo4GBAWCrcq5RHOqSeipqHBnOu/u024Q=="
},
"make-error": {
"version": "1.3.5",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartacme",
"version": "2.0.13",
"version": "2.0.16",
"private": false,
"description": "acme implementation in TypeScript",
"main": "dist/index.js",

View File

@ -5,6 +5,7 @@ import * as interfaces from './interfaces';
import { CertManager } from './smartacme.classes.certmanager';
import { Collection, svDb, unI } from '@pushrocks/smartdata';
import { ICert } from './interfaces';
@plugins.smartdata.Collection(() => {
return CertManager.activeDB;
@ -28,10 +29,12 @@ export class Cert extends plugins.smartdata.SmartDataDbDoc<Cert> implements inte
@svDb()
public csr: string;
constructor(privateKeyArg: string, publicKeyArg: string, csrArg: string) {
constructor(optionsArg: ICert) {
super();
this.privateKey = privateKeyArg;
this.publicKey = publicKeyArg;
this.csr = csrArg;
this.created = optionsArg.created;
this.domainName = optionsArg.domainName;
this.privateKey = optionsArg.privateKey;
this.publicKey = optionsArg.publicKey;
this.csr = optionsArg.csr;
}
}

View File

@ -3,6 +3,7 @@ import { Cert } from './smartacme.classes.cert';
import { SmartAcme } from './smartacme.classes.smartacme';
import * as interfaces from './interfaces';
import { ICert } from './interfaces';
export class CertManager {
@ -61,8 +62,8 @@ export class CertManager {
* @param privateKeyArg
* @param csrArg
*/
public async storeCertificate(privateKeyArg: string, publicKeyArg: string, csrArg: string) {
const cert = new Cert(privateKeyArg, publicKeyArg, csrArg);
public async storeCertificate(optionsArg: ICert) {
const cert = new Cert(optionsArg);
cert.save();
};

View File

@ -5,7 +5,7 @@ import * as interfaces from './interfaces';
import { request } from 'http';
/**
*
* the options for the @see SmartAcme
*/
export interface ISmartAcmeOptions {
accountPrivateKey?: string;
@ -16,6 +16,16 @@ export interface ISmartAcmeOptions {
validateRemoteRequest: () => Promise<boolean>;
}
/**
* class SmartAcme
* can be used for setting up communication with an ACME authority
*
* ```ts
* const mySmartAcmeInstance = new SmartAcme({
* // see ISmartAcmeOptions for options
* })
* ```
*/
export class SmartAcme {
private options: ISmartAcmeOptions;
@ -41,6 +51,9 @@ export class SmartAcme {
/**
* inits the instance
* ```ts
* await myCloudlyInstance.init() // does not support options
* ```
*/
public async init() {
this.privateKey =
@ -99,6 +112,8 @@ export class SmartAcme {
});
}
public async stop() {};
public async getCertificateForDomain(domainArg: string) {
const domain = domainArg;
@ -162,6 +177,15 @@ export class SmartAcme {
console.log(`Private key:\n${key.toString()}`);
console.log(`Certificate:\n${cert.toString()}`);
this.certmanager.storeCertificate(key.toString(), cert.toString(), csr.toString());
await this.certmanager.storeCertificate({
domainName: domainArg,
privateKey: key.toString(),
publicKey: cert.toString(),
csr: csr.toString(),
created: Date.now()
});
const newCertificate = await this.certmanager.retrieveCertificate(domainArg);
return newCertificate;
}
}