1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178 | /**
* Hosted DNS: put registered domains on ird nameservers, manage the hosted
* zones' records, DNSSEC and nameserver set, and bring domains held at other
* registrars onto ird DNS through claims. Mutations are subject to the
* client's domain gate when configured.
*/
import type { Client } from './client.js';
import { checkGate } from './gate.js';
import * as http from './http.js';
import type { Body, Query } from './types.js';
/** POST /domains/registrations/{id}/dns — Put a domain on ird nameservers (202). */
export const enableHosting = async (
client: Client,
id: string,
body?: Body<'/domains/registrations/{id}/dns', 'post'>,
) => {
await checkGate(client, 'POST /domains/registrations/{id}/dns', { registrationId: id });
return http.post(client, '/domains/registrations/{id}/dns', { params: { id }, body });
};
/** DELETE /domains/registrations/{id}/dns — Take a domain off ird DNS. */
export const disableHosting = async (
client: Client,
id: string,
body?: Body<'/domains/registrations/{id}/dns', 'delete'>,
) => {
await checkGate(client, 'DELETE /domains/registrations/{id}/dns', { registrationId: id });
return http.del(client, '/domains/registrations/{id}/dns', { params: { id }, body });
};
/** GET /domains/registrations/{id}/dns/dnssec — DNSSEC state of the hosted zone. */
export const getDnssec = (client: Client, id: string) =>
http.get(client, '/domains/registrations/{id}/dns/dnssec', { params: { id } });
/** POST /domains/registrations/{id}/dns/dnssec — Enable DNSSEC on the hosted zone (202). */
export const enableDnssec = async (
client: Client,
id: string,
body?: Body<'/domains/registrations/{id}/dns/dnssec', 'post'>,
) => {
await checkGate(client, 'POST /domains/registrations/{id}/dns/dnssec', { registrationId: id });
return http.post(client, '/domains/registrations/{id}/dns/dnssec', { params: { id }, body });
};
/** DELETE /domains/registrations/{id}/dns/dnssec — Disable DNSSEC on the hosted zone (202). */
export const disableDnssec = async (
client: Client,
id: string,
body?: Body<'/domains/registrations/{id}/dns/dnssec', 'delete'>,
) => {
await checkGate(client, 'DELETE /domains/registrations/{id}/dns/dnssec', { registrationId: id });
return http.del(client, '/domains/registrations/{id}/dns/dnssec', { params: { id }, body });
};
/**
* GET /domains/registrations/{id}/dns/nameservers — The nameserver set the
* hosted zone is published under: `mode` "shared" (ird's public nameservers)
* or "labels" (private nameservers unique to the domain), with
* `nameservers`, `nameservers_ready` and `available_modes`. Free.
*/
export const hostedNameservers = (client: Client, id: string) =>
http.get(client, '/domains/registrations/{id}/dns/nameservers', { params: { id } });
/**
* POST /domains/registrations/{id}/dns/nameservers — Move the hosted zone
* between nameserver sets: `mode` "shared" or "labels" (labels are offered
* for .ro domains only). Answers 200 when nothing had to change, 202 with a
* `registry_action` when a registrar nameserver change was enqueued — poll
* `hostedNameservers` for `nameservers_ready`. Free.
*/
export const setHostedNameservers = async (
client: Client,
id: string,
body: Body<'/domains/registrations/{id}/dns/nameservers', 'post'>,
) => {
await checkGate(client, 'POST /domains/registrations/{id}/dns/nameservers', { registrationId: id });
return http.post(client, '/domains/registrations/{id}/dns/nameservers', { params: { id }, body });
};
/** GET /dns/domains — Your hosted DNS domains. */
export const listZones = (client: Client) => http.get(client, '/dns/domains');
/** GET /dns/domains/{domain} — A hosted domain's zone. */
export const getZone = (client: Client, domain: string) =>
http.get(client, '/dns/domains/{domain}', { params: { domain } });
/** PUT /dns/domains/{domain}/records — Set a DNS record or RRset. */
export const setRecord = async (client: Client, domain: string, body: Body<'/dns/domains/{domain}/records', 'put'>) => {
await checkGate(client, 'PUT /dns/domains/{domain}/records', { domain });
return http.put(client, '/dns/domains/{domain}/records', { params: { domain }, body });
};
/** DELETE /dns/domains/{domain}/records — Delete a DNS record (carries a JSON body). */
export const deleteRecord = async (
client: Client,
domain: string,
body: Body<'/dns/domains/{domain}/records', 'delete'>,
) => {
await checkGate(client, 'DELETE /dns/domains/{domain}/records', { domain });
return http.del(client, '/dns/domains/{domain}/records', { params: { domain }, body });
};
/**
* GET /dns/claims — Domains you hold at another registrar and host (or are
* about to host) on ird DNS: every live claim plus those ended in the last
* 30 days, newest first. Optional `state` (pending / verified / active /
* lapsed / revoked / expired) and `limit` (1..500, default 50).
*/
export const listClaims = (client: Client, query?: Query<'/dns/claims', 'get'>) =>
http.get(client, '/dns/claims', { query });
/**
* POST /dns/claims — Claim a registrable domain registered elsewhere so ird
* can be its DNS (201). The response's `claim` carries the `nameservers` to
* set at your registrar; the claim activates once the parent zone lists
* exactly those (checked every few minutes, or now via `verifyClaim`).
* Gated on `domain`.
*/
export const createClaim = async (client: Client, body: Body<'/dns/claims', 'post'>) => {
await checkGate(client, 'POST /dns/claims', { domain: body.domain });
return http.post(client, '/dns/claims', { body });
};
/**
* GET /dns/claims/{id} — A claim: nameservers to set, its window while
* pending, the latest delegation read and registry facts.
*/
export const getClaim = (client: Client, id: string) => http.get(client, '/dns/claims/{id}', { params: { id } });
/** Resolve the claim's domain (only when gated) and run the gate. */
const checkClaimGate = async (client: Client, op: string, id: string): Promise<void> => {
if (!client.gate) return;
const { claim } = await getClaim(client, id);
await checkGate(client, op, { domain: claim?.domain });
};
/**
* DELETE /dns/claims/{id} — Release a claim: it ends (state revoked) and the
* hosted zone goes out of service, a snapshot of its records kept. Point the
* domain's nameservers elsewhere first. Gated on the claim's domain
* (resolved via `getClaim` when a gate is set).
*/
export const releaseClaim = async (client: Client, id: string) => {
await checkClaimGate(client, 'DELETE /dns/claims/{id}', id);
return http.del(client, '/dns/claims/{id}', { params: { id } });
};
/**
* PUT /dns/claims/{id}/seed — Attach a copy of the domain's current records
* to a pending claim, so the zone ird creates at activation starts from them
* instead of empty. `snapshot_id` comes from `domains.dnsSnapshot`, taken
* while the domain still resolves at its previous host. Gated on the
* claim's domain (resolved via `getClaim` when a gate is set).
*/
export const seedClaim = async (client: Client, id: string, body: Body<'/dns/claims/{id}/seed', 'put'>) => {
await checkClaimGate(client, 'PUT /dns/claims/{id}/seed', id);
return http.put(client, '/dns/claims/{id}/seed', { params: { id }, body });
};
/**
* DELETE /dns/claims/{id}/seed — Drop the attached copy; the zone then
* starts empty at activation. Gated on the claim's domain (resolved via
* `getClaim` when a gate is set).
*/
export const unseedClaim = async (client: Client, id: string) => {
await checkClaimGate(client, 'DELETE /dns/claims/{id}/seed', id);
return http.del(client, '/dns/claims/{id}/seed', { params: { id } });
};
/**
* POST /dns/claims/{id}/verify — Read the domain's delegation at its parent
* zone now and activate the claim when it lists the claim's nameservers.
* Anything else is not an error: the response is 200 with `check.ok` false
* and a `reason`.
*/
export const verifyClaim = (client: Client, id: string) =>
http.post(client, '/dns/claims/{id}/verify', { params: { id } });
|