refactor(auth): share profile id dedupe helper

This commit is contained in:
Peter Steinberger
2026-02-16 22:51:42 +00:00
parent ff7a735115
commit 230e1d9962
5 changed files with 12 additions and 29 deletions

View File

@@ -3,6 +3,7 @@ import os from "node:os";
import path from "node:path";
import type { UsageProviderId } from "./provider-usage.types.js";
import {
dedupeProfileIds,
ensureAuthProfileStore,
listProfilesForProvider,
resolveApiKeyForProfile,
@@ -144,14 +145,7 @@ async function resolveOAuthToken(params: {
store,
provider: params.provider,
});
const candidates = order;
const deduped: string[] = [];
for (const entry of candidates) {
if (!deduped.includes(entry)) {
deduped.push(entry);
}
}
const deduped = dedupeProfileIds(order);
for (const profileId of deduped) {
const cred = store.profiles[profileId];