2024-11-04 15:14:56 +08:00
|
|
|
import { HttpClient, ILogger, utils } from "@certd/basic";
|
2026-03-15 23:55:49 +08:00
|
|
|
import { IAccess, IAccessService, IServiceGetter, PageRes, PageSearch, Registrable } from "@certd/pipeline";
|
2022-10-26 09:02:47 +08:00
|
|
|
|
|
|
|
|
export type DnsProviderDefine = Registrable & {
|
|
|
|
|
accessType: string;
|
2024-11-30 01:57:09 +08:00
|
|
|
icon?: string;
|
2022-10-26 09:02:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type CreateRecordOptions = {
|
2024-10-07 03:21:16 +08:00
|
|
|
domain: string;
|
2022-10-26 09:02:47 +08:00
|
|
|
fullRecord: string;
|
2024-10-07 03:21:16 +08:00
|
|
|
hostRecord: string;
|
2022-10-26 09:02:47 +08:00
|
|
|
type: string;
|
|
|
|
|
value: any;
|
|
|
|
|
};
|
2024-10-07 03:21:16 +08:00
|
|
|
export type RemoveRecordOptions<T> = {
|
|
|
|
|
recordReq: CreateRecordOptions;
|
2024-06-15 02:17:34 +08:00
|
|
|
// 本次创建的dns解析记录,实际上就是createRecord接口的返回值
|
2024-10-07 03:21:16 +08:00
|
|
|
recordRes: T;
|
2022-10-26 09:02:47 +08:00
|
|
|
};
|
|
|
|
|
|
2024-06-14 01:22:07 +08:00
|
|
|
export type DnsProviderContext = {
|
|
|
|
|
access: IAccess;
|
|
|
|
|
logger: ILogger;
|
|
|
|
|
http: HttpClient;
|
2024-10-01 23:34:01 +08:00
|
|
|
utils: typeof utils;
|
2025-04-11 12:13:57 +08:00
|
|
|
domainParser: IDomainParser;
|
2025-09-23 23:24:36 +08:00
|
|
|
serviceGetter: IServiceGetter;
|
2026-03-15 23:55:49 +08:00
|
|
|
accessGetter?: IAccessService;
|
2024-06-14 01:22:07 +08:00
|
|
|
};
|
|
|
|
|
|
2026-01-16 18:18:39 +08:00
|
|
|
export type DomainRecord = {
|
|
|
|
|
id: string;
|
|
|
|
|
domain: string;
|
|
|
|
|
};
|
|
|
|
|
|
2026-06-10 23:32:39 +08:00
|
|
|
export type DnsResolveRecord = {
|
|
|
|
|
id: string;
|
|
|
|
|
hostRecord: string;
|
|
|
|
|
fullRecord: string;
|
|
|
|
|
type: string;
|
|
|
|
|
value: string;
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-15 02:17:34 +08:00
|
|
|
export interface IDnsProvider<T = any> {
|
2023-05-09 10:16:49 +08:00
|
|
|
onInstance(): Promise<void>;
|
2025-06-05 11:25:16 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 中文转英文
|
|
|
|
|
* @param domain
|
|
|
|
|
*/
|
|
|
|
|
punyCodeEncode(domain: string): string;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 转中文域名
|
|
|
|
|
* @param domain
|
|
|
|
|
*/
|
|
|
|
|
punyCodeDecode(domain: string): string;
|
|
|
|
|
|
2024-06-15 02:17:34 +08:00
|
|
|
createRecord(options: CreateRecordOptions): Promise<T>;
|
2025-06-05 11:25:16 +08:00
|
|
|
|
2024-06-15 02:17:34 +08:00
|
|
|
removeRecord(options: RemoveRecordOptions<T>): Promise<void>;
|
2025-06-05 11:25:16 +08:00
|
|
|
|
2024-06-14 01:22:07 +08:00
|
|
|
setCtx(ctx: DnsProviderContext): void;
|
2025-06-05 11:25:16 +08:00
|
|
|
|
2025-04-24 11:54:54 +08:00
|
|
|
//中文域名是否需要punycode转码,如果返回True,则使用punycode来添加解析记录,否则使用中文域名添加解析记录
|
|
|
|
|
usePunyCode(): boolean;
|
2026-01-16 18:18:39 +08:00
|
|
|
|
2026-01-23 16:56:01 +08:00
|
|
|
getDomainListPage(pager: PageSearch): Promise<PageRes<DomainRecord>>;
|
2026-06-10 23:32:39 +08:00
|
|
|
|
|
|
|
|
getRecordListPage?(domain: string, pager: PageSearch): Promise<PageRes<DnsResolveRecord>>;
|
2022-10-26 09:02:47 +08:00
|
|
|
}
|
2025-04-11 12:13:57 +08:00
|
|
|
|
|
|
|
|
export interface ISubDomainsGetter {
|
|
|
|
|
getSubDomains(): Promise<string[]>;
|
2026-01-31 02:39:28 +08:00
|
|
|
hasSubDomain(domain: string): Promise<string>;
|
2025-04-11 12:13:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IDomainParser {
|
|
|
|
|
parse(fullDomain: string): Promise<string>;
|
|
|
|
|
}
|
2025-07-12 23:00:04 +08:00
|
|
|
|
|
|
|
|
export type DnsVerifier = {
|
|
|
|
|
// dns直接校验
|
2025-07-13 23:08:00 +08:00
|
|
|
dnsProviderType?: string;
|
|
|
|
|
dnsProviderAccessId?: number;
|
2025-07-12 23:00:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type CnameVerifier = {
|
2025-07-13 23:08:00 +08:00
|
|
|
hostRecord: string;
|
|
|
|
|
domain: string;
|
|
|
|
|
recordValue: string;
|
2025-07-12 23:00:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type HttpVerifier = {
|
|
|
|
|
// http校验
|
|
|
|
|
httpUploaderType: string;
|
2025-07-13 18:25:09 +08:00
|
|
|
httpUploaderAccess: number;
|
2025-07-12 23:00:04 +08:00
|
|
|
httpUploadRootDir: string;
|
|
|
|
|
};
|
|
|
|
|
export type DomainVerifier = {
|
|
|
|
|
domain: string;
|
|
|
|
|
mainDomain: string;
|
2025-07-13 18:25:09 +08:00
|
|
|
type: string;
|
2025-07-12 23:00:04 +08:00
|
|
|
dns?: DnsVerifier;
|
|
|
|
|
cname?: CnameVerifier;
|
|
|
|
|
http?: HttpVerifier;
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-13 18:25:09 +08:00
|
|
|
export type DomainVerifiers = {
|
|
|
|
|
[key: string]: DomainVerifier;
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-12 23:00:04 +08:00
|
|
|
export interface IDomainVerifierGetter {
|
2025-07-13 18:25:09 +08:00
|
|
|
getVerifiers(domains: string[]): Promise<DomainVerifiers>;
|
2025-07-12 23:00:04 +08:00
|
|
|
}
|