domainkit 0.5.0 → 0.6.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/README.md +3 -1
- package/dist/canonical-json-9x7gHIoS.mjs +304 -0
- package/dist/canonical-json-9x7gHIoS.mjs.map +1 -0
- package/dist/connect-Db830jad.d.mts +1387 -0
- package/dist/connect-ks3cpqBD.mjs +185 -0
- package/dist/connect-ks3cpqBD.mjs.map +1 -0
- package/dist/connection-DuYDgWir.d.mts +186 -0
- package/dist/connection-api-B__0M3PA.d.mts +26 -0
- package/dist/index.d.mts +7 -26
- package/dist/index.mjs +11 -5
- package/dist/index.mjs.map +1 -1
- package/dist/managed-dns-connections-CaXts84E.mjs +99 -0
- package/dist/managed-dns-connections-CaXts84E.mjs.map +1 -0
- package/dist/promise.d.mts +39 -217
- package/dist/promise.mjs +39 -125
- package/dist/promise.mjs.map +1 -1
- package/dist/{resolver-BGBLnPjJ.d.mts → resolver-DUAIlm2I.d.mts} +24 -1127
- package/dist/{resolver-tZU6gEVq.mjs → resolver-DxJPsq6l.mjs} +11 -227
- package/dist/resolver-DxJPsq6l.mjs.map +1 -0
- package/dist/server.d.mts +128 -0
- package/dist/server.mjs +319 -0
- package/dist/server.mjs.map +1 -0
- package/dist/testing.d.mts +5 -4
- package/dist/testing.mjs +10 -13
- package/dist/testing.mjs.map +1 -1
- package/dist/{verify-B2fPyjde.mjs → verify-DAtUAEeg.mjs} +124 -309
- package/dist/verify-DAtUAEeg.mjs.map +1 -0
- package/dist/{verify-6xK05pwL.d.mts → verify-yAy-r9no.d.mts} +34 -19
- package/package.json +5 -1
- package/dist/resolver-tZU6gEVq.mjs.map +0 -1
- package/dist/verify-B2fPyjde.mjs.map +0 -1
|
@@ -1,177 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { E as decode$2, O as parse$1, T as Schema$3, k as Error$4, n as sha256Encoded, r as stringify } from "./canonical-json-9x7gHIoS.mjs";
|
|
3
|
+
import { Cause, Clock, Context, Data, Effect, Layer, Schema } from "effect";
|
|
3
4
|
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$3,
|
|
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$3 = 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/connection.ts
|
|
42
|
-
/** A provider account and authoritative zone selected for one domain attachment. */
|
|
43
|
-
const ProviderTargetEvidence = Schema.Struct({
|
|
44
|
-
/** The account display name observed during discovery, when the provider exposes one. */
|
|
45
|
-
accountName: Schema.optionalKey(Schema.String),
|
|
46
|
-
/** Nameserver and provider-state evidence observed during discovery. */
|
|
47
|
-
nameservers: Schema.Array(Schema$3),
|
|
48
|
-
status: Schema.String,
|
|
49
|
-
/** Provider-specific authoritative-zone type, such as Cloudflare's `full` or Vercel's `external`. */
|
|
50
|
-
zoneType: Schema.String
|
|
51
|
-
});
|
|
52
|
-
const ProviderTarget = Schema.Struct({
|
|
53
|
-
accountId: Schema.String,
|
|
54
|
-
accountKind: Schema.NullOr(Schema.Literals([
|
|
55
|
-
"account",
|
|
56
|
-
"personal",
|
|
57
|
-
"team"
|
|
58
|
-
])),
|
|
59
|
-
evidence: Schema.optionalKey(ProviderTargetEvidence),
|
|
60
|
-
zoneId: Schema.String,
|
|
61
|
-
zoneName: Schema$3
|
|
62
|
-
});
|
|
63
|
-
/** The lifecycle state visible to a host for an organization connection. */
|
|
64
|
-
const ConnectionStatus = Schema.Literals([
|
|
65
|
-
"active",
|
|
66
|
-
"expired",
|
|
67
|
-
"revocation-pending"
|
|
68
|
-
]);
|
|
69
|
-
/** An organization-scoped provider connection. */
|
|
70
|
-
const ProviderConnection = Schema.Struct({
|
|
71
|
-
createdAt: Schema.DateFromString,
|
|
72
|
-
id: Schema.String,
|
|
73
|
-
method: Schema.Literals([
|
|
74
|
-
"integration",
|
|
75
|
-
"oauth2",
|
|
76
|
-
"token"
|
|
77
|
-
]),
|
|
78
|
-
ownerId: Schema.String,
|
|
79
|
-
providerId: Schema.String,
|
|
80
|
-
status: ConnectionStatus
|
|
81
|
-
});
|
|
82
|
-
/** An exact provider target attached to one organization domain. */
|
|
83
|
-
const DomainAttachment = Schema.Struct({
|
|
84
|
-
connectionId: Schema.String,
|
|
85
|
-
createdAt: Schema.DateFromString,
|
|
86
|
-
domain: Schema$3,
|
|
87
|
-
id: Schema.String,
|
|
88
|
-
target: ProviderTarget
|
|
89
|
-
});
|
|
90
|
-
Schema.Struct({
|
|
91
|
-
authorizationId: Schema.String,
|
|
92
|
-
createdAt: Schema.DateFromString,
|
|
93
|
-
id: Schema.String,
|
|
94
|
-
method: Schema.Literals([
|
|
95
|
-
"integration",
|
|
96
|
-
"oauth2",
|
|
97
|
-
"token"
|
|
98
|
-
]),
|
|
99
|
-
ownerId: Schema.String,
|
|
100
|
-
providerId: Schema.String
|
|
101
|
-
});
|
|
102
|
-
var AuthorizationError$1 = class extends Schema.TaggedError()("AuthorizationError", {
|
|
103
|
-
category: Schema.Literal("authorization"),
|
|
104
|
-
message: Schema.String,
|
|
105
|
-
operation: Schema.String,
|
|
106
|
-
retry: Schema.Literals([
|
|
107
|
-
"never",
|
|
108
|
-
"after-user-action",
|
|
109
|
-
"safe",
|
|
110
|
-
"unknown"
|
|
111
|
-
])
|
|
112
|
-
}) {};
|
|
113
|
-
const authorizationError = (message, operation) => new AuthorizationError$1({
|
|
114
|
-
category: "authorization",
|
|
115
|
-
message,
|
|
116
|
-
operation,
|
|
117
|
-
retry: "after-user-action"
|
|
118
|
-
});
|
|
119
|
-
/** Decode a public connection snapshot returned by a host. */
|
|
120
|
-
const decode$2 = Effect.fn("ProviderConnection.decode")((input) => Schema.decodeUnknownEffect(ProviderConnection)(input).pipe(Effect.mapError((cause) => new Error$5({ message: cause.message }))));
|
|
121
|
-
const validate$2 = Effect.fn("ProviderConnection.validate")((input) => Schema.decodeUnknownEffect(Schema.toType(ProviderConnection))(input).pipe(Effect.mapError((cause) => new Error$5({ message: cause.message }))));
|
|
122
|
-
const encode$1 = Schema.encodeSync(ProviderConnection);
|
|
123
|
-
/** Derive a public connection projection from its private authorization state. */
|
|
124
|
-
function project(connection, authorization, now = /* @__PURE__ */ new Date()) {
|
|
125
|
-
const status = authorization.revocation._tag === "Pending" ? "revocation-pending" : authorization.expiresAt !== null && authorization.expiresAt <= now ? "expired" : "active";
|
|
126
|
-
return {
|
|
127
|
-
createdAt: connection.createdAt,
|
|
128
|
-
id: connection.id,
|
|
129
|
-
method: connection.method,
|
|
130
|
-
ownerId: connection.ownerId,
|
|
131
|
-
providerId: connection.providerId,
|
|
132
|
-
status
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/** Assert that an exact attachment is usable for one DNS operation. */
|
|
136
|
-
function assertAttachment(input) {
|
|
137
|
-
if (input.connection.providerId !== input.providerId || input.authorization.providerId !== input.providerId || input.authorization.revocation._tag !== "Active" || input.attachment.connectionId !== input.connection.id) throw authorizationError("Domain attachment is not active for this provider", "Connection.assertAttachment");
|
|
138
|
-
if (input.authorization.expiresAt !== null) {
|
|
139
|
-
if (Number.isNaN(input.authorization.expiresAt.getTime())) throw authorizationError("Provider authorization expiration is invalid", "Connection.assertAttachment");
|
|
140
|
-
if (input.authorization.expiresAt <= (input.now ?? /* @__PURE__ */ new Date())) throw authorizationError("Provider authorization has expired", "Connection.assertAttachment");
|
|
141
|
-
}
|
|
142
|
-
if (!input.authorization.requiredCapabilities.includes(input.capability)) throw authorizationError(`Provider authorization lacks the ${input.capability} capability`, "Connection.assertAttachment");
|
|
143
|
-
if (!input.authorization.capabilityEvidence.some((item) => item.capability === input.capability)) throw authorizationError(`Provider authorization has no evidence for the ${input.capability} capability`, "Connection.assertAttachment");
|
|
144
|
-
let domain;
|
|
145
|
-
try {
|
|
146
|
-
domain = parse$1(input.domain);
|
|
147
|
-
} catch (cause) {
|
|
148
|
-
if (cause instanceof Error$5) throw cause;
|
|
149
|
-
throw new Error$5({ message: cause instanceof Error ? cause.message : String(cause) });
|
|
150
|
-
}
|
|
151
|
-
if (input.attachment.domain !== domain && !domain.endsWith(`.${input.attachment.domain}`)) throw authorizationError("Domain attachment does not match the requested domain", "Connection.assertAttachment");
|
|
152
|
-
return domain;
|
|
153
|
-
}
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/auth/lifecycle-repository.ts
|
|
156
|
-
var Error$4 = class extends Schema.TaggedError()("ManagedDnsLifecycleError", {
|
|
157
|
-
category: Schema.Literal("storage"),
|
|
158
|
-
message: Schema.String,
|
|
159
|
-
operation: Schema.String,
|
|
160
|
-
retry: Schema.Literals([
|
|
161
|
-
"never",
|
|
162
|
-
"after-user-action",
|
|
163
|
-
"safe",
|
|
164
|
-
"unknown"
|
|
165
|
-
])
|
|
166
|
-
}) {};
|
|
167
|
-
var Service$3 = class extends Context.Service()("@domainkit/ManagedDnsConnections") {};
|
|
168
|
-
//#endregion
|
|
169
5
|
//#region src/discovery/zones.ts
|
|
170
6
|
var zones_exports = /* @__PURE__ */ __exportAll({ candidates: () => candidates });
|
|
171
7
|
function candidates(input) {
|
|
172
8
|
const domain = parse$1(input);
|
|
173
9
|
const registrable = getDomain(domain, { allowPrivateDomains: true });
|
|
174
|
-
if (registrable === null) throw new Error$
|
|
10
|
+
if (registrable === null) throw new Error$4({ message: "Domain does not have a registrable DNS zone" });
|
|
175
11
|
const labels = domain.split(".");
|
|
176
12
|
const registrableLabels = registrable.split(".").length;
|
|
177
13
|
const values = [];
|
|
@@ -356,12 +192,12 @@ const Opaque = Schema.Struct({
|
|
|
356
192
|
});
|
|
357
193
|
/** Any DNS record observed through a provider, including non-portable record types. */
|
|
358
194
|
const Observed = Schema.Union([Schema$2, Opaque]);
|
|
359
|
-
const decode$1 = Effect.fn("DnsRecord.decode")((input) => Schema.decodeUnknownEffect(Schema$2)(input).pipe(Effect.mapError((cause) => new Error$
|
|
195
|
+
const decode$1 = Effect.fn("DnsRecord.decode")((input) => Schema.decodeUnknownEffect(Schema$2)(input).pipe(Effect.mapError((cause) => new Error$4({ message: cause.message }))));
|
|
360
196
|
function parse(input) {
|
|
361
197
|
try {
|
|
362
198
|
return Schema.decodeUnknownSync(Schema$2)(input);
|
|
363
199
|
} catch (cause) {
|
|
364
|
-
throw new Error$
|
|
200
|
+
throw new Error$4({ message: cause instanceof Error ? cause.message : String(cause) });
|
|
365
201
|
}
|
|
366
202
|
}
|
|
367
203
|
function data(record) {
|
|
@@ -470,58 +306,6 @@ function failure(provider, operation, cause) {
|
|
|
470
306
|
});
|
|
471
307
|
}
|
|
472
308
|
//#endregion
|
|
473
|
-
//#region src/plan/canonical-json.ts
|
|
474
|
-
var canonical_json_exports = /* @__PURE__ */ __exportAll({
|
|
475
|
-
CryptoError: () => CryptoError,
|
|
476
|
-
sha256Encoded: () => sha256Encoded,
|
|
477
|
-
sha256Json: () => sha256Json,
|
|
478
|
-
sha256Text: () => sha256Text,
|
|
479
|
-
stringify: () => stringify,
|
|
480
|
-
webCryptoLayer: () => webCryptoLayer
|
|
481
|
-
});
|
|
482
|
-
var CryptoError = class extends Schema.TaggedError()("CryptoError", { message: Schema.String }) {};
|
|
483
|
-
/** Deterministic JSON serialization for already schema-encoded protocol values. */
|
|
484
|
-
function stringify(value) {
|
|
485
|
-
if (value === null || typeof value !== "object") {
|
|
486
|
-
const encoded = JSON.stringify(value);
|
|
487
|
-
if (encoded === void 0) throw new TypeError("Value is not representable as JSON");
|
|
488
|
-
return encoded;
|
|
489
|
-
}
|
|
490
|
-
if (isJsonArray(value)) return `[${value.map(stringify).join(",")}]`;
|
|
491
|
-
return `{${Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${stringify(entry)}`).join(",")}}`;
|
|
492
|
-
}
|
|
493
|
-
function isJsonArray(value) {
|
|
494
|
-
return Array.isArray(value);
|
|
495
|
-
}
|
|
496
|
-
const sha256Text = Effect.fn("Digest.sha256Text")(function* (value) {
|
|
497
|
-
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("");
|
|
498
|
-
});
|
|
499
|
-
const sha256Json = Effect.fn("Digest.sha256Json")((value) => Effect.try({
|
|
500
|
-
try: () => stringify(value),
|
|
501
|
-
catch: (cause) => new CryptoError({ message: cause instanceof Error ? cause.message : String(cause) })
|
|
502
|
-
}).pipe(Effect.flatMap(sha256Text)));
|
|
503
|
-
function sha256EncodedProgram(schema, value) {
|
|
504
|
-
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));
|
|
505
|
-
}
|
|
506
|
-
const sha256Encoded = Effect.fn("Digest.sha256Encoded")(sha256EncodedProgram);
|
|
507
|
-
/** Portable Web Crypto implementation for hosts that want a ready-made Layer. */
|
|
508
|
-
const webCryptoLayer = Layer.succeed(Crypto.Crypto, Crypto.make({
|
|
509
|
-
randomBytes: (size) => crypto.getRandomValues(new Uint8Array(size)),
|
|
510
|
-
digest: (algorithm, data) => Effect.tryPromise({
|
|
511
|
-
try: async () => {
|
|
512
|
-
const bytes = new Uint8Array(data.byteLength);
|
|
513
|
-
bytes.set(data);
|
|
514
|
-
return new Uint8Array(await crypto.subtle.digest(algorithm, bytes.buffer));
|
|
515
|
-
},
|
|
516
|
-
catch: (cause) => PlatformError.systemError({
|
|
517
|
-
_tag: "Unknown",
|
|
518
|
-
module: "WebCrypto",
|
|
519
|
-
method: "digest",
|
|
520
|
-
cause
|
|
521
|
-
})
|
|
522
|
-
})
|
|
523
|
-
}));
|
|
524
|
-
//#endregion
|
|
525
309
|
//#region src/plan/types.ts
|
|
526
310
|
var types_exports = /* @__PURE__ */ __exportAll({
|
|
527
311
|
Authorization: () => Authorization$1,
|
|
@@ -575,9 +359,9 @@ const Receipt$1 = Schema.Struct({
|
|
|
575
359
|
version: Schema.Literal("domainkit.apply-receipt.v1"),
|
|
576
360
|
zone: Schema$3
|
|
577
361
|
});
|
|
578
|
-
const decode = Effect.fn("DnsPlan.decode")((input) => Schema.decodeUnknownEffect(Schema$1)(input).pipe(Effect.mapError((cause) => new Error$
|
|
362
|
+
const decode = Effect.fn("DnsPlan.decode")((input) => Schema.decodeUnknownEffect(Schema$1)(input).pipe(Effect.mapError((cause) => new Error$4({ message: cause.message }))));
|
|
579
363
|
const encode = Schema.encodeSync(Schema$1);
|
|
580
|
-
const decodeReceipt = Effect.fn("DnsPlan.decodeReceipt")((input) => Schema.decodeUnknownEffect(Receipt$1)(input).pipe(Effect.mapError((cause) => new Error$
|
|
364
|
+
const decodeReceipt = Effect.fn("DnsPlan.decodeReceipt")((input) => Schema.decodeUnknownEffect(Receipt$1)(input).pipe(Effect.mapError((cause) => new Error$4({ message: cause.message }))));
|
|
581
365
|
const encodeReceipt = Schema.encodeSync(Receipt$1);
|
|
582
366
|
//#endregion
|
|
583
367
|
//#region src/plan/plan.ts
|
|
@@ -625,7 +409,7 @@ function create$1(input) {
|
|
|
625
409
|
const target = input.target;
|
|
626
410
|
if (target._tag === "ExactZone") return Effect.gen(function* () {
|
|
627
411
|
const provider = yield* Service$1;
|
|
628
|
-
const zone = yield* decode$
|
|
412
|
+
const zone = yield* decode$2(target.zone);
|
|
629
413
|
return CreateResult.Resolved({
|
|
630
414
|
candidate: null,
|
|
631
415
|
plan: yield* planAgainst(provider, zone, input.requirements)
|
|
@@ -633,7 +417,7 @@ function create$1(input) {
|
|
|
633
417
|
}).pipe(Effect.withSpan("Provisioning.create"));
|
|
634
418
|
return Effect.gen(function* () {
|
|
635
419
|
const discovery = yield* Service$2;
|
|
636
|
-
const domain = yield* decode$
|
|
420
|
+
const domain = yield* decode$2(target.domain);
|
|
637
421
|
const outcome = yield* discovery.discover(domain);
|
|
638
422
|
switch (outcome._tag) {
|
|
639
423
|
case "NotFound": return CreateResult.NotFound({ domain: outcome.domain });
|
|
@@ -1050,6 +834,6 @@ const toAsync = (resolver) => ({ resolve: (query) => Effect.runPromise(resolver.
|
|
|
1050
834
|
onSuccess: (resolution) => resolution
|
|
1051
835
|
}))) });
|
|
1052
836
|
//#endregion
|
|
1053
|
-
export {
|
|
837
|
+
export { data as $, decodeReceipt as A, A as B, plan_exports as C, Receipt$1 as D, Operation$1 as E, Service$1 as F, Ns as G, Caa as H, fromAsync as I, RequirementMetadata as J, Observed as K, layerFromAsync$1 as L, encodeReceipt as M, types_exports as N, Schema$1 as O, Error$3 as P, Type as Q, provider_exports as R, create$1 as S, Authorization$1 as T, Cname as U, Aaaa as V, Mx as W, Srv as X, Schema$2 as Y, Txt as Z, PartialApplyError as _, Authorization as a, Service$2 as at, apply$1 as b, PartialError as c, candidates as ct, apply as d, decode$1 as et, authorize as f, CreateResult as g, ConflictError as h, toAsync as i, Candidate as it, encode as j, decode as k, Plan as l, zones_exports as lt, deletion_exports as m, Service as n, equals as nt, Error$2 as o, make as ot, create as p, Opaque as q, resolver_exports as r, parse as rt, Operation as s, zone_discovery_exports as st, Error$1 as t, dns_record_exports as tt, Receipt as u, StaleError as v, renderManualInstructions as w, authorize$1 as x, Target as y, toAsync$1 as z };
|
|
1054
838
|
|
|
1055
|
-
//# sourceMappingURL=resolver-
|
|
839
|
+
//# sourceMappingURL=resolver-DxJPsq6l.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver-DxJPsq6l.mjs","names":["DomainName.parse","InvalidInputError","Domain.Schema","Service","Zones.candidates","S","DomainName.Schema","Schema","decode","InvalidInputError","Error","Service","layerFromAsync","toAsync","Operation","S","DnsRecord.Schema","DnsRecord.Observed","Schema","DomainName.Schema","Authorization","Receipt","InvalidInputError","UnsignedPlan","S","DnsPlan.Operation","DomainName.Schema","DnsRecord.Schema","DnsPlan.Receipt","create","DnsProvider.Service","DomainName.decode","ZoneDiscovery.Service","DnsRecord.decode","authorize","validate","apply","makeReceipt","data","DnsRecord.data","DnsRecord.equals","DnsRecord.Observed","S","DnsRecord.Schema","DomainName.Schema","Error","DnsProvider.Service","Provisioning.validate","DnsRecord.equals","DomainName.Schema","DnsRecord.Type","Error"],"sources":["../src/discovery/zones.ts","../src/discovery/zone-discovery.ts","../src/domain/dns-record.ts","../src/provider/provider.ts","../src/plan/types.ts","../src/plan/plan.ts","../src/plan/deletion.ts","../src/verification/resolver.ts"],"sourcesContent":["import { getDomain } from \"tldts\";\n\nimport * as DomainName from \"../domain/domain-name.ts\";\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\n\nexport function candidates(input: string): ReadonlyArray<DomainName.DomainName> {\n const domain = DomainName.parse(input);\n const registrable = getDomain(domain, { allowPrivateDomains: true });\n if (registrable === null) {\n throw new InvalidInputError({ message: \"Domain does not have a registrable DNS zone\" });\n }\n const labels = domain.split(\".\");\n const registrableLabels = registrable.split(\".\").length;\n const values: Array<DomainName.DomainName> = [];\n for (let index = 0; index <= labels.length - registrableLabels; index += 1) {\n values.push(DomainName.parse(labels.slice(index).join(\".\")));\n }\n return values;\n}\n","import { Context, Data, Effect, Schema } from \"effect\";\n\nimport type * as DomainName from \"../domain/domain-name.ts\";\nimport * as Domain from \"../domain/domain-name.ts\";\nimport * as DnsProvider from \"../provider/provider.ts\";\nimport * as Zones from \"./zones.ts\";\n\n/** Display-safe identity and nameserver evidence for one provider-owned zone. */\nexport const Candidate = Schema.Struct({\n accountId: Schema.String,\n id: Schema.String,\n name: Domain.Schema,\n nameservers: Schema.Array(Domain.Schema),\n providerId: Schema.String,\n status: Schema.Literals([\"active\", \"pending\", \"unknown\"]),\n});\nexport interface Candidate extends Schema.Schema.Type<typeof Candidate> {}\n\nexport interface Source {\n readonly listZones: (\n name: DomainName.DomainName,\n ) => Effect.Effect<ReadonlyArray<Omit<Candidate, \"providerId\">>, DnsProvider.Error>;\n readonly provider: DnsProvider.Interface;\n}\n\nexport type Outcome = Data.TaggedEnum<{\n NotFound: { readonly domain: DomainName.DomainName };\n Resolved: { readonly candidate: Candidate; readonly provider: DnsProvider.Interface };\n SelectionRequired: { readonly candidates: ReadonlyArray<Candidate> };\n}>;\nexport const Outcome = Data.taggedEnum<Outcome>();\n\nexport interface Interface {\n readonly discover: (domain: DomainName.DomainName) => Effect.Effect<Outcome, DnsProvider.Error>;\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@domainkit/ZoneDiscovery\") {}\n\n/** Compose provider-account discovery sources without expanding the record-provider contract. */\nexport function make(sources: ReadonlyArray<Source>): Interface {\n return Service.of({\n discover: Effect.fn(\"ZoneDiscovery.discover\")(function* (domain) {\n for (const name of Zones.candidates(domain)) {\n const matches = deduplicate(\n (yield* Effect.forEach(\n sources,\n (source) =>\n source.listZones(name).pipe(\n Effect.map((zones) =>\n zones\n .filter((zone) => zone.name === name)\n .map((zone) => ({\n candidate: { ...zone, providerId: source.provider.id },\n provider: source.provider,\n })),\n ),\n ),\n { concurrency: \"unbounded\" },\n )).flat(),\n );\n const match = matches[0];\n if (matches.length === 1 && match !== undefined) {\n return Outcome.Resolved(match);\n }\n if (matches.length > 1) {\n return Outcome.SelectionRequired({\n candidates: matches.map(({ candidate }) => candidate),\n });\n }\n }\n return Outcome.NotFound({ domain });\n }),\n });\n}\n\nfunction deduplicate(\n matches: ReadonlyArray<{\n readonly candidate: Candidate;\n readonly provider: DnsProvider.Interface;\n }>,\n): ReadonlyArray<{\n readonly candidate: Candidate;\n readonly provider: DnsProvider.Interface;\n}> {\n const unique = new Map<string, (typeof matches)[number]>();\n for (const match of matches) {\n const key = [\n match.candidate.providerId,\n match.candidate.accountId,\n match.candidate.id,\n match.candidate.name,\n ].join(\":\");\n const existing = unique.get(key);\n if (existing === undefined) unique.set(key, match);\n }\n return [...unique.values()].sort((left, right) =>\n candidateKey(left.candidate).localeCompare(candidateKey(right.candidate)),\n );\n}\n\nfunction candidateKey(candidate: Candidate): string {\n return [candidate.name, candidate.providerId, candidate.accountId, candidate.id].join(\":\");\n}\n","import { Effect, Schema as S } from \"effect\";\n\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\nimport * as DomainName from \"./domain-name.ts\";\n\nexport const Type = S.Literals([\"A\", \"AAAA\", \"CNAME\", \"TXT\", \"MX\", \"CAA\", \"NS\", \"SRV\"]);\nexport type Type = typeof Type.Type;\n\nexport const RequirementMetadata = S.Struct({\n ownership: S.String.check(S.isMinLength(1)),\n provenance: S.String.check(S.isMinLength(1)),\n purpose: S.String.check(S.isMinLength(1)),\n});\nexport interface RequirementMetadata extends S.Schema.Type<typeof RequirementMetadata> {}\n\nconst CommonFields = {\n metadata: RequirementMetadata,\n name: DomainName.Schema,\n policy: S.Literals([\"exclusive\", \"append\"]),\n ttl: S.NullOr(S.Int.check(S.isBetween({ minimum: 60, maximum: 2_147_483_647 }))),\n};\n\nconst ExclusiveCommonFields = { ...CommonFields, policy: S.Literal(\"exclusive\") };\nconst Address = S.String.check(\n S.makeFilter((value) => (isIpv4(value) ? undefined : \"Expected an IPv4 address\")),\n);\nconst Ipv6Address = S.String.check(\n S.makeFilter((value) => (isIpv6(value) ? undefined : \"Expected an IPv6 address\")),\n);\nconst Port = S.Int.check(S.isBetween({ minimum: 0, maximum: 65_535 }));\nconst Priority = S.Int.check(S.isBetween({ minimum: 0, maximum: 65_535 }));\n\nexport const Schema = S.TaggedUnion({\n A: { ...CommonFields, address: Address },\n AAAA: { ...CommonFields, address: Ipv6Address },\n CNAME: { ...ExclusiveCommonFields, target: DomainName.Schema },\n TXT: { ...CommonFields, value: S.String.check(S.isMinLength(1)) },\n MX: { ...CommonFields, exchange: DomainName.Schema, priority: Priority },\n CAA: {\n ...CommonFields,\n flags: S.Int.check(S.isBetween({ minimum: 0, maximum: 255 })),\n tag: S.Literals([\"issue\", \"issuewild\", \"iodef\"]),\n value: S.String.check(S.isMinLength(1)),\n },\n NS: { ...CommonFields, target: DomainName.Schema },\n SRV: {\n ...CommonFields,\n port: Port,\n priority: Priority,\n target: DomainName.Schema,\n weight: Priority,\n },\n});\nexport const {\n A,\n AAAA: Aaaa,\n CAA: Caa,\n CNAME: Cname,\n MX: Mx,\n NS: Ns,\n SRV: Srv,\n TXT: Txt,\n} = Schema.cases;\nexport type DnsRecord = typeof Schema.Type;\nexport type Encoded = typeof Schema.Encoded;\n\n/** Provider state that DomainKit cannot create but must retain for safe reconciliation. */\nexport const Opaque = S.Struct({\n _tag: S.Literal(\"Opaque\"),\n name: S.String.check(S.isMinLength(1)),\n providerRecordId: S.NullOr(S.String),\n providerType: S.String.check(S.isMinLength(1)),\n});\nexport interface Opaque extends S.Schema.Type<typeof Opaque> {}\n\n/** Any DNS record observed through a provider, including non-portable record types. */\nexport const Observed = S.Union([Schema, Opaque]);\nexport type Observed = typeof Observed.Type;\n\nexport const decode = Effect.fn(\"DnsRecord.decode\")((input: unknown) =>\n S.decodeUnknownEffect(Schema)(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\n\nexport function parse(input: unknown): DnsRecord {\n try {\n return S.decodeUnknownSync(Schema)(input);\n } catch (cause) {\n throw new InvalidInputError({\n message: cause instanceof Error ? cause.message : String(cause),\n });\n }\n}\n\nexport function data(record: DnsRecord): Readonly<Record<string, number | string>> {\n switch (record._tag) {\n case \"A\":\n case \"AAAA\":\n return { address: record.address };\n case \"CNAME\":\n case \"NS\":\n return { target: record.target };\n case \"TXT\":\n return { value: record.value };\n case \"MX\":\n return { exchange: record.exchange, priority: record.priority };\n case \"CAA\":\n return { flags: record.flags, tag: record.tag, value: record.value };\n case \"SRV\":\n return {\n port: record.port,\n priority: record.priority,\n target: record.target,\n weight: record.weight,\n };\n }\n}\n\nexport function equals(left: DnsRecord, right: DnsRecord): boolean {\n return (\n left._tag === right._tag &&\n left.name === right.name &&\n JSON.stringify(data(left)) === JSON.stringify(data(right))\n );\n}\n\nfunction isIpv4(value: string): boolean {\n const parts = value.split(\".\");\n return (\n parts.length === 4 &&\n parts.every(\n (part) => /^\\d{1,3}$/.test(part) && Number(part) <= 255 && String(Number(part)) === part,\n )\n );\n}\n\nfunction isIpv6(value: string): boolean {\n try {\n return new URL(`http://[${value}]/`).hostname.startsWith(\"[\");\n } catch {\n return false;\n }\n}\n","import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport type * as DomainName from \"../domain/domain-name.ts\";\nimport type * as DnsRecord from \"../domain/dns-record.ts\";\n\nexport interface CreateResult {\n readonly providerRecordId: string | null;\n}\n\nexport const ErrorReason = Schema.Literals([\n \"authentication\",\n \"authorization\",\n \"conflict\",\n \"not_found\",\n \"rate_limit\",\n \"request\",\n \"response\",\n \"transport\",\n \"unsupported\",\n]);\nexport type ErrorReason = typeof ErrorReason.Type;\n\nexport class Error extends Schema.TaggedError<Error>()(\"ProviderError\", {\n cause: Schema.optionalKey(Schema.Unknown),\n code: Schema.optionalKey(Schema.Union([Schema.Number, Schema.String])),\n message: Schema.String,\n operation: Schema.String,\n providerId: Schema.String,\n reason: Schema.optionalKey(ErrorReason),\n retryAfterMs: Schema.optionalKey(Schema.Number),\n status: Schema.optionalKey(Schema.Number),\n}) {}\n\n/** The provider capability used by DNS planning, application, and verification. */\nexport interface Interface {\n readonly id: string;\n readonly createRecord: (\n zone: DomainName.DomainName,\n record: DnsRecord.DnsRecord,\n ) => Effect.Effect<CreateResult, Error>;\n readonly deleteRecord: (\n zone: DomainName.DomainName,\n providerRecordId: string,\n ) => Effect.Effect<void, Error>;\n readonly getRecord: (\n zone: DomainName.DomainName,\n providerRecordId: string,\n ) => Effect.Effect<DnsRecord.Observed | null, Error>;\n readonly listRecords: (\n zone: DomainName.DomainName,\n ) => Effect.Effect<ReadonlyArray<DnsRecord.Observed>, Error>;\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@domainkit/DnsProvider\") {}\n\n/** Minimal Promise-shaped provider contract for hosts that do not use Effect directly. */\nexport interface AsyncInterface {\n readonly id: string;\n readonly createRecord: (\n zone: DomainName.DomainName,\n record: DnsRecord.DnsRecord,\n ) => Promise<CreateResult>;\n readonly deleteRecord: (zone: DomainName.DomainName, providerRecordId: string) => Promise<void>;\n readonly getRecord: (\n zone: DomainName.DomainName,\n providerRecordId: string,\n ) => Promise<DnsRecord.Observed | null>;\n readonly listRecords: (zone: DomainName.DomainName) => Promise<ReadonlyArray<DnsRecord.Observed>>;\n}\n\nexport const fromAsync = (provider: AsyncInterface): Interface =>\n Service.of({\n id: provider.id,\n createRecord: Effect.fn(\"DnsProvider.createRecord\")((zone, record) =>\n Effect.tryPromise({\n try: () => provider.createRecord(zone, record),\n catch: (cause) => failure(provider, \"createRecord\", cause),\n }),\n ),\n deleteRecord: Effect.fn(\"DnsProvider.deleteRecord\")((zone, providerRecordId) =>\n Effect.tryPromise({\n try: () => provider.deleteRecord(zone, providerRecordId),\n catch: (cause) => failure(provider, \"deleteRecord\", cause),\n }),\n ),\n getRecord: Effect.fn(\"DnsProvider.getRecord\")((zone, providerRecordId) =>\n Effect.tryPromise({\n try: () => provider.getRecord(zone, providerRecordId),\n catch: (cause) => failure(provider, \"getRecord\", cause),\n }),\n ),\n listRecords: Effect.fn(\"DnsProvider.listRecords\")((zone) =>\n Effect.tryPromise({\n try: () => provider.listRecords(zone),\n catch: (cause) => failure(provider, \"listRecords\", cause),\n }),\n ),\n });\n\nexport const layerFromAsync = (provider: AsyncInterface): Layer.Layer<Service> =>\n Layer.succeed(Service, fromAsync(provider));\n\nexport const toAsync = (provider: Interface): AsyncInterface => ({\n id: provider.id,\n createRecord: (zone, record) => Effect.runPromise(provider.createRecord(zone, record)),\n deleteRecord: (zone, providerRecordId) =>\n Effect.runPromise(provider.deleteRecord(zone, providerRecordId)),\n getRecord: (zone, providerRecordId) =>\n Effect.runPromise(provider.getRecord(zone, providerRecordId)),\n listRecords: (zone) => Effect.runPromise(provider.listRecords(zone)),\n});\n\nfunction failure(provider: AsyncInterface, operation: string, cause: unknown): Error {\n return cause instanceof Error\n ? cause\n : new Error({\n cause,\n message: cause instanceof globalThis.Error ? cause.message : String(cause),\n operation,\n providerId: provider.id,\n });\n}\n","import { Effect, Schema as S } from \"effect\";\n\nimport * as DomainName from \"../domain/domain-name.ts\";\nimport * as DnsRecord from \"../domain/dns-record.ts\";\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\n\nexport const Operation = S.TaggedUnion({\n create: {\n id: S.String,\n requirement: DnsRecord.Schema,\n },\n noop: {\n id: S.String,\n requirement: DnsRecord.Schema,\n ttlDrift: S.Boolean,\n },\n conflict: {\n existing: S.Array(DnsRecord.Observed),\n id: S.String,\n reason: S.String,\n requirement: DnsRecord.Schema,\n },\n});\nexport type Operation = typeof Operation.Type;\n\nexport const Schema = S.Struct({\n digest: S.String,\n operations: S.Array(Operation),\n providerId: S.String,\n version: S.Literal(\"domainkit.dns-plan.v1\"),\n zone: DomainName.Schema,\n});\nexport interface DnsPlan extends S.Schema.Type<typeof Schema> {}\n\nexport const Authorization = S.Struct({\n allowPartial: S.Boolean,\n operationIds: S.Array(S.String),\n planDigest: S.String,\n version: S.Literal(\"domainkit.plan-authorization.v1\"),\n});\nexport interface PlanAuthorization extends S.Schema.Type<typeof Authorization> {}\n\nexport const Receipt = S.Struct({\n appliedAt: S.DateFromString,\n operations: S.Array(\n S.Struct({\n operationId: S.String,\n providerRecordId: S.NullOr(S.String),\n }),\n ),\n planDigest: S.String,\n providerId: S.String,\n status: S.Literals([\"complete\", \"partial\"]),\n version: S.Literal(\"domainkit.apply-receipt.v1\"),\n zone: DomainName.Schema,\n});\nexport interface ApplyReceipt extends S.Schema.Type<typeof Receipt> {}\n\nexport const decode = Effect.fn(\"DnsPlan.decode\")((input: unknown) =>\n S.decodeUnknownEffect(Schema)(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\n\nexport const encode = S.encodeSync(Schema);\nexport const decodeReceipt = Effect.fn(\"DnsPlan.decodeReceipt\")((input: unknown) =>\n S.decodeUnknownEffect(Receipt)(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\nexport const encodeReceipt = S.encodeSync(Receipt);\n","import { Cause, Clock, Crypto, Data, Effect, Schema as S } from \"effect\";\n\nimport * as DomainName from \"../domain/domain-name.ts\";\nimport * as DnsRecord from \"../domain/dns-record.ts\";\nimport * as ZoneDiscovery from \"../discovery/zone-discovery.ts\";\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\nimport * as DnsProvider from \"../provider/provider.ts\";\nimport { CryptoError, sha256Encoded, stringify } from \"./canonical-json.ts\";\nimport * as DnsPlan from \"./types.ts\";\n\nconst UnsignedPlan = S.Struct({\n operations: S.Array(DnsPlan.Operation),\n providerId: S.String,\n version: S.Literal(\"domainkit.dns-plan.v1\"),\n zone: DomainName.Schema,\n});\n\nconst RequirementDigest = S.Struct({ requirement: DnsRecord.Schema });\n\nexport class ConflictError extends S.TaggedError<ConflictError>()(\"PlanConflictError\", {\n operationIds: S.Array(S.String),\n}) {}\n\nexport class AuthorizationError extends S.TaggedError<AuthorizationError>()(\"AuthorizationError\", {\n message: S.String,\n}) {}\n\nexport class StaleError extends S.TaggedError<StaleError>()(\"StalePlanError\", {\n approvedPlanDigest: S.String,\n currentPlanDigest: S.String,\n}) {}\n\nexport class PartialApplyError extends S.TaggedError<PartialApplyError>()(\"PartialApplyError\", {\n causeTag: S.Literals([\n \"CryptoError\",\n \"InvalidInputError\",\n \"Interrupted\",\n \"ProviderError\",\n \"StalePlanError\",\n ]),\n failedOperationId: S.String,\n message: S.String,\n receipt: DnsPlan.Receipt,\n}) {}\n\nexport type Target = Data.TaggedEnum<{\n DiscoverFromDomain: { readonly domain: string };\n ExactZone: { readonly zone: string };\n}>;\nexport const Target = Data.taggedEnum<Target>();\n\nexport type CreateResult = Data.TaggedEnum<{\n NotFound: { readonly domain: DomainName.DomainName };\n Resolved: {\n readonly candidate: ZoneDiscovery.Candidate | null;\n readonly plan: DnsPlan.DnsPlan;\n };\n SelectionRequired: { readonly candidates: ReadonlyArray<ZoneDiscovery.Candidate> };\n}>;\nexport const CreateResult = Data.taggedEnum<CreateResult>();\nexport type ResolvedCreateResult = Extract<CreateResult, { readonly _tag: \"Resolved\" }>;\n\nexport interface CreateInput {\n readonly requirements: ReadonlyArray<DnsRecord.Encoded | DnsRecord.DnsRecord>;\n readonly target: Target;\n}\nexport type ExactCreateInput = Omit<CreateInput, \"target\"> & {\n readonly target: Extract<Target, { readonly _tag: \"ExactZone\" }>;\n};\nexport type DiscoverCreateInput = Omit<CreateInput, \"target\"> & {\n readonly target: Extract<Target, { readonly _tag: \"DiscoverFromDomain\" }>;\n};\n\nexport interface ApplyInput {\n readonly authorization: DnsPlan.PlanAuthorization;\n readonly plan: DnsPlan.DnsPlan;\n}\n\nexport type CreateError = InvalidInputError | DnsProvider.Error | CryptoError;\nexport type AuthorizeError = AuthorizationError | CryptoError;\nexport type ApplyError =\n | InvalidInputError\n | DnsProvider.Error\n | CryptoError\n | AuthorizationError\n | ConflictError\n | StaleError\n | PartialApplyError;\n\n/** Builds a deterministic DNS plan through an exact or discoverable authoritative-zone target. */\nexport function create(\n input: ExactCreateInput,\n): Effect.Effect<ResolvedCreateResult, CreateError, Crypto.Crypto | DnsProvider.Service>;\nexport function create(\n input: DiscoverCreateInput,\n): Effect.Effect<CreateResult, CreateError, Crypto.Crypto | ZoneDiscovery.Service>;\nexport function create(\n input: CreateInput,\n): Effect.Effect<\n CreateResult,\n CreateError,\n Crypto.Crypto | DnsProvider.Service | ZoneDiscovery.Service\n> {\n const target = input.target;\n if (target._tag === \"ExactZone\") {\n return Effect.gen(function* () {\n const provider = yield* DnsProvider.Service;\n const zone = yield* DomainName.decode(target.zone);\n return CreateResult.Resolved({\n candidate: null,\n plan: yield* planAgainst(provider, zone, input.requirements),\n });\n }).pipe(Effect.withSpan(\"Provisioning.create\"));\n }\n return Effect.gen(function* () {\n const discovery = yield* ZoneDiscovery.Service;\n const domain = yield* DomainName.decode(target.domain);\n const outcome = yield* discovery.discover(domain);\n switch (outcome._tag) {\n case \"NotFound\":\n return CreateResult.NotFound({ domain: outcome.domain });\n case \"SelectionRequired\":\n return CreateResult.SelectionRequired({ candidates: outcome.candidates });\n case \"Resolved\":\n return CreateResult.Resolved({\n candidate: outcome.candidate,\n plan: yield* planAgainst(outcome.provider, outcome.candidate.name, input.requirements),\n });\n }\n }).pipe(Effect.withSpan(\"Provisioning.create\"));\n}\n\nconst planAgainst = Effect.fn(\"Provisioning.planAgainst\")(function* (\n provider: DnsProvider.Interface,\n zone: DomainName.DomainName,\n inputs: ReadonlyArray<DnsRecord.Encoded | DnsRecord.DnsRecord>,\n) {\n const requirements = (yield* Effect.forEach(inputs, DnsRecord.decode, {\n concurrency: \"unbounded\",\n })).sort(compareRecords);\n const existing = [...(yield* provider.listRecords(zone))].sort(compareRecords);\n const { operations } = yield* Effect.reduce(\n requirements,\n (): PlanningState => ({ operations: [], projected: existing }),\n (state, requirement) =>\n reconcileRequirement(requirement, state.projected).pipe(\n Effect.map((operation) => ({\n operations: [...state.operations, operation],\n projected:\n operation._tag === \"create\"\n ? [...state.projected, operation.requirement].sort(compareRecords)\n : state.projected,\n })),\n ),\n );\n const unsigned: S.Schema.Type<typeof UnsignedPlan> = {\n operations,\n providerId: provider.id,\n version: \"domainkit.dns-plan.v1\",\n zone,\n };\n return { ...unsigned, digest: yield* sha256Encoded(UnsignedPlan, unsigned) };\n});\n\ninterface PlanningState {\n readonly operations: ReadonlyArray<DnsPlan.Operation>;\n readonly projected: ReadonlyArray<DnsRecord.Observed>;\n}\n\n/** Authorizes all or a selected subset of create operations in a digest-bound plan. */\nexport const authorize = Effect.fn(\"Provisioning.authorize\")(function* (\n plan: DnsPlan.DnsPlan,\n operationIds?: ReadonlyArray<string>,\n options: { readonly allowPartial?: boolean } = {},\n) {\n yield* validate(plan);\n const createIds = plan.operations\n .filter((operation) => operation._tag === \"create\")\n .map(({ id }) => id);\n const selected = [...new Set(operationIds ?? createIds)].sort();\n const unknown = selected.filter((id) => !createIds.includes(id));\n if (unknown.length > 0) {\n return yield* new AuthorizationError({\n message: `Unknown operation IDs: ${unknown.join(\", \")}`,\n });\n }\n if (!options.allowPartial && selected.length !== createIds.length) {\n return yield* new AuthorizationError({\n message: \"Partial authorization requires allowPartial\",\n });\n }\n return {\n allowPartial: options.allowPartial ?? false,\n operationIds: selected,\n planDigest: plan.digest,\n version: \"domainkit.plan-authorization.v1\" as const,\n };\n});\n\n/** Applies approved creates sequentially after full and per-operation revalidation. */\nexport const apply = Effect.fn(\"Provisioning.apply\")(function* (input: ApplyInput) {\n const { authorization, plan } = input;\n const provider = yield* DnsProvider.Service;\n yield* validate(plan);\n if (authorization.planDigest !== plan.digest) {\n return yield* new AuthorizationError({\n message: \"Authorization belongs to a different plan\",\n });\n }\n if (provider.id !== plan.providerId) {\n return yield* new AuthorizationError({\n message: \"Provider does not match the approved plan\",\n });\n }\n const conflicts = plan.operations.filter((operation) => operation._tag === \"conflict\");\n if (conflicts.length > 0) {\n return yield* new ConflictError({\n operationIds: conflicts.map(({ id }) => id),\n });\n }\n\n const creates = plan.operations.filter(DnsPlan.Operation.guards.create);\n const approved = new Set(authorization.operationIds);\n const unknown = authorization.operationIds.filter(\n (id) => !creates.some((operation) => operation.id === id),\n );\n if (unknown.length > 0) {\n return yield* new AuthorizationError({\n message: `Authorization contains unknown operations: ${unknown.join(\", \")}`,\n });\n }\n if (!authorization.allowPartial && creates.some(({ id }) => !approved.has(id))) {\n return yield* new AuthorizationError({\n message: \"Authorization does not cover every create operation\",\n });\n }\n\n const currentPlan = yield* planAgainst(\n provider,\n plan.zone,\n plan.operations.map(({ requirement }) => requirement),\n );\n if (currentPlan.digest !== plan.digest) {\n return yield* new StaleError({\n approvedPlanDigest: plan.digest,\n currentPlanDigest: currentPlan.digest,\n });\n }\n\n const operations: Array<{\n operationId: string;\n providerRecordId: string | null;\n }> = [];\n for (const operation of creates) {\n if (!approved.has(operation.id)) continue;\n yield* Effect.gen(function* () {\n yield* assertStillCreatable(plan, operation);\n const result = yield* provider.createRecord(plan.zone, operation.requirement);\n operations.push({\n operationId: operation.id,\n providerRecordId: result.providerRecordId,\n });\n }).pipe(\n Effect.catch((failure): Effect.Effect<never, CreateError | StaleError | PartialApplyError> =>\n operations.length === 0\n ? Effect.fail(failure)\n : makeReceipt(input, operations, \"partial\").pipe(\n Effect.flatMap((receipt) =>\n Effect.fail(\n new PartialApplyError({\n causeTag: failure._tag,\n failedOperationId: operation.id,\n message: failureMessage(failure),\n receipt,\n }),\n ),\n ),\n ),\n ),\n Effect.catchCause((cause) => {\n if (!Cause.hasInterruptsOnly(cause) || operations.length === 0) {\n return Effect.failCause(cause);\n }\n return makeReceipt(input, operations, \"partial\").pipe(\n Effect.flatMap((receipt) =>\n Effect.fail(\n new PartialApplyError({\n causeTag: \"Interrupted\",\n failedOperationId: operation.id,\n message: \"DNS apply was interrupted after confirmed writes\",\n receipt,\n }),\n ),\n ),\n );\n }),\n );\n }\n return yield* makeReceipt(input, operations, \"complete\");\n});\n\nexport function renderManualInstructions(plan: DnsPlan.DnsPlan): ReadonlyArray<string> {\n return plan.operations.map((operation) => {\n const record = operation.requirement;\n const data = Object.entries(DnsRecord.data(record))\n .map(([key, value]) => `${key}=${value}`)\n .join(\" \");\n return `${operation._tag.toUpperCase()} ${record._tag} ${record.name} ${data}`.trim();\n });\n}\n\nfunction makeReceipt(\n input: ApplyInput,\n operations: ReadonlyArray<{\n readonly operationId: string;\n readonly providerRecordId: string | null;\n }>,\n status: \"complete\" | \"partial\",\n): Effect.Effect<DnsPlan.ApplyReceipt> {\n return Clock.currentTimeMillis.pipe(\n Effect.map((now) => ({\n appliedAt: new Date(now),\n operations,\n planDigest: input.plan.digest,\n providerId: input.plan.providerId,\n status,\n version: \"domainkit.apply-receipt.v1\" as const,\n zone: input.plan.zone,\n })),\n );\n}\n\nfunction assertStillCreatable(\n plan: DnsPlan.DnsPlan,\n operation: Extract<DnsPlan.Operation, { readonly _tag: \"create\" }>,\n): Effect.Effect<void, CreateError | StaleError, DnsProvider.Service | Crypto.Crypto> {\n return DnsProvider.Service.pipe(\n Effect.flatMap((provider) => planAgainst(provider, plan.zone, [operation.requirement])),\n Effect.flatMap((currentPlan) => {\n const currentOperation = currentPlan.operations[0];\n return currentOperation?._tag === \"create\" && currentOperation.id === operation.id\n ? Effect.void\n : Effect.fail(\n new StaleError({\n approvedPlanDigest: plan.digest,\n currentPlanDigest: currentPlan.digest,\n }),\n );\n }),\n );\n}\n\nfunction reconcileRequirement(\n requirement: DnsRecord.DnsRecord,\n allExisting: ReadonlyArray<DnsRecord.Observed>,\n): Effect.Effect<DnsPlan.Operation, CryptoError, Crypto.Crypto> {\n return Effect.gen(function* () {\n const sameName = allExisting.filter((record) => record.name === requirement.name);\n const sameSet = sameName.filter(\n (record): record is DnsRecord.DnsRecord =>\n record._tag !== \"Opaque\" && record._tag === requirement._tag,\n );\n const exact = sameSet.find((record) => DnsRecord.equals(record, requirement));\n const id = yield* sha256Encoded(RequirementDigest, { requirement });\n if (exact !== undefined) {\n return {\n _tag: \"noop\",\n id,\n requirement,\n ttlDrift: exact.ttl !== requirement.ttl,\n };\n }\n const cnameConflict =\n sameName.length > 0 &&\n (requirement._tag === \"CNAME\" || sameName.some((record) => record._tag === \"CNAME\"));\n if (cnameConflict) {\n return {\n _tag: \"conflict\",\n existing: sameName,\n id,\n reason: \"CNAME records cannot coexist with other records at the same name\",\n requirement,\n };\n }\n if (\n sameSet.length > 0 &&\n (requirement.policy === \"exclusive\" || sameSet.some(({ policy }) => policy === \"exclusive\"))\n ) {\n return {\n _tag: \"conflict\",\n existing: sameSet,\n id,\n reason: \"The exclusive record set already contains incompatible data\",\n requirement,\n };\n }\n return { _tag: \"create\", id, requirement };\n });\n}\n\nexport function validate(\n plan: DnsPlan.DnsPlan,\n): Effect.Effect<void, AuthorizeError, Crypto.Crypto> {\n const unsigned: S.Schema.Type<typeof UnsignedPlan> = {\n operations: plan.operations,\n providerId: plan.providerId,\n version: plan.version,\n zone: plan.zone,\n };\n return sha256Encoded(UnsignedPlan, unsigned).pipe(\n Effect.flatMap((digest) =>\n digest === plan.digest\n ? Effect.void\n : Effect.fail(\n new AuthorizationError({\n message: \"Plan digest does not match its contents\",\n }),\n ),\n ),\n );\n}\n\nfunction failureMessage(failure: CreateError | StaleError): string {\n return failure._tag === \"StalePlanError\"\n ? \"DNS state changed while applying the approved plan\"\n : failure.message;\n}\n\nfunction compareRecords(left: DnsRecord.Observed, right: DnsRecord.Observed): number {\n const encode = S.encodeSync(DnsRecord.Observed);\n const toJson = S.decodeUnknownSync(S.Json);\n const leftJson = stringify(toJson(encode(left)));\n const rightJson = stringify(toJson(encode(right)));\n return leftJson < rightJson ? -1 : leftJson > rightJson ? 1 : 0;\n}\n","import { Clock, Crypto, Effect, Schema as S } from \"effect\";\n\nimport * as DomainName from \"../domain/domain-name.ts\";\nimport * as DnsRecord from \"../domain/dns-record.ts\";\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\nimport * as DnsProvider from \"../provider/provider.ts\";\nimport { CryptoError, sha256Encoded } from \"./canonical-json.ts\";\nimport * as Provisioning from \"./plan.ts\";\nimport * as DnsPlan from \"./types.ts\";\n\nexport const Operation = S.Struct({\n id: S.String,\n providerRecordId: S.String,\n record: DnsRecord.Schema,\n});\nexport interface Operation extends S.Schema.Type<typeof Operation> {}\n\nconst UnsignedPlan = S.Struct({\n createdAt: S.DateFromString,\n expiresAt: S.DateFromString,\n operations: S.Array(Operation),\n providerId: S.String,\n sourcePlanDigest: S.String,\n version: S.Literal(\"domainkit.deletion-plan.v1\"),\n zone: DomainName.Schema,\n});\n\nexport const Plan = S.Struct({ ...UnsignedPlan.fields, digest: S.String });\nexport interface Plan extends S.Schema.Type<typeof Plan> {}\n\nexport const Authorization = S.Struct({\n operationIds: S.Array(S.String),\n planDigest: S.String,\n version: S.Literal(\"domainkit.deletion-authorization.v1\"),\n});\nexport interface Authorization extends S.Schema.Type<typeof Authorization> {}\n\nexport const Receipt = S.Struct({\n deletedAt: S.DateFromString,\n operations: S.Array(S.Struct({ operationId: S.String, providerRecordId: S.String })),\n planDigest: S.String,\n providerId: S.String,\n status: S.Literals([\"complete\", \"partial\"]),\n version: S.Literal(\"domainkit.deletion-receipt.v1\"),\n zone: DomainName.Schema,\n});\nexport interface Receipt extends S.Schema.Type<typeof Receipt> {}\n\nexport class Error extends S.TaggedError<Error>()(\"UnsafeDeletionError\", {\n message: S.String,\n operationId: S.optionalKey(S.String),\n}) {}\n\nexport class PartialError extends S.TaggedError<PartialError>()(\"PartialDeletionError\", {\n failedOperationId: S.String,\n message: S.String,\n receipt: Receipt,\n}) {}\n\nexport interface CreateInput {\n readonly plan: DnsPlan.DnsPlan;\n readonly receipt: DnsPlan.ApplyReceipt;\n readonly ttlMs?: number;\n}\n\n/** Build a fresh deletion plan only from records proven by a prior create receipt. */\nexport const create = Effect.fn(\"Deletion.create\")(function* (input: CreateInput) {\n const provider = yield* DnsProvider.Service;\n yield* Provisioning.validate(input.plan);\n if (\n input.receipt.planDigest !== input.plan.digest ||\n input.receipt.providerId !== input.plan.providerId ||\n input.receipt.zone !== input.plan.zone\n ) {\n return yield* new Error({ message: \"Create receipt does not belong to the source plan\" });\n }\n if (provider.id !== input.plan.providerId) {\n return yield* new Error({ message: \"Provider does not match the source receipt\" });\n }\n const operations = yield* Effect.forEach(input.receipt.operations, (applied) =>\n Effect.gen(function* () {\n const source = input.plan.operations.find(\n (operation) => operation._tag === \"create\" && operation.id === applied.operationId,\n );\n if (source === undefined || source._tag !== \"create\") {\n return yield* new Error({\n message: \"Receipt operation is not a created source record\",\n operationId: applied.operationId,\n });\n }\n if (applied.providerRecordId === null) {\n return yield* new Error({\n message: \"Provider record ID is required for safe deletion\",\n operationId: applied.operationId,\n });\n }\n yield* assertExact(\n provider,\n input.plan.zone,\n applied.providerRecordId,\n source.requirement,\n source.id,\n );\n return {\n id: source.id,\n providerRecordId: applied.providerRecordId,\n record: source.requirement,\n };\n }),\n );\n const now = yield* Clock.currentTimeMillis;\n const unsigned: S.Schema.Type<typeof UnsignedPlan> = {\n createdAt: new Date(now),\n expiresAt: new Date(now + (input.ttlMs ?? 15 * 60_000)),\n operations,\n providerId: input.plan.providerId,\n sourcePlanDigest: input.plan.digest,\n version: \"domainkit.deletion-plan.v1\",\n zone: input.plan.zone,\n };\n return { ...unsigned, digest: yield* sha256Encoded(UnsignedPlan, unsigned) };\n});\n\n/** Produce a separate digest-bound consent artifact for destructive operations. */\nexport const authorize = Effect.fn(\"Deletion.authorize\")(function* (\n plan: Plan,\n operationIds?: ReadonlyArray<string>,\n) {\n yield* validate(plan);\n const selected = [...new Set(operationIds ?? plan.operations.map(({ id }) => id))].sort();\n const unknown = selected.filter(\n (id) => !plan.operations.some((operation) => operation.id === id),\n );\n if (unknown.length > 0) {\n return yield* new Error({ message: `Unknown deletion operation IDs: ${unknown.join(\", \")}` });\n }\n return {\n operationIds: selected,\n planDigest: plan.digest,\n version: \"domainkit.deletion-authorization.v1\" as const,\n };\n});\n\n/** Re-read every approved record before the first delete, then delete by provider record ID. */\nexport const apply = Effect.fn(\"Deletion.apply\")(function* (input: {\n readonly authorization: Authorization;\n readonly plan: Plan;\n readonly priorReceipt?: Receipt;\n}) {\n const provider = yield* DnsProvider.Service;\n yield* validate(input.plan);\n if (input.authorization.planDigest !== input.plan.digest) {\n return yield* new Error({ message: \"Deletion authorization belongs to a different plan\" });\n }\n if (provider.id !== input.plan.providerId) {\n return yield* new Error({ message: \"Provider does not match the deletion plan\" });\n }\n const now = yield* Clock.currentTimeMillis;\n if (input.plan.expiresAt <= new Date(now)) {\n return yield* new Error({ message: \"Deletion plan has expired\" });\n }\n const selected = input.plan.operations.filter(({ id }) =>\n input.authorization.operationIds.includes(id),\n );\n if (selected.length !== input.authorization.operationIds.length) {\n return yield* new Error({ message: \"Deletion authorization contains unknown operations\" });\n }\n const previouslyDeleted = yield* validatePriorReceipt(input.plan, input.priorReceipt);\n const completedIds = new Set(previouslyDeleted.map(({ operationId }) => operationId));\n if (\n previouslyDeleted.some(\n ({ operationId }) => !input.authorization.operationIds.includes(operationId),\n )\n ) {\n return yield* new Error({ message: \"Prior receipt contains an unauthorized operation\" });\n }\n const remaining = selected.filter(({ id }) => !completedIds.has(id));\n yield* Effect.forEach(remaining, (operation) =>\n assertExact(\n provider,\n input.plan.zone,\n operation.providerRecordId,\n operation.record,\n operation.id,\n ),\n );\n\n const deleted: Array<{ operationId: string; providerRecordId: string }> = [...previouslyDeleted];\n for (const operation of remaining) {\n const failure = yield* Effect.gen(function* () {\n yield* assertExact(\n provider,\n input.plan.zone,\n operation.providerRecordId,\n operation.record,\n operation.id,\n );\n yield* provider.deleteRecord(input.plan.zone, operation.providerRecordId);\n deleted.push({ operationId: operation.id, providerRecordId: operation.providerRecordId });\n }).pipe(Effect.match({ onFailure: (cause) => cause, onSuccess: () => null }));\n if (failure !== null) {\n if (deleted.length === 0) return yield* failure;\n return yield* new PartialError({\n failedOperationId: operation.id,\n message: failure.message,\n receipt: yield* makeReceipt(input.plan, deleted, \"partial\"),\n });\n }\n }\n return yield* makeReceipt(input.plan, deleted, \"complete\");\n});\n\nexport function validate(plan: Plan): Effect.Effect<void, Error | CryptoError, Crypto.Crypto> {\n const unsigned: S.Schema.Type<typeof UnsignedPlan> = {\n createdAt: plan.createdAt,\n expiresAt: plan.expiresAt,\n operations: plan.operations,\n providerId: plan.providerId,\n sourcePlanDigest: plan.sourcePlanDigest,\n version: plan.version,\n zone: plan.zone,\n };\n return sha256Encoded(UnsignedPlan, unsigned).pipe(\n Effect.flatMap((digest) =>\n digest === plan.digest\n ? Effect.void\n : Effect.fail(new Error({ message: \"Deletion plan digest does not match its contents\" })),\n ),\n );\n}\n\nfunction validatePriorReceipt(\n plan: Plan,\n receipt: Receipt | undefined,\n): Effect.Effect<ReadonlyArray<{ operationId: string; providerRecordId: string }>, Error> {\n if (receipt === undefined) return Effect.succeed([]);\n if (\n receipt.planDigest !== plan.digest ||\n receipt.providerId !== plan.providerId ||\n receipt.zone !== plan.zone ||\n receipt.status !== \"partial\"\n ) {\n return Effect.fail(\n new Error({ message: \"Prior receipt does not belong to this deletion plan\" }),\n );\n }\n for (const completed of receipt.operations) {\n const operation = plan.operations.find(({ id }) => id === completed.operationId);\n if (operation === undefined || operation.providerRecordId !== completed.providerRecordId) {\n return Effect.fail(\n new Error({ message: \"Prior receipt operation does not match the deletion plan\" }),\n );\n }\n }\n return Effect.succeed([...receipt.operations]);\n}\n\nfunction assertExact(\n provider: DnsProvider.Interface,\n zone: DomainName.DomainName,\n providerRecordId: string,\n expected: DnsRecord.DnsRecord,\n operationId: string,\n): Effect.Effect<void, Error | DnsProvider.Error> {\n return provider.getRecord(zone, providerRecordId).pipe(\n Effect.flatMap((observed) =>\n observed !== null && observed._tag !== \"Opaque\" && DnsRecord.equals(observed, expected)\n ? Effect.void\n : Effect.fail(\n new Error({\n message:\n observed === null\n ? \"Created record no longer exists\"\n : \"Created record content no longer matches its receipt\",\n operationId,\n }),\n ),\n ),\n );\n}\n\nfunction makeReceipt(\n plan: Plan,\n operations: ReadonlyArray<{ readonly operationId: string; readonly providerRecordId: string }>,\n status: \"complete\" | \"partial\",\n): Effect.Effect<Receipt> {\n return Clock.currentTimeMillis.pipe(\n Effect.map((now) => ({\n deletedAt: new Date(now),\n operations,\n planDigest: plan.digest,\n providerId: plan.providerId,\n status,\n version: \"domainkit.deletion-receipt.v1\" as const,\n zone: plan.zone,\n })),\n );\n}\n\nexport type CreateError =\n | Error\n | InvalidInputError\n | Provisioning.AuthorizationError\n | DnsProvider.Error\n | CryptoError;\nexport type ApplyError = Error | PartialError | DnsProvider.Error | CryptoError;\nexport type Requirements = DnsProvider.Service | Crypto.Crypto;\n","import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport * as DomainName from \"../domain/domain-name.ts\";\nimport * as DnsRecord from \"../domain/dns-record.ts\";\n\nexport interface Query {\n readonly name: DomainName.DomainName;\n readonly signal?: AbortSignal;\n readonly type: DnsRecord.Type;\n}\n\nexport const Answer = Schema.Struct({\n data: Schema.String,\n name: DomainName.Schema,\n ttl: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n type: DnsRecord.Type,\n});\nexport interface Answer extends Schema.Schema.Type<typeof Answer> {}\n\nexport const Resolution = Schema.TaggedUnion({\n answer: { answers: Schema.Array(Answer) },\n nodata: {},\n});\nexport type Resolution = typeof Resolution.Type;\n\nexport class Error extends Schema.TaggedError<Error>()(\"ResolverError\", {\n cause: Schema.optionalKey(Schema.Unknown),\n message: Schema.String,\n reason: Schema.Literals([\"response\", \"timeout\", \"transport\"]),\n}) {}\n\nexport interface Interface {\n readonly resolve: (query: Query) => Effect.Effect<Resolution, Error>;\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\"@domainkit/DnsResolver\") {}\n\nexport type AsyncResolution =\n | Resolution\n | { readonly _tag: \"timeout\" }\n | { readonly _tag: \"failure\"; readonly message: string };\n\nexport interface AsyncInterface {\n readonly resolve: (query: Query) => Promise<AsyncResolution>;\n}\n\nexport const layerFromAsync = (resolver: AsyncInterface): Layer.Layer<Service> =>\n Layer.succeed(Service, {\n resolve: Effect.fn(\"DnsResolver.resolve\")((query) =>\n Effect.tryPromise({\n try: () => resolver.resolve(query),\n catch: (cause) =>\n new Error({\n cause,\n message: cause instanceof globalThis.Error ? cause.message : String(cause),\n reason: \"transport\",\n }),\n }).pipe(\n Effect.flatMap((resolution) => {\n switch (resolution._tag) {\n case \"answer\":\n case \"nodata\":\n return Effect.succeed(resolution);\n case \"timeout\":\n return Effect.fail(new Error({ message: \"DNS query timed out\", reason: \"timeout\" }));\n case \"failure\":\n return Effect.fail(new Error({ message: resolution.message, reason: \"transport\" }));\n }\n }),\n ),\n ),\n });\n\nexport const toAsync = (resolver: Interface): AsyncInterface => ({\n resolve: (query) =>\n Effect.runPromise(\n resolver.resolve(query).pipe(\n Effect.match({\n onFailure: (failure): AsyncResolution =>\n failure.reason === \"timeout\"\n ? { _tag: \"timeout\" }\n : { _tag: \"failure\", message: failure.message },\n onSuccess: (resolution) => resolution,\n }),\n ),\n ),\n});\n"],"mappings":";;;;;;AAKA,SAAgB,WAAW,OAAqD;CAC9E,MAAM,SAASA,QAAiB,KAAK;CACrC,MAAM,cAAc,UAAU,QAAQ,EAAE,qBAAqB,KAAK,CAAC;CACnE,IAAI,gBAAgB,MAClB,MAAM,IAAIC,QAAkB,EAAE,SAAS,8CAA8C,CAAC;CAExF,MAAM,SAAS,OAAO,MAAM,GAAG;CAC/B,MAAM,oBAAoB,YAAY,MAAM,GAAG,CAAC,CAAC;CACjD,MAAM,SAAuC,CAAC;CAC9C,KAAK,IAAI,QAAQ,GAAG,SAAS,OAAO,SAAS,mBAAmB,SAAS,GACvE,OAAO,KAAKD,QAAiB,OAAO,MAAM,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;CAE7D,OAAO;AACT;;;;;;;;;;ACVA,MAAa,YAAY,OAAO,OAAO;CACrC,WAAW,OAAO;CAClB,IAAI,OAAO;CACX,MAAME;CACN,aAAa,OAAO,MAAMA,QAAa;CACvC,YAAY,OAAO;CACnB,QAAQ,OAAO,SAAS;EAAC;EAAU;EAAW;CAAS,CAAC;AAC1D,CAAC;AAeD,MAAa,UAAU,KAAK,WAAoB;AAMhD,IAAaC,YAAb,cAA6B,QAAQ,QAA4B,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC;;AAGhG,SAAgB,KAAK,SAA2C;CAC9D,OAAOA,UAAQ,GAAG,EAChB,UAAU,OAAO,GAAG,wBAAwB,CAAC,CAAC,WAAW,QAAQ;EAC/D,KAAK,MAAM,QAAQC,WAAiB,MAAM,GAAG;GAC3C,MAAM,UAAU,aACb,OAAO,OAAO,QACb,UACC,WACC,OAAO,UAAU,IAAI,CAAC,CAAC,KACrB,OAAO,KAAK,UACV,MACG,QAAQ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AClC,KAAK,WACH,OAAO,OAAO,KAAK,IAAIA,QAAM;GAAE,SAAS;GAAuB,QAAQ;EAAU,CAAC,CAAC;EACrF,KAAK,WACH,OAAO,OAAO,KAAK,IAAIA,QAAM;GAAE,SAAS,WAAW;GAAS,QAAQ;EAAY,CAAC,CAAC;CACtF;AACF,CAAC,CACH,CACF,EACF,CAAC;AAEH,MAAa,WAAW,cAAyC,EAC/D,UAAU,UACR,OAAO,WACL,SAAS,QAAQ,KAAK,CAAC,CAAC,KACtB,OAAO,MAAM;CACX,YAAY,YACV,QAAQ,WAAW,YACf,EAAE,MAAM,UAAU,IAClB;EAAE,MAAM;EAAW,SAAS,QAAQ;CAAQ;CAClD,YAAY,eAAe;AAC7B,CAAC,CACH,CACF,EACJ"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { O as Service, a as Continuation, l as InteractiveFlow } from "./connect-Db830jad.mjs";
|
|
2
|
+
import "./connection-api-B__0M3PA.mjs";
|
|
3
|
+
import { i as AsyncInterface, t as InteractiveFlow$1 } from "./connection-DuYDgWir.mjs";
|
|
4
|
+
import { Context, Crypto, Effect, Layer, Schema } from "effect";
|
|
5
|
+
declare namespace index_d_exports {
|
|
6
|
+
export { AsyncConnectionPolicy, AsyncIdentity, AsyncInteractiveFlow, AsyncInteractiveProvider, AsyncPendingAuthorizations, AuthorizationReuseInput, Configuration, ConnectionPolicy, ConnectionPolicyInterface, CreateDomainKitOptions, DEFAULT_BASE_PATH, Error, Handler, Identity, IdentityInterface, InteractiveFlowInput, InteractiveProvider, Interface, PendingAuthorization, PendingAuthorizationContext, PendingAuthorizations, PendingAuthorizationsInterface, Principal, Providers, ProvidersInterface, WebHandler, createDomainKit, layer, make, providersLayer, toWebHandler };
|
|
7
|
+
}
|
|
8
|
+
declare const DEFAULT_BASE_PATH = "/api/domainkit";
|
|
9
|
+
declare const Error_base: Schema.Class<Error, Schema.TaggedStruct<"DomainKitServerError", {
|
|
10
|
+
readonly category: Schema.Literals<readonly ["authentication", "authorization", "configuration", "provider", "request", "storage"]>;
|
|
11
|
+
readonly message: Schema.String;
|
|
12
|
+
readonly operation: Schema.String;
|
|
13
|
+
readonly retry: Schema.Literals<readonly ["never", "after-user-action", "safe", "unknown"]>;
|
|
14
|
+
}>, import("effect/Cause").YieldableError>;
|
|
15
|
+
declare class Error extends Error_base {}
|
|
16
|
+
interface Principal {
|
|
17
|
+
readonly authorizedById: string;
|
|
18
|
+
readonly ownerId: string;
|
|
19
|
+
}
|
|
20
|
+
interface IdentityInterface {
|
|
21
|
+
readonly authenticate: (request: Request) => Effect.Effect<Principal, Error>;
|
|
22
|
+
}
|
|
23
|
+
declare const Identity_base: Context.ServiceClass<Identity, "@domainkit/server/Identity", IdentityInterface>;
|
|
24
|
+
declare class Identity extends Identity_base {}
|
|
25
|
+
interface AuthorizationReuseInput {
|
|
26
|
+
readonly authorizationId: string;
|
|
27
|
+
readonly domain: string | undefined;
|
|
28
|
+
readonly method: "integration" | "oauth2";
|
|
29
|
+
readonly principal: Principal;
|
|
30
|
+
readonly providerId: string;
|
|
31
|
+
}
|
|
32
|
+
interface ConnectionPolicyInterface {
|
|
33
|
+
readonly authorizeReuse: (input: AuthorizationReuseInput) => Effect.Effect<void, Error>;
|
|
34
|
+
}
|
|
35
|
+
declare const ConnectionPolicy_base: Context.ServiceClass<ConnectionPolicy, "@domainkit/server/ConnectionPolicy", ConnectionPolicyInterface>;
|
|
36
|
+
/** Host authorization boundary for reusing an existing provider authorization. */
|
|
37
|
+
declare class ConnectionPolicy extends ConnectionPolicy_base {}
|
|
38
|
+
interface InteractiveFlowInput {
|
|
39
|
+
readonly callbackUrl: URL;
|
|
40
|
+
readonly domain: string | undefined;
|
|
41
|
+
readonly method: "integration" | "oauth2";
|
|
42
|
+
readonly providerId: string;
|
|
43
|
+
}
|
|
44
|
+
interface ProvidersInterface {
|
|
45
|
+
readonly interactiveFlow: (input: InteractiveFlowInput) => Effect.Effect<InteractiveFlow, Error>;
|
|
46
|
+
}
|
|
47
|
+
declare const Providers_base: Context.ServiceClass<Providers, "@domainkit/server/Providers", ProvidersInterface>;
|
|
48
|
+
declare class Providers extends Providers_base {}
|
|
49
|
+
interface InteractiveProvider {
|
|
50
|
+
readonly create: (input: Omit<InteractiveFlowInput, "method" | "providerId">) => Effect.Effect<InteractiveFlow, Error>;
|
|
51
|
+
readonly method: "integration" | "oauth2";
|
|
52
|
+
readonly providerId: string;
|
|
53
|
+
}
|
|
54
|
+
/** Configure all interactive providers once at the host composition root. */
|
|
55
|
+
declare const providersLayer: (definitions: ReadonlyArray<InteractiveProvider>) => Layer.Layer<Providers>;
|
|
56
|
+
interface PendingAuthorizationContext {
|
|
57
|
+
readonly baseURL: string;
|
|
58
|
+
readonly domain: string | undefined;
|
|
59
|
+
readonly method: "integration" | "oauth2";
|
|
60
|
+
readonly providerId: string;
|
|
61
|
+
readonly returnTo: string;
|
|
62
|
+
}
|
|
63
|
+
interface PendingAuthorization {
|
|
64
|
+
readonly context: PendingAuthorizationContext;
|
|
65
|
+
readonly continuation: Continuation;
|
|
66
|
+
}
|
|
67
|
+
interface PendingAuthorizationsInterface {
|
|
68
|
+
readonly consume: (id: string, now: Date) => Effect.Effect<PendingAuthorization | null, Error>;
|
|
69
|
+
readonly get: (id: string, now: Date) => Effect.Effect<PendingAuthorization | null, Error>;
|
|
70
|
+
readonly put: (pending: PendingAuthorization) => Effect.Effect<void, Error>;
|
|
71
|
+
}
|
|
72
|
+
declare const PendingAuthorizations_base: Context.ServiceClass<PendingAuthorizations, "@domainkit/server/PendingAuthorizations", PendingAuthorizationsInterface>;
|
|
73
|
+
declare class PendingAuthorizations extends PendingAuthorizations_base {}
|
|
74
|
+
interface Configuration {
|
|
75
|
+
/** Public origin used to construct provider callbacks. Defaults to the incoming request origin. */
|
|
76
|
+
readonly baseURL?: string;
|
|
77
|
+
/** Catch-all mount path. */
|
|
78
|
+
readonly basePath?: string;
|
|
79
|
+
/** Relative same-origin destination used when a start request omits `returnTo`. */
|
|
80
|
+
readonly defaultReturnTo?: string;
|
|
81
|
+
}
|
|
82
|
+
interface AsyncIdentity {
|
|
83
|
+
readonly authenticate: (request: Request) => Promise<Principal>;
|
|
84
|
+
}
|
|
85
|
+
interface AsyncConnectionPolicy {
|
|
86
|
+
readonly authorizeReuse: (input: AuthorizationReuseInput) => Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
type AsyncInteractiveFlow = InteractiveFlow$1;
|
|
89
|
+
interface AsyncInteractiveProvider {
|
|
90
|
+
readonly create: (input: Omit<InteractiveFlowInput, "method" | "providerId">) => Promise<AsyncInteractiveFlow>;
|
|
91
|
+
readonly method: "integration" | "oauth2";
|
|
92
|
+
readonly providerId: string;
|
|
93
|
+
}
|
|
94
|
+
interface AsyncPendingAuthorizations {
|
|
95
|
+
readonly consume: (id: string, now: Date) => Promise<PendingAuthorization | null>;
|
|
96
|
+
readonly get: (id: string, now: Date) => Promise<PendingAuthorization | null>;
|
|
97
|
+
readonly put: (pending: PendingAuthorization) => Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
interface CreateDomainKitOptions extends Configuration {
|
|
100
|
+
readonly connectionPolicy: AsyncConnectionPolicy;
|
|
101
|
+
readonly identity: AsyncIdentity;
|
|
102
|
+
readonly pendingAuthorizations: AsyncPendingAuthorizations;
|
|
103
|
+
/** Host-owned Promise persistence. DomainKit does not initialize or dispose this resource. */
|
|
104
|
+
readonly persistence: AsyncInterface;
|
|
105
|
+
readonly providers: ReadonlyArray<AsyncInteractiveProvider>;
|
|
106
|
+
}
|
|
107
|
+
interface Interface {
|
|
108
|
+
readonly handle: (request: Request) => Effect.Effect<Response>;
|
|
109
|
+
}
|
|
110
|
+
declare const Handler_base: Context.ServiceClass<Handler, "@domainkit/server/Handler", Interface>;
|
|
111
|
+
declare class Handler extends Handler_base {}
|
|
112
|
+
/** Construct the Effect-native server handler from host-provided services. */
|
|
113
|
+
declare const make: (configuration?: Configuration) => Effect.Effect<Interface, never, ConnectionPolicy | Crypto.Crypto | Identity | PendingAuthorizations | Providers | Service>;
|
|
114
|
+
/** Provide the Effect-native server handler as a Layer. */
|
|
115
|
+
declare const layer: (configuration?: Configuration) => Layer.Layer<Handler, never, ConnectionPolicy | Crypto.Crypto | Identity | PendingAuthorizations | Providers | Service>;
|
|
116
|
+
interface WebHandler {
|
|
117
|
+
readonly dispose: () => Promise<void>;
|
|
118
|
+
readonly fetch: (request: Request) => Promise<Response>;
|
|
119
|
+
}
|
|
120
|
+
/** Build one reusable Web handler from a fully provided Effect server Layer. */
|
|
121
|
+
declare function toWebHandler<E>(serverLayer: Layer.Layer<Handler, E>): WebHandler;
|
|
122
|
+
/**
|
|
123
|
+
* Build a Web handler for async hosts. The host owns persistence setup, migrations, and disposal.
|
|
124
|
+
*/
|
|
125
|
+
declare function createDomainKit(options: CreateDomainKitOptions): Promise<WebHandler>;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { index_d_exports as Server, createDomainKit };
|
|
128
|
+
//# sourceMappingURL=server.d.mts.map
|