mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 00:05:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,89 +1,80 @@
|
||||
import * as React from 'react'
|
||||
import { clearTrustedDeviceTokenCache } from '../../bridge/trustedDevice.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { refreshGrowthBookAfterAuthChange } from '../../services/analytics/growthbook.js'
|
||||
import {
|
||||
getGroveNoticeConfig,
|
||||
getGroveSettings,
|
||||
} from '../../services/api/grove.js'
|
||||
import { clearPolicyLimitsCache } from '../../services/policyLimits/index.js'
|
||||
import * as React from 'react';
|
||||
import { clearTrustedDeviceTokenCache } from '../../bridge/trustedDevice.js';
|
||||
import { Text } from '@anthropic/ink';
|
||||
import { refreshGrowthBookAfterAuthChange } from '../../services/analytics/growthbook.js';
|
||||
import { getGroveNoticeConfig, getGroveSettings } from '../../services/api/grove.js';
|
||||
import { clearPolicyLimitsCache } from '../../services/policyLimits/index.js';
|
||||
// flushTelemetry is loaded lazily to avoid pulling in ~1.1MB of OpenTelemetry at startup
|
||||
import { clearRemoteManagedSettingsCache } from '../../services/remoteManagedSettings/index.js'
|
||||
import { getClaudeAIOAuthTokens, removeApiKey } from '../../utils/auth.js'
|
||||
import { clearBetasCaches } from '../../utils/betas.js'
|
||||
import { saveGlobalConfig } from '../../utils/config.js'
|
||||
import { gracefulShutdownSync } from '../../utils/gracefulShutdown.js'
|
||||
import { getSecureStorage } from '../../utils/secureStorage/index.js'
|
||||
import { clearToolSchemaCache } from '../../utils/toolSchemaCache.js'
|
||||
import { resetUserCache } from '../../utils/user.js'
|
||||
import { clearRemoteManagedSettingsCache } from '../../services/remoteManagedSettings/index.js';
|
||||
import { getClaudeAIOAuthTokens, removeApiKey } from '../../utils/auth.js';
|
||||
import { clearBetasCaches } from '../../utils/betas.js';
|
||||
import { saveGlobalConfig } from '../../utils/config.js';
|
||||
import { gracefulShutdownSync } from '../../utils/gracefulShutdown.js';
|
||||
import { getSecureStorage } from '../../utils/secureStorage/index.js';
|
||||
import { clearToolSchemaCache } from '../../utils/toolSchemaCache.js';
|
||||
import { resetUserCache } from '../../utils/user.js';
|
||||
|
||||
export async function performLogout({
|
||||
clearOnboarding = false,
|
||||
}): Promise<void> {
|
||||
export async function performLogout({ clearOnboarding = false }): Promise<void> {
|
||||
// Flush telemetry BEFORE clearing credentials to prevent org data leakage
|
||||
const { flushTelemetry } = await import(
|
||||
'../../utils/telemetry/instrumentation.js'
|
||||
)
|
||||
await flushTelemetry()
|
||||
const { flushTelemetry } = await import('../../utils/telemetry/instrumentation.js');
|
||||
await flushTelemetry();
|
||||
|
||||
await removeApiKey()
|
||||
await removeApiKey();
|
||||
|
||||
// Wipe all secure storage data on logout
|
||||
const secureStorage = getSecureStorage()
|
||||
secureStorage.delete()
|
||||
const secureStorage = getSecureStorage();
|
||||
secureStorage.delete();
|
||||
|
||||
await clearAuthRelatedCaches()
|
||||
await clearAuthRelatedCaches();
|
||||
saveGlobalConfig(current => {
|
||||
const updated = { ...current }
|
||||
const updated = { ...current };
|
||||
if (clearOnboarding) {
|
||||
updated.hasCompletedOnboarding = false
|
||||
updated.subscriptionNoticeCount = 0
|
||||
updated.hasAvailableSubscription = false
|
||||
updated.hasCompletedOnboarding = false;
|
||||
updated.subscriptionNoticeCount = 0;
|
||||
updated.hasAvailableSubscription = false;
|
||||
if (updated.customApiKeyResponses?.approved) {
|
||||
updated.customApiKeyResponses = {
|
||||
...updated.customApiKeyResponses,
|
||||
approved: [],
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
updated.oauthAccount = undefined
|
||||
return updated
|
||||
})
|
||||
updated.oauthAccount = undefined;
|
||||
return updated;
|
||||
});
|
||||
}
|
||||
|
||||
// clearing anything memoized that must be invalidated when user/session/auth changes
|
||||
export async function clearAuthRelatedCaches(): Promise<void> {
|
||||
// Clear the OAuth token cache
|
||||
getClaudeAIOAuthTokens.cache?.clear?.()
|
||||
clearTrustedDeviceTokenCache()
|
||||
clearBetasCaches()
|
||||
clearToolSchemaCache()
|
||||
getClaudeAIOAuthTokens.cache?.clear?.();
|
||||
clearTrustedDeviceTokenCache();
|
||||
clearBetasCaches();
|
||||
clearToolSchemaCache();
|
||||
|
||||
// Clear user data cache BEFORE GrowthBook refresh so it picks up fresh credentials
|
||||
resetUserCache()
|
||||
refreshGrowthBookAfterAuthChange()
|
||||
resetUserCache();
|
||||
refreshGrowthBookAfterAuthChange();
|
||||
|
||||
// Clear Grove config cache
|
||||
getGroveNoticeConfig.cache?.clear?.()
|
||||
getGroveSettings.cache?.clear?.()
|
||||
getGroveNoticeConfig.cache?.clear?.();
|
||||
getGroveSettings.cache?.clear?.();
|
||||
|
||||
// Clear remotely managed settings cache
|
||||
await clearRemoteManagedSettingsCache()
|
||||
await clearRemoteManagedSettingsCache();
|
||||
|
||||
// Clear policy limits cache
|
||||
await clearPolicyLimitsCache()
|
||||
await clearPolicyLimitsCache();
|
||||
}
|
||||
|
||||
export async function call(): Promise<React.ReactNode> {
|
||||
await performLogout({ clearOnboarding: true })
|
||||
await performLogout({ clearOnboarding: true });
|
||||
|
||||
const message = (
|
||||
<Text>Successfully logged out from your Anthropic account.</Text>
|
||||
)
|
||||
const message = <Text>Successfully logged out from your Anthropic account.</Text>;
|
||||
|
||||
setTimeout(() => {
|
||||
gracefulShutdownSync(0, 'logout')
|
||||
}, 200)
|
||||
gracefulShutdownSync(0, 'logout');
|
||||
}, 200);
|
||||
|
||||
return message
|
||||
return message;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user