mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
refactor(qoder): mirror Kiro's OAuth service layout
Move device-flow / poll / userinfo / parseExpiry from src/lib/qoder/auth.js
into a QoderService class at src/lib/oauth/services/qoder.js, matching how
KiroService is organized. Also re-add the QoderService re-export from
services/index.js.
The split now mirrors Kiro:
src/lib/oauth/services/qoder.js OAuth flow (was auth.js)
src/lib/qoder/cosy.js Per-request signing (unchanged)
src/lib/qoder/encoding.js WAF-bypass body (unchanged)
src/lib/qoder/constants.js Endpoints + model map (unchanged)
Behavior is unchanged — same functions, same signatures, just relocated
into a class so the import path lines up with `import { QoderService } from
"@/lib/oauth/services"` like every other OAuth provider. parseExpiry is now
a static method so callers and tests can use it without instantiating.
42 tests still pass; build still clean.
This commit is contained in:
@@ -14,10 +14,17 @@ import crypto from "crypto";
|
||||
|
||||
import { qoderEncodeBody } from "../../src/lib/qoder/encoding.js";
|
||||
import { buildCosyHeaders } from "../../src/lib/qoder/cosy.js";
|
||||
import { initiateDeviceFlow, generatePkcePair, parseExpiry } from "../../src/lib/qoder/auth.js";
|
||||
import { QoderService } from "../../src/lib/oauth/services/qoder.js";
|
||||
import { QODER_CHAT_URL_ENCODED, QODER_MODEL_LIST_URL } from "../../src/lib/qoder/constants.js";
|
||||
import { __test__ as qoderExecutorInternals } from "../../open-sse/executors/qoder.js";
|
||||
|
||||
// Convenience aliases — tests were originally written against module-level
|
||||
// helpers; the QoderService class wraps them so each test creates its own
|
||||
// instance to avoid hidden state.
|
||||
const generatePkcePair = () => new QoderService().generatePkcePair();
|
||||
const initiateDeviceFlow = () => new QoderService().initiateDeviceFlow();
|
||||
const parseExpiry = QoderService.parseExpiry;
|
||||
|
||||
describe("qoderEncodeBody", () => {
|
||||
it("preserves base64 length (input length divisible by 3)", () => {
|
||||
const input = Buffer.from("abcdef", "utf8"); // 6 bytes → 8 base64 chars
|
||||
|
||||
Reference in New Issue
Block a user