fix(core): update

This commit is contained in:
2020-02-10 11:15:47 +00:00
parent ac515f5e80
commit 83afea95e6
11 changed files with 270 additions and 299 deletions

View File

@ -28,22 +28,24 @@ export class Cert extends plugins.smartdata.SmartDataDbDoc<Cert> implements inte
@svDb()
public csr: string;
/**
* computed value for when the certificate is still valid
*/
get validUntil (): number {
return this.created + plugins.smarttime.getMilliSecondsFromUnits({
days: 90
});
get validUntil(): number {
return (
this.created +
plugins.smarttime.getMilliSecondsFromUnits({
days: 90
})
);
}
get isStillValid (): boolean {
const shouldBeValitAtLeastUntil = Date.now() + plugins.smarttime.getMilliSecondsFromUnits({
days: 10
});
get isStillValid(): boolean {
const shouldBeValitAtLeastUntil =
Date.now() +
plugins.smarttime.getMilliSecondsFromUnits({
days: 10
});
return this.validUntil >= shouldBeValitAtLeastUntil;
}

View File

@ -26,15 +26,14 @@ export class CertRemoteClient {
public async getCertificateForDomain(domainNameArg: string): Promise<interfaces.ICert> {
let certificate: interfaces.ICert;
const doRequestCycle = async (): Promise<interfaces.ICert> => {
const responseBody: interfaces.ICertRemoteResponse = (await plugins.smartrequest.postJson(
this.remoteUrl,
{
const responseBody: interfaces.ICertRemoteResponse = (
await plugins.smartrequest.postJson(this.remoteUrl, {
requestBody: <interfaces.ICertRemoteRequest>{
domainName: domainNameArg,
secret: this.secret
}
}
)).body;
})
).body;
switch (responseBody.status as interfaces.TCertStatus) {
case 'pending':
this.logger.log('info', `request for ${domainNameArg} still pending!`);

View File

@ -68,9 +68,9 @@ export class SmartAcme {
this.logger.log('ok', `certificate exists for ${certDomain}. Sending certificate!`);
response = {
status,
certificate: await (await this.certmanager.retrieveCertificate(
certDomain
)).createSavableObject()
certificate: await (
await this.certmanager.retrieveCertificate(certDomain)
).createSavableObject()
};
break;
default:
@ -103,7 +103,7 @@ export class SmartAcme {
*/
public async init() {
this.privateKey =
this.options.accountPrivateKey || (await plugins.acme.forge.createPrivateKey());
this.options.accountPrivateKey || (await plugins.acme.forge.createPrivateKey()).toString();
this.setChallenge = this.options.setChallenge;
this.removeChallenge = this.options.removeChallenge;
@ -165,7 +165,10 @@ export class SmartAcme {
/* Place new order */
const order = await this.client.createOrder({
identifiers: [{ type: 'dns', value: certDomain }, { type: 'dns', value: `*.${certDomain}` }]
identifiers: [
{ type: 'dns', value: certDomain },
{ type: 'dns', value: `*.${certDomain}` }
]
});
/* Get authorizations and select challenges */