BREAKING CHANGE(structure): renamed classes to avoid confusion
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartacme',
|
||||
version: '4.0.8',
|
||||
description: 'acme with an easy yet powerful interface in TypeScript'
|
||||
version: '5.0.0',
|
||||
description: 'A TypeScript-based ACME client for LetsEncrypt certificate management with a focus on simplicity and power.'
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
export * from './smartacme.classes.smartacme.js';
|
||||
export { Cert } from './smartacme.classes.cert.js';
|
||||
export { SmartacmeCert as Cert } from './smartacme.classes.cert.js';
|
@ -2,15 +2,15 @@ import * as plugins from './smartacme.plugins.js';
|
||||
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
import { CertManager } from './smartacme.classes.certmanager.js';
|
||||
import { SmartacmeCertManager } from './smartacme.classes.certmanager.js';
|
||||
|
||||
import { Collection, svDb, unI } from '@push.rocks/smartdata';
|
||||
|
||||
@plugins.smartdata.Collection(() => {
|
||||
return CertManager.activeDB;
|
||||
return SmartacmeCertManager.activeDB;
|
||||
})
|
||||
export class Cert
|
||||
extends plugins.smartdata.SmartDataDbDoc<Cert, plugins.tsclass.network.ICert>
|
||||
export class SmartacmeCert
|
||||
extends plugins.smartdata.SmartDataDbDoc<SmartacmeCert, plugins.tsclass.network.ICert>
|
||||
implements plugins.tsclass.network.ICert
|
||||
{
|
||||
@unI()
|
||||
|
@ -1,10 +1,10 @@
|
||||
import * as plugins from './smartacme.plugins.js';
|
||||
import { Cert } from './smartacme.classes.cert.js';
|
||||
import { SmartacmeCert } from './smartacme.classes.cert.js';
|
||||
import { SmartAcme } from './smartacme.classes.smartacme.js';
|
||||
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
export class CertManager {
|
||||
export class SmartacmeCertManager {
|
||||
// =========
|
||||
// STATIC
|
||||
// =========
|
||||
@ -16,7 +16,7 @@ export class CertManager {
|
||||
private mongoDescriptor: plugins.smartdata.IMongoDescriptor;
|
||||
public smartdataDb: plugins.smartdata.SmartdataDb;
|
||||
|
||||
public interestMap: plugins.lik.InterestMap<string, Cert>;
|
||||
public interestMap: plugins.lik.InterestMap<string, SmartacmeCert>;
|
||||
|
||||
constructor(
|
||||
smartAcmeArg: SmartAcme,
|
||||
@ -31,7 +31,7 @@ export class CertManager {
|
||||
// Smartdata DB
|
||||
this.smartdataDb = new plugins.smartdata.SmartdataDb(this.mongoDescriptor);
|
||||
await this.smartdataDb.init();
|
||||
CertManager.activeDB = this.smartdataDb;
|
||||
SmartacmeCertManager.activeDB = this.smartdataDb;
|
||||
|
||||
// Pending Map
|
||||
this.interestMap = new plugins.lik.InterestMap((certName) => certName);
|
||||
@ -42,8 +42,8 @@ export class CertManager {
|
||||
* @returns the Cert class or null
|
||||
* @param certDomainNameArg the domain Name to retrieve the vcertificate for
|
||||
*/
|
||||
public async retrieveCertificate(certDomainNameArg: string): Promise<Cert> {
|
||||
const existingCertificate: Cert = await Cert.getInstance<Cert>({
|
||||
public async retrieveCertificate(certDomainNameArg: string): Promise<SmartacmeCert> {
|
||||
const existingCertificate: SmartacmeCert = await SmartacmeCert.getInstance<SmartacmeCert>({
|
||||
domainName: certDomainNameArg,
|
||||
});
|
||||
|
||||
@ -59,7 +59,7 @@ export class CertManager {
|
||||
* @param optionsArg
|
||||
*/
|
||||
public async storeCertificate(optionsArg: plugins.tsclass.network.ICert) {
|
||||
const cert = new Cert(optionsArg);
|
||||
const cert = new SmartacmeCert(optionsArg);
|
||||
await cert.save();
|
||||
const interest = this.interestMap.findInterest(cert.domainName);
|
||||
if (interest) {
|
||||
@ -69,7 +69,7 @@ export class CertManager {
|
||||
}
|
||||
|
||||
public async deleteCertificate(certDomainNameArg: string) {
|
||||
const cert: Cert = await Cert.getInstance<Cert>({
|
||||
const cert: SmartacmeCert = await SmartacmeCert.getInstance<SmartacmeCert>({
|
||||
domainName: certDomainNameArg,
|
||||
});
|
||||
await cert.delete();
|
||||
|
@ -4,7 +4,7 @@ import * as interfaces from './interfaces/index.js';
|
||||
/**
|
||||
* certmatcher is responsible for matching certificates
|
||||
*/
|
||||
export class CertMatcher {
|
||||
export class SmartacmeCertMatcher {
|
||||
/**
|
||||
* creates a domainName for the certificate that will include the broadest scope
|
||||
* for wild card certificates
|
||||
|
@ -1,7 +1,8 @@
|
||||
import * as plugins from './smartacme.plugins.js';
|
||||
import { Cert } from './smartacme.classes.cert.js';
|
||||
import { CertManager } from './smartacme.classes.certmanager.js';
|
||||
import { CertMatcher } from './smartacme.classes.certmatcher.js';
|
||||
import { SmartacmeCert } from './smartacme.classes.cert.js';
|
||||
import { SmartacmeCertManager } from './smartacme.classes.certmanager.js';
|
||||
import { SmartacmeCertMatcher } from './smartacme.classes.certmatcher.js';
|
||||
import { commitinfo } from './00_commitinfo_data.js';
|
||||
|
||||
/**
|
||||
* the options for the class @see SmartAcme
|
||||
@ -31,7 +32,7 @@ export class SmartAcme {
|
||||
// the acme client
|
||||
private client: any;
|
||||
private smartdns = new plugins.smartdns.Smartdns({});
|
||||
public logger: plugins.smartlog.ConsoleLog;
|
||||
public logger: plugins.smartlog.Smartlog;
|
||||
|
||||
// the account private key
|
||||
private privateKey: string;
|
||||
@ -41,34 +42,34 @@ export class SmartAcme {
|
||||
private removeChallenge: (dnsChallengeArg: plugins.tsclass.network.IDnsChallenge) => Promise<any>;
|
||||
|
||||
// certmanager
|
||||
private certmanager: CertManager;
|
||||
private certmatcher: CertMatcher;
|
||||
private certmanager: SmartacmeCertManager;
|
||||
private certmatcher: SmartacmeCertMatcher;
|
||||
|
||||
constructor(optionsArg: ISmartAcmeOptions) {
|
||||
this.options = optionsArg;
|
||||
this.logger = new plugins.smartlog.ConsoleLog();
|
||||
this.logger = plugins.smartlog.Smartlog.createForCommitinfo(commitinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* inits the instance
|
||||
* starts the instance
|
||||
* ```ts
|
||||
* await myCloudlyInstance.init() // does not support options
|
||||
* await myCloudlyInstance.start() // does not support options
|
||||
* ```
|
||||
*/
|
||||
public async init() {
|
||||
public async start() {
|
||||
this.privateKey =
|
||||
this.options.accountPrivateKey || (await plugins.acme.forge.createPrivateKey()).toString();
|
||||
this.setChallenge = this.options.setChallenge;
|
||||
this.removeChallenge = this.options.removeChallenge;
|
||||
|
||||
// CertMangaer
|
||||
this.certmanager = new CertManager(this, {
|
||||
this.certmanager = new SmartacmeCertManager(this, {
|
||||
mongoDescriptor: this.options.mongoDescriptor,
|
||||
});
|
||||
await this.certmanager.init();
|
||||
|
||||
// CertMatcher
|
||||
this.certmatcher = new CertMatcher();
|
||||
this.certmatcher = new SmartacmeCertMatcher();
|
||||
|
||||
// ACME Client
|
||||
this.client = new plugins.acme.Client({
|
||||
@ -107,7 +108,7 @@ export class SmartAcme {
|
||||
*
|
||||
* @param domainArg
|
||||
*/
|
||||
public async getCertificateForDomain(domainArg: string): Promise<Cert> {
|
||||
public async getCertificateForDomain(domainArg: string): Promise<SmartacmeCert> {
|
||||
const certDomainName = this.certmatcher.getCertificateDomainNameByDomainName(domainArg);
|
||||
const retrievedCertificate = await this.certmanager.retrieveCertificate(certDomainName);
|
||||
|
||||
@ -209,4 +210,8 @@ export class SmartAcme {
|
||||
currentDomainInterst.destroy();
|
||||
return newCertificate;
|
||||
}
|
||||
|
||||
public async getAllCertificates(): Promise<SmartacmeCert[]> {
|
||||
return SmartacmeCert.getInstances({});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user