2025-05-09 17:28:27 +00:00
|
|
|
/**
|
|
|
|
* Type definitions for SmartAcme interfaces used by ChallengeResponder
|
|
|
|
* These reflect the actual SmartAcme API based on the documentation
|
|
|
|
*/
|
|
|
|
import * as plugins from '../../plugins.js';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Structure for SmartAcme certificate result
|
|
|
|
*/
|
2025-05-09 22:46:53 +00:00
|
|
|
export interface ISmartAcmeCert {
|
2025-05-09 17:28:27 +00:00
|
|
|
id?: string;
|
|
|
|
domainName: string;
|
|
|
|
created?: number | Date | string;
|
|
|
|
privateKey: string;
|
|
|
|
publicKey: string;
|
|
|
|
csr?: string;
|
|
|
|
validUntil: number | Date | string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Structure for SmartAcme options
|
|
|
|
*/
|
2025-05-09 22:46:53 +00:00
|
|
|
export interface ISmartAcmeOptions {
|
2025-05-09 17:28:27 +00:00
|
|
|
accountEmail: string;
|
|
|
|
certManager: ICertManager;
|
|
|
|
environment: 'production' | 'integration';
|
|
|
|
challengeHandlers: IChallengeHandler<any>[];
|
|
|
|
challengePriority?: string[];
|
|
|
|
retryOptions?: {
|
|
|
|
retries?: number;
|
|
|
|
factor?: number;
|
|
|
|
minTimeoutMs?: number;
|
|
|
|
maxTimeoutMs?: number;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for certificate manager
|
|
|
|
*/
|
|
|
|
export interface ICertManager {
|
|
|
|
init(): Promise<void>;
|
2025-05-09 22:46:53 +00:00
|
|
|
get(domainName: string): Promise<ISmartAcmeCert | null>;
|
|
|
|
put(cert: ISmartAcmeCert): Promise<ISmartAcmeCert>;
|
2025-05-09 17:28:27 +00:00
|
|
|
delete(domainName: string): Promise<void>;
|
|
|
|
close?(): Promise<void>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for challenge handler
|
|
|
|
*/
|
|
|
|
export interface IChallengeHandler<T> {
|
|
|
|
getSupportedTypes(): string[];
|
|
|
|
prepare(ch: T): Promise<void>;
|
|
|
|
verify?(ch: T): Promise<void>;
|
|
|
|
cleanup(ch: T): Promise<void>;
|
|
|
|
checkWetherDomainIsSupported(domain: string): Promise<boolean>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* HTTP-01 challenge type
|
|
|
|
*/
|
2025-05-09 22:46:53 +00:00
|
|
|
export interface IHttp01Challenge {
|
2025-05-09 17:28:27 +00:00
|
|
|
type: string; // 'http-01'
|
|
|
|
token: string;
|
|
|
|
keyAuthorization: string;
|
|
|
|
webPath: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* HTTP-01 Memory Handler Interface
|
|
|
|
*/
|
2025-05-09 22:46:53 +00:00
|
|
|
export interface IHttp01MemoryHandler extends IChallengeHandler<IHttp01Challenge> {
|
2025-05-09 17:28:27 +00:00
|
|
|
handleRequest(req: plugins.http.IncomingMessage, res: plugins.http.ServerResponse, next?: () => void): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SmartAcme main class interface
|
|
|
|
*/
|
2025-05-09 22:46:53 +00:00
|
|
|
export interface ISmartAcme {
|
2025-05-09 17:28:27 +00:00
|
|
|
start(): Promise<void>;
|
|
|
|
stop(): Promise<void>;
|
2025-05-09 22:46:53 +00:00
|
|
|
getCertificateForDomain(domain: string): Promise<ISmartAcmeCert>;
|
2025-05-09 17:28:27 +00:00
|
|
|
on?(event: string, listener: (data: any) => void): void;
|
|
|
|
eventEmitter?: plugins.EventEmitter;
|
|
|
|
}
|