@geekmidas/edge 0.0.0-stage → 10.0.0-alpha.182
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -2
- package/dist/certificates/local.cjs +393 -0
- package/dist/certificates/local.cjs.map +1 -0
- package/dist/certificates/local.d.cts +92 -0
- package/dist/certificates/local.d.cts.map +1 -0
- package/dist/certificates/local.d.mts +92 -0
- package/dist/certificates/local.d.mts.map +1 -0
- package/dist/certificates/local.mjs +361 -0
- package/dist/certificates/local.mjs.map +1 -0
- package/dist/compose-BHWyQvsD.cjs +22 -0
- package/dist/compose-BHWyQvsD.cjs.map +1 -0
- package/dist/compose-CcNlj65h.mjs +17 -0
- package/dist/compose-CcNlj65h.mjs.map +1 -0
- package/dist/dns/godaddy/index.cjs +448 -0
- package/dist/dns/godaddy/index.cjs.map +1 -0
- package/dist/dns/godaddy/index.d.cts +164 -0
- package/dist/dns/godaddy/index.d.cts.map +1 -0
- package/dist/dns/godaddy/index.d.mts +164 -0
- package/dist/dns/godaddy/index.d.mts.map +1 -0
- package/dist/dns/godaddy/index.mjs +435 -0
- package/dist/dns/godaddy/index.mjs.map +1 -0
- package/dist/dns/hostinger/index.cjs +252 -0
- package/dist/dns/hostinger/index.cjs.map +1 -0
- package/dist/dns/hostinger/index.d.cts +143 -0
- package/dist/dns/hostinger/index.d.cts.map +1 -0
- package/dist/dns/hostinger/index.d.mts +143 -0
- package/dist/dns/hostinger/index.d.mts.map +1 -0
- package/dist/dns/hostinger/index.mjs +249 -0
- package/dist/dns/hostinger/index.mjs.map +1 -0
- package/dist/dns/index.cjs +76 -0
- package/dist/dns/index.cjs.map +1 -0
- package/dist/dns/index.d.cts +144 -0
- package/dist/dns/index.d.cts.map +1 -0
- package/dist/dns/index.d.mts +144 -0
- package/dist/dns/index.d.mts.map +1 -0
- package/dist/dns/index.mjs +71 -0
- package/dist/dns/index.mjs.map +1 -0
- package/dist/dns/route53.cjs +210 -0
- package/dist/dns/route53.cjs.map +1 -0
- package/dist/dns/route53.d.cts +45 -0
- package/dist/dns/route53.d.cts.map +1 -0
- package/dist/dns/route53.d.mts +45 -0
- package/dist/dns/route53.d.mts.map +1 -0
- package/dist/dns/route53.mjs +209 -0
- package/dist/dns/route53.mjs.map +1 -0
- package/dist/errors-CO33_TDV.mjs +16 -0
- package/dist/errors-CO33_TDV.mjs.map +1 -0
- package/dist/errors-DBZfelEN.d.cts +13 -0
- package/dist/errors-DBZfelEN.d.cts.map +1 -0
- package/dist/errors-DBZfelEN.d.mts +13 -0
- package/dist/errors-DBZfelEN.d.mts.map +1 -0
- package/dist/errors-DlRLQOyZ.cjs +27 -0
- package/dist/errors-DlRLQOyZ.cjs.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/proxy/caddy.cjs +167 -0
- package/dist/proxy/caddy.cjs.map +1 -0
- package/dist/proxy/caddy.d.cts +35 -0
- package/dist/proxy/caddy.d.cts.map +1 -0
- package/dist/proxy/caddy.d.mts +35 -0
- package/dist/proxy/caddy.d.mts.map +1 -0
- package/dist/proxy/caddy.mjs +164 -0
- package/dist/proxy/caddy.mjs.map +1 -0
- package/dist/proxy/traefik.cjs +460 -0
- package/dist/proxy/traefik.cjs.map +1 -0
- package/dist/proxy/traefik.d.cts +129 -0
- package/dist/proxy/traefik.d.cts.map +1 -0
- package/dist/proxy/traefik.d.mts +129 -0
- package/dist/proxy/traefik.d.mts.map +1 -0
- package/dist/proxy/traefik.mjs +437 -0
- package/dist/proxy/traefik.mjs.map +1 -0
- package/dist/routes/index.cjs +49 -0
- package/dist/routes/index.cjs.map +1 -0
- package/dist/routes/index.d.cts +205 -0
- package/dist/routes/index.d.cts.map +1 -0
- package/dist/routes/index.d.mts +205 -0
- package/dist/routes/index.d.mts.map +1 -0
- package/dist/routes/index.mjs +44 -0
- package/dist/routes/index.mjs.map +1 -0
- package/package.json +131 -3
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/dns/hostinger/api.ts
|
|
3
|
+
/**
|
|
4
|
+
* Hostinger DNS API client
|
|
5
|
+
*
|
|
6
|
+
* API Documentation: https://developers.hostinger.com/
|
|
7
|
+
* Authentication: Bearer token from hpanel.hostinger.com/profile/api
|
|
8
|
+
*/
|
|
9
|
+
const HOSTINGER_API_BASE = "https://developers.hostinger.com";
|
|
10
|
+
/**
|
|
11
|
+
* Hostinger API error
|
|
12
|
+
*/
|
|
13
|
+
var HostingerApiError = class extends Error {
|
|
14
|
+
status;
|
|
15
|
+
statusText;
|
|
16
|
+
errors;
|
|
17
|
+
constructor(message, status, statusText, errors) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.status = status;
|
|
20
|
+
this.statusText = statusText;
|
|
21
|
+
this.errors = errors;
|
|
22
|
+
this.name = "HostingerApiError";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Hostinger DNS API client
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const api = new HostingerApi(token);
|
|
31
|
+
*
|
|
32
|
+
* // Get all records for a domain
|
|
33
|
+
* const records = await api.getRecords('traflabs.io');
|
|
34
|
+
*
|
|
35
|
+
* // Create/update records
|
|
36
|
+
* await api.upsertRecords('traflabs.io', [
|
|
37
|
+
* { name: 'api.joemoer', type: 'A', ttl: 300, records: ['1.2.3.4'] }
|
|
38
|
+
* ]);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
var HostingerApi = class {
|
|
42
|
+
token;
|
|
43
|
+
constructor(token) {
|
|
44
|
+
this.token = token;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Make a request to the Hostinger API
|
|
48
|
+
*/
|
|
49
|
+
async request(method, endpoint, body) {
|
|
50
|
+
const url = `${HOSTINGER_API_BASE}${endpoint}`;
|
|
51
|
+
const response = await fetch(url, {
|
|
52
|
+
method,
|
|
53
|
+
headers: {
|
|
54
|
+
"Content-Type": "application/json",
|
|
55
|
+
Authorization: `Bearer ${this.token}`
|
|
56
|
+
},
|
|
57
|
+
body: body ? JSON.stringify(body) : void 0
|
|
58
|
+
});
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
let errorMessage = `Hostinger API error: ${response.status} ${response.statusText}`;
|
|
61
|
+
let errors;
|
|
62
|
+
try {
|
|
63
|
+
const errorBody = await response.json();
|
|
64
|
+
if (errorBody.message) errorMessage = `Hostinger API error: ${errorBody.message}`;
|
|
65
|
+
errors = errorBody.errors;
|
|
66
|
+
} catch {}
|
|
67
|
+
throw new HostingerApiError(errorMessage, response.status, response.statusText, errors);
|
|
68
|
+
}
|
|
69
|
+
const text = await response.text();
|
|
70
|
+
if (!text || text.trim() === "") return;
|
|
71
|
+
return JSON.parse(text);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get all DNS records for a domain
|
|
75
|
+
*
|
|
76
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
77
|
+
*/
|
|
78
|
+
async getRecords(domain) {
|
|
79
|
+
const response = await this.request("GET", `/api/dns/v1/zones/${domain}`);
|
|
80
|
+
if (Array.isArray(response)) return response;
|
|
81
|
+
return response?.data ?? [];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create or update DNS records
|
|
85
|
+
*
|
|
86
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
87
|
+
* @param records - Records to create/update
|
|
88
|
+
* @param overwrite - If true, replaces all existing records. If false, merges with existing.
|
|
89
|
+
*/
|
|
90
|
+
async upsertRecords(domain, records, overwrite = false) {
|
|
91
|
+
await this.request("PUT", `/api/dns/v1/zones/${domain}`, {
|
|
92
|
+
overwrite,
|
|
93
|
+
zone: records
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Validate DNS records before applying
|
|
98
|
+
*
|
|
99
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
100
|
+
* @param records - Records to validate
|
|
101
|
+
* @returns true if valid, throws if invalid
|
|
102
|
+
*/
|
|
103
|
+
async validateRecords(domain, records) {
|
|
104
|
+
await this.request("POST", `/api/dns/v1/zones/${domain}/validate`, {
|
|
105
|
+
overwrite: false,
|
|
106
|
+
zone: records
|
|
107
|
+
});
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Delete specific DNS records
|
|
112
|
+
*
|
|
113
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
114
|
+
* @param filters - Filters to match records for deletion
|
|
115
|
+
*/
|
|
116
|
+
async deleteRecords(domain, filters) {
|
|
117
|
+
await this.request("DELETE", `/api/dns/v1/zones/${domain}`, { filters });
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if a specific record exists
|
|
121
|
+
*
|
|
122
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
123
|
+
* @param name - Subdomain name (e.g., 'api.joemoer')
|
|
124
|
+
* @param type - Record type (e.g., 'A')
|
|
125
|
+
*/
|
|
126
|
+
async recordExists(domain, name, type = "A") {
|
|
127
|
+
return (await this.getRecords(domain)).some((r) => r.name === name && r.type === type);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Create a single A record if it doesn't exist
|
|
131
|
+
*
|
|
132
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
133
|
+
* @param subdomain - Subdomain name (e.g., 'api.joemoer')
|
|
134
|
+
* @param ip - IP address to point to
|
|
135
|
+
* @param ttl - TTL in seconds (default: 300)
|
|
136
|
+
* @returns true if created, false if already exists
|
|
137
|
+
*/
|
|
138
|
+
async createARecordIfNotExists(domain, subdomain, ip, ttl = 300) {
|
|
139
|
+
if (await this.recordExists(domain, subdomain, "A")) return false;
|
|
140
|
+
await this.upsertRecords(domain, [{
|
|
141
|
+
name: subdomain,
|
|
142
|
+
type: "A",
|
|
143
|
+
ttl,
|
|
144
|
+
records: [{ content: ip }]
|
|
145
|
+
}]);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/dns/hostinger/index.ts
|
|
151
|
+
/** A value compared the way DNS does: case, a trailing dot and spacing aside. */
|
|
152
|
+
function normalize(value) {
|
|
153
|
+
return value.trim().replace(/\.$/, "").replace(/\s+/g, " ").toLowerCase();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Hostinger DNS provider implementation.
|
|
157
|
+
*/
|
|
158
|
+
var HostingerProvider = class {
|
|
159
|
+
credential;
|
|
160
|
+
name = "hostinger";
|
|
161
|
+
api = null;
|
|
162
|
+
/**
|
|
163
|
+
* `credential`: where the token comes from, asked the first time the API
|
|
164
|
+
* is called. It throws when there is none: what to do about a missing
|
|
165
|
+
* token is the caller's to say.
|
|
166
|
+
*/
|
|
167
|
+
constructor(credential) {
|
|
168
|
+
this.credential = credential;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get or create the Hostinger API client.
|
|
172
|
+
*/
|
|
173
|
+
async getApi() {
|
|
174
|
+
if (this.api) return this.api;
|
|
175
|
+
const { token } = await this.credential();
|
|
176
|
+
this.api = new HostingerApi(token);
|
|
177
|
+
return this.api;
|
|
178
|
+
}
|
|
179
|
+
async getRecords(domain) {
|
|
180
|
+
return (await (await this.getApi()).getRecords(domain)).map((r) => ({
|
|
181
|
+
name: r.name,
|
|
182
|
+
type: r.type,
|
|
183
|
+
ttl: r.ttl,
|
|
184
|
+
values: r.records.map((rec) => rec.content)
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
async upsertRecords(domain, records) {
|
|
188
|
+
const api = await this.getApi();
|
|
189
|
+
const results = [];
|
|
190
|
+
const existingRecords = await api.getRecords(domain);
|
|
191
|
+
for (const record of records) {
|
|
192
|
+
const existing = existingRecords.find((r) => r.name === record.name && r.type === record.type);
|
|
193
|
+
const existingValue = existing?.records?.[0]?.content;
|
|
194
|
+
if (existing && existingValue !== void 0 && normalize(existingValue) === normalize(record.value)) {
|
|
195
|
+
results.push({
|
|
196
|
+
record,
|
|
197
|
+
created: false,
|
|
198
|
+
unchanged: true
|
|
199
|
+
});
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
await api.upsertRecords(domain, [{
|
|
203
|
+
name: record.name,
|
|
204
|
+
type: record.type,
|
|
205
|
+
ttl: record.ttl,
|
|
206
|
+
records: [{ content: record.value }]
|
|
207
|
+
}], true);
|
|
208
|
+
results.push({
|
|
209
|
+
record,
|
|
210
|
+
created: !existing,
|
|
211
|
+
unchanged: false
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return results;
|
|
215
|
+
}
|
|
216
|
+
async deleteRecords(domain, records) {
|
|
217
|
+
const api = await this.getApi();
|
|
218
|
+
const results = [];
|
|
219
|
+
const existingRecords = await api.getRecords(domain);
|
|
220
|
+
const recordsToDelete = records.filter((record) => existingRecords.some((r) => r.name === record.name && r.type === record.type));
|
|
221
|
+
if (recordsToDelete.length > 0) try {
|
|
222
|
+
await api.deleteRecords(domain, recordsToDelete.map((r) => ({
|
|
223
|
+
name: r.name,
|
|
224
|
+
type: r.type
|
|
225
|
+
})));
|
|
226
|
+
for (const record of recordsToDelete) results.push({
|
|
227
|
+
record,
|
|
228
|
+
deleted: true,
|
|
229
|
+
notFound: false
|
|
230
|
+
});
|
|
231
|
+
} catch (error) {
|
|
232
|
+
for (const record of recordsToDelete) results.push({
|
|
233
|
+
record,
|
|
234
|
+
deleted: false,
|
|
235
|
+
notFound: false,
|
|
236
|
+
error: String(error)
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
for (const record of records) if (!existingRecords.find((r) => r.name === record.name && r.type === record.type)) results.push({
|
|
240
|
+
record,
|
|
241
|
+
deleted: false,
|
|
242
|
+
notFound: true
|
|
243
|
+
});
|
|
244
|
+
return results;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
//#endregion
|
|
248
|
+
exports.HostingerApi = HostingerApi;
|
|
249
|
+
exports.HostingerApiError = HostingerApiError;
|
|
250
|
+
exports.HostingerProvider = HostingerProvider;
|
|
251
|
+
|
|
252
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../../src/dns/hostinger/api.ts","../../../src/dns/hostinger/index.ts"],"sourcesContent":["/**\n * Hostinger DNS API client\n *\n * API Documentation: https://developers.hostinger.com/\n * Authentication: Bearer token from hpanel.hostinger.com/profile/api\n */\n\nconst HOSTINGER_API_BASE = 'https://developers.hostinger.com';\n\n/**\n * DNS record types supported by Hostinger\n */\nexport type DnsRecordType =\n\t| 'A'\n\t| 'AAAA'\n\t| 'CNAME'\n\t| 'MX'\n\t| 'TXT'\n\t| 'NS'\n\t| 'SRV'\n\t| 'CAA';\n\n/**\n * A single DNS record\n */\nexport interface DnsRecord {\n\t/** Subdomain name (e.g., 'api.joemoer' for api.joemoer.traflabs.io) */\n\tname: string;\n\t/** Record type */\n\ttype: DnsRecordType;\n\t/** TTL in seconds */\n\tttl: number;\n\t/** Record values */\n\trecords: Array<{ content: string }>;\n}\n\n/**\n * Filter for deleting specific records\n */\nexport interface DnsRecordFilter {\n\tname: string;\n\ttype: DnsRecordType;\n}\n\n/**\n * API error response\n */\nexport interface HostingerErrorResponse {\n\tmessage?: string;\n\terrors?: Record<string, string[]>;\n}\n\n/**\n * Hostinger API error\n */\nexport class HostingerApiError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic status: number,\n\t\tpublic statusText: string,\n\t\tpublic errors?: Record<string, string[]>,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'HostingerApiError';\n\t}\n}\n\n/**\n * Hostinger DNS API client\n *\n * @example\n * ```ts\n * const api = new HostingerApi(token);\n *\n * // Get all records for a domain\n * const records = await api.getRecords('traflabs.io');\n *\n * // Create/update records\n * await api.upsertRecords('traflabs.io', [\n * { name: 'api.joemoer', type: 'A', ttl: 300, records: ['1.2.3.4'] }\n * ]);\n * ```\n */\nexport class HostingerApi {\n\tprivate token: string;\n\n\tconstructor(token: string) {\n\t\tthis.token = token;\n\t}\n\n\t/**\n\t * Make a request to the Hostinger API\n\t */\n\tprivate async request<T>(\n\t\tmethod: 'GET' | 'POST' | 'PUT' | 'DELETE',\n\t\tendpoint: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst url = `${HOSTINGER_API_BASE}${endpoint}`;\n\n\t\tconst response = await fetch(url, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\n\t\t\t},\n\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tlet errorMessage = `Hostinger API error: ${response.status} ${response.statusText}`;\n\t\t\tlet errors: Record<string, string[]> | undefined;\n\n\t\t\ttry {\n\t\t\t\tconst errorBody = (await response.json()) as HostingerErrorResponse;\n\t\t\t\tif (errorBody.message) {\n\t\t\t\t\terrorMessage = `Hostinger API error: ${errorBody.message}`;\n\t\t\t\t}\n\t\t\t\terrors = errorBody.errors;\n\t\t\t} catch {\n\t\t\t\t// Ignore JSON parse errors\n\t\t\t}\n\n\t\t\tthrow new HostingerApiError(\n\t\t\t\terrorMessage,\n\t\t\t\tresponse.status,\n\t\t\t\tresponse.statusText,\n\t\t\t\terrors,\n\t\t\t);\n\t\t}\n\n\t\t// Handle empty responses\n\t\tconst text = await response.text();\n\t\tif (!text || text.trim() === '') {\n\t\t\treturn undefined as T;\n\t\t}\n\t\treturn JSON.parse(text) as T;\n\t}\n\n\t/**\n\t * Get all DNS records for a domain\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t */\n\tasync getRecords(domain: string): Promise<DnsRecord[]> {\n\t\t// The zone comes back as a **bare array**, not `{ data: [...] }`.\n\t\t//\n\t\t// This read `response.data || []`, so every call returned zero records\n\t\t// against the real API while every mocked test passed. Silently: no error,\n\t\t// no warning, just an empty zone. `upsertRecords` uses this to decide what\n\t\t// already exists, so everything looked new and every write was reported as\n\t\t// a creation — harmless only because the PUT merges rather than replaces.\n\t\t//\n\t\t// Both shapes are accepted because one of them is a guess: the wrapper was\n\t\t// written against documentation and the array is what the API actually\n\t\t// sends, so tolerating an envelope costs a line and survives it appearing.\n\t\tconst response = await this.request<DnsRecord[] | { data?: DnsRecord[] }>(\n\t\t\t'GET',\n\t\t\t`/api/dns/v1/zones/${domain}`,\n\t\t);\n\n\t\tif (Array.isArray(response)) return response;\n\n\t\treturn response?.data ?? [];\n\t}\n\n\t/**\n\t * Create or update DNS records\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param records - Records to create/update\n\t * @param overwrite - If true, replaces all existing records. If false, merges with existing.\n\t */\n\tasync upsertRecords(\n\t\tdomain: string,\n\t\trecords: DnsRecord[],\n\t\toverwrite = false,\n\t): Promise<void> {\n\t\tawait this.request('PUT', `/api/dns/v1/zones/${domain}`, {\n\t\t\toverwrite,\n\t\t\tzone: records,\n\t\t});\n\t}\n\n\t/**\n\t * Validate DNS records before applying\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param records - Records to validate\n\t * @returns true if valid, throws if invalid\n\t */\n\tasync validateRecords(\n\t\tdomain: string,\n\t\trecords: DnsRecord[],\n\t): Promise<boolean> {\n\t\tawait this.request('POST', `/api/dns/v1/zones/${domain}/validate`, {\n\t\t\toverwrite: false,\n\t\t\tzone: records,\n\t\t});\n\t\treturn true;\n\t}\n\n\t/**\n\t * Delete specific DNS records\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param filters - Filters to match records for deletion\n\t */\n\tasync deleteRecords(\n\t\tdomain: string,\n\t\tfilters: DnsRecordFilter[],\n\t): Promise<void> {\n\t\tawait this.request('DELETE', `/api/dns/v1/zones/${domain}`, {\n\t\t\tfilters,\n\t\t});\n\t}\n\n\t/**\n\t * Check if a specific record exists\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param name - Subdomain name (e.g., 'api.joemoer')\n\t * @param type - Record type (e.g., 'A')\n\t */\n\tasync recordExists(\n\t\tdomain: string,\n\t\tname: string,\n\t\ttype: DnsRecordType = 'A',\n\t): Promise<boolean> {\n\t\tconst records = await this.getRecords(domain);\n\t\treturn records.some((r) => r.name === name && r.type === type);\n\t}\n\n\t/**\n\t * Create a single A record if it doesn't exist\n\t *\n\t * @param domain - Root domain (e.g., 'traflabs.io')\n\t * @param subdomain - Subdomain name (e.g., 'api.joemoer')\n\t * @param ip - IP address to point to\n\t * @param ttl - TTL in seconds (default: 300)\n\t * @returns true if created, false if already exists\n\t */\n\tasync createARecordIfNotExists(\n\t\tdomain: string,\n\t\tsubdomain: string,\n\t\tip: string,\n\t\tttl = 300,\n\t): Promise<boolean> {\n\t\tconst exists = await this.recordExists(domain, subdomain, 'A');\n\t\tif (exists) {\n\t\t\treturn false;\n\t\t}\n\n\t\tawait this.upsertRecords(domain, [\n\t\t\t{\n\t\t\t\tname: subdomain,\n\t\t\t\ttype: 'A',\n\t\t\t\tttl,\n\t\t\t\trecords: [{ content: ip }],\n\t\t\t},\n\t\t]);\n\n\t\treturn true;\n\t}\n}\n","/**\n * Hostinger DNS Provider\n *\n * Implements DnsProvider interface using the Hostinger DNS API. A record's\n * `content` is its zone-file value — an MX record's is `<priority> <host>`,\n * Hostinger having no field of its own for the priority — so values pass\n * through as they are. Each write replaces its one name and type\n * (`overwrite: true`): without it Hostinger appends, and a record with\n * another value would end up holding both.\n */\n\nimport type {\n\tDeleteDnsRecord,\n\tDeleteResult,\n\tDnsProvider,\n\tDnsRecord,\n\tUpsertDnsRecord,\n\tUpsertResult,\n} from '../index';\nimport { HostingerApi } from './api';\n\n/** A Hostinger API token, from hpanel.hostinger.com/profile/api. */\nexport interface HostingerCredential {\n\ttoken: string;\n}\n\n/** A value compared the way DNS does: case, a trailing dot and spacing aside. */\nfunction normalize(value: string): string {\n\treturn value.trim().replace(/\\.$/, '').replace(/\\s+/g, ' ').toLowerCase();\n}\n\n/**\n * Hostinger DNS provider implementation.\n */\nexport class HostingerProvider implements DnsProvider {\n\treadonly name = 'hostinger';\n\tprivate api: HostingerApi | null = null;\n\n\t/**\n\t * `credential`: where the token comes from, asked the first time the API\n\t * is called. It throws when there is none: what to do about a missing\n\t * token is the caller's to say.\n\t */\n\tconstructor(\n\t\tprivate readonly credential: () => Promise<HostingerCredential>,\n\t) {}\n\n\t/**\n\t * Get or create the Hostinger API client.\n\t */\n\tprivate async getApi(): Promise<HostingerApi> {\n\t\tif (this.api) {\n\t\t\treturn this.api;\n\t\t}\n\n\t\tconst { token } = await this.credential();\n\n\t\tthis.api = new HostingerApi(token);\n\t\treturn this.api;\n\t}\n\n\tasync getRecords(domain: string): Promise<DnsRecord[]> {\n\t\tconst api = await this.getApi();\n\t\tconst records = await api.getRecords(domain);\n\n\t\treturn records.map((r) => ({\n\t\t\tname: r.name,\n\t\t\ttype: r.type,\n\t\t\tttl: r.ttl,\n\t\t\tvalues: r.records.map((rec) => rec.content),\n\t\t}));\n\t}\n\n\tasync upsertRecords(\n\t\tdomain: string,\n\t\trecords: UpsertDnsRecord[],\n\t): Promise<UpsertResult[]> {\n\t\tconst api = await this.getApi();\n\t\tconst results: UpsertResult[] = [];\n\n\t\t// Get existing records to check what already exists\n\t\tconst existingRecords = await api.getRecords(domain);\n\n\t\tfor (const record of records) {\n\t\t\tconst existing = existingRecords.find(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t);\n\n\t\t\tconst existingValue = existing?.records?.[0]?.content;\n\n\t\t\tif (\n\t\t\t\texisting &&\n\t\t\t\texistingValue !== undefined &&\n\t\t\t\tnormalize(existingValue) === normalize(record.value)\n\t\t\t) {\n\t\t\t\t// Record exists with same value - unchanged\n\t\t\t\tresults.push({\n\t\t\t\t\trecord,\n\t\t\t\t\tcreated: false,\n\t\t\t\t\tunchanged: true,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Create the record, or replace this name's records of this type.\n\t\t\tawait api.upsertRecords(\n\t\t\t\tdomain,\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tname: record.name,\n\t\t\t\t\t\ttype: record.type,\n\t\t\t\t\t\tttl: record.ttl,\n\t\t\t\t\t\trecords: [{ content: record.value }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tresults.push({\n\t\t\t\trecord,\n\t\t\t\tcreated: !existing,\n\t\t\t\tunchanged: false,\n\t\t\t});\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tasync deleteRecords(\n\t\tdomain: string,\n\t\trecords: DeleteDnsRecord[],\n\t): Promise<DeleteResult[]> {\n\t\tconst api = await this.getApi();\n\t\tconst results: DeleteResult[] = [];\n\n\t\t// Get existing records to check what exists\n\t\tconst existingRecords = await api.getRecords(domain);\n\n\t\t// Filter to only records that exist\n\t\tconst recordsToDelete = records.filter((record) =>\n\t\t\texistingRecords.some(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t),\n\t\t);\n\n\t\t// Delete existing records\n\t\tif (recordsToDelete.length > 0) {\n\t\t\ttry {\n\t\t\t\tawait api.deleteRecords(\n\t\t\t\t\tdomain,\n\t\t\t\t\trecordsToDelete.map((r) => ({\n\t\t\t\t\t\tname: r.name,\n\t\t\t\t\t\ttype: r.type as\n\t\t\t\t\t\t\t| 'A'\n\t\t\t\t\t\t\t| 'AAAA'\n\t\t\t\t\t\t\t| 'CNAME'\n\t\t\t\t\t\t\t| 'MX'\n\t\t\t\t\t\t\t| 'TXT'\n\t\t\t\t\t\t\t| 'SRV'\n\t\t\t\t\t\t\t| 'CAA',\n\t\t\t\t\t})),\n\t\t\t\t);\n\n\t\t\t\tfor (const record of recordsToDelete) {\n\t\t\t\t\tresults.push({\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\tdeleted: true,\n\t\t\t\t\t\tnotFound: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// If batch delete fails, report error for all records\n\t\t\t\tfor (const record of recordsToDelete) {\n\t\t\t\t\tresults.push({\n\t\t\t\t\t\trecord,\n\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t\tnotFound: false,\n\t\t\t\t\t\terror: String(error),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Mark non-existent records as not found\n\t\tfor (const record of records) {\n\t\t\tconst existing = existingRecords.find(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t);\n\t\t\tif (!existing) {\n\t\t\t\tresults.push({\n\t\t\t\t\trecord,\n\t\t\t\t\tdeleted: false,\n\t\t\t\t\tnotFound: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n}\n\nexport { HostingerApi, HostingerApiError } from './api';\n"],"mappings":"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"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { DeleteDnsRecord, DeleteResult, DnsProvider, DnsRecord as DnsRecord$1, UpsertDnsRecord, UpsertResult } from "../index.cjs";
|
|
2
|
+
//#region src/dns/hostinger/api.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Hostinger DNS API client
|
|
5
|
+
*
|
|
6
|
+
* API Documentation: https://developers.hostinger.com/
|
|
7
|
+
* Authentication: Bearer token from hpanel.hostinger.com/profile/api
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* DNS record types supported by Hostinger
|
|
11
|
+
*/
|
|
12
|
+
type DnsRecordType = 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA';
|
|
13
|
+
/**
|
|
14
|
+
* A single DNS record
|
|
15
|
+
*/
|
|
16
|
+
interface DnsRecord {
|
|
17
|
+
/** Subdomain name (e.g., 'api.joemoer' for api.joemoer.traflabs.io) */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Record type */
|
|
20
|
+
type: DnsRecordType;
|
|
21
|
+
/** TTL in seconds */
|
|
22
|
+
ttl: number;
|
|
23
|
+
/** Record values */
|
|
24
|
+
records: Array<{
|
|
25
|
+
content: string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Filter for deleting specific records
|
|
30
|
+
*/
|
|
31
|
+
interface DnsRecordFilter {
|
|
32
|
+
name: string;
|
|
33
|
+
type: DnsRecordType;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Hostinger API error
|
|
37
|
+
*/
|
|
38
|
+
export declare class HostingerApiError extends Error {
|
|
39
|
+
status: number;
|
|
40
|
+
statusText: string;
|
|
41
|
+
errors?: Record<string, string[]> | undefined;
|
|
42
|
+
constructor(message: string, status: number, statusText: string, errors?: Record<string, string[]> | undefined);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Hostinger DNS API client
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const api = new HostingerApi(token);
|
|
50
|
+
*
|
|
51
|
+
* // Get all records for a domain
|
|
52
|
+
* const records = await api.getRecords('traflabs.io');
|
|
53
|
+
*
|
|
54
|
+
* // Create/update records
|
|
55
|
+
* await api.upsertRecords('traflabs.io', [
|
|
56
|
+
* { name: 'api.joemoer', type: 'A', ttl: 300, records: ['1.2.3.4'] }
|
|
57
|
+
* ]);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class HostingerApi {
|
|
61
|
+
private token;
|
|
62
|
+
constructor(token: string);
|
|
63
|
+
/**
|
|
64
|
+
* Make a request to the Hostinger API
|
|
65
|
+
*/
|
|
66
|
+
private request;
|
|
67
|
+
/**
|
|
68
|
+
* Get all DNS records for a domain
|
|
69
|
+
*
|
|
70
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
71
|
+
*/
|
|
72
|
+
getRecords(domain: string): Promise<DnsRecord[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Create or update DNS records
|
|
75
|
+
*
|
|
76
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
77
|
+
* @param records - Records to create/update
|
|
78
|
+
* @param overwrite - If true, replaces all existing records. If false, merges with existing.
|
|
79
|
+
*/
|
|
80
|
+
upsertRecords(domain: string, records: DnsRecord[], overwrite?: boolean): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Validate DNS records before applying
|
|
83
|
+
*
|
|
84
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
85
|
+
* @param records - Records to validate
|
|
86
|
+
* @returns true if valid, throws if invalid
|
|
87
|
+
*/
|
|
88
|
+
validateRecords(domain: string, records: DnsRecord[]): Promise<boolean>;
|
|
89
|
+
/**
|
|
90
|
+
* Delete specific DNS records
|
|
91
|
+
*
|
|
92
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
93
|
+
* @param filters - Filters to match records for deletion
|
|
94
|
+
*/
|
|
95
|
+
deleteRecords(domain: string, filters: DnsRecordFilter[]): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Check if a specific record exists
|
|
98
|
+
*
|
|
99
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
100
|
+
* @param name - Subdomain name (e.g., 'api.joemoer')
|
|
101
|
+
* @param type - Record type (e.g., 'A')
|
|
102
|
+
*/
|
|
103
|
+
recordExists(domain: string, name: string, type?: DnsRecordType): Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* Create a single A record if it doesn't exist
|
|
106
|
+
*
|
|
107
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
108
|
+
* @param subdomain - Subdomain name (e.g., 'api.joemoer')
|
|
109
|
+
* @param ip - IP address to point to
|
|
110
|
+
* @param ttl - TTL in seconds (default: 300)
|
|
111
|
+
* @returns true if created, false if already exists
|
|
112
|
+
*/
|
|
113
|
+
createARecordIfNotExists(domain: string, subdomain: string, ip: string, ttl?: number): Promise<boolean>;
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/dns/hostinger/index.d.ts
|
|
117
|
+
/** A Hostinger API token, from hpanel.hostinger.com/profile/api. */
|
|
118
|
+
export interface HostingerCredential {
|
|
119
|
+
token: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Hostinger DNS provider implementation.
|
|
123
|
+
*/
|
|
124
|
+
export declare class HostingerProvider implements DnsProvider {
|
|
125
|
+
private readonly credential;
|
|
126
|
+
readonly name = "hostinger";
|
|
127
|
+
private api;
|
|
128
|
+
/**
|
|
129
|
+
* `credential`: where the token comes from, asked the first time the API
|
|
130
|
+
* is called. It throws when there is none: what to do about a missing
|
|
131
|
+
* token is the caller's to say.
|
|
132
|
+
*/
|
|
133
|
+
constructor(credential: () => Promise<HostingerCredential>);
|
|
134
|
+
/**
|
|
135
|
+
* Get or create the Hostinger API client.
|
|
136
|
+
*/
|
|
137
|
+
private getApi;
|
|
138
|
+
getRecords(domain: string): Promise<DnsRecord$1[]>;
|
|
139
|
+
upsertRecords(domain: string, records: UpsertDnsRecord[]): Promise<UpsertResult[]>;
|
|
140
|
+
deleteRecords(domain: string, records: DeleteDnsRecord[]): Promise<DeleteResult[]>;
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["DnsRecord"],"sources":["../../../src/dns/hostinger/api.ts","../../../src/dns/hostinger/index.ts"],"mappings":";;;;;;;;;;;KAYY;;;;UAaK;;EAEhB;;EAEA,MAAM;;EAEN;;EAEA,SAAS;IAAQ;;;;;;UAMD;EAChB;EACA,MAAM;;;;;qBAcM,0BAA0B;EAG9B;EACA;EACA,SAAS;EAJjB,YACC,iBACO,gBACA,oBACA,SAAS;;;;;;;;;;;;;;;;;;qBAuBL;UACJ;EAER,YAAY;;;;UAOE;;;;;;EAmDR,WAAW,iBAAiB,QAAQ;;;;;;;;EA6BpC,cACL,gBACA,SAAS,aACT,sBACE;;;;;;;;EAcG,gBACL,gBACA,SAAS,cACP;;;;;;;EAcG,cACL,gBACA,SAAS,oBACP;;;;;;;;EAaG,aACL,gBACA,cACA,OAAM,gBACJ;;;;;;;;;;EAcG,yBACL,gBACA,mBACA,YACA,eACE;;;;;iBCjOa;EAChB;;;;;qBAWY,6BAA6B;mBAUvB;WATT;UACD;;;;;;EAOR,YACkB,kBAAkB,QAAQ;;;;UAM9B;EAWR,WAAW,iBAAiB,QAAQA;EAYpC,cACL,gBACA,SAAS,oBACP,QAAQ;EAoDL,cACL,gBACA,SAAS,oBACP,QAAQ"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { DeleteDnsRecord, DeleteResult, DnsProvider, DnsRecord as DnsRecord$1, UpsertDnsRecord, UpsertResult } from "../index.mjs";
|
|
2
|
+
//#region src/dns/hostinger/api.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Hostinger DNS API client
|
|
5
|
+
*
|
|
6
|
+
* API Documentation: https://developers.hostinger.com/
|
|
7
|
+
* Authentication: Bearer token from hpanel.hostinger.com/profile/api
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* DNS record types supported by Hostinger
|
|
11
|
+
*/
|
|
12
|
+
type DnsRecordType = 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA';
|
|
13
|
+
/**
|
|
14
|
+
* A single DNS record
|
|
15
|
+
*/
|
|
16
|
+
interface DnsRecord {
|
|
17
|
+
/** Subdomain name (e.g., 'api.joemoer' for api.joemoer.traflabs.io) */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Record type */
|
|
20
|
+
type: DnsRecordType;
|
|
21
|
+
/** TTL in seconds */
|
|
22
|
+
ttl: number;
|
|
23
|
+
/** Record values */
|
|
24
|
+
records: Array<{
|
|
25
|
+
content: string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Filter for deleting specific records
|
|
30
|
+
*/
|
|
31
|
+
interface DnsRecordFilter {
|
|
32
|
+
name: string;
|
|
33
|
+
type: DnsRecordType;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Hostinger API error
|
|
37
|
+
*/
|
|
38
|
+
export declare class HostingerApiError extends Error {
|
|
39
|
+
status: number;
|
|
40
|
+
statusText: string;
|
|
41
|
+
errors?: Record<string, string[]> | undefined;
|
|
42
|
+
constructor(message: string, status: number, statusText: string, errors?: Record<string, string[]> | undefined);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Hostinger DNS API client
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const api = new HostingerApi(token);
|
|
50
|
+
*
|
|
51
|
+
* // Get all records for a domain
|
|
52
|
+
* const records = await api.getRecords('traflabs.io');
|
|
53
|
+
*
|
|
54
|
+
* // Create/update records
|
|
55
|
+
* await api.upsertRecords('traflabs.io', [
|
|
56
|
+
* { name: 'api.joemoer', type: 'A', ttl: 300, records: ['1.2.3.4'] }
|
|
57
|
+
* ]);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class HostingerApi {
|
|
61
|
+
private token;
|
|
62
|
+
constructor(token: string);
|
|
63
|
+
/**
|
|
64
|
+
* Make a request to the Hostinger API
|
|
65
|
+
*/
|
|
66
|
+
private request;
|
|
67
|
+
/**
|
|
68
|
+
* Get all DNS records for a domain
|
|
69
|
+
*
|
|
70
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
71
|
+
*/
|
|
72
|
+
getRecords(domain: string): Promise<DnsRecord[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Create or update DNS records
|
|
75
|
+
*
|
|
76
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
77
|
+
* @param records - Records to create/update
|
|
78
|
+
* @param overwrite - If true, replaces all existing records. If false, merges with existing.
|
|
79
|
+
*/
|
|
80
|
+
upsertRecords(domain: string, records: DnsRecord[], overwrite?: boolean): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Validate DNS records before applying
|
|
83
|
+
*
|
|
84
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
85
|
+
* @param records - Records to validate
|
|
86
|
+
* @returns true if valid, throws if invalid
|
|
87
|
+
*/
|
|
88
|
+
validateRecords(domain: string, records: DnsRecord[]): Promise<boolean>;
|
|
89
|
+
/**
|
|
90
|
+
* Delete specific DNS records
|
|
91
|
+
*
|
|
92
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
93
|
+
* @param filters - Filters to match records for deletion
|
|
94
|
+
*/
|
|
95
|
+
deleteRecords(domain: string, filters: DnsRecordFilter[]): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Check if a specific record exists
|
|
98
|
+
*
|
|
99
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
100
|
+
* @param name - Subdomain name (e.g., 'api.joemoer')
|
|
101
|
+
* @param type - Record type (e.g., 'A')
|
|
102
|
+
*/
|
|
103
|
+
recordExists(domain: string, name: string, type?: DnsRecordType): Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* Create a single A record if it doesn't exist
|
|
106
|
+
*
|
|
107
|
+
* @param domain - Root domain (e.g., 'traflabs.io')
|
|
108
|
+
* @param subdomain - Subdomain name (e.g., 'api.joemoer')
|
|
109
|
+
* @param ip - IP address to point to
|
|
110
|
+
* @param ttl - TTL in seconds (default: 300)
|
|
111
|
+
* @returns true if created, false if already exists
|
|
112
|
+
*/
|
|
113
|
+
createARecordIfNotExists(domain: string, subdomain: string, ip: string, ttl?: number): Promise<boolean>;
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/dns/hostinger/index.d.ts
|
|
117
|
+
/** A Hostinger API token, from hpanel.hostinger.com/profile/api. */
|
|
118
|
+
export interface HostingerCredential {
|
|
119
|
+
token: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Hostinger DNS provider implementation.
|
|
123
|
+
*/
|
|
124
|
+
export declare class HostingerProvider implements DnsProvider {
|
|
125
|
+
private readonly credential;
|
|
126
|
+
readonly name = "hostinger";
|
|
127
|
+
private api;
|
|
128
|
+
/**
|
|
129
|
+
* `credential`: where the token comes from, asked the first time the API
|
|
130
|
+
* is called. It throws when there is none: what to do about a missing
|
|
131
|
+
* token is the caller's to say.
|
|
132
|
+
*/
|
|
133
|
+
constructor(credential: () => Promise<HostingerCredential>);
|
|
134
|
+
/**
|
|
135
|
+
* Get or create the Hostinger API client.
|
|
136
|
+
*/
|
|
137
|
+
private getApi;
|
|
138
|
+
getRecords(domain: string): Promise<DnsRecord$1[]>;
|
|
139
|
+
upsertRecords(domain: string, records: UpsertDnsRecord[]): Promise<UpsertResult[]>;
|
|
140
|
+
deleteRecords(domain: string, records: DeleteDnsRecord[]): Promise<DeleteResult[]>;
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["DnsRecord"],"sources":["../../../src/dns/hostinger/api.ts","../../../src/dns/hostinger/index.ts"],"mappings":";;;;;;;;;;;KAYY;;;;UAaK;;EAEhB;;EAEA,MAAM;;EAEN;;EAEA,SAAS;IAAQ;;;;;;UAMD;EAChB;EACA,MAAM;;;;;qBAcM,0BAA0B;EAG9B;EACA;EACA,SAAS;EAJjB,YACC,iBACO,gBACA,oBACA,SAAS;;;;;;;;;;;;;;;;;;qBAuBL;UACJ;EAER,YAAY;;;;UAOE;;;;;;EAmDR,WAAW,iBAAiB,QAAQ;;;;;;;;EA6BpC,cACL,gBACA,SAAS,aACT,sBACE;;;;;;;;EAcG,gBACL,gBACA,SAAS,cACP;;;;;;;EAcG,cACL,gBACA,SAAS,oBACP;;;;;;;;EAaG,aACL,gBACA,cACA,OAAM,gBACJ;;;;;;;;;;EAcG,yBACL,gBACA,mBACA,YACA,eACE;;;;;iBCjOa;EAChB;;;;;qBAWY,6BAA6B;mBAUvB;WATT;UACD;;;;;;EAOR,YACkB,kBAAkB,QAAQ;;;;UAM9B;EAWR,WAAW,iBAAiB,QAAQA;EAYpC,cACL,gBACA,SAAS,oBACP,QAAQ;EAoDL,cACL,gBACA,SAAS,oBACP,QAAQ"}
|