domainkit 0.4.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 +243 -42
- package/dist/index.mjs +63 -27
- 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 -184
- package/dist/promise.mjs +113 -156
- package/dist/promise.mjs.map +1 -1
- package/dist/{resolver-uqe1h5Vz.d.mts → resolver-DUAIlm2I.d.mts} +24 -1396
- package/dist/{resolver-CvK7JoJM.mjs → resolver-DxJPsq6l.mjs} +9 -115
- 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 +6 -5
- package/dist/testing.mjs +122 -64
- package/dist/testing.mjs.map +1 -1
- package/dist/{verify-BUB4N5zs.mjs → verify-DAtUAEeg.mjs} +461 -485
- package/dist/verify-DAtUAEeg.mjs.map +1 -0
- package/dist/{verify-CkgVrwyl.d.mts → verify-yAy-r9no.d.mts} +198 -42
- package/package.json +5 -1
- package/dist/resolver-CvK7JoJM.mjs.map +0 -1
- package/dist/verify-BUB4N5zs.mjs.map +0 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as Capability, J as Manifest, M as ProviderConnection, N as ProviderTarget, Nt as Error$1, Q as OAuthSubjectResolver, W as ProviderAuthorization, X as OAuthClientConfiguration, Z as OAuthMethod, ct as Service$1, d as Method, et as TokenValidation, g as Envelope, h as Codec, it as AsyncInterface$1, j as DomainAttachment, kt as DomainName, l as InteractiveFlow, mt as DnsRecord, nt as Value, ot as Error, q as IntegrationMethod, s as Error$2, st as Interface$4 } from "./connect-Db830jad.mjs";
|
|
2
|
+
import { H as Source, a as Interface$5, c as Service$2, i as Error$3, n as AsyncInterface$2, o as Query, t as Answer } from "./resolver-DUAIlm2I.mjs";
|
|
2
3
|
import { Context, Data, Effect, Layer, Schema } from "effect";
|
|
3
4
|
import * as oauth from "oauth4webapi";
|
|
4
|
-
declare namespace connection_api_d_exports {
|
|
5
|
-
export { Authentication, AuthenticationFailure, AuthorizationError, BaseInput, CompleteInput, Connection, Method as ConnectionMethod, RemoveDomainResult as ConnectionRemoveDomainResult, StartResult as ConnectionStartResult, Continuation, ContinuationStore, Error, ExtendInput, Failure, Grant, InteractiveFlow, InteractiveStart, Method, RemoveDomainInput, RemoveDomainResult, Requirements, Schema$1 as Schema, StartResult, StoredCredential, assertGrant, authorizationError, complete, coversDomain, decode, encode, extend, includeDomains, removeDomain, removeDomain$1 as removeDomainFromGrant, start, validate };
|
|
6
|
-
}
|
|
7
5
|
declare namespace diagnostic_d_exports {
|
|
8
6
|
export { Category, Diagnostic, Fields, RetryAdvice, from };
|
|
9
7
|
}
|
|
@@ -36,10 +34,9 @@ declare namespace selection_d_exports {
|
|
|
36
34
|
}
|
|
37
35
|
interface ConnectedZone {
|
|
38
36
|
readonly authorization: ProviderAuthorization;
|
|
39
|
-
readonly
|
|
37
|
+
readonly attachment: DomainAttachment;
|
|
38
|
+
readonly connection: ProviderConnection;
|
|
40
39
|
readonly nameservers: ReadonlyArray<string>;
|
|
41
|
-
readonly providerId: string;
|
|
42
|
-
readonly zone: string;
|
|
43
40
|
}
|
|
44
41
|
declare const Evidence$1: Schema.Struct<{
|
|
45
42
|
readonly accountId: Schema.String;
|
|
@@ -98,6 +95,135 @@ declare namespace zones_d_exports {
|
|
|
98
95
|
export { candidates };
|
|
99
96
|
}
|
|
100
97
|
declare function candidates(input: string): ReadonlyArray<DomainName>;
|
|
98
|
+
declare namespace session_d_exports {
|
|
99
|
+
export { AsyncInterface, Authorization, Credential, Interface$3 as Interface, ListTargetsInput, Resolution, RestoreInput, fromAsync, toAsync$3 as toAsync };
|
|
100
|
+
}
|
|
101
|
+
/** A credential-scoped provider session that discovers safe targets before DNS access. */
|
|
102
|
+
interface Interface$3 {
|
|
103
|
+
/** The provider represented by this credential. */
|
|
104
|
+
readonly providerId: string;
|
|
105
|
+
/** Lists provider account and authoritative-zone targets visible to this credential. */
|
|
106
|
+
readonly listTargets: (input?: ListTargetsInput) => Effect.Effect<ReadonlyArray<ProviderTarget>, Error>;
|
|
107
|
+
/** Resolves a domain without guessing when more than one account owns a matching zone. */
|
|
108
|
+
readonly resolveTarget: (domain: DomainName) => Effect.Effect<Resolution, Error>;
|
|
109
|
+
/** Creates the focused DNS-record capability bound to one exact discovered target. */
|
|
110
|
+
readonly forTarget: (target: ProviderTarget) => Effect.Effect<Interface$4, Error>;
|
|
111
|
+
}
|
|
112
|
+
interface ListTargetsInput {
|
|
113
|
+
/** Restrict results to the authoritative zone candidates for this domain. */
|
|
114
|
+
readonly domain?: DomainName;
|
|
115
|
+
/** Provider-specific account filter, when supported by the adapter. */
|
|
116
|
+
readonly accountId?: string;
|
|
117
|
+
}
|
|
118
|
+
type Resolution = Data.TaggedEnum<{
|
|
119
|
+
NotFound: {
|
|
120
|
+
readonly domain: DomainName;
|
|
121
|
+
};
|
|
122
|
+
Resolved: {
|
|
123
|
+
readonly target: ProviderTarget;
|
|
124
|
+
};
|
|
125
|
+
SelectionRequired: {
|
|
126
|
+
readonly candidates: ReadonlyArray<ProviderTarget>;
|
|
127
|
+
};
|
|
128
|
+
}>;
|
|
129
|
+
declare const Resolution: {
|
|
130
|
+
readonly $is: <Tag extends "NotFound" | "Resolved" | "SelectionRequired">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
131
|
+
readonly _tag: "NotFound";
|
|
132
|
+
readonly domain: DomainName;
|
|
133
|
+
}, {
|
|
134
|
+
readonly _tag: Tag;
|
|
135
|
+
}> | Extract<{
|
|
136
|
+
readonly _tag: "Resolved";
|
|
137
|
+
readonly target: ProviderTarget;
|
|
138
|
+
}, {
|
|
139
|
+
readonly _tag: Tag;
|
|
140
|
+
}> | Extract<{
|
|
141
|
+
readonly _tag: "SelectionRequired";
|
|
142
|
+
readonly candidates: ReadonlyArray<ProviderTarget>;
|
|
143
|
+
}, {
|
|
144
|
+
readonly _tag: Tag;
|
|
145
|
+
}>;
|
|
146
|
+
readonly $match: {
|
|
147
|
+
<Cases extends { readonly [Tag in "NotFound" | "Resolved" | "SelectionRequired"]: (args: Extract<{
|
|
148
|
+
readonly _tag: "NotFound";
|
|
149
|
+
readonly domain: DomainName;
|
|
150
|
+
} | {
|
|
151
|
+
readonly _tag: "Resolved";
|
|
152
|
+
readonly target: ProviderTarget;
|
|
153
|
+
} | {
|
|
154
|
+
readonly _tag: "SelectionRequired";
|
|
155
|
+
readonly candidates: ReadonlyArray<ProviderTarget>;
|
|
156
|
+
}, {
|
|
157
|
+
readonly _tag: Tag;
|
|
158
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
159
|
+
readonly _tag: "NotFound";
|
|
160
|
+
readonly domain: DomainName;
|
|
161
|
+
} | {
|
|
162
|
+
readonly _tag: "Resolved";
|
|
163
|
+
readonly target: ProviderTarget;
|
|
164
|
+
} | {
|
|
165
|
+
readonly _tag: "SelectionRequired";
|
|
166
|
+
readonly candidates: ReadonlyArray<ProviderTarget>;
|
|
167
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["NotFound" | "Resolved" | "SelectionRequired"]>>;
|
|
168
|
+
<Cases extends { readonly [Tag in "NotFound" | "Resolved" | "SelectionRequired"]: (args: Extract<{
|
|
169
|
+
readonly _tag: "NotFound";
|
|
170
|
+
readonly domain: DomainName;
|
|
171
|
+
} | {
|
|
172
|
+
readonly _tag: "Resolved";
|
|
173
|
+
readonly target: ProviderTarget;
|
|
174
|
+
} | {
|
|
175
|
+
readonly _tag: "SelectionRequired";
|
|
176
|
+
readonly candidates: ReadonlyArray<ProviderTarget>;
|
|
177
|
+
}, {
|
|
178
|
+
readonly _tag: Tag;
|
|
179
|
+
}>) => any; }>(value: {
|
|
180
|
+
readonly _tag: "NotFound";
|
|
181
|
+
readonly domain: DomainName;
|
|
182
|
+
} | {
|
|
183
|
+
readonly _tag: "Resolved";
|
|
184
|
+
readonly target: ProviderTarget;
|
|
185
|
+
} | {
|
|
186
|
+
readonly _tag: "SelectionRequired";
|
|
187
|
+
readonly candidates: ReadonlyArray<ProviderTarget>;
|
|
188
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["NotFound" | "Resolved" | "SelectionRequired"]>>;
|
|
189
|
+
};
|
|
190
|
+
readonly NotFound: Data.TaggedEnum.ConstructorFrom<{
|
|
191
|
+
readonly _tag: "NotFound";
|
|
192
|
+
readonly domain: DomainName;
|
|
193
|
+
}, "_tag">;
|
|
194
|
+
readonly Resolved: Data.TaggedEnum.ConstructorFrom<{
|
|
195
|
+
readonly _tag: "Resolved";
|
|
196
|
+
readonly target: ProviderTarget;
|
|
197
|
+
}, "_tag">;
|
|
198
|
+
readonly SelectionRequired: Data.TaggedEnum.ConstructorFrom<{
|
|
199
|
+
readonly _tag: "SelectionRequired";
|
|
200
|
+
readonly candidates: ReadonlyArray<ProviderTarget>;
|
|
201
|
+
}, "_tag">;
|
|
202
|
+
};
|
|
203
|
+
/** The credential material a provider adapter needs to restore a session. */
|
|
204
|
+
interface Credential {
|
|
205
|
+
readonly accessToken: Value;
|
|
206
|
+
readonly expiresAt: Date | null;
|
|
207
|
+
readonly refreshToken: Value | null;
|
|
208
|
+
readonly tokenType: string;
|
|
209
|
+
}
|
|
210
|
+
/** The non-secret authorization projection required when restoring a provider session. */
|
|
211
|
+
type Authorization = Pick<ProviderAuthorization, "capabilityEvidence" | "method" | "providerContext" | "providerId" | "requiredCapabilities" | "revocation">;
|
|
212
|
+
interface RestoreInput {
|
|
213
|
+
readonly authorization: Authorization;
|
|
214
|
+
readonly credential: Credential;
|
|
215
|
+
}
|
|
216
|
+
/** Minimal Promise-shaped provider-session contract for hosts that do not use Effect directly. */
|
|
217
|
+
interface AsyncInterface {
|
|
218
|
+
readonly providerId: string;
|
|
219
|
+
readonly listTargets: (input?: ListTargetsInput) => Promise<ReadonlyArray<ProviderTarget>>;
|
|
220
|
+
readonly resolveTarget: (domain: DomainName) => Promise<Resolution>;
|
|
221
|
+
readonly forTarget: (target: ProviderTarget) => Promise<AsyncInterface$1>;
|
|
222
|
+
}
|
|
223
|
+
/** Adapts a Promise-shaped session to the Effect-native session boundary. */
|
|
224
|
+
declare const fromAsync: (session: AsyncInterface) => Interface$3;
|
|
225
|
+
/** Adapts an Effect-native session to the Promise facade. */
|
|
226
|
+
declare const toAsync$3: (session: Interface$3) => AsyncInterface;
|
|
101
227
|
//#endregion
|
|
102
228
|
//#region src/providers/cloudflare/protocol.d.ts
|
|
103
229
|
declare const Account$2: Schema.Struct<{
|
|
@@ -111,7 +237,8 @@ declare namespace client_d_exports$1 {
|
|
|
111
237
|
type Fetch$2 = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
112
238
|
/** Configuration for an Effect-native Cloudflare authoritative-DNS client. */
|
|
113
239
|
interface Options$4 {
|
|
114
|
-
|
|
240
|
+
/** Account scope for account tokens; omit for user or OAuth credentials. */
|
|
241
|
+
readonly accountId?: string;
|
|
115
242
|
readonly baseUrl?: string;
|
|
116
243
|
/** Capabilities the host required when issuing or authorizing this credential. */
|
|
117
244
|
readonly capabilities: TokenValidation["capabilities"];
|
|
@@ -132,10 +259,14 @@ interface Zone$1 {
|
|
|
132
259
|
readonly nameservers: ReadonlyArray<DomainName>;
|
|
133
260
|
readonly status: string | null;
|
|
134
261
|
}
|
|
135
|
-
interface Interface$2 extends Interface$
|
|
136
|
-
readonly
|
|
137
|
-
readonly
|
|
138
|
-
readonly
|
|
262
|
+
interface Interface$2 extends Interface$4 {
|
|
263
|
+
readonly providerId: "cloudflare";
|
|
264
|
+
readonly forTarget: (target: ProviderTarget) => Effect.Effect<Interface$4, Error>;
|
|
265
|
+
readonly listAccounts: () => Effect.Effect<ReadonlyArray<Account$1>, Error>;
|
|
266
|
+
readonly listZones: (input?: ListZonesInput$1) => Effect.Effect<ReadonlyArray<Zone$1>, Error>;
|
|
267
|
+
readonly listTargets: (input?: ListTargetsInput) => Effect.Effect<ReadonlyArray<ProviderTarget>, Error>;
|
|
268
|
+
readonly resolveTarget: (domain: DomainName) => Effect.Effect<Resolution, Error>;
|
|
269
|
+
readonly validateToken: () => Effect.Effect<TokenValidation, Error>;
|
|
139
270
|
}
|
|
140
271
|
/** Exposes Cloudflare zone lookup as the optional provider discovery capability. */
|
|
141
272
|
declare function discovery$1(client: Interface$2): Source;
|
|
@@ -154,23 +285,25 @@ declare const discoverAuthorizationAccount: (options: CredentialOptions$1 & {
|
|
|
154
285
|
}) => Effect.Effect<{
|
|
155
286
|
readonly id: string;
|
|
156
287
|
readonly name: string;
|
|
157
|
-
}, Error
|
|
288
|
+
}, Error, never>;
|
|
158
289
|
declare const validateDomainToken: (options: DomainCredentialOptions) => Effect.Effect<{
|
|
159
290
|
accountId: string;
|
|
160
291
|
capabilities: readonly ("dns:read" | "dns:write")[];
|
|
161
292
|
expiresAt: Date | null;
|
|
162
293
|
scopes: never[];
|
|
163
|
-
}, Error
|
|
294
|
+
}, Error, never>;
|
|
164
295
|
/** Creates an Effect-native Cloudflare client without owning the credential lifecycle. */
|
|
165
296
|
declare function make$5(options: Options$4): Interface$2;
|
|
166
297
|
declare namespace auth_d_exports$1 {
|
|
167
|
-
export { Context$2 as Context, CredentialTarget, OAuthFlowOptions, OAuthMethodOptions, SubjectResolverOptions, TokenConnectionOptions$1 as TokenConnectionOptions, TokenValidatorOptions, contextCodec$1 as contextCodec, manifest$1 as manifest, oauthAuthentication, oauthFlow, oauthMethod, subjectResolver, tokenConnectionMethod$1 as tokenConnectionMethod, tokenMethod$1 as tokenMethod, tokenValidator };
|
|
298
|
+
export { Context$2 as Context, CredentialTarget, OAuthFlowOptions, OAuthMethodOptions, RefreshCredentialOptions, SubjectResolverOptions, TokenConnectionOptions$1 as TokenConnectionOptions, TokenValidatorOptions, contextCodec$1 as contextCodec, manifest$1 as manifest, oauthAuthentication, oauthFlow, oauthMethod, refreshCredential, restore$1 as restore, subjectResolver, tokenConnectionMethod$1 as tokenConnectionMethod, tokenMethod$1 as tokenMethod, tokenValidator };
|
|
168
299
|
}
|
|
169
300
|
declare const Context$2: Schema.Struct<{
|
|
301
|
+
readonly accountId: Schema.optionalKey<Schema.String>;
|
|
170
302
|
readonly tokenKind: Schema.Literals<readonly ["account", "user"]>;
|
|
171
303
|
}>;
|
|
172
304
|
type Context$2 = typeof Context$2.Type;
|
|
173
305
|
declare const contextCodec$1: Codec<{
|
|
306
|
+
readonly accountId?: string;
|
|
174
307
|
readonly tokenKind: "account" | "user";
|
|
175
308
|
}>;
|
|
176
309
|
/** Describes Cloudflare's caller-created API-token authorization method. */
|
|
@@ -208,7 +341,7 @@ type TokenValidatorOptions = CredentialOptions & ({
|
|
|
208
341
|
readonly domain: DomainName;
|
|
209
342
|
readonly tokenKind?: "account" | "user";
|
|
210
343
|
});
|
|
211
|
-
/** Resolves the Cloudflare account selected by a completed OAuth
|
|
344
|
+
/** Resolves the Cloudflare account selected by a completed OAuth authorization. */
|
|
212
345
|
declare function subjectResolver(options: SubjectResolverOptions): OAuthSubjectResolver;
|
|
213
346
|
/** Creates a host callback that validates a Cloudflare API token. */
|
|
214
347
|
declare function tokenValidator(options: TokenValidatorOptions): (token: Value) => ReturnType<Interface$2["validateToken"]>;
|
|
@@ -219,7 +352,7 @@ type TokenConnectionOptions$1 = TokenValidatorOptions & {
|
|
|
219
352
|
declare function tokenConnectionMethod$1(options: TokenConnectionOptions$1): Extract<Method, {
|
|
220
353
|
readonly _tag: "Token";
|
|
221
354
|
}>;
|
|
222
|
-
/** Converts a completed Cloudflare OAuth
|
|
355
|
+
/** Converts a completed Cloudflare OAuth authorization into canonical connection authentication. */
|
|
223
356
|
declare const oauthAuthentication: (options: SubjectResolverOptions & {
|
|
224
357
|
readonly accessToken: Value;
|
|
225
358
|
readonly tokens: oauth.TokenEndpointResponse;
|
|
@@ -233,14 +366,29 @@ declare const oauthAuthentication: (options: SubjectResolverOptions & {
|
|
|
233
366
|
}[];
|
|
234
367
|
credential: {
|
|
235
368
|
accessToken: Value;
|
|
369
|
+
expiresAt: Date | null;
|
|
236
370
|
refreshToken: Value | null;
|
|
237
371
|
tokenType: Lowercase<string>;
|
|
238
372
|
};
|
|
239
|
-
expiresAt: Date | null;
|
|
240
373
|
providerAccountId: string;
|
|
241
374
|
providerContext: Envelope;
|
|
242
375
|
scopes: string[];
|
|
243
|
-
}, Error$
|
|
376
|
+
}, Error$1 | Error, never>;
|
|
377
|
+
/** Restore a credential-scoped Cloudflare session from persisted authorization state. */
|
|
378
|
+
declare function restore$1(options: RestoreInput & Pick<Options$4, "baseUrl" | "fetch">): Effect.Effect<Interface$2, Error>;
|
|
379
|
+
interface RefreshCredentialOptions {
|
|
380
|
+
readonly client: OAuthClientConfiguration;
|
|
381
|
+
readonly clientAuth: OAuthMethod["clientAuth"];
|
|
382
|
+
readonly credential: Credential;
|
|
383
|
+
readonly fetch?: Fetch$2;
|
|
384
|
+
}
|
|
385
|
+
/** Exchanges a Cloudflare refresh token for a fresh provider credential. */
|
|
386
|
+
declare const refreshCredential: (options: RefreshCredentialOptions) => Effect.Effect<{
|
|
387
|
+
accessToken: Value;
|
|
388
|
+
expiresAt: Date | null;
|
|
389
|
+
refreshToken: Value;
|
|
390
|
+
tokenType: Lowercase<string>;
|
|
391
|
+
}, Error | Error$2, never>;
|
|
244
392
|
type OAuthFlowOptions = SubjectResolverOptions & {
|
|
245
393
|
readonly client: OAuthClientConfiguration;
|
|
246
394
|
readonly clientAuth: OAuthMethod["clientAuth"];
|
|
@@ -289,17 +437,21 @@ interface Zone {
|
|
|
289
437
|
readonly nameservers: ReadonlyArray<DomainName>;
|
|
290
438
|
readonly status: "active" | "pending";
|
|
291
439
|
}
|
|
292
|
-
interface Interface$1 extends Interface$
|
|
293
|
-
readonly
|
|
294
|
-
readonly
|
|
295
|
-
readonly
|
|
440
|
+
interface Interface$1 extends Interface$4 {
|
|
441
|
+
readonly providerId: "vercel";
|
|
442
|
+
readonly forTarget: (target: ProviderTarget) => Effect.Effect<Interface$4, Error>;
|
|
443
|
+
readonly listAccounts: () => Effect.Effect<ReadonlyArray<Account>, Error>;
|
|
444
|
+
readonly listZones: (input?: ListZonesInput) => Effect.Effect<ReadonlyArray<Zone>, Error>;
|
|
445
|
+
readonly listTargets: (input?: ListTargetsInput) => Effect.Effect<ReadonlyArray<ProviderTarget>, Error>;
|
|
446
|
+
readonly resolveTarget: (domain: DomainName) => Effect.Effect<Resolution, Error>;
|
|
447
|
+
readonly validateToken: () => Effect.Effect<TokenValidation, Error>;
|
|
296
448
|
}
|
|
297
449
|
/** Exposes Vercel zone lookup as the optional provider discovery capability. */
|
|
298
450
|
declare function discovery(client: Interface$1): Source;
|
|
299
451
|
/** Creates an Effect-native Vercel client without owning the credential lifecycle. */
|
|
300
452
|
declare function make$4(options: Options$3): Interface$1;
|
|
301
453
|
declare namespace auth_d_exports {
|
|
302
|
-
export { Context$1 as Context, ExchangeCodeOptions, IntegrationCredential, IntegrationFlowOptions, IntegrationMethodOptions, TokenConnectionOptions, contextCodec, exchangeCode, integrationAuthentication, integrationFlow, integrationMethod, manifest, tokenConnectionMethod, tokenMethod };
|
|
454
|
+
export { Context$1 as Context, ExchangeCodeOptions, IntegrationCredential, IntegrationFlowOptions, IntegrationMethodOptions, TokenConnectionOptions, contextCodec, exchangeCode, integrationAuthentication, integrationFlow, integrationMethod, manifest, restore, tokenConnectionMethod, tokenMethod };
|
|
303
455
|
}
|
|
304
456
|
declare const Context$1: Schema.TaggedUnion<{
|
|
305
457
|
readonly personal: Schema.TaggedStruct<"personal", {
|
|
@@ -336,6 +488,8 @@ interface ExchangeCodeOptions {
|
|
|
336
488
|
readonly clientId: string;
|
|
337
489
|
readonly clientSecret: Value;
|
|
338
490
|
readonly code: Value;
|
|
491
|
+
/** Configuration ID returned by Vercel's integration callback, when available. */
|
|
492
|
+
readonly configurationId?: string;
|
|
339
493
|
readonly fetch?: Fetch$1;
|
|
340
494
|
readonly redirectUri: string;
|
|
341
495
|
}
|
|
@@ -357,7 +511,7 @@ declare const exchangeCode: (options: ExchangeCodeOptions) => Effect.Effect<{
|
|
|
357
511
|
};
|
|
358
512
|
installationId: string | null;
|
|
359
513
|
userId: string;
|
|
360
|
-
}, Error
|
|
514
|
+
}, Error, never>;
|
|
361
515
|
interface TokenConnectionOptions extends Omit<Options$3, "token"> {
|
|
362
516
|
readonly token: Value;
|
|
363
517
|
}
|
|
@@ -378,14 +532,16 @@ declare const integrationAuthentication: (options: ExchangeCodeOptions & {
|
|
|
378
532
|
}[];
|
|
379
533
|
credential: {
|
|
380
534
|
accessToken: Value;
|
|
535
|
+
expiresAt: null;
|
|
381
536
|
refreshToken: null;
|
|
382
537
|
tokenType: string;
|
|
383
538
|
};
|
|
384
|
-
expiresAt: null;
|
|
385
539
|
providerAccountId: string;
|
|
386
540
|
providerContext: Envelope;
|
|
387
541
|
scopes: never[];
|
|
388
|
-
}, Error$
|
|
542
|
+
}, Error$1 | Error, never>;
|
|
543
|
+
/** Restore a credential-scoped Vercel session from persisted authorization state. */
|
|
544
|
+
declare function restore(options: RestoreInput & Pick<Options$3, "baseUrl" | "fetch">): Effect.Effect<Interface$1, Error>;
|
|
389
545
|
interface IntegrationFlowOptions extends Omit<ExchangeCodeOptions, "code">, IntegrationMethodOptions {}
|
|
390
546
|
/** Creates Vercel Integration's implementation of the common interactive connection capability. */
|
|
391
547
|
declare function integrationFlow(options: IntegrationFlowOptions): InteractiveFlow;
|
|
@@ -401,33 +557,33 @@ interface Options$2 {
|
|
|
401
557
|
readonly fetch?: Fetch;
|
|
402
558
|
readonly timeoutMs?: number;
|
|
403
559
|
}
|
|
404
|
-
declare function make$3(options: Options$2): Interface$
|
|
405
|
-
declare const layer$2: (options: Options$2) => Layer.Layer<Service$
|
|
406
|
-
declare const toAsync$2: (options: Options$2) => AsyncInterface;
|
|
560
|
+
declare function make$3(options: Options$2): Interface$5;
|
|
561
|
+
declare const layer$2: (options: Options$2) => Layer.Layer<Service$2>;
|
|
562
|
+
declare const toAsync$2: (options: Options$2) => AsyncInterface$2;
|
|
407
563
|
declare namespace cloudflare_doh_d_exports {
|
|
408
564
|
export { Options$1 as Options, layer$1 as layer, make$2 as make, toAsync$1 as toAsync };
|
|
409
565
|
}
|
|
410
566
|
interface Options$1 extends Omit<Options$2, "endpoint"> {
|
|
411
567
|
readonly endpoint?: string;
|
|
412
568
|
}
|
|
413
|
-
declare function make$2(options?: Options$1): Interface$
|
|
414
|
-
declare const layer$1: (options?: Options$1) => Layer.Layer<Service$
|
|
415
|
-
declare const toAsync$1: (options?: Options$1) => AsyncInterface;
|
|
569
|
+
declare function make$2(options?: Options$1): Interface$5;
|
|
570
|
+
declare const layer$1: (options?: Options$1) => Layer.Layer<Service$2>;
|
|
571
|
+
declare const toAsync$1: (options?: Options$1) => AsyncInterface$2;
|
|
416
572
|
declare namespace google_doh_d_exports {
|
|
417
573
|
export { Options, layer, make$1 as make, toAsync };
|
|
418
574
|
}
|
|
419
575
|
interface Options extends Omit<Options$2, "endpoint"> {
|
|
420
576
|
readonly endpoint?: string;
|
|
421
577
|
}
|
|
422
|
-
declare function make$1(options?: Options): Interface$
|
|
423
|
-
declare const layer: (options?: Options) => Layer.Layer<Service$
|
|
424
|
-
declare const toAsync: (options?: Options) => AsyncInterface;
|
|
578
|
+
declare function make$1(options?: Options): Interface$5;
|
|
579
|
+
declare const layer: (options?: Options) => Layer.Layer<Service$2>;
|
|
580
|
+
declare const toAsync: (options?: Options) => AsyncInterface$2;
|
|
425
581
|
declare namespace resolver_pool_d_exports {
|
|
426
582
|
export { DefaultOptions, Entry, Interface, Observation, Policy, Service, defaultLayer, defaultMake, make };
|
|
427
583
|
}
|
|
428
584
|
interface Entry {
|
|
429
585
|
readonly id: string;
|
|
430
|
-
readonly resolver: Interface$
|
|
586
|
+
readonly resolver: Interface$5;
|
|
431
587
|
readonly timeoutMs?: number;
|
|
432
588
|
}
|
|
433
589
|
type Observation = Data.TaggedEnum<{
|
|
@@ -1094,9 +1250,9 @@ declare const Result: {
|
|
|
1094
1250
|
readonly publicDns: PublicDnsObservation | null;
|
|
1095
1251
|
}, "_tag">;
|
|
1096
1252
|
};
|
|
1097
|
-
declare function observe(input: PublicOnlyConfig): Effect.Effect<Result, Error$
|
|
1098
|
-
declare function observe(input: ProviderConfig): Effect.Effect<Result, Error$
|
|
1099
|
-
declare function observe(input: Config): Effect.Effect<Result, Error$
|
|
1253
|
+
declare function observe(input: PublicOnlyConfig): Effect.Effect<Result, Error$1>;
|
|
1254
|
+
declare function observe(input: ProviderConfig): Effect.Effect<Result, Error$1, Service$1>;
|
|
1255
|
+
declare function observe(input: Config): Effect.Effect<Result, Error$1, Service$1>;
|
|
1100
1256
|
//#endregion
|
|
1101
|
-
export {
|
|
1102
|
-
//# sourceMappingURL=verify-
|
|
1257
|
+
export { RestoreInput as $, Options$3 as A, manifest$1 as B, manifest as C, Fetch$1 as D, AccountContext as E, OAuthMethodOptions as F, Interface$2 as G, tokenMethod$1 as H, RefreshCredentialOptions as I, Zone$1 as J, ListZonesInput$1 as K, SubjectResolverOptions as L, index_d_exports$1 as M, CredentialTarget as N, Interface$1 as O, OAuthFlowOptions as P, Resolution as Q, TokenConnectionOptions$1 as R, integrationMethod as S, Account as T, Account$1 as U, oauthMethod as V, Fetch$2 as W, Interface$3 as X, Credential as Y, ListTargetsInput as Z, ExchangeCodeOptions as _, verify_d_exports as a, IntegrationMethodOptions as b, Policy as c, google_doh_d_exports as d, session_d_exports as et, Options$1 as f, index_d_exports as g, doh_d_exports as h, Result as i, Zone as j, ListZonesInput as k, resolver_pool_d_exports as l, Options$2 as m, PublicDns as n, selection_d_exports as nt, DefaultOptions as o, cloudflare_doh_d_exports as p, Options$4 as q, PublicDnsObservation as r, diagnostic_d_exports as rt, Observation as s, ProviderObservation as t, zones_d_exports as tt, Options as u, IntegrationCredential as v, tokenMethod as w, TokenConnectionOptions as x, IntegrationFlowOptions as y, TokenValidatorOptions as z };
|
|
1258
|
+
//# sourceMappingURL=verify-yAy-r9no.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "domainkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Provider-independent DNS provisioning plans and authorization for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dns",
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
"types": "./dist/promise.d.mts",
|
|
36
36
|
"import": "./dist/promise.mjs"
|
|
37
37
|
},
|
|
38
|
+
"./server": {
|
|
39
|
+
"types": "./dist/server.d.mts",
|
|
40
|
+
"import": "./dist/server.mjs"
|
|
41
|
+
},
|
|
38
42
|
"./testing": {
|
|
39
43
|
"types": "./dist/testing.d.mts",
|
|
40
44
|
"import": "./dist/testing.mjs"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver-CvK7JoJM.mjs","names":["Error","Type","S","Schema","decode","InvalidInputError","parse","Error","Service","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/invalid-input.ts","../src/domain/domain-name.ts","../src/auth/lifecycle-repository.ts","../src/discovery/zones.ts","../src/discovery/zone-discovery.ts","../src/domain/dns-record.ts","../src/provider/provider.ts","../src/plan/canonical-json.ts","../src/plan/types.ts","../src/plan/plan.ts","../src/plan/deletion.ts","../src/verification/resolver.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport class Error extends Schema.TaggedError<Error>()(\"InvalidInputError\", {\n message: Schema.String,\n}) {}\n","import { Effect, Schema as S, SchemaIssue, SchemaTransformation } from \"effect\";\n\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\n\nconst labelPattern = /^[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9_])?$/;\n\nconst Type = S.String.check(\n S.makeFilter<string>(\n (value) =>\n value.length <= 253 &&\n value.includes(\".\") &&\n value.split(\".\").every((label) => labelPattern.test(label))\n ? undefined\n : \"Expected a fully qualified DNS name\",\n { identifier: \"DomainName\" },\n ),\n).pipe(S.brand(\"DomainName\"));\n\n/** A lower-case, fully qualified DNS name without a trailing dot. */\nexport type DomainName = typeof Type.Type;\n\n/** Decodes user and wire strings into canonical domain names. */\nexport const Schema = S.String.pipe(\n S.decodeTo(\n Type,\n SchemaTransformation.transformOrFail({\n decode: (input, options) =>\n Effect.try({\n try: () => normalize(input),\n catch: (cause) =>\n new SchemaIssue.InvalidValue(\n { message: cause instanceof Error ? cause.message : String(cause) },\n input,\n options,\n ),\n }),\n encode: (domain) => Effect.succeed(domain),\n }),\n ),\n);\n\nexport const decode = Effect.fn(\"DomainName.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): DomainName {\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\nfunction normalize(input: string): string {\n const labels = input\n .trim()\n .replace(/\\.+$/, \"\")\n .split(\".\")\n .map((label) => {\n if (label.includes(\"_\") || [...label].every((character) => character.charCodeAt(0) <= 127)) {\n return label.toLowerCase();\n }\n const hostname = new URL(`http://${label}.example`).hostname;\n const normalized = hostname.split(\".\")[0];\n if (normalized === undefined) throw new Error(\"Domain label could not be normalized\");\n return normalized.toLowerCase();\n });\n return labels.join(\".\");\n}\n","import { Context, Effect, Schema } from \"effect\";\n\nimport type * as ProviderAuthorization from \"./authorization.ts\";\nimport type * as Connection from \"./connection.ts\";\n\nexport interface Aggregate {\n readonly authorization: ProviderAuthorization.ProviderAuthorization;\n readonly bindings: ReadonlyArray<Connection.Connection>;\n readonly credential: Connection.StoredCredential;\n}\n\nexport interface DetachResult {\n readonly authorizationId: string;\n readonly remainingBindings: number;\n readonly revokedAuthorization: boolean;\n}\n\nexport interface BindingModification<A> {\n readonly aggregate: Aggregate;\n readonly value: A;\n}\n\nexport class Error extends Schema.TaggedError<Error>()(\"LifecycleRepositoryError\", {\n category: Schema.Literal(\"storage\"),\n message: Schema.String,\n operation: Schema.String,\n retry: Schema.Literals([\"never\", \"after-user-action\", \"safe\", \"unknown\"]),\n}) {}\n\nexport interface Interface {\n readonly bind: (\n authorizationId: string,\n binding: Connection.Connection,\n ) => Effect.Effect<Aggregate, Error>;\n readonly connect: (aggregate: Aggregate) => Effect.Effect<Aggregate, Error>;\n readonly detach: <E>(input: {\n readonly connectionId: string;\n readonly revoke: (aggregate: Aggregate) => Effect.Effect<void, E>;\n }) => Effect.Effect<DetachResult, Error | E>;\n readonly findByProviderAccount: (\n providerId: string,\n providerAccountId: string,\n ) => Effect.Effect<Aggregate | null, Error>;\n readonly get: (authorizationId: string) => Effect.Effect<Aggregate | null, Error>;\n readonly getByConnectionId: (connectionId: string) => Effect.Effect<Aggregate | null, Error>;\n readonly modifyBinding: <A>(\n connectionId: string,\n modify: (binding: Connection.Connection) => {\n readonly binding: Connection.Connection;\n readonly value: A;\n },\n ) => Effect.Effect<BindingModification<A>, Error>;\n readonly promoteEvidence: (\n authorizationId: string,\n evidence: ReadonlyArray<ProviderAuthorization.CapabilityEvidence>,\n ) => Effect.Effect<Aggregate, Error>;\n readonly recover: <E>(input: {\n readonly authorizationId: string;\n readonly revoke: (aggregate: Aggregate) => Effect.Effect<void, E>;\n }) => Effect.Effect<DetachResult, Error | E>;\n readonly rotate: (\n authorizationId: string,\n credential: Connection.StoredCredential,\n expiresAt: Date | null,\n ) => Effect.Effect<Aggregate, Error>;\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\n \"@domainkit/AuthorizationLifecycleRepository\",\n) {}\n","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 { Crypto, Effect, Layer, PlatformError, Schema } from \"effect\";\n\nexport class CryptoError extends Schema.TaggedError<CryptoError>()(\"CryptoError\", {\n message: Schema.String,\n}) {}\n\nexport type Json =\n | null\n | boolean\n | number\n | string\n | ReadonlyArray<Json>\n | { readonly [key: string]: Json };\n\n/** Deterministic JSON serialization for already schema-encoded protocol values. */\nexport function stringify(value: Json): string {\n if (value === null || typeof value !== \"object\") {\n const encoded = JSON.stringify(value);\n if (encoded === undefined) throw new TypeError(\"Value is not representable as JSON\");\n return encoded;\n }\n if (isJsonArray(value)) return `[${value.map(stringify).join(\",\")}]`;\n return `{${Object.entries(value)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n .map(([key, entry]) => `${JSON.stringify(key)}:${stringify(entry)}`)\n .join(\",\")}}`;\n}\n\nfunction isJsonArray(value: Json): value is ReadonlyArray<Json> {\n return Array.isArray(value);\n}\n\nexport const sha256Text = Effect.fn(\"Digest.sha256Text\")(function* (value: string) {\n const cryptoService = yield* Crypto.Crypto;\n const digest = yield* cryptoService\n .digest(\"SHA-256\", new TextEncoder().encode(value))\n .pipe(Effect.mapError((cause) => new CryptoError({ message: cause.message })));\n return [...digest].map((byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n});\n\nexport const sha256Json = Effect.fn(\"Digest.sha256Json\")((value: Json) =>\n Effect.try({\n try: () => stringify(value),\n catch: (cause) =>\n new CryptoError({ message: cause instanceof Error ? cause.message : String(cause) }),\n }).pipe(Effect.flatMap(sha256Text)),\n);\n\nfunction sha256EncodedProgram<S extends Schema.Constraint>(\n schema: S,\n value: S[\"Type\"],\n): Effect.Effect<string, CryptoError, Crypto.Crypto | S[\"EncodingServices\"]> {\n return Schema.encodeEffect(schema)(value).pipe(\n Effect.mapError((cause) => new CryptoError({ message: cause.message })),\n Effect.flatMap(Schema.decodeUnknownEffect(Schema.Json)),\n Effect.mapError((cause) => new CryptoError({ message: cause.message })),\n Effect.flatMap(sha256Json),\n );\n}\n\nexport const sha256Encoded = Effect.fn(\"Digest.sha256Encoded\")(sha256EncodedProgram);\n\n/** Portable Web Crypto implementation for hosts that want a ready-made Layer. */\nexport const webCryptoLayer: Layer.Layer<Crypto.Crypto> = Layer.succeed(\n Crypto.Crypto,\n Crypto.make({\n randomBytes: (size) => crypto.getRandomValues(new Uint8Array(size)),\n digest: (algorithm, data) =>\n Effect.tryPromise({\n try: async () => {\n const bytes = new Uint8Array(data.byteLength);\n bytes.set(data);\n return new Uint8Array(await crypto.subtle.digest(algorithm, bytes.buffer));\n },\n catch: (cause) =>\n PlatformError.systemError({\n _tag: \"Unknown\",\n module: \"WebCrypto\",\n method: \"digest\",\n cause,\n }),\n }),\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":";;;;;AAEA,IAAaA,UAAb,cAA2B,OAAO,YAAmB,CAAC,CAAC,qBAAqB,EAC1E,SAAS,OAAO,OAClB,CAAC,CAAC,CAAC,CAAC;;;;;;;;ACAJ,MAAM,eAAe;AAErB,MAAMC,SAAOC,OAAE,OAAO,MACpBA,OAAE,YACC,UACC,MAAM,UAAU,OAChB,MAAM,SAAS,GAAG,KAClB,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,UAAU,aAAa,KAAK,KAAK,CAAC,IACtD,KAAA,IACA,uCACN,EAAE,YAAY,aAAa,CAC7B,CACF,CAAC,CAAC,KAAKA,OAAE,MAAM,YAAY,CAAC;;AAM5B,MAAaC,WAASD,OAAE,OAAO,KAC7BA,OAAE,SACAD,QACA,qBAAqB,gBAAgB;CACnC,SAAS,OAAO,YACd,OAAO,IAAI;EACT,WAAW,UAAU,KAAK;EAC1B,QAAQ,UACN,IAAI,YAAY,aACd,EAAE,SAAS,iBAAiB,QAAQ,MAAM,UAAU,O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