domainkit 0.2.2 → 0.3.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 (58) hide show
  1. package/README.md +26 -26
  2. package/dist/index.d.mts +639 -187
  3. package/dist/index.mjs +301 -300
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/promise.d.mts +464 -0
  6. package/dist/promise.mjs +636 -0
  7. package/dist/promise.mjs.map +1 -0
  8. package/dist/{resolver-CxE-VDw4.mjs → resolver-CvK7JoJM.mjs} +401 -54
  9. package/dist/resolver-CvK7JoJM.mjs.map +1 -0
  10. package/dist/{resolver-Dc0hwV-J.d.mts → resolver-uqe1h5Vz.d.mts} +1513 -25
  11. package/dist/testing.d.mts +4 -5
  12. package/dist/testing.mjs +17 -3
  13. package/dist/testing.mjs.map +1 -1
  14. package/dist/verify-B00c81-n.mjs +2420 -0
  15. package/dist/verify-B00c81-n.mjs.map +1 -0
  16. package/dist/{verify-Dls29YC-.d.mts → verify-CkgVrwyl.d.mts} +318 -21
  17. package/package.json +6 -30
  18. package/dist/auth-BR-19zj-.mjs +0 -738
  19. package/dist/auth-BR-19zj-.mjs.map +0 -1
  20. package/dist/auth-g-waCHcz.mjs +0 -671
  21. package/dist/auth-g-waCHcz.mjs.map +0 -1
  22. package/dist/authorization-OeaSR47S.mjs +0 -284
  23. package/dist/authorization-OeaSR47S.mjs.map +0 -1
  24. package/dist/canonical-json-CpvqGMcr.mjs +0 -57
  25. package/dist/canonical-json-CpvqGMcr.mjs.map +0 -1
  26. package/dist/cloudflare-BrZPU9li.d.mts +0 -32
  27. package/dist/cloudflare-CGmasR8A.mjs +0 -69
  28. package/dist/cloudflare-CGmasR8A.mjs.map +0 -1
  29. package/dist/cloudflare.d.mts +0 -3
  30. package/dist/cloudflare.mjs +0 -2
  31. package/dist/connection-BfkloPZy.d.mts +0 -186
  32. package/dist/connection-BwtOwpH6.mjs +0 -195
  33. package/dist/connection-BwtOwpH6.mjs.map +0 -1
  34. package/dist/connection-CjNQe_E-.mjs +0 -58
  35. package/dist/connection-CjNQe_E-.mjs.map +0 -1
  36. package/dist/connection-api-DNuEZ_jR.d.mts +0 -7
  37. package/dist/dns-record-BLeqo56C.mjs +0 -289
  38. package/dist/dns-record-BLeqo56C.mjs.map +0 -1
  39. package/dist/effect-cloudflare.d.mts +0 -2
  40. package/dist/effect-cloudflare.mjs +0 -2
  41. package/dist/effect-vercel.d.mts +0 -2
  42. package/dist/effect-vercel.mjs +0 -2
  43. package/dist/effect.d.mts +0 -36
  44. package/dist/effect.mjs +0 -51
  45. package/dist/effect.mjs.map +0 -1
  46. package/dist/index-BHWRTThN.d.mts +0 -159
  47. package/dist/index-D3PVknwE.d.mts +0 -145
  48. package/dist/resolver-CxE-VDw4.mjs.map +0 -1
  49. package/dist/vercel-BsNDu4Np.d.mts +0 -31
  50. package/dist/vercel-CfoJaaCu.mjs +0 -60
  51. package/dist/vercel-CfoJaaCu.mjs.map +0 -1
  52. package/dist/vercel.d.mts +0 -3
  53. package/dist/vercel.mjs +0 -2
  54. package/dist/verify-BKbvq7IN.mjs +0 -642
  55. package/dist/verify-BKbvq7IN.mjs.map +0 -1
  56. package/dist/zone-discovery-BPnH3sLU.d.mts +0 -1397
  57. package/dist/zones-DKHTpX9C.mjs +0 -19
  58. package/dist/zones-DKHTpX9C.mjs.map +0 -1
