fix(github-copilot): format legacy oauth credentials

This commit is contained in:
joshavant
2026-07-27 16:58:09 -05:00
committed by Josh Avant
parent 7c980eaec0
commit 3da4ef3a6c
2 changed files with 15 additions and 0 deletions

View File

@@ -174,6 +174,20 @@ function registerProviderWithPluginConfig(pluginConfig: Record<string, unknown>)
}
describe("github-copilot plugin", () => {
it("formats legacy OAuth profiles with the durable GitHub credential", () => {
const provider = registerProviderWithPluginConfig({});
expect(
provider.formatApiKey?.({
type: "oauth",
provider: "github-copilot",
access: "short-lived-copilot-token",
refresh: " durable-github-token ",
expires: Date.now() + 60_000,
}),
).toBe("durable-github-token");
});
it("preserves the source token supplied by the auth layer for runtime auth", async () => {
mocks.resolveCopilotRuntimeAuth.mockResolvedValueOnce({
apiKey: "github-source-token",

View File

@@ -600,6 +600,7 @@ export default definePluginEntry({
prepareDynamicModel: dynamicModels.prepareDynamicModel,
resolveDynamicModel: dynamicModels.resolveDynamicModel,
preferRuntimeResolvedModel: dynamicModels.preferRuntimeResolvedModel,
formatApiKey: (credential) => (credential.type === "oauth" ? credential.refresh.trim() : ""),
wrapStreamFn: wrapCopilotProviderStream,
buildReplayPolicy: ({ modelId }) => buildGithubCopilotReplayPolicy(modelId),
sanitizeReplayHistory: sanitizeGithubCopilotReplayHistory,