mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
OAUTH_ENDPOINTS.{openai,anthropic,iflow}.token now reference PROVIDERS.*.tokenUrl
(values identical) so each backend token URL is declared once. qwen left as-is
(its appConstants/PROVIDERS values intentionally differ). Add verify-oauth-urls
script; URLs byte-for-byte equal, gate clean.
Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
// Verify OAuth/token URLs resolve byte-for-byte vs snapshot (backend open-sse).
|
|
// Captures every URL executors/tokenRefresh actually use, to guard DRY dedup.
|
|
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, join } from "node:path";
|
|
import { OAUTH_ENDPOINTS } from "../../open-sse/config/appConstants.js";
|
|
import { PROVIDERS } from "../../open-sse/config/providers.js";
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const snapPath = join(here, "oauth-urls-baseline.json");
|
|
|
|
// Collect resolved URLs that backend code depends on
|
|
const resolved = {
|
|
oauthEndpoints: OAUTH_ENDPOINTS,
|
|
tokenUrls: {
|
|
claude: PROVIDERS.claude?.tokenUrl,
|
|
codex: PROVIDERS.codex?.tokenUrl,
|
|
qwen: PROVIDERS.qwen?.tokenUrl,
|
|
iflow: PROVIDERS.iflow?.tokenUrl,
|
|
kiro: PROVIDERS.kiro?.tokenUrl,
|
|
xai: PROVIDERS.xai?.tokenUrl,
|
|
cline: PROVIDERS.cline?.tokenUrl,
|
|
"kimi-coding": PROVIDERS["kimi-coding"]?.tokenUrl,
|
|
},
|
|
authUrls: {
|
|
qwen: PROVIDERS.qwen?.authUrl,
|
|
iflow: PROVIDERS.iflow?.authUrl,
|
|
kiro: PROVIDERS.kiro?.authUrl,
|
|
},
|
|
};
|
|
const current = JSON.parse(JSON.stringify(resolved));
|
|
|
|
const mode = process.argv[2];
|
|
if (mode === "--snapshot") {
|
|
writeFileSync(snapPath, JSON.stringify(current, null, 2));
|
|
console.log(`Snapshot OAuth URLs → ${snapPath}`);
|
|
process.exit(0);
|
|
}
|
|
|
|
if (!existsSync(snapPath)) {
|
|
console.error("No baseline. Run with --snapshot on OLD code first.");
|
|
process.exit(1);
|
|
}
|
|
const baseline = JSON.parse(readFileSync(snapPath, "utf8"));
|
|
const a = JSON.stringify(baseline);
|
|
const b = JSON.stringify(current);
|
|
if (a === b) {
|
|
console.log("✅ OAuth URLs byte-for-byte equal.");
|
|
process.exit(0);
|
|
}
|
|
console.error("❌ OAuth URL mismatch:");
|
|
console.error("baseline:", a);
|
|
console.error("current :", b);
|
|
process.exit(1);
|