feat: 支持协助链接秒级导入 (corps add-link) 与多集群 (wx2等) 动态鉴权换票

This commit is contained in:
gitea committed 2026-09-07 14:44:37 +08:00
1 parent f2b0f15a6e
commit 2bf8d22810
13 files changed
+1268 -408

No files matched your search

+13 -6
View File
@@ -2,6 +2,7 @@ import ky from "ky";
import { CorpConfig } from "../../core/config/types.js";
import { createAuthClient } from "../../core/http/factory.js";
import { AuthenticationError } from "../../core/errors.js";
import { resolveCorpCluster } from "./easo.js";
const PIPER_BASE_URL = "https://piper.ekuaibao.com";
const BUSINESS_CENTER_URL = "https://business-center.ekuaibao.com";
@@ -19,14 +20,15 @@ function isExpired(entry: { expiresAt: number }, refreshTtl: number): boolean {
async function fetchHoseToken(
accessToken: string,
corpId: string
corpId: string,
environment: string = "app"
): Promise<string> {
const response = await ky
.get(`${BUSINESS_CENTER_URL}/auth/oauth2/grant/ekb/accessToken`, {
searchParams: {
corpId,
ekbAccessToken: accessToken,
environment: "app",
environment,
},
})
.json<{ data: string }>();
@@ -39,10 +41,11 @@ async function fetchHoseToken(
async function fetchEasoJwt(
accessToken: string,
corpId: string,
staffId: string
staffId: string,
baseUrl: string = EKB_BASE_URL
): Promise<string> {
const response = await ky
.get(`${EKB_BASE_URL}/api/engine/realm/$EASO/actions/jwt`, {
.get(`${baseUrl}/api/engine/realm/$EASO/actions/jwt`, {
searchParams: { corpId },
headers: {
accesstoken: accessToken,
@@ -82,16 +85,20 @@ export async function getPiperClient(
const corpId = corp.corpId || corp.credentials.corpId;
const staffId = corp.staffId || corp.credentials.staffId;
const environment = resolveCorpCluster(corp);
const baseUrl = corp.baseUrl || EKB_BASE_URL;
// 重新换取
const hoseToken = await fetchHoseToken(
corp.credentials.accessToken,
corpId
corpId,
environment
);
const easoJwt = await fetchEasoJwt(
corp.credentials.accessToken,
corpId,
staffId
staffId,
baseUrl
);
const entry = {