Add Providers

This commit is contained in:
decolua 2026-02-20 17:05:46 +07:00
parent bd71298fb7
commit 3debf84b9a
30 changed files with 1583 additions and 670 deletions

View file

@ -36,13 +36,13 @@ export async function GET(request, { params }) {
const authData = generateAuthData(provider, null);
// For providers that don't use PKCE (like GitHub), don't pass codeChallenge
// Providers that don't use PKCE for device code
const noPkceDeviceProviders = ["github", "kiro", "kimi-coding", "kilocode"];
let deviceData;
if (provider === "github" || provider === "kiro") {
// GitHub and Kiro don't use PKCE for device code
if (noPkceDeviceProviders.includes(provider)) {
deviceData = await requestDeviceCode(provider);
} else {
// Qwen and other providers use PKCE
// Qwen and other PKCE providers
deviceData = await requestDeviceCode(provider, authData.codeChallenge);
}
@ -69,7 +69,9 @@ export async function POST(request, { params }) {
if (action === "exchange") {
const { code, redirectUri, codeVerifier, state } = body;
if (!code || !redirectUri || !codeVerifier) {
// Cline uses authorization_code without PKCE
const noPkceExchangeProviders = ["cline"];
if (!code || !redirectUri || (!codeVerifier && !noPkceExchangeProviders.includes(provider))) {
return NextResponse.json({ error: "Missing required fields" }, { status: 400 });
}
@ -108,15 +110,16 @@ export async function POST(request, { params }) {
return NextResponse.json({ error: "Missing device code" }, { status: 400 });
}
// For providers that don't use PKCE (like GitHub, Kiro), don't pass codeVerifier
// Providers that don't use PKCE for device code
const noPkceProviders = ["github", "kimi-coding", "kilocode"];
let result;
if (provider === "github") {
if (noPkceProviders.includes(provider)) {
result = await pollForToken(provider, deviceCode);
} else if (provider === "kiro") {
// Kiro needs extraData (clientId, clientSecret) from device code response
result = await pollForToken(provider, deviceCode, null, extraData);
} else {
// Qwen and other providers use PKCE
// Qwen and other PKCE providers
if (!codeVerifier) {
return NextResponse.json({ error: "Missing code verifier" }, { status: 400 });
}