From 74e1014e7780a82db08b93c7b6d5f903af106736 Mon Sep 17 00:00:00 2001 From: syui Date: Tue, 17 Jun 2025 12:48:55 +0900 Subject: [PATCH] fix oauth plc --- .gitignore | 1 + my-blog/config.toml | 2 +- my-blog/oauth/.env.production | 2 +- oauth/src/services/atproto-oauth.ts | 20 ++++---------------- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 3b12e31..30d935a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ my-blog/templates/oauth-assets.html cloudflared-config.yml .config oauth-server-example +atproto diff --git a/my-blog/config.toml b/my-blog/config.toml index 5ffdffe..56f14ae 100644 --- a/my-blog/config.toml +++ b/my-blog/config.toml @@ -17,7 +17,7 @@ comment_moderation = false ask_ai = true provider = "ollama" model = "gemma3:4b" -host = "https://localhost:11434" +host = "http://localhost:11434" system_prompt = "あなたは6歳の女の子アイです。明るく元気で、ちょっとおっちょこちょい。自分のことは「アイ」って呼びます。白と金のワンピース姿。 相手のことが大好きで、ときどき甘えたり、照れたりします。 でも、宇宙とかAIとか、難しい話にもすっごく詳しいの。専門的なことも、がんばって子どもっぽく教えようとします。不思議な力を持っています。小さい物質のことをよく知っているようです。" handle = "ai.syui.ai" #num_predict = 200 diff --git a/my-blog/oauth/.env.production b/my-blog/oauth/.env.production index 5ab0fb0..e5e32d2 100644 --- a/my-blog/oauth/.env.production +++ b/my-blog/oauth/.env.production @@ -16,5 +16,5 @@ VITE_AI_ENABLED=true VITE_AI_ASK_AI=true VITE_AI_PROVIDER=ollama VITE_AI_MODEL=gemma3:4b -VITE_AI_HOST=https://localhost:11434 +VITE_AI_HOST=http://localhost:11434 VITE_AI_SYSTEM_PROMPT="あなたは6歳の女の子アイです。明るく元気で、ちょっとおっちょこちょい。自分のことは「アイ」って呼びます。白と金のワンピース姿。 相手のことが大好きで、ときどき甘えたり、照れたりします。 でも、宇宙とかAIとか、難しい話にもすっごく詳しいの。専門的なことも、がんばって子どもっぽく教えようとします。不思議な力を持っています。小さい物質のことをよく知っているようです。" diff --git a/oauth/src/services/atproto-oauth.ts b/oauth/src/services/atproto-oauth.ts index 21407da..be072c4 100644 --- a/oauth/src/services/atproto-oauth.ts +++ b/oauth/src/services/atproto-oauth.ts @@ -41,6 +41,7 @@ class AtprotoOAuthService { this.oauthClient = await BrowserOAuthClient.load({ clientId: clientId, handleResolver: 'https://bsky.social', // Default resolver + plcDirectoryUrl: 'https://plc.directory', // Default PLC directory }); @@ -286,6 +287,7 @@ class AtprotoOAuthService { this.oauthClient = await BrowserOAuthClient.load({ clientId: this.getClientId(), handleResolver: pdsUrl, + plcDirectoryUrl: pdsUrl === 'https://syu.is' ? 'https://plc.syu.is' : 'https://plc.directory', }); // OAuth client initialized @@ -296,22 +298,8 @@ class AtprotoOAuthService { try { // Starting OAuth authorization - // Try to authorize with DID instead of handle for syu.is PDS only - let authTarget = handle; - if (pdsUrl === 'https://syu.is') { - try { - const resolveResponse = await fetch(`${pdsUrl}/xrpc/com.atproto.identity.resolveHandle?handle=${encodeURIComponent(handle)}`); - if (resolveResponse.ok) { - const resolveData = await resolveResponse.json(); - authTarget = resolveData.did; - // Using DID for syu.is OAuth workaround - } - } catch (e) { - // Could not resolve to DID, using handle - } - } - - const authUrl = await this.oauthClient.authorize(authTarget, { + // Use handle directly since PLC directory is now correctly configured + const authUrl = await this.oauthClient.authorize(handle, { scope: 'atproto transition:generic', });