/** * Types for built-in auth providers */ import type { createOpencodeClient } from "@groeimetai/snow-code-sdk" export type AuthClient = ReturnType export type AuthInfo = { type: string access?: string refresh?: string expires?: number } export type ProviderInfo = { id: string models: Record } export type AuthResult = | { type: "success"; refresh: string; access: string; expires: number } | { type: "success"; key: string } | { type: "failed" } export type AuthMethod = | { type: "oauth" label: string authorize(): Promise< { url: string; instructions: string } & ( | { method: "auto" callback(): Promise } | { method: "code" callback(code: string): Promise } ) > } | { type: "api"; label: string; provider?: string } export interface BuiltInAuthProvider { provider: string loader?: ( getAuth: () => Promise, provider: ProviderInfo, client: AuthClient, ) => Promise> methods: AuthMethod[] }