domainkit 0.2.2 → 0.3.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 +26 -26
- package/dist/index.d.mts +639 -187
- package/dist/index.mjs +301 -300
- package/dist/index.mjs.map +1 -1
- package/dist/promise.d.mts +464 -0
- package/dist/promise.mjs +636 -0
- package/dist/promise.mjs.map +1 -0
- package/dist/{resolver-CxE-VDw4.mjs → resolver-CvK7JoJM.mjs} +401 -54
- package/dist/resolver-CvK7JoJM.mjs.map +1 -0
- package/dist/{resolver-Dc0hwV-J.d.mts → resolver-uqe1h5Vz.d.mts} +1513 -25
- package/dist/testing.d.mts +4 -5
- package/dist/testing.mjs +17 -3
- package/dist/testing.mjs.map +1 -1
- package/dist/verify-B00c81-n.mjs +2420 -0
- package/dist/verify-B00c81-n.mjs.map +1 -0
- package/dist/{verify-Dls29YC-.d.mts → verify-CkgVrwyl.d.mts} +318 -21
- package/package.json +6 -30
- package/dist/auth-BR-19zj-.mjs +0 -738
- package/dist/auth-BR-19zj-.mjs.map +0 -1
- package/dist/auth-g-waCHcz.mjs +0 -671
- package/dist/auth-g-waCHcz.mjs.map +0 -1
- package/dist/authorization-OeaSR47S.mjs +0 -284
- package/dist/authorization-OeaSR47S.mjs.map +0 -1
- package/dist/canonical-json-CpvqGMcr.mjs +0 -57
- package/dist/canonical-json-CpvqGMcr.mjs.map +0 -1
- package/dist/cloudflare-BrZPU9li.d.mts +0 -32
- package/dist/cloudflare-CGmasR8A.mjs +0 -69
- package/dist/cloudflare-CGmasR8A.mjs.map +0 -1
- package/dist/cloudflare.d.mts +0 -3
- package/dist/cloudflare.mjs +0 -2
- package/dist/connection-BfkloPZy.d.mts +0 -186
- package/dist/connection-BwtOwpH6.mjs +0 -195
- package/dist/connection-BwtOwpH6.mjs.map +0 -1
- package/dist/connection-CjNQe_E-.mjs +0 -58
- package/dist/connection-CjNQe_E-.mjs.map +0 -1
- package/dist/connection-api-DNuEZ_jR.d.mts +0 -7
- package/dist/dns-record-BLeqo56C.mjs +0 -289
- package/dist/dns-record-BLeqo56C.mjs.map +0 -1
- package/dist/effect-cloudflare.d.mts +0 -2
- package/dist/effect-cloudflare.mjs +0 -2
- package/dist/effect-vercel.d.mts +0 -2
- package/dist/effect-vercel.mjs +0 -2
- package/dist/effect.d.mts +0 -36
- package/dist/effect.mjs +0 -51
- package/dist/effect.mjs.map +0 -1
- package/dist/index-BHWRTThN.d.mts +0 -159
- package/dist/index-D3PVknwE.d.mts +0 -145
- package/dist/resolver-CxE-VDw4.mjs.map +0 -1
- package/dist/vercel-BsNDu4Np.d.mts +0 -31
- package/dist/vercel-CfoJaaCu.mjs +0 -60
- package/dist/vercel-CfoJaaCu.mjs.map +0 -1
- package/dist/vercel.d.mts +0 -3
- package/dist/vercel.mjs +0 -2
- package/dist/verify-BKbvq7IN.mjs +0 -642
- package/dist/verify-BKbvq7IN.mjs.map +0 -1
- package/dist/zone-discovery-BPnH3sLU.d.mts +0 -1397
- package/dist/zones-DKHTpX9C.mjs +0 -19
- package/dist/zones-DKHTpX9C.mjs.map +0 -1
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { a as subjectResolver$1, c as tokenValidator$1, d as make$1, i as oauthMethod$1, n as manifest$1, o as tokenConnectionMethod$1, r as oauthFlow$1, s as tokenMethod$1 } from "./auth-BR-19zj-.mjs";
|
|
3
|
-
import { n as fromEffectFlow, r as fromEffectTokenMethod } from "./connection-BwtOwpH6.mjs";
|
|
4
|
-
import { Effect } from "effect";
|
|
5
|
-
//#region src/promise/cloudflare-auth.ts
|
|
6
|
-
var cloudflare_auth_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
-
manifest: () => manifest,
|
|
8
|
-
oauthFlow: () => oauthFlow,
|
|
9
|
-
oauthMethod: () => oauthMethod,
|
|
10
|
-
subjectResolver: () => subjectResolver,
|
|
11
|
-
tokenConnectionMethod: () => tokenConnectionMethod,
|
|
12
|
-
tokenMethod: () => tokenMethod,
|
|
13
|
-
tokenValidator: () => tokenValidator
|
|
14
|
-
});
|
|
15
|
-
const manifest = manifest$1;
|
|
16
|
-
const oauthMethod = oauthMethod$1;
|
|
17
|
-
const tokenMethod = tokenMethod$1;
|
|
18
|
-
function subjectResolver(options) {
|
|
19
|
-
const resolve = subjectResolver$1(options);
|
|
20
|
-
return (tokens, accessToken) => Effect.runPromise(resolve(tokens, accessToken));
|
|
21
|
-
}
|
|
22
|
-
/** Creates Cloudflare's OAuth implementation for the Promise connection facade. */
|
|
23
|
-
function oauthFlow(options) {
|
|
24
|
-
return fromEffectFlow(oauthFlow$1(options));
|
|
25
|
-
}
|
|
26
|
-
/** Creates a Cloudflare token method for the Promise connection facade. */
|
|
27
|
-
function tokenConnectionMethod(options) {
|
|
28
|
-
return fromEffectTokenMethod(tokenConnectionMethod$1(options));
|
|
29
|
-
}
|
|
30
|
-
function tokenValidator(options) {
|
|
31
|
-
const validate = tokenValidator$1(options);
|
|
32
|
-
return (token) => Effect.runPromise(validate(token));
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/promise/cloudflare.ts
|
|
36
|
-
var cloudflare_exports = /* @__PURE__ */ __exportAll({
|
|
37
|
-
Auth: () => cloudflare_auth_exports,
|
|
38
|
-
discovery: () => discovery,
|
|
39
|
-
make: () => make
|
|
40
|
-
});
|
|
41
|
-
/** Creates a Promise-compatible facade over the Effect-native Cloudflare client. */
|
|
42
|
-
function make(options) {
|
|
43
|
-
const client = make$1(options);
|
|
44
|
-
return {
|
|
45
|
-
id: client.id,
|
|
46
|
-
createRecord: (zone, record) => Effect.runPromise(client.createRecord(zone, record)),
|
|
47
|
-
deleteRecord: (zone, providerRecordId) => Effect.runPromise(client.deleteRecord(zone, providerRecordId)),
|
|
48
|
-
getRecord: (zone, providerRecordId) => Effect.runPromise(client.getRecord(zone, providerRecordId)),
|
|
49
|
-
listAccounts: () => Effect.runPromise(client.listAccounts()),
|
|
50
|
-
listRecords: (zone) => Effect.runPromise(client.listRecords(zone)),
|
|
51
|
-
listZones: (input) => Effect.runPromise(client.listZones(input)),
|
|
52
|
-
validateToken: () => Effect.runPromise(client.validateToken())
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/** Creates the optional Cloudflare discovery source for Promise consumers. */
|
|
56
|
-
function discovery(options) {
|
|
57
|
-
const client = make(options);
|
|
58
|
-
return {
|
|
59
|
-
listZones: async (name) => (await client.listZones({ name })).map((zone) => ({
|
|
60
|
-
...zone,
|
|
61
|
-
status: zone.status === "active" || zone.status === "pending" ? zone.status : "unknown"
|
|
62
|
-
})),
|
|
63
|
-
provider: client
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
export { cloudflare_auth_exports as i, discovery as n, make as r, cloudflare_exports as t };
|
|
68
|
-
|
|
69
|
-
//# sourceMappingURL=cloudflare-CGmasR8A.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare-CGmasR8A.mjs","names":["EffectAuth.manifest","EffectAuth.oauthMethod","EffectAuth.tokenMethod","EffectAuth.subjectResolver","Connection.fromEffectFlow","EffectAuth.oauthFlow","Connection.fromEffectTokenMethod","EffectAuth.tokenConnectionMethod","EffectAuth.tokenValidator","Cloudflare.make"],"sources":["../src/promise/cloudflare-auth.ts","../src/promise/cloudflare.ts"],"sourcesContent":["import type * as oauth from \"oauth4webapi\";\nimport { Effect } from \"effect\";\n\nimport type * as ProviderAuth from \"../auth/manifest.ts\";\nimport type * as Secret from \"../auth/secret.ts\";\nimport * as EffectAuth from \"../providers/cloudflare/auth.ts\";\nimport * as Connection from \"./connection.ts\";\n\nexport const manifest = EffectAuth.manifest;\nexport const oauthMethod = EffectAuth.oauthMethod;\nexport const tokenMethod = EffectAuth.tokenMethod;\nexport type {\n CredentialTarget,\n OAuthFlowOptions,\n OAuthMethodOptions,\n SubjectResolverOptions,\n TokenValidatorOptions,\n} from \"../providers/cloudflare/auth.ts\";\n\nexport function subjectResolver(\n options: EffectAuth.SubjectResolverOptions,\n): ProviderAuth.AsyncOAuthSubjectResolver {\n const resolve = EffectAuth.subjectResolver(options);\n return (tokens: oauth.TokenEndpointResponse, accessToken: Secret.Value) =>\n Effect.runPromise(resolve(tokens, accessToken));\n}\n\n/** Creates Cloudflare's OAuth implementation for the Promise connection facade. */\nexport function oauthFlow(options: EffectAuth.OAuthFlowOptions): Connection.InteractiveFlow {\n return Connection.fromEffectFlow(EffectAuth.oauthFlow(options));\n}\n\n/** Creates a Cloudflare token method for the Promise connection facade. */\nexport function tokenConnectionMethod(\n options: EffectAuth.TokenConnectionOptions,\n): Extract<Connection.Method, { readonly _tag: \"Token\" }> {\n return Connection.fromEffectTokenMethod(EffectAuth.tokenConnectionMethod(options));\n}\n\nexport function tokenValidator(\n options: EffectAuth.TokenValidatorOptions,\n): (token: Secret.Value) => Promise<ProviderAuth.TokenValidation> {\n const validate = EffectAuth.tokenValidator(options);\n return (token) => Effect.runPromise(validate(token));\n}\n","import { Effect } from \"effect\";\n\nimport type * as ProviderAuth from \"../auth/manifest.ts\";\nimport type * as DnsProvider from \"../provider/provider.ts\";\nimport * as Cloudflare from \"../providers/cloudflare/index.ts\";\nimport type * as ZoneDiscovery from \"./zone-discovery.ts\";\n\nexport * as Auth from \"./cloudflare-auth.ts\";\nexport type {\n Account,\n Fetch,\n ListZonesInput,\n Options,\n Zone,\n} from \"../providers/cloudflare/client.ts\";\n\nexport interface Interface extends DnsProvider.AsyncInterface {\n readonly listAccounts: () => Promise<ReadonlyArray<Cloudflare.Account>>;\n readonly listZones: (\n input?: Cloudflare.Client.ListZonesInput,\n ) => Promise<ReadonlyArray<Cloudflare.Zone>>;\n readonly validateToken: () => Promise<ProviderAuth.TokenValidation>;\n}\n\n/** Creates a Promise-compatible facade over the Effect-native Cloudflare client. */\nexport function make(options: Cloudflare.Client.Options): Interface {\n const client = Cloudflare.make(options);\n return {\n id: client.id,\n createRecord: (zone, record) => Effect.runPromise(client.createRecord(zone, record)),\n deleteRecord: (zone, providerRecordId) =>\n Effect.runPromise(client.deleteRecord(zone, providerRecordId)),\n getRecord: (zone, providerRecordId) =>\n Effect.runPromise(client.getRecord(zone, providerRecordId)),\n listAccounts: () => Effect.runPromise(client.listAccounts()),\n listRecords: (zone) => Effect.runPromise(client.listRecords(zone)),\n listZones: (input) => Effect.runPromise(client.listZones(input)),\n validateToken: () => Effect.runPromise(client.validateToken()),\n };\n}\n\n/** Creates the optional Cloudflare discovery source for Promise consumers. */\nexport function discovery(options: Cloudflare.Client.Options): ZoneDiscovery.Source {\n const client = make(options);\n return {\n listZones: async (name) =>\n (await client.listZones({ name })).map((zone) => ({\n ...zone,\n status: zone.status === \"active\" || zone.status === \"pending\" ? zone.status : \"unknown\",\n })),\n provider: client,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAQA,MAAa,WAAWA;AACxB,MAAa,cAAcC;AAC3B,MAAa,cAAcC;AAS3B,SAAgB,gBACd,SACwC;CACxC,MAAM,UAAUC,kBAA2B,OAAO;CAClD,QAAQ,QAAqC,gBAC3C,OAAO,WAAW,QAAQ,QAAQ,WAAW,CAAC;AAClD;;AAGA,SAAgB,UAAU,SAAkE;CAC1F,OAAOC,eAA0BC,YAAqB,OAAO,CAAC;AAChE;;AAGA,SAAgB,sBACd,SACwD;CACxD,OAAOC,sBAAiCC,wBAAiC,OAAO,CAAC;AACnF;AAEA,SAAgB,eACd,SACgE;CAChE,MAAM,WAAWC,iBAA0B,OAAO;CAClD,QAAQ,UAAU,OAAO,WAAW,SAAS,KAAK,CAAC;AACrD;;;;;;;;;ACnBA,SAAgB,KAAK,SAA+C;CAClE,MAAM,SAASC,OAAgB,OAAO;CACtC,OAAO;EACL,IAAI,OAAO;EACX,eAAe,MAAM,WAAW,OAAO,WAAW,OAAO,aAAa,MAAM,MAAM,CAAC;EACnF,eAAe,MAAM,qBACnB,OAAO,WAAW,OAAO,aAAa,MAAM,gBAAgB,CAAC;EAC/D,YAAY,MAAM,qBAChB,OAAO,WAAW,OAAO,UAAU,MAAM,gBAAgB,CAAC;EAC5D,oBAAoB,OAAO,WAAW,OAAO,aAAa,CAAC;EAC3D,cAAc,SAAS,OAAO,WAAW,OAAO,YAAY,IAAI,CAAC;EACjE,YAAY,UAAU,OAAO,WAAW,OAAO,UAAU,KAAK,CAAC;EAC/D,qBAAqB,OAAO,WAAW,OAAO,cAAc,CAAC;CAC/D;AACF;;AAGA,SAAgB,UAAU,SAA0D;CAClF,MAAM,SAAS,KAAK,OAAO;CAC3B,OAAO;EACL,WAAW,OAAO,UACf,MAAM,OAAO,UAAU,EAAE,KAAK,CAAC,EAAA,CAAG,KAAK,UAAU;GAChD,GAAG;GACH,QAAQ,KAAK,WAAW,YAAY,KAAK,WAAW,YAAY,KAAK,SAAS;EAChF,EAAE;EACJ,UAAU;CACZ;AACF"}
|
package/dist/cloudflare.d.mts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { _ as Zone, f as Account, g as Options, h as ListZonesInput, p as Fetch } from "./index-BHWRTThN.mjs";
|
|
2
|
-
import { a as cloudflare_auth_d_exports, i as make, r as discovery, t as Interface } from "./cloudflare-BrZPU9li.mjs";
|
|
3
|
-
export { type Account, cloudflare_auth_d_exports as Auth, type Fetch, Interface, type ListZonesInput, type Options, type Zone, discovery, make };
|
package/dist/cloudflare.mjs
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { B as encode, D as Error, E as DetachResult, F as Schema$1, Ft as DomainName, H as Capability, I as StoredCredential, L as assertGrant, M as Connection, N as Grant, O as Interface, P as OAuthContinuation, T as Aggregate, U as CapabilityEvidence, a as Authentication, ct as Value, d as Error$1, f as ExtendInput, g as Method$1, h as InteractiveStart, j as AuthorizationError, k as Service, l as Continuation, m as InteractiveFlow$1, r as Source$1, s as BaseInput, t as Candidate, u as ContinuationStore$1, ut as AsyncInterface, v as StartResult } from "./zone-discovery-BPnH3sLU.mjs";
|
|
2
|
-
import "./connection-api-DNuEZ_jR.mjs";
|
|
3
|
-
import { Data, Layer } from "effect";
|
|
4
|
-
declare namespace zone_discovery_d_exports {
|
|
5
|
-
export { Candidate, Outcome, Source, discover, toEffectSource };
|
|
6
|
-
}
|
|
7
|
-
interface Source {
|
|
8
|
-
readonly listZones: (name: DomainName) => Promise<ReadonlyArray<Omit<Candidate, "providerId">>>;
|
|
9
|
-
readonly provider: AsyncInterface;
|
|
10
|
-
}
|
|
11
|
-
type Outcome = {
|
|
12
|
-
readonly _tag: "NotFound";
|
|
13
|
-
readonly domain: DomainName;
|
|
14
|
-
} | {
|
|
15
|
-
readonly _tag: "Resolved";
|
|
16
|
-
readonly candidate: Candidate;
|
|
17
|
-
} | {
|
|
18
|
-
readonly _tag: "SelectionRequired";
|
|
19
|
-
readonly candidates: ReadonlyArray<Candidate>;
|
|
20
|
-
};
|
|
21
|
-
declare function discover(input: {
|
|
22
|
-
readonly domain: DomainName;
|
|
23
|
-
readonly sources: ReadonlyArray<Source>;
|
|
24
|
-
}): Promise<Outcome>;
|
|
25
|
-
declare function toEffectSource(source: Source): Source$1;
|
|
26
|
-
declare namespace authorization_lifecycle_d_exports {
|
|
27
|
-
export { Aggregate, DetachResult, Error, Repository, from, layerFrom, toAsync };
|
|
28
|
-
}
|
|
29
|
-
interface Repository {
|
|
30
|
-
readonly bind: (authorizationId: string, binding: Connection) => Promise<Aggregate>;
|
|
31
|
-
readonly connect: (aggregate: Aggregate) => Promise<Aggregate>;
|
|
32
|
-
readonly detach: (input: {
|
|
33
|
-
readonly connectionId: string;
|
|
34
|
-
readonly revoke: (aggregate: Aggregate) => Promise<void>;
|
|
35
|
-
}) => Promise<DetachResult>;
|
|
36
|
-
readonly findByProviderAccount: (providerId: string, providerAccountId: string) => Promise<Aggregate | null>;
|
|
37
|
-
readonly get: (authorizationId: string) => Promise<Aggregate | null>;
|
|
38
|
-
readonly getByConnectionId: (connectionId: string) => Promise<Aggregate | null>;
|
|
39
|
-
readonly promoteEvidence: (authorizationId: string, evidence: ReadonlyArray<CapabilityEvidence>) => Promise<Aggregate>;
|
|
40
|
-
readonly recover: (input: {
|
|
41
|
-
readonly authorizationId: string;
|
|
42
|
-
readonly revoke: (aggregate: Aggregate) => Promise<void>;
|
|
43
|
-
}) => Promise<DetachResult>;
|
|
44
|
-
readonly rotate: (authorizationId: string, credential: StoredCredential, expiresAt: Date | null) => Promise<Aggregate>;
|
|
45
|
-
}
|
|
46
|
-
declare const layerFrom: (repository: Repository) => Layer.Layer<Service>;
|
|
47
|
-
declare const toAsync: (repository: Interface) => Repository;
|
|
48
|
-
declare const from: (repository: Repository) => Repository;
|
|
49
|
-
declare namespace connection_d_exports {
|
|
50
|
-
export { Authentication, AuthorizationError, Connection, StartResult as ConnectionStartResult, ContinuationStore, Error$1 as Error, ExtendInput, Grant, InteractiveFlow, Method, OAuthContinuation, Schema$1 as Schema, StartResult, StoredCredential, assertGrant, complete, decode, encode, extend, fromEffectFlow, fromEffectTokenMethod, start, toAsyncContinuations };
|
|
51
|
-
}
|
|
52
|
-
declare function decode(input: unknown): Promise<Connection>;
|
|
53
|
-
type Method = Data.TaggedEnum<{
|
|
54
|
-
Interactive: {
|
|
55
|
-
readonly continuations: ContinuationStore;
|
|
56
|
-
readonly flow: InteractiveFlow;
|
|
57
|
-
readonly ttlMs?: number;
|
|
58
|
-
};
|
|
59
|
-
Token: {
|
|
60
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
61
|
-
readonly providerId: string;
|
|
62
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
63
|
-
readonly token: Value;
|
|
64
|
-
};
|
|
65
|
-
}>;
|
|
66
|
-
declare const Method: {
|
|
67
|
-
readonly $is: <Tag extends "Interactive" | "Token">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
68
|
-
readonly _tag: "Interactive";
|
|
69
|
-
readonly continuations: ContinuationStore;
|
|
70
|
-
readonly flow: InteractiveFlow;
|
|
71
|
-
readonly ttlMs?: number;
|
|
72
|
-
}, {
|
|
73
|
-
readonly _tag: Tag;
|
|
74
|
-
}> | Extract<{
|
|
75
|
-
readonly _tag: "Token";
|
|
76
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
77
|
-
readonly providerId: string;
|
|
78
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
79
|
-
readonly token: Value;
|
|
80
|
-
}, {
|
|
81
|
-
readonly _tag: Tag;
|
|
82
|
-
}>;
|
|
83
|
-
readonly $match: {
|
|
84
|
-
<Cases extends { readonly [Tag in "Interactive" | "Token"]: (args: Extract<{
|
|
85
|
-
readonly _tag: "Interactive";
|
|
86
|
-
readonly continuations: ContinuationStore;
|
|
87
|
-
readonly flow: InteractiveFlow;
|
|
88
|
-
readonly ttlMs?: number;
|
|
89
|
-
} | {
|
|
90
|
-
readonly _tag: "Token";
|
|
91
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
92
|
-
readonly providerId: string;
|
|
93
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
94
|
-
readonly token: Value;
|
|
95
|
-
}, {
|
|
96
|
-
readonly _tag: Tag;
|
|
97
|
-
}>) => any; }>(cases: Cases): (value: {
|
|
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
|
-
}) => import("effect/Unify").Unify<ReturnType<Cases["Interactive" | "Token"]>>;
|
|
109
|
-
<Cases extends { readonly [Tag in "Interactive" | "Token"]: (args: Extract<{
|
|
110
|
-
readonly _tag: "Interactive";
|
|
111
|
-
readonly continuations: ContinuationStore;
|
|
112
|
-
readonly flow: InteractiveFlow;
|
|
113
|
-
readonly ttlMs?: number;
|
|
114
|
-
} | {
|
|
115
|
-
readonly _tag: "Token";
|
|
116
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
117
|
-
readonly providerId: string;
|
|
118
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
119
|
-
readonly token: Value;
|
|
120
|
-
}, {
|
|
121
|
-
readonly _tag: Tag;
|
|
122
|
-
}>) => any; }>(value: {
|
|
123
|
-
readonly _tag: "Interactive";
|
|
124
|
-
readonly continuations: ContinuationStore;
|
|
125
|
-
readonly flow: InteractiveFlow;
|
|
126
|
-
readonly ttlMs?: number;
|
|
127
|
-
} | {
|
|
128
|
-
readonly _tag: "Token";
|
|
129
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
130
|
-
readonly providerId: string;
|
|
131
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
132
|
-
readonly token: Value;
|
|
133
|
-
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Interactive" | "Token"]>>;
|
|
134
|
-
};
|
|
135
|
-
readonly Interactive: Data.TaggedEnum.ConstructorFrom<{
|
|
136
|
-
readonly _tag: "Interactive";
|
|
137
|
-
readonly continuations: ContinuationStore;
|
|
138
|
-
readonly flow: InteractiveFlow;
|
|
139
|
-
readonly ttlMs?: number;
|
|
140
|
-
}, "_tag">;
|
|
141
|
-
readonly Token: Data.TaggedEnum.ConstructorFrom<{
|
|
142
|
-
readonly _tag: "Token";
|
|
143
|
-
readonly authenticate: (token: Value) => Promise<Authentication>;
|
|
144
|
-
readonly providerId: string;
|
|
145
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
146
|
-
readonly token: Value;
|
|
147
|
-
}, "_tag">;
|
|
148
|
-
};
|
|
149
|
-
interface ContinuationStore {
|
|
150
|
-
readonly consume: (id: string, now: Date) => Promise<Continuation | null>;
|
|
151
|
-
readonly put: (continuation: Continuation) => Promise<void>;
|
|
152
|
-
}
|
|
153
|
-
interface InteractiveFlow {
|
|
154
|
-
readonly complete: (payload: Value, callbackUrl: URL) => Promise<Authentication>;
|
|
155
|
-
readonly method: "integration" | "oauth2";
|
|
156
|
-
readonly providerId: string;
|
|
157
|
-
readonly requiredCapabilities: ReadonlyArray<Capability>;
|
|
158
|
-
readonly start: (continuationId: string) => Promise<InteractiveStart>;
|
|
159
|
-
}
|
|
160
|
-
declare const toAsyncContinuations: (store: ContinuationStore$1) => ContinuationStore;
|
|
161
|
-
/** Adapts an Effect-native provider flow to the Promise facade. */
|
|
162
|
-
declare const fromEffectFlow: (flow: InteractiveFlow$1) => InteractiveFlow;
|
|
163
|
-
/** Adapts an Effect-native token method to the Promise facade. */
|
|
164
|
-
declare function fromEffectTokenMethod(method: Extract<Method$1, {
|
|
165
|
-
readonly _tag: "Token";
|
|
166
|
-
}>): Extract<Method, {
|
|
167
|
-
readonly _tag: "Token";
|
|
168
|
-
}>;
|
|
169
|
-
declare function start(input: BaseInput & {
|
|
170
|
-
readonly method: Method;
|
|
171
|
-
readonly repository: Repository;
|
|
172
|
-
}): Promise<StartResult>;
|
|
173
|
-
declare function complete(input: {
|
|
174
|
-
readonly callbackUrl: URL;
|
|
175
|
-
readonly continuationId: string;
|
|
176
|
-
readonly continuations: ContinuationStore;
|
|
177
|
-
readonly flow: InteractiveFlow;
|
|
178
|
-
readonly repository: Repository;
|
|
179
|
-
}): Promise<Aggregate>;
|
|
180
|
-
/** Extends one owner binding without repeating provider authentication. */
|
|
181
|
-
declare function extend(input: ExtendInput & {
|
|
182
|
-
readonly repository: Repository;
|
|
183
|
-
}): Promise<Aggregate>;
|
|
184
|
-
//#endregion
|
|
185
|
-
export { Source as a, authorization_lifecycle_d_exports as i, Method as n, zone_discovery_d_exports as o, connection_d_exports as r, InteractiveFlow as t };
|
|
186
|
-
//# sourceMappingURL=connection-BfkloPZy.d.mts.map
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { M as Service, j as Error } from "./dns-record-BLeqo56C.mjs";
|
|
3
|
-
import { _ as StartResult, b as start$1, g as Method$1, h as Error$1, v as complete$1, y as extend$1 } from "./authorization-OeaSR47S.mjs";
|
|
4
|
-
import { i as assertGrant, n as Grant, o as decode$1, r as Schema$1, s as encode, t as AuthorizationError } from "./connection-CjNQe_E-.mjs";
|
|
5
|
-
import { i as webCryptoLayer } from "./canonical-json-CpvqGMcr.mjs";
|
|
6
|
-
import { Data, Effect, Layer } from "effect";
|
|
7
|
-
//#region src/promise/authorization-lifecycle.ts
|
|
8
|
-
var authorization_lifecycle_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
-
Error: () => Error,
|
|
10
|
-
from: () => from,
|
|
11
|
-
layerFrom: () => layerFrom,
|
|
12
|
-
toAsync: () => toAsync
|
|
13
|
-
});
|
|
14
|
-
const failure = (operation, cause) => cause instanceof Error ? cause : new Error({
|
|
15
|
-
category: "storage",
|
|
16
|
-
message: cause instanceof globalThis.Error ? cause.message : String(cause),
|
|
17
|
-
operation,
|
|
18
|
-
retry: "safe"
|
|
19
|
-
});
|
|
20
|
-
const layerFrom = (repository) => Layer.succeed(Service, {
|
|
21
|
-
bind: Effect.fn("AuthorizationLifecycleRepository.bind")((authorizationId, binding) => Effect.tryPromise({
|
|
22
|
-
try: () => repository.bind(authorizationId, binding),
|
|
23
|
-
catch: (cause) => failure("AuthorizationLifecycleRepository.bind", cause)
|
|
24
|
-
})),
|
|
25
|
-
connect: Effect.fn("AuthorizationLifecycleRepository.connect")((aggregate) => Effect.tryPromise({
|
|
26
|
-
try: () => repository.connect(aggregate),
|
|
27
|
-
catch: (cause) => failure("AuthorizationLifecycleRepository.connect", cause)
|
|
28
|
-
})),
|
|
29
|
-
detach: ({ connectionId, revoke }) => Effect.tryPromise({
|
|
30
|
-
try: () => repository.detach({
|
|
31
|
-
connectionId,
|
|
32
|
-
revoke: (aggregate) => Effect.runPromise(revoke(aggregate))
|
|
33
|
-
}),
|
|
34
|
-
catch: (cause) => failure("AuthorizationLifecycleRepository.detach", cause)
|
|
35
|
-
}),
|
|
36
|
-
findByProviderAccount: Effect.fn("AuthorizationLifecycleRepository.findByProviderAccount")((providerId, providerAccountId) => Effect.tryPromise({
|
|
37
|
-
try: () => repository.findByProviderAccount(providerId, providerAccountId),
|
|
38
|
-
catch: (cause) => failure("AuthorizationLifecycleRepository.findByProviderAccount", cause)
|
|
39
|
-
})),
|
|
40
|
-
get: Effect.fn("AuthorizationLifecycleRepository.get")((authorizationId) => Effect.tryPromise({
|
|
41
|
-
try: () => repository.get(authorizationId),
|
|
42
|
-
catch: (cause) => failure("AuthorizationLifecycleRepository.get", cause)
|
|
43
|
-
})),
|
|
44
|
-
getByConnectionId: Effect.fn("AuthorizationLifecycleRepository.getByConnectionId")((connectionId) => Effect.tryPromise({
|
|
45
|
-
try: () => repository.getByConnectionId(connectionId),
|
|
46
|
-
catch: (cause) => failure("AuthorizationLifecycleRepository.getByConnectionId", cause)
|
|
47
|
-
})),
|
|
48
|
-
promoteEvidence: Effect.fn("AuthorizationLifecycleRepository.promoteEvidence")((authorizationId, evidence) => Effect.tryPromise({
|
|
49
|
-
try: () => repository.promoteEvidence(authorizationId, evidence),
|
|
50
|
-
catch: (cause) => failure("AuthorizationLifecycleRepository.promoteEvidence", cause)
|
|
51
|
-
})),
|
|
52
|
-
recover: ({ authorizationId, revoke }) => Effect.tryPromise({
|
|
53
|
-
try: () => repository.recover({
|
|
54
|
-
authorizationId,
|
|
55
|
-
revoke: (aggregate) => Effect.runPromise(revoke(aggregate))
|
|
56
|
-
}),
|
|
57
|
-
catch: (cause) => failure("AuthorizationLifecycleRepository.recover", cause)
|
|
58
|
-
}),
|
|
59
|
-
rotate: Effect.fn("AuthorizationLifecycleRepository.rotate")((authorizationId, credential, expiresAt) => Effect.tryPromise({
|
|
60
|
-
try: () => repository.rotate(authorizationId, credential, expiresAt),
|
|
61
|
-
catch: (cause) => failure("AuthorizationLifecycleRepository.rotate", cause)
|
|
62
|
-
}))
|
|
63
|
-
});
|
|
64
|
-
const toAsync = (repository) => ({
|
|
65
|
-
bind: (authorizationId, binding) => Effect.runPromise(repository.bind(authorizationId, binding)),
|
|
66
|
-
connect: (aggregate) => Effect.runPromise(repository.connect(aggregate)),
|
|
67
|
-
detach: ({ connectionId, revoke }) => Effect.runPromise(repository.detach({
|
|
68
|
-
connectionId,
|
|
69
|
-
revoke: (aggregate) => Effect.tryPromise(() => revoke(aggregate))
|
|
70
|
-
})),
|
|
71
|
-
findByProviderAccount: (providerId, providerAccountId) => Effect.runPromise(repository.findByProviderAccount(providerId, providerAccountId)),
|
|
72
|
-
get: (authorizationId) => Effect.runPromise(repository.get(authorizationId)),
|
|
73
|
-
getByConnectionId: (connectionId) => Effect.runPromise(repository.getByConnectionId(connectionId)),
|
|
74
|
-
promoteEvidence: (authorizationId, evidence) => Effect.runPromise(repository.promoteEvidence(authorizationId, evidence)),
|
|
75
|
-
recover: ({ authorizationId, revoke }) => Effect.runPromise(repository.recover({
|
|
76
|
-
authorizationId,
|
|
77
|
-
revoke: (aggregate) => Effect.tryPromise(() => revoke(aggregate))
|
|
78
|
-
})),
|
|
79
|
-
rotate: (authorizationId, credential, expiresAt) => Effect.runPromise(repository.rotate(authorizationId, credential, expiresAt))
|
|
80
|
-
});
|
|
81
|
-
const from = (repository) => repository;
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/promise/connection.ts
|
|
84
|
-
var connection_exports = /* @__PURE__ */ __exportAll({
|
|
85
|
-
AuthorizationError: () => AuthorizationError,
|
|
86
|
-
Error: () => Error$1,
|
|
87
|
-
Grant: () => Grant,
|
|
88
|
-
Method: () => Method,
|
|
89
|
-
Schema: () => Schema$1,
|
|
90
|
-
StartResult: () => StartResult,
|
|
91
|
-
assertGrant: () => assertGrant,
|
|
92
|
-
complete: () => complete,
|
|
93
|
-
decode: () => decode,
|
|
94
|
-
encode: () => encode,
|
|
95
|
-
extend: () => extend,
|
|
96
|
-
fromEffectFlow: () => fromEffectFlow,
|
|
97
|
-
fromEffectTokenMethod: () => fromEffectTokenMethod,
|
|
98
|
-
start: () => start,
|
|
99
|
-
toAsyncContinuations: () => toAsyncContinuations
|
|
100
|
-
});
|
|
101
|
-
function decode(input) {
|
|
102
|
-
return Effect.runPromise(decode$1(input));
|
|
103
|
-
}
|
|
104
|
-
const Method = Data.taggedEnum();
|
|
105
|
-
const connectionFailure = (operation, cause) => cause instanceof Error$1 ? cause : new Error$1({
|
|
106
|
-
category: "provider",
|
|
107
|
-
message: cause instanceof globalThis.Error ? cause.message : String(cause),
|
|
108
|
-
operation,
|
|
109
|
-
retry: "unknown"
|
|
110
|
-
});
|
|
111
|
-
const effectMethod = (method) => method._tag === "Interactive" ? Method$1.Interactive({
|
|
112
|
-
continuations: effectContinuations(method.continuations),
|
|
113
|
-
flow: effectFlow(method.flow),
|
|
114
|
-
...method.ttlMs === void 0 ? {} : { ttlMs: method.ttlMs }
|
|
115
|
-
}) : Method$1.Token({
|
|
116
|
-
authenticate: (token) => Effect.tryPromise({
|
|
117
|
-
try: () => method.authenticate(token),
|
|
118
|
-
catch: (cause) => connectionFailure("Connection.start", cause)
|
|
119
|
-
}),
|
|
120
|
-
providerId: method.providerId,
|
|
121
|
-
requiredCapabilities: method.requiredCapabilities,
|
|
122
|
-
token: method.token
|
|
123
|
-
});
|
|
124
|
-
const effectContinuations = (store) => ({
|
|
125
|
-
consume: (id, now) => Effect.tryPromise({
|
|
126
|
-
try: () => store.consume(id, now),
|
|
127
|
-
catch: (cause) => connectionFailure("ConnectionContinuations.consume", cause)
|
|
128
|
-
}),
|
|
129
|
-
put: (continuation) => Effect.tryPromise({
|
|
130
|
-
try: () => store.put(continuation),
|
|
131
|
-
catch: (cause) => connectionFailure("ConnectionContinuations.put", cause)
|
|
132
|
-
})
|
|
133
|
-
});
|
|
134
|
-
const toAsyncContinuations = (store) => ({
|
|
135
|
-
consume: (id, now) => Effect.runPromise(store.consume(id, now)),
|
|
136
|
-
put: (continuation) => Effect.runPromise(store.put(continuation))
|
|
137
|
-
});
|
|
138
|
-
const effectFlow = (flow) => ({
|
|
139
|
-
complete: (payload, callbackUrl) => Effect.tryPromise({
|
|
140
|
-
try: () => flow.complete(payload, callbackUrl),
|
|
141
|
-
catch: (cause) => connectionFailure("Connection.complete", cause)
|
|
142
|
-
}),
|
|
143
|
-
method: flow.method,
|
|
144
|
-
providerId: flow.providerId,
|
|
145
|
-
requiredCapabilities: flow.requiredCapabilities,
|
|
146
|
-
start: (continuationId) => Effect.tryPromise({
|
|
147
|
-
try: () => flow.start(continuationId),
|
|
148
|
-
catch: (cause) => connectionFailure("Connection.start", cause)
|
|
149
|
-
})
|
|
150
|
-
});
|
|
151
|
-
/** Adapts an Effect-native provider flow to the Promise facade. */
|
|
152
|
-
const fromEffectFlow = (flow) => ({
|
|
153
|
-
complete: (payload, callbackUrl) => Effect.runPromise(flow.complete(payload, callbackUrl)),
|
|
154
|
-
method: flow.method,
|
|
155
|
-
providerId: flow.providerId,
|
|
156
|
-
requiredCapabilities: flow.requiredCapabilities,
|
|
157
|
-
start: (continuationId) => Effect.runPromise(flow.start(continuationId).pipe(Effect.provide(webCryptoLayer)))
|
|
158
|
-
});
|
|
159
|
-
/** Adapts an Effect-native token method to the Promise facade. */
|
|
160
|
-
function fromEffectTokenMethod(method) {
|
|
161
|
-
return Method.Token({
|
|
162
|
-
authenticate: (token) => Effect.runPromise(method.authenticate(token)),
|
|
163
|
-
providerId: method.providerId,
|
|
164
|
-
requiredCapabilities: method.requiredCapabilities,
|
|
165
|
-
token: method.token
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
async function start(input) {
|
|
169
|
-
return Effect.runPromise(start$1({
|
|
170
|
-
authorizedById: input.authorizedById,
|
|
171
|
-
grant: input.grant,
|
|
172
|
-
method: effectMethod(input.method),
|
|
173
|
-
ownerId: input.ownerId
|
|
174
|
-
}).pipe(Effect.provide(Layer.merge(layerFrom(input.repository), webCryptoLayer))));
|
|
175
|
-
}
|
|
176
|
-
async function complete(input) {
|
|
177
|
-
return Effect.runPromise(complete$1({
|
|
178
|
-
callbackUrl: input.callbackUrl,
|
|
179
|
-
continuationId: input.continuationId,
|
|
180
|
-
continuations: effectContinuations(input.continuations),
|
|
181
|
-
flow: effectFlow(input.flow)
|
|
182
|
-
}).pipe(Effect.provide(Layer.merge(layerFrom(input.repository), webCryptoLayer))));
|
|
183
|
-
}
|
|
184
|
-
/** Extends one owner binding without repeating provider authentication. */
|
|
185
|
-
async function extend(input) {
|
|
186
|
-
return Effect.runPromise(extend$1({
|
|
187
|
-
connectionId: input.connectionId,
|
|
188
|
-
grant: input.grant,
|
|
189
|
-
ownerId: input.ownerId
|
|
190
|
-
}).pipe(Effect.provide(layerFrom(input.repository))));
|
|
191
|
-
}
|
|
192
|
-
//#endregion
|
|
193
|
-
export { authorization_lifecycle_exports as i, fromEffectFlow as n, fromEffectTokenMethod as r, connection_exports as t };
|
|
194
|
-
|
|
195
|
-
//# sourceMappingURL=connection-BwtOwpH6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-BwtOwpH6.mjs","names":["Lifecycle.Error","Lifecycle.Service","Connection.decode","Connect.Error","Connect.start","LifecycleRepository.layerFrom","Connect.complete","Connect.extend"],"sources":["../src/promise/authorization-lifecycle.ts","../src/promise/connection.ts"],"sourcesContent":["import { Effect, Layer } from \"effect\";\n\nimport type * as ProviderAuthorization from \"../auth/authorization.ts\";\nimport type * as Connection from \"../auth/connection.ts\";\nimport * as Lifecycle from \"../auth/lifecycle-repository.ts\";\n\nexport interface Repository {\n readonly bind: (\n authorizationId: string,\n binding: Connection.Connection,\n ) => Promise<Lifecycle.Aggregate>;\n readonly connect: (aggregate: Lifecycle.Aggregate) => Promise<Lifecycle.Aggregate>;\n readonly detach: (input: {\n readonly connectionId: string;\n readonly revoke: (aggregate: Lifecycle.Aggregate) => Promise<void>;\n }) => Promise<Lifecycle.DetachResult>;\n readonly findByProviderAccount: (\n providerId: string,\n providerAccountId: string,\n ) => Promise<Lifecycle.Aggregate | null>;\n readonly get: (authorizationId: string) => Promise<Lifecycle.Aggregate | null>;\n readonly getByConnectionId: (connectionId: string) => Promise<Lifecycle.Aggregate | null>;\n readonly promoteEvidence: (\n authorizationId: string,\n evidence: ReadonlyArray<ProviderAuthorization.CapabilityEvidence>,\n ) => Promise<Lifecycle.Aggregate>;\n readonly recover: (input: {\n readonly authorizationId: string;\n readonly revoke: (aggregate: Lifecycle.Aggregate) => Promise<void>;\n }) => Promise<Lifecycle.DetachResult>;\n readonly rotate: (\n authorizationId: string,\n credential: Connection.StoredCredential,\n expiresAt: Date | null,\n ) => Promise<Lifecycle.Aggregate>;\n}\n\nconst failure = (operation: string, cause: unknown): Lifecycle.Error =>\n cause instanceof Lifecycle.Error\n ? cause\n : new Lifecycle.Error({\n category: \"storage\",\n message: cause instanceof globalThis.Error ? cause.message : String(cause),\n operation,\n retry: \"safe\",\n });\n\nexport const layerFrom = (repository: Repository): Layer.Layer<Lifecycle.Service> =>\n Layer.succeed(Lifecycle.Service, {\n bind: Effect.fn(\"AuthorizationLifecycleRepository.bind\")((authorizationId, binding) =>\n Effect.tryPromise({\n try: () => repository.bind(authorizationId, binding),\n catch: (cause) => failure(\"AuthorizationLifecycleRepository.bind\", cause),\n }),\n ),\n connect: Effect.fn(\"AuthorizationLifecycleRepository.connect\")((aggregate) =>\n Effect.tryPromise({\n try: () => repository.connect(aggregate),\n catch: (cause) => failure(\"AuthorizationLifecycleRepository.connect\", cause),\n }),\n ),\n detach: ({ connectionId, revoke }) =>\n Effect.tryPromise({\n try: () =>\n repository.detach({\n connectionId,\n revoke: (aggregate) => Effect.runPromise(revoke(aggregate)),\n }),\n catch: (cause) => failure(\"AuthorizationLifecycleRepository.detach\", cause),\n }),\n findByProviderAccount: Effect.fn(\"AuthorizationLifecycleRepository.findByProviderAccount\")(\n (providerId, providerAccountId) =>\n Effect.tryPromise({\n try: () => repository.findByProviderAccount(providerId, providerAccountId),\n catch: (cause) =>\n failure(\"AuthorizationLifecycleRepository.findByProviderAccount\", cause),\n }),\n ),\n get: Effect.fn(\"AuthorizationLifecycleRepository.get\")((authorizationId) =>\n Effect.tryPromise({\n try: () => repository.get(authorizationId),\n catch: (cause) => failure(\"AuthorizationLifecycleRepository.get\", cause),\n }),\n ),\n getByConnectionId: Effect.fn(\"AuthorizationLifecycleRepository.getByConnectionId\")(\n (connectionId) =>\n Effect.tryPromise({\n try: () => repository.getByConnectionId(connectionId),\n catch: (cause) => failure(\"AuthorizationLifecycleRepository.getByConnectionId\", cause),\n }),\n ),\n promoteEvidence: Effect.fn(\"AuthorizationLifecycleRepository.promoteEvidence\")(\n (authorizationId, evidence) =>\n Effect.tryPromise({\n try: () => repository.promoteEvidence(authorizationId, evidence),\n catch: (cause) => failure(\"AuthorizationLifecycleRepository.promoteEvidence\", cause),\n }),\n ),\n recover: ({ authorizationId, revoke }) =>\n Effect.tryPromise({\n try: () =>\n repository.recover({\n authorizationId,\n revoke: (aggregate) => Effect.runPromise(revoke(aggregate)),\n }),\n catch: (cause) => failure(\"AuthorizationLifecycleRepository.recover\", cause),\n }),\n rotate: Effect.fn(\"AuthorizationLifecycleRepository.rotate\")(\n (authorizationId, credential, expiresAt) =>\n Effect.tryPromise({\n try: () => repository.rotate(authorizationId, credential, expiresAt),\n catch: (cause) => failure(\"AuthorizationLifecycleRepository.rotate\", cause),\n }),\n ),\n });\n\nexport const toAsync = (repository: Lifecycle.Interface): Repository => ({\n bind: (authorizationId, binding) => Effect.runPromise(repository.bind(authorizationId, binding)),\n connect: (aggregate) => Effect.runPromise(repository.connect(aggregate)),\n detach: ({ connectionId, revoke }) =>\n Effect.runPromise(\n repository.detach({\n connectionId,\n revoke: (aggregate) => Effect.tryPromise(() => revoke(aggregate)),\n }),\n ),\n findByProviderAccount: (providerId, providerAccountId) =>\n Effect.runPromise(repository.findByProviderAccount(providerId, providerAccountId)),\n get: (authorizationId) => Effect.runPromise(repository.get(authorizationId)),\n getByConnectionId: (connectionId) =>\n Effect.runPromise(repository.getByConnectionId(connectionId)),\n promoteEvidence: (authorizationId, evidence) =>\n Effect.runPromise(repository.promoteEvidence(authorizationId, evidence)),\n recover: ({ authorizationId, revoke }) =>\n Effect.runPromise(\n repository.recover({\n authorizationId,\n revoke: (aggregate) => Effect.tryPromise(() => revoke(aggregate)),\n }),\n ),\n rotate: (authorizationId, credential, expiresAt) =>\n Effect.runPromise(repository.rotate(authorizationId, credential, expiresAt)),\n});\n\nexport const from = (repository: Repository): Repository => repository;\n\nexport { Error } from \"../auth/lifecycle-repository.ts\";\nexport type { Aggregate, DetachResult } from \"../auth/lifecycle-repository.ts\";\n","import { Data, Effect, Layer } from \"effect\";\n\nimport * as Connection from \"../auth/connection.ts\";\nimport * as Connect from \"../auth/connect.ts\";\nimport type * as Repository from \"./authorization-lifecycle.ts\";\nimport type * as ProviderAuthorization from \"../auth/authorization.ts\";\nimport { webCryptoLayer } from \"../plan/canonical-json.ts\";\nimport * as LifecycleRepository from \"./authorization-lifecycle.ts\";\nimport type * as Secret from \"../auth/secret.ts\";\n\nexport { assertGrant, AuthorizationError, encode, Grant, Schema } from \"../auth/connection.ts\";\nexport type { Connection, OAuthContinuation, StoredCredential } from \"../auth/connection.ts\";\n\nexport function decode(input: unknown): Promise<Connection.Connection> {\n return Effect.runPromise(Connection.decode(input));\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: (token: Secret.Value) => Promise<Connect.Authentication>;\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 interface ContinuationStore {\n readonly consume: (id: string, now: Date) => Promise<Connect.Continuation | null>;\n readonly put: (continuation: Connect.Continuation) => Promise<void>;\n}\n\nexport interface InteractiveFlow {\n readonly complete: (payload: Secret.Value, callbackUrl: URL) => Promise<Connect.Authentication>;\n readonly method: \"integration\" | \"oauth2\";\n readonly providerId: string;\n readonly requiredCapabilities: ReadonlyArray<ProviderAuthorization.Capability>;\n readonly start: (continuationId: string) => Promise<Connect.InteractiveStart>;\n}\n\nconst connectionFailure = (operation: string, cause: unknown): Connect.Error =>\n cause instanceof Connect.Error\n ? cause\n : new Connect.Error({\n category: \"provider\",\n message: cause instanceof globalThis.Error ? cause.message : String(cause),\n operation,\n retry: \"unknown\",\n });\n\nconst effectMethod = (method: Method): Connect.Method =>\n method._tag === \"Interactive\"\n ? Connect.Method.Interactive({\n continuations: effectContinuations(method.continuations),\n flow: effectFlow(method.flow),\n ...(method.ttlMs === undefined ? {} : { ttlMs: method.ttlMs }),\n })\n : Connect.Method.Token({\n authenticate: (token) =>\n Effect.tryPromise({\n try: () => method.authenticate(token),\n catch: (cause) => connectionFailure(\"Connection.start\", cause),\n }),\n providerId: method.providerId,\n requiredCapabilities: method.requiredCapabilities,\n token: method.token,\n });\n\nconst effectContinuations = (store: ContinuationStore): Connect.ContinuationStore => ({\n consume: (id, now) =>\n Effect.tryPromise({\n try: () => store.consume(id, now),\n catch: (cause) => connectionFailure(\"ConnectionContinuations.consume\", cause),\n }),\n put: (continuation) =>\n Effect.tryPromise({\n try: () => store.put(continuation),\n catch: (cause) => connectionFailure(\"ConnectionContinuations.put\", cause),\n }),\n});\n\nexport const toAsyncContinuations = (store: Connect.ContinuationStore): ContinuationStore => ({\n consume: (id, now) => Effect.runPromise(store.consume(id, now)),\n put: (continuation) => Effect.runPromise(store.put(continuation)),\n});\n\nconst effectFlow = (flow: InteractiveFlow): Connect.InteractiveFlow => ({\n complete: (payload, callbackUrl) =>\n Effect.tryPromise({\n try: () => flow.complete(payload, callbackUrl),\n catch: (cause) => connectionFailure(\"Connection.complete\", cause),\n }),\n method: flow.method,\n providerId: flow.providerId,\n requiredCapabilities: flow.requiredCapabilities,\n start: (continuationId) =>\n Effect.tryPromise({\n try: () => flow.start(continuationId),\n catch: (cause) => connectionFailure(\"Connection.start\", cause),\n }),\n});\n\n/** Adapts an Effect-native provider flow to the Promise facade. */\nexport const fromEffectFlow = (flow: Connect.InteractiveFlow): InteractiveFlow => ({\n complete: (payload, callbackUrl) => Effect.runPromise(flow.complete(payload, callbackUrl)),\n method: flow.method,\n providerId: flow.providerId,\n requiredCapabilities: flow.requiredCapabilities,\n start: (continuationId) =>\n Effect.runPromise(flow.start(continuationId).pipe(Effect.provide(webCryptoLayer))),\n});\n\n/** Adapts an Effect-native token method to the Promise facade. */\nexport function fromEffectTokenMethod(\n method: Extract<Connect.Method, { readonly _tag: \"Token\" }>,\n): Extract<Method, { readonly _tag: \"Token\" }> {\n return Method.Token({\n authenticate: (token) => Effect.runPromise(method.authenticate(token)),\n providerId: method.providerId,\n requiredCapabilities: method.requiredCapabilities,\n token: method.token,\n });\n}\n\nexport async function start(\n input: Connect.BaseInput & {\n readonly method: Method;\n readonly repository: Repository.Repository;\n },\n): Promise<Connect.StartResult> {\n return Effect.runPromise(\n Connect.start({\n authorizedById: input.authorizedById,\n grant: input.grant,\n method: effectMethod(input.method),\n ownerId: input.ownerId,\n }).pipe(\n Effect.provide(Layer.merge(LifecycleRepository.layerFrom(input.repository), webCryptoLayer)),\n ),\n );\n}\n\nexport async function complete(input: {\n readonly callbackUrl: URL;\n readonly continuationId: string;\n readonly continuations: ContinuationStore;\n readonly flow: InteractiveFlow;\n readonly repository: Repository.Repository;\n}): Promise<Repository.Aggregate> {\n return Effect.runPromise(\n Connect.complete({\n callbackUrl: input.callbackUrl,\n continuationId: input.continuationId,\n continuations: effectContinuations(input.continuations),\n flow: effectFlow(input.flow),\n }).pipe(\n Effect.provide(Layer.merge(LifecycleRepository.layerFrom(input.repository), webCryptoLayer)),\n ),\n );\n}\n\n/** Extends one owner binding without repeating provider authentication. */\nexport async function extend(\n input: Connect.ExtendInput & { readonly repository: Repository.Repository },\n): Promise<Repository.Aggregate> {\n return Effect.runPromise(\n Connect.extend({\n connectionId: input.connectionId,\n grant: input.grant,\n ownerId: input.ownerId,\n }).pipe(Effect.provide(LifecycleRepository.layerFrom(input.repository))),\n );\n}\n\nexport { Error, StartResult } from \"../auth/connect.ts\";\nexport type { Authentication, ConnectionStartResult, ExtendInput } from \"../auth/connection-api.ts\";\n"],"mappings":";;;;;;;;;;;;;AAqCA,MAAM,WAAW,WAAmB,UAClC,iBAAiBA,QACb,QACA,IAAIA,MAAgB;CAClB,UAAU;CACV,SAAS,iBAAiB,WAAW,QAAQ,MAAM,UAAU,OAAO,KAAK;CACzE;CACA,OAAO;AACT,CAAC;AAEP,MAAa,aAAa,eACxB,MAAM,QAAQC,SAAmB;CAC/B,MAAM,OAAO,GAAG,uCAAuC,CAAC,EAAE,iBAAiB,YACzE,OAAO,WAAW;EAChB,WAAW,WAAW,KAAK,iBAAiB,OAAO;EACnD,QAAQ,UAAU,QAAQ,yCAAyC,KAAK;CAC1E,CAAC,CACH;CACA,SAAS,OAAO,GAAG,0CAA0C,CAAC,EAAE,cAC9D,OAAO,WAAW;EAChB,WAAW,WAAW,QAAQ,SAAS;EACvC,QAAQ,UAAU,QAAQ,4CAA4C,KAAK;CAC7E,CAAC,CACH;CACA,SAAS,EAAE,cAAc,aACvB,OAAO,WAAW;EAChB,WACE,WAAW,OAAO;GAChB;GACA,SAAS,cAAc,OAAO,WAAW,OAAO,SAAS,CAAC;EAC5D,CAAC;EACH,QAAQ,UAAU,QAAQ,2CAA2C,KAAK;CAC5E,CAAC;CACH,uBAAuB,OAAO,GAAG,wDAAwD,CAAC,EACvF,YAAY,sBACX,OAAO,WAAW;EAChB,WAAW,WAAW,sBAAsB,YAAY,iBAAiB;EACzE,QAAQ,UACN,QAAQ,0DAA0D,KAAK;CAC3E,CAAC,CACL;CACA,KAAK,OAAO,GAAG,sCAAsC,CAAC,EAAE,oBACtD,OAAO,WAAW;EAChB,WAAW,WAAW,IAAI,eAAe;EACz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G,cAAc,CAAC,CAC7F,CACF;AACF;AAEA,eAAsB,SAAS,OAMG;CAChC,OAAO,OAAO,WACZC,WAAiB;EACf,aAAa,MAAM;EACnB,gBAAgB,MAAM;EACtB,eAAe,oBAAoB,MAAM,aAAa;EACtD,MAAM,WAAW,MAAM,IAAI;CAC7B,CAAC,CAAC,CAAC,KACD,OAAO,QAAQ,MAAM,MAAMD,UAA8B,MAAM,UAAU,GAAG,cAAc,CAAC,CAC7F,CACF;AACF;;AAGA,eAAsB,OACpB,OAC+B;CAC/B,OAAO,OAAO,WACZE,SAAe;EACb,cAAc,MAAM;EACpB,OAAO,MAAM;EACb,SAAS,MAAM;CACjB,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQF,UAA8B,MAAM,UAAU,CAAC,CAAC,CACzE;AACF"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { O as parse, T as Schema$2, k as Error$1 } from "./dns-record-BLeqo56C.mjs";
|
|
2
|
-
import { l as evidenceFor } from "./authorization-OeaSR47S.mjs";
|
|
3
|
-
import { Effect, Schema } from "effect";
|
|
4
|
-
//#region src/auth/connection.ts
|
|
5
|
-
const Grant = Schema.TaggedUnion({
|
|
6
|
-
account: {},
|
|
7
|
-
domains: { domains: Schema.Array(Schema$2) }
|
|
8
|
-
});
|
|
9
|
-
/** An owner-scoped grant bound to one provider authorization. */
|
|
10
|
-
const Schema$1 = Schema.Struct({
|
|
11
|
-
authorizationId: Schema.String,
|
|
12
|
-
createdAt: Schema.DateFromString,
|
|
13
|
-
grant: Grant,
|
|
14
|
-
id: Schema.String,
|
|
15
|
-
ownerId: Schema.String
|
|
16
|
-
});
|
|
17
|
-
const decode = Effect.fn("Connection.decode")((input) => Schema.decodeUnknownEffect(Schema$1)(input).pipe(Effect.mapError((cause) => new Error$1({ message: cause.message }))));
|
|
18
|
-
const validate = Effect.fn("Connection.validate")((input) => Schema.decodeUnknownEffect(Schema.toType(Schema$1))(input).pipe(Effect.mapError((cause) => new Error$1({ message: cause.message }))));
|
|
19
|
-
const encode = Schema.encodeSync(Schema$1);
|
|
20
|
-
var AuthorizationError = class extends Schema.TaggedError()("AuthorizationError", {
|
|
21
|
-
category: Schema.Literal("authorization"),
|
|
22
|
-
message: Schema.String,
|
|
23
|
-
operation: Schema.String,
|
|
24
|
-
retry: Schema.Literals([
|
|
25
|
-
"never",
|
|
26
|
-
"after-user-action",
|
|
27
|
-
"safe",
|
|
28
|
-
"unknown"
|
|
29
|
-
])
|
|
30
|
-
}) {};
|
|
31
|
-
const authorizationError = (message, operation) => new AuthorizationError({
|
|
32
|
-
category: "authorization",
|
|
33
|
-
message,
|
|
34
|
-
operation,
|
|
35
|
-
retry: "after-user-action"
|
|
36
|
-
});
|
|
37
|
-
function assertGrant(connection, authorization, request) {
|
|
38
|
-
if (connection.authorizationId !== authorization.id || authorization.providerId !== request.providerId || authorization.revocation._tag !== "Active") throw authorizationError("Connection does not grant this provider account", "Connection.assertGrant");
|
|
39
|
-
if (authorization.expiresAt !== null) {
|
|
40
|
-
if (Number.isNaN(authorization.expiresAt.getTime())) throw authorizationError("Connection expiration is invalid", "Connection.assertGrant");
|
|
41
|
-
if (authorization.expiresAt <= (request.now ?? /* @__PURE__ */ new Date())) throw authorizationError("Connection has expired", "Connection.assertGrant");
|
|
42
|
-
}
|
|
43
|
-
if (!authorization.requiredCapabilities.includes(request.capability)) throw authorizationError(`Connection lacks the ${request.capability} capability`, "Connection.assertGrant");
|
|
44
|
-
if (evidenceFor(authorization, request.capability) === void 0) throw authorizationError(`Connection has no evidence for the ${request.capability} capability`, "Connection.assertGrant");
|
|
45
|
-
let domain;
|
|
46
|
-
try {
|
|
47
|
-
domain = parse(request.domain);
|
|
48
|
-
} catch (cause) {
|
|
49
|
-
if (cause instanceof Error$1) throw cause;
|
|
50
|
-
throw new Error$1({ message: cause instanceof Error ? cause.message : String(cause) });
|
|
51
|
-
}
|
|
52
|
-
if (connection.grant._tag === "domains" && !connection.grant.domains.includes(domain)) throw authorizationError("Connection does not grant this domain", "Connection.assertGrant");
|
|
53
|
-
return domain;
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { authorizationError as a, validate as c, assertGrant as i, Grant as n, decode as o, Schema$1 as r, encode as s, AuthorizationError as t };
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=connection-CjNQe_E-.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-CjNQe_E-.mjs","names":["S","DomainName.Schema","Schema","InvalidInputError","ProviderAuthorization.evidenceFor","DomainName.parse"],"sources":["../src/auth/connection.ts"],"sourcesContent":["import { Effect, Schema as S } from \"effect\";\n\nimport * as DomainName from \"../domain/domain-name.ts\";\nimport { Error as InvalidInputError } from \"../invalid-input.ts\";\nimport type { Value as Secret } from \"./secret.ts\";\nimport type { OAuthMethod } from \"./manifest.ts\";\nimport * as ProviderAuthorization from \"./authorization.ts\";\n\nexport const Grant = S.TaggedUnion({\n account: {},\n domains: { domains: S.Array(DomainName.Schema) },\n});\nexport type Grant = typeof Grant.Type;\n\n/** An owner-scoped grant bound to one provider authorization. */\nexport const Schema = S.Struct({\n authorizationId: S.String,\n createdAt: S.DateFromString,\n grant: Grant,\n id: S.String,\n ownerId: S.String,\n});\nexport interface Connection extends S.Schema.Type<typeof Schema> {}\n\nexport const decode = Effect.fn(\"Connection.decode\")((input: unknown) =>\n S.decodeUnknownEffect(Schema)(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\n\nexport const validate = Effect.fn(\"Connection.validate\")((input: unknown) =>\n S.decodeUnknownEffect(S.toType(Schema))(input).pipe(\n Effect.mapError((cause) => new InvalidInputError({ message: cause.message })),\n ),\n);\n\nexport const encode = S.encodeSync(Schema);\n\nexport interface OAuthContinuation {\n readonly clientId: string;\n readonly codeVerifier: Secret;\n readonly expiresAt: Date;\n readonly grant: Grant;\n readonly method: OAuthMethod;\n readonly ownerId: string;\n readonly redirectUri: string;\n readonly stateHash: string;\n readonly authorizedById: string;\n}\n\nexport interface StoredCredential {\n readonly accessToken: Secret;\n readonly refreshToken: Secret | null;\n readonly tokenType: string;\n}\n\nexport class AuthorizationError extends S.TaggedError<AuthorizationError>()(\"AuthorizationError\", {\n category: S.Literal(\"authorization\"),\n message: S.String,\n operation: S.String,\n retry: S.Literals([\"never\", \"after-user-action\", \"safe\", \"unknown\"]),\n}) {}\n\nexport const authorizationError = (message: string, operation: string): AuthorizationError =>\n new AuthorizationError({\n category: \"authorization\",\n message,\n operation,\n retry: \"after-user-action\",\n });\n\nexport function assertGrant(\n connection: Connection,\n authorization: ProviderAuthorization.ProviderAuthorization,\n request: {\n readonly capability: ProviderAuthorization.Capability;\n readonly domain: string;\n readonly now?: Date;\n readonly providerId: string;\n },\n): DomainName.DomainName {\n if (\n connection.authorizationId !== authorization.id ||\n authorization.providerId !== request.providerId ||\n authorization.revocation._tag !== \"Active\"\n ) {\n throw authorizationError(\n \"Connection does not grant this provider account\",\n \"Connection.assertGrant\",\n );\n }\n if (authorization.expiresAt !== null) {\n if (Number.isNaN(authorization.expiresAt.getTime())) {\n throw authorizationError(\"Connection expiration is invalid\", \"Connection.assertGrant\");\n }\n if (authorization.expiresAt <= (request.now ?? new Date())) {\n throw authorizationError(\"Connection has expired\", \"Connection.assertGrant\");\n }\n }\n if (!authorization.requiredCapabilities.includes(request.capability)) {\n throw authorizationError(\n `Connection lacks the ${request.capability} capability`,\n \"Connection.assertGrant\",\n );\n }\n if (ProviderAuthorization.evidenceFor(authorization, request.capability) === undefined) {\n throw authorizationError(\n `Connection has no evidence for the ${request.capability} capability`,\n \"Connection.assertGrant\",\n );\n }\n let domain: DomainName.DomainName;\n try {\n domain = DomainName.parse(request.domain);\n } catch (cause) {\n if (cause instanceof InvalidInputError) throw cause;\n throw new InvalidInputError({\n message: cause instanceof Error ? cause.message : String(cause),\n });\n }\n if (connection.grant._tag === \"domains\" && !connection.grant.domains.includes(domain)) {\n throw authorizationError(\"Connection does not grant this domain\", \"Connection.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,IAAI,OAAO,MAAM,cAAc,UAAU,QAAQ,CAAC,GAChD,MAAM,mBAAmB,oCAAoC,wBAAwB;EAEvF,IAAI,cAAc,cAAc,QAAQ,uBAAO,IAAI,KAAK,IACtD,MAAM,mBAAmB,0BAA0B,wBAAwB;CAE/E;CACA,IAAI,CAAC,cAAc,qBAAqB,SAAS,QAAQ,UAAU,GACjE,MAAM,mBACJ,wBAAwB,QAAQ,WAAW,cAC3C,wBACF;CAEF,IAAII,YAAkC,eAAe,QAAQ,UAAU,MAAM,KAAA,GAC3E,MAAM,mBACJ,sCAAsC,QAAQ,WAAW,cACzD,wBACF;CAEF,IAAI;CACJ,IAAI;EACF,SAASC,MAAiB,QAAQ,MAAM;CAC1C,SAAS,OAAO;EACd,IAAI,iBAAiBF,SAAmB,MAAM;EAC9C,MAAM,IAAIA,QAAkB,EAC1B,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAChE,CAAC;CACH;CACA,IAAI,WAAW,MAAM,SAAS,aAAa,CAAC,WAAW,MAAM,QAAQ,SAAS,MAAM,GAClF,MAAM,mBAAmB,yCAAyC,wBAAwB;CAE5F,OAAO;AACT"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { B as encode, F as Schema, I as StoredCredential, L as assertGrant, M as Connection, N as Grant, R as authorizationError, V as validate, _ as Requirements, a as Authentication, b as extend, c as CompleteInput, d as Error, f as ExtendInput, g as Method, h as InteractiveStart, j as AuthorizationError, l as Continuation, m as InteractiveFlow, o as AuthenticationFailure, p as Failure, s as BaseInput, u as ContinuationStore, v as StartResult, x as start, y as complete, z as decode } from "./zone-discovery-BPnH3sLU.mjs";
|
|
2
|
-
declare namespace connection_api_d_exports {
|
|
3
|
-
export { Authentication, AuthenticationFailure, AuthorizationError, BaseInput, CompleteInput, Connection, Method as ConnectionMethod, StartResult as ConnectionStartResult, Continuation, ContinuationStore, Error, ExtendInput, Failure, Grant, InteractiveFlow, InteractiveStart, Method, Requirements, Schema, StartResult, StoredCredential, assertGrant, authorizationError, complete, decode, encode, extend, start, validate };
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
export { connection_api_d_exports as t };
|
|
7
|
-
//# sourceMappingURL=connection-api-DNuEZ_jR.d.mts.map
|