@serve.zone/interfaces 32.124.0 → 32.126.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.
Files changed (42) hide show
  1. package/changelog.md +16 -0
  2. package/dist_ts/00_commitinfo_data.js +1 -1
  3. package/dist_ts/data/certificateauthority.d.ts +57 -0
  4. package/dist_ts/data/certificateauthority.js +69 -0
  5. package/dist_ts/data/externaldns.d.ts +135 -0
  6. package/dist_ts/data/externaldns.js +138 -0
  7. package/dist_ts/data/gateway.d.ts +17 -0
  8. package/dist_ts/data/gateway.js +1 -1
  9. package/dist_ts/data/hetzner.d.ts +6 -0
  10. package/dist_ts/data/hetzner.js +17 -1
  11. package/dist_ts/data/index.d.ts +4 -0
  12. package/dist_ts/data/index.js +5 -1
  13. package/dist_ts/data/nattraversal.d.ts +98 -0
  14. package/dist_ts/data/nattraversal.js +172 -0
  15. package/dist_ts/data/pathrouting.d.ts +170 -0
  16. package/dist_ts/data/pathrouting.js +227 -0
  17. package/dist_ts/requests/certificateauthority.d.ts +118 -0
  18. package/dist_ts/requests/certificateauthority.js +2 -0
  19. package/dist_ts/requests/externaldns.d.ts +213 -0
  20. package/dist_ts/requests/externaldns.js +2 -0
  21. package/dist_ts/requests/hetzner.d.ts +7 -0
  22. package/dist_ts/requests/index.d.ts +5 -1
  23. package/dist_ts/requests/index.js +6 -2
  24. package/dist_ts/requests/nattraversal.d.ts +47 -0
  25. package/dist_ts/requests/nattraversal.js +2 -0
  26. package/dist_ts/requests/pathrouting.d.ts +107 -0
  27. package/dist_ts/requests/pathrouting.js +2 -0
  28. package/package.json +33 -1
  29. package/ts/00_commitinfo_data.ts +1 -1
  30. package/ts/data/certificateauthority.ts +115 -0
  31. package/ts/data/externaldns.ts +273 -0
  32. package/ts/data/gateway.ts +17 -0
  33. package/ts/data/hetzner.ts +22 -0
  34. package/ts/data/index.ts +4 -0
  35. package/ts/data/nattraversal.ts +261 -0
  36. package/ts/data/pathrouting.ts +410 -0
  37. package/ts/requests/certificateauthority.ts +139 -0
  38. package/ts/requests/externaldns.ts +263 -0
  39. package/ts/requests/hetzner.ts +7 -0
  40. package/ts/requests/index.ts +8 -0
  41. package/ts/requests/nattraversal.ts +63 -0
  42. package/ts/requests/pathrouting.ts +134 -0
