mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-23 14:45:46 +00:00
Provider usage: narrow auth store before profile lookup
This commit is contained in:
@@ -9,7 +9,7 @@ const ensureAuthProfileStoreMock = vi.fn(() => ({
|
||||
|
||||
vi.mock("../agents/auth-profiles.js", () => ({
|
||||
dedupeProfileIds: (profileIds: string[]) => [...new Set(profileIds)],
|
||||
ensureAuthProfileStore: (...args: unknown[]) => ensureAuthProfileStoreMock(...args),
|
||||
ensureAuthProfileStore: () => ensureAuthProfileStoreMock(),
|
||||
listProfilesForProvider: () => [],
|
||||
resolveApiKeyForProfile: async () => null,
|
||||
resolveAuthProfileOrder: () => [],
|
||||
|
||||
@@ -92,15 +92,16 @@ async function resolveOAuthToken(params: {
|
||||
state: UsageAuthState;
|
||||
provider: string;
|
||||
}): Promise<ProviderAuth | null> {
|
||||
const store = resolveUsageAuthStore(params.state);
|
||||
const order = resolveAuthProfileOrder({
|
||||
cfg: params.state.cfg,
|
||||
store: resolveUsageAuthStore(params.state),
|
||||
store,
|
||||
provider: params.provider,
|
||||
});
|
||||
const deduped = dedupeProfileIds(order);
|
||||
|
||||
for (const profileId of deduped) {
|
||||
const cred = params.state.store.profiles[profileId];
|
||||
const cred = store.profiles[profileId];
|
||||
if (!cred || (cred.type !== "oauth" && cred.type !== "token")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user