






















@@ -262,28 +262,46 @@ export function buildAuthHealthSummary(params: {
262262continue;
263263}
264264265-const oauthProfiles = provider.profiles.filter((p) => p.type === "oauth");
266-const tokenProfiles = provider.profiles.filter((p) => p.type === "token");
267-const apiKeyProfiles = provider.profiles.filter((p) => p.type === "api_key");
265+let hasApiKeyProfile = false;
266+let hasExpirableProfile = false;
267+let hasExpiredOrMissing = false;
268+let hasExpiring = false;
269+let earliestExpiry: number | undefined;
270+for (const profile of provider.profiles) {
271+if (profile.type === "api_key") {
272+hasApiKeyProfile = true;
273+continue;
274+}
275+if (profile.type !== "oauth" && profile.type !== "token") {
276+continue;
277+}
278+hasExpirableProfile = true;
279+if (typeof profile.expiresAt === "number" && Number.isFinite(profile.expiresAt)) {
280+earliestExpiry =
281+earliestExpiry === undefined
282+ ? profile.expiresAt
283+ : Math.min(earliestExpiry, profile.expiresAt);
284+}
285+if (profile.status === "expired" || profile.status === "missing") {
286+hasExpiredOrMissing = true;
287+} else if (profile.status === "expiring") {
288+hasExpiring = true;
289+}
290+}
268291269-const expirable = [...oauthProfiles, ...tokenProfiles];
270-if (expirable.length === 0) {
271-provider.status = apiKeyProfiles.length > 0 ? "static" : "missing";
292+if (!hasExpirableProfile) {
293+provider.status = hasApiKeyProfile ? "static" : "missing";
272294continue;
273295}
274296275-const expiryCandidates = expirable
276-.map((p) => p.expiresAt)
277-.filter((v): v is number => typeof v === "number" && Number.isFinite(v));
278-if (expiryCandidates.length > 0) {
279-provider.expiresAt = Math.min(...expiryCandidates);
297+if (earliestExpiry !== undefined) {
298+provider.expiresAt = earliestExpiry;
280299provider.remainingMs = provider.expiresAt - now;
281300}
282301283-const statuses = new Set(expirable.map((p) => p.status));
284-if (statuses.has("expired") || statuses.has("missing")) {
302+if (hasExpiredOrMissing) {
285303provider.status = "expired";
286-} else if (statuses.has("expiring")) {
304+} else if (hasExpiring) {
287305provider.status = "expiring";
288306} else {
289307provider.status = "ok";
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。