feat(assist-platform): 固化钉钉扫码登录闭环并优化多集群与网关错误解析

- 支持一行命令自动发起钉钉交互式扫码登录 (hose-use assist-platform login [--qr])
  - 集成 qrcode-terminal 在终端直接输出紧凑 ANSI 文本二维码
  - 严格对齐 HoseCloud SSO 钉钉时间戳的 60 秒安全防重放倒计时
  - 自动从重定向参数或 Token 换取 Unity 运营中心会话凭证并安全落盘
- 在 core/http/assist-platform-client 增加响应体 errorCode: 403 拦截,杜绝凭证过期被吞成空数据的静默失败
- 修复 assist-platform enter 多集群租户 (wx2/shanghai 等) baseUrl 硬编码为 app 的验票失败问题
- 修复 workflow nodes grant 网关回包双层嵌套 saved/skipped 数据解析问题
- 补全 core/http/sso-client 单元测试并确保全部 957 项测试通过
This commit is contained in:
gitea committed 2026-11-02 14:58:20 +08:00
1 parent eb9b979943
commit 95af2177e5
10 files changed
+555 -29

No files matched your search

+20
View File
@@ -14,6 +14,7 @@ import {
getOpenApiHeaders,
} from "./openapi-client.js";
import { resolveCorpCluster, getEasoClient, getUnityClient, clearUnityClientCache } from "./unity-client.js";
import { createAssistPlatformClient } from "./assist-platform-client.js";
import { getScriptEngineClient } from "./script-engine-client.js";
import { setCorpTokens, resetTokenStoreMemory } from "../auth/token-store.js";
import { mkdtempSync, rmSync } from "node:fs";
@@ -150,4 +151,23 @@ describe("core/http/unity-client & script-engine-client", () => {
rmSync(tempDir, { recursive: true, force: true });
}
});
it("createAssistPlatformClient throws AuthenticationError when response body contains errorCode: 403", async () => {
const client = createAssistPlatformClient({
token: "fake-token",
baseUrl: "https://mock-unity.invalid",
});
const mockFetch = async () =>
new Response(JSON.stringify({ errorCode: 403, errorMessage: "token过期请重新登录!" }), {
status: 200,
headers: { "content-type": "application/json" },
});
const testClient = client.extend({ fetch: mockFetch as any });
expect(async () => {
await testClient.get("test").json();
}).toThrow("协助平台凭证已过期或无效,请运行: hose-use assist-platform login 重新扫码登录");
});
});