Open History to see the last commit
1import type {
2 ChatGptReconnectProfile,
3 ChatGptTransferredProfile,
4 ProviderAuthRespondInput,
5 ProviderAuthState,
6 ProviderSetupError,
7} from "@t3tools/contracts";
8import type * as Effect from "effect/Effect";
9import type * as Scope from "effect/Scope";
10import type * as Stream from "effect/Stream";
11
12export interface ProviderAuthController {
13 readonly credentialBinding?: { readonly owner: "provider" | "t3"; readonly key: string };
14 readonly reconnectProfile?: (
15 methodId: string,
16 ) => Effect.Effect<ChatGptReconnectProfile | null, ProviderSetupError>;
17 readonly importProfile?: (
18 profile: ChatGptTransferredProfile,
19 stopSessions: Effect.Effect<void, ProviderSetupError>,
20 ) => Effect.Effect<ProviderAuthState, ProviderSetupError>;
21 readonly adoptCredentials?: (
22 update: Effect.Effect<void, ProviderSetupError>,
23 stopSessions: Effect.Effect<void, ProviderSetupError>,
24 ) => Effect.Effect<ProviderAuthState, ProviderSetupError>;
25 readonly isChangingCredentials?: Effect.Effect<boolean>;
26 readonly invalidate?: Effect.Effect<void>;
27 readonly refreshMethods?: Effect.Effect<void>;
28 readonly withAccess?: <A, E, R>(
29 task: Effect.Effect<A, E, R>,
30 ) => Effect.Effect<A, E | ProviderSetupError, R | Scope.Scope>;
31 readonly start: (
32 ownerSessionId: string,
33 stopSessions?: Effect.Effect<void, ProviderSetupError>,
34 methodId?: string,
35 returnUrl?: string,
36 callbackMode?: "server" | "client",
37 ) => Effect.Effect<ProviderAuthState, ProviderSetupError>;
38 readonly complete: (
39 ownerSessionId: string,
40 input: { readonly flowId: string; readonly callbackUrl: string },
41 ) => Effect.Effect<ProviderAuthState, ProviderSetupError>;
42 readonly cancel: (
43 ownerSessionId: string,
44 flowId: string,
45 ) => Effect.Effect<ProviderAuthState, ProviderSetupError>;
46 readonly respond?: (
47 ownerSessionId: string,
48 input: ProviderAuthRespondInput,
49 ) => Effect.Effect<ProviderAuthState, ProviderSetupError>;
50 readonly logout: (
51 stopSessions: Effect.Effect<void, ProviderSetupError>,
52 ) => Effect.Effect<ProviderAuthState, ProviderSetupError>;
53 readonly subscribe: (ownerSessionId: string) => Stream.Stream<ProviderAuthState>;
54 readonly isLogoutPrompt?: (text: string, hasAttachments: boolean) => boolean;
55}