This commit is contained in:
2019-02-06 09:47:33 +01:00
parent 1d8fb2b296
commit 86929251ba
10 changed files with 92 additions and 98 deletions

View File

@ -7,4 +7,4 @@ export interface ICert {
privateKey: string;
publicKey: string;
csr: string;
}
}

View File

@ -22,10 +22,10 @@ export class Cert extends plugins.smartdata.SmartDataDbDoc<Cert> implements inte
@svDb()
public privateKey: string;
@svDb()
public publicKey: string;
@svDb()
public csr: string;

View File

@ -4,14 +4,12 @@ import { SmartAcme } from './smartacme.classes.smartacme';
import * as interfaces from './interfaces';
export class CertManager {
// =========
// STATIC
// =========
public static activeDB: plugins.smartdata.SmartdataDb;
// =========
// INSTANCE
// =========
@ -20,13 +18,16 @@ export class CertManager {
public pendingMap: plugins.lik.Stringmap;
constructor(smartAcmeArg: SmartAcme,optionsArg: {
mongoDescriptor: plugins.smartdata.IMongoDescriptor;
}) {
constructor(
smartAcmeArg: SmartAcme,
optionsArg: {
mongoDescriptor: plugins.smartdata.IMongoDescriptor;
}
) {
this.mongoDescriptor = optionsArg.mongoDescriptor;
}
public async init () {
public async init() {
// Smartdata DB
this.smartdataDb = new plugins.smartdata.SmartdataDb(this.mongoDescriptor);
await this.smartdataDb.init();
@ -47,17 +48,16 @@ export class CertManager {
domainName
});
if(existingCertificate) {
if (existingCertificate) {
return existingCertificate;
} else {
return null;
}
}
/**
* stores the certificate
* @param optionsArg
* @param optionsArg
*/
public async storeCertificate(optionsArg: interfaces.ICert) {
const cert = new Cert(optionsArg);
@ -65,14 +65,12 @@ export class CertManager {
this.pendingMap.removeString(optionsArg.domainName);
}
public async deleteCertificate(domainNameArg: string) {
}
public async deleteCertificate(domainNameArg: string) {}
/**
* announce a certificate as being in the process of being retrieved
*/
public async announceCertificate (domainNameArg: string) {
public async announceCertificate(domainNameArg: string) {
this.pendingMap.addString(domainNameArg);
}
@ -100,5 +98,5 @@ export class CertManager {
*/
private async checkCerts() {
// TODO
};
}
}

View File

@ -86,7 +86,7 @@ export class SmartAcme {
res.status(200);
res.send(response);
res.end();
}
};
constructor(optionsArg: ISmartAcmeOptions) {
this.options = optionsArg;
@ -142,7 +142,7 @@ export class SmartAcme {
/**
* gets a certificate
* it runs through the following steps
*
*
* * look in the database
* * if in the database return it
* * of not in the database announce it
@ -150,7 +150,7 @@ export class SmartAcme {
* * store it
* * remove it from the pending map (which it go onto by announcing it)
* * retrieve it from the databse and return it
*
*
* @param domainArg
*/
public async getCertificateForDomain(domainArg: string): Promise<Cert> {

View File

@ -11,7 +11,19 @@ import * as smartunique from '@pushrocks/smartunique';
import * as smartstring from '@pushrocks/smartstring';
import * as smarttime from '@pushrocks/smarttime';
export { lik, smartdata, smartdelay, smartdns, smartexpress, smartlog, smartpromise, smartrequest, smartunique, smartstring, smarttime };
export {
lik,
smartdata,
smartdelay,
smartdns,
smartexpress,
smartlog,
smartpromise,
smartrequest,
smartunique,
smartstring,
smarttime
};
// thirs party scope
import * as acme from 'acme-client';