domainkit 0.1.1 → 0.2.1
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 +87 -83
- package/dist/{client-BnD7QLRF.mjs → auth-6-KRy1gN.mjs} +235 -131
- package/dist/auth-6-KRy1gN.mjs.map +1 -0
- package/dist/{auth-B0owkrpk.mjs → auth-B4jq3yk3.mjs} +212 -20
- package/dist/auth-B4jq3yk3.mjs.map +1 -0
- package/dist/authorization-CQSKKMrW.mjs +255 -0
- package/dist/authorization-CQSKKMrW.mjs.map +1 -0
- package/dist/canonical-json-CpvqGMcr.mjs +57 -0
- package/dist/canonical-json-CpvqGMcr.mjs.map +1 -0
- package/dist/{cloudflare-D0-J2MfP.mjs → cloudflare-Bg_p-M2c.mjs} +26 -3
- package/dist/cloudflare-Bg_p-M2c.mjs.map +1 -0
- package/dist/cloudflare-FDl5q7Dm.d.mts +32 -0
- package/dist/cloudflare.d.mts +3 -3
- package/dist/cloudflare.mjs +2 -2
- package/dist/connection-BXoSrhZs.mjs +58 -0
- package/dist/connection-BXoSrhZs.mjs.map +1 -0
- package/dist/connection-CEqadXSm.d.mts +182 -0
- package/dist/connection-X3rZhrBZ.mjs +186 -0
- package/dist/connection-X3rZhrBZ.mjs.map +1 -0
- package/dist/connection-api-DftK7eHo.d.mts +7 -0
- package/dist/{dns-record-C_KwGPLf.mjs → dns-record-BLeqo56C.mjs} +23 -3
- package/dist/dns-record-BLeqo56C.mjs.map +1 -0
- package/dist/effect-cloudflare.d.mts +2 -2
- package/dist/effect-cloudflare.mjs +2 -2
- package/dist/effect-vercel.d.mts +2 -2
- package/dist/effect-vercel.mjs +2 -2
- package/dist/effect.d.mts +9 -46
- package/dist/effect.mjs +29 -7
- package/dist/effect.mjs.map +1 -1
- package/dist/{index-D2howbNz.d.mts → index-B1opsgls.d.mts} +53 -6
- package/dist/{index-CEzk2gbZ.d.mts → index-Ewc__bQu.d.mts} +58 -7
- package/dist/index.d.mts +169 -113
- package/dist/index.mjs +201 -139
- package/dist/index.mjs.map +1 -1
- package/dist/{resolver-BHPsADzE.d.mts → resolver-BbVzTbCX.d.mts} +630 -273
- package/dist/resolver-CxE-VDw4.mjs +598 -0
- package/dist/resolver-CxE-VDw4.mjs.map +1 -0
- package/dist/testing.d.mts +53 -44
- package/dist/testing.mjs +379 -107
- package/dist/testing.mjs.map +1 -1
- package/dist/{vercel-DD89DCqH.mjs → vercel-BIFpZRPu.mjs} +23 -3
- package/dist/vercel-BIFpZRPu.mjs.map +1 -0
- package/dist/vercel-DgJaUX9D.d.mts +31 -0
- package/dist/vercel.d.mts +3 -3
- package/dist/vercel.mjs +2 -2
- package/dist/verify-7_EbKbFM.d.mts +805 -0
- package/dist/verify-Q5RYpnuw.mjs +642 -0
- package/dist/verify-Q5RYpnuw.mjs.map +1 -0
- package/dist/zone-discovery-BA5I24vu.d.mts +1390 -0
- package/dist/zones-DKHTpX9C.mjs +19 -0
- package/dist/zones-DKHTpX9C.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/auth-B0owkrpk.mjs.map +0 -1
- package/dist/client-BnD7QLRF.mjs.map +0 -1
- package/dist/cloudflare-CprjjXfm.d.mts +0 -23
- package/dist/cloudflare-D0-J2MfP.mjs.map +0 -1
- package/dist/dns-record-C_KwGPLf.mjs.map +0 -1
- package/dist/manifest-CP85ePFn.d.mts +0 -583
- package/dist/receipt-CGSnfZQ6.mjs +0 -28
- package/dist/receipt-CGSnfZQ6.mjs.map +0 -1
- package/dist/resolver-tEXpKxmH.mjs +0 -200
- package/dist/resolver-tEXpKxmH.mjs.map +0 -1
- package/dist/vercel-D-E2aqb1.d.mts +0 -22
- package/dist/vercel-DD89DCqH.mjs.map +0 -1
- package/dist/verify-B80xCBh2.d.mts +0 -1407
- package/dist/verify-BXOvXE20.mjs +0 -1388
- package/dist/verify-BXOvXE20.mjs.map +0 -1
|
@@ -1,33 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
var secret_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
-
Value: () => Value,
|
|
7
|
-
make: () => make$1
|
|
8
|
-
});
|
|
9
|
-
/** A deliberately non-serializable credential value. */
|
|
10
|
-
var Value = class Value {
|
|
11
|
-
#value;
|
|
12
|
-
constructor(value) {
|
|
13
|
-
this.#value = value;
|
|
14
|
-
}
|
|
15
|
-
static from(value) {
|
|
16
|
-
if (value.length === 0) throw new Error("Secret values cannot be empty");
|
|
17
|
-
return new Value(value);
|
|
18
|
-
}
|
|
19
|
-
expose() {
|
|
20
|
-
return this.#value;
|
|
21
|
-
}
|
|
22
|
-
toJSON() {
|
|
23
|
-
return "[REDACTED]";
|
|
24
|
-
}
|
|
25
|
-
toString() {
|
|
26
|
-
return "[REDACTED]";
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const make$1 = Value.from;
|
|
30
|
-
//#endregion
|
|
2
|
+
import { E as decode$2, c as Opaque, h as decode$3, y as Error } from "./dns-record-BLeqo56C.mjs";
|
|
3
|
+
import { g as Method, h as Error$1, p as make$1, r as Evidence, u as codec } from "./authorization-CQSKKMrW.mjs";
|
|
4
|
+
import { Clock, Effect, Schema } from "effect";
|
|
31
5
|
//#region src/providers/vercel/protocol.ts
|
|
32
6
|
const Pagination = Schema.Struct({
|
|
33
7
|
count: Schema.Number,
|
|
@@ -113,88 +87,6 @@ const IntegrationToken = Schema.Struct({
|
|
|
113
87
|
user_id: Schema.String
|
|
114
88
|
});
|
|
115
89
|
//#endregion
|
|
116
|
-
//#region src/providers/vercel/auth.ts
|
|
117
|
-
var auth_exports = /* @__PURE__ */ __exportAll({
|
|
118
|
-
exchangeCode: () => exchangeCode,
|
|
119
|
-
integrationMethod: () => integrationMethod,
|
|
120
|
-
manifest: () => manifest,
|
|
121
|
-
tokenMethod: () => tokenMethod
|
|
122
|
-
});
|
|
123
|
-
/** Describes Vercel's caller-created personal access-token method. */
|
|
124
|
-
function tokenMethod(capabilities) {
|
|
125
|
-
return {
|
|
126
|
-
_tag: "token",
|
|
127
|
-
capabilities: [...capabilities],
|
|
128
|
-
instructionsUrl: "https://vercel.com/account/settings/tokens"
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
/** Describes Vercel's provider-specific integration installation flow. */
|
|
132
|
-
function integrationMethod(options) {
|
|
133
|
-
return {
|
|
134
|
-
_tag: "integration",
|
|
135
|
-
capabilities: [...options.capabilities],
|
|
136
|
-
installUrl: `https://vercel.com/integrations/${encodeURIComponent(options.slug)}/new`,
|
|
137
|
-
tokenEndpoint: "https://api.vercel.com/oauth/access_token"
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
/** Creates the Vercel token and integration authorization manifest. */
|
|
141
|
-
function manifest(options) {
|
|
142
|
-
return {
|
|
143
|
-
methods: [tokenMethod(options.capabilities), integrationMethod(options)],
|
|
144
|
-
providerId: "vercel"
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
/** Exchanges Vercel's one-time integration code and preserves its account context. */
|
|
148
|
-
const exchangeCode = Effect.fn("VercelAuth.exchangeCode")((options) => Effect.gen(function* () {
|
|
149
|
-
const fetch = options.fetch ?? globalThis.fetch;
|
|
150
|
-
const baseUrl = (options.baseUrl ?? "https://api.vercel.com").replace(/\/$/, "");
|
|
151
|
-
const body = new URLSearchParams({
|
|
152
|
-
client_id: options.clientId,
|
|
153
|
-
client_secret: options.clientSecret.expose(),
|
|
154
|
-
code: options.code.expose(),
|
|
155
|
-
redirect_uri: options.redirectUri
|
|
156
|
-
});
|
|
157
|
-
const response = yield* Effect.tryPromise({
|
|
158
|
-
try: () => fetch(`${baseUrl}/oauth/access_token`, {
|
|
159
|
-
body,
|
|
160
|
-
headers: {
|
|
161
|
-
Accept: "application/json",
|
|
162
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
163
|
-
},
|
|
164
|
-
method: "POST"
|
|
165
|
-
}),
|
|
166
|
-
catch: () => failure$2("exchangeCode", "Vercel token exchange failed", "transport")
|
|
167
|
-
});
|
|
168
|
-
const input = yield* Effect.tryPromise({
|
|
169
|
-
try: () => response.json(),
|
|
170
|
-
catch: () => failure$2("exchangeCode", response.ok ? "Vercel returned a non-JSON token response" : `Vercel token exchange failed with HTTP ${response.status}`, response.ok ? "response" : response.status === 401 ? "authentication" : "request", response.status)
|
|
171
|
-
});
|
|
172
|
-
if (!response.ok) {
|
|
173
|
-
const detail = Schema.decodeUnknownOption(ErrorEnvelope)(input);
|
|
174
|
-
return yield* Effect.fail(failure$2("exchangeCode", detail._tag === "Some" ? detail.value.error.message : `Vercel token exchange failed with HTTP ${response.status}`, response.status === 401 ? "authentication" : "request", response.status, detail._tag === "Some" ? detail.value.error.code : void 0));
|
|
175
|
-
}
|
|
176
|
-
const token = yield* Schema.decodeUnknownEffect(IntegrationToken)(input).pipe(Effect.mapError((cause) => failure$2("exchangeCode", `Vercel token response did not match its API contract: ${cause.message}`, "response", response.status)));
|
|
177
|
-
return {
|
|
178
|
-
accessToken: make$1(token.access_token),
|
|
179
|
-
context: token.team_id === null ? { _tag: "personal" } : {
|
|
180
|
-
_tag: "team",
|
|
181
|
-
teamId: token.team_id
|
|
182
|
-
},
|
|
183
|
-
installationId: token.installation_id ?? null,
|
|
184
|
-
userId: token.user_id
|
|
185
|
-
};
|
|
186
|
-
}));
|
|
187
|
-
function failure$2(operation, message, reason, status, code) {
|
|
188
|
-
return new Error$1({
|
|
189
|
-
...code === void 0 ? {} : { code },
|
|
190
|
-
message,
|
|
191
|
-
operation,
|
|
192
|
-
providerId: "vercel",
|
|
193
|
-
reason,
|
|
194
|
-
...status === void 0 ? {} : { status }
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
//#endregion
|
|
198
90
|
//#region src/providers/vercel/records.ts
|
|
199
91
|
const decode$1 = Effect.fn("VercelRecords.decode")((zone, record) => Effect.gen(function* () {
|
|
200
92
|
const absolute = absoluteNameCandidate(zone, record.name);
|
|
@@ -213,7 +105,7 @@ const decode$1 = Effect.fn("VercelRecords.decode")((zone, record) => Effect.gen(
|
|
|
213
105
|
policy: record.type === "CNAME" ? "exclusive" : "append",
|
|
214
106
|
ttl: record.ttl ?? 60
|
|
215
107
|
};
|
|
216
|
-
const fromRecord = (input) => decode$3(input).pipe(Effect.mapError((cause) => failure$
|
|
108
|
+
const fromRecord = (input) => decode$3(input).pipe(Effect.mapError((cause) => failure$2("decodeRecord", cause.message)));
|
|
217
109
|
switch (record.type) {
|
|
218
110
|
case "A":
|
|
219
111
|
case "AAAA": return yield* fromRecord({
|
|
@@ -240,7 +132,7 @@ const decode$1 = Effect.fn("VercelRecords.decode")((zone, record) => Effect.gen(
|
|
|
240
132
|
});
|
|
241
133
|
case "CAA": {
|
|
242
134
|
const match = record.value.match(/^(\d{1,3})\s+(issue|issuewild|iodef)\s+(?:"((?:\\.|[^"])*)"|(\S.*))$/);
|
|
243
|
-
if (match === null) return yield* Effect.fail(failure$
|
|
135
|
+
if (match === null) return yield* Effect.fail(failure$2("decodeRecord", "Vercel CAA record has an invalid value"));
|
|
244
136
|
return yield* fromRecord({
|
|
245
137
|
...common,
|
|
246
138
|
_tag: "CAA",
|
|
@@ -274,7 +166,7 @@ const decodeOpaque = Effect.fn("VercelRecords.decodeOpaque")((record, name) => S
|
|
|
274
166
|
name,
|
|
275
167
|
providerRecordId: record.id,
|
|
276
168
|
providerType: record.type
|
|
277
|
-
}).pipe(Effect.mapError((cause) => failure$
|
|
169
|
+
}).pipe(Effect.mapError((cause) => failure$2("decodeRecord", cause.message))));
|
|
278
170
|
function encode(zone, record) {
|
|
279
171
|
const common = {
|
|
280
172
|
name: relativeName(zone, record.name),
|
|
@@ -322,7 +214,7 @@ function absoluteNameCandidate(zone, name) {
|
|
|
322
214
|
function relativeName(zone, name) {
|
|
323
215
|
if (name === zone) return "";
|
|
324
216
|
const suffix = `.${zone}`;
|
|
325
|
-
if (!name.endsWith(suffix)) throw failure$
|
|
217
|
+
if (!name.endsWith(suffix)) throw failure$2("encodeRecord", `DNS record ${name} is outside Vercel zone ${zone}`, { reason: "request" });
|
|
326
218
|
return name.slice(0, -suffix.length);
|
|
327
219
|
}
|
|
328
220
|
function escapeQuoted(value) {
|
|
@@ -331,8 +223,8 @@ function escapeQuoted(value) {
|
|
|
331
223
|
function unescapeQuoted(value) {
|
|
332
224
|
return value.replace(/\\([\\"])/g, "$1");
|
|
333
225
|
}
|
|
334
|
-
function failure$
|
|
335
|
-
return new Error
|
|
226
|
+
function failure$2(operation, message, fields = {}) {
|
|
227
|
+
return new Error({
|
|
336
228
|
message,
|
|
337
229
|
operation,
|
|
338
230
|
providerId: "vercel",
|
|
@@ -341,7 +233,17 @@ function failure$1(operation, message, fields = {}) {
|
|
|
341
233
|
}
|
|
342
234
|
//#endregion
|
|
343
235
|
//#region src/providers/vercel/client.ts
|
|
344
|
-
var client_exports = /* @__PURE__ */ __exportAll({
|
|
236
|
+
var client_exports = /* @__PURE__ */ __exportAll({
|
|
237
|
+
discovery: () => discovery,
|
|
238
|
+
make: () => make
|
|
239
|
+
});
|
|
240
|
+
/** Exposes Vercel zone lookup as the optional provider discovery capability. */
|
|
241
|
+
function discovery(client) {
|
|
242
|
+
return {
|
|
243
|
+
listZones: (name) => client.listZones({ name }),
|
|
244
|
+
provider: client
|
|
245
|
+
};
|
|
246
|
+
}
|
|
345
247
|
/** Creates an Effect-native Vercel client without owning the credential lifecycle. */
|
|
346
248
|
function make(options) {
|
|
347
249
|
const fetch = options.fetch ?? globalThis.fetch;
|
|
@@ -363,11 +265,11 @@ function make(options) {
|
|
|
363
265
|
...init?.headers
|
|
364
266
|
}
|
|
365
267
|
}),
|
|
366
|
-
catch: () => failure(operation, "Vercel request failed", { reason: "transport" })
|
|
268
|
+
catch: () => failure$1(operation, "Vercel request failed", { reason: "transport" })
|
|
367
269
|
});
|
|
368
270
|
const body = yield* Effect.tryPromise({
|
|
369
271
|
try: () => response.json(),
|
|
370
|
-
catch: () => failure(operation, response.ok ? "Vercel returned a non-JSON response" : `Vercel request failed with HTTP ${response.status}`, {
|
|
272
|
+
catch: () => failure$1(operation, response.ok ? "Vercel returned a non-JSON response" : `Vercel request failed with HTTP ${response.status}`, {
|
|
371
273
|
reason: response.ok ? "response" : reason(response.status),
|
|
372
274
|
...rateLimit(response),
|
|
373
275
|
status: response.status
|
|
@@ -416,8 +318,8 @@ function make(options) {
|
|
|
416
318
|
}).pipe(Effect.catchTag("ProviderError", (cause) => cause.reason === "not_found" ? Effect.succeed(null) : Effect.fail(cause))));
|
|
417
319
|
const resolveZone = Effect.fn("VercelClient.resolveZone")((name) => Effect.gen(function* () {
|
|
418
320
|
const domain = yield* discoverZone(name);
|
|
419
|
-
if (domain === null) return yield* Effect.fail(failure("resolveZone", `Vercel zone ${name} is not configured for authoritative DNS in the selected account`, { reason: "not_found" }));
|
|
420
|
-
return yield* decode$2(domain.name).pipe(Effect.mapError((cause) => failure("resolveZone", `Vercel returned an invalid storage zone: ${cause.message}`)));
|
|
321
|
+
if (domain === null) return yield* Effect.fail(failure$1("resolveZone", `Vercel zone ${name} is not configured for authoritative DNS in the selected account`, { reason: "not_found" }));
|
|
322
|
+
return yield* decode$2(domain.name).pipe(Effect.mapError((cause) => failure$1("resolveZone", `Vercel returned an invalid storage zone: ${cause.message}`)));
|
|
421
323
|
}));
|
|
422
324
|
const listRecords = Effect.fn("VercelClient.listRecords")((zoneName) => Effect.gen(function* () {
|
|
423
325
|
const storageZone = yield* resolveZone(zoneName);
|
|
@@ -438,7 +340,7 @@ function make(options) {
|
|
|
438
340
|
const storageZone = yield* resolveZone(zoneName);
|
|
439
341
|
const body = yield* Effect.try({
|
|
440
342
|
try: () => encode(storageZone, record),
|
|
441
|
-
catch: (cause) => cause instanceof Error
|
|
343
|
+
catch: (cause) => cause instanceof Error ? cause : failure$1("createRecord", "Vercel record could not be encoded", { reason: "request" })
|
|
442
344
|
});
|
|
443
345
|
const result = yield* request(withContext(`/v2/domains/${encodeURIComponent(storageZone)}/records`), "createRecord", {
|
|
444
346
|
body: JSON.stringify(body),
|
|
@@ -513,8 +415,8 @@ function hasDnsStorage(domain, configuredServiceType = domain.serviceType) {
|
|
|
513
415
|
return configuredServiceType === "zeit.world" || domain.zone === true || domain.intendedNameservers.length > 0;
|
|
514
416
|
}
|
|
515
417
|
const projectZone = Effect.fn("VercelClient.projectZone")((domain) => Effect.gen(function* () {
|
|
516
|
-
const name = yield* decode$2(domain.name).pipe(Effect.mapError((cause) => failure("listZones", cause.message, { reason: "response" })));
|
|
517
|
-
const nameservers = yield* Effect.forEach(domain.intendedNameservers, (nameserver) => decode$2(nameserver).pipe(Effect.mapError((cause) => failure("listZones", cause.message, { reason: "response" }))));
|
|
418
|
+
const name = yield* decode$2(domain.name).pipe(Effect.mapError((cause) => failure$1("listZones", cause.message, { reason: "response" })));
|
|
419
|
+
const nameservers = yield* Effect.forEach(domain.intendedNameservers, (nameserver) => decode$2(nameserver).pipe(Effect.mapError((cause) => failure$1("listZones", cause.message, { reason: "response" }))));
|
|
518
420
|
return {
|
|
519
421
|
accountId: domain.teamId ?? domain.userId,
|
|
520
422
|
id: domain.id,
|
|
@@ -524,14 +426,14 @@ const projectZone = Effect.fn("VercelClient.projectZone")((domain) => Effect.gen
|
|
|
524
426
|
};
|
|
525
427
|
}));
|
|
526
428
|
function decode(schema, input, operation, response) {
|
|
527
|
-
return Schema.decodeUnknownEffect(schema)(input).pipe(Effect.mapError((cause) => failure(operation, `Vercel response did not match its API contract: ${cause.message}`, {
|
|
429
|
+
return Schema.decodeUnknownEffect(schema)(input).pipe(Effect.mapError((cause) => failure$1(operation, `Vercel response did not match its API contract: ${cause.message}`, {
|
|
528
430
|
reason: "response",
|
|
529
431
|
status: response.status
|
|
530
432
|
})));
|
|
531
433
|
}
|
|
532
434
|
function apiFailure(input, operation, response) {
|
|
533
435
|
const detail = Schema.decodeUnknownOption(ErrorEnvelope)(input);
|
|
534
|
-
return failure(operation, detail._tag === "Some" ? detail.value.error.message : `Vercel request failed with HTTP ${response.status}`, {
|
|
436
|
+
return failure$1(operation, detail._tag === "Some" ? detail.value.error.message : `Vercel request failed with HTTP ${response.status}`, {
|
|
535
437
|
...detail._tag === "Some" ? { code: detail.value.error.code } : {},
|
|
536
438
|
reason: reason(response.status, detail._tag === "Some" ? detail.value.error.code : void 0),
|
|
537
439
|
...rateLimit(response, detail._tag === "Some" ? detail.value.error : void 0),
|
|
@@ -553,8 +455,8 @@ function rateLimit(response, detail) {
|
|
|
553
455
|
const reset = resetMs ?? (header === null ? void 0 : Number(header) * 1e3);
|
|
554
456
|
return reset === void 0 || !Number.isFinite(reset) ? {} : { retryAfterMs: Math.max(0, reset - Date.now()) };
|
|
555
457
|
}
|
|
556
|
-
function failure(operation, message, fields = {}) {
|
|
557
|
-
return new Error
|
|
458
|
+
function failure$1(operation, message, fields = {}) {
|
|
459
|
+
return new Error({
|
|
558
460
|
...fields,
|
|
559
461
|
message,
|
|
560
462
|
operation,
|
|
@@ -562,6 +464,208 @@ function failure(operation, message, fields = {}) {
|
|
|
562
464
|
});
|
|
563
465
|
}
|
|
564
466
|
//#endregion
|
|
565
|
-
|
|
467
|
+
//#region src/providers/vercel/auth.ts
|
|
468
|
+
var auth_exports = /* @__PURE__ */ __exportAll({
|
|
469
|
+
contextCodec: () => contextCodec,
|
|
470
|
+
exchangeCode: () => exchangeCode,
|
|
471
|
+
integrationAuthentication: () => integrationAuthentication,
|
|
472
|
+
integrationFlow: () => integrationFlow,
|
|
473
|
+
integrationMethod: () => integrationMethod,
|
|
474
|
+
manifest: () => manifest,
|
|
475
|
+
tokenConnectionMethod: () => tokenConnectionMethod,
|
|
476
|
+
tokenMethod: () => tokenMethod
|
|
477
|
+
});
|
|
478
|
+
const Context$1 = Schema.TaggedUnion({
|
|
479
|
+
personal: { installationId: Schema.NullOr(Schema.String) },
|
|
480
|
+
team: {
|
|
481
|
+
installationId: Schema.NullOr(Schema.String),
|
|
482
|
+
teamId: Schema.String
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
const contextCodec = codec("vercel.v1", Context$1);
|
|
486
|
+
/** Describes Vercel's caller-created personal access-token method. */
|
|
487
|
+
function tokenMethod(capabilities) {
|
|
488
|
+
return {
|
|
489
|
+
_tag: "token",
|
|
490
|
+
capabilities: [...capabilities],
|
|
491
|
+
instructionsUrl: "https://vercel.com/account/settings/tokens"
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
/** Describes Vercel's provider-specific integration installation flow. */
|
|
495
|
+
function integrationMethod(options) {
|
|
496
|
+
return {
|
|
497
|
+
_tag: "integration",
|
|
498
|
+
capabilities: [...options.capabilities],
|
|
499
|
+
installUrl: `https://vercel.com/integrations/${encodeURIComponent(options.slug)}/new`,
|
|
500
|
+
tokenEndpoint: "https://api.vercel.com/oauth/access_token"
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
/** Creates the Vercel token and integration authorization manifest. */
|
|
504
|
+
function manifest(options) {
|
|
505
|
+
return {
|
|
506
|
+
methods: [tokenMethod(options.capabilities), integrationMethod(options)],
|
|
507
|
+
providerId: "vercel"
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
/** Exchanges Vercel's one-time integration code and preserves its account context. */
|
|
511
|
+
const exchangeCode = Effect.fn("VercelAuth.exchangeCode")((options) => Effect.gen(function* () {
|
|
512
|
+
const fetch = options.fetch ?? globalThis.fetch;
|
|
513
|
+
const baseUrl = (options.baseUrl ?? "https://api.vercel.com").replace(/\/$/, "");
|
|
514
|
+
const body = new URLSearchParams({
|
|
515
|
+
client_id: options.clientId,
|
|
516
|
+
client_secret: options.clientSecret.expose(),
|
|
517
|
+
code: options.code.expose(),
|
|
518
|
+
redirect_uri: options.redirectUri
|
|
519
|
+
});
|
|
520
|
+
const response = yield* Effect.tryPromise({
|
|
521
|
+
try: () => fetch(`${baseUrl}/oauth/access_token`, {
|
|
522
|
+
body,
|
|
523
|
+
headers: {
|
|
524
|
+
Accept: "application/json",
|
|
525
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
526
|
+
},
|
|
527
|
+
method: "POST"
|
|
528
|
+
}),
|
|
529
|
+
catch: () => failure("exchangeCode", "Vercel token exchange failed", "transport")
|
|
530
|
+
});
|
|
531
|
+
const input = yield* Effect.tryPromise({
|
|
532
|
+
try: () => response.json(),
|
|
533
|
+
catch: () => failure("exchangeCode", response.ok ? "Vercel returned a non-JSON token response" : `Vercel token exchange failed with HTTP ${response.status}`, response.ok ? "response" : response.status === 401 ? "authentication" : "request", response.status)
|
|
534
|
+
});
|
|
535
|
+
if (!response.ok) {
|
|
536
|
+
const detail = Schema.decodeUnknownOption(ErrorEnvelope)(input);
|
|
537
|
+
return yield* Effect.fail(failure("exchangeCode", detail._tag === "Some" ? detail.value.error.message : `Vercel token exchange failed with HTTP ${response.status}`, response.status === 401 ? "authentication" : "request", response.status, detail._tag === "Some" ? detail.value.error.code : void 0));
|
|
538
|
+
}
|
|
539
|
+
const token = yield* Schema.decodeUnknownEffect(IntegrationToken)(input).pipe(Effect.mapError((cause) => failure("exchangeCode", `Vercel token response did not match its API contract: ${cause.message}`, "response", response.status)));
|
|
540
|
+
return {
|
|
541
|
+
accessToken: make$1(token.access_token),
|
|
542
|
+
context: token.team_id === null ? { _tag: "personal" } : {
|
|
543
|
+
_tag: "team",
|
|
544
|
+
teamId: token.team_id
|
|
545
|
+
},
|
|
546
|
+
installationId: token.installation_id ?? null,
|
|
547
|
+
userId: token.user_id
|
|
548
|
+
};
|
|
549
|
+
}));
|
|
550
|
+
/** Creates a provider-independent token connection method backed by Vercel validation. */
|
|
551
|
+
function tokenConnectionMethod(options) {
|
|
552
|
+
const requiredCapabilities = [...options.capabilities];
|
|
553
|
+
return Method.Token({
|
|
554
|
+
authenticate: Effect.fn("VercelAuth.authenticateToken")(function* (token) {
|
|
555
|
+
const validated = yield* make({
|
|
556
|
+
...options,
|
|
557
|
+
token
|
|
558
|
+
}).validateToken();
|
|
559
|
+
const observedAt = new Date(yield* Clock.currentTimeMillis);
|
|
560
|
+
return {
|
|
561
|
+
capabilityEvidence: validated.capabilities.map((capability) => ({
|
|
562
|
+
capability,
|
|
563
|
+
evidence: Evidence.Introspected({ observedAt })
|
|
564
|
+
})),
|
|
565
|
+
credential: {
|
|
566
|
+
accessToken: token,
|
|
567
|
+
refreshToken: null,
|
|
568
|
+
tokenType: "bearer"
|
|
569
|
+
},
|
|
570
|
+
expiresAt: validated.expiresAt,
|
|
571
|
+
providerAccountId: validated.accountId,
|
|
572
|
+
providerContext: yield* contextCodec.encode(options.context._tag === "team" ? {
|
|
573
|
+
_tag: "team",
|
|
574
|
+
installationId: null,
|
|
575
|
+
teamId: options.context.teamId
|
|
576
|
+
} : {
|
|
577
|
+
_tag: "personal",
|
|
578
|
+
installationId: null
|
|
579
|
+
}),
|
|
580
|
+
scopes: [...validated.scopes]
|
|
581
|
+
};
|
|
582
|
+
}),
|
|
583
|
+
providerId: "vercel",
|
|
584
|
+
requiredCapabilities,
|
|
585
|
+
token: options.token
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
/** Converts a completed Vercel Integration exchange into canonical connection authentication. */
|
|
589
|
+
const integrationAuthentication = Effect.fn("VercelAuth.integrationAuthentication")(function* (options) {
|
|
590
|
+
const exchanged = yield* exchangeCode(options);
|
|
591
|
+
const observedAt = new Date(yield* Clock.currentTimeMillis);
|
|
592
|
+
return {
|
|
593
|
+
capabilityEvidence: options.capabilities.map((capability) => ({
|
|
594
|
+
capability,
|
|
595
|
+
evidence: Evidence.Introspected({ observedAt })
|
|
596
|
+
})),
|
|
597
|
+
credential: {
|
|
598
|
+
accessToken: exchanged.accessToken,
|
|
599
|
+
refreshToken: null,
|
|
600
|
+
tokenType: "bearer"
|
|
601
|
+
},
|
|
602
|
+
expiresAt: null,
|
|
603
|
+
providerAccountId: exchanged.context._tag === "team" ? exchanged.context.teamId : exchanged.userId,
|
|
604
|
+
providerContext: yield* contextCodec.encode(exchanged.context._tag === "team" ? {
|
|
605
|
+
_tag: "team",
|
|
606
|
+
installationId: exchanged.installationId,
|
|
607
|
+
teamId: exchanged.context.teamId
|
|
608
|
+
} : {
|
|
609
|
+
_tag: "personal",
|
|
610
|
+
installationId: exchanged.installationId
|
|
611
|
+
}),
|
|
612
|
+
scopes: []
|
|
613
|
+
};
|
|
614
|
+
});
|
|
615
|
+
/** Creates Vercel Integration's implementation of the common interactive connection capability. */
|
|
616
|
+
function integrationFlow(options) {
|
|
617
|
+
const method = integrationMethod(options);
|
|
618
|
+
const Payload = Schema.fromJsonString(Schema.Struct({ state: Schema.String }));
|
|
619
|
+
return {
|
|
620
|
+
complete: Effect.fn("VercelAuth.integrationFlow.complete")(function* (payload, callbackUrl) {
|
|
621
|
+
const continuation = yield* Schema.decodeUnknownEffect(Payload)(payload.expose()).pipe(Effect.mapError(() => new Error$1({
|
|
622
|
+
category: "authorization",
|
|
623
|
+
message: "Vercel Integration continuation payload is invalid",
|
|
624
|
+
operation: "VercelAuth.integrationFlow.complete",
|
|
625
|
+
retry: "after-user-action"
|
|
626
|
+
})));
|
|
627
|
+
const code = callbackUrl.searchParams.get("code");
|
|
628
|
+
if (callbackUrl.searchParams.get("state") !== continuation.state || code === null) return yield* new Error$1({
|
|
629
|
+
category: "authorization",
|
|
630
|
+
message: "Vercel Integration callback does not match its continuation",
|
|
631
|
+
operation: "VercelAuth.integrationFlow.complete",
|
|
632
|
+
retry: "after-user-action"
|
|
633
|
+
});
|
|
634
|
+
return yield* integrationAuthentication({
|
|
635
|
+
...options.baseUrl === void 0 ? {} : { baseUrl: options.baseUrl },
|
|
636
|
+
capabilities: options.capabilities,
|
|
637
|
+
clientId: options.clientId,
|
|
638
|
+
clientSecret: options.clientSecret,
|
|
639
|
+
code: make$1(code),
|
|
640
|
+
...options.fetch === void 0 ? {} : { fetch: options.fetch },
|
|
641
|
+
redirectUri: options.redirectUri
|
|
642
|
+
});
|
|
643
|
+
}),
|
|
644
|
+
method: "integration",
|
|
645
|
+
providerId: "vercel",
|
|
646
|
+
requiredCapabilities: [...options.capabilities],
|
|
647
|
+
start: (continuationId) => {
|
|
648
|
+
const authorizationUrl = new URL(method.installUrl);
|
|
649
|
+
authorizationUrl.searchParams.set("source", "external");
|
|
650
|
+
authorizationUrl.searchParams.set("state", continuationId);
|
|
651
|
+
return Effect.succeed({
|
|
652
|
+
authorizationUrl,
|
|
653
|
+
payload: make$1(JSON.stringify({ state: continuationId }))
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
function failure(operation, message, reason, status, code) {
|
|
659
|
+
return new Error({
|
|
660
|
+
...code === void 0 ? {} : { code },
|
|
661
|
+
message,
|
|
662
|
+
operation,
|
|
663
|
+
providerId: "vercel",
|
|
664
|
+
reason,
|
|
665
|
+
...status === void 0 ? {} : { status }
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
//#endregion
|
|
669
|
+
export { manifest as a, client_exports as c, integrationMethod as i, discovery as l, exchangeCode as n, tokenConnectionMethod as o, integrationFlow as r, tokenMethod as s, auth_exports as t, make as u };
|
|
566
670
|
|
|
567
|
-
//# sourceMappingURL=
|
|
671
|
+
//# sourceMappingURL=auth-6-KRy1gN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-6-KRy1gN.mjs","names":["S","decode","DomainName.decode","DnsRecord.decode","failure","S","DnsRecord.Opaque","DnsProvider.Error","failure","Protocol.TeamListEnvelope","Protocol.DomainListEnvelope","Protocol.DomainConfig","Protocol.DomainEnvelope","DomainName.decode","Protocol.RecordListEnvelope","Records.decode","Records.encode","DnsProvider.Error","Protocol.CreateRecordEnvelope","Protocol.UserEnvelope","S","Protocol.ErrorEnvelope","Context","S","ProviderContext.codec","Protocol.ErrorEnvelope","Protocol.IntegrationToken","Secret.make","Client.make","Connection.Error","DnsProvider.Error"],"sources":["../src/providers/vercel/protocol.ts","../src/providers/vercel/records.ts","../src/providers/vercel/client.ts","../src/providers/vercel/auth.ts"],"sourcesContent":["import { Schema as S } from \"effect\";\n\nexport const Pagination = S.Struct({\n count: S.Number,\n next: S.NullOr(S.Number),\n prev: S.NullOr(S.Number),\n});\nexport interface Pagination extends S.Schema.Type<typeof Pagination> {}\n\nexport const ErrorDetail = S.Struct({\n code: S.String,\n message: S.String,\n limit: S.optionalKey(\n S.Struct({\n remaining: S.Number,\n reset: S.optionalKey(S.Number),\n resetMs: S.optionalKey(S.Number),\n total: S.Number,\n }),\n ),\n});\nexport interface ErrorDetail extends S.Schema.Type<typeof ErrorDetail> {}\n\nexport const ErrorEnvelope = S.Struct({ error: ErrorDetail });\n\nexport const User = S.Struct({\n id: S.String,\n name: S.NullOr(S.String),\n username: S.String,\n});\nexport interface User extends S.Schema.Type<typeof User> {}\n\nexport const UserEnvelope = S.Struct({ user: User });\n\nexport const Team = S.Struct({\n id: S.String,\n name: S.NullOr(S.String),\n slug: S.String,\n});\nexport interface Team extends S.Schema.Type<typeof Team> {}\n\nexport const TeamListEnvelope = S.Struct({\n pagination: Pagination,\n teams: S.Array(Team),\n});\n\nexport const Domain = S.Struct({\n id: S.String,\n intendedNameservers: S.Array(S.String),\n name: S.String,\n nameservers: S.Array(S.String),\n serviceType: S.Literals([\"zeit.world\", \"external\", \"na\"]),\n teamId: S.NullOr(S.String),\n userId: S.String,\n verified: S.Boolean,\n zone: S.optionalKey(S.Boolean),\n});\nexport interface Domain extends S.Schema.Type<typeof Domain> {}\n\nexport const DomainConfig = S.Struct({\n misconfigured: S.Boolean,\n serviceType: S.Literals([\"zeit.world\", \"external\", \"na\"]),\n});\nexport interface DomainConfig extends S.Schema.Type<typeof DomainConfig> {}\n\nexport const DomainEnvelope = S.Struct({ domain: Domain });\n\nexport const DomainListEnvelope = S.Struct({\n domains: S.Array(Domain),\n pagination: Pagination,\n});\n\nexport const Record = S.Struct({\n id: S.String,\n mxPriority: S.optionalKey(S.Number),\n name: S.String,\n priority: S.optionalKey(S.Number),\n ttl: S.optionalKey(S.Number),\n type: S.String,\n value: S.String,\n});\nexport interface Record extends S.Schema.Type<typeof Record> {}\n\nexport const RecordListEnvelope = S.Struct({\n pagination: S.optionalKey(Pagination),\n records: S.Array(Record),\n});\n\nexport const CreateRecordEnvelope = S.Struct({\n uid: S.String,\n updated: S.optionalKey(S.Number),\n});\n\nexport const IntegrationToken = S.Struct({\n access_token: S.String,\n installation_id: S.optionalKey(S.String),\n team_id: S.NullOr(S.String),\n token_type: S.optionalKey(S.String),\n user_id: S.String,\n});\nexport interface IntegrationToken extends S.Schema.Type<typeof IntegrationToken> {}\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 * as DnsProvider from \"../../provider/provider.ts\";\nimport type * as Protocol from \"./protocol.ts\";\n\nexport type CreateBody = Readonly<Record<string, unknown>>;\n\nexport const decode = Effect.fn(\"VercelRecords.decode\")(\n (zone: DomainName.DomainName, record: Protocol.Record) =>\n Effect.gen(function* () {\n const absolute = absoluteNameCandidate(zone, record.name);\n const name = yield* DomainName.decode(absolute).pipe(\n Effect.match({ onFailure: () => null, onSuccess: (value) => value }),\n );\n if (name === null) return yield* decodeOpaque(record, absolute);\n const common = {\n metadata: {\n ownership: \"provider\",\n provenance: \"vercel\",\n purpose: \"existing DNS record\",\n },\n name,\n policy: record.type === \"CNAME\" ? \"exclusive\" : \"append\",\n ttl: record.ttl ?? 60,\n } as const;\n const fromRecord = (input: unknown) =>\n DnsRecord.decode(input).pipe(\n Effect.mapError((cause) => failure(\"decodeRecord\", cause.message)),\n );\n\n switch (record.type) {\n case \"A\":\n case \"AAAA\":\n return yield* fromRecord({ ...common, _tag: record.type, address: record.value });\n case \"CNAME\":\n case \"NS\":\n return yield* fromRecord({ ...common, _tag: record.type, target: record.value });\n case \"TXT\":\n return yield* fromRecord({ ...common, _tag: \"TXT\", value: record.value });\n case \"MX\":\n return yield* fromRecord({\n ...common,\n _tag: \"MX\",\n exchange: record.value,\n priority: record.mxPriority ?? record.priority,\n });\n case \"CAA\": {\n const match = record.value.match(\n /^(\\d{1,3})\\s+(issue|issuewild|iodef)\\s+(?:\"((?:\\\\.|[^\"])*)\"|(\\S.*))$/,\n );\n if (match === null) {\n return yield* Effect.fail(\n failure(\"decodeRecord\", \"Vercel CAA record has an invalid value\"),\n );\n }\n return yield* fromRecord({\n ...common,\n _tag: \"CAA\",\n flags: Number(match[1]),\n tag: match[2],\n value: unescapeQuoted(match[3] ?? match[4] ?? \"\"),\n });\n }\n case \"SRV\": {\n const parts = record.value.trim().split(/\\s+/);\n const [priority, weight, port, target] =\n parts.length === 4\n ? parts\n : [String(record.priority ?? \"\"), parts[0], parts[1], parts[2]];\n return yield* fromRecord({\n ...common,\n _tag: \"SRV\",\n port: Number(port),\n priority: Number(priority),\n target,\n weight: Number(weight),\n });\n }\n default:\n return yield* decodeOpaque(record, name);\n }\n }),\n);\n\nconst decodeOpaque = Effect.fn(\"VercelRecords.decodeOpaque\")(\n (record: Protocol.Record, name: string) =>\n S.decodeUnknownEffect(DnsRecord.Opaque)({\n _tag: \"Opaque\",\n name,\n providerRecordId: record.id,\n providerType: record.type,\n }).pipe(Effect.mapError((cause) => failure(\"decodeRecord\", cause.message))),\n);\n\nexport function encode(zone: DomainName.DomainName, record: DnsRecord.DnsRecord): CreateBody {\n const common = {\n name: relativeName(zone, record.name),\n ...(record.ttl === null ? {} : { ttl: record.ttl }),\n type: record._tag,\n };\n switch (record._tag) {\n case \"A\":\n case \"AAAA\":\n return { ...common, value: record.address };\n case \"CNAME\":\n case \"NS\":\n return { ...common, value: record.target };\n case \"TXT\":\n return { ...common, value: record.value };\n case \"MX\":\n return { ...common, mxPriority: record.priority, value: record.exchange };\n case \"CAA\":\n return {\n ...common,\n value: `${record.flags} ${record.tag} \"${escapeQuoted(record.value)}\"`,\n };\n case \"SRV\":\n return {\n ...common,\n srv: {\n port: record.port,\n priority: record.priority,\n target: record.target,\n weight: record.weight,\n },\n };\n }\n}\n\nfunction absoluteNameCandidate(zone: DomainName.DomainName, name: string): string {\n return name === \"\" || name === \"@\"\n ? zone\n : name === zone || name.endsWith(`.${zone}`)\n ? name\n : `${name}.${zone}`;\n}\n\nfunction relativeName(zone: DomainName.DomainName, name: DomainName.DomainName): string {\n if (name === zone) return \"\";\n const suffix = `.${zone}`;\n if (!name.endsWith(suffix)) {\n throw failure(\"encodeRecord\", `DNS record ${name} is outside Vercel zone ${zone}`, {\n reason: \"request\",\n });\n }\n return name.slice(0, -suffix.length);\n}\n\nfunction escapeQuoted(value: string): string {\n return value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"');\n}\n\nfunction unescapeQuoted(value: string): string {\n return value.replace(/\\\\([\\\\\"])/g, \"$1\");\n}\n\nfunction failure(\n operation: string,\n message: string,\n fields: Partial<Pick<DnsProvider.Error, \"reason\">> = {},\n): DnsProvider.Error {\n return new DnsProvider.Error({\n message,\n operation,\n providerId: \"vercel\",\n reason: fields.reason ?? \"response\",\n });\n}\n","import { Effect, Schema as S } from \"effect\";\n\nimport type * as ProviderAuth from \"../../auth/manifest.ts\";\nimport type * as Secret from \"../../auth/secret.ts\";\nimport * as DomainName from \"../../domain/domain-name.ts\";\nimport type * as DnsRecord from \"../../domain/dns-record.ts\";\nimport type * as ZoneDiscovery from \"../../discovery/zone-discovery.ts\";\nimport * as DnsProvider from \"../../provider/provider.ts\";\nimport * as Protocol from \"./protocol.ts\";\nimport * as Records from \"./records.ts\";\n\nexport type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;\n\n/** Selects whether Vercel requests operate on a personal account or a team. */\nexport type AccountContext =\n | { readonly _tag: \"personal\" }\n | { readonly _tag: \"team\"; readonly teamId: string };\n\n/** Configuration for an Effect-native Vercel authoritative-DNS client. */\nexport interface Options {\n readonly baseUrl?: string;\n /** Capabilities the host required when issuing or authorizing this credential. */\n readonly capabilities: ProviderAuth.TokenValidation[\"capabilities\"];\n readonly context: AccountContext;\n readonly fetch?: Fetch;\n readonly token: Secret.Value;\n}\n\nexport interface ListZonesInput {\n readonly name?: DomainName.DomainName;\n}\n\n/** A Vercel account visible to the supplied credential. */\nexport interface Account {\n readonly id: string;\n readonly name: string;\n readonly type: \"personal\" | \"team\";\n}\n\n/** A Vercel-managed authoritative zone with normalized nameserver evidence. */\nexport interface Zone {\n readonly accountId: string;\n readonly id: string;\n readonly name: DomainName.DomainName;\n readonly nameservers: ReadonlyArray<DomainName.DomainName>;\n readonly status: \"active\" | \"pending\";\n}\n\nexport interface Interface extends DnsProvider.Interface {\n readonly listAccounts: () => Effect.Effect<ReadonlyArray<Account>, DnsProvider.Error>;\n readonly listZones: (\n input?: ListZonesInput,\n ) => Effect.Effect<ReadonlyArray<Zone>, DnsProvider.Error>;\n readonly validateToken: () => Effect.Effect<ProviderAuth.TokenValidation, DnsProvider.Error>;\n}\n\n/** Exposes Vercel zone lookup as the optional provider discovery capability. */\nexport function discovery(client: Interface): ZoneDiscovery.Source {\n return {\n listZones: (name) => client.listZones({ name }),\n provider: client,\n };\n}\n\n/** Creates an Effect-native Vercel client without owning the credential lifecycle. */\nexport function make(options: Options): Interface {\n const fetch = options.fetch ?? globalThis.fetch;\n const baseUrl = (options.baseUrl ?? \"https://api.vercel.com\").replace(/\\/$/, \"\");\n\n const withContext = (path: string, values: Readonly<Record<string, string>> = {}) => {\n const url = new URL(`${baseUrl}${path}`);\n for (const [key, value] of Object.entries(values)) url.searchParams.set(key, value);\n if (options.context._tag === \"team\") url.searchParams.set(\"teamId\", options.context.teamId);\n return url;\n };\n\n const request = Effect.fn(\"VercelClient.request\")(\n (url: URL, operation: string, init?: RequestInit) =>\n Effect.gen(function* () {\n const response = yield* Effect.tryPromise({\n try: () =>\n fetch(url, {\n ...init,\n headers: {\n Accept: \"application/json\",\n Authorization: `Bearer ${options.token.expose()}`,\n ...(init?.body === undefined ? {} : { \"Content-Type\": \"application/json\" }),\n ...init?.headers,\n },\n }),\n catch: () => failure(operation, \"Vercel request failed\", { reason: \"transport\" }),\n });\n const body = yield* Effect.tryPromise({\n try: () => response.json() as Promise<unknown>,\n catch: () =>\n failure(\n operation,\n response.ok\n ? \"Vercel returned a non-JSON response\"\n : `Vercel request failed with HTTP ${response.status}`,\n {\n reason: response.ok ? \"response\" : reason(response.status),\n ...rateLimit(response),\n status: response.status,\n },\n ),\n });\n if (!response.ok) return yield* Effect.fail(apiFailure(body, operation, response));\n return { body, response } as const;\n }),\n );\n\n const allTeams = Effect.fn(\"VercelClient.allTeams\")(() =>\n Effect.gen(function* () {\n const teams: Array<Protocol.Team> = [];\n let until: number | null = null;\n while (true) {\n const url = new URL(`${baseUrl}/v2/teams`);\n url.searchParams.set(\"limit\", \"100\");\n if (until !== null) url.searchParams.set(\"until\", String(until));\n const { body, response } = yield* request(url, \"listAccounts\");\n const envelope = yield* decode(Protocol.TeamListEnvelope, body, \"listAccounts\", response);\n teams.push(...envelope.teams);\n if (envelope.pagination.next === null) return teams;\n until = envelope.pagination.next;\n }\n }),\n );\n\n const allDomains = Effect.fn(\"VercelClient.allDomains\")(() =>\n Effect.gen(function* () {\n const domains: Array<Protocol.Domain> = [];\n let until: number | null = null;\n while (true) {\n const values: Record<string, string> = { limit: \"100\" };\n if (until !== null) values.until = String(until);\n const { body, response } = yield* request(withContext(\"/v5/domains\", values), \"listZones\");\n const envelope = yield* decode(Protocol.DomainListEnvelope, body, \"listZones\", response);\n domains.push(...envelope.domains);\n if (envelope.pagination.next === null) return domains;\n until = envelope.pagination.next;\n }\n }),\n );\n\n const discoverZone = Effect.fn(\"VercelClient.discoverZone\")((name: DomainName.DomainName) =>\n Effect.gen(function* () {\n const configResult = yield* request(\n withContext(`/v6/domains/${encodeURIComponent(name)}/config`),\n \"resolveZone\",\n );\n const config = yield* decode(\n Protocol.DomainConfig,\n configResult.body,\n \"resolveZone\",\n configResult.response,\n );\n const domainResult = yield* request(\n withContext(`/v5/domains/${encodeURIComponent(name)}`),\n \"resolveZone\",\n );\n const envelope = yield* decode(\n Protocol.DomainEnvelope,\n domainResult.body,\n \"resolveZone\",\n domainResult.response,\n );\n if (!hasDnsStorage(envelope.domain, config.serviceType)) {\n return null;\n }\n return envelope.domain;\n }).pipe(\n Effect.catchTag(\"ProviderError\", (cause) =>\n cause.reason === \"not_found\" ? Effect.succeed(null) : Effect.fail(cause),\n ),\n ),\n );\n\n const resolveZone = Effect.fn(\"VercelClient.resolveZone\")((name: DomainName.DomainName) =>\n Effect.gen(function* () {\n const domain = yield* discoverZone(name);\n if (domain === null) {\n return yield* Effect.fail(\n failure(\n \"resolveZone\",\n `Vercel zone ${name} is not configured for authoritative DNS in the selected account`,\n { reason: \"not_found\" },\n ),\n );\n }\n return yield* DomainName.decode(domain.name).pipe(\n Effect.mapError((cause) =>\n failure(\"resolveZone\", `Vercel returned an invalid storage zone: ${cause.message}`),\n ),\n );\n }),\n );\n\n const listRecords = Effect.fn(\"VercelClient.listRecords\")((zoneName: DomainName.DomainName) =>\n Effect.gen(function* () {\n const storageZone = yield* resolveZone(zoneName);\n const records: Array<DnsRecord.Observed> = [];\n let until: number | null = null;\n while (true) {\n const values: Record<string, string> = { limit: \"100\" };\n if (until !== null) values.until = String(until);\n const { body, response } = yield* request(\n withContext(`/v5/domains/${encodeURIComponent(storageZone)}/records`, values),\n \"listRecords\",\n );\n const envelope = yield* decode(Protocol.RecordListEnvelope, body, \"listRecords\", response);\n records.push(\n ...(yield* Effect.forEach(envelope.records, (record) =>\n Records.decode(storageZone, record),\n )),\n );\n const next = envelope.pagination?.next ?? null;\n if (next === null) {\n return records.filter(\n (record) => record.name === zoneName || record.name.endsWith(`.${zoneName}`),\n );\n }\n until = next;\n }\n }),\n );\n\n const createRecord = Effect.fn(\"VercelClient.createRecord\")(\n (zoneName: DomainName.DomainName, record: DnsRecord.DnsRecord) =>\n Effect.gen(function* () {\n const storageZone = yield* resolveZone(zoneName);\n const body = yield* Effect.try({\n try: () => Records.encode(storageZone, record),\n catch: (cause) =>\n cause instanceof DnsProvider.Error\n ? cause\n : failure(\"createRecord\", \"Vercel record could not be encoded\", {\n reason: \"request\",\n }),\n });\n const result = yield* request(\n withContext(`/v2/domains/${encodeURIComponent(storageZone)}/records`),\n \"createRecord\",\n { body: JSON.stringify(body), method: \"POST\" },\n );\n const envelope = yield* decode(\n Protocol.CreateRecordEnvelope,\n result.body,\n \"createRecord\",\n result.response,\n );\n return { providerRecordId: envelope.uid };\n }),\n );\n\n const getRecord = Effect.fn(\"VercelClient.getRecord\")(\n (zoneName: DomainName.DomainName, providerRecordId: string) =>\n Effect.gen(function* () {\n const storageZone = yield* resolveZone(zoneName);\n let until: number | null = null;\n while (true) {\n const values: Record<string, string> = { limit: \"100\" };\n if (until !== null) values.until = String(until);\n const { body, response } = yield* request(\n withContext(`/v5/domains/${encodeURIComponent(storageZone)}/records`, values),\n \"getRecord\",\n );\n const envelope = yield* decode(Protocol.RecordListEnvelope, body, \"getRecord\", response);\n const record = envelope.records.find(({ id }) => id === providerRecordId);\n if (record !== undefined) return yield* Records.decode(storageZone, record);\n const next = envelope.pagination?.next ?? null;\n if (next === null) return null;\n until = next;\n }\n }),\n );\n\n const deleteRecord = Effect.fn(\"VercelClient.deleteRecord\")(\n (zoneName: DomainName.DomainName, providerRecordId: string) =>\n Effect.gen(function* () {\n const storageZone = yield* resolveZone(zoneName);\n yield* request(\n withContext(\n `/v2/domains/${encodeURIComponent(storageZone)}/records/${encodeURIComponent(providerRecordId)}`,\n ),\n \"deleteRecord\",\n { method: \"DELETE\" },\n );\n }),\n );\n\n const listAccounts = Effect.fn(\"VercelClient.listAccounts\")(() =>\n Effect.gen(function* () {\n const userResult = yield* request(new URL(`${baseUrl}/v2/user`), \"listAccounts\");\n const { user } = yield* decode(\n Protocol.UserEnvelope,\n userResult.body,\n \"listAccounts\",\n userResult.response,\n );\n const teams = yield* allTeams();\n return [\n { id: user.id, name: user.name ?? user.username, type: \"personal\" as const },\n ...teams.map((team) => ({\n id: team.id,\n name: team.name ?? team.slug,\n type: \"team\" as const,\n })),\n ];\n }),\n );\n\n const listZones = Effect.fn(\"VercelClient.listZones\")((input: ListZonesInput = {}) =>\n Effect.gen(function* () {\n const domains = (yield* allDomains()).filter(\n (domain) =>\n hasDnsStorage(domain) && (input.name === undefined || domain.name === input.name),\n );\n if (domains.length > 0 || input.name === undefined) {\n return yield* Effect.forEach(domains, projectZone);\n }\n const discovered = yield* discoverZone(input.name);\n return discovered === null ? [] : [yield* projectZone(discovered)];\n }),\n );\n\n const validateToken = Effect.fn(\"VercelClient.validateToken\")(() =>\n Effect.gen(function* () {\n let accountId: string;\n if (options.context._tag === \"team\") {\n yield* allDomains();\n accountId = options.context.teamId;\n } else {\n const result = yield* request(new URL(`${baseUrl}/v2/user`), \"validateToken\");\n const { user } = yield* decode(\n Protocol.UserEnvelope,\n result.body,\n \"validateToken\",\n result.response,\n );\n accountId = user.id;\n }\n return {\n accountId,\n capabilities: options.capabilities,\n expiresAt: null,\n scopes: [],\n };\n }),\n );\n\n return {\n id: \"vercel\",\n createRecord,\n deleteRecord,\n getRecord,\n listAccounts,\n listRecords,\n listZones,\n validateToken,\n };\n}\n\nfunction hasDnsStorage(\n domain: Protocol.Domain,\n configuredServiceType: Protocol.DomainConfig[\"serviceType\"] = domain.serviceType,\n): boolean {\n return (\n configuredServiceType === \"zeit.world\" ||\n domain.zone === true ||\n domain.intendedNameservers.length > 0\n );\n}\n\nconst projectZone = Effect.fn(\"VercelClient.projectZone\")((domain: Protocol.Domain) =>\n Effect.gen(function* () {\n const name = yield* DomainName.decode(domain.name).pipe(\n Effect.mapError((cause) => failure(\"listZones\", cause.message, { reason: \"response\" })),\n );\n const nameservers = yield* Effect.forEach(domain.intendedNameservers, (nameserver) =>\n DomainName.decode(nameserver).pipe(\n Effect.mapError((cause) => failure(\"listZones\", cause.message, { reason: \"response\" })),\n ),\n );\n return {\n accountId: domain.teamId ?? domain.userId,\n id: domain.id,\n name,\n nameservers,\n status: domain.verified ? \"active\" : \"pending\",\n } as const;\n }),\n);\n\nfunction decode<A>(\n schema: S.ConstraintCodec<A, unknown, never, unknown>,\n input: unknown,\n operation: string,\n response: Response,\n): Effect.Effect<A, DnsProvider.Error> {\n return S.decodeUnknownEffect(schema)(input).pipe(\n Effect.mapError((cause) =>\n failure(operation, `Vercel response did not match its API contract: ${cause.message}`, {\n reason: \"response\",\n status: response.status,\n }),\n ),\n );\n}\n\nfunction apiFailure(input: unknown, operation: string, response: Response): DnsProvider.Error {\n const detail = S.decodeUnknownOption(Protocol.ErrorEnvelope)(input);\n return failure(\n operation,\n detail._tag === \"Some\"\n ? detail.value.error.message\n : `Vercel request failed with HTTP ${response.status}`,\n {\n ...(detail._tag === \"Some\" ? { code: detail.value.error.code } : {}),\n reason: reason(response.status, detail._tag === \"Some\" ? detail.value.error.code : undefined),\n ...rateLimit(response, detail._tag === \"Some\" ? detail.value.error : undefined),\n status: response.status,\n },\n );\n}\n\nfunction reason(status: number, code?: string): DnsProvider.ErrorReason {\n if (status === 401 || code === \"invalid_token\") return \"authentication\";\n if (status === 403) return \"authorization\";\n if (status === 404 || code === \"not_found\") return \"not_found\";\n if (status === 409 || code === \"conflict\") return \"conflict\";\n if (status === 429 || code === \"rate_limited\") return \"rate_limit\";\n if (status >= 500) return \"response\";\n return \"request\";\n}\n\nfunction rateLimit(\n response: Response,\n detail?: Protocol.ErrorDetail,\n): Partial<Pick<DnsProvider.Error, \"retryAfterMs\">> {\n const resetMs = detail?.limit?.resetMs;\n const header = response.headers.get(\"x-ratelimit-reset\");\n const reset = resetMs ?? (header === null ? undefined : Number(header) * 1_000);\n return reset === undefined || !Number.isFinite(reset)\n ? {}\n : { retryAfterMs: Math.max(0, reset - Date.now()) };\n}\n\nfunction failure(\n operation: string,\n message: string,\n fields: Partial<Pick<DnsProvider.Error, \"code\" | \"reason\" | \"retryAfterMs\" | \"status\">> = {},\n): DnsProvider.Error {\n return new DnsProvider.Error({ ...fields, message, operation, providerId: \"vercel\" });\n}\n","import { Clock, Effect, Schema as S } from \"effect\";\n\nimport * as Connection from \"../../auth/connect.ts\";\nimport * as ProviderAuthorization from \"../../auth/authorization.ts\";\nimport type * as ProviderAuth from \"../../auth/manifest.ts\";\nimport * as ProviderContext from \"../../auth/provider-context.ts\";\nimport * as Secret from \"../../auth/secret.ts\";\nimport * as DnsProvider from \"../../provider/provider.ts\";\nimport * as Client from \"./client.ts\";\nimport * as Protocol from \"./protocol.ts\";\n\nconst Context = S.TaggedUnion({\n personal: { installationId: S.NullOr(S.String) },\n team: { installationId: S.NullOr(S.String), teamId: S.String },\n});\nexport type Context = typeof Context.Type;\nexport const contextCodec = ProviderContext.codec(\"vercel.v1\", Context);\n\n/** Describes Vercel's caller-created personal access-token method. */\nexport function tokenMethod(\n capabilities: ProviderAuth.TokenValidation[\"capabilities\"],\n): Extract<ProviderAuth.Manifest[\"methods\"][number], { readonly _tag: \"token\" }> {\n return {\n _tag: \"token\",\n capabilities: [...capabilities],\n instructionsUrl: \"https://vercel.com/account/settings/tokens\",\n };\n}\n\nexport interface IntegrationMethodOptions {\n readonly capabilities: ProviderAuth.TokenValidation[\"capabilities\"];\n readonly slug: string;\n}\n\n/** Describes Vercel's provider-specific integration installation flow. */\nexport function integrationMethod(\n options: IntegrationMethodOptions,\n): ProviderAuth.IntegrationMethod {\n return {\n _tag: \"integration\",\n capabilities: [...options.capabilities],\n installUrl: `https://vercel.com/integrations/${encodeURIComponent(options.slug)}/new`,\n tokenEndpoint: \"https://api.vercel.com/oauth/access_token\",\n };\n}\n\n/** Creates the Vercel token and integration authorization manifest. */\nexport function manifest(options: IntegrationMethodOptions): ProviderAuth.Manifest {\n return {\n methods: [tokenMethod(options.capabilities), integrationMethod(options)],\n providerId: \"vercel\",\n };\n}\n\nexport interface ExchangeCodeOptions {\n readonly baseUrl?: string;\n readonly clientId: string;\n readonly clientSecret: Secret.Value;\n readonly code: Secret.Value;\n readonly fetch?: Client.Fetch;\n readonly redirectUri: string;\n}\n\nexport interface IntegrationCredential {\n readonly accessToken: Secret.Value;\n readonly context: Client.AccountContext;\n readonly installationId: string | null;\n readonly userId: string;\n}\n\n/** Exchanges Vercel's one-time integration code and preserves its account context. */\nexport const exchangeCode = Effect.fn(\"VercelAuth.exchangeCode\")((options: ExchangeCodeOptions) =>\n Effect.gen(function* () {\n const fetch = options.fetch ?? globalThis.fetch;\n const baseUrl = (options.baseUrl ?? \"https://api.vercel.com\").replace(/\\/$/, \"\");\n const body = new URLSearchParams({\n client_id: options.clientId,\n client_secret: options.clientSecret.expose(),\n code: options.code.expose(),\n redirect_uri: options.redirectUri,\n });\n const response = yield* Effect.tryPromise({\n try: () =>\n fetch(`${baseUrl}/oauth/access_token`, {\n body,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n method: \"POST\",\n }),\n catch: () => failure(\"exchangeCode\", \"Vercel token exchange failed\", \"transport\"),\n });\n const input = yield* Effect.tryPromise({\n try: () => response.json() as Promise<unknown>,\n catch: () =>\n failure(\n \"exchangeCode\",\n response.ok\n ? \"Vercel returned a non-JSON token response\"\n : `Vercel token exchange failed with HTTP ${response.status}`,\n response.ok ? \"response\" : response.status === 401 ? \"authentication\" : \"request\",\n response.status,\n ),\n });\n if (!response.ok) {\n const detail = S.decodeUnknownOption(Protocol.ErrorEnvelope)(input);\n return yield* Effect.fail(\n failure(\n \"exchangeCode\",\n detail._tag === \"Some\"\n ? detail.value.error.message\n : `Vercel token exchange failed with HTTP ${response.status}`,\n response.status === 401 ? \"authentication\" : \"request\",\n response.status,\n detail._tag === \"Some\" ? detail.value.error.code : undefined,\n ),\n );\n }\n const token = yield* S.decodeUnknownEffect(Protocol.IntegrationToken)(input).pipe(\n Effect.mapError((cause) =>\n failure(\n \"exchangeCode\",\n `Vercel token response did not match its API contract: ${cause.message}`,\n \"response\",\n response.status,\n ),\n ),\n );\n return {\n accessToken: Secret.make(token.access_token),\n context:\n token.team_id === null\n ? ({ _tag: \"personal\" } as const)\n : ({ _tag: \"team\", teamId: token.team_id } as const),\n installationId: token.installation_id ?? null,\n userId: token.user_id,\n };\n }),\n);\n\nexport interface TokenConnectionOptions extends Omit<Client.Options, \"token\"> {\n readonly token: Secret.Value;\n}\n\n/** Creates a provider-independent token connection method backed by Vercel validation. */\nexport function tokenConnectionMethod(\n options: TokenConnectionOptions,\n): Extract<Connection.Method, { readonly _tag: \"Token\" }> {\n const requiredCapabilities = [...options.capabilities];\n return Connection.Method.Token({\n authenticate: Effect.fn(\"VercelAuth.authenticateToken\")(function* (token) {\n const validated = yield* Client.make({ ...options, token }).validateToken();\n const observedAt = new Date(yield* Clock.currentTimeMillis);\n return {\n capabilityEvidence: validated.capabilities.map((capability) => ({\n capability,\n evidence: ProviderAuthorization.Evidence.Introspected({ observedAt }),\n })),\n credential: { accessToken: token, refreshToken: null, tokenType: \"bearer\" },\n expiresAt: validated.expiresAt,\n providerAccountId: validated.accountId,\n providerContext: yield* contextCodec.encode(\n options.context._tag === \"team\"\n ? { _tag: \"team\", installationId: null, teamId: options.context.teamId }\n : { _tag: \"personal\", installationId: null },\n ),\n scopes: [...validated.scopes],\n } satisfies Connection.Authentication;\n }),\n providerId: \"vercel\",\n requiredCapabilities,\n token: options.token,\n });\n}\n\n/** Converts a completed Vercel Integration exchange into canonical connection authentication. */\nexport const integrationAuthentication = Effect.fn(\"VercelAuth.integrationAuthentication\")(\n function* (\n options: ExchangeCodeOptions & {\n readonly capabilities: ReadonlyArray<ProviderAuthorization.Capability>;\n },\n ) {\n const exchanged = yield* exchangeCode(options);\n const observedAt = new Date(yield* Clock.currentTimeMillis);\n return {\n capabilityEvidence: options.capabilities.map((capability) => ({\n capability,\n evidence: ProviderAuthorization.Evidence.Introspected({ observedAt }),\n })),\n credential: {\n accessToken: exchanged.accessToken,\n refreshToken: null,\n tokenType: \"bearer\",\n },\n expiresAt: null,\n providerAccountId:\n exchanged.context._tag === \"team\" ? exchanged.context.teamId : exchanged.userId,\n providerContext: yield* contextCodec.encode(\n exchanged.context._tag === \"team\"\n ? {\n _tag: \"team\",\n installationId: exchanged.installationId,\n teamId: exchanged.context.teamId,\n }\n : { _tag: \"personal\", installationId: exchanged.installationId },\n ),\n scopes: [],\n } satisfies Connection.Authentication;\n },\n);\n\nexport interface IntegrationFlowOptions\n extends Omit<ExchangeCodeOptions, \"code\">, IntegrationMethodOptions {}\n\n/** Creates Vercel Integration's implementation of the common interactive connection capability. */\nexport function integrationFlow(options: IntegrationFlowOptions): Connection.InteractiveFlow {\n const method = integrationMethod(options);\n const Payload = S.fromJsonString(S.Struct({ state: S.String }));\n return {\n complete: Effect.fn(\"VercelAuth.integrationFlow.complete\")(function* (payload, callbackUrl) {\n const continuation = yield* S.decodeUnknownEffect(Payload)(payload.expose()).pipe(\n Effect.mapError(\n () =>\n new Connection.Error({\n category: \"authorization\",\n message: \"Vercel Integration continuation payload is invalid\",\n operation: \"VercelAuth.integrationFlow.complete\",\n retry: \"after-user-action\",\n }),\n ),\n );\n const code = callbackUrl.searchParams.get(\"code\");\n if (callbackUrl.searchParams.get(\"state\") !== continuation.state || code === null) {\n return yield* new Connection.Error({\n category: \"authorization\",\n message: \"Vercel Integration callback does not match its continuation\",\n operation: \"VercelAuth.integrationFlow.complete\",\n retry: \"after-user-action\",\n });\n }\n return yield* integrationAuthentication({\n ...(options.baseUrl === undefined ? {} : { baseUrl: options.baseUrl }),\n capabilities: options.capabilities,\n clientId: options.clientId,\n clientSecret: options.clientSecret,\n code: Secret.make(code),\n ...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n redirectUri: options.redirectUri,\n });\n }),\n method: \"integration\",\n providerId: \"vercel\",\n requiredCapabilities: [...options.capabilities],\n start: (continuationId) => {\n const authorizationUrl = new URL(method.installUrl);\n authorizationUrl.searchParams.set(\"source\", \"external\");\n authorizationUrl.searchParams.set(\"state\", continuationId);\n return Effect.succeed({\n authorizationUrl,\n payload: Secret.make(JSON.stringify({ state: continuationId })),\n });\n },\n };\n}\n\nfunction failure(\n operation: string,\n message: string,\n reason: DnsProvider.ErrorReason,\n status?: number,\n code?: string,\n): DnsProvider.Error {\n return new DnsProvider.Error({\n ...(code === undefined ? {} : { code }),\n message,\n operation,\n providerId: \"vercel\",\n reason,\n ...(status === undefined ? {} : { status }),\n });\n}\n"],"mappings":";;;;;AAEA,MAAa,aAAaA,OAAE,OAAO;CACjC,OAAOA,OAAE;CACT,MAAMA,OAAE,OAAOA,OAAE,MAAM;CACvB,MAAMA,OAAE,OAAOA,OAAE,MAAM;AACzB,CAAC;AAGD,MAAa,cAAcA,OAAE,OAAO;CAClC,MAAMA,OAAE;CACR,SAASA,OAAE;CACX,OAAOA,OAAE,YACPA,OAAE,OAAO;EACP,WAAWA,OAAE;EACb,OAAOA,OAAE,YAAYA,OAAE,MAAM;EAC7B,SAASA,OAAE,YAAYA,OAAE,MAAM;EAC/B,OAAOA,OAAE;CACX,CAAC,CACH;AACF,CAAC;AAGD,MAAa,gBAAgBA,OAAE,OAAO,EAAE,OAAO,YAAY,CAAC;AAE5D,MAAa,OAAOA,OAAE,OAAO;CAC3B,IAAIA,OAAE;CACN,MAAMA,OAAE,OAAOA,OAAE,MAAM;CACvB,UAAUA,OAAE;AACd,CAAC;AAGD,MAAa,eAAeA,OAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnD,MAAa,OAAOA,OAAE,OAAO;CAC3B,IAAIA,OAAE;CACN,MAAMA,OAAE,OAAOA,OAAE,MAAM;CACvB,MAAMA,OAAE;AACV,CAAC;AAGD,MAAa,mBAAmBA,OAAE,OAAO;CACvC,YAAY;CACZ,OAAOA,OAAE,MAAM,IAAI;AACrB,CAAC;AAED,MAAa,SAASA,OAAE,OAAO;CAC7B,IAAIA,OAAE;CACN,qBAAqBA,OAAE,MAAMA,OAAE,MAAM;CACrC,MAAMA,OAAE;CACR,aAAaA,OAAE,MAAMA,OAAE,MAAM;CAC7B,aAAaA,OAAE,SAAS;EAAC;EAAc;EAAY;CAAI,CAAC;CACxD,QAAQA,OAAE,OAAOA,OAAE,MAAM;CACzB,QAAQA,OAAE;CACV,UAAUA,OAAE;CACZ,MAAMA,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