@@ -1,21 +1,87 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { E as decode$1, T as Schema$2, _ as equals, b as Service$2, h as decode$2, k as Error$2, m as data, p as Type, s as Observed, u as Schema$3 } from "./dns-record-BLeqo56C.mjs";
3
- import { t as candidates } from "./zones-DKHTpX9C.mjs";
4
- import { n as sha256Encoded, r as stringify } from "./canonical-json-CpvqGMcr.mjs";
5
- import { Cause, Clock, Context, Data, Effect, Layer, Schema } from "effect";
2
+ import { Cause, Clock, Context, Crypto, Data, Effect, Layer, PlatformError, Schema, SchemaIssue, SchemaTransformation } from "effect";
3
+ import { getDomain } from "tldts";
4
+ //#region src/invalid-input.ts
5
+ var invalid_input_exports = /* @__PURE__ */ __exportAll({ Error: () => Error$5 });
6
+ var Error$5 = class extends Schema.TaggedError()("InvalidInputError", { message: Schema.String }) {};
7
+ //#endregion
8
+ //#region src/domain/domain-name.ts
9
+ var domain_name_exports = /* @__PURE__ */ __exportAll({
10
+ Schema: () => Schema$3,
11
+ decode: () => decode$2,
12
+ parse: () => parse$1
13
+ });
14
+ const labelPattern = /^[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9_])?$/;
15
+ const Type$1 = Schema.String.check(Schema.makeFilter((value) => value.length <= 253 && value.includes(".") && value.split(".").every((label) => labelPattern.test(label)) ? void 0 : "Expected a fully qualified DNS name", { identifier: "DomainName" })).pipe(Schema.brand("DomainName"));
16
+ /** Decodes user and wire strings into canonical domain names. */
17
+ const Schema$3 = Schema.String.pipe(Schema.decodeTo(Type$1, SchemaTransformation.transformOrFail({
18
+ decode: (input, options) => Effect.try({
19
+ try: () => normalize(input),
20
+ catch: (cause) => new SchemaIssue.InvalidValue({ message: cause instanceof Error ? cause.message : String(cause) }, input, options)
21
+ }),
22
+ encode: (domain) => Effect.succeed(domain)
23
+ })));
24
+ const decode$2 = Effect.fn("DomainName.decode")((input) => Schema.decodeUnknownEffect(Schema$3)(input).pipe(Effect.mapError((cause) => new Error$5({ message: cause.message }))));
25
+ function parse$1(input) {
26
+ try {
27
+ return Schema.decodeUnknownSync(Schema$3)(input);
28
+ } catch (cause) {
29
+ throw new Error$5({ message: cause instanceof Error ? cause.message : String(cause) });
30
+ }
31
+ }
32
+ function normalize(input) {
33
+ return input.trim().replace(/\.+$/, "").split(".").map((label) => {
34
+ if (label.includes("_") || [...label].every((character) => character.charCodeAt(0) <= 127)) return label.toLowerCase();
35
+ const normalized = new URL(`http://${label}.example`).hostname.split(".")[0];
36
+ if (normalized === void 0) throw new Error("Domain label could not be normalized");
37
+ return normalized.toLowerCase();
38
+ }).join(".");
39
+ }
40
+ //#endregion
41
+ //#region src/auth/lifecycle-repository.ts
42
+ var lifecycle_repository_exports = /* @__PURE__ */ __exportAll({
43
+ Error: () => Error$4,
44
+ Service: () => Service$3
45
+ });
46
+ var Error$4 = class extends Schema.TaggedError()("LifecycleRepositoryError", {
47
+ category: Schema.Literal("storage"),
48
+ message: Schema.String,
49
+ operation: Schema.String,
50
+ retry: Schema.Literals([
51
+ "never",
52
+ "after-user-action",
53
+ "safe",
54
+ "unknown"
55
+ ])
56
+ }) {};
57
+ var Service$3 = class extends Context.Service()("@domainkit/AuthorizationLifecycleRepository") {};
58
+ //#endregion
59
+ //#region src/discovery/zones.ts
60
+ var zones_exports = /* @__PURE__ */ __exportAll({ candidates: () => candidates });
61
+ function candidates(input) {
62
+ const domain = parse$1(input);
63
+ const registrable = getDomain(domain, { allowPrivateDomains: true });
64
+ if (registrable === null) throw new Error$5({ message: "Domain does not have a registrable DNS zone" });
65
+ const labels = domain.split(".");
66
+ const registrableLabels = registrable.split(".").length;
67
+ const values = [];
68
+ for (let index = 0; index <= labels.length - registrableLabels; index += 1) values.push(parse$1(labels.slice(index).join(".")));
69
+ return values;
70
+ }
71
+ //#endregion
6
72
  //#region src/discovery/zone-discovery.ts
7
73
  var zone_discovery_exports = /* @__PURE__ */ __exportAll({
8
74
  Candidate: () => Candidate,
9
75
  Outcome: () => Outcome,
10
- Service: () => Service$1,
76
+ Service: () => Service$2,
11
77
  make: () => make
12
78
  });
13
79
  /** Display-safe identity and nameserver evidence for one provider-owned zone. */
