import * as plugins from '../smartacme.plugins.js'; import type { ICertManager } from '../interfaces/certmanager.js'; import { SmartacmeCert } from '../smartacme.classes.cert.js'; /** * In-memory certificate manager for mongoless mode. * Stores certificates in memory only and does not connect to MongoDB. */ export class MemoryCertManager implements ICertManager { public interestMap: plugins.lik.InterestMap; private certs: Map = new Map(); constructor() { this.interestMap = new plugins.lik.InterestMap((domain) => domain); } public async init(): Promise { // no-op for in-memory store } public async retrieveCertificate(domainName: string): Promise { return this.certs.get(domainName) ?? null; } public async storeCertificate(cert: SmartacmeCert): Promise { this.certs.set(cert.domainName, cert); const interest = this.interestMap.findInterest(cert.domainName); if (interest) { interest.fullfillInterest(cert); interest.markLost(); } } public async deleteCertificate(domainName: string): Promise { this.certs.delete(domainName); } public async close(): Promise { // no-op } /** * Wipe all certificates from the in-memory store (for testing) */ public async wipe(): Promise { this.certs.clear(); // reset interest map this.interestMap = new plugins.lik.InterestMap((domain) => domain); } }