47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
|
import * as plugins from '../cloudly.plugins.js';
|
||
|
import { Cloudly } from '../cloudly.classes.cloudly.js';
|
||
|
|
||
|
export class LetsencryptConnector {
|
||
|
private cloudlyRef: Cloudly;
|
||
|
private smartacme: plugins.smartacme.SmartAcme;
|
||
|
|
||
|
constructor(cloudlyArg: Cloudly) {
|
||
|
this.cloudlyRef = cloudlyArg;
|
||
|
}
|
||
|
|
||
|
public async getCertificateForDomain(domainName: string) {
|
||
|
const cert = await this.smartacme.getCertificateForDomain(domainName);
|
||
|
return cert;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* inits letsencrypt
|
||
|
*/
|
||
|
public async init() {
|
||
|
this.smartacme = new plugins.smartacme.SmartAcme({
|
||
|
accountEmail: this.cloudlyRef.config.data.letsEncryptEmail,
|
||
|
accountPrivateKey: this.cloudlyRef.config.data.letsEncryptPrivateKey,
|
||
|
environment: this.cloudlyRef.config.data.environment,
|
||
|
setChallenge: async (dnsChallenge) => {
|
||
|
await this.cloudlyRef.cloudflareConnector.cloudflare.convenience.acmeSetDnsChallenge(
|
||
|
dnsChallenge
|
||
|
);
|
||
|
},
|
||
|
removeChallenge: async (dnsChallenge) => {
|
||
|
await this.cloudlyRef.cloudflareConnector.cloudflare.convenience.acmeRemoveDnsChallenge(
|
||
|
dnsChallenge
|
||
|
);
|
||
|
},
|
||
|
mongoDescriptor: this.cloudlyRef.config.data.mongoDescriptor,
|
||
|
});
|
||
|
await this.smartacme.init();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* stops the instance
|
||
|
*/
|
||
|
public async stop() {
|
||
|
await this.smartacme.stop();
|
||
|
}
|
||
|
}
|