14
80
  const Candidate = Schema.Struct({
15
81
  accountId: Schema.String,
16
82
  id: Schema.String,
17
- name: Schema$2,
18
- nameservers: Schema.Array(Schema$2),
83
+ name: Schema$3,
84
+ nameservers: Schema.Array(Schema$3),
19
85
  providerId: Schema.String,
20
86
  status: Schema.Literals([
21
87
  "active",
@@ -24,10 +90,10 @@ const Candidate = Schema.Struct({
24
90
  ])
25
91
  });
26
92
  const Outcome = Data.taggedEnum();
27
- var Service$1 = class extends Context.Service()("@domainkit/ZoneDiscovery") {};
93
+ var Service$2 = class extends Context.Service()("@domainkit/ZoneDiscovery") {};
28
94
  /** Compose provider-account discovery sources without expanding the record-provider contract. */
29
95
  function make(sources) {
30
- return Service$1.of({ discover: Effect.fn("ZoneDiscovery.discover")(function* (domain) {
96
+ return Service$2.of({ discover: Effect.fn("ZoneDiscovery.discover")(function* (domain) {
31
97
  for (const name of candidates(domain)) {
32
98
  const matches = deduplicate((yield* Effect.forEach(sources, (source) => source.listZones(name).pipe(Effect.map((zones) => zones.filter((zone) => zone.name === name).map((zone) => ({
33
99
  candidate: {
@@ -65,6 +131,287 @@ function candidateKey(candidate) {
65
131
  ].join(":");
66
132
  }
67
133
  //#endregion
134
+ //#region src/domain/dns-record.ts
135
+ var dns_record_exports = /* @__PURE__ */ __exportAll({
136
+ A: () => A,
137
+ Aaaa: () => Aaaa,
138
+ Caa: () => Caa,
139
+ Cname: () => Cname,
140
+ Mx: () => Mx,
141
+ Ns: () => Ns,
142
+ Observed: () => Observed,
143
+ Opaque: () => Opaque,
144
+ RequirementMetadata: () => RequirementMetadata,
145
+ Schema: () => Schema$2,
146
+ Srv: () => Srv,
147
+ Txt: () => Txt,
148
+ Type: () => Type,
149
+ data: () => data,
150
+ decode: () => decode$1,
151
+ equals: () => equals,
152
+ parse: () => parse
153
+ });
154
+ const Type = Schema.Literals([
155
+ "A",
156
+ "AAAA",
157
+ "CNAME",
158
+ "TXT",
159
+ "MX",
160
+ "CAA",
161
+ "NS",
162
+ "SRV"
163
+ ]);
164
+ const RequirementMetadata = Schema.Struct({
165
+ ownership: Schema.String.check(Schema.isMinLength(1)),
166
+ provenance: Schema.String.check(Schema.isMinLength(1)),
167
+ purpose: Schema.String.check(Schema.isMinLength(1))
168
+ });
169
+ const CommonFields = {
170
+ metadata: RequirementMetadata,
171
+ name: Schema$3,
172
+ policy: Schema.Literals(["exclusive", "append"]),
173
+ ttl: Schema.NullOr(Schema.Int.check(Schema.isBetween({
174
+ minimum: 60,
175
+ maximum: 2147483647
176
+ })))
177
+ };
178
+ const ExclusiveCommonFields = {
179
+ ...CommonFields,
180
+ policy: Schema.Literal("exclusive")
181
+ };
182
+ const Address = Schema.String.check(Schema.makeFilter((value) => isIpv4(value) ? void 0 : "Expected an IPv4 address"));
183
+ const Ipv6Address = Schema.String.check(Schema.makeFilter((value) => isIpv6(value) ? void 0 : "Expected an IPv6 address"));
184
+ const Port = Schema.Int.check(Schema.isBetween({
185
+ minimum: 0,
186
+ maximum: 65535
187
+ }));
188
+ const Priority = Schema.Int.check(Schema.isBetween({
189
+ minimum: 0,
190
+ maximum: 65535
191
+ }));
192
+ const Schema$2 = Schema.TaggedUnion({
193
+ A: {
194
+ ...CommonFields,
195
+ address: Address
196
+ },
197
+ AAAA: {
198
+ ...CommonFields,
199
+ address: Ipv6Address
200
+ },
201
+ CNAME: {
202
+ ...ExclusiveCommonFields,
203
+ target: Schema$3
204
+ },
205
+ TXT: {
206
+ ...CommonFields,
207
+ value: Schema.String.check(Schema.isMinLength(1))
208
+ },
209
+ MX: {
210
+ ...CommonFields,
211
+ exchange: Schema$3,
212
+ priority: Priority
213
+ },
214
+ CAA: {
215
+ ...CommonFields,
216
+ flags: Schema.Int.check(Schema.isBetween({
217
+ minimum: 0,
218
+ maximum: 255
219
+ })),
220
+ tag: Schema.Literals([
221
+ "issue",
222
+ "issuewild",
223
+ "iodef"
224
+ ]),
225
+ value: Schema.String.check(Schema.isMinLength(1))
226
+ },
227
+ NS: {
228
+ ...CommonFields,
229
+ target: Schema$3
230
+ },
231
+ SRV: {
232
+ ...CommonFields,
233
+ port: Port,
234
+ priority: Priority,
235
+ target: Schema$3,
236
+ weight: Priority
237
+ }
238
+ });
239
+ const { A, AAAA: Aaaa, CAA: Caa, CNAME: Cname, MX: Mx, NS: Ns, SRV: Srv, TXT: Txt } = Schema$2.cases;
240
+ /** Provider state that DomainKit cannot create but must retain for safe reconciliation. */
241
+ const Opaque = Schema.Struct({
242
+ _tag: Schema.Literal("Opaque"),
243
+ name: Schema.String.check(Schema.isMinLength(1)),
244
+ providerRecordId: Schema.NullOr(Schema.String),
245
+ providerType: Schema.String.check(Schema.isMinLength(1))
246
+ });
247
+ /** Any DNS record observed through a provider, including non-portable record types. */
248
+ const Observed = Schema.Union([Schema$2, Opaque]);
249
+ const decode$1 = Effect.fn("DnsRecord.decode")((input) => Schema.decodeUnknownEffect(Schema$2)(input).pipe(Effect.mapError((cause) => new Error$5({ message: cause.message }))));
250
+ function parse(input) {
251
+ try {
252
+ return Schema.decodeUnknownSync(Schema$2)(input);
253
+ } catch (cause) {
254
+ throw new Error$5({ message: cause instanceof Error ? cause.message : String(cause) });
255
+ }
256
+ }
257
+ function data(record) {
258
+ switch (record._tag) {
259
+ case "A":
260
+ case "AAAA": return { address: record.address };
261
+ case "CNAME":
262
+ case "NS": return { target: record.target };
263
+ case "TXT": return { value: record.value };
264
+ case "MX": return {
265
+ exchange: record.exchange,
266
+ priority: record.priority
267
+ };
268
+ case "CAA": return {
269
+ flags: record.flags,
270
+ tag: record.tag,
271
+ value: record.value
272
+ };
273
+ case "SRV": return {
274
+ port: record.port,
275
+ priority: record.priority,
276
+ target: record.target,
277
+ weight: record.weight
278
+ };
279
+ }
280
+ }
281
+ function equals(left, right) {
282
+ return left._tag === right._tag && left.name === right.name && JSON.stringify(data(left)) === JSON.stringify(data(right));
283
+ }
284
+ function isIpv4(value) {
285
+ const parts = value.split(".");
286
+ return parts.length === 4 && parts.every((part) => /^\d{1,3}$/.test(part) && Number(part) <= 255 && String(Number(part)) === part);
287
+ }
288
+ function isIpv6(value) {
289
+ try {
290
+ return new URL(`http://[${value}]/`).hostname.startsWith("[");
291
+ } catch {
292
+ return false;
293
+ }
294
+ }
295
+ //#endregion
296
+ //#region src/provider/provider.ts
297
+ var provider_exports = /* @__PURE__ */ __exportAll({
298
+ Error: () => Error$3,
299
+ ErrorReason: () => ErrorReason,
300
+ Service: () => Service$1,
301
+ fromAsync: () => fromAsync,
302
+ layerFromAsync: () => layerFromAsync$1,
303
+ toAsync: () => toAsync$1
304
+ });
305
+ const ErrorReason = Schema.Literals([
306
+ "authentication",
307
+ "authorization",
308
+ "conflict",
309
+ "not_found",
310
+ "rate_limit",
311
+ "request",
312
+ "response",
313
+ "transport",
314
+ "unsupported"
315
+ ]);
316
+ var Error$3 = class extends Schema.TaggedError()("ProviderError", {
317
+ cause: Schema.optionalKey(Schema.Unknown),
318
+ code: Schema.optionalKey(Schema.Union([Schema.Number, Schema.String])),
319
+ message: Schema.String,
320
+ operation: Schema.String,
321
+ providerId: Schema.String,
322
+ reason: Schema.optionalKey(ErrorReason),
323
+ retryAfterMs: Schema.optionalKey(Schema.Number),
324
+ status: Schema.optionalKey(Schema.Number)
325
+ }) {};
326
+ var Service$1 = class extends Context.Service()("@domainkit/DnsProvider") {};
327
+ const fromAsync = (provider) => Service$1.of({
328
+ id: provider.id,
329
+ createRecord: Effect.fn("DnsProvider.createRecord")((zone, record) => Effect.tryPromise({
330
+ try: () => provider.createRecord(zone, record),
331
+ catch: (cause) => failure(provider, "createRecord", cause)
332
+ })),
333
+ deleteRecord: Effect.fn("DnsProvider.deleteRecord")((zone, providerRecordId) => Effect.tryPromise({
334
+ try: () => provider.deleteRecord(zone, providerRecordId),
335
+ catch: (cause) => failure(provider, "deleteRecord", cause)
336
+ })),
337
+ getRecord: Effect.fn("DnsProvider.getRecord")((zone, providerRecordId) => Effect.tryPromise({
338
+ try: () => provider.getRecord(zone, providerRecordId),
339
+ catch: (cause) => failure(provider, "getRecord", cause)
340
+ })),
341
+ listRecords: Effect.fn("DnsProvider.listRecords")((zone) => Effect.tryPromise({
342
+ try: () => provider.listRecords(zone),
343
+ catch: (cause) => failure(provider, "listRecords", cause)
344
+ }))
345
+ });
346
+ const layerFromAsync$1 = (provider) => Layer.succeed(Service$1, fromAsync(provider));
347
+ const toAsync$1 = (provider) => ({
348
+ id: provider.id,
349
+ createRecord: (zone, record) => Effect.runPromise(provider.createRecord(zone, record)),
350
+ deleteRecord: (zone, providerRecordId) => Effect.runPromise(provider.deleteRecord(zone, providerRecordId)),
351
+ getRecord: (zone, providerRecordId) => Effect.runPromise(provider.getRecord(zone, providerRecordId)),
352
+ listRecords: (zone) => Effect.runPromise(provider.listRecords(zone))
353
+ });
354
+ function failure(provider, operation, cause) {
355
+ return cause instanceof Error$3 ? cause : new Error$3({
356
+ cause,
357
+ message: cause instanceof globalThis.Error ? cause.message : String(cause),
358
+ operation,
359
+ providerId: provider.id
360
+ });
361
+ }
362
+ //#endregion
363
+ //#region src/plan/canonical-json.ts
364
+ var canonical_json_exports = /* @__PURE__ */ __exportAll({
365
+ CryptoError: () => CryptoError,
366
+ sha256Encoded: () => sha256Encoded,
367
+ sha256Json: () => sha256Json,
368
+ sha256Text: () => sha256Text,
369
+ stringify: () => stringify,
370
+ webCryptoLayer: () => webCryptoLayer
371
+ });
372
+ var CryptoError = class extends Schema.TaggedError()("CryptoError", { message: Schema.String }) {};
373
+ /** Deterministic JSON serialization for already schema-encoded protocol values. */
374
+ function stringify(value) {
375
+ if (value === null || typeof value !== "object") {
376
+ const encoded = JSON.stringify(value);
377
+ if (encoded === void 0) throw new TypeError("Value is not representable as JSON");
378
+ return encoded;
379
+ }
380
+ if (isJsonArray(value)) return `[${value.map(stringify).join(",")}]`;
381
+ return `{${Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${stringify(entry)}`).join(",")}}`;
382
+ }
383
+ function isJsonArray(value) {
384
+ return Array.isArray(value);
385
+ }
386
+ const sha256Text = Effect.fn("Digest.sha256Text")(function* (value) {
387
+ return [...yield* (yield* Crypto.Crypto).digest("SHA-256", new TextEncoder().encode(value)).pipe(Effect.mapError((cause) => new CryptoError({ message: cause.message })))].map((byte) => byte.toString(16).padStart(2, "0")).join("");
388
+ });
389
+ const sha256Json = Effect.fn("Digest.sha256Json")((value) => Effect.try({
390
+ try: () => stringify(value),
391
+ catch: (cause) => new CryptoError({ message: cause instanceof Error ? cause.message : String(cause) })
392
+ }).pipe(Effect.flatMap(sha256Text)));
393
+ function sha256EncodedProgram(schema, value) {
394
+ return Schema.encodeEffect(schema)(value).pipe(Effect.mapError((cause) => new CryptoError({ message: cause.message })), Effect.flatMap(Schema.decodeUnknownEffect(Schema.Json)), Effect.mapError((cause) => new CryptoError({ message: cause.message })), Effect.flatMap(sha256Json));
395
+ }
396
+ const sha256Encoded = Effect.fn("Digest.sha256Encoded")(sha256EncodedProgram);
397
+ /** Portable Web Crypto implementation for hosts that want a ready-made Layer. */
398
+ const webCryptoLayer = Layer.succeed(Crypto.Crypto, Crypto.make({
399
+ randomBytes: (size) => crypto.getRandomValues(new Uint8Array(size)),
400
+ digest: (algorithm, data) => Effect.tryPromise({
401
+ try: async () => {
402
+ const bytes = new Uint8Array(data.byteLength);
403
+ bytes.set(data);
404
+ return new Uint8Array(await crypto.subtle.digest(algorithm, bytes.buffer));
405
+ },
406
+ catch: (cause) => PlatformError.systemError({
407
+ _tag: "Unknown",
408
+ module: "WebCrypto",
409
+ method: "digest",
410
+ cause
411
+ })
412
+ })
413
+ }));
414
+ //#endregion
68
415
  //#region src/plan/types.ts
69
416
  var types_exports = /* @__PURE__ */ __exportAll({
70
417
  Authorization: () => Authorization$1,
@@ -79,18 +426,18 @@ var types_exports = /* @__PURE__ */ __exportAll({
79
426
  const Operation$1 = Schema.TaggedUnion({
80
427
  create: {
81
428
  id: Schema.String,
82
- requirement: Schema$3
429
+ requirement: Schema$2
83
430
  },
84
431
  noop: {
85
432
  id: Schema.String,
86
- requirement: Schema$3,
433
+ requirement: Schema$2,
87
434
  ttlDrift: Schema.Boolean
88
435
  },
89
436
  conflict: {
90
437
  existing: Schema.Array(Observed),
91
438
  id: Schema.String,
92
439
  reason: Schema.String,
93
- requirement: Schema$3
440
+ requirement: Schema$2
94
441
  }
95
442
  });
96
443
  const Schema$1 = Schema.Struct({
@@ -98,7 +445,7 @@ const Schema$1 = Schema.Struct({
98
445
  operations: Schema.Array(Operation$1),
99
446
  providerId: Schema.String,
100
447
  version: Schema.Literal("domainkit.dns-plan.v1"),
101
- zone: Schema$2
448
+ zone: Schema$3
102
449
  });
103
450
  const Authorization$1 = Schema.Struct({
104
451
  allowPartial: Schema.Boolean,
@@ -116,11 +463,11 @@ const Receipt$1 = Schema.Struct({
116
463
  providerId: Schema.String,
117
464
  status: Schema.Literals(["complete", "partial"]),
118
465
  version: Schema.Literal("domainkit.apply-receipt.v1"),
119
- zone: Schema$2
466
+ zone: Schema$3
120
467
  });
121
- const decode = Effect.fn("DnsPlan.decode")((input) => Schema.decodeUnknownEffect(Schema$1)(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
468
+ const decode = Effect.fn("DnsPlan.decode")((input) => Schema.decodeUnknownEffect(Schema$1)(input).pipe(Effect.mapError((cause) => new Error$5({ message: cause.message }))));
122
469
  const encode = Schema.encodeSync(Schema$1);
123
- const decodeReceipt = Effect.fn("DnsPlan.decodeReceipt")((input) => Schema.decodeUnknownEffect(Receipt$1)(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
470
+ const decodeReceipt = Effect.fn("DnsPlan.decodeReceipt")((input) => Schema.decodeUnknownEffect(Receipt$1)(input).pipe(Effect.mapError((cause) => new Error$5({ message: cause.message }))));
124
471
  const encodeReceipt = Schema.encodeSync(Receipt$1);
125
472
  //#endregion
126
473
  //#region src/plan/plan.ts
@@ -141,9 +488,9 @@ const UnsignedPlan$1 = Schema.Struct({
141
488
  operations: Schema.Array(Operation$1),
142
489
  providerId: Schema.String,
143
490
  version: Schema.Literal("domainkit.dns-plan.v1"),
144
- zone: Schema$2
491
+ zone: Schema$3
145
492
  });
146
- const RequirementDigest = Schema.Struct({ requirement: Schema$3 });
493
+ const RequirementDigest = Schema.Struct({ requirement: Schema$2 });
147
494
  var ConflictError = class extends Schema.TaggedError()("PlanConflictError", { operationIds: Schema.Array(Schema.String) }) {};
148
495
  var AuthorizationError = class extends Schema.TaggedError()("AuthorizationError", { message: Schema.String }) {};
149
496
  var StaleError = class extends Schema.TaggedError()("StalePlanError", {
@@ -167,16 +514,16 @@ const CreateResult = Data.taggedEnum();
167
514
  function create$1(input) {
168
515
  const target = input.target;
169
516
  if (target._tag === "ExactZone") return Effect.gen(function* () {
170
- const provider = yield* Service$2;
171
- const zone = yield* decode$1(target.zone);
517
+ const provider = yield* Service$1;
518
+ const zone = yield* decode$2(target.zone);
172
519
  return CreateResult.Resolved({
173
520
  candidate: null,
174
521
  plan: yield* planAgainst(provider, zone, input.requirements)
175
522
  });
176
523
  }).pipe(Effect.withSpan("Provisioning.create"));
177
524
  return Effect.gen(function* () {
178
- const discovery = yield* Service$1;
179
- const domain = yield* decode$1(target.domain);
525
+ const discovery = yield* Service$2;
526
+ const domain = yield* decode$2(target.domain);
180
527
  const outcome = yield* discovery.discover(domain);
181
528
  switch (outcome._tag) {
182
529
  case "NotFound": return CreateResult.NotFound({ domain: outcome.domain });
@@ -189,7 +536,7 @@ function create$1(input) {
189
536
  }).pipe(Effect.withSpan("Provisioning.create"));
190
537
  }
191
538
  const planAgainst = Effect.fn("Provisioning.planAgainst")(function* (provider, zone, inputs) {
192
- const requirements = (yield* Effect.forEach(inputs, decode$2, { concurrency: "unbounded" })).sort(compareRecords);
539
+ const requirements = (yield* Effect.forEach(inputs, decode$1, { concurrency: "unbounded" })).sort(compareRecords);
193
540
  const existing = [...yield* provider.listRecords(zone)].sort(compareRecords);
194
541
  const { operations } = yield* Effect.reduce(requirements, () => ({
195
542
  operations: [],
@@ -227,7 +574,7 @@ const authorize$1 = Effect.fn("Provisioning.authorize")(function* (plan, operati
227
574
  /** Applies approved creates sequentially after full and per-operation revalidation. */
228
575
  const apply$1 = Effect.fn("Provisioning.apply")(function* (input) {
229
576
  const { authorization, plan } = input;
230
- const provider = yield* Service$2;
577
+ const provider = yield* Service$1;
231
578
  yield* validate$1(plan);
232
579
  if (authorization.planDigest !== plan.digest) return yield* new AuthorizationError({ message: "Authorization belongs to a different plan" });
233
580
  if (provider.id !== plan.providerId) return yield* new AuthorizationError({ message: "Provider does not match the approved plan" });
@@ -289,7 +636,7 @@ function makeReceipt$1(input, operations, status) {
289
636
  })));
290
637
  }
291
638
  function assertStillCreatable(plan, operation) {
292
- return Service$2.pipe(Effect.flatMap((provider) => planAgainst(provider, plan.zone, [operation.requirement])), Effect.flatMap((currentPlan) => {
639
+ return Service$1.pipe(Effect.flatMap((provider) => planAgainst(provider, plan.zone, [operation.requirement])), Effect.flatMap((currentPlan) => {
293
640
  const currentOperation = currentPlan.operations[0];
294
641
  return currentOperation?._tag === "create" && currentOperation.id === operation.id ? Effect.void : Effect.fail(new StaleError({
295
642
  approvedPlanDigest: plan.digest,
@@ -353,7 +700,7 @@ function compareRecords(left, right) {
353
700
  //#region src/plan/deletion.ts
354
701
  var deletion_exports = /* @__PURE__ */ __exportAll({
355
702
  Authorization: () => Authorization,
356
- Error: () => Error$1,
703
+ Error: () => Error$2,
357
704
  Operation: () => Operation,
358
705
  PartialError: () => PartialError,
359
706
  Plan: () => Plan,
@@ -366,7 +713,7 @@ var deletion_exports = /* @__PURE__ */ __exportAll({
366
713
  const Operation = Schema.Struct({
367
714
  id: Schema.String,
368
715
  providerRecordId: Schema.String,
369
- record: Schema$3
716
+ record: Schema$2
370
717
  });
371
718
  const UnsignedPlan = Schema.Struct({
372
719
  createdAt: Schema.DateFromString,
@@ -375,7 +722,7 @@ const UnsignedPlan = Schema.Struct({
375
722
  providerId: Schema.String,
376
723
  sourcePlanDigest: Schema.String,
377
724
  version: Schema.Literal("domainkit.deletion-plan.v1"),
378
- zone: Schema$2
725
+ zone: Schema$3
379
726
  });
380
727
  const Plan = Schema.Struct({
381
728
  ...UnsignedPlan.fields,
@@ -396,9 +743,9 @@ const Receipt = Schema.Struct({
396
743
  providerId: Schema.String,
397
744
  status: Schema.Literals(["complete", "partial"]),
398
745
  version: Schema.Literal("domainkit.deletion-receipt.v1"),
399
- zone: Schema$2
746
+ zone: Schema$3
400
747
  });
401
- var Error$1 = class extends Schema.TaggedError()("UnsafeDeletionError", {
748
+ var Error$2 = class extends Schema.TaggedError()("UnsafeDeletionError", {
402
749
  message: Schema.String,
403
750
  operationId: Schema.optionalKey(Schema.String)
404
751
  }) {};
@@ -409,17 +756,17 @@ var PartialError = class extends Schema.TaggedError()("PartialDeletionError", {
409
756
  }) {};
410
757
  /** Build a fresh deletion plan only from records proven by a prior create receipt. */
411
758
  const create = Effect.fn("Deletion.create")(function* (input) {
412
- const provider = yield* Service$2;
759
+ const provider = yield* Service$1;
413
760
  yield* validate$1(input.plan);
414
- if (input.receipt.planDigest !== input.plan.digest || input.receipt.providerId !== input.plan.providerId || input.receipt.zone !== input.plan.zone) return yield* new Error$1({ message: "Create receipt does not belong to the source plan" });
415
- if (provider.id !== input.plan.providerId) return yield* new Error$1({ message: "Provider does not match the source receipt" });
761
+ if (input.receipt.planDigest !== input.plan.digest || input.receipt.providerId !== input.plan.providerId || input.receipt.zone !== input.plan.zone) return yield* new Error$2({ message: "Create receipt does not belong to the source plan" });
762
+ if (provider.id !== input.plan.providerId) return yield* new Error$2({ message: "Provider does not match the source receipt" });
416
763
  const operations = yield* Effect.forEach(input.receipt.operations, (applied) => Effect.gen(function* () {
417
764
  const source = input.plan.operations.find((operation) => operation._tag === "create" && operation.id === applied.operationId);
418
- if (source === void 0 || source._tag !== "create") return yield* new Error$1({
765
+ if (source === void 0 || source._tag !== "create") return yield* new Error$2({
419
766
  message: "Receipt operation is not a created source record",
420
767
  operationId: applied.operationId
421
768
  });
422
- if (applied.providerRecordId === null) return yield* new Error$1({
769
+ if (applied.providerRecordId === null) return yield* new Error$2({
423
770
  message: "Provider record ID is required for safe deletion",
424
771
  operationId: applied.operationId
425
772
  });
@@ -450,7 +797,7 @@ const authorize = Effect.fn("Deletion.authorize")(function* (plan, operationIds)
450
797
  yield* validate(plan);
451
798
  const selected = [...new Set(operationIds ?? plan.operations.map(({ id }) => id))].sort();
452
799
  const unknown = selected.filter((id) => !plan.operations.some((operation) => operation.id === id));
453
- if (unknown.length > 0) return yield* new Error$1({ message: `Unknown deletion operation IDs: ${unknown.join(", ")}` });
800
+ if (unknown.length > 0) return yield* new Error$2({ message: `Unknown deletion operation IDs: ${unknown.join(", ")}` });
454
801
  return {
455
802
  operationIds: selected,
456
803
  planDigest: plan.digest,
@@ -459,17 +806,17 @@ const authorize = Effect.fn("Deletion.authorize")(function* (plan, operationIds)
459
806
  });
460
807
  /** Re-read every approved record before the first delete, then delete by provider record ID. */
461
808
  const apply = Effect.fn("Deletion.apply")(function* (input) {
462
- const provider = yield* Service$2;
809
+ const provider = yield* Service$1;
463
810
  yield* validate(input.plan);
464
- if (input.authorization.planDigest !== input.plan.digest) return yield* new Error$1({ message: "Deletion authorization belongs to a different plan" });
465
- if (provider.id !== input.plan.providerId) return yield* new Error$1({ message: "Provider does not match the deletion plan" });
811
+ if (input.authorization.planDigest !== input.plan.digest) return yield* new Error$2({ message: "Deletion authorization belongs to a different plan" });
812
+ if (provider.id !== input.plan.providerId) return yield* new Error$2({ message: "Provider does not match the deletion plan" });
466
813
  const now = yield* Clock.currentTimeMillis;
467
- if (input.plan.expiresAt <= new Date(now)) return yield* new Error$1({ message: "Deletion plan has expired" });
814
+ if (input.plan.expiresAt <= new Date(now)) return yield* new Error$2({ message: "Deletion plan has expired" });
468
815
  const selected = input.plan.operations.filter(({ id }) => input.authorization.operationIds.includes(id));
469
- if (selected.length !== input.authorization.operationIds.length) return yield* new Error$1({ message: "Deletion authorization contains unknown operations" });
816
+ if (selected.length !== input.authorization.operationIds.length) return yield* new Error$2({ message: "Deletion authorization contains unknown operations" });
470
817
  const previouslyDeleted = yield* validatePriorReceipt(input.plan, input.priorReceipt);
471
818
  const completedIds = new Set(previouslyDeleted.map(({ operationId }) => operationId));
472
- if (previouslyDeleted.some(({ operationId }) => !input.authorization.operationIds.includes(operationId))) return yield* new Error$1({ message: "Prior receipt contains an unauthorized operation" });
819
+ if (previouslyDeleted.some(({ operationId }) => !input.authorization.operationIds.includes(operationId))) return yield* new Error$2({ message: "Prior receipt contains an unauthorized operation" });
473
820
  const remaining = selected.filter(({ id }) => !completedIds.has(id));
474
821
  yield* Effect.forEach(remaining, (operation) => assertExact(provider, input.plan.zone, operation.providerRecordId, operation.record, operation.id));
475
822
  const deleted = [...previouslyDeleted];
@@ -506,19 +853,19 @@ function validate(plan) {
506
853
  version: plan.version,
507
854
  zone: plan.zone
508
855
  };
509
- return sha256Encoded(UnsignedPlan, unsigned).pipe(Effect.flatMap((digest) => digest === plan.digest ? Effect.void : Effect.fail(new Error$1({ message: "Deletion plan digest does not match its contents" }))));
856
+ return sha256Encoded(UnsignedPlan, unsigned).pipe(Effect.flatMap((digest) => digest === plan.digest ? Effect.void : Effect.fail(new Error$2({ message: "Deletion plan digest does not match its contents" }))));
510
857
  }
511
858
  function validatePriorReceipt(plan, receipt) {
512
859
  if (receipt === void 0) return Effect.succeed([]);
513
- if (receipt.planDigest !== plan.digest || receipt.providerId !== plan.providerId || receipt.zone !== plan.zone || receipt.status !== "partial") return Effect.fail(new Error$1({ message: "Prior receipt does not belong to this deletion plan" }));
860
+ if (receipt.planDigest !== plan.digest || receipt.providerId !== plan.providerId || receipt.zone !== plan.zone || receipt.status !== "partial") return Effect.fail(new Error$2({ message: "Prior receipt does not belong to this deletion plan" }));
514
861
  for (const completed of receipt.operations) {
515
862
  const operation = plan.operations.find(({ id }) => id === completed.operationId);
516
- if (operation === void 0 || operation.providerRecordId !== completed.providerRecordId) return Effect.fail(new Error$1({ message: "Prior receipt operation does not match the deletion plan" }));
863
+ if (operation === void 0 || operation.providerRecordId !== completed.providerRecordId) return Effect.fail(new Error$2({ message: "Prior receipt operation does not match the deletion plan" }));
517
864
  }
518
865
  return Effect.succeed([...receipt.operations]);
519
866
  }
520
867
  function assertExact(provider, zone, providerRecordId, expected, operationId) {
521
- return provider.getRecord(zone, providerRecordId).pipe(Effect.flatMap((observed) => observed !== null && observed._tag !== "Opaque" && equals(observed, expected) ? Effect.void : Effect.fail(new Error$1({
868
+ return provider.getRecord(zone, providerRecordId).pipe(Effect.flatMap((observed) => observed !== null && observed._tag !== "Opaque" && equals(observed, expected) ? Effect.void : Effect.fail(new Error$2({
522
869
  message: observed === null ? "Created record no longer exists" : "Created record content no longer matches its receipt",
523
870
  operationId
524
871
  }))));
@@ -538,7 +885,7 @@ function makeReceipt(plan, operations, status) {
538
885
  //#region src/verification/resolver.ts
539
886
  var resolver_exports = /* @__PURE__ */ __exportAll({
540
887
  Answer: () => Answer,
541
- Error: () => Error,
888
+ Error: () => Error$1,
542
889
  Resolution: () => Resolution,
543
890
  Service: () => Service,
544
891
  layerFromAsync: () => layerFromAsync,
@@ -546,7 +893,7 @@ var resolver_exports = /* @__PURE__ */ __exportAll({
546
893
  });
547
894
  const Answer = Schema.Struct({
548
895
  data: Schema.String,
549
- name: Schema$2,
896
+ name: Schema$3,
550
897
  ttl: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
551
898
  type: Type
552
899
  });
@@ -554,7 +901,7 @@ const Resolution = Schema.TaggedUnion({
554
901
  answer: { answers: Schema.Array(Answer) },
555
902
  nodata: {}
556
903
  });
557
- var Error = class extends Schema.TaggedError()("ResolverError", {
904
+ var Error$1 = class extends Schema.TaggedError()("ResolverError", {
558
905
  cause: Schema.optionalKey(Schema.Unknown),
559
906
  message: Schema.String,
560
907
  reason: Schema.Literals([
@@ -566,7 +913,7 @@ var Error = class extends Schema.TaggedError()("ResolverError", {
566
913
  var Service = class extends Context.Service()("@domainkit/DnsResolver") {};
567
914
  const layerFromAsync = (resolver) => Layer.succeed(Service, { resolve: Effect.fn("DnsResolver.resolve")((query) => Effect.tryPromise({
568
915
  try: () => resolver.resolve(query),
569
- catch: (cause) => new Error({
916
+ catch: (cause) => new Error$1({
570
917
  cause,
571
918
  message: cause instanceof globalThis.Error ? cause.message : String(cause),
572
919
  reason: "transport"
@@ -575,11 +922,11 @@ const layerFromAsync = (resolver) => Layer.succeed(Service, { resolve: Effect.fn
575
922
  switch (resolution._tag) {
576
923
  case "answer":
577
924
  case "nodata": return Effect.succeed(resolution);
578
- case "timeout": return Effect.fail(new Error({
925
+ case "timeout": return Effect.fail(new Error$1({
579
926
  message: "DNS query timed out",
580
927
  reason: "timeout"
581
928
  }));
582
- case "failure": return Effect.fail(new Error({
929
+ case "failure": return Effect.fail(new Error$1({
583
930
  message: resolution.message,
584
931
  reason: "transport"
585
932
  }));
@@ -593,6 +940,6 @@ const toAsync = (resolver) => ({ resolve: (query) => Effect.runPromise(resolver.
593
940
  onSuccess: (resolution) => resolution
594
941
  }))) });
595
942
  //#endregion
596
- export { decodeReceipt as A, plan_exports as C, Receipt$1 as D, Operation$1 as E, Service$1 as F, make as I, zone_discovery_exports as L, encodeReceipt as M, types_exports as N, Schema$1 as O, Candidate as P, create$1 as S, Authorization$1 as T, PartialApplyError as _, Authorization as a, apply$1 as b, PartialError as c, apply as d, authorize as f, CreateResult as g, ConflictError as h, toAsync as i, encode as j, decode as k, Plan as l, deletion_exports as m, Service as n, Error$1 as o, create as p, resolver_exports as r, Operation as s, Error as t, Receipt as u, StaleError as v, renderManualInstructions as w, authorize$1 as x, Target as y };
943
+ export { Txt as $, decodeReceipt as A, provider_exports as B, plan_exports as C, Receipt$1 as D, Operation$1 as E, webCryptoLayer as F, Cname as G, A as H, Error$3 as I, Observed as J, Mx as K, Service$1 as L, encodeReceipt as M, types_exports as N, Schema$1 as O, canonical_json_exports as P, Srv as Q, fromAsync as R, create$1 as S, Authorization$1 as T, Aaaa as U, toAsync$1 as V, Caa as W, RequirementMetadata as X, Opaque as Y, Schema$2 as Z, PartialApplyError as _, domain_name_exports as _t, Authorization as a, parse as at, apply$1 as b, invalid_input_exports as bt, PartialError as c, make as ct, apply as d, zones_exports as dt, Type as et, authorize as f, Error$4 as ft, CreateResult as g, decode$2 as gt, ConflictError as h, Schema$3 as ht, toAsync as i, equals as it, encode as j, decode as k, Plan as l, zone_discovery_exports as lt, deletion_exports as m, lifecycle_repository_exports as mt, Service as n, decode$1 as nt, Error$2 as o, Candidate as ot, create as p, Service$3 as pt, Ns as q, resolver_exports as r, dns_record_exports as rt, Operation as s, Service$2 as st, Error$1 as t, data as tt, Receipt as u, candidates as ut, StaleError as v, parse$1 as vt, renderManualInstructions as w, authorize$1 as x, Target as y, Error$5 as yt, layerFromAsync$1 as z };
597
944
 
598
- //# sourceMappingURL=resolver-CxE-VDw4.mjs.map
945
+ //# sourceMappingURL=resolver-CvK7JoJM.mjs.map