Files
certd/packages/plugins/plugin-lib/src/cert/dns-provider/api.ts

98 lines
2.1 KiB
TypeScript
Raw Normal View History

2024-11-04 15:14:56 +08:00
import { HttpClient, ILogger, utils } from "@certd/basic";
2025-09-23 23:24:36 +08:00
import { IAccess, IServiceGetter, 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 = {
domain: string;
2022-10-26 09:02:47 +08:00
fullRecord: string;
hostRecord: string;
2022-10-26 09:02:47 +08:00
type: string;
value: any;
};
export type RemoveRecordOptions<T> = {
recordReq: CreateRecordOptions;
2024-06-15 02:17:34 +08:00
// 本次创建的dns解析记录实际上就是createRecord接口的返回值
recordRes: T;
2022-10-26 09:02:47 +08:00
};
export type DnsProviderContext = {
access: IAccess;
logger: ILogger;
http: HttpClient;
utils: typeof utils;
domainParser: IDomainParser;
2025-09-23 23:24:36 +08:00
serviceGetter: IServiceGetter;
};
2024-06-15 02:17:34 +08:00
export interface IDnsProvider<T = any> {
2023-05-09 10:16:49 +08:00
onInstance(): Promise<void>;
/**
*
* @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>;
2024-06-15 02:17:34 +08:00
removeRecord(options: RemoveRecordOptions<T>): Promise<void>;
setCtx(ctx: DnsProviderContext): void;
//中文域名是否需要punycode转码如果返回True则使用punycode来添加解析记录否则使用中文域名添加解析记录
usePunyCode(): boolean;
2022-10-26 09:02:47 +08:00
}
export interface ISubDomainsGetter {
getSubDomains(): Promise<string[]>;
}
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;
httpUploaderAccess: number;
2025-07-12 23:00:04 +08:00
httpUploadRootDir: string;
};
export type DomainVerifier = {
domain: string;
mainDomain: string;
type: string;
2025-07-12 23:00:04 +08:00
dns?: DnsVerifier;
cname?: CnameVerifier;
http?: HttpVerifier;
};
export type DomainVerifiers = {
[key: string]: DomainVerifier;
};
2025-07-12 23:00:04 +08:00
export interface IDomainVerifierGetter {
getVerifiers(domains: string[]): Promise<DomainVerifiers>;
2025-07-12 23:00:04 +08:00
}