@libkakashi/porkbunjs
Version:
A comprehensive TypeScript library for the Porkbun API v3
274 lines • 7.38 kB
TypeScript
//#region src/types.d.ts
interface PorkbunAuth {
secretapikey: string;
apikey: string;
}
interface PingResponse {
yourIp?: string;
}
interface DomainPricing {
registration: string;
renewal: string;
transfer: string;
}
interface PricingResponse {
pricing?: Record<string, DomainPricing>;
}
interface DomainLabel {
id: string;
title: string;
color: string;
}
interface Domain {
domain: string;
status: string;
tld: string;
createDate: string;
expireDate: string;
securityLock: string;
whoisPrivacy: string;
autoRenew: number;
notLocal: number;
labels?: DomainLabel[];
}
interface ListDomainsOptions {
start?: string;
includeLabels?: boolean;
}
interface UpdateNameServersOptions {
ns: string[];
}
interface URLForward {
id: string;
subdomain: string;
location: string;
type: 'temporary' | 'permanent';
includePath: boolean;
wildcard: boolean;
}
interface AddURLForwardOptions {
subdomain?: string;
location: string;
type: 'temporary' | 'permanent';
includePath: boolean;
wildcard: boolean;
}
interface DomainAvailabilityCheck {
avail: boolean;
type: string;
price: string;
firstYearPromo?: boolean;
regularPrice: string;
premium: boolean;
additional?: {
renewal: {
type: string;
price: string;
regularPrice: string;
};
transfer: {
type: string;
price: string;
regularPrice: string;
};
};
}
interface DomainCheckLimits {
TTL: string;
limit: string;
used: number;
naturalLanguage: string;
}
interface CreateGlueRecordOptions {
ips: string[];
}
interface UpdateGlueRecordOptions {
ips: string[];
}
interface GlueRecordHost {
v6?: string[];
v4?: string[];
}
type DNSRecordType = 'A' | 'MX' | 'CNAME' | 'ALIAS' | 'TXT' | 'NS' | 'AAAA' | 'SRV' | 'TLSA' | 'CAA' | 'HTTPS' | 'SVCB';
interface DNSRecord {
id: string;
name: string;
type: DNSRecordType;
content: string;
ttl: string;
prio: string;
notes: string;
}
interface CreateDNSRecordOptions {
name?: string;
type: DNSRecordType;
content: string;
ttl?: string;
prio?: string;
notes?: string;
}
interface EditDNSRecordOptions {
name?: string;
type: DNSRecordType;
content: string;
ttl?: string;
prio?: string;
notes?: string | null;
}
interface EditDNSRecordByTypeOptions {
content: string;
ttl?: string;
prio?: string;
notes?: string | null;
}
interface CreateDNSSECRecordOptions {
keyTag: string;
alg: string;
digestType: string;
digest: string;
maxSigLife?: string;
keyDataFlags?: string;
keyDataProtocol?: string;
keyDataAlgo?: string;
keyDataPubKey?: string;
}
interface DNSSECRecord {
keyTag: string;
alg: string;
digestType: string;
digest: string;
}
interface SSLBundle {
certificatechain: string;
privatekey: string;
publickey: string;
}
interface PorkbunConfig {
apiKey: string;
secretKey: string;
baseUrl?: string;
timeout?: number;
}
//#endregion
//#region src/errors.d.ts
declare class PorkbunError extends Error {
status?: string | undefined;
response?: any | undefined;
constructor(message: string, status?: string | undefined, response?: any | undefined);
}
declare class PorkbunAuthError extends PorkbunError {
constructor(message?: string);
}
declare class PorkbunRateLimitError extends PorkbunError {
limits?: DomainCheckLimits | undefined;
constructor(message?: string, limits?: DomainCheckLimits | undefined);
}
//#endregion
//#region src/client.d.ts
declare class PorkbunClient {
#private;
constructor(config: PorkbunConfig);
/**
* Test communication with the API and get your IP address
*/
ping(): Promise<PingResponse>;
/**
* Get domain pricing information for all supported TLDs
* This endpoint does not require authentication
*/
getPricing(): Promise<PricingResponse>;
/**
* Update the name servers for a domain
*/
updateNameServers(domain: string, options: UpdateNameServersOptions): Promise<void>;
/**
* Get the authoritative name servers for a domain
*/
getNameServers(domain: string): Promise<string[]>;
/**
* Get all domains in the account
*/
listDomains(options?: ListDomainsOptions): Promise<Domain[]>;
/**
* Add URL forwarding for a domain
*/
addURLForward(domain: string, options: AddURLForwardOptions): Promise<void>;
/**
* Get URL forwarding records for a domain
*/
getURLForwarding(domain: string): Promise<URLForward[]>;
/**
* Delete a URL forward record
*/
deleteURLForward(domain: string, recordId: string): Promise<void>;
/**
* Check domain availability
* Note: This endpoint is rate limited
*/
checkDomain(domain: string): Promise<{
response: DomainAvailabilityCheck;
limits: DomainCheckLimits;
}>;
/**
* Create a glue record for a domain
*/
createGlueRecord(domain: string, subdomain: string, options: CreateGlueRecordOptions): Promise<void>;
/**
* Update a glue record for a domain
*/
updateGlueRecord(domain: string, subdomain: string, options: UpdateGlueRecordOptions): Promise<void>;
/**
* Delete a glue record for a domain
*/
deleteGlueRecord(domain: string, subdomain: string): Promise<void>;
/**
* Get all glue records for a domain
*/
getGlueRecords(domain: string): Promise<[string, GlueRecordHost][]>;
/**
* Create a DNS record
*/
createDNSRecord(domain: string, options: CreateDNSRecordOptions): Promise<string>;
/**
* Edit a DNS record by domain and record ID
*/
editDNSRecord(domain: string, recordId: string, options: EditDNSRecordOptions): Promise<void>;
/**
* Edit DNS records by domain, subdomain, and type
*/
editDNSRecordsByType(domain: string, type: DNSRecordType, subdomain: string | undefined, options: EditDNSRecordByTypeOptions): Promise<void>;
/**
* Delete a DNS record by domain and record ID
*/
deleteDNSRecord(domain: string, recordId: string): Promise<void>;
/**
* Delete DNS records by domain, subdomain, and type
*/
deleteDNSRecordsByType(domain: string, type: DNSRecordType, subdomain?: string): Promise<void>;
/**
* Get all DNS records for a domain or a specific record by ID
*/
getDNSRecords(domain: string, recordId?: string): Promise<DNSRecord[]>;
/**
* Get DNS records by domain, subdomain, and type
*/
getDNSRecordsByType(domain: string, type: DNSRecordType, subdomain?: string): Promise<DNSRecord[]>;
/**
* Create a DNSSEC record
*/
createDNSSECRecord(domain: string, options: CreateDNSSECRecordOptions): Promise<void>;
/**
* Get DNSSEC records for a domain
*/
getDNSSECRecords(domain: string): Promise<DNSSECRecord[]>;
/**
* Delete a DNSSEC record
*/
deleteDNSSECRecord(domain: string, keyTag: string): Promise<void>;
/**
* Get SSL certificate bundle for a domain
*/
getSSLBundle(domain: string): Promise<SSLBundle>;
}
//#endregion
export { AddURLForwardOptions, CreateDNSRecordOptions, CreateDNSSECRecordOptions, CreateGlueRecordOptions, DNSRecord, DNSRecordType, DNSSECRecord, Domain, DomainAvailabilityCheck, DomainCheckLimits, DomainLabel, DomainPricing, EditDNSRecordByTypeOptions, EditDNSRecordOptions, GlueRecordHost, ListDomainsOptions, PingResponse, PorkbunAuth, PorkbunAuthError, PorkbunClient, PorkbunConfig, PorkbunError, PorkbunRateLimitError, PricingResponse, SSLBundle, URLForward, UpdateGlueRecordOptions, UpdateNameServersOptions };