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

+18
View File
@@ -2,6 +2,10 @@ import ky from "ky";
import type { CorpConfig } from "../config/types.js";
import { createAuthClient } from "./factory.js";
import { AuthenticationError } from "../errors.js";
import {
canRefreshCorpAccessToken,
refreshSingleCorpAccessToken,
} from "../auth/login.js";
export const EASO_BASE_URL = "https://unity.ekuaibao.com";
export const BUSINESS_CENTER_URL = "https://business-center.ekuaibao.com";
@@ -133,6 +137,13 @@ export async function getEasoClient(corp: CorpConfig): Promise<{
};
}
if (canRefreshCorpAccessToken(corp)) {
const expiresAt = corp.auth?.expiresAt || corp.session?.expTime;
if (!corp.credentials.accessToken || (expiresAt && Date.now() >= expiresAt - refreshTtl * 1000)) {
await refreshSingleCorpAccessToken(corp);
}
}
const corpId = corp.corpId || corp.credentials.corpId;
const staffId = corp.staffId || corp.credentials.staffId;
const environment = resolveCorpCluster(corp);
@@ -207,6 +218,13 @@ export async function getUnityClient(corp: CorpConfig): Promise<{
};
}
if (canRefreshCorpAccessToken(corp)) {
const expiresAt = corp.auth?.expiresAt || corp.session?.expTime;
if (!corp.credentials.accessToken || (expiresAt && Date.now() >= expiresAt - refreshTtl * 1000)) {
await refreshSingleCorpAccessToken(corp);
}
}
const corpId = corp.corpId || corp.credentials.corpId;
const staffId = corp.staffId || corp.credentials.staffId;
const baseUrl = corp.baseUrl || EKB_BASE_URL;