mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
25 lines
673 B
TypeScript
25 lines
673 B
TypeScript
import type { IntegrationMethod } from "@opencode/client/promise"
|
|
|
|
type ProviderAuthMethod = Extract<IntegrationMethod, { type: "key" | "oauth" }>
|
|
|
|
const data = {
|
|
provider: {
|
|
all: new Map(),
|
|
connected: [],
|
|
default: {},
|
|
},
|
|
provider_auth: {} as Record<string, ProviderAuthMethod[]>,
|
|
config: { disabled_providers: [] as string[] },
|
|
}
|
|
|
|
export function mockProviderAuth(provider: string, methods: ProviderAuthMethod[]) {
|
|
const previous = data.provider_auth[provider]
|
|
data.provider_auth[provider] = methods
|
|
return () => {
|
|
if (previous) {
|
|
data.provider_auth[provider] = previous
|
|
return
|
|
}
|
|
delete data.provider_auth[provider]
|
|
}
|
|
}
|