mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
refactor(open-sse): merge beta-url case + single-source refresh URLs (D)
buildUrl: fold kimi-coding into the shared ?beta=true case. refreshCline/ refreshKimiCoding now read URL (and kimi-coding clientId) from PROVIDERS instead of hardcoded strings. Extend verify-oauth-urls with refresh/clientId snapshot; URLs byte-for-byte equal, golden + gate clean. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -61,7 +61,6 @@ export class DefaultExecutor extends BaseExecutor {
|
|||||||
case "kimi":
|
case "kimi":
|
||||||
case "minimax":
|
case "minimax":
|
||||||
case "minimax-cn":
|
case "minimax-cn":
|
||||||
return `${this.config.baseUrl}?beta=true`;
|
|
||||||
case "kimi-coding":
|
case "kimi-coding":
|
||||||
return `${this.config.baseUrl}?beta=true`;
|
return `${this.config.baseUrl}?beta=true`;
|
||||||
case "gemini":
|
case "gemini":
|
||||||
@@ -282,7 +281,7 @@ export class DefaultExecutor extends BaseExecutor {
|
|||||||
|
|
||||||
async refreshCline(refreshToken, proxyOptions = null) {
|
async refreshCline(refreshToken, proxyOptions = null) {
|
||||||
console.log('[DEBUG] Refreshing Cline token, refreshToken length:', refreshToken?.length);
|
console.log('[DEBUG] Refreshing Cline token, refreshToken length:', refreshToken?.length);
|
||||||
const response = await proxyAwareFetch("https://api.cline.bot/api/v1/auth/refresh", {
|
const response = await proxyAwareFetch(PROVIDERS.cline.refreshUrl, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json", "Accept": "application/json" },
|
headers: { "Content-Type": "application/json", "Accept": "application/json" },
|
||||||
body: JSON.stringify({ refreshToken, grantType: "refresh_token", clientType: "extension" })
|
body: JSON.stringify({ refreshToken, grantType: "refresh_token", clientType: "extension" })
|
||||||
@@ -304,14 +303,14 @@ export class DefaultExecutor extends BaseExecutor {
|
|||||||
|
|
||||||
async refreshKimiCoding(refreshToken, proxyOptions = null) {
|
async refreshKimiCoding(refreshToken, proxyOptions = null) {
|
||||||
const kimiHeaders = buildKimiHeaders();
|
const kimiHeaders = buildKimiHeaders();
|
||||||
const response = await proxyAwareFetch("https://auth.kimi.com/api/oauth/token", {
|
const response = await proxyAwareFetch(PROVIDERS["kimi-coding"].refreshUrl, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
...kimiHeaders
|
...kimiHeaders
|
||||||
},
|
},
|
||||||
body: new URLSearchParams({ grant_type: "refresh_token", refresh_token: refreshToken, client_id: "17e5f671-d194-4dfb-9706-5516cb48c098" })
|
body: new URLSearchParams({ grant_type: "refresh_token", refresh_token: refreshToken, client_id: PROVIDERS["kimi-coding"].clientId })
|
||||||
}, proxyOptions);
|
}, proxyOptions);
|
||||||
if (!response.ok) return null;
|
if (!response.ok) return null;
|
||||||
const tokens = await response.json();
|
const tokens = await response.json();
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -40,5 +40,17 @@
|
|||||||
"qwen": "https://chat.qwen.ai/api/v1/oauth2/device/code",
|
"qwen": "https://chat.qwen.ai/api/v1/oauth2/device/code",
|
||||||
"iflow": "https://iflow.cn/oauth",
|
"iflow": "https://iflow.cn/oauth",
|
||||||
"kiro": "https://prod.us-east-1.auth.desktop.kiro.dev"
|
"kiro": "https://prod.us-east-1.auth.desktop.kiro.dev"
|
||||||
|
},
|
||||||
|
"refreshUrls": {
|
||||||
|
"cline": "https://api.cline.bot/api/v1/auth/refresh",
|
||||||
|
"kimi-coding": "https://auth.kimi.com/api/oauth/token",
|
||||||
|
"xai": "https://auth.x.ai/oauth2/token"
|
||||||
|
},
|
||||||
|
"clientIds": {
|
||||||
|
"claude": "9d1c250a-e61b-44d9-88ed-5944d1962f5e",
|
||||||
|
"codex": "app_EMoamEEZ73f0CkXaXp7hrann",
|
||||||
|
"qwen": "f0304373b74a44d2b584a3fb70ca9e56",
|
||||||
|
"iflow": "10009311001",
|
||||||
|
"kimi-coding": "17e5f671-d194-4dfb-9706-5516cb48c098"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,18 @@ const resolved = {
|
|||||||
iflow: PROVIDERS.iflow?.authUrl,
|
iflow: PROVIDERS.iflow?.authUrl,
|
||||||
kiro: PROVIDERS.kiro?.authUrl,
|
kiro: PROVIDERS.kiro?.authUrl,
|
||||||
},
|
},
|
||||||
|
refreshUrls: {
|
||||||
|
cline: PROVIDERS.cline?.refreshUrl,
|
||||||
|
"kimi-coding": PROVIDERS["kimi-coding"]?.refreshUrl,
|
||||||
|
xai: PROVIDERS.xai?.refreshUrl,
|
||||||
|
},
|
||||||
|
clientIds: {
|
||||||
|
claude: PROVIDERS.claude?.clientId,
|
||||||
|
codex: PROVIDERS.codex?.clientId,
|
||||||
|
qwen: PROVIDERS.qwen?.clientId,
|
||||||
|
iflow: PROVIDERS.iflow?.clientId,
|
||||||
|
"kimi-coding": PROVIDERS["kimi-coding"]?.clientId,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const current = JSON.parse(JSON.stringify(resolved));
|
const current = JSON.parse(JSON.stringify(resolved));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user