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
package/README.md
CHANGED
|
@@ -54,11 +54,13 @@ and incompatible state becomes a conflict. DomainKit never silently overwrites D
|
|
|
54
54
|
|
|
55
55
|
- `domainkit` — canonical Effect services, schemas, plans, providers, and verification;
|
|
56
56
|
- `domainkit/promise` — Promise adapters for foreign-runtime boundaries;
|
|
57
|
+
- `domainkit/server` — Effect-first provider connection routes with an async Web handler factory;
|
|
57
58
|
- `domainkit/testing` — in-memory services and provider conformance helpers.
|
|
58
59
|
|
|
59
60
|
Provider credentials, OAuth state, durable connections, plans, receipts, authorization, and audit
|
|
60
61
|
history remain owned by your application. DomainKit supplies the domain model and operations, not a
|
|
61
|
-
hosted control plane.
|
|
62
|
+
hosted control plane. Cloudflare's provider namespace includes credential refresh, while the host
|
|
63
|
+
owns refresh locking, encrypted rotation, retry policy, and reconnect UX.
|
|
62
64
|
|
|
63
65
|
## Learn more
|
|
64
66
|
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Context, Crypto, Data, Effect, Layer, PlatformError, Schema, SchemaIssue, SchemaTransformation } from "effect";
|
|
3
|
+
//#region src/invalid-input.ts
|
|
4
|
+
var invalid_input_exports = /* @__PURE__ */ __exportAll({ Error: () => Error$2 });
|
|
5
|
+
var Error$2 = class extends Schema.TaggedError()("InvalidInputError", { message: Schema.String }) {};
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/domain/domain-name.ts
|
|
8
|
+
var domain_name_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
Schema: () => Schema$2,
|
|
10
|
+
decode: () => decode$3,
|
|
11
|
+
parse: () => parse
|
|
12
|
+
});
|
|
13
|
+
const labelPattern = /^[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9_])?$/;
|
|
14
|
+
const Type = 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"));
|
|
15
|
+
/** Decodes user and wire strings into canonical domain names. */
|
|
16
|
+
const Schema$2 = Schema.String.pipe(Schema.decodeTo(Type, SchemaTransformation.transformOrFail({
|
|
17
|
+
decode: (input, options) => Effect.try({
|
|
18
|
+
try: () => normalize(input),
|
|
19
|
+
catch: (cause) => new SchemaIssue.InvalidValue({ message: cause instanceof Error ? cause.message : String(cause) }, input, options)
|
|
20
|
+
}),
|
|
21
|
+
encode: (domain) => Effect.succeed(domain)
|
|
22
|
+
})));
|
|
23
|
+
const decode$3 = Effect.fn("DomainName.decode")((input) => Schema.decodeUnknownEffect(Schema$2)(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
|
|
24
|
+
function parse(input) {
|
|
25
|
+
try {
|
|
26
|
+
return Schema.decodeUnknownSync(Schema$2)(input);
|
|
27
|
+
} catch (cause) {
|
|
28
|
+
throw new Error$2({ message: cause instanceof Error ? cause.message : String(cause) });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function normalize(input) {
|
|
32
|
+
return input.trim().replace(/\.+$/, "").split(".").map((label) => {
|
|
33
|
+
if (label.includes("_") || [...label].every((character) => character.charCodeAt(0) <= 127)) return label.toLowerCase();
|
|
34
|
+
const normalized = new URL(`http://${label}.example`).hostname.split(".")[0];
|
|
35
|
+
if (normalized === void 0) throw new Error("Domain label could not be normalized");
|
|
36
|
+
return normalized.toLowerCase();
|
|
37
|
+
}).join(".");
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/auth/connection.ts
|
|
41
|
+
/** A provider account and authoritative zone selected for one domain attachment. */
|
|
42
|
+
const ProviderTargetEvidence = Schema.Struct({
|
|
43
|
+
/** The account display name observed during discovery, when the provider exposes one. */
|
|
44
|
+
accountName: Schema.optionalKey(Schema.String),
|
|
45
|
+
/** Nameserver and provider-state evidence observed during discovery. */
|
|
46
|
+
nameservers: Schema.Array(Schema$2),
|
|
47
|
+
status: Schema.String,
|
|
48
|
+
/** Provider-specific authoritative-zone type, such as Cloudflare's `full` or Vercel's `external`. */
|
|
49
|
+
zoneType: Schema.String
|
|
50
|
+
});
|
|
51
|
+
const ProviderTarget = Schema.Struct({
|
|
52
|
+
accountId: Schema.String,
|
|
53
|
+
accountKind: Schema.NullOr(Schema.Literals([
|
|
54
|
+
"account",
|
|
55
|
+
"personal",
|
|
56
|
+
"team"
|
|
57
|
+
])),
|
|
58
|
+
evidence: Schema.optionalKey(ProviderTargetEvidence),
|
|
59
|
+
zoneId: Schema.String,
|
|
60
|
+
zoneName: Schema$2
|
|
61
|
+
});
|
|
62
|
+
/** The lifecycle state visible to a host for an organization connection. */
|
|
63
|
+
const ConnectionStatus = Schema.Literals([
|
|
64
|
+
"active",
|
|
65
|
+
"expired",
|
|
66
|
+
"revocation-pending"
|
|
67
|
+
]);
|
|
68
|
+
/** An organization-scoped provider connection. */
|
|
69
|
+
const ProviderConnection = Schema.Struct({
|
|
70
|
+
createdAt: Schema.DateFromString,
|
|
71
|
+
id: Schema.String,
|
|
72
|
+
method: Schema.Literals([
|
|
73
|
+
"integration",
|
|
74
|
+
"oauth2",
|
|
75
|
+
"token"
|
|
76
|
+
]),
|
|
77
|
+
ownerId: Schema.String,
|
|
78
|
+
providerId: Schema.String,
|
|
79
|
+
status: ConnectionStatus
|
|
80
|
+
});
|
|
81
|
+
/** An exact provider target attached to one organization domain. */
|
|
82
|
+
const DomainAttachment = Schema.Struct({
|
|
83
|
+
connectionId: Schema.String,
|
|
84
|
+
createdAt: Schema.DateFromString,
|
|
85
|
+
domain: Schema$2,
|
|
86
|
+
id: Schema.String,
|
|
87
|
+
target: ProviderTarget
|
|
88
|
+
});
|
|
89
|
+
/** Internal connection row; the authorization id is intentionally not part of the public shape. */
|
|
90
|
+
const StoredConnection = 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 = 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({
|
|
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$2({ message: cause.message }))));
|
|
121
|
+
const validate$1 = Effect.fn("ProviderConnection.validate")((input) => Schema.decodeUnknownEffect(Schema.toType(ProviderConnection))(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
|
|
122
|
+
const encode$2 = Schema.encodeSync(ProviderConnection);
|
|
123
|
+
/** Derive a public connection projection from its private authorization state. */
|
|
124
|
+
function project(connection, authorization, credential, now = /* @__PURE__ */ new Date()) {
|
|
125
|
+
const status = authorization.revocation._tag === "Pending" ? "revocation-pending" : credential.refreshToken === null && credential.expiresAt !== null && (Number.isNaN(credential.expiresAt.valueOf()) || credential.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
|
+
const credentialStatus = "status" in input.connection ? input.connection.status : input.credential === void 0 ? null : project(input.connection, input.authorization, input.credential, input.now).status;
|
|
138
|
+
if (input.connection.providerId !== input.providerId || input.authorization.providerId !== input.providerId || input.authorization.revocation._tag !== "Active" || input.attachment.connectionId !== input.connection.id || credentialStatus !== "active") throw authorizationError("Domain attachment is not active for this provider", "Connection.assertAttachment");
|
|
139
|
+
if (!input.authorization.requiredCapabilities.includes(input.capability)) throw authorizationError(`Provider authorization lacks the ${input.capability} capability`, "Connection.assertAttachment");
|
|
140
|
+
if (!input.authorization.capabilityEvidence.some((item) => item.capability === input.capability)) throw authorizationError(`Provider authorization has no evidence for the ${input.capability} capability`, "Connection.assertAttachment");
|
|
141
|
+
let domain;
|
|
142
|
+
try {
|
|
143
|
+
domain = parse(input.domain);
|
|
144
|
+
} catch (cause) {
|
|
145
|
+
if (cause instanceof Error$2) throw cause;
|
|
146
|
+
throw new Error$2({ message: cause instanceof Error ? cause.message : String(cause) });
|
|
147
|
+
}
|
|
148
|
+
if (input.attachment.domain !== domain && !domain.endsWith(`.${input.attachment.domain}`)) throw authorizationError("Domain attachment does not match the requested domain", "Connection.assertAttachment");
|
|
149
|
+
return domain;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/auth/provider-context.ts
|
|
153
|
+
var provider_context_exports = /* @__PURE__ */ __exportAll({
|
|
154
|
+
Envelope: () => Envelope,
|
|
155
|
+
codec: () => codec,
|
|
156
|
+
decode: () => decode$1,
|
|
157
|
+
encode: () => encode$1
|
|
158
|
+
});
|
|
159
|
+
/** A provider-owned, versioned, non-secret context value persisted by the host. */
|
|
160
|
+
const Envelope = Schema.Struct({
|
|
161
|
+
value: Schema.Json,
|
|
162
|
+
version: Schema.String
|
|
163
|
+
});
|
|
164
|
+
/** Build an adapter-owned context codec from a schema and stable version identifier. */
|
|
165
|
+
function codec(version, schema) {
|
|
166
|
+
return {
|
|
167
|
+
decode: Effect.fn("ProviderContext.decode")((envelope) => envelope.version !== version ? Effect.fail(new Error$2({ message: `Unsupported provider context version: ${envelope.version}` })) : Schema.decodeUnknownEffect(schema)(envelope.value).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message })))),
|
|
168
|
+
encode: Effect.fn("ProviderContext.encode")((value) => Schema.encodeEffect(schema)(value).pipe(Effect.flatMap((encoded) => Schema.decodeUnknownEffect(Schema.Json)(encoded)), Effect.map((encoded) => ({
|
|
169
|
+
value: encoded,
|
|
170
|
+
version
|
|
171
|
+
})), Effect.mapError((cause) => new Error$2({ message: cause.message })))),
|
|
172
|
+
version
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const decode$1 = Effect.fn("ProviderContext.Envelope.decode")((input) => Schema.decodeUnknownEffect(Envelope)(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
|
|
176
|
+
const encode$1 = Schema.encodeSync(Envelope);
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/auth/authorization.ts
|
|
179
|
+
var authorization_exports = /* @__PURE__ */ __exportAll({
|
|
180
|
+
Capability: () => Capability,
|
|
181
|
+
CapabilityEvidence: () => CapabilityEvidence,
|
|
182
|
+
Evidence: () => Evidence,
|
|
183
|
+
EvidenceSchema: () => EvidenceSchema,
|
|
184
|
+
Revocation: () => Revocation,
|
|
185
|
+
Schema: () => Schema$1,
|
|
186
|
+
decode: () => decode,
|
|
187
|
+
encode: () => encode,
|
|
188
|
+
evidenceFor: () => evidenceFor,
|
|
189
|
+
validate: () => validate
|
|
190
|
+
});
|
|
191
|
+
const Capability = Schema.Literals(["dns:read", "dns:write"]);
|
|
192
|
+
const Evidence = Data.taggedEnum();
|
|
193
|
+
const EvidenceSchema = Schema.TaggedUnion({
|
|
194
|
+
Declared: {},
|
|
195
|
+
Exercised: { observedAt: Schema.DateFromString },
|
|
196
|
+
Introspected: { observedAt: Schema.DateFromString }
|
|
197
|
+
});
|
|
198
|
+
const CapabilityEvidence = Schema.Struct({
|
|
199
|
+
capability: Capability,
|
|
200
|
+
evidence: EvidenceSchema
|
|
201
|
+
});
|
|
202
|
+
const Revocation = Schema.TaggedUnion({
|
|
203
|
+
Active: {},
|
|
204
|
+
Pending: { requestedAt: Schema.DateFromString }
|
|
205
|
+
});
|
|
206
|
+
/** A provider credential authorization shared by one or more organization connections. */
|
|
207
|
+
const Schema$1 = Schema.Struct({
|
|
208
|
+
authorizedById: Schema.String,
|
|
209
|
+
capabilityEvidence: Schema.Array(CapabilityEvidence),
|
|
210
|
+
createdAt: Schema.DateFromString,
|
|
211
|
+
id: Schema.String,
|
|
212
|
+
method: Schema.Literals([
|
|
213
|
+
"integration",
|
|
214
|
+
"oauth2",
|
|
215
|
+
"token"
|
|
216
|
+
]),
|
|
217
|
+
providerContext: Envelope,
|
|
218
|
+
providerId: Schema.String,
|
|
219
|
+
requiredCapabilities: Schema.Array(Capability),
|
|
220
|
+
revocation: Revocation,
|
|
221
|
+
scopes: Schema.Array(Schema.String)
|
|
222
|
+
});
|
|
223
|
+
const decode = Effect.fn("ProviderAuthorization.decode")((input) => Schema.decodeUnknownEffect(Schema$1)(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
|
|
224
|
+
const validate = Effect.fn("ProviderAuthorization.validate")((input) => Schema.decodeUnknownEffect(Schema.toType(Schema$1))(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
|
|
225
|
+
const encode = Schema.encodeSync(Schema$1);
|
|
226
|
+
function evidenceFor(authorization, capability) {
|
|
227
|
+
return authorization.capabilityEvidence.find((item) => item.capability === capability)?.evidence;
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/auth/lifecycle-repository.ts
|
|
231
|
+
/** Serializable durable state. Credential material is deliberately sealed separately. */
|
|
232
|
+
const AggregateSchema = Schema.Struct({
|
|
233
|
+
authorization: Schema$1,
|
|
234
|
+
connections: Schema.Array(StoredConnection),
|
|
235
|
+
attachments: Schema.Array(DomainAttachment)
|
|
236
|
+
});
|
|
237
|
+
var Error$1 = class extends Schema.TaggedError()("ManagedDnsLifecycleError", {
|
|
238
|
+
category: Schema.Literal("storage"),
|
|
239
|
+
message: Schema.String,
|
|
240
|
+
operation: Schema.String,
|
|
241
|
+
retry: Schema.Literals([
|
|
242
|
+
"never",
|
|
243
|
+
"after-user-action",
|
|
244
|
+
"safe",
|
|
245
|
+
"unknown"
|
|
246
|
+
])
|
|
247
|
+
}) {};
|
|
248
|
+
var Service = class extends Context.Service()("@domainkit/ManagedDnsConnections") {};
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/plan/canonical-json.ts
|
|
251
|
+
var canonical_json_exports = /* @__PURE__ */ __exportAll({
|
|
252
|
+
CryptoError: () => CryptoError,
|
|
253
|
+
sha256Encoded: () => sha256Encoded,
|
|
254
|
+
sha256Json: () => sha256Json,
|
|
255
|
+
sha256Text: () => sha256Text,
|
|
256
|
+
stringify: () => stringify,
|
|
257
|
+
webCryptoLayer: () => webCryptoLayer
|
|
258
|
+
});
|
|
259
|
+
var CryptoError = class extends Schema.TaggedError()("CryptoError", { message: Schema.String }) {};
|
|
260
|
+
/** Deterministic JSON serialization for already schema-encoded protocol values. */
|
|
261
|
+
function stringify(value) {
|
|
262
|
+
if (value === null || typeof value !== "object") {
|
|
263
|
+
const encoded = JSON.stringify(value);
|
|
264
|
+
if (encoded === void 0) throw new TypeError("Value is not representable as JSON");
|
|
265
|
+
return encoded;
|
|
266
|
+
}
|
|
267
|
+
if (isJsonArray(value)) return `[${value.map(stringify).join(",")}]`;
|
|
268
|
+
return `{${Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${stringify(entry)}`).join(",")}}`;
|
|
269
|
+
}
|
|
270
|
+
function isJsonArray(value) {
|
|
271
|
+
return Array.isArray(value);
|
|
272
|
+
}
|
|
273
|
+
const sha256Text = Effect.fn("Digest.sha256Text")(function* (value) {
|
|
274
|
+
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("");
|
|
275
|
+
});
|
|
276
|
+
const sha256Json = Effect.fn("Digest.sha256Json")((value) => Effect.try({
|
|
277
|
+
try: () => stringify(value),
|
|
278
|
+
catch: (cause) => new CryptoError({ message: cause instanceof Error ? cause.message : String(cause) })
|
|
279
|
+
}).pipe(Effect.flatMap(sha256Text)));
|
|
280
|
+
function sha256EncodedProgram(schema, value) {
|
|
281
|
+
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));
|
|
282
|
+
}
|
|
283
|
+
const sha256Encoded = Effect.fn("Digest.sha256Encoded")(sha256EncodedProgram);
|
|
284
|
+
/** Portable Web Crypto implementation for hosts that want a ready-made Layer. */
|
|
285
|
+
const webCryptoLayer = Layer.succeed(Crypto.Crypto, Crypto.make({
|
|
286
|
+
randomBytes: (size) => crypto.getRandomValues(new Uint8Array(size)),
|
|
287
|
+
digest: (algorithm, data) => Effect.tryPromise({
|
|
288
|
+
try: async () => {
|
|
289
|
+
const bytes = new Uint8Array(data.byteLength);
|
|
290
|
+
bytes.set(data);
|
|
291
|
+
return new Uint8Array(await crypto.subtle.digest(algorithm, bytes.buffer));
|
|
292
|
+
},
|
|
293
|
+
catch: (cause) => PlatformError.systemError({
|
|
294
|
+
_tag: "Unknown",
|
|
295
|
+
module: "WebCrypto",
|
|
296
|
+
method: "digest",
|
|
297
|
+
cause
|
|
298
|
+
})
|
|
299
|
+
})
|
|
300
|
+
}));
|
|
301
|
+
//#endregion
|
|
302
|
+
export { invalid_input_exports as A, project as C, domain_name_exports as D, decode$3 as E, parse as O, encode$2 as S, Schema$2 as T, ProviderTargetEvidence as _, AggregateSchema as a, authorizationError as b, Evidence as c, provider_context_exports as d, AuthorizationError as f, ProviderTarget as g, ProviderConnection as h, webCryptoLayer as i, Error$2 as k, authorization_exports as l, DomainAttachment as m, sha256Encoded as n, Error$1 as o, ConnectionStatus as p, stringify as r, Service as s, canonical_json_exports as t, codec as u, StoredConnection as v, validate$1 as w, decode$2 as x, assertAttachment as y };
|
|
303
|
+
|
|
304
|
+
//# sourceMappingURL=canonical-json-9x7gHIoS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-json-9x7gHIoS.mjs","names":["Error","S","Schema","decode","InvalidInputError","S","DomainName.Schema","decode","InvalidInputError","validate","encode","DomainName.parse","InvalidInputError","decode","encode","S","Schema","ProviderContext.Envelope","InvalidInputError","ProviderAuthorization.Schema","Connection.StoredConnection","Connection.DomainAttachment","Error"],"sources":["../src/invalid-input.ts","../src/domain/domain-name.ts","../src/auth/connection.ts","../src/auth/provider-context.ts","../src/auth/authorization.ts","../src/auth/lifecycle-repository.ts","../src/plan/canonical-json.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 { Effect, Schema as S } from \"effect\";\n\nimport * as DomainName from \"../domain/domain-name.ts\";\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\nimport type { OAuthMethod } from \"./manifest.ts\";\nimport type * as ProviderAuthorization from \"./authorization.ts\";\nimport type { Value as Secret } from \"./secret.ts\";\n\n/** A provider account and authoritative zone selected for one domain attachment. */\nexport const ProviderTargetEvidence = S.Struct({\n /** The account display name observed during discovery, when the provider exposes one. */\n accountName: S.optionalKey(S.String),\n /** Nameserver and provider-state evidence observed during discovery. */\n nameservers: S.Array(DomainName.Schema),\n status: S.String,\n /** Provider-specific authoritative-zone type, such as Cloudflare's `full` or Vercel's `external`. */\n zoneType: S.String,\n});\nexport interface ProviderTargetEvidence extends S.Schema.Type<typeof ProviderTargetEvidence> {}\n\nexport const ProviderTarget = S.Struct({\n accountId: S.String,\n accountKind: S.NullOr(S.Literals([\"account\", \"personal\", \"team\"])),\n evidence: S.optionalKey(ProviderTargetEvidence),\n zoneId: S.String,\n zoneName: DomainName.Schema,\n});\nexport interface ProviderTarget extends S.Schema.Type<typeof ProviderTarget> {}\n\n/** The lifecycle state visible to a host for an organization connection. */\nexport const ConnectionStatus = S.Literals([\"active\", \"expired\", \"revocation-pending\"]);\nexport type ConnectionStatus = typeof ConnectionStatus.Type;\n\n/** An organization-scoped provider connection. */\nexport const ProviderConnection = S.Struct({\n createdAt: S.DateFromString,\n id: S.String,\n method: S.Literals([\"integration\", \"oauth2\", \"token\"]),\n ownerId: S.String,\n providerId: S.String,\n status: ConnectionStatus,\n});\nexport interface ProviderConnection extends S.Schema.Type<typeof ProviderConnection> {}\n\n/** An exact provider target attached to one organization domain. */\nexport const DomainAttachment = S.Struct({\n connectionId: S.String,\n createdAt: S.DateFromString,\n domain: DomainName.Schema,\n id: S.String,\n target: ProviderTarget,\n});\nexport interface DomainAttachment extends S.Schema.Type<typeof DomainAttachment> {}\n\n/** Internal connection row; the authorization id is intentionally not part of the public shape. */\nexport const StoredConnection = S.Struct({\n authorizationId: S.String,\n createdAt: S.DateFromString,\n id: S.String,\n method: S.Literals([\"integration\", \"oauth2\", \"token\"]),\n ownerId: S.String,\n providerId: S.String,\n});\nexport interface StoredConnection extends S.Schema.Type<typeof StoredConnection> {}\n\n/** Internal credential material retained by the host's persistence implementation. */\nexport interface StoredCredential {\n readonly accessToken: Secret;\n readonly expiresAt: Date | null;\n readonly refreshToken: Secret | null;\n readonly tokenType: string;\n}\n\n/** The provider context carried through an interactive connection continuation. */\nexport interface OAuthContinuation {\n readonly clientId: string;\n readonly codeVerifier: Secret;\n readonly expiresAt: Date;\n readonly authorizationId?: string;\n readonly method: OAuthMethod;\n readonly ownerId: string;\n readonly redirectUri: string;\n readonly stateHash: string;\n readonly authorizedById: string;\n}\n\nexport class AuthorizationError extends S.TaggedError<AuthorizationError>()(\"AuthorizationError\", {\n category: S.Literal(\"authorization\"),\n message: S.String,\n operation: S.String,\n retry: S.Literals([\"never\", \"after-user-action\", \"safe\", \"unknown\"]),\n}) {}\n\nexport const authorizationError = (message: string, operation: string): AuthorizationError =>\n new AuthorizationError({\n category: \"authorization\",\n message,\n operation,\n retry: \"after-user-action\",\n });\n\n/** Decode a public connection snapshot returned by a host. */\nexport const decode = Effect.fn(\"ProviderConnection.decode\")((input: unknown) =>\n S.decodeUnknownEffect(ProviderConnection)(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\n\nexport const validate = Effect.fn(\"ProviderConnection.validate\")((input: unknown) =>\n S.decodeUnknownEffect(S.toType(ProviderConnection))(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\n\nexport const encode = S.encodeSync(ProviderConnection);\n\n/** Derive a public connection projection from its private authorization state. */\nexport function project(\n connection: StoredConnection,\n authorization: ProviderAuthorization.ProviderAuthorization,\n credential: StoredCredential,\n now = new Date(),\n): ProviderConnection {\n const status: ConnectionStatus =\n authorization.revocation._tag === \"Pending\"\n ? \"revocation-pending\"\n : credential.refreshToken === null &&\n credential.expiresAt !== null &&\n (Number.isNaN(credential.expiresAt.valueOf()) || credential.expiresAt <= now)\n ? \"expired\"\n : \"active\";\n return {\n createdAt: connection.createdAt,\n id: connection.id,\n method: connection.method,\n ownerId: connection.ownerId,\n providerId: connection.providerId,\n status,\n };\n}\n\n/** Assert that an exact attachment is usable for one DNS operation. */\nexport function assertAttachment(input: {\n readonly attachment: DomainAttachment;\n readonly authorization: ProviderAuthorization.ProviderAuthorization;\n readonly capability: ProviderAuthorization.Capability;\n readonly connection: StoredConnection | ProviderConnection;\n readonly credential?: StoredCredential;\n readonly domain: string;\n readonly now?: Date;\n readonly providerId: string;\n}): DomainName.DomainName {\n const credentialStatus =\n \"status\" in input.connection\n ? input.connection.status\n : input.credential === undefined\n ? null\n : project(input.connection, input.authorization, input.credential, input.now).status;\n if (\n input.connection.providerId !== input.providerId ||\n input.authorization.providerId !== input.providerId ||\n input.authorization.revocation._tag !== \"Active\" ||\n input.attachment.connectionId !== input.connection.id ||\n credentialStatus !== \"active\"\n ) {\n throw authorizationError(\n \"Domain attachment is not active for this provider\",\n \"Connection.assertAttachment\",\n );\n }\n if (!input.authorization.requiredCapabilities.includes(input.capability)) {\n throw authorizationError(\n `Provider authorization lacks the ${input.capability} capability`,\n \"Connection.assertAttachment\",\n );\n }\n if (\n !input.authorization.capabilityEvidence.some((item) => item.capability === input.capability)\n ) {\n throw authorizationError(\n `Provider authorization has no evidence for the ${input.capability} capability`,\n \"Connection.assertAttachment\",\n );\n }\n let domain: DomainName.DomainName;\n try {\n domain = DomainName.parse(input.domain);\n } catch (cause) {\n if (cause instanceof InvalidInputError) throw cause;\n throw new InvalidInputError({\n message: cause instanceof Error ? cause.message : String(cause),\n });\n }\n if (input.attachment.domain !== domain && !domain.endsWith(`.${input.attachment.domain}`)) {\n throw authorizationError(\n \"Domain attachment does not match the requested domain\",\n \"Connection.assertAttachment\",\n );\n }\n return domain;\n}\n","import { Effect, Schema } from \"effect\";\n\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\n\n/** A provider-owned, versioned, non-secret context value persisted by the host. */\nexport const Envelope = Schema.Struct({\n value: Schema.Json,\n version: Schema.String,\n});\nexport interface Envelope extends Schema.Schema.Type<typeof Envelope> {}\n\nexport interface Codec<A> {\n readonly decode: (envelope: Envelope) => Effect.Effect<A, InvalidInputError>;\n readonly encode: (value: A) => Effect.Effect<Envelope, InvalidInputError>;\n readonly version: string;\n}\n\n/** Build an adapter-owned context codec from a schema and stable version identifier. */\nexport function codec<A, I>(version: string, schema: Schema.Codec<A, I>): Codec<A> {\n return {\n decode: Effect.fn(\"ProviderContext.decode\")((envelope) =>\n envelope.version !== version\n ? Effect.fail(\n new InvalidInputError({\n message: `Unsupported provider context version: ${envelope.version}`,\n }),\n )\n : Schema.decodeUnknownEffect(schema)(envelope.value).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n ),\n encode: Effect.fn(\"ProviderContext.encode\")((value) =>\n Schema.encodeEffect(schema)(value).pipe(\n Effect.flatMap((encoded) => Schema.decodeUnknownEffect(Schema.Json)(encoded)),\n Effect.map((encoded) => ({ value: encoded, version })),\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n ),\n version,\n };\n}\n\nexport const decode = Effect.fn(\"ProviderContext.Envelope.decode\")((input: unknown) =>\n Schema.decodeUnknownEffect(Envelope)(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\n\nexport const encode = Schema.encodeSync(Envelope);\n","import { Data, Effect, Schema as S } from \"effect\";\n\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\nimport * as ProviderContext from \"./provider-context.ts\";\n\nexport const Capability = S.Literals([\"dns:read\", \"dns:write\"]);\nexport type Capability = typeof Capability.Type;\n\nexport type Evidence = Data.TaggedEnum<{\n Declared: {};\n Exercised: { readonly observedAt: Date };\n Introspected: { readonly observedAt: Date };\n}>;\nexport const Evidence = Data.taggedEnum<Evidence>();\n\nexport const EvidenceSchema = S.TaggedUnion({\n Declared: {},\n Exercised: { observedAt: S.DateFromString },\n Introspected: { observedAt: S.DateFromString },\n});\n\nexport const CapabilityEvidence = S.Struct({\n capability: Capability,\n evidence: EvidenceSchema,\n});\nexport interface CapabilityEvidence extends S.Schema.Type<typeof CapabilityEvidence> {}\n\nexport const Revocation = S.TaggedUnion({\n Active: {},\n Pending: { requestedAt: S.DateFromString },\n});\nexport type Revocation = typeof Revocation.Type;\n\n/** A provider credential authorization shared by one or more organization connections. */\nexport const Schema = S.Struct({\n authorizedById: S.String,\n capabilityEvidence: S.Array(CapabilityEvidence),\n createdAt: S.DateFromString,\n id: S.String,\n method: S.Literals([\"integration\", \"oauth2\", \"token\"]),\n providerContext: ProviderContext.Envelope,\n providerId: S.String,\n requiredCapabilities: S.Array(Capability),\n revocation: Revocation,\n scopes: S.Array(S.String),\n});\nexport interface ProviderAuthorization extends S.Schema.Type<typeof Schema> {}\n\nexport const decode = Effect.fn(\"ProviderAuthorization.decode\")((input: unknown) =>\n S.decodeUnknownEffect(Schema)(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\n\nexport const validate = Effect.fn(\"ProviderAuthorization.validate\")((input: unknown) =>\n S.decodeUnknownEffect(S.toType(Schema))(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\n\nexport const encode = S.encodeSync(Schema);\n\nexport function evidenceFor(\n authorization: ProviderAuthorization,\n capability: Capability,\n): Evidence | undefined {\n return authorization.capabilityEvidence.find((item) => item.capability === capability)?.evidence;\n}\n","import { Context, Effect, Schema } from \"effect\";\n\nimport * as ProviderAuthorization from \"./authorization.ts\";\nimport * as Connection from \"./connection.ts\";\n\n/** Private aggregate owned by the managed-DNS persistence capability. */\nexport interface Aggregate {\n readonly authorization: ProviderAuthorization.ProviderAuthorization;\n readonly connections: ReadonlyArray<Connection.StoredConnection>;\n readonly attachments: ReadonlyArray<Connection.DomainAttachment>;\n readonly credential: Connection.StoredCredential;\n}\n\n/** Serializable durable state. Credential material is deliberately sealed separately. */\nexport const AggregateSchema = Schema.Struct({\n authorization: ProviderAuthorization.Schema,\n connections: Schema.Array(Connection.StoredConnection),\n attachments: Schema.Array(Connection.DomainAttachment),\n});\n\nexport interface ConnectInput {\n readonly authorization: ProviderAuthorization.ProviderAuthorization;\n readonly connection: Connection.StoredConnection;\n readonly credential: Connection.StoredCredential;\n /** The authorization id observed before building a reuse update, if any. */\n readonly expectedAuthorizationId?: string;\n /** The owner connection id observed before building a reuse update, if any. */\n readonly expectedConnectionId?: string;\n}\n\nexport interface AttachmentResult {\n readonly attachment: Connection.DomainAttachment;\n readonly connection: Connection.ProviderConnection;\n}\n\nexport interface DetachResult {\n readonly attachment: Connection.DomainAttachment;\n readonly connection: Connection.ProviderConnection;\n readonly remainingAttachments: number;\n}\n\nexport interface DisconnectResult {\n readonly connection: Connection.ProviderConnection;\n readonly remainingConnections: number;\n readonly revokedAuthorization: boolean;\n}\n\nexport class Error extends Schema.TaggedError<Error>()(\"ManagedDnsLifecycleError\", {\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\n/**\n * Persistence capability for the managed-DNS model.\n *\n * Implementations own the atomic aggregate containing one provider credential authorization,\n * organization connections, and exact domain attachments. Provider authorization is deliberately\n * an implementation detail of the capability; public callers operate on the projections returned\n * by the connection and attachment methods.\n */\nexport interface Interface {\n readonly attach: (input: {\n readonly attachment: Connection.DomainAttachment;\n readonly connectionId: string;\n readonly ownerId: string;\n }) => Effect.Effect<AttachmentResult, Error>;\n readonly connect: (input: ConnectInput) => Effect.Effect<Aggregate, Error>;\n readonly detach: (input: {\n readonly attachmentId: string;\n readonly ownerId: string;\n }) => Effect.Effect<DetachResult, Error>;\n readonly disconnect: <E>(input: {\n readonly connectionId: string;\n readonly ownerId: string;\n readonly revoke: (\n authorization: ProviderAuthorization.ProviderAuthorization,\n ) => Effect.Effect<void, E>;\n }) => Effect.Effect<DisconnectResult, Error | E>;\n readonly findConnection: (\n ownerId: string,\n authorizationId: string,\n ) => Effect.Effect<Connection.StoredConnection | null, Error>;\n readonly get: (authorizationId: string) => Effect.Effect<Aggregate | null, Error>;\n readonly getAttachment: (\n attachmentId: string,\n ) => Effect.Effect<Connection.DomainAttachment | null, Error>;\n readonly getByConnectionId: (connectionId: string) => Effect.Effect<Aggregate | null, Error>;\n readonly listAttachments: (\n connectionId: string,\n ownerId: string,\n ) => Effect.Effect<ReadonlyArray<Connection.DomainAttachment>, 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: (\n authorization: ProviderAuthorization.ProviderAuthorization,\n ) => Effect.Effect<void, E>;\n }) => Effect.Effect<DisconnectResult, Error | E>;\n readonly rotate: (\n authorizationId: string,\n credential: Connection.StoredCredential,\n ) => Effect.Effect<Aggregate, Error>;\n}\n\nexport class Service extends Context.Service<Service, Interface>()(\n \"@domainkit/ManagedDnsConnections\",\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"],"mappings":";;;;AAEA,IAAaA,UAAb,cAA2B,OAAO,YAAmB,CAAC,CAAC,qBAAqB,EAC1E,SAAS,OAAO,OAClB,CAAC,CAAC,CAAC,CAAC;;;;;;;;ACAJ,MAAM,eAAe;AAErB,MAAM,OAAOC,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,SACA,MACA,qBAAqB,gBAAgB;CACnC,SAAS,OAAO,YACd,OAAO,IAAI;EACT,WAAW,UAAU,KAAK;EAC1B,QAAQ,UACN,IAAI,YAAY,aACd,EAAE,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAClE,OACA,OACF;CACJ,CAAC;C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