fix(core): update
This commit is contained in:
10
ts/smartacme.classes.certmatcher.ts
Normal file
10
ts/smartacme.classes.certmatcher.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import * as plugins from './smartacme.plugins';
|
||||
|
||||
export class CertMatcher {
|
||||
public getCertificateDomainNameByDomainName(domainNameArg: string): string {
|
||||
const originalDomain = new plugins.smartstring.Domain(domainNameArg);
|
||||
if (!originalDomain.level4) {
|
||||
return `${originalDomain.level2}.${originalDomain.level1}`;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import * as plugins from './smartacme.plugins';
|
||||
import { Cert } from './smartacme.classes.cert';
|
||||
import { CertManager } from './smartacme.classes.certmanager';
|
||||
import { CertMatcher } from './smartacme.classes.certmatcher';
|
||||
|
||||
import * as interfaces from './interfaces';
|
||||
import { request } from 'http';
|
||||
@ -44,6 +45,7 @@ export class SmartAcme {
|
||||
|
||||
// certmanager
|
||||
private certmanager: CertManager;
|
||||
private certmatcher: CertMatcher;
|
||||
private certremoteHandler: plugins.smartexpress.Handler;
|
||||
|
||||
constructor(optionsArg: ISmartAcmeOptions) {
|
||||
@ -68,6 +70,9 @@ export class SmartAcme {
|
||||
});
|
||||
await this.certmanager.init();
|
||||
|
||||
// CertMatcher
|
||||
this.certmatcher = new CertMatcher();
|
||||
|
||||
// CertRemoteHandler
|
||||
this.certremoteHandler = new plugins.smartexpress.Handler('POST', async (req, res) => {
|
||||
const requestBody: interfaces.ICertRemoteRequest = req.body;
|
||||
@ -118,7 +123,7 @@ export class SmartAcme {
|
||||
}
|
||||
|
||||
public async getCertificateForDomain(domainArg: string): Promise<Cert> {
|
||||
const domain = domainArg;
|
||||
const domain = this.certmatcher.getCertificateDomainNameByDomainName(domainArg);
|
||||
|
||||
const retrievedCertificate = await this.certmanager.retrieveCertificate(domain);
|
||||
|
||||
|
@ -7,9 +7,10 @@ import * as smartexpress from '@pushrocks/smartexpress';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
import * as smarttime from '@pushrocks/smarttime';
|
||||
|
||||
export { lik, smartdata, smartdelay, smartdns, smartexpress, smartpromise, smartrequest, smartunique, smarttime };
|
||||
export { lik, smartdata, smartdelay, smartdns, smartexpress, smartpromise, smartrequest, smartunique, smartstring, smarttime };
|
||||
|
||||
// thirs party scope
|
||||
import * as acme from 'acme-client';
|
||||
|
Reference in New Issue
Block a user