import React, { useState } from 'react'; import { motion } from 'framer-motion'; import { authService } from '../services/auth'; import { atprotoOAuthService } from '../services/atproto-oauth'; import '../styles/Login.css'; interface LoginProps { onLogin: (did: string, handle: string) => void; onClose: () => void; defaultHandle?: string; } export const Login: React.FC = ({ onLogin, onClose, defaultHandle }) => { const [loginMode, setLoginMode] = useState<'oauth' | 'legacy'>('oauth'); const [identifier, setIdentifier] = useState(defaultHandle || ''); const [password, setPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const handleOAuthLogin = async () => { setError(null); setIsLoading(true); try { // Prompt for handle if not provided const handle = identifier.trim() || undefined; await atprotoOAuthService.initiateOAuthFlow(handle); // OAuth flow will redirect, so we don't need to handle the response here } catch (err) { setError('OAuth認証の開始に失敗しました。'); setIsLoading(false); } }; const handleLegacyLogin = async (e: React.FormEvent) => { e.preventDefault(); setError(null); setIsLoading(true); try { const response = await authService.login(identifier, password); onLogin(response.did, response.handle); } catch (err) { setError('ログインに失敗しました。認証情報を確認してください。'); } finally { setIsLoading(false); } }; return ( e.stopPropagation()} >

atprotoログイン

{loginMode === 'oauth' ? (

🔐 OAuth 2.1 認証

より安全で標準準拠の認証方式です。 ブラウザが一時的にatproto認証サーバーにリダイレクトされます。

{(window.location.hostname === '127.0.0.1' || window.location.hostname === 'localhost') && (
🛠️ 開発環境: モック認証を使用します(実際のBlueskyにはアクセスしません)
)}
setIdentifier(e.target.value)} placeholder="your.handle.bsky.social" required disabled={isLoading} />
{error && (
{error}
)}
) : (
setIdentifier(e.target.value)} placeholder="your.handle または did:plc:..." required disabled={isLoading} />
setPassword(e.target.value)} placeholder="アプリパスワード" required disabled={isLoading} /> メインパスワードではなく、 アプリパスワード を使用してください
{error && (
{error}
)}
)}

ai.logはatprotoアカウントを使用します。 コメントはあなたのPDSに保存されます。

); };