fix
This commit is contained in:
@@ -113,7 +113,7 @@ export function getAppConfig(): AppConfig {
|
||||
const aiEnabled = import.meta.env.VITE_AI_ENABLED === 'true';
|
||||
const aiAskAi = import.meta.env.VITE_AI_ASK_AI === 'true';
|
||||
const aiProvider = import.meta.env.VITE_AI_PROVIDER || 'ollama';
|
||||
const aiModel = import.meta.env.VITE_AI_MODEL || 'qwen2.5-coder:latest';
|
||||
const aiModel = import.meta.env.VITE_AI_MODEL || 'gemma3:4b';
|
||||
const aiHost = import.meta.env.VITE_AI_HOST || 'https://ollama.syui.ai';
|
||||
const aiSystemPrompt = import.meta.env.VITE_AI_SYSTEM_PROMPT || 'You are a helpful AI assistant trained on this blog\'s content.';
|
||||
const atprotoPds = import.meta.env.VITE_ATPROTO_PDS || 'syu.is';
|
||||
|
@@ -41,7 +41,6 @@ class AtprotoOAuthService {
|
||||
this.oauthClient = await BrowserOAuthClient.load({
|
||||
clientId: clientId,
|
||||
handleResolver: 'https://bsky.social', // Default resolver
|
||||
plcDirectoryUrl: 'https://plc.directory', // Default PLC directory
|
||||
});
|
||||
|
||||
|
||||
@@ -177,46 +176,21 @@ class AtprotoOAuthService {
|
||||
return `${origin}/client-metadata.json`;
|
||||
}
|
||||
|
||||
private async detectPDSFromHandle(handle: string): Promise<string> {
|
||||
// Handle detection for OAuth PDS routing
|
||||
|
||||
// Check if handle ends with known PDS domains first
|
||||
private detectPDSFromHandle(handle: string): string {
|
||||
// Supported PDS hosts and their corresponding handles
|
||||
const pdsMapping = {
|
||||
'syu.is': 'https://syu.is',
|
||||
'bsky.social': 'https://bsky.social',
|
||||
};
|
||||
|
||||
// Check if handle ends with known PDS domains
|
||||
for (const [domain, pdsUrl] of Object.entries(pdsMapping)) {
|
||||
if (handle.endsWith(`.${domain}`)) {
|
||||
// Using PDS for domain match
|
||||
return pdsUrl;
|
||||
}
|
||||
}
|
||||
|
||||
// For handles that don't match domain patterns, resolve via API
|
||||
try {
|
||||
// Try to resolve handle to get the actual PDS
|
||||
const endpoints = ['https://syu.is', 'https://bsky.social'];
|
||||
|
||||
for (const endpoint of endpoints) {
|
||||
try {
|
||||
const response = await fetch(`${endpoint}/xrpc/com.atproto.identity.resolveHandle?handle=${encodeURIComponent(handle)}`);
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
if (data.did) {
|
||||
return endpoint;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle resolution failed, using default
|
||||
}
|
||||
|
||||
// Default to bsky.social
|
||||
// Using default bsky.social
|
||||
return 'https://bsky.social';
|
||||
}
|
||||
|
||||
@@ -241,7 +215,13 @@ class AtprotoOAuthService {
|
||||
// Detect PDS based on handle
|
||||
const pdsUrl = await this.detectPDSFromHandle(handle);
|
||||
|
||||
// For all handles, use the default OAuth client (no re-initialization)
|
||||
// Re-initialize OAuth client with correct PDS if needed
|
||||
if (pdsUrl !== 'https://bsky.social') {
|
||||
this.oauthClient = await BrowserOAuthClient.load({
|
||||
clientId: this.getClientId(),
|
||||
handleResolver: pdsUrl,
|
||||
});
|
||||
}
|
||||
|
||||
// OAuth client initialized
|
||||
|
||||
@@ -611,4 +591,10 @@ class AtprotoOAuthService {
|
||||
}
|
||||
|
||||
export const atprotoOAuthService = new AtprotoOAuthService();
|
||||
|
||||
// Debug: Make service available globally for testing
|
||||
if (typeof window !== 'undefined') {
|
||||
(window as any).atprotoOAuthService = atprotoOAuthService;
|
||||
}
|
||||
|
||||
export type { AtprotoSession };
|
||||
|
Reference in New Issue
Block a user