domainkit 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/canonical-json-9x7gHIoS.mjs +304 -0
- package/dist/canonical-json-9x7gHIoS.mjs.map +1 -0
- package/dist/connect-Db830jad.d.mts +1387 -0
- package/dist/connect-ks3cpqBD.mjs +185 -0
- package/dist/connect-ks3cpqBD.mjs.map +1 -0
- package/dist/connection-DuYDgWir.d.mts +186 -0
- package/dist/connection-api-B__0M3PA.d.mts +26 -0
- package/dist/index.d.mts +7 -26
- package/dist/index.mjs +11 -5
- package/dist/index.mjs.map +1 -1
- package/dist/managed-dns-connections-CaXts84E.mjs +99 -0
- package/dist/managed-dns-connections-CaXts84E.mjs.map +1 -0
- package/dist/promise.d.mts +39 -217
- package/dist/promise.mjs +39 -125
- package/dist/promise.mjs.map +1 -1
- package/dist/{resolver-BGBLnPjJ.d.mts → resolver-DUAIlm2I.d.mts} +24 -1127
- package/dist/{resolver-tZU6gEVq.mjs → resolver-DxJPsq6l.mjs} +11 -227
- package/dist/resolver-DxJPsq6l.mjs.map +1 -0
- package/dist/server.d.mts +128 -0
- package/dist/server.mjs +319 -0
- package/dist/server.mjs.map +1 -0
- package/dist/testing.d.mts +5 -4
- package/dist/testing.mjs +10 -13
- package/dist/testing.mjs.map +1 -1
- package/dist/{verify-B2fPyjde.mjs → verify-DAtUAEeg.mjs} +124 -309
- package/dist/verify-DAtUAEeg.mjs.map +1 -0
- package/dist/{verify-6xK05pwL.d.mts → verify-yAy-r9no.d.mts} +34 -19
- package/package.json +5 -1
- package/dist/resolver-tZU6gEVq.mjs.map +0 -1
- package/dist/verify-B2fPyjde.mjs.map +0 -1
|
@@ -1,192 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { E as decode$5, O as parse$1, T as Schema$2, b as authorizationError, c as Evidence$1, f as AuthorizationError, k as Error$1, s as Service$1, u as codec, y as assertAttachment } from "./canonical-json-9x7gHIoS.mjs";
|
|
3
|
+
import { n as Method$1, t as Error$2 } from "./connect-ks3cpqBD.mjs";
|
|
4
|
+
import { $ as data, F as Service$3, I as fromAsync$1, P as Error$3, ct as candidates, et as decode$6, i as toAsync$5, n as Service$2, nt as equals, q as Opaque, t as Error$4, x as authorize$1, z as toAsync$4 } from "./resolver-DxJPsq6l.mjs";
|
|
3
5
|
import { Clock, Context, Crypto, Data, Effect, Layer, Option, Schema, SchemaIssue, SchemaTransformation } from "effect";
|
|
4
6
|
import * as oauth from "oauth4webapi";
|
|
5
7
|
import * as DnsPacket from "@leichtgewicht/dns-packet";
|
|
6
8
|
//#region package.json
|
|
7
|
-
var version = "0.
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/auth/connect.ts
|
|
10
|
-
const Method$1 = Data.taggedEnum();
|
|
11
|
-
const StartResult = Data.taggedEnum();
|
|
12
|
-
var Error$1 = class extends Schema.TaggedError()("ConnectionError", {
|
|
13
|
-
category: Schema.Literals([
|
|
14
|
-
"authorization",
|
|
15
|
-
"provider",
|
|
16
|
-
"validation"
|
|
17
|
-
]),
|
|
18
|
-
message: Schema.String,
|
|
19
|
-
operation: Schema.String,
|
|
20
|
-
retry: Schema.Literals([
|
|
21
|
-
"never",
|
|
22
|
-
"after-user-action",
|
|
23
|
-
"safe",
|
|
24
|
-
"unknown"
|
|
25
|
-
])
|
|
26
|
-
}) {};
|
|
27
|
-
const missingCapability = (authentication, requiredCapabilities) => requiredCapabilities.find((capability) => !authentication.capabilityEvidence.some((item) => item.capability === capability));
|
|
28
|
-
const freshId = Effect.fn("Connection.freshId")(function* () {
|
|
29
|
-
return yield* (yield* Crypto.Crypto).randomUUIDv4.pipe(Effect.mapError((cause) => new Error$1({
|
|
30
|
-
category: "validation",
|
|
31
|
-
message: cause.message,
|
|
32
|
-
operation: "Connection.connect",
|
|
33
|
-
retry: "safe"
|
|
34
|
-
})));
|
|
35
|
-
});
|
|
36
|
-
/** Persist one authenticated provider connection, optionally reusing a proven authorization. */
|
|
37
|
-
const connect = Effect.fn("Connection.connect")(function* (input) {
|
|
38
|
-
const repository = yield* Service$1;
|
|
39
|
-
const now = new Date(yield* Clock.currentTimeMillis);
|
|
40
|
-
const missing = missingCapability(input.authentication, input.requiredCapabilities);
|
|
41
|
-
if (missing !== void 0) return yield* new Error$1({
|
|
42
|
-
category: "authorization",
|
|
43
|
-
message: `Provider authorization lacks evidence for ${missing}`,
|
|
44
|
-
operation: "Connection.connect",
|
|
45
|
-
retry: "after-user-action"
|
|
46
|
-
});
|
|
47
|
-
const existing = input.authorizationId === void 0 ? null : yield* repository.get(input.authorizationId);
|
|
48
|
-
if (input.authorizationId !== void 0 && existing === null) return yield* new Error$1({
|
|
49
|
-
category: "authorization",
|
|
50
|
-
message: "Provider authorization does not exist",
|
|
51
|
-
operation: "Connection.connect",
|
|
52
|
-
retry: "after-user-action"
|
|
53
|
-
});
|
|
54
|
-
if (existing?.authorization.revocation._tag === "Pending") return yield* new Error$1({
|
|
55
|
-
category: "authorization",
|
|
56
|
-
message: "Provider authorization is awaiting revocation recovery",
|
|
57
|
-
operation: "Connection.connect",
|
|
58
|
-
retry: "after-user-action"
|
|
59
|
-
});
|
|
60
|
-
if (existing !== null && (existing.authorization.providerId !== input.providerId || existing.authorization.method !== input.method)) return yield* new Error$1({
|
|
61
|
-
category: "authorization",
|
|
62
|
-
message: "Provider proof does not match the existing authorization",
|
|
63
|
-
operation: "Connection.connect",
|
|
64
|
-
retry: "never"
|
|
65
|
-
});
|
|
66
|
-
const authorizationId = existing?.authorization.id ?? (yield* freshId());
|
|
67
|
-
const authorization = existing === null ? {
|
|
68
|
-
authorizedById: input.authorizedById,
|
|
69
|
-
capabilityEvidence: [...input.authentication.capabilityEvidence],
|
|
70
|
-
createdAt: now,
|
|
71
|
-
expiresAt: input.authentication.expiresAt,
|
|
72
|
-
id: authorizationId,
|
|
73
|
-
method: input.method,
|
|
74
|
-
providerContext: input.authentication.providerContext,
|
|
75
|
-
providerId: input.providerId,
|
|
76
|
-
requiredCapabilities: [...input.requiredCapabilities],
|
|
77
|
-
revocation: { _tag: "Active" },
|
|
78
|
-
scopes: [...input.authentication.scopes]
|
|
79
|
-
} : {
|
|
80
|
-
...existing.authorization,
|
|
81
|
-
capabilityEvidence: mergeEvidence(existing.authorization.capabilityEvidence, input.authentication.capabilityEvidence),
|
|
82
|
-
expiresAt: input.authentication.expiresAt,
|
|
83
|
-
method: input.method,
|
|
84
|
-
providerContext: input.authentication.providerContext,
|
|
85
|
-
requiredCapabilities: [...input.requiredCapabilities],
|
|
86
|
-
revocation: { _tag: "Active" },
|
|
87
|
-
scopes: [...input.authentication.scopes]
|
|
88
|
-
};
|
|
89
|
-
const existingConnection = yield* repository.findConnection(input.ownerId, authorizationId);
|
|
90
|
-
const connection = {
|
|
91
|
-
authorizationId,
|
|
92
|
-
createdAt: existingConnection?.createdAt ?? now,
|
|
93
|
-
id: existingConnection?.id ?? (yield* freshId()),
|
|
94
|
-
method: input.method,
|
|
95
|
-
ownerId: input.ownerId,
|
|
96
|
-
providerId: input.providerId
|
|
97
|
-
};
|
|
98
|
-
return yield* repository.connect({
|
|
99
|
-
authorization,
|
|
100
|
-
connection,
|
|
101
|
-
credential: input.authentication.credential,
|
|
102
|
-
...existing === null ? {} : { expectedAuthorizationId: existing.authorization.id },
|
|
103
|
-
...existingConnection === null ? {} : { expectedConnectionId: existingConnection.id }
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
const start$1 = Effect.fn("Connection.start")(function* (input) {
|
|
107
|
-
if (input.method._tag === "Interactive") {
|
|
108
|
-
const crypto = yield* Crypto.Crypto;
|
|
109
|
-
const now = yield* Clock.currentTimeMillis;
|
|
110
|
-
const continuationId = yield* crypto.randomUUIDv4.pipe(Effect.mapError((cause) => new Error$1({
|
|
111
|
-
category: "validation",
|
|
112
|
-
message: cause.message,
|
|
113
|
-
operation: "Connection.start",
|
|
114
|
-
retry: "safe"
|
|
115
|
-
})));
|
|
116
|
-
const started = yield* input.method.flow.start(continuationId);
|
|
117
|
-
yield* input.method.continuations.put({
|
|
118
|
-
authorizedById: input.authorizedById,
|
|
119
|
-
...input.authorizationId === void 0 ? {} : { authorizationId: input.authorizationId },
|
|
120
|
-
expiresAt: new Date(now + (input.method.ttlMs ?? 6e5)),
|
|
121
|
-
id: continuationId,
|
|
122
|
-
method: input.method.flow.method,
|
|
123
|
-
ownerId: input.ownerId,
|
|
124
|
-
payload: started.payload,
|
|
125
|
-
providerId: input.method.flow.providerId,
|
|
126
|
-
requiredCapabilities: [...input.method.flow.requiredCapabilities]
|
|
127
|
-
});
|
|
128
|
-
return StartResult.Redirect({
|
|
129
|
-
authorizationUrl: started.authorizationUrl,
|
|
130
|
-
continuationId
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
const authentication = yield* input.method.authenticate(input.method.token);
|
|
134
|
-
const aggregate = yield* connect({
|
|
135
|
-
authentication,
|
|
136
|
-
authorizedById: input.authorizedById,
|
|
137
|
-
...input.authorizationId === void 0 ? {} : { authorizationId: input.authorizationId },
|
|
138
|
-
method: "token",
|
|
139
|
-
ownerId: input.ownerId,
|
|
140
|
-
providerId: input.method.providerId,
|
|
141
|
-
requiredCapabilities: input.method.requiredCapabilities
|
|
142
|
-
});
|
|
143
|
-
const storedConnection = aggregate.connections.find(({ ownerId }) => ownerId === input.ownerId);
|
|
144
|
-
if (storedConnection === void 0) return yield* new Error$1({
|
|
145
|
-
category: "validation",
|
|
146
|
-
message: "Connected provider authorization returned no organization connection",
|
|
147
|
-
operation: "Connection.start",
|
|
148
|
-
retry: "safe"
|
|
149
|
-
});
|
|
150
|
-
return StartResult.Connected({ connection: project(storedConnection, aggregate.authorization) });
|
|
151
|
-
});
|
|
152
|
-
const complete$1 = Effect.fn("Connection.complete")(function* (input) {
|
|
153
|
-
const continuation = yield* input.continuations.consume(input.continuationId, new Date(yield* Clock.currentTimeMillis));
|
|
154
|
-
if (continuation === null) return yield* new Error$1({
|
|
155
|
-
category: "authorization",
|
|
156
|
-
message: "Connection continuation is expired, unknown, or already consumed",
|
|
157
|
-
operation: "Connection.complete",
|
|
158
|
-
retry: "after-user-action"
|
|
159
|
-
});
|
|
160
|
-
if (continuation.providerId !== input.flow.providerId || continuation.method !== input.flow.method) return yield* new Error$1({
|
|
161
|
-
category: "authorization",
|
|
162
|
-
message: "Connection continuation does not match the provider flow",
|
|
163
|
-
operation: "Connection.complete",
|
|
164
|
-
retry: "never"
|
|
165
|
-
});
|
|
166
|
-
const authentication = yield* input.flow.complete(continuation.payload, input.callbackUrl);
|
|
167
|
-
const aggregate = yield* connect({
|
|
168
|
-
authentication,
|
|
169
|
-
authorizedById: continuation.authorizedById,
|
|
170
|
-
...continuation.authorizationId === void 0 ? {} : { authorizationId: continuation.authorizationId },
|
|
171
|
-
method: continuation.method,
|
|
172
|
-
ownerId: continuation.ownerId,
|
|
173
|
-
providerId: continuation.providerId,
|
|
174
|
-
requiredCapabilities: continuation.requiredCapabilities
|
|
175
|
-
});
|
|
176
|
-
const storedConnection = aggregate.connections.find(({ ownerId }) => ownerId === continuation.ownerId);
|
|
177
|
-
if (storedConnection === void 0) return yield* new Error$1({
|
|
178
|
-
category: "validation",
|
|
179
|
-
message: "Connected provider authorization returned no organization connection",
|
|
180
|
-
operation: "Connection.complete",
|
|
181
|
-
retry: "safe"
|
|
182
|
-
});
|
|
183
|
-
return project(storedConnection, aggregate.authorization);
|
|
184
|
-
});
|
|
185
|
-
function mergeEvidence(current, incoming) {
|
|
186
|
-
const byCapability = new Map(current.map((item) => [item.capability, item]));
|
|
187
|
-
for (const item of incoming) byCapability.set(item.capability, item);
|
|
188
|
-
return [...byCapability.values()];
|
|
189
|
-
}
|
|
9
|
+
var version = "0.6.0";
|
|
190
10
|
//#endregion
|
|
191
11
|
//#region src/auth/diagnostic.ts
|
|
192
12
|
var diagnostic_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -227,8 +47,8 @@ function from(error) {
|
|
|
227
47
|
//#region src/auth/manifest.ts
|
|
228
48
|
var manifest_exports = /* @__PURE__ */ __exportAll({
|
|
229
49
|
Method: () => Method,
|
|
230
|
-
Schema: () => Schema$
|
|
231
|
-
decode: () => decode$
|
|
50
|
+
Schema: () => Schema$1,
|
|
51
|
+
decode: () => decode$4
|
|
232
52
|
});
|
|
233
53
|
const Method = Schema.TaggedUnion({
|
|
234
54
|
integration: {
|
|
@@ -256,37 +76,11 @@ const Method = Schema.TaggedUnion({
|
|
|
256
76
|
instructionsUrl: Schema.String
|
|
257
77
|
}
|
|
258
78
|
});
|
|
259
|
-
const Schema$
|
|
79
|
+
const Schema$1 = Schema.Struct({
|
|
260
80
|
methods: Schema.Array(Method),
|
|
261
81
|
providerId: Schema.String
|
|
262
82
|
});
|
|
263
|
-
const decode$
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region src/auth/provider-context.ts
|
|
266
|
-
var provider_context_exports = /* @__PURE__ */ __exportAll({
|
|
267
|
-
Envelope: () => Envelope,
|
|
268
|
-
codec: () => codec,
|
|
269
|
-
decode: () => decode$5,
|
|
270
|
-
encode: () => encode$3
|
|
271
|
-
});
|
|
272
|
-
/** A provider-owned, versioned, non-secret context value persisted by the host. */
|
|
273
|
-
const Envelope = Schema.Struct({
|
|
274
|
-
value: Schema.Json,
|
|
275
|
-
version: Schema.String
|
|
276
|
-
});
|
|
277
|
-
/** Build an adapter-owned context codec from a schema and stable version identifier. */
|
|
278
|
-
function codec(version, schema) {
|
|
279
|
-
return {
|
|
280
|
-
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 })))),
|
|
281
|
-
encode: Effect.fn("ProviderContext.encode")((value) => Schema.encodeEffect(schema)(value).pipe(Effect.flatMap((encoded) => Schema.decodeUnknownEffect(Schema.Json)(encoded)), Effect.map((encoded) => ({
|
|
282
|
-
value: encoded,
|
|
283
|
-
version
|
|
284
|
-
})), Effect.mapError((cause) => new Error$2({ message: cause.message })))),
|
|
285
|
-
version
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
const decode$5 = Effect.fn("ProviderContext.Envelope.decode")((input) => Schema.decodeUnknownEffect(Envelope)(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
|
|
289
|
-
const encode$3 = Schema.encodeSync(Envelope);
|
|
83
|
+
const decode$4 = Effect.fn("ProviderAuth.decode")((input) => Schema.decodeUnknownEffect(Schema$1)(input).pipe(Effect.mapError((cause) => new Error$1({ message: cause.message }))));
|
|
290
84
|
//#endregion
|
|
291
85
|
//#region src/auth/secret.ts
|
|
292
86
|
var secret_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -317,26 +111,26 @@ const make$6 = Value.from;
|
|
|
317
111
|
//#endregion
|
|
318
112
|
//#region src/discovery/selection.ts
|
|
319
113
|
var selection_exports = /* @__PURE__ */ __exportAll({
|
|
320
|
-
Evidence: () => Evidence
|
|
114
|
+
Evidence: () => Evidence,
|
|
321
115
|
Selection: () => Selection,
|
|
322
116
|
select: () => select
|
|
323
117
|
});
|
|
324
|
-
const Evidence
|
|
118
|
+
const Evidence = Schema.Struct({
|
|
325
119
|
accountId: Schema.String,
|
|
326
120
|
connectionId: Schema.String,
|
|
327
121
|
decisiveNameserverMatch: Schema.Boolean,
|
|
328
|
-
matchedNameservers: Schema.Array(Schema$
|
|
122
|
+
matchedNameservers: Schema.Array(Schema$2),
|
|
329
123
|
providerId: Schema.String,
|
|
330
|
-
zone: Schema$
|
|
124
|
+
zone: Schema$2
|
|
331
125
|
});
|
|
332
126
|
const Selection = Schema.TaggedUnion({
|
|
333
127
|
selected: {
|
|
334
|
-
candidate: Evidence
|
|
335
|
-
evidence: Schema.Array(Evidence
|
|
128
|
+
candidate: Evidence,
|
|
129
|
+
evidence: Schema.Array(Evidence),
|
|
336
130
|
reason: Schema.Literals(["explicit", "unique-nameserver-match"])
|
|
337
131
|
},
|
|
338
132
|
manual: {
|
|
339
|
-
evidence: Schema.Array(Evidence
|
|
133
|
+
evidence: Schema.Array(Evidence),
|
|
340
134
|
reason: Schema.Literals(["ambiguous", "unsupported"])
|
|
341
135
|
}
|
|
342
136
|
});
|
|
@@ -456,10 +250,11 @@ const authorize = Effect.fn("ConnectionAuthorization.authorize")(function* (inpu
|
|
|
456
250
|
capability: "dns:write",
|
|
457
251
|
authorization: aggregate.authorization,
|
|
458
252
|
connection: storedConnection,
|
|
253
|
+
credential: aggregate.credential,
|
|
459
254
|
domain: input.domain,
|
|
460
255
|
providerId: input.plan.providerId
|
|
461
256
|
}),
|
|
462
|
-
catch: (cause) => cause instanceof AuthorizationError || cause instanceof Error$
|
|
257
|
+
catch: (cause) => cause instanceof AuthorizationError || cause instanceof Error$1 ? cause : authorizationError("Domain attachment is invalid", "ConnectionAuthorization.authorize")
|
|
463
258
|
});
|
|
464
259
|
const authorization = yield* authorize$1(input.plan, input.operationIds, input.allowPartial === void 0 ? {} : { allowPartial: input.allowPartial });
|
|
465
260
|
const selected = new Set(authorization.operationIds);
|
|
@@ -496,14 +291,14 @@ const complete = Effect.fn("AuthorizationCode.complete")(function* (input) {
|
|
|
496
291
|
if (input.callbackUrl.searchParams.get("state") !== payload.state) return yield* failure$6("Authorization callback state does not match its continuation");
|
|
497
292
|
const server = input.method.authorizationServer;
|
|
498
293
|
const client = { client_id: input.client.clientId };
|
|
499
|
-
const authentication = yield* clientAuthentication(input.method, input.client);
|
|
294
|
+
const authentication = yield* clientAuthentication$1(input.method, input.client);
|
|
500
295
|
return yield* Effect.tryPromise({
|
|
501
296
|
try: async (signal) => {
|
|
502
297
|
const callback = oauth.validateAuthResponse(server, client, input.callbackUrl, payload.state);
|
|
503
298
|
const response = await oauth.authorizationCodeGrantRequest(server, client, authentication, callback, payload.redirectUri, payload.codeVerifier, requestOptions(input.fetch, signal));
|
|
504
299
|
return oauth.processAuthorizationCodeResponse(server, client, response);
|
|
505
300
|
},
|
|
506
|
-
catch: (cause) => new Error$
|
|
301
|
+
catch: (cause) => new Error$2({
|
|
507
302
|
category: "provider",
|
|
508
303
|
message: cause instanceof globalThis.Error ? cause.name : "OAuth provider request failed",
|
|
509
304
|
operation: "AuthorizationCode.complete",
|
|
@@ -517,14 +312,14 @@ const PayloadSchema = Schema.Struct({
|
|
|
517
312
|
state: Schema.String
|
|
518
313
|
});
|
|
519
314
|
function decodePayload(payload) {
|
|
520
|
-
return Schema.decodeUnknownEffect(Schema.fromJsonString(PayloadSchema))(payload.expose()).pipe(Effect.mapError(() => new Error$
|
|
315
|
+
return Schema.decodeUnknownEffect(Schema.fromJsonString(PayloadSchema))(payload.expose()).pipe(Effect.mapError(() => new Error$2({
|
|
521
316
|
category: "authorization",
|
|
522
317
|
message: "OAuth continuation payload is invalid",
|
|
523
318
|
operation: "AuthorizationCode",
|
|
524
319
|
retry: "after-user-action"
|
|
525
320
|
})));
|
|
526
321
|
}
|
|
527
|
-
function clientAuthentication(method, client) {
|
|
322
|
+
function clientAuthentication$1(method, client) {
|
|
528
323
|
switch (method.clientAuth) {
|
|
529
324
|
case "none": return Effect.succeed(oauth.None());
|
|
530
325
|
case "client_secret_basic": return client.clientSecret === void 0 ? failure$6("OAuth client secret is required") : Effect.succeed(oauth.ClientSecretBasic(client.clientSecret.expose()));
|
|
@@ -540,14 +335,14 @@ function requestOptions(fetchImplementation, signal) {
|
|
|
540
335
|
})
|
|
541
336
|
};
|
|
542
337
|
}
|
|
543
|
-
const failure$6 = (message) => Effect.fail(new Error$
|
|
338
|
+
const failure$6 = (message) => Effect.fail(new Error$2({
|
|
544
339
|
category: "authorization",
|
|
545
340
|
message,
|
|
546
341
|
operation: "AuthorizationCode",
|
|
547
342
|
retry: "after-user-action"
|
|
548
343
|
}));
|
|
549
344
|
function randomBytes(crypto, size) {
|
|
550
|
-
return crypto.randomBytes(size).pipe(Effect.mapError((cause) => new Error$
|
|
345
|
+
return crypto.randomBytes(size).pipe(Effect.mapError((cause) => new Error$2({
|
|
551
346
|
category: "validation",
|
|
552
347
|
message: cause.message,
|
|
553
348
|
operation: "AuthorizationCode.start",
|
|
@@ -555,7 +350,7 @@ function randomBytes(crypto, size) {
|
|
|
555
350
|
})));
|
|
556
351
|
}
|
|
557
352
|
function digest(crypto, value) {
|
|
558
|
-
return crypto.digest("SHA-256", new TextEncoder().encode(value)).pipe(Effect.mapError((cause) => new Error$
|
|
353
|
+
return crypto.digest("SHA-256", new TextEncoder().encode(value)).pipe(Effect.mapError((cause) => new Error$2({
|
|
559
354
|
category: "validation",
|
|
560
355
|
message: cause.message,
|
|
561
356
|
operation: "AuthorizationCode.start",
|
|
@@ -568,44 +363,6 @@ function base64Url(bytes) {
|
|
|
568
363
|
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
569
364
|
}
|
|
570
365
|
//#endregion
|
|
571
|
-
//#region src/auth/authorization.ts
|
|
572
|
-
const Capability = Schema.Literals(["dns:read", "dns:write"]);
|
|
573
|
-
const Evidence = Data.taggedEnum();
|
|
574
|
-
const EvidenceSchema = Schema.TaggedUnion({
|
|
575
|
-
Declared: {},
|
|
576
|
-
Exercised: { observedAt: Schema.DateFromString },
|
|
577
|
-
Introspected: { observedAt: Schema.DateFromString }
|
|
578
|
-
});
|
|
579
|
-
const CapabilityEvidence = Schema.Struct({
|
|
580
|
-
capability: Capability,
|
|
581
|
-
evidence: EvidenceSchema
|
|
582
|
-
});
|
|
583
|
-
const Revocation = Schema.TaggedUnion({
|
|
584
|
-
Active: {},
|
|
585
|
-
Pending: { requestedAt: Schema.DateFromString }
|
|
586
|
-
});
|
|
587
|
-
/** A provider credential authorization shared by one or more organization connections. */
|
|
588
|
-
const Schema$1 = Schema.Struct({
|
|
589
|
-
authorizedById: Schema.String,
|
|
590
|
-
capabilityEvidence: Schema.Array(CapabilityEvidence),
|
|
591
|
-
createdAt: Schema.DateFromString,
|
|
592
|
-
expiresAt: Schema.NullOr(Schema.DateFromString),
|
|
593
|
-
id: Schema.String,
|
|
594
|
-
method: Schema.Literals([
|
|
595
|
-
"integration",
|
|
596
|
-
"oauth2",
|
|
597
|
-
"token"
|
|
598
|
-
]),
|
|
599
|
-
providerContext: Envelope,
|
|
600
|
-
providerId: Schema.String,
|
|
601
|
-
requiredCapabilities: Schema.Array(Capability),
|
|
602
|
-
revocation: Revocation,
|
|
603
|
-
scopes: Schema.Array(Schema.String)
|
|
604
|
-
});
|
|
605
|
-
Effect.fn("ProviderAuthorization.decode")((input) => Schema.decodeUnknownEffect(Schema$1)(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
|
|
606
|
-
Effect.fn("ProviderAuthorization.validate")((input) => Schema.decodeUnknownEffect(Schema.toType(Schema$1))(input).pipe(Effect.mapError((cause) => new Error$2({ message: cause.message }))));
|
|
607
|
-
Schema.encodeSync(Schema$1);
|
|
608
|
-
//#endregion
|
|
609
366
|
//#region src/providers/cloudflare/protocol.ts
|
|
610
367
|
const ErrorDetail$1 = Schema.Struct({
|
|
611
368
|
code: Schema.Number,
|
|
@@ -702,7 +459,7 @@ const Data$1 = Schema.Struct({
|
|
|
702
459
|
weight: Schema.optionalKey(Schema.Number)
|
|
703
460
|
});
|
|
704
461
|
const decode$3 = Effect.fn("CloudflareRecords.decode")((record) => Effect.gen(function* () {
|
|
705
|
-
const name = yield* decode$
|
|
462
|
+
const name = yield* decode$5(record.name).pipe(Effect.match({
|
|
706
463
|
onFailure: () => null,
|
|
707
464
|
onSuccess: (value) => value
|
|
708
465
|
}));
|
|
@@ -720,23 +477,23 @@ const decode$3 = Effect.fn("CloudflareRecords.decode")((record) => Effect.gen(fu
|
|
|
720
477
|
const content = () => record.content === void 0 ? Effect.fail(failure$5("decodeRecord", `Cloudflare ${record.type} record has no content`)) : Effect.succeed(record.content);
|
|
721
478
|
switch (record.type) {
|
|
722
479
|
case "A":
|
|
723
|
-
case "AAAA": return yield* decode$
|
|
480
|
+
case "AAAA": return yield* decode$6({
|
|
724
481
|
...common,
|
|
725
482
|
_tag: record.type,
|
|
726
483
|
address: yield* content()
|
|
727
484
|
}).pipe(Effect.mapError((cause) => failure$5("decodeRecord", cause.message)));
|
|
728
485
|
case "CNAME":
|
|
729
|
-
case "NS": return yield* decode$
|
|
486
|
+
case "NS": return yield* decode$6({
|
|
730
487
|
...common,
|
|
731
488
|
_tag: record.type,
|
|
732
489
|
target: yield* content()
|
|
733
490
|
}).pipe(Effect.mapError((cause) => failure$5("decodeRecord", cause.message)));
|
|
734
|
-
case "TXT": return yield* decode$
|
|
491
|
+
case "TXT": return yield* decode$6({
|
|
735
492
|
...common,
|
|
736
493
|
_tag: "TXT",
|
|
737
494
|
value: yield* content()
|
|
738
495
|
}).pipe(Effect.mapError((cause) => failure$5("decodeRecord", cause.message)));
|
|
739
|
-
case "MX": return yield* decode$
|
|
496
|
+
case "MX": return yield* decode$6({
|
|
740
497
|
...common,
|
|
741
498
|
_tag: "MX",
|
|
742
499
|
exchange: yield* content(),
|
|
@@ -744,7 +501,7 @@ const decode$3 = Effect.fn("CloudflareRecords.decode")((record) => Effect.gen(fu
|
|
|
744
501
|
}).pipe(Effect.mapError((cause) => failure$5("decodeRecord", cause.message)));
|
|
745
502
|
case "CAA": {
|
|
746
503
|
const data = yield* decodeData(record);
|
|
747
|
-
return yield* decode$
|
|
504
|
+
return yield* decode$6({
|
|
748
505
|
...common,
|
|
749
506
|
_tag: "CAA",
|
|
750
507
|
...data
|
|
@@ -752,7 +509,7 @@ const decode$3 = Effect.fn("CloudflareRecords.decode")((record) => Effect.gen(fu
|
|
|
752
509
|
}
|
|
753
510
|
case "SRV": {
|
|
754
511
|
const data = yield* decodeData(record);
|
|
755
|
-
return yield* decode$
|
|
512
|
+
return yield* decode$6({
|
|
756
513
|
...common,
|
|
757
514
|
_tag: "SRV",
|
|
758
515
|
...data
|
|
@@ -1069,8 +826,8 @@ function makeClient$1(options) {
|
|
|
1069
826
|
};
|
|
1070
827
|
}
|
|
1071
828
|
const targetFromZone = Effect.fn("CloudflareClient.targetFromZone")((zone) => Effect.gen(function* () {
|
|
1072
|
-
const name = yield* decode$
|
|
1073
|
-
const nameservers = yield* Effect.forEach(zone.name_servers, (nameserver) => decode$
|
|
829
|
+
const name = yield* decode$5(zone.name).pipe(Effect.mapError((cause) => failure$4("listTargets", cause.message, { reason: "response" })));
|
|
830
|
+
const nameservers = yield* Effect.forEach(zone.name_servers, (nameserver) => decode$5(nameserver).pipe(Effect.mapError((cause) => failure$4("listTargets", cause.message, { reason: "response" }))));
|
|
1074
831
|
return {
|
|
1075
832
|
accountId: zone.account.id,
|
|
1076
833
|
accountKind: "account",
|
|
@@ -1085,8 +842,8 @@ const targetFromZone = Effect.fn("CloudflareClient.targetFromZone")((zone) => Ef
|
|
|
1085
842
|
};
|
|
1086
843
|
}));
|
|
1087
844
|
const projectZone$1 = Effect.fn("CloudflareClient.projectZone")((zone) => Effect.gen(function* () {
|
|
1088
|
-
const name = yield* decode$
|
|
1089
|
-
const nameservers = yield* Effect.forEach(zone.name_servers, (nameserver) => decode$
|
|
845
|
+
const name = yield* decode$5(zone.name).pipe(Effect.mapError((cause) => failure$4("listZones", cause.message, { reason: "response" })));
|
|
846
|
+
const nameservers = yield* Effect.forEach(zone.name_servers, (nameserver) => decode$5(nameserver).pipe(Effect.mapError((cause) => failure$4("listZones", cause.message, { reason: "response" }))));
|
|
1090
847
|
return {
|
|
1091
848
|
accountId: zone.account.id,
|
|
1092
849
|
id: zone.id,
|
|
@@ -1149,6 +906,7 @@ var auth_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
1149
906
|
oauthAuthentication: () => oauthAuthentication,
|
|
1150
907
|
oauthFlow: () => oauthFlow,
|
|
1151
908
|
oauthMethod: () => oauthMethod,
|
|
909
|
+
refreshCredential: () => refreshCredential,
|
|
1152
910
|
restore: () => restore$1,
|
|
1153
911
|
subjectResolver: () => subjectResolver,
|
|
1154
912
|
tokenConnectionMethod: () => tokenConnectionMethod$1,
|
|
@@ -1161,10 +919,11 @@ const authorizationServer = {
|
|
|
1161
919
|
revocation_endpoint: "https://dash.cloudflare.com/oauth2/revoke",
|
|
1162
920
|
token_endpoint: "https://dash.cloudflare.com/oauth2/token"
|
|
1163
921
|
};
|
|
1164
|
-
const
|
|
922
|
+
const Context$2 = Schema.Struct({
|
|
1165
923
|
accountId: Schema.optionalKey(Schema.String),
|
|
1166
924
|
tokenKind: Schema.Literals(["account", "user"])
|
|
1167
|
-
})
|
|
925
|
+
});
|
|
926
|
+
const contextCodec$1 = codec("cloudflare.v1", Context$2);
|
|
1168
927
|
/** Describes Cloudflare's caller-created API-token authorization method. */
|
|
1169
928
|
function tokenMethod$1(capabilities) {
|
|
1170
929
|
return {
|
|
@@ -1242,14 +1001,14 @@ function tokenConnectionMethod$1(options) {
|
|
|
1242
1001
|
return {
|
|
1243
1002
|
capabilityEvidence: validated.capabilities.map((capability) => ({
|
|
1244
1003
|
capability,
|
|
1245
|
-
evidence: Evidence.Introspected({ observedAt })
|
|
1004
|
+
evidence: Evidence$1.Introspected({ observedAt })
|
|
1246
1005
|
})),
|
|
1247
1006
|
credential: {
|
|
1248
1007
|
accessToken: token,
|
|
1008
|
+
expiresAt: validated.expiresAt,
|
|
1249
1009
|
refreshToken: null,
|
|
1250
1010
|
tokenType: "bearer"
|
|
1251
1011
|
},
|
|
1252
|
-
expiresAt: validated.expiresAt,
|
|
1253
1012
|
providerAccountId: validated.accountId,
|
|
1254
1013
|
providerContext: yield* contextCodec$1.encode(options.tokenKind === "account" ? {
|
|
1255
1014
|
accountId: validated.accountId,
|
|
@@ -1270,14 +1029,14 @@ const oauthAuthentication = Effect.fn("CloudflareAuth.oauthAuthentication")(func
|
|
|
1270
1029
|
return {
|
|
1271
1030
|
capabilityEvidence: options.capabilities.map((capability) => ({
|
|
1272
1031
|
capability,
|
|
1273
|
-
evidence: Evidence.Introspected({ observedAt })
|
|
1032
|
+
evidence: Evidence$1.Introspected({ observedAt })
|
|
1274
1033
|
})),
|
|
1275
1034
|
credential: {
|
|
1276
1035
|
accessToken: options.accessToken,
|
|
1036
|
+
expiresAt: resolved.expiresAt,
|
|
1277
1037
|
refreshToken: options.tokens.refresh_token === void 0 ? null : Value.from(options.tokens.refresh_token),
|
|
1278
1038
|
tokenType: options.tokens.token_type
|
|
1279
1039
|
},
|
|
1280
|
-
expiresAt: resolved.expiresAt,
|
|
1281
1040
|
providerAccountId: resolved.accountId,
|
|
1282
1041
|
providerContext: yield* contextCodec$1.encode({ tokenKind: "user" }),
|
|
1283
1042
|
scopes: (options.tokens.scope ?? "").split(" ").filter(Boolean)
|
|
@@ -1291,7 +1050,7 @@ function restore$1(options) {
|
|
|
1291
1050
|
if (options.authorization.revocation._tag !== "Active") return yield* Effect.fail(failure$3("restore", "Cloudflare authorization is pending revocation", "authorization"));
|
|
1292
1051
|
const missingCapability = options.authorization.requiredCapabilities.find((capability) => !options.authorization.capabilityEvidence.some((item) => item.capability === capability));
|
|
1293
1052
|
if (missingCapability !== void 0) return yield* Effect.fail(failure$3("restore", `Cloudflare authorization lacks evidence for ${missingCapability}`, "authorization"));
|
|
1294
|
-
if (options.
|
|
1053
|
+
if (options.credential.expiresAt !== null && (Number.isNaN(options.credential.expiresAt.valueOf()) || options.credential.expiresAt <= /* @__PURE__ */ new Date())) return yield* Effect.fail(failure$3("restore", "Cloudflare authorization has expired", "authentication"));
|
|
1295
1054
|
const context = yield* contextCodec$1.decode(options.authorization.providerContext).pipe(Effect.mapError((cause) => failure$3("restore", cause.message, "response")));
|
|
1296
1055
|
return make$5({
|
|
1297
1056
|
...context.accountId === void 0 ? {} : { accountId: context.accountId },
|
|
@@ -1303,6 +1062,47 @@ function restore$1(options) {
|
|
|
1303
1062
|
});
|
|
1304
1063
|
});
|
|
1305
1064
|
}
|
|
1065
|
+
/** Exchanges a Cloudflare refresh token for a fresh provider credential. */
|
|
1066
|
+
const refreshCredential = Effect.fn("CloudflareAuth.refreshCredential")(function* (options) {
|
|
1067
|
+
if (options.credential.refreshToken === null) return yield* new Error$2({
|
|
1068
|
+
category: "authorization",
|
|
1069
|
+
message: "Cloudflare credential has no refresh token",
|
|
1070
|
+
operation: "CloudflareAuth.refreshCredential",
|
|
1071
|
+
retry: "after-user-action"
|
|
1072
|
+
});
|
|
1073
|
+
const refreshToken = options.credential.refreshToken;
|
|
1074
|
+
const client = { client_id: options.client.clientId };
|
|
1075
|
+
const authentication = yield* Effect.try({
|
|
1076
|
+
try: () => clientAuthentication(options.clientAuth, options.client),
|
|
1077
|
+
catch: () => new Error$2({
|
|
1078
|
+
category: "authorization",
|
|
1079
|
+
message: "Cloudflare OAuth client authentication is invalid",
|
|
1080
|
+
operation: "CloudflareAuth.refreshCredential",
|
|
1081
|
+
retry: "never"
|
|
1082
|
+
})
|
|
1083
|
+
});
|
|
1084
|
+
const fetch = options.fetch;
|
|
1085
|
+
const tokens = yield* Effect.tryPromise({
|
|
1086
|
+
try: async (signal) => {
|
|
1087
|
+
const request = await oauth.refreshTokenGrantRequest(authorizationServer, client, authentication, refreshToken.expose(), fetch === void 0 ? { signal } : {
|
|
1088
|
+
signal,
|
|
1089
|
+
[oauth.customFetch]: (url, init) => fetch(url, {
|
|
1090
|
+
...init,
|
|
1091
|
+
body: init.body
|
|
1092
|
+
})
|
|
1093
|
+
});
|
|
1094
|
+
return oauth.processRefreshTokenResponse(authorizationServer, client, request);
|
|
1095
|
+
},
|
|
1096
|
+
catch: (cause) => refreshFailure(cause)
|
|
1097
|
+
});
|
|
1098
|
+
const now = yield* Clock.currentTimeMillis;
|
|
1099
|
+
return {
|
|
1100
|
+
accessToken: Value.from(tokens.access_token),
|
|
1101
|
+
expiresAt: typeof tokens.expires_in === "number" ? new Date(now + tokens.expires_in * 1e3) : null,
|
|
1102
|
+
refreshToken: tokens.refresh_token === void 0 ? refreshToken : Value.from(tokens.refresh_token),
|
|
1103
|
+
tokenType: tokens.token_type
|
|
1104
|
+
};
|
|
1105
|
+
});
|
|
1306
1106
|
/** Creates Cloudflare's OAuth implementation of the common interactive connection capability. */
|
|
1307
1107
|
function oauthFlow(options) {
|
|
1308
1108
|
const method = oauthMethod({
|
|
@@ -1348,6 +1148,20 @@ function failure$3(operation, message, reason) {
|
|
|
1348
1148
|
reason
|
|
1349
1149
|
});
|
|
1350
1150
|
}
|
|
1151
|
+
function clientAuthentication(method, client) {
|
|
1152
|
+
if (method === "none") return oauth.None();
|
|
1153
|
+
if (client.clientSecret === void 0) throw new Error("Client secret is required");
|
|
1154
|
+
return method === "client_secret_basic" ? oauth.ClientSecretBasic(client.clientSecret.expose()) : oauth.ClientSecretPost(client.clientSecret.expose());
|
|
1155
|
+
}
|
|
1156
|
+
function refreshFailure(cause) {
|
|
1157
|
+
if (cause instanceof oauth.ResponseBodyError && ["invalid_client", "invalid_grant"].includes(cause.error)) return new Error$2({
|
|
1158
|
+
category: "authorization",
|
|
1159
|
+
message: "Cloudflare authorization can no longer be refreshed",
|
|
1160
|
+
operation: "CloudflareAuth.refreshCredential",
|
|
1161
|
+
retry: "after-user-action"
|
|
1162
|
+
});
|
|
1163
|
+
return failure$3("refreshCredential", cause instanceof Error ? cause.message : "Cloudflare token refresh failed", cause instanceof oauth.ResponseBodyError ? "response" : "transport");
|
|
1164
|
+
}
|
|
1351
1165
|
//#endregion
|
|
1352
1166
|
//#region src/providers/vercel/protocol.ts
|
|
1353
1167
|
const Pagination = Schema.Struct({
|
|
@@ -1437,7 +1251,7 @@ const IntegrationToken = Schema.Struct({
|
|
|
1437
1251
|
//#region src/providers/vercel/records.ts
|
|
1438
1252
|
const decode$1 = Effect.fn("VercelRecords.decode")((zone, record) => Effect.gen(function* () {
|
|
1439
1253
|
const absolute = absoluteNameCandidate(zone, record.name);
|
|
1440
|
-
const name = yield* decode$
|
|
1254
|
+
const name = yield* decode$5(absolute).pipe(Effect.match({
|
|
1441
1255
|
onFailure: () => null,
|
|
1442
1256
|
onSuccess: (value) => value
|
|
1443
1257
|
}));
|
|
@@ -1452,7 +1266,7 @@ const decode$1 = Effect.fn("VercelRecords.decode")((zone, record) => Effect.gen(
|
|
|
1452
1266
|
policy: record.type === "CNAME" ? "exclusive" : "append",
|
|
1453
1267
|
ttl: record.ttl ?? 60
|
|
1454
1268
|
};
|
|
1455
|
-
const fromRecord = (input) => decode$
|
|
1269
|
+
const fromRecord = (input) => decode$6(input).pipe(Effect.mapError((cause) => failure$2("decodeRecord", cause.message)));
|
|
1456
1270
|
switch (record.type) {
|
|
1457
1271
|
case "A":
|
|
1458
1272
|
case "AAAA": return yield* fromRecord({
|
|
@@ -1673,7 +1487,7 @@ function makeClient(options) {
|
|
|
1673
1487
|
}
|
|
1674
1488
|
const domain = yield* discoverZone(name);
|
|
1675
1489
|
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" }));
|
|
1676
|
-
return yield* decode$
|
|
1490
|
+
return yield* decode$5(domain.name).pipe(Effect.mapError((cause) => failure$1("resolveZone", `Vercel returned an invalid storage zone: ${cause.message}`)));
|
|
1677
1491
|
}));
|
|
1678
1492
|
const listRecords = Effect.fn("VercelClient.listRecords")((zoneName) => Effect.gen(function* () {
|
|
1679
1493
|
const storageZone = yield* resolveZone(zoneName);
|
|
@@ -1819,8 +1633,8 @@ function hasDnsStorage(domain, configuredServiceType = domain.serviceType) {
|
|
|
1819
1633
|
return configuredServiceType === "zeit.world" || domain.zone === true || domain.intendedNameservers.length > 0;
|
|
1820
1634
|
}
|
|
1821
1635
|
const projectZone = Effect.fn("VercelClient.projectZone")((domain) => Effect.gen(function* () {
|
|
1822
|
-
const name = yield* decode$
|
|
1823
|
-
const nameservers = yield* Effect.forEach(domain.intendedNameservers, (nameserver) => decode$
|
|
1636
|
+
const name = yield* decode$5(domain.name).pipe(Effect.mapError((cause) => failure$1("listZones", cause.message, { reason: "response" })));
|
|
1637
|
+
const nameservers = yield* Effect.forEach(domain.intendedNameservers, (nameserver) => decode$5(nameserver).pipe(Effect.mapError((cause) => failure$1("listZones", cause.message, { reason: "response" }))));
|
|
1824
1638
|
return {
|
|
1825
1639
|
accountId: domain.teamId ?? domain.userId,
|
|
1826
1640
|
id: domain.id,
|
|
@@ -1830,8 +1644,8 @@ const projectZone = Effect.fn("VercelClient.projectZone")((domain) => Effect.gen
|
|
|
1830
1644
|
};
|
|
1831
1645
|
}));
|
|
1832
1646
|
const targetFromDomain = Effect.fn("VercelClient.targetFromDomain")((domain) => Effect.gen(function* () {
|
|
1833
|
-
const zoneName = yield* decode$
|
|
1834
|
-
const nameservers = yield* Effect.forEach(domain.nameservers.length > 0 ? domain.nameservers : domain.intendedNameservers, (nameserver) => decode$
|
|
1647
|
+
const zoneName = yield* decode$5(domain.name).pipe(Effect.mapError((cause) => failure$1("listTargets", cause.message, { reason: "response" })));
|
|
1648
|
+
const nameservers = yield* Effect.forEach(domain.nameservers.length > 0 ? domain.nameservers : domain.intendedNameservers, (nameserver) => decode$5(nameserver).pipe(Effect.mapError((cause) => failure$1("listTargets", cause.message, { reason: "response" }))));
|
|
1835
1649
|
return {
|
|
1836
1650
|
accountId: domain.teamId ?? domain.userId,
|
|
1837
1651
|
accountKind: domain.teamId === null ? "personal" : "team",
|
|
@@ -1895,13 +1709,14 @@ var auth_exports = /* @__PURE__ */ __exportAll({
|
|
|
1895
1709
|
tokenConnectionMethod: () => tokenConnectionMethod,
|
|
1896
1710
|
tokenMethod: () => tokenMethod
|
|
1897
1711
|
});
|
|
1898
|
-
const
|
|
1712
|
+
const Context$1 = Schema.TaggedUnion({
|
|
1899
1713
|
personal: { installationId: Schema.NullOr(Schema.String) },
|
|
1900
1714
|
team: {
|
|
1901
1715
|
installationId: Schema.NullOr(Schema.String),
|
|
1902
1716
|
teamId: Schema.String
|
|
1903
1717
|
}
|
|
1904
|
-
})
|
|
1718
|
+
});
|
|
1719
|
+
const contextCodec = codec("vercel.v1", Context$1);
|
|
1905
1720
|
/** Describes Vercel's caller-created personal access-token method. */
|
|
1906
1721
|
function tokenMethod(capabilities) {
|
|
1907
1722
|
return {
|
|
@@ -1979,14 +1794,14 @@ function tokenConnectionMethod(options) {
|
|
|
1979
1794
|
return {
|
|
1980
1795
|
capabilityEvidence: validated.capabilities.map((capability) => ({
|
|
1981
1796
|
capability,
|
|
1982
|
-
evidence: Evidence.Introspected({ observedAt })
|
|
1797
|
+
evidence: Evidence$1.Introspected({ observedAt })
|
|
1983
1798
|
})),
|
|
1984
1799
|
credential: {
|
|
1985
1800
|
accessToken: token,
|
|
1801
|
+
expiresAt: validated.expiresAt,
|
|
1986
1802
|
refreshToken: null,
|
|
1987
1803
|
tokenType: "bearer"
|
|
1988
1804
|
},
|
|
1989
|
-
expiresAt: validated.expiresAt,
|
|
1990
1805
|
providerAccountId: validated.accountId,
|
|
1991
1806
|
providerContext: yield* contextCodec.encode(options.context._tag === "team" ? {
|
|
1992
1807
|
_tag: "team",
|
|
@@ -2011,14 +1826,14 @@ const integrationAuthentication = Effect.fn("VercelAuth.integrationAuthenticatio
|
|
|
2011
1826
|
return {
|
|
2012
1827
|
capabilityEvidence: options.capabilities.map((capability) => ({
|
|
2013
1828
|
capability,
|
|
2014
|
-
evidence: Evidence.Introspected({ observedAt })
|
|
1829
|
+
evidence: Evidence$1.Introspected({ observedAt })
|
|
2015
1830
|
})),
|
|
2016
1831
|
credential: {
|
|
2017
1832
|
accessToken: exchanged.accessToken,
|
|
1833
|
+
expiresAt: null,
|
|
2018
1834
|
refreshToken: null,
|
|
2019
1835
|
tokenType: "bearer"
|
|
2020
1836
|
},
|
|
2021
|
-
expiresAt: null,
|
|
2022
1837
|
providerAccountId: exchanged.context._tag === "team" ? exchanged.context.teamId : exchanged.userId,
|
|
2023
1838
|
providerContext: yield* contextCodec.encode(exchanged.context._tag === "team" ? {
|
|
2024
1839
|
_tag: "team",
|
|
@@ -2038,7 +1853,7 @@ function restore(options) {
|
|
|
2038
1853
|
if (options.authorization.revocation._tag !== "Active") return yield* Effect.fail(failure("restore", "Vercel authorization is pending revocation", "authorization"));
|
|
2039
1854
|
const missingCapability = options.authorization.requiredCapabilities.find((capability) => !options.authorization.capabilityEvidence.some((item) => item.capability === capability));
|
|
2040
1855
|
if (missingCapability !== void 0) return yield* Effect.fail(failure("restore", `Vercel authorization lacks evidence for ${missingCapability}`, "authorization"));
|
|
2041
|
-
if (options.
|
|
1856
|
+
if (options.credential.expiresAt !== null && (Number.isNaN(options.credential.expiresAt.valueOf()) || options.credential.expiresAt <= /* @__PURE__ */ new Date())) return yield* Effect.fail(failure("restore", "Vercel authorization has expired", "authentication"));
|
|
2042
1857
|
const context = yield* contextCodec.decode(options.authorization.providerContext).pipe(Effect.mapError((cause) => failure("restore", cause.message, "response")));
|
|
2043
1858
|
return make$4({
|
|
2044
1859
|
...options.baseUrl === void 0 ? {} : { baseUrl: options.baseUrl },
|
|
@@ -2058,7 +1873,7 @@ function integrationFlow(options) {
|
|
|
2058
1873
|
const Payload = Schema.fromJsonString(Schema.Struct({ state: Schema.String }));
|
|
2059
1874
|
return {
|
|
2060
1875
|
complete: Effect.fn("VercelAuth.integrationFlow.complete")(function* (payload, callbackUrl) {
|
|
2061
|
-
const continuation = yield* Schema.decodeUnknownEffect(Payload)(payload.expose()).pipe(Effect.mapError(() => new Error$
|
|
1876
|
+
const continuation = yield* Schema.decodeUnknownEffect(Payload)(payload.expose()).pipe(Effect.mapError(() => new Error$2({
|
|
2062
1877
|
category: "authorization",
|
|
2063
1878
|
message: "Vercel Integration continuation payload is invalid",
|
|
2064
1879
|
operation: "VercelAuth.integrationFlow.complete",
|
|
@@ -2066,7 +1881,7 @@ function integrationFlow(options) {
|
|
|
2066
1881
|
})));
|
|
2067
1882
|
const code = callbackUrl.searchParams.get("code");
|
|
2068
1883
|
const configurationId = callbackUrl.searchParams.get("configurationId");
|
|
2069
|
-
if (callbackUrl.searchParams.get("state") !== continuation.state || code === null || configurationId === null) return yield* new Error$
|
|
1884
|
+
if (callbackUrl.searchParams.get("state") !== continuation.state || code === null || configurationId === null) return yield* new Error$2({
|
|
2070
1885
|
category: "authorization",
|
|
2071
1886
|
message: "Vercel Integration callback does not match its continuation",
|
|
2072
1887
|
operation: "VercelAuth.integrationFlow.complete",
|
|
@@ -2084,13 +1899,13 @@ function integrationFlow(options) {
|
|
|
2084
1899
|
});
|
|
2085
1900
|
const callbackTeamId = callbackUrl.searchParams.get("teamId");
|
|
2086
1901
|
if (callbackTeamId !== null) {
|
|
2087
|
-
const context = yield* contextCodec.decode(authentication.providerContext).pipe(Effect.mapError((cause) => new Error$
|
|
1902
|
+
const context = yield* contextCodec.decode(authentication.providerContext).pipe(Effect.mapError((cause) => new Error$2({
|
|
2088
1903
|
category: "provider",
|
|
2089
1904
|
message: cause.message,
|
|
2090
1905
|
operation: "VercelAuth.integrationFlow.complete",
|
|
2091
1906
|
retry: "unknown"
|
|
2092
1907
|
})));
|
|
2093
|
-
if (context._tag !== "team" || context.teamId !== callbackTeamId) return yield* new Error$
|
|
1908
|
+
if (context._tag !== "team" || context.teamId !== callbackTeamId) return yield* new Error$2({
|
|
2094
1909
|
category: "authorization",
|
|
2095
1910
|
message: "Vercel Integration callback team does not match the exchanged installation",
|
|
2096
1911
|
operation: "VercelAuth.integrationFlow.complete",
|
|
@@ -2167,7 +1982,7 @@ function parse(type, input) {
|
|
|
2167
1982
|
try {
|
|
2168
1983
|
return Schema.decodeUnknownSync(schema)(input);
|
|
2169
1984
|
} catch (cause) {
|
|
2170
|
-
throw new Error$
|
|
1985
|
+
throw new Error$1({ message: cause instanceof Error ? cause.message : String(cause) });
|
|
2171
1986
|
}
|
|
2172
1987
|
}
|
|
2173
1988
|
function tokenizedDomain(length, domainIndex) {
|
|
@@ -2270,7 +2085,7 @@ function decodeAnswer(answer) {
|
|
|
2270
2085
|
})
|
|
2271
2086
|
});
|
|
2272
2087
|
if (decoded === void 0) return null;
|
|
2273
|
-
const name = yield* decode$
|
|
2088
|
+
const name = yield* decode$5(answer.name);
|
|
2274
2089
|
const data = yield* Effect.try({
|
|
2275
2090
|
try: () => parse(decoded.type, decoded.data),
|
|
2276
2091
|
catch: (cause) => new Error$4({
|
|
@@ -2527,13 +2342,13 @@ function observeProvider(provider, zone, requirement) {
|
|
|
2527
2342
|
}
|
|
2528
2343
|
function observePublicDns(requirement, policy) {
|
|
2529
2344
|
return Effect.gen(function* () {
|
|
2530
|
-
const validatedPolicy = yield* Schema.decodeUnknownEffect(Policy.Schema)(policy).pipe(Effect.mapError((cause) => new Error$
|
|
2345
|
+
const validatedPolicy = yield* Schema.decodeUnknownEffect(Policy.Schema)(policy).pipe(Effect.mapError((cause) => new Error$1({ message: cause.message })));
|
|
2531
2346
|
const configuredPool = yield* Effect.serviceOption(Service);
|
|
2532
2347
|
const evidence = yield* Option.getOrElse(configuredPool, () => defaultMake()).observe({
|
|
2533
2348
|
name: requirement.name,
|
|
2534
2349
|
type: requirement._tag
|
|
2535
2350
|
});
|
|
2536
|
-
if (validatedPolicy._tag === "Quorum" && validatedPolicy.minimum > evidence.length) return yield* new Error$
|
|
2351
|
+
if (validatedPolicy._tag === "Quorum" && validatedPolicy.minimum > evidence.length) return yield* new Error$1({ message: `Quorum minimum ${validatedPolicy.minimum} exceeds the ${evidence.length} configured resolvers` });
|
|
2537
2352
|
return evaluatePublicDns(requirement, validatedPolicy, evidence);
|
|
2538
2353
|
});
|
|
2539
2354
|
}
|
|
@@ -2576,6 +2391,6 @@ function recordValue(requirement) {
|
|
|
2576
2391
|
}
|
|
2577
2392
|
}
|
|
2578
2393
|
//#endregion
|
|
2579
|
-
export { manifest_exports as $, discovery as A,
|
|
2394
|
+
export { manifest_exports as $, discovery as A, tokenMethod$1 as B, integrationFlow as C, tokenConnectionMethod as D, restore as E, oauthMethod as F, authorize as G, client_exports$1 as H, refreshCredential as I, selection_exports as J, connection_authorization_exports as K, restore$1 as L, auth_exports$1 as M, manifest$1 as N, tokenMethod as O, oauthFlow as P, decode$4 as Q, subjectResolver as R, exchangeCode as S, manifest as T, discovery$1 as U, tokenValidator as V, make$5 as W, Method as X, secret_exports as Y, Schema$1 as Z, toAsync$1 as _, Result as a, dns_data_exports as b, Observation as c, defaultMake as d, diagnostic_exports as et, make as f, cloudflare_doh_exports as g, toAsync as h, PublicDnsObservation as i, make$4 as j, client_exports as k, Policy as l, google_doh_exports as m, ProviderObservation as n, observe as o, resolver_pool_exports as p, session_exports as q, PublicDns as r, verify_exports as s, Provider as t, version as tt, Service as u, doh_exports as v, integrationMethod as w, auth_exports as x, toAsync$2 as y, tokenConnectionMethod$1 as z };
|
|
2580
2395
|
|
|
2581
|
-
//# sourceMappingURL=verify-
|
|
2396
|
+
//# sourceMappingURL=verify-DAtUAEeg.mjs.map
|