domainkit 0.8.0 → 0.9.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 +213 -41
- package/dist/Approval.mjs +34 -0
- package/dist/Approval.mjs.map +1 -0
- package/dist/Cleanup.mjs +97 -0
- package/dist/Cleanup.mjs.map +1 -0
- package/dist/Cloudflare.mjs +225 -0
- package/dist/Cloudflare.mjs.map +1 -0
- package/dist/Connect.mjs +463 -0
- package/dist/Connect.mjs.map +1 -0
- package/dist/Custody.mjs +64 -0
- package/dist/Custody.mjs.map +1 -0
- package/dist/DnsRecord.mjs +213 -0
- package/dist/DnsRecord.mjs.map +1 -0
- package/dist/DomainKit.mjs +34 -0
- package/dist/DomainKit.mjs.map +1 -0
- package/dist/DomainName.mjs +100 -0
- package/dist/DomainName.mjs.map +1 -0
- package/dist/Plan.mjs +102 -0
- package/dist/Plan.mjs.map +1 -0
- package/dist/Principal.mjs +23 -0
- package/dist/Principal.mjs.map +1 -0
- package/dist/Provider.mjs +130 -0
- package/dist/Provider.mjs.map +1 -0
- package/dist/Providers.mjs +40 -0
- package/dist/Providers.mjs.map +1 -0
- package/dist/Provision.mjs +93 -0
- package/dist/Provision.mjs.map +1 -0
- package/dist/Reason.mjs +162 -0
- package/dist/Reason.mjs.map +1 -0
- package/dist/Receipt.mjs +71 -0
- package/dist/Receipt.mjs.map +1 -0
- package/dist/Resolver.mjs +75 -0
- package/dist/Resolver.mjs.map +1 -0
- package/dist/Server.mjs +516 -0
- package/dist/Server.mjs.map +1 -0
- package/dist/Storage.mjs +236 -0
- package/dist/Storage.mjs.map +1 -0
- package/dist/Testing.mjs +226 -0
- package/dist/Testing.mjs.map +1 -0
- package/dist/Transport.mjs +187 -0
- package/dist/Transport.mjs.map +1 -0
- package/dist/Vercel.mjs +116 -0
- package/dist/Vercel.mjs.map +1 -0
- package/dist/Verify.mjs +292 -0
- package/dist/Verify.mjs.map +1 -0
- package/dist/{rolldown-runtime-D7D4PA-g.mjs → _virtual/_rolldown/runtime.mjs} +1 -1
- package/dist/entry/client.mjs +2 -0
- package/dist/entry/server.mjs +2 -0
- package/dist/entry/testing.mjs +3 -0
- package/dist/index.mjs +33 -462
- package/dist/index.mjs.map +1 -1
- package/dist/internal/aes.mjs +61 -0
- package/dist/internal/aes.mjs.map +1 -0
- package/dist/internal/attempts.mjs +284 -0
- package/dist/internal/attempts.mjs.map +1 -0
- package/dist/internal/cloudflare/client.mjs +100 -0
- package/dist/internal/cloudflare/client.mjs.map +1 -0
- package/dist/internal/cloudflare/protocol.mjs +59 -0
- package/dist/internal/cloudflare/protocol.mjs.map +1 -0
- package/dist/internal/cloudflare/records.mjs +156 -0
- package/dist/internal/cloudflare/records.mjs.map +1 -0
- package/dist/internal/config.mjs +13 -0
- package/dist/internal/config.mjs.map +1 -0
- package/dist/internal/conformance/provider.mjs +207 -0
- package/dist/internal/conformance/provider.mjs.map +1 -0
- package/dist/internal/conformance/storage.mjs +428 -0
- package/dist/internal/conformance/storage.mjs.map +1 -0
- package/dist/internal/digest.mjs +25 -0
- package/dist/internal/digest.mjs.map +1 -0
- package/dist/internal/doh.mjs +153 -0
- package/dist/internal/doh.mjs.map +1 -0
- package/dist/internal/error.mjs +69 -0
- package/dist/internal/error.mjs.map +1 -0
- package/dist/internal/http.mjs +90 -0
- package/dist/internal/http.mjs.map +1 -0
- package/dist/internal/ids.mjs +8 -0
- package/dist/internal/ids.mjs.map +1 -0
- package/dist/internal/oauth.mjs +113 -0
- package/dist/internal/oauth.mjs.map +1 -0
- package/dist/internal/planner.mjs +88 -0
- package/dist/internal/planner.mjs.map +1 -0
- package/dist/internal/provider-async.mjs +83 -0
- package/dist/internal/provider-async.mjs.map +1 -0
- package/dist/internal/storage-memory.mjs +302 -0
- package/dist/internal/storage-memory.mjs.map +1 -0
- package/dist/internal/vercel/client.mjs +122 -0
- package/dist/internal/vercel/client.mjs.map +1 -0
- package/dist/internal/vercel/protocol.mjs +80 -0
- package/dist/internal/vercel/protocol.mjs.map +1 -0
- package/dist/internal/vercel/records.mjs +151 -0
- package/dist/internal/vercel/records.mjs.map +1 -0
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/dist/types/Approval.d.ts +26 -0
- package/dist/types/Cleanup.d.ts +41 -0
- package/dist/types/Cloudflare.d.ts +36 -0
- package/dist/types/Connect.d.ts +506 -0
- package/dist/types/Custody.d.ts +38 -0
- package/dist/types/DnsRecord.d.ts +158 -0
- package/dist/types/DomainKit.d.ts +31 -0
- package/dist/types/DomainName.d.ts +27 -0
- package/dist/types/Plan.d.ts +76 -0
- package/dist/types/Principal.d.ts +18 -0
- package/dist/types/Provider.d.ts +248 -0
- package/dist/types/Providers.d.ts +16 -0
- package/dist/types/Provision.d.ts +75 -0
- package/dist/types/Reason.d.ts +118 -0
- package/dist/types/Receipt.d.ts +55 -0
- package/dist/types/Resolver.d.ts +135 -0
- package/dist/types/Server.d.ts +6523 -0
- package/dist/types/Storage.d.ts +314 -0
- package/dist/types/Testing.d.ts +84 -0
- package/dist/types/Transport.d.ts +124 -0
- package/dist/types/Vercel.d.ts +25 -0
- package/dist/types/Verify.d.ts +109 -0
- package/dist/types/entry/client.d.ts +2 -0
- package/dist/types/entry/server.d.ts +2 -0
- package/dist/types/entry/testing.d.ts +3 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/internal/aes.d.ts +8 -0
- package/dist/types/internal/attempts.d.ts +40 -0
- package/dist/types/internal/cloudflare/client.d.ts +23 -0
- package/dist/types/internal/cloudflare/protocol.d.ts +71 -0
- package/dist/types/internal/cloudflare/records.d.ts +8 -0
- package/dist/types/internal/config.d.ts +4 -0
- package/dist/types/internal/conformance/provider.d.ts +12 -0
- package/dist/types/internal/conformance/storage.d.ts +14 -0
- package/dist/types/internal/digest.d.ts +10 -0
- package/dist/types/internal/doh.d.ts +19 -0
- package/dist/types/internal/error.d.ts +24 -0
- package/dist/types/internal/http.d.ts +27 -0
- package/dist/types/internal/ids.d.ts +3 -0
- package/dist/types/internal/oauth.d.ts +58 -0
- package/dist/types/internal/planner.d.ts +22 -0
- package/dist/types/internal/provider-async.d.ts +78 -0
- package/dist/types/internal/storage-memory.d.ts +2 -0
- package/dist/types/internal/vercel/client.d.ts +29 -0
- package/dist/types/internal/vercel/protocol.d.ts +124 -0
- package/dist/types/internal/vercel/records.d.ts +7 -0
- package/package.json +88 -12
- package/dist/canonical-json-CQYKsZw7.mjs +0 -310
- package/dist/canonical-json-CQYKsZw7.mjs.map +0 -1
- package/dist/connect-D-X8T9W8.d.mts +0 -1597
- package/dist/connect-oI8hcMxc.mjs +0 -185
- package/dist/connect-oI8hcMxc.mjs.map +0 -1
- package/dist/connection-Dp6ZdSo8.d.mts +0 -186
- package/dist/connection-api-lqG1nBtD.d.mts +0 -26
- package/dist/index.d.mts +0 -1551
- package/dist/managed-dns-connections-C3A_GBaz.mjs +0 -99
- package/dist/managed-dns-connections-C3A_GBaz.mjs.map +0 -1
- package/dist/promise.d.mts +0 -378
- package/dist/promise.mjs +0 -598
- package/dist/promise.mjs.map +0 -1
- package/dist/resolver-BeGz1ukw.mjs +0 -921
- package/dist/resolver-BeGz1ukw.mjs.map +0 -1
- package/dist/resolver-xoSwyXDJ.d.mts +0 -3734
- package/dist/server.d.mts +0 -128
- package/dist/server.mjs +0 -319
- package/dist/server.mjs.map +0 -1
- package/dist/testing.d.mts +0 -62
- package/dist/testing.mjs +0 -507
- package/dist/testing.mjs.map +0 -1
- package/dist/verify-DvGPb5C9.mjs +0 -2402
- package/dist/verify-DvGPb5C9.mjs.map +0 -1
- package/dist/verify-FpunAcM7.d.mts +0 -1335
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { l as Revocation, s as Service, w as project } from "./canonical-json-CQYKsZw7.mjs";
|
|
2
|
-
import { Clock, Crypto, Data, Effect, Schema } from "effect";
|
|
3
|
-
//#region src/auth/connect.ts
|
|
4
|
-
const Method = Data.taggedEnum();
|
|
5
|
-
const StartResult = Data.taggedEnum();
|
|
6
|
-
var Error = class extends Schema.TaggedError()("ConnectionError", {
|
|
7
|
-
category: Schema.Literals([
|
|
8
|
-
"authorization",
|
|
9
|
-
"provider",
|
|
10
|
-
"validation"
|
|
11
|
-
]),
|
|
12
|
-
message: Schema.String,
|
|
13
|
-
operation: Schema.String,
|
|
14
|
-
retry: Schema.Literals([
|
|
15
|
-
"never",
|
|
16
|
-
"after-user-action",
|
|
17
|
-
"safe",
|
|
18
|
-
"unknown"
|
|
19
|
-
])
|
|
20
|
-
}) {};
|
|
21
|
-
const missingCapability = (authentication, requiredCapabilities) => requiredCapabilities.find((capability) => !authentication.capabilityEvidence.some((item) => item.capability === capability));
|
|
22
|
-
const freshId = Effect.fn("Connection.freshId")(function* () {
|
|
23
|
-
return yield* (yield* Crypto.Crypto).randomUUIDv4.pipe(Effect.mapError((cause) => new Error({
|
|
24
|
-
category: "validation",
|
|
25
|
-
message: cause.message,
|
|
26
|
-
operation: "Connection.connect",
|
|
27
|
-
retry: "safe"
|
|
28
|
-
})));
|
|
29
|
-
});
|
|
30
|
-
/** Persist one authenticated provider connection, optionally reusing a proven authorization. */
|
|
31
|
-
const connect = Effect.fn("Connection.connect")(function* (input) {
|
|
32
|
-
const repository = yield* Service;
|
|
33
|
-
const now = new Date(yield* Clock.currentTimeMillis);
|
|
34
|
-
const missing = missingCapability(input.authentication, input.requiredCapabilities);
|
|
35
|
-
if (missing !== void 0) return yield* new Error({
|
|
36
|
-
category: "authorization",
|
|
37
|
-
message: `Provider authorization lacks evidence for ${missing}`,
|
|
38
|
-
operation: "Connection.connect",
|
|
39
|
-
retry: "after-user-action"
|
|
40
|
-
});
|
|
41
|
-
const existing = input.authorizationId === void 0 ? null : yield* repository.get(input.authorizationId);
|
|
42
|
-
if (input.authorizationId !== void 0 && existing === null) return yield* new Error({
|
|
43
|
-
category: "authorization",
|
|
44
|
-
message: "Provider authorization does not exist",
|
|
45
|
-
operation: "Connection.connect",
|
|
46
|
-
retry: "after-user-action"
|
|
47
|
-
});
|
|
48
|
-
if (existing?.authorization.revocation._tag === "Pending") return yield* new Error({
|
|
49
|
-
category: "authorization",
|
|
50
|
-
message: "Provider authorization is awaiting revocation recovery",
|
|
51
|
-
operation: "Connection.connect",
|
|
52
|
-
retry: "after-user-action"
|
|
53
|
-
});
|
|
54
|
-
if (existing !== null && (existing.authorization.providerId !== input.providerId || existing.authorization.method !== input.method)) return yield* new Error({
|
|
55
|
-
category: "authorization",
|
|
56
|
-
message: "Provider proof does not match the existing authorization",
|
|
57
|
-
operation: "Connection.connect",
|
|
58
|
-
retry: "never"
|
|
59
|
-
});
|
|
60
|
-
const authorizationId = existing?.authorization.id ?? (yield* freshId());
|
|
61
|
-
const authorization = existing === null ? {
|
|
62
|
-
authorizedById: input.authorizedById,
|
|
63
|
-
capabilityEvidence: [...input.authentication.capabilityEvidence],
|
|
64
|
-
createdAt: now,
|
|
65
|
-
id: authorizationId,
|
|
66
|
-
method: input.method,
|
|
67
|
-
providerContext: input.authentication.providerContext,
|
|
68
|
-
providerId: input.providerId,
|
|
69
|
-
requiredCapabilities: [...input.requiredCapabilities],
|
|
70
|
-
revocation: Revocation.Active(),
|
|
71
|
-
scopes: [...input.authentication.scopes]
|
|
72
|
-
} : {
|
|
73
|
-
...existing.authorization,
|
|
74
|
-
capabilityEvidence: mergeEvidence(existing.authorization.capabilityEvidence, input.authentication.capabilityEvidence),
|
|
75
|
-
method: input.method,
|
|
76
|
-
providerContext: input.authentication.providerContext,
|
|
77
|
-
requiredCapabilities: [...input.requiredCapabilities],
|
|
78
|
-
revocation: Revocation.Active(),
|
|
79
|
-
scopes: [...input.authentication.scopes]
|
|
80
|
-
};
|
|
81
|
-
const existingConnection = yield* repository.findConnection(input.ownerId, authorizationId);
|
|
82
|
-
const connection = {
|
|
83
|
-
authorizationId,
|
|
84
|
-
createdAt: existingConnection?.createdAt ?? now,
|
|
85
|
-
id: existingConnection?.id ?? (yield* freshId()),
|
|
86
|
-
method: input.method,
|
|
87
|
-
ownerId: input.ownerId,
|
|
88
|
-
providerId: input.providerId
|
|
89
|
-
};
|
|
90
|
-
return yield* repository.connect({
|
|
91
|
-
authorization,
|
|
92
|
-
connection,
|
|
93
|
-
credential: input.authentication.credential,
|
|
94
|
-
...existing === null ? {} : { expectedAuthorizationId: existing.authorization.id },
|
|
95
|
-
...existingConnection === null ? {} : { expectedConnectionId: existingConnection.id }
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
const start = Effect.fn("Connection.start")(function* (input) {
|
|
99
|
-
if (input.method._tag === "Interactive") {
|
|
100
|
-
const crypto = yield* Crypto.Crypto;
|
|
101
|
-
const now = yield* Clock.currentTimeMillis;
|
|
102
|
-
const continuationId = yield* crypto.randomUUIDv4.pipe(Effect.mapError((cause) => new Error({
|
|
103
|
-
category: "validation",
|
|
104
|
-
message: cause.message,
|
|
105
|
-
operation: "Connection.start",
|
|
106
|
-
retry: "safe"
|
|
107
|
-
})));
|
|
108
|
-
const started = yield* input.method.flow.start(continuationId);
|
|
109
|
-
yield* input.method.continuations.put({
|
|
110
|
-
authorizedById: input.authorizedById,
|
|
111
|
-
...input.authorizationId === void 0 ? {} : { authorizationId: input.authorizationId },
|
|
112
|
-
expiresAt: new Date(now + (input.method.ttlMs ?? 6e5)),
|
|
113
|
-
id: continuationId,
|
|
114
|
-
method: input.method.flow.method,
|
|
115
|
-
ownerId: input.ownerId,
|
|
116
|
-
payload: started.payload,
|
|
117
|
-
providerId: input.method.flow.providerId,
|
|
118
|
-
requiredCapabilities: [...input.method.flow.requiredCapabilities]
|
|
119
|
-
});
|
|
120
|
-
return StartResult.Redirect({
|
|
121
|
-
authorizationUrl: started.authorizationUrl,
|
|
122
|
-
continuationId
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
const authentication = yield* input.method.authenticate(input.method.token);
|
|
126
|
-
const aggregate = yield* connect({
|
|
127
|
-
authentication,
|
|
128
|
-
authorizedById: input.authorizedById,
|
|
129
|
-
...input.authorizationId === void 0 ? {} : { authorizationId: input.authorizationId },
|
|
130
|
-
method: "token",
|
|
131
|
-
ownerId: input.ownerId,
|
|
132
|
-
providerId: input.method.providerId,
|
|
133
|
-
requiredCapabilities: input.method.requiredCapabilities
|
|
134
|
-
});
|
|
135
|
-
const storedConnection = aggregate.connections.find(({ ownerId }) => ownerId === input.ownerId);
|
|
136
|
-
if (storedConnection === void 0) return yield* new Error({
|
|
137
|
-
category: "validation",
|
|
138
|
-
message: "Connected provider authorization returned no organization connection",
|
|
139
|
-
operation: "Connection.start",
|
|
140
|
-
retry: "safe"
|
|
141
|
-
});
|
|
142
|
-
return StartResult.Connected({ connection: project(storedConnection, aggregate.authorization, aggregate.credential) });
|
|
143
|
-
});
|
|
144
|
-
const complete = Effect.fn("Connection.complete")(function* (input) {
|
|
145
|
-
const continuation = yield* input.continuations.consume(input.continuationId, new Date(yield* Clock.currentTimeMillis));
|
|
146
|
-
if (continuation === null) return yield* new Error({
|
|
147
|
-
category: "authorization",
|
|
148
|
-
message: "Connection continuation is expired, unknown, or already consumed",
|
|
149
|
-
operation: "Connection.complete",
|
|
150
|
-
retry: "after-user-action"
|
|
151
|
-
});
|
|
152
|
-
if (continuation.providerId !== input.flow.providerId || continuation.method !== input.flow.method) return yield* new Error({
|
|
153
|
-
category: "authorization",
|
|
154
|
-
message: "Connection continuation does not match the provider flow",
|
|
155
|
-
operation: "Connection.complete",
|
|
156
|
-
retry: "never"
|
|
157
|
-
});
|
|
158
|
-
const authentication = yield* input.flow.complete(continuation.payload, input.callbackUrl);
|
|
159
|
-
const aggregate = yield* connect({
|
|
160
|
-
authentication,
|
|
161
|
-
authorizedById: continuation.authorizedById,
|
|
162
|
-
...continuation.authorizationId === void 0 ? {} : { authorizationId: continuation.authorizationId },
|
|
163
|
-
method: continuation.method,
|
|
164
|
-
ownerId: continuation.ownerId,
|
|
165
|
-
providerId: continuation.providerId,
|
|
166
|
-
requiredCapabilities: continuation.requiredCapabilities
|
|
167
|
-
});
|
|
168
|
-
const storedConnection = aggregate.connections.find(({ ownerId }) => ownerId === continuation.ownerId);
|
|
169
|
-
if (storedConnection === void 0) return yield* new Error({
|
|
170
|
-
category: "validation",
|
|
171
|
-
message: "Connected provider authorization returned no organization connection",
|
|
172
|
-
operation: "Connection.complete",
|
|
173
|
-
retry: "safe"
|
|
174
|
-
});
|
|
175
|
-
return project(storedConnection, aggregate.authorization, aggregate.credential);
|
|
176
|
-
});
|
|
177
|
-
function mergeEvidence(current, incoming) {
|
|
178
|
-
const byCapability = new Map(current.map((item) => [item.capability, item]));
|
|
179
|
-
for (const item of incoming) byCapability.set(item.capability, item);
|
|
180
|
-
return [...byCapability.values()];
|
|
181
|
-
}
|
|
182
|
-
//#endregion
|
|
183
|
-
export { start as a, complete as i, Method as n, StartResult as r, Error as t };
|
|
184
|
-
|
|
185
|
-
//# sourceMappingURL=connect-oI8hcMxc.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect-oI8hcMxc.mjs","names":["Repository.Service","Connection.project"],"sources":["../src/auth/connect.ts"],"sourcesContent":["import { Clock, Crypto, Data, Effect, Schema } from \"effect\";\n\nimport { CryptoError } from \"../plan/canonical-json.ts\";\nimport type { Error as InvalidInputError } from \"../invalid-input.ts\";\nimport type * as DnsProvider from \"../provider/provider.ts\";\nimport * as ProviderAuthorization from \"./authorization.ts\";\nimport * as Connection from \"./connection.ts\";\nimport * as Repository from \"./lifecycle-repository.ts\";\nimport type * as ProviderContext from \"./provider-context.ts\";\nimport type * as Secret from \"./secret.ts\";\n\nexport interface Authentication {\n readonly capabilityEvidence: ReadonlyArray<ProviderAuthorization.CapabilityEvidence>;\n readonly credential: Connection.StoredCredential;\n /** Provider-specific subject identity used only during authentication; targets are selected later. */\n readonly providerAccountId: string;\n readonly providerContext: ProviderContext.Envelope;\n readonly scopes: ReadonlyArray<string>;\n}\n\nexport type AuthenticationFailure = Error | InvalidInputError | DnsProvider.Error;\n\nexport interface InteractiveStart {\n readonly authorizationUrl: URL;\n readonly payload: Secret.Value;\n}\n\nexport interface Continuation extends BaseInput {\n readonly expiresAt: Date;\n readonly id: string;\n readonly method: \"integration\" | \"oauth2\";\n readonly payload: Secret.Value;\n readonly providerId: string;\n readonly requiredCapabilities: ReadonlyArray<ProviderAuthorization.Capability>;\n}\n\nexport interface ContinuationStore {\n readonly consume: (id: string, now: Date) => Effect.Effect<Continuation | null, Error>;\n readonly put: (continuation: Continuation) => Effect.Effect<void, Error>;\n}\n\nexport interface InteractiveFlow {\n readonly complete: (\n payload: Secret.Value,\n callbackUrl: URL,\n ) => Effect.Effect<Authentication, AuthenticationFailure>;\n readonly method: \"integration\" | \"oauth2\";\n readonly providerId: string;\n readonly requiredCapabilities: ReadonlyArray<ProviderAuthorization.Capability>;\n readonly start: (\n continuationId: string,\n ) => Effect.Effect<InteractiveStart, AuthenticationFailure, Crypto.Crypto>;\n}\n\nexport type Method = Data.TaggedEnum<{\n Interactive: {\n readonly continuations: ContinuationStore;\n readonly flow: InteractiveFlow;\n readonly ttlMs?: number;\n };\n Token: {\n readonly authenticate: (\n token: Secret.Value,\n ) => Effect.Effect<Authentication, AuthenticationFailure>;\n readonly providerId: string;\n readonly requiredCapabilities: ReadonlyArray<ProviderAuthorization.Capability>;\n readonly token: Secret.Value;\n };\n}>;\nexport const Method = Data.taggedEnum<Method>();\n\nexport type StartResult = Data.TaggedEnum<{\n Connected: { readonly connection: Connection.ProviderConnection };\n Redirect: { readonly authorizationUrl: URL; readonly continuationId: string };\n}>;\nexport const StartResult = Data.taggedEnum<StartResult>();\n\nexport class Error extends Schema.TaggedError<Error>()(\"ConnectionError\", {\n category: Schema.Literals([\"authorization\", \"provider\", \"validation\"]),\n message: Schema.String,\n operation: Schema.String,\n retry: Schema.Literals([\"never\", \"after-user-action\", \"safe\", \"unknown\"]),\n}) {}\n\n/** Inputs shared by token and interactive connection flows. */\nexport interface BaseInput {\n readonly authorizedById: string;\n /** Existing authorization may be supplied only after the host completed fresh provider proof. */\n readonly authorizationId?: string;\n readonly ownerId: string;\n}\n\nexport interface CompleteInput {\n readonly callbackUrl: URL;\n readonly continuationId: string;\n readonly continuations: ContinuationStore;\n readonly flow: InteractiveFlow;\n}\n\nexport interface ConnectInput extends BaseInput {\n readonly authentication: Authentication;\n readonly method: \"integration\" | \"oauth2\" | \"token\";\n readonly providerId: string;\n readonly requiredCapabilities: ReadonlyArray<ProviderAuthorization.Capability>;\n}\n\nconst missingCapability = (\n authentication: Authentication,\n requiredCapabilities: ReadonlyArray<ProviderAuthorization.Capability>,\n): ProviderAuthorization.Capability | undefined =>\n requiredCapabilities.find(\n (capability) =>\n !authentication.capabilityEvidence.some((item) => item.capability === capability),\n );\n\nconst freshId = Effect.fn(\"Connection.freshId\")(function* () {\n const crypto = yield* Crypto.Crypto;\n return yield* crypto.randomUUIDv4.pipe(\n Effect.mapError(\n (cause) =>\n new Error({\n category: \"validation\",\n message: cause.message,\n operation: \"Connection.connect\",\n retry: \"safe\",\n }),\n ),\n );\n});\n\n/** Persist one authenticated provider connection, optionally reusing a proven authorization. */\nexport const connect = Effect.fn(\"Connection.connect\")(function* (input: ConnectInput) {\n const repository = yield* Repository.Service;\n const now = new Date(yield* Clock.currentTimeMillis);\n const missing = missingCapability(input.authentication, input.requiredCapabilities);\n if (missing !== undefined) {\n return yield* new Error({\n category: \"authorization\",\n message: `Provider authorization lacks evidence for ${missing}`,\n operation: \"Connection.connect\",\n retry: \"after-user-action\",\n });\n }\n\n const existing =\n input.authorizationId === undefined ? null : yield* repository.get(input.authorizationId);\n if (input.authorizationId !== undefined && existing === null) {\n return yield* new Error({\n category: \"authorization\",\n message: \"Provider authorization does not exist\",\n operation: \"Connection.connect\",\n retry: \"after-user-action\",\n });\n }\n if (existing?.authorization.revocation._tag === \"Pending\") {\n return yield* new Error({\n category: \"authorization\",\n message: \"Provider authorization is awaiting revocation recovery\",\n operation: \"Connection.connect\",\n retry: \"after-user-action\",\n });\n }\n if (\n existing !== null &&\n (existing.authorization.providerId !== input.providerId ||\n existing.authorization.method !== input.method)\n ) {\n return yield* new Error({\n category: \"authorization\",\n message: \"Provider proof does not match the existing authorization\",\n operation: \"Connection.connect\",\n retry: \"never\",\n });\n }\n\n const authorizationId = existing?.authorization.id ?? (yield* freshId());\n const authorization: ProviderAuthorization.ProviderAuthorization =\n existing === null\n ? {\n authorizedById: input.authorizedById,\n capabilityEvidence: [...input.authentication.capabilityEvidence],\n createdAt: now,\n id: authorizationId,\n method: input.method,\n providerContext: input.authentication.providerContext,\n providerId: input.providerId,\n requiredCapabilities: [...input.requiredCapabilities],\n revocation: ProviderAuthorization.Revocation.Active(),\n scopes: [...input.authentication.scopes],\n }\n : {\n ...existing.authorization,\n capabilityEvidence: mergeEvidence(\n existing.authorization.capabilityEvidence,\n input.authentication.capabilityEvidence,\n ),\n method: input.method,\n providerContext: input.authentication.providerContext,\n requiredCapabilities: [...input.requiredCapabilities],\n revocation: ProviderAuthorization.Revocation.Active(),\n scopes: [...input.authentication.scopes],\n };\n const existingConnection = yield* repository.findConnection(input.ownerId, authorizationId);\n const connection: Connection.StoredConnection = {\n authorizationId,\n createdAt: existingConnection?.createdAt ?? now,\n id: existingConnection?.id ?? (yield* freshId()),\n method: input.method,\n ownerId: input.ownerId,\n providerId: input.providerId,\n };\n return yield* repository.connect({\n authorization,\n connection,\n credential: input.authentication.credential,\n ...(existing === null ? {} : { expectedAuthorizationId: existing.authorization.id }),\n ...(existingConnection === null ? {} : { expectedConnectionId: existingConnection.id }),\n });\n});\n\nexport const start = Effect.fn(\"Connection.start\")(function* (\n input: BaseInput & { readonly method: Method },\n) {\n if (input.method._tag === \"Interactive\") {\n const crypto = yield* Crypto.Crypto;\n const now = yield* Clock.currentTimeMillis;\n const continuationId = yield* crypto.randomUUIDv4.pipe(\n Effect.mapError(\n (cause) =>\n new Error({\n category: \"validation\",\n message: cause.message,\n operation: \"Connection.start\",\n retry: \"safe\",\n }),\n ),\n );\n const started = yield* input.method.flow.start(continuationId);\n yield* input.method.continuations.put({\n authorizedById: input.authorizedById,\n ...(input.authorizationId === undefined ? {} : { authorizationId: input.authorizationId }),\n expiresAt: new Date(now + (input.method.ttlMs ?? 10 * 60_000)),\n id: continuationId,\n method: input.method.flow.method,\n ownerId: input.ownerId,\n payload: started.payload,\n providerId: input.method.flow.providerId,\n requiredCapabilities: [...input.method.flow.requiredCapabilities],\n });\n return StartResult.Redirect({\n authorizationUrl: started.authorizationUrl,\n continuationId,\n });\n }\n const authentication = yield* input.method.authenticate(input.method.token);\n const aggregate = yield* connect({\n authentication,\n authorizedById: input.authorizedById,\n ...(input.authorizationId === undefined ? {} : { authorizationId: input.authorizationId }),\n method: \"token\",\n ownerId: input.ownerId,\n providerId: input.method.providerId,\n requiredCapabilities: input.method.requiredCapabilities,\n });\n const storedConnection = aggregate.connections.find(({ ownerId }) => ownerId === input.ownerId);\n if (storedConnection === undefined) {\n return yield* new Error({\n category: \"validation\",\n message: \"Connected provider authorization returned no organization connection\",\n operation: \"Connection.start\",\n retry: \"safe\",\n });\n }\n return StartResult.Connected({\n connection: Connection.project(storedConnection, aggregate.authorization, aggregate.credential),\n });\n});\n\nexport const complete = Effect.fn(\"Connection.complete\")(function* (input: CompleteInput) {\n const continuation = yield* input.continuations.consume(\n input.continuationId,\n new Date(yield* Clock.currentTimeMillis),\n );\n if (continuation === null) {\n return yield* new Error({\n category: \"authorization\",\n message: \"Connection continuation is expired, unknown, or already consumed\",\n operation: \"Connection.complete\",\n retry: \"after-user-action\",\n });\n }\n if (\n continuation.providerId !== input.flow.providerId ||\n continuation.method !== input.flow.method\n ) {\n return yield* new Error({\n category: \"authorization\",\n message: \"Connection continuation does not match the provider flow\",\n operation: \"Connection.complete\",\n retry: \"never\",\n });\n }\n const authentication = yield* input.flow.complete(continuation.payload, input.callbackUrl);\n const aggregate = yield* connect({\n authentication,\n authorizedById: continuation.authorizedById,\n ...(continuation.authorizationId === undefined\n ? {}\n : { authorizationId: continuation.authorizationId }),\n method: continuation.method,\n ownerId: continuation.ownerId,\n providerId: continuation.providerId,\n requiredCapabilities: continuation.requiredCapabilities,\n });\n const storedConnection = aggregate.connections.find(\n ({ ownerId }) => ownerId === continuation.ownerId,\n );\n if (storedConnection === undefined) {\n return yield* new Error({\n category: \"validation\",\n message: \"Connected provider authorization returned no organization connection\",\n operation: \"Connection.complete\",\n retry: \"safe\",\n });\n }\n return Connection.project(storedConnection, aggregate.authorization, aggregate.credential);\n});\n\nfunction mergeEvidence(\n current: ReadonlyArray<ProviderAuthorization.CapabilityEvidence>,\n incoming: ReadonlyArray<ProviderAuthorization.CapabilityEvidence>,\n): ReadonlyArray<ProviderAuthorization.CapabilityEvidence> {\n const byCapability = new Map(current.map((item) => [item.capability, item]));\n for (const item of incoming) byCapability.set(item.capability, item);\n return [...byCapability.values()];\n}\n\nexport type Requirements = Repository.Service | Crypto.Crypto;\nexport type Failure = AuthenticationFailure | Repository.Error | CryptoError;\n"],"mappings":";;;AAqEA,MAAa,SAAS,KAAK,WAAmB;AAM9C,MAAa,cAAc,KAAK,WAAwB;AAExD,IAAa,QAAb,cAA2B,OAAO,YAAmB,CAAC,CAAC,mBAAmB;CACxE,UAAU,OAAO,SAAS;EAAC;EAAiB;EAAY;CAAY,CAAC;CACrE,SAAS,OAAO;CAChB,WAAW,OAAO;CAClB,OAAO,OAAO,SAAS;EAAC;EAAS;EAAqB;EAAQ;CAAS,CAAC;AAC1E,CAAC,CAAC,CAAC,CAAC;AAwBJ,MAAM,qBACJ,gBACA,yBAEA,qBAAqB,MAClB,eACC,CAAC,eAAe,mBAAmB,MAAM,SAAS,KAAK,eAAe,UAAU,CACpF;AAEF,MAAM,UAAU,OAAO,GAAG,oBAAoB,CAAC,CAAC,aAAa;CAE3D,OAAO,QAAO,OADQ,OAAO,OAAA,CACR,aAAa,KAChC,OAAO,UACJ,UACC,IAAI,MAAM;EACR,UAAU;EACV,SAAS,MAAM;EACf,WAAW;EACX,OAAO;CACT,CAAC,CACL,CACF;AACF,CAAC;;AAGD,MAAa,UAAU,OAAO,GAAG,oBAAoB,CAAC,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AC7B,GAAI,aAAa,oBAAoB,KAAA,IACjC,CAAC,IACD,EAAE,iBAAiB,aAAa,gBAAgB;EACpD,QAAQ,aAAa;EACrB,SAAS,aAAa;EACtB,YAAY,aAAa;EACzB,sBAAsB,aAAa;CACrC,CAAC;CACD,MAAM,mBAAmB,UAAU,YAAY,MAC5C,EAAE,cAAc,YAAY,aAAa,OAC5C;CACA,IAAI,qBAAqB,KAAA,GACvB,OAAO,OAAO,IAAI,MAAM;EACtB,UAAU;EACV,SAAS;EACT,WAAW;EACX,OAAO;CACT,CAAC;CAEH,OAAOA,QAAmB,kBAAkB,UAAU,eAAe,UAAU,UAAU;AAC3F,CAAC;AAED,SAAS,cACP,SACA,UACyD;CACzD,MAAM,eAAe,IAAI,IAAI,QAAQ,KAAK,SAAS,CAAC,KAAK,YAAY,IAAI,CAAC,CAAC;CAC3E,KAAK,MAAM,QAAQ,UAAU,aAAa,IAAI,KAAK,YAAY,IAAI;CACnE,OAAO,CAAC,GAAG,aAAa,OAAO,CAAC;AAClC"}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { A as ConnectionStatus, C as ConnectInput, D as Interface, E as Error, F as StoredConnection, H as Capability, I as StoredCredential, L as authorizationError, M as ProviderConnection, N as ProviderTarget, O as Service, P as ProviderTargetEvidence, S as AttachmentResult, T as DisconnectResult, U as CapabilityEvidence, V as validate, W as ProviderAuthorization, a as Continuation, b as Aggregate, c as Failure, d as Method$1, f as StartResult, i as CompleteInput, j as DomainAttachment, k as AuthorizationError, l as InteractiveFlow$1, n as AuthenticationFailure, nt as Value, r as BaseInput, s as Error$1, t as Authentication, u as InteractiveStart, w as DetachResult, z as encode } from "./connect-D-X8T9W8.mjs";
|
|
2
|
-
import { Data, Layer } from "effect";
|
|
3
|
-
declare namespace managed_dns_connections_d_exports {
|
|
4
|
-
export { AsyncInterface, AttachmentResult, DetachResult, DisconnectResult, Error, from, layerFromAsync, toAsync };
|
|
5
|
-
}
|
|
6
|
-
interface AsyncInterface {
|
|
7
|
-
readonly attach: (input: {
|
|
8
|
-
readonly attachment: DomainAttachment;
|
|
9
|
-
readonly connectionId: string;
|
|
10
|
-
readonly ownerId: string;
|
|
11
|
-
}) => Promise<AttachmentResult>;
|
|
12
|
-
readonly connect: (input: ConnectInput) => Promise<Aggregate>;
|
|
13
|
-
readonly detach: (input: {
|
|
14
|
-
readonly attachmentId: string;
|
|
15
|
-
readonly ownerId: string;
|
|
16
|
-
}) => Promise<DetachResult>;
|
|
17
|
-
readonly disconnect: (input: {
|
|
18
|
-
readonly connectionId: string;
|
|
19
|
-
readonly ownerId: string;
|
|
20
|
-
readonly revoke: (authorization: ProviderAuthorization) => Promise<void>;
|
|
21
|
-
}) => Promise<DisconnectResult>;
|
|
22
|
-
readonly findConnection: (ownerId: string, authorizationId: string) => Promise<StoredConnection | null>;
|
|
23
|
-
readonly get: (authorizationId: string) => Promise<Aggregate | null>;
|
|
24
|
-
readonly getAttachment: (attachmentId: string) => Promise<DomainAttachment | null>;
|
|
25
|
-
readonly getByConnectionId: (connectionId: string) => Promise<Aggregate | null>;
|
|
26
|
-
readonly listAttachments: (connectionId: string, ownerId: string) => Promise<ReadonlyArray<DomainAttachment>>;
|
|
27
|
-
readonly promoteEvidence: (authorizationId: string, evidence: ReadonlyArray<CapabilityEvidence>) => Promise<Aggregate>;
|
|
28
|
-
readonly recover: (input: {
|
|
29
|
-
readonly authorizationId: string;
|
|
30
|
-
readonly revoke: (authorization: ProviderAuthorization) => Promise<void>;
|
|
31
|
-
}) => Promise<DisconnectResult>;
|
|
32
|
-
readonly rotate: (authorizationId: string, credential: StoredCredential) => Promise<Aggregate>;
|
|
33
|
-
}
|
|
34
|
-
declare const layerFromAsync: (repository: AsyncInterface) => Layer.Layer<Service>;
|
|
35
|
-
declare const toAsync: (service: Interface) => AsyncInterface;
|
|
36
|
-
declare const from: (repository: AsyncInterface) => AsyncInterface;
|
|
37
|
-
declare namespace connection_d_exports {
|
|
38
|
-
export { Authentication, AuthenticationFailure, AuthorizationError, BaseInput, CompleteInput, ConnectionStatus, Continuation, ContinuationStore, DomainAttachment, Error$1 as Error, Failure, InteractiveFlow, InteractiveStart, Method, ProviderConnection, ProviderTarget, ProviderTargetEvidence, StartResult, attach, authorizationError, complete, decode, detach, disconnect, encode, fromEffectFlow, fromEffectTokenMethod, start, validate };
|
|
39
|
-
}
|
|
40
|
-
declare function decode(input: unknown): Promise<ProviderConnection>;
|
|
41
|
-
type Method = Data.TaggedEnum<{
|
|
42
|
-
Interactive: {
|
|
43
|
-
readonly continuations: ContinuationStore;
|
|
44
|
-
readonly flow: InteractiveFlow;
|
|
45
|
-
readonly ttlMs?: number;
|
|
46
|
-
};
|
|
47
|
-
Token: {
|
|
48
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
49
|
-
readonly providerId: string;
|
|
50
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
51
|
-
readonly token: Value;
|
|
52
|
-
};
|
|
53
|
-
}>;
|
|
54
|
-
declare const Method: {
|
|
55
|
-
readonly $is: <Tag extends "Interactive" | "Token">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
56
|
-
readonly _tag: "Interactive";
|
|
57
|
-
readonly continuations: ContinuationStore;
|
|
58
|
-
readonly flow: InteractiveFlow;
|
|
59
|
-
readonly ttlMs?: number;
|
|
60
|
-
}, {
|
|
61
|
-
readonly _tag: Tag;
|
|
62
|
-
}> | Extract<{
|
|
63
|
-
readonly _tag: "Token";
|
|
64
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
65
|
-
readonly providerId: string;
|
|
66
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
67
|
-
readonly token: Value;
|
|
68
|
-
}, {
|
|
69
|
-
readonly _tag: Tag;
|
|
70
|
-
}>;
|
|
71
|
-
readonly $match: {
|
|
72
|
-
<Cases extends { readonly [Tag in "Interactive" | "Token"]: (args: Extract<{
|
|
73
|
-
readonly _tag: "Interactive";
|
|
74
|
-
readonly continuations: ContinuationStore;
|
|
75
|
-
readonly flow: InteractiveFlow;
|
|
76
|
-
readonly ttlMs?: number;
|
|
77
|
-
} | {
|
|
78
|
-
readonly _tag: "Token";
|
|
79
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
80
|
-
readonly providerId: string;
|
|
81
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
82
|
-
readonly token: Value;
|
|
83
|
-
}, {
|
|
84
|
-
readonly _tag: Tag;
|
|
85
|
-
}>) => any; }>(cases: Cases): (value: {
|
|
86
|
-
readonly _tag: "Interactive";
|
|
87
|
-
readonly continuations: ContinuationStore;
|
|
88
|
-
readonly flow: InteractiveFlow;
|
|
89
|
-
readonly ttlMs?: number;
|
|
90
|
-
} | {
|
|
91
|
-
readonly _tag: "Token";
|
|
92
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
93
|
-
readonly providerId: string;
|
|
94
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
95
|
-
readonly token: Value;
|
|
96
|
-
}) => import("effect/Unify").Unify<ReturnType<Cases["Interactive" | "Token"]>>;
|
|
97
|
-
<Cases extends { readonly [Tag in "Interactive" | "Token"]: (args: Extract<{
|
|
98
|
-
readonly _tag: "Interactive";
|
|
99
|
-
readonly continuations: ContinuationStore;
|
|
100
|
-
readonly flow: InteractiveFlow;
|
|
101
|
-
readonly ttlMs?: number;
|
|
102
|
-
} | {
|
|
103
|
-
readonly _tag: "Token";
|
|
104
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
105
|
-
readonly providerId: string;
|
|
106
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
107
|
-
readonly token: Value;
|
|
108
|
-
}, {
|
|
109
|
-
readonly _tag: Tag;
|
|
110
|
-
}>) => any; }>(value: {
|
|
111
|
-
readonly _tag: "Interactive";
|
|
112
|
-
readonly continuations: ContinuationStore;
|
|
113
|
-
readonly flow: InteractiveFlow;
|
|
114
|
-
readonly ttlMs?: number;
|
|
115
|
-
} | {
|
|
116
|
-
readonly _tag: "Token";
|
|
117
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
118
|
-
readonly providerId: string;
|
|
119
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
120
|
-
readonly token: Value;
|
|
121
|
-
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Interactive" | "Token"]>>;
|
|
122
|
-
};
|
|
123
|
-
readonly Interactive: Data.TaggedEnum.ConstructorFrom<{
|
|
124
|
-
readonly _tag: "Interactive";
|
|
125
|
-
readonly continuations: ContinuationStore;
|
|
126
|
-
readonly flow: InteractiveFlow;
|
|
127
|
-
readonly ttlMs?: number;
|
|
128
|
-
}, "_tag">;
|
|
129
|
-
readonly Token: Data.TaggedEnum.ConstructorFrom<{
|
|
130
|
-
readonly _tag: "Token";
|
|
131
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
132
|
-
readonly providerId: string;
|
|
133
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
134
|
-
readonly token: Value;
|
|
135
|
-
}, "_tag">;
|
|
136
|
-
};
|
|
137
|
-
interface ContinuationStore {
|
|
138
|
-
readonly consume: (id: string, now: Date) => Promise<Continuation | null>;
|
|
139
|
-
readonly put: (continuation: Continuation) => Promise<void>;
|
|
140
|
-
}
|
|
141
|
-
interface InteractiveFlow {
|
|
142
|
-
readonly complete: (payload: Value, callbackUrl: URL) => Promise<Authentication>;
|
|
143
|
-
readonly method: "integration" | "oauth2";
|
|
144
|
-
readonly providerId: string;
|
|
145
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
146
|
-
readonly start: (continuationId: string) => Promise<InteractiveStart>;
|
|
147
|
-
}
|
|
148
|
-
/** Adapts an Effect-native provider flow to the Promise facade. */
|
|
149
|
-
declare const fromEffectFlow: (flow: InteractiveFlow$1) => InteractiveFlow;
|
|
150
|
-
/** Adapts an Effect-native token method to the Promise facade. */
|
|
151
|
-
declare function fromEffectTokenMethod(method: Extract<Method$1, {
|
|
152
|
-
readonly _tag: "Token";
|
|
153
|
-
}>): Extract<Method, {
|
|
154
|
-
readonly _tag: "Token";
|
|
155
|
-
}>;
|
|
156
|
-
declare function start(input: BaseInput & {
|
|
157
|
-
readonly method: Method;
|
|
158
|
-
readonly repository: AsyncInterface;
|
|
159
|
-
}): Promise<StartResult>;
|
|
160
|
-
declare function complete(input: {
|
|
161
|
-
readonly callbackUrl: URL;
|
|
162
|
-
readonly continuationId: string;
|
|
163
|
-
readonly continuations: ContinuationStore;
|
|
164
|
-
readonly flow: InteractiveFlow;
|
|
165
|
-
readonly repository: AsyncInterface;
|
|
166
|
-
}): Promise<ProviderConnection>;
|
|
167
|
-
declare function attach(input: {
|
|
168
|
-
readonly attachment: DomainAttachment;
|
|
169
|
-
readonly connectionId: string;
|
|
170
|
-
readonly ownerId: string;
|
|
171
|
-
readonly repository: AsyncInterface;
|
|
172
|
-
}): Promise<AttachmentResult>;
|
|
173
|
-
declare function detach(input: {
|
|
174
|
-
readonly attachmentId: string;
|
|
175
|
-
readonly ownerId: string;
|
|
176
|
-
readonly repository: AsyncInterface;
|
|
177
|
-
}): Promise<DetachResult>;
|
|
178
|
-
declare function disconnect(input: {
|
|
179
|
-
readonly connectionId: string;
|
|
180
|
-
readonly ownerId: string;
|
|
181
|
-
readonly repository: AsyncInterface;
|
|
182
|
-
readonly revoke: (authorization: ProviderAuthorization) => Promise<void>;
|
|
183
|
-
}): Promise<DisconnectResult>;
|
|
184
|
-
//#endregion
|
|
185
|
-
export { managed_dns_connections_d_exports as a, AsyncInterface as i, Method as n, connection_d_exports as r, InteractiveFlow as t };
|
|
186
|
-
//# sourceMappingURL=connection-Dp6ZdSo8.d.mts.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { A as ConnectionStatus, B as project, E as Error, L as authorizationError, M as ProviderConnection, N as ProviderTarget, O as Service, P as ProviderTargetEvidence, R as decode, S as AttachmentResult, T as DisconnectResult, V as validate, W as ProviderAuthorization, a as Continuation, c as Failure, d as Method, f as StartResult, i as CompleteInput, j as DomainAttachment, k as AuthorizationError, l as InteractiveFlow, m as start, n as AuthenticationFailure, o as ContinuationStore, p as complete, r as BaseInput, s as Error$1, t as Authentication, u as InteractiveStart, w as DetachResult, z as encode } from "./connect-D-X8T9W8.mjs";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
//#region src/auth/connection-lifecycle.d.ts
|
|
4
|
-
/** Attach one exact provider target to one organization domain. */
|
|
5
|
-
declare const attach: (input: {
|
|
6
|
-
readonly attachment: DomainAttachment;
|
|
7
|
-
readonly connectionId: string;
|
|
8
|
-
readonly ownerId: string;
|
|
9
|
-
}) => Effect.Effect<AttachmentResult, Error, Service>;
|
|
10
|
-
/** Remove one domain attachment while retaining the organization connection. */
|
|
11
|
-
declare const detach: (input: {
|
|
12
|
-
readonly attachmentId: string;
|
|
13
|
-
readonly ownerId: string;
|
|
14
|
-
}) => Effect.Effect<DetachResult, Error, Service>;
|
|
15
|
-
/** Disconnect one organization connection, revoking the shared authorization only when final. */
|
|
16
|
-
declare function disconnect<E>(input: {
|
|
17
|
-
readonly connectionId: string;
|
|
18
|
-
readonly ownerId: string;
|
|
19
|
-
readonly revokeAuthorization: (authorization: ProviderAuthorization) => Effect.Effect<void, E>;
|
|
20
|
-
}): Effect.Effect<DisconnectResult, Error | E, Service>;
|
|
21
|
-
declare namespace connection_api_d_exports {
|
|
22
|
-
export { AttachmentResult, Authentication, AuthenticationFailure, AuthorizationError, BaseInput, CompleteInput, Method as ConnectionMethod, StartResult as ConnectionStartResult, ConnectionStatus, Continuation, ContinuationStore, DetachResult, DisconnectResult, DomainAttachment, Error$1 as Error, Failure, InteractiveFlow, InteractiveStart, Method, ProviderConnection, ProviderTarget, ProviderTargetEvidence, StartResult, attach, authorizationError, complete, decode, detach, disconnect, encode, project, start, validate };
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { connection_api_d_exports as t };
|
|
26
|
-
//# sourceMappingURL=connection-api-lqG1nBtD.d.mts.map
|