fix(smartacme): Refactor module exports and update wildcard certificate support documentation
This commit is contained in:
parent
88ba970494
commit
fe495a5f03
@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-05-05 - 7.2.5 - fix(smartacme)
|
||||
Refactor module exports and update wildcard certificate support documentation
|
||||
|
||||
- Updated readme.plan.md to streamline and remove obsolete wildcard plan details
|
||||
- Normalized certmanager imports by consolidating exports in ts/index.ts and updating tests accordingly
|
||||
- Reordered ISmartAcmeOptions interface properties for clarity (accountEmail moved to the top)
|
||||
|
||||
## 2025-05-04 - 7.2.4 - fix(test)
|
||||
Refactor wildcard certificate test to properly stub SmartAcme.start and getCertificateForDomain for robust integration.
|
||||
|
||||
|
@ -1,27 +1,3 @@
|
||||
# Plan: Add wildcard domain support to SmartAcme
|
||||
## Plan
|
||||
|
||||
## Goal
|
||||
- Enable SmartAcme to accept wildcard domain inputs like `*.domain.com` or `*.sub.example.com` and correctly request and match wildcard certificates.
|
||||
|
||||
## Steps
|
||||
1. [x] Extend SmartacmeCertMatcher:
|
||||
- [x] Update `getCertificateDomainNameByDomainName()` to handle wildcard prefixes:
|
||||
- If input starts with `*.` strip the prefix and return the base domain.
|
||||
- For example:
|
||||
- `*.example.com` → `example.com`
|
||||
- `*.sub.example.com` → `sub.example.com`
|
||||
- `*.a.b.example.com` → `a.b.example.com`
|
||||
- [x] Ensure existing logic for non-wildcards remains unchanged.
|
||||
2. [x] Update `SmartAcme.getCertificateForDomain()`:
|
||||
- [x] Detect wildcard inputs (`domainArg.startsWith('*.')`).
|
||||
- [x] For wildcard cases, enforce DNS-01 challenge only (throw error if handlers don't support DNS-01).
|
||||
- [x] Use the matcher result to request wildcard certificate identifiers (e.g., `value: '*.baseDomain'`).
|
||||
3. [x] Update tests:
|
||||
- [x] Add unit tests in `test/test.certmatcher.ts` for wildcard handling:
|
||||
- `*.example.com` → `example.com`
|
||||
- `*.sub.example.com` → `sub.example.com`
|
||||
- `*.a.b.example.com` → `a.b.example.com`
|
||||
- [x] Add integration stub in `test/test.smartacme.ts` for wildcard input in integration mode:
|
||||
- Call `getCertificateForDomain('*.domain.com')` and expect returned cert `domainName` equals `*.domain.com`.
|
||||
4. [x] Update documentation (README.md) if needed.
|
||||
5. [x] Run CI (`pnpm build` & `pnpm test`) and fix any regressions.
|
||||
Move the
|
@ -1,7 +1,7 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import { Qenv } from '@push.rocks/qenv';
|
||||
import * as cloudflare from '@apiclient.xyz/cloudflare';
|
||||
import { SmartAcme, MongoCertManager, MemoryCertManager } from '../ts/index.js';
|
||||
import { SmartAcme, certmanagers } from '../ts/index.js';
|
||||
import { Dns01Handler } from '../ts/handlers/Dns01Handler.js';
|
||||
|
||||
// Load environment variables for credentials (stored under .nogit/)
|
||||
@ -21,7 +21,7 @@ tap.test('create SmartAcme instance with DNS-01 handler and start', async () =>
|
||||
smartAcmeInstance = new SmartAcme({
|
||||
accountEmail: 'domains@lossless.org',
|
||||
// certManager: new MongoCertManager({ mongoDbName, mongoDbPass, mongoDbUrl }),
|
||||
certManager: new MemoryCertManager(),
|
||||
certManager: new certmanagers.MemoryCertManager(),
|
||||
environment: 'integration',
|
||||
retryOptions: {},
|
||||
challengeHandlers: [new Dns01Handler(cfAccount)],
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import { SmartAcme, MemoryCertManager } from '../ts/index.js';
|
||||
import { SmartAcme, certmanagers } from '../ts/index.js';
|
||||
import { Cert } from '../ts/index.js';
|
||||
import type { IChallengeHandler } from '../ts/handlers/IChallengeHandler.js';
|
||||
|
||||
@ -13,7 +13,7 @@ class DummyHandler implements IChallengeHandler<any> {
|
||||
tap.test('constructor throws without challengeHandlers', async () => {
|
||||
expect(() => new SmartAcme({
|
||||
accountEmail: 'test@example.com',
|
||||
certManager: new MemoryCertManager(),
|
||||
certManager: new certmanagers.MemoryCertManager(),
|
||||
environment: 'integration',
|
||||
retryOptions: {},
|
||||
} as any)).toThrow();
|
||||
@ -22,7 +22,7 @@ tap.test('constructor throws without challengeHandlers', async () => {
|
||||
tap.test('constructor accepts valid challengeHandlers', async () => {
|
||||
const sa = new SmartAcme({
|
||||
accountEmail: 'test@example.com',
|
||||
certManager: new MemoryCertManager(),
|
||||
certManager: new certmanagers.MemoryCertManager(),
|
||||
environment: 'integration',
|
||||
retryOptions: {},
|
||||
challengeHandlers: [new DummyHandler()],
|
||||
@ -41,7 +41,7 @@ tap.test('get wildcard certificate stub in integration mode', async () => {
|
||||
};
|
||||
const sa = new SmartAcme({
|
||||
accountEmail: 'domains@lossless.org',
|
||||
certManager: new MemoryCertManager(),
|
||||
certManager: new certmanagers.MemoryCertManager(),
|
||||
environment: 'integration',
|
||||
retryOptions: {},
|
||||
challengeHandlers: [new DummyHandler()],
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartacme',
|
||||
version: '7.2.4',
|
||||
version: '7.2.5',
|
||||
description: 'A TypeScript-based ACME client for LetsEncrypt certificate management with a focus on simplicity and power.'
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
export * from './smartacme.classes.smartacme.js';
|
||||
export { SmartacmeCert as Cert } from './smartacme.classes.cert.js';
|
||||
export type { ICertManager } from './interfaces/certmanager.js';
|
||||
export { MemoryCertManager, MongoCertManager } from './certmanagers/index.js';
|
||||
import * as certmanagers from './certmanagers/index.js';
|
||||
export { certmanagers };
|
@ -8,8 +8,8 @@ import { SmartacmeCert } from './smartacme.classes.cert.js';
|
||||
* the options for the class @see SmartAcme
|
||||
*/
|
||||
export interface ISmartAcmeOptions {
|
||||
accountPrivateKey?: string;
|
||||
accountEmail: string;
|
||||
accountPrivateKey?: string;
|
||||
/**
|
||||
* Certificate storage manager (e.g., Mongo or in-memory).
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user