@serve.zone/interfaces 32.123.0 → 32.125.0
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/changelog.md +17 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/backupmx.d.ts +135 -0
- package/dist_ts/data/backupmx.js +128 -0
- package/dist_ts/data/certificateauthority.d.ts +57 -0
- package/dist_ts/data/certificateauthority.js +69 -0
- package/dist_ts/data/externaldns.d.ts +135 -0
- package/dist_ts/data/externaldns.js +138 -0
- package/dist_ts/data/gateway.d.ts +22 -0
- package/dist_ts/data/gateway.js +1 -1
- package/dist_ts/data/gatewayarearows.d.ts +2 -1
- package/dist_ts/data/gatewayarearows.js +1 -1
- package/dist_ts/data/gatewayareas.d.ts +19 -0
- package/dist_ts/data/gatewayareas.js +1 -1
- package/dist_ts/data/gatewayareas.validation.js +37 -5
- package/dist_ts/data/hetzner.d.ts +177 -0
- package/dist_ts/data/hetzner.js +253 -0
- package/dist_ts/data/index.d.ts +5 -0
- package/dist_ts/data/index.js +6 -1
- package/dist_ts/data/pathrouting.d.ts +170 -0
- package/dist_ts/data/pathrouting.js +227 -0
- package/dist_ts/requests/backupmx.d.ts +209 -0
- package/dist_ts/requests/backupmx.js +2 -0
- package/dist_ts/requests/certificateauthority.d.ts +118 -0
- package/dist_ts/requests/certificateauthority.js +2 -0
- package/dist_ts/requests/externaldns.d.ts +213 -0
- package/dist_ts/requests/externaldns.js +2 -0
- package/dist_ts/requests/hetzner.d.ts +216 -0
- package/dist_ts/requests/hetzner.js +2 -0
- package/dist_ts/requests/index.d.ts +6 -1
- package/dist_ts/requests/index.js +7 -2
- package/dist_ts/requests/pathrouting.d.ts +107 -0
- package/dist_ts/requests/pathrouting.js +2 -0
- package/package.json +47 -8
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/backupmx.ts +252 -0
- package/ts/data/certificateauthority.ts +115 -0
- package/ts/data/externaldns.ts +273 -0
- package/ts/data/gateway.ts +22 -0
- package/ts/data/gatewayarearows.ts +2 -0
- package/ts/data/gatewayareas.ts +20 -0
- package/ts/data/gatewayareas.validation.ts +40 -4
- package/ts/data/hetzner.ts +419 -0
- package/ts/data/index.ts +5 -0
- package/ts/data/pathrouting.ts +410 -0
- package/ts/requests/backupmx.ts +275 -0
- package/ts/requests/certificateauthority.ts +139 -0
- package/ts/requests/externaldns.ts +263 -0
- package/ts/requests/hetzner.ts +276 -0
- package/ts/requests/index.ts +10 -0
- package/ts/requests/pathrouting.ts +134 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
export const externalDnsProviderTypes = Object.freeze([
|
|
2
|
+
'cloudflare',
|
|
3
|
+
] as const);
|
|
4
|
+
|
|
5
|
+
export type TExternalDnsProviderType = typeof externalDnsProviderTypes[number];
|
|
6
|
+
|
|
7
|
+
export const externalDnsRecordTypes = Object.freeze([
|
|
8
|
+
'A',
|
|
9
|
+
'AAAA',
|
|
10
|
+
'CNAME',
|
|
11
|
+
'TXT',
|
|
12
|
+
'MX',
|
|
13
|
+
'SRV',
|
|
14
|
+
'CAA',
|
|
15
|
+
'NS',
|
|
16
|
+
] as const);
|
|
17
|
+
|
|
18
|
+
export type TExternalDnsRecordType = typeof externalDnsRecordTypes[number];
|
|
19
|
+
|
|
20
|
+
export const externalDnsRefusalCodes = Object.freeze([
|
|
21
|
+
'administrator-required',
|
|
22
|
+
'fresh-sign-in-required',
|
|
23
|
+
'invalid-request',
|
|
24
|
+
'provider-not-found',
|
|
25
|
+
'provider-name-conflict',
|
|
26
|
+
'provider-in-use',
|
|
27
|
+
'zone-not-found',
|
|
28
|
+
'record-not-found',
|
|
29
|
+
'record-conflict',
|
|
30
|
+
'precondition-failed',
|
|
31
|
+
'provider-unavailable',
|
|
32
|
+
'protected-hostname',
|
|
33
|
+
'invalid-record-value',
|
|
34
|
+
'mutation-not-found',
|
|
35
|
+
] as const);
|
|
36
|
+
|
|
37
|
+
export type TExternalDnsRefusalCode = typeof externalDnsRefusalCodes[number];
|
|
38
|
+
|
|
39
|
+
export const externalDnsMutationActions = Object.freeze([
|
|
40
|
+
'create',
|
|
41
|
+
'update',
|
|
42
|
+
'delete',
|
|
43
|
+
'takeover',
|
|
44
|
+
'rollback',
|
|
45
|
+
] as const);
|
|
46
|
+
|
|
47
|
+
export type TExternalDnsMutationAction = typeof externalDnsMutationActions[number];
|
|
48
|
+
|
|
49
|
+
export const externalDnsContract = Object.freeze({
|
|
50
|
+
managementMarkerPrefix: 'servezone:cloudly:',
|
|
51
|
+
defaultTtlSeconds: 60,
|
|
52
|
+
minimumTtlSeconds: 1,
|
|
53
|
+
maximumTtlSeconds: 86_400,
|
|
54
|
+
maximumProviderNameLength: 160,
|
|
55
|
+
maximumHostnameLength: 253,
|
|
56
|
+
maximumRecordValueLength: 4_096,
|
|
57
|
+
maximumBatchRecords: 200,
|
|
58
|
+
} as const);
|
|
59
|
+
|
|
60
|
+
export interface IExternalDnsProviderTokenMetadata {
|
|
61
|
+
configured: boolean;
|
|
62
|
+
updatedAt: number | null;
|
|
63
|
+
/** Short SHA-256 prefix fingerprint (never the token itself). */
|
|
64
|
+
fingerprint: string | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface IExternalDnsProvider {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
type: TExternalDnsProviderType;
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
token: IExternalDnsProviderTokenMetadata;
|
|
73
|
+
status: 'untested' | 'ok' | 'error';
|
|
74
|
+
lastTestedAt: number | null;
|
|
75
|
+
lastSyncedAt: number | null;
|
|
76
|
+
lastError: string | null;
|
|
77
|
+
zoneCount: number;
|
|
78
|
+
createdAt: number;
|
|
79
|
+
updatedAt: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface IExternalDnsZone {
|
|
83
|
+
id: string;
|
|
84
|
+
providerId: string;
|
|
85
|
+
name: string;
|
|
86
|
+
externalZoneId: string;
|
|
87
|
+
nameservers: string[];
|
|
88
|
+
recordCount: number;
|
|
89
|
+
lastSyncedAt: number;
|
|
90
|
+
createdAt: number;
|
|
91
|
+
updatedAt: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface IExternalDnsRecord {
|
|
95
|
+
id: string;
|
|
96
|
+
providerId: string;
|
|
97
|
+
zoneName: string;
|
|
98
|
+
providerRecordId: string;
|
|
99
|
+
name: string;
|
|
100
|
+
type: TExternalDnsRecordType;
|
|
101
|
+
value: string;
|
|
102
|
+
ttl: number;
|
|
103
|
+
proxied: boolean;
|
|
104
|
+
ownership: 'cloudly' | 'unmanaged';
|
|
105
|
+
managementMarker: string | null;
|
|
106
|
+
ownerKey: string | null;
|
|
107
|
+
updatedAt: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface IExternalDnsDesiredRecord {
|
|
111
|
+
name: string;
|
|
112
|
+
type: TExternalDnsRecordType;
|
|
113
|
+
value: string;
|
|
114
|
+
ttl?: number;
|
|
115
|
+
proxied?: boolean;
|
|
116
|
+
/** Stable Cloudly ownership key (e.g. `service:<id>` or `control-plane:cloudly`). */
|
|
117
|
+
ownerKey: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface IExternalDnsConflict {
|
|
121
|
+
fqdn: string;
|
|
122
|
+
zoneName: string;
|
|
123
|
+
providerId: string;
|
|
124
|
+
blockingRecords: IExternalDnsRecord[];
|
|
125
|
+
desiredRecords: IExternalDnsDesiredRecord[];
|
|
126
|
+
detectedAt: number;
|
|
127
|
+
message: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface IExternalDnsTakeoverPreview {
|
|
131
|
+
fqdn: string;
|
|
132
|
+
zoneName: string;
|
|
133
|
+
providerId: string;
|
|
134
|
+
blockingRecords: IExternalDnsRecord[];
|
|
135
|
+
desiredRecords: IExternalDnsDesiredRecord[];
|
|
136
|
+
willReplaceRecordIds: string[];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface IExternalDnsRecordSnapshot {
|
|
140
|
+
providerRecordId: string;
|
|
141
|
+
name: string;
|
|
142
|
+
type: TExternalDnsRecordType;
|
|
143
|
+
value: string;
|
|
144
|
+
ttl: number;
|
|
145
|
+
proxied: boolean;
|
|
146
|
+
managementMarker: string | null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface IExternalDnsMutationJournalEntry {
|
|
150
|
+
id: string;
|
|
151
|
+
providerId: string;
|
|
152
|
+
zoneName: string;
|
|
153
|
+
fqdn: string;
|
|
154
|
+
action: TExternalDnsMutationAction;
|
|
155
|
+
actorId: string;
|
|
156
|
+
reason: string | null;
|
|
157
|
+
previousRecords: IExternalDnsRecordSnapshot[];
|
|
158
|
+
resultingRecords: IExternalDnsRecordSnapshot[];
|
|
159
|
+
rolledBackByMutationId: string | null;
|
|
160
|
+
createdAt: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface IExternalDnsReconcileSummary {
|
|
164
|
+
providerId: string;
|
|
165
|
+
zoneName: string;
|
|
166
|
+
applied: number;
|
|
167
|
+
unchanged: number;
|
|
168
|
+
deleted: number;
|
|
169
|
+
conflicts: IExternalDnsConflict[];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const hostnameLabelPattern = /^[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9])?$/;
|
|
173
|
+
|
|
174
|
+
export const isExternalDnsProviderType = (valueArg: unknown): valueArg is TExternalDnsProviderType =>
|
|
175
|
+
typeof valueArg === 'string' && (externalDnsProviderTypes as readonly string[]).includes(valueArg);
|
|
176
|
+
|
|
177
|
+
export const isExternalDnsRecordType = (valueArg: unknown): valueArg is TExternalDnsRecordType =>
|
|
178
|
+
typeof valueArg === 'string' && (externalDnsRecordTypes as readonly string[]).includes(valueArg);
|
|
179
|
+
|
|
180
|
+
export const normalizeExternalDnsName = (nameArg: unknown): string | null => {
|
|
181
|
+
if (typeof nameArg !== 'string') return null;
|
|
182
|
+
const trimmed = nameArg.trim().toLowerCase().replace(/\.+$/, '');
|
|
183
|
+
if (trimmed.length === 0 || trimmed.length > externalDnsContract.maximumHostnameLength) return null;
|
|
184
|
+
const labels = trimmed.split('.');
|
|
185
|
+
if (labels.length < 2) return null;
|
|
186
|
+
const [first, ...rest] = labels;
|
|
187
|
+
const firstValid = first === '*' ? rest.length > 0 : hostnameLabelPattern.test(first);
|
|
188
|
+
if (!firstValid || !rest.every((labelArg) => hostnameLabelPattern.test(labelArg))) return null;
|
|
189
|
+
return trimmed;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const normalizeExternalDnsZone = (zoneArg: unknown): string | null => {
|
|
193
|
+
const normalized = normalizeExternalDnsName(zoneArg);
|
|
194
|
+
if (!normalized || normalized.startsWith('*.')) return null;
|
|
195
|
+
return normalized;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export const isHostnameInZone = (fqdnArg: string, zoneNameArg: string): boolean => {
|
|
199
|
+
const fqdn = normalizeExternalDnsName(fqdnArg);
|
|
200
|
+
const zone = normalizeExternalDnsZone(zoneNameArg);
|
|
201
|
+
if (!fqdn || !zone) return false;
|
|
202
|
+
return fqdn === zone || fqdn.endsWith(`.${zone}`);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export const createCloudlyManagementMarker = (ownerKeyArg: string): string => {
|
|
206
|
+
const sanitized = ownerKeyArg.trim().replace(/\s+/g, '');
|
|
207
|
+
if (!sanitized || sanitized.length > 160) {
|
|
208
|
+
throw new Error('ownerKey must be a non-empty string of at most 160 characters');
|
|
209
|
+
}
|
|
210
|
+
return `${externalDnsContract.managementMarkerPrefix}${sanitized}`;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export const parseCloudlyManagementMarker = (markerArg: unknown): string | null => {
|
|
214
|
+
if (typeof markerArg !== 'string') return null;
|
|
215
|
+
const trimmed = markerArg.trim();
|
|
216
|
+
if (!trimmed.startsWith(externalDnsContract.managementMarkerPrefix)) return null;
|
|
217
|
+
const ownerKey = trimmed.slice(externalDnsContract.managementMarkerPrefix.length).trim();
|
|
218
|
+
return ownerKey.length > 0 ? ownerKey : null;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export const isCloudlyManagedMarker = (markerArg: unknown): boolean =>
|
|
222
|
+
parseCloudlyManagementMarker(markerArg) !== null;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Returns true when an existing record at the same FQDN conflicts with writing a desired record.
|
|
226
|
+
* CNAME records conflict with any other record type at the same name (RFC 1034 §3.6.2);
|
|
227
|
+
* otherwise records of the same type conflict unless owned by Cloudly.
|
|
228
|
+
*/
|
|
229
|
+
export const isConflictingDnsRecordType = (
|
|
230
|
+
existingTypeArg: TExternalDnsRecordType,
|
|
231
|
+
desiredTypeArg: TExternalDnsRecordType,
|
|
232
|
+
): boolean => {
|
|
233
|
+
if (existingTypeArg === desiredTypeArg) return true;
|
|
234
|
+
return existingTypeArg === 'CNAME' || desiredTypeArg === 'CNAME';
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const validateExternalDnsDesiredRecord = (recordArg: unknown): string[] => {
|
|
238
|
+
const errors: string[] = [];
|
|
239
|
+
if (recordArg === null || typeof recordArg !== 'object' || Array.isArray(recordArg)) {
|
|
240
|
+
return ['desired record must be an object'];
|
|
241
|
+
}
|
|
242
|
+
const candidate = recordArg as Record<string, unknown>;
|
|
243
|
+
if (normalizeExternalDnsName(candidate.name) === null) {
|
|
244
|
+
errors.push('name must be a valid DNS hostname');
|
|
245
|
+
}
|
|
246
|
+
if (!isExternalDnsRecordType(candidate.type)) {
|
|
247
|
+
errors.push('type must be a supported DNS record type');
|
|
248
|
+
}
|
|
249
|
+
if (
|
|
250
|
+
typeof candidate.value !== 'string'
|
|
251
|
+
|| candidate.value.trim().length === 0
|
|
252
|
+
|| candidate.value.length > externalDnsContract.maximumRecordValueLength
|
|
253
|
+
) {
|
|
254
|
+
errors.push('value must be a non-empty string within maximum length');
|
|
255
|
+
}
|
|
256
|
+
if (candidate.ttl !== undefined) {
|
|
257
|
+
if (
|
|
258
|
+
typeof candidate.ttl !== 'number'
|
|
259
|
+
|| !Number.isInteger(candidate.ttl)
|
|
260
|
+
|| candidate.ttl < externalDnsContract.minimumTtlSeconds
|
|
261
|
+
|| candidate.ttl > externalDnsContract.maximumTtlSeconds
|
|
262
|
+
) {
|
|
263
|
+
errors.push('ttl must be an integer between 1 and 86400');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (candidate.proxied !== undefined && typeof candidate.proxied !== 'boolean') {
|
|
267
|
+
errors.push('proxied must be a boolean when provided');
|
|
268
|
+
}
|
|
269
|
+
if (typeof candidate.ownerKey !== 'string' || candidate.ownerKey.trim().length === 0 || candidate.ownerKey.trim().length > 160) {
|
|
270
|
+
errors.push('ownerKey must be a non-empty string of at most 160 characters');
|
|
271
|
+
}
|
|
272
|
+
return errors;
|
|
273
|
+
};
|
package/ts/data/gateway.ts
CHANGED
|
@@ -287,6 +287,12 @@ export interface IGatewayCapabilities {
|
|
|
287
287
|
configEvents?: true;
|
|
288
288
|
/** The adopted controller session serves `readGatewayServiceHealth`. */
|
|
289
289
|
serviceHealth?: true;
|
|
290
|
+
/** Multi-gateway optimal path routing capabilities advertised by the gateway. */
|
|
291
|
+
routing?: {
|
|
292
|
+
pathTelemetry?: true;
|
|
293
|
+
pathProbing?: true;
|
|
294
|
+
loopGuard?: true;
|
|
295
|
+
};
|
|
290
296
|
routes: {
|
|
291
297
|
read: boolean;
|
|
292
298
|
write: boolean;
|
|
@@ -323,6 +329,11 @@ export interface IGatewayCapabilities {
|
|
|
323
329
|
storeManagement?: true;
|
|
324
330
|
/** Related wildcard import against an observed legacy backing on the adopted session. */
|
|
325
331
|
storeRelatedImport?: true;
|
|
332
|
+
/**
|
|
333
|
+
* When `true`, Cloudly owns ACME issuance and pushes leaf certificate bundles to the gateway
|
|
334
|
+
* via `pushGatewayCertificateBundle`; the gateway disables local ACME issuance.
|
|
335
|
+
*/
|
|
336
|
+
controllerPushed?: true;
|
|
326
337
|
};
|
|
327
338
|
email: {
|
|
328
339
|
domains: boolean;
|
|
@@ -335,6 +346,11 @@ export interface IGatewayCapabilities {
|
|
|
335
346
|
* means unsupported.
|
|
336
347
|
*/
|
|
337
348
|
observations?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* The mail area accepts `backupMxTargets` and `domains[].backupMxEnabled`. Cloudly may send
|
|
351
|
+
* those members only when the gateway advertises this flag.
|
|
352
|
+
*/
|
|
353
|
+
backupMxTargets?: true;
|
|
338
354
|
};
|
|
339
355
|
remoteIngress: {
|
|
340
356
|
enabled: boolean;
|
|
@@ -353,6 +369,12 @@ export interface IGatewayCapabilities {
|
|
|
353
369
|
providerManaged: boolean;
|
|
354
370
|
/** The adopted connector serves redacted DNS diagnostics and stored-credential connection tests. */
|
|
355
371
|
operations?: true;
|
|
372
|
+
/**
|
|
373
|
+
* When `true`, Cloudly owns external DNS providers (e.g. Cloudflare) directly: Cloudly strips
|
|
374
|
+
* external provider rows and API tokens from the gateway's pushed `dns` area, and the gateway
|
|
375
|
+
* skips external provider mirroring and external route DNS reconciliation.
|
|
376
|
+
*/
|
|
377
|
+
externalProvidersDisabled?: true;
|
|
356
378
|
/** The adopted connector pages records from its durable provider-zone mirror; no provider call is made. */
|
|
357
379
|
providerRecords?: true;
|
|
358
380
|
/**
|
|
@@ -36,6 +36,7 @@ import type {
|
|
|
36
36
|
IGatewayBlockRuleRow,
|
|
37
37
|
IGatewayCoreMailCredentialVerifier,
|
|
38
38
|
IGatewayCoreMailPeerRow,
|
|
39
|
+
IGatewayMailBackupMxTargetRow,
|
|
39
40
|
IGatewayDnsClientHostnameRow,
|
|
40
41
|
IGatewayDnsDomainRow,
|
|
41
42
|
IGatewayDnsProtectedHostnameRow,
|
|
@@ -205,6 +206,7 @@ export interface IGatewayAreaRowWrites {
|
|
|
205
206
|
smtpAccounts: IGatewaySmtpAccountRowWrite;
|
|
206
207
|
identities: IGatewayMailIdentityRowWrite;
|
|
207
208
|
coreMailPeers: IGatewayCoreMailPeerRowWrite;
|
|
209
|
+
backupMxTargets?: IGatewayMailBackupMxTargetRow;
|
|
208
210
|
};
|
|
209
211
|
edges: {
|
|
210
212
|
hub: IGatewayEdgeHubSettings;
|
package/ts/data/gatewayareas.ts
CHANGED
|
@@ -897,6 +897,11 @@ export interface IGatewayMailDomainRow {
|
|
|
897
897
|
rateLimits: IGatewayMailDomainRateLimits | null;
|
|
898
898
|
/** A set of edge ids or tags; empty reaches every mail edge (the gateway reads absent as empty). */
|
|
899
899
|
edgeFilter: string[];
|
|
900
|
+
/**
|
|
901
|
+
* Optional opt-in to publish managed Backup MX records (e.g. `MX 30 backupmx.*`) for this domain.
|
|
902
|
+
* Sent only when the gateway advertises `email.backupMxTargets`.
|
|
903
|
+
*/
|
|
904
|
+
backupMxEnabled?: boolean;
|
|
900
905
|
}
|
|
901
906
|
|
|
902
907
|
/** One SMTP submission account. */
|
|
@@ -968,6 +973,16 @@ export interface IGatewayCoreMailPeerRow {
|
|
|
968
973
|
credentials: IGatewayCoreMailCredentialVerifier[];
|
|
969
974
|
}
|
|
970
975
|
|
|
976
|
+
/** One managed Backup MX target published as a lower-priority MX record behind RemoteIngress mail edges. */
|
|
977
|
+
export interface IGatewayMailBackupMxTargetRow {
|
|
978
|
+
id: string;
|
|
979
|
+
hostname: string;
|
|
980
|
+
priority: number;
|
|
981
|
+
ipv4: string | null;
|
|
982
|
+
ipv6: string | null;
|
|
983
|
+
enabled: boolean;
|
|
984
|
+
}
|
|
985
|
+
|
|
971
986
|
/** The `mail` area. */
|
|
972
987
|
export interface IGatewayMailArea {
|
|
973
988
|
/**
|
|
@@ -982,6 +997,11 @@ export interface IGatewayMailArea {
|
|
|
982
997
|
smtpAccounts: IGatewaySmtpAccountRow[];
|
|
983
998
|
identities: IGatewayMailIdentityRow[];
|
|
984
999
|
coreMailPeers: IGatewayCoreMailPeerRow[];
|
|
1000
|
+
/**
|
|
1001
|
+
* Optional Backup MX targets for managed mail DNS reconciliation. Sent only when the gateway
|
|
1002
|
+
* advertises `email.backupMxTargets`.
|
|
1003
|
+
*/
|
|
1004
|
+
backupMxTargets?: IGatewayMailBackupMxTargetRow[];
|
|
985
1005
|
}
|
|
986
1006
|
|
|
987
1007
|
// ---------------------------------------------------------------------------------------------
|
|
@@ -1830,12 +1830,21 @@ const validateMail = (scopeArg: IScope, contentArg: Record<string, unknown>, dns
|
|
|
1830
1830
|
}
|
|
1831
1831
|
});
|
|
1832
1832
|
rowList(scopeArg, 'domains', contentArg.domains, bounds.domains, (rowScopeArg, rowArg) => {
|
|
1833
|
-
const
|
|
1834
|
-
|
|
1835
|
-
|
|
1833
|
+
const hasBackupMxEnabled = isPlainRecord(rowArg) && Object.hasOwn(rowArg, 'backupMxEnabled');
|
|
1834
|
+
const row = exact(
|
|
1835
|
+
rowScopeArg,
|
|
1836
|
+
rowArg,
|
|
1837
|
+
hasBackupMxEnabled
|
|
1838
|
+
? ['id', 'domain', 'linkedDomainId', 'subdomain', 'dkim', 'rateLimits', 'edgeFilter', 'backupMxEnabled']
|
|
1839
|
+
: ['id', 'domain', 'linkedDomainId', 'subdomain', 'dkim', 'rateLimits', 'edgeFilter'],
|
|
1840
|
+
null,
|
|
1841
|
+
);
|
|
1836
1842
|
if (row === null) {
|
|
1837
1843
|
return;
|
|
1838
1844
|
}
|
|
1845
|
+
if (hasBackupMxEnabled) {
|
|
1846
|
+
checkBoolean(rowScopeArg, row.backupMxEnabled, 'backupMxEnabled');
|
|
1847
|
+
}
|
|
1839
1848
|
check(rowScopeArg, isZoneName(row.domain), 'domain');
|
|
1840
1849
|
if (typeof row.linkedDomainId !== 'string') {
|
|
1841
1850
|
refuse(rowScopeArg, 'linkedDomainId', 'invalid-value');
|
|
@@ -1945,6 +1954,29 @@ const validateMail = (scopeArg: IScope, contentArg: Record<string, unknown>, dns
|
|
|
1945
1954
|
checkText(rowScopeArg, row.transferOrigin, 'transferOrigin', 2048);
|
|
1946
1955
|
checkCoreMailVerifiers(rowScopeArg, row.credentials);
|
|
1947
1956
|
});
|
|
1957
|
+
if (Object.hasOwn(contentArg, 'backupMxTargets')) {
|
|
1958
|
+
const seenBackupHostnames = new Set<string>();
|
|
1959
|
+
rowList(scopeArg, 'backupMxTargets', contentArg.backupMxTargets, 64, (rowScopeArg, rowArg) => {
|
|
1960
|
+
const row = exact(rowScopeArg, rowArg, [
|
|
1961
|
+
'id', 'hostname', 'priority', 'ipv4', 'ipv6', 'enabled',
|
|
1962
|
+
], null);
|
|
1963
|
+
if (row === null) {
|
|
1964
|
+
return;
|
|
1965
|
+
}
|
|
1966
|
+
check(rowScopeArg, isZoneName(row.hostname), 'hostname');
|
|
1967
|
+
if (typeof row.hostname === 'string' && isZoneName(row.hostname)) {
|
|
1968
|
+
if (seenBackupHostnames.has(row.hostname)) {
|
|
1969
|
+
refuse(rowScopeArg, 'hostname', 'duplicate-key');
|
|
1970
|
+
} else {
|
|
1971
|
+
seenBackupHostnames.add(row.hostname);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
check(rowScopeArg, typeof row.priority === 'number' && Number.isSafeInteger(row.priority) && row.priority >= 21 && row.priority <= 65535, 'priority');
|
|
1975
|
+
checkNullableAddress(rowScopeArg, row.ipv4, 'ipv4', 4);
|
|
1976
|
+
checkNullableAddress(rowScopeArg, row.ipv6, 'ipv6', 6);
|
|
1977
|
+
checkBoolean(rowScopeArg, row.enabled, 'enabled');
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1948
1980
|
};
|
|
1949
1981
|
|
|
1950
1982
|
// ---------------------------------------------------------------------------------------------
|
|
@@ -2151,7 +2183,11 @@ const validateArea = (
|
|
|
2151
2183
|
refuse(scope, null, 'not-strict-json');
|
|
2152
2184
|
return;
|
|
2153
2185
|
}
|
|
2154
|
-
const
|
|
2186
|
+
const hasBackupMxTargets = areaArg === 'mail' && isPlainRecord(contentArg) && Object.hasOwn(contentArg, 'backupMxTargets');
|
|
2187
|
+
const expectedKeys = hasBackupMxTargets
|
|
2188
|
+
? [...gatewayAreaMembers.mail, 'backupMxTargets']
|
|
2189
|
+
: gatewayAreaMembers[areaArg];
|
|
2190
|
+
const content = exact(scope, contentArg, expectedKeys, null);
|
|
2155
2191
|
if (content === null) {
|
|
2156
2192
|
return;
|
|
2157
2193
|
}
|