feat(auth): support OpenAPI persistent credentials, auto-refresh, and Web login link generation (v0.8.10)

This commit is contained in:
gitea committed 2026-09-28 16:50:18 +08:00
1 parent 1d825269f4
commit 96c5a3f242
27 files changed
+2994 -583

No files matched your search

+13 -2
View File
@@ -1,3 +1,4 @@
import { canRefreshCorpAccessToken, hasOpenApiPersistentCredentials } from "../../core/auth/login.js";
import { createSessionClient, getEasoClient } from "../../core/http/index.js";
import * as api from "../../domains/platform/api.js";
import { printJson, printKeyValue, formatSourceLabel, formatExpiresAt } from "../printer.js";
@@ -16,6 +17,9 @@ export async function handleProbeCommand(
};
}
const hasOpenApi = hasOpenApiPersistentCredentials(currentCorp);
const isPersistent = canRefreshCorpAccessToken(currentCorp);
const results: Record<string, unknown> = {
enterprise: {
id: currentCorp.id,
@@ -24,6 +28,8 @@ export async function handleProbeCommand(
baseUrl: currentCorp.baseUrl,
source: currentCorp.source,
accountId: currentCorp.accountId,
persistent: isPersistent,
hasOpenApiKey: hasOpenApi,
},
ekbSession: { status: "pending" },
easoToken: { status: "pending" },
@@ -98,8 +104,13 @@ export async function handleProbeCommand(
"企业 ID": currentCorp.id,
"员工工号": currentCorp.credentials.staffId,
"员工姓名": currentCorp.staffName || currentCorp.session?.staffName || "-",
"凭证来源": formatSourceLabel(currentCorp.source),
"Token 过期时间": formatExpiresAt(currentCorp.auth?.expiresAt || currentCorp.session?.expTime),
"凭证来源": formatSourceLabel(currentCorp.source, hasOpenApi),
"持久化状态": isPersistent
? hasOpenApi
? `✅ OpenAPI 持久化密钥 (${currentCorp.credentials.appKey})`
: "✅ 统一认证主账号自动换票"
: "⚪ 短期会话",
"Token 过期时间": formatExpiresAt(currentCorp.auth?.expiresAt || currentCorp.session?.expTime, isPersistent),
"主站 Session 连通": (results.ekbSession as any).status === "ok" ? "🟢 正常" : "🔴 异常",
"EASO 引擎鉴权换票": (results.easoToken as any).status === "ok" ? "🟢 握手成功" : "🔴 失败",
"自建应用扫描": (results.platformAccess as any).status === "ok" ? `🟢 可访问 (${(results.platformAccess as any).totalPlatforms} 个自建应用)` : "🔴 失败",