@@ -0,0 +1,410 @@
1
+ export const serviceRoutingProfiles = Object.freeze([
2
+ 'latency',
3
+ 'balanced',
4
+ 'throughput',
5
+ ] as const);
6
+
7
+ export type TServiceRoutingProfile = typeof serviceRoutingProfiles[number];
8
+
9
+ export const pathRoutingRefusalCodes = Object.freeze([
10
+ 'administrator-required',
11
+ 'fresh-sign-in-required',
12
+ 'invalid-request',
13
+ 'policy-not-found',
14
+ 'gateway-not-found',
15
+ 'gateway-disconnected',
16
+ 'gateway-unsupported',
17
+ 'no-healthy-path',
18
+ 'probe-unavailable',
19
+ ] as const);
20
+
21
+ export type TPathRoutingRefusalCode = typeof pathRoutingRefusalCodes[number];
22
+
23
+ export const pathSwitchReasons = Object.freeze([
24
+ 'initial',
25
+ 'failover',
26
+ 'degradation',
27
+ 'optimization',
28
+ 'pinned',
29
+ 'retained-hysteresis',
30
+ 'retained-dwell',
31
+ 'no-healthy-path',
32
+ ] as const);
33
+
34
+ export type TPathSwitchReason = typeof pathSwitchReasons[number];
35
+
36
+ export const pathRoutingContract = Object.freeze({
37
+ defaultHysteresisMargin: 0.2,
38
+ defaultMinDwellMs: 5 * 60_000,
39
+ defaultSampleStaleMs: 120_000,
40
+ defaultProbeIntervalMs: 30_000,
41
+ defaultProbeJitterRatio: 0.2,
42
+ defaultThroughputProbeMaxBytes: 512 * 1024,
43
+ defaultThroughputProbeTimeoutMs: 2_500,
44
+ defaultThroughputProbeCooldownMs: 60_000,
45
+ defaultDnsTtlSeconds: 60,
46
+ gatewayHopHeader: 'x-servezone-gateway-hop',
47
+ diagnosticProbeTtlHeader: 'x-servezone-probe-ttl',
48
+ } as const);
49
+
50
+ /**
51
+ * Hop 1 telemetry: RemoteIngress edge (e) <-> dcrouter hub (d).
52
+ * Combines passive RemoteIngressHub flow-control/QUIC signals with active tunnel probes.
53
+ */
54
+ export interface IRemoteIngressEdgePathSample {
55
+ edgeId: string;
56
+ edgeName: string;
57
+ publicIpv4: string | null;
58
+ publicIpv6: string | null;
59
+ connected: boolean;
60
+ rttMs: number | null;
61
+ throughputMbps: number | null;
62
+ stalledStreams: number;
63
+ rejectedStreams: number;
64
+ dataQueueDepth: number;
65
+ blackHolesDetected: number;
66
+ fallbackUsed: boolean;
67
+ observedAt: number;
68
+ }
69
+
70
+ /**
71
+ * Hop 2 telemetry: dcrouter (d) <-> backend CoreTraffic / service target (s).
72
+ * Deduplicated per unique cluster/node backend targetKey so co-located services share network probes.
73
+ */
74
+ export interface IGatewayBackendPathSample {
75
+ targetKey: string;
76
+ clusterId: string | null;
77
+ targetHost: string;
78
+ targetPort: number;
79
+ reachable: boolean;
80
+ rttMs: number | null;
81
+ p95TtfbMs: number | null;
82
+ throughputMbps: number | null;
83
+ /** Fraction of recent requests failing with 5xx or TCP resets, in [0, 1]. */
84
+ errorRate: number;
85
+ consecutiveFailures: number;
86
+ observedAt: number;
87
+ }
88
+
89
+ export interface IGatewayPathTelemetryReport {
90
+ gatewayId: string;
91
+ reportedAt: number;
92
+ edgeSamples: IRemoteIngressEdgePathSample[];
93
+ backendSamples: IGatewayBackendPathSample[];
94
+ }
95
+
96
+ export interface IGatewayPathProbeRequest {
97
+ probeId: string;
98
+ kind: 'rtt' | 'throughput';
99
+ targetHost: string;
100
+ targetPort: number;
101
+ /** Optional HTTP probe path (e.g. '/_servezone/probe'). */
102
+ path?: string;
103
+ /** Upper bound on bytes transferred for throughput micro-probes. */
104
+ maxBytes?: number;
105
+ timeoutMs?: number;
106
+ /**
107
+ * Explicitly permits a bounded single-pass diagnostic loopback measurement
108
+ * (tagged with `x-servezone-probe-ttl: 1`) without relaxing production loop guards.
109
+ */
110
+ allowDiagnosticLoopback?: boolean;
111
+ }
112
+
113
+ export interface IGatewayPathProbeResult {
114
+ probeId: string;
115
+ ok: boolean;
116
+ kind: 'rtt' | 'throughput';
117
+ rttMs: number | null;
118
+ throughputMbps: number | null;
119
+ bytesTransferred: number;
120
+ statusCode: number | null;
121
+ error: string | null;
122
+ measuredAt: number;
123
+ }
124
+
125
+ export interface IServicePathPolicy {
126
+ serviceId: string;
127
+ hostname: string;
128
+ /** Backend target key matched against `IGatewayBackendPathSample.targetKey`. */
129
+ targetKey: string;
130
+ clusterId: string | null;
131
+ enabled: boolean;
132
+ profile: TServiceRoutingProfile;
133
+ pinnedGatewayId: string | null;
134
+ pinnedEdgeId: string | null;
135
+ /** Minimum relative score improvement (0..1) required to move a healthy service. */
136
+ hysteresisMargin: number;
137
+ /** Minimum dwell time (ms) between optimization switches while healthy. */
138
+ minDwellMs: number;
139
+ ttlSeconds: number;
140
+ proxied: boolean;
141
+ updatedAt: number;
142
+ }
143
+
144
+ export interface IServicePathCandidateScore {
145
+ gatewayId: string;
146
+ edgeId: string;
147
+ edgePublicIpv4: string | null;
148
+ edgePublicIpv6: string | null;
149
+ healthy: boolean;
150
+ degraded: boolean;
151
+ effectiveRttMs: number | null;
152
+ effectiveThroughputMbps: number | null;
153
+ /** Higher is better; 0 indicates a disqualified/unhealthy candidate. */
154
+ score: number;
155
+ disqualifyReason: string | null;
156
+ }
157
+
158
+ export interface IServicePathDecision {
159
+ serviceId: string;
160
+ hostname: string;
161
+ targetKey: string;
162
+ selectedGatewayId: string | null;
163
+ selectedEdgeId: string | null;
164
+ selectedPublicIpv4: string | null;
165
+ selectedPublicIpv6: string | null;
166
+ selectedScore: number | null;
167
+ effectiveRttMs: number | null;
168
+ effectiveThroughputMbps: number | null;
169
+ switchReason: TPathSwitchReason;
170
+ decidedAt: number;
171
+ lastSwitchedAt: number | null;
172
+ candidates: IServicePathCandidateScore[];
173
+ }
174
+
175
+ export const isServiceRoutingProfile = (valueArg: unknown): valueArg is TServiceRoutingProfile =>
176
+ typeof valueArg === 'string' && (serviceRoutingProfiles as readonly string[]).includes(valueArg);
177
+
178
+ const normalizeIpToken = (valueArg: string): string => valueArg.trim().toLowerCase().replace(/^\[|\]$/g, '');
179
+
180
+ /**
181
+ * Enforces the strict loop-free production DAG `RemoteIngress -> dcrouter -> Service`.
182
+ * Production routes MUST NOT target a known RemoteIngress edge public IP or peer dcrouter ingress IP.
183
+ */
184
+ export const isProductionRoutingLoopTarget = (
185
+ targetHostArg: string,
186
+ knownEdgePublicIpsArg: readonly string[],
187
+ peerGatewayIngressIpsArg: readonly string[],
188
+ ): boolean => {
189
+ const normalizedTarget = normalizeIpToken(targetHostArg);
190
+ if (!normalizedTarget) return false;
191
+ for (const ip of knownEdgePublicIpsArg) {
192
+ if (normalizeIpToken(ip) === normalizedTarget) return true;
193
+ }
194
+ for (const ip of peerGatewayIngressIpsArg) {
195
+ if (normalizeIpToken(ip) === normalizedTarget) return true;
196
+ }
197
+ return false;
198
+ };
199
+
200
+ /**
201
+ * Computes a deterministic phase-staggered + jittered probe delay so checks across many services
202
+ * spread smoothly across `intervalMs` instead of firing in synchronized bursts.
203
+ */
204
+ export const computeStaggeredProbeDelayMs = (
205
+ targetKeyArg: string,
206
+ intervalMsArg: number,
207
+ jitterRatioArg: number = pathRoutingContract.defaultProbeJitterRatio,
208
+ randomUnitArg: number = Math.random(),
209
+ ): number => {
210
+ const interval = Math.max(1_000, Math.floor(intervalMsArg));
211
+ // 32-bit FNV-1a hash for stable phase distribution across targets
212
+ let hash = 0x811c9dc5;
213
+ for (let i = 0; i < targetKeyArg.length; i += 1) {
214
+ hash ^= targetKeyArg.charCodeAt(i);
215
+ hash = Math.imul(hash, 0x01000193) >>> 0;
216
+ }
217
+ const baseOffset = hash % interval;
218
+ const clampedJitter = Math.max(0, Math.min(0.5, jitterRatioArg));
219
+ const clampedUnit = Math.max(0, Math.min(1, randomUnitArg));
220
+ const jitterSpan = Math.floor(interval * clampedJitter);
221
+ const jitterDelta = Math.floor((clampedUnit * 2 - 1) * jitterSpan);
222
+ return Math.max(0, (baseOffset + jitterDelta + interval) % interval);
223
+ };
224
+
225
+ /**
226
+ * Scores one candidate path `RemoteIngress edge (e) -> dcrouter (d) -> backend (s)`.
227
+ * Higher score is better; unhealthy/stale/disconnected paths receive score 0.
228
+ */
229
+ export const scoreServicePathCandidate = (paramsArg: {
230
+ gatewayId: string;
231
+ edge: IRemoteIngressEdgePathSample;
232
+ backend: IGatewayBackendPathSample;
233
+ profile: TServiceRoutingProfile;
234
+ nowMs: number;
235
+ maxStaleMs?: number;
236
+ }): IServicePathCandidateScore => {
237
+ const { gatewayId, edge, backend, profile, nowMs } = paramsArg;
238
+ const maxStaleMs = paramsArg.maxStaleMs ?? pathRoutingContract.defaultSampleStaleMs;
239
+
240
+ const baseResult: Omit<IServicePathCandidateScore, 'healthy' | 'degraded' | 'effectiveRttMs' | 'effectiveThroughputMbps' | 'score' | 'disqualifyReason'> = {
241
+ gatewayId,
242
+ edgeId: edge.edgeId,
243
+ edgePublicIpv4: edge.publicIpv4,
244
+ edgePublicIpv6: edge.publicIpv6,
245
+ };
246
+
247
+ if (!edge.connected) {
248
+ return { ...baseResult, healthy: false, degraded: true, effectiveRttMs: null, effectiveThroughputMbps: null, score: 0, disqualifyReason: 'edge-disconnected' };
249
+ }
250
+ if (!edge.publicIpv4 && !edge.publicIpv6) {
251
+ return { ...baseResult, healthy: false, degraded: true, effectiveRttMs: null, effectiveThroughputMbps: null, score: 0, disqualifyReason: 'edge-no-public-ip' };
252
+ }
253
+ if (!backend.reachable || backend.consecutiveFailures >= 3) {
254
+ return { ...baseResult, healthy: false, degraded: true, effectiveRttMs: null, effectiveThroughputMbps: null, score: 0, disqualifyReason: 'backend-unreachable' };
255
+ }
256
+ if (nowMs - edge.observedAt > maxStaleMs || nowMs - backend.observedAt > maxStaleMs) {
257
+ return { ...baseResult, healthy: false, degraded: true, effectiveRttMs: null, effectiveThroughputMbps: null, score: 0, disqualifyReason: 'telemetry-stale' };
258
+ }
259
+
260
+ const edgeRtt = edge.rttMs !== null && edge.rttMs >= 0 ? edge.rttMs : 25;
261
+ const backendRtt = backend.rttMs !== null && backend.rttMs >= 0
262
+ ? backend.rttMs
263
+ : (backend.p95TtfbMs !== null && backend.p95TtfbMs >= 0 ? backend.p95TtfbMs : 25);
264
+ const effectiveRttMs = Math.round((edgeRtt + backendRtt) * 100) / 100;
265
+
266
+ // Bottleneck throughput of the two-hop path = min(hop1, hop2)
267
+ let effectiveThroughputMbps: number | null = null;
268
+ if (edge.throughputMbps !== null && backend.throughputMbps !== null) {
269
+ effectiveThroughputMbps = Math.min(edge.throughputMbps, backend.throughputMbps);
270
+ } else if (edge.throughputMbps !== null) {
271
+ effectiveThroughputMbps = edge.throughputMbps;
272
+ } else if (backend.throughputMbps !== null) {
273
+ effectiveThroughputMbps = backend.throughputMbps;
274
+ }
275
+ const throughputForScore = effectiveThroughputMbps !== null && effectiveThroughputMbps > 0 ? effectiveThroughputMbps : 100;
276
+
277
+ // Normalized components in (0, 1]
278
+ const latencyComponent = 1 / (1 + effectiveRttMs / 50);
279
+ const throughputComponent = Math.min(1, Math.log10(1 + throughputForScore) / 3); // ~1.0 at 1000 Mbps
280
+
281
+ const weights = profile === 'latency'
282
+ ? { latency: 0.78, throughput: 0.22 }
283
+ : profile === 'throughput'
284
+ ? { latency: 0.25, throughput: 0.75 }
285
+ : { latency: 0.55, throughput: 0.45 };
286
+
287
+ let rawScore = (weights.latency * latencyComponent + weights.throughput * throughputComponent) * 100;
288
+
289
+ // Apply degradation penalties
290
+ const degraded =
291
+ backend.errorRate >= 0.05
292
+ || backend.consecutiveFailures > 0
293
+ || edge.stalledStreams > 0
294
+ || edge.blackHolesDetected > 0
295
+ || edge.fallbackUsed
296
+ || edge.dataQueueDepth > 256;
297
+
298
+ if (backend.errorRate > 0) {
299
+ rawScore *= Math.max(0.1, 1 - Math.min(0.9, backend.errorRate * 4));
300
+ }
301
+ if (edge.stalledStreams > 0) rawScore *= 0.75;
302
+ if (edge.blackHolesDetected > 0) rawScore *= 0.7;
303
+ if (edge.fallbackUsed) rawScore *= 0.85;
304
+ if (backend.consecutiveFailures > 0) rawScore *= 0.6;
305
+
306
+ const score = Math.max(0.01, Math.round(rawScore * 100) / 100);
307
+ return {
308
+ ...baseResult,
309
+ healthy: true,
310
+ degraded,
311
+ effectiveRttMs,
312
+ effectiveThroughputMbps,
313
+ score,
314
+ disqualifyReason: null,
315
+ };
316
+ };
317
+
318
+ /**
319
+ * Selects the optimal healthy `(edge, dcrouter)` path for one service, enforcing:
320
+ * - Immediate failover on hard failure or severe degradation (zero dwell wait).
321
+ * - Hysteresis margin + minimum dwell time when moving a healthy service to a faster healthy path.
322
+ */
323
+ export const selectOptimalServicePath = (paramsArg: {
324
+ policy: IServicePathPolicy;
325
+ candidates: IServicePathCandidateScore[];
326
+ previous: IServicePathDecision | null;
327
+ nowMs: number;
328
+ }): IServicePathDecision => {
329
+ const { policy, candidates, previous, nowMs } = paramsArg;
330
+ const sorted = [...candidates].sort((a, b) => (
331
+ b.score - a.score
332
+ || a.gatewayId.localeCompare(b.gatewayId)
333
+ || a.edgeId.localeCompare(b.edgeId)
334
+ ));
335
+ const healthy = sorted.filter((c) => c.healthy);
336
+
337
+ const makeDecision = (
338
+ chosen: IServicePathCandidateScore | null,
339
+ switchReason: TPathSwitchReason,
340
+ switched: boolean,
341
+ ): IServicePathDecision => ({
342
+ serviceId: policy.serviceId,
343
+ hostname: policy.hostname,
344
+ targetKey: policy.targetKey,
345
+ selectedGatewayId: chosen?.gatewayId ?? null,
346
+ selectedEdgeId: chosen?.edgeId ?? null,
347
+ selectedPublicIpv4: chosen?.edgePublicIpv4 ?? null,
348
+ selectedPublicIpv6: chosen?.edgePublicIpv6 ?? null,
349
+ selectedScore: chosen?.score ?? null,
350
+ effectiveRttMs: chosen?.effectiveRttMs ?? null,
351
+ effectiveThroughputMbps: chosen?.effectiveThroughputMbps ?? null,
352
+ switchReason,
353
+ decidedAt: nowMs,
354
+ lastSwitchedAt: switched ? nowMs : (previous?.lastSwitchedAt ?? null),
355
+ candidates: sorted,
356
+ });
357
+
358
+ if (healthy.length === 0) {
359
+ return makeDecision(null, 'no-healthy-path', previous?.selectedEdgeId !== null);
360
+ }
361
+
362
+ // Respect explicit operator pin when healthy
363
+ if (policy.pinnedGatewayId || policy.pinnedEdgeId) {
364
+ const pinned = healthy.find((c) => (
365
+ (!policy.pinnedGatewayId || c.gatewayId === policy.pinnedGatewayId)
366
+ && (!policy.pinnedEdgeId || c.edgeId === policy.pinnedEdgeId)
367
+ ));
368
+ if (pinned) {
369
+ const changed = previous?.selectedGatewayId !== pinned.gatewayId || previous?.selectedEdgeId !== pinned.edgeId;
370
+ return makeDecision(pinned, 'pinned', changed);
371
+ }
372
+ }
373
+
374
+ const best = healthy[0];
375
+ if (!previous || !previous.selectedGatewayId || !previous.selectedEdgeId) {
376
+ return makeDecision(best, 'initial', true);
377
+ }
378
+
379
+ const current = sorted.find(
380
+ (c) => c.gatewayId === previous.selectedGatewayId && c.edgeId === previous.selectedEdgeId,
381
+ );
382
+
383
+ // Instant failover if current path disappeared or became unhealthy
384
+ if (!current || !current.healthy) {
385
+ return makeDecision(best, 'failover', true);
386
+ }
387
+
388
+ // If current path is already the top candidate, retain cleanly
389
+ if (current.gatewayId === best.gatewayId && current.edgeId === best.edgeId) {
390
+ return makeDecision(current, previous.switchReason === 'no-healthy-path' ? 'initial' : previous.switchReason, false);
391
+ }
392
+
393
+ // Immediate switch if current path is degraded and best is clean (non-degraded)
394
+ if (current.degraded && !best.degraded) {
395
+ return makeDecision(best, 'degradation', true);
396
+ }
397
+
398
+ // Healthy -> faster healthy path requires hysteresis margin + minimum dwell time
399
+ const margin = Math.max(0, policy.hysteresisMargin);
400
+ const improvement = current.score > 0 ? (best.score - current.score) / current.score : 1;
401
+ if (improvement < margin) {
402
+ return makeDecision(current, 'retained-hysteresis', false);
403
+ }
404
+ const lastSwitch = previous.lastSwitchedAt ?? 0;
405
+ if (nowMs - lastSwitch < Math.max(0, policy.minDwellMs)) {
406
+ return makeDecision(current, 'retained-dwell', false);
407
+ }
408
+
409
+ return makeDecision(best, 'optimization', true);
410
+ };
@@ -0,0 +1,139 @@
1
+ import type { ITypedRequest, implementsTR } from '@api.global/typedrequest-interfaces';
2
+ import type {
3
+ ICloudlyAcmeConfig,
4
+ ICloudlyCertificateBundleItem,
5
+ ICloudlyCertificateSummary,
6
+ TCloudlyCertificateRefusalCode,
7
+ } from '../data/certificateauthority.js';
8
+ import type { IIdentityCredential } from '../data/user.js';
9
+
10
+ export type TCloudlyCertificateResult<TData> =
11
+ | ({ ok: true } & TData)
12
+ | { ok: false; code: TCloudlyCertificateRefusalCode; message: string };
13
+
14
+ export interface IReq_Admin_Cloudly_ConfigureAcme extends implementsTR<
15
+ ITypedRequest,
16
+ IReq_Admin_Cloudly_ConfigureAcme
17
+ > {
18
+ method: 'configureCloudlyAcme';
19
+ request: {
20
+ identity: IIdentityCredential;
21
+ enabled: boolean;
22
+ accountEmail: string;
23
+ useProduction: boolean;
24
+ directoryUrl?: string | null;
25
+ renewBeforeDays?: number;
26
+ };
27
+ response: TCloudlyCertificateResult<{ config: ICloudlyAcmeConfig }>;
28
+ }
29
+
30
+ export interface IReq_Admin_Cloudly_GetAcmeConfig extends implementsTR<
31
+ ITypedRequest,
32
+ IReq_Admin_Cloudly_GetAcmeConfig
33
+ > {
34
+ method: 'getCloudlyAcmeConfig';
35
+ request: {
36
+ identity: IIdentityCredential;
37
+ };
38
+ response: TCloudlyCertificateResult<{ config: ICloudlyAcmeConfig | null }>;
39
+ }
40
+
41
+ export interface IReq_Admin_Cloudly_ListCertificates extends implementsTR<
42
+ ITypedRequest,
43
+ IReq_Admin_Cloudly_ListCertificates
44
+ > {
45
+ method: 'listCloudlyCertificates';
46
+ request: {
47
+ identity: IIdentityCredential;
48
+ domain?: string;
49
+ };
50
+ response: TCloudlyCertificateResult<{ certificates: ICloudlyCertificateSummary[] }>;
51
+ }
52
+
53
+ export interface IReq_Admin_Cloudly_IssueCertificate extends implementsTR<
54
+ ITypedRequest,
55
+ IReq_Admin_Cloudly_IssueCertificate
56
+ > {
57
+ method: 'issueCloudlyCertificate';
58
+ request: {
59
+ identity: IIdentityCredential;
60
+ domain: string;
61
+ altNames?: string[];
62
+ autoRenew?: boolean;
63
+ /** Optional providerId override in CloudlyExternalDnsManager for DNS-01 challenge records. */
64
+ providerId?: string;
65
+ /** Force immediate renewal even if an unexpired certificate already exists. */
66
+ forceRenew?: boolean;
67
+ };
68
+ response: TCloudlyCertificateResult<{
69
+ certificate: ICloudlyCertificateSummary;
70
+ pushedGatewayIds: string[];
71
+ }>;
72
+ }
73
+
74
+ export interface IReq_Admin_Cloudly_ImportCertificate extends implementsTR<
75
+ ITypedRequest,
76
+ IReq_Admin_Cloudly_ImportCertificate
77
+ > {
78
+ method: 'importCloudlyCertificate';
79
+ request: {
80
+ identity: IIdentityCredential;
81
+ domain: string;
82
+ altNames?: string[];
83
+ certPem: string;
84
+ /** Write-only PEM private key; sealed at rest and scrubbed from request echoes. */
85
+ keyPem: string;
86
+ caPem?: string | null;
87
+ autoRenew?: boolean;
88
+ };
89
+ response: TCloudlyCertificateResult<{
90
+ certificate: ICloudlyCertificateSummary;
91
+ pushedGatewayIds: string[];
92
+ }>;
93
+ }
94
+
95
+ export interface IReq_Admin_Cloudly_DeleteCertificate extends implementsTR<
96
+ ITypedRequest,
97
+ IReq_Admin_Cloudly_DeleteCertificate
98
+ > {
99
+ method: 'deleteCloudlyCertificate';
100
+ request: {
101
+ identity: IIdentityCredential;
102
+ domain: string;
103
+ };
104
+ response: TCloudlyCertificateResult<{ deleted: true }>;
105
+ }
106
+
107
+ export interface IReq_Admin_Cloudly_PushCertificatesToGateways extends implementsTR<
108
+ ITypedRequest,
109
+ IReq_Admin_Cloudly_PushCertificatesToGateways
110
+ > {
111
+ method: 'pushCloudlyCertificatesToGateways';
112
+ request: {
113
+ identity: IIdentityCredential;
114
+ gatewayId?: string;
115
+ };
116
+ response: TCloudlyCertificateResult<{
117
+ pushedGatewayIds: string[];
118
+ skippedGatewayIds: string[];
119
+ }>;
120
+ }
121
+
122
+ /**
123
+ * Controller-to-gateway push over the authenticated gateway TypedSocket.
124
+ * Only dispatched to gateways declaring `capabilities.certificates.controllerPushed === true`.
125
+ */
126
+ export interface IReq_Cloudly_Gateway_PushCertificateBundle extends implementsTR<
127
+ ITypedRequest,
128
+ IReq_Cloudly_Gateway_PushCertificateBundle
129
+ > {
130
+ method: 'pushGatewayCertificateBundle';
131
+ request: {
132
+ revision: number;
133
+ certificates: ICloudlyCertificateBundleItem[];
134
+ pruneMissing?: boolean;
135
+ };
136
+ response:
137
+ | { ok: true; appliedCount: number; removedCount: number }
138
+ | { ok: false; reason: string };
139
+ }