





















@@ -7,12 +7,16 @@ import { loadJsonFile, saveJsonFile } from "../../infra/json-file.js";
77import { cloneAuthProfileStore } from "./clone.js";
88import { AUTH_STORE_LOCK_OPTIONS, AUTH_STORE_VERSION, log } from "./constants.js";
99import {
10+listRuntimeExternalAuthProfiles,
1011overlayExternalAuthProfiles,
11-shouldPersistExternalAuthProfile,
1212syncPersistedExternalCliAuthProfiles,
1313} from "./external-auth.js";
1414import type { ExternalCliAuthDiscovery } from "./external-cli-discovery.js";
15-import { isSafeToAdoptMainStoreOAuthIdentity } from "./oauth-shared.js";
15+import {
16+isSafeToAdoptMainStoreOAuthIdentity,
17+shouldPersistRuntimeExternalOAuthProfile,
18+type RuntimeExternalOAuthProfile,
19+} from "./oauth-shared.js";
1620import {
1721ensureAuthStoreFile,
1822resolveAuthStatePath,
@@ -364,6 +368,7 @@ function shouldKeepProfileInLocalStore(params: {
364368credential: AuthProfileStore["profiles"][string];
365369agentDir?: string;
366370options?: SaveAuthProfileStoreOptions;
371+externalProfiles: () => RuntimeExternalOAuthProfile[];
367372}): boolean {
368373if (params.credential.type !== "oauth") {
369374return true;
@@ -380,11 +385,10 @@ function shouldKeepProfileInLocalStore(params: {
380385if (params.options?.filterExternalAuthProfiles === false) {
381386return true;
382387}
383-return shouldPersistExternalAuthProfile({
384-store: params.store,
388+return shouldPersistRuntimeExternalOAuthProfile({
385389profileId: params.profileId,
386390credential: params.credential,
387-agentDir: params.agentDir,
391+profiles: params.externalProfiles(),
388392});
389393}
390394@@ -394,6 +398,12 @@ function buildLocalAuthProfileStoreForSave(params: {
394398options?: SaveAuthProfileStoreOptions;
395399}): AuthProfileStore {
396400const localStore = cloneAuthProfileStore(params.store);
401+let externalProfiles: RuntimeExternalOAuthProfile[] | undefined;
402+const getExternalProfiles = (): RuntimeExternalOAuthProfile[] =>
403+(externalProfiles ??= listRuntimeExternalAuthProfiles({
404+store: params.store,
405+agentDir: params.agentDir,
406+}));
397407localStore.profiles = Object.fromEntries(
398408Object.entries(localStore.profiles).filter(([profileId, credential]) =>
399409shouldKeepProfileInLocalStore({
@@ -402,6 +412,7 @@ function buildLocalAuthProfileStoreForSave(params: {
402412 credential,
403413agentDir: params.agentDir,
404414options: params.options,
415+externalProfiles: getExternalProfiles,
405416}),
406417),
407418